Skip to content

chore(process): make descendant termination proof deterministic - #131876

Merged
steipete merged 1 commit into
mainfrom
steipete/busy-pasteur-48b1aa
Aug 28, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/busy-pasteur-48b1aa

Conversation

@steipete

@steipete steipete commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Related: #106495 (buffered execution through Execa), #107011 (earlier descendant-test timing adjustment).

What Problem This Solves

Resolves a problem where the buffered process-tree regression test could report a normal exit instead of the expected timeout under process-startup load. This is a maintainer-requested repair of the existing test, not a runtime timeout-policy change.

Why This Change Was Made

The fixture let its direct child exit before the descendant had installed its SIGTERM handler. The normal 100 ms inherited-pipe idle release could then settle Execa and clear the command deadline. Raising the deadline from 50 ms to 500 ms in #107011 did not synchronize that setup.

The fixture now acknowledges readiness over real IPC after installing its handler and a quiet keepalive, observes the direct child's actual exit through the existing pass-through spawn helper, and advances only host deadlines. It separately proves SIGTERM receipt and survival, then descendant disappearance after the existing kill grace. Quiet output prevents EPIPE from masquerading as force-kill proof. Cleanup restores timers and the spy, kills the owned process group, settles the command, and removes temporary artifacts. No production API or implementation changes.

User Impact

No user-visible behavior, configuration, timeout, or runtime changes. Developers get deterministic coverage of cancellation and force-kill after direct-child exit.

Production LOC: +0/-0. Tests: +86/-40 (net +46), entirely in src/process/exec.test.ts.

Evidence

  • Before/after: a diagnostic 250 ms descendant initialization delay reproduced the original failure in full-file execution order (normal code: 0, termination: exit). The repaired full file passed with that same delay: 40 passed, 1 platform skip. The diagnostic delay is not included in the patch.
  • Negative controls: disabling post-exit cancellation failed the SIGTERM acknowledgment assertion; suppressing SIGKILL failed descendant disappearance. Both temporary production mutations were removed.
  • The repaired full file passed three further runs in the original execution order, and passed after final type/lint cleanup.
  • Existing sibling proof covered inherited-pipe draining, no-output deadlines, process-group escalation, and simulated Windows semantics: 101 passed, 1 platform skip across five files. Windows intentionally does not reclassify a completed direct child as timed out; no real Windows execution is claimed.
  • Fresh Codex autoreview: clean at the configured P0 threshold, with no accepted/actionable findings. AI-assisted; maintainer reviewed the lifecycle behavior and cleanup.

Local validation after a normal dependency install:

  • node scripts/check-changed.mjs -- src/process/exec.test.ts passed, including the full dead-export scans, core-test typechecks, and changed-file lint.
  • node scripts/run-tsgo-core-test-shards.mjs passed. The prior local Pako declaration error was an incomplete installation; pnpm install restored UI Pako 3.0.1 and its bundled declarations without manifest or lockfile edits.
  • node scripts/run-tsgo.mjs -b test/tsconfig/tsconfig.core.test.other.json --builders 1, targeted oxlint, formatting, and git diff --check passed.

After rebasing, node scripts/run-vitest.mjs src/process/exec.test.ts src/process/child-process.test.ts src/process/exec.no-output-timer.test.ts src/process/kill-tree.test.ts src/process/exec.windows.test.ts passed again: 101 passed, 1 skipped. Targeted core-test types, formatting, and git diff --check also passed. The rebased patch is byte-identical to the reviewed patch.

Exact-head CI run 33186830918 passed for e2a7e65b1db8101986e1cac78162f7ebc265a0e1. The Linux changed-test job ran the full exec.test.ts file: 40 passed, 1 skipped, including the repaired descendant case. Native review artifacts validate with zero findings. ClawSweeper review follow-through: latest review reported no code findings. Both remaining items are satisfied: exact-head CI 33186830918 and its Linux process integration job passed; direct local inspection of pinned Execa 10.0.1 lib/resolve/wait-subprocess.js:85 and lib/resolve/wait-stream.js:87 confirmed exit-plus-stream settlement and readable-stream destruction semantics. The reviewer could not inspect its own dependency checkout, but that gap is covered by this direct source inspection and the passing integration run. No production change or additional repair is needed. Native OPENCLAW_TESTBOX=1 scripts/pr prepare-run 131876 passed hosted gates and preserved the exact reviewed head.

@steipete steipete self-assigned this Aug 28, 2026
@clawsweeper

clawsweeper Bot commented Aug 28, 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 size: S maintainer Maintainer-authored PR labels Aug 28, 2026
@steipete
steipete marked this pull request as ready for review August 28, 2026 15:47
@steipete

steipete commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Land-ready proof for source head e2a7e65b1db8101986e1cac78162f7ebc265a0e1.

This repairs the fixture's unproven descendant readiness, not production timeout or pipe-drain policy. Real IPC and direct-child exit establish setup; separate SIGTERM receipt/survival and descendant-disappearance assertions prove escalation. Production +0/-0; tests +86/-40.

Local proof:

  • node scripts/check-changed.mjs -- src/process/exec.test.ts — passed all guards, dead-export scans, core-test types, and lint.
  • node scripts/run-tsgo-core-test-shards.mjs — passed. Normal pnpm install resolved the earlier Pako declaration installation gap without manifest/lockfile edits.
  • node scripts/run-vitest.mjs src/process/exec.test.ts src/process/child-process.test.ts src/process/exec.no-output-timer.test.ts src/process/kill-tree.test.ts src/process/exec.windows.test.ts — 101 passed, 1 skipped before and after rebase.
  • node scripts/run-tsgo.mjs -b test/tsconfig/tsconfig.core.test.other.json --builders 1, node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/process/exec.test.ts, node_modules/.bin/oxfmt --check src/process/exec.test.ts, and git diff --check — passed; targeted types and formatting repeated after rebase.

