loki-mode 11.153.0 → 11.155.0

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.
Files changed (68) hide show
  1. package/SKILL.md +2 -2
  2. package/VERSION +1 -1
  3. package/dashboard/__init__.py +1 -1
  4. package/docs/CLI-REFERENCE.md +1 -1
  5. package/docs/INSTALLATION.md +1 -1
  6. package/docs/dev/architecture-reference.md +1 -1
  7. package/loki-ts/dist/loki.js +1901 -1899
  8. package/mcp/__init__.py +1 -1
  9. package/package.json +2 -2
  10. package/packages/control-plane/dist/server.js +820 -361
  11. package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
  12. package/web-app/dist/assets/{AdminPage-DbZu7ddP.js → AdminPage-Boa67lzh.js} +1 -1
  13. package/web-app/dist/assets/{Avatar-DAUwn6hI.js → Avatar-C3DI3EEn.js} +1 -1
  14. package/web-app/dist/assets/{Badge-jfM-X3V8.js → Badge-BnGLw1fJ.js} +1 -1
  15. package/web-app/dist/assets/{Button-DPQtwxuu.js → Button-ZMnLNI7o.js} +1 -1
  16. package/web-app/dist/assets/{CockpitPage-_R18YJ80.js → CockpitPage-DIIqR58D.js} +1 -1
  17. package/web-app/dist/assets/{ComparePage-B8G0ncAB.js → ComparePage-CDsN66rY.js} +1 -1
  18. package/web-app/dist/assets/{ErrorBoundary-BfsmlmUv.js → ErrorBoundary-DrZ3fY1U.js} +1 -1
  19. package/web-app/dist/assets/{EvidenceReceiptPanel-C2cDyG7P.js → EvidenceReceiptPanel-CZcqcDS3.js} +1 -1
  20. package/web-app/dist/assets/{GitHubIssuesPanel-m_epB_9T.js → GitHubIssuesPanel-COUvczPk.js} +1 -1
  21. package/web-app/dist/assets/{GitHubPRsPanel-C3e2E4tR.js → GitHubPRsPanel-DbooMfZ0.js} +1 -1
  22. package/web-app/dist/assets/{HomePage-DufEN9yU.js → HomePage-DGuRFkHe.js} +2 -2
  23. package/web-app/dist/assets/{LoginPage-B9crVo53.js → LoginPage--OEMrZWJ.js} +1 -1
  24. package/web-app/dist/assets/{MagicPage-D2CxnNve.js → MagicPage-DcY1ZUQz.js} +1 -1
  25. package/web-app/dist/assets/{MetricsPage-CB89RXmW.js → MetricsPage-Zck3H8PY.js} +1 -1
  26. package/web-app/dist/assets/{NotFoundPage-DsT1R9Nv.js → NotFoundPage-q-O5Dgw8.js} +1 -1
  27. package/web-app/dist/assets/{ProjectPage-DUB7qHau.js → ProjectPage-DKEhIWSM.js} +3 -3
  28. package/web-app/dist/assets/{ProjectsPage-BGXk5sdH.js → ProjectsPage-4qJqGKCc.js} +1 -1
  29. package/web-app/dist/assets/{SettingsPage-CM-HClE1.js → SettingsPage-Dhwccm2t.js} +1 -1
  30. package/web-app/dist/assets/{ShowcasePage-bIdIymaJ.js → ShowcasePage-r2OE0IpC.js} +1 -1
  31. package/web-app/dist/assets/{SystemSettingsPage-Cepwl537.js → SystemSettingsPage-C6DmgimV.js} +1 -1
  32. package/web-app/dist/assets/{TeamsPage-BxtK3rw2.js → TeamsPage-Bs9BwK8e.js} +1 -1
  33. package/web-app/dist/assets/{TemplatesPage-qwpDk5T0.js → TemplatesPage-GmpwmgEh.js} +1 -1
  34. package/web-app/dist/assets/{TerminalOutput-BnM3M3pB.js → TerminalOutput-CaofkqFm.js} +1 -1
  35. package/web-app/dist/assets/{activity-CawceXZd.js → activity-D-14EqSb.js} +1 -1
  36. package/web-app/dist/assets/{bell-CsKWxejH.js → bell-C1c4rghW.js} +1 -1
  37. package/web-app/dist/assets/{bot-D3510Z28.js → bot-BqSfqVvF.js} +1 -1
  38. package/web-app/dist/assets/{check-C2LOCCOY.js → check-CahavLb3.js} +1 -1
  39. package/web-app/dist/assets/{chevron-left-BB9kFeem.js → chevron-left-DUt0IVom.js} +1 -1
  40. package/web-app/dist/assets/{circle-alert-B2Cp1Ig9.js → circle-alert-geBwxian.js} +1 -1
  41. package/web-app/dist/assets/{clock-CMyPpDIq.js → clock-BsJao1Wl.js} +1 -1
  42. package/web-app/dist/assets/{cloud-PSbWAP8z.js → cloud-PePBuFR2.js} +1 -1
  43. package/web-app/dist/assets/{code-xml-BrxGLiE7.js → code-xml-B30O5Rvg.js} +1 -1
  44. package/web-app/dist/assets/{database-Dvb3EBwQ.js → database-BdxKkqEA.js} +1 -1
  45. package/web-app/dist/assets/{dollar-sign-B04ktJSv.js → dollar-sign-Byx9c05P.js} +1 -1
  46. package/web-app/dist/assets/{file-code-corner-CohHD1q-.js → file-code-corner-BxPRoPfK.js} +1 -1
  47. package/web-app/dist/assets/{file-plus-CNXxBPL0.js → file-plus-CK_Y36Mo.js} +1 -1
  48. package/web-app/dist/assets/{globe-VbFCeKXo.js → globe-Bakqsa6G.js} +1 -1
  49. package/web-app/dist/assets/{hammer-zDl_5fsf.js → hammer-2bumN232.js} +1 -1
  50. package/web-app/dist/assets/{index-B9FaIM3t.js → index-hm-yRBoI.js} +3 -3
  51. package/web-app/dist/assets/{layers-ybdXw7tA.js → layers-Ba8SyI41.js} +1 -1
  52. package/web-app/dist/assets/{loader-circle-Df0W4piv.js → loader-circle-BB-t0hUZ.js} +1 -1
  53. package/web-app/dist/assets/{lock-BwHhoraW.js → lock-geLwsvEJ.js} +1 -1
  54. package/web-app/dist/assets/{package-DvX-5_gZ.js → package-CilxqDqb.js} +1 -1
  55. package/web-app/dist/assets/{plus-C8BtEtIx.js → plus-eS9shrSX.js} +1 -1
  56. package/web-app/dist/assets/{refresh-cw-DzlXJr-S.js → refresh-cw-sd9kWzxP.js} +1 -1
  57. package/web-app/dist/assets/{rotate-ccw-CEzK4HJF.js → rotate-ccw-fpPuQpml.js} +1 -1
  58. package/web-app/dist/assets/{scroll-text-c7tRHJkn.js → scroll-text-BwAKCqKY.js} +1 -1
  59. package/web-app/dist/assets/{server-kPzCaOGi.js → server-BD2uVpGr.js} +1 -1
  60. package/web-app/dist/assets/{shield-alert-5XEfb5as.js → shield-alert-Dru2kiyn.js} +1 -1
  61. package/web-app/dist/assets/{thumbs-up-ZMTB2fvb.js → thumbs-up-Bvz7N-Kv.js} +1 -1
  62. package/web-app/dist/assets/{trash-2-C_NKhJ52.js → trash-2-u0TXHYJE.js} +1 -1
  63. package/web-app/dist/assets/{trending-down-B5RqvF8F.js → trending-down-CnhmwKMr.js} +1 -1
  64. package/web-app/dist/assets/{trending-up-BRi1caL4.js → trending-up-DyzE_6em.js} +1 -1
  65. package/web-app/dist/assets/{upload-DVYE4Uwe.js → upload-CsyUlDw7.js} +1 -1
  66. package/web-app/dist/assets/{usePolling-CJhQhw27.js → usePolling-2de8HDwC.js} +1 -1
  67. package/web-app/dist/assets/{user-DbKPy6Y-.js → user--P3saPpx.js} +1 -1
  68. package/web-app/dist/index.html +1 -1
