loki-mode 11.109.0 → 11.111.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 (78) hide show
  1. package/README.md +1 -1
  2. package/SKILL.md +2 -2
  3. package/VERSION +1 -1
  4. package/dashboard/__init__.py +1 -1
  5. package/docs/CLI-REFERENCE.md +1 -1
  6. package/docs/INSTALLATION.md +1 -1
  7. package/docs/trackers.md +4 -0
  8. package/docs/v10/GUIDE.md +13 -3
  9. package/loki-ts/dist/loki.js +1474 -1459
  10. package/mcp/__init__.py +1 -1
  11. package/package.json +2 -2
  12. package/packages/control-plane/dist/ask-tools-server.js +138 -91
  13. package/packages/control-plane/dist/server.js +412 -267
  14. package/packages/control-plane/drizzle/0007_outcome_metrics.sql +7 -0
  15. package/packages/control-plane/drizzle/meta/0007_snapshot.json +846 -0
  16. package/packages/control-plane/drizzle/meta/_journal.json +7 -0
  17. package/packages/control-plane/src/db/schema.ts +6 -1
  18. package/packages/control-plane/src/server/routes/cost.ts +18 -17
  19. package/packages/control-plane/src/server/routes/stats.ts +172 -13
  20. package/packages/control-plane/src/server/runs.ts +24 -8
  21. package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
  22. package/web-app/dist/assets/{AdminPage-B6sjfLKR.js → AdminPage-CVhdjm4W.js} +1 -1
  23. package/web-app/dist/assets/{Avatar-DoNmo0_7.js → Avatar-BAKmd47w.js} +1 -1
  24. package/web-app/dist/assets/{Badge-Ct_pt2J_.js → Badge-DeSidjNE.js} +1 -1
  25. package/web-app/dist/assets/{Button-B_8UwSWE.js → Button-Bsq--imw.js} +1 -1
  26. package/web-app/dist/assets/{CockpitPage-bHjpV0-h.js → CockpitPage-C4OmZ7Zs.js} +1 -1
  27. package/web-app/dist/assets/{ComparePage-CYdev3xk.js → ComparePage-DxCOUyuK.js} +1 -1
  28. package/web-app/dist/assets/{ErrorBoundary-ninWIhC3.js → ErrorBoundary-C-eJidjw.js} +1 -1
  29. package/web-app/dist/assets/{EvidenceReceiptPanel-DNcLk_Ub.js → EvidenceReceiptPanel-CbB-uoq8.js} +1 -1
  30. package/web-app/dist/assets/{GitHubIssuesPanel-DxQCMMlP.js → GitHubIssuesPanel-Co8PJAFZ.js} +1 -1
  31. package/web-app/dist/assets/{GitHubPRsPanel-YENgPd2g.js → GitHubPRsPanel-BW2MHXtE.js} +1 -1
  32. package/web-app/dist/assets/{HomePage-xY2gaAq-.js → HomePage-DB-Wva5X.js} +2 -2
  33. package/web-app/dist/assets/{LoginPage-CrR7G_9f.js → LoginPage-Wjb8beuu.js} +1 -1
  34. package/web-app/dist/assets/{MagicPage-CKfqtzgr.js → MagicPage-BwcUZUxN.js} +1 -1
  35. package/web-app/dist/assets/{MetricsPage-BQzsoIHL.js → MetricsPage-H3cTQAvY.js} +1 -1
  36. package/web-app/dist/assets/{NotFoundPage-D3q_Zpqa.js → NotFoundPage-BNjC-8et.js} +1 -1
  37. package/web-app/dist/assets/{ProjectPage-XIJBGrhl.js → ProjectPage-Dq62Dui3.js} +3 -3
  38. package/web-app/dist/assets/{ProjectsPage-Dx5ATvLd.js → ProjectsPage-CDpxlwjA.js} +1 -1
  39. package/web-app/dist/assets/{SettingsPage-D6wXPubj.js → SettingsPage-nnJWzqjY.js} +1 -1
  40. package/web-app/dist/assets/{ShowcasePage-BYRBw9fs.js → ShowcasePage-CTUAcngH.js} +1 -1
  41. package/web-app/dist/assets/{SystemSettingsPage-DRBUsjDQ.js → SystemSettingsPage-DTO5IQ0Y.js} +1 -1
  42. package/web-app/dist/assets/{TeamsPage-DTUrqLfa.js → TeamsPage-B5TUplzs.js} +1 -1
  43. package/web-app/dist/assets/{TemplatesPage-CnXmu6bS.js → TemplatesPage-BMNxOv3x.js} +1 -1
  44. package/web-app/dist/assets/{TerminalOutput-D0Bot7tj.js → TerminalOutput-eqTWN6Av.js} +1 -1
  45. package/web-app/dist/assets/{activity-BM_k7xqd.js → activity-CIMlAuUK.js} +1 -1
  46. package/web-app/dist/assets/{bell-CHpBnXmZ.js → bell-CWtJHfAz.js} +1 -1
  47. package/web-app/dist/assets/{bot-D5Pbb2HN.js → bot-CrxNs6o2.js} +1 -1
  48. package/web-app/dist/assets/{check-CbTL1Y0C.js → check-0bXjNAw7.js} +1 -1
  49. package/web-app/dist/assets/{chevron-left-j1WDVhuq.js → chevron-left-B7-IUQne.js} +1 -1
  50. package/web-app/dist/assets/{circle-alert-f-0fHGNq.js → circle-alert-dx8_xe86.js} +1 -1
  51. package/web-app/dist/assets/{clock-BquqlMeP.js → clock-BSMlFAwd.js} +1 -1
  52. package/web-app/dist/assets/{cloud-9Ca3aWcZ.js → cloud-y26Fcv_n.js} +1 -1
  53. package/web-app/dist/assets/{code-xml-Bl_k6DrF.js → code-xml-BRBN2bH_.js} +1 -1
  54. package/web-app/dist/assets/{database-DCDIOLu-.js → database-kDCennrN.js} +1 -1
  55. package/web-app/dist/assets/{dollar-sign-Cg5nvgeK.js → dollar-sign-LiubOfVU.js} +1 -1
  56. package/web-app/dist/assets/{file-code-corner-CXYvO2D2.js → file-code-corner-CwZtgXkV.js} +1 -1
  57. package/web-app/dist/assets/{file-plus-MmttmlbT.js → file-plus-SKxkfS4a.js} +1 -1
  58. package/web-app/dist/assets/{globe-pEa5xzIs.js → globe-B7BRExHz.js} +1 -1
  59. package/web-app/dist/assets/{hammer-ZFLNr4FV.js → hammer-COp7qN6_.js} +1 -1
  60. package/web-app/dist/assets/{index-CG5gorJw.js → index-CgI_tsxE.js} +3 -3
  61. package/web-app/dist/assets/{layers-Bk3JF92s.js → layers-CgcOGlBN.js} +1 -1
  62. package/web-app/dist/assets/{loader-circle-Cdz8N-C8.js → loader-circle-CDl-iT1r.js} +1 -1
  63. package/web-app/dist/assets/{lock-lU7YeI3N.js → lock-CPXrrOS0.js} +1 -1
  64. package/web-app/dist/assets/{package-Di8GX8dX.js → package-B411mlKL.js} +1 -1
  65. package/web-app/dist/assets/{plus-BaMf5gKS.js → plus-C_roRS0B.js} +1 -1
  66. package/web-app/dist/assets/{refresh-cw-DkqSop6V.js → refresh-cw-CEtX5fuV.js} +1 -1
  67. package/web-app/dist/assets/{rotate-ccw-DMLCMNJc.js → rotate-ccw-ToeHrGzx.js} +1 -1
  68. package/web-app/dist/assets/{scroll-text-B9iDfF5Q.js → scroll-text-B5KRnTyG.js} +1 -1
  69. package/web-app/dist/assets/{server-CnkC2wYj.js → server-CzJmSSgp.js} +1 -1
  70. package/web-app/dist/assets/{shield-alert-Dzt3c_XB.js → shield-alert-HA5VCG0H.js} +1 -1
  71. package/web-app/dist/assets/{thumbs-up-CKP6qDnH.js → thumbs-up-5VTo5laU.js} +1 -1
  72. package/web-app/dist/assets/{trash-2-CEbOLHPe.js → trash-2-BK-8D9Bf.js} +1 -1
  73. package/web-app/dist/assets/{trending-down-lidUZ_Qf.js → trending-down-CKKI5Lp8.js} +1 -1
  74. package/web-app/dist/assets/{trending-up-C_xakGKL.js → trending-up-jCqitD_J.js} +1 -1
  75. package/web-app/dist/assets/{upload-DDSml_xI.js → upload-DWWoHUBE.js} +1 -1
  76. package/web-app/dist/assets/{usePolling-DC24UYSd.js → usePolling-C0ZWDmbJ.js} +1 -1
  77. package/web-app/dist/assets/{user-BSoRLrwA.js → user-oPFolEsb.js} +1 -1
  78. package/web-app/dist/index.html +1 -1
@@ -3202,8 +3202,8 @@ var require_Node = __commonJS((exports) => {
3202
3202
  };
3203
3203
  const res = toJS.toJS(this, "", ctx);
3204
3204
  if (typeof onAnchor === "function")
3205
- for (const { count, res: res2 } of ctx.anchors.values())
3206
- onAnchor(res2, count);
3205
+ for (const { count: count2, res: res2 } of ctx.anchors.values())
3206
+ onAnchor(res2, count2);
3207
3207
  return typeof reviver === "function" ? applyReviver.applyReviver(reviver, { "": res }, "", res) : res;
3208
3208
  }
3209
3209
  }
