Repository navigation
fix: keep stale Stop messages from canceling replacement sessions - #152116
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 18, 2026, 5:15 PM ET / 21:15 UTC (Revision 4). ClawSweeper reviewWhat this changesThe PR rechecks session and transcript guards during typed Stop cancellation, preserves accepted cancellation and captured output, and adds regression coverage and documentation. Merge readiness✅ Ready for maintainer review This remains a useful, focused fix: fetched main and the latest release still bypass transcript guards for typed Stop. No actionable introduced defect was found. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway receives Stop requests from chat clients and coordinates cancellation of active turns, queued work, and child agents. Session guards keep those effects attached to the conversation originally selected. flowchart TD
A[Typed Stop request] --> B[Session and transcript guards]
B --> C{Target still current?}
C -->|Yes| D[Cancel selected runs and children]
D --> B
C -->|No| E[Reject further cancellation]
D --> F[Settle accepted work and preserve output]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +94, Tests +617, Docs +5. Total +716 across 10 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep cancellation in the existing owner, revalidate before new effects, and settle accepted work only against its captured session incarnation. Do we have a high-confidence way to reproduce the issue? Yes, from source: send typed /stop with a stale expected leaf to an active session; current main reaches cancellation before applying that guard. This review did not execute the scenario. Is this the best way to solve the issue? Yes. Reusing the existing guard and cancellation-control owner addresses the race while preserving accepted settlement and established unguarded behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d5b46dfea58a. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
2efab94 to
f5af7b2
Compare
…n-20260918-v4 * origin/main: (81 commits) fix: retire failed setup plugins without replaying facade initialization (#152026) fix(test): select Node for built runtime recovery fixtures (#152162) refactor(auth): reuse privately assembled choice groups (#152166) fix: preserve chat media delivery and session boundaries (#152079) fix: keep stale Stop messages from canceling replacement sessions (#152116) improve(plugins): reduce mutable argument handling overhead (#152154) fix(scripts): prevent host tooling drift from blocking PR workflows (#152078) improve: reduce model capability preparation work (#152128) fix: stop marking delivered scheduled reports as failed (#152165) fix: start background context maintenance after durable turns (#151936) fix(models): avoid ambient state reads during prepared selection (#152119) feat: recover abandoned Crabbox source staging (#152006) chore(ui): refresh control ui locales (#152098) fix(ui): keep cloud startup prompts and progress in chat (#152024) fix: report completed subprocess cleanup after cancellation (#152107) perf(reply): reuse normalized inbound text (#152110) fix(cron): paused future one-shots disappear after Run now (#152126) perf(sessions): reuse rows and skip discarded terminal labels (#152109) fix(ui): keep keyboard-focused automation controls clear of sticky actions (#152135) fix(ui): load remote images in compact activity previews (#152045) ...
|
Merged via squash.
|
…enclaw#152116) * fix(gateway): guard typed Stop at cancellation boundaries * test(gateway): retain config in ended-parent abort fixture
Related: #150153
What Problem This Solves
A stale Stop message can cancel a replacement session or its child work after the request's captured session guard has become invalid.
User Impact
Guarded Stop messages stay bound to their admitted session and transcript position. Rejected cancellation releases unaccepted claims, while cancellation already accepted still settles and preserves captured output.
Why This Change Was Made
Reuse the existing session guard at cancellation effect boundaries and after awaited descendant work. Retain the physical storage source selected during admission, and let the existing router preserve structured authorization errors. Ordinary run-specific abort behavior remains unchanged.
Evidence
Original handler regressions fail before the fix. Real isolated listening WebSocket Gateway cases reproduce stale-leaf cancellation and a session replacement during the awaited drain, then pass with the correction; controlled agent streams verify partial-output persistence and child settlement. No external provider traffic is claimed.
All 353 focused tests, the final three-case replay, full changed checks, and fresh independent P0–P2 review pass. Hosted CI exposed an ended-parent fixture that omitted the captured config required by the real session reader. The fixture now supplies its own context config and resets its mock between cases; all 80 affected and sibling cases, selected checks, and fresh review pass without a production fallback or changed assertions. The next CI run hit duplicate declarations in three unchanged SQLite tests; #152028 independently fixed those on main. The branch was restacked onto that fix with byte-identical patch content and unchanged review scope. All 196 cases in the nine selected Stop, persistence, SQLite, and requester-settlement suites pass on the refreshed base. Exact-head CI35395311933 passes for
f5af7b222d8c.This focused prerequisite adds 94 production lines; the aggregate production reduction target for the replacement series remains unmet.