loki-mode 11.114.0 → 11.115.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/SKILL.md +2 -2
  2. package/VERSION +1 -1
  3. package/autonomy/loki +30 -129
  4. package/autonomy/quickstart.sh +25 -42
  5. package/autonomy/route.sh +42 -9
  6. package/bin/loki +38 -24
  7. package/dashboard/__init__.py +1 -1
  8. package/docs/CLI-REFERENCE.md +1 -1
  9. package/docs/INSTALLATION.md +2 -2
  10. package/docs/exit-codes.md +1 -1
  11. package/docs/v10/GUIDE.md +15 -12
  12. package/loki-ts/dist/loki.js +513 -512
  13. package/mcp/__init__.py +1 -1
  14. package/package.json +2 -2
  15. package/packages/control-plane/dist/server.js +396 -373
  16. package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
  17. package/web-app/dist/assets/{AdminPage-DHD5YwZO.js → AdminPage-CLt-wTEW.js} +1 -1
  18. package/web-app/dist/assets/{Avatar-DbmXZYj_.js → Avatar-_AmCl55M.js} +1 -1
  19. package/web-app/dist/assets/{Badge-Nq9IlKbi.js → Badge-C_jPseM2.js} +1 -1
  20. package/web-app/dist/assets/{Button-BB29bg4G.js → Button-CWos7s9a.js} +1 -1
  21. package/web-app/dist/assets/{CockpitPage-D3WGuYal.js → CockpitPage-BLOWb4S2.js} +1 -1
  22. package/web-app/dist/assets/{ComparePage-Dc7txTbc.js → ComparePage-Bc-WNJaw.js} +1 -1
  23. package/web-app/dist/assets/{ErrorBoundary-DO85OYYt.js → ErrorBoundary-Ct1mDa90.js} +1 -1
  24. package/web-app/dist/assets/{EvidenceReceiptPanel-BX36iUDO.js → EvidenceReceiptPanel-pza0n1ty.js} +1 -1
  25. package/web-app/dist/assets/{GitHubIssuesPanel-BC-rWDVk.js → GitHubIssuesPanel-nMFy01T7.js} +1 -1
  26. package/web-app/dist/assets/{GitHubPRsPanel-DozNklyN.js → GitHubPRsPanel-CMSBADNj.js} +1 -1
  27. package/web-app/dist/assets/{HomePage-CvlpZnMF.js → HomePage-ehqhrsQe.js} +2 -2
  28. package/web-app/dist/assets/{LoginPage-D8triQep.js → LoginPage-CQp6lhty.js} +1 -1
  29. package/web-app/dist/assets/{MagicPage-CJ3w-QA1.js → MagicPage-BTYQWXyU.js} +1 -1
  30. package/web-app/dist/assets/{MetricsPage-DkeWF6w_.js → MetricsPage-ikIhWjPC.js} +1 -1
  31. package/web-app/dist/assets/{NotFoundPage-C6ug2gpC.js → NotFoundPage-CS3l-ChX.js} +1 -1
  32. package/web-app/dist/assets/{ProjectPage-DW2tYr2l.js → ProjectPage-CVfRF_Ct.js} +3 -3
  33. package/web-app/dist/assets/{ProjectsPage-BdFBxCoq.js → ProjectsPage-CIWMxVP_.js} +1 -1
  34. package/web-app/dist/assets/{SettingsPage-DXfa2-qh.js → SettingsPage-B9KU5D2w.js} +1 -1
  35. package/web-app/dist/assets/{ShowcasePage-BYHFTJCy.js → ShowcasePage-Dg6OGSEF.js} +1 -1
  36. package/web-app/dist/assets/{SystemSettingsPage-3XJw6IrI.js → SystemSettingsPage-BIOv4rVr.js} +1 -1
  37. package/web-app/dist/assets/{TeamsPage-TeTfhM1F.js → TeamsPage-Dejcxxlu.js} +1 -1
  38. package/web-app/dist/assets/{TemplatesPage-D43YOPTJ.js → TemplatesPage-CCysEWaz.js} +1 -1
  39. package/web-app/dist/assets/{TerminalOutput-BPnAqK64.js → TerminalOutput-RQsssvJM.js} +1 -1
  40. package/web-app/dist/assets/{activity-DCCAY929.js → activity-DdLAQ_51.js} +1 -1
  41. package/web-app/dist/assets/{bell-BsVsHi3h.js → bell-BxZyZdvO.js} +1 -1
  42. package/web-app/dist/assets/{bot-BbN7wMZX.js → bot-YV3xWoPK.js} +1 -1
  43. package/web-app/dist/assets/{check-Tyk1mrdH.js → check-B0nOO-9W.js} +1 -1
  44. package/web-app/dist/assets/{chevron-left-DBBD8bZs.js → chevron-left-ByTE-Q8f.js} +1 -1
  45. package/web-app/dist/assets/{circle-alert-BFBU13St.js → circle-alert-DQNaOXIO.js} +1 -1
  46. package/web-app/dist/assets/{clock-Bkk7v3pN.js → clock-D_XB7W8n.js} +1 -1
  47. package/web-app/dist/assets/{cloud-DdxKGfzC.js → cloud-BSzLDv2y.js} +1 -1
  48. package/web-app/dist/assets/{code-xml--6j3vK62.js → code-xml-BqRjDgg5.js} +1 -1
  49. package/web-app/dist/assets/{database-wgf6WWvv.js → database-Bv5v49-U.js} +1 -1
  50. package/web-app/dist/assets/{dollar-sign-CRCXoq4I.js → dollar-sign-NeoXzalo.js} +1 -1
  51. package/web-app/dist/assets/{file-code-corner-D6IDMxIq.js → file-code-corner-Byb9oE9e.js} +1 -1
  52. package/web-app/dist/assets/{file-plus-DLz_nZaL.js → file-plus-BjrNsgqg.js} +1 -1
  53. package/web-app/dist/assets/{globe-DXXv2npn.js → globe-7nXBAnf5.js} +1 -1
  54. package/web-app/dist/assets/{hammer-DgV8WFmY.js → hammer-BSzyJNYG.js} +1 -1
  55. package/web-app/dist/assets/{index-CuuEG3hc.js → index-BDE396DT.js} +3 -3
  56. package/web-app/dist/assets/{layers-BtKE0z6S.js → layers-Las0Giv2.js} +1 -1
  57. package/web-app/dist/assets/{loader-circle-DhmVhPNf.js → loader-circle-DMZ-MAqB.js} +1 -1
  58. package/web-app/dist/assets/{lock-BJZysQgx.js → lock-BtWTiBTH.js} +1 -1
  59. package/web-app/dist/assets/{package-BFAOCws4.js → package-DP0GgNkB.js} +1 -1
  60. package/web-app/dist/assets/{plus-C8NOHg9l.js → plus-4917sY-l.js} +1 -1
  61. package/web-app/dist/assets/{refresh-cw-97PjfXPq.js → refresh-cw-wuIoLSNK.js} +1 -1
  62. package/web-app/dist/assets/{rotate-ccw-Dpq_tfhl.js → rotate-ccw-BRDEqchX.js} +1 -1
  63. package/web-app/dist/assets/{scroll-text-CxXHbR8d.js → scroll-text-B8VYlm45.js} +1 -1
  64. package/web-app/dist/assets/{server-BcsDNKwP.js → server-DYmIcf8d.js} +1 -1
  65. package/web-app/dist/assets/{shield-alert-jSGg7ywe.js → shield-alert-CXDJ30r1.js} +1 -1
  66. package/web-app/dist/assets/{thumbs-up-CVARZVuU.js → thumbs-up-X863JNkQ.js} +1 -1
  67. package/web-app/dist/assets/{trash-2-DUYZejSc.js → trash-2-bok8gFGB.js} +1 -1
  68. package/web-app/dist/assets/{trending-down-DoEuZ_uI.js → trending-down-B_gtPxRQ.js} +1 -1
  69. package/web-app/dist/assets/{trending-up-DSC8EGV3.js → trending-up-CNIXijLQ.js} +1 -1
  70. package/web-app/dist/assets/{upload-D2k1cwYw.js → upload-ihiK-592.js} +1 -1
  71. package/web-app/dist/assets/{usePolling-DMhCgxhw.js → usePolling-C0VEkwmx.js} +1 -1
  72. package/web-app/dist/assets/{user-CfFpJKIA.js → user-BK4TYpOC.js} +1 -1
  73. package/web-app/dist/index.html +1 -1
@@ -36402,13 +36402,24 @@ __export(exports_first_run_repo, {
36402
36402
  initEmptyRepo: () => initEmptyRepo,
36403
36403
  NOT_A_REPO: () => NOT_A_REPO
36404
36404
  });
