Repository navigation
Fix vendored re-scan of a gem patched in another mode (#2269) - #2274
Mikola Lysenko (mikolalysenko) wants to merge 4 commits into
Conversation
Refs #2269. A vendored scan fails on every run for a gem it refuses to vendor even after the gem holds its patch in the mode the refusal names. Assisted-by: Claude Code:claude-fable-5-2
A gem with a native extension that holds the selected patch in hosted or agent mode should be a skip of scan --mode vendored, not a failure on every run (#2269). Both tests fail today; the third pins that a native gem patched in no mode is still refused. Assisted-by: Claude Code:claude-fable-5-2
Vendored mode refuses a gem that builds a native extension and names hosted or agent mode as the way to patch it. The vendor loop had no outcome for a gem that already holds the selected patch there, so every later scan --mode vendored raised the refusal again, counted the gem as failed and as left to patch, and exited 1. A gem refused with native_extensions_unsupported is now the skip vendor_gem_patched_in_other_mode when the lock still pins the same patch hosted, or the manifest records it and the installed copy holds it as agent mode leaves it. The closing totals count it as patched. A native gem that holds another patch, or none, is refused as before. Fixes #2269 Assisted-by: Claude Code:claude-fable-5-2
Review of the skip found two cases it should not cover. The agent verdict read one installed copy, where vex and apply --check judge every copy, so an unpatched copy in the tree of another Ruby was skipped as patched. And a hosted pin counted on its uuid alone, so a pin over an install that is still the upstream gem closed the scan with "Nothing left to patch". The skip now needs every installed copy of the gem to hold the patch: a hosted copy by its files, a copy patched in place by its rebuilt extension as well. Otherwise the refusal stands as before. The second place that raises native_extensions_unsupported uses the constant. Refs #2269 Assisted-by: Claude Code:claude-fable-5-2
|
bugbot run Generated by Claude Code |
PR SummaryMedium Risk Overview Adds Reviewed by Cursor Bugbot for commit 53a6a67. Configure here. |
|
[agent] The only failing test is
Generated by Claude Code |
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 53a6a67. Configure here.
|
[agent] PR shepherd: review brief for the approver What it does Risk: medium. A refusal that used to exit 1 now exits 0, so a wrong match would report an unpatched gem as patched. That is guarded by checking every crawled copy ( Look here
Verified
Changes I made: none. Open questions: none. Generated by Claude Code |

LLM Description written by Claude Code:claude-fable-5-2
Fixes #2269
Summary
Vendored mode refuses a gem that builds a native extension (
native_extensions_unsupported) and tells the user to patch it with--mode hostedor--mode agent. After the user did that, every laterscan --mode vendoredraised the same refusal, counted the gem as failed and as "left to patch", and exited 1. A stock Rails Gemfile has such gems (json, puma, bootsnap, racc), so every vendored Ruby project ended up there.Such a gem is now a skip,
vendor_gem_patched_in_other_mode:The run exits 0 when nothing else failed, the closing totals count the gem as patched, and nothing is written: the hosted pin, the manifest record and the installed copies stay as they were.
Root cause
The vendor loop had two outcomes for a backend refusal: one of a fixed list of benign codes (a skip), or a failure. It had none for "the remedy this refusal names is already in place".
The change
crates/socket-patch-cli/src/commands/vendor.rs: a backend refusal withnative_extensions_unsupportedgoes throughsettle_gem_refusal. It becomes the skip when the gem holds the patch the run selected:live_pinis cleared when this run's restore of the upstream entry stands, so a gem the takeover left un-hosted is never called hosted.vexandapply --checkuse (rebuilt extension included).crates/socket-patch-core: the two code constants, the skip inrefusal_is_benign, andgem_copies_patched_in_placeover the existing every-copy gem verdict.scancount the skip as a patch in place, likealready_vendored.CLI_CONTRACT.md(code table) anddocs/ecosystems.md("Ruby gems: gems vendored mode refuses") describe the skip and when the refusal still stands.What still fails, on purpose (do no harm: never report a gem as patched that isn't):
vendored_takeover_of_a_superseded_native_gem_names_the_extensiontest keeps this);In each of these the refusal's own remedy, followed, puts the patch in place, and the next vendored scan skips the gem.
Evidence
Tests, all in
crates/socket-patch-cli/tests/e2e_redirect_gem_stale_install.rs. The first commit adds them failing; the fix turns them green.vendored_scan_skips_a_native_gem_that_holds_the_patch_in_hosted_modescan --mode vendoredtwice (JSON), a human run ("Nothing left to patch", no error), andget <uuid> --mode vendored; the pair and the gem home are byte-identicalvendored_scan_skips_a_native_gem_that_holds_the_patch_in_agent_modevendored_scan_still_refuses_a_native_gem_that_is_not_patchednative_extensions_unsupporteda_gem_patched_in_another_mode_is_a_skip_and_its_refusal_is_not(core,vendor/refusals.rs)Run locally (Ruby 3.3.6, Bundler 4.0.18):
cargo clippy --locked --workspace --all-features -- -D warnings(CI's command): clean.cargo test -p socket-patch-core --lib: 8642 passed.cargo test -p socket-patch-cli --lib: 1076 passed.e2e_redirect_gem_stale_install: 70 passed.in_process_vendor: 156 passed.e2e_gem_native_ext_build: 43 passed.in_process_gem_apply,e2e_gem: passed.e2e_vendor_gem_build -- --ignored(real Bundler): 13 passed.cargo clippy ... --all-targetsreports lints in test files this PR does not touch (crawler_ruby_e2e.rs,prebuilt_common/mod.rsand others); they are there without this change too, and CI's clippy does not lint test targets.Review
/code-review highran on the diff. Fixed: the agent verdict read one installed copy only; a hosted pin counted as patched over a stale install; one place still used the code as a literal; the doc named--mode hostedas the remedy for every case.Not fixed here, because each is a different refusal path that fails the same way before this PR and needs its own decision:
groupblock fails every vendored scan withgemfile_declaration_not_editable(raised before the takeover and in the download phase). The same holds forplatform_gem_unsupported. The docs group these with the native-extension refusal, so they probably want the same skip.vendor_prebuilt_required(the service serves no stub for a native gem), notnative_extensions_unsupported.CHECKSUMSlock and the gem registry unreachable, the takeover's restore fails withredirect_revert_failedbefore the backend is asked.scan/get --mode vendoredpreviews a native gem as "would vendor"; it previews neither the refusal nor this skip (existing behavior, and the contract row says so).For the reviewer to decide
scan,get,vendor), asrefusal_is_benigndocuments for the other skips.get <gem> --mode vendoredon such a gem therefore exits 0 with the "Skipping" line instead of 1. If an explicitgetshould keep failing, the conversion can be limited toscan.Bugbot
One finding (the dry run of a hosted native gem would fail where the real run skips). Answered in its thread and resolved: no command reaches that branch for a hosted gem.
vendor --dry-runtakes the eject plan, andscan/get --dry-runare answered by the scan preview, which exits 0.CI
hosted-e2e(and with itci-ok) fails on every PR until #2270 lands: production published a new activestorage 6.0.3 patch that is not in the test's pinned set. That is not from this change.https://claude.ai/code/session_011f9aeNf7JPkrSosgqVrSyG
Generated by Claude Code