Repository navigation
fix: recover Linux stream automations after command-anchor crashes - #203149
Conversation
Worked on by: - @DonnieFi Co-authored-by: DonnieFi <[email protected]> OpenClaw-Publication: f661748b-286f-4b2e-9a63-08c463e19eb5
|
🦞👀 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 changesRetain an outer Linux subreaper so stream automations can restart after command-anchor crashes once descendant cleanup is confirmed. Example: A Linux stream emitting {} every two seconds loses its command anchor to SIGKILL.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a confirmed Linux automation recovery failure, and all three prior findings are addressed; no remaining actionable defect was found, while exact-head CI is still pending. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe process supervisor launches stream commands and owns their cleanup; the cron owner consumes command results and extinction confirmation before scheduling replacements. flowchart TD
A[Cron stream owner] --> B[Process supervisor]
B --> C[Outer Linux custodian]
C --> D[Command anchor]
D --> E[Source and descendants]
E --> C
C --> F[Kernel extinction certificate]
F --> B
B --> A
Technical reviewBest possible solution: Merge the existing-owner custody repair once the normal exact-head gates pass. Do we have a high-confidence way to reproduce the issue? Current source establishes the missing-receipt cleanup rejection and terminal restart path, supported by the reporter's released-version reproduction and the PR's before/after Gateway evidence. Is this the best way to solve the issue? The patch repairs cleanup at the shared process owner rather than clearing cron failures, reuses kernel subreaper custody, and preserves the existing restart and intentional-handoff contracts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f4ef065b92f1. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +187, Tests +121, Docs +2, Other +4. Total +314 across 14 files. Added test files: 0. 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: 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 (2 earlier review cycles)
Reviewed November 21, 2026, 11:34 AM ET / 16:34 UTC (Revision 3). |
Worked on by: - @DonnieFi Co-authored-by: DonnieFi <[email protected]> OpenClaw-Publication: 804ae956-6252-4826-b6c8-1cf779c86539
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Worked on by: - @DonnieFi Co-authored-by: DonnieFi <[email protected]> OpenClaw-Publication: 4c82b555-2bdd-4796-81a6-b5bf44c45d18
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…irement-rule * origin/main: (172 commits) test(gateway): expect a revoked person's Goal retry to be hidden as not found (#205698) fix: keep browser disabled when only hardening relay authentication (#203137) fix: recover Linux stream automations after command-anchor crashes (#203149) fix(whatsapp): identify voice-note captions as text in delivery receipts (#205381) fix(test): unblock restart-auth plugin and worker publication qualification (#205679) chore(ui): refresh control ui locales (#205691) fix: reduce memory during SQLite usage refresh (#201064) fix(plugins): readmit native captures with a dangling host link chore(i18n): refresh native locales (#205680) fix(update): hash SQLite lock bytes as zeros so Windows exclusion cannot fail verification (#205668) fix(skill-workshop): skip the skill diet for skills with Markdown outside support directories (#204881) fix(plugins): clarify dated SDK migration notices (#200932) fix: keep the resident launcher when reinstalling Gateway (#205655) fix: show the whole reply when you reopen a TUI session (#200455) test(ui): wait for restored speech player authorization (#199502) feat: let agents post approved GitHub comments (#204301) fix(agents): honor imageMaxDimensionPx at the provider and CLI image handoffs (#205663) chore(ui): refresh control ui locales (#205664) fix(google): preserve playback when Google Live splits audio into parts (#205364) fix: show named characters in exported session messages (#205362) ...
…penclaw#203149) Keep a separate Linux process owner alive when the command anchor crashes. Retire its descendants before restarting the stream, and leave cleanup unconfirmed if that process owner is lost. Closes openclaw#202900.
…203149) Keep a separate Linux process owner alive when the command anchor crashes. Retire its descendants before restarting the stream, and leave cleanup unconfirmed if that process owner is lost. Closes #202900. (cherry picked from commit fad575b) Release adaptation: None; source applies intact to current stable owner. Companion audit: PR #203149 is the source; keep the protocol, runtime-worker manifest, and cleanup refusal together. No native package bump. Co-authored-by: RomneyDa <[email protected]>
Closes #202900
What Problem This Solves
A Linux stream automation can stop permanently when its command anchor crashes: it immediately exhausts its restart budget, and disabling and re-enabling it cannot recover the retained cleanup failure. Simply clearing that failure is unsafe: a detached child can remain alive after both the source and anchor disappear.
User Impact
Stream automations recover through their existing backoff after the command anchor dies, including across shutdown and restart. Old descendants are stopped and reaped before replacement. No configuration or data migration is required.
Strict Linux child scopes retain one additional native relay process. Losing that final custodian remains fail-closed: neither retry nor manual enable overrides unconfirmed extinction. macOS/Windows, owned workers, and intentional root-exit handoffs keep their existing paths.
Why This Change Was Made
The existing relay now retains kernel subreaper custody outside the command anchor for strict, non-handoff Linux child scopes. After anchor loss, it adopts and reaps detached descendants and supplies an independent extinction certificate. The host joins that certificate, output/lineage closure, and relay exit before releasing cleanup. Cron continues using its existing restart owner and backoff; no exhaustion bypass is added.
Certificate observation stays with the retirement owner. Existing startup/private-input settlement moves into preparation to preserve the enforced module-size limit without changing its admission or cleanup behavior.
Evidence
Verified result (2026-11-21 16:51 UTC): The completed exact-head review rates patch quality 4/6 platinum, proof 5/6 diamond, with no actionable findings and ready for maintainer review. The exact-head CI gate is successful on
0c080a7fc16a7f0c341eb400df78e93a0d635b99; the full observed check inventory has no failed or active checks. This PR is open and non-draft; it has not been merged or deployed.Forced-cancellation review repair
The second hosted review, on
f2430a8c0f37f957dbda9dff0a03895fc014e2db, accepted both prior fixes and rated the real terminal proof 5/6, but found a P2 cancellation-result regression. That finding is repaired in0c080a7fc16a7f0c341eb400df78e93a0d635b99: after independent extinction is certified, an explicitly requested cancellation uses the existing requested-signal result instead of becoming an unexpected-anchor-loss error. Unexpected anchor loss still rejects its missing command result; loss of final custody still rejects cleanup.The new native regression runs a real child that ignores SIGTERM, then closes its strict scope within a 500ms cleanup budget. On the reviewed head cleanup succeeds but
run.wait()rejects; on the repaired head it returnsreason: manual-cancel,exitSignal: SIGKILL, and the child is absent. The unexpected-loss regression now explicitly requires the error rather than swallowing it. 88 native/supervisor cases pass (40.9s wrapper), including the failed-custody and deadline controls. Core/services-test types, touched-file lint/format, session-identity and line-cap guards pass; the runtime build and real Gateway matrix were rerun on this repaired tree. The final exact-head review and CI now pass, as recorded above.Review and CI repairs
The initial review of 3789e953445a identified two P2 defects, both reproduced locally and repaired in
f2430a8c0f37f957dbda9dff0a03895fc014e2db:Repair proof: the previously failing matrix file now passes all 4 cases; the selected matrix/resolver/native-host group passes 74 tests (45.2s wrapper), sealed-build consumers pass 70 tests, and the real cloud-worker mid-turn-loss composition passes (85.8s wrapper). That last local fixture initially lacked Debian
ps; genuine signed-repository procps 4.0.2 and its library were staged only in task scratch, then the same test passed through the real native utility. No application guard or test assertion was relaxed. Core, scripts, tooling-test and E2E-test typechecks, changed-file lint/format, line-cap, session-identity and runtime-process-lifecycle checks pass. The runtime build and full disposable Gateway matrix were rerun after repair. Initial CI run 44920799768 remains failed evidence for the first head; the final head has its own successful CI receipt above; the original failed run is not backdated green.Redacted terminal receipts from the repaired real Gateway run
The following is the terminal receipt projection from the same public CLI/Gateway reproduction, completed 2026-11-21 16:28 UTC on the repaired tree. Addresses, paths, process/job identifiers and credentials are omitted; statuses and observed cleanup results are retained. The published file blobs were compared with that tested tree. The before-state and source regression are described above; this is not an in-process mocked Gateway.
{"case":"midrun-recovered","at":"2026-11-21T16:27:57.933Z","streamStatus":"running","failures":1,"restartExhausted":false,"oldExtinct":true} {"case":"same-gateway-disable-enable","at":"2026-11-21T16:28:02.756Z","streamStatus":"running","failures":0,"restartExhausted":false} {"case":"gateway-stop","at":"2026-11-21T16:28:03.168Z","exitCode":0} {"case":"shutdown-reopen-recovered","at":"2026-11-21T16:28:10.774Z","streamStatus":"running","failures":1,"restartExhausted":false} {"case":"detached-descendant-reclaimed","at":"2026-11-21T16:28:47.538Z","streamStatus":"running","failures":1,"restartExhausted":false,"oldExtinct":true,"noOverlap":true} {"case":"custodian-loss-fail-closed","at":"2026-11-21T16:28:52.256Z","streamStatus":"error","failures":1,"restartExhausted":true,"noReplacement":true} {"case":"gateway-stop","at":"2026-11-21T16:28:52.644Z","exitCode":0} {"case":"cleanup","at":"2026-11-21T16:28:52.648Z","allRecordedProcessesAbsent":true,"portRebound":true}The source emitted
{}periodically with a deliberately nonmatching predicate, so these cases made no model turn. Faults targeted only fixture processes after checking their birth identity and ancestry. The real custodian-loss control remained in error and could not admit a replacement.The real disposable Gateway reproduced the original failure before the change. The repaired source passed the same production CLI/Gateway flows:
The final proof used a nonmatching stream predicate: no channel or model execution was needed. Every recorded fixture process disappeared, both Gateway stops exited 0, and the fixture port rebound successfully. This is Linux source proof with the normal pinned OpenClaw Bun runtime and a Node 24.20 feeder, not packaged-release or Node-26 parity.
0c475b963b585012a180030bdabbfb0016027505with the missing closing receipt, and passes on the candidate. The existing deadline test now stalls the final custodian rather than the recoverable inner anchor; it still requires a failed cleanup result.pnpm build:runtime, core and selected services-test typechecks, touched-file typed lint/format, line-cap/assertion-safety guards, import-cycle check, andgit diff --checkpassed.Focused commands and scope
node scripts/run-vitest.mjs src/process/supervisor/service-child-relay-host*.test.ts src/process/supervisor/service-child-relay.native-owner.test.ts src/process/supervisor/supervisor.cleanup-history.real.test.ts src/process/supervisor/supervisor.test.ts src/process/supervisor/supervisor.root-exit.real.test.ts src/gateway/cron-stream-watchers.extinction.test.ts src/gateway/server-cron.stream-lifecycle.test.ts --maxWorkers=1node scripts/run-tsgo-core-test-shards.mjs --changed-paths-json '["src/process/supervisor/service-child-relay-host.test.ts","src/process/supervisor/supervisor.cleanup-history.real.test.ts"]'The repair changes 14 existing files. No production cleanup path was replaced with a PID census or a fabricated receipt. Necessary growth is the independent native custody join and its regression coverage; the input-startup movement is behavior-preserving. Broader platform/CI proof remains with normal PR CI.
Requested by Donniefi. Original report and reproduction details by @warm-cloth.
Work sessions
Linked for team reference; these sessions aren’t public.
🦞 Made with OpenClaw
Worked on by