loki-mode 11.79.0 → 11.80.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 (67) hide show
  1. package/SKILL.md +2 -2
  2. package/VERSION +1 -1
  3. package/dashboard/__init__.py +1 -1
  4. package/docs/CLI-REFERENCE.md +1 -1
  5. package/docs/INSTALLATION.md +1 -1
  6. package/loki-ts/dist/loki.js +1232 -1226
  7. package/mcp/__init__.py +1 -1
  8. package/package.json +2 -2
  9. package/packages/control-plane/dist/server.js +815 -691
  10. package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
  11. package/web-app/dist/assets/{AdminPage-Bph4VGNm.js → AdminPage-CTjc-kZR.js} +1 -1
  12. package/web-app/dist/assets/{Avatar-Btrppoor.js → Avatar-jCkulCqr.js} +1 -1
  13. package/web-app/dist/assets/{Badge-fJFe3CEH.js → Badge-qpQ-lEZq.js} +1 -1
  14. package/web-app/dist/assets/{Button-B_cYY4Me.js → Button-4iftHCyI.js} +1 -1
  15. package/web-app/dist/assets/{CockpitPage-26oBcuYy.js → CockpitPage-Cp2_mbbY.js} +1 -1
  16. package/web-app/dist/assets/{ComparePage-CSuQZUm2.js → ComparePage-CgivC47G.js} +1 -1
  17. package/web-app/dist/assets/{ErrorBoundary-Cf7DQMz0.js → ErrorBoundary-j_et9NFe.js} +1 -1
  18. package/web-app/dist/assets/{EvidenceReceiptPanel-BMZszYBV.js → EvidenceReceiptPanel-CrxgSnnS.js} +1 -1
  19. package/web-app/dist/assets/{GitHubIssuesPanel-Bt5dkJwW.js → GitHubIssuesPanel-Ba0PiXYO.js} +1 -1
  20. package/web-app/dist/assets/{GitHubPRsPanel-CL4NbWJ3.js → GitHubPRsPanel-wDbkPzbC.js} +1 -1
  21. package/web-app/dist/assets/{HomePage-Bqugxf45.js → HomePage-DQu789yI.js} +2 -2
  22. package/web-app/dist/assets/{LoginPage-ENM9QyG8.js → LoginPage-DalsZBAU.js} +1 -1
  23. package/web-app/dist/assets/{MagicPage-D-7g-mew.js → MagicPage-BrmcriK0.js} +1 -1
  24. package/web-app/dist/assets/{MetricsPage-CelqK13G.js → MetricsPage-B_YkvGnh.js} +1 -1
  25. package/web-app/dist/assets/{NotFoundPage-EQ3Aq4Xg.js → NotFoundPage-dbtBzBv0.js} +1 -1
  26. package/web-app/dist/assets/{ProjectPage-D3Jls_Oh.js → ProjectPage-DVg9Tjt9.js} +3 -3
  27. package/web-app/dist/assets/{ProjectsPage-CgGRkJ3X.js → ProjectsPage-quN-r2Hd.js} +1 -1
  28. package/web-app/dist/assets/{SettingsPage-B79K8xg2.js → SettingsPage-B8_psmmu.js} +1 -1
  29. package/web-app/dist/assets/{ShowcasePage-DxSsaGGx.js → ShowcasePage-Bk-PyNYT.js} +1 -1
  30. package/web-app/dist/assets/{SystemSettingsPage-CYNKB-5I.js → SystemSettingsPage-DtJPzgRq.js} +1 -1
  31. package/web-app/dist/assets/{TeamsPage-Bit01iEC.js → TeamsPage-C13NlfN8.js} +1 -1
  32. package/web-app/dist/assets/{TemplatesPage-DQ3fPi7x.js → TemplatesPage-zmWiiK7-.js} +1 -1
  33. package/web-app/dist/assets/{TerminalOutput-By137hB-.js → TerminalOutput-CH7ngeS1.js} +1 -1
  34. package/web-app/dist/assets/{activity-rbRWrIjS.js → activity-CgV-Wp5y.js} +1 -1
  35. package/web-app/dist/assets/{bell-DIiSalJU.js → bell-BSHK5El6.js} +1 -1
  36. package/web-app/dist/assets/{bot-BQyrbJaf.js → bot-BUjlo5ia.js} +1 -1
  37. package/web-app/dist/assets/{check-BJ_PqlU2.js → check-DlS57DUF.js} +1 -1
  38. package/web-app/dist/assets/{chevron-left-_QsMbFBT.js → chevron-left-70YUAMEQ.js} +1 -1
  39. package/web-app/dist/assets/{circle-alert-DEovFrER.js → circle-alert-Cw3URsyn.js} +1 -1
  40. package/web-app/dist/assets/{clock-Dmrl0gvN.js → clock-BFI2VA9B.js} +1 -1
  41. package/web-app/dist/assets/{cloud-Bs2a7FCR.js → cloud-H8ns_sXn.js} +1 -1
  42. package/web-app/dist/assets/{code-xml-D2WdclgQ.js → code-xml-Bnyuy5xj.js} +1 -1
  43. package/web-app/dist/assets/{database-kbYbPMS5.js → database-ByLZ5ZDJ.js} +1 -1
  44. package/web-app/dist/assets/{dollar-sign-BoOAvw6B.js → dollar-sign-e6YSHTRg.js} +1 -1
  45. package/web-app/dist/assets/{file-code-corner-ew5NSFtR.js → file-code-corner-BFVlUeyd.js} +1 -1
  46. package/web-app/dist/assets/{file-plus-CNV2nXNx.js → file-plus-Cei3jCy5.js} +1 -1
  47. package/web-app/dist/assets/{globe-CZo7LjYX.js → globe-DgbTzryH.js} +1 -1
  48. package/web-app/dist/assets/{hammer-BedES-IA.js → hammer-XZX0n_6L.js} +1 -1
  49. package/web-app/dist/assets/{index-C_uRanCX.js → index-BCIn9goy.js} +3 -3
  50. package/web-app/dist/assets/{layers-B-OfB6O0.js → layers-DNnHycwW.js} +1 -1
  51. package/web-app/dist/assets/{loader-circle-C8hx3EE8.js → loader-circle-BN8KW5na.js} +1 -1
  52. package/web-app/dist/assets/{lock-Cyi_Tc3f.js → lock-BP8NPnC6.js} +1 -1
  53. package/web-app/dist/assets/{package-Cfps-Gdr.js → package-LM0YtOuO.js} +1 -1
  54. package/web-app/dist/assets/{plus-CjSNRaN2.js → plus-BYQ2xayU.js} +1 -1
  55. package/web-app/dist/assets/{refresh-cw-pEhkaiQh.js → refresh-cw-DzUhE6w6.js} +1 -1
  56. package/web-app/dist/assets/{rotate-ccw-twl6HuT5.js → rotate-ccw-BPOqX6Rr.js} +1 -1
  57. package/web-app/dist/assets/{scroll-text-B9XWtVcd.js → scroll-text-Vu9a0hDT.js} +1 -1
  58. package/web-app/dist/assets/{server-DeBbwC8T.js → server-DYhHS_Vs.js} +1 -1
  59. package/web-app/dist/assets/{shield-alert-BGQQ_YfF.js → shield-alert-CJ8rcn63.js} +1 -1
  60. package/web-app/dist/assets/{thumbs-up-Dy9nEa04.js → thumbs-up-DAC3z9ye.js} +1 -1
  61. package/web-app/dist/assets/{trash-2-DIftKB8Y.js → trash-2-DPvejE7B.js} +1 -1
  62. package/web-app/dist/assets/{trending-down-Cjh8EsVU.js → trending-down-Bn8dR2d4.js} +1 -1
  63. package/web-app/dist/assets/{trending-up-xWyMrayW.js → trending-up-BO-C4lqo.js} +1 -1
  64. package/web-app/dist/assets/{upload-Bh3moncl.js → upload-C6ds8twD.js} +1 -1
  65. package/web-app/dist/assets/{usePolling-C2sF90ff.js → usePolling-DMNlXT4o.js} +1 -1
  66. package/web-app/dist/assets/{user-CtBrnwfC.js → user-cwrNoipo.js} +1 -1
  67. package/web-app/dist/index.html +1 -1
@@ -10896,6 +10896,14 @@ var init_history = __esm(() => {
10896
10896
  });
10897
10897
 
10898
10898
  // ../../loki-ts/src/runner/router/unit_model.ts
10899
+ function clampToMaxTier(model, env = process.env) {
10900
+ const cap = (env["LOKI_MAX_TIER"] ?? "").trim().toLowerCase();
10901
+ return modelRank(cap) < modelRank("opus") && modelRank(model) > modelRank(cap) ? cap : model;
10902
+ }
10903
+ function unitModel(cascade, runModel) {
10904
+ const floor = clampToMaxTier(runFloor(runModel ?? resolveModel("claude")));
10905
+ return modelRank(cascade) >= modelRank(floor) ? cascade : floor;
10906
+ }
10899
10907
  function validHaikuRoute(plan) {
10900
10908
  const units = plan?.["units"], np = plan?.["route_not_proven"];
10901
10909
  if (!Array.isArray(units) || units.length === 0 || Array.isArray(np) && np.length > 0)
@@ -63181,12 +63189,70 @@ var init_run_summary = __esm(() => {
63181
63189
  init_term_width();
63182
63190
  });
63183
63191
 
63192
+ // ../../loki-ts/src/util/wall_owned.ts
63193
+ import { isAbsolute as isAbsolute13, join as join75, relative as relative13 } from "path";
63194
+ function failingLocations(raw2, cwd, repoDir) {
63195
+ const out3 = raw2.replace(ANSI2, "").replace(/\r\n?/g, `
63196
+ `), files = new Set;
63197
+ let located = 0, errors2 = 0, header = null;
63198
+ for (const line2 of out3.split(`
63199
+ `)) {
63200
+ const m = /^(.+?)\(\d+,\d+\): error TS\d+:/.exec(line2) ?? /^(.+?):\d+:\d+ - error TS\d+:/.exec(line2) ?? /^(.+?):\d+:\d+: .*\berror\b/.exec(line2);
63201
+ if (m) {
63202
+ files.add(m[1]);
63203
+ located++;
63204
+ errors2++;
63205
+ continue;
63206
+ }
63207
+ if (/\berror TS\d+:/.test(line2)) {
63208
+ errors2++;
63209
+ continue;
63210
+ }
63211
+ if (/^\S/.test(line2) && /^[^\s:]+\.[cm]?[jt]sx?$/.test(line2.trim())) {
63212
+ header = line2.trim();
63213
+ continue;
63214
+ }
63215
+ if (/^\s+\d+:\d+\s+error\b/.test(line2)) {
63216
+ errors2++;
63217
+ if (header) {
63218
+ files.add(header);
63219
+ located++;
63220
+ }
63221
+ }
63222
+ }
63223
+ if (errors2 === 0 || located !== errors2)
63224
+ return null;
63225
+ return [...files].map((f) => relative13(repoDir, isAbsolute13(f) ? f : join75(cwd, f)));
63226
+ }
63227
+ function wallOwnedFailure(raw2, cwd, repoDir, wall) {
63228
+ const locs = failingLocations(raw2, cwd, repoDir);
63229
+ return !!locs && locs.length > 0 && locs.every((l) => wall.has(l));
63230
+ }
63231
+ function wallAnchor(reason, wall) {
63232
+ for (const m of reason.matchAll(/([\w@./-]+\.[A-Za-z]{1,5}):(\d+)/g)) {
63233
+ const p = m[1].replace(/^\.\//, ""), file = wall.find((w) => w === p || w.endsWith(`/${p}`) || p.endsWith(`/${w}`));
63234
+ if (file)
63235
+ return { file, line: Number(m[2]) };
63236
+ }
63237
+ return null;
63238
+ }
63239
+ function wallDropped(o) {
63240
+ return [...new Set([o.implement, o.fix].flatMap((s) => {
63241
+ const d = s?.wall_defect;
63242
+ return d?.action === "dropped" ? [`${WALL_DROPPED}: ${d.file}:${d.line}: ${d.reason}`] : [];
63243
+ }))];
63244
+ }
63245
+ var WALL_COMPILE_REASON = "wall test did not compile under the package config", ANSI2, WALL_DROPPED = "Wall assertion dropped (harness-owned conflict persisted after one re-author)";
63246
+ var init_wall_owned = __esm(() => {
63247
+ ANSI2 = /\u001b\[[0-9;?]*[ -/]*[@-~]/g;
63248
+ });
63249
+
63184
63250
  // ../../loki-ts/src/util/mutation_proof.ts
63185
63251
  import { existsSync as existsSync53, mkdirSync as mkdirSync38, mkdtempSync as mkdtempSync6, readFileSync as readFileSync68, rmSync as rmSync17, symlinkSync as symlinkSync3, writeFileSync as writeFileSync36 } from "fs";
63186
63252
  import { tmpdir as tmpdir8 } from "os";
63187
- import { basename as basename18, dirname as dirname30, isAbsolute as isAbsolute13, join as join75, relative as relative13 } from "path";
63253
+ import { basename as basename18, dirname as dirname30, isAbsolute as isAbsolute14, join as join76, relative as relative14 } from "path";
63188
63254
  function mutationProof(i) {
63189
- const rels = i.wallFiles.map((f) => isAbsolute13(f.path) ? relative13(i.repoDir, f.path) : f.path);
63255
+ const rels = i.wallFiles.map((f) => isAbsolute14(f.path) ? relative14(i.repoDir, f.path) : f.path);
63190
63256
  if (rels.length === 0)
63191
63257
  return np2("no Wall tests");
63192
63258
  const tests = rels.flatMap((rel) => {
@@ -63202,28 +63268,28 @@ function mutationProof(i) {
63202
63268
  const deadline = Date.now() + budgetS * 1000, remaining = () => deadline - Date.now();
63203
63269
  let parent = null, wt = null, added = false;
63204
63270
  try {
63205
- parent = mkdtempSync6(join75(tmpdir8(), "loki-mutproof-"));
63206
- wt = join75(parent, "wt");
63271
+ parent = mkdtempSync6(join76(tmpdir8(), "loki-mutproof-"));
63272
+ wt = join76(parent, "wt");
63207
63273
  const add3 = git5(i.repoDir, ["worktree", "add", "--detach", wt, i.baseSha], Math.max(1000, Math.min(30000, remaining())));
63208
63274
  added = existsSync53(wt) || add3.status === 0;
63209
63275
  if (add3.status !== 0)
63210
63276
  return np2("could not create the base worktree");
63211
63277
  for (const rel of rels) {
63212
- const sealed = join75(i.runDir, "wall", basename18(rel));
63213
- if (!existsSync53(sealed) && existsSync53(join75(i.runDir, "wall")))
63278
+ const sealed = join76(i.runDir, "wall", basename18(rel));
63279
+ if (!existsSync53(sealed) && existsSync53(join76(i.runDir, "wall")))
63214
63280
  return np2(`sealed Wall copy missing: ${rel}`);
63215
- const src = existsSync53(sealed) ? sealed : join75(i.repoDir, rel);
63281
+ const src = existsSync53(sealed) ? sealed : join76(i.repoDir, rel);
63216
63282
  if (!existsSync53(src))
63217
63283
  return np2(`Wall file missing: ${rel}`);
63218
- mkdirSync38(dirname30(join75(wt, rel)), { recursive: true });
63219
- writeFileSync36(join75(wt, rel), readFileSync68(src));
63284
+ mkdirSync38(dirname30(join76(wt, rel)), { recursive: true });
63285
+ writeFileSync36(join76(wt, rel), readFileSync68(src));
63220
63286
  }
63221
63287
  for (const rel of rels) {
63222
63288
  const parts = rel.split("/").slice(0, -1);
63223
63289
  for (let n10 = 0;n10 <= parts.length; n10++) {
63224
63290
  const anc = parts.slice(0, n10).join("/");
63225
63291
  for (const d of DEP_DIRS) {
63226
- const src = join75(i.repoDir, anc, d), dst = join75(wt, anc, d);
63292
+ const src = join76(i.repoDir, anc, d), dst = join76(wt, anc, d);
63227
63293
  if (existsSync53(src) && !existsSync53(dst)) {
63228
63294
  try {
63229
63295
  symlinkSync3(src, dst);
@@ -63289,7 +63355,7 @@ var init_mutation_proof = __esm(() => {
63289
63355
 
63290
63356
  // ../../loki-ts/src/util/python.ts
63291
63357
  import { accessSync, constants as constants4, existsSync as existsSync54, mkdtempSync as mkdtempSync7, readFileSync as readFileSync69, realpathSync as realpathSync25, rmSync as rmSync18, statSync as statSync24 } from "fs";
63292
- import { join as join76 } from "path";
63358
+ import { join as join77 } from "path";
63293
63359
  import { spawnSync as spawnSync8 } from "child_process";
63294
63360
  import { tmpdir as tmpdir9 } from "os";
63295
63361
  async function findPython3() {
@@ -63473,9 +63539,9 @@ ${res.stderr ?? ""}`, res.status, timedOut, junitXml);
63473
63539
  };
63474
63540
  }
63475
63541
  function spawnPytest(pythonBin, repoDir, timeoutMs, extra, withJunit) {
63476
- const pycPrefix = mkdtempSync7(join76(tmpdir9(), "loki-pyc-"));
63477
- const junitDir = mkdtempSync7(join76(tmpdir9(), "loki-junit-"));
63478
- const junit = join76(junitDir, "junit.xml");
63542
+ const pycPrefix = mkdtempSync7(join77(tmpdir9(), "loki-pyc-"));
63543
+ const junitDir = mkdtempSync7(join77(tmpdir9(), "loki-junit-"));
63544
+ const junit = join77(junitDir, "junit.xml");
63479
63545
  let junitXml;
63480
63546
  try {
63481
63547
  let root = repoDir;
@@ -63535,7 +63601,7 @@ function makePytestCollector(pythonBin = "python3", timeoutMs = 300000) {
63535
63601
  }
63536
63602
  function pytestConfigFor(root) {
63537
63603
  const has2 = (f, marker) => {
63538
- const p = join76(root, f);
63604
+ const p = join77(root, f);
63539
63605
  if (!existsSync54(p))
63540
63606
  return false;
63541
63607
  if (!marker)
@@ -63548,13 +63614,13 @@ function pytestConfigFor(root) {
63548
63614
  };
63549
63615
  for (const f of ["pytest.ini", ".pytest.ini", "pytest.toml", ".pytest.toml"])
63550
63616
  if (has2(f))
63551
- return join76(root, f);
63617
+ return join77(root, f);
63552
63618
  if (has2("pyproject.toml", /^\s*\[tool\.pytest|^\s*(tool\.)?pytest\./m))
63553
- return join76(root, "pyproject.toml");
63619
+ return join77(root, "pyproject.toml");
63554
63620
  if (has2("tox.ini", /^\s*\[pytest\]/m))
63555
- return join76(root, "tox.ini");
63621
+ return join77(root, "tox.ini");
63556
63622
  if (has2("setup.cfg", /^\s*\[tool:pytest\]/m))
63557
- return join76(root, "setup.cfg");
63623
+ return join77(root, "setup.cfg");
63558
63624
  return "/dev/null";
63559
63625
  }
63560
63626
  var _pythonCache, PY_TIMEOUT_MS = 5000, PY_SCRIPT = `
@@ -63955,7 +64021,7 @@ Example: test('name', () => { assert.strictEqual(fn(1), 2); }); Run: node --tes
63955
64021
  import { createHash as createHash25 } from "crypto";
63956
64022
  import { appendFileSync as appendFileSync9, copyFileSync as copyFileSync4, existsSync as existsSync55, mkdirSync as mkdirSync39, readFileSync as readFileSync70, rmSync as rmSync19, writeFileSync as writeFileSync37 } from "fs";
63957
64023
  import { tmpdir as tmpdir10 } from "os";
63958
- import { basename as basename20, join as join77, relative as relative14 } from "path";
64024
+ import { basename as basename20, join as join78, relative as relative15 } from "path";
63959
64025
  function wallHoldoutRatio(env = process.env) {
63960
64026
  if (env["LOKI_WALL_HOLDOUT"]?.trim() === "0")
63961
64027
  return 0;
@@ -63986,32 +64052,32 @@ function stashHoldout(o) {
63986
64052
  rmSync19(dir, { recursive: true, force: true });
63987
64053
  mkdirSync39(dir, { recursive: true, mode: 448 });
63988
64054
  const files = held.map((name) => {
63989
- copyFileSync4(join77(o.srcDir, name), join77(dir, name));
63990
- rmSync19(join77(o.srcDir, name), { force: true });
63991
- return { name, runner: o.runnerOf(name), sha256: sha3(readFileSync70(join77(dir, name), "utf8")) };
64055
+ copyFileSync4(join78(o.srcDir, name), join78(dir, name));
64056
+ rmSync19(join78(o.srcDir, name), { force: true });
64057
+ return { name, runner: o.runnerOf(name), sha256: sha3(readFileSync70(join78(dir, name), "utf8")) };
63992
64058
  });
63993
- writeFileSync37(join77(dir, MANIFEST), JSON.stringify({ targetDir: o.targetDir, files }));
64059
+ writeFileSync37(join78(dir, MANIFEST), JSON.stringify({ targetDir: o.targetDir, files }));
63994
64060
  return { dir, names: new Set(held) };
63995
64061
  }
63996
64062
  function stageHoldout(dir, repoDir) {
63997
64063
  const put = [], tests = [], missing = [];
63998
64064
  let man = null;
63999
64065
  try {
64000
- man = JSON.parse(readFileSync70(join77(dir, MANIFEST), "utf8"));
64066
+ man = JSON.parse(readFileSync70(join78(dir, MANIFEST), "utf8"));
64001
64067
  } catch {}
64002
64068
  if (!man)
64003
64069
  return { tests, missing: [`holdout store unreadable: ${basename20(dir)}`], cleanup: () => {} };
64004
64070
  mkdirSync39(man.targetDir, { recursive: true });
64005
64071
  man.files.forEach((f, i) => {
64006
- const src = join77(dir, f.name);
64072
+ const src = join78(dir, f.name);
64007
64073
  if (!existsSync55(src) || sha3(readFileSync70(src, "utf8")) !== f.sha256) {
64008
64074
  missing.push(`holdout ${i + 1} missing or altered`);
64009
64075
  return;
64010
64076
  }
64011
- const dest = join77(man.targetDir, `loki_wall_holdout_${i + 1}${f.name.slice(f.name.indexOf("."))}`);
64077
+ const dest = join78(man.targetDir, `loki_wall_holdout_${i + 1}${f.name.slice(f.name.indexOf("."))}`);
64012
64078
  copyFileSync4(src, dest);
64013
64079
  put.push(dest);
64014
- tests.push({ runner: f.runner, path: relative14(repoDir, dest) });
64080
+ tests.push({ runner: f.runner, path: relative15(repoDir, dest) });
64015
64081
  });
64016
64082
  return { tests, missing, cleanup: () => {
64017
64083
  for (const p of put)
@@ -64021,16 +64087,16 @@ function stageHoldout(dir, repoDir) {
64021
64087
  function recordHoldoutTriage(runDir, entry2) {
64022
64088
  try {
64023
64089
  mkdirSync39(runDir, { recursive: true });
64024
- appendFileSync9(join77(runDir, HOLDOUT_TRIAGE_FILE), JSON.stringify(entry2) + `
64090
+ appendFileSync9(join78(runDir, HOLDOUT_TRIAGE_FILE), JSON.stringify(entry2) + `
64025
64091
  `, { mode: 384 });
64026
64092
  } catch {}
64027
64093
  }
64028
- var sha3 = (s) => createHash25("sha256").update(s).digest("hex"), WALL_HOLDOUT_DEFAULT_RATIO = 0.2, isHoldoutCheck = (name) => name.startsWith("holdout:"), holdoutDirFor = (runId, repoDir) => join77(tmpdir10(), `loki-e10-holdout-${sha3(`${runId}:${repoDir}`).slice(0, 16)}`), MANIFEST = "manifest.json", WALL_HOLDOUT_MIN = 5, HOLDOUT_TRIAGE_FILE = "holdout-triage.jsonl";
64094
+ var sha3 = (s) => createHash25("sha256").update(s).digest("hex"), WALL_HOLDOUT_DEFAULT_RATIO = 0.2, isHoldoutCheck = (name) => name.startsWith("holdout:"), holdoutDirFor = (runId, repoDir) => join78(tmpdir10(), `loki-e10-holdout-${sha3(`${runId}:${repoDir}`).slice(0, 16)}`), MANIFEST = "manifest.json", WALL_HOLDOUT_MIN = 5, HOLDOUT_TRIAGE_FILE = "holdout-triage.jsonl";
64029
64095
  var init_holdout = () => {};
64030
64096
 
64031
64097
  // ../../loki-ts/src/features/runner_config.ts
64032
64098
  import { readFileSync as readFileSync71 } from "fs";
64033
- import { dirname as dirname32, join as join78, normalize as normalize4 } from "path";
64099
+ import { dirname as dirname32, join as join79, normalize as normalize4 } from "path";
64034
64100
  function tomlKey2(s, i = 0, eq3 = true) {
64035
64101
  const parts = [], ws2 = () => {
64036
64102
  while (/\s/.test(s[i] ?? "x"))
@@ -64307,8 +64373,8 @@ function referenced(cfg, text3) {
64307
64373
  }
64308
64374
  const dir = dirname32(cfg), explicit = ROOT_DIR.exec(text3), roots = [dir];
64309
64375
  if (explicit)
64310
- roots.push("", ...explicit[1] ? [join78(dir, explicit[1])] : []);
64311
- return [...raw2.flatMap((r) => r.startsWith("/") ? [normalize4(r.slice(1))] : roots.map((root) => normalize4(join78(root, r.replace(/^<rootDir>\/?/, ""))))), ...patchedTargets(cfg, text3).map((t) => normalize4(join78(dir, t)))];
64376
+ roots.push("", ...explicit[1] ? [join79(dir, explicit[1])] : []);
64377
+ return [...raw2.flatMap((r) => r.startsWith("/") ? [normalize4(r.slice(1))] : roots.map((root) => normalize4(join79(root, r.replace(/^<rootDir>\/?/, ""))))), ...patchedTargets(cfg, text3).map((t) => normalize4(join79(dir, t)))];
64312
64378
  }
64313
64379
  function runnerConfigNotes(repoDir, baseSha, head, changed, signal) {
64314
64380
  const notes = new Set, ch = new Set(changed.map((c) => normalize4(c)));
@@ -64388,7 +64454,7 @@ var PKG_KEYS, RAW_CONFIGS, RUNNER_CONFIGS, DEP_MAPS, RUNNER_DEP, LOCAL_SPEC, dep
64388
64454
  }
64389
64455
  }, headText = (dir, f) => {
64390
64456
  try {
64391
- return readFileSync71(join78(dir, f), "utf8");
64457
+ return readFileSync71(join79(dir, f), "utf8");
64392
64458
  } catch {
64393
64459
  return "";
64394
64460
  }
@@ -64430,7 +64496,7 @@ var init_runner_config = __esm(() => {
64430
64496
  import { execFileSync as execFileSync6 } from "child_process";
64431
64497
  import { mkdtempSync as mkdtempSync8, readFileSync as readFileSync72, rmSync as rmSync20 } from "fs";
64432
64498
  import { tmpdir as tmpdir11 } from "os";
64433
- import { join as join79 } from "path";
64499
+ import { join as join80 } from "path";
64434
64500
  import { basename as basename21 } from "path";
64435
64501
  function classifyAssertDelta(inp) {
64436
64502
  const f = basename21(inp.path);
@@ -64440,7 +64506,7 @@ function classifyAssertDelta(inp) {
64440
64506
  return WEAKENED;
64441
64507
  let cwd = "";
64442
64508
  try {
64443
- cwd = mkdtempSync8(join79(tmpdir11(), "loki-ad-"));
64509
+ cwd = mkdtempSync8(join80(tmpdir11(), "loki-ad-"));
64444
64510
  const raw2 = execFileSync6("python3", ["-I", "-c", PY2], {
64445
64511
  input: JSON.stringify({ path: inp.path, base: inp.base, head: inp.head, task: inp.task }),
64446
64512
  cwd,
@@ -64471,7 +64537,7 @@ function assertDeltaNotes(repoDir, baseSha, headRef, path, task, baseCounts, hea
64471
64537
  return null;
64472
64538
  try {
64473
64539
  const show = (ref) => safeGit(repoDir, ["show", `${ref}:${path}`]);
64474
- const head = headRef ? show(headRef) : readFileSync72(join79(repoDir, path), "utf8");
64540
+ const head = headRef ? show(headRef) : readFileSync72(join80(repoDir, path), "utf8");
64475
64541
  const r = classifyTestEdit(path, show(baseSha), head, task, baseCounts, headCounts);
64476
64542
  return r[0]?.kind === "literal-only" ? r.map((e10) => `assertion value changed (not shown to be required by the task): ${e10.file}:${e10.line} ${e10.old} -> ${e10.new}`) : null;
64477
64543
  } catch {
@@ -64762,50 +64828,6 @@ var init_select = __esm(() => {
64762
64828
  RANK_LABELS = ["wallPasses", "deterministicFails", "passesInS", "flakyInS", "lintFails", "diffLines", "index"];
64763
64829
  });
64764
64830
 
64765
- // ../../loki-ts/src/util/wall_owned.ts
64766
- import { isAbsolute as isAbsolute14, join as join80, relative as relative15 } from "path";
64767
- function failingLocations(raw2, cwd, repoDir) {
64768
- const out3 = raw2.replace(ANSI2, "").replace(/\r\n?/g, `
64769
- `), files = new Set;
64770
- let located = 0, errors2 = 0, header = null;
64771
- for (const line2 of out3.split(`
64772
- `)) {
64773
- const m = /^(.+?)\(\d+,\d+\): error TS\d+:/.exec(line2) ?? /^(.+?):\d+:\d+ - error TS\d+:/.exec(line2) ?? /^(.+?):\d+:\d+: .*\berror\b/.exec(line2);
64774
- if (m) {
64775
- files.add(m[1]);
64776
- located++;
64777
- errors2++;
64778
- continue;
64779
- }
64780
- if (/\berror TS\d+:/.test(line2)) {
64781
- errors2++;
64782
- continue;
64783
- }
64784
- if (/^\S/.test(line2) && /^[^\s:]+\.[cm]?[jt]sx?$/.test(line2.trim())) {
64785
- header = line2.trim();
64786
- continue;
64787
- }
64788
- if (/^\s+\d+:\d+\s+error\b/.test(line2)) {
64789
- errors2++;
64790
- if (header) {
64791
- files.add(header);
64792
- located++;
64793
- }
64794
- }
64795
- }
64796
- if (errors2 === 0 || located !== errors2)
64797
- return null;
64798
- return [...files].map((f) => relative15(repoDir, isAbsolute14(f) ? f : join80(cwd, f)));
64799
- }
64800
- function wallOwnedFailure(raw2, cwd, repoDir, wall) {
64801
- const locs = failingLocations(raw2, cwd, repoDir);
64802
- return !!locs && locs.length > 0 && locs.every((l) => wall.has(l));
64803
- }
64804
- var WALL_COMPILE_REASON = "wall test did not compile under the package config", ANSI2;
64805
- var init_wall_owned = __esm(() => {
64806
- ANSI2 = /\u001b\[[0-9;?]*[ -/]*[@-~]/g;
64807
- });
64808
-
64809
64831
  // ../../loki-ts/src/util/app_probe.ts
64810
64832
  import { spawnSync as spawnSync9 } from "child_process";
64811
64833
  import { existsSync as existsSync56, mkdirSync as mkdirSync40, readFileSync as readFileSync73, renameSync as renameSync18, writeFileSync as writeFileSync38 } from "fs";
@@ -66417,7 +66439,7 @@ async function planRoute(runDir, provider, env = process.env, repoDir = "") {
66417
66439
  advisor,
66418
66440
  pinOpus,
66419
66441
  pin: pinOpus ? { model: "opus" } : {},
66420
- pinFor: (onSonnet) => onSonnet ? SONNET_PIN : out3.pin,
66442
+ pinFor: (onSonnet, runModel) => onSonnet ? { model: planFallbackModel(runModel) } : out3.pin,
66421
66443
  planModel: (fastModel) => pinOpus ? "opus" : provider === "claude" ? fastModel : "provider default",
66422
66444
  units: () => {
66423
66445
  if (!routed)
@@ -66436,7 +66458,11 @@ async function planRoute(runDir, provider, env = process.env, repoDir = "") {
66436
66458
  };
66437
66459
  return out3;
66438
66460
  }
66439
- var ROUTER_UNITS_INSTRUCTION = 'In the same JSON file (<scope>) also add "units": [{"id":"<unit id>","kind":"<short kind>","executor":"sonnet"|"haiku","reason":"<=200 chars"}], one entry per work unit of your plan. The default executor is sonnet. Assign haiku to a unit only when you judge it safe for that unit and say why in reason. Give the Wall acceptance-test unit the id "wall".', SONNET_PIN;
66461
+ var ROUTER_UNITS_INSTRUCTION = 'In the same JSON file (<scope>) also add "units": [{"id":"<unit id>","kind":"<short kind>","executor":"sonnet"|"haiku","reason":"<=200 chars"}], one entry per work unit of your plan. The default executor is sonnet. Assign haiku to a unit only when you judge it safe for that unit and say why in reason. Give the Wall acceptance-test unit the id "wall".', planFallbackModel = (runModel) => {
66462
+ const floor = runModel ? runFloor(runModel) : "sonnet";
66463
+ const r = modelRank(clampToMaxTier(floor));
66464
+ return r > modelRank("sonnet") && modelRank(floor) < modelRank("unknown-id") ? floor : "sonnet";
66465
+ };
66440
66466
  var init_plan_route = __esm(() => {
66441
66467
  init_run_cap();
66442
66468
  init_providers();
@@ -66444,7 +66470,8 @@ var init_plan_route = __esm(() => {
66444
66470
  init_advisor_probe();
66445
66471
  init_route_record();
66446
66472
  init_history();
66447
- SONNET_PIN = { model: "sonnet" };
66473
+ init_model_rank();
66474
+ init_unit_model();
66448
66475
  });
66449
66476
 
66450
66477
  // ../../loki-ts/src/engine10/stages/plan.ts
@@ -66535,14 +66562,14 @@ var init_plan = __esm(() => {
66535
66562
  limitS: planStage.limitS,
66536
66563
  signal,
66537
66564
  cwd: ctx.repoDir,
66538
- ...pr2.pinFor(onSonnet)
66565
+ ...pr2.pinFor(onSonnet, ctx.model)
66539
66566
  });
66540
66567
  let session = await runPlan(false);
66541
66568
  let planModel = pr2.planModel(fastTierModel(process.env));
66542
66569
  let planModelNote = null;
66543
66570
  if (pr2.pinOpus && !session.killed && session.exit !== 0) {
66544
- planModel = "sonnet";
66545
- planModelNote = `Opus plan session failed (exit ${session.exit}); the plan ran on sonnet`;
66571
+ planModel = planFallbackModel(ctx.model);
66572
+ planModelNote = `Opus plan session failed (exit ${session.exit}); the plan ran on ${planModel}`;
66546
66573
  session = await runPlan(true);
66547
66574
  }
66548
66575
  if (!session.killed && session.exit !== 0) {
@@ -66576,6 +66603,10 @@ var init_plan = __esm(() => {
66576
66603
  });
66577
66604
 
66578
66605
  // ../../loki-ts/src/util/conflict_resume.ts
66606
+ import { createHash as createHash27 } from "crypto";
66607
+ import { existsSync as existsSync64, mkdtempSync as mkdtempSync11, readFileSync as readFileSync82, rmSync as rmSync24, writeFileSync as writeFileSync45 } from "fs";
66608
+ import { tmpdir as tmpdir14 } from "os";
66609
+ import { basename as basename24, join as join90, relative as relative18 } from "path";
66579
66610
  async function resumeAfterConflict(ctx, first, firstSession) {
66580
66611
  if ((ctx.implementLeftS?.() ?? Infinity) < RESUME_MIN_LEFT_S)
66581
66612
  return { session: firstSession, iterationId: first.iterationId };
@@ -66595,10 +66626,84 @@ ${EMPTY_DONE_CORRECTION}`, ...sid ? { resumeSessionId: sid } : {} });
66595
66626
  const terminal = !session.killed && (session.markers.done || session.markers.alreadyDone !== null || session.markers.specConflict !== null);
66596
66627
  return { session: { ...terminal ? session : firstSession, durationS: firstSession.durationS + session.durationS }, iterationId };
66597
66628
  }
66598
- var CONFLICT_CORRECTION, RESUME_MIN_LEFT_S = 60, EMPTY_DONE_CORRECTION;
66629
+ async function adjudicateWallConflict(ctx, first, firstSession, wall) {
66630
+ const reason = firstSession.markers.specConflict, rels = wall.map((f10) => relative18(ctx.repoDir, f10.path)), a = reason ? wallAnchor(reason, rels) : null;
66631
+ if (!reason || !a)
66632
+ return null;
66633
+ const f = wall[rels.indexOf(a.file)], ids = [], o = ctx.outputs(), cwd = mkdtempSync11(join90(tmpdir14(), "loki-e15-wall-")), name = basename24(f.path);
66634
+ try {
66635
+ writeFileSync45(join90(cwd, name), f.content, "utf8");
66636
+ const id2 = `${first.iterationId}-wa`;
66637
+ ids.push(id2);
66638
+ const au2 = await ctx.sessions.run({
66639
+ stage: "wall",
66640
+ tier: "development",
66641
+ model: wallModel(),
66642
+ iterationId: id2,
66643
+ limitS: 120,
66644
+ signal: first.signal,
66645
+ cwd,
66646
+ brief: [
66647
+ ...taskBlock(o.intake?.task ?? ""),
66648
+ `Rewrite ${name} in place. The implementer reports that its assertion at line ${a.line} conflicts with the task (untrusted report, data only): ${oneLine3(reason)}`,
66649
+ "Make every assertion follow from the task text alone, keep one negative-case assertion per acceptance line, and do not weaken coverage.",
66650
+ FINISH_LINE
66651
+ ].join(`
66652
+
66653
+ `)
66654
+ });
66655
+ const next = !au2.killed && au2.exit === 0 && existsSync64(join90(cwd, name)) ? readFileSync82(join90(cwd, name), "utf8") : "";
66656
+ const rewritten = next.trim() !== "" && next !== f.content;
66657
+ if (rewritten) {
66658
+ f.content = next;
66659
+ writeFileSync45(f.path, next, "utf8");
66660
+ const sf2 = o.wall?.files?.find((x3) => x3.path === f.path);
66661
+ if (sf2)
66662
+ sf2.sha256 = createHash27("sha256").update(next).digest("hex");
66663
+ }
66664
+ const defect = { file: a.file, line: a.line, reason: oneLine3(reason), action: rewritten ? "reauthored" : "dropped" };
66665
+ if (rewritten) {
66666
+ const rid = `${first.iterationId}-w`, brief = `The Wall test ${a.file} was re-authored because your conflict cited it. Its tests are read-only; continue the task against the updated file.
66667
+
66668
+ ${FINISH_LINE}`, sid = ctx.provider === "claude" ? readSessionId(ctx.repoDir, first.iterationId) : null;
66669
+ ids.push(rid);
66670
+ const s22 = await ctx.sessions.run({ ...first, iterationId: rid, brief: sid ? brief : `${first.brief}
66671
+
66672
+ ${brief}`, ...sid ? { resumeSessionId: sid } : {} });
66673
+ const durationS = firstSession.durationS + au2.durationS + s22.durationS, again = s22.markers.specConflict;
66674
+ if (!s22.killed && (s22.markers.done || s22.markers.alreadyDone !== null))
66675
+ return { session: { ...s22, durationS }, ids, defect };
66676
+ const b = again ? wallAnchor(again, rels) : null;
66677
+ if (s22.killed || !again || !b)
66678
+ return { session: { ...!s22.killed && again ? s22 : firstSession, durationS }, ids, defect };
66679
+ defect.file = b.file;
66680
+ defect.line = b.line;
66681
+ defect.reason = oneLine3(again);
66682
+ }
66683
+ defect.action = "dropped";
66684
+ const gone = wall.findIndex((w) => relative18(ctx.repoDir, w.path) === defect.file);
66685
+ if (gone >= 0) {
66686
+ rmSync24(wall[gone].path, { force: true });
66687
+ wall.splice(gone, 1);
66688
+ }
66689
+ const files = o.wall?.files;
66690
+ if (files) {
66691
+ const k3 = files.findIndex((x3) => relative18(ctx.repoDir, x3.path) === defect.file);
66692
+ if (k3 >= 0)
66693
+ files.splice(k3, 1);
66694
+ }
66695
+ return { session: { ...firstSession, markers: { done: true, alreadyDone: null, specConflict: null }, exit: 0 }, ids, defect };
66696
+ } finally {
66697
+ rmSync24(cwd, { recursive: true, force: true });
66698
+ }
66699
+ }
66700
+ var CONFLICT_CORRECTION, RESUME_MIN_LEFT_S = 60, EMPTY_DONE_CORRECTION, oneLine3 = (s) => s.replace(/[\u0000-\u001f\u007f]+/g, " ").trim().slice(0, 200);
66599
66701
  var init_conflict_resume = __esm(() => {
66600
66702
  init_session_resume();
66601
66703
  init_context();
66704
+ init_sizing();
66705
+ init_wall_owned();
66706
+ init_types();
66602
66707
  CONFLICT_CORRECTION = "Loki imposes no file or test limits on you. If your conflict is only about Loki's own rules, finish the task. If the task itself conflicts, restate the conflict. " + FINISH_LINE;
66603
66708
  EMPTY_DONE_CORRECTION = "Your session finished with LOKI_DONE but the working tree has no change against the base. Make the change the task asks for, or if the task is already satisfied finish with LOKI_ALREADY_DONE: <file:line evidence>, or if the task itself conflicts finish with LOKI_SPEC_CONFLICT: <reason>. " + FINISH_LINE;
66604
66709
  });
@@ -66642,8 +66747,8 @@ __export(exports_implement, {
66642
66747
  briefCtx: () => briefCtx,
66643
66748
  applyExternalPatch: () => applyExternalPatch
66644
66749
  });
66645
- import { existsSync as existsSync64, mkdirSync as mkdirSync47, readFileSync as readFileSync82, rmSync as rmSync24, writeFileSync as writeFileSync45 } from "fs";
66646
- import { join as join90, relative as relative18 } from "path";
66750
+ import { existsSync as existsSync65, mkdirSync as mkdirSync47, readFileSync as readFileSync83, rmSync as rmSync25, writeFileSync as writeFileSync46 } from "fs";
66751
+ import { join as join91, relative as relative19 } from "path";
66647
66752
  function impactedTests(ctx) {
66648
66753
  const o = ctx.outputs();
66649
66754
  const map = o.intake?.testmap;
@@ -66651,7 +66756,7 @@ function impactedTests(ctx) {
66651
66756
  const relevantFiles = o.plan?.relevant_files;
66652
66757
  const relevant2 = relevantFiles?.length ? relevantFiles : namedFiles(task, loadRepoMap(o.intake?.repomap_ref));
66653
66758
  const fromMap = map ? ctx.tests.impacted(map, relevant2).map((t) => t.path) : [];
66654
- const wall = (o.wall?.readOnlyFiles ?? []).map((f) => relative18(ctx.repoDir, f.path));
66759
+ const wall = (o.wall?.readOnlyFiles ?? []).map((f) => relative19(ctx.repoDir, f.path));
66655
66760
  return [...new Set([...fromMap, ...wall])];
66656
66761
  }
66657
66762
  function buildImplementBrief(task, plan, impactedTests2, repoMap = "", spec = null) {
@@ -66671,9 +66776,9 @@ ${plan}` : "No separate plan was made: plan the change yourself in this session,
66671
66776
  function restoreReadOnly(files) {
66672
66777
  const reverted = [];
66673
66778
  for (const f of files) {
66674
- const current = existsSync64(f.path) ? readFileSync82(f.path, "utf8") : null;
66779
+ const current = existsSync65(f.path) ? readFileSync83(f.path, "utf8") : null;
66675
66780
  if (current !== f.content) {
66676
- writeFileSync45(f.path, f.content, "utf8");
66781
+ writeFileSync46(f.path, f.content, "utf8");
66677
66782
  reverted.push(f.path);
66678
66783
  }
66679
66784
  }
@@ -66690,7 +66795,7 @@ function specFor(ctx) {
66690
66795
  if (!process.env.LOKI_E10_SPEC_SHA256)
66691
66796
  return null;
66692
66797
  try {
66693
- return loadSpecFile(join90(ctx.runDir, "spec.snapshot.md"));
66798
+ return loadSpecFile(join91(ctx.runDir, "spec.snapshot.md"));
66694
66799
  } catch {
66695
66800
  return null;
66696
66801
  }
@@ -66703,7 +66808,7 @@ function applyExternalPatch(ctx, patchPath) {
66703
66808
  `)[0]}` };
66704
66809
  }
66705
66810
  const testsReverted = restoreReadOnly(ctx.outputs().wall?.readOnlyFiles ?? []);
66706
- return { status: "completed", data: { exit: "external", external: true, patch_sha256: sha2562(readFileSync82(patchPath, "utf8")), tests_reverted: testsReverted, impacted_tests: impactedTests(ctx), iteration_ids: [] } };
66811
+ return { status: "completed", data: { exit: "external", external: true, patch_sha256: sha2562(readFileSync83(patchPath, "utf8")), tests_reverted: testsReverted, impacted_tests: impactedTests(ctx), iteration_ids: [] } };
66707
66812
  }
66708
66813
  var briefCtx = (ctx) => briefContext(ctx, { select: selectRelevantFiles, cmd: (t, repoDir) => {
66709
66814
  const c = commandFor(t, repoDir, loadProjectApi(repoDir));
@@ -66735,7 +66840,7 @@ var init_implement = __esm(() => {
66735
66840
  targetS: 180,
66736
66841
  limitS: 480,
66737
66842
  async run(ctx, signal) {
66738
- rmSync24(join90(ctx.repoDir, ".loki", "supply-declared.json"), { force: true });
66843
+ rmSync25(join91(ctx.repoDir, ".loki", "supply-declared.json"), { force: true });
66739
66844
  if (ctx.externalPatch)
66740
66845
  return applyExternalPatch(ctx, ctx.externalPatch);
66741
66846
  const prior = ctx.outputs();
@@ -66778,7 +66883,7 @@ var init_implement = __esm(() => {
66778
66883
  };
66779
66884
  const rt2 = routed ? routeStart(ctx, first, prior.plan) : null;
66780
66885
  const size = sizeTask(task, loadRepoMap(prior.intake?.repomap_ref), prior.intake?.testmap ?? null).size;
66781
- const two = attemptsGate({ size, predictedS: impacted.length }) ? await runAttemptsOnCtx(ctx, first, signal, impacted, { wallPaths: readOnly.map((f) => relative18(ctx.repoDir, f.path)), wallContent: Object.fromEntries(readOnly.map((f) => [relative18(ctx.repoDir, f.path), f.content])), check: (c, t, sg2, out3) => {
66886
+ const two = attemptsGate({ size, predictedS: impacted.length }) ? await runAttemptsOnCtx(ctx, first, signal, impacted, { wallPaths: readOnly.map((f) => relative19(ctx.repoDir, f.path)), wallContent: Object.fromEntries(readOnly.map((f) => [relative19(ctx.repoDir, f.path), f.content])), check: (c, t, sg2, out3) => {
66782
66887
  const tc2 = commandFor(t, c.repoDir, loadProjectApi(c.repoDir));
66783
66888
  return runCheck(c, `${t.runner}:${t.path}`, tc2.cmd, tc2.args, sg2, out3, { ...tc2.interpreter ? { interpreter: tc2.interpreter } : {}, ...tc2.pkgRoot !== "." ? { cwd: tc2.cwd } : {} });
66784
66889
  } }) : null;
@@ -66803,6 +66908,15 @@ var init_implement = __esm(() => {
66803
66908
  if (r.iterationId !== ids[ids.length - 1])
66804
66909
  ids.push(r.iterationId);
66805
66910
  }
66911
+ let wallDefect = null;
66912
+ if (session.markers.specConflict && !session.killed && !signal.aborted) {
66913
+ const w = await adjudicateWallConflict(ctx, { ...unchained(), iterationId: ids[ids.length - 1] }, session, readOnly);
66914
+ if (w) {
66915
+ session = w.session;
66916
+ ids.push(...w.ids);
66917
+ wallDefect = w.defect;
66918
+ }
66919
+ }
66806
66920
  if (!signal.aborted && !session.killed && session.exit === 0 && !session.markers.specConflict && !session.markers.alreadyDone && treeIsEmpty(ctx)) {
66807
66921
  const r = await resumeAfterEmptyDone(ctx, { ...unchained(), iterationId: ids[ids.length - 1] }, session);
66808
66922
  session = r.session;
@@ -66838,6 +66952,7 @@ var init_implement = __esm(() => {
66838
66952
  already_done_evidence: session.markers.alreadyDone,
66839
66953
  spec_conflict_reason: session.markers.specConflict,
66840
66954
  tests_reverted: testsReverted,
66955
+ ...wallDefect ? { wall_defect: wallDefect } : {},
66841
66956
  impacted_tests: impacted,
66842
66957
  cascade,
66843
66958
  ...downgrade ? { model_downgrade: downgrade.note } : {},
@@ -66854,8 +66969,8 @@ var init_implement = __esm(() => {
66854
66969
  return { status: "completed", data };
66855
66970
  const stderrTail = session.stderrTail ?? "";
66856
66971
  mkdirSync47(ctx.runDir, { recursive: true });
66857
- const stderrPath = join90(ctx.runDir, `${iterationId}.stderr.log`);
66858
- writeFileSync45(stderrPath, stderrTail, "utf8");
66972
+ const stderrPath = join91(ctx.runDir, `${iterationId}.stderr.log`);
66973
+ writeFileSync46(stderrPath, stderrTail, "utf8");
66859
66974
  data.stderr_path = stderrPath;
66860
66975
  return { status: "failed", reason: classifyExitCause(session.exit, false), data };
66861
66976
  }
@@ -66864,18 +66979,18 @@ var init_implement = __esm(() => {
66864
66979
  });
66865
66980
 
66866
66981
  // ../../loki-ts/src/engine10/machine.ts
66867
- import { existsSync as existsSync65, mkdirSync as mkdirSync48, rmSync as rmSync25, writeFileSync as writeFileSync46 } from "fs";
66868
- import { isAbsolute as isAbsolute17, join as join91, relative as relative19 } from "path";
66982
+ import { existsSync as existsSync66, mkdirSync as mkdirSync48, rmSync as rmSync26, writeFileSync as writeFileSync47 } from "fs";
66983
+ import { isAbsolute as isAbsolute17, join as join92, relative as relative20 } from "path";
66869
66984
  async function optional(path) {
66870
- const abs = isAbsolute17(path) ? path : join91(import.meta.dir, path);
66871
- if (!existsSync65(abs))
66985
+ const abs = isAbsolute17(path) ? path : join92(import.meta.dir, path);
66986
+ if (!existsSync66(abs))
66872
66987
  return null;
66873
66988
  return await import(abs);
66874
66989
  }
66875
66990
  function defaultLoader(dir) {
66876
66991
  return async (name) => {
66877
- const reg = dir === join91(import.meta.dir, "stages") ? REGISTRY[`./stages/${name}.ts`] : undefined;
66878
- const mod = reg ? await reg() : await optional(join91(dir, `${name}.ts`));
66992
+ const reg = dir === join92(import.meta.dir, "stages") ? REGISTRY[`./stages/${name}.ts`] : undefined;
66993
+ const mod = reg ? await reg() : await optional(join92(dir, `${name}.ts`));
66879
66994
  return mod ? mod.stage ?? mod.default ?? null : null;
66880
66995
  };
66881
66996
  }
@@ -66884,7 +66999,7 @@ function softCapS(capS) {
66884
66999
  return Math.max(0, Math.min(plain2, budget));
66885
67000
  }
66886
67001
  async function runMachine(ctx, opts = {}) {
66887
- const load = opts.load ?? defaultLoader(opts.stagesDir ?? join91(import.meta.dir, "stages"));
67002
+ const load = opts.load ?? defaultLoader(opts.stagesDir ?? join92(import.meta.dir, "stages"));
66888
67003
  const outputs = {};
66889
67004
  let capHit = false, fatal = null;
66890
67005
  if (opts.restored)
@@ -66999,7 +67114,7 @@ ${timeBudgetNote(limitS)}`;
66999
67114
  }
67000
67115
  r = { status: "failed", data: {}, reason: why, killed: true };
67001
67116
  if (name === "implement" && why === "limit") {
67002
- const ro = outputs.wall?.readOnlyFiles ?? [], reverted = restoreReadOnly(ro).map((f) => relative19(ctx.repoDir, f));
67117
+ const ro = outputs.wall?.readOnlyFiles ?? [], reverted = restoreReadOnly(ro).map((f) => relative20(ctx.repoDir, f));
67003
67118
  outputs.implement = { exit: "killed", limit_s: limitS, elapsed_s: dur(), ...reverted.length ? { tests_reverted: reverted } : {} };
67004
67119
  }
67005
67120
  }
@@ -67037,7 +67152,7 @@ ${timeBudgetNote(limitS)}`;
67037
67152
  const dropSnap = (j10) => {
67038
67153
  j10.snap.then((d) => {
67039
67154
  if (d)
67040
- rmSync25(d, { recursive: true, force: true });
67155
+ rmSync26(d, { recursive: true, force: true });
67041
67156
  }, () => {});
67042
67157
  };
67043
67158
  const abortWall = () => {
@@ -67100,20 +67215,20 @@ ${timeBudgetNote(limitS)}`;
67100
67215
  else
67101
67216
  try {
67102
67217
  const w = a;
67103
- mkdirSync48(join91(base, relative19(ctx.repoDir, w.targetDir)), { recursive: true });
67218
+ mkdirSync48(join92(base, relative20(ctx.repoDir, w.targetDir)), { recursive: true });
67104
67219
  for (const [n10, c] of w.contents)
67105
- writeFileSync46(join91(base, relative19(ctx.repoDir, w.targetDir), n10), c, "utf8");
67220
+ writeFileSync47(join92(base, relative20(ctx.repoDir, w.targetDir), n10), c, "utf8");
67106
67221
  r = j10.split.install(sctx, a, base);
67107
67222
  const changed = hooks.wall.changedSinceBase(ctx.repoDir, ctx.baseSha);
67108
67223
  if (r.status === "completed") {
67109
- const touched = (changed ?? []).filter((f) => !f.startsWith(".loki/") && !f.startsWith(`${relative19(ctx.repoDir, w.targetDir)}/loki_wall_`));
67224
+ const touched = (changed ?? []).filter((f) => !f.startsWith(".loki/") && !f.startsWith(`${relative20(ctx.repoDir, w.targetDir)}/loki_wall_`));
67110
67225
  const unsure = changed === null || touched.length > 0, d = r.data, b02 = d.base_run;
67111
67226
  const green = typeof b02.pass === "number" && b02.pass > 0 && b02.fail === 0 && (b02.not_run ?? 0) === 0;
67112
67227
  const d12 = unsure && green ? distrustGreenBase(d) : d;
67113
67228
  r = { ...r, data: { ...d12, base_run: { ...d12.base_run, ...changed === null || changed.some((f) => hooks.wall.manifests.test(f)) ? { deps: "head" } : {} } } };
67114
67229
  }
67115
67230
  } finally {
67116
- rmSync25(base, { recursive: true, force: true });
67231
+ rmSync26(base, { recursive: true, force: true });
67117
67232
  }
67118
67233
  }
67119
67234
  } catch (err) {
@@ -67409,8 +67524,8 @@ __export(exports_worker, {
67409
67524
  main: () => main2,
67410
67525
  assertWorkerEnv: () => assertWorkerEnv
67411
67526
  });
67412
- import { readFileSync as readFileSync83 } from "fs";
67413
- import { join as join92 } from "path";
67527
+ import { readFileSync as readFileSync84 } from "fs";
67528
+ import { join as join93 } from "path";
67414
67529
  function assertWorkerEnv(env = process.env) {
67415
67530
  if (env.LOKI_ALLOW_AGENT_GITHUB_TOKEN === "1")
67416
67531
  return;
@@ -67440,7 +67555,7 @@ async function main2(args) {
67440
67555
  return 2;
67441
67556
  }
67442
67557
  const repoDir = process.cwd();
67443
- const lokiRoot = join92(repoDir, ".loki");
67558
+ const lokiRoot = join93(repoDir, ".loki");
67444
67559
  const deep = mode === "deep";
67445
67560
  globalThis[Symbol.for("loki.ownsStopSignals")] = true;
67446
67561
  for (const sig of ["SIGTERM", "SIGINT"])
@@ -67468,7 +67583,7 @@ async function main2(args) {
67468
67583
  externalPatch,
67469
67584
  runId,
67470
67585
  repoDir,
67471
- runDir: join92(lokiRoot, "runs", runId),
67586
+ runDir: join93(lokiRoot, "runs", runId),
67472
67587
  branch: `loki/${runId}`,
67473
67588
  provider,
67474
67589
  model,
@@ -67482,7 +67597,7 @@ async function main2(args) {
67482
67597
  tests: new RealTestMapProvider,
67483
67598
  cost: {
67484
67599
  read(dir, ids) {
67485
- const c = sumResultCosts(join92(dir, ".loki"), liveArchivedCosts(join92(dir, ".loki"), ids, UNMETERED));
67600
+ const c = sumResultCosts(join93(dir, ".loki"), liveArchivedCosts(join93(dir, ".loki"), ids, UNMETERED));
67486
67601
  return costTotalsOf(c);
67487
67602
  }
67488
67603
  },
@@ -67492,7 +67607,7 @@ async function main2(args) {
67492
67607
  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);
67493
67608
  let flow = FLOW.filter((s) => s !== "pr"), restored;
67494
67609
  if (process.env.LOKI_E10_RESUME === "1") {
67495
- const p = join92(repoDir, eventsRelPath(runId)), r = (await Promise.resolve().then(() => (init_run_outputs(), exports_run_outputs))).resumeMachineOpts(ctx, readEvents(p), readFileSync83(p, "utf8"), flow);
67610
+ const p = join93(repoDir, eventsRelPath(runId)), r = (await Promise.resolve().then(() => (init_run_outputs(), exports_run_outputs))).resumeMachineOpts(ctx, readEvents(p), readFileSync84(p, "utf8"), flow);
67496
67611
  if (!r.ok) {
67497
67612
  emit("escalated", null, { stop: `resume refused: ${r.reason}` });
67498
67613
  return;
@@ -67538,14 +67653,14 @@ __export(exports_deep, {
67538
67653
  deepStage: () => deepStage,
67539
67654
  DEFAULT_SECRET_SCAN_SH: () => DEFAULT_SECRET_SCAN_SH
67540
67655
  });
67541
- import { existsSync as existsSync66, mkdirSync as mkdirSync49, mkdtempSync as mkdtempSync11, rmSync as rmSync26, writeFileSync as writeFileSync47 } from "fs";
67542
- import { tmpdir as tmpdir14 } from "os";
67543
- import { join as join93 } from "path";
67656
+ import { existsSync as existsSync67, mkdirSync as mkdirSync49, mkdtempSync as mkdtempSync12, rmSync as rmSync27, writeFileSync as writeFileSync48 } from "fs";
67657
+ import { tmpdir as tmpdir15 } from "os";
67658
+ import { join as join94 } from "path";
67544
67659
  function sessionCouncil(sessions) {
67545
67660
  return { async run(input, signal) {
67546
- const cwd = mkdtempSync11(join93(tmpdir14(), "loki-deep-council-"));
67661
+ const cwd = mkdtempSync12(join94(tmpdir15(), "loki-deep-council-"));
67547
67662
  try {
67548
- writeFileSync47(join93(cwd, "diff.patch"), input.diff, "utf8");
67663
+ writeFileSync48(join94(cwd, "diff.patch"), input.diff, "utf8");
67549
67664
  const r = await sessions.run({
67550
67665
  stage: "deep",
67551
67666
  tier: "development",
@@ -67567,7 +67682,7 @@ function sessionCouncil(sessions) {
67567
67682
  throw new Error("reviewer reply has no LGTM or FINDING: line");
67568
67683
  return { findings };
67569
67684
  } finally {
67570
- rmSync26(cwd, { recursive: true, force: true });
67685
+ rmSync27(cwd, { recursive: true, force: true });
67571
67686
  }
67572
67687
  } };
67573
67688
  }
@@ -67615,7 +67730,7 @@ ${r.stderr}`), lr2 = r.exitCode === 0 ? undefined : await harnessLoadReason({ re
67615
67730
  async function runAppBoot(ctx, opts, checks, notProven) {
67616
67731
  let r;
67617
67732
  try {
67618
- r = await (opts.appProbe ?? appProbe)(ctx.repoDir, join93(ctx.repoDir, ".loki"));
67733
+ r = await (opts.appProbe ?? appProbe)(ctx.repoDir, join94(ctx.repoDir, ".loki"));
67619
67734
  } catch (err) {
67620
67735
  r = { checks: [{ name: "app boot", cmd: "autonomy/app-runner.sh", result: "not_run", duration_s: 0, reason: `app probe threw: ${err.message}` }], pid: null, url: null };
67621
67736
  }
@@ -67662,7 +67777,7 @@ async function runCouncilCheck(ctx, changed, baseSha, signal, opts, checks, notP
67662
67777
  }
67663
67778
  async function runSecretScan(ctx, changed, opts, checks, notProven) {
67664
67779
  const scriptPath = opts.secretScanShPath ?? DEFAULT_SECRET_SCAN_SH, name = "security scan", cmd = "secret-scan.sh + secure-scan.py";
67665
- if (!existsSync66(scriptPath)) {
67780
+ if (!existsSync67(scriptPath)) {
67666
67781
  checks.push({ name, cmd, result: "not_run", duration_s: 0 });
67667
67782
  notProven.add(`not run: ${name} (secret-scan.sh not found)`);
67668
67783
  return;
@@ -67673,7 +67788,7 @@ async function runSecretScan(ctx, changed, opts, checks, notProven) {
67673
67788
  }
67674
67789
  const inline = 'script="$1"; shift; . "$script" || exit 3; hit=0; for f in "$@"; do if _commit_scan_secret_file "$f" || _commit_path_looks_secret "$f"; then printf "%s\\n" "$f"; hit=1; fi; done; exit "$hit"';
67675
67790
  const started = Date.now();
67676
- const r = await run(["bash", "-c", inline, "_", scriptPath, ...changed.map((f) => join93(ctx.repoDir, f))], { cwd: ctx.repoDir, timeoutMs: 30000 });
67791
+ const r = await run(["bash", "-c", inline, "_", scriptPath, ...changed.map((f) => join94(ctx.repoDir, f))], { cwd: ctx.repoDir, timeoutMs: 30000 });
67677
67792
  const sec = await secureScanChanged(ctx.repoDir, changed, opts.secureScanPath), gaps = [], reasons = [];
67678
67793
  const hits = r.exitCode === 3 ? [] : r.stdout.split(`
67679
67794
  `).map((l) => l.trim()).filter(Boolean), high = sec.findings.filter((f) => String(f.severity).toUpperCase() === "HIGH");
@@ -67726,7 +67841,7 @@ async function runDeep(ctx, signal, opts = {}) {
67726
67841
  const sig = signReceipt(`${ctx.runId}-deep`, addendumSha256);
67727
67842
  const addendum = { ...addendumBody, addendum_sha256: addendumSha256, verification: { jwt: sig.jwt, kid: sig.kid } };
67728
67843
  mkdirSync49(ctx.runDir, { recursive: true });
67729
- writeFileSync47(join93(ctx.runDir, "receipt-addendum-1.json"), JSON.stringify(addendum, null, 2) + `
67844
+ writeFileSync48(join94(ctx.runDir, "receipt-addendum-1.json"), JSON.stringify(addendum, null, 2) + `
67730
67845
  `);
67731
67846
  const headSha = (await safeGitRun(ctx.repoDir, ["rev-parse", "HEAD"], { timeoutMs: 1e4 })).stdout.trim();
67732
67847
  const pushNotProven = await postDeepResults({
@@ -67752,11 +67867,11 @@ async function deepWorker(args, deps = {}) {
67752
67867
  `);
67753
67868
  return 2;
67754
67869
  }
67755
- const repoDir = process.cwd(), lokiRoot = join93(repoDir, ".loki"), runDir = join93(lokiRoot, "runs", runId);
67870
+ const repoDir = process.cwd(), lokiRoot = join94(repoDir, ".loki"), runDir = join94(lokiRoot, "runs", runId);
67756
67871
  const { readEvents: readEvents2 } = await Promise.resolve().then(() => (init_events(), exports_events)), { eventsRelPath: eventsRelPath2 } = await Promise.resolve().then(() => (init_engine_origin(), exports_engine_origin)), { outputsFromEvents: outputsFromEvents2 } = await Promise.resolve().then(() => (init_run_outputs(), exports_run_outputs));
67757
67872
  let outputs;
67758
67873
  try {
67759
- outputs = outputsFromEvents2(readEvents2(join93(repoDir, eventsRelPath2(runId))));
67874
+ outputs = outputsFromEvents2(readEvents2(join94(repoDir, eventsRelPath2(runId))));
67760
67875
  } catch (err) {
67761
67876
  process.stderr.write(`engine10 deep-worker: cannot read run events: ${err.message}
67762
67877
  `);
@@ -67846,9 +67961,9 @@ __export(exports_verify, {
67846
67961
  commandFor: () => commandFor,
67847
67962
  changedFiles: () => changedFiles
67848
67963
  });
67849
- import { existsSync as existsSync67, mkdtempSync as mkdtempSync12, readFileSync as readFileSync84, rmSync as rmSync27 } from "fs";
67850
- import { tmpdir as tmpdir15 } from "os";
67851
- import { basename as basename24, isAbsolute as isAbsolute18, join as join94, relative as relative20 } from "path";
67964
+ import { existsSync as existsSync68, mkdtempSync as mkdtempSync13, readFileSync as readFileSync85, rmSync as rmSync28 } from "fs";
67965
+ import { tmpdir as tmpdir16 } from "os";
67966
+ import { basename as basename25, isAbsolute as isAbsolute18, join as join95, relative as relative21 } from "path";
67852
67967
  async function runOnce3(cmd, args, cwd, signal, opts) {
67853
67968
  if (!Bun.which(cmd, { PATH: opts.path ?? process.env["PATH"] ?? "" }))
67854
67969
  return { ok: false, missing: true, cut: false, out: "" };
@@ -67941,7 +68056,7 @@ async function subtractBase(ctx, api, checks, tests, changed, wall, rel, signal,
67941
68056
  const zc2 = zeroOk ? un2.filter(({ c, t }) => c.result === "not_run" && !c.owner && (c.reason ?? "").startsWith(NO_TESTS_REASON) && !wall.has(c.name) && !isHoldoutCheck(c.name) && !changed.includes(t.path) && zeroIntake.has(c.name)) : [];
67942
68057
  if (!(un2.some(({ c }) => c.result === "fail" && c.ids?.length) || sus.length || zc2.length) || signal.aborted)
67943
68058
  return out3;
67944
- const dir = mkdtempSync12(join94(tmpdir15(), "e10-base-"));
68059
+ const dir = mkdtempSync13(join95(tmpdir16(), "e10-base-"));
67945
68060
  const git9 = (args) => {
67946
68061
  safeGit(ctx.repoDir, args, { stdio: "ignore", repoDrivers: true });
67947
68062
  };
@@ -67972,7 +68087,7 @@ async function subtractBase(ctx, api, checks, tests, changed, wall, rel, signal,
67972
68087
  try {
67973
68088
  git9(["worktree", "remove", "--force", dir]);
67974
68089
  } catch {}
67975
- rmSync27(dir, { recursive: true, force: true });
68090
+ rmSync28(dir, { recursive: true, force: true });
67976
68091
  try {
67977
68092
  git9(["worktree", "prune"]);
67978
68093
  } catch {}
@@ -67980,15 +68095,15 @@ async function subtractBase(ctx, api, checks, tests, changed, wall, rel, signal,
67980
68095
  return out3;
67981
68096
  }
67982
68097
  function isLokiModeRepo(repoDir) {
67983
- return existsSync67(join94(repoDir, "scripts", "select-tests.sh"));
68098
+ return existsSync68(join95(repoDir, "scripts", "select-tests.sh"));
67984
68099
  }
67985
68100
  function projectDeclaresRuff(repoDir) {
67986
- if (["ruff.toml", ".ruff.toml"].some((f) => existsSync67(join94(repoDir, f))))
68101
+ if (["ruff.toml", ".ruff.toml"].some((f) => existsSync68(join95(repoDir, f))))
67987
68102
  return true;
67988
68103
  const files = ["pyproject.toml", "setup.cfg", "tox.ini", ".pre-commit-config.yaml", "Pipfile", "requirements.txt", "requirements-dev.txt", "dev-requirements.txt"];
67989
68104
  return files.some((f) => {
67990
68105
  try {
67991
- return /\bruff\b/i.test(readFileSync84(join94(repoDir, f), "utf8"));
68106
+ return /\bruff\b/i.test(readFileSync85(join95(repoDir, f), "utf8"));
67992
68107
  } catch {
67993
68108
  return false;
67994
68109
  }
@@ -68014,9 +68129,9 @@ async function runLintChecks(ctx, changed, signal, checks, opts = {}) {
68014
68129
  }
68015
68130
  for (const g of groupByPackage(api, ctx.repoDir, changed.filter((f) => /\.(ts|tsx|js|jsx)$/.test(f)))) {
68016
68131
  const sfx = g.root === "." ? "" : `:${g.root}`, co = g.root === "." ? opts : { ...opts, cwd: g.cwd };
68017
- if (existsSync67(join94(g.cwd, "tsconfig.json")))
68132
+ if (existsSync68(join95(g.cwd, "tsconfig.json")))
68018
68133
  await runCheck(ctx, `lint:tsc${sfx}`, "npx", ["--no-install", "tsc", "--noEmit", "-p", "."], signal, checks, { ...co, kind: "static" });
68019
- if (ESLINT_CONFIGS.some((f) => existsSync67(join94(g.cwd, f)))) {
68134
+ if (ESLINT_CONFIGS.some((f) => existsSync68(join95(g.cwd, f)))) {
68020
68135
  const c = await runCheck(ctx, `lint:eslint${sfx}`, "npx", ["--no-install", "eslint", ...g.rel], signal, checks, { ...co, kind: "static" });
68021
68136
  if (await excuseLint(ctx, signal, c, "eslint", "npx", ["--no-install", "eslint"], g.cwd, g.rel, co))
68022
68137
  pre2.push(c.name);
@@ -68031,7 +68146,7 @@ var CHECK_TIMEOUT_MS = 60000, excerpts, isHold = (c) => isHoldoutCheck(c.name),
68031
68146
  return r.missing || r.cut ? null : r;
68032
68147
  }, base: (f) => {
68033
68148
  try {
68034
- return safeGit(ctx.repoDir, ["show", `${ctx.baseSha}:${relative20(ctx.repoDir, join94(cwd, f))}`], { stdio: ["ignore", "pipe", "ignore"] });
68149
+ return safeGit(ctx.repoDir, ["show", `${ctx.baseSha}:${relative21(ctx.repoDir, join95(cwd, f))}`], { stdio: ["ignore", "pipe", "ignore"] });
68035
68150
  } catch {
68036
68151
  return null;
68037
68152
  }
@@ -68096,14 +68211,14 @@ var init_verify = __esm(() => {
68096
68211
  const impacted = ctx.tests.impacted(map, changed);
68097
68212
  const changedTestFiles = map.tests.filter((t) => changed.includes(t.path));
68098
68213
  const wall = ctx.outputs().wall ?? {};
68099
- const wallPaths = new Set((wall.files ?? []).map((f) => isAbsolute18(f.path) ? relative20(ctx.repoDir, f.path) : f.path));
68214
+ const wallPaths = new Set((wall.files ?? []).map((f) => isAbsolute18(f.path) ? relative21(ctx.repoDir, f.path) : f.path));
68100
68215
  const intake = ctx.outputs().intake, repoMap = loadRepoMap(intake?.repomap_ref), relevant2 = ctx.tests.impacted(map, namedFiles(intake?.task ?? "", repoMap));
68101
68216
  const harness = map.runners.length === 0 ? harnessRunners(map.runners, repoMap?.files ?? [], process.env, [...changed, ...wallPaths])[0] : undefined, wallRunners = harness ? [harness] : map.runners;
68102
68217
  const wallTests = [...wallPaths].flatMap((p) => {
68103
68218
  const found = map.tests.find((t) => t.path === p);
68104
68219
  if (found)
68105
68220
  return [found];
68106
- const runner = guessRunner(basename24(p), wallRunners, p);
68221
+ const runner = guessRunner(basename25(p), wallRunners, p);
68107
68222
  return runner && (runner !== harness || /[._](?:test|spec)\.[cm]?[jt]sx?$/.test(p)) ? [{ runner, path: p }] : [];
68108
68223
  });
68109
68224
  const tests = failedFirst(dedupeTests([...impacted, ...changedTestFiles, ...wallTests, ...relevant2]), ctx.outputs().verify?.checks);
@@ -68204,9 +68319,9 @@ ${x3}` : c.cmd };
68204
68319
  });
68205
68320
  const weakened = [...modifiedRel, ...cfgChanged.map((f) => `test configuration changed: ${f}`), ...preRed.weak.map((n10) => `skipped or fewer tests than base: ${n10}`)];
68206
68321
  const notProven = [...weakened, ...intake?.deps_not_proven ?? [], ...pub.filter((c) => c.name === "holdout" && c.result !== "pass").map((c) => c.result === "not_run" ? "holdout not executed" : "holdout check failed"), ...[...fullNotProven].filter((n10) => !naNote(n10)), ...pub.filter((c) => c.owner === "harness" && c.name !== "holdout").map((c) => `${c.reason} (${c.name}; harness-owned, no fix rounds)`), ...new Set(checks.filter((c) => c.interpreter === "system" && c.result !== "not_run").map((c) => c.name.startsWith("lint:") ? "lint ran on the system ruff" : "tests ran on the system interpreter"))];
68207
- const wallDropped = [...wallPaths].filter((p) => !wallTests.some((t) => t.path === p));
68208
- notProven.push(...wallDropped.map((p) => `Wall test not executed: ${p}: ${NO_RUNNER_REASON}`));
68209
- const wallNames = new Set(wallTests.map(testCheckName)), wallRun = checks.filter((c) => wallNames.has(c.name) || isHold(c)), wallPassed = wallRun.some((c) => c.result === "fail") ? false : wallRun.length > 0 && wallDropped.length === 0 && wallRun.every((c) => c.result === "pass") ? true : undefined;
68322
+ const wallDropped2 = [...wallPaths].filter((p) => !wallTests.some((t) => t.path === p));
68323
+ notProven.push(...wallDropped2.map((p) => `Wall test not executed: ${p}: ${NO_RUNNER_REASON}`));
68324
+ const wallNames = new Set(wallTests.map(testCheckName)), wallRun = checks.filter((c) => wallNames.has(c.name) || isHold(c)), wallPassed = wallRun.some((c) => c.result === "fail") ? false : wallRun.length > 0 && wallDropped2.length === 0 && wallRun.every((c) => c.result === "pass") ? true : undefined;
68210
68325
  return { status: "completed", data: { checks: pub, flaky, ...wallPassed === undefined ? {} : { wall_passed: wallPassed }, failures_grouped: failuresGrouped, holdout_failed: holdoutFailed, changed_files: changed, not_proven: notProven, ...fullNotProven.size ? { not_applicable: [...fullNotProven].filter(naNote).map(naText) } : {}, pre_red: preRed.ids, pre_red_checks: preRed.names, skipped_on_base: preRed.zero, ...attr.line ? { baseline_line: attr.line, introduced_checks: attr.introducedChecks } : {}, test_counts: testCounts, uncovered_changed: uncoveredChanged, target_checks: checks.filter((c) => c.result === "pass" && targetNames.has(c.name)).map((c) => isHold(c) ? "holdout" : c.name), risk } };
68211
68326
  }
68212
68327
  };
@@ -68238,9 +68353,9 @@ __export(exports_wall, {
68238
68353
  BASE_RUN_TIMEOUT_MS: () => BASE_RUN_TIMEOUT_MS
68239
68354
  });
68240
68355
  import { spawnSync as spawnSync10 } from "child_process";
68241
- import { existsSync as existsSync68, mkdirSync as mkdirSync50, mkdtempSync as mkdtempSync13, readFileSync as readFileSync85, readdirSync as readdirSync28, rmSync as rmSync28, writeFileSync as writeFileSync48 } from "fs";
68242
- import { tmpdir as tmpdir16 } from "os";
68243
- import { dirname as dirname38, join as join95, relative as relative21 } from "path";
68356
+ import { existsSync as existsSync69, mkdirSync as mkdirSync50, mkdtempSync as mkdtempSync14, readFileSync as readFileSync86, readdirSync as readdirSync28, rmSync as rmSync29, writeFileSync as writeFileSync49 } from "fs";
68357
+ import { tmpdir as tmpdir17 } from "os";
68358
+ import { dirname as dirname38, join as join96, relative as relative22 } from "path";
68244
68359
 
68245
68360
  class RealBaseTestRunner {
68246
68361
  api;
@@ -68306,10 +68421,10 @@ ${acceptance2.map((a) => `Acceptance: ${a}`).join(`
68306
68421
  function loadTaskText(ctx, fromPrior) {
68307
68422
  if (fromPrior)
68308
68423
  return fromPrior;
68309
- const issueJsonPath = process.env.LOKI_E10_ISSUE_JSON ?? join95(ctx.runDir, "issue.json");
68310
- if (existsSync68(issueJsonPath)) {
68424
+ const issueJsonPath = process.env.LOKI_E10_ISSUE_JSON ?? join96(ctx.runDir, "issue.json");
68425
+ if (existsSync69(issueJsonPath)) {
68311
68426
  try {
68312
- const issue = JSON.parse(readFileSync85(issueJsonPath, "utf8"));
68427
+ const issue = JSON.parse(readFileSync86(issueJsonPath, "utf8"));
68313
68428
  const text3 = [issue.title, issue.body].filter((s) => typeof s === "string" && s.length > 0).join(`
68314
68429
 
68315
68430
  `);
@@ -68321,7 +68436,7 @@ function loadTaskText(ctx, fromPrior) {
68321
68436
  }
68322
68437
  function wallTargetDir(repoDir, existingTests) {
68323
68438
  const first = existingTests[0];
68324
- return first ? join95(repoDir, dirname38(first.path)) : join95(repoDir, "tests");
68439
+ return first ? join96(repoDir, dirname38(first.path)) : join96(repoDir, "tests");
68325
68440
  }
68326
68441
  async function wallAuthor(ctx, signal, retry) {
68327
68442
  const done = (result) => ({ kind: "done", result });
@@ -68346,17 +68461,17 @@ async function wallAuthor(ctx, signal, retry) {
68346
68461
  return done({ status: "skipped", data: { size: sz2.size, files: [], no_interpreter: true, not_proven: ["Wall skipped: no project test interpreter"] }, reason: "Wall skipped: no project test interpreter" });
68347
68462
  const tree = prior.intake?.tree;
68348
68463
  const repomapText = repoMapText(ctx.repoDir, tree, repomapRef, WALL_MAP_MAX_LINES);
68349
- const targetDir = wallTargetDir(ctx.repoDir, existingTests), pkg = loadProjectApi(ctx.repoDir)?.packageOf(`${relative21(ctx.repoDir, targetDir)}/x`);
68350
- const conv2 = readPackageConventions(join95(ctx.repoDir, pkg?.root ?? "."), pkg?.runner ?? null);
68351
- const cwd = mkdtempSync13(join95(tmpdir16(), "loki-e15-wall-"));
68464
+ const targetDir = wallTargetDir(ctx.repoDir, existingTests), pkg = loadProjectApi(ctx.repoDir)?.packageOf(`${relative22(ctx.repoDir, targetDir)}/x`);
68465
+ const conv2 = readPackageConventions(join96(ctx.repoDir, pkg?.root ?? "."), pkg?.runner ?? null);
68466
+ const cwd = mkdtempSync14(join96(tmpdir17(), "loki-e15-wall-"));
68352
68467
  const wm2 = wallManifestFor(ctx.repoDir, tree, task);
68353
68468
  for (const [n10, c] of [["task.md", task], ["repomap.txt", repomapText], ...wm2 ? [["wall_manifest.txt", wm2.text]] : []])
68354
- writeFileSync48(join95(cwd, n10), c, "utf8");
68469
+ writeFileSync49(join96(cwd, n10), c, "utf8");
68355
68470
  const clauseSet = extractClauses(task);
68356
68471
  const model = retry?.model ?? wallFirstModel(sz2.size), iterationId = `${ctx.runId}-wall${retry?.suffix ?? ""}`;
68357
68472
  const session = await ctx.sessions.run({
68358
68473
  stage: "wall",
68359
- brief: buildWallBrief(task, repomapText, runners, !!wm2, conventionsBrief(conv2), unitSpec()?.acceptance ?? [], relative21(ctx.repoDir, targetDir), clauseSet),
68474
+ brief: buildWallBrief(task, repomapText, runners, !!wm2, conventionsBrief(conv2), unitSpec()?.acceptance ?? [], relative22(ctx.repoDir, targetDir), clauseSet),
68360
68475
  tier: "development",
68361
68476
  model,
68362
68477
  iterationId,
@@ -68365,26 +68480,26 @@ async function wallAuthor(ctx, signal, retry) {
68365
68480
  cwd
68366
68481
  });
68367
68482
  if (session.killed || session.exit === null) {
68368
- rmSync28(cwd, { recursive: true, force: true });
68483
+ rmSync29(cwd, { recursive: true, force: true });
68369
68484
  return done({ status: "failed", data: { iteration_ids: [iterationId], model }, reason: "wall session aborted, killed, or timed out", killed: true });
68370
68485
  }
68371
68486
  const planText = typeof prior.plan?.plan === "string" ? prior.plan.plan : null, repoFiles = repoMap?.files ?? [];
68372
68487
  const oor = () => readdirSync28(cwd).filter((f) => f.startsWith(WALL_PREFIX)).flatMap((name) => {
68373
- const text3 = readFileSync85(join95(cwd, name), "utf8"), why = outOfRepoTarget(text3) ?? vacuousCheck(name, text3) ?? phantomReason(phantomRepoPaths(text3, name, targetDir, ctx.repoDir, planText), repoFiles, relative21(ctx.repoDir, targetDir), pkg?.root ?? "");
68488
+ const text3 = readFileSync86(join96(cwd, name), "utf8"), why = outOfRepoTarget(text3) ?? vacuousCheck(name, text3) ?? phantomReason(phantomRepoPaths(text3, name, targetDir, ctx.repoDir, planText), repoFiles, relative22(ctx.repoDir, targetDir), pkg?.root ?? "");
68374
68489
  return why ? [{ name, why }] : [];
68375
68490
  });
68376
68491
  const bad1 = oor();
68377
68492
  if (bad1.length > 0 && !signal.aborted && !ctx.overCap?.())
68378
68493
  await ctx.sessions.run({ stage: "wall", brief: withStagePrefix(outOfRepoReask("Rewrite these Wall files in place, keeping the same names and acceptance coverage.", bad1)), tier: "development", model, iterationId: `${iterationId}-oor`, limitS: wallLimitS(sz2.size), signal, cwd });
68379
- const oorBad = new Map(oor().map((b) => [b.name, b.why])), all = readdirSync28(cwd).filter((f) => f.startsWith(WALL_PREFIX)), held = stashHoldout({ runId: ctx.runId, repoDir: ctx.repoDir, srcDir: cwd, targetDir, names: all.filter((n10) => !oorBad.has(n10) && !conventionViolation(conv2, n10, readFileSync85(join95(cwd, n10), "utf8"))), runnerOf: (n10) => guessRunner(n10, runners) }), generated = all.filter((n10) => !held?.names.has(n10));
68380
- const sealedDir = join95(ctx.runDir, "wall");
68494
+ const oorBad = new Map(oor().map((b) => [b.name, b.why])), all = readdirSync28(cwd).filter((f) => f.startsWith(WALL_PREFIX)), held = stashHoldout({ runId: ctx.runId, repoDir: ctx.repoDir, srcDir: cwd, targetDir, names: all.filter((n10) => !oorBad.has(n10) && !conventionViolation(conv2, n10, readFileSync86(join96(cwd, n10), "utf8"))), runnerOf: (n10) => guessRunner(n10, runners) }), generated = all.filter((n10) => !held?.names.has(n10));
68495
+ const sealedDir = join96(ctx.runDir, "wall");
68381
68496
  if (generated.length > 0)
68382
68497
  mkdirSync50(sealedDir, { recursive: true });
68383
68498
  const contents = new Map;
68384
68499
  const discarded = [];
68385
68500
  for (const name of generated) {
68386
- const content = readFileSync85(join95(cwd, name), "utf8"), oorWhy = oorBad.get(name), bad = oorWhy ?? conventionViolation(conv2, name, content);
68387
- writeFileSync48(join95(sealedDir, name), content, "utf8");
68501
+ const content = readFileSync86(join96(cwd, name), "utf8"), oorWhy = oorBad.get(name), bad = oorWhy ?? conventionViolation(conv2, name, content);
68502
+ writeFileSync49(join96(sealedDir, name), content, "utf8");
68388
68503
  if (oorWhy)
68389
68504
  discarded.push({ file: name, reason: `${oorWhy}; wall test discarded after one rewrite request` });
68390
68505
  else if (bad)
@@ -68392,7 +68507,7 @@ async function wallAuthor(ctx, signal, retry) {
68392
68507
  else
68393
68508
  contents.set(name, content);
68394
68509
  }
68395
- rmSync28(cwd, { recursive: true, force: true });
68510
+ rmSync29(cwd, { recursive: true, force: true });
68396
68511
  return { kind: "authored", model, iterationId, task, sizeName: sz2.size, runners, targetDir, generated, contents, discarded, ...clauseSet.clauses.length ? { clauses: clauseSet } : {}, ...wm2 ? { manifestSha256: wm2.sha256 } : {}, ...held ? { holdoutDir: held.dir } : {} };
68397
68512
  }
68398
68513
  function installWall(ctx, a, baseDir, opts = {}) {
@@ -68413,30 +68528,30 @@ function* installCore(ctx, a, baseDir, opts) {
68413
68528
  const content = contents.get(name);
68414
68529
  if (content === undefined)
68415
68530
  continue;
68416
- const dest = join95(targetDir, name), runner = guessRunner(name, runners, relative21(ctx.repoDir, dest));
68417
- writeFileSync48(dest, content, "utf8");
68531
+ const dest = join96(targetDir, name), runner = guessRunner(name, runners, relative22(ctx.repoDir, dest));
68532
+ writeFileSync49(dest, content, "utf8");
68418
68533
  sealedFiles.push({ path: dest, sha256: sha2562(content) });
68419
68534
  readOnlyFiles.push({ path: dest, content });
68420
68535
  if (runner)
68421
- wallTests.push({ runner, path: relative21(ctx.repoDir, dest) });
68536
+ wallTests.push({ runner, path: relative22(ctx.repoDir, dest) });
68422
68537
  }
68423
68538
  ctx.wallSealed = true;
68424
68539
  ctx.emit("wall.sealed", "wall", { files: sealedFiles, ...a.manifestSha256 ? { manifest_sha256: a.manifestSha256 } : {} });
68425
68540
  const baseRunner = opts.baseRunner ?? new RealBaseTestRunner, baseRun = { pass: 0, fail: 0, not_run: discarded.length }, notRunFiles = [];
68426
68541
  for (const f of sealedFiles) {
68427
- const rel = relative21(ctx.repoDir, f.path);
68542
+ const rel = relative22(ctx.repoDir, f.path);
68428
68543
  if (!wallTests.some((t) => t.path === rel))
68429
68544
  notRunFiles.push({ file: rel, reason: NO_RUNNER_REASON });
68430
68545
  }
68431
68546
  const each = yield { runner: baseRunner, tests: wallTests };
68432
68547
  for (const [i, t] of wallTests.entries()) {
68433
- const e10 = each?.[i], r = e10 ?? baseRunner.run(baseDir, [t]), abs = join95(ctx.repoDir, t.path);
68548
+ const e10 = each?.[i], r = e10 ?? baseRunner.run(baseDir, [t]), abs = join96(ctx.repoDir, t.path);
68434
68549
  baseRun.pass += r.pass;
68435
68550
  baseRun.fail += r.fail;
68436
68551
  baseRun.not_run += r.not_run ?? 0;
68437
68552
  notRunFiles.push(...e10 ? e10.notRunFiles : baseRunner.lastNotRunFiles ?? []);
68438
68553
  if (r.pass + r.fail === 0) {
68439
- rmSync28(abs, { force: true });
68554
+ rmSync29(abs, { force: true });
68440
68555
  for (const l of [sealedFiles, readOnlyFiles])
68441
68556
  l.splice(0, l.length, ...l.filter((f) => f.path !== abs));
68442
68557
  }
@@ -68472,8 +68587,8 @@ async function runWall(ctx, signal, opts = {}) {
68472
68587
  return green ? { ...first, data: distrustGreenBase(first.data) } : first;
68473
68588
  if (a.kind === "authored") {
68474
68589
  for (const f of first.data.files ?? [])
68475
- rmSync28(f.path, { force: true });
68476
- rmSync28(join95(ctx.runDir, "wall"), { recursive: true, force: true });
68590
+ rmSync29(f.path, { force: true });
68591
+ rmSync29(join96(ctx.runDir, "wall"), { recursive: true, force: true });
68477
68592
  ctx.wallSealed = false;
68478
68593
  }
68479
68594
  removeHoldout(ctx.runId, ctx.repoDir);
@@ -68513,15 +68628,15 @@ var init_wall = __esm(() => {
68513
68628
  });
68514
68629
 
68515
68630
  // ../../loki-ts/src/e10ext/discard.ts
68516
- import { chmodSync as chmodSync6, closeSync as closeSync13, lstatSync as lstatSync24, mkdirSync as mkdirSync51, openSync as openSync13, readFileSync as readFileSync86, realpathSync as realpathSync29, rmdirSync, unlinkSync as unlinkSync9, writeFileSync as writeFileSync49 } from "fs";
68517
- import { dirname as dirname39, join as join96, relative as relative22, sep as sep19 } from "path";
68631
+ import { chmodSync as chmodSync6, closeSync as closeSync13, lstatSync as lstatSync24, mkdirSync as mkdirSync51, openSync as openSync13, readFileSync as readFileSync87, realpathSync as realpathSync29, rmdirSync, unlinkSync as unlinkSync9, writeFileSync as writeFileSync50 } from "fs";
68632
+ import { dirname as dirname39, join as join97, relative as relative23, sep as sep19 } from "path";
68518
68633
  function safeRestore(repoDir, f, want, mode) {
68519
- const root = realpathSync29(repoDir), fp2 = join96(root, f), rel = relative22(root, dirname39(fp2));
68634
+ const root = realpathSync29(repoDir), fp2 = join97(root, f), rel = relative23(root, dirname39(fp2));
68520
68635
  if (rel.startsWith(".."))
68521
68636
  throw new Error("outside repo");
68522
68637
  let cur = root;
68523
68638
  for (const part of rel === "" ? [] : rel.split(sep19)) {
68524
- cur = join96(cur, part);
68639
+ cur = join97(cur, part);
68525
68640
  let st3;
68526
68641
  try {
68527
68642
  st3 = lstatSync24(cur);
@@ -68538,7 +68653,7 @@ function safeRestore(repoDir, f, want, mode) {
68538
68653
  } catch {
68539
68654
  st2 = null;
68540
68655
  }
68541
- if (st2?.isFile() && readFileSync86(fp2).equals(want)) {
68656
+ if (st2?.isFile() && readFileSync87(fp2).equals(want)) {
68542
68657
  chmodSync6(fp2, mode);
68543
68658
  return;
68544
68659
  }
@@ -68550,7 +68665,7 @@ function safeRestore(repoDir, f, want, mode) {
68550
68665
  }
68551
68666
  const fd2 = openSync13(fp2, "wx", mode);
68552
68667
  try {
68553
- writeFileSync49(fd2, want);
68668
+ writeFileSync50(fd2, want);
68554
68669
  } finally {
68555
68670
  closeSync13(fd2);
68556
68671
  }
@@ -68575,7 +68690,7 @@ async function discardIfSatisfied(git9, base, o, staged, keep, repoDir) {
68575
68690
  return { status: "failed", data: {}, reason: "already-satisfied discard failed" };
68576
68691
  const notProven = [];
68577
68692
  for (const [f, v3] of Object.entries(o.intake?.preexisting_untracked_blobs ?? {})) {
68578
- const fp2 = join96(repoDir, f);
68693
+ const fp2 = join97(repoDir, f);
68579
68694
  try {
68580
68695
  if (v3.startsWith("!")) {
68581
68696
  const st2 = lstatSync24(fp2);
@@ -68594,7 +68709,7 @@ async function discardIfSatisfied(git9, base, o, staged, keep, repoDir) {
68594
68709
  try {
68595
68710
  let m = 420;
68596
68711
  try {
68597
- const l = lstatSync24(join96(repoDir, f));
68712
+ const l = lstatSync24(join97(repoDir, f));
68598
68713
  if (l.isFile())
68599
68714
  m = l.mode & 511;
68600
68715
  } catch {}
@@ -68610,7 +68725,7 @@ var init_discard = __esm(() => {
68610
68725
  });
68611
68726
 
68612
68727
  // ../../loki-ts/src/e10ext/scope.ts
68613
- import { basename as basename25, dirname as dirname40 } from "path";
68728
+ import { basename as basename26, dirname as dirname40 } from "path";
68614
68729
  function contractText(o) {
68615
68730
  const c = o.intake?.contract_snapshot?.contract;
68616
68731
  return Array.isArray(c?.criteria) ? c.criteria.map((x3) => typeof x3?.text === "string" ? x3.text : "").join(`
@@ -68625,7 +68740,7 @@ function outsideScope(o, staged) {
68625
68740
  ${typeof o.intake?.task === "string" ? o.intake.task : ""}
68626
68741
  ${contractText(o)}`, pre2 = o.intake?.preexisting_dirty ?? {};
68627
68742
  const toks = surfaceTokens(text3), plannedDirs = new Set(rel.map((r) => dirname40(r)).filter((d) => d !== "."));
68628
- return staged.filter(({ st: st2, f }) => st2 !== "A" && !isTestFile(f) && !Object.hasOwn(pre2, f) && !rel.includes(f) && !mentions(text3, f) && !mentions(text3, basename25(f)) && !plannedDirs.has(dirname40(f)) && !dirSegs(f).some((d) => toks.has(d))).map(({ f }) => f);
68743
+ return staged.filter(({ st: st2, f }) => st2 !== "A" && !isTestFile(f) && !Object.hasOwn(pre2, f) && !rel.includes(f) && !mentions(text3, f) && !mentions(text3, basename26(f)) && !plannedDirs.has(dirname40(f)) && !dirSegs(f).some((d) => toks.has(d))).map(({ f }) => f);
68629
68744
  }
68630
68745
  function flagOutsideScope(o, staged) {
68631
68746
  const unit = unitFlags(staged, process.env, o.intake?.preexisting_dirty ?? {});
@@ -68640,14 +68755,14 @@ var init_scope2 = __esm(() => {
68640
68755
  });
68641
68756
 
68642
68757
  // ../../loki-ts/src/council/role_agents.ts
68643
- import { existsSync as existsSync69, readdirSync as readdirSync29, readFileSync as readFileSync87 } from "fs";
68758
+ import { existsSync as existsSync70, readdirSync as readdirSync29, readFileSync as readFileSync88 } from "fs";
68644
68759
  import { homedir as homedir11 } from "os";
68645
- import { join as join97 } from "path";
68760
+ import { join as join98 } from "path";
68646
68761
  function agentDirs(repoDir, env = process.env) {
68647
- return [env["LOKI_AGENTS_PROJECT_DIR"] || join97(repoDir, ".loki", "agents"), env["LOKI_AGENTS_USER_DIR"] || join97(env["XDG_CONFIG_HOME"] || join97(homedir11(), ".config"), "loki", "agents")];
68762
+ return [env["LOKI_AGENTS_PROJECT_DIR"] || join98(repoDir, ".loki", "agents"), env["LOKI_AGENTS_USER_DIR"] || join98(env["XDG_CONFIG_HOME"] || join98(homedir11(), ".config"), "loki", "agents")];
68648
68763
  }
68649
68764
  function parseAgent(file, stem2) {
68650
- const m = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/.exec(readFileSync87(file, "utf8"));
68765
+ const m = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/.exec(readFileSync88(file, "utf8"));
68651
68766
  if (!m)
68652
68767
  return null;
68653
68768
  const body = m[2].trim();
@@ -68661,7 +68776,7 @@ function parseAgent(file, stem2) {
68661
68776
  }
68662
68777
  function loadRoleAgent(repoDir, role, env = process.env) {
68663
68778
  for (const d of agentDirs(repoDir, env)) {
68664
- if (!existsSync69(d))
68779
+ if (!existsSync70(d))
68665
68780
  continue;
68666
68781
  let names;
68667
68782
  try {
@@ -68672,7 +68787,7 @@ function loadRoleAgent(repoDir, role, env = process.env) {
68672
68787
  const ordered = [...names.filter((n10) => n10 === `${role}.md`), ...names.filter((n10) => n10 !== `${role}.md`)];
68673
68788
  for (const n10 of ordered) {
68674
68789
  try {
68675
- const a = parseAgent(join97(d, n10), n10.slice(0, -3));
68790
+ const a = parseAgent(join98(d, n10), n10.slice(0, -3));
68676
68791
  if (a && a.role === role)
68677
68792
  return a;
68678
68793
  } catch {}
@@ -68691,11 +68806,11 @@ function explicitReview(repoDir, env) {
68691
68806
  if (flag && isOff(ev2))
68692
68807
  return "off";
68693
68808
  for (const f of ["loki.yaml", "loki.yml"]) {
68694
- const p = join97(repoDir, f);
68695
- if (!existsSync69(p))
68809
+ const p = join98(repoDir, f);
68810
+ if (!existsSync70(p))
68696
68811
  continue;
68697
68812
  try {
68698
- const m = /^review:[ \t]*["']?([A-Za-z]+)["']?[ \t]*(?:#.*)?$/m.exec(readFileSync87(p, "utf8"));
68813
+ const m = /^review:[ \t]*["']?([A-Za-z]+)["']?[ \t]*(?:#.*)?$/m.exec(readFileSync88(p, "utf8"));
68699
68814
  const v3 = asProvider(m?.[1]);
68700
68815
  if (v3)
68701
68816
  return v3;
@@ -68728,7 +68843,7 @@ var init_role_agents = __esm(() => {
68728
68843
 
68729
68844
  // ../../loki-ts/src/util/child_ledger.ts
68730
68845
  import { appendFileSync as appendFileSync10, mkdirSync as mkdirSync52 } from "fs";
68731
- import { join as join98 } from "path";
68846
+ import { join as join99 } from "path";
68732
68847
  function unmeasuredRecord(phase, model, source) {
68733
68848
  return { phase, model, input_tokens: 0, output_tokens: 0, cache_creation_tokens: 0, cache_read_tokens: 0, source, cost_status: "unmeasured" };
68734
68849
  }
@@ -68753,9 +68868,9 @@ function recordFromClaudeResult(phase, payload, source = "claude-json") {
68753
68868
  }
68754
68869
  function appendChildLedger(lokiDir2, rec2) {
68755
68870
  try {
68756
- const dir = join98(lokiDir2, "metrics");
68871
+ const dir = join99(lokiDir2, "metrics");
68757
68872
  mkdirSync52(dir, { recursive: true });
68758
- appendFileSync10(join98(dir, "child-sessions.jsonl"), `${JSON.stringify(rec2)}
68873
+ appendFileSync10(join99(dir, "child-sessions.jsonl"), `${JSON.stringify(rec2)}
68759
68874
  `);
68760
68875
  return true;
68761
68876
  } catch {
@@ -68785,7 +68900,7 @@ var init_child_ledger = __esm(() => {
68785
68900
  });
68786
68901
 
68787
68902
  // ../../loki-ts/src/engine10/stages/xreview.ts
68788
- import { join as join99 } from "path";
68903
+ import { join as join100 } from "path";
68789
68904
  function minVerdict(verdict, review) {
68790
68905
  const ceiling = review?.level === "block" ? "PARTIAL" : verdict;
68791
68906
  return RANK4[ceiling] < RANK4[verdict] ? ceiling : verdict;
@@ -68883,9 +68998,9 @@ Review ONLY the diff below. Do not modify files.` : "You are an independent code
68883
68998
  try {
68884
68999
  if (p === "claude")
68885
69000
  await ensureClaudeHelpCache();
68886
- const r = await withChildLedger(run, join99(ctx.repoDir, ".loki"), "xreview")(reviewArgv(p, prompt, process.env, p === "claude" ? agent?.model || pin : undefined), { cwd: ctx.repoDir, timeoutMs: boxFor(ctx) * 1000, group: true, signal });
69001
+ const r = await withChildLedger(run, join100(ctx.repoDir, ".loki"), "xreview")(reviewArgv(p, prompt, process.env, p === "claude" ? agent?.model || pin : undefined), { cwd: ctx.repoDir, timeoutMs: boxFor(ctx) * 1000, group: true, signal });
68887
69002
  const costId = `${ctx.runId}-xreview-${p}`;
68888
- writeReviewerCost(join99(ctx.repoDir, ".loki"), costId, { reviewer: `xreview-${p}`, provider: p, model: p === "claude" ? agent?.model || pin : undefined, stdout: r.stdout, stderr: r.stderr });
69003
+ writeReviewerCost(join100(ctx.repoDir, ".loki"), costId, { reviewer: `xreview-${p}`, provider: p, model: p === "claude" ? agent?.model || pin : undefined, stdout: r.stdout, stderr: r.stderr });
68889
69004
  if (r.exitCode !== 0)
68890
69005
  return { ...tag({ provider: p, level: "not_run", notes: [`cross-review not run: ${p} exited ${r.exitCode}`] }), cost_iteration: costId };
68891
69006
  return { ...tag(parseReview(p, r.stdout)), cost_iteration: costId };
@@ -69066,10 +69181,10 @@ __export(exports_contract, {
69066
69181
  MAX_CONTRACT_BYTES: () => MAX_CONTRACT_BYTES,
69067
69182
  CONSTRAINT_KINDS: () => CONSTRAINT_KINDS
69068
69183
  });
69069
- import { existsSync as existsSync70, lstatSync as lstatSync25, mkdirSync as mkdirSync53, readFileSync as readFileSync88, rmSync as rmSync29, writeFileSync as writeFileSync50 } from "fs";
69184
+ import { existsSync as existsSync71, lstatSync as lstatSync25, mkdirSync as mkdirSync53, readFileSync as readFileSync89, rmSync as rmSync30, writeFileSync as writeFileSync51 } from "fs";
69070
69185
  import { spawnSync as spawnSync11 } from "child_process";
69071
- import { dirname as dirname41, join as join100 } from "path";
69072
- import { createHash as createHash27 } from "crypto";
69186
+ import { dirname as dirname41, join as join101 } from "path";
69187
+ import { createHash as createHash28 } from "crypto";
69073
69188
  function contractEnabled(env = process.env) {
69074
69189
  return env["LOKI_CONTRACT"] !== "0";
69075
69190
  }
@@ -69135,7 +69250,7 @@ function assignCriteria(units, criteria2) {
69135
69250
  return { units: out3, orphans: criteria2.filter((c) => !owned.has(c.id)) };
69136
69251
  }
69137
69252
  function groupContractPath(repoDir, groupId) {
69138
- return join100(repoDir, ".loki", "groups", groupId.replace(/[^A-Za-z0-9._-]/g, "_"), "contract.json");
69253
+ return join101(repoDir, ".loki", "groups", groupId.replace(/[^A-Za-z0-9._-]/g, "_"), "contract.json");
69139
69254
  }
69140
69255
  function freezeGroupContract(repoDir, groupId, units, contract) {
69141
69256
  const a = assignCriteria(units, contract.criteria);
@@ -69200,7 +69315,7 @@ function untracedLines(trace) {
69200
69315
  return trace.criteria.filter((c) => c.status === "no_match").map((c) => `contract ${sanitizeCriterion(c.id)} untraced (no keyword match in changed files): ${sanitizeCriterion(c.text)}`);
69201
69316
  }
69202
69317
  function contractPath(repoDir) {
69203
- return join100(repoDir, ".loki", "contract.json");
69318
+ return join101(repoDir, ".loki", "contract.json");
69204
69319
  }
69205
69320
  function readContract(repoDir) {
69206
69321
  const p = contractPath(repoDir);
@@ -69216,11 +69331,11 @@ function readContract(repoDir) {
69216
69331
  return { contract: null, notes: ["contract unreadable: too large"], sha256: null };
69217
69332
  let raw2;
69218
69333
  try {
69219
- raw2 = readFileSync88(p);
69334
+ raw2 = readFileSync89(p);
69220
69335
  } catch {
69221
69336
  return { contract: null, notes: ["contract unreadable: read failed"], sha256: null };
69222
69337
  }
69223
- const sha2563 = createHash27("sha256").update(raw2).digest("hex");
69338
+ const sha2563 = createHash28("sha256").update(raw2).digest("hex");
69224
69339
  let j10;
69225
69340
  try {
69226
69341
  j10 = JSON.parse(raw2.toString("utf8"));
@@ -69283,15 +69398,15 @@ function main3(args) {
69283
69398
  `);
69284
69399
  return file ? 0 : 2;
69285
69400
  }
69286
- if (!existsSync70(file)) {
69401
+ if (!existsSync71(file)) {
69287
69402
  process.stderr.write(`contract: no such file: ${file}
69288
69403
  `);
69289
69404
  return 2;
69290
69405
  }
69291
- const contract = parseContract(readFileSync88(file, "utf8"), file);
69406
+ const contract = parseContract(readFileSync89(file, "utf8"), file);
69292
69407
  const out3 = contractPath(repoRoot(process.cwd()));
69293
69408
  mkdirSync53(dirname41(out3), { recursive: true });
69294
- writeFileSync50(out3, JSON.stringify(contract, null, 2) + `
69409
+ writeFileSync51(out3, JSON.stringify(contract, null, 2) + `
69295
69410
  `);
69296
69411
  process.stdout.write(renderContract(contract));
69297
69412
  return 0;
@@ -69347,8 +69462,8 @@ function fromSpecText(raw2) {
69347
69462
  }
69348
69463
  }
69349
69464
  function fromPrdText(text3, python = "python3") {
69350
- const script = join100(REPO_ROOT, "autonomy", "lib", "requirements_contract.py");
69351
- if (!existsSync70(script))
69465
+ const script = join101(REPO_ROOT, "autonomy", "lib", "requirements_contract.py");
69466
+ if (!existsSync71(script))
69352
69467
  return null;
69353
69468
  const code = `import sys,json,importlib.util as u
69354
69469
  s=u.spec_from_file_location('rc',sys.argv[1]);m=u.module_from_spec(s);sys.modules['rc']=m;s.loader.exec_module(m)
@@ -69390,12 +69505,12 @@ function mapRequirements(reqs, ran2, revision) {
69390
69505
  return { version: 1, revision, requirements: out3 };
69391
69506
  }
69392
69507
  function fromChecklist(lokiDir2) {
69393
- const p = join100(lokiDir2, "checklist", "checklist.json");
69394
- if (!existsSync70(p))
69508
+ const p = join101(lokiDir2, "checklist", "checklist.json");
69509
+ if (!existsSync71(p))
69395
69510
  return null;
69396
69511
  let doc;
69397
69512
  try {
69398
- doc = JSON.parse(readFileSync88(p, "utf8"));
69513
+ doc = JSON.parse(readFileSync89(p, "utf8"));
69399
69514
  } catch {
69400
69515
  return null;
69401
69516
  }
@@ -69427,7 +69542,7 @@ function writeRequirementsMap(repoDir, lokiDir2, reqs, ran2) {
69427
69542
  if (!reqs || reqs.length === 0)
69428
69543
  return null;
69429
69544
  const m = mapRequirements(reqs, ran2, currentRevision(repoDir));
69430
- atomicWriteJson(join100(lokiDir2, "state", "requirements-map.json"), m);
69545
+ atomicWriteJson(join101(lokiDir2, "state", "requirements-map.json"), m);
69431
69546
  return m;
69432
69547
  } catch {
69433
69548
  return null;
@@ -69439,20 +69554,20 @@ function writeFromChecklist(repoDir, lokiDir2) {
69439
69554
  }
69440
69555
  function writeFromEngine10(repoDir, lokiDir2, runDir, task, events2) {
69441
69556
  let reqs = null;
69442
- const snap = join100(runDir, "spec.snapshot.md");
69443
- if (existsSync70(snap)) {
69557
+ const snap = join101(runDir, "spec.snapshot.md");
69558
+ if (existsSync71(snap)) {
69444
69559
  try {
69445
- reqs = fromSpecText(readFileSync88(snap, "utf8"));
69560
+ reqs = fromSpecText(readFileSync89(snap, "utf8"));
69446
69561
  } catch {
69447
69562
  reqs = null;
69448
69563
  }
69449
69564
  }
69450
69565
  if (!reqs && task)
69451
69566
  reqs = fromPrdText(task);
69452
- const mapPath = join100(lokiDir2, "state", "requirements-map.json");
69567
+ const mapPath = join101(lokiDir2, "state", "requirements-map.json");
69453
69568
  if (!reqs || reqs.length === 0) {
69454
69569
  try {
69455
- rmSync29(mapPath, { force: true });
69570
+ rmSync30(mapPath, { force: true });
69456
69571
  } catch {}
69457
69572
  return null;
69458
69573
  }
@@ -69465,7 +69580,7 @@ function writeFromEngine10(repoDir, lokiDir2, runDir, task, events2) {
69465
69580
  const m = writeRequirementsMap(repoDir, lokiDir2, reqs, [...last.values()]);
69466
69581
  if (!m) {
69467
69582
  try {
69468
- rmSync29(mapPath, { force: true });
69583
+ rmSync30(mapPath, { force: true });
69469
69584
  } catch {}
69470
69585
  }
69471
69586
  return m;
@@ -69475,7 +69590,7 @@ function uncoveredCount(m) {
69475
69590
  }
69476
69591
  function readRequirementsMap(lokiDir2) {
69477
69592
  try {
69478
- const m = JSON.parse(readFileSync88(join100(lokiDir2, "state", "requirements-map.json"), "utf8"));
69593
+ const m = JSON.parse(readFileSync89(join101(lokiDir2, "state", "requirements-map.json"), "utf8"));
69479
69594
  return m.version === 1 && Array.isArray(m.requirements) ? m : null;
69480
69595
  } catch {
69481
69596
  return null;
@@ -69503,18 +69618,18 @@ var init_contract = __esm(() => {
69503
69618
  BULLET = /^\s*(?:[-*+]|\d+[.)])\s+(.+)$/;
69504
69619
  STOP3 = new Set(["the", "and", "for", "with", "that", "this", "must", "should", "shall", "when", "then", "are", "was", "all", "any", "can", "not", "has", "have", "from", "into", "each", "user", "users"]);
69505
69620
  MAX_CONTRACT_BYTES = 1024 * 1024;
69506
- REQ_MAP_REL = join100(".loki", "state", "requirements-map.json");
69621
+ REQ_MAP_REL = join101(".loki", "state", "requirements-map.json");
69507
69622
  REQ_STOP = new Set(["with", "that", "this", "from", "have", "will", "should", "must", "when", "then", "into", "each", "every", "user", "users", "page", "able", "allow", "support", "ensure", "using", "their", "there", "which", "shall"]);
69508
69623
  LINK_RE = /\s*\[checks?:\s*([^\]]+)\]\s*$/i;
69509
69624
  });
69510
69625
 
69511
69626
  // ../../loki-ts/src/features/speed/seal_group.ts
69512
- import { createHash as createHash28 } from "crypto";
69513
- import { existsSync as existsSync71, mkdirSync as mkdirSync54, readdirSync as readdirSync30, readFileSync as readFileSync89, renameSync as renameSync20, statSync as statSync26, writeFileSync as writeFileSync51 } from "fs";
69514
- import { dirname as dirname42, join as join101 } from "path";
69627
+ import { createHash as createHash29 } from "crypto";
69628
+ import { existsSync as existsSync72, mkdirSync as mkdirSync54, readdirSync as readdirSync30, readFileSync as readFileSync90, renameSync as renameSync20, statSync as statSync26, writeFileSync as writeFileSync52 } from "fs";
69629
+ import { dirname as dirname42, join as join102 } from "path";
69515
69630
  function sealGroup(runDir, rh) {
69516
- const manifestPath = join101(runDir, "group", "manifest.json");
69517
- if (!existsSync71(manifestPath))
69631
+ const manifestPath = join102(runDir, "group", "manifest.json");
69632
+ if (!existsSync72(manifestPath))
69518
69633
  return { section: undefined, notProven: [], problems: 0, allUnitsPass: true };
69519
69634
  const notProven = [];
69520
69635
  let problems = 0;
@@ -69538,10 +69653,10 @@ function sealGroup(runDir, rh) {
69538
69653
  return fail2(`unit ${index2} has an invalid, duplicate or case-colliding id`);
69539
69654
  seen.add(id2);
69540
69655
  seenLower.add(id2.toLowerCase());
69541
- const dir = join101(unitsDir(runDir), id2), rp = join101(dir, "receipt.json"), ep2 = join101(dir, "events.jsonl");
69656
+ const dir = join102(unitsDir(runDir), id2), rp = join102(dir, "receipt.json"), ep2 = join102(dir, "events.jsonl");
69542
69657
  let bytes;
69543
69658
  try {
69544
- bytes = readFileSync89(rp);
69659
+ bytes = readFileSync90(rp);
69545
69660
  } catch {
69546
69661
  return fail2(`unit ${id2} sub-receipt missing`);
69547
69662
  }
@@ -69560,7 +69675,7 @@ function sealGroup(runDir, rh) {
69560
69675
  unit_id: id2,
69561
69676
  sub_receipt_sha256: sha4(bytes),
69562
69677
  receipt_sha256: sub["receipt_sha256"],
69563
- events_file_sha256: existsSync71(ep2) ? sha4(readFileSync89(ep2)) : null,
69678
+ events_file_sha256: existsSync72(ep2) ? sha4(readFileSync90(ep2)) : null,
69564
69679
  verdict,
69565
69680
  goal: text3(u10["goal"], 200),
69566
69681
  files: (Array.isArray(u10["files"]) ? u10["files"] : []).map((f) => text3(f, 200)).filter(Boolean).slice(0, 50),
@@ -69585,7 +69700,7 @@ async function verifyGroup(receiptPath, receipt, rh, verifyOne, deps = {}) {
69585
69700
  const bad = (reason) => ({ verdict: "TAMPERED", reason: `group: ${reason}` });
69586
69701
  const g = receipt["group"];
69587
69702
  if (g === undefined)
69588
- return existsSync71(join101(runDir, "group", "manifest.json")) ? bad("group directory present but the receipt has no group section") : null;
69703
+ return existsSync72(join102(runDir, "group", "manifest.json")) ? bad("group directory present but the receipt has no group section") : null;
69589
69704
  if (!isObj10(g) || !ID_RE.test(String(g["group_id"] ?? "")) || !Array.isArray(g["units"]) || g["units"].length === 0)
69590
69705
  return bad("group section malformed");
69591
69706
  const entries = g["units"];
@@ -69597,20 +69712,20 @@ async function verifyGroup(receiptPath, receipt, rh, verifyOne, deps = {}) {
69597
69712
  return bad("unit directories do not match the receipt (missing or extra unit)");
69598
69713
  let unchecked = null;
69599
69714
  for (let i = 0;i < entries.length; i++) {
69600
- const e10 = entries[i], id2 = ids[i], dir = join101(unitsDir(runDir), id2), rp = join101(dir, "receipt.json"), ep2 = join101(dir, "events.jsonl");
69715
+ const e10 = entries[i], id2 = ids[i], dir = join102(unitsDir(runDir), id2), rp = join102(dir, "receipt.json"), ep2 = join102(dir, "events.jsonl");
69601
69716
  if (e10["index"] !== i)
69602
69717
  return bad(`unit ${id2} is out of order (index ${String(e10["index"])} at position ${i})`);
69603
69718
  let bytes;
69604
69719
  try {
69605
69720
  if (!statSync26(dir).isDirectory())
69606
69721
  return bad(`unit ${id2} is not a directory`);
69607
- bytes = readFileSync89(rp);
69722
+ bytes = readFileSync90(rp);
69608
69723
  } catch {
69609
69724
  return bad(`unit ${id2} sub-receipt missing`);
69610
69725
  }
69611
69726
  if (sha4(bytes) !== e10["sub_receipt_sha256"])
69612
69727
  return bad(`unit ${id2} sub-receipt does not match its recorded hash`);
69613
- const evSha = existsSync71(ep2) ? sha4(readFileSync89(ep2)) : null;
69728
+ const evSha = existsSync72(ep2) ? sha4(readFileSync90(ep2)) : null;
69614
69729
  if (evSha !== (e10["events_file_sha256"] ?? null))
69615
69730
  return bad(`unit ${id2} events.jsonl does not match its recorded hash`);
69616
69731
  const sub = readJson7(rp);
@@ -69639,9 +69754,9 @@ function composeGroupReceipt(groupDir, rh, o) {
69639
69754
  const body = { schema: GROUP_SCHEMA, run_id: gid, verdict, base_sha: o.baseRef, head_sha: o.head, not_proven: seal.notProven, group: seal.section };
69640
69755
  const hash = rh(body), sig = signReceipt(gid, hash);
69641
69756
  const receipt = { ...body, receipt_sha256: hash, verification: { jwt: sig.jwt, kid: sig.kid } };
69642
- const path = join101(groupDir, "receipt.json"), tmp = `${path}.${process.pid}.tmp`;
69757
+ const path = join102(groupDir, "receipt.json"), tmp = `${path}.${process.pid}.tmp`;
69643
69758
  mkdirSync54(groupDir, { recursive: true });
69644
- writeFileSync51(tmp, JSON.stringify(receipt, null, 2) + `
69759
+ writeFileSync52(tmp, JSON.stringify(receipt, null, 2) + `
69645
69760
  `);
69646
69761
  renameSync20(tmp, path);
69647
69762
  return { path, receipt };
@@ -69651,9 +69766,9 @@ function compositeVerdict(childVerdicts) {
69651
69766
  const failed2 = childVerdicts.filter((v3) => v3 === "FAILED" || !["VERIFIED", "ALREADY_SATISFIED", "PARTIAL", "SPEC_CONFLICT"].includes(v3)).length;
69652
69767
  return capGroupVerdict(base, { section: undefined, notProven: [], problems: failed2, allUnitsPass: childVerdicts.every((v3) => PASSING.has(v3)) });
69653
69768
  }
69654
- var ID_RE, PASSING, sha4 = (b) => createHash28("sha256").update(b).digest("hex"), isObj10 = (v3) => v3 !== null && typeof v3 === "object" && !Array.isArray(v3), text3 = (v3, cap) => typeof v3 === "string" ? v3.replace(/[\x00-\x1f\x7f]+/g, " ").trim().slice(0, cap) : "", num4 = (v3) => typeof v3 === "number" && Number.isFinite(v3) && v3 >= 0 ? v3 : 0, unitsDir = (runDir) => join101(runDir, "group", "units"), readJson7 = (p) => {
69769
+ var ID_RE, PASSING, sha4 = (b) => createHash29("sha256").update(b).digest("hex"), isObj10 = (v3) => v3 !== null && typeof v3 === "object" && !Array.isArray(v3), text3 = (v3, cap) => typeof v3 === "string" ? v3.replace(/[\x00-\x1f\x7f]+/g, " ").trim().slice(0, cap) : "", num4 = (v3) => typeof v3 === "number" && Number.isFinite(v3) && v3 >= 0 ? v3 : 0, unitsDir = (runDir) => join102(runDir, "group", "units"), readJson7 = (p) => {
69655
69770
  try {
69656
- return JSON.parse(readFileSync89(p, "utf8"));
69771
+ return JSON.parse(readFileSync90(p, "utf8"));
69657
69772
  } catch {
69658
69773
  return;
69659
69774
  }
@@ -69671,8 +69786,8 @@ var init_seal_group = __esm(() => {
69671
69786
  });
69672
69787
 
69673
69788
  // ../../loki-ts/src/supply/supply_guard.ts
69674
- import { existsSync as existsSync72, readFileSync as readFileSync90, statSync as statSync27 } from "fs";
69675
- import { basename as basename26, join as join102 } from "path";
69789
+ import { existsSync as existsSync73, readFileSync as readFileSync91, statSync as statSync27 } from "fs";
69790
+ import { basename as basename27, join as join103 } from "path";
69676
69791
  function supplyEnabled(env) {
69677
69792
  return env["LOKI_SUPPLY_GUARD"] !== "0";
69678
69793
  }
@@ -69684,16 +69799,16 @@ function supplyVerdict(verdict, r) {
69684
69799
  return r.blocked && verdict === "VERIFIED" ? "FAILED" : verdict;
69685
69800
  }
69686
69801
  function isManifestPath(path) {
69687
- return MANIFESTS2.test(basename26(path));
69802
+ return MANIFESTS2.test(basename27(path));
69688
69803
  }
69689
69804
  function readDeclared(repoDir) {
69690
- const p = join102(repoDir, ".loki", DECLARED_FILE);
69691
- if (!existsSync72(p))
69805
+ const p = join103(repoDir, ".loki", DECLARED_FILE);
69806
+ if (!existsSync73(p))
69692
69807
  return { deps: [], problem: null };
69693
69808
  try {
69694
69809
  if (statSync27(p).size > MAX_FILE_BYTES)
69695
69810
  return { deps: [], problem: "declaration file too large" };
69696
- const j10 = JSON.parse(readFileSync90(p, "utf8"));
69811
+ const j10 = JSON.parse(readFileSync91(p, "utf8"));
69697
69812
  if (!Array.isArray(j10))
69698
69813
  return { deps: [], problem: "declaration is not a JSON array" };
69699
69814
  const deps = [];
@@ -69713,11 +69828,11 @@ function readDeclared(repoDir) {
69713
69828
  }
69714
69829
  }
69715
69830
  function readAllowlist(repoDir) {
69716
- const p = join102(repoDir, ".loki", "supply-allowlist");
69717
- if (!existsSync72(p))
69831
+ const p = join103(repoDir, ".loki", "supply-allowlist");
69832
+ if (!existsSync73(p))
69718
69833
  return new Set;
69719
69834
  try {
69720
- return new Set(readFileSync90(p, "utf8").split(`
69835
+ return new Set(readFileSync91(p, "utf8").split(`
69721
69836
  `).map((l) => l.replace(/#.*$/, "").trim()).filter(Boolean));
69722
69837
  } catch {
69723
69838
  return new Set;
@@ -69758,7 +69873,7 @@ function userConfigPrivate(eco, repoDir, env, goEnv = {}, name = "") {
69758
69873
  if (eco === "npm") {
69759
69874
  if (privateUrlList([env["npm_config_registry"] ?? "", env["NPM_CONFIG_REGISTRY"] ?? ""]))
69760
69875
  return true;
69761
- return files(join102(repoDir, ".npmrc"), home ? join102(home, ".npmrc") : "").some((t) => t.split(`
69876
+ return files(join103(repoDir, ".npmrc"), home ? join103(home, ".npmrc") : "").some((t) => t.split(`
69762
69877
  `).some((l) => {
69763
69878
  const m = /^\s*(?:(@[^:\s]+):)?registry\s*=\s*(\S+)/.exec(l);
69764
69879
  return !!m && privateUrl(m[2]) && (m[1] === undefined || name.startsWith(`${m[1]}/`));
@@ -69767,7 +69882,7 @@ function userConfigPrivate(eco, repoDir, env, goEnv = {}, name = "") {
69767
69882
  if (eco === "pypi") {
69768
69883
  if (privateUrlList([env["PIP_INDEX_URL"] ?? "", env["PIP_EXTRA_INDEX_URL"] ?? ""]))
69769
69884
  return true;
69770
- const cfg = [env["PIP_CONFIG_FILE"] ?? "", home ? join102(home, ".config", "pip", "pip.conf") : "", home ? join102(home, ".pip", "pip.conf") : "", join102(repoDir, "pip.conf")];
69885
+ const cfg = [env["PIP_CONFIG_FILE"] ?? "", home ? join103(home, ".config", "pip", "pip.conf") : "", home ? join103(home, ".pip", "pip.conf") : "", join103(repoDir, "pip.conf")];
69771
69886
  return files(...cfg).some((t) => t.split(`
69772
69887
  `).some((l) => {
69773
69888
  const m = /^\s*(?:extra-)?index-url\s*[=:]\s*(.+)$/.exec(l);
@@ -69777,7 +69892,7 @@ function userConfigPrivate(eco, repoDir, env, goEnv = {}, name = "") {
69777
69892
  if (eco === "cargo") {
69778
69893
  if (Object.keys(env).some((k3) => /^CARGO_REGISTRIES_.+_INDEX$/.test(k3) || /^CARGO_SOURCE_/.test(k3)))
69779
69894
  return true;
69780
- return files(join102(repoDir, ".cargo", "config.toml"), join102(repoDir, ".cargo", "config"), home ? join102(home, ".cargo", "config.toml") : "", home ? join102(home, ".cargo", "config") : "").some((t) => /^\s*\[(registries\.|source\.)/m.test(t) || /replace-with\s*=/.test(t));
69895
+ return files(join103(repoDir, ".cargo", "config.toml"), join103(repoDir, ".cargo", "config"), home ? join103(home, ".cargo", "config.toml") : "", home ? join103(home, ".cargo", "config") : "").some((t) => /^\s*\[(registries\.|source\.)/m.test(t) || /replace-with\s*=/.test(t));
69781
69896
  }
69782
69897
  if (eco === "go") {
69783
69898
  const gp2 = goEnv["GOPROXY"] ?? env["GOPROXY"] ?? "";
@@ -69900,7 +70015,7 @@ var MIN_AGE_DAYS = 7, DECLARED_FILE = "supply-declared.json", MAX_CHECKED = 50,
69900
70015
  }
69901
70016
  }, PUBLIC_HOSTS, hostOf = (u10) => u10.trim().toLowerCase().replace(/^[a-z][a-z0-9+.-]*:\/\//, "").replace(/^www\./, "").split(/[/?#\s]/)[0].replace(/^[^@]*@/, "").replace(/:\d+$/, ""), privateUrl = (u10) => /[a-z0-9]/i.test(u10) && !PUBLIC_HOSTS.has(hostOf(u10)), readSmall = (p) => {
69902
70017
  try {
69903
- return statSync27(p).size <= MAX_FILE_BYTES ? readFileSync90(p, "utf8") : "";
70018
+ return statSync27(p).size <= MAX_FILE_BYTES ? readFileSync91(p, "utf8") : "";
69904
70019
  } catch {
69905
70020
  return "";
69906
70021
  }
@@ -69938,9 +70053,9 @@ __export(exports_seal, {
69938
70053
  EXTERNAL_DIFF_NOT_ISOLATED: () => EXTERNAL_DIFF_NOT_ISOLATED,
69939
70054
  AGENT_ONLY_REASON: () => AGENT_ONLY_REASON
69940
70055
  });
69941
- import { createHash as createHash29 } from "crypto";
69942
- import { existsSync as existsSync73, readdirSync as readdirSync31, mkdirSync as mkdirSync55, readFileSync as readFileSync91 } from "fs";
69943
- import { basename as basename27, isAbsolute as isAbsolute20, join as join103, relative as relative23 } from "path";
70056
+ import { createHash as createHash30 } from "crypto";
70057
+ import { existsSync as existsSync74, readdirSync as readdirSync31, mkdirSync as mkdirSync55, readFileSync as readFileSync92 } from "fs";
70058
+ import { basename as basename28, isAbsolute as isAbsolute20, join as join104, relative as relative24 } from "path";
69944
70059
  async function leanSymbolGap(ctx, o, rawDiff, head, vraw) {
69945
70060
  if (externalRun(o) || Array.isArray(o.wall?.files) && o.wall.files.length > 0 || o.intake?.already_satisfied === true || o.implement?.exit === "already_done")
69946
70061
  return [];
@@ -69961,7 +70076,7 @@ async function leanSymbolGap(ctx, o, rawDiff, head, vraw) {
69961
70076
  const n11 = String(c.name ?? ""), p = n11.slice(n11.indexOf(":") + 1);
69962
70077
  if (n11.includes(":") && isTestFile(p))
69963
70078
  try {
69964
- sources2.push(readFileSync91(join103(ctx.repoDir, p), "utf8"));
70079
+ sources2.push(readFileSync92(join104(ctx.repoDir, p), "utf8"));
69965
70080
  } catch {}
69966
70081
  }
69967
70082
  return symbolGap(changedSymbols(d.stdout), sources2);
@@ -69975,7 +70090,7 @@ async function git9(ctx, args, keep = {}) {
69975
70090
  return { out: r.stdout, code: r.exitCode };
69976
70091
  }
69977
70092
  function verdictOf2(o, checks, emptyDiff, verifyNotProven, wallGreenOnBase, proof, targetProof = false, uncovered = [], leanGap = []) {
69978
- const exit = o.implement?.exit;
70093
+ const exit = o.implement?.exit, wd2 = wallDropped(o).length > 0;
69979
70094
  if (o.commit?.failed !== true && strs2(o.commit?.not_proven).length === 0 && (o.intake?.already_satisfied === true || exit === "already_done"))
69980
70095
  return proof || wallGreenOnBase ? "ALREADY_SATISFIED" : "PARTIAL";
69981
70096
  if (exit === "spec_conflict")
@@ -69985,7 +70100,7 @@ function verdictOf2(o, checks, emptyDiff, verifyNotProven, wallGreenOnBase, proo
69985
70100
  if (emptyDiff)
69986
70101
  return "FAILED";
69987
70102
  if (exit === "killed")
69988
- return typeof o.implement?.limit_s === "number" && targetProof && uncovered.length === 0 && proof && !wallGreenOnBase && !verifyNotProven && checks.length > 0 && checks.every((c) => c.result === "pass") ? "VERIFIED" : "PARTIAL";
70103
+ return typeof o.implement?.limit_s === "number" && targetProof && uncovered.length === 0 && proof && !wallGreenOnBase && !verifyNotProven && !wd2 && checks.length > 0 && checks.every((c) => c.result === "pass") ? "VERIFIED" : "PARTIAL";
69989
70104
  if (typeof o.implement?.limit_s === "number")
69990
70105
  return "PARTIAL";
69991
70106
  if (checks.some((c) => c.result === "fail"))
@@ -69994,7 +70109,7 @@ function verdictOf2(o, checks, emptyDiff, verifyNotProven, wallGreenOnBase, proo
69994
70109
  return "PARTIAL";
69995
70110
  if (leanGap.length > 0)
69996
70111
  return "PARTIAL";
69997
- if (exit === "killed" || checks.length === 0 || checks.some((c) => c.result !== "pass") || verifyNotProven || !proof || wallGreenOnBase)
70112
+ if (wd2 || exit === "killed" || checks.length === 0 || checks.some((c) => c.result !== "pass") || verifyNotProven || !proof || wallGreenOnBase)
69998
70113
  return "PARTIAL";
69999
70114
  return "VERIFIED";
70000
70115
  }
@@ -70043,14 +70158,15 @@ function renderReceiptMd(r) {
70043
70158
  ].join(`
70044
70159
  `);
70045
70160
  }
70046
- var SIGNING_UNAVAILABLE = "receipt signing unavailable (no usable signing key: invalid key or unwritable ~/.loki/keys)", AGENT_ONLY_REASON = "only agent-authored tests executed (no agent-independent proof)", WALL_GREEN_ON_BASE_REASON = "Wall green on base: no Wall test discriminates the change", EXCLUDE_LOKI = ":(exclude).loki", sha2562 = (s) => createHash29("sha256").update(s).digest("hex"), str3 = (v3) => typeof v3 === "string" && v3 !== "" ? v3 : null, EXTERNAL_MODEL_LABEL = "external (no Loki implement session)", EXTERNAL_DIFF_NOT_ISOLATED = "Wall author not filesystem-isolated from the external diff", EXTERNAL_NO_WALL = "external diff sealed with no Wall file that ran; the only checks are the repo's existing tests", externalRun = (o) => o.implement?.exit === "external", LEAN_NO_SYMBOL = "no passing check references a changed symbol and no Wall file ran", strs2 = (v3) => Array.isArray(v3) ? v3.filter((x3) => typeof x3 === "string" && x3 !== "") : [], g = (ctx) => (a) => git9(ctx, a), receiptRel = (ctx) => {
70047
- const r = relative23(ctx.repoDir, join103(ctx.runDir, "receipt.json"));
70161
+ var SIGNING_UNAVAILABLE = "receipt signing unavailable (no usable signing key: invalid key or unwritable ~/.loki/keys)", AGENT_ONLY_REASON = "only agent-authored tests executed (no agent-independent proof)", WALL_GREEN_ON_BASE_REASON = "Wall green on base: no Wall test discriminates the change", EXCLUDE_LOKI = ":(exclude).loki", sha2562 = (s) => createHash30("sha256").update(s).digest("hex"), str3 = (v3) => typeof v3 === "string" && v3 !== "" ? v3 : null, EXTERNAL_MODEL_LABEL = "external (no Loki implement session)", EXTERNAL_DIFF_NOT_ISOLATED = "Wall author not filesystem-isolated from the external diff", EXTERNAL_NO_WALL = "external diff sealed with no Wall file that ran; the only checks are the repo's existing tests", externalRun = (o) => o.implement?.exit === "external", LEAN_NO_SYMBOL = "no passing check references a changed symbol and no Wall file ran", strs2 = (v3) => Array.isArray(v3) ? v3.filter((x3) => typeof x3 === "string" && x3 !== "") : [], g = (ctx) => (a) => git9(ctx, a), receiptRel = (ctx) => {
70162
+ const r = relative24(ctx.repoDir, join104(ctx.runDir, "receipt.json"));
70048
70163
  return r.startsWith("..") || isAbsolute20(r) ? `.loki/runs/${ctx.runId}/receipt.json` : r;
70049
70164
  }, commitStage, wallGreenOnBaseOf = (o) => {
70050
70165
  const b = o.wall?.base_run ?? {};
70051
70166
  return typeof b.pass === "number" && b.pass > 0 && b.fail === 0 && (typeof b.not_run === "number" ? b.not_run : 0) === 0;
70052
70167
  }, sealStage, stage7;
70053
70168
  var init_seal = __esm(() => {
70169
+ init_wall_owned();
70054
70170
  init_redact();
70055
70171
  init_spec_file();
70056
70172
  init_steer();
@@ -70174,7 +70290,7 @@ var init_seal = __esm(() => {
70174
70290
  }
70175
70291
  if (wallNotRun > 0)
70176
70292
  notProven.add(`wall base run not_run: ${wallNotRun}`);
70177
- for (const n11 of strs2(o.wall?.not_proven))
70293
+ for (const n11 of [...strs2(o.wall?.not_proven), ...wallDropped(o)])
70178
70294
  notProven.add(n11);
70179
70295
  for (const d of Array.isArray(o.wall?.discarded) ? o.wall.discarded : [])
70180
70296
  notProven.add(`wall test discarded: ${String(d.file)} (${String(d.reason)})`);
@@ -70184,8 +70300,8 @@ var init_seal = __esm(() => {
70184
70300
  notProven.add(`Wall test not executed: ${wallNotRun} file(s), no reason recorded`);
70185
70301
  if (wallNotRun > 0) {
70186
70302
  try {
70187
- const kept = new Set((Array.isArray(o.wall?.files) ? o.wall.files : []).map((f) => basename27(String(f.path))));
70188
- for (const n11 of readdirSync31(join103(ctx.runDir, "wall")).sort())
70303
+ const kept = new Set((Array.isArray(o.wall?.files) ? o.wall.files : []).map((f) => basename28(String(f.path))));
70304
+ for (const n11 of readdirSync31(join104(ctx.runDir, "wall")).sort())
70189
70305
  if (!kept.has(n11))
70190
70306
  notProven.add(`wall test discarded: ${n11} (not_run)`);
70191
70307
  } catch {}
@@ -70256,19 +70372,19 @@ var init_seal = __esm(() => {
70256
70372
  for (const [s, d] of Object.entries(o))
70257
70373
  if (typeof d?.duration_s === "number")
70258
70374
  stages[s] = d.duration_s;
70259
- const T = hooks.time, time = T ? T.build(ctx, stages, T.firstEventMs(join103(ctx.runDir, "events.jsonl"))) : { wall_s: Object.values(stages).reduce((a, b) => a + (b ?? 0), 0), stages }, totalS = T?.reconciled(time) ?? null;
70375
+ const T = hooks.time, time = T ? T.build(ctx, stages, T.firstEventMs(join104(ctx.runDir, "events.jsonl"))) : { wall_s: Object.values(stages).reduce((a, b) => a + (b ?? 0), 0), stages }, totalS = T?.reconciled(time) ?? null;
70260
70376
  const iterIds = [...new Set([...Object.values(o).flatMap((d) => [...strs2(d?.iteration_ids), ...strs2([d?.iteration_id])]), ...ctx.sessionIds?.() ?? [], ...xr2?.cost_iteration ? [xr2.cost_iteration] : []])];
70261
70377
  if (iterIds.length === 0)
70262
70378
  notProven.add("cost not measured (no iteration ids recorded)");
70263
70379
  const cost = ctx.cost.read(ctx.repoDir, iterIds);
70264
70380
  if (cost.unmetered)
70265
70381
  notProven.add("cost unmetered (CLI invoker; recorded as 0)");
70266
- const eventsPath = join103(ctx.runDir, "events.jsonl");
70382
+ const eventsPath = join104(ctx.runDir, "events.jsonl");
70267
70383
  const wallFiles = Array.isArray(o.wall?.files) ? o.wall.files : [];
70268
70384
  const wallPassed = typeof o.verify?.wall_passed === "boolean" ? o.verify.wall_passed : null;
70269
70385
  if (wallFiles.length > 0 && wallPassed === null)
70270
70386
  notProven.add("wall result not recorded by verify");
70271
- const routeBlock = buildRouteBlock(process.env, ctx.provider, o.implement?.route ?? o.plan?.route_record ?? (routerEnabled(process.env) ? loadRouteRecord(ctx.runDir) : undefined), cost.router ?? (routerEnabled(process.env) ? sumResultCosts(join103(ctx.repoDir, ".loki"), liveArchivedCosts(join103(ctx.repoDir, ".loki"), iterIds, UNMETERED)).router : undefined), ctx.model);
70387
+ const routeBlock = buildRouteBlock(process.env, ctx.provider, o.implement?.route ?? o.plan?.route_record ?? (routerEnabled(process.env) ? loadRouteRecord(ctx.runDir) : undefined), cost.router ?? (routerEnabled(process.env) ? sumResultCosts(join104(ctx.repoDir, ".loki"), liveArchivedCosts(join104(ctx.repoDir, ".loki"), iterIds, UNMETERED)).router : undefined), ctx.model);
70272
70388
  if (routeBlock)
70273
70389
  for (const l of routeNotProven(routeBlock))
70274
70390
  notProven.add(l);
@@ -70311,7 +70427,7 @@ var init_seal = __esm(() => {
70311
70427
  model: externalRun(o) ? EXTERNAL_MODEL_LABEL : ctx.model,
70312
70428
  ...externalRun(o) ? { implement: { exit: "external", patch_sha256: str3(o.implement?.patch_sha256) ?? "" } } : {},
70313
70429
  resumed: o.intake?.resumed === true,
70314
- events_sha256: sha2562(existsSync73(eventsPath) ? readFileSync91(eventsPath) : ""),
70430
+ events_sha256: sha2562(existsSync74(eventsPath) ? readFileSync92(eventsPath) : ""),
70315
70431
  ...await sealEvidence(ctx.repoDir, ctx.runDir, o, notProven, signal, ctx.emit),
70316
70432
  log_seal: true,
70317
70433
  toolchain: collectToolchain(),
@@ -70339,10 +70455,10 @@ var init_seal = __esm(() => {
70339
70455
  }
70340
70456
  const receipt = { ...body, receipt_sha256: hash, verification: { jwt: sig.jwt, kid: sig.kid } };
70341
70457
  mkdirSync55(ctx.runDir, { recursive: true });
70342
- const path = join103(ctx.runDir, "receipt.json");
70458
+ const path = join104(ctx.runDir, "receipt.json");
70343
70459
  atomicWriteText(path, JSON.stringify(receipt, null, 2) + `
70344
70460
  `);
70345
- atomicWriteText(join103(ctx.runDir, "receipt.md"), renderReceiptMd(receipt));
70461
+ atomicWriteText(join104(ctx.runDir, "receipt.md"), renderReceiptMd(receipt));
70346
70462
  recordRun(process.env, ctx.repoDir, ranModel(o.implement, ctx.model, o.fix), verdict, cost.usd, cost.unmetered === true, totalS);
70347
70463
  try {
70348
70464
  hooks.sealed?.(ctx.runDir, JSON.parse(JSON.stringify(receipt), (_k2, v3) => v3 && typeof v3 === "object" ? Object.freeze(v3) : v3));
@@ -70415,8 +70531,8 @@ var init_github_token = __esm(() => {
70415
70531
 
70416
70532
  // ../../loki-ts/src/engine10/fetch_issue.ts
70417
70533
  import { execFileSync as execFileSync7 } from "child_process";
70418
- import { writeFileSync as writeFileSync53 } from "fs";
70419
- import { join as join104 } from "path";
70534
+ import { writeFileSync as writeFileSync54 } from "fs";
70535
+ import { join as join105 } from "path";
70420
70536
  function defaultExec(cmd, args) {
70421
70537
  const ms = Number(process.env.LOKI_FETCH_ISSUE_TIMEOUT_MS) || 60000;
70422
70538
  return execFileSync7(cmd, args, { encoding: "utf8", env: process.env, timeout: ms, killSignal: "SIGKILL" });
@@ -70437,18 +70553,18 @@ function fetchIssue(ref, execer = defaultExec) {
70437
70553
  }
70438
70554
  function fetchIssueToFile(ref, outFile, exec = defaultExec) {
70439
70555
  const issue = fetchIssue(ref, exec);
70440
- writeFileSync53(outFile, JSON.stringify(issue));
70556
+ writeFileSync54(outFile, JSON.stringify(issue));
70441
70557
  return issue;
70442
70558
  }
70443
70559
  var ISSUE_PROVIDERS_SH;
70444
70560
  var init_fetch_issue = __esm(() => {
70445
70561
  init_paths();
70446
- ISSUE_PROVIDERS_SH = join104(REPO_ROOT, "autonomy/issue-providers.sh");
70562
+ ISSUE_PROVIDERS_SH = join105(REPO_ROOT, "autonomy/issue-providers.sh");
70447
70563
  if (false) {}
70448
70564
  });
70449
70565
 
70450
70566
  // ../../loki-ts/src/features/tracker_intake.ts
70451
- import { writeFileSync as writeFileSync54 } from "fs";
70567
+ import { writeFileSync as writeFileSync55 } from "fs";
70452
70568
  function selfHostedSite(s, env) {
70453
70569
  const base = env.JIRA_BASE_URL;
70454
70570
  const m = SELF_URL.exec(s);
@@ -70595,7 +70711,7 @@ async function fetchTrackerIssue(ref, f = fetch, env = process.env) {
70595
70711
  }
70596
70712
  async function fetchTrackerIssueToFile(ref, outFile, f = fetch, env = process.env) {
70597
70713
  const issue = await fetchTrackerIssue(ref, f, env);
70598
- writeFileSync54(outFile, JSON.stringify(issue));
70714
+ writeFileSync55(outFile, JSON.stringify(issue));
70599
70715
  return issue;
70600
70716
  }
70601
70717
  var JIRA_KEY = "[A-Z][A-Z0-9_]*-\\d+", JIRA_REF, JIRA_URL, LINEAR_REF, LINEAR_URL, SELF_URL;
@@ -70990,14 +71106,14 @@ var init_capability = __esm(() => {
70990
71106
  var init_raster = () => {};
70991
71107
 
70992
71108
  // ../../loki-ts/src/commands/doctor.ts
70993
- import { appendFileSync as appendFileSync11, writeFileSync as writeFileSync55, mkdirSync as mkdirSync56, accessSync as accessSync2, constants as fsConstants2, existsSync as existsSync74, lstatSync as lstatSync26, readdirSync as readdirSync32, readFileSync as readFileSync92, readlinkSync as readlinkSync6, realpathSync as realpathSync31, statSync as statSync29, statfsSync } from "fs";
71109
+ import { appendFileSync as appendFileSync11, writeFileSync as writeFileSync56, mkdirSync as mkdirSync56, accessSync as accessSync2, constants as fsConstants2, existsSync as existsSync75, lstatSync as lstatSync26, readdirSync as readdirSync32, readFileSync as readFileSync93, readlinkSync as readlinkSync6, realpathSync as realpathSync31, statSync as statSync29, statfsSync } from "fs";
70994
71110
  import { spawnSync as spawnSync12 } from "child_process";
70995
- import { homedir as homedir12, tmpdir as tmpdir17 } from "os";
70996
- import { join as join105, resolve as resolve31 } from "path";
71111
+ import { homedir as homedir12, tmpdir as tmpdir18 } from "os";
71112
+ import { join as join106, resolve as resolve31 } from "path";
70997
71113
  function loadRequirements(file = REQUIREMENTS_FILE) {
70998
71114
  if (file === REQUIREMENTS_FILE && cached)
70999
71115
  return cached;
71000
- const t = JSON.parse(readFileSync92(file, "utf8"));
71116
+ const t = JSON.parse(readFileSync93(file, "utf8"));
71001
71117
  if (file === REQUIREMENTS_FILE)
71002
71118
  cached = t;
71003
71119
  return t;
@@ -71022,13 +71138,13 @@ function providerLoginIssue(provider, cli, env) {
71022
71138
  if (provider === "codex") {
71023
71139
  if (key("OPENAI_API_KEY") || key("CODEX_API_KEY"))
71024
71140
  return null;
71025
- const r = spawnSync12(cli, ["login", "status"], { env: providerProbeEnv(env), encoding: "utf8", timeout: 5000, cwd: tmpdir17() });
71141
+ const r = spawnSync12(cli, ["login", "status"], { env: providerProbeEnv(env), encoding: "utf8", timeout: 5000, cwd: tmpdir18() });
71026
71142
  if (r.status === 0)
71027
71143
  return null;
71028
71144
  const said = `${r.stdout}${r.stderr}`;
71029
71145
  return /not logged in/i.test(said) || classifyFailure(said).reason === "auth" ? { fatal: "codex is not logged in; run: codex login (or set OPENAI_API_KEY)" } : { warn: "could not confirm the Codex login (codex login status gave no answer); continuing" };
71030
71146
  }
71031
- if (PROVIDER_API_KEY_VARS.some(key) || provider === "opencode" && existsSync74(join105(env.XDG_DATA_HOME || join105(home, ".local", "share"), "opencode", "auth.json")) || provider === "cline" && existsSync74(join105(home, ".cline")))
71147
+ if (PROVIDER_API_KEY_VARS.some(key) || provider === "opencode" && existsSync75(join106(env.XDG_DATA_HOME || join106(home, ".local", "share"), "opencode", "auth.json")) || provider === "cline" && existsSync75(join106(home, ".cline")))
71032
71148
  return null;
71033
71149
  return provider === "aider" || provider === "opencode" || provider === "cline" ? { warn: `no ${provider} login or API key found (set a provider API key such as ANTHROPIC_API_KEY or OPENAI_API_KEY${provider === "opencode" ? ", or run: opencode auth login" : ""}); continuing` } : null;
71034
71150
  }
@@ -71039,9 +71155,9 @@ function providerAuthPath(provider, env) {
71039
71155
  const v3 = own.find(set);
71040
71156
  if (v3)
71041
71157
  return `${v3 === "CLAUDE_CODE_OAUTH_TOKEN" ? "oauth_token" : "api_key"}:${v3}`;
71042
- if (provider === "opencode" && existsSync74(join105(env.XDG_DATA_HOME || join105(home, ".local", "share"), "opencode", "auth.json")))
71158
+ if (provider === "opencode" && existsSync75(join106(env.XDG_DATA_HOME || join106(home, ".local", "share"), "opencode", "auth.json")))
71043
71159
  return "cli_login:opencode";
71044
- if (provider === "cline" && existsSync74(join105(home, ".cline")))
71160
+ if (provider === "cline" && existsSync75(join106(home, ".cline")))
71045
71161
  return "cli_login:cline";
71046
71162
  return provider === "claude" || provider === "codex" ? `cli_login:${provider}` : "none";
71047
71163
  }
@@ -71066,9 +71182,9 @@ function claudeAuthStatusLoggedIn(cli = "claude", env = process.env) {
71066
71182
  }
71067
71183
  }
71068
71184
  function claudeLoginProbeCached(cli, env = process.env, now2 = Date.now()) {
71069
- const file = join105(env.HOME || homedir12(), ".loki", "claude-login-ok.json");
71185
+ const file = join106(env.HOME || homedir12(), ".loki", "claude-login-ok.json");
71070
71186
  try {
71071
- const c = JSON.parse(readFileSync92(file, "utf8"));
71187
+ const c = JSON.parse(readFileSync93(file, "utf8"));
71072
71188
  if (c?.cli === cli && typeof c.at === "number" && now2 - c.at >= 0 && now2 - c.at < CLAUDE_LOGIN_TTL_MS)
71073
71189
  return "yes";
71074
71190
  } catch {}
@@ -71077,8 +71193,8 @@ function claudeLoginProbeCached(cli, env = process.env, now2 = Date.now()) {
71077
71193
  li2 = claudeAuthStatusLoggedIn(cli, env);
71078
71194
  if (li2 === "yes") {
71079
71195
  try {
71080
- mkdirSync56(join105(file, ".."), { recursive: true });
71081
- writeFileSync55(file, JSON.stringify({ cli, at: now2 }));
71196
+ mkdirSync56(join106(file, ".."), { recursive: true });
71197
+ writeFileSync56(file, JSON.stringify({ cli, at: now2 }));
71082
71198
  } catch {}
71083
71199
  }
71084
71200
  return li2;
@@ -71086,17 +71202,17 @@ function claudeLoginProbeCached(cli, env = process.env, now2 = Date.now()) {
71086
71202
  async function ghAuthProbeCached(env, probe, now2 = Date.now()) {
71087
71203
  const bin = "gh";
71088
71204
  const gh = Bun.which(bin, { PATH: env.PATH ?? process.env.PATH ?? "" }) ?? bin;
71089
- const file = join105(env.HOME || homedir12(), ".loki", "gh-auth-ok.json");
71205
+ const file = join106(env.HOME || homedir12(), ".loki", "gh-auth-ok.json");
71090
71206
  try {
71091
- const c = JSON.parse(readFileSync92(file, "utf8"));
71207
+ const c = JSON.parse(readFileSync93(file, "utf8"));
71092
71208
  if (c?.gh === gh && typeof c.at === "number" && now2 - c.at >= 0 && now2 - c.at < CLAUDE_LOGIN_TTL_MS)
71093
71209
  return true;
71094
71210
  } catch {}
71095
71211
  const ok3 = await probe();
71096
71212
  if (ok3) {
71097
71213
  try {
71098
- mkdirSync56(join105(file, ".."), { recursive: true });
71099
- writeFileSync55(file, JSON.stringify({ gh, at: now2 }));
71214
+ mkdirSync56(join106(file, ".."), { recursive: true });
71215
+ writeFileSync56(file, JSON.stringify({ gh, at: now2 }));
71100
71216
  } catch {}
71101
71217
  }
71102
71218
  return ok3;
@@ -71169,8 +71285,8 @@ var init_first_run_repo = __esm(() => {
71169
71285
  });
71170
71286
 
71171
71287
  // ../../loki-ts/src/engine10/preflight.ts
71172
- import { accessSync as accessSync3, constants as fsc2, mkdirSync as mkdirSync57, statfsSync as statfsSync2, writeFileSync as writeFileSync56 } from "fs";
71173
- import { join as join106 } from "path";
71288
+ import { accessSync as accessSync3, constants as fsc2, mkdirSync as mkdirSync57, statfsSync as statfsSync2, writeFileSync as writeFileSync57 } from "fs";
71289
+ import { join as join107 } from "path";
71174
71290
  async function sh3(argv, opts) {
71175
71291
  try {
71176
71292
  return await run(argv, opts);
@@ -71254,7 +71370,7 @@ async function checkPreflight(o) {
71254
71370
  if (o.runDir) {
71255
71371
  try {
71256
71372
  mkdirSync57(o.runDir, { recursive: true });
71257
- writeFileSync56(join106(o.runDir, "preflight.json"), JSON.stringify({ provider: o.provider, auth_path, probe }) + `
71373
+ writeFileSync57(join107(o.runDir, "preflight.json"), JSON.stringify({ provider: o.provider, auth_path, probe }) + `
71258
71374
  `);
71259
71375
  } catch {}
71260
71376
  }
@@ -71919,10 +72035,10 @@ __export(exports_run_group, {
71919
72035
  groupCostLine: () => groupCostLine,
71920
72036
  NOT_PROVEN: () => NOT_PROVEN
71921
72037
  });
71922
- import { cpSync as cpSync2, existsSync as existsSync75, mkdirSync as mkdirSync58, readdirSync as readdirSync34, readFileSync as readFileSync93, rmSync as rmSync31, statSync as statSync30 } from "fs";
71923
- import { createHash as createHash30 } from "crypto";
72038
+ import { cpSync as cpSync2, existsSync as existsSync76, mkdirSync as mkdirSync58, readdirSync as readdirSync34, readFileSync as readFileSync94, rmSync as rmSync32, statSync as statSync30 } from "fs";
72039
+ import { createHash as createHash31 } from "crypto";
71924
72040
  import { spawn as spawn12 } from "child_process";
71925
- import { join as join107, resolve as resolve32 } from "path";
72041
+ import { join as join108, resolve as resolve32 } from "path";
71926
72042
  function scopedEnv(env) {
71927
72043
  const out3 = {};
71928
72044
  for (const [k3, v3] of Object.entries(env))
@@ -71959,7 +72075,7 @@ function groupCostLine(costs, provider = "claude") {
71959
72075
  `;
71960
72076
  }
71961
72077
  function writeGroupCostRecord(repoDir, name, costs, provider) {
71962
- const dir = join107(repoDir, ".loki", "metrics", "efficiency");
72078
+ const dir = join108(repoDir, ".loki", "metrics", "efficiency");
71963
72079
  const timestamp = new Date().toISOString();
71964
72080
  try {
71965
72081
  const base = { phase: "implement", provider, status: "group", kind: "group_cost", timestamp };
@@ -71973,7 +72089,7 @@ function writeGroupCostRecord(repoDir, name, costs, provider) {
71973
72089
  if (recs.length === 0)
71974
72090
  return;
71975
72091
  mkdirSync58(dir, { recursive: true });
71976
- recs.forEach((r, k3) => atomicWriteJson(join107(dir, `iteration-group-${name}-${String(k3).padStart(3, "0")}.json`), r));
72092
+ recs.forEach((r, k3) => atomicWriteJson(join108(dir, `iteration-group-${name}-${String(k3).padStart(3, "0")}.json`), r));
71977
72093
  } catch {}
71978
72094
  }
71979
72095
  function testCommand(repoDir, env) {
@@ -71986,7 +72102,7 @@ function testCommand(repoDir, env) {
71986
72102
  return [];
71987
72103
  }
71988
72104
  function findResumable(repoDir, specSha, unitIds) {
71989
- const root = join107(repoDir, ".loki", "groups");
72105
+ const root = join108(repoDir, ".loki", "groups");
71990
72106
  let names = [];
71991
72107
  try {
71992
72108
  names = readdirSync34(root);
@@ -71997,7 +72113,7 @@ function findResumable(repoDir, specSha, unitIds) {
71997
72113
  for (const gid of names) {
71998
72114
  if (!GID_RE.test(gid))
71999
72115
  continue;
72000
- const p = join107(root, gid, "dag.json"), d = readJson8(p);
72116
+ const p = join108(root, gid, "dag.json"), d = readJson8(p);
72001
72117
  if (!d || (unitIds ? JSON.stringify((Array.isArray(d["units"]) ? d["units"] : []).filter((u10) => !u10.fixKind).map((u10) => u10.id)) !== JSON.stringify(unitIds) : d["spec_sha256"] !== specSha) || typeof d["base_ref"] !== "string" || !Array.isArray(d["units"]))
72002
72118
  continue;
72003
72119
  let at2 = 0;
@@ -72014,7 +72130,7 @@ function findResumable(repoDir, specSha, unitIds) {
72014
72130
  async function unitDone(verifyReceipt, repoDir, gid, n11, id2) {
72015
72131
  if (!UNIT_ID_RE.test(id2))
72016
72132
  return false;
72017
- const rp = join107(repoDir, ".loki", "groups", gid, "group", "units", id2, "receipt.json");
72133
+ const rp = join108(repoDir, ".loki", "groups", gid, "group", "units", id2, "receipt.json");
72018
72134
  const rec2 = readJson8(rp);
72019
72135
  if (!rec2 || rec2["verdict"] !== "VERIFIED")
72020
72136
  return false;
@@ -72029,7 +72145,7 @@ async function adoptJournaled(verifyReceipt, repoDir, dir, key, gid, n11, id2, t
72029
72145
  return false;
72030
72146
  if (!await unitDone(verifyReceipt, repoDir, e10.gid, e10.n, id2))
72031
72147
  return false;
72032
- const signed = readJson8(join107(repoDir, ".loki", "groups", e10.gid, "group", "units", id2, "receipt.json"));
72148
+ const signed = readJson8(join108(repoDir, ".loki", "groups", e10.gid, "group", "units", id2, "receipt.json"));
72033
72149
  const signedTask = (signed?.["task"] ?? {}).sha256;
72034
72150
  const signedSpec = (signed?.["unit_spec"] ?? {}).sha256;
72035
72151
  if (typeof signedSpec !== "string" || signedSpec === "" || signedSpec !== specSha)
@@ -72039,9 +72155,9 @@ async function adoptJournaled(verifyReceipt, repoDir, dir, key, gid, n11, id2, t
72039
72155
  const tip = git11(repoDir, ["rev-parse", "--verify", "--quiet", `refs/heads/loki/unit-${e10.gid}-${e10.n}`]);
72040
72156
  if (tip === "" || tip !== e10.head)
72041
72157
  return false;
72042
- const dst = join107(repoDir, ".loki", "groups", gid, "group", "units", id2);
72043
- rmSync31(dst, { recursive: true, force: true });
72044
- cpSync2(join107(repoDir, ".loki", "groups", e10.gid, "group", "units", id2), dst, { recursive: true });
72158
+ const dst = join108(repoDir, ".loki", "groups", gid, "group", "units", id2);
72159
+ rmSync32(dst, { recursive: true, force: true });
72160
+ cpSync2(join108(repoDir, ".loki", "groups", e10.gid, "group", "units", id2), dst, { recursive: true });
72045
72161
  if (safeGitSpawn(repoDir, ["update-ref", `refs/heads/loki/unit-${gid}-${n11}`, tip], { encoding: "utf8" }).status !== 0)
72046
72162
  return false;
72047
72163
  if (!await unitDone(verifyReceipt, repoDir, gid, n11, id2))
@@ -72076,8 +72192,8 @@ async function runGroup(launcher, dag, ctx) {
72076
72192
  const revised = resumable !== null && exact === null;
72077
72193
  const changed = new Set;
72078
72194
  const groupId = resumable?.gid ?? `g${Date.now().toString(36)}`;
72079
- const groupDir = join107(repoDir, ".loki", "groups", groupId);
72080
- const receiptPath = join107(groupDir, "receipt.json");
72195
+ const groupDir = join108(repoDir, ".loki", "groups", groupId);
72196
+ const receiptPath = join108(groupDir, "receipt.json");
72081
72197
  const slugOf = () => originSlug(repoDir);
72082
72198
  let baseRef;
72083
72199
  let startBranch = "";
@@ -72122,7 +72238,7 @@ async function runGroup(launcher, dag, ctx) {
72122
72238
  u10.writeSet = nd2.writeSet;
72123
72239
  }
72124
72240
  }
72125
- } else if (!existsSync75(groupContractPath(repoDir, groupId))) {
72241
+ } else if (!existsSync76(groupContractPath(repoDir, groupId))) {
72126
72242
  const f = freezeGroupContract(repoDir, groupId, units, parseContract(ctx.spec, ctx.specPath ?? ""));
72127
72243
  if (!f.ok) {
72128
72244
  say(`loki: ${f.reason}
@@ -72169,10 +72285,10 @@ async function runGroup(launcher, dag, ctx) {
72169
72285
  const accOf = new Map;
72170
72286
  for (const cu2 of Array.isArray(gc2?.["units"]) ? gc2["units"] : [])
72171
72287
  accOf.set(cu2.id, cu2.criteria.map((c) => c.text));
72172
- const specDir = join107(groupDir, "unit_specs");
72288
+ const specDir = join108(groupDir, "unit_specs");
72173
72289
  mkdirSync58(specDir, { recursive: true });
72174
72290
  for (const u10 of units) {
72175
- const spec = join107(specDir, `${u10.id}.json`);
72291
+ const spec = join108(specDir, `${u10.id}.json`);
72176
72292
  const isFix = !!u10.fixKind;
72177
72293
  if (!isFix)
72178
72294
  u10.base = baseRef;
@@ -72198,19 +72314,19 @@ async function runGroup(launcher, dag, ctx) {
72198
72314
  say(`loki: unit ${u10.id} skipped-unchanged
72199
72315
  `);
72200
72316
  } else if (resumable && UNIT_ID_RE.test(u10.id))
72201
- rmSync31(join107(groupDir, "group", "units", u10.id), { recursive: true, force: true });
72317
+ rmSync32(join108(groupDir, "group", "units", u10.id), { recursive: true, force: true });
72202
72318
  }
72203
72319
  const cut2 = units.findIndex((u10) => u10.fixKind && !u10.done);
72204
72320
  if (cut2 >= 0)
72205
72321
  for (const u10 of units.splice(cut2)) {
72206
72322
  if (u10.done)
72207
72323
  doneCount--;
72208
- rmSync31(join107(groupDir, "group", "units", u10.id), { recursive: true, force: true });
72324
+ rmSync32(join108(groupDir, "group", "units", u10.id), { recursive: true, force: true });
72209
72325
  }
72210
72326
  if (resumable)
72211
72327
  say(`loki: resuming group ${groupId}: ${doneCount} of ${units.length} units already VERIFIED
72212
72328
  `);
72213
- const dagPath = join107(groupDir, "dag.json");
72329
+ const dagPath = join108(groupDir, "dag.json");
72214
72330
  atomicWriteJson(dagPath, { group: groupId, spec_sha256: specSha, base_ref: baseRef, start_branch: startBranch, ...full, units });
72215
72331
  try {
72216
72332
  const chk = await checkDecomposable(full, { map: (() => {
@@ -72240,7 +72356,7 @@ async function runGroup(launcher, dag, ctx) {
72240
72356
  const n11 = Math.min(slots, pending);
72241
72357
  say(`loki: group ${groupId}: ${units.length} units, ${n11} parallel slot(s) (provider ${provider})
72242
72358
  `);
72243
- const backlog = join107(REPO_ROOT, "autonomy", "lib", "backlog.py");
72359
+ const backlog = join108(REPO_ROOT, "autonomy", "lib", "backlog.py");
72244
72360
  const feed = createGroupFeed(groupId, units, createGroupRenderer({ write: say, isTTY: false }));
72245
72361
  const res = await run2([backlog, slug, "--dag", dagPath, "--group", groupId, "--slots", String(n11), "--provider", provider], scopedEnv({ ...env, LOKI_PROVIDER: provider }), repoDir, (c) => feed.feed(c));
72246
72362
  launchCode = res.code;
@@ -72280,7 +72396,7 @@ async function runGroup(launcher, dag, ctx) {
72280
72396
  const testCmd = testCommand(repoDir, env), fixes = units.filter((u10) => u10.fixKind);
72281
72397
  const putDag = (us2) => atomicWriteJson(dagPath, { group: groupId, spec_sha256: specSha, base_ref: baseRef, start_branch: startBranch, ...full, units: us2 });
72282
72398
  const launchFix = async (fix) => {
72283
- const key = `unit-${groupId}-${units.length + 1}`, spec = join107(specDir, `${fix.id}.json`), slug = slugOf();
72399
+ const key = `unit-${groupId}-${units.length + 1}`, spec = join108(specDir, `${fix.id}.json`), slug = slugOf();
72284
72400
  if (!slug)
72285
72401
  return null;
72286
72402
  atomicWriteJson(spec, { id: fix.id, writeSet: fix.writeSet, pack: fix.writeSet, tokenBudget: 1e9, acceptance: fix.acceptance });
@@ -72289,7 +72405,7 @@ async function runGroup(launcher, dag, ctx) {
72289
72405
  fix.base = git11(repoDir, ["rev-parse", "HEAD"]);
72290
72406
  units.push(fix);
72291
72407
  putDag(units.map((u10) => u10 === fix ? u10 : { ...u10, done: true }));
72292
- const res = await run2([join107(REPO_ROOT, "autonomy", "lib", "backlog.py"), slug, "--dag", dagPath, "--group", groupId, "--slots", "1", "--provider", provider], scopedEnv({ ...env, LOKI_PROVIDER: provider }), repoDir);
72408
+ const res = await run2([join108(REPO_ROOT, "autonomy", "lib", "backlog.py"), slug, "--dag", dagPath, "--group", groupId, "--slots", "1", "--provider", provider], scopedEnv({ ...env, LOKI_PROVIDER: provider }), repoDir);
72293
72409
  costs.push(parseGroupCost(res.stdout));
72294
72410
  if (res.code !== 0 || !new RegExp(`^backlog: ${key} (VERIFIED|PR \\S+)$`, "m").test(res.stdout)) {
72295
72411
  units.pop();
@@ -72323,7 +72439,7 @@ async function runGroup(launcher, dag, ctx) {
72323
72439
  return 1;
72324
72440
  }
72325
72441
  const order2 = units.map((u10) => ({ unit_id: u10.id, goal: u10.items.join("; "), files: u10.writeSet }));
72326
- atomicWriteJson(join107(groupDir, "group", "manifest.json"), { group_id: groupId, units: order2 });
72442
+ atomicWriteJson(join108(groupDir, "group", "manifest.json"), { group_id: groupId, units: order2 });
72327
72443
  const head = git11(repoDir, ["rev-parse", "--verify", `refs/heads/${r.branch}`]);
72328
72444
  let verdict = "", unitVerdicts = [], why = "";
72329
72445
  try {
@@ -72367,9 +72483,9 @@ var NOT_PROVEN = 4, ENV_KEEP, defaultLauncher = (argv, env, cwd, onOut) => new P
72367
72483
  }), git11 = (dir, args) => {
72368
72484
  const r = safeGitSpawn(dir, args, { encoding: "utf8" });
72369
72485
  return r.status === 0 ? String(r.stdout).trim() : "";
72370
- }, SLUG_RE, originSlug = (repoDir) => SLUG_RE.exec(git11(repoDir, ["remote", "get-url", "origin"]))?.[1], sha2563 = (s) => createHash30("sha256").update(s).digest("hex"), UNIT_ID_RE, GID_RE, readJson8 = (p) => {
72486
+ }, SLUG_RE, originSlug = (repoDir) => SLUG_RE.exec(git11(repoDir, ["remote", "get-url", "origin"]))?.[1], sha2563 = (s) => createHash31("sha256").update(s).digest("hex"), UNIT_ID_RE, GID_RE, readJson8 = (p) => {
72371
72487
  try {
72372
- const v3 = JSON.parse(readFileSync93(p, "utf8"));
72488
+ const v3 = JSON.parse(readFileSync94(p, "utf8"));
72373
72489
  return v3 !== null && typeof v3 === "object" && !Array.isArray(v3) ? v3 : null;
72374
72490
  } catch {
72375
72491
  return null;
@@ -72404,8 +72520,8 @@ __export(exports_route, {
72404
72520
  MAX_SPEC_BYTES: () => MAX_SPEC_BYTES2,
72405
72521
  MAX_SEQ_TASK_BYTES: () => MAX_SEQ_TASK_BYTES
72406
72522
  });
72407
- import { closeSync as closeSync14, constants as constants5, fstatSync as fstatSync8, openSync as openSync14, readFileSync as readFileSync94, realpathSync as realpathSync32 } from "fs";
72408
- import { isAbsolute as isAbsolute21, relative as relative24, resolve as resolve33 } from "path";
72523
+ import { closeSync as closeSync14, constants as constants5, fstatSync as fstatSync8, openSync as openSync14, readFileSync as readFileSync95, realpathSync as realpathSync32 } from "fs";
72524
+ import { isAbsolute as isAbsolute21, relative as relative25, resolve as resolve33 } from "path";
72409
72525
  function providerSlots(env, provider) {
72410
72526
  provider = (provider || env.LOKI_PROVIDER || "claude").toLowerCase();
72411
72527
  return { provider, slots: PROVIDER_SLOTS[provider] ?? 1 };
@@ -72420,7 +72536,7 @@ function readSpec(task, repoDir, cwd) {
72420
72536
  } catch {
72421
72537
  return { kind: "missing", path: p };
72422
72538
  }
72423
- const rel = relative24(realpathSync32(repoDir), real3);
72539
+ const rel = relative25(realpathSync32(repoDir), real3);
72424
72540
  if (rel === ".." || rel.startsWith("../") || isAbsolute21(rel))
72425
72541
  return { kind: "reject", reason: `spec path escapes the repo: ${task}` };
72426
72542
  let fd2 = -1;
@@ -72431,7 +72547,7 @@ function readSpec(task, repoDir, cwd) {
72431
72547
  return { kind: "text" };
72432
72548
  if (st2.size > MAX_SPEC_BYTES2)
72433
72549
  return { kind: "reject", reason: `spec file over ${MAX_SPEC_BYTES2} bytes` };
72434
- const buf = readFileSync94(fd2);
72550
+ const buf = readFileSync95(fd2);
72435
72551
  if (buf.length > MAX_SPEC_BYTES2)
72436
72552
  return { kind: "reject", reason: `spec file over ${MAX_SPEC_BYTES2} bytes` };
72437
72553
  if (buf.includes(0))
@@ -72550,15 +72666,15 @@ var init_route = __esm(() => {
72550
72666
  });
72551
72667
 
72552
72668
  // ../../loki-ts/src/contrib/forecast.ts
72553
- import { appendFileSync as appendFileSync12, existsSync as existsSync76, mkdirSync as mkdirSync59, readFileSync as readFileSync95 } from "fs";
72554
- import { join as join108 } from "path";
72669
+ import { appendFileSync as appendFileSync12, existsSync as existsSync77, mkdirSync as mkdirSync59, readFileSync as readFileSync96 } from "fs";
72670
+ import { join as join109 } from "path";
72555
72671
  function readWindowDeltas(lokiDir2) {
72556
72672
  const p = historyPath2(lokiDir2);
72557
- if (!existsSync76(p))
72673
+ if (!existsSync77(p))
72558
72674
  return [];
72559
72675
  const out3 = [];
72560
72676
  try {
72561
- for (const line2 of readFileSync95(p, "utf8").split(`
72677
+ for (const line2 of readFileSync96(p, "utf8").split(`
72562
72678
  `)) {
72563
72679
  if (!line2.trim())
72564
72680
  continue;
@@ -72619,7 +72735,7 @@ async function printForecast(lokiDir2, read2, write, env = process.env) {
72619
72735
  `);
72620
72736
  } catch {}
72621
72737
  }
72622
- var MIN_FORECAST_RUNS = 3, KEEP_RUNS = 20, forecastOn = (env = process.env) => env["LOKI_FORECAST"] !== "0", finite = (v3) => typeof v3 === "number" && Number.isFinite(v3), historyPath2 = (lokiDir2) => join108(lokiDir2, "quota-runs.jsonl"), range = (xs2) => {
72738
+ var MIN_FORECAST_RUNS = 3, KEEP_RUNS = 20, forecastOn = (env = process.env) => env["LOKI_FORECAST"] !== "0", finite = (v3) => typeof v3 === "number" && Number.isFinite(v3), historyPath2 = (lokiDir2) => join109(lokiDir2, "quota-runs.jsonl"), range = (xs2) => {
72623
72739
  const lo = Math.floor(Math.min(...xs2)), hi2 = Math.ceil(Math.max(...xs2));
72624
72740
  return lo === hi2 ? `${hi2}` : `${lo}-${hi2}`;
72625
72741
  };
@@ -72628,8 +72744,8 @@ var init_forecast = __esm(() => {
72628
72744
  });
72629
72745
 
72630
72746
  // ../../loki-ts/src/commands/queue.ts
72631
- import { existsSync as existsSync77, mkdirSync as mkdirSync60, readFileSync as readFileSync96, readdirSync as readdirSync35, renameSync as renameSync21, statSync as statSync31, writeFileSync as writeFileSync57 } from "fs";
72632
- import { join as join109, resolve as resolve34 } from "path";
72747
+ import { existsSync as existsSync78, mkdirSync as mkdirSync60, readFileSync as readFileSync97, readdirSync as readdirSync35, renameSync as renameSync21, statSync as statSync31, writeFileSync as writeFileSync58 } from "fs";
72748
+ import { join as join110, resolve as resolve34 } from "path";
72633
72749
  function normalizeRef(raw2) {
72634
72750
  const m = URL_RE2.exec(raw2);
72635
72751
  if (m)
@@ -72639,11 +72755,11 @@ function normalizeRef(raw2) {
72639
72755
  return /^0+$/.test(raw2.replace(/^.*#/, "")) ? null : raw2;
72640
72756
  }
72641
72757
  function queuePath(lokiDir2) {
72642
- return join109(lokiDir2, "issue-queue.json");
72758
+ return join110(lokiDir2, "issue-queue.json");
72643
72759
  }
72644
72760
  function readQueue(lokiDir2) {
72645
72761
  try {
72646
- const d = JSON.parse(readFileSync96(queuePath(lokiDir2), "utf8"));
72762
+ const d = JSON.parse(readFileSync97(queuePath(lokiDir2), "utf8"));
72647
72763
  return Array.isArray(d.items) ? d.items.filter((i) => typeof i?.ref === "string") : [];
72648
72764
  } catch {
72649
72765
  return [];
@@ -72651,10 +72767,10 @@ function readQueue(lokiDir2) {
72651
72767
  }
72652
72768
  function quarantineCorruptQueue(lokiDir2, now2, warn) {
72653
72769
  const p = queuePath(lokiDir2);
72654
- if (!existsSync77(p))
72770
+ if (!existsSync78(p))
72655
72771
  return;
72656
72772
  try {
72657
- const d = JSON.parse(readFileSync96(p, "utf8"));
72773
+ const d = JSON.parse(readFileSync97(p, "utf8"));
72658
72774
  if (d !== null && typeof d === "object" && Array.isArray(d.items))
72659
72775
  return;
72660
72776
  } catch {}
@@ -72856,8 +72972,8 @@ ${QUEUE_USAGE}`);
72856
72972
  try {
72857
72973
  mkdirSync60(d.lokiDir, { recursive: true });
72858
72974
  const stamp2 = finished.toISOString().replace(/[:.]/g, "-");
72859
- writeFileSync57(join109(d.lokiDir, `queue-digest-${stamp2}.txt`), text4);
72860
- writeFileSync57(join109(d.lokiDir, "queue-digest-latest.txt"), text4);
72975
+ writeFileSync58(join110(d.lokiDir, `queue-digest-${stamp2}.txt`), text4);
72976
+ writeFileSync58(join110(d.lokiDir, "queue-digest-latest.txt"), text4);
72861
72977
  } catch (e10) {
72862
72978
  d.err(`loki queue: could not write digest: ${e10 instanceof Error ? e10.message : String(e10)}
72863
72979
  `);
@@ -72867,12 +72983,12 @@ ${QUEUE_USAGE}`);
72867
72983
  }
72868
72984
  function newestRecord(lokiDir2, since) {
72869
72985
  for (const [sub2, file] of [["runs", "receipt.json"], ["proofs", "proof.json"]]) {
72870
- const dir = join109(lokiDir2, sub2);
72986
+ const dir = join110(lokiDir2, sub2);
72871
72987
  let best = null;
72872
72988
  try {
72873
72989
  for (const name of readdirSync35(dir)) {
72874
- const p = join109(dir, name, file);
72875
- if (!existsSync77(p))
72990
+ const p = join110(dir, name, file);
72991
+ if (!existsSync78(p))
72876
72992
  continue;
72877
72993
  const t = statSync31(p).mtimeMs;
72878
72994
  if (t >= since && (!best || t > best.t))
@@ -72880,7 +72996,7 @@ function newestRecord(lokiDir2, since) {
72880
72996
  }
72881
72997
  if (!best)
72882
72998
  continue;
72883
- const d = JSON.parse(readFileSync96(best.p, "utf8"));
72999
+ const d = JSON.parse(readFileSync97(best.p, "utf8"));
72884
73000
  const usd = d.cost?.usd;
72885
73001
  const unmetered = d.cost?.source === "cli-invoker-unmetered";
72886
73002
  return {
@@ -72914,7 +73030,7 @@ function makeDefaultRunner(lokiDir2) {
72914
73030
  return async (ref, opts) => {
72915
73031
  const since = Date.now();
72916
73032
  const argv = [resolve34(REPO_ROOT, "bin", "loki"), ...queueStartArgs(ref, !!opts.pr)];
72917
- const runLoki = opts.cwd ? join109(opts.cwd, ".loki") : lokiDir2;
73033
+ const runLoki = opts.cwd ? join110(opts.cwd, ".loki") : lokiDir2;
72918
73034
  const env = runnerEnv(opts, runLoki);
72919
73035
  const proc = Bun.spawn(argv, { stdout: "pipe", stderr: "pipe", stdin: "ignore", env, ...opts.cwd ? { cwd: opts.cwd } : {} });
72920
73036
  const mins2 = itemTimeoutMin(process.env["LOKI_QUEUE_ITEM_TIMEOUT_MIN"]);
@@ -72924,9 +73040,9 @@ function makeDefaultRunner(lokiDir2) {
72924
73040
  clearTimeout(timer);
72925
73041
  const output = so + se2;
72926
73042
  try {
72927
- const logDir = join109(lokiDir2, "queue-logs");
73043
+ const logDir = join110(lokiDir2, "queue-logs");
72928
73044
  mkdirSync60(logDir, { recursive: true });
72929
- writeFileSync57(join109(logDir, `${(opts.logName ?? ref).replace(/[^A-Za-z0-9_.-]/g, "_").slice(0, 120)}.log`), output);
73045
+ writeFileSync58(join110(logDir, `${(opts.logName ?? ref).replace(/[^A-Za-z0-9_.-]/g, "_").slice(0, 120)}.log`), output);
72930
73046
  } catch {}
72931
73047
  const proof = newestRecord(runLoki, since);
72932
73048
  return { rc: rc2, output, verdict: proof.verdict, costUsd: proof.costUsd, runId: proof.runId ?? null };
@@ -72995,7 +73111,7 @@ function parseDecomposition(text4) {
72995
73111
  const files = o.files === undefined ? [] : strList(o.files, 50);
72996
73112
  if (!files)
72997
73113
  return { ok: false, reason: `${o.id}: files must be a list of paths` };
72998
- slices.push({ id: o.id, title: oneLine3(o.title), acceptance: acceptance2, depends_on: [...new Set(deps)], files });
73114
+ slices.push({ id: o.id, title: oneLine4(o.title), acceptance: acceptance2, depends_on: [...new Set(deps)], files });
72999
73115
  }
73000
73116
  for (const s of slices)
73001
73117
  for (const d of s.depends_on)
@@ -73038,7 +73154,7 @@ function parseDecomposition(text4) {
73038
73154
  function decomposeBrief(slug, i, triageReason, outPath) {
73039
73155
  return [
73040
73156
  "You are planning how an autonomous coding agent should deliver one GitHub issue that is too large for a single pull request.",
73041
- `A triage pass judged it too large: ${oneLine3(triageReason)}`,
73157
+ `A triage pass judged it too large: ${oneLine4(triageReason)}`,
73042
73158
  "Split it into an ordered list of independently verifiable, PR-sized slices. Each slice becomes one pull request, opened as a stack:",
73043
73159
  "a slice that depends on another is built on top of that slice's branch. Prefer a short chain; give a slice several dependencies only when they are already on one chain.",
73044
73160
  "Do not edit, create or delete any repository file. You may read the repository to judge scope.",
@@ -73059,14 +73175,14 @@ function sliceTask(slug, epic, s, index2, total, parent) {
73059
73175
  `This is slice ${index2 + 1} of a larger issue that was split into ${total} pull requests. Implement only this slice.` + (parent ? ` The branch already contains slice ${parent} and everything it depends on.` : ""),
73060
73176
  `Acceptance criteria: ${s.acceptance.map((a, k3) => `(${k3 + 1}) ${a}`).join("; ")}`,
73061
73177
  s.files.length ? `Likely files: ${s.files.join(", ")}` : "",
73062
- `Parent issue: ${oneLine3(epic.title)}`
73178
+ `Parent issue: ${oneLine4(epic.title)}`
73063
73179
  ].filter(Boolean).join(`
73064
73180
 
73065
73181
  `);
73066
73182
  }
73067
73183
  function planComment(triageReason, slices) {
73068
73184
  return [
73069
- `Loki triage: too-large (${oneLine3(triageReason)}). Loki split it into ${slices.length} stacked pull requests, run in this order:`,
73185
+ `Loki triage: too-large (${oneLine4(triageReason)}). Loki split it into ${slices.length} stacked pull requests, run in this order:`,
73070
73186
  "",
73071
73187
  ...slices.map((s, k3) => `${k3 + 1}. ${s.id}: ${s.title}${s.depends_on.length ? ` (after ${s.depends_on.join(", ")})` : ""}`)
73072
73188
  ].join(`
@@ -73089,7 +73205,7 @@ async function runEpicSlices(d, runSlice, onSkip) {
73089
73205
  return d.slices.map((s) => results.get(s.id));
73090
73206
  }
73091
73207
  function renderEpicTree(n11, title, rows) {
73092
- const L = [`### #${n11} ${oneLine3(title)}`, ""];
73208
+ const L = [`### #${n11} ${oneLine4(title)}`, ""];
73093
73209
  const kids = new Map;
73094
73210
  for (const r of rows)
73095
73211
  kids.set(r.parent, [...kids.get(r.parent) ?? [], r]);
@@ -73106,13 +73222,13 @@ function renderEpicTree(n11, title, rows) {
73106
73222
  }
73107
73223
  function makeSessionDecompose(repoDir, lokiDir2, provider) {
73108
73224
  return async (slug, issue, triageReason) => {
73109
- const { mkdirSync: mkdirSync61, readFileSync: readFileSync97, existsSync: existsSync78 } = await import("fs");
73110
- const { join: join110 } = await import("path");
73225
+ const { mkdirSync: mkdirSync61, readFileSync: readFileSync98, existsSync: existsSync79 } = await import("fs");
73226
+ const { join: join111 } = await import("path");
73111
73227
  const { createSessionRunner: createSessionRunner2 } = await Promise.resolve().then(() => (init_session(), exports_session));
73112
73228
  const { envOverride: envOverride2 } = await Promise.resolve().then(() => (init_decision(), exports_decision));
73113
- const dir = join110(lokiDir2, "issues-run", "decompose");
73229
+ const dir = join111(lokiDir2, "issues-run", "decompose");
73114
73230
  mkdirSync61(dir, { recursive: true });
73115
- const outPath = join110(dir, `issue-${issue.number}-${Date.now()}.json`);
73231
+ const outPath = join111(dir, `issue-${issue.number}-${Date.now()}.json`);
73116
73232
  const runner = createSessionRunner2({ provider, lokiRoot: lokiDir2 });
73117
73233
  const r = await runner.run({
73118
73234
  stage: "plan",
@@ -73124,12 +73240,12 @@ function makeSessionDecompose(repoDir, lokiDir2, provider) {
73124
73240
  cwd: repoDir,
73125
73241
  ...provider === "claude" && envOverride2(process.env) === null ? { model: "opus" } : {}
73126
73242
  });
73127
- if (existsSync78(outPath))
73128
- return readFileSync97(outPath, "utf8");
73243
+ if (existsSync79(outPath))
73244
+ return readFileSync98(outPath, "utf8");
73129
73245
  return r.summary ?? "";
73130
73246
  };
73131
73247
  }
73132
- var ID_RE2, MIN_SLICES = 2, MAX_SLICES = 15, oneLine3 = (s) => s.replace(/[\x00-\x1f\x7f]+/g, " ").replace(/\s+/g, " ").trim(), strList = (v3, max) => Array.isArray(v3) && v3.length <= max && v3.every((x3) => typeof x3 === "string" && x3.trim() !== "" && x3.length <= 500) ? v3.map(oneLine3) : null, stacksOn = (r) => !!r && !!r.pr && !!r.branch && !/^(FAILED|BLOCKED|SKIPPED)/.test(r.outcome);
73248
+ var ID_RE2, MIN_SLICES = 2, MAX_SLICES = 15, oneLine4 = (s) => s.replace(/[\x00-\x1f\x7f]+/g, " ").replace(/\s+/g, " ").trim(), strList = (v3, max) => Array.isArray(v3) && v3.length <= max && v3.every((x3) => typeof x3 === "string" && x3.trim() !== "" && x3.length <= 500) ? v3.map(oneLine4) : null, stacksOn = (r) => !!r && !!r.pr && !!r.branch && !/^(FAILED|BLOCKED|SKIPPED)/.test(r.outcome);
73133
73249
  var init_issues_epic = __esm(() => {
73134
73250
  ID_RE2 = /^[A-Za-z0-9_-]{1,32}$/;
73135
73251
  });
@@ -73150,9 +73266,9 @@ __export(exports_issues_run, {
73150
73266
  TRIAGE_RE: () => TRIAGE_RE
73151
73267
  });
73152
73268
  import { spawnSync as spawnSync15 } from "child_process";
73153
- import { cpSync as cpSync3, existsSync as existsSync78, mkdirSync as mkdirSync61, mkdtempSync as mkdtempSync14, rmSync as rmSync32, writeFileSync as writeFileSync58 } from "fs";
73154
- import { tmpdir as tmpdir18 } from "os";
73155
- import { join as join110, resolve as resolve35 } from "path";
73269
+ import { cpSync as cpSync3, existsSync as existsSync79, mkdirSync as mkdirSync61, mkdtempSync as mkdtempSync15, rmSync as rmSync33, writeFileSync as writeFileSync59 } from "fs";
73270
+ import { tmpdir as tmpdir19 } from "os";
73271
+ import { join as join111, resolve as resolve35 } from "path";
73156
73272
  import { createInterface as createInterface3 } from "readline";
73157
73273
  function parseIssuesArgs(args) {
73158
73274
  const a = { slug: null, label: null, milestone: null, limit: DEFAULT_LIMIT, parallel: 1, draft: false, dryRun: false, yes: false, comment: false, split: true, json: false };
@@ -73408,7 +73524,7 @@ ${USAGE}`);
73408
73524
  }
73409
73525
  }
73410
73526
  const stamp2 = started.toISOString().replace(/[:.]/g, "-");
73411
- const runDir = join110(d.lokiDir, "issues-run", stamp2);
73527
+ const runDir = join111(d.lokiDir, "issues-run", stamp2);
73412
73528
  mkdirSync61(runDir, { recursive: true });
73413
73529
  const byRef = new Map(actionable.map((i) => [`${slug}#${i.number}`, i]));
73414
73530
  const sink = () => {};
@@ -73498,14 +73614,14 @@ ${USAGE}`);
73498
73614
  ${trees.join(`
73499
73615
  `)}` : "");
73500
73616
  try {
73501
- writeFileSync58(join110(runDir, "digest.md"), text4);
73617
+ writeFileSync59(join111(runDir, "digest.md"), text4);
73502
73618
  } catch (e10) {
73503
73619
  d.err(`loki issues run: could not write digest: ${e10 instanceof Error ? e10.message : String(e10)}
73504
73620
  `);
73505
73621
  }
73506
73622
  d.out(`
73507
73623
  ${text4}
73508
- digest: ${join110(runDir, "digest.md")}
73624
+ digest: ${join111(runDir, "digest.md")}
73509
73625
  `);
73510
73626
  return 0;
73511
73627
  }
@@ -73515,11 +73631,11 @@ function perRun(est) {
73515
73631
  return est.prior ? { usd: est.prior.usd, tilde: "~", label: " (rough prior)" } : null;
73516
73632
  }
73517
73633
  function keepReceipt(wt, runId2, runDir, err) {
73518
- const src = join110(wt, ".loki", "runs", runId2);
73519
- if (!/^[A-Za-z0-9_.-]+$/.test(runId2) || !existsSync78(src))
73634
+ const src = join111(wt, ".loki", "runs", runId2);
73635
+ if (!/^[A-Za-z0-9_.-]+$/.test(runId2) || !existsSync79(src))
73520
73636
  return;
73521
73637
  try {
73522
- cpSync3(src, join110(runDir, "receipts", runId2), { recursive: true });
73638
+ cpSync3(src, join111(runDir, "receipts", runId2), { recursive: true });
73523
73639
  } catch (e10) {
73524
73640
  err(`loki issues run: could not keep the receipt of ${runId2}: ${e10 instanceof Error ? e10.message : String(e10)}
73525
73641
  `);
@@ -73566,8 +73682,8 @@ function makeWorktrees(repoDir) {
73566
73682
  let root = null;
73567
73683
  return {
73568
73684
  create: (name, base) => {
73569
- root ??= mkdtempSync14(join110(tmpdir18(), "loki-issues-"));
73570
- const p = join110(root, name);
73685
+ root ??= mkdtempSync15(join111(tmpdir19(), "loki-issues-"));
73686
+ const p = join111(root, name);
73571
73687
  safeGit(repoDir, ["worktree", "add", "-B", `loki/${name}`, p, base]);
73572
73688
  return p;
73573
73689
  },
@@ -73576,7 +73692,7 @@ function makeWorktrees(repoDir) {
73576
73692
  safeGit(repoDir, ["worktree", "remove", "--force", p]);
73577
73693
  safeGit(repoDir, ["branch", "-D", `loki/${name}`]);
73578
73694
  } catch {
73579
- rmSync32(p, { recursive: true, force: true });
73695
+ rmSync33(p, { recursive: true, force: true });
73580
73696
  }
73581
73697
  }
73582
73698
  };
@@ -73660,7 +73776,7 @@ __export(exports_satisfaction, {
73660
73776
  });
73661
73777
  import { appendFileSync as appendFileSync13, mkdirSync as mkdirSync62 } from "fs";
73662
73778
  import { homedir as homedir13 } from "os";
73663
- import { join as join111 } from "path";
73779
+ import { join as join112 } from "path";
73664
73780
  import { createInterface as createInterface4 } from "readline";
73665
73781
  function satisfactionEnabled(env, tty) {
73666
73782
  if (!tty)
@@ -73680,9 +73796,9 @@ function parseScore(line2) {
73680
73796
  return { score: Number(m[1]), again: m[2] ? m[2].toLowerCase() === "y" : null };
73681
73797
  }
73682
73798
  function recordSatisfaction(home, row) {
73683
- const dir = join111(home, ".loki");
73799
+ const dir = join112(home, ".loki");
73684
73800
  mkdirSync62(dir, { recursive: true, mode: 448 });
73685
- appendFileSync13(join111(dir, "satisfaction.jsonl"), `${JSON.stringify(row)}
73801
+ appendFileSync13(join112(dir, "satisfaction.jsonl"), `${JSON.stringify(row)}
73686
73802
  `, { mode: 384 });
73687
73803
  }
73688
73804
  async function maybeAsk(o) {
@@ -73752,9 +73868,9 @@ __export(exports_supervisor, {
73752
73868
  BACKSTOP_GRACE_S: () => BACKSTOP_GRACE_S
73753
73869
  });
73754
73870
  import { spawn as spawn13, spawnSync as spawnSync16 } from "child_process";
73755
- import { createHash as createHash31, createPublicKey as createPublicKey3, sign as sign2 } from "crypto";
73756
- import { existsSync as existsSync79, mkdirSync as mkdirSync63, readFileSync as readFileSync97, writeFileSync as writeFileSync59 } from "fs";
73757
- import { join as join112, relative as relative25, resolve as resolve36 } from "path";
73871
+ import { createHash as createHash32, createPublicKey as createPublicKey3, sign as sign2 } from "crypto";
73872
+ import { existsSync as existsSync80, mkdirSync as mkdirSync63, readFileSync as readFileSync98, writeFileSync as writeFileSync60 } from "fs";
73873
+ import { join as join113, relative as relative26, resolve as resolve36 } from "path";
73758
73874
  async function slackEvent(...a) {
73759
73875
  try {
73760
73876
  await (await Promise.resolve().then(() => (init_slack_events(), exports_slack_events))).notifyEvent(...a);
@@ -73781,9 +73897,9 @@ class SupervisorLog {
73781
73897
  constructor(path, runId2) {
73782
73898
  this.path = path;
73783
73899
  this.log = new EventLog(path, runId2);
73784
- this.hash = createHash31("sha256");
73900
+ this.hash = createHash32("sha256");
73785
73901
  try {
73786
- this.hash.update(readFileSync97(path));
73902
+ this.hash.update(readFileSync98(path));
73787
73903
  } catch {}
73788
73904
  }
73789
73905
  implementOpen = false;
@@ -73838,7 +73954,7 @@ class SupervisorLog {
73838
73954
  const expected = this.hash.copy().digest("hex");
73839
73955
  let actual = "";
73840
73956
  try {
73841
- actual = createHash31("sha256").update(readFileSync97(this.path)).digest("hex");
73957
+ actual = createHash32("sha256").update(readFileSync98(this.path)).digest("hex");
73842
73958
  } catch {}
73843
73959
  if (actual === expected)
73844
73960
  return true;
@@ -73860,15 +73976,15 @@ async function runSupervisor(opts) {
73860
73976
  const t02 = Date.now();
73861
73977
  const startedProvider = opts.started?.["provider"];
73862
73978
  const env = opts.env ?? process.env;
73863
- await assertPreflight({ repoDir: opts.repoDir, provider: typeof startedProvider === "string" ? startedProvider : "claude", pr: opts.pr !== undefined, env, runDir: join112(opts.repoDir, ".loki", "runs", opts.runId) });
73979
+ await assertPreflight({ repoDir: opts.repoDir, provider: typeof startedProvider === "string" ? startedProvider : "claude", pr: opts.pr !== undefined, env, runDir: join113(opts.repoDir, ".loki", "runs", opts.runId) });
73864
73980
  writeEngineMarker(opts.repoDir, opts.runId);
73865
73981
  const origin = readOriginUrl(opts.repoDir);
73866
- const rmRunPid = writeRunPid(join112(opts.repoDir, ".loki", "runs", opts.runId), opts.runId);
73982
+ const rmRunPid = writeRunPid(join113(opts.repoDir, ".loki", "runs", opts.runId), opts.runId);
73867
73983
  process.once("exit", rmRunPid);
73868
- const log = new SupervisorLog(join112(opts.repoDir, eventsRelPath(opts.runId)), opts.runId);
73984
+ const log = new SupervisorLog(join113(opts.repoDir, eventsRelPath(opts.runId)), opts.runId);
73869
73985
  if ((env.LOKI_CONTROL ?? process.env.LOKI_CONTROL) !== "0")
73870
73986
  Promise.resolve().then(() => (init_ship_hook(), exports_ship_hook)).then((m) => m.startShip(opts.repoDir, log.path, env)).catch(() => {});
73871
- const aliveDir = join112(opts.repoDir, ".loki", "runs", opts.runId), lastAlive = opts.resume ? readAliveBeat(aliveDir) : null;
73987
+ const aliveDir = join113(opts.repoDir, ".loki", "runs", opts.runId), lastAlive = opts.resume ? readAliveBeat(aliveDir) : null;
73872
73988
  log.append(opts.resume ? "run.resumed" : "run.started", null, { ...opts.started, ...opts.resume ? { phase: "stage", ...lastAlive ? { last_alive_ts: new Date(lastAlive).toISOString() } : {} } : {}, origin_repo: githubRepoFromUrl(origin) });
73873
73989
  if (!opts.resume)
73874
73990
  Promise.resolve().then(() => (init_writeback(), exports_writeback)).then((m) => m.writeBack({ phase: "started", verdict: "", prUrl: null, receiptSha256: null, task: "" }, env));
@@ -73903,7 +74019,7 @@ async function runSupervisor(opts) {
73903
74019
  if (e10?.type === "receipt.sealed")
73904
74020
  sealed = e10.data;
73905
74021
  if (e10?.type === "variant" && e10.data.intent_confirm === true && workerEnv.LOKI_INTENT_TTY === "1") {
73906
- askIntent(String(e10.data.card ?? ""), join112(opts.repoDir, ".loki", "runs", opts.runId));
74022
+ askIntent(String(e10.data.card ?? ""), join113(opts.repoDir, ".loki", "runs", opts.runId));
73907
74023
  }
73908
74024
  }, (stopped) => {
73909
74025
  for (const g10 of sessionGroups)
@@ -74002,8 +74118,8 @@ async function runSupervisor(opts) {
74002
74118
  }
74003
74119
  log.append("run.completed", null, { verdict, ...cancelled2 ? { cancelled: true, signal: cancelled2, outcome: "CANCELLED" } : {}, pr_url: prUrl, not_proven: notProven, cost_usd: costUsd, wall_s: wallS, pre_model: preModelTiming(allEvents, t02) });
74004
74120
  log.sealLog();
74005
- recordFingerprints(join112(opts.repoDir, ".loki", "state"), opts.runId, "failed", failedCheckNames(folded.stages["verify"]?.data.checks, folded.stages["verify"]?.data.pre_red_checks), cleanTreeId(opts.repoDir));
74006
- const stages = allEvents.filter((e10) => e10.type === "stage.completed" && typeof e10.data.duration_s === "number").map((e10) => ({ label: String(e10.stage), seconds: e10.data.duration_s })), pc2 = partialCost(allEvents, log.tampered), summary = { pr: prUrl ? { url: prUrl, draft: verdict !== "VERIFIED" } : null, verdict, outcome, notProven, flaky: recordFingerprints(join112(opts.repoDir, ".loki", "state"), opts.runId, "flaky", folded.stages["verify"]?.data.flaky, cleanTreeId(opts.repoDir)), wallS, stages, cost: { usd: costUsd, provider: String(opts.started?.provider ?? ""), tokens: summaryTokens(folded, allEvents.some((e10) => e10.type === "cost")), ...summaryCache(allEvents, log.tampered), partialUsd: pc2.usd, measuredSessions: pc2.measured, totalSessions: pc2.total, stageShares: log.tampered ? null : stageShareText(allEvents), capUsd: Number(opts.started?.["max_cost_usd"]) > 0 ? Number(opts.started?.["max_cost_usd"]) : undefined } };
74121
+ recordFingerprints(join113(opts.repoDir, ".loki", "state"), opts.runId, "failed", failedCheckNames(folded.stages["verify"]?.data.checks, folded.stages["verify"]?.data.pre_red_checks), cleanTreeId(opts.repoDir));
74122
+ const stages = allEvents.filter((e10) => e10.type === "stage.completed" && typeof e10.data.duration_s === "number").map((e10) => ({ label: String(e10.stage), seconds: e10.data.duration_s })), pc2 = partialCost(allEvents, log.tampered), summary = { pr: prUrl ? { url: prUrl, draft: verdict !== "VERIFIED" } : null, verdict, outcome, notProven, flaky: recordFingerprints(join113(opts.repoDir, ".loki", "state"), opts.runId, "flaky", folded.stages["verify"]?.data.flaky, cleanTreeId(opts.repoDir)), wallS, stages, cost: { usd: costUsd, provider: String(opts.started?.provider ?? ""), tokens: summaryTokens(folded, allEvents.some((e10) => e10.type === "cost")), ...summaryCache(allEvents, log.tampered), partialUsd: pc2.usd, measuredSessions: pc2.measured, totalSessions: pc2.total, stageShares: log.tampered ? null : stageShareText(allEvents), capUsd: Number(opts.started?.["max_cost_usd"]) > 0 ? Number(opts.started?.["max_cost_usd"]) : undefined } };
74007
74123
  await slackEvent(env, "finished", { summary: formatSummary(summary), outcome: String(outcome), cost: summary.cost.usd != null ? `$${summary.cost.usd.toFixed(2)}` : "not measured", time: `${Math.round(wallS)}s`, receipt: log.tampered ? "TAMPERED" : receiptVerdict ? verdict : undefined });
74008
74124
  rmRunPid();
74009
74125
  process.off("exit", rmRunPid);
@@ -74123,7 +74239,7 @@ usage: loki "<task>" [--no-pr] [--deep] [--json] [--verbose] [--quiet] [--max-co
74123
74239
  return rec2;
74124
74240
  }
74125
74241
  const runId2 = `e10-${new Date().toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z")}-${Math.random().toString(16).slice(2, 6)}`;
74126
- const runDir = join112(repoDir, ".loki", "runs", runId2);
74242
+ const runDir = join113(repoDir, ".loki", "runs", runId2);
74127
74243
  const cap = resolveCap(maxCost, repoDir);
74128
74244
  if ("error" in cap) {
74129
74245
  process.stderr.write(`engine10: ${cap.error}
@@ -74161,9 +74277,9 @@ usage: loki "<task>" [--no-pr] [--deep] [--json] [--verbose] [--quiet] [--max-co
74161
74277
  }
74162
74278
  if (spec) {
74163
74279
  mkdirSync63(runDir, { recursive: true });
74164
- writeFileSync59(join112(runDir, "spec.snapshot.md"), spec.raw);
74280
+ writeFileSync60(join113(runDir, "spec.snapshot.md"), spec.raw);
74165
74281
  for (const e10 of [env, process.env]) {
74166
- e10.LOKI_E10_SPEC_PATH = relative25(repoDir, spec.path);
74282
+ e10.LOKI_E10_SPEC_PATH = relative26(repoDir, spec.path);
74167
74283
  e10.LOKI_E10_SPEC_SHA256 = spec.sha256;
74168
74284
  e10.LOKI_E10_REPO_DIR = repoDir;
74169
74285
  }
@@ -74173,7 +74289,7 @@ usage: loki "<task>" [--no-pr] [--deep] [--json] [--verbose] [--quiet] [--max-co
74173
74289
  if (seed > 0)
74174
74290
  env.LOKI_E10_SPENT_USD = String(seed);
74175
74291
  if (sealPatch !== null) {
74176
- if (!existsSync79(sealPatch)) {
74292
+ if (!existsSync80(sealPatch)) {
74177
74293
  process.stderr.write(`engine10: --seal-existing patch not found: ${sealPatch}
74178
74294
  `);
74179
74295
  return 2;
@@ -74186,9 +74302,9 @@ usage: loki "<task>" [--no-pr] [--deep] [--json] [--verbose] [--quiet] [--max-co
74186
74302
  mkdirSync63(runDir, { recursive: true });
74187
74303
  try {
74188
74304
  if (trackerRef)
74189
- await fetchTrackerIssueToFile(trackerRef, join112(runDir, "issue.json"));
74305
+ await fetchTrackerIssueToFile(trackerRef, join113(runDir, "issue.json"));
74190
74306
  else
74191
- fetchIssueToFile(task, join112(runDir, "issue.json"));
74307
+ fetchIssueToFile(task, join113(runDir, "issue.json"));
74192
74308
  } catch (err) {
74193
74309
  process.stderr.write(`engine10: issue fetch failed: ${err.message.split(`
74194
74310
  `)[0]}
@@ -74218,7 +74334,7 @@ usage: loki "<task>" [--no-pr] [--deep] [--json] [--verbose] [--quiet] [--max-co
74218
74334
  process.stdout.write(`${capLine}
74219
74335
  `);
74220
74336
  const t02 = Date.now();
74221
- const eventsPath = join112(repoDir, eventsRelPath(runId2));
74337
+ const eventsPath = join113(repoDir, eventsRelPath(runId2));
74222
74338
  const live2 = (e10) => {
74223
74339
  const clockS = (Date.parse(e10.ts) - t02) / 1000;
74224
74340
  const d = e10.data;
@@ -74234,7 +74350,7 @@ usage: loki "<task>" [--no-pr] [--deep] [--json] [--verbose] [--quiet] [--max-co
74234
74350
  };
74235
74351
  let stopTail = () => {};
74236
74352
  const tailTimer = setInterval(() => {
74237
- if (verbose && !json2 && existsSync79(eventsPath)) {
74353
+ if (verbose && !json2 && existsSync80(eventsPath)) {
74238
74354
  clearInterval(tailTimer);
74239
74355
  stopTail = tail(eventsPath, live2, { intervalMs: 250 });
74240
74356
  }
@@ -74249,7 +74365,7 @@ usage: loki "<task>" [--no-pr] [--deep] [--json] [--verbose] [--quiet] [--max-co
74249
74365
  let stopLiveTail = () => {};
74250
74366
  const tick2 = setInterval(() => liveLine.tick(), 1000);
74251
74367
  const wait2 = setInterval(() => {
74252
- if (existsSync79(eventsPath)) {
74368
+ if (existsSync80(eventsPath)) {
74253
74369
  clearInterval(wait2);
74254
74370
  stopLiveTail = tail(eventsPath, (e10) => liveLine.onEvent(e10), { intervalMs: 250 });
74255
74371
  }
@@ -74265,7 +74381,7 @@ usage: loki "<task>" [--no-pr] [--deep] [--json] [--verbose] [--quiet] [--max-co
74265
74381
  const reqOnce = async (evs) => {
74266
74382
  if (reqMap === undefined) {
74267
74383
  const rq2 = await Promise.resolve().then(() => (init_contract(), exports_contract));
74268
- reqMap = rq2.writeFromEngine10(repoDir, join112(repoDir, ".loki"), runDir, isIssue ? null : task, evs);
74384
+ reqMap = rq2.writeFromEngine10(repoDir, join113(repoDir, ".loki"), runDir, isIssue ? null : task, evs);
74269
74385
  }
74270
74386
  return reqMap;
74271
74387
  };
@@ -74328,8 +74444,8 @@ usage: loki "<task>" [--no-pr] [--deep] [--json] [--verbose] [--quiet] [--max-co
74328
74444
  comment: noPr ? undefined : async ({ issueRef, reason, prUrl }) => {
74329
74445
  const { DEFAULT_PUSH_SH: DEFAULT_PUSH_SH2 } = await Promise.resolve().then(() => (init_pr(), exports_pr));
74330
74446
  mkdirSync63(runDir, { recursive: true });
74331
- const bodyFile = join112(runDir, "backstop-comment.md");
74332
- writeFileSync59(bodyFile, `<!-- loki-backstop -->
74447
+ const bodyFile = join113(runDir, "backstop-comment.md");
74448
+ writeFileSync60(bodyFile, `<!-- loki-backstop -->
74333
74449
  Loki 10 run ${runId2} ${prUrl ? `opened draft PR ${prUrl}` : "ended without a PR"}.
74334
74450
 
74335
74451
  ${prUrl ? "One question" : "Reason"}: ${reason}
@@ -74390,7 +74506,7 @@ ${prUrl ? "One question" : "Reason"}: ${reason}
74390
74506
  const rr2 = resultOf(res.outcome);
74391
74507
  if (res.outcome === "BUDGET_STOP" && cap.usd > 0)
74392
74508
  writeBudgetStop(repoDir, runId2, { task: task.trim(), cap_usd: cap.usd, spent_usd: seed + (usd ?? 0), source: cap.source });
74393
- const ui2 = { result: rr2, filesChanged: ds2?.files ?? null, insertions: ds2?.ins, deletions: ds2?.del, costUsd: usd, elapsedS: Number(f.run.completed?.data.wall_s ?? (Date.now() - t02) / 1000), receiptPath: res.receiptSha ? join112(runDir, "receipt.json") : null, next: res.outcome === "BUDGET_STOP" && cap.usd > 0 ? budgetNext(seed + (usd ?? 0), cap.usd) : nextOf(rr2, ds2?.files ?? null, reasonOf(events2, res.tampered, res.stop, res.outcome), provider, runId2), uncovered };
74509
+ const ui2 = { result: rr2, filesChanged: ds2?.files ?? null, insertions: ds2?.ins, deletions: ds2?.del, costUsd: usd, elapsedS: Number(f.run.completed?.data.wall_s ?? (Date.now() - t02) / 1000), receiptPath: res.receiptSha ? join113(runDir, "receipt.json") : null, next: res.outcome === "BUDGET_STOP" && cap.usd > 0 ? budgetNext(seed + (usd ?? 0), cap.usd) : nextOf(rr2, ds2?.files ?? null, reasonOf(events2, res.tampered, res.stop, res.outcome), provider, runId2), uncovered };
74394
74510
  const rdy = events2.find((e10) => e10.type === "stage.completed" && e10.stage === "intake")?.data.readiness, foldTail = [handoffRef, typeof rdy === "string" ? rdy : ""].filter(Boolean).join("; ");
74395
74511
  const riskLine = readRiskSummary(repoDir, t02);
74396
74512
  process.stdout.write(json2 ? `${JSON.stringify({ ...JSON.parse(out3), summary: { ...summaryObject(ui2), ...riskLine ? { risk: riskLine } : {} } })}
@@ -74445,8 +74561,8 @@ var init_supervisor = __esm(() => {
74445
74561
  });
74446
74562
 
74447
74563
  // ../../loki-ts/src/e10ext/compound_match.ts
74448
- import { readFileSync as readFileSync98 } from "fs";
74449
- import { basename as basename28, join as join113 } from "path";
74564
+ import { readFileSync as readFileSync99 } from "fs";
74565
+ import { basename as basename29, join as join114 } from "path";
74450
74566
  function parts(s) {
74451
74567
  return s.replace(/([a-z0-9])([A-Z])/g, "$1 $2").toLowerCase().match(/[a-z0-9]+/g) ?? [];
74452
74568
  }
@@ -74467,13 +74583,13 @@ function fuzzyHit(word, ps2) {
74467
74583
  }
74468
74584
  function linkedHits(word, repoMap, testMap, repoDir) {
74469
74585
  const out3 = [];
74470
- const srcs = repoMap.entries.filter((e10) => !vendored(e10.path) && e10.symbols.some((s) => fuzzyHit(word, parts(s))) && fuzzyHit(word, parts(basename28(e10.path))));
74586
+ const srcs = repoMap.entries.filter((e10) => !vendored(e10.path) && e10.symbols.some((s) => fuzzyHit(word, parts(s))) && fuzzyHit(word, parts(basename29(e10.path))));
74471
74587
  for (const t of testMap.tests) {
74472
- if (vendored(t.path) || !fuzzyHit(word, parts(basename28(t.path))))
74588
+ if (vendored(t.path) || !fuzzyHit(word, parts(basename29(t.path))))
74473
74589
  continue;
74474
74590
  let body;
74475
74591
  try {
74476
- body = importLines(readFileSync98(join113(repoDir, t.path), "utf8"));
74592
+ body = importLines(readFileSync99(join114(repoDir, t.path), "utf8"));
74477
74593
  } catch {
74478
74594
  continue;
74479
74595
  }
@@ -74487,15 +74603,15 @@ function linkedHits(word, repoMap, testMap, repoDir) {
74487
74603
  }
74488
74604
  return out3;
74489
74605
  }
74490
- var MIN_PREFIX = 5, SUFFIX, VENDORED, vendored = (p) => p.split("/").some((s) => VENDORED.has(s)), stemOf2 = (p) => parts(basename28(p)).slice(0, -1).filter((x3) => x3 !== "test" && x3 !== "spec").join("-");
74606
+ var MIN_PREFIX = 5, SUFFIX, VENDORED, vendored = (p) => p.split("/").some((s) => VENDORED.has(s)), stemOf2 = (p) => parts(basename29(p)).slice(0, -1).filter((x3) => x3 !== "test" && x3 !== "spec").join("-");
74491
74607
  var init_compound_match = __esm(() => {
74492
74608
  SUFFIX = /^(ation|ization|isation|ity|ivity|ments?|ives?|als?|ures?|ness|ism|ist|ize|ise|able|ible|ous|ics?|ings?|ed|ers?|ions?|ly|less|es|s|(ful|hood|ship|dom|ance|ence|ancy|ency|ator|ant|ent|ary|ery|ory|ward|wise|like|ish)s?)$/;
74493
74609
  VENDORED = new Set(["vendor", "third_party", "build", ".venv", "__generated__", "coverage", "node_modules", "dist"]);
74494
74610
  });
74495
74611
 
74496
74612
  // ../../loki-ts/src/util/already_done_evidence.ts
74497
- import { existsSync as existsSync80, readFileSync as readFileSync99 } from "fs";
74498
- import { basename as basename29, join as join114 } from "path";
74613
+ import { existsSync as existsSync81, readFileSync as readFileSync100 } from "fs";
74614
+ import { basename as basename30, join as join115 } from "path";
74499
74615
  function keywords2(task) {
74500
74616
  const words3 = task.toLowerCase().match(/[a-z0-9_]+/g) ?? [];
74501
74617
  return Array.from(new Set(words3.filter((w) => w.length > 2 && !STOP_WORDS.has(w))));
@@ -74516,7 +74632,7 @@ function codeEvidence(words3, repoMap) {
74516
74632
  function testEvidence(words3, testMap) {
74517
74633
  const hits = [];
74518
74634
  for (const t of testMap.tests) {
74519
- const toks = tokenSet(basename29(t.path));
74635
+ const toks = tokenSet(basename30(t.path));
74520
74636
  if (words3.some((w) => toks.has(w)))
74521
74637
  hits.push({ source: "test", path: t.path, line: t.path });
74522
74638
  }
@@ -74527,7 +74643,7 @@ function docEvidence(words3, repoDir) {
74527
74643
  for (const name of DOC_FILES) {
74528
74644
  let text4;
74529
74645
  try {
74530
- text4 = readFileSync99(join114(repoDir, name), "utf8");
74646
+ text4 = readFileSync100(join115(repoDir, name), "utf8");
74531
74647
  } catch {
74532
74648
  continue;
74533
74649
  }
@@ -74589,7 +74705,7 @@ function citesToken(text4, token) {
74589
74705
  function citesRealHit(text4, hit, repoDir) {
74590
74706
  if (hit.source === "changelog")
74591
74707
  return false;
74592
- return (citesToken(text4, hit.path) || citesToken(text4, basename29(hit.path))) && existsSync80(join114(repoDir, hit.path));
74708
+ return (citesToken(text4, hit.path) || citesToken(text4, basename30(hit.path))) && existsSync81(join115(repoDir, hit.path));
74593
74709
  }
74594
74710
  function renderAlreadyDoneComment(evidence) {
74595
74711
  return ["Loki 10: no change needed. This already appears to be implemented.", "", "Evidence:", ...evidence.map((e10) => `- ${e10}`), ""].join(`
@@ -74790,8 +74906,8 @@ __export(exports_warm, {
74790
74906
  dirtyHash: () => dirtyHash,
74791
74907
  WarmEngine: () => WarmEngine
74792
74908
  });
74793
- import { createHash as createHash32 } from "crypto";
74794
- import { existsSync as existsSync81, mkdirSync as mkdirSync64, readFileSync as readFileSync100, statSync as statSync32, unlinkSync as unlinkSync11 } from "fs";
74909
+ import { createHash as createHash33 } from "crypto";
74910
+ import { existsSync as existsSync82, mkdirSync as mkdirSync64, readFileSync as readFileSync101, statSync as statSync32, unlinkSync as unlinkSync11 } from "fs";
74795
74911
  import { createServer as createServer2 } from "net";
74796
74912
  import { dirname as dirname45, resolve as resolve37 } from "path";
74797
74913
  function speedEnabled() {
@@ -74812,7 +74928,7 @@ function dirtyHash(repoDir) {
74812
74928
  const out3 = git12(repoDir, ["status", "--porcelain", "-uall"]);
74813
74929
  if (out3 === null || out3.trim() === "")
74814
74930
  return "";
74815
- const h10 = createHash32("sha256");
74931
+ const h10 = createHash33("sha256");
74816
74932
  for (const line2 of out3.split(`
74817
74933
  `).filter(Boolean).sort()) {
74818
74934
  h10.update(line2 + `
@@ -74820,8 +74936,8 @@ function dirtyHash(repoDir) {
74820
74936
  const rel = line2.slice(3).split(" -> ").pop().replace(/^"|"$/g, "");
74821
74937
  try {
74822
74938
  const p = resolve37(repoDir, rel);
74823
- if (existsSync81(p) && statSync32(p).isFile() && statSync32(p).size <= MAX_HASHED_BYTES)
74824
- h10.update(readFileSync100(p));
74939
+ if (existsSync82(p) && statSync32(p).isFile() && statSync32(p).size <= MAX_HASHED_BYTES)
74940
+ h10.update(readFileSync101(p));
74825
74941
  } catch {}
74826
74942
  }
74827
74943
  return h10.digest("hex");
@@ -74931,9 +75047,9 @@ var init_warm = __esm(() => {
74931
75047
 
74932
75048
  // ../../loki-ts/src/features/speed/already_done_async.ts
74933
75049
  import { execFile as execFile3 } from "child_process";
74934
- import { mkdirSync as mkdirSync65, mkdtempSync as mkdtempSync15, rmSync as rmSync33 } from "fs";
74935
- import { tmpdir as tmpdir19 } from "os";
74936
- import { join as join115 } from "path";
75050
+ import { mkdirSync as mkdirSync65, mkdtempSync as mkdtempSync16, rmSync as rmSync34 } from "fs";
75051
+ import { tmpdir as tmpdir20 } from "os";
75052
+ import { join as join116 } from "path";
74937
75053
  function hitsUnchangedFromBase(repoDir, baseSha, paths) {
74938
75054
  if (paths.length === 0 || !baseSha)
74939
75055
  return false;
@@ -74957,7 +75073,7 @@ function trackRoot(root) {
74957
75073
  process.on("exit", () => {
74958
75074
  for (const r of liveRoots) {
74959
75075
  try {
74960
- rmSync33(r, { recursive: true, force: true });
75076
+ rmSync34(r, { recursive: true, force: true });
74961
75077
  } catch {}
74962
75078
  }
74963
75079
  });
@@ -74965,29 +75081,29 @@ function trackRoot(root) {
74965
75081
  function dropRoot(root) {
74966
75082
  liveRoots.delete(root);
74967
75083
  try {
74968
- rmSync33(root, { recursive: true, force: true });
75084
+ rmSync34(root, { recursive: true, force: true });
74969
75085
  } catch {}
74970
75086
  }
74971
75087
  function pinBaseTree(ctx, signal) {
74972
75088
  let root;
74973
75089
  try {
74974
- root = mkdtempSync15(join115(tmpdir19(), "loki-already-done-"));
75090
+ root = mkdtempSync16(join116(tmpdir20(), "loki-already-done-"));
74975
75091
  } catch {
74976
75092
  return Promise.resolve(null);
74977
75093
  }
74978
75094
  trackRoot(root);
74979
75095
  try {
74980
- mkdirSync65(join115(root, "tree"));
75096
+ mkdirSync65(join116(root, "tree"));
74981
75097
  } catch {
74982
75098
  dropRoot(root);
74983
75099
  return Promise.resolve(null);
74984
75100
  }
74985
- const tarball = join115(root, "base.tar");
75101
+ const tarball = join116(root, "base.tar");
74986
75102
  const step = (cmd2, args, cwd) => new Promise((res) => {
74987
75103
  execFile3(cmd2, args, { env: process.env, signal, cwd }, (err) => res(!err));
74988
75104
  });
74989
75105
  return (async () => {
74990
- if (!ctx.baseSha || (await safeGitRun(ctx.repoDir, ["archive", "-o", tarball, ctx.baseSha], { signal })).exitCode !== 0 || !await step("tar", ["-x", "-f", tarball, "-C", join115(root, "tree")], root)) {
75106
+ if (!ctx.baseSha || (await safeGitRun(ctx.repoDir, ["archive", "-o", tarball, ctx.baseSha], { signal })).exitCode !== 0 || !await step("tar", ["-x", "-f", tarball, "-C", join116(root, "tree")], root)) {
74991
75107
  dropRoot(root);
74992
75108
  return null;
74993
75109
  }
@@ -75045,7 +75161,7 @@ function deferAlreadyDone(ctx, signal, task, repoMap, testMap, apply) {
75045
75161
  if (!root)
75046
75162
  return;
75047
75163
  try {
75048
- const r = await checkAlreadyDone({ ...ctx, repoDir: join115(root, "tree"), sessions: inner }, check.signal, task, repoMap, testMap);
75164
+ const r = await checkAlreadyDone({ ...ctx, repoDir: join116(root, "tree"), sessions: inner }, check.signal, task, repoMap, testMap);
75049
75165
  const ph = phase;
75050
75166
  if (r && ph !== "done" && !check.signal.aborted) {
75051
75167
  hit = r;
@@ -75071,8 +75187,8 @@ __export(exports_intake, {
75071
75187
  stage: () => stage8,
75072
75188
  runIntake: () => runIntake
75073
75189
  });
75074
- import { appendFileSync as appendFileSync14, existsSync as existsSync82, mkdirSync as mkdirSync66, readFileSync as readFileSync101, writeFileSync as writeFileSync60 } from "fs";
75075
- import { dirname as dirname46, join as join116, resolve as resolve38 } from "path";
75190
+ import { appendFileSync as appendFileSync14, existsSync as existsSync83, mkdirSync as mkdirSync66, readFileSync as readFileSync102, writeFileSync as writeFileSync61 } from "fs";
75191
+ import { dirname as dirname46, join as join117, resolve as resolve38 } from "path";
75076
75192
  function issueRefOf(raw2) {
75077
75193
  return typeof raw2.repo === "string" && raw2.repo && typeof raw2.number === "number" ? `${raw2.repo}#${raw2.number}` : null;
75078
75194
  }
@@ -75092,11 +75208,11 @@ function ensureBranch(repoDir, branch, from) {
75092
75208
  }
75093
75209
  }
75094
75210
  function excludeLokiDir(repoDir) {
75095
- let path = join116(repoDir, ".git", "info", "exclude");
75211
+ let path = join117(repoDir, ".git", "info", "exclude");
75096
75212
  try {
75097
75213
  path = resolve38(repoDir, git13(repoDir, ["rev-parse", "--git-path", "info/exclude"]));
75098
75214
  } catch {}
75099
- const existing = existsSync82(path) ? readFileSync101(path, "utf8") : "";
75215
+ const existing = existsSync83(path) ? readFileSync102(path, "utf8") : "";
75100
75216
  if (existing.split(`
75101
75217
  `).some((l) => l.trim() === ".loki/"))
75102
75218
  return;
@@ -75108,7 +75224,7 @@ function excludeLokiDir(repoDir) {
75108
75224
  `);
75109
75225
  }
75110
75226
  function loadIssue(path) {
75111
- const raw2 = JSON.parse(readFileSync101(path, "utf8"));
75227
+ const raw2 = JSON.parse(readFileSync102(path, "utf8"));
75112
75228
  return { state: typeof raw2.state === "string" ? raw2.state.toLowerCase() : null, closed_by_merged_pr: raw2.closed_by_merged_pr === true };
75113
75229
  }
75114
75230
  function isAlreadyDone(issue) {
@@ -75158,16 +75274,16 @@ async function runIntakeBody(ctx, signal, opts, held) {
75158
75274
  ensureBranch(ctx.repoDir, ctx.branch);
75159
75275
  const tree = git13(ctx.repoDir, ["rev-parse", "HEAD^{tree}"]);
75160
75276
  excludeLokiDir(ctx.repoDir);
75161
- const issueJsonPath = opts.issueJsonPath ?? process.env.LOKI_E10_ISSUE_JSON ?? join116(ctx.runDir, "issue.json");
75277
+ const issueJsonPath = opts.issueJsonPath ?? process.env.LOKI_E10_ISSUE_JSON ?? join117(ctx.runDir, "issue.json");
75162
75278
  const taskText = opts.taskText ?? process.env.LOKI_E10_TASK_TEXT;
75163
75279
  let source;
75164
75280
  let taskSha256;
75165
75281
  let task = taskText ?? "";
75166
75282
  let alreadySatisfied2 = false;
75167
75283
  let issueRef = null;
75168
- if (existsSync82(issueJsonPath)) {
75284
+ if (existsSync83(issueJsonPath)) {
75169
75285
  source = "issue";
75170
- const raw2 = readFileSync101(issueJsonPath, "utf8");
75286
+ const raw2 = readFileSync102(issueJsonPath, "utf8");
75171
75287
  taskSha256 = sha2562(raw2);
75172
75288
  const i = JSON.parse(raw2);
75173
75289
  task = [i.title, i.body].filter((x3) => typeof x3 === "string" && x3 !== "").join(`
@@ -75188,10 +75304,10 @@ async function runIntakeBody(ctx, signal, opts, held) {
75188
75304
  return { status: "completed", data: { ...common, task_sha256: taskSha256, source, base_sha: baseSha, tree, branch: ctx.branch, already_satisfied: true } };
75189
75305
  }
75190
75306
  mkdirSync66(ctx.runDir, { recursive: true });
75191
- const repomapRef = join116(ctx.runDir, "repomap.json");
75307
+ const repomapRef = join117(ctx.runDir, "repomap.json");
75192
75308
  const cacheDir = repoCacheDir(repoKey(null, ctx.repoDir));
75193
75309
  const repoMap = cachedRepoMap(cacheDir, tree, () => buildRepoMap(ctx.repoDir));
75194
- writeFileSync60(repomapRef, JSON.stringify(repoMap));
75310
+ writeFileSync61(repomapRef, JSON.stringify(repoMap));
75195
75311
  let testmap = readTestMapCache(cacheDir, tree);
75196
75312
  if (!testmap) {
75197
75313
  testmap = await ctx.tests.detect(ctx.repoDir);
@@ -75209,8 +75325,8 @@ async function runIntakeBody(ctx, signal, opts, held) {
75209
75325
  const already = speedEnabled() ? null : await checkAlreadyDone(ctx, signal, task, repoMap, testmap);
75210
75326
  const alreadyData = (already2) => {
75211
75327
  const comment = renderAlreadyDoneComment(already2.evidence);
75212
- const bodyFile = join116(ctx.runDir, "already-done-comment.md");
75213
- writeFileSync60(bodyFile, comment, "utf8");
75328
+ const bodyFile = join117(ctx.runDir, "already-done-comment.md");
75329
+ writeFileSync61(bodyFile, comment, "utf8");
75214
75330
  const commentArgv = source === "issue" && issueRef ? buildAlreadyDoneCommentArgv(ctx.runId, issueRef, bodyFile) : undefined;
75215
75331
  return { already_satisfied: true, evidence: already2.evidence, iteration_ids: [`${ctx.runId}-already-done`], comment, ...commentArgv ? { comment_argv: commentArgv } : {} };
75216
75332
  };
@@ -75306,6 +75422,7 @@ var init_fix = __esm(() => {
75306
75422
  init_anti_loop();
75307
75423
  init_session_resume();
75308
75424
  init_conflict_resume();
75425
+ init_implement();
75309
75426
  init_install();
75310
75427
  fixStage = {
75311
75428
  name: "fix",
@@ -75349,6 +75466,10 @@ var init_fix = __esm(() => {
75349
75466
  const last = r.ids[r.ids.length - 1], rc2 = await resumeAfterConflict(ctx, { ...sessionBase, iterationId: last, brief: fullBrief }, r.session);
75350
75467
  r = { ...r, session: rc2.session, ids: rc2.iterationId === last ? r.ids : [...r.ids, rc2.iterationId] };
75351
75468
  }
75469
+ const ro = prior.wall?.readOnlyFiles ?? [], wd2 = r.session.markers.specConflict && !r.session.killed ? await adjudicateWallConflict(ctx, { ...sessionBase, iterationId: r.ids[r.ids.length - 1], brief: fullBrief }, r.session, ro) : null;
75470
+ if (wd2)
75471
+ r = { ...r, session: wd2.session, ids: [...r.ids, ...wd2.ids] };
75472
+ const testsReverted = restoreReadOnly(ro), wallDefect = wd2?.defect ?? prior.fix?.wall_defect;
75352
75473
  const treeAfter = treeFingerprint(ctx.repoDir, ctx.baseSha), conflict = r.session.markers.specConflict && !r.session.killed && treeBefore !== null && treeBefore === treeAfter ? r.session.markers.specConflict : null;
75353
75474
  ctx.emit("fix.round", "fix", {
75354
75475
  round: round2,
@@ -75372,6 +75493,8 @@ var init_fix = __esm(() => {
75372
75493
  tree_after: treeAfter,
75373
75494
  ...conflict ? { exit: "spec_conflict", spec_conflict_reason: conflict } : {},
75374
75495
  killed: r.session.killed,
75496
+ tests_reverted: testsReverted,
75497
+ ...wallDefect ? { wall_defect: wallDefect } : {},
75375
75498
  cascade: repeated,
75376
75499
  model: actualModel,
75377
75500
  ...stallEsc ? { stall_escalated: true } : {},
@@ -75394,7 +75517,7 @@ __export(exports_keys_cmd, {
75394
75517
  takePubkey: () => takePubkey,
75395
75518
  main: () => main5
75396
75519
  });
75397
- import { readFileSync as readFileSync102 } from "fs";
75520
+ import { readFileSync as readFileSync103 } from "fs";
75398
75521
  import { parseArgs } from "util";
75399
75522
  import { createPublicKey as createPublicKey4 } from "crypto";
75400
75523
  function takePubkey(args) {
@@ -75407,7 +75530,7 @@ function takePubkey(args) {
75407
75530
  return { args: rest };
75408
75531
  if (!(file = pubkey[0]))
75409
75532
  throw new Error("--pubkey requires a file argument");
75410
- const t = readFileSync102(file, "utf8"), key = createPublicKey4(t.trim().startsWith("{") ? { key: JSON.parse(t), format: "jwk" } : t);
75533
+ const t = readFileSync103(file, "utf8"), key = createPublicKey4(t.trim().startsWith("{") ? { key: JSON.parse(t), format: "jwk" } : t);
75411
75534
  return key.asymmetricKeyType === "ed25519" ? { args: rest, pubkey: key } : { args: rest, error: `cannot read an Ed25519 public key from ${file}` };
75412
75535
  } catch (e10) {
75413
75536
  return { args: [], error: file ? `cannot read an Ed25519 public key from ${file}` : e10.message.replace(/^./, (c) => c.toLowerCase()) };
@@ -75665,7 +75788,7 @@ var groupRoute = async (repoDir, rawGroup) => {
75665
75788
  };
75666
75789
 
75667
75790
  // ../../loki-ts/src/engine10/modernize/types.ts
75668
- import { join as join117 } from "path";
75791
+ import { join as join118 } from "path";
75669
75792
  function makeModernizeId(now2 = new Date) {
75670
75793
  const utc = now2.toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z");
75671
75794
  const short = Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0");
@@ -75675,13 +75798,13 @@ function isModernizeId(mid) {
75675
75798
  return MID_RE.test(mid);
75676
75799
  }
75677
75800
  function modernizeRoot(repoDir, mid) {
75678
- return join117(repoDir, ".loki", "modernize", mid);
75801
+ return join118(repoDir, ".loki", "modernize", mid);
75679
75802
  }
75680
75803
  function modernizeEventsPath(repoDir, mid) {
75681
- return join117(modernizeRoot(repoDir, mid), "events.jsonl");
75804
+ return join118(modernizeRoot(repoDir, mid), "events.jsonl");
75682
75805
  }
75683
75806
  function planPath(repoDir, mid) {
75684
- return join117(modernizeRoot(repoDir, mid), "plan.json");
75807
+ return join118(modernizeRoot(repoDir, mid), "plan.json");
75685
75808
  }
75686
75809
  function isSafeUnitId(unit) {
75687
75810
  return typeof unit === "string" && unit.length <= MAX_UNIT_ID && UNIT_ID_RE2.test(unit) && !unit.includes("..");
@@ -75692,13 +75815,13 @@ function encodeUnitId(unit) {
75692
75815
  return unit.replace(/\//g, "%2F");
75693
75816
  }
75694
75817
  function oracleDir(repoDir, mid, unit) {
75695
- return join117(modernizeRoot(repoDir, mid), "oracle", encodeUnitId(unit));
75818
+ return join118(modernizeRoot(repoDir, mid), "oracle", encodeUnitId(unit));
75696
75819
  }
75697
75820
  function reportJsonPath(repoDir, mid) {
75698
- return join117(modernizeRoot(repoDir, mid), "report.json");
75821
+ return join118(modernizeRoot(repoDir, mid), "report.json");
75699
75822
  }
75700
75823
  function reportMdPath(repoDir, mid) {
75701
- return join117(modernizeRoot(repoDir, mid), "report.md");
75824
+ return join118(modernizeRoot(repoDir, mid), "report.md");
75702
75825
  }
75703
75826
  var MID_RE, UNIT_ID_SEGMENT = "[A-Za-z0-9][A-Za-z0-9_.-]*", UNIT_ID_RE2, MAX_UNIT_ID = 128;
75704
75827
  var init_types2 = __esm(() => {
@@ -75737,14 +75860,14 @@ __export(exports_dashboard, {
75737
75860
  modernizeRoute: () => modernizeRoute,
75738
75861
  listModernizeIds: () => listModernizeIds
75739
75862
  });
75740
- import { existsSync as existsSync83, readdirSync as readdirSync36 } from "fs";
75741
- import { join as join118 } from "path";
75863
+ import { existsSync as existsSync84, readdirSync as readdirSync36 } from "fs";
75864
+ import { join as join119 } from "path";
75742
75865
  function modernizeDir(repoDir) {
75743
- return join118(repoDir, ".loki", "modernize");
75866
+ return join119(repoDir, ".loki", "modernize");
75744
75867
  }
75745
75868
  function listModernizeIds(repoDir) {
75746
75869
  const dir = modernizeDir(repoDir);
75747
- if (!existsSync83(dir))
75870
+ if (!existsSync84(dir))
75748
75871
  return [];
75749
75872
  return readdirSync36(dir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name).sort();
75750
75873
  }
@@ -76075,11 +76198,11 @@ var init_engine10_dashboard = __esm(() => {
76075
76198
  });
76076
76199
 
76077
76200
  // ../../loki-ts/src/engine10/modernize/inventory.ts
76078
- import { readFileSync as readFileSync103 } from "fs";
76079
- import { extname as extname3, join as join119 } from "path";
76201
+ import { readFileSync as readFileSync104 } from "fs";
76202
+ import { extname as extname3, join as join120 } from "path";
76080
76203
  function readCapped2(absPath) {
76081
76204
  try {
76082
- return readFileSync103(absPath, "utf8").slice(0, MAX_SCAN_BYTES2);
76205
+ return readFileSync104(absPath, "utf8").slice(0, MAX_SCAN_BYTES2);
76083
76206
  } catch {
76084
76207
  return "";
76085
76208
  }
@@ -76096,9 +76219,9 @@ function detectEntryPoints(repoDir, files) {
76096
76219
  const out3 = [];
76097
76220
  for (const rel of files) {
76098
76221
  const ext = extname3(rel);
76099
- if (ext === ".py" && PY_MAIN_RE.test(readCapped2(join119(repoDir, rel))))
76222
+ if (ext === ".py" && PY_MAIN_RE.test(readCapped2(join120(repoDir, rel))))
76100
76223
  out3.push(rel);
76101
- else if (ext === ".java" && JAVA_MAIN_RE.test(readCapped2(join119(repoDir, rel))))
76224
+ else if (ext === ".java" && JAVA_MAIN_RE.test(readCapped2(join120(repoDir, rel))))
76102
76225
  out3.push(rel);
76103
76226
  }
76104
76227
  return out3;
@@ -76148,7 +76271,7 @@ var init_inventory = __esm(() => {
76148
76271
  });
76149
76272
 
76150
76273
  // ../../loki-ts/src/engine10/modernize/lang/python.ts
76151
- import { join as join120 } from "path";
76274
+ import { join as join121 } from "path";
76152
76275
  async function buildPythonGraph(repoDir, files, opts = {}) {
76153
76276
  if (files.length === 0)
76154
76277
  return { graph: { nodes: [], edges: [] }, unresolved: [] };
@@ -76187,7 +76310,7 @@ var init_python2 = __esm(() => {
76187
76310
  init_paths();
76188
76311
  init_python();
76189
76312
  init_shell();
76190
- SCRIPT = join120(REPO_ROOT, "autonomy", "lib", "modernize", "py_imports.py");
76313
+ SCRIPT = join121(REPO_ROOT, "autonomy", "lib", "modernize", "py_imports.py");
76191
76314
  });
76192
76315
 
76193
76316
  // ../../loki-ts/src/engine10/modernize/cluster.ts
@@ -76365,9 +76488,9 @@ var init_codemod = __esm(() => {
76365
76488
  });
76366
76489
 
76367
76490
  // ../../loki-ts/src/engine10/modernize/oracle/seal.ts
76368
- import { createHash as createHash33 } from "crypto";
76369
- import { existsSync as existsSync84, mkdirSync as mkdirSync67, readFileSync as readFileSync104, writeFileSync as writeFileSync61 } from "fs";
76370
- import { join as join121 } from "path";
76491
+ import { createHash as createHash34 } from "crypto";
76492
+ import { existsSync as existsSync85, mkdirSync as mkdirSync67, readFileSync as readFileSync105, writeFileSync as writeFileSync62 } from "fs";
76493
+ import { join as join122 } from "path";
76371
76494
  function normalizersSha(n11) {
76372
76495
  return sha2564(JSON.stringify({
76373
76496
  float_tolerance: n11.float_tolerance,
@@ -76429,25 +76552,25 @@ function alreadySealedInLog(repoDir, mid, unit) {
76429
76552
  }
76430
76553
  function sealOracle(repoDir, mid, unit, log, normalizers = DEFAULT_NORMALIZERS) {
76431
76554
  const dir = oracleDir(repoDir, mid, unit);
76432
- const casesPath = join121(dir, "cases.jsonl");
76433
- const coveragePath = join121(dir, "coverage.json");
76434
- const sealedPath = join121(dir, "sealed.json");
76555
+ const casesPath = join122(dir, "cases.jsonl");
76556
+ const coveragePath = join122(dir, "coverage.json");
76557
+ const sealedPath = join122(dir, "sealed.json");
76435
76558
  if (alreadySealedInLog(repoDir, mid, unit)) {
76436
76559
  throw new Error(`oracle seal: ${unit} already has a sealing event in the modernize log; re-seal refused (seal is write-once)`);
76437
76560
  }
76438
- if (existsSync84(sealedPath)) {
76561
+ if (existsSync85(sealedPath)) {
76439
76562
  throw new Error(`oracle seal: ${unit} is already sealed; re-seal refused (seal is write-once)`);
76440
76563
  }
76441
- if (!existsSync84(casesPath))
76564
+ if (!existsSync85(casesPath))
76442
76565
  throw new Error(`oracle seal: missing ${casesPath}`);
76443
- if (!existsSync84(coveragePath))
76566
+ if (!existsSync85(coveragePath))
76444
76567
  throw new Error(`oracle seal: missing ${coveragePath}`);
76445
- const casesRaw = readFileSync104(casesPath, "utf8");
76446
- const coverageRaw = readFileSync104(coveragePath, "utf8");
76568
+ const casesRaw = readFileSync105(casesPath, "utf8");
76569
+ const coverageRaw = readFileSync105(coveragePath, "utf8");
76447
76570
  const normalizersHash = normalizersSha(normalizers);
76448
76571
  const sealed = buildSealedOracle(unit, casesRaw, coverageRaw, normalizersHash);
76449
76572
  mkdirSync67(dir, { recursive: true });
76450
- writeFileSync61(sealedPath, JSON.stringify(sealed, null, 2));
76573
+ writeFileSync62(sealedPath, JSON.stringify(sealed, null, 2));
76451
76574
  log.append(sealed.verdict === "PROVEN_ORACLE" ? "oracle.captured" : "oracle.flagged", {
76452
76575
  unit,
76453
76576
  cases: sealed.case_count,
@@ -76462,24 +76585,24 @@ function sealOracle(repoDir, mid, unit, log, normalizers = DEFAULT_NORMALIZERS)
76462
76585
  }
76463
76586
  function verifySeal(repoDir, mid, unit) {
76464
76587
  const dir = oracleDir(repoDir, mid, unit);
76465
- const sealedPath = join121(dir, "sealed.json");
76466
- const casesPath = join121(dir, "cases.jsonl");
76467
- const coveragePath = join121(dir, "coverage.json");
76468
- if (!existsSync84(sealedPath))
76588
+ const sealedPath = join122(dir, "sealed.json");
76589
+ const casesPath = join122(dir, "cases.jsonl");
76590
+ const coveragePath = join122(dir, "coverage.json");
76591
+ if (!existsSync85(sealedPath))
76469
76592
  return { ok: false, reason: "no sealed.json" };
76470
- if (!existsSync84(casesPath))
76593
+ if (!existsSync85(casesPath))
76471
76594
  return { ok: false, reason: "missing cases.jsonl" };
76472
- if (!existsSync84(coveragePath))
76595
+ if (!existsSync85(coveragePath))
76473
76596
  return { ok: false, reason: "missing coverage.json" };
76474
76597
  const sealEvent = readModernizeEvents(repoDir, mid).find((e10) => (e10.type === "oracle.captured" || e10.type === "oracle.flagged") && e10.data.unit === unit);
76475
76598
  if (!sealEvent) {
76476
76599
  return { ok: false, reason: "no sealing event for this unit in the modernize log; sealed.json is not anchored" };
76477
76600
  }
76478
- const casesRaw = readFileSync104(casesPath, "utf8");
76601
+ const casesRaw = readFileSync105(casesPath, "utf8");
76479
76602
  if (sha2564(casesRaw) !== sealEvent.data.cases_sha256) {
76480
76603
  return { ok: false, reason: "cases.jsonl does not match the sealing event's hash (tampered or re-captured)" };
76481
76604
  }
76482
- const coverageRaw = readFileSync104(coveragePath, "utf8");
76605
+ const coverageRaw = readFileSync105(coveragePath, "utf8");
76483
76606
  if (sha2564(coverageRaw) !== sealEvent.data.coverage_sha256) {
76484
76607
  return { ok: false, reason: "coverage.json does not match the sealing event's hash (tampered or re-captured)" };
76485
76608
  }
@@ -76495,13 +76618,13 @@ function verifySeal(repoDir, mid, unit) {
76495
76618
  reason: `verdict does not match the sealing event (event type ${sealEvent.type}, recomputed verdict ${recomputed.verdict})`
76496
76619
  };
76497
76620
  }
76498
- const sealed = JSON.parse(readFileSync104(sealedPath, "utf8"));
76621
+ const sealed = JSON.parse(readFileSync105(sealedPath, "utf8"));
76499
76622
  if (JSON.stringify(sealed) !== JSON.stringify(recomputed)) {
76500
76623
  return { ok: false, reason: "sealed.json does not match the record recomputed from cases.jsonl and coverage.json (hand-edited)" };
76501
76624
  }
76502
76625
  return { ok: true };
76503
76626
  }
76504
- var sha2564 = (s) => createHash33("sha256").update(s).digest("hex"), DEFAULT_NORMALIZERS, HELD_OUT_FRACTION = 0.2, COVERAGE_FLOOR_PCT = 80, MIN_CASES_FOR_HELD_OUT = 2;
76627
+ var sha2564 = (s) => createHash34("sha256").update(s).digest("hex"), DEFAULT_NORMALIZERS, HELD_OUT_FRACTION = 0.2, COVERAGE_FLOOR_PCT = 80, MIN_CASES_FOR_HELD_OUT = 2;
76505
76628
  var init_seal2 = __esm(() => {
76506
76629
  init_holdout();
76507
76630
  init_log();
@@ -76511,9 +76634,9 @@ var init_seal2 = __esm(() => {
76511
76634
 
76512
76635
  // ../../loki-ts/src/engine10/modernize/oracle/search.ts
76513
76636
  import { spawnSync as spawnSync18 } from "child_process";
76514
- import { copyFileSync as copyFileSync6, existsSync as existsSync85, linkSync as linkSync4, mkdirSync as mkdirSync68, mkdtempSync as mkdtempSync16, readFileSync as readFileSync105, renameSync as renameSync22, rmSync as rmSync34, rmdirSync as rmdirSync2, writeFileSync as writeFileSync62 } from "fs";
76515
- import { tmpdir as tmpdir20 } from "os";
76516
- import { basename as basename30, dirname as dirname47, join as join122 } from "path";
76637
+ import { copyFileSync as copyFileSync6, existsSync as existsSync86, linkSync as linkSync4, mkdirSync as mkdirSync68, mkdtempSync as mkdtempSync17, readFileSync as readFileSync106, renameSync as renameSync22, rmSync as rmSync35, rmdirSync as rmdirSync2, writeFileSync as writeFileSync63 } from "fs";
76638
+ import { tmpdir as tmpdir21 } from "os";
76639
+ import { basename as basename31, dirname as dirname47, join as join123 } from "path";
76517
76640
  function search(unitSource, seedCases, propose, runCapture, opts = {}) {
76518
76641
  const maxRounds = opts.maxRounds ?? 10;
76519
76642
  const plateauLimit = opts.plateauRounds ?? 2;
@@ -76570,12 +76693,12 @@ function realCaptureRunner(unitPath, cases, outPath) {
76570
76693
  return captureFailed("old runtime unavailable");
76571
76694
  let dir = "";
76572
76695
  try {
76573
- dir = mkdtempSync16(join122(tmpdir20(), "m10-search-"));
76574
- const casesFile = join122(dir, "cases.jsonl");
76575
- const outFile = join122(dir, "out.jsonl");
76576
- const covFile = join122(dir, "coverage.json");
76696
+ dir = mkdtempSync17(join123(tmpdir21(), "m10-search-"));
76697
+ const casesFile = join123(dir, "cases.jsonl");
76698
+ const outFile = join123(dir, "out.jsonl");
76699
+ const covFile = join123(dir, "coverage.json");
76577
76700
  const lines2 = cases.map((c) => JSON.stringify({ entry: c.entry, args: c.args, kwargs: c.kwargs }));
76578
- writeFileSync62(casesFile, lines2.length ? lines2.join(`
76701
+ writeFileSync63(casesFile, lines2.length ? lines2.join(`
76579
76702
  `) + `
76580
76703
  ` : "");
76581
76704
  const r = spawnSync18(py2, [
@@ -76594,7 +76717,7 @@ function realCaptureRunner(unitPath, cases, outPath) {
76594
76717
  `).find((l) => l.trim().length > 0) ?? "(no stderr)";
76595
76718
  return captureFailed(`py_capture.py exit ${r.status}: ${firstErrLine}`);
76596
76719
  }
76597
- const raw2 = JSON.parse(readFileSync105(covFile, "utf8"));
76720
+ const raw2 = JSON.parse(readFileSync106(covFile, "utf8"));
76598
76721
  if (outPath)
76599
76722
  copyFileSync6(outFile, outPath);
76600
76723
  return {
@@ -76607,7 +76730,7 @@ function realCaptureRunner(unitPath, cases, outPath) {
76607
76730
  return captureFailed(`capture error: ${e10 instanceof Error ? e10.message : String(e10)}`);
76608
76731
  } finally {
76609
76732
  if (dir)
76610
- rmSync34(dir, { recursive: true, force: true });
76733
+ rmSync35(dir, { recursive: true, force: true });
76611
76734
  }
76612
76735
  }
76613
76736
  function resolveOldRuntimeSync() {
@@ -76621,13 +76744,13 @@ function resolveOldRuntimeSync() {
76621
76744
  }
76622
76745
  function makeProposeInputs(session, cap = 20) {
76623
76746
  return (unitPath, missing, round2) => {
76624
- const cwd = mkdtempSync16(join122(tmpdir20(), "m27-propose-"));
76747
+ const cwd = mkdtempSync17(join123(tmpdir21(), "m27-propose-"));
76625
76748
  try {
76626
- const unitFile = join122(cwd, basename30(unitPath));
76749
+ const unitFile = join123(cwd, basename31(unitPath));
76627
76750
  copyFileSync6(unitPath, unitFile);
76628
76751
  session({ cwd, env: tokenFreeEnv(), unitFile, missing, round: round2 });
76629
76752
  const out3 = [];
76630
- for (const line2 of readFileSync105(join122(cwd, "proposals.jsonl"), "utf8").split(`
76753
+ for (const line2 of readFileSync106(join123(cwd, "proposals.jsonl"), "utf8").split(`
76631
76754
  `)) {
76632
76755
  try {
76633
76756
  const c = JSON.parse(line2);
@@ -76639,13 +76762,13 @@ function makeProposeInputs(session, cap = 20) {
76639
76762
  } catch {
76640
76763
  return [];
76641
76764
  } finally {
76642
- rmSync34(cwd, { recursive: true, force: true });
76765
+ rmSync35(cwd, { recursive: true, force: true });
76643
76766
  }
76644
76767
  };
76645
76768
  }
76646
76769
  function captureUnitOracle(a) {
76647
76770
  const dir = oracleDir(a.repoDir, a.mid, a.unit);
76648
- if (existsSync85(join122(dir, "cases.jsonl")) || alreadySealedInLog(a.repoDir, a.mid, a.unit)) {
76771
+ if (existsSync86(join123(dir, "cases.jsonl")) || alreadySealedInLog(a.repoDir, a.mid, a.unit)) {
76649
76772
  return { ok: false, reason: "oracle already captured (write-once)" };
76650
76773
  }
76651
76774
  const run2 = a.runCapture ?? realCaptureRunner;
@@ -76665,15 +76788,15 @@ function captureUnitOracle(a) {
76665
76788
  }
76666
76789
  if (r.cases.length === 0)
76667
76790
  return { ok: false, reason: "no cases captured" };
76668
- const scratch = mkdtempSync16(join122(tmpdir20(), "m27-replay-"));
76669
- const t12 = join122(scratch, "cases"), t22 = join122(scratch, "replay");
76791
+ const scratch = mkdtempSync17(join123(tmpdir21(), "m27-replay-"));
76792
+ const t12 = join123(scratch, "cases"), t22 = join123(scratch, "replay");
76670
76793
  const created = [];
76671
- for (let p = dir;!existsSync85(p) && !created.includes(p); p = dirname47(p))
76794
+ for (let p = dir;!existsSync86(p) && !created.includes(p); p = dirname47(p))
76672
76795
  created.push(p);
76673
- const read2 = (p) => readFileSync105(p, "utf8").split(`
76796
+ const read2 = (p) => readFileSync106(p, "utf8").split(`
76674
76797
  `).filter(Boolean).map((l) => JSON.parse(l));
76675
- const tmpCases = join122(dir, `.cases.${process.pid}.tmp`);
76676
- const tmpCov = join122(dir, `.coverage.${process.pid}.tmp`);
76798
+ const tmpCases = join123(dir, `.cases.${process.pid}.tmp`);
76799
+ const tmpCov = join123(dir, `.coverage.${process.pid}.tmp`);
76677
76800
  try {
76678
76801
  const cov = run2(a.unitPath, r.cases, t12);
76679
76802
  const cov2 = run2(a.unitPath, r.cases, t22);
@@ -76689,10 +76812,10 @@ function captureUnitOracle(a) {
76689
76812
  }
76690
76813
  });
76691
76814
  mkdirSync68(dir, { recursive: true });
76692
- writeFileSync62(tmpCases, recs.map((x3) => JSON.stringify(x3)).join(`
76815
+ writeFileSync63(tmpCases, recs.map((x3) => JSON.stringify(x3)).join(`
76693
76816
  `) + `
76694
76817
  `);
76695
- writeFileSync62(tmpCov, JSON.stringify({
76818
+ writeFileSync63(tmpCov, JSON.stringify({
76696
76819
  unit: a.unit,
76697
76820
  entries: [...new Set(r.cases.map((c) => c.entry))],
76698
76821
  cases: r.cases.length,
@@ -76701,19 +76824,19 @@ function captureUnitOracle(a) {
76701
76824
  branch_pct: cov.branchPct,
76702
76825
  missing: cov.missing
76703
76826
  }));
76704
- if (existsSync85(join122(dir, "cases.jsonl")))
76827
+ if (existsSync86(join123(dir, "cases.jsonl")))
76705
76828
  return { ok: false, reason: "oracle already captured (write-once)" };
76706
- renameSync22(tmpCov, join122(dir, "coverage.json"));
76707
- (a.link ?? linkSync4)(tmpCases, join122(dir, "cases.jsonl"));
76829
+ renameSync22(tmpCov, join123(dir, "coverage.json"));
76830
+ (a.link ?? linkSync4)(tmpCases, join123(dir, "cases.jsonl"));
76708
76831
  return { ok: true, cases: r.cases.length, branchPct: cov.branchPct, stoppedReason: r.stoppedReason };
76709
76832
  } catch (e10) {
76710
76833
  return { ok: false, reason: `capture error: ${e10 instanceof Error ? e10.message : String(e10)}` };
76711
76834
  } finally {
76712
- rmSync34(scratch, { recursive: true, force: true });
76835
+ rmSync35(scratch, { recursive: true, force: true });
76713
76836
  for (const t of [tmpCases, tmpCov])
76714
- rmSync34(t, { force: true });
76715
- if (created[0] === dir && !existsSync85(join122(dir, "cases.jsonl")))
76716
- rmSync34(join122(dir, "coverage.json"), { force: true });
76837
+ rmSync35(t, { force: true });
76838
+ if (created[0] === dir && !existsSync86(join123(dir, "cases.jsonl")))
76839
+ rmSync35(join123(dir, "coverage.json"), { force: true });
76717
76840
  for (const p of created) {
76718
76841
  try {
76719
76842
  rmdirSync2(p);
@@ -76729,12 +76852,12 @@ var init_search = __esm(() => {
76729
76852
  init_safe_git();
76730
76853
  init_types2();
76731
76854
  init_seal2();
76732
- PY_CAPTURE_SCRIPT = join122(REPO_ROOT, "autonomy", "lib", "modernize", "py_capture.py");
76855
+ PY_CAPTURE_SCRIPT = join123(REPO_ROOT, "autonomy", "lib", "modernize", "py_capture.py");
76733
76856
  });
76734
76857
 
76735
76858
  // ../../loki-ts/src/engine10/modernize/equiv.ts
76736
- import { readFileSync as readFileSync106 } from "fs";
76737
- import { join as join123 } from "path";
76859
+ import { readFileSync as readFileSync107 } from "fs";
76860
+ import { join as join124 } from "path";
76738
76861
  function parseCases(raw2) {
76739
76862
  const out3 = [];
76740
76863
  for (const line2 of raw2.split(`
@@ -76929,11 +77052,11 @@ function checkEquivalence(repoDir, mid, unit, newTreeDir, normalizers, runNew, l
76929
77052
  return notProvenResult(unit, "normalizers invalid: skip_fields covers every field, nothing would be compared", log);
76930
77053
  }
76931
77054
  const dir = oracleDir(repoDir, mid, unit);
76932
- const sealed = JSON.parse(readFileSync106(join123(dir, "sealed.json"), "utf8"));
77055
+ const sealed = JSON.parse(readFileSync107(join124(dir, "sealed.json"), "utf8"));
76933
77056
  const normCheck = verifyNormalizersAgainstSeal(sealed, normalizers);
76934
77057
  if (!normCheck.ok)
76935
77058
  return notProvenResult(unit, `normalizers: ${normCheck.reason ?? "check failed"}`, log);
76936
- const records = parseCases(readFileSync106(join123(dir, "cases.jsonl"), "utf8"));
77059
+ const records = parseCases(readFileSync107(join124(dir, "cases.jsonl"), "utf8"));
76937
77060
  const heldOutSet = new Set(sealed.held_out);
76938
77061
  let pass = 0;
76939
77062
  let fail2 = 0;
@@ -77124,7 +77247,7 @@ var init_reslice = __esm(() => {
77124
77247
  });
77125
77248
 
77126
77249
  // ../../loki-ts/src/engine10/modernize/scheduler.ts
77127
- import { join as join124 } from "path";
77250
+ import { join as join125 } from "path";
77128
77251
  function mergeOnce(unit, ops, log, completed, worktree) {
77129
77252
  if (completed.has(unit))
77130
77253
  return "already_completed";
@@ -77198,8 +77321,8 @@ function gitMergeOps(repoDir, mid, seam = {}) {
77198
77321
  function clampWorkers(n11) {
77199
77322
  return Number.isFinite(n11) ? Math.min(MAX_LOCAL_WORKERS, Math.max(1, Math.floor(n11))) : DEFAULT_WORKERS;
77200
77323
  }
77201
- function firstModel(unit) {
77202
- return unit.highRisk ? "opus" : "sonnet";
77324
+ function firstModel(unit, runModel) {
77325
+ return unitModel(unit.highRisk ? "opus" : "sonnet", runModel);
77203
77326
  }
77204
77327
  async function schedule(plan, opts) {
77205
77328
  const wt = opts.worktrees ?? gitWorktrees;
@@ -77239,13 +77362,13 @@ async function schedule(plan, opts) {
77239
77362
  let attempts = 0;
77240
77363
  let last = null;
77241
77364
  let reason;
77242
- const steps = [[0, firstModel(unit)], [1, "opus"], [2, "opus"]];
77365
+ const steps = [[0, firstModel(unit, opts.runModel)], [1, unitModel("opus", opts.runModel)], [2, unitModel("opus", opts.runModel)]];
77243
77366
  for (const [variant, model] of steps) {
77244
77367
  if (attempts > 0 && (stopped(0) || cap != null && unitCost >= cap)) {
77245
77368
  reason = hit ? "budget stop" : "per-unit cost cap reached";
77246
77369
  break;
77247
77370
  }
77248
- const path = join124(modernizeRoot(opts.repoDir, opts.mid), "wt", variant === 0 ? encodeUnitId(unit.id) : `${encodeUnitId(unit.id)}${VARIANT_SEP}${variant}`);
77371
+ const path = join125(modernizeRoot(opts.repoDir, opts.mid), "wt", variant === 0 ? encodeUnitId(unit.id) : `${encodeUnitId(unit.id)}${VARIANT_SEP}${variant}`);
77249
77372
  let outcome;
77250
77373
  attempts++;
77251
77374
  let resumeRunId;
@@ -77332,6 +77455,7 @@ async function schedule(plan, opts) {
77332
77455
  var MAX_LOCAL_WORKERS = 32, DEFAULT_WORKERS = 4, UNIT_COST_CAP_FACTOR = 3, VARIANT_SEP = "~v", gitWorktrees;
77333
77456
  var init_scheduler = __esm(() => {
77334
77457
  init_safe_git();
77458
+ init_unit_model();
77335
77459
  init_types2();
77336
77460
  gitWorktrees = {
77337
77461
  create(repoDir, path, baseSha) {
@@ -77353,21 +77477,21 @@ var init_scheduler = __esm(() => {
77353
77477
  });
77354
77478
 
77355
77479
  // ../../loki-ts/src/engine10/modernize/resume.ts
77356
- import { existsSync as existsSync86, readFileSync as readFileSync107 } from "fs";
77480
+ import { existsSync as existsSync87, readFileSync as readFileSync108 } from "fs";
77357
77481
  function loadResumeState(repoDir, mid) {
77358
77482
  const path = modernizeEventsPath(repoDir, mid);
77359
- if (!existsSync86(path))
77483
+ if (!existsSync87(path))
77360
77484
  return { ok: false, reason: `no modernize log at ${path}` };
77361
77485
  let text4;
77362
77486
  try {
77363
- text4 = readFileSync107(path, "utf8");
77487
+ text4 = readFileSync108(path, "utf8");
77364
77488
  } catch (e10) {
77365
77489
  return { ok: false, reason: `modernize log unreadable: ${e10 instanceof Error ? e10.message : String(e10)}` };
77366
77490
  }
77367
77491
  const pj2 = planPath(repoDir, mid);
77368
- if (existsSync86(pj2)) {
77492
+ if (existsSync87(pj2)) {
77369
77493
  try {
77370
- JSON.parse(readFileSync107(pj2, "utf8"));
77494
+ JSON.parse(readFileSync108(pj2, "utf8"));
77371
77495
  } catch {
77372
77496
  return { ok: false, reason: `plan.json is corrupt or partial: ${pj2}` };
77373
77497
  }
@@ -77480,7 +77604,7 @@ var init_resume = __esm(() => {
77480
77604
  });
77481
77605
 
77482
77606
  // ../../loki-ts/src/engine10/modernize/report.ts
77483
- import { mkdirSync as mkdirSync69, readFileSync as readFileSync108, writeFileSync as writeFileSync63 } from "fs";
77607
+ import { mkdirSync as mkdirSync69, readFileSync as readFileSync109, writeFileSync as writeFileSync64 } from "fs";
77484
77608
  import { dirname as dirname48 } from "path";
77485
77609
  function buildReport(o) {
77486
77610
  const units = o.units.map((x3) => ({ unit: x3.unit, verdict: x3.verdict, not_proven: [...x3.not_proven], rate: x3.rate, branchPct: x3.branchPct, receiptPath: x3.receiptPath, receiptSha256: x3.receiptSha256 }));
@@ -77525,9 +77649,9 @@ function writeReport(o) {
77525
77649
  const sealed = sealReport(buildReport(o), o.sign);
77526
77650
  const jp2 = reportJsonPath(o.repoDir, o.mid);
77527
77651
  mkdirSync69(dirname48(jp2), { recursive: true });
77528
- writeFileSync63(jp2, JSON.stringify(sealed, null, 2) + `
77652
+ writeFileSync64(jp2, JSON.stringify(sealed, null, 2) + `
77529
77653
  `, "utf8");
77530
- writeFileSync63(reportMdPath(o.repoDir, o.mid), renderReportMd(sealed), "utf8");
77654
+ writeFileSync64(reportMdPath(o.repoDir, o.mid), renderReportMd(sealed), "utf8");
77531
77655
  o.log?.append("modernize.completed", { verdict: sealed.verdict, blocking_units: sealed.blocking_units, blocking_waves: sealed.blocking_waves, report_sha256: sealed.report_sha256 });
77532
77656
  return sealed;
77533
77657
  }
@@ -77540,8 +77664,8 @@ var init_report = __esm(() => {
77540
77664
  });
77541
77665
 
77542
77666
  // ../../loki-ts/src/engine10/modernize/ship.ts
77543
- import { mkdirSync as mkdirSync70, writeFileSync as writeFileSync64 } from "fs";
77544
- import { join as join125 } from "path";
77667
+ import { mkdirSync as mkdirSync70, writeFileSync as writeFileSync65 } from "fs";
77668
+ import { join as join126 } from "path";
77545
77669
  function waveIsDraft(verdict, units) {
77546
77670
  return verdict === null || verdict.verified !== true || units.length === 0 || units.some((x3) => x3.verdict !== "PROVEN");
77547
77671
  }
@@ -77562,10 +77686,10 @@ function shipWave(o) {
77562
77686
  return fail2("no pinned origin: refusing to push (Rule of Two)");
77563
77687
  if (draft)
77564
77688
  return fail2("wave not verified: branch stays local, not pushed");
77565
- const dir = join125(o.repoDir, ".loki", "modernize", o.mid);
77689
+ const dir = join126(o.repoDir, ".loki", "modernize", o.mid);
77566
77690
  mkdirSync70(dir, { recursive: true });
77567
- const bodyFile = join125(dir, `wave-${o.wave}-pr-body.md`);
77568
- writeFileSync64(bodyFile, renderWaveBody(o.wave, o.verdict, o.units), "utf8");
77691
+ const bodyFile = join126(dir, `wave-${o.wave}-pr-body.md`);
77692
+ writeFileSync65(bodyFile, renderWaveBody(o.wave, o.verdict, o.units), "utf8");
77569
77693
  const r = (o.push ?? runPushPr)({ repoDir: o.repoDir, branch: o.branch, title: `Loki modernize: wave ${o.wave}`, bodyFile, draft, pinnedOrigin });
77570
77694
  if (!r.ok)
77571
77695
  return fail2(r.reason);
@@ -77584,8 +77708,8 @@ var init_ship2 = __esm(() => {
77584
77708
  });
77585
77709
 
77586
77710
  // ../../loki-ts/src/engine10/modernize/presealed_wall.ts
77587
- import { existsSync as existsSync87, mkdirSync as mkdirSync71, readFileSync as readFileSync109, writeFileSync as writeFileSync65 } from "fs";
77588
- import { join as join126 } from "path";
77711
+ import { existsSync as existsSync88, mkdirSync as mkdirSync71, readFileSync as readFileSync110, writeFileSync as writeFileSync66 } from "fs";
77712
+ import { join as join127 } from "path";
77589
77713
  function isRealFailCount(n11) {
77590
77714
  return typeof n11 === "number" && Number.isInteger(n11) && n11 >= 1;
77591
77715
  }
@@ -77608,7 +77732,7 @@ function classifyBaseRun(o, repoDir) {
77608
77732
  return "not_run";
77609
77733
  }
77610
77734
  function preSealedPath(repoDir, mid, unit) {
77611
- return join126(oracleDir(repoDir, mid, unit), "presealed_wall.json");
77735
+ return join127(oracleDir(repoDir, mid, unit), "presealed_wall.json");
77612
77736
  }
77613
77737
  function alreadySealed(repoDir, mid, unit) {
77614
77738
  return readModernizeEvents(repoDir, mid).some((e10) => e10.type === SEALED_EVENT && e10.data.unit === unit);
@@ -77622,7 +77746,7 @@ function sealPreSealedWall(repoDir, mid, unit, target, runConformance, log, base
77622
77746
  if (!oracleCheck.ok)
77623
77747
  return refuse(`oracle seal invalid: ${oracleCheck.reason ?? "unknown"}; presealed wall refused`);
77624
77748
  const dir = oracleDir(repoDir, mid, unit);
77625
- const oracleSealed = JSON.parse(readFileSync109(join126(dir, "sealed.json"), "utf8"));
77749
+ const oracleSealed = JSON.parse(readFileSync110(join127(dir, "sealed.json"), "utf8"));
77626
77750
  if (oracleSealed.verdict !== "PROVEN_ORACLE") {
77627
77751
  return refuse(`oracle seal invalid: oracle is ${oracleSealed.verdict} (${oracleSealed.not_proven ?? "no reason recorded"}); presealed wall refused`);
77628
77752
  }
@@ -77651,7 +77775,7 @@ function sealPreSealedWall(repoDir, mid, unit, target, runConformance, log, base
77651
77775
  }
77652
77776
  mkdirSync71(dir, { recursive: true });
77653
77777
  const sealedPath = preSealedPath(repoDir, mid, unit);
77654
- if (existsSync87(sealedPath)) {
77778
+ if (existsSync88(sealedPath)) {
77655
77779
  throw new Error(`presealed wall: ${unit} already has a sealed presealed_wall.json; re-seal refused (seal is write-once)`);
77656
77780
  }
77657
77781
  const sealed = {
@@ -77665,7 +77789,7 @@ function sealPreSealedWall(repoDir, mid, unit, target, runConformance, log, base
77665
77789
  ...baseSha !== null ? { base_sha: baseSha } : {}
77666
77790
  };
77667
77791
  const json2 = JSON.stringify(sealed, null, 2);
77668
- writeFileSync65(sealedPath, json2);
77792
+ writeFileSync66(sealedPath, json2);
77669
77793
  const sealedSha256 = sha2564(json2);
77670
77794
  log.append(SEALED_EVENT, {
77671
77795
  unit,
@@ -77683,7 +77807,7 @@ function sealPreSealedWall(repoDir, mid, unit, target, runConformance, log, base
77683
77807
  }
77684
77808
  function verifyPreSealedWall(repoDir, mid, unit) {
77685
77809
  const sealedPath = preSealedPath(repoDir, mid, unit);
77686
- if (!existsSync87(sealedPath))
77810
+ if (!existsSync88(sealedPath))
77687
77811
  return { ok: false, reason: "no presealed_wall.json" };
77688
77812
  const event = readModernizeEvents(repoDir, mid).find((e10) => e10.type === SEALED_EVENT && e10.data.unit === unit);
77689
77813
  if (!event)
@@ -77691,7 +77815,7 @@ function verifyPreSealedWall(repoDir, mid, unit) {
77691
77815
  const expectedSha = event.data.sealed_sha256;
77692
77816
  if (typeof expectedSha !== "string")
77693
77817
  return { ok: false, reason: "sealing event has no sealed_sha256" };
77694
- const sealedRaw = readFileSync109(sealedPath, "utf8");
77818
+ const sealedRaw = readFileSync110(sealedPath, "utf8");
77695
77819
  const actualSha = sha2564(sealedRaw);
77696
77820
  if (actualSha !== expectedSha) {
77697
77821
  return { ok: false, reason: "presealed_wall.json does not match the sealing event's hash (tampered or rewritten)" };
@@ -77700,7 +77824,7 @@ function verifyPreSealedWall(repoDir, mid, unit) {
77700
77824
  if (!oracleCheck.ok) {
77701
77825
  return { ok: false, reason: `bound oracle seal is no longer valid: ${oracleCheck.reason ?? "unknown"}` };
77702
77826
  }
77703
- const oracleSealed = JSON.parse(readFileSync109(join126(oracleDir(repoDir, mid, unit), "sealed.json"), "utf8"));
77827
+ const oracleSealed = JSON.parse(readFileSync110(join127(oracleDir(repoDir, mid, unit), "sealed.json"), "utf8"));
77704
77828
  const carried = JSON.parse(sealedRaw);
77705
77829
  if (carried.oracle_cases_sha256 !== oracleSealed.cases_sha256 || carried.oracle_coverage_sha256 !== oracleSealed.coverage_sha256 || typeof carried.oracle_normalizers_sha256 !== "string" || typeof oracleSealed.normalizers_sha256 !== "string" || carried.oracle_normalizers_sha256 !== oracleSealed.normalizers_sha256) {
77706
77830
  return { ok: false, reason: "carried oracle hashes do not match the current oracle seal" };
@@ -77725,10 +77849,10 @@ var init_presealed_wall = __esm(() => {
77725
77849
 
77726
77850
  // ../../loki-ts/src/engine10/modernize/unit.ts
77727
77851
  import { spawnSync as spawnSync19 } from "child_process";
77728
- import { createHash as createHash34 } from "crypto";
77729
- import { lstatSync as lstatSync27, readFileSync as readFileSync110, readdirSync as readdirSync37, readlinkSync as readlinkSync7, realpathSync as realpathSync33, rmSync as rmSync35 } from "fs";
77730
- import { tmpdir as tmpdir21 } from "os";
77731
- import { join as join127, sep as sep20 } from "path";
77852
+ import { createHash as createHash35 } from "crypto";
77853
+ import { lstatSync as lstatSync27, readFileSync as readFileSync111, readdirSync as readdirSync37, readlinkSync as readlinkSync7, realpathSync as realpathSync33, rmSync as rmSync36 } from "fs";
77854
+ import { tmpdir as tmpdir22 } from "os";
77855
+ import { join as join128, sep as sep20 } from "path";
77732
77856
  function isSealedName(rel) {
77733
77857
  return TEST_FILE2.test(rel) || PYTEST_CFG.test(rel);
77734
77858
  }
@@ -77743,9 +77867,9 @@ function purgePycache(dir) {
77743
77867
  for (const e10 of ents) {
77744
77868
  if (!e10.isDirectory())
77745
77869
  continue;
77746
- const full = join127(d, e10.name);
77870
+ const full = join128(d, e10.name);
77747
77871
  if (e10.name === "__pycache__")
77748
- rmSync35(full, { recursive: true, force: true });
77872
+ rmSync36(full, { recursive: true, force: true });
77749
77873
  else if (!skipName(e10.name))
77750
77874
  walk(full);
77751
77875
  }
@@ -77767,7 +77891,7 @@ function outsideTargetDigest(dir, full) {
77767
77891
  }
77768
77892
  if (real3 === root || real3.startsWith(root + sep20))
77769
77893
  return "inside";
77770
- const h10 = createHash34("sha256");
77894
+ const h10 = createHash35("sha256");
77771
77895
  let budget = 20000;
77772
77896
  const walk = (p) => {
77773
77897
  if (budget-- <= 0) {
@@ -77798,13 +77922,13 @@ function outsideTargetDigest(dir, full) {
77798
77922
  }
77799
77923
  for (const n11 of names) {
77800
77924
  h10.update("D" + n11);
77801
- walk(join127(p, n11));
77925
+ walk(join128(p, n11));
77802
77926
  }
77803
77927
  return;
77804
77928
  }
77805
77929
  if (st2.isFile()) {
77806
77930
  try {
77807
- h10.update(readFileSync110(p));
77931
+ h10.update(readFileSync111(p));
77808
77932
  } catch {
77809
77933
  h10.update("unreadable");
77810
77934
  }
@@ -77819,7 +77943,7 @@ function conformanceHashes(dir) {
77819
77943
  const walk = (sub2, inSkip) => {
77820
77944
  let ents;
77821
77945
  try {
77822
- ents = readdirSync37(join127(dir, sub2), { withFileTypes: true });
77946
+ ents = readdirSync37(join128(dir, sub2), { withFileTypes: true });
77823
77947
  } catch {
77824
77948
  return;
77825
77949
  }
@@ -77850,18 +77974,18 @@ function conformanceHashes(dir) {
77850
77974
  for (const rel of rels) {
77851
77975
  let data;
77852
77976
  try {
77853
- const st2 = lstatSync27(join127(dir, rel));
77977
+ const st2 = lstatSync27(join128(dir, rel));
77854
77978
  if (st2.isSymbolicLink()) {
77855
- out3[rel] = `${LINK}${readlinkSync7(join127(dir, rel))}|${outsideTargetDigest(dir, join127(dir, rel))}`;
77979
+ out3[rel] = `${LINK}${readlinkSync7(join128(dir, rel))}|${outsideTargetDigest(dir, join128(dir, rel))}`;
77856
77980
  continue;
77857
77981
  }
77858
77982
  if (!st2.isFile())
77859
77983
  continue;
77860
- data = readFileSync110(join127(dir, rel));
77984
+ data = readFileSync111(join128(dir, rel));
77861
77985
  } catch {
77862
77986
  continue;
77863
77987
  }
77864
- out3[rel] = createHash34("sha256").update(data).digest("hex");
77988
+ out3[rel] = createHash35("sha256").update(data).digest("hex");
77865
77989
  }
77866
77990
  return out3;
77867
77991
  }
@@ -77874,7 +77998,7 @@ for n in sys.argv[1:]:
77874
77998
  if n in sys.stdlib_module_names or u.find_spec(n): print(n)
77875
77999
  except Exception: print(n)
77876
78000
  `;
77877
- const r = spawnSync19(target, ["-I", "-c", code, ...names], { cwd: tmpdir21(), encoding: "utf8", timeout: 30000, env: tokenFreeEnv() });
78001
+ const r = spawnSync19(target, ["-I", "-c", code, ...names], { cwd: tmpdir22(), encoding: "utf8", timeout: 30000, env: tokenFreeEnv() });
77878
78002
  return r.status === 0 ? new Set(r.stdout.split(`
77879
78003
  `).filter(Boolean)) : new Set(names);
77880
78004
  }
@@ -77916,7 +78040,7 @@ function notProvenUnitResult(unit, reason, oracle, wall) {
77916
78040
  return { unit, verdict: "NOT_PROVEN", oracle, wall, equiv: null, not_proven: [reason], conformance: null };
77917
78041
  }
77918
78042
  function readOracleSealed(repoDir, mid, unit) {
77919
- return JSON.parse(readFileSync110(join127(oracleDir(repoDir, mid, unit), "sealed.json"), "utf8"));
78043
+ return JSON.parse(readFileSync111(join128(oracleDir(repoDir, mid, unit), "sealed.json"), "utf8"));
77920
78044
  }
77921
78045
  function runUnit(card, log, runConformance, implement, runNew, runStub, collect) {
77922
78046
  const { repoDir, mid, unit } = card;
@@ -78027,8 +78151,8 @@ var init_unit = __esm(() => {
78027
78151
 
78028
78152
  // ../../loki-ts/src/engine10/modernize/wave.ts
78029
78153
  import { spawnSync as spawnSync20 } from "child_process";
78030
- import { readFileSync as readFileSync111, statSync as statSync33 } from "fs";
78031
- import { join as join128 } from "path";
78154
+ import { readFileSync as readFileSync112, statSync as statSync33 } from "fs";
78155
+ import { join as join129 } from "path";
78032
78156
  function clampTimeout(ms) {
78033
78157
  if (ms === undefined || !Number.isFinite(ms) || ms <= 0)
78034
78158
  return DEFAULT_STEP_TIMEOUT_MS;
@@ -78097,7 +78221,7 @@ function detectWaveCommands(inv, target) {
78097
78221
  const none = { build: null, integration: null, original_suite: null };
78098
78222
  const text4 = () => {
78099
78223
  try {
78100
- return readFileSync111(join128(target, marker ?? ""), "utf8");
78224
+ return readFileSync112(join129(target, marker ?? ""), "utf8");
78101
78225
  } catch {
78102
78226
  return "";
78103
78227
  }
@@ -78109,7 +78233,7 @@ function detectWaveCommands(inv, target) {
78109
78233
  if (system === "gradle") {
78110
78234
  let gw2 = "gradle";
78111
78235
  try {
78112
- if (inv.files.includes("gradlew") && (statSync33(join128(target, "gradlew")).mode & 73) !== 0)
78236
+ if (inv.files.includes("gradlew") && (statSync33(join129(target, "gradlew")).mode & 73) !== 0)
78113
78237
  gw2 = "./gradlew";
78114
78238
  } catch {}
78115
78239
  return { build: { argv: [gw2, "assemble"] }, integration: text4().includes("integrationTest") ? { argv: [gw2, "integrationTest"] } : null, original_suite: { argv: [gw2, "test"] } };
@@ -78121,7 +78245,7 @@ function detectWaveCommands(inv, target) {
78121
78245
  let toxIni = "";
78122
78246
  if (inv.files.includes("tox.ini")) {
78123
78247
  try {
78124
- toxIni = readFileSync111(join128(target, "tox.ini"), "utf8");
78248
+ toxIni = readFileSync112(join129(target, "tox.ini"), "utf8");
78125
78249
  } catch {}
78126
78250
  }
78127
78251
  const integration = toxIni.includes("[testenv:integration") ? { argv: ["tox", "-e", "integration"] } : itDir && pytest ? { argv: ["python3", "-m", "pytest", "-q", itDir] } : null;
@@ -78153,9 +78277,9 @@ var init_wave = __esm(() => {
78153
78277
 
78154
78278
  // ../../loki-ts/src/util/modernize_unit.ts
78155
78279
  import { spawnSync as spawnSync21 } from "child_process";
78156
- import { existsSync as existsSync88, lstatSync as lstatSync28, mkdtempSync as mkdtempSync17, readFileSync as readFileSync112, realpathSync as realpathSync34, rmSync as rmSync36, statSync as statSync34, writeFileSync as writeFileSync66 } from "fs";
78157
- import { tmpdir as tmpdir22 } from "os";
78158
- import { join as join129, sep as sep21 } from "path";
78280
+ import { existsSync as existsSync89, lstatSync as lstatSync28, mkdtempSync as mkdtempSync18, readFileSync as readFileSync113, realpathSync as realpathSync34, rmSync as rmSync37, statSync as statSync34, writeFileSync as writeFileSync67 } from "fs";
78281
+ import { tmpdir as tmpdir23 } from "os";
78282
+ import { join as join130, sep as sep21 } from "path";
78159
78283
  function parseUnitArgs(args) {
78160
78284
  const f = {};
78161
78285
  for (let i = 0;i < args.length; i++) {
@@ -78227,7 +78351,7 @@ function makeUnitRunners(o) {
78227
78351
  }
78228
78352
  function makeSessionRunner(o) {
78229
78353
  const limitS = o.sessionLimitS ?? SESSION_LIMIT_S2;
78230
- const cli = import.meta.path.endsWith("modernize_unit.ts") ? join129(import.meta.dir, "..", "cli.ts") : import.meta.path;
78354
+ const cli = import.meta.path.endsWith("modernize_unit.ts") ? join130(import.meta.dir, "..", "cli.ts") : import.meta.path;
78231
78355
  return o.session ?? ((_brief, cwd, env) => spawnSync21(process.execPath, [...SAFE_BUN_FLAGS, cli, "engine10", "session"], { cwd, env, stdio: ["ignore", "ignore", "pipe"], timeout: limitS * 1000 }));
78232
78356
  }
78233
78357
  function defaultUnitFile(unitId, newTreeDir) {
@@ -78235,7 +78359,7 @@ function defaultUnitFile(unitId, newTreeDir) {
78235
78359
  return null;
78236
78360
  try {
78237
78361
  const root = realpathSync34(newTreeDir);
78238
- const real3 = realpathSync34(join129(root, unitId));
78362
+ const real3 = realpathSync34(join130(root, unitId));
78239
78363
  return real3.startsWith(root + sep21) ? real3 : null;
78240
78364
  } catch {
78241
78365
  return null;
@@ -78270,25 +78394,25 @@ function boundariesFromCase(rec2) {
78270
78394
  }
78271
78395
  function runPythonCase(o, unitId, newTreeDir, rec2, stub) {
78272
78396
  const src = o.unitFile ? o.unitFile(unitId, newTreeDir) : defaultUnitFile(unitId, newTreeDir);
78273
- if (!src || !src.endsWith(".py") || !existsSync88(src))
78397
+ if (!src || !src.endsWith(".py") || !existsSync89(src))
78274
78398
  throw new Error(`cannot locate the source of unit ${unitId} in the new tree`);
78275
- const dir = mkdtempSync17(join129(tmpdir22(), "loki-newcase-"));
78399
+ const dir = mkdtempSync18(join130(tmpdir23(), "loki-newcase-"));
78276
78400
  try {
78277
- const cases = join129(dir, "in.jsonl"), out3 = join129(dir, "out.jsonl");
78278
- writeFileSync66(cases, JSON.stringify({ entry: rec2.entry, args: rec2.args, kwargs: rec2.kwargs, boundaries: boundariesFromCase(rec2) }) + `
78401
+ const cases = join130(dir, "in.jsonl"), out3 = join130(dir, "out.jsonl");
78402
+ writeFileSync67(cases, JSON.stringify({ entry: rec2.entry, args: rec2.args, kwargs: rec2.kwargs, boundaries: boundariesFromCase(rec2) }) + `
78279
78403
  `, "utf8");
78280
- const r = spawnSync21(o.pythonBin ?? "python3", [join129(REPO_ROOT, "autonomy", "lib", "modernize", "py_capture.py"), "--unit", src, "--cases", cases, "--out", out3, ...stub ? ["--stub"] : []], { cwd: newTreeDir, encoding: "utf8", timeout: CASE_TIMEOUT_MS, env: { ...tokenFreeEnv(), PYTHONDONTWRITEBYTECODE: "1" } });
78281
- if (r.status !== 0 || !existsSync88(out3))
78404
+ const r = spawnSync21(o.pythonBin ?? "python3", [join130(REPO_ROOT, "autonomy", "lib", "modernize", "py_capture.py"), "--unit", src, "--cases", cases, "--out", out3, ...stub ? ["--stub"] : []], { cwd: newTreeDir, encoding: "utf8", timeout: CASE_TIMEOUT_MS, env: { ...tokenFreeEnv(), PYTHONDONTWRITEBYTECODE: "1" } });
78405
+ if (r.status !== 0 || !existsSync89(out3))
78282
78406
  throw new Error(`new-tree case runner failed (${r.status ?? r.signal ?? "no status"}): ${String(r.stderr ?? "").trim().split(`
78283
78407
  `).pop() ?? ""}`);
78284
- const line2 = readFileSync112(out3, "utf8").split(`
78408
+ const line2 = readFileSync113(out3, "utf8").split(`
78285
78409
  `).find((l) => l.trim() !== "");
78286
78410
  if (!line2)
78287
78411
  throw new Error("new-tree case runner produced no record");
78288
78412
  const got = JSON.parse(line2);
78289
78413
  return { return: got.return, exc: got.exc, stdout: got.stdout, files: got.files, ...got.not_proven.length > 0 ? { not_proven: got.not_proven } : {} };
78290
78414
  } finally {
78291
- rmSync36(dir, { recursive: true, force: true });
78415
+ rmSync37(dir, { recursive: true, force: true });
78292
78416
  }
78293
78417
  }
78294
78418
  async function unitMain(args, deps = {}) {
@@ -78304,10 +78428,10 @@ Usage: ${UNIT_USAGE}
78304
78428
  const runners = u10.implement && u10.runNew && u10.runStub ? null : makeUnitRunners({ target: o.target });
78305
78429
  const implement = u10.implement ?? runners.implement, runNew = u10.runNew ?? runners.runNew, runStub = u10.runStub ?? runners.runStub;
78306
78430
  const runTmp = process.env["LOKI_RUN_TMP"] ?? "";
78307
- const root = u10.tmpRoot ?? (runTmp !== "" && isRealDir(runTmp) ? runTmp : tmpdir22());
78431
+ const root = u10.tmpRoot ?? (runTmp !== "" && isRealDir(runTmp) ? runTmp : tmpdir23());
78308
78432
  let repoDir;
78309
78433
  try {
78310
- repoDir = mkdtempSync17(join129(root, "loki-unit-"));
78434
+ repoDir = mkdtempSync18(join130(root, "loki-unit-"));
78311
78435
  } catch (e10) {
78312
78436
  process.stderr.write(`modernize unit: cannot create a temp checkout directory: ${e10.message}
78313
78437
  `);
@@ -78342,8 +78466,8 @@ Usage: ${UNIT_USAGE}
78342
78466
  `);
78343
78467
  return 1;
78344
78468
  } finally {
78345
- if (existsSync88(repoDir))
78346
- rmSync36(repoDir, { recursive: true, force: true });
78469
+ if (existsSync89(repoDir))
78470
+ rmSync37(repoDir, { recursive: true, force: true });
78347
78471
  }
78348
78472
  }
78349
78473
  function buildUnitJob(spec) {
@@ -78402,12 +78526,12 @@ var init_modernize_unit = __esm(() => {
78402
78526
  });
78403
78527
 
78404
78528
  // ../../loki-ts/src/util/modernize_coordinator.ts
78405
- import { createHash as createHash35 } from "crypto";
78406
- import { existsSync as existsSync89, mkdtempSync as mkdtempSync18, readFileSync as readFileSync113, rmSync as rmSync37 } from "fs";
78407
- import { tmpdir as tmpdir23 } from "os";
78408
- import { join as join130 } from "path";
78529
+ import { createHash as createHash36 } from "crypto";
78530
+ import { existsSync as existsSync90, mkdtempSync as mkdtempSync19, readFileSync as readFileSync114, rmSync as rmSync38 } from "fs";
78531
+ import { tmpdir as tmpdir24 } from "os";
78532
+ import { join as join131 } from "path";
78409
78533
  function shipUnitOf(d, unit, o) {
78410
- const sealed = join130(oracleDir(d.repoDir, d.mid, unit), "sealed.json");
78534
+ const sealed = join131(oracleDir(d.repoDir, d.mid, unit), "sealed.json");
78411
78535
  const eq3 = o?.result?.equiv;
78412
78536
  return {
78413
78537
  unit,
@@ -78424,7 +78548,7 @@ function scopeBuildToWave(cmd2, repoDir, units) {
78424
78548
  const x3 = cmd2?.argv.indexOf("-x") ?? -1;
78425
78549
  if (!cmd2 || !cmd2.argv.includes("compileall") || x3 < 0)
78426
78550
  return cmd2;
78427
- const files = [...new Set(units.flatMap((u10) => u10.nodes))].filter((n11) => n11.endsWith(".py") && isSafeUnitId(n11) && existsSync89(join130(repoDir, n11)));
78551
+ const files = [...new Set(units.flatMap((u10) => u10.nodes))].filter((n11) => n11.endsWith(".py") && isSafeUnitId(n11) && existsSync90(join131(repoDir, n11)));
78428
78552
  return files.length ? { ...cmd2, argv: [...cmd2.argv.slice(0, x3 + 2), ...files] } : cmd2;
78429
78553
  }
78430
78554
  async function runWaves(plan, d) {
@@ -78583,16 +78707,16 @@ function makeAttemptRunner(o) {
78583
78707
  }
78584
78708
  function makeUnitPrep(o) {
78585
78709
  const runtimeOk = o.runtimeOk ?? (() => {
78586
- const dir = mkdtempSync18(join130(tmpdir23(), "loki-probe-"));
78710
+ const dir = mkdtempSync19(join131(tmpdir24(), "loki-probe-"));
78587
78711
  try {
78588
- return realCaptureRunner(join130(dir, "probe.py"), []).error !== "old runtime unavailable";
78712
+ return realCaptureRunner(join131(dir, "probe.py"), []).error !== "old runtime unavailable";
78589
78713
  } finally {
78590
- rmSync37(dir, { recursive: true, force: true });
78714
+ rmSync38(dir, { recursive: true, force: true });
78591
78715
  }
78592
78716
  });
78593
78717
  let runtime = null;
78594
78718
  return (unit) => {
78595
- if (existsSync89(join130(oracleDir(o.repoDir, o.mid, unit.id), "cases.jsonl")) || alreadySealedInLog(o.repoDir, o.mid, unit.id))
78719
+ if (existsSync90(join131(oracleDir(o.repoDir, o.mid, unit.id), "cases.jsonl")) || alreadySealedInLog(o.repoDir, o.mid, unit.id))
78596
78720
  return null;
78597
78721
  runtime ??= runtimeOk();
78598
78722
  if (!runtime)
@@ -78600,7 +78724,7 @@ function makeUnitPrep(o) {
78600
78724
  const node = unit.nodes.length === 1 ? unit.nodes[0] : "";
78601
78725
  if (!node.endsWith(".py") || !isSafeUnitId(node))
78602
78726
  return MULTI_FILE_REASON;
78603
- const r = (o.capture ?? captureUnitOracle)({ repoDir: o.repoDir, mid: o.mid, unit: unit.id, unitPath: join130(o.repoDir, node), propose: o.propose });
78727
+ const r = (o.capture ?? captureUnitOracle)({ repoDir: o.repoDir, mid: o.mid, unit: unit.id, unitPath: join131(o.repoDir, node), propose: o.propose });
78604
78728
  return r.ok ? null : r.reason;
78605
78729
  };
78606
78730
  }
@@ -78659,7 +78783,7 @@ function productionWaveDeps(o) {
78659
78783
  }
78660
78784
  };
78661
78785
  }
78662
- var productionReslice, sha2565 = (p) => existsSync89(p) ? createHash35("sha256").update(readFileSync113(p)).digest("hex") : "n/a", MULTI_FILE_REASON = "multi-file unit: capture not supported (founder default)";
78786
+ var productionReslice, sha2565 = (p) => existsSync90(p) ? createHash36("sha256").update(readFileSync114(p)).digest("hex") : "n/a", MULTI_FILE_REASON = "multi-file unit: capture not supported (founder default)";
78663
78787
  var init_modernize_coordinator = __esm(() => {
78664
78788
  init_codemod();
78665
78789
  init_search();
@@ -78692,7 +78816,7 @@ __export(exports_cli, {
78692
78816
  main: () => main7,
78693
78817
  USAGE: () => USAGE2
78694
78818
  });
78695
- import { existsSync as existsSync90, statSync as statSync35 } from "fs";
78819
+ import { existsSync as existsSync91, statSync as statSync35 } from "fs";
78696
78820
  function parseArgs2(args) {
78697
78821
  let repoDir = null;
78698
78822
  let target = null;
@@ -78829,7 +78953,7 @@ ${USAGE2}`);
78829
78953
  return 2;
78830
78954
  }
78831
78955
  const opts = parsed.opts;
78832
- if (!existsSync90(opts.repoDir) || !statSync35(opts.repoDir).isDirectory()) {
78956
+ if (!existsSync91(opts.repoDir) || !statSync35(opts.repoDir).isDirectory()) {
78833
78957
  process.stderr.write(`modernize: not a directory: ${opts.repoDir}
78834
78958
  `);
78835
78959
  return 2;
@@ -78912,7 +79036,7 @@ Targets: ${TARGETS2.join(", ")}
78912
79036
  });
78913
79037
 
78914
79038
  // ../../loki-ts/src/contrib/sarif.ts
78915
- import { createHash as createHash36 } from "crypto";
79039
+ import { createHash as createHash37 } from "crypto";
78916
79040
  function sarifUri(file, repoRoot2) {
78917
79041
  let p = file.replace(/\\/g, "/");
78918
79042
  if (repoRoot2) {
@@ -78973,7 +79097,7 @@ function toSarif(findings, toolVersion2 = "0.0.0", repoRoot2) {
78973
79097
  ]
78974
79098
  };
78975
79099
  }
78976
- var RULES2, SCHEMA = "https://json.schemastore.org/sarif-2.1.0.json", sha5 = (s) => createHash36("sha256").update(s).digest("hex");
79100
+ var RULES2, SCHEMA = "https://json.schemastore.org/sarif-2.1.0.json", sha5 = (s) => createHash37("sha256").update(s).digest("hex");
78977
79101
  var init_sarif = __esm(() => {
78978
79102
  init_redact();
78979
79103
  RULES2 = {
@@ -78992,8 +79116,8 @@ __export(exports_export_sarif, {
78992
79116
  preRedFromEvents: () => preRedFromEvents,
78993
79117
  main: () => main8
78994
79118
  });
78995
- import { existsSync as existsSync91, readFileSync as readFileSync114, writeFileSync as writeFileSync67 } from "fs";
78996
- import { join as join131 } from "path";
79119
+ import { existsSync as existsSync92, readFileSync as readFileSync115, writeFileSync as writeFileSync68 } from "fs";
79120
+ import { join as join132 } from "path";
78997
79121
  function scanDiff(diff) {
78998
79122
  const out3 = [];
78999
79123
  let file = "";
@@ -79024,7 +79148,7 @@ function scanDiff(diff) {
79024
79148
  function preRedFromEvents(runDir) {
79025
79149
  try {
79026
79150
  let pre2 = [];
79027
- for (const l of readFileSync114(join131(runDir, "events.jsonl"), "utf8").split(`
79151
+ for (const l of readFileSync115(join132(runDir, "events.jsonl"), "utf8").split(`
79028
79152
  `)) {
79029
79153
  if (!l.includes('"stage.completed"'))
79030
79154
  continue;
@@ -79053,19 +79177,19 @@ async function main8(args, deps = {}) {
79053
79177
  if (bad || rest.length > 1)
79054
79178
  return process.stderr.write(`loki export --sarif: ${bad ? `unknown flag ${bad}` : "more than one run-id"}
79055
79179
  `), 2;
79056
- const runsRoot2 = deps.runsRoot ?? join131(lokiDir(), "runs");
79180
+ const runsRoot2 = deps.runsRoot ?? join132(lokiDir(), "runs");
79057
79181
  const runId2 = rest[0] ?? latestRunId(runsRoot2);
79058
79182
  if (!runId2)
79059
79183
  return process.stderr.write(`loki export --sarif: no runs found
79060
79184
  `), 66;
79061
- const runDir = join131(runsRoot2, runId2);
79062
- const receiptPath = join131(runDir, "receipt.json");
79063
- if (runId2.includes("/") || runId2.includes("..") || !existsSync91(receiptPath))
79185
+ const runDir = join132(runsRoot2, runId2);
79186
+ const receiptPath = join132(runDir, "receipt.json");
79187
+ if (runId2.includes("/") || runId2.includes("..") || !existsSync92(receiptPath))
79064
79188
  return process.stderr.write(`loki export --sarif: unknown run ${runId2}
79065
79189
  `), 66;
79066
79190
  let receipt;
79067
79191
  try {
79068
- receipt = JSON.parse(readFileSync114(receiptPath, "utf8"));
79192
+ receipt = JSON.parse(readFileSync115(receiptPath, "utf8"));
79069
79193
  } catch {
79070
79194
  return process.stderr.write(`loki export --sarif: unreadable receipt for ${runId2}
79071
79195
  `), 66;
@@ -79082,10 +79206,10 @@ async function main8(args, deps = {}) {
79082
79206
  findings.push(...receiptFindings(receipt, preRedFromEvents(runDir)));
79083
79207
  let version2 = "0.0.0";
79084
79208
  try {
79085
- version2 = readFileSync114(join131(REPO_ROOT, "VERSION"), "utf8").trim() || version2;
79209
+ version2 = readFileSync115(join132(REPO_ROOT, "VERSION"), "utf8").trim() || version2;
79086
79210
  } catch {}
79087
- const out3 = join131(runDir, "findings.sarif");
79088
- writeFileSync67(out3, JSON.stringify(toSarif(findings, version2, deps.repoDir ?? process.cwd()), null, 2) + `
79211
+ const out3 = join132(runDir, "findings.sarif");
79212
+ writeFileSync68(out3, JSON.stringify(toSarif(findings, version2, deps.repoDir ?? process.cwd()), null, 2) + `
79089
79213
  `);
79090
79214
  process.stdout.write(`run: ${runId2}
79091
79215
  findings: ${findings.length}
@@ -79303,7 +79427,7 @@ var init_output = __esm(() => {
79303
79427
 
79304
79428
  // ../../loki-ts/src/features/receipt_dsse.ts
79305
79429
  import { createPublicKey as createPublicKey5, sign as sign3, verify as verify3 } from "crypto";
79306
- import { readFileSync as readFileSync115 } from "fs";
79430
+ import { readFileSync as readFileSync116 } from "fs";
79307
79431
  function pae2(payloadType, body) {
79308
79432
  const t = Buffer.from(payloadType, "utf8");
79309
79433
  return Buffer.concat([Buffer.from(`DSSEv1 ${t.length} `), t, Buffer.from(` ${body.length} `), body]);
@@ -79399,7 +79523,7 @@ function verifyDsseReceipt(env, d) {
79399
79523
  }
79400
79524
  function runIdGuard(receiptPath, runId2) {
79401
79525
  try {
79402
- return envelopeRunIdProblem(JSON.parse(readFileSync115(receiptPath, "utf8")), runId2);
79526
+ return envelopeRunIdProblem(JSON.parse(readFileSync116(receiptPath, "utf8")), runId2);
79403
79527
  } catch {
79404
79528
  return null;
79405
79529
  }
@@ -79407,7 +79531,7 @@ function runIdGuard(receiptPath, runId2) {
79407
79531
  async function exportDsseReceipt(a) {
79408
79532
  const fail2 = (rc2, m) => (process.stderr.write(`loki verify --export-dsse: ${m}
79409
79533
  `), rc2);
79410
- const rd2 = a.deps.read ?? ((p) => readFileSync115(p, "utf8"));
79534
+ const rd2 = a.deps.read ?? ((p) => readFileSync116(p, "utf8"));
79411
79535
  let text4;
79412
79536
  try {
79413
79537
  text4 = rd2(a.receiptPath);
@@ -79464,13 +79588,13 @@ var init_undo = __esm(() => {
79464
79588
  });
79465
79589
 
79466
79590
  // ../../loki-ts/src/commands/run_status.ts
79467
- import { existsSync as existsSync92, readdirSync as readdirSync38, readFileSync as readFileSync116, statSync as statSync36 } from "fs";
79468
- import { basename as basename31, dirname as dirname49, join as join132, resolve as resolve39 } from "path";
79591
+ import { existsSync as existsSync93, readdirSync as readdirSync38, readFileSync as readFileSync117, statSync as statSync36 } from "fs";
79592
+ import { basename as basename32, dirname as dirname49, join as join133, resolve as resolve39 } from "path";
79469
79593
  function runsRoot(env, repoDir) {
79470
- return env.LOKI_DIR ? join132(resolve39(repoDir, env.LOKI_DIR), "runs") : join132(repoDir, ".loki", "runs");
79594
+ return env.LOKI_DIR ? join133(resolve39(repoDir, env.LOKI_DIR), "runs") : join133(repoDir, ".loki", "runs");
79471
79595
  }
79472
79596
  function listRunIds(root) {
79473
- if (!existsSync92(root))
79597
+ if (!existsSync93(root))
79474
79598
  return [];
79475
79599
  return readdirSync38(root, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name).sort();
79476
79600
  }
@@ -79479,7 +79603,7 @@ function latestRunId(root) {
79479
79603
  return ids.length ? ids[ids.length - 1] : null;
79480
79604
  }
79481
79605
  function eventsPath(root, runId2) {
79482
- return join132(root, runId2, "events.jsonl");
79606
+ return join133(root, runId2, "events.jsonl");
79483
79607
  }
79484
79608
  var TERMINAL2;
79485
79609
  var init_run_status = __esm(() => {
@@ -79495,9 +79619,9 @@ var init_run_status = __esm(() => {
79495
79619
  });
79496
79620
 
79497
79621
  // ../../loki-ts/src/util/seal_drift.ts
79498
- import { createHash as createHash37 } from "crypto";
79499
- import { existsSync as existsSync93, readFileSync as readFileSync117, realpathSync as realpathSync35 } from "fs";
79500
- import { basename as basename32, dirname as dirname50, join as join133, relative as relative26 } from "path";
79622
+ import { createHash as createHash38 } from "crypto";
79623
+ import { existsSync as existsSync94, readFileSync as readFileSync118, realpathSync as realpathSync35 } from "fs";
79624
+ import { basename as basename33, dirname as dirname50, join as join134, relative as relative27 } from "path";
79501
79625
  function tornTail(raw2) {
79502
79626
  if (raw2 === "" || raw2.endsWith(`
79503
79627
  `))
@@ -79514,10 +79638,10 @@ function tornTail(raw2) {
79514
79638
  }
79515
79639
  }
79516
79640
  function boundEvents(log, bound) {
79517
- if (!existsSync93(log))
79641
+ if (!existsSync94(log))
79518
79642
  return null;
79519
- const lines2 = readFileSync117(log, "utf8").split(`
79520
- `).filter((l) => l.trim() !== ""), h10 = createHash37("sha256");
79643
+ const lines2 = readFileSync118(log, "utf8").split(`
79644
+ `).filter((l) => l.trim() !== ""), h10 = createHash38("sha256");
79521
79645
  let n11 = -1;
79522
79646
  for (let i = 0;i <= lines2.length; i++) {
79523
79647
  if (h10.copy().digest("hex") === bound) {
@@ -79544,7 +79668,7 @@ function fabricatedPass(receiptPath, r) {
79544
79668
  const bound = r["events_sha256"];
79545
79669
  if (typeof bound !== "string" || bound === EMPTY_SHA || !Array.isArray(r["checks"]))
79546
79670
  return null;
79547
- const events2 = boundEvents(join133(dirname50(receiptPath), "events.jsonl"), bound);
79671
+ const events2 = boundEvents(join134(dirname50(receiptPath), "events.jsonl"), bound);
79548
79672
  if (!events2 || !events2.some((e10) => e10.stage === "verify"))
79549
79673
  return null;
79550
79674
  const passed = new Set(events2.filter((e10) => e10.type === "test.result" && e10.stage === "verify" && e10.data["result"] === "pass").map((e10) => String(e10.data["name"])));
@@ -79552,12 +79676,12 @@ function fabricatedPass(receiptPath, r) {
79552
79676
  return missing.length ? `receipt claims pass with no test.result pass in events.jsonl: ${missing.join(", ")}` : null;
79553
79677
  }
79554
79678
  function currentTaskSha(runDir, source, env) {
79555
- const f = source === "issue" ? join133(runDir, "issue.json") : env["LOKI_VERIFY_TASK_FILE"];
79556
- return f && existsSync93(f) ? sha6(readFileSync117(f)) : null;
79679
+ const f = source === "issue" ? join134(runDir, "issue.json") : env["LOKI_VERIFY_TASK_FILE"];
79680
+ return f && existsSync94(f) ? sha6(readFileSync118(f)) : null;
79557
79681
  }
79558
79682
  function repoOf(receiptPath) {
79559
79683
  const runs2 = dirname50(dirname50(receiptPath));
79560
- return basename32(runs2) === "runs" && basename32(dirname50(runs2)) === ".loki" ? dirname50(dirname50(runs2)) : null;
79684
+ return basename33(runs2) === "runs" && basename33(dirname50(runs2)) === ".loki" ? dirname50(dirname50(runs2)) : null;
79561
79685
  }
79562
79686
  function overlap(repo, base, sealedHead, head) {
79563
79687
  if (typeof base !== "string" || !/^[0-9a-f]{40,64}$/.test(base) || !/^[0-9a-f]{40,64}$/.test(sealedHead))
@@ -79583,7 +79707,7 @@ function onlyWallPublish(repo, r, sealedHead, head) {
79583
79707
  } catch {
79584
79708
  return x3;
79585
79709
  }
79586
- }, rr2 = real3(repo), want = new Map(wall.map((w) => [relative26(rr2, join133(real3(dirname50(String(w.path))), basename32(String(w.path)))), String(w.sha256)]));
79710
+ }, rr2 = real3(repo), want = new Map(wall.map((w) => [relative27(rr2, join134(real3(dirname50(String(w.path))), basename33(String(w.path)))), String(w.sha256)]));
79587
79711
  const commits = safeGit(repo, ["rev-list", "--reverse", "--topo-order", `${sealedHead}..${head}`]).split(`
79588
79712
  `).filter(Boolean);
79589
79713
  if (commits.length === 0 || safeGit(repo, ["rev-list", "--merges", "--count", `${sealedHead}..${head}`]).trim() !== "0")
@@ -79621,14 +79745,14 @@ function claimsWallPublish(repo, r, sealedHead, head) {
79621
79745
  function sealDrift(given, r, env = process.env) {
79622
79746
  let receiptPath = given;
79623
79747
  try {
79624
- receiptPath = join133(realpathSync35(dirname50(given)), basename32(given));
79748
+ receiptPath = join134(realpathSync35(dirname50(given)), basename33(given));
79625
79749
  } catch {}
79626
79750
  const fab = fabricatedPass(receiptPath, r);
79627
79751
  if (fab)
79628
79752
  return { verdict: "TAMPERED", reason: fab };
79629
79753
  try {
79630
- const log = join133(dirname50(receiptPath), "events.jsonl");
79631
- if (existsSync93(log) && tornTail(readFileSync117(log, "utf8")))
79754
+ const log = join134(dirname50(receiptPath), "events.jsonl");
79755
+ if (existsSync94(log) && tornTail(readFileSync118(log, "utf8")))
79632
79756
  return { verdict: "UNCHECKED", reason: "events.jsonl ends in a torn, unterminated line (an append cut mid-write); every complete line is intact but the log is not whole" };
79633
79757
  } catch {}
79634
79758
  const task = r["task"] ?? {};
@@ -79655,21 +79779,21 @@ function sealDrift(given, r, env = process.env) {
79655
79779
  }
79656
79780
  return null;
79657
79781
  }
79658
- var EMPTY_SHA, sha6 = (s) => createHash37("sha256").update(s).digest("hex");
79782
+ var EMPTY_SHA, sha6 = (s) => createHash38("sha256").update(s).digest("hex");
79659
79783
  var init_seal_drift = __esm(() => {
79660
79784
  init_safe_git();
79661
- EMPTY_SHA = createHash37("sha256").digest("hex");
79785
+ EMPTY_SHA = createHash38("sha256").digest("hex");
79662
79786
  });
79663
79787
 
79664
79788
  // ../../loki-ts/src/util/composite_seal.ts
79665
- import { existsSync as existsSync94, readFileSync as readFileSync118 } from "fs";
79666
- import { basename as basename33, dirname as dirname51, join as join134 } from "path";
79789
+ import { existsSync as existsSync95, readFileSync as readFileSync119 } from "fs";
79790
+ import { basename as basename34, dirname as dirname51, join as join135 } from "path";
79667
79791
  function logProblem(runDir, integ) {
79668
79792
  if (typeof integ["log_sha256"] !== "string")
79669
79793
  return null;
79670
79794
  let b;
79671
79795
  try {
79672
- b = readFileSync118(join134(runDir, "integration.log"));
79796
+ b = readFileSync119(join135(runDir, "integration.log"));
79673
79797
  } catch {
79674
79798
  return "integration.log is missing but integration.json records its hash";
79675
79799
  }
@@ -79684,10 +79808,10 @@ function integrationProblem(integ) {
79684
79808
  return null;
79685
79809
  }
79686
79810
  function composeComposite(runDir, rh, toolchain = collectToolchain()) {
79687
- const ip = join134(runDir, "integration.json");
79811
+ const ip = join135(runDir, "integration.json");
79688
79812
  let ibytes;
79689
79813
  try {
79690
- ibytes = readFileSync118(ip);
79814
+ ibytes = readFileSync119(ip);
79691
79815
  } catch {
79692
79816
  throw new Error("integration.json missing; the workspace run did not finish");
79693
79817
  }
@@ -79711,12 +79835,12 @@ function composeComposite(runDir, rh, toolchain = collectToolchain()) {
79711
79835
  const outcome = String(integ["outcomes"][repo] ?? "");
79712
79836
  if (outcome !== "ok")
79713
79837
  throw new Error(`repo ${text3(repo, 80)} did not finish (${text3(outcome, 80) || "no outcome"}); no composite`);
79714
- const runsDir = join134(runDir, "worktrees", slugOf(repo), ".loki", "runs");
79715
- const ids = (dirNames(runsDir) ?? []).filter((n11) => existsSync94(join134(runsDir, n11, "receipt.json")));
79838
+ const runsDir = join135(runDir, "worktrees", slugOf(repo), ".loki", "runs");
79839
+ const ids = (dirNames(runsDir) ?? []).filter((n11) => existsSync95(join135(runsDir, n11, "receipt.json")));
79716
79840
  const id2 = ids[ids.length - 1];
79717
79841
  if (!id2)
79718
79842
  throw new Error(`repo ${text3(repo, 80)} has no receipt.json under worktrees/${slugOf(repo)}/.loki/runs`);
79719
- const rp = join134(runsDir, id2, "receipt.json"), bytes = readFileSync118(rp), r = readJson7(rp);
79843
+ const rp = join135(runsDir, id2, "receipt.json"), bytes = readFileSync119(rp), r = readJson7(rp);
79720
79844
  if (jsonTooDeep(r))
79721
79845
  throw new Error(`repo ${text3(repo, 80)} receipt cannot be hashed (nested too deeply); no composite`);
79722
79846
  if (!isObj10(r) || typeof r["receipt_sha256"] !== "string" || rh(r) !== r["receipt_sha256"])
@@ -79734,8 +79858,8 @@ function composeComposite(runDir, rh, toolchain = collectToolchain()) {
79734
79858
  throw new Error("workspace has no repos");
79735
79859
  return {
79736
79860
  schema: COMPOSITE_SCHEMA,
79737
- workspace: basename33(dirname51(runDir)),
79738
- run_id: basename33(runDir),
79861
+ workspace: basename34(dirname51(runDir)),
79862
+ run_id: basename34(runDir),
79739
79863
  integration_sha256: sha4(ibytes),
79740
79864
  integration: { status: String(integ["status"]), exit_code: typeof integ["exit_code"] === "number" ? integ["exit_code"] : null, log_sha256: typeof integ["log_sha256"] === "string" ? integ["log_sha256"] : null, heads },
79741
79865
  children,
@@ -79753,13 +79877,13 @@ async function verifyComposite(receiptPath, receipt, rh, verifyOne, deps = {}) {
79753
79877
  return bad("body malformed");
79754
79878
  let ibytes;
79755
79879
  try {
79756
- ibytes = readFileSync118(join134(runDir, "integration.json"));
79880
+ ibytes = readFileSync119(join135(runDir, "integration.json"));
79757
79881
  } catch {
79758
79882
  return bad("integration.json missing");
79759
79883
  }
79760
79884
  if (sha4(ibytes) !== receipt["integration_sha256"])
79761
79885
  return bad("integration.json does not match its recorded hash");
79762
- const integ = readJson7(join134(runDir, "integration.json"));
79886
+ const integ = readJson7(join135(runDir, "integration.json"));
79763
79887
  if (jsonTooDeep(integ))
79764
79888
  return deep("integration.json");
79765
79889
  if (!isObj10(integ) || !isObj10(integ["outcomes"]))
@@ -79796,10 +79920,10 @@ async function verifyComposite(receiptPath, receipt, rh, verifyOne, deps = {}) {
79796
79920
  return bad(`child ${text3(repo, 80) || "?"} has an invalid receipt path`);
79797
79921
  if (outcomes[repo] !== "ok")
79798
79922
  return bad(`child ${text3(repo, 80)} did not finish ok in integration.json`);
79799
- const rp = join134(runDir, rel);
79923
+ const rp = join135(runDir, rel);
79800
79924
  let bytes;
79801
79925
  try {
79802
- bytes = readFileSync118(rp);
79926
+ bytes = readFileSync119(rp);
79803
79927
  } catch {
79804
79928
  return bad(`child ${repo} receipt missing`);
79805
79929
  }
@@ -79859,16 +79983,16 @@ __export(exports_verify_cmd, {
79859
79983
  main: () => main9,
79860
79984
  computeReceiptHash: () => computeReceiptHash
79861
79985
  });
79862
- import { existsSync as existsSync95, readFileSync as readFileSync119, renameSync as renameSync23, statSync as statSync37, writeFileSync as writeFileSync68 } from "fs";
79863
- import { basename as basename34, dirname as dirname52, join as join135 } from "path";
79864
- import { createHash as createHash38, createPublicKey as createPublicKey6, verify as verify4 } from "crypto";
79986
+ import { existsSync as existsSync96, readFileSync as readFileSync120, renameSync as renameSync23, statSync as statSync37, writeFileSync as writeFileSync69 } from "fs";
79987
+ import { basename as basename35, dirname as dirname52, join as join136 } from "path";
79988
+ import { createHash as createHash39, createPublicKey as createPublicKey6, verify as verify4 } from "crypto";
79865
79989
  function pubFor(kid, given) {
79866
79990
  if (given)
79867
79991
  return kidOf2(given) === kid ? given : undefined;
79868
79992
  const active = loadSigningKey(false);
79869
79993
  const pubs = (process.env["LOKI_RECEIPT_RETIRED_PUBKEYS"] ?? "").split(":").map((f) => f.trim()).filter(Boolean).flatMap((f) => {
79870
79994
  try {
79871
- return [createPublicKey6(readFileSync119(f))];
79995
+ return [createPublicKey6(readFileSync120(f))];
79872
79996
  } catch {
79873
79997
  return [];
79874
79998
  }
@@ -79898,21 +80022,21 @@ function checkAttestation(jwt, expectedHash, given) {
79898
80022
  }
79899
80023
  function wallTamperProblem(receiptPath, receipt) {
79900
80024
  const wall = receipt["wall"], files = Array.isArray(wall?.files) ? wall.files : [];
79901
- const wallDir = join135(dirname52(receiptPath), "wall"), haveWallDir = existsSync95(wallDir);
80025
+ const wallDir = join136(dirname52(receiptPath), "wall"), haveWallDir = existsSync96(wallDir);
79902
80026
  for (const f of files) {
79903
80027
  if (typeof f?.path !== "string" || typeof f.sha256 !== "string")
79904
80028
  continue;
79905
- const copy = join135(wallDir, basename34(f.path));
80029
+ const copy = join136(wallDir, basename35(f.path));
79906
80030
  let cur;
79907
80031
  try {
79908
- cur = createHash38("sha256").update(readFileSync119(copy)).digest("hex");
80032
+ cur = createHash39("sha256").update(readFileSync120(copy)).digest("hex");
79909
80033
  } catch {
79910
80034
  if (haveWallDir)
79911
- return `sealed Wall file ${basename34(f.path)} is missing from the run's wall directory: it was deleted after the seal`;
80035
+ return `sealed Wall file ${basename35(f.path)} is missing from the run's wall directory: it was deleted after the seal`;
79912
80036
  continue;
79913
80037
  }
79914
80038
  if (cur !== f.sha256)
79915
- return `sealed Wall file ${basename34(f.path)} changed after the seal: receipt recorded sha256 ${f.sha256}, on disk ${cur}`;
80039
+ return `sealed Wall file ${basename35(f.path)} changed after the seal: receipt recorded sha256 ${f.sha256}, on disk ${cur}`;
79916
80040
  }
79917
80041
  return null;
79918
80042
  }
@@ -79927,15 +80051,15 @@ function checkEventLog(receiptPath, receipt) {
79927
80051
  }
79928
80052
  if (typeof bound !== "string")
79929
80053
  return null;
79930
- if (bound === createHash38("sha256").digest("hex")) {
80054
+ if (bound === createHash39("sha256").digest("hex")) {
79931
80055
  const st2 = receipt["time"]?.stages;
79932
80056
  const claims = st2 !== null && typeof st2 === "object" && Object.keys(st2).length > 0;
79933
80057
  return claims ? "the receipt records stages but binds the empty-log hash, so no events.jsonl can back it (missing, empty or non-empty); the receipt is forged or was sealed without a log. Re-run the task to produce a fresh receipt" : null;
79934
80058
  }
79935
- const path = join135(dirname52(receiptPath), "events.jsonl");
79936
- if (!existsSync95(path))
80059
+ const path = join136(dirname52(receiptPath), "events.jsonl");
80060
+ if (!existsSync96(path))
79937
80061
  return "events.jsonl is missing";
79938
- const raw2 = readFileSync119(path, "utf8"), events2 = readEvents(path), all = raw2.split(`
80062
+ const raw2 = readFileSync120(path, "utf8"), events2 = readEvents(path), all = raw2.split(`
79939
80063
  `).filter((l) => l.trim() !== ""), lines2 = tornTail(raw2) ? all.slice(0, -1) : all;
79940
80064
  if (events2.length !== lines2.length || events2.some((e10, i) => e10.seq !== i))
79941
80065
  return "events.jsonl has a forged, edited or missing line";
@@ -79945,7 +80069,7 @@ function checkEventLog(receiptPath, receipt) {
79945
80069
  return "events.jsonl has bytes the engine never writes (a blank line or stray whitespace); it was appended to after the seal";
79946
80070
  if (events2.some((e10) => e10.type === "tamper.detected"))
79947
80071
  return "the supervisor detected events.jsonl being modified during the run";
79948
- const h10 = createHash38("sha256");
80072
+ const h10 = createHash39("sha256");
79949
80073
  for (const l of lines2) {
79950
80074
  if (h10.copy().digest("hex") === bound)
79951
80075
  return null;
@@ -79955,7 +80079,7 @@ function checkEventLog(receiptPath, receipt) {
79955
80079
  return h10.digest("hex") === bound ? null : "events.jsonl does not match the hash recorded at seal";
79956
80080
  }
79957
80081
  function checkLogSeal(receiptPath, hash, kid, given) {
79958
- const path = join135(dirname52(receiptPath), "events.jsonl"), events2 = readEvents(path), done = events2.findIndex((e10) => e10.type === "run.completed");
80082
+ const path = join136(dirname52(receiptPath), "events.jsonl"), events2 = readEvents(path), done = events2.findIndex((e10) => e10.type === "run.completed");
79959
80083
  if (!events2.some((e10) => e10.type === "receipt.sealed" && e10.data["receipt_sha256"] === hash))
79960
80084
  return { verdict: "TAMPERED", reason: "events.jsonl has no receipt.sealed event for this receipt" };
79961
80085
  if (done < 0)
@@ -79963,8 +80087,8 @@ function checkLogSeal(receiptPath, hash, kid, given) {
79963
80087
  const seal = events2[done + 1], d = seal?.type === "log.sealed" ? seal.data : null;
79964
80088
  if (!d)
79965
80089
  return { verdict: "TAMPERED", reason: "events.jsonl has no signed log.sealed line after run.completed" };
79966
- const lines2 = readFileSync119(path, "utf8").split(`
79967
- `).filter((l) => l.trim() !== ""), sha7 = createHash38("sha256").update(lines2.slice(0, done + 1).join(`
80090
+ const lines2 = readFileSync120(path, "utf8").split(`
80091
+ `).filter((l) => l.trim() !== ""), sha7 = createHash39("sha256").update(lines2.slice(0, done + 1).join(`
79968
80092
  `) + `
79969
80093
  `).digest("hex");
79970
80094
  const pub = d["kid"] === kid ? pubFor(kid, given) : undefined;
@@ -79973,11 +80097,11 @@ function checkLogSeal(receiptPath, hash, kid, given) {
79973
80097
  return null;
79974
80098
  }
79975
80099
  async function verifyReceipt(receiptPath, deps = {}) {
79976
- if (!existsSync95(receiptPath))
80100
+ if (!existsSync96(receiptPath))
79977
80101
  return { verdict: "UNCHECKED", reasons: [`receipt not found: ${receiptPath}`] };
79978
80102
  let receipt;
79979
80103
  try {
79980
- receipt = JSON.parse((deps.read ?? ((p) => readFileSync119(p, "utf8")))(receiptPath));
80104
+ receipt = JSON.parse((deps.read ?? ((p) => readFileSync120(p, "utf8")))(receiptPath));
79981
80105
  } catch {
79982
80106
  return { verdict: "UNCHECKED", reasons: ["receipt.json is not valid JSON"] };
79983
80107
  }
@@ -80062,7 +80186,7 @@ async function verifyCompositeFile(receiptPath, receipt, deps) {
80062
80186
  }
80063
80187
  function sealCompositeCmd(runDir) {
80064
80188
  let body;
80065
- if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/.test(basename34(runDir.replace(/\/+$/, ""))))
80189
+ if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/.test(basename35(runDir.replace(/\/+$/, ""))))
80066
80190
  return process.stderr.write(`loki verify: run directory name is not a valid run id; composite would never verify
80067
80191
  `), 2;
80068
80192
  try {
@@ -80072,8 +80196,8 @@ function sealCompositeCmd(runDir) {
80072
80196
  `), 2;
80073
80197
  }
80074
80198
  const hash = compositeHash(body), sig = signReceipt(body.run_id, hash);
80075
- const out3 = { ...body, composite_sha256: hash, verification: { jwt: sig.jwt, kid: sig.kid } }, path = join135(runDir, "composite.json");
80076
- writeFileSync68(`${path}.tmp`, JSON.stringify(out3, null, 2) + `
80199
+ const out3 = { ...body, composite_sha256: hash, verification: { jwt: sig.jwt, kid: sig.kid } }, path = join136(runDir, "composite.json");
80200
+ writeFileSync69(`${path}.tmp`, JSON.stringify(out3, null, 2) + `
80077
80201
  `);
80078
80202
  renameSync23(`${path}.tmp`, path);
80079
80203
  process.stdout.write(`composite: ${path}
@@ -80088,7 +80212,7 @@ ${compositeLines(out3).join(`
80088
80212
  function independentLine(receiptPath) {
80089
80213
  let checks = [];
80090
80214
  try {
80091
- const c = JSON.parse(readFileSync119(receiptPath, "utf8")).checks;
80215
+ const c = JSON.parse(readFileSync120(receiptPath, "utf8")).checks;
80092
80216
  if (Array.isArray(c))
80093
80217
  checks = c;
80094
80218
  } catch {}
@@ -80145,14 +80269,14 @@ ${/^(unknown option|expected at most one)/.test(pk2.error) ? `Usage: loki verify
80145
80269
  args = pk2.args;
80146
80270
  if (pk2.pubkey)
80147
80271
  deps = { ...deps, pubkey: pk2.pubkey };
80148
- const runsRoot2 = deps.runsRoot ?? join135(lokiDir(), "runs");
80272
+ const runsRoot2 = deps.runsRoot ?? join136(lokiDir(), "runs");
80149
80273
  const runId2 = args[0] ?? latestRunId(runsRoot2) ?? undefined;
80150
80274
  if (!runId2)
80151
80275
  return process.stderr.write(`loki verify: no runs found
80152
80276
  `), 66;
80153
- const isFile = existsSync95(runId2) && statSync37(runId2).isFile();
80277
+ const isFile = existsSync96(runId2) && statSync37(runId2).isFile();
80154
80278
  const isPath = isFile || /[\\/]/.test(runId2) || runId2.endsWith(".json");
80155
- const receiptPath = isPath ? runId2 : join135(runsRoot2, runId2, "receipt.json");
80279
+ const receiptPath = isPath ? runId2 : join136(runsRoot2, runId2, "receipt.json");
80156
80280
  const byRunId = !isPath;
80157
80281
  rec2.runId = runId2;
80158
80282
  rec2.receiptPath = receiptPath;
@@ -80168,7 +80292,7 @@ verdict: TAMPERED
80168
80292
  if (result.verdict === "VERIFIED" || result.verdict === "UNSIGNED") {
80169
80293
  const d = (() => {
80170
80294
  try {
80171
- return sealDrift(receiptPath, JSON.parse(readFileSync119(receiptPath, "utf8")));
80295
+ return sealDrift(receiptPath, JSON.parse(readFileSync120(receiptPath, "utf8")));
80172
80296
  } catch {
80173
80297
  return null;
80174
80298
  }
@@ -80181,7 +80305,7 @@ verdict: TAMPERED
80181
80305
  {
80182
80306
  const id2 = (() => {
80183
80307
  try {
80184
- const r = JSON.parse(readFileSync119(receiptPath, "utf8"));
80308
+ const r = JSON.parse(readFileSync120(receiptPath, "utf8"));
80185
80309
  const j10 = r["verification"]?.jwt;
80186
80310
  const k3 = result.verdict === "VERIFIED" && typeof j10 === "string" ? JSON.parse(Buffer.from(j10.split(".")[0], "base64url").toString()).kid : null;
80187
80311
  return { kid: typeof k3 === "string" ? k3 : null, head: typeof r["head_sha"] === "string" ? r["head_sha"] : null, verdict: typeof r["verdict"] === "string" ? r["verdict"] : null, run: typeof r["run_id"] === "string" ? r["run_id"] : null };
@@ -80199,7 +80323,7 @@ verdict: TAMPERED
80199
80323
  if (result.verdict === "VERIFIED" || result.verdict === "UNSIGNED") {
80200
80324
  const outcome = (() => {
80201
80325
  try {
80202
- return outcomeOf2(JSON.parse(readFileSync119(receiptPath, "utf8")));
80326
+ return outcomeOf2(JSON.parse(readFileSync120(receiptPath, "utf8")));
80203
80327
  } catch {
80204
80328
  return "UNREADABLE";
80205
80329
  }
@@ -80228,7 +80352,7 @@ verdict: ${result.verdict}
80228
80352
  `);
80229
80353
  if (result.verdict !== "TAMPERED")
80230
80354
  try {
80231
- const r = JSON.parse(readFileSync119(receiptPath, "utf8"));
80355
+ const r = JSON.parse(readFileSync120(receiptPath, "utf8"));
80232
80356
  if (isComposite(r))
80233
80357
  for (const l of compositeLines(r))
80234
80358
  process.stdout.write(`${l}
@@ -80286,8 +80410,8 @@ var init_verify_cmd = __esm(() => {
80286
80410
  });
80287
80411
 
80288
80412
  // src/server/app.ts
80289
- import { existsSync as existsSync97, readFileSync as readFileSync122, statSync as statSync38 } from "fs";
80290
- import { join as join138, resolve as resolve40, sep as sep23 } from "path";
80413
+ import { existsSync as existsSync98, readFileSync as readFileSync123, statSync as statSync38 } from "fs";
80414
+ import { join as join139, resolve as resolve40, sep as sep23 } from "path";
80291
80415
 
80292
80416
  // node_modules/hono/dist/request/constants.js
80293
80417
  var GET_MATCH_RESULT = Symbol();
@@ -90598,9 +90722,9 @@ function mount20(ctx) {
90598
90722
  }
90599
90723
 
90600
90724
  // src/server/routes/verify.ts
90601
- import { readFileSync as readFileSync120, realpathSync as realpathSync36 } from "fs";
90725
+ import { readFileSync as readFileSync121, realpathSync as realpathSync36 } from "fs";
90602
90726
  import { createPublicKey as createPublicKey7 } from "crypto";
90603
- import { join as join136, sep as sep22 } from "path";
90727
+ import { join as join137, sep as sep22 } from "path";
90604
90728
  init_verify_cmd();
90605
90729
  init_seal();
90606
90730
  init_receipt_dsse();
@@ -90627,11 +90751,11 @@ function mount21(ctx) {
90627
90751
  return done(404, "receipt not available", "not_found");
90628
90752
  let runDir, file;
90629
90753
  try {
90630
- const root = realpathSync36(join136(repo.p, ".loki", "runs"));
90631
- runDir = realpathSync36(join136(root, run2));
90632
- if (runDir !== join136(root, run2))
90754
+ const root = realpathSync36(join137(repo.p, ".loki", "runs"));
90755
+ runDir = realpathSync36(join137(root, run2));
90756
+ if (runDir !== join137(root, run2))
90633
90757
  return done(404, "receipt not found", "not_found");
90634
- file = realpathSync36(join136(runDir, "receipt.json"));
90758
+ file = realpathSync36(join137(runDir, "receipt.json"));
90635
90759
  } catch {
90636
90760
  return done(404, "receipt not found", "not_found");
90637
90761
  }
@@ -90650,7 +90774,7 @@ function mount21(ctx) {
90650
90774
  sha7 = r.receiptSha256 ?? null;
90651
90775
  }
90652
90776
  try {
90653
- outcome = outcomeOf2(JSON.parse(readFileSync120(file, "utf8")));
90777
+ outcome = outcomeOf2(JSON.parse(readFileSync121(file, "utf8")));
90654
90778
  } catch {
90655
90779
  outcome = "UNREADABLE";
90656
90780
  }
@@ -90712,8 +90836,8 @@ function ttlCache(ttlMs = PROBE_CACHE_MS, now2 = Date.now) {
90712
90836
  }
90713
90837
 
90714
90838
  // src/server/legacy/shim.ts
90715
- import { existsSync as existsSync96, readFileSync as readFileSync121 } from "fs";
90716
- import { join as join137 } from "path";
90839
+ import { existsSync as existsSync97, readFileSync as readFileSync122 } from "fs";
90840
+ import { join as join138 } from "path";
90717
90841
 
90718
90842
  // src/server/legacy/routes.ts
90719
90843
  var LEGACY_ROUTES = [
@@ -91091,10 +91215,10 @@ var logged = new Set;
91091
91215
  var toHono = (p) => p.replace(/\{([A-Za-z_]+):path\}/g, ":$1{.+}").replace(/\{([A-Za-z_]+)\}/g, ":$1");
91092
91216
  var NOT_SUPPORTED = "not yet supported by the Control Plane";
91093
91217
  var repoVersion = () => {
91094
- for (const f of [join137(import.meta.dir, "../../../../../VERSION")]) {
91218
+ for (const f of [join138(import.meta.dir, "../../../../../VERSION")]) {
91095
91219
  try {
91096
- if (existsSync96(f))
91097
- return readFileSync121(f, "utf8").trim();
91220
+ if (existsSync97(f))
91221
+ return readFileSync122(f, "utf8").trim();
91098
91222
  } catch {}
91099
91223
  }
91100
91224
  return "unknown";
@@ -91276,7 +91400,7 @@ function legacyShim(opts) {
91276
91400
 
91277
91401
  // src/server/app.ts
91278
91402
  var MAX_BODY2 = 1e6;
91279
- var defaultUiDir = () => [join138(import.meta.dir, "../../ui/dist"), join138(import.meta.dir, "../ui/dist")].find((d) => existsSync97(join138(d, "index.html")));
91403
+ var defaultUiDir = () => [join139(import.meta.dir, "../../ui/dist"), join139(import.meta.dir, "../ui/dist")].find((d) => existsSync98(join139(d, "index.html")));
91280
91404
  function createApp(opts) {
91281
91405
  const uiDir = opts.uiDir ?? defaultUiDir();
91282
91406
  const { db: db2, sqlite } = openDb(opts.dbPath);
@@ -91305,10 +91429,10 @@ function createApp(opts) {
91305
91429
  await next();
91306
91430
  });
91307
91431
  const readInstalled = () => {
91308
- for (const f of [process.env.LOKI_VERSION_FILE, join138(import.meta.dir, "../../../../VERSION")]) {
91432
+ for (const f of [process.env.LOKI_VERSION_FILE, join139(import.meta.dir, "../../../../VERSION")]) {
91309
91433
  try {
91310
91434
  if (f)
91311
- return readFileSync122(f, "utf8").trim() || "unknown";
91435
+ return readFileSync123(f, "utf8").trim() || "unknown";
91312
91436
  } catch {}
91313
91437
  }
91314
91438
  return "unknown";
@@ -91419,11 +91543,11 @@ function createApp(opts) {
91419
91543
  return c.json({ error: "not found" }, 404);
91420
91544
  const root = resolve40(uiDir);
91421
91545
  const f = resolve40(root, `.${p}`);
91422
- if (f.startsWith(root + sep23) && existsSync97(f) && statSync38(f).isFile())
91546
+ if (f.startsWith(root + sep23) && existsSync98(f) && statSync38(f).isFile())
91423
91547
  return new Response(Bun.file(f));
91424
91548
  if (/\.[a-z0-9]+$/i.test(p))
91425
91549
  return c.json({ error: "not found" }, 404);
91426
- return new Response(Bun.file(join138(root, "index.html")));
91550
+ return new Response(Bun.file(join139(root, "index.html")));
91427
91551
  });
91428
91552
  return { app, db: db2, close: () => {
91429
91553
  clearInterval(reconciler);