Skip to content

fix(process): a finished command is reported as timed out when the event loop lags - #159578

Merged
steipete merged 7 commits into
mainfrom
codex/exec-timeout-race
Sep 28, 2026
Merged

steipete merged 7 commits into
mainfrom
codex/exec-timeout-race

Conversation

@steipete

@steipete steipete commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: on a busy Gateway, a subprocess that already exited successfully can be reported as timed out (exit 124) because the overdue deadline timer runs before Node delivers the queued exit notification.

User Impact

User impact: short commands the Gateway runs (git, Crabbox, helper scripts) no longer fail as "timed out" just because the event loop was briefly busy when they finished; their real exit status and output are used. Commands that genuinely hang still time out, have their process tree killed, and report a timeout with the existing grace and settlement behavior.

Behavior note: a command that finishes and is fully drained before the deadline decision runs is reported with its real result even if the exit landed slightly after the nominal deadline during event-loop lag; the supervisor no longer infers a timeout from elapsed time alone. Deadline, kill, and grace ownership are otherwise unchanged.

Why This Change Was Made

Found during cloud-session stress testing: a managed git init returned 124 although it succeeded instantly when run directly. Reproduced with the production helper — runCommandWithTimeout(["git","--version"], { timeoutMs: 20 }) plus a 250 ms event-loop block returned 124 after ~291 ms with Git's successful stdout. The deadline timer ran before the queued child exit callback populated the exit state, and the accepted timeout then normalized native success to 124. Checking child.exitCode inside the timer is not enough on current Node (v26 assigns it inside the exit callback just before emitting). All three owners had the same ordering bug:

  • exec-runner.ts: deadline and no-output timers now decide through a shared deadline helper that defers the decision one I/O turn and preserves an exited, fully drained child;
  • exec.ts runExec: native and spawn-broker transports use the same corrected deadline (execa's own timeout is no longer used, so both transports share one owner);
  • supervisor.ts: timeout classification uses completed process state; the elapsed-time inference (resolveElapsedTimeoutReason, which classified any exit observed after the deadline as a timeout) is removed.
    Production +17 lines.

Evidence

  • The original reproduction returns 124 on main and 0 with this change; warmed-broker probes pass for ordinary commands, process-tree commands, and runExec.
  • pnpm test src/process/exec-runner.timeout.test.ts --maxWorkers=1: main 3 failed | 2 passed; here 9 passed, 30.8 s wall. Supervisor regression ("preserves a queued successful exit") fails on main.
  • pnpm test src/process/exec-runner.timeout.test.ts src/process/exec.test.ts src/process/exec.windows.test.ts src/process/child-process.test.ts src/process/spawn-broker/command-startup.test.ts --maxWorkers=1: 126 passed, 1 skipped (71.7 s). Supervisor suites (timeout-overflow, output-fence, readiness, output-activity): 20 passed.
  • Five existing fake-clock tests assumed a timeout is accepted in the same tick as its timer; they now advance through the deferred decision — no assertions weakened.
  • Core typecheck passed; independent Codex review (P2): scoped-clean. Windows taskkill/shim simulations pass; native Windows was not run.

Follow-up (ClawSweeper: independent broker deadline; test cost)

  • Broker execution backstop. Removing Execa's timeout also removed the spawn broker's independent deadline. Putting it back as a padded Execa timeout reintroduced the original bug: in the broker, Execa's timeout covers the whole subprocess promise, including output drain that waits on the stalled Gateway. With a 200 ms deadline plus 100 ms margin, a child that exited at 101 ms was still reported timedOut after a 453 ms parent stall. The broker now enforces an execution-only deadline instead (timeout + 1 s; the margin only absorbs broker scheduling lag). It kills the root only while the root is still running, using the configured kill semantics, and marks the result timedOut. Root exit clears it, and so does an earlier host cancellation. Because the check looks only at the root, it can never relabel an exited child. The Gateway's deferred decision stays primary. Native (non-broker) commands keep the Gateway-side watchdog only, since a second timer in the same process adds no independence.
  • Late EOF after exit. An exit notification could arrive before the deadline decision while stdout EOF came one turn later, and that was still reported as a timeout. Observed root exit now wins for runExec and non-tree runs, which already had a bounded post-exit drain. Successful owned trees keep the fix(process): preserve output and cleanup after command exit #140927 contract (descendant output stays under the command deadline; held pipes still time out). At the deadline they get one fixed 100 ms EOF grace (EXIT_STDIO_GRACE_MS) before the existing timeout path.
  • Tests and cost (pnpm test <file> --maxWorkers=1): exec-runner.timeout.test.ts 12 tests / 5.7 s (was 30.8 s before moving its mock boundary to exec-spawn). The live-broker file (execution-deadline.test.ts, real broker process with frozen Gateway timers) takes 40 s wall but only 2.5 s of test execution: shared worker-artifact setup dominates, and only real IPC can prove the deadline runs independently of Gateway callbacks. The expanded process run passes 314 tests (1 platform skip), including every fix(process): preserve output and cleanup after command exit #140927 ownership suite with its original expectations. Core and services tsgo, lint, format, and full-branch P2 review are clean.
  • Whole-branch size: production +82, tests +486.

@clawsweeper

clawsweeper Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 27, 2026
@clawsweeper

clawsweeper Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 28, 2026, 1:43 AM ET / 05:43 UTC (Revision 9).

ClawSweeper review

What this changes

Adjusts Gateway command runners, the spawn broker, and the process supervisor so delayed exit notifications do not turn completed commands into timeouts, with regression tests and a wrapper inventory update.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep open: current main still has the reported timeout race, and the branch has credible direct-path proof. The previously identified descendant-cleanup defect remains a merge blocker.

Priority: P1
Reviewed head: c89482d65be24e10c079b7b0d5bc4294670a73ff

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The reported real-path proof is useful, but an unchanged broker timeout path still violates owned process-tree cleanup.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The captured PR body reports a real production-helper before/after run: a successful Git command is returned as 124 on main and 0 with this branch under event-loop lag. The added real-broker test uses native child IPC with Gateway timers frozen and observes broker timeout recovery; it does not prove descendant cleanup for the blocking finding. No stored-data contract changes.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The captured PR body reports a real production-helper before/after run: a successful Git command is returned as 124 on main and 0 with this branch under event-loop lag. The added real-broker test uses native child IPC with Gateway timers frozen and observes broker timeout recovery; it does not prove descendant cleanup for the blocking finding. No stored-data contract changes.
Evidence reviewed 10 items Current main still needs the fix: The fetched main retains elapsed-time timeout inference, and its central process files match the PR base. The branch's deadline behavior is not already on main.
Introduced broker timeout trigger: The new independent broker deadline calls Execa's kill method when the root is still running.
Descendant killing is not selected by the tree option: Execa receives killDescendants only when a separate command process scope exists; killProcessTree on the runner does not set it.
Findings 1 actionable finding [P2] Clean up descendants after broker-accepted timeouts
Security None None.

How this fits together

OpenClaw runs agent and Gateway helper commands through its process runner. Local or brokered child processes produce exit and output events that the runner turns into command results and cleanup.

flowchart LR
A[Agent or Gateway command] --> B[Process runner]
B --> C[Local child or spawn broker]
C --> D[Exit and output events]
E[Configured timeout] --> F[Deadline decision]
D --> F
F --> G[Command result and cleanup]
Loading

Before merge

  • Clean up descendants after broker-accepted timeouts (P2) - With killProcessTree: true outside a separate command scope, this call signals only the root. If that root handles SIGTERM and exits zero while a descendant has closed inherited output, the runner skips tree termination, then marks the settled result timed out. The descendant can survive a reported timeout. Route this path through the existing tree cleanup owner and cover it with a real-broker regression.
  • Resolve merge risk (P2) - For a brokered killProcessTree command, the broker can report a timeout after killing only a cooperative root; a descendant that closed inherited output can continue running while cleanup settles as normal.
  • Complete next step (P2) - Repair broker-accepted timeout cleanup for owned descendants and verify it with a real-broker regression before merge.

Findings

  • [P2] Clean up descendants after broker-accepted timeouts — src/process/spawn-broker/execa-worker.ts:91
Agent review details

Security

None.

PR surface

Source +82, Tests +500, Other +1. Total +583 across 28 files.

View PR surface stats
Area Files Added Removed Net
Source 9 188 106 +82
Tests 18 523 23 +500
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 0 +1
Total 28 712 129 +583

Review metrics

Metric Value Why it matters
Production versus test growth production +82 net lines, tests +486 net lines The PR body attributes the production growth to deferred deadline decisions and an independent broker backstop, with regression coverage for both.

Merge-risk options

Maintainer options:

  1. Join broker timeout to tree cleanup (recommended)
    Have an accepted broker timeout settle the owned process tree before reporting completion, with a real-broker test whose root exits zero on SIGTERM while its descendant remains active.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Route broker-accepted timeouts for killProcessTree commands through the existing tree termination and settlement owner before the result is returned. Add a real-broker regression with a SIGTERM-handling root that exits zero and a descendant that closes inherited output; verify the descendant is gone and cleanup is not reported normal while it survives.

Technical review

Best possible solution:

Route broker-accepted execution timeouts through the existing process-tree termination owner before settlement, preserve the selected group identity, and prove descendant extinction through the real broker.

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

Yes. The PR gives a concrete production-helper run with a short git command and a blocked event loop, and current main retains the responsible timeout path; this read-only review did not execute it.

Is this the best way to solve the issue?

No, not yet. Deferring the deadline decision addresses the reported exit-ordering race, but the independent broker deadline must preserve the existing owned-tree cleanup contract.

Full review comments:

  • [P2] Clean up descendants after broker-accepted timeouts — src/process/spawn-broker/execa-worker.ts:91
    With killProcessTree: true outside a separate command scope, this call signals only the root. If that root handles SIGTERM and exits zero while a descendant has closed inherited output, the runner skips tree termination, then marks the settled result timed out. The descendant can survive a reported timeout. Route this path through the existing tree cleanup owner and cover it with a real-broker regression.
    Confidence: 0.95

Overall correctness: patch is incorrect
Overall confidence: 0.93

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P1: False timeouts can break real agent and Gateway command workflows when the event loop is busy.
  • merge-risk: 🚨 availability: The introduced broker deadline can leave an owned descendant running after a command reports timeout and cleanup completes.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (terminal): The captured PR body reports a real production-helper before/after run: a successful Git command is returned as 124 on main and 0 with this branch under event-loop lag. The added real-broker test uses native child IPC with Gateway timers frozen and observes broker timeout recovery; it does not prove descendant cleanup for the blocking finding. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured PR body reports a real production-helper before/after run: a successful Git command is returned as 124 on main and 0 with this branch under event-loop lag. The added real-broker test uses native child IPC with Gateway timers frozen and observes broker timeout recovery; it does not prove descendant cleanup for the blocking finding. No stored-data contract changes.

Evidence

Acceptance criteria:

  • [P2] pnpm test src/process/spawn-broker/execution-deadline.test.ts src/process/exec-runner.timeout.test.ts --maxWorkers=1.
  • [P1] pnpm test src/process/exec.test.ts src/process/exec-termination.test.ts --maxWorkers=1.
  • [P1] node scripts/check-changed.mjs --dry-run -- src/process/spawn-broker/execa-worker.ts src/process/exec-runner.ts src/process/spawn-broker/execution-deadline.test.ts.

What I checked:

  • Current main still needs the fix: The fetched main retains elapsed-time timeout inference, and its central process files match the PR base. The branch's deadline behavior is not already on main. (src/process/supervisor/supervisor.ts:90, 45b00bdd13c1)
  • Introduced broker timeout trigger: The new independent broker deadline calls Execa's kill method when the root is still running. (src/process/spawn-broker/execa-worker.ts:91, c89482d65be2)
  • Descendant killing is not selected by the tree option: Execa receives killDescendants only when a separate command process scope exists; killProcessTree on the runner does not set it. (src/process/exec-spawn.ts:343, c89482d65be2)
  • Pinned dependency termination contract: The target pins Execa 10.0.1. Its versioned termination documentation says subprocess.kill() signals only the root by default; killDescendants enables tree termination. (docs/termination.md)
  • Runner misses tree cleanup after a cooperative zero exit: The exit listener invokes tree termination for a nonzero exit or an explicit extinction request. A broker timedOut result is applied later, after process cleanup has begun settling. (src/process/exec-runner.ts:302, c89482d65be2)
  • Real-broker coverage gap: The production broker test freezes Gateway timers and checks that the root dies, but does not request killProcessTree or observe a descendant after a cooperative root exit. (src/process/spawn-broker/execution-deadline.test.ts:35, c89482d65be2)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add real-broker proof that a timeout extinguishes an owned descendant when the root exits zero after SIGTERM.

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.

History

Review history (8 earlier review cycles)
  • reviewed 2026-09-27T09:58:26.676Z sha bb2145b :: blocked before merge. :: [P2] Retain an independent deadline for brokered commands | [P3] Explain or reduce the new timeout suite's cost
  • reviewed 2026-09-27T10:39:13.191Z sha bb2145b :: blocked before merge. :: [P2] Restore independent deadline enforcement for brokered commands | [P3] Explain or reduce the new timeout suite's cost
  • reviewed 2026-09-27T11:12:09.236Z sha 6846f77 :: blocked before merge. :: [P2] Restore an independent deadline for brokered commands | [P3] Explain or reduce the new timeout suite's cost
  • reviewed 2026-09-27T14:16:47.127Z sha fc2e8be :: needs maintainer review before merge. :: none
  • reviewed 2026-09-27T18:21:22.971Z sha 254de9c865c23beba2c81c4501c8a20f6266f4d2 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-27T20:19:52.715Z sha ae114feb2f86b9cd7c82444776f854cab37adc75 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-27T21:01:41.972Z sha 1f46232 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-28T01:25:57.484Z sha 6def01f :: blocked before merge. :: [P2] Clean up owned descendants after broker-accepted timeouts

@steipete
steipete marked this pull request as ready for review September 27, 2026 10:11
@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: L and removed size: M labels Sep 27, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 27, 2026
@steipete
steipete force-pushed the codex/exec-timeout-race branch from fc2e8be to 254de9c Compare September 27, 2026 18:14
@steipete
steipete enabled auto-merge (squash) September 27, 2026 18:14
@steipete
steipete force-pushed the codex/exec-timeout-race branch from 254de9c to ae114fe Compare September 27, 2026 20:12
Let pending child notifications run before accepting process deadlines, and preserve exited commands whose drained output precedes broker result delivery. Keep inherited-pipe deadlines and existing cancellation, output limits, and process-tree cleanup.

Use one watchdog for native and brokered runExec calls. Remove supervisor timeout inference based on delayed result observation. This prevents successful Gateway subprocesses from becoming spurious timeout failures during event-loop stalls.

Validation: deterministic regressions fail before their fixes; 126 focused tests pass with one platform skip; related supervisor and idle-timeout tests pass. Core and all 25 selected test typecheck graphs, changed-file lint, and independent review pass. The full changed-check command was stopped under the host time limit during import-cycle scanning after its preceding gates passed.
Mock the spawn boundary for deterministic deadline tests so their fake children do not load the unrelated spawn and worker runtime closure. Keep all nine behavior assertions; standalone wall time falls from 30.84 seconds to 3.15 seconds.

Validation: 208 process tests passed with one platform skip; PR wrapper inventory and both requested provisioning cases passed. Scoped services tsgo, changed-file lint, formatting, and independent review passed. This commit does not change runtime timeout behavior; the independent backstop finding remains unresolved.
Give brokered command wrappers an execution-only deadline with one second of scheduling grace. The broker checks the native root state, retains configured kill escalation, clears the backstop on exit or earlier host cancellation, and reports accepted timeouts even after a cooperative zero exit. Native commands retain their local primary watchdog.

Preserve observed root exits while EOF or broker results are pending. Apply the existing 100ms idle and 1000ms hard output drain bounds to successful tree roots, and join owned descendants without rewriting the root exit status. Raw Execa timeout contracts remain unchanged.

Validation: 250 process tests passed with one platform skip, including live broker execution with frozen Gateway timers; wrapper inventory and both provisioning cases passed. Core and services test tsgo, changed-file lint and format, and independent review passed. Deterministic deadline regressions take 3.77s standalone. The live broker proof takes 40.06s wall with 2.47s test execution; its real process and IPC are required to prove an independently running deadline, while shared worker artifact setup accounts for most of the overhead.
Restore the successful owned-tree output contract from #140927: retain descendant output until the command deadline and preserve timeout classification for held pipes. Remove early output release and group termination after a successful root exit.

At the deadline, give an already-successful root one fixed 100ms EOF grace using the existing stdio grace constant. Both streams reaching EOF preserve the exit result; a held stream enters the existing timeout and cleanup path. Keep runExec and non-tree post-exit handling, the broker execution-only backstop, and broker timeout propagation.

Validation: 314 process tests passed with one platform skip, including all requested process ownership suites. The 12-case deadline regression file passed in 5.72s wall; wrapper inventory and both provisioning cases passed. Core and services test tsgo, changed-file lint/format, and full-branch P2 autoreview with the macOS private temporary directory passed.
@steipete
steipete force-pushed the codex/exec-timeout-race branch from ae114fe to 1f46232 Compare September 27, 2026 20:53
Command deadlines now take their timeout decision one timer turn after the deadline fires. The systemd availability test advanced fake time by exactly the deadline, leaving that decision pending until the real child exited and CI's 10 s test timeout expired. Advance to the next timer after the deadline. Failed 5/5 before, passes 5/5 after; process deadline suites pass (76).
@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Sep 28, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 28, 2026
@clawsweeper clawsweeper Bot added the status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. label Sep 28, 2026
Advance fake clocks through the queued deadline decision before asserting cancellation or awaiting construction and process settlement. Preserve MCP authority, exec liveness, and native process-group cleanup assertions.

Keep the production timer: setImmediate preserves native exit handling but still requires another fake-clock tick. No new real waits or child processes are introduced.
@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations agents Agent runtime and tooling labels Sep 28, 2026
@steipete
steipete merged commit cf14554 into main Sep 28, 2026
430 of 442 checks passed
@steipete
steipete deleted the codex/exec-timeout-race branch September 28, 2026 07:03
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 29, 2026
…ent loop lags (openclaw#159578)

* fix(process): preserve exits across delayed deadlines

Let pending child notifications run before accepting process deadlines, and preserve exited commands whose drained output precedes broker result delivery. Keep inherited-pipe deadlines and existing cancellation, output limits, and process-tree cleanup.

Use one watchdog for native and brokered runExec calls. Remove supervisor timeout inference based on delayed result observation. This prevents successful Gateway subprocesses from becoming spurious timeout failures during event-loop stalls.

Validation: deterministic regressions fail before their fixes; 126 focused tests pass with one platform skip; related supervisor and idle-timeout tests pass. Core and all 25 selected test typecheck graphs, changed-file lint, and independent review pass. The full changed-check command was stopped under the host time limit during import-cycle scanning after its preceding gates passed.

* build(pr): add the shared process deadline to the PR wrapper inventory

* test(process): isolate deadline regression spawn fixtures

Mock the spawn boundary for deterministic deadline tests so their fake children do not load the unrelated spawn and worker runtime closure. Keep all nine behavior assertions; standalone wall time falls from 30.84 seconds to 3.15 seconds.

Validation: 208 process tests passed with one platform skip; PR wrapper inventory and both requested provisioning cases passed. Scoped services tsgo, changed-file lint, formatting, and independent review passed. This commit does not change runtime timeout behavior; the independent backstop finding remains unresolved.

* fix(process): separate broker execution deadlines from output drain

Give brokered command wrappers an execution-only deadline with one second of scheduling grace. The broker checks the native root state, retains configured kill escalation, clears the backstop on exit or earlier host cancellation, and reports accepted timeouts even after a cooperative zero exit. Native commands retain their local primary watchdog.

Preserve observed root exits while EOF or broker results are pending. Apply the existing 100ms idle and 1000ms hard output drain bounds to successful tree roots, and join owned descendants without rewriting the root exit status. Raw Execa timeout contracts remain unchanged.

Validation: 250 process tests passed with one platform skip, including live broker execution with frozen Gateway timers; wrapper inventory and both provisioning cases passed. Core and services test tsgo, changed-file lint and format, and independent review passed. Deterministic deadline regressions take 3.77s standalone. The live broker proof takes 40.06s wall with 2.47s test execution; its real process and IPC are required to prove an independently running deadline, while shared worker artifact setup accounts for most of the overhead.

* fix(process): preserve descendant deadlines with bounded EOF grace

Restore the successful owned-tree output contract from openclaw#140927: retain descendant output until the command deadline and preserve timeout classification for held pipes. Remove early output release and group termination after a successful root exit.

At the deadline, give an already-successful root one fixed 100ms EOF grace using the existing stdio grace constant. Both streams reaching EOF preserve the exit result; a held stream enters the existing timeout and cleanup path. Keep runExec and non-tree post-exit handling, the broker execution-only backstop, and broker timeout propagation.

Validation: 314 process tests passed with one platform skip, including all requested process ownership suites. The 12-case deadline regression file passed in 5.72s wall; wrapper inventory and both provisioning cases passed. Core and services test tsgo, changed-file lint/format, and full-branch P2 autoreview with the macOS private temporary directory passed.

* test(daemon): let systemd deadline decisions settle after expiry

Command deadlines now take their timeout decision one timer turn after the deadline fires. The systemd availability test advanced fake time by exactly the deadline, leaving that decision pending until the real child exited and CI's 10 s test timeout expired. Advance to the next timer after the deadline. Failed 5/5 before, passes 5/5 after; process deadline suites pass (76).

* test(process): settle deferred deadlines in consumer tests

Advance fake clocks through the queued deadline decision before asserting cancellation or awaiting construction and process settlement. Preserve MCP authority, exec liveness, and native process-group cleanup assertions.

Keep the production timer: setImmediate preserves native exit handling but still requires another fake-clock tick. No new real waits or child processes are introduced.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations gateway Gateway runtime merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant