Skip to content

fix(test): preserve survivor probe stderr after process exit - #155220

Merged
steipete merged 1 commit into
mainfrom
upd/survivor-probe-stderr-drain
Sep 21, 2026
Merged

steipete merged 1 commit into
mainfrom
upd/survivor-probe-stderr-drain

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes upgrade-survivor probe tests intermittently losing child validation diagnostics on hosted runners. Run 35654149298, job 106514023806 failed on #154920 with empty stderr in rejects loose numeric probe limits instead of parsing prefixes (core-tooling-7-hosted-2).

User Impact

No production behavior changes. The test helper reliably returns complete probe output together with the child result; invalid-limit assertions also require exit code 1 without a signal or timeout error.

Why This Change Was Made

runProbe() captured stderr on the child process's exit event, before its output pipes were guaranteed to drain. Resolve on close instead. The regression pauses the real probe child's stderr through the recorded exit event, then resumes it and requires the complete diagnostic. It uses no delay or invented error output.

The probe and original test blobs are identical between the failed merge's main parent (6615891cc3650b2136fa25c136ac37c8dc111676) and this branch's starting main (de5312833912c9926a80835c25139feaa0511c64). Today's survivor changes did not touch this probe; #154861 changes diagnostic artifact collection.

Evidence

  • Blacksmith Testbox tbx_01m32yckncrx90w3g3f8c7crdq, validation run, with the test and unchanged probe source hashes verified.
  • Pre-fix proof: restoring only the exit handler deterministically failed with expected '' to contain 'invalid --timeout-ms: 1e3', after recording exit code 1, no signal, and paused stderr. Restoring close passed.
  • pnpm test test/scripts/upgrade-survivor-probe-gateway.test.ts --maxWorkers=1: 12 passed; 3.657 s command wall time, 2.41 s Vitest duration (88% test time). The new regression took 47 ms in the local focused run.
  • N=20 complete file runs under CPU contention: 240/240 tests passed. Four CPU burners shared CPUs 0–1 with the test command; command wall times were 6.061–13.563 s. Both source hashes were rechecked and all burners stopped afterward.
  • node scripts/check-changed.mjs -- test/scripts/upgrade-survivor-probe-gateway.test.ts: passed, including root test typecheck, all dead-export scans, all script lint, and changed-test lint. The combined proof/check command exited 0 in 9m35s.
  • Codex P1 autoreview: clean. Formatting and git diff --check passed.
  • LOC split: production/tooling 0; tests/test support +33/-6. No timeout, retry, skip, dependency, option, or baseline changes.

Validation targets the real probe and its output-collection boundary; the original 82-file hosted shard was not replayed. Hosted PR CI timing is pending at authoring handoff.

@clawsweeper

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

@steipete
steipete marked this pull request as ready for review September 21, 2026 21:50
@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Sep 21, 2026
@steipete
steipete enabled auto-merge (squash) September 21, 2026 21:54
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 21, 2026
@clawsweeper

clawsweeper Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 21, 2026, 5:59 PM ET / 21:59 UTC.

ClawSweeper review

What this changes

The probe test helper waits for child output streams to close before returning results, adds a real-process stderr regression, and strengthens invalid-input exit assertions.

Merge readiness

✅ Ready for maintainer review

Keep open: this focused repair remains necessary on fetched main, and no actionable correctness or security findings were found. The deterministic regression addresses the reported output-drain race.

Priority: P2
Reviewed head: 4c4329708b3d9dcfa1caec32089632c7317cfbb1

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, correct lifecycle repair with meaningful deterministic regression coverage and documented validation.
Proof confidence 🌊 off-meta tidepool Not applicable: The external-contributor proof gate does not apply to this maintainer-authored test-only PR. Its captured Testbox evidence exercises the changed collector with the real probe child and records diagnostic recovery after switching to close.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The external-contributor proof gate does not apply to this maintainer-authored test-only PR. Its captured Testbox evidence exercises the changed collector with the real probe child and records diagnostic recovery after switching to close.
Evidence reviewed 8 items Pinned introduced change: The merge-base-to-head diff changes only the probe test helper and its assertions. Completion moves from exit to close; the regression pauses the real child's stderr, observes exit, resumes reading, and checks the diagnostic. The spawn spy is restored in finally.
Still necessary on main: Fetched main still snapshots the output at exit. A separate comparison found no changes to this file between the pinned merge base and fetched main.
Latest release comparison: The supplied latest release, v2026.9.5, also contains the exit-based collector; it does not contain this repair.
Findings None None.
Security None None.