@@ -3305,13 +3305,13 @@ var require_Alias = __commonJS((exports) => {
3305
3305
  const anchor = anchors2 && source && anchors2.get(source);
3306
3306
  return anchor ? anchor.count * anchor.aliasCount : 0;
3307
3307
  } else if (identity.isCollection(node)) {
3308
- let count = 0;
3308
+ let count2 = 0;
3309
3309
  for (const item of node.items) {
3310
3310
  const c = getAliasCount(doc, item, anchors2);
3311
- if (c > count)
3312
- count = c;
3311
+ if (c > count2)
3312
+ count2 = c;
3313
3313
  }
3314
- return count;
3314
+ return count2;
3315
3315
  } else if (identity.isPair(node)) {
3316
3316
  const kc = getAliasCount(doc, node.key, anchors2);
3317
3317
  const vc = getAliasCount(doc, node.value, anchors2);
@@ -6051,8 +6051,8 @@ var require_Document = __commonJS((exports) => {
6051
6051
  };
6052
6052
  const res = toJS.toJS(this.contents, jsonArg ?? "", ctx);
6053
6053
  if (typeof onAnchor === "function")
6054
- for (const { count, res: res2 } of ctx.anchors.values())
6055
- onAnchor(res2, count);
6054
+ for (const { count: count2, res: res2 } of ctx.anchors.values())
6055
+ onAnchor(res2, count2);
6056
6056
  return typeof reviver === "function" ? applyReviver.applyReviver(reviver, { "": res }, "", res) : res;
6057
6057
  }
6058
6058
  toJSON(jsonArg, onAnchor) {
@@ -6122,12 +6122,12 @@ var require_errors = __commonJS((exports) => {
6122
6122
  lineStr = prev + lineStr;
6123
6123
  }
6124
6124
  if (/[^ ]/.test(lineStr)) {
6125
- let count = 1;
6125
+ let count2 = 1;
6126
6126
  const end = error.linePos[1];
6127
6127
  if (end?.line === line2 && end.col > col) {
6128
- count = Math.max(1, Math.min(end.col - col, 80 - ci2));
6128
+ count2 = Math.max(1, Math.min(end.col - col, 80 - ci2));
6129
6129
  }
6130
- const pointer = " ".repeat(ci2) + "^".repeat(count);
6130
+ const pointer = " ".repeat(ci2) + "^".repeat(count2);
6131
6131
  error.message += `:
6132
6132
 
6133
6133
  ${lineStr}
@@ -11542,9 +11542,9 @@ function deliverables(task) {
11542
11542
  section = kindOf(head) ?? "other";
11543
11543
  continue;
11544
11544
  }
11545
- const label = /[:*_]\s*$/.test(l) || /^\s*(?:\*\*|__)/.test(l) ? LABEL_RE.exec(l)?.[1] : undefined;
11546
- if (label !== undefined)
11547
- section = kindOf(label) ?? (CONTEXT_WORD.test(label) ? "other" : section);
11545
+ const label2 = /[:*_]\s*$/.test(l) || /^\s*(?:\*\*|__)/.test(l) ? LABEL_RE.exec(l)?.[1] : undefined;
11546
+ if (label2 !== undefined)
11547
+ section = kindOf(label2) ?? (CONTEXT_WORD.test(label2) ? "other" : section);
11548
11548
  }
11549
11549
  const stack = BACKEND_WORD.test(task) && FRONTEND_WORD.test(task);
11550
11550
  const hits = [parts >= LARGE_PARTS, criteria >= LARGE_CRITERIA, stack].filter(Boolean).length;
@@ -12474,14 +12474,14 @@ function goCargoIds(output) {
12474
12474
  `).map((l) => l.trim()), ids = [];
12475
12475
  const cargo = lines.filter((l) => /^test result: /.test(l));
12476
12476
  if (cargo.length) {
12477
- const count2 = cargo.reduce((a, l) => a + +(l.match(/(\d+) failed/)?.[1] ?? 0), 0);
12477
+ const count3 = cargo.reduce((a, l) => a + +(l.match(/(\d+) failed/)?.[1] ?? 0), 0);
12478
12478
  for (const l of lines) {
12479
12479
  const m = /^test (.+?) \.\.\. FAILED$/.exec(l);
12480
12480
  if (m)
12481
12481
  ids.push(m[1]);
12482
12482
  }
12483
12483
  const u2 = [...new Set(ids)];
12484
- return count2 && u2.length >= count2 ? u2 : [];
12484
+ return count3 && u2.length >= count3 ? u2 : [];
12485
12485
  }
12486
12486
  const events2 = lines.flatMap((l) => {
12487
12487
  try {
@@ -12491,19 +12491,19 @@ function goCargoIds(output) {
12491
12491
  return [];
12492
12492
  }
12493
12493
  });
12494
- let count = 0;
12494
+ let count2 = 0;
12495
12495
  if (events2.length) {
12496
12496
  const tested = new Set(events2.filter((e) => e.Action === "fail" && e.Test).map((e) => e.Package ?? ""));
12497
12497
  for (const e of events2) {
12498
12498
  if (e.Action === "output" && /^\s*--- FAIL: /.test(e.Output ?? ""))
12499
- count++;
12499
+ count2++;
12500
12500
  if (e.Action !== "fail")
12501
12501
  continue;
12502
12502
  if (e.Test)
12503
12503
  ids.push(`${e.Package ?? ""}::${e.Test}`);
12504
12504
  else if (!tested.has(e.Package ?? "")) {
12505
12505
  ids.push(e.Package ?? "");
12506
- count++;
12506
+ count2++;
12507
12507
  }
12508
12508
  }
12509
12509
  } else if (lines.some((l) => /^(?:--- FAIL: |FAIL\t|ok\t)/.test(l))) {
@@ -12512,12 +12512,12 @@ function goCargoIds(output) {
12512
12512
  const t = /^--- FAIL: (\S+)/.exec(l), p = /^FAIL\t(\S+)(?:\t|\s+\[)/.exec(l);
12513
12513
  if (t) {
12514
12514
  ids.push(t[1]);
12515
- count++;
12515
+ count2++;
12516
12516
  pending++;
12517
12517
  } else if (p) {
12518
12518
  if (!pending) {
12519
12519
  ids.push(p[1]);
12520
- count++;
12520
+ count2++;
12521
12521
  }
12522
12522
  pending = 0;
12523
12523
  } else if (/^ok\t/.test(l))
@@ -12526,7 +12526,7 @@ function goCargoIds(output) {
12526
12526
  } else
12527
12527
  return null;
12528
12528
  const u = [...new Set(ids)];
12529
- return count && u.length >= count ? u : [];
12529
+ return count2 && u.length >= count2 ? u : [];
12530
12530
  }
12531
12531
  function failIds(raw2) {
12532
12532
  const output = stripAnsi(raw2), gc = goCargoIds(output);
@@ -15349,9 +15349,9 @@ function rustflagsReachLinker(t) {
15349
15349
  }
15350
15350
  function compilerSettingIn(raw2) {
15351
15351
  const t = stripTomlComments(raw2);
15352
- for (const [k, label] of [["rustc", "build.rustc"], ["rustc-wrapper", "build.rustc-wrapper"], ["rustc-workspace-wrapper", "build.rustc-workspace-wrapper"], ["linker", "linker"]])
15352
+ for (const [k, label2] of [["rustc", "build.rustc"], ["rustc-wrapper", "build.rustc-wrapper"], ["rustc-workspace-wrapper", "build.rustc-workspace-wrapper"], ["linker", "linker"]])
15353
15353
  if (CARGO_KEY(k).test(t))
15354
- return label;
15354
+ return label2;
15355
15355
  for (const name of CARGO_ENV_HIJACK)
15356
15356
  if (cargoEnvSets(t, name))
15357
15357
  return `[env] ${name}`;
@@ -15919,7 +15919,7 @@ function deepGaps(risk, verifyChecks, deepChecks = [], reviewRan = false) {
15919
15919
  return { notProven: [...items], notSelected: [] };
15920
15920
  const low = r?.tier === "low", gap = (i) => !low && (i === "full suite" ? sel.includes("full test command") || sel.includes("full suite") : sel.includes(i));
15921
15921
  const notProven = items.filter(gap), notSelected = items.filter((i) => !gap(i)).map((i) => NOT_SELECTED + i);
15922
- const reviewed = reviewRan || executed(deepChecks, "council");
15922
+ const reviewed = reviewRan;
15923
15923
  for (const d of arr2(r?.checks_deferred).filter((x) => !DEEP_ITEMS.includes(x) && !(x === REVIEWER_ITEM && reviewed)))
15924
15924
  (low ? notSelected : notProven).push(low ? NOT_SELECTED + d : d);
15925
15925
  return { notProven, notSelected };
@@ -16337,13 +16337,13 @@ function ignoreRuleChanges(repoDir, snap, baseSha) {
16337
16337
  return ["ignore rules could not be compared with the intake snapshot: the file .git/info/exclude or core.excludesFile was not recorded readable"];
16338
16338
  try {
16339
16339
  const now2 = ignoreSnapshot(repoDir), notes = [];
16340
- for (const [label, a, b] of [[".git/info/exclude", s.info_exclude, now2.info_exclude], ["core.excludesFile", s.global_excludes, now2.global_excludes]]) {
16340
+ for (const [label2, a, b] of [[".git/info/exclude", s.info_exclude, now2.info_exclude], ["core.excludesFile", s.global_excludes, now2.global_excludes]]) {
16341
16341
  if (b.state === "unreadable")
16342
- notes.push(`ignore rules could not be read at verify: ${label}`);
16342
+ notes.push(`ignore rules could not be read at verify: ${label2}`);
16343
16343
  else if (a.path !== b.path)
16344
- notes.push(`ignore rules changed while the run was in progress: ${label} now resolves to ${noteLabel(repoDir, b.path)} (was ${noteLabel(repoDir, a.path)})`);
16344
+ notes.push(`ignore rules changed while the run was in progress: ${label2} now resolves to ${noteLabel(repoDir, b.path)} (was ${noteLabel(repoDir, a.path)})`);
16345
16345
  else if (a.state !== b.state)
16346
- notes.push(`ignore rules changed while the run was in progress: ${label} was edited, so git may hide files the run created`);
16346
+ notes.push(`ignore rules changed while the run was in progress: ${label2} was edited, so git may hide files the run created`);
16347
16347
  }
16348
16348
  const prior = s.exec_files, cur = execFiles(repoDir);
16349
16349
  if (!prior || !cur)
@@ -17150,10 +17150,10 @@ var init_check_result = __esm(() => {
17150
17150
  PLAN = {
17151
17151
  low: { selected: [...RAN_ALWAYS] },
17152
17152
  medium: { selected: [...RAN_ALWAYS, "full test command", REVIEWER_ITEM] },
17153
- high: { selected: [...RAN_ALWAYS, "full test command", "full suite", "council", "security scan"] }
17153
+ high: { selected: [...RAN_ALWAYS, "full test command", "full suite", REVIEWER_ITEM, "security scan"] }
17154
17154
  };
17155
- LOW_SKIPPED = ["full test command", "reviewer", "council", "security scan"];
17156
- DEEP_ITEMS = ["full suite", "app boot", "council", "security scan"];
17155
+ LOW_SKIPPED = ["full test command", "reviewer", "security scan"];
17156
+ DEEP_ITEMS = ["full suite", "app boot", "security scan"];
17157
17157
  MANIFEST_LOCKS = [
17158
17158
  [/(^|\/)package\.json$/, /(^|\/)(package-lock\.json|npm-shrinkwrap\.json|pnpm-lock\.yaml|yarn\.lock|bun\.lockb?)$/],
17159
17159
  [/(^|\/)pyproject\.toml$/, /(^|\/)(poetry\.lock|uv\.lock|pdm\.lock|Pipfile\.lock)$/],
@@ -21677,7 +21677,7 @@ function withRouteLine(body, line2) {
21677
21677
  function withSealRoute(body, env, seal) {
21678
21678
  return withRouteLine(body, routerEnabled(env) && typeof seal.route_line === "string" ? seal.route_line : null);
21679
21679
  }
21680
- var ALIAS, modelLabel = (m) => ALIAS[m] ?? m, nN = (v) => typeof v === "number" && Number.isFinite(v) ? v : null, rec = (v) => v === null ? "not recorded" : String(v), s0 = (v) => typeof v === "string" && v.trim() ? v.trim() : null, assignedBy = (src, explicit) => s0(explicit) ?? (src === null || src === "opus" ? "opus" : src), over = (r, unit) => r.requests_total === null || r.requests_over_100k === null ? "not recorded" : `${r.requests_over_100k} of ${r.requests_total}${unit} (${pct(r)})`, pct = (r) => r.over_100k_share === null ? "n/a (no requests)" : `${(r.over_100k_share * 100).toFixed(1)}%`;
21680
+ var ALIAS, modelLabel = (m) => ALIAS[m] ?? m, nN = (v) => typeof v === "number" && Number.isFinite(v) ? v : null, rec = (v) => v === null ? "not recorded" : String(v), s0 = (v) => typeof v === "string" && v.trim() ? v.trim() : null, assignedBy = (src, explicit) => s0(explicit) ?? (src === null || src === "opus" ? "opus" : src), over = (r, unit) => r.requests_total === null || r.requests_over_100k === null ? "not recorded" : `${r.requests_over_100k} of ${r.requests_total}${unit} (${pct2(r)})`, pct2 = (r) => r.over_100k_share === null ? "n/a (no requests)" : `${(r.over_100k_share * 100).toFixed(1)}%`;
21681
21681
  var init_route_block = __esm(() => {
21682
21682
  init_advisor_probe();
21683
21683
  ALIAS = { haiku: "haiku-5.5", sonnet: "sonnet-5.5", opus: "opus-5.5" };
@@ -21971,8 +21971,8 @@ function decisionCommands(i) {
21971
21971
  return { accept: "loki diff (review), then commit what you keep", reject: "loki undo" };
21972
21972
  }
21973
21973
  function checkLine(c) {
21974
- const label = c.result === "pass" ? "PASSED" : c.result === "fail" ? "FAILED" : c.result === "flaky" ? "FLAKY (not counted as passed)" : "NOT RUN";
21975
- return `${label}: ${clip2(c.cmd || c.name, 70)}${c.reason && c.result !== "pass" ? ` (${clip2(c.reason, 40)})` : ""}`;
21974
+ const label2 = c.result === "pass" ? "PASSED" : c.result === "fail" ? "FAILED" : c.result === "flaky" ? "FLAKY (not counted as passed)" : "NOT RUN";
21975
+ return `${label2}: ${clip2(c.cmd || c.name, 70)}${c.reason && c.result !== "pass" ? ` (${clip2(c.reason, 40)})` : ""}`;
21976
21976
  }
21977
21977
  function renderHandoff(i) {
21978
21978
  const ran2 = i.checks.filter((c) => c.result === "pass"), bad = i.checks.filter((c) => c.result === "fail" && !c.pre_red), onBase = i.checks.filter((c) => c.result === "fail" && c.pre_red);
@@ -22037,14 +22037,14 @@ function composeHandoff(f) {
22037
22037
  const risk = typeof rt?.tier === "string" ? rt.tier : undefined;
22038
22038
  const deferred = Array.isArray(rt?.checks_deferred) ? rt.checks_deferred.filter((x) => typeof x === "string") : [];
22039
22039
  const iv = f.events.filter((e) => e.type === "steer.consumed" || e.type === "intervention").length;
22040
- let count = iv > 0 ? iv : null, detail = null;
22041
- if (count === null) {
22040
+ let count2 = iv > 0 ? iv : null, detail = null;
22041
+ if (count2 === null) {
22042
22042
  try {
22043
22043
  const p = join70(f.repoDir, ".loki", "state", "interventions.json");
22044
22044
  const r = statSync22(p).mtimeMs < (f.sinceMs ?? 0) ? null : JSON.parse(readFileSync62(p, "utf8"));
22045
22045
  const nn = (v) => typeof v === "number" && Number.isInteger(v) && v >= 0 ? v : null;
22046
22046
  if (r && nn(r.count) !== null) {
22047
- count = nn(r.count);
22047
+ count2 = nn(r.count);
22048
22048
  const bt = r.by_type && typeof r.by_type === "object" ? Object.fromEntries(Object.entries(r.by_type).map(([k, v]) => [k, nn(v) ?? 0])) : null;
22049
22049
  if (bt)
22050
22050
  detail = { by_type: bt, waited_s: nn(r.waited_s) };
@@ -22092,7 +22092,7 @@ function composeHandoff(f) {
22092
22092
  measuredSessions: f.measuredSessions,
22093
22093
  totalSessions: f.totalSessions,
22094
22094
  elapsedS: f.elapsedS,
22095
- interventions: count,
22095
+ interventions: count2,
22096
22096
  interventionDetail: detail,
22097
22097
  merge,
22098
22098
  baseSha: f.baseSha,
@@ -26712,14 +26712,14 @@ function commentText(i) {
26712
26712
  return [`Loki outcome: ${i.verdict}`, `PR: ${i.prUrl ?? "none"}`, `Receipt sha256: ${i.receiptSha256 ?? "unavailable"}`].join(`
26713
26713
  `);
26714
26714
  }
26715
- async function post(url, init, label, what = "comment") {
26715
+ async function post(url, init, label2, what = "comment") {
26716
26716
  try {
26717
26717
  const r = await fetch(url, { ...init, signal: AbortSignal.timeout(TIMEOUT_MS) });
26718
26718
  if (!r.ok)
26719
- process.stderr.write(`writeback: ${label} ${what} failed (HTTP ${r.status})
26719
+ process.stderr.write(`writeback: ${label2} ${what} failed (HTTP ${r.status})
26720
26720
  `);
26721
26721
  } catch (e) {
26722
- process.stderr.write(`writeback: ${label} ${what} failed (${e.name})
26722
+ process.stderr.write(`writeback: ${label2} ${what} failed (${e.name})
26723
26723
  `);
26724
26724
  }
26725
26725
  }
@@ -27853,7 +27853,7 @@ function pickReviewer(ctx, agent) {
27853
27853
  const p = reviewProvider(ctx.repoDir, process.env, ctx.provider) ?? agent?.provider ?? null;
27854
27854
  if (p)
27855
27855
  return { p, dflt: false };
27856
- const ok = !isOff(process.env["LOKI_REVIEW_PROVIDER"]) && (ctx.provider === "claude" || ctx.provider === "codex") && readRiskRecord(ctx.repoDir, ctx.startedAtMs ?? 0)?.tier === "medium";
27856
+ const ok = !isOff(process.env["LOKI_REVIEW_PROVIDER"]) && (ctx.provider === "claude" || ctx.provider === "codex") && ["medium", "high"].includes(String(readRiskRecord(ctx.repoDir, ctx.startedAtMs ?? 0)?.tier));
27857
27857
  return { p: ok ? ctx.provider : null, dflt: ok };
27858
27858
  }
27859
27859
  async function crossReview(ctx, verdict, head, signal) {
@@ -30969,7 +30969,7 @@ var init_implement_route = __esm(() => {
30969
30969
  import { existsSync as existsSync70, readFileSync as readFileSync90 } from "fs";
30970
30970
  import { basename as basename28, join as join101 } from "path";
30971
30971
  function weakensTest(baseText2, newText) {
30972
- return count(ASSERT_RE, newText) < count(ASSERT_RE, baseText2) || count(CASE_RE, newText) < count(CASE_RE, baseText2) || count(SKIP_RE, newText) > count(SKIP_RE, baseText2);
30972
+ return count2(ASSERT_RE, newText) < count2(ASSERT_RE, baseText2) || count2(CASE_RE, newText) < count2(CASE_RE, baseText2) || count2(SKIP_RE, newText) > count2(SKIP_RE, baseText2);
30973
30973
  }
30974
30974
  function taskAllowsTestEdit(task, rel) {
30975
30975
  return task.includes(rel) || task.includes(basename28(rel)) || CHANGE_TESTS.test(task) || TESTS_WRONG.test(task);
@@ -30996,7 +30996,7 @@ function restoreBaseTests(repoDir, baseSha, intake) {
30996
30996
  return [];
30997
30997
  }
30998
30998
  }
30999
- var CHANGE_TESTS, TESTS_WRONG, ASSERT_RE, CASE_RE, SKIP_RE, count = (re, text4) => (text4.match(re) ?? []).length;
30999
+ var CHANGE_TESTS, TESTS_WRONG, ASSERT_RE, CASE_RE, SKIP_RE, count2 = (re, text4) => (text4.match(re) ?? []).length;
31000
31000
  var init_test_guard = __esm(() => {
31001
31001
  init_test_file_text();
31002
31002
  init_safe_git();
@@ -32046,6 +32046,48 @@ var init_github_token = __esm(() => {
32046
32046
  import { execFileSync as execFileSync7 } from "child_process";
32047
32047
  import { writeFileSync as writeFileSync51 } from "fs";
32048
32048
  import { join as join105 } from "path";
32049
+ function isTrustedGithubComment(c) {
32050
+ const login = typeof c?.author?.login === "string" ? c.author.login : "";
32051
+ return TRUSTED_ASSOCIATIONS.has(String(c?.authorAssociation ?? "")) && login !== "" && !login.endsWith("[bot]") && c.author?.is_bot !== true && c.isMinimized !== true && typeof c.body === "string" && c.body.trim() !== "" && !c.body.includes(LOKI_COMMENT_MARKER);
32052
+ }
32053
+ function capComments(list, cap = COMMENTS_CAP_BYTES) {
32054
+ const kept = [];
32055
+ let used = 0;
32056
+ for (let k = list.length - 1;k >= 0; k--) {
32057
+ const c = list[k], n3 = Buffer.byteLength(renderComment(c));
32058
+ if (used + n3 <= cap) {
32059
+ kept.unshift(c);
32060
+ used += n3;
32061
+ continue;
32062
+ }
32063
+ if (kept.length === 0) {
32064
+ const note = `
32065
+ [cut at the 16 KB comment cap]`, room = cap - Buffer.byteLength(renderComment({ ...c, body: "" })) - Buffer.byteLength(note);
32066
+ if (room > 0)
32067
+ kept.unshift({ ...c, body: Buffer.from(c.body.trim()).subarray(0, room).toString("utf8").replace(/\uFFFD+$/, "") + note });
32068
+ }
32069
+ break;
32070
+ }
32071
+ return { comments: kept, omitted: list.length - kept.length };
32072
+ }
32073
+ function withIssueContext(issue, trusted, excluded) {
32074
+ const { comments, omitted } = capComments(trusted);
32075
+ const parts = [];
32076
+ if (issue.labels.length > 0)
32077
+ parts.push(`Labels: ${issue.labels.join(", ")}
32078
+ `);
32079
+ if (comments.length > 0) {
32080
+ parts.push(`Comments from trusted authors, oldest first${omitted ? ` (${omitted} older comment(s) left out to stay within 16 KB)` : ""}:`);
32081
+ parts.push(...comments.map(renderComment));
32082
+ }
32083
+ const body = parts.length === 0 ? issue.body : `${issue.body.replace(/\s+$/, "")}${issue.body.trim() ? `
32084
+
32085
+ ` : ""}## Issue tracker context
32086
+
32087
+ ${parts.join(`
32088
+ `)}`.replace(/\s+$/, "");
32089
+ return { ...issue, body, comments, comments_omitted: omitted, comments_excluded: excluded };
32090
+ }
32049
32091
  function defaultExec(cmd, args) {
32050
32092
  const ms = Number(process.env.LOKI_FETCH_ISSUE_TIMEOUT_MS) || 60000;
32051
32093
  return execFileSync7(cmd, args, { encoding: "utf8", env: process.env, timeout: ms, killSignal: "SIGKILL" });
@@ -32055,23 +32097,30 @@ function fetchIssue(ref, execer = defaultExec) {
32055
32097
  const base = JSON.parse(raw2);
32056
32098
  let state = null;
32057
32099
  let closedByMergedPr = false;
32100
+ let trusted = [], excluded = 0;
32058
32101
  if (base.provider === "github" && base.repo && base.number) {
32059
32102
  try {
32060
- const extra = JSON.parse(execer("gh", ["issue", "view", String(base.number), "--repo", base.repo, "--json", "state,closedByPullRequestsReferences"]));
32103
+ const extra = JSON.parse(execer("gh", ["issue", "view", String(base.number), "--repo", base.repo, "--json", "state,closedByPullRequestsReferences,comments"]));
32061
32104
  state = typeof extra.state === "string" ? extra.state.toLowerCase() : null;
32062
32105
  closedByMergedPr = Array.isArray(extra.closedByPullRequestsReferences) && extra.closedByPullRequestsReferences.some((pr) => pr?.merged === true);
32106
+ const all = Array.isArray(extra.comments) ? extra.comments : [];
32107
+ trusted = all.filter(isTrustedGithubComment).map((c) => ({ author: c.author.login, association: c.authorAssociation, created_at: typeof c.createdAt === "string" ? c.createdAt : "", body: c.body }));
32108
+ excluded = all.length - trusted.length;
32063
32109
  } catch {}
32064
32110
  }
32065
- return { ...base, state, closed_by_merged_pr: closedByMergedPr };
32111
+ return withIssueContext({ ...base, state, closed_by_merged_pr: closedByMergedPr }, trusted, excluded);
32066
32112
  }
32067
32113
  function fetchIssueToFile(ref, outFile, exec = defaultExec) {
32068
32114
  const issue = fetchIssue(ref, exec);
32069
32115
  writeFileSync51(outFile, JSON.stringify(issue));
32070
32116
  return issue;
32071
32117
  }
32072
- var ISSUE_PROVIDERS_SH;
32118
+ var TRUSTED_ASSOCIATIONS, LOKI_COMMENT_MARKER = "<!-- loki-", COMMENTS_CAP_BYTES = 16384, renderComment = (c) => `Comment from ${c.author} (${c.association}${c.created_at ? `, ${c.created_at}` : ""}):
32119
+ ${c.body.trim()}
32120
+ `, ISSUE_PROVIDERS_SH;
32073
32121
  var init_fetch_issue = __esm(() => {
32074
32122
  init_paths();
32123
+ TRUSTED_ASSOCIATIONS = new Set(["OWNER", "MEMBER", "COLLABORATOR"]);
32075
32124
  ISSUE_PROVIDERS_SH = join105(REPO_ROOT, "autonomy/issue-providers.sh");
32076
32125
  if (false) {}
32077
32126
  });
@@ -32146,6 +32195,18 @@ function adfToText(doc) {
32146
32195
 
32147
32196
  `).trim();
32148
32197
  }
32198
+ function steerActors(env, source) {
32199
+ const v = source === "jira" ? env.LOKI_JIRA_STEER_ACTORS : env.LOKI_LINEAR_STEER_ACTORS;
32200
+ return new Set((v ?? "").split(",").map((x) => x.trim()).filter(Boolean));
32201
+ }
32202
+ function pickTrusted(list, actor, toComment, allow) {
32203
+ const all = Array.isArray(list) ? list : [];
32204
+ const trusted = all.filter((c) => {
32205
+ const a = actor(c);
32206
+ return typeof a === "string" && allow.has(a);
32207
+ }).map(toComment).filter((c) => c.body.trim() !== "" && !c.body.includes(LOKI_COMMENT_MARKER));
32208
+ return { trusted, excluded: all.length - trusted.length };
32209
+ }
32149
32210
  function need(env, name, hint = "") {
32150
32211
  const v = env[name];
32151
32212
  if (!v)
@@ -32172,7 +32233,8 @@ async function fetchJira(ref, f, env) {
32172
32233
  throw new Error(`Jira returned HTTP ${res.status} for ${ref.key}`);
32173
32234
  const j = await res.json();
32174
32235
  const fl = j.fields ?? {};
32175
- return {
32236
+ const { trusted, excluded } = pickTrusted(fl.comment?.comments, (c) => c.author?.accountId, (c) => ({ author: c.author?.displayName || c.author?.accountId || "", association: "LOKI_JIRA_STEER_ACTORS", created_at: c.created ?? "", body: adfToText(c.body) }), steerActors(env, "jira"));
32237
+ return withIssueContext({
32176
32238
  source: "jira",
32177
32239
  provider: "jira",
32178
32240
  number: 0,
@@ -32185,14 +32247,14 @@ async function fetchJira(ref, f, env) {
32185
32247
  repo: j.key ?? ref.key,
32186
32248
  state: null,
32187
32249
  closed_by_merged_pr: false
32188
- };
32250
+ }, trusted, excluded);
32189
32251
  }
32190
32252
  async function fetchLinear(ref, f, env) {
32191
32253
  const key = need(env, "LINEAR_API_KEY", "; Linear intake needs LINEAR_API_KEY");
32192
32254
  const res = await f("https://api.linear.app/graphql", {
32193
32255
  method: "POST",
32194
32256
  headers: { Authorization: key, "Content-Type": "application/json" },
32195
- body: JSON.stringify({ query: "query($id: String!) { issue(id: $id) { identifier title description url } }", variables: { id: ref.key } })
32257
+ body: JSON.stringify({ query: "query($id: String!) { issue(id: $id) { identifier title description url labels { nodes { name } } comments(first: 100) { nodes { body createdAt user { id name } } } } }", variables: { id: ref.key } })
32196
32258
  });
32197
32259
  if (res.status === 401)
32198
32260
  throw new Error(`Linear rejected the credentials (HTTP 401); check LINEAR_API_KEY`);
@@ -32204,20 +32266,22 @@ async function fetchLinear(ref, f, env) {
32204
32266
  throw new Error(`Linear returned errors for ${ref.key}; check LINEAR_API_KEY: ${j.errors[0]?.message ?? "unknown"}`);
32205
32267
  if (!is2)
32206
32268
  throw new Error(`Linear issue ${ref.key} not found${j.errors?.[0]?.message ? `: ${j.errors[0].message}` : ""}`);
32207
- return {
32269
+ const labels = (is2.labels?.nodes ?? []).map((l) => l?.name).filter((n3) => typeof n3 === "string" && n3 !== "");
32270
+ const { trusted, excluded } = pickTrusted(is2.comments?.nodes, (c) => c.user?.id, (c) => ({ author: c.user?.name || c.user?.id || "", association: "LOKI_LINEAR_STEER_ACTORS", created_at: c.createdAt ?? "", body: c.body ?? "" }), steerActors(env, "linear"));
32271
+ return withIssueContext({
32208
32272
  source: "linear",
32209
32273
  provider: "linear",
32210
32274
  number: 0,
32211
32275
  title: is2.title ?? ref.key,
32212
32276
  body: is2.description ?? "",
32213
- labels: [],
32277
+ labels,
32214
32278
  author: "",
32215
32279
  url: is2.url ?? "",
32216
32280
  created_at: "",
32217
32281
  repo: is2.identifier ?? ref.key,
32218
32282
  state: null,
32219
32283
  closed_by_merged_pr: false
32220
- };
32284
+ }, trusted, excluded);
32221
32285
  }
32222
32286
  async function fetchTrackerIssue(ref, f = fetch, env = process.env) {
32223
32287
  return ref.source === "jira" ? fetchJira(ref, f, env) : fetchLinear(ref, f, env);
@@ -32229,6 +32293,7 @@ async function fetchTrackerIssueToFile(ref, outFile, f = fetch, env = process.en
32229
32293
  }
32230
32294
  var JIRA_KEY = "[A-Z][A-Z0-9_]*-\\d+", JIRA_REF, JIRA_URL, LINEAR_REF, LINEAR_URL, SELF_URL;
32231
32295
  var init_tracker_intake = __esm(() => {
32296
+ init_fetch_issue();
32232
32297
  JIRA_REF = new RegExp(`^jira:(${JIRA_KEY})$`);
32233
32298
  JIRA_URL = new RegExp(`^https://([\\w-]+(?:\\.[\\w-]+)*\\.atlassian\\.net)/browse/(${JIRA_KEY})/?(?:[?#]\\S*)?$`);
32234
32299
  LINEAR_REF = /^linear:([A-Za-z][A-Za-z0-9]*-\d+)$/;
@@ -35161,7 +35226,7 @@ async function splitWithReask(d, slug, i, reason) {
35161
35226
  return { ok: false, reason: `split call failed: ${e instanceof Error ? e.message : String(e)}` };
35162
35227
  }
35163
35228
  }
35164
- async function runWithRetry(d, receiptsDir, label, ref, opts, wt) {
35229
+ async function runWithRetry(d, receiptsDir, label2, ref, opts, wt) {
35165
35230
  for (let attempt = 0;; attempt++) {
35166
35231
  const res = await d.runner(ref, { ...opts, ...wt ? { cwd: wt } : {} });
35167
35232
  if (wt && res.runId)
@@ -35169,7 +35234,7 @@ async function runWithRetry(d, receiptsDir, label, ref, opts, wt) {
35169
35234
  if (res.rc === 0 || attempt >= RATE_LIMIT_RETRIES || !isRateLimited(res.output))
35170
35235
  return res;
35171
35236
  const wait2 = calculateRateLimitBackoff(parseRetryAfter(res.output));
35172
- d.out(`${label} provider rate limit, retrying in ${wait2}s
35237
+ d.out(`${label2} provider rate limit, retrying in ${wait2}s
35173
35238
  `);
35174
35239
  await d.sleep(wait2 * 1000);
35175
35240
  }
@@ -37709,7 +37774,6 @@ var init_secure_scan = __esm(() => {
37709
37774
  var exports_deep = {};
37710
37775
  __export(exports_deep, {
37711
37776
  stage: () => stage8,
37712
- sessionCouncil: () => sessionCouncil,
37713
37777
  runSecretScan: () => runSecretScan,
37714
37778
  runFullSuite: () => runFullSuite,
37715
37779
  runDeep: () => runDeep,
@@ -37720,36 +37784,6 @@ __export(exports_deep, {
37720
37784
  import { copyFileSync as copyFileSync7, existsSync as existsSync85, mkdirSync as mkdirSync65, mkdtempSync as mkdtempSync15, rmSync as rmSync32, writeFileSync as writeFileSync62 } from "fs";
37721
37785
  import { tmpdir as tmpdir20 } from "os";
37722
37786
  import { dirname as dirname51, join as join121 } from "path";
37723
- function sessionCouncil(sessions) {
37724
- return { async run(input, signal) {
37725
- const cwd = mkdtempSync15(join121(tmpdir20(), "loki-deep-council-"));
37726
- try {
37727
- writeFileSync62(join121(cwd, "diff.patch"), input.diff, "utf8");
37728
- const r = await sessions.run({
37729
- stage: "deep",
37730
- tier: "development",
37731
- iterationId: `${input.runId}-council`,
37732
- limitS: COUNCIL_LIMIT_S,
37733
- signal,
37734
- cwd,
37735
- disallowedTools: `${REVIEW_GUARD_DENYLIST},Bash`,
37736
- brief: `You are a read-only code reviewer. Read diff.patch (changed files: ${input.files.join(", ")}). Do not write or run anything. Reply with one line per defect, each starting "FINDING:", or "LGTM".`
37737
- });
37738
- if (r.killed || r.exit !== 0)
37739
- throw new Error(`reviewer session ${r.killed ? "killed" : `exit ${r.exit}`}`);
37740
- const text4 = (r.summary ?? "").trim();
37741
- if (!text4)
37742
- throw new Error("reviewer returned no review");
37743
- const lines2 = text4.split(`
37744
- `).map((l) => l.trim()), findings = lines2.filter((l) => l.startsWith("FINDING:"));
37745
- if (findings.length === 0 && !lines2.includes("LGTM"))
37746
- throw new Error("reviewer reply has no LGTM or FINDING: line");
37747
- return { findings };
37748
- } finally {
37749
- rmSync32(cwd, { recursive: true, force: true });
37750
- }
37751
- } };
37752
- }
37753
37787
  async function runFullSuite(ctx, signal, opts, checks, notProven) {
37754
37788
  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))
37755
37789
  return;
@@ -37814,35 +37848,6 @@ async function runAppBoot(ctx, opts, checks, notProven) {
37814
37848
  notProven.add(`not run: ${c.name} (${c.reason ?? "no reason given"})`);
37815
37849
  }
37816
37850
  }
37817
- async function runCouncilCheck(ctx, changed, baseSha, signal, opts, checks, notProven) {
37818
- const codeFiles = changed.filter((f) => !f.endsWith(".md"));
37819
- if (codeFiles.length === 0) {
37820
- notProven.add("council (no non-doc changes to review)");
37821
- return;
37822
- }
37823
- if (!opts.council) {
37824
- notProven.add("council (not wired: see the contract-gap note in stages/deep.ts)");
37825
- return;
37826
- }
37827
- const diffResult = await safeGitRun(ctx.repoDir, ["diff", "--no-color", baseSha, "HEAD", "--", ...codeFiles], { timeoutMs: 20000 });
37828
- if (diffResult.exitCode !== 0 || !diffResult.stdout.trim()) {
37829
- notProven.add("council (refused: empty or failed diff, nothing to review)");
37830
- return;
37831
- }
37832
- const diff = diffResult.stdout;
37833
- const maxBytes = opts.maxCouncilDiffBytes ?? MAX_COUNCIL_DIFF_BYTES;
37834
- if (Buffer.byteLength(diff, "utf8") > maxBytes) {
37835
- notProven.add("council (context oversized, refused)");
37836
- return;
37837
- }
37838
- const started = Date.now();
37839
- try {
37840
- const outcome = await opts.council.run({ runId: ctx.runId, diff, files: codeFiles }, signal);
37841
- checks.push({ name: "council", cmd: "dispatchClaudeAgents", result: "pass", duration_s: (Date.now() - started) / 1000 });
37842
- } catch (err) {
37843
- notProven.add(`council (refused: ${err.message})`);
37844
- }
37845
- }
37846
37851
  async function runSecretScan(ctx, changed, opts, checks, notProven) {
37847
37852
  const scriptPath = opts.secretScanShPath ?? DEFAULT_SECRET_SCAN_SH, name = "security scan", cmd2 = "secret-scan.sh + secure-scan.py";
37848
37853
  if (!existsSync85(scriptPath)) {
@@ -37939,10 +37944,13 @@ async function runDeep(ctx, signal, opts = {}) {
37939
37944
  const checks = [];
37940
37945
  const notProven = new Set;
37941
37946
  await runFullSuite(ctx, signal, { ...opts, changed }, checks, notProven);
37947
+ const fa = attributeFullSuite(ctx.repoDir, ctx.baseSha, checks, [], changed);
37948
+ for (const c of checks)
37949
+ if (fa.preExistingChecks.includes(c.name))
37950
+ Object.assign(c, { base_red: true, reason: `every failing test id already failed on base ${ctx.baseSha.slice(0, 12)}` });
37942
37951
  await runAppBoot(ctx, opts, checks, notProven);
37943
- await runCouncilCheck(ctx, changed, ctx.baseSha, signal, opts, checks, notProven);
37944
37952
  await runSecretScan(ctx, changed, opts, checks, notProven);
37945
- const statusState = checks.some((c) => c.result === "fail") ? "failure" : "success";
37953
+ const statusState = checks.some((c) => c.result === "fail" && !c.base_red) ? "failure" : "success";
37946
37954
  const notProvenList = [...notProven].filter((n3) => !naNote(n3)), notApplicable = [...notProven].filter(naNote).map(naText);
37947
37955
  const seal = ctx.outputs().seal;
37948
37956
  const addendumBody = {
@@ -38000,9 +38008,8 @@ async function deepWorker(args, deps = {}) {
38000
38008
  `);
38001
38009
  return 1;
38002
38010
  }
38003
- const { createSessionRunner: createSessionRunner2, resolveModel: resolveModel2 } = await Promise.resolve().then(() => (init_session(), exports_session));
38004
- const resolved = model || resolveModel2(provider);
38005
- const sessions = deps.sessions ?? createSessionRunner2({ provider, model: resolved, emit: () => {}, lokiRoot, remaining: () => null });
38011
+ const resolved = model || (await Promise.resolve().then(() => (init_session(), exports_session))).resolveModel(provider);
38012
+ const sessions = { run: () => Promise.reject(new Error("deep verify starts no model session (L003)")) };
38006
38013
  const pinned = origin ? { pinnedOrigin: origin } : {};
38007
38014
  const ctx = {
38008
38015
  runId: runId2,
@@ -38026,7 +38033,7 @@ async function deepWorker(args, deps = {}) {
38026
38033
  const ac = new AbortController;
38027
38034
  for (const sig of ["SIGTERM", "SIGINT"])
38028
38035
  process.once(sig, () => ac.abort());
38029
- const r = await runDeep(ctx, ac.signal, { council: sessionCouncil(sessions), ...deps.opts });
38036
+ const r = await runDeep(ctx, ac.signal, { ...deps.opts });
38030
38037
  process.stderr.write((await Promise.resolve().then(() => (init_base_guard(), exports_base_guard))).finishDeferredRun(repoDir, runId2));
38031
38038
  if (r.status !== "completed") {
38032
38039
  process.stderr.write(`engine10 deep-worker: ${r.reason ?? r.status}
@@ -38035,7 +38042,7 @@ async function deepWorker(args, deps = {}) {
38035
38042
  }
38036
38043
  return 0;
38037
38044
  }
38038
- var DEFAULT_SECRET_SCAN_SH, MAX_COUNCIL_DIFF_BYTES = 400000, COUNCIL_LIMIT_S = 600, FULL_SUITE_TIMEOUT_MS = 300000, deepStage, stage8;
38045
+ var DEFAULT_SECRET_SCAN_SH, FULL_SUITE_TIMEOUT_MS = 300000, deepStage, stage8;
38039
38046
  var init_deep = __esm(() => {
38040
38047
  init_install();
38041
38048
  init_app_probe();
@@ -38051,14 +38058,13 @@ var init_deep = __esm(() => {
38051
38058
  init_failures();
38052
38059
  init_repo_profile();
38053
38060
  init_types();
38054
- init_claude_flags();
38055
38061
  init_safe_git();
38056
38062
  init_pr();
38057
38063
  DEFAULT_SECRET_SCAN_SH = new URL("../../../../autonomy/lib/secret-scan.sh", import.meta.url).pathname;
38058
38064
  deepStage = {
38059
38065
  name: "deep",
38060
38066
  ...STAGE_BUDGETS.deep,
38061
- run: (ctx, signal) => runDeep(ctx, signal, { council: sessionCouncil(ctx.sessions) })
38067
+ run: (ctx, signal) => runDeep(ctx, signal)
38062
38068
  };
38063
38069
  stage8 = deepStage;
38064
38070
  });
@@ -66923,7 +66929,7 @@ function Q9(e10, t) {
66923
66929
  return null;
66924
66930
  }
66925
66931
 
66926
- class r62 {
66932
+ class r63 {
66927
66933
  promise = null;
66928
66934
  start() {
66929
66935
  if (this.promise)
@@ -82219,7 +82225,7 @@ XA==
82219
82225
  V9 = [["model"], ["fallbackModel"], ["advisorModel"], ["modelOverrides"], ["modelPricing"], ["modelPicker"], ["processWrapper"], ["sandbox", "credentials", "files"], ["sandbox", "credentials", "envVars"], ["sandbox", "credentials", "awsPairs"], ["availableModels"], ["requiredMinimumVersion"], ["requiredMaximumVersion"], ["strictKnownMarketplaces"], ["allowedMarketplaces"], ["allowedChannelPlugins"], ["deniedModels"], ["blockedMarketplaces"], ...Mc.map((e10) => ["autoMode", e10]), ["hooks"], ["allowedHttpHookUrls"], ["httpHookAllowedEnvVars"], ["managedMcpServers"], ["extraKnownMarketplaces"], ["additionalMarketplaces"], ["enabledPlugins"], ["pluginConfigs"], ["pluginTrustMessage"], ["pluginSuggestionMarketplaces"], ["claudeMd"], ["cleanupPeriodDays"], ["desktopSessionCleanupPeriodDays"]];
82220
82226
  n9e = ["deniedModels", "blockedMarketplaces", ...Mc.map((e10) => `autoMode.${e10}`)];
82221
82227
  o9e = [...xy, "forceLoginOrgUUID", "forceLoginMethod", "forceLoginGatewayUrl", "gatewayInternalNetworks", "parentSettingsBehavior", "env", "modelPicker", ...av, ...Oi];
82222
- S9e = new r62;
82228
+ S9e = new r63;
82223
82229
  O9e = Object.freeze({ settings: {}, errors: [], loadState: "absent" });
82224
82230
  Vc = Object.freeze({ settings: {}, errors: [] });
82225
82231
  T9e = ["prependPlugins", "appendPlugins"];
@@ -92941,6 +92947,11 @@ var runs = sqliteTable("runs", {
92941
92947
  tokenSessions: integer("token_sessions"),
92942
92948
  inputTokens: integer("input_tokens").notNull(),
92943
92949
  outputTokens: integer("output_tokens").notNull(),
92950
+ cacheReadTokens: integer("cache_read_tokens").notNull().default(0),
92951
+ cacheCreationTokens: integer("cache_creation_tokens").notNull().default(0),
92952
+ fixRounds: integer("fix_rounds").notNull().default(0),
92953
+ escalations: integer("escalations").notNull().default(0),
92954
+ size: text("size"),
92944
92955
  wallS: real("wall_s"),
92945
92956
  lastSeq: integer("last_seq").notNull(),
92946
92957
  lastEventAt: text("last_event_at"),
@@ -93350,16 +93361,214 @@ function effectiveVerdict(r) {
93350
93361
  return r.verdict;
93351
93362
  }
93352
93363
 
93364
+ // src/server/routes/stats.ts
93365
+ var displayVerdict = (r) => r.verdict ? effectiveVerdict({ verdict: r.verdict, tampered: r.tampered === 1, attested: r.attested === 1, sig_checked: r.sigChecked === 1 }) : null;
93366
+ function outcomeClass(r) {
93367
+ const v = displayVerdict(r);
93368
+ if (v === null)
93369
+ return null;
93370
+ if (v === "VERIFIED")
93371
+ return "verified";
93372
+ if (v === "VERIFIED (signature not checked)")
93373
+ return "unchecked";
93374
+ if (v === "ALREADY_SATISFIED" || v === "ALREADY_SATISFIED (signature not checked)")
93375
+ return "satisfied";
93376
+ if (v === "FAILED" || v === "PARTIAL" || v === "TAMPERED")
93377
+ return "failed";
93378
+ return "other";
93379
+ }
93380
+ var r6 = (n3) => Math.round(n3 * 1e6) / 1e6;
93381
+ function computeStats(db, since) {
93382
+ const all = db.select().from(runs).all().filter((r) => !since || r.startedAt !== null && r.startedAt >= since);
93383
+ const by = {};
93384
+ let finished = 0, running = 0, blocked = 0, verified = 0, unchecked = 0, failed2 = 0, satisfied = 0, other = 0;
93385
+ let mUsd = 0, mRuns = 0, pUsd = 0, pRuns = 0;
93386
+ for (const r of all) {
93387
+ if (r.endedAt)
93388
+ finished++;
93389
+ else
93390
+ running++;
93391
+ const verdict = displayVerdict(r);
93392
+ if (verdict) {
93393
+ by[verdict] = (by[verdict] ?? 0) + 1;
93394
+ const k = r.endedAt ? outcomeClass(r) : null;
93395
+ if (k === "verified")
93396
+ verified++;
93397
+ else if (k === "unchecked")
93398
+ unchecked++;
93399
+ else if (k === "satisfied")
93400
+ satisfied++;
93401
+ else if (k === "failed")
93402
+ failed2++;
93403
+ else if (k === "other")
93404
+ other++;
93405
+ }
93406
+ if (r.verdict === "SPEC_CONFLICT")
93407
+ blocked++;
93408
+ if (r.costUsd !== null) {
93409
+ mUsd += r.costUsd;
93410
+ mRuns++;
93411
+ } else if (r.totalSessions > 0) {
93412
+ pUsd += r.partialUsd;
93413
+ pRuns++;
93414
+ }
93415
+ }
93416
+ const keys = new Set(all.map((r) => `${r.sourceId}/${r.runId}`));
93417
+ let total = 0, signed = 0;
93418
+ for (const e of db.select({ s: events.sourceId, r: events.runId, data: events.data }).from(events).where(eq(events.type, "receipt.sealed")).all()) {
93419
+ if (!keys.has(`${e.s}/${e.r}`))
93420
+ continue;
93421
+ total++;
93422
+ if (e.data?.signed === true)
93423
+ signed++;
93424
+ }
93425
+ return {
93426
+ since,
93427
+ runs_total: all.length,
93428
+ runs_finished: finished,
93429
+ runs_running: running,
93430
+ by_verdict: by,
93431
+ blocked_waiting: blocked,
93432
+ verified_rate: verified + unchecked + failed2 ? verified / (verified + unchecked + failed2) : null,
93433
+ breakdown: { verified, failed: failed2, already_satisfied: satisfied, other },
93434
+ verified_unchecked: unchecked,
93435
+ keys_configured: pubkeysFromEnv().configured === true,
93436
+ ...pubkeysFromEnv().reason ? { keys_reason: pubkeysFromEnv().reason } : {},
93437
+ cost: {
93438
+ measured_usd: mRuns ? r6(mUsd) : null,
93439
+ measured_runs: mRuns,
93440
+ partial_usd: pRuns ? r6(pUsd) : null,
93441
+ partial_runs: pRuns,
93442
+ label: pRuns ? "partial" : mRuns ? "measured" : "not measured"
93443
+ },
93444
+ receipts: { total, signed }
93445
+ };
93446
+ }
93447
+ function pct(vals, q) {
93448
+ if (vals.length === 0)
93449
+ return null;
93450
+ const s = [...vals].sort((a, b) => a - b), x = q * (s.length - 1), f = Math.floor(x), d = x - f;
93451
+ const k = d > 0.5 ? f + 1 : d < 0.5 ? f : f % 2 === 0 ? f : f + 1;
93452
+ return s[Math.max(0, Math.min(s.length - 1, k))];
93453
+ }
93454
+ function median2(vals) {
93455
+ if (vals.length === 0)
93456
+ return null;
93457
+ const s = [...vals].sort((a, b) => a - b), m = s.length >> 1;
93458
+ return s.length % 2 ? s[m] : r6((s[m - 1] + s[m]) / 2);
93459
+ }
93460
+ var label = (n3) => n3 > 0 ? "measured" : "not measured";
93461
+ var spread = (vals, hi, q) => ({ p50: median2(vals), [hi]: pct(vals, q), n: vals.length, label: label(vals.length) });
93462
+ var count = (vals) => {
93463
+ const t = vals.reduce((a, b) => a + b, 0);
93464
+ return { total: t, mean: vals.length ? r6(t / vals.length) : null, n: vals.length, label: label(vals.length) };
93465
+ };
93466
+ function costPerVerified(rows) {
93467
+ let spend = 0, priced = 0, unpriced2 = 0, verified = 0, pricedVerified = 0;
93468
+ for (const r of rows) {
93469
+ if (!r.endedAt || r.tampered === 1)
93470
+ continue;
93471
+ const ok = outcomeClass(r) === "verified";
93472
+ if (ok)
93473
+ verified++;
93474
+ if (r.costUsd === null) {
93475
+ unpriced2++;
93476
+ continue;
93477
+ }
93478
+ priced++;
93479
+ spend += r.costUsd;
93480
+ if (ok)
93481
+ pricedVerified++;
93482
+ }
93483
+ return { value: pricedVerified ? r6(spend / pricedVerified) : null, n: pricedVerified, label: label(pricedVerified), spend_usd: priced ? r6(spend) : null, priced_runs: priced, unpriced_runs: unpriced2, verified_runs: verified };
93484
+ }
93485
+ var cacheReadShare = (r) => {
93486
+ const d = r.inputTokens + r.cacheReadTokens + r.cacheCreationTokens;
93487
+ return d > 0 ? r6(r.cacheReadTokens / d) : null;
93488
+ };
93489
+ var OUTCOME_DEFINITIONS = {
93490
+ sessions: "cost events per finished run (h2h sessions); p50 is the median, p90 is h2h pct()",
93491
+ fix_rounds: "fix.round events per finished run",
93492
+ escalations: "escalated plus route.escalated events per finished run",
93493
+ cache_read_share: "cache_read_tokens over input + cache_read + cache_creation tokens, summed over finished runs that recorded input tokens",
93494
+ cost_per_verified_usd: "spend of finished priced runs over the plain VERIFIED runs among them; ALREADY_SATISFIED is not a success here",
93495
+ first_pass_rate: "plain VERIFIED runs with 0 fix rounds over finished verifiable runs (VERIFIED, VERIFIED signature not checked, FAILED, PARTIAL, TAMPERED)",
93496
+ wall_s: "run.completed wall_s of finished runs: p50 (median) and p95 (h2h pct()), overall and by the plan stage's task size",
93497
+ n: "every value carries its n; n = 0 reads not measured and the value is null"
93498
+ };
93499
+ function computeOutcomes(rows) {
93500
+ const fin = rows.filter((r) => r.endedAt);
93501
+ const ok = fin.filter((r) => r.tampered !== 1);
93502
+ let fp = 0, verifiable = 0, cr = 0, tot = 0, crN = 0;
93503
+ for (const r of fin) {
93504
+ const k = outcomeClass(r);
93505
+ if (k === "verified" || k === "unchecked" || k === "failed")
93506
+ verifiable++;
93507
+ if (k === "verified" && r.fixRounds === 0)
93508
+ fp++;
93509
+ }
93510
+ for (const r of ok) {
93511
+ const d = r.inputTokens + r.cacheReadTokens + r.cacheCreationTokens;
93512
+ if (d > 0) {
93513
+ cr += r.cacheReadTokens;
93514
+ tot += d;
93515
+ crN++;
93516
+ }
93517
+ }
93518
+ const walled = ok.filter((r) => r.wallS !== null);
93519
+ const sizeOf = (r) => r.size ?? "unknown";
93520
+ const sizes = [...new Set(walled.map(sizeOf))].sort();
93521
+ return {
93522
+ runs_finished: fin.length,
93523
+ runs_tampered: fin.length - ok.length,
93524
+ sessions: spread(ok.map((r) => r.totalSessions), "p90", 0.9),
93525
+ fix_rounds: count(ok.map((r) => r.fixRounds)),
93526
+ escalations: count(ok.map((r) => r.escalations)),
93527
+ cache_read_share: { value: crN ? r6(cr / tot) : null, n: crN, label: label(crN), cache_read_tokens: cr, input_tokens_total: tot },
93528
+ cost_per_verified_usd: costPerVerified(rows),
93529
+ first_pass_rate: { value: verifiable ? r6(fp / verifiable) : null, n: verifiable, label: label(verifiable), first_pass_runs: fp },
93530
+ wall_s: {
93531
+ all: spread(walled.map((r) => r.wallS), "p95", 0.95),
93532
+ by_size: Object.fromEntries(sizes.map((z) => [z, spread(walled.filter((r) => sizeOf(r) === z).map((r) => r.wallS), "p95", 0.95)]))
93533
+ }
93534
+ };
93535
+ }
93536
+ function outcomesReport(rows) {
93537
+ const byRepo = new Map;
93538
+ for (const r of rows) {
93539
+ const k = r.originRepo ?? "(unknown)";
93540
+ byRepo.set(k, [...byRepo.get(k) ?? [], r]);
93541
+ }
93542
+ return { ...computeOutcomes(rows), by_repo: Object.fromEntries([...byRepo.keys()].sort().map((k) => [k, computeOutcomes(byRepo.get(k))])), definitions: OUTCOME_DEFINITIONS };
93543
+ }
93544
+ var badSince = (s) => !/^\d{4}-\d{2}-\d{2}/.test(s) || Number.isNaN(Date.parse(s));
93545
+ function mount(ctx) {
93546
+ ctx.app.get("/v1/stats", (c) => {
93547
+ const since = c.req.query("since") ?? null;
93548
+ if (since !== null && badSince(since))
93549
+ return c.json({ error: "since must be an ISO date or timestamp" }, 400);
93550
+ return c.json(computeStats(ctx.db, since === null ? null : new Date(since).toISOString()));
93551
+ });
93552
+ ctx.app.get("/v1/stats/outcomes", (c) => {
93553
+ const since = c.req.query("since") ?? null, repo = c.req.query("repo") ?? null;
93554
+ if (since !== null && badSince(since))
93555
+ return c.json({ error: "since must be an ISO date or timestamp" }, 400);
93556
+ const iso = since === null ? null : new Date(since).toISOString();
93557
+ const rows = ctx.db.select().from(runs).all().filter((r) => (!iso || r.startedAt !== null && r.startedAt >= iso) && (repo === null || (r.originRepo ?? "(unknown)") === repo));
93558
+ return c.json({ since: iso, repo, ...outcomesReport(rows) });
93559
+ });
93560
+ }
93561
+
93353
93562
  // src/server/runs.ts
93354
93563
  var str = (x) => typeof x === "string" ? x : null;
93355
93564
  function loadEvents(db, sourceId, runId) {
93356
93565
  return db.select().from(events).where(and(eq(events.sourceId, sourceId), eq(events.runId, runId))).orderBy(asc(events.seq)).all().map((r) => ({ v: 1, seq: r.seq, ts: r.ts, run: r.runId, type: r.type, stage: r.stage, data: r.data }));
93357
93566
  }
93358
- function rebuildRun(db, sourceId, runId) {
93359
- const evs = loadEvents(db, sourceId, runId);
93360
- if (evs.length === 0)
93361
- return;
93362
- const f = fold(sealedPrefix(evs));
93567
+ var sizeOf = (evs) => str(evs.findLast((e) => e.type === "variant" && typeof e.data.size === "string")?.data.size) ?? str(evs.findLast((e) => e.stage === "plan" && e.type.startsWith("stage.") && typeof e.data.size === "string")?.data.size);
93568
+ var ESCALATION_EVENTS = new Set(["escalated", "route.escalated"]);
93569
+ function projectRun(evs, sourceId, runId) {
93570
+ const sealed = sealedPrefix(evs);
93571
+ const f = fold(sealed);
93363
93572
  const keys = pubkeysFromEnv();
93364
93573
  const integ = verifyRunIntegrity(evs, { pubkeyFor: keys });
93365
93574
  const tampered = f.run.tampered || integ.tampered;
@@ -93367,7 +93576,7 @@ function rebuildRun(db, sourceId, runId) {
93367
93576
  const sd = f.run.started?.data ?? {};
93368
93577
  const done = f.run.completed?.data ?? {};
93369
93578
  const pr = evs.find((e) => e.type === "pr.opened")?.data;
93370
- const row = {
93579
+ return {
93371
93580
  sourceId,
93372
93581
  runId,
93373
93582
  originRepo: str(sd.origin_repo),
@@ -93387,8 +93596,13 @@ function rebuildRun(db, sourceId, runId) {
93387
93596
  measuredSessions: pc.measured,
93388
93597
  totalSessions: pc.total,
93389
93598
  tokenSessions: tampered ? null : evs.filter((e) => e.type === "cost" && typeof e.data.input_tokens === "number").length,
93390
- inputTokens: f.cost.inputTokens + f.cost.cacheReadTokens + f.cost.cacheCreationTokens,
93599
+ inputTokens: f.cost.inputTokens,
93391
93600
  outputTokens: f.cost.outputTokens,
93601
+ cacheReadTokens: f.cost.cacheReadTokens,
93602
+ cacheCreationTokens: f.cost.cacheCreationTokens,
93603
+ fixRounds: sealed.filter((e) => e.type === "fix.round").length,
93604
+ escalations: sealed.filter((e) => ESCALATION_EVENTS.has(e.type)).length,
93605
+ size: sizeOf(sealed),
93392
93606
  wallS: typeof done.wall_s === "number" ? done.wall_s : null,
93393
93607
  lastSeq: f.lastSeq,
93394
93608
  lastEventAt: evs[evs.length - 1]?.ts ?? null,
@@ -93398,6 +93612,12 @@ function rebuildRun(db, sourceId, runId) {
93398
93612
  integrityKeyFp: keys.fingerprint ?? "",
93399
93613
  integrityReasons: JSON.stringify(integ.reasons)
93400
93614
  };
93615
+ }
93616
+ function rebuildRun(db, sourceId, runId) {
93617
+ const evs = loadEvents(db, sourceId, runId);
93618
+ if (evs.length === 0)
93619
+ return;
93620
+ const row = projectRun(evs, sourceId, runId);
93401
93621
  db.insert(runs).values(row).onConflictDoUpdate({ target: [runs.sourceId, runs.runId], set: row }).run();
93402
93622
  }
93403
93623
  var reasonsOf = (j) => {
@@ -93430,6 +93650,12 @@ var parseRun = (r) => ({
93430
93650
  token_sessions: r.tokenSessions,
93431
93651
  input_tokens: r.inputTokens,
93432
93652
  output_tokens: r.outputTokens,
93653
+ cache_read_tokens: r.cacheReadTokens,
93654
+ cache_creation_tokens: r.cacheCreationTokens,
93655
+ cache_read_share: cacheReadShare(r),
93656
+ fix_rounds: r.fixRounds,
93657
+ escalations: r.escalations,
93658
+ size: r.size,
93433
93659
  wall_s: r.wallS,
93434
93660
  last_seq: r.lastSeq,
93435
93661
  last_event_at: r.lastEventAt,
@@ -93816,7 +94042,7 @@ function readCapped(path) {
93816
94042
  closeSync5(fd);
93817
94043
  }
93818
94044
  }
93819
- function mount(ctx) {
94045
+ function mount2(ctx) {
93820
94046
  const { app, act, db } = ctx;
93821
94047
  const known = (source, run) => safeId(source) && safeId(run) && !!db.select({ r: runs.runId }).from(runs).where(and(eq(runs.sourceId, source), eq(runs.runId, run))).get();
93822
94048
  app.get("/v1/runs/:source/:run/events", (c) => {
@@ -94631,7 +94857,7 @@ function createSse(opts) {
94631
94857
  return new Response(body, { headers });
94632
94858
  };
94633
94859
  }
94634
- function mount2(ctx) {
94860
+ function mount3(ctx) {
94635
94861
  const pollMs = num2(process.env.LOKI_CONTROL_STREAM_POLL_MS, 1000);
94636
94862
  const heartbeatMs = num2(process.env.LOKI_CONTROL_STREAM_HEARTBEAT_MS, 15000);
94637
94863
  const maxStreams = num2(process.env.LOKI_CONTROL_STREAM_MAX, 32);
@@ -94703,7 +94929,7 @@ var num3 = (v, d) => {
94703
94929
  return Number.isFinite(n3) && n3 > 0 ? n3 : d;
94704
94930
  };
94705
94931
  var askEnabled = () => process.env.LOKI_CP_ASK === "1";
94706
- function mount3(ctx) {
94932
+ function mount4(ctx) {
94707
94933
  const { app, db } = ctx;
94708
94934
  markInterrupted(db, pidAlive);
94709
94935
  const sse = createSse({ pollMs: num3(process.env.LOKI_ASK_STREAM_POLL_MS, 300), heartbeatMs: num3(process.env.LOKI_CONTROL_STREAM_HEARTBEAT_MS, 15000), maxStreams: num3(process.env.LOKI_CONTROL_STREAM_MAX, 32) });
@@ -94876,7 +95102,7 @@ ${first.join("")}`, tick);
94876
95102
  }
94877
95103
 
94878
95104
  // src/server/routes/audit.ts
94879
- function mount4(ctx) {
95105
+ function mount5(ctx) {
94880
95106
  ctx.app.get("/v1/audit", (c) => {
94881
95107
  const limit = Math.min(Math.max(Number.parseInt(c.req.query("limit") ?? "50", 10) || 50, 1), 200);
94882
95108
  const offset = Math.max(Number.parseInt(c.req.query("cursor") ?? "0", 10) || 0, 0);
@@ -94900,7 +95126,7 @@ import { existsSync as existsSync10, readdirSync as readdirSync8, readFileSync a
94900
95126
  import { join as join22 } from "path";
94901
95127
  var isNum2 = (v) => typeof v === "number" && Number.isFinite(v);
94902
95128
  var isObj3 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
94903
- var r6 = (n3) => Math.round(n3 * 1e6) / 1e6;
95129
+ var r62 = (n3) => Math.round(n3 * 1e6) / 1e6;
94904
95130
  var MEASURED_FIELDS = ["cost_usd", "input_tokens", "output_tokens", "cache_read_tokens", "cache_creation_tokens"];
94905
95131
  var BUDGET_WARN_FRACTION = 0.8;
94906
95132
  var NOT_MEASURED = "not measured";
@@ -94938,7 +95164,7 @@ function modelCost(table, model, inp, out, cr = 0, cw = 0) {
94938
95164
  const or2 = isNum2(p.output) ? p.output : 15;
94939
95165
  const crr = isNum2(p.cache_read) ? p.cache_read : ir * 0.1;
94940
95166
  const cwr = isNum2(p.cache_write) ? p.cache_write : ir * 1.25;
94941
- return r6((inp * ir + out * or2 + cr * crr + cw * cwr) / 1e6);
95167
+ return r62((inp * ir + out * or2 + cr * crr + cw * cwr) / 1e6);
94942
95168
  }
94943
95169
  function iterationRecords(lokiDir2) {
94944
95170
  const dir = join22(lokiDir2, "metrics", "efficiency");
@@ -95025,7 +95251,7 @@ function costSnapshot(lokiDir2) {
95025
95251
  const fmt = (m) => Object.fromEntries(Object.entries(m).map(([k, v]) => [k, {
95026
95252
  input_tokens: v.tokens_measured ? v.input_tokens : null,
95027
95253
  output_tokens: v.tokens_measured ? v.output_tokens : null,
95028
- cost_usd: v.measured ? r6(v.cost_usd) : null
95254
+ cost_usd: v.measured ? r62(v.cost_usd) : null
95029
95255
  }]));
95030
95256
  return {
95031
95257
  total_input_tokens: recorded ? tIn : null,
@@ -95034,13 +95260,13 @@ function costSnapshot(lokiDir2) {
95034
95260
  total_cache_creation_tokens: recorded ? tCw : null,
95035
95261
  total_tokens: recorded ? tIn + tOut + tCr + tCw : null,
95036
95262
  cache_hit_ratio: readIn > 0 ? Math.round(tCr / readIn * 1e4) / 1e4 : null,
95037
- estimated_cost_usd: recorded && !unknownUsd ? r6(est) : null,
95263
+ estimated_cost_usd: recorded && !unknownUsd ? r62(est) : null,
95038
95264
  cost_recorded: recorded,
95039
95265
  by_phase: fmt(byPhase),
95040
95266
  by_model: fmt(byModel),
95041
95267
  budget_limit: limit,
95042
- budget_used: limit !== null && used !== null ? r6(used) : null,
95043
- budget_remaining: remaining !== null ? r6(remaining) : null,
95268
+ budget_used: limit !== null && used !== null ? r62(used) : null,
95269
+ budget_remaining: remaining !== null ? r62(remaining) : null,
95044
95270
  ...recorded ? {} : { not_measured: NOT_MEASURED }
95045
95271
  };
95046
95272
  }
@@ -95074,13 +95300,13 @@ function budgetSnapshot(lokiDir2) {
95074
95300
  if (Number.isFinite(e))
95075
95301
  limit = e;
95076
95302
  }
95077
- const used = recorded ? r6(total) : null;
95303
+ const used = recorded ? r62(total) : null;
95078
95304
  const ok = limit !== null && limit > 0 && used !== null;
95079
95305
  const status = budgetStatus(used, limit);
95080
95306
  return {
95081
95307
  limit,
95082
95308
  used,
95083
- remaining: ok ? r6(Math.max(0, limit - used)) : null,
95309
+ remaining: ok ? r62(Math.max(0, limit - used)) : null,
95084
95310
  percent_used: ok ? Math.round(used / limit * 1e4) / 100 : null,
95085
95311
  status,
95086
95312
  warn_threshold_percent: Math.round(BUDGET_WARN_FRACTION * 100),
@@ -95109,8 +95335,8 @@ function costTimeline(lokiDir2) {
95109
95335
  provider: d.provider ?? null,
95110
95336
  input_tokens: measured ? num0(d.input_tokens) : null,
95111
95337
  output_tokens: measured ? num0(d.output_tokens) : null,
95112
- cost_usd: measured ? r6(priced(table, d)) : null,
95113
- cumulative_usd: measured ? r6(cum) : null
95338
+ cost_usd: measured ? r62(priced(table, d)) : null,
95339
+ cumulative_usd: measured ? r62(cum) : null
95114
95340
  });
95115
95341
  }
95116
95342
  const runs2 = [];
@@ -95140,7 +95366,7 @@ function costTimeline(lokiDir2) {
95140
95366
  run_id: p.run_id ?? e,
95141
95367
  generated_at: p.generated_at ?? null,
95142
95368
  model: isObj3(p.provider) ? p.provider.model ?? null : null,
95143
- cost_usd: usd !== null ? r6(usd) : null,
95369
+ cost_usd: usd !== null ? r62(usd) : null,
95144
95370
  cost_partial: cost.cost_partial === true,
95145
95371
  files_changed: isObj3(p.files_changed) ? p.files_changed.count ?? null : null,
95146
95372
  final_verdict: isObj3(p.council) ? p.council.final_verdict ?? null : null
@@ -95148,10 +95374,10 @@ function costTimeline(lokiDir2) {
95148
95374
  }
95149
95375
  runs2.sort((a, b) => String(b.generated_at ?? "").localeCompare(String(a.generated_at ?? "")));
95150
95376
  return {
95151
- current_run: { iterations, total_usd: recorded ? r6(cum) : null, cost_recorded: recorded, partial: recorded && unmeasured > 0, unmeasured_iterations: unmeasured },
95377
+ current_run: { iterations, total_usd: recorded ? r62(cum) : null, cost_recorded: recorded, partial: recorded && unmeasured > 0, unmeasured_iterations: unmeasured },
95152
95378
  runs: runs2,
95153
95379
  runs_count: runs2.length,
95154
- project_total_usd: runsMeasured ? r6(projectTotal) : null,
95380
+ project_total_usd: runsMeasured ? r62(projectTotal) : null,
95155
95381
  project_total_partial: runsMeasured > 0 && runsMeasured < runs2.length,
95156
95382
  budget: budgetSnapshot(lokiDir2),
95157
95383
  ...recorded || runsMeasured ? {} : { not_measured: NOT_MEASURED }
@@ -95159,7 +95385,7 @@ function costTimeline(lokiDir2) {
95159
95385
  }
95160
95386
  var lokiDirOf = (repoDir) => join22(repoDir, ".loki");
95161
95387
  var lokiDirExists = (repoDir) => existsSync10(lokiDirOf(repoDir));
95162
- function mount5(ctx) {
95388
+ function mount6(ctx) {
95163
95389
  const deny = { error: "loopback only without a token" };
95164
95390
  ctx.app.get("/v1/cost/snapshot", (c) => probeAllowed(ctx, c) ? c.json(costSnapshot(lokiDirOf(ctx.repoDir))) : c.json(deny, 403));
95165
95391
  ctx.app.get("/v1/cost/timeline", (c) => probeAllowed(ctx, c) ? c.json(costTimeline(lokiDirOf(ctx.repoDir))) : c.json(deny, 403));
@@ -95369,7 +95595,7 @@ var parseLimit = (v) => {
95369
95595
  const n3 = Number.parseInt(v ?? "20", 10);
95370
95596
  return Number.isFinite(n3) ? Math.min(Math.max(n3, 1), 200) : 20;
95371
95597
  };
95372
- function mount6(ctx) {
95598
+ function mount7(ctx) {
95373
95599
  const deny = { error: "loopback only without a token" };
95374
95600
  const { app, act, db, repoDir } = ctx;
95375
95601
  app.get("/v1/checkpoints", (c) => probeAllowed(ctx, c) ? c.json({ checkpoints: listCheckpoints(repoDir, parseLimit(c.req.query("limit"))) }) : c.json(deny, 403));
@@ -95479,7 +95705,7 @@ function originOk(origin) {
95479
95705
  return false;
95480
95706
  }
95481
95707
  }
95482
- function mount7(ctx) {
95708
+ function mount8(ctx) {
95483
95709
  const { act, db, repoDir, local } = ctx;
95484
95710
  const inflight = new Set;
95485
95711
  const handler = async (c) => {
@@ -95909,7 +96135,7 @@ function atomicWrite(file, text2, mode) {
95909
96135
  }
95910
96136
  var etagOf = (raw2) => `"${sha(raw2)}"`;
95911
96137
  var norm = (h) => h ? h.trim().replace(/^W\//, "").replace(/^"|"$/g, "") : null;
95912
- function mount8(ctx) {
96138
+ function mount9(ctx) {
95913
96139
  const { act, db, repoDir, local } = ctx;
95914
96140
  const deny = (c, kind, status, error, extra = {}) => {
95915
96141
  audit3(db, { kind, target: "loki.yaml", result: status === 409 ? "conflict" : status === 500 ? "error" : "refused", detail: error });
@@ -96039,7 +96265,7 @@ import { join as join25, resolve as resolve9, sep as sep8 } from "path";
96039
96265
  init_run_pid();
96040
96266
  var ID4 = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
96041
96267
  var busy = new Set;
96042
- function mount9(ctx) {
96268
+ function mount10(ctx) {
96043
96269
  const { act, db } = ctx;
96044
96270
  const bin = ctx.startBin ?? "loki", spawnIt = ctx.spawnImpl ?? spawnStart, answerDir = ctx.answerDir ?? defaultAnswerDir();
96045
96271
  const guarded = (kind, handler) => act.post(`/v1/runs/:source/:run/${kind}`, async (c) => {
@@ -96119,7 +96345,7 @@ function mount9(ctx) {
96119
96345
  var COST_DIMS = ["day", "model", "repo", "provider"];
96120
96346
  var DEFAULT_API_KEY_CAP_USD = 100;
96121
96347
  var NONE = "unknown";
96122
- var mk = (key) => ({ key, runs: 0, measured_runs: 0, partial_runs: 0, unmeasured_runs: 0, measured_usd: 0, partial_usd: 0, input_tokens: 0, output_tokens: 0, tk: 0, tn: 0 });
96348
+ var mk = (key) => ({ key, runs: 0, measured_runs: 0, partial_runs: 0, unmeasured_runs: 0, measured_usd: 0, partial_usd: 0, input_tokens: 0, output_tokens: 0, cache_read_tokens: 0, cache_creation_tokens: 0, tk: 0, tn: 0 });
96123
96349
  var add2 = (a, r) => {
96124
96350
  a.runs++;
96125
96351
  if (r.costUsd !== null) {
@@ -96132,6 +96358,8 @@ var add2 = (a, r) => {
96132
96358
  a.unmeasured_runs++;
96133
96359
  a.input_tokens += r.inputTokens;
96134
96360
  a.output_tokens += r.outputTokens;
96361
+ a.cache_read_tokens += r.cacheReadTokens;
96362
+ a.cache_creation_tokens += r.cacheCreationTokens;
96135
96363
  if (r.tokenSessions !== null) {
96136
96364
  a.tk += r.tokenSessions;
96137
96365
  a.tn += r.totalSessions;
@@ -96139,31 +96367,26 @@ var add2 = (a, r) => {
96139
96367
  };
96140
96368
  var dimVal = (d, r) => d === "day" ? r.startedAt ? r.startedAt.slice(0, 10) : NONE : d === "model" ? r.model ?? NONE : d === "provider" ? r.provider ?? NONE : r.originRepo ?? NONE;
96141
96369
  var round = (n3) => Math.round(n3 * 1e6) / 1e6;
96142
- var out = (a) => ({ ...a.key, runs: a.runs, measured_runs: a.measured_runs, partial_runs: a.partial_runs, unmeasured_runs: a.unmeasured_runs, measured_usd: round(a.measured_usd), partial_usd: round(a.partial_usd), input_tokens: a.input_tokens, output_tokens: a.output_tokens, ...a.tk < a.tn ? { token_sessions: a.tk, token_sessions_total: a.tn } : {} });
96143
- function mount10(ctx) {
96370
+ var out = (a) => ({ ...a.key, runs: a.runs, measured_runs: a.measured_runs, partial_runs: a.partial_runs, unmeasured_runs: a.unmeasured_runs, measured_usd: round(a.measured_usd), partial_usd: round(a.partial_usd), input_tokens: a.input_tokens, output_tokens: a.output_tokens, cache_read_tokens: a.cache_read_tokens, cache_creation_tokens: a.cache_creation_tokens, ...a.tk < a.tn ? { token_sessions: a.tk, token_sessions_total: a.tn } : {} });
96371
+ function mount11(ctx) {
96144
96372
  ctx.app.get("/v1/cost/repos", (c) => {
96145
96373
  const g = new Map;
96146
96374
  for (const r of ctx.db.select().from(runs).all()) {
96147
96375
  const k = r.originRepo ?? "(unknown)";
96148
- const a = g.get(k) ?? { runs: 0, priced: 0, usd: 0, verified: 0 };
96149
- a.runs++;
96150
- if (r.costUsd !== null) {
96151
- a.priced++;
96152
- a.usd += r.costUsd;
96153
- }
96154
- const ev = effectiveVerdict({ verdict: r.verdict, tampered: r.tampered === 1, attested: r.attested === 1, sig_checked: r.sigChecked === 1 });
96155
- if (ev !== null && SUCCESS_VERDICTS.has(ev))
96156
- a.verified++;
96157
- g.set(k, a);
96158
- }
96159
- const rows = [...g.entries()].sort((x, y) => x[0].localeCompare(y[0])).map(([repo, a]) => ({
96160
- repo,
96161
- runs: a.runs,
96162
- total_usd: round(a.usd),
96163
- avg_usd: a.priced ? round(a.usd / a.priced) : null,
96164
- verified_runs: a.verified,
96165
- usd_per_verified: a.verified ? round(a.usd / a.verified) : null
96166
- }));
96376
+ g.set(k, [...g.get(k) ?? [], r]);
96377
+ }
96378
+ const rows = [...g.entries()].sort((x, y) => x[0].localeCompare(y[0])).map(([repo, rs]) => {
96379
+ const priced2 = rs.filter((r) => r.costUsd !== null), usd = priced2.reduce((t, r) => t + r.costUsd, 0), cpv = costPerVerified(rs);
96380
+ return {
96381
+ repo,
96382
+ runs: rs.length,
96383
+ total_usd: round(usd),
96384
+ avg_usd: priced2.length ? round(usd / priced2.length) : null,
96385
+ verified_runs: cpv.verified_runs,
96386
+ usd_per_verified: cpv.value,
96387
+ usd_per_verified_n: cpv.n
96388
+ };
96389
+ });
96167
96390
  return c.json({ rows });
96168
96391
  });
96169
96392
  ctx.app.get("/v1/stats/cost", (c) => {
@@ -96278,7 +96501,7 @@ function mapDoctor(raw2) {
96278
96501
  throw new Error("loki doctor returned no usable checks");
96279
96502
  return out2;
96280
96503
  }
96281
- function mount11(ctx) {
96504
+ function mount12(ctx) {
96282
96505
  const cached = ttlCache();
96283
96506
  ctx.app.get("/v1/doctor", async (c) => {
96284
96507
  if (!probeAllowed(ctx, c))
@@ -96404,7 +96627,7 @@ function fleetSummary(includeInactive = true, file = registryFile()) {
96404
96627
  };
96405
96628
  }
96406
96629
  var parseInactive = (v) => !["false", "0", "no"].includes((v ?? "true").toLowerCase());
96407
- function mount12(ctx) {
96630
+ function mount13(ctx) {
96408
96631
  const deny = { error: "loopback only without a token" };
96409
96632
  ctx.app.get("/v1/fleet/runs", (c) => probeAllowed(ctx, c) ? c.json(fleetRuns(parseInactive(c.req.query("include_inactive"))).map(({ path: _p, ...r }) => r)) : c.json(deny, 403));
96410
96633
  ctx.app.get("/v1/fleet/summary", (c) => probeAllowed(ctx, c) ? c.json(fleetSummary(parseInactive(c.req.query("include_inactive")))) : c.json(deny, 403));
@@ -96645,7 +96868,7 @@ function contextTracking(loki) {
96645
96868
  return { status: 500, body: { error: "Failed to read context tracking data" } };
96646
96869
  }
96647
96870
  }
96648
- function mount13(ctx) {
96871
+ function mount14(ctx) {
96649
96872
  const deny = { error: "loopback only without a token" };
96650
96873
  const read = (path, fn) => ctx.app.get(path, (c) => probeAllowed(ctx, c) ? fn(c, lokiFor(ctx.repoDir)) : c.json(deny, 403));
96651
96874
  read("/v1/tasks", (c, l) => {
@@ -96803,7 +97026,7 @@ function buildMetricsText(repoDir, now2 = Date.now()) {
96803
97026
  `) + `
96804
97027
  `;
96805
97028
  }
96806
- function mount14(ctx) {
97029
+ function mount15(ctx) {
96807
97030
  ctx.app.get("/v1/metrics", (c) => {
96808
97031
  if (!probeAllowed(ctx, c))
96809
97032
  return c.json({ error: "loopback only without a token" }, 403);
@@ -96980,7 +97203,7 @@ function councilTranscripts(loki, q) {
96980
97203
  return { transcripts: out2, total: out2.length, latest_id: out2.length ? out2[0].iteration_id : null };
96981
97204
  }
96982
97205
  var intQ = (v, max) => v === undefined ? undefined : /^\d+$/.test(v) && Number(v) <= max ? Number(v) : null;
96983
- function mount15(ctx) {
97206
+ function mount16(ctx) {
96984
97207
  const deny = { error: "loopback only without a token" };
96985
97208
  const loki = () => lokiDirOf(ctx.repoDir);
96986
97209
  ctx.act.post("/v1/control/:action", (c) => {
@@ -97135,7 +97358,7 @@ async function listIntegrations(repoDir, gh = () => ghAuthed()) {
97135
97358
  });
97136
97359
  return rows;
97137
97360
  }
97138
- function mount16(ctx) {
97361
+ function mount17(ctx) {
97139
97362
  const cached = ttlCache();
97140
97363
  ctx.app.get("/v1/integrations", async (c) => {
97141
97364
  if (!probeAllowed(ctx, c))
@@ -97238,7 +97461,7 @@ function parseRisk(out2) {
97238
97461
  return null;
97239
97462
  }
97240
97463
  }
97241
- function mount17(ctx) {
97464
+ function mount18(ctx) {
97242
97465
  const { act, db } = ctx;
97243
97466
  const bin = () => ctx.startBin ?? process.env["LOKI_BIN"] ?? "loki";
97244
97467
  const busy2 = new Set;
@@ -97264,7 +97487,7 @@ function mount17(ctx) {
97264
97487
  const wantReal = real3(want);
97265
97488
  if (wantReal && known.has(wantReal))
97266
97489
  return wantReal;
97267
- const named = [...known].filter(([r, label]) => label === want || basename7(r) === want).map(([r]) => r);
97490
+ const named = [...known].filter(([r, label2]) => label2 === want || basename7(r) === want).map(([r]) => r);
97268
97491
  return named.length === 1 ? named[0] : null;
97269
97492
  };
97270
97493
  const slot = async (c, kind, auditKind, fn) => {
@@ -97442,7 +97665,7 @@ function deriveNotifications(db) {
97442
97665
  }
97443
97666
  return out2.sort((a, b) => a.ts < b.ts ? 1 : a.ts > b.ts ? -1 : a.id < b.id ? -1 : 1);
97444
97667
  }
97445
- function mount18(ctx) {
97668
+ function mount19(ctx) {
97446
97669
  ctx.app.get("/v1/notifications", (c) => {
97447
97670
  const all = deriveNotifications(ctx.db);
97448
97671
  const limit = Math.min(Math.max(Number.parseInt(c.req.query("limit") ?? "50", 10) || 50, 1), 200);
@@ -97556,7 +97779,7 @@ async function listProviders(timeoutMs = DEFAULT_TIMEOUT_MS2) {
97556
97779
  }));
97557
97780
  return { providers: rows, catalog_updated: cat.updated, probe_timeout_ms: timeoutMs };
97558
97781
  }
97559
- function mount19(ctx) {
97782
+ function mount20(ctx) {
97560
97783
  const cached = ttlCache();
97561
97784
  ctx.app.get("/v1/providers", async (c) => {
97562
97785
  if (!probeAllowed(ctx, c))
@@ -97567,84 +97790,6 @@ function mount19(ctx) {
97567
97790
  });
97568
97791
  }
97569
97792
 
97570
- // src/server/routes/stats.ts
97571
- function computeStats(db, since) {
97572
- const all = db.select().from(runs).all().filter((r) => !since || r.startedAt !== null && r.startedAt >= since);
97573
- const by = {};
97574
- let finished = 0, running = 0, blocked = 0, verified = 0, unchecked = 0, failed2 = 0, satisfied = 0, other = 0;
97575
- let mUsd = 0, mRuns = 0, pUsd = 0, pRuns = 0;
97576
- for (const r of all) {
97577
- if (r.endedAt)
97578
- finished++;
97579
- else
97580
- running++;
97581
- const verdict = r.verdict ? effectiveVerdict({ verdict: r.verdict, tampered: r.tampered === 1, attested: r.attested === 1, sig_checked: r.sigChecked === 1 }) : null;
97582
- if (verdict) {
97583
- by[verdict] = (by[verdict] ?? 0) + 1;
97584
- if (r.endedAt) {
97585
- if (verdict === "VERIFIED")
97586
- verified++;
97587
- else if (verdict === "VERIFIED (signature not checked)")
97588
- unchecked++;
97589
- else if (verdict === "ALREADY_SATISFIED" || verdict === "ALREADY_SATISFIED (signature not checked)")
97590
- satisfied++;
97591
- else if (verdict === "FAILED" || verdict === "PARTIAL" || verdict === "TAMPERED")
97592
- failed2++;
97593
- else
97594
- other++;
97595
- }
97596
- }
97597
- if (r.verdict === "SPEC_CONFLICT")
97598
- blocked++;
97599
- if (r.costUsd !== null) {
97600
- mUsd += r.costUsd;
97601
- mRuns++;
97602
- } else if (r.totalSessions > 0) {
97603
- pUsd += r.partialUsd;
97604
- pRuns++;
97605
- }
97606
- }
97607
- const keys = new Set(all.map((r) => `${r.sourceId}/${r.runId}`));
97608
- let total = 0, signed = 0;
97609
- for (const e of db.select({ s: events.sourceId, r: events.runId, data: events.data }).from(events).where(eq(events.type, "receipt.sealed")).all()) {
97610
- if (!keys.has(`${e.s}/${e.r}`))
97611
- continue;
97612
- total++;
97613
- if (e.data?.signed === true)
97614
- signed++;
97615
- }
97616
- const r62 = (n3) => Math.round(n3 * 1e6) / 1e6;
97617
- return {
97618
- since,
97619
- runs_total: all.length,
97620
- runs_finished: finished,
97621
- runs_running: running,
97622
- by_verdict: by,
97623
- blocked_waiting: blocked,
97624
- verified_rate: verified + unchecked + failed2 ? verified / (verified + unchecked + failed2) : null,
97625
- breakdown: { verified, failed: failed2, already_satisfied: satisfied, other },
97626
- verified_unchecked: unchecked,
97627
- keys_configured: pubkeysFromEnv().configured === true,
97628
- ...pubkeysFromEnv().reason ? { keys_reason: pubkeysFromEnv().reason } : {},
97629
- cost: {
97630
- measured_usd: mRuns ? r62(mUsd) : null,
97631
- measured_runs: mRuns,
97632
- partial_usd: pRuns ? r62(pUsd) : null,
97633
- partial_runs: pRuns,
97634
- label: pRuns ? "partial" : mRuns ? "measured" : "not measured"
97635
- },
97636
- receipts: { total, signed }
97637
- };
97638
- }
97639
- function mount20(ctx) {
97640
- ctx.app.get("/v1/stats", (c) => {
97641
- const since = c.req.query("since") ?? null;
97642
- if (since !== null && (!/^\d{4}-\d{2}-\d{2}/.test(since) || Number.isNaN(Date.parse(since))))
97643
- return c.json({ error: "since must be an ISO date or timestamp" }, 400);
97644
- return c.json(computeStats(ctx.db, since === null ? null : new Date(since).toISOString()));
97645
- });
97646
- }
97647
-
97648
97793
  // src/server/routes/verify.ts
97649
97794
  import { readFileSync as readFileSync133, realpathSync as realpathSync36 } from "fs";
97650
97795
  import { createPublicKey as createPublicKey8 } from "crypto";
@@ -97733,7 +97878,7 @@ function mount21(ctx) {
97733
97878
  }
97734
97879
 
97735
97880
  // src/server/routes/index.ts
97736
- var routeModules = [mount, mount3, mount2, mount7, mount9, mount20, mount10, mount5, mount11, mount12, mount14, mount6, mount13, mount15, mount8, mount19, mount21, mount16, mount18, mount4, mount17];
97881
+ var routeModules = [mount2, mount4, mount3, mount8, mount10, mount, mount11, mount6, mount12, mount13, mount15, mount7, mount14, mount16, mount9, mount20, mount21, mount17, mount19, mount5, mount18];
97737
97882
  function registerRoutes(ctx) {
97738
97883
  mountRepos(ctx.act, ctx.db, ctx.peerIsLoopback, ctx.repoDir, ctx.ghImpl);
97739
97884
  for (const m of routeModules)