Repository navigation
Fix hosted cargo pins for multi-line inline tables (#757) - #1735
Conversation
Assisted-by: Claude Code:claude-opus-5-5
Hosted cargo scan refused a Cargo.toml dependency written as an inline
table whose array wraps onto later lines, the usual rustfmt style for
a long feature list:
serde = { version = "1.0.0", features = [
"derive",
] }
It warned redirect_cargo_toml_dep_unrewritable and left the crate
unpatched. The planner, the pin readers and upstream restore all
assumed an inline table closes on its own line.
A shared reader now follows such a table to its closing brace. It only
lets a line break happen inside an array or a multi-line string, as
TOML 1.0 does, so a break straight after "{" is still refused. The
planner classifies the whole table text and pins it on the opening
line, right after "{". The pin readers read that pin back, and restore
removes exactly the inserted text, so rollback leaves the manifest
byte-identical for LF, CRLF and BOM files.
Refs #757
Assisted-by: Claude Code:claude-opus-5-5
Follow-ups from review of the multi-line inline table support: - Keys or braces that appear only in a comment inside a wrapped features array no longer get the dependency refused as a path, workspace or other-registry entry, or pinned inside the comment. - Every inline table, one-line or wrapped, is now read by the same brace- and string-aware scanner. A "}" inside a string or comment no longer ends it, and a multi-line string may end in extra quotes. - A rescan that picks a newer patch moves an earlier pin on a wrapped table to the new registry, the same as it does for every other spelling. - Restore uses the same scanner to tell a wrapped table's opening line from a one-line table. - A real-cargo e2e shape covers the wrapped spelling for LF and CRLF: scan, offline locked build, vex, and a byte-exact remove. The migration test no longer lists it as a spelling hosted mode refuses. Refs #757 Assisted-by: Claude Code:claude-opus-5-5
|
BugBot review Generated by Claude Code |
A wrapped inline table with an explicit registry = "crates-io" was still refused, while #386 pins the one-line form. Hosted scan now drops that redundant key, with one adjacent comma, and pins the table on its opening line in the spelling restore unpins. remove then leaves the declaration without the key, which cargo resolves the same way, as it does for the one-line form. Unit tests cover the key after "{", in the middle of the opening line and on the closing line. A real-cargo e2e row covers the closing-line spelling. Refs #757 Assisted-by: Claude Code:claude-opus-5-5
|
BugBot review Generated by Claude Code |
The crates-io repin for a wrapped inline table found only the bare key with a double-quoted value. registry = 'crates-io' and "registry" = "crates-io" mean the same thing, and the one-line form already accepts them, but in a wrapped table they still got the dependency refused. The matcher now takes the same key and value spellings as the one-line rewrite. 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 319351f. Configure here.
|
Burn-down agent: labeled Ready for review at head
Generated by Claude Code |
|
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
Refs #757
Root cause
Hosted cargo plans
Cargo.tomlpins with a line scanner that treated every inline table as one line (plan_cargo_tomlincrates/socket-patch-core/src/patch/redirect/mod.rs). It refused a valid TOML 1.0 declaration whose array value wraps, which is rustfmt's style for a long feature list:scan --mode hostedwarnedredirect_cargo_toml_dep_unrewritableand left the crate unpatched, although the same project vendors fine. The pin readers (CargoRegistryPinsand its test oraclecargo_socket_registry_pin) and upstream restore'sunpin_linemade the same one-line assumption.Changes
cargo_inline_table: one brace-, bracket-, string- and comment-aware reader for an inline table. It returns the closing line and the text between the braces, borrowed when the table closes on its own line. It allows a line break only inside an array or a multi-line string, as TOML 1.0 does, so{⏎ version = … }is still refused. Comment text is left out, so a key named only in a comment is not read as one.registry = "<reg>",straight after{). An earlier Socket pin in that spelling is superseded in place. An explicitregistry = "crates-io"(Hosted cargo redirect refuses a crates.io dependency declared with an explicitregistry = "crates-io", treating crates.io as "another registry" #386) anywhere in the wrapped table is dropped and the pin written in that spelling, soremoveleaves the declaration without the redundant key, as it does for one-line tables. Any other registry already named in a wrapped table is still refused, because restore could not unpin it. Lines inside a wrapped table are skipped, so they are never read as entries or headers.CargoRegistryPinsand the oracle read pins out of the same span.rollback/removeleave the manifest byte-identical.Not in this PR (why
Refs, notFixes)#757's acceptance table also lists
serde.version = "1.0.0"(dotted keys) andserde = '1.0.0'(literal string). Both stay refused. Supporting them, and deleting the regex scanner, is the largertoml_editplanner rewrite the issue proposes. I'm leaving the issue open for that.Tests (red → green)
Before the fix, run against
origin/main's core:patch::redirect::tests::cargo_multiline_inline_table_is_pinned_on_its_opening_line(LF and CRLF; comments in the array; a rename): red, refused.patch::redirect::tests::cargo_multiline_inline_table_is_classified_by_its_whole_text(path key after the array; renamed-away table; keys and braces only in comments;"a}"and"""q""""strings; already pinned): red.patch::redirect::tests::cargo_socket_registry_pin_reads_back_every_written_shapewith two new multi-line shapes: red.patch::redirect::tests::cargo_supersede_replaces_previous_multiline_pin: re-pin to a newer patch.upstream::cargo::tests::multiline_inline_table_opening_line_loses_only_the_pinandrestore_unpins_a_multiline_inline_table_byte_exact(LF, CRLF, BOM, CRLF+BOM): red, restore refused.e2e_redirect_cargo_shapes::cargo_hosted_multiline_inline_table_is_pinned(LF and CRLF; cargo 1.93.1): red on main (skipped: no lockfile entry pinning it could be rewritten). Green with the fix: scan, fresh-checkoutcargo fetch --locked+ offlinecargo build --lockedlinks the patched symbol,vexattests,removeis byte-identical.cargo 1.97.0 metadatareads a pinned wrapped declaration (with comments anddefault-features = false) as serde from the Socket registry, with its features kept.mode_migration_cargo::takeover_over_unrewritable_spelling_keeps_vendoredlisted the wrapped table as a spelling hosted mode refuses. Now that it's pinned, I removed that row. The dotted and literal rows stay.Per issue:
Local gates
cargo fmt --all -- --check: clean.cargo clippy --workspace --all-features -- -D warnings: clean.cargo test -p socket-patch-core --all-features --lib: 6795 passed, 4 failed. All 4 are chmod/unremovable-file tests that can't fail as root, which this container runs as:copy_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_…. Fix berry unwind under a user yarn patch (#962) #1733 lists the same tests. None of them touch this diff.SOCKET_PATCH_CARGO_E2E_REQUIRED=1:e2e_redirect_cargo_shapes34/34,e2e_redirect_cargo_build23/23,e2e_vendor_cargo_build40/40,mode_migration_cargo30/30,in_process_cargo_apply23/23,e2e_cargo25/25.cargo test --workspace: building every CLI test binary ran this container out of disk. CI runs the rest.npm/,pypi/,gem/only dispatch the binary)./code-review highFixed in 20f1ef5:
find('}')dispatch, which a}in a comment or string broke, in planner, readers and restore;Cow.Nothing was left unfixed.
CI
All checks green on 319351f (37 success, the rest skipped). Cursor Bugbot found no new issues on 319351f.
Bugbot
crates-iowere refused. Fixed in bde22cd, with unit tests for three placements and acrates-io-wrappedreal-cargo e2e row. Thread resolved.'crates-io'and"registry"spellings. Fixed in 319351f, with tests. Thread resolved.https://claude.ai/code/session_011f9aeSkjzuMR7wJ9h5JWZd
Generated by Claude Code