loki-mode 11.126.1 → 11.128.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/environment-variables.md +2 -0
  7. package/loki-ts/dist/loki.js +1514 -1506
  8. package/mcp/__init__.py +1 -1
  9. package/package.json +2 -2
  10. package/packages/control-plane/dist/server.js +511 -133
  11. package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
  12. package/web-app/dist/assets/{AdminPage-DL1Y4kX0.js → AdminPage-DF4k0ysx.js} +1 -1
  13. package/web-app/dist/assets/{Avatar-DzrZ8jmw.js → Avatar-C-uwJexT.js} +1 -1
  14. package/web-app/dist/assets/{Badge-D_Qt4KgD.js → Badge-CFwXAvwp.js} +1 -1
  15. package/web-app/dist/assets/{Button-Dw9WbGQh.js → Button-CKs00rxd.js} +1 -1
  16. package/web-app/dist/assets/{CockpitPage-CpViUB1T.js → CockpitPage-DXQ6K0Uv.js} +1 -1
  17. package/web-app/dist/assets/{ComparePage-CKB6UA4C.js → ComparePage-CV1WdrxH.js} +1 -1
  18. package/web-app/dist/assets/{ErrorBoundary-BWBsYZuA.js → ErrorBoundary-BoNQlXN0.js} +1 -1
  19. package/web-app/dist/assets/{EvidenceReceiptPanel-iqhmIDIs.js → EvidenceReceiptPanel-BoPcm5Uy.js} +1 -1
  20. package/web-app/dist/assets/{GitHubIssuesPanel-DHpYnJ-y.js → GitHubIssuesPanel-Bv7T8Ie3.js} +1 -1
  21. package/web-app/dist/assets/{GitHubPRsPanel-FPYdU-uS.js → GitHubPRsPanel-D3otxDyX.js} +1 -1
  22. package/web-app/dist/assets/{HomePage-vL0m88t1.js → HomePage-DBFbNHTs.js} +2 -2
  23. package/web-app/dist/assets/{LoginPage-D8kG1Aps.js → LoginPage-CoSICpxe.js} +1 -1
  24. package/web-app/dist/assets/{MagicPage-LDg-xZZC.js → MagicPage-DkwWlmRA.js} +1 -1
  25. package/web-app/dist/assets/{MetricsPage-CH9ixfvN.js → MetricsPage-CExS9EXg.js} +1 -1
  26. package/web-app/dist/assets/{NotFoundPage-Cf9DjzK9.js → NotFoundPage-Bgfe2qnY.js} +1 -1
  27. package/web-app/dist/assets/{ProjectPage-CK6KCUTI.js → ProjectPage-BhCjP5SY.js} +3 -3
  28. package/web-app/dist/assets/{ProjectsPage-BOrtyYc1.js → ProjectsPage-BzdHMSEl.js} +1 -1
  29. package/web-app/dist/assets/{SettingsPage-BeibJbPE.js → SettingsPage-7cayqMSq.js} +1 -1
  30. package/web-app/dist/assets/{ShowcasePage-CVe1odCt.js → ShowcasePage-wUCln7dW.js} +1 -1
  31. package/web-app/dist/assets/{SystemSettingsPage-BgnIj59m.js → SystemSettingsPage-DBwjF02W.js} +1 -1
  32. package/web-app/dist/assets/{TeamsPage-BewuiJMq.js → TeamsPage-Bdw_T_6h.js} +1 -1
  33. package/web-app/dist/assets/{TemplatesPage-DswtNB8r.js → TemplatesPage-nu1f2803.js} +1 -1
  34. package/web-app/dist/assets/{TerminalOutput-BNh-8SZV.js → TerminalOutput-CLmpIK4L.js} +1 -1
  35. package/web-app/dist/assets/{activity-CFXgAoCB.js → activity-BXMGKZvU.js} +1 -1
  36. package/web-app/dist/assets/{bell-COD1_24d.js → bell-JNPwlzvO.js} +1 -1
  37. package/web-app/dist/assets/{bot--XZuncsH.js → bot-Sk6fR1wH.js} +1 -1
  38. package/web-app/dist/assets/{check-CSbmOvH8.js → check-Ma-sojpE.js} +1 -1
  39. package/web-app/dist/assets/{chevron-left-srDoUMmw.js → chevron-left-CrcDqrVe.js} +1 -1
  40. package/web-app/dist/assets/{circle-alert-44p3-rn-.js → circle-alert-Cwr65c2e.js} +1 -1
  41. package/web-app/dist/assets/{clock-B4wWvmn8.js → clock-C-5tIG8f.js} +1 -1
  42. package/web-app/dist/assets/{cloud-jCJzGUo3.js → cloud-Db03agpM.js} +1 -1
  43. package/web-app/dist/assets/{code-xml-gsEEhpyx.js → code-xml-Cx0hm4Iq.js} +1 -1
  44. package/web-app/dist/assets/{database-BlsMlX5t.js → database-CfRhE_ZA.js} +1 -1
  45. package/web-app/dist/assets/{dollar-sign--S4tx00t.js → dollar-sign-DTUegk3W.js} +1 -1
  46. package/web-app/dist/assets/{file-code-corner-CmAkbkRm.js → file-code-corner-XuxF-CrX.js} +1 -1
  47. package/web-app/dist/assets/{file-plus-izkG40Mr.js → file-plus-BbMAmihn.js} +1 -1
  48. package/web-app/dist/assets/{globe-DW7kjaBE.js → globe-CpidIbDl.js} +1 -1
  49. package/web-app/dist/assets/{hammer-Ch1qtGCT.js → hammer-DY_Kpy42.js} +1 -1
  50. package/web-app/dist/assets/{index-znyrPGmf.js → index-D9BKjMuU.js} +3 -3
  51. package/web-app/dist/assets/{layers-CCfYtl8A.js → layers-KfTHlTb8.js} +1 -1
  52. package/web-app/dist/assets/{loader-circle-DZRaw300.js → loader-circle-BPaci-XO.js} +1 -1
  53. package/web-app/dist/assets/{lock-BYgUYM1q.js → lock-CvsetYwc.js} +1 -1
  54. package/web-app/dist/assets/{package-DALzp01h.js → package-B64hIjyi.js} +1 -1
  55. package/web-app/dist/assets/{plus-BNTTZF4m.js → plus-CR-XFuXp.js} +1 -1
  56. package/web-app/dist/assets/{refresh-cw-DJyC0T4Q.js → refresh-cw-CF5cvVRx.js} +1 -1
  57. package/web-app/dist/assets/{rotate-ccw-DKg0jwCg.js → rotate-ccw-LtJcHjJa.js} +1 -1
  58. package/web-app/dist/assets/{scroll-text-D6Creg_c.js → scroll-text-CeHSJV7U.js} +1 -1
  59. package/web-app/dist/assets/{server-DTwXqYo5.js → server-CENdgPIr.js} +1 -1
  60. package/web-app/dist/assets/{shield-alert-CqjVo8Iy.js → shield-alert-BBEtOHZe.js} +1 -1
  61. package/web-app/dist/assets/{thumbs-up-CX5fPcNB.js → thumbs-up-CT4JNEH-.js} +1 -1
  62. package/web-app/dist/assets/{trash-2-setTym8u.js → trash-2-BbdDz5UF.js} +1 -1
  63. package/web-app/dist/assets/{trending-down-DyPkOiAD.js → trending-down-BJQbwZ0K.js} +1 -1
  64. package/web-app/dist/assets/{trending-up-gIjxA5wm.js → trending-up-CcyzNaYn.js} +1 -1
  65. package/web-app/dist/assets/{upload-DIlS1XVV.js → upload-MSdRT33n.js} +1 -1
  66. package/web-app/dist/assets/{usePolling-DXJiMkzR.js → usePolling-BdUBXq9n.js} +1 -1
  67. package/web-app/dist/assets/{user-CD2UF5MI.js → user-CaCotRD9.js} +1 -1
  68. package/web-app/dist/index.html +1 -1
