fix(release): capture the lockfile baseline before anything can rewrite it - #2573
Open
glennmichael123 wants to merge 1 commit into
Open
fix(release): capture the lockfile baseline before anything can rewrite it#2573glennmichael123 wants to merge 1 commit into
glennmichael123 wants to merge 1 commit into
Conversation
…te it bump.ts guards against releasing a lockfile in the wrong format: it compares the version bun regenerated against the version already committed, and aborts when they disagree. The guard is correct. Its baseline was read too late. `refreshPantryLock()` runs `pantry install`, which reaches for Bun and rewrites bun.lock once `pinLockstepDeps` has changed hundreds of manifests. The baseline was read after that call, so on a machine whose Bun predates the committed format both sides of the comparison were the already-downgraded version. The guard passed on exactly the lockfile it exists to reject. That is how v0.74.33 committed a lockfileVersion 1 lockfile into a repository that requires v2, tagged it, and pushed - CI failed on the release commit, and the tag had to be deleted and the commit reverted. Read both lockfiles before the pantry refresh and compare against that. Also restore pantry.lock alongside bun.lock on every abort. Only bun.lock was restored before, so a release that stopped here left a rewritten pantry.lock in the working tree - and where the pinned toolchain cannot be downloaded, that rewrite silently drops the `bun.sh` pin from it. Verified end to end on a machine with the older Bun, with pushes blocked at the remote: the release now aborts with Release aborted: regenerating bun.lock produced lockfileVersion 1, but the committed one is v2 - this machine's Bun is older than the one that wrote the committed lockfile. exits 1, creates no commit and no tag, and leaves bun.lock at v2 and pantry.lock with its system block intact. Before this change the same command on the same machine committed, tagged and pushed.
@stacksjs/action-runner
@stacksjs/actions
@stacksjs/ai
@stacksjs/alias
@stacksjs/analytics
@stacksjs/api
@stacksjs/arrays
@stacksjs/audio
@stacksjs/auth
@stacksjs/browser
@stacksjs/browser-extension
@stacksjs/buddy
@stacksjs/build
@stacksjs/cache
@stacksjs/calendar-api
@stacksjs/charts
@stacksjs/chat
@stacksjs/cli
@stacksjs/cloud
@stacksjs/cms
@stacksjs/collections
@stacksjs/commerce
@stacksjs/composables
@stacksjs/config
@stacksjs/cron
@stacksjs/database
@stacksjs/datetime
@stacksjs/defaults
@stacksjs/desktop-build
@stacksjs/dns
@stacksjs/docs
@stacksjs/email
@stacksjs/enums
@stacksjs/env
@stacksjs/error-handling
@stacksjs/events
@stacksjs/faker
@stacksjs/feature-flags
@stacksjs/features
@stacksjs/forms
@stacksjs/git
@stacksjs/github
@stacksjs/health
@stacksjs/http
@stacksjs/i18n
@stacksjs/image
@stacksjs/lint
@stacksjs/logging
@stacksjs/mobile
@stacksjs/model-meta
@stacksjs/newsletter
@stacksjs/notifications
@stacksjs/objects
@stacksjs/orm
@stacksjs/pagination
@stacksjs/path
@stacksjs/payments
@stacksjs/push
@stacksjs/query-builder
@stacksjs/queue
@stacksjs/realtime
@stacksjs/registry
@stacksjs/repl
@stacksjs/router
@stacksjs/scheduler
@stacksjs/search-engine
@stacksjs/security
@stacksjs/server
@stacksjs/shell
@stacksjs/sites
@stacksjs/skills
@stacksjs/slug
@stacksjs/sms
@stacksjs/socials
@stacksjs/storage
@stacksjs/strings
@stacksjs/testing
@stacksjs/tinker
@stacksjs/tunnel
@stacksjs/types
@stacksjs/ui
@stacksjs/utils
@stacksjs/validation
@stacksjs/video
@stacksjs/whois
commit: |
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.
The bug
bump.tsalready guards against releasing a lockfile in the wrong format. It compares the version Bun just regenerated against the version already committed, and aborts when they disagree — with a carefully written message that names which side is stale.The guard is correct. Its baseline was read too late.
refreshPantryLock()runspantry install, which reaches for Bun and rewritesbun.lockoncepinLockstepDepshas changed the manifests. So on a machine whose Bun predates the committed format,bun.lockwas already downgraded by line 311 — andexpectedandproducedwere both the downgraded version. The guard compared the corrupted file against itself, passed, and let the release continue.That is how v0.74.33 committed a
lockfileVersion: 1lockfile into a repository that requires v2, tagged it and pushed. CI failed on the release commit; the tag had to be deleted and the commit reverted.The fix
Capture both lockfiles before the pantry refresh, and compare against that.
Also restore
pantry.lockalongsidebun.lockon every abort path. Onlybun.lockwas restored before, so a release that stopped here left a rewrittenpantry.lockin the working tree — and on a machine that cannot download the pinned toolchain, that rewrite silently drops thebun.shpin from it. All three aborts (failed regeneration, regeneration that wrote nothing, format mismatch) now go through onerestoreCommittedLockfiles().refreshPantryLock's own internal restore is untouched — it is correct and unrelated.Verified end to end
Not just unit-tested. I ran the real
./buddy release --bump patchon the machine with the older Bun (1.3.14 against a repo pinning 1.4.1 indeps.yml), withremote.origin.pushurlpointed at a nonexistent path so nothing could escape if the fix were wrong.Result:
1bun.lockpantry.lockbun.shpins intactBefore this change, the identical command on the identical machine committed, tagged and pushed.
Tests
Two added to
release-artifacts.test.ts, which readsbump.tsas source because it runs its release on import:captures the lockfile baseline before anything can rewrite it— asserts by source position that the capture precedes bothrefreshPantryLock()and the regeneration, and that the comparison reads that capture rather than the working tree. This is the actual regression: nothing about the guard's own logic was wrong, only when its input was read.every abort path restores both committed lockfiles— pins the shared restore and that no abort inside the block falls back to the single-file version.The existing
preserves the canonical lockfile format during a releasetest pins the exactexpectedLockfileVersionline, so I kept thepreviousLockname rather than renaming through it.Checks
release-artifacts9 pass / 0 fail,release-preflight13 pass / 0 fail./buddy lint— exit 0, 0 errors and 0 warnings across 3449 filesbun run typecheck— 13 pre-existing errors, none inbump.ts. That is two fewer than the 15 I measured yesterday; both differences are unrelated resolution errors (stx generateCss,ts-css/engine) that cleared when the verification runs'bun installrefreshed node_modules, not anything this change did.Note
This does not make releases possible from a machine with the wrong toolchain — it makes them fail there instead of shipping something broken. Releasing still needs Bun 1.4.1 and a working
pantry install; on this machinepantry installreportsbun.sh@1.4.1 (DownloadFailed), which is a separate problem.🤖 Generated with Claude Code