loki-mode 11.154.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 +1903 -1901
  8. package/mcp/__init__.py +1 -1
  9. package/package.json +2 -2
  10. package/packages/control-plane/dist/server.js +796 -343
  11. package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
  12. package/web-app/dist/assets/{AdminPage-DiYv9QX3.js → AdminPage-Boa67lzh.js} +1 -1
  13. package/web-app/dist/assets/{Avatar-D8xgDhXi.js → Avatar-C3DI3EEn.js} +1 -1
  14. package/web-app/dist/assets/{Badge-B9uBTN7K.js → Badge-BnGLw1fJ.js} +1 -1
  15. package/web-app/dist/assets/{Button-BJkNLiWh.js → Button-ZMnLNI7o.js} +1 -1
  16. package/web-app/dist/assets/{CockpitPage-DG23RV4T.js → CockpitPage-DIIqR58D.js} +1 -1
  17. package/web-app/dist/assets/{ComparePage-CY9mcXyY.js → ComparePage-CDsN66rY.js} +1 -1
  18. package/web-app/dist/assets/{ErrorBoundary-COHsdbJf.js → ErrorBoundary-DrZ3fY1U.js} +1 -1
  19. package/web-app/dist/assets/{EvidenceReceiptPanel-B4PseFey.js → EvidenceReceiptPanel-CZcqcDS3.js} +1 -1
  20. package/web-app/dist/assets/{GitHubIssuesPanel-D0KfNlW2.js → GitHubIssuesPanel-COUvczPk.js} +1 -1
  21. package/web-app/dist/assets/{GitHubPRsPanel-CDPAE9fn.js → GitHubPRsPanel-DbooMfZ0.js} +1 -1
  22. package/web-app/dist/assets/{HomePage-aKEHtjps.js → HomePage-DGuRFkHe.js} +2 -2
  23. package/web-app/dist/assets/{LoginPage-Dz3tkjNe.js → LoginPage--OEMrZWJ.js} +1 -1
  24. package/web-app/dist/assets/{MagicPage-CwX7Qveh.js → MagicPage-DcY1ZUQz.js} +1 -1
  25. package/web-app/dist/assets/{MetricsPage-BPn1kGrY.js → MetricsPage-Zck3H8PY.js} +1 -1
  26. package/web-app/dist/assets/{NotFoundPage-yN4E_E9L.js → NotFoundPage-q-O5Dgw8.js} +1 -1
  27. package/web-app/dist/assets/{ProjectPage-DGozzUjl.js → ProjectPage-DKEhIWSM.js} +3 -3
  28. package/web-app/dist/assets/{ProjectsPage-CKfZ9HqL.js → ProjectsPage-4qJqGKCc.js} +1 -1
  29. package/web-app/dist/assets/{SettingsPage-CZwkXq9s.js → SettingsPage-Dhwccm2t.js} +1 -1
  30. package/web-app/dist/assets/{ShowcasePage-DMT87b7c.js → ShowcasePage-r2OE0IpC.js} +1 -1
  31. package/web-app/dist/assets/{SystemSettingsPage-DXQECr0D.js → SystemSettingsPage-C6DmgimV.js} +1 -1
  32. package/web-app/dist/assets/{TeamsPage-BToX86gg.js → TeamsPage-Bs9BwK8e.js} +1 -1
  33. package/web-app/dist/assets/{TemplatesPage-BOsPainh.js → TemplatesPage-GmpwmgEh.js} +1 -1
  34. package/web-app/dist/assets/{TerminalOutput-BpUH2T2I.js → TerminalOutput-CaofkqFm.js} +1 -1
  35. package/web-app/dist/assets/{activity-3fblzNUj.js → activity-D-14EqSb.js} +1 -1
  36. package/web-app/dist/assets/{bell-mA0pgtzl.js → bell-C1c4rghW.js} +1 -1
  37. package/web-app/dist/assets/{bot-vQONIYoS.js → bot-BqSfqVvF.js} +1 -1
  38. package/web-app/dist/assets/{check-BrEJZqtS.js → check-CahavLb3.js} +1 -1
  39. package/web-app/dist/assets/{chevron-left-50IJvv4C.js → chevron-left-DUt0IVom.js} +1 -1
  40. package/web-app/dist/assets/{circle-alert-D9syjc3B.js → circle-alert-geBwxian.js} +1 -1
  41. package/web-app/dist/assets/{clock-BboMPS77.js → clock-BsJao1Wl.js} +1 -1
  42. package/web-app/dist/assets/{cloud-DDEp4yUM.js → cloud-PePBuFR2.js} +1 -1
  43. package/web-app/dist/assets/{code-xml-CAtMXik8.js → code-xml-B30O5Rvg.js} +1 -1
  44. package/web-app/dist/assets/{database-CAOqYM1E.js → database-BdxKkqEA.js} +1 -1
  45. package/web-app/dist/assets/{dollar-sign-DOdmdqOB.js → dollar-sign-Byx9c05P.js} +1 -1
  46. package/web-app/dist/assets/{file-code-corner-BPAksle-.js → file-code-corner-BxPRoPfK.js} +1 -1
  47. package/web-app/dist/assets/{file-plus-CBmhCe_9.js → file-plus-CK_Y36Mo.js} +1 -1
  48. package/web-app/dist/assets/{globe-ZsWZvCkr.js → globe-Bakqsa6G.js} +1 -1
  49. package/web-app/dist/assets/{hammer-SbKfTPb3.js → hammer-2bumN232.js} +1 -1
  50. package/web-app/dist/assets/{index-C74Su7jP.js → index-hm-yRBoI.js} +3 -3
  51. package/web-app/dist/assets/{layers-Cv_FErq-.js → layers-Ba8SyI41.js} +1 -1
  52. package/web-app/dist/assets/{loader-circle-dIPyEfsE.js → loader-circle-BB-t0hUZ.js} +1 -1
  53. package/web-app/dist/assets/{lock-CGAxTxO5.js → lock-geLwsvEJ.js} +1 -1
  54. package/web-app/dist/assets/{package-CgvIF1Ku.js → package-CilxqDqb.js} +1 -1
  55. package/web-app/dist/assets/{plus-_3FKv0NS.js → plus-eS9shrSX.js} +1 -1
  56. package/web-app/dist/assets/{refresh-cw-Bnb0_V6n.js → refresh-cw-sd9kWzxP.js} +1 -1
  57. package/web-app/dist/assets/{rotate-ccw-ZLvlePsk.js → rotate-ccw-fpPuQpml.js} +1 -1
  58. package/web-app/dist/assets/{scroll-text-BPFgZCbN.js → scroll-text-BwAKCqKY.js} +1 -1
  59. package/web-app/dist/assets/{server-H0O63Cgk.js → server-BD2uVpGr.js} +1 -1
  60. package/web-app/dist/assets/{shield-alert-DZ91-CiS.js → shield-alert-Dru2kiyn.js} +1 -1
  61. package/web-app/dist/assets/{thumbs-up-DPoDpxQt.js → thumbs-up-Bvz7N-Kv.js} +1 -1
  62. package/web-app/dist/assets/{trash-2-Da4bSFuC.js → trash-2-u0TXHYJE.js} +1 -1
  63. package/web-app/dist/assets/{trending-down-CcnmOjB2.js → trending-down-CnhmwKMr.js} +1 -1
  64. package/web-app/dist/assets/{trending-up-NzCUunlQ.js → trending-up-DyzE_6em.js} +1 -1
  65. package/web-app/dist/assets/{upload-Cy_koNIe.js → upload-CsyUlDw7.js} +1 -1
  66. package/web-app/dist/assets/{usePolling-CgA0f7-y.js → usePolling-2de8HDwC.js} +1 -1
  67. package/web-app/dist/assets/{user-DkwhGZ5j.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 {
@@ -17882,7 +17959,7 @@ function repoReadiness(p, host, verify3 = []) {
17882
17959
  const miss = verify3.find((c) => c.validated === false);
17883
17960
  if (miss)
17884
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.` });
17885
- } 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)
17886
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." });
17887
17964
  else if (b.failing_ids.length > 0)
17888
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." });
@@ -17955,7 +18032,32 @@ ${r.stderr ?? ""}`), missing: r.status === 127 };
17955
18032
  for (const f of untracked(repoDir))
17956
18033
  if (!before.has(f))
17957
18034
  rmSync11(join57(repoDir, f), { force: true, recursive: true });
17958
- }, 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) => {
17959
18061
  try {
17960
18062
  return safeGit(repoDir, ["rev-parse", "HEAD"]).trim();
17961
18063
  } catch {
@@ -18197,6 +18299,8 @@ __export(exports_package_suite, {
18197
18299
  suiteTimeoutOn: () => suiteTimeoutOn,
18198
18300
  suiteEnv: () => suiteEnv,
18199
18301
  suiteCmdsOpt: () => suiteCmdsOpt,
18302
+ scopedSuites: () => scopedSuites,
18303
+ scopedOutNote: () => scopedOutNote,
18200
18304
  runPackageSuites: () => runPackageSuites,
18201
18305
  packageSuiteSpecs: () => packageSuiteSpecs,
18202
18306
  ownedSuites: () => ownedSuites,
@@ -18218,6 +18322,27 @@ function ownedSuites(specs, changed) {
18218
18322
  }
18219
18323
  return specs.filter((s) => out2.has(s));
18220
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
+ }
18221
18346
  function packageSuiteSpecs(api, repoDir) {
18222
18347
  if (!isMultiRoot(api))
18223
18348
  return null;
@@ -18335,12 +18460,21 @@ async function runPackageSuites(repoDir, signal, opts, checks, notProven) {
18335
18460
  const api = loadProjectApi(repoDir), all = packageSuiteSpecs(api, repoDir);
18336
18461
  if (!api || !all)
18337
18462
  return false;
18338
- const specs = opts.ownedOnly ? ownedSuites(all, opts.changed ?? []) : all;
18339
- 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)
18340
18466
  return false;
18341
- 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
+ }
18342
18476
  const started = Date.now();
18343
- 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 } : {} });
18344
18478
  const duration_s = (Date.now() - started) / 1000;
