Repository navigation
fix(tui): trust prompt answers only for the content it showed - #213
Conversation
resolve_trust re-scanned the project files when the key was pressed, so a file edited while the prompt was open (a git pull adding an MCP stdio server) was trusted without being shown. The root now keeps the (path, digest) pairs the prompt displayed; qq-config grants or admits only when the pending set matches them, otherwise returns TrustChanged with the current set and the TUI redraws the prompt with it. qq trust is unchanged. Refs: ENG-970
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Line 437 in b035cad
If a project file changes after either reviewed scan succeeds but before this second load reads it, this propagation returns ConfigError::TrustRequired, not TrustChanged. interactive refreshes its reviewed digests and displayed declarations only for TrustChanged, so this race leaves the old prompt visible with a generic error and requires another trust attempt before the current content is shown. Convert the post-grant TrustRequired { pending, .. } into the changed-content path (or make validation and loading atomic), with a deterministic race regression.
AGENTS.md reference: AGENTS.md:L146-L150
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Review (Codex, #213): design/tools.md still said t calls grant_pending_trust and s admits the pending pairs directly. It now names grant_reviewed_trust / reviewed_pending_trust, the TrustChanged refusal and the redraw, and why qq trust keeps granting the current set. Refs: ENG-970
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e440adafff
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…ewed digests Review (Codex, #213): - A file rewritten after grant_reviewed_trust / reviewed_pending_trust scanned but before the post-grant load made that load fail TrustRequired, shown as a generic error over the old declarations. It is now reported as TrustChanged with the new content, so the prompt redraws. Regression an_edit_after_the_grant_scan_redraws_the_prompt_instead_of_failing places the edit exactly between grant and load; it gets TrustRequired without the fix. - ensure_reviewed indexed nothing, so n config.d fragments cost n^2 comparisons per key press. reviewed is now a BTreeSet of (path, digest). Also merges #212's runbook fix. Refs: ENG-970
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7c8d4ee519
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| *reviewed = pending | ||
| .iter() | ||
| .filter_map(config::PendingTrust::reviewed) | ||
| .collect(); |
There was a problem hiding this comment.
Drop buffered answers when the trust prompt changes
When the user presses t or s again while the first resolution is still running, the terminal loop at crates/qq-tui/src/terminal.rs:307-323 awaits the resolver and leaves subsequent input buffered. If that first resolution detects a changed file, replacing reviewed here and resetting trust_resolving means the already-buffered key is processed as approval for the newly discovered digest, even though it was entered before the updated prompt was displayed. A double tap or key repeat can therefore persist or admit content the user never reviewed; discard queued trust-choice input or bind each choice to a prompt generation, with a deterministic buffered-input race test.
AGENTS.md reference: AGENTS.md:L149-L150
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Valid, but not a regression: before this PR the prompt had no digest check at all, so the stack is strictly safer. Tracked as ENG-984 (bind each trust choice to a prompt generation / drop buffered trust keys on redraw, with a buffered-input race test).
Stack ENG-968 (v0.1.5 readiness), 2 of 9. Merge in order; diff shown is this layer only.
Bug
resolve_trustre-scanned project config whent/swas pressed, so a file edited while the prompt was open (e.g. agit pulladding an MCP stdio server) was trusted without being shown (against ADR-0042's intent).Fix
The composition root keeps the
(path, digest)pairs the prompt displayed.qq-configgainsgrant_reviewed_trust/reviewed_pending_trust, which refuse with the newConfigError::TrustChanged { pending }when anything is pending at an unshown digest; nothing is written or admitted. The TUI (TrustFailure { reason, changed }) redraws the prompt with the new content.qq trustis unchanged.Tests
a_trust_answer_covers_only_the_content_the_prompt_showed(both answers, no state written, re-answer succeeds)a_reviewed_grant_refuses_content_edited_after_it_was_shown(qq-config)a_trust_answer_for_changed_files_redraws_the_prompt_with_the_new_content(TUI loop)Guide
tui.md§ Trust updated. Linear: ENG-970.Verification (top of stack)
cargo test --workspace1970 passed / 0 failed / 7 ignored;cargo clippy --workspace --all-targets --all-features -- -D warningsclean;cargo fmt --all -- --checkclean;cargo test -p qq-provider --no-default-features --features test-supportpassed.