Repository navigation
feat(tui): add explicit next-turn follow-up submission - #992
Conversation
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review completed against ec3cc04d056da887732e64cc9cef4e5fecea6729 (base 2873a950f2c9fea00343757933e96070d1631596), including the latest slash-completion follow-up commit. No actionable findings.
The implementation keeps ownership in the existing TUI submission and handoff paths:
- Explicit follow-ups enter the existing client-owned FIFO before guidance admission. They do not acquire remote guidance custody or arm the pre-bind deferral latch, so subsequent Enter submissions can still guide an admitting run.
- The active event loop owns the routing decision, including startup, tool execution, in-flight guidance, and post-output settlement. It does not rely on the displayed Busy/Idle state.
- Traced FIFO release, delayed guidance rejection placement, unsuccessful-settlement recovery, server-owned guidance exclusion, and modal/draft/session handoff gates. I found no newly introduced duplicate-submission or input-loss path.
- Composer routing preserves modal/AskUser ownership, approval behavior, paste custody, and ordinary local slash/shell dispatch. In the latest commit, Ctrl+Q uses the highlighted slash completion, refreshes completion after flushing a due paste, and preserves arguments or unmatched drafts through the ordinary composer path. The new regression cases cover those boundaries and additional control modifiers.
- The feature reuses the existing queue and scheduler. No new durable state, database operation, network request, or background task is introduced. The process-local lifetime is documented.
Validation: inspected source and regression tests and ran git diff --check. I previously verified the actual CI logs for fff52054: all 13 then-new explicit-follow-up tests passed; the shared CLI job reported 4,723 passed and 10 skipped; Static Checks, including dependency audit, passed. The latest ec3cc04d adds four keyboard regressions; its Test Suite is in progress and Static Checks are queued at submission time. Those earlier results are not being represented as validation of the latest commit. Rust tests were not rerun locally because this review environment has no Rust toolchain.
Approve from the code-review perspective; the latest commit's required CI checks still need to complete.
Merge Queue Status
This pull request spent 18 seconds in the queue, including 2 seconds running CI. Required conditions to merge
|
## Summary Fix the Ask User / follow-up guidance lifecycle conflict reported in #985. An exact live Ask User, approval or provider interaction can be superseded by newer durable guidance. Previously, interaction resolution recorded the superseded receipt but left the run in `waiting`. The executor then returned from the interaction and attempted to acknowledge guidance at its next action boundary; the database store rejected that acknowledgement because the run was not `running`, ending the turn with `contract_violation`. Release that exact live wait in the existing resolution transaction while preserving its `superseded` receipt. Old answers/provider responses are not applied and old approvals are denied, even when their recorded decision was allow. The same owner can then acknowledge guidance before admitting its next fresh action. Also distinguish supersession from a late response or lost execution ownership in the existing runtime consumers and Edge approval sink. Review follow-up `4edabe37` also classifies shared Edge approval receipts explicitly. A `superseded` receipt observed before the guidance poll wakes enters the existing supersession continuation, not `FailedClosed`. The recorded old decision is never replayed as approval; `authority_lost`, invalid decisions/kinds and mismatched request/tool identities remain rejected. Both the ordinary shared wait and the nested shared wait after a local callback hint use this classification. ## Related issue Closes #985 ## Change type - [x] Bug fix - [x] Test - [x] Documentation - [ ] Feature - [ ] Refactor or performance improvement - [ ] Build, CI, or maintenance ## User and compatibility impact Waiting for Ask User and then sending follow-up guidance no longer leaves an already-resolved questionnaire blocking guidance acknowledgement. This requires a Server update; no CLI protocol, configuration or database schema changes are introduced. The same exact-wait release rule applies to all three existing interaction kinds; the duplicated AskUser-only predicates are removed rather than introducing a separate policy mechanism. This does not broaden the database guidance-apply status guard, convert guidance into an answer/approval, or auto-resume a terminal, cancelled, stale-frontier or ownership-lost run. Existing HTTP superseded conflict codes remain unchanged. ## Architecture and complexity delta - Canonical owner changed or extended: existing `resolve_run_interaction` implementations in the in-memory and database Run stores, plus the existing durable interaction consumers and Edge approval sink. - Existing implementations and callers searched: interaction registration/wait/resolution, exact frontier/owner/lease validation, resolution receipts, projection/replay, guidance acknowledgement, and questionnaire/approval/provider tests. - Superseded code, states, tables, shims, or self-only tests removed: none; the existing transaction and events are reused. - If parallel implementations remain, their boundary and retirement condition: existing deterministic in-memory fixture and production database implementation retain the same interaction behavior; no new lifecycle implementation is added. ## Verification - UT correction `3522749b` updates the sole failing runtime regression, `newer_guidance_fences_an_approved_stale_tool_before_execution`: the superseded exact wait must now be running with no waiting reason, while the old approval remains denied with a superseded receipt. The test additionally checks exactly one resume and idempotent durable guidance acknowledgement using the existing helper. Merge commit `b58267e9` includes upstream `main` at `a41e48a4` without conflicts, including the already-reviewed `quinn-proto 0.11.18` security fix from #992. Formatting, diff checks and repository metadata validation passed; source review covered this one changed test with no blocking findings. The focused local test is still compiling, so no passing result on this updated head is claimed. New CI must validate the merged head. - Previous-head evidence (`4edabe37`): GitHub runtime execution ran 5914 tests, with 5913 passed and one failed due to the stale `waiting` expectation fixed above. The shared supersession race regression and authority-lost rejection regression passed. CI Clippy and formatting passed; Static Checks failed only at dependency audit on the old `quinn-proto 0.11.15`. Serial local Clippy also completed successfully. Upstream #992 security audit passed, but that is not a passing audit result for this new PR head. - Review follow-up `4edabe37`: added `shared_superseded_approval_wins_before_guidance_poll_wakes`, with six paused-clock cases (local hint present/absent × old allow/deny/timeout); it exercises the reader/wait path rather than calling the settlement sink directly. Existing authority-lost denial rejection coverage is retained. Both regressions subsequently passed in CI as recorded above. The earlier local `cargo test --locked -p astra-runtime --lib shared_` was stopped during compilation under severe memory pressure; serial `CARGO_BUILD_JOBS=1 cargo clippy --locked -p astra-runtime --lib --tests -- -D warnings` later passed. This follow-up changes no database code/schema, and no new database verification is claimed. - Commands and results: formatting and `git diff --check` passed. `cargo test --locked -p astra-services --lib runs::tests::`: 191 passed, 0 failed, 67 ignored. The MatrixOne-backed `database_superseded_interaction_releases_wait_for_guidance` regression passed (six cases across all three kinds), and `database_terminal_statuses_close_all_interactions_and_replay_authority_loss_on_matrixone` passed. `cargo clippy --locked -p astra-services -p astra-runtime --lib --tests -- -D warnings` passed, including runtime test type checking. The initial runtime test build and CI failed because the new test imported a nonexistent `RunControl` trait; follow-up commit `5e99ef9d` fixed that import. Full local runtime execution was stopped after excessive compilation time; runtime regression execution and broader gates must run in CI. No passing runtime execution is claimed. - Public entrypoint exercised: production durable questionnaire gate and Run store registration/resolution/guidance APIs in targeted tests; no authenticated production interaction was replayed or mutated. - Unhappy paths covered: guidance arriving after an exact interaction wait starts; approval/answer/provider-response and timeout supersession; callback replay; exactly-once guidance acknowledgement; admission of a fresh subsequent action. Runtime regressions cover Server and Edge approvals, provider submission and Ask User timeout, preserving rejection of old responses and ownership-lost waits. - Database verification: targeted regression uses a dedicated disposable local MatrixOne database. No schema change. Existing owner/generation/lease/frontier checks and atomic status/event/session-slot update are retained. ## Final checklist - [x] I added or updated tests at the layer that owns the behavior. - [x] I updated design documentation for the lifecycle contract. - [x] I checked the diff for credentials, private URLs, customer data, generated files, and other sensitive information. - [x] The PR title follows the repository's Conventional Commit format. Approved-by: XuPeng-SH <[email protected]>
…ecall (#995) ## Summary Session closure could purge working memories after its final snapshot read failed. Preserve typed read errors in the canonical snapshot loader and stop session-end governance before any subsequent write, purge or reflection when that read fails. Optional prompt/local-context consumers continue to treat failed reads as absent context. Session-start profile/episode recall capped candidates before validating prompt eligibility. Apply the existing three-entry cap to admitted evidence instead, preserving ranking, type checks, deduplication and the shared interactive deadline. ## Related issue Closes #994 ## Change type - [x] Bug fix - [x] Documentation - [x] Test ## User and compatibility impact Working memories survive transient snapshot read failures, unavailable authorization and a memory-disable race during session closure. Successful empty reads retain existing cleanup behavior. Valid recall candidates remain usable when higher-scoring rows are malformed, inactive or inconsistent with their declared type. No public HTTP API, configuration, database schema, credentials or deployment changes. ## Architecture and complexity delta - Canonical owner changed or extended: existing session-memory snapshot loader and session-end governance; existing typed prompt admission. - Existing implementations and callers searched: optional remote/local snapshot consumers, session-close scheduling and debounce completion, scoped MemoriaPort reads, profile/episode recall and contract tests. - Superseded code, states, tables, shims, or self-only tests removed: error-to-empty projection is removed from the shared snapshot boundary; optional consumers make that projection explicitly. Candidate truncation moves after canonical prompt validation. - If parallel implementations remain, their boundary and retirement condition: none added. ## Verification - `make format-check`: passed. - `git diff --check`: passed. - Independently compiled source-module memory-prefetch tests: 15 passed, including the new mixed-candidate regression. - CI on memory-fix commit `431c30ef`: `Test: astra-runtime`, `Test: MOI fresh-Astra compatibility`, clippy and formatting passed. The previous local whole-runtime compilation was stopped after these CI checks completed. - Rebased onto current `main` (`a41e48a4`), which includes the dependency security fix from #992. `git range-diff` confirms the Memoria patch is unchanged; this PR contains no `Cargo.lock` changes and no duplicate dependency commit. - Security audit after rebasing (cargo-audit 0.22.2, current advisory database): passed with zero reported vulnerabilities; audit policy is unchanged. - `cargo check --locked -p astra-core`: passed with the same lockfile now supplied by #992. - `make format-check` and `git diff --check` passed after rebasing. CI is rerunning on the rebased Memoria-only branch; final results are pending. - Public entrypoint exercised: `run_session_end_governance`, used by authenticated session closure, and `prefetch_session_start_memories_with_client`, used by first-turn context assembly. - Unhappy paths exercised: failed snapshot transport, unavailable authority and disabled reads with both empty and nonempty session facts; mixed malformed/archived/type-mismatched/unranked recall candidates. Positive paths cover successful empty reads and existing snapshot consolidation, write failure retention, ranking and per-bucket bounds. - Database verification: not applicable; no schema, query, transaction or database-routing changes. The regressions use deterministic MemoriaPort fixtures without live credentials or cluster mutation. ## Final checklist - [x] I added or updated tests at the layer that owns the behavior. - [x] I updated the memory design contract. - [x] I checked the diff for credentials, private URLs, customer data, generated files, and other sensitive information. - [x] The PR title follows the repository's Conventional Commit format. Approved-by: XuPeng-SH <[email protected]>
Summary
During an active TUI turn, Enter can guide the current run, but users cannot explicitly select subsequent work while guidance is still admitted. Add Ctrl+Q to queue conversational input in the existing next-turn FIFO. The current run receives no guidance request for that input; subsequent Enter submissions can still guide it.
The shortcut operates only in the composer. Idle submission and local slash/shell controls use the ordinary dispatcher, and Shift+Enter/Alt+Enter keep their newline behavior. Reuse queue previews and add a local enqueue acknowledgement,
/help keysguidance, and public/design documentation.The lockfile also upgrades
quinn-protofrom 0.11.15 to 0.11.18, plus its required RNG dependency changes, to resolve RUSTSEC-2026-0338 through RUSTSEC-2026-0342. The initial CI run passed Clippy, formatting, and functional gates but failed dependency audit; the upstreammainlockfile reproduces all five findings. Audit policy is unchanged.Related issue
Closes #990 (the recommended TUI milestone). The queue remains process-local; durable API delivery, queue editing, and persistence across client restart are separate extensions.
Change type
User and compatibility impact
Architecture and complexity delta
BottomPane::handle_key,queue_next_turn_submission,admit_idle_followup, settlement and modal/session release gates, pre-bind deferral, guidance custody/reconciliation, and local control dispatch.UserIntentDelivery, Server run admission, execution-slot fencing, cancellation, and provider/permission contracts are unchanged.Verification
CARGO_INCREMENTAL=0 RUST_MIN_STACK=16777216 cargo test --locked -p astra-cli --lib explicit_followup -- --test-threads=2: 13 passed, including a fresh run after the lockfile upgrade.CARGO_INCREMENTAL=0 RUST_MIN_STACK=16777216 cargo test --locked -p astra-cli --lib tui:: -- --test-threads=2: 1977 passed, 1 existing ignored, 0 failed (includes the 13 new regressions).CARGO_INCREMENTAL=0 RUST_MIN_STACK=16777216 cargo test --locked -p astra-cli --lib cli::turn::local_run_control:: -- --test-threads=2: 11 passed.CARGO_INCREMENTAL=0 cargo clippy --locked -p astra-cli --all-targets -- -D warnings: passed.CARGO_INCREMENTAL=0 make lint: passed for the full default workspace and all targets after the lockfile update.cargo audit --no-fetch(cargo-audit 0.22.2, RustSec databased5f46becf4d442d460e1fce5e12f2c0f00924868): passed, 0 vulnerabilities, with only existing informational warnings. The unchangedmainlockfile reports all five quinn-proto vulnerabilities against the same database.make format-check: passed.python3 scripts/ci/validate_repository.py: passed.git diff --check: passed.fff52054de101fb08822b0d8781444cda19728da, including dependency audit: https://github.com/matrixorigin/Astra/actions/runs/38372414920BottomPane::handle_key, then the production active-queue, settlement, ordinary replay, and handoff helpers. The broader TUI suite also exercises the existing terminal reader and workbench paths.Final checklist