mutant-cafe 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -4
- package/dist/bin.js +822 -498
- package/dist/bin.js.map +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ Other mutants, all chosen from the checker's view of the return type:
|
|
|
22
22
|
|
|
23
23
|
## Use it
|
|
24
24
|
|
|
25
|
-
Needs Node 24 or later, a `tsconfig.json`, and a
|
|
25
|
+
Needs Node 24 or later, a `tsconfig.json`, and a passing suite on Vitest 5 or newer. Older Vitest versions stop during preflight with exit 8 and the installed version.
|
|
26
26
|
|
|
27
27
|
```sh
|
|
28
28
|
npm install -D mutant-cafe
|
|
@@ -134,6 +134,7 @@ An include glob that matches no source file is a usage error, including a path o
|
|
|
134
134
|
| 5 | the `--in-diff` diff does not match the tree |
|
|
135
135
|
| 6 | the diff cannot be parsed |
|
|
136
136
|
| 7 | some results are unreliable, with none missed |
|
|
137
|
+
| 8 | installed Vitest is older than 5.0 |
|
|
137
138
|
| 70 | internal error |
|
|
138
139
|
|
|
139
140
|
Precedence is **missed (2), unreliable (7), untested (2), then timeout (3)**. A real miss wins over unreliable results; unreliable wins over an empty selection or timeout.
|
|
@@ -165,7 +166,9 @@ Selection and partial failures come from Vitest's reporter hooks, not its human-
|
|
|
165
166
|
|
|
166
167
|
### Warm and cold runs
|
|
167
168
|
|
|
168
|
-
The baseline has a 30-minute overall hang guard, including selection and process startup. Set `--baseline-timeout 2400` (seconds), or `baselineTimeoutMs` in `mutants.config.json`, for a longer suite. Expiry reports `BaselineTimedOut`, names the limit and flag, and exits 3 rather than calling the original tests failed. Each paired calibration run uses that same baseline budget independently, across all scratch copies. Each cold execution also includes startup in its existing per-run budget. Cold runs launch the installed project's Vitest bin through
|
|
169
|
+
The baseline has a 30-minute overall hang guard, including selection and process startup. Set `--baseline-timeout 2400` (seconds), or `baselineTimeoutMs` in `mutants.config.json`, for a longer suite. Expiry reports `BaselineTimedOut`, names the limit and flag, and exits 3 rather than calling the original tests failed. Each paired calibration run uses that same baseline budget independently, across all scratch copies. Each cold execution also includes startup in its existing per-run budget. Cold runs launch the installed project's Vitest bin through the current runtime, without an npm wrapper or shell lookup; the printed command names the actual generated launcher. Cleanup runs after deadline expiry before the next execution.
|
|
170
|
+
|
|
171
|
+
Cold, warm and preflight launches inherit only supported resolution flags from the parent runtime arguments: `--conditions` (`-C`), `--import`, `--require` (`-r`), Bun's `--preload`, and Node's `--experimental-loader` (`--loader`) and `--experimental-import-meta-resolve`. Relative preload and loader paths resolve from the original working directory. Debugger, entry, test and watch modes are dropped with a warning; other runtime arguments are not replayed. The installed runner is still Vitest when launched through Bun, not `bun test`.
|
|
169
172
|
|
|
170
173
|
Set `MUTANT_CAFE_PROCESS_TRACE=/absolute/path/trace.jsonl` to opt into timestamped startup and cleanup stages: parent spawn, preload, birth inspection, child spawn, Vitest resolution/start, test-module start and cwd inspection. Traces append process IDs, times and stage details, not arguments, environment contents or test output. No trace file is written by default.
|
|
171
174
|
|
|
@@ -173,11 +176,11 @@ By default, mutant.cafe first verifies a clean cold baseline and stops if it fai
|
|
|
173
176
|
|
|
174
177
|
A warm scratch copy keeps one instance of the project's installed Vitest. Mutations and restores invalidate the changed module and its importers before the next run. Vitest's normal per-file isolation resets module-level state. Both modes use the project's configured worker count, or Vitest's default. `--jobs N` uses N scratch copies.
|
|
175
178
|
|
|
176
|
-
Use `--cold` to start a fresh Vitest process for each mutant that needs tests, or `--warm` to force a persistent instance. The flags are mutually exclusive. Warm execution supports isolated built-in `forks` and `threads` pools on Vitest major 5, verified against 5.1.0. Other majors, VM pools, browser mode, custom pools, `globalSetup`, `isolate: false`, `poolOptions.*.isolate: false` and `--no-isolate` use cold execution. Auto
|
|
179
|
+
Use `--cold` to start a fresh Vitest process for each mutant that needs tests, or `--warm` to force a persistent instance. The flags are mutually exclusive. Warm execution supports isolated built-in `forks` and `threads` pools on Vitest major 5, verified against 5.1.0. Other majors, VM pools, browser mode, custom pools, `globalSetup`, `isolate: false`, `poolOptions.*.isolate: false` and `--no-isolate` use cold execution. Auto prints one `Vitest auto mode: <cold|warm>; <reason>` line, including cold fallbacks. The mode and reason match the baseline in `outcomes.json`; `--warm` warns once with the reason. `baseline.runnerModeReason` records the reason in either mode. Selection-only hosts can inspect refused configurations but cannot execute tests; quiet logging never relaxes execution checks. The adapter also checks the private fields and transform/invalidation interfaces it uses. Falling back for `globalSetup` ensures each mutant initializes from its own source, just as cold execution does.
|
|
177
180
|
|
|
178
181
|
After every warm execution, mutant.cafe closes the disposable worker pool and reaps test-created descendants before the next mutant. The Vitest/Vite host and its startup services remain alive. Test and hook timeouts, parallel bail and ordinary unhandled errors do not restart a healthy host. An unhandled error is a caught failure unless the project ignores it. Real worker death gets one pool retry; a second death switches the remaining run to cold mode. Only an unhealthy host is replaced. Reports and summaries include host restarts and unexpected pool resets from crashes, outer-deadline recovery or cancellation. Routine pool disposal is not counted. A host health check performs a trivial Vite transform as well as an IPC round trip. Worker-budget telemetry comes from Vitest's resolved config and is omitted when unavailable. Invalid telemetry never changes a verdict or triggers a pool retry: outcomes are written first, then the reporter warns with the bad field and value.
|
|
179
182
|
|
|
180
|
-
Each Vitest instance has an ownership ledger. Child spawns inherit a unique label. Cleanup checks recorded PID identities, parent chains and escaped process groups with POSIX `ps`, then stops, kills and verifies the owned tree. Cleanup runs before reuse and on exit. Inspection or ownership failures warn with tracked PIDs, keep the ledger and let the run continue; an unhealthy host is not reused. Each ownership sweep shares a 10-second deadline across discovery, signalling and retries. Inspector calls allow two seconds, discovery seven seconds and signalling three seconds, all clamped to that shared deadline. These are hang guards, not clean-run speed targets. PPID descendants in the snapshot are claimed before fallible label inspection, so degraded cleanup claims unlabelled children before signalling their known parents. Inspector subprocesses receive cancellation signals; a stalled inspection cannot turn interruption into minutes of serial retries. If inspection fails or the budget expires, cleanup still attempts SIGKILL for PIDs already birth-matched in that sweep, then warns about unconfirmed exits and unverified ledger PIDs. A stale ledger entry alone never authorizes a signal. Zombies do not count as live survivors, and unverifiable PIDs are never signalled. Explicit child environments are left unchanged. The preload is appended only for implicit children using the current Node executable. Inspector environment output is never logged or included in reports. A minimal-env grandchild that daemonizes after its parent exits can escape cleanup. After each run, a scratch-path scan warns with the PIDs of unowned survivors; it never kills a process on a path match alone. The warning scan recognizes birth-validated PIDs from every live mutant.cafe ledger, including selector hosts. It reuses the latest PID/birth/argv snapshot and checks cwd only for unknown processes born since the scratch session opened. Darwin restricts `lsof` to those candidate PIDs, drops exited or inaccessible PIDs and preserves partial output when another candidate exits during inspection. This warning-only filter never changes ownership or kill permissions. Each executed result records `backstopMs`, the total scratch-path scan time during that mutant. Summaries show its per-mutant p50/p90; baseline and selector-only scans are not samples. A source entry that vanishes during
|
|
183
|
+
Each Vitest instance has an ownership ledger. Child spawns inherit a unique label. Cleanup checks recorded PID identities, parent chains and escaped process groups with POSIX `ps`, then stops, kills and verifies the owned tree. Cleanup runs before reuse and on exit. Inspection or ownership failures warn with tracked PIDs, keep the ledger and let the run continue; an unhealthy host is not reused. Each ownership sweep shares a 10-second deadline across discovery, signalling and retries. Inspector calls allow two seconds, discovery seven seconds and signalling three seconds, all clamped to that shared deadline. These are hang guards, not clean-run speed targets. PPID descendants in the snapshot are claimed before fallible label inspection, so degraded cleanup claims unlabelled children before signalling their known parents. Inspector subprocesses receive cancellation signals; a stalled inspection cannot turn interruption into minutes of serial retries. If inspection fails or the budget expires, cleanup still attempts SIGKILL for PIDs already birth-matched in that sweep, then warns about unconfirmed exits and unverified ledger PIDs. A stale ledger entry alone never authorizes a signal. Zombies do not count as live survivors, and unverifiable PIDs are never signalled. Explicit child environments are left unchanged. The preload is appended only for implicit children using the current Node executable. Inspector environment output is never logged or included in reports. A minimal-env grandchild that daemonizes after its parent exits can escape cleanup. After each run, a scratch-path scan warns with the PIDs of unowned survivors; it never kills a process on a path match alone. The warning scan recognizes birth-validated PIDs from every live mutant.cafe ledger, including selector hosts. It reuses the latest PID/birth/argv snapshot and checks cwd only for unknown processes born since the scratch session opened. Darwin restricts `lsof` to those candidate PIDs, drops exited or inaccessible PIDs and preserves partial output when another candidate exits during inspection. This warning-only filter never changes ownership or kill permissions. Each executed result records `backstopMs`, the total scratch-path scan time during that mutant. Summaries show its per-mutant p50/p90; baseline and selector-only scans are not samples. In a Git repository, scratch copies tracked and untracked files, including ignored build output, generated code and environment files. It links independent ignored checkouts and dependency trees with their own `.git` or `node_modules` back to their original paths without traversing them; relative imports and shared configs remain available, but functions inside those links are reported as not mutated, with a reason, before `--max-mutants` is applied. They do not appear in `mutants.json` or consume the mutation budget. An all-linked selection skips scratch creation and the baseline. Direct mutant edits through those links are refused. Unreadable ignored paths are skipped with a warning naming the denied path; readable siblings remain in scratch. Trees named by package `exports`, `imports`, `main`, `module` and `types` are copied even when ignored or holding their own `node_modules`. If Git discovery fails, scratch warns and uses the recursive copy instead. Outside Git, scratch keeps the recursive copy behavior. A source entry that vanishes during copying is skipped with a debug note. Dangling symlinks are skipped with a warning; permission errors on tracked inputs or scratch destinations, and missing destinations, still fail the copy. Scratch removal allows 30 seconds for large workspaces and sends failures to stderr, never into GitHub Markdown output.
|
|
181
184
|
|
|
182
185
|
Ordinary mutants use the configured timeout. For `Effect.never`, the reporter measures each passing test in the clean baseline. The budget uses the slowest test among the related files, including any full-suite fallback. A related-file probe selects those files. Comparing each task's original and probe timeouts distinguishes explicit options from inherited defaults; the probe's imposed timeout is not an original limit. The test and hook timeout is that duration × the timeout multiplier, with a 2 s floor, rather than the duration of the whole suite. Explicit per-test timeout options remain in effect, including larger values. Vitest does not expose a configuration API to raise a smaller explicit per-test timeout; those tests still use their own value. Reports record the computed timeout on each mutant result. The report also records the baseline test duration used as the budget base and the separate outer deadline. An inherited config timeout does not raise the outer deadline. That deadline allows the original startup time and the selected baseline files' collection, environment, hook and test durations, not the duration of the whole package. Cold and warm modes use the same per-test budget policy, so switching modes alone does not shorten a hanging test's timeout. A process killed before test collection is not credited as caught. Other mutants keep the existing per-test timeout of half their run budget. Both modes stop after the first reported failure.
|
|
183
186
|
|