✅ test(sys): the mutation gate judges src/sys.ts, and every mutant dies

Merged
AT
11h ago
+578-90

Slice: #635

The mutation gate can now judge src/sys.ts, and every one of its mutants dies. The inventory on #580 could not judge the file at all.

Why the gate could not judge it

  • sys.test.ts's Ctrl-C test called process.emit('SIGINT'), which reaches every SIGINT listener in the process.
  • Stryker's tap-runner hook exits on SIGINT, and with 128 + undefined, so NaN. The dry run failed on both tries.
  • The test now calls only the listener onInterrupt added (963218f).

Measured once the dry run passed: 349 mutants, of which 158 blocked: 72 Survived and 86 NoCoverage.

How they die

  • One seam. realSys(machine = {}) takes the machine calls it makes, with the real ones as defaults:

    • spawn and spawnSync;
    • the fs calls behind write, replace and detach;
    • isatty and the prompts loader;
    • the proxy setup;
    • the terminal's streams, which stay unopened until a prompt needs them.

    Callers are unchanged. Tests now drive the terminal, spinner, prompts and process paths in-process. They were NoCoverage because per-test coverage cannot credit code that runs only in a child process.

  • Rewrites where the code hid a mutant.

    • write opens the file and fchmods the fd: a file already there keeps its own mode when opened. Overwriting a 0644 file with 0600 is now tested.
    • modified and present return from outside their catch.
    • realPath() of nothing is '': realpathSync('') gives the working folder.
    • nearestPresent and the cause walk recurse instead of looping, so a broken stop fails at once.
    • serve awaits 'listening', using one loopback constant for both the listen and the request URL.
    • The abort wait drops a { once: true } that changed nothing.
  • Direct tests of the exported helpers:

    • useProxy, isTimeout, exitCode, realPath, nearestPresent, readHidden, loadPrompts;
    • every branch of notMade's reason.
  • Waits have a deadline. Every wait in the suite has one, and the lane passes --test-force-exit (stryker/lane.mjs). A mutant that breaks a wait, or leaves a server open, now fails at once instead of timing out. Before this, the retries of those timeouts outgrew agnipariksha's 15-minute budget, and the run was refused even with nothing blocking.

Evidence

agnipariksha --lane src --files src/sys.ts --no-reuse
src: 365 killed of 365 in 1 file(s) (364 Killed, 1 Timeout; 1 timeout(s) retried) - pass
agnipariksha total: 365 killed of 365 in 1 lane(s), 0 blocking, 0 refused - exit 0
exit 0 after 311 s
  • pnpm check passes locally.
  • 365 mutants is not the 349 measured before the change: the seam adds code, and the rewrites remove some mutants.

🤖 Generated with Claude Code


Summary by cubic

Makes the mutation gate judge src/sys.ts, killing all 366 of its mutants; before, the gate could not judge the file at all.

A Ctrl-C test emitted SIGINT process-wide, which exits Stryker's tap-runner hook and failed the dry run. The test now calls only the listener onInterrupt added.

  • realSys() takes the machine calls it makes, with the real ones as defaults, so tests drive the terminal, spinner, prompts and process paths in-process.
  • Rewrites fixed hidden mutants: write sets the mode on the fd only after the data is written, realPath('') is '', and recursive walks fail at once on a broken stop.
  • serve keeps its error listener after it starts, so a later error no longer ends the process.
  • Waits have deadlines and the lane passes --test-force-exit, so broken waits and unclosed servers fail fast instead of timing out.