The original full-file failure and the fixed run used the same diagnostic 250 ms startup delay. Negative controls independently failed when post-exit cancellation or SIGKILL was disabled; those diagnostic changes are not in this PR. Fresh Codex autoreview was clean at P0, and the rebased patch matches the reviewed bytes.

Exact-head CI 33186830918 passed. Linux job 98902091464 ran the full exec.test.ts: 40 passed, 1 skipped, including this test. Native review artifacts validated with zero findings. No real Windows run is claimed; this case is POSIX-only and the simulated Windows sibling tests passed. ClawSweeper review follow-through: latest review reported no code findings. Both remaining items are satisfied: exact-head CI 33186830918 and its Linux process integration job passed; direct local inspection of pinned Execa 10.0.1 lib/resolve/wait-subprocess.js:85 and lib/resolve/wait-stream.js:87 confirmed exit-plus-stream settlement and readable-stream destruction semantics. The reviewer could not inspect its own dependency checkout, but that gap is covered by this direct source inspection and the passing integration run. No production change or additional repair is needed. No unresolved review conversations exist. Native OPENCLAW_TESTBOX=1 scripts/pr prepare-run 131876 completed successfully; hosted gates passed and the source head did not change. Proceeding through native merge only.

@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 Aug 28, 2026
@clawsweeper

clawsweeper Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 28, 2026, 11:54 AM ET / 15:54 UTC.

ClawSweeper review

What this changes

The PR makes the buffered-command descendant-cleanup test deterministic by synchronizing descendant readiness over IPC and checking graceful and forced process-tree termination separately.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open. Current main still contains the timing-sensitive fixture, while this PR replaces it with a readiness-synchronized lifecycle proof; it is a maintainer-owned test-only repair awaiting the normal exact-head check completion.

Priority: P3
Reviewed head: e2a7e65b1db8101986e1cac78162f7ebc265a0e1

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused fixture is well scoped and exercises the production lifecycle boundary; only normal exact-head validation remains.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored, test-only PR is exempt from the external-contributor real-behavior-proof gate; its body nevertheless records focused after-fix process-test runs.
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, test-only PR is exempt from the external-contributor real-behavior-proof gate; its body nevertheless records focused after-fix process-test runs.
Evidence reviewed 6 items Introduced deterministic fixture: The introduced test waits for a descendant IPC readiness message, verifies SIGTERM acknowledgement while the descendant remains alive, then advances the existing kill grace before asserting termination.
Current-main necessity: Fetched current main still uses the prior fixture, which writes a PID and lets its direct child exit immediately; the central test-stability problem is not already implemented there.
Production owner boundary: runCommandBuffered enables process-tree termination by default and delegates to the timeout runner; the PR leaves that production path unchanged.
Findings None None.
Security None None.

How this fits together

Buffered command execution starts a process, captures its pipes, enforces deadlines, and terminates its process tree when needed. This test exercises that lifecycle through the public buffered-command helper and observes the spawned parent and descendant.

flowchart LR
  A[Buffered command test] --> B[Command runner]
  B --> C[Spawned parent]
  C --> D[Ready descendant]
  B --> E[Timeout cancellation]
  E --> F[Graceful signal]
  F --> G[Forced cleanup]
Loading

Before merge

  • Resolve merge risk (P1) - Review limitation: the workspace lacks installed Execa source and GitHub DNS was unavailable for direct upstream inspection; the PR does not alter that dependency surface, but exact-head integration checks should complete before landing.
  • Complete next step (P2) - No repair task is needed; this maintainer-owned PR needs ordinary exact-head CI and latest-review guidance confirmation before landing.
Agent review details

Security

None.

PR surface

Tests +46. Total +46 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 86 40 +46
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 86 40 +46

Review metrics

Metric Value Why it matters
Production versus test LOC production +0/-0; tests +86/-40 (net +46) All changed lines are in the descendant-lifecycle regression test; no runtime behavior or public contract is added.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the synchronized fixture and land it after exact-head checks confirm the process test suite; retain the production timeout and termination implementation unchanged.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the synchronized fixture and land it after exact-head checks confirm the process test suite; retain the production timeout and termination implementation unchanged.

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

Yes, from source: current main's fixture permits its direct child to exit immediately after reporting a PID, while the production runner deliberately retains POSIX tree-cancellation ownership after that exit. The PR body also records a before/after full-file reproduction.

Is this the best way to solve the issue?

Yes. Synchronizing readiness at the test-fixture boundary directly removes the startup race without widening production timeouts or changing process-tree policy.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a bounded internal test-reliability repair with no user-visible runtime change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored, test-only PR is exempt from the external-contributor real-behavior-proof gate; its body nevertheless records focused after-fix process-test runs.

Label justifications:

  • P3: This is a bounded internal test-reliability repair with no user-visible runtime change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored, test-only PR is exempt from the external-contributor real-behavior-proof gate; its body nevertheless records focused after-fix process-test runs.

Evidence

What I checked:

Likely related people:

  • steipete: Peter Steinberger authored the reviewed test commit and the two supplied, merged predecessor PRs on the same buffered-execution and descendant-cleanup surface. (role: process-lifecycle feature owner; confidence: high; commits: e2a7e65b1db8, db02a96c4c7a, 704b17d80f36; files: src/process/exec.test.ts, src/process/exec-runner.ts, src/process/child-process.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 a3c445d into main Aug 28, 2026
198 of 199 checks passed
@steipete
steipete deleted the steipete/busy-pasteur-48b1aa branch August 28, 2026 16:00
@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

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant