Skip to content

fix(test): preserve shard crash exit codes and failure reports - #134688

Merged
steipete merged 1 commit into
mainfrom
codex/fix-vitest-crash-exit
Sep 1, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/fix-vitest-crash-exit

Conversation

@steipete

@steipete steipete commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Resolves a problem where a Vitest shard killed by SIGABRT or SIGKILL was recorded as exit 143 in the test wrapper's failure digest and retained report index.

This follows a report that an OOM during pnpm test src/commands printed passed 2 Vitest shards and exited zero. Current main already removed that historical signal-loss path in #133309 and #132716. This PR corrects the remaining result mismatch and adds real-process regression coverage for the original false-success contract.

Why This Change Was Made

Normalize the effective forwarded or child signal once at the shard completion boundary using the existing signalExitCode helper. The scheduler, report owner, and failure digest now receive the same nonzero signal-derived code. Ordinary numeric exits retain their existing behavior.

Production/tooling LOC: +6/-6. Test and fixture LOC: +40/-1. No new production API, option, dependency, or fallback.

User Impact

Test-wrapper failure evidence accurately records SIGABRT as 134 and SIGKILL as 137. Regression tests require both serial and parallel crashes to fail, omit a passing summary, and end with a failure trailer through the project runner and JavaScript wrapper.

Evidence

  • Before the change: the new seven-case crash matrix had four passing cases and three failures because reports recorded 143 instead of 134/137.
  • After the change: 15 focused crash, success, ordinary failure, and cancellation cases passed:
    node scripts/run-vitest.mjs test/scripts/vitest-report-owner.test.ts -t 'preserves shard crashes|retains the exact case union.*serial|retains the exact case union.*parallel|publishes complete evidence.*failure|never publishes incomplete.*cancel'
  • Manual real OOM proof: a child launched at the Vitest process boundary with --max-old-space-size=16 exhausted its heap during the src/commands runner flow. The fatal V8 OOM remained visible; the runner exited 134 and its final stderr line was [test] FAILED (exit 134).
  • Fresh Codex autoreview completed with no accepted/actionable findings at its default P0 threshold. Formatting and git diff --check passed. Changed-file validation passed on Blacksmith Testbox tbx_01m1de6770rh777tz9etkp3zks, Actions run 33464239543; the one-shot lease stopped successfully. Exact-head hosted CI 33464291816 passed at 95bf5027ea570cb42425253f9c5ba77889290497.
  • Dependency contract: Node's child-process exit event reports a null code and a signal on signal termination: https://nodejs.org/api/child_process.html#event-exit.

The crash tests use real Vitest processes and synthetic temporary configs, with no production test seam. POSIX signal assertions are skipped on Windows. This does not diagnose or fix the original command-suite heap growth.

Follow-up identified during sibling inspection: the plugin batch runner separately records code ?? 1 for signaled report outcomes. Its owner still propagates termination and rejects incomplete reports; normalizing those report codes belongs with its own batch/trailer coverage.

@clawsweeper

clawsweeper Bot commented Sep 1, 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 scripts Repository scripts size: S maintainer Maintainer-authored PR labels Sep 1, 2026
@steipete
steipete marked this pull request as ready for review September 1, 2026 02:54
@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready proof for 95bf5027ea570cb42425253f9c5ba77889290497:

The historical false-success signal branch was already removed by #133309 and #132716. This change fixes the remaining producer mismatch: the shard completion adapter used 143 for every signal. It now reuses signalExitCode for the effective forwarded/child signal before the scheduler, failure digest, or report owner consumes it. Production/tooling delta is +6/-6; tests and fixture are +40/-1.

The new native-process matrix failed three report-code assertions before the change (143 versus 134/137) and all seven cases passed afterward. With existing serial/parallel success, ordinary failure, and cancellation coverage, 15 focused cases passed:

node scripts/run-vitest.mjs test/scripts/vitest-report-owner.test.ts -t 'preserves shard crashes|retains the exact case union.*serial|retains the exact case union.*parallel|publishes complete evidence.*failure|never publishes incomplete.*cancel'
node scripts/check-changed.mjs -- scripts/test-projects.mts test/scripts/vitest-report-fixture.ts test/scripts/vitest-report-owner.test.ts

A separate real V8 heap exhaustion at the shard process boundary (--max-old-space-size=16) preserved the fatal OOM text, exited 134, and ended with [test] FAILED (exit 134). The signal matrix covers both project and JavaScript wrapper entrypoints without a new production test seam.

Changed-file checks passed on Blacksmith Testbox tbx_01m1de6770rh777tz9etkp3zks (run 33464239543); its one-shot lease and local sync cleanup completed. Exact-head CI 33464291816 is green. Fresh Codex autoreview reported no accepted/actionable findings at its default P0 threshold. The clean rebase changed none of the inspected runner/fixture surfaces.

Limits: POSIX signal cases are skipped on Windows. This is wrapper evidence and reporting repair, not a fix for command-suite heap retention. The sibling plugin-batch numeric report-code inconsistency is recorded in the PR body as a separate follow-up.

