Fix bun.lockb prerelease order in hash check (#739) - #741
Open
Mikola Lysenko (mikolalysenko) wants to merge 4 commits into
Open
Mikola Lysenko (mikolalysenko) wants to merge 4 commits into
Mikola Lysenko (mikolalysenko) wants to merge 4 commits into
Conversation
Assisted-by: Claude Code:claude-opus-5-5
A bun.lockb holding both X@1.0.0 and X@1.0.0-beta.1 was refused as "package metadata hash does not match the lockfile" before any edit, so hosted mode patched nothing (exiting 0) and vendored mode failed. Running bun install never helped, because Bun's own hash was valid. The hash check re-derives Bun's sorted package list and compared a release with a same-version prerelease as strings, putting the release first. Bun orders the prerelease first, as semver does. Sort it that way in every hash dialect. Adds real Bun-written fixtures for 0.8.1, 1.0.0, 1.1.45 and 1.3.14 with uuid@8.0.0 + uuid@8.0.0-beta.0, each of which was refused before. Fixes #739 Assisted-by: Claude Code:claude-opus-5-5
Adds a "prerelease" shape to the real-Bun binary lock matrix: a project that also installs uuid@8.0.0 and uuid@8.0.0-beta.0 must go through hosted and vendored patching and a frozen install. Refs #739 Assisted-by: Claude Code:claude-opus-5-5
Mikola Lysenko (mikolalysenko)
marked this pull request as ready for review
October 4, 2026 02:49
Collaborator
Author
|
BugBot review Generated by Claude Code |
The VEX discovery golden corpus covers every committed fixture, so the new bun.lockb prerelease-pair fixtures need entries. Each lists its three plain registry packages and nothing else. Refs #739 Assisted-by: Claude Code:claude-opus-5-5
Collaborator
Author
|
BugBot review Generated by Claude Code |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 0b1a2ae. Configure here.
Collaborator
Author
|
[burn-down agent] Ready for review at head
Generated by Claude Code |
This branch has not been deployed
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.
LLM Description written by Claude Code:claude-opus-5-5
Fixes #739
Summary
Some valid
bun.lockbfiles were refused with "package metadata hash does not match the lockfile". This happened whenever the lock held a release and a prerelease of the same version (for exampleuuid@8.0.0anduuid@8.0.0-beta.0). Those locks are now accepted, so hosted and vendored modes can patch these projects. Before this change, hosted mode patched nothing and still exited 0, vendored mode failed, andbun installnever helped, because Bun's stored hash was valid all along.Root cause
BunLockb::meta_hash(crates/socket-patch-core/src/vendor/bun_lockb.rs) recomputes Bun's package metadata hash before any edit, andhash_stylerefuses the lock when no dialect matches. The recomputation sorts packages by name and then by version. When two versions sharedmajor.minor.patchand only one had a prerelease tag, the code compared the prerelease fields as strings, which put the release ("") first. Bun'sVersion.orderWithoutTagputs the prerelease first, as semver precedence does. Real locks from Bun 0.8.1, 1.0.0, 1.1.45 and 1.3.14 confirm Bun's order, in both the legacy and the current hash dialect.Change
meta_hashsort: a prerelease sorts before its release, in every dialect. Ordering between two prereleases is unchanged.tests/fixtures/bun-lockb/prerelease-pair-{0.8.1,1.0.0,1.1.45,1.3.14}. These are real Bun-written locks (Linux x64) withprovenance.json, documented in the fixtures README. Their VEX-discovery goldens were regenerated withSOCKET_PATCH_UPDATE_GOLDEN=1; each lists its three registry packages and nothing else.prereleaseshape in the real-Bune2e_bun_lockbextended matrix: hosted scan, frozen install, VEX and vendored round trip on a project carrying the pair. CI already runs it on Bun 1.0.36 and 1.1.45.Test evidence
vendor::bun_lockb::tests::release_and_same_triple_prerelease_keep_a_valid_metahash(all 4 writers)package metadata hash does not match the lockfilee2e_bun_lockb::native_binary_alias_and_transitive,prereleaseshape (real Bun)status: success,redirected: 0(the issue's fail-open)CI: every workflow on
0b1a2aeis green (CI, Bun, npm, pnpm, vlt and Composer compatibility, Benchmarks, Audit GHA Workflows). Cursor Bugbot reviewed0b1a2aeand found no issues. The earlier redtest/coverageruns on9d2047bwere the VEX golden corpus missing the new fixtures;0b1a2aefixes that.Local gate:
cargo clippy --workspace --all-features -- -D warnings: clean.cargo test --workspace --all-features --no-fail-fast: 214 test binaries pass, including the VEX golden. 12 tests fail locally only: they force write failures with read-only permissions (*_write_failure_*, unremovable-file andcopy_treepermission cases), which the root-run sandbox ignores. None involves the Bun codec, and all pass in CI.cargo fmt --check: no new diffs.mainalready has unrelated fmt drift, and CI has no fmt step.npm/,pypi/,gem/): the fix is entirely inside the Rust lock codec.🤖 Generated with Claude Code
Generated by Claude Code