Skip to content

chore: show OS state for stalled CLI process tests - #151946

Merged
steipete merged 1 commit into
mainfrom
upd/flake83c-cli-exit-no-signal
Sep 19, 2026
Merged

steipete merged 1 commit into
mainfrom
upd/flake83c-cli-exit-no-signal

Conversation

@steipete

@steipete steipete commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

CLI process test failures can print complete output and then reach the deadlock guard without answering either SIGUSR2 diagnostic hook, leaving CI without OS-level evidence of the stalled process.

Maintainer-requested diagnostic follow-up. Related: #151161. Observed in the gateway-backed CLI shard.

User Impact

No user-visible runtime change. This is test instrumentation; it does not claim to fix the intermittent CLI exit failure.

Why This Change Was Made

The child harness now captures PID ancestry, process state, and Linux per-thread wait channels, kernel stacks, and signal status before requesting the Node report. A separate observer bounds the entire probe and reports partial or unavailable evidence. It omits command arguments, environment, and command names.

The exact failing revision already disables both warning and compile-cache respawn. The watched PID is the real CLI, and missing credentials are rejected before opening a Gateway client. The normal path unwinds runCli cleanup, prints guidance, drains output, and calls process.exit(1). Node 24.19.0 implements report-on-signal through a JavaScript signal callback, so absence of both dumps does not independently prove a watchdog failure. CI uses a prepared JavaScript entrypoint, so a TSX loader-thread explanation also needs direct evidence. A native exit-time wait remains a hypothesis until captured.

Evidence

The helper suite passed 18/18 on macOS. The busy-loop and SIGSTOP assertions both failed against the original harness because its errors contain no OS snapshot; both passed after restoring this patch. Both the scoped pre-commit review and the requested branch review (--mode branch --base origin/main --max-priority P1) are scoped-clean. pnpm check:changed passed after correcting five brace-style lint findings.

The exact agentic-cli-process-hosted-3 mix is src/cli/gateway-backed-exit.process.test.ts (42 cases). With OPENCLAW_VITEST_MAX_WORKERS=2, 30 complete runs passed (1,260 cases), plus 14 standalone focused runs; no wedge was captured. The target's 30-run distribution was min 530 ms, median 564 ms, p95 742 ms, max 797 ms. This Testbox used Node 24.19.0, exposed 4 CPUs, and backed /tmp with ext4; the failing CI job reported 2 logical CPUs. The original job did not record cgroup or filesystem facts, and the Testbox's cgroup-v2 limit files were not exposed.

The 30-run snapshot differs from this head only by the five brace-style corrections. On committed head b9f4f62b2bc6d57f8299d222d3dab42410737c0a, both Linux injected-state checks passed, then all 200 focused repetitions passed with --repeats 199 and zero retries. Reporter-observed per-repeat intervals: min 523 ms, median 728 ms, p95 915 ms, max 1,368 ms. This fresh Testbox exposed 4 CPUs and 15.4 GiB RAM, versus the original CI shard's reported 2 logical CPUs and 7.66 GiB; both used Node 24.19.0. Neither probed cgroup-v1 nor cgroup-v2 limit interface was exposed on the Testbox.

No wedged state or production mechanism was captured in the requested campaign. The fix remains diagnostics-only. The external campaign watcher was armed to capture the process tree and force SIGUSR2 throughout it before the existing guard; it never fired. The injected busy-loop/SIGSTOP cases prove the committed observer still reports OS state when the child cannot answer.

Testbox runs: full-shard cohort and committed-head focused cohort. These are delegated Testbox leases: individual test results and the focused wrapper's exit 0 are the proof; ending the leases can cancel their hosting workflows. The first cohort driver was intentionally interrupted after the completed 30 full runs and 14 extra focused passes to switch to native repeat mode.

Production LOC: 0. Tests and test support: +165 / -33 (net +132).

Exact-head CI on df3130db49d50f9e3e9ea26d576bac4cde47c1d2 is green: the aggregate gate succeeded, and all 159 check runs are complete with success, skipped, or neutral conclusions. The earlier unrelated Gateway task-list performance failure is superseded by this current-head proof; no CI rerun was requested for landing.

ClawSweeper also reviewed this exact head: no actionable findings and ready for maintainer review.

ClawSweeper disposition (September 19, 2026): the latest review at 17:22 UTC covers this exact head, lists no actionable findings, and has no Rank-up moves or before-merge requests. No code changes or review rerun are needed. The campaign review of record is scoped-clean at P0/P1.

@clawsweeper