18345
18479
  if (signal.aborted) {
18346
18480
  checks.push({ name, cmd, result: "not_run", duration_s });
@@ -18348,7 +18482,7 @@ async function runPackageSuites(repoDir, signal, opts, checks, notProven) {
18348
18482
  continue;
18349
18483
  }
18350
18484
  if (r.timedOut && suiteTimeoutOn()) {
18351
- const why = `timed out after ${Math.round(opts.timeoutMs / 1000)}s`;
18485
+ const why = `timed out after ${Math.round(timeoutMs / 1000)}s`;
18352
18486
  checks.push({ name, cmd, result: "not_run", duration_s, reason: why });
18353
18487
  notProven.add(`not run: ${name} (${why})`);
18354
18488
  continue;
@@ -18362,6 +18496,8 @@ ${r.stderr}`).replace(go ? /^make(?:\[\d+\])?: .*$/gm : /(?!)/, "");
18362
18496
  continue;
18363
18497
  }
18364
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);
18365
18501
  if (cls.result === "not_run" && r.exitCode === 0 && (opts.targetPassed === true || cwd !== "." && emptySubsuiteNaOn()) && suiteEmptyOnBase(repoDir, opts.baseSha, line2, cmd, cls, out2, cwd)) {
18366
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"})`);
18367
18503
  continue;
@@ -18387,7 +18523,7 @@ ${r.stderr}`).replace(go ? /^make(?:\[\d+\])?: .*$/gm : /(?!)/, "");
18387
18523
  }
18388
18524
  return true;
18389
18525
  }
18390
- 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) => {
18391
18527
  const f = baseRun?.fail;
18392
18528
  return typeof f === "number" && f > 0;
18393
18529
  }, wallProofOf = (checks, wall) => {
@@ -18402,6 +18538,7 @@ var init_package_suite = __esm(() => {
18402
18538
  init_stack_tools();
18403
18539
  init_failures();
18404
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)$/;
18405
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"]);
18406
18543
  });
18407
18544
 
@@ -35927,6 +36064,7 @@ var init_budget_cap = __esm(() => {
35927
36064
  // ../../loki-ts/src/engine10/machine.ts
35928
36065
  var exports_machine = {};
35929
36066
  __export(exports_machine, {
36067
+ verifyLimitFor: () => verifyLimitFor,
35930
36068
  suiteOnlyRed: () => suiteOnlyRed,
35931
36069
  suiteFixSkipEnabled: () => suiteFixSkipEnabled,
35932
36070
  stillFailing: () => stillFailing,
@@ -35940,6 +36078,7 @@ __export(exports_machine, {
35940
36078
  haikuIndepFixOn: () => haikuIndepFixOn,
35941
36079
  freshBaseCheckout: () => freshBaseCheckout,
35942
36080
  attemptSignalOf: () => attemptSignalOf,
36081
+ VERIFY_MAX_S: () => VERIFY_MAX_S,
35943
36082
  USAGE_LIMIT_STOP: () => USAGE_LIMIT_STOP,
35944
36083
  SUITE_FIX_SKIP_NOTE: () => SUITE_FIX_SKIP_NOTE,
35945
36084
  PRE_EXISTING_CLAIM: () => PRE_EXISTING_CLAIM,
@@ -35983,6 +36122,10 @@ function stillFailing(groups, kept) {
35983
36122
  return !green.some((n3) => s === n3 || s.startsWith(`${n3} `));
35984
36123
  });
35985
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
+ }
35986
36129
  function softCapS(capS) {
35987
36130
  const plain = capS * 14 / 15, budget = backstopS(capS) - ((STAGE_BUDGETS.commit.targetS ?? 0) + (STAGE_BUDGETS.seal.targetS ?? 0) + KILL_GRACE_MS3 / 1000 + 2);
35988
36131
  return Math.max(0, Math.min(plain, budget));
@@ -36054,7 +36197,7 @@ ${timeBudgetNote(limitS)}`;
36054
36197
  let implementBudgetS = 0;
36055
36198
  const implementLimitS = (floorS) => Math.max(floorS, Math.floor(softCapS(ctx.capS) - elapsedS2() - (STAGE_BUDGETS.verify.limitS ?? 0) - proveReserveS()));
36056
36199
  const fixLimitS = (baseS) => Math.max(baseS, Math.min(2 * baseS, Math.round(baseS * ctx.capS / DEFAULT_CAP_S)));
36057
- 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());
36058
36201
  const runStage = async (name, underCap) => {
36059
36202
  if (limited)
36060
36203
  throw new UsageLimitCut;
@@ -36074,6 +36217,8 @@ ${timeBudgetNote(limitS)}`;
36074
36217
  }
36075
36218
  ctx.emit("stage.started", name, { target_s: st.targetS, limit_s: limitS, ...name === "wall" ? { start_ms: ctx.clock.now() } : {} });
36076
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));
36077
36222
  const dur = () => (ctx.clock.now() - t0) / 1000;
36078
36223
  const snapBefore = TREE_STAGES.has(name) || name === "verify" && regenDropOn() ? treeSnapshot(ctx.repoDir) : null;
36079
36224
  const ctl = new AbortController;
@@ -36603,7 +36748,7 @@ var FLOW, TAIL, USAGE_LIMIT_STOP = "usage_limit", UsageLimitCut, harnessOnlyFail
36603
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/"));
36604
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))));
36605
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 ?? "")));
36606
- }, 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;
36607
36752
  var init_machine = __esm(() => {
36608
36753
  init_base_guard();
36609
36754
  init_commit_filter();
@@ -36648,7 +36793,7 @@ var init_machine = __esm(() => {
36648
36793
  }
36649
36794
  };
36650
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;
36651
- 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;
36652
36797
  ATTEMPTS_TAIL_S = STAGE_BUDGETS.verify.limitS + STAGE_BUDGETS.commit.limitS + STAGE_BUDGETS.seal.limitS + STAGE_BUDGETS.pr.limitS;
36653
36798
  TREE_STAGES = new Set(["wall", "implement", "prove", "fix"]);
36654
36799
  });
@@ -48127,25 +48272,25 @@ Summary:`);
48127
48272
  if (at < 0)
