Skip to content

fix(process): keep signal forwarding through child errors - #126493

Merged
steipete merged 1 commit into
mainfrom
codex/autoqa-155-process-signal-bridge
Aug 20, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/autoqa-155-process-signal-bridge

Conversation

@steipete

@steipete steipete commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Closes #126488

What Problem This Solves

Fixes an issue where a failed signal delivery or IPC operation could make a live CLI respawn, relaunched TUI, or fleet logs --follow child stop receiving later parent termination signals. Node reports those operational failures through the child's error event without necessarily ending the process, but OpenClaw treated every child error as terminal and released process ownership early.

Why This Change Was Made

The shared child-process bridge now keeps signal forwarding installed until Node reports the terminal exit or close lifecycle event. The respawn runner, TUI launcher, and Fleet stream runner keep persistent error listeners and settle immediately only for a true spawn failure, identified by an undefined child PID. Successful exit and spawn-failure behavior remain unchanged, while post-spawn errors no longer cancel respawn escalation or release terminal/stream ownership.

This is the canonical owner-boundary repair: Node's error event is an operational report, while exit and close own terminal state. A shared exported helper or broader bridge API was rejected because the three local PID checks express the dependency contract without expanding the process API. Detaching only on close was also rejected because exit preserves prompt signal-listener cleanup for normally terminated children.

User Impact

Supervisors and operators can continue to stop respawned CLI, TUI, and Fleet follow processes after a transient signal or IPC failure. Those children no longer risk being silently orphaned because one nonterminal error disabled later signal forwarding.

Evidence

  • Before the fix, the live bridge probe showed its signal listener count drop from 1 to 0 after an EPERM-style child error, and a later parent signal produced zero child kill calls. The new owner regressions failed on the frozen baseline for the same reason in the bridge, respawn, TUI, and Fleet paths.
  • After the fix, the live bridge probe retained one listener across the error, forwarded the later signal, then detached on close.
  • Node 24.19.0 and Node 26.7.0 contract/source probes confirm failed kill() and repeated IPC errors can leave the PID/handle live, while spawn failure has no PID and proceeds from error to close.
  • Focused tests: process bridge 2/2, respawn runner 8/8, TUI launcher 8/8, Fleet container runtime 35/35, entry respawn 21/21, compile-cache respawn 15/15.
  • node scripts/check-changed.mjs -- <8 changed paths> passed all selected formatting, typecheck, lint, architecture, state/database, import-cycle, and safety gates.
  • P1 autoreview and a separate read-only owner/caller/dependency review reported no actionable findings and judged this the cleanest bounded repair.
  • Exact-head CI passed: https://github.com/openclaw/openclaw/actions/runs/32318855839
  • ClawSweeper exact-head review generated no findings or Rank-up moves, cleared security, and passed pnpm openclaw --help: https://github.com/openclaw/clawsweeper/actions/runs/32318951966. Its public comment publisher was still pending at landing time.
  • Exact reviewed head: 3495ce55d8054fb29c39e23c326226590d372f73.
  • Production LOC: +17/-5 (net +12). Tests: +196/-2 (net +194).
  • AI-assisted: yes. The implementation and tests were read and verified against the Node runtime contract.

Proof gap: no packaged supervisor or platform-specific end-to-end signal session was run. The repair is covered by deterministic owner-boundary regressions, live Node runtime probes on the two supported runtime lines, exact-head CI, and the ClawSweeper terminal smoke.

@clawsweeper

clawsweeper Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added fleet size: M maintainer Maintainer-authored PR labels Aug 20, 2026
@steipete
steipete marked this pull request as ready for review August 20, 2026 00:51
@steipete