How this fits together

Upgrade-survivor tests launch a Gateway health-probe script and collect its exit status and diagnostic output. This change affects the test harness that reports those results, without changing the probe or installed updater.

flowchart LR
  A[Test arguments] --> B[Probe test helper]
  B --> C[Real probe child]
  C --> D[Exit status]
  C --> E[Buffered diagnostic output]
  D --> F[Wait for stream closure]
  E --> F
  F --> G[Result assertions]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +27. Total +27 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 33 6 +27
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 33 6 +27

Review metrics

Metric Value Why it matters
Regression cost 47 ms regression; 3.657 s focused-file wall time The captured measurements show that deterministic process-boundary coverage stays within the documented test budget.

Technical review

Best possible solution:

Keep output collection in the existing test helper and publish results only after its child streams finish draining.

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

Yes: pausing the real probe child's stderr through exit exposes the collector's premature snapshot, and the captured validation reports the expected pre-fix failure. This review verified the source path without executing it.

Is this the best way to solve the issue?

Yes: close is the correct completion boundary for collected child output, and the regression preserves real process behavior without adding sleeps, retries, or production seams.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This repairs a concrete diagnostic-collection race in test infrastructure with no production behavior 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: The external-contributor proof gate does not apply to this maintainer-authored test-only PR. Its captured Testbox evidence exercises the changed collector with the real probe child and records diagnostic recovery after switching to close.

Label justifications:

  • P2: This repairs a concrete diagnostic-collection race in test infrastructure with no production behavior 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: The external-contributor proof gate does not apply to this maintainer-authored test-only PR. Its captured Testbox evidence exercises the changed collector with the real probe child and records diagnostic recovery after switching to close.

Evidence

What I checked:

  • Pinned introduced change: The merge-base-to-head diff changes only the probe test helper and its assertions. Completion moves from exit to close; the regression pauses the real child's stderr, observes exit, resumes reading, and checks the diagnostic. The spawn spy is restored in finally. (test/scripts/upgrade-survivor-probe-gateway.test.ts:61, 4c4329708b3d)
  • Still necessary on main: Fetched main still snapshots the output at exit. A separate comparison found no changes to this file between the pinned merge base and fetched main. (test/scripts/upgrade-survivor-probe-gateway.test.ts:61, bc41bb950b65)
  • Latest release comparison: The supplied latest release, v2026.9.5, also contains the exit-based collector; it does not contain this repair. (test/scripts/upgrade-survivor-probe-gateway.test.ts:61, ec9c1a13db89)
  • Authoritative child-process lifecycle: The changed file directly uses node:child_process. Node v24.16.0 emits exit before scheduling stdio flushing; close is emitted only after the required closure count is reached. This supports waiting for close before reading accumulated output. (lib/internal/child_process.js:272, c7d10158bc31)
  • Captured validation evidence: The supplied PR body reports a deterministic failure when restoring exit, success with close, 12 passing focused tests in 3.657 seconds, a 47 ms regression, and 240/240 passing cases under CPU contention. It explicitly discloses that the original 82-file hosted shard was not replayed. No tests were executed during this read-only review. (4c4329708b3d)
  • Validation reservation status: The linked Testbox reservation workflow is marked cancelled, so its workflow conclusion does not independently certify the reported commands. The captured body records the individual command results and source-hash verification.

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • vincentkoc: 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.

@steipete
steipete merged commit f56c75f into main Sep 21, 2026
120 checks passed
@steipete
steipete deleted the upd/survivor-probe-stderr-drain branch September 21, 2026 22:05
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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