Repository navigation
fix(swarm): wait for owned cleanup when stopping children - #163558
Conversation
Continue #157347 with exact execution ownership through terminal persistence and runtime cleanup.
|
🦞👀 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, 7:45 PM ET / 23:45 UTC (Revision 7). ClawSweeper reviewWhat this changesSwarm Stop waits for selected children's preparation, terminal persistence, and runtime disposal while preserving exact ownership and reporting cleanup failures. Merge readiness✅ Ready for maintainer review This remains a useful maintainer-owned repair: current main does not retain the same execution cleanup ownership. No actionable introduced defect was found, and the documented indefinite-wait tradeoff has already been accepted in the maintainer-authored PR. Priority: P1 Review scores
Verification
How this fits togetherSwarm schedules child agent work through the Gateway and subagent registry. Stop selects authorized children, cancels their work, and publishes results after the selected cleanup owners settle. flowchart TD
A[Swarm Stop request] --> B[Select authorized children]
B --> C[Retain exact execution ownership]
C --> D[Cancel queued or running work]
D --> E[Join persistence and disposal]
E --> F[Publish result or cleanup failure]
F --> G[Release retained ownership]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +1002, Tests +2283, Docs +3. Total +3288 across 50 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep cancellation settlement with the existing scheduler, session, and execution owners, preserving truthful results without releasing unfinished cleanup. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main can retire logical registration without retaining the raw disposal tail that this branch joins. This review did not execute a failing runtime reproduction. Is this the best way to solve the issue? Yes. The patch extends the existing ownership boundaries, keeps cancellation separate from deletion authority, and avoids a competing cleanup manager. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 810018486a55. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
Preserve recorded execution cleanup when Stop is called from a disposer before or after normal retirement. Keep session and controller authority current, reject unrecorded binding loss, and compose current attachment cleanup and silent-child completion behavior.
|
Merged via squash.
|
fdbf48d (#163558) changed subagent binding retirement to retain owned execution cleanup. That path reads the Gateway chatAbortControllers map, which production contexts always initialize, but the shared restart fixture and its predecessor/replacement contexts omitted it. Give each fixture Gateway its own empty controller map. Preserve the real retirement path and every sweeper and parent-continuation assertion. Before: sweeper 2/8 and parent recovery 1/14 failed at the missing map. Validation: both files passed three complete local runs (66/66). Linux Crabbox proof used the authorized AWS fallback after Testbox congestion: all four fixture consumers passed (67/67), the full agents-support config passed (5,326 tests), and check-changed plus boundary lint passed. P2 review found no actionable issues. No assertions or skips changed.
…63558) * fix(swarm): wait for queued child cleanup on Stop Continue openclaw#157347 with exact execution ownership through terminal persistence and runtime cleanup. * test(swarm): bind cancellation fixtures to actual execution cleanup * refactor(tests): keep cancellation fixtures in bounded support modules * refactor(swarm): simplify spawn cleanup handoff
94d479b (openclaw#163558) changed subagent binding retirement to retain owned execution cleanup. That path reads the Gateway chatAbortControllers map, which production contexts always initialize, but the shared restart fixture and its predecessor/replacement contexts omitted it. Give each fixture Gateway its own empty controller map. Preserve the real retirement path and every sweeper and parent-continuation assertion. Before: sweeper 2/8 and parent recovery 1/14 failed at the missing map. Validation: both files passed three complete local runs (66/66). Linux Crabbox proof used the authorized AWS fallback after Testbox congestion: all four fixture consumers passed (67/67), the full agents-support config passed (5,326 tests), and check-changed plus boundary lint passed. P2 review found no actionable issues. No assertions or skips changed.
- registry SQLite fixture helpers moved to subagent-registry-state.fixture.test-support - registration scopes carry canAbortAcceptedRun (upstream openclaw#163558 family) - kill publication preparation is { prepare, publishSnapshot } (upstream openclaw#163558) - resumed-run set is keyed by run runtime key; startQueued/settleFailed/add/reset are async - restore runSubagentAnnounceDispatch import dropped with upstream's removed cases - widen registration promise annotations for the ownership-returning registerSubagentRun Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Jhynq2GVpzuVQQieebEubg
Related: #157347, #130741
Continuation of #157347 by @steipete.
What Problem This Solves
Fixes: stopping a Swarm could release a child's queue or lifecycle ownership while its preparation, terminal persistence, or runtime disposal was still pending.
User Impact
Stop retains the selected children through their owned cleanup and reports cleanup failures. Children belonging to different agents remain distinct even when they share a raw session key. Accepted cancellation survives the initiating caller's retirement.
A disposer can stop its own work without waiting for itself. If the execution binding retires before or during that call, the pending self-call requires the exact recorded retirement and current session authority. Unrecorded binding loss and replacement controllers still refuse.
An external Stop waits for selected cleanup to settle. A disposer that never settles leaves that request pending with ownership retained. This is the cleanup ownership repair; the real-OpenAI 500 ms responsiveness target remains unproven. FIFO ordering, integrity checks, and retention remain intact. No configuration or schema migration is required.
Why This Change Was Made
Keep preparation with its existing reservation and retain each exact execution through terminal persistence and disposal. Compose this with current main's acknowledged registration, failed-registration cleanup, attachment-removal policy, and silent-child completion behavior. Permission to abort remains separate from permission to delete. Main’s parent lineage capture remains inside the preparation hold; cancellation joins both ancestor and child publication readiness.
Self-cancellation joins its terminal writer while its outer execution remains responsible for final disposal. The retirement observation supplies cleanup facts without restoring execution authority.
Evidence
Reviewed, committed source:
73fd7487237b28a7a7f53ae9cfc9c4ee977d28d2, incorporating maina97e007542efcc5757e59fd2d7e0b467c1a7a262.0003036head passed all 34 canonical checks, the normal build, and exact-head hosted CI run 37068334838. Main then introduced two real conflicts; this successor preserves aggregate readiness while adopting its parent-binding structure. The focused proof above covers that composition. Current-head CI run 37077363634 passed separately: 65 successful jobs, 22 skipped, no failures or cancellations. Its build-artifacts job was skipped; this is not a new normal-build result.Earlier fixture corrections made child completion explicit, retained exact abort-controller ownership, and preserved scoped catalog-reader lifetime checks. No timeout, capacity limit, assertion, or baseline was weakened to obtain passing results.
Measured focused-test costs
Node 24.21.0, pnpm 12.5.1, one worker. The 33-case integration command took 353.540 s including preparation and cleanup; affected types took 104.826 s. The earlier 28-case cleanup command took 436.556 s; its wake-retirement case took 7.964 s, unrecorded-loss control 6.789 s, and retired-self case 9.476 s. These include test infrastructure and host contention; they are not product latency measurements. Current-head CI’s observed job window was 484 s; its slowest selected Node test job took 394 s. These are job-level costs, not per-case timings.