48128
48273
  return { usd: null, measured: 0, unmeasured: 0 };
48129
48274
  const tail2 = stdout.slice(at + 1);
48130
- let usd = 0, measured = 0, unmeasured = 0;
48275
+ let usd = 0, measured2 = 0, unmeasured = 0;
48131
48276
  for (const m of tail2.matchAll(/^(?!ITEM\b)\S+[ \t]+(\$[0-9]+(?:\.[0-9]+)?|unmeasured)[ \t]+\S/gm)) {
48132
48277
  if (m[1] === "unmeasured")
48133
48278
  unmeasured++;
48134
48279
  else {
48135
48280
  usd += Number(m[1].slice(1));
48136
- measured++;
48281
+ measured2++;
48137
48282
  }
48138
48283
  }
48139
- return { usd: measured > 0 ? usd : null, measured, unmeasured };
48284
+ return { usd: measured2 > 0 ? usd : null, measured: measured2, unmeasured };
48140
48285
  }
48141
48286
  function groupCostLine(costs, provider = "claude") {
48142
- const measured = costs.reduce((a, c) => a + c.measured, 0), unmeasured = costs.reduce((a, c) => a + c.unmeasured, 0);
48143
- 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)
48144
48289
  return `Cost: not measured
48145
48290
  `;
48146
48291
  const usd = costs.reduce((a, c) => a + (c.usd ?? 0), 0);
48147
- return unmeasured > 0 ? `Cost: $${usd.toFixed(2)} partial (${provider}, ${measured} of ${measured + unmeasured} unit sessions measured)
48148
- ` : `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"})
48149
48294
  `;
48150
48295
  }
48151
48296
  function writeGroupCostRecord(repoDir, name, costs, provider) {
@@ -51348,7 +51493,13 @@ async function runIntakeBody(ctx, signal, opts, held) {
51348
51493
  if (dirty.length > 0)
51349
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` };
51350
51495
  let baseSha = git13(ctx.repoDir, ["rev-parse", "HEAD"]);
51351
- 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
+ })();
51352
51503
  let stacked = stackedOnLokiRun(ctx.repoDir);
51353
51504
  if (stacked) {
51354
51505
  try {
@@ -51429,7 +51580,8 @@ async function runIntakeBody(ctx, signal, opts, held) {
51429
51580
  tm.repo_walk = { ms: walkEnd(), at: walkAt, cached: walkCached };
51430
51581
  tm.exec_spec_prefetch = await prefetchLeanExecSpec(ctx, task, repoMap, testmap, signal);
51431
51582
  const baselineAt = at(), baselineEnd = lap(), baselineOn = process.env.LOKI_REPO_BASELINE !== "0";
51432
- 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();
51433
51585
  if (icap !== null && built && !built.reused && built.profile.baseline.timed_out && icap < baselineCmdS(ctx.capS))
51434
51586
  intakeBudgetNote(baselineMs / 1000, "root baseline cut off on base");
51435
51587
  const readiness = built ? readinessNotice(ctx.repoDir, repoReadiness(built.profile, undefined, built.profile.commands.some((c) => c.kind === "test") ? [] : verifyCommandRows(ctx.repoDir, testmap))) : null;
@@ -51807,7 +51959,7 @@ import { copyFileSync as copyFileSync9, existsSync as existsSync97, mkdirSync as
51807
51959
  import { tmpdir as tmpdir26 } from "os";
51808
51960
  import { dirname as dirname60, join as join137 } from "path";
51809
51961
  async function runFullSuite(ctx, signal, opts, checks, notProven2) {
51810
- 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))
51811
51963
  return;
51812
51964
  const map = await ctx.tests.detect(ctx.repoDir);
51813
51965
  if (map.runners.length === 0) {
@@ -56153,7 +56305,7 @@ var NAME_WIDTH = 12, STATUS_WIDTH = 8, LABEL_WIDTH = 12, etaMod = null, targetOf
56153
56305
  const c = summaryCost(events2, false, lokiRoot);
56154
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)";
56155
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)}
56156
- `, 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`;
56157
56309
  var init_output = __esm(() => {
56158
56310
  init_types2();
56159
56311
  init_term_width();
@@ -56233,12 +56385,13 @@ __export(exports_base_guard, {
56233
56385
  deepPid: () => deepPid,
56234
56386
  deepAlive: () => deepAlive,
56235
56387
  baseLine: () => baseLine,
56388
+ baseDepsView: () => baseDepsView,
56236
56389
  baseDepsLinker: () => baseDepsLinker,
56237
56390
  addedSymlinkNotes: () => addedSymlinkNotes
56238
56391
  });
56239
56392
  import { execFileSync as execFileSync12 } from "child_process";
56240
56393
  import { createHash as createHash39 } from "crypto";
56241
- 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";
56242
56395
  import { tmpdir as tmpdir31 } from "os";
56243
56396
  import { basename as basename43, dirname as dirname65, join as join154, relative as relative32, resolve as resolve39, sep as sep24 } from "path";
56244
56397
  import { fileURLToPath as fileURLToPath5 } from "url";
@@ -56527,6 +56680,91 @@ function baseDepsLinker(baseDir, repoDir, gate = {}) {
56527
56680
  return true;
56528
56681
  };
56529
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
+ }
56530
56768
  function isZeroRun(c, b) {
56531
56769
  const last = c.args[c.args.length - 1] ?? "";
56532
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 });
@@ -56635,11 +56873,12 @@ function settleBranch(repoDir, branch, dir, stem2, pushed, extra = {}) {
56635
56873
  return { note: bundle ? `engine10: run branch ${branch} removed, its history is saved; restore it with: git fetch ${bundle} ${branch}:${branch}
56636
56874
  ` : "", deleted: true };
56637
56875
  }
56638
- function returnCheckout(repoDir, branch, orig) {
56876
+ function returnCheckout(repoDir, branch, orig, startSha = null) {
56639
56877
  const cur = currentBranch(repoDir);
56640
56878
  if (cur !== branch)
56641
56879
  return null;
56642
- if (!orig || orig === branch)
56880
+ const detached = !orig && !!startSha && /^[0-9a-f]{40}$/.test(startSha);
56881
+ if (!detached && (!orig || orig === branch))
56643
56882
  return `engine10: the checkout stays on ${branch}: the run did not record the branch it started from
56644
56883
  `;
56645
56884
  let dirty;
@@ -56649,8 +56888,11 @@ function returnCheckout(repoDir, branch, orig) {
56649
56888
  dirty = null;
56650
56889
  }
56651
56890
  if (dirty === null || dirty.split("\x00").filter(Boolean).some((l) => !l.slice(3).startsWith(".loki/")))
56652
- 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}
56653
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;
56654
56896
  return git14(repoDir, ["checkout", "-q", orig]) === null ? `engine10: the checkout stays on ${branch}: git checkout ${orig} failed; return with: git checkout ${orig}
56655
56897
  ` : null;
56656
56898
  }
@@ -56705,7 +56947,7 @@ function finishRunBranch(repoDir, runId2, end, env = process.env) {
56705
56947
  notes += `engine10: removed Loki's own acceptance test ${wallGone.join(", ")} from your tree; its sealed copy is under .loki/runs/${runId2}/wall/
56706
56948
  `;
56707
56949
  const keepHere = end.keepWork === true && tip !== null && tipOf(repoDir, end.baseSha ?? "") !== tip;
56708
- const stay = tip ? returnCheckout(repoDir, branch, end.orig) : null;
56950
+ const stay = tip ? returnCheckout(repoDir, branch, end.orig, end.baseSha ?? null) : null;
56709
56951
  if (stay)
56710
56952
  notes += stay;
56711
56953
  if (tip && !keepHere) {
@@ -56755,7 +56997,7 @@ function sweepRunBranches(repoDir, env = process.env, skipRunId) {
56755
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>)` : ""}
56756
56998
  ${kept.join("")}`;
56757
56999
  }
56758
- 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) => {
56759
57001
  try {
56760
57002
  return safeGit(repoDir, ["rev-parse", "--verify", "-q", `${ref}^{commit}`], { stdio: ["ignore", "pipe", "ignore"] }).trim() || null;
56761
57003
  } catch {
@@ -56815,9 +57057,11 @@ __export(exports_verify, {
56815
57057
  timeoutCarryOn: () => timeoutCarryOn,
56816
57058
  testConfigChanged: () => testConfigChanged,
56817
57059
  testCheckName: () => testCheckName,
57060
+ suiteTimeoutFor: () => suiteTimeoutFor,
56818
57061
  subtractBase: () => subtractBase,
56819
57062
  stage: () => stage10,
56820
57063
  skipped: () => skipped2,
57064
+ sameFailureLines: () => sameFailureLines,
56821
57065
  sameErrors: () => sameErrors,
56822
57066
  runnerCmd: () => runnerCmd,
56823
57067
  runOnce: () => runOnce3,
@@ -56852,11 +57096,14 @@ __export(exports_verify, {
56852
57096
  WALL_FAILURE_TAIL_FILE: () => WALL_FAILURE_TAIL_FILE,
56853
57097
  WALL_FAILURE_TAIL_CAP: () => WALL_FAILURE_TAIL_CAP,
56854
57098
  TIMEOUT_CARRY_NOTE: () => TIMEOUT_CARRY_NOTE,
57099
+ SUITE_MARGIN_MS: () => SUITE_MARGIN_MS,
56855
57100
  QUIET_RED: () => QUIET_RED,
57101
+ NO_ID_BASE_REASON: () => NO_ID_BASE_REASON,
56856
57102
  LINT_UNTOUCHED_NOTE: () => LINT_UNTOUCHED_NOTE,
56857
57103
  KILL_AFTER_MS: () => KILL_AFTER_MS,
56858
57104
  COLLATERAL_RED: () => COLLATERAL_RED,
56859
- BCE_REASON: () => BCE_REASON
57105
+ BCE_REASON: () => BCE_REASON,
57106
+ BASE_NOT_MEASURED: () => BASE_NOT_MEASURED
56860
57107
  });
56861
57108
  import { existsSync as existsSync109, mkdtempSync as mkdtempSync26, readFileSync as readFileSync142, realpathSync as realpathSync45, rmSync as rmSync50, statSync as statSync47 } from "fs";
56862
57109
  import { tmpdir as tmpdir32 } from "os";
@@ -56872,6 +57119,22 @@ function carriedTimeouts(prev, tests, changed, keep, env = process.env) {
56872
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}` }];
56873
57120
  });
