Repository navigation
fix(cli): queue settlement-fenced follow-up instead of showing raw 409 - #865
Conversation
A definitive run_intent_settlement_fenced rejection did not commit, so keep the text for the next turn instead of surfacing the HTTP body. Co-authored-by: Cursor <[email protected]>
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of 5803682: one P2 correctness issue in the new settlement-fenced handoff, detailed inline. A delayed fence response can move an earlier submission behind a later next-turn message, causing automatic execution in the wrong order.
I traced the HTTP classification and retry path, durable admission's duplicate-before-fence handling and rollback, local intent custody, turn-closure barriers, queued follow-up dispatch, cancellation/failure draft recovery, and visible-output settlement. The narrow 409 classification and continued separation of output settlement from admission are sound; the remaining issue is preserving submission order across the asynchronous response.
Validation: GitHub Static Checks and Test Suite succeeded for this head, including the CLI non-edge test job. The new queue test starts with an empty queue and does not cover this interleaving. This review used source analysis; Cargo/rustc are unavailable in the review environment, so I did not run local Rust tests.
A delayed settlement-fence response was appended behind messages submitted while that request was still in flight, so the next turn ran them backwards. Co-authored-by: Cursor <[email protected]>
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep re-review of 7986132. No new actionable blocking findings.
The previously reported FIFO issue is fixed: the event loop captures the next-turn queue length when guidance is submitted, then inserts a settlement-fenced submission at that position. This preserves both an earlier queued prefix and messages queued while the HTTP request was pending. The single-in-flight submission guard and turn-owned queue make the position meaningful during the handoff. The new regression covers A before B, an existing prefix before A, and the resulting draft-recovery order.
I reread the full two-file PR diff and traced submission/index lifetime, exact 409 classification, stable-identity retries, server duplicate-before-fence handling and rollback, turn-closure barriers, later-input routing, failure/cancellation draft recovery, existing-draft preservation, and outer-loop dispatch. A fence still does not stand in for visible-output settlement or grant permission to start another run early. The fix remains within the existing queue/turn owner and introduces no additional network request or parallel lifecycle.
Validation limits: reviewed source and regression tests; Cargo/rustc are unavailable locally, so I did not run Rust tests. The latest head's Static Checks and Test Suite were still running when checked; this approval is a code-review conclusion, not a claim that those checks have completed.
Merge Queue Status
This pull request spent 34 seconds in the queue, including 2 seconds running CI. Required conditions to merge
|
Summary
Fixes #852.
When a follow-up is submitted while the client still treats the run as active, the TUI posts it as current-run guidance. If the server has already fenced that run, admission rolls the insert back and returns HTTP 409 with
error_code=run_intent_settlement_fenced. The TUI used to classify every non-408 4xx as an ordinary rejection and renderHTTP 409 Conflict:plus the raw JSON. This change keeps that text for the next turn instead.The server fence is unchanged. A visible
Workingindicator that outlives a completed-looking answer is a separate, still-unproven problem and is not inferred from this 409.What was going wrong
active_submission_belongs_to_next_turnsends ordinary text asGuideCurrentRununtil local output settlement or a foreground lifecycle transfer. Those client facts can lag the server fence, so a message typed after the answer is visible can still be posted to a run that no longer accepts guidance.The server path in
admit_run_guidancehandles identity and duplicate cases first. Only a new submission whose latest fence event isuser_intent_settlement_fencedreturnsSettlementFenced, and that branch rolls the transaction back before returning. The intent did not commit. Showing the protocol body asked the user to interpret a conflict and submit again by hand.Solution
The client now treats this one response as a typed non-acceptance, not as display text.
GuidanceSubmissionError::from_thin_clientreturnsSettlementFencedonly when the status is HTTP 409 and the JSON fielderror_codeis exactlyrun_intent_settlement_fenced. The detail string is not consulted.submit_active_run_guidancereturns that variant immediately and does not retry the fenced run.release_remote_user_intent_submissionandremove_local_user_intent) and moves the original text onto the existingqueue_next_turn_submissionlane. It does not restore the text into the composer and does not start a run itself.guidance_admission_closedflag. Later composer input in that same turn goes throughactive_submission_routes_to_next_turnand is queued directly, so it is not posted to the fenced run again.The existing turn owner still decides what happens to that queue:
settle_followup_submissionsappends the text to the follow-up lane, and the outer loop submits it only after ownership returns. That submission is a new turn with a new intent id.should_start_followupsis false and the same helper restores the draft instead of starting it.guidance_admission_closedonly changes input ownership. It does not callsettle_visible_reply, clearWorking, or treat the fence as proof that the visible answer stream has finished. A live tool segment therefore stays live.What stays the same
Unconfirmed, including a 408 whose body happens to contain thiserror_code. An acknowledgement that may already have committed is not turned into a second turn.run_intent_identity_conflict, staysRejected: the raw HTTP error is still shown and the text returns to the composer.Rejected.Test plan
cargo test -p astra-cli --lib -- guidance_submission_errors_preserve_ambiguous_commit_ownership settlement_fenced_follow_up_is_queued_without_keeping_the_rejected_intent closed_guidance_routes_later_input_to_the_next_turn active_slash_commands_never_enter_model_guidanceSettlementFencedand the notice does not contain the HTTP body.error_codestaysUnconfirmed.