@@ -16929,6 +16929,7 @@ __export(exports_repo_profile, {
16929
16929
  profileBrief: () => profileBrief,
16930
16930
  pickRunnable: () => pickRunnable,
16931
16931
  oneBaseRunOn: () => oneBaseRunOn,
16932
+ multiPackageRepo: () => multiPackageRepo,
16932
16933
  manifestModel: () => manifestModel,
16933
16934
  manifestHash: () => manifestHash,
16934
16935
  loadProfile: () => loadProfile,
@@ -16946,12 +16947,15 @@ __export(exports_repo_profile, {
16946
16947
  buildProfileCached: () => buildProfileCached,
16947
16948
  buildProfile: () => buildProfile,
16948
16949
  baselineSuites: () => baselineSuites,
16950
+ baselineSuiteOnDemand: () => baselineSuiteOnDemand,
16949
16951
  baselineCmdS: () => baselineCmdS,
16950
16952
  baseRedByIdOn: () => baseRedByIdOn,
16951
16953
  baseRedById: () => baseRedById,
16954
+ baseOnDemandOn: () => baseOnDemandOn,
16952
16955
  attributeStatic: () => attributeStatic,
16953
16956
  attributeFullSuite: () => attributeFullSuite,
16954
16957
  attribute: () => attribute,
16958
+ asyncShellRunner: () => asyncShellRunner,
16955
16959
  TOUCHED_RED: () => TOUCHED_RED,
16956
16960
  SUITE_BASELINE_BUDGET_S: () => SUITE_BASELINE_BUDGET_S,
16957
16961
  SAME_RED_NOTE: () => SAME_RED_NOTE,
@@ -16960,6 +16964,7 @@ __export(exports_repo_profile, {
16960
16964
  MANIFESTS: () => MANIFESTS,
16961
16965
  INTAKE_BUDGET_LINE: () => INTAKE_BUDGET_LINE,
16962
16966
  FLAKE_PROBE_MAX_S: () => FLAKE_PROBE_MAX_S,
16967
+ BASE_DEFERRED: () => BASE_DEFERRED,
16963
16968
  BASELINE_CMD_TIMEOUT_S: () => BASELINE_CMD_TIMEOUT_S
16964
16969
  });
16965
16970
  import { createHash as createHash14 } from "crypto";
@@ -17403,6 +17408,9 @@ function runOnce(repoDir, cmd, cwd, tmo, opts) {
17403
17408
  const r = (opts.run ?? shellRunner)(cmd, cwd, tmo * 1000);
17404
17409
  const dur = Math.round((Date.now() - started) / 100) / 10;
17405
17410
  rmNewUntracked(repoDir, before);
17411
+ return measured(repoDir, cmd, r, dur);
17412
+ }
17413
+ function measured(repoDir, cmd, r, dur) {
17406
17414
  const ids = r.code !== 0 && !r.timedOut ? failIds(r.out).length ? failIds(r.out) : isExitCodedScript(cmd) && r.code !== null ? [exitCodedId(cmd, r.out, repoDir) ?? []].flat() : [] : [], missing = r.missing === true;
17407
17415
  const attributable = !r.timedOut && !missing && r.code !== null && (r.code === 0 || ids.length > 0);
17408
17416
  const reason = attributable ? undefined : r.timedOut ? "timed out" : missing ? "command not found" : "failing test ids not parseable, failures cannot be attributed";
@@ -17414,11 +17422,13 @@ function runProbed(repoDir, cmd, cwd, tmo, opts) {
17414
17422
  return { b: { ...b, flaky_probe: "done" }, missing: first.missing };
17415
17423
  if (b.timed_out || first.missing || (b.duration_s ?? 0) > FLAKE_PROBE_MAX_S)
17416
17424
  return { b: { ...b, flaky_probe: `skipped: first pass ${b.duration_s ?? "?"}s` }, missing: first.missing };
17417
- const second = runOnce(repoDir, cmd, cwd, tmo, opts).b;
17425
+ return { b: probeMerge(b, runOnce(repoDir, cmd, cwd, tmo, opts).b), missing: first.missing };
17426
+ }
17427
+ function probeMerge(b, second) {
17418
17428
  if (second.timed_out || second.exit_code === null)
17419
- return { b: { ...b, flaky_probe: "skipped: second pass did not finish" }, missing: first.missing };
17429
+ return { ...b, flaky_probe: "skipped: second pass did not finish" };
17420
17430
  const one = new Set(b.failing_ids), two = new Set(second.failing_ids), flaky = [...one].filter((i) => !two.has(i)).concat([...two].filter((i) => !one.has(i)));
17421
- return { b: { ...b, flaky_probe: "done", ...flaky.length ? { flaky_ids: flaky, failing_errors: { ...second.failing_errors ?? {}, ...b.failing_errors ?? {} } } : {} }, missing: first.missing };
17431
+ return { ...b, flaky_probe: "done", ...flaky.length ? { flaky_ids: flaky, failing_errors: { ...second.failing_errors ?? {}, ...b.failing_errors ?? {} } } : {} };
17422
17432
  }
17423
17433
  function runBaseline(repoDir, commands, opts = {}) {
17424
17434
  const t = commands.find((c) => c.kind === "test");
@@ -17476,8 +17486,11 @@ function baselineSuites(repoDir, specs, opts = {}) {
17476
17486
  let left = Math.min(opts.budgetS ?? SUITE_BASELINE_BUDGET_S, dl());
17477
17487
  const old = p.suites ?? [];
17478
17488
  const rootSpeaks = (run2) => repoRelCmd(repoDir, run2) === repoRelCmd(repoDir, p.baseline.command ?? "") || p.baseline.ran && p.baseline.attributable && !p.baseline.timed_out && sameRootScript(repoDir, p.baseline.command ?? "", run2);
17489
+ const lazy = baseOnDemandOn() && (specs.some((s) => s.cwd !== ".") || p.baseline.reason === BASE_DEFERRED);
17479
17490
  p.suites = specs.filter((s) => s.cwd !== "." || !rootSpeaks(s.run)).map((s) => {
17480
17491
  const prev = old.find((o) => o.command === s.cmd);
17492
+ if (lazy)
17493
+ return prev?.ran && !opts.rerun && !prev.timed_out && (prev.failing_ids.length === 0 || prev.failing_errors && prev.flaky_probe !== undefined) ? prev : { name: s.name, ran: false, command: s.cmd, exit_code: null, duration_s: null, timed_out: false, failing_ids: [], attributable: false, reason: BASE_DEFERRED };
17481
17494
  if (prev?.ran && !opts.rerun && !cutShort(prev, Math.min(opts.timeoutS ?? BASELINE_CMD_TIMEOUT_S, Math.floor(left))) && (prev.failing_ids.length === 0 || prev.failing_errors && prev.flaky_probe !== undefined))
17482
17495
  return prev;
17483
17496
  const tmo = Math.min(opts.timeoutS ?? BASELINE_CMD_TIMEOUT_S, Math.floor(left)), t0 = Date.now();
@@ -17498,6 +17511,69 @@ function baselineSuites(repoDir, specs, opts = {}) {
17498
17511
  return null;
17499
17512
  }
17500
17513
  }
17514
+ async function baselineSuiteOnDemand(repoDir, baseSha, spec, baseDir, runner, timeoutS, stopped = () => false) {
17515
+ try {
17516
+ const p = loadProfile(repoDir);
17517
+ if (!p || !baseSha || p.revision !== baseSha || timeoutS < 1)
17518
+ return false;
17519
+ const usable = (b2) => !!b2?.ran && !cutShort(b2, timeoutS) && (b2.failing_ids.length === 0 || !!b2.failing_errors && b2.flaky_probe !== undefined);
17520
+ const root = spec.cwd === "." && (repoRelCmd(repoDir, spec.run) === repoRelCmd(repoDir, p.baseline.command ?? "") || repoRelCmd(baseDir, spec.run) === repoRelCmd(repoDir, p.baseline.command ?? ""));
17521
+ if (usable(root ? p.baseline : p.suites?.find((o) => o.command === spec.cmd)))
17522
+ return true;
17523
+ if (root && p.baseline.ran && p.baseline.reason !== BASE_DEFERRED)
17524
+ return true;
17525
+ const dirs = [baseDir];
17526
+ try {
17527
+ dirs.push(realpathSync16(baseDir));
17528
+ } catch {}
17529
+ const home = (out2) => {
17530
+ let o = out2;
17531
+ for (const d of [...new Set(dirs.flatMap((x) => [x, x.startsWith("/private/") ? x.slice("/private".length) : `/private${x}`]))].sort((a, b2) => b2.length - a.length))
17532
+ o = o.split(d).join(repoDir.replace(/\/+$/, ""));
17533
+ return o;
17534
+ };
17535
+ const one = async () => {
17536
+ const t0 = Date.now(), r = await runner(spec.run, join57(baseDir, spec.cwd), timeoutS * 1000);
17537
+ return measured(repoDir, spec.run, { ...r, out: home(r.out) }, Math.round((Date.now() - t0) / 100) / 10);
17538
+ };
17539
+ const first = await one();
17540
+ let b = first.b;
17541
+ if (stopped())
17542
+ return false;
17543
+ if (!b.failing_ids.length)
17544
+ b = { ...b, flaky_probe: "done" };
17545
+ else if (b.timed_out || first.missing || (b.duration_s ?? 0) > FLAKE_PROBE_MAX_S)
17546
+ b = { ...b, flaky_probe: `skipped: first pass ${b.duration_s ?? "?"}s` };
17547
+ else {
17548
+ b = probeMerge(b, (await one()).b);
17549
+ if (stopped())
17550
+ return false;
17551
+ }
17552
+ const cur = loadProfile(repoDir);
17553
+ if (!cur || cur.revision !== baseSha)
17554
+ return false;
17555
+ if (root)
17556
+ cur.baseline = { ...b, command: cur.baseline.command };
17557
+ else
17558
+ cur.suites = [...(cur.suites ?? []).filter((o) => o.command !== spec.cmd), { name: spec.name, ...b, command: spec.cmd }];
17559
+ save(repoDir, cur);
17560
+ return true;
17561
+ } catch {
17562
+ return false;
17563
+ }
17564
+ }
17565
+ function multiPackageRepo(repoDir) {
17566
+ try {
17567
+ const m = manifestModel(repoDir);
17568
+ if (!m)
17569
+ return false;
17570
+ if ("fanOut" in m)
17571
+ return true;
17572
+ return (m["packages"] ?? []).some((x) => x.root !== "." && !!x.commands.test);
17573
+ } catch {
17574
+ return false;
17575
+ }
17576
+ }
17501
17577
  function suiteEmptyOnBase(repoDir, baseSha, line2, name, cls, out2, cwd = ".") {
17502
17578
  const p = baseSha ? loadProfile(repoDir) : null;
17503
17579
  if (!p || p.revision !== baseSha || !emptyDiscovery(cls, out2))
@@ -17534,10 +17610,11 @@ function save(repoDir, p) {
17534
17610
  function ensureProfile(repoDir, opts = {}) {
17535
17611
  try {
17536
17612
  const hash = manifestHash(repoDir), rev = headOf(repoDir), old = loadProfile(repoDir);
17537
- if (old && old.manifest_hash === hash && old.revision === rev && !cutShort(old.baseline, opts.timeoutS ?? BASELINE_CMD_TIMEOUT_S) && (old.baseline.failing_ids.length === 0 || old.baseline.failing_errors && old.baseline.flaky_probe !== undefined))
17613
+ if (old && old.manifest_hash === hash && old.revision === rev && !(old.baseline.reason === BASE_DEFERRED && !opts.defer) && !cutShort(old.baseline, opts.timeoutS ?? BASELINE_CMD_TIMEOUT_S) && (old.baseline.failing_ids.length === 0 || old.baseline.failing_errors && old.baseline.flaky_probe !== undefined))
17538
17614
  return { profile: old, reused: true };
17539
17615
  const commands = old && old.manifest_hash === hash ? old.commands.map((c) => ({ ...c, ...c.kind === "test" ? { validated: null, exit_code: null, duration_s: null, failing_ids: [] } : {} })) : discoverCommands(repoDir);
17540
- const profile = { version: 1, revision: rev, manifest_hash: hash, created_at: (opts.now?.() ?? new Date).toISOString(), commands, baseline: runBaseline(repoDir, commands, opts) };
17616
+ const t = commands.find((c) => c.kind === "test");
17617
+ const profile = { version: 1, revision: rev, manifest_hash: hash, created_at: (opts.now?.() ?? new Date).toISOString(), commands, baseline: opts.defer && t ? { ran: false, command: t.cmd, exit_code: null, duration_s: null, timed_out: false, failing_ids: [], attributable: false, reason: BASE_DEFERRED } : runBaseline(repoDir, commands, opts) };
17541
17618
  save(repoDir, profile);
17542
17619
  return { profile, reused: false };
17543
17620
  } catch {
@@ -17548,11 +17625,13 @@ function attribute(repoDir, baseSha, failing) {
17548
17625
  const p = loadProfile(repoDir), none = { preExistingChecks: [], preExistingIds: [], introducedChecks: failing.map((f) => f.name), line: null };
17549
17626
  if (!p || p.revision !== baseSha || failing.length === 0)
17550
17627
  return none;
17551
- const root = p.baseline.attributable ? p.baseline.failing_ids : [], own = (name) => {
17552
- const s = name ? p.suites?.find((x) => x.name === name && x.ran && x.attributable) : undefined;
17553
- return s ? s.failing_ids : root;
17628
+ const rec = (name) => name ? p.suites?.find((x) => x.name === name && x.ran && x.attributable) : undefined, root = p.baseline.attributable ? p.baseline.failing_ids : [], own = (name) => rec(name)?.failing_ids ?? root;
17629
+ const sameWay = (f) => {
17630
+ const be = rec(f.suite)?.failing_errors;
17631
+ return !!be && !!f.errors && sameErrors(f.errors instanceof Map ? f.errors : new Map(Object.entries(f.errors)), be, comparableIds(f.ids ?? []));
17554
17632
  };
17555
- const byId = baseRedByIdOn(), rows = failing.map((f) => ({ ...f, base: new Set(own(f.rerun === "same" || byId && f.rerun !== "differs" ? f.suite : undefined)) })), known = new Set(rows.flatMap((r) => [...r.base]));
17633
+ const absent = (f) => f.rerun === undefined && !!f.suite && (baseRedByIdOn() || !baseRedSuiteOff() && sameWay(f));
17634
+ const rows = failing.map((f) => ({ ...f, base: new Set(own(f.rerun === "same" || absent(f) ? f.suite : undefined)) })), known = new Set(rows.flatMap((r) => [...r.base]));
17556
17635
  if (known.size === 0)
17557
17636
  return none;
17558
17637
  return split(rows, known.size);
@@ -17702,28 +17781,27 @@ function touchedRedOnBase(repoDir, baseSha, c, editedTitles) {
17702
17781
  return false;
17703
17782
  return redOnBaseProfile(p, ids, c.errors);
17704
17783
  }
17705
- function redOnBaseProfile(p, ids, errors2) {
17784
+ function redOnBaseProfile(p, ids, errors2, textOnly = false) {
17706
17785
  const runs2 = [p.baseline, ...p.suites ?? []].filter((b) => b.ran && b.attributable && !b.timed_out && b.reason !== "baseline budget used up");
17707
17786
  const baseIds = new Set(runs2.flatMap((b) => b.failing_ids)), baseErr = new Map;
17708
17787
  for (const b of runs2)
17709
17788
  for (const [k, v] of Object.entries(b.failing_errors ?? {}))
17710
17789
  if (!baseErr.has(k))
17711
17790
  baseErr.set(k, v);
17712
- return ids.length > 0 && ids.every((i) => baseIds.has(i) || [...baseIds].some((b) => b.endsWith(` > ${i}`))) && (baseRedByIdOn() || sameErrors(errors2, baseErr, [...ids]));
17791
+ return ids.length > 0 && ids.every((i) => baseIds.has(i) || [...baseIds].some((b) => b.endsWith(` > ${i}`))) && (!textOnly && baseRedByIdOn() || sameErrors(errors2, baseErr, [...ids]));
17713
17792
  }
17714
17793
  function collateralOnBaseline(repoDir, baseSha, test, c, changed, stem) {
17715
17794
  if (!collateralBaselineOn() || changed.includes(test))
17716
17795
  return false;
17717
17796
  const td = test.includes("/") ? test.slice(0, test.lastIndexOf("/")) : ".", sd = /(?:^|\/)(?:__tests__|tests|test)$/.test(td) ? td.includes("/") ? td.slice(0, td.lastIndexOf("/")) : "." : td;
17718
- if (!baseRedByIdOn() && changed.some((f) => {
17797
+ const paired = changed.some((f) => {
17719
17798
  const fd = f.includes("/") ? f.slice(0, f.lastIndexOf("/")) : ".";
17720
17799
  return (fd === sd || fd === td) && f.slice(f.lastIndexOf("/") + 1).replace(/\.[^.]+$/, "") === stem;
17721
- }))
17722
- return false;
17800
+ });
17723
17801
  const p = loadProfile(repoDir);
17724
17802
  if (!p || p.revision !== baseSha || !c.errors)
17725
17803
  return false;
17726
- return redOnBaseProfile(p, comparableIds(c.ids ?? []), c.errors);
17804
+ return redOnBaseProfile(p, comparableIds(c.ids ?? []), c.errors, paired);
17727
17805
  }
17728
17806
  function whyFullSuiteNotExcused(repoDir, baseSha, full, changed, excused, blocked = [], shownIds = new Set) {
17729
17807
  const p = loadProfile(repoDir), out2 = [];
@@ -17881,7 +17959,7 @@ function repoReadiness(p, host, verify3 = []) {
17881
17959
  const miss = verify3.find((c) => c.validated === false);
17882
17960
  if (miss)
17883
17961
  add3(30, { id: "test-tool-missing", severity: "high", message: `Loki tests this repo with \`${miss.cmd}\` (from ${miss.source}), but ${miss.note}.`, fix: miss.fix ?? `Install the tool \`${miss.cmd.split(" ")[0]}\` needs.` });
17884
- } else if (!b.ran || b.timed_out || !b.attributable)
17962
+ } else if (b.reason === BASE_DEFERRED) {} else if (!b.ran || b.timed_out || !b.attributable)
17885
17963
  add3(15, { id: "baseline-unattributable", severity: "medium", message: `Baseline test run is not usable${b.reason ? ` (${b.reason})` : b.ran ? "" : " (not run)"}.`, fix: "Make the test command runnable from the repo root and finish within the baseline timeout so failures can be attributed." });
17886
17964
  else if (b.failing_ids.length > 0)
17887
17965
  add3(20, { id: "baseline-red", severity: "medium", message: `Baseline is red: ${b.failing_ids.length} test(s) already fail before any change.`, fix: "Fix or quarantine them; until then `loki start` will not blame these on your change." });
@@ -17954,13 +18032,38 @@ ${r.stderr ?? ""}`), missing: r.status === 127 };
17954
18032
  for (const f of untracked(repoDir))
17955
18033
  if (!before.has(f))
17956
18034
  rmSync11(join57(repoDir, f), { force: true, recursive: true });
17957
- }, FLAKE_PROBE_MAX_S = 120, MASSIVE_RED_IDS = 500, normCmd = (s) => s.replace(/\s+--silent\b/, "").trim().replace(/^\(cd \.\s+&&\s+(.+)\)$/, "$1"), oneBaseRunOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_ONE_BASE_RUN"] ?? "").trim()), PM_SCRIPT, SUITE_BASELINE_BUDGET_S = 300, headOf = (repoDir) => {
18035
+ }, FLAKE_PROBE_MAX_S = 120, MASSIVE_RED_IDS = 500, normCmd = (s) => s.replace(/\s+--silent\b/, "").trim().replace(/^\(cd \.\s+&&\s+(.+)\)$/, "$1"), oneBaseRunOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_ONE_BASE_RUN"] ?? "").trim()), PM_SCRIPT, SUITE_BASELINE_BUDGET_S = 300, baseOnDemandOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_BASE_ON_DEMAND"] ?? "").trim()), BASE_DEFERRED = "deferred: measured on base on demand, after implement", asyncShellRunner = (signal) => async (cmd, cwd, timeoutMs) => {
18036
+ const proc = Bun.spawn(["sh", "-c", cmd], { cwd, env: { ...plainTestEnv(), PYTHONDONTWRITEBYTECODE: "1", CI: "1" }, stdin: "ignore", stdout: "pipe", stderr: "pipe", detached: true });
18037
+ let stopped = false;
18038
+ const kill = () => {
18039
+ try {
18040
+ process.kill(-proc.pid, "SIGKILL");
18041
+ } catch {}
18042
+ }, stop = () => {
18043
+ stopped = true;
18044
+ kill();
18045
+ };
18046
+ const timer = setTimeout(stop, timeoutMs);
18047
+ if (signal?.aborted)
18048
+ stop();
18049
+ else
18050
+ signal?.addEventListener("abort", stop, { once: true });
18051
+ try {
18052
+ const [o, e, code] = await Promise.all([new Response(proc.stdout).text(), new Response(proc.stderr).text(), proc.exited]);
18053
+ return { code: stopped ? null : code, timedOut: stopped, out: stripAnsi(`${o}
18054
+ ${e}`).slice(-8 * 1024 * 1024), missing: code === 127 };
18055
+ } finally {
18056
+ clearTimeout(timer);
18057
+ signal?.removeEventListener("abort", stop);
18058
+ kill();
18059
+ }
18060
+ }, headOf = (repoDir) => {
17958
18061
  try {
17959
18062
  return safeGit(repoDir, ["rev-parse", "HEAD"]).trim();
17960
18063
  } catch {
17961
18064
  return "";
17962
18065
  }
17963
- }, SAME_RED_NOTE = "excused as red on base in the identical kind (same command, same exit code, the same unparseable output shape; no failing id could be compared)", baseRedByIdOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_BASE_RED_BY_ID"] ?? "").trim()), touchedBaseRedOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_TOUCHED_BASE_RED"] ?? "").trim()), collateralBaselineOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_COLLATERAL_BASELINE"] ?? "").trim()), TOUCHED_RED = "edited test file red on base by every failing id with the same errors; the cases the change added or edited pass (excused, not blocking)", STATIC_DIAG, STATIC_NOISE, STATIC_SUMMARY, readinessLines = (r) => [` Readiness: ${r.score}/100 (${r.grade})`, ...r.findings.length ? [" Fix:", ...r.findings.map((f) => ` - ${f.fix}`)] : []];
18066
+ }, SAME_RED_NOTE = "excused as red on base in the identical kind (same command, same exit code, the same unparseable output shape; no failing id could be compared)", baseRedByIdOn = (env = process.env) => /^(1|on|true|yes)$/i.test((env["LOKI_E10_BASE_RED_BY_ID"] ?? "").trim()), baseRedSuiteOff = (env = process.env) => /^(0|off|false|no)$/i.test((env["LOKI_E10_BASE_RED_BY_ID"] ?? "").trim()), touchedBaseRedOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_TOUCHED_BASE_RED"] ?? "").trim()), collateralBaselineOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_COLLATERAL_BASELINE"] ?? "").trim()), TOUCHED_RED = "edited test file red on base by every failing id with the same errors; the cases the change added or edited pass (excused, not blocking)", STATIC_DIAG, STATIC_NOISE, STATIC_SUMMARY, readinessLines = (r) => [` Readiness: ${r.score}/100 (${r.grade})`, ...r.findings.length ? [" Fix:", ...r.findings.map((f) => ` - ${f.fix}`)] : []];
17964
18067
  var init_repo_profile = __esm(() => {
17965
18068
  init_failures();
17966
18069
  init_check_result();
@@ -18196,6 +18299,8 @@ __export(exports_package_suite, {
18196
18299
  suiteTimeoutOn: () => suiteTimeoutOn,
18197
18300
  suiteEnv: () => suiteEnv,
18198
18301
  suiteCmdsOpt: () => suiteCmdsOpt,
18302
+ scopedSuites: () => scopedSuites,
18303
+ scopedOutNote: () => scopedOutNote,
18199
18304
  runPackageSuites: () => runPackageSuites,
18200
18305
  packageSuiteSpecs: () => packageSuiteSpecs,
18201
18306
  ownedSuites: () => ownedSuites,
@@ -18217,6 +18322,27 @@ function ownedSuites(specs, changed) {
18217
18322
  }
18218
18323
  return specs.filter((s) => out2.has(s));
18219
18324
  }
18325
+ function scopedSuites(specs, changed, dependsOn, roots = []) {
18326
+ const clean2 = (d) => d.replace(/\/+$/, "") || ".", dirs = [...new Set([...specs.map((s) => clean2(s.cwd)), ...roots.map(clean2)])], below = dirs.filter((d) => d !== ".");
18327
+ const inPkg = (f) => below.some((d) => f === d || f.startsWith(`${d}/`));
18328
+ const wide = changed.some((f) => f.startsWith('"') || !inPkg(f) && WORKSPACE_WIDE.test(f));
18329
+ if (wide)
18330
+ return { run: [...specs], skipped: [] };
18331
+ const ownerOf = (f) => dirs.filter((d) => d === "." || f === d || f.startsWith(`${d}/`)).sort((a, b) => b.length - a.length)[0];
18332
+ const owned = new Set(changed.map(ownerOf).filter((d) => d !== undefined)), inScope = new Set(owned);
18333
+ for (let grew = true;grew; ) {
18334
+ grew = false;
18335
+ for (const s of specs) {
18336
+ const d = clean2(s.cwd);
18337
+ if (!inScope.has(d) && dependsOn(d).some((x) => inScope.has(clean2(x)))) {
18338
+ inScope.add(d);
18339
+ grew = true;
18340
+ }
18341
+ }
18342
+ }
18343
+ const run2 = specs.filter((s) => inScope.has(clean2(s.cwd)));
18344
+ return { run: [...run2.filter((s) => owned.has(clean2(s.cwd))), ...run2.filter((s) => !owned.has(clean2(s.cwd)))], skipped: specs.filter((s) => !inScope.has(clean2(s.cwd))) };
18345
+ }
18220
18346
  function packageSuiteSpecs(api, repoDir) {
18221
18347
  if (!isMultiRoot(api))
18222
18348
  return null;
@@ -18334,12 +18460,21 @@ async function runPackageSuites(repoDir, signal, opts, checks, notProven) {
18334
18460
  const api = loadProjectApi(repoDir), all = packageSuiteSpecs(api, repoDir);
18335
18461
  if (!api || !all)
18336
18462
  return false;
18337
- const specs = opts.ownedOnly ? ownedSuites(all, opts.changed ?? []) : all;
18338
- if (!specs.length)
18463
+ const sc = opts.scope && opts.changed ? scopedSuites(all, opts.changed, (root) => api.dependsOn(root) ?? [], api.packages().map((p) => p.root)) : null;
18464
+ const specs = sc ? sc.run : opts.ownedOnly ? ownedSuites(all, opts.changed ?? []) : all;
18465
+ if (!specs.length && !sc)
18339
18466
  return false;
18340
- for (const { name, cmd, cwd, run: line2, go } of specs) {
18467
+ for (const s of sc?.skipped ?? [])
18468
+ notProven.add(scopedOutNote(s));
18469
+ for (const spec of specs) {
18470
+ const { name, cmd, cwd, run: line2, go } = spec, timeoutMs = typeof opts.timeoutMs === "function" ? opts.timeoutMs() : opts.timeoutMs;
18471
+ if (timeoutMs <= 0 && !signal.aborted) {
18472
+ checks.push({ name, cmd, result: "not_run", duration_s: 0, reason: "no time left before the verify limit" });
18473
+ notProven.add(`not run: ${name} (no time left before the verify limit)`);
18474
+ continue;
18475
+ }
18341
18476
  const started = Date.now();
18342
- const r = await run(["bash", "-c", line2], { cwd: join59(repoDir, cwd), timeoutMs: opts.timeoutMs, env: suiteEnv(opts.path), ...suiteTimeoutOn() ? { group: true, signal } : {} });
18477
+ const r = await run(["bash", "-c", line2], { cwd: join59(repoDir, cwd), timeoutMs, env: suiteEnv(opts.path), ...suiteTimeoutOn() ? { group: true, signal } : {} });
18343
18478
  const duration_s = (Date.now() - started) / 1000;
18344
18479
  if (signal.aborted) {
18345
18480
  checks.push({ name, cmd, result: "not_run", duration_s });
@@ -18347,7 +18482,7 @@ async function runPackageSuites(repoDir, signal, opts, checks, notProven) {
18347
18482
  continue;
18348
18483
  }
18349
18484
  if (r.timedOut && suiteTimeoutOn()) {
18350
- const why = `timed out after ${Math.round(opts.timeoutMs / 1000)}s`;
18485
+ const why = `timed out after ${Math.round(timeoutMs / 1000)}s`;
18351
18486
  checks.push({ name, cmd, result: "not_run", duration_s, reason: why });
18352
18487
  notProven.add(`not run: ${name} (${why})`);
18353
18488
  continue;
@@ -18361,6 +18496,8 @@ ${r.stderr}`).replace(go ? /^make(?:\[\d+\])?: .*$/gm : /(?!)/, "");
18361
18496
  continue;
18362
18497
  }
18363
18498
  const cls = await corroboratePass(classifyCheck({ kind: "test", ok: r.exitCode === 0, out: out2, ...go ? { runner: "go" } : goRunner(line2), exitCoded: !go && isExitCodedScript(line2) }), out2, go ?? line2, undefined, { cwd: join59(repoDir, cwd), env: suiteEnv(opts.path), signal });
18499
+ if (cls.result === "not_run" && r.exitCode === 0 && (opts.targetPassed === true || cwd !== "." && emptySubsuiteNaOn()) && opts.ensureBase)
18500
+ await opts.ensureBase(spec);
18364
18501
  if (cls.result === "not_run" && r.exitCode === 0 && (opts.targetPassed === true || cwd !== "." && emptySubsuiteNaOn()) && suiteEmptyOnBase(repoDir, opts.baseSha, line2, cmd, cls, out2, cwd)) {
18365
18502
  notProven.add(`${NA_PREFIX}${name} (ran 0 tests on base and head; ${opts.targetPassed === true ? "the Wall or a task-named check passed with executed tests" : "a sub-module package with no tests on either side"})`);
18366
18503
  continue;
@@ -18386,7 +18523,7 @@ ${r.stderr}`).replace(go ? /^make(?:\[\d+\])?: .*$/gm : /(?!)/, "");
18386
18523
  }
18387
18524
  return true;
18388
18525
  }
18389
- var GO_VALUED, NA_PREFIX = "n/a: ", naNote = (n3) => n3.startsWith(NA_PREFIX) || n3.startsWith("full suite (no test runner"), naText = (n3) => n3.startsWith(NA_PREFIX) ? n3.slice(NA_PREFIX.length) : n3, wallRedOnBaseOf = (baseRun) => {
18526
+ var WORKSPACE_WIDE, scopedOutNote = (s) => `n/a: ${s.name} (\`${s.cmd}\`) not run: no changed file is in this package and its manifest does not depend on a package the change touched`, GO_VALUED, NA_PREFIX = "n/a: ", naNote = (n3) => n3.startsWith(NA_PREFIX) || n3.startsWith("full suite (no test runner"), naText = (n3) => n3.startsWith(NA_PREFIX) ? n3.slice(NA_PREFIX.length) : n3, wallRedOnBaseOf = (baseRun) => {
18390
18527
  const f = baseRun?.fail;
18391
18528
  return typeof f === "number" && f > 0;
18392
18529
  }, wallProofOf = (checks, wall) => {
@@ -18401,6 +18538,7 @@ var init_package_suite = __esm(() => {
18401
18538
  init_stack_tools();
18402
18539
  init_failures();
18403
18540
  init_resolve();
18541
+ WORKSPACE_WIDE = /(?:^|\/)(?:package\.json|package-lock\.json|pnpm-lock\.yaml|pnpm-workspace\.yaml|yarn\.lock|bun\.lockb?|bunfig\.toml|turbo\.json|nx\.json|lerna\.json|tsconfig[^/]*\.json|jsconfig\.json|\.eslintrc[^/]*|eslint\.config\.[cm]?[jt]s|biome\.jsonc?|babel\.config\.[cm]?[jt]s|\.babelrc|(?:vitest|vite|jest)\.(?:config|workspace)\.[cm]?[jt]s|pyproject\.toml|setup\.py|setup\.cfg|requirements[^/]*\.txt|uv\.lock|poetry\.lock|tox\.ini|pytest\.ini|conftest\.py|go\.mod|go\.sum|go\.work|Cargo\.toml|Cargo\.lock|Makefile|\.npmrc|\.nvmrc|\.python-version|\.tool-versions)$/;
18404
18542
  GO_VALUED = new Set(["cpu", "count", "timeout", "parallel", "p", "shuffle", "run", "skip", "tags", "exec", "o", "coverprofile", "covermode", "coverpkg", "bench", "benchtime", "list", "vet", "mod", "modfile", "overlay", "pkgdir", "asmflags", "gcflags", "ldflags", "toolexec", "trimpath", "fuzz", "fuzztime", "outputdir", "memprofile", "cpuprofile", "blockprofile", "mutexprofile", "trace"]);
18405
18543
  });
18406
18544
 
@@ -21193,20 +21331,25 @@ function excusedEdit(repoDir, baseSha, headSha, rel, base, head, task) {
21193
21331
  return [...new Set([p, ...["ts", "tsx", "js", "mjs", "cjs", "jsx", "mts", "cts"].map((x) => `${stem}.${x}`), ...["ts", "tsx", "js"].map((x) => `${stem}/index.${x}`)])];
21194
21332
  };
21195
21333
  let addedImports = null;
21334
+ const subjectOf = () => {
21335
+ const low = (x) => x.toLowerCase(), up = dir.includes("/") ? dir.slice(0, dir.lastIndexOf("/")) : "", stem = (f) => low(f.slice(f.lastIndexOf("/") + 1)).replace(/\.(?:test|spec)(?=\.[^.]+$)/, "").replace(/\.[^.]+$/, "");
21336
+ const imported = new Set([...base.matchAll(/(?:\bfrom\s*|\brequire\(\s*|\bimport\s*\(?\s*)['"](\.{1,2}\/[^'"]+)['"]/g)].flatMap((m) => candidates2(m[1])).map(low));
21337
+ return (file) => !isTestFile(file) && (imported.has(low(file)) || (dir === "" ? [""] : [dir, up]).map(low).includes(low(file.includes("/") ? file.slice(0, file.lastIndexOf("/")) : "")) && stem(file) === stem(rel));
21338
+ };
21196
21339
  const newlyImported = (spec) => {
21197
21340
  if (/^(0|off|false|no)$/i.test((process.env["LOKI_E10_WEAK_MOCK_PKG"] ?? "").trim()) || spec.startsWith(".") || spec.startsWith("/"))
21198
21341
  return false;
21199
21342
  if (addedImports === null) {
21200
21343
  try {
21201
21344
  let file = "";
21202
- const keep = [];
21203
- for (const l of safeGit(repoDir, ["diff", "-U0", baseSha, ...headSha ? [headSha] : []]).split(`
21345
+ const keep = [], subject = subjectOf();
21346
+ for (const l of safeGit(repoDir, ["diff", "-U0", "--no-color", baseSha, ...headSha ? [headSha] : []]).split(`
21204
21347
  `)) {
21205
21348
  if (l.startsWith("+++ "))
21206
- file = l.slice(6);
21207
- else if (l.startsWith("-") && !l.startsWith("---") && file && !isTestFile(file))
21349
+ file = l.startsWith("+++ b/") && subject(l.slice(6)) ? l.slice(6) : "";
21350
+ else if (l.startsWith("-") && !l.startsWith("---") && file)
21208
21351
  keep.push(`gone ${l.slice(1)}`);
21209
- else if (l.startsWith("+") && !l.startsWith("+++") && file && !isTestFile(file))
21352
+ else if (l.startsWith("+") && !l.startsWith("+++") && file)
21210
21353
  keep.push(`new ${l.slice(1)}`);
21211
21354
  }
21212
21355
  addedImports = keep.join(`
@@ -21215,7 +21358,7 @@ function excusedEdit(repoDir, baseSha, headSha, rel, base, head, task) {
21215
21358
  addedImports = "";
21216
21359
  }
21217
21360
  }
21218
- const q = spec.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), imp = (kind) => new RegExp(`^${kind} .*(?:\\bfrom\\s*|\\brequire\\(\\s*|\\bimport\\s*\\(?\\s*)['"]${q}['"]`, "m");
21361
+ const q = escapeRegex(spec), imp = (kind) => new RegExp(`^${kind} .*(?:\\bfrom\\s*|\\brequire\\(\\s*|\\bimport\\s*\\(?\\s*)['"]${q}['"]`, "m");
21219
21362
  return imp("new").test(addedImports) && !imp("gone").test(addedImports);
21220
21363
  };
21221
21364
  let excused = 0;
@@ -21273,7 +21416,7 @@ function excusedEdit(repoDir, baseSha, headSha, rel, base, head, task) {
21273
21416
  }
21274
21417
  if (count2(SETUP_RE, head) - excused > count2(SETUP_RE, base))
21275
21418
  return null;
21276
- why.push("added setup only in describe blocks the change added, or mocks of modules new in the change or of a package its source starts importing");
21419
+ why.push("added setup only in describe blocks the change added, or mocks of modules new in the change or of a package the test's own subject starts importing");
21277
21420
  }
21278
21421
  return why.join("; ") || null;
21279
21422
  }
@@ -35921,6 +36064,7 @@ var init_budget_cap = __esm(() => {
35921
36064
  // ../../loki-ts/src/engine10/machine.ts
35922
36065
  var exports_machine = {};
35923
36066
  __export(exports_machine, {
36067
+ verifyLimitFor: () => verifyLimitFor,
35924
36068
  suiteOnlyRed: () => suiteOnlyRed,
35925
36069
  suiteFixSkipEnabled: () => suiteFixSkipEnabled,
35926
36070
  stillFailing: () => stillFailing,
@@ -35934,6 +36078,7 @@ __export(exports_machine, {
35934
36078
  haikuIndepFixOn: () => haikuIndepFixOn,
35935
36079
  freshBaseCheckout: () => freshBaseCheckout,
35936
36080
  attemptSignalOf: () => attemptSignalOf,
36081
+ VERIFY_MAX_S: () => VERIFY_MAX_S,
35937
36082
  USAGE_LIMIT_STOP: () => USAGE_LIMIT_STOP,
35938
36083
  SUITE_FIX_SKIP_NOTE: () => SUITE_FIX_SKIP_NOTE,
35939
36084
  PRE_EXISTING_CLAIM: () => PRE_EXISTING_CLAIM,
@@ -35977,6 +36122,10 @@ function stillFailing(groups, kept) {
35977
36122
  return !green.some((n3) => s === n3 || s.startsWith(`${n3} `));
35978
36123
  });
35979
36124
  }
36125
+ function verifyLimitFor(floorS, softS, elapsedS2, env = process.env) {
36126
+ const v = Number((env["LOKI_E10_VERIFY_MAX_S"] ?? "").trim()), max = Number.isFinite(v) && v >= 1 ? Math.floor(v) : VERIFY_MAX_S;
36127
+ return Math.min(Math.max(floorS, Math.floor(softS - elapsedS2 - VERIFY_TAIL_S)), max);
36128
+ }
35980
36129
  function softCapS(capS) {
35981
36130
  const plain = capS * 14 / 15, budget = backstopS(capS) - ((STAGE_BUDGETS.commit.targetS ?? 0) + (STAGE_BUDGETS.seal.targetS ?? 0) + KILL_GRACE_MS3 / 1000 + 2);
35982
36131
  return Math.max(0, Math.min(plain, budget));
@@ -36048,7 +36197,7 @@ ${timeBudgetNote(limitS)}`;
36048
36197
  let implementBudgetS = 0;
36049
36198
  const implementLimitS = (floorS) => Math.max(floorS, Math.floor(softCapS(ctx.capS) - elapsedS2() - (STAGE_BUDGETS.verify.limitS ?? 0) - proveReserveS()));
36050
36199
  const fixLimitS = (baseS) => Math.max(baseS, Math.min(2 * baseS, Math.round(baseS * ctx.capS / DEFAULT_CAP_S)));
36051
- const verifyLimitS = (floorS) => Math.max(floorS, Math.floor(softCapS(ctx.capS) - elapsedS2() - VERIFY_RESERVE_S));
36200
+ const verifyLimitS = (floorS) => verifyLimitFor(floorS, softCapS(ctx.capS), elapsedS2());
36052
36201
  const runStage = async (name, underCap) => {
36053
36202
  if (limited)
36054
36203
  throw new UsageLimitCut;
@@ -36068,6 +36217,8 @@ ${timeBudgetNote(limitS)}`;
36068
36217
  }
36069
36218
  ctx.emit("stage.started", name, { target_s: st.targetS, limit_s: limitS, ...name === "wall" ? { start_ms: ctx.clock.now() } : {} });
36070
36219
  const t0 = ctx.clock.now();
36220
+ if (name === "verify")
36221
+ sctx.verifyDeadlineMs = Date.now() + Math.max(0, Math.min(limitS * 1000, underCap ? capAtMs - ctx.clock.now() : Infinity));
36071
36222
  const dur = () => (ctx.clock.now() - t0) / 1000;
36072
36223
  const snapBefore = TREE_STAGES.has(name) || name === "verify" && regenDropOn() ? treeSnapshot(ctx.repoDir) : null;
36073
36224
  const ctl = new AbortController;
@@ -36597,7 +36748,7 @@ var FLOW, TAIL, USAGE_LIMIT_STOP = "usage_limit", UsageLimitCut, harnessOnlyFail
36597
36748
  const checks = Array.isArray(d?.checks) ? d.checks : [], changed = (Array.isArray(d?.changed_files) ? d.changed_files : []).map(String).filter((f) => f && !f.startsWith(".loki/"));
36598
36749
  const namesChanged = checks.some((c) => c?.result === "fail" && String(c.name ?? "").startsWith("full suite") && (Array.isArray(c.ids) ? c.ids : []).some((i) => changed.some((f) => String(i).includes(f))));
36599
36750
  return onlyFullSuiteRed(d) && !namesChanged && !(Number(d?.holdout_failed ?? 0) > 0) && checks.some((c) => c?.result === "pass" && typeof c.n === "number" && c.n > 0 && !/^(full suite|lint:|security scan|select-tests|holdout)/.test(String(c.name ?? "")));
36600
- }, hasFailures = (d) => Array.isArray(d?.failures_grouped) && d.failures_grouped.length > 0 && !harnessOnlyFail(d) || typeof d?.holdout_failed === "number" && d.holdout_failed > 0, attemptSignalOf = (o, conflict) => ({ red: hasFailures(o.verify), conflict, notProven: signalNotProven([...Array.isArray(o.verify?.not_proven) ? o.verify.not_proven : [], ...Array.isArray(o.fix?.not_proven) ? o.fix.not_proven : []]) }), earlyExit = (d) => d.already_satisfied === true, KILL_GRACE_MS3 = 2000, VERIFY_RESERVE_S, ATTEMPTS_TAIL_S, TREE_STAGES;
36751
+ }, hasFailures = (d) => Array.isArray(d?.failures_grouped) && d.failures_grouped.length > 0 && !harnessOnlyFail(d) || typeof d?.holdout_failed === "number" && d.holdout_failed > 0, attemptSignalOf = (o, conflict) => ({ red: hasFailures(o.verify), conflict, notProven: signalNotProven([...Array.isArray(o.verify?.not_proven) ? o.verify.not_proven : [], ...Array.isArray(o.fix?.not_proven) ? o.fix.not_proven : []]) }), earlyExit = (d) => d.already_satisfied === true, KILL_GRACE_MS3 = 2000, VERIFY_MAX_S = 900, VERIFY_TAIL_S, ATTEMPTS_TAIL_S, TREE_STAGES;
36601
36752
  var init_machine = __esm(() => {
36602
36753
  init_base_guard();
36603
36754
  init_commit_filter();
@@ -36642,7 +36793,7 @@ var init_machine = __esm(() => {
36642
36793
  }
36643
36794
  };
36644
36795
  PRE_EXISTING_CLAIM = /\bpre-?exist|\balready (?:fail|red|broken)|\bidentical(?:ly)?\b|\bon (?:the )?(?:clean |unmodified |original )?(?:base|HEAD|main|master)\b|\bbefore (?:this|the|my|any) change|\bnot caused by\b|\bunrelated to (?:this|the) (?:change|task)/i;
36645
- VERIFY_RESERVE_S = STAGE_BUDGETS.fix.limitS + STAGE_BUDGETS.commit.limitS + STAGE_BUDGETS.seal.limitS + STAGE_BUDGETS.pr.limitS;
36796
+ VERIFY_TAIL_S = STAGE_BUDGETS.commit.limitS + STAGE_BUDGETS.seal.limitS + STAGE_BUDGETS.pr.limitS;
36646
36797
  ATTEMPTS_TAIL_S = STAGE_BUDGETS.verify.limitS + STAGE_BUDGETS.commit.limitS + STAGE_BUDGETS.seal.limitS + STAGE_BUDGETS.pr.limitS;
36647
36798
  TREE_STAGES = new Set(["wall", "implement", "prove", "fix"]);
36648
36799
  });
@@ -48121,25 +48272,25 @@ Summary:`);
48121
48272
  if (at < 0)
48122
48273
  return { usd: null, measured: 0, unmeasured: 0 };
48123
48274
  const tail2 = stdout.slice(at + 1);
48124
- let usd = 0, measured = 0, unmeasured = 0;
48275
+ let usd = 0, measured2 = 0, unmeasured = 0;
48125
48276
  for (const m of tail2.matchAll(/^(?!ITEM\b)\S+[ \t]+(\$[0-9]+(?:\.[0-9]+)?|unmeasured)[ \t]+\S/gm)) {
48126
48277
  if (m[1] === "unmeasured")
48127
48278
  unmeasured++;
48128
48279
  else {
48129
48280
  usd += Number(m[1].slice(1));
48130
- measured++;
48281
+ measured2++;
48131
48282
  }
48132
48283
  }
48133
- return { usd: measured > 0 ? usd : null, measured, unmeasured };
48284
+ return { usd: measured2 > 0 ? usd : null, measured: measured2, unmeasured };
48134
48285
  }
48135
48286
  function groupCostLine(costs, provider = "claude") {
48136
- const measured = costs.reduce((a, c) => a + c.measured, 0), unmeasured = costs.reduce((a, c) => a + c.unmeasured, 0);
48137
- if (measured === 0)
48287
+ const measured2 = costs.reduce((a, c) => a + c.measured, 0), unmeasured = costs.reduce((a, c) => a + c.unmeasured, 0);
48288
+ if (measured2 === 0)
48138
48289
  return `Cost: not measured
48139
48290
  `;
48140
48291
  const usd = costs.reduce((a, c) => a + (c.usd ?? 0), 0);
48141
- return unmeasured > 0 ? `Cost: $${usd.toFixed(2)} partial (${provider}, ${measured} of ${measured + unmeasured} unit sessions measured)
48142
- ` : `Cost: $${usd.toFixed(2)} (${provider}, ${measured} unit session${measured === 1 ? "" : "s"})
48292
+ return unmeasured > 0 ? `Cost: $${usd.toFixed(2)} partial (${provider}, ${measured2} of ${measured2 + unmeasured} unit sessions measured)
48293
+ ` : `Cost: $${usd.toFixed(2)} (${provider}, ${measured2} unit session${measured2 === 1 ? "" : "s"})
48143
48294
  `;
48144
48295
  }
48145
48296
  function writeGroupCostRecord(repoDir, name, costs, provider) {
@@ -51342,7 +51493,13 @@ async function runIntakeBody(ctx, signal, opts, held) {
51342
51493
  if (dirty.length > 0)
51343
51494
  return { status: "failed", data: { blocker: "dirty_tracked_tree" }, reason: `dirty tracked tree: ${dirty.join(", ")}; loki never stashes or commits your edits: commit them or run git stash push -m wip yourself, then rerun the same command` };
51344
51495
  let baseSha = git13(ctx.repoDir, ["rev-parse", "HEAD"]);
51345
- const startBranch = git13(ctx.repoDir, ["symbolic-ref", "-q", "--short", "HEAD"]);
51496
+ const startBranch = (() => {
51497
+ try {
51498
+ return git13(ctx.repoDir, ["symbolic-ref", "-q", "--short", "HEAD"]) || null;
51499
+ } catch {
51500
+ return null;
51501
+ }
51502
+ })();
51346
51503
  let stacked = stackedOnLokiRun(ctx.repoDir);
51347
51504
  if (stacked) {
51348
51505
  try {
@@ -51423,7 +51580,8 @@ async function runIntakeBody(ctx, signal, opts, held) {
51423
51580
  tm.repo_walk = { ms: walkEnd(), at: walkAt, cached: walkCached };
51424
51581
  tm.exec_spec_prefetch = await prefetchLeanExecSpec(ctx, task, repoMap, testmap, signal);
51425
51582
  const baselineAt = at(), baselineEnd = lap(), baselineOn = process.env.LOKI_REPO_BASELINE !== "0";
51426
- const icap = intakeCapS(), built = baselineOn ? ensureProfile(ctx.repoDir, { timeoutS: icap === null ? baselineCmdS(ctx.capS) : Math.min(baselineCmdS(ctx.capS), icap) }) : null, baselineMs = baselineEnd();
51583
+ const defer = baselineOn && baseOnDemandOn() && multiPackageRepo(ctx.repoDir);
51584
+ const icap = intakeCapS(), built = baselineOn ? ensureProfile(ctx.repoDir, { timeoutS: icap === null ? baselineCmdS(ctx.capS) : Math.min(baselineCmdS(ctx.capS), icap), ...defer ? { defer: true } : {} }) : null, baselineMs = baselineEnd();
51427
51585
  if (icap !== null && built && !built.reused && built.profile.baseline.timed_out && icap < baselineCmdS(ctx.capS))
51428
51586
  intakeBudgetNote(baselineMs / 1000, "root baseline cut off on base");
51429
51587
  const readiness = built ? readinessNotice(ctx.repoDir, repoReadiness(built.profile, undefined, built.profile.commands.some((c) => c.kind === "test") ? [] : verifyCommandRows(ctx.repoDir, testmap))) : null;
@@ -51801,7 +51959,7 @@ import { copyFileSync as copyFileSync9, existsSync as existsSync97, mkdirSync as
51801
51959
  import { tmpdir as tmpdir26 } from "os";
51802
51960
  import { dirname as dirname60, join as join137 } from "path";
51803
51961
  async function runFullSuite(ctx, signal, opts, checks, notProven2) {
51804
- if (await runPackageSuites(ctx.repoDir, signal, { path: opts.path, timeoutMs: opts.fullSuiteTimeoutMs ?? FULL_SUITE_TIMEOUT_MS, baseSha: ctx.baseSha, skip: installOwned(ctx.repoDir, ctx.outputs().intake?.install_created), changed: opts.changed, proofFiles: opts.proofFiles, wallBaseRed: opts.wallBaseRed, targetPassed: opts.targetPassed, ...opts.ownedOnly ? { ownedOnly: true } : {} }, checks, notProven2))
51962
+ if (await runPackageSuites(ctx.repoDir, signal, { path: opts.path, timeoutMs: opts.suiteTimeoutMs ?? opts.fullSuiteTimeoutMs ?? FULL_SUITE_TIMEOUT_MS, baseSha: ctx.baseSha, skip: installOwned(ctx.repoDir, ctx.outputs().intake?.install_created), changed: opts.changed, proofFiles: opts.proofFiles, wallBaseRed: opts.wallBaseRed, targetPassed: opts.targetPassed, ...opts.ownedOnly ? { ownedOnly: true } : {}, ...opts.scope ? { scope: true } : {}, ...opts.ensureBase ? { ensureBase: opts.ensureBase } : {} }, checks, notProven2))
51805
51963
  return;
51806
51964
  const map = await ctx.tests.detect(ctx.repoDir);
51807
51965
  if (map.runners.length === 0) {
@@ -56147,7 +56305,7 @@ var NAME_WIDTH = 12, STATUS_WIDTH = 8, LABEL_WIDTH = 12, etaMod = null, targetOf
56147
56305
  const c = summaryCost(events2, false, lokiRoot);
56148
56306
  return c.usd != null ? `($${c.usd.toFixed(2)} so far)` : c.pc.measured > 0 ? `(partial: $${c.pc.usd.toFixed(2)} so far)` : "(spend not measured)";
56149
56307
  }, EXIT, exitCodeOf = (o, env = process.env) => env.LOKI_DURABLE_STATE === "1" && o !== "CANCELLED" && EXIT[o] !== 0 ? 20 : EXIT[o], currentAttempt = (ev) => ev.slice(Math.max(0, ev.findLastIndex((e) => e.type === "run.started" || e.type === "run.resumed"))), plainLine = (v, max = 200) => clipWords(redactSecrets(String(v ?? "").replace(/[\x00-\x1f\x7f-\x9f\u200b-\u200f\u2028-\u202e\u2060-\u2064\u2066-\u206f\u061c\u180e\ufeff]+/g, " ").trim()), max), phasesNote = (t) => t.intake_phases ? ` [intake: ${Object.entries(t.intake_phases).map(([k, v]) => `${k} ${"ms" in v ? `${(v.ms / 1000).toFixed(1)}s${v.cached ? " cached" : ""}` : "skipped"}`).join(", ")}]` : "", formatPreModelLine = (t, env = process.env) => env.LOKI_SPEED === "0" || !t ? "" : `pre-model ${t.span_s.toFixed(1)}s (${Object.entries(t.stages).filter(([, v]) => v >= 0.05).map(([k, v]) => `${k} ${v.toFixed(1)}s`).join(", ")})${phasesNote(t)}
56150
- `, partialCostText = (usd, measured, total, digits = 4) => `partial: $${usd.toFixed(digits)} for ${measured} of ${total} sessions`;
56308
+ `, partialCostText = (usd, measured2, total, digits = 4) => `partial: $${usd.toFixed(digits)} for ${measured2} of ${total} sessions`;
56151
56309
  var init_output = __esm(() => {
56152
56310
  init_types2();
56153
56311
  init_term_width();
@@ -56227,12 +56385,13 @@ __export(exports_base_guard, {
56227
56385
  deepPid: () => deepPid,
56228
56386
  deepAlive: () => deepAlive,
56229
56387
  baseLine: () => baseLine,
56388
+ baseDepsView: () => baseDepsView,
56230
56389
  baseDepsLinker: () => baseDepsLinker,
56231
56390
  addedSymlinkNotes: () => addedSymlinkNotes
56232
56391
  });
56233
56392
  import { execFileSync as execFileSync12 } from "child_process";
56234
56393
  import { createHash as createHash39 } from "crypto";
56235
- import { existsSync as existsSync108, mkdirSync as mkdirSync81, mkdtempSync as mkdtempSync25, readdirSync as readdirSync54, readFileSync as readFileSync141, readlinkSync as readlinkSync8, realpathSync as realpathSync44, rmSync as rmSync49, statSync as statSync46, symlinkSync as symlinkSync6, utimesSync, writeFileSync as writeFileSync82 } from "fs";
56394
+ import { existsSync as existsSync108, lstatSync as lstatSync34, mkdirSync as mkdirSync81, mkdtempSync as mkdtempSync25, readdirSync as readdirSync54, readFileSync as readFileSync141, readlinkSync as readlinkSync8, realpathSync as realpathSync44, rmSync as rmSync49, statSync as statSync46, symlinkSync as symlinkSync6, utimesSync, writeFileSync as writeFileSync82 } from "fs";
56236
56395
  import { tmpdir as tmpdir31 } from "os";
56237
56396
  import { basename as basename43, dirname as dirname65, join as join154, relative as relative32, resolve as resolve39, sep as sep24 } from "path";
56238
56397
  import { fileURLToPath as fileURLToPath5 } from "url";
@@ -56521,6 +56680,91 @@ function baseDepsLinker(baseDir, repoDir, gate = {}) {
56521
56680
  return true;
56522
56681
  };
56523
56682
  }
56683
+ function baseDepsView(baseDir, repoDir, gate = {}) {
56684
+ const seen = new Map;
56685
+ let roots = [];
56686
+ try {
56687
+ roots = [...new Set([resolve39(repoDir), realpathSync44(repoDir)])];
56688
+ } catch {}
56689
+ const member = (rt) => {
56690
+ for (const r of roots)
56691
+ if (rt.startsWith(r + sep24) && !rt.slice(r.length).split(sep24).includes("node_modules"))
56692
+ return relative32(r, rt);
56693
+ return null;
56694
+ };
56695
+ const levelDir = (name) => name.startsWith("@") || name === ".bin";
56696
+ const build = (src, cwd) => {
56697
+ const nm = join154(src, "node_modules"), out3 = join154(cwd, "node_modules");
56698
+ if (existsSync108(join154(src, ".venv")))
56699
+ return false;
56700
+ if (!existsSync108(nm))
56701
+ return true;
56702
+ if (roots.length === 0 || existsSync108(out3))
56703
+ return false;
56704
+ if (gate.sinceMs !== undefined && envChangedSince(repoDir, src, gate.sinceMs, gate.ignored ?? null, gate.deps))
56705
+ return false;
56706
+ const own = [...new Set([resolve39(nm), realpathSync44(nm)])], t0 = Date.now();
56707
+ let n3 = 0;
56708
+ const leaks = (dir, level) => {
56709
+ for (const e of readdirSync54(dir, { withFileTypes: true })) {
56710
+ if (++n3 > VIEW_WALK_BOUND || Date.now() - t0 > VIEW_WALK_MS)
56711
+ return true;
56712
+ const p = join154(dir, e.name);
56713
+ if (e.isSymbolicLink()) {
56714
+ if (level)
56715
+ continue;
56716
+ const t = resolve39(dir, readlinkSync8(p));
56717
+ let rt = t;
56718
+ try {
56719
+ rt = realpathSync44(t);
56720
+ } catch {}
56721
+ if (insideAny(t, roots) && !own.some((r) => rt === r || rt.startsWith(r + sep24)))
56722
+ return true;
56723
+ } else if (e.isDirectory() && leaks(p, dir === nm && levelDir(e.name)))
56724
+ return true;
56725
+ }
56726
+ return false;
56727
+ };
56728
+ if (leaks(nm, true))
56729
+ return false;
56730
+ const one3 = (p, q) => {
56731
+ let target = p;
56732
+ try {
56733
+ if (lstatSync34(p).isSymbolicLink()) {
56734
+ const rt = realpathSync44(p), m = member(rt);
56735
+ target = m !== null ? join154(baseDir, m) : rt;
56736
+ }
56737
+ } catch {
56738
+ return;
56739
+ }
56740
+ symlinkSync6(target, q);
56741
+ };
56742
+ mkdirSync81(out3);
56743
+ for (const e of readdirSync54(nm, { withFileTypes: true })) {
56744
+ const p = join154(nm, e.name), q = join154(out3, e.name);
56745
+ if (e.isDirectory() && levelDir(e.name)) {
56746
+ mkdirSync81(q);
56747
+ for (const s of readdirSync54(p))
56748
+ one3(join154(p, s), join154(q, s));
56749
+ } else
56750
+ one3(p, q);
56751
+ }
56752
+ return true;
56753
+ };
56754
+ return (cwd) => {
56755
+ const src = join154(repoDir, relative32(baseDir, cwd));
56756
+ if (!seen.has(src)) {
56757
+ let ok2 = false;
56758
+ try {
56759
+ ok2 = build(src, cwd);
56760
+ } catch {
56761
+ ok2 = false;
56762
+ }
56763
+ seen.set(src, ok2);
56764
+ }
56765
+ return seen.get(src);
56766
+ };
56767
+ }
56524
56768
  function isZeroRun(c, b) {
56525
56769
  const last = c.args[c.args.length - 1] ?? "";
56526
56770
  const k = classifyCheck({ kind: "test", ok: b.ok, cut: b.cut, missing: b.missing, out: b.out, ...goRunner(c.cmd, c.args), path: /\.[cm]?[jt]s$/.test(last) ? last : undefined });
@@ -56629,11 +56873,12 @@ function settleBranch(repoDir, branch, dir, stem2, pushed, extra = {}) {
56629
56873
  return { note: bundle ? `engine10: run branch ${branch} removed, its history is saved; restore it with: git fetch ${bundle} ${branch}:${branch}
56630
56874
  ` : "", deleted: true };
56631
56875
  }
56632
- function returnCheckout(repoDir, branch, orig) {
56876
+ function returnCheckout(repoDir, branch, orig, startSha = null) {
56633
56877
  const cur = currentBranch(repoDir);
56634
56878
  if (cur !== branch)
56635
56879
  return null;
56636
- if (!orig || orig === branch)
56880
+ const detached = !orig && !!startSha && /^[0-9a-f]{40}$/.test(startSha);
56881
+ if (!detached && (!orig || orig === branch))
56637
56882
  return `engine10: the checkout stays on ${branch}: the run did not record the branch it started from
56638
56883
  `;
56639
56884
  let dirty;
@@ -56643,8 +56888,11 @@ function returnCheckout(repoDir, branch, orig) {
56643
56888
  dirty = null;
56644
56889
  }
56645
56890
  if (dirty === null || dirty.split("\x00").filter(Boolean).some((l) => !l.slice(3).startsWith(".loki/")))
56646
- return `engine10: the checkout stays on ${branch}: it has uncommitted changes; return with: git checkout ${orig}
56891
+ return `engine10: the checkout stays on ${branch}: it has uncommitted changes; return with: git checkout ${detached ? `--detach ${startSha}` : orig}
56647
56892
  `;
56893
+ if (detached)
56894
+ return git14(repoDir, ["checkout", "-q", "--detach", startSha]) === null ? `engine10: the checkout stays on ${branch}: git checkout --detach ${startSha} failed; return with: git checkout --detach ${startSha}
56895
+ ` : null;
56648
56896
  return git14(repoDir, ["checkout", "-q", orig]) === null ? `engine10: the checkout stays on ${branch}: git checkout ${orig} failed; return with: git checkout ${orig}
56649
56897
  ` : null;
56650
56898
  }
@@ -56699,7 +56947,7 @@ function finishRunBranch(repoDir, runId2, end, env = process.env) {
56699
56947
  notes += `engine10: removed Loki's own acceptance test ${wallGone.join(", ")} from your tree; its sealed copy is under .loki/runs/${runId2}/wall/
56700
56948
  `;
56701
56949
  const keepHere = end.keepWork === true && tip !== null && tipOf(repoDir, end.baseSha ?? "") !== tip;
56702
- const stay = tip ? returnCheckout(repoDir, branch, end.orig) : null;
56950
+ const stay = tip ? returnCheckout(repoDir, branch, end.orig, end.baseSha ?? null) : null;
56703
56951
  if (stay)
56704
56952
  notes += stay;
56705
56953
  if (tip && !keepHere) {
@@ -56749,7 +56997,7 @@ function sweepRunBranches(repoDir, env = process.env, skipRunId) {
56749
56997
  return `engine10: removed ${removed} run branch(es) left by earlier runs${saved ? `; ${saved} with unpushed commits saved as bundles under .loki/runs/ (restore one with: git fetch <bundle> <branch>:<branch>)` : ""}
56750
56998
  ${kept.join("")}`;
56751
56999
  }
56752
- var exists2 = (repoDir, ref) => git14(repoDir, ["rev-parse", "--verify", "-q", `${ref}^{commit}`]) !== null, ok = (repoDir, args) => git14(repoDir, args) !== null, WALK_BOUND = 50000, REPO_LINK_FILE, IGNORED_CAP = 5000, RUNNER_CACHE_DIRS, TOOL_OUTPUT_FILE, ADVISORY_PATH, E10_BRANCH_RE, RUN_TMP_WORKTREE_RE, NOT_ELSEWHERE, tipOf = (repoDir, ref) => {
57000
+ var exists2 = (repoDir, ref) => git14(repoDir, ["rev-parse", "--verify", "-q", `${ref}^{commit}`]) !== null, ok = (repoDir, args) => git14(repoDir, args) !== null, WALK_BOUND = 50000, REPO_LINK_FILE, IGNORED_CAP = 5000, RUNNER_CACHE_DIRS, TOOL_OUTPUT_FILE, VIEW_WALK_BOUND = 1500000, VIEW_WALK_MS = 5000, ADVISORY_PATH, E10_BRANCH_RE, RUN_TMP_WORKTREE_RE, NOT_ELSEWHERE, tipOf = (repoDir, ref) => {
56753
57001
  try {
56754
57002
  return safeGit(repoDir, ["rev-parse", "--verify", "-q", `${ref}^{commit}`], { stdio: ["ignore", "pipe", "ignore"] }).trim() || null;
56755
57003
  } catch {
@@ -56809,9 +57057,11 @@ __export(exports_verify, {
56809
57057
  timeoutCarryOn: () => timeoutCarryOn,
56810
57058
  testConfigChanged: () => testConfigChanged,
56811
57059
  testCheckName: () => testCheckName,
57060
+ suiteTimeoutFor: () => suiteTimeoutFor,
56812
57061
  subtractBase: () => subtractBase,
56813
57062
  stage: () => stage10,
56814
57063
  skipped: () => skipped2,
57064
+ sameFailureLines: () => sameFailureLines,
56815
57065
  sameErrors: () => sameErrors,
56816
57066
  runnerCmd: () => runnerCmd,
56817
57067
  runOnce: () => runOnce3,
@@ -56846,11 +57096,14 @@ __export(exports_verify, {
56846
57096
  WALL_FAILURE_TAIL_FILE: () => WALL_FAILURE_TAIL_FILE,
56847
57097
  WALL_FAILURE_TAIL_CAP: () => WALL_FAILURE_TAIL_CAP,
56848
57098
  TIMEOUT_CARRY_NOTE: () => TIMEOUT_CARRY_NOTE,
57099
+ SUITE_MARGIN_MS: () => SUITE_MARGIN_MS,
56849
57100
  QUIET_RED: () => QUIET_RED,
57101
+ NO_ID_BASE_REASON: () => NO_ID_BASE_REASON,
56850
57102
  LINT_UNTOUCHED_NOTE: () => LINT_UNTOUCHED_NOTE,
56851
57103
  KILL_AFTER_MS: () => KILL_AFTER_MS,
56852
57104
  COLLATERAL_RED: () => COLLATERAL_RED,
56853
- BCE_REASON: () => BCE_REASON
57105
+ BCE_REASON: () => BCE_REASON,
57106
+ BASE_NOT_MEASURED: () => BASE_NOT_MEASURED
56854
57107
  });
56855
57108
  import { existsSync as existsSync109, mkdtempSync as mkdtempSync26, readFileSync as readFileSync142, realpathSync as realpathSync45, rmSync as rmSync50, statSync as statSync47 } from "fs";
56856
57109
  import { tmpdir as tmpdir32 } from "os";
@@ -56866,6 +57119,22 @@ function carriedTimeouts(prev, tests, changed, keep, env = process.env) {
56866
57119
  return [{ name: n3, cmd: p.cmd, result: "not_run", duration_s: 0, reason: `${String(p.reason).replace(/; carried from an earlier verify.*$/, "")}; ${TIMEOUT_CARRY_NOTE}` }];
56867
57120
  });
56868
57121
  }
57122
+ function sameFailureLines(headOut, base2, changed, symbols, headRoot, baseRoot) {
57123
+ if (!base2 || base2.ok)
57124
+ return false;
57125
+ const h = new Set(failureLines(rootless(stripAnsi(headOut), [headRoot]))), b = new Set(failureLines(rootless(stripAnsi(base2.out), [baseRoot])));
57126
+ if (h.size === 0 || h.size !== b.size || [...h].some((l) => !b.has(l)))
57127
+ return false;
57128
+ const names = lineNamesChange(changed, symbols);
57129
+ return ![...h].some((l) => names(l));
57130
+ }
57131
+ function suiteTimeoutFor(deadlineMs, nowMs, env = process.env) {
57132
+ const v = Number((env["LOKI_E10_SUITE_TIMEOUT_S"] ?? "").trim()), max = Number.isFinite(v) && v >= 1 ? Math.floor(v * 1000) : 300000;
57133
+ if (deadlineMs === undefined)
57134
+ return max;
57135
+ const left = deadlineMs - nowMs - SUITE_MARGIN_MS;
57136
+ return left < 1000 ? 0 : Math.min(max, left);
57137
+ }
56869
57138
  function crashSignature(out3) {
56870
57139
  const m = /^(?:[.sxXFE]*(?=Fatal Python error: )Fatal Python error: [^\n]+|Segmentation fault[^\n]*|E\s+ModuleNotFoundError: No module named '[^']+'|ModuleNotFoundError: No module named '[^']+'|ImportError while (?:loading conftest|importing test module)[^\n]*)$/m.exec(out3);
56871
57140
  return m ? m[0].replace(/^[.sxXFE]+(?=Fatal Python error: )/, "").replace(/\s+/g, " ").replace(/'\/[^']*\//g, "'").trim() : null;
@@ -57059,6 +57328,8 @@ async function runCheck(ctx, name, cmd2, args, signal, checks, opts = {}) {
57059
57328
  excerpts.set(check, failureExcerpt(attempt.out, ctx.repoDir));
57060
57329
  failTails.set(check, wallTailOf(attempt.out, ctx.repoDir));
57061
57330
  headErrors.set(check, errorsById(attempt.out));
57331
+ if (kind === "test" && !check.ids?.length)
57332
+ noIdOut.set(check, attempt.out);
57062
57333
  }
57063
57334
  if (result === "fail" && kind === "static" && name.startsWith("lint:tsc"))
57064
57335
  tscOut.set(check, attempt.out);
@@ -57526,9 +57797,24 @@ function tscUntouchedOnly(out3, pkgRel, touched, symbols, baseOut) {
57526
57797
  const base2 = new Set(tscLines(baseOut));
57527
57798
  return tscLines(out3).every((l) => base2.has(l));
57528
57799
  }
57529
- async function tscOnBase(ctx, groupCwd, signal, opts) {
57800
+ async function tscOnBase(ctx, groupCwd, signal, opts, shared2) {
57530
57801
  if (signal.aborted)
57531
57802
  return null;
57803
+ if (shared2 !== undefined) {
57804
+ if (!shared2)
57805
+ return null;
57806
+ try {
57807
+ const cwd = join155(shared2.dir, relative33(ctx.repoDir, groupCwd));
57808
+ if (!existsSync109(join155(cwd, "tsconfig.json")) || !shared2.link(cwd))
57809
+ return null;
57810
+ if (cwd !== shared2.dir)
57811
+ shared2.link(shared2.dir);
57812
+ const r = await runOnce3("npx", ["--no-install", "tsc", "--noEmit", "-p", "."], cwd, AbortSignal.any([signal, AbortSignal.timeout(opts.timeoutMs ?? CHECK_TIMEOUT_MS)]), { ...opts });
57813
+ return r.missing || r.cut ? null : r.out;
57814
+ } catch {
57815
+ return null;
57816
+ }
57817
+ }
57532
57818
  const dir = mkdtempSync26(join155(tmpdir32(), "e10-basetsc-")), git15 = (args) => {
57533
57819
  safeGit(ctx.repoDir, args, { stdio: "ignore", repoDrivers: true });
57534
57820
  };
@@ -57557,7 +57843,7 @@ function lintFallbacks(repoDir, tool, env = process.env) {
57557
57843
  return lintMissingDiscloseOn(env) ? toolFallbacks(repoDir, tool, env) : [];
57558
57844
  }
57559
57845
  async function runLintChecks(ctx, changed, signal, checks, opts = {}) {
57560
- const { api, keep, untouched, ...runOpts } = opts;
57846
+ const { api, keep, untouched, base: base2, ...runOpts } = opts;
57561
57847
  opts = runOpts;
57562
57848
  const pre = [];
57563
57849
  const py = changed.filter((f) => f.endsWith(".py"));
@@ -57592,11 +57878,11 @@ async function runLintChecks(ctx, changed, signal, checks, opts = {}) {
57592
57878
  const c = await runCheck(ctx, `lint:tsc${sfx}`, "npx", ["--no-install", "tsc", "--noEmit", "-p", "."], signal, checks, { ...co, kind: "static" });
57593
57879
  if (c.result === "fail" && tscOnlyIgnored(ctx.repoDir, g2.cwd, tscOut.get(c) ?? ""))
57594
57880
  pre.push(c.name);
57595
- else if (c.result === "fail" && keep && tscLocalKeys(tscOut.get(c) ?? "", g2.root, keep, [...keep]) && tscUntouchedLocal(tscOut.get(c) ?? "", g2.root, keep, [...keep], await tscOnBase(ctx, g2.cwd, signal, co)))
57881
+ else if (c.result === "fail" && keep && tscLocalKeys(tscOut.get(c) ?? "", g2.root, keep, [...keep]) && tscUntouchedLocal(tscOut.get(c) ?? "", g2.root, keep, [...keep], await tscOnBase(ctx, g2.cwd, signal, co, base2 ? base2() : undefined)))
57596
57882
  pre.push(c.name);
57597
57883
  else if (c.result === "fail" && keep && untouched && lintUntouchedOn()) {
57598
57884
  const syms = diffSymbols(ctx, [...keep]), o = tscOut.get(c) ?? "";
57599
- if (tscUntouchedShape(o, g2.root, keep, syms) && tscUntouchedOnly(o, g2.root, keep, syms, await tscOnBase(ctx, g2.cwd, signal, co)))
57885
+ if (tscUntouchedShape(o, g2.root, keep, syms) && tscUntouchedOnly(o, g2.root, keep, syms, await tscOnBase(ctx, g2.cwd, signal, co, base2 ? base2() : undefined)))
57600
57886
  untouched.push(c.name);
57601
57887
  }
57602
57888
  }
@@ -57608,7 +57894,433 @@ async function runLintChecks(ctx, changed, signal, checks, opts = {}) {
57608
57894
  }
57609
57895
  return pre;
57610
57896
  }
57611
- var timeoutCarryOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_TIMEOUT_CARRY"] ?? "").trim()), TIMEOUT_CARRY_NOTE = "carried from an earlier verify of this run, not rerun (untouched file)", KILL_AFTER_MS = 5000, CHECK_TIMEOUT_MS = 60000, excerpts, checkExcerpt = (c) => excerpts.get(c) ?? "", suites, failTails, tscOut, crashSigs, baseCrashEnvOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_BASE_CRASH_ENV"] ?? "").trim()), BCE_REASON = "fails the same way on base, so its result cannot be read: the environment, not the change", headErrors, WALL_FAILURE_TAIL_CAP = 16384, wallTailOf = (out3, repoDir) => redactSecrets(stripAnsi(out3).replace(/\r/g, "").split(repoDir.replace(/\/+$/, "") + "/").join("")).slice(-WALL_FAILURE_TAIL_CAP), isHold = (c) => isHoldoutCheck(c.name), pubHold = (c) => ({ name: "holdout", cmd: "holdout", result: c.result, duration_s: c.duration_s, ...c.n !== undefined ? { n: c.n } : {}, ...c.sk !== undefined ? { sk: c.sk } : {}, ...c.owner ? { owner: c.owner, reason: "holdout infrastructure failure" } : {} }), testCheckName = (t) => `${t.runner}:${t.path}`, QUIET_RED = "excused as red on base although its error text differs from base by noise only (the same error shapes; no changed file or symbol appears in the failure)", COLLATERAL_RED = "relevant test already failing on base, still failing the same tests (it imports a file the task names; capped, not blocking)", noTestFallbackOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_NO_TEST_FALLBACK"] ?? "").trim()), ownByPathOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_OWN_BY_PATH"] ?? "").trim()), TEST_TITLE_RE, dedupeTests = (tests) => [...new Map(tests.map((t) => [`${t.runner}:${t.path}`, t])).values()], verifyBatchOn = (env = process.env) => env["LOKI_E10_VERIFY_BATCH"] !== "0", BATCH_MIN = 2, UNHANDLED_RE, batchTimeoutMs = (files) => Math.max(CHECK_TIMEOUT_MS, Math.min(300000, files * 5000)), vitestFile = (t, c) => t.runner === "vitest" && c.cmd === "npx" && c.args.length === 4 && c.args[0] === "--no-install" && c.args[1] === "vitest" && c.args[2] === "run", goBatchOn = (env = process.env) => verifyBatchOn(env) && env["LOKI_E10_GO_BATCH"] !== "0", goFileCmd = (t, c) => t.runner === "go" && c.cmd === "go" && c.args.length === 5 && c.args[0] === "test" && c.args[1] === "-json" && c.args[2] === "-run" && /^\^\([A-Za-z0-9_|]+\)\$$/.test(c.args[3]), goBatchable = (t, targets, changed, env = process.env) => goBatchOn(env) && t.runner === "go" && !targets.has(testCheckName(t)) && !changed.includes(t.path), uncausedOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_UNCAUSED_NO_FIX"] ?? "").trim()), LINT_CONFIG, INERT_FILE, feedsFixRound = (c, pre) => c.result === "fail" && !pre.names.includes(c.name) && !pre.sameError.includes(c.name) && !isHoldoutCheck(c.name), baseMemoOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_BASE_MEMO"] ?? "").trim()), ESLINT_CONFIGS, excuseLint = (ctx, signal, c, tool, cmd2, prefix, cwd, rel, opts) => c.result !== "fail" || signal.aborted ? Promise.resolve(false) : staticPreExisting(tool, prefix, rel, { run: async (a, stdin) => {
57897
+ function baseTree(ctx) {
57898
+ let dir, linker = null, view = null;
57899
+ const git15 = (args) => {
57900
+ safeGit(ctx.repoDir, args, { stdio: "ignore", repoDrivers: true });
57901
+ };
57902
+ return {
57903
+ get(changed, gate) {
57904
+ if (dir !== undefined)
57905
+ return dir;
57906
+ const d = mkdtempSync26(join155(tmpdir32(), "e10-base-"));
57907
+ gate = gate.ignored ? { ...gate, ignored: [] } : gate;
57908
+ try {
57909
+ git15(["-c", "core.hooksPath=/dev/null", "worktree", "add", "--detach", d, ctx.baseSha]);
57910
+ dir = d;
57911
+ linker = changed.some((f) => MANIFESTS2.test(f)) ? null : baseDepsLinker(d, ctx.repoDir, gate);
57912
+ view = linker ? baseDepsView(d, ctx.repoDir, gate) : null;
57913
+ } catch {
57914
+ rmSync50(d, { recursive: true, force: true });
57915
+ dir = null;
57916
+ }
57917
+ return dir;
57918
+ },
57919
+ link: (cwd) => linker && view ? linker(cwd) || view(cwd) : false,
57920
+ dispose() {
57921
+ if (!dir)
57922
+ return;
57923
+ try {
57924
+ git15(["worktree", "remove", "--force", dir]);
57925
+ } catch {}
57926
+ rmSync50(dir, { recursive: true, force: true });
57927
+ try {
57928
+ git15(["worktree", "prune"]);
57929
+ } catch {}
57930
+ dir = null;
57931
+ }
57932
+ };
57933
+ }
57934
+ async function runVerify(ctx, signal, bt) {
57935
+ {
57936
+ let changed;
57937
+ const ownWall = (ctx.outputs().wall?.files ?? []).map((f) => f.path), live2 = (l) => withoutStaleWall(l, ownWall, ctx.repoDir);
57938
+ try {
57939
+ changed = live2(changedFiles(ctx.repoDir, ctx.baseSha, installOwned(ctx.repoDir, ctx.outputs().intake?.install_created)));
57940
+ } catch (err) {
57941
+ return { status: "failed", data: {}, reason: `git diff against base failed: ${err.message}` };
57942
+ }
57943
+ if (changed.length === 0) {
57944
+ const implementExit = ctx.outputs().implement?.exit;
57945
+ if (implementExit === "already_done") {
57946
+ return { status: "completed", data: { already_satisfied: true, checks: [], flaky: [], failures_grouped: [], changed_files: [] } };
57947
+ }
57948
+ return { status: "failed", data: { changed_files: [] }, reason: "empty diff without an already_done marker" };
57949
+ }
57950
+ let risk = (() => {
57951
+ try {
57952
+ const r = classifyRisk(live2(diffFiles(ctx.repoDir, ctx.baseSha, installOwned(ctx.repoDir, ctx.outputs().intake?.install_created))));
57953
+ recordRisk(ctx.repoDir, r);
57954
+ return r;
57955
+ } catch {
57956
+ return null;
57957
+ }
57958
+ })();
57959
+ const checks = [];
57960
+ const api = loadProjectApi(ctx.repoDir);
57961
+ const map0 = await ctx.tests.detect(ctx.repoDir), map = { ...map0, tests: live2(map0.tests) };
57962
+ const impacted = ctx.tests.impacted(map, changed);
57963
+ const changedTestFiles = map.tests.filter((t) => changed.includes(t.path));
57964
+ const wall = ctx.outputs().wall ?? {};
57965
+ const wallPaths = new Set((wall.files ?? []).map((f) => isAbsolute21(f.path) ? relative33(ctx.repoDir, f.path) : f.path));
57966
+ const intake = ctx.outputs().intake, repoMap = loadRepoMap(intake?.repomap_ref), named2 = namedFiles(intake?.task ?? "", repoMap), relevant2 = ctx.tests.impacted(map, named2);
57967
+ const recorded = new Map((wall.files ?? []).flatMap((f) => f.runner ? [[isAbsolute21(f.path) ? relative33(ctx.repoDir, f.path) : f.path, f.runner]] : []));
57968
+ const wallTests = [...wallPaths].flatMap((p) => {
57969
+ const rec2 = recorded.get(p), found = map.tests.find((t) => t.path === p && (!rec2 || t.runner === rec2));
57970
+ if (found)
57971
+ return [found];
57972
+ const runner = rec2 ?? guessRunner(basename44(p), map.runners, p);
57973
+ return runner && (runner !== "bun" || map.runners.includes("bun") || /[._](?:test|spec)\.[cm]?[jt]sx?$/.test(p)) ? [{ runner, path: p }] : [];
57974
+ });
57975
+ const dep = dependentTests(ctx.repoDir, map, changed, [...impacted, ...changedTestFiles, ...wallTests, ...relevant2]), depNames = new Set(dep.tests.map(testCheckName));
57976
+ const tests0 = failedFirst(dedupeTests([...wallTests, ...relevant2, ...changedTestFiles, ...changedSymbolsFirst(ctx, impacted, changed), ...dep.tests]), ctx.outputs().verify?.checks);
57977
+ const tests = tests0.length === 0 ? [...mochaTargets(ctx.repoDir, changed), ...avaTargets(ctx.repoDir, changed)] : tests0;
57978
+ const own = ownByPathOn() ? ownTests(relevant2, named2, changed) : relevant2;
57979
+ const hashes = fileHashes(ctx.repoDir, changed), qs = quickScope(ctx.outputs(), hashes), keep = new Set([...qs?.blocking ?? [], ...[...wallTests, ...own].map(testCheckName)]);
57980
+ const sinceTests = qs ? [...ctx.tests.impacted(map, qs.since), ...map.tests.filter((t) => qs.since.includes(t.path))] : [], split2 = qs ? quickSplit(tests, keep, sinceTests) : { first: tests, rest: [] };
57981
+ const done = [], wallNames0 = new Set(wallTests.map(testCheckName)), targets0 = new Set([...wallTests, ...own].map(testCheckName)), wallDropped0 = [...wallPaths].filter((p) => !wallTests.some((t) => t.path === p));
57982
+ let holdN = wall.holdout_dir ? null : 0;
57983
+ let partialPre = { names: [], ids: [] };
57984
+ const deadline = ctx.verifyDeadlineMs;
57985
+ const publish = () => {
57986
+ if (!ctx.partial)
57987
+ return;
57988
+ const ran2 = checks.length ? checks : done, w = ran2.filter((c) => wallNames0.has(c.name) || isHold(c)), allRan = holdN !== null && ran2.filter(isHold).length >= holdN && wallTests.every((t) => ran2.some((c) => c.name === testCheckName(t)));
57989
+ const wp = w.some((c) => c.result === "fail") ? false : w.length > 0 && allRan && wallDropped0.length === 0 && w.every((c) => c.result === "pass") ? true : undefined;
57990
+ ctx.partial("verify", { checks: ran2.map((c) => isHold(c) ? pubHold(c) : c), flaky: ran2.filter((c) => c.result === "flaky").map((c) => isHold(c) ? "holdout" : c.name), ...wp === undefined ? {} : { wall_passed: wp }, changed_files: changed, ...partialPre.names.length ? { pre_red_checks: partialPre.names, pre_red: partialPre.ids } : {}, not_proven: wallDropped0.map((p) => `Wall test not executed: ${p}: ${NO_RUNNER_REASON}`), target_checks: ran2.filter((c) => c.result === "pass" && (targets0.has(c.name) || isHold(c))).map((c) => isHold(c) ? "holdout" : c.name), risk });
57991
+ };
57992
+ const scopedOut = scopedOutOf(map);
57993
+ if (scopedOut.length)
57994
+ ctx.emit("test.scoped_out", "verify", { tests: scopedOut });
57995
+ const batchable = (t) => verifyBatchOn() && t.runner === "vitest" && !wallNames0.has(testCheckName(t));
57996
+ const runTests = async (all) => {
57997
+ const byName = new Map;
57998
+ for (const c of carriedTimeouts(ctx.outputs().verify?.checks ?? [], all, changed, new Set([...wallNames0, ...targets0]))) {
57999
+ byName.set(c.name, [c]);
58000
+ done.push(c);
58001
+ ctx.emit("test.result", "verify", { ...c });
58002
+ }
58003
+ const list = all.filter((t) => !byName.has(testCheckName(t)));
58004
+ const alone = async (l) => {
58005
+ (await mapPool(l, verifyJobs(), async (t) => {
58006
+ const tc = commandFor(t, ctx.repoDir, api), slot = [];
58007
+ await runCheck(ctx, testCheckName(t), tc.cmd, tc.args, signal, slot, { ...tc.interpreter ? { interpreter: tc.interpreter } : {}, protect: [...wallTests, ...relevant2].includes(t), ...tc.pkgRoot !== "." ? { cwd: tc.cwd } : {} });
58008
+ done.push(...slot);
58009
+ publish();
58010
+ return slot;
58011
+ }, () => signal.aborted)).forEach((sl, i) => {
58012
+ if (sl)
58013
+ byName.set(testCheckName(l[i]), sl);
58014
+ });
58015
+ };
58016
+ const goPart = (t) => goBatchable(t, targets0, changed);
58017
+ await alone(list.filter((t) => !batchable(t) && !goPart(t)));
58018
+ const goB = await runGoBatches(ctx, list.filter(goPart), api, signal, (c) => {
58019
+ done.push(c);
58020
+ publish();
58021
+ });
58022
+ for (const [n3, c] of goB)
58023
+ byName.set(n3, [c]);
58024
+ await alone(list.filter((t) => goPart(t) && !goB.has(testCheckName(t))));
58025
+ for (const part of [list.filter((t) => batchable(t) && targets0.has(testCheckName(t))), list.filter((t) => batchable(t) && !targets0.has(testCheckName(t)))]) {
58026
+ for (const [n3, c] of await runVitestBatches(ctx, part, api, signal, (c2) => {
58027
+ done.push(c2);
58028
+ publish();
58029
+ }))
58030
+ byName.set(n3, [c]);
58031
+ }
58032
+ await alone(list.filter((t) => batchable(t) && !byName.has(testCheckName(t))));
58033
+ checks.push(...all.flatMap((t) => byName.get(testCheckName(t)) ?? []));
58034
+ };
58035
+ await runTests(split2.first);
58036
+ const zgEnv = zeroGate(ctx.outputs().intake?.zero_baseline), envAsIntake = (rel) => {
58037
+ if (zgEnv.sinceMs === undefined)
58038
+ return false;
58039
+ const root = api?.packageRootOf(rel) ?? ".";
58040
+ return [...new Set([root, "."])].every((d) => !envChangedSince(ctx.repoDir, d === "." ? ctx.repoDir : join155(ctx.repoDir, d), zgEnv.sinceMs, zgEnv.ignored ?? null, zgEnv.deps));
58041
+ };
58042
+ const depsSeen = new Map, depsAsIntake = (rel) => {
58043
+ if (zgEnv.sinceMs === undefined)
58044
+ return false;
58045
+ return [...new Set([api?.packageRootOf(rel) ?? ".", "."])].every((d) => {
58046
+ if (!depsSeen.has(d))
58047
+ depsSeen.set(d, !envChangedSince(ctx.repoDir, d === "." ? ctx.repoDir : join155(ctx.repoDir, d), zgEnv.sinceMs, [], zgEnv.deps));
58048
+ return depsSeen.get(d);
58049
+ });
58050
+ };
58051
+ const zg0 = zeroGate(ctx.outputs().intake?.zero_baseline);
58052
+ const suiteSpecs = (() => {
58053
+ try {
58054
+ return baseOnDemandOn() ? fullSuiteSpecs(ctx.repoDir, map.runners) : [];
58055
+ } catch {
58056
+ return [];
58057
+ }
58058
+ })(), baseUnmeasured = new Set;
58059
+ const ensureBase = async (spec) => {
58060
+ if (!baseOnDemandOn() || signal.aborted)
58061
+ return;
58062
+ const tmo = Math.floor(suiteTimeoutFor(deadline, Date.now()) / 1000);
58063
+ if (tmo < 1)
58064
+ return;
58065
+ const dir = bt.get(changed, zg0);
58066
+ if (!dir)
58067
+ return;
58068
+ const cwd = join155(dir, spec.cwd), linked = bt.link(cwd) && (cwd === dir || bt.link(dir));
58069
+ if (!linked && [spec.cwd, "."].some((d) => ["node_modules", ".venv"].some((x) => existsSync109(join155(ctx.repoDir, d, x))))) {
58070
+ baseUnmeasured.add(`${spec.name} (\`${spec.cmd}\`) ${BASE_NOT_MEASURED}`);
58071
+ return;
58072
+ }
58073
+ await baselineSuiteOnDemand(ctx.repoDir, ctx.baseSha, spec, dir, asyncShellRunner(signal), tmo, () => signal.aborted);
58074
+ };
58075
+ for (const c of checks) {
58076
+ const rel = c.name.slice(c.name.indexOf(":") + 1);
58077
+ if (c.result !== "fail" || !changed.includes(rel) || wallNames0.has(c.name) || isHold(c))
58078
+ continue;
58079
+ const tcw = api?.packageOf(rel)?.commands.test?.cwd, spec = tcw === undefined ? undefined : suiteSpecs.find((sp) => sp.cwd === tcw);
58080
+ if (spec)
58081
+ await ensureBase(spec);
58082
+ }
58083
+ const touchedRed = new Set(checks.filter((c) => {
58084
+ const rel = c.name.slice(c.name.indexOf(":") + 1);
58085
+ return c.result === "fail" && changed.includes(rel) && !wallNames0.has(c.name) && !isHold(c) && envAsIntake(rel) && touchedRedOnBase(ctx.repoDir, ctx.baseSha, { ids: c.ids, errors: headErrors.get(c) }, editedTestTitles(ctx.repoDir, ctx.baseSha, rel));
58086
+ }).map((c) => c.name));
58087
+ const decisive = qs !== null && checks.some((c) => c.result === "fail" && !touchedRed.has(c.name) && (keep.has(c.name) || changed.includes(c.name.slice(c.name.indexOf(":") + 1))));
58088
+ if (!decisive)
58089
+ await runTests(split2.rest);
58090
+ const complete = !decisive;
58091
+ const pg = (ctx.outputs().verify?.failures_grouped ?? []).map((g2) => g2.signature), fs2 = (x) => x.startsWith("full suite") || x.startsWith("lint:"), failSigs = (l) => [...new Set(l.filter((c) => c.result === "fail" && !fs2(c.name) && !isHoldoutCheck(c.name)).map((c) => failureSignature(c)))].sort(), same = (a, b) => a.length === b.length && a.every((x, i) => x === b[i]);
58092
+ const settle2 = decisive && pg.some((x) => x.startsWith("full suite")) && same(failSigs(ctx.outputs().verify?.checks ?? []), failSigs(checks.filter((c) => !isHold(c))));
58093
+ const hold = wall.holdout_dir ? stageHoldout(wall.holdout_dir, ctx.repoDir) : null;
58094
+ if (hold && !hold.missing.length)
58095
+ holdN = hold.tests.length;
58096
+ try {
58097
+ for (const [i, h] of (hold?.tests ?? []).entries()) {
58098
+ if (signal.aborted)
58099
+ break;
58100
+ const t = h, tc = commandFor(t, ctx.repoDir, api);
58101
+ await runCheck(ctx, `holdout:${i + 1}`, tc.cmd, tc.args, signal, checks, { ...tc.interpreter ? { interpreter: tc.interpreter } : {}, protect: true, opaque: true, ...tc.pkgRoot !== "." ? { cwd: tc.cwd } : {} });
58102
+ publish();
58103
+ }
58104
+ } finally {
58105
+ hold?.cleanup();
58106
+ }
58107
+ if (hold?.missing.length) {
58108
+ for (const m of hold.missing)
58109
+ recordHoldoutTriage(ctx.runDir, { check: "holdout:store", result: "not_run", reason: m });
58110
+ const k = { name: "holdout:store", cmd: "holdout", result: "not_run", duration_s: 0, reason: "holdout store unavailable", owner: "harness" };
58111
+ checks.push(k);
58112
+ ctx.emit("test.result", "verify", { ...pubHold(k) });
58113
+ }
58114
+ const targetNames = new Set([...[...wallTests, ...own].map(testCheckName), ...checks.filter(isHold).map((c) => c.name)]);
58115
+ const cfgChanged = [...new Set([...testConfigChanged(ctx.repoDir, ctx.baseSha, changed), ...hiddenConfigChanged(ctx.repoDir, ctx.outputs().intake?.hidden_cfg)])];
58116
+ const collateral = new Set((ownByPathOn() ? relevant2.filter((t) => !own.includes(t)) : collateralTests(relevant2, named2)).map(testCheckName)), ownRel = new Set([...relevant2.map(testCheckName)].filter((n3) => !collateral.has(n3)));
58117
+ const symbols = checks.some((c) => c.result === "fail") ? diffSymbols(ctx, changed) : [];
58118
+ const preRed = await subtractBase(ctx, api, checks, tests, changed, new Set(wallTests.map(testCheckName)), new Set(relevant2.map(testCheckName)), signal, cfgChanged.length === 0, zeroGate(ctx.outputs().intake?.zero_baseline), depNames, ownRel, symbols);
58119
+ for (const e of preRed.envCrash) {
58120
+ const c = checks.find((x) => x.name === e.name && x.result === "fail");
58121
+ if (c) {
58122
+ c.result = "not_run";
58123
+ c.reason = `${BCE_REASON} (${e.sig})`;
58124
+ }
58125
+ }
58126
+ const noIdNotes = [];
58127
+ {
58128
+ const cand = baseOnDemandOn() ? checks.filter((c) => c.result === "fail" && !c.ids?.length && noIdOut.has(c) && !isHold(c) && tests.some((t) => testCheckName(t) === c.name)) : [];
58129
+ const dir = cand.length && !signal.aborted ? bt.get(changed, zg0) : null, byLine = new Map;
58130
+ const sub2 = (x) => dir ? x.split(ctx.repoDir).join(dir) : x;
58131
+ for (const c of cand) {
58132
+ if (!dir || signal.aborted || deadline !== undefined && Date.now() > deadline - SUITE_MARGIN_MS)
58133
+ break;
58134
+ const t = tests.find((x) => testCheckName(x) === c.name), tc = commandFor(t, ctx.repoDir, api), head = noIdOut.get(c);
58135
+ const cwd = sub2(tc.cwd);
58136
+ bt.link(cwd);
58137
+ if (cwd !== dir)
58138
+ bt.link(dir);
58139
+ const cmd2 = sub2(tc.cmd);
58140
+ if (isAbsolute21(cmd2) && !existsSync109(cmd2))
58141
+ continue;
58142
+ const b = await runOnce3(cmd2, tc.args.map(sub2), cwd, signal, {});
58143
+ if (b.cut || b.missing || !sameFailureLines(head, b, changed, symbols, ctx.repoDir, dir))
58144
+ continue;
58145
+ const line2 = failureLines(rootless(stripAnsi(head), [ctx.repoDir])).find((l) => /error|No module named|not found|cannot|failed/i.test(l)) ?? failureLines(rootless(stripAnsi(head), [ctx.repoDir]))[0] ?? "";
58146
+ c.result = "not_run";
58147
+ c.reason = `${NO_ID_BASE_REASON} (${line2.slice(0, 160)})`;
58148
+ delete c.first_error;
58149
+ delete c.ids;
58150
+ delete c.anchor;
58151
+ byLine.set(line2, [...byLine.get(line2) ?? [], c.name]);
58152
+ }
58153
+ for (const [line2, names] of byLine)
58154
+ noIdNotes.push(`${NO_ID_BASE_REASON} (${line2.slice(0, 160)}): ${names.length} check(s), first ${names[0]}`);
58155
+ }
58156
+ for (const c of checks) {
58157
+ if (c.result !== "fail" || preRed.names.includes(c.name) || targetNames.has(c.name) || changed.includes(c.name.slice(c.name.indexOf(":") + 1)) || preRed.compared.includes(c.name) && !preRed.sameError.includes(c.name))
58158
+ continue;
58159
+ const t = tests.find((x) => testCheckName(x) === c.name), tcw = t ? api?.packageOf(t.path)?.commands.test?.cwd : undefined, spec = tcw === undefined ? undefined : suiteSpecs.find((sp) => sp.cwd === tcw);
58160
+ if (spec)
58161
+ await ensureBase(spec);
58162
+ }
58163
+ const fixRounds = Number(ctx.outputs().fix?.round ?? 0) || 0, collateralSame = preRed.sameError.filter((n3) => collateral.has(n3) && !preRed.names.includes(n3));
58164
+ const collateralBase = checks.filter((c) => c.result === "fail" && collateral.has(c.name) && !preRed.names.includes(c.name) && envAsIntake(c.name.slice(c.name.indexOf(":") + 1)) && collateralOnBaseline(ctx.repoDir, ctx.baseSha, c.name.slice(c.name.indexOf(":") + 1), { ids: c.ids, errors: headErrors.get(c) }, changed, coveredStem(c.name.slice(c.name.indexOf(":") + 1)))).map((c) => c.name);
58165
+ if (collateralBase.length) {
58166
+ preRed.names.push(...collateralBase);
58167
+ preRed.ids.push(...checks.filter((c) => collateralBase.includes(c.name)).flatMap((c) => c.ids ?? []));
58168
+ }
58169
+ const collateralRed = fixRounds >= 1 ? collateralSame.filter((n3) => !collateralBase.includes(n3)) : [];
58170
+ if (collateralRed.length) {
58171
+ preRed.names.push(...collateralRed);
58172
+ preRed.ids.push(...checks.filter((c) => collateralRed.includes(c.name)).flatMap((c) => c.ids ?? []));
58173
+ }
58174
+ const touchedExcused = [...touchedRed].filter((n3) => !preRed.names.includes(n3) && checks.some((c) => c.name === n3 && c.result === "fail"));
58175
+ if (touchedExcused.length) {
58176
+ preRed.names.push(...touchedExcused);
58177
+ preRed.ids.push(...checks.filter((c) => touchedExcused.includes(c.name)).flatMap((c) => c.ids ?? []));
58178
+ }
58179
+ const suiteOf = (name) => {
58180
+ const t = tests.find((x) => testCheckName(x) === name), pkg = t ? api?.packageOf(t.path) : null;
58181
+ return pkg?.commands.test ? `full suite: ${pkg.name}` : undefined;
58182
+ };
58183
+ const attr = attribute(ctx.repoDir, ctx.baseSha, checks.filter((c) => c.result === "fail" && !preRed.names.includes(c.name)).map((c) => ({ name: c.name, ids: c.ids, eligible: !targetNames.has(c.name) && !changed.includes(c.name.slice(c.name.indexOf(":") + 1)), ...suiteOf(c.name) && (preRed.compared.includes(c.name) || depsAsIntake(c.name.slice(c.name.indexOf(":") + 1))) ? { suite: suiteOf(c.name), ...headErrors.get(c) ? { errors: headErrors.get(c) } : {}, ...preRed.sameError.includes(c.name) ? { rerun: "same" } : preRed.compared.includes(c.name) ? { rerun: "differs" } : {} } : {} })));
58184
+ attr.introducedChecks = [...new Set(attr.introducedChecks.map((n3) => isHoldoutCheck(n3) ? "holdout" : n3))];
58185
+ preRed.names.push(...attr.preExistingChecks);
58186
+ preRed.ids.push(...attr.preExistingIds);
58187
+ partialPre = { names: [...preRed.names], ids: [...preRed.ids] };
58188
+ publish();
58189
+ const lintUntouchedNames = [];
58190
+ if (!signal.aborted) {
58191
+ const lintUntouched = lintUntouchedNames;
58192
+ const lintPre = await runLintChecks(ctx, complete || [...qs?.blocking ?? []].some((n3) => n3.startsWith("lint:")) ? changed : changed.filter((f) => qs?.since.includes(f)), signal, checks, { api, wall: wallPaths, keep: new Set([...changed, ...named2]), untouched: lintUntouched, ...baseOnDemandOn() ? { base: () => {
58193
+ const d = bt.get(changed, zg0);
58194
+ return d ? { dir: d, link: bt.link } : null;
58195
+ } } : {} });
58196
+ preRed.names.push(...lintPre);
58197
+ if (lintPre.length)
58198
+ attr.line = [attr.line, `baseline: ${lintPre.join(", ")} static diagnostics already on base (not blocking)`].filter(Boolean).join("; ");
58199
+ preRed.names.push(...lintUntouched);
58200
+ if (lintUntouched.length)
58201
+ attr.line = [attr.line, `${LINT_UNTOUCHED_NOTE}: ${lintUntouched.join(", ")}`].filter(Boolean).join("; ");
58202
+ if (isLokiModeRepo(ctx.repoDir)) {
58203
+ await runCheck(ctx, "select-tests", "bash", ["scripts/select-tests.sh", "--files", "-", "--run"], signal, checks, {
58204
+ kind: "static",
58205
+ stdin: changed.join(`
58206
+ `) + `
58207
+ `
58208
+ });
58209
+ }
58210
+ }
58211
+ const notExcused = [];
58212
+ const fullNotProven = new Set;
58213
+ const fullErr = new Map;
58214
+ const ranDeeper = [];
58215
+ const ntf = noTestFallbackOn() && risk?.tier === "low" && !checks.some((c) => !c.name.startsWith("lint:") && (c.result === "pass" || c.result === "fail"));
58216
+ if (risk && (risk.tier !== "low" || ntf) && !signal.aborted && (complete || settle2)) {
58217
+ const { runFullSuite: runFullSuite2 } = await Promise.resolve().then(() => (init_deep(), exports_deep));
58218
+ const full = [];
58219
+ await runFullSuite2(ctx, signal, { changed, ...ntf && risk?.tier === "low" ? { ownedOnly: true } : {}, ...baseOnDemandOn() ? { scope: true, suiteTimeoutMs: () => suiteTimeoutFor(deadline, Date.now()), ensureBase } : {}, targetPassed: checks.some((c) => targetNames.has(c.name) && c.result === "pass" && hasExecutedProof([c])), wallBaseRed: wallRedOnBaseOf(ctx.outputs().wall?.base_run), proofFiles: wallProofOf(checks, [...wallTests.map((t) => ({ name: testCheckName(t), path: t.path })), ...(hold?.tests ?? []).map((h, i) => ({ name: `holdout:${i + 1}`, path: h.path }))]) }, full, fullNotProven);
58220
+ for (const c of full) {
58221
+ const k = { name: c.name, cmd: c.cmd, result: c.result, duration_s: c.duration_s, ...c.reason ? { reason: c.reason } : {}, ...c.count ? { count: c.count } : {}, ...c.result === "fail" ? { ...c.ids ? { ids: c.ids } : {}, ...c.first_error ? { first_error: c.first_error } : {} } : {} };
58222
+ suites.add(k);
58223
+ checks.push(k);
58224
+ ctx.emit("test.result", "verify", { ...k });
58225
+ if (c.excerpt)
58226
+ excerpts.set(k, c.excerpt);
58227
+ }
58228
+ for (const c of full)
58229
+ if (c.errors)
58230
+ fullErr.set(c.name, c.errors);
58231
+ for (const c of full) {
58232
+ const spec = c.result === "fail" ? suiteSpecs.find((sp) => sp.name === c.name && sp.cmd === c.cmd) : undefined;
58233
+ if (spec)
58234
+ await ensureBase(spec);
58235
+ }
58236
+ if (baseOnDemandOn() && ctx.runDir)
58237
+ writeBaselineRecord(ctx.repoDir, ctx.runDir);
58238
+ for (const n3 of baseUnmeasured)
58239
+ fullNotProven.add(n3);
58240
+ const blockedIds = checks.filter((c) => c.result === "fail" && !suites.has(c) && !preRed.names.includes(c.name)).flatMap((c) => c.ids ?? []);
58241
+ const shown = new Set(checks.filter((c) => touchedExcused.includes(c.name)).flatMap((c) => c.ids ?? [])), fa = attributeFullSuite(ctx.repoDir, ctx.baseSha, full, blockedIds, changed, symbols, shown);
58242
+ preRed.names.push(...fa.preExistingChecks);
58243
+ preRed.ids.push(...fa.preExistingIds);
58244
+ attr.introducedChecks.push(...fa.introducedChecks);
58245
+ attr.line = [attr.line, fa.line].filter(Boolean).join("; ") || null;
58246
+ notExcused.push(...whyFullSuiteNotExcused(ctx.repoDir, ctx.baseSha, full, changed, fa.preExistingChecks, blockedIds, shown));
58247
+ if (full.some((c) => c.result === "pass" || c.result === "fail")) {
58248
+ ranDeeper.push("full test command", "full suite");
58249
+ risk = markExecuted(risk, ranDeeper);
58250
+ recordRisk(ctx.repoDir, risk);
58251
+ }
58252
+ const known = new Set(checks.filter((c) => c.result === "fail" && (preRed.sameError.includes(c.name) || wallNames0.has(c.name))).flatMap((c) => c.ids ?? []));
58253
+ for (const c of full)
58254
+ if (c.result === "fail" && c.ids?.length && !c.unhandled?.length && comparableIds(c.ids).every((i) => known.has(i)) && !preRed.names.includes(c.name)) {
58255
+ preRed.knownRed.push(c.name);
58256
+ preRed.sameError.push(c.name);
58257
+ }
58258
+ }
58259
+ const baseRed = baseRedById(ctx.repoDir, ctx.baseSha, checks.filter((c) => c.result === "fail" && !preRed.names.includes(c.name) && !isHold(c) && (suites.has(c) || tests.some((t) => testCheckName(t) === c.name))).map((c) => ({ name: c.name, ...c.ids ? { ids: c.ids } : {}, ...suites.has(c) ? { cmd: c.cmd } : {}, ...fullErr.get(c.name) ?? headErrors.get(c) ? { errors: fullErr.get(c.name) ?? headErrors.get(c) } : {}, ...suiteOf(c.name) ? { suite: suiteOf(c.name) } : {}, eligible: suites.has(c) || !targetNames.has(c.name) && !changed.includes(c.name.slice(c.name.indexOf(":") + 1)) })), preRed.knownRed.filter((n3) => !preRed.shapeDiffers.includes(n3)), changed, symbols, preRed.shapeDiffers);
58260
+ if (risk && risk.tier === "high" && !signal.aborted && complete) {
58261
+ const { runSecretScan: runSecretScan2 } = await Promise.resolve().then(() => (init_deep(), exports_deep));
58262
+ const sec = [];
58263
+ await runSecretScan2(ctx, changed, { scanAddedSince: ctx.baseSha }, sec, fullNotProven);
58264
+ for (const c of sec) {
58265
+ const k = { name: c.name, cmd: c.cmd, result: c.result, duration_s: c.duration_s, ...c.reason ? { reason: c.reason } : {}, ...c.secret_matches ? { secret_matches: c.secret_matches } : {} };
58266
+ checks.push(k);
58267
+ ctx.emit("test.result", "verify", { ...k });
58268
+ }
58269
+ if (sec.some((c) => c.result === "pass" || c.result === "fail")) {
58270
+ ranDeeper.push(SECURITY_SCAN);
58271
+ risk = markExecuted(risk, ranDeeper);
58272
+ recordRisk(ctx.repoDir, risk);
58273
+ }
58274
+ }
58275
+ const covered = (f) => [...ctx.tests.impacted(map, [f]), ...tests === tests0 ? [] : [...mochaTargets(ctx.repoDir, [f]), ...avaTargets(ctx.repoDir, [f])]].some((t) => checks.some((c) => c.name === testCheckName(t) && hasExecutedProof([c])));
58276
+ const uncoveredChanged = changed.filter((f) => CODE_FILE_EXT.test(f) && !isTestFile(f) && !wallPaths.has(f) && !cfgChanged.includes(f) && !covered(f));
58277
+ const flaky = checks.filter((c) => c.result === "flaky").map((c) => isHold(c) ? "holdout" : c.name);
58278
+ const indepNames = new Set([...wallNames0, ...[...changedTestFiles, ...impacted, ...own].map(testCheckName), ...attr.introducedChecks]);
58279
+ const uncaused = uncausedOn() ? checks.filter((c) => feedsFixRound(c, preRed) && !indepNames.has(c.name) && uncausedRed(c, changed, symbols, excerpts.get(c) ?? "")).map((c) => c.name) : [];
58280
+ const independentFail = checks.some((c) => c.result === "fail" && indepNames.has(c.name) && !preRed.names.includes(c.name));
58281
+ const { groups: failuresGrouped, names: blockingNames } = briefGroups(checks.filter((c) => !uncaused.includes(c.name)).filter((c) => feedsFixRound(c, preRed) || fixRounds === 0 && collateralSame.includes(c.name) && !collateralBase.includes(c.name)), (c) => excerpts.get(c) ?? "", (c) => suites.has(c), EXCERPT_TOTAL_CAP, qs && !complete ? { prev: ctx.outputs().verify, ran: new Set(checks.map((c) => c.name)) } : undefined);
58282
+ const pub = checks.map((c) => isHold(c) ? pubHold(c) : c), holdoutFailed = checks.filter((c) => c.result === "fail" && isHold(c) && !preRed.names.includes(c.name)).length;
58283
+ const inBase = (f) => {
58284
+ try {
58285
+ safeGit(ctx.repoDir, ["cat-file", "-e", `${ctx.baseSha}:${f}`], { stdio: "ignore" });
58286
+ return true;
58287
+ } catch {
58288
+ return false;
58289
+ }
58290
+ };
58291
+ const testCounts = {};
58292
+ const modifiedRel = relevant2.filter((t) => changed.includes(t.path) && inBase(t.path)).flatMap((t) => {
58293
+ const k = preRed.cnt[testCheckName(t)];
58294
+ if (k)
58295
+ testCounts[t.path] = k;
58296
+ return [...testFileWeakened(ctx.repoDir, ctx.baseSha, null, t.path, "M", intake?.task ?? "") ? [`weakened test: ${t.path}`] : [], ...assertDeltaNotes(ctx.repoDir, ctx.baseSha, null, t.path, intake?.task ?? "", k?.b, k?.h) ?? []];
58297
+ });
58298
+ const weakened = [...modifiedRel, ...cfgChanged.map((f) => `test configuration changed: ${f}`), ...preRed.weak.map((n3) => `skipped or fewer tests than base: ${n3}`), ...collateralRed.map((n3) => `${COLLATERAL_RED}: ${n3}`), ...preRed.quiet.filter((n3) => preRed.names.includes(n3)).map((n3) => `${QUIET_RED}: ${n3}`)];
58299
+ const fullChecks = checks.filter((c) => c.name.startsWith("full suite")), fullSuiteRan = fullChecks.length > 0 && fullChecks.every((c) => c.result === "pass" || c.result === "fail") && ![...fullNotProven].some((n3) => n3.includes(" not run: no changed file is in this package"));
58300
+ const depsNotes = unusedInstallNotes(intake?.deps_not_proven ?? [], api, changed, checks.map((c) => c.name), ctx.repoDir);
58301
+ const notProven2 = [...complete ? [] : [QUICK_ONLY_NOTE], ...preRed.envCrash.map((e) => `${e.name}: ${BCE_REASON} (${e.sig})`), ...noIdNotes, ...venvSkipNotes(ctx.repoDir), ...weakened, ...hiddenEdits(ctx.repoDir), ...ignoreRuleChanges(ctx.repoDir, intake?.ignore_snapshot, ctx.baseSha), ...dependentNotes(dep).filter((n3) => !(fullSuiteRan && n3.startsWith("reverse-dependent tests dropped"))), ...depsNotes.cap, ...pub.filter((c) => c.name === "holdout" && c.result !== "pass").map((c) => c.result === "not_run" ? "holdout not executed" : "holdout check failed"), ...[...fullNotProven].filter((n3) => !naNote(n3)), ...pub.filter((c) => c.owner === "harness" && c.name !== "holdout").map((c) => `${c.reason} (${c.name}; harness-owned, no fix rounds)`), ...new Set(checks.filter((c) => c.interpreter === "system" && c.result !== "not_run").map((c) => c.name.startsWith("lint:") ? "lint ran on the system ruff" : "tests ran on the system interpreter"))];
58302
+ const wallDropped = [...wallPaths].filter((p) => !wallTests.some((t) => t.path === p));
58303
+ notProven2.push(...wallDropped.map((p) => `Wall test not executed: ${p}: ${NO_RUNNER_REASON}`));
58304
+ const wallNames = new Set(wallTests.map(testCheckName)), wallRun = checks.filter((c) => wallNames.has(c.name) || isHold(c)), wallFailTail = writeWallFailureTail(ctx.runDir, checks.filter((c) => wallNames.has(c.name) && c.result === "fail" && !isHold(c) && !preRed.names.includes(c.name)).map((c) => ({ name: c.name, out: failTails.get(c) ?? "" }))), wallPassed = wallRun.some((c) => c.result === "fail") ? false : wallRun.length > 0 && wallDropped.length === 0 && wallRun.every((c) => c.result === "pass") ? true : undefined;
58305
+ await settleNrd(ctx);
58306
+ if (touchedExcused.length)
58307
+ attr.line = [attr.line, ...touchedExcused.map((n3) => `${TOUCHED_RED}: ${n3}`)].filter(Boolean).join("; ") || null;
58308
+ return { status: "completed", data: { checks: pub, flaky, verify_scope: complete ? "complete" : "quick", ...ntf ? { no_test_fallback: true } : {}, ...uncaused.length ? { uncaused_reds: uncaused } : {}, ...lintUntouchedNames.length ? { lint_untouched: lintUntouchedNames } : {}, independent_fail: independentFail, file_hashes: hashes, blocking_checks: blockingNames, ...wallFailTail ? { wall_failure_tail: wallFailTail } : {}, ...wallPassed === undefined ? {} : { wall_passed: wallPassed }, failures_grouped: [...failuresGrouped, ...nrdGroupsFor(ctx.outputs().implement, fixRounds)], holdout_failed: holdoutFailed, changed_files: changed, ...depNames.size ? { dependent_checks: [...depNames] } : {}, not_proven: notProven2, ...fullNotProven.size || depsNotes.na.length ? { not_applicable: [...[...fullNotProven].filter(naNote).map(naText), ...depsNotes.na] } : {}, pre_red: preRed.ids, pre_red_checks: preRed.names, ...notExcused.length ? { not_excused: notExcused } : {}, ...preRed.knownRed.length ? { known_red_checks: preRed.knownRed } : {}, ...preRed.sameError.length ? { known_red_same_error: preRed.sameError } : {}, ...baseRed.length ? { base_red_checks: baseRed } : {}, skipped_on_base: preRed.zero, ...collateralSame.length && fixRounds === 0 ? { collateral_same_error: collateralSame } : {}, ...attr.line ? { baseline_line: attr.line, introduced_checks: attr.introducedChecks } : {}, test_counts: testCounts, uncovered_changed: uncoveredChanged, target_checks: checks.filter((c) => c.result === "pass" && targetNames.has(c.name)).map((c) => isHold(c) ? "holdout" : c.name), risk } };
58309
+ }
58310
+ }
58311
+ var timeoutCarryOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_TIMEOUT_CARRY"] ?? "").trim()), TIMEOUT_CARRY_NOTE = "carried from an earlier verify of this run, not rerun (untouched file)", KILL_AFTER_MS = 5000, NO_ID_BASE_REASON = "the test command does not run in this checkout: it fails the same way with the change removed", rootless = (out3, roots) => {
58312
+ const all = roots.flatMap((x) => {
58313
+ try {
58314
+ return [x, realpathSync45(x)];
58315
+ } catch {
58316
+ return [x];
58317
+ }
58318
+ }).flatMap((x) => [x, x.startsWith("/private/") ? x.slice("/private".length) : `/private${x}`]);
58319
+ let o = out3;
58320
+ for (const r of [...new Set(all)].filter((x) => x.length > 1).sort((a, b) => b.length - a.length))
58321
+ o = o.split(r).join("<repo>");
58322
+ return o;
58323
+ }, SUITE_MARGIN_MS = 5000, CHECK_TIMEOUT_MS = 60000, excerpts, checkExcerpt = (c) => excerpts.get(c) ?? "", suites, failTails, tscOut, crashSigs, baseCrashEnvOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_BASE_CRASH_ENV"] ?? "").trim()), BCE_REASON = "fails the same way on base, so its result cannot be read: the environment, not the change", noIdOut, headErrors, WALL_FAILURE_TAIL_CAP = 16384, wallTailOf = (out3, repoDir) => redactSecrets(stripAnsi(out3).replace(/\r/g, "").split(repoDir.replace(/\/+$/, "") + "/").join("")).slice(-WALL_FAILURE_TAIL_CAP), isHold = (c) => isHoldoutCheck(c.name), pubHold = (c) => ({ name: "holdout", cmd: "holdout", result: c.result, duration_s: c.duration_s, ...c.n !== undefined ? { n: c.n } : {}, ...c.sk !== undefined ? { sk: c.sk } : {}, ...c.owner ? { owner: c.owner, reason: "holdout infrastructure failure" } : {} }), testCheckName = (t) => `${t.runner}:${t.path}`, QUIET_RED = "excused as red on base although its error text differs from base by noise only (the same error shapes; no changed file or symbol appears in the failure)", COLLATERAL_RED = "relevant test already failing on base, still failing the same tests (it imports a file the task names; capped, not blocking)", noTestFallbackOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_NO_TEST_FALLBACK"] ?? "").trim()), ownByPathOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_OWN_BY_PATH"] ?? "").trim()), TEST_TITLE_RE, dedupeTests = (tests) => [...new Map(tests.map((t) => [`${t.runner}:${t.path}`, t])).values()], verifyBatchOn = (env = process.env) => env["LOKI_E10_VERIFY_BATCH"] !== "0", BATCH_MIN = 2, UNHANDLED_RE, batchTimeoutMs = (files) => Math.max(CHECK_TIMEOUT_MS, Math.min(300000, files * 5000)), vitestFile = (t, c) => t.runner === "vitest" && c.cmd === "npx" && c.args.length === 4 && c.args[0] === "--no-install" && c.args[1] === "vitest" && c.args[2] === "run", goBatchOn = (env = process.env) => verifyBatchOn(env) && env["LOKI_E10_GO_BATCH"] !== "0", goFileCmd = (t, c) => t.runner === "go" && c.cmd === "go" && c.args.length === 5 && c.args[0] === "test" && c.args[1] === "-json" && c.args[2] === "-run" && /^\^\([A-Za-z0-9_|]+\)\$$/.test(c.args[3]), goBatchable = (t, targets, changed, env = process.env) => goBatchOn(env) && t.runner === "go" && !targets.has(testCheckName(t)) && !changed.includes(t.path), uncausedOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_UNCAUSED_NO_FIX"] ?? "").trim()), LINT_CONFIG, INERT_FILE, feedsFixRound = (c, pre) => c.result === "fail" && !pre.names.includes(c.name) && !pre.sameError.includes(c.name) && !isHoldoutCheck(c.name), baseMemoOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_BASE_MEMO"] ?? "").trim()), ESLINT_CONFIGS, excuseLint = (ctx, signal, c, tool, cmd2, prefix, cwd, rel, opts) => c.result !== "fail" || signal.aborted ? Promise.resolve(false) : staticPreExisting(tool, prefix, rel, { run: async (a, stdin) => {
57612
58324
  if (signal.aborted)
57613
58325
  return null;
57614
58326
  const r = await runOnce3(cmd2, a, cwd, AbortSignal.any([signal, AbortSignal.timeout(opts.timeoutMs ?? CHECK_TIMEOUT_MS)]), { ...opts, ...stdin !== undefined ? { stdin } : {} });
@@ -57619,8 +58331,11 @@ var timeoutCarryOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LO
57619
58331
  } catch {
57620
58332
  return null;
57621
58333
  }
57622
- } }), TSC_LOCAL, TSC_DIAG, LINT_UNTOUCHED_NOTE = "lint red only in files the change did not touch (disclosed, not blocking)", lintUntouchedOn = (env = process.env) => /^(1|on|true|yes)$/i.test((env["LOKI_E10_LINT_UNTOUCHED"] ?? "").trim()), tscLines = (out3) => out3.split(`
57623
- `).map((l) => l.trim()).filter((l) => /error TS\d+/.test(l)), lintMissingDiscloseOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_LINT_MISSING_DISCLOSE"] ?? "").trim()), verifyStage, stage10;
58334
+ } }), TSC_LOCAL, TSC_DIAG, LINT_UNTOUCHED_NOTE = "lint red only in files the change did not touch (disclosed, not blocking)", lintUntouchedOn = (env = process.env) => {
58335
+ const v = (env["LOKI_E10_LINT_UNTOUCHED"] ?? "").trim();
58336
+ return /^(1|on|true|yes)$/i.test(v) || v === "" && baseOnDemandOn(env);
58337
+ }, tscLines = (out3) => out3.split(`
58338
+ `).map((l) => l.trim()).filter((l) => /error TS\d+/.test(l)), lintMissingDiscloseOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_LINT_MISSING_DISCLOSE"] ?? "").trim()), BASE_NOT_MEASURED = "not measured on base (its dependency directories link into this checkout, a dependency manifest changed, or the environment changed since intake), so its failures cannot be compared", verifyStage, stage10;
57624
58339
  var init_verify = __esm(() => {
57625
58340
  init_stack_tools();
57626
58341
  init_atomic();
@@ -57649,6 +58364,7 @@ var init_verify = __esm(() => {
57649
58364
  init_safe_git();
57650
58365
  init_test_guard();
57651
58366
  init_base_guard();
58367
+ init_package_suite();
57652
58368
  init_repo_profile();
57653
58369
  init_check_result();
57654
58370
  init_check_result();
@@ -57663,6 +58379,7 @@ var init_verify = __esm(() => {
57663
58379
  failTails = new WeakMap;
57664
58380
  tscOut = new WeakMap;
57665
58381
  crashSigs = new WeakMap;
58382
+ noIdOut = new WeakMap;
57666
58383
  headErrors = new WeakMap;
57667
58384
  TEST_TITLE_RE = /\b(?:it|test)(?:\.\w+)*\(\s*(['"`])((?:(?!\1).)+)\1/;
57668
58385
  UNHANDLED_RE = /Unhandled (?:Errors?|Rejection)\b/;
@@ -57676,294 +58393,12 @@ var init_verify = __esm(() => {
57676
58393
  targetS: STAGE_BUDGETS.verify.targetS,
57677
58394
  limitS: STAGE_BUDGETS.verify.limitS,
57678
58395
  async run(ctx, signal) {
57679
- let changed;
57680
- const ownWall = (ctx.outputs().wall?.files ?? []).map((f) => f.path), live2 = (l) => withoutStaleWall(l, ownWall, ctx.repoDir);
57681
- try {
57682
- changed = live2(changedFiles(ctx.repoDir, ctx.baseSha, installOwned(ctx.repoDir, ctx.outputs().intake?.install_created)));
57683
- } catch (err) {
57684
- return { status: "failed", data: {}, reason: `git diff against base failed: ${err.message}` };
57685
- }
57686
- if (changed.length === 0) {
57687
- const implementExit = ctx.outputs().implement?.exit;
57688
- if (implementExit === "already_done") {
57689
- return { status: "completed", data: { already_satisfied: true, checks: [], flaky: [], failures_grouped: [], changed_files: [] } };
57690
- }
57691
- return { status: "failed", data: { changed_files: [] }, reason: "empty diff without an already_done marker" };
57692
- }
57693
- let risk = (() => {
57694
- try {
57695
- const r = classifyRisk(live2(diffFiles(ctx.repoDir, ctx.baseSha, installOwned(ctx.repoDir, ctx.outputs().intake?.install_created))));
57696
- recordRisk(ctx.repoDir, r);
57697
- return r;
57698
- } catch {
57699
- return null;
57700
- }
57701
- })();
57702
- const checks = [];
57703
- const api = loadProjectApi(ctx.repoDir);
57704
- const map0 = await ctx.tests.detect(ctx.repoDir), map = { ...map0, tests: live2(map0.tests) };
57705
- const impacted = ctx.tests.impacted(map, changed);
57706
- const changedTestFiles = map.tests.filter((t) => changed.includes(t.path));
57707
- const wall = ctx.outputs().wall ?? {};
57708
- const wallPaths = new Set((wall.files ?? []).map((f) => isAbsolute21(f.path) ? relative33(ctx.repoDir, f.path) : f.path));
57709
- const intake = ctx.outputs().intake, repoMap = loadRepoMap(intake?.repomap_ref), named2 = namedFiles(intake?.task ?? "", repoMap), relevant2 = ctx.tests.impacted(map, named2);
57710
- const recorded = new Map((wall.files ?? []).flatMap((f) => f.runner ? [[isAbsolute21(f.path) ? relative33(ctx.repoDir, f.path) : f.path, f.runner]] : []));
57711
- const wallTests = [...wallPaths].flatMap((p) => {
57712
- const rec2 = recorded.get(p), found = map.tests.find((t) => t.path === p && (!rec2 || t.runner === rec2));
57713
- if (found)
57714
- return [found];
57715
- const runner = rec2 ?? guessRunner(basename44(p), map.runners, p);
57716
- return runner && (runner !== "bun" || map.runners.includes("bun") || /[._](?:test|spec)\.[cm]?[jt]sx?$/.test(p)) ? [{ runner, path: p }] : [];
57717
- });
57718
- const dep = dependentTests(ctx.repoDir, map, changed, [...impacted, ...changedTestFiles, ...wallTests, ...relevant2]), depNames = new Set(dep.tests.map(testCheckName));
57719
- const tests0 = failedFirst(dedupeTests([...wallTests, ...relevant2, ...changedTestFiles, ...changedSymbolsFirst(ctx, impacted, changed), ...dep.tests]), ctx.outputs().verify?.checks);
57720
- const tests = tests0.length === 0 ? [...mochaTargets(ctx.repoDir, changed), ...avaTargets(ctx.repoDir, changed)] : tests0;
57721
- const own = ownByPathOn() ? ownTests(relevant2, named2, changed) : relevant2;
57722
- const hashes = fileHashes(ctx.repoDir, changed), qs = quickScope(ctx.outputs(), hashes), keep = new Set([...qs?.blocking ?? [], ...[...wallTests, ...own].map(testCheckName)]);
57723
- const sinceTests = qs ? [...ctx.tests.impacted(map, qs.since), ...map.tests.filter((t) => qs.since.includes(t.path))] : [], split2 = qs ? quickSplit(tests, keep, sinceTests) : { first: tests, rest: [] };
57724
- const done = [], wallNames0 = new Set(wallTests.map(testCheckName)), targets0 = new Set([...wallTests, ...own].map(testCheckName)), wallDropped0 = [...wallPaths].filter((p) => !wallTests.some((t) => t.path === p));
57725
- let holdN = wall.holdout_dir ? null : 0;
57726
- const publish = () => {
57727
- if (!ctx.partial)
57728
- return;
57729
- const ran2 = checks.length ? checks : done, w = ran2.filter((c) => wallNames0.has(c.name) || isHold(c)), allRan = holdN !== null && ran2.filter(isHold).length >= holdN && wallTests.every((t) => ran2.some((c) => c.name === testCheckName(t)));
57730
- const wp = w.some((c) => c.result === "fail") ? false : w.length > 0 && allRan && wallDropped0.length === 0 && w.every((c) => c.result === "pass") ? true : undefined;
57731
- ctx.partial("verify", { checks: ran2.map((c) => isHold(c) ? pubHold(c) : c), flaky: ran2.filter((c) => c.result === "flaky").map((c) => isHold(c) ? "holdout" : c.name), ...wp === undefined ? {} : { wall_passed: wp }, changed_files: changed, not_proven: wallDropped0.map((p) => `Wall test not executed: ${p}: ${NO_RUNNER_REASON}`), target_checks: ran2.filter((c) => c.result === "pass" && (targets0.has(c.name) || isHold(c))).map((c) => isHold(c) ? "holdout" : c.name), risk });
57732
- };
57733
- const scopedOut = scopedOutOf(map);
57734
- if (scopedOut.length)
57735
- ctx.emit("test.scoped_out", "verify", { tests: scopedOut });
57736
- const batchable = (t) => verifyBatchOn() && t.runner === "vitest" && !wallNames0.has(testCheckName(t));
57737
- const runTests = async (all) => {
57738
- const byName = new Map;
57739
- for (const c of carriedTimeouts(ctx.outputs().verify?.checks ?? [], all, changed, new Set([...wallNames0, ...targets0]))) {
57740
- byName.set(c.name, [c]);
57741
- done.push(c);
57742
- ctx.emit("test.result", "verify", { ...c });
57743
- }
57744
- const list = all.filter((t) => !byName.has(testCheckName(t)));
57745
- const alone = async (l) => {
57746
- (await mapPool(l, verifyJobs(), async (t) => {
57747
- const tc = commandFor(t, ctx.repoDir, api), slot = [];
57748
- await runCheck(ctx, testCheckName(t), tc.cmd, tc.args, signal, slot, { ...tc.interpreter ? { interpreter: tc.interpreter } : {}, protect: [...wallTests, ...relevant2].includes(t), ...tc.pkgRoot !== "." ? { cwd: tc.cwd } : {} });
57749
- done.push(...slot);
57750
- publish();
57751
- return slot;
57752
- }, () => signal.aborted)).forEach((sl, i) => {
57753
- if (sl)
57754
- byName.set(testCheckName(l[i]), sl);
57755
- });
57756
- };
57757
- const goPart = (t) => goBatchable(t, targets0, changed);
57758
- await alone(list.filter((t) => !batchable(t) && !goPart(t)));
57759
- const goB = await runGoBatches(ctx, list.filter(goPart), api, signal, (c) => {
57760
- done.push(c);
57761
- publish();
57762
- });
57763
- for (const [n3, c] of goB)
57764
- byName.set(n3, [c]);
57765
- await alone(list.filter((t) => goPart(t) && !goB.has(testCheckName(t))));
57766
- for (const part of [list.filter((t) => batchable(t) && targets0.has(testCheckName(t))), list.filter((t) => batchable(t) && !targets0.has(testCheckName(t)))]) {
57767
- for (const [n3, c] of await runVitestBatches(ctx, part, api, signal, (c2) => {
57768
- done.push(c2);
57769
- publish();
57770
- }))
57771
- byName.set(n3, [c]);
57772
- }
57773
- await alone(list.filter((t) => batchable(t) && !byName.has(testCheckName(t))));
57774
- checks.push(...all.flatMap((t) => byName.get(testCheckName(t)) ?? []));
57775
- };
57776
- await runTests(split2.first);
57777
- const zgEnv = zeroGate(ctx.outputs().intake?.zero_baseline), envAsIntake = (rel) => {
57778
- if (zgEnv.sinceMs === undefined)
57779
- return false;
57780
- const root = api?.packageRootOf(rel) ?? ".";
57781
- return [...new Set([root, "."])].every((d) => !envChangedSince(ctx.repoDir, d === "." ? ctx.repoDir : join155(ctx.repoDir, d), zgEnv.sinceMs, zgEnv.ignored ?? null, zgEnv.deps));
57782
- };
57783
- const depsSeen = new Map, depsAsIntake = (rel) => {
57784
- if (zgEnv.sinceMs === undefined)
57785
- return false;
57786
- return [...new Set([api?.packageRootOf(rel) ?? ".", "."])].every((d) => {
57787
- if (!depsSeen.has(d))
57788
- depsSeen.set(d, !envChangedSince(ctx.repoDir, d === "." ? ctx.repoDir : join155(ctx.repoDir, d), zgEnv.sinceMs, [], zgEnv.deps));
57789
- return depsSeen.get(d);
57790
- });
57791
- };
57792
- const touchedRed = new Set(checks.filter((c) => {
57793
- const rel = c.name.slice(c.name.indexOf(":") + 1);
57794
- return c.result === "fail" && changed.includes(rel) && !wallNames0.has(c.name) && !isHold(c) && envAsIntake(rel) && touchedRedOnBase(ctx.repoDir, ctx.baseSha, { ids: c.ids, errors: headErrors.get(c) }, editedTestTitles(ctx.repoDir, ctx.baseSha, rel));
57795
- }).map((c) => c.name));
57796
- const decisive = qs !== null && checks.some((c) => c.result === "fail" && !touchedRed.has(c.name) && (keep.has(c.name) || changed.includes(c.name.slice(c.name.indexOf(":") + 1))));
57797
- if (!decisive)
57798
- await runTests(split2.rest);
57799
- const complete = !decisive;
57800
- const pg = (ctx.outputs().verify?.failures_grouped ?? []).map((g2) => g2.signature), fs2 = (x) => x.startsWith("full suite") || x.startsWith("lint:"), failSigs = (l) => [...new Set(l.filter((c) => c.result === "fail" && !fs2(c.name) && !isHoldoutCheck(c.name)).map((c) => failureSignature(c)))].sort(), same = (a, b) => a.length === b.length && a.every((x, i) => x === b[i]);
57801
- const settle2 = decisive && pg.some((x) => x.startsWith("full suite")) && same(failSigs(ctx.outputs().verify?.checks ?? []), failSigs(checks.filter((c) => !isHold(c))));
57802
- const hold = wall.holdout_dir ? stageHoldout(wall.holdout_dir, ctx.repoDir) : null;
57803
- if (hold && !hold.missing.length)
57804
- holdN = hold.tests.length;
58396
+ const bt = baseTree(ctx);
57805
58397
  try {
57806
- for (const [i, h] of (hold?.tests ?? []).entries()) {
57807
- if (signal.aborted)
57808
- break;
57809
- const t = h, tc = commandFor(t, ctx.repoDir, api);
57810
- await runCheck(ctx, `holdout:${i + 1}`, tc.cmd, tc.args, signal, checks, { ...tc.interpreter ? { interpreter: tc.interpreter } : {}, protect: true, opaque: true, ...tc.pkgRoot !== "." ? { cwd: tc.cwd } : {} });
57811
- publish();
57812
- }
58398
+ return await runVerify(ctx, signal, bt);
57813
58399
  } finally {
57814
- hold?.cleanup();
58400
+ bt.dispose();
57815
58401
  }
57816
- if (hold?.missing.length) {
57817
- for (const m of hold.missing)
57818
- recordHoldoutTriage(ctx.runDir, { check: "holdout:store", result: "not_run", reason: m });
57819
- const k = { name: "holdout:store", cmd: "holdout", result: "not_run", duration_s: 0, reason: "holdout store unavailable", owner: "harness" };
57820
- checks.push(k);
57821
- ctx.emit("test.result", "verify", { ...pubHold(k) });
57822
- }
57823
- const targetNames = new Set([...[...wallTests, ...own].map(testCheckName), ...checks.filter(isHold).map((c) => c.name)]);
57824
- const cfgChanged = [...new Set([...testConfigChanged(ctx.repoDir, ctx.baseSha, changed), ...hiddenConfigChanged(ctx.repoDir, ctx.outputs().intake?.hidden_cfg)])];
57825
- const collateral = new Set((ownByPathOn() ? relevant2.filter((t) => !own.includes(t)) : collateralTests(relevant2, named2)).map(testCheckName)), ownRel = new Set([...relevant2.map(testCheckName)].filter((n3) => !collateral.has(n3)));
57826
- const symbols = checks.some((c) => c.result === "fail") ? diffSymbols(ctx, changed) : [];
57827
- const preRed = await subtractBase(ctx, api, checks, tests, changed, new Set(wallTests.map(testCheckName)), new Set(relevant2.map(testCheckName)), signal, cfgChanged.length === 0, zeroGate(ctx.outputs().intake?.zero_baseline), depNames, ownRel, symbols);
57828
- for (const e of preRed.envCrash) {
57829
- const c = checks.find((x) => x.name === e.name && x.result === "fail");
57830
- if (c) {
57831
- c.result = "not_run";
57832
- c.reason = `${BCE_REASON} (${e.sig})`;
57833
- }
57834
- }
57835
- const fixRounds = Number(ctx.outputs().fix?.round ?? 0) || 0, collateralSame = preRed.sameError.filter((n3) => collateral.has(n3) && !preRed.names.includes(n3));
57836
- const collateralBase = checks.filter((c) => c.result === "fail" && collateral.has(c.name) && !preRed.names.includes(c.name) && envAsIntake(c.name.slice(c.name.indexOf(":") + 1)) && collateralOnBaseline(ctx.repoDir, ctx.baseSha, c.name.slice(c.name.indexOf(":") + 1), { ids: c.ids, errors: headErrors.get(c) }, changed, coveredStem(c.name.slice(c.name.indexOf(":") + 1)))).map((c) => c.name);
57837
- if (collateralBase.length) {
57838
- preRed.names.push(...collateralBase);
57839
- preRed.ids.push(...checks.filter((c) => collateralBase.includes(c.name)).flatMap((c) => c.ids ?? []));
57840
- }
57841
- const collateralRed = fixRounds >= 1 ? collateralSame.filter((n3) => !collateralBase.includes(n3)) : [];
57842
- if (collateralRed.length) {
57843
- preRed.names.push(...collateralRed);
57844
- preRed.ids.push(...checks.filter((c) => collateralRed.includes(c.name)).flatMap((c) => c.ids ?? []));
57845
- }
57846
- const touchedExcused = [...touchedRed].filter((n3) => !preRed.names.includes(n3) && checks.some((c) => c.name === n3 && c.result === "fail"));
57847
- if (touchedExcused.length) {
57848
- preRed.names.push(...touchedExcused);
57849
- preRed.ids.push(...checks.filter((c) => touchedExcused.includes(c.name)).flatMap((c) => c.ids ?? []));
57850
- }
57851
- const suiteOf = (name) => {
57852
- const t = tests.find((x) => testCheckName(x) === name), pkg = t ? api?.packageOf(t.path) : null;
57853
- return pkg?.commands.test ? `full suite: ${pkg.name}` : undefined;
57854
- };
57855
- const attr = attribute(ctx.repoDir, ctx.baseSha, checks.filter((c) => c.result === "fail" && !preRed.names.includes(c.name)).map((c) => ({ name: c.name, ids: c.ids, eligible: !targetNames.has(c.name) && !changed.includes(c.name.slice(c.name.indexOf(":") + 1)), ...suiteOf(c.name) && (preRed.compared.includes(c.name) || depsAsIntake(c.name.slice(c.name.indexOf(":") + 1))) ? { suite: suiteOf(c.name), ...preRed.sameError.includes(c.name) ? { rerun: "same" } : preRed.compared.includes(c.name) ? { rerun: "differs" } : {} } : {} })));
57856
- attr.introducedChecks = [...new Set(attr.introducedChecks.map((n3) => isHoldoutCheck(n3) ? "holdout" : n3))];
57857
- preRed.names.push(...attr.preExistingChecks);
57858
- preRed.ids.push(...attr.preExistingIds);
57859
- const lintUntouchedNames = [];
57860
- if (!signal.aborted) {
57861
- const lintUntouched = lintUntouchedNames;
57862
- const lintPre = await runLintChecks(ctx, complete || [...qs?.blocking ?? []].some((n3) => n3.startsWith("lint:")) ? changed : changed.filter((f) => qs?.since.includes(f)), signal, checks, { api, wall: wallPaths, keep: new Set([...changed, ...named2]), untouched: lintUntouched });
57863
- preRed.names.push(...lintPre);
57864
- if (lintPre.length)
57865
- attr.line = [attr.line, `baseline: ${lintPre.join(", ")} static diagnostics already on base (not blocking)`].filter(Boolean).join("; ");
57866
- preRed.names.push(...lintUntouched);
57867
- if (lintUntouched.length)
57868
- attr.line = [attr.line, `${LINT_UNTOUCHED_NOTE}: ${lintUntouched.join(", ")}`].filter(Boolean).join("; ");
57869
- if (isLokiModeRepo(ctx.repoDir)) {
57870
- await runCheck(ctx, "select-tests", "bash", ["scripts/select-tests.sh", "--files", "-", "--run"], signal, checks, {
57871
- kind: "static",
57872
- stdin: changed.join(`
57873
- `) + `
57874
- `
57875
- });
57876
- }
57877
- }
57878
- const notExcused = [];
57879
- const fullNotProven = new Set;
57880
- const fullErr = new Map;
57881
- const ranDeeper = [];
57882
- const ntf = noTestFallbackOn() && risk?.tier === "low" && !checks.some((c) => !c.name.startsWith("lint:") && (c.result === "pass" || c.result === "fail"));
57883
- if (risk && (risk.tier !== "low" || ntf) && !signal.aborted && (complete || settle2)) {
57884
- const { runFullSuite: runFullSuite2 } = await Promise.resolve().then(() => (init_deep(), exports_deep));
57885
- const full = [];
57886
- await runFullSuite2(ctx, signal, { changed, ...ntf && risk?.tier === "low" ? { ownedOnly: true } : {}, targetPassed: checks.some((c) => targetNames.has(c.name) && c.result === "pass" && hasExecutedProof([c])), wallBaseRed: wallRedOnBaseOf(ctx.outputs().wall?.base_run), proofFiles: wallProofOf(checks, [...wallTests.map((t) => ({ name: testCheckName(t), path: t.path })), ...(hold?.tests ?? []).map((h, i) => ({ name: `holdout:${i + 1}`, path: h.path }))]) }, full, fullNotProven);
57887
- for (const c of full) {
57888
- const k = { name: c.name, cmd: c.cmd, result: c.result, duration_s: c.duration_s, ...c.reason ? { reason: c.reason } : {}, ...c.count ? { count: c.count } : {}, ...c.result === "fail" ? { ...c.ids ? { ids: c.ids } : {}, ...c.first_error ? { first_error: c.first_error } : {} } : {} };
57889
- suites.add(k);
57890
- checks.push(k);
57891
- ctx.emit("test.result", "verify", { ...k });
57892
- if (c.excerpt)
57893
- excerpts.set(k, c.excerpt);
57894
- }
57895
- for (const c of full)
57896
- if (c.errors)
57897
- fullErr.set(c.name, c.errors);
57898
- const blockedIds = checks.filter((c) => c.result === "fail" && !suites.has(c) && !preRed.names.includes(c.name)).flatMap((c) => c.ids ?? []);
57899
- const shown = new Set(checks.filter((c) => touchedExcused.includes(c.name)).flatMap((c) => c.ids ?? [])), fa = attributeFullSuite(ctx.repoDir, ctx.baseSha, full, blockedIds, changed, symbols, shown);
57900
- preRed.names.push(...fa.preExistingChecks);
57901
- preRed.ids.push(...fa.preExistingIds);
57902
- attr.introducedChecks.push(...fa.introducedChecks);
57903
- attr.line = [attr.line, fa.line].filter(Boolean).join("; ") || null;
57904
- notExcused.push(...whyFullSuiteNotExcused(ctx.repoDir, ctx.baseSha, full, changed, fa.preExistingChecks, blockedIds, shown));
57905
- if (full.some((c) => c.result === "pass" || c.result === "fail")) {
57906
- ranDeeper.push("full test command", "full suite");
57907
- risk = markExecuted(risk, ranDeeper);
57908
- recordRisk(ctx.repoDir, risk);
57909
- }
57910
- const known = new Set(checks.filter((c) => c.result === "fail" && (preRed.sameError.includes(c.name) || wallNames0.has(c.name))).flatMap((c) => c.ids ?? []));
57911
- for (const c of full)
57912
- if (c.result === "fail" && c.ids?.length && !c.unhandled?.length && comparableIds(c.ids).every((i) => known.has(i)) && !preRed.names.includes(c.name)) {
57913
- preRed.knownRed.push(c.name);
57914
- preRed.sameError.push(c.name);
57915
- }
57916
- }
57917
- const baseRed = baseRedById(ctx.repoDir, ctx.baseSha, checks.filter((c) => c.result === "fail" && !preRed.names.includes(c.name) && !isHold(c) && (suites.has(c) || tests.some((t) => testCheckName(t) === c.name))).map((c) => ({ name: c.name, ...c.ids ? { ids: c.ids } : {}, ...suites.has(c) ? { cmd: c.cmd } : {}, ...fullErr.get(c.name) ?? headErrors.get(c) ? { errors: fullErr.get(c.name) ?? headErrors.get(c) } : {}, ...suiteOf(c.name) ? { suite: suiteOf(c.name) } : {}, eligible: suites.has(c) || !targetNames.has(c.name) && !changed.includes(c.name.slice(c.name.indexOf(":") + 1)) })), preRed.knownRed.filter((n3) => !preRed.shapeDiffers.includes(n3)), changed, symbols, preRed.shapeDiffers);
57918
- if (risk && risk.tier === "high" && !signal.aborted && complete) {
57919
- const { runSecretScan: runSecretScan2 } = await Promise.resolve().then(() => (init_deep(), exports_deep));
57920
- const sec = [];
57921
- await runSecretScan2(ctx, changed, { scanAddedSince: ctx.baseSha }, sec, fullNotProven);
57922
- for (const c of sec) {
57923
- const k = { name: c.name, cmd: c.cmd, result: c.result, duration_s: c.duration_s, ...c.reason ? { reason: c.reason } : {}, ...c.secret_matches ? { secret_matches: c.secret_matches } : {} };
57924
- checks.push(k);
57925
- ctx.emit("test.result", "verify", { ...k });
57926
- }
57927
- if (sec.some((c) => c.result === "pass" || c.result === "fail")) {
57928
- ranDeeper.push(SECURITY_SCAN);
57929
- risk = markExecuted(risk, ranDeeper);
57930
- recordRisk(ctx.repoDir, risk);
57931
- }
57932
- }
57933
- const covered = (f) => [...ctx.tests.impacted(map, [f]), ...tests === tests0 ? [] : [...mochaTargets(ctx.repoDir, [f]), ...avaTargets(ctx.repoDir, [f])]].some((t) => checks.some((c) => c.name === testCheckName(t) && hasExecutedProof([c])));
57934
- const uncoveredChanged = changed.filter((f) => CODE_FILE_EXT.test(f) && !isTestFile(f) && !wallPaths.has(f) && !cfgChanged.includes(f) && !covered(f));
57935
- const flaky = checks.filter((c) => c.result === "flaky").map((c) => isHold(c) ? "holdout" : c.name);
57936
- const indepNames = new Set([...wallNames0, ...[...changedTestFiles, ...impacted, ...own].map(testCheckName), ...attr.introducedChecks]);
57937
- const uncaused = uncausedOn() ? checks.filter((c) => feedsFixRound(c, preRed) && !indepNames.has(c.name) && uncausedRed(c, changed, symbols, excerpts.get(c) ?? "")).map((c) => c.name) : [];
57938
- const independentFail = checks.some((c) => c.result === "fail" && indepNames.has(c.name) && !preRed.names.includes(c.name));
57939
- const { groups: failuresGrouped, names: blockingNames } = briefGroups(checks.filter((c) => !uncaused.includes(c.name)).filter((c) => feedsFixRound(c, preRed) || fixRounds === 0 && collateralSame.includes(c.name) && !collateralBase.includes(c.name)), (c) => excerpts.get(c) ?? "", (c) => suites.has(c), EXCERPT_TOTAL_CAP, qs && !complete ? { prev: ctx.outputs().verify, ran: new Set(checks.map((c) => c.name)) } : undefined);
57940
- const pub = checks.map((c) => isHold(c) ? pubHold(c) : c), holdoutFailed = checks.filter((c) => c.result === "fail" && isHold(c) && !preRed.names.includes(c.name)).length;
57941
- const inBase = (f) => {
57942
- try {
57943
- safeGit(ctx.repoDir, ["cat-file", "-e", `${ctx.baseSha}:${f}`], { stdio: "ignore" });
57944
- return true;
57945
- } catch {
57946
- return false;
57947
- }
57948
- };
57949
- const testCounts = {};
57950
- const modifiedRel = relevant2.filter((t) => changed.includes(t.path) && inBase(t.path)).flatMap((t) => {
57951
- const k = preRed.cnt[testCheckName(t)];
57952
- if (k)
57953
- testCounts[t.path] = k;
57954
- return [...testFileWeakened(ctx.repoDir, ctx.baseSha, null, t.path, "M", intake?.task ?? "") ? [`weakened test: ${t.path}`] : [], ...assertDeltaNotes(ctx.repoDir, ctx.baseSha, null, t.path, intake?.task ?? "", k?.b, k?.h) ?? []];
57955
- });
57956
- const weakened = [...modifiedRel, ...cfgChanged.map((f) => `test configuration changed: ${f}`), ...preRed.weak.map((n3) => `skipped or fewer tests than base: ${n3}`), ...collateralRed.map((n3) => `${COLLATERAL_RED}: ${n3}`), ...preRed.quiet.filter((n3) => preRed.names.includes(n3)).map((n3) => `${QUIET_RED}: ${n3}`)];
57957
- const fullChecks = checks.filter((c) => c.name.startsWith("full suite")), fullSuiteRan = fullChecks.length > 0 && fullChecks.every((c) => c.result === "pass" || c.result === "fail");
57958
- const depsNotes = unusedInstallNotes(intake?.deps_not_proven ?? [], api, changed, checks.map((c) => c.name), ctx.repoDir);
57959
- const notProven2 = [...complete ? [] : [QUICK_ONLY_NOTE], ...preRed.envCrash.map((e) => `${e.name}: ${BCE_REASON} (${e.sig})`), ...weakened, ...hiddenEdits(ctx.repoDir), ...ignoreRuleChanges(ctx.repoDir, intake?.ignore_snapshot, ctx.baseSha), ...dependentNotes(dep).filter((n3) => !(fullSuiteRan && n3.startsWith("reverse-dependent tests dropped"))), ...depsNotes.cap, ...pub.filter((c) => c.name === "holdout" && c.result !== "pass").map((c) => c.result === "not_run" ? "holdout not executed" : "holdout check failed"), ...[...fullNotProven].filter((n3) => !naNote(n3)), ...pub.filter((c) => c.owner === "harness" && c.name !== "holdout").map((c) => `${c.reason} (${c.name}; harness-owned, no fix rounds)`), ...new Set(checks.filter((c) => c.interpreter === "system" && c.result !== "not_run").map((c) => c.name.startsWith("lint:") ? "lint ran on the system ruff" : "tests ran on the system interpreter"))];
57960
- const wallDropped = [...wallPaths].filter((p) => !wallTests.some((t) => t.path === p));
57961
- notProven2.push(...wallDropped.map((p) => `Wall test not executed: ${p}: ${NO_RUNNER_REASON}`));
57962
- const wallNames = new Set(wallTests.map(testCheckName)), wallRun = checks.filter((c) => wallNames.has(c.name) || isHold(c)), wallFailTail = writeWallFailureTail(ctx.runDir, checks.filter((c) => wallNames.has(c.name) && c.result === "fail" && !isHold(c) && !preRed.names.includes(c.name)).map((c) => ({ name: c.name, out: failTails.get(c) ?? "" }))), wallPassed = wallRun.some((c) => c.result === "fail") ? false : wallRun.length > 0 && wallDropped.length === 0 && wallRun.every((c) => c.result === "pass") ? true : undefined;
57963
- await settleNrd(ctx);
57964
- if (touchedExcused.length)
57965
- attr.line = [attr.line, ...touchedExcused.map((n3) => `${TOUCHED_RED}: ${n3}`)].filter(Boolean).join("; ") || null;
57966
- return { status: "completed", data: { checks: pub, flaky, verify_scope: complete ? "complete" : "quick", ...ntf ? { no_test_fallback: true } : {}, ...uncaused.length ? { uncaused_reds: uncaused } : {}, ...lintUntouchedNames.length ? { lint_untouched: lintUntouchedNames } : {}, independent_fail: independentFail, file_hashes: hashes, blocking_checks: blockingNames, ...wallFailTail ? { wall_failure_tail: wallFailTail } : {}, ...wallPassed === undefined ? {} : { wall_passed: wallPassed }, failures_grouped: [...failuresGrouped, ...nrdGroupsFor(ctx.outputs().implement, fixRounds)], holdout_failed: holdoutFailed, changed_files: changed, ...depNames.size ? { dependent_checks: [...depNames] } : {}, not_proven: notProven2, ...fullNotProven.size || depsNotes.na.length ? { not_applicable: [...[...fullNotProven].filter(naNote).map(naText), ...depsNotes.na] } : {}, pre_red: preRed.ids, pre_red_checks: preRed.names, ...notExcused.length ? { not_excused: notExcused } : {}, ...preRed.knownRed.length ? { known_red_checks: preRed.knownRed } : {}, ...preRed.sameError.length ? { known_red_same_error: preRed.sameError } : {}, ...baseRed.length ? { base_red_checks: baseRed } : {}, skipped_on_base: preRed.zero, ...collateralSame.length && fixRounds === 0 ? { collateral_same_error: collateralSame } : {}, ...attr.line ? { baseline_line: attr.line, introduced_checks: attr.introducedChecks } : {}, test_counts: testCounts, uncovered_changed: uncoveredChanged, target_checks: checks.filter((c) => c.result === "pass" && targetNames.has(c.name)).map((c) => isHold(c) ? "holdout" : c.name), risk } };
57967
58402
  }
57968
58403
  };
57969
58404
  stage10 = verifyStage;
@@ -100857,7 +101292,7 @@ var init_python_build_check = __esm(() => {
100857
101292
  // ../../loki-ts/src/util/check_result.ts
100858
101293
  import { spawn as spawn13, spawnSync as spawnSync28 } from "child_process";
100859
101294
  import { createHash as createHash40 } from "crypto";
100860
- import { copyFileSync as copyFileSync12, existsSync as existsSync117, lstatSync as lstatSync35, mkdirSync as mkdirSync89, readlinkSync as readlinkSync10, mkdtempSync as mkdtempSync27, readdirSync as readdirSync56, readFileSync as readFileSync149, realpathSync as realpathSync48, renameSync as renameSync29, rmSync as rmSync53, statSync as statSync50, writeFileSync as writeFileSync87 } from "fs";
101295
+ import { copyFileSync as copyFileSync12, existsSync as existsSync117, lstatSync as lstatSync36, mkdirSync as mkdirSync89, readlinkSync as readlinkSync10, mkdtempSync as mkdtempSync27, readdirSync as readdirSync56, readFileSync as readFileSync149, realpathSync as realpathSync48, renameSync as renameSync29, rmSync as rmSync53, statSync as statSync50, writeFileSync as writeFileSync87 } from "fs";
100861
101296
  import { homedir as homedir16, tmpdir as tmpdir34 } from "os";
100862
101297
  import { basename as basename47, dirname as dirname71, isAbsolute as isAbsolute25, join as join164, normalize as normalize9, relative as relative36, resolve as resolve44, sep as sep27 } from "path";
100863
101298
  function plainTestEnv(base2 = process.env) {
@@ -101269,7 +101704,7 @@ function cargoRunnerConfigured(cwd, env, toks2) {
101269
101704
  if (CARGO_REDIRECT_TEXT(v10))
101270
101705
  return true;
101271
101706
  const f = resolve44(cwd, v10);
101272
- if (existsSync117(f) && lstatSync35(f).isFile() && doubtful(f))
101707
+ if (existsSync117(f) && lstatSync36(f).isFile() && doubtful(f))
101273
101708
  return true;
101274
101709
  }
101275
101710
  const dirs = [env["CARGO_HOME"] ?? join164(env["HOME"] ?? homedir16(), ".cargo"), join164(homedir16(), ".cargo")];
@@ -101466,7 +101901,7 @@ function cargoRepoCompilerRedirected(cwd, env, toks2) {
101466
101901
  if (inline)
101467
101902
  return cargoCompilerReason(inline, "--config");
101468
101903
  const f = resolve44(cwd, v10);
101469
- if (existsSync117(f) && lstatSync35(f).isFile()) {
101904
+ if (existsSync117(f) && lstatSync36(f).isFile()) {
101470
101905
  const w = inFile(f);
101471
101906
  if (w)
101472
101907
  return cargoCompilerReason(w, v10);
@@ -101914,10 +102349,12 @@ function changedSymbols(diffU0, readNew) {
101914
102349
  flush();
101915
102350
  return [...out3];
101916
102351
  }
101917
- function failureShape(out3) {
101918
- const norm5 = out3.split(`
102352
+ function failureLines(out3) {
102353
+ return out3.split(`
101919
102354
  `).map((l) => l.replace(/\s+$/, "").replace(/\b\d{4}-\d{2}-\d{2}[T ][\d:._,]+Z?/g, "<ts>").replace(/\b\d{1,2}:\d{2}:\d{2}(?:[.,]\d+)?\b/g, "<clock>").replace(/\b\d+(?:\.\d+)?\s?(?:ms|s|sec|secs|seconds|m|min)\b/g, "<t>").replace(/\b0x[0-9a-f]{4,}\b/gi, "<hex>")).filter((l) => l !== "");
101920
- return createHash40("sha256").update(norm5.join(`
102355
+ }
102356
+ function failureShape(out3) {
102357
+ return createHash40("sha256").update(failureLines(out3).join(`
101921
102358
  `)).digest("hex");
101922
102359
  }
101923
102360
  function enclosingDecl(lines3, at2) {
@@ -102306,7 +102743,7 @@ function wallPathProblem(repoDir, relPath) {
102306
102743
  for (const part of dirname71(rel) === "." ? [] : dirname71(rel).split(sep27)) {
102307
102744
  cur = join164(cur, part);
102308
102745
  try {
102309
- const st2 = lstatSync35(cur);
102746
+ const st2 = lstatSync36(cur);
102310
102747
  if (st2.isSymbolicLink() || !st2.isDirectory())
102311
102748
  return `Wall path crosses a symlink or non-directory: ${relPath}`;
102312
102749
  } catch {
@@ -102314,7 +102751,7 @@ function wallPathProblem(repoDir, relPath) {
102314
102751
  }
102315
102752
  }
102316
102753
  try {
102317
- return lstatSync35(join164(repoDir, rel)).isSymbolicLink() ? `Wall path is a symlink: ${relPath}` : null;
102754
+ return lstatSync36(join164(repoDir, rel)).isSymbolicLink() ? `Wall path is a symlink: ${relPath}` : null;
102318
102755
  } catch {
102319
102756
  return null;
102320
102757
  }
@@ -102366,7 +102803,7 @@ function changedFiles(repoDir, baseSha, skip2) {
102366
102803
  return [...new Set([...tracked, ...untracked3])].filter((f) => !f.startsWith(".loki/") && !skip2?.(f));
102367
102804
  }
102368
102805
  function sha256File2(abs) {
102369
- const st2 = lstatSync35(abs);
102806
+ const st2 = lstatSync36(abs);
102370
102807
  return st2.isSymbolicLink() ? `link:${readlinkSync10(abs)}` : st2.size > 4000000 ? `big:${st2.size}` : createHash40("sha256").update(readFileSync149(abs)).digest("hex");
102371
102808
  }
102372
102809
  function fileHashes(repoDir, files) {
@@ -103243,7 +103680,22 @@ function toolFallbacks(repoDir, tool, env = process.env) {
103243
103680
  }
103244
103681
  return out3;
103245
103682
  }
103246
- function resolveTool(repoDir, bin, fallback, lastResort = fallback) {
103683
+ function canImport(py2, module) {
103684
+ if (!/^[A-Za-z_][\w.]*$/.test(module))
103685
+ return false;
103686
+ const k10 = `${py2}\x00${module}`;
103687
+ if (!importProbe.has(k10)) {
103688
+ let ok2 = false;
103689
+ try {
103690
+ ok2 = spawnSync28(py2, ["-c", `import ${module}`], { stdio: "ignore", timeout: 15000, env: plainTestEnv() }).status === 0;
103691
+ } catch {
103692
+ ok2 = false;
103693
+ }
103694
+ importProbe.set(k10, ok2);
103695
+ }
103696
+ return importProbe.get(k10);
103697
+ }
103698
+ function resolveTool(repoDir, bin, fallback, lastResort = fallback, module) {
103247
103699
  const inRepo2 = (p) => {
103248
103700
  try {
103249
103701
  const r = relative36(realpathSync48(repoDir), realpathSync48(p));
@@ -103254,6 +103706,11 @@ function resolveTool(repoDir, bin, fallback, lastResort = fallback) {
103254
103706
  };
103255
103707
  const venvEnv = process.env["VIRTUAL_ENV"], onPath2 = (b) => Bun.which(b, { PATH: process.env["PATH"] ?? "" });
103256
103708
  const project = [join164(repoDir, ".venv", "bin", bin), join164(repoDir, "venv", "bin", bin), ...venvEnv && inRepo2(venvEnv) ? [join164(venvEnv, "bin", bin)] : []].find(existsSync117);
103709
+ if (project && module && !canImport(project, module)) {
103710
+ const sys = onPath2(fallback) ? fallback : lastResort;
103711
+ venvSkips.set(`${repoDir}\x00${project}\x00${module}`, `tests ran on ${sys}, outside the project virtualenv: ${relative36(repoDir, project)} cannot import ${module}`);
103712
+ return [sys, "system", []];
103713
+ }
103257
103714
  return project ? [project, "project", []] : existsSync117(join164(repoDir, "uv.lock")) && onPath2("uv") ? ["uv", "project", ["run", "--", bin]] : [onPath2(fallback) ? fallback : lastResort, "system", []];
103258
103715
  }
103259
103716
  function goTestNames(file) {
@@ -103269,7 +103726,7 @@ function runnerCmd(t, repoDir) {
103269
103726
  return ["bash", ["-c", own]];
103270
103727
  switch (t.runner) {
103271
103728
  case "pytest": {
103272
- const [cmd2, interpreter, pre2] = resolveTool(repoDir, "python", "python3", "python");
103729
+ const [cmd2, interpreter, pre2] = resolveTool(repoDir, "python", "python3", "python", "pytest");
103273
103730
  return [cmd2, [...pre2, "-m", "pytest", "-q", t.path], interpreter];
103274
103731
  }
103275
103732
  case "unittest": {
@@ -103324,7 +103781,7 @@ function fullSuiteCmd(runner, repoDir) {
103324
103781
  return dotnetFullCmd(repoDir);
103325
103782
  if (runner !== "pytest" && runner !== "unittest")
103326
103783
  return FULL_SUITE_STATIC[runner];
103327
- const [cmd2, interpreter, pre2] = resolveTool(repoDir, "python", "python3", "python");
103784
+ const [cmd2, interpreter, pre2] = resolveTool(repoDir, "python", "python3", "python", runner === "pytest" ? "pytest" : undefined);
103328
103785
  return { cmd: cmd2, args: [...pre2, ...runner === "unittest" ? UNITTEST_DISCOVER_ARGS : ["-m", "pytest", "-q"]], ...runner === "unittest" && interpreter === "system" ? {} : { interpreter } };
103329
103786
  }
103330
103787
  function ownVitestSite(repoDir, path) {
@@ -103554,7 +104011,7 @@ Go: your test files are copied into ${relative36(repoDir, targetDir) || "the rep
103554
104011
  return m !== null && varNamesTool(tool, m[1]) && (wordIsTool(tool, m[2]) || varIsTool(tool, m[2]));
103555
104012
  }, SPAWN_API, DYNAMIC_CMD, varIsTool = (tool, w) => [...w.matchAll(/\$\{?([A-Za-z_][A-Za-z0-9_]*)(?::?-([^}]*))?/g)].some((m) => m[1].toLowerCase() === tool || m[2] !== undefined && wordIsTool(tool, m[2])), anyCommandRuns = (tool, line2, depth = 0) => simpleCommands(line2).reduce((acc, c) => triOr(acc, runsTool(tool, c, depth)), NO2), commandWords = (cmd2, args) => args ? [cmd2, ...args] : cmd2.trim().split(/\s+/), GO_JSON_KEEP, goJsonStream = (cmd2, args) => goRunner(cmd2, args).runner === "go" && commandWords(cmd2, args).includes("-json"), CARGO_GLOBAL_FLAGS, CARGO_OTHER_SUBS, CARGO_RUNNER_REASON = "test count could not be confirmed: a cargo target or alias setting can redirect both the test run and its listing", CARGO_UNLISTED_REASON = "test count could not be confirmed: the cargo summary does not match the tests cargo lists for the same command", CARGO_KEY = (name) => new RegExp(`(?:^|[\\s\\[,{.])["']?${name}["']?\\s*[.\\]=]`, "m"), CARGO_TARGET_KEY, CARGO_ALIAS_KEY, CARGO_REDIRECT_TEXT = (t) => CARGO_TARGET_KEY.test(t) || CARGO_ALIAS_KEY.test(t) || /\\[uU]/.test(t) || /^\s*include\s*=/m.test(t), CARGO_TOOLCHAIN_REASON = "test count could not be confirmed: a rust-toolchain path or RUSTUP_TOOLCHAIN path hands every cargo call to a toolchain the repo controls", lstatOk = (f) => {
103556
104013
  try {
103557
- lstatSync35(f);
104014
+ lstatSync36(f);
103558
104015
  return true;
103559
104016
  } catch {
103560
104017
  return false;
@@ -103619,7 +104076,7 @@ const done = (code, sig) => { if (fin) return; fin = true; kill("SIGKILL"); try
103619
104076
  setTimeout(() => { to = true; kill("SIGTERM"); setTimeout(() => done(null, 1), 1000); }, ms);
103620
104077
  const over = () => { if (out.length > MAX || err.length > MAX) { to = true; kill("SIGKILL"); } };
103621
104078
  c.stdout.on("data", (d) => { out += d; over(); }); c.stderr.on("data", (d) => { err += d; over(); });
103622
- c.on("error", () => done(null, 1)); c.on("close", done); c.on("exit", (a, b) => setTimeout(() => done(a, b), 500)); `, FULL_SUITE_STATIC, BUILD_TOOL_RUNNERS, VITEST_CFG, WALL_FAILURE_TAIL_FILE = "wall-failure-tail.txt", ALREADY_FAILING_ON_BASE = "already failing on base, not caused by this change", SKIPPED_BY_REPO = "skipped by the repo on base and head", checkResultLabel = (result, preRed, repoSkipped = false) => result === "fail" && preRed ? `fail (${ALREADY_FAILING_ON_BASE})` : result === "not_run" && repoSkipped ? `not_run (${SKIPPED_BY_REPO})` : result, blobSha = (b, hex) => createHash40(hex === 64 ? "sha256" : "sha1").update(Buffer.concat([Buffer.from(`blob ${b.length}\x00`), b])).digest("hex"), URL_RE2, ANCHOR_RE, EXTENSIONLESS;
104079
+ c.on("error", () => done(null, 1)); c.on("close", done); c.on("exit", (a, b) => setTimeout(() => done(a, b), 500)); `, importProbe, venvSkips, venvSkipNotes = (repoDir) => [...venvSkips].filter(([k10]) => k10.startsWith(`${repoDir}\x00`)).map(([, v10]) => v10), FULL_SUITE_STATIC, BUILD_TOOL_RUNNERS, VITEST_CFG, WALL_FAILURE_TAIL_FILE = "wall-failure-tail.txt", ALREADY_FAILING_ON_BASE = "already failing on base, not caused by this change", SKIPPED_BY_REPO = "skipped by the repo on base and head", checkResultLabel = (result, preRed, repoSkipped = false) => result === "fail" && preRed ? `fail (${ALREADY_FAILING_ON_BASE})` : result === "not_run" && repoSkipped ? `not_run (${SKIPPED_BY_REPO})` : result, blobSha = (b, hex) => createHash40(hex === 64 ? "sha256" : "sha1").update(Buffer.concat([Buffer.from(`blob ${b.length}\x00`), b])).digest("hex"), URL_RE2, ANCHOR_RE, EXTENSIONLESS;
103623
104080
  var init_check_result = __esm(() => {
103624
104081
  init_stack_tools();
103625
104082
  init_dotnet_test();
@@ -103748,6 +104205,8 @@ var init_check_result = __esm(() => {
103748
104205
  MISSING_API = /^(?:Import|ModuleNotFound|Attribute|Name|UnboundLocal|Syntax|Indentation)Error\b|^TypeError: .*(?:unexpected keyword argument|positional argument|required (?:positional|keyword-only) argument|is not callable|takes no arguments)/;
103749
104206
  JS_ASSERTED = /\bAssertionError\b|\bERR_ASSERTION\b|\bexpect\((?:received|value)\)\.\w+/;
103750
104207
  JS_MISSING_API = /\bTypeError: [^\n]*\bis not a (?:function|constructor)\b|\bReferenceError: |\bSyntaxError: |Cannot find module|ERR_MODULE_NOT_FOUND|does not provide an export named|is not exported|Test suite failed to run|failureType: '(?:hookFailed|cancelledByParent)'|test failed to load/;
104208
+ importProbe = new Map;
104209
+ venvSkips = new Map;
103751
104210
  FULL_SUITE_STATIC = {
103752
104211
  vitest: { cmd: "npx", args: ["vitest", "run"] },
103753
104212
  jest: { cmd: "npx", args: ["jest"] },
@@ -127879,7 +128338,7 @@ __export(exports_run_outputs, {
127879
128338
  });
127880
128339
  import { execFile as execFile3, spawnSync as spawnSync29 } from "child_process";
127881
128340
  import { createHash as createHash42 } from "crypto";
127882
- import { existsSync as existsSync120, lstatSync as lstatSync36, mkdirSync as mkdirSync92, readdirSync as readdirSync59, readFileSync as readFileSync154, statSync as statSync53, writeFileSync as writeFileSync90 } from "fs";
128341
+ import { existsSync as existsSync120, lstatSync as lstatSync37, mkdirSync as mkdirSync92, readdirSync as readdirSync59, readFileSync as readFileSync154, statSync as statSync53, writeFileSync as writeFileSync90 } from "fs";
127883
128342
  import { basename as basename49, join as join169, resolve as resolve46 } from "path";
127884
128343
  function intentRevisionsBlock(revs) {
127885
128344
  const r = (revs ?? []).filter((r10) => r10.unapplied !== true).map(({ rev, source, actor, sha: sha6 }) => ({ rev, source, actor, sha: sha6 }));
@@ -128357,7 +128816,7 @@ async function signedReceiptFacts(runDir, runId2, events2) {
128357
128816
  const file = join169(runDir, "receipt.json"), { checkAttestation, computeReceiptHash: computeReceiptHash2, checkEventLog } = await Promise.resolve().then(() => (init_verify_cmd(), exports_verify_cmd)), { loadSigningKey: loadSigningKey2 } = await Promise.resolve().then(() => (init_receipt_signer(), exports_receipt_signer));
128358
128817
  for (const f of [file, join169(runDir, "events.jsonl")]) {
128359
128818
  try {
128360
- if (lstatSync36(f).isSymbolicLink())
128819
+ if (lstatSync37(f).isSymbolicLink())
128361
128820
  return { problem: `${basename49(f)} is a symlink; a run's own files are never links` };
128362
128821
  } catch {}
128363
128822
  }
@@ -128533,7 +128992,7 @@ function discardRun(repoDir, runId2) {
128533
128992
  return false;
128534
128993
  const dir = join169(repoDir, ".loki", "runs", runId2);
128535
128994
  try {
128536
- if (!lstatSync36(dir).isDirectory())
128995
+ if (!lstatSync37(dir).isDirectory())
128537
128996
  return false;
128538
128997
  writeFileSync90(join169(dir, DISCARD_MARK), `${new Date().toISOString()}
128539
128998
  `, { flag: "wx" });