Repository navigation
Fix the vendored unwind of a platform gem (#2174) - #2175
Mikola Lysenko (mikolalysenko) merged 5 commits into
Conversation
Claims #2174: the vendored unwind judges only the ruby-platform build of an unwound gem, so a precompiled platform build that a hosted scan replaced stays patched. 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_011f9aeQwRPCRjnzyQ3rqcZr
A gem locked as precompiled platform gems that a hosted scan patched and a vendored run then took over keeps its patched installed copy after rollback, remove and vendor --revert (#2174). The takeover leg of the platform prebuild capstone fails on that until the unwind follows the lock's builds. 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_011f9aeQwRPCRjnzyQ3rqcZr
After a vendored unwind put a gem back on its upstream entry, the refresh looked only for the ruby-platform installed copy (<name>-<version>). A gem vendored from prebuilt platform gems is installed as <name>-<version>-<platform>, so a copy a hosted scan had replaced with the patched build stayed in the gem home: the app kept loading the patch, and bundle pristine failed on the restored checksum. Look for the builds the restored lock names instead, as the refresh that follows already does, and fall back to the ruby-platform gem when the lock names none. Fixes #2174 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_011f9aeQwRPCRjnzyQ3rqcZr
The vendored unwind's check of Bundler's cache dir judged only <name>-<version>.gem, and stopped when the lock had no ruby-platform entry: always, for a gem vendored from prebuilt platform gems. A patched <name>-<version>-<platform>.gem that a bundle cache took under the hosted pin went unnamed, and the next install took it first. Judge the archive of every build the restored lock names, as the hosted restore does, with one warning per archive. Refs #2174 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_011f9aeQwRPCRjnzyQ3rqcZr
Review follow-ups to the vendored unwind's cache dir check: - A gem whose lock names platform builds alone still has its <name>-<version>.gem judged, as the hosted restore judges it. A gem none of whose builds can be judged stays silent. - The takeover e2e leg counts the stale-cache warnings and asserts the archive was judged patched, not unchecked. - CLI_CONTRACT.md states the archive shapes once for the whole upstream_gem_stale_cache row. Refs #2174 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_011f9aeQwRPCRjnzyQ3rqcZr
|
bugbot run Generated by Claude Code |
PR SummaryMedium Risk Overview Vendored unwind refresh ( Stale cache warnings ( Contract text ( Reviewed by Cursor Bugbot for commit 123e56f. 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 123e56f. Configure here.
|
[agent] PR shepherd: review brief for the approver What it does. Fixes #2174. When a precompiled platform gem (nokogiri) went hosted → vendored and was then unwound ( Risk: low. The change only touches the vendored gem unwind's follow-up steps. It reuses the build derivation and the per-token archive check that the hosted restore already ships. Output formats, exit codes and warning codes are unchanged. Vendoring platform gems is new on Look here
Verified
Changes I made: none. Open questions: none. One known limit is described in the PR: with no readable lock, the cache-dir check judges only the ruby-platform archive. A vendored unwind always rewrites the lock, so this case should not come up. Generated by Claude Code |
LLM Description written by Claude Code:claude-fable-5-2
Fixes #2174
Summary
A gem locked as precompiled platform gems (nokogiri) that a hosted scan
patched and a vendored run then took over kept its patched installed
copy after
rollback,removeandvendor --revert. TheGemfilepair came back byte for byte, but the app kept loading the patch, and on a
lock with
CHECKSUMSthe nextbundle pristinefailed on the restoredchecksum after removing the installed gem.
The unwind now brings that copy back to the upstream platform gem, as it
already did for a ruby-platform gem, and names a patched platform archive
left in Bundler's cache dir.
Root cause
A vendored unwind has two follow-ups for a gem it put back on its upstream
entry, and both assumed the gem is the ruby-platform one:
after_vendored_unwind(crates/socket-patch-cli/src/commands/gem_refresh.rs)looked for installed copies under
<name>-<version>only. A platformbuild is installed as
<name>-<version>-<platform>, so nothing wasfound and the refresh never started. The refresh itself
(
refresh_restored) already works by the builds the restored lock names.unwound_stale_cache(crates/socket-patch-core/src/patch/redirect/upstream/gem.rs)judged only
<name>-<version>.gemin Bundler's cache dir, and returnedearly when the lock has no ruby-platform entry, which is always the case
for a gem vendored from prebuilt platform gems. The review of the first
fix found this one.
Vendoring a platform gem is new on
main, so no release has the bug.The change
after_vendored_unwindlooks for the builds the restored lock names(read from disk, no registry request), and falls back to the
ruby-platform gem when the lock names none. The code that derives those
builds moved out of
refresh_restoredintonamed_builds, unchanged.unwound_stale_cachejudges the archive of the ruby-platform gem and ofeach platform build the lock names, with one warning per archive, the way
the hosted restore does. A gem none of whose builds the lock pins a
sha256 for or resolves from rubygems.org is still not judged. It now returns a list; its one caller
(
push_gem_stale_cache) pushes each warning.CLI_CONTRACT.md("Gem stale-install guard", theupstream_gem_stale_cacherow) anddocs/ecosystems.md("Ruby gems:gems already installed") say that platform builds are covered.
No output format, exit code or warning code changes.
Evidence
Ruby 3.3.6, Bundler 4.0.18, Linux x86_64.
e2e_redirect_gem_build:gem_vendored_unwind_restores_a_platform_install_the_hosted_scan_patched(CHECKSUMSlock)removee2e_redirect_gem_build:gem_vendored_unwind_restores_a_platform_install_without_checksumsbundle install,bundle pristineandbundle execafterrollbackvendored_unwind_names_a_patched_platform_archivetests/nokogiri/patch_service.rbdefined?(SOCKET_PATCHED)is"constant",bundle pristinefailsReplaced the installed copy of 1 gem with the upstream build: nokogiri 1.18.10.,defined?(SOCKET_PATCHED)isnil,bundle pristinepasses and nokogiri loadsThe two e2e tests are a takeover leg of the existing platform prebuild
capstone: hosted scan,
get --mode vendored, thenremoveandvendor --revertover copies of the project (each with a patched platformarchive in
vendor/cache) androllbackon the project itself. Theycover all three commands the issue names.
Local runs:
cargo clippy --locked -p socket-patch-core -p socket-patch-cli --all-features -- -D warningsis clean.
e2e_redirect_gem_build(55),e2e_vendor_gem_build(20),e2e_redirect_gem_stale_install(58) ande2e_gem_native_ext_build(52)pass with
--include-ignored, as do the coreredirect::upstreamunittests (203) and the CLI
gem_refreshandvendored_backendunit tests.Notes for the reviewer
cargo clippy --all-targetsreportsduplicate_modandtype_complexityin test targets onmainas well; CI's clippy job doesnot lint test targets, and none of the reports are in lines this PR
touches.
123e56f:ci-okandclippyare green, Bugbot found noissues. The nokogiri and Bazel (RubyGems) compatibility workflows were
cancelled by the trigger race when the PR left draft; re-run once, both
pass.
cannot be vendored (
platform_gem_unsupported), so there is no takeoverleg for it.
/code-review highran on the diff, twice. Fixed: the cache-dir archivecheck above, a stale test comment, a loose e2e assertion, the contract
row's wording, and the ruby-platform archive of a gem whose lock names
platform builds alone (now judged, as the hosted restore judges it).
cannot learn the platform builds and judges the ruby-platform archive
alone. A vendored gem unwind rewrites the lock, so it has one; guessing
builds from file names in the cache dir would name archives of builds
the project does not lock.
https://claude.ai/code/session_011f9aeQwRPCRjnzyQ3rqcZr
Generated by Claude Code