56874
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
+ }
56875
57138
  function crashSignature(out3) {
56876
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);
56877
57140
  return m ? m[0].replace(/^[.sxXFE]+(?=Fatal Python error: )/, "").replace(/\s+/g, " ").replace(/'\/[^']*\//g, "'").trim() : null;
@@ -57065,6 +57328,8 @@ async function runCheck(ctx, name, cmd2, args, signal, checks, opts = {}) {
57065
57328
  excerpts.set(check, failureExcerpt(attempt.out, ctx.repoDir));
57066
57329
  failTails.set(check, wallTailOf(attempt.out, ctx.repoDir));
57067
57330
  headErrors.set(check, errorsById(attempt.out));
57331
+ if (kind === "test" && !check.ids?.length)
57332
+ noIdOut.set(check, attempt.out);
57068
57333
  }
57069
57334
  if (result === "fail" && kind === "static" && name.startsWith("lint:tsc"))
57070
57335
  tscOut.set(check, attempt.out);
@@ -57532,9 +57797,24 @@ function tscUntouchedOnly(out3, pkgRel, touched, symbols, baseOut) {
57532
57797
  const base2 = new Set(tscLines(baseOut));
57533
57798
  return tscLines(out3).every((l) => base2.has(l));
57534
57799
  }
57535
- async function tscOnBase(ctx, groupCwd, signal, opts) {
57800
+ async function tscOnBase(ctx, groupCwd, signal, opts, shared2) {
57536
57801
  if (signal.aborted)
57537
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
+ }
57538
57818
  const dir = mkdtempSync26(join155(tmpdir32(), "e10-basetsc-")), git15 = (args) => {
57539
57819
  safeGit(ctx.repoDir, args, { stdio: "ignore", repoDrivers: true });
57540
57820
  };
@@ -57563,7 +57843,7 @@ function lintFallbacks(repoDir, tool, env = process.env) {
57563
57843
  return lintMissingDiscloseOn(env) ? toolFallbacks(repoDir, tool, env) : [];
57564
57844
  }
57565
57845
  async function runLintChecks(ctx, changed, signal, checks, opts = {}) {
57566
- const { api, keep, untouched, ...runOpts } = opts;
57846
+ const { api, keep, untouched, base: base2, ...runOpts } = opts;
57567
57847
  opts = runOpts;
57568
57848
  const pre = [];
57569
57849
  const py = changed.filter((f) => f.endsWith(".py"));
@@ -57598,11 +57878,11 @@ async function runLintChecks(ctx, changed, signal, checks, opts = {}) {
57598
57878
  const c = await runCheck(ctx, `lint:tsc${sfx}`, "npx", ["--no-install", "tsc", "--noEmit", "-p", "."], signal, checks, { ...co, kind: "static" });
57599
57879
  if (c.result === "fail" && tscOnlyIgnored(ctx.repoDir, g2.cwd, tscOut.get(c) ?? ""))
57600
57880
  pre.push(c.name);
57601
- 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)))
57602
57882
  pre.push(c.name);
57603
57883
  else if (c.result === "fail" && keep && untouched && lintUntouchedOn()) {
57604
57884
  const syms = diffSymbols(ctx, [...keep]), o = tscOut.get(c) ?? "";
57605
- 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)))
57606
57886
  untouched.push(c.name);
57607
57887
  }
57608
57888
  }
@@ -57614,7 +57894,433 @@ async function runLintChecks(ctx, changed, signal, checks, opts = {}) {
57614
57894
  }
57615
57895
  return pre;
57616
57896
  }
57617
- 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) => {
57618
58324
  if (signal.aborted)
57619
58325
  return null;
57620
58326
  const r = await runOnce3(cmd2, a, cwd, AbortSignal.any([signal, AbortSignal.timeout(opts.timeoutMs ?? CHECK_TIMEOUT_MS)]), { ...opts, ...stdin !== undefined ? { stdin } : {} });
@@ -57625,8 +58331,11 @@ var timeoutCarryOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LO
57625
58331
  } catch {
57626
58332
  return null;
57627
58333
  }
