Repository navigation
Fix cargo apply skipping other registry copies (#339) - #1394
Merged
Mikola Lysenko (mikolalysenko) merged 3 commits intoOct 11, 2026
Merged
Conversation
Assisted-by: Claude Code:claude-opus-5-5
A shared CARGO_HOME keeps one extracted copy of a crate per registry index dir: cargo 1.70-1.84 and cargo 1.85+ each unpack and build their own. Agent mode only patched, checked and restored the copy in the first dir, so a project built by the other cargo kept compiling the unpatched crate while apply reported success and vex attested not_affected. Carry every copy the crawler finds, so apply patches them all, apply --check and vex fail on an unpatched one, and rollback restores each one. Fixes #339 Assisted-by: Claude Code:claude-opus-5-5
A pkg:cargo PURL names a crates.io crate, but a private registry or the hosted Socket registry can unpack a different crate with the same name and version into its own registry/src dir. Patch every crates.io copy only, and fall back to the single first-found copy as before when no crates.io copy exists. The regression test now also shows apply --check passing and vex attesting once every copy is patched, so its failure checks can't pass for an unrelated reason. Assisted-by: Claude Code:claude-opus-5-5
Mikola Lysenko (mikolalysenko)
marked this pull request as ready for review
October 11, 2026 17:56
Collaborator
Author
|
BugBot review Generated by Claude Code |
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 73f4a18. Configure here.
Collaborator
Author
|
Ready for review at
Worth a look: the cargo arm of Generated by Claude Code |
Tanmay Singla (Tanmay182003)
approved these changes
Oct 11, 2026
Mikola Lysenko (mikolalysenko)
deleted the
agent/fix-cargo-every-registry-copy
branch
October 11, 2026 19:56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LLM Description written by Claude Code:claude-opus-5-5
Fixes #339
Summary
A shared
CARGO_HOMEkeeps one extracted copy of a crate per registryindex dir:
index.crates.io-6f17d22bba15001f(cargo 1.70–1.84),index.crates.io-1949cf8c6b5b557f(cargo ≥ 1.85), and the pre-1.70 gitindex
github.com-1ecc6299db9ec823. Each cargo builds from its own copy.Agent mode now patches, checks, attests and restores every crates.io
copy, not just the one in the first dir in listing order.
Root cause
The crawler lists every index dir, but the cargo arm of
dispatch_find(
crates/socket-patch-cli/src/ecosystem_dispatch.rs) merged them withmerge_first_wins. Soapply,apply --check,vexandrollback(and the
scan --prunekeep check, throughfind_cargo_copies) onlysaw one copy. A project built by the other cargo kept compiling the
unpatched crate while
applyreported success and VEX attestednot_affected.Fix
merge_cargo_copiesfor the cargo arm. It keeps every copy thatsits in a crates.io index dir (
push_pathdedup, discovery order).The apply loop, rollback and vex already act on every path in the list.
pkg:cargoPURL names a crates.io crate, so a copy with the samename@versionin another registry's dir (a private registry, or thehosted
patch.socket.dev-*registry) is a different crate. It is neverpatched beside crates.io copies, whatever the listing order. When no
crates.io copy exists, it stays the single first-found copy, as before.
This came from
/code-review high.cargo vendortree or--global-prefixis one root, so it stillgives one copy.
every-copy behavior. Dispatch doc comments that still described cargo
as first-wins are updated.
Test evidence
e2e_cargo::agent_mode_covers_every_registry_index_copy(new) buildsa hermetic
CARGO_HOMEwith two crates.io index dirs plus a privateregistry dir, all holding
cfg-if-1.0.0. It checks:applypatches both crates.io copies and leaves the private one alone.apply --checkpasses andvexattestsnot_affected(baseline).apply --checkfailsand
vexdoesn't attest.rollbackrestores both and stillleaves the private crate alone.
merge_first_wins,the test fails with
apply left …/index.crates.io-6f17d22bba15001f/cfg-if-1.0.0 unpatched.With the fix it passes. All 24 tests in
e2e_cargopass.merge_cargo_copies_keeps_every_registry_index_copyandmerge_cargo_copies_prefers_crates_io_over_another_registrypass.cargo fmt --all -- --checkandcargo clippy --workspace --all-features -- -D warningsare clean.cargo test --workspace --all-features --no-fail-fast: every suitepasses except 16 tests, and none of them touch cargo or dispatch.
as root in the agent sandbox. 4 of them are in
socket-patch-core,which this PR doesn't change.
e2e_bun_lockb) needspatches-api.socket.dev, which the sandboxegress proxy blocks.
npm/,pypi/,gem/) only dispatch to the binary, sothey need no change.
Per-issue checklist
agent_mode_covers_every_registry_index_copycovers apply,apply --check, vex and rollback. The merge unit tests cover thedispatch-level contract.
Review notes (
/code-review highfindings not changed)CargoCrawler::crawl_allstill dedupes by PURL across roots. Thatcrawl is the package inventory sent to the patch API (one entry per
crate), not the copy list. Every command that writes or verifies bytes
resolves copies through
dispatch_find.touches now fails
applyinstead of being ignored when it sortedsecond. That copy is still one an old cargo builds from, so failing
loudly is the safe choice. Deleting the stale dir clears it.
🤖 Generated with Claude Code
https://claude.ai/code/session_018K8nQgVxQZtm4DDeDVhfUo
Generated by Claude Code