steipete commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Land-ready proof for 3495ce55d8054fb29c39e23c326226590d372f73:

  • Before: the bridge regression lost its parent signal listener after a live-PID error; respawn, TUI, and Fleet regressions settled early and consumed their only error handler.
  • After: the live bridge probe retained forwarding across the operational error, forwarded the next parent signal, and detached on close.
  • Focused tests passed: bridge 2/2, respawn 8/8, TUI 8/8, Fleet 35/35, entry respawn 21/21, compile-cache respawn 15/15.
  • Changed-path gate passed, including production/test typechecks, changed lint, formatting, import cycles, state/database guards, and runtime sidecar checks.
  • P1 autoreview: clean, no accepted/actionable findings.
  • Independent read-only review: clean; best-fix verdict was the bounded owner-boundary repair.
  • Exact-head CI: green — https://github.com/openclaw/openclaw/actions/runs/32318855839
  • ClawSweeper final review: no findings and best-solution verdict yes — fix(process): keep signal forwarding through child errors #126493 (comment)
  • ClawSweeper before-merge items are satisfied: exact-head CI is green; the production +12 is the three local PID guards plus terminal bridge ownership, while a shared helper would widen the process API; maintainer decision is to land through the repository-native workflow.
  • ClawSweeper terminal smoke passed — https://github.com/openclaw/clawsweeper/actions/runs/32318951966
  • LOC: production +17/-5 (net +12); tests +196/-2 (net +194).
  • Proof gap: no packaged supervisor or platform-specific end-to-end signal session; the lifecycle behavior is covered by the deterministic regressions and live Node 24/26 runtime probes.

Ready for the repository-native prepare and merge gates.

@clawsweeper

clawsweeper Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 19, 2026, 8:59 PM ET / August 20, 2026, 00:59 UTC.

ClawSweeper review

What this changes

The PR keeps CLI respawn, relaunched TUI, and Fleet log-follow child processes responsive to later parent signals after nonterminal Node child-process errors.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep open. Current main still removes signal forwarding on every child error; this PR moves cleanup to terminal lifecycle events and preserves true spawn-failure handling across all three affected owners. No blocking patch defect found; the maintainer-labelled PR needs normal exact-head CI and maintainer merge handling.

Priority: P2
Reviewed head: 3495ce55d8054fb29c39e23c326226590d372f73
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-backed owner-boundary repair with direct regression coverage; exact-head CI remains the normal merge gate.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored process-lifecycle PR is not subject to the external-contributor real-behavior-proof gate.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored process-lifecycle PR is not subject to the external-contributor real-behavior-proof gate.
Evidence reviewed 6 items Current-main failure path: Current main detaches the bridge on every child error, which removes the parent signal listeners before a still-live child reaches a terminal event.
Node ChildProcess contract: Installed Node type documentation states that a failed spawn has an undefined PID and emits error, while a failed signal delivery may emit error; this supports retaining the PID-based distinction.
Owner-boundary repair: The branch detaches the shared bridge on exit or close, while respawn, TUI, and Fleet retain error listeners that only settle when PID is undefined.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw --help

Result: PASS (completed)

runner@runnervmzvulz:/tmp/clawsweeper-live-proof-126493-fqi1UJ/target$ pnpm openclaw --help
$ node scripts/run-node.mjs --help
pnpm openclaw --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 115.91 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.7s
node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

[tsdown-build] invocation 2/2 finished in 12.9s
[plugin-control-plane-loads] verified 36 built modules with native require and checked doctor closures
runtime-postbuild: 10 phases completed in 3829ms (slowest: built plugin control-plane loads 2952ms)

OpenClaw 2026.8.1 (3495ce5) — All your chats, one OpenClaw.

Usage: openclaw [options] [command]

