Skip to content

fix(tui): trust prompt answers only for the content it showed - #213

Merged
lg2m merged 6 commits into
docs/eng-969-release-0verfrom
fix/eng-970-trust-prompt-digest
Sep 29, 2026
Merged

lg2m merged 6 commits into
docs/eng-969-release-0verfrom
fix/eng-970-trust-prompt-digest

Conversation

@lg2m

@lg2m lg2m commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

Stack ENG-968 (v0.1.5 readiness), 2 of 9. Merge in order; diff shown is this layer only.

Bug

resolve_trust re-scanned project config when t/s was pressed, so a file edited while the prompt was open (e.g. a git pull adding 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-config gains grant_reviewed_trust / reviewed_pending_trust, which refuse with the new ConfigError::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 trust is 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 --workspace 1970 passed / 0 failed / 7 ignored; cargo clippy --workspace --all-targets --all-features -- -D warnings clean; cargo fmt --all -- --check clean; cargo test -p qq-provider --no-default-features --features test-support passed.

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
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-29T06:34:54.257399Z 7c8d4ee New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@lg2m
lg2m added this pull request to stack #221 September 29, 2026 02:17

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

let snapshot = self.load_for_client(&request)?;

P2 Badge Reclassify changes detected by the post-grant reload

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

Comment thread docs/guide/tui.md Resolved
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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread src/main.rs Resolved
Comment thread crates/qq-config/src/loader.rs Resolved
…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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread src/main.rs
Comment on lines +735 to +738
*reviewed = pending
.iter()
.filter_map(config::PendingTrust::reviewed)
.collect();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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

@lg2m
lg2m merged commit cae35df into main Sep 29, 2026
10 of 12 checks passed
@lg2m
lg2m deleted the fix/eng-970-trust-prompt-digest branch September 29, 2026 18:56
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