Fix Bun lockfile inventory skipping hosted pins (#720) - #722
Mikola Lysenko (mikolalysenko) wants to merge 4 commits into
Conversation
Assisted-by: Claude Code:claude-opus-5-5
A Bun project whose lock carries a Socket-hosted pin lost that package from lockfile-only discovery: the text bun.lock view kept only registry 4-tuples and the bun.lockb view only records with a registry version. On a checkout without node_modules, a hosted re-run never picked up a superseding patch and scan --mode vendored never took the pin over, both reporting success with 0 packages. Recognise the hosted URL tuple (and the digest-less re-save) and the re-pointed binary record by their <name>-<version>.tgz URL leaf, the rule lockfile discovery already reads Bun hosted refs by, matching the pnpm, vlt and yarn berry views. Fixes #720 Assisted-by: Claude Code:claude-opus-5-5
b4e5b7c to
3f03a57
Compare
|
BugBot review Generated by Claude Code |
|
[agent] Generated by Claude Code |
A hosted pin's URL and sha512 belong to the patched artifact, and the lockfile inventory can't tell a Socket host from a foreign one. Keeping the URL let a uuid-bearing URL on any host count as proof that a hosted redirect was still wired, so vex attested a foreign-host lock it must refuse (e2e_vex_lockfile bun::f_uuid_on_a_non_socket_host_is_not_a_patch). Hosted pins are now listed by name and version only, as yarn berry's are, so liveness and pristine fetches behave as before. Refs #720 Assisted-by: Claude Code:claude-opus-5-5
|
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 48487cd. Configure here.
|
[agent] Generated by Claude Code |
|
[burn-down agent] Ready for review at head
Slack announcement not sent: this run has no Slack send tool. Generated by Claude Code |
LLM Description written by Claude Code:claude-opus-5-5
Fixes #720
Summary
On a Bun checkout with no
node_modules(the usual CI shape), a package whose lock entry is a Socket-hosted pin used to disappear from lockfile discovery. This change makes it visible again, so:success, 0 scanned and kept the old uuid;scan --mode vendoredtakes the hosted pin over, where before it reportedsuccess, 0 scanned and left the project hosted.Root cause
The Bun registry views in
crates/socket-patch-core/src/vendor/lock_inventory/bun.rsdropped Socket-hosted pins:bun.lock: only registry 4-tuples[spec, registry, {deps}, sha512]were kept, but a hosted pin is the 3-tuple["name@https://…/name-ver.tgz", {deps}, "sha512-…"];bun.lockb: records without a registry version were dropped, and a hosted record carries a tarball resolution with no version.The pnpm, vlt and yarn berry views already keep hosted pins. Bun was the odd one out.
Fix
hosted_pin_entryrecognises the hosted URL tuple whose URL leaf is the package's own<bare>-<version>.tgz. It also covers the digest-less 2-tuple that a Bun < 1.3.10 re-save leaves. The check goes throughhosted_url_version, the rule VEX discovery already uses to read Bun hosted refs.name@versionwith no URL and no verifier, like yarn berry's hosted pins.vex::discover::redirect_record_live).The first CI run caught the foreign-host problem, from when the entry still carried the URL:
e2e_vex_lockfile bun::f_uuid_on_a_non_socket_host_is_not_a_patchfailed. 48487cd fixes it, and that suite now passes in CI coverage and 286/286 locally.Test evidence
Every new test failed on
mainand passes with the fix:lock_inventory::tests::bun_text_hosted_pins_inventory_as_their_registry_packagelock_inventory::tests::bun_text_hosted_pin_shapes_and_non_pinsbun.lockbhosted recordlock_inventory::tests::bun_binary_hosted_pins_inventory_as_their_registry_packagein_process_vendor_bun_takeover::bun_lockfile_only_hosted_rerun_moves_to_a_superseding_patchscannedPackages0)scan --mode vendoredtakeoverin_process_vendor_bun_takeover::bun_lockfile_only_scan_vendored_takes_over_the_hosted_pinscannedPackages0)CI on 48487cd is fully green:
coverage,teston all OSes,clippy,hosted-e2e, every Pipenv matrix cell, and all 39 native Bun compat jobs from Bun 0.8.1 to 1.4.2 (thelockfile-onlycells passed in both modes).hosted-e2e's first attempt died during corepack setup before any test ran; the re-run passed.Commands run locally (all green):
cargo clippy --workspace --all-features -- -D warningscargo test -p socket-patch-core --all-features --lib: 4845 passed. 4 unrelated permission tests fail only because the sandbox runs as root.cargo test -p socket-patch-core --test redirect_golden --test upstream_restore_golden --test hosted_inventorycargo test -p socket-patch-cli --all-features --test e2e_vex_lockfile --test in_process_vendor_bun_takeover --test covgap_commands_scan_hosted --test vendor_eject_bun_lockb --test mode_migration_bun --test e2e_vex_redirect --test vendor_eject_fresh_checkout --test hosted_memory_parity --test hosted_memory_engine --test in_process_scan --test scan_vendor_e2e --test covgap_commands_scan_mod --test e2e_vexNotes:
cargo fmt --all -- --checkis not clean onmainitself, and CI doesn't run it. The changed files are rustfmt-clean individually.🤖 Generated with Claude Code
https://claude.ai/code/session_01N8TujytRhQrHLiWi5ziPVj
Generated by Claude Code