mutant-cafe 0.1.6 → 0.1.7

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/dist/bin.js CHANGED
@@ -63,7 +63,7 @@ var ScratchError = class extends Schema2.TaggedError()("ScratchError", {
63
63
  }) {
64
64
  };
65
65
  var TestSpawnError = class extends Schema2.TaggedError()("TestSpawnError", {
66
- kind: Schema2.optional(Schema2.Literal("reporter")),
66
+ kind: Schema2.optional(Schema2.Literals(["reporter", "vitest-version"])),
67
67
  command: Schema2.Array(Schema2.String),
68
68
  message: Schema2.String
69
69
  }) {
@@ -265,24 +265,48 @@ function sanitizeReportTelemetry(report) {
265
265
  return { report: { ...root.value, baseline: { ...baseline.value, ...warnings.length ? { telemetryWarnings: warnings } : {} }, results: results.map((result5) => result5.value) }, warnings };
266
266
  }
267
267
 
268
- // packages/engine/src/index.ts
268
+ // packages/core/src/Selection.ts
269
269
  import * as Effect from "effect/Effect";
270
+ import * as Path from "effect/Path";
271
+ var excludeLinkedCandidates = Effect.fn("Selection.excludeLinkedCandidates")(function* (root, candidates, linkedRoots) {
272
+ const path = yield* Path.Path;
273
+ const mutants = [];
274
+ const skipped2 = [];
275
+ for (const mutant of candidates) {
276
+ const file = path.isAbsolute(mutant.file) ? path.relative(root, mutant.file) : mutant.file;
277
+ const linked = linkedRoots.some((link) => {
278
+ const relative2 = path.relative(link, file);
279
+ return relative2 === "" || relative2 !== ".." && !relative2.startsWith(`..${path.sep}`) && !path.isAbsolute(relative2);
280
+ });
281
+ if (linked) skipped2.push({
282
+ file: path.resolve(root, file),
283
+ functionName: mutant.functionName,
284
+ span: mutant.span,
285
+ reason: "Source is in a linked ignored tree; original files are not mutation targets"
286
+ });
287
+ else mutants.push(mutant);
288
+ }
289
+ return { mutants, notMutated: [...new Map(skipped2.map((entry) => [JSON.stringify(entry), entry])).values()] };
290
+ });
291
+
292
+ // packages/engine/src/index.ts
293
+ import * as Effect2 from "effect/Effect";
270
294
  import * as Layer from "effect/Layer";
271
295
  import * as Stream from "effect/Stream";
272
296
  import * as Schema4 from "effect/Schema";
273
297
 
274
298
  // packages/engine/src/Generate.ts
275
299
  import { createHash } from "node:crypto";
276
- function* generateFunction(fn11) {
277
- const issue = fn11.generationIssue?.();
300
+ function* generateFunction(fn12) {
301
+ const issue = fn12.generationIssue?.();
278
302
  if (issue) return issue;
279
- const api = fn11.api;
303
+ const api = fn12.api;
280
304
  const candidate = (genre, expression, value = { text: "", synthetic: false }, description = expression) => {
281
- const pinned = `((): ${fn11.returnType} => (${expression}))()`;
282
- const text = fn11.block ? `{ return ${fn11.generator ? "yield* " : ""}${pinned}; }` : `(${pinned})`;
283
- return makeMutant(fn11, genre, text, value.synthetic, description);
305
+ const pinned = `((): ${fn12.returnType} => (${expression}))()`;
306
+ const text = fn12.block ? `{ return ${fn12.generator ? "yield* " : ""}${pinned}; }` : `(${pinned})`;
307
+ return makeMutant(fn12, genre, text, value.synthetic, description);
284
308
  };
285
- const shape = fn11.shape;
309
+ const shape = fn12.shape;
286
310
  const fits = (value) => new TextEncoder().encode(value.text).byteLength <= 2048;
287
311
  const values = "values" in shape ? shape.values.filter(fits) : [];
288
312
  switch (shape.kind) {
@@ -290,7 +314,7 @@ function* generateFunction(fn11) {
290
314
  const succeed7 = api("Effect", "succeed");
291
315
  if (succeed7) {
292
316
  for (const value of values) {
293
- if (!fn11.equivalentValues.includes(value.text) && !(fn11.generator && value.text === fn11.literal)) yield candidate("EffectSucceed", `${succeed7}(${value.text})`, value);
317
+ if (!fn12.equivalentValues.includes(value.text) && !(fn12.generator && value.text === fn12.literal)) yield candidate("EffectSucceed", `${succeed7}(${value.text})`, value);
294
318
  }
295
319
  }
296
320
  const fail4 = api("Effect", "fail");
@@ -299,7 +323,7 @@ function* generateFunction(fn11) {
299
323
  if (fail4 && fits(error3)) yield candidate("EffectFail", `${fail4}(${error3.text})`, error3, `${fail4}(${error3.text}) [${error3.synthetic ? "synthetic tag cast" : "constructed error"}]`);
300
324
  const recoveries = values.length ? shape.enumerateRecoveries ? values : values.slice(0, 1) : [void 0];
301
325
  const gen11 = api("Effect", "gen");
302
- const original = fn11.generator ? gen11 && `((): ${fn11.returnType} => ${gen11}(function* () ${fn11.original}))()` : fn11.block ? `((): ${fn11.returnType} => ${fn11.original})()` : `((): ${fn11.returnType} => (${fn11.original}))()`;
326
+ const original = fn12.generator ? gen11 && `((): ${fn12.returnType} => ${gen11}(function* () ${fn12.original}))()` : fn12.block ? `((): ${fn12.returnType} => ${fn12.original})()` : `((): ${fn12.returnType} => (${fn12.original}))()`;
303
327
  for (const value of recoveries) {
304
328
  const die3 = api("Effect", "die");
305
329
  const recovery = value && succeed7 ? `${succeed7}(${value.text})` : die3 ? `${die3}(${JSON.stringify(`mutant.cafe: swallowed ${error3.tag}`)})` : void 0;
@@ -323,10 +347,10 @@ function* generateFunction(fn11) {
323
347
  }
324
348
  case "Stream": {
325
349
  const empty = api("Stream", "empty");
326
- const make11 = api("Stream", "make");
350
+ const make12 = api("Stream", "make");
327
351
  const fail4 = api("Stream", "fail");
328
352
  if (empty) yield candidate("StreamEmpty", empty);
329
- if (make11) for (const value of values) yield candidate("StreamOne", `${make11}(${value.text})`, value);
353
+ if (make12) for (const value of values) yield candidate("StreamOne", `${make12}(${value.text})`, value);
330
354
  if (fail4) {
331
355
  for (const error3 of shape.errors) if (fits(error3)) yield candidate("StreamFail", `${fail4}(${error3.text})`, error3);
332
356
  }
@@ -343,32 +367,32 @@ function* generateFunction(fn11) {
343
367
  break;
344
368
  }
345
369
  case "Void":
346
- yield makeMutant(fn11, "FnValue", "{}", false, "an empty body");
370
+ if (!fn12.equivalentValues.includes("{}")) yield makeMutant(fn12, "FnValue", "{}", false, "an empty body");
347
371
  break;
348
372
  default: {
349
373
  const genre = shape.kind === "Boolean" ? "BooleanFlip" : shape.kind === "Literal" ? "LiteralCycle" : "FnValue";
350
374
  for (const value of values) {
351
- if (value.text === fn11.literal) continue;
375
+ if (value.text === fn12.literal || fn12.equivalentValues.includes(value.text)) continue;
352
376
  yield candidate(genre, value.text, value);
353
377
  }
354
378
  }
355
379
  }
356
380
  }
357
- function makeMutant(fn11, genre, text, synthetic, description) {
358
- const additions = fn11.extraImports?.filter((item) => text.includes(`${item.namespace}.`)) ?? [];
359
- const prefix = fn11.sourcePrefix ?? "";
360
- const insertion = fn11.importInsertionOffset ?? 0;
361
- const replacement = additions.length && fn11.sourcePrefix !== void 0 ? { startOffset: 0, endOffset: fn11.endOffset, text: prefix.slice(0, insertion) + (insertion ? "\n" : "") + additions.map((item) => item.statement).join("\n") + "\n" + prefix.slice(insertion) + text } : { startOffset: fn11.startOffset, endOffset: fn11.endOffset, text };
362
- const id = createHash("sha256").update(JSON.stringify([fn11.identityFile ?? fn11.file, fn11.name, fn11.identityOrdinal ?? 0, fn11.logicalSpan, genre, text, additions.map((item) => item.statement)])).digest("hex").slice(0, 24);
381
+ function makeMutant(fn12, genre, text, synthetic, description) {
382
+ const additions = fn12.extraImports?.filter((item) => text.includes(`${item.namespace}.`)) ?? [];
383
+ const prefix = fn12.sourcePrefix ?? "";
384
+ const insertion = fn12.importInsertionOffset ?? 0;
385
+ const replacement = additions.length && fn12.sourcePrefix !== void 0 ? { startOffset: 0, endOffset: fn12.endOffset, text: prefix.slice(0, insertion) + (insertion ? "\n" : "") + additions.map((item) => item.statement).join("\n") + "\n" + prefix.slice(insertion) + text } : { startOffset: fn12.startOffset, endOffset: fn12.endOffset, text };
386
+ const id = createHash("sha256").update(JSON.stringify([fn12.identityFile ?? fn12.file, fn12.name, fn12.identityOrdinal ?? 0, fn12.logicalSpan, genre, text, additions.map((item) => item.statement)])).digest("hex").slice(0, 24);
363
387
  return {
364
388
  id,
365
- file: fn11.file,
366
- functionName: fn11.name,
367
- returnType: fn11.returnType,
368
- displayReturnType: fn11.displayReturnType,
389
+ file: fn12.file,
390
+ functionName: fn12.name,
391
+ returnType: fn12.returnType,
392
+ displayReturnType: fn12.displayReturnType,
369
393
  genre,
370
- description: `replace ${fn11.name} -> ${fn11.returnType} with ${description}`,
371
- span: fn11.span,
394
+ description: `replace ${fn12.name} -> ${fn12.returnType} with ${description}`,
395
+ span: fn12.span,
372
396
  replacement,
373
397
  synthetic
374
398
  };
@@ -395,6 +419,8 @@ var ProgramSession = class {
395
419
  if (config.error) throw new ProgramLoadError({ tsconfig: configPath, diagnostics: diagnosticsText([config.error]) });
396
420
  const parsed = ts.parseJsonConfigFileContent(config.config, ts.sys, resolve(configPath, ".."));
397
421
  if (parsed.errors.length) throw new ProgramLoadError({ tsconfig: configPath, diagnostics: diagnosticsText(parsed.errors) });
422
+ parsed.options.incremental = false;
423
+ delete parsed.options.tsBuildInfoFile;
398
424
  this.host = ts.createCompilerHost(parsed.options, true);
399
425
  const read = this.host.getSourceFile;
400
426
  this.host.getSourceFile = (file, languageVersion, onError, shouldCreateNewSourceFile) => {
@@ -490,7 +516,7 @@ function makeTypeScriptOracle() {
490
516
  const b = source.getLineAndCharacterOfPosition(end);
491
517
  const beforePipeables = wrapped && ts.isFunctionExpression(node) ? generatorContract(node, checker) : void 0;
492
518
  const shape = beforePipeables?.shape ?? shapeOf(type, checker, node, body);
493
- const originals = equivalentSuccessValues(body, api);
519
+ const originals = generator ? equivalentLiteralValues(body) : equivalentSuccessValues(body, checker);
494
520
  if (!beforePipeables && type.flags & ts.TypeFlags.TypeParameter && !("values" in shape && shape.values.length) || (beforePipeables ? !nameableContract(beforePipeables, checker, node) : hasUnnameableType(type, checker, node))) {
495
521
  notMutated.push({ file, functionName: name, span: nodeSpan(node), reason: "generic: naked or context-only type-parameter return" });
496
522
  } else found.push({
@@ -503,7 +529,7 @@ function makeTypeScriptOracle() {
503
529
  returnType: beforePipeables?.text ?? returnTypeText(type, checker, node),
504
530
  displayReturnType: node.type?.getText(source) ?? checker.typeToString(type, node),
505
531
  skipReason: beforePipeables ? `no synthesizable generator success value: ${beforePipeables.text}` : synthesisReason(type, checker, node),
506
- equivalentValues: shape.kind === "Effect" ? shape.values.filter((value) => isEquivalentSuccess(value.text, originals)).map((value) => value.text) : [],
532
+ equivalentValues: shape.kind === "Void" && ts.isBlock(body) && body.statements.length === 0 ? ["{}"] : "values" in shape ? shape.values.filter((value) => isEquivalentSuccess(value.text, shape.kind === "Effect" ? originals : equivalentLiteralValues(body))).map((value) => value.text) : [],
507
533
  span: { start: { line: a.line + 1, column: a.character + 1 }, end: { line: b.line + 1, column: b.character + 1 } },
508
534
  startOffset: start,
509
535
  endOffset: end,
@@ -576,10 +602,10 @@ function makeTypeScriptOracle() {
576
602
  const found = [];
577
603
  visit(source);
578
604
  const occurrences = /* @__PURE__ */ new Map();
579
- for (const fn11 of found) {
580
- const ordinal = occurrences.get(fn11.name) ?? 0;
581
- occurrences.set(fn11.name, ordinal + 1);
582
- functions.push({ ...fn11, identityOrdinal: ordinal });
605
+ for (const fn12 of found) {
606
+ const ordinal = occurrences.get(fn12.name) ?? 0;
607
+ occurrences.set(fn12.name, ordinal + 1);
608
+ functions.push({ ...fn12, identityOrdinal: ordinal });
583
609
  }
584
610
  }
585
611
  const unmatched = config.include.filter((glob) => !matched.has(glob));
@@ -804,11 +830,25 @@ function generatorContract(node, checker) {
804
830
  };
805
831
  }
806
832
  function literalOfBody(body, checker) {
807
- const first = ts.isBlock(body) && body.statements.length === 1 ? body.statements[0] : void 0;
808
- const expression = ts.isBlock(body) ? first && ts.isReturnStatement(first) ? first.expression : void 0 : body;
833
+ const expression = returnedExpression(body);
809
834
  if (!expression) return void 0;
810
- const type = checker.getTypeAtLocation(expression);
811
- return type.isStringLiteral() ? JSON.stringify(type.value) : type.isNumberLiteral() ? String(type.value) : type.flags & ts.TypeFlags.BooleanLiteral ? checker.typeToString(type) : void 0;
835
+ if (ts.isStringLiteral(expression)) return JSON.stringify(expression.text);
836
+ if (ts.isNumericLiteral(expression)) return String(Number(expression.text));
837
+ if (expression.kind === ts.SyntaxKind.TrueKeyword) return "true";
838
+ if (expression.kind === ts.SyntaxKind.FalseKeyword) return "false";
839
+ if (expression.kind === ts.SyntaxKind.NullKeyword) return "null";
840
+ if (ts.isIdentifier(expression)) {
841
+ let symbol = checker.getSymbolAtLocation(expression);
842
+ if (symbol && symbol.flags & ts.SymbolFlags.Alias) symbol = checker.getAliasedSymbol(symbol);
843
+ const constant = symbol?.declarations?.some((declaration) => ts.isEnumMember(declaration) || ts.isVariableDeclaration(declaration) && ts.isVariableDeclarationList(declaration.parent) && !!(declaration.parent.flags & ts.NodeFlags.Const));
844
+ if (constant) {
845
+ const type = checker.getTypeAtLocation(expression);
846
+ if (type.isStringLiteral()) return JSON.stringify(type.value);
847
+ if (type.isNumberLiteral()) return String(type.value);
848
+ if (type.flags & ts.TypeFlags.BooleanLiteral) return checker.typeToString(type);
849
+ }
850
+ }
851
+ return void 0;
812
852
  }
813
853
  function generatorBody(node, checker) {
814
854
  if (!node.body) return void 0;
@@ -1012,10 +1052,13 @@ function returnTypeText(type, checker, node) {
1012
1052
  return print(type);
1013
1053
  }
1014
1054
  function literalData(node) {
1015
- if (ts.isParenthesizedExpression(node) || ts.isAsExpression(node) || ts.isSatisfiesExpression(node)) return literalData(node.expression);
1055
+ if (ts.isParenthesizedExpression(node) || ts.isAsExpression(node) || ts.isSatisfiesExpression(node) || ts.isTypeAssertionExpression(node) || ts.isNonNullExpression(node)) return literalData(node.expression);
1016
1056
  if (ts.isStringLiteral(node) || ts.isNumericLiteral(node)) return [node.kind, node.text];
1017
1057
  if (ts.isIdentifier(node) && node.text === "undefined") return ["undefined"];
1018
- if (ts.isPrefixUnaryExpression(node)) return [node.operator, literalData(node.operand)];
1058
+ if (ts.isPrefixUnaryExpression(node)) {
1059
+ const operand = literalData(node.operand);
1060
+ return operand === void 0 ? void 0 : [node.operator, operand];
1061
+ }
1019
1062
  if (ts.isArrayLiteralExpression(node)) {
1020
1063
  const items = node.elements.map(literalData);
1021
1064
  return items.every((item) => item !== void 0) ? ["array", items] : void 0;
@@ -1033,17 +1076,54 @@ function literalData(node) {
1033
1076
  }
1034
1077
  return void 0;
1035
1078
  }
1036
- function equivalentSuccessValues(body, api) {
1037
- const values = [];
1038
- const visit = (node) => {
1039
- if (ts.isCallExpression(node) && node.expression.getText() === api("Effect", "succeed") && node.arguments[0]) {
1040
- const value = literalData(node.arguments[0]);
1041
- if (value !== void 0) values.push(JSON.stringify(value));
1079
+ function unwrapped(node) {
1080
+ while (ts.isParenthesizedExpression(node) || ts.isAsExpression(node) || ts.isSatisfiesExpression(node) || ts.isTypeAssertionExpression(node) || ts.isNonNullExpression(node)) node = node.expression;
1081
+ return node;
1082
+ }
1083
+ function returnedExpression(body) {
1084
+ if (!ts.isBlock(body)) return unwrapped(body);
1085
+ const statement = body.statements.length === 1 ? body.statements[0] : void 0;
1086
+ return statement && ts.isReturnStatement(statement) && statement.expression ? unwrapped(statement.expression) : void 0;
1087
+ }
1088
+ function equivalentLiteralValues(body) {
1089
+ const expression = returnedExpression(body);
1090
+ const value = expression && literalData(expression);
1091
+ return value === void 0 ? [] : [JSON.stringify(value)];
1092
+ }
1093
+ function equivalentSuccessValues(body, checker) {
1094
+ const expression = returnedExpression(body);
1095
+ if (!expression) return [];
1096
+ const namespace = (node, seen = /* @__PURE__ */ new Set()) => {
1097
+ node = unwrapped(node);
1098
+ if (!ts.isIdentifier(node) && !ts.isPropertyAccessExpression(node)) return false;
1099
+ if (ts.isPropertyAccessExpression(node) && !namespace(node.expression, seen)) return false;
1100
+ let symbol = checker.getSymbolAtLocation(ts.isPropertyAccessExpression(node) ? node.name : node);
1101
+ if (!symbol || seen.has(symbol)) return false;
1102
+ seen.add(symbol);
1103
+ if (symbol.flags & ts.SymbolFlags.Alias) symbol = checker.getAliasedSymbol(symbol);
1104
+ return symbol.declarations?.some((declaration) => {
1105
+ if (ts.isSourceFile(declaration)) return /\/node_modules\/effect\/(?:.*\/)?(?:Effect|index)\.(?:d\.)?ts$/.test(declaration.fileName);
1106
+ return ts.isVariableDeclaration(declaration) && !!declaration.initializer && ts.isVariableDeclarationList(declaration.parent) && !!(declaration.parent.flags & ts.NodeFlags.Const) && namespace(declaration.initializer, seen);
1107
+ }) ?? false;
1108
+ };
1109
+ const member = (node, seen = /* @__PURE__ */ new Set()) => {
1110
+ node = unwrapped(node);
1111
+ if (!ts.isIdentifier(node) && !ts.isPropertyAccessExpression(node)) return void 0;
1112
+ if (ts.isPropertyAccessExpression(node) && !namespace(node.expression)) return void 0;
1113
+ let symbol = checker.getSymbolAtLocation(ts.isPropertyAccessExpression(node) ? node.name : node);
1114
+ if (!symbol || seen.has(symbol)) return void 0;
1115
+ seen.add(symbol);
1116
+ if (symbol.flags & ts.SymbolFlags.Alias) symbol = checker.getAliasedSymbol(symbol);
1117
+ for (const declaration of symbol.declarations ?? []) {
1118
+ if (/\/node_modules\/effect\/(?:.*\/)?Effect\.(?:d\.)?ts$/.test(declaration.getSourceFile().fileName)) return symbol.name === "void_" ? "void" : symbol.name;
1119
+ if (ts.isVariableDeclaration(declaration) && declaration.initializer && ts.isVariableDeclarationList(declaration.parent) && declaration.parent.flags & ts.NodeFlags.Const) return member(declaration.initializer, seen);
1042
1120
  }
1043
- ts.forEachChild(node, visit);
1121
+ return void 0;
1044
1122
  };
1045
- visit(body);
1046
- return values;
1123
+ if (member(expression) === "void") return [JSON.stringify(["undefined"])];
1124
+ if (!ts.isCallExpression(expression) || expression.arguments.length !== 1 || member(expression.expression) !== "succeed") return [];
1125
+ const value = literalData(expression.arguments[0]);
1126
+ return value === void 0 ? [] : [JSON.stringify(value)];
1047
1127
  }
1048
1128
  function isEquivalentSuccess(text, values) {
1049
1129
  const source = ts.createSourceFile("literal.ts", `(${text})`, ts.ScriptTarget.Latest, true);
@@ -1233,18 +1313,18 @@ function synthesizeValues(type, checker, location, ancestors, depth, issues) {
1233
1313
  // packages/engine/src/index.ts
1234
1314
  var MutantSourceLive = Layer.effect(
1235
1315
  MutantSource,
1236
- Effect.sync(() => makeMutantSource(makeTypeScriptOracle()))
1316
+ Effect2.sync(() => makeMutantSource(makeTypeScriptOracle()))
1237
1317
  );
1238
1318
  function makeMutantSource(oracle) {
1239
- const discover = (config) => Effect.try({
1319
+ const discover = (config) => Effect2.try({
1240
1320
  try: () => {
1241
1321
  const discovered = oracle.discover(config);
1242
1322
  const notMutated = [...discovered.notMutated];
1243
1323
  const mutants = [];
1244
1324
  const failed = /* @__PURE__ */ new Set();
1245
- const generatedFunctions = discovered.functions.map((fn11) => {
1325
+ const generatedFunctions = discovered.functions.map((fn12) => {
1246
1326
  try {
1247
- const iterator = generateFunction(fn11);
1327
+ const iterator = generateFunction(fn12);
1248
1328
  const generated = [];
1249
1329
  let step = iterator.next();
1250
1330
  while (!step.done) {
@@ -1252,32 +1332,32 @@ function makeMutantSource(oracle) {
1252
1332
  step = iterator.next();
1253
1333
  }
1254
1334
  if (step.value) {
1255
- failed.add(fn11);
1256
- notMutated.push({ file: fn11.file, functionName: fn11.name, span: fn11.span, reason: step.value });
1257
- return { fn: fn11, generated: [] };
1335
+ failed.add(fn12);
1336
+ notMutated.push({ file: fn12.file, functionName: fn12.name, span: fn12.span, reason: step.value });
1337
+ return { fn: fn12, generated: [] };
1258
1338
  }
1259
- return { fn: fn11, generated };
1339
+ return { fn: fn12, generated };
1260
1340
  } catch (error3) {
1261
- failed.add(fn11);
1341
+ failed.add(fn12);
1262
1342
  notMutated.push({
1263
- file: fn11.file,
1264
- functionName: fn11.name,
1265
- span: fn11.span,
1343
+ file: fn12.file,
1344
+ functionName: fn12.name,
1345
+ span: fn12.span,
1266
1346
  reason: `analysis failed: ${error3 instanceof Error ? error3.message : String(error3)}`
1267
1347
  });
1268
- return { fn: fn11, generated: [] };
1348
+ return { fn: fn12, generated: [] };
1269
1349
  }
1270
1350
  });
1271
- for (const { fn: fn11, generated } of generatedFunctions) {
1272
- if (failed.has(fn11)) continue;
1351
+ for (const { fn: fn12, generated } of generatedFunctions) {
1352
+ if (failed.has(fn12)) continue;
1273
1353
  {
1274
- const reasons = [...fn11.notices ?? []];
1275
- if (!generated.length && !reasons.length) reasons.push(fn11.skipReason ?? `return not synthesizable (type ${fn11.displayReturnType})`);
1276
- const innerMutated = !generated.length && generatedFunctions.some(({ fn: inner, generated: generated2 }) => inner.file === fn11.file && inner.startOffset > fn11.startOffset && inner.endOffset < fn11.endOffset && generated2.length > 0);
1354
+ const reasons = [...fn12.notices ?? []];
1355
+ if (!generated.length && !reasons.length) reasons.push(fn12.skipReason ?? `return not synthesizable (type ${fn12.displayReturnType})`);
1356
+ const innerMutated = !generated.length && generatedFunctions.some(({ fn: inner, generated: generated2 }) => inner.file === fn12.file && inner.startOffset > fn12.startOffset && inner.endOffset < fn12.endOffset && generated2.length > 0);
1277
1357
  if (innerMutated && !generated.length) {
1278
1358
  for (let i = 0; i < reasons.length; i++) if (reasons[i].startsWith("return not synthesizable")) reasons[i] += "; inner functions mutated";
1279
1359
  }
1280
- if (reasons.length) notMutated.push({ file: fn11.file, functionName: fn11.name, span: fn11.span, reason: [...new Set(reasons)].join("; ") });
1360
+ if (reasons.length) notMutated.push({ file: fn12.file, functionName: fn12.name, span: fn12.span, reason: [...new Set(reasons)].join("; ") });
1281
1361
  }
1282
1362
  mutants.push(...generated);
1283
1363
  }
@@ -1289,9 +1369,9 @@ function makeMutantSource(oracle) {
1289
1369
  }
1290
1370
  });
1291
1371
  return {
1292
- notMutated: (config) => discover(config).pipe(Effect.map((result5) => result5.notMutated)),
1293
- generate: (config) => Stream.unwrap(discover(config).pipe(Effect.map((result5) => Stream.fromIterable(result5.mutants)))),
1294
- checkViable: (mutant) => Effect.sync(() => {
1372
+ notMutated: (config) => discover(config).pipe(Effect2.map((result5) => result5.notMutated)),
1373
+ generate: (config) => Stream.unwrap(discover(config).pipe(Effect2.map((result5) => Stream.fromIterable(result5.mutants)))),
1374
+ checkViable: (mutant) => Effect2.sync(() => {
1295
1375
  try {
1296
1376
  return oracle.checkViable(mutant);
1297
1377
  } catch (error3) {
@@ -1307,11 +1387,15 @@ function makeMutantSource(oracle) {
1307
1387
  }
1308
1388
 
1309
1389
  // packages/runner/src/Scratch.ts
1310
- import * as Effect2 from "effect/Effect";
1390
+ import * as Effect3 from "effect/Effect";
1311
1391
  import * as Console from "effect/Console";
1312
1392
  import * as FileSystem from "effect/FileSystem";
1313
1393
  import * as Layer2 from "effect/Layer";
1314
- import * as Path from "effect/Path";
1394
+ import * as Path3 from "effect/Path";
1395
+ import * as ChildProcess from "effect/process/ChildProcess";
1396
+ import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
1397
+ import * as Stream2 from "effect/Stream";
1398
+ import * as Schema5 from "effect/Schema";
1315
1399
 
1316
1400
  // packages/runner/src/Poison.ts
1317
1401
  function prologueEnd(source) {
@@ -1373,46 +1457,186 @@ throw new Error(${JSON.stringify(token)});
1373
1457
  }
1374
1458
 
1375
1459
  // packages/runner/src/Scratch.ts
1376
- var ScratchLive = Layer2.effect(Scratch, Effect2.gen(function* () {
1460
+ var ScratchLive = Layer2.effect(Scratch, Effect3.gen(function* () {
1377
1461
  const fs = yield* FileSystem.FileSystem;
1378
- const path = yield* Path.Path;
1462
+ const path = yield* Path3.Path;
1463
+ const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
1379
1464
  const failure = (operation, location, error3) => new ScratchError({ operation, path: location, message: error3.message });
1380
- const skipVanished = (from, to) => (effect5) => effect5.pipe(Effect2.catch((error3) => {
1381
- if (error3._tag !== "PlatformError" || error3.reason._tag !== "NotFound") return Effect2.fail(error3);
1382
- return Effect2.gen(function* () {
1383
- const entry = yield* fs.lstat(from).pipe(Effect2.result);
1384
- if (entry._tag === "Success") return yield* Effect2.fail(error3);
1385
- if (entry.failure.reason._tag !== "NotFound") return yield* Effect2.fail(entry.failure);
1465
+ const skipVanished = (from, to) => (effect5) => effect5.pipe(Effect3.catch((error3) => {
1466
+ if (error3._tag !== "PlatformError" || error3.reason._tag !== "NotFound") return Effect3.fail(error3);
1467
+ return Effect3.gen(function* () {
1468
+ const entry = yield* fs.lstat(from).pipe(Effect3.result);
1469
+ if (entry._tag === "Success") {
1470
+ if (entry.success.type !== "SymbolicLink") return yield* Effect3.fail(error3);
1471
+ const target = yield* fs.stat(from).pipe(Effect3.result);
1472
+ if (target._tag === "Success") return yield* Effect3.fail(error3);
1473
+ if (target.failure.reason._tag !== "NotFound") return yield* Effect3.fail(target.failure);
1474
+ yield* Console.warn(`Warning: scratch copy skipped a dangling symlink: ${from}`);
1475
+ } else if (entry.failure.reason._tag !== "NotFound") return yield* Effect3.fail(entry.failure);
1386
1476
  yield* fs.remove(to, { recursive: true, force: true });
1387
- yield* Effect2.logDebug("Scratch copy skipped a vanished source", { source: from });
1477
+ yield* Effect3.logDebug("Scratch copy skipped a vanished source", { source: from });
1388
1478
  });
1389
1479
  }));
1390
- return Scratch.of({
1391
- acquire: Effect2.fn("Scratch.acquire")(function* (root) {
1392
- const source = path.resolve(root);
1393
- let copyRoot = source;
1394
- let ancestor = source;
1395
- while (true) {
1396
- if ((yield* fs.exists(path.join(ancestor, "pnpm-workspace.yaml"))) || (yield* fs.exists(path.join(ancestor, ".git")))) {
1397
- copyRoot = ancestor;
1398
- break;
1480
+ const discover = Effect3.fn("Scratch.discover")(function* (root) {
1481
+ let source = path.resolve(root);
1482
+ let copyRoot = source;
1483
+ let ancestor = source;
1484
+ while (true) {
1485
+ if ((yield* fs.exists(path.join(ancestor, "pnpm-workspace.yaml"))) || (yield* fs.exists(path.join(ancestor, ".git")))) {
1486
+ copyRoot = ancestor;
1487
+ break;
1488
+ }
1489
+ const parent = path.dirname(ancestor);
1490
+ if (parent === ancestor) break;
1491
+ ancestor = parent;
1492
+ }
1493
+ const git2 = (args, cwd = source) => Effect3.scoped(Effect3.gen(function* () {
1494
+ const env = { ...process.env };
1495
+ for (const key of ["GIT_DIR", "GIT_WORK_TREE", "GIT_INDEX_FILE"]) delete env[key];
1496
+ const child = yield* spawner.spawn(ChildProcess.make("git", ["-C", cwd, ...args], { stdin: "ignore", env, extendEnv: false }));
1497
+ const [code, output] = yield* Effect3.all([child.exitCode, child.stdout.pipe(Stream2.decodeText(), Stream2.mkString), child.stderr.pipe(Stream2.runDrain)], { concurrency: "unbounded" });
1498
+ return { code, output };
1499
+ }));
1500
+ let gitAncestor = source;
1501
+ let inRepository = false;
1502
+ while (true) {
1503
+ if (yield* fs.exists(path.join(gitAncestor, ".git"))) {
1504
+ inRepository = true;
1505
+ break;
1506
+ }
1507
+ const parent = path.dirname(gitAncestor);
1508
+ if (parent === gitAncestor) break;
1509
+ gitAncestor = parent;
1510
+ }
1511
+ let selected;
1512
+ let directories;
1513
+ const linked = /* @__PURE__ */ new Set();
1514
+ const unreadable = /* @__PURE__ */ new Set();
1515
+ const ignoredRoots = /* @__PURE__ */ new Set();
1516
+ const pruneUnreadable = (location) => Effect3.gen(function* () {
1517
+ unreadable.add(location);
1518
+ yield* Console.warn(`Warning: scratch copy skipped an unreadable ignored tree: ${location}`);
1519
+ });
1520
+ const originalSource = source;
1521
+ const originalCopyRoot = copyRoot;
1522
+ if (inRepository) yield* Effect3.gen(function* () {
1523
+ const repository = yield* git2(["rev-parse", "--show-toplevel"]);
1524
+ if (repository.code !== 0) return yield* new ScratchError({ operation: "git rev-parse", path: source, message: `Git exited ${repository.code}` });
1525
+ source = yield* fs.realPath(source);
1526
+ copyRoot = path.resolve(repository.output.trim());
1527
+ const files = yield* git2(["ls-files", "--cached", "--others", "--exclude-standard", "--full-name", "-z"], copyRoot).pipe(Effect3.mapError((error3) => failure("git", source, error3)));
1528
+ if (files.code !== 0) return yield* Effect3.fail(new ScratchError({ operation: "git ls-files", path: source, message: `Git exited ${files.code}` }));
1529
+ selected = new Set(files.output.split("\0").filter(Boolean).map((file) => path.resolve(copyRoot, file)));
1530
+ const ignored = yield* git2(["ls-files", "--others", "--ignored", "--exclude-standard", "--directory", "-z"], copyRoot);
1531
+ if (ignored.code !== 0) return yield* new ScratchError({ operation: "git ls-files", path: source, message: `Git exited ${ignored.code}` });
1532
+ const independent = (dir) => Effect3.gen(function* () {
1533
+ if ((yield* fs.exists(path.join(dir, ".git"))) || (yield* fs.exists(path.join(dir, "node_modules")))) return true;
1534
+ for (const name of yield* fs.readDirectory(dir)) {
1535
+ const child = path.join(dir, name);
1536
+ const info = yield* fs.lstat(child).pipe(Effect3.result);
1537
+ if (info._tag === "Failure") {
1538
+ if (info.failure.reason._tag === "PermissionDenied") {
1539
+ yield* pruneUnreadable(child);
1540
+ continue;
1541
+ }
1542
+ return yield* info.failure;
1543
+ }
1544
+ if (info.success.type === "Directory" && (yield* independent(child))) return true;
1545
+ }
1546
+ return false;
1547
+ }).pipe(Effect3.catch((error3) => error3.reason._tag === "PermissionDenied" ? pruneUnreadable(dir).pipe(Effect3.as(false)) : Effect3.fail(error3)));
1548
+ for (const file of ignored.output.split("\0").filter(Boolean)) {
1549
+ const target = path.resolve(copyRoot, file);
1550
+ if (path.relative(copyRoot, target).split(path.sep).some((part) => ["node_modules", ".git", "mutants.out", ".agent_sources", ".agent-sources", ".brain", ".pi", ".rift"].includes(part))) continue;
1551
+ ignoredRoots.add(target);
1552
+ const info = yield* fs.lstat(target).pipe(Effect3.result);
1553
+ if (info._tag === "Failure") {
1554
+ if (info.failure.reason._tag === "NotFound") continue;
1555
+ if (info.failure.reason._tag === "PermissionDenied") {
1556
+ yield* pruneUnreadable(target);
1557
+ continue;
1558
+ }
1559
+ return yield* info.failure;
1560
+ }
1561
+ if (info.success.type !== "Directory") {
1562
+ selected.add(target);
1563
+ continue;
1564
+ }
1565
+ if (yield* independent(target)) linked.add(target);
1566
+ else selected.add(target);
1567
+ }
1568
+ const PackageEntries = Schema5.fromJsonString(Schema5.Struct({
1569
+ exports: Schema5.optional(Schema5.Unknown),
1570
+ imports: Schema5.optional(Schema5.Unknown),
1571
+ main: Schema5.optional(Schema5.String),
1572
+ module: Schema5.optional(Schema5.String),
1573
+ types: Schema5.optional(Schema5.String)
1574
+ }));
1575
+ const targets = (entry) => typeof entry === "string" ? [entry] : Array.isArray(entry) ? entry.flatMap(targets) : entry !== null && typeof entry === "object" ? Object.values(entry).flatMap(targets) : [];
1576
+ for (const file of [...selected]) {
1577
+ if (path.basename(file) !== "package.json" || !(yield* fs.exists(file))) continue;
1578
+ const decoded = yield* Schema5.decodeEffect(PackageEntries)(yield* fs.readFileString(file)).pipe(Effect3.result);
1579
+ if (decoded._tag === "Failure") {
1580
+ yield* Console.warn(`Warning: cannot inspect package entry points for scratch copying: ${file}`);
1581
+ continue;
1582
+ }
1583
+ const pkg = decoded.success;
1584
+ const root2 = path.dirname(file);
1585
+ const entries = [...targets(pkg.exports), ...targets(pkg.imports)].filter((entry) => entry.startsWith("./"));
1586
+ entries.push(...[pkg.main, pkg.module, pkg.types].filter((entry) => entry !== void 0));
1587
+ for (const entry of entries) {
1588
+ const relative2 = path.relative(root2, path.resolve(root2, entry));
1589
+ if (!relative2 || relative2 === ".." || relative2.startsWith(`..${path.sep}`) || path.isAbsolute(relative2)) continue;
1590
+ const first = relative2.split(path.sep)[0];
1591
+ if (!["node_modules", ".git"].includes(first)) selected.add(path.join(root2, first));
1399
1592
  }
1400
- const parent = path.dirname(ancestor);
1401
- if (parent === ancestor) break;
1402
- ancestor = parent;
1403
1593
  }
1404
- const temp = yield* Effect2.acquireRelease(
1594
+ directories = /* @__PURE__ */ new Set([copyRoot]);
1595
+ for (const file of [...selected, ...linked]) {
1596
+ let parent = path.dirname(file);
1597
+ while (parent !== copyRoot && parent !== path.dirname(parent)) {
1598
+ directories.add(parent);
1599
+ parent = path.dirname(parent);
1600
+ }
1601
+ }
1602
+ }).pipe(Effect3.catch((error3) => Effect3.gen(function* () {
1603
+ yield* Console.warn(`Warning: Git scratch discovery failed; using recursive copy: ${error3.message}`);
1604
+ source = originalSource;
1605
+ copyRoot = originalCopyRoot;
1606
+ selected = void 0;
1607
+ directories = void 0;
1608
+ linked.clear();
1609
+ unreadable.clear();
1610
+ ignoredRoots.clear();
1611
+ })));
1612
+ const linkedRoots = () => [...linked].filter((root2) => !selected?.has(root2) && !unreadable.has(root2)).map((root2) => path.relative(source, root2)).filter((root2) => root2 !== ".." && !root2.startsWith(`..${path.sep}`) && !path.isAbsolute(root2));
1613
+ return { source, copyRoot, selected, directories, linked, unreadable, ignoredRoots, pruneUnreadable, linkedRoots };
1614
+ }, (effect5, root) => effect5.pipe(Effect3.mapError((error3) => failure("discover", root, error3))));
1615
+ return Scratch.of({
1616
+ inspect: Effect3.fn("Scratch.inspect")(function* (root) {
1617
+ return (yield* discover(root)).linkedRoots();
1618
+ }),
1619
+ acquire: Effect3.fn("Scratch.acquire")(function* (root) {
1620
+ const plan = yield* discover(root);
1621
+ const { source, copyRoot, selected, directories, linked, unreadable, ignoredRoots, pruneUnreadable } = plan;
1622
+ const skipUnreadable = (from, to, enabled) => (effect5) => effect5.pipe(Effect3.catch((error3) => enabled && error3._tag === "PlatformError" && error3.reason._tag === "PermissionDenied" && error3.reason.pathOrDescriptor === from && ["access", "realPath", "stat", "lstat", "readDirectory"].includes(error3.reason.method) ? pruneUnreadable(from).pipe(Effect3.andThen(fs.remove(to, { recursive: true, force: true }))) : Effect3.fail(error3)));
1623
+ const temp = yield* Effect3.acquireRelease(
1405
1624
  fs.makeTempDirectory({ prefix: "mutant-cafe-" }).pipe(
1406
- Effect2.mapError((error3) => failure("create", source, error3))
1625
+ Effect3.mapError((error3) => failure("create", source, error3))
1407
1626
  ),
1408
- (dir2) => fs.remove(dir2, { recursive: true, force: true }).pipe(Effect2.interruptible, Effect2.timeout(3e4), Effect2.catch((error3) => Console.warn(`Warning: scratch removal did not complete within its cleanup budget: ${error3.message}`, { path: dir2 })))
1627
+ (dir2) => fs.remove(dir2, { recursive: true, force: true }).pipe(Effect3.interruptible, Effect3.timeout(3e4), Effect3.catch((error3) => Console.warn(`Warning: scratch removal did not complete within its cleanup budget: ${error3.message}`, { path: dir2 })))
1409
1628
  );
1410
- const copy = (from, to, ancestors) => Effect2.gen(function* () {
1629
+ const copy = (from, to, ancestors, filter = true, ignored = false) => Effect3.gen(function* () {
1630
+ if (unreadable.has(from)) return;
1631
+ if (linked.has(from) && !selected?.has(from)) {
1632
+ yield* fs.symlink(from, to);
1633
+ return;
1634
+ }
1411
1635
  const real = yield* fs.realPath(from);
1412
1636
  const info = yield* fs.stat(from);
1413
1637
  if (info.type === "Directory") {
1414
1638
  if (ancestors.includes(real)) {
1415
- return yield* Effect2.fail(new ScratchError({ operation: "copy", path: from, message: "Cyclic directory symlink" }));
1639
+ return yield* Effect3.fail(new ScratchError({ operation: "copy", path: from, message: "Cyclic directory symlink" }));
1416
1640
  }
1417
1641
  yield* fs.makeDirectory(to, { recursive: true });
1418
1642
  const entries = yield* fs.readDirectory(from);
@@ -1420,84 +1644,92 @@ var ScratchLive = Layer2.effect(Scratch, Effect2.gen(function* () {
1420
1644
  if ([".git", "mutants.out", ".agent_sources", ".agent-sources", ".brain", ".pi", ".rift"].includes(entry)) continue;
1421
1645
  const src = path.join(from, entry);
1422
1646
  const dest = path.join(to, entry);
1647
+ const filterChildren = filter && !selected?.has(from);
1648
+ if (filterChildren && selected && directories && !selected.has(src) && !directories.has(src) && !linked.has(src) && entry !== "node_modules") continue;
1423
1649
  if (entry === "node_modules") {
1424
- const linkDependencies = (from2, to2) => Effect2.gen(function* () {
1650
+ const linkDependencies = (from2, to2, ignored2) => Effect3.gen(function* () {
1425
1651
  yield* fs.makeDirectory(to2, { recursive: true });
1426
1652
  for (const name of yield* fs.readDirectory(from2)) {
1427
1653
  if ([".vite", ".vite-temp", ".vitest", ".cache"].includes(name)) continue;
1428
1654
  const dependency = path.join(from2, name);
1429
1655
  const destination = path.join(to2, name);
1430
- yield* Effect2.gen(function* () {
1656
+ yield* Effect3.gen(function* () {
1431
1657
  if (name.startsWith("@")) {
1432
- yield* linkDependencies(dependency, destination);
1658
+ yield* linkDependencies(dependency, destination, ignored2);
1433
1659
  return;
1434
1660
  }
1435
1661
  const realDependency = yield* fs.realPath(dependency);
1436
1662
  const rel = path.relative(copyRoot, realDependency);
1437
- const inside = rel !== ".." && !rel.startsWith(`..${path.sep}`) && !path.isAbsolute(rel) && !rel.split(path.sep).includes("node_modules");
1663
+ const inside = rel !== ".." && !rel.startsWith(`..${path.sep}`) && !path.isAbsolute(rel) && !rel.split(path.sep).includes("node_modules") && (!selected || selected.has(realDependency) || directories?.has(realDependency));
1438
1664
  yield* fs.symlink(inside ? path.join(temp, rel) : realDependency, destination);
1439
- }).pipe(skipVanished(dependency, destination));
1665
+ }).pipe(skipVanished(dependency, destination), skipUnreadable(dependency, destination, ignored2));
1440
1666
  }
1441
1667
  });
1442
- yield* linkDependencies(src, dest).pipe(skipVanished(src, dest));
1668
+ yield* linkDependencies(src, dest, ignored || ignoredRoots.has(from)).pipe(skipVanished(src, dest), skipUnreadable(src, dest, ignored || ignoredRoots.has(from)));
1443
1669
  } else {
1444
- yield* copy(src, dest, [...ancestors, real]);
1670
+ yield* copy(src, dest, [...ancestors, real], filterChildren, ignored || ignoredRoots.has(from));
1445
1671
  }
1446
1672
  }
1447
1673
  } else if (info.type === "File") {
1674
+ if (ignored || ignoredRoots.has(from)) yield* fs.access(from, { readable: true });
1448
1675
  yield* fs.copyFile(from, to);
1449
1676
  }
1450
- }).pipe(skipVanished(from, to), Effect2.mapError((error3) => failure("copy", from, error3)));
1677
+ }).pipe(skipVanished(from, to), skipUnreadable(from, to, ignored || ignoredRoots.has(from)), Effect3.mapError((error3) => failure("copy", from, error3)));
1451
1678
  yield* copy(copyRoot, temp, []);
1452
1679
  const packageRoot = yield* fs.realPath(path.join(temp, path.relative(copyRoot, source))).pipe(
1453
- Effect2.mapError((error3) => failure("resolve", source, error3))
1680
+ Effect3.mapError((error3) => failure("resolve", source, error3))
1454
1681
  );
1682
+ const packageRelative = path.relative(yield* fs.realPath(temp), packageRoot);
1683
+ if (packageRelative === ".." || packageRelative.startsWith(`..${path.sep}`) || path.isAbsolute(packageRelative)) {
1684
+ return yield* new ScratchError({ operation: "resolve", path: source, message: "Requested package is inside a linked ignored tree; refusing to mutate the original checkout. Choose an editable source package outside that tree." });
1685
+ }
1455
1686
  const originals = /* @__PURE__ */ new Map();
1456
- const target = (mutant) => Effect2.gen(function* () {
1687
+ const target = (mutant) => Effect3.gen(function* () {
1457
1688
  const relative2 = path.isAbsolute(mutant.file) ? path.relative(source, mutant.file) : mutant.file;
1458
1689
  const location = path.resolve(packageRoot, relative2);
1459
1690
  const rel = path.relative(packageRoot, location);
1460
1691
  if (rel === "" || rel === ".." || rel.startsWith(`..${path.sep}`) || path.isAbsolute(rel) || rel.split(path.sep).includes("node_modules")) {
1461
- return yield* Effect2.fail(new ScratchError({ operation: "resolve", path: mutant.file, message: "Mutant file must be inside the copied source tree" }));
1692
+ return yield* Effect3.fail(new ScratchError({ operation: "resolve", path: mutant.file, message: "Mutant file must be inside the copied source tree" }));
1462
1693
  }
1463
- const real = yield* fs.realPath(location).pipe(Effect2.mapError((error3) => failure("resolve", location, error3)));
1694
+ const real = yield* fs.realPath(location).pipe(Effect3.mapError((error3) => failure("resolve", location, error3)));
1464
1695
  const realRelative = path.relative(packageRoot, real);
1465
1696
  if (realRelative === ".." || realRelative.startsWith(`..${path.sep}`) || path.isAbsolute(realRelative)) {
1466
- return yield* Effect2.fail(new ScratchError({ operation: "resolve", path: mutant.file, message: "Mutant file resolves outside the scratch package" }));
1697
+ return yield* Effect3.fail(new ScratchError({ operation: "resolve", path: mutant.file, message: "Mutant file resolves outside the scratch package" }));
1467
1698
  }
1468
1699
  return location;
1469
1700
  });
1470
1701
  const dir = {
1471
1702
  path: packageRoot,
1472
- apply: Effect2.fn("Scratch.apply")(function* (mutant) {
1703
+ linkedRoots: plan.linkedRoots(),
1704
+ apply: Effect3.fn("Scratch.apply")(function* (mutant) {
1473
1705
  const location = yield* target(mutant);
1474
1706
  const bytes = yield* fs.readFile(location);
1475
1707
  originals.set(location, bytes);
1476
1708
  const original = new TextDecoder("utf-8", { ignoreBOM: true }).decode(bytes);
1477
1709
  const { startOffset, endOffset, text } = mutant.replacement;
1478
1710
  if (startOffset < 0 || endOffset < startOffset || endOffset > original.length) {
1479
- return yield* Effect2.fail(new ScratchError({ operation: "apply", path: location, message: "Replacement offsets are outside the file" }));
1711
+ return yield* Effect3.fail(new ScratchError({ operation: "apply", path: location, message: "Replacement offsets are outside the file" }));
1480
1712
  }
1481
1713
  yield* fs.writeFileString(location, original.slice(0, startOffset) + text + original.slice(endOffset));
1482
- }, (effect5, mutant) => effect5.pipe(Effect2.mapError((error3) => failure("apply", mutant.file, error3)))),
1483
- poison: Effect2.fn("Scratch.poison")(function* (mutant, signal, token) {
1714
+ }, (effect5, mutant) => effect5.pipe(Effect3.mapError((error3) => failure("apply", mutant.file, error3)))),
1715
+ poison: Effect3.fn("Scratch.poison")(function* (mutant, signal, token) {
1484
1716
  const location = yield* target(mutant);
1485
- const bytes = yield* fs.readFile(location).pipe(Effect2.mapError((error3) => failure("probe", location, error3)));
1717
+ const bytes = yield* fs.readFile(location).pipe(Effect3.mapError((error3) => failure("probe", location, error3)));
1486
1718
  const original = new TextDecoder("utf-8", { ignoreBOM: true }).decode(bytes);
1487
1719
  const insertion = poisonInsertion(original, signal, token);
1488
1720
  yield* dir.apply({ ...mutant, replacement: { startOffset: insertion.offset, endOffset: insertion.offset, text: insertion.text } });
1489
1721
  }),
1490
- revert: Effect2.fn("Scratch.revert")(function* (mutant) {
1722
+ revert: Effect3.fn("Scratch.revert")(function* (mutant) {
1491
1723
  const location = yield* target(mutant);
1492
1724
  const bytes = originals.get(location);
1493
1725
  if (bytes !== void 0) {
1494
1726
  yield* fs.writeFile(location, bytes);
1495
1727
  originals.delete(location);
1496
1728
  }
1497
- }, (effect5, mutant) => effect5.pipe(Effect2.mapError((error3) => failure("revert", mutant.file, error3))))
1729
+ }, (effect5, mutant) => effect5.pipe(Effect3.mapError((error3) => failure("revert", mutant.file, error3))))
1498
1730
  };
1499
1731
  return dir;
1500
- }, (effect5, root) => effect5.pipe(Effect2.mapError((error3) => error3._tag === "ScratchError" ? error3 : failure("acquire", root, error3))))
1732
+ }, (effect5, root) => effect5.pipe(Effect3.mapError((error3) => error3._tag === "ScratchError" ? error3 : failure("acquire", root, error3))))
1501
1733
  });
1502
1734
  }));
1503
1735
 
@@ -1506,11 +1738,11 @@ import * as Clock4 from "effect/Clock";
1506
1738
  import * as Console4 from "effect/Console";
1507
1739
 
1508
1740
  // packages/runner/src/Preflight.ts
1509
- import * as Effect4 from "effect/Effect";
1741
+ import * as Effect5 from "effect/Effect";
1510
1742
  import * as Clock2 from "effect/Clock";
1511
- import * as Schema6 from "effect/Schema";
1512
- import * as ChildProcess from "effect/process/ChildProcess";
1513
- import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
1743
+ import * as Schema7 from "effect/Schema";
1744
+ import * as ChildProcess2 from "effect/process/ChildProcess";
1745
+ import * as ChildProcessSpawner3 from "effect/process/ChildProcessSpawner";
1514
1746
 
1515
1747
  // packages/runner/src/ProcessTree.ts
1516
1748
  import { createEffectActor, createEffectLogic, join, send, setupEffect } from "@xstate/effect";
@@ -1531,10 +1763,10 @@ const traceProcess = (stage, details = {}) => {
1531
1763
  import * as Console2 from "effect/Console";
1532
1764
  import * as Clock from "effect/Clock";
1533
1765
  import * as Context2 from "effect/Context";
1534
- import * as Effect3 from "effect/Effect";
1766
+ import * as Effect4 from "effect/Effect";
1535
1767
  import * as FileSystem3 from "effect/FileSystem";
1536
1768
  import * as Result from "effect/Result";
1537
- import * as Schema5 from "effect/Schema";
1769
+ import * as Schema6 from "effect/Schema";
1538
1770
  import * as Semaphore from "effect/Semaphore";
1539
1771
  import { execFile } from "node:child_process";
1540
1772
  import { promisify } from "node:util";
@@ -1542,11 +1774,11 @@ import { randomUUID } from "node:crypto";
1542
1774
  import { pathToFileURL } from "node:url";
1543
1775
  var execute = promisify(execFile);
1544
1776
  var liveLedgers = /* @__PURE__ */ new Set();
1545
- var ProcessInspector = Context2.Reference("mutant.cafe/ProcessInspector", { defaultValue: () => ({ inspect: (args) => Effect3.tryPromise({
1777
+ var ProcessInspector = Context2.Reference("mutant.cafe/ProcessInspector", { defaultValue: () => ({ inspect: (args) => Effect4.tryPromise({
1546
1778
  try: (signal) => execute("/bin/ps", [...args], { signal, encoding: "utf8", maxBuffer: 32 * 1024 * 1024, timeout: 2e3, env: { PATH: process.env.PATH, LC_ALL: "C", TZ: "UTC" } }),
1547
1779
  catch: () => new TestSpawnError({ command: ["ps"], message: "Cannot inspect owned test processes" })
1548
1780
  }) }) });
1549
- var PartialCwd = Schema5.Struct({ code: Schema5.Literal(1), stdout: Schema5.String, signal: Schema5.optional(Schema5.Null), killed: Schema5.optional(Schema5.Literal(false)) });
1781
+ var PartialCwd = Schema6.Struct({ code: Schema6.Literal(1), stdout: Schema6.String, signal: Schema6.optional(Schema6.Null), killed: Schema6.optional(Schema6.Literal(false)) });
1550
1782
  var inspectScratchCwd = (pids, probe2 = {
1551
1783
  live: (pid) => {
1552
1784
  if (pid <= 0) return false;
@@ -1558,7 +1790,7 @@ var inspectScratchCwd = (pids, probe2 = {
1558
1790
  }
1559
1791
  },
1560
1792
  read: (pids2, signal) => execute("/usr/sbin/lsof", ["-b", "-w", "-n", "-P", "-a", "-d", "cwd", "-p", pids2.join(","), "-Fpn"], { signal, encoding: "utf8", timeout: 2e3, maxBuffer: 32 * 1024 * 1024, env: { PATH: process.env.PATH, LC_ALL: "C" } })
1561
- }) => Effect3.tryPromise({
1793
+ }) => Effect4.tryPromise({
1562
1794
  // @effect-diagnostics-next-line asyncFunction:off -- Native execFile adapter preserves partial stdout while Effect supplies cancellation.
1563
1795
  try: async (signal) => {
1564
1796
  const live2 = pids.filter(probe2.live);
@@ -1566,7 +1798,7 @@ var inspectScratchCwd = (pids, probe2 = {
1566
1798
  try {
1567
1799
  return await probe2.read(live2, signal);
1568
1800
  } catch (error3) {
1569
- const partial = Schema5.decodeUnknownOption(PartialCwd)(error3);
1801
+ const partial = Schema6.decodeUnknownOption(PartialCwd)(error3);
1570
1802
  if (partial._tag === "Some") return { stdout: partial.value.stdout };
1571
1803
  throw error3;
1572
1804
  }
@@ -1664,20 +1896,20 @@ for (const name of ["spawn", "fork", "execFile", "exec"]) {
1664
1896
  syncBuiltinESMExports();
1665
1897
  }
1666
1898
  `;
1667
- var Record2 = Schema5.Struct({ pid: Schema5.Int, birth: Schema5.String });
1668
- var acquireProcessTree = Effect3.fn("ProcessTree.acquire")(function* (scratch, onBackstop, processesSince) {
1899
+ var Record2 = Schema6.Struct({ pid: Schema6.Int, birth: Schema6.String });
1900
+ var acquireProcessTree = Effect4.fn("ProcessTree.acquire")(function* (scratch, onBackstop, processesSince) {
1669
1901
  const fs = yield* FileSystem3.FileSystem;
1670
1902
  const directory = yield* fs.makeTempDirectory({ prefix: "mutant-processes-" });
1671
1903
  const ledger = `${directory}/pids.jsonl`;
1672
1904
  const script = `${directory}/register.mjs`;
1673
- const token = yield* Effect3.sync(randomUUID);
1905
+ const token = yield* Effect4.sync(randomUUID);
1674
1906
  const url = pathToFileURL(script).href;
1675
1907
  yield* fs.writeFileString(ledger, "");
1676
1908
  yield* fs.writeFileString(script, preloadSource);
1677
1909
  liveLedgers.add(ledger);
1678
1910
  const trace = (stage, details = {}) => {
1679
1911
  const destination = process.env.MUTANT_CAFE_PROCESS_TRACE;
1680
- return destination ? Clock.currentTimeMillis.pipe(Effect3.flatMap((at) => fs.writeFileString(destination, JSON.stringify({ at, pid: process.pid, ppid: process.ppid, stage, ...details }) + "\n", { flag: "a" })), Effect3.timeout(100), Effect3.catch(() => Effect3.void)) : Effect3.void;
1912
+ return destination ? Clock.currentTimeMillis.pipe(Effect4.flatMap((at) => fs.writeFileString(destination, JSON.stringify({ at, pid: process.pid, ppid: process.ppid, stage, ...details }) + "\n", { flag: "a" })), Effect4.timeout(100), Effect4.catch(() => Effect4.void)) : Effect4.void;
1681
1913
  };
1682
1914
  const roots = /* @__PURE__ */ new Set();
1683
1915
  const command = ["vitest", "process-cleanup"];
@@ -1690,19 +1922,19 @@ var acquireProcessTree = Effect3.fn("ProcessTree.acquire")(function* (scratch, o
1690
1922
  const kill = inspector.signal ?? ((pid, signal2) => {
1691
1923
  process.kill(pid, signal2);
1692
1924
  });
1693
- const bounded = (phase, effect5, limit = 7e3) => Effect3.suspend(() => {
1925
+ const bounded = (phase, effect5, limit = 7e3) => Effect4.suspend(() => {
1694
1926
  const remaining = Math.min(limit, deadline - performance.now());
1695
- if (remaining <= 0) return Effect3.fail(new TestSpawnError({ command, message: `Cleanup deadline exceeded during ${phase}` }));
1696
- return effect5.pipe(Effect3.interruptible, Effect3.timeout(remaining), Effect3.mapError(() => new TestSpawnError({ command, message: `Cleanup ${phase} failed or exceeded its ${Math.ceil(remaining)} ms budget` })));
1927
+ if (remaining <= 0) return Effect4.fail(new TestSpawnError({ command, message: `Cleanup deadline exceeded during ${phase}` }));
1928
+ return effect5.pipe(Effect4.interruptible, Effect4.timeout(remaining), Effect4.mapError(() => new TestSpawnError({ command, message: `Cleanup ${phase} failed or exceeded its ${Math.ceil(remaining)} ms budget` })));
1697
1929
  });
1698
- const inspect = (args) => bounded("ps inspection", Effect3.gen(function* () {
1930
+ const inspect = (args) => bounded("ps inspection", Effect4.gen(function* () {
1699
1931
  const began = performance.now();
1700
1932
  yield* trace("inspect-start", { operation: args[0] ?? "ps" });
1701
1933
  const result5 = yield* inspector.inspect(args);
1702
1934
  yield* trace("inspect-done", { elapsedMs: performance.now() - began });
1703
1935
  return result5;
1704
1936
  }), 2e3);
1705
- const snapshot = Effect3.gen(function* () {
1937
+ const snapshot = Effect4.gen(function* () {
1706
1938
  const result5 = yield* inspect(["-A", "-ww", "-o", "pid=,ppid=,pgid=,stat=,lstart=,args="]);
1707
1939
  const found = /* @__PURE__ */ new Map();
1708
1940
  for (const line of result5.stdout.split("\n")) {
@@ -1715,10 +1947,10 @@ var acquireProcessTree = Effect3.fn("ProcessTree.acquire")(function* (scratch, o
1715
1947
  lastSnapshot = found;
1716
1948
  return found;
1717
1949
  });
1718
- const discover = (preserved, retained) => Effect3.gen(function* () {
1719
- const registered = yield* fs.readFileString(ledger).pipe(Effect3.mapError(() => new TestSpawnError({ command, message: "Cannot read the test process ownership ledger" })));
1950
+ const discover = (preserved, retained) => Effect4.gen(function* () {
1951
+ const registered = yield* fs.readFileString(ledger).pipe(Effect4.mapError(() => new TestSpawnError({ command, message: "Cannot read the test process ownership ledger" })));
1720
1952
  ledgerRows = registered.split("\n").flatMap((line) => {
1721
- const parsed = Schema5.decodeOption(Schema5.fromJsonString(Record2))(line);
1953
+ const parsed = Schema6.decodeOption(Schema6.fromJsonString(Record2))(line);
1722
1954
  return parsed._tag === "Some" ? [parsed.value] : [];
1723
1955
  });
1724
1956
  const table = yield* snapshot;
@@ -1754,9 +1986,9 @@ var acquireProcessTree = Effect3.fn("ProcessTree.acquire")(function* (scratch, o
1754
1986
  for (const item of ledgerRows) if (table.get(item.pid)?.birth === item.birth) claim(item.pid);
1755
1987
  closeDescendants();
1756
1988
  if (process.platform === "linux") {
1757
- yield* Effect3.forEach([...table.keys()], (pid) => fs.readFileString(`/proc/${pid}/environ`).pipe(
1758
- Effect3.catch(() => Effect3.succeed("")),
1759
- Effect3.tap((environment) => Effect3.sync(() => {
1989
+ yield* Effect4.forEach([...table.keys()], (pid) => fs.readFileString(`/proc/${pid}/environ`).pipe(
1990
+ Effect4.catch(() => Effect4.succeed("")),
1991
+ Effect4.tap((environment) => Effect4.sync(() => {
1760
1992
  if (!owned.has(pid) && environment.split("\0").includes(`${tokenKey}=${token}`)) {
1761
1993
  claim(pid);
1762
1994
  closeDescendants();
@@ -1771,9 +2003,9 @@ var acquireProcessTree = Effect3.fn("ProcessTree.acquire")(function* (scratch, o
1771
2003
  const pid = Number(row[1]);
1772
2004
  const record = labelled.stdout.slice(row.index, rows[index + 1]?.index);
1773
2005
  if (owned.has(pid) || table.get(pid)?.birth !== row[2]?.trim() || !label.test(record)) continue;
1774
- const argv = yield* inspect(["ww", "-p", String(pid), "-o", "command="]).pipe(Effect3.result);
1775
- const environment = yield* inspect(["eww", "-p", String(pid), "-o", "command="]).pipe(Effect3.result);
1776
- const after = yield* inspect(["ww", "-p", String(pid), "-o", "command="]).pipe(Effect3.result);
2006
+ const argv = yield* inspect(["ww", "-p", String(pid), "-o", "command="]).pipe(Effect4.result);
2007
+ const environment = yield* inspect(["eww", "-p", String(pid), "-o", "command="]).pipe(Effect4.result);
2008
+ const after = yield* inspect(["ww", "-p", String(pid), "-o", "command="]).pipe(Effect4.result);
1777
2009
  if (Result.isFailure(argv) || Result.isFailure(environment) || Result.isFailure(after)) continue;
1778
2010
  const prefix = argv.success.stdout.trimEnd();
1779
2011
  if (prefix && prefix === after.success.stdout.trimEnd() && environment.success.stdout.startsWith(prefix + " ") && label.test(environment.success.stdout.slice(prefix.length))) uncertain.add(pid);
@@ -1785,11 +2017,11 @@ var acquireProcessTree = Effect3.fn("ProcessTree.acquire")(function* (scratch, o
1785
2017
  if (unverified.length) yield* Console2.warn(`Warning: unverified process PIDs ${unverified.join(", ")}; not signalled. Cleaning verified descendants first.`);
1786
2018
  return [...owned].flatMap((pid) => table.has(pid) && !keep.has(pid) ? [table.get(pid)] : []);
1787
2019
  });
1788
- const signal = (pending, value) => Effect3.gen(function* () {
2020
+ const signal = (pending, value) => Effect4.gen(function* () {
1789
2021
  const current = yield* snapshot;
1790
2022
  for (const item of pending) {
1791
2023
  if (current.get(item.pid)?.birth !== item.birth) continue;
1792
- yield* Effect3.sync(() => {
2024
+ yield* Effect4.sync(() => {
1793
2025
  try {
1794
2026
  if (roots.has(item.pid) && current.get(item.pid)?.pgid === item.pid) kill(-item.pid, value);
1795
2027
  } catch {
@@ -1801,28 +2033,28 @@ var acquireProcessTree = Effect3.fn("ProcessTree.acquire")(function* (scratch, o
1801
2033
  });
1802
2034
  }
1803
2035
  });
1804
- const inspectUnowned = Effect3.gen(function* () {
2036
+ const inspectUnowned = Effect4.gen(function* () {
1805
2037
  if (!scratch) return;
1806
2038
  const table = lastSnapshot ?? (yield* snapshot);
1807
- const registered = yield* Effect3.forEach([...liveLedgers], (path) => fs.readFileString(path).pipe(Effect3.catch(() => Effect3.succeed(""))));
2039
+ const registered = yield* Effect4.forEach([...liveLedgers], (path) => fs.readFileString(path).pipe(Effect4.catch(() => Effect4.succeed(""))));
1808
2040
  const known = new Set(registered.join("\n").split("\n").flatMap((line) => {
1809
- const parsed = Schema5.decodeOption(Schema5.fromJsonString(Record2))(line);
2041
+ const parsed = Schema6.decodeOption(Schema6.fromJsonString(Record2))(line);
1810
2042
  return parsed._tag === "Some" && table.get(parsed.value.pid)?.birth === parsed.value.birth ? [parsed.value.pid] : [];
1811
2043
  }));
1812
2044
  const candidates = /* @__PURE__ */ new Set();
1813
2045
  const since = processesSince === void 0 ? -Infinity : Math.floor(processesSince / 1e3) * 1e3;
1814
2046
  const possible = [...table.values()].filter((item) => !known.has(item.pid) && (processesSince === void 0 || Date.parse(item.birth + " UTC") >= since));
1815
2047
  for (const item of possible) if (item.argv.includes(scratch)) candidates.add(item.pid);
1816
- if (process.platform === "linux") yield* Effect3.forEach(possible.map((item) => item.pid), (pid) => fs.readLink(`/proc/${pid}/cwd`).pipe(
1817
- Effect3.catch(() => Effect3.succeed("")),
1818
- Effect3.tap((cwd) => Effect3.sync(() => {
2048
+ if (process.platform === "linux") yield* Effect4.forEach(possible.map((item) => item.pid), (pid) => fs.readLink(`/proc/${pid}/cwd`).pipe(
2049
+ Effect4.catch(() => Effect4.succeed("")),
2050
+ Effect4.tap((cwd) => Effect4.sync(() => {
1819
2051
  if (cwd === scratch || cwd.startsWith(scratch + "/")) candidates.add(pid);
1820
2052
  }))
1821
2053
  ), { concurrency: 8, discard: true });
1822
2054
  else if (process.platform === "darwin" && possible.length) {
1823
2055
  const cwdStarted = performance.now();
1824
2056
  yield* trace("cwd-start", { candidates: possible.length });
1825
- const cwd = yield* inspectScratchCwd(possible.map((item) => item.pid)).pipe(Effect3.catch(() => Console2.warn("Warning: cannot inspect scratch working directories; argv backstop remains active").pipe(Effect3.as({ stdout: "" }))));
2057
+ const cwd = yield* inspectScratchCwd(possible.map((item) => item.pid)).pipe(Effect4.catch(() => Console2.warn("Warning: cannot inspect scratch working directories; argv backstop remains active").pipe(Effect4.as({ stdout: "" }))));
1826
2058
  yield* trace("cwd-done", { elapsedMs: performance.now() - cwdStarted });
1827
2059
  let pid = 0;
1828
2060
  for (const row of cwd.stdout.split("\n")) {
@@ -1832,29 +2064,29 @@ var acquireProcessTree = Effect3.fn("ProcessTree.acquire")(function* (scratch, o
1832
2064
  }
1833
2065
  const survivors = [...candidates].filter((pid) => table.has(pid) && !known.has(pid));
1834
2066
  if (survivors.length) yield* Console2.warn(`Warning: unowned scratch-related process PIDs ${survivors.join(", ")} survived; not signalled because ownership is unproven`);
1835
- }).pipe(Effect3.catch(() => Console2.warn("Warning: cannot inspect unowned scratch-related survivors; no unverified PID was signalled")));
1836
- const warnUnowned = Effect3.gen(function* () {
2067
+ }).pipe(Effect4.catch(() => Console2.warn("Warning: cannot inspect unowned scratch-related survivors; no unverified PID was signalled")));
2068
+ const warnUnowned = Effect4.gen(function* () {
1837
2069
  if (!scratch) return;
1838
2070
  const started = yield* Clock.currentTimeMillis;
1839
2071
  if (!lastSnapshot) return yield* Console2.warn("Warning: scratch backstop unavailable without a process snapshot; no unverified PID was signalled");
1840
- yield* bounded("scratch backstop", inspectUnowned, 2e3).pipe(Effect3.catch((error3) => Console2.warn(`Warning: ${error3.message}; unowned PIDs were not signalled`)));
2072
+ yield* bounded("scratch backstop", inspectUnowned, 2e3).pipe(Effect4.catch((error3) => Console2.warn(`Warning: ${error3.message}; unowned PIDs were not signalled`)));
1841
2073
  const elapsed = Math.max(0, (yield* Clock.currentTimeMillis) - started);
1842
- yield* Effect3.sync(() => onBackstop?.(elapsed));
2074
+ yield* Effect4.sync(() => onBackstop?.(elapsed));
1843
2075
  });
1844
2076
  const semaphore = yield* Semaphore.make(1);
1845
2077
  let closed;
1846
- const sweep = (preserved, retained = []) => Effect3.scoped(Effect3.gen(function* () {
2078
+ const sweep = (preserved, retained = []) => Effect4.scoped(Effect4.gen(function* () {
1847
2079
  deadline = performance.now() + 1e4;
1848
2080
  lastSnapshot = void 0;
1849
2081
  ledgerRows = [];
1850
2082
  verified.clear();
1851
2083
  const keep = new Set(preserved);
1852
2084
  effectiveKeep = keep;
1853
- const discovering = createEffectLogic(() => bounded("discovery", discover(keep, retained)).pipe(Effect3.result));
1854
- const stopping = createEffectLogic(({ input }) => bounded("stop", signal(input, "SIGSTOP"), 3e3).pipe(Effect3.result));
1855
- const killing = createEffectLogic(({ input }) => bounded("kill", signal(input, "SIGKILL"), 3e3).pipe(Effect3.result));
2085
+ const discovering = createEffectLogic(() => bounded("discovery", discover(keep, retained)).pipe(Effect4.result));
2086
+ const stopping = createEffectLogic(({ input }) => bounded("stop", signal(input, "SIGSTOP"), 3e3).pipe(Effect4.result));
2087
+ const killing = createEffectLogic(({ input }) => bounded("kill", signal(input, "SIGKILL"), 3e3).pipe(Effect4.result));
1856
2088
  const machine = setupEffect({
1857
- schemas: { context: types(), events: { CLOSE: Schema5.Struct({}) } },
2089
+ schemas: { context: types(), events: { CLOSE: Schema6.Struct({}) } },
1858
2090
  actors: { discovering, stopping, killing }
1859
2091
  }).createMachine({
1860
2092
  context: { pending: [], round: 0, failure: void 0 },
@@ -1877,10 +2109,10 @@ var acquireProcessTree = Effect3.fn("ProcessTree.acquire")(function* (scratch, o
1877
2109
  });
1878
2110
  const actor = yield* createEffectActor(machine);
1879
2111
  yield* send(actor, { type: "CLOSE" });
1880
- const joined = yield* bounded("state machine", join(actor), 8e3).pipe(Effect3.result);
2112
+ const joined = yield* bounded("state machine", join(actor), 8e3).pipe(Effect4.result);
1881
2113
  const result5 = joined._tag === "Success" ? joined.success : { ...actor.getSnapshot().context, failure: joined.failure.message };
1882
2114
  if (result5.failure) {
1883
- yield* Effect3.sync(() => {
2115
+ yield* Effect4.sync(() => {
1884
2116
  actor.stop();
1885
2117
  for (const item of verified.values()) {
1886
2118
  try {
@@ -1895,19 +2127,19 @@ var acquireProcessTree = Effect3.fn("ProcessTree.acquire")(function* (scratch, o
1895
2127
  yield* warnUnowned;
1896
2128
  if (result5.failure) yield* Console2.warn(`Warning: ${result5.failure} (tracked PIDs ${(result5.pending.length ? result5.pending.map((item) => item.pid) : [...roots]).join(", ")}); ownership ledger kept at ${ledger}; continuing without reusing the host`);
1897
2129
  return result5.failure ? "warning" : "clean";
1898
- })).pipe(Effect3.uninterruptible);
1899
- const reap = (preserved, retained = []) => semaphore.withPermit(Effect3.suspend(() => closed === void 0 ? sweep(preserved, retained) : Effect3.succeed(closed)));
1900
- const cleanup = semaphore.withPermit(Effect3.gen(function* () {
2130
+ })).pipe(Effect4.uninterruptible);
2131
+ const reap = (preserved, retained = []) => semaphore.withPermit(Effect4.suspend(() => closed === void 0 ? sweep(preserved, retained) : Effect4.succeed(closed)));
2132
+ const cleanup = semaphore.withPermit(Effect4.gen(function* () {
1901
2133
  if (closed === void 0) closed = yield* sweep([]);
1902
2134
  }));
1903
- yield* Effect3.addFinalizer(() => Effect3.gen(function* () {
2135
+ yield* Effect4.addFinalizer(() => Effect4.gen(function* () {
1904
2136
  yield* cleanup;
1905
2137
  if (closed === "clean") yield* fs.remove(directory, { recursive: true }).pipe(
1906
- Effect3.interruptible,
1907
- Effect3.timeout(2e3),
1908
- Effect3.catch((error3) => Console2.warn(`Warning: cannot remove process ledger directory: ${error3.message}`))
2138
+ Effect4.interruptible,
2139
+ Effect4.timeout(2e3),
2140
+ Effect4.catch((error3) => Console2.warn(`Warning: cannot remove process ledger directory: ${error3.message}`))
1909
2141
  );
1910
- }).pipe(Effect3.ensuring(Effect3.sync(() => {
2142
+ }).pipe(Effect4.ensuring(Effect4.sync(() => {
1911
2143
  liveLedgers.delete(ledger);
1912
2144
  }))));
1913
2145
  const existing = process.env.NODE_OPTIONS ?? "";
@@ -1923,7 +2155,7 @@ var acquireProcessTree = Effect3.fn("ProcessTree.acquire")(function* (scratch, o
1923
2155
  });
1924
2156
 
1925
2157
  // packages/runner/src/Preflight.ts
1926
- var Issues = Schema6.Array(SelectionIssue);
2158
+ var Issues = Schema7.Array(SelectionIssue);
1927
2159
  var probe = String.raw`
1928
2160
  import { readFile, readdir } from "node:fs/promises";
1929
2161
  import { resolve, relative, dirname, isAbsolute, sep } from "node:path";
@@ -1940,6 +2172,14 @@ if (otherRunner) {
1940
2172
  issues.push({ kind: "runner", reason: 'package.json scripts.test = ' + JSON.stringify(script) + '; mutant.cafe only runs Vitest' });
1941
2173
  } else {
1942
2174
  if (!vitestScript) issues.push({ kind: "warning", reason: 'package.json scripts.test = ' + JSON.stringify(script) + (delegated ? '; delegated test runner: Vitest selection is unverified' : '; unknown test wrapper: Vitest selection is unverified') });
2175
+ // Resolve from the adopter's package, not mutant.cafe's bundled dependencies.
2176
+ const require = createRequire(resolve(root, "package.json"));
2177
+ let version;
2178
+ try { version = JSON.parse(await readFile(require.resolve("vitest/package.json"), "utf8")).version; } catch {}
2179
+ if (typeof version === "string" && /^\d+\./.test(version) && Number(version.split(".")[0]) < 5) {
2180
+ console.log("mutant-cafe-vitest-version:" + JSON.stringify(version));
2181
+ process.exit(0);
2182
+ }
1943
2183
  let ctx;
1944
2184
  try {
1945
2185
  const { createVitest } = await import("vitest/node");
@@ -2065,17 +2305,22 @@ if (otherRunner) {
2065
2305
  }
2066
2306
  console.log('mutant-cafe-preflight:' + JSON.stringify([...new Map(issues.map(issue => [JSON.stringify(issue), issue])).values()]));
2067
2307
  `;
2068
- var preflight = Effect4.fn("TestRunner.preflight")(function* (root, tsconfig = "tsconfig.json", timeoutMs = DEFAULT_BASELINE_TIMEOUT_MS, options = {}) {
2069
- const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
2308
+ var preflight = Effect5.fn("TestRunner.preflight")(function* (root, tsconfig = "tsconfig.json", timeoutMs = DEFAULT_BASELINE_TIMEOUT_MS, options = {}) {
2309
+ const spawner = yield* ChildProcessSpawner3.ChildProcessSpawner;
2070
2310
  const since = options.processesSince ?? (yield* Clock2.currentTimeMillis);
2071
2311
  const owned = yield* acquireProcessTree(root, options.onBackstop, since);
2072
2312
  yield* owned.trace("preflight-start", { budgetMs: timeoutMs });
2073
- const output = yield* spawner.string(ChildProcess.make(process.execPath, ["--input-type=module", "--eval", probe, tsconfig], { cwd: root, env: owned.env, detached: true, killSignal: "SIGKILL", forceKillAfter: "100 millis", stdin: "ignore" })).pipe(Effect4.onInterrupt(() => owned.cleanup));
2313
+ const output = yield* spawner.string(ChildProcess2.make(process.execPath, ["--input-type=module", "--eval", probe, tsconfig], { cwd: root, env: owned.env, detached: true, killSignal: "SIGKILL", forceKillAfter: "100 millis", stdin: "ignore" })).pipe(Effect5.onInterrupt(() => owned.cleanup));
2074
2314
  yield* owned.trace("preflight-done");
2315
+ const version = output.split("\n").find((line) => line.startsWith("mutant-cafe-vitest-version:"))?.slice("mutant-cafe-vitest-version:".length);
2316
+ if (version !== void 0) {
2317
+ const found = yield* Schema7.decodeEffect(Schema7.fromJsonString(Schema7.String))(version);
2318
+ return yield* new TestSpawnError({ kind: "vitest-version", command: ["vitest"], message: `mutant.cafe needs vitest >= 5.0, found ${found}` });
2319
+ }
2075
2320
  const encoded = output.split("\n").find((line) => line.startsWith("mutant-cafe-preflight:"))?.slice("mutant-cafe-preflight:".length);
2076
- const issues = encoded === void 0 ? [{ kind: "warning", reason: "Vitest selection probe returned no evidence" }] : yield* Schema6.decodeEffect(Schema6.fromJsonString(Issues))(encoded);
2321
+ const issues = encoded === void 0 ? [{ kind: "warning", reason: "Vitest selection probe returned no evidence" }] : yield* Schema7.decodeEffect(Schema7.fromJsonString(Issues))(encoded);
2077
2322
  return issues;
2078
- }, (effect5, _root, _tsconfig = "tsconfig.json", timeoutMs = DEFAULT_BASELINE_TIMEOUT_MS, _options = {}) => effect5.pipe(Effect4.timeout(timeoutMs), Effect4.scoped));
2323
+ }, (effect5, _root, _tsconfig = "tsconfig.json", timeoutMs = DEFAULT_BASELINE_TIMEOUT_MS, _options = {}) => effect5.pipe(Effect5.timeout(timeoutMs), Effect5.scoped));
2079
2324
  function unreliableFor(baseline, file, testFiles) {
2080
2325
  return baseline.unreliable?.filter((issue) => {
2081
2326
  switch (issue.kind) {
@@ -2092,26 +2337,26 @@ function unreliableFor(baseline, file, testFiles) {
2092
2337
  }
2093
2338
 
2094
2339
  // packages/runner/src/TestRunner.ts
2095
- import * as Effect6 from "effect/Effect";
2340
+ import * as Effect7 from "effect/Effect";
2096
2341
  import * as Layer3 from "effect/Layer";
2097
2342
  import * as FileSystem7 from "effect/FileSystem";
2098
- import * as Path3 from "effect/Path";
2099
- import * as Stream2 from "effect/Stream";
2100
- import * as Schema8 from "effect/Schema";
2343
+ import * as Path5 from "effect/Path";
2344
+ import * as Stream3 from "effect/Stream";
2345
+ import * as Schema9 from "effect/Schema";
2101
2346
  import * as Scope3 from "effect/Scope";
2102
2347
  import { createRequire } from "node:module";
2103
2348
  import { pathToFileURL as pathToFileURL2 } from "node:url";
2104
- import * as ChildProcess2 from "effect/process/ChildProcess";
2105
- import * as ChildProcessSpawner3 from "effect/process/ChildProcessSpawner";
2349
+ import * as ChildProcess3 from "effect/process/ChildProcess";
2350
+ import * as ChildProcessSpawner5 from "effect/process/ChildProcessSpawner";
2106
2351
 
2107
2352
  // packages/runner/src/WarmRunner.ts
2108
2353
  import { createEffectActor as createEffectActor2, send as send2, setupEffect as setupEffect2 } from "@xstate/effect";
2109
2354
  import { spawn } from "node:child_process";
2110
2355
  import * as Clock3 from "effect/Clock";
2111
- import * as Effect5 from "effect/Effect";
2356
+ import * as Effect6 from "effect/Effect";
2112
2357
  import * as Console3 from "effect/Console";
2113
2358
  import * as FileSystem5 from "effect/FileSystem";
2114
- import * as Schema7 from "effect/Schema";
2359
+ import * as Schema8 from "effect/Schema";
2115
2360
  import * as Scope from "effect/Scope";
2116
2361
  import * as Exit from "effect/Exit";
2117
2362
 
@@ -2413,36 +2658,36 @@ process.on("message", async request => {
2413
2658
  `;
2414
2659
 
2415
2660
  // packages/runner/src/WarmRunner.ts
2416
- var Message = Schema7.Union([
2417
- Schema7.Struct({ type: Schema7.Literal("ready") }),
2418
- Schema7.Struct({ type: Schema7.Literal("retained"), pids: Schema7.Array(Schema7.Struct({ pid: Schema7.Int, birth: Schema7.String })) }),
2419
- Schema7.Struct({ type: Schema7.Literal("invalidated") }),
2420
- Schema7.Struct({ type: Schema7.Literal("collected") }),
2421
- Schema7.Struct({ type: Schema7.Literal("failed") }),
2422
- Schema7.Struct({ type: Schema7.Literal("selected"), files: Schema7.Array(Schema7.String) }),
2423
- Schema7.Struct({ type: Schema7.Literal("selection"), files: Schema7.Array(Schema7.String) }),
2424
- Schema7.Struct({ type: Schema7.Literal("probeLoaded") }),
2425
- Schema7.Struct({ type: Schema7.Literal("quiescing") }),
2426
- Schema7.Struct({ type: Schema7.Literal("quiesced") }),
2427
- Schema7.Struct({ type: Schema7.Literal("healthy") }),
2428
- Schema7.Struct({ type: Schema7.Literal("fallback"), message: Schema7.String }),
2429
- Schema7.Struct({ type: Schema7.Literal("crash"), message: Schema7.String }),
2430
- Schema7.Struct({
2431
- type: Schema7.Literal("result"),
2432
- status: Schema7.Literals(["passed", "failed", "untested"]),
2433
- testFiles: Schema7.Array(Schema7.String),
2434
- testsCollected: Schema7.Boolean,
2435
- testDurations: Schema7.Record(Schema7.String, Schema7.Finite),
2436
- testTimeouts: Schema7.Record(Schema7.String, Schema7.Finite),
2437
- testWorkers: Schema7.optional(Schema7.Int),
2438
- testConcurrency: Schema7.optional(Schema7.Int),
2439
- telemetryWarnings: Schema7.optional(Schema7.Array(Schema7.String)),
2440
- testFileDurations: Schema7.Record(Schema7.String, Schema7.Finite),
2441
- firstTestStart: Schema7.Finite,
2442
- probeSupported: Schema7.Boolean,
2443
- probeLoaded: Schema7.Boolean,
2444
- testTimeoutDetails: Schema7.Record(Schema7.String, Schema7.Finite),
2445
- crashed: Schema7.Boolean
2661
+ var Message = Schema8.Union([
2662
+ Schema8.Struct({ type: Schema8.Literal("ready") }),
2663
+ Schema8.Struct({ type: Schema8.Literal("retained"), pids: Schema8.Array(Schema8.Struct({ pid: Schema8.Int, birth: Schema8.String })) }),
2664
+ Schema8.Struct({ type: Schema8.Literal("invalidated") }),
2665
+ Schema8.Struct({ type: Schema8.Literal("collected") }),
2666
+ Schema8.Struct({ type: Schema8.Literal("failed") }),
2667
+ Schema8.Struct({ type: Schema8.Literal("selected"), files: Schema8.Array(Schema8.String) }),
2668
+ Schema8.Struct({ type: Schema8.Literal("selection"), files: Schema8.Array(Schema8.String) }),
2669
+ Schema8.Struct({ type: Schema8.Literal("probeLoaded") }),
2670
+ Schema8.Struct({ type: Schema8.Literal("quiescing") }),
2671
+ Schema8.Struct({ type: Schema8.Literal("quiesced") }),
2672
+ Schema8.Struct({ type: Schema8.Literal("healthy") }),
2673
+ Schema8.Struct({ type: Schema8.Literal("fallback"), message: Schema8.String }),
2674
+ Schema8.Struct({ type: Schema8.Literal("crash"), message: Schema8.String }),
2675
+ Schema8.Struct({
2676
+ type: Schema8.Literal("result"),
2677
+ status: Schema8.Literals(["passed", "failed", "untested"]),
2678
+ testFiles: Schema8.Array(Schema8.String),
2679
+ testsCollected: Schema8.Boolean,
2680
+ testDurations: Schema8.Record(Schema8.String, Schema8.Finite),
2681
+ testTimeouts: Schema8.Record(Schema8.String, Schema8.Finite),
2682
+ testWorkers: Schema8.optional(Schema8.Int),
2683
+ testConcurrency: Schema8.optional(Schema8.Int),
2684
+ telemetryWarnings: Schema8.optional(Schema8.Array(Schema8.String)),
2685
+ testFileDurations: Schema8.Record(Schema8.String, Schema8.Finite),
2686
+ firstTestStart: Schema8.Finite,
2687
+ probeSupported: Schema8.Boolean,
2688
+ probeLoaded: Schema8.Boolean,
2689
+ testTimeoutDetails: Schema8.Record(Schema8.String, Schema8.Finite),
2690
+ crashed: Schema8.Boolean
2446
2691
  })
2447
2692
  ]);
2448
2693
  var ReporterMessageError = class extends Error {
@@ -2450,7 +2695,7 @@ var ReporterMessageError = class extends Error {
2450
2695
  };
2451
2696
  function decodeWarmMessage(value) {
2452
2697
  try {
2453
- const raw = Schema7.decodeUnknownSync(Schema7.Record(Schema7.String, Schema7.Unknown))(value);
2698
+ const raw = Schema8.decodeUnknownSync(Schema8.Record(Schema8.String, Schema8.Unknown))(value);
2454
2699
  const cleaned = cleanTelemetry(raw, "warm message");
2455
2700
  if (raw.type === "result") {
2456
2701
  for (const [key, fallback] of Object.entries({ testDurations: {}, testTimeouts: {}, testFileDurations: {}, testTimeoutDetails: {}, firstTestStart: 0 }))
@@ -2458,7 +2703,7 @@ function decodeWarmMessage(value) {
2458
2703
  const previous = cleaned.value.telemetryWarnings;
2459
2704
  Reflect.set(cleaned.value, "telemetryWarnings", [...Array.isArray(previous) ? previous : [], ...cleaned.warnings]);
2460
2705
  }
2461
- return Schema7.decodeUnknownSync(Message)(cleaned.value);
2706
+ return Schema8.decodeUnknownSync(Message)(cleaned.value);
2462
2707
  } catch (error3) {
2463
2708
  const actual = (() => {
2464
2709
  try {
@@ -2581,24 +2826,24 @@ var Host = class {
2581
2826
  }
2582
2827
  grace() {
2583
2828
  const self = this;
2584
- return Effect5.gen(function* () {
2829
+ return Effect6.gen(function* () {
2585
2830
  self.post({ type: "close" });
2586
- const exited = Effect5.promise(() => self.exited);
2587
- const result5 = yield* exited.pipe(Effect5.interruptible, Effect5.timeout(500), Effect5.result);
2588
- if (result5._tag === "Failure") yield* Effect5.sync(() => {
2831
+ const exited = Effect6.promise(() => self.exited);
2832
+ const result5 = yield* exited.pipe(Effect6.interruptible, Effect6.timeout(500), Effect6.result);
2833
+ if (result5._tag === "Failure") yield* Effect6.sync(() => {
2589
2834
  self.child.kill("SIGKILL");
2590
2835
  });
2591
2836
  });
2592
2837
  }
2593
2838
  };
2594
2839
  var lifecycle = setupEffect2({ schemas: { events: {
2595
- RUN: Schema7.Struct({}),
2596
- DONE: Schema7.Struct({}),
2597
- CANCEL: Schema7.Struct({}),
2598
- RESTART: Schema7.Struct({}),
2599
- READY: Schema7.Struct({}),
2600
- FAIL: Schema7.Struct({}),
2601
- FALLBACK: Schema7.Struct({})
2840
+ RUN: Schema8.Struct({}),
2841
+ DONE: Schema8.Struct({}),
2842
+ CANCEL: Schema8.Struct({}),
2843
+ RESTART: Schema8.Struct({}),
2844
+ READY: Schema8.Struct({}),
2845
+ FAIL: Schema8.Struct({}),
2846
+ FALLBACK: Schema8.Struct({})
2602
2847
  } } }).createMachine({
2603
2848
  initial: "idle",
2604
2849
  on: { FAIL: { target: ".failed" }, FALLBACK: { target: ".cold" } },
@@ -2611,7 +2856,7 @@ var lifecycle = setupEffect2({ schemas: { events: {
2611
2856
  cold: { type: "final" }
2612
2857
  }
2613
2858
  });
2614
- var openWarmRunner = Effect5.fn("TestRunner.openWarm")(function* (dir, onFallback, options = {}) {
2859
+ var openWarmRunner = Effect6.fn("TestRunner.openWarm")(function* (dir, onFallback, options = {}) {
2615
2860
  const fs = yield* FileSystem5.FileSystem;
2616
2861
  const parentScope = yield* Scope.Scope;
2617
2862
  const temp = yield* fs.makeTempDirectoryScoped({ prefix: "mutant-warm-" });
@@ -2621,77 +2866,77 @@ var openWarmRunner = Effect5.fn("TestRunner.openWarm")(function* (dir, onFallbac
2621
2866
  yield* fs.writeFileString(reporter, reporterSource("mutant-warm:"));
2622
2867
  const actor = yield* createEffectActor2(lifecycle);
2623
2868
  let host;
2624
- const attempt = (fn11) => Effect5.tryPromise({
2625
- try: fn11,
2869
+ const attempt = (fn12) => Effect6.tryPromise({
2870
+ try: fn12,
2626
2871
  catch: (error3) => new TestSpawnError({ command: ["vitest", "warm"], message: String(error3), ...error3 instanceof ReporterMessageError ? { kind: "reporter" } : {} })
2627
- }).pipe(Effect5.interruptible);
2628
- const close2 = () => host === void 0 ? Effect5.void : host.close();
2629
- const abortHost = (error3) => Effect5.gen(function* () {
2872
+ }).pipe(Effect6.interruptible);
2873
+ const close2 = () => host === void 0 ? Effect6.void : host.close();
2874
+ const abortHost = (error3) => Effect6.gen(function* () {
2630
2875
  yield* send2(actor, { type: "FAIL" });
2631
2876
  yield* close2();
2632
2877
  return yield* error3;
2633
2878
  });
2634
- yield* Effect5.addFinalizer(() => close2().pipe(Effect5.orDie));
2635
- const start = Effect5.gen(function* () {
2879
+ yield* Effect6.addFinalizer(() => close2().pipe(Effect6.orDie));
2880
+ const start = Effect6.gen(function* () {
2636
2881
  const scope = yield* Scope.make();
2637
- yield* Effect5.addFinalizer(() => Scope.close(scope, Exit.succeed(void 0))).pipe(Effect5.provideService(Scope.Scope, parentScope));
2882
+ yield* Effect6.addFinalizer(() => Scope.close(scope, Exit.succeed(void 0))).pipe(Effect6.provideService(Scope.Scope, parentScope));
2638
2883
  const tree = yield* acquireProcessTree(dir.path, options.onBackstop, options.processesSince).pipe(
2639
- Effect5.provideService(Scope.Scope, scope),
2640
- Effect5.provideService(FileSystem5.FileSystem, fs),
2641
- Effect5.mapError((error3) => new TestSpawnError({ command: ["vitest", "warm"], message: String(error3) }))
2884
+ Effect6.provideService(Scope.Scope, scope),
2885
+ Effect6.provideService(FileSystem5.FileSystem, fs),
2886
+ Effect6.mapError((error3) => new TestSpawnError({ command: ["vitest", "warm"], message: String(error3) }))
2642
2887
  );
2643
2888
  const active = new Host(dir.path, script, reporter, tree, scope, options.selectionOnly === true, options.decodeMessage);
2644
2889
  host = active;
2645
- yield* Effect5.addFinalizer(() => active.grace()).pipe(Effect5.provideService(Scope.Scope, scope));
2890
+ yield* Effect6.addFinalizer(() => active.grace()).pipe(Effect6.provideService(Scope.Scope, scope));
2646
2891
  const initialized = yield* attempt(() => host.ready()).pipe(
2647
- Effect5.timeout(3e4),
2648
- Effect5.mapError((error3) => error3._tag === "TestSpawnError" ? error3 : new TestSpawnError({ command: ["vitest", "warm"], message: String(error3) })),
2649
- Effect5.result
2892
+ Effect6.timeout(3e4),
2893
+ Effect6.mapError((error3) => error3._tag === "TestSpawnError" ? error3 : new TestSpawnError({ command: ["vitest", "warm"], message: String(error3) })),
2894
+ Effect6.result
2650
2895
  );
2651
2896
  if (initialized._tag === "Failure") return yield* abortHost(initialized.failure);
2652
2897
  const ready = initialized.success;
2653
2898
  if (ready.type !== "ready") {
2654
2899
  if (!options.quiet) yield* (options.warn ?? Console3.warn)(`Warning: warm Vitest unavailable; using cold mode: ${"message" in ready ? ready.message : ready.type}`);
2655
- yield* Effect5.sync(() => onFallback("message" in ready ? ready.message : `Unexpected startup frame: ${ready.type}`));
2900
+ yield* Effect6.sync(() => onFallback("message" in ready ? ready.message : `Unexpected startup frame: ${ready.type}`));
2656
2901
  yield* send2(actor, { type: "FALLBACK" });
2657
2902
  yield* close2();
2658
2903
  }
2659
2904
  });
2660
- const retire = Effect5.gen(function* () {
2905
+ const retire = Effect6.gen(function* () {
2661
2906
  yield* send2(actor, { type: "RESTART" });
2662
2907
  yield* close2();
2663
2908
  });
2664
- const restart = Effect5.gen(function* () {
2909
+ const restart = Effect6.gen(function* () {
2665
2910
  yield* retire;
2666
2911
  yield* start;
2667
- yield* Effect5.sync(() => options.onRestart?.());
2912
+ yield* Effect6.sync(() => options.onRestart?.());
2668
2913
  if (actor.getSnapshot().value !== "cold") yield* send2(actor, { type: "READY" });
2669
2914
  });
2670
2915
  yield* start;
2671
2916
  const isCold = () => actor.getSnapshot().value === "cold";
2672
- const invalidate = Effect5.fn("Warm.invalidate")(function* (file) {
2917
+ const invalidate = Effect6.fn("Warm.invalidate")(function* (file) {
2673
2918
  if (isCold() || actor.getSnapshot().value === "failed") return;
2674
2919
  if (actor.getSnapshot().value === "restarting") {
2675
2920
  yield* start;
2676
- yield* Effect5.sync(() => options.onRestart?.());
2921
+ yield* Effect6.sync(() => options.onRestart?.());
2677
2922
  if (!isCold()) yield* send2(actor, { type: "READY" });
2678
2923
  return;
2679
2924
  }
2680
- const result5 = yield* attempt(() => host.request({ type: "invalidate", file })).pipe(Effect5.timeout(1e3), Effect5.result);
2925
+ const result5 = yield* attempt(() => host.request({ type: "invalidate", file })).pipe(Effect6.timeout(1e3), Effect6.result);
2681
2926
  if (result5._tag === "Failure" && result5.failure._tag === "TestSpawnError" && result5.failure.kind === "reporter") return yield* abortHost(result5.failure);
2682
2927
  if (result5._tag === "Failure") yield* restart;
2683
2928
  });
2684
- const finish = Effect5.fn("Warm.finish")(function* (active, pending) {
2929
+ const finish = Effect6.fn("Warm.finish")(function* (active, pending) {
2685
2930
  const pool = active.quiesce();
2686
- const started = yield* attempt(() => pool.started).pipe(Effect5.timeout(500), Effect5.result);
2931
+ const started = yield* attempt(() => pool.started).pipe(Effect6.timeout(500), Effect6.result);
2687
2932
  const clean = yield* active.tree.reap(active.child.pid === void 0 ? [] : [active.child.pid], active.retained);
2688
2933
  if (clean !== "clean" || started._tag === "Failure") return false;
2689
- yield* attempt(() => pool.done).pipe(Effect5.timeout(100), Effect5.result);
2690
- const settled = yield* attempt(() => pending).pipe(Effect5.timeout(500), Effect5.result);
2691
- const health = settled._tag === "Success" ? yield* attempt(() => active.request({ type: "ping" })).pipe(Effect5.timeout(500), Effect5.result) : settled;
2934
+ yield* attempt(() => pool.done).pipe(Effect6.timeout(100), Effect6.result);
2935
+ const settled = yield* attempt(() => pending).pipe(Effect6.timeout(500), Effect6.result);
2936
+ const health = settled._tag === "Success" ? yield* attempt(() => active.request({ type: "ping" })).pipe(Effect6.timeout(500), Effect6.result) : settled;
2692
2937
  return clean === "clean" && started._tag === "Success" && health._tag === "Success" && health.success.type === "healthy";
2693
2938
  });
2694
- const run2 = Effect5.fn("Warm.run")(function* (file, timeoutMs, testTimeout, probe2) {
2939
+ const run2 = Effect6.fn("Warm.run")(function* (file, timeoutMs, testTimeout, probe2) {
2695
2940
  if (isCold()) return void 0;
2696
2941
  if (options.selectionOnly) return yield* abortHost(new TestSpawnError({ command: ["vitest", "select"], kind: "reporter", message: "Selection-only host cannot execute tests" }));
2697
2942
  const command = ["vitest", ...file ? ["related", file, "--run"] : ["run"], "--reporter=default"];
@@ -2704,14 +2949,14 @@ var openWarmRunner = Effect5.fn("TestRunner.openWarm")(function* (dir, onFallbac
2704
2949
  const started = yield* Clock3.currentTimeMillis;
2705
2950
  active.runPending = void 0;
2706
2951
  const budgetMs = timeoutMs ?? DEFAULT_BASELINE_TIMEOUT_MS;
2707
- const operation = Effect5.gen(function* () {
2952
+ const operation = Effect6.gen(function* () {
2708
2953
  yield* active.tree.trace("warm-attempt-start", { budgetMs });
2709
2954
  yield* send2(actor, { type: "RUN" });
2710
2955
  const pending2 = active.request({ type: "run", file, testTimeout, probe: probe2 });
2711
2956
  active.runPending = pending2;
2712
2957
  return yield* attempt(() => pending2);
2713
2958
  });
2714
- const result5 = yield* operation.pipe(Effect5.interruptible, Effect5.timeout(budgetMs), Effect5.result);
2959
+ const result5 = yield* operation.pipe(Effect6.interruptible, Effect6.timeout(budgetMs), Effect6.result);
2715
2960
  const pending = active.runPending;
2716
2961
  if (result5._tag === "Success" && result5.success.type === "result" && !result5.success.crashed) {
2717
2962
  if (pending && (yield* finish(active, pending))) yield* send2(actor, { type: "DONE" });
@@ -2726,7 +2971,7 @@ var openWarmRunner = Effect5.fn("TestRunner.openWarm")(function* (dir, onFallbac
2726
2971
  };
2727
2972
  }
2728
2973
  if (result5._tag === "Failure" && result5.failure._tag === "TimeoutError") {
2729
- yield* Effect5.sync(() => options.onPoolReset?.());
2974
+ yield* Effect6.sync(() => options.onPoolReset?.());
2730
2975
  yield* active.tree.trace("warm-deadline", { budgetMs });
2731
2976
  const failedAtDeadline = active.failed;
2732
2977
  yield* send2(actor, { type: "CANCEL" });
@@ -2744,7 +2989,7 @@ var openWarmRunner = Effect5.fn("TestRunner.openWarm")(function* (dir, onFallbac
2744
2989
  };
2745
2990
  }
2746
2991
  if (result5._tag === "Failure" && result5.failure._tag === "TestSpawnError" && result5.failure.kind === "reporter") return yield* abortHost(result5.failure);
2747
- yield* Effect5.sync(() => options.onPoolReset?.());
2992
+ yield* Effect6.sync(() => options.onPoolReset?.());
2748
2993
  if (crash === 0) {
2749
2994
  yield* Console3.warn(`Warning: Vitest pool crashed; restarting once: ${result5._tag === "Failure" ? String(result5.failure) : "message" in result5.success ? result5.success.message : result5.success.type}`);
2750
2995
  if (pending && (yield* finish(active, pending))) yield* send2(actor, { type: "DONE" });
@@ -2753,32 +2998,32 @@ var openWarmRunner = Effect5.fn("TestRunner.openWarm")(function* (dir, onFallbac
2753
2998
  yield* send2(actor, { type: "FAIL" });
2754
2999
  yield* close2();
2755
3000
  yield* Console3.warn("Warning: Vitest pool crashed twice for one mutant; using cold mode for the rest of this run");
2756
- yield* Effect5.sync(() => onFallback("Vitest pool crashed twice for one mutant"));
3001
+ yield* Effect6.sync(() => onFallback("Vitest pool crashed twice for one mutant"));
2757
3002
  yield* send2(actor, { type: "FALLBACK" });
2758
3003
  }
2759
3004
  if (isCold()) return void 0;
2760
3005
  }
2761
3006
  return void 0;
2762
- }, (effect5) => effect5.pipe(Effect5.onInterrupt(() => Effect5.gen(function* () {
3007
+ }, (effect5) => effect5.pipe(Effect6.onInterrupt(() => Effect6.gen(function* () {
2763
3008
  yield* send2(actor, { type: "CANCEL" });
2764
3009
  const active = host;
2765
- yield* Effect5.sync(() => options.onPoolReset?.());
3010
+ yield* Effect6.sync(() => options.onPoolReset?.());
2766
3011
  active?.post({ type: "cancel" });
2767
- if (active?.runPending && (yield* finish(active, active.runPending).pipe(Effect5.orDie))) yield* send2(actor, { type: "DONE" });
3012
+ if (active?.runPending && (yield* finish(active, active.runPending).pipe(Effect6.orDie))) yield* send2(actor, { type: "DONE" });
2768
3013
  else {
2769
- yield* retire.pipe(Effect5.orDie);
2770
- yield* Effect5.sync(() => onFallback("Interrupted run retired its unhealthy host"));
3014
+ yield* retire.pipe(Effect6.orDie);
3015
+ yield* Effect6.sync(() => onFallback("Interrupted run retired its unhealthy host"));
2771
3016
  yield* send2(actor, { type: "FALLBACK" });
2772
3017
  }
2773
3018
  }))));
2774
- const disable = Effect5.gen(function* () {
3019
+ const disable = Effect6.gen(function* () {
2775
3020
  if (isCold()) return;
2776
3021
  yield* close2();
2777
3022
  yield* send2(actor, { type: "FALLBACK" });
2778
3023
  });
2779
- const select = Effect5.fn("Warm.select")(function* (file) {
3024
+ const select = Effect6.fn("Warm.select")(function* (file) {
2780
3025
  if (isCold()) return void 0;
2781
- const result5 = yield* attempt(() => host.request({ type: "select", file })).pipe(Effect5.timeout(3e4), Effect5.result);
3026
+ const result5 = yield* attempt(() => host.request({ type: "select", file })).pipe(Effect6.timeout(3e4), Effect6.result);
2782
3027
  if (result5._tag === "Success" && result5.success.type === "selection") return result5.success.files;
2783
3028
  if (result5._tag === "Failure" && result5.failure._tag === "TestSpawnError" && result5.failure.kind === "reporter") return yield* abortHost(result5.failure);
2784
3029
  yield* restart;
@@ -2804,10 +3049,10 @@ var baselineTimedOut = (timeoutMs, command) => new BaselineTimedOut({
2804
3049
  command,
2805
3050
  message: `Baseline exceeded ${timeoutMs / 1e3} seconds overall, including selection and startup. Increase --baseline-timeout (seconds), or baselineTimeoutMs in mutants.config.json, for a longer suite.`
2806
3051
  });
2807
- var TestRunnerLive = Layer3.effect(TestRunner, Effect6.gen(function* () {
2808
- const spawner = yield* ChildProcessSpawner3.ChildProcessSpawner;
3052
+ var TestRunnerLive = Layer3.effect(TestRunner, Effect7.gen(function* () {
3053
+ const spawner = yield* ChildProcessSpawner5.ChildProcessSpawner;
2809
3054
  const fs = yield* FileSystem7.FileSystem;
2810
- const path = yield* Path3.Path;
3055
+ const path = yield* Path5.Path;
2811
3056
  let warmDisabled = false;
2812
3057
  let modeReason;
2813
3058
  const sessions = /* @__PURE__ */ new Map();
@@ -2826,8 +3071,8 @@ var TestRunnerLive = Layer3.effect(TestRunner, Effect6.gen(function* () {
2826
3071
  let hostRestarts = 0;
2827
3072
  let poolResets = 0;
2828
3073
  let warned = false;
2829
- const warn6 = (message) => Effect6.suspend(() => {
2830
- if (warned) return Effect6.void;
3074
+ const warn7 = (message) => Effect7.suspend(() => {
3075
+ if (warned) return Effect7.void;
2831
3076
  warned = true;
2832
3077
  return Console4.warn(message);
2833
3078
  });
@@ -2836,7 +3081,7 @@ var TestRunnerLive = Layer3.effect(TestRunner, Effect6.gen(function* () {
2836
3081
  }, onPoolReset: () => {
2837
3082
  poolResets++;
2838
3083
  } };
2839
- const execute2 = Effect6.fn("TestRunner.execute")(function* (dir, args, timeoutMs, testTimeoutMs, forceCold = false, probe2) {
3084
+ const execute2 = Effect7.fn("TestRunner.execute")(function* (dir, args, timeoutMs, testTimeoutMs, forceCold = false, probe2) {
2840
3085
  const overallMs = timeoutMs ?? baselineBudgetMs;
2841
3086
  const beforeBackstop = backstopTotals.get(dir.path) ?? 0;
2842
3087
  const backstopMs = () => Math.max(0, (backstopTotals.get(dir.path) ?? 0) - beforeBackstop);
@@ -2847,13 +3092,13 @@ var TestRunnerLive = Layer3.effect(TestRunner, Effect6.gen(function* () {
2847
3092
  if (run3 !== void 0) return { ...run3, backstopMs: backstopMs(), exitCode: run3.status === "passed" || run3.status === "untested" ? 0 : 1 };
2848
3093
  }
2849
3094
  const reporterDir = yield* fs.makeTempDirectoryScoped({ prefix: "mutant-vitest-" }).pipe(
2850
- Effect6.mapError((error3) => new TestSpawnError({ command: ["vitest"], message: String(error3) }))
3095
+ Effect7.mapError((error3) => new TestSpawnError({ command: ["vitest"], message: String(error3) }))
2851
3096
  );
2852
3097
  const reporter = path.join(reporterDir, "reporter.mjs");
2853
3098
  const launcher = path.join(reporterDir, "launch.mjs");
2854
- yield* fs.writeFileString(launcher, vitestLauncherSource).pipe(Effect6.mapError((error3) => new TestSpawnError({ command: ["vitest"], message: String(error3) })));
3099
+ yield* fs.writeFileString(launcher, vitestLauncherSource).pipe(Effect7.mapError((error3) => new TestSpawnError({ command: ["vitest"], message: String(error3) })));
2855
3100
  const marker = `mutant-cafe:${path.basename(reporterDir)}:`;
2856
- yield* fs.writeFileString(reporter, reporterSource(marker, probe2)).pipe(Effect6.mapError((error3) => new TestSpawnError({ command: ["vitest"], message: String(error3) })));
3101
+ yield* fs.writeFileString(reporter, reporterSource(marker, probe2)).pipe(Effect7.mapError((error3) => new TestSpawnError({ command: ["vitest"], message: String(error3) })));
2857
3102
  const command = [
2858
3103
  process.execPath,
2859
3104
  launcher,
@@ -2868,16 +3113,16 @@ var TestRunnerLive = Layer3.effect(TestRunner, Effect6.gen(function* () {
2868
3113
  ];
2869
3114
  const started = yield* Clock4.currentTimeMillis;
2870
3115
  const owned = yield* acquireProcessTree(dir.path, onBackstop(dir.path), openedAt.get(dir.path)).pipe(
2871
- Effect6.provideService(FileSystem7.FileSystem, fs),
2872
- Effect6.mapError((error3) => new TestSpawnError({ command, message: String(error3) }))
3116
+ Effect7.provideService(FileSystem7.FileSystem, fs),
3117
+ Effect7.mapError((error3) => new TestSpawnError({ command, message: String(error3) }))
2873
3118
  );
2874
3119
  const chunks = [];
2875
3120
  let exitCode = 1;
2876
- const child = Effect6.scoped(Effect6.gen(function* () {
3121
+ const child = Effect7.scoped(Effect7.gen(function* () {
2877
3122
  if (timeoutMs === void 0) yield* Console4.error(`Baseline command: ${formatTestCommand(command)} (cwd: ${dir.path})`);
2878
3123
  lastCommands.set(dir.path, command);
2879
3124
  yield* owned.trace("cold-spawn-start", { budgetMs: overallMs });
2880
- const handle = yield* spawner.spawn(ChildProcess2.make(command[0], command.slice(1), {
3125
+ const handle = yield* spawner.spawn(ChildProcess3.make(command[0], command.slice(1), {
2881
3126
  cwd: dir.path,
2882
3127
  env: owned.env,
2883
3128
  // Node's scoped spawner kills the detached process group, not just pnpm.
@@ -2886,36 +3131,36 @@ var TestRunnerLive = Layer3.effect(TestRunner, Effect6.gen(function* () {
2886
3131
  forceKillAfter: "100 millis",
2887
3132
  stdin: "ignore"
2888
3133
  }));
2889
- yield* Effect6.sync(() => owned.addRoot(handle.pid));
3134
+ yield* Effect7.sync(() => owned.addRoot(handle.pid));
2890
3135
  yield* owned.trace("cold-spawn", { childPid: handle.pid });
2891
- const collect = handle.all.pipe(Stream2.decodeText(), Stream2.runForEach((chunk) => Effect6.sync(() => {
3136
+ const collect = handle.all.pipe(Stream3.decodeText(), Stream3.runForEach((chunk) => Effect7.sync(() => {
2892
3137
  chunks.push(chunk);
2893
3138
  })));
2894
- const [code] = yield* Effect6.all([handle.exitCode.pipe(Effect6.tap(() => owned.cleanup)), collect], { concurrency: "unbounded" });
3139
+ const [code] = yield* Effect7.all([handle.exitCode.pipe(Effect7.tap(() => owned.cleanup)), collect], { concurrency: "unbounded" });
2895
3140
  exitCode = code;
2896
3141
  return code === 0 ? "passed" : "failed";
2897
- }).pipe(Effect6.onInterrupt(() => owned.cleanup)));
3142
+ }).pipe(Effect7.onInterrupt(() => owned.cleanup)));
2898
3143
  const status = yield* child.pipe(
2899
- Effect6.timeout(overallMs),
2900
- Effect6.catchTag("TimeoutError", () => Effect6.sync(() => {
3144
+ Effect7.timeout(overallMs),
3145
+ Effect7.catchTag("TimeoutError", () => Effect7.sync(() => {
2901
3146
  exitCode = 124;
2902
3147
  chunks.push(`
2903
3148
  Vitest timed out after ${overallMs}ms overall, including startup.
2904
3149
  `);
2905
3150
  return "timedOut";
2906
3151
  }))
2907
- ).pipe(Effect6.mapError((error3) => new TestSpawnError({ command, message: error3.message })));
3152
+ ).pipe(Effect7.mapError((error3) => new TestSpawnError({ command, message: error3.message })));
2908
3153
  yield* owned.cleanup;
2909
3154
  const ended = yield* Clock4.currentTimeMillis;
2910
3155
  const output = chunks.join("");
2911
3156
  const failed = output.includes(marker + "failed");
2912
3157
  const selection = output.split("\n").find((line) => line.includes(marker + "selected:"))?.split(marker + "selected:")[1];
2913
- const selected = selection === void 0 ? [] : yield* Schema8.decodeEffect(Schema8.fromJsonString(Schema8.Array(Schema8.String)))(selection).pipe(
2914
- Effect6.mapError((error3) => new TestSpawnError({ command, kind: "reporter", message: `Internal cold reporter protocol error in selected files: ${String(error3)}` }))
3158
+ const selected = selection === void 0 ? [] : yield* Schema9.decodeEffect(Schema9.fromJsonString(Schema9.Array(Schema9.String)))(selection).pipe(
3159
+ Effect7.mapError((error3) => new TestSpawnError({ command, kind: "reporter", message: `Internal cold reporter protocol error in selected files: ${String(error3)}` }))
2915
3160
  );
2916
3161
  const telemetryWarnings = [];
2917
3162
  for (const part of output.split(marker + "telemetryWarning:").slice(1)) {
2918
- const warning = Schema8.decodeOption(Schema8.fromJsonString(Schema8.String))(part.split("\n")[0]);
3163
+ const warning = Schema9.decodeOption(Schema9.fromJsonString(Schema9.String))(part.split("\n")[0]);
2919
3164
  if (warning._tag === "Some") telemetryWarnings.push(warning.value);
2920
3165
  }
2921
3166
  const testDurations = {};
@@ -2926,7 +3171,7 @@ Vitest timed out after ${overallMs}ms overall, including startup.
2926
3171
  for (const line of output.split("\n")) {
2927
3172
  const entry = line.split(marker + "duration:")[1];
2928
3173
  if (entry === void 0) continue;
2929
- const decoded = Schema8.decodeOption(Schema8.fromJsonString(Schema8.Struct({ file: Schema8.String, duration: Schema8.Finite, timeout: Schema8.Finite, key: Schema8.String, start: Schema8.Finite })))(entry);
3174
+ const decoded = Schema9.decodeOption(Schema9.fromJsonString(Schema9.Struct({ file: Schema9.String, duration: Schema9.Finite, timeout: Schema9.Finite, key: Schema9.String, start: Schema9.Finite })))(entry);
2930
3175
  if (decoded._tag === "None") {
2931
3176
  telemetryWarnings.push("Internal reporter telemetry error: invalid cold timing marker; omitted");
2932
3177
  continue;
@@ -2938,7 +3183,7 @@ Vitest timed out after ${overallMs}ms overall, including startup.
2938
3183
  testTimeouts[timing.file] = Math.max(testTimeouts[timing.file] ?? 0, timing.timeout);
2939
3184
  }
2940
3185
  for (const part of output.split(marker + "fileDuration:").slice(1)) {
2941
- const decoded = Schema8.decodeOption(Schema8.fromJsonString(Schema8.Struct({ file: Schema8.String, duration: Schema8.Finite })))(part.split("\n")[0]);
3186
+ const decoded = Schema9.decodeOption(Schema9.fromJsonString(Schema9.Struct({ file: Schema9.String, duration: Schema9.Finite })))(part.split("\n")[0]);
2942
3187
  if (decoded._tag === "None") {
2943
3188
  telemetryWarnings.push("Internal reporter telemetry error: invalid cold file timing marker; omitted");
2944
3189
  continue;
@@ -2965,13 +3210,13 @@ Vitest timed out after ${overallMs}ms overall, including startup.
2965
3210
  };
2966
3211
  const cleaned = cleanTelemetry(run2, "cold run");
2967
3212
  return { ...cleaned.value, backstopMs: backstopMs(), telemetryWarnings: [...telemetryWarnings, ...cleaned.warnings], exitCode };
2968
- }, Effect6.scoped);
3213
+ }, Effect7.scoped);
2969
3214
  return TestRunner.of({
2970
- stats: Effect6.sync(() => ({ hostRestarts, poolResets })),
2971
- open: Effect6.fn("TestRunner.open")(function* (dir, cold, warm = false, mutants = 1) {
3215
+ stats: Effect7.sync(() => ({ hostRestarts, poolResets })),
3216
+ open: Effect7.fn("TestRunner.open")(function* (dir, cold, warm = false, mutants = 1) {
2972
3217
  scopes.set(dir.path, yield* Scope3.Scope);
2973
3218
  openedAt.set(dir.path, yield* Clock4.currentTimeMillis);
2974
- yield* Effect6.addFinalizer(() => Effect6.sync(() => {
3219
+ yield* Effect7.addFinalizer(() => Effect7.sync(() => {
2975
3220
  sessions.delete(dir.path);
2976
3221
  selectors.delete(dir.path);
2977
3222
  auto.delete(dir.path);
@@ -2996,7 +3241,7 @@ Vitest timed out after ${overallMs}ms overall, including startup.
2996
3241
  const session = yield* openWarmRunner(dir, (reason) => {
2997
3242
  warmDisabled = true;
2998
3243
  modeReason = reason;
2999
- }, { ...sessionOptions, quiet: !warm, warn: warn6, onBackstop: onBackstop(dir.path), processesSince: openedAt.get(dir.path) }).pipe(Effect6.provideService(FileSystem7.FileSystem, fs), Effect6.mapError((error3) => error3._tag === "TestSpawnError" ? error3 : new TestSpawnError({ command: ["vitest", "warm"], message: String(error3) })));
3244
+ }, { ...sessionOptions, quiet: !warm, warn: warn7, onBackstop: onBackstop(dir.path), processesSince: openedAt.get(dir.path) }).pipe(Effect7.provideService(FileSystem7.FileSystem, fs), Effect7.mapError((error3) => error3._tag === "TestSpawnError" ? error3 : new TestSpawnError({ command: ["vitest", "warm"], message: String(error3) })));
3000
3245
  sessions.set(dir.path, session);
3001
3246
  if (warmDisabled || !warm && automaticMode === "cold") {
3002
3247
  yield* session.disable;
@@ -3005,8 +3250,8 @@ Vitest timed out after ${overallMs}ms overall, including startup.
3005
3250
  if (warm) modeReason = "Explicit --warm; supported configuration";
3006
3251
  if (!warm && automaticMode === "pending") auto.set(dir.path, { startupMs: (yield* Clock4.currentTimeMillis) - started, mutants });
3007
3252
  }),
3008
- invalidate: (dir, file) => sessions.get(dir.path)?.invalidate(file) ?? Effect6.void,
3009
- selectRelated: Effect6.fn("TestRunner.selectRelated")(function* (dir, file) {
3253
+ invalidate: (dir, file) => sessions.get(dir.path)?.invalidate(file) ?? Effect7.void,
3254
+ selectRelated: Effect7.fn("TestRunner.selectRelated")(function* (dir, file) {
3010
3255
  const session = sessions.get(dir.path);
3011
3256
  if (session !== void 0 && !warmDisabled) return yield* session.select(file);
3012
3257
  let selector = selectors.get(dir.path) ?? selectors.values().next().value;
@@ -3015,22 +3260,22 @@ Vitest timed out after ${overallMs}ms overall, including startup.
3015
3260
  if (!scope) return void 0;
3016
3261
  selector = yield* openWarmRunner(dir, () => {
3017
3262
  }, { quiet: true, selectionOnly: true, onBackstop: onBackstop(dir.path), processesSince: openedAt.get(dir.path) }).pipe(
3018
- Effect6.provideService(FileSystem7.FileSystem, fs),
3019
- Effect6.provideService(Scope3.Scope, scope),
3020
- Effect6.mapError((error3) => error3._tag === "TestSpawnError" ? error3 : new TestSpawnError({ command: ["vitest", "select"], message: String(error3) }))
3263
+ Effect7.provideService(FileSystem7.FileSystem, fs),
3264
+ Effect7.provideService(Scope3.Scope, scope),
3265
+ Effect7.mapError((error3) => error3._tag === "TestSpawnError" ? error3 : new TestSpawnError({ command: ["vitest", "select"], message: String(error3) }))
3021
3266
  );
3022
3267
  selectors.set(dir.path, selector);
3023
3268
  }
3024
3269
  return yield* selector.select(file);
3025
3270
  }),
3026
- probeReachability: Effect6.fn("TestRunner.probeReachability")(function* (dir, mutant, timeoutMs) {
3271
+ probeReachability: Effect7.fn("TestRunner.probeReachability")(function* (dir, mutant, timeoutMs) {
3027
3272
  if (!dir.poison) return { file: mutant.file, status: "unsupported", durationMs: 0, testCommand: [], output: "Scratch adapter cannot poison modules" };
3028
3273
  const temporary = yield* fs.makeTempDirectoryScoped({ prefix: "mutant-probe-" });
3029
3274
  const signal = path.join(temporary, "loaded");
3030
3275
  const control = path.join(temporary, "control");
3031
3276
  const token = `mutant-cafe-probe:${path.basename(temporary)}`;
3032
3277
  const setupFile = path.join(temporary, "setup.mjs");
3033
- const vitest = yield* Effect6.try({
3278
+ const vitest = yield* Effect7.try({
3034
3279
  try: () => pathToFileURL2(path.join(path.dirname(createRequire(path.join(dir.path, "package.json")).resolve("vitest/package.json")), "dist/index.js")).href,
3035
3280
  catch: (error3) => new TestSpawnError({ command: ["vitest", "probe"], message: String(error3) })
3036
3281
  });
@@ -3038,14 +3283,14 @@ Vitest timed out after ${overallMs}ms overall, including startup.
3038
3283
  beforeAll(() => globalThis.process.getBuiltinModule("node:fs").writeFileSync(${JSON.stringify(control)}, "ready"));
3039
3284
  afterAll(() => { if (globalThis[Symbol.for(${JSON.stringify(token)})]) throw new Error(${JSON.stringify(token)}); });`);
3040
3285
  const started = yield* Clock4.currentTimeMillis;
3041
- const invalidate = () => sessions.get(dir.path)?.invalidate(mutant.file) ?? Effect6.void;
3042
- const run2 = yield* Effect6.acquireUseRelease(
3286
+ const invalidate = () => sessions.get(dir.path)?.invalidate(mutant.file) ?? Effect7.void;
3287
+ const run2 = yield* Effect7.acquireUseRelease(
3043
3288
  dir.poison(mutant, signal, token),
3044
- () => Effect6.gen(function* () {
3289
+ () => Effect7.gen(function* () {
3045
3290
  yield* invalidate();
3046
3291
  return yield* execute2(dir, ["run", "--passWithNoTests"], timeoutMs, void 0, false, { token, setupFile });
3047
3292
  }),
3048
- () => dir.revert(mutant).pipe(Effect6.andThen(invalidate), Effect6.orDie)
3293
+ () => dir.revert(mutant).pipe(Effect7.andThen(invalidate), Effect7.orDie)
3049
3294
  );
3050
3295
  const supported = yield* fs.exists(control);
3051
3296
  const loaded = (yield* fs.exists(signal)) || run2.probeLoaded === true;
@@ -3056,21 +3301,21 @@ Vitest timed out after ${overallMs}ms overall, including startup.
3056
3301
  testCommand: run2.command,
3057
3302
  output: run2.output
3058
3303
  };
3059
- }, (effect5) => effect5.pipe(Effect6.scoped, Effect6.mapError((error3) => error3._tag === "ScratchError" || error3._tag === "TestSpawnError" ? error3 : new TestSpawnError({ command: ["vitest", "probe"], message: String(error3) })))),
3060
- baseline: Effect6.fn("TestRunner.baseline")(function* (dir, tsconfig, timeoutMs = DEFAULT_BASELINE_TIMEOUT_MS) {
3304
+ }, (effect5) => effect5.pipe(Effect7.scoped, Effect7.mapError((error3) => error3._tag === "ScratchError" || error3._tag === "TestSpawnError" ? error3 : new TestSpawnError({ command: ["vitest", "probe"], message: String(error3) })))),
3305
+ baseline: Effect7.fn("TestRunner.baseline")(function* (dir, tsconfig, timeoutMs = DEFAULT_BASELINE_TIMEOUT_MS) {
3061
3306
  baselineBudgetMs = timeoutMs;
3062
3307
  lastCommands.delete(dir.path);
3063
- const unreliable = yield* preflight(dir.path, tsconfig, timeoutMs, { processesSince: openedAt.get(dir.path), onBackstop: onBackstop(dir.path) }).pipe(Effect6.provideService(FileSystem7.FileSystem, fs), Effect6.provideService(ChildProcessSpawner3.ChildProcessSpawner, spawner), Effect6.catch((error3) => Effect6.succeed([{ kind: "warning", reason: `Cannot verify runner selection: ${String(error3)}` }])));
3308
+ const unreliable = yield* preflight(dir.path, tsconfig, timeoutMs, { processesSince: openedAt.get(dir.path), onBackstop: onBackstop(dir.path) }).pipe(Effect7.provideService(FileSystem7.FileSystem, fs), Effect7.provideService(ChildProcessSpawner5.ChildProcessSpawner, spawner), Effect7.catch((error3) => error3._tag === "TestSpawnError" && error3.kind === "vitest-version" ? Effect7.fail(error3) : Effect7.succeed([{ kind: "warning", reason: `Cannot verify runner selection: ${String(error3)}` }])));
3064
3309
  for (const issue of unreliable) yield* Console4.warn(`Warning (${issue.kind}): ${issue.reason}`);
3065
3310
  if (unreliable.some((issue) => issue.kind === "runner")) {
3066
3311
  const command = ["npx", "--no", "vitest", "run", "--passWithNoTests"];
3067
3312
  yield* Console4.warn(`Baseline command (not executed: unsupported runner): ${command.join(" ")}`);
3068
- return { durationMs: 0, testCommand: command, unreliable };
3313
+ return { durationMs: 0, testCommand: command, unreliable, runnerMode: "cold", runnerModeReason: "Unsupported test runner" };
3069
3314
  }
3070
3315
  const run2 = yield* execute2(dir, ["run", "--passWithNoTests"], void 0, void 0, auto.has(dir.path));
3071
3316
  if (run2.status === "timedOut") return yield* baselineTimedOut(timeoutMs, run2.command);
3072
3317
  if (run2.status !== "passed" && run2.status !== "untested") {
3073
- return yield* Effect6.fail(new BaselineFailed({ exitCode: run2.exitCode, output: run2.output, command: run2.command }));
3318
+ return yield* Effect7.fail(new BaselineFailed({ exitCode: run2.exitCode, output: run2.output, command: run2.command }));
3074
3319
  }
3075
3320
  if (sessions.has(dir.path)) yield* sessions.get(dir.path).invalidate(run2.testFiles?.[0] ?? "package.json");
3076
3321
  if (auto.has(dir.path)) primers.set(dir.path, run2);
@@ -3092,13 +3337,13 @@ Vitest timed out after ${overallMs}ms overall, including startup.
3092
3337
  runnerMode: sessions.has(dir.path) && !warmDisabled && !auto.has(dir.path) ? "warm" : "cold"
3093
3338
  };
3094
3339
  }, (effect5, dir, _tsconfig, timeoutMs = DEFAULT_BASELINE_TIMEOUT_MS) => effect5.pipe(
3095
- Effect6.timeout(timeoutMs),
3096
- Effect6.catchTag("TimeoutError", () => Effect6.fail(baselineTimedOut(timeoutMs, lastCommands.get(dir.path) ?? [])))
3340
+ Effect7.timeout(timeoutMs),
3341
+ Effect7.catchTag("TimeoutError", () => Effect7.fail(baselineTimedOut(timeoutMs, lastCommands.get(dir.path) ?? [])))
3097
3342
  )),
3098
- calibrate: Effect6.fn("TestRunner.calibrate")(function* (dir, mutants, copies) {
3343
+ calibrate: Effect7.fn("TestRunner.calibrate")(function* (dir, mutants, copies) {
3099
3344
  const primer = primers.get(dir.path) ?? primers.values().next().value;
3100
3345
  if (!primer || automaticMode !== "pending" || auto.size === 0 || warmDisabled) return {};
3101
- const disable = Effect6.gen(function* () {
3346
+ const disable = Effect7.gen(function* () {
3102
3347
  automaticMode = "cold";
3103
3348
  warmDisabled = true;
3104
3349
  auto.clear();
@@ -3107,7 +3352,6 @@ Vitest timed out after ${overallMs}ms overall, including startup.
3107
3352
  if (mutants <= (primer.testFiles?.length ?? 0)) {
3108
3353
  modeReason = `Auto: small selection (${mutants} testable mutants across ${primer.testFiles?.length ?? 0} files)`;
3109
3354
  yield* disable;
3110
- yield* Console4.warn(`Vitest auto mode: cold; small selection (${mutants} testable mutants across ${primer.testFiles?.length ?? 0} files), skipping paired calibration`);
3111
3355
  return { runnerMode: "cold", runnerModeReason: modeReason, testableMutants: mutants };
3112
3356
  }
3113
3357
  const startups = [...auto.values()].map((entry) => entry.startupMs);
@@ -3133,13 +3377,12 @@ Vitest timed out after ${overallMs}ms overall, including startup.
3133
3377
  modeReason = warmDisabled ? modeReason ?? "Warm execution failed during calibration" : !sameSelection || warm.status !== cold.status ? "Auto: cold/warm selection or status mismatch" : `Auto: paired measurements favor ${choice}`;
3134
3378
  automaticMode = choice;
3135
3379
  auto.clear();
3136
- yield* Console4.warn(`Vitest auto mode: ${choice}; paired cold ${cold.durationMs} ms, warm ${warm.durationMs} ms; ${mutants} testable mutants, ${copies} copies, startup ${calibration2.warmStartupMs} ms`);
3137
3380
  if (choice === "cold") yield* disable;
3138
3381
  else if (sessions.has(dir.path)) yield* sessions.get(dir.path).invalidate(warm.testFiles?.[0] ?? "package.json");
3139
3382
  const run2 = choice === "cold" ? cold : warm;
3140
3383
  return { runnerMode: choice, runnerModeReason: modeReason, calibration: calibration2, testableMutants: mutants, hostPid: run2.hostPid };
3141
3384
  }),
3142
- runRelated: Effect6.fn("TestRunner.runRelated")(function* (dir, file, timeoutMs, testTimeoutMs) {
3385
+ runRelated: Effect7.fn("TestRunner.runRelated")(function* (dir, file, timeoutMs, testTimeoutMs) {
3143
3386
  const related = yield* execute2(dir, ["related", file, "--run", "--passWithNoTests"], timeoutMs, testTimeoutMs);
3144
3387
  if (related.status !== "untested") return related;
3145
3388
  const remaining = Math.max(1, timeoutMs - related.durationMs);
@@ -3158,26 +3401,27 @@ Vitest timed out after ${overallMs}ms overall, including startup.
3158
3401
  // packages/runner/src/Run.ts
3159
3402
  import { createEffectActor as createEffectActor3, createEffectLogic as createEffectLogic2, join as join2, send as send3, setupEffect as setupEffect3 } from "@xstate/effect";
3160
3403
  import { types as types2 } from "xstate";
3161
- import * as Effect7 from "effect/Effect";
3404
+ import * as Effect8 from "effect/Effect";
3405
+ import * as Console5 from "effect/Console";
3162
3406
  import * as Pool from "effect/Pool";
3163
- import * as Path5 from "effect/Path";
3407
+ import * as Path7 from "effect/Path";
3164
3408
  import * as Result2 from "effect/Result";
3165
- import * as Schema9 from "effect/Schema";
3409
+ import * as Schema10 from "effect/Schema";
3166
3410
  import * as Scope5 from "effect/Scope";
3167
- import * as Stream3 from "effect/Stream";
3411
+ import * as Stream4 from "effect/Stream";
3168
3412
  var ScratchPool = class {
3169
3413
  value;
3170
3414
  constructor(value) {
3171
3415
  this.value = value;
3172
3416
  }
3173
3417
  };
3174
- var runMutants = Effect7.fn("Runner.runMutants")(function* (config, mutants) {
3418
+ var runMutants = Effect8.fn("Runner.runMutants")(function* (config, mutants) {
3175
3419
  const scratch = yield* Scratch;
3176
3420
  const tests = yield* TestRunner;
3177
3421
  const source = yield* MutantSource;
3178
3422
  const reporter = yield* Reporter;
3179
3423
  const scope = yield* Scope5.Scope;
3180
- const path = yield* Path5.Path;
3424
+ const path = yield* Path7.Path;
3181
3425
  const jobs = Math.max(1, Math.floor(config.jobs));
3182
3426
  const report = (state2) => sanitizeReportTelemetry({
3183
3427
  schemaVersion: 2,
@@ -3193,35 +3437,39 @@ var runMutants = Effect7.fn("Runner.runMutants")(function* (config, mutants) {
3193
3437
  ...state2.failure === void 0 ? {} : { failure: state2.failure._tag === "BaselineTimedOut" ? `BaselineTimedOut: ${state2.failure.message}` : state2.failure._tag === "BaselineFailed" ? `${state2.failure._tag}: ${formatTestCommand(state2.failure.command)}
3194
3438
  ${state2.failure.output.slice(-8e3)}` : String(state2.failure) }
3195
3439
  }).report;
3196
- const capture = (effect5) => Effect7.result(effect5);
3197
- const copying = createEffectLogic2(({ input }) => capture(Effect7.gen(function* () {
3198
- const acquire = Effect7.gen(function* () {
3440
+ const capture = (effect5) => Effect8.result(effect5);
3441
+ const copying = createEffectLogic2(({ input }) => capture(Effect8.gen(function* () {
3442
+ const acquire = Effect8.gen(function* () {
3199
3443
  const dir = yield* scratch.acquire(config.root);
3200
3444
  if (tests.open) yield* tests.open(dir, config.cold ?? false, config.warm ?? false, input);
3201
3445
  return dir;
3202
- }).pipe(Effect7.mapError((error3) => error3._tag === "ScratchError" ? error3 : new ScratchError({ operation: "warm runner", path: config.root, message: String(error3) })));
3446
+ }).pipe(Effect8.mapError((error3) => error3._tag === "ScratchError" ? error3 : new ScratchError({ operation: "warm runner", path: config.root, message: String(error3) })));
3203
3447
  const pool = yield* Pool.make({ acquire, size: jobs }).pipe(
3204
- Effect7.provideService(Scope5.Scope, scope)
3448
+ Effect8.provideService(Scope5.Scope, scope)
3205
3449
  );
3206
- yield* Effect7.scoped(Pool.get(pool));
3450
+ yield* Effect8.scoped(Pool.get(pool));
3207
3451
  return new ScratchPool(pool);
3208
3452
  })));
3209
- const baselining = createEffectLogic2(({ input }) => capture(Effect7.gen(function* () {
3210
- if (input === void 0) return yield* Effect7.die("Missing scratch pool");
3211
- const baseline = yield* Effect7.scoped(Effect7.gen(function* () {
3453
+ const baselining = createEffectLogic2(({ input }) => capture(Effect8.gen(function* () {
3454
+ if (input === void 0) return yield* Effect8.die("Missing scratch pool");
3455
+ const baseline = yield* Effect8.scoped(Effect8.gen(function* () {
3212
3456
  const dir = yield* Pool.get(input.value);
3213
3457
  return yield* tests.baseline(dir, path.isAbsolute(config.tsconfig) ? path.relative(config.root, config.tsconfig) : config.tsconfig, config.baselineTimeoutMs);
3214
3458
  }));
3215
3459
  return { baseline, timeoutMs: config.timeoutMs ?? Math.max(config.minimumTimeoutMs, Math.ceil(config.timeoutMultiplier * baseline.durationMs)) };
3216
3460
  })));
3217
- const generating = createEffectLogic2(() => capture(Stream3.runCollect(mutants ?? source.generate(config))));
3218
- const testing = createEffectLogic2(({ input }) => capture(Effect7.gen(function* () {
3461
+ const generating = createEffectLogic2(() => capture(Stream4.runCollect(mutants ?? source.generate(config))));
3462
+ const testing = createEffectLogic2(({ input }) => capture(Effect8.gen(function* () {
3219
3463
  const dirs = input.state.pool?.value;
3220
- if (dirs === void 0) return yield* Effect7.die("Missing scratch pool");
3464
+ if (dirs === void 0) return yield* Effect8.die("Missing scratch pool");
3465
+ const linkedRoots = yield* Effect8.scoped(Pool.get(dirs).pipe(Effect8.map((dir) => dir.linkedRoots ?? [])));
3466
+ const eligible = yield* excludeLinkedCandidates(config.root, input.state.pending, linkedRoots);
3467
+ for (const entry of eligible.notMutated) yield* input.skip(entry);
3468
+ const pending = eligible.mutants;
3221
3469
  let baseline = input.state.baseline;
3222
3470
  const viabilityById = /* @__PURE__ */ new Map();
3223
3471
  const preReported = /* @__PURE__ */ new Set();
3224
- if (!config.cold && !config.warm && tests.calibrate) yield* Effect7.forEach(input.state.pending, (mutant) => Effect7.gen(function* () {
3472
+ if (!config.cold && !config.warm && tests.calibrate) yield* Effect8.forEach(pending, (mutant) => Effect8.gen(function* () {
3225
3473
  const viability = yield* source.checkViable(mutant);
3226
3474
  viabilityById.set(mutant.id, viability);
3227
3475
  if (viability.analysisFailed) {
@@ -3240,13 +3488,13 @@ ${state2.failure.output.slice(-8e3)}` : String(state2.failure) }
3240
3488
  if (input.state.baseline.probeSupported && selectRelated && probeReachability) {
3241
3489
  const seen = /* @__PURE__ */ new Set();
3242
3490
  const builtTests = input.state.baseline.unreliable?.flatMap((issue) => issue.kind === "built" ? issue.testFiles : []) ?? [];
3243
- for (const mutant of input.state.pending) {
3491
+ for (const mutant of pending) {
3244
3492
  if (viabilityById.has(mutant.id) && !viabilityById.get(mutant.id)?.viable) continue;
3245
3493
  const file = path.isAbsolute(mutant.file) ? path.relative(config.root, mutant.file) : mutant.file;
3246
3494
  if (seen.has(file)) continue;
3247
3495
  seen.add(file);
3248
3496
  if (unreliableFor(input.state.baseline, file, builtTests).length) continue;
3249
- const probe2 = yield* Effect7.scoped(Effect7.gen(function* () {
3497
+ const probe2 = yield* Effect8.scoped(Effect8.gen(function* () {
3250
3498
  const dir = yield* Pool.get(dirs);
3251
3499
  if (!dir.poison) return void 0;
3252
3500
  const files = yield* selectRelated(dir, file);
@@ -3261,29 +3509,30 @@ ${state2.failure.output.slice(-8e3)}` : String(state2.failure) }
3261
3509
  }
3262
3510
  const calibrate = tests.calibrate;
3263
3511
  if (calibrate) {
3264
- const testable = input.state.pending.filter((mutant) => {
3512
+ const testable = pending.filter((mutant) => {
3265
3513
  const file = path.isAbsolute(mutant.file) ? path.relative(config.root, mutant.file) : mutant.file;
3266
3514
  return viabilityById.get(mutant.id)?.viable && !unreachable.has(file) && !unreliableFor(baseline, file).length;
3267
3515
  }).length;
3268
- const selected = yield* Effect7.scoped(Effect7.gen(function* () {
3516
+ const selected = yield* Effect8.scoped(Effect8.gen(function* () {
3269
3517
  const dir = yield* Pool.get(dirs);
3270
3518
  return yield* calibrate(dir, testable, config.jobs);
3271
3519
  }));
3272
3520
  baseline = { ...baseline, ...selected };
3273
3521
  yield* input.updateBaseline(baseline);
3274
3522
  }
3523
+ if (!config.cold && !config.warm) yield* Console5.warn(`Vitest auto mode: ${baseline.runnerMode ?? "cold"}; ${baseline.runnerModeReason ?? "Cold execution; no warm session"}`);
3275
3524
  const neverBudgets = /* @__PURE__ */ new Map();
3276
3525
  const neverLimits = /* @__PURE__ */ new Map();
3277
3526
  const neverBases = /* @__PURE__ */ new Map();
3278
3527
  const neverAllowances = /* @__PURE__ */ new Map();
3279
- for (const mutant of input.state.pending) {
3528
+ for (const mutant of pending) {
3280
3529
  if (viabilityById.has(mutant.id) && !viabilityById.get(mutant.id)?.viable) continue;
3281
3530
  if (unreachable.has(path.isAbsolute(mutant.file) ? path.relative(config.root, mutant.file) : mutant.file)) continue;
3282
3531
  if (mutant.genre !== "EffectNever" || neverBudgets.has(mutant.file) || unreliableFor(input.state.baseline, path.isAbsolute(mutant.file) ? path.relative(config.root, mutant.file) : mutant.file).length > 0) continue;
3283
3532
  let probeTimeout = Math.max(1, Math.floor(input.state.timeoutMs / 2));
3284
3533
  const originalTimeouts = new Set(Object.values(baseline.testTimeoutDetails ?? {}));
3285
3534
  while (originalTimeouts.has(probeTimeout)) probeTimeout++;
3286
- const measured = yield* Effect7.scoped(Effect7.gen(function* () {
3535
+ const measured = yield* Effect8.scoped(Effect8.gen(function* () {
3287
3536
  const dir = yield* Pool.get(dirs);
3288
3537
  return yield* tests.runRelated(dir, path.isAbsolute(mutant.file) ? path.relative(config.root, mutant.file) : mutant.file, input.state.timeoutMs, probeTimeout);
3289
3538
  }));
@@ -3304,8 +3553,8 @@ ${state2.failure.output.slice(-8e3)}` : String(state2.failure) }
3304
3553
  const explicit = Object.entries(baseline.testTimeoutDetails ?? {}).filter(([key, value]) => value > 0 && measured.testTimeoutDetails?.[key] === value).map(([, value]) => value);
3305
3554
  neverLimits.set(mutant.file, Math.max(0, ...explicit));
3306
3555
  }
3307
- yield* Stream3.fromIterable(input.state.pending).pipe(
3308
- Stream3.mapEffect((mutant) => Effect7.scoped(Effect7.gen(function* () {
3556
+ yield* Stream4.fromIterable(pending).pipe(
3557
+ Stream4.mapEffect((mutant) => Effect8.scoped(Effect8.gen(function* () {
3309
3558
  if (preReported.has(mutant.id)) return;
3310
3559
  const viability = viabilityById.get(mutant.id) ?? (yield* source.checkViable(mutant));
3311
3560
  if (viability.analysisFailed) {
@@ -3342,17 +3591,17 @@ ${state2.failure.output.slice(-8e3)}` : String(state2.failure) }
3342
3591
  const dir = yield* Pool.get(dirs);
3343
3592
  const testTimeoutMs = mutant.genre === "EffectNever" ? neverBudgets.get(mutant.file) : void 0;
3344
3593
  const timeoutMs = testTimeoutMs === void 0 ? input.state.timeoutMs : Math.max(testTimeoutMs, neverLimits.get(mutant.file) ?? 0) + (neverAllowances.get(mutant.file) ?? 0);
3345
- const run2 = yield* Effect7.acquireUseRelease(
3594
+ const run2 = yield* Effect8.acquireUseRelease(
3346
3595
  dir.apply(mutant),
3347
- () => Effect7.gen(function* () {
3596
+ () => Effect8.gen(function* () {
3348
3597
  if (tests.invalidate) yield* tests.invalidate(dir, localFile);
3349
3598
  return yield* tests.runRelated(dir, localFile, timeoutMs, testTimeoutMs);
3350
3599
  }),
3351
3600
  // Restore and re-invalidate even on interruption before leasing again.
3352
- () => Effect7.gen(function* () {
3601
+ () => Effect8.gen(function* () {
3353
3602
  yield* dir.revert(mutant);
3354
3603
  if (tests.invalidate) yield* tests.invalidate(dir, localFile);
3355
- }).pipe(Effect7.orDie)
3604
+ }).pipe(Effect8.orDie)
3356
3605
  );
3357
3606
  const selectedIssues = unreliableFor(input.state.baseline, localFile, run2.testFiles);
3358
3607
  const result5 = {
@@ -3374,18 +3623,18 @@ ${state2.failure.output.slice(-8e3)}` : String(state2.failure) }
3374
3623
  yield* input.record(result5);
3375
3624
  yield* reporter.progress(result5);
3376
3625
  })), { concurrency: jobs }),
3377
- Stream3.runDrain
3626
+ Stream4.runDrain
3378
3627
  );
3379
3628
  })));
3380
- const reporting = createEffectLogic2(({ input }) => capture(Effect7.gen(function* () {
3381
- const stats = yield* tests.stats ?? Effect7.succeed({ hostRestarts: 0, poolResets: 0 });
3629
+ const reporting = createEffectLogic2(({ input }) => capture(Effect8.gen(function* () {
3630
+ const stats = yield* tests.stats ?? Effect8.succeed({ hostRestarts: 0, poolResets: 0 });
3382
3631
  if (!input.reported) yield* reporter.write({ ...report(input), ...stats });
3383
3632
  return stats;
3384
3633
  })));
3385
3634
  const machine = setupEffect3({
3386
3635
  schemas: {
3387
3636
  context: types2(),
3388
- events: { CANCEL: Schema9.Struct({}), RESULT: Schema9.Struct({ result: MutantResult }), SKIP: Schema9.Struct({ entry: NotMutated }), PROBE: Schema9.Struct({ entry: ReachabilityProbe }), BASELINE: Schema9.Struct({ entry: Baseline }) }
3637
+ events: { CANCEL: Schema10.Struct({}), RESULT: Schema10.Struct({ result: MutantResult }), SKIP: Schema10.Struct({ entry: NotMutated }), PROBE: Schema10.Struct({ entry: ReachabilityProbe }), BASELINE: Schema10.Struct({ entry: Baseline }) }
3389
3638
  },
3390
3639
  actors: { copying, baselining, generating, testing, reporting }
3391
3640
  }).createMachine({
@@ -3463,47 +3712,47 @@ ${state2.failure.output.slice(-8e3)}` : String(state2.failure) }
3463
3712
  done: { type: "final" }
3464
3713
  }
3465
3714
  });
3466
- const state = yield* Effect7.scoped(Effect7.gen(function* () {
3715
+ const state = yield* Effect8.scoped(Effect8.gen(function* () {
3467
3716
  const actor = yield* createEffectActor3(machine);
3468
- return yield* join2(actor).pipe(Effect7.orDie, Effect7.onInterrupt(() => Effect7.gen(function* () {
3717
+ return yield* join2(actor).pipe(Effect8.orDie, Effect8.onInterrupt(() => Effect8.gen(function* () {
3469
3718
  yield* send3(actor, { type: "CANCEL" });
3470
- yield* join2(actor).pipe(Effect7.orDie);
3719
+ yield* join2(actor).pipe(Effect8.orDie);
3471
3720
  })));
3472
3721
  }));
3473
3722
  if (state.failure !== void 0) return yield* state.failure;
3474
3723
  return report(state);
3475
- }, Effect7.scoped);
3724
+ }, Effect8.scoped);
3476
3725
 
3477
3726
  // packages/cli/src/bin.ts
3478
- import * as Effect12 from "effect/Effect";
3727
+ import * as Effect13 from "effect/Effect";
3479
3728
  import * as Layer5 from "effect/Layer";
3480
- import * as Stream7 from "effect/Stream";
3729
+ import * as Stream8 from "effect/Stream";
3481
3730
 
3482
3731
  // packages/cli/src/Command.ts
3483
- import * as Console6 from "effect/Console";
3484
- import * as Effect11 from "effect/Effect";
3732
+ import * as Console7 from "effect/Console";
3733
+ import * as Effect12 from "effect/Effect";
3485
3734
  import * as FileSystem15 from "effect/FileSystem";
3486
3735
  import * as Option from "effect/Option";
3487
- import * as Path13 from "effect/Path";
3736
+ import * as Path15 from "effect/Path";
3488
3737
  import * as Ref from "effect/Ref";
3489
- import * as Schema13 from "effect/Schema";
3490
- import * as Stream6 from "effect/Stream";
3738
+ import * as Schema14 from "effect/Schema";
3739
+ import * as Stream7 from "effect/Stream";
3491
3740
  import * as Command from "effect/cli/Command";
3492
3741
  import * as Flag from "effect/cli/Flag";
3493
3742
 
3494
3743
  // packages/cli/src/Diff.ts
3495
- import * as Effect8 from "effect/Effect";
3744
+ import * as Effect9 from "effect/Effect";
3496
3745
  import * as FileSystem9 from "effect/FileSystem";
3497
- import * as Path7 from "effect/Path";
3498
- import * as Schema10 from "effect/Schema";
3499
- import * as Stream4 from "effect/Stream";
3500
- import * as ChildProcess3 from "effect/process/ChildProcess";
3501
- var DiffMismatch = class extends Schema10.TaggedError()("DiffMismatch", {
3502
- path: Schema10.String,
3503
- message: Schema10.String
3746
+ import * as Path9 from "effect/Path";
3747
+ import * as Schema11 from "effect/Schema";
3748
+ import * as Stream5 from "effect/Stream";
3749
+ import * as ChildProcess4 from "effect/process/ChildProcess";
3750
+ var DiffMismatch = class extends Schema11.TaggedError()("DiffMismatch", {
3751
+ path: Schema11.String,
3752
+ message: Schema11.String
3504
3753
  }) {
3505
3754
  };
3506
- var parseDiff = (text, path) => Effect8.try({
3755
+ var parseDiff = (text, path) => Effect9.try({
3507
3756
  try: () => {
3508
3757
  const fail4 = (message) => {
3509
3758
  throw new DiffParseError({ path, message });
@@ -3579,21 +3828,21 @@ var parseDiff = (text, path) => Effect8.try({
3579
3828
  if (!sawFile) fail4("No unified diff found");
3580
3829
  return patches;
3581
3830
  },
3582
- catch: (error3) => Schema10.is(DiffParseError)(error3) ? error3 : new DiffParseError({ path, message: String(error3) })
3831
+ catch: (error3) => Schema11.is(DiffParseError)(error3) ? error3 : new DiffParseError({ path, message: String(error3) })
3583
3832
  });
3584
- var selectDiffScope = Effect8.fn("selectDiffScope")(function* (options) {
3833
+ var selectDiffScope = Effect9.fn("selectDiffScope")(function* (options) {
3585
3834
  const fs = yield* FileSystem9.FileSystem;
3586
- const path = yield* Path7.Path;
3835
+ const path = yield* Path9.Path;
3587
3836
  const diffPath = path.resolve(options.root, options.diffPath);
3588
- const text = options.diffText ?? (yield* fs.readFileString(diffPath).pipe(Effect8.mapError((error3) => new DiffParseError({ path: diffPath, message: String(error3) }))));
3837
+ const text = options.diffText ?? (yield* fs.readFileString(diffPath).pipe(Effect9.mapError((error3) => new DiffParseError({ path: diffPath, message: String(error3) }))));
3589
3838
  const patches = yield* parseDiff(text, diffPath);
3590
- const gitRoot = yield* Effect8.scoped(Effect8.gen(function* () {
3591
- const handle = yield* ChildProcess3.make("git", ["rev-parse", "--show-toplevel"], { cwd: options.root, stderr: "ignore" });
3592
- const [output, code] = yield* Effect8.all([Stream4.mkString(Stream4.decodeText(handle.stdout)), handle.exitCode], { concurrency: "unbounded" });
3839
+ const gitRoot = yield* Effect9.scoped(Effect9.gen(function* () {
3840
+ const handle = yield* ChildProcess4.make("git", ["rev-parse", "--show-toplevel"], { cwd: options.root, stderr: "ignore" });
3841
+ const [output, code] = yield* Effect9.all([Stream5.mkString(Stream5.decodeText(handle.stdout)), handle.exitCode], { concurrency: "unbounded" });
3593
3842
  if (Number(code) !== 0 || !output.trim()) return options.root;
3594
3843
  const physicalRoot = yield* fs.realPath(options.root);
3595
3844
  return path.resolve(options.root, path.relative(physicalRoot, output.trim()));
3596
- })).pipe(Effect8.catch(() => Effect8.succeed(options.root)));
3845
+ })).pipe(Effect9.catch(() => Effect9.succeed(options.root)));
3597
3846
  const changed = /* @__PURE__ */ new Map();
3598
3847
  for (const patch of patches) {
3599
3848
  const repositoryPath = path.resolve(gitRoot, patch.file);
@@ -3605,7 +3854,7 @@ var selectDiffScope = Effect8.fn("selectDiffScope")(function* (options) {
3605
3854
  return yield* new DiffParseError({ path: diffPath, message: "Diff path escapes repository root" });
3606
3855
  }
3607
3856
  if (!(yield* fs.exists(candidate))) continue;
3608
- const current = yield* fs.readFileString(candidate).pipe(Effect8.mapError((error3) => new DiffMismatch({ path: patch.file, message: String(error3) })));
3857
+ const current = yield* fs.readFileString(candidate).pipe(Effect9.mapError((error3) => new DiffMismatch({ path: patch.file, message: String(error3) })));
3609
3858
  const lines2 = current.split("\n");
3610
3859
  const finalLine = current.endsWith("\n") ? lines2.length - 1 : lines2.length;
3611
3860
  if (patch.lines.every((line) => {
@@ -3639,6 +3888,8 @@ var errorExitCode = (error3) => {
3639
3888
  return 4;
3640
3889
  case "BaselineTimedOut":
3641
3890
  return 3;
3891
+ case "TestSpawnError":
3892
+ return error3.kind === "vitest-version" ? 8 : 70;
3642
3893
  case "DiffMismatch":
3643
3894
  return 5;
3644
3895
  case "DiffParseError":
@@ -3657,12 +3908,12 @@ var errorExitCode = (error3) => {
3657
3908
 
3658
3909
  // packages/cli/src/Reporter.ts
3659
3910
  import * as Clock5 from "effect/Clock";
3660
- import * as Console5 from "effect/Console";
3661
- import * as Effect9 from "effect/Effect";
3911
+ import * as Console6 from "effect/Console";
3912
+ import * as Effect10 from "effect/Effect";
3662
3913
  import * as FileSystem11 from "effect/FileSystem";
3663
3914
  import * as Layer4 from "effect/Layer";
3664
- import * as Path9 from "effect/Path";
3665
- import * as Schema11 from "effect/Schema";
3915
+ import * as Path11 from "effect/Path";
3916
+ import * as Schema12 from "effect/Schema";
3666
3917
  import * as Semaphore2 from "effect/Semaphore";
3667
3918
 
3668
3919
  // packages/cli/src/UnifiedDiff.ts
@@ -3788,14 +4039,14 @@ var shortType = (text) => {
3788
4039
  return line.length > 80 ? line.slice(0, 79) + "\u2026" : line;
3789
4040
  };
3790
4041
  var outcomes = ["caught", "missed", "timeout", "unviable", "untested", "unreliable"];
3791
- var jsonReport = Schema11.encodeEffect(Schema11.fromJsonString(RunReport));
4042
+ var jsonReport = Schema12.encodeEffect(Schema12.fromJsonString(RunReport));
3792
4043
  var logText = (result5) => [
3793
4044
  ..."output" in result5 && typeof result5.output === "string" ? [result5.output] : [],
3794
4045
  ...result5.diagnostics
3795
4046
  ].join("\n");
3796
- var makeReporter = Effect9.fn("makeReporter")(function* (options) {
4047
+ var makeReporter = Effect10.fn("makeReporter")(function* (options) {
3797
4048
  const fs = yield* FileSystem11.FileSystem;
3798
- const path = yield* Path9.Path;
4049
+ const path = yield* Path11.Path;
3799
4050
  const dir = path.resolve(options.root, options.outDir);
3800
4051
  const started = yield* Clock5.currentTimeMillis;
3801
4052
  const semaphore = yield* Semaphore2.make(1);
@@ -3809,7 +4060,7 @@ var makeReporter = Effect9.fn("makeReporter")(function* (options) {
3809
4060
  if (!/^[A-Za-z0-9_-]+$/.test(mutant.id) || ids.has(mutant.id)) return yield* writeError("Mutant ids must be unique safe filenames");
3810
4061
  ids.add(mutant.id);
3811
4062
  }
3812
- yield* Effect9.gen(function* () {
4063
+ yield* Effect10.gen(function* () {
3813
4064
  const relative2 = path.relative(dir, path.resolve(options.root));
3814
4065
  if (relative2 === "" || relative2 !== ".." && !relative2.startsWith(`..${path.sep}`) && !path.isAbsolute(relative2)) {
3815
4066
  return yield* new ReportWriteError({ path: dir, message: "Output cannot be the project root or an ancestor" });
@@ -3824,40 +4075,40 @@ var makeReporter = Effect9.fn("makeReporter")(function* (options) {
3824
4075
  }
3825
4076
  yield* fs.makeDirectory(path.join(dir, "diff"), { recursive: true });
3826
4077
  yield* fs.makeDirectory(path.join(dir, "logs"), { recursive: true });
3827
- }).pipe(Effect9.mapError(writeError));
3828
- const encodedMutants = yield* Schema11.encodeEffect(Schema11.fromJsonString(Schema11.Array(Mutant)))(options.mutants).pipe(Effect9.mapError(writeError));
3829
- yield* fs.writeFileString(path.join(dir, "mutants.json"), encodedMutants).pipe(Effect9.mapError(writeError));
4078
+ }).pipe(Effect10.mapError(writeError));
4079
+ const encodedMutants = yield* Schema12.encodeEffect(Schema12.fromJsonString(Schema12.Array(Mutant)))(options.mutants).pipe(Effect10.mapError(writeError));
4080
+ yield* fs.writeFileString(path.join(dir, "mutants.json"), encodedMutants).pipe(Effect10.mapError(writeError));
3830
4081
  yield* fs.writeFileString(path.join(dir, "not-mutated.txt"), (options.notMutated ?? []).map((item) => `${path.relative(options.root, item.file)}:${item.span?.start.line ?? "?"}:${item.span?.start.column ?? "?"}: ${item.functionName}: ${item.reason}
3831
- `).join("")).pipe(Effect9.mapError(writeError));
3832
- yield* Effect9.forEach(outcomes, (outcome) => fs.writeFileString(path.join(dir, `${outcome}.txt`), ""), { discard: true }).pipe(Effect9.mapError(writeError));
4082
+ `).join("")).pipe(Effect10.mapError(writeError));
4083
+ yield* Effect10.forEach(outcomes, (outcome) => fs.writeFileString(path.join(dir, `${outcome}.txt`), ""), { discard: true }).pipe(Effect10.mapError(writeError));
3833
4084
  for (const mutant of options.mutants) {
3834
- const original = yield* fs.readFileString(path.resolve(options.root, mutant.file)).pipe(Effect9.mapError(writeError));
3835
- yield* fs.writeFileString(path.join(dir, "diff", `${mutant.id}.diff`), unifiedDiff(original, original.slice(0, mutant.replacement.startOffset) + mutant.replacement.text + original.slice(mutant.replacement.endOffset), path.relative(options.root, path.resolve(options.root, mutant.file)).replaceAll("\\", "/"))).pipe(Effect9.mapError(writeError));
4085
+ const original = yield* fs.readFileString(path.resolve(options.root, mutant.file)).pipe(Effect10.mapError(writeError));
4086
+ yield* fs.writeFileString(path.join(dir, "diff", `${mutant.id}.diff`), unifiedDiff(original, original.slice(0, mutant.replacement.startOffset) + mutant.replacement.text + original.slice(mutant.replacement.endOffset), path.relative(options.root, path.resolve(options.root, mutant.file)).replaceAll("\\", "/"))).pipe(Effect10.mapError(writeError));
3836
4087
  }
3837
- const writeLists = (items) => Effect9.forEach(outcomes, (outcome) => {
4088
+ const writeLists = (items) => Effect10.forEach(outcomes, (outcome) => {
3838
4089
  const lines2 = items.filter((result5) => result5.outcome === outcome).map((result5) => mutantLine(result5.mutant, options.root, path));
3839
4090
  return fs.writeFileString(path.join(dir, `${outcome}.txt`), lines2.length === 0 ? "" : lines2.join("\n") + "\n");
3840
4091
  }, { discard: true });
3841
4092
  const service = Reporter.of({
3842
- progress: (result5) => semaphore.withPermit(Effect9.gen(function* () {
4093
+ progress: (result5) => semaphore.withPermit(Effect10.gen(function* () {
3843
4094
  results.push(result5);
3844
- if (!options.markdown?.stdout) yield* Console5.log(`${result5.outcome} ${mutantLine(result5.mutant, options.root, path)} (${result5.durationMs}ms)`);
3845
- yield* Effect9.gen(function* () {
4095
+ if (!options.markdown?.stdout) yield* Console6.log(`${result5.outcome} ${mutantLine(result5.mutant, options.root, path)} (${result5.durationMs}ms)`);
4096
+ yield* Effect10.gen(function* () {
3846
4097
  if (!ids.has(result5.mutant.id)) return yield* writeError("Progress result does not belong to this report");
3847
4098
  yield* writeLists(results);
3848
4099
  yield* fs.writeFileString(path.join(dir, "logs", `${result5.mutant.id}.log`), logText(result5));
3849
- }).pipe(Effect9.catch((error3) => Effect9.gen(function* () {
4100
+ }).pipe(Effect10.catch((error3) => Effect10.gen(function* () {
3850
4101
  if (pendingError === void 0) {
3851
4102
  pendingError = writeError(error3);
3852
- yield* Console5.warn(`Report write failed: ${pendingError.message}`);
4103
+ yield* Console6.warn(`Report write failed: ${pendingError.message}`);
3853
4104
  }
3854
4105
  })));
3855
4106
  })),
3856
- write: (report) => semaphore.withPermit(Effect9.gen(function* () {
4107
+ write: (report) => semaphore.withPermit(Effect10.gen(function* () {
3857
4108
  if (pendingError !== void 0) return yield* pendingError;
3858
4109
  const notMutated = [...new Map([...options.notMutated ?? [], ...report.notMutated ?? []].map((item) => [JSON.stringify(item), item])).values()];
3859
4110
  yield* fs.writeFileString(path.join(dir, "not-mutated.txt"), notMutated.map((item) => `${path.relative(options.root, item.file)}:${item.span?.start.line ?? "?"}:${item.span?.start.column ?? "?"}: ${item.functionName}: ${item.reason}
3860
- `).join("")).pipe(Effect9.mapError(writeError));
4111
+ `).join("")).pipe(Effect10.mapError(writeError));
3861
4112
  const telemetry = sanitizeReportTelemetry(report);
3862
4113
  const counted = {
3863
4114
  ...telemetry.report,
@@ -3866,64 +4117,64 @@ var makeReporter = Effect9.fn("makeReporter")(function* (options) {
3866
4117
  run: report.results.length,
3867
4118
  budgetSkipped: options.budgetSkipped ?? 0
3868
4119
  };
3869
- const encoded = yield* jsonReport(counted).pipe(Effect9.mapError(writeError));
3870
- yield* fs.writeFileString(path.join(dir, "outcomes.json.tmp"), encoded).pipe(Effect9.mapError(writeError));
3871
- yield* fs.rename(path.join(dir, "outcomes.json.tmp"), path.join(dir, "outcomes.json")).pipe(Effect9.mapError(writeError));
3872
- yield* writeLists(report.results).pipe(Effect9.mapError(writeError));
4120
+ const encoded = yield* jsonReport(counted).pipe(Effect10.mapError(writeError));
4121
+ yield* fs.writeFileString(path.join(dir, "outcomes.json.tmp"), encoded).pipe(Effect10.mapError(writeError));
4122
+ yield* fs.rename(path.join(dir, "outcomes.json.tmp"), path.join(dir, "outcomes.json")).pipe(Effect10.mapError(writeError));
4123
+ yield* writeLists(report.results).pipe(Effect10.mapError(writeError));
3873
4124
  for (const result5 of report.results) {
3874
4125
  if (!ids.has(result5.mutant.id)) return yield* writeError("Final result does not belong to this report");
3875
- yield* fs.writeFileString(path.join(dir, "logs", `${result5.mutant.id}.log`), logText(result5)).pipe(Effect9.mapError(writeError));
4126
+ yield* fs.writeFileString(path.join(dir, "logs", `${result5.mutant.id}.log`), logText(result5)).pipe(Effect10.mapError(writeError));
3876
4127
  }
3877
4128
  for (const warning of telemetry.warnings) if (!telemetryWarned.has(warning)) {
3878
4129
  telemetryWarned.add(warning);
3879
- yield* Console5.warn(warning);
4130
+ yield* Console6.warn(warning);
3880
4131
  }
3881
4132
  if (options.markdown !== void 0) {
3882
4133
  const markdown = markdownSummary({ ...options.markdown, root: options.root, path, report: counted, notMutated: notMutated.length });
3883
4134
  for (const file of new Set(options.markdown.files)) {
3884
- yield* fs.writeFileString(file, markdown).pipe(Effect9.mapError((error3) => new ReportWriteError({ path: file, message: String(error3) })));
4135
+ yield* fs.writeFileString(file, markdown).pipe(Effect10.mapError((error3) => new ReportWriteError({ path: file, message: String(error3) })));
3885
4136
  }
3886
- if (!summarized && options.markdown.stdout) yield* Console5.log(markdown);
4137
+ if (!summarized && options.markdown.stdout) yield* Console6.log(markdown);
3887
4138
  }
3888
4139
  if (summarized) return;
3889
4140
  summarized = true;
3890
- if (report.results.some((result5) => result5.outcome === "unreliable")) yield* Console5.warn("Unreliable: the configured Vitest run cannot see all tests. See unreliable.txt and per-mutant diagnostics; these are not missed mutants.");
4141
+ if (report.results.some((result5) => result5.outcome === "unreliable")) yield* Console6.warn("Unreliable: the configured Vitest run cannot see all tests. See unreliable.txt and per-mutant diagnostics; these are not missed mutants.");
3891
4142
  const elapsed = (yield* Clock5.currentTimeMillis) - started;
3892
- if (!options.markdown?.stdout) yield* Console5.log(countsLine(counted, notMutated.length) + `; ${(elapsed / 1e3).toFixed(2)}s`);
3893
- if (options.markdown === void 0 && report.failure !== void 0) yield* Console5.warn(report.failure);
4143
+ if (!options.markdown?.stdout) yield* Console6.log(countsLine(counted, notMutated.length) + `; ${(elapsed / 1e3).toFixed(2)}s`);
4144
+ if (options.markdown === void 0 && report.failure !== void 0) yield* Console6.warn(report.failure);
3894
4145
  }))
3895
4146
  });
3896
4147
  return service;
3897
4148
  });
3898
4149
 
3899
4150
  // packages/cli/src/Git.ts
3900
- import * as Effect10 from "effect/Effect";
4151
+ import * as Effect11 from "effect/Effect";
3901
4152
  import * as FileSystem13 from "effect/FileSystem";
3902
- import * as Path11 from "effect/Path";
3903
- import * as Schema12 from "effect/Schema";
3904
- import * as Stream5 from "effect/Stream";
3905
- import * as ChildProcess4 from "effect/process/ChildProcess";
3906
- var UsageError = class extends Schema12.TaggedError()("UsageError", { message: Schema12.String }) {
4153
+ import * as Path13 from "effect/Path";
4154
+ import * as Schema13 from "effect/Schema";
4155
+ import * as Stream6 from "effect/Stream";
4156
+ import * as ChildProcess5 from "effect/process/ChildProcess";
4157
+ var UsageError = class extends Schema13.TaggedError()("UsageError", { message: Schema13.String }) {
3907
4158
  };
3908
- var git = Effect10.fn("git")(function* (root, args) {
4159
+ var git = Effect11.fn("git")(function* (root, args) {
3909
4160
  const command = `git ${args.join(" ")}`;
3910
- return yield* Effect10.scoped(Effect10.gen(function* () {
3911
- const handle = yield* ChildProcess4.make("git", args, { cwd: root });
3912
- const [stdout, stderr, code] = yield* Effect10.all([
3913
- Stream5.mkString(Stream5.decodeText(handle.stdout)),
3914
- Stream5.mkString(Stream5.decodeText(handle.stderr)),
4161
+ return yield* Effect11.scoped(Effect11.gen(function* () {
4162
+ const handle = yield* ChildProcess5.make("git", args, { cwd: root });
4163
+ const [stdout, stderr, code] = yield* Effect11.all([
4164
+ Stream6.mkString(Stream6.decodeText(handle.stdout)),
4165
+ Stream6.mkString(Stream6.decodeText(handle.stderr)),
3915
4166
  handle.exitCode
3916
4167
  ], { concurrency: "unbounded" });
3917
4168
  if (Number(code) !== 0) return yield* new UsageError({ message: `${command}:
3918
4169
  ${stderr}` });
3919
4170
  return stdout;
3920
- })).pipe(Effect10.mapError((error3) => error3._tag === "UsageError" ? error3 : new UsageError({ message: `${command}: ${String(error3)}` })));
4171
+ })).pipe(Effect11.mapError((error3) => error3._tag === "UsageError" ? error3 : new UsageError({ message: `${command}: ${String(error3)}` })));
3921
4172
  });
3922
- var repositoryRoot = Effect10.fn("repositoryRoot")(function* (root) {
3923
- const path = yield* Path11.Path;
4173
+ var repositoryRoot = Effect11.fn("repositoryRoot")(function* (root) {
4174
+ const path = yield* Path13.Path;
3924
4175
  const fs = yield* FileSystem13.FileSystem;
3925
4176
  const top = (yield* git(root, ["rev-parse", "--show-toplevel"])).trim();
3926
- const physical = yield* fs.realPath(root).pipe(Effect10.mapError((error3) => new UsageError({ message: String(error3) })));
4177
+ const physical = yield* fs.realPath(root).pipe(Effect11.mapError((error3) => new UsageError({ message: String(error3) })));
3927
4178
  return path.resolve(root, path.relative(physical, top));
3928
4179
  });
3929
4180
 
@@ -3950,9 +4201,9 @@ var flags = {
3950
4201
  output: Flag.String("output").pipe(Flag.withDefault("mutants.out"), Flag.withDescription("Report directory; default mutants.out")),
3951
4202
  tsconfig: Flag.String("tsconfig").pipe(Flag.withDefault("tsconfig.json"), Flag.withDescription("TypeScript project path; default tsconfig.json"))
3952
4203
  };
3953
- var makeCommand = (options) => Command.make("mutant-cafe", flags, (input) => Effect11.gen(function* () {
4204
+ var makeCommand = (options) => Command.make("mutant-cafe", flags, (input) => Effect12.gen(function* () {
3954
4205
  const fs = yield* FileSystem15.FileSystem;
3955
- const path = yield* Path13.Path;
4206
+ const path = yield* Path15.Path;
3956
4207
  const root = path.resolve(options.root);
3957
4208
  if (input.cold && input.warm) return yield* new UsageError({ message: "--warm and --cold are mutually exclusive" });
3958
4209
  const range = Option.getOrUndefined(input.inDiffRange);
@@ -3966,15 +4217,15 @@ var makeCommand = (options) => Command.make("mutant-cafe", flags, (input) => Eff
3966
4217
  if (maxMutants !== void 0 && (!Number.isSafeInteger(maxMutants) || maxMutants < 0)) return yield* new UsageError({ message: "--max-mutants must be a nonnegative safe integer" });
3967
4218
  if (!["text", "json", "github"].includes(input.format) || input.format === "json" && !input.list) return yield* new UsageError({ message: "--format expects text, github, or json with --list" });
3968
4219
  if (/[\r\n]/.test(input.summaryMarker)) return yield* new UsageError({ message: "--summary-marker must be one line" });
3969
- const gitRoot = range !== void 0 ? yield* repositoryRoot(root) : yield* repositoryRoot(root).pipe(Effect11.catch(() => Effect11.succeed(root)));
4220
+ const gitRoot = range !== void 0 ? yield* repositoryRoot(root) : yield* repositoryRoot(root).pipe(Effect12.catch(() => Effect12.succeed(root)));
3970
4221
  const diffText = range === void 0 ? void 0 : yield* git(gitRoot, ["diff", "--no-ext-diff", "--no-color", range, "--"]);
3971
4222
  const configPath = path.join(root, "mutants.config.json");
3972
4223
  const fileConfig = (yield* fs.exists(configPath)) ? yield* fs.readFileString(configPath).pipe(
3973
- Effect11.flatMap(Schema13.decodeEffect(Schema13.fromJsonString(ConfigFile))),
3974
- Effect11.mapError((error3) => new UsageError({ message: `Invalid mutants.config.json: ${String(error3)}` }))
4224
+ Effect12.flatMap(Schema14.decodeEffect(Schema14.fromJsonString(ConfigFile))),
4225
+ Effect12.mapError((error3) => new UsageError({ message: `Invalid mutants.config.json: ${String(error3)}` }))
3975
4226
  ) : {};
3976
4227
  const timeoutMs = Option.map(input.timeout, (seconds) => Math.ceil(seconds * 1e3));
3977
- const config = yield* Schema13.decodeEffect(RunConfig)({
4228
+ const config = yield* Schema14.decodeEffect(RunConfig)({
3978
4229
  root,
3979
4230
  tsconfig: input.tsconfig,
3980
4231
  exportedOnly: input.exportedOnly,
@@ -3991,25 +4242,28 @@ var makeCommand = (options) => Command.make("mutant-cafe", flags, (input) => Eff
3991
4242
  minimumTimeoutMs: Option.match(input.minimumTimeout, { onNone: () => fileConfig.minimumTimeoutMs ?? 2e4, onSome: (seconds) => Math.ceil(seconds * 1e3) }),
3992
4243
  neverTimeoutMs: 1e3,
3993
4244
  outDir: input.output
3994
- }).pipe(Effect11.mapError((error3) => new UsageError({ message: String(error3) })));
4245
+ }).pipe(Effect12.mapError((error3) => new UsageError({ message: String(error3) })));
3995
4246
  if (config.jobs < 1 || config.timeoutMultiplier <= 0 || config.minimumTimeoutMs <= 0 || config.timeoutMs !== void 0 && config.timeoutMs <= 0 || config.baselineTimeoutMs !== void 0 && config.baselineTimeoutMs <= 0) {
3996
4247
  return yield* new UsageError({ message: "Jobs and timeout values must be positive" });
3997
4248
  }
3998
4249
  const source = yield* MutantSource;
3999
- const generated = yield* Stream6.runCollect(source.generate(config)).pipe(
4000
- Effect11.mapError((error3) => error3.reason === "selection" ? new UsageError({ message: error3.diagnostics.join("\n") }) : error3)
4250
+ const generated = yield* Stream7.runCollect(source.generate(config)).pipe(
4251
+ Effect12.mapError((error3) => error3.reason === "selection" ? new UsageError({ message: error3.diagnostics.join("\n") }) : error3)
4001
4252
  );
4002
4253
  const skipped2 = yield* source.notMutated(config);
4003
4254
  const selected = inDiff === void 0 && diffText === void 0 ? { mutants: generated, notMutated: skipped2 } : yield* selectDiffScope({ root, diffPath: inDiff ?? `git diff ${range}`, ...diffText === void 0 ? {} : { diffText }, mutants: generated, notMutated: skipped2 });
4255
+ const scratch = yield* Scratch;
4256
+ const roots = selected.mutants.length && scratch.inspect ? yield* scratch.inspect(root) : [];
4257
+ const eligible = yield* excludeLinkedCandidates(root, selected.mutants, roots);
4004
4258
  const relative2 = (mutant) => path.relative(gitRoot, path.resolve(root, mutant.file)).replaceAll("\\", "/");
4005
4259
  const compare = (a, b) => a < b ? -1 : a > b ? 1 : 0;
4006
- const ordered = [...selected.mutants].sort((a, b) => compare(relative2(a), relative2(b)) || a.span.start.line - b.span.start.line || a.span.start.column - b.span.start.column || compare(a.id, b.id));
4260
+ const ordered = [...eligible.mutants].sort((a, b) => compare(relative2(a), relative2(b)) || a.span.start.line - b.span.start.line || a.span.start.column - b.span.start.column || compare(a.id, b.id));
4007
4261
  const mutants = ordered.slice(0, maxMutants);
4008
- const notMutated = selected.notMutated;
4262
+ const notMutated = [...new Map([...selected.notMutated, ...eligible.notMutated].map((entry) => [JSON.stringify(entry), entry])).values()];
4009
4263
  const counts = { selected: ordered.length, run: 0, budgetSkipped: ordered.length - mutants.length };
4010
4264
  if (mutants.length === 0) {
4011
- const cause = ordered.length > 0 ? "budget" : range !== void 0 ? "range" : inDiff !== void 0 || diffText !== void 0 ? "diff" : config.functionFilter.length || config.exportedOnly ? "filter" : "file selection";
4012
- yield* Console6.error(`0 mutants selected (${counts.selected} before budget); cause: ${cause}. Baseline skipped.`);
4265
+ const cause = ordered.length > 0 ? "budget" : eligible.notMutated.length > 0 ? "linked ignored trees" : range !== void 0 ? "range" : inDiff !== void 0 || diffText !== void 0 ? "diff" : config.functionFilter.length || config.exportedOnly ? "filter" : "file selection";
4266
+ yield* Console7.error(`0 mutants selected (${counts.selected} before budget); cause: ${cause}. Baseline skipped.`);
4013
4267
  }
4014
4268
  const markdown = input.format === "github" || summaryMd !== void 0 ? {
4015
4269
  gitRoot,
@@ -4030,33 +4284,33 @@ var makeCommand = (options) => Command.make("mutant-cafe", flags, (input) => Eff
4030
4284
  report: { schemaVersion: 2, tool: "mutant.cafe", root, baseline: { durationMs: 0, testCommand: [] }, timeoutMs: 0, results: [], ...counts }
4031
4285
  });
4032
4286
  for (const file of new Set(markdown.files)) yield* fs.writeFileString(file, text).pipe(
4033
- Effect11.mapError((error3) => new ReportWriteError({ path: file, message: String(error3) }))
4287
+ Effect12.mapError((error3) => new ReportWriteError({ path: file, message: String(error3) }))
4034
4288
  );
4035
4289
  if (markdown.stdout) {
4036
- yield* Console6.log(text);
4290
+ yield* Console7.log(text);
4037
4291
  if (options.onExit !== void 0) yield* options.onExit(0);
4038
4292
  return;
4039
4293
  }
4040
4294
  }
4041
4295
  if (input.list && input.format === "json") {
4042
- yield* Console6.log(yield* Schema13.encodeEffect(Schema13.fromJsonString(MutantList))({ schemaVersion: 2, tool: "mutant.cafe", mutants, notMutated, counts }));
4296
+ yield* Console7.log(yield* Schema14.encodeEffect(Schema14.fromJsonString(MutantList))({ schemaVersion: 2, tool: "mutant.cafe", mutants, notMutated, counts }));
4043
4297
  if (options.onExit !== void 0) yield* options.onExit(0);
4044
4298
  return;
4045
4299
  }
4046
4300
  if (input.list) {
4047
- for (const mutant of mutants) yield* Console6.log(mutantLine(mutant, config.root, path));
4301
+ for (const mutant of mutants) yield* Console7.log(mutantLine(mutant, config.root, path));
4048
4302
  const perFile = /* @__PURE__ */ new Map();
4049
4303
  for (const mutant of mutants) {
4050
4304
  const file = path.relative(root, path.resolve(root, mutant.file));
4051
4305
  perFile.set(file, (perFile.get(file) ?? 0) + 1);
4052
4306
  }
4053
- for (const [file, count] of [...perFile].sort(([a], [b]) => a.localeCompare(b))) yield* Console6.log(`${file}: ${count} mutants`);
4054
- yield* Console6.log(`${mutants.length} mutants total; ${notMutated.length} not mutated; ${counts.selected} selected, 0 run, ${counts.budgetSkipped} budget-skipped`);
4307
+ for (const [file, count] of [...perFile].sort(([a], [b]) => a.localeCompare(b))) yield* Console7.log(`${file}: ${count} mutants`);
4308
+ yield* Console7.log(`${mutants.length} mutants total; ${notMutated.length} not mutated; ${counts.selected} selected, 0 run, ${counts.budgetSkipped} budget-skipped`);
4055
4309
  if (options.onExit !== void 0) yield* options.onExit(0);
4056
4310
  return;
4057
4311
  }
4058
4312
  const reporter = yield* makeReporter({ root, outDir: config.outDir, mutants, notMutated, selected: counts.selected, budgetSkipped: counts.budgetSkipped, ...markdown === void 0 ? {} : { markdown } });
4059
- const report = yield* (mutants.length === 0 ? Effect11.succeed({
4313
+ const report = yield* (mutants.length === 0 ? Effect12.succeed({
4060
4314
  schemaVersion: 2,
4061
4315
  tool: "mutant.cafe",
4062
4316
  root,
@@ -4064,8 +4318,8 @@ var makeCommand = (options) => Command.make("mutant-cafe", flags, (input) => Eff
4064
4318
  timeoutMs: 0,
4065
4319
  results: []
4066
4320
  }) : options.run(config, mutants)).pipe(
4067
- Effect11.provideService(Reporter, reporter),
4068
- Effect11.catchTag("BaselineFailed", (error3) => Effect11.gen(function* () {
4321
+ Effect12.provideService(Reporter, reporter),
4322
+ Effect12.catchTag("BaselineFailed", (error3) => Effect12.gen(function* () {
4069
4323
  const failed = {
4070
4324
  schemaVersion: 2,
4071
4325
  tool: "mutant.cafe",
@@ -4078,10 +4332,10 @@ ${error3.output.slice(-8e3)}`
4078
4332
  };
4079
4333
  yield* reporter.write(failed);
4080
4334
  if (!input.advisory) return yield* error3;
4081
- if (markdown === void 0) yield* Console6.log("Advisory: baseline failed; would exit 4 without --advisory.");
4335
+ if (markdown === void 0) yield* Console7.log("Advisory: baseline failed; would exit 4 without --advisory.");
4082
4336
  return failed;
4083
4337
  })),
4084
- Effect11.catchTag("BaselineTimedOut", (error3) => Effect11.gen(function* () {
4338
+ Effect12.catchTag("BaselineTimedOut", (error3) => Effect12.gen(function* () {
4085
4339
  const timedOut = {
4086
4340
  schemaVersion: 2,
4087
4341
  tool: "mutant.cafe",
@@ -4096,22 +4350,22 @@ ${error3.output.slice(-8e3)}`
4096
4350
  return timedOut;
4097
4351
  }))
4098
4352
  );
4099
- if (input.advisory && reportExitCode(report) !== 0 && markdown === void 0) yield* Console6.log(`Advisory: would exit ${reportExitCode(report)} without --advisory.`);
4353
+ if (input.advisory && reportExitCode(report) !== 0 && markdown === void 0) yield* Console7.log(`Advisory: would exit ${reportExitCode(report)} without --advisory.`);
4100
4354
  yield* reporter.write(report);
4101
4355
  if (options.onExit !== void 0) yield* options.onExit(input.advisory ? 0 : reportExitCode(report));
4102
4356
  }));
4103
- var runCli = Effect11.fn("runCli")(function* (options) {
4357
+ var runCli = Effect12.fn("runCli")(function* (options) {
4104
4358
  const code = yield* Ref.make(0);
4105
4359
  const command = makeCommand({ ...options, onExit: (value) => Ref.set(code, value) });
4106
- yield* Command.runWith(command, { version: "0.1.6" })(options.args).pipe(
4107
- Effect11.catch((error3) => Effect11.gen(function* () {
4108
- yield* Console6.error(error3._tag === "ProgramLoadError" ? `${error3.tsconfig}:
4109
- ${error3.diagnostics.join("\n")}` : error3._tag === "BaselineTimedOut" ? error3.message : error3._tag === "BaselineFailed" ? `Baseline failed (${error3.exitCode}): ${formatTestCommand(error3.command)}
4360
+ yield* Command.runWith(command, { version: "0.1.7" })(options.args).pipe(
4361
+ Effect12.catch((error3) => Effect12.gen(function* () {
4362
+ yield* Console7.error(error3._tag === "ProgramLoadError" ? `${error3.tsconfig}:
4363
+ ${error3.diagnostics.join("\n")}` : error3._tag === "TestSpawnError" && error3.kind === "vitest-version" ? error3.message : error3._tag === "BaselineTimedOut" ? error3.message : error3._tag === "BaselineFailed" ? `Baseline failed (${error3.exitCode}): ${formatTestCommand(error3.command)}
4110
4364
  ${error3.output.slice(-8e3)}` : String(error3));
4111
4365
  yield* Ref.set(code, errorExitCode(error3));
4112
4366
  })),
4113
- Effect11.catchDefect((defect) => Effect11.gen(function* () {
4114
- yield* Console6.error(`Internal error: ${String(defect)}`);
4367
+ Effect12.catchDefect((defect) => Effect12.gen(function* () {
4368
+ yield* Console7.error(`Internal error: ${String(defect)}`);
4115
4369
  yield* Ref.set(code, 70);
4116
4370
  }))
4117
4371
  );
@@ -4119,15 +4373,15 @@ ${error3.output.slice(-8e3)}` : String(error3));
4119
4373
  });
4120
4374
 
4121
4375
  // packages/cli/src/bin.ts
4122
- var run = (config, mutants) => runMutants(config, Stream7.fromIterable(mutants));
4376
+ var run = (config, mutants) => runMutants(config, Stream8.fromIterable(mutants));
4123
4377
  var live = Layer5.mergeAll(MutantSourceLive, ScratchLive, TestRunnerLive).pipe(
4124
4378
  Layer5.provideMerge(NodeServices.layer)
4125
4379
  );
4126
- var main = Effect12.gen(function* () {
4380
+ var main = Effect13.gen(function* () {
4127
4381
  const code = yield* runCli({ root: process.cwd(), args: process.argv.slice(2), run });
4128
- yield* Effect12.sync(() => {
4382
+ yield* Effect13.sync(() => {
4129
4383
  process.exitCode = code;
4130
4384
  });
4131
- }).pipe(Effect12.provide(live));
4385
+ }).pipe(Effect13.provide(live));
4132
4386
  NodeRuntime.runMain(main);
4133
4387
  //# sourceMappingURL=bin.js.map