Repository navigation
fix(swarm): reduce cancellation stalls during session writes - #163485
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 October 2, 2026, 8:29 AM ET / 12:29 UTC (Revision 3). ClawSweeper reviewWhat this changesThe PR lets Swarm child cancellation reuse an initialized database worker while awaiting the selected session’s pending publication and preserving final write ordering. Merge readiness✅ Ready for maintainer review This PR remains useful: current main still queues cancellation preparation behind unrelated session writes. No actionable introduced correctness or security defect was found. Priority: P2 Review scores
Verification
How this fits togetherSwarm coordinates child-agent runs and their cancellation. Session preparation reads the child’s SQLite state and retains its live generation before cancellation and terminal-state publication proceed. flowchart TD
A[Stop child request] --> B[Select child session]
B --> C{Database worker ready?}
C -->|Yes| D[Retain live generation]
C -->|No| E[Normal writer preparation]
E --> D
D --> F[Await selected session publication]
F --> G[Validate and cancel child]
G --> H[Publish through writer queue]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +81, Tests +487, Docs +8. Total +576 across 31 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep preparation independent of unrelated writes while the existing session and cancellation owners enforce lifecycle validity and ordered terminal publication. Do we have a high-confidence way to reproduce the issue? Yes, source establishes the path: hold an unrelated session writer, then prepare cancellation for an already initialized child. Main submits the empty preparation operation to that same queue; this review did not execute the scenario. Is this the best way to solve the issue? Yes. Reusing the existing live generation removes unnecessary writer admission while preserving cold preparation, selected-session settlement, and final publication ordering. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 71b1c049f4c0. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
Merge main to incorporate the execution lifecycle changes in #163485. Import the maintenance executor type from its contract owner, restoring declaration generation and downstream production/test types and lint. The focused patch, maintenance, recap retry, generation-readiness and replacement-publication selection passes 147 tests. Core types, scoped lint and the full-candidate review through P2 pass.
Related: #130741
What Problem This Solves
Fixes: stopping a Swarm child can stall during session preparation behind a write for an unrelated session.
User Impact
Cancellation can reuse a session that is already ready, while retaining current identity checks and the existing ordering for its final publication. No configuration or migration is required.
Why This Change Was Made
A prepared native generation now records readiness only after initialization and registration publication have settled. Cancellation reuses that exact live generation instead of submitting an empty writer operation. Unready generations still use normal preparation, and stale authority still fails.
Evidence
A deterministic regression failed with cancellation preparation queued behind an unrelated writer and passes with this change. The final focused run passed 32 cases covering warm preparation, generation readiness, metadata publication, and replacement publication. Changed type, lint, and storage checks passed, the normal build passed with all declarations enabled, and fresh Codex review completed without actionable findings through P2.
Single-worker command wall times were 164.56 s for warm preparation (2 cases), 84.55 s for readiness (2), 122.67 s for metadata publication (6), and 106.83 s for replacement publication (22). These include test startup and transformation. CI job timings are available in the run below.
CI attempt 37002820229/1 completed with 87 successful jobs, 20 skipped jobs, two failing test shards and their aggregate, and no cancellations. The failures are pre-existing fixtures in
server.chat.orphaned-recovery.test.tsandserver-plugin-in-process-dispatch.session-reads.test.ts: main's roster migration in #162612 rejects their retired default marker andagents.listbefore the modified Swarm paths execute. The fixtures and their configuration-loading paths are unchanged between the tested main baseline and PR merge. This is source-based attribution; no separate baseline replay is claimed. CI remains failed, with explicit maintainer authorization to use the native pre-existing-failure admin exception.Main subsequently corrected both fixtures in #148951. ClawSweeper completed review of the exact published head without actionable introduced findings. This component proof does not establish the combined live 500 ms responsiveness target.