Skip to content

Distinguish a process abort from a genuine test failure in the pre-push gate - #2475

Merged
mstomar125 merged 2 commits into
mainfrom
issue-2431-distinguish-test-abort-from-failure
Sep 8, 2026
Merged

mstomar125 merged 2 commits into
mainfrom
issue-2431-distinguish-test-abort-from-failure

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Summary

Scoped narrowly, per the issue's own framing risk: this distinguishes a process abort (e.g. the intermittent SIGSEGV seen in nodespace-core's lib tests under parallel-test resource contention) from a genuine test/assertion failure in scripts/test-gate.ts's (ADR-047) reporting. It does not root-cause the underlying SIGSEGV — that needs real Rust/FFI investigation (suspects: libsql/SQLite FFI under concurrency, or a post-merge cold-build/test-load overlap) and is out of scope for a reporting change.

Today, a load-induced abort and a real regression print identically — ✗ <step> failed — push blocked. — which costs a multi-minute rerun just to find out which one happened, and nudges people toward git push --no-verify when they assume (often correctly, sometimes not) that it was "just the flaky SIGSEGV thing."

What changed

  • scripts/classify-test-failure.ts (new): classifyFailure(output) scans captured text for known abort signatures (SIGSEGV/SIGABRT/SIGBUS/SIGILL/SIGKILL, signal: N, "segmentation fault", "core dumped", Windows' STATUS_ACCESS_VIOLATION) and returns "abort" | "failure" — defaulting to "failure" (silence is the safe default). extractFailureOutput(err) pulls the text worth scanning out of a thrown error, mirroring check-branch-behind.ts's errorMessage() pattern: Bun's ShellError exposes .stdout/.stderr as Buffers (populated alongside the live terminal stream), which is where cargo's abort message actually shows up — .message alone is a generic "Failed with exit code N". formatAbortNote(label) renders the note.
  • scripts/test-gate.ts: run()'s catch block now classifies the captured output and, on "abort", prints the note before the existing "push blocked" message. The outcome is unchanged — an abort still blocks the push, exactly like any other failure; retrying is still on the person, not automated.

What this does NOT do (explicitly out of scope)

  • Does not fix, mitigate, or reduce the frequency of the underlying SIGSEGV.
  • Does not add retry logic, quarantining, or any mechanism that lets a push through despite an abort.
  • Does not touch packages/agent or packages/nlp-engine.

Test plan

  • scripts/classify-test-failure.test.ts — 12 new tests: real cargo SIGSEGV output, a genuine assertion failure, empty output, bare SIGABRT, case-insensitive segmentation fault, prose that merely mentions "signal" without a number (negative case), stdout/stderr Buffer joining, .message fallback, non-object/non-Buffer guards, and the note's content/shape. Each mutation-tested individually (temporarily broke the corresponding logic, confirmed the specific test failed, restored, confirmed all pass). One test's own fixture string was found to be a mutation-testing escape during that pass — a segmentation-fault case that also contained "core dumped" let a broken case-insensitivity check pass, since the separate core-dumped pattern still matched — fixed by isolating the fixture to the pattern under test, then re-verified the mutation now correctly fails it.
  • bun run test:scripts — 361 tests pass (full scripts/ suite, no new failures).
  • bun run test:all — clean, no new failures.
  • bun run quality:fix — clean.
  • Pushed content verified byte-identical (md5) against the local worktree for all 3 changed files.

Acceptance criteria status (from the issue)

  • Root cause of the intermittent SIGSEGV identified — not attempted, needs real Rust/FFI investigation
  • SIGSEGV eliminated or mitigated at the source — not attempted
  • Gate reporting distinguishes an abort from a genuine failure, so people stop burning reruns to tell them apart
  • (any other root-cause-adjacent AC from the issue) — deferred, same reason as above

Leaving the issue open after this merges — the reporting half is done, but the actual SIGSEGV is still there and still needs someone with Rust/FFI context to chase it.

🤖 Generated with Claude Code

…sh gate

A load-induced abort (SIGSEGV under parallel-test resource contention,
observed intermittently in nodespace-core's lib tests) and a real
assertion failure currently look identical in scripts/test-gate.ts's
output: "script exited with code 101, push blocked." Telling them
apart today means re-running a multi-minute suite, which also trains
people toward `git push --no-verify`.

Adds scripts/classify-test-failure.ts: scans captured stdout/stderr
for known abort signatures (SIGSEGV/SIGABRT/SIGBUS/SIGILL/SIGKILL,
"signal: N", segmentation fault, core dumped, the Windows
STATUS_ACCESS_VIOLATION equivalent) and, when found, prints a note
before the existing failure message in test-gate.ts's run() catch
block. Does not change the outcome — an abort still blocks the push,
same as any other failure — only what the person sees.

This does not root-cause the underlying SIGSEGV itself (suspected
libsql/SQLite FFI under concurrency, or cold-build/test-load overlap
after a merge) — that needs real Rust/FFI investigation and stays
out of scope here.

12 new tests, each mutation-tested individually (temporarily broke
the corresponding logic, confirmed the test failed, restored,
confirmed it passed). One caught a real mutation-testing escape in
its own first draft: a segmentation-fault fixture that also
contained "core dumped" let a broken case-insensitivity check pass,
since the separate core-dumped pattern still matched; fixed by
using a fixture string that isolates only the pattern under test.

Co-Authored-By: Claude <[email protected]>
Adversarial review of the classifier found two of the ten
ABORT_PATTERNS regexes — "process didn't exit successfully...
(signal" and STATUS_ACCESS_VIOLATION — were only ever exercised
alongside another already-matching pattern (SIGSEGV / signal:\s*\d+),
so a typo in either specific regex wouldn't be caught by the existing
suite. Adds one isolated fixture per pattern, each avoiding every
other ABORT_PATTERNS trigger, and mutation-tested individually
(broke each pattern in turn, confirmed only its own test failed,
restored, confirmed all 14 pass).

Co-Authored-By: Claude <[email protected]>
@mstomar125

Copy link
Copy Markdown
Contributor Author

Addressed the two testable nits from review in 2a43ebc: added isolated fixtures for the two ABORT_PATTERNS entries that were previously only ever exercised alongside an already-matching pattern ("process didn't exit successfully...(signal" and STATUS_ACCESS_VIOLATION), each mutation-tested individually. 14/14 tests pass, test:all clean.

Left as-is (per the review's own framing — cosmetic, non-blocking):

  • formatAbortNote's generic wording across all 5 gate steps — the pattern was only empirically diagnosed for the Rust lib-test step, but the note doesn't name a specific step as the culprit, and softening it further risks being less useful to the person reading it.
  • readBufferField's missing .trim() vs. check-branch-behind.ts's version — doesn't affect regex matching, no behavior difference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant