loki-mode 11.161.0 → 11.163.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 (73) hide show
  1. package/SKILL.md +2 -2
  2. package/VERSION +1 -1
  3. package/autonomy/loki +24 -1
  4. package/autonomy/route.sh +12 -5
  5. package/bin/loki +1 -0
  6. package/dashboard/__init__.py +1 -1
  7. package/docs/CLI-REFERENCE.md +1 -1
  8. package/docs/INSTALLATION.md +1 -1
  9. package/docs/cost-controls.md +26 -2
  10. package/docs/dev/architecture-reference.md +2 -0
  11. package/docs/environment-variables.md +9 -1
  12. package/loki-ts/dist/loki.js +1970 -1952
  13. package/mcp/__init__.py +1 -1
  14. package/package.json +2 -2
  15. package/packages/control-plane/dist/server.js +378 -148
  16. package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
  17. package/web-app/dist/assets/{AdminPage-CuV3jwO8.js → AdminPage-Dc_e8C_g.js} +1 -1
  18. package/web-app/dist/assets/{Avatar-fwxJYmU0.js → Avatar-CtkU_V8o.js} +1 -1
  19. package/web-app/dist/assets/{Badge-C-16U-fv.js → Badge-10lwViZy.js} +1 -1
  20. package/web-app/dist/assets/{Button-DFjWZzwM.js → Button-D9wLMuKV.js} +1 -1
  21. package/web-app/dist/assets/{CockpitPage-BMe0TFba.js → CockpitPage-B4P679NA.js} +1 -1
  22. package/web-app/dist/assets/{ComparePage-BGNs7d0W.js → ComparePage-CFvw6yC-.js} +1 -1
  23. package/web-app/dist/assets/{ErrorBoundary-Dg4jYVbI.js → ErrorBoundary-B8b7m5zw.js} +1 -1
  24. package/web-app/dist/assets/{EvidenceReceiptPanel-BPiK4shg.js → EvidenceReceiptPanel-BSveU6Uc.js} +1 -1
  25. package/web-app/dist/assets/{GitHubIssuesPanel-Bj73V3QA.js → GitHubIssuesPanel-CQgbdmxS.js} +1 -1
  26. package/web-app/dist/assets/{GitHubPRsPanel-BbmTPafH.js → GitHubPRsPanel-BulOGtWs.js} +1 -1
  27. package/web-app/dist/assets/{HomePage-_kzSwCXX.js → HomePage-C61Gquuw.js} +2 -2
  28. package/web-app/dist/assets/{LoginPage-D3guOsi2.js → LoginPage-CylrcuLY.js} +1 -1
  29. package/web-app/dist/assets/{MagicPage-SWoVP7OY.js → MagicPage-C4gLb8Be.js} +1 -1
  30. package/web-app/dist/assets/{MetricsPage-BogKy2pu.js → MetricsPage-BhmaQzNp.js} +1 -1
  31. package/web-app/dist/assets/{NotFoundPage-CQiT_FXs.js → NotFoundPage-Bxex3oMK.js} +1 -1
  32. package/web-app/dist/assets/{ProjectPage-CZ_hFP38.js → ProjectPage-BC2BHkRl.js} +3 -3
  33. package/web-app/dist/assets/{ProjectsPage-Bq-oT_Pe.js → ProjectsPage-CRddx1WM.js} +1 -1
  34. package/web-app/dist/assets/{SettingsPage-DSr6lHmq.js → SettingsPage-DXStgGb0.js} +1 -1
  35. package/web-app/dist/assets/{ShowcasePage-Dqjj3rgJ.js → ShowcasePage-BsiVhy1_.js} +1 -1
  36. package/web-app/dist/assets/{SystemSettingsPage-scRs0fQ3.js → SystemSettingsPage-Cvc2Rv6L.js} +1 -1
  37. package/web-app/dist/assets/{TeamsPage-BhLTiTJf.js → TeamsPage-DZ5qGheQ.js} +1 -1
  38. package/web-app/dist/assets/{TemplatesPage-CfLqFEwD.js → TemplatesPage-DWGts6xb.js} +1 -1
  39. package/web-app/dist/assets/{TerminalOutput-LEdtHTdQ.js → TerminalOutput-D_yJifgE.js} +1 -1
  40. package/web-app/dist/assets/{activity-CIE6E4sw.js → activity-DBFtxB4p.js} +1 -1
  41. package/web-app/dist/assets/{bell-CbXNt0VT.js → bell-BQBgmaZT.js} +1 -1
  42. package/web-app/dist/assets/{bot-DBilu5by.js → bot-D85VQ4wc.js} +1 -1
  43. package/web-app/dist/assets/{check-ByCaYntD.js → check-CnDR2u8p.js} +1 -1
  44. package/web-app/dist/assets/{chevron-left-lmByeTlW.js → chevron-left-BTY-4Si9.js} +1 -1
  45. package/web-app/dist/assets/{circle-alert-DKEPsx9y.js → circle-alert-uZfharAW.js} +1 -1
  46. package/web-app/dist/assets/{clock-t4QPQ9P1.js → clock-Dgg4J30J.js} +1 -1
  47. package/web-app/dist/assets/{cloud-YfbBdG9Y.js → cloud-YR8Y1Mof.js} +1 -1
  48. package/web-app/dist/assets/{code-xml-DUdvGh42.js → code-xml-Bf-AzxR8.js} +1 -1
  49. package/web-app/dist/assets/{database-DMsUwuu7.js → database-CzNb9ch2.js} +1 -1
  50. package/web-app/dist/assets/{dollar-sign-CQj8ulH4.js → dollar-sign-CkqzDdZe.js} +1 -1
  51. package/web-app/dist/assets/{file-code-corner-Dcun8Ito.js → file-code-corner-B2lhA9eJ.js} +1 -1
  52. package/web-app/dist/assets/{file-plus-BipK8vSI.js → file-plus-A0KdDFJa.js} +1 -1
  53. package/web-app/dist/assets/{globe-0GE20vx4.js → globe-CdOgdSGt.js} +1 -1
  54. package/web-app/dist/assets/{hammer-BSCC-aCx.js → hammer-Ccos8dOi.js} +1 -1
  55. package/web-app/dist/assets/{index-uBPpPPl7.js → index-Cn-3Kqbn.js} +3 -3
  56. package/web-app/dist/assets/{layers-BT6Akh8A.js → layers-BOnmEKlQ.js} +1 -1
  57. package/web-app/dist/assets/{loader-circle-BSF5o6lv.js → loader-circle-DPrX5ziD.js} +1 -1
  58. package/web-app/dist/assets/{lock-DhvY9ErS.js → lock-BqFyS1O4.js} +1 -1
  59. package/web-app/dist/assets/{package-BMUewVpu.js → package-CGzYc35X.js} +1 -1
  60. package/web-app/dist/assets/{plus-JcYGK4QC.js → plus-DEj-ibGp.js} +1 -1
  61. package/web-app/dist/assets/{refresh-cw-BSMX6sVQ.js → refresh-cw-B173UvaC.js} +1 -1
  62. package/web-app/dist/assets/{rotate-ccw-I5qSLfsL.js → rotate-ccw-DDS3YEAZ.js} +1 -1
  63. package/web-app/dist/assets/{scroll-text-DQ8wk3hX.js → scroll-text-zI5mkC8X.js} +1 -1
  64. package/web-app/dist/assets/{server-P6nlJ6_y.js → server-C6gc5oLW.js} +1 -1
  65. package/web-app/dist/assets/{shield-alert-DJXz2Y6G.js → shield-alert-g9_8A5VX.js} +1 -1
  66. package/web-app/dist/assets/{thumbs-up-BlLS0TcM.js → thumbs-up-B5zNvs0q.js} +1 -1
  67. package/web-app/dist/assets/{trash-2-2-LU0vyX.js → trash-2-C_4D6pb9.js} +1 -1
  68. package/web-app/dist/assets/{trending-down-DBVjyJy7.js → trending-down-C187ygzx.js} +1 -1
  69. package/web-app/dist/assets/{trending-up-Dbz8-n-y.js → trending-up-Bdr0BHTs.js} +1 -1
  70. package/web-app/dist/assets/{upload-CbP9Qhau.js → upload-CFkle0ZZ.js} +1 -1
  71. package/web-app/dist/assets/{usePolling-Br1am1Wv.js → usePolling-CXnCA3Yj.js} +1 -1
  72. package/web-app/dist/assets/{user-B43gT1q9.js → user-BZ9wfmTQ.js} +1 -1
  73. package/web-app/dist/index.html +1 -1
@@ -14610,6 +14610,94 @@ var init_retry_class = __esm(() => {
14610
14610
  CAUSE_FIX_DEFAULT = { auth: "re-authenticate the provider CLI (see `loki doctor`)", quota_exhausted: "add credit to the provider account or wait for the plan reset" };
14611
14611
  });
14612
14612
 
14613
+ // ../../loki-ts/src/engine10/types.ts
14614
+ function armTimer(fn, ms, o = {}) {
14615
+ let t = null, done = false;
14616
+ if (!Number.isFinite(ms) && ms > 0)
14617
+ return { clear: () => {} };
14618
+ const due = Date.now() + Math.max(0, Number.isFinite(ms) ? ms : 0);
14619
+ const arm = () => {
14620
+ const left = due - Date.now();
14621
+ t = setTimeout(() => {
14622
+ if (done)
14623
+ return;
14624
+ if (due - Date.now() > 0 && left > MAX_TIMER_MS)
14625
+ arm();
14626
+ else {
14627
+ done = true;
14628
+ fn();
14629
+ }
14630
+ }, Math.min(Math.max(0, left), MAX_TIMER_MS));
14631
+ if (o.unref)
14632
+ t.unref?.();
14633
+ };
14634
+ arm();
14635
+ return { clear: () => {
14636
+ done = true;
14637
+ if (t)
14638
+ clearTimeout(t);
14639
+ } };
14640
+ }
14641
+ function warnBadCap(source, raw2) {
14642
+ const key = `${source}=${raw2}`;
14643
+ if (warnedCap.has(key))
14644
+ return;
14645
+ warnedCap.add(key);
14646
+ process.stderr.write(`loki: ignoring invalid ${source}="${raw2}" (need a number > 0); using the default cap of ${DEFAULT_CAP_S}s
14647
+ `);
14648
+ }
14649
+ function envCapS(raw2) {
14650
+ if (raw2 === undefined || raw2.trim() === "")
14651
+ return null;
14652
+ const n3 = Number(raw2);
14653
+ if (Number.isFinite(n3) && n3 > 0)
14654
+ return n3;
14655
+ warnBadCap("LOKI_E10_CAP_S", raw2);
14656
+ return null;
14657
+ }
14658
+ function backstopS(capS, graceS = BACKSTOP_GRACE_S) {
14659
+ return capS - Math.min(graceS, capS / 30);
14660
+ }
14661
+ function pushArgv(a) {
14662
+ switch (a.cmd) {
14663
+ case "push-pr":
14664
+ return ["push-pr", a.repoDir, a.branch, a.title, a.bodyFile, a.draft ? "1" : "0"];
14665
+ case "comment":
14666
+ return ["comment", a.runId, a.prUrl, a.file];
14667
+ case "status":
14668
+ return ["status", a.sha, a.state, a.description];
14669
+ case "issue-comment":
14670
+ return a.update ? ["issue-comment", "--update", a.issueRef, a.bodyFile] : ["issue-comment", a.issueRef, a.bodyFile];
14671
+ }
14672
+ }
14673
+ function taskBlock(task) {
14674
+ return ["Task (untrusted, quoted verbatim):", "<<<TASK", task, "TASK"];
14675
+ }
14676
+ var STAGE_BUDGETS, DEFAULT_CAP_S = 900, DEEP_CAP_S = 2700, defaultBudgetsOn = (env = process.env) => /^(1|on|true|yes)$/i.test((env["LOKI_E10_DEFAULT_BUDGETS"] ?? "").trim()), budgetsOn = (env = process.env) => defaultBudgetsOn(env) || (env["LOKI_E10_CAP_S"] ?? "").trim() !== "", posEnv = (raw2, dflt) => {
14677
+ const n3 = Number((raw2 ?? "").trim());
14678
+ return (raw2 ?? "").trim() !== "" && Number.isFinite(n3) && n3 > 0 ? n3 : dflt;
14679
+ }, NO_PROGRESS_ROUNDS = 2, noProgressRounds = (env = process.env) => Math.floor(posEnv(env["LOKI_E10_NO_PROGRESS_ROUNDS"], NO_PROGRESS_ROUNDS)), SILENCE_KILL_S = 1800, LOOP_KILL_S = 3600, loopKillS = (env = process.env) => posEnv(env["LOKI_E10_LOOP_KILL_S"], LOOP_KILL_S), cmdSilenceS = (env = process.env) => posEnv(env["LOKI_E10_CMD_SILENCE_S"], SILENCE_KILL_S), HANG_SILENCE_S = 1800, hangSilenceS = (env = process.env) => posEnv(env["LOKI_E10_HANG_SILENCE_S"], HANG_SILENCE_S), MAX_TIMER_MS, warnedCap, BACKSTOP_GRACE_S = 30, DEEP_IMPLEMENT_LIMIT_S = 1800, MAX_FIX_ROUNDS = 2, VERIFY_STOPPED_NOTE, ROUTER_COST_FIELDS, FINISH_LINE = "Finish with exactly one line: LOKI_DONE, or LOKI_ALREADY_DONE: <file:line evidence>, or LOKI_SPEC_CONFLICT: <reason; cite test as path:line>.", ISSUE_FINISH_LINE = "Finish with exactly one line: LOKI_DONE, or LOKI_ALREADY_DONE: <file:line evidence>, or LOKI_SPEC_CONFLICT: <reason; cite test as path:line>, or LOKI_UNFINISHED: <what is left> when something the issue requires is not delivered. An item the issue marks optional is not required: do it or skip it, say which in your reply, and still finish with LOKI_DONE. Use LOKI_SPEC_CONFLICT only when a test in the repository contradicts the task.", taskWording = (s) => s.replace(/\bThis is an issue\b/g, "This is a task").replace(/\bThis issue\b/g, "This task").replace(/\bthe issue\b/g, "the task"), TEXT_FINISH_LINE, proveByRunningOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_PROVE_BY_RUNNING"] ?? "").trim()), WORK_ROAD_ENV = "LOKI_E10_WORK_ROAD", workRoadOn = (env = process.env) => env[WORK_ROAD_ENV] === "1", issueRunBrief = (provider, source, env = process.env) => provider === "claude" && (source === "issue" || source === "text" && workRoadOn(env)) && proveByRunningOn(env);
14680
+ var init_types2 = __esm(() => {
14681
+ STAGE_BUDGETS = {
14682
+ intake: { targetS: 15, limitS: 60 },
14683
+ plan: { targetS: 45, limitS: 90 },
14684
+ wall: { targetS: 45, limitS: 90 },
14685
+ implement: { targetS: 180, limitS: 480 },
14686
+ prove: { targetS: 300, limitS: 3600 },
14687
+ verify: { targetS: 60, limitS: 120 },
14688
+ fix: { targetS: 90, limitS: 180 },
14689
+ commit: { targetS: 5, limitS: 30 },
14690
+ seal: { targetS: 15, limitS: 60 },
14691
+ pr: { targetS: 15, limitS: 60 },
14692
+ deep: { targetS: null, limitS: 2700 }
14693
+ };
14694
+ MAX_TIMER_MS = 2 ** 31 - 1;
14695
+ warnedCap = new Set;
14696
+ VERIFY_STOPPED_NOTE = { limit: "verify stopped at its time limit before all checks ran", cap: "verify stopped at the run time cap before all checks ran" };
14697
+ ROUTER_COST_FIELDS = ["requests_total", "requests_over_100k", "advisor_calls", "advisor_input_tokens", "advisor_output_tokens"];
14698
+ TEXT_FINISH_LINE = taskWording(ISSUE_FINISH_LINE);
14699
+ });
14700
+
14613
14701
  // ../../loki-ts/src/runner/worker_proc.ts
14614
14702
  import { spawn as spawn7, spawnSync as spawnSync2 } from "child_process";
14615
14703
  import { createInterface } from "readline";
@@ -14659,7 +14747,11 @@ function maxTurnsFor(limitS, env) {
14659
14747
  return Number.isInteger(user) && user > 0 ? user : Math.max(MIN_TURNS, Math.ceil(limitS / SECONDS_PER_TURN));
14660
14748
  }
