Skip to content

agent(command): preserve backslashes inside single-quoted recovered routes (#3231) - #3248

Merged
EffortlessSteven merged 1 commit into
mainfrom
fix-3231-single-quote-backslash-recovery
Aug 14, 2026
Merged

EffortlessSteven merged 1 commit into
mainfrom
fix-3231-single-quote-backslash-recovery

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Change

Makes the bounded canonical-route recovery parser agree with the renderer (#3231): shell_words handled \ before quote-specific logic, consuming a backslash even inside a single-quoted token, while loop_commands::shell_arg correctly 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.

  • Inside single quotes, backslash is now literal.
  • Outside single quotes (unquoted and double-quoted), escape semantics are retained — pinned by test.
  • The helper stays restricted to canonical compatibility recovery; display text is not re-established as argv authority.

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-context stays honest) recovers byte-for-byte through agent_command_spec_from_display and 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_spec carry the semantic Windows token directly in args[], built from semantic inputs — never through shell_words (slice(#1617 PR C): project typed CommandSpec routes into CLI, packets, and standard editor actions #1906 law).
  • Discriminating power: scratch-disabling the fix arm makes both round-trip/semantics tests fail; with the fix, all 5 command-spec tests pass. Compound-command and metacharacter rejection tests unchanged and green.

Verification

  • cargo test -p ripr --lib -- agent::command_specs — 5 passed
  • cargo xtask goldens check exit 0; cargo xtask precommit exit 0 (incl. check-local-context)
  • cargo fmt --check, cargo clippy -p ripr --all-targets -- -D warnings — pass

Closes #3231

…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
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Aug 14, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: cd262756-ab18-45c9-88f4-326d71f5f2a8

📥 Commits

Reviewing files that changed from the base of the PR and between 5218a6c and 707124c.

📒 Files selected for processing (1)
  • crates/ripr/src/agent/command_specs.rs

Summary by CodeRabbit

  • Bug Fixes
    • Improved shell command parsing so backslashes are preserved inside single-quoted text.
    • Maintained expected escaping behavior in other quoting contexts.
    • Improved round-tripping of quoted commands and typed route arguments.
    • Added support for Windows-style paths in shell arguments.

Walkthrough

The 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.

Changes

Command recovery semantics

Layer / File(s) Summary
Parser semantics and typed route preservation
crates/ripr/src/agent/command_specs.rs
shell_words preserves backslashes inside single quotes while retaining escape behavior elsewhere. Tests cover Windows-like path round-trips and direct producer-owned route arguments.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 70712

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

A rabbit checks the quoted trail,
Backslashes stay upon the rail.
The paths return, unchanged and bright,
Typed routes keep their tokens right.
Hop, hop—no slash takes flight!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the change, scope, tests, and verification, but it omits most required template sections and checklists. Complete the template sections for source links, scope classification, policy and support impact, claim boundary, rollback, traceability, engineering checks, and gates.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the command parser change and the preserved backslashes in single-quoted recovered routes.
Linked Issues check ✅ Passed The changes address the linked issue by fixing single-quote backslash handling, preserving typed arguments, retaining rejection behavior, and adding focused tests.
Out of Scope Changes check ✅ Passed The parser correction and focused tests remain within the linked issue’s bounded compatibility and command-spec objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-3231-single-quote-backslash-recovery

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.22222% with 20 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/ripr/src/agent/command_specs.rs 72.22% 20 Missing ⚠️

📢 Thoughts on this report? Let us know!

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 renderer shell_arg documented 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_semantics covers 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_arg in loop_commands is documented as the renderer authority on bash single-quote semantics; shell_words now 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.

@EffortlessSteven

Copy link
Copy Markdown
Member Author

Note on the red codecov/patch: informational status per codecov.yml (status.informational: true); 72.22% of diff vs 88.73% is patch accounting dominated by the ~90 added test-file lines. The single new production arm (the single-quote backslash literal case) is executed by the round-trip and semantics tests — their outcomes depend on it. Required checks green; merging on that basis.

@EffortlessSteven
EffortlessSteven merged commit 1e742aa into main Aug 14, 2026
22 of 24 checks passed
@EffortlessSteven
EffortlessSteven deleted the fix-3231-single-quote-backslash-recovery branch August 14, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

agent(command): preserve backslashes inside single-quoted recovered routes

1 participant