36405
- import { readdirSync as readdirSync38 } from "fs";
36405
+ import { readdirSync as readdirSync38, statSync as statSync31 } from "fs";
36406
+ import { join as join110 } from "path";
36406
36407
  async function initEmptyRepo(dir, env) {
36407
36408
  if (env["LOKI_AUTO_GIT_INIT"] === "0")
36408
36409
  return { fatal: NOT_A_REPO(dir) };
36409
- let empty = false;
36410
+ const ours = firstRunFiles(env);
36411
+ let empty = false, written = [];
36412
+ const isFile = (f) => {
36413
+ try {
36414
+ return statSync31(join110(dir, f)).isFile();
36415
+ } catch {
36416
+ return false;
36417
+ }
36418
+ };
36410
36419
  try {
36411
- empty = readdirSync38(dir).every((f) => OS_METADATA.has(f));
36420
+ const all = readdirSync38(dir);
36421
+ written = all.filter((f) => ours.has(f) && isFile(f));
36422
+ empty = all.every((f) => OS_METADATA.has(f) || written.includes(f));
36412
36423
  } catch {}
36413
36424
  if (!empty)
36414
36425
  return { fatal: NON_EMPTY_FIX(dir) };
@@ -36416,10 +36427,20 @@ async function initEmptyRepo(dir, env) {
36416
36427
  if ((await git8(["init", "-q"])).exitCode !== 0)
36417
36428
  return { fatal: NOT_A_REPO(dir) };
36418
36429
  await git8(["symbolic-ref", "HEAD", "refs/heads/main"]);
36419
- await git8(["commit", "-q", "--allow-empty", "-m", "init"]);
36420
- return { notice: `initialized a new git repository in ${dir} (LOKI_AUTO_GIT_INIT=0 to refuse)` };
36430
+ const [name, email] = await Promise.all([git8(["config", "user.name"]), git8(["config", "user.email"])]);
36431
+ const noName = !name.stdout.trim(), noEmail = !email.stdout.trim(), localId = noName || noEmail;
36432
+ if (noName)
36433
+ await git8(["config", "user.name", "Loki Mode"]);
36434
+ if (noEmail)
36435
+ await git8(["config", "user.email", "loki@localhost"]);
36436
+ if (written.length > 0) {
36437
+ await git8(["add", "--", ...written]);
36438
+ await git8(["commit", "-q", "-m", "init"]);
36439
+ } else
36440
+ await git8(["commit", "-q", "--allow-empty", "-m", "init"]);
36441
+ return { notice: `initialized a new git repository in ${dir} (LOKI_AUTO_GIT_INIT=0 to refuse)${localId ? `; git had no ${noName && noEmail ? "identity" : noName ? "user.name" : "user.email"}, so this repo sets ${[noName ? 'user.name "Loki Mode"' : "", noEmail ? "user.email loki@localhost" : ""].filter(Boolean).join(" and ")} (git config to change it)` : ""}` };
36421
36442
  }
36422
- var NOT_A_REPO = (dir) => `not a git repository: ${dir} is not inside a git work tree; run loki from inside a git checkout`, NON_EMPTY_FIX = (dir) => `${NOT_A_REPO(dir)}. This folder is not empty, so loki will not initialise it; run: git init && git add . && git commit -m init`, OS_METADATA;
36443
+ var NOT_A_REPO = (dir) => `not a git repository: ${dir} is not inside a git work tree; run loki from inside a git checkout`, NON_EMPTY_FIX = (dir) => `${NOT_A_REPO(dir)}. This folder is not empty, so loki will not initialise it; run: git init && git add . && git commit -m init`, OS_METADATA, firstRunFiles = (env) => new Set((env["LOKI_FIRST_RUN_FILES"] ?? "").split(",").map((f) => f.trim()).filter((f) => f !== "" && !f.includes("/") && f !== "." && f !== ".."));
36423
36444
  var init_first_run_repo = __esm(() => {
36424
36445
  init_safe_git();
36425
36446
  OS_METADATA = new Set([".DS_Store", ".localized", "Thumbs.db", "desktop.ini"]);
@@ -36435,7 +36456,7 @@ __export(exports_preflight, {
36435
36456
  PreflightError: () => PreflightError
36436
36457
  });
36437
36458
  import { accessSync as accessSync4, constants as fsc2, mkdirSync as mkdirSync53, statfsSync as statfsSync2, writeFileSync as writeFileSync55 } from "fs";
36438
- import { join as join110 } from "path";
36459
+ import { join as join111 } from "path";
36439
36460
  async function sh2(argv, opts) {
36440
36461
  try {
36441
36462
  return await run(argv, opts);
@@ -36528,7 +36549,7 @@ async function checkPreflight(o) {
36528
36549
  if (o.runDir && hits.every(([b]) => b === "not_logged_in")) {
36529
36550
  try {
36530
36551
  mkdirSync53(o.runDir, { recursive: true });
36531
- writeFileSync55(join110(o.runDir, "preflight.json"), JSON.stringify({ provider: o.provider, auth_path, probe }) + `
36552
+ writeFileSync55(join111(o.runDir, "preflight.json"), JSON.stringify({ provider: o.provider, auth_path, probe }) + `
36532
36553
  `);
36533
36554
  } catch {}
36534
36555
  }
@@ -36669,7 +36690,7 @@ var init_one_line_goal = __esm(() => {
36669
36690
 
36670
36691
  // ../../loki-ts/src/util/group_integrate.ts
36671
36692
  import { existsSync as existsSync76, mkdirSync as mkdirSync54, readFileSync as readFileSync97, rmSync as rmSync27, writeFileSync as writeFileSync56 } from "fs";
36672
- import { basename as basename30, dirname as dirname46, join as join111, normalize as normalize7 } from "path";
36693
+ import { basename as basename30, dirname as dirname46, join as join112, normalize as normalize7 } from "path";
36673
36694
  function integrationOrder(dag) {
36674
36695
  const ids = dag.units.map((u) => u.id), indeg = new Map(ids.map((i) => [i, 0]));
36675
36696
  for (const e of dag.edges)
@@ -36705,7 +36726,7 @@ async function rerunWalls(runner, repoDir, merged, walls) {
36705
36726
  }
36706
36727
  try {
36707
36728
  for (const f of bad ? [] : files) {
36708
- const rel = normalize7(f.rel), abs = join111(repoDir, rel), r2 = f.runner ?? guessRunner(basename30(rel), harnessRunners([], [rel], process.env, repoDir, [rel]), rel);
36729
+ const rel = normalize7(f.rel), abs = join112(repoDir, rel), r2 = f.runner ?? guessRunner(basename30(rel), harnessRunners([], [rel], process.env, repoDir, [rel]), rel);
36709
36730
  if (bad = wallPathProblem(repoDir, rel) ?? (r2 ? undefined : `no runner for ${f.rel}`))
36710
36731
  break;
36711
36732
  written.push({ abs, prev: existsSync76(abs) ? readFileSync97(abs) : null });
@@ -37167,10 +37188,10 @@ __export(exports_run_group, {
37167
37188
  groupCostLine: () => groupCostLine,
37168
37189
  NOT_PROVEN: () => NOT_PROVEN
37169
37190
  });
37170
- import { cpSync as cpSync3, existsSync as existsSync77, mkdirSync as mkdirSync55, readdirSync as readdirSync39, readFileSync as readFileSync98, rmSync as rmSync28, statSync as statSync31 } from "fs";
37191
+ import { cpSync as cpSync3, existsSync as existsSync77, mkdirSync as mkdirSync55, readdirSync as readdirSync39, readFileSync as readFileSync98, rmSync as rmSync28, statSync as statSync32 } from "fs";
37171
37192
  import { createHash as createHash32 } from "crypto";
37172
37193
  import { spawn as spawn12 } from "child_process";
37173
- import { join as join112, resolve as resolve29 } from "path";
37194
+ import { join as join113, resolve as resolve29 } from "path";
37174
37195
  function scopedEnv(env) {
37175
37196
  const out2 = {};
37176
37197
  for (const [k, v] of Object.entries(env))
@@ -37207,7 +37228,7 @@ function groupCostLine(costs, provider = "claude") {
37207
37228
  `;
37208
37229
  }
37209
37230
  function writeGroupCostRecord(repoDir, name, costs, provider) {
37210
- const dir = join112(repoDir, ".loki", "metrics", "efficiency");
37231
+ const dir = join113(repoDir, ".loki", "metrics", "efficiency");
37211
37232
  const timestamp = new Date().toISOString();
37212
37233
  try {
37213
37234
  const base = { phase: "implement", provider, status: "group", kind: "group_cost", timestamp };
@@ -37221,7 +37242,7 @@ function writeGroupCostRecord(repoDir, name, costs, provider) {
37221
37242
  if (recs.length === 0)
37222
37243
  return;
37223
37244
  mkdirSync55(dir, { recursive: true });
37224
- recs.forEach((r, k) => atomicWriteJson(join112(dir, `iteration-group-${name}-${String(k).padStart(3, "0")}.json`), r));
37245
+ recs.forEach((r, k) => atomicWriteJson(join113(dir, `iteration-group-${name}-${String(k).padStart(3, "0")}.json`), r));
37225
37246
  } catch {}
37226
37247
  }
37227
37248
  function testCommand(repoDir, env) {
@@ -37234,7 +37255,7 @@ function testCommand(repoDir, env) {
37234
37255
  return [];
37235
37256
  }
37236
37257
  function findResumable(repoDir, specSha, unitIds) {
37237
- const root = join112(repoDir, ".loki", "groups");
37258
+ const root = join113(repoDir, ".loki", "groups");
37238
37259
  let names = [];
37239
37260
  try {
37240
37261
  names = readdirSync39(root);
@@ -37245,12 +37266,12 @@ function findResumable(repoDir, specSha, unitIds) {
37245
37266
  for (const gid of names) {
37246
37267
  if (!GID_RE.test(gid))
37247
37268
  continue;
37248
- const p = join112(root, gid, "dag.json"), d = readJson7(p);
37269
+ const p = join113(root, gid, "dag.json"), d = readJson7(p);
37249
37270
  if (!d || (unitIds ? JSON.stringify((Array.isArray(d["units"]) ? d["units"] : []).filter((u) => !u.fixKind).map((u) => u.id)) !== JSON.stringify(unitIds) : d["spec_sha256"] !== specSha) || typeof d["base_ref"] !== "string" || !Array.isArray(d["units"]))
37250
37271
  continue;
37251
37272
  let at = 0;
37252
37273
  try {
37253
- at = statSync31(p).mtimeMs;
37274
+ at = statSync32(p).mtimeMs;
37254
37275
  } catch {
37255
37276
  continue;
37256
37277
  }
@@ -37262,7 +37283,7 @@ function findResumable(repoDir, specSha, unitIds) {
37262
37283
  async function unitDone(verifyReceipt, repoDir, gid, n3, id) {
37263
37284
  if (!UNIT_ID_RE.test(id))
37264
37285
  return false;
37265
- const rp = join112(repoDir, ".loki", "groups", gid, "group", "units", id, "receipt.json");
37286
+ const rp = join113(repoDir, ".loki", "groups", gid, "group", "units", id, "receipt.json");
37266
37287
  const rec2 = readJson7(rp);
37267
37288
  if (!rec2 || rec2["verdict"] !== "VERIFIED")
37268
37289
  return false;
@@ -37277,7 +37298,7 @@ async function adoptJournaled(verifyReceipt, repoDir, dir, key, gid, n3, id, tas
37277
37298
  return false;
37278
37299
  if (!await unitDone(verifyReceipt, repoDir, e.gid, e.n, id))
37279
37300
  return false;
37280
- const signed = readJson7(join112(repoDir, ".loki", "groups", e.gid, "group", "units", id, "receipt.json"));
37301
+ const signed = readJson7(join113(repoDir, ".loki", "groups", e.gid, "group", "units", id, "receipt.json"));
37281
37302
  const signedTask = (signed?.["task"] ?? {}).sha256;
37282
37303
  const signedSpec = (signed?.["unit_spec"] ?? {}).sha256;
37283
37304
  if (typeof signedSpec !== "string" || signedSpec === "" || signedSpec !== specSha)
@@ -37287,9 +37308,9 @@ async function adoptJournaled(verifyReceipt, repoDir, dir, key, gid, n3, id, tas
37287
37308
  const tip = git9(repoDir, ["rev-parse", "--verify", "--quiet", `refs/heads/loki/unit-${e.gid}-${e.n}`]);
37288
37309
  if (tip === "" || tip !== e.head)
37289
37310
  return false;
37290
- const dst = join112(repoDir, ".loki", "groups", gid, "group", "units", id);
37311
+ const dst = join113(repoDir, ".loki", "groups", gid, "group", "units", id);
37291
37312
  rmSync28(dst, { recursive: true, force: true });
37292
- cpSync3(join112(repoDir, ".loki", "groups", e.gid, "group", "units", id), dst, { recursive: true });
37313
+ cpSync3(join113(repoDir, ".loki", "groups", e.gid, "group", "units", id), dst, { recursive: true });
37293
37314
  if (safeGitSpawn(repoDir, ["update-ref", `refs/heads/loki/unit-${gid}-${n3}`, tip], { encoding: "utf8" }).status !== 0)
37294
37315
  return false;
37295
37316
  if (!await unitDone(verifyReceipt, repoDir, gid, n3, id))
@@ -37345,8 +37366,8 @@ async function runGroupCore(launcher, dag, ctx) {
37345
37366
  const revised = resumable !== null && exact === null;
37346
37367
  const changed = new Set;
37347
37368
  const groupId = resumable?.gid ?? `g${Date.now().toString(36)}`;
37348
- const groupDir = join112(repoDir, ".loki", "groups", groupId);
37349
- const receiptPath = join112(groupDir, "receipt.json");
37369
+ const groupDir = join113(repoDir, ".loki", "groups", groupId);
37370
+ const receiptPath = join113(groupDir, "receipt.json");
37350
37371
  const slugOf = () => originSlug(repoDir);
37351
37372
  let baseRef;
37352
37373
  let startBranch = "";
@@ -37438,10 +37459,10 @@ async function runGroupCore(launcher, dag, ctx) {
37438
37459
  const accOf = new Map;
37439
37460
  for (const cu of Array.isArray(gc?.["units"]) ? gc["units"] : [])
37440
37461
  accOf.set(cu.id, cu.criteria.map((c) => c.text));
37441
- const specDir = join112(groupDir, "unit_specs");
37462
+ const specDir = join113(groupDir, "unit_specs");
37442
37463
  mkdirSync55(specDir, { recursive: true });
37443
37464
  for (const u of units) {
37444
- const spec = join112(specDir, `${u.id}.json`);
37465
+ const spec = join113(specDir, `${u.id}.json`);
37445
37466
  const isFix = !!u.fixKind;
37446
37467
  if (!isFix)
37447
37468
  u.base = baseRef;
@@ -37467,19 +37488,19 @@ async function runGroupCore(launcher, dag, ctx) {
37467
37488
  say(`loki: unit ${u.id} skipped-unchanged
37468
37489
  `);
37469
37490
  } else if (resumable && UNIT_ID_RE.test(u.id))
37470
- rmSync28(join112(groupDir, "group", "units", u.id), { recursive: true, force: true });
37491
+ rmSync28(join113(groupDir, "group", "units", u.id), { recursive: true, force: true });
37471
37492
  }
37472
37493
  const cut = units.findIndex((u) => u.fixKind && !u.done);
37473
37494
  if (cut >= 0)
37474
37495
  for (const u of units.splice(cut)) {
37475
37496
  if (u.done)
37476
37497
  doneCount--;
37477
- rmSync28(join112(groupDir, "group", "units", u.id), { recursive: true, force: true });
37498
+ rmSync28(join113(groupDir, "group", "units", u.id), { recursive: true, force: true });
37478
37499
  }
37479
37500
  if (resumable)
37480
37501
  say(`loki: resuming group ${groupId}: ${doneCount} of ${units.length} units already VERIFIED
37481
37502
  `);
37482
- const dagPath = join112(groupDir, "dag.json");
37503
+ const dagPath = join113(groupDir, "dag.json");
37483
37504
  atomicWriteJson(dagPath, { group: groupId, spec_sha256: specSha, base_ref: baseRef, start_branch: startBranch, ...full, units });
37484
37505
  try {
37485
37506
  const chk = await checkDecomposable(full, { map: (() => {
@@ -37509,7 +37530,7 @@ async function runGroupCore(launcher, dag, ctx) {
37509
37530
  const n3 = Math.min(slots, pending);
37510
37531
  say(`loki: group ${groupId}: ${units.length} units, ${n3} parallel slot(s) (provider ${provider})
37511
37532
  `);
37512
- const backlog = join112(REPO_ROOT, "autonomy", "lib", "backlog.py");
37533
+ const backlog = join113(REPO_ROOT, "autonomy", "lib", "backlog.py");
37513
37534
  const feed = createGroupFeed(groupId, units, createGroupRenderer({ write: say, isTTY: false }));
37514
37535
  const res = await run2([backlog, slug, "--dag", dagPath, "--group", groupId, "--slots", String(n3), "--provider", provider], scopedEnv({ ...env, LOKI_PROVIDER: provider }), repoDir, (c) => feed.feed(c));
37515
37536
  launchCode = res.code;
@@ -37549,7 +37570,7 @@ async function runGroupCore(launcher, dag, ctx) {
37549
37570
  const testCmd = testCommand(repoDir, env), fixes = units.filter((u) => u.fixKind);
37550
37571
  const putDag = (us) => atomicWriteJson(dagPath, { group: groupId, spec_sha256: specSha, base_ref: baseRef, start_branch: startBranch, ...full, units: us });
37551
37572
  const launchFix = async (fix) => {
37552
- const key = `unit-${groupId}-${units.length + 1}`, spec = join112(specDir, `${fix.id}.json`), slug = slugOf();
37573
+ const key = `unit-${groupId}-${units.length + 1}`, spec = join113(specDir, `${fix.id}.json`), slug = slugOf();
37553
37574
  if (!slug)
37554
37575
  return null;
37555
37576
  atomicWriteJson(spec, { id: fix.id, writeSet: fix.writeSet, pack: fix.writeSet, tokenBudget: 1e9, acceptance: fix.acceptance });
@@ -37558,7 +37579,7 @@ async function runGroupCore(launcher, dag, ctx) {
37558
37579
  fix.base = git9(repoDir, ["rev-parse", "HEAD"]);
37559
37580
  units.push(fix);
37560
37581
  putDag(units.map((u) => u === fix ? u : { ...u, done: true }));
37561
- const res = await run2([join112(REPO_ROOT, "autonomy", "lib", "backlog.py"), slug, "--dag", dagPath, "--group", groupId, "--slots", "1", "--provider", provider], scopedEnv({ ...env, LOKI_PROVIDER: provider }), repoDir);
37582
+ const res = await run2([join113(REPO_ROOT, "autonomy", "lib", "backlog.py"), slug, "--dag", dagPath, "--group", groupId, "--slots", "1", "--provider", provider], scopedEnv({ ...env, LOKI_PROVIDER: provider }), repoDir);
37562
37583
  costs.push(parseGroupCost(res.stdout));
37563
37584
  if (res.code !== 0 || !new RegExp(`^backlog: ${key} (VERIFIED|PR \\S+)$`, "m").test(res.stdout)) {
37564
37585
  units.pop();
@@ -37595,7 +37616,7 @@ async function runGroupCore(launcher, dag, ctx) {
37595
37616
  return 1;
37596
37617
  }
37597
37618
  const order2 = units.map((u) => ({ unit_id: u.id, goal: u.items.join("; "), files: u.writeSet }));
37598
- atomicWriteJson(join112(groupDir, "group", "manifest.json"), { group_id: groupId, units: order2 });
37619
+ atomicWriteJson(join113(groupDir, "group", "manifest.json"), { group_id: groupId, units: order2 });
37599
37620
  const head = git9(repoDir, ["rev-parse", "--verify", `refs/heads/${r.branch}`]);
37600
37621
  let verdict = "", unitVerdicts = [], why = "";
37601
37622
  try {
@@ -37829,7 +37850,7 @@ var init_route = __esm(() => {
37829
37850
 
37830
37851
  // ../../loki-ts/src/contrib/forecast.ts
37831
37852
  import { appendFileSync as appendFileSync11, existsSync as existsSync78, mkdirSync as mkdirSync56, readFileSync as readFileSync100 } from "fs";
37832
- import { join as join113 } from "path";
37853
+ import { join as join114 } from "path";
37833
37854
  function readWindowDeltas(lokiDir2) {
37834
37855
  const p = historyPath2(lokiDir2);
37835
37856
  if (!existsSync78(p))
@@ -37897,7 +37918,7 @@ async function printForecast(lokiDir2, read3, write, env = process.env) {
37897
37918
  `);
37898
37919
  } catch {}
37899
37920
  }
37900
- var MIN_FORECAST_RUNS = 3, KEEP_RUNS = 20, forecastOn = (env = process.env) => env["LOKI_FORECAST"] !== "0", finite = (v) => typeof v === "number" && Number.isFinite(v), historyPath2 = (lokiDir2) => join113(lokiDir2, "quota-runs.jsonl"), range = (xs) => {
37921
+ var MIN_FORECAST_RUNS = 3, KEEP_RUNS = 20, forecastOn = (env = process.env) => env["LOKI_FORECAST"] !== "0", finite = (v) => typeof v === "number" && Number.isFinite(v), historyPath2 = (lokiDir2) => join114(lokiDir2, "quota-runs.jsonl"), range = (xs) => {
37901
37922
  const lo = Math.floor(Math.min(...xs)), hi = Math.ceil(Math.max(...xs));
37902
37923
  return lo === hi ? `${hi}` : `${lo}-${hi}`;
37903
37924
  };
@@ -37906,8 +37927,8 @@ var init_forecast = __esm(() => {
37906
37927
  });
37907
37928
 
37908
37929
  // ../../loki-ts/src/commands/queue.ts
37909
- import { existsSync as existsSync79, mkdirSync as mkdirSync57, readFileSync as readFileSync101, readdirSync as readdirSync40, renameSync as renameSync21, statSync as statSync32, writeFileSync as writeFileSync57 } from "fs";
37910
- import { join as join114, resolve as resolve31 } from "path";
37930
+ import { existsSync as existsSync79, mkdirSync as mkdirSync57, readFileSync as readFileSync101, readdirSync as readdirSync40, renameSync as renameSync21, statSync as statSync33, writeFileSync as writeFileSync57 } from "fs";
37931
+ import { join as join115, resolve as resolve31 } from "path";
37911
37932
  function normalizeRef(raw2) {
37912
37933
  const m = URL_RE2.exec(raw2);
37913
37934
  if (m)
@@ -37917,7 +37938,7 @@ function normalizeRef(raw2) {
37917
37938
  return /^0+$/.test(raw2.replace(/^.*#/, "")) ? null : raw2;
37918
37939
  }
37919
37940
  function queuePath(lokiDir2) {
37920
- return join114(lokiDir2, "issue-queue.json");
37941
+ return join115(lokiDir2, "issue-queue.json");
37921
37942
  }
37922
37943
  function readQueue(lokiDir2) {
37923
37944
  try {
@@ -38134,8 +38155,8 @@ ${QUEUE_USAGE}`);
38134
38155
  try {
38135
38156
  mkdirSync57(d.lokiDir, { recursive: true });
38136
38157
  const stamp2 = finished.toISOString().replace(/[:.]/g, "-");
38137
- writeFileSync57(join114(d.lokiDir, `queue-digest-${stamp2}.txt`), text4);
38138
- writeFileSync57(join114(d.lokiDir, "queue-digest-latest.txt"), text4);
38158
+ writeFileSync57(join115(d.lokiDir, `queue-digest-${stamp2}.txt`), text4);
38159
+ writeFileSync57(join115(d.lokiDir, "queue-digest-latest.txt"), text4);
38139
38160
  } catch (e) {
38140
38161
  d.err(`loki queue: could not write digest: ${e instanceof Error ? e.message : String(e)}
38141
38162
  `);
@@ -38145,14 +38166,14 @@ ${QUEUE_USAGE}`);
38145
38166
  }
38146
38167
  function newestRecord(lokiDir2, since) {
38147
38168
  for (const [sub2, file] of [["runs", "receipt.json"], ["proofs", "proof.json"]]) {
38148
- const dir = join114(lokiDir2, sub2);
38169
+ const dir = join115(lokiDir2, sub2);
38149
38170
  let best = null;
38150
38171
  try {
38151
38172
  for (const name of readdirSync40(dir)) {
38152
- const p = join114(dir, name, file);
38173
+ const p = join115(dir, name, file);
38153
38174
  if (!existsSync79(p))
38154
38175
  continue;
38155
- const t = statSync32(p).mtimeMs;
38176
+ const t = statSync33(p).mtimeMs;
38156
38177
  if (t >= since && (!best || t > best.t))
38157
38178
  best = { t, p, name };
38158
38179
  }
@@ -38192,7 +38213,7 @@ function makeDefaultRunner(lokiDir2) {
38192
38213
  return async (ref, opts) => {
38193
38214
  const since = Date.now();
38194
38215
  const argv = [resolve31(REPO_ROOT, "bin", "loki"), ...queueStartArgs(ref, !!opts.pr)];
38195
- const runLoki = opts.cwd ? join114(opts.cwd, ".loki") : lokiDir2;
38216
+ const runLoki = opts.cwd ? join115(opts.cwd, ".loki") : lokiDir2;
38196
38217
  const env = runnerEnv(opts, runLoki);
38197
38218
  const proc = Bun.spawn(argv, { stdout: "pipe", stderr: "pipe", stdin: "ignore", env, ...opts.cwd ? { cwd: opts.cwd } : {} });
38198
38219
  const mins2 = itemTimeoutMin(process.env["LOKI_QUEUE_ITEM_TIMEOUT_MIN"]);
@@ -38202,9 +38223,9 @@ function makeDefaultRunner(lokiDir2) {
38202
38223
  clearTimeout(timer);
38203
38224
  const output = so + se;
38204
38225
  try {
38205
- const logDir = join114(lokiDir2, "queue-logs");
38226
+ const logDir = join115(lokiDir2, "queue-logs");
38206
38227
  mkdirSync57(logDir, { recursive: true });
38207
- writeFileSync57(join114(logDir, `${(opts.logName ?? ref).replace(/[^A-Za-z0-9_.-]/g, "_").slice(0, 120)}.log`), output);
38228
+ writeFileSync57(join115(logDir, `${(opts.logName ?? ref).replace(/[^A-Za-z0-9_.-]/g, "_").slice(0, 120)}.log`), output);
38208
38229
  } catch {}
38209
38230
  const proof = newestRecord(runLoki, since);
38210
38231
  return { rc, output, verdict: proof.verdict, costUsd: proof.costUsd, runId: proof.runId ?? null, didWork: proof.didWork ?? null };
@@ -38410,12 +38431,12 @@ function renderEpicTree(n3, title, rows) {
38410
38431
  function makeSessionDecompose(repoDir, lokiDir2, provider) {
38411
38432
  return async (slug, issue, triageReason, note) => {
38412
38433
  const { mkdirSync: mkdirSync58, readFileSync: readFileSync102, existsSync: existsSync80 } = await import("fs");
38413
- const { join: join115 } = await import("path");
38434
+ const { join: join116 } = await import("path");
38414
38435
  const { createSessionRunner: createSessionRunner2 } = await Promise.resolve().then(() => (init_session(), exports_session));
38415
38436
  const { envOverride: envOverride2 } = await Promise.resolve().then(() => (init_decision(), exports_decision));
38416
- const dir = join115(lokiDir2, "issues-run", "decompose");
38437
+ const dir = join116(lokiDir2, "issues-run", "decompose");
38417
38438
  mkdirSync58(dir, { recursive: true });
38418
- const outPath = join115(dir, `issue-${issue.number}-${Date.now()}.json`);
38439
+ const outPath = join116(dir, `issue-${issue.number}-${Date.now()}.json`);
38419
38440
  const runner = createSessionRunner2({ provider, lokiRoot: lokiDir2 });
38420
38441
  const r = await runner.run({
38421
38442
  stage: "plan",
@@ -38457,7 +38478,7 @@ __export(exports_issues_run, {
38457
38478
  import { spawnSync as spawnSync16 } from "child_process";
38458
38479
  import { cpSync as cpSync4, existsSync as existsSync80, mkdirSync as mkdirSync58, mkdtempSync as mkdtempSync12, readFileSync as readFileSync102, rmSync as rmSync29, writeFileSync as writeFileSync58 } from "fs";
38459
38480
  import { tmpdir as tmpdir17 } from "os";
38460
- import { join as join115, resolve as resolve32 } from "path";
38481
+ import { join as join116, resolve as resolve32 } from "path";
38461
38482
  import { createInterface as createInterface3 } from "readline";
38462
38483
  function parseIssuesArgs(args) {
38463
38484
  const a = { slug: null, label: null, milestone: null, limit: DEFAULT_LIMIT, parallel: DEFAULT_PARALLEL, draft: false, dryRun: false, yes: false, comment: false, split: true, triage: false, json: false };
@@ -38713,7 +38734,7 @@ ${USAGE}`);
38713
38734
  }
38714
38735
  }
38715
38736
  const stamp2 = started.toISOString().replace(/[:.]/g, "-");
38716
- const runDir = join115(d.lokiDir, "issues-run", stamp2);
38737
+ const runDir = join116(d.lokiDir, "issues-run", stamp2);
38717
38738
  mkdirSync58(runDir, { recursive: true });
38718
38739
  const byRef = new Map(actionable.map((i) => [`${slug}#${i.number}`, i]));
38719
38740
  const sink = () => {};
@@ -38778,14 +38799,14 @@ ${USAGE}`);
38778
38799
  ${trees.join(`
38779
38800
  `)}` : "");
38780
38801
  try {
38781
- writeFileSync58(join115(runDir, "digest.md"), text4);
38802
+ writeFileSync58(join116(runDir, "digest.md"), text4);
38782
38803
  } catch (e) {
38783
38804
  d.err(`loki issues run: could not write digest: ${e instanceof Error ? e.message : String(e)}
38784
38805
  `);
38785
38806
  }
38786
38807
  d.out(`
38787
38808
  ${text4}
38788
- digest: ${join115(runDir, "digest.md")}
38809
+ digest: ${join116(runDir, "digest.md")}
38789
38810
  `);
38790
38811
  return 0;
38791
38812
  }
@@ -38862,7 +38883,7 @@ async function startIssueEpic(o) {
38862
38883
  return null;
38863
38884
  let raw2;
38864
38885
  try {
38865
- raw2 = JSON.parse(readFileSync102(join115(o.runDir, "issue.json"), "utf8"));
38886
+ raw2 = JSON.parse(readFileSync102(join116(o.runDir, "issue.json"), "utf8"));
38866
38887
  } catch {
38867
38888
  return null;
38868
38889
  }
@@ -38874,7 +38895,7 @@ async function startIssueEpic(o) {
38874
38895
  `), null, null);
38875
38896
  if (size.size !== "large")
38876
38897
  return null;
38877
- const lokiDir2 = env["LOKI_DIR"] ?? join115(o.repoDir, ".loki");
38898
+ const lokiDir2 = env["LOKI_DIR"] ?? join116(o.repoDir, ".loki");
38878
38899
  const userEnv = groupEnv({ ...env }, o.capUsd ?? 0, o.repoDir);
38879
38900
  const base = makeDefaultRunner(lokiDir2);
38880
38901
  const d = {
@@ -38897,9 +38918,9 @@ async function startIssueEpic(o) {
38897
38918
  }
38898
38919
  d.out(`#${issue.number} split into ${plan.slices.length} slices: ${plan.slices.map((s) => s.id + (plan.parent[s.id] ? `<-${plan.parent[s.id]}` : "")).join(", ")}
38899
38920
  `);
38900
- const r = await runOneEpic(d, raw2.repo, { issue, plan }, 1, join115(o.runDir, "slices"), !o.noPr);
38921
+ const r = await runOneEpic(d, raw2.repo, { issue, plan }, 1, join116(o.runDir, "slices"), !o.noPr);
38901
38922
  try {
38902
- writeFileSync58(join115(o.runDir, "epic.json"), JSON.stringify({ issue: `${raw2.repo}#${issue.number}`, size: size.size, reasons: size.reasons, slices: plan.slices, results: r.results }, null, 2) + `
38923
+ writeFileSync58(join116(o.runDir, "epic.json"), JSON.stringify({ issue: `${raw2.repo}#${issue.number}`, size: size.size, reasons: size.reasons, slices: plan.slices, results: r.results }, null, 2) + `
38903
38924
  `);
38904
38925
  } catch {}
38905
38926
  d.out(`
@@ -38922,11 +38943,11 @@ function perRun(est) {
38922
38943
  return est.prior ? { usd: est.prior.usd, tilde: "~", label: " (rough prior)" } : null;
38923
38944
  }
38924
38945
  function keepReceipt(wt, runId2, runDir, err) {
38925
- const src = join115(wt, ".loki", "runs", runId2);
38946
+ const src = join116(wt, ".loki", "runs", runId2);
38926
38947
  if (!/^[A-Za-z0-9_.-]+$/.test(runId2) || !existsSync80(src))
38927
38948
  return;
38928
38949
  try {
38929
- cpSync4(src, join115(runDir, "receipts", runId2), { recursive: true });
38950
+ cpSync4(src, join116(runDir, "receipts", runId2), { recursive: true });
38930
38951
  } catch (e) {
38931
38952
  err(`loki issues run: could not keep the receipt of ${runId2}: ${e instanceof Error ? e.message : String(e)}
38932
38953
  `);
@@ -38974,8 +38995,8 @@ function makeWorktrees(repoDir) {
38974
38995
  let root = null;
38975
38996
  return {
38976
38997
  create: (name, base) => {
38977
- root ??= mkdtempSync12(join115(tmpdir17(), "loki-issues-"));
38978
- const p = join115(root, name);
38998
+ root ??= mkdtempSync12(join116(tmpdir17(), "loki-issues-"));
38999
+ const p = join116(root, name);
38979
39000
  safeGit(repoDir, ["worktree", "add", "-B", `loki/${name}`, p, base]);
38980
39001
  return p;
38981
39002
  },
@@ -39074,7 +39095,7 @@ __export(exports_satisfaction, {
39074
39095
  });
39075
39096
  import { appendFileSync as appendFileSync12, mkdirSync as mkdirSync59 } from "fs";
39076
39097
  import { homedir as homedir15 } from "os";
39077
- import { join as join116 } from "path";
39098
+ import { join as join117 } from "path";
39078
39099
  import { createInterface as createInterface4 } from "readline";
39079
39100
  function satisfactionEnabled(env, tty) {
39080
39101
  if (!tty)
@@ -39094,9 +39115,9 @@ function parseScore(line2) {
39094
39115
  return { score: Number(m[1]), again: m[2] ? m[2].toLowerCase() === "y" : null };
39095
39116
  }
39096
39117
  function recordSatisfaction(home, row) {
39097
- const dir = join116(home, ".loki");
39118
+ const dir = join117(home, ".loki");
39098
39119
  mkdirSync59(dir, { recursive: true, mode: 448 });
39099
- appendFileSync12(join116(dir, "satisfaction.jsonl"), `${JSON.stringify(row)}
39120
+ appendFileSync12(join117(dir, "satisfaction.jsonl"), `${JSON.stringify(row)}
39100
39121
  `, { mode: 384 });
39101
39122
  }
39102
39123
  async function maybeAsk(o) {
@@ -39169,7 +39190,7 @@ __export(exports_supervisor, {
39169
39190
  import { spawn as spawn13, spawnSync as spawnSync17 } from "child_process";
39170
39191
  import { createHash as createHash33, createPublicKey as createPublicKey4, sign as sign3 } from "crypto";
39171
39192
  import { existsSync as existsSync81, mkdirSync as mkdirSync60, readFileSync as readFileSync103, writeFileSync as writeFileSync59 } from "fs";
39172
- import { dirname as dirname47, join as join117, relative as relative26, resolve as resolve33 } from "path";
39193
+ import { dirname as dirname47, join as join118, relative as relative26, resolve as resolve33 } from "path";
39173
39194
  async function slackEvent(...a) {
39174
39195
  try {
39175
39196
  await (await Promise.resolve().then(() => (init_slack_events(), exports_slack_events))).notifyEvent(...a);
@@ -39288,15 +39309,15 @@ async function runSupervisor(opts) {
39288
39309
  const t0 = Date.now();
39289
39310
  const startedProvider = opts.started?.["provider"];
39290
39311
  const env = opts.env ?? process.env;
39291
- await assertPreflight({ repoDir: opts.repoDir, provider: typeof startedProvider === "string" ? startedProvider : "claude", pr: opts.pr !== undefined, env, runDir: join117(opts.repoDir, ".loki", "runs", opts.runId) });
39312
+ await assertPreflight({ repoDir: opts.repoDir, provider: typeof startedProvider === "string" ? startedProvider : "claude", pr: opts.pr !== undefined, env, runDir: join118(opts.repoDir, ".loki", "runs", opts.runId) });
39292
39313
  writeEngineMarker(opts.repoDir, opts.runId);
39293
39314
  const origin = readOriginUrl(opts.repoDir);
39294
- const rmRunPid = writeRunPid(join117(opts.repoDir, ".loki", "runs", opts.runId), opts.runId);
39315
+ const rmRunPid = writeRunPid(join118(opts.repoDir, ".loki", "runs", opts.runId), opts.runId);
39295
39316
  process.once("exit", rmRunPid);
39296
- const log = new SupervisorLog(join117(opts.repoDir, eventsRelPath(opts.runId)), opts.runId);
39317
+ const log = new SupervisorLog(join118(opts.repoDir, eventsRelPath(opts.runId)), opts.runId);
39297
39318
  if ((env.LOKI_CONTROL ?? process.env.LOKI_CONTROL) !== "0")
39298
39319
  Promise.resolve().then(() => (init_ship_hook(), exports_ship_hook)).then((m) => m.startShip(opts.repoDir, log.path, env)).catch(() => {});
39299
- const aliveDir = join117(opts.repoDir, ".loki", "runs", opts.runId), lastAlive = opts.resume ? readAliveBeat(aliveDir) : null;
39320
+ const aliveDir = join118(opts.repoDir, ".loki", "runs", opts.runId), lastAlive = opts.resume ? readAliveBeat(aliveDir) : null;
39300
39321
  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) });
39301
39322
  if (!opts.resume)
39302
39323
  Promise.resolve().then(() => (init_writeback(), exports_writeback)).then((m) => m.writeBack({ phase: "started", verdict: "", prUrl: null, receiptSha256: null, task: "" }, env));
@@ -39342,7 +39363,7 @@ async function runSupervisor(opts) {
39342
39363
  log.checkpoint(e.data["receipt_sha256"]);
39343
39364
  }
39344
39365
  if (e?.type === "variant" && e.data.intent_confirm === true && workerEnv.LOKI_INTENT_TTY === "1") {
39345
- askIntent(String(e.data.card ?? ""), join117(opts.repoDir, ".loki", "runs", opts.runId));
39366
+ askIntent(String(e.data.card ?? ""), join118(opts.repoDir, ".loki", "runs", opts.runId));
39346
39367
  }
39347
39368
  }, (stopped) => {
39348
39369
  for (const g2 of sessionGroups)
@@ -39413,7 +39434,7 @@ async function runSupervisor(opts) {
39413
39434
  }
39414
39435
  }
39415
39436
  }
39416
- const allEvents = readEvents(log.path), folded = fold(allEvents), lokiRoot = join117(opts.repoDir, ".loki"), costUsd = runCostUsd(allEvents, log.tampered, lokiRoot), wallS = (Date.now() - t0) / 1000;
39437
+ const allEvents = readEvents(log.path), folded = fold(allEvents), lokiRoot = join118(opts.repoDir, ".loki"), costUsd = runCostUsd(allEvents, log.tampered, lokiRoot), wallS = (Date.now() - t0) / 1000;
39417
39438
  const stopRaw = folded.run.escalated?.data.stop, stop = typeof stopRaw === "string" ? stopRaw : null;
39418
39439
  const outcome = cancelled2 ? "CANCELLED" : outcomeOf(verdict, allEvents.some((e) => e.type === "cap.hit"), stop, log.tampered, receiptVerdict), blocked = outcome === "BLOCKED";
39419
39440
  let statusReason;
@@ -39440,12 +39461,12 @@ async function runSupervisor(opts) {
39440
39461
  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, t0) });
39441
39462
  log.sealLog();
39442
39463
  log.state("closed", outcome);
39443
- recordFingerprints(join117(opts.repoDir, ".loki", "state"), opts.runId, "failed", failedCheckNames(folded.stages["verify"]?.data.checks, folded.stages["verify"]?.data.pre_red_checks), cleanTreeId(opts.repoDir));
39464
+ recordFingerprints(join118(opts.repoDir, ".loki", "state"), opts.runId, "failed", failedCheckNames(folded.stages["verify"]?.data.checks, folded.stages["verify"]?.data.pre_red_checks), cleanTreeId(opts.repoDir));
39444
39465
  if (!cancelled2)
39445
39466
  try {
39446
39467
  (await Promise.resolve().then(() => (init_pr_lessons(), exports_pr_lessons))).learnFromRun(opts.repoDir, opts.runId, allEvents, verdict);
39447
39468
  } catch {}
39448
- const stages = allEvents.filter((e) => e.type === "stage.completed" && typeof e.data.duration_s === "number").map((e) => ({ label: String(e.stage), seconds: e.data.duration_s })), pc = partialCost(allEvents, log.tampered, lokiRoot), summary = { pr: prUrl ? { url: prUrl, draft: verdict !== "VERIFIED" } : null, verdict, outcome, notProven, flaky: recordFingerprints(join117(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((e) => e.type === "cost")), ...summaryCache(allEvents, log.tampered), partialUsd: pc.usd, measuredSessions: pc.measured, totalSessions: pc.total, stageShares: log.tampered ? null : stageShareText(allEvents), capUsd: Number(opts.started?.["max_cost_usd"]) > 0 ? Number(opts.started?.["max_cost_usd"]) : undefined } };
39469
+ const stages = allEvents.filter((e) => e.type === "stage.completed" && typeof e.data.duration_s === "number").map((e) => ({ label: String(e.stage), seconds: e.data.duration_s })), pc = partialCost(allEvents, log.tampered, lokiRoot), summary = { pr: prUrl ? { url: prUrl, draft: verdict !== "VERIFIED" } : null, verdict, outcome, notProven, flaky: recordFingerprints(join118(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((e) => e.type === "cost")), ...summaryCache(allEvents, log.tampered), partialUsd: pc.usd, measuredSessions: pc.measured, totalSessions: pc.total, stageShares: log.tampered ? null : stageShareText(allEvents), capUsd: Number(opts.started?.["max_cost_usd"]) > 0 ? Number(opts.started?.["max_cost_usd"]) : undefined } };
39449
39470
  if (prUrl === null && (cancelled2 || !receiptVerdict || verdict !== "VERIFIED" && verdict !== "PARTIAL" && verdict !== "ALREADY_SATISFIED"))
39450
39471
  commitUnsealedWork(intact && !log.tampered, opts.repoDir, workerEnv, opts.runId, folded.stages["intake"]?.type === "stage.completed" ? folded.stages["intake"].data : undefined);
39451
39472
  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 });
@@ -39556,10 +39577,11 @@ usage: loki "<task>" [--no-pr] [--deep] [--json] [--verbose] [--quiet] [--max-co
39556
39577
  } catch {}
39557
39578
  }
39558
39579
  if (!task) {
39559
- process.stderr.write(`engine10: no task given
39580
+ process.stderr.write(`loki: no goal given.
39581
+ usage: loki "<goal>" (or: loki start <prd.md | owner/repo#N>)
39560
39582
  `);
39561
39583
  noteRefusal("prd_missing");
39562
- return 2;
39584
+ return 64;
39563
39585
  }
39564
39586
  if (spec === null) {
39565
39587
  const r = (await Promise.resolve().then(() => (init_one_line_goal(), exports_one_line_goal))).refuseCommandGoal(task);
@@ -39588,6 +39610,7 @@ usage: loki "<task>" [--no-pr] [--deep] [--json] [--verbose] [--quiet] [--max-co
39588
39610
  return 2;
39589
39611
  }
39590
39612
  }
39613
+ delete process.env.LOKI_FIRST_RUN_FILES;
39591
39614
  const olg = await Promise.resolve().then(() => (init_one_line_goal(), exports_one_line_goal));
39592
39615
  const inferred = olg.inferProvider(process.env, providerNamed);
39593
39616
  if (inferred) {
@@ -39615,7 +39638,7 @@ usage: loki "<task>" [--no-pr] [--deep] [--json] [--verbose] [--quiet] [--max-co
39615
39638
  return rec2;
39616
39639
  }
39617
39640
  const runId2 = `e10-${new Date().toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z")}-${Math.random().toString(16).slice(2, 6)}`;
39618
- const runDir = join117(repoDir, ".loki", "runs", runId2);
39641
+ const runDir = join118(repoDir, ".loki", "runs", runId2);
39619
39642
  const cap = resolveCap(maxCost, repoDir);
39620
39643
  if ("error" in cap) {
39621
39644
  process.stderr.write(`engine10: ${cap.error}
@@ -39658,7 +39681,7 @@ usage: loki "<task>" [--no-pr] [--deep] [--json] [--verbose] [--quiet] [--max-co
39658
39681
  }
39659
39682
  if (spec) {
39660
39683
  mkdirSync60(runDir, { recursive: true });
39661
- writeFileSync59(join117(runDir, "spec.snapshot.md"), spec.raw);
39684
+ writeFileSync59(join118(runDir, "spec.snapshot.md"), spec.raw);
39662
39685
  for (const e of [env, process.env]) {
39663
39686
  e.LOKI_E10_SPEC_PATH = relative26(repoDir, spec.path);
39664
39687
  e.LOKI_E10_SPEC_SHA256 = spec.sha256;
@@ -39683,9 +39706,9 @@ usage: loki "<task>" [--no-pr] [--deep] [--json] [--verbose] [--quiet] [--max-co
39683
39706
  mkdirSync60(runDir, { recursive: true });
39684
39707
  try {
39685
39708
  if (trackerRef)
39686
- await fetchTrackerIssueToFile(trackerRef, join117(runDir, "issue.json"));
39709
+ await fetchTrackerIssueToFile(trackerRef, join118(runDir, "issue.json"));
39687
39710
  else
39688
- fetchIssueToFile(task, join117(runDir, "issue.json"));
39711
+ fetchIssueToFile(task, join118(runDir, "issue.json"));
39689
39712
  } catch (err) {
39690
39713
  process.stderr.write(`engine10: issue fetch failed: ${err.message.split(`
39691
39714
  `)[0]}
@@ -39720,14 +39743,14 @@ usage: loki "<task>" [--no-pr] [--deep] [--json] [--verbose] [--quiet] [--max-co
39720
39743
  process.stdout.write(`${capLine}
39721
39744
  `);
39722
39745
  const t0 = Date.now();
39723
- const eventsPath = join117(repoDir, eventsRelPath(runId2));
39746
+ const eventsPath = join118(repoDir, eventsRelPath(runId2));
39724
39747
  const liveSeen = [], live2 = (e) => {
39725
39748
  liveSeen.push(e);
39726
39749
  const clockS = (Date.parse(e.ts) - t0) / 1000;
39727
39750
  const d = e.data;
39728
39751
  if (e.type.startsWith("stage.") && e.type !== "stage.started") {
39729
39752
  const status = e.type === "stage.completed" ? "done" : e.type === "stage.failed" ? "failed" : "skipped";
39730
- process.stdout.write(formatStageLine({ clockS, name: String(e.stage), status, durationS: Number(d.duration_s ?? 0), detail: String(d.reason ?? d.summary ?? ""), spend: spendSoFar(liveSeen, join117(repoDir, ".loki")) }) + `
39753
+ process.stdout.write(formatStageLine({ clockS, name: String(e.stage), status, durationS: Number(d.duration_s ?? 0), detail: String(d.reason ?? d.summary ?? ""), spend: spendSoFar(liveSeen, join118(repoDir, ".loki")) }) + `
39731
39754
  `);
39732
39755
  } else if (e.type === "heartbeat") {
39733
39756
  const diff = d.diff;
@@ -39768,7 +39791,7 @@ usage: loki "<task>" [--no-pr] [--deep] [--json] [--verbose] [--quiet] [--max-co
39768
39791
  const reqOnce = async (evs) => {
39769
39792
  if (reqMap === undefined) {
39770
39793
  const rq = await Promise.resolve().then(() => (init_contract(), exports_contract));
39771
- reqMap = rq.writeFromEngine10(repoDir, join117(repoDir, ".loki"), runDir, isIssue ? null : task, evs);
39794
+ reqMap = rq.writeFromEngine10(repoDir, join118(repoDir, ".loki"), runDir, isIssue ? null : task, evs);
39772
39795
  }
39773
39796
  return reqMap;
39774
39797
  };
@@ -39810,8 +39833,8 @@ usage: loki "<task>" [--no-pr] [--deep] [--json] [--verbose] [--quiet] [--max-co
39810
39833
  const { loadRunOutputs } = await Promise.resolve().then(() => (init_run_outputs(), exports_run_outputs)), { runPr: runPr2 } = await Promise.resolve().then(() => (init_pr(), exports_pr));
39811
39834
  const events3 = readEvents(eventsPath);
39812
39835
  const sealed = { ...events3.findLast((e) => e.type === "receipt.sealed")?.data ?? {}, not_proven: "note" in gate && gate.note ? [...notProven, gate.note] : notProven };
39813
- const hbase = events3.find((e) => e.type === "stage.completed" && e.stage === "intake")?.data.base_sha, hpc = partialCost(events3, false, join117(repoDir, ".loki"));
39814
- const handoffMd = handoffSection({ requirements: (await reqOnce(events3))?.requirements ?? null, sinceMs: t0, repoDir, runId: runId2, events: events3, outcome: String(verdict), usd: runCostUsd(events3, false, join117(repoDir, ".loki")), partialUsd: hpc.usd, measuredSessions: hpc.measured, totalSessions: hpc.total, elapsedS: null, notProven, baseSha: typeof hbase === "string" ? hbase : null, stats: diffStat(repoDir, typeof hbase === "string" ? hbase : null) });
39836
+ const hbase = events3.find((e) => e.type === "stage.completed" && e.stage === "intake")?.data.base_sha, hpc = partialCost(events3, false, join118(repoDir, ".loki"));
39837
+ const handoffMd = handoffSection({ requirements: (await reqOnce(events3))?.requirements ?? null, sinceMs: t0, repoDir, runId: runId2, events: events3, outcome: String(verdict), usd: runCostUsd(events3, false, join118(repoDir, ".loki")), partialUsd: hpc.usd, measuredSessions: hpc.measured, totalSessions: hpc.total, elapsedS: null, notProven, baseSha: typeof hbase === "string" ? hbase : null, stats: diffStat(repoDir, typeof hbase === "string" ? hbase : null) });
39815
39838
  const r = await runPr2({
39816
39839
  runId: runId2,
39817
39840
  repoDir,
@@ -39832,7 +39855,7 @@ usage: loki "<task>" [--no-pr] [--deep] [--json] [--verbose] [--quiet] [--max-co
39832
39855
  comment: noPr ? undefined : async ({ issueRef, reason, prUrl }) => {
39833
39856
  const { DEFAULT_PUSH_SH: DEFAULT_PUSH_SH2 } = await Promise.resolve().then(() => (init_pr(), exports_pr));
39834
39857
  mkdirSync60(runDir, { recursive: true });
39835
- const bodyFile = join117(runDir, "backstop-comment.md");
39858
+ const bodyFile = join118(runDir, "backstop-comment.md");
39836
39859
  writeFileSync59(bodyFile, `<!-- loki-backstop -->
39837
39860
  Loki 10 run ${runId2} ${prUrl ? `opened draft PR ${prUrl}` : "ended without a PR"}.
39838
39861
 
@@ -39898,7 +39921,7 @@ ${prUrl ? "One question" : "Reason"}: ${reason}
39898
39921
  const rr = resultOf(res.outcome);
39899
39922
  if (res.outcome === "BUDGET_STOP" && cap.usd > 0)
39900
39923
  writeBudgetStop(repoDir, runId2, { task: task.trim(), cap_usd: cap.usd, spent_usd: seed + (usd ?? 0), source: cap.source });
39901
- const ui = { result: rr, filesChanged: ds?.files ?? null, insertions: ds?.ins, deletions: ds?.del, costUsd: usd, elapsedS: Number(f.run.completed?.data.wall_s ?? (Date.now() - t0) / 1000), receiptPath: res.receiptSha ? join117(runDir, "receipt.json") : null, next: res.outcome === "BUDGET_STOP" && cap.usd > 0 ? budgetNext(seed + (usd ?? 0), cap.usd) : nextOf(rr, ds?.files ?? null, reasonOf(events2, res.tampered, res.stop, res.outcome), provider, runId2, res.prUrl ? "" : olg.landNext(localReason, typeof f.stages["intake"]?.data.branch === "string" ? f.stages["intake"].data.branch : null, origBranch)), uncovered };
39924
+ const ui = { result: rr, filesChanged: ds?.files ?? null, insertions: ds?.ins, deletions: ds?.del, costUsd: usd, elapsedS: Number(f.run.completed?.data.wall_s ?? (Date.now() - t0) / 1000), receiptPath: res.receiptSha ? join118(runDir, "receipt.json") : null, next: res.outcome === "BUDGET_STOP" && cap.usd > 0 ? budgetNext(seed + (usd ?? 0), cap.usd) : nextOf(rr, ds?.files ?? null, reasonOf(events2, res.tampered, res.stop, res.outcome), provider, runId2, res.prUrl ? "" : olg.landNext(localReason, typeof f.stages["intake"]?.data.branch === "string" ? f.stages["intake"].data.branch : null, origBranch)), uncovered };
39902
39925
  const rdy = events2.find((e) => e.type === "stage.completed" && e.stage === "intake")?.data.readiness, foldTail = [handoffRef, typeof rdy === "string" ? rdy : ""].filter(Boolean).join("; ");
39903
39926
  const riskLine = readRiskSummary(repoDir, t0);
39904
39927
  process.stdout.write(json2 ? `${JSON.stringify({ ...JSON.parse(out2), summary: { ...summaryObject(ui), ...riskLine ? { risk: riskLine } : {} } })}
@@ -39911,7 +39934,7 @@ ${withRiskLine(formatRunSummary(ui, { color: useColor() }), riskLine, 99)}${hand
39911
39934
  await Promise.resolve().then(() => (init_satisfaction(), exports_satisfaction)).then((m) => m.maybeAsk({ runId: runId2, env: process.env, isTTY: process.stdin.isTTY === true && process.stdout.isTTY === true })).catch(() => {});
39912
39935
  return res.outcome === "CANCELLED" && res.notProven.some((n3) => n3.endsWith("SIGTERM")) ? 143 : exitCodeOf(res.outcome);
39913
39936
  }
39914
- var START_LINE = "Loki 10 engine", TAMPER_NOT_PROVEN = "event log modified outside the engine", SUPERVISOR_ONLY, VERDICTS2, ALIVE_BEAT_MS = 15000, SESSION_EXITS, BACKSTOP_NOT_PROVEN = "worker killed by the supervisor backstop (cap minus grace)", isRev = (r) => typeof r === "object" && r !== null && Number.isInteger(r.rev) && nonNegNum(r.at), nonNegNum = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0, ISSUE_RE, runSummaryCost = (events2, tampered, repoDir) => summaryCost(events2, tampered, join117(repoDir, ".loki"));
39937
+ var START_LINE = "Loki 10 engine", TAMPER_NOT_PROVEN = "event log modified outside the engine", SUPERVISOR_ONLY, VERDICTS2, ALIVE_BEAT_MS = 15000, SESSION_EXITS, BACKSTOP_NOT_PROVEN = "worker killed by the supervisor backstop (cap minus grace)", isRev = (r) => typeof r === "object" && r !== null && Number.isInteger(r.rev) && nonNegNum(r.at), nonNegNum = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0, ISSUE_RE, runSummaryCost = (events2, tampered, repoDir) => summaryCost(events2, tampered, join118(repoDir, ".loki"));
39915
39938
  var init_supervisor = __esm(() => {
39916
39939
  init_route_block();
39917
39940
  init_stop_restore();
@@ -39957,7 +39980,7 @@ var init_supervisor = __esm(() => {
39957
39980
 
39958
39981
  // ../../loki-ts/src/e10ext/compound_match.ts
39959
39982
  import { readFileSync as readFileSync104 } from "fs";
39960
- import { basename as basename31, join as join118 } from "path";
39983
+ import { basename as basename31, join as join119 } from "path";
39961
39984
  function parts(s) {
39962
39985
  return s.replace(/([a-z0-9])([A-Z])/g, "$1 $2").toLowerCase().match(/[a-z0-9]+/g) ?? [];
39963
39986
  }
@@ -39984,7 +40007,7 @@ function linkedHits(word, repoMap, testMap, repoDir) {
39984
40007
  continue;
39985
40008
  let body;
39986
40009
  try {
39987
- body = importLines(readFileSync104(join118(repoDir, t.path), "utf8"));
40010
+ body = importLines(readFileSync104(join119(repoDir, t.path), "utf8"));
39988
40011
  } catch {
39989
40012
  continue;
39990
40013
  }
@@ -40006,7 +40029,7 @@ var init_compound_match = __esm(() => {
40006
40029
 
40007
40030
  // ../../loki-ts/src/util/already_done_evidence.ts
40008
40031
  import { existsSync as existsSync82, readFileSync as readFileSync105 } from "fs";
40009
- import { basename as basename32, join as join119 } from "path";
40032
+ import { basename as basename32, join as join120 } from "path";
40010
40033
  function keywords2(task) {
40011
40034
  const words3 = task.toLowerCase().match(/[a-z0-9_]+/g) ?? [];
40012
40035
  return Array.from(new Set(words3.filter((w) => w.length > 2 && !STOP_WORDS.has(w))));
@@ -40038,7 +40061,7 @@ function docEvidence(words3, repoDir) {
40038
40061
  for (const name of DOC_FILES) {
40039
40062
  let text4;
40040
40063
  try {
40041
- text4 = readFileSync105(join119(repoDir, name), "utf8");
40064
+ text4 = readFileSync105(join120(repoDir, name), "utf8");
40042
40065
  } catch {
40043
40066
  continue;
40044
40067
  }
@@ -40100,7 +40123,7 @@ function citesToken(text4, token) {
40100
40123
  function citesRealHit(text4, hit2, repoDir) {
40101
40124
  if (hit2.source === "changelog")
40102
40125
  return false;
40103
- return (citesToken(text4, hit2.path) || citesToken(text4, basename32(hit2.path))) && existsSync82(join119(repoDir, hit2.path));
40126
+ return (citesToken(text4, hit2.path) || citesToken(text4, basename32(hit2.path))) && existsSync82(join120(repoDir, hit2.path));
40104
40127
  }
40105
40128
  function renderAlreadyDoneComment(evidence) {
40106
40129
  return ["Loki 10: no change needed. This already appears to be implemented.", "", "Evidence:", ...evidence.map((e) => `- ${e}`), ""].join(`
@@ -40302,7 +40325,7 @@ __export(exports_warm, {
40302
40325
  WarmEngine: () => WarmEngine
40303
40326
  });
40304
40327
  import { createHash as createHash34 } from "crypto";
40305
- import { existsSync as existsSync83, mkdirSync as mkdirSync61, readFileSync as readFileSync106, statSync as statSync33, unlinkSync as unlinkSync11 } from "fs";
40328
+ import { existsSync as existsSync83, mkdirSync as mkdirSync61, readFileSync as readFileSync106, statSync as statSync34, unlinkSync as unlinkSync11 } from "fs";
40306
40329
  import { createServer as createServer2 } from "net";
40307
40330
  import { dirname as dirname48, resolve as resolve34 } from "path";
40308
40331
  function speedEnabled() {
@@ -40331,7 +40354,7 @@ function dirtyHash(repoDir) {
40331
40354
  const rel = line2.slice(3).split(" -> ").pop().replace(/^"|"$/g, "");
40332
40355
  try {
40333
40356
  const p = resolve34(repoDir, rel);
40334
- if (existsSync83(p) && statSync33(p).isFile() && statSync33(p).size <= MAX_HASHED_BYTES)
40357
+ if (existsSync83(p) && statSync34(p).isFile() && statSync34(p).size <= MAX_HASHED_BYTES)
40335
40358
  h.update(readFileSync106(p));
40336
40359
  } catch {}
40337
40360
  }
@@ -40444,7 +40467,7 @@ var init_warm = __esm(() => {
40444
40467
  import { execFile as execFile2 } from "child_process";
40445
40468
  import { mkdirSync as mkdirSync62, mkdtempSync as mkdtempSync13, rmSync as rmSync30 } from "fs";
40446
40469
  import { tmpdir as tmpdir18 } from "os";
40447
- import { join as join120 } from "path";
40470
+ import { join as join121 } from "path";
40448
40471
  function hitsUnchangedFromBase(repoDir, baseSha, paths) {
40449
40472
  if (paths.length === 0 || !baseSha)
40450
40473
  return false;
@@ -40482,23 +40505,23 @@ function dropRoot(root) {
40482
40505
  function pinBaseTree(ctx, signal) {
40483
40506
  let root;
40484
40507
  try {
40485
- root = mkdtempSync13(join120(tmpdir18(), "loki-already-done-"));
40508
+ root = mkdtempSync13(join121(tmpdir18(), "loki-already-done-"));
40486
40509
  } catch {
40487
40510
  return Promise.resolve(null);
40488
40511
  }
40489
40512
  trackRoot(root);
40490
40513
  try {
40491
- mkdirSync62(join120(root, "tree"));
40514
+ mkdirSync62(join121(root, "tree"));
40492
40515
  } catch {
40493
40516
  dropRoot(root);
40494
40517
  return Promise.resolve(null);
40495
40518
  }
40496
- const tarball = join120(root, "base.tar");
40519
+ const tarball = join121(root, "base.tar");
40497
40520
  const step = (cmd2, args, cwd) => new Promise((res) => {
40498
40521
  execFile2(cmd2, args, { env: process.env, signal, cwd }, (err) => res(!err));
40499
40522
  });
40500
40523
  return (async () => {
40501
- if (!ctx.baseSha || (await safeGitRun(ctx.repoDir, ["archive", "-o", tarball, ctx.baseSha], { signal })).exitCode !== 0 || !await step("tar", ["-x", "-f", tarball, "-C", join120(root, "tree")], root)) {
40524
+ if (!ctx.baseSha || (await safeGitRun(ctx.repoDir, ["archive", "-o", tarball, ctx.baseSha], { signal })).exitCode !== 0 || !await step("tar", ["-x", "-f", tarball, "-C", join121(root, "tree")], root)) {
40502
40525
  dropRoot(root);
40503
40526
  return null;
40504
40527
  }
@@ -40556,7 +40579,7 @@ function deferAlreadyDone(ctx, signal, task, repoMap, testMap, apply) {
40556
40579
  if (!root)
40557
40580
  return;
40558
40581
  try {
40559
- const r = await checkAlreadyDone({ ...ctx, repoDir: join120(root, "tree"), sessions: inner }, check.signal, task, repoMap, testMap);
40582
+ const r = await checkAlreadyDone({ ...ctx, repoDir: join121(root, "tree"), sessions: inner }, check.signal, task, repoMap, testMap);
40560
40583
  const ph = phase;
40561
40584
  if (r && ph !== "done" && !check.signal.aborted) {
40562
40585
  hit2 = r;
@@ -40583,7 +40606,7 @@ __export(exports_intake, {
40583
40606
  runIntake: () => runIntake
40584
40607
  });
40585
40608
  import { appendFileSync as appendFileSync13, existsSync as existsSync84, mkdirSync as mkdirSync63, readFileSync as readFileSync107, writeFileSync as writeFileSync60 } from "fs";
40586
- import { dirname as dirname49, join as join121, resolve as resolve35 } from "path";
40609
+ import { dirname as dirname49, join as join122, resolve as resolve35 } from "path";
40587
40610
  function issueRefOf(raw2) {
40588
40611
  return typeof raw2.repo === "string" && raw2.repo && typeof raw2.number === "number" ? `${raw2.repo}#${raw2.number}` : null;
40589
40612
  }
@@ -40603,7 +40626,7 @@ function ensureBranch(repoDir, branch, from) {
40603
40626
  }
40604
40627
  }
40605
40628
  function excludeLokiDir(repoDir) {
40606
- let path = join121(repoDir, ".git", "info", "exclude");
40629
+ let path = join122(repoDir, ".git", "info", "exclude");
40607
40630
  try {
40608
40631
  path = resolve35(repoDir, git11(repoDir, ["rev-parse", "--git-path", "info/exclude"]));
40609
40632
  } catch {}
@@ -40669,7 +40692,7 @@ async function runIntakeBody(ctx, signal, opts, held) {
40669
40692
  ensureBranch(ctx.repoDir, ctx.branch);
40670
40693
  const tree = git11(ctx.repoDir, ["rev-parse", "HEAD^{tree}"]);
40671
40694
  excludeLokiDir(ctx.repoDir);
40672
- const issueJsonPath = opts.issueJsonPath ?? process.env.LOKI_E10_ISSUE_JSON ?? join121(ctx.runDir, "issue.json");
40695
+ const issueJsonPath = opts.issueJsonPath ?? process.env.LOKI_E10_ISSUE_JSON ?? join122(ctx.runDir, "issue.json");
40673
40696
  const taskText = opts.taskText ?? process.env.LOKI_E10_TASK_TEXT;
40674
40697
  let source;
40675
40698
  let taskSha256;
@@ -40704,7 +40727,7 @@ async function runIntakeBody(ctx, signal, opts, held) {
40704
40727
  if (gate.stop)
40705
40728
  return { status: "failed", data: { ...common, task_sha256: taskSha256, source, base_sha: baseSha, tree, branch: ctx.branch, ...gate.stop.failData }, reason: gate.stop.reason };
40706
40729
  mkdirSync63(ctx.runDir, { recursive: true });
40707
- const repomapRef = join121(ctx.runDir, "repomap.json");
40730
+ const repomapRef = join122(ctx.runDir, "repomap.json");
40708
40731
  const cacheDir = repoCacheDir(repoKey(null, ctx.repoDir));
40709
40732
  const tm = { setup: { ms: Date.now() - t0, at: 0 } }, lap = () => {
40710
40733
  const t = Date.now();
@@ -40738,7 +40761,7 @@ async function runIntakeBody(ctx, signal, opts, held) {
40738
40761
  tm.already_done = speedEnabled() ? { skipped: "deferred past intake (LOKI_SPEED)" } : { ms: adEnd(), at: adAt };
40739
40762
  const alreadyData = (already2) => {
40740
40763
  const comment = renderAlreadyDoneComment(already2.evidence);
40741
- const bodyFile = join121(ctx.runDir, "already-done-comment.md");
40764
+ const bodyFile = join122(ctx.runDir, "already-done-comment.md");
40742
40765
  writeFileSync60(bodyFile, comment, "utf8");
40743
40766
  const commentArgv = source === "issue" && issueRef ? buildAlreadyDoneCommentArgv(ctx.runId, issueRef, bodyFile) : undefined;
40744
40767
  return { already_satisfied: true, evidence: already2.evidence, iteration_ids: [`${ctx.runId}-already-done`], comment, ...commentArgv ? { comment_argv: commentArgv } : {} };
@@ -40936,7 +40959,7 @@ var init_fix = __esm(() => {
40936
40959
  // ../../loki-ts/src/util/app_probe.ts
40937
40960
  import { spawnSync as spawnSync18 } from "child_process";
40938
40961
  import { existsSync as existsSync85, mkdirSync as mkdirSync64, readFileSync as readFileSync108, renameSync as renameSync22, writeFileSync as writeFileSync61 } from "fs";
40939
- import { join as join122 } from "path";
40962
+ import { join as join123 } from "path";
40940
40963
  function readJson8(p) {
40941
40964
  try {
40942
40965
  const v = JSON.parse(readFileSync108(p, "utf8"));
@@ -40946,14 +40969,14 @@ function readJson8(p) {
40946
40969
  }
40947
40970
  }
40948
40971
  function stopApp(repoDir, opts = {}) {
40949
- const runner = opts.runnerPath ?? join122(REPO_ROOT, "autonomy", "app-runner.sh");
40950
- if (!existsSync85(runner) || !existsSync85(join122(repoDir, ".loki", "app-runner", "app.pid")))
40972
+ const runner = opts.runnerPath ?? join123(REPO_ROOT, "autonomy", "app-runner.sh");
40973
+ if (!existsSync85(runner) || !existsSync85(join123(repoDir, ".loki", "app-runner", "app.pid")))
40951
40974
  return;
40952
40975
  spawnSync18("bash", ["-c", STOP4, "app-probe", repoDir, runner], { cwd: repoDir, env: plainTestEnv(), timeout: opts.timeoutMs ?? 60000, killSignal: "SIGKILL", stdio: "ignore" });
40953
40976
  }
40954
40977
  async function appProbe(repoDir, lokiDir2, opts = {}) {
40955
- const timeoutMs = opts.timeoutMs ?? 60000, runner = opts.runnerPath ?? join122(REPO_ROOT, "autonomy", "app-runner.sh");
40956
- const dir = join122(repoDir, ".loki", "app-runner"), checks = [];
40978
+ const timeoutMs = opts.timeoutMs ?? 60000, runner = opts.runnerPath ?? join123(REPO_ROOT, "autonomy", "app-runner.sh");
40979
+ const dir = join123(repoDir, ".loki", "app-runner"), checks = [];
40957
40980
  const t0 = Date.now();
40958
40981
  const mk2 = (name, result, reason) => ({ name, cmd: "autonomy/app-runner.sh", result, duration_s: (Date.now() - t0) / 1000, reason });
40959
40982
  const sh3 = (script) => {
@@ -40971,9 +40994,9 @@ async function appProbe(repoDir, lokiDir2, opts = {}) {
40971
40994
  return { checks, pid, url };
40972
40995
  }
40973
40996
  const ir = Number(m[1]), sr = Number(m[2]), hr = Number(m[3]), noApp = m[4] === "1";
40974
- const pidTxt = existsSync85(join122(dir, "app.pid")) ? readFileSync108(join122(dir, "app.pid"), "utf8").trim() : "";
40997
+ const pidTxt = existsSync85(join123(dir, "app.pid")) ? readFileSync108(join123(dir, "app.pid"), "utf8").trim() : "";
40975
40998
  pid = /^\d+$/.test(pidTxt) && sr >= 0 ? Number(pidTxt) : null;
40976
- const st = readJson8(join122(dir, "state.json"));
40999
+ const st = readJson8(join123(dir, "state.json"));
40977
41000
  url = typeof st?.["url"] === "string" ? st["url"] : null;
40978
41001
  if (sr < 0) {
40979
41002
  checks.push(noApp ? mk2("app boot", "n/a", "app-runner detected no app") : mk2("app boot", "not_run", ir === 0 ? "app-runner detected no app" : "no runnable app detected or runtime missing"), mk2("http probe", noApp ? "n/a" : "not_run", "app not booted"));
@@ -40984,7 +41007,7 @@ async function appProbe(repoDir, lokiDir2, opts = {}) {
40984
41007
  return { checks, pid, url };
40985
41008
  }
40986
41009
  checks.push(mk2("app boot", "pass", "app process started"));
40987
- const health = readJson8(join122(dir, "health.json"));
41010
+ const health = readJson8(join123(dir, "health.json"));
40988
41011
  checks.push(hr === 0 && health?.["ok"] === true ? mk2("http probe", "pass", "health.json ok") : mk2("http probe", "fail", "app-runner health check failed"));
40989
41012
  if (opts.specText !== undefined && checks[1]?.result === "pass" && url)
40990
41013
  checks.push(await functionalVerify(opts, url, dir, lokiDir2, timeoutMs));
@@ -40997,10 +41020,10 @@ async function appProbe(repoDir, lokiDir2, opts = {}) {
40997
41020
  async function functionalVerify(opts, url, dir, lokiDir2, timeoutMs) {
40998
41021
  const t0 = Date.now();
40999
41022
  const res = (result, reason) => ({ name: "functional verify", cmd: "autonomy/lib/functional-verify.py", result, duration_s: (Date.now() - t0) / 1000, reason });
41000
- const py = await findPython3(), script = opts.verifyPath ?? join122(REPO_ROOT, "autonomy", "lib", "functional-verify.py");
41023
+ const py = await findPython3(), script = opts.verifyPath ?? join123(REPO_ROOT, "autonomy", "lib", "functional-verify.py");
41001
41024
  if (!py || !existsSync85(script))
41002
41025
  return res("not_run", "python3 or functional-verify.py unavailable");
41003
- const specFile = join122(dir, "spec.txt");
41026
+ const specFile = join123(dir, "spec.txt");
41004
41027
  writeFileSync61(specFile, opts.specText ?? "");
41005
41028
  const r = spawnSync18(py, ["-I", script, specFile, url], { env: plainTestEnv(), encoding: "utf8", timeout: timeoutMs, killSignal: "SIGKILL", stdio: ["ignore", "pipe", "ignore"] });
41006
41029
  let out2 = null;
@@ -41012,11 +41035,11 @@ async function functionalVerify(opts, url, dir, lokiDir2, timeoutMs) {
41012
41035
  }
41013
41036
  if (!out2 || r.status !== 0)
41014
41037
  return res("not_run", "functional harness produced no result");
41015
- const q = join122(lokiDir2, "quality");
41038
+ const q = join123(lokiDir2, "quality");
41016
41039
  mkdirSync64(q, { recursive: true });
41017
- const tmp = join122(q, `functional-results.json.tmp.${process.pid}`);
41040
+ const tmp = join123(q, `functional-results.json.tmp.${process.pid}`);
41018
41041
  writeFileSync61(tmp, JSON.stringify(out2, null, 2));
41019
- renameSync22(tmp, join122(q, "functional-results.json"));
41042
+ renameSync22(tmp, join123(q, "functional-results.json"));
41020
41043
  const s = String(out2["functional_status"] ?? "inconclusive");
41021
41044
  return res(s === "verified" ? "pass" : s === "failed" ? "fail" : "not_run", `functional_status ${s}`);
41022
41045
  }
@@ -41048,15 +41071,15 @@ app_runner_stop >/dev/null 2>&1
41048
41071
  });
41049
41072
 
41050
41073
  // ../../loki-ts/src/util/secure_scan.ts
41051
- import { copyFileSync as copyFileSync7, existsSync as existsSync86, lstatSync as lstatSync28, mkdirSync as mkdirSync65, mkdtempSync as mkdtempSync14, readFileSync as readFileSync109, realpathSync as realpathSync30, rmSync as rmSync31, statSync as statSync34, writeFileSync as writeFileSync62 } from "fs";
41074
+ import { copyFileSync as copyFileSync7, existsSync as existsSync86, lstatSync as lstatSync28, mkdirSync as mkdirSync65, mkdtempSync as mkdtempSync14, readFileSync as readFileSync109, realpathSync as realpathSync30, rmSync as rmSync31, statSync as statSync35, writeFileSync as writeFileSync62 } from "fs";
41052
41075
  import { randomBytes as randomBytes6 } from "crypto";
41053
41076
  import { tmpdir as tmpdir19 } from "os";
41054
- import { basename as basename33, dirname as dirname50, join as join123, resolve as resolve36, sep as sep19 } from "path";
41077
+ import { basename as basename33, dirname as dirname50, join as join124, resolve as resolve36, sep as sep19 } from "path";
41055
41078
  function fail(error) {
41056
41079
  return { ok: false, findings: [], error };
41057
41080
  }
41058
41081
  async function runSecureScan(targetDir, opts = {}) {
41059
- const script = opts.scriptPath ?? join123(REPO_ROOT, "autonomy", "lib", "secure-scan.py");
41082
+ const script = opts.scriptPath ?? join124(REPO_ROOT, "autonomy", "lib", "secure-scan.py");
41060
41083
  if (!existsSync86(script))
41061
41084
  return fail(`secure-scan script not found: ${script}`);
41062
41085
  const py = await findPython3();
@@ -41100,12 +41123,12 @@ async function runSecureScan(targetDir, opts = {}) {
41100
41123
  return fail(`secure-scan failed (exit ${res.exitCode}): ${tail2}`);
41101
41124
  }
41102
41125
  async function secureScanChanged(repoDir, changed, scriptPath) {
41103
- const dir = mkdtempSync14(join123(tmpdir19(), "loki-deep-secure-"));
41126
+ const dir = mkdtempSync14(join124(tmpdir19(), "loki-deep-secure-"));
41104
41127
  try {
41105
41128
  for (const f of changed)
41106
- if (existsSync86(join123(repoDir, f)) && lstatSync28(join123(repoDir, f)).isFile()) {
41107
- mkdirSync65(dirname50(join123(dir, f)), { recursive: true });
41108
- copyFileSync7(join123(repoDir, f), join123(dir, f));
41129
+ if (existsSync86(join124(repoDir, f)) && lstatSync28(join124(repoDir, f)).isFile()) {
41130
+ mkdirSync65(dirname50(join124(dir, f)), { recursive: true });
41131
+ copyFileSync7(join124(repoDir, f), join124(dir, f));
41109
41132
  }
41110
41133
  return await runSecureScan(dir, { ...scriptPath ? { scriptPath } : {}, timeoutMs: 60000 });
41111
41134
  } finally {
@@ -41239,7 +41262,7 @@ async function scanAddedLines(repoDir, opts = {}) {
41239
41262
  const skipped2 = [];
41240
41263
  for (const p of untracked3.split("\x00").filter(Boolean)) {
41241
41264
  try {
41242
- const st = statSync34(join123(repoDir, p));
41265
+ const st = statSync35(join124(repoDir, p));
41243
41266
  if (!st.isFile())
41244
41267
  continue;
41245
41268
  if (st.size > MAX_ADDED_FILE_BYTES) {
@@ -41254,14 +41277,14 @@ async function scanAddedLines(repoDir, opts = {}) {
41254
41277
  continue;
41255
41278
  }
41256
41279
  const lines2 = new Map;
41257
- readFileSync109(join123(repoDir, p), "utf8").split(`
41280
+ readFileSync109(join124(repoDir, p), "utf8").split(`
41258
41281
  `).forEach((t, i) => lines2.set(i + 1, t));
41259
41282
  added.set(p, lines2);
41260
41283
  } catch {}
41261
41284
  }
41262
41285
  if (added.size === 0)
41263
41286
  return { ok: true, findings: skipped2 };
41264
- const mirror = mkdtempSync14(join123(tmpdir19(), "loki-secure-added-"));
41287
+ const mirror = mkdtempSync14(join124(tmpdir19(), "loki-secure-added-"));
41265
41288
  try {
41266
41289
  const root = resolve36(mirror) + sep19;
41267
41290
  const chunkMap = new Map;
@@ -41307,7 +41330,7 @@ async function scanAddedLines(repoDir, opts = {}) {
41307
41330
  chunks.push(cur);
41308
41331
  const whole = chunks.length === 1;
41309
41332
  for (const c of chunks) {
41310
- const rel = whole ? p : join123(chunkRoot, String(chunkSeq++), basename33(p));
41333
+ const rel = whole ? p : join124(chunkRoot, String(chunkSeq++), basename33(p));
41311
41334
  const out2 = whole ? dest : resolve36(mirror, rel);
41312
41335
  if (!out2.startsWith(root))
41313
41336
  break;
@@ -41371,7 +41394,7 @@ __export(exports_deep, {
41371
41394
  });
41372
41395
  import { copyFileSync as copyFileSync8, existsSync as existsSync87, mkdirSync as mkdirSync66, mkdtempSync as mkdtempSync15, rmSync as rmSync32, writeFileSync as writeFileSync63 } from "fs";
41373
41396
  import { tmpdir as tmpdir20 } from "os";
41374
- import { dirname as dirname51, join as join124 } from "path";
41397
+ import { dirname as dirname51, join as join125 } from "path";
41375
41398
  async function runFullSuite(ctx, signal, opts, checks, notProven) {
41376
41399
  if (await runPackageSuites(ctx.repoDir, signal, { path: opts.path, timeoutMs: opts.fullSuiteTimeoutMs ?? FULL_SUITE_TIMEOUT_MS, baseSha: ctx.baseSha, skip: installOwned(ctx.repoDir, ctx.outputs().intake?.install_created), changed: opts.changed, proofFiles: opts.proofFiles, wallBaseRed: opts.wallBaseRed, targetPassed: opts.targetPassed }, checks, notProven))
41377
41400
  return;
@@ -41420,7 +41443,7 @@ ${r.stderr}`), lr = r.exitCode === 0 ? undefined : await harnessLoadReason({ rep
41420
41443
  async function runAppBoot(ctx, opts, checks, notProven) {
41421
41444
  let r;
41422
41445
  try {
41423
- r = await (opts.appProbe ?? appProbe)(ctx.repoDir, join124(ctx.repoDir, ".loki"));
41446
+ r = await (opts.appProbe ?? appProbe)(ctx.repoDir, join125(ctx.repoDir, ".loki"));
41424
41447
  } catch (err) {
41425
41448
  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 };
41426
41449
  }
@@ -41458,10 +41481,10 @@ async function runSecretScan(ctx, changed, opts, checks, notProven) {
41458
41481
  };
41459
41482
  let sec;
41460
41483
  if (opts.scanAddedSince) {
41461
- const base = opts.scanAddedSince, root = mkdtempSync15(join124(tmpdir20(), "loki-verify-secscan-")), fresh = [], copied = [], unread = [];
41484
+ const base = opts.scanAddedSince, root = mkdtempSync15(join125(tmpdir20(), "loki-verify-secscan-")), fresh = [], copied = [], unread = [];
41462
41485
  try {
41463
41486
  for (const f of changed) {
41464
- if (!existsSync87(join124(ctx.repoDir, f)))
41487
+ if (!existsSync87(join125(ctx.repoDir, f)))
41465
41488
  continue;
41466
41489
  const atBase = (await safeGitRun(ctx.repoDir, ["cat-file", "-e", `${base}:${f}`], { timeoutMs: 1e4 })).exitCode === 0;
41467
41490
  let added = null;
@@ -41478,11 +41501,11 @@ async function runSecretScan(ctx, changed, opts, checks, notProven) {
41478
41501
  continue;
41479
41502
  } else
41480
41503
  fresh.push(f);
41481
- mkdirSync66(dirname51(join124(root, f)), { recursive: true });
41504
+ mkdirSync66(dirname51(join125(root, f)), { recursive: true });
41482
41505
  if (added === null)
41483
- copyFileSync8(join124(ctx.repoDir, f), join124(root, f));
41506
+ copyFileSync8(join125(ctx.repoDir, f), join125(root, f));
41484
41507
  else
41485
- writeFileSync63(join124(root, f), added + `
41508
+ writeFileSync63(join125(root, f), added + `
41486
41509
  `);
41487
41510
  copied.push(f);
41488
41511
  }
@@ -41554,7 +41577,7 @@ async function runDeep(ctx, signal, opts = {}) {
41554
41577
  const sig = signReceipt(`${ctx.runId}-deep`, addendumSha256);
41555
41578
  const addendum = { ...addendumBody, addendum_sha256: addendumSha256, verification: { jwt: sig.jwt, kid: sig.kid } };
41556
41579
  mkdirSync66(ctx.runDir, { recursive: true });
41557
- writeFileSync63(join124(ctx.runDir, "receipt-addendum-1.json"), JSON.stringify(addendum, null, 2) + `
41580
+ writeFileSync63(join125(ctx.runDir, "receipt-addendum-1.json"), JSON.stringify(addendum, null, 2) + `
41558
41581
  `);
41559
41582
  const headSha = (await safeGitRun(ctx.repoDir, ["rev-parse", "HEAD"], { timeoutMs: 1e4 })).stdout.trim();
41560
41583
  const pushNotProven = await postDeepResults({
@@ -41580,11 +41603,11 @@ async function deepWorker(args, deps = {}) {
41580
41603
  `);
41581
41604
  return 2;
41582
41605
  }
41583
- const repoDir = process.cwd(), lokiRoot = join124(repoDir, ".loki"), runDir = join124(lokiRoot, "runs", runId2);
41606
+ const repoDir = process.cwd(), lokiRoot = join125(repoDir, ".loki"), runDir = join125(lokiRoot, "runs", runId2);
41584
41607
  const { readEvents: readEvents2 } = await Promise.resolve().then(() => (init_events(), exports_events)), { eventsRelPath: eventsRelPath2 } = await Promise.resolve().then(() => (init_engine_origin(), exports_engine_origin)), { outputsFromEvents } = await Promise.resolve().then(() => (init_run_outputs(), exports_run_outputs));
41585
41608
  let outputs;
41586
41609
  try {
41587
- outputs = outputsFromEvents(readEvents2(join124(repoDir, eventsRelPath2(runId2))));
41610
+ outputs = outputsFromEvents(readEvents2(join125(repoDir, eventsRelPath2(runId2))));
41588
41611
  } catch (err) {
41589
41612
  process.stderr.write(`engine10 deep-worker: cannot read run events: ${err.message}
41590
41613
  `);
@@ -41649,7 +41672,7 @@ var init_deep = __esm(() => {
41649
41672
  init_safe_git();
41650
41673
  init_paths();
41651
41674
  init_pr();
41652
- DEFAULT_SECRET_SCAN_SH = join124(REPO_ROOT, "autonomy/lib/secret-scan.sh");
41675
+ DEFAULT_SECRET_SCAN_SH = join125(REPO_ROOT, "autonomy/lib/secret-scan.sh");
41653
41676
  deepStage = {
41654
41677
  name: "deep",
41655
41678
  ...STAGE_BUDGETS.deep,
@@ -41935,7 +41958,7 @@ var groupRoute = async (repoDir, rawGroup) => {
41935
41958
  };
41936
41959
 
41937
41960
  // ../../loki-ts/src/engine10/modernize/types.ts
41938
- import { join as join125 } from "path";
41961
+ import { join as join126 } from "path";
41939
41962
  function makeModernizeId(now2 = new Date) {
41940
41963
  const utc = now2.toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z");
41941
41964
  const short = Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0");
@@ -41945,13 +41968,13 @@ function isModernizeId(mid) {
41945
41968
  return MID_RE.test(mid);
41946
41969
  }
41947
41970
  function modernizeRoot(repoDir, mid) {
41948
- return join125(repoDir, ".loki", "modernize", mid);
41971
+ return join126(repoDir, ".loki", "modernize", mid);
41949
41972
  }
41950
41973
  function modernizeEventsPath(repoDir, mid) {
41951
- return join125(modernizeRoot(repoDir, mid), "events.jsonl");
41974
+ return join126(modernizeRoot(repoDir, mid), "events.jsonl");
41952
41975
  }
41953
41976
  function planPath(repoDir, mid) {
41954
- return join125(modernizeRoot(repoDir, mid), "plan.json");
41977
+ return join126(modernizeRoot(repoDir, mid), "plan.json");
41955
41978
  }
41956
41979
  function isSafeUnitId(unit) {
41957
41980
  return typeof unit === "string" && unit.length <= MAX_UNIT_ID && UNIT_ID_RE2.test(unit) && !unit.includes("..");
@@ -41962,13 +41985,13 @@ function encodeUnitId(unit) {
41962
41985
  return unit.replace(/\//g, "%2F");
41963
41986
  }
41964
41987
  function oracleDir(repoDir, mid, unit) {
41965
- return join125(modernizeRoot(repoDir, mid), "oracle", encodeUnitId(unit));
41988
+ return join126(modernizeRoot(repoDir, mid), "oracle", encodeUnitId(unit));
41966
41989
  }
41967
41990
  function reportJsonPath(repoDir, mid) {
41968
- return join125(modernizeRoot(repoDir, mid), "report.json");
41991
+ return join126(modernizeRoot(repoDir, mid), "report.json");
41969
41992
  }
41970
41993
  function reportMdPath(repoDir, mid) {
41971
- return join125(modernizeRoot(repoDir, mid), "report.md");
41994
+ return join126(modernizeRoot(repoDir, mid), "report.md");
41972
41995
  }
41973
41996
  var MID_RE, UNIT_ID_SEGMENT = "[A-Za-z0-9][A-Za-z0-9_.-]*", UNIT_ID_RE2, MAX_UNIT_ID = 128;
41974
41997
  var init_types2 = __esm(() => {
@@ -42008,9 +42031,9 @@ __export(exports_dashboard, {
42008
42031
  listModernizeIds: () => listModernizeIds
42009
42032
  });
42010
42033
  import { existsSync as existsSync88, readdirSync as readdirSync41 } from "fs";
42011
- import { join as join126 } from "path";
42034
+ import { join as join127 } from "path";
42012
42035
  function modernizeDir(repoDir) {
42013
- return join126(repoDir, ".loki", "modernize");
42036
+ return join127(repoDir, ".loki", "modernize");
42014
42037
  }
42015
42038
  function listModernizeIds(repoDir) {
42016
42039
  const dir = modernizeDir(repoDir);
@@ -42347,7 +42370,7 @@ var init_engine10_dashboard = __esm(() => {
42347
42370
 
42348
42371
  // ../../loki-ts/src/engine10/modernize/inventory.ts
42349
42372
  import { readFileSync as readFileSync111 } from "fs";
42350
- import { extname as extname4, join as join127 } from "path";
42373
+ import { extname as extname4, join as join128 } from "path";
42351
42374
  function readCapped2(absPath) {
42352
42375
  try {
42353
42376
  return readFileSync111(absPath, "utf8").slice(0, MAX_SCAN_BYTES3);
@@ -42367,9 +42390,9 @@ function detectEntryPoints(repoDir, files) {
42367
42390
  const out2 = [];
42368
42391
  for (const rel of files) {
42369
42392
  const ext = extname4(rel);
42370
- if (ext === ".py" && PY_MAIN_RE.test(readCapped2(join127(repoDir, rel))))
42393
+ if (ext === ".py" && PY_MAIN_RE.test(readCapped2(join128(repoDir, rel))))
42371
42394
  out2.push(rel);
42372
- else if (ext === ".java" && JAVA_MAIN_RE.test(readCapped2(join127(repoDir, rel))))
42395
+ else if (ext === ".java" && JAVA_MAIN_RE.test(readCapped2(join128(repoDir, rel))))
42373
42396
  out2.push(rel);
42374
42397
  }
42375
42398
  return out2;
@@ -42419,7 +42442,7 @@ var init_inventory = __esm(() => {
42419
42442
  });
42420
42443
 
42421
42444
  // ../../loki-ts/src/engine10/modernize/lang/python.ts
42422
- import { join as join128 } from "path";
42445
+ import { join as join129 } from "path";
42423
42446
  async function buildPythonGraph(repoDir, files, opts = {}) {
42424
42447
  if (files.length === 0)
42425
42448
  return { graph: { nodes: [], edges: [] }, unresolved: [] };
@@ -42458,7 +42481,7 @@ var init_python2 = __esm(() => {
42458
42481
  init_paths();
42459
42482
  init_python();
42460
42483
  init_shell();
42461
- SCRIPT = join128(REPO_ROOT, "autonomy", "lib", "modernize", "py_imports.py");
42484
+ SCRIPT = join129(REPO_ROOT, "autonomy", "lib", "modernize", "py_imports.py");
42462
42485
  });
42463
42486
 
42464
42487
  // ../../loki-ts/src/engine10/modernize/cluster.ts
@@ -42638,7 +42661,7 @@ var init_codemod = __esm(() => {
42638
42661
  // ../../loki-ts/src/engine10/modernize/oracle/seal.ts
42639
42662
  import { createHash as createHash35 } from "crypto";
42640
42663
  import { existsSync as existsSync89, mkdirSync as mkdirSync67, readFileSync as readFileSync112, writeFileSync as writeFileSync64 } from "fs";
42641
- import { join as join129 } from "path";
42664
+ import { join as join130 } from "path";
42642
42665
  function normalizersSha(n3) {
42643
42666
  return sha2564(JSON.stringify({
42644
42667
  float_tolerance: n3.float_tolerance,
@@ -42700,9 +42723,9 @@ function alreadySealedInLog(repoDir, mid, unit) {
42700
42723
  }
42701
42724
  function sealOracle(repoDir, mid, unit, log, normalizers = DEFAULT_NORMALIZERS) {
42702
42725
  const dir = oracleDir(repoDir, mid, unit);
42703
- const casesPath = join129(dir, "cases.jsonl");
42704
- const coveragePath = join129(dir, "coverage.json");
42705
- const sealedPath = join129(dir, "sealed.json");
42726
+ const casesPath = join130(dir, "cases.jsonl");
42727
+ const coveragePath = join130(dir, "coverage.json");
42728
+ const sealedPath = join130(dir, "sealed.json");
42706
42729
  if (alreadySealedInLog(repoDir, mid, unit)) {
42707
42730
  throw new Error(`oracle seal: ${unit} already has a sealing event in the modernize log; re-seal refused (seal is write-once)`);
42708
42731
  }
@@ -42733,9 +42756,9 @@ function sealOracle(repoDir, mid, unit, log, normalizers = DEFAULT_NORMALIZERS)
42733
42756
  }
42734
42757
  function verifySeal(repoDir, mid, unit) {
42735
42758
  const dir = oracleDir(repoDir, mid, unit);
42736
- const sealedPath = join129(dir, "sealed.json");
42737
- const casesPath = join129(dir, "cases.jsonl");
42738
- const coveragePath = join129(dir, "coverage.json");
42759
+ const sealedPath = join130(dir, "sealed.json");
42760
+ const casesPath = join130(dir, "cases.jsonl");
42761
+ const coveragePath = join130(dir, "coverage.json");
42739
42762
  if (!existsSync89(sealedPath))
42740
42763
  return { ok: false, reason: "no sealed.json" };
42741
42764
  if (!existsSync89(casesPath))
@@ -42784,7 +42807,7 @@ var init_seal2 = __esm(() => {
42784
42807
  import { spawnSync as spawnSync20 } from "child_process";
42785
42808
  import { copyFileSync as copyFileSync9, existsSync as existsSync90, linkSync as linkSync4, mkdirSync as mkdirSync68, mkdtempSync as mkdtempSync16, readFileSync as readFileSync113, renameSync as renameSync23, rmSync as rmSync33, rmdirSync as rmdirSync2, writeFileSync as writeFileSync65 } from "fs";
42786
42809
  import { tmpdir as tmpdir21 } from "os";
42787
- import { basename as basename34, dirname as dirname53, join as join130 } from "path";
42810
+ import { basename as basename34, dirname as dirname53, join as join131 } from "path";
42788
42811
  function search(unitSource, seedCases, propose, runCapture, opts = {}) {
42789
42812
  const maxRounds = opts.maxRounds ?? 10;
42790
42813
  const plateauLimit = opts.plateauRounds ?? 2;
@@ -42841,10 +42864,10 @@ function realCaptureRunner(unitPath, cases, outPath) {
42841
42864
  return captureFailed("old runtime unavailable");
42842
42865
  let dir = "";
42843
42866
  try {
42844
- dir = mkdtempSync16(join130(tmpdir21(), "m10-search-"));
42845
- const casesFile = join130(dir, "cases.jsonl");
42846
- const outFile = join130(dir, "out.jsonl");
42847
- const covFile = join130(dir, "coverage.json");
42867
+ dir = mkdtempSync16(join131(tmpdir21(), "m10-search-"));
42868
+ const casesFile = join131(dir, "cases.jsonl");
42869
+ const outFile = join131(dir, "out.jsonl");
42870
+ const covFile = join131(dir, "coverage.json");
42848
42871
  const lines2 = cases.map((c) => JSON.stringify({ entry: c.entry, args: c.args, kwargs: c.kwargs }));
42849
42872
  writeFileSync65(casesFile, lines2.length ? lines2.join(`
42850
42873
  `) + `
@@ -42892,13 +42915,13 @@ function resolveOldRuntimeSync() {
42892
42915
  }
42893
42916
  function makeProposeInputs(session, cap = 20) {
42894
42917
  return (unitPath, missing, round2) => {
42895
- const cwd = mkdtempSync16(join130(tmpdir21(), "m27-propose-"));
42918
+ const cwd = mkdtempSync16(join131(tmpdir21(), "m27-propose-"));
42896
42919
  try {
42897
- const unitFile = join130(cwd, basename34(unitPath));
42920
+ const unitFile = join131(cwd, basename34(unitPath));
42898
42921
  copyFileSync9(unitPath, unitFile);
42899
42922
  session({ cwd, env: tokenFreeEnv(), unitFile, missing, round: round2 });
42900
42923
  const out2 = [];
42901
- for (const line2 of readFileSync113(join130(cwd, "proposals.jsonl"), "utf8").split(`
42924
+ for (const line2 of readFileSync113(join131(cwd, "proposals.jsonl"), "utf8").split(`
42902
42925
  `)) {
42903
42926
  try {
42904
42927
  const c = JSON.parse(line2);
@@ -42916,7 +42939,7 @@ function makeProposeInputs(session, cap = 20) {
42916
42939
  }
42917
42940
  function captureUnitOracle(a) {
42918
42941
  const dir = oracleDir(a.repoDir, a.mid, a.unit);
42919
- if (existsSync90(join130(dir, "cases.jsonl")) || alreadySealedInLog(a.repoDir, a.mid, a.unit)) {
42942
+ if (existsSync90(join131(dir, "cases.jsonl")) || alreadySealedInLog(a.repoDir, a.mid, a.unit)) {
42920
42943
  return { ok: false, reason: "oracle already captured (write-once)" };
42921
42944
  }
42922
42945
  const run2 = a.runCapture ?? realCaptureRunner;
@@ -42936,15 +42959,15 @@ function captureUnitOracle(a) {
42936
42959
  }
42937
42960
  if (r.cases.length === 0)
42938
42961
  return { ok: false, reason: "no cases captured" };
42939
- const scratch = mkdtempSync16(join130(tmpdir21(), "m27-replay-"));
42940
- const t1 = join130(scratch, "cases"), t2 = join130(scratch, "replay");
42962
+ const scratch = mkdtempSync16(join131(tmpdir21(), "m27-replay-"));
42963
+ const t1 = join131(scratch, "cases"), t2 = join131(scratch, "replay");
42941
42964
  const created = [];
42942
42965
  for (let p = dir;!existsSync90(p) && !created.includes(p); p = dirname53(p))
42943
42966
  created.push(p);
42944
42967
  const read3 = (p) => readFileSync113(p, "utf8").split(`
42945
42968
  `).filter(Boolean).map((l) => JSON.parse(l));
42946
- const tmpCases = join130(dir, `.cases.${process.pid}.tmp`);
42947
- const tmpCov = join130(dir, `.coverage.${process.pid}.tmp`);
42969
+ const tmpCases = join131(dir, `.cases.${process.pid}.tmp`);
42970
+ const tmpCov = join131(dir, `.coverage.${process.pid}.tmp`);
42948
42971
  try {
42949
42972
  const cov = run2(a.unitPath, r.cases, t1);
42950
42973
  const cov2 = run2(a.unitPath, r.cases, t2);
@@ -42972,10 +42995,10 @@ function captureUnitOracle(a) {
42972
42995
  branch_pct: cov.branchPct,
42973
42996
  missing: cov.missing
42974
42997
  }));
42975
- if (existsSync90(join130(dir, "cases.jsonl")))
42998
+ if (existsSync90(join131(dir, "cases.jsonl")))
42976
42999
  return { ok: false, reason: "oracle already captured (write-once)" };
42977
- renameSync23(tmpCov, join130(dir, "coverage.json"));
42978
- (a.link ?? linkSync4)(tmpCases, join130(dir, "cases.jsonl"));
43000
+ renameSync23(tmpCov, join131(dir, "coverage.json"));
43001
+ (a.link ?? linkSync4)(tmpCases, join131(dir, "cases.jsonl"));
42979
43002
  return { ok: true, cases: r.cases.length, branchPct: cov.branchPct, stoppedReason: r.stoppedReason };
42980
43003
  } catch (e) {
42981
43004
  return { ok: false, reason: `capture error: ${e instanceof Error ? e.message : String(e)}` };
@@ -42983,8 +43006,8 @@ function captureUnitOracle(a) {
42983
43006
  rmSync33(scratch, { recursive: true, force: true });
42984
43007
  for (const t of [tmpCases, tmpCov])
42985
43008
  rmSync33(t, { force: true });
42986
- if (created[0] === dir && !existsSync90(join130(dir, "cases.jsonl")))
42987
- rmSync33(join130(dir, "coverage.json"), { force: true });
43009
+ if (created[0] === dir && !existsSync90(join131(dir, "cases.jsonl")))
43010
+ rmSync33(join131(dir, "coverage.json"), { force: true });
42988
43011
  for (const p of created) {
42989
43012
  try {
42990
43013
  rmdirSync2(p);
@@ -43000,12 +43023,12 @@ var init_search = __esm(() => {
43000
43023
  init_safe_git();
43001
43024
  init_types2();
43002
43025
  init_seal2();
43003
- PY_CAPTURE_SCRIPT = join130(REPO_ROOT, "autonomy", "lib", "modernize", "py_capture.py");
43026
+ PY_CAPTURE_SCRIPT = join131(REPO_ROOT, "autonomy", "lib", "modernize", "py_capture.py");
43004
43027
  });
43005
43028
 
43006
43029
  // ../../loki-ts/src/engine10/modernize/equiv.ts
43007
43030
  import { readFileSync as readFileSync114 } from "fs";
43008
- import { join as join131 } from "path";
43031
+ import { join as join132 } from "path";
43009
43032
  function parseCases(raw2) {
43010
43033
  const out2 = [];
43011
43034
  for (const line2 of raw2.split(`
@@ -43200,11 +43223,11 @@ function checkEquivalence(repoDir, mid, unit, newTreeDir, normalizers, runNew, l
43200
43223
  return notProvenResult(unit, "normalizers invalid: skip_fields covers every field, nothing would be compared", log);
43201
43224
  }
43202
43225
  const dir = oracleDir(repoDir, mid, unit);
43203
- const sealed = JSON.parse(readFileSync114(join131(dir, "sealed.json"), "utf8"));
43226
+ const sealed = JSON.parse(readFileSync114(join132(dir, "sealed.json"), "utf8"));
43204
43227
  const normCheck = verifyNormalizersAgainstSeal(sealed, normalizers);
43205
43228
  if (!normCheck.ok)
43206
43229
  return notProvenResult(unit, `normalizers: ${normCheck.reason ?? "check failed"}`, log);
43207
- const records = parseCases(readFileSync114(join131(dir, "cases.jsonl"), "utf8"));
43230
+ const records = parseCases(readFileSync114(join132(dir, "cases.jsonl"), "utf8"));
43208
43231
  const heldOutSet = new Set(sealed.held_out);
43209
43232
  let pass = 0;
43210
43233
  let fail2 = 0;
@@ -43395,7 +43418,7 @@ var init_reslice = __esm(() => {
43395
43418
  });
43396
43419
 
43397
43420
  // ../../loki-ts/src/engine10/modernize/scheduler.ts
43398
- import { join as join132 } from "path";
43421
+ import { join as join133 } from "path";
43399
43422
  function mergeOnce(unit, ops, log, completed, worktree) {
43400
43423
  if (completed.has(unit))
43401
43424
  return "already_completed";
@@ -43516,7 +43539,7 @@ async function schedule(plan, opts) {
43516
43539
  reason = hit2 ? "budget stop" : "per-unit cost cap reached";
43517
43540
  break;
43518
43541
  }
43519
- const path = join132(modernizeRoot(opts.repoDir, opts.mid), "wt", variant === 0 ? encodeUnitId(unit.id) : `${encodeUnitId(unit.id)}${VARIANT_SEP}${variant}`);
43542
+ const path = join133(modernizeRoot(opts.repoDir, opts.mid), "wt", variant === 0 ? encodeUnitId(unit.id) : `${encodeUnitId(unit.id)}${VARIANT_SEP}${variant}`);
43520
43543
  let outcome;
43521
43544
  attempts++;
43522
43545
  let resumeRunId;
@@ -43813,7 +43836,7 @@ var init_report = __esm(() => {
43813
43836
 
43814
43837
  // ../../loki-ts/src/engine10/modernize/ship.ts
43815
43838
  import { mkdirSync as mkdirSync70, writeFileSync as writeFileSync67 } from "fs";
43816
- import { join as join133 } from "path";
43839
+ import { join as join134 } from "path";
43817
43840
  function waveIsDraft(verdict, units) {
43818
43841
  return verdict === null || verdict.verified !== true || units.length === 0 || units.some((x) => x.verdict !== "PROVEN");
43819
43842
  }
@@ -43834,9 +43857,9 @@ function shipWave(o) {
43834
43857
  return fail2("no pinned origin: refusing to push (Rule of Two)");
43835
43858
  if (draft)
43836
43859
  return fail2("wave not verified: branch stays local, not pushed");
43837
- const dir = join133(o.repoDir, ".loki", "modernize", o.mid);
43860
+ const dir = join134(o.repoDir, ".loki", "modernize", o.mid);
43838
43861
  mkdirSync70(dir, { recursive: true });
43839
- const bodyFile = join133(dir, `wave-${o.wave}-pr-body.md`);
43862
+ const bodyFile = join134(dir, `wave-${o.wave}-pr-body.md`);
43840
43863
  writeFileSync67(bodyFile, renderWaveBody(o.wave, o.verdict, o.units), "utf8");
43841
43864
  const r = (o.push ?? runPushPr)({ repoDir: o.repoDir, branch: o.branch, title: `Loki modernize: wave ${o.wave}`, bodyFile, draft, pinnedOrigin });
43842
43865
  if (!r.ok)
@@ -43857,7 +43880,7 @@ var init_ship2 = __esm(() => {
43857
43880
 
43858
43881
  // ../../loki-ts/src/engine10/modernize/presealed_wall.ts
43859
43882
  import { existsSync as existsSync92, mkdirSync as mkdirSync71, readFileSync as readFileSync117, writeFileSync as writeFileSync68 } from "fs";
43860
- import { join as join134 } from "path";
43883
+ import { join as join135 } from "path";
43861
43884
  function isRealFailCount(n3) {
43862
43885
  return typeof n3 === "number" && Number.isInteger(n3) && n3 >= 1;
43863
43886
  }
@@ -43880,7 +43903,7 @@ function classifyBaseRun(o, repoDir) {
43880
43903
  return "not_run";
43881
43904
  }
43882
43905
  function preSealedPath(repoDir, mid, unit) {
43883
- return join134(oracleDir(repoDir, mid, unit), "presealed_wall.json");
43906
+ return join135(oracleDir(repoDir, mid, unit), "presealed_wall.json");
43884
43907
  }
43885
43908
  function alreadySealed(repoDir, mid, unit) {
43886
43909
  return readModernizeEvents(repoDir, mid).some((e) => e.type === SEALED_EVENT && e.data.unit === unit);
@@ -43894,7 +43917,7 @@ function sealPreSealedWall(repoDir, mid, unit, target, runConformance, log, base
43894
43917
  if (!oracleCheck.ok)
43895
43918
  return refuse(`oracle seal invalid: ${oracleCheck.reason ?? "unknown"}; presealed wall refused`);
43896
43919
  const dir = oracleDir(repoDir, mid, unit);
43897
- const oracleSealed = JSON.parse(readFileSync117(join134(dir, "sealed.json"), "utf8"));
43920
+ const oracleSealed = JSON.parse(readFileSync117(join135(dir, "sealed.json"), "utf8"));
43898
43921
  if (oracleSealed.verdict !== "PROVEN_ORACLE") {
43899
43922
  return refuse(`oracle seal invalid: oracle is ${oracleSealed.verdict} (${oracleSealed.not_proven ?? "no reason recorded"}); presealed wall refused`);
43900
43923
  }
@@ -43972,7 +43995,7 @@ function verifyPreSealedWall(repoDir, mid, unit) {
43972
43995
  if (!oracleCheck.ok) {
43973
43996
  return { ok: false, reason: `bound oracle seal is no longer valid: ${oracleCheck.reason ?? "unknown"}` };
43974
43997
  }
43975
- const oracleSealed = JSON.parse(readFileSync117(join134(oracleDir(repoDir, mid, unit), "sealed.json"), "utf8"));
43998
+ const oracleSealed = JSON.parse(readFileSync117(join135(oracleDir(repoDir, mid, unit), "sealed.json"), "utf8"));
43976
43999
  const carried = JSON.parse(sealedRaw);
43977
44000
  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) {
43978
44001
  return { ok: false, reason: "carried oracle hashes do not match the current oracle seal" };
@@ -44000,7 +44023,7 @@ import { spawnSync as spawnSync21 } from "child_process";
44000
44023
  import { createHash as createHash36 } from "crypto";
44001
44024
  import { lstatSync as lstatSync29, readFileSync as readFileSync118, readdirSync as readdirSync42, readlinkSync as readlinkSync6, realpathSync as realpathSync31, rmSync as rmSync34 } from "fs";
44002
44025
  import { tmpdir as tmpdir22 } from "os";
44003
- import { join as join135, sep as sep20 } from "path";
44026
+ import { join as join136, sep as sep20 } from "path";
44004
44027
  function isSealedName(rel) {
44005
44028
  return TEST_FILE2.test(rel) || PYTEST_CFG.test(rel);
44006
44029
  }
@@ -44015,7 +44038,7 @@ function purgePycache(dir) {
44015
44038
  for (const e of ents) {
44016
44039
  if (!e.isDirectory())
44017
44040
  continue;
44018
- const full = join135(d, e.name);
44041
+ const full = join136(d, e.name);
44019
44042
  if (e.name === "__pycache__")
44020
44043
  rmSync34(full, { recursive: true, force: true });
44021
44044
  else if (!skipName(e.name))
@@ -44070,7 +44093,7 @@ function outsideTargetDigest(dir, full) {
44070
44093
  }
44071
44094
  for (const n3 of names) {
44072
44095
  h.update("D" + n3);
44073
- walk(join135(p, n3));
44096
+ walk(join136(p, n3));
44074
44097
  }
44075
44098
  return;
44076
44099
  }
@@ -44091,7 +44114,7 @@ function conformanceHashes(dir) {
44091
44114
  const walk = (sub2, inSkip) => {
44092
44115
  let ents;
44093
44116
  try {
44094
- ents = readdirSync42(join135(dir, sub2), { withFileTypes: true });
44117
+ ents = readdirSync42(join136(dir, sub2), { withFileTypes: true });
44095
44118
  } catch {
44096
44119
  return;
44097
44120
  }
@@ -44122,14 +44145,14 @@ function conformanceHashes(dir) {
44122
44145
  for (const rel of rels) {
44123
44146
  let data;
44124
44147
  try {
44125
- const st = lstatSync29(join135(dir, rel));
44148
+ const st = lstatSync29(join136(dir, rel));
44126
44149
  if (st.isSymbolicLink()) {
44127
- out2[rel] = `${LINK}${readlinkSync6(join135(dir, rel))}|${outsideTargetDigest(dir, join135(dir, rel))}`;
44150
+ out2[rel] = `${LINK}${readlinkSync6(join136(dir, rel))}|${outsideTargetDigest(dir, join136(dir, rel))}`;
44128
44151
  continue;
44129
44152
  }
44130
44153
  if (!st.isFile())
44131
44154
  continue;
44132
- data = readFileSync118(join135(dir, rel));
44155
+ data = readFileSync118(join136(dir, rel));
44133
44156
  } catch {
44134
44157
  continue;
44135
44158
  }
@@ -44188,7 +44211,7 @@ function notProvenUnitResult(unit, reason, oracle, wall) {
44188
44211
  return { unit, verdict: "NOT_PROVEN", oracle, wall, equiv: null, not_proven: [reason], conformance: null };
44189
44212
  }
44190
44213
  function readOracleSealed(repoDir, mid, unit) {
44191
- return JSON.parse(readFileSync118(join135(oracleDir(repoDir, mid, unit), "sealed.json"), "utf8"));
44214
+ return JSON.parse(readFileSync118(join136(oracleDir(repoDir, mid, unit), "sealed.json"), "utf8"));
44192
44215
  }
44193
44216
  function runUnit(card, log, runConformance, implement, runNew, runStub, collect) {
44194
44217
  const { repoDir, mid, unit } = card;
@@ -44299,8 +44322,8 @@ var init_unit = __esm(() => {
44299
44322
 
44300
44323
  // ../../loki-ts/src/engine10/modernize/wave.ts
44301
44324
  import { spawnSync as spawnSync22 } from "child_process";
44302
- import { readFileSync as readFileSync119, statSync as statSync35 } from "fs";
44303
- import { join as join136 } from "path";
44325
+ import { readFileSync as readFileSync119, statSync as statSync36 } from "fs";
44326
+ import { join as join137 } from "path";
44304
44327
  function clampTimeout(ms) {
44305
44328
  if (ms === undefined || !Number.isFinite(ms) || ms <= 0)
44306
44329
  return DEFAULT_STEP_TIMEOUT_MS;
@@ -44369,7 +44392,7 @@ function detectWaveCommands(inv, target) {
44369
44392
  const none = { build: null, integration: null, original_suite: null };
44370
44393
  const text4 = () => {
44371
44394
  try {
44372
- return readFileSync119(join136(target, marker ?? ""), "utf8");
44395
+ return readFileSync119(join137(target, marker ?? ""), "utf8");
44373
44396
  } catch {
44374
44397
  return "";
44375
44398
  }
@@ -44381,7 +44404,7 @@ function detectWaveCommands(inv, target) {
44381
44404
  if (system === "gradle") {
44382
44405
  let gw = "gradle";
44383
44406
  try {
44384
- if (inv.files.includes("gradlew") && (statSync35(join136(target, "gradlew")).mode & 73) !== 0)
44407
+ if (inv.files.includes("gradlew") && (statSync36(join137(target, "gradlew")).mode & 73) !== 0)
44385
44408
  gw = "./gradlew";
44386
44409
  } catch {}
44387
44410
  return { build: { argv: [gw, "assemble"] }, integration: text4().includes("integrationTest") ? { argv: [gw, "integrationTest"] } : null, original_suite: { argv: [gw, "test"] } };
@@ -44393,7 +44416,7 @@ function detectWaveCommands(inv, target) {
44393
44416
  let toxIni = "";
44394
44417
  if (inv.files.includes("tox.ini")) {
44395
44418
  try {
44396
- toxIni = readFileSync119(join136(target, "tox.ini"), "utf8");
44419
+ toxIni = readFileSync119(join137(target, "tox.ini"), "utf8");
44397
44420
  } catch {}
44398
44421
  }
44399
44422
  const integration = toxIni.includes("[testenv:integration") ? { argv: ["tox", "-e", "integration"] } : itDir && pytest ? { argv: ["python3", "-m", "pytest", "-q", itDir] } : null;
@@ -44425,9 +44448,9 @@ var init_wave = __esm(() => {
44425
44448
 
44426
44449
  // ../../loki-ts/src/util/modernize_unit.ts
44427
44450
  import { spawnSync as spawnSync23 } from "child_process";
44428
- import { existsSync as existsSync93, lstatSync as lstatSync30, mkdtempSync as mkdtempSync17, readFileSync as readFileSync120, realpathSync as realpathSync32, rmSync as rmSync35, statSync as statSync36, writeFileSync as writeFileSync69 } from "fs";
44451
+ import { existsSync as existsSync93, lstatSync as lstatSync30, mkdtempSync as mkdtempSync17, readFileSync as readFileSync120, realpathSync as realpathSync32, rmSync as rmSync35, statSync as statSync37, writeFileSync as writeFileSync69 } from "fs";
44429
44452
  import { tmpdir as tmpdir23 } from "os";
44430
- import { join as join137, sep as sep21 } from "path";
44453
+ import { join as join138, sep as sep21 } from "path";
44431
44454
  function parseUnitArgs(args) {
44432
44455
  const f = {};
44433
44456
  for (let i = 0;i < args.length; i++) {
@@ -44499,7 +44522,7 @@ function makeUnitRunners(o) {
44499
44522
  }
44500
44523
  function makeSessionRunner(o) {
44501
44524
  const limitS = o.sessionLimitS ?? SESSION_LIMIT_S2;
44502
- const cli = import.meta.path.endsWith("modernize_unit.ts") ? join137(import.meta.dir, "..", "cli.ts") : import.meta.path;
44525
+ const cli = import.meta.path.endsWith("modernize_unit.ts") ? join138(import.meta.dir, "..", "cli.ts") : import.meta.path;
44503
44526
  return o.session ?? ((_brief, cwd, env) => spawnSync23(process.execPath, [...SAFE_BUN_FLAGS, cli, "engine10", "session"], { cwd, env, stdio: ["ignore", "ignore", "pipe"], timeout: limitS * 1000 }));
44504
44527
  }
44505
44528
  function defaultUnitFile(unitId, newTreeDir) {
@@ -44507,7 +44530,7 @@ function defaultUnitFile(unitId, newTreeDir) {
44507
44530
  return null;
44508
44531
  try {
44509
44532
  const root = realpathSync32(newTreeDir);
44510
- const real3 = realpathSync32(join137(root, unitId));
44533
+ const real3 = realpathSync32(join138(root, unitId));
44511
44534
  return real3.startsWith(root + sep21) ? real3 : null;
44512
44535
  } catch {
44513
44536
  return null;
@@ -44544,12 +44567,12 @@ function runPythonCase(o, unitId, newTreeDir, rec2, stub) {
44544
44567
  const src = o.unitFile ? o.unitFile(unitId, newTreeDir) : defaultUnitFile(unitId, newTreeDir);
44545
44568
  if (!src || !src.endsWith(".py") || !existsSync93(src))
44546
44569
  throw new Error(`cannot locate the source of unit ${unitId} in the new tree`);
44547
- const dir = mkdtempSync17(join137(tmpdir23(), "loki-newcase-"));
44570
+ const dir = mkdtempSync17(join138(tmpdir23(), "loki-newcase-"));
44548
44571
  try {
44549
- const cases = join137(dir, "in.jsonl"), out2 = join137(dir, "out.jsonl");
44572
+ const cases = join138(dir, "in.jsonl"), out2 = join138(dir, "out.jsonl");
44550
44573
  writeFileSync69(cases, JSON.stringify({ entry: rec2.entry, args: rec2.args, kwargs: rec2.kwargs, boundaries: boundariesFromCase(rec2) }) + `
44551
44574
  `, "utf8");
44552
- const r = spawnSync23(o.pythonBin ?? "python3", [join137(REPO_ROOT, "autonomy", "lib", "modernize", "py_capture.py"), "--unit", src, "--cases", cases, "--out", out2, ...stub ? ["--stub"] : []], { cwd: newTreeDir, encoding: "utf8", timeout: CASE_TIMEOUT_MS, env: { ...tokenFreeEnv(), PYTHONDONTWRITEBYTECODE: "1" } });
44575
+ const r = spawnSync23(o.pythonBin ?? "python3", [join138(REPO_ROOT, "autonomy", "lib", "modernize", "py_capture.py"), "--unit", src, "--cases", cases, "--out", out2, ...stub ? ["--stub"] : []], { cwd: newTreeDir, encoding: "utf8", timeout: CASE_TIMEOUT_MS, env: { ...tokenFreeEnv(), PYTHONDONTWRITEBYTECODE: "1" } });
44553
44576
  if (r.status !== 0 || !existsSync93(out2))
44554
44577
  throw new Error(`new-tree case runner failed (${r.status ?? r.signal ?? "no status"}): ${String(r.stderr ?? "").trim().split(`
44555
44578
  `).pop() ?? ""}`);
@@ -44579,7 +44602,7 @@ Usage: ${UNIT_USAGE}
44579
44602
  const root = u.tmpRoot ?? (runTmp !== "" && isRealDir(runTmp) ? runTmp : tmpdir23());
44580
44603
  let repoDir;
44581
44604
  try {
44582
- repoDir = mkdtempSync17(join137(root, "loki-unit-"));
44605
+ repoDir = mkdtempSync17(join138(root, "loki-unit-"));
44583
44606
  } catch (e) {
44584
44607
  process.stderr.write(`modernize unit: cannot create a temp checkout directory: ${e.message}
44585
44608
  `);
@@ -44650,7 +44673,7 @@ var UNIT_USAGE = "loki modernize unit --repo <owner/name> --ref <ref> --unit <id
44650
44673
  return s.size === 1 ? [...s][0] : null;
44651
44674
  }, isRealDir = (p) => {
44652
44675
  try {
44653
- return !lstatSync30(p).isSymbolicLink() && statSync36(p).isDirectory();
44676
+ return !lstatSync30(p).isSymbolicLink() && statSync37(p).isDirectory();
44654
44677
  } catch {
44655
44678
  return false;
44656
44679
  }
@@ -44677,9 +44700,9 @@ var init_modernize_unit = __esm(() => {
44677
44700
  import { createHash as createHash37 } from "crypto";
44678
44701
  import { existsSync as existsSync94, mkdtempSync as mkdtempSync18, readFileSync as readFileSync121, rmSync as rmSync36 } from "fs";
44679
44702
  import { tmpdir as tmpdir24 } from "os";
44680
- import { join as join138 } from "path";
44703
+ import { join as join139 } from "path";
44681
44704
  function shipUnitOf(d, unit, o) {
44682
- const sealed = join138(oracleDir(d.repoDir, d.mid, unit), "sealed.json");
44705
+ const sealed = join139(oracleDir(d.repoDir, d.mid, unit), "sealed.json");
44683
44706
  const eq2 = o?.result?.equiv;
44684
44707
  return {
44685
44708
  unit,
@@ -44696,7 +44719,7 @@ function scopeBuildToWave(cmd2, repoDir, units) {
44696
44719
  const x = cmd2?.argv.indexOf("-x") ?? -1;
44697
44720
  if (!cmd2 || !cmd2.argv.includes("compileall") || x < 0)
44698
44721
  return cmd2;
44699
- const files = [...new Set(units.flatMap((u) => u.nodes))].filter((n3) => n3.endsWith(".py") && isSafeUnitId(n3) && existsSync94(join138(repoDir, n3)));
44722
+ const files = [...new Set(units.flatMap((u) => u.nodes))].filter((n3) => n3.endsWith(".py") && isSafeUnitId(n3) && existsSync94(join139(repoDir, n3)));
44700
44723
  return files.length ? { ...cmd2, argv: [...cmd2.argv.slice(0, x + 2), ...files] } : cmd2;
44701
44724
  }
44702
44725
  async function runWaves(plan, d) {
@@ -44855,16 +44878,16 @@ function makeAttemptRunner(o) {
44855
44878
  }
44856
44879
  function makeUnitPrep(o) {
44857
44880
  const runtimeOk = o.runtimeOk ?? (() => {
44858
- const dir = mkdtempSync18(join138(tmpdir24(), "loki-probe-"));
44881
+ const dir = mkdtempSync18(join139(tmpdir24(), "loki-probe-"));
44859
44882
  try {
44860
- return realCaptureRunner(join138(dir, "probe.py"), []).error !== "old runtime unavailable";
44883
+ return realCaptureRunner(join139(dir, "probe.py"), []).error !== "old runtime unavailable";
44861
44884
  } finally {
44862
44885
  rmSync36(dir, { recursive: true, force: true });
44863
44886
  }
44864
44887
  });
44865
44888
  let runtime = null;
44866
44889
  return (unit) => {
44867
- if (existsSync94(join138(oracleDir(o.repoDir, o.mid, unit.id), "cases.jsonl")) || alreadySealedInLog(o.repoDir, o.mid, unit.id))
44890
+ if (existsSync94(join139(oracleDir(o.repoDir, o.mid, unit.id), "cases.jsonl")) || alreadySealedInLog(o.repoDir, o.mid, unit.id))
44868
44891
  return null;
44869
44892
  runtime ??= runtimeOk();
44870
44893
  if (!runtime)
@@ -44872,7 +44895,7 @@ function makeUnitPrep(o) {
44872
44895
  const node = unit.nodes.length === 1 ? unit.nodes[0] : "";
44873
44896
  if (!node.endsWith(".py") || !isSafeUnitId(node))
44874
44897
  return MULTI_FILE_REASON;
44875
- const r = (o.capture ?? captureUnitOracle)({ repoDir: o.repoDir, mid: o.mid, unit: unit.id, unitPath: join138(o.repoDir, node), propose: o.propose });
44898
+ const r = (o.capture ?? captureUnitOracle)({ repoDir: o.repoDir, mid: o.mid, unit: unit.id, unitPath: join139(o.repoDir, node), propose: o.propose });
44876
44899
  return r.ok ? null : r.reason;
44877
44900
  };
44878
44901
  }
@@ -44964,7 +44987,7 @@ __export(exports_cli, {
44964
44987
  main: () => main6,
44965
44988
  USAGE: () => USAGE2
44966
44989
  });
44967
- import { existsSync as existsSync95, statSync as statSync37 } from "fs";
44990
+ import { existsSync as existsSync95, statSync as statSync38 } from "fs";
44968
44991
  function parseArgs2(args) {
44969
44992
  let repoDir = null;
44970
44993
  let target = null;
@@ -45101,7 +45124,7 @@ ${USAGE2}`);
45101
45124
  return 2;
45102
45125
  }
45103
45126
  const opts = parsed.opts;
45104
- if (!existsSync95(opts.repoDir) || !statSync37(opts.repoDir).isDirectory()) {
45127
+ if (!existsSync95(opts.repoDir) || !statSync38(opts.repoDir).isDirectory()) {
45105
45128
  process.stderr.write(`modernize: not a directory: ${opts.repoDir}
45106
45129
  `);
45107
45130
  return 2;
@@ -45265,7 +45288,7 @@ __export(exports_export_sarif, {
45265
45288
  main: () => main7
45266
45289
  });
45267
45290
  import { existsSync as existsSync96, readFileSync as readFileSync122, writeFileSync as writeFileSync70 } from "fs";
45268
- import { join as join139 } from "path";
45291
+ import { join as join140 } from "path";
45269
45292
  function scanDiff(diff) {
45270
45293
  const out2 = [];
45271
45294
  let file = "";
@@ -45296,7 +45319,7 @@ function scanDiff(diff) {
45296
45319
  function preRedFromEvents(runDir) {
45297
45320
  try {
45298
45321
  let pre = [];
45299
- for (const l of readFileSync122(join139(runDir, "events.jsonl"), "utf8").split(`
45322
+ for (const l of readFileSync122(join140(runDir, "events.jsonl"), "utf8").split(`
45300
45323
  `)) {
45301
45324
  if (!l.includes('"stage.completed"'))
45302
45325
  continue;
@@ -45325,13 +45348,13 @@ async function main7(args, deps = {}) {
45325
45348
  if (bad || rest.length > 1)
45326
45349
  return process.stderr.write(`loki export --sarif: ${bad ? `unknown flag ${bad}` : "more than one run-id"}
45327
45350
  `), 2;
45328
- const runsRoot2 = deps.runsRoot ?? join139(lokiDir(), "runs");
45351
+ const runsRoot2 = deps.runsRoot ?? join140(lokiDir(), "runs");
45329
45352
  const runId2 = rest[0] ?? latestRunId(runsRoot2);
45330
45353
  if (!runId2)
45331
45354
  return process.stderr.write(`loki export --sarif: no runs found
45332
45355
  `), 66;
45333
- const runDir = join139(runsRoot2, runId2);
45334
- const receiptPath = join139(runDir, "receipt.json");
45356
+ const runDir = join140(runsRoot2, runId2);
45357
+ const receiptPath = join140(runDir, "receipt.json");
45335
45358
  if (runId2.includes("/") || runId2.includes("..") || !existsSync96(receiptPath))
45336
45359
  return process.stderr.write(`loki export --sarif: unknown run ${runId2}
45337
45360
  `), 66;
@@ -45354,9 +45377,9 @@ async function main7(args, deps = {}) {
45354
45377
  findings.push(...receiptFindings(receipt, preRedFromEvents(runDir)));
45355
45378
  let version2 = "0.0.0";
45356
45379
  try {
45357
- version2 = readFileSync122(join139(REPO_ROOT, "VERSION"), "utf8").trim() || version2;
45380
+ version2 = readFileSync122(join140(REPO_ROOT, "VERSION"), "utf8").trim() || version2;
45358
45381
  } catch {}
45359
- const out2 = join139(runDir, "findings.sarif");
45382
+ const out2 = join140(runDir, "findings.sarif");
45360
45383
  writeFileSync70(out2, JSON.stringify(toSarif(findings, version2, deps.repoDir ?? process.cwd()), null, 2) + `
45361
45384
  `);
45362
45385
  process.stdout.write(`run: ${runId2}
@@ -45757,10 +45780,10 @@ var init_undo = __esm(() => {
45757
45780
  });
45758
45781
 
45759
45782
  // ../../loki-ts/src/commands/run_status.ts
45760
- import { existsSync as existsSync97, readdirSync as readdirSync43, readFileSync as readFileSync124, statSync as statSync38 } from "fs";
45761
- import { basename as basename35, dirname as dirname55, join as join140, resolve as resolve37 } from "path";
45783
+ import { existsSync as existsSync97, readdirSync as readdirSync43, readFileSync as readFileSync124, statSync as statSync39 } from "fs";
45784
+ import { basename as basename35, dirname as dirname55, join as join141, resolve as resolve37 } from "path";
45762
45785
  function runsRoot(env, repoDir) {
45763
- return env.LOKI_DIR ? join140(resolve37(repoDir, env.LOKI_DIR), "runs") : join140(repoDir, ".loki", "runs");
45786
+ return env.LOKI_DIR ? join141(resolve37(repoDir, env.LOKI_DIR), "runs") : join141(repoDir, ".loki", "runs");
45764
45787
  }
45765
45788
  function listRunIds(root) {
45766
45789
  if (!existsSync97(root))
@@ -45772,7 +45795,7 @@ function latestRunId(root) {
45772
45795
  return ids.length ? ids[ids.length - 1] : null;
45773
45796
  }
45774
45797
  function eventsPath(root, runId2) {
45775
- return join140(root, runId2, "events.jsonl");
45798
+ return join141(root, runId2, "events.jsonl");
45776
45799
  }
45777
45800
  var TERMINAL2, LEGACY_BRANCHES_DIR = "legacy-branches";
45778
45801
  var init_run_status = __esm(() => {
@@ -45810,9 +45833,9 @@ __export(exports_base_guard, {
45810
45833
  addedSymlinkNotes: () => addedSymlinkNotes
45811
45834
  });
45812
45835
  import { execFileSync as execFileSync9 } from "child_process";
45813
- import { existsSync as existsSync98, mkdirSync as mkdirSync72, mkdtempSync as mkdtempSync19, readdirSync as readdirSync44, readFileSync as readFileSync125, readlinkSync as readlinkSync7, realpathSync as realpathSync33, rmSync as rmSync37, statSync as statSync39, symlinkSync as symlinkSync4, utimesSync, writeFileSync as writeFileSync71 } from "fs";
45836
+ import { existsSync as existsSync98, mkdirSync as mkdirSync72, mkdtempSync as mkdtempSync19, readdirSync as readdirSync44, readFileSync as readFileSync125, readlinkSync as readlinkSync7, realpathSync as realpathSync33, rmSync as rmSync37, statSync as statSync40, symlinkSync as symlinkSync4, utimesSync, writeFileSync as writeFileSync71 } from "fs";
45814
45837
  import { tmpdir as tmpdir25 } from "os";
45815
- import { basename as basename36, dirname as dirname56, join as join141, relative as relative27, resolve as resolve38, sep as sep22 } from "path";
45838
+ import { basename as basename36, dirname as dirname56, join as join142, relative as relative27, resolve as resolve38, sep as sep22 } from "path";
45816
45839
  import { fileURLToPath as fileURLToPath8 } from "url";
45817
45840
  function git13(repoDir, args, timeout = 20000, extraEnv = {}) {
45818
45841
  try {
@@ -45851,10 +45874,10 @@ function resolveBase(repoDir, explicit = process.env.LOKI_E10_BASE, fetchRemote
45851
45874
  function lokiCommitsOnHead(repoDir, target) {
45852
45875
  if ((git13(repoDir, ["log", `${target}..HEAD`, "--format=%(trailers:key=Loki-Run,valueonly)"]) ?? "").trim() !== "")
45853
45876
  return true;
45854
- const runsDir = join141(repoDir, ".loki", "runs");
45877
+ const runsDir = join142(repoDir, ".loki", "runs");
45855
45878
  for (const id of listRunIds(runsDir)) {
45856
45879
  try {
45857
- const rc = JSON.parse(readFileSync125(join141(runsDir, id, "receipt.json"), "utf8"));
45880
+ const rc = JSON.parse(readFileSync125(join142(runsDir, id, "receipt.json"), "utf8"));
45858
45881
  const sha6 = typeof rc.head_sha === "string" ? rc.head_sha : "", from = typeof rc.base_sha === "string" ? rc.base_sha : "";
45859
45882
  if (!/^[0-9a-f]{40}$/.test(sha6) || !/^[0-9a-f]{40}$/.test(from) || sha6 === from)
45860
45883
  continue;
@@ -45935,7 +45958,7 @@ function depsSeeHead(pkgDir, repoDir) {
45935
45958
  for (const e of readdirSync44(dir, { withFileTypes: true })) {
45936
45959
  if (++seen > WALK_BOUND)
45937
45960
  return true;
45938
- const p = join141(dir, e.name);
45961
+ const p = join142(dir, e.name);
45939
45962
  if (e.isSymbolicLink()) {
45940
45963
  const t = resolve38(dir, readlinkSync7(p));
45941
45964
  let rt = t;
@@ -45958,7 +45981,7 @@ function depsSeeHead(pkgDir, repoDir) {
45958
45981
  try {
45959
45982
  return ["node_modules", ".venv"].some((d) => {
45960
45983
  try {
45961
- const top = join141(pkgDir, d);
45984
+ const top = join142(pkgDir, d);
45962
45985
  return walk(top, [...new Set([resolve38(top), realpathSync33(top)])]);
45963
45986
  } catch (e) {
45964
45987
  if (e.code === "ENOENT")
@@ -45990,19 +46013,19 @@ function envChangedSince(repoDir, pkgDir, sinceMs, ignored) {
45990
46013
  try {
45991
46014
  const roots = [];
45992
46015
  for (const rel of ignored) {
45993
- const st = statSync39(join141(repoDir, rel), { throwIfNoEntry: false });
46016
+ const st = statSync40(join142(repoDir, rel), { throwIfNoEntry: false });
45994
46017
  if (!st)
45995
46018
  return true;
45996
46019
  if (!st.isDirectory())
45997
- roots.push(join141(repoDir, rel));
46020
+ roots.push(join142(repoDir, rel));
45998
46021
  }
45999
46022
  for (const d of ["node_modules", ".venv"])
46000
- if (existsSync98(join141(pkgDir, d)))
46001
- roots.push(join141(pkgDir, d));
46023
+ if (existsSync98(join142(pkgDir, d)))
46024
+ roots.push(join142(pkgDir, d));
46002
46025
  if (roots.length === 0)
46003
46026
  return false;
46004
- stampDir = mkdtempSync19(join141(tmpdir25(), "loki-zero-stamp-"));
46005
- const stamp2 = join141(stampDir, "since");
46027
+ stampDir = mkdtempSync19(join142(tmpdir25(), "loki-zero-stamp-"));
46028
+ const stamp2 = join142(stampDir, "since");
46006
46029
  writeFileSync71(stamp2, "");
46007
46030
  utimesSync(stamp2, sinceMs / 1000, sinceMs / 1000);
46008
46031
  const prune = RUNNER_CACHE_DIRS.flatMap((n3, i) => [...i ? ["-o"] : [], "-name", n3]);
@@ -46023,13 +46046,13 @@ async function zeroOnBase(cands, baseDir, repoDir, run2, note, gate = {}) {
46023
46046
  return envMoved.get(src);
46024
46047
  };
46025
46048
  for (const c of cands) {
46026
- const src = join141(repoDir, relative27(baseDir, c.cwd));
46049
+ const src = join142(repoDir, relative27(baseDir, c.cwd));
46027
46050
  if (depsSeeHead(src, repoDir) || gate.sinceMs !== undefined && moved(src))
46028
46051
  continue;
46029
46052
  for (const d of ["node_modules", ".venv"]) {
46030
46053
  try {
46031
- if (existsSync98(join141(src, d)) && !existsSync98(join141(c.cwd, d)))
46032
- symlinkSync4(join141(src, d), join141(c.cwd, d));
46054
+ if (existsSync98(join142(src, d)) && !existsSync98(join142(c.cwd, d)))
46055
+ symlinkSync4(join142(src, d), join142(c.cwd, d));
46033
46056
  } catch {}
46034
46057
  }
46035
46058
  if (isZeroRun(c, await run2(c))) {
@@ -46067,7 +46090,7 @@ function splitDeclaredAdvisories(notes, c) {
46067
46090
  }
46068
46091
  let wallText = null;
46069
46092
  const wall = () => wallText ??= c.wallPaths.map((w) => {
46070
- for (const f of [sealedWallCopy(c.runDir, w), join141(c.repoDir, w)])
46093
+ for (const f of [sealedWallCopy(c.runDir, w), join142(c.repoDir, w)])
46071
46094
  try {
46072
46095
  return readFileSync125(f, "utf8");
46073
46096
  } catch {}
@@ -46078,8 +46101,8 @@ function splitDeclaredAdvisories(notes, c) {
46078
46101
  const named = (f) => new RegExp(`${f.includes("/") ? `(?<![\\w./-])${esc6(f)}(?![\\w-])|` : ""}[/"'\`]${esc6(basename36(f))}(?=["'\`\\s);]|$)`).test(wall());
46079
46102
  const linkOk = (f) => {
46080
46103
  try {
46081
- const root = realpathSync33(c.repoDir), t = realpathSync33(join141(c.repoDir, f)), rel = relative27(root, t);
46082
- return !rel.startsWith("..") && !rel.split(sep22).includes(".git") && statSync39(t).isFile() && changed.has(rel.split(sep22).join("/")) && !isTestFile(rel) && !c.wallPaths.includes(rel);
46104
+ const root = realpathSync33(c.repoDir), t = realpathSync33(join142(c.repoDir, f)), rel = relative27(root, t);
46105
+ return !rel.startsWith("..") && !rel.split(sep22).includes(".git") && statSync40(t).isFile() && changed.has(rel.split(sep22).join("/")) && !isTestFile(rel) && !c.wallPaths.includes(rel);
46083
46106
  } catch {
46084
46107
  return false;
46085
46108
  }
@@ -46131,12 +46154,12 @@ function settleBranch(repoDir, branch, dir, stem2, pushed, extra = {}) {
46131
46154
  try {
46132
46155
  mkdirSync72(dir, { recursive: true });
46133
46156
  if (unique > 0) {
46134
- const file = join141(dir, `${stem2}.bundle`);
46157
+ const file = join142(dir, `${stem2}.bundle`);
46135
46158
  if (git13(repoDir, ["bundle", "create", file, `refs/heads/${branch}`, ...NOT_ELSEWHERE], 120000) === null || git13(repoDir, ["bundle", "verify", file], 120000) === null)
46136
46159
  throw new Error("bundle");
46137
46160
  bundle = relative27(repoDir, file);
46138
46161
  }
46139
- writeFileSync71(join141(dir, `${stem2}.json`), JSON.stringify({ ...extra, branch, head_sha: tip, pushed, bundle }, null, 2) + `
46162
+ writeFileSync71(join142(dir, `${stem2}.json`), JSON.stringify({ ...extra, branch, head_sha: tip, pushed, bundle }, null, 2) + `
46140
46163
  `);
46141
46164
  } catch {
46142
46165
  return { note: `engine10: kept ${branch}: its ${unique} unpushed commit(s) could not be saved under ${relative27(repoDir, dir)}
@@ -46170,11 +46193,11 @@ function workLine(repoDir, branch, orig) {
46170
46193
  function finishRunBranch(repoDir, runId2, end, env = process.env) {
46171
46194
  if (keepRunBranch(env) || !/^e10-[A-Za-z0-9-]+$/.test(runId2))
46172
46195
  return "";
46173
- const branch = `loki/${runId2}`, runDir = join141(repoDir, ".loki", "runs", runId2), tip = tipOf(repoDir, `refs/heads/${branch}`);
46196
+ const branch = `loki/${runId2}`, runDir = join142(repoDir, ".loki", "runs", runId2), tip = tipOf(repoDir, `refs/heads/${branch}`);
46174
46197
  try {
46175
46198
  if (end.deferred && tip) {
46176
46199
  mkdirSync72(runDir, { recursive: true });
46177
- writeFileSync71(join141(runDir, "branch.json"), JSON.stringify({ branch, head_sha: tip, pushed: end.pushed, bundle: null, orig_branch: end.orig, deferred: true }, null, 2) + `
46200
+ writeFileSync71(join142(runDir, "branch.json"), JSON.stringify({ branch, head_sha: tip, pushed: end.pushed, bundle: null, orig_branch: end.orig, deferred: true }, null, 2) + `
46178
46201
  `);
46179
46202
  return `engine10: the checkout stays on ${branch} while the background deep verify runs, then returns to ${end.orig ?? "the starting branch"}
46180
46203
  `;
@@ -46199,7 +46222,7 @@ function finishRunBranch(repoDir, runId2, end, env = process.env) {
46199
46222
  }
46200
46223
  }
46201
46224
  function finishDeferredRun(repoDir, runId2, env = process.env) {
46202
- const rec2 = readRecord(join141(repoDir, ".loki", "runs", runId2, "branch.json"));
46225
+ const rec2 = readRecord(join142(repoDir, ".loki", "runs", runId2, "branch.json"));
46203
46226
  if (!rec2?.deferred || rec2.branch !== `loki/${runId2}`)
46204
46227
  return "";
46205
46228
  const tip = tipOf(repoDir, `refs/heads/${rec2.branch}`);
@@ -46212,15 +46235,15 @@ function sweepRunBranches(repoDir, env = process.env, skipRunId) {
46212
46235
  `).filter((b) => E10_BRANCH_RE.test(b));
46213
46236
  if (names.length === 0)
46214
46237
  return "";
46215
- const busy2 = checkedOut(repoDir).branches, runs2 = join141(repoDir, ".loki", "runs"), resumable = findInterrupted(repoDir, undefined, true)?.runId;
46238
+ const busy2 = checkedOut(repoDir).branches, runs2 = join142(repoDir, ".loki", "runs"), resumable = findInterrupted(repoDir, undefined, true)?.runId;
46216
46239
  let removed = 0, saved = 0;
46217
46240
  const kept = [];
46218
46241
  for (const branch of names) {
46219
- const id = E10_BRANCH_RE.exec(branch)[1], runDir = join141(runs2, id), own = existsSync98(runDir);
46242
+ const id = E10_BRANCH_RE.exec(branch)[1], runDir = join142(runs2, id), own = existsSync98(runDir);
46220
46243
  if (id === skipRunId || id === resumable || busy2.has(branch) || own && runLive(runDir))
46221
46244
  continue;
46222
- const rec2 = own ? readRecord(join141(runDir, "branch.json")) : null, tip = tipOf(repoDir, `refs/heads/${branch}`);
46223
- const r = own ? settleBranch(repoDir, branch, runDir, "branch", rec2?.pushed === true && rec2.head_sha === tip) : settleBranch(repoDir, branch, join141(runs2, LEGACY_BRANCHES_DIR), id, false);
46245
+ const rec2 = own ? readRecord(join142(runDir, "branch.json")) : null, tip = tipOf(repoDir, `refs/heads/${branch}`);
46246
+ const r = own ? settleBranch(repoDir, branch, runDir, "branch", rec2?.pushed === true && rec2.head_sha === tip) : settleBranch(repoDir, branch, join142(runs2, LEGACY_BRANCHES_DIR), id, false);
46224
46247
  if (r.deleted) {
46225
46248
  removed++;
46226
46249
  if (r.note)
@@ -46241,7 +46264,7 @@ var exists2 = (repoDir, ref) => git13(repoDir, ["rev-parse", "--verify", "-q", `
46241
46264
  }
46242
46265
  }, keepRunBranch = (env = process.env) => env.LOKI_KEEP_RUN_BRANCH === "1", deepAlive = (runDir) => {
46243
46266
  try {
46244
- const pid = readFileSync125(join141(runDir, "events.jsonl"), "utf8").split(`
46267
+ const pid = readFileSync125(join142(runDir, "events.jsonl"), "utf8").split(`
46245
46268
  `).filter((l) => l.includes('"deep.started"')).map((l) => Number(JSON.parse(l).data?.pid)).pop();
46246
46269
  if (!pid || !Number.isInteger(pid) || pid <= 1)
46247
46270
  return false;
@@ -46298,9 +46321,9 @@ __export(exports_verify, {
46298
46321
  });
46299
46322
  import { existsSync as existsSync99, mkdtempSync as mkdtempSync20, readFileSync as readFileSync126, rmSync as rmSync38 } from "fs";
46300
46323
  import { tmpdir as tmpdir26 } from "os";
46301
- import { basename as basename37, isAbsolute as isAbsolute20, join as join142, relative as relative28 } from "path";
46324
+ import { basename as basename37, isAbsolute as isAbsolute20, join as join143, relative as relative28 } from "path";
46302
46325
  function writeWallFailureTail(runDir, failed2) {
46303
- const file = join142(runDir, WALL_FAILURE_TAIL_FILE);
46326
+ const file = join143(runDir, WALL_FAILURE_TAIL_FILE);
46304
46327
  try {
46305
46328
  if (failed2.length === 0) {
46306
46329
  rmSync38(file, { force: true });
@@ -46409,7 +46432,7 @@ async function subtractBase(ctx, api, checks, tests, changed, wall, rel, signal,
46409
46432
  const zc = zeroOk ? un.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)) : [];
46410
46433
  if (!(un.some(({ c }) => c.result === "fail" && c.ids?.length) || sus.length || zc.length) || signal.aborted)
46411
46434
  return out2;
46412
- const dir = mkdtempSync20(join142(tmpdir26(), "e10-base-"));
46435
+ const dir = mkdtempSync20(join143(tmpdir26(), "e10-base-"));
46413
46436
  const git14 = (args) => {
46414
46437
  safeGit(ctx.repoDir, args, { stdio: "ignore", repoDrivers: true });
46415
46438
  };
@@ -46448,15 +46471,15 @@ async function subtractBase(ctx, api, checks, tests, changed, wall, rel, signal,
46448
46471
  return out2;
46449
46472
  }
46450
46473
  function isLokiModeRepo(repoDir) {
46451
- return existsSync99(join142(repoDir, "scripts", "select-tests.sh"));
46474
+ return existsSync99(join143(repoDir, "scripts", "select-tests.sh"));
46452
46475
  }
46453
46476
  function projectDeclaresRuff(repoDir) {
46454
- if (["ruff.toml", ".ruff.toml"].some((f) => existsSync99(join142(repoDir, f))))
46477
+ if (["ruff.toml", ".ruff.toml"].some((f) => existsSync99(join143(repoDir, f))))
46455
46478
  return true;
46456
46479
  const files = ["pyproject.toml", "setup.cfg", "tox.ini", ".pre-commit-config.yaml", "Pipfile", "requirements.txt", "requirements-dev.txt", "dev-requirements.txt"];
46457
46480
  return files.some((f) => {
46458
46481
  try {
46459
- return /\bruff\b/i.test(readFileSync126(join142(repoDir, f), "utf8"));
46482
+ return /\bruff\b/i.test(readFileSync126(join143(repoDir, f), "utf8"));
46460
46483
  } catch {
46461
46484
  return false;
46462
46485
  }
@@ -46482,9 +46505,9 @@ async function runLintChecks(ctx, changed, signal, checks, opts = {}) {
46482
46505
  }
46483
46506
  for (const g2 of groupByPackage(api, ctx.repoDir, changed.filter((f) => /\.(ts|tsx|js|jsx)$/.test(f)))) {
46484
46507
  const sfx = g2.root === "." ? "" : `:${g2.root}`, co = g2.root === "." ? opts : { ...opts, cwd: g2.cwd };
46485
- if (existsSync99(join142(g2.cwd, "tsconfig.json")))
46508
+ if (existsSync99(join143(g2.cwd, "tsconfig.json")))
46486
46509
  await runCheck(ctx, `lint:tsc${sfx}`, "npx", ["--no-install", "tsc", "--noEmit", "-p", "."], signal, checks, { ...co, kind: "static" });
46487
- if (ESLINT_CONFIGS.some((f) => existsSync99(join142(g2.cwd, f)))) {
46510
+ if (ESLINT_CONFIGS.some((f) => existsSync99(join143(g2.cwd, f)))) {
46488
46511
  const c = await runCheck(ctx, `lint:eslint${sfx}`, "npx", ["--no-install", "eslint", ...g2.rel], signal, checks, { ...co, kind: "static" });
46489
46512
  if (await excuseLint(ctx, signal, c, "eslint", "npx", ["--no-install", "eslint"], g2.cwd, g2.rel, co))
46490
46513
  pre.push(c.name);
@@ -46499,7 +46522,7 @@ var CHECK_TIMEOUT_MS = 60000, excerpts, failTails, WALL_FAILURE_TAIL_FILE = "wal
46499
46522
  return r.missing || r.cut ? null : r;
46500
46523
  }, base: (f) => {
46501
46524
  try {
46502
- return safeGit(ctx.repoDir, ["show", `${ctx.baseSha}:${relative28(ctx.repoDir, join142(cwd, f))}`], { stdio: ["ignore", "pipe", "ignore"] });
46525
+ return safeGit(ctx.repoDir, ["show", `${ctx.baseSha}:${relative28(ctx.repoDir, join143(cwd, f))}`], { stdio: ["ignore", "pipe", "ignore"] });
46503
46526
  } catch {
46504
46527
  return null;
46505
46528
  }
@@ -46720,10 +46743,10 @@ ${x}` : c.cmd };
46720
46743
 
46721
46744
  // ../../loki-ts/src/runner/stop_checks.ts
46722
46745
  import { existsSync as existsSync100, readFileSync as readFileSync127 } from "fs";
46723
- import { basename as basename38, isAbsolute as isAbsolute21, join as join143, relative as relative29 } from "path";
46746
+ import { basename as basename38, isAbsolute as isAbsolute21, join as join144, relative as relative29 } from "path";
46724
46747
  function redOnBase(repoDir) {
46725
46748
  try {
46726
- const b = JSON.parse(readFileSync127(join143(repoDir, ".loki", "state", "repo-profile.json"), "utf8")).baseline;
46749
+ const b = JSON.parse(readFileSync127(join144(repoDir, ".loki", "state", "repo-profile.json"), "utf8")).baseline;
46727
46750
  return Array.isArray(b?.failing_ids) ? b.failing_ids.filter((x) => typeof x === "string") : [];
46728
46751
  } catch {
46729
46752
  return [];
@@ -46743,7 +46766,7 @@ function planStopChecks(repoDir, outputs, impacted, stageLimitS, baseSha, env =
46743
46766
  return runner && (runner !== "bun" || map.runners.includes("bun") || /[._](?:test|spec)\.[cm]?[jt]sx?$/.test(p)) ? [{ runner, path: p }] : [];
46744
46767
  });
46745
46768
  const red = redOnBase(repoDir), api = loadProjectApi(repoDir), seen = new Set;
46746
- const refs = [...wall.map((t) => [t, true]), ...map.tests.filter((t) => impacted.has(t.path)).map((t) => [t, false])].filter(([t]) => existsSync100(join143(repoDir, t.path)) && !seen.has(`${t.runner}:${t.path}`) && seen.add(`${t.runner}:${t.path}`) && !red.some((id) => id.includes(t.path)));
46769
+ const refs = [...wall.map((t) => [t, true]), ...map.tests.filter((t) => impacted.has(t.path)).map((t) => [t, false])].filter(([t]) => existsSync100(join144(repoDir, t.path)) && !seen.has(`${t.runner}:${t.path}`) && seen.add(`${t.runner}:${t.path}`) && !red.some((id) => id.includes(t.path)));
46747
46770
  const checks = refs.flatMap(([t, protect]) => {
46748
46771
  const c = commandFor(t, repoDir, api);
46749
46772
  return c.interpreter === "system" ? [] : [{ cwd: c.cwd, cmd: c.cmd, args: c.args, ...protect ? { protect } : {} }];
@@ -88328,7 +88351,7 @@ __export(exports_session, {
88328
88351
  });
88329
88352
  import { spawn as spawn14 } from "child_process";
88330
88353
  import { copyFileSync as copyFileSync10, existsSync as existsSync103, mkdirSync as mkdirSync76, readFileSync as readFileSync130, writeFileSync as writeFileSync73, writeSync as writeSync4 } from "fs";
88331
- import { dirname as dirname60, join as join146 } from "path";
88354
+ import { dirname as dirname60, join as join147 } from "path";
88332
88355
  function resolveModel(provider) {
88333
88356
  const e10 = process.env;
88334
88357
  if (e10.LOKI_MODEL_OVERRIDE)
@@ -88432,7 +88455,7 @@ function parseMarkers(stdout) {
88432
88455
  function recordCost(cfg, opts, status, durationS, outText = "") {
88433
88456
  if (!cfg.lokiRoot)
88434
88457
  return;
88435
- const ownRoot = join146(opts.cwd ?? process.cwd(), ".loki");
88458
+ const ownRoot = join147(opts.cwd ?? process.cwd(), ".loki");
88436
88459
  const own = resultCostPath(ownRoot, opts.iterationId), dest = resultCostPath(cfg.lokiRoot, opts.iterationId);
88437
88460
  if (own !== dest && existsSync103(own)) {
88438
88461
  mkdirSync76(dirname60(dest), { recursive: true });
@@ -88522,7 +88545,7 @@ function createSessionRunner(cfg) {
88522
88545
  cfg.emit?.("session.started", opts.stage, { session_id: sessionId, provider: cfg.provider, model: opts.model ?? cfg.model ?? null, pgid: pgid ?? null });
88523
88546
  const onAbort = () => kill("aborted");
88524
88547
  const limitTimer = setTimeout(() => kill("limit"), opts.limitS * 1000);
88525
- const capUsd = parseCapUsd(process.env["LOKI_E10_MAX_COST_USD"]), effDir = cfg.lokiRoot ? join146(cfg.lokiRoot, "metrics", "efficiency") : null, effBase = effDir !== null && capUsd !== null ? calculateCostFromRecords(readEfficiencyDir(effDir)) : 0;
88548
+ const capUsd = parseCapUsd(process.env["LOKI_E10_MAX_COST_USD"]), effDir = cfg.lokiRoot ? join147(cfg.lokiRoot, "metrics", "efficiency") : null, effBase = effDir !== null && capUsd !== null ? calculateCostFromRecords(readEfficiencyDir(effDir)) : 0;
88526
88549
  const stopBudgetWatch = isGuarded(cfg.provider) && capUsd !== null ? watchBudget(() => (cfg.remaining?.() ?? 1) <= 0 || effDir !== null && calculateCostFromRecords(readEfficiencyDir(effDir)) - effBase >= capUsd, () => {
88527
88550
  cfg.emit?.("guard.budget_stop", opts.stage, { provider: cfg.provider });
88528
88551
  kill("limit");
@@ -88549,7 +88572,7 @@ function createSessionRunner(cfg) {
88549
88572
  if (!guard.ok)
88550
88573
  cfg.emit?.("guard.violation", opts.stage, { provider: cfg.provider, violations: guard.violations, reverted: guard.reverted });
88551
88574
  opts.signal.removeEventListener("abort", onAbort);
88552
- const log = join146(opts.cwd ?? process.cwd(), ".loki", `iteration-${sessionId}.log`);
88575
+ const log = join147(opts.cwd ?? process.cwd(), ".loki", `iteration-${sessionId}.log`);
88553
88576
  const logText = existsSync103(log) ? readFileSync130(log, "utf8") : "";
88554
88577
  const markers = parseMarkers(stdout + logText);
88555
88578
  const durationS = (Date.now() - start) / 1000, authCause = code === 0 ? null : sdkAuthCause(logText);
@@ -88621,10 +88644,10 @@ var init_session = __esm(() => {
88621
88644
 
88622
88645
  // ../../loki-ts/src/runner/session_resume.ts
88623
88646
  import { existsSync as existsSync104, mkdirSync as mkdirSync77, readdirSync as readdirSync46, readFileSync as readFileSync131, renameSync as renameSync25, rmSync as rmSync40, writeFileSync as writeFileSync74 } from "fs";
88624
- import { basename as basename39, dirname as dirname61, join as join147 } from "path";
88647
+ import { basename as basename39, dirname as dirname61, join as join148 } from "path";
88625
88648
  function readFirstTurnTokens(repoDir, iterationId) {
88626
88649
  try {
88627
- const v = JSON.parse(readFileSync131(join147(repoDir, ".loki", "metrics", `result-cost-${iterationId}.json`), "utf8")).first_turn_prompt_tokens;
88650
+ const v = JSON.parse(readFileSync131(join148(repoDir, ".loki", "metrics", `result-cost-${iterationId}.json`), "utf8")).first_turn_prompt_tokens;
88628
88651
  return typeof v === "number" && Number.isFinite(v) ? v : null;
88629
88652
  } catch {
88630
88653
  return null;
@@ -88650,18 +88673,18 @@ function planChain(ctx, implementModel, planModel) {
88650
88673
  return { id: id2 };
88651
88674
  }
88652
88675
  function sessionFilePath(repoDir, iterationId) {
88653
- const loki = join147(repoDir, ".loki"), parts2 = iterationId.split("-");
88676
+ const loki = join148(repoDir, ".loki"), parts2 = iterationId.split("-");
88654
88677
  for (let n5 = parts2.length - 1;n5 >= 2; n5--) {
88655
88678
  const id2 = parts2.slice(0, n5).join("-");
88656
- if (/^e10-[A-Za-z0-9-]+$/.test(id2) && existsSync104(join147(loki, "runs", id2)))
88657
- return join147(loki, "runs", id2, `e10-session-${iterationId}.json`);
88679
+ if (/^e10-[A-Za-z0-9-]+$/.test(id2) && existsSync104(join148(loki, "runs", id2)))
88680
+ return join148(loki, "runs", id2, `e10-session-${iterationId}.json`);
88658
88681
  }
88659
- return join147(loki, "sessions", `e10-session-${iterationId}.json`);
88682
+ return join148(loki, "sessions", `e10-session-${iterationId}.json`);
88660
88683
  }
88661
88684
  function migrateSessionFiles(repoDir, isLive = () => false) {
88662
88685
  let moved = 0, names = [];
88663
88686
  try {
88664
- names = readdirSync46(join147(repoDir, ".loki")).filter((n5) => /^e10-session-.+\.json$/.test(n5));
88687
+ names = readdirSync46(join148(repoDir, ".loki")).filter((n5) => /^e10-session-.+\.json$/.test(n5));
88665
88688
  } catch {
88666
88689
  return 0;
88667
88690
  }
@@ -88787,7 +88810,7 @@ async function runFixSession(ctx, base, iterationId, priorIds, chain, actualMode
88787
88810
  }
88788
88811
  return { session, mode, ...why ? { why } : {}, ids, sessionId: readSessionId(ctx.repoDir, iterId), cacheRead: ctx.cost.read(ctx.repoDir, [iterId]).cacheReadTokens };
88789
88812
  }
88790
- var CHAIN_MAX_PROMPT_TOKENS = 1e5, chainEnabled = () => process.env["LOKI_E10_FIX_RESUME"] === "1", legacySessionPath = (repoDir, iterationId) => join147(repoDir, ".loki", `e10-session-${iterationId}.json`), INTERRUPTED_BRIEF = "The previous turn was interrupted before you finished. Check the working tree for the work already done, then continue the task and finish it.";
88813
+ var CHAIN_MAX_PROMPT_TOKENS = 1e5, chainEnabled = () => process.env["LOKI_E10_FIX_RESUME"] === "1", legacySessionPath = (repoDir, iterationId) => join148(repoDir, ".loki", `e10-session-${iterationId}.json`), INTERRUPTED_BRIEF = "The previous turn was interrupted before you finished. Check the working tree for the work already done, then continue the task and finish it.";
88791
88814
  var init_session_resume = __esm(() => {
88792
88815
  init_safe_git();
88793
88816
  init_session();
@@ -88798,7 +88821,7 @@ import { createHash as createHash39 } from "crypto";
88798
88821
  import { execFileSync as execFileSync10 } from "child_process";
88799
88822
  import { existsSync as existsSync105, mkdirSync as mkdirSync78, mkdtempSync as mkdtempSync21, readFileSync as readFileSync132, rmSync as rmSync41, symlinkSync as symlinkSync5, writeFileSync as writeFileSync75 } from "fs";
88800
88823
  import { tmpdir as tmpdir27 } from "os";
88801
- import { basename as basename40, dirname as dirname62, isAbsolute as isAbsolute24, join as join148, relative as relative31 } from "path";
88824
+ import { basename as basename40, dirname as dirname62, isAbsolute as isAbsolute24, join as join149, relative as relative31 } from "path";
88802
88825
  function answerMark(events2, assumeNext = false) {
88803
88826
  if (assumeNext)
88804
88827
  return events2.length;
@@ -88869,16 +88892,16 @@ function applyArbitrations(wall, events2) {
88869
88892
  wall.arbitrated = got;
88870
88893
  }
88871
88894
  function defaultBaseTree(ctx) {
88872
- const dir = mkdtempSync21(join148(tmpdir27(), "loki-e15-base-"));
88895
+ const dir = mkdtempSync21(join149(tmpdir27(), "loki-e15-base-"));
88873
88896
  try {
88874
88897
  const g10 = safeGitSpawn(ctx.repoDir, ["archive", ctx.baseSha], { maxBuffer: 512 * 1024 * 1024 });
88875
88898
  if (g10.status !== 0)
88876
88899
  throw new Error("git archive failed");
88877
88900
  execFileSync10("tar", ["-x", "-C", dir], { input: g10.stdout, stdio: ["pipe", "ignore", "ignore"], env: tokenFreeEnv() });
88878
88901
  for (const v of [".venv", "venv"]) {
88879
- const src = join148(ctx.repoDir, v);
88880
- if (existsSync105(src) && !existsSync105(join148(dir, v)))
88881
- symlinkSync5(src, join148(dir, v), "dir");
88902
+ const src = join149(ctx.repoDir, v);
88903
+ if (existsSync105(src) && !existsSync105(join149(dir, v)))
88904
+ symlinkSync5(src, join149(dir, v), "dir");
88882
88905
  }
88883
88906
  return dir;
88884
88907
  } catch {
@@ -88887,11 +88910,11 @@ function defaultBaseTree(ctx) {
88887
88910
  }
88888
88911
  }
88889
88912
  async function refereeSession(ctx, first, id2, task, files, ask, keep = []) {
88890
- const cwd = mkdtempSync21(join148(tmpdir27(), "loki-e15-ref-"));
88913
+ const cwd = mkdtempSync21(join149(tmpdir27(), "loki-e15-ref-"));
88891
88914
  try {
88892
- writeFileSync75(join148(cwd, "task.md"), task, "utf8");
88915
+ writeFileSync75(join149(cwd, "task.md"), task, "utf8");
88893
88916
  for (const [n5, c] of Object.entries(files))
88894
- writeFileSync75(join148(cwd, n5), c, "utf8");
88917
+ writeFileSync75(join149(cwd, n5), c, "utf8");
88895
88918
  const s = await ctx.sessions.run({ stage: "wall", tier: "development", model: refereeModel(ctx), iterationId: id2, limitS: 120, signal: first.signal, cwd, brief: [...taskBlock(task), ask, FINISH_LINE].join(`
88896
88919
 
88897
88920
  `) });
@@ -88899,10 +88922,10 @@ async function refereeSession(ctx, first, id2, task, files, ask, keep = []) {
88899
88922
  if (ok3)
88900
88923
  for (const n5 of keep) {
88901
88924
  try {
88902
- out3[n5] = readFileSync132(join148(cwd, n5), "utf8");
88925
+ out3[n5] = readFileSync132(join149(cwd, n5), "utf8");
88903
88926
  } catch {}
88904
88927
  }
88905
- return { verdict: ok3 ? readJson9(join148(cwd, "verdict.json")) : null, out: out3, ids: [id2], durationS: s.durationS };
88928
+ return { verdict: ok3 ? readJson9(join149(cwd, "verdict.json")) : null, out: out3, ids: [id2], durationS: s.durationS };
88906
88929
  } finally {
88907
88930
  rmSync41(cwd, { recursive: true, force: true });
88908
88931
  }
@@ -88959,8 +88982,8 @@ async function adjudicateWallConflict(ctx, first, firstSession, wall, deps = {})
88959
88982
  declined("no copy of the base tree could be made, so red-on-base was not run");
88960
88983
  return null;
88961
88984
  }
88962
- mkdirSync78(dirname62(join148(base, a.file)), { recursive: true });
88963
- writeFileSync75(join148(base, a.file), next, "utf8");
88985
+ mkdirSync78(dirname62(join149(base, a.file)), { recursive: true });
88986
+ writeFileSync75(join149(base, a.file), next, "utf8");
88964
88987
  const onBase = runCheck2(base, ref);
88965
88988
  if (onBase !== "fail") {
88966
88989
  restore();
@@ -88968,7 +88991,7 @@ async function adjudicateWallConflict(ctx, first, firstSession, wall, deps = {})
88968
88991
  return null;
88969
88992
  }
88970
88993
  f.content = next;
88971
- const sealedCopy = join148(sealedWallDir(ctx.runDir), name);
88994
+ const sealedCopy = join149(sealedWallDir(ctx.runDir), name);
88972
88995
  if (existsSync105(dirname62(sealedCopy)))
88973
88996
  writeFileSync75(sealedCopy, next, "utf8");
88974
88997
  sf2.sha256 = createHash39("sha256").update(next).digest("hex");
@@ -89011,9 +89034,9 @@ ${brief}`, ...sid ? { resumeSessionId: sid } : {} });
89011
89034
  }
89012
89035
  }
89013
89036
  async function legacyReauthor(ctx, first, firstSession, f, a, reason, task) {
89014
- const ids = [], o = ctx.outputs(), cwd = mkdtempSync21(join148(tmpdir27(), "loki-e15-wall-")), name = basename40(f.path);
89037
+ const ids = [], o = ctx.outputs(), cwd = mkdtempSync21(join149(tmpdir27(), "loki-e15-wall-")), name = basename40(f.path);
89015
89038
  try {
89016
- writeFileSync75(join148(cwd, name), f.content, "utf8");
89039
+ writeFileSync75(join149(cwd, name), f.content, "utf8");
89017
89040
  const id2 = `${first.iterationId}-wa`;
89018
89041
  ids.push(id2);
89019
89042
  const au2 = await ctx.sessions.run({
@@ -89033,7 +89056,7 @@ async function legacyReauthor(ctx, first, firstSession, f, a, reason, task) {
89033
89056
 
89034
89057
  `)
89035
89058
  });
89036
- const next = !au2.killed && au2.exit === 0 && existsSync105(join148(cwd, name)) ? readFileSync132(join148(cwd, name), "utf8") : "";
89059
+ const next = !au2.killed && au2.exit === 0 && existsSync105(join149(cwd, name)) ? readFileSync132(join149(cwd, name), "utf8") : "";
89037
89060
  if (next.trim() === "" || next === f.content)
89038
89061
  return null;
89039
89062
  f.content = next;
@@ -89085,7 +89108,7 @@ async function deliverOverWallConflict(o, repoDir, reverify, emit) {
89085
89108
  return null;
89086
89109
  const gone = (p) => files.includes(isAbsolute24(p) ? relative31(repoDir, p) : p);
89087
89110
  for (const f of files)
89088
- rmSync41(join148(repoDir, f), { force: true });
89111
+ rmSync41(join149(repoDir, f), { force: true });
89089
89112
  w.files = (w.files ?? []).filter((f) => !gone(f.path));
89090
89113
  w.readOnlyFiles = (w.readOnlyFiles ?? []).filter((f) => !gone(f.path));
89091
89114
  w.discarded = [...w.discarded ?? [], ...files.map((file) => ({ file, reason: WALL_CONFLICT_DISCARD }))];
@@ -89193,20 +89216,20 @@ __export(exports_run_outputs, {
89193
89216
  });
89194
89217
  import { execFile as execFile3, spawnSync as spawnSync24 } from "child_process";
89195
89218
  import { createHash as createHash40 } from "crypto";
89196
- import { existsSync as existsSync106, lstatSync as lstatSync32, mkdirSync as mkdirSync79, readdirSync as readdirSync47, readFileSync as readFileSync133, statSync as statSync41, writeFileSync as writeFileSync76 } from "fs";
89197
- import { basename as basename41, join as join149, resolve as resolve41 } from "path";
89219
+ import { existsSync as existsSync106, lstatSync as lstatSync32, mkdirSync as mkdirSync79, readdirSync as readdirSync47, readFileSync as readFileSync133, statSync as statSync42, writeFileSync as writeFileSync76 } from "fs";
89220
+ import { basename as basename41, join as join150, resolve as resolve41 } from "path";
89198
89221
  function intentRevisionsBlock(revs) {
89199
89222
  const r = (revs ?? []).filter((r10) => r10.unapplied !== true).map(({ rev, source, actor, sha: sha6 }) => ({ rev, source, actor, sha: sha6 }));
89200
89223
  return r.length ? { intent_revisions: r } : {};
89201
89224
  }
89202
89225
  function seededCorpusBlock(env = process.env) {
89203
- const dir = env["LOKI_SEEDED_DEFECTS_DIR"] || join149(REPO_ROOT, "benchmarks", "seeded-defects");
89226
+ const dir = env["LOKI_SEEDED_DEFECTS_DIR"] || join150(REPO_ROOT, "benchmarks", "seeded-defects");
89204
89227
  try {
89205
- const bytes = readFileSync133(join149(dir, "manifest.json")), version2 = createHash40("sha256").update(bytes).digest("hex");
89228
+ const bytes = readFileSync133(join150(dir, "manifest.json")), version2 = createHash40("sha256").update(bytes).digest("hex");
89206
89229
  const ids = (JSON.parse(bytes.toString("utf8")).defects ?? []).map((d) => d.id);
89207
89230
  let rate = null;
89208
89231
  try {
89209
- const res = JSON.parse(readFileSync133(join149(dir, "results", "wrong-pass.json"), "utf8"));
89232
+ const res = JSON.parse(readFileSync133(join150(dir, "results", "wrong-pass.json"), "utf8"));
89210
89233
  const runs2 = res.manifest_sha256 === version2 && Array.isArray(res.runs) ? res.runs : [];
89211
89234
  const complete = (o) => !!o && Object.keys(o).length === ids.length && ids.every((id2) => typeof id2 === "string" && (o[id2] === "SEALED" || o[id2] === "NOT_SEALED"));
89212
89235
  const top = runs2.filter((r) => r.setup === "top"), floor = runs2.filter((r) => r.setup === "floor");
@@ -89222,8 +89245,8 @@ function seededCorpusBlock(env = process.env) {
89222
89245
  }
89223
89246
  function sealAccuracyLine(changed, checks, model, env = process.env, nowMs = Date.now()) {
89224
89247
  try {
89225
- const dir = env["LOKI_SEEDED_DEFECTS_DIR"] || join149(REPO_ROOT, "benchmarks", "seeded-defects"), file = join149(dir, "results", "wrong-pass.json");
89226
- const corpus = createHash40("sha256").update(readFileSync133(join149(dir, "manifest.json"))).digest("hex");
89248
+ const dir = env["LOKI_SEEDED_DEFECTS_DIR"] || join150(REPO_ROOT, "benchmarks", "seeded-defects"), file = join150(dir, "results", "wrong-pass.json");
89249
+ const corpus = createHash40("sha256").update(readFileSync133(join150(dir, "manifest.json"))).digest("hex");
89227
89250
  const res = JSON.parse(readFileSync133(file, "utf8"));
89228
89251
  if (res.manifest_sha256 !== corpus || !Array.isArray(res.runs))
89229
89252
  return SEAL_ACCURACY_NOT_MEASURED;
@@ -89270,7 +89293,7 @@ function loadRunOutputs(runDir, events2) {
89270
89293
  out3["verify"] = { ...verify5, changed_files: verify5["changed_files"].filter((f) => !reverted.has(String(f))) };
89271
89294
  const intake = { ...out3["intake"] ?? {} };
89272
89295
  if (typeof intake["task"] !== "string" || !intake["task"].trim()) {
89273
- const raw2 = readText2(join149(runDir, "issue.json"));
89296
+ const raw2 = readText2(join150(runDir, "issue.json"));
89274
89297
  if (raw2) {
89275
89298
  try {
89276
89299
  const j10 = JSON.parse(raw2);
@@ -89290,7 +89313,7 @@ function loadRunOutputs(runDir, events2) {
89290
89313
  out3["intake"] = intake;
89291
89314
  const plan = { ...out3["plan"] ?? {} };
89292
89315
  if (typeof plan["plan"] !== "string" || !plan["plan"].trim()) {
89293
- const txt = readText2(join149(runDir, "plan-output.txt"));
89316
+ const txt = readText2(join150(runDir, "plan-output.txt"));
89294
89317
  if (txt && txt.trim())
89295
89318
  plan["plan"] = txt.trim();
89296
89319
  }
@@ -89368,30 +89391,30 @@ function findInterrupted(repoDir, runId2, includeCancelled = false, why) {
89368
89391
  why.reason = reason;
89369
89392
  return null;
89370
89393
  };
89371
- const root = join149(repoDir, ".loki", "runs");
89394
+ const root = join150(repoDir, ".loki", "runs");
89372
89395
  let ids = [];
89373
89396
  try {
89374
89397
  ids = runId2 ? [runId2] : readdirSync47(root);
89375
89398
  } catch {
89376
89399
  return null;
89377
89400
  }
89378
- const rows = ids.filter((id2) => /^e10-[A-Za-z0-9-]+$/.test(id2) && existsSync106(join149(repoDir, eventsRelPath(id2)))).map((id2) => ({ id: id2, m: statSync41(join149(repoDir, eventsRelPath(id2))).mtimeMs })).sort((a, b) => b.m - a.m);
89401
+ const rows = ids.filter((id2) => /^e10-[A-Za-z0-9-]+$/.test(id2) && existsSync106(join150(repoDir, eventsRelPath(id2)))).map((id2) => ({ id: id2, m: statSync42(join150(repoDir, eventsRelPath(id2))).mtimeMs })).sort((a, b) => b.m - a.m);
89379
89402
  const top = rows[0];
89380
89403
  if (!top)
89381
89404
  return null;
89382
- const events2 = readEvents(join149(repoDir, eventsRelPath(top.id)));
89405
+ const events2 = readEvents(join150(repoDir, eventsRelPath(top.id)));
89383
89406
  const doneAt = events2.findLastIndex((e10) => e10.type === "run.completed"), tail2 = events2.slice(doneAt + 1 + (events2[doneAt + 1]?.type === "log.sealed" ? 1 : 0));
89384
89407
  const cancelDone = doneAt >= 0 && isCancelDone(events2[doneAt]), cancelled2 = cancelDone && tail2.length === 0;
89385
89408
  if (cancelled2 && !includeCancelled)
89386
89409
  return null;
89387
89410
  const phase = phaseOf(events2.filter((e10) => !isCancelDone(e10)));
89388
- if (phase === "done" || isDiscarded(root, top.id) || runOwnerAlive(join149(root, top.id)) || events2.length === 0)
89411
+ if (phase === "done" || isDiscarded(root, top.id) || runOwnerAlive(join150(root, top.id)) || events2.length === 0)
89389
89412
  return null;
89390
89413
  const foreign = events2.find((e10) => e10.run !== top.id);
89391
89414
  if (foreign)
89392
89415
  return no(`run ${top.id} holds an event from run ${String(foreign.run)}; its log is not its own`);
89393
89416
  try {
89394
- const raw2 = readFileSync133(join149(repoDir, eventsRelPath(top.id)), "utf8"), torn = raw2.split(`
89417
+ const raw2 = readFileSync133(join150(repoDir, eventsRelPath(top.id)), "utf8"), torn = raw2.split(`
89395
89418
  `).filter((l) => l.trim() !== "").length !== events2.length;
89396
89419
  if (torn && phase === "publish")
89397
89420
  return no(`run ${top.id} has a torn or unparsable event log`);
@@ -89516,8 +89539,8 @@ function resumeMachineOpts(ctx, events2, raw2, flow) {
89516
89539
  function findBlocked(repoDir, runId2) {
89517
89540
  if (!runId2)
89518
89541
  return null;
89519
- const p = join149(repoDir, eventsRelPath(runId2));
89520
- if (!existsSync106(p) || runOwnerAlive(join149(repoDir, ".loki", "runs", runId2)))
89542
+ const p = join150(repoDir, eventsRelPath(runId2));
89543
+ if (!existsSync106(p) || runOwnerAlive(join150(repoDir, ".loki", "runs", runId2)))
89521
89544
  return null;
89522
89545
  const events2 = readEvents(p);
89523
89546
  return events2.length ? { runId: runId2, phase: "implement", events: events2, task: taskOf(events2) } : null;
@@ -89544,7 +89567,7 @@ async function resumeFlag(runId2, noPr = false, deps = {}, answer) {
89544
89567
  }
89545
89568
  let raw2 = "";
89546
89569
  try {
89547
- raw2 = readFileSync133(join149(repoDir, eventsRelPath(it2.runId)), "utf8");
89570
+ raw2 = readFileSync133(join150(repoDir, eventsRelPath(it2.runId)), "utf8");
89548
89571
  } catch {
89549
89572
  return cannotResume(out3, it2.runId, "its event log is unreadable");
89550
89573
  }
@@ -89586,7 +89609,7 @@ async function resumeFlag(runId2, noPr = false, deps = {}, answer) {
89586
89609
  }
89587
89610
  out3(`engine10: resume from stage ${rp2.stage} (settled: ${rp2.skip.join(", ") || "none"})
89588
89611
  `);
89589
- const br2 = `loki/${it2.runId}`, origBranch = currentBranch(repoDir), pc2 = partialCost(it2.events, false, join149(repoDir, ".loki")), st0 = it2.events.find((e10) => e10.type === "run.started")?.data ?? {};
89612
+ const br2 = `loki/${it2.runId}`, origBranch = currentBranch(repoDir), pc2 = partialCost(it2.events, false, join150(repoDir, ".loki")), st0 = it2.events.find((e10) => e10.type === "run.started")?.data ?? {};
89590
89613
  if (it2.events.some((e10) => e10.type === "cap.hit")) {
89591
89614
  out3(`engine10: --resume refused: run ${it2.runId} already hit its cost or time cap
89592
89615
  `);
@@ -89641,7 +89664,7 @@ async function resumeFlag(runId2, noPr = false, deps = {}, answer) {
89641
89664
  }
89642
89665
  const st2 = it2.events.find((e10) => e10.type === "run.started")?.data ?? {}, provider = String(st2["provider"] ?? "claude"), model = String(st2["model"] ?? ""), deep = st2["deep"] === true;
89643
89666
  const env = { ...process.env, ...capS !== undefined ? { LOKI_E10_CAP_S: String(Math.floor(capS)) } : {}, ...pc2.usd > 0 ? { LOKI_E10_SPENT_USD: String(pc2.usd) } : {}, ...Number(st2["max_cost_usd"]) >= 0 && st2["max_cost_usd"] !== undefined ? { LOKI_E10_MAX_COST_USD: String(st2["max_cost_usd"]) } : {} };
89644
- const runDir = join149(repoDir, ".loki", "runs", it2.runId), eventsPath2 = join149(repoDir, eventsRelPath(it2.runId));
89667
+ const runDir = join150(repoDir, ".loki", "runs", it2.runId), eventsPath2 = join150(repoDir, eventsRelPath(it2.runId));
89645
89668
  const pr2 = noPr ? undefined : async ({ pushEnv: pushEnv2, verdict, notProven }) => {
89646
89669
  const gate = prGate(repoDir);
89647
89670
  if ("deny" in gate)
@@ -89668,8 +89691,8 @@ async function signedReceiptFacts(runDir, runId2, events2) {
89668
89691
  const foreign = events2.find((e10) => e10.run !== runId2);
89669
89692
  if (foreign)
89670
89693
  return { problem: `event log holds an event from run ${String(foreign.run)}, not ${runId2}` };
89671
- const file = join149(runDir, "receipt.json"), { checkAttestation, computeReceiptHash, checkEventLog } = await Promise.resolve().then(() => (init_verify_cmd(), exports_verify_cmd)), { loadSigningKey: loadSigningKey2 } = await Promise.resolve().then(() => (init_receipt_signer(), exports_receipt_signer));
89672
- for (const f of [file, join149(runDir, "events.jsonl")]) {
89694
+ const file = join150(runDir, "receipt.json"), { checkAttestation, computeReceiptHash, checkEventLog } = await Promise.resolve().then(() => (init_verify_cmd(), exports_verify_cmd)), { loadSigningKey: loadSigningKey2 } = await Promise.resolve().then(() => (init_receipt_signer(), exports_receipt_signer));
89695
+ for (const f of [file, join150(runDir, "events.jsonl")]) {
89673
89696
  try {
89674
89697
  if (lstatSync32(f).isSymbolicLink())
89675
89698
  return { problem: `${basename41(f)} is a symlink; a run's own files are never links` };
@@ -89726,7 +89749,7 @@ async function resumePublish(repoDir, it2, deps = {}) {
89726
89749
  const out3 = deps.out ?? ((s) => {
89727
89750
  process.stdout.write(s);
89728
89751
  });
89729
- const runDir = join149(repoDir, ".loki", "runs", it2.runId);
89752
+ const runDir = join150(repoDir, ".loki", "runs", it2.runId);
89730
89753
  const facts = await signedReceiptFacts(runDir, it2.runId, it2.events);
89731
89754
  if ("problem" in facts) {
89732
89755
  out3(`resume: refused: ${plainLine(facts.problem, 400)}
@@ -89755,7 +89778,7 @@ async function resumePublish(repoDir, it2, deps = {}) {
89755
89778
  `);
89756
89779
  return 5;
89757
89780
  }
89758
- const log = new SupervisorLog2(join149(repoDir, eventsRelPath(it2.runId)), it2.runId);
89781
+ const log = new SupervisorLog2(join150(repoDir, eventsRelPath(it2.runId)), it2.runId);
89759
89782
  log.append("run.resumed", null, { phase: "publish", receipt_reused: true, receipt_sha256: sealedData["receipt_sha256"] ?? null });
89760
89783
  const notProven = [...Array.isArray(sealedData["not_proven"]) ? sealedData["not_proven"] : [], "publish phase resumed after an interruption", ..."note" in gate && gate.note ? [gate.note] : []];
89761
89784
  const runPr2 = deps.runPr ?? (async (c, s) => (await Promise.resolve().then(() => (init_pr(), exports_pr))).runPr(c, s));
@@ -89821,7 +89844,7 @@ function stagesResumable(repoDir, runId2, events2) {
89821
89844
  if (!branchExists2(repoDir, runId2) || cancelTailProblem(events2))
89822
89845
  return false;
89823
89846
  try {
89824
- const tl2 = trustedLog(events2, readFileSync133(join149(repoDir, eventsRelPath(runId2)), "utf8")), rp2 = resumePoint(tl2.events, tl2.raw);
89847
+ const tl2 = trustedLog(events2, readFileSync133(join150(repoDir, eventsRelPath(runId2)), "utf8")), rp2 = resumePoint(tl2.events, tl2.raw);
89825
89848
  if (!rp2.ok || rp2.skip.length === 0)
89826
89849
  return false;
89827
89850
  const base = tl2.events.findLast((e10) => e10.type === "stage.completed" && e10.stage === "intake")?.data["base_sha"];
@@ -89837,7 +89860,7 @@ function statusNextStep(repoDir, runsDir, runId2, events2) {
89837
89860
  if (events2.some((e10) => e10.type === "run.completed") && !cancelled2)
89838
89861
  return null;
89839
89862
  const phase = phaseOf(events2.filter((e10) => !isCancelDone(e10)));
89840
- if (phase === "done" || events2.length === 0 || isDiscarded(runsDir, runId2) || runOwnerAlive(join149(runsDir, runId2)))
89863
+ if (phase === "done" || events2.length === 0 || isDiscarded(runsDir, runId2) || runOwnerAlive(join150(runsDir, runId2)))
89841
89864
  return null;
89842
89865
  const hasBranch = branchExists2(repoDir, runId2);
89843
89866
  return nextStepText(runId2, phase, phase === "publish" ? hasBranch && taskOf(events2) !== null : stagesResumable(repoDir, runId2, events2), hasBranch);
@@ -89845,11 +89868,11 @@ function statusNextStep(repoDir, runsDir, runId2, events2) {
89845
89868
  function discardRun(repoDir, runId2) {
89846
89869
  if (!/^e10-[A-Za-z0-9-]+$/.test(runId2))
89847
89870
  return false;
89848
- const dir = join149(repoDir, ".loki", "runs", runId2);
89871
+ const dir = join150(repoDir, ".loki", "runs", runId2);
89849
89872
  try {
89850
89873
  if (!lstatSync32(dir).isDirectory())
89851
89874
  return false;
89852
- writeFileSync76(join149(dir, DISCARD_MARK), `${new Date().toISOString()}
89875
+ writeFileSync76(join150(dir, DISCARD_MARK), `${new Date().toISOString()}
89853
89876
  `, { flag: "wx" });
89854
89877
  return true;
89855
89878
  } catch {
@@ -89871,7 +89894,7 @@ async function startRecovery(repoDir, task, noPr, deps = {}) {
89871
89894
  });
89872
89895
  const hasBranch = branchExists2(repoDir, it2.runId), t = task.trim();
89873
89896
  const sameTask = it2.task !== null && (t === "" || it2.task === t), publish = it2.phase === "publish";
89874
- const resumable = sameTask && (publish ? !noPr && hasBranch && readOriginUrl(repoDir) !== null && !("deny" in prGate(repoDir)) && publishStateOk(join149(repoDir, ".loki", "runs", it2.runId), it2) : stagesResumable(repoDir, it2.runId, it2.events));
89897
+ const resumable = sameTask && (publish ? !noPr && hasBranch && readOriginUrl(repoDir) !== null && !("deny" in prGate(repoDir)) && publishStateOk(join150(repoDir, ".loki", "runs", it2.runId), it2) : stagesResumable(repoDir, it2.runId, it2.events));
89875
89898
  const kept = hasBranch ? `old work is kept on loki/${it2.runId}` : "no run branch was created", was = it2.cancelled ? "cancelled" : "interrupted";
89876
89899
  const interactive = (deps.tty ?? (process.stdin.isTTY === true && process.stderr.isTTY === true)) && process.env["LOKI_NONINTERACTIVE"] !== "1";
89877
89900
  let began = false;
@@ -89967,11 +89990,11 @@ function unmergedLokiWorkNote(events2) {
89967
89990
  return noteOf(events2.find((e10) => e10.type === "stage.completed" && e10.stage === "intake")?.data);
89968
89991
  }
89969
89992
  function policyFile(repoDir, env = process.env) {
89970
- const dataDir = env.LOKI_DATA_DIR || join149(env.HOME ?? "", ".loki");
89971
- for (const d of [join149(repoDir, ".loki"), dataDir])
89993
+ const dataDir = env.LOKI_DATA_DIR || join150(env.HOME ?? "", ".loki");
89994
+ for (const d of [join150(repoDir, ".loki"), dataDir])
89972
89995
  for (const f of ["policies.json", "policies.yaml"])
89973
- if (existsSync106(join149(d, f)))
89974
- return join149(d, f);
89996
+ if (existsSync106(join150(d, f)))
89997
+ return join150(d, f);
89975
89998
  return null;
89976
89999
  }
89977
90000
  function runIntent(repoDir, env = process.env) {
@@ -90022,7 +90045,7 @@ function issueStatusProjector(o) {
90022
90045
  const once = async (x10) => {
90023
90046
  const events2 = readEvents(o.eventsPath), since = Date.parse(events2[0]?.ts ?? "") || 0;
90024
90047
  const revs = readIntentRevisions(o.repoDir, since).length;
90025
- const body = issueStatusBody(events2, { runId: o.runId, steerRevs: revs, controlUrl: controlRunLink(o.env.LOKI_CONTROL_PLANE_URL || o.env.LOKI_CONTROL_URL, o.repoDir, o.runId), ...x10 }), bodyFile = join149(o.runDir, "status-comment.md"), argv = argvOf(bodyFile);
90048
+ const body = issueStatusBody(events2, { runId: o.runId, steerRevs: revs, controlUrl: controlRunLink(o.env.LOKI_CONTROL_PLANE_URL || o.env.LOKI_CONTROL_URL, o.repoDir, o.runId), ...x10 }), bodyFile = join150(o.runDir, "status-comment.md"), argv = argvOf(bodyFile);
90026
90049
  if (body === last)
90027
90050
  return { argv, ok: true };
90028
90051
  mkdirSync79(o.runDir, { recursive: true });
@@ -90079,9 +90102,9 @@ Stacked on \`${base}\`: review and merge that pull request first.
90079
90102
  ` : "");
90080
90103
  }
90081
90104
  function tierSealFor(repoDir, runId2) {
90082
- const root = join149(repoDir, ".loki", "runs"), shape = shapeKeyForRun(repoDir, join149(root, basename41(runId2))), receipts = [], read3 = (d) => {
90105
+ const root = join150(repoDir, ".loki", "runs"), shape = shapeKeyForRun(repoDir, join150(root, basename41(runId2))), receipts = [], read3 = (d) => {
90083
90106
  try {
90084
- const r = JSON.parse(readFileSync133(join149(root, d, "receipt.json"), "utf8"));
90107
+ const r = JSON.parse(readFileSync133(join150(root, d, "receipt.json"), "utf8"));
90085
90108
  return typeof r === "object" && r !== null ? r : null;
90086
90109
  } catch {
90087
90110
  return null;
@@ -90092,7 +90115,7 @@ function tierSealFor(repoDir, runId2) {
90092
90115
  dirs = readdirSync47(root).sort().slice(-200);
90093
90116
  } catch {}
90094
90117
  for (const d of dirs) {
90095
- const own = shapeKeyForRun(repoDir, join149(root, d), true), receipt = own === null ? null : read3(d);
90118
+ const own = shapeKeyForRun(repoDir, join150(root, d), true), receipt = own === null ? null : read3(d);
90096
90119
  if (receipt && own !== null)
90097
90120
  receipts.push({ shape: own, receipt });
90098
90121
  }
@@ -90136,9 +90159,9 @@ async function sealRefusal(o) {
90136
90159
  const clean6 = (s) => s.replace(/[\x00-\x1f\x7f]+/g, " ").trim().slice(0, 500);
90137
90160
  const [{ SupervisorLog: SupervisorLog2 }, seal, signer, { atomicWriteText: atomicWriteText2 }, { githubRepoFromUrl: githubRepoFromUrl2 }] = await Promise.all([Promise.resolve().then(() => (init_supervisor(), exports_supervisor)), Promise.resolve().then(() => (init_seal(), exports_seal)), Promise.resolve().then(() => (init_receipt_signer(), exports_receipt_signer)), Promise.resolve().then(() => (init_atomic(), exports_atomic)), Promise.resolve().then(() => (init_engine_origin(), exports_engine_origin))]);
90138
90161
  const runId2 = `e10-${new Date().toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z")}-${Math.random().toString(16).slice(2, 6)}`;
90139
- const runDir = join149(o.repoDir, ".loki", "runs", runId2), provider = o.provider ?? "claude", repo = githubRepoFromUrl2(readOriginUrl(o.repoDir));
90162
+ const runDir = join150(o.repoDir, ".loki", "runs", runId2), provider = o.provider ?? "claude", repo = githubRepoFromUrl2(readOriginUrl(o.repoDir));
90140
90163
  mkdirSync79(runDir, { recursive: true });
90141
- const log = new SupervisorLog2(join149(o.repoDir, eventsRelPath(runId2)), runId2);
90164
+ const log = new SupervisorLog2(join150(o.repoDir, eventsRelPath(runId2)), runId2);
90142
90165
  log.append("run.started", null, { task_source: "text", provider, refused: true, origin_repo: repo });
90143
90166
  const git14 = (a) => {
90144
90167
  try {
@@ -90179,10 +90202,10 @@ async function sealRefusal(o) {
90179
90202
  hash = seal.receiptSha256(body);
90180
90203
  }
90181
90204
  const receipt = { ...body, receipt_sha256: hash, verification: { jwt: sig.jwt, kid: sig.kid } };
90182
- const receiptPath = join149(runDir, "receipt.json");
90205
+ const receiptPath = join150(runDir, "receipt.json");
90183
90206
  atomicWriteText2(receiptPath, JSON.stringify(receipt, null, 2) + `
90184
90207
  `);
90185
- atomicWriteText2(join149(runDir, "receipt.md"), seal.renderReceiptMd(receipt));
90208
+ atomicWriteText2(join150(runDir, "receipt.md"), seal.renderReceiptMd(receipt));
90186
90209
  log.append("receipt.sealed", "seal", { path: receiptPath, receipt_sha256: hash, signed: sig.jwt !== null, kid: sig.kid, verdict: "FAILED", not_proven: receipt.not_proven });
90187
90210
  log.append("run.completed", null, { verdict: "FAILED", pr_url: null, not_proven: receipt.not_proven, cost_usd: null, wall_s: 0 });
90188
90211
  log.sealLog();
@@ -90200,7 +90223,7 @@ var SEAL_ACCURACY_NOT_MEASURED = "Seal accuracy: not measured", SEAL_ACCURACY_MA
90200
90223
  } catch {
90201
90224
  return SEAL_ACCURACY_NOT_MEASURED;
90202
90225
  }
90203
- }, REVERTED = "unrelated edit reverted:", STALE_S2, isCancelDone = (e10) => e10.type === "run.completed" && e10.data["cancelled"] === true, isResumableDone = (e10) => isCancelDone(e10) || e10.type === "run.completed" && e10.data["verdict"] === "SPEC_CONFLICT", DISCARD_MARK = "discarded", isDiscarded = (runsDir, runId2) => existsSync106(join149(runsDir, runId2, DISCARD_MARK)), STAGE_ORDER, sha6 = (v) => createHash40("sha256").update(JSON.stringify(v) ?? "null").digest("hex"), settled = (events2, s) => events2.some((e10) => e10.stage === s && (e10.type === "stage.completed" || e10.type === "stage.skipped")), cannotResume = (out3, id2, reason) => {
90226
+ }, REVERTED = "unrelated edit reverted:", STALE_S2, isCancelDone = (e10) => e10.type === "run.completed" && e10.data["cancelled"] === true, isResumableDone = (e10) => isCancelDone(e10) || e10.type === "run.completed" && e10.data["verdict"] === "SPEC_CONFLICT", DISCARD_MARK = "discarded", isDiscarded = (runsDir, runId2) => existsSync106(join150(runsDir, runId2, DISCARD_MARK)), STAGE_ORDER, sha6 = (v) => createHash40("sha256").update(JSON.stringify(v) ?? "null").digest("hex"), settled = (events2, s) => events2.some((e10) => e10.stage === s && (e10.type === "stage.completed" || e10.type === "stage.skipped")), cannotResume = (out3, id2, reason) => {
90204
90227
  out3(`resume: run ${plainLine(id2, 80)} cannot be resumed (${plainLine(reason, 400)}); its work is on branch loki/${plainLine(id2, 80)}. Start a new run: loki start <task>
90205
90228
  `);
90206
90229
  return 4;
@@ -90252,13 +90275,13 @@ var init_run_outputs = __esm(() => {
90252
90275
 
90253
90276
  // ../../loki-ts/src/util/composite_seal.ts
90254
90277
  import { existsSync as existsSync107, readFileSync as readFileSync134 } from "fs";
90255
- import { basename as basename42, dirname as dirname63, join as join150 } from "path";
90278
+ import { basename as basename42, dirname as dirname63, join as join151 } from "path";
90256
90279
  function logProblem(runDir, integ) {
90257
90280
  if (typeof integ["log_sha256"] !== "string")
90258
90281
  return null;
90259
90282
  let b;
90260
90283
  try {
90261
- b = readFileSync134(join150(runDir, "integration.log"));
90284
+ b = readFileSync134(join151(runDir, "integration.log"));
90262
90285
  } catch {
90263
90286
  return "integration.log is missing but integration.json records its hash";
90264
90287
  }
@@ -90273,7 +90296,7 @@ function integrationProblem(integ) {
90273
90296
  return null;
90274
90297
  }
90275
90298
  function composeComposite(runDir, rh, toolchain = collectToolchain()) {
90276
- const ip = join150(runDir, "integration.json");
90299
+ const ip = join151(runDir, "integration.json");
90277
90300
  let ibytes;
90278
90301
  try {
90279
90302
  ibytes = readFileSync134(ip);
@@ -90300,12 +90323,12 @@ function composeComposite(runDir, rh, toolchain = collectToolchain()) {
90300
90323
  const outcome = String(integ["outcomes"][repo] ?? "");
90301
90324
  if (outcome !== "ok")
90302
90325
  throw new Error(`repo ${text3(repo, 80)} did not finish (${text3(outcome, 80) || "no outcome"}); no composite`);
90303
- const runsDir = join150(runDir, "worktrees", slugOf(repo), ".loki", "runs");
90304
- const ids = (dirNames(runsDir) ?? []).filter((n5) => existsSync107(join150(runsDir, n5, "receipt.json")));
90326
+ const runsDir = join151(runDir, "worktrees", slugOf(repo), ".loki", "runs");
90327
+ const ids = (dirNames(runsDir) ?? []).filter((n5) => existsSync107(join151(runsDir, n5, "receipt.json")));
90305
90328
  const id2 = ids[ids.length - 1];
90306
90329
  if (!id2)
90307
90330
  throw new Error(`repo ${text3(repo, 80)} has no receipt.json under worktrees/${slugOf(repo)}/.loki/runs`);
90308
- const rp2 = join150(runsDir, id2, "receipt.json"), bytes = readFileSync134(rp2), r = readJson6(rp2);
90331
+ const rp2 = join151(runsDir, id2, "receipt.json"), bytes = readFileSync134(rp2), r = readJson6(rp2);
90309
90332
  if (jsonTooDeep(r))
90310
90333
  throw new Error(`repo ${text3(repo, 80)} receipt cannot be hashed (nested too deeply); no composite`);
90311
90334
  if (!isObj10(r) || typeof r["receipt_sha256"] !== "string" || rh(r) !== r["receipt_sha256"])
@@ -90342,13 +90365,13 @@ async function verifyComposite(receiptPath, receipt, rh, verifyOne, deps = {}) {
90342
90365
  return bad("body malformed");
90343
90366
  let ibytes;
90344
90367
  try {
90345
- ibytes = readFileSync134(join150(runDir, "integration.json"));
90368
+ ibytes = readFileSync134(join151(runDir, "integration.json"));
90346
90369
  } catch {
90347
90370
  return bad("integration.json missing");
90348
90371
  }
90349
90372
  if (sha3(ibytes) !== receipt["integration_sha256"])
90350
90373
  return bad("integration.json does not match its recorded hash");
90351
- const integ = readJson6(join150(runDir, "integration.json"));
90374
+ const integ = readJson6(join151(runDir, "integration.json"));
90352
90375
  if (jsonTooDeep(integ))
90353
90376
  return deep("integration.json");
90354
90377
  if (!isObj10(integ) || !isObj10(integ["outcomes"]))
@@ -90385,7 +90408,7 @@ async function verifyComposite(receiptPath, receipt, rh, verifyOne, deps = {}) {
90385
90408
  return bad(`child ${text3(repo, 80) || "?"} has an invalid receipt path`);
90386
90409
  if (outcomes[repo] !== "ok")
90387
90410
  return bad(`child ${text3(repo, 80)} did not finish ok in integration.json`);
90388
- const rp2 = join150(runDir, rel);
90411
+ const rp2 = join151(runDir, rel);
90389
90412
  let bytes;
90390
90413
  try {
90391
90414
  bytes = readFileSync134(rp2);
@@ -90450,8 +90473,8 @@ __export(exports_verify_cmd, {
90450
90473
  checkEventLog: () => checkEventLog,
90451
90474
  checkAttestation: () => checkAttestation
90452
90475
  });
90453
- import { existsSync as existsSync108, readFileSync as readFileSync135, renameSync as renameSync26, statSync as statSync42, writeFileSync as writeFileSync77 } from "fs";
90454
- import { basename as basename43, dirname as dirname64, join as join151 } from "path";
90476
+ import { existsSync as existsSync108, readFileSync as readFileSync135, renameSync as renameSync26, statSync as statSync43, writeFileSync as writeFileSync77 } from "fs";
90477
+ import { basename as basename43, dirname as dirname64, join as join152 } from "path";
90455
90478
  import { createHash as createHash41, verify as verify5 } from "crypto";
90456
90479
  function checkAttestation(jwt, expectedHash, given) {
90457
90480
  const bad = (reason) => ({ status: "tampered", reason });
@@ -90510,7 +90533,7 @@ function checkEventLog(receiptPath, receipt) {
90510
90533
  const claims = st2 !== null && typeof st2 === "object" && Object.keys(st2).length > 0;
90511
90534
  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;
90512
90535
  }
90513
- const path = join151(dirname64(receiptPath), "events.jsonl");
90536
+ const path = join152(dirname64(receiptPath), "events.jsonl");
90514
90537
  if (!existsSync108(path))
90515
90538
  return "events.jsonl is missing";
90516
90539
  const raw2 = readFileSync135(path, "utf8"), events2 = readEvents(path), all = raw2.split(`
@@ -90543,7 +90566,7 @@ function resumeCheckpointOk(events2, done, i) {
90543
90566
  return m > done && isAnsweredResume(events2[m]);
90544
90567
  }
90545
90568
  function checkLogSeal(receiptPath, hash, kid, given) {
90546
- const path = join151(dirname64(receiptPath), "events.jsonl"), events2 = readEvents(path), done = events2.findLastIndex((e10) => e10.type === "run.completed");
90569
+ const path = join152(dirname64(receiptPath), "events.jsonl"), events2 = readEvents(path), done = events2.findLastIndex((e10) => e10.type === "run.completed");
90547
90570
  const rs2 = events2.findIndex((e10) => e10.type === "receipt.sealed" && e10.data["receipt_sha256"] === hash);
90548
90571
  if (rs2 < 0)
90549
90572
  return { verdict: "TAMPERED", reason: "events.jsonl has no receipt.sealed event for this receipt" };
@@ -90679,7 +90702,7 @@ function sealCompositeCmd(runDir) {
90679
90702
  `), 2;
90680
90703
  }
90681
90704
  const hash = compositeHash(body), sig = signReceipt(body.run_id, hash);
90682
- const out3 = { ...body, composite_sha256: hash, verification: { jwt: sig.jwt, kid: sig.kid } }, path = join151(runDir, "composite.json");
90705
+ const out3 = { ...body, composite_sha256: hash, verification: { jwt: sig.jwt, kid: sig.kid } }, path = join152(runDir, "composite.json");
90683
90706
  writeFileSync77(`${path}.tmp`, JSON.stringify(out3, null, 2) + `
90684
90707
  `);
90685
90708
  renameSync26(`${path}.tmp`, path);
@@ -90760,14 +90783,14 @@ ${/^(unknown option|expected at most one)/.test(pk2.error) ? `Usage: loki verify
90760
90783
  args = pk2.args;
90761
90784
  if (pk2.pubkey)
90762
90785
  deps = { ...deps, pubkey: pk2.pubkey };
90763
- const runsRoot2 = deps.runsRoot ?? join151(lokiDir(), "runs");
90786
+ const runsRoot2 = deps.runsRoot ?? join152(lokiDir(), "runs");
90764
90787
  const runId2 = args[0] ?? latestRunId(runsRoot2) ?? undefined;
90765
90788
  if (!runId2)
90766
90789
  return process.stderr.write(`loki verify: no runs found
90767
90790
  `), 66;
90768
- const isFile = existsSync108(runId2) && statSync42(runId2).isFile();
90791
+ const isFile = existsSync108(runId2) && statSync43(runId2).isFile();
90769
90792
  const isPath = isFile || /[\\/]/.test(runId2) || runId2.endsWith(".json");
90770
- const receiptPath = isPath ? runId2 : join151(runsRoot2, runId2, "receipt.json");
90793
+ const receiptPath = isPath ? runId2 : join152(runsRoot2, runId2, "receipt.json");
90771
90794
  const byRunId = !isPath;
90772
90795
  rec2.runId = runId2;
90773
90796
  rec2.receiptPath = receiptPath;
@@ -90911,8 +90934,8 @@ var init_verify_cmd = __esm(() => {
90911
90934
  });
90912
90935
 
90913
90936
  // src/server/app.ts
90914
- import { existsSync as existsSync110, readFileSync as readFileSync138, statSync as statSync43 } from "fs";
90915
- import { join as join154, resolve as resolve42, sep as sep26 } from "path";
90937
+ import { existsSync as existsSync110, readFileSync as readFileSync138, statSync as statSync44 } from "fs";
90938
+ import { join as join155, resolve as resolve42, sep as sep26 } from "path";
90916
90939
 
90917
90940
  // node_modules/hono/dist/request/constants.js
90918
90941
  var GET_MATCH_RESULT = Symbol();
@@ -101392,7 +101415,7 @@ function mount20(ctx) {
101392
101415
  // src/server/routes/verify.ts
101393
101416
  import { readFileSync as readFileSync136, realpathSync as realpathSync36 } from "fs";
101394
101417
  import { createPublicKey as createPublicKey8 } from "crypto";
101395
- import { join as join152, sep as sep25 } from "path";
101418
+ import { join as join153, sep as sep25 } from "path";
101396
101419
  init_verify_cmd();
101397
101420
  init_seal();
101398
101421
  init_receipt_dsse();
@@ -101419,11 +101442,11 @@ function mount21(ctx) {
101419
101442
  return done(404, "receipt not available", "not_found");
101420
101443
  let runDir, file;
101421
101444
  try {
101422
- const root = realpathSync36(join152(repo.p, ".loki", "runs"));
101423
- runDir = realpathSync36(join152(root, run2));
101424
- if (runDir !== join152(root, run2))
101445
+ const root = realpathSync36(join153(repo.p, ".loki", "runs"));
101446
+ runDir = realpathSync36(join153(root, run2));
101447
+ if (runDir !== join153(root, run2))
101425
101448
  return done(404, "receipt not found", "not_found");
101426
- file = realpathSync36(join152(runDir, "receipt.json"));
101449
+ file = realpathSync36(join153(runDir, "receipt.json"));
101427
101450
  } catch {
101428
101451
  return done(404, "receipt not found", "not_found");
101429
101452
  }
@@ -101505,7 +101528,7 @@ function ttlCache(ttlMs = PROBE_CACHE_MS, now2 = Date.now) {
101505
101528
 
101506
101529
  // src/server/legacy/shim.ts
101507
101530
  import { existsSync as existsSync109, readFileSync as readFileSync137 } from "fs";
101508
- import { join as join153 } from "path";
101531
+ import { join as join154 } from "path";
101509
101532
 
101510
101533
  // src/server/legacy/routes.ts
101511
101534
  var LEGACY_ROUTES = [
@@ -101883,7 +101906,7 @@ var logged = new Set;
101883
101906
  var toHono = (p) => p.replace(/\{([A-Za-z_]+):path\}/g, ":$1{.+}").replace(/\{([A-Za-z_]+)\}/g, ":$1");
101884
101907
  var NOT_SUPPORTED = "not yet supported by the Control Plane";
101885
101908
  var repoVersion = () => {
101886
- for (const f of [join153(import.meta.dir, "../../../../../VERSION")]) {
101909
+ for (const f of [join154(import.meta.dir, "../../../../../VERSION")]) {
101887
101910
  try {
101888
101911
  if (existsSync109(f))
101889
101912
  return readFileSync137(f, "utf8").trim();
@@ -102068,7 +102091,7 @@ function legacyShim(opts) {
102068
102091
 
102069
102092
  // src/server/app.ts
102070
102093
  var MAX_BODY2 = 1e6;
102071
- var defaultUiDir = () => [join154(import.meta.dir, "../../ui/dist"), join154(import.meta.dir, "../ui/dist")].find((d) => existsSync110(join154(d, "index.html")));
102094
+ var defaultUiDir = () => [join155(import.meta.dir, "../../ui/dist"), join155(import.meta.dir, "../ui/dist")].find((d) => existsSync110(join155(d, "index.html")));
102072
102095
  function createApp(opts) {
102073
102096
  const uiDir = opts.uiDir ?? defaultUiDir();
102074
102097
  const { db: db2, sqlite } = openDb(opts.dbPath);
@@ -102097,7 +102120,7 @@ function createApp(opts) {
102097
102120
  await next();
102098
102121
  });
102099
102122
  const readInstalled = () => {
102100
- for (const f of [process.env.LOKI_VERSION_FILE, join154(import.meta.dir, "../../../../VERSION")]) {
102123
+ for (const f of [process.env.LOKI_VERSION_FILE, join155(import.meta.dir, "../../../../VERSION")]) {
102101
102124
  try {
102102
102125
  if (f)
102103
102126
  return readFileSync138(f, "utf8").trim() || "unknown";
@@ -102211,11 +102234,11 @@ function createApp(opts) {
102211
102234
  return c.json({ error: "not found" }, 404);
102212
102235
  const root = resolve42(uiDir);
102213
102236
  const f = resolve42(root, `.${p}`);
102214
- if (f.startsWith(root + sep26) && existsSync110(f) && statSync43(f).isFile())
102237
+ if (f.startsWith(root + sep26) && existsSync110(f) && statSync44(f).isFile())
102215
102238
  return new Response(Bun.file(f));
102216
102239
  if (/\.[a-z0-9]+$/i.test(p))
102217
102240
  return c.json({ error: "not found" }, 404);
102218
- return new Response(Bun.file(join154(root, "index.html")));
102241
+ return new Response(Bun.file(join155(root, "index.html")));
102219
102242
  });
102220
102243
  return { app, db: db2, close: () => {
102221
102244
  clearInterval(reconciler);