Repository navigation
Conversation
Gateway stop failed with "Spawn broker group cleanup could not be confirmed" whenever a broker's private process group retained only dead members that an ancestor child subreaper adopted but never reaped. kill(-pgid, 0) still succeeds for zombies, so the host waited out the full TERM grace plus its 2 s confirmation window, then reported a cleanup failure. The native-resource broker hit the same 7 s wait inside nativeWorkerLifetimes, overran the 3 s global-singletons grace, and turned the stop into retained resources that keep the process alive until the hard-exit watchdog. Host-side group confirmation now counts only live members, matching the broker's own drainCurrentBrokerProcessGroup. Live members are still signaled, escalated and joined. Zombies pin the PGID until reaped, so no reuse can follow retirement. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🦞👀 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. What this changesThis PR lets broker cleanup finish when Linux process-group members are confirmed dead but remain unreaped. Example: A Linux Gateway receives SIGTERM under a supervisor retaining adopted esbuild zombies.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current Linux shutdown failure and remains useful; no actionable defects were found, and the reviewed head’s CI gate passes. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherAfter a broker exits, its host joins private process-group cleanup; kernel group probes and process observations determine whether cleanup must continue. flowchart TD
A[Gateway shutdown] --> B[Spawn broker host]
B --> C[Broker exit join]
C --> D[Private group cleanup]
D --> E[Linux process census]
E --> F[Live members retain TERM and KILL cleanup]
E --> G[Confirmed dead members settle cleanup]
Technical reviewBest possible solution: Keep the existing cleanup owner and use its conservative Linux census to distinguish live work from unreaped dead members. Do we have a high-confidence way to reproduce the issue? Current-main source explains the failure, and contributor-supplied Gateway logs demonstrate it under controlled non-reaping supervision; this read-only review ran no target code. Is this the best way to solve the issue? The patch is a focused repair using existing census and death-detection owners, while preserving live-member escalation and conservative handling of unavailable observations. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f1c935770852. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +31, Tests +136. Total +167 across 3 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed October 31, 2026, 11:19 AM ET / 15:19 UTC (Revision 2). |
|
Added inspectable, redacted output to the PR body from the reported real isolated Gateway under a non-reaping supervisor: original process topology, baseline failure, repaired clean shutdown and recorded exit status. The earlier integration candidate is identified separately from this publication head and its extra guards. No new live call was made. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Merge main 6a60076 into the published head 49b93b1. One conflict, in src/process/spawn-broker/cleanup.ts: main rewrote terminateBrokerProcessGroup around asynchronous kernel and census probes (openclaw#197510, openclaw#198132). The resolution keeps main's structure and ports the zombie-only extinction check onto it as isBrokerProcessGroupExtinct, which reuses main's asynchronous census, own-procfs guard and zombie predicate. An empty or unreadable census still keeps a kernel-visible group pending, so TERM/KILL escalation and the deadline error are retained.
Related: #170000
What Problem This Solves
Fixes joined Gateway shutdown failing when a spawn broker's private process group contains only dead processes awaiting reaping by another supervisor.
User Impact
Gateways launched under a child subreaper that does not reap adopted children can stop cleanly instead of reporting retained broker resources. Live descendants still receive TERM/KILL cleanup and must be joined. Timeouts, shutdown budgets, permissions, and non-Linux behavior do not change.
Why This Change Was Made
Node's process-group existence probe still succeeds for unreaped zombies. The host previously treated that as proof that broker work remained alive, waited through the TERM and confirmation windows, and reported
Spawn broker group cleanup could not be confirmed.After the existing group probe, Linux confirmation now uses the existing asynchronous process census, own-procfs guard and zombie/definite-death predicate to distinguish live members from zombies. This matches the broker-side drain policy without changing invocation or child custody. An empty or unavailable census does not prove death: while the kernel still reports that group, cleanup remains pending and preserves the existing TERM/KILL escalation and deadline error. Zombies pin the group identifier while they await their reaper; retiring their group observation does not authorize signaling a reused identifier.
A short-lived fork during a census remains an accepted edge of the existing census-based policy. This patch does not alter detached command-group cleanup or the global-singleton grace budget.
Refresh onto current main. Head
9ef4c65c411merges main6a6007663b3into the previously published49b93b101d0(normal merge commit, no rebase). Since the old base, main rewroteterminateBrokerProcessGrouparound asynchronous kernel and census probes and added a census fallback that applies only when the host denies the group probe (#197510, #198132). It did not fix this case: with a working probe, a zombie-only group still reads as alive. The one conflict was resolved by keeping main's structure and porting the check onto it asisBrokerProcessGroupExtinct. The synchronous process-exitforcepath and the SIGKILL escalation are main's, unchanged. Against main the diff is still three files (+165/−2); the two test files carry the same added tests as before. On a host that denies group signals and still has live members, each 50 ms confirmation tick now reads the census twice; that is accepted for this rare path rather than widening the shared probe API.Evidence
6a6007663b3: the real-process fixture from the new test launches a Node subreaper, a private group leader and a delayed-TERM child, with no mocked census or signals. With main's exactcleanup.tsit ends inSpawn broker group cleanup could not be confirmedafter 7,031 ms. With this head it settles in 462 ms while the adopted child is an unreaped zombie, which is after the child's 300 ms exit delay and before the 5,000 ms TERM grace.cleanup.test.tsand the other real-broker spawn-broker test files did not run under Vitest on this head. The red/green above executed the test's own driver script, extracted byte-for-byte fromcleanup.test.ts, directly under Node. Exact-head hosted CI must run the spawn-broker suite itself.9ef4c65c411:cleanup-group.test.tspasses 18 of 18 in 1 file. With the empty-census and unreadable-census guards removed from the fix, exactly the two "retains and escalates a kernel-visible broker group" cases fail, so those cases do protect TERM/KILL escalation.tsgo:core), thesrctest typecheck (22 shards), core-scoped type-aware lint and format on the three changed files, andgit diff --checkpass. Ratchets against6a60076pass for max-lines, line-cap, assertion-safety, session-identity, timeout-race, mock-exports and test lines (net +132, within the 400-line allowance). Thedatabase-dialectratchet exceeded the memory cap and thedatabase-workerratchet was not attempted; this change touches no database code, and hosted CI runs both. Frozen dependency installation passed without manifest or lockfile changes.49b93b101d0(historical): 45 tests passed across 6 spawn-broker files with 1 Node-only case skipped, on baseaf300f44712. Those results are not claimed for the current head.stop_close_failed. With the fix it logged clean shutdown in 445 ms and exited 0. Four normal-shell control runs were already clean. Temporary processes, zombies, state and ports were removed.The original operator run's ancestor reaper state was not captured. The matching error and timings support this diagnosis, but the exact live ancestry and post-failure linger are not independently proven. No new call, model connection, production deployment, or live-service change was performed. The full build, the Vitest spawn-broker suite and the two database ratchets were not run on the current head; PR CI remains required. No canonical autoreview has run on this head.
Inspectable isolated-Gateway red/green proof
Baseline integration source:
3488f3f09731c1e1c0f83e9ce7ab7f080b0f70be. Fixed integration source: the same base with thecleanup.tsproduction change subsequently committed as18e0aa7b5f051d7115ae09f76d67b88f4a15141b. This earlier runtime experiment predates both the previously published head49b93b101d062edff8e1acb436140e80c1594433(with its additional conservative empty/unavailable-census guards) and the current head9ef4c65c41184f9991efc271ad6457eda5811209(ported onto main's asynchronous cleanup); it is not relabeled as a runtime run on either head. No isolated-Gateway run exists for the current head.Both runs launched the real source Gateway with isolated synthetic state, loopback listeners and a synthetic non-reaping child subreaper. No model, SIP or phone session was used. Here is selected original process-watch output for the baseline; numeric PIDs/PGIDs are consistently aliased. Columns within each entry are PID, PPID, process state and command.
Zentries remain adopted by the synthetic supervisor while their broker groups await confirmation.The same run's recorded zombie census associates
ZOMBIE_CwithBROKER_A's PGID, andZOMBIE_A/ZOMBIE_BwithNATIVE_BROKER_A's PGID (all three commands wereesbuild). This is a projection of recorded process identities, not an inferred relationship from the PPID column above.Baseline Gateway log excerpt (timestamps/messages preserved; PGID aliased):
Fixed Gateway log excerpt:
Recorded launcher wait status for the fixed process:
{ "status": 0, "elapsedS": 120.823 }status: 0is the recorded OS wait status;elapsedSis total launched-process lifetime including cold startup, not shutdown duration. The Gateway log reports its measured 445 ms shutdown. Temporary processes, zombies and listeners were checked absent afterward. The original operator run's supervisor ancestry was not captured; this proof establishes the controlled topology, not that unseen ancestry.Refresh review
An independent parent review checked this exact committed range against main
6a6007663b3, the merge resolutions, preserved upstream owners and terminal verification logs. The carrier feature and dependency patch was independently compared with the previous published range and remains unchanged. For the shutdown repair, the parent also reran the real-process fixture on9ef4c65under a task-owned memory cgroup: it settled in 460 ms while the adopted child was a zombie, with all four fixture checks passing. This is a focused refresh review, not a canonical autoreview, not full original-feature re-review, and not a current installed Gateway or conversation proof. The disclosed missing Vitest / resource-limited checks still require exact-head hosted CI.