Repository navigation
Fix vendoring a hosted gem whose patch was superseded (#2129) - #2143
Mikola Lysenko (mikolalysenko) merged 5 commits into
Conversation
Refs #2129. Empty commit that opens the draft PR; the failing test and the fix follow. Assisted-by: Claude Code:claude-fable-5-2
…r-superseded-hosted-patch
Two failing hermetic cases for #2129: a hosted-pinned gem whose installed copy holds an older patch's bytes must be vendored at the newer patch, and a native gem in that state must be refused for its extension. Both report package_not_installed today. 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_011f9aeT7HWFSwgbuzoQv6kJ
A gem on a hosted patch has that patch's bytes installed. Once a newer patch is published, those bytes match neither side of the new record, so the vendored variant probe skipped the gem and the run reported it as package_not_installed, though it is installed and the dry run previewed success. A sole gem candidate under a live hosted pin now passes the probe with its installed dir as the source. The gem backend takes no file from that dir (the copy is the service's build) and still reads its name and gemspec, so a platform gem or a native extension is refused for what it is. PyPI got the matching exemption earlier. Fixes #2129 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_011f9aeT7HWFSwgbuzoQv6kJ
Review follow-ups: a unit test drives CandidateGates::judge for a hosted-pinned gem (with and without an older ledger entry), and the suite's API mocks take the patch uuid so the newer-patch fixture reuses them instead of copying them. 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_011f9aeT7HWFSwgbuzoQv6kJ
|
[agent] bugbot run Generated by Claude Code |
PR SummaryMedium Risk Overview The vendor judge now treats sole hosted gem candidates like PyPI: a new Coverage adds unit tests for the predicate and judge path, plus e2e scenarios for Reviewed by Cursor Bugbot for commit 2f618d2. 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 |
Wenxin Jiang (Wenxin-Jiang)
left a comment
There was a problem hiding this comment.
[agent] Reviewed at 2f618d2. Letting a sole hosted-pinned candidate past a failed variant probe is safe: the installed dir feeds only the name and gemspec refusals in gem_prelude, and materialise_patched_copy builds the vendored copy from the service build checked against the after hashes. Multi-variant gems stay excluded and the refusal and symlink gates still run. Non-blocking: a dry run still previews no native-extension refusal for a hosted gem (unchanged by this PR).
LLM Description written by Claude Code:claude-fable-5-2
Fixes #2129
Summary
A gem on a hosted patch has that patch's bytes installed. Once a newer
patch is published for the same version,
scan --mode vendored(andget <uuid> --mode vendored) failed withpackage_not_installed/"no installed package found on disk" and exit 1, though the gem is
installed and
--dry-runpreviewed success. The gem is now vendored atthe newer patch, as it already was on a checkout with no gems installed.
Root cause
The vendor loop judges each candidate of a release-variant ecosystem with
a variant probe (
CandidateGates::judgeincrates/socket-patch-cli/src/commands/vendor.rs): it hashes one patchtarget in the installed dir against the record. The installed copy holds
the older hosted patch's bytes, which match neither the before nor the
after hash of the newer record, so the candidate was skipped and later
reported as not installed. PyPI got an exemption for a live hosted pin in
#1713. Gems were left out because the gem backend reads the installed
dir to refuse a platform gem.
Fix
A sole gem candidate that the lockfiles still pin hosted passes a failed
probe and keeps its installed dir as the source (
hosted_gem_install).That is safe because the gem backend takes no file from the installed
dir: the vendored copy is always the patch service's build, verified
against the record's after hashes. The backend still reads the dir's name
and its gemspec, so a platform gem or a gem with a native extension is
refused for what it is instead of "not installed". The PyPI path (a
stand-in source) is unchanged.
No file under
docs/orCLI_CONTRACT.mdchanges:docs/ecosystems.mdalready says vendoring a hosted gem works and leaves installed copies
alone.
Evidence
e2e_redirect_gem_stale_install::vendored_takeover_of_a_hosted_gem_whose_patch_was_supersededscan --mode vendoredandget --mode vendored: dry run, real run (pair wired to the newer uuid, vendored copy is the newer patch, gem home untouched), and a no-op re-rune2e_redirect_gem_stale_install::vendored_takeover_of_a_superseded_native_gem_names_the_extensionnative_extensions_unsupported, hosted pin keptvendor::plan_gate_tests::judge_sends_a_hosted_gem_on_from_its_installed_dirvendor::plan_gate_tests::hosted_pin_keeps_a_gem_install_as_the_sourceThe two end-to-end tests were committed first and failed with
package_not_installed(commit 81d12e1); they pass after abff7a2.Local runs (Ruby 3.3.6, Bundler 4.0.18):
cargo test -p socket-patch-cli --lib: 957 passedcargo test -p socket-patch-cli --test e2e_redirect_gem_stale_install: 54 passedcargo test -p socket-patch-cli --test e2e_redirect_gem_build --test e2e_vendor_gem_build -- --ignored: 48 and 11 passedcargo clippy --locked -p socket-patch-cli --all-features -- -D warnings(CI's form): clean.With
--all-targetsclippy reports errors in files this PR does nottouch (
tests/prebuilt_common/mod.rs,tests/common/mod.rs,src/commands/vendored_backend/repair.rstest code); none is in thetwo changed files.
Review (
/code-review high)No correctness finding. Applied: the judge-level unit test, and the
suite's API mocks now take the patch uuid so the newer-patch fixture
reuses them. Not applied, with reasons:
?platform=rubybeside a native platform record) is still skipped whenits installed copy is superseded. The hosted pin names no variant, so
picking one needs its own rule; the sole-candidate limit is the same
one PyPI has and never vendors a wrong variant.
(superseded or not): the scan preview checks only the manifest and
Gemfile declaration refusals. The real run refuses and keeps the hosted
pin. This predates the PR and is a follow-up.
vendor(eject) vendors the uuid the lock pins and is unchanged.https://claude.ai/code/session_011f9aeT7HWFSwgbuzoQv6kJ
Generated by Claude Code