Repository navigation
Fix hosted cargo dotted-key and literal pins (#757) - #1743
Mikola Lysenko (mikolalysenko) wants to merge 4 commits into
Conversation
Assisted-by: Claude Code:claude-opus-5-5
Hosted cargo scan refused two valid Cargo.toml spellings and left the
crate unpatched with redirect_cargo_toml_dep_unrewritable:
serde.version = "1.0.0" # dotted keys
serde = '1.0.0' # literal-string version
Dotted keys are now gathered per dependency across their table, since
TOML lets them sit anywhere in it, and classified like the table form:
rename, workspace inheritance, path/git, registry-index and an earlier
or crates-io registry. The pin is a new <key>.registry line right after
the version line, using that line's key spelling, indent and line
ending. A rescan moves an earlier pin in place.
A literal-string version is pinned as { version = '...', registry =
"..." }, keeping the user's quotes.
The pin readers resolve a dotted rename's owning crate, and restore
drops the added dotted line and collapses the literal table back to
'...', so remove and rollback leave the manifest byte-identical for
LF, CRLF and BOM files.
Spellings still refused are multi-line string versions and keys nested
deeper than <key>.<field>.
Fixes #757
Assisted-by: Claude Code:claude-opus-5-5
A real-cargo shape pins dotted keys (with a wrapped features array and a rename) and a literal-string version for LF and CRLF manifests, builds against the patched copy offline, and checks remove restores every byte. The vendored-to-hosted takeover test needs spellings hosted mode still refuses, so it now uses multi-line string versions instead of the two spellings that hosted mode pins now. Refs #757 Assisted-by: Claude Code:claude-opus-5-5
Review follow-ups for the dotted-key and literal-string pins:
- A literal version is now pinned registry-first. The earlier spelling
matched what the one-line rewrite writes for a user's own
{ version = '...' } table, so remove collapsed that table into a bare
string. That table now comes back byte-exact.
- A dotted rename whose package value can't be read falls back to the
key, as the table form and the pin readers do.
- A dotted registry value that can't be read is reported as an
unreadable spelling, not as a registry named "".
- Doc comments name the dotted shape and the readers' scan order.
Refs #757
Assisted-by: Claude Code:claude-opus-5-5
|
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 b29ceb4. Configure here.
|
Burn-down agent: labeled Ready for review at head
Generated by Claude Code |
Final review brief (head
|
LLM Description written by Claude Code:claude-opus-5-5
Fixes #757
Finishes #757, which #1735 left open. Hosted cargo now pins the last two rows of the issue's table, dotted keys and literal-string versions. Before this,
scan --mode hostedwarnedredirect_cargo_toml_dep_unrewritableon them and left the crate unpatched.Root cause
Hosted cargo plans
Cargo.tomlpins with a line scanner (plan_cargo_toml). Upstream restore (unpin_line) recognizes only the spellings that scanner writes. Neither had a rule for:serde.version = "1.0.0", or a renamealias.package = "serde"+alias.version = …serde = '1.0.0'Change
[dependencies.<key>]table form: rename,workspace = true, path/git,registry-index, and an existingsocket-patch-*orcrates-ioregistry, which is superseded in place. The pin is a new<key>.registry = "socket-patch-<uuid>"line right after the version line. It reuses that line's key spelling, indent and line ending.serde = '1.0.0'becomesserde = { registry = "…", version = '1.0.0' }. It is written registry-first so restore can tell it apart from a user's own one-line{ version = '…' }table, which the one-line rewrite pins version-first.CargoRegistryPinsand its test oracle) read a dotted pin at the end of its table and resolve a dotted rename's owning crate.unpin_line) drops the added<key>.registryline and collapses the registry-first literal table back to'…'.Spellings still refused, both rare: multi-line string versions (
'''1.0''',"""1.0"""), and keys nested below<key>.<field>. The policy refusals stay as before: path/git,registry-index, another registry, an ambiguous requirement.Tests (red → green)
New tests fail on
mainand pass here:cargo_literal_string_version_is_pinned'…', with a comment, with a quoted key; LF + CRLFcargo_dotted_keys_are_pinnedcrates-iorepin; LF + CRLF; a rescan writes nothingcargo_dotted_workspace_dependency_is_pinned[workspace.dependencies]+serde.workspace = true; another version left alonecargo_dotted_pin_is_superseded_in_placecargo_dotted_unreadable_package_falls_back_to_the_keycargo_socket_registry_pin_reads_back_every_written_shape(+3 shapes)dotted_and_literal_pins_unpin_to_the_original_spellingunpin_lineper spelling; a user's literal table keeps its tablerestore_unpins_dotted_and_literal_pins_byte_exactcargo_hosted_dotted_and_literal_spellings_are_pinnedremove; dotted (LF/CRLF), renamed dotted, literal (LF/CRLF)Without the fix, the e2e test fails with
cfg-if in Cargo.toml cannot be pinned (declared with dotted keys this rewriter does not edit).Updated tests:
cargo_unsupported_spellings_refuse_whole_depnow lists only the refusals that remain, and adds dotted path/git/registry-index/other-registry rows.cargo_dotted_literal_renames_*now expects a pin.cargo_unrewritable_occurrence_skips_dep_entirelyandmode_migration_cargo::takeover_over_unrewritable_spelling_keeps_vendoredswitch to spellings that are still refused.Commands run locally
cargo fmt --all -- --check: cleancargo clippy --workspace --all-features -- -D warnings: cleancargo test -p socket-patch-core --all-features: 6806 passed, 4 failed. The 4 failures arecopy_tree::relax_loop_must_not_traverse_symlinked_root,vlt_heal::an_unremovable_hidden_lock_keeps_every_store_entry,pypi_poetry::wire_write_failure_…andpypi_requirements::wire_failure_…. They are chmod-based tests that can't fail when run as root in this sandbox, and they fail identically on unchangedmain.SOCKET_PATCH_CARGO_E2E_REQUIRED=1(cargo 1.93.1):e2e_redirect_cargo_build23/23,e2e_redirect_cargo_shapes35/35,e2e_vendor_cargo_build40/40,mode_migration_cargo30/30/code-review high
Fixed: the literal-table restore ambiguity, the unreadable dotted
packageandregistryhandling, and stale docs.Not fixed:
toml_editplanner rewrite removes it at the root. This PR keeps to the line-scanner design Fix hosted cargo pins for multi-line inline tables (#757) #1735 extended, so the change stays reviewable.\ron the dotted insert. The table-form insert doesn't, but restore drops either line whole, and copying it keeps a mixed-ending file consistent.https://claude.ai/code/session_011f9aeQKabmsWm4uJyqrMaD
Generated by Claude Code