Repository navigation
fix(runtime): refuse reserved and malformed slash prompts at admission (RR2) - #116
Merged
Merged
Conversation
…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.
This was referenced Sep 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #108 (RR1) → #107 (plan). RR2 of
docs/plans/run-reliability.md; audit finding R06.Behaviour
A prompt such as
/clearor/agentsthat the TUI did not own was forwarded to the runtime, admitted, and then failed inside the run loop withInvalidCommand. The failed run row's "The previous run failed" notice then opened the operator's next real prompt.Now
SessionCommand::SubmitPromptvalidates the rendered prompt's leading slash name against the grammar andRESERVED_CLIENT_SLASH_COMMANDSbefore any row is written (no I/O; the workspace index is not consulted) and refuses with a newSessionRuntimeError::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./clearjoins the client vocabulary as an alias of/new(constant 20 → 21 entries; additive, noPROTOCOL_VERSIONbump).Audit correction
Only 3 of the 8
invalid_commandruns 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 Nameeach refused with the typed error;//clear the tableruns; exactly oneRunStarted, completed.slash_clear_is_a_client_alias_for_a_new_session.cargo test -p qq-core -p qq-tui -p qq-protocolgreen (687 / 266 / 48);cargo clippy --workspace --all-targets --all-features -D warningsclean; fmt clean.