loki-mode 11.110.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.
- package/README.md +1 -1
- package/SKILL.md +2 -2
- package/VERSION +1 -1
- package/dashboard/__init__.py +1 -1
- package/docs/CLI-REFERENCE.md +1 -1
- package/docs/INSTALLATION.md +1 -1
- package/docs/v10/GUIDE.md +4 -3
- package/loki-ts/dist/loki.js +1403 -1398
- package/mcp/__init__.py +1 -1
- package/package.json +2 -2
- package/packages/control-plane/dist/ask-tools-server.js +138 -91
- package/packages/control-plane/dist/server.js +338 -258
- package/packages/control-plane/drizzle/0007_outcome_metrics.sql +7 -0
- package/packages/control-plane/drizzle/meta/0007_snapshot.json +846 -0
- package/packages/control-plane/drizzle/meta/_journal.json +7 -0
- package/packages/control-plane/src/db/schema.ts +6 -1
- package/packages/control-plane/src/server/routes/cost.ts +18 -17
- package/packages/control-plane/src/server/routes/stats.ts +172 -13
- package/packages/control-plane/src/server/runs.ts +24 -8
- package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
- package/web-app/dist/assets/{AdminPage-D4cF1rIZ.js → AdminPage-CVhdjm4W.js} +1 -1
- package/web-app/dist/assets/{Avatar-BzP8tfUm.js → Avatar-BAKmd47w.js} +1 -1
- package/web-app/dist/assets/{Badge-DHiXrt2w.js → Badge-DeSidjNE.js} +1 -1
- package/web-app/dist/assets/{Button-VW_O8cPs.js → Button-Bsq--imw.js} +1 -1
- package/web-app/dist/assets/{CockpitPage-DjkhEbWq.js → CockpitPage-C4OmZ7Zs.js} +1 -1
- package/web-app/dist/assets/{ComparePage-DLlVSZRD.js → ComparePage-DxCOUyuK.js} +1 -1
- package/web-app/dist/assets/{ErrorBoundary-lVnlq_o6.js → ErrorBoundary-C-eJidjw.js} +1 -1
- package/web-app/dist/assets/{EvidenceReceiptPanel-DKTIY04g.js → EvidenceReceiptPanel-CbB-uoq8.js} +1 -1
- package/web-app/dist/assets/{GitHubIssuesPanel-BzEuZ8ci.js → GitHubIssuesPanel-Co8PJAFZ.js} +1 -1
- package/web-app/dist/assets/{GitHubPRsPanel-l2cGea-l.js → GitHubPRsPanel-BW2MHXtE.js} +1 -1
- package/web-app/dist/assets/{HomePage-Dr8vp_3u.js → HomePage-DB-Wva5X.js} +2 -2
- package/web-app/dist/assets/{LoginPage-CgbDB5yk.js → LoginPage-Wjb8beuu.js} +1 -1
- package/web-app/dist/assets/{MagicPage-413ACFN7.js → MagicPage-BwcUZUxN.js} +1 -1
- package/web-app/dist/assets/{MetricsPage-BUZnmN6f.js → MetricsPage-H3cTQAvY.js} +1 -1
- package/web-app/dist/assets/{NotFoundPage-DMwCpNo-.js → NotFoundPage-BNjC-8et.js} +1 -1
- package/web-app/dist/assets/{ProjectPage-D2PXm_Z2.js → ProjectPage-Dq62Dui3.js} +3 -3
- package/web-app/dist/assets/{ProjectsPage-C4Z6bs4h.js → ProjectsPage-CDpxlwjA.js} +1 -1
- package/web-app/dist/assets/{SettingsPage-B7U5W_zb.js → SettingsPage-nnJWzqjY.js} +1 -1
- package/web-app/dist/assets/{ShowcasePage-BowJuTpb.js → ShowcasePage-CTUAcngH.js} +1 -1
- package/web-app/dist/assets/{SystemSettingsPage-Cwg3jmaI.js → SystemSettingsPage-DTO5IQ0Y.js} +1 -1
- package/web-app/dist/assets/{TeamsPage-MFqradkQ.js → TeamsPage-B5TUplzs.js} +1 -1
- package/web-app/dist/assets/{TemplatesPage-DxlIsCpO.js → TemplatesPage-BMNxOv3x.js} +1 -1
- package/web-app/dist/assets/{TerminalOutput-5KpPXY2s.js → TerminalOutput-eqTWN6Av.js} +1 -1
- package/web-app/dist/assets/{activity-CK7Th554.js → activity-CIMlAuUK.js} +1 -1
- package/web-app/dist/assets/{bell-Da2vUkgy.js → bell-CWtJHfAz.js} +1 -1
- package/web-app/dist/assets/{bot-ZYBMnjxr.js → bot-CrxNs6o2.js} +1 -1
- package/web-app/dist/assets/{check-DDvtqnGn.js → check-0bXjNAw7.js} +1 -1
- package/web-app/dist/assets/{chevron-left-CWzC5TPz.js → chevron-left-B7-IUQne.js} +1 -1
- package/web-app/dist/assets/{circle-alert-Cy3pK14a.js → circle-alert-dx8_xe86.js} +1 -1
- package/web-app/dist/assets/{clock-CSJ_03ek.js → clock-BSMlFAwd.js} +1 -1
- package/web-app/dist/assets/{cloud-00d8dA8K.js → cloud-y26Fcv_n.js} +1 -1
- package/web-app/dist/assets/{code-xml-CvvQVSmh.js → code-xml-BRBN2bH_.js} +1 -1
- package/web-app/dist/assets/{database-SRoWkIl2.js → database-kDCennrN.js} +1 -1
- package/web-app/dist/assets/{dollar-sign-U4VZlNqY.js → dollar-sign-LiubOfVU.js} +1 -1
- package/web-app/dist/assets/{file-code-corner-CbTMgHZT.js → file-code-corner-CwZtgXkV.js} +1 -1
- package/web-app/dist/assets/{file-plus-Do8T6r6c.js → file-plus-SKxkfS4a.js} +1 -1
- package/web-app/dist/assets/{globe-C3NyfavU.js → globe-B7BRExHz.js} +1 -1
- package/web-app/dist/assets/{hammer-xRLjuRRo.js → hammer-COp7qN6_.js} +1 -1
- package/web-app/dist/assets/{index-qz83Pq2m.js → index-CgI_tsxE.js} +3 -3
- package/web-app/dist/assets/{layers-JPZePf7u.js → layers-CgcOGlBN.js} +1 -1
- package/web-app/dist/assets/{loader-circle-VGGdjbyB.js → loader-circle-CDl-iT1r.js} +1 -1
- package/web-app/dist/assets/{lock-Cmu-pxmX.js → lock-CPXrrOS0.js} +1 -1
- package/web-app/dist/assets/{package-CsR7U7E0.js → package-B411mlKL.js} +1 -1
- package/web-app/dist/assets/{plus-ACxpSzwa.js → plus-C_roRS0B.js} +1 -1
- package/web-app/dist/assets/{refresh-cw-DEUod6qB.js → refresh-cw-CEtX5fuV.js} +1 -1
- package/web-app/dist/assets/{rotate-ccw-BEUC0FCQ.js → rotate-ccw-ToeHrGzx.js} +1 -1
- package/web-app/dist/assets/{scroll-text-CDEBT5kW.js → scroll-text-B5KRnTyG.js} +1 -1
- package/web-app/dist/assets/{server-CA-yxQGN.js → server-CzJmSSgp.js} +1 -1
- package/web-app/dist/assets/{shield-alert-cxvAEv6s.js → shield-alert-HA5VCG0H.js} +1 -1
- package/web-app/dist/assets/{thumbs-up-iN79euHQ.js → thumbs-up-5VTo5laU.js} +1 -1
- package/web-app/dist/assets/{trash-2-DAKpXlI3.js → trash-2-BK-8D9Bf.js} +1 -1
- package/web-app/dist/assets/{trending-down-BETPoZ1b.js → trending-down-CKKI5Lp8.js} +1 -1
- package/web-app/dist/assets/{trending-up-RT8Y4bH1.js → trending-up-jCqitD_J.js} +1 -1
- package/web-app/dist/assets/{upload-DfDke1nO.js → upload-DWWoHUBE.js} +1 -1
- package/web-app/dist/assets/{usePolling-ap6dAXry.js → usePolling-C0ZWDmbJ.js} +1 -1
- package/web-app/dist/assets/{user-D--LOGSn.js → user-oPFolEsb.js} +1 -1
- 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,
|
|
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
|
|
3308
|
+
let count2 = 0;
|
|
3309
3309
|
for (const item of node.items) {
|
|
3310
3310
|
const c = getAliasCount(doc, item, anchors2);
|
|
3311
|
-
if (c >
|
|
3312
|
-
|
|
3311
|
+
if (c > count2)
|
|
3312
|
+
count2 = c;
|
|
3313
3313
|
}
|
|
3314
|
-
return
|
|
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,
|
|
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
|
|
6125
|
+
let count2 = 1;
|
|
6126
6126
|
const end = error.linePos[1];
|
|
6127
6127
|
if (end?.line === line2 && end.col > col) {
|
|
6128
|
-
|
|
6128
|
+
count2 = Math.max(1, Math.min(end.col - col, 80 - ci2));
|
|
6129
6129
|
}
|
|
6130
|
-
const pointer = " ".repeat(ci2) + "^".repeat(
|
|
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
|
|
11546
|
-
if (
|
|
11547
|
-
section = kindOf(
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
12515
|
+
count2++;
|
|
12516
12516
|
pending++;
|
|
12517
12517
|
} else if (p) {
|
|
12518
12518
|
if (!pending) {
|
|
12519
12519
|
ids.push(p[1]);
|
|
12520
|
-
|
|
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
|
|
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,
|
|
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
|
|
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
|
|
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 [
|
|
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: ${
|
|
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: ${
|
|
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: ${
|
|
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",
|
|
17153
|
+
high: { selected: [...RAN_ALWAYS, "full test command", "full suite", REVIEWER_ITEM, "security scan"] }
|
|
17154
17154
|
};
|
|
17155
|
-
LOW_SKIPPED = ["full test command", "reviewer", "
|
|
17156
|
-
DEEP_ITEMS = ["full suite", "app boot", "
|
|
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} (${
|
|
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
|
|
21975
|
-
return `${
|
|
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
|
|
22041
|
-
if (
|
|
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
|
-
|
|
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:
|
|
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,
|
|
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: ${
|
|
26719
|
+
process.stderr.write(`writeback: ${label2} ${what} failed (HTTP ${r.status})
|
|
26720
26720
|
`);
|
|
26721
26721
|
} catch (e) {
|
|
26722
|
-
process.stderr.write(`writeback: ${
|
|
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
|
|
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
|
|
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,
|
|
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();
|
|
@@ -35226,7 +35226,7 @@ async function splitWithReask(d, slug, i, reason) {
|
|
|
35226
35226
|
return { ok: false, reason: `split call failed: ${e instanceof Error ? e.message : String(e)}` };
|
|
35227
35227
|
}
|
|
35228
35228
|
}
|
|
35229
|
-
async function runWithRetry(d, receiptsDir,
|
|
35229
|
+
async function runWithRetry(d, receiptsDir, label2, ref, opts, wt) {
|
|
35230
35230
|
for (let attempt = 0;; attempt++) {
|
|
35231
35231
|
const res = await d.runner(ref, { ...opts, ...wt ? { cwd: wt } : {} });
|
|
35232
35232
|
if (wt && res.runId)
|
|
@@ -35234,7 +35234,7 @@ async function runWithRetry(d, receiptsDir, label, ref, opts, wt) {
|
|
|
35234
35234
|
if (res.rc === 0 || attempt >= RATE_LIMIT_RETRIES || !isRateLimited(res.output))
|
|
35235
35235
|
return res;
|
|
35236
35236
|
const wait2 = calculateRateLimitBackoff(parseRetryAfter(res.output));
|
|
35237
|
-
d.out(`${
|
|
35237
|
+
d.out(`${label2} provider rate limit, retrying in ${wait2}s
|
|
35238
35238
|
`);
|
|
35239
35239
|
await d.sleep(wait2 * 1000);
|
|
35240
35240
|
}
|
|
@@ -37774,7 +37774,6 @@ var init_secure_scan = __esm(() => {
|
|
|
37774
37774
|
var exports_deep = {};
|
|
37775
37775
|
__export(exports_deep, {
|
|
37776
37776
|
stage: () => stage8,
|
|
37777
|
-
sessionCouncil: () => sessionCouncil,
|
|
37778
37777
|
runSecretScan: () => runSecretScan,
|
|
37779
37778
|
runFullSuite: () => runFullSuite,
|
|
37780
37779
|
runDeep: () => runDeep,
|
|
@@ -37785,36 +37784,6 @@ __export(exports_deep, {
|
|
|
37785
37784
|
import { copyFileSync as copyFileSync7, existsSync as existsSync85, mkdirSync as mkdirSync65, mkdtempSync as mkdtempSync15, rmSync as rmSync32, writeFileSync as writeFileSync62 } from "fs";
|
|
37786
37785
|
import { tmpdir as tmpdir20 } from "os";
|
|
37787
37786
|
import { dirname as dirname51, join as join121 } from "path";
|
|
37788
|
-
function sessionCouncil(sessions) {
|
|
37789
|
-
return { async run(input, signal) {
|
|
37790
|
-
const cwd = mkdtempSync15(join121(tmpdir20(), "loki-deep-council-"));
|
|
37791
|
-
try {
|
|
37792
|
-
writeFileSync62(join121(cwd, "diff.patch"), input.diff, "utf8");
|
|
37793
|
-
const r = await sessions.run({
|
|
37794
|
-
stage: "deep",
|
|
37795
|
-
tier: "development",
|
|
37796
|
-
iterationId: `${input.runId}-council`,
|
|
37797
|
-
limitS: COUNCIL_LIMIT_S,
|
|
37798
|
-
signal,
|
|
37799
|
-
cwd,
|
|
37800
|
-
disallowedTools: `${REVIEW_GUARD_DENYLIST},Bash`,
|
|
37801
|
-
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".`
|
|
37802
|
-
});
|
|
37803
|
-
if (r.killed || r.exit !== 0)
|
|
37804
|
-
throw new Error(`reviewer session ${r.killed ? "killed" : `exit ${r.exit}`}`);
|
|
37805
|
-
const text4 = (r.summary ?? "").trim();
|
|
37806
|
-
if (!text4)
|
|
37807
|
-
throw new Error("reviewer returned no review");
|
|
37808
|
-
const lines2 = text4.split(`
|
|
37809
|
-
`).map((l) => l.trim()), findings = lines2.filter((l) => l.startsWith("FINDING:"));
|
|
37810
|
-
if (findings.length === 0 && !lines2.includes("LGTM"))
|
|
37811
|
-
throw new Error("reviewer reply has no LGTM or FINDING: line");
|
|
37812
|
-
return { findings };
|
|
37813
|
-
} finally {
|
|
37814
|
-
rmSync32(cwd, { recursive: true, force: true });
|
|
37815
|
-
}
|
|
37816
|
-
} };
|
|
37817
|
-
}
|
|
37818
37787
|
async function runFullSuite(ctx, signal, opts, checks, notProven) {
|
|
37819
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))
|
|
37820
37789
|
return;
|
|
@@ -37879,35 +37848,6 @@ async function runAppBoot(ctx, opts, checks, notProven) {
|
|
|
37879
37848
|
notProven.add(`not run: ${c.name} (${c.reason ?? "no reason given"})`);
|
|
37880
37849
|
}
|
|
37881
37850
|
}
|
|
37882
|
-
async function runCouncilCheck(ctx, changed, baseSha, signal, opts, checks, notProven) {
|
|
37883
|
-
const codeFiles = changed.filter((f) => !f.endsWith(".md"));
|
|
37884
|
-
if (codeFiles.length === 0) {
|
|
37885
|
-
notProven.add("council (no non-doc changes to review)");
|
|
37886
|
-
return;
|
|
37887
|
-
}
|
|
37888
|
-
if (!opts.council) {
|
|
37889
|
-
notProven.add("council (not wired: see the contract-gap note in stages/deep.ts)");
|
|
37890
|
-
return;
|
|
37891
|
-
}
|
|
37892
|
-
const diffResult = await safeGitRun(ctx.repoDir, ["diff", "--no-color", baseSha, "HEAD", "--", ...codeFiles], { timeoutMs: 20000 });
|
|
37893
|
-
if (diffResult.exitCode !== 0 || !diffResult.stdout.trim()) {
|
|
37894
|
-
notProven.add("council (refused: empty or failed diff, nothing to review)");
|
|
37895
|
-
return;
|
|
37896
|
-
}
|
|
37897
|
-
const diff = diffResult.stdout;
|
|
37898
|
-
const maxBytes = opts.maxCouncilDiffBytes ?? MAX_COUNCIL_DIFF_BYTES;
|
|
37899
|
-
if (Buffer.byteLength(diff, "utf8") > maxBytes) {
|
|
37900
|
-
notProven.add("council (context oversized, refused)");
|
|
37901
|
-
return;
|
|
37902
|
-
}
|
|
37903
|
-
const started = Date.now();
|
|
37904
|
-
try {
|
|
37905
|
-
const outcome = await opts.council.run({ runId: ctx.runId, diff, files: codeFiles }, signal);
|
|
37906
|
-
checks.push({ name: "council", cmd: "dispatchClaudeAgents", result: "pass", duration_s: (Date.now() - started) / 1000 });
|
|
37907
|
-
} catch (err) {
|
|
37908
|
-
notProven.add(`council (refused: ${err.message})`);
|
|
37909
|
-
}
|
|
37910
|
-
}
|
|
37911
37851
|
async function runSecretScan(ctx, changed, opts, checks, notProven) {
|
|
37912
37852
|
const scriptPath = opts.secretScanShPath ?? DEFAULT_SECRET_SCAN_SH, name = "security scan", cmd2 = "secret-scan.sh + secure-scan.py";
|
|
37913
37853
|
if (!existsSync85(scriptPath)) {
|
|
@@ -38004,10 +37944,13 @@ async function runDeep(ctx, signal, opts = {}) {
|
|
|
38004
37944
|
const checks = [];
|
|
38005
37945
|
const notProven = new Set;
|
|
38006
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)}` });
|
|
38007
37951
|
await runAppBoot(ctx, opts, checks, notProven);
|
|
38008
|
-
await runCouncilCheck(ctx, changed, ctx.baseSha, signal, opts, checks, notProven);
|
|
38009
37952
|
await runSecretScan(ctx, changed, opts, checks, notProven);
|
|
38010
|
-
const statusState = checks.some((c) => c.result === "fail") ? "failure" : "success";
|
|
37953
|
+
const statusState = checks.some((c) => c.result === "fail" && !c.base_red) ? "failure" : "success";
|
|
38011
37954
|
const notProvenList = [...notProven].filter((n3) => !naNote(n3)), notApplicable = [...notProven].filter(naNote).map(naText);
|
|
38012
37955
|
const seal = ctx.outputs().seal;
|
|
38013
37956
|
const addendumBody = {
|
|
@@ -38065,9 +38008,8 @@ async function deepWorker(args, deps = {}) {
|
|
|
38065
38008
|
`);
|
|
38066
38009
|
return 1;
|
|
38067
38010
|
}
|
|
38068
|
-
const
|
|
38069
|
-
const
|
|
38070
|
-
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)")) };
|
|
38071
38013
|
const pinned = origin ? { pinnedOrigin: origin } : {};
|
|
38072
38014
|
const ctx = {
|
|
38073
38015
|
runId: runId2,
|
|
@@ -38091,7 +38033,7 @@ async function deepWorker(args, deps = {}) {
|
|
|
38091
38033
|
const ac = new AbortController;
|
|
38092
38034
|
for (const sig of ["SIGTERM", "SIGINT"])
|
|
38093
38035
|
process.once(sig, () => ac.abort());
|
|
38094
|
-
const r = await runDeep(ctx, ac.signal, {
|
|
38036
|
+
const r = await runDeep(ctx, ac.signal, { ...deps.opts });
|
|
38095
38037
|
process.stderr.write((await Promise.resolve().then(() => (init_base_guard(), exports_base_guard))).finishDeferredRun(repoDir, runId2));
|
|
38096
38038
|
if (r.status !== "completed") {
|
|
38097
38039
|
process.stderr.write(`engine10 deep-worker: ${r.reason ?? r.status}
|
|
@@ -38100,7 +38042,7 @@ async function deepWorker(args, deps = {}) {
|
|
|
38100
38042
|
}
|
|
38101
38043
|
return 0;
|
|
38102
38044
|
}
|
|
38103
|
-
var DEFAULT_SECRET_SCAN_SH,
|
|
38045
|
+
var DEFAULT_SECRET_SCAN_SH, FULL_SUITE_TIMEOUT_MS = 300000, deepStage, stage8;
|
|
38104
38046
|
var init_deep = __esm(() => {
|
|
38105
38047
|
init_install();
|
|
38106
38048
|
init_app_probe();
|
|
@@ -38116,14 +38058,13 @@ var init_deep = __esm(() => {
|
|
|
38116
38058
|
init_failures();
|
|
38117
38059
|
init_repo_profile();
|
|
38118
38060
|
init_types();
|
|
38119
|
-
init_claude_flags();
|
|
38120
38061
|
init_safe_git();
|
|
38121
38062
|
init_pr();
|
|
38122
38063
|
DEFAULT_SECRET_SCAN_SH = new URL("../../../../autonomy/lib/secret-scan.sh", import.meta.url).pathname;
|
|
38123
38064
|
deepStage = {
|
|
38124
38065
|
name: "deep",
|
|
38125
38066
|
...STAGE_BUDGETS.deep,
|
|
38126
|
-
run: (ctx, signal) => runDeep(ctx, signal
|
|
38067
|
+
run: (ctx, signal) => runDeep(ctx, signal)
|
|
38127
38068
|
};
|
|
38128
38069
|
stage8 = deepStage;
|
|
38129
38070
|
});
|
|
@@ -66988,7 +66929,7 @@ function Q9(e10, t) {
|
|
|
66988
66929
|
return null;
|
|
66989
66930
|
}
|
|
66990
66931
|
|
|
66991
|
-
class
|
|
66932
|
+
class r63 {
|
|
66992
66933
|
promise = null;
|
|
66993
66934
|
start() {
|
|
66994
66935
|
if (this.promise)
|
|
@@ -82284,7 +82225,7 @@ XA==
|
|
|
82284
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"]];
|
|
82285
82226
|
n9e = ["deniedModels", "blockedMarketplaces", ...Mc.map((e10) => `autoMode.${e10}`)];
|
|
82286
82227
|
o9e = [...xy, "forceLoginOrgUUID", "forceLoginMethod", "forceLoginGatewayUrl", "gatewayInternalNetworks", "parentSettingsBehavior", "env", "modelPicker", ...av, ...Oi];
|
|
82287
|
-
S9e = new
|
|
82228
|
+
S9e = new r63;
|
|
82288
82229
|
O9e = Object.freeze({ settings: {}, errors: [], loadState: "absent" });
|
|
82289
82230
|
Vc = Object.freeze({ settings: {}, errors: [] });
|
|
82290
82231
|
T9e = ["prependPlugins", "appendPlugins"];
|
|
@@ -93006,6 +92947,11 @@ var runs = sqliteTable("runs", {
|
|
|
93006
92947
|
tokenSessions: integer("token_sessions"),
|
|
93007
92948
|
inputTokens: integer("input_tokens").notNull(),
|
|
93008
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"),
|
|
93009
92955
|
wallS: real("wall_s"),
|
|
93010
92956
|
lastSeq: integer("last_seq").notNull(),
|
|
93011
92957
|
lastEventAt: text("last_event_at"),
|
|
@@ -93415,16 +93361,214 @@ function effectiveVerdict(r) {
|
|
|
93415
93361
|
return r.verdict;
|
|
93416
93362
|
}
|
|
93417
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
|
+
|
|
93418
93562
|
// src/server/runs.ts
|
|
93419
93563
|
var str = (x) => typeof x === "string" ? x : null;
|
|
93420
93564
|
function loadEvents(db, sourceId, runId) {
|
|
93421
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 }));
|
|
93422
93566
|
}
|
|
93423
|
-
|
|
93424
|
-
|
|
93425
|
-
|
|
93426
|
-
|
|
93427
|
-
const f = fold(
|
|
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);
|
|
93428
93572
|
const keys = pubkeysFromEnv();
|
|
93429
93573
|
const integ = verifyRunIntegrity(evs, { pubkeyFor: keys });
|
|
93430
93574
|
const tampered = f.run.tampered || integ.tampered;
|
|
@@ -93432,7 +93576,7 @@ function rebuildRun(db, sourceId, runId) {
|
|
|
93432
93576
|
const sd = f.run.started?.data ?? {};
|
|
93433
93577
|
const done = f.run.completed?.data ?? {};
|
|
93434
93578
|
const pr = evs.find((e) => e.type === "pr.opened")?.data;
|
|
93435
|
-
|
|
93579
|
+
return {
|
|
93436
93580
|
sourceId,
|
|
93437
93581
|
runId,
|
|
93438
93582
|
originRepo: str(sd.origin_repo),
|
|
@@ -93452,8 +93596,13 @@ function rebuildRun(db, sourceId, runId) {
|
|
|
93452
93596
|
measuredSessions: pc.measured,
|
|
93453
93597
|
totalSessions: pc.total,
|
|
93454
93598
|
tokenSessions: tampered ? null : evs.filter((e) => e.type === "cost" && typeof e.data.input_tokens === "number").length,
|
|
93455
|
-
inputTokens: f.cost.inputTokens
|
|
93599
|
+
inputTokens: f.cost.inputTokens,
|
|
93456
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),
|
|
93457
93606
|
wallS: typeof done.wall_s === "number" ? done.wall_s : null,
|
|
93458
93607
|
lastSeq: f.lastSeq,
|
|
93459
93608
|
lastEventAt: evs[evs.length - 1]?.ts ?? null,
|
|
@@ -93463,6 +93612,12 @@ function rebuildRun(db, sourceId, runId) {
|
|
|
93463
93612
|
integrityKeyFp: keys.fingerprint ?? "",
|
|
93464
93613
|
integrityReasons: JSON.stringify(integ.reasons)
|
|
93465
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);
|
|
93466
93621
|
db.insert(runs).values(row).onConflictDoUpdate({ target: [runs.sourceId, runs.runId], set: row }).run();
|
|
93467
93622
|
}
|
|
93468
93623
|
var reasonsOf = (j) => {
|
|
@@ -93495,6 +93650,12 @@ var parseRun = (r) => ({
|
|
|
93495
93650
|
token_sessions: r.tokenSessions,
|
|
93496
93651
|
input_tokens: r.inputTokens,
|
|
93497
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,
|
|
93498
93659
|
wall_s: r.wallS,
|
|
93499
93660
|
last_seq: r.lastSeq,
|
|
93500
93661
|
last_event_at: r.lastEventAt,
|
|
@@ -93881,7 +94042,7 @@ function readCapped(path) {
|
|
|
93881
94042
|
closeSync5(fd);
|
|
93882
94043
|
}
|
|
93883
94044
|
}
|
|
93884
|
-
function
|
|
94045
|
+
function mount2(ctx) {
|
|
93885
94046
|
const { app, act, db } = ctx;
|
|
93886
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();
|
|
93887
94048
|
app.get("/v1/runs/:source/:run/events", (c) => {
|
|
@@ -94696,7 +94857,7 @@ function createSse(opts) {
|
|
|
94696
94857
|
return new Response(body, { headers });
|
|
94697
94858
|
};
|
|
94698
94859
|
}
|
|
94699
|
-
function
|
|
94860
|
+
function mount3(ctx) {
|
|
94700
94861
|
const pollMs = num2(process.env.LOKI_CONTROL_STREAM_POLL_MS, 1000);
|
|
94701
94862
|
const heartbeatMs = num2(process.env.LOKI_CONTROL_STREAM_HEARTBEAT_MS, 15000);
|
|
94702
94863
|
const maxStreams = num2(process.env.LOKI_CONTROL_STREAM_MAX, 32);
|
|
@@ -94768,7 +94929,7 @@ var num3 = (v, d) => {
|
|
|
94768
94929
|
return Number.isFinite(n3) && n3 > 0 ? n3 : d;
|
|
94769
94930
|
};
|
|
94770
94931
|
var askEnabled = () => process.env.LOKI_CP_ASK === "1";
|
|
94771
|
-
function
|
|
94932
|
+
function mount4(ctx) {
|
|
94772
94933
|
const { app, db } = ctx;
|
|
94773
94934
|
markInterrupted(db, pidAlive);
|
|
94774
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) });
|
|
@@ -94941,7 +95102,7 @@ ${first.join("")}`, tick);
|
|
|
94941
95102
|
}
|
|
94942
95103
|
|
|
94943
95104
|
// src/server/routes/audit.ts
|
|
94944
|
-
function
|
|
95105
|
+
function mount5(ctx) {
|
|
94945
95106
|
ctx.app.get("/v1/audit", (c) => {
|
|
94946
95107
|
const limit = Math.min(Math.max(Number.parseInt(c.req.query("limit") ?? "50", 10) || 50, 1), 200);
|
|
94947
95108
|
const offset = Math.max(Number.parseInt(c.req.query("cursor") ?? "0", 10) || 0, 0);
|
|
@@ -94965,7 +95126,7 @@ import { existsSync as existsSync10, readdirSync as readdirSync8, readFileSync a
|
|
|
94965
95126
|
import { join as join22 } from "path";
|
|
94966
95127
|
var isNum2 = (v) => typeof v === "number" && Number.isFinite(v);
|
|
94967
95128
|
var isObj3 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
94968
|
-
var
|
|
95129
|
+
var r62 = (n3) => Math.round(n3 * 1e6) / 1e6;
|
|
94969
95130
|
var MEASURED_FIELDS = ["cost_usd", "input_tokens", "output_tokens", "cache_read_tokens", "cache_creation_tokens"];
|
|
94970
95131
|
var BUDGET_WARN_FRACTION = 0.8;
|
|
94971
95132
|
var NOT_MEASURED = "not measured";
|
|
@@ -95003,7 +95164,7 @@ function modelCost(table, model, inp, out, cr = 0, cw = 0) {
|
|
|
95003
95164
|
const or2 = isNum2(p.output) ? p.output : 15;
|
|
95004
95165
|
const crr = isNum2(p.cache_read) ? p.cache_read : ir * 0.1;
|
|
95005
95166
|
const cwr = isNum2(p.cache_write) ? p.cache_write : ir * 1.25;
|
|
95006
|
-
return
|
|
95167
|
+
return r62((inp * ir + out * or2 + cr * crr + cw * cwr) / 1e6);
|
|
95007
95168
|
}
|
|
95008
95169
|
function iterationRecords(lokiDir2) {
|
|
95009
95170
|
const dir = join22(lokiDir2, "metrics", "efficiency");
|
|
@@ -95090,7 +95251,7 @@ function costSnapshot(lokiDir2) {
|
|
|
95090
95251
|
const fmt = (m) => Object.fromEntries(Object.entries(m).map(([k, v]) => [k, {
|
|
95091
95252
|
input_tokens: v.tokens_measured ? v.input_tokens : null,
|
|
95092
95253
|
output_tokens: v.tokens_measured ? v.output_tokens : null,
|
|
95093
|
-
cost_usd: v.measured ?
|
|
95254
|
+
cost_usd: v.measured ? r62(v.cost_usd) : null
|
|
95094
95255
|
}]));
|
|
95095
95256
|
return {
|
|
95096
95257
|
total_input_tokens: recorded ? tIn : null,
|
|
@@ -95099,13 +95260,13 @@ function costSnapshot(lokiDir2) {
|
|
|
95099
95260
|
total_cache_creation_tokens: recorded ? tCw : null,
|
|
95100
95261
|
total_tokens: recorded ? tIn + tOut + tCr + tCw : null,
|
|
95101
95262
|
cache_hit_ratio: readIn > 0 ? Math.round(tCr / readIn * 1e4) / 1e4 : null,
|
|
95102
|
-
estimated_cost_usd: recorded && !unknownUsd ?
|
|
95263
|
+
estimated_cost_usd: recorded && !unknownUsd ? r62(est) : null,
|
|
95103
95264
|
cost_recorded: recorded,
|
|
95104
95265
|
by_phase: fmt(byPhase),
|
|
95105
95266
|
by_model: fmt(byModel),
|
|
95106
95267
|
budget_limit: limit,
|
|
95107
|
-
budget_used: limit !== null && used !== null ?
|
|
95108
|
-
budget_remaining: remaining !== null ?
|
|
95268
|
+
budget_used: limit !== null && used !== null ? r62(used) : null,
|
|
95269
|
+
budget_remaining: remaining !== null ? r62(remaining) : null,
|
|
95109
95270
|
...recorded ? {} : { not_measured: NOT_MEASURED }
|
|
95110
95271
|
};
|
|
95111
95272
|
}
|
|
@@ -95139,13 +95300,13 @@ function budgetSnapshot(lokiDir2) {
|
|
|
95139
95300
|
if (Number.isFinite(e))
|
|
95140
95301
|
limit = e;
|
|
95141
95302
|
}
|
|
95142
|
-
const used = recorded ?
|
|
95303
|
+
const used = recorded ? r62(total) : null;
|
|
95143
95304
|
const ok = limit !== null && limit > 0 && used !== null;
|
|
95144
95305
|
const status = budgetStatus(used, limit);
|
|
95145
95306
|
return {
|
|
95146
95307
|
limit,
|
|
95147
95308
|
used,
|
|
95148
|
-
remaining: ok ?
|
|
95309
|
+
remaining: ok ? r62(Math.max(0, limit - used)) : null,
|
|
95149
95310
|
percent_used: ok ? Math.round(used / limit * 1e4) / 100 : null,
|
|
95150
95311
|
status,
|
|
95151
95312
|
warn_threshold_percent: Math.round(BUDGET_WARN_FRACTION * 100),
|
|
@@ -95174,8 +95335,8 @@ function costTimeline(lokiDir2) {
|
|
|
95174
95335
|
provider: d.provider ?? null,
|
|
95175
95336
|
input_tokens: measured ? num0(d.input_tokens) : null,
|
|
95176
95337
|
output_tokens: measured ? num0(d.output_tokens) : null,
|
|
95177
|
-
cost_usd: measured ?
|
|
95178
|
-
cumulative_usd: measured ?
|
|
95338
|
+
cost_usd: measured ? r62(priced(table, d)) : null,
|
|
95339
|
+
cumulative_usd: measured ? r62(cum) : null
|
|
95179
95340
|
});
|
|
95180
95341
|
}
|
|
95181
95342
|
const runs2 = [];
|
|
@@ -95205,7 +95366,7 @@ function costTimeline(lokiDir2) {
|
|
|
95205
95366
|
run_id: p.run_id ?? e,
|
|
95206
95367
|
generated_at: p.generated_at ?? null,
|
|
95207
95368
|
model: isObj3(p.provider) ? p.provider.model ?? null : null,
|
|
95208
|
-
cost_usd: usd !== null ?
|
|
95369
|
+
cost_usd: usd !== null ? r62(usd) : null,
|
|
95209
95370
|
cost_partial: cost.cost_partial === true,
|
|
95210
95371
|
files_changed: isObj3(p.files_changed) ? p.files_changed.count ?? null : null,
|
|
95211
95372
|
final_verdict: isObj3(p.council) ? p.council.final_verdict ?? null : null
|
|
@@ -95213,10 +95374,10 @@ function costTimeline(lokiDir2) {
|
|
|
95213
95374
|
}
|
|
95214
95375
|
runs2.sort((a, b) => String(b.generated_at ?? "").localeCompare(String(a.generated_at ?? "")));
|
|
95215
95376
|
return {
|
|
95216
|
-
current_run: { iterations, total_usd: recorded ?
|
|
95377
|
+
current_run: { iterations, total_usd: recorded ? r62(cum) : null, cost_recorded: recorded, partial: recorded && unmeasured > 0, unmeasured_iterations: unmeasured },
|
|
95217
95378
|
runs: runs2,
|
|
95218
95379
|
runs_count: runs2.length,
|
|
95219
|
-
project_total_usd: runsMeasured ?
|
|
95380
|
+
project_total_usd: runsMeasured ? r62(projectTotal) : null,
|
|
95220
95381
|
project_total_partial: runsMeasured > 0 && runsMeasured < runs2.length,
|
|
95221
95382
|
budget: budgetSnapshot(lokiDir2),
|
|
95222
95383
|
...recorded || runsMeasured ? {} : { not_measured: NOT_MEASURED }
|
|
@@ -95224,7 +95385,7 @@ function costTimeline(lokiDir2) {
|
|
|
95224
95385
|
}
|
|
95225
95386
|
var lokiDirOf = (repoDir) => join22(repoDir, ".loki");
|
|
95226
95387
|
var lokiDirExists = (repoDir) => existsSync10(lokiDirOf(repoDir));
|
|
95227
|
-
function
|
|
95388
|
+
function mount6(ctx) {
|
|
95228
95389
|
const deny = { error: "loopback only without a token" };
|
|
95229
95390
|
ctx.app.get("/v1/cost/snapshot", (c) => probeAllowed(ctx, c) ? c.json(costSnapshot(lokiDirOf(ctx.repoDir))) : c.json(deny, 403));
|
|
95230
95391
|
ctx.app.get("/v1/cost/timeline", (c) => probeAllowed(ctx, c) ? c.json(costTimeline(lokiDirOf(ctx.repoDir))) : c.json(deny, 403));
|
|
@@ -95434,7 +95595,7 @@ var parseLimit = (v) => {
|
|
|
95434
95595
|
const n3 = Number.parseInt(v ?? "20", 10);
|
|
95435
95596
|
return Number.isFinite(n3) ? Math.min(Math.max(n3, 1), 200) : 20;
|
|
95436
95597
|
};
|
|
95437
|
-
function
|
|
95598
|
+
function mount7(ctx) {
|
|
95438
95599
|
const deny = { error: "loopback only without a token" };
|
|
95439
95600
|
const { app, act, db, repoDir } = ctx;
|
|
95440
95601
|
app.get("/v1/checkpoints", (c) => probeAllowed(ctx, c) ? c.json({ checkpoints: listCheckpoints(repoDir, parseLimit(c.req.query("limit"))) }) : c.json(deny, 403));
|
|
@@ -95544,7 +95705,7 @@ function originOk(origin) {
|
|
|
95544
95705
|
return false;
|
|
95545
95706
|
}
|
|
95546
95707
|
}
|
|
95547
|
-
function
|
|
95708
|
+
function mount8(ctx) {
|
|
95548
95709
|
const { act, db, repoDir, local } = ctx;
|
|
95549
95710
|
const inflight = new Set;
|
|
95550
95711
|
const handler = async (c) => {
|
|
@@ -95974,7 +96135,7 @@ function atomicWrite(file, text2, mode) {
|
|
|
95974
96135
|
}
|
|
95975
96136
|
var etagOf = (raw2) => `"${sha(raw2)}"`;
|
|
95976
96137
|
var norm = (h) => h ? h.trim().replace(/^W\//, "").replace(/^"|"$/g, "") : null;
|
|
95977
|
-
function
|
|
96138
|
+
function mount9(ctx) {
|
|
95978
96139
|
const { act, db, repoDir, local } = ctx;
|
|
95979
96140
|
const deny = (c, kind, status, error, extra = {}) => {
|
|
95980
96141
|
audit3(db, { kind, target: "loki.yaml", result: status === 409 ? "conflict" : status === 500 ? "error" : "refused", detail: error });
|
|
@@ -96104,7 +96265,7 @@ import { join as join25, resolve as resolve9, sep as sep8 } from "path";
|
|
|
96104
96265
|
init_run_pid();
|
|
96105
96266
|
var ID4 = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
96106
96267
|
var busy = new Set;
|
|
96107
|
-
function
|
|
96268
|
+
function mount10(ctx) {
|
|
96108
96269
|
const { act, db } = ctx;
|
|
96109
96270
|
const bin = ctx.startBin ?? "loki", spawnIt = ctx.spawnImpl ?? spawnStart, answerDir = ctx.answerDir ?? defaultAnswerDir();
|
|
96110
96271
|
const guarded = (kind, handler) => act.post(`/v1/runs/:source/:run/${kind}`, async (c) => {
|
|
@@ -96184,7 +96345,7 @@ function mount9(ctx) {
|
|
|
96184
96345
|
var COST_DIMS = ["day", "model", "repo", "provider"];
|
|
96185
96346
|
var DEFAULT_API_KEY_CAP_USD = 100;
|
|
96186
96347
|
var NONE = "unknown";
|
|
96187
|
-
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 });
|
|
96188
96349
|
var add2 = (a, r) => {
|
|
96189
96350
|
a.runs++;
|
|
96190
96351
|
if (r.costUsd !== null) {
|
|
@@ -96197,6 +96358,8 @@ var add2 = (a, r) => {
|
|
|
96197
96358
|
a.unmeasured_runs++;
|
|
96198
96359
|
a.input_tokens += r.inputTokens;
|
|
96199
96360
|
a.output_tokens += r.outputTokens;
|
|
96361
|
+
a.cache_read_tokens += r.cacheReadTokens;
|
|
96362
|
+
a.cache_creation_tokens += r.cacheCreationTokens;
|
|
96200
96363
|
if (r.tokenSessions !== null) {
|
|
96201
96364
|
a.tk += r.tokenSessions;
|
|
96202
96365
|
a.tn += r.totalSessions;
|
|
@@ -96204,31 +96367,26 @@ var add2 = (a, r) => {
|
|
|
96204
96367
|
};
|
|
96205
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;
|
|
96206
96369
|
var round = (n3) => Math.round(n3 * 1e6) / 1e6;
|
|
96207
|
-
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 } : {} });
|
|
96208
|
-
function
|
|
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) {
|
|
96209
96372
|
ctx.app.get("/v1/cost/repos", (c) => {
|
|
96210
96373
|
const g = new Map;
|
|
96211
96374
|
for (const r of ctx.db.select().from(runs).all()) {
|
|
96212
96375
|
const k = r.originRepo ?? "(unknown)";
|
|
96213
|
-
|
|
96214
|
-
|
|
96215
|
-
|
|
96216
|
-
|
|
96217
|
-
|
|
96218
|
-
|
|
96219
|
-
|
|
96220
|
-
|
|
96221
|
-
|
|
96222
|
-
|
|
96223
|
-
|
|
96224
|
-
|
|
96225
|
-
|
|
96226
|
-
|
|
96227
|
-
total_usd: round(a.usd),
|
|
96228
|
-
avg_usd: a.priced ? round(a.usd / a.priced) : null,
|
|
96229
|
-
verified_runs: a.verified,
|
|
96230
|
-
usd_per_verified: a.verified ? round(a.usd / a.verified) : null
|
|
96231
|
-
}));
|
|
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
|
+
});
|
|
96232
96390
|
return c.json({ rows });
|
|
96233
96391
|
});
|
|
96234
96392
|
ctx.app.get("/v1/stats/cost", (c) => {
|
|
@@ -96343,7 +96501,7 @@ function mapDoctor(raw2) {
|
|
|
96343
96501
|
throw new Error("loki doctor returned no usable checks");
|
|
96344
96502
|
return out2;
|
|
96345
96503
|
}
|
|
96346
|
-
function
|
|
96504
|
+
function mount12(ctx) {
|
|
96347
96505
|
const cached = ttlCache();
|
|
96348
96506
|
ctx.app.get("/v1/doctor", async (c) => {
|
|
96349
96507
|
if (!probeAllowed(ctx, c))
|
|
@@ -96469,7 +96627,7 @@ function fleetSummary(includeInactive = true, file = registryFile()) {
|
|
|
96469
96627
|
};
|
|
96470
96628
|
}
|
|
96471
96629
|
var parseInactive = (v) => !["false", "0", "no"].includes((v ?? "true").toLowerCase());
|
|
96472
|
-
function
|
|
96630
|
+
function mount13(ctx) {
|
|
96473
96631
|
const deny = { error: "loopback only without a token" };
|
|
96474
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));
|
|
96475
96633
|
ctx.app.get("/v1/fleet/summary", (c) => probeAllowed(ctx, c) ? c.json(fleetSummary(parseInactive(c.req.query("include_inactive")))) : c.json(deny, 403));
|
|
@@ -96710,7 +96868,7 @@ function contextTracking(loki) {
|
|
|
96710
96868
|
return { status: 500, body: { error: "Failed to read context tracking data" } };
|
|
96711
96869
|
}
|
|
96712
96870
|
}
|
|
96713
|
-
function
|
|
96871
|
+
function mount14(ctx) {
|
|
96714
96872
|
const deny = { error: "loopback only without a token" };
|
|
96715
96873
|
const read = (path, fn) => ctx.app.get(path, (c) => probeAllowed(ctx, c) ? fn(c, lokiFor(ctx.repoDir)) : c.json(deny, 403));
|
|
96716
96874
|
read("/v1/tasks", (c, l) => {
|
|
@@ -96868,7 +97026,7 @@ function buildMetricsText(repoDir, now2 = Date.now()) {
|
|
|
96868
97026
|
`) + `
|
|
96869
97027
|
`;
|
|
96870
97028
|
}
|
|
96871
|
-
function
|
|
97029
|
+
function mount15(ctx) {
|
|
96872
97030
|
ctx.app.get("/v1/metrics", (c) => {
|
|
96873
97031
|
if (!probeAllowed(ctx, c))
|
|
96874
97032
|
return c.json({ error: "loopback only without a token" }, 403);
|
|
@@ -97045,7 +97203,7 @@ function councilTranscripts(loki, q) {
|
|
|
97045
97203
|
return { transcripts: out2, total: out2.length, latest_id: out2.length ? out2[0].iteration_id : null };
|
|
97046
97204
|
}
|
|
97047
97205
|
var intQ = (v, max) => v === undefined ? undefined : /^\d+$/.test(v) && Number(v) <= max ? Number(v) : null;
|
|
97048
|
-
function
|
|
97206
|
+
function mount16(ctx) {
|
|
97049
97207
|
const deny = { error: "loopback only without a token" };
|
|
97050
97208
|
const loki = () => lokiDirOf(ctx.repoDir);
|
|
97051
97209
|
ctx.act.post("/v1/control/:action", (c) => {
|
|
@@ -97200,7 +97358,7 @@ async function listIntegrations(repoDir, gh = () => ghAuthed()) {
|
|
|
97200
97358
|
});
|
|
97201
97359
|
return rows;
|
|
97202
97360
|
}
|
|
97203
|
-
function
|
|
97361
|
+
function mount17(ctx) {
|
|
97204
97362
|
const cached = ttlCache();
|
|
97205
97363
|
ctx.app.get("/v1/integrations", async (c) => {
|
|
97206
97364
|
if (!probeAllowed(ctx, c))
|
|
@@ -97303,7 +97461,7 @@ function parseRisk(out2) {
|
|
|
97303
97461
|
return null;
|
|
97304
97462
|
}
|
|
97305
97463
|
}
|
|
97306
|
-
function
|
|
97464
|
+
function mount18(ctx) {
|
|
97307
97465
|
const { act, db } = ctx;
|
|
97308
97466
|
const bin = () => ctx.startBin ?? process.env["LOKI_BIN"] ?? "loki";
|
|
97309
97467
|
const busy2 = new Set;
|
|
@@ -97329,7 +97487,7 @@ function mount17(ctx) {
|
|
|
97329
97487
|
const wantReal = real3(want);
|
|
97330
97488
|
if (wantReal && known.has(wantReal))
|
|
97331
97489
|
return wantReal;
|
|
97332
|
-
const named = [...known].filter(([r,
|
|
97490
|
+
const named = [...known].filter(([r, label2]) => label2 === want || basename7(r) === want).map(([r]) => r);
|
|
97333
97491
|
return named.length === 1 ? named[0] : null;
|
|
97334
97492
|
};
|
|
97335
97493
|
const slot = async (c, kind, auditKind, fn) => {
|
|
@@ -97507,7 +97665,7 @@ function deriveNotifications(db) {
|
|
|
97507
97665
|
}
|
|
97508
97666
|
return out2.sort((a, b) => a.ts < b.ts ? 1 : a.ts > b.ts ? -1 : a.id < b.id ? -1 : 1);
|
|
97509
97667
|
}
|
|
97510
|
-
function
|
|
97668
|
+
function mount19(ctx) {
|
|
97511
97669
|
ctx.app.get("/v1/notifications", (c) => {
|
|
97512
97670
|
const all = deriveNotifications(ctx.db);
|
|
97513
97671
|
const limit = Math.min(Math.max(Number.parseInt(c.req.query("limit") ?? "50", 10) || 50, 1), 200);
|
|
@@ -97621,7 +97779,7 @@ async function listProviders(timeoutMs = DEFAULT_TIMEOUT_MS2) {
|
|
|
97621
97779
|
}));
|
|
97622
97780
|
return { providers: rows, catalog_updated: cat.updated, probe_timeout_ms: timeoutMs };
|
|
97623
97781
|
}
|
|
97624
|
-
function
|
|
97782
|
+
function mount20(ctx) {
|
|
97625
97783
|
const cached = ttlCache();
|
|
97626
97784
|
ctx.app.get("/v1/providers", async (c) => {
|
|
97627
97785
|
if (!probeAllowed(ctx, c))
|
|
@@ -97632,84 +97790,6 @@ function mount19(ctx) {
|
|
|
97632
97790
|
});
|
|
97633
97791
|
}
|
|
97634
97792
|
|
|
97635
|
-
// src/server/routes/stats.ts
|
|
97636
|
-
function computeStats(db, since) {
|
|
97637
|
-
const all = db.select().from(runs).all().filter((r) => !since || r.startedAt !== null && r.startedAt >= since);
|
|
97638
|
-
const by = {};
|
|
97639
|
-
let finished = 0, running = 0, blocked = 0, verified = 0, unchecked = 0, failed2 = 0, satisfied = 0, other = 0;
|
|
97640
|
-
let mUsd = 0, mRuns = 0, pUsd = 0, pRuns = 0;
|
|
97641
|
-
for (const r of all) {
|
|
97642
|
-
if (r.endedAt)
|
|
97643
|
-
finished++;
|
|
97644
|
-
else
|
|
97645
|
-
running++;
|
|
97646
|
-
const verdict = r.verdict ? effectiveVerdict({ verdict: r.verdict, tampered: r.tampered === 1, attested: r.attested === 1, sig_checked: r.sigChecked === 1 }) : null;
|
|
97647
|
-
if (verdict) {
|
|
97648
|
-
by[verdict] = (by[verdict] ?? 0) + 1;
|
|
97649
|
-
if (r.endedAt) {
|
|
97650
|
-
if (verdict === "VERIFIED")
|
|
97651
|
-
verified++;
|
|
97652
|
-
else if (verdict === "VERIFIED (signature not checked)")
|
|
97653
|
-
unchecked++;
|
|
97654
|
-
else if (verdict === "ALREADY_SATISFIED" || verdict === "ALREADY_SATISFIED (signature not checked)")
|
|
97655
|
-
satisfied++;
|
|
97656
|
-
else if (verdict === "FAILED" || verdict === "PARTIAL" || verdict === "TAMPERED")
|
|
97657
|
-
failed2++;
|
|
97658
|
-
else
|
|
97659
|
-
other++;
|
|
97660
|
-
}
|
|
97661
|
-
}
|
|
97662
|
-
if (r.verdict === "SPEC_CONFLICT")
|
|
97663
|
-
blocked++;
|
|
97664
|
-
if (r.costUsd !== null) {
|
|
97665
|
-
mUsd += r.costUsd;
|
|
97666
|
-
mRuns++;
|
|
97667
|
-
} else if (r.totalSessions > 0) {
|
|
97668
|
-
pUsd += r.partialUsd;
|
|
97669
|
-
pRuns++;
|
|
97670
|
-
}
|
|
97671
|
-
}
|
|
97672
|
-
const keys = new Set(all.map((r) => `${r.sourceId}/${r.runId}`));
|
|
97673
|
-
let total = 0, signed = 0;
|
|
97674
|
-
for (const e of db.select({ s: events.sourceId, r: events.runId, data: events.data }).from(events).where(eq(events.type, "receipt.sealed")).all()) {
|
|
97675
|
-
if (!keys.has(`${e.s}/${e.r}`))
|
|
97676
|
-
continue;
|
|
97677
|
-
total++;
|
|
97678
|
-
if (e.data?.signed === true)
|
|
97679
|
-
signed++;
|
|
97680
|
-
}
|
|
97681
|
-
const r62 = (n3) => Math.round(n3 * 1e6) / 1e6;
|
|
97682
|
-
return {
|
|
97683
|
-
since,
|
|
97684
|
-
runs_total: all.length,
|
|
97685
|
-
runs_finished: finished,
|
|
97686
|
-
runs_running: running,
|
|
97687
|
-
by_verdict: by,
|
|
97688
|
-
blocked_waiting: blocked,
|
|
97689
|
-
verified_rate: verified + unchecked + failed2 ? verified / (verified + unchecked + failed2) : null,
|
|
97690
|
-
breakdown: { verified, failed: failed2, already_satisfied: satisfied, other },
|
|
97691
|
-
verified_unchecked: unchecked,
|
|
97692
|
-
keys_configured: pubkeysFromEnv().configured === true,
|
|
97693
|
-
...pubkeysFromEnv().reason ? { keys_reason: pubkeysFromEnv().reason } : {},
|
|
97694
|
-
cost: {
|
|
97695
|
-
measured_usd: mRuns ? r62(mUsd) : null,
|
|
97696
|
-
measured_runs: mRuns,
|
|
97697
|
-
partial_usd: pRuns ? r62(pUsd) : null,
|
|
97698
|
-
partial_runs: pRuns,
|
|
97699
|
-
label: pRuns ? "partial" : mRuns ? "measured" : "not measured"
|
|
97700
|
-
},
|
|
97701
|
-
receipts: { total, signed }
|
|
97702
|
-
};
|
|
97703
|
-
}
|
|
97704
|
-
function mount20(ctx) {
|
|
97705
|
-
ctx.app.get("/v1/stats", (c) => {
|
|
97706
|
-
const since = c.req.query("since") ?? null;
|
|
97707
|
-
if (since !== null && (!/^\d{4}-\d{2}-\d{2}/.test(since) || Number.isNaN(Date.parse(since))))
|
|
97708
|
-
return c.json({ error: "since must be an ISO date or timestamp" }, 400);
|
|
97709
|
-
return c.json(computeStats(ctx.db, since === null ? null : new Date(since).toISOString()));
|
|
97710
|
-
});
|
|
97711
|
-
}
|
|
97712
|
-
|
|
97713
97793
|
// src/server/routes/verify.ts
|
|
97714
97794
|
import { readFileSync as readFileSync133, realpathSync as realpathSync36 } from "fs";
|
|
97715
97795
|
import { createPublicKey as createPublicKey8 } from "crypto";
|
|
@@ -97798,7 +97878,7 @@ function mount21(ctx) {
|
|
|
97798
97878
|
}
|
|
97799
97879
|
|
|
97800
97880
|
// src/server/routes/index.ts
|
|
97801
|
-
var routeModules = [
|
|
97881
|
+
var routeModules = [mount2, mount4, mount3, mount8, mount10, mount, mount11, mount6, mount12, mount13, mount15, mount7, mount14, mount16, mount9, mount20, mount21, mount17, mount19, mount5, mount18];
|
|
97802
97882
|
function registerRoutes(ctx) {
|
|
97803
97883
|
mountRepos(ctx.act, ctx.db, ctx.peerIsLoopback, ctx.repoDir, ctx.ghImpl);
|
|
97804
97884
|
for (const m of routeModules)
|