Repository navigation
fix(macos): node-host worker escapes the app's process group and outlives every worker restart - #135663
Conversation
MacNodeHostWorker launches `openclaw node worker` under ManagedProcess, which owns the child by process group (SIGTERM -pgid, 250 ms, SIGKILL -pgid). The CLI startup respawn re-executes the real worker with detached: true (setsid), so the app only ever owned the respawn wrapper. When the worker did not exit on the forwarded SIGTERM, the app's SIGKILL escalation killed the wrapper and orphaned the worker together with its codex app-server child. Set OPENCLAW_NO_RESPAWN=1 on the worker launch, matching the gateway's own node-worker supervisor, so the worker stays in the owned group. The package proof harness uses the same launch shape so requireProcessTreeExit proves the real worker exited, not only the wrapper.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed September 3, 2026, 12:35 AM ET / 04:35 UTC. ClawSweeper reviewWhat this changesThe PR sets the existing no-respawn launch contract for the macOS node-host worker and mirrors it in its owner test and packaged-worker verifier. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review Keep this PR open as the focused fix for the linked macOS worker-containment bug. The prior TLS finding is disproved by the existing startup path, and the current patch correctly prevents the detached respawn at the lifecycle owner. Priority: P1 Review scores
Verification
How this fits togetherThe macOS app launches a private Node worker and terminates its managed process group on restart or shutdown. CLI startup decides whether the real worker remains in that group or moves into a detached session the app cannot kill. flowchart LR
A[macOS app] --> B[Managed process group]
B --> C[Node worker launch]
C --> D{CLI respawn enabled?}
D -->|yes| E[Detached worker session]
D -->|no| F[App-owned worker]
F --> G[Shutdown removes worker tree]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceOther +7. Total +7 across 3 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Land the lifecycle-owner assignment with its existing focused coverage and packaged-worker verification, leaving any separate launchd TLS-policy discussion outside this containment repair. Do we have a high-confidence way to reproduce the issue? Yes: current source shows that the macOS app owns one process group while noninteractive CLI respawn can detach the real worker, and the supplied packaged baseline and candidate traces exercise that exact shutdown boundary. Is this the best way to solve the issue? Yes: applying the established no-respawn contract at the launch owner prevents the process-group escape instead of adding downstream orphan cleanup. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4e106e66581f. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
Preserve the contributor's no-respawn repair at the MacNodeHostWorker launch owner and the packaged verifier. ManagedProcess owns the direct process group; CLI startup respawn otherwise puts the actual worker in a separate session. The existing OPENCLAW_NO_RESPAWN contract keeps the packaged worker in-process. GitHub macOS baseline proof reproduced a SIGSTOP worker surviving after its launcher was reaped. The launch-environment regression failed with exit46, 26 controls passed, and exact worker cleanup succeeded. The outer expected-RED command's closure receipt remains unconfirmed; its namespace was retained. Fresh candidate build, package and native lifecycle proof run on GitHub CI. Non-test growth is six lines: one existing-contract assignment and two invariant comment lines at each launch site. No new option or process supervisor is added. The permanent test is net+1. Contributor ancestry is preserved. Co-authored-by: Colton Harris <[email protected]>
Preserve the reviewed worker containment repair and contributor ancestry while integrating current main build fixes for exact-head verification.
|
@clawsweeper re-review The latest TLS finding has a false premise at the exact reviewed head. The existing bootstrap test explicitly expects both values to be undefined when that option is false (node-startup-env.test.ts). This opt-out was preserved deliberately during the TLS planner refactor; its predecessor also used Linux-only discovery. These startup files are unchanged between the tested baseline, integrated main, this candidate, and the review's cited main. The launchd service owner separately opts into the Darwin defaults. It is not on the app-owned worker's launch path. The app retains inherited and explicit environment values, including CA settings, before assigning no-respawn (MacNodeHostWorker.swift:403–414). Adding service defaults here would introduce a separate policy change, not preserve a default lost by this patch. That app-versus-service policy difference remains a named follow-up; this PR makes no new private-CA connectivity claim. Disposition: skip the requested TLS assignments because they would change pre-existing behavior without the claimed regression. Keep the single process-group ownership repair. Its +3 app lines are one existing-contract assignment and two invariant comments; tooling mirrors that assignment, with +1 net test line. The refreshed packaged macOS proof passed all 27 owner tests and both actual worker scenarios. Both normal and SIGSTOP workers were absent when stop returned, with exact process identity, source/runtime integrity and cleanup verified. Exact-head GitHub CI passed 120 jobs, including all five Mac jobs. The PR body contains the full before/after evidence and its limits. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
…up (openclaw#135663) MacNodeHostWorker launches `openclaw node worker` under ManagedProcess, which owns the child by process group (SIGTERM -pgid, 250 ms, SIGKILL -pgid). The CLI startup respawn re-executes the real worker with detached: true (setsid), so the app only ever owned the respawn wrapper. When the worker did not exit on the forwarded SIGTERM, the app's SIGKILL escalation killed the wrapper and orphaned the worker together with its codex app-server child. Set OPENCLAW_NO_RESPAWN=1 on the worker launch, matching the gateway's own node-worker supervisor, so the worker stays in the owned group. The package proof harness uses the same launch shape so requireProcessTreeExit proves the real worker exited, not only the wrapper. Co-authored-by: Colton Harris <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
Closes #135660. Related worker-shutdown work: #135661.
What Problem This Solves
The macOS app owns its node-host worker through
ManagedProcessand a process group. CLI startup can instead launch the actual worker in a separate session, leaving the app owning only the startup wrapper. When shutdown kills that wrapper, an unresponsive worker can survive and become orphaned.The worker launch owner now sets the existing
OPENCLAW_NO_RESPAWN=1contract alongside its app execution settings. The packaged-worker verifier uses the same launch shape. This keeps the worker inside the process group already owned by the app and preserves the existing shutdown implementation.Production: +3 app lines; verification tooling: +3 lines; tests: +2/-1, net +1. Each non-test site adds one existing-contract assignment and two lines explaining the process-group invariant. No new configuration option, supervisor or protocol is introduced. Colton Harris's original commits remain in the ancestry.
Evidence
Current integrated head:
1dd2887cb5ad9a2297598065dcccdc63c73f863c, treeb4eb41c93ac95d855457cf3ae83aa1a74e5c5338. Candidate packaged-process proof and exact-head GitHub CI passed.The independent GitHub-hosted macOS baseline proof used the canonical staged package and actual Swift owner, with pinned Node 24.19.0. It observed a launcher and worker in separate process groups. In the unresponsive scenario, the same identified worker was stopped with SIGSTOP after readiness, survived
owner.stop()after its launcher was reaped, and remained under PPID 1 until exact-process cleanup removed it. The normal worker exited eventually after stop returned; this is not immediate joined shutdown.The permanent launch-environment regression failed as intended with exit 46; all 26 existing owner controls passed. Full frozen installation, package build/staging/native-first checks and Swift compilation passed. Source/lock/runtime receipts and raw index captures are retained. Only parsed index ctime/mtime fields changed; other index and packaged runtime bytes remained fixed.
The baseline's outer controller conservatively marks the expected failing test command as unconfirmed and retains its namespace. This is not a measured live-process result. The actual worker cleanup is independently established by exact PID, UID, birth, executable and group observations; whole-namespace deletion is not claimed for that baseline.
The exact candidate proof passed all 27 owner tests and both actual packaged-worker scenarios on GitHub-hosted macOS 26.5.2 / arm64, Xcode 26.6, Swift 6.3.3, and bundled Node 24.19.0. It performs a fresh full canonical build, package staging/native-first checks and Swift compilation on the integrated head.
PID, parent, process group, birth timestamp, UID and canonical executable were checked together; requested and canonical paths are recorded separately. Both later cleanup observations remain empty. There is no wrapper worker outside the app-owned group.
All 54 source bindings, tracked and installed locks, and 39,029 packaged runtime records remain unchanged. Independent parsing checked 20 raw-index captures across 36,821 entries; only five paths' ctime/mtime fields changed, with every other entry/extension byte fixed. The proof overlay was removed, source restoration succeeded, and the private namespace was removed with no unconfirmed failed command. The actual worker disappearance is measured separately from generic outer subprocess exit status.
Exact-head CI attempt 2 passed 120 jobs, with 14 skipped and zero failures. Every executed job used actual GitHub Actions runners: 115 Ubuntu, two macOS 26 and three macOS 15. All five Mac jobs, the package build and the aggregate gate passed.
The prior candidate attempt stopped at an unrelated shared UI startup budget failure before any owner tests or actual worker scenarios ran. After integrating canonical main507 build repairs, the fresh build above passed. No budget or unrelated product changes are introduced by this PR.
Independent product review is clean. The latest TLS review finding is inapplicable: entry.respawn explicitly calls the TLS planner with includeDarwinDefaults:false, and its Linux-only CA discovery returns undefined on Darwin. That unchanged startup path did not supply the proposed Darwin defaults before this PR; existing inherited/explicit CA settings remain preserved. The separate launchd service policy is not on this app-worker path. The detailed source/history disposition is posted with a re-review request. The proof covers direct app-owned worker containment, not separate provider-process shutdown or unrelated Accessibility behavior. The source-checkout compile-cache launcher remains a named separate follow-up.
Contributor: Colton Harris (@Colton-Harris).