@@ -11880,7 +11880,7 @@ function pySpans(src) {
11880
11880
  if (!m)
11881
11881
  continue;
11882
11882
  const indent = m[1].length;
11883
- while (stack.length && stack[stack.length - 1].indent >= indent)
11883
+ while (stack.length && (stack[stack.length - 1].indent >= indent || stack[stack.length - 1].span.end < k + 1))
11884
11884
  stack.pop();
11885
11885
  let end = k, depth = 0;
11886
11886
  for (let j = k;j < lines.length; j++) {
@@ -13358,6 +13358,97 @@ function failIds(raw2) {
13358
13358
  const c = failCount(output);
13359
13359
  return c && ids.length >= c ? ids : [];
13360
13360
  }
13361
+ function normError(line2) {
13362
+ const root = "(?:Users|private|var|tmp|home|opt|Volumes|mnt|root|workspace)", file = "[\\w.@-]+\\.(?:[cm]?[jt]sx?|json|py|go|rs|java|kt|cs|rb|php|vue|svelte|mdx?|ya?ml|toml|css|scss|html)(?![\\w])";
13363
+ const absPath = new RegExp(`(?<![\\w.@/-])/(?:${root}/(?:[\\w.@+-]+/)*[\\w.@+-]+|(?:[\\w.@+-]+/)*${file})(?::\\d+){0,2}`, "g"), rootPath = new RegExp(`(?<![\\w.@/-])/${root}/(?:[\\w.@+-]+/)*[\\w.@+-]+(?::\\d+){0,2}`, "g");
13364
+ const outside = (t) => t.replace(/\b\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?/g, "<ts>").replace(absPath, "<path>").replace(/\s\d+(?:\.\d+)?\s?ms\)?$/, " <dur>");
13365
+ return line2.split(/('[^']*'|"[^"]*"|`[^`]*`)/).map((part, n3) => n3 % 2 === 0 ? outside(part) : part.replace(rootPath, "<path>")).join("").replace(/\s+/g, " ").trim();
13366
+ }
13367
+ function errorsById(out2) {
13368
+ const norm2 = (l) => normError(l);
13369
+ const lines = stripAnsi(out2).split(`
13370
+ `).map((l) => l.trim()), m = new Map, add3 = (id, e) => {
13371
+ m.set(id, [...m.get(id) ?? [], e]);
13372
+ };
13373
+ const bun = lines.some((l) => /^Ran \d+ tests? across \d+ files?\./.test(l));
13374
+ let file = "", err = [];
13375
+ for (const [i, l] of lines.entries()) {
13376
+ if (bun) {
13377
+ const f = /^([\w./@-]+\.[cm]?[jt]sx?):$/.exec(l), m2 = /^(?:\(fail\)|\u2717)\s+(.+?)(?:\s+\[[\d.]+m?s\])?$/.exec(l);
13378
+ if (f) {
13379
+ file = f[1];
13380
+ err = [];
13381
+ } else if (/^error:/.test(l))
13382
+ err = [l];
13383
+ else if (err.length && /^(?:Expected|Received)\b/.test(l))
13384
+ err.push(l);
13385
+ else if (m2) {
13386
+ if (err.length)
13387
+ add3(`${file}::${m2[1].trim()}`, norm2(err.join(" | ")));
13388
+ err = [];
13389
+ } else if (/^\((?:pass|skip|todo)\)|^\u2713/.test(l))
13390
+ err = [];
13391
+ continue;
13392
+ }
13393
+ const py = /^FAILED (\S+::\S*) - (.+)$/.exec(l);
13394
+ if (py) {
13395
+ add3(py[1], norm2(py[2]));
13396
+ continue;
13397
+ }
13398
+ const g = /^(?:\u25cf\s+(?!Console|Test suite failed)(.+)|not ok \d+ - (.+?)(?:\s+#.*)?|\u2716\s+(?!failing tests:)(.+?)(?:\s+\([\d.]+ms\))?)$/.exec(l);
13399
+ if (g) {
13400
+ let e = "(no diagnostics)";
13401
+ for (const x of lines.slice(i + 1)) {
13402
+ if (x === "" || x === "---")
13403
+ continue;
13404
+ if (/^(?:not ok|ok) \d+|^\u25cf|^\u2716|^\u2714|^1\.\.\d+|^#/.test(x))
13405
+ break;
13406
+ e = x.replace(/^message:\s*/, "");
13407
+ break;
13408
+ }
13409
+ add3((g[1] ?? g[2] ?? g[3]).trim(), norm2(e));
13410
+ continue;
13411
+ }
13412
+ const v = /^FAIL\s+(.+)$/.exec(l);
13413
+ if (!v)
13414
+ continue;
13415
+ const next = lines.slice(i + 1).find((x) => x !== "" && !/^FAIL\s/.test(x));
13416
+ if (next !== undefined)
13417
+ add3(v[1].trim(), norm2(next));
13418
+ }
13419
+ for (const [k, e] of m)
13420
+ m.set(k, e.sort());
13421
+ return m;
13422
+ }
13423
+ function unhandledBlock(out2) {
13424
+ const lines = stripAnsi(out2).split(`
13425
+ `).map((l) => l.trim()), res = [];
13426
+ for (const [i, l] of lines.entries()) {
13427
+ if (/^[\u23af\-=\s]*Unhandled (?:Errors?|Rejections?|Exceptions?)\b/i.test(l) || /\bunhandled (?:promise )?(?:errors?|rejections?)\b/i.test(l) || /^Errors\s+\d+ errors?\b/.test(l)) {
13428
+ res.push(normError(l.replace(/^[\u23af\-=\s]+|[\u23af\-=\s]+$/g, "")));
13429
+ if (/Unhandled (?:Rejection|Exception|Error)\b/i.test(l) || /Unhandled (?:Errors?|Rejections?)\b/.test(l))
13430
+ for (const x of lines.slice(i + 1, i + 6)) {
13431
+ if (x === "" || /^[\u23af\-=]{3,}/.test(x))
13432
+ break;
13433
+ res.push(normError(x));
13434
+ }
13435
+ }
13436
+ }
13437
+ return [...new Set(res)].sort();
13438
+ }
13439
+ function sameErrors(head, base, ids) {
13440
+ const asMap = (x) => typeof x === "string" ? errorsById(x) : x instanceof Map ? x : new Map(Object.entries(x));
13441
+ const h = asMap(head), b = asMap(base), all = ids ?? [], eq2 = (x = [], y = []) => x.length === y.length && x.every((e, n3) => e === y[n3]);
13442
+ const keys = (i) => h.has(i) ? [i] : [...h.keys()].filter((k) => k.endsWith(` > ${i}`));
13443
+ return all.length > 0 && all.every((i) => {
13444
+ const ks = keys(i);
13445
+ return ks.length > 0 && ks.every((k) => eq2(b.get(k), h.get(k)));
13446
+ });
13447
+ }
13448
+ function comparableIds(ids) {
13449
+ const full = ids.filter((i) => /^[^>]*\.[cm]?[jt]sx? > /.test(i));
13450
+ return full.length ? full : [...ids];
13451
+ }
13361
13452
  var ID_LINE;
13362
13453
  var init_failures = __esm(() => {
13363
13454
  init_check_result();
@@ -13762,7 +13853,7 @@ function runOnce(repoDir, cmd, cwd, tmo, opts) {
13762
13853
  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;
13763
13854
  const attributable = !r.timedOut && !missing && r.code !== null && (r.code === 0 || ids.length > 0);
13764
13855
  const reason = attributable ? undefined : r.timedOut ? "timed out" : missing ? "command not found" : "failing test ids not parseable, failures cannot be attributed";
13765
- return { b: { ran: true, command: cmd, exit_code: r.code, duration_s: dur, timed_out: r.timedOut, failing_ids: ids, attributable, ...reason ? { reason } : {}, zero_tests: r.code === 0 && emptyDiscovery(classifyCheck({ kind: "test", ok: true, out: r.out, ...goRunner(cmd) }), r.out) }, missing };
13856
+ return { b: { ran: true, command: cmd, exit_code: r.code, duration_s: dur, timed_out: r.timedOut, failing_ids: ids, attributable, ...reason ? { reason } : {}, ...ids.length ? { failing_errors: Object.fromEntries(errorsById(r.out)) } : {}, ...unhandledBlock(r.out).length ? { failing_unhandled: unhandledBlock(r.out) } : {}, zero_tests: r.code === 0 && emptyDiscovery(classifyCheck({ kind: "test", ok: true, out: r.out, ...goRunner(cmd) }), r.out) }, missing };
13766
13857
  }
13767
13858
  function runBaseline(repoDir, commands, opts = {}) {
13768
13859
  const t = commands.find((c) => c.kind === "test");
@@ -13790,7 +13881,7 @@ function baselineSuites(repoDir, specs, opts = {}) {
13790
13881
  const old = p.suites ?? [];
13791
13882
  p.suites = specs.filter((s) => s.cwd !== "." || normCmd(s.run) !== normCmd(p.baseline.command ?? "")).map((s) => {
13792
13883
  const prev = old.find((o) => o.command === s.cmd);
13793
- if (prev?.ran && !opts.rerun)
13884
+ if (prev?.ran && !opts.rerun && (prev.failing_ids.length === 0 || prev.failing_errors))
13794
13885
  return prev;
13795
13886
  const tmo = Math.min(opts.timeoutS ?? DEFAULT_TIMEOUT_S, Math.floor(left)), t0 = Date.now();
13796
13887
  if (tmo < 1)
@@ -13830,7 +13921,7 @@ function save(repoDir, p) {
13830
13921
  function ensureProfile(repoDir, opts = {}) {
13831
13922
  try {
13832
13923
  const hash = manifestHash(repoDir), rev = headOf(repoDir), old = loadProfile(repoDir);
13833
- if (old && old.manifest_hash === hash && old.revision === rev)
13924
+ if (old && old.manifest_hash === hash && old.revision === rev && (old.baseline.failing_ids.length === 0 || old.baseline.failing_errors))
13834
13925
  return { profile: old, reused: true };
13835
13926
  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);
13836
13927
  const profile = { version: 1, revision: rev, manifest_hash: hash, created_at: (opts.now?.() ?? new Date).toISOString(), commands, baseline: runBaseline(repoDir, commands, opts) };
@@ -13842,14 +13933,20 @@ function ensureProfile(repoDir, opts = {}) {
13842
13933
  }
13843
13934
  function attribute(repoDir, baseSha, failing) {
13844
13935
  const p = loadProfile(repoDir), none = { preExistingChecks: [], preExistingIds: [], introducedChecks: failing.map((f) => f.name), line: null };
13845
- if (!p || p.revision !== baseSha || !p.baseline.attributable || p.baseline.failing_ids.length === 0 || failing.length === 0)
13936
+ if (!p || p.revision !== baseSha || failing.length === 0)
13846
13937
  return none;
13847
- const base = new Set(p.baseline.failing_ids);
13848
- return split(failing.map((f) => ({ ...f, base })), base.size);
13938
+ const root = p.baseline.attributable ? p.baseline.failing_ids : [], own = (name) => {
13939
+ const s = name ? p.suites?.find((x) => x.name === name && x.ran && x.attributable) : undefined;
13940
+ return s ? s.failing_ids : root;
13941
+ };
13942
+ const rows = failing.map((f) => ({ ...f, base: new Set(own(f.suite)) })), known = new Set(rows.flatMap((r) => [...r.base]));
13943
+ if (known.size === 0)
13944
+ return none;
13945
+ return split(rows, known.size);
13849
13946
  }
13850
13947
  function split(failing, known) {
13851
13948
  const unparsed = failing.filter((f) => !f.ids?.length && f.base.size > 0).length;
13852
- const pre = failing.filter((f) => f.eligible && f.ids?.length && f.ids.every((i) => f.base.has(i)));
13949
+ const pre = failing.filter((f) => f.eligible && f.ids?.length && comparableIds(f.ids).every((i) => f.base.has(i)));
13853
13950
  const introduced = failing.filter((f) => !pre.includes(f)).map((f) => f.name);
13854
13951
  if (pre.length === 0)
13855
13952
  return { preExistingChecks: [], preExistingIds: [], introducedChecks: introduced, line: `baseline: ${known} known failure(s) before this run; ${unparsed ? `head failure ids unparseable for ${unparsed} failing check(s), cannot compare` : "none of the failing checks match them"}, ${introduced.length} introduced (blocking)` };
@@ -13920,11 +14017,14 @@ function attributeFullSuite(repoDir, baseSha, full, blocked, changed) {
13920
14017
  }, miss = bad.find((c) => !of(c.cmd));
13921
14018
  if (miss)
13922
14019
  return { ...none, line: `baseline: ran ${runs2.map((b) => `"${b.command}"`).join(", ") || "nothing"}, not the full suite command "${miss.cmd}", ids not comparable, full suite failures not excused` };
13923
- const known = new Set(bad.flatMap((c) => ids(c.cmd))), block = new Set(blocked);
14020
+ const known = new Set(bad.flatMap((c) => ids(c.cmd))), block = new Set(blocked), sameAsBase = (c) => {
14021
+ const b = of(c.cmd), be = b?.failing_errors, hu = c.unhandled ?? [], bu = b?.failing_unhandled ?? [];
14022
+ return !!be && !!c.errors && hu.length === bu.length && hu.every((x, n3) => x === bu[n3]) && sameErrors(new Map(Object.entries(c.errors)), be, comparableIds(c.ids ?? []));
14023
+ };
13924
14024
  if (known.size === 0)
13925
14025
  return none;
13926
14026
  const unproven = [...new Set(bad.flatMap((c) => c.ids ?? []).filter((i) => !i.includes("::") && goIdTouched(repoDir, i, changed)))];
13927
- const res = split(bad.map((c) => ({ name: c.name, ...c.ids ? { ids: c.ids } : {}, eligible: !cargoTouched(changed) && (c.ids ?? []).every((i) => !block.has(i) && !changed.some((f) => i.includes(f)) && !goIdTouched(repoDir, i, changed)), base: new Set(ids(c.cmd)) })), known.size);
14027
+ const res = split(bad.map((c) => ({ name: c.name, ...c.ids ? { ids: c.ids } : {}, eligible: !cargoTouched(changed) && sameAsBase(c) && (c.ids ?? []).every((i) => !block.has(i) && !changed.some((f) => i.includes(f)) && !goIdTouched(repoDir, i, changed)), base: new Set(ids(c.cmd)) })), known.size);
13928
14028
  const rust = (cargoTouched(changed) ? bad : []).map((c) => `NOT PROVEN: ${c.name} may run cargo tests and the diff edits Rust source or a manifest; cargo test ids carry no crate path, so a failure cannot be shown pre-existing`);
13929
14029
  if (!unproven.length && !rust.length)
13930
14030
  return res;
@@ -15155,6 +15255,14 @@ function buildTestMap(root) {
15155
15255
  }
15156
15256
  }
15157
15257
  const sourceRefs = Object.create(null);
15258
+ const goMods = files.filter((f) => basename14(f) === "go.mod").map((f) => ({ dir: dirname15(f), path: /^module\s+(\S+)/m.exec(readText(join50(root, f)))?.[1] })).filter((m) => !!m.path).sort((a, b) => b.path.length - a.path.length);
15259
+ const goImportDir = (imp) => {
15260
+ const m = goMods.find((x) => imp === x.path || imp.startsWith(`${x.path}/`));
15261
+ if (!m)
15262
+ return null;
15263
+ const rel = join50(m.dir, imp.slice(m.path.length + 1));
15264
+ return rel === "" ? "." : rel;
15265
+ };
15158
15266
  const specs = Object.create(null);
15159
15267
  for (const t of tests) {
15160
15268
  const text3 = jsText.get(t.path) ?? readText(join50(root, t.path));
@@ -15164,6 +15272,12 @@ function buildTestMap(root) {
15164
15272
  if (/\.(?:java|cs)$/.test(t.path))
15165
15273
  for (const w of pascalWords(text3))
15166
15274
  names.add(w);
15275
+ if (t.runner === "go")
15276
+ for (const m of text3.matchAll(/"([\w.\-~]+(?:\/[\w.\-~]+)*)"/g)) {
15277
+ const d = goImportDir(m[1]);
15278
+ if (d !== null)
15279
+ names.add(`godir:${d}`);
15280
+ }
15167
15281
  for (const n3 of names) {
15168
15282
  (sourceRefs[n3] ??= []).push(t.path);
15169
15283
  }
@@ -15201,6 +15315,13 @@ function impactedRefs(map, changedFiles) {
15201
15315
  for (const s of stems)
15202
15316
  for (const p of sourceRefs[s] ?? [])
15203
15317
  add3(map.tests.find((t) => t.path === p));
15318
+ if (extname2(rel) === ".go") {
15319
+ for (const t of map.tests)
15320
+ if (t.runner === "go" && dirname15(t.path) === dirname15(rel))
15321
+ add3(t);
15322
+ for (const p of sourceRefs[`godir:${dirname15(rel)}`] ?? [])
15323
+ add3(map.tests.find((t) => t.path === p));
15324
+ }
15204
15325
  }
15205
15326
  return scopeRefs(map, changedFiles.map(normalizeRel), out2);
15206
15327
  }
@@ -16479,20 +16600,49 @@ function* corroborateGoSteps(c, out2, cmdOrLine, args, toks, o) {
16479
16600
  };
16480
16601
  try {
16481
16602
  const want = new Set(names.map((n3) => n3.slice(0, n3.indexOf("::")))), expected = new Set;
16482
- const ls2 = yield ["go", ["list", "-json=ImportPath,Dir,GoFiles,CgoFiles", ...where], spawnOpts];
16483
- if (ls2.status !== 0)
16603
+ const listed = (out3) => {
16604
+ const r2 = [];
16605
+ for (const chunk of out3.split(/\n(?=\{\n)/)) {
16606
+ try {
16607
+ r2.push(JSON.parse(chunk));
16608
+ } catch {
16609
+ return null;
16610
+ }
16611
+ }
16612
+ return r2;
16613
+ };
16614
+ const ls2 = yield ["go", ["list", "-json=ImportPath,Dir,GoFiles,CgoFiles,TestImports,XTestImports", ...where], spawnOpts];
16615
+ const top = ls2.status === 0 ? listed(ls2.output) : null;
16616
+ if (!top)
16484
16617
  return refuse;
16485
- const perPkg = new Map;
16486
- for (const chunk of ls2.output.split(/\n(?=\{\n)/)) {
16487
- let pk;
16488
- try {
16489
- pk = JSON.parse(chunk);
16490
- } catch {
16491
- return refuse;
16618
+ const cover = new Map, testOnly = [], ownImports = [];
16619
+ for (const pk of top)
16620
+ if (pk.ImportPath && want.has(pk.ImportPath)) {
16621
+ if (pk.GoFiles?.length)
16622
+ cover.set(pk.ImportPath, pk);
16623
+ else {
16624
+ const imps = [...pk.TestImports ?? [], ...pk.XTestImports ?? []];
16625
+ testOnly.push(...imps);
16626
+ ownImports.push(imps);
16627
+ }
16492
16628
  }
16493
- if (!pk.ImportPath || !want.has(pk.ImportPath))
16494
- continue;
16495
- if (!pk.Dir || !pk.GoFiles?.length || pk.CgoFiles?.length)
16629
+ const viaImports = [...new Set(testOnly)].filter((i) => !cover.has(i) && !want.has(i));
16630
+ if (top.some((pk) => pk.ImportPath && want.has(pk.ImportPath) && !pk.GoFiles?.length) && viaImports.length) {
16631
+ const li = yield ["go", ["list", "-e", "-json=ImportPath,Dir,GoFiles,CgoFiles,Standard,Module", ...viaImports], spawnOpts];
16632
+ const deps = li.status === 0 ? listed(li.output) : null;
16633
+ if (!deps)
16634
+ return refuse;
16635
+ for (const pk of deps)
16636
+ if (pk.ImportPath && !pk.Standard && pk.Module?.Main === true && pk.GoFiles?.length)
16637
+ cover.set(pk.ImportPath, pk);
16638
+ }
16639
+ if (cover.size === 0 || [...want].some((pk) => !cover.has(pk) && !top.some((t) => t.ImportPath === pk && !t.GoFiles?.length)))
16640
+ return refuse;
16641
+ if (ownImports.some((imps) => !imps.some((i) => cover.has(i))))
16642
+ return refuse;
16643
+ const perPkg = new Map;
16644
+ for (const pk of cover.values()) {
16645
+ if (!pk.ImportPath || !pk.Dir || !pk.GoFiles?.length || pk.CgoFiles?.length)
16496
16646
  return refuse;
16497
16647
  perPkg.set(pk.ImportPath, 0);
16498
16648
  for (const f of pk.GoFiles) {
@@ -16512,16 +16662,17 @@ function* corroborateGoSteps(c, out2, cmdOrLine, args, toks, o) {
16512
16662
  });
16513
16663
  }
16514
16664
  }
16515
- if (![...want].every((pk) => (perPkg.get(pk) ?? 0) > 0))
16665
+ if (![...cover.keys()].every((pk) => (perPkg.get(pk) ?? 0) > 0))
16516
16666
  return refuse;
16517
- const r = yield ["go", ["test", "-json", "-count=1", `-coverprofile=${prof}`, ...run2, ...where], spawnOpts];
16667
+ const viaPkg = [...cover.keys()].some((pk) => !want.has(pk));
16668
+ const r = yield ["go", ["test", "-json", "-count=1", `-coverprofile=${prof}`, ...viaPkg ? [`-coverpkg=${[...cover.keys()].join(",")}`] : [], ...run2, ...where], spawnOpts];
16518
16669
  const second = goJson(stripAnsi(r.output));
16519
16670
  if (r.status !== 0 || !second || second.failed || !second.complete)
16520
16671
  return refuse;
16521
16672
  const again = new Set(second.passedNames);
16522
16673
  if (!names.every((n3) => again.has(n3)))
16523
16674
  return refuse;
16524
- const got = [...profBlocks()].filter((k) => [...want].some((pk) => k.startsWith(`${pk}/`) && !k.slice(pk.length + 1).includes("/")));
16675
+ const got = [...profBlocks()].filter((k) => [...cover.keys()].some((pk) => k.startsWith(`${pk}/`) && !k.slice(pk.length + 1).includes("/")));
16525
16676
  return got.length === expected.size && got.every((k) => expected.has(k)) ? c : refuse;
16526
16677
  } finally {
16527
16678
  rmSync10(dir, { recursive: true, force: true });
@@ -16726,12 +16877,109 @@ function changedSymbols(diffU0) {
16726
16877
  flush();
16727
16878
  return [...out2];
16728
16879
  }
16880
+ function goInterfaceMethod(name, methods) {
16881
+ if (["Error", "String", "GoString", "Format"].includes(name))
16882
+ return true;
16883
+ if (["Unwrap", "Is", "As"].includes(name))
16884
+ return methods.has("Error");
16885
+ const sorts = GO_SORT.every((m) => methods.has(m));
16886
+ return (GO_SORT.includes(name) || name === "Push" || name === "Pop") && sorts && (GO_SORT.includes(name) || methods.has("Push") && methods.has("Pop"));
16887
+ }
16888
+ function addedPublicFunctions(path, head, base) {
16889
+ if (notApiFile(path, head))
16890
+ return [];
16891
+ const lang = langOf(path);
16892
+ if (lang !== "py" && lang !== "go" && lang !== "rs" && lang !== "ts")
16893
+ return [];
16894
+ const spans = symbolSpans(path, head), had = new Set(symbolSpans(path, base).map((x) => x.name)), byName = new Map(spans.map((x) => [x.name, x]));
16895
+ const lines = head.split(`
16896
+ `), exported = lang === "ts" ? tsExportList(head) : new Set, out2 = new Set;
16897
+ const declOf = (start) => lines.slice(start - 1, start + 4).find((l) => !/^\s*@/.test(l)) ?? "";
16898
+ for (const sp of spans) {
16899
+ if (sp.container || had.has(sp.name))
16900
+ continue;
16901
+ const parts = sp.name.split("."), name = parts[parts.length - 1], parent = parts.length > 1 ? byName.get(parts.slice(0, -1).join(".")) : undefined, decl = declOf(sp.start);
16902
+ if (lang === "py") {
16903
+ if (/^\s*(?:async\s+)?def\s/.test(decl) && parts.every((x) => !x.startsWith("_")))
16904
+ out2.add(name);
16905
+ continue;
16906
+ }
16907
+ if (lang === "go") {
16908
+ const recv = parent?.name ?? (parts.length > 1 ? parts[parts.length - 2] : undefined);
16909
+ if (/^func\b/.test(decl) && /^[A-Z]/.test(name) && (recv === undefined ? true : /^[A-Z]/.test(recv) && !goInterfaceMethod(name, new Set(spans.filter((x) => x.name.startsWith(`${recv}.`)).map((x) => x.name.slice(recv.length + 1))))))
16910
+ out2.add(name);
16911
+ continue;
16912
+ }
16913
+ if (lang === "rs") {
16914
+ if (/\bpub(?:\([^)]*\))?\s+(?:const\s+)?(?:async\s+)?(?:unsafe\s+)?(?:extern\s+"[^"]*"\s+)?fn\s/.test(decl))
16915
+ out2.add(name);
16916
+ continue;
16917
+ }
16918
+ const arrowHead = /^\s*(?:export\s+)?(?:const|let|var)\s[^=]*=\s*(?:async\s*)?(?:<[^>]*>\s*)?\(\s*$/.test(decl) ? lines.slice(sp.start - 1, Math.min(sp.end, sp.start + 30)).join(`
16919
+ `) : "";
16920
+ const fnLike = /\bfunction\b|=>|^\s*(?:(?:public|static|async|override|readonly|get|set)\s+)*[A-Za-z_$][\w$]*\s*(?:<[^>]*>)?\s*\(/.test(decl) || /^[^]*?\)\s*(?::[^=]*?)?=>/.test(arrowHead);
16921
+ if (!fnLike || name === "constructor" || /^\s*(?:export\s+)?(?:declare\s|type\s)/.test(decl))
16922
+ continue;
16923
+ if (parent) {
16924
+ const cls = declOf(parent.start);
16925
+ if ((/^\s*export\s/.test(cls) || exported.has(parent.name)) && !/^\s*(?:private|protected)\b|#/.test(decl))
16926
+ out2.add(name);
16927
+ } else if (/^\s*export\s/.test(decl) || exported.has(name))
16928
+ out2.add(name);
16929
+ }
16930
+ if (lang === "go") {
16931
+ const vars = (src) => new Set([...src.matchAll(/^var\s+([A-Z]\w*)\s*=\s*func\b/gm)].map((m) => m[1]));
16932
+ const was = vars(base);
16933
+ for (const v of vars(head))
16934
+ if (!was.has(v))
16935
+ out2.add(v);
16936
+ }
16937
+ return [...out2];
16938
+ }
16939
+ function unreferenced(symbols, sources2) {
16940
+ const sets = sources2.map((x) => identifierSet(x)), plain = symbols.filter((x) => !PLAIN_IDENT.test(x)), code = plain.length ? sources2.map(codeOnly) : [];
16941
+ return symbols.filter((sym) => PLAIN_IDENT.test(sym) ? !sets.some((st) => st.has(sym)) : !code.some((src) => refRe(sym).test(src)));
16942
+ }
16729
16943
  function symbolGap(symbols, testSources) {
16730
16944
  if (symbols.length === 0)
16731
16945
  return ["(no declared symbol)"];
16732
- const ref = (sym, src) => new RegExp(`(?<![\\w$])${sym.replace(/[$]/g, "\\$")}(?![\\w$])`).test(src);
16733
- const code = testSources.map(stripComments);
16734
- return code.some((src) => symbols.some((sym) => ref(sym, src))) ? [] : [...symbols];
16946
+ return unreferenced(symbols, testSources).length === symbols.length ? [...symbols] : [];
16947
+ }
16948
+ function callerFiles(changed, candidates) {
16949
+ const names = new Set(changed.flatMap((f) => symbolSpans(f.path, f.src).filter((x) => !x.container).map((x) => x.name.split(".").pop())));
16950
+ if (names.size === 0)
16951
+ return [];
16952
+ return candidates.filter((f) => {
16953
+ for (const n3 of calledNames(codeOnly(f.src)))
16954
+ if (names.has(n3))
16955
+ return true;
16956
+ return false;
16957
+ });
16958
+ }
16959
+ function exercisedViaCallers(unexercised, seed, files) {
16960
+ const byName = new Map, seeds = [];
16961
+ for (const f of files) {
16962
+ const code = codeOnly(f.src), lines = code.split(`
16963
+ `);
16964
+ for (const x of symbolSpans(f.path, f.src)) {
16965
+ if (x.container)
16966
+ continue;
16967
+ const name = x.name.split(".").pop(), called = calledNames(lines.slice(x.start, x.end).join(`
16968
+ `));
16969
+ (byName.get(name) ?? byName.set(name, []).get(name)).push(called);
16970
+ if (seed(name, f.path))
16971
+ seeds.push(name);
16972
+ }
16973
+ }
16974
+ const covered = new Set(seeds), work = [...covered];
16975
+ for (let n3 = work.pop();n3 !== undefined; n3 = work.pop())
16976
+ for (const called of byName.get(n3) ?? [])
16977
+ for (const c of called)
16978
+ if (byName.has(c) && !covered.has(c)) {
16979
+ covered.add(c);
16980
+ work.push(c);
16981
+ }
16982
+ return unexercised.filter((f) => !covered.has(f));
16735
16983
  }
16736
16984
  function explainGates(receiptPath) {
16737
16985
  let checks = [];
@@ -17992,6 +18240,9 @@ exit $st`, wrapperOr = (repoDir, w, bare) => existsSync33(join53(repoDir, w)) ?
17992
18240
  if (m)
17993
18241
  out2.push(m[1]);
17994
18242
  return out2.filter((n3) => !NOT_A_NAME.has(n3));
18243
+ }, GO_SORT, API_FILE_EXT, GENERATED_PATH, TEST_SUPPORT_PATH, GENERATED_HEADER, notApiFile = (path, src = "") => !API_FILE_EXT.test(path) || isTestFile(path) || TEST_SUPPORT_PATH.test(path) || GENERATED_PATH.test(path) || GENERATED_HEADER.test(src.slice(0, 2000)), tsExportList = (src) => new Set([...src.matchAll(/^\s*export\s*\{([^}]*)\}/gm)].flatMap((m) => m[1].split(",").map((x) => x.trim().split(/\s+as\s+/)[0].trim()).filter(Boolean)).concat([...src.matchAll(/^\s*export\s+default\s+([A-Za-z_$][\w$]*)\s*;?\s*$/gm)].map((m) => m[1]))), codeOnly = (src) => stripComments(src.replace(/"""[\s\S]*?"""|'''[\s\S]*?'''|`(?:\\[\s\S]|[^`\\])*`|"(?:\\.|[^"\\\n])*"|'(?:\\.|[^'\\\n])*'/g, '""')), refRe = (sym) => new RegExp(`(?<![\\w$])${sym.replace(/[$]/g, "\\$")}(?![\\w$])`), IDENT2, PLAIN_IDENT, identifierSet = (src, keepStrings = false) => new Set((keepStrings ? stripComments(src) : codeOnly(src)).match(IDENT2) ?? []), CALL, calledNames = (code) => new Set([...code.matchAll(CALL)].map((m) => m[1])), moduleToken = (path) => {
18244
+ const parts = path.split("/"), base = (parts.pop() ?? "").replace(/\.[^.]+$/, "");
18245
+ return path.endsWith(".go") || /^(?:index|__init__|mod|lib|main)$/.test(base) ? parts.pop() ?? base : base;
17995
18246
  }, printable = (s) => s.replace(UNSAFE_TERMINAL_CHARS_RE, "?"), SENSITIVE, API, TEST_CFG, RANK3, FILES_MEDIUM = 4, FILES_HIGH = 15, LINES_MEDIUM = 100, LINES_HIGH = 500, RAN_ALWAYS, REVIEWER_ITEM = "one reviewer", PLAN, LOW_SKIPPED, deferredOf = (tier, selected, executed) => (tier === "low" ? LOW_SKIPPED : selected).filter((c) => !RAN_ALWAYS.includes(c) && !executed.includes(c)), DEEP_ITEMS, NOT_SELECTED = "not selected by risk tier: ", SECURITY_SCAN = "security scan", MANIFEST_LOCKS, dirOf = (p) => p.includes("/") ? p.slice(0, p.lastIndexOf("/")) : "", PKG_DEP_KEYS, PYPROJECT_NONDEP, SEM_RULES, DOC_FILE, readOr = (p) => {
17996
18247
  try {
17997
18248
  return readFileSync43(p, "utf8");
@@ -18027,6 +18278,7 @@ var init_check_result = __esm(() => {
18027
18278
  init_safe_git();
18028
18279
  init_redact();
18029
18280
  init_spec_file();
18281
+ init_context_pack();
18030
18282
  FAIL_EVIDENCE = /\[(?:build|setup) failed\]|^--- FAIL|^[\w./-]+\.go:\d+:\d+: \S|\b[1-9]\d* (?:failed|errors?)\b/m;
18031
18283
  GO_FAIL_EVIDENCE = /^FAIL\t\S+\t[\d.]+s$|^panic: /m;
18032
18284
  CARGO_NOISE = /^\s*(?:Compiling|Finished|Running|Doc-tests|Fresh|Blocking|Downloaded|Downloading|Updating|Locking|Adding|Packaging|Building)\b|^(?:warning|error|note|help)\b|^\s*(?:-->|=\s|\||\d+\s*\||\^|~)|^(?:Some errors have detailed|For more information about)/;
@@ -18066,6 +18318,14 @@ var init_check_result = __esm(() => {
18066
18318
  GO_METHOD_RE = /\bfunc\s*\([^)]*\)\s*([A-Za-z_]\w*)/g;
18067
18319
  METHOD_RE = /^\s*(?:(?:public|private|protected|static|async|export|override|final|abstract)\s+)*([A-Za-z_$][\w$]*)\s*\([^)]*\)\s*(?::\s*[^{=]+)?\{\s*$/;
18068
18320
  NOT_A_NAME = new Set(["if", "for", "while", "switch", "catch", "function", "return", "else", "with", "constructor"]);
18321
+ GO_SORT = ["Len", "Less", "Swap"];
18322
+ API_FILE_EXT = /\.(?:[cm]?[jt]sx?|py|go|rs)$/;
18323
+ GENERATED_PATH = /(?:\.pb\.go|_pb2(?:_grpc)?\.pyi?|\.pb\.[cm]?[jt]s|[._-]gen(?:erated)?\.\w+|\.d\.[cm]?ts)$/;
18324
+ TEST_SUPPORT_PATH = /(^|\/)(?:tests?|__tests__|spec|testutils?|testhelpers?|test_?helpers?|testing|testdata|fixtures?|mocks?)\/|(^|\/)conftest\.py$/;
18325
+ GENERATED_HEADER = /^\s*(?:\/\/|#)\s*Code generated .* DO NOT EDIT\.?\s*$|@generated\b/m;
18326
+ IDENT2 = /[\w$]+/g;
18327
+ PLAIN_IDENT = /^[\w$]+$/;
18328
+ CALL = /(?<![\w$])([\w$]+)\s*\(/g;
18069
18329
  SENSITIVE = [
18070
18330
  ["auth", /(^|\/)(auth|oauth|sso|session|login|permission|rbac|acl)[\w.-]*(\/|\.|$)/i],
18071
18331
  ["crypto", /(^|\/)(crypt|crypto|jwt|signing|keys?|secrets?|tokens?|credential|password)[\w.-]*(\/|\.|$)/i],
@@ -20992,7 +21252,7 @@ ${r.stderr}`);
20992
21252
  notProven.add(`${NA_PREFIX}${name} (ran 0 tests on base and head; the Wall or a task-named check passed with executed tests)`);
20993
21253
  continue;
20994
21254
  }
20995
- checks.push({ name, cmd, result: cls.result, duration_s, ...cls.count ? { count: cls.count } : {}, ...cls.result === "fail" ? { ids: cls.count ? [exitCodedId(line2, out2, repoDir) ?? []].flat() : failIds(out2), first_error: firstError(out2), excerpt: failureExcerpt(out2, repoDir) } : {} });
21255
+ checks.push({ name, cmd, result: cls.result, duration_s, ...cls.count ? { count: cls.count } : {}, ...cls.result === "fail" ? { ids: cls.count ? [exitCodedId(line2, out2, repoDir) ?? []].flat() : failIds(out2), errors: Object.fromEntries(errorsById(out2)), ...unhandledBlock(out2).length ? { unhandled: unhandledBlock(out2) } : {}, first_error: firstError(out2), excerpt: failureExcerpt(out2, repoDir) } : {} });
20996
21256
  if (cls.result === "not_run")
20997
21257
  notProven.add(`not run: ${name} (${cls.reason ?? NO_TESTS_REASON})`);
20998
21258
  }
@@ -21635,22 +21895,22 @@ function relevant(shared, text3) {
21635
21895
  `);
21636
21896
  }
21637
21897
  function testConfigChanged(repoDir, baseSha, changed) {
21638
- return changed.filter((f) => {
21639
- const spec = RUNNER_CONFIGS.find((s) => s.re.test(f));
21640
- if (!spec)
21641
- return false;
21642
- if (!spec.shared)
21643
- return true;
21644
- const b = baseText(repoDir, baseSha, f), h = headText(repoDir, f);
21645
- if (b === h)
21646
- return false;
21647
- const e = typeof spec.shared === "string" && spec.shared !== "tsconfig" ? "" : "{}";
21648
- try {
21649
- return relevant(spec.shared, b || e) !== relevant(spec.shared, h || e);
21650
- } catch {
21651
- return true;
21652
- }
21653
- });
21898
+ return changed.filter((f) => steersRunner(f, baseText(repoDir, baseSha, f), headText(repoDir, f)));
21899
+ }
21900
+ function steersRunner(f, before, after) {
21901
+ const spec = RUNNER_CONFIGS.find((s) => s.re.test(f));
21902
+ if (!spec)
21903
+ return false;
21904
+ if (!spec.shared)
21905
+ return true;
21906
+ if (before === after)
21907
+ return false;
21908
+ const e = typeof spec.shared === "string" && spec.shared !== "tsconfig" ? "" : "{}";
21909
+ try {
21910
+ return relevant(spec.shared, before || e) !== relevant(spec.shared, after || e);
21911
+ } catch {
21912
+ return true;
21913
+ }
21654
21914
  }
21655
21915
  function patchedTargets(cfg, text3) {
21656
21916
  const out2 = [], unq = (v) => v.replace(/^["']|["']$/g, "");
@@ -21820,7 +22080,7 @@ function hiddenConfigChanged(repoDir, snap) {
21820
22080
  if (!snap || typeof snap !== "object")
21821
22081
  return Object.keys(now2).length ? ["untracked runner configs (no intake snapshot to compare)"] : [];
21822
22082
  const was = snap;
21823
- const d = [...new Set([...Object.keys(now2), ...Object.keys(was)])].filter((f) => now2[f] !== was[f]).sort();
22083
+ const d = [...new Set([...Object.keys(now2), ...Object.keys(was)])].filter((f) => now2[f] !== was[f] && (was[f] !== undefined || now2[f] === "!unreadable" || steersRunner(f, "", headText(repoDir, f)))).sort();
21824
22084
  return d.length > 5 ? [...d.slice(0, 5), `(+${d.length - 5} more)`] : d;
21825
22085
  }
21826
22086
  var PKG_KEYS, RAW_CONFIGS, RUNNER_CONFIGS, DEP_MAPS, RUNNER_DEP, LOCAL_SPEC, depGuard = (j) => DEP_MAPS.map((m) => Object.entries(j[m] ?? {}).filter(([k, v]) => RUNNER_DEP.test(k) || LOCAL_SPEC.test(String(v)))), KW2, lines = (t) => t.split(`
@@ -30527,6 +30787,7 @@ __export(exports_seal, {
30527
30787
  commitStage: () => commitStage,
30528
30788
  canonicalJson: () => canonicalJson,
30529
30789
  WALL_GREEN_ON_BASE_REASON: () => WALL_GREEN_ON_BASE_REASON,
30790
+ UNEXERCISED_PUBLIC: () => UNEXERCISED_PUBLIC,
30530
30791
  SIGNING_UNAVAILABLE: () => SIGNING_UNAVAILABLE,
30531
30792
  LEAN_NO_SYMBOL: () => LEAN_NO_SYMBOL,
30532
30793
  EXTERNAL_NO_WALL: () => EXTERNAL_NO_WALL,
@@ -30537,30 +30798,67 @@ __export(exports_seal, {
30537
30798
  import { createHash as createHash30 } from "crypto";
30538
30799
  import { existsSync as existsSync62, readdirSync as readdirSync33, mkdirSync as mkdirSync43, readFileSync as readFileSync81 } from "fs";
30539
30800
  import { basename as basename26, isAbsolute as isAbsolute16, join as join95, relative as relative19 } from "path";
30540
- async function leanSymbolGap(ctx, o, rawDiff, head, vraw) {
30541
- if (externalRun(o) || Array.isArray(o.wall?.files) && o.wall.files.length > 0 || o.intake?.already_satisfied === true || o.implement?.exit === "already_done")
30542
- return [];
30543
- const code = [];
30801
+ async function symbolGaps(ctx, o, rawDiff, head, vraw) {
30802
+ const none = { lean: [], pub: [] };
30803
+ if (externalRun(o) || o.intake?.already_satisfied === true || o.implement?.exit === "already_done")
30804
+ return none;
30805
+ const touched = new Set, code = [], added = [];
30544
30806
  for (let i = 0;i + 1 < rawDiff.length; i += 2) {
30545
30807
  const st = rawDiff[i].trim().split(" ").pop() ?? "", f = rawDiff[i + 1];
30546
- if (st !== "D" && CODE_FILE_EXT.test(f) && !isTestFile(f))
30808
+ touched.add(f);
30809
+ if (st !== "D" && (CODE_FILE_EXT.test(f) || API_FILE_EXT.test(f)) && !isTestFile(f))
30547
30810
  code.push(f);
30811
+ if (st === "A")
30812
+ added.push(f);
30548
30813
  }
30549
30814
  if (code.length === 0)
30550
- return [];
30551
- const d = await safeGitRun(ctx.repoDir, ["diff", "-U0", "--no-color", "--no-ext-diff", "--no-textconv", "--no-renames", ctx.baseSha, head, "--", ...code], { timeoutMs: 20000 });
30552
- if (d.exitCode !== 0)
30553
- return [];
30554
- const sources2 = [];
30555
- for (const c of vraw)
30556
- if (isExecutedProof(c)) {
30557
- const n3 = String(c.name ?? ""), p = n3.slice(n3.indexOf(":") + 1);
30558
- if (n3.includes(":") && isTestFile(p))
30559
- try {
30560
- sources2.push(readFileSync81(join95(ctx.repoDir, p), "utf8"));
30561
- } catch {}
30815
+ return none;
30816
+ const read3 = (p) => {
30817
+ try {
30818
+ return readFileSync81(join95(ctx.repoDir, p), "utf8");
30819
+ } catch {
30820
+ return "";
30562
30821
  }
30563
- return symbolGap(changedSymbols(d.stdout), sources2);
30822
+ };
30823
+ const executed = vraw.filter((c) => isExecutedProof(c)), testOf = (c) => {
30824
+ const n3 = String(c.name ?? ""), p = n3.slice(n3.indexOf(":") + 1);
30825
+ return n3.includes(":") && !n3.startsWith("full suite:") && isTestFile(p) ? p : null;
30826
+ };
30827
+ const allSources = executed.map(testOf).filter((p) => p !== null).map(read3);
30828
+ const ranWall = Array.isArray(o.wall?.files) && o.wall.files.length > 0, leanFiles = code.filter((f) => CODE_FILE_EXT.test(f));
30829
+ let lean = [];
30830
+ if (!ranWall && leanFiles.length) {
30831
+ const d = await safeGitRun(ctx.repoDir, ["diff", "-U0", "--no-color", "--no-ext-diff", "--no-textconv", "--no-renames", ctx.baseSha, head, "--", ...leanFiles], { timeoutMs: 20000 });
30832
+ if (d.exitCode === 0)
30833
+ lean = symbolGap(changedSymbols(d.stdout), allSources);
30834
+ }
30835
+ if (process.env["LOKI_E10_PUBLIC_GAP"] !== "1")
30836
+ return { lean, pub: [] };
30837
+ const files = code.filter((f) => API_FILE_EXT.test(f)).map((path) => ({ path, src: read3(path) }));
30838
+ const fns = [];
30839
+ for (const f of files) {
30840
+ const base2 = added.includes(f.path) ? "" : await safeGitRun(ctx.repoDir, ["show", `${ctx.baseSha}:${f.path}`], { timeoutMs: 20000 });
30841
+ const b = typeof base2 === "string" ? base2 : base2.exitCode === 0 ? base2.stdout : null;
30842
+ if (b !== null)
30843
+ fns.push(...addedPublicFunctions(f.path, f.src, b));
30844
+ }
30845
+ if (fns.length === 0)
30846
+ return { lean, pub: [] };
30847
+ const wall = new Set((o.wall?.files ?? []).map((f) => isAbsolute16(f.path) ? relative19(ctx.repoDir, f.path) : f.path));
30848
+ const paths = new Set(executed.map(testOf).filter((p) => p !== null && (wall.has(p) || !touched.has(p))));
30849
+ const ls2 = await safeGitRun(ctx.repoDir, ["ls-files", "-z"], { timeoutMs: 20000 }), tracked = ls2.exitCode === 0 ? ls2.stdout.split("\x00").filter((t) => t && !touched.has(t)) : [];
30850
+ if (executed.some((c) => String(c.name ?? "").startsWith("full suite:"))) {
30851
+ for (const t of tracked)
30852
+ if (isTestFile(t))
30853
+ paths.add(t);
30854
+ }
30855
+ const texts = [...paths].map(read3), idents = texts.map((t) => identifierSet(t)), imports2 = texts.map((t) => identifierSet(t, true)), named2 = new Set(fns.filter((f) => idents.some((st) => st.has(f))));
30856
+ const pending = [...new Set(fns)].filter((f) => !named2.has(f));
30857
+ if (pending.length === 0)
30858
+ return { lean, pub: [] };
30859
+ const candidates = tracked.filter((t) => !notApiFile(t)).slice(0, CALLER_SCAN).map((path) => ({ path, src: read3(path) })).filter((f) => f.src.length <= CALLER_MAX_BYTES && !notApiFile(f.path, f.src));
30860
+ const changedPaths = new Set(files.map((f) => f.path)), seed = (name, path) => idents.some((st, i) => st.has(name) && (changedPaths.has(path) || imports2[i].has(moduleToken(path))));
30861
+ return { lean, pub: exercisedViaCallers(pending, seed, [...files, ...callerFiles(files, candidates)]) };
30564
30862
  }
30565
30863
  function receiptSha256(r) {
30566
30864
  const { verification: _v, receipt_sha256: _h, ...body } = r;
@@ -30642,7 +30940,7 @@ function renderReceiptMd(r) {
30642
30940
  ].join(`
30643
30941
  `);
30644
30942
  }
30645
- var SYSTEM_INTERP = "tests ran on the system interpreter", SYSTEM_INTERP_SUFFIX = " (the repo declares no Python dependencies, so this is its interpreter; informational, does not cap)", SIGNING_UNAVAILABLE = "receipt signing unavailable (no usable signing key: invalid key or unwritable ~/.loki/keys)", AGENT_ONLY_REASON = "only agent-authored tests executed (no agent-independent proof)", WALL_GREEN_ON_BASE_REASON = "Wall green on base: no Wall test discriminates the change", EXCLUDE_LOKI = ":(exclude).loki", sha2562 = (s) => createHash30("sha256").update(s).digest("hex"), str3 = (v) => typeof v === "string" && v !== "" ? v : null, EXTERNAL_MODEL_LABEL = "external (no Loki implement session)", EXTERNAL_DIFF_NOT_ISOLATED = "Wall author not filesystem-isolated from the external diff", EXTERNAL_NO_WALL = "external diff sealed with no Wall file that ran; the only checks are the repo's existing tests", externalRun = (o) => o.implement?.exit === "external", LEAN_NO_SYMBOL = "no passing check references a changed symbol and no Wall file ran", strs2 = (v) => Array.isArray(v) ? v.filter((x) => typeof x === "string" && x !== "") : [], g = (ctx) => (a) => git5(ctx, a), receiptRel = (ctx) => {
30943
+ var SYSTEM_INTERP = "tests ran on the system interpreter", SYSTEM_INTERP_SUFFIX = " (the repo declares no Python dependencies, so this is its interpreter; informational, does not cap)", SIGNING_UNAVAILABLE = "receipt signing unavailable (no usable signing key: invalid key or unwritable ~/.loki/keys)", AGENT_ONLY_REASON = "only agent-authored tests executed (no agent-independent proof)", WALL_GREEN_ON_BASE_REASON = "Wall green on base: no Wall test discriminates the change", EXCLUDE_LOKI = ":(exclude).loki", sha2562 = (s) => createHash30("sha256").update(s).digest("hex"), str3 = (v) => typeof v === "string" && v !== "" ? v : null, EXTERNAL_MODEL_LABEL = "external (no Loki implement session)", EXTERNAL_DIFF_NOT_ISOLATED = "Wall author not filesystem-isolated from the external diff", EXTERNAL_NO_WALL = "external diff sealed with no Wall file that ran; the only checks are the repo's existing tests", externalRun = (o) => o.implement?.exit === "external", LEAN_NO_SYMBOL = "no passing check references a changed symbol and no Wall file ran", UNEXERCISED_PUBLIC = "no agent-independent passing test calls these added public functions", CALLER_SCAN = 3000, CALLER_MAX_BYTES = 200000, strs2 = (v) => Array.isArray(v) ? v.filter((x) => typeof x === "string" && x !== "") : [], g = (ctx) => (a) => git5(ctx, a), receiptRel = (ctx) => {
30646
30944
  const r = relative19(ctx.repoDir, join95(ctx.runDir, "receipt.json"));
30647
30945
  return r.startsWith("..") || isAbsolute16(r) ? `.loki/runs/${ctx.runId}/receipt.json` : r;
30648
30946
  }, commitStage, wallGreenOnBaseOf = (o) => {
@@ -30755,9 +31053,9 @@ var init_seal = __esm(() => {
30755
31053
  const grp = sealGroup(ctx.runDir, receiptSha256);
30756
31054
  const executed = hasExecutedProof(vraw), proof = process.env["LOKI_EXOGENOUS_PROOF"] === "0" ? executed : hasExogenousProof(vraw, pctx);
30757
31055
  const uncoveredAfterLimit = o.implement?.exit === "killed" ? strs2(o.verify?.uncovered_changed) : [];
30758
- const leanGap = diffOk ? await leanSymbolGap(ctx, o, rawDiff, head, vraw) : [];
31056
+ const { lean: leanGap, pub: pubGap } = diffOk ? await symbolGaps(ctx, o, rawDiff, head, vraw) : { lean: [], pub: [] };
30759
31057
  const wpAll = publishableWall(ctx.repoDir, ctx.runDir, o, process.env, loadTaskText(ctx, str3(o.intake?.task) ?? undefined));
30760
- const verdict0 = capGroupVerdict(verdictOf2(o, checks.filter((c) => !(c.result === "fail" && preRedChecks.includes(c.name)) && c.repo_skipped !== true), !diffOk || diff.stdout === "", capVerify.length > 0 || weakTests.length > 0 || capRc.length > 0, wallGreenOnBase, proof, targetProofOf(o.verify), uncoveredAfterLimit, leanGap, wpAll.notes, wpAll.clauseGap), grp);
31058
+ const verdict0 = capGroupVerdict(verdictOf2(o, checks.filter((c) => !(c.result === "fail" && preRedChecks.includes(c.name)) && c.repo_skipped !== true), !diffOk || diff.stdout === "", capVerify.length > 0 || weakTests.length > 0 || capRc.length > 0, wallGreenOnBase, proof, targetProofOf(o.verify), uncoveredAfterLimit, [...leanGap, ...pubGap], wpAll.notes, wpAll.clauseGap), grp);
30761
31059
  const supply = await supplyGuard(ctx.repoDir, rawDiff.filter((_, i) => i % 2 === 1), readDeclared(ctx.repoDir), process.env);
30762
31060
  const verdict1 = supplyVerdict(verdict0, supply);
30763
31061
  const xr = await crossReview(ctx, verdict1, head, signal), verdict2 = minVerdict(verdict1, xr);
@@ -30858,6 +31156,8 @@ var init_seal = __esm(() => {
30858
31156
  notProven.add(o.verify.baseline_line);
30859
31157
  if (leanGap.length > 0)
30860
31158
  notProven.add(`${LEAN_NO_SYMBOL}: ${leanGap.join(", ")}`);
31159
+ if (pubGap.length > 0)
31160
+ notProven.add(`${UNEXERCISED_PUBLIC}: ${pubGap.join(", ")}`);
30861
31161
  if (externalRun(o) && !(Array.isArray(o.wall?.files) && o.wall.files.length > 0))
30862
31162
  notProven.add(EXTERNAL_NO_WALL);
30863
31163
  if (externalRun(o))
@@ -32597,13 +32897,16 @@ async function routeEscalate(ctx, first, session, rt, ids, noDiff = () => false)
32597
32897
  first.model = rt.current;
32598
32898
  first.iterationId = `${first.iterationId}-esc`;
32599
32899
  ids.push(first.iterationId);
32600
- return ctx.sessions.run(first);
32900
+ return ctx.sessions.run(trig === "already_done_claim" ? { ...first, brief: `${first.brief}
32901
+
32902
+ ${REDO_CHALLENGE}` } : first);
32601
32903
  }
32602
32904
  var UNIT = "run";
32603
32905
  var init_implement_route = __esm(() => {
32604
32906
  init_model_rank();
32605
32907
  init_unit_model();
32606
32908
  init_history();
32909
+ init_conflict_resume();
32607
32910
  });
32608
32911
 
32609
32912
  // ../../loki-ts/src/util/test_guard.ts
@@ -32835,10 +33138,22 @@ var init_implement = __esm(() => {
32835
33138
  ids.push(...w.ids);
32836
33139
  }
32837
33140
  }
32838
- if (!signal.aborted && !session.killed && session.exit === 0 && !session.markers.specConflict && !session.markers.alreadyDone && treeIsEmpty(ctx)) {
32839
- const r = await resumeAfterEmptyDone(ctx, { ...unchained(), iterationId: ids[ids.length - 1] }, session);
33141
+ let challenged = false;
33142
+ const routerRedid = rt?.escalations.some((e) => e.trigger === "already_done_claim") ?? false;
33143
+ const challenge = async () => {
33144
+ if (signal.aborted || session.killed || !session.markers.alreadyDone || session.markers.specConflict || challenged || routerRedid || process.env.LOKI_E10_ALREADY_DONE_CHALLENGE === "0")
33145
+ return;
33146
+ challenged = true;
33147
+ const r = await resumeAfterAlreadyDone(ctx, { ...unchained(), iterationId: ids[ids.length - 1] }, session);
32840
33148
  session = r.session;
32841
33149
  ids.push(r.iterationId);
33150
+ };
33151
+ await challenge();
33152
+ if (!challenged && !signal.aborted && !session.killed && session.exit === 0 && !session.markers.specConflict && !session.markers.alreadyDone && treeIsEmpty(ctx)) {
33153
+ const r = await resumeAfterEmptyDone(ctx, { ...unchained(), iterationId: ids[ids.length - 1] }, session, routerRedid);
33154
+ session = r.session;
33155
+ ids.push(r.iterationId);
33156
+ await challenge();
32842
33157
  }
32843
33158
  if (process.env.LOKI_E10_REPRO === "1" && !plan && !signal.aborted && !session.killed && session.exit === 0) {
32844
33159
  let bad = [];
@@ -32858,8 +33173,10 @@ var init_implement = __esm(() => {
32858
33173
  exit = "killed";
32859
33174
  } else if (session.markers.specConflict) {
32860
33175
  exit = "spec_conflict";
32861
- } else if (session.markers.alreadyDone) {
33176
+ } else if (session.markers.alreadyDone && treeIsEmpty(ctx)) {
32862
33177
  exit = "already_done";
33178
+ } else if (session.markers.alreadyDone) {
33179
+ exit = "done";
32863
33180
  } else if (session.exit !== 0) {
32864
33181
  exit = "error";
32865
33182
  } else {
@@ -33256,6 +33573,13 @@ ${timeBudgetNote(limitS)}`;
33256
33573
  const fx = await runStage("fix", true);
33257
33574
  if (!fx || mustJump("fix", fx) || fatal)
33258
33575
  break;
33576
+ if (fx.status === "completed" && outputs.fix?.exit === "spec_conflict" && onlyCollateralRed(outputs.verify)) {
33577
+ const v2 = await runStage("verify", true);
33578
+ if (mustJump("verify", v2))
33579
+ break;
33580
+ if (!hasFailures(outputs.verify))
33581
+ break;
33582
+ }
33259
33583
  if (fx.status === "completed" && outputs.fix?.exit === "spec_conflict") {
33260
33584
  outputs.implement = { ...outputs.implement, exit: "spec_conflict", spec_conflict_reason: outputs.fix.spec_conflict_reason ?? null };
33261
33585
  break;
@@ -33308,6 +33632,9 @@ ${timeBudgetNote(limitS)}`;
33308
33632
  var FLOW, TAIL, harnessOnlyFail = (d) => {
33309
33633
  const f = (Array.isArray(d?.checks) ? d.checks : []).filter((c) => c?.result === "fail");
33310
33634
  return f.length > 0 && f.every((c) => c.owner === "harness");
33635
+ }, onlyCollateralRed = (d) => {
33636
+ const col = Array.isArray(d?.collateral_same_error) ? d.collateral_same_error.map(String) : [], b = Array.isArray(d?.blocking_checks) ? d.blocking_checks.map(String) : [];
33637
+ return col.length > 0 && b.length > 0 && b.every((n3) => col.includes(n3) || n3.startsWith("full suite"));
33311
33638
  }, hasFailures = (d) => Array.isArray(d?.failures_grouped) && d.failures_grouped.length > 0 && !harnessOnlyFail(d) || typeof d?.holdout_failed === "number" && d.holdout_failed > 0, earlyExit = (d) => d.already_satisfied === true, KILL_GRACE_MS3 = 2000, VERIFY_RESERVE_S, TREE_STAGES;
33312
33639
  var init_machine = __esm(() => {
33313
33640
  init_hooks();
@@ -37470,12 +37797,12 @@ ${String(s.stderr ?? "")}`.slice(-16000);
37470
37797
  const allPass = Object.values(perUnit).every((v) => v === "pass");
37471
37798
  return res({ suiteExit, ...wallResults ? { wallResults } : {}, ok: allPass, ...allPass ? {} : { reason: "a unit failed its own run" } });
37472
37799
  }
37473
- var IDENT2, SUITE_ENV_KEYS, git8 = (dir, args) => safeGitSpawn(dir, [...IDENT2, ...args], { encoding: "utf8" });
37800
+ var IDENT3, SUITE_ENV_KEYS, git8 = (dir, args) => safeGitSpawn(dir, [...IDENT3, ...args], { encoding: "utf8" });
37474
37801
  var init_integrate = __esm(() => {
37475
37802
  init_wall();
37476
37803
  init_group_integrate();
37477
37804
  init_safe_git();
37478
- IDENT2 = ["-c", "user.name=loki-integrate", "-c", "user.email=integrate@loki.invalid", "-c", "commit.gpgSign=false"];
37805
+ IDENT3 = ["-c", "user.name=loki-integrate", "-c", "user.email=integrate@loki.invalid", "-c", "commit.gpgSign=false"];
37479
37806
  SUITE_ENV_KEYS = ["PATH", "HOME", "TMPDIR", "LANG", "LC_ALL", "CI", "LOKI_NO_BROWSER"];
37480
37807
  });
37481
37808
 
@@ -39116,9 +39443,10 @@ function epicOutcome(rows, planUsd = [], env = process.env) {
39116
39443
  const failed2 = rows.find((r) => !isBudget(r) && !/^(VERIFIED|PARTIAL|SKIPPED)/.test(r.outcome)), budget = rows.find(isBudget);
39117
39444
  const outcome = failed2 ? "FAILED" : budget ? "BUDGET_STOP" : rows.some((r) => /^PARTIAL/.test(r.outcome)) ? "PARTIAL" : "VERIFIED";
39118
39445
  const why = failed2 ?? budget ?? rows.find((r) => /^PARTIAL/.test(r.outcome));
39446
+ const prs = rows.filter((r) => r.pr).length, kept = why && !why.pr && why.branch ? `; ${why.id}'s change is on branch ${why.branch}` : "", got = (outcome === "FAILED" || outcome === "BUDGET_STOP") && prs > 0 ? ` (${prs} of ${rows.length} slices opened a PR${kept})` : "";
39119
39447
  const lines2 = [
39120
39448
  `${labelCol("Outcome")}${outcome}`,
39121
- ...why && outcome !== "VERIFIED" ? [`${labelCol("Reason")}slice ${why.id}: ${oneLine3(why.outcome)}`] : [],
39449
+ ...why && outcome !== "VERIFIED" ? [`${labelCol("Reason")}slice ${why.id}: ${oneLine3(why.outcome)}${got}`] : [],
39122
39450
  ...rows.filter((r) => r.pr).map((r) => `${labelCol("PR")}${r.pr}`),
39123
39451
  `${labelCol("Cost")}${splitCostText(splitCost(rows, planUsd))}`
39124
39452
  ];
@@ -42161,7 +42489,7 @@ ${r.stderr}`), lr = r.exitCode === 0 ? undefined : await harnessLoadReason({ rep
42161
42489
  notProven.add(`${NA_PREFIX}${name} (ran 0 tests on base and head; the Wall or a task-named check passed with executed tests)`);
42162
42490
  continue;
42163
42491
  }
42164
- checks.push({ name, cmd: [spec.cmd, ...spec.args].join(" "), result: cls.result, duration_s: durationS, ...cls.result === "fail" ? { ids: failIds(out2), first_error: firstError(out2), excerpt: failureExcerpt(out2, ctx.repoDir) } : {} });
42492
+ checks.push({ name, cmd: [spec.cmd, ...spec.args].join(" "), result: cls.result, duration_s: durationS, ...cls.result === "fail" ? { ids: failIds(out2), errors: Object.fromEntries(errorsById(out2)), ...unhandledBlock(out2).length ? { unhandled: unhandledBlock(out2) } : {}, first_error: firstError(out2), excerpt: failureExcerpt(out2, ctx.repoDir) } : {} });
42165
42493
  if (cls.result === "not_run")
42166
42494
  notProven.add(`not run: ${name} (${cls.reason ?? NO_TESTS_REASON})`);
42167
42495
  }
@@ -46557,6 +46885,7 @@ __export(exports_base_guard, {
46557
46885
  finishDeferredRun: () => finishDeferredRun,
46558
46886
  envChangedSince: () => envChangedSince,
46559
46887
  depsSeeHead: () => depsSeeHead,
46888
+ depsListing: () => depsListing,
46560
46889
  deepPid: () => deepPid,
46561
46890
  deepAlive: () => deepAlive,
46562
46891
  baseLine: () => baseLine,
@@ -46729,17 +47058,58 @@ function depsSeeHead(pkgDir, repoDir) {
46729
47058
  function lazyZeroBaseline(repoDir) {
46730
47059
  const raw2 = git13(repoDir, ["ls-files", "-z", "--others", "--ignored", "--exclude-standard", "--directory"]);
46731
47060
  const ignored = raw2 === null ? null : raw2.split("\x00").map((p) => p.replace(/\/$/, "")).filter((p) => p !== "" && p !== ".loki" && !p.startsWith(".loki/"));
46732
- return { lazy: true, since_ms: Date.now(), ignored: ignored && ignored.length <= IGNORED_CAP ? ignored : null };
47061
+ const deps = {};
47062
+ for (const rel of ignored ?? [])
47063
+ if (/(?:^|\/)(?:node_modules|\.venv)$/.test(rel))
47064
+ deps[rel] = depsListing(join143(repoDir, rel));
47065
+ return { lazy: true, since_ms: Date.now(), ignored: ignored && ignored.length <= IGNORED_CAP ? ignored : null, deps };
46733
47066
  }
46734
47067
  function zeroGate(rec2) {
46735
47068
  const z = rec2 && typeof rec2 === "object" ? rec2 : {};
46736
47069
  const strs5 = (v) => Array.isArray(v) ? v.filter((s) => typeof s === "string") : [];
46737
47070
  if (z.lazy === true && typeof z.since_ms === "number")
46738
- return { has: () => true, sinceMs: z.since_ms, ignored: Array.isArray(z.ignored) ? strs5(z.ignored) : null };
47071
+ return { has: () => true, sinceMs: z.since_ms, ignored: Array.isArray(z.ignored) ? strs5(z.ignored) : null, ...z.deps && typeof z.deps === "object" ? { deps: z.deps } : {} };
46739
47072
  const names = new Set(strs5(z.zero));
46740
47073
  return { has: (n3) => names.has(n3) };
46741
47074
  }
46742
- function envChangedSince(repoDir, pkgDir, sinceMs, ignored) {
47075
+ function depsListing(root) {
47076
+ const out2 = [], skip = (n3) => RUNNER_CACHE_DIRS.includes(n3) || n3 === "__pycache__";
47077
+ const list = (dir, prefix) => {
47078
+ for (const e of readdirSync45(dir, { withFileTypes: true })) {
47079
+ if (skip(e.name))
47080
+ continue;
47081
+ if (e.name.startsWith("@") && (e.isDirectory() || e.isSymbolicLink())) {
47082
+ try {
47083
+ list(join143(dir, e.name), `${prefix}${e.name}/`);
47084
+ continue;
47085
+ } catch {}
47086
+ }
47087
+ out2.push(prefix + e.name);
47088
+ if (out2.length > 50000)
47089
+ throw new RangeError("bound");
47090
+ }
47091
+ };
47092
+ try {
47093
+ list(root, "");
47094
+ for (const lib of ["lib", "lib64", "Lib"]) {
47095
+ const l = join143(root, lib);
47096
+ if (!existsSync98(l))
47097
+ continue;
47098
+ if (lib === "Lib") {
47099
+ if (existsSync98(join143(l, "site-packages")))
47100
+ list(join143(l, "site-packages"), "py/");
47101
+ continue;
47102
+ }
47103
+ for (const py of readdirSync45(l))
47104
+ if (/^python/.test(py) && existsSync98(join143(l, py, "site-packages")))
47105
+ list(join143(l, py, "site-packages"), "py/");
47106
+ }
47107
+ } catch {
47108
+ return null;
47109
+ }
47110
+ return out2.sort();
47111
+ }
47112
+ function envChangedSince(repoDir, pkgDir, sinceMs, ignored, deps) {
46743
47113
  if (ignored === null)
46744
47114
  return true;
46745
47115
  let stampDir = "";
@@ -46752,9 +47122,18 @@ function envChangedSince(repoDir, pkgDir, sinceMs, ignored) {
46752
47122
  if (!st.isDirectory())
46753
47123
  roots.push(join143(repoDir, rel));
46754
47124
  }
47125
+ const depRoots = [];
46755
47126
  for (const d of ["node_modules", ".venv"])
46756
- if (existsSync98(join143(pkgDir, d)))
47127
+ if (existsSync98(join143(pkgDir, d))) {
46757
47128
  roots.push(join143(pkgDir, d));
47129
+ depRoots.push(join143(pkgDir, d));
47130
+ }
47131
+ if (deps)
47132
+ for (const r of depRoots) {
47133
+ const was = deps[relative28(repoDir, r)], now2 = depsListing(r);
47134
+ if (!was || !now2 || was.length !== now2.length || was.some((n3, i) => n3 !== now2[i]))
47135
+ return true;
47136
+ }
46758
47137
  if (roots.length === 0)
46759
47138
  return false;
46760
47139
  stampDir = mkdtempSync19(join143(tmpdir25(), "loki-zero-stamp-"));
@@ -46762,8 +47141,12 @@ function envChangedSince(repoDir, pkgDir, sinceMs, ignored) {
46762
47141
  writeFileSync71(stamp2, "");
46763
47142
  utimesSync(stamp2, sinceMs / 1000, sinceMs / 1000);
46764
47143
  const prune = RUNNER_CACHE_DIRS.flatMap((n3, i) => [...i ? ["-o"] : [], "-name", n3]);
46765
- const out2 = execFileSync9("find", ["-P", ...new Set(roots), "(", ...prune, ")", "-prune", "-o", "-cnewer", stamp2, "-print", "-quit"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: 120000 });
46766
- return out2.trim() !== "";
47144
+ const out2 = execFileSync9("find", ["-P", ...new Set(roots), "(", ...prune, ")", "-prune", "-o", "(", "-type", "f", "-o", "-type", "l", ")", "-cnewer", stamp2, "-print", "-quit"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: 120000 });
47145
+ if (out2.trim() !== "")
47146
+ return true;
47147
+ const dirs = execFileSync9("find", ["-P", ...new Set(roots), "(", ...prune, ")", "-prune", "-o", "-type", "d", "-cnewer", stamp2, "-print"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: 120000, maxBuffer: 64 * 1024 * 1024 }).split(`
47148
+ `).filter(Boolean);
47149
+ return dirs.some((d) => !(roots.includes(d) || /(?:^|\/)site-packages$/.test(d) || RUNNER_CACHE_DIRS.concat("__pycache__").some((c) => existsSync98(join143(d, c)))));
46767
47150
  } catch {
46768
47151
  return true;
46769
47152
  } finally {
@@ -46788,7 +47171,7 @@ function baseDepsLinker(baseDir, repoDir, gate = {}) {
46788
47171
  return (cwd) => {
46789
47172
  const src = join143(repoDir, relative28(baseDir, cwd));
46790
47173
  if (!seen.has(src))
46791
- seen.set(src, !(depsSeeHead(src, repoDir) || gate.sinceMs !== undefined && envChangedSince(repoDir, src, gate.sinceMs, gate.ignored ?? null)));
47174
+ seen.set(src, !(depsSeeHead(src, repoDir) || gate.sinceMs !== undefined && envChangedSince(repoDir, src, gate.sinceMs, gate.ignored ?? null, gate.deps)));
46792
47175
  if (!seen.get(src))
46793
47176
  return false;
46794
47177
  for (const d of ["node_modules", ".venv"]) {
@@ -47065,7 +47448,7 @@ var init_base_guard = __esm(() => {
47065
47448
  init_test_file_text();
47066
47449
  init_stop_restore();
47067
47450
  REPO_LINK_FILE = /\.pth$|\.egg-link$|^direct_url\.json$|^__editable___.*_finder\.py$/;
47068
- RUNNER_CACHE_DIRS = [".vite", ".vitest", ".cache", "__pycache__", ".pytest_cache"];
47451
+ RUNNER_CACHE_DIRS = [".vite", ".vite-temp", ".vitest", ".vitest-cache", ".cache", "__pycache__", ".pytest_cache"];
47069
47452
  ADVISORY_PATH = /^(?:test configuration changed|runner config changed): (.+?)(?: \(.*\))?$|^symlink added by the change .*?\): (.+)$/;
47070
47453
  E10_BRANCH_RE = /^loki\/(e10-[A-Za-z0-9-]+)$/;
47071
47454
  RUN_TMP_WORKTREE_RE = /^(?:e10-base-|e10-loadown-|loki-mutproof-)/;
@@ -47095,9 +47478,11 @@ __export(exports_verify, {
47095
47478
  feedsFixRound: () => feedsFixRound,
47096
47479
  errorsById: () => errorsById,
47097
47480
  commandFor: () => commandFor,
47481
+ collateralTests: () => collateralTests,
47098
47482
  changedFiles: () => changedFiles,
47099
47483
  WALL_FAILURE_TAIL_FILE: () => WALL_FAILURE_TAIL_FILE,
47100
- WALL_FAILURE_TAIL_CAP: () => WALL_FAILURE_TAIL_CAP
47484
+ WALL_FAILURE_TAIL_CAP: () => WALL_FAILURE_TAIL_CAP,
47485
+ COLLATERAL_RED: () => COLLATERAL_RED
47101
47486
  });
47102
47487
  import { existsSync as existsSync99, mkdtempSync as mkdtempSync20, readFileSync as readFileSync125, realpathSync as realpathSync35, rmSync as rmSync38 } from "fs";
47103
47488
  import { tmpdir as tmpdir26 } from "os";
@@ -47123,6 +47508,13 @@ ${tail2(f.out)}
47123
47508
  return;
47124
47509
  }
47125
47510
  }
47511
+ function collateralTests(relevant2, named2) {
47512
+ const stems = new Set(named2.flatMap((f) => {
47513
+ const s = basename37(f).replace(/\.[^.]+$/, "");
47514
+ return /^(index|__init__|mod)$/.test(s) && f.includes("/") ? [s, basename37(f.slice(0, f.lastIndexOf("/")))] : [s];
47515
+ }));
47516
+ return relevant2.filter((t) => !named2.includes(t.path) && !stems.has(coveredStem(t.path)));
47517
+ }
47126
47518
  async function runOnce3(cmd2, args, cwd, signal, opts) {
47127
47519
  if (!Bun.which(cmd2, { PATH: opts.path ?? process.env["PATH"] ?? "" }))
47128
47520
  return { ok: false, missing: true, cut: false, out: "" };
@@ -47317,38 +47709,7 @@ function changedSymbolsFirst(ctx, tests, changed) {
47317
47709
  });
47318
47710
  return [...hits, ...tests.filter((t) => !hits.includes(t))];
47319
47711
  }
47320
- function errorsById(out2) {
47321
- const norm5 = (l) => l.replace(/\b\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?/g, "<ts>").replace(/\b\d{1,2}:\d{2}:\d{2}(?:\.\d+)?\b/g, "<ts>").replace(/(^|[\s(])\/(?:[\w.@-]+\/)*[\w.@-]+(?::\d+){0,2}/g, "$1<path>").replace(/\b\d+(?:\.\d+)?\s?(?:ms|s|us|\u00B5s|ns|min)\b/g, "<dur>").replace(/\s+/g, " ").trim();
47322
- const lines2 = stripAnsi(out2).split(`
47323
- `).map((l) => l.trim()), m = new Map, add3 = (id, e) => {
47324
- m.set(id, [...m.get(id) ?? [], e]);
47325
- };
47326
- for (const [i, l] of lines2.entries()) {
47327
- const py = /^FAILED (\S+::\S*) - (.+)$/.exec(l);
47328
- if (py) {
47329
- add3(py[1], norm5(py[2]));
47330
- continue;
47331
- }
47332
- const v = /^FAIL\s+(.+)$/.exec(l);
47333
- if (!v)
47334
- continue;
47335
- const next = lines2.slice(i + 1).find((x) => x !== "" && !/^FAIL\s/.test(x));
47336
- if (next !== undefined)
47337
- add3(v[1].trim(), norm5(next));
47338
- }
47339
- for (const [k, e] of m)
47340
- m.set(k, e.sort());
47341
- return m;
47342
- }
47343
- function sameErrors(head, base2, ids) {
47344
- const h = typeof head === "string" ? errorsById(head) : head, b = errorsById(base2), all = ids ?? [], eq2 = (x = [], y = []) => x.length === y.length && x.every((e, n3) => e === y[n3]);
47345
- const keys = (i) => h.has(i) ? [i] : [...h.keys()].filter((k) => k.endsWith(` > ${i}`));
47346
- return all.length > 0 && all.every((i) => {
47347
- const ks = keys(i);
47348
- return ks.length > 0 && ks.every((k) => eq2(b.get(k), h.get(k)));
47349
- });
47350
- }
47351
- async function subtractBase(ctx, api, checks, tests, changed, wall, rel, signal, zeroOk = true, zeroIntake = zeroGate(null), dep = new Set) {
47712
+ async function subtractBase(ctx, api, checks, tests, changed, wall, rel, signal, zeroOk = true, zeroIntake = zeroGate(null), dep = new Set, own = rel) {
47352
47713
  const out2 = { ids: [], names: [], knownRed: [], sameError: [], weak: [], zero: [], cnt: {} };
47353
47714
  const pairs = checks.flatMap((c) => {
47354
47715
  const t = tests.find((x) => testCheckName(x) === c.name);
@@ -47405,7 +47766,7 @@ async function subtractBase(ctx, api, checks, tests, changed, wall, rel, signal,
47405
47766
  const progress = checks.some((c) => wall.has(c.name) && c.result === "pass") || sus.some(({ c }) => !out2.weak.includes(c.name) && base2.get(c).red.length > 0 && (c.n ?? 0) >= base2.get(c).n);
47406
47767
  {
47407
47768
  for (const { c } of un) {
47408
- if (rel.has(c.name) || c.result !== "fail" || !c.ids?.length || !c.ids.every((i) => base2.get(c)?.red.includes(i)))
47769
+ if (own.has(c.name) || c.result !== "fail" || !c.ids?.length || !comparableIds(c.ids).every((i) => base2.get(c)?.red.includes(i)))
47409
47770
  continue;
47410
47771
  out2.knownRed.push(c.name);
47411
47772
  if (sameErrors(headErrors.get(c) ?? "", base2.get(c).out, c.ids))
@@ -47472,7 +47833,7 @@ async function runLintChecks(ctx, changed, signal, checks, opts = {}) {
47472
47833
  }
47473
47834
  return pre;
47474
47835
  }
47475
- var CHECK_TIMEOUT_MS = 60000, excerpts, suites, failTails, headErrors, WALL_FAILURE_TAIL_CAP = 16384, wallTailOf = (out2, repoDir) => redactSecrets(stripAnsi(out2).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}`, 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", feedsFixRound = (c, pre) => c.result === "fail" && !pre.names.includes(c.name) && !pre.sameError.includes(c.name) && !isHoldoutCheck(c.name), 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) => {
47836
+ var CHECK_TIMEOUT_MS = 60000, excerpts, suites, failTails, headErrors, WALL_FAILURE_TAIL_CAP = 16384, wallTailOf = (out2, repoDir) => redactSecrets(stripAnsi(out2).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}`, COLLATERAL_RED = "relevant test already failing on base, still failing the same tests (it imports a file the task names; capped, not blocking)", 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", feedsFixRound = (c, pre) => c.result === "fail" && !pre.names.includes(c.name) && !pre.sameError.includes(c.name) && !isHoldoutCheck(c.name), 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) => {
47476
47837
  if (signal.aborted)
47477
47838
  return null;
47478
47839
  const r = await runOnce3(cmd2, a, cwd, AbortSignal.any([signal, AbortSignal.timeout(opts.timeoutMs ?? CHECK_TIMEOUT_MS)]), { ...opts, ...stdin !== undefined ? { stdin } : {} });
@@ -47500,6 +47861,9 @@ var init_verify = __esm(() => {
47500
47861
  init_load_owner();
47501
47862
  init_sizing();
47502
47863
  init_testmap();
47864
+ init_test_file_text();
47865
+ init_failures();
47866
+ init_failures();
47503
47867
  init_check_result();
47504
47868
  init_wall_owned();
47505
47869
  init_holdout();
@@ -47557,7 +47921,7 @@ var init_verify = __esm(() => {
47557
47921
  const changedTestFiles = map.tests.filter((t) => changed.includes(t.path));
47558
47922
  const wall = ctx.outputs().wall ?? {};
47559
47923
  const wallPaths = new Set((wall.files ?? []).map((f) => isAbsolute21(f.path) ? relative29(ctx.repoDir, f.path) : f.path));
47560
- const intake = ctx.outputs().intake, repoMap = loadRepoMap(intake?.repomap_ref), relevant2 = ctx.tests.impacted(map, namedFiles(intake?.task ?? "", repoMap));
47924
+ const intake = ctx.outputs().intake, repoMap = loadRepoMap(intake?.repomap_ref), named2 = namedFiles(intake?.task ?? "", repoMap), relevant2 = ctx.tests.impacted(map, named2);
47561
47925
  const recorded = new Map((wall.files ?? []).flatMap((f) => f.runner ? [[isAbsolute21(f.path) ? relative29(ctx.repoDir, f.path) : f.path, f.runner]] : []));
47562
47926
  const wallTests = [...wallPaths].flatMap((p) => {
47563
47927
  const rec2 = recorded.get(p), found = map.tests.find((t) => t.path === p && (!rec2 || t.runner === rec2));
@@ -47613,8 +47977,8 @@ var init_verify = __esm(() => {
47613
47977
  if (!decisive)
47614
47978
  await runTests(split2.rest);
47615
47979
  const complete = !decisive;
47616
- const pg = (ctx.outputs().verify?.failures_grouped ?? []).map((g2) => g2.signature), fs2 = (x) => x.startsWith("full suite") || x.startsWith("lint:"), same = (a, b) => a.length === b.length && a.every((x, i) => x === b[i]);
47617
- const settle = decisive && pg.some((x) => x.startsWith("full suite")) && same(pg.filter((x) => !fs2(x)).sort(), checks.filter((c) => c.result === "fail" && !isHold(c)).map((c) => failureSignature(c)).sort());
47980
+ 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]);
47981
+ const settle = decisive && pg.some((x) => x.startsWith("full suite")) && same(failSigs(ctx.outputs().verify?.checks ?? []), failSigs(checks.filter((c) => !isHold(c))));
47618
47982
  const hold = wall.holdout_dir ? stageHoldout(wall.holdout_dir, ctx.repoDir) : null;
47619
47983
  if (hold && !hold.missing.length)
47620
47984
  holdN = hold.tests.length;
@@ -47638,8 +48002,19 @@ var init_verify = __esm(() => {
47638
48002
  }
47639
48003
  const targetNames = new Set([...[...wallTests, ...relevant2].map(testCheckName), ...checks.filter(isHold).map((c) => c.name)]);
47640
48004
  const cfgChanged = [...new Set([...testConfigChanged(ctx.repoDir, ctx.baseSha, changed), ...hiddenConfigChanged(ctx.repoDir, ctx.outputs().intake?.hidden_cfg)])];
47641
- 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);
47642
- 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)) })));
48005
+ const collateral = new Set(collateralTests(relevant2, named2).map(testCheckName)), ownRel = new Set([...relevant2.map(testCheckName)].filter((n3) => !collateral.has(n3)));
48006
+ 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);
48007
+ const fixRounds = Number(ctx.outputs().fix?.round ?? 0) || 0, collateralSame = preRed.sameError.filter((n3) => collateral.has(n3) && !preRed.names.includes(n3));
48008
+ const collateralRed = fixRounds >= 1 ? collateralSame : [];
48009
+ if (collateralRed.length) {
48010
+ preRed.names.push(...collateralRed);
48011
+ preRed.ids.push(...checks.filter((c) => collateralRed.includes(c.name)).flatMap((c) => c.ids ?? []));
48012
+ }
48013
+ const suiteOf = (name) => {
48014
+ const t = tests.find((x) => testCheckName(x) === name), pkg = t ? api?.packageOf(t.path) : null;
48015
+ return pkg?.commands.test ? `full suite: ${pkg.name}` : undefined;
48016
+ };
48017
+ 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.sameError.includes(c.name) ? { suite: suiteOf(c.name) } : {} })));
47643
48018
  attr.introducedChecks = [...new Set(attr.introducedChecks.map((n3) => isHoldoutCheck(n3) ? "holdout" : n3))];
47644
48019
  preRed.names.push(...attr.preExistingChecks);
47645
48020
  preRed.ids.push(...attr.preExistingIds);
@@ -47683,7 +48058,7 @@ var init_verify = __esm(() => {
47683
48058
  }
47684
48059
  const known = new Set(checks.filter((c) => c.result === "fail" && (preRed.sameError.includes(c.name) || wallNames0.has(c.name))).flatMap((c) => c.ids ?? []));
47685
48060
  for (const c of full)
47686
- if (c.result === "fail" && c.ids?.length && c.ids.every((i) => known.has(i)) && !preRed.names.includes(c.name)) {
48061
+ if (c.result === "fail" && c.ids?.length && !c.unhandled?.length && comparableIds(c.ids).every((i) => known.has(i)) && !preRed.names.includes(c.name)) {
47687
48062
  preRed.knownRed.push(c.name);
47688
48063
  preRed.sameError.push(c.name);
47689
48064
  }
@@ -47706,7 +48081,7 @@ var init_verify = __esm(() => {
47706
48081
  const covered = (f) => ctx.tests.impacted(map, [f]).some((t) => checks.some((c) => c.name === testCheckName(t) && hasExecutedProof([c])));
47707
48082
  const uncoveredChanged = changed.filter((f) => CODE_FILE_EXT.test(f) && !isTestFile(f) && !wallPaths.has(f) && !cfgChanged.includes(f) && !covered(f));
47708
48083
  const flaky = checks.filter((c) => c.result === "flaky").map((c) => isHold(c) ? "holdout" : c.name);
47709
- const { groups: failuresGrouped, names: blockingNames } = briefGroups(checks.filter((c) => feedsFixRound(c, preRed)), (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);
48084
+ const { groups: failuresGrouped, names: blockingNames } = briefGroups(checks.filter((c) => feedsFixRound(c, preRed) || fixRounds === 0 && collateralSame.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);
47710
48085
  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;
47711
48086
  const inBase = (f) => {
47712
48087
  try {
@@ -47723,12 +48098,12 @@ var init_verify = __esm(() => {
47723
48098
  testCounts[t.path] = k;
47724
48099
  return [`weakened test: ${t.path}`, ...assertDeltaNotes(ctx.repoDir, ctx.baseSha, null, t.path, intake?.task ?? "", k?.b, k?.h) ?? []];
47725
48100
  });
47726
- const weakened = [...modifiedRel, ...cfgChanged.map((f) => `test configuration changed: ${f}`), ...preRed.weak.map((n3) => `skipped or fewer tests than base: ${n3}`)];
48101
+ 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}`)];
47727
48102
  const notProven = [...complete ? [] : [QUICK_ONLY_NOTE], ...weakened, ...hiddenEdits(ctx.repoDir), ...ignoreRuleChanges(ctx.repoDir, intake?.ignore_snapshot, ctx.baseSha), ...dependentNotes(dep), ...intake?.deps_not_proven ?? [], ...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"))];
47728
48103
  const wallDropped = [...wallPaths].filter((p) => !wallTests.some((t) => t.path === p));
47729
48104
  notProven.push(...wallDropped.map((p) => `Wall test not executed: ${p}: ${NO_RUNNER_REASON}`));
47730
48105
  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;
47731
- return { status: "completed", data: { checks: pub, flaky, verify_scope: complete ? "complete" : "quick", file_hashes: hashes, blocking_checks: blockingNames, ...wallFailTail ? { wall_failure_tail: wallFailTail } : {}, ...wallPassed === undefined ? {} : { wall_passed: wallPassed }, failures_grouped: failuresGrouped, holdout_failed: holdoutFailed, changed_files: changed, ...depNames.size ? { dependent_checks: [...depNames] } : {}, not_proven: notProven, ...fullNotProven.size ? { not_applicable: [...fullNotProven].filter(naNote).map(naText) } : {}, pre_red: preRed.ids, pre_red_checks: preRed.names, ...preRed.knownRed.length ? { known_red_checks: preRed.knownRed } : {}, ...preRed.sameError.length ? { known_red_same_error: preRed.sameError } : {}, skipped_on_base: preRed.zero, ...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 } };
48106
+ return { status: "completed", data: { checks: pub, flaky, verify_scope: complete ? "complete" : "quick", file_hashes: hashes, blocking_checks: blockingNames, ...wallFailTail ? { wall_failure_tail: wallFailTail } : {}, ...wallPassed === undefined ? {} : { wall_passed: wallPassed }, failures_grouped: failuresGrouped, holdout_failed: holdoutFailed, changed_files: changed, ...depNames.size ? { dependent_checks: [...depNames] } : {}, not_proven: notProven, ...fullNotProven.size ? { not_applicable: [...fullNotProven].filter(naNote).map(naText) } : {}, pre_red: preRed.ids, pre_red_checks: preRed.names, ...preRed.knownRed.length ? { known_red_checks: preRed.knownRed } : {}, ...preRed.sameError.length ? { known_red_same_error: preRed.sameError } : {}, 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 } };
47732
48107
  }
47733
48108
  };
47734
48109
  stage9 = verifyStage;
@@ -89786,11 +90161,11 @@ ${CONFLICT_CORRECTION}`, ...sid ? { resumeSessionId: sid } : {} });
89786
90161
  const durationS = firstSession.durationS + session.durationS;
89787
90162
  return { session: { ...terminal ? session : firstSession, durationS }, iterationId };
89788
90163
  }
89789
- async function resumeAfterEmptyDone(ctx, first, firstSession) {
89790
- const iterationId = `${first.iterationId}-e`, sid = ctx.provider === "claude" ? readSessionId(ctx.repoDir, first.iterationId) : null;
89791
- const session = await ctx.sessions.run({ ...first, iterationId, brief: sid ? EMPTY_DONE_CORRECTION : `${first.brief}
90164
+ async function resumeWith(ctx, first, firstSession, correction, suffix) {
90165
+ const iterationId = `${first.iterationId}${suffix}`, sid = ctx.provider === "claude" ? readSessionId(ctx.repoDir, first.iterationId) : null;
90166
+ const session = await ctx.sessions.run({ ...first, iterationId, brief: sid ? correction : `${first.brief}
89792
90167
 
89793
- ${EMPTY_DONE_CORRECTION}`, ...sid ? { resumeSessionId: sid } : {} });
90168
+ ${correction}`, ...sid ? { resumeSessionId: sid } : {} });
89794
90169
  const terminal = !session.killed && (session.markers.done || session.markers.alreadyDone !== null || session.markers.specConflict !== null);
89795
90170
  return { session: { ...terminal ? session : firstSession, durationS: firstSession.durationS + session.durationS }, iterationId };
89796
90171
  }
@@ -90117,7 +90492,7 @@ async function deliverOverWallConflict(o, repoDir, reverify, emit, opts = {}) {
90117
90492
  o.implement = { ...o.implement, exit: "done", conflict_delivered: files };
90118
90493
  return files;
90119
90494
  }
90120
- var refereeModel = (ctx) => capToRunTier(wallPinModel(), ctx.model, ["LOKI_E10_WALL_TIER", "LOKI_MODEL_OVERRIDE"]), AFTER_PLAN, FROM_PLAN, CONFLICT_CORRECTION, RESUME_MIN_LEFT_S = 60, EMPTY_DONE_CORRECTION, oneLine4 = (s) => s.replace(/[\u0000-\u001f\u007f]+/g, " ").trim().slice(0, 200), REFEREE_PER_CHECK = 1, REFEREE_PER_RUN = 2, wallRefereeEnabled = (env = process.env) => !["0", "off", "false"].includes((env.LOKI_E10_WALL_REFEREE ?? "").toLowerCase()), defaultRunCheck = (dir, ref) => {
90495
+ var refereeModel = (ctx) => capToRunTier(wallPinModel(), ctx.model, ["LOKI_E10_WALL_TIER", "LOKI_MODEL_OVERRIDE"]), AFTER_PLAN, FROM_PLAN, CONFLICT_CORRECTION, RESUME_MIN_LEFT_S = 60, EMPTY_DONE_HEAD = "Your session finished with LOKI_DONE but the working tree has no change against the base. Make the change the task asks for, or if the task is already satisfied finish with LOKI_ALREADY_DONE: <file:line evidence>, or if the task itself conflicts finish with LOKI_SPEC_CONFLICT: <reason; cite test as path:line>. ", EMPTY_DONE_CORRECTION, CHALLENGE_STEP = "A task's example code can encode the current, wrong behaviour (expected lines commented out, or asserting today's output), so passing it is not evidence. Reproduce the problem the task's prose describes with a check of the behaviour it asks for. If that check fails on the current code, make the change and finish with LOKI_DONE. Only if the described behaviour already holds, finish with LOKI_ALREADY_DONE: <file:line evidence of that behaviour>. ", ALREADY_DONE_CHALLENGE, REDO_CHALLENGE, EMPTY_DONE_CHALLENGED, resumeAfterEmptyDone = (ctx, first, firstSession, challenge = false) => resumeWith(ctx, first, firstSession, challenge ? EMPTY_DONE_CHALLENGED : EMPTY_DONE_CORRECTION, "-e"), resumeAfterAlreadyDone = (ctx, first, firstSession) => resumeWith(ctx, first, firstSession, ALREADY_DONE_CHALLENGE, "-a"), oneLine4 = (s) => s.replace(/[\u0000-\u001f\u007f]+/g, " ").trim().slice(0, 200), REFEREE_PER_CHECK = 1, REFEREE_PER_RUN = 2, wallRefereeEnabled = (env = process.env) => !["0", "off", "false"].includes((env.LOKI_E10_WALL_REFEREE ?? "").toLowerCase()), defaultRunCheck = (dir, ref) => {
90121
90496
  const r = new RealBaseTestRunner(undefined, undefined, { PYTHONDONTWRITEBYTECODE: "1" }).run(dir, [ref]);
90122
90497
  return r.fail > 0 ? "fail" : r.pass > 0 && (r.not_run ?? 0) === 0 ? "pass" : "not_run";
90123
90498
  }, readJson9 = (p) => {
@@ -90155,7 +90530,10 @@ var init_conflict_resume = __esm(() => {
90155
90530
  AFTER_PLAN = ["implement", "fix", "verify", "commit", "seal", "pr"];
90156
90531
  FROM_PLAN = ["plan", ...AFTER_PLAN];
90157
90532
  CONFLICT_CORRECTION = "Loki imposes no file or test limits on you. If your conflict is only about Loki's own rules, finish the task. If the task itself conflicts, restate the conflict. " + FINISH_LINE;
90158
- EMPTY_DONE_CORRECTION = "Your session finished with LOKI_DONE but the working tree has no change against the base. Make the change the task asks for, or if the task is already satisfied finish with LOKI_ALREADY_DONE: <file:line evidence>, or if the task itself conflicts finish with LOKI_SPEC_CONFLICT: <reason; cite test as path:line>. " + FINISH_LINE;
90533
+ EMPTY_DONE_CORRECTION = EMPTY_DONE_HEAD + FINISH_LINE;
90534
+ ALREADY_DONE_CHALLENGE = "You finished with LOKI_ALREADY_DONE without changing anything. " + CHALLENGE_STEP + FINISH_LINE;
90535
+ REDO_CHALLENGE = "An earlier session claimed LOKI_ALREADY_DONE without changing anything. Before you claim it too: " + CHALLENGE_STEP + FINISH_LINE;
90536
+ EMPTY_DONE_CHALLENGED = EMPTY_DONE_HEAD + "Before you claim LOKI_ALREADY_DONE: " + CHALLENGE_STEP + FINISH_LINE;
90159
90537
  });
90160
90538
 
90161
90539
  // ../../loki-ts/src/util/run_outputs.ts