Repository navigation
agent(command): preserve backslashes inside single-quoted recovered routes (#3231) - #3248
Conversation
…outes (#3231) shell_words handled backslash before quote-specific logic, so it consumed a backslash even inside a single-quoted token — disagreeing with the renderer (loop_commands::shell_arg), which documents bash single-quote semantics where backslash is literal. A single-quoted Windows-like token could not round-trip through the bounded recovery parser. Found by the ripr#1543 source-promotion review; no supported W7 producer/executor route supplies the shape, so this is bounded compat recovery, not an authority change. Inside single quotes the backslash is now literal; outside single quotes (unquoted and double-quoted) the escape meaning is retained. The helper stays restricted to canonical compatibility recovery — display text is never re-established as argv authority. Tests: single-quoted Windows-like token round-trips byte-for-byte through agent_command_spec_from_display AND through the renderer's own output; unquoted/double-quoted escape semantics stay pinned; a drift test proves producer-owned specs (agent_verify_command_spec / agent_receipt_command_spec) carry the semantic Windows token directly in args[] without display parsing (#1906 law). Discriminating power verified by scratch-disabling the fix arm (round-trip tests fail). Compound-command/metachar rejection unchanged. Closes #3231
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Summary by CodeRabbit
WalkthroughThe command recovery parser now preserves backslashes inside single-quoted tokens. Tests cover Windows-like path round-tripping, quote-specific escaping, and direct preservation of typed verify and receipt route arguments. ChangesCommand recovery semantics
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This localized parser fix preserves backslashes in single-quoted recovered routes while retaining existing escape behavior elsewhere, with the described validation passing; no actionable merge-blocking risk remains after normal checks and review. Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Decision
- Needs reviewer attention before upstream: findings remain.
Confirmed findings
- The pre-fix arm only consumed one backslash per escape cycle; bash semantics also allow \ -> \ inside double quotes. The new tests pin single-quote literal and unquoted/double-quoted single-escape, but do not assert \ in double quotes yields a single backslash. Bounded recovery; not a blocker but worth noting as a residual.
Verification questions
- Confirm added arm
(Some('\''), '\') => current.push(character)preserves literal backslash inside single quotes, matching renderershell_argdocumented bash semantics for round-trip. - Confirm new tests cover the changed arm, the control contexts, and the #1906 drift invariant. Red/green discrimination is adequate; remaining gaps are coverage (72.22% patch coverage per codecov) on the parser loop body, not oracle correctness.
- Confirm codecov reports 72.22% patch coverage with 20 lines missing in
command_specs.rs. The three new tests exercise the new match arm and the typed constructors, but if the missing lines are in surrounding branches (e.g. metacharacter rejection or quote-open paths), behavior preservation on those paths relies on the unchanged prior tests. Architecturally low-risk given the diff is additive and a single match arm; flagging only for the proof broker to confirm.
Refuted
- Coverage 72.22% means 20 uncovered lines in this diff is a correctness gap.; refuted because: Helper-level
backslash_outside_single_quotes_keeps_escape_semanticscovers the new arm's complement paths; round-trip test exercises the new arm. Lack of coverage detail is a witness gap, not a missing correctness assertion. - Single-quote-only literal-backslash arm is tightly scoped and preserves escape semantics elsewhere.
- Fix re-establishes display text as argv authority and violates #1906 law; refuted because: producer_owned_routes_preserve_windows_argv_without_display_parsing proves agent_verify_command_spec and agent_receipt_command_spec carry the semantic Windows token directly in args[], never via shell_words; the fix only changes bounded recovery, not producer routes.
Parked follow-ups
- Duplication risk:
shell_arginloop_commandsis documented as the renderer authority on bash single-quote semantics;shell_wordsnow mirrors only the backslash subset of that semantics. Future quote/expansion features should be added to one source of truth, not both — a parked scope-control note. - artifact-verifier failed with exit code 2; cargo-test scheduled late; coverage 72.22% per codecov. None block correctness, but verifier failure warrants follow-up to confirm receipt contents, not just status.
Evidence gaps
- Model proof intent was rejected by deterministic validation.
- artifact-verifier failed (exit 2) but PR body reports cargo fmt/clippy/test/precommit/goldens all pass; failure is likely witness-environment related, not source-route truth.
|
Note on the red |
Change
Makes the bounded canonical-route recovery parser agree with the renderer (#3231):
shell_wordshandled\before quote-specific logic, consuming a backslash even inside a single-quoted token, whileloop_commands::shell_argcorrectly documents bash single-quote semantics (backslash is literal there). A single-quoted Windows-like token therefore could not round-trip. Found by the rejected-join review (ripr#1543); per the issue's audit, no supported W7 producer/executor route supplies the shape, so this is bounded compat recovery only.Proof
single_quoted_backslash_tokens_round_trip_through_recovery: a synthetic Windows-like token (built at runtime — no literal drive path in source,check-local-contextstays honest) recovers byte-for-byte throughagent_command_spec_from_displayand through the renderer's own output (agent_verify_command→ recover → identical argv entry).backslash_outside_single_quotes_keeps_escape_semantics: unquoted/double-quoted backslash still escapes.producer_owned_routes_preserve_windows_argv_without_display_parsing(the issue's drift test):agent_verify_command_spec/agent_receipt_command_speccarry the semantic Windows token directly inargs[], built from semantic inputs — never throughshell_words(slice(#1617 PR C): project typed CommandSpec routes into CLI, packets, and standard editor actions #1906 law).Verification
cargo test -p ripr --lib -- agent::command_specs— 5 passedcargo xtask goldens checkexit 0;cargo xtask precommitexit 0 (incl.check-local-context)cargo fmt --check,cargo clippy -p ripr --all-targets -- -D warnings— passCloses #3231