Repository navigation
fix(runtime): release superseded interaction waits - #986
Conversation
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed all three commits from 2873a950f2c9fea00343757933e96070d1631596 to c53dc5d194a4bc5a49912dccab6efc4d029066e7.
The core fix is appropriate: release the exact live interaction wait in the existing transaction, preserve the superseded receipt, and retain the owner/generation/lease/frontier checks. This adds no schema, background worker, or additional query. The production change is small relative to the regression coverage.
Requesting changes for one incomplete Edge consumer update, detailed inline: the shared approval polling path still classifies a superseded receipt as lost authority before it reaches the updated settlement sink. Please cover the ordering where the shared receipt is observed before the guidance poll and route that receipt through the existing supersession control path.
The current Edge regression invokes the sink directly and manually acknowledges guidance, so it cannot detect this ordering. Keep the authority-lost rejection coverage alongside the new regression.
Non-blocking existing limitation: Ask User and provider waits still await a callback or their deadline before processing guidance; the new 200 ms questionnaire timeout test establishes post-timeout recovery, not immediate guidance responsiveness.
Validation: source-level review and git diff --check passed. This review environment has no Rust toolchain, so I did not execute the Rust tests or independently reproduce the author's reported MatrixOne results. Runtime test execution remains unverified here.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Re-reviewed all four commits from 2873a950f2c9fea00343757933e96070d1631596 through 4edabe3769783ea91c5f6f1877586a5f6835e714. The P2 in my previous review is addressed; no new actionable findings.
The shared Edge approval reader now classifies supersession explicitly, and both the ordinary shared wait and the nested wait after a local callback hint enter the existing guidance continuation. Old allow/deny/timeout decisions are not replayed as execution permission. Request/tool identity, decision and approval-kind validation remain mandatory, and authority-lost receipts still fail closed.
The new paused-clock regression exercises the actual reader/wait path with the shared receipt visible at 100 ms while the guidance poll remains asleep for 250 ms. Its six cases cover local hint present/absent and old allow/deny/timeout. This closes the coverage gap in the previous sink-only test.
Rechecked the store-to-consumer path: the exact live wait is released atomically while retaining its superseded receipt; owner, generation, lease, frontier and cancellation checks remain in place. Callback replay does not double-resume, and guidance acknowledgement precedes fresh action admission. The implementation reuses existing transactions and continuation paths without adding queries, background tasks or a parallel state machine.
Existing non-blocking limitation remains: Ask User and provider waits process guidance after their callback or deadline rather than immediately on guidance arrival.
Validation: source review and git diff --check passed. Latest CI Clippy and formatting steps passed. Static Checks failed at dependency audit on the existing quinn-proto 0.11.15 advisories; this PR does not change Cargo.lock. The Test Suite is still in progress at submission time. This environment has no Rust toolchain, so I did not independently execute Rust or MatrixOne tests.
Approve from the code-review perspective. Required CI still needs to complete successfully, including the dependency fix already addressed in #992.
Merge Queue Status
This pull request spent 21 seconds in the queue, including 1 second 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 notrunning, ending the turn withcontract_violation.Release that exact live wait in the existing resolution transaction while preserving its
supersededreceipt. 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
4edabe37also classifies shared Edge approval receipts explicitly. Asupersededreceipt observed before the guidance poll wakes enters the existing supersession continuation, notFailedClosed. 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
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
resolve_run_interactionimplementations in the in-memory and database Run stores, plus the existing durable interaction consumers and Edge approval sink.Verification
3522749bupdates 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 commitb58267e9includes upstreammainata41e48a4without conflicts, including the already-reviewedquinn-proto 0.11.18security fix from feat(tui): add explicit next-turn follow-up submission #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.4edabe37): GitHub runtime execution ran 5914 tests, with 5913 passed and one failed due to the stalewaitingexpectation 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 oldquinn-proto 0.11.15. Serial local Clippy also completed successfully. Upstream feat(tui): add explicit next-turn follow-up submission #992 security audit passed, but that is not a passing audit result for this new PR head.4edabe37: addedshared_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 localcargo test --locked -p astra-runtime --lib shared_was stopped during compilation under severe memory pressure; serialCARGO_BUILD_JOBS=1 cargo clippy --locked -p astra-runtime --lib --tests -- -D warningslater passed. This follow-up changes no database code/schema, and no new database verification is claimed.git diff --checkpassed.cargo test --locked -p astra-services --lib runs::tests::: 191 passed, 0 failed, 67 ignored. The MatrixOne-backeddatabase_superseded_interaction_releases_wait_for_guidanceregression passed (six cases across all three kinds), anddatabase_terminal_statuses_close_all_interactions_and_replay_authority_loss_on_matrixonepassed.cargo clippy --locked -p astra-services -p astra-runtime --lib --tests -- -D warningspassed, including runtime test type checking. The initial runtime test build and CI failed because the new test imported a nonexistentRunControltrait; follow-up commit5e99ef9dfixed 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.Final checklist