Repository navigation
Fix rollback reinstall note for vendored gems (#2214) - #2215
Conversation
Refs #2214. Assisted-by: Claude Code:claude-fable-5-2 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeQWcPFYLN6RCQyh8RM
A gem that was only ever vendored has no patched byte in a gem home: Bundler loaded it from .socket/vendor. Rollback counted it as keeping its patched bytes anyway, because only a refreshed or in-place-restored copy was left out, and --json pushed reinstall_required whenever anything was unwired. The vendored gem unwind now reports the gems whose installed copies are proven to be the upstream build (the archive in the gem home has the verified upstream sha256 and no recorded patch is in the files) or that are not installed. Rollback leaves them out, and derives the --json warning from the same count as the human note. Fixes #2214. Assisted-by: Claude Code:claude-fable-5-2 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeQWcPFYLN6RCQyh8RM
Review found the first cut too generous: a copy agent mode patched in place sits beside the upstream archive, a gem with no copy found may live in a gem home this run cannot see, and a partly patched copy does not hold the whole patch. A vendored gem is now left out of rollback's reinstall count only when it has an installed copy and every copy is proven upstream: its archive has the verified upstream sha256 and every file of the gem's ledger record is in its pre-patch state. Refs #2214. Assisted-by: Claude Code:claude-fable-5-2 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeQWcPFYLN6RCQyh8RM
The get-vendored capstone installs rack with a real Bundler and vendors it through a detached ledger entry. Roll it back at the end: the pair is restored byte for byte, Bundler's own install was upstream all along, and no reinstall_required warning is raised. Refs #2214. Assisted-by: Claude Code:claude-fable-5-2 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeQWcPFYLN6RCQyh8RM
|
[agent] bugbot run Generated by Claude Code |
PR SummaryMedium Risk Overview Gem unwind now tracks Rollback uses one Contract and ecosystem docs describe the rule; e2e tests cover only-vendored rollback, unjudged installs, and agent-patched-in-place cases. Reviewed by Cursor Bugbot for commit a0c0ff2. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit a0c0ff2. Configure here.
verify_file_patch says Ready for a file the patch adds when it is there with other content, since apply overwrites it. For the proof that an installed gem never got its patch, only the file's absence counts. Refs #2214. Assisted-by: Claude Code:claude-fable-5-2 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeQWcPFYLN6RCQyh8RM
|
[agent] PR shepherd: review brief for the approver What it does Risk Look here
Verified
Changes I made Open questions Generated by Claude Code |
Wenxin Jiang (Wenxin-Jiang)
left a comment
There was a problem hiding this comment.
[agent] Reviewed the installed-gem verification and both rollback outputs. The upstream archive and pre-patch file checks gate suppression of the same reinstall warning in human and JSON output.

LLM Description written by Claude Code:claude-fable-5-2
Fixes #2214
Summary
socket-patch rollbackof a gem that was only ever vendored ended with "Note: 1 unwired package keeps its patched bytes in installed trees until the next package-manager install", and--jsoncarriedreinstall_required. Neither was true: vendored mode never writes to a gem home, so Bundler's own install was the upstream build all along.After this change rollback leaves a vendored gem out of that count when it can prove the installed copies are the upstream build, and the
--jsonwarning is derived from the same count as the human note.Root cause
Two things in
commands/rollback.rs:reinstall_requiredwas pushed whenever anything was unwired, with no filter, so it disagreed with the human note even in cases the note already handled (a refreshed gem, a package restored in place).The fix
gem_refresh::after_vendored_unwindnow also reportsupstream_installs: the unwound gems that have an installed copy and whose every copy is proven upstream. The proof is two-fold: the archive RubyGems installed the copy from (<home>/cache/<leaf>.gem) has the verified upstream sha256, and every file of the gem's ledger record is in its pre-patch state (verify_file_patchsaysReady).cache/, no verified sha256, a ledger entry with no record, a file that is patched, edited or unreadable. The fix only ever removes a warning on positive proof.rollbackcomputes the count once and uses it for both the human note and the--jsonwarning.CLI_CONTRACT.mdanddocs/ecosystems.mddescribe the rule.No change was needed in the
npm/,pypi/orgem/wrappers.Behavior change to review
rollback --jsonno longer emitsreinstall_requiredin the cases where the human run already printed no note: every unwired package was also restored in place (or found original there), or was a gem the unwind refreshed. This affects every ecosystem, not only gems. No existing test expected the warning in those cases.Evidence
maine2e_redirect_gem_stale_install::rollback_of_an_only_vendored_gem_names_no_reinstall--jsone2e_vendor_gem_build::gem_get_uuid_vendored_fresh_checkout_bundle_install(new rollback step, real Bundler 4.0.18 / Ruby 3.3.6)vendored_unwind_restores_an_install_a_hosted_scan_patched(new assertion)reinstall_requiredafter a refreshrollback_still_names_a_reinstall_for_an_install_it_could_not_judgerollback_never_calls_an_agent_patched_install_upstreamLocal runs:
cargo test -p socket-patch-cli --no-fail-fast: 5,671 passed, 5 failed. The five are write-failure tests (in_process_redirectx3,repairx2) that cannot fail a write when run as root, which this sandbox does; none touches rollback or gems. That run predates the last two commits; after them I re-ran the lib tests and therollback,in_process_rollback_*,mode_migration_vlt,mode_migration_pypiand gem suites, all green.e2e_vendor_gem_build,e2e_redirect_gem_build,e2e_redirect_gem_stale_installwith--include-ignored(real Bundler): 20, 55 and 62 passed.cargo clippy --locked --workspace --all-features -- -D warnings(CI's command): clean.--all-targetsreports errors onmaintoo, all in files this PR does not touch.e2e_gemneeds the live Socket API and could not run here.Review
/code-review highran on the first cut and found three cases where the proof was too generous (a copy agent mode patched in place beside the upstream archive, a gem with no copy found, a partly patched copy). All three are fixed in the second commit by requiring the record-file proof and an installed copy. Two findings are not fixed:cache/, still gets the note: nothing proves its copy upstream. This is the old behavior; the docs say when the note is dropped.rollback --dry-runstill counts every vendored gem: the gem unwind does not judge installed copies on a dry run.CLI_CONTRACT.mdsays so.Bugbot
One finding, fixed in the last commit: a file the patch adds that is present with other content counted as unpatched.
is_unpatchednow requires such a file to be absent;gem_refresh::tests::is_unpatched_needs_every_record_file_in_its_pre_patch_statecovers it.Follow-ups
apply(agent mode) and then standalonevendorof the same gem,rollbackremoves the manifest record and the vendoring but leaves the installed copy patched. The only trace is thisreinstall_requiredwarning, whose advice ("the next package-manager install") does not help with Bundler, which keeps an installed gem.rollback_never_calls_an_agent_patched_install_upstreampins that the warning stays; the leftover copy deserves its own issue.https://claude.ai/code/session_011f9aeQWcPFYLN6RCQyh8RM
Generated by Claude Code