57628
- } }), 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(`
57629
- `).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;
57630
58339
  var init_verify = __esm(() => {
57631
58340
  init_stack_tools();
57632
58341
  init_atomic();
@@ -57655,6 +58364,7 @@ var init_verify = __esm(() => {
57655
58364
  init_safe_git();
57656
58365
  init_test_guard();
57657
58366
  init_base_guard();
58367
+ init_package_suite();
57658
58368
  init_repo_profile();
57659
58369
  init_check_result();
57660
58370
  init_check_result();
@@ -57669,6 +58379,7 @@ var init_verify = __esm(() => {
57669
58379
  failTails = new WeakMap;
57670
58380
  tscOut = new WeakMap;
57671
58381
  crashSigs = new WeakMap;
58382
+ noIdOut = new WeakMap;
57672
58383
  headErrors = new WeakMap;
57673
58384
  TEST_TITLE_RE = /\b(?:it|test)(?:\.\w+)*\(\s*(['"`])((?:(?!\1).)+)\1/;
57674
58385
  UNHANDLED_RE = /Unhandled (?:Errors?|Rejection)\b/;
@@ -57682,294 +58393,12 @@ var init_verify = __esm(() => {
57682
58393
  targetS: STAGE_BUDGETS.verify.targetS,
57683
58394
  limitS: STAGE_BUDGETS.verify.limitS,
57684
58395
  async run(ctx, signal) {
57685
- let changed;
57686
- const ownWall = (ctx.outputs().wall?.files ?? []).map((f) => f.path), live2 = (l) => withoutStaleWall(l, ownWall, ctx.repoDir);
57687
- try {
57688
- changed = live2(changedFiles(ctx.repoDir, ctx.baseSha, installOwned(ctx.repoDir, ctx.outputs().intake?.install_created)));
57689
- } catch (err) {
57690
- return { status: "failed", data: {}, reason: `git diff against base failed: ${err.message}` };
57691
- }
57692
- if (changed.length === 0) {
57693
- const implementExit = ctx.outputs().implement?.exit;
57694
- if (implementExit === "already_done") {
57695
- return { status: "completed", data: { already_satisfied: true, checks: [], flaky: [], failures_grouped: [], changed_files: [] } };
57696
- }
57697
- return { status: "failed", data: { changed_files: [] }, reason: "empty diff without an already_done marker" };
57698
- }
57699
- let risk = (() => {
57700
- try {
57701
- const r = classifyRisk(live2(diffFiles(ctx.repoDir, ctx.baseSha, installOwned(ctx.repoDir, ctx.outputs().intake?.install_created))));
57702
- recordRisk(ctx.repoDir, r);
57703
- return r;
57704
- } catch {
57705
- return null;
57706
- }
57707
- })();
57708
- const checks = [];
57709
- const api = loadProjectApi(ctx.repoDir);
57710
- const map0 = await ctx.tests.detect(ctx.repoDir), map = { ...map0, tests: live2(map0.tests) };
57711
- const impacted = ctx.tests.impacted(map, changed);
57712
- const changedTestFiles = map.tests.filter((t) => changed.includes(t.path));
57713
- const wall = ctx.outputs().wall ?? {};
57714
- const wallPaths = new Set((wall.files ?? []).map((f) => isAbsolute21(f.path) ? relative33(ctx.repoDir, f.path) : f.path));
57715
- const intake = ctx.outputs().intake, repoMap = loadRepoMap(intake?.repomap_ref), named2 = namedFiles(intake?.task ?? "", repoMap), relevant2 = ctx.tests.impacted(map, named2);
57716
- const recorded = new Map((wall.files ?? []).flatMap((f) => f.runner ? [[isAbsolute21(f.path) ? relative33(ctx.repoDir, f.path) : f.path, f.runner]] : []));
57717
- const wallTests = [...wallPaths].flatMap((p) => {
57718
- const rec2 = recorded.get(p), found = map.tests.find((t) => t.path === p && (!rec2 || t.runner === rec2));
57719
- if (found)
57720
- return [found];
57721
- const runner = rec2 ?? guessRunner(basename44(p), map.runners, p);
57722
- return runner && (runner !== "bun" || map.runners.includes("bun") || /[._](?:test|spec)\.[cm]?[jt]sx?$/.test(p)) ? [{ runner, path: p }] : [];
57723
- });
57724
- const dep = dependentTests(ctx.repoDir, map, changed, [...impacted, ...changedTestFiles, ...wallTests, ...relevant2]), depNames = new Set(dep.tests.map(testCheckName));
57725
- const tests0 = failedFirst(dedupeTests([...wallTests, ...relevant2, ...changedTestFiles, ...changedSymbolsFirst(ctx, impacted, changed), ...dep.tests]), ctx.outputs().verify?.checks);
57726
- const tests = tests0.length === 0 ? [...mochaTargets(ctx.repoDir, changed), ...avaTargets(ctx.repoDir, changed)] : tests0;
57727
- const own = ownByPathOn() ? ownTests(relevant2, named2, changed) : relevant2;
57728
- const hashes = fileHashes(ctx.repoDir, changed), qs = quickScope(ctx.outputs(), hashes), keep = new Set([...qs?.blocking ?? [], ...[...wallTests, ...own].map(testCheckName)]);
57729
- 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: [] };
57730
- 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));
57731
- let holdN = wall.holdout_dir ? null : 0;
57732
- const publish = () => {
57733
- if (!ctx.partial)
57734
- return;
57735
- 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)));
57736
- const wp = w.some((c) => c.result === "fail") ? false : w.length > 0 && allRan && wallDropped0.length === 0 && w.every((c) => c.result === "pass") ? true : undefined;
57737
- 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 });
57738
- };
57739
- const scopedOut = scopedOutOf(map);
57740
- if (scopedOut.length)
57741
- ctx.emit("test.scoped_out", "verify", { tests: scopedOut });
57742
- const batchable = (t) => verifyBatchOn() && t.runner === "vitest" && !wallNames0.has(testCheckName(t));
57743
- const runTests = async (all) => {
57744
- const byName = new Map;
57745
- for (const c of carriedTimeouts(ctx.outputs().verify?.checks ?? [], all, changed, new Set([...wallNames0, ...targets0]))) {
57746
- byName.set(c.name, [c]);
57747
- done.push(c);
57748
- ctx.emit("test.result", "verify", { ...c });
57749
- }
57750
- const list = all.filter((t) => !byName.has(testCheckName(t)));
57751
- const alone = async (l) => {
57752
- (await mapPool(l, verifyJobs(), async (t) => {
57753
- const tc = commandFor(t, ctx.repoDir, api), slot = [];
57754
- 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 } : {} });
57755
- done.push(...slot);
57756
- publish();
57757
- return slot;
57758
- }, () => signal.aborted)).forEach((sl, i) => {
57759
- if (sl)
57760
- byName.set(testCheckName(l[i]), sl);
57761
- });
57762
- };
57763
- const goPart = (t) => goBatchable(t, targets0, changed);
57764
- await alone(list.filter((t) => !batchable(t) && !goPart(t)));
57765
- const goB = await runGoBatches(ctx, list.filter(goPart), api, signal, (c) => {
57766
- done.push(c);
57767
- publish();
57768
- });
57769
- for (const [n3, c] of goB)
57770
- byName.set(n3, [c]);
57771
- await alone(list.filter((t) => goPart(t) && !goB.has(testCheckName(t))));
57772
- for (const part of [list.filter((t) => batchable(t) && targets0.has(testCheckName(t))), list.filter((t) => batchable(t) && !targets0.has(testCheckName(t)))]) {
57773
- for (const [n3, c] of await runVitestBatches(ctx, part, api, signal, (c2) => {
57774
- done.push(c2);
57775
- publish();
57776
- }))
57777
- byName.set(n3, [c]);
57778
- }
57779
- await alone(list.filter((t) => batchable(t) && !byName.has(testCheckName(t))));
57780
- checks.push(...all.flatMap((t) => byName.get(testCheckName(t)) ?? []));
57781
- };
57782
- await runTests(split2.first);
57783
- const zgEnv = zeroGate(ctx.outputs().intake?.zero_baseline), envAsIntake = (rel) => {
57784
- if (zgEnv.sinceMs === undefined)
57785
- return false;
57786
- const root = api?.packageRootOf(rel) ?? ".";
57787
- return [...new Set([root, "."])].every((d) => !envChangedSince(ctx.repoDir, d === "." ? ctx.repoDir : join155(ctx.repoDir, d), zgEnv.sinceMs, zgEnv.ignored ?? null, zgEnv.deps));
57788
- };
57789
- const depsSeen = new Map, depsAsIntake = (rel) => {
57790
- if (zgEnv.sinceMs === undefined)
57791
- return false;
57792
- return [...new Set([api?.packageRootOf(rel) ?? ".", "."])].every((d) => {
57793
- if (!depsSeen.has(d))
57794
- depsSeen.set(d, !envChangedSince(ctx.repoDir, d === "." ? ctx.repoDir : join155(ctx.repoDir, d), zgEnv.sinceMs, [], zgEnv.deps));
57795
- return depsSeen.get(d);
57796
- });
57797
- };
57798
- const touchedRed = new Set(checks.filter((c) => {
57799
- const rel = c.name.slice(c.name.indexOf(":") + 1);
57800
- 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));
57801
- }).map((c) => c.name));
57802
- 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))));
57803
- if (!decisive)
57804
- await runTests(split2.rest);
57805
- const complete = !decisive;
57806
- 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]);
57807
- const settle2 = decisive && pg.some((x) => x.startsWith("full suite")) && same(failSigs(ctx.outputs().verify?.checks ?? []), failSigs(checks.filter((c) => !isHold(c))));
57808
- const hold = wall.holdout_dir ? stageHoldout(wall.holdout_dir, ctx.repoDir) : null;
57809
- if (hold && !hold.missing.length)
57810
- holdN = hold.tests.length;
58396
+ const bt = baseTree(ctx);
57811
58397
  try {
57812
- for (const [i, h] of (hold?.tests ?? []).entries()) {
57813
- if (signal.aborted)
57814
- break;
57815
- const t = h, tc = commandFor(t, ctx.repoDir, api);
57816
- 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 } : {} });
57817
- publish();
57818
- }
58398
+ return await runVerify(ctx, signal, bt);
57819
58399
  } finally {
57820
- hold?.cleanup();
58400
+ bt.dispose();
57821
58401
  }
