Skip to content

Fix hosted cargo pin of registry = "crates-io" (#386) - #1412

Merged
Mikola Lysenko (mikolalysenko) merged 5 commits into
mainfrom
agent/fix-cargo-crates-io-registry-pin
Oct 12, 2026
Merged

Mikola Lysenko (mikolalysenko) merged 5 commits into
mainfrom
agent/fix-cargo-crates-io-registry-pin

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

LLM Description written by Claude Code:claude-opus-5-5

Fixes #386

Summary

scan --mode hosted now pins a crates.io dependency declared with an explicit registry = "crates-io", in both the inline-table and the [dependencies.x] table spellings, instead of skipping it as "pinned to another registry".

Root cause

The hosted Cargo.toml planner (plan_cargo_toml in patch/redirect/mod.rs) let a registry = … value through only when it was our current pin or a stale socket-patch-<uuid> pin. Every other value was refused, including crates-io, Cargo's built-in name for crates.io. Cargo resolves that declaration exactly like one with no registry key, so hosted mode skipped a dependency it is built to redirect. It reported redirected: 0 and exited 0 with status: success while the project kept building the unpatched crate.

Changes

Tests (red → green)

Issue Test Without fix With fix
#386 redirect::tests::cargo_explicit_crates_io_registry_is_pinned_in_place (inline, single-quoted + comment, table, renamed table with quoted key; idempotent re-run) FAILED: redirect_cargo_toml_dep_unrewritable … pinned to another registry ("crates-io") ok
#386 e2e e2e_redirect_cargo_shapes::cargo_hosted_explicit_crates_io_registry_is_pinned (real cargo: scan, fresh --locked build links the patched crate, VEX, remove) FAILED: skipped … no lockfile entry pinning it could be rewritten ok
— upstream::cargo::tests::table_form_line_keeps_its_comment — ok

Local runs on 46af5c2 (c2b3f89 adds the Bugbot CRLF fix; upstream::cargo tests, core clippy and e2e_redirect_cargo_shapes re-run green):

  • cargo fmt --all -- --check: clean
  • cargo clippy --workspace --all-features -- -D warnings: clean
  • cargo test -p socket-patch-core --all-features: 6321 passed, 4 failed. The failures are copy_tree::relax_loop_must_not_traverse_symlinked_root, vlt_heal::an_unremovable_hidden_lock_keeps_every_store_entry, pypi_poetry::wire_write_failure… and pypi_requirements::wire_failure_rolls_back…. All four are chmod-based tests that fail because the agent sandbox runs as root, and they're unrelated (see Go go.work audit: false NotAMember for a use path through a missing dir on macOS (breaks macOS test job) #1409 for the same note).
  • SOCKET_PATCH_CARGO_E2E_REQUIRED=1 cargo test -p socket-patch-cli --all-features --test e2e_redirect_cargo_shapes --test mode_migration_cargo --test e2e_redirect_cargo_build: 31 / 29 / 22 passed
  • cargo test -p socket-patch-cli --lib --test in_process_cargo_apply: ok
  • The full cargo test --workspace couldn't finish locally because the sandbox ran out of disk linking ~100 CLI test binaries. CI covers it.
  • No wrapper changes: the fix is in core only, and npm/, pypi/ and gem/ just dispatch to the binary.

/code-review high: findings not fixed

Not in scope

#757 (multi-line inline tables) touches the same planner but has a different cause: the planner reads one line per inline table. It needs the planner moved onto toml_edit and the upstream restore taught multi-line edits.

🤖 Generated with Claude Code


Generated by Claude Code

Assisted-by: Claude Code:claude-opus-5-5
Hosted cargo scan skipped a dependency declared with
`registry = "crates-io"`, warning that it was pinned to another
registry. `crates-io` is Cargo's built-in name for crates.io, so the
declaration resolves exactly like one with no registry key, and the
project kept building the unpatched crate while scan reported
success.

The Cargo.toml pin now overwrites a `crates-io` value in place, the
same way it supersedes an earlier socket-patch pin, in both the
inline-table and the [dependencies.x] table spellings. Removing the
patch drops the pin, which leaves the declaration without the
redundant key; cargo resolves it the same way.

Fixes #386

Assisted-by: Claude Code:claude-opus-5-5
The vendored-to-hosted takeover test used `registry = "crates-io"` as
a Cargo.toml spelling the hosted rewriter refuses. Hosted mode now
pins that spelling, so the case would no longer exercise the refusal.
Use a multi-line inline table instead, which hosted mode still
refuses (#757) and vendored mode accepts.

Refs #386

Assisted-by: Claude Code:claude-opus-5-5
Removing a hosted cargo patch dropped a table-form pin line whole,
including any comment the user had on it. Since the pin can now
overwrite a user's `registry = "crates-io"` line in place, that
comment was the user's. The restore now keeps it on its own line.

Also refresh the doc comments that still said only socket-patch pins
are overwritten, and note that a restored crates-io declaration comes
back without the redundant registry key.

Refs #386

Assisted-by: Claude Code:claude-opus-5-5
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review October 12, 2026 02:56
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

BugBot review


Generated by Claude Code

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread crates/socket-patch-core/src/patch/redirect/upstream/cargo.rs
A comment kept from a table-form pin line lost its carriage return on
a CRLF Cargo.toml, so remove left that one line ending in LF. The
comment is now sliced from the raw line, keeping its `\r`.

Refs #386

Assisted-by: Claude Code:claude-opus-5-5
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

BugBot review


Generated by Claude Code

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 c2b3f89. Configure here.

@mikolalysenko Mikola Lysenko (mikolalysenko) added the Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review label Oct 12, 2026
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

Ready for review (burn-down agent)


Generated by Claude Code

@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

Final review brief

What it does
scan --mode hosted used to skip a Cargo dependency written with an explicit registry = "crates-io", treating it as "pinned to another registry". It reported redirected: 0 with status: success while the project kept building the unpatched crate. crates-io is Cargo's built-in name for crates.io, so the planner now overwrites it in place the same way it overwrites a stale socket-patch-<uuid> pin. Every other registry name is still refused.

Risk: low. It's a one-predicate change in the hosted Cargo.toml planner, and it only affects the literal value crates-io. The one visible side effect: remove restores the declaration without the redundant registry = "crates-io" key. Cargo resolves it identically, the module doc says so, and the e2e test asserts the restored bytes.

Look here

Verified

  • I read the full diff. It's consistent with the existing registry != "crates-io" handling at mod.rs:2357. No CHANGELOG change and no unrelated edits.
  • I ran cargo test -p socket-patch-core --lib patch::redirect locally: 748 passed. The 1 failure is vlt_heal::an_unremovable_hidden_lock…, a chmod test that fails because the sandbox runs as root. It's unrelated and also fails on main.
  • Red check: with the one-line predicate change reverted, cargo_explicit_crates_io_registry_is_pinned_in_place fails with "pinned to another registry ("crates-io")".
  • cargo clippy -p socket-patch-core --all-features -- -D warnings (what CI runs) is clean. With --all-targets there are pre-existing lints, but none of them are in this diff.
  • CI: 35/35 non-skipped checks green on c2b3f89 (19 skipped by path filter). Bugbot is clean and its one thread is resolved.

Changes I made: none.

Open questions: none. The contrived triple-quoted spellings in the PR description fail closed and are deferred to #757.

Auto-merge is armed, so approving sends this straight to the merge queue.


Generated by Claude Code

Merged via the queue into main with commit f777807 Oct 12, 2026
54 checks passed
@mikolalysenko
Mikola Lysenko (mikolalysenko) deleted the agent/fix-cargo-crates-io-registry-pin branch October 12, 2026 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hosted cargo redirect refuses a crates.io dependency declared with an explicit registry = "crates-io", treating crates.io as "another registry"

3 participants