✅ test(dvara): watchdog.ts's createWatchdog, execAsync and pruneOldHangs keep only equivalent mutants
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
createWatchdogruns through its injectedexecandclock, against strict fakes.- No test sends a real signal: the default
killis checked by spying onprocess.kill. execAsyncruns stand-inps,lsofandsamplescripts put first onPATH. PATH andLC_ALLare restored infinally.- 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
| Line | Mutant | Why no test can tell it apart |
|---|---|---|
| 722 | force: true → false | The path was just stat'ed, so it exists. |
| 848 | classes === null → false | decide never returns internal-deadlock when classes is null. |
| 1108 | row.pid === rootPid → true | buildTree puts the root first. |
| 1109 | originalRoot !== undefined → true | tick bails out on an empty tree. |
| 1211 | verdictAt !== null → true | verdictAt and summary.verdict are always set and cleared together. |
Checks
pnpm --filter ./packages/dvara test: 737 pass.watchdog.tscoverage is 99.51% lines, 96.46% branches, 100% functions.pnpm lintand 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,
decidenever reaching its deadlock branch whenclassesis null, the root always appearing first in the tree, the tree never being empty when verdicts are checked, andverdictAtbeing set and cleared together withsummary.verdict.