Repository navigation
fix(process): Doctor and spawn-broker cleanup fail when the host denies process-group signals - #198132
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 changes before merge. What this changesUse a process census and individual process signals to settle Doctor and broker cleanup when Linux denies process-group signals. Example: Run openclaw doctor --fix --non-interactive under a Linux seccomp filter denying negative-PID kill calls.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains This PR fixes a demonstrated Linux cleanup failure and now supplies the requested upgrade proof, but its new regression fixture fails CI by launching a Node-only broker scenario under Bun. Priority: P1 Before merge
Findings
Agent review detailsHow this fits togetherCommand scopes and spawn brokers retain subprocess custody until cleanup confirms extinction; the changed owners translate signal failures and process-table observations into termination and settlement outcomes. flowchart TD
A[Doctor and command scopes] --> B[Process group observation]
C[Spawn broker shutdown] --> B
B --> D[Kernel group probe]
D --> E[Linux process census]
C --> F[Revalidated member signals]
E --> G[Cleanup settlement]
F --> G
Technical reviewBest possible solution: Keep the shared observation and broker cleanup repair, and launch its Node-only regression fixture with the existing explicit Node resolver. Do we have a high-confidence way to reproduce the issue? Contributor-supplied terminal evidence reproduces the failure on published 2026.11.3 and the merge base under a real seccomp filter; source inspection confirms the mechanism, and no target code was executed during this review. Is this the best way to solve the issue? The production change repairs the owning observation boundary and reuses broker member signaling without adding configuration or persistence; the regression launcher needs a focused runtime-selection correction. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b9f1e62e00d8. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceAcceptance criteria:
What I checked:
PR surfaceSource +151, Tests +387, Docs +4. Total +542 across 13 files. Added test files: 1. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel 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 November 13, 2026, 8:29 AM ET / 13:29 UTC (Revision 2). |
|
This is the latest-stable upgrade run you asked for. We upgraded the published Setup: Linux x86_64, Node 24.22.1, an isolated
The PR build carries main's version string, so Profile snapshot before the upgrade, then after the first filtered Doctor run on the PR build: This PR adds no schema or config changes. The version bumps come from migrations main gained since the stable tag, and they ran to completion under the filter. Redacted outputStable 2026.11.3 under the filter (complete output): PR build under the filter (Doctor phase lines; We also ran a control without the filter on the PR build. It printed the same |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…roup probes are denied Some Linux sandboxes deny kill(2) with a negative PID. OpenShell's child seccomp filter returns EPERM for any process-group signal, including the signal 0 probe. isChildProcessTreeAlive() treated that EPERM as "alive" forever, so command scopes, Doctor process custody and update handoffs never confirmed that a finished group was gone, and Doctor failed with "Command cleanup could not confirm that owned work stopped". isProcessGroupGone() now makes that decision for isChildProcessTreeAlive() and spawn-broker cleanup. The kernel probe still runs first and ESRCH still means gone. An EPERM only counts as a host denial when the same call against a group id above PID_MAX_LIMIT, which the kernel always answers with ESRCH, is refused too; a kernel EPERM from a member owned by another user keeps the group alive as before. On a denial, the /proc census decides: the group is gone when no member with that pgid is alive. A census failure, or a /proc that is not this PID namespace's, keeps the group alive. Hosts where group probes work take the same path as before. Signed-off-by: Emilien Macchi <[email protected]>
… denied Under a host that denies kill(2) with a negative PID, spawn-broker cleanup could neither probe nor signal its process groups. SpawnBrokerHost.close() failed with "Spawn broker group cleanup could not be confirmed ... kill EPERM", and the worker's retained detached groups rethrew EPERM and left the broker hanging. Doctor inspection cleanup then reported unfinished spawn-broker resources. Every broker group probe now goes through isProcessGroupGone(). When a group signal is denied, terminateBrokerProcessGroup() and the retained detached cleanup signal each census member by PID instead, after rechecking its pgid and start time, and repeat the current signal on every poll so members that join later are covered. One member that cannot be signaled no longer stops the others, and both paths record errors and retry until their deadline. The drain's existing per-member step is shared for this rather than copied. A detached lost child settles on the same group decision; without a recorded group identity it can be confirmed but still not signaled, as the docs now say. The host-side regression runs a real broker under the kernel seccomp fixture that denies group signals. When group signals work, cleanup takes the same path as before. Signed-off-by: Emilien Macchi <[email protected]>
Co-authored-by: sallyom <[email protected]>
041b1b2 to
1435ab7
Compare
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
…es process-group signals (openclaw#198132) * fix(process): confirm process-group extinction from the census when group probes are denied Some Linux sandboxes deny kill(2) with a negative PID. OpenShell's child seccomp filter returns EPERM for any process-group signal, including the signal 0 probe. isChildProcessTreeAlive() treated that EPERM as "alive" forever, so command scopes, Doctor process custody and update handoffs never confirmed that a finished group was gone, and Doctor failed with "Command cleanup could not confirm that owned work stopped". isProcessGroupGone() now makes that decision for isChildProcessTreeAlive() and spawn-broker cleanup. The kernel probe still runs first and ESRCH still means gone. An EPERM only counts as a host denial when the same call against a group id above PID_MAX_LIMIT, which the kernel always answers with ESRCH, is refused too; a kernel EPERM from a member owned by another user keeps the group alive as before. On a denial, the /proc census decides: the group is gone when no member with that pgid is alive. A census failure, or a /proc that is not this PID namespace's, keeps the group alive. Hosts where group probes work take the same path as before. Signed-off-by: Emilien Macchi <[email protected]> * fix(process): clean spawn-broker groups when negative-PID signals are denied Under a host that denies kill(2) with a negative PID, spawn-broker cleanup could neither probe nor signal its process groups. SpawnBrokerHost.close() failed with "Spawn broker group cleanup could not be confirmed ... kill EPERM", and the worker's retained detached groups rethrew EPERM and left the broker hanging. Doctor inspection cleanup then reported unfinished spawn-broker resources. Every broker group probe now goes through isProcessGroupGone(). When a group signal is denied, terminateBrokerProcessGroup() and the retained detached cleanup signal each census member by PID instead, after rechecking its pgid and start time, and repeat the current signal on every poll so members that join later are covered. One member that cannot be signaled no longer stops the others, and both paths record errors and retry until their deadline. The drain's existing per-member step is shared for this rather than copied. A detached lost child settles on the same group decision; without a recorded group identity it can be confirmed but still not signaled, as the docs now say. The host-side regression runs a real broker under the kernel seccomp fixture that denies group signals. When group signals work, cleanup takes the same path as before. Signed-off-by: Emilien Macchi <[email protected]> * test(process): run denied-group broker fixture with Node Co-authored-by: sallyom <[email protected]> --------- Signed-off-by: Emilien Macchi <[email protected]> Co-authored-by: sallyom <[email protected]>
Backport #198132. Classify host-denied negative-PID probes separately from genuine kernel EPERM and use a bounded namespace-checked census for command and broker group extinction. Reuse identity-revalidated member signaling for broker cleanup, including late members and KILL escalation. Keep service-relay anchor proof kernel-only. The real seccomp broker baseline left a descendant alive and failed shutdown; all 180 targeted cases now pass across 12 files. (cherry picked from commit 708c378) Signed-off-by: Emilien Macchi <[email protected]> Co-authored-by: sallyom <[email protected]> Co-authored-by: RomneyDa <[email protected]>
Closes #198130
What Problem This Solves
Fixes:
openclaw doctor --fixand spawn-broker shutdown fail when OpenClaw runs on a Linux host that denies process-group signals, such as inside an OpenShell sandbox.User Impact
User impact: OpenClaw inside an OpenShell sandbox (or under any seccomp rule that denies
kill(2)with a negative PID) can finish Doctor maintenance and shut its spawn broker down again. OpenClaw Enterprise holds Agent startup until Doctor reports settled maintenance, so this unblocks Agents that could not start after an upgrade (openclaw/openclaw-enterprise#5706). Hosts where group signals work are unchanged. No config, state or schema changes, and no update steps.Why This Change Was Made
OpenShell's child seccomp filter returns EPERM for every process-group signal, including the signal 0 probe. Two probes treated that EPERM as "still alive" forever:
isChildProcessTreeAlive()(command scopes, Doctor process custody, update handoffs) and the spawn-brokergroupGone(). Every wait ran to its deadline and failed.isProcessGroupGone()now makes that decision for both. The kernel probe still runs first. Only when the host itself denies the call (the same call against a group id abovePID_MAX_LIMIT, which the kernel always answers with ESRCH, is refused too) does the/proccensus decide, and it fails closed: a live member, a census error, or a/procfrom another PID namespace keeps the group alive. A kernel EPERM from a member owned by another user keeps the old answer. When a broker group signal is denied, cleanup signals each member by PID after rechecking its pgid and start time, reusing the drain's existing per-member step.Accepted edge cases, named rather than coded around:
/procscan. That is cheap in a sandbox (the OpenShell workload we checked has 6 processes) but scales with retained detached groups; sharing one census per tick is a possible follow-up.hidepidor a restricted/procunder the deny can still hide a member.Follow-ups, not in this PR: agent-core
killProcessTreegroup signals (used by exec-spawn stop, exec-termination, command custody, provider-local services, and a detached child lost with the broker before its group identity is recorded) still only signal the group, so under the deny those paths can now confirm extinction but cannot kill survivors.Overlap: #189415 changes the same
terminateBrokerProcessGroupconfirmation for zombie-only groups and leaves permission handling alone. ItsbrokerGroupHasLiveMemberscallsgroupGone(), which this PR replaces withisProcessGroupGone(), so whichever lands second needs a one-line rename.Evidence
Review follow-up on 2026-11-13
Rebased onto
mainat6eb8095ae971f51bfa547644d4d249c21ebb8335. Both original production commits remain patch-identical after the rebase. Follow-up commit1435ab73daa5adfaddresses ClawSweeper's remaining P2 finding: the Node-only broker scenario now usesresolveTestNodeExecPath()for bothexecFileandresolveRuntimeWorkerArgv. All existing shutdown and child-extinction assertions are retained.Focused proof on secretless AWS Linux, Node 24.22.1, with the rebased candidate's exact source tree verified before execution:
pnpm test src/process/spawn-broker/group-custody.test.ts --maxWorkers=1— 3/3 pass, including the real kernel seccomp scenario. Wall time 54.45 s, including 43.15 s of cold worker compilation; test bodies total 1.09 s.cleanup-group.test.ts,service-child-group-ownership.test.ts, andexec-spawn.test.ts— 70/70 pass across 4 files, 13.86 s wall time.node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.services.json --incremental— pass. The final formatting-only adjustment leaves the tested behavior unchanged; the final checked source tree matches the pushed commit.985779b9ea9aea9, before mechanical formatting — no actionable findings. The existing full-PR ClawSweeper review covers041b1b2509b; its sole remaining finding is addressed above. New-head broad CI is separate from these focused results.Current-head CI and inherited failure
CI run 43438047021, attempt 1 tested head
1435ab73daa5adf104f489b4c2f88a915eb8083ain merge checkoutb14d600d19758cb6aed4ceb911ffa4401c973a88against main64fd44bdaae8434611e841f4fb50d2443c9461f6. All 10 executed Node test shards and the executed lint, type, and security checks passed. CI remains failed, not green: checks-ui-e2e (1/3) timed out after 120000 ms inRead-only Home real Gateway > opens existing Home for a reader without granting writes and hides denied targets(ui/src/e2e/home-readonly.real-gateway.e2e.test.ts:45), making the downstreamopenclaw/ci-gatefail.The same test, timeout, and suite stack already fail in scheduled main run 43425732822, attempt 1 at
777c036d592808418f95da97cf6b4ee6af614bbc. The test, its shared suite support, andsrc/gateway/server.tsare byte-identical between that baseline, the CI main parent, and the tested PR merge; this PR changes no UI or Gateway source. This qualifies as an inherited unrelated CI failure for the authorized landing exception. Its underlying UI cause is not repaired or claimed to be a proven flake. No CI rerun or branch refresh was made solely to seek green.Contributor runtime and upgrade proof at
041b1b2509bRed on the original merge base
664a791058e, green on041b1b2509b, all under a real BPF filter that returns EPERM forkill()with a negative PID (the OpenShell rule; wrapper in the linked issue):node openclaw.mjs doctor --fix --non-interactive, isolatedHOMESpawnBrokerHostclose with an attached / detached childCommandProcessCleanupErrorafter 10 ssettleCommandProcessGroupscustodycleanup: "uncertain"after 10.3 scleanup: "normal"Upgrade from the latest stable: the published
[email protected]npm release (registry integrity verified) was upgraded to the packed build at041b1b2509b, with an isolatedHOME, and Doctor ran under the same filter. On 2026.11.3,doctor --fix --non-interactiveexits 1 with "Command cleanup could not confirm that owned work stopped" (exit 0 without the filter). After the upgrade, it exits 0 with "Doctor complete.", applies main's pending state and agent database migrations, and keeps the profile's four settings and all workspace files byte-identical. A rerun is clean. Steps, snapshot diff and redacted output: upgrade proof comment.Committed regressions, each red on the pre-fix source:
group-custody.test.tsruns a real broker in its own Node process under the repo's kernel seccomp fixture (installKillGroupSeccompFilter) and checks that close settles and a detached descendant dies.exec-spawn.test.tscovers scope settlement under a denied probe, that a kernel EPERM keeps the group alive without a census, and that the census never runs when the kernel probe works.service-child-group-ownership.test.tsandcleanup-group.test.tscover the census contract and per-member signalling (late joiners get SIGKILL, one unsignalable member does not stop the others, errors retry until the deadline, a foreign/procsignals nothing).Contributor local checks at
041b1b2509bon Linux with Node 24 (OPENCLAW_VITEST_RUNTIME=node; the pinned Bun fork could not be staged on that host): 61 test files acrosssrc/process/spawn-broker, the supervisor service-child suites and everyisChildProcessTreeAliveconsumer pass.tsgo:core,tsgo:test:src, oxlint and oxfmt on the changed files,check:test-mock-exports, both import-cycle guards andcheck:docspass.pnpm checkpasses every guard and typecheck lane. Its lint lane fails only on untouched files (mostlyui/), because of the plain-oxlint fallback without the Bun fork, and fails the same way on the base.proxy-retention.test.ts("releases completed command proxies after the host closes") is flaky on main without this change (2 of 3 runs fail).Size against the rebased merge base: production +229/-78 in three existing owners (
child-process-tree.ts,service-child-group-ownership.ts,spawn-broker/cleanup.ts), tests +389 net, docs +4. The drain's own per-member signalling moved into the shared step rather than being duplicated.