Skip to content

fix(runtime): refuse reserved and malformed slash prompts at admission (RR2) - #116

Merged
lg2m merged 2 commits into
feat/rr1-checkpoint-tolerancefrom
fix/rr2-slash-admission
Sep 22, 2026
Merged

lg2m merged 2 commits into
feat/rr1-checkpoint-tolerancefrom
fix/rr2-slash-admission

Conversation

@lg2m

@lg2m lg2m commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #108 (RR1) → #107 (plan). RR2 of docs/plans/run-reliability.md; audit finding R06.

Behaviour

A prompt such as /clear or /agents that the TUI did not own was forwarded to the runtime, admitted, and then failed inside the run loop with InvalidCommand. The failed run row's "The previous run failed" notice then opened the operator's next real prompt.

Now SessionCommand::SubmitPrompt validates the rendered prompt's leading slash name against the grammar and RESERVED_CLIENT_SLASH_COMMANDS before any row is written (no I/O; the workspace index is not consulted) and refuses with a new SessionRuntimeError::InvalidSlashCommand(SlashCommandError). Server → InvalidRequest; headless → InvalidConfiguration. The TUI already returns the text to the composer on a refused command. // still escapes to literal text. An unknown-but-well-formed name still fails the run because only the workspace index can decide it.

/clear joins the client vocabulary as an alias of /new (constant 20 → 21 entries; additive, no PROTOCOL_VERSION bump).

Audit correction

Only 3 of the 8 invalid_command runs were slash names. The other 5 ("conversation messages must not be empty", two sessions on 2026-09-11) were the pre-#27 empty-conversation bug, fixed the next day and not recurring. Recorded in the audit and ledger.

Verification

  • unresolvable_slash_prompts_are_refused_at_admission_without_a_run_row: /clear, /agents please, /Bad Name each refused with the typed error; //clear the table runs; exactly one RunStarted, completed.
  • slash_clear_is_a_client_alias_for_a_new_session.
  • cargo test -p qq-core -p qq-tui -p qq-protocol green (687 / 266 / 48); cargo clippy --workspace --all-targets --all-features -D warnings clean; fmt clean.

…n instead of failing the run (RR2)

A prompt such as `/clear` or `/agents` that the TUI did not own was
forwarded to the runtime, admitted, and then failed inside the run loop
with InvalidCommand, leaving a failed run row whose "The previous run
failed" notice opened the operator's next real prompt. Three runs in the
2026-09-21 audit; the other five in that bucket were the pre-#27 empty
conversation bug and have not recurred.

SessionCommand::SubmitPrompt now validates the rendered prompt's leading
name against the grammar and RESERVED_CLIENT_SLASH_COMMANDS before any row
is written (no I/O; the workspace index is not consulted) and refuses with
SessionRuntimeError::InvalidSlashCommand(SlashCommandError), which the
server maps to InvalidRequest and headless to InvalidConfiguration. The TUI
already returns the text to the composer on a refused command. `//` still
escapes to literal text, and an unknown but well-formed name still fails
the run because only the workspace index can decide it.

`/clear` joins the client vocabulary as an alias of `/new` (constant grows
20 -> 21 entries; additive, no PROTOCOL_VERSION bump).

Tests: unresolvable_slash_prompts_are_refused_at_admission_without_a_run_row
(three refusals, one escaped prompt, exactly one run, completed);
slash_clear_is_a_client_alias_for_a_new_session.
@lg2m
lg2m added this pull request to stack #109 September 22, 2026 02:39
@lg2m
lg2m merged commit fb2247f into main Sep 22, 2026
4 checks passed
@lg2m
lg2m deleted the fix/rr2-slash-admission branch September 22, 2026 02:52
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.

1 participant