clawsweeper Bot commented Sep 18, 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.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: S maintainer Maintainer-authored PR labels Sep 18, 2026
@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 Sep 18, 2026
@clawsweeper

clawsweeper Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 19, 2026, 4:34 PM ET / 20:34 UTC (Revision 5).

ClawSweeper review

What this changes

Adds bounded operating-system process snapshots to stalled CLI tests, including Linux thread state, before requesting Node diagnostics.

Merge readiness

✅ Ready for maintainer review

Keep open: this remains a useful diagnostic addition absent from current main. No actionable correctness or security findings were identified, consistent with the previous review of the same head.

Priority: P3
Reviewed head: df3130db49d50f9e3e9ea26d576bac4cde47c1d2

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused diagnostic improvement with meaningful subprocess coverage and no identified blocking defects.
Proof confidence 🌊 off-meta tidepool Not applicable: The contributor-proof gate is exempt for this maintainer-authored test instrumentation. Supplied macOS/Linux injected-child results target the changed harness; the repetition campaign does not establish the natural stall's cause.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The contributor-proof gate is exempt for this maintainer-authored test instrumentation. Supplied macOS/Linux injected-child results target the changed harness; the repetition campaign does not establish the natural stall's cause.
Evidence reviewed 9 items Introduced scope: The independently inspected merge-base-to-head delta contains only the CLI harness, its tests, and two observer support files; unrelated endpoint drift was excluded.
Timeout and cleanup integration: The harness marks the deadline as final before capturing OS state, then requests existing diagnostics and retains its existing forced-child cleanup and original failure handling.
Bounded, restricted diagnostic capture: The observer has a one-second execution timeout and 256 KiB output limit. Its process listing excludes arguments, environment, and command names; Linux reads select thread state, wait channels, stacks, and signal status.
Findings None None.
Security None None.

How this fits together

The CLI test harness launches real child processes and collects their output and exit status. When a child exceeds its deadline, this change gathers operating-system evidence before the existing diagnostic and cleanup sequence.

flowchart TD
  A[CLI process test] --> B[Child process harness]
  B --> C{Deadline exceeded?}
  C -->|No| D[Output and exit result]
  C -->|Yes| E[Bounded OS observer]
  E --> F[Node diagnostic request]
  F --> G[Failure report and child cleanup]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +132. Total +132 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 4 165 33 +132
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 165 33 +132

Review metrics

None.

Technical review

Best possible solution:

Keep OS capture in the shared CLI deadline path while preserving failure semantics, restricted diagnostic output, and existing cleanup ownership.

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

Not applicable to a production fix: this PR adds instrumentation. Busy-loop and stopped-child scenarios directly exercise the diagnostic gap; the intermittent CI stall itself remains unreproduced.

Is this the best way to solve the issue?

Yes. Capturing OS state before signaling addresses unresponsive children without depending on their event loop or changing successful test execution.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against e9390ffd104e.

Labels

Label justifications:

  • P3: This improves test-failure diagnostics without changing user-facing runtime behavior.
  • 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: The contributor-proof gate is exempt for this maintainer-authored test instrumentation. Supplied macOS/Linux injected-child results target the changed harness; the repetition campaign does not establish the natural stall's cause.

Evidence

What I checked:

  • Introduced scope: The independently inspected merge-base-to-head delta contains only the CLI harness, its tests, and two observer support files; unrelated endpoint drift was excluded. (df3130db49d5)
  • Timeout and cleanup integration: The harness marks the deadline as final before capturing OS state, then requests existing diagnostics and retains its existing forced-child cleanup and original failure handling. (src/cli/cli-process-child.test-helpers.ts:319, df3130db49d5)
  • Bounded, restricted diagnostic capture: The observer has a one-second execution timeout and 256 KiB output limit. Its process listing excludes arguments, environment, and command names; Linux reads select thread state, wait channels, stacks, and signal status. (src/cli/cli-process-tree.test-support.ts:16, df3130db49d5)
  • Meaningful regression coverage: The changed table exercises real busy-loop and SIGSTOP children through the harness and checks OS state in the resulting timeout error. Existing tests retain normal exit, diagnostic-grace failure, pipe cleanup, and detached-handoff coverage. Tests were inspected, not executed during this read-only review. (src/cli/cli-process-child.test-helpers.test.ts:206, df3130db49d5)
  • Current-main necessity: Current main's CLI timeout path still requests only the existing Node and JavaScript diagnostics; it does not call the new OS observer. (src/cli/cli-process-child.test-helpers.ts:317, e9390ffd104e)
  • Latest-release comparison: The v2026.9.5 harness also uses the signal-based diagnostic path without OS snapshot capture. A local historical-object read failed, so the release source was checked through GitHub's contents API. (src/cli/cli-process-child.test-helpers.ts:217, ec9c1a13db89)

