Repository navigation
Fix vendored scan skipping a gem locked only as platform gems (#2394) - #2447
Mikola Lysenko (mikolalysenko) merged 3 commits into
Conversation
Refs #2394 Assisted-by: Claude Code:claude-fable-5-2
The scan's lockfile supplement named a gem that Gemfile.lock holds only as precompiled platform gems for a hosted run alone. That limit predates vendoring from prebuilt platform gems, so a vendored scan of a checkout with nothing installed never asked the patch service about such a gem: it was skipped without a message and the run ended with "Nothing left to patch." The supplement now names these gems in every mode. A vendored run vendors the gem from the lock alone, and an agent run counts it among the packages that are not installed. The stand-in patch service of the nokogiri end-to-end test now answers a lookup for the gem only when the run asks about it, as the service does, and the vendored scenario scans a checkout with nothing installed first. Fixes #2394 Assisted-by: Claude Code:claude-fable-5-2
Add a hermetic test of the success path: a vendored scan of a checkout with nothing installed vendors a gem the lock holds only as platform gems, one tree per locked platform, when the service has a patch for each. The service of the test answers a lookup for the gem only when the run asks about it. Bring the contract's agent-mode paragraph and the comments that still called these gems hosted-only in line with the code. Refs #2394 Assisted-by: Claude Code:claude-fable-5-2
|
bugbot run Generated by Claude Code |
PR SummaryLow Risk Overview Previously those PURLs were added to discovery only when Docs & tests: Reviewed by Cursor Bugbot for commit 94099f5. Configure here. |
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 94099f5. Configure here.
|
[agent] PR shepherd: review brief for the approver What it does Risk Look here
Verified
Changes I made Open questions Generated by Claude Code |
LLM Description written by Claude Code:claude-fable-5-2
Fixes #2394
Summary
socket-patch scan --mode vendoredon a checkout with nothing installednever asked the patch service about a gem that
Gemfile.lockholds only asprecompiled platform gems (
nokogiri (1.19.7-x86_64-linux-gnu), no plainnokogiri (1.19.7)). The gem was skipped without a message, the run endedwith
Nothing left to patch.and exited 0. That lock is what Bundler 2.xwrites by default, and what the vendored refusal's own remedy
(
bundle lock --remove-platform ruby) leaves behind.Now the scan looks the gem up in every mode. A vendored run vendors it from
the lock alone (or names it when it cannot), and an agent run counts it
among the packages that are not installed.
Root cause
The scan's lockfile supplement (
commands/scan/discovery.rs) adds thepackages the lock resolves that have no installed copy. The Bundler lock
inventory leaves platform-only gems out, and the supplement added them back
for a hosted run alone. That limit predates vendoring from prebuilt platform
gems: the vendored engine has not needed an installed copy since then, but
discovery still never named the gem.
The fix
The supplement names platform-only gems in every mode (one filter removed).
Nothing else in the engine changes.
get --mode vendoredreads the samesupplement, so it finds such a gem on a fresh checkout too.
CLI_CONTRACT.md("Lockfile supplement" and the agent-mode paragraph ongems that are not installed) says so.
No file is written that was not written before for an installed copy: the
vendored path is the one the same scan takes after
bundle install.Evidence
The issue's repro (Ruby 3.3.6, Bundler 4.0.18, nokogiri 1.19.7, 8 platforms,
nothing installed), which gems each scan asks the service about:
mainWith the repository's stand-in patch service, on this branch: the fresh
checkout prints
Vendored 1 package.,vendor --checkverifies it, afrozen
bundle installpasses and Ruby loads the patched nokogiri. A secondscan says
already vendored. An agent scan of the fresh checkout prints the"not yet installed" note for both locked gems, skips the patches and exits 0.
Tests, each red on
mainand green here:platform_only_gem_is_looked_up_on_a_fresh_checkout(
e2e_redirect_gem_stale_install, no Bundler needed) coversFixes #2394: a vendored and an agent scan of a fresh checkout ask aboutthe gem. The vendored run names the gem it skips (one platform has no
patch) and counts its advisory as left to patch. The agent run counts it
as not installed.
platform_only_gem_is_vendored_from_the_lock_alone(same suite): with apatch for every locked platform, the vendored scan writes one tree per
platform, moves the lock to the vendored path and records each platform's
patch in the ledger.
tests/nokogiri/nokogiri_e2e.rb, vendored scenario (real Bundler, realnokogiri): it now first scans a checkout with nothing installed, installs
it frozen and checks Ruby loads the patched gem from the vendored tree.
The stand-in service now answers a lookup for nokogiri only when the run
asks about it, as the real service does. Before that it always answered,
which is why this scenario never caught the bug.
Local runs:
cargo test -p socket-patch-cli --lib(1102 passed);e2e_redirect_gem_stale_install(84),in_process_gem_multi_platform(9),hosted_memory_parity(48),e2e_vex_redirect(39); with real Bundler4.0.18 and
--include-ignored:e2e_vendor_gem_build(21),e2e_redirect_gem_build(57),e2e_gem_native_ext_build(54); the nokogiriscript's
vendored(36 checks) andhosted(38 checks) scenarios onnokogiri 1.18.10.
cargo clippy --locked -p socket-patch-core -p socket-patch-cli --all-features -- -D warnings(CI's form) is clean. With--all-targetsclippy reports errors on this toolchain in test code this PRdoes not touch; none is on a changed line.
Review findings not fixed here
/code-review highran on the diff. Fixed: the missing success-path test,the contract paragraph that still said an agent scan never names these gems,
and three comments that still called them hosted-only. Left out, with
reasons:
newer patch available" for a platform-locked gem that is on the current
fix. Agent and report-only runs compare each platform's patch with the
one uuid the hosted pin records. This already happens on
mainwhen thegem is installed; it is now also reachable on a fresh checkout. It is a
separate comparison bug and worth its own issue.
applyexits 1 (package_not_installed) for a recorded patch of aplatform-only gem that is not installed, while the agent scan now skips it
calmly.
applyis unchanged and an existing unit test pins it. Agentmode only records a patch for an installed copy, so this needs a manifest
committed from another machine. Loosening
applyis a behavior decisionof its own.
patches are not installed" for one gem locked on 8 platforms). The wording
is not new and is the same count Vendored scan prints the
platform_gem_unsupportedrefusal once per platform patch of a gem: 9 identical lines for nokogiri on a default Bundler 4 lock, 31 for three gems, and "9 patches failed" for one gem #2436 reports for vendored mode.https://claude.ai/code/session_011f9aeQTW6Y2zvHzpaEquUN
Generated by Claude Code