Options:
  --container ‹name›   Run the CLI inside a running Podman/Docker container named ‹name› (default: env OPENCLAW_CONTAINER)
  --dev                Dev profile: isolate state under ~/.openclaw-dev, default gateway port 19001, and shift derived ports (browser/canvas)
  -h, --help           Display help for command
  --log-level ‹level›  Global log level override for file + console (silent|fatal|error|
… output truncated …

Assertions:

  • PASS expect_output: Usage: openclaw [options] [command]

How this fits together

OpenClaw launches child processes for CLI respawn, TUI relaunch, and Fleet log following. Their shared bridge forwards parent termination signals and must only clean up after the child has actually ended.

flowchart LR
  A[Parent process] --> B[Signal bridge]
  B --> C[CLI, TUI, or Fleet child]
  C --> D[Operational error]
  C --> E[Exit or close]
  D --> B
  B --> F[Forwarded termination]
  E --> G[Bridge cleanup]
Loading

Decision needed

Question Recommendation
Should this maintainer-owned process-lifecycle repair merge once required checks are green on its exact head? Merge after exact-head CI: Land the focused owner-boundary repair once required checks complete successfully on commit 3495ce5.

Why: The PR is maintainer-labelled and changes child shutdown ownership, so the final merge choice needs explicit maintainer judgment despite the clean source review.

Before merge

  • Resolve merge risk (P1) - A PID-classification mistake would alter shutdown behavior across CLI respawn, TUI, and Fleet follow processes; required exact-head CI is still in progress.
  • Resolve merge risk (P1) - Production code grows by 12 net lines; the local PID checks are justified because a shared helper would widen the process API without reducing owner-specific behavior.
  • Complete next step (P2) - This protected maintainer-labelled PR needs normal maintainer merge handling, not a separate repair dispatch.
Agent review details

Security

None.

PR surface

Source +12, Tests +194. Total +206 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 4 17 5 +12
Tests 4 196 2 +194
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 213 7 +206

Review metrics

Metric Value Why it matters
Production and regression LOC production +17/-5 (net +12); tests +196/-2 (net +194) The production growth implements three local PID guards; the larger test delta covers the shared bridge and each affected process owner.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #126488
Summary: This PR is the concrete candidate repair for the canonical child-process signal-forwarding report.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Complete exact-head verification (recommended)
    Allow required checks to finish successfully for the reviewed head before merging this process shutdown change.

Technical review

Best possible solution:

Keep the local PID-based spawn-failure checks and exit-or-close bridge cleanup, then merge after exact-head CI confirms the covered process paths.

Do we have a high-confidence way to reproduce the issue?

Yes—source-reproducible but not executed here: current main detaches the bridge on error, while the supplied focused tests exercise a live-PID error followed by a later parent signal.

Is this the best way to solve the issue?

Yes. Node’s PID/error contract supports keeping the shared bridge until exit or close while leaving each local owner responsible for true spawn failure.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against c6ecfd26e5f4.

Labels

Label changes:

  • add P2: This fixes an edge-case shutdown failure that can leave a live local child process without later parent signal forwarding.
  • add merge-risk: 🚨 availability: The patch changes signal forwarding and terminal cleanup for CLI, TUI, and Fleet child processes.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Label justifications:

  • P2: This fixes an edge-case shutdown failure that can leave a live local child process without later parent signal forwarding.
  • merge-risk: 🚨 availability: The patch changes signal forwarding and terminal cleanup for CLI, TUI, and Fleet child processes.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Evidence

What I checked:

  • Current-main failure path: Current main detaches the bridge on every child error, which removes the parent signal listeners before a still-live child reaches a terminal event. (src/process/child-process-bridge.ts:47, c6ecfd26e5f4)
  • Node ChildProcess contract: Installed Node type documentation states that a failed spawn has an undefined PID and emits error, while a failed signal delivery may emit error; this supports retaining the PID-based distinction.
  • Owner-boundary repair: The branch detaches the shared bridge on exit or close, while respawn, TUI, and Fleet retain error listeners that only settle when PID is undefined. (src/process/child-process-bridge.ts:46, 3495ce55d805)
  • Focused regression coverage: New tests cover the bridge lifetime and both spawn-failure and repeated operational-error behavior in each affected owner. (src/process/child-process-bridge.test.ts:7, 3495ce55d805)
  • Regression provenance: Blame ties the current-main terminal-on-error bridge line to the merged lifecycle commit associated with the earlier process behavior. (src/process/child-process-bridge.ts:47, db533799d592)
  • Release timing: The latest release commit predates both the current-main behavior and this repair, so the issue remains current-main work rather than a released fix. (0790d9f593ad)

Likely related people:

  • steipete: Blame attributes the current-main bridge and sibling error handlers to the earlier lifecycle commit, and this PR updates the same owner boundary. (role: introduced the current lifecycle behavior and authored the repair; confidence: high; commits: db533799d592, 3495ce55d805; files: src/process/child-process-bridge.ts, src/process/respawn-child-runner.ts, src/tui/tui-launch.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 3bfc9bc into main Aug 20, 2026
229 checks passed
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fleet maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Child process errors can disable signal forwarding before exit

1 participant