Likely related people:

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

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 (4 earlier review cycles)
  • reviewed 2026-09-18T16:26:58.324Z sha b9f4f62 :: blocked before merge. :: none
  • reviewed 2026-09-18T16:50:30.157Z sha b9f4f62 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-18T17:13:01.077Z sha b9f4f62 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-19T17:22:44.067Z sha df3130d :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as ready for review September 18, 2026 16:43
steipete added a commit that referenced this pull request Sep 19, 2026
Infrastructure tests could pass and then stall during fork termination without identifying the outstanding resource or blocked wait.

Extend the existing diagnostic forks adapter to the infra pool and capture bounded active-resource, thread, child-process, and blocked-wait evidence after ten seconds. A separate Linux observer can collect evidence even when the worker event loop is blocked. Preserve Vitest shutdown ownership, deadlines, isolation, and worker limits, and join diagnostic capture before removing its temporary directory.

This is internal test instrumentation with no user-visible runtime change. The natural intermittent stall was not reproduced, so this change does not claim to resolve its root cause. Related: #151663, #151946.

Validation: normal shutdown and three injected stalled-shutdown scenarios, Linux observer boundary proof, 93/93 routing assertions, and changed-file checks passed. The hosted campaign passed 20 repetitions, 80 plan invocations, and 1,000 fork teardowns. Exact-head CI run 35416912203 passed; the native watcher excluded 12 superseded check contexts. Campaign autoreview was scoped-clean, and the exact-head ClawSweeper review had no actionable findings or Rank-up moves.

Production LOC: 0. Tests: +123/-23. Test support: +272/-5.
Capture bounded process and Linux thread state before requesting child diagnostics. Preserve the original deadlock failure and cleanup when JavaScript cannot answer SIGUSR2. Related to #151161.
@steipete
steipete force-pushed the upd/flake83c-cli-exit-no-signal branch from b9f4f62 to df3130d Compare September 19, 2026 17:15
@steipete steipete changed the title improve: show OS state for stalled CLI process tests chore: show OS state for stalled CLI process tests Sep 19, 2026
@steipete
steipete merged commit 19448d8 into main Sep 19, 2026
283 of 285 checks passed
@steipete
steipete deleted the upd/flake83c-cli-exit-no-signal branch September 19, 2026 20:42
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 20, 2026
Infrastructure tests could pass and then stall during fork termination without identifying the outstanding resource or blocked wait.

Extend the existing diagnostic forks adapter to the infra pool and capture bounded active-resource, thread, child-process, and blocked-wait evidence after ten seconds. A separate Linux observer can collect evidence even when the worker event loop is blocked. Preserve Vitest shutdown ownership, deadlines, isolation, and worker limits, and join diagnostic capture before removing its temporary directory.

This is internal test instrumentation with no user-visible runtime change. The natural intermittent stall was not reproduced, so this change does not claim to resolve its root cause. Related: openclaw#151663, openclaw#151946.

Validation: normal shutdown and three injected stalled-shutdown scenarios, Linux observer boundary proof, 93/93 routing assertions, and changed-file checks passed. The hosted campaign passed 20 repetitions, 80 plan invocations, and 1,000 fork teardowns. Exact-head CI run 35416912203 passed; the native watcher excluded 12 superseded check contexts. Campaign autoreview was scoped-clean, and the exact-head ClawSweeper review had no actionable findings or Rank-up moves.

Production LOC: 0. Tests: +123/-23. Test support: +272/-5.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 20, 2026
Stalled CLI test children can miss both JavaScript diagnostic signals, leaving the deadlock guard without OS evidence. Capture bounded PID ancestry, process state, and Linux thread wait channels, stacks, and signal status in the shared CLI test harness before requesting Node diagnostics. Preserve the existing deadline failure and joined child/pipe cleanup.

Test instrumentation only; no user-visible runtime change. The intermittent CLI exit failure remains unproven. Related: openclaw#151161.

Validation: 18/18 helper tests, busy-loop and SIGSTOP regression checks on macOS and Linux, 30 full-shard runs (1,260 cases), and 200 focused repetitions. Exact-head CI passed; campaign review and ClawSweeper found no actionable defects. Production LOC: 0; tests and test support: +165/-33.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes 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