✅ test(dvara): watchdog.ts's createWatchdog, execAsync and pruneOldHangs keep only equivalent mutants

Merged
AT
2d ago
+1029-1

This PR adds a 32-test "createWatchdog, step by step" suite to watchdog.test.ts. It kills the survivors in createWatchdog, execAsync and pruneOldHangs (slice #627). It is test-only, so the gate judges nothing on it, and Cubic skips test files.

The tests

  • createWatchdog runs through its injected exec and clock, against strict fakes.
  • No test sends a real signal: the default kill is checked by spying on process.kill.
  • execAsync runs stand-in ps, lsof and sample scripts put first on PATH. PATH and LC_ALL are restored in finally.
  • Three tests use deliberately odd input, because each is the only way to separate one mutant:
    • a monotonic clock that steps back (line 1054),
    • negative clock readings (line 1143),
    • a stage file that appears empty (line 816).

Gate result (pnpm exec agnipariksha --lane dvara --files packages/dvara/src/watchdog.ts --no-reuse, run on #628's tests plus these):

  • Before: 156 blocking (121 Survived, 35 NoCoverage), 136 of them from line 706 down.
  • After: 1003 of 1028 killed, 25 blocking (20 Survived, 5 NoCoverage).
    • 20 are #628's equivalents, above line 706.
    • 5 are new equivalents in the effectful part, listed below.
  • #625 rewrites the source so that none of the 25 can be generated, without changing behaviour. That PR must reach zero.

The 5 from line 706 down

LineMutantWhy no test can tell it apart
722force: true → falseThe path was just stat'ed, so it exists.
848classes === null → falsedecide never returns internal-deadlock when classes is null.
1108row.pid === rootPid → truebuildTree puts the root first.
1109originalRoot !== undefined → truetick bails out on an empty tree.
1211verdictAt !== null → trueverdictAt and summary.verdict are always set and cleared together.

Checks

  • pnpm --filter ./packages/dvara test: 737 pass. watchdog.ts coverage is 99.51% lines, 96.46% branches, 100% functions.
  • pnpm lint and typecheck are clean.
  • The test file runs in about 1.8 s. The 4 Timeouts are unchanged: lines 244 (×2), 500 and 501, each stopped by Stryker's hit limit.

Alok approved the slice with 👍 on https://github.com/veda-hq/veda/issues/627#issuecomment-7193610153.

Slice: #627

🤖 Generated with Claude Code


Summary by cubic

Adds a 32-test "step by step" suite to watchdog.test.ts that drives createWatchdog, execAsync, and pruneOldHangs through a strict exec, asserting whole values: command order, signals, log lines, summary, and diagnostics files. Test-only; surviving mutants in these functions drop from 156 to 25 blocking.

No test sends a real signal — the default kill is checked by spying on process.kill, and execAsync runs stand-in ps, lsof, and sample scripts placed first on PATH.

Leftover equivalents

  • 20 of the 25 blocking mutants belong to #628, above line 706.
  • The 5 below line 706 are only distinguishable by behavior callers rely on: a just-stat'ed stage path, decide never reaching its deadlock branch when classes is null, the root always appearing first in the tree, the tree never being empty when verdicts are checked, and verdictAt being set and cleared together with summary.verdict.