Repository navigation
fix(runtime): converge session cancellation before checkout reuse - #822
Conversation
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of e125200: no actionable correctness findings identified. Posting as a comment because GitHub does not allow the authenticated PR author to approve their own PR.
Traced session-wide cancellation intent, retained terminal-run discovery, generation-scoped settlement evidence, exact writer/reservation release, the shared checkout-reuse proof and lock order, terminal tool reconciliation, cancellation-safe connection handling, and the HTTP/CLI/SDK response contracts. Unknown tool outcomes and externally supplied or pre-admission writers remain fenced; pending cancellation does not persist a cancelled Session projection. The one-second server budget is explicitly cooperative, with a separate hard deadline in the CLI.
Validation performed: SDK typecheck passed; SDK tests passed (338 passed, 13 skipped); git diff --check passed. Python fresh-database contract tests: 14 passed, 2 blocked by this environment's AF_UNIX socket restrictions. Rust and live MatrixOne tests were not run locally because this environment lacks the Rust toolchain and a configured database. Test Suite and Static Checks are still in progress at review time; this review does not replace those CI gates.
Summary
Cancelling a session could leave its checkout claimed even after execution stopped, preventing a new conversation from starting. Cancellation now converges through the canonical runtime lifecycle and reports completion only after proving that the session no longer blocks checkout reuse. Session history is retained.
Pending cancellation returns HTTP 202 with settlement evidence and a typed blocker when available. CLI, SDK and harness consumers validate that evidence; terminal orphan cleanup releases only the exact internal writer after rechecking generation and ownership. Unknown tool outcomes remain fenced.
Related issue
Closes #821
Change type
User and compatibility impact
POST /sessions/{id}/canceladds requiredexecution_settledand per-run settlement fields. HTTP 200 means settled; HTTP 202 means cancellation is still pending. The CLI waits up to ten seconds and reports incomplete cleanup truthfully. SDK cancellation returnsSessionCancellationResult. Clients must not infer checkout availability from a terminal display status alone.Architecture and complexity delta
Verification
Completed during implementation:
cargo check --locked -p astra-cli --all-targets: passed.-D warnings: passed.make test-contract: 16 passed.Final harness compatibility verification:
make format-checkandgit diff --check: passed.python -m unittest scripts.harness.test_benchmark_model_seed scripts.harness.test_case_history scripts.harness.test_fresh_database_contract scripts.harness.test_work_surface_live: all 42 passed, including both abstract socket tests. Shell syntax checks andbash scripts/harness/test_local_gateway_contract.shpassed.Public entrypoints covered: session cancellation HTTP response, CLI cancellation polling, SDK response validation and harness exact-session cleanup. Unhappy paths include pending settlement, ambiguous/disconnected database operations, retained terminal authority, unresolved tools, ownership races and invalid cancellation proof. No schema migration is introduced.
Final checklist