fix: detect stale CLI builds - #2338
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
wp-codebox/cli-build-provenance/v1evidence after normal and release builds, binding package version, Git commit/ref, source identity, and compiled dist identitywp-codebox doctorfail or warn actionably when source/dist/package provenance differs or the checkout is behind/diverged from its locally available upstreamRefs #1222
Related owner gap: Extra-Chill/homeboy-extensions#2677
Root Cause
The CLI previously reported only a package JSON hash and current Git HEAD. Compiled
distcarried no immutable record of the source/version/commit that produced it, so doctor could not distinguish a fresh build from stale generated output. Release/deploy also correctly treated the private root npm package separately from the WordPress plugin artifact, leaving independently installed global copies untouched.Ownership Boundary
WP Codebox owns its CLI source, build artifacts, package metadata, provenance, and diagnostics. This PR adds only that contract.
The WordPress Homeboy extension owns managed WP Codebox installation/refresh. Its setup currently accepts runnable ambient/global
wp-codebox-workspacecandidates based on runtime and minimum-version probes, including the production~/.opencodeinstall. Extra-Chill/homeboy-extensions#2677 tracks consuming this provenance contract and converging ambient stale installs without adding WP Codebox literals to generic Homeboy or Data Machine Code layers.Provenance And Freshness Contract
packages/cli/dist/cli-build-provenance.jsonrecords package name/version, source SHA-256 identity, dist SHA-256 identity, and build Git commit/ref.WP_CODEBOX_SOURCE_SHAthat differs from checkout HEAD fails loudly.Remediation Behavior
Doctor reports
npm run buildfor stale source/dist checkouts and reinstalling a release artifact for stale packaged installs. Normal CLI commands never fetch, rebuild, or mutate Git. The existing explicitnpm run wp-codebox:source -- ...launcher remains the safe source-checkout rebuild path.Tests
Passed:
npm run buildnpm run test:cli-build-freshnessnpm run smoke -- --command=doctor-command-smokenpm run smoke -- --command=source-checkout-entrypoint-smokenpm run smoke:cli-versionnpm run package:wordpress-pluginnpm run smoke -- --group packagenpm run test:release-targetnpm run test:sharp-release-runtimenpm run test:prepare-declaration-rebuildnpm run test:release-package-coveragewp-codebox doctor --jsonreturnedokwith matching source/dist/commit and explicit local-upstream/no-fetch evidenceThe package-group Docker-backed disposable MySQL E2E reported its existing skip because
docker infois unavailable; all other declared gates passed.No secrets, generated version changes,
CHANGELOG.mdedits, release, deploy, or production source modification occurred.