@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 1, 2026
@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 31, 2026, 11:11 PM ET / September 1, 2026, 03:11 UTC.

ClawSweeper review

What this changes

The branch preserves each crashed Vitest shard’s actual signal-derived exit code in test-runner failure output and retained report metadata.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

The patch is correct and remains necessary: current main still hard-codes 143 for all shard signals. It is maintainer-labeled work, so it should stay open for normal maintainer handling.

Priority: P2
Reviewed head: 95bf5027ea570cb42425253f9c5ba77889290497

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, net-neutral boundary repair with credible real-process regression evidence and no identified introduced defect.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: This maintainer-authored, maintainer-labeled PR is exempt from the external-contributor proof gate; its supplied terminal evidence nevertheless matches the changed project-runner boundary and records after-fix SIGABRT/SIGKILL failure outcomes.
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, maintainer-labeled PR is exempt from the external-contributor proof gate; its supplied terminal evidence nevertheless matches the changed project-runner boundary and records after-fix SIGABRT/SIGKILL failure outcomes.
Evidence reviewed 6 items Introduced repair: The PR replaces the two hard-coded 143 fallbacks with one effective signal and the repository’s canonical signalExitCode mapping.
Current-main behavior: Fetched main still contains the old forwarded-signal and child-signal fallbacks that record 143, so this PR is neither obsolete nor implemented on main.
Owner-boundary flow: The watched-process owner returns the child signal and forwarded signal; the project runner records the normalized outcome, stops scheduling, and emits the matching failure trailer. The report owner persists the outcome and rejects signaled attempts from aggregate publication.
Findings None None.
Security None None.

How this fits together

The test project runner launches Vitest shards and passes outcomes to the scheduler, failure digest, and optional retained reports. This change normalizes signal termination before those consumers record the outcome.

flowchart LR
  A[Vitest shard] --> B[Process completion]
  B --> C[Signal normalization]
  C --> D[Test scheduler]
  C --> E[Failure digest]
  C --> F[Retained report set]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +39, Other 0. Total +39 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 40 1 +39
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 6 6 0
Total 3 46 7 +39

Review metrics

Metric Value Why it matters
Production versus test delta tooling +6/-6; tests/support +40/-1 The repair is net-neutral in production tooling and adds focused real-process coverage for crash reporting.

Technical review

Best possible solution:

Land the boundary-level normalization and its real-process regression matrix, while tracking the pre-existing plugin-batch report-code mismatch separately under its own owner and coverage.

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

Yes—source establishes the incorrect 143 fallback on current main, and the PR supplies a real-child crash matrix that exercises the affected project-runner paths.

Is this the best way to solve the issue?

Yes—the canonical signal helper is applied at the single completion boundary before scheduling, reporting, and trailer consumers diverge.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This repairs developer-facing test failure reporting without changing application runtime behavior.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit 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, maintainer-labeled PR is exempt from the external-contributor proof gate; its supplied terminal evidence nevertheless matches the changed project-runner boundary and records after-fix SIGABRT/SIGKILL failure outcomes.

Label justifications:

  • P2: This repairs developer-facing test failure reporting without changing application runtime behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit 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, maintainer-labeled PR is exempt from the external-contributor proof gate; its supplied terminal evidence nevertheless matches the changed project-runner boundary and records after-fix SIGABRT/SIGKILL failure outcomes.

Evidence

What I checked:

  • Introduced repair: The PR replaces the two hard-coded 143 fallbacks with one effective signal and the repository’s canonical signalExitCode mapping. (scripts/test-projects.mts:120, 95bf5027ea57)
  • Current-main behavior: Fetched main still contains the old forwarded-signal and child-signal fallbacks that record 143, so this PR is neither obsolete nor implemented on main. (scripts/test-projects.mts:120, a0868f477a8e)
  • Owner-boundary flow: The watched-process owner returns the child signal and forwarded signal; the project runner records the normalized outcome, stops scheduling, and emits the matching failure trailer. The report owner persists the outcome and rejects signaled attempts from aggregate publication. (scripts/run-vitest.mts:1286, 95bf5027ea57)
  • Regression coverage: The new POSIX-only real-process matrix covers serial and parallel project execution, direct and wrapper entrypoints, report/no-report paths, SIGABRT, and SIGKILL; report cases require the exact stored code, incomplete index, and no published aggregate. (test/scripts/vitest-report-owner.test.ts:27, 95bf5027ea57)
  • Signal-code contract: The established helper derives conventional exit codes from OS signal numbers, and its existing tests assert SIGKILL maps to 137. (scripts/lib/managed-child-process.mts:78, 95bf5027ea57)
  • History and current relevance: The PR commit has raw parent 9aa82b1 and changes the completion boundary plus fixture and regression tests; the base/current-main path retains the historical 143 behavior. (scripts/test-projects.mts:120, 95bf5027ea57)

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.

@steipete
steipete merged commit f4b4932 into main Sep 1, 2026
235 checks passed
@steipete
steipete deleted the codex/fix-vitest-crash-exit branch September 1, 2026 03:50
@steipete

steipete commented Sep 1, 2026

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