14661
14749
  function clampBashTimeoutEnv(env, limitS) {
14662
- env["LOKI_E10_MAX_TURNS"] = String(maxTurnsFor(limitS, env));
14750
+ const turns = maxTurnsFor(limitS, env);
14751
+ if (Number.isFinite(turns))
14752
+ env["LOKI_E10_MAX_TURNS"] = String(turns);
14753
+ else
14754
+ delete env["LOKI_E10_MAX_TURNS"];
14663
14755
  const budget = Math.max(BASH_CLAMP_FLOOR_MS, Math.floor(limitS * 1000) - BASH_CLAMP_MARGIN_MS);
14664
14756
  for (const [k, dflt] of [["BASH_DEFAULT_TIMEOUT_MS", 120000], ["BASH_MAX_TIMEOUT_MS", 600000]]) {
14665
14757
  const cur = Number(env[k]);
@@ -14689,7 +14781,15 @@ function ulimitArgv(argv, env) {
14689
14781
  const script = `${set.map(([, flag], i) => `ulimit ${flag} "$${i + 1}"`).join(" && ")} || { printf '%s\\n' '${why}' >&2; exit ${ULIMIT_REFUSED_EXIT}; }; shift ${set.length}; exec "$@"`;
14690
14782
  return [LIMIT_SHELL, "-c", script, "sh", ...values, ...argv];
14691
14783
  }
14692
- function spawnWorker(argv, env, cwd, backstopMs, escalateMs, onLine, onStopped = () => {}) {
14784
+ function hasChildProcess(pid) {
14785
+ try {
14786
+ const r = spawnSync2("pgrep", ["-P", String(pid)], { encoding: "utf8", timeout: 5000 });
14787
+ return r.status === 1 && r.stdout.trim() === "" ? false : true;
14788
+ } catch {
14789
+ return true;
14790
+ }
14791
+ }
14792
+ function spawnWorker(argv, env, cwd, backstopMs, escalateMs, onLine, hang, onStopped = () => {}) {
14693
14793
  return new Promise((resolve11) => {
14694
14794
  if (!argv[0])
14695
14795
  return resolve11({ code: null, killed: false });
@@ -14772,6 +14872,9 @@ function spawnWorker(argv, env, cwd, backstopMs, escalateMs, onLine, onStopped =
14772
14872
  globalThis[Symbol.for("loki.ownsStopSignals")] = false;
14773
14873
  for (const t of timers)
14774
14874
  clearTimeout(t);
14875
+ backstop.clear();
14876
+ if (hangBeat)
14877
+ clearInterval(hangBeat);
14775
14878
  rl.close();
14776
14879
  child.stdout?.destroy();
14777
14880
  if (fwd && child.stderr) {
@@ -14783,13 +14886,24 @@ function spawnWorker(argv, env, cwd, backstopMs, escalateMs, onLine, onStopped =
14783
14886
  }
14784
14887
  killGroup2(child.pid, "SIGKILL");
14785
14888
  onStopped(cancelled2 !== undefined);
14786
- resolve11({ code, killed, ...cancelled2 ? { cancelled: cancelled2 } : {} });
14889
+ resolve11({ code, killed, ...cancelled2 ? { cancelled: cancelled2 } : {}, ...hung ? { hung: true } : {} });
14787
14890
  };
14788
- timers.push(setTimeout(() => {
14891
+ const stopWorker = () => {
14892
+ if (killed)
14893
+ return;
14789
14894
  killed = true;
14790
14895
  killGroup2(child.pid, "SIGTERM");
14791
14896
  timers.push(setTimeout(() => killGroup2(child.pid, "SIGKILL"), escalateMs));
14792
- }, backstopMs));
14897
+ };
14898
+ const backstop = armTimer(stopWorker, backstopMs);
14899
+ let hung = false;
14900
+ const hangBeat = hang ? setInterval(() => {
14901
+ if (!killed && Date.now() - hang.lastEventMs() >= hang.silenceS * 1000 && child.pid !== undefined && !hasChildProcess(child.pid)) {
14902
+ hung = true;
14903
+ stopWorker();
14904
+ }
14905
+ }, Math.max(100, Math.min(HANG_POLL_MS, Math.floor(hang.silenceS * 500)))) : null;
14906
+ hangBeat?.unref();
14793
14907
  child.on("error", () => finish2(null));
14794
14908
  child.on("exit", (code) => {
14795
14909
  const drained = () => (child.stdout?.readableEnded ?? true) && (!fwd || (child.stderr?.readableEnded ?? true));
@@ -15022,7 +15136,7 @@ var CANCEL_GRACE_MS, DRAIN_MS = 2000, KILL_GRACE_MS2 = 2000, BASH_CLAMP_FLOOR_MS
15022
15136
  } catch {
15023
15137
  return false;
15024
15138
  }
15025
- }, SAFE_BUN_FLAGS, ULIMIT_REFUSED_EXIT = 97, LIMIT_SHELL, ULIMIT_KNOBS, forwardsWorkerStderr = (stream = process.stderr) => stream.isTTY === true && globalThis[Symbol.for("loki.consoleOwnsTerminal")] === true, EXIT_CAUSES, SCRATCH_MARKER = ".loki-scratch-owned", SCRATCH_RECORD = "scratch.json", OWNER_ENV = "LOKI_RUN_OWNER", TASK_MEMORY_SUBDIR = "task-memory", scratchSessionEnv = (s) => ({ LOKI_SCRATCH: s.dir, LOKI_SCRATCH_SINCE: String(s.since), TMPDIR: s.dir, [OWNER_ENV]: s.nonce }), psOut = (args, timeout = 4000) => spawnSync2("ps", args, { encoding: "utf8", env: { PATH: process.env["PATH"] ?? "/usr/bin:/bin", LC_ALL: "C", TZ: "UTC" }, timeout }).stdout ?? "", alive = (pid) => {
15139
+ }, SAFE_BUN_FLAGS, ULIMIT_REFUSED_EXIT = 97, LIMIT_SHELL, ULIMIT_KNOBS, forwardsWorkerStderr = (stream = process.stderr) => stream.isTTY === true && globalThis[Symbol.for("loki.consoleOwnsTerminal")] === true, HANG_POLL_MS = 30000, EXIT_CAUSES, SCRATCH_MARKER = ".loki-scratch-owned", SCRATCH_RECORD = "scratch.json", OWNER_ENV = "LOKI_RUN_OWNER", TASK_MEMORY_SUBDIR = "task-memory", scratchSessionEnv = (s) => ({ LOKI_SCRATCH: s.dir, LOKI_SCRATCH_SINCE: String(s.since), TMPDIR: s.dir, [OWNER_ENV]: s.nonce }), psOut = (args, timeout = 4000) => spawnSync2("ps", args, { encoding: "utf8", env: { PATH: process.env["PATH"] ?? "/usr/bin:/bin", LC_ALL: "C", TZ: "UTC" }, timeout }).stdout ?? "", alive = (pid) => {
15026
15140
  try {
15027
15141
  process.kill(pid, 0);
15028
15142
  return true;
@@ -15043,6 +15157,7 @@ ${r.stdout ?? ""}`);
15043
15157
  }, procName = (command) => (command.trim().split(/\s+/)[0] ?? "").split("/").pop().slice(0, 60), SCRATCH_EXIT_RECORD = "scratch-cleanup.json";
15044
15158
  var init_worker_proc = __esm(() => {
15045
15159
  init_retry_class();
15160
+ init_types2();
15046
15161
  CANCEL_GRACE_MS = Number(process.env["LOKI_E10_CANCEL_GRACE_MS"]) > 0 ? Number(process.env["LOKI_E10_CANCEL_GRACE_MS"]) : 1e4;
15047
15162
  SAFE_BUN_FLAGS = ["--no-env-file", "--config=/dev/null"];
15048
15163
  LIMIT_SHELL = existsSync17("/bin/bash") ? "/bin/bash" : "/bin/sh";
@@ -15062,65 +15177,8 @@ var init_worker_proc = __esm(() => {
15062
15177
  ].map(([code, what]) => [code, `exit ${code} (${what})`]));
15063
15178
  });
15064
15179
 
15065
- // ../../loki-ts/src/engine10/types.ts
15066
- function warnBadCap(source, raw2) {
15067
- const key = `${source}=${raw2}`;
15068
- if (warnedCap.has(key))
15069
- return;
15070
- warnedCap.add(key);
15071
- process.stderr.write(`loki: ignoring invalid ${source}="${raw2}" (need a number > 0); using the default cap of ${DEFAULT_CAP_S}s
15072
- `);
15073
- }
15074
- function envCapS(raw2) {
15075
- if (raw2 === undefined || raw2.trim() === "")
15076
- return null;
15077
- const n3 = Number(raw2);
15078
- if (Number.isFinite(n3) && n3 > 0)
15079
- return n3;
15080
- warnBadCap("LOKI_E10_CAP_S", raw2);
15081
- return null;
15082
- }
15083
- function backstopS(capS, graceS = BACKSTOP_GRACE_S) {
15084
- return capS - Math.min(graceS, capS / 30);
15085
- }
15086
- function pushArgv(a) {
15087
- switch (a.cmd) {
15088
- case "push-pr":
15089
- return ["push-pr", a.repoDir, a.branch, a.title, a.bodyFile, a.draft ? "1" : "0"];
15090
- case "comment":
15091
- return ["comment", a.runId, a.prUrl, a.file];
15092
- case "status":
15093
- return ["status", a.sha, a.state, a.description];
15094
- case "issue-comment":
15095
- return a.update ? ["issue-comment", "--update", a.issueRef, a.bodyFile] : ["issue-comment", a.issueRef, a.bodyFile];
15096
- }
15097
- }
15098
- function taskBlock(task) {
15099
- return ["Task (untrusted, quoted verbatim):", "<<<TASK", task, "TASK"];
15100
- }
15101
- var STAGE_BUDGETS, DEFAULT_CAP_S = 900, DEEP_CAP_S = 2700, warnedCap, BACKSTOP_GRACE_S = 30, DEEP_IMPLEMENT_LIMIT_S = 1800, MAX_FIX_ROUNDS = 2, VERIFY_STOPPED_NOTE, ROUTER_COST_FIELDS, FINISH_LINE = "Finish with exactly one line: LOKI_DONE, or LOKI_ALREADY_DONE: <file:line evidence>, or LOKI_SPEC_CONFLICT: <reason; cite test as path:line>.", ISSUE_FINISH_LINE = "Finish with exactly one line: LOKI_DONE, or LOKI_ALREADY_DONE: <file:line evidence>, or LOKI_SPEC_CONFLICT: <reason; cite test as path:line>, or LOKI_UNFINISHED: <what is left> when something the issue requires is not delivered. An item the issue marks optional is not required: do it or skip it, say which in your reply, and still finish with LOKI_DONE. Use LOKI_SPEC_CONFLICT only when a test in the repository contradicts the task.", taskWording = (s) => s.replace(/\bThis is an issue\b/g, "This is a task").replace(/\bThis issue\b/g, "This task").replace(/\bthe issue\b/g, "the task"), TEXT_FINISH_LINE, proveByRunningOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_PROVE_BY_RUNNING"] ?? "").trim()), WORK_ROAD_ENV = "LOKI_E10_WORK_ROAD", workRoadOn = (env = process.env) => env[WORK_ROAD_ENV] === "1", issueRunBrief = (provider, source, env = process.env) => provider === "claude" && (source === "issue" || source === "text" && workRoadOn(env)) && proveByRunningOn(env);
15102
- var init_types2 = __esm(() => {
15103
- STAGE_BUDGETS = {
15104
- intake: { targetS: 15, limitS: 60 },
15105
- plan: { targetS: 45, limitS: 90 },
15106
- wall: { targetS: 45, limitS: 90 },
15107
- implement: { targetS: 180, limitS: 480 },
15108
- prove: { targetS: 300, limitS: 3600 },
15109
- verify: { targetS: 60, limitS: 120 },
15110
- fix: { targetS: 90, limitS: 180 },
15111
- commit: { targetS: 5, limitS: 30 },
15112
- seal: { targetS: 15, limitS: 60 },
15113
- pr: { targetS: 15, limitS: 60 },
15114
- deep: { targetS: null, limitS: 2700 }
15115
- };
15116
- warnedCap = new Set;
15117
- VERIFY_STOPPED_NOTE = { limit: "verify stopped at its time limit before all checks ran", cap: "verify stopped at the run time cap before all checks ran" };
15118
- ROUTER_COST_FIELDS = ["requests_total", "requests_over_100k", "advisor_calls", "advisor_input_tokens", "advisor_output_tokens"];
15119
- TEXT_FINISH_LINE = taskWording(ISSUE_FINISH_LINE);
15120
- });
15121
-
15122
15180
  // ../../loki-ts/src/util/shell.ts
15123
- async function readStreamCapped(stream, maxBytes = MAX_STDOUT_BYTES, onFirstChunk) {
15181
+ async function readStreamCapped(stream, maxBytes = MAX_STDOUT_BYTES, onFirstChunk, onChunk) {
15124
15182
  const reader = stream.getReader();
15125
15183
  let first = onFirstChunk;
15126
15184
  const decoder = new TextDecoder;
@@ -15133,6 +15191,11 @@ async function readStreamCapped(stream, maxBytes = MAX_STDOUT_BYTES, onFirstChun
15133
15191
  break;
15134
15192
  if (!value)
15135
15193
  continue;
15194
+ if (onChunk && value.byteLength > 0) {
15195
+ try {
15196
+ onChunk();
15197
+ } catch {}
15198
+ }
15136
15199
  if (first && value.byteLength > 0) {
15137
15200
  const cb = first;
15138
15201
  first = undefined;
@@ -15186,10 +15249,22 @@ async function run(argv, opts = {}) {
15186
15249
  };
15187
15250
  let timedOut = false;
15188
15251
  if (opts.timeoutMs && opts.timeoutMs > 0)
15189
- timer = setTimeout(() => {
15252
+ timer = armTimer(() => {
15190
15253
  timedOut = true;
15191
15254
  stop();
15192
15255
  }, opts.timeoutMs);
15256
+ const silenceMs = opts.silenceMs ?? (opts.timeoutMs !== undefined && !Number.isFinite(opts.timeoutMs) ? cmdSilenceS() * 1000 : undefined);
15257
+ let lastByte = Date.now(), silent = false;
15258
+ const touch = () => {
15259
+ lastByte = Date.now();
15260
+ };
15261
+ const quiet = silenceMs !== undefined && Number.isFinite(silenceMs) && silenceMs > 0 ? setInterval(() => {
15262
+ if (Date.now() - lastByte >= silenceMs) {
15263
+ silent = true;
15264
+ timedOut = true;
15265
+ stop();
15266
+ }
15267
+ }, Math.min(30000, Math.max(50, Math.floor(silenceMs / 4)))) : undefined;
15193
15268
  if (opts.signal) {
15194
15269
  if (opts.signal.aborted)
15195
15270
  stop();
@@ -15198,14 +15273,15 @@ async function run(argv, opts = {}) {
15198
15273
  }
15199
15274
  try {
15200
15275
  const [stdout, stderr, exitCode] = await Promise.all([
15201
- readStreamCapped(proc.stdout, MAX_STDOUT_BYTES, opts.onFirstStdout),
15202
- new Response(proc.stderr).text(),
15276
+ readStreamCapped(proc.stdout, MAX_STDOUT_BYTES, opts.onFirstStdout, quiet ? touch : undefined),
15277
+ quiet ? readStreamCapped(proc.stderr, MAX_STDOUT_BYTES, undefined, touch) : new Response(proc.stderr).text(),
15203
15278
  proc.exited
15204
15279
  ]);
15205
- return { stdout, stderr, exitCode, ...timedOut ? { timedOut: true } : {} };
15280
+ return { stdout, stderr, exitCode, ...timedOut ? { timedOut: true } : {}, ...silent ? { silent: true } : {} };
15206
15281
  } finally {
15207
- if (timer)
15208
- clearTimeout(timer);
15282
+ timer?.clear();
15283
+ if (quiet)
15284
+ clearInterval(quiet);
15209
15285
  if (killTimer)
15210
15286
  clearTimeout(killTimer);
15211
15287
  opts.signal?.removeEventListener("abort", stop);
@@ -15237,6 +15313,7 @@ function shellWord(value) {
15237
15313
  var MAX_STDOUT_BYTES;
15238
15314
  var init_shell = __esm(() => {
15239
15315
  init_worker_proc();
15316
+ init_types2();
15240
15317
  MAX_STDOUT_BYTES = 16 * 1024 * 1024;
15241
15318
  });
15242
15319
 
@@ -18346,11 +18423,11 @@ function positiveEnv(name, env, dflt) {
18346
18423
  function stallThresholdS(env = process.env["LOKI_E10_STALL_S"]) {
18347
18424
  return positiveEnv("LOKI_E10_STALL_S", env, DEFAULT_STALL_S);
18348
18425
  }
18349
- function stallKillS(env = process.env["LOKI_E10_STALL_KILL_S"]) {
18350
- return positiveEnv("LOKI_E10_STALL_KILL_S", env, 0);
18426
+ function stallKillS(env = process.env["LOKI_E10_STALL_KILL_S"], dflt = 0) {
18427
+ return positiveEnv("LOKI_E10_STALL_KILL_S", env, dflt);
18351
18428
  }
18352
18429
  function createWatchdog(now2, stallS = stallThresholdS()) {
18353
- let lastBytes = 0, lastDiff = "", lastChange = now2(), loopTicks = 0, stalled = false;
18430
+ let lastBytes = 0, lastDiff = "", lastChange = now2(), lastDiffChange = now2(), loopTicks = 0, stalled = false;
18354
18431
  return {
18355
18432
  tick(bytes, diff) {
18356
18433
  const t = now2();
@@ -18360,6 +18437,7 @@ function createWatchdog(now2, stallS = stallThresholdS()) {
18360
18437
  lastDiff = diff;
18361
18438
  loopTicks = 0;
18362
18439
  lastChange = t;
18440
+ lastDiffChange = t;
18363
18441
  stalled = false;
18364
18442
  } else if (moreOutput) {
18365
18443
  loopTicks++;
@@ -18367,17 +18445,17 @@ function createWatchdog(now2, stallS = stallThresholdS()) {
18367
18445
  stalled = false;
18368
18446
  } else
18369
18447
  loopTicks = 0;
18370
- const idleS = (t - lastChange) / 1000;
18448
+ const idleS = (t - lastChange) / 1000, diffIdleS = (t - lastDiffChange) / 1000;
18371
18449
  if (idleS >= stallS) {
18372
18450
  const stalledNow = !stalled;
18373
18451
  stalled = true;
18374
- return { cls: "stalled", idleS, stalledNow };
18452
+ return { cls: "stalled", idleS, stalledNow, diffIdleS };
18375
18453
  }
18376
18454
  if (loopTicks >= LOOP_TICKS)
18377
- return { cls: "looping", idleS, stalledNow: false };
18455
+ return { cls: "looping", idleS, stalledNow: false, diffIdleS };
18378
18456
  if (!moreOutput && !diffMoved && idleS >= IDLE_S)
18379
- return { cls: "idle", idleS, stalledNow: false };
18380
- return { cls: "progressing", idleS, stalledNow: false };
18457
+ return { cls: "idle", idleS, stalledNow: false, diffIdleS };
18458
+ return { cls: "progressing", idleS, stalledNow: false, diffIdleS };
18381
18459
  }
18382
18460
  };
18383
18461
  }
@@ -22166,6 +22244,7 @@ __export(exports_repo_profile, {
22166
22244
  repoReadiness: () => repoReadiness,
22167
22245
  renderProfile: () => renderProfile,
22168
22246
  redactEvidence: () => redactEvidence,
22247
+ redUnattributableOnBase: () => redUnattributableOnBase,
22169
22248
  readinessNotice: () => readinessNotice,
22170
22249
  readinessLines: () => readinessLines,
22171
22250
  readProfile: () => readProfile,
@@ -22194,6 +22273,7 @@ __export(exports_repo_profile, {
22194
22273
  baselineSuites: () => baselineSuites,
22195
22274
  baselineSuiteOnDemand: () => baselineSuiteOnDemand,
22196
22275
  baselineCmdS: () => baselineCmdS,
22276
+ baseUnattributedOn: () => baseUnattributedOn,
22197
22277
  baseRedByIdOn: () => baseRedByIdOn,
22198
22278
  baseRedById: () => baseRedById,
22199
22279
  baseOnDemandOn: () => baseOnDemandOn,
@@ -22965,6 +23045,19 @@ function sameUnattributableRed(repoDir, baseSha, full) {
22965
23045
  return !!b && b.ran && !b.attributable && !b.timed_out && b.reason !== "baseline budget used up" && b.failing_ids.length === 0 && !!b.failing_shape && b.failing_shape === c.shape && b.exit_code === c.exit;
22966
23046
  }).map((c) => c.name);
22967
23047
  }
23048
+ function redUnattributableOnBase(repoDir, baseSha, full) {
23049
+ if (!baseUnattributedOn())
23050
+ return [];
23051
+ const p = loadProfile(repoDir);
23052
+ if (!p || p.revision !== baseSha)
23053
+ return [];
23054
+ return full.filter((c) => {
23055
+ if (c.result !== "fail" || (c.ids ?? []).length > 0 || typeof c.exit !== "number")
23056
+ return false;
23057
+ const b = baseFor(repoDir, p, c.cmd, true);
23058
+ return !!b && b.ran && !b.attributable && !b.timed_out && b.reason !== "baseline budget used up" && b.failing_ids.length === 0 && typeof b.exit_code === "number" && b.exit_code !== 0 && b.exit_code === c.exit;
23059
+ }).map((c) => c.name);
23060
+ }
22968
23061
  function attributeFullSuite(repoDir, baseSha, full, blocked, changed, symbols = [], shownIds = new Set) {
22969
23062
  const same = sameUnattributableRed(repoDir, baseSha, full);
22970
23063
  const res = attributeFullSuiteById(repoDir, baseSha, same.length ? full.filter((c) => !same.includes(c.name)) : full, blocked, changed, symbols, shownIds);
@@ -23297,17 +23390,27 @@ ${r.stderr ?? ""}`), missing: r.status === 127 };
23297
23390
  stopped = true;
23298
23391
  kill();
23299
23392
  };
23300
- const timer = setTimeout(stop, timeoutMs);
23393
+ const timer = armTimer(stop, timeoutMs), open = !Number.isFinite(timeoutMs);
23394
+ let last = Date.now();
23395
+ const touch = () => {
23396
+ last = Date.now();
23397
+ };
23398
+ const quiet = open ? setInterval(() => {
23399
+ if (Date.now() - last >= cmdSilenceS() * 1000)
23400
+ stop();
23401
+ }, Math.min(30000, Math.max(50, cmdSilenceS() * 250))) : undefined;
23301
23402
  if (signal?.aborted)
23302
23403
  stop();
23303
23404
  else
23304
23405
  signal?.addEventListener("abort", stop, { once: true });
23305
23406
  try {
23306
- const [o, e, code] = await Promise.all([new Response(proc.stdout).text(), new Response(proc.stderr).text(), proc.exited]);
23407
+ const [o, e, code] = await Promise.all([open ? readStreamCapped(proc.stdout, MAX_STDOUT_BYTES, undefined, touch) : new Response(proc.stdout).text(), open ? readStreamCapped(proc.stderr, MAX_STDOUT_BYTES, undefined, touch) : new Response(proc.stderr).text(), proc.exited]);
23307
23408
  return { code: stopped ? null : code, timedOut: stopped, out: stripAnsi(`${o}
23308
23409
  ${e}`).slice(-8 * 1024 * 1024), missing: code === 127 };
23309
23410
  } finally {
23310
- clearTimeout(timer);
23411
+ timer.clear();
23412
+ if (quiet)
23413
+ clearInterval(quiet);
23311
23414
  signal?.removeEventListener("abort", stop);
23312
23415
  kill();
23313
23416
  }
@@ -23317,8 +23420,10 @@ ${e}`).slice(-8 * 1024 * 1024), missing: code === 127 };
23317
23420
  } catch {
23318
23421
  return "";
23319
23422
  }
23320
- }, SAME_RED_NOTE = "excused as red on base in the identical kind (same command, same exit code, the same unparseable output shape; no failing id could be compared)", baseRedByIdOn = (env = process.env) => /^(1|on|true|yes)$/i.test((env["LOKI_E10_BASE_RED_BY_ID"] ?? "").trim()), baseRedSuiteOff = (env = process.env) => /^(0|off|false|no)$/i.test((env["LOKI_E10_BASE_RED_BY_ID"] ?? "").trim()), touchedBaseRedOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_TOUCHED_BASE_RED"] ?? "").trim()), collateralBaselineOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_COLLATERAL_BASELINE"] ?? "").trim()), TOUCHED_RED = "edited test file red on base by every failing id with the same errors; the cases the change added or edited pass (excused, not blocking)", STATIC_DIAG, STATIC_NOISE, STATIC_SUMMARY, readinessLines = (r) => [` Readiness: ${r.score}/100 (${r.grade})`, ...r.findings.length ? [" Fix:", ...r.findings.map((f) => ` - ${f.fix}`)] : []];
23423
+ }, baseUnattributedOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_BASE_UNATTRIBUTED"] ?? "").trim()), SAME_RED_NOTE = "excused as red on base in the identical kind (same command, same exit code, the same unparseable output shape; no failing id could be compared)", baseRedByIdOn = (env = process.env) => /^(1|on|true|yes)$/i.test((env["LOKI_E10_BASE_RED_BY_ID"] ?? "").trim()), baseRedSuiteOff = (env = process.env) => /^(0|off|false|no)$/i.test((env["LOKI_E10_BASE_RED_BY_ID"] ?? "").trim()), touchedBaseRedOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_TOUCHED_BASE_RED"] ?? "").trim()), collateralBaselineOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_COLLATERAL_BASELINE"] ?? "").trim()), TOUCHED_RED = "edited test file red on base by every failing id with the same errors; the cases the change added or edited pass (excused, not blocking)", STATIC_DIAG, STATIC_NOISE, STATIC_SUMMARY, readinessLines = (r) => [` Readiness: ${r.score}/100 (${r.grade})`, ...r.findings.length ? [" Fix:", ...r.findings.map((f) => ` - ${f.fix}`)] : []];
23321
23424
  var init_repo_profile = __esm(() => {
23425
+ init_types2();
23426
+ init_shell();
23322
23427
  init_failures();
23323
23428
  init_check_result();
23324
23429
  init_safe_git();
@@ -23737,7 +23842,7 @@ async function runPackageSuites(repoDir, signal, opts, checks2, notProven) {
23737
23842
  continue;
23738
23843
  }
23739
23844
  if (r.timedOut && suiteTimeoutOn()) {
23740
- const why = `timed out after ${Math.round(timeoutMs / 1000)}s`;
23845
+ const why = r.silent ? `stopped after ${cmdSilenceS()}s with no output` : `timed out after ${Math.round(timeoutMs / 1000)}s`;
23741
23846
  checks2.push({ name, cmd, result: "not_run", duration_s, reason: why });
23742
23847
  notProven.add(`not run: ${name} (${why})`);
23743
23848
  continue;
@@ -23786,6 +23891,7 @@ var WORKSPACE_WIDE, scopedOutNote = (s) => `n/a: ${s.name} (\`${s.cmd}\`) not ru
23786
23891
  return w.length > 0 && w.every((c) => c.result === "pass") ? wall.map((x) => x.path) : [];
23787
23892
  }, emptySubsuiteNaOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_EMPTY_SUBSUITE_NA"] ?? "").trim()), suiteTimeoutOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_SUITE_TIMEOUT_NOT_RUN"] ?? "").trim());
23788
23893
  var init_package_suite = __esm(() => {
23894
+ init_types2();
23789
23895
  init_load_owner();
23790
23896
  init_repo_profile();
23791
23897
  init_check_result();
@@ -24506,6 +24612,13 @@ function yamlRunCapS(text4) {
24506
24612
  warnBadCap("budgets.run_cap_s", raw2);
24507
24613
  return null;
24508
24614
  }
24615
+ function parseDurationS(raw2) {
24616
+ const m = /^\s*(\d+)\s*([smh]?)\s*$/.exec(raw2 ?? "");
24617
+ if (!m)
24618
+ return null;
24619
+ const n3 = Number(m[1]) * (m[2] === "h" ? 3600 : m[2] === "m" ? 60 : 1);
24620
+ return n3 > 0 ? n3 : null;
24621
+ }
24509
24622
  function deadlineCapS(env = process.env, uptimeS = process.uptime()) {
24510
24623
  const raw2 = env.LOKI_RUN_DEADLINE_S;
24511
24624
  if (raw2 === undefined || raw2.trim() === "")
@@ -24522,6 +24635,9 @@ function resolveRunCapS(repoDir, subscription, env = process.env) {
24522
24635
  const first = texts.find((t) => yamlKey(t, "budgets", "run_cap_s") !== null);
24523
24636
  const yamlS = first !== undefined ? yamlRunCapS(first) : null;
24524
24637
  const set = fixedCapS(envCapS(env.LOKI_E10_CAP_S) ?? undefined, yamlS), dl = deadlineCapS(env), fixedS = dl === undefined ? set : Math.min(set ?? dl, dl);
24638
+ const badLimit = (env.LOKI_E10_CAP_S ?? "").trim() !== "" || first !== undefined && yamlS === null || (env.LOKI_RUN_DEADLINE_S ?? "").trim() !== "";
24639
+ if (fixedS === undefined && !badLimit && !defaultBudgetsOn(env))
24640
+ return { capS: Infinity, ceilingS: Infinity };
24525
24641
  return { capS: fixedS ?? DEFAULT_CAP_S, fixedS, ceilingS: fixedS ?? capCeilingS(subscription) };
24526
24642
  }
24527
24643
  function planOutOfRepo(runDir) {
@@ -24544,12 +24660,13 @@ var PLAN_SCOPE_FILE = "plan-scope.json", MAX_SCOPE_BYTES, CEILING_SUBSCRIPTION_S
24544
24660
  }, issueMinCapS = (env = process.env) => {
24545
24661
  const v = (env["LOKI_E10_ISSUE_MIN_CAP_S"] ?? "").trim(), n3 = Number(v);
24546
24662
  return v !== "" && Number.isFinite(n3) && n3 >= 0 ? n3 : 2400;
24547
- }, issueCapRule = (runDir, env = process.env) => existsSync39(join62(runDir, "issue.json")) || workRoadOn(env) || !!env["LOKI_E10_ISSUE_JSON"] && existsSync39(env["LOKI_E10_ISSUE_JSON"]), DEADLINE_MARGIN_S = 30, DEADLINE_MIN_CAP_S = 60, timeNoteOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_TIME_NOTE"] ?? "").trim()), timeBudgetNote = (limitS) => `Time budget: about ${Math.max(1, Math.round(limitS / 60))} minutes left for this session. Work in small steps, keep the test suite passing at every checkpoint, and leave the tree in a working state when time runs out.`, outOfRepoInstruction = (scopePath) => `If the requested change has no target in this repository (for example the code lives in a hosted service or another repo), write {"files":[],"out_of_repo":"<one sentence why>"} to ${scopePath} and do not guess files.`, localBranchNote = (runId, verdict, repoDir) => `engine10: run ${runId} sealed ${verdict}, not verified: branch loki/${runId} stays local (not pushed); inspect it in ${repoDir}
24663
+ }, issueCapRule = (runDir, env = process.env) => existsSync39(join62(runDir, "issue.json")) || workRoadOn(env) || !!env["LOKI_E10_ISSUE_JSON"] && existsSync39(env["LOKI_E10_ISSUE_JSON"]), DEADLINE_MARGIN_S = 30, DEADLINE_MIN_CAP_S = 60, TIME_FLAGS, timeNoteOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_TIME_NOTE"] ?? "").trim()), timeBudgetNote = (limitS) => `Time budget: about ${Math.max(1, Math.round(limitS / 60))} minutes left for this session. Work in small steps, keep the test suite passing at every checkpoint, and leave the tree in a working state when time runs out.`, outOfRepoInstruction = (scopePath) => `If the requested change has no target in this repository (for example the code lives in a hosted service or another repo), write {"files":[],"out_of_repo":"<one sentence why>"} to ${scopePath} and do not guess files.`, localBranchNote = (runId, verdict, repoDir) => `engine10: run ${runId} sealed ${verdict}, not verified: branch loki/${runId} stays local (not pushed); inspect it in ${repoDir}
24548
24664
  `;
24549
24665
  var init_run_cap = __esm(() => {
24550
24666
  init_types2();
24551
24667
  init_yaml_key();
24552
24668
  MAX_SCOPE_BYTES = 256 * 1024;
24669
+ TIME_FLAGS = { "--max-time": "LOKI_RUN_DEADLINE_S", "--verify-max-time": "LOKI_E10_VERIFY_MAX_S" };
24553
24670
  });
24554
24671
 
24555
24672
  // ../../loki-ts/src/engine10/closure.ts
@@ -25784,7 +25901,8 @@ function dependentTests(repoDir, map, changed, already) {
25784
25901
  if (deps.size === 0)
25785
25902
  return { ...none, truncated };
25786
25903
  const all = map.tests.filter((t) => !have.has(t.path) && importsAny(read3(repoDir, t.path), t.path, deps, js)).sort((a, b) => a.path.localeCompare(b.path));
25787
- return { tests: all.slice(0, MAX_DEPENDENT_TESTS), dropped: Math.max(0, all.length - MAX_DEPENDENT_TESTS), truncated };
25904
+ const cap = defaultBudgetsOn() ? MAX_DEPENDENT_TESTS : all.length;
25905
+ return { tests: all.slice(0, cap), dropped: Math.max(0, all.length - cap), truncated };
25788
25906
  }
25789
25907
  var MAX_DEPENDENT_TESTS = 20, SCAN_MAX_BYTES = 48000000, SCAN_MAX_MS = 4000, FILE_MAX_BYTES = 256000, JS, PY, JS_EXT, PY_FROM, PY_IMP, pyMod = (base) => [`${base}.py`, `${base}/__init__.py`], read3 = (repoDir, rel) => {
25790
25908
  try {
@@ -25794,6 +25912,7 @@ var MAX_DEPENDENT_TESTS = 20, SCAN_MAX_BYTES = 48000000, SCAN_MAX_MS = 4000, FIL
25794
25912
  }
25795
25913
  }, importsAny = (text4, rel, set, js) => importTargets(rel, text4, js).some((t) => set.has(t)), dependentNotes = (d) => [...d.truncated ? ["reverse-dependent scan hit its byte or time bound: some importers of changed files may not have been tested"] : [], ...d.dropped ? [`reverse-dependent tests dropped by the ${MAX_DEPENDENT_TESTS}-file cap: ${d.dropped}`] : []];
25796
25914
  var init_dependents = __esm(() => {
25915
+ init_types2();
25797
25916
  init_safe_git();
25798
25917
  init_test_file_text();
25799
25918
  init_js_resolve();
@@ -31571,7 +31690,7 @@ var TEST_DIR2, TEST_NAME3, isTestFile3 = (f) => isTestFile(f) || TEST_DIR2.test(
31571
31690
  return /^(0|off|false|no)$/.test(v) ? "off" : v === "always" ? "always" : "on";
31572
31691
  }, SELF_REVIEW_MAX_TURNS = 12, selfReviewMaxTurns = (env = process.env) => {
31573
31692
  const n3 = Number((env["LOKI_E10_SELF_REVIEW_MAX_TURNS"] ?? "").trim());
31574
- return Number.isInteger(n3) && n3 > 0 ? n3 : SELF_REVIEW_MAX_TURNS;
31693
+ return Number.isInteger(n3) && n3 > 0 ? n3 : defaultBudgetsOn(env) ? SELF_REVIEW_MAX_TURNS : 0;
31575
31694
  }, SRC_EXT2, STYLE_FILES, repoConventionsOn = (env = process.env) => /^(1|on|true|yes)$/i.test((env["LOKI_E10_REPO_CONVENTIONS"] ?? "").trim()), PC_TYPES, CODE_FILE, docEnumOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_DOC_ENUM"] ?? "").trim()), NAME_TOKENS = (text4) => new Set([...text4.matchAll(/['"`]([A-Za-z][\w-]{2,39})['"`]|\b([A-Za-z_][\w]{2,39})\s*:/g)].map((m) => m[1] ?? m[2]).filter((t) => !/^(?:true|false|null|undefined|this|type|name|value|string|number|default|function|return|const|let|var|import|export|from|https?)$/i.test(t))), srCoverageOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_SR_COVERAGE"] ?? "").trim()), COMMON_CALLS, RESULT_AFTER, ERROR_IN, wallCasesOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_WALL_CASES"] ?? "").trim()), WALL_CASES_FILE = "wall-required-cases.json", wallCasesHanded = (runDir) => {
31576
31695
  if (!runDir)
31577
31696
  return 0;
@@ -31582,9 +31701,10 @@ var TEST_DIR2, TEST_NAME3, isTestFile3 = (f) => isTestFile(f) || TEST_DIR2.test(
31582
31701
  }
31583
31702
  }, SIB_SKIP, S = "[[:space:]]", DEF_RE, selfReviewWanted = (items, mode) => mode === "always" || mode === "on" && items.some((i) => i.status === "flagged"), LABEL2, KEY_OF, selfReviewReceiptBlock = (implement) => implement && implement["self_review"] ? { self_review: implement["self_review"] } : {}, verifiedFinishOn = (env = process.env) => /^(1|on|true|yes)$/i.test((env["LOKI_E10_VERIFIED_FINISH"] ?? "").trim()), VERIFIED_FINISH_MAX_TURNS = 8, verifiedFinishMaxTurns = (env = process.env) => {
31584
31703
  const n3 = Number((env["LOKI_E10_VERIFIED_FINISH_MAX_TURNS"] ?? "").trim());
31585
- return Number.isInteger(n3) && n3 > 0 ? n3 : VERIFIED_FINISH_MAX_TURNS;
31704
+ return Number.isInteger(n3) && n3 > 0 ? n3 : defaultBudgetsOn(env) ? VERIFIED_FINISH_MAX_TURNS : 0;
31586
31705
  }, FINISH_DIFF_MAX = 40000, FINISH_FILE_MAX = 12000, FINISH_FILES_MAX = 36000, FINISH_LEAD = "Finish pass. The change below is already applied, uncommitted, in this checkout. Do not redo, rewrite or extend the fix itself; only bring the change up to the repository's rules.", reviewTurnGuardOn = (env = process.env) => /^(1|on|true|yes)$/i.test((env["LOKI_E10_REVIEW_TURN_GUARD"] ?? "").trim()), sameEntry = (a, b) => !a || !b ? a === b : a.kind === b.kind && a.mode === b.mode && a.symlinkTarget === b.symlinkTarget && (a.content && b.content ? a.content.equals(b.content) : a.content === b.content), turnGuardNote = (g) => g?.reverted ? [`review turn reverted: ${g.broke.join(", ")} passed before the turn and failed after it; the turn's edits to ${g.paths.join(", ")} were taken back and the pre-turn diff kept`] : [], releaseRefsReceiptBlock = (implement) => Array.isArray(implement?.["changelog_refs_removed"]) && implement["changelog_refs_removed"].length ? { changelog_refs_removed: implement["changelog_refs_removed"] } : {};
31587
31706
  var init_self_review = __esm(() => {
31707
+ init_types2();
31588
31708
  init_commit_filter();
31589
31709
  init_scope2();
31590
31710
  init_conventions();
@@ -37144,11 +37264,11 @@ function resolveCap(cli, repoDir, env = process.env) {
37144
37264
  if (raw2 !== null && !isZeroCap(raw2))
37145
37265
  return { error: `loki.yaml budgets.per_run must be a positive number of US dollars (got "${raw2}")` };
37146
37266
  }
37147
- return hasApiKey(env) ? { usd: DEFAULT_MAX_COST_USD, source: "default" } : { usd: 0, source: "subscription" };
37267
+ return { usd: 0, source: hasApiKey(env) ? "default" : "subscription" };
37148
37268
  }
37149
37269
  function capNote(usd, source) {
37150
37270
  if (usd <= 0)
37151
- return "no dollar cap (subscription)";
37271
+ return source === "default" ? NO_COST_LIMIT_NOTE : "no dollar cap (subscription)";
37152
37272
  return `cap $${usd.toFixed(2)} (${source})`;
37153
37273
  }
37154
37274
  function groupEnv(env, capUsd, repoDir) {
@@ -37323,7 +37443,7 @@ function budgetNext(spentUsd, capUsd) {
37323
37443
  function unenforceableNote(provider, capUsd) {
37324
37444
  return capUsd > 0 && capability(provider)?.cost === "none" ? `warning: ${provider} reports no cost, so the $${capUsd.toFixed(2)} cap cannot be enforced` : null;
37325
37445
  }
37326
- var DEFAULT_MAX_COST_USD, SUBSCRIPTION_NOTE = "subscription: no dollar cap; usage counts against your plan limits", isZeroCap = (raw2) => /^\$?(0+(\.0*)?|\.0+)$/.test(raw2.trim()), BUDGET_THRESHOLDS;
37446
+ var DEFAULT_MAX_COST_USD, SUBSCRIPTION_NOTE = "subscription: no dollar cap; usage counts against your plan limits", NO_COST_LIMIT_NOTE = "no cost limit is set: the run stops when it is done or makes no progress (--max-cost <usd> sets one)", isZeroCap = (raw2) => /^\$?(0+(\.0*)?|\.0+)$/.test(raw2.trim()), BUDGET_THRESHOLDS;
37327
37447
  var init_budget_cap = __esm(() => {
37328
37448
  init_yaml_key();
37329
37449
  init_budget();
@@ -38488,12 +38608,13 @@ loki_services_stop() {
38488
38608
  }
38489
38609
  `, checkKey = (text4) => text4.split(/ \| (?:status \d|exit \d|wanted )/)[0].toLowerCase().replace(/\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f-]{22,}\b|\b[0-9a-f]{12,}\b/g, "#").replace(/\d+/g, "#").replace(/\s+/g, " ").trim().slice(0, 200), proofChecks = (out2, token) => proofLines(out2, token).map((c) => ({ item: c.item, what: checkKey(c.text), ok: c.ok })), MAX_SCRIPT_BYTES = 200000, TAIL_CHARS = 8000, proofRerunS = (env = process.env) => {
38490
38610
  const n3 = Number(env["LOKI_E10_PROOF_RERUN_S"]);
38491
- return n3 > 0 ? n3 : 600;
38611
+ return n3 > 0 ? n3 : defaultBudgetsOn(env) ? 600 : Infinity;
38492
38612
  }, proofLoopMax = (env = process.env) => {
38493
38613
  const v = (env["LOKI_E10_PROOF_LOOP_MAX"] ?? "").trim(), n3 = Number(v);
38494
38614
  return v !== "" && Number.isInteger(n3) && n3 >= 0 ? n3 : 3;
38495
38615
  }, proofRerunOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_PROOF_RERUN"] ?? "").trim()), proofBaseOn = (env = process.env) => /^(1|on|true|yes)$/i.test((env["LOKI_E10_PROOF_BASE"] ?? "").trim()), proofBaseCapOn = (env = process.env) => /^(1|on|true|yes)$/i.test((env["LOKI_E10_PROOF_BASE_CAP"] ?? "").trim()), keepsWorkingAsk = (line2) => /\b(still|existing|remains?|unchanged|regress\w*|backwards?[- ]compatib\w*|compatib\w*|continues? to|keeps?|preserv\w*|no breaking|without breaking|(?:does|do|must|should) not break|not affect\w*|refactor\w*|clean ?up|renam\w*|upgrad\w*|bump\w*|tests? pass(?:es|ing)?|lint\w*|type ?checks?|ci (?:is |stays )?green|builds? (?:pass|succeed)\w*)\b/i.test(line2), provesNothingReason = (base, n3) => `every passing check for this line also passes on the base commit, before the change, so none of them proves the change (for example: ${base.same[String(n3)]?.first ?? ""})`.slice(0, 300), baseFacts = (asks, r, base) => provesNothing(asks, r, base).map((n3) => `Line ${n3}: every passing check for it in Loki's own run also passes when the same script runs against the base commit, before the change. Those checks do not show that the change delivered this line.`), PROVES_NOTHING_FIX = "Replace it with, or add, a check of what you built for this line: the request the new endpoint or page serves, the new output, the new row. A check that would also pass with your change removed proves nothing. If this line only asks that something keeps working, leave its check and say so in your reply", BASE_CACHE = "proof-base.json", DEPS_COPY_MS = 180000, RESULT_LOG = "loki-proof-results.log", SETUP_CHECK_S = 120, SETUP_TAIL_CHARS = 1000, NO_OWN_PROOF_NOTE = "no proof script: the session left nothing Loki could run itself, so no acceptance line is proved by Loki's own run", noOwnProofNotes = (source, listed, r, env = process.env) => source === "text" && listed > 0 && !r && proofRerunOn(env) ? [NO_OWN_PROOF_NOTE] : [];
38496
38616
  var init_proof_rerun = __esm(() => {
38617
+ init_types2();
38497
38618
  init_worker_proc();
38498
38619
  init_shell();
38499
38620
  init_safe_git();
@@ -39168,7 +39289,7 @@ Review ONLY the diff below. Do not modify files.` : "You are an independent code
39168
39289
  }
39169
39290
  var modelReviewRan = (xr) => !!xr && xr.level !== "not_run" && xr.reviewed_by !== "deterministic" && xr.reviewed_by !== "none", COMPILED_PATHS, hygieneFindings = (paths, ignored = new Set) => paths.filter((f) => !f.startsWith(".loki/") && (COMPILED_PATHS.some((re) => re.test(f)) || ignored.has(f))), RANK3, MAX_NOTES = 5, reviewRanWording = (xr) => modelReviewRan(xr) ? xr.reviewer_model ? `reviewer (${xr.reviewer_model})` : "reviewer" : xr?.reviewed_by === "deterministic" ? "deterministic check" : "none", REVIEW_TOOLS_NOTE = "Your tools are Read, Grep, Glob and a read-only shell (cat, ls, grep, rg, find, head, tail, wc). No git commands are available; the diff is in this prompt. You cannot edit files or run project code or tests, so trace behaviour by reading the code. If a tool fails or you could not inspect something, say so plainly in your reasons.", clean4 = (s) => capWhole(s.replace(/[\x00-\x1f\x7f`]+/g, " "), 600), UNMET_REASON_RE, isUnmetNote = (note2) => /^cross-review \w+ \([^)]*\):\s*\**UNMET\b/.test(note2), reviewDefaultOn = (tier, env = process.env) => tier === "high" || tier === "medium" && env["LOKI_REVIEW_DEFAULT"] === "1", reviewBoxS = (env = process.env) => {
39170
39291
  const n3 = Number(env["LOKI_E10_REVIEW_BOX_S"]);
39171
- return n3 > 0 ? n3 : 300;
39292
+ return n3 > 0 ? n3 : defaultBudgetsOn(env) ? 300 : Infinity;
39172
39293
  }, MIN_REVIEW_S = 30, roomS = (ctx) => backstopS(ctx.capS ?? Infinity) - (ctx.startedAtMs === undefined ? 0 : (ctx.clock?.now() ?? Date.now()) - ctx.startedAtMs) / 1000 - 55, boxFor = (ctx) => Math.min(reviewBoxS(), roomS(ctx)), reviewExtraLimitS = (ctx) => pickReviewer(ctx, configuredReviewer(ctx.repoDir)).p && roomS(ctx) >= MIN_REVIEW_S ? boxFor(ctx) + 30 : 0, LINE_CHECK_HEAD = "Loki acceptance line check.", LINE_CHECK_SYSTEM = "You check a code change against an issue's acceptance lines. You have no tools: read only what is below. Answer for every numbered line, one line each, nothing else.", LINE_CHECK_DIFF_MAX = 240000, CUT_FIRST, lineCheckOverride = null, lineCheckModel = (ctxModel, env = process.env) => (env["LOKI_E10_ISSUE_ACCEPTANCE_MODEL"] ?? "").trim() || (ctxModel && /^claude-/.test(ctxModel) ? ctxModel : ctxModel && /^(opus|sonnet|haiku)$/.test(ctxModel) ? `claude-${ctxModel}-5-5` : "claude-sonnet-5-5"), reviewAcceptance = (ctx) => {
39173
39294
  const o = ctx.outputs?.() ?? {}, il = issueAcceptanceCapOn() ? issueAcceptanceOf(o.intake) : [];
39174
39295
  return il.length ? il : acceptanceLines(o.plan);
@@ -39178,6 +39299,7 @@ var modelReviewRan = (xr) => !!xr && xr.level !== "not_run" && xr.reviewed_by !=
39178
39299
  return rows.length ? ["", "Checks the harness already ran on this change (name: result). Do not flag a line only because you could not run a test yourself; use these results:", ...rows] : [];
39179
39300
  }, reviewFixOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_REVIEW_FIX"] ?? "").trim());
39180
39301
  var init_xreview = __esm(() => {
39302
+ init_types2();
39181
39303
  init_role_agents();
39182
39304
  init_role_agents();
39183
39305
  init_shell();
@@ -40116,6 +40238,15 @@ ${r.session.summary}` };
40116
40238
  let reviewedEarly = false, earlyReviewCost = null;
40117
40239
  let proofFails = 0, lineTurns = 0;
40118
40240
  const LINE_TURNS_MAX = 2;
40241
+ const noBudget = !defaultBudgetsOn() && !ctx.deep;
40242
+ let proofBest = { failed: Infinity, unmet: Infinity }, proofStill = 0;
40243
+ const proofStep = (failed2, unmet) => {
40244
+ if (failed2 < proofBest.failed || unmet < proofBest.unmet) {
40245
+ proofBest = { failed: Math.min(failed2, proofBest.failed), unmet: Math.min(unmet, proofBest.unmet) };
40246
+ proofStill = 0;
40247
+ } else
40248
+ proofStill++;
40249
+ };
40119
40250
  const reviewRound = async (tree) => {
40120
40251
  if (reviewedEarly || !reviewFixOn())
40121
40252
  return false;
@@ -40140,7 +40271,7 @@ ${r.session.summary}` };
40140
40271
  ${r3.session.summary}` };
40141
40272
  return true;
40142
40273
  };
40143
- for (let round2 = 0;proofFails < proofLoopMax() && scratch && proofRerunOn() && existsSync68(join103(scratch.dir, PROOF_SCRIPT)) && !signal.aborted && !session3.killed && session3.exit === 0 && !session3.markers.specConflict && !session3.markers.alreadyDone; round2++) {
40274
+ for (let round2 = 0;(noBudget ? proofStill < noProgressRounds() : proofFails < proofLoopMax()) && scratch && proofRerunOn() && existsSync68(join103(scratch.dir, PROOF_SCRIPT)) && !signal.aborted && !session3.killed && session3.exit === 0 && !session3.markers.specConflict && !session3.markers.alreadyDone; round2++) {
40144
40275
  if (!keepProofScript(scratch.dir, ctx.runDir))
40145
40276
  break;
40146
40277
  const pr = await rerunProof(ctx.repoDir, ctx.runDir, signal);
@@ -40158,7 +40289,7 @@ ${r3.session.summary}` };
40158
40289
  const la = labelAsks(ctx.provider, prior.intake, prior.plan, ctx.repoDir);
40159
40290
  if (!la.asks.length)
40160
40291
  break;
40161
- if (lineTurns >= LINE_TURNS_MAX) {
40292
+ if (noBudget ? proofStill >= noProgressRounds() : lineTurns >= LINE_TURNS_MAX) {
40162
40293
  const t = await worktreeTree(ctx.repoDir);
40163
40294
  if (t && await reviewRound(t))
40164
40295
  continue;
@@ -40178,6 +40309,7 @@ ${r3.session.summary}` };
40178
40309
  return lc.marks && !lc.marks.met.includes(i + 1) ? [{ line: `${i + 1}. ${line2}`, reason: `it has a passing check, but a reviewer found a gap: ${lc.reasons?.[String(i + 1)] ?? "not stated"}` }] : [];
40179
40310
  });
40180
40311
  const lineUnmet = unmet.length;
40312
+ proofStep(pr.failed, lineUnmet);
40181
40313
  for (const f of await unusedNewFiles(ctx.repoDir, ctx.baseSha, tree))
40182
40314
  unmet.push({ line: `(not an acceptance line) ${f}`, reason: "no other file in the repository imports or names this new file, so a user cannot reach what it does. Mount it where it belongs (a page, a route, a registry, a menu) and prove that path, or remove it" });
40183
40315
  lineRounds.push({ met: lc.marks?.met.length ?? 0, unmet: unmet.length, usd: lc.usd });
@@ -40201,6 +40333,9 @@ ${r3.session.summary}` };
40201
40333
  ${r2.session.summary}` };
40202
40334
  continue;
40203
40335
  }
40336
+ proofStep(Math.max(1, pr.failed), Infinity);
40337
+ if (noBudget && proofStill >= noProgressRounds())
40338
+ break;
40204
40339
  const r = await resumeForProofScript(ctx, { ...unchained(), iterationId: ids[ids.length - 1] }, session3, `Loki ran your proof script ($LOKI_SCRATCH/loki-proof.sh) by itself, in a new empty directory, and it did not pass: exit ${pr.exit === null ? "none (it did not finish in time)" : pr.exit}, ${pr.proved} PROVED and ${pr.failed} FAILED line(s). This is the real end of its output:
40205
40340
 
40206
40341
  ${pr.tail.slice(-4000)}
@@ -40563,7 +40698,7 @@ async function runPass(root, dir, out2, ids, signal, o = {}) {
40563
40698
  cut = true;
40564
40699
  killGroup2(proc.pid, "SIGKILL");
40565
40700
  };
40566
- const timer = setTimeout(stop, Math.max(1, passS) * 1000);
40701
+ const timer = setTimeout(stop, Math.min(MAX_TIMER_MS, Math.max(1, passS) * 1000));
40567
40702
  if (signal.aborted)
40568
40703
  stop();
40569
40704
  else
@@ -40777,6 +40912,7 @@ printf 'done\\n' > "$OUT/driver.done"
40777
40912
  }
40778
40913
  }, proveStage, stage3, proveDisclosures = (o) => (o.prove?.notes ?? []).filter((n3) => !n3.startsWith("not proved:")).map((n3) => clean5(n3, 400));
40779
40914
  var init_prove = __esm(() => {
40915
+ init_types2();
40780
40916
  init_worker_proc();
40781
40917
  init_check_result();
40782
40918
  init_anti_loop();
@@ -43713,6 +43849,7 @@ __export(exports_machine, {
43713
43849
  hasFailures: () => hasFailures,
43714
43850
  haikuIndepFixOn: () => haikuIndepFixOn,
43715
43851
  freshBaseCheckout: () => freshBaseCheckout,
43852
+ fixProgressOf: () => fixProgressOf,
43716
43853
  attemptSignalOf: () => attemptSignalOf,
43717
43854
  VERIFY_MAX_S: () => VERIFY_MAX_S,
43718
43855
  USAGE_LIMIT_STOP: () => USAGE_LIMIT_STOP,
@@ -43759,9 +43896,13 @@ function stillFailing(groups, kept) {
43759
43896
  });
43760
43897
  }
43761
43898
  function verifyLimitFor(floorS, softS, elapsedS2, env = process.env) {
43762
- const v = Number((env["LOKI_E10_VERIFY_MAX_S"] ?? "").trim()), max = Number.isFinite(v) && v >= 1 ? Math.floor(v) : VERIFY_MAX_S;
43899
+ const v = Number((env["LOKI_E10_VERIFY_MAX_S"] ?? "").trim()), max = Number.isFinite(v) && v >= 1 ? Math.floor(v) : defaultBudgetsOn(env) ? VERIFY_MAX_S : Infinity;
43763
43900
  return Math.min(Math.max(floorS, Math.floor(softS - elapsedS2 - VERIFY_TAIL_S)), max);
43764
43901
  }
43902
+ function fixProgressOf(d) {
43903
+ const checks2 = Array.isArray(d?.checks) ? d.checks : [];
43904
+ return { failing: checks2.filter((c) => c?.result === "fail").reduce((n3, c) => n3 + Math.max(1, Array.isArray(c.ids) ? c.ids.length : 0), 0) + (Number(d?.holdout_failed) > 0 ? Number(d.holdout_failed) : 0), ran: checks2.filter((c) => c?.result !== "not_run").length };
43905
+ }
43765
43906
  function softCapS(capS) {
43766
43907
  const plain = capS * 14 / 15, budget = backstopS(capS) - ((STAGE_BUDGETS.commit.targetS ?? 0) + (STAGE_BUDGETS.seal.targetS ?? 0) + KILL_GRACE_MS3 / 1000 + 2);
43767
43908
  return Math.max(0, Math.min(plain, budget));
@@ -43781,7 +43922,8 @@ async function runMachine(ctx, opts = {}) {
43781
43922
  const timeline = ctx.timeline ??= [], intentRevs = ctx.intentRevisions ??= [];
43782
43923
  let capAtMs = startMs + softCapS(ctx.capS) * 1000;
43783
43924
  const capCtl = new AbortController;
43784
- let capTimer = setTimeout(() => capCtl.abort(), Math.max(0, capAtMs - ctx.clock.now()));
43925
+ let capTimer = armTimer(() => capCtl.abort(), Math.max(0, capAtMs - ctx.clock.now()));
43926
+ const unbounded = !defaultBudgetsOn() && !ctx.deep;
43785
43927
  let implementStartMs = null;
43786
43928
  const withTimeNote = (brief, limitS) => brief.endsWith(FINISH_LINE) ? `${brief.slice(0, -FINISH_LINE.length)}${timeBudgetNote(limitS)}
43787
43929
 
@@ -43793,10 +43935,10 @@ ${timeBudgetNote(limitS)}`;
43793
43935
  if (limited)
43794
43936
  return { exit: null, markers: { done: false, alreadyDone: null, specConflict: null }, durationS: 0, killed: true };
43795
43937
  startedIds.add(o0.iterationId);
43796
- const n0 = intentRevs.length, o = withSteer(o0, ctx.repoDir, intentRevs);
43938
+ const n0 = intentRevs.length, o = withSteer(unbounded ? { ...o0, limitS: Infinity } : o0, ctx.repoDir, intentRevs);
43797
43939
  if (intentRevs.length > n0)
43798
43940
  ctx.emit("intent.revised", o.stage, { revisions: intentRevs });
43799
- const left = implementStartMs === null ? Infinity : Math.max(1, implementBudgetS - (ctx.clock.now() - implementStartMs) / 1000), imp = o.stage === "implement" ? { ...o, limitS: Math.min(Math.max(o.limitS, implementBudgetS), left) } : o, r = await rerunOnQuota(() => ctx.sessions.run(imp.stage === "implement" && typeof imp.brief === "string" && imp.limitS > 0 && !issueRunBrief(ctx.provider, outputs.intake?.source) && timeNoteOn() ? { ...imp, brief: withTimeNote(imp.brief, imp.limitS) } : imp), sessionKind, ctx.clock, imp.signal, capAtMs, () => ctx.overCap?.() === true);
43941
+ const left = implementStartMs === null ? Infinity : Math.max(1, implementBudgetS - (ctx.clock.now() - implementStartMs) / 1000), imp = o.stage === "implement" ? { ...o, limitS: Math.min(Math.max(o.limitS, implementBudgetS), left) } : o, r = await rerunOnQuota(() => ctx.sessions.run(imp.stage === "implement" && typeof imp.brief === "string" && imp.limitS > 0 && Number.isFinite(imp.limitS) && !issueRunBrief(ctx.provider, outputs.intake?.source) && timeNoteOn() ? { ...imp, brief: withTimeNote(imp.brief, imp.limitS) } : imp), sessionKind, ctx.clock, imp.signal, Number.isFinite(capAtMs) ? capAtMs : ctx.clock.now() + hangSilenceS() * 1000, () => ctx.overCap?.() === true);
43800
43942
  const k = r.exit === 0 ? null : sessionKind(r);
43801
43943
  if (k === "auth" || k === "quota_exhausted" && !capReached())
43802
43944
  fatal ??= `fatal:${k}`;
@@ -43818,8 +43960,8 @@ ${timeBudgetNote(limitS)}`;
43818
43960
  return;
43819
43961
  ctx.capS = sctx.capS = proposedS;
43820
43962
  capAtMs = startMs + softCapS(proposedS) * 1000;
43821
- clearTimeout(capTimer);
43822
- capTimer = setTimeout(() => capCtl.abort(), Math.max(0, capAtMs - ctx.clock.now()));
43963
+ capTimer.clear();
43964
+ capTimer = armTimer(() => capCtl.abort(), Math.max(0, capAtMs - ctx.clock.now()));
43823
43965
  ctx.emit("cap.sized", null, { cap_s: proposedS });
43824
43966
  };
43825
43967
  const capReached = () => capCtl.signal.aborted || ctx.clock.now() >= capAtMs || ctx.overCap?.() === true;
@@ -43832,7 +43974,7 @@ ${timeBudgetNote(limitS)}`;
43832
43974
  const proveReserveS = () => proveScope(ctx.provider, outputs) ? proveBudgetS() : 0;
43833
43975
  let implementBudgetS = 0;
43834
43976
  const implementLimitS = (floorS) => Math.max(floorS, Math.floor(softCapS(ctx.capS) - elapsedS2() - (STAGE_BUDGETS.verify.limitS ?? 0) - proveReserveS()));
43835
- const fixLimitS = (baseS) => Math.max(baseS, Math.min(2 * baseS, Math.round(baseS * ctx.capS / DEFAULT_CAP_S)));
43977
+ const fixLimitS = (baseS) => unbounded ? Infinity : Math.max(baseS, Math.min(2 * baseS, Math.round(baseS * ctx.capS / DEFAULT_CAP_S)));
43836
43978
  const verifyLimitS = (floorS) => verifyLimitFor(floorS, softCapS(ctx.capS), elapsedS2());
43837
43979
  const runStage = async (name, underCap) => {
43838
43980
  if (limited)
@@ -43846,7 +43988,7 @@ ${timeBudgetNote(limitS)}`;
43846
43988
  markCap(name);
43847
43989
  return null;
43848
43990
  }
43849
- const limitS = name === "implement" ? ctx.deep ? DEEP_IMPLEMENT_LIMIT_S : st.limitS >= STAGE_BUDGETS.implement.limitS ? implementLimitS(st.limitS) : st.limitS : (name === "verify" && st.limitS >= STAGE_BUDGETS.verify.limitS ? verifyLimitS(st.limitS) : name === "fix" ? fixLimitS(st.limitS) : name === "prove" ? sctx.proveBudgetS ?? st.limitS : st.limitS) + (st.extraLimitS?.(sctx) ?? 0);
43991
+ const limitS0 = name === "implement" ? ctx.deep ? DEEP_IMPLEMENT_LIMIT_S : st.limitS >= STAGE_BUDGETS.implement.limitS ? implementLimitS(st.limitS) : st.limitS : (name === "verify" && st.limitS >= STAGE_BUDGETS.verify.limitS ? verifyLimitS(st.limitS) : name === "fix" ? fixLimitS(st.limitS) : name === "prove" ? sctx.proveBudgetS ?? st.limitS : st.limitS) + (st.extraLimitS?.(sctx) ?? 0), limitS = unbounded && !(name === "verify" || name === "implement" && Number.isFinite(ctx.capS)) ? Infinity : limitS0;
43850
43992
  if (name === "implement") {
43851
43993
  implementBudgetS = limitS;
43852
43994
  implementStartMs = ctx.clock.now();
@@ -43865,7 +44007,7 @@ ${timeBudgetNote(limitS)}`;
43865
44007
  ctl.abort();
43866
44008
  }
43867
44009
  };
43868
- const limitTimer = setTimeout(() => kill("limit"), limitS * 1000);
44010
+ const limitTimer = armTimer(() => kill("limit"), limitS * 1000);
43869
44011
  const onCap = () => kill("cap"), onUsage = () => kill("usage");
43870
44012
  limitCtl.signal.addEventListener("abort", onUsage);
43871
44013
  if (underCap) {
@@ -43885,7 +44027,7 @@ ${timeBudgetNote(limitS)}`;
43885
44027
  } catch (err) {
43886
44028
  r = { status: "failed", data: {}, reason: err instanceof Error ? err.message : String(err) };
43887
44029
  } finally {
43888
- clearTimeout(limitTimer);
44030
+ limitTimer.clear();
43889
44031
  capCtl.signal.removeEventListener("abort", onCap);
43890
44032
  limitCtl.signal.removeEventListener("abort", onUsage);
43891
44033
  }
@@ -43975,7 +44117,7 @@ ${timeBudgetNote(limitS)}`;
43975
44117
 
43976
44118
  ${CASCADE_LEAD}
43977
44119
  ${wallTail}` : brief0;
43978
- const room = Math.floor(softCapS(ctx.capS) - elapsedS2() - ATTEMPTS_TAIL_S), limitS = Math.min(STAGE_BUDGETS.implement.limitS, room);
44120
+ const room = Math.floor(softCapS(ctx.capS) - elapsedS2() - ATTEMPTS_TAIL_S), limitS = unbounded ? Infinity : Math.min(STAGE_BUDGETS.implement.limitS, room);
43979
44121
  if (limitS < MIN_ATTEMPT_WINDOW_S)
43980
44122
  return note2(`not enough run time left (${Math.max(room, 0)}s)`);
43981
44123
  if (capReached())
@@ -44040,7 +44182,7 @@ ${wallTail}` : brief0;
44040
44182
  };
44041
44183
  let wallJob = null;
44042
44184
  const closeWallJob = (j) => {
44043
- clearTimeout(j.timer);
44185
+ j.timer.clear();
44044
44186
  capCtl.signal.removeEventListener("abort", j.onCap);
44045
44187
  };
44046
44188
  const dropSnap = (j) => {
@@ -44073,7 +44215,7 @@ ${wallTail}` : brief0;
44073
44215
  ctl.abort();
44074
44216
  }
44075
44217
  };
44076
- const timer = setTimeout(() => kill("limit"), st.limitS * 1000), onCap = () => kill("cap");
44218
+ const timer = armTimer(() => kill("limit"), (unbounded ? Infinity : st.limitS) * 1000), onCap = () => kill("cap");
44077
44219
  if (capCtl.signal.aborted)
44078
44220
  onCap();
44079
44221
  else
@@ -44258,6 +44400,7 @@ ${wallTail}` : brief0;
44258
44400
  }
44259
44401
  }
44260
44402
  let extraRounds = 0;
44403
+ let fixBest = fixProgressOf(outputs.verify), stillRounds = 0;
44261
44404
  let noopSig = null;
44262
44405
  const suiteSkip = suiteFixSkipEnabled() && !fatal && !capHit && outputs.implement?.exit === "done" && hasFailures(outputs.verify) && suiteOnlyRed(outputs.verify);
44263
44406
  const indepSkip = !fatal && !capHit && hasFailures(outputs.verify) && fixGateOf(outputs.verify, `${String(outputs.implement?.model ?? "")} ${ctx.model}`).startsWith("closed");
@@ -44269,7 +44412,7 @@ ${wallTail}` : brief0;
44269
44412
  outputs.verify = { ...outputs.verify, not_proven: [...Array.isArray(outputs.verify?.not_proven) ? outputs.verify.not_proven : [], SUITE_FIX_SKIP_NOTE] };
44270
44413
  ctx.emit("loop.repeat", "fix", { reason: SUITE_FIX_SKIP_NOTE, round: 0, skipped: true });
44271
44414
  }
44272
- for (let round2 = 1;!indepSkip && round2 <= MAX_FIX_ROUNDS + extraRounds && !fatal && !capHit && !outputs.implement?.attempts?.error && !((round2 > 1 || suiteSkip) && onlyFullSuiteRed(outputs.verify)) && hasFailures(outputs.verify) && outputs.implement?.exit !== "spec_conflict" && outputs.implement?.exit !== "external"; round2++) {
44415
+ for (let round2 = 1;!indepSkip && (unbounded ? stillRounds < noProgressRounds() : round2 <= MAX_FIX_ROUNDS + extraRounds) && !fatal && !capHit && !outputs.implement?.attempts?.error && !((round2 > 1 || suiteSkip) && onlyFullSuiteRed(outputs.verify)) && hasFailures(outputs.verify) && outputs.implement?.exit !== "spec_conflict" && outputs.implement?.exit !== "external"; round2++) {
44273
44416
  const wallBefore = wallSignature(outputs, ctx.repoDir);
44274
44417
  const fx = await runStage("fix", true);
44275
44418
  if (!fx || mustJump("fix", fx) || fatal)
@@ -44318,6 +44461,14 @@ ${wallTail}` : brief0;
44318
44461
  noopSig = noop ? fedBy : null;
44319
44462
  const v = await runStage("verify", true);
44320
44463
  sigs.push(sigOf(outputs.verify, v));
44464
+ {
44465
+ const now2 = fixProgressOf(outputs.verify);
44466
+ if (now2.failing < fixBest.failing || now2.ran > fixBest.ran) {
44467
+ fixBest = { failing: Math.min(now2.failing, fixBest.failing), ran: Math.max(now2.ran, fixBest.ran) };
44468
+ stillRounds = 0;
44469
+ } else
44470
+ stillRounds++;
44471
+ }
44321
44472
  if (mustJump("verify", v))
44322
44473
  break;
44323
44474
  if (wallOnlyAfterFix(outputs, ctx.repoDir) && wallSignature(outputs, ctx.repoDir) === wallBefore)
@@ -44332,6 +44483,8 @@ ${wallTail}` : brief0;
44332
44483
  }
44333
44484
  if (round2 === 1 && round2 < MAX_FIX_ROUNDS + extraRounds && consultAvailable(ctx.runDir))
44334
44485
  continue;
44486
+ if (unbounded && stillRounds < noProgressRounds())
44487
+ continue;
44335
44488
  stopped = "stalled";
44336
44489
  break;
44337
44490
  }
@@ -44350,7 +44503,7 @@ ${wallTail}` : brief0;
44350
44503
  if (!fatal && !capHit && stopped === null && await deliverOverWallConflict(outputs, ctx.repoDir, () => runStage("verify", true), (path, why) => ctx.emit("wall.arbitrated", "wall", { path, discarded: why }), { runDir: ctx.runDir, restored: (v) => ctx.emit("stage.completed", "verify", { ...v, restored: true }) }) && wasConflict)
44351
44504
  ctx.emit("spec.conflict", "implement", { delivered: true, reason: outputs.implement?.spec_conflict_reason ?? null });
44352
44505
  if (outputs.prove)
44353
- outputs.prove = await recheckProve(sctx, outputs.prove, fatal || capHit ? 0 : Math.floor(softCapS(ctx.capS) - elapsedS2() - (STAGE_BUDGETS.commit.limitS + STAGE_BUDGETS.seal.limitS + STAGE_BUDGETS.pr.limitS)), capCtl.signal);
44506
+ outputs.prove = await recheckProve(sctx, outputs.prove, fatal || capHit ? 0 : unbounded ? proveBudgetS() : Math.floor(softCapS(ctx.capS) - elapsedS2() - (STAGE_BUDGETS.commit.limitS + STAGE_BUDGETS.seal.limitS + STAGE_BUDGETS.pr.limitS)), capCtl.signal);
44354
44507
  if (fatal) {
44355
44508
  stopped = fatal;
44356
44509
  jumped = true;
@@ -44366,7 +44519,7 @@ ${wallTail}` : brief0;
44366
44519
  throw err;
44367
44520
  } finally {
44368
44521
  abortWall();
44369
- clearTimeout(capTimer);
44522
+ capTimer.clear();
44370
44523
  removeHoldout(ctx.runId, ctx.repoDir);
44371
44524
  }
44372
44525
  }
@@ -44634,7 +44787,7 @@ async function runWorker(drive, opts = {}) {
44634
44787
  `));
44635
44788
  }
44636
44789
  function workerCapS(deep, env) {
44637
- return envCapS(env.LOKI_E10_CAP_S) ?? (deep ? DEEP_CAP_S : DEFAULT_CAP_S);
44790
+ return envCapS(env.LOKI_E10_CAP_S) ?? (deep ? DEEP_CAP_S : budgetsOn(env) ? DEFAULT_CAP_S : Infinity);
44638
44791
  }
44639
44792
  function costCapture(rawEmit, runId, repoDir, env = process.env) {
44640
44793
  const kept = env.LOKI_E10_RESUME === "1" ? readEvents(join112(repoDir, eventsRelPath(runId))).filter((e) => e.type === "cost") : [];
@@ -44703,7 +44856,7 @@ async function main(args) {
44703
44856
  clock: { now: () => Date.now() },
44704
44857
  outputs: () => ({})
44705
44858
  };
44706
- const resize = deep ? undefined : () => resizeCap(ctx.runDir, loadProjectApi(repoDir), !(Number(parseCapUsd(process.env.LOKI_E10_MAX_COST_USD)) > 0), Number(process.env.LOKI_E10_CAP_FIXED_S) || undefined);
44859
+ const resize = deep || !Number.isFinite(ctx.capS) ? undefined : () => resizeCap(ctx.runDir, loadProjectApi(repoDir), !(Number(parseCapUsd(process.env.LOKI_E10_MAX_COST_USD)) > 0), Number(process.env.LOKI_E10_CAP_FIXED_S) || undefined);
44707
44860
  let flow = FLOW.filter((s) => s !== "pr"), restored;
44708
44861
  if (process.env.LOKI_E10_RESUME === "1") {
44709
44862
  const p = join112(repoDir, eventsRelPath(runId)), r = (await Promise.resolve().then(() => (init_run_outputs(), exports_run_outputs))).resumeMachineOpts(ctx, readEvents(p), readFileSync102(p, "utf8"), flow);
@@ -44771,7 +44924,7 @@ import { copyFileSync as copyFileSync8, existsSync as existsSync77, mkdirSync as
44771
44924
  import { tmpdir as tmpdir21 } from "os";
44772
44925
  import { dirname as dirname46, join as join113 } from "path";
44773
44926
  async function runFullSuite(ctx, signal, opts, checks2, notProven2) {
44774
- 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 } : {} }, checks2, notProven2))
44927
+ if (await runPackageSuites(ctx.repoDir, signal, { path: opts.path, timeoutMs: opts.suiteTimeoutMs ?? opts.fullSuiteTimeoutMs ?? fullSuiteMs(), 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 } : {} }, checks2, notProven2))
44775
44928
  return;
44776
44929
  const map = await ctx.tests.detect(ctx.repoDir);
44777
44930
  if (map.runners.length === 0) {
@@ -44789,7 +44942,7 @@ async function runFullSuite(ctx, signal, opts, checks2, notProven2) {
44789
44942
  const started = Date.now();
44790
44943
  const r = await run([spec.cmd, ...spec.args], {
44791
44944
  cwd: ctx.repoDir,
44792
- timeoutMs: opts.fullSuiteTimeoutMs ?? FULL_SUITE_TIMEOUT_MS,
44945
+ timeoutMs: opts.fullSuiteTimeoutMs ?? fullSuiteMs(),
44793
44946
  env: suiteEnv(opts.path),
44794
44947
  ...suiteTimeoutOn() ? { group: true, signal } : {}
44795
44948
  });
@@ -44800,7 +44953,7 @@ async function runFullSuite(ctx, signal, opts, checks2, notProven2) {
44800
44953
  continue;
44801
44954
  }
44802
44955
  if (r.timedOut && suiteTimeoutOn()) {
44803
- const why = `timed out after ${Math.round((opts.fullSuiteTimeoutMs ?? FULL_SUITE_TIMEOUT_MS) / 1000)}s`;
44956
+ const why = r.silent ? `stopped after ${cmdSilenceS()}s with no output` : `timed out after ${Math.round((opts.fullSuiteTimeoutMs ?? fullSuiteMs()) / 1000)}s`;
44804
44957
  checks2.push({ name, cmd: [spec.cmd, ...spec.args].join(" "), result: "not_run", duration_s: durationS, reason: why });
44805
44958
  notProven2.add(`not run: ${name} (${why})`);
44806
44959
  continue;
@@ -45162,7 +45315,7 @@ async function deepPost(args, deps = {}) {
45162
45315
  `);
45163
45316
  return out2.some((n3) => n3.startsWith("loki/deep-verify status not set") || n3.startsWith("push refused")) ? 1 : 0;
45164
45317
  }
45165
- var DEFAULT_SECRET_SCAN_SH, FULL_SUITE_TIMEOUT_MS, deepStage, stage5;
45318
+ var DEFAULT_SECRET_SCAN_SH, fullSuiteMs = () => defaultBudgetsOn() ? BASELINE_CMD_TIMEOUT_S * 1000 : Infinity, deepStage, stage5;
45166
45319
  var init_deep = __esm(() => {
45167
45320
  init_install();
45168
45321
  init_app_probe();
@@ -45182,7 +45335,6 @@ var init_deep = __esm(() => {
45182
45335
  init_paths();
45183
45336
  init_pr();
45184
45337
  DEFAULT_SECRET_SCAN_SH = join113(REPO_ROOT, "autonomy/lib/secret-scan.sh");
45185
- FULL_SUITE_TIMEOUT_MS = BASELINE_CMD_TIMEOUT_S * 1000;
45186
45338
  deepStage = {
45187
45339
  name: "deep",
45188
45340
  ...STAGE_BUDGETS.deep,
@@ -45284,7 +45436,7 @@ function sameFailureLines(headOut, base2, changed, symbols, headRoot, baseRoot)
45284
45436
  return ![...h].some((l) => names(l));
45285
45437
  }
45286
45438
  function suiteTimeoutFor(deadlineMs, nowMs, env = process.env) {
45287
- const v = Number((env["LOKI_E10_SUITE_TIMEOUT_S"] ?? "").trim()), max = Number.isFinite(v) && v >= 1 ? Math.floor(v * 1000) : 300000;
45439
+ const v = Number((env["LOKI_E10_SUITE_TIMEOUT_S"] ?? "").trim()), max = Number.isFinite(v) && v >= 1 ? Math.floor(v * 1000) : defaultBudgetsOn(env) ? 300000 : Infinity;
45288
45440
  if (deadlineMs === undefined)
45289
45441
  return max;
45290
45442
  const left = deadlineMs - nowMs - SUITE_MARGIN_MS;
@@ -45391,7 +45543,15 @@ function editedTestTitles(repoDir, baseSha, rel) {
45391
45543
  async function runOnce3(cmd, args, cwd, signal, opts) {
45392
45544
  if (!Bun.which(cmd, { PATH: opts.path ?? process.env["PATH"] ?? "" }))
45393
45545
  return { ok: false, missing: true, cut: false, out: "" };
45394
- const timeout = AbortSignal.timeout(opts.timeoutMs ?? CHECK_TIMEOUT_MS);
45546
+ const tmo = opts.timeoutMs ?? checkTimeoutMs(), silence = new AbortController;
45547
+ let silent = false, lastByte = Date.now();
45548
+ const timeout = Number.isFinite(tmo) ? AbortSignal.timeout(Math.max(0, tmo)) : silence.signal;
45549
+ const quiet = Number.isFinite(tmo) ? undefined : setInterval(() => {
45550
+ if (Date.now() - lastByte >= cmdSilenceS() * 1000) {
45551
+ silent = true;
45552
+ silence.abort();
45553
+ }
45554
+ }, Math.min(30000, Math.max(50, cmdSilenceS() * 250)));
45395
45555
  const proc = Bun.spawn([cmd, ...args], {
45396
45556
  cwd,
45397
45557
  stdin: opts.stdin !== undefined ? Buffer.from(opts.stdin) : "ignore",
@@ -45434,19 +45594,22 @@ async function runOnce3(cmd, args, cwd, signal, opts) {
45434
45594
  const c = await r.read().catch(() => ({ done: true, value: undefined }));
45435
45595
  if (c.done)
45436
45596
  return;
45597
+ lastByte = Date.now();
45437
45598
  tail2 += d.decode(c.value, { stream: true });
45438
45599
  if (tail2.length > keep * 2)
45439
45600
  tail2 = tail2.slice(-keep);
45440
45601
  }
45441
45602
  });
45442
45603
  const exitCode = await proc.exited;
45604
+ if (quiet)
45605
+ clearInterval(quiet);
45443
45606
  await Promise.race([Promise.all(pumps), new Promise((r) => setTimeout(r, 300))]);
45444
45607
  rs.forEach((r) => r.cancel().catch(() => {}));
45445
45608
  if (opts.group)
45446
45609
  killGroup3();
45447
45610
  const cut = timeout.aborted || signal.aborted;
45448
45611
  const out2 = cut ? "" : stripAnsi(tail2.slice(-keep)), spawnTool = exitCode !== 0 && !cut ? spawnFailedTool(out2, exitCode) : null;
45449
- return { ok: exitCode === 0 && !cut, missing: spawnTool !== null, cut, out: out2, ...spawnTool ? { spawnTool } : {} };
45612
+ return { ok: exitCode === 0 && !cut, missing: spawnTool !== null, cut, out: out2, ...spawnTool ? { spawnTool } : {}, ...silent ? { silent } : {} };
45450
45613
  }
45451
45614
  async function runCheck(ctx, name, cmd, args, signal, checks2, opts = {}) {
45452
45615
  const started = Date.now();
@@ -45460,7 +45623,7 @@ async function runCheck(ctx, name, cmd, args, signal, checks2, opts = {}) {
45460
45623
  c2 = { result: "not_run", reason: lr, owner: "harness" };
45461
45624
  if (!lr && kind === "static" && !a.ok && !a.cut && !a.missing && opts.wall?.size && wallOwnedFailure(a.out, cwd, ctx.repoDir, opts.wall))
45462
45625
  c2 = { result: "not_run", reason: WALL_COMPILE_REASON, owner: "harness" };
45463
- const reason2 = a.missing ? a.spawnTool ? `${a.spawnTool} could not be started (not installed)${installHint(a.spawnTool)}` : `${cmd} not found on PATH${installHint(cmd)}` : a.cut ? signal.aborted ? "aborted" : `timed out after ${(opts.timeoutMs ?? CHECK_TIMEOUT_MS) / 1000}s` : c2.reason;
45626
+ const reason2 = a.missing ? a.spawnTool ? `${a.spawnTool} could not be started (not installed)${installHint(a.spawnTool)}` : `${cmd} not found on PATH${installHint(cmd)}` : a.cut ? signal.aborted ? "aborted" : a.silent ? `stopped after ${cmdSilenceS()}s with no output` : `timed out after ${(opts.timeoutMs ?? checkTimeoutMs()) / 1000}s` : c2.reason;
45464
45627
  return { ...c2, ...reason2 ? { reason: reason2 } : {} };
45465
45628
  };
45466
45629
  let attempt = await runOnce3(cmd, args, cwd, signal, opts);
@@ -45974,7 +46137,7 @@ async function tscOnBase(ctx, groupCwd, signal, opts, shared2) {
45974
46137
  return null;
45975
46138
  if (cwd !== shared2.dir)
45976
46139
  shared2.link(shared2.dir);
45977
- const r = await runOnce3("npx", ["--no-install", "tsc", "--noEmit", "-p", "."], cwd, AbortSignal.any([signal, AbortSignal.timeout(opts.timeoutMs ?? CHECK_TIMEOUT_MS)]), { ...opts });
46140
+ const r = await runOnce3("npx", ["--no-install", "tsc", "--noEmit", "-p", "."], cwd, AbortSignal.any([signal, Number.isFinite(opts.timeoutMs ?? checkTimeoutMs()) ? AbortSignal.timeout(opts.timeoutMs ?? checkTimeoutMs()) : new AbortController().signal]), { ...opts });
45978
46141
  return r.missing || r.cut ? null : r.out;
45979
46142
  } catch {
45980
46143
  return null;
@@ -45990,7 +46153,7 @@ async function tscOnBase(ctx, groupCwd, signal, opts, shared2) {
45990
46153
  return null;
45991
46154
  if (cwd !== dir)
45992
46155
  link(dir);
45993
- const r = await runOnce3("npx", ["--no-install", "tsc", "--noEmit", "-p", "."], cwd, AbortSignal.any([signal, AbortSignal.timeout(opts.timeoutMs ?? CHECK_TIMEOUT_MS)]), { ...opts });
46156
+ const r = await runOnce3("npx", ["--no-install", "tsc", "--noEmit", "-p", "."], cwd, AbortSignal.any([signal, Number.isFinite(opts.timeoutMs ?? checkTimeoutMs()) ? AbortSignal.timeout(opts.timeoutMs ?? checkTimeoutMs()) : new AbortController().signal]), { ...opts });
45994
46157
  return r.missing || r.cut ? null : r.out;
45995
46158
  } catch {
45996
46159
  return null;
@@ -46374,6 +46537,7 @@ async function runVerify(ctx, signal, bt) {
46374
46537
  }
46375
46538
  }
46376
46539
  const notExcused = [];
46540
+ const baseUnattributed = [];
46377
46541
  const fullNotProven = new Set;
46378
46542
  const fullErr = new Map;
46379
46543
  const ranDeeper = [];
@@ -46409,6 +46573,11 @@ async function runVerify(ctx, signal, bt) {
46409
46573
  attr.introducedChecks.push(...fa.introducedChecks);
46410
46574
  attr.line = [attr.line, fa.line].filter(Boolean).join("; ") || null;
46411
46575
  notExcused.push(...whyFullSuiteNotExcused(ctx.repoDir, ctx.baseSha, full, changed, fa.preExistingChecks, blockedIds, shown));
46576
+ {
46577
+ const namesChange = lineNamesChange(changed);
46578
+ baseUnattributed.push(...redUnattributableOnBase(ctx.repoDir, ctx.baseSha, full).filter((n3) => !fa.preExistingChecks.includes(n3) && !(full.find((c) => c.name === n3)?.excerpt ?? "").split(`
46579
+ `).some(namesChange)));
46580
+ }
46412
46581
  if (full.some((c) => c.result === "pass" || c.result === "fail")) {
46413
46582
  ranDeeper.push("full test command", "full suite");
46414
46583
  risk = markExecuted(risk, ranDeeper);
@@ -46471,7 +46640,7 @@ async function runVerify(ctx, signal, bt) {
46471
46640
  await settleNrd(ctx);
46472
46641
  if (touchedExcused.length)
46473
46642
  attr.line = [attr.line, ...touchedExcused.map((n3) => `${TOUCHED_RED}: ${n3}`)].filter(Boolean).join("; ") || null;
46474
- 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 } : {}, ...ownLintNames.length ? { own_lint: ownLintNames } : {}, independent_fail: independentFail, ...independentReds.length ? { independent_reds: independentReds } : {}, fix_gate: fixGateOf({ independent_fail: independentFail, independent_reds: independentReds }, `${String(ctx.outputs().implement?.model ?? "")} ${ctx.model}`, failuresGrouped.length > 0), 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: checks2.filter((c) => c.result === "pass" && targetNames.has(c.name)).map((c) => isHold(c) ? "holdout" : c.name), risk } };
46643
+ 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 } : {}, ...ownLintNames.length ? { own_lint: ownLintNames } : {}, independent_fail: independentFail, ...independentReds.length ? { independent_reds: independentReds } : {}, fix_gate: fixGateOf({ independent_fail: independentFail, independent_reds: independentReds }, `${String(ctx.outputs().implement?.model ?? "")} ${ctx.model}`, failuresGrouped.length > 0), 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 } : {}, ...baseUnattributed.length ? { base_unattributed: baseUnattributed } : {}, ...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: checks2.filter((c) => c.result === "pass" && targetNames.has(c.name)).map((c) => isHold(c) ? "holdout" : c.name), risk } };
46475
46644
  }
46476
46645
  }
46477
46646
  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 = (out2, roots2) => {
@@ -46486,10 +46655,10 @@ var timeoutCarryOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LO
46486
46655
  for (const r of [...new Set(all)].filter((x) => x.length > 1).sort((a, b) => b.length - a.length))
46487
46656
  o = o.split(r).join("<repo>");
46488
46657
  return o;
46489
- }, 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 = (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}`, 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, OWN_LINT, OWN_TYPECHECK, haikuIndepFixOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_HAIKU_INDEP_FIX"] ?? "").trim()), ownLintOf = (c, pre, changed, symbols, excerpt2, re = OWN_LINT) => re.test(c.name) && feedsFixRound(c, pre) && !uncausedRed(c, changed, symbols, excerpt2), 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, cmd, prefix, cwd, rel, opts) => c.result !== "fail" || signal.aborted ? Promise.resolve(false) : staticPreExisting(tool, prefix, rel, { run: async (a, stdin) => {
46658
+ }, SUITE_MARGIN_MS = 5000, CHECK_TIMEOUT_MS = 60000, checkTimeoutMs = () => defaultBudgetsOn() ? CHECK_TIMEOUT_MS : Infinity, 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 = (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}`, 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) => defaultBudgetsOn() ? Math.max(CHECK_TIMEOUT_MS, Math.min(300000, files * 5000)) : Infinity, 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, OWN_LINT, OWN_TYPECHECK, haikuIndepFixOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_HAIKU_INDEP_FIX"] ?? "").trim()), ownLintOf = (c, pre, changed, symbols, excerpt2, re = OWN_LINT) => re.test(c.name) && feedsFixRound(c, pre) && !uncausedRed(c, changed, symbols, excerpt2), 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, cmd, prefix, cwd, rel, opts) => c.result !== "fail" || signal.aborted ? Promise.resolve(false) : staticPreExisting(tool, prefix, rel, { run: async (a, stdin) => {
46490
46659
  if (signal.aborted)
46491
46660
  return null;
46492
- const r = await runOnce3(cmd, a, cwd, AbortSignal.any([signal, AbortSignal.timeout(opts.timeoutMs ?? CHECK_TIMEOUT_MS)]), { ...opts, ...stdin !== undefined ? { stdin } : {} });
46661
+ const r = await runOnce3(cmd, a, cwd, AbortSignal.any([signal, Number.isFinite(opts.timeoutMs ?? checkTimeoutMs()) ? AbortSignal.timeout(opts.timeoutMs ?? checkTimeoutMs()) : new AbortController().signal]), { ...opts, ...stdin !== undefined ? { stdin } : {} });
46493
46662
  return r.missing || r.cut ? null : r;
46494
46663
  }, base: (f) => {
46495
46664
  try {
@@ -48136,6 +48305,7 @@ var exports_seal = {};
48136
48305
  __export(exports_seal, {
48137
48306
  wallGreenOnBaseOf: () => wallGreenOnBaseOf,
48138
48307
  verdictOf: () => verdictOf2,
48308
+ unattributedRed: () => unattributedRed,
48139
48309
  targetedBreak: () => targetedBreak,
48140
48310
  targetProofOf: () => targetProofOf,
48141
48311
  stage: () => stage8,
@@ -48348,6 +48518,11 @@ function secretPushRefusal(verify4, runId) {
48348
48518
  return null;
48349
48519
  return { check: "security scan", matches: m && m.length ? m : ["(where it matched was not recorded)"], command: `git push -u origin loki/${runId}` };
48350
48520
  }
48521
+ function unattributedRed(o, c) {
48522
+ const cut = o.verify?.stopped_at === "limit" || o.verify?.stopped_at === "cap", head = c.name.split(":")[0];
48523
+ const baseRed = head === "full suite" && strs2(o.verify?.base_unattributed).includes(c.name);
48524
+ return (cut || baseRed) && c.provenance === "exogenous" && c.name.includes(":") && !/^(lint|typecheck|holdout|select-tests|build|patch|turn)$/.test(head);
48525
+ }
48351
48526
  function verdictOf2(o, checks2, emptyDiff, verifyNotProven, wallGreenOnBase, proof, targetProof = false, uncovered = [], leanGap = [], copyGap = [], clauseGap = []) {
48352
48527
  const exit = o.implement?.exit;
48353
48528
  if (o.commit?.failed !== true && strs2(o.commit?.not_proven).length === 0 && (o.intake?.already_satisfied === true || exit === "already_done"))
@@ -48362,7 +48537,7 @@ function verdictOf2(o, checks2, emptyDiff, verifyNotProven, wallGreenOnBase, pro
48362
48537
  return typeof o.implement?.limit_s === "number" && targetProof && uncovered.length === 0 && copyGap.length === 0 && clauseGap.length === 0 && proof && !wallGreenOnBase && !verifyNotProven && checks2.length > 0 && checks2.every((c) => c.result === "pass") ? "VERIFIED" : "PARTIAL";
48363
48538
  if (typeof o.implement?.limit_s === "number")
48364
48539
  return "PARTIAL";
48365
- if (checks2.some((c) => c.result === "fail"))
48540
+ if (checks2.some((c) => c.result === "fail" && !unattributedRed(o, c)))
48366
48541
  return "FAILED";
48367
48542
  if (exit === "external" && !(Array.isArray(o.wall?.files) && o.wall.files.length > 0))
48368
48543
  return "PARTIAL";
@@ -57403,6 +57578,8 @@ __export(exports_supervisor, {
57403
57578
  TAMPER_NOT_PROVEN: () => TAMPER_NOT_PROVEN,
57404
57579
  SupervisorLog: () => SupervisorLog,
57405
57580
  START_LINE: () => START_LINE,
57581
+ HANG_SEALED_NOTE: () => HANG_SEALED_NOTE,
57582
+ HANG_NOT_PROVEN: () => HANG_NOT_PROVEN,
57406
57583
  BACKSTOP_SEAL_MIN_MS: () => BACKSTOP_SEAL_MIN_MS,
57407
57584
  BACKSTOP_SEAL_MAX_MS: () => BACKSTOP_SEAL_MAX_MS,
57408
57585
  BACKSTOP_SEAL_MARGIN_S: () => BACKSTOP_SEAL_MARGIN_S,
@@ -57583,6 +57760,11 @@ class SupervisorLog {
57583
57760
  }
57584
57761
  }
57585
57762
  function applyCapEnv(env, capS, sized) {
57763
+ if (!Number.isFinite(capS)) {
57764
+ delete env.LOKI_E10_CAP_S;
57765
+ delete env.LOKI_E10_CAP_FIXED_S;
57766
+ return;
57767
+ }
57586
57768
  env.LOKI_E10_CAP_S = String(capS);
57587
57769
  if (sized) {
57588
57770
  if (sized.fixedS)
@@ -57641,10 +57823,12 @@ async function runSupervisor(opts) {
57641
57823
  else
57642
57824
  delete workerEnv[WORK_ROAD_ENV];
57643
57825
  workerEnv.LOKI_INTENT_TTY = env.LOKI_CONFIRM === "1" && process.stdin.isTTY === true && process.stdout.isTTY === true ? "1" : "0";
57644
- const capS = opts.capS ?? envCapS(env.LOKI_E10_CAP_S) ?? DEFAULT_CAP_S;
57826
+ const capS = opts.capS ?? envCapS(env.LOKI_E10_CAP_S) ?? (budgetsOn(env) ? DEFAULT_CAP_S : Infinity);
57645
57827
  const ceilingS = Math.max(capS, opts.capCeilingS ?? capS);
57646
57828
  const backstopMs = backstopS(ceilingS, opts.graceS ?? BACKSTOP_GRACE_S) * 1000;
57647
- const escalateMs = Math.max(0, Math.min(2000, ceilingS * 1000 - backstopMs));
57829
+ const escalateMs = Number.isFinite(ceilingS) ? Math.max(0, Math.min(2000, ceilingS * 1000 - backstopMs)) : 2000;
57830
+ let lastEventMs = Date.now();
57831
+ const hang = Number.isFinite(ceilingS) ? undefined : { silenceS: hangSilenceS(env), lastEventMs: () => lastEventMs };
57648
57832
  let spawnArgv = opts.workerArgv;
57649
57833
  try {
57650
57834
  spawnArgv = ulimitArgv(opts.workerArgv, workerEnv);
@@ -57655,6 +57839,7 @@ async function runSupervisor(opts) {
57655
57839
  const onWorkerLine = (line2) => {
57656
57840
  const e = log.ingest(line2);
57657
57841
  if (e) {
57842
+ lastEventMs = Date.now();
57658
57843
  stuck.event(String(e.stage ?? "unknown"), Date.now());
57659
57844
  quiet.event(e.stage ?? null, e.type, Date.now());
57660
57845
  }
@@ -57669,7 +57854,7 @@ async function runSupervisor(opts) {
57669
57854
  }
57670
57855
  };
57671
57856
  let workerStopped = false;
57672
- let worker = await spawnWorker(opts.workerArgv, workerEnv, opts.repoDir, backstopMs, escalateMs, onWorkerLine, (stopped) => {
57857
+ let worker = await spawnWorker(opts.workerArgv, workerEnv, opts.repoDir, backstopMs, escalateMs, onWorkerLine, hang, (stopped) => {
57673
57858
  for (const g2 of sessionGroups)
57674
57859
  killGroup2(g2, "SIGKILL");
57675
57860
  workerStopped = stopped;
@@ -57694,7 +57879,7 @@ async function runSupervisor(opts) {
57694
57879
  safeGit(opts.repoDir, ["checkout", runBr], { stdio: "ignore" });
57695
57880
  } catch {}
57696
57881
  log.sealLog();
57697
- const sealed2 = await spawnWorker(opts.workerArgv, { ...workerEnv, LOKI_E10_RESUME: "1", LOKI_E10_SEAL_ONLY: "1" }, opts.repoDir, leftMs, escalateMs, onWorkerLine, () => {
57882
+ const sealed2 = await spawnWorker(opts.workerArgv, { ...workerEnv, LOKI_E10_RESUME: "1", LOKI_E10_SEAL_ONLY: "1" }, opts.repoDir, leftMs, escalateMs, onWorkerLine, undefined, () => {
57698
57883
  for (const g2 of sessionGroups)
57699
57884
  killGroup2(g2, "SIGKILL");
57700
57885
  });
@@ -57710,7 +57895,7 @@ async function runSupervisor(opts) {
57710
57895
  const receiptVerdict = workerExit === 0 && typeof v === "string" && VERDICTS2.has(v), verdict = receiptVerdict ? v : "FAILED";
57711
57896
  const notProven2 = Array.isArray(sealedData?.not_proven) ? sealedData.not_proven.map(String) : [];
57712
57897
  if (worker.killed)
57713
- notProven2.push(sealPass && sealed ? BACKSTOP_SEALED_NOTE : BACKSTOP_NOT_PROVEN);
57898
+ notProven2.push(worker.hung ? sealPass && sealed ? HANG_SEALED_NOTE : HANG_NOT_PROVEN : sealPass && sealed ? BACKSTOP_SEALED_NOTE : BACKSTOP_NOT_PROVEN);
57714
57899
  const ev0 = readEvents(log.path), usage = worker.cancelled ? null : usageLimitOfRun(ev0);
57715
57900
  const cancelled2 = worker.cancelled ?? (ev0.some((e) => e.type === "cancel_effective") ? "request" : usage ? "usage limit" : null);
57716
57901
  if (cancelled2)
@@ -57834,7 +58019,16 @@ async function main3(args) {
57834
58019
  verbose = true;
57835
58020
  else if (a === "--quiet")
57836
58021
  quiet = true;
57837
- else if (a === "--max-cost") {
58022
+ else if (TIME_FLAGS[a.split("=")[0]]) {
58023
+ const name = a.split("=")[0], v = a.includes("=") ? a.slice(a.indexOf("=") + 1) : args[++i], s = parseDurationS(v);
58024
+ if (s === null) {
58025
+ process.stderr.write(`engine10: ${name} needs a duration (seconds, or 90m / 2h), got '${v ?? ""}'
58026
+ `);
58027
+ noteRefusal("unsupported_flag");
58028
+ return 2;
58029
+ }
58030
+ process.env[TIME_FLAGS[name]] = String(s);
58031
+ } else if (a === "--max-cost") {
57838
58032
  const v = args[i + 1];
57839
58033
  if (v === undefined || v === "" || v.startsWith("-")) {
57840
58034
  process.stderr.write(`engine10: --max-cost needs a value
@@ -57902,7 +58096,7 @@ async function main3(args) {
57902
58096
  eoo = true;
57903
58097
  else if (!eoo && /^--?[A-Za-z][\w-]*(=\S*)?$/.test(a)) {
57904
58098
  process.stderr.write(`engine10: unknown flag ${a}
57905
- usage: loki "<task>" [--no-pr] [--deep] [--verified] [--json] [--verbose] [--quiet] [--max-cost N] [--provider P] [--spec F] [--seal-existing PATCH] [--resume] [--fresh] [--base-current] [-- <task>]
58099
+ usage: loki "<task>" [--no-pr] [--deep] [--verified] [--json] [--verbose] [--quiet] [--max-cost N] [--max-time DUR] [--verify-max-time DUR] [--provider P] [--spec F] [--seal-existing PATCH] [--resume] [--fresh] [--base-current] [-- <task>]
57906
58100
  `);
57907
58101
  noteRefusal("unsupported_flag");
57908
58102
  return 2;
@@ -58420,7 +58614,7 @@ var START_LINE = "Loki 10 engine", TAMPER_NOT_PROVEN = "event log modified outsi
58420
58614
  return 120;
58421
58615
  const v = Number(raw2);
58422
58616
  return Number.isFinite(v) && v >= 0 ? v : 120;
58423
- }, deepPostOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_DEEP_POST"] ?? "").trim()), VERDICTS2, ALIVE_BEAT_MS = 15000, SESSION_EXITS, BACKSTOP_NOT_PROVEN = "worker killed by the supervisor backstop (cap minus grace)", BACKSTOP_SEALED_NOTE = "time ran out: the worker was stopped at its time limit and the current tree was sealed by a seal pass", backstopSealOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_BACKSTOP_SEAL"] ?? "").trim()), BACKSTOP_SEAL_MAX_MS = 45000, BACKSTOP_SEAL_MIN_MS = 1e4, BACKSTOP_SEAL_MARGIN_S = 25, isRev = (r) => typeof r === "object" && r !== null && Number.isInteger(r.rev) && nonNegNum(r.at), nonNegNum = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0, ISSUE_RE, runSummaryCost = (events2, tampered, repoDir) => summaryCost(events2, tampered, join135(repoDir, ".loki"));
58617
+ }, deepPostOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_DEEP_POST"] ?? "").trim()), VERDICTS2, ALIVE_BEAT_MS = 15000, SESSION_EXITS, BACKSTOP_NOT_PROVEN = "worker killed by the supervisor backstop (cap minus grace)", HANG_NOT_PROVEN = "worker stopped by the supervisor: no event and no running process for the hang window (LOKI_E10_HANG_SILENCE_S)", HANG_SEALED_NOTE = "the worker made no progress (no event and no running process for the hang window) and was stopped; the current tree was sealed by a seal pass", BACKSTOP_SEALED_NOTE = "time ran out: the worker was stopped at its time limit and the current tree was sealed by a seal pass", backstopSealOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_BACKSTOP_SEAL"] ?? "").trim()), BACKSTOP_SEAL_MAX_MS = 45000, BACKSTOP_SEAL_MIN_MS = 1e4, BACKSTOP_SEAL_MARGIN_S = 25, isRev = (r) => typeof r === "object" && r !== null && Number.isInteger(r.rev) && nonNegNum(r.at), nonNegNum = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0, ISSUE_RE, runSummaryCost = (events2, tampered, repoDir) => summaryCost(events2, tampered, join135(repoDir, ".loki"));
58424
58618
  var init_supervisor = __esm(() => {
58425
58619
  init_worker_proc();
58426
58620
  init_route_block();
@@ -107555,13 +107749,13 @@ function createSessionRunner(cfg) {
107555
107749
  };
107556
107750
  cfg.emit?.("session.started", opts.stage, { session_id: sessionId, provider: cfg.provider, model: opts.model ?? cfg.model ?? null, pgid: pgid ?? null });
107557
107751
  const onAbort = () => kill("aborted");
107558
- const limitTimer = setTimeout(() => kill("limit"), opts.limitS * 1000);
107752
+ const limitTimer = armTimer(() => kill("limit"), opts.limitS * 1000);
107559
107753
  const capUsd = parseCapUsd(process.env["LOKI_E10_MAX_COST_USD"]), effDir = cfg.lokiRoot ? join162(cfg.lokiRoot, "metrics", "efficiency") : null, effBase = effDir !== null && capUsd !== null ? calculateCostFromRecords(readEfficiencyDir(effDir)) : 0;
107560
107754
  const stopBudgetWatch = isGuarded(cfg.provider) && capUsd !== null ? watchBudget(() => (cfg.remaining?.() ?? 1) <= 0 || effDir !== null && calculateCostFromRecords(readEfficiencyDir(effDir)) - effBase >= capUsd, () => {
107561
107755
  cfg.emit?.("guard.budget_stop", opts.stage, { provider: cfg.provider });
107562
107756
  kill("limit");
107563
107757
  }) : () => {};
107564
- const watchdog = createWatchdog(Date.now), stallKill = stallKillS();
107758
+ const noLimit = !Number.isFinite(opts.limitS), watchdog = createWatchdog(Date.now), stallKill = stallKillS(undefined, noLimit ? SILENCE_KILL_S : 0), loopKill = noLimit ? loopKillS() : 0;
107565
107759
  const heartbeatTimer = setInterval(() => {
107566
107760
  const un2 = untrackedList(opts.cwd), diff = diffShortstat(opts.cwd, un2), w = watchdog.tick(stdout.length + errBytes, diffSignature(opts.cwd, diff, un2));
107567
107761
  const live2 = readSessionId(opts.cwd ?? process.cwd(), opts.iterationId);
@@ -107570,13 +107764,17 @@ function createSessionRunner(cfg) {
107570
107764
  cfg.emit?.("session.stalled", opts.stage, { session_id: sessionId, idle_s: w.idleS, threshold_s: stallThresholdS() });
107571
107765
  if (stallKill > 0 && w.idleS >= stallKill)
107572
107766
  kill("stalled");
107767
+ else if (loopKill > 0 && w.diffIdleS >= loopKill) {
107768
+ cfg.emit?.("session.looping", opts.stage, { session_id: sessionId, no_tree_change_s: Math.round(w.diffIdleS), threshold_s: loopKill });
107769
+ kill("stalled");
107770
+ }
107573
107771
  }, cfg.heartbeatMs ?? HEARTBEAT_MS_DEFAULT);
107574
107772
  opts.signal.addEventListener("abort", onAbort, { once: true });
107575
107773
  const untrack = trackSession(() => kill("aborted"));
107576
107774
  return new Promise((resolve46) => {
107577
107775
  child.on("exit", () => reapLiveGroup(pgid, () => cfg.emit?.("session.group_reaped", opts.stage, { session_id: sessionId, pgid })));
107578
107776
  child.on("close", (code) => {
107579
- clearTimeout(limitTimer);
107777
+ limitTimer.clear();
107580
107778
  clearInterval(heartbeatTimer);
107581
107779
  stopBudgetWatch();
107582
107780
  if (workRun) {
@@ -107685,6 +107883,7 @@ var init_session3 = __esm(() => {
107685
107883
  init_hooks();
107686
107884
  init_session_resume();
107687
107885
  init_session_route();
107886
+ init_types2();
107688
107887
  init_worker_proc();
107689
107888
  init_providers();
107690
107889
  init_model_rank();
@@ -110688,7 +110887,8 @@ function startWatchdog(pgid) {
110688
110887
  }
110689
110888
  }
110690
110889
  function spawnGroupSync(cmd2, args, o) {
110691
- const r = spawnSync30(process.execPath, [...SAFE_BUN_FLAGS, "-e", GROUP_LAUNCHER], { input: JSON.stringify([cmd2, args, o.cwd ?? "", o.timeoutMs, watchdogArgv(), o.env ?? plainTestEnv()]), env: { PATH: process.env["PATH"] ?? "" }, encoding: "utf8", timeout: o.timeoutMs + 5000, killSignal: "SIGKILL", maxBuffer: 16 * 1024 * 1024 });
110890
+ const fin = Number.isFinite(o.timeoutMs);
110891
+ const r = spawnSync30(process.execPath, [...SAFE_BUN_FLAGS, "-e", GROUP_LAUNCHER], { input: JSON.stringify([cmd2, args, o.cwd ?? "", fin ? o.timeoutMs : 0, watchdogArgv(), o.env ?? plainTestEnv(), fin ? 0 : cmdSilenceS() * 1000]), env: { PATH: process.env["PATH"] ?? "" }, encoding: "utf8", ...fin ? { timeout: o.timeoutMs + 5000 } : {}, killSignal: "SIGKILL", maxBuffer: 16 * 1024 * 1024 });
110692
110892
  try {
110693
110893
  return JSON.parse(r.stdout);
110694
110894
  } catch {
@@ -110701,10 +110901,14 @@ function spawnCollect(cmd2, args, o) {
110701
110901
  let out3 = "", err = "", error = false, done = false;
110702
110902
  const MAX = o.maxBytes ?? 1024 * 1024;
110703
110903
  const timers = [];
110904
+ let main9, quiet, lastByte = Date.now();
110704
110905
  const fin = (status2) => {
110705
110906
  if (!done) {
110706
110907
  done = true;
110707
110908
  timers.forEach(clearTimeout);
110909
+ main9?.clear();
110910
+ if (quiet)
110911
+ clearInterval(quiet);
110708
110912
  o.signal?.removeEventListener("abort", abort);
110709
110913
  killGroup2(c.pid, "SIGKILL");
110710
110914
  wd2?.kill("SIGKILL");
@@ -110721,14 +110925,22 @@ ${err}` });
110721
110925
  c.kill("SIGTERM");
110722
110926
  }
110723
110927
  };
110724
- timers.push(setTimeout(() => {
110928
+ const expire = () => {
110725
110929
  error = true;
110726
110930
  term();
110727
110931
  timers.push(setTimeout(() => {
110728
110932
  killGroup2(c.pid, "SIGKILL");
110729
110933
  fin(null);
110730
110934
  }, 1000));
110731
- }, o.timeoutMs));
110935
+ };
110936
+ main9 = armTimer(expire, o.timeoutMs);
110937
+ if (!Number.isFinite(o.timeoutMs))
110938
+ quiet = setInterval(() => {
110939
+ if (Date.now() - lastByte >= cmdSilenceS() * 1000) {
110940
+ clearInterval(quiet);
110941
+ expire();
110942
+ }
110943
+ }, Math.min(30000, Math.max(50, cmdSilenceS() * 250)));
110732
110944
  const abort = () => {
110733
110945
  error = true;
110734
110946
  term();
@@ -110748,10 +110960,12 @@ ${err}` });
110748
110960
  }
110749
110961
  };
110750
110962
  c.stdout?.on("data", (d) => {
110963
+ lastByte = Date.now();
110751
110964
  out3 += d;
110752
110965
  over2();
110753
110966
  });
110754
110967
  c.stderr?.on("data", (d) => {
110968
+ lastByte = Date.now();
110755
110969
  err += d;
110756
110970
  over2();
110757
110971
  });
@@ -111186,14 +111400,14 @@ exit $st`, wrapperOr = (repoDir, w, bare) => existsSync120(join167(repoDir, w))
111186
111400
  }, verifyJobs = () => {
111187
111401
  const n10 = Number.parseInt(process.env["LOKI_E10_VERIFY_JOBS"] ?? "", 10);
111188
111402
  return Number.isFinite(n10) && n10 >= 1 ? Math.min(n10, 8) : 1;
111189
- }, WATCHDOG = `const O = __O__, G = __G__; setInterval(() => { try { process.kill(O, 0); } catch { try { process.kill(-G, "SIGKILL"); } catch {} process.exit(0); } }, 200);`, watchdogArgv = () => [process.execPath, ...SAFE_BUN_FLAGS, "-e", WATCHDOG], GROUP_LAUNCHER = `const { spawn } = require("node:child_process"); const fs = require("node:fs"); const [cmd, args, cwd, ms, wd, env] = JSON.parse(fs.readFileSync(0, "utf8")); const MAX = 1048576; let out = "", err = "", to = false, fin = false;
111403
+ }, WATCHDOG = `const O = __O__, G = __G__; setInterval(() => { try { process.kill(O, 0); } catch { try { process.kill(-G, "SIGKILL"); } catch {} process.exit(0); } }, 200);`, watchdogArgv = () => [process.execPath, ...SAFE_BUN_FLAGS, "-e", WATCHDOG], GROUP_LAUNCHER = `const { spawn } = require("node:child_process"); const fs = require("node:fs"); const [cmd, args, cwd, ms, wd, env, sil] = JSON.parse(fs.readFileSync(0, "utf8")); const MAX = 1048576; let out = "", err = "", to = false, fin = false, last = Date.now();
111190
111404
  const c = spawn(cmd, args, { cwd: cwd || undefined, env, detached: true, stdio: ["ignore", "pipe", "pipe"] });
111191
111405
  let w; try { const a = wd.slice(1); a[a.length - 1] = a[a.length - 1].replace("__O__", String(process.pid)).replace("__G__", String(c.pid)); w = spawn(wd[0], a, { detached: true, stdio: "ignore", env: { PATH: process.env.PATH || "" } }); w.on("error", () => {}); } catch {}
111192
111406
  const kill = (s) => { try { process.kill(-c.pid, s); } catch { try { c.kill(s); } catch {} } };
111193
111407
  const done = (code, sig) => { if (fin) return; fin = true; kill("SIGKILL"); try { w.kill("SIGKILL"); } catch {} const b = Buffer.from(JSON.stringify({ status: to || sig ? null : code, output: out + "\\n" + err })); for (let i = 0; i < b.length;) { try { i += fs.writeSync(1, b, i); } catch (e) { if (e.code !== "EAGAIN") break; } } process.exit(0); };
111194
- setTimeout(() => { to = true; kill("SIGTERM"); setTimeout(() => done(null, 1), 1000); }, ms);
111408
+ const expire = () => { to = true; kill("SIGTERM"); setTimeout(() => done(null, 1), 1000); }; if (ms) setTimeout(expire, ms); if (sil) { const q = setInterval(() => { if (Date.now() - last >= sil) { clearInterval(q); expire(); } }, Math.min(30000, Math.max(50, Math.floor(sil / 4)))); }
111195
111409
  const over = () => { if (out.length > MAX || err.length > MAX) { to = true; kill("SIGKILL"); } };
111196
- c.stdout.on("data", (d) => { out += d; over(); }); c.stderr.on("data", (d) => { err += d; over(); });
111410
+ c.stdout.on("data", (d) => { last = Date.now(); out += d; over(); }); c.stderr.on("data", (d) => { last = Date.now(); err += d; over(); });
111197
111411
  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, genericSuiteLine = (runner, repoDir) => {
111198
111412
  const f = discoveredSuiteCmd(runner, repoDir);
111199
111413
  return [f.cmd, ...f.args].join(" ");
@@ -111205,6 +111419,7 @@ var init_check_result = __esm(() => {
111205
111419
  init_resolve();
111206
111420
  init_guides();
111207
111421
  init_testmap();
111422
+ init_types2();
111208
111423
  init_lock_ecosystems();
111209
111424
  init_python_build_check();
111210
111425
  init_safe_git();
@@ -134748,6 +134963,8 @@ async function resumeToFinish(ctx, first, session3, o) {
134748
134963
  const missing = () => readPlanScope(ctx.runDir).filter((f) => !existsSync122(join171(ctx.repoDir, f)));
134749
134964
  let unchanged = 0;
134750
134965
  let cur = session3, outstanding = outstandingOf(session3.summary), base2 = first, ended = max === 0 ? "continue off" : "count cap", spent = null;
134966
+ const noCount = !Number.isFinite(max), saidBefore = new Set([outstanding]);
134967
+ let fewestMissing = noCount ? missing().length : 0;
134751
134968
  for (let n10 = 1;n10 <= max; n10++) {
134752
134969
  if (o.signal.aborted) {
134753
134970
  ended = "aborted";
@@ -134782,6 +134999,18 @@ async function resumeToFinish(ctx, first, session3, o) {
134782
134999
  ended = "tree unknown";
134783
135000
  break;
134784
135001
  }
135002
+ if (noCount) {
135003
+ const left = missing().length, said = outstandingOf(r.reply.summary), moved = left < fewestMissing || said !== "" && !saidBefore.has(said);
135004
+ fewestMissing = Math.min(fewestMissing, left);
135005
+ saidBefore.add(said);
135006
+ if (moved)
135007
+ unchanged = 0;
135008
+ else if (++unchanged >= noProgressRounds(env2)) {
135009
+ ended = "no progress";
135010
+ break;
135011
+ }
135012
+ continue;
135013
+ }
134785
135014
  if (before === after) {
134786
135015
  if (++unchanged >= 2) {
134787
135016
  ended = "tree unchanged";
@@ -135313,10 +135542,10 @@ var refereeModel = (ctx) => capToRunTier(wallPinModel(), ctx.model, ["LOKI_E10_W
135313
135542
  if (isOff(v10))
135314
135543
  return 0;
135315
135544
  const n10 = Number(v10);
135316
- return v10 !== "" && Number.isInteger(n10) && n10 >= 0 ? Math.min(n10, 10) : CONTINUE_MAX_DEFAULT;
135545
+ return v10 !== "" && Number.isInteger(n10) && n10 >= 0 ? Math.min(n10, 10) : defaultBudgetsOn(env2) ? CONTINUE_MAX_DEFAULT : Infinity;
135317
135546
  }, continueMaxUsd = (env2 = process.env) => {
135318
135547
  const n10 = Number((env2["LOKI_E10_CONTINUE_MAX_USD"] ?? "").trim());
135319
- return (env2["LOKI_E10_CONTINUE_MAX_USD"] ?? "").trim() !== "" && Number.isFinite(n10) && n10 >= 0 ? n10 : CONTINUE_MAX_USD_DEFAULT;
135548
+ return (env2["LOKI_E10_CONTINUE_MAX_USD"] ?? "").trim() !== "" && Number.isFinite(n10) && n10 >= 0 ? n10 : defaultBudgetsOn(env2) ? CONTINUE_MAX_USD_DEFAULT : Infinity;
135320
135549
  }, lacksFinishLine = (provider, s) => provider === "claude" && s.markers.finishLine === null, conflictNeedsTestOn = (env2 = process.env) => /^(1|on|true|yes)$/i.test((env2["LOKI_E10_CONFLICT_NEEDS_TEST"] ?? "").trim()), asUnfinishedConflict = (s) => s.markers.specConflict !== null && !citesTestFile(s.markers.specConflict) ? { ...s, markers: { ...s.markers, specConflict: null, finishLine: s.markers.finishLine === "spec_conflict" ? null : s.markers.finishLine } } : s, resumeForProofScript = (ctx, first, firstSession, brief) => (ctx.implementLeftS?.() ?? Infinity) < RESUME_MIN_LEFT_S ? Promise.resolve({ session: firstSession, iterationId: first.iterationId }) : resumeWith(ctx, first, firstSession, brief, "-pf"), resumeAfterEmptyDone = (ctx, first, firstSession, challenge = false) => resumeWith(ctx, first, firstSession, challenge ? EMPTY_DONE_CHALLENGED : EMPTY_DONE_CORRECTION, "-e"), resumeNeverStop = (ctx, first, firstSession, reason, advice) => (ctx.implementLeftS?.() ?? Infinity) < RESUME_MIN_LEFT_S ? Promise.resolve({ session: firstSession, iterationId: first.iterationId }) : resumeWith(ctx, first, firstSession, neverStopBrief(reason, advice), "-n"), runVerifiedFinish = async (ctx, first, firstSession, brief, maxTurns) => {
135321
135550
  if ((ctx.implementLeftS?.() ?? Infinity) < RESUME_MIN_LEFT_S)
135322
135551
  return null;
@@ -135336,7 +135565,7 @@ var refereeModel = (ctx) => capToRunTier(wallPinModel(), ctx.model, ["LOKI_E10_W
135336
135565
  if (isOff(v10))
135337
135566
  return;
135338
135567
  const n10 = Number(v10);
135339
- return v10 !== "" && Number.isInteger(n10) && n10 > 0 ? n10 : COVERAGE_MAX_TURNS_DEFAULT;
135568
+ return v10 !== "" && Number.isInteger(n10) && n10 > 0 ? n10 : defaultBudgetsOn(env2) ? COVERAGE_MAX_TURNS_DEFAULT : 0;
135340
135569
  }, siteHintsEnabled = (env2 = process.env) => !["0", "off", "false"].includes((env2.LOKI_E10_SITE_HINTS ?? "").toLowerCase()), claimAbsentBrief = (sites) => `You wrote SITE ... changed for these lines, but each is byte-identical to the base: ${sites.join(", ")}. Make the change at each one, or write it as unchanged with the reason. ` + FINISH_LINE, oneLine6 = (s) => s.replace(/[\u0000-\u001f\u007f]+/g, " ").trim().slice(0, 200), REFEREE_PER_CHECK = 1, REFEREE_PER_RUN = 2, wallRefereeEnabled = (env2 = process.env) => !["0", "off", "false"].includes((env2.LOKI_E10_WALL_REFEREE ?? "").toLowerCase()), defaultRunCheck = (dir, ref) => {
135341
135570
  const r = new RealBaseTestRunner(undefined, undefined, { PYTHONDONTWRITEBYTECODE: "1" }).run(dir, [ref]);
135342
135571
  return r.fail > 0 ? "fail" : r.pass > 0 && (r.not_run ?? 0) === 0 ? "pass" : "not_run";
@@ -135373,6 +135602,7 @@ ${diff.length > REMEDY_DIFF_CAP ? `${diff.slice(0, REMEDY_DIFF_CAP)}
135373
135602
  return miss && !impl ? "missing" : impl && !miss ? "implemented" : null;
135374
135603
  }, remedyResumeBrief = (remedy) => `The issue's first-choice remedy is not in your change: "${remedy}". Implement that remedy now, keep any other fix only on top of it, run the targeted tests, then finish. ` + FINISH_LINE, remedyCallOverride = null;
135375
135604
  var init_conflict_resume = __esm(() => {
135605
+ init_types2();
135376
135606
  init_role_agents();
135377
135607
  init_opus_consult();
135378
135608
  init_session_resume();