peaks-loop-mut 0.1.81 → 0.1.82

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.
@@ -41,6 +41,9 @@ export interface StrykerInvokerInput {
41
41
  readonly tsconfigFile?: string;
42
42
  readonly timeoutMs?: number;
43
43
  readonly concurrency?: number;
44
+ /** Session id — scopes the generated per-run vitest config. Optional at this
45
+ * layer: an invoker that receives no test files has nothing to scope. */
46
+ readonly sessionId?: string;
44
47
  }
45
48
  export type StrykerInvoker = (opts: StrykerInvokerInput) => Promise<StrykerRawResult>;
46
49
  export interface RunMutationInput {
@@ -51,6 +54,10 @@ export interface RunMutationInput {
51
54
  readonly tsconfigFile?: string;
52
55
  readonly timeoutMs?: number;
53
56
  readonly concurrency?: number;
57
+ /** Session id — scopes the generated per-run vitest config. Optional here so a
58
+ * caller that fails earlier (a missing test file, say) still gets THAT named
59
+ * error; the options builder refuses a test-file run without one. */
60
+ readonly sessionId?: string;
54
61
  readonly invokeStryker: StrykerInvoker;
55
62
  }
56
63
  export interface RunMutationOutput {
@@ -1 +1 @@
1
- {"version":3,"file":"mut-runner.d.ts","sourceRoot":"","sources":["../../../src/services/mut/mut-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;QAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;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EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B;8EAC0E;IAC1E,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,mBAAmB,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAEtF,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC1C,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACxC,QAAQ,CAAC,cAAc,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAChD,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B;;0EAEsE;IACtE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,aAAa,EAAE,cAAc,CAAC;CACxC;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;CACnC;AAED,wBAAsB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAgCrF"}
@@ -8,7 +8,8 @@ export async function runMutation(input) {
8
8
  ignorePatterns: input.ignorePatterns,
9
9
  tsconfigFile: input.tsconfigFile,
10
10
  timeoutMs: input.timeoutMs,
11
- concurrency: input.concurrency
11
+ concurrency: input.concurrency,
12
+ sessionId: input.sessionId
12
13
  });
13
14
  }
14
15
  catch (err) {
@@ -1 +1 @@
1
- {"version":3,"file":"production-stryker.d.ts","sourceRoot":"","sources":["../../../src/services/mut/production-stryker.ts"],"names":[],"mappings":"AAuCA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAUzE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,CAAC;AAY9C,wBAAgB,8BAA8B,IAAI,cAAc,CAkD/D"}
1
+ {"version":3,"file":"production-stryker.d.ts","sourceRoot":"","sources":["../../../src/services/mut/production-stryker.ts"],"names":[],"mappings":"AAuCA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAUzE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,CAAC;AAY9C,wBAAgB,8BAA8B,IAAI,cAAc,CAqD/D"}
@@ -78,6 +78,9 @@ export function createProductionStrykerInvoker() {
78
78
  ignorePatterns: input.ignorePatterns,
79
79
  pluginDescriptors,
80
80
  tsconfigFile: input.tsconfigFile,
81
+ // Scopes the per-run vitest config whose `include` IS `--test-files`.
82
+ // Without it the project's own config filters the list to zero tests.
83
+ ...(input.sessionId !== undefined ? { sessionId: input.sessionId } : {}),
81
84
  // The console log stays 'off' (stdout belongs to --json), so this is
82
85
  // the ONLY channel that records WHY Stryker failed. `runInProject`
83
86
  // removes the file again unless the project already had one.
@@ -46,9 +46,24 @@ export declare const STRYKER_DEFAULTS: {
46
46
  /** The caller's sandbox-ignore list is opt-in, so the default is empty. */
47
47
  readonly ignorePatterns: ReadonlyArray<string>;
48
48
  /**
49
- * ALWAYS ignored, whatever the caller asked for: Stryker copies the
50
- * project into `.stryker-tmp/sandbox-*`, so a sandbox directory that is
51
- * itself copied is a copy of the sandbox into itself.
49
+ * ALWAYS ignored, whatever the caller asked for.
50
+ *
51
+ * `.stryker-tmp`: Stryker copies the project into `.stryker-tmp/sandbox-*`, so
52
+ * a sandbox directory that is itself copied is a copy of the sandbox into
53
+ * itself.
54
+ *
55
+ * `.peaks`: the runtime artifact tree. Two measured reasons (2026-11-17):
56
+ * - it holds past sessions whose scratch fixtures contain Windows junctions
57
+ * and symlinks, and Stryker's copier dies on them with `EPERM: operation
58
+ * not permitted, copyfile` — the run never started, on a tree that has
59
+ * nothing to do with the code under mutation;
60
+ * - it is large and grows with every session, so copying it per mutant is
61
+ * pure cost. A mutation run needs the source, the tests and the toolchain,
62
+ * never the session archive.
63
+ *
64
+ * No mutation target or test lives under `.peaks/**`: that tree is gitignored
65
+ * runtime state, and `git ls-files` — which every gate scope is built from —
66
+ * never lists it.
52
67
  */
53
68
  readonly alwaysIgnoredPatterns: ReadonlyArray<string>;
54
69
  /**
@@ -66,6 +81,24 @@ export interface StrykerOptionsInput {
66
81
  readonly mutate?: ReadonlyArray<string>;
67
82
  /** Test files to run. Empty means "let the runner discover them". */
68
83
  readonly testFiles?: ReadonlyArray<string>;
84
+ /**
85
+ * Session id, used to place the per-run generated vitest config under
86
+ * `.peaks/_runtime/<sessionId>/mut/`. When given, that config's `include` is
87
+ * what makes `--test-files` select anything (see `stryker-run-config.ts`).
88
+ *
89
+ * OPTIONAL here: this builder produces OPTIONS and does not own the run's
90
+ * preconditions. `peaks mut run` makes `--session-id` a required option, so
91
+ * the CLI cannot reach Stryker unscoped; a programmatic caller that omits it
92
+ * gets the project's own `include` and the loud "No tests were executed"
93
+ * abort instead of an error from a pure builder.
94
+ */
95
+ readonly sessionId?: string;
96
+ /**
97
+ * Setup files the generated per-run config should carry. A suite that depends
98
+ * on global setup fails without it, and a setup failure reports mutants as
99
+ * killed when nothing actually ran.
100
+ */
101
+ readonly setupFiles?: ReadonlyArray<string>;
69
102
  /**
70
103
  * Patterns NOT to copy into the Stryker sandbox. Empty by default.
71
104
  * Passed through verbatim (Stryker's own glob semantics) and always
@@ -1 +1 @@
1
- {"version":3,"file":"stryker-options.d.ts","sourceRoot":"","sources":["../../../src/services/mut/stryker-options.ts"],"names":[],"mappings":"AAsEA,OAAO,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;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,mBAAmB,GAAG,iBAAiB,CAEnF"}
@@ -67,7 +67,8 @@
67
67
  * rootInjector, process.stdout)`) and the built-in reporters write
68
68
  * there too. Measured: stdout length 0 for a real run.
69
69
  */
70
- import { isAbsolute, resolve } from 'node:path';
70
+ import { resolve } from 'node:path';
71
+ import { resolveTestFiles, scopedVitestOptions } from './stryker-run-config.js';
71
72
  /** Every default the builder applies lives here — nowhere else. */
72
73
  export const STRYKER_DEFAULTS = {
73
74
  testRunner: 'vitest',
@@ -81,11 +82,26 @@ export const STRYKER_DEFAULTS = {
81
82
  /** The caller's sandbox-ignore list is opt-in, so the default is empty. */
82
83
  ignorePatterns: [],
83
84
  /**
84
- * ALWAYS ignored, whatever the caller asked for: Stryker copies the
85
- * project into `.stryker-tmp/sandbox-*`, so a sandbox directory that is
86
- * itself copied is a copy of the sandbox into itself.
85
+ * ALWAYS ignored, whatever the caller asked for.
86
+ *
87
+ * `.stryker-tmp`: Stryker copies the project into `.stryker-tmp/sandbox-*`, so
88
+ * a sandbox directory that is itself copied is a copy of the sandbox into
89
+ * itself.
90
+ *
91
+ * `.peaks`: the runtime artifact tree. Two measured reasons (2026-11-17):
92
+ * - it holds past sessions whose scratch fixtures contain Windows junctions
93
+ * and symlinks, and Stryker's copier dies on them with `EPERM: operation
94
+ * not permitted, copyfile` — the run never started, on a tree that has
95
+ * nothing to do with the code under mutation;
96
+ * - it is large and grows with every session, so copying it per mutant is
97
+ * pure cost. A mutation run needs the source, the tests and the toolchain,
98
+ * never the session archive.
99
+ *
100
+ * No mutation target or test lives under `.peaks/**`: that tree is gitignored
101
+ * runtime state, and `git ls-files` — which every gate scope is built from —
102
+ * never lists it.
87
103
  */
88
- alwaysIgnoredPatterns: ['.stryker-tmp'],
104
+ alwaysIgnoredPatterns: ['.stryker-tmp', '.peaks'],
89
105
  /**
90
106
  * The file-log level the PRODUCTION invoker turns on while a run is in
91
107
  * flight (`production-stryker.ts` reads it). The console level stays
@@ -116,16 +132,25 @@ export function buildStrykerOptions(input) {
116
132
  const testFiles = resolveTestFiles(project, input.testFiles);
117
133
  if (testFiles.length > 0) {
118
134
  options.testFiles = testFiles;
119
- // An explicit test list is authoritative — do not let vitest's
120
- // related-mode narrowing discard it. See the module header.
121
- options.vitest = { related: false };
135
+ options.vitest = scopedVitestOptions({
136
+ project,
137
+ testFiles,
138
+ sessionId: input.sessionId,
139
+ ...(input.setupFiles !== undefined ? { setupFiles: input.setupFiles } : {})
140
+ });
122
141
  }
123
142
  // Verbatim, like `mutate`: these are Stryker globs, not file paths.
124
143
  // `.stryker-tmp` is appended unconditionally (see STRYKER_DEFAULTS).
144
+ // Deduplicated: the always-ignored list is the caller's to repeat (a caller
145
+ // that already passes `.peaks` should not get it twice), and a duplicated
146
+ // glob is not harmless — it makes the resolved options harder to read and
147
+ // would double any future per-pattern warning.
125
148
  options.ignorePatterns = [
126
- ...STRYKER_DEFAULTS.ignorePatterns,
127
- ...(input.ignorePatterns ?? []),
128
- ...STRYKER_DEFAULTS.alwaysIgnoredPatterns
149
+ ...new Set([
150
+ ...STRYKER_DEFAULTS.ignorePatterns,
151
+ ...(input.ignorePatterns ?? []),
152
+ ...STRYKER_DEFAULTS.alwaysIgnoredPatterns
153
+ ])
129
154
  ];
130
155
  if (pluginDescriptors.length > 0) {
131
156
  // `appendPlugins` (not `plugins`) so a project `stryker.conf.js` keeps
@@ -136,6 +161,7 @@ export function buildStrykerOptions(input) {
136
161
  }
137
162
  /**
138
163
  * Apply the options the caller owns. Everything here is a PROJECT-owned
164
+
139
165
  * setting: it is written only when the caller asked for it, so a project
140
166
  * `stryker.conf.js` keeps its own value.
141
167
  *
@@ -180,17 +206,3 @@ function applyCallerOwnedOptions(options, input) {
180
206
  export function toStrykerCliOptions(options) {
181
207
  return options;
182
208
  }
183
- /**
184
- * Resolve test-file patterns against the project root so the result does
185
- * not depend on the caller's CWD. Absolute patterns are kept as-is.
186
- *
187
- * PURE: a path that does not exist is resolved anyway. Rejecting it is the
188
- * validator's job (`test-files.ts`), and the validator runs at the boundary
189
- * that owns the file system — see the module header.
190
- */
191
- function resolveTestFiles(project, patterns) {
192
- if (!patterns || patterns.length === 0) {
193
- return [];
194
- }
195
- return patterns.map((pattern) => (isAbsolute(pattern) ? pattern : resolve(project, pattern)));
196
- }
@@ -0,0 +1,91 @@
1
+ /**
2
+ * A throwaway vitest config whose `include` is exactly the caller's test files.
3
+ *
4
+ * THE DEFECT THIS EXISTS FOR. `peaks mut run --test-files <a> <b>` passed the
5
+ * files to Stryker, but Stryker loads the project's `stryker.conf.js`, which
6
+ * points `vitest.configFile` at `stryker.vitest.config.mjs` — a config whose
7
+ * `include` names TWO hard-coded test files. Vitest filters `--test-files`
8
+ * through that `include`, so any other file selected ZERO tests and the dry run
9
+ * aborted with "No tests were executed". Measured 2026-11-17: a brand-new test
10
+ * file for a brand-new module could not be mutation-tested at all. The
11
+ * `--test-files` option was effectively decorative for every file outside those
12
+ * two.
13
+ *
14
+ * WHY NOT JUST WIDEN THE PROJECT CONFIG'S `include`. `stryker.vitest.config.mjs`
15
+ * is also what a direct `npx stryker run` uses, and its narrow list is deliberate
16
+ * there: the main suite contains CLI tests that call `process.chdir()`, which
17
+ * Stryker's forced-threaded vitest workers reject. Widening it would break that
18
+ * path. A per-run generated config leaves the project's own file exactly as its
19
+ * author intended and gives `peaks mut` the selection the caller asked for.
20
+ *
21
+ * WHERE IT LIVES. Under the project's `.peaks/_runtime/<sid>/mut/`, which is
22
+ * gitignored runtime state and is already in `alwaysIgnoredPatterns`, so the file
23
+ * neither pollutes the tree nor gets copied into the Stryker sandbox.
24
+ */
25
+ export type GeneratedVitestConfig = {
26
+ /** Absolute path of the config file that was written. */
27
+ readonly configPath: string;
28
+ };
29
+ /**
30
+ * Write a vitest config under `<project>/.peaks/_runtime/<sid>/mut/` whose
31
+ * `include` is exactly `testFiles`, and whose aliases match the project's own
32
+ * `~/src/*` mapping so tests load exactly as they do normally.
33
+ *
34
+ * `setupFiles` is carried over from the project's config when the caller names
35
+ * one: a suite that depends on global setup (the workspace build, for instance)
36
+ * fails without it, and a mutation run that fails for a setup reason reports
37
+ * mutants as killed when nothing ran.
38
+ */
39
+ export declare function writeRunScopedVitestConfig(input: {
40
+ readonly project: string;
41
+ readonly sessionId: string;
42
+ readonly testFiles: ReadonlyArray<string>;
43
+ readonly setupFiles?: ReadonlyArray<string>;
44
+ }): GeneratedVitestConfig;
45
+ /** Display path for a generated config, relative to the project when possible. */
46
+ export declare function displayConfigPath(project: string, configPath: string): string;
47
+ /**
48
+ * The `vitest` options for a run that names its test files.
49
+ *
50
+ * TWO THINGS, both required:
51
+ * - `related: false` — an explicit test list is authoritative, so vitest's
52
+ * related-mode narrowing must not discard it;
53
+ * - `configFile` — the generated config below, whose `include` IS the list.
54
+ * A project `stryker.conf.js` normally points at a config with a fixed
55
+ * short `include`, and vitest filters `--test-files` through it, so any
56
+ * other file selects ZERO tests and the dry run aborts with "No tests were
57
+ * executed". Measured 2026-11-17: a new test file could not be
58
+ * mutation-tested at all.
59
+ *
60
+ * WITHOUT A SESSION ID, `configFile` is OMITTED and only `related` is returned.
61
+ * This function builds OPTIONS; it does not own the run's preconditions. An
62
+ * earlier version threw here, which made every caller that only inspects the
63
+ * built options — the package's own `stryker-options.test.ts` does exactly that
64
+ * — supply a session id it has no use for. The requirement belongs where the
65
+ * run is started: `peaks mut run` declares `--session-id` a REQUIRED option, so
66
+ * an unscoped run cannot reach Stryker through the CLI. A programmatic caller
67
+ * that omits it falls back to the project's own `include` and sees the
68
+ * zero-tests abort, which is loud and names its own cause.
69
+ */
70
+ export declare function scopedVitestOptions(input: {
71
+ readonly project: string;
72
+ readonly testFiles: ReadonlyArray<string>;
73
+ readonly sessionId: string | undefined;
74
+ readonly setupFiles?: ReadonlyArray<string>;
75
+ }): {
76
+ related: boolean;
77
+ configFile?: string;
78
+ };
79
+ /**
80
+ * Resolve test-file patterns against the project root so the result does
81
+ * not depend on the caller's CWD. Absolute patterns are kept as-is.
82
+ *
83
+ * PURE: a path that does not exist is resolved anyway. Rejecting it is this
84
+ * module's own `assertTestFilesUsable`, which runs at the boundary that owns
85
+ * the file system — see the module header.
86
+ *
87
+ * Lives here rather than in `stryker-options.ts` because it is about test
88
+ * files, not about Stryker options; the options builder imports it.
89
+ */
90
+ export declare function resolveTestFiles(project: string, patterns: ReadonlyArray<string> | undefined): string[];
91
+ //# sourceMappingURL=stryker-run-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stryker-run-config.d.ts","sourceRoot":"","sources":["../../../src/services/mut/stryker-run-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAKH,MAAM,MAAM,qBAAqB,GAAG;IAClC,yDAAyD;IACzD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B,CAAC;AAQF;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE;IAChD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC1C,QAAQ,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC7C,GAAG,qBAAqB,CAgBxB;AA2CD,kFAAkF;AAClF,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAG7E;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE;IACzC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC1C,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC7C,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAW5C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,GAC1C,MAAM,EAAE,CAKV"}
@@ -0,0 +1,153 @@
1
+ /**
2
+ * A throwaway vitest config whose `include` is exactly the caller's test files.
3
+ *
4
+ * THE DEFECT THIS EXISTS FOR. `peaks mut run --test-files <a> <b>` passed the
5
+ * files to Stryker, but Stryker loads the project's `stryker.conf.js`, which
6
+ * points `vitest.configFile` at `stryker.vitest.config.mjs` — a config whose
7
+ * `include` names TWO hard-coded test files. Vitest filters `--test-files`
8
+ * through that `include`, so any other file selected ZERO tests and the dry run
9
+ * aborted with "No tests were executed". Measured 2026-11-17: a brand-new test
10
+ * file for a brand-new module could not be mutation-tested at all. The
11
+ * `--test-files` option was effectively decorative for every file outside those
12
+ * two.
13
+ *
14
+ * WHY NOT JUST WIDEN THE PROJECT CONFIG'S `include`. `stryker.vitest.config.mjs`
15
+ * is also what a direct `npx stryker run` uses, and its narrow list is deliberate
16
+ * there: the main suite contains CLI tests that call `process.chdir()`, which
17
+ * Stryker's forced-threaded vitest workers reject. Widening it would break that
18
+ * path. A per-run generated config leaves the project's own file exactly as its
19
+ * author intended and gives `peaks mut` the selection the caller asked for.
20
+ *
21
+ * WHERE IT LIVES. Under the project's `.peaks/_runtime/<sid>/mut/`, which is
22
+ * gitignored runtime state and is already in `alwaysIgnoredPatterns`, so the file
23
+ * neither pollutes the tree nor gets copied into the Stryker sandbox.
24
+ */
25
+ import { mkdirSync, writeFileSync } from 'node:fs';
26
+ import { isAbsolute, join, relative, resolve, sep } from 'node:path';
27
+ /** One `'<path>',` line for an array literal in the generated module. */
28
+ function includeLine(projectRoot, file) {
29
+ const rel = relative(projectRoot, resolve(projectRoot, file)).split(sep).join('/');
30
+ return ` '${rel.replace(/'/g, "\\'")}',`;
31
+ }
32
+ /**
33
+ * Write a vitest config under `<project>/.peaks/_runtime/<sid>/mut/` whose
34
+ * `include` is exactly `testFiles`, and whose aliases match the project's own
35
+ * `~/src/*` mapping so tests load exactly as they do normally.
36
+ *
37
+ * `setupFiles` is carried over from the project's config when the caller names
38
+ * one: a suite that depends on global setup (the workspace build, for instance)
39
+ * fails without it, and a mutation run that fails for a setup reason reports
40
+ * mutants as killed when nothing ran.
41
+ */
42
+ export function writeRunScopedVitestConfig(input) {
43
+ const projectRoot = resolve(input.project);
44
+ const outDir = join(projectRoot, '.peaks', '_runtime', input.sessionId, 'mut');
45
+ mkdirSync(outDir, { recursive: true });
46
+ const configPath = join(outDir, 'vitest.run-scoped.config.mjs');
47
+ // PROJECT-RELATIVE, never absolute. Stryker copies the project into
48
+ // `.stryker-tmp/sandbox-*` and evaluates this config THERE, so an absolute
49
+ // path baked at generation time names the ORIGINAL tree — outside the
50
+ // sandbox's `root`, which vitest then filters away, reporting zero tests.
51
+ // Measured 2026-11-17: absolute includes produced exactly that.
52
+ const includes = input.testFiles.map((f) => includeLine(projectRoot, f)).join('\n');
53
+ const setup = (input.setupFiles ?? []).map((f) => includeLine(projectRoot, f)).join('\n');
54
+ writeFileSync(configPath, renderConfigSource(includes, setup), 'utf8');
55
+ return { configPath };
56
+ }
57
+ /** The module text a run-scoped config is made of. Separate from the file write
58
+ * so the template stays readable (and under the function-length cap). */
59
+ function renderConfigSource(includes, setup) {
60
+ return [
61
+ '// GENERATED PER MUTATION RUN — do not edit, do not commit.',
62
+ '//',
63
+ '// Its `include` is exactly the test files this run was asked for, which is',
64
+ "// what `--test-files` means. See writeRunScopedVitestConfig's header.",
65
+ '',
66
+ '// NO `vitest/config` IMPORT, and a PLAIN OBJECT export. A target project may',
67
+ '// have no node_modules at all — the integration fixture deliberately has',
68
+ '// none, to prove the runner is loaded from peaks-loop own installation — so',
69
+ '// `import { defineConfig } from "vitest/config"` would fail to resolve and',
70
+ '// the run would die before Stryker started. `defineConfig` is a typing',
71
+ '// helper, not a requirement: vitest accepts an exported plain object.',
72
+ '',
73
+ '// NO `root`, AND RELATIVE `include`/`alias` BASE. Stryker evaluates this',
74
+ '// config inside a copy of the project at `.stryker-tmp/sandbox-*`, so any',
75
+ '// absolute path baked at generation time would name the ORIGINAL tree —',
76
+ '// outside the sandbox — and vitest would filter every include away',
77
+ '// (measured 2026-11-17: exactly zero tests selected that way). Omitting',
78
+ '// `root` lets vitest use its own cwd, which is the sandbox.',
79
+ 'const projectRoot = process.cwd();',
80
+ '',
81
+ 'export default {',
82
+ ' resolve: {',
83
+ ' alias: [',
84
+ " { find: /^~\\/src\\/(.*)$/, replacement: projectRoot + '/src/' + '$1' },",
85
+ " { find: /^~\\/src\\/(.*)\\.js$/, replacement: projectRoot + '/src/' + '$1' + '.ts' }",
86
+ ' ]',
87
+ ' },',
88
+ ' test: {',
89
+ ' include: [\n' + includes + '\n ],',
90
+ ...(setup === '' ? [] : [' setupFiles: [\n' + setup + '\n ],']),
91
+ ' passWithNoTests: false',
92
+ ' }',
93
+ '};',
94
+ ''
95
+ ].join('\n');
96
+ }
97
+ /** Display path for a generated config, relative to the project when possible. */
98
+ export function displayConfigPath(project, configPath) {
99
+ const rel = relative(resolve(project), configPath);
100
+ return rel === '' ? configPath : rel.split(sep).join('/');
101
+ }
102
+ /**
103
+ * The `vitest` options for a run that names its test files.
104
+ *
105
+ * TWO THINGS, both required:
106
+ * - `related: false` — an explicit test list is authoritative, so vitest's
107
+ * related-mode narrowing must not discard it;
108
+ * - `configFile` — the generated config below, whose `include` IS the list.
109
+ * A project `stryker.conf.js` normally points at a config with a fixed
110
+ * short `include`, and vitest filters `--test-files` through it, so any
111
+ * other file selects ZERO tests and the dry run aborts with "No tests were
112
+ * executed". Measured 2026-11-17: a new test file could not be
113
+ * mutation-tested at all.
114
+ *
115
+ * WITHOUT A SESSION ID, `configFile` is OMITTED and only `related` is returned.
116
+ * This function builds OPTIONS; it does not own the run's preconditions. An
117
+ * earlier version threw here, which made every caller that only inspects the
118
+ * built options — the package's own `stryker-options.test.ts` does exactly that
119
+ * — supply a session id it has no use for. The requirement belongs where the
120
+ * run is started: `peaks mut run` declares `--session-id` a REQUIRED option, so
121
+ * an unscoped run cannot reach Stryker through the CLI. A programmatic caller
122
+ * that omits it falls back to the project's own `include` and sees the
123
+ * zero-tests abort, which is loud and names its own cause.
124
+ */
125
+ export function scopedVitestOptions(input) {
126
+ if (input.sessionId === undefined) {
127
+ return { related: false };
128
+ }
129
+ const generated = writeRunScopedVitestConfig({
130
+ project: input.project,
131
+ sessionId: input.sessionId,
132
+ testFiles: input.testFiles,
133
+ ...(input.setupFiles !== undefined ? { setupFiles: input.setupFiles } : {})
134
+ });
135
+ return { related: false, configFile: generated.configPath };
136
+ }
137
+ /**
138
+ * Resolve test-file patterns against the project root so the result does
139
+ * not depend on the caller's CWD. Absolute patterns are kept as-is.
140
+ *
141
+ * PURE: a path that does not exist is resolved anyway. Rejecting it is this
142
+ * module's own `assertTestFilesUsable`, which runs at the boundary that owns
143
+ * the file system — see the module header.
144
+ *
145
+ * Lives here rather than in `stryker-options.ts` because it is about test
146
+ * files, not about Stryker options; the options builder imports it.
147
+ */
148
+ export function resolveTestFiles(project, patterns) {
149
+ if (!patterns || patterns.length === 0) {
150
+ return [];
151
+ }
152
+ return patterns.map((pattern) => (isAbsolute(pattern) ? pattern : resolve(project, pattern)));
153
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "peaks-loop-mut",
3
- "version": "0.1.81",
3
+ "version": "0.1.82",
4
4
  "description": "Mutation testing + assertion scanning + ECC cache for peaks-loop (workspace-internal)",
5
5
  "keywords": [
6
6
  "peaks-loop",