57822
- if (hold?.missing.length) {
57823
- for (const m of hold.missing)
57824
- recordHoldoutTriage(ctx.runDir, { check: "holdout:store", result: "not_run", reason: m });
57825
- const k = { name: "holdout:store", cmd: "holdout", result: "not_run", duration_s: 0, reason: "holdout store unavailable", owner: "harness" };
57826
- checks.push(k);
57827
- ctx.emit("test.result", "verify", { ...pubHold(k) });
57828
- }
57829
- const targetNames = new Set([...[...wallTests, ...own].map(testCheckName), ...checks.filter(isHold).map((c) => c.name)]);
57830
- const cfgChanged = [...new Set([...testConfigChanged(ctx.repoDir, ctx.baseSha, changed), ...hiddenConfigChanged(ctx.repoDir, ctx.outputs().intake?.hidden_cfg)])];
57831
- 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)));
57832
- const symbols = checks.some((c) => c.result === "fail") ? diffSymbols(ctx, changed) : [];
57833
- 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);
57834
- for (const e of preRed.envCrash) {
57835
- const c = checks.find((x) => x.name === e.name && x.result === "fail");
57836
- if (c) {
57837
- c.result = "not_run";
57838
- c.reason = `${BCE_REASON} (${e.sig})`;
57839
- }
57840
- }
57841
- const fixRounds = Number(ctx.outputs().fix?.round ?? 0) || 0, collateralSame = preRed.sameError.filter((n3) => collateral.has(n3) && !preRed.names.includes(n3));
57842
- 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);
57843
- if (collateralBase.length) {
57844
- preRed.names.push(...collateralBase);
57845
- preRed.ids.push(...checks.filter((c) => collateralBase.includes(c.name)).flatMap((c) => c.ids ?? []));
57846
- }
57847
- const collateralRed = fixRounds >= 1 ? collateralSame.filter((n3) => !collateralBase.includes(n3)) : [];
57848
- if (collateralRed.length) {
57849
- preRed.names.push(...collateralRed);
57850
- preRed.ids.push(...checks.filter((c) => collateralRed.includes(c.name)).flatMap((c) => c.ids ?? []));
57851
- }
57852
- const touchedExcused = [...touchedRed].filter((n3) => !preRed.names.includes(n3) && checks.some((c) => c.name === n3 && c.result === "fail"));
57853
- if (touchedExcused.length) {
57854
- preRed.names.push(...touchedExcused);
57855
- preRed.ids.push(...checks.filter((c) => touchedExcused.includes(c.name)).flatMap((c) => c.ids ?? []));
57856
- }
57857
- const suiteOf = (name) => {
57858
- const t = tests.find((x) => testCheckName(x) === name), pkg = t ? api?.packageOf(t.path) : null;
57859
- return pkg?.commands.test ? `full suite: ${pkg.name}` : undefined;
57860
- };
57861
- 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" } : {} } : {} })));
57862
- attr.introducedChecks = [...new Set(attr.introducedChecks.map((n3) => isHoldoutCheck(n3) ? "holdout" : n3))];
57863
- preRed.names.push(...attr.preExistingChecks);
57864
- preRed.ids.push(...attr.preExistingIds);
57865
- const lintUntouchedNames = [];
57866
- if (!signal.aborted) {
57867
- const lintUntouched = lintUntouchedNames;
57868
- 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 });
57869
- preRed.names.push(...lintPre);
57870
- if (lintPre.length)
57871
- attr.line = [attr.line, `baseline: ${lintPre.join(", ")} static diagnostics already on base (not blocking)`].filter(Boolean).join("; ");
57872
- preRed.names.push(...lintUntouched);
57873
- if (lintUntouched.length)
57874
- attr.line = [attr.line, `${LINT_UNTOUCHED_NOTE}: ${lintUntouched.join(", ")}`].filter(Boolean).join("; ");
57875
- if (isLokiModeRepo(ctx.repoDir)) {
57876
- await runCheck(ctx, "select-tests", "bash", ["scripts/select-tests.sh", "--files", "-", "--run"], signal, checks, {
57877
- kind: "static",
57878
- stdin: changed.join(`
57879
- `) + `
57880
- `
57881
- });
57882
- }
57883
- }
57884
- const notExcused = [];
57885
- const fullNotProven = new Set;
57886
- const fullErr = new Map;
57887
- const ranDeeper = [];
57888
- const ntf = noTestFallbackOn() && risk?.tier === "low" && !checks.some((c) => !c.name.startsWith("lint:") && (c.result === "pass" || c.result === "fail"));
57889
- if (risk && (risk.tier !== "low" || ntf) && !signal.aborted && (complete || settle2)) {
57890
- const { runFullSuite: runFullSuite2 } = await Promise.resolve().then(() => (init_deep(), exports_deep));
57891
- const full = [];
57892
- 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);
57893
- for (const c of full) {
57894
- 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 } : {} } : {} };
57895
- suites.add(k);
57896
- checks.push(k);
57897
- ctx.emit("test.result", "verify", { ...k });
57898
- if (c.excerpt)
57899
- excerpts.set(k, c.excerpt);
57900
- }
57901
- for (const c of full)
57902
- if (c.errors)
57903
- fullErr.set(c.name, c.errors);
57904
- const blockedIds = checks.filter((c) => c.result === "fail" && !suites.has(c) && !preRed.names.includes(c.name)).flatMap((c) => c.ids ?? []);
57905
- 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);
57906
- preRed.names.push(...fa.preExistingChecks);
57907
- preRed.ids.push(...fa.preExistingIds);
57908
- attr.introducedChecks.push(...fa.introducedChecks);
57909
- attr.line = [attr.line, fa.line].filter(Boolean).join("; ") || null;
57910
- notExcused.push(...whyFullSuiteNotExcused(ctx.repoDir, ctx.baseSha, full, changed, fa.preExistingChecks, blockedIds, shown));
57911
- if (full.some((c) => c.result === "pass" || c.result === "fail")) {
57912
- ranDeeper.push("full test command", "full suite");
57913
- risk = markExecuted(risk, ranDeeper);
57914
- recordRisk(ctx.repoDir, risk);
57915
- }
57916
- const known = new Set(checks.filter((c) => c.result === "fail" && (preRed.sameError.includes(c.name) || wallNames0.has(c.name))).flatMap((c) => c.ids ?? []));
57917
- for (const c of full)
57918
- if (c.result === "fail" && c.ids?.length && !c.unhandled?.length && comparableIds(c.ids).every((i) => known.has(i)) && !preRed.names.includes(c.name)) {
57919
- preRed.knownRed.push(c.name);
57920
- preRed.sameError.push(c.name);
57921
- }
57922
- }
57923
- 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);
57924
- if (risk && risk.tier === "high" && !signal.aborted && complete) {
57925
- const { runSecretScan: runSecretScan2 } = await Promise.resolve().then(() => (init_deep(), exports_deep));
57926
- const sec = [];
57927
- await runSecretScan2(ctx, changed, { scanAddedSince: ctx.baseSha }, sec, fullNotProven);
57928
- for (const c of sec) {
57929
- 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 } : {} };
57930
- checks.push(k);
57931
- ctx.emit("test.result", "verify", { ...k });
57932
- }
57933
- if (sec.some((c) => c.result === "pass" || c.result === "fail")) {
57934
- ranDeeper.push(SECURITY_SCAN);
57935
- risk = markExecuted(risk, ranDeeper);
57936
- recordRisk(ctx.repoDir, risk);
57937
- }
57938
- }
57939
- 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])));
57940
- const uncoveredChanged = changed.filter((f) => CODE_FILE_EXT.test(f) && !isTestFile(f) && !wallPaths.has(f) && !cfgChanged.includes(f) && !covered(f));
57941
- const flaky = checks.filter((c) => c.result === "flaky").map((c) => isHold(c) ? "holdout" : c.name);
57942
- const indepNames = new Set([...wallNames0, ...[...changedTestFiles, ...impacted, ...own].map(testCheckName), ...attr.introducedChecks]);
57943
- const uncaused = uncausedOn() ? checks.filter((c) => feedsFixRound(c, preRed) && !indepNames.has(c.name) && uncausedRed(c, changed, symbols, excerpts.get(c) ?? "")).map((c) => c.name) : [];
57944
- const independentFail = checks.some((c) => c.result === "fail" && indepNames.has(c.name) && !preRed.names.includes(c.name));
57945
- 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);
57946
- 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;
57947
- const inBase = (f) => {
57948
- try {
57949
- safeGit(ctx.repoDir, ["cat-file", "-e", `${ctx.baseSha}:${f}`], { stdio: "ignore" });
57950
- return true;
57951
- } catch {
57952
- return false;
57953
- }
57954
- };
57955
- const testCounts = {};
57956
- const modifiedRel = relevant2.filter((t) => changed.includes(t.path) && inBase(t.path)).flatMap((t) => {
57957
- const k = preRed.cnt[testCheckName(t)];
57958
- if (k)
57959
- testCounts[t.path] = k;
57960
- 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) ?? []];
57961
- });
57962
- 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}`)];
57963
- const fullChecks = checks.filter((c) => c.name.startsWith("full suite")), fullSuiteRan = fullChecks.length > 0 && fullChecks.every((c) => c.result === "pass" || c.result === "fail");
57964
- const depsNotes = unusedInstallNotes(intake?.deps_not_proven ?? [], api, changed, checks.map((c) => c.name), ctx.repoDir);
57965
- 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"))];
57966
- const wallDropped = [...wallPaths].filter((p) => !wallTests.some((t) => t.path === p));
57967
- notProven2.push(...wallDropped.map((p) => `Wall test not executed: ${p}: ${NO_RUNNER_REASON}`));
57968
- 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;
57969
- await settleNrd(ctx);
57970
- if (touchedExcused.length)
57971
- attr.line = [attr.line, ...touchedExcused.map((n3) => `${TOUCHED_RED}: ${n3}`)].filter(Boolean).join("; ") || null;
57972
- 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 } };
57973
58402
  }
57974
58403
  };
57975
58404
  stage10 = verifyStage;
@@ -100863,7 +101292,7 @@ var init_python_build_check = __esm(() => {
100863
101292
  // ../../loki-ts/src/util/check_result.ts
100864
101293
  import { spawn as spawn13, spawnSync as spawnSync28 } from "child_process";
100865
101294
  import { createHash as createHash40 } from "crypto";
100866
- 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";
100867
101296
  import { homedir as homedir16, tmpdir as tmpdir34 } from "os";
100868
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";
100869
101298
  function plainTestEnv(base2 = process.env) {
@@ -101275,7 +101704,7 @@ function cargoRunnerConfigured(cwd, env, toks2) {
101275
101704
  if (CARGO_REDIRECT_TEXT(v10))
101276
101705
  return true;
101277
101706
  const f = resolve44(cwd, v10);
101278
- if (existsSync117(f) && lstatSync35(f).isFile() && doubtful(f))
101707
+ if (existsSync117(f) && lstatSync36(f).isFile() && doubtful(f))
101279
101708
  return true;
101280
101709
  }
101281
101710
  const dirs = [env["CARGO_HOME"] ?? join164(env["HOME"] ?? homedir16(), ".cargo"), join164(homedir16(), ".cargo")];
@@ -101472,7 +101901,7 @@ function cargoRepoCompilerRedirected(cwd, env, toks2) {
101472
101901
  if (inline)
101473
101902
  return cargoCompilerReason(inline, "--config");
101474
101903
  const f = resolve44(cwd, v10);
101475
- if (existsSync117(f) && lstatSync35(f).isFile()) {
101904
+ if (existsSync117(f) && lstatSync36(f).isFile()) {
101476
101905
  const w = inFile(f);
101477
101906
  if (w)
101478
101907
  return cargoCompilerReason(w, v10);
@@ -101920,10 +102349,12 @@ function changedSymbols(diffU0, readNew) {
101920
102349
  flush();
101921
102350
  return [...out3];
101922
102351
  }
101923
- function failureShape(out3) {
101924
- const norm5 = out3.split(`
102352
+ function failureLines(out3) {
102353
+ return out3.split(`
101925
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 !== "");
101926
- return createHash40("sha256").update(norm5.join(`
102355
+ }
102356
+ function failureShape(out3) {
102357
+ return createHash40("sha256").update(failureLines(out3).join(`
101927
102358
  `)).digest("hex");
101928
102359
  }
101929
102360
  function enclosingDecl(lines3, at2) {
@@ -102312,7 +102743,7 @@ function wallPathProblem(repoDir, relPath) {
102312
102743
  for (const part of dirname71(rel) === "." ? [] : dirname71(rel).split(sep27)) {
102313
102744
  cur = join164(cur, part);
102314
102745
  try {
102315
- const st2 = lstatSync35(cur);
102746
+ const st2 = lstatSync36(cur);
102316
102747
  if (st2.isSymbolicLink() || !st2.isDirectory())
102317
102748
  return `Wall path crosses a symlink or non-directory: ${relPath}`;
102318
102749
  } catch {
@@ -102320,7 +102751,7 @@ function wallPathProblem(repoDir, relPath) {
102320
102751
  }
102321
102752
  }
102322
102753
  try {
102323
- 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;
102324
102755
  } catch {
102325
102756
  return null;
102326
102757
  }
@@ -102372,7 +102803,7 @@ function changedFiles(repoDir, baseSha, skip2) {
102372
102803
  return [...new Set([...tracked, ...untracked3])].filter((f) => !f.startsWith(".loki/") && !skip2?.(f));
102373
102804
  }
102374
102805
  function sha256File2(abs) {
102375
- const st2 = lstatSync35(abs);
102806
+ const st2 = lstatSync36(abs);
102376
102807
  return st2.isSymbolicLink() ? `link:${readlinkSync10(abs)}` : st2.size > 4000000 ? `big:${st2.size}` : createHash40("sha256").update(readFileSync149(abs)).digest("hex");
102377
102808
  }
102378
102809
  function fileHashes(repoDir, files) {
@@ -103249,7 +103680,22 @@ function toolFallbacks(repoDir, tool, env = process.env) {
103249
103680
  }
103250
103681
  return out3;
103251
103682
  }
103252
- 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) {
103253
103699
  const inRepo2 = (p) => {
103254
103700
  try {
103255
103701
  const r = relative36(realpathSync48(repoDir), realpathSync48(p));
@@ -103260,6 +103706,11 @@ function resolveTool(repoDir, bin, fallback, lastResort = fallback) {
103260
103706
  };
103261
103707
  const venvEnv = process.env["VIRTUAL_ENV"], onPath2 = (b) => Bun.which(b, { PATH: process.env["PATH"] ?? "" });
103262
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
+ }
103263
103714
  return project ? [project, "project", []] : existsSync117(join164(repoDir, "uv.lock")) && onPath2("uv") ? ["uv", "project", ["run", "--", bin]] : [onPath2(fallback) ? fallback : lastResort, "system", []];
103264
103715
  }
103265
103716
  function goTestNames(file) {
@@ -103275,7 +103726,7 @@ function runnerCmd(t, repoDir) {
103275
103726
  return ["bash", ["-c", own]];
103276
103727
  switch (t.runner) {
103277
103728
  case "pytest": {
103278
- const [cmd2, interpreter, pre2] = resolveTool(repoDir, "python", "python3", "python");
103729
+ const [cmd2, interpreter, pre2] = resolveTool(repoDir, "python", "python3", "python", "pytest");
103279
103730
  return [cmd2, [...pre2, "-m", "pytest", "-q", t.path], interpreter];
103280
103731
  }
103281
103732
  case "unittest": {
@@ -103330,7 +103781,7 @@ function fullSuiteCmd(runner, repoDir) {
103330
103781
  return dotnetFullCmd(repoDir);
103331
103782
  if (runner !== "pytest" && runner !== "unittest")
103332
103783
  return FULL_SUITE_STATIC[runner];
103333
- const [cmd2, interpreter, pre2] = resolveTool(repoDir, "python", "python3", "python");
103784
+ const [cmd2, interpreter, pre2] = resolveTool(repoDir, "python", "python3", "python", runner === "pytest" ? "pytest" : undefined);
103334
103785
  return { cmd: cmd2, args: [...pre2, ...runner === "unittest" ? UNITTEST_DISCOVER_ARGS : ["-m", "pytest", "-q"]], ...runner === "unittest" && interpreter === "system" ? {} : { interpreter } };
103335
103786
  }
103336
103787
  function ownVitestSite(repoDir, path) {
@@ -103560,7 +104011,7 @@ Go: your test files are copied into ${relative36(repoDir, targetDir) || "the rep
103560
104011
  return m !== null && varNamesTool(tool, m[1]) && (wordIsTool(tool, m[2]) || varIsTool(tool, m[2]));
103561
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) => {
103562
104013
  try {
103563
- lstatSync35(f);
104014
+ lstatSync36(f);
103564
104015
  return true;
103565
104016
  } catch {
103566
104017
  return false;
@@ -103625,7 +104076,7 @@ const done = (code, sig) => { if (fin) return; fin = true; kill("SIGKILL"); try
103625
104076
  setTimeout(() => { to = true; kill("SIGTERM"); setTimeout(() => done(null, 1), 1000); }, ms);
103626
104077
  const over = () => { if (out.length > MAX || err.length > MAX) { to = true; kill("SIGKILL"); } };
103627
104078
  c.stdout.on("data", (d) => { out += d; over(); }); c.stderr.on("data", (d) => { err += d; over(); });
103628
- 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;
103629
104080
  var init_check_result = __esm(() => {
103630
104081
  init_stack_tools();
103631
104082
  init_dotnet_test();
@@ -103754,6 +104205,8 @@ var init_check_result = __esm(() => {
103754
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)/;
103755
104206
  JS_ASSERTED = /\bAssertionError\b|\bERR_ASSERTION\b|\bexpect\((?:received|value)\)\.\w+/;
103756
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;
103757
104210
  FULL_SUITE_STATIC = {
103758
104211
  vitest: { cmd: "npx", args: ["vitest", "run"] },
103759
104212
  jest: { cmd: "npx", args: ["jest"] },
@@ -127885,7 +128338,7 @@ __export(exports_run_outputs, {
127885
128338
  });
127886
128339
  import { execFile as execFile3, spawnSync as spawnSync29 } from "child_process";
127887
128340
  import { createHash as createHash42 } from "crypto";
127888
- 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";
127889
128342
  import { basename as basename49, join as join169, resolve as resolve46 } from "path";
127890
128343
  function intentRevisionsBlock(revs) {
127891
128344
  const r = (revs ?? []).filter((r10) => r10.unapplied !== true).map(({ rev, source, actor, sha: sha6 }) => ({ rev, source, actor, sha: sha6 }));
@@ -128363,7 +128816,7 @@ async function signedReceiptFacts(runDir, runId2, events2) {
128363
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));
128364
128817
  for (const f of [file, join169(runDir, "events.jsonl")]) {
128365
128818
  try {
128366
- if (lstatSync36(f).isSymbolicLink())
128819
+ if (lstatSync37(f).isSymbolicLink())
128367
128820
  return { problem: `${basename49(f)} is a symlink; a run's own files are never links` };
128368
128821
  } catch {}
128369
128822
  }
@@ -128539,7 +128992,7 @@ function discardRun(repoDir, runId2) {
128539
128992
  return false;
128540
128993
  const dir = join169(repoDir, ".loki", "runs", runId2);
128541
128994
  try {
128542
- if (!lstatSync36(dir).isDirectory())
128995
+ if (!lstatSync37(dir).isDirectory())
128543
128996
  return false;
128544
128997
  writeFileSync90(join169(dir, DISCARD_MARK), `${new Date().toISOString()}
128545
128998
  `, { flag: "wx" });