loki-mode 11.141.3 → 11.141.4
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/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/dev/architecture-reference.md +6 -1
- package/loki-ts/dist/loki.js +1688 -1680
- package/mcp/__init__.py +1 -1
- package/package.json +2 -2
- package/packages/control-plane/dist/server.js +644 -254
- package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
- package/web-app/dist/assets/{AdminPage-CXYutD4P.js → AdminPage-Dkj5FgZn.js} +1 -1
- package/web-app/dist/assets/{Avatar-DtQv32ei.js → Avatar-D6ZOMRQj.js} +1 -1
- package/web-app/dist/assets/{Badge-B0OEiGWj.js → Badge-przKIrx7.js} +1 -1
- package/web-app/dist/assets/{Button-DAxRHI93.js → Button-X5VdLM9H.js} +1 -1
- package/web-app/dist/assets/{CockpitPage-B9Hi4roF.js → CockpitPage-CWUPO4jE.js} +1 -1
- package/web-app/dist/assets/{ComparePage-BFCQ2npD.js → ComparePage-jinxUAH3.js} +1 -1
- package/web-app/dist/assets/{ErrorBoundary-iD00UcjA.js → ErrorBoundary-B3o_toch.js} +1 -1
- package/web-app/dist/assets/{EvidenceReceiptPanel-B76dpKnO.js → EvidenceReceiptPanel-ClySg933.js} +1 -1
- package/web-app/dist/assets/{GitHubIssuesPanel-B5-pxBUX.js → GitHubIssuesPanel-Dm_UsFAy.js} +1 -1
- package/web-app/dist/assets/{GitHubPRsPanel-Cz8MDVpH.js → GitHubPRsPanel-FAkViqVu.js} +1 -1
- package/web-app/dist/assets/{HomePage-RN8tGnly.js → HomePage-VeVb73XG.js} +2 -2
- package/web-app/dist/assets/{LoginPage-3bgx6JO5.js → LoginPage-BpEKt-6l.js} +1 -1
- package/web-app/dist/assets/{MagicPage-Csph1itx.js → MagicPage-CNC180dU.js} +1 -1
- package/web-app/dist/assets/{MetricsPage-C-gpg5dg.js → MetricsPage-BIfpdlcf.js} +1 -1
- package/web-app/dist/assets/{NotFoundPage-D_2iaSIZ.js → NotFoundPage-D54hg346.js} +1 -1
- package/web-app/dist/assets/{ProjectPage-sOWNmoyz.js → ProjectPage-Dl3rZ5bV.js} +3 -3
- package/web-app/dist/assets/{ProjectsPage-Bcj1zeOK.js → ProjectsPage-DzQrB1jU.js} +1 -1
- package/web-app/dist/assets/{SettingsPage-V3PvBKXt.js → SettingsPage-DYB5XNpM.js} +1 -1
- package/web-app/dist/assets/{ShowcasePage-Dgnx6rqF.js → ShowcasePage-CjhoM3rN.js} +1 -1
- package/web-app/dist/assets/{SystemSettingsPage-CYwtNhot.js → SystemSettingsPage-BVNnfllD.js} +1 -1
- package/web-app/dist/assets/{TeamsPage-zE5VGlot.js → TeamsPage-1KkrFd0Y.js} +1 -1
- package/web-app/dist/assets/{TemplatesPage-ByMfvWWy.js → TemplatesPage-DGDnu_RB.js} +1 -1
- package/web-app/dist/assets/{TerminalOutput-DWlKNNgH.js → TerminalOutput-DSomtLgf.js} +1 -1
- package/web-app/dist/assets/{activity-E89Nv0Gn.js → activity-CW1VLglI.js} +1 -1
- package/web-app/dist/assets/{bell-F5OLNHAS.js → bell-tJAz56Yb.js} +1 -1
- package/web-app/dist/assets/{bot-BgMvMeIE.js → bot-B6I5yrNn.js} +1 -1
- package/web-app/dist/assets/{check-DDjMmGIx.js → check-IVM56fVX.js} +1 -1
- package/web-app/dist/assets/{chevron-left-DOuYhQj3.js → chevron-left-SsA1da21.js} +1 -1
- package/web-app/dist/assets/{circle-alert-4RB4dTkg.js → circle-alert-Dsq3DqO-.js} +1 -1
- package/web-app/dist/assets/{clock-CuPAeSjR.js → clock-Cj9sLcEq.js} +1 -1
- package/web-app/dist/assets/{cloud-BMbPHSHB.js → cloud-CSbZsshu.js} +1 -1
- package/web-app/dist/assets/{code-xml-DM3_SytH.js → code-xml-qCQWXElP.js} +1 -1
- package/web-app/dist/assets/{database-Dg6mN6Ow.js → database-BnviiGuk.js} +1 -1
- package/web-app/dist/assets/{dollar-sign-B614dJTB.js → dollar-sign-DaU9xa0A.js} +1 -1
- package/web-app/dist/assets/{file-code-corner-Dl4JdVpI.js → file-code-corner-a393d0YD.js} +1 -1
- package/web-app/dist/assets/{file-plus-BInei2Fp.js → file-plus-C3J3IYsn.js} +1 -1
- package/web-app/dist/assets/{globe-D9dhwBk0.js → globe-DKRN-OfP.js} +1 -1
- package/web-app/dist/assets/{hammer-DkHCWudw.js → hammer-AJ4xEMEQ.js} +1 -1
- package/web-app/dist/assets/{index-CGg-uQi6.js → index-BmuNF2mZ.js} +3 -3
- package/web-app/dist/assets/{layers-D7FRJ2Cg.js → layers-ZxK3Lg-E.js} +1 -1
- package/web-app/dist/assets/{loader-circle-DWu2xFyT.js → loader-circle-BQGio77U.js} +1 -1
- package/web-app/dist/assets/{lock-DtQ7UEiT.js → lock-BSMOsGRv.js} +1 -1
- package/web-app/dist/assets/{package-D-uGJ1YH.js → package-Dc3iyh_u.js} +1 -1
- package/web-app/dist/assets/{plus-BfTkHz42.js → plus-BE-oSyaC.js} +1 -1
- package/web-app/dist/assets/{refresh-cw-BXeJY2sm.js → refresh-cw-B24IKBF1.js} +1 -1
- package/web-app/dist/assets/{rotate-ccw-CSugG-Ae.js → rotate-ccw-Cm9OyY5g.js} +1 -1
- package/web-app/dist/assets/{scroll-text-DRwM3FIU.js → scroll-text-gdM4zNkj.js} +1 -1
- package/web-app/dist/assets/{server-CClk8rzC.js → server-B8YzsGPg.js} +1 -1
- package/web-app/dist/assets/{shield-alert-xtO3fBXY.js → shield-alert-COu4qEAn.js} +1 -1
- package/web-app/dist/assets/{thumbs-up-DbWHOFPx.js → thumbs-up-Bs3ZSrCN.js} +1 -1
- package/web-app/dist/assets/{trash-2-CYZZlWrP.js → trash-2-vdl0RPBK.js} +1 -1
- package/web-app/dist/assets/{trending-down-DUl7D2qn.js → trending-down-DhxJxyuC.js} +1 -1
- package/web-app/dist/assets/{trending-up-CgDQ9rvV.js → trending-up-sBLyeLVo.js} +1 -1
- package/web-app/dist/assets/{upload-DuB3Cd-6.js → upload-B_SYHnav.js} +1 -1
- package/web-app/dist/assets/{usePolling-u10dSbx_.js → usePolling-CLtoYkMM.js} +1 -1
- package/web-app/dist/assets/{user-CUl0PWOM.js → user-CIt72Y0w.js} +1 -1
- package/web-app/dist/index.html +1 -1
|
@@ -16554,6 +16554,7 @@ __export(exports_repo_profile, {
|
|
|
16554
16554
|
runFormatters: () => runFormatters,
|
|
16555
16555
|
runBaseline: () => runBaseline,
|
|
16556
16556
|
rmNewUntracked: () => rmNewUntracked,
|
|
16557
|
+
repoRelCmd: () => repoRelCmd,
|
|
16557
16558
|
repoReadiness: () => repoReadiness,
|
|
16558
16559
|
renderProfile: () => renderProfile,
|
|
16559
16560
|
redactEvidence: () => redactEvidence,
|
|
@@ -16564,6 +16565,7 @@ __export(exports_repo_profile, {
|
|
|
16564
16565
|
profileEnabled: () => profileEnabled,
|
|
16565
16566
|
profileBrief: () => profileBrief,
|
|
16566
16567
|
pickRunnable: () => pickRunnable,
|
|
16568
|
+
oneBaseRunOn: () => oneBaseRunOn,
|
|
16567
16569
|
manifestModel: () => manifestModel,
|
|
16568
16570
|
manifestHash: () => manifestHash,
|
|
16569
16571
|
loadProfile: () => loadProfile,
|
|
@@ -16598,7 +16600,7 @@ __export(exports_repo_profile, {
|
|
|
16598
16600
|
});
|
|
16599
16601
|
import { createHash as createHash14 } from "crypto";
|
|
16600
16602
|
import { spawnSync as spawnSync4 } from "child_process";
|
|
16601
|
-
import { existsSync as existsSync35, lstatSync as lstatSync12, readFileSync as readFileSync49, mkdirSync as mkdirSync21, readdirSync as readdirSync23, renameSync as renameSync13, rmSync as rmSync10, writeFileSync as writeFileSync22 } from "fs";
|
|
16603
|
+
import { existsSync as existsSync35, lstatSync as lstatSync12, readFileSync as readFileSync49, mkdirSync as mkdirSync21, readdirSync as readdirSync23, realpathSync as realpathSync15, renameSync as renameSync13, rmSync as rmSync10, writeFileSync as writeFileSync22 } from "fs";
|
|
16602
16604
|
import { basename as basename14, dirname as dirname19, join as join56, relative as relative3, resolve as resolve15, isAbsolute as isAbsolute2 } from "path";
|
|
16603
16605
|
function num5(env, name, fallback) {
|
|
16604
16606
|
const raw2 = env[name];
|
|
@@ -17069,6 +17071,19 @@ function runBaseline(repoDir, commands, opts = {}) {
|
|
|
17069
17071
|
t.note = "command not found";
|
|
17070
17072
|
return b;
|
|
17071
17073
|
}
|
|
17074
|
+
function repoRelCmd(repoDir, cmd, env = process.env) {
|
|
17075
|
+
const c = normCmd(cmd);
|
|
17076
|
+
if (!oneBaseRunOn(env) || !repoDir)
|
|
17077
|
+
return c;
|
|
17078
|
+
const dirs = [repoDir.replace(/\/+$/, "")];
|
|
17079
|
+
try {
|
|
17080
|
+
dirs.push(realpathSync15(repoDir));
|
|
17081
|
+
} catch {}
|
|
17082
|
+
for (const d of [...new Set(dirs.flatMap((x) => [x, x.startsWith("/private/") ? x.slice("/private".length) : `/private${x}`]))])
|
|
17083
|
+
if (c.startsWith(`${d}/`))
|
|
17084
|
+
return normCmd(c.slice(d.length + 1));
|
|
17085
|
+
return c;
|
|
17086
|
+
}
|
|
17072
17087
|
function sameRootScript(repoDir, a, b, env = process.env) {
|
|
17073
17088
|
if (env.LOKI_BASELINE_SCRIPT_ALIAS === "0")
|
|
17074
17089
|
return false;
|
|
@@ -17084,7 +17099,7 @@ function sameRootScript(repoDir, a, b, env = process.env) {
|
|
|
17084
17099
|
}
|
|
17085
17100
|
function baseFor(repoDir, p, cmd, ranOnly) {
|
|
17086
17101
|
const all = [p.baseline, ...p.suites ?? []].filter((b) => !ranOnly || b.ran);
|
|
17087
|
-
return all.find((b) => normCmd(b.command ?? "") === normCmd(cmd)) ?? ((!ranOnly || p.baseline.ran) && sameRootScript(repoDir, p.baseline.command ?? "", cmd) ? p.baseline : undefined);
|
|
17102
|
+
return all.find((b) => normCmd(b.command ?? "") === normCmd(cmd)) ?? all.find((b) => repoRelCmd(repoDir, b.command ?? "") === repoRelCmd(repoDir, cmd)) ?? ((!ranOnly || p.baseline.ran) && sameRootScript(repoDir, p.baseline.command ?? "", cmd) ? p.baseline : undefined);
|
|
17088
17103
|
}
|
|
17089
17104
|
function baselineSuites(repoDir, specs, opts = {}) {
|
|
17090
17105
|
try {
|
|
@@ -17096,7 +17111,7 @@ function baselineSuites(repoDir, specs, opts = {}) {
|
|
|
17096
17111
|
p.baseline = runBaseline(repoDir, p.commands, opts.deadlineMs === undefined ? opts : { ...opts, timeoutS: Math.max(1, Math.min(opts.timeoutS ?? BASELINE_CMD_TIMEOUT_S, dl())) });
|
|
17097
17112
|
let left = Math.min(opts.budgetS ?? SUITE_BASELINE_BUDGET_S, dl());
|
|
17098
17113
|
const old = p.suites ?? [];
|
|
17099
|
-
const rootSpeaks = (run2) =>
|
|
17114
|
+
const rootSpeaks = (run2) => repoRelCmd(repoDir, run2) === repoRelCmd(repoDir, p.baseline.command ?? "") || p.baseline.ran && p.baseline.attributable && !p.baseline.timed_out && sameRootScript(repoDir, p.baseline.command ?? "", run2);
|
|
17100
17115
|
p.suites = specs.filter((s) => s.cwd !== "." || !rootSpeaks(s.run)).map((s) => {
|
|
17101
17116
|
const prev = old.find((o) => o.command === s.cmd);
|
|
17102
17117
|
if (prev?.ran && !opts.rerun && !cutShort(prev, Math.min(opts.timeoutS ?? BASELINE_CMD_TIMEOUT_S, Math.floor(left))) && (prev.failing_ids.length === 0 || prev.failing_errors && prev.flaky_probe !== undefined))
|
|
@@ -17123,7 +17138,7 @@ function suiteEmptyOnBase(repoDir, baseSha, line2, name, cls, out2, cwd = ".") {
|
|
|
17123
17138
|
const p = baseSha ? loadProfile(repoDir) : null;
|
|
17124
17139
|
if (!p || p.revision !== baseSha || !emptyDiscovery(cls, out2))
|
|
17125
17140
|
return false;
|
|
17126
|
-
const e = p.suites?.find((x) => x.command === name) ?? (cwd === "." && (
|
|
17141
|
+
const e = p.suites?.find((x) => x.command === name) ?? (cwd === "." && (repoRelCmd(repoDir, p.baseline.command ?? "") === repoRelCmd(repoDir, line2) || sameRootScript(repoDir, p.baseline.command ?? "", line2)) ? p.baseline : undefined);
|
|
17127
17142
|
return e?.ran === true && e.exit_code === 0 && e.zero_tests === true;
|
|
17128
17143
|
}
|
|
17129
17144
|
function writeBaselineRecord(repoDir, runDir) {
|
|
@@ -17575,7 +17590,7 @@ ${r.stderr ?? ""}`), missing: r.status === 127 };
|
|
|
17575
17590
|
for (const f of untracked(repoDir))
|
|
17576
17591
|
if (!before.has(f))
|
|
17577
17592
|
rmSync10(join56(repoDir, f), { force: true, recursive: true });
|
|
17578
|
-
}, FLAKE_PROBE_MAX_S = 120, MASSIVE_RED_IDS = 500, normCmd = (s) => s.replace(/\s+--silent\b/, "").trim().replace(/^\(cd \.\s+&&\s+(.+)\)$/, "$1"), PM_SCRIPT, SUITE_BASELINE_BUDGET_S = 300, headOf = (repoDir) => {
|
|
17593
|
+
}, FLAKE_PROBE_MAX_S = 120, MASSIVE_RED_IDS = 500, normCmd = (s) => s.replace(/\s+--silent\b/, "").trim().replace(/^\(cd \.\s+&&\s+(.+)\)$/, "$1"), oneBaseRunOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_ONE_BASE_RUN"] ?? "").trim()), PM_SCRIPT, SUITE_BASELINE_BUDGET_S = 300, headOf = (repoDir) => {
|
|
17579
17594
|
try {
|
|
17580
17595
|
return safeGit(repoDir, ["rev-parse", "HEAD"]).trim();
|
|
17581
17596
|
} catch {
|
|
@@ -17653,7 +17668,7 @@ var init_runner_errors = __esm(() => {
|
|
|
17653
17668
|
|
|
17654
17669
|
// ../../loki-ts/src/runner/load_owner.ts
|
|
17655
17670
|
import { spawnSync as spawnSync5 } from "child_process";
|
|
17656
|
-
import { mkdtempSync as mkdtempSync5, realpathSync as
|
|
17671
|
+
import { mkdtempSync as mkdtempSync5, realpathSync as realpathSync16, rmSync as rmSync11 } from "fs";
|
|
17657
17672
|
import { tmpdir as tmpdir8 } from "os";
|
|
17658
17673
|
import { basename as basename15, extname as extname2, join as join57 } from "path";
|
|
17659
17674
|
function changedFilesNamed(out2, repoDir, changed) {
|
|
@@ -17675,7 +17690,7 @@ function loadSignature(out2, roots) {
|
|
|
17675
17690
|
let o = out2;
|
|
17676
17691
|
for (const r of roots.flatMap((x) => {
|
|
17677
17692
|
try {
|
|
17678
|
-
return [x,
|
|
17693
|
+
return [x, realpathSync16(x)];
|
|
17679
17694
|
} catch {
|
|
17680
17695
|
return [x];
|
|
17681
17696
|
}
|
|
@@ -18021,7 +18036,7 @@ var init_package_suite = __esm(() => {
|
|
|
18021
18036
|
// ../../loki-ts/src/project_model/install.ts
|
|
18022
18037
|
import { spawn as spawn8 } from "child_process";
|
|
18023
18038
|
import { createHash as createHash15 } from "crypto";
|
|
18024
|
-
import { existsSync as existsSync37, lstatSync as lstatSync13, readFileSync as readFileSync51, readlinkSync, realpathSync as
|
|
18039
|
+
import { existsSync as existsSync37, lstatSync as lstatSync13, readFileSync as readFileSync51, readlinkSync, realpathSync as realpathSync17 } from "fs";
|
|
18025
18040
|
import { dirname as dirname20, isAbsolute as isAbsolute4, join as join59, relative as relative5 } from "path";
|
|
18026
18041
|
function optedOut(repoDir, env) {
|
|
18027
18042
|
if (env["LOKI_E10_INSTALL"] === "0")
|
|
@@ -18162,7 +18177,7 @@ function runDetached(cmd, cwd, env, signal, timeoutMs) {
|
|
|
18162
18177
|
});
|
|
18163
18178
|
}
|
|
18164
18179
|
function lockDir(repoDir, cwd, rule) {
|
|
18165
|
-
const top =
|
|
18180
|
+
const top = realpathSync17(repoDir), start = realpathSync17(cwd);
|
|
18166
18181
|
if (rule.locks.some((n3) => existsSync37(join59(start, n3))))
|
|
18167
18182
|
return start;
|
|
18168
18183
|
if (!rule.ws)
|
|
@@ -18201,7 +18216,7 @@ function lockedInstall(repoDir, cwd, modelCmd) {
|
|
|
18201
18216
|
const lastSemi = parts.reduce((m, p, k) => k % 2 === 1 && /[;\n]/.test(p) ? k : m, -1);
|
|
18202
18217
|
let later = false;
|
|
18203
18218
|
const notes = [];
|
|
18204
|
-
let hits = 0, locked = true, rewritten = false, cur =
|
|
18219
|
+
let hits = 0, locked = true, rewritten = false, cur = realpathSync17(cwd);
|
|
18205
18220
|
const out2 = parts.map((seg, k) => {
|
|
18206
18221
|
if (k % 2 === 1)
|
|
18207
18222
|
return seg;
|
|
@@ -18211,7 +18226,7 @@ function lockedInstall(repoDir, cwd, modelCmd) {
|
|
|
18211
18226
|
const env = w.slice(0, e);
|
|
18212
18227
|
if (tool === "cd") {
|
|
18213
18228
|
try {
|
|
18214
|
-
cur = cur !== null && w.length === e + 2 && !/[$~`*]/.test(w[e + 1]) && !w[e + 1].startsWith("-") ?
|
|
18229
|
+
cur = cur !== null && w.length === e + 2 && !/[$~`*]/.test(w[e + 1]) && !w[e + 1].startsWith("-") ? realpathSync17(join59(cur, w[e + 1])) : null;
|
|
18215
18230
|
} catch {
|
|
18216
18231
|
cur = null;
|
|
18217
18232
|
}
|
|
@@ -18319,8 +18334,8 @@ async function prepareDeps(input) {
|
|
|
18319
18334
|
}
|
|
18320
18335
|
let cwd;
|
|
18321
18336
|
try {
|
|
18322
|
-
cwd =
|
|
18323
|
-
const rel = relative5(
|
|
18337
|
+
cwd = realpathSync17(join59(input.repoDir, mc.cwd));
|
|
18338
|
+
const rel = relative5(realpathSync17(input.repoDir), cwd);
|
|
18324
18339
|
if (isAbsolute4(mc.cwd) || rel.startsWith("..") || isAbsolute4(rel)) {
|
|
18325
18340
|
notRun(`install cwd ${mc.cwd} resolves outside the repo`);
|
|
18326
18341
|
continue;
|
|
@@ -18342,9 +18357,9 @@ async function prepareDeps(input) {
|
|
|
18342
18357
|
}
|
|
18343
18358
|
const uvNeed = r.code !== 0 && !r.cut && uvRequiredOn() ? UV_REQUIRED.exec(r.tail) : null, uvCmd = uvNeed ? uvRequiredCmd(li.cmd, uvNeed[1]) : null;
|
|
18344
18359
|
if (uvCmd) {
|
|
18345
|
-
const ws = uvWorkspaceRoot(
|
|
18360
|
+
const ws = uvWorkspaceRoot(realpathSync17(input.repoDir), cwd), at = ws ?? cwd;
|
|
18346
18361
|
r = await runDetached(uvCmd, at, env, input.signal, Math.max(1, budget - (Date.now() - t0)));
|
|
18347
|
-
li = { ...li, cmd: uvCmd, note: `${li.note ? `${li.note}; ` : ""}the repo requires uv ${uvNeed[1]} and the host has an older uv: ran it with uvx${ws && ws !== cwd ? ` at the uv workspace root (${relative5(
|
|
18362
|
+
li = { ...li, cmd: uvCmd, note: `${li.note ? `${li.note}; ` : ""}the repo requires uv ${uvNeed[1]} and the host has an older uv: ran it with uvx${ws && ws !== cwd ? ` at the uv workspace root (${relative5(realpathSync17(input.repoDir), ws) || "."})` : ""}` };
|
|
18348
18363
|
}
|
|
18349
18364
|
const dt = (Date.now() - t0) / 1000;
|
|
18350
18365
|
left -= Date.now() - t0;
|
|
@@ -18604,13 +18619,54 @@ function regenDrops(runDir, staged, task, changedLines, env = process.env) {
|
|
|
18604
18619
|
return [];
|
|
18605
18620
|
const kw = [...taskKeywords2(task)];
|
|
18606
18621
|
return staged.filter(({ st, f }) => {
|
|
18607
|
-
if (!(st === "A" || st === "M") || !regen.has(f) || f.startsWith(".loki/") || task
|
|
18622
|
+
if (!(st === "A" || st === "M") || !regen.has(f) || f.startsWith(".loki/") || taskNamesPath(task, f))
|
|
18608
18623
|
return false;
|
|
18624
|
+
if (st === "A")
|
|
18625
|
+
return true;
|
|
18609
18626
|
const lines = changedLines(f).join(`
|
|
18610
18627
|
`);
|
|
18611
18628
|
return !kw.some((w) => lines.includes(w));
|
|
18612
18629
|
});
|
|
18613
18630
|
}
|
|
18631
|
+
function guardRegenDrops(repoDir, baseSha, picked, breaks) {
|
|
18632
|
+
if (!picked.length)
|
|
18633
|
+
return { dropped: [], kept: [] };
|
|
18634
|
+
const saved = picked.map(({ f }) => {
|
|
18635
|
+
try {
|
|
18636
|
+
return { f, b: readFileSync52(join60(repoDir, f)) };
|
|
18637
|
+
} catch {
|
|
18638
|
+
return { f, b: null };
|
|
18639
|
+
}
|
|
18640
|
+
});
|
|
18641
|
+
const toBase = () => {
|
|
18642
|
+
for (const { st, f } of picked) {
|
|
18643
|
+
try {
|
|
18644
|
+
if (st === "M")
|
|
18645
|
+
safeGit(repoDir, ["--literal-pathspecs", "checkout", "-q", baseSha, "--", f]);
|
|
18646
|
+
else
|
|
18647
|
+
rmSync12(join60(repoDir, f), { force: true });
|
|
18648
|
+
} catch {}
|
|
18649
|
+
}
|
|
18650
|
+
};
|
|
18651
|
+
toBase();
|
|
18652
|
+
let red = true;
|
|
18653
|
+
try {
|
|
18654
|
+
red = breaks();
|
|
18655
|
+
} catch {
|
|
18656
|
+
red = true;
|
|
18657
|
+
}
|
|
18658
|
+
if (!red)
|
|
18659
|
+
return { dropped: picked, kept: [] };
|
|
18660
|
+
for (const { f, b } of saved) {
|
|
18661
|
+
if (b === null)
|
|
18662
|
+
continue;
|
|
18663
|
+
try {
|
|
18664
|
+
mkdirSync22(dirname21(join60(repoDir, f)), { recursive: true });
|
|
18665
|
+
writeFileSync23(join60(repoDir, f), b);
|
|
18666
|
+
} catch {}
|
|
18667
|
+
}
|
|
18668
|
+
return { dropped: [], kept: picked };
|
|
18669
|
+
}
|
|
18614
18670
|
function formattingOnly(f, base, head) {
|
|
18615
18671
|
if (base === head)
|
|
18616
18672
|
return false;
|
|
@@ -18681,14 +18737,22 @@ function commitUnsealedWork(intact, repoDir, workerEnv, runId, intake) {
|
|
|
18681
18737
|
g(["--literal-pathspecs", "reset", "-q", "HEAD", "--", ...keep]);
|
|
18682
18738
|
const base = intake["base_sha"], task = typeof intake["task"] === "string" ? intake["task"] : undefined;
|
|
18683
18739
|
const staged = parseStaged(g(["diff", "--cached", "--name-status", "--no-renames", "-z", base])), mine = new Set(keep);
|
|
18684
|
-
const
|
|
18740
|
+
const runDir = join60(repoDir, ".loki", "runs", runId), regenWip = regenDrops(runDir, staged.filter(({ f }) => !mine.has(f)), task ?? "", (f) => {
|
|
18741
|
+
try {
|
|
18742
|
+
return safeGit(repoDir, ["diff", "--no-color", "-U0", base, "--", f], { env: workerEnv }).split(`
|
|
18743
|
+
`).filter((l) => /^[+-](?![+-]{2})/.test(l));
|
|
18744
|
+
} catch {
|
|
18745
|
+
return [];
|
|
18746
|
+
}
|
|
18747
|
+
});
|
|
18748
|
+
const churn = [...dropSet(repoDir, staged, intake["preexisting_dirty"], workerEnv, intake["install_created"], intake["preexisting_untracked_blobs"], base, task), ...regenWip.filter(({ f }) => !mine.has(f))].filter(({ st, f }) => st !== "L" && !f.startsWith(".loki/") && (!commitWallEnabled() || !WALL_FILE.test(f)) && !mine.has(f) && staged.some((s) => s.f === f && (s.st === "M" || s.st === "A")));
|
|
18685
18749
|
if (churn.length > 0)
|
|
18686
18750
|
g(["--literal-pathspecs", "reset", "-q", base, "--", ...churn.map(({ f }) => f)]);
|
|
18687
18751
|
const modified = churn.filter(({ f }) => staged.find((x) => x.f === f)?.st === "M").map(({ f }) => f);
|
|
18688
18752
|
if (modified.length > 0)
|
|
18689
18753
|
g(["--literal-pathspecs", "checkout", "-q", base, "--", ...modified]);
|
|
18690
18754
|
for (const { f } of churn) {
|
|
18691
|
-
if (staged.find((x) => x.f === f)?.st === "A" && (LOCKFILE_RE.test(f) || WALL_FILE.test(f))) {
|
|
18755
|
+
if (staged.find((x) => x.f === f)?.st === "A" && (LOCKFILE_RE.test(f) || WALL_FILE.test(f) || regenWip.some((r) => r.f === f))) {
|
|
18692
18756
|
try {
|
|
18693
18757
|
const p = join60(repoDir, f);
|
|
18694
18758
|
if (lstatSync14(p).isFile())
|
|
@@ -18718,7 +18782,7 @@ var WALL_FILE, parseStaged = (out2) => out2.split("\x00").reduce((a, t, i, all)
|
|
|
18718
18782
|
} catch {
|
|
18719
18783
|
return [];
|
|
18720
18784
|
}
|
|
18721
|
-
}, regenDropNote = (f) => `rewritten only by Loki's own check run, not by the change, and left out of the commit: ${f}`, diffNeedOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_DIFF_NEED"] ?? "").trim()), WS_SIGNIFICANT, SUPPRESS, suppressionOnly = (base, head) => base !== head && base.replace(SUPPRESS, "").replace(/[ \t]+$/gm, "").replace(/\n{2,}/g, `
|
|
18785
|
+
}, taskNamesPath = (task, f) => task.includes(f) || task.includes(basename16(f)), regenDropNote = (f) => `rewritten only by Loki's own check run, not by the change, and left out of the commit: ${f}`, regenKeptNote = (f) => `rewritten by Loki's own check run and kept: a targeted test fails without it: ${f}`, diffNeedOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_DIFF_NEED"] ?? "").trim()), WS_SIGNIFICANT, SUPPRESS, suppressionOnly = (base, head) => base !== head && base.replace(SUPPRESS, "").replace(/[ \t]+$/gm, "").replace(/\n{2,}/g, `
|
|
18722
18786
|
`) === head.replace(SUPPRESS, "").replace(/[ \t]+$/gm, "").replace(/\n{2,}/g, `
|
|
18723
18787
|
`), needDropNote = (d) => `${d.why} left out of the delivered diff: ${d.f}`, buildArtifactNotes = (repoDir, droppedAdded, baseSha, task) => {
|
|
18724
18788
|
const s = new Set([...buildArtifactDropEnabled() ? buildArtifacts(repoDir, droppedAdded, baseSha, task) : [], ...runOutputDropEnabled() ? runOutputs(repoDir, droppedAdded, baseSha, task) : []]);
|
|
@@ -19035,7 +19099,7 @@ var init_config_fence = __esm(() => {
|
|
|
19035
19099
|
});
|
|
19036
19100
|
|
|
19037
19101
|
// ../../loki-ts/src/runner/host_guard.ts
|
|
19038
|
-
import { appendFileSync as appendFileSync6, mkdirSync as mkdirSync24, realpathSync as
|
|
19102
|
+
import { appendFileSync as appendFileSync6, mkdirSync as mkdirSync24, realpathSync as realpathSync18 } from "fs";
|
|
19039
19103
|
import { isAbsolute as isAbsolute6, join as join62, resolve as resolve17, sep as sep11 } from "path";
|
|
19040
19104
|
function hookTimeoutSeconds(env = process.env) {
|
|
19041
19105
|
const raw2 = env["LOKI_HOOK_TIMEOUT"] ?? "";
|
|
@@ -19117,7 +19181,7 @@ function scriptRuleMayApply(command, env = process.env) {
|
|
|
19117
19181
|
}
|
|
19118
19182
|
function realpathOrNull(p) {
|
|
19119
19183
|
try {
|
|
19120
|
-
return
|
|
19184
|
+
return realpathSync18(p);
|
|
19121
19185
|
} catch {
|
|
19122
19186
|
return null;
|
|
19123
19187
|
}
|
|
@@ -19339,7 +19403,7 @@ var init_scope = __esm(() => {
|
|
|
19339
19403
|
});
|
|
19340
19404
|
|
|
19341
19405
|
// ../../loki-ts/src/util/python.ts
|
|
19342
|
-
import { accessSync as accessSync2, constants, existsSync as existsSync40, mkdtempSync as mkdtempSync6, readFileSync as readFileSync54, realpathSync as
|
|
19406
|
+
import { accessSync as accessSync2, constants, existsSync as existsSync40, mkdtempSync as mkdtempSync6, readFileSync as readFileSync54, realpathSync as realpathSync19, rmSync as rmSync14, statSync as statSync22 } from "fs";
|
|
19343
19407
|
import { isAbsolute as isAbsolute7, join as join63, relative as relative7 } from "path";
|
|
19344
19408
|
import { spawnSync as spawnSync6 } from "child_process";
|
|
19345
19409
|
import { tmpdir as tmpdir9 } from "os";
|
|
@@ -19542,7 +19606,7 @@ function spawnPytest(pythonBin, repoDir, timeoutMs, extra, withJunit) {
|
|
|
19542
19606
|
try {
|
|
19543
19607
|
let root = repoDir;
|
|
19544
19608
|
try {
|
|
19545
|
-
root =
|
|
19609
|
+
root = realpathSync19(repoDir);
|
|
19546
19610
|
} catch {}
|
|
19547
19611
|
const res = spawnSync6(pythonBin, [
|
|
19548
19612
|
"-m",
|
|
@@ -19630,7 +19694,7 @@ function pytestPython(root) {
|
|
|
19630
19694
|
function projectInterpreter(root) {
|
|
19631
19695
|
const ve = process.env["VIRTUAL_ENV"], inRepo = (p) => {
|
|
19632
19696
|
try {
|
|
19633
|
-
const r = relative7(
|
|
19697
|
+
const r = relative7(realpathSync19(root), realpathSync19(p));
|
|
19634
19698
|
return r !== "" && !r.startsWith("..") && !isAbsolute7(r);
|
|
19635
19699
|
} catch {
|
|
19636
19700
|
return false;
|
|
@@ -20076,7 +20140,7 @@ import {
|
|
|
20076
20140
|
openSync as openSync12,
|
|
20077
20141
|
readFileSync as readFileSync56,
|
|
20078
20142
|
readlinkSync as readlinkSync2,
|
|
20079
|
-
realpathSync as
|
|
20143
|
+
realpathSync as realpathSync20,
|
|
20080
20144
|
rmSync as rmSync15,
|
|
20081
20145
|
symlinkSync,
|
|
20082
20146
|
unlinkSync as unlinkSync7,
|
|
@@ -20648,15 +20712,169 @@ import { join as join67 } from "path";
|
|
|
20648
20712
|
function weakensTest(baseText, newText) {
|
|
20649
20713
|
return count2(ASSERT_RE, newText) < count2(ASSERT_RE, baseText) || count2(CASE_RE, newText) < count2(CASE_RE, baseText) || count2(SKIP_RE, newText) > count2(SKIP_RE, baseText) || count2(SETUP_RE, newText) > count2(SETUP_RE, baseText);
|
|
20650
20714
|
}
|
|
20651
|
-
function testFileWeakened(repoDir, baseSha, headSha, rel, status) {
|
|
20715
|
+
function testFileWeakened(repoDir, baseSha, headSha, rel, status, task = "") {
|
|
20652
20716
|
if (status === "D" || status === "T")
|
|
20653
20717
|
return true;
|
|
20654
20718
|
try {
|
|
20655
|
-
|
|
20719
|
+
const base = safeGit(repoDir, ["show", `${baseSha}:${rel}`]), head = headSha === null ? readFileSync58(join67(repoDir, rel), "utf8") : safeGit(repoDir, ["show", `${headSha}:${rel}`]);
|
|
20720
|
+
if (!weakensTest(base, head))
|
|
20721
|
+
return false;
|
|
20722
|
+
return !weakenExcuseOn() || excusedEdit(repoDir, baseSha, headSha, rel, base, head, task) === null;
|
|
20656
20723
|
} catch {
|
|
20657
20724
|
return true;
|
|
20658
20725
|
}
|
|
20659
20726
|
}
|
|
20727
|
+
function weakenExcuse(repoDir, baseSha, headSha, rel, task = "") {
|
|
20728
|
+
if (!weakenExcuseOn())
|
|
20729
|
+
return null;
|
|
20730
|
+
try {
|
|
20731
|
+
const base = safeGit(repoDir, ["show", `${baseSha}:${rel}`]), head = headSha === null ? readFileSync58(join67(repoDir, rel), "utf8") : safeGit(repoDir, ["show", `${headSha}:${rel}`]);
|
|
20732
|
+
return weakensTest(base, head) ? excusedEdit(repoDir, baseSha, headSha, rel, base, head, task) : null;
|
|
20733
|
+
} catch {
|
|
20734
|
+
return null;
|
|
20735
|
+
}
|
|
20736
|
+
}
|
|
20737
|
+
function taskAsksUpdate(task, title) {
|
|
20738
|
+
for (let i = task.indexOf(title);i >= 0; i = task.indexOf(title, i + 1))
|
|
20739
|
+
if (UPDATE_ASK_RE.test(task.slice(Math.max(0, i - 200), i + title.length + 200)))
|
|
20740
|
+
return true;
|
|
20741
|
+
return false;
|
|
20742
|
+
}
|
|
20743
|
+
function hunksOf(patch) {
|
|
20744
|
+
return [...patch.matchAll(/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/gm)].map((m) => ({ b0: Number(m[1]), bn: m[2] === undefined ? 1 : Number(m[2]), h0: Number(m[3]), hn: m[4] === undefined ? 1 : Number(m[4]) }));
|
|
20745
|
+
}
|
|
20746
|
+
function caseHolding(lines, from, to) {
|
|
20747
|
+
let start = -1;
|
|
20748
|
+
for (let i = Math.min(from, lines.length) - 1;i >= 0; i--) {
|
|
20749
|
+
if (CASE_START_RE.test(lines[i])) {
|
|
20750
|
+
start = i;
|
|
20751
|
+
break;
|
|
20752
|
+
}
|
|
20753
|
+
if (ANY_CASE_RE.test(lines[i]) && i < from - 1)
|
|
20754
|
+
return null;
|
|
20755
|
+
}
|
|
20756
|
+
if (start < 0)
|
|
20757
|
+
return null;
|
|
20758
|
+
let end = lines.length;
|
|
20759
|
+
for (let i = start + 1;i < lines.length; i++)
|
|
20760
|
+
if (ANY_CASE_RE.test(lines[i])) {
|
|
20761
|
+
end = i;
|
|
20762
|
+
break;
|
|
20763
|
+
}
|
|
20764
|
+
if (to > end)
|
|
20765
|
+
return null;
|
|
20766
|
+
for (let i = from - 1;i < Math.min(to, lines.length); i++)
|
|
20767
|
+
if (i !== start && ANY_CASE_RE.test(lines[i]))
|
|
20768
|
+
return null;
|
|
20769
|
+
return { title: CASE_START_RE.exec(lines[start])[2], start, end };
|
|
20770
|
+
}
|
|
20771
|
+
function excusedEdit(repoDir, baseSha, headSha, rel, base, head, task) {
|
|
20772
|
+
if (count2(CASE_RE, head) < count2(CASE_RE, base) || count2(SKIP_RE, head) > count2(SKIP_RE, base))
|
|
20773
|
+
return null;
|
|
20774
|
+
const why = [];
|
|
20775
|
+
const patch = safeGit(repoDir, headSha ? ["diff", "-U0", "--no-color", `${baseSha}:${rel}`, `${headSha}:${rel}`] : ["diff", "-U0", "--no-color", baseSha, "--", rel]);
|
|
20776
|
+
const hunks = hunksOf(patch);
|
|
20777
|
+
if (hunks.length === 0)
|
|
20778
|
+
return null;
|
|
20779
|
+
const bl = base.split(`
|
|
20780
|
+
`), hl = head.split(`
|
|
20781
|
+
`), added = new Set;
|
|
20782
|
+
for (const h of hunks)
|
|
20783
|
+
for (let i = 0;i < h.hn; i++)
|
|
20784
|
+
added.add(h.h0 + i);
|
|
20785
|
+
if (count2(ASSERT_RE, head) < count2(ASSERT_RE, base)) {
|
|
20786
|
+
const removing = hunks.filter((h) => h.bn > 0);
|
|
20787
|
+
const named = removing.length > 0 && removing.every((h) => {
|
|
20788
|
+
const b = caseHolding(bl, h.b0, h.b0 + h.bn - 1), n3 = h.hn > 0 ? caseHolding(hl, h.h0, h.h0 + h.hn - 1) : caseHolding(hl, Math.max(1, h.h0), Math.max(1, h.h0));
|
|
20789
|
+
if (!b || !n3 || b.title !== n3.title || b.title.length < 8 || !taskAsksUpdate(task, b.title))
|
|
20790
|
+
return false;
|
|
20791
|
+
return count2(ASSERT_RE, hl.slice(n3.start, n3.end).join(`
|
|
20792
|
+
`)) > 0;
|
|
20793
|
+
});
|
|
20794
|
+
if (!named)
|
|
20795
|
+
return null;
|
|
20796
|
+
why.push("fewer assertions only inside test cases the task asks to update");
|
|
20797
|
+
}
|
|
20798
|
+
if (count2(SETUP_RE, head) > count2(SETUP_RE, base)) {
|
|
20799
|
+
const exists2 = (ref, p) => {
|
|
20800
|
+
try {
|
|
20801
|
+
safeGit(repoDir, ["cat-file", "-e", `${ref}:${p}`], { stdio: "ignore" });
|
|
20802
|
+
return true;
|
|
20803
|
+
} catch {
|
|
20804
|
+
return false;
|
|
20805
|
+
}
|
|
20806
|
+
};
|
|
20807
|
+
const onHead = (p) => headSha ? exists2(headSha, p) : (() => {
|
|
20808
|
+
try {
|
|
20809
|
+
readFileSync58(join67(repoDir, p));
|
|
20810
|
+
return true;
|
|
20811
|
+
} catch {
|
|
20812
|
+
return false;
|
|
20813
|
+
}
|
|
20814
|
+
})();
|
|
20815
|
+
const dir = rel.includes("/") ? rel.slice(0, rel.lastIndexOf("/")) : "";
|
|
20816
|
+
const candidates = (spec) => {
|
|
20817
|
+
const p = normalizeRel2(dir ? `${dir}/${spec}` : spec);
|
|
20818
|
+
if (p === null)
|
|
20819
|
+
return [];
|
|
20820
|
+
const stem = p.replace(/\.(?:js|mjs|cjs|jsx)$/, "");
|
|
20821
|
+
return [...new Set([p, ...["ts", "tsx", "js", "mjs", "cjs", "jsx", "mts", "cts"].map((x) => `${stem}.${x}`), ...["ts", "tsx", "js"].map((x) => `${stem}/index.${x}`)])];
|
|
20822
|
+
};
|
|
20823
|
+
let excused = 0;
|
|
20824
|
+
for (const n3 of added) {
|
|
20825
|
+
const line2 = hl[n3 - 1] ?? "";
|
|
20826
|
+
const hits = count2(SETUP_RE, line2);
|
|
20827
|
+
if (hits === 0)
|
|
20828
|
+
continue;
|
|
20829
|
+
const m = MOCK_RE.exec(line2);
|
|
20830
|
+
if (m) {
|
|
20831
|
+
const spec = m[2], cs = spec.startsWith(".") ? candidates(spec) : [];
|
|
20832
|
+
let depth = 0, k = n3 - 1, body = "";
|
|
20833
|
+
for (;k < hl.length; k++) {
|
|
20834
|
+
body += hl[k] + `
|
|
20835
|
+
`;
|
|
20836
|
+
for (const ch of hl[k]) {
|
|
20837
|
+
if (ch === "(")
|
|
20838
|
+
depth++;
|
|
20839
|
+
else if (ch === ")")
|
|
20840
|
+
depth--;
|
|
20841
|
+
}
|
|
20842
|
+
if (depth <= 0)
|
|
20843
|
+
break;
|
|
20844
|
+
}
|
|
20845
|
+
const allAdded = Array.from({ length: k - (n3 - 1) + 1 }, (_, j) => n3 + j).every((x) => added.has(x));
|
|
20846
|
+
const fresh = cs.length > 0 && !cs.some((c) => exists2(baseSha, c)) && cs.some(onHead);
|
|
20847
|
+
const stub = OBSERVABILITY_RE.test((spec.split("/").pop() ?? "").replace(/\.\w+$/, "")) && STUB_FACTORY_RE.test(body.replace(/\n/g, " "));
|
|
20848
|
+
if (weakMockNewOn() && allAdded && (fresh || stub)) {
|
|
20849
|
+
excused += hits;
|
|
20850
|
+
continue;
|
|
20851
|
+
}
|
|
20852
|
+
return null;
|
|
20853
|
+
}
|
|
20854
|
+
if (HOOK_RE.test(line2)) {
|
|
20855
|
+
const ind = /^\s*/.exec(line2)[0].length;
|
|
20856
|
+
let owner = -1;
|
|
20857
|
+
for (let i = n3 - 2;i >= 0; i--) {
|
|
20858
|
+
const l = hl[i];
|
|
20859
|
+
if (/\bdescribe\s*\(/.test(l) && /^\s*/.exec(l)[0].length < ind) {
|
|
20860
|
+
owner = i + 1;
|
|
20861
|
+
break;
|
|
20862
|
+
}
|
|
20863
|
+
}
|
|
20864
|
+
if (weakMockNewOn() && owner > 0 && added.has(owner)) {
|
|
20865
|
+
excused += hits;
|
|
20866
|
+
continue;
|
|
20867
|
+
}
|
|
20868
|
+
return null;
|
|
20869
|
+
}
|
|
20870
|
+
return null;
|
|
20871
|
+
}
|
|
20872
|
+
if (count2(SETUP_RE, head) - excused > count2(SETUP_RE, base))
|
|
20873
|
+
return null;
|
|
20874
|
+
why.push("added setup only in describe blocks the change added, or mocks of modules new in the change");
|
|
20875
|
+
}
|
|
20876
|
+
return why.join("; ") || null;
|
|
20877
|
+
}
|
|
20660
20878
|
function findDefectPins(repoDir, task, ref = null) {
|
|
20661
20879
|
try {
|
|
20662
20880
|
const files = safeGit(repoDir, ref ? ["ls-tree", "-r", "--name-only", ref] : ["ls-files"]).split(`
|
|
@@ -20756,7 +20974,20 @@ function pinnedTestUpdates(repoDir, baseSha, reply, task) {
|
|
|
20756
20974
|
}
|
|
20757
20975
|
return out2.slice(0, 12);
|
|
20758
20976
|
}
|
|
20759
|
-
var ASSERT_RE, CASE_RE, SKIP_RE, SETUP_RE, count2 = (re, text3) => (text3.match(re) ?? []).length,
|
|
20977
|
+
var ASSERT_RE, CASE_RE, SKIP_RE, SETUP_RE, count2 = (re, text3) => (text3.match(re) ?? []).length, weakenExcuseOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_WEAK_EXCUSE"] ?? "").trim()), weakMockNewOn = (env = process.env) => /^(1|on|true|yes)$/i.test((env["LOKI_E10_WEAK_MOCK_NEW"] ?? "").trim()), UPDATE_ASK_RE, CASE_START_RE, ANY_CASE_RE, HOOK_RE, MOCK_RE, OBSERVABILITY_RE, STUB_FACTORY_RE, normalizeRel2 = (p) => {
|
|
20978
|
+
const out2 = [];
|
|
20979
|
+
for (const s of p.split("/")) {
|
|
20980
|
+
if (s === "" || s === ".")
|
|
20981
|
+
continue;
|
|
20982
|
+
if (s === "..") {
|
|
20983
|
+
if (!out2.length)
|
|
20984
|
+
return null;
|
|
20985
|
+
out2.pop();
|
|
20986
|
+
} else
|
|
20987
|
+
out2.push(s);
|
|
20988
|
+
}
|
|
20989
|
+
return out2.join("/");
|
|
20990
|
+
}, defectPinNote = (e) => `value change (defect pin): ${e.file}:${e.line} ${e.old} -> ${e.new}`, MAX_PIN_FILES = 400, MAX_PIN_BYTES = 200000, UPDATED_RE, flat = (t) => t.replace(/[\s`]+/g, "").replace(/'/g, '"'), pinnedUpdateNotes = (xs) => xs.filter((x) => !x.verified).map((x) => `test update reported but not verified: ${x.test}:${x.line} (${x.why ?? "unchecked"})`);
|
|
20760
20991
|
var init_test_guard = __esm(() => {
|
|
20761
20992
|
init_safe_git();
|
|
20762
20993
|
init_assert_delta();
|
|
@@ -20765,6 +20996,13 @@ var init_test_guard = __esm(() => {
|
|
|
20765
20996
|
CASE_RE = /\b(?:it|test|describe|context)\s*(?:\.each\b[^(]*)?\(|\bdef\s+test_\w+|@Test\b|\[(?:Fact|Theory|Test|TestMethod)\]|\bfunc\s+Test\w+/g;
|
|
20766
20997
|
SKIP_RE = /\.(?:skip|only|todo|fails)\s*\(|\b(?:xit|xdescribe|xtest|fit|fdescribe)\s*\(|@pytest\.mark\.(?:skip|skipif|xfail)\b|@(?:Disabled|Ignore)\b|\bt\.Skip\w*\(|\bpytest\.skip\(|\[Ignore\]/g;
|
|
20767
20998
|
SETUP_RE = /\b(?:beforeEach|afterEach|beforeAll|afterAll|vi\.(?:mock|doMock|spyOn|stubGlobal|stubEnv)|jest\.(?:mock|doMock|spyOn)|mock\.module|setUp|tearDown|setup_method|teardown_method|monkeypatch|autouse)\b|@pytest\.fixture\b|@(?:Before|After)(?:Each|All|Class)?\b|\[(?:SetUp|TearDown|OneTimeSetUp)\]/g;
|
|
20999
|
+
UPDATE_ASK_RE = /\btests?\b(?:(?!\.\s)[^\n]){0,200}?\b(?:is|are|be|gets?|must be|should be)\s+(?:updated|changed|rewritten|replaced)\b|\b(?:update|change|rewrite|replace)\s+(?:the\s+|this\s+|that\s+|its\s+)?(?:existing\s+)?(?:test|assertion|expectation)s?\b/i;
|
|
21000
|
+
CASE_START_RE = /^\s*(?:it|test)(?:\.\w+)?\s*\(\s*(['"`])((?:\\.|(?!\1).)*)\1/;
|
|
21001
|
+
ANY_CASE_RE = /^\s*(?:it|test|describe|context)(?:\.\w+)?\s*\(/;
|
|
21002
|
+
HOOK_RE = /\b(?:beforeEach|afterEach|beforeAll|afterAll)\s*\(/;
|
|
21003
|
+
MOCK_RE = /\b(?:vi|jest)\.(?:mock|doMock)\s*\(\s*(['"])([^'"]+)\1/;
|
|
21004
|
+
OBSERVABILITY_RE = /^(?:logger|log|logging|metrics|telemetry|tracing|tracer)$/i;
|
|
21005
|
+
STUB_FACTORY_RE = /^\s*(?:vi|jest)\.(?:mock|doMock)\s*\(\s*['"][^'"]+['"]\s*,\s*\(\)\s*=>\s*\(\{\s*(?:\w+\s*:\s*)?\{\s*(?:\w+\s*:\s*(?:vi|jest)\.fn\(\)\s*,?\s*)+\}\s*,?\s*\}\)\s*,?\s*\)\s*;?\s*$/;
|
|
20768
21006
|
UPDATED_RE = /^\W*UPDATED TEST\s+`?([^\s`:]+):(\d+)`?:\s*(.+?)\s*->\s*(.+?)\s*;\s*issue:\s*["\u201C](.+?)["\u201D]\s*\.?\s*$/gm;
|
|
20769
21007
|
});
|
|
20770
21008
|
|
|
@@ -20934,7 +21172,7 @@ __export(exports_unit_mode, {
|
|
|
20934
21172
|
DEFAULT_UNIT_USD_PER_MTOK: () => DEFAULT_UNIT_USD_PER_MTOK
|
|
20935
21173
|
});
|
|
20936
21174
|
import { createHash as createHash16 } from "crypto";
|
|
20937
|
-
import { closeSync as closeSync13, constants as constants2, fstatSync as fstatSync6, lstatSync as lstatSync18, openSync as openSync13, readSync as readSync10, realpathSync as
|
|
21175
|
+
import { closeSync as closeSync13, constants as constants2, fstatSync as fstatSync6, lstatSync as lstatSync18, openSync as openSync13, readSync as readSync10, realpathSync as realpathSync21 } from "fs";
|
|
20938
21176
|
import { isAbsolute as isAbsolute9, relative as relative10, resolve as resolve19 } from "path";
|
|
20939
21177
|
function readBounded(path) {
|
|
20940
21178
|
const l = lstatSync18(path);
|
|
@@ -21037,7 +21275,7 @@ function unitIntake(env, repoDir, existingCapUsd) {
|
|
|
21037
21275
|
const bad = (why) => ({ ok: false, note: UNIT_NOT_PROVEN(why) });
|
|
21038
21276
|
let txt;
|
|
21039
21277
|
try {
|
|
21040
|
-
const real3 =
|
|
21278
|
+
const real3 = realpathSync21(resolve19(path)), root = realpathSync21(repoDir), rel = relative10(root, real3);
|
|
21041
21279
|
if (!(rel === ".." || rel.startsWith("../") || isAbsolute9(rel)))
|
|
21042
21280
|
return bad("its spec file is inside the worktree where the agent could edit it");
|
|
21043
21281
|
txt = readBounded(real3);
|
|
@@ -22030,7 +22268,7 @@ var init_exec_spec = __esm(() => {
|
|
|
22030
22268
|
});
|
|
22031
22269
|
|
|
22032
22270
|
// ../../loki-ts/src/project_model/conventions.ts
|
|
22033
|
-
import { existsSync as existsSync44, readdirSync as readdirSync28, readFileSync as readFileSync61, realpathSync as
|
|
22271
|
+
import { existsSync as existsSync44, readdirSync as readdirSync28, readFileSync as readFileSync61, realpathSync as realpathSync22, renameSync as renameSync14, rmSync as rmSync18, statSync as statSync24, writeFileSync as writeFileSync28 } from "fs";
|
|
22034
22272
|
import { basename as basename20, dirname as dirname26, isAbsolute as isAbsolute10, join as join70, relative as relative12, resolve as resolve20, sep as sep14 } from "path";
|
|
22035
22273
|
function parseJsonc(text3) {
|
|
22036
22274
|
let out2 = "", i = 0;
|
|
@@ -23280,7 +23518,7 @@ var init_scope2 = __esm(() => {
|
|
|
23280
23518
|
});
|
|
23281
23519
|
|
|
23282
23520
|
// ../../loki-ts/src/features/attempts.ts
|
|
23283
|
-
import { existsSync as existsSync46, lstatSync as lstatSync19, mkdtempSync as mkdtempSync9, readFileSync as readFileSync63, realpathSync as
|
|
23521
|
+
import { existsSync as existsSync46, lstatSync as lstatSync19, mkdtempSync as mkdtempSync9, readFileSync as readFileSync63, realpathSync as realpathSync23, rmSync as rmSync19, symlinkSync as symlinkSync2 } from "fs";
|
|
23284
23522
|
import { tmpdir as tmpdir12 } from "os";
|
|
23285
23523
|
import { basename as basename22, dirname as dirname28, join as join72 } from "path";
|
|
23286
23524
|
function attemptsTotal(model, env = process.env) {
|
|
@@ -23408,7 +23646,7 @@ function removeAttemptTrees(primary, root, dirs) {
|
|
|
23408
23646
|
safeGit(primary, ["worktree", "prune"]);
|
|
23409
23647
|
} catch {}
|
|
23410
23648
|
try {
|
|
23411
|
-
if (basename22(root).startsWith(ATTEMPTS_TMP_PREFIX) && dirname28(
|
|
23649
|
+
if (basename22(root).startsWith(ATTEMPTS_TMP_PREFIX) && dirname28(realpathSync23(root)) === realpathSync23(tmpdir12()) && !lstatSync19(root).isSymbolicLink())
|
|
23412
23650
|
rmSync19(root, { recursive: true, force: true });
|
|
23413
23651
|
} catch {}
|
|
23414
23652
|
}
|
|
@@ -23663,7 +23901,7 @@ var init_attempts = __esm(() => {
|
|
|
23663
23901
|
});
|
|
23664
23902
|
|
|
23665
23903
|
// ../../loki-ts/src/util/secure_scan.ts
|
|
23666
|
-
import { copyFileSync as copyFileSync3, existsSync as existsSync47, lstatSync as lstatSync20, mkdirSync as mkdirSync28, mkdtempSync as mkdtempSync10, readFileSync as readFileSync64, realpathSync as
|
|
23904
|
+
import { copyFileSync as copyFileSync3, existsSync as existsSync47, lstatSync as lstatSync20, mkdirSync as mkdirSync28, mkdtempSync as mkdtempSync10, readFileSync as readFileSync64, realpathSync as realpathSync24, rmSync as rmSync20, statSync as statSync25, writeFileSync as writeFileSync29 } from "fs";
|
|
23667
23905
|
import { randomBytes as randomBytes4 } from "crypto";
|
|
23668
23906
|
import { tmpdir as tmpdir13 } from "os";
|
|
23669
23907
|
import { basename as basename23, dirname as dirname29, join as join73, resolve as resolve21, sep as sep15 } from "path";
|
|
@@ -23736,7 +23974,7 @@ function isWorkTreeRoot(dir) {
|
|
|
23736
23974
|
if (top === null)
|
|
23737
23975
|
return false;
|
|
23738
23976
|
try {
|
|
23739
|
-
return
|
|
23977
|
+
return realpathSync24(top.trim()) === realpathSync24(dir);
|
|
23740
23978
|
} catch {
|
|
23741
23979
|
return false;
|
|
23742
23980
|
}
|
|
@@ -24316,7 +24554,7 @@ var init_edit_shape = __esm(() => {
|
|
|
24316
24554
|
});
|
|
24317
24555
|
|
|
24318
24556
|
// ../../loki-ts/src/features/tournament.ts
|
|
24319
|
-
import { existsSync as existsSync48, mkdirSync as mkdirSync29, readFileSync as readFileSync65, realpathSync as
|
|
24557
|
+
import { existsSync as existsSync48, mkdirSync as mkdirSync29, readFileSync as readFileSync65, realpathSync as realpathSync25, renameSync as renameSync15, rmSync as rmSync21, writeFileSync as writeFileSync30 } from "fs";
|
|
24320
24558
|
import { dirname as dirname30, join as join74 } from "path";
|
|
24321
24559
|
function candidatePrompt(c, lenses = LENSES) {
|
|
24322
24560
|
return [
|
|
@@ -24522,7 +24760,7 @@ function runGoProbe(treeDir, pkgRel, pkg, cases, timeoutMs = 60000) {
|
|
|
24522
24760
|
const dir = join74(treeDir, pkgRel), helper = join74(dir, GO_PROBE_HELPER_FILE), file = join74(dir, GO_PROBE_CASES_FILE), t0 = Date.now();
|
|
24523
24761
|
let real3 = treeDir;
|
|
24524
24762
|
try {
|
|
24525
|
-
real3 =
|
|
24763
|
+
real3 = realpathSync25(treeDir);
|
|
24526
24764
|
} catch {}
|
|
24527
24765
|
let program = goBefore118(treeDir) ? anyToInterface(cases) : cases;
|
|
24528
24766
|
const pruned = [];
|
|
@@ -25184,7 +25422,7 @@ var init_tournament = __esm(() => {
|
|
|
25184
25422
|
|
|
25185
25423
|
// ../../loki-ts/src/features/no_regression.ts
|
|
25186
25424
|
import { execFileSync as execFileSync6, spawnSync as spawnSync8 } from "child_process";
|
|
25187
|
-
import { cpSync as cpSync2, lstatSync as lstatSync21, mkdirSync as mkdirSync30, mkdtempSync as mkdtempSync11, readFileSync as readFileSync66, realpathSync as
|
|
25425
|
+
import { cpSync as cpSync2, lstatSync as lstatSync21, mkdirSync as mkdirSync30, mkdtempSync as mkdtempSync11, readFileSync as readFileSync66, realpathSync as realpathSync26, rmSync as rmSync22, writeFileSync as writeFileSync31 } from "fs";
|
|
25188
25426
|
import { tmpdir as tmpdir14 } from "os";
|
|
25189
25427
|
import { basename as basename24, dirname as dirname31, join as join75 } from "path";
|
|
25190
25428
|
function goStringLiterals(body) {
|
|
@@ -25546,7 +25784,7 @@ function makeScratch(repoDir, baseSha, skip, userUntracked = [], diff) {
|
|
|
25546
25784
|
const root = mkdtempSync11(join75(tmpdir14(), SCRATCH_PREFIX)), base = join75(root, "base"), patched = join75(root, "patched"), replay = join75(root, "replay");
|
|
25547
25785
|
const dispose = () => {
|
|
25548
25786
|
try {
|
|
25549
|
-
if (basename24(root).startsWith(SCRATCH_PREFIX) && dirname31(
|
|
25787
|
+
if (basename24(root).startsWith(SCRATCH_PREFIX) && dirname31(realpathSync26(root)) === realpathSync26(tmpdir14()) && !lstatSync21(root).isSymbolicLink())
|
|
25550
25788
|
rmSync22(root, { recursive: true, force: true });
|
|
25551
25789
|
} catch {}
|
|
25552
25790
|
};
|
|
@@ -26233,7 +26471,7 @@ var init_runner_config = __esm(() => {
|
|
|
26233
26471
|
});
|
|
26234
26472
|
|
|
26235
26473
|
// ../../loki-ts/src/util/js_resolve.ts
|
|
26236
|
-
import { readFileSync as readFileSync68, realpathSync as
|
|
26474
|
+
import { readFileSync as readFileSync68, realpathSync as realpathSync27 } from "fs";
|
|
26237
26475
|
import { dirname as dirname33, isAbsolute as isAbsolute11, join as join77, normalize as normalize3, sep as sep16 } from "path";
|
|
26238
26476
|
function stripJsonc(t) {
|
|
26239
26477
|
let o = "", i = 0;
|
|
@@ -26260,7 +26498,7 @@ function stripJsonc(t) {
|
|
|
26260
26498
|
return o.replace(/,(\s*[}\]])/g, "$1");
|
|
26261
26499
|
}
|
|
26262
26500
|
function realInRepo(repoDir, rel) {
|
|
26263
|
-
const root =
|
|
26501
|
+
const root = realpathSync27(repoDir), rp = realpathSync27(join77(repoDir, rel));
|
|
26264
26502
|
return rp === root || rp.startsWith(root + sep16);
|
|
26265
26503
|
}
|
|
26266
26504
|
function readCompilerOptions(repoDir, rel, depth) {
|
|
@@ -28713,7 +28951,7 @@ var init_steer = __esm(() => {
|
|
|
28713
28951
|
});
|
|
28714
28952
|
|
|
28715
28953
|
// ../../loki-ts/src/util/reviewer_brief.ts
|
|
28716
|
-
import { closeSync as closeSync15, existsSync as existsSync54, fstatSync as fstatSync8, lstatSync as lstatSync23, openSync as openSync15, readFileSync as readFileSync76, readSync as readSync12, readdirSync as readdirSync31, realpathSync as
|
|
28954
|
+
import { closeSync as closeSync15, existsSync as existsSync54, fstatSync as fstatSync8, lstatSync as lstatSync23, openSync as openSync15, readFileSync as readFileSync76, readSync as readSync12, readdirSync as readdirSync31, realpathSync as realpathSync28, statSync as statSync29 } from "fs";
|
|
28717
28955
|
import { dirname as dirname35, join as join87, normalize as normalize4, sep as sep17 } from "path";
|
|
28718
28956
|
function reviewFlagLines(text3) {
|
|
28719
28957
|
const out2 = [];
|
|
@@ -28988,14 +29226,14 @@ function withAiMarker(body, line2) {
|
|
|
28988
29226
|
function readPrTemplate(repoDir) {
|
|
28989
29227
|
let top;
|
|
28990
29228
|
try {
|
|
28991
|
-
top =
|
|
29229
|
+
top = realpathSync28(repoDir);
|
|
28992
29230
|
} catch {
|
|
28993
29231
|
return null;
|
|
28994
29232
|
}
|
|
28995
29233
|
const inside = (q) => q === top || q.startsWith(top.endsWith(sep17) ? top : top + sep17);
|
|
28996
29234
|
for (const d of TPL_DIRS) {
|
|
28997
29235
|
try {
|
|
28998
|
-
if (!inside(
|
|
29236
|
+
if (!inside(realpathSync28(join87(repoDir, d))))
|
|
28999
29237
|
continue;
|
|
29000
29238
|
} catch {
|
|
29001
29239
|
continue;
|
|
@@ -29013,7 +29251,7 @@ function readPrTemplate(repoDir) {
|
|
|
29013
29251
|
try {
|
|
29014
29252
|
if (!lstatSync23(p).isFile())
|
|
29015
29253
|
continue;
|
|
29016
|
-
if (!inside(
|
|
29254
|
+
if (!inside(realpathSync28(p)))
|
|
29017
29255
|
continue;
|
|
29018
29256
|
const fd = openSync15(p, "r");
|
|
29019
29257
|
try {
|
|
@@ -29143,13 +29381,13 @@ var init_pr_body = __esm(() => {
|
|
|
29143
29381
|
|
|
29144
29382
|
// ../../loki-ts/src/util/mutation_proof.ts
|
|
29145
29383
|
import { execFileSync as execFileSync8, spawnSync as spawnSync9 } from "child_process";
|
|
29146
|
-
import { existsSync as existsSync55, mkdirSync as mkdirSync36, mkdtempSync as mkdtempSync12, readdirSync as readdirSync32, readFileSync as readFileSync77, realpathSync as
|
|
29384
|
+
import { existsSync as existsSync55, mkdirSync as mkdirSync36, mkdtempSync as mkdtempSync12, readdirSync as readdirSync32, readFileSync as readFileSync77, realpathSync as realpathSync29, rmSync as rmSync25, symlinkSync as symlinkSync3, writeFileSync as writeFileSync39 } from "fs";
|
|
29147
29385
|
import { tmpdir as tmpdir16 } from "os";
|
|
29148
29386
|
import { delimiter as delimiter4, dirname as dirname36, isAbsolute as isAbsolute14, join as join88, relative as relative16 } from "path";
|
|
29149
29387
|
function editableBaseEnv(repoDir, wt, venvs, env = process.env) {
|
|
29150
29388
|
const roots = new Set([repoDir]);
|
|
29151
29389
|
try {
|
|
29152
|
-
roots.add(
|
|
29390
|
+
roots.add(realpathSync29(repoDir));
|
|
29153
29391
|
} catch {}
|
|
29154
29392
|
for (const r of [...roots])
|
|
29155
29393
|
roots.add(r.startsWith("/private/") ? r.slice("/private".length) : `/private${r}`);
|
|
@@ -31243,7 +31481,7 @@ __export(exports_wall, {
|
|
|
31243
31481
|
RealBaseTestRunner: () => RealBaseTestRunner,
|
|
31244
31482
|
BASE_RUN_TIMEOUT_MS: () => BASE_RUN_TIMEOUT_MS
|
|
31245
31483
|
});
|
|
31246
|
-
import { existsSync as existsSync58, mkdirSync as mkdirSync38, mkdtempSync as mkdtempSync13, readFileSync as readFileSync81, readdirSync as readdirSync34, realpathSync as
|
|
31484
|
+
import { existsSync as existsSync58, mkdirSync as mkdirSync38, mkdtempSync as mkdtempSync13, readFileSync as readFileSync81, readdirSync as readdirSync34, realpathSync as realpathSync30, rmSync as rmSync27, writeFileSync as writeFileSync42 } from "fs";
|
|
31247
31485
|
import { tmpdir as tmpdir17 } from "os";
|
|
31248
31486
|
import { basename as basename30, dirname as dirname39, join as join92, relative as relative18 } from "path";
|
|
31249
31487
|
|
|
@@ -31282,7 +31520,7 @@ class RealBaseTestRunner {
|
|
|
31282
31520
|
fail2++;
|
|
31283
31521
|
this.lastFailLines[f.path] = proofExcerpt(out2, [repoDir, (() => {
|
|
31284
31522
|
try {
|
|
31285
|
-
return
|
|
31523
|
+
return realpathSync30(repoDir);
|
|
31286
31524
|
} catch {
|
|
31287
31525
|
return repoDir;
|
|
31288
31526
|
}
|
|
@@ -31655,10 +31893,10 @@ var init_wall = __esm(() => {
|
|
|
31655
31893
|
});
|
|
31656
31894
|
|
|
31657
31895
|
// ../../loki-ts/src/e10ext/discard.ts
|
|
31658
|
-
import { chmodSync as chmodSync6, closeSync as closeSync16, lstatSync as lstatSync24, mkdirSync as mkdirSync39, openSync as openSync16, readFileSync as readFileSync82, realpathSync as
|
|
31896
|
+
import { chmodSync as chmodSync6, closeSync as closeSync16, lstatSync as lstatSync24, mkdirSync as mkdirSync39, openSync as openSync16, readFileSync as readFileSync82, realpathSync as realpathSync31, rmdirSync, unlinkSync as unlinkSync9, writeFileSync as writeFileSync43 } from "fs";
|
|
31659
31897
|
import { dirname as dirname40, join as join93, relative as relative19, sep as sep19 } from "path";
|
|
31660
31898
|
function safeRestore(repoDir, f, want, mode) {
|
|
31661
|
-
const root =
|
|
31899
|
+
const root = realpathSync31(repoDir), fp = join93(root, f), rel = relative19(root, dirname40(fp));
|
|
31662
31900
|
if (rel.startsWith(".."))
|
|
31663
31901
|
throw new Error("outside repo");
|
|
31664
31902
|
let cur = root;
|
|
@@ -35263,7 +35501,7 @@ var init_supply_guard = __esm(() => {
|
|
|
35263
35501
|
});
|
|
35264
35502
|
|
|
35265
35503
|
// ../../loki-ts/src/features/patch_protocol.ts
|
|
35266
|
-
import { existsSync as existsSync68, lstatSync as lstatSync28, mkdirSync as mkdirSync49, readFileSync as readFileSync94, realpathSync as
|
|
35504
|
+
import { existsSync as existsSync68, lstatSync as lstatSync28, mkdirSync as mkdirSync49, readFileSync as readFileSync94, realpathSync as realpathSync32, rmSync as rmSync31, writeFileSync as writeFileSync51 } from "fs";
|
|
35267
35505
|
import { basename as basename33, dirname as dirname47, join as join105, normalize as normalize7, relative as relative21, sep as sep21 } from "path";
|
|
35268
35506
|
function buildPatchBrief(task, code, conventions, checkCmds) {
|
|
35269
35507
|
return [
|
|
@@ -35328,7 +35566,7 @@ function refusal(rules, rel, before, after) {
|
|
|
35328
35566
|
}
|
|
35329
35567
|
function contained(repoDir, rel) {
|
|
35330
35568
|
try {
|
|
35331
|
-
const root =
|
|
35569
|
+
const root = realpathSync32(repoDir);
|
|
35332
35570
|
let p = join105(root, rel);
|
|
35333
35571
|
for (;; ) {
|
|
35334
35572
|
let exists2 = false;
|
|
@@ -35337,7 +35575,7 @@ function contained(repoDir, rel) {
|
|
|
35337
35575
|
exists2 = true;
|
|
35338
35576
|
} catch {}
|
|
35339
35577
|
if (exists2) {
|
|
35340
|
-
const r =
|
|
35578
|
+
const r = realpathSync32(p);
|
|
35341
35579
|
return r === p && (r === root || r.startsWith(root + sep21));
|
|
35342
35580
|
}
|
|
35343
35581
|
const up = dirname47(p);
|
|
@@ -35661,6 +35899,7 @@ var exports_seal = {};
|
|
|
35661
35899
|
__export(exports_seal, {
|
|
35662
35900
|
wallGreenOnBaseOf: () => wallGreenOnBaseOf,
|
|
35663
35901
|
verdictOf: () => verdictOf2,
|
|
35902
|
+
targetedBreak: () => targetedBreak,
|
|
35664
35903
|
targetProofOf: () => targetProofOf,
|
|
35665
35904
|
stage: () => stage3,
|
|
35666
35905
|
specSiteGap: () => specSiteGap,
|
|
@@ -35836,6 +36075,28 @@ async function git7(ctx, args, keep = {}, timeoutMs = 20000) {
|
|
|
35836
36075
|
const r = await safeGitRun(ctx.repoDir, args, { timeoutMs, ...keep });
|
|
35837
36076
|
return { out: r.stdout, code: r.exitCode, err: String(r.stderr ?? "") };
|
|
35838
36077
|
}
|
|
36078
|
+
function targetedBreak(ctx, runner = (ms) => new RealBaseTestRunner(undefined, ms)) {
|
|
36079
|
+
const checks = (Array.isArray(ctx.outputs().verify?.checks) ? ctx.outputs().verify.checks : []).filter((c) => c.result === "pass" && typeof c.name === "string" && /^[a-z]+:[^ ]/.test(c.name) && !/^(?:lint|full suite|typecheck|build|holdout|patch|turn):/.test(c.name));
|
|
36080
|
+
const refs = [...new Map(checks.map((c) => {
|
|
36081
|
+
const n3 = String(c.name), i = n3.indexOf(":");
|
|
36082
|
+
return [n3.slice(i + 1), { runner: n3.slice(0, i), path: n3.slice(i + 1) }];
|
|
36083
|
+
})).values()].slice(0, REGEN_GUARD_MAX);
|
|
36084
|
+
if (!refs.length)
|
|
36085
|
+
return false;
|
|
36086
|
+
const t0 = Date.now();
|
|
36087
|
+
let ran = 0;
|
|
36088
|
+
for (const r of refs) {
|
|
36089
|
+
const left = REGEN_GUARD_MS - (Date.now() - t0);
|
|
36090
|
+
if (left < 1000)
|
|
36091
|
+
break;
|
|
36092
|
+
const x = runner(left).run(ctx.repoDir, [r]);
|
|
36093
|
+
if (x.fail > 0)
|
|
36094
|
+
return true;
|
|
36095
|
+
if (x.pass > 0)
|
|
36096
|
+
ran++;
|
|
36097
|
+
}
|
|
36098
|
+
return ran === 0;
|
|
36099
|
+
}
|
|
35839
36100
|
function verdictOf2(o, checks, emptyDiff, verifyNotProven, wallGreenOnBase, proof, targetProof = false, uncovered = [], leanGap = [], copyGap = [], clauseGap = []) {
|
|
35840
36101
|
const exit = o.implement?.exit;
|
|
35841
36102
|
if (o.commit?.failed !== true && strs2(o.commit?.not_proven).length === 0 && (o.intake?.already_satisfied === true || exit === "already_done"))
|
|
@@ -35925,7 +36186,7 @@ var SYSTEM_INTERP = "tests ran on the system interpreter", SYSTEM_INTERP_SUFFIX
|
|
|
35925
36186
|
`).map((l) => l.trim()).filter(Boolean).slice(-4).join(" | ").slice(0, 400) || "no error output", hookBypassNote = (err) => `the repo's own commit hook rejected Loki's commit (${gitErrorLine(err)}); committed with hooks off, signing kept (LOKI_E10_COMMIT_HOOK_BYPASS)`, receiptRel = (ctx) => {
|
|
35926
36187
|
const r = relative22(ctx.repoDir, join106(ctx.runDir, "receipt.json"));
|
|
35927
36188
|
return r.startsWith("..") || isAbsolute17(r) ? `.loki/runs/${ctx.runId}/receipt.json` : r;
|
|
35928
|
-
}, pinnedUpdatesOf = (implement) => Array.isArray(implement?.pinned_test_updates) ? implement.pinned_test_updates : [], pinnedUpdatesBlock = (implement) => {
|
|
36189
|
+
}, REGEN_GUARD_MAX = 6, REGEN_GUARD_MS = 20000, pinnedUpdatesOf = (implement) => Array.isArray(implement?.pinned_test_updates) ? implement.pinned_test_updates : [], pinnedUpdatesBlock = (implement) => {
|
|
35929
36190
|
const xs = pinnedUpdatesOf(implement);
|
|
35930
36191
|
return xs.length ? { pinned_test_updates: xs } : {};
|
|
35931
36192
|
}, commitStage, wallGreenOnBaseOf = (o) => {
|
|
@@ -36000,7 +36261,7 @@ var init_seal = __esm(() => {
|
|
|
36000
36261
|
return { status: "failed", data: {}, reason: "git diff against base failed" };
|
|
36001
36262
|
const staged = parseStaged(sd.out);
|
|
36002
36263
|
const drop0 = dropSet(ctx.repoDir, staged, ctx.outputs().intake?.preexisting_dirty, process.env, ctx.outputs().intake?.install_created, ctx.outputs().intake?.preexisting_untracked_blobs, ctx.baseSha, str3(ctx.outputs().intake?.task) ?? undefined);
|
|
36003
|
-
const
|
|
36264
|
+
const regen0 = regenDrops(ctx.runDir, staged.filter(({ f }) => !drop0.some((d) => d.f === f)), str3(ctx.outputs().intake?.task) ?? "", (f) => {
|
|
36004
36265
|
try {
|
|
36005
36266
|
return safeGit(ctx.repoDir, ["diff", "--no-color", "-U0", ctx.baseSha, "--", f]).split(`
|
|
36006
36267
|
`).filter((l) => /^[+-](?![+-]{2})/.test(l));
|
|
@@ -36008,6 +36269,7 @@ var init_seal = __esm(() => {
|
|
|
36008
36269
|
return [];
|
|
36009
36270
|
}
|
|
36010
36271
|
});
|
|
36272
|
+
const regenG = guardRegenDrops(ctx.repoDir, ctx.baseSha, regen0, () => targetedBreak(ctx)), regen = regenG.dropped;
|
|
36011
36273
|
const rest = staged.filter(({ f }) => !drop0.some((d) => d.f === f) && !regen.some((d) => d.f === f));
|
|
36012
36274
|
const need = needDrops(rest, str3(ctx.outputs().intake?.task) ?? "", (f) => {
|
|
36013
36275
|
let base2 = null, head = null;
|
|
@@ -36048,7 +36310,7 @@ var init_seal = __esm(() => {
|
|
|
36048
36310
|
const dropped2 = new Set([...drop.map(({ f }) => f), ...xpkg]), fmtRec = formatChangedRecord(ctx.repoDir, staged, dropped2, process.env, ctx.baseSha), fmt = fmtRec.formatted;
|
|
36049
36311
|
if (fmt.length > 0)
|
|
36050
36312
|
await git7(ctx, ["--literal-pathspecs", "add", "--", ...fmt], { repoDrivers: true });
|
|
36051
|
-
const notes = [...xpkg.map(crossPackageTestNote), ...flagOutsideScope(ctx.outputs(), staged.filter(({ f }) => !dropped2.has(f)), ctx.runDir, ctx.repoDir), ...toolchainDropNotes(ctx.repoDir, drop.filter(({ st }) => st === "A").map(({ f }) => f), ctx.baseSha), ...buildArtifactNotes(ctx.repoDir, drop.filter(({ st }) => st === "A").map(({ f }) => f), ctx.baseSha, str3(ctx.outputs().intake?.task) ?? undefined), ...regen.map(({ f }) => regenDropNote(f)), ...need.map(needDropNote)];
|
|
36313
|
+
const notes = [...xpkg.map(crossPackageTestNote), ...flagOutsideScope(ctx.outputs(), staged.filter(({ f }) => !dropped2.has(f)), ctx.runDir, ctx.repoDir), ...toolchainDropNotes(ctx.repoDir, drop.filter(({ st }) => st === "A").map(({ f }) => f), ctx.baseSha), ...buildArtifactNotes(ctx.repoDir, drop.filter(({ st }) => st === "A").map(({ f }) => f), ctx.baseSha, str3(ctx.outputs().intake?.task) ?? undefined), ...regen.map(({ f }) => regenDropNote(f)), ...regenG.kept.map(({ f }) => regenKeptNote(f)), ...need.map(needDropNote)];
|
|
36052
36314
|
const format = fmtRec.records.length ? { format: fmtRec.records } : {};
|
|
36053
36315
|
if ((await git7(ctx, ["diff", "--cached", "--quiet"])).code === 0)
|
|
36054
36316
|
return { status: "completed", data: { committed: false, scope_notes: notes, ...format } };
|
|
@@ -36096,7 +36358,7 @@ var init_seal = __esm(() => {
|
|
|
36096
36358
|
const weakTests = [];
|
|
36097
36359
|
for (let i = 0;i + 1 < rawDiff.length; i += 2) {
|
|
36098
36360
|
const st = rawDiff[i].trim().split(" ").pop() ?? "";
|
|
36099
|
-
if (st !== "A" && isTestFile(rawDiff[i + 1]) && testFileWeakened(ctx.repoDir, ctx.baseSha, head, rawDiff[i + 1], st))
|
|
36361
|
+
if (st !== "A" && isTestFile(rawDiff[i + 1]) && testFileWeakened(ctx.repoDir, ctx.baseSha, head, rawDiff[i + 1], st, loadTaskText(ctx, str3(o.intake?.task) ?? undefined)))
|
|
36100
36362
|
weakTests.push(rawDiff[i + 1]);
|
|
36101
36363
|
}
|
|
36102
36364
|
const rcNotes = diffOk ? [...runnerConfigNotes(ctx.repoDir, ctx.baseSha, head, rawDiff.filter((_, i) => i % 2 === 1), signal), ...addedSymlinkNotes(rawDiff, str3(o.plan?.plan)), ...misplacedNamedNotes(str3(o.intake?.task) ?? "", rawDiff, ctx.repoDir, head)] : [];
|
|
@@ -36216,6 +36478,14 @@ var init_seal = __esm(() => {
|
|
|
36216
36478
|
for (const v of vl)
|
|
36217
36479
|
dropped2.add(v);
|
|
36218
36480
|
}
|
|
36481
|
+
for (let i = 0;i + 1 < rawDiff.length; i += 2) {
|
|
36482
|
+
const st = rawDiff[i].trim().split(" ").pop() ?? "", f = rawDiff[i + 1];
|
|
36483
|
+
if (st === "M" && isTestFile(f) && !weakTests.includes(f)) {
|
|
36484
|
+
const why = weakenExcuse(ctx.repoDir, ctx.baseSha, head, f, loadTaskText(ctx, str3(o.intake?.task) ?? undefined));
|
|
36485
|
+
if (why)
|
|
36486
|
+
notProven2.add(`edited test kept uncapped (${why}): ${f}`);
|
|
36487
|
+
}
|
|
36488
|
+
}
|
|
36219
36489
|
for (const e of pinEdits)
|
|
36220
36490
|
notProven2.add(defectPinNote(e));
|
|
36221
36491
|
for (const v of pinDropped)
|
|
@@ -36423,7 +36693,7 @@ var init_seal = __esm(() => {
|
|
|
36423
36693
|
|
|
36424
36694
|
// ../../loki-ts/src/util/seal_drift.ts
|
|
36425
36695
|
import { createHash as createHash28, createPublicKey as createPublicKey5, sign as sign3, verify as verify4 } from "crypto";
|
|
36426
|
-
import { existsSync as existsSync70, lstatSync as lstatSync29, readFileSync as readFileSync96, realpathSync as
|
|
36696
|
+
import { existsSync as existsSync70, lstatSync as lstatSync29, readFileSync as readFileSync96, realpathSync as realpathSync34 } from "fs";
|
|
36427
36697
|
import { basename as basename35, dirname as dirname49, join as join107, relative as relative23 } from "path";
|
|
36428
36698
|
function tornTail(raw2) {
|
|
36429
36699
|
if (raw2 === "" || raw2.endsWith(`
|
|
@@ -36552,7 +36822,7 @@ function onlyWallPublish(repo, r, sealedHead, head) {
|
|
|
36552
36822
|
try {
|
|
36553
36823
|
const real3 = (x) => {
|
|
36554
36824
|
try {
|
|
36555
|
-
return
|
|
36825
|
+
return realpathSync34(x);
|
|
36556
36826
|
} catch {
|
|
36557
36827
|
return x;
|
|
36558
36828
|
}
|
|
@@ -36594,7 +36864,7 @@ function claimsWallPublish(repo, r, sealedHead, head) {
|
|
|
36594
36864
|
function sealDrift(given, r, env = process.env) {
|
|
36595
36865
|
let receiptPath = given;
|
|
36596
36866
|
try {
|
|
36597
|
-
receiptPath = join107(
|
|
36867
|
+
receiptPath = join107(realpathSync34(dirname49(given)), basename35(given));
|
|
36598
36868
|
} catch {}
|
|
36599
36869
|
const fab = fabricatedPass(receiptPath, r);
|
|
36600
36870
|
if (fab)
|
|
@@ -36740,7 +37010,7 @@ var init_seal_drift = __esm(() => {
|
|
|
36740
37010
|
});
|
|
36741
37011
|
|
|
36742
37012
|
// ../../loki-ts/src/providers/provider_guard.ts
|
|
36743
|
-
import { copyFileSync as copyFileSync6, existsSync as existsSync71, lstatSync as lstatSync30, mkdirSync as mkdirSync51, readFileSync as readFileSync97, readdirSync as readdirSync39, readlinkSync as readlinkSync3, realpathSync as
|
|
37013
|
+
import { copyFileSync as copyFileSync6, existsSync as existsSync71, lstatSync as lstatSync30, mkdirSync as mkdirSync51, readFileSync as readFileSync97, readdirSync as readdirSync39, readlinkSync as readlinkSync3, realpathSync as realpathSync35, rmSync as rmSync33 } from "fs";
|
|
36744
37014
|
import { dirname as dirname50, isAbsolute as isAbsolute18, join as join108, relative as relative24, resolve as resolve23 } from "path";
|
|
36745
37015
|
function providerSandboxFlags(provider) {
|
|
36746
37016
|
return [];
|
|
@@ -36765,7 +37035,7 @@ function escapesProject(root, linkPath) {
|
|
|
36765
37035
|
try {
|
|
36766
37036
|
const target = readlinkSync3(linkPath);
|
|
36767
37037
|
const abs = isAbsolute18(target) ? target : resolve23(dirname50(linkPath), target);
|
|
36768
|
-
const rel = relative24(
|
|
37038
|
+
const rel = relative24(realpathSync35(root), existsSync71(abs) ? realpathSync35(abs) : abs);
|
|
36769
37039
|
return rel.startsWith("..") || isAbsolute18(rel);
|
|
36770
37040
|
} catch {
|
|
36771
37041
|
return false;
|
|
@@ -40703,7 +40973,7 @@ __export(exports_doctor, {
|
|
|
40703
40973
|
CLAUDE_LOGIN_TTL_MS: () => CLAUDE_LOGIN_TTL_MS,
|
|
40704
40974
|
AUTH_PROVIDERS: () => AUTH_PROVIDERS
|
|
40705
40975
|
});
|
|
40706
|
-
import { appendFileSync as appendFileSync12, writeFileSync as writeFileSync62, mkdirSync as mkdirSync59, accessSync as accessSync3, constants as fsConstants3, existsSync as existsSync81, lstatSync as lstatSync31, readdirSync as readdirSync42, readFileSync as readFileSync107, readlinkSync as readlinkSync4, realpathSync as
|
|
40976
|
+
import { appendFileSync as appendFileSync12, writeFileSync as writeFileSync62, mkdirSync as mkdirSync59, accessSync as accessSync3, constants as fsConstants3, existsSync as existsSync81, lstatSync as lstatSync31, readdirSync as readdirSync42, readFileSync as readFileSync107, readlinkSync as readlinkSync4, realpathSync as realpathSync36, statSync as statSync34, statfsSync } from "fs";
|
|
40707
40977
|
import { spawnSync as spawnSync15 } from "child_process";
|
|
40708
40978
|
import { homedir as homedir14, tmpdir as tmpdir20 } from "os";
|
|
40709
40979
|
import { basename as basename36, join as join117, resolve as resolve28 } from "path";
|
|
@@ -42175,7 +42445,7 @@ async function runText(deps = {}) {
|
|
|
42175
42445
|
{
|
|
42176
42446
|
const resolveReal = (p) => {
|
|
42177
42447
|
try {
|
|
42178
|
-
return
|
|
42448
|
+
return realpathSync36(p);
|
|
42179
42449
|
} catch {
|
|
42180
42450
|
return p;
|
|
42181
42451
|
}
|
|
@@ -43848,7 +44118,7 @@ __export(exports_route, {
|
|
|
43848
44118
|
MAX_SPEC_BYTES: () => MAX_SPEC_BYTES2,
|
|
43849
44119
|
MAX_SEQ_TASK_BYTES: () => MAX_SEQ_TASK_BYTES
|
|
43850
44120
|
});
|
|
43851
|
-
import { closeSync as closeSync17, constants as constants4, fstatSync as fstatSync9, openSync as openSync17, readFileSync as readFileSync110, realpathSync as
|
|
44121
|
+
import { closeSync as closeSync17, constants as constants4, fstatSync as fstatSync9, openSync as openSync17, readFileSync as readFileSync110, realpathSync as realpathSync37 } from "fs";
|
|
43852
44122
|
import { isAbsolute as isAbsolute20, relative as relative27, resolve as resolve30 } from "path";
|
|
43853
44123
|
function providerSlots(env, provider) {
|
|
43854
44124
|
provider = (provider || env.LOKI_PROVIDER || "claude").toLowerCase();
|
|
@@ -43860,11 +44130,11 @@ function readSpec(task, repoDir, cwd) {
|
|
|
43860
44130
|
const p = isAbsolute20(task) ? task : resolve30(cwd, task);
|
|
43861
44131
|
let real3;
|
|
43862
44132
|
try {
|
|
43863
|
-
real3 =
|
|
44133
|
+
real3 = realpathSync37(p);
|
|
43864
44134
|
} catch {
|
|
43865
44135
|
return { kind: "missing", path: p };
|
|
43866
44136
|
}
|
|
43867
|
-
const rel = relative27(
|
|
44137
|
+
const rel = relative27(realpathSync37(repoDir), real3);
|
|
43868
44138
|
if (rel === ".." || rel.startsWith("../") || isAbsolute20(rel))
|
|
43869
44139
|
return { kind: "reject", reason: `spec path escapes the repo: ${task}` };
|
|
43870
44140
|
let fd = -1;
|
|
@@ -45436,6 +45706,7 @@ __export(exports_supervisor, {
|
|
|
45436
45706
|
unmergedLokiWorkNote: () => unmergedLokiWorkNote,
|
|
45437
45707
|
summaryTokens: () => summaryTokens,
|
|
45438
45708
|
summaryCache: () => summaryCache,
|
|
45709
|
+
spawnDeep: () => spawnDeep,
|
|
45439
45710
|
runSupervisor: () => runSupervisor,
|
|
45440
45711
|
runSummaryCost: () => runSummaryCost,
|
|
45441
45712
|
renderMainOutput: () => renderMainOutput,
|
|
@@ -45446,6 +45717,8 @@ __export(exports_supervisor, {
|
|
|
45446
45717
|
main: () => main3,
|
|
45447
45718
|
githubRepoFromUrl: () => githubRepoFromUrl,
|
|
45448
45719
|
eventsRelPath: () => eventsRelPath,
|
|
45720
|
+
deepPostOn: () => deepPostOn,
|
|
45721
|
+
deepPostArgv: () => deepPostArgv,
|
|
45449
45722
|
backstopS: () => backstopS,
|
|
45450
45723
|
applyCapEnv: () => applyCapEnv,
|
|
45451
45724
|
alreadyDoneTextComment: () => alreadyDoneTextComment,
|
|
@@ -45464,6 +45737,35 @@ async function slackEvent(...a) {
|
|
|
45464
45737
|
await (await Promise.resolve().then(() => (init_slack_events(), exports_slack_events))).notifyEvent(...a);
|
|
45465
45738
|
} catch {}
|
|
45466
45739
|
}
|
|
45740
|
+
function deepPostArgv(deepArgv, origin, pid) {
|
|
45741
|
+
const k = deepArgv.indexOf("deep-worker"), runId2 = k >= 0 ? deepArgv[k + 1] : undefined;
|
|
45742
|
+
return k > 0 && runId2 ? [...deepArgv.slice(0, k), "deep-post", runId2, String(pid), origin] : null;
|
|
45743
|
+
}
|
|
45744
|
+
function spawnDeep(deepArgv, origin, o) {
|
|
45745
|
+
const spawn12 = o.spawn ?? spawnDetached, out2 = [];
|
|
45746
|
+
let argv = null;
|
|
45747
|
+
try {
|
|
45748
|
+
argv = ulimitArgv([...deepArgv, origin], o.workerEnv);
|
|
45749
|
+
} catch (e) {
|
|
45750
|
+
out2.push(`deep verify not spawned: ${e.message}`);
|
|
45751
|
+
}
|
|
45752
|
+
const poster = deepPostOn(o.env), deepEnv = poster ? { ...o.workerEnv, LOKI_E10_DEEP_POSTER: "1" } : o.workerEnv, [cmd2, ...dArgs] = argv ?? [], pid = argv && cmd2 ? spawn12(cmd2, dArgs, { cwd: o.repoDir, env: deepEnv }) : null;
|
|
45753
|
+
if (!pid) {
|
|
45754
|
+
if (argv)
|
|
45755
|
+
out2.push("deep verify not spawned");
|
|
45756
|
+
return out2;
|
|
45757
|
+
}
|
|
45758
|
+
o.append({ type: "capability.recorded", data: { stages: [stageCapability("deep", deepEnv, argv ?? [])] } });
|
|
45759
|
+
o.append({ type: "deep.started", data: { pid } });
|
|
45760
|
+
if (!poster)
|
|
45761
|
+
return out2;
|
|
45762
|
+
const pArgv = deepPostArgv(deepArgv, origin, pid), ppid = pArgv ? spawn12(pArgv[0], pArgv.slice(1), { cwd: o.repoDir, env: o.env }) : null;
|
|
45763
|
+
if (ppid)
|
|
45764
|
+
o.append({ type: "deep.started", data: { pid: ppid, poster: true } });
|
|
45765
|
+
else
|
|
45766
|
+
out2.push("deep verify result poster not spawned: loki/deep-verify stays pending");
|
|
45767
|
+
return out2;
|
|
45768
|
+
}
|
|
45467
45769
|
function dataOk(type, d) {
|
|
45468
45770
|
if (type === "session.ended") {
|
|
45469
45771
|
return typeof d.session_id === "string" && SESSION_EXITS.has(d.exit) && nonNegNum(d.duration_s);
|
|
@@ -45684,20 +45986,8 @@ async function runSupervisor(opts) {
|
|
|
45684
45986
|
log.append("pr.opened", "pr", { url: out2.url, draft: out2.draft, existing: out2.existing });
|
|
45685
45987
|
await opts.status?.({ prUrl: out2.url });
|
|
45686
45988
|
await slackEvent(env, "pr_opened", { repo: githubRepoFromUrl(origin) ?? undefined, issue: String(opts.started?.["issue_ref"] ?? ""), prUrl: out2.url, outcome: verdict });
|
|
45687
|
-
if (opts.deepArgv)
|
|
45688
|
-
|
|
45689
|
-
try {
|
|
45690
|
-
argv = ulimitArgv([...opts.deepArgv, origin], workerEnv);
|
|
45691
|
-
} catch (e) {
|
|
45692
|
-
notProven2.push(`deep verify not spawned: ${e.message}`);
|
|
45693
|
-
}
|
|
45694
|
-
const [cmd2, ...dArgs] = argv ?? [], pid = argv && cmd2 ? spawnDetached(cmd2, dArgs, { cwd: opts.repoDir, env: workerEnv }) : null;
|
|
45695
|
-
if (pid) {
|
|
45696
|
-
log.append("capability.recorded", "deep", { stages: [stageCapability("deep", workerEnv, argv ?? [])] });
|
|
45697
|
-
log.append("deep.started", "deep", { pid });
|
|
45698
|
-
} else if (argv)
|
|
45699
|
-
notProven2.push("deep verify not spawned");
|
|
45700
|
-
}
|
|
45989
|
+
if (opts.deepArgv)
|
|
45990
|
+
notProven2.push(...spawnDeep(opts.deepArgv, origin, { workerEnv, env, repoDir: opts.repoDir, append: (d) => log.append(d.type, "deep", d.data) }));
|
|
45701
45991
|
}
|
|
45702
45992
|
}
|
|
45703
45993
|
const allEvents = readEvents(log.path), folded = fold(allEvents), lokiRoot = join126(opts.repoDir, ".loki"), costUsd = runCostUsd(allEvents, log.tampered, lokiRoot), wallS = (Date.now() - t0) / 1000;
|
|
@@ -46257,7 +46547,7 @@ ${rs.renderAweProofCard(card, useColor())}
|
|
|
46257
46547
|
await Promise.resolve().then(() => (init_satisfaction(), exports_satisfaction)).then((m) => m.maybeAsk({ runId: runId2, env: process.env, isTTY: process.stdin.isTTY === true && process.stdout.isTTY === true })).catch(() => {});
|
|
46258
46548
|
return res.outcome === "CANCELLED" && res.notProven.some((n3) => n3.endsWith("SIGTERM")) ? 143 : exitCodeOf(res.outcome);
|
|
46259
46549
|
}
|
|
46260
|
-
var START_LINE = "Loki 10 engine", TAMPER_NOT_PROVEN = "event log modified outside the engine", SUPERVISOR_ONLY, VERDICTS2, ALIVE_BEAT_MS = 15000, SESSION_EXITS, BACKSTOP_NOT_PROVEN = "worker killed by the supervisor backstop (cap minus grace)", isRev = (r) => typeof r === "object" && r !== null && Number.isInteger(r.rev) && nonNegNum(r.at), nonNegNum = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0, ISSUE_RE, runSummaryCost = (events2, tampered, repoDir) => summaryCost(events2, tampered, join126(repoDir, ".loki"));
|
|
46550
|
+
var START_LINE = "Loki 10 engine", TAMPER_NOT_PROVEN = "event log modified outside the engine", SUPERVISOR_ONLY, deepPostOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_DEEP_POST"] ?? "").trim()), VERDICTS2, ALIVE_BEAT_MS = 15000, SESSION_EXITS, BACKSTOP_NOT_PROVEN = "worker killed by the supervisor backstop (cap minus grace)", isRev = (r) => typeof r === "object" && r !== null && Number.isInteger(r.rev) && nonNegNum(r.at), nonNegNum = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0, ISSUE_RE, runSummaryCost = (events2, tampered, repoDir) => summaryCost(events2, tampered, join126(repoDir, ".loki"));
|
|
46261
46551
|
var init_supervisor = __esm(() => {
|
|
46262
46552
|
init_route_block();
|
|
46263
46553
|
init_stop_restore();
|
|
@@ -47464,9 +47754,10 @@ __export(exports_deep, {
|
|
|
47464
47754
|
runDeep: () => runDeep,
|
|
47465
47755
|
deepWorker: () => deepWorker,
|
|
47466
47756
|
deepStage: () => deepStage,
|
|
47757
|
+
deepPost: () => deepPost,
|
|
47467
47758
|
DEFAULT_SECRET_SCAN_SH: () => DEFAULT_SECRET_SCAN_SH
|
|
47468
47759
|
});
|
|
47469
|
-
import { copyFileSync as copyFileSync8, existsSync as existsSync93, mkdirSync as mkdirSync72, mkdtempSync as mkdtempSync18, rmSync as rmSync40, writeFileSync as writeFileSync70 } from "fs";
|
|
47760
|
+
import { copyFileSync as copyFileSync8, existsSync as existsSync93, mkdirSync as mkdirSync72, mkdtempSync as mkdtempSync18, readFileSync as readFileSync121, rmSync as rmSync40, writeFileSync as writeFileSync70 } from "fs";
|
|
47470
47761
|
import { tmpdir as tmpdir23 } from "os";
|
|
47471
47762
|
import { dirname as dirname57, join as join132 } from "path";
|
|
47472
47763
|
async function runFullSuite(ctx, signal, opts, checks, notProven2) {
|
|
@@ -47653,6 +47944,10 @@ async function runDeep(ctx, signal, opts = {}) {
|
|
|
47653
47944
|
mkdirSync72(ctx.runDir, { recursive: true });
|
|
47654
47945
|
writeFileSync70(join132(ctx.runDir, "receipt-addendum-1.json"), JSON.stringify(addendum, null, 2) + `
|
|
47655
47946
|
`);
|
|
47947
|
+
if (opts.post === false) {
|
|
47948
|
+
ctx.emit("deep.completed", "deep", { checks, status_state: statusState, addendum_sha256: addendumSha256 });
|
|
47949
|
+
return { status: "completed", data: { checks, addendum_sha256: addendumSha256, status_state: statusState, not_proven: notProvenList, ...notApplicable.length ? { not_applicable: notApplicable } : {} } };
|
|
47950
|
+
}
|
|
47656
47951
|
const headSha = (await safeGitRun(ctx.repoDir, ["rev-parse", "HEAD"], { timeoutMs: 1e4 })).stdout.trim();
|
|
47657
47952
|
const pushNotProven = await postDeepResults({
|
|
47658
47953
|
scriptPath: opts.pushScriptPath ?? DEFAULT_PUSH_SH,
|
|
@@ -47718,7 +48013,7 @@ async function deepWorker(args, deps = {}) {
|
|
|
47718
48013
|
const ac = new AbortController;
|
|
47719
48014
|
for (const sig of ["SIGTERM", "SIGINT"])
|
|
47720
48015
|
process.once(sig, () => ac.abort());
|
|
47721
|
-
const r = await runDeep(ctx, ac.signal, { ...deps.opts });
|
|
48016
|
+
const r = await runDeep(ctx, ac.signal, { ...process.env.LOKI_E10_DEEP_POSTER === "1" ? { post: false } : {}, ...deps.opts });
|
|
47722
48017
|
process.stderr.write((await Promise.resolve().then(() => (init_base_guard(), exports_base_guard))).finishDeferredRun(repoDir, runId2));
|
|
47723
48018
|
if (r.status !== "completed") {
|
|
47724
48019
|
process.stderr.write(`engine10 deep-worker: ${r.reason ?? r.status}
|
|
@@ -47727,6 +48022,53 @@ async function deepWorker(args, deps = {}) {
|
|
|
47727
48022
|
}
|
|
47728
48023
|
return 0;
|
|
47729
48024
|
}
|
|
48025
|
+
async function deepPost(args, deps = {}) {
|
|
48026
|
+
const [runId2, pidArg = "", origin = ""] = args, pid = Number(pidArg);
|
|
48027
|
+
if (!runId2 || !/^e10-[A-Za-z0-9-]+$/.test(runId2) || !Number.isInteger(pid) || pid <= 1) {
|
|
48028
|
+
process.stderr.write(`engine10 deep-post: usage: deep-post <run-id> <deep-pid> <origin>
|
|
48029
|
+
`);
|
|
48030
|
+
return 2;
|
|
48031
|
+
}
|
|
48032
|
+
const repoDir = process.cwd(), runDir = join132(repoDir, ".loki", "runs", runId2), pollMs = deps.pollMs ?? 2000, capMs = deps.waitCapMs ?? (DEEP_CAP_S + 300) * 1000;
|
|
48033
|
+
const alive2 = () => {
|
|
48034
|
+
try {
|
|
48035
|
+
process.kill(pid, 0);
|
|
48036
|
+
return true;
|
|
48037
|
+
} catch (e) {
|
|
48038
|
+
return e.code === "EPERM";
|
|
48039
|
+
}
|
|
48040
|
+
};
|
|
48041
|
+
for (const t0 = Date.now();alive2() && Date.now() - t0 < capMs; )
|
|
48042
|
+
await new Promise((r) => setTimeout(r, pollMs));
|
|
48043
|
+
const read3 = (f) => {
|
|
48044
|
+
try {
|
|
48045
|
+
return JSON.parse(readFileSync121(join132(runDir, f), "utf8"));
|
|
48046
|
+
} catch {
|
|
48047
|
+
return null;
|
|
48048
|
+
}
|
|
48049
|
+
};
|
|
48050
|
+
const receipt = read3("receipt.json"), headSha = typeof receipt?.head_sha === "string" && SHA_RE.test(receipt.head_sha) ? receipt.head_sha : "";
|
|
48051
|
+
let prUrl;
|
|
48052
|
+
try {
|
|
48053
|
+
for (const l of readFileSync121(join132(runDir, "events.jsonl"), "utf8").split(`
|
|
48054
|
+
`)) {
|
|
48055
|
+
if (!l.includes('"pr.opened"'))
|
|
48056
|
+
continue;
|
|
48057
|
+
const u = JSON.parse(l).data?.url;
|
|
48058
|
+
if (typeof u === "string")
|
|
48059
|
+
prUrl = u;
|
|
48060
|
+
}
|
|
48061
|
+
} catch {}
|
|
48062
|
+
const add3 = read3("receipt-addendum-1.json"), ok = add3 !== null && add3.run_id === runId2 && (add3.status_state === "success" || add3.status_state === "failure");
|
|
48063
|
+
const still = alive2(), state = ok ? add3.status_state : "error";
|
|
48064
|
+
const checks = ok && Array.isArray(add3.checks) ? add3.checks : [];
|
|
48065
|
+
const notProven2 = ok && Array.isArray(add3.not_proven) ? add3.not_proven.map(String) : [still ? "deep verify still running after its time limit; no result recorded" : "deep verify ended without writing its addendum; no result recorded"];
|
|
48066
|
+
const out2 = await postDeepResults({ scriptPath: deps.pushScriptPath ?? DEFAULT_PUSH_SH, extraEnv: deps.pushExtraEnv, pinnedOrigin: origin || undefined, prUrl, headSha, repoDir, runDir, checks, notProven: notProven2, statusState: state });
|
|
48067
|
+
for (const n3 of out2)
|
|
48068
|
+
process.stderr.write(`engine10 deep-post: ${n3}
|
|
48069
|
+
`);
|
|
48070
|
+
return out2.some((n3) => n3.startsWith("loki/deep-verify status not set") || n3.startsWith("push refused")) ? 1 : 0;
|
|
48071
|
+
}
|
|
47730
48072
|
var DEFAULT_SECRET_SCAN_SH, FULL_SUITE_TIMEOUT_MS, deepStage, stage8;
|
|
47731
48073
|
var init_deep = __esm(() => {
|
|
47732
48074
|
init_install();
|
|
@@ -47762,7 +48104,7 @@ __export(exports_keys_cmd, {
|
|
|
47762
48104
|
takePubkey: () => takePubkey,
|
|
47763
48105
|
main: () => main4
|
|
47764
48106
|
});
|
|
47765
|
-
import { readFileSync as
|
|
48107
|
+
import { readFileSync as readFileSync122 } from "fs";
|
|
47766
48108
|
import { parseArgs } from "util";
|
|
47767
48109
|
import { createPublicKey as createPublicKey7 } from "crypto";
|
|
47768
48110
|
function takePubkey(args) {
|
|
@@ -47775,7 +48117,7 @@ function takePubkey(args) {
|
|
|
47775
48117
|
return { args: rest };
|
|
47776
48118
|
if (!(file = pubkey[0]))
|
|
47777
48119
|
throw new Error("--pubkey requires a file argument");
|
|
47778
|
-
const t =
|
|
48120
|
+
const t = readFileSync122(file, "utf8"), key = createPublicKey7(t.trim().startsWith("{") ? { key: JSON.parse(t), format: "jwk" } : t);
|
|
47779
48121
|
return key.asymmetricKeyType === "ed25519" ? { args: rest, pubkey: key } : { args: rest, error: `cannot read an Ed25519 public key from ${file}` };
|
|
47780
48122
|
} catch (e) {
|
|
47781
48123
|
return { args: [], error: file ? `cannot read an Ed25519 public key from ${file}` : e.message.replace(/^./, (c) => c.toLowerCase()) };
|
|
@@ -48444,11 +48786,11 @@ var init_engine10_dashboard = __esm(() => {
|
|
|
48444
48786
|
});
|
|
48445
48787
|
|
|
48446
48788
|
// ../../loki-ts/src/engine10/modernize/inventory.ts
|
|
48447
|
-
import { readFileSync as
|
|
48789
|
+
import { readFileSync as readFileSync123 } from "fs";
|
|
48448
48790
|
import { extname as extname4, join as join135 } from "path";
|
|
48449
48791
|
function readCapped2(absPath) {
|
|
48450
48792
|
try {
|
|
48451
|
-
return
|
|
48793
|
+
return readFileSync123(absPath, "utf8").slice(0, MAX_SCAN_BYTES3);
|
|
48452
48794
|
} catch {
|
|
48453
48795
|
return "";
|
|
48454
48796
|
}
|
|
@@ -48735,7 +49077,7 @@ var init_codemod = __esm(() => {
|
|
|
48735
49077
|
|
|
48736
49078
|
// ../../loki-ts/src/engine10/modernize/oracle/seal.ts
|
|
48737
49079
|
import { createHash as createHash33 } from "crypto";
|
|
48738
|
-
import { existsSync as existsSync95, mkdirSync as mkdirSync73, readFileSync as
|
|
49080
|
+
import { existsSync as existsSync95, mkdirSync as mkdirSync73, readFileSync as readFileSync124, writeFileSync as writeFileSync71 } from "fs";
|
|
48739
49081
|
import { join as join137 } from "path";
|
|
48740
49082
|
function normalizersSha(n3) {
|
|
48741
49083
|
return sha2564(JSON.stringify({
|
|
@@ -48811,8 +49153,8 @@ function sealOracle(repoDir, mid, unit, log, normalizers = DEFAULT_NORMALIZERS)
|
|
|
48811
49153
|
throw new Error(`oracle seal: missing ${casesPath}`);
|
|
48812
49154
|
if (!existsSync95(coveragePath))
|
|
48813
49155
|
throw new Error(`oracle seal: missing ${coveragePath}`);
|
|
48814
|
-
const casesRaw =
|
|
48815
|
-
const coverageRaw =
|
|
49156
|
+
const casesRaw = readFileSync124(casesPath, "utf8");
|
|
49157
|
+
const coverageRaw = readFileSync124(coveragePath, "utf8");
|
|
48816
49158
|
const normalizersHash = normalizersSha(normalizers);
|
|
48817
49159
|
const sealed = buildSealedOracle(unit, casesRaw, coverageRaw, normalizersHash);
|
|
48818
49160
|
mkdirSync73(dir, { recursive: true });
|
|
@@ -48844,11 +49186,11 @@ function verifySeal(repoDir, mid, unit) {
|
|
|
48844
49186
|
if (!sealEvent) {
|
|
48845
49187
|
return { ok: false, reason: "no sealing event for this unit in the modernize log; sealed.json is not anchored" };
|
|
48846
49188
|
}
|
|
48847
|
-
const casesRaw =
|
|
49189
|
+
const casesRaw = readFileSync124(casesPath, "utf8");
|
|
48848
49190
|
if (sha2564(casesRaw) !== sealEvent.data.cases_sha256) {
|
|
48849
49191
|
return { ok: false, reason: "cases.jsonl does not match the sealing event's hash (tampered or re-captured)" };
|
|
48850
49192
|
}
|
|
48851
|
-
const coverageRaw =
|
|
49193
|
+
const coverageRaw = readFileSync124(coveragePath, "utf8");
|
|
48852
49194
|
if (sha2564(coverageRaw) !== sealEvent.data.coverage_sha256) {
|
|
48853
49195
|
return { ok: false, reason: "coverage.json does not match the sealing event's hash (tampered or re-captured)" };
|
|
48854
49196
|
}
|
|
@@ -48864,7 +49206,7 @@ function verifySeal(repoDir, mid, unit) {
|
|
|
48864
49206
|
reason: `verdict does not match the sealing event (event type ${sealEvent.type}, recomputed verdict ${recomputed.verdict})`
|
|
48865
49207
|
};
|
|
48866
49208
|
}
|
|
48867
|
-
const sealed = JSON.parse(
|
|
49209
|
+
const sealed = JSON.parse(readFileSync124(sealedPath, "utf8"));
|
|
48868
49210
|
if (JSON.stringify(sealed) !== JSON.stringify(recomputed)) {
|
|
48869
49211
|
return { ok: false, reason: "sealed.json does not match the record recomputed from cases.jsonl and coverage.json (hand-edited)" };
|
|
48870
49212
|
}
|
|
@@ -48880,7 +49222,7 @@ var init_seal2 = __esm(() => {
|
|
|
48880
49222
|
|
|
48881
49223
|
// ../../loki-ts/src/engine10/modernize/oracle/search.ts
|
|
48882
49224
|
import { spawnSync as spawnSync22 } from "child_process";
|
|
48883
|
-
import { copyFileSync as copyFileSync9, existsSync as existsSync96, linkSync as linkSync4, mkdirSync as mkdirSync74, mkdtempSync as mkdtempSync19, readFileSync as
|
|
49225
|
+
import { copyFileSync as copyFileSync9, existsSync as existsSync96, linkSync as linkSync4, mkdirSync as mkdirSync74, mkdtempSync as mkdtempSync19, readFileSync as readFileSync125, renameSync as renameSync26, rmSync as rmSync41, rmdirSync as rmdirSync3, writeFileSync as writeFileSync72 } from "fs";
|
|
48884
49226
|
import { tmpdir as tmpdir24 } from "os";
|
|
48885
49227
|
import { basename as basename40, dirname as dirname59, join as join138 } from "path";
|
|
48886
49228
|
function search(unitSource, seedCases, propose, runCapture, opts = {}) {
|
|
@@ -48963,7 +49305,7 @@ function realCaptureRunner(unitPath, cases, outPath) {
|
|
|
48963
49305
|
`).find((l) => l.trim().length > 0) ?? "(no stderr)";
|
|
48964
49306
|
return captureFailed(`py_capture.py exit ${r.status}: ${firstErrLine}`);
|
|
48965
49307
|
}
|
|
48966
|
-
const raw2 = JSON.parse(
|
|
49308
|
+
const raw2 = JSON.parse(readFileSync125(covFile, "utf8"));
|
|
48967
49309
|
if (outPath)
|
|
48968
49310
|
copyFileSync9(outFile, outPath);
|
|
48969
49311
|
return {
|
|
@@ -48996,7 +49338,7 @@ function makeProposeInputs(session, cap = 20) {
|
|
|
48996
49338
|
copyFileSync9(unitPath, unitFile);
|
|
48997
49339
|
session({ cwd, env: tokenFreeEnv(), unitFile, missing, round: round2 });
|
|
48998
49340
|
const out2 = [];
|
|
48999
|
-
for (const line2 of
|
|
49341
|
+
for (const line2 of readFileSync125(join138(cwd, "proposals.jsonl"), "utf8").split(`
|
|
49000
49342
|
`)) {
|
|
49001
49343
|
try {
|
|
49002
49344
|
const c = JSON.parse(line2);
|
|
@@ -49039,7 +49381,7 @@ function captureUnitOracle(a) {
|
|
|
49039
49381
|
const created = [];
|
|
49040
49382
|
for (let p = dir;!existsSync96(p) && !created.includes(p); p = dirname59(p))
|
|
49041
49383
|
created.push(p);
|
|
49042
|
-
const read3 = (p) =>
|
|
49384
|
+
const read3 = (p) => readFileSync125(p, "utf8").split(`
|
|
49043
49385
|
`).filter(Boolean).map((l) => JSON.parse(l));
|
|
49044
49386
|
const tmpCases = join138(dir, `.cases.${process.pid}.tmp`);
|
|
49045
49387
|
const tmpCov = join138(dir, `.coverage.${process.pid}.tmp`);
|
|
@@ -49102,7 +49444,7 @@ var init_search = __esm(() => {
|
|
|
49102
49444
|
});
|
|
49103
49445
|
|
|
49104
49446
|
// ../../loki-ts/src/engine10/modernize/equiv.ts
|
|
49105
|
-
import { readFileSync as
|
|
49447
|
+
import { readFileSync as readFileSync126 } from "fs";
|
|
49106
49448
|
import { join as join139 } from "path";
|
|
49107
49449
|
function parseCases(raw2) {
|
|
49108
49450
|
const out2 = [];
|
|
@@ -49298,11 +49640,11 @@ function checkEquivalence(repoDir, mid, unit, newTreeDir, normalizers, runNew, l
|
|
|
49298
49640
|
return notProvenResult(unit, "normalizers invalid: skip_fields covers every field, nothing would be compared", log);
|
|
49299
49641
|
}
|
|
49300
49642
|
const dir = oracleDir(repoDir, mid, unit);
|
|
49301
|
-
const sealed = JSON.parse(
|
|
49643
|
+
const sealed = JSON.parse(readFileSync126(join139(dir, "sealed.json"), "utf8"));
|
|
49302
49644
|
const normCheck = verifyNormalizersAgainstSeal(sealed, normalizers);
|
|
49303
49645
|
if (!normCheck.ok)
|
|
49304
49646
|
return notProvenResult(unit, `normalizers: ${normCheck.reason ?? "check failed"}`, log);
|
|
49305
|
-
const records = parseCases(
|
|
49647
|
+
const records = parseCases(readFileSync126(join139(dir, "cases.jsonl"), "utf8"));
|
|
49306
49648
|
const heldOutSet = new Set(sealed.held_out);
|
|
49307
49649
|
let pass = 0;
|
|
49308
49650
|
let fail2 = 0;
|
|
@@ -49723,21 +50065,21 @@ var init_scheduler = __esm(() => {
|
|
|
49723
50065
|
});
|
|
49724
50066
|
|
|
49725
50067
|
// ../../loki-ts/src/engine10/modernize/resume.ts
|
|
49726
|
-
import { existsSync as existsSync97, readFileSync as
|
|
50068
|
+
import { existsSync as existsSync97, readFileSync as readFileSync127 } from "fs";
|
|
49727
50069
|
function loadResumeState(repoDir, mid) {
|
|
49728
50070
|
const path = modernizeEventsPath(repoDir, mid);
|
|
49729
50071
|
if (!existsSync97(path))
|
|
49730
50072
|
return { ok: false, reason: `no modernize log at ${path}` };
|
|
49731
50073
|
let text4;
|
|
49732
50074
|
try {
|
|
49733
|
-
text4 =
|
|
50075
|
+
text4 = readFileSync127(path, "utf8");
|
|
49734
50076
|
} catch (e) {
|
|
49735
50077
|
return { ok: false, reason: `modernize log unreadable: ${e instanceof Error ? e.message : String(e)}` };
|
|
49736
50078
|
}
|
|
49737
50079
|
const pj = planPath(repoDir, mid);
|
|
49738
50080
|
if (existsSync97(pj)) {
|
|
49739
50081
|
try {
|
|
49740
|
-
JSON.parse(
|
|
50082
|
+
JSON.parse(readFileSync127(pj, "utf8"));
|
|
49741
50083
|
} catch {
|
|
49742
50084
|
return { ok: false, reason: `plan.json is corrupt or partial: ${pj}` };
|
|
49743
50085
|
}
|
|
@@ -49850,7 +50192,7 @@ var init_resume = __esm(() => {
|
|
|
49850
50192
|
});
|
|
49851
50193
|
|
|
49852
50194
|
// ../../loki-ts/src/engine10/modernize/report.ts
|
|
49853
|
-
import { mkdirSync as mkdirSync75, readFileSync as
|
|
50195
|
+
import { mkdirSync as mkdirSync75, readFileSync as readFileSync128, writeFileSync as writeFileSync73 } from "fs";
|
|
49854
50196
|
import { dirname as dirname60 } from "path";
|
|
49855
50197
|
function buildReport(o) {
|
|
49856
50198
|
const units = o.units.map((x) => ({ unit: x.unit, verdict: x.verdict, not_proven: [...x.not_proven], rate: x.rate, branchPct: x.branchPct, receiptPath: x.receiptPath, receiptSha256: x.receiptSha256 }));
|
|
@@ -49954,7 +50296,7 @@ var init_ship2 = __esm(() => {
|
|
|
49954
50296
|
});
|
|
49955
50297
|
|
|
49956
50298
|
// ../../loki-ts/src/engine10/modernize/presealed_wall.ts
|
|
49957
|
-
import { existsSync as existsSync98, mkdirSync as mkdirSync77, readFileSync as
|
|
50299
|
+
import { existsSync as existsSync98, mkdirSync as mkdirSync77, readFileSync as readFileSync129, writeFileSync as writeFileSync75 } from "fs";
|
|
49958
50300
|
import { join as join142 } from "path";
|
|
49959
50301
|
function isRealFailCount(n3) {
|
|
49960
50302
|
return typeof n3 === "number" && Number.isInteger(n3) && n3 >= 1;
|
|
@@ -49992,7 +50334,7 @@ function sealPreSealedWall(repoDir, mid, unit, target, runConformance, log, base
|
|
|
49992
50334
|
if (!oracleCheck.ok)
|
|
49993
50335
|
return refuse(`oracle seal invalid: ${oracleCheck.reason ?? "unknown"}; presealed wall refused`);
|
|
49994
50336
|
const dir = oracleDir(repoDir, mid, unit);
|
|
49995
|
-
const oracleSealed = JSON.parse(
|
|
50337
|
+
const oracleSealed = JSON.parse(readFileSync129(join142(dir, "sealed.json"), "utf8"));
|
|
49996
50338
|
if (oracleSealed.verdict !== "PROVEN_ORACLE") {
|
|
49997
50339
|
return refuse(`oracle seal invalid: oracle is ${oracleSealed.verdict} (${oracleSealed.not_proven ?? "no reason recorded"}); presealed wall refused`);
|
|
49998
50340
|
}
|
|
@@ -50061,7 +50403,7 @@ function verifyPreSealedWall(repoDir, mid, unit) {
|
|
|
50061
50403
|
const expectedSha = event.data.sealed_sha256;
|
|
50062
50404
|
if (typeof expectedSha !== "string")
|
|
50063
50405
|
return { ok: false, reason: "sealing event has no sealed_sha256" };
|
|
50064
|
-
const sealedRaw =
|
|
50406
|
+
const sealedRaw = readFileSync129(sealedPath, "utf8");
|
|
50065
50407
|
const actualSha = sha2564(sealedRaw);
|
|
50066
50408
|
if (actualSha !== expectedSha) {
|
|
50067
50409
|
return { ok: false, reason: "presealed_wall.json does not match the sealing event's hash (tampered or rewritten)" };
|
|
@@ -50070,7 +50412,7 @@ function verifyPreSealedWall(repoDir, mid, unit) {
|
|
|
50070
50412
|
if (!oracleCheck.ok) {
|
|
50071
50413
|
return { ok: false, reason: `bound oracle seal is no longer valid: ${oracleCheck.reason ?? "unknown"}` };
|
|
50072
50414
|
}
|
|
50073
|
-
const oracleSealed = JSON.parse(
|
|
50415
|
+
const oracleSealed = JSON.parse(readFileSync129(join142(oracleDir(repoDir, mid, unit), "sealed.json"), "utf8"));
|
|
50074
50416
|
const carried = JSON.parse(sealedRaw);
|
|
50075
50417
|
if (carried.oracle_cases_sha256 !== oracleSealed.cases_sha256 || carried.oracle_coverage_sha256 !== oracleSealed.coverage_sha256 || typeof carried.oracle_normalizers_sha256 !== "string" || typeof oracleSealed.normalizers_sha256 !== "string" || carried.oracle_normalizers_sha256 !== oracleSealed.normalizers_sha256) {
|
|
50076
50418
|
return { ok: false, reason: "carried oracle hashes do not match the current oracle seal" };
|
|
@@ -50096,7 +50438,7 @@ var init_presealed_wall = __esm(() => {
|
|
|
50096
50438
|
// ../../loki-ts/src/engine10/modernize/unit.ts
|
|
50097
50439
|
import { spawnSync as spawnSync23 } from "child_process";
|
|
50098
50440
|
import { createHash as createHash34 } from "crypto";
|
|
50099
|
-
import { lstatSync as lstatSync32, readFileSync as
|
|
50441
|
+
import { lstatSync as lstatSync32, readFileSync as readFileSync130, readdirSync as readdirSync48, readlinkSync as readlinkSync5, realpathSync as realpathSync38, rmSync as rmSync42 } from "fs";
|
|
50100
50442
|
import { tmpdir as tmpdir25 } from "os";
|
|
50101
50443
|
import { join as join143, sep as sep22 } from "path";
|
|
50102
50444
|
function isSealedName(rel) {
|
|
@@ -50125,13 +50467,13 @@ function purgePycache(dir) {
|
|
|
50125
50467
|
function outsideTargetDigest(dir, full) {
|
|
50126
50468
|
let real3;
|
|
50127
50469
|
try {
|
|
50128
|
-
real3 =
|
|
50470
|
+
real3 = realpathSync38(full);
|
|
50129
50471
|
} catch {
|
|
50130
50472
|
return "dangling";
|
|
50131
50473
|
}
|
|
50132
50474
|
let root;
|
|
50133
50475
|
try {
|
|
50134
|
-
root =
|
|
50476
|
+
root = realpathSync38(dir);
|
|
50135
50477
|
} catch {
|
|
50136
50478
|
return "noroot";
|
|
50137
50479
|
}
|
|
@@ -50174,7 +50516,7 @@ function outsideTargetDigest(dir, full) {
|
|
|
50174
50516
|
}
|
|
50175
50517
|
if (st.isFile()) {
|
|
50176
50518
|
try {
|
|
50177
|
-
h.update(
|
|
50519
|
+
h.update(readFileSync130(p));
|
|
50178
50520
|
} catch {
|
|
50179
50521
|
h.update("unreadable");
|
|
50180
50522
|
}
|
|
@@ -50227,7 +50569,7 @@ function conformanceHashes(dir) {
|
|
|
50227
50569
|
}
|
|
50228
50570
|
if (!st.isFile())
|
|
50229
50571
|
continue;
|
|
50230
|
-
data =
|
|
50572
|
+
data = readFileSync130(join143(dir, rel));
|
|
50231
50573
|
} catch {
|
|
50232
50574
|
continue;
|
|
50233
50575
|
}
|
|
@@ -50286,7 +50628,7 @@ function notProvenUnitResult(unit, reason, oracle, wall) {
|
|
|
50286
50628
|
return { unit, verdict: "NOT_PROVEN", oracle, wall, equiv: null, not_proven: [reason], conformance: null };
|
|
50287
50629
|
}
|
|
50288
50630
|
function readOracleSealed(repoDir, mid, unit) {
|
|
50289
|
-
return JSON.parse(
|
|
50631
|
+
return JSON.parse(readFileSync130(join143(oracleDir(repoDir, mid, unit), "sealed.json"), "utf8"));
|
|
50290
50632
|
}
|
|
50291
50633
|
function runUnit(card, log, runConformance, implement, runNew, runStub, collect) {
|
|
50292
50634
|
const { repoDir, mid, unit } = card;
|
|
@@ -50397,7 +50739,7 @@ var init_unit = __esm(() => {
|
|
|
50397
50739
|
|
|
50398
50740
|
// ../../loki-ts/src/engine10/modernize/wave.ts
|
|
50399
50741
|
import { spawnSync as spawnSync24 } from "child_process";
|
|
50400
|
-
import { readFileSync as
|
|
50742
|
+
import { readFileSync as readFileSync131, statSync as statSync39 } from "fs";
|
|
50401
50743
|
import { join as join144 } from "path";
|
|
50402
50744
|
function clampTimeout(ms) {
|
|
50403
50745
|
if (ms === undefined || !Number.isFinite(ms) || ms <= 0)
|
|
@@ -50467,7 +50809,7 @@ function detectWaveCommands(inv, target) {
|
|
|
50467
50809
|
const none = { build: null, integration: null, original_suite: null };
|
|
50468
50810
|
const text4 = () => {
|
|
50469
50811
|
try {
|
|
50470
|
-
return
|
|
50812
|
+
return readFileSync131(join144(target, marker ?? ""), "utf8");
|
|
50471
50813
|
} catch {
|
|
50472
50814
|
return "";
|
|
50473
50815
|
}
|
|
@@ -50491,7 +50833,7 @@ function detectWaveCommands(inv, target) {
|
|
|
50491
50833
|
let toxIni = "";
|
|
50492
50834
|
if (inv.files.includes("tox.ini")) {
|
|
50493
50835
|
try {
|
|
50494
|
-
toxIni =
|
|
50836
|
+
toxIni = readFileSync131(join144(target, "tox.ini"), "utf8");
|
|
50495
50837
|
} catch {}
|
|
50496
50838
|
}
|
|
50497
50839
|
const integration = toxIni.includes("[testenv:integration") ? { argv: ["tox", "-e", "integration"] } : itDir && pytest ? { argv: ["python3", "-m", "pytest", "-q", itDir] } : null;
|
|
@@ -50523,7 +50865,7 @@ var init_wave = __esm(() => {
|
|
|
50523
50865
|
|
|
50524
50866
|
// ../../loki-ts/src/util/modernize_unit.ts
|
|
50525
50867
|
import { spawnSync as spawnSync25 } from "child_process";
|
|
50526
|
-
import { existsSync as existsSync99, lstatSync as lstatSync33, mkdtempSync as mkdtempSync20, readFileSync as
|
|
50868
|
+
import { existsSync as existsSync99, lstatSync as lstatSync33, mkdtempSync as mkdtempSync20, readFileSync as readFileSync132, realpathSync as realpathSync39, rmSync as rmSync43, statSync as statSync40, writeFileSync as writeFileSync76 } from "fs";
|
|
50527
50869
|
import { tmpdir as tmpdir26 } from "os";
|
|
50528
50870
|
import { join as join145, sep as sep23 } from "path";
|
|
50529
50871
|
function parseUnitArgs(args) {
|
|
@@ -50604,8 +50946,8 @@ function defaultUnitFile(unitId, newTreeDir) {
|
|
|
50604
50946
|
if (!isSafeUnitId(unitId))
|
|
50605
50947
|
return null;
|
|
50606
50948
|
try {
|
|
50607
|
-
const root =
|
|
50608
|
-
const real3 =
|
|
50949
|
+
const root = realpathSync39(newTreeDir);
|
|
50950
|
+
const real3 = realpathSync39(join145(root, unitId));
|
|
50609
50951
|
return real3.startsWith(root + sep23) ? real3 : null;
|
|
50610
50952
|
} catch {
|
|
50611
50953
|
return null;
|
|
@@ -50651,7 +50993,7 @@ function runPythonCase(o, unitId, newTreeDir, rec2, stub) {
|
|
|
50651
50993
|
if (r.status !== 0 || !existsSync99(out2))
|
|
50652
50994
|
throw new Error(`new-tree case runner failed (${r.status ?? r.signal ?? "no status"}): ${String(r.stderr ?? "").trim().split(`
|
|
50653
50995
|
`).pop() ?? ""}`);
|
|
50654
|
-
const line2 =
|
|
50996
|
+
const line2 = readFileSync132(out2, "utf8").split(`
|
|
50655
50997
|
`).find((l) => l.trim() !== "");
|
|
50656
50998
|
if (!line2)
|
|
50657
50999
|
throw new Error("new-tree case runner produced no record");
|
|
@@ -50773,7 +51115,7 @@ var init_modernize_unit = __esm(() => {
|
|
|
50773
51115
|
|
|
50774
51116
|
// ../../loki-ts/src/util/modernize_coordinator.ts
|
|
50775
51117
|
import { createHash as createHash35 } from "crypto";
|
|
50776
|
-
import { existsSync as existsSync100, mkdtempSync as mkdtempSync21, readFileSync as
|
|
51118
|
+
import { existsSync as existsSync100, mkdtempSync as mkdtempSync21, readFileSync as readFileSync133, rmSync as rmSync44 } from "fs";
|
|
50777
51119
|
import { tmpdir as tmpdir27 } from "os";
|
|
50778
51120
|
import { join as join146 } from "path";
|
|
50779
51121
|
function shipUnitOf(d, unit, o) {
|
|
@@ -51029,7 +51371,7 @@ function productionWaveDeps(o) {
|
|
|
51029
51371
|
}
|
|
51030
51372
|
};
|
|
51031
51373
|
}
|
|
51032
|
-
var productionReslice, sha2565 = (p) => existsSync100(p) ? createHash35("sha256").update(
|
|
51374
|
+
var productionReslice, sha2565 = (p) => existsSync100(p) ? createHash35("sha256").update(readFileSync133(p)).digest("hex") : "n/a", MULTI_FILE_REASON = "multi-file unit: capture not supported (founder default)";
|
|
51033
51375
|
var init_modernize_coordinator = __esm(() => {
|
|
51034
51376
|
init_codemod();
|
|
51035
51377
|
init_search();
|
|
@@ -51362,7 +51704,7 @@ __export(exports_export_sarif, {
|
|
|
51362
51704
|
preRedFromEvents: () => preRedFromEvents,
|
|
51363
51705
|
main: () => main7
|
|
51364
51706
|
});
|
|
51365
|
-
import { existsSync as existsSync102, readFileSync as
|
|
51707
|
+
import { existsSync as existsSync102, readFileSync as readFileSync134, writeFileSync as writeFileSync77 } from "fs";
|
|
51366
51708
|
import { join as join147 } from "path";
|
|
51367
51709
|
function scanDiff(diff) {
|
|
51368
51710
|
const out2 = [];
|
|
@@ -51394,7 +51736,7 @@ function scanDiff(diff) {
|
|
|
51394
51736
|
function preRedFromEvents(runDir) {
|
|
51395
51737
|
try {
|
|
51396
51738
|
let pre = [];
|
|
51397
|
-
for (const l of
|
|
51739
|
+
for (const l of readFileSync134(join147(runDir, "events.jsonl"), "utf8").split(`
|
|
51398
51740
|
`)) {
|
|
51399
51741
|
if (!l.includes('"stage.completed"'))
|
|
51400
51742
|
continue;
|
|
@@ -51435,7 +51777,7 @@ async function main7(args, deps = {}) {
|
|
|
51435
51777
|
`), 66;
|
|
51436
51778
|
let receipt;
|
|
51437
51779
|
try {
|
|
51438
|
-
receipt = JSON.parse(
|
|
51780
|
+
receipt = JSON.parse(readFileSync134(receiptPath, "utf8"));
|
|
51439
51781
|
} catch {
|
|
51440
51782
|
return process.stderr.write(`loki export --sarif: unreadable receipt for ${runId2}
|
|
51441
51783
|
`), 66;
|
|
@@ -51452,7 +51794,7 @@ async function main7(args, deps = {}) {
|
|
|
51452
51794
|
findings.push(...receiptFindings(receipt, preRedFromEvents(runDir)));
|
|
51453
51795
|
let version2 = "0.0.0";
|
|
51454
51796
|
try {
|
|
51455
|
-
version2 =
|
|
51797
|
+
version2 = readFileSync134(join147(REPO_ROOT, "VERSION"), "utf8").trim() || version2;
|
|
51456
51798
|
} catch {}
|
|
51457
51799
|
const out2 = join147(runDir, "findings.sarif");
|
|
51458
51800
|
writeFileSync77(out2, JSON.stringify(toSarif(findings, version2, deps.repoDir ?? process.cwd()), null, 2) + `
|
|
@@ -51694,7 +52036,7 @@ var init_undo = __esm(() => {
|
|
|
51694
52036
|
});
|
|
51695
52037
|
|
|
51696
52038
|
// ../../loki-ts/src/commands/run_status.ts
|
|
51697
|
-
import { existsSync as existsSync103, readdirSync as readdirSync49, readFileSync as
|
|
52039
|
+
import { existsSync as existsSync103, readdirSync as readdirSync49, readFileSync as readFileSync135, statSync as statSync42 } from "fs";
|
|
51698
52040
|
import { basename as basename41, dirname as dirname61, join as join148, resolve as resolve37 } from "path";
|
|
51699
52041
|
function runsRoot(env, repoDir) {
|
|
51700
52042
|
return env.LOKI_DIR ? join148(resolve37(repoDir, env.LOKI_DIR), "runs") : join148(repoDir, ".loki", "runs");
|
|
@@ -51753,7 +52095,7 @@ __export(exports_base_guard, {
|
|
|
51753
52095
|
});
|
|
51754
52096
|
import { execFileSync as execFileSync12 } from "child_process";
|
|
51755
52097
|
import { createHash as createHash37 } from "crypto";
|
|
51756
|
-
import { existsSync as existsSync104, mkdirSync as mkdirSync78, mkdtempSync as mkdtempSync22, readdirSync as readdirSync50, readFileSync as
|
|
52098
|
+
import { existsSync as existsSync104, mkdirSync as mkdirSync78, mkdtempSync as mkdtempSync22, readdirSync as readdirSync50, readFileSync as readFileSync136, readlinkSync as readlinkSync6, realpathSync as realpathSync40, rmSync as rmSync45, statSync as statSync43, symlinkSync as symlinkSync5, utimesSync, writeFileSync as writeFileSync78 } from "fs";
|
|
51757
52099
|
import { tmpdir as tmpdir28 } from "os";
|
|
51758
52100
|
import { basename as basename42, dirname as dirname62, join as join149, relative as relative30, resolve as resolve38, sep as sep24 } from "path";
|
|
51759
52101
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
@@ -51797,7 +52139,7 @@ function lokiCommitsOnHead(repoDir, target) {
|
|
|
51797
52139
|
const runsDir = join149(repoDir, ".loki", "runs");
|
|
51798
52140
|
for (const id of listRunIds(runsDir)) {
|
|
51799
52141
|
try {
|
|
51800
|
-
const rc = JSON.parse(
|
|
52142
|
+
const rc = JSON.parse(readFileSync136(join149(runsDir, id, "receipt.json"), "utf8"));
|
|
51801
52143
|
const sha6 = typeof rc.head_sha === "string" ? rc.head_sha : "", from = typeof rc.base_sha === "string" ? rc.base_sha : "";
|
|
51802
52144
|
if (!/^[0-9a-f]{40}$/.test(sha6) || !/^[0-9a-f]{40}$/.test(from) || sha6 === from)
|
|
51803
52145
|
continue;
|
|
@@ -51855,7 +52197,7 @@ function insideAny(p, roots) {
|
|
|
51855
52197
|
if (under2(resolve38(p)))
|
|
51856
52198
|
return true;
|
|
51857
52199
|
try {
|
|
51858
|
-
return under2(
|
|
52200
|
+
return under2(realpathSync40(p));
|
|
51859
52201
|
} catch {
|
|
51860
52202
|
return false;
|
|
51861
52203
|
}
|
|
@@ -51870,7 +52212,7 @@ function namedPaths2(file, text4) {
|
|
|
51870
52212
|
function depsSeeHead(pkgDir, repoDir) {
|
|
51871
52213
|
let roots;
|
|
51872
52214
|
try {
|
|
51873
|
-
roots = [...new Set([resolve38(repoDir),
|
|
52215
|
+
roots = [...new Set([resolve38(repoDir), realpathSync40(repoDir)])];
|
|
51874
52216
|
} catch {
|
|
51875
52217
|
return true;
|
|
51876
52218
|
}
|
|
@@ -51884,7 +52226,7 @@ function depsSeeHead(pkgDir, repoDir) {
|
|
|
51884
52226
|
const t = resolve38(dir, readlinkSync6(p));
|
|
51885
52227
|
let rt = t;
|
|
51886
52228
|
try {
|
|
51887
|
-
rt =
|
|
52229
|
+
rt = realpathSync40(t);
|
|
51888
52230
|
} catch {}
|
|
51889
52231
|
if (insideAny(t, roots) && !own.some((r) => rt === r || rt.startsWith(r + sep24)))
|
|
51890
52232
|
return true;
|
|
@@ -51892,7 +52234,7 @@ function depsSeeHead(pkgDir, repoDir) {
|
|
|
51892
52234
|
if (walk(p, own))
|
|
51893
52235
|
return true;
|
|
51894
52236
|
} else if (REPO_LINK_FILE.test(e.name)) {
|
|
51895
|
-
const text4 =
|
|
52237
|
+
const text4 = readFileSync136(p, "utf8");
|
|
51896
52238
|
if (roots.some((r) => text4.includes(r)) || namedPaths2(p, text4).some((n3) => insideAny(n3, roots)))
|
|
51897
52239
|
return true;
|
|
51898
52240
|
}
|
|
@@ -51903,7 +52245,7 @@ function depsSeeHead(pkgDir, repoDir) {
|
|
|
51903
52245
|
return ["node_modules", ".venv"].some((d) => {
|
|
51904
52246
|
try {
|
|
51905
52247
|
const top = join149(pkgDir, d);
|
|
51906
|
-
return walk(top, [...new Set([resolve38(top),
|
|
52248
|
+
return walk(top, [...new Set([resolve38(top), realpathSync40(top)])]);
|
|
51907
52249
|
} catch (e) {
|
|
51908
52250
|
if (e.code === "ENOENT")
|
|
51909
52251
|
return false;
|
|
@@ -52072,7 +52414,7 @@ function splitDeclaredAdvisories(notes, c) {
|
|
|
52072
52414
|
const wall = () => wallText ??= c.wallPaths.map((w) => {
|
|
52073
52415
|
for (const f of [sealedWallCopy(c.runDir, w), join149(c.repoDir, w)])
|
|
52074
52416
|
try {
|
|
52075
|
-
return
|
|
52417
|
+
return readFileSync136(f, "utf8");
|
|
52076
52418
|
} catch {}
|
|
52077
52419
|
return "";
|
|
52078
52420
|
}).join(`
|
|
@@ -52080,7 +52422,7 @@ function splitDeclaredAdvisories(notes, c) {
|
|
|
52080
52422
|
const named2 = (f) => new RegExp(`${f.includes("/") ? `(?<![\\w./-])${escapeRegex(f)}(?![\\w-])|` : ""}[/"'\`]${escapeRegex(basename42(f))}(?=["'\`\\s);]|$)`).test(wall());
|
|
52081
52423
|
const linkOk = (f) => {
|
|
52082
52424
|
try {
|
|
52083
|
-
const root =
|
|
52425
|
+
const root = realpathSync40(c.repoDir), t = realpathSync40(join149(c.repoDir, f)), rel = relative30(root, t);
|
|
52084
52426
|
return !rel.startsWith("..") && !rel.split(sep24).includes(".git") && statSync43(t).isFile() && changed.has(rel.split(sep24).join("/")) && !isTestFile(rel) && !c.wallPaths.includes(rel);
|
|
52085
52427
|
} catch {
|
|
52086
52428
|
return false;
|
|
@@ -52113,7 +52455,7 @@ function removeRunWorktrees(repoDir, baseSha) {
|
|
|
52113
52455
|
return;
|
|
52114
52456
|
const roots = [tmpdir28()];
|
|
52115
52457
|
try {
|
|
52116
|
-
roots.push(
|
|
52458
|
+
roots.push(realpathSync40(tmpdir28()));
|
|
52117
52459
|
} catch {}
|
|
52118
52460
|
for (const t of checkedOut(repoDir).trees.slice(1)) {
|
|
52119
52461
|
const named2 = RUN_TMP_WORKTREE_RE.test(basename42(t.path)) || RUN_TMP_WORKTREE_RE.test(basename42(dirname62(t.path)));
|
|
@@ -52172,7 +52514,7 @@ function returnCheckout(repoDir, branch, orig) {
|
|
|
52172
52514
|
function removeOwnWallFiles(repoDir, runId2) {
|
|
52173
52515
|
let files = [];
|
|
52174
52516
|
try {
|
|
52175
|
-
files = JSON.parse(
|
|
52517
|
+
files = JSON.parse(readFileSync136(join149(repoDir, ".loki", "runs", runId2, "receipt.json"), "utf8")).wall?.files ?? [];
|
|
52176
52518
|
} catch {
|
|
52177
52519
|
return [];
|
|
52178
52520
|
}
|
|
@@ -52186,7 +52528,7 @@ function removeOwnWallFiles(repoDir, runId2) {
|
|
|
52186
52528
|
if (git13(repoDir, ["ls-files", "--error-unmatch", "--", rel]) !== null)
|
|
52187
52529
|
continue;
|
|
52188
52530
|
try {
|
|
52189
|
-
if (createHash37("sha256").update(
|
|
52531
|
+
if (createHash37("sha256").update(readFileSync136(abs)).digest("hex") !== f.sha256)
|
|
52190
52532
|
continue;
|
|
52191
52533
|
rmSync45(abs);
|
|
52192
52534
|
gone.push(rel);
|
|
@@ -52279,7 +52621,7 @@ var exists2 = (repoDir, ref) => git13(repoDir, ["rev-parse", "--verify", "-q", `
|
|
|
52279
52621
|
}, keepRunBranch = (env = process.env) => env.LOKI_KEEP_RUN_BRANCH === "1", deepPid = (runDir) => {
|
|
52280
52622
|
let pid;
|
|
52281
52623
|
try {
|
|
52282
|
-
pid =
|
|
52624
|
+
pid = readFileSync136(join149(runDir, "events.jsonl"), "utf8").split(`
|
|
52283
52625
|
`).filter((l) => l.includes('"deep.started"')).map((l) => Number(JSON.parse(l).data?.pid)).pop();
|
|
52284
52626
|
if (!pid || !Number.isInteger(pid) || pid <= 1)
|
|
52285
52627
|
return null;
|
|
@@ -52290,7 +52632,7 @@ var exists2 = (repoDir, ref) => git13(repoDir, ["rev-parse", "--verify", "-q", `
|
|
|
52290
52632
|
}
|
|
52291
52633
|
}, deepAlive = (runDir) => deepPid(runDir) !== null, runLive = (runDir) => runOwnerAlive(runDir) || deepAlive(runDir), readRecord = (file) => {
|
|
52292
52634
|
try {
|
|
52293
|
-
return JSON.parse(
|
|
52635
|
+
return JSON.parse(readFileSync136(file, "utf8"));
|
|
52294
52636
|
} catch {
|
|
52295
52637
|
return null;
|
|
52296
52638
|
}
|
|
@@ -52357,6 +52699,8 @@ __export(exports_verify, {
|
|
|
52357
52699
|
collateralTests: () => collateralTests,
|
|
52358
52700
|
checkExcerpt: () => checkExcerpt,
|
|
52359
52701
|
changedFiles: () => changedFiles,
|
|
52702
|
+
baseMemoOn: () => baseMemoOn,
|
|
52703
|
+
baseMemo: () => baseMemo,
|
|
52360
52704
|
baseCrashEnvOn: () => baseCrashEnvOn,
|
|
52361
52705
|
WALL_FAILURE_TAIL_FILE: () => WALL_FAILURE_TAIL_FILE,
|
|
52362
52706
|
WALL_FAILURE_TAIL_CAP: () => WALL_FAILURE_TAIL_CAP,
|
|
@@ -52364,7 +52708,7 @@ __export(exports_verify, {
|
|
|
52364
52708
|
COLLATERAL_RED: () => COLLATERAL_RED,
|
|
52365
52709
|
BCE_REASON: () => BCE_REASON
|
|
52366
52710
|
});
|
|
52367
|
-
import { existsSync as existsSync105, mkdtempSync as mkdtempSync23, readFileSync as
|
|
52711
|
+
import { existsSync as existsSync105, mkdtempSync as mkdtempSync23, readFileSync as readFileSync137, realpathSync as realpathSync41, rmSync as rmSync46 } from "fs";
|
|
52368
52712
|
import { tmpdir as tmpdir29 } from "os";
|
|
52369
52713
|
import { basename as basename43, isAbsolute as isAbsolute21, join as join150, relative as relative31, resolve as resolve39 } from "path";
|
|
52370
52714
|
function crashSignature(out2) {
|
|
@@ -52420,7 +52764,7 @@ function editedTestTitles(repoDir, baseSha, rel) {
|
|
|
52420
52764
|
}
|
|
52421
52765
|
let lines2 = [];
|
|
52422
52766
|
try {
|
|
52423
|
-
lines2 =
|
|
52767
|
+
lines2 = readFileSync137(join150(repoDir, rel), "utf8").split(`
|
|
52424
52768
|
`);
|
|
52425
52769
|
} catch {}
|
|
52426
52770
|
const out2 = new Set;
|
|
@@ -52575,13 +52919,13 @@ async function vitestBatch(cwd, rels, signal, opts = {}) {
|
|
|
52575
52919
|
const r = await runOnce3("npx", ["--no-install", "vitest", "run", "--reporter=json", "--reporter=default", `--outputFile.json=${file}`, ...rels], cwd, signal, { timeoutMs: opts.timeoutMs ?? batchTimeoutMs(rels.length), group: true, ...opts.path ? { path: opts.path } : {} });
|
|
52576
52920
|
if (r.cut || r.missing || !existsSync105(file) || UNHANDLED_RE.test(r.out))
|
|
52577
52921
|
return null;
|
|
52578
|
-
const rep = JSON.parse(
|
|
52922
|
+
const rep = JSON.parse(readFileSync137(file, "utf8"));
|
|
52579
52923
|
const tests = rep.testResults ?? [], failedFile = (tr) => tr.status === "failed";
|
|
52580
52924
|
if (!r.ok && !tests.some(failedFile))
|
|
52581
52925
|
return null;
|
|
52582
52926
|
const real3 = (p) => {
|
|
52583
52927
|
try {
|
|
52584
|
-
return
|
|
52928
|
+
return realpathSync41(p);
|
|
52585
52929
|
} catch {
|
|
52586
52930
|
return p;
|
|
52587
52931
|
}
|
|
@@ -52704,7 +53048,7 @@ function diffSymbols(ctx, changed) {
|
|
|
52704
53048
|
if (code.length === 0)
|
|
52705
53049
|
return [];
|
|
52706
53050
|
try {
|
|
52707
|
-
return changedSymbols(safeGit(ctx.repoDir, ["diff", "-U0", "--no-color", "--no-ext-diff", "--no-textconv", "--no-renames", ctx.baseSha, "--", ...code], { timeout: 20000 }), (p) =>
|
|
53051
|
+
return changedSymbols(safeGit(ctx.repoDir, ["diff", "-U0", "--no-color", "--no-ext-diff", "--no-textconv", "--no-renames", ctx.baseSha, "--", ...code], { timeout: 20000 }), (p) => readFileSync137(join150(ctx.repoDir, p), "utf8")).filter((n3) => n3.length >= 3);
|
|
52708
53052
|
} catch {
|
|
52709
53053
|
return [];
|
|
52710
53054
|
}
|
|
@@ -52718,7 +53062,7 @@ function changedSymbolsFirst(ctx, tests, changed) {
|
|
|
52718
53062
|
const re = new RegExp(`\\b(?:${names.map((n3) => n3.replace(/[$]/g, "\\$")).join("|")})\\b`);
|
|
52719
53063
|
const hits = tests.filter((t) => {
|
|
52720
53064
|
try {
|
|
52721
|
-
return re.test(
|
|
53065
|
+
return re.test(readFileSync137(join150(ctx.repoDir, t.path), "utf8"));
|
|
52722
53066
|
} catch {
|
|
52723
53067
|
return false;
|
|
52724
53068
|
}
|
|
@@ -52797,6 +53141,32 @@ async function baseGoBatch(items2, signal, record) {
|
|
|
52797
53141
|
});
|
|
52798
53142
|
}
|
|
52799
53143
|
}
|
|
53144
|
+
function baseMemo(runDir, baseSha, on = baseMemoOn()) {
|
|
53145
|
+
const file = join150(runDir, "base-runs.json");
|
|
53146
|
+
let runs2 = {}, dirty = false;
|
|
53147
|
+
if (on)
|
|
53148
|
+
try {
|
|
53149
|
+
const m = JSON.parse(readFileSync137(file, "utf8"));
|
|
53150
|
+
if (m.base === baseSha && m.runs && typeof m.runs === "object")
|
|
53151
|
+
runs2 = m.runs;
|
|
53152
|
+
} catch {}
|
|
53153
|
+
return {
|
|
53154
|
+
key: (dir, bc, deps) => JSON.stringify([bc.cmd, bc.args.map((a) => a.split(dir).join("<base>")), relative31(dir, bc.cwd), deps]),
|
|
53155
|
+
get: (k) => on ? runs2[k] : undefined,
|
|
53156
|
+
put: (k, r) => {
|
|
53157
|
+
if (!on)
|
|
53158
|
+
return;
|
|
53159
|
+
runs2[k] = { ok: r.ok, out: r.out.length > 65536 ? r.out.slice(-65536) : r.out };
|
|
53160
|
+
dirty = true;
|
|
53161
|
+
},
|
|
53162
|
+
save: () => {
|
|
53163
|
+
if (on && dirty)
|
|
53164
|
+
try {
|
|
53165
|
+
atomicWriteText(file, JSON.stringify({ base: baseSha, runs: runs2 }));
|
|
53166
|
+
} catch {}
|
|
53167
|
+
}
|
|
53168
|
+
};
|
|
53169
|
+
}
|
|
52800
53170
|
async function subtractBase(ctx, api, checks, tests, changed, wall, rel, signal, zeroOk = true, zeroIntake = zeroGate(null), dep = new Set, own = rel, symbols = []) {
|
|
52801
53171
|
const out2 = { ids: [], names: [], knownRed: [], sameError: [], quiet: [], shapeDiffers: [], weak: [], zero: [], cnt: {}, envCrash: [] };
|
|
52802
53172
|
const pairs = checks.flatMap((c) => {
|
|
@@ -52813,6 +53183,16 @@ async function subtractBase(ctx, api, checks, tests, changed, wall, rel, signal,
|
|
|
52813
53183
|
const git14 = (args) => {
|
|
52814
53184
|
safeGit(ctx.repoDir, args, { stdio: "ignore", repoDrivers: true });
|
|
52815
53185
|
};
|
|
53186
|
+
const memo4 = baseMemo(ctx.runDir ?? "", ctx.baseSha, !!ctx.runDir && baseMemoOn());
|
|
53187
|
+
const once = async (bc, deps) => {
|
|
53188
|
+
const k = memo4.key(dir, bc, deps), hit2 = memo4.get(k);
|
|
53189
|
+
if (hit2)
|
|
53190
|
+
return hit2;
|
|
53191
|
+
const r = await runOnce3(bc.cmd, bc.args, bc.cwd, signal, {});
|
|
53192
|
+
if (!r.cut && !r.missing && !signal.aborted)
|
|
53193
|
+
memo4.put(k, r);
|
|
53194
|
+
return r;
|
|
53195
|
+
};
|
|
52816
53196
|
try {
|
|
52817
53197
|
git14(["-c", "core.hooksPath=/dev/null", "worktree", "add", "--detach", dir, ctx.baseSha]);
|
|
52818
53198
|
const base2 = new Map;
|
|
@@ -52824,17 +53204,23 @@ async function subtractBase(ctx, api, checks, tests, changed, wall, rel, signal,
|
|
|
52824
53204
|
if (base2.has(c))
|
|
52825
53205
|
continue;
|
|
52826
53206
|
const bc = commandFor(t, dir, api);
|
|
52827
|
-
record(c, await
|
|
53207
|
+
record(c, await once(bc, false));
|
|
52828
53208
|
}
|
|
52829
53209
|
const red = un.filter(({ c }) => c.result === "fail" && c.ids?.length && !base2.has(c));
|
|
52830
53210
|
const link = changed.some((f) => MANIFESTS2.test(f)) ? null : baseDepsLinker(dir, ctx.repoDir, zeroIntake);
|
|
52831
53211
|
const cmds = red.map((p) => ({ ...p, bc: commandFor(p.t, dir, api) }));
|
|
52832
53212
|
for (const bc of new Set(cmds.map((x) => x.bc.cwd)))
|
|
52833
53213
|
link?.(bc);
|
|
53214
|
+
const linked = link !== null;
|
|
53215
|
+
for (const x of cmds) {
|
|
53216
|
+
const hit2 = memo4.get(memo4.key(dir, x.bc, linked));
|
|
53217
|
+
if (hit2)
|
|
53218
|
+
record(x.c, hit2);
|
|
53219
|
+
}
|
|
52834
53220
|
if (verifyBatchOn() && !signal.aborted) {
|
|
52835
53221
|
const byCwd = new Map;
|
|
52836
53222
|
for (const x of cmds)
|
|
52837
|
-
if (vitestFile(x.t, x.bc))
|
|
53223
|
+
if (!base2.has(x.c) && vitestFile(x.t, x.bc))
|
|
52838
53224
|
byCwd.set(x.bc.cwd, [...byCwd.get(x.bc.cwd) ?? [], x]);
|
|
52839
53225
|
for (const [cwd, g2] of byCwd) {
|
|
52840
53226
|
if (g2.length < BATCH_MIN || signal.aborted)
|
|
@@ -52842,15 +53228,18 @@ async function subtractBase(ctx, api, checks, tests, changed, wall, rel, signal,
|
|
|
52842
53228
|
const res = await vitestBatch(cwd, g2.map((x) => x.bc.args[3]), signal);
|
|
52843
53229
|
for (const x of g2) {
|
|
52844
53230
|
const f = res?.get(x.bc.args[3]);
|
|
52845
|
-
if (f)
|
|
53231
|
+
if (f) {
|
|
52846
53232
|
record(x.c, f);
|
|
53233
|
+
if (!signal.aborted)
|
|
53234
|
+
memo4.put(memo4.key(dir, x.bc, linked), f);
|
|
53235
|
+
}
|
|
52847
53236
|
}
|
|
52848
53237
|
}
|
|
52849
53238
|
}
|
|
52850
|
-
await baseGoBatch(cmds.map((x) => ({ c: x.c, t: x.t, bc: x.bc })), signal, record);
|
|
53239
|
+
await baseGoBatch(cmds.filter((x) => !base2.has(x.c)).map((x) => ({ c: x.c, t: x.t, bc: x.bc })), signal, record);
|
|
52851
53240
|
for (const { c, bc } of cmds)
|
|
52852
53241
|
if (!base2.has(c) && !signal.aborted)
|
|
52853
|
-
record(c, await
|
|
53242
|
+
record(c, await once(bc, linked));
|
|
52854
53243
|
for (const { c, t } of crash) {
|
|
52855
53244
|
if (signal.aborted)
|
|
52856
53245
|
break;
|
|
@@ -52886,6 +53275,7 @@ async function subtractBase(ctx, api, checks, tests, changed, wall, rel, signal,
|
|
|
52886
53275
|
}
|
|
52887
53276
|
}
|
|
52888
53277
|
} catch {} finally {
|
|
53278
|
+
memo4.save();
|
|
52889
53279
|
try {
|
|
52890
53280
|
git14(["worktree", "remove", "--force", dir]);
|
|
52891
53281
|
} catch {}
|
|
@@ -52989,7 +53379,7 @@ async function runLintChecks(ctx, changed, signal, checks, opts = {}) {
|
|
|
52989
53379
|
}
|
|
52990
53380
|
return pre;
|
|
52991
53381
|
}
|
|
52992
|
-
var CHECK_TIMEOUT_MS = 60000, excerpts, checkExcerpt = (c) => excerpts.get(c) ?? "", suites, failTails, tscOut, crashSigs, baseCrashEnvOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_BASE_CRASH_ENV"] ?? "").trim()), BCE_REASON = "fails the same way on base, so its result cannot be read: the environment, not the change", headErrors, WALL_FAILURE_TAIL_CAP = 16384, wallTailOf = (out2, repoDir) => redactSecrets(stripAnsi(out2).replace(/\r/g, "").split(repoDir.replace(/\/+$/, "") + "/").join("")).slice(-WALL_FAILURE_TAIL_CAP), isHold = (c) => isHoldoutCheck(c.name), pubHold = (c) => ({ name: "holdout", cmd: "holdout", result: c.result, duration_s: c.duration_s, ...c.n !== undefined ? { n: c.n } : {}, ...c.sk !== undefined ? { sk: c.sk } : {}, ...c.owner ? { owner: c.owner, reason: "holdout infrastructure failure" } : {} }), testCheckName = (t) => `${t.runner}:${t.path}`, QUIET_RED = "excused as red on base although its error text differs from base by noise only (the same error shapes; no changed file or symbol appears in the failure)", COLLATERAL_RED = "relevant test already failing on base, still failing the same tests (it imports a file the task names; capped, not blocking)", noTestFallbackOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_NO_TEST_FALLBACK"] ?? "").trim()), ownByPathOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_OWN_BY_PATH"] ?? "").trim()), TEST_TITLE_RE, dedupeTests = (tests) => [...new Map(tests.map((t) => [`${t.runner}:${t.path}`, t])).values()], verifyBatchOn = (env = process.env) => env["LOKI_E10_VERIFY_BATCH"] !== "0", BATCH_MIN = 2, UNHANDLED_RE, batchTimeoutMs = (files) => Math.max(CHECK_TIMEOUT_MS, Math.min(300000, files * 5000)), vitestFile = (t, c) => t.runner === "vitest" && c.cmd === "npx" && c.args.length === 4 && c.args[0] === "--no-install" && c.args[1] === "vitest" && c.args[2] === "run", goBatchOn = (env = process.env) => verifyBatchOn(env) && env["LOKI_E10_GO_BATCH"] !== "0", goFileCmd = (t, c) => t.runner === "go" && c.cmd === "go" && c.args.length === 5 && c.args[0] === "test" && c.args[1] === "-json" && c.args[2] === "-run" && /^\^\([A-Za-z0-9_|]+\)\$$/.test(c.args[3]), goBatchable = (t, targets, changed, env = process.env) => goBatchOn(env) && t.runner === "go" && !targets.has(testCheckName(t)) && !changed.includes(t.path), uncausedOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_UNCAUSED_NO_FIX"] ?? "").trim()), LINT_CONFIG, INERT_FILE, feedsFixRound = (c, pre) => c.result === "fail" && !pre.names.includes(c.name) && !pre.sameError.includes(c.name) && !isHoldoutCheck(c.name), ESLINT_CONFIGS, excuseLint = (ctx, signal, c, tool, cmd2, prefix, cwd, rel, opts) => c.result !== "fail" || signal.aborted ? Promise.resolve(false) : staticPreExisting(tool, prefix, rel, { run: async (a, stdin) => {
|
|
53382
|
+
var CHECK_TIMEOUT_MS = 60000, excerpts, checkExcerpt = (c) => excerpts.get(c) ?? "", suites, failTails, tscOut, crashSigs, baseCrashEnvOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_BASE_CRASH_ENV"] ?? "").trim()), BCE_REASON = "fails the same way on base, so its result cannot be read: the environment, not the change", headErrors, WALL_FAILURE_TAIL_CAP = 16384, wallTailOf = (out2, repoDir) => redactSecrets(stripAnsi(out2).replace(/\r/g, "").split(repoDir.replace(/\/+$/, "") + "/").join("")).slice(-WALL_FAILURE_TAIL_CAP), isHold = (c) => isHoldoutCheck(c.name), pubHold = (c) => ({ name: "holdout", cmd: "holdout", result: c.result, duration_s: c.duration_s, ...c.n !== undefined ? { n: c.n } : {}, ...c.sk !== undefined ? { sk: c.sk } : {}, ...c.owner ? { owner: c.owner, reason: "holdout infrastructure failure" } : {} }), testCheckName = (t) => `${t.runner}:${t.path}`, QUIET_RED = "excused as red on base although its error text differs from base by noise only (the same error shapes; no changed file or symbol appears in the failure)", COLLATERAL_RED = "relevant test already failing on base, still failing the same tests (it imports a file the task names; capped, not blocking)", noTestFallbackOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_NO_TEST_FALLBACK"] ?? "").trim()), ownByPathOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_OWN_BY_PATH"] ?? "").trim()), TEST_TITLE_RE, dedupeTests = (tests) => [...new Map(tests.map((t) => [`${t.runner}:${t.path}`, t])).values()], verifyBatchOn = (env = process.env) => env["LOKI_E10_VERIFY_BATCH"] !== "0", BATCH_MIN = 2, UNHANDLED_RE, batchTimeoutMs = (files) => Math.max(CHECK_TIMEOUT_MS, Math.min(300000, files * 5000)), vitestFile = (t, c) => t.runner === "vitest" && c.cmd === "npx" && c.args.length === 4 && c.args[0] === "--no-install" && c.args[1] === "vitest" && c.args[2] === "run", goBatchOn = (env = process.env) => verifyBatchOn(env) && env["LOKI_E10_GO_BATCH"] !== "0", goFileCmd = (t, c) => t.runner === "go" && c.cmd === "go" && c.args.length === 5 && c.args[0] === "test" && c.args[1] === "-json" && c.args[2] === "-run" && /^\^\([A-Za-z0-9_|]+\)\$$/.test(c.args[3]), goBatchable = (t, targets, changed, env = process.env) => goBatchOn(env) && t.runner === "go" && !targets.has(testCheckName(t)) && !changed.includes(t.path), uncausedOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_UNCAUSED_NO_FIX"] ?? "").trim()), LINT_CONFIG, INERT_FILE, feedsFixRound = (c, pre) => c.result === "fail" && !pre.names.includes(c.name) && !pre.sameError.includes(c.name) && !isHoldoutCheck(c.name), baseMemoOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_BASE_MEMO"] ?? "").trim()), ESLINT_CONFIGS, excuseLint = (ctx, signal, c, tool, cmd2, prefix, cwd, rel, opts) => c.result !== "fail" || signal.aborted ? Promise.resolve(false) : staticPreExisting(tool, prefix, rel, { run: async (a, stdin) => {
|
|
52993
53383
|
if (signal.aborted)
|
|
52994
53384
|
return null;
|
|
52995
53385
|
const r = await runOnce3(cmd2, a, cwd, AbortSignal.any([signal, AbortSignal.timeout(opts.timeoutMs ?? CHECK_TIMEOUT_MS)]), { ...opts, ...stdin !== undefined ? { stdin } : {} });
|
|
@@ -53311,7 +53701,7 @@ var init_verify = __esm(() => {
|
|
|
53311
53701
|
const k = preRed.cnt[testCheckName(t)];
|
|
53312
53702
|
if (k)
|
|
53313
53703
|
testCounts[t.path] = k;
|
|
53314
|
-
return [...testFileWeakened(ctx.repoDir, ctx.baseSha, null, t.path, "M") ? [`weakened test: ${t.path}`] : [], ...assertDeltaNotes(ctx.repoDir, ctx.baseSha, null, t.path, intake?.task ?? "", k?.b, k?.h) ?? []];
|
|
53704
|
+
return [...testFileWeakened(ctx.repoDir, ctx.baseSha, null, t.path, "M", intake?.task ?? "") ? [`weakened test: ${t.path}`] : [], ...assertDeltaNotes(ctx.repoDir, ctx.baseSha, null, t.path, intake?.task ?? "", k?.b, k?.h) ?? []];
|
|
53315
53705
|
});
|
|
53316
53706
|
const weakened = [...modifiedRel, ...cfgChanged.map((f) => `test configuration changed: ${f}`), ...preRed.weak.map((n3) => `skipped or fewer tests than base: ${n3}`), ...collateralRed.map((n3) => `${COLLATERAL_RED}: ${n3}`), ...preRed.quiet.filter((n3) => preRed.names.includes(n3)).map((n3) => `${QUIET_RED}: ${n3}`)];
|
|
53317
53707
|
const depsNotes = unusedInstallNotes(intake?.deps_not_proven ?? [], api, changed, checks.map((c) => c.name), ctx.repoDir);
|
|
@@ -53329,11 +53719,11 @@ var init_verify = __esm(() => {
|
|
|
53329
53719
|
});
|
|
53330
53720
|
|
|
53331
53721
|
// ../../loki-ts/src/runner/stop_checks.ts
|
|
53332
|
-
import { appendFileSync as appendFileSync16, existsSync as existsSync106, mkdirSync as mkdirSync79, readFileSync as
|
|
53722
|
+
import { appendFileSync as appendFileSync16, existsSync as existsSync106, mkdirSync as mkdirSync79, readFileSync as readFileSync138, statSync as statSync44 } from "fs";
|
|
53333
53723
|
import { basename as basename44, isAbsolute as isAbsolute22, join as join151, relative as relative32 } from "path";
|
|
53334
53724
|
function redOnBase(repoDir) {
|
|
53335
53725
|
try {
|
|
53336
|
-
const b = JSON.parse(
|
|
53726
|
+
const b = JSON.parse(readFileSync138(join151(repoDir, ".loki", "state", "repo-profile.json"), "utf8")).baseline;
|
|
53337
53727
|
return Array.isArray(b?.failing_ids) ? b.failing_ids.filter((x) => typeof x === "string") : [];
|
|
53338
53728
|
} catch {
|
|
53339
53729
|
return [];
|
|
@@ -94643,7 +95033,7 @@ __export(exports_providers, {
|
|
|
94643
95033
|
SDK_BUNDLED_CLAUDE_CODE: () => SDK_BUNDLED_CLAUDE_CODE,
|
|
94644
95034
|
PROVIDER_COMMIT_HYGIENE: () => PROVIDER_COMMIT_HYGIENE
|
|
94645
95035
|
});
|
|
94646
|
-
import { mkdirSync as mkdirSync82, existsSync as existsSync108, readFileSync as
|
|
95036
|
+
import { mkdirSync as mkdirSync82, existsSync as existsSync108, readFileSync as readFileSync140, realpathSync as realpathSync43, appendFileSync as appendFileSync18 } from "fs";
|
|
94647
95037
|
import { delimiter as delimiter5, dirname as dirname65, isAbsolute as isAbsolute24, relative as relative33, resolve as resolve41, sep as sep26 } from "path";
|
|
94648
95038
|
function mergeDisallowedTools(policy, stageCsv) {
|
|
94649
95039
|
return [...new Set([...policy ?? [], ...stageCsv.split(",").filter(Boolean)])];
|
|
@@ -94794,7 +95184,7 @@ function ensureParentDir(path) {
|
|
|
94794
95184
|
}
|
|
94795
95185
|
function physicalPath(path) {
|
|
94796
95186
|
try {
|
|
94797
|
-
return
|
|
95187
|
+
return realpathSync43(path);
|
|
94798
95188
|
} catch {
|
|
94799
95189
|
return resolve41(path);
|
|
94800
95190
|
}
|
|
@@ -95028,7 +95418,7 @@ function buildSdkLoopOptions(args) {
|
|
|
95028
95418
|
try {
|
|
95029
95419
|
const cfgPath = mcpConfigPath(args.cwd);
|
|
95030
95420
|
if (existsSync108(cfgPath)) {
|
|
95031
|
-
const bundle = JSON.parse(
|
|
95421
|
+
const bundle = JSON.parse(readFileSync140(cfgPath, "utf8"));
|
|
95032
95422
|
if (bundle.mcpServers && Object.keys(bundle.mcpServers).length > 0) {
|
|
95033
95423
|
out2.mcpServers = [bundle.mcpServers];
|
|
95034
95424
|
out2.strictMcpConfig = true;
|
|
@@ -95247,7 +95637,7 @@ __export(exports_session, {
|
|
|
95247
95637
|
HEARTBEAT_MS_DEFAULT: () => HEARTBEAT_MS_DEFAULT
|
|
95248
95638
|
});
|
|
95249
95639
|
import { spawn as spawn12 } from "child_process";
|
|
95250
|
-
import { copyFileSync as copyFileSync10, existsSync as existsSync109, mkdirSync as mkdirSync83, readFileSync as
|
|
95640
|
+
import { copyFileSync as copyFileSync10, existsSync as existsSync109, mkdirSync as mkdirSync83, readFileSync as readFileSync141, writeFileSync as writeFileSync80, writeSync as writeSync4 } from "fs";
|
|
95251
95641
|
import { dirname as dirname66, join as join154, resolve as resolve42 } from "path";
|
|
95252
95642
|
import { tmpdir as tmpdir30 } from "os";
|
|
95253
95643
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
@@ -95532,7 +95922,7 @@ function createSessionRunner(cfg) {
|
|
|
95532
95922
|
healRecord(fenceRunDir);
|
|
95533
95923
|
}
|
|
95534
95924
|
const log = join154(opts.cwd ?? process.cwd(), ".loki", `iteration-${sessionId}.log`);
|
|
95535
|
-
const logText = existsSync109(log) ?
|
|
95925
|
+
const logText = existsSync109(log) ? readFileSync141(log, "utf8") : "";
|
|
95536
95926
|
const markers = parseMarkers(stdout + logText);
|
|
95537
95927
|
if (fenceSnap && markers.specConflict) {
|
|
95538
95928
|
const named2 = conflictNamed(markers.specConflict, fenceSnap.files.keys(), fenceAllow);
|
|
@@ -95643,7 +96033,7 @@ var init_model_rank = __esm(() => {
|
|
|
95643
96033
|
});
|
|
95644
96034
|
|
|
95645
96035
|
// ../../loki-ts/src/engine10/sizing.ts
|
|
95646
|
-
import { existsSync as existsSync110, readFileSync as
|
|
96036
|
+
import { existsSync as existsSync110, readFileSync as readFileSync142 } from "fs";
|
|
95647
96037
|
import { basename as basename45 } from "path";
|
|
95648
96038
|
function namedFiles(task, map) {
|
|
95649
96039
|
const text4 = task.toLowerCase();
|
|
@@ -95694,7 +96084,7 @@ function hardReason(size, map, task) {
|
|
|
95694
96084
|
}
|
|
95695
96085
|
function loadRepoMap(repomapRef) {
|
|
95696
96086
|
try {
|
|
95697
|
-
return repomapRef && existsSync110(repomapRef) ? JSON.parse(
|
|
96087
|
+
return repomapRef && existsSync110(repomapRef) ? JSON.parse(readFileSync142(repomapRef, "utf8")) : null;
|
|
95698
96088
|
} catch {
|
|
95699
96089
|
return null;
|
|
95700
96090
|
}
|
|
@@ -95809,14 +96199,14 @@ function recordRunShape(runDir, model) {
|
|
|
95809
96199
|
var init_run_shape = () => {};
|
|
95810
96200
|
|
|
95811
96201
|
// ../../loki-ts/src/project_model/discover.ts
|
|
95812
|
-
import { existsSync as existsSync112, mkdirSync as mkdirSync85, readFileSync as
|
|
96202
|
+
import { existsSync as existsSync112, mkdirSync as mkdirSync85, readFileSync as readFileSync143, rmSync as rmSync48, writeFileSync as writeFileSync82 } from "fs";
|
|
95813
96203
|
import { join as join157 } from "path";
|
|
95814
96204
|
function projectModelEnabled(env = process.env) {
|
|
95815
96205
|
return env["LOKI_E10_PROJECT_MODEL"] !== "0";
|
|
95816
96206
|
}
|
|
95817
96207
|
function loadCached(repoDir, now2 = Date.now()) {
|
|
95818
96208
|
try {
|
|
95819
|
-
return parseCached(repoDir, JSON.parse(
|
|
96209
|
+
return parseCached(repoDir, JSON.parse(readFileSync143(join157(repoDir, PROJECT_FILE), "utf8")), now2);
|
|
95820
96210
|
} catch {
|
|
95821
96211
|
return null;
|
|
95822
96212
|
}
|
|
@@ -95831,7 +96221,7 @@ function loadCommitted(repoDir) {
|
|
|
95831
96221
|
};
|
|
95832
96222
|
let raw2;
|
|
95833
96223
|
try {
|
|
95834
|
-
raw2 = JSON.parse(
|
|
96224
|
+
raw2 = JSON.parse(readFileSync143(join157(repoDir, PROJECT_FILE), "utf8"));
|
|
95835
96225
|
} catch (e10) {
|
|
95836
96226
|
return ignore(`unreadable JSON (${e10 instanceof Error ? e10.message : String(e10)})`);
|
|
95837
96227
|
}
|
|
@@ -95895,7 +96285,7 @@ ${errors2.map((e10) => `- ${e10}`).join(`
|
|
|
95895
96285
|
`);
|
|
95896
96286
|
}
|
|
95897
96287
|
function readAnswer(answerPath, summary) {
|
|
95898
|
-
for (const text4 of [existsSync112(answerPath) ?
|
|
96288
|
+
for (const text4 of [existsSync112(answerPath) ? readFileSync143(answerPath, "utf8") : "", summary ?? ""]) {
|
|
95899
96289
|
const start = text4.indexOf("{");
|
|
95900
96290
|
const end = text4.lastIndexOf("}");
|
|
95901
96291
|
if (start < 0 || end <= start)
|
|
@@ -96177,7 +96567,7 @@ var init_python_build_check = __esm(() => {
|
|
|
96177
96567
|
// ../../loki-ts/src/util/check_result.ts
|
|
96178
96568
|
import { spawn as spawn13, spawnSync as spawnSync26 } from "child_process";
|
|
96179
96569
|
import { createHash as createHash38 } from "crypto";
|
|
96180
|
-
import { copyFileSync as copyFileSync11, existsSync as existsSync113, lstatSync as lstatSync35, mkdirSync as mkdirSync86, readlinkSync as readlinkSync8, mkdtempSync as mkdtempSync24, readdirSync as readdirSync52, readFileSync as
|
|
96570
|
+
import { copyFileSync as copyFileSync11, existsSync as existsSync113, lstatSync as lstatSync35, mkdirSync as mkdirSync86, readlinkSync as readlinkSync8, mkdtempSync as mkdtempSync24, readdirSync as readdirSync52, readFileSync as readFileSync144, realpathSync as realpathSync44, renameSync as renameSync28, rmSync as rmSync49, statSync as statSync46, writeFileSync as writeFileSync83 } from "fs";
|
|
96181
96571
|
import { homedir as homedir16, tmpdir as tmpdir31 } from "os";
|
|
96182
96572
|
import { basename as basename46, dirname as dirname67, isAbsolute as isAbsolute25, join as join159, normalize as normalize9, relative as relative34, resolve as resolve43, sep as sep27 } from "path";
|
|
96183
96573
|
function plainTestEnv(base2 = process.env) {
|
|
@@ -96348,7 +96738,7 @@ function plannedGoDir(repoDir, texts) {
|
|
|
96348
96738
|
const all = [...sentence.matchAll(GO_SRC)], k10 = all.findIndex((x10) => x10.index === m.index), after = sentence.slice(m.index + m[0].length, all[k10 + 1]?.index ?? sentence.length), before = sentence.slice(k10 > 0 ? all[k10 - 1].index + all[k10 - 1][0].length : 0, m.index);
|
|
96349
96739
|
const tiedMain = base2 === "main" || GO_PKG_AFTER.exec(after)?.[1] === "main" || GO_MAIN_BEFORE.test(before);
|
|
96350
96740
|
const em2 = /\bpackage\s+`([A-Za-z_]\w*)`|\(package\s+([A-Za-z_]\w*)\)/.exec(texts[texts.length - 1] ?? ""), explicit = em2 ? em2[1] ?? em2[2] : undefined;
|
|
96351
|
-
const mod = rel === "." && existsSync113(join159(repoDir, "go.mod")) ? /^module\s+(\S+)/m.exec(
|
|
96741
|
+
const mod = rel === "." && existsSync113(join159(repoDir, "go.mod")) ? /^module\s+(\S+)/m.exec(readFileSync144(join159(repoDir, "go.mod"), "utf8"))?.[1]?.replace(/\/v\d+$/, "").split("/").pop() : undefined;
|
|
96352
96742
|
const okName = (n10) => n10 !== undefined && GO_IDENT.test(n10) && !GO_MAJOR.test(n10);
|
|
96353
96743
|
const named2 = (explicit !== undefined && !GO_KEYWORDS.has(explicit) ? explicit : undefined) ?? [tiedMain ? "main" : undefined, rel === "." ? undefined : rel.split("/").pop(), mod, base2].find(okName) ?? null;
|
|
96354
96744
|
return { dir, pkg: goSiblingPkg(dir) ?? named2 };
|
|
@@ -96579,7 +96969,7 @@ function cargoRunnerConfigured(cwd, env, toks2) {
|
|
|
96579
96969
|
return true;
|
|
96580
96970
|
const doubtful = (f) => {
|
|
96581
96971
|
try {
|
|
96582
|
-
return CARGO_REDIRECT_TEXT(
|
|
96972
|
+
return CARGO_REDIRECT_TEXT(readFileSync144(f, "utf8"));
|
|
96583
96973
|
} catch {
|
|
96584
96974
|
return true;
|
|
96585
96975
|
}
|
|
@@ -96602,7 +96992,7 @@ function cargoToolchainRedirected(cwd, env) {
|
|
|
96602
96992
|
return true;
|
|
96603
96993
|
const doubtful = (f) => {
|
|
96604
96994
|
try {
|
|
96605
|
-
const t =
|
|
96995
|
+
const t = readFileSync144(f, "utf8");
|
|
96606
96996
|
if (/\\[uU]/.test(t) || CARGO_KEY("path").test(t) || /^\s*channel\s*=\s*["']([^"']*)["']/m.test(t) && PATH_SHAPED(/^\s*channel\s*=\s*["']([^"']*)["']/m.exec(t)[1]))
|
|
96607
96997
|
return true;
|
|
96608
96998
|
const first = t.split(`
|
|
@@ -96727,7 +97117,7 @@ function topLevelDoubt(t) {
|
|
|
96727
97117
|
function cargoProfileRustflagsManifest(root, cwd, toks2) {
|
|
96728
97118
|
const hit2 = (f) => {
|
|
96729
97119
|
try {
|
|
96730
|
-
const t = stripTomlComments(
|
|
97120
|
+
const t = stripTomlComments(readFileSync144(f, "utf8"));
|
|
96731
97121
|
if (/["']?cargo-features["']?\s*=\s*\[[^\]]*profile-rustflags/.test(t))
|
|
96732
97122
|
return "cargo-features profile-rustflags";
|
|
96733
97123
|
return topLevelDoubt(t) ? CARGO_ESCAPED_LABEL : null;
|
|
@@ -96775,7 +97165,7 @@ function cargoRepoCompilerRedirected(cwd, env, toks2) {
|
|
|
96775
97165
|
};
|
|
96776
97166
|
const inFile = (f) => {
|
|
96777
97167
|
try {
|
|
96778
|
-
return compilerSettingIn(
|
|
97168
|
+
return compilerSettingIn(readFileSync144(f, "utf8"));
|
|
96779
97169
|
} catch {
|
|
96780
97170
|
return "an unreadable config";
|
|
96781
97171
|
}
|
|
@@ -96912,7 +97302,7 @@ function* corroborateGoSteps(c, out2, cmdOrLine, args, toks2, o) {
|
|
|
96912
97302
|
const spawnOpts = { cwd: o.cwd, env: o.env, timeoutMs: 600000, maxBytes: GO_JSON_KEEP };
|
|
96913
97303
|
const profBlocks = () => {
|
|
96914
97304
|
const set = new Set;
|
|
96915
|
-
for (const l of (existsSync113(prof) ?
|
|
97305
|
+
for (const l of (existsSync113(prof) ? readFileSync144(prof, "utf8") : "").split(`
|
|
96916
97306
|
`)) {
|
|
96917
97307
|
const m = /^(.+:\d+\.\d+,\d+\.\d+ \d+) \d+$/.exec(l);
|
|
96918
97308
|
if (m)
|
|
@@ -96968,7 +97358,7 @@ function* corroborateGoSteps(c, out2, cmdOrLine, args, toks2, o) {
|
|
|
96968
97358
|
return refuse;
|
|
96969
97359
|
perPkg.set(pk.ImportPath, 0);
|
|
96970
97360
|
for (const f of pk.GoFiles) {
|
|
96971
|
-
if (/^\s*(?:\/\/line |\/\*line )/m.test(
|
|
97361
|
+
if (/^\s*(?:\/\/line |\/\*line )/m.test(readFileSync144(join159(pk.Dir, f), "utf8")))
|
|
96972
97362
|
return refuse;
|
|
96973
97363
|
const t = yield ["go", ["tool", "cover", "-mode=set", "-var=GoCoverStatic", join159(pk.Dir, f)], spawnOpts];
|
|
96974
97364
|
if (t.status !== 0)
|
|
@@ -97366,7 +97756,7 @@ function exercisedViaCallers(unexercised, seed, files) {
|
|
|
97366
97756
|
function explainGates(receiptPath) {
|
|
97367
97757
|
let checks = [];
|
|
97368
97758
|
try {
|
|
97369
|
-
const c = JSON.parse(
|
|
97759
|
+
const c = JSON.parse(readFileSync144(receiptPath, "utf8")).checks;
|
|
97370
97760
|
if (Array.isArray(c))
|
|
97371
97761
|
checks = c.filter((x10) => !!x10 && typeof x10 === "object");
|
|
97372
97762
|
} catch {}
|
|
@@ -97599,7 +97989,7 @@ function publishableWall(repoDir, runDir, o, env = process.env, task) {
|
|
|
97599
97989
|
if (!hit2 || rel.startsWith("..") || isAbsolute25(rel) || rel.startsWith(".loki/") || !basename46(rel).startsWith("loki_wall_"))
|
|
97600
97990
|
continue;
|
|
97601
97991
|
try {
|
|
97602
|
-
const bytes =
|
|
97992
|
+
const bytes = readFileSync144(sealedWallCopy(runDir, rel));
|
|
97603
97993
|
if (createHash38("sha256").update(bytes).digest("hex") !== w["sha256"])
|
|
97604
97994
|
throw new Error("hash");
|
|
97605
97995
|
out2.files.push({ rel, bytes, cmd: String(hit2["cmd"]), runner: String(hit2["name"]).slice(0, String(hit2["name"]).indexOf(":")) });
|
|
@@ -97643,7 +98033,7 @@ function loadSealedWall(runDir, unitRepoDir) {
|
|
|
97643
98033
|
const files = [], problems = [];
|
|
97644
98034
|
let listed;
|
|
97645
98035
|
try {
|
|
97646
|
-
listed = JSON.parse(
|
|
98036
|
+
listed = JSON.parse(readFileSync144(join159(runDir, "receipt.json"), "utf8")).wall?.files;
|
|
97647
98037
|
} catch {
|
|
97648
98038
|
return { files, problems, receiptMissing: true };
|
|
97649
98039
|
}
|
|
@@ -97654,7 +98044,7 @@ function loadSealedWall(runDir, unitRepoDir) {
|
|
|
97654
98044
|
continue;
|
|
97655
98045
|
}
|
|
97656
98046
|
try {
|
|
97657
|
-
const bytes =
|
|
98047
|
+
const bytes = readFileSync144(join159(runDir, "wall", basename46(rel)));
|
|
97658
98048
|
if (createHash38("sha256").update(bytes).digest("hex") !== w.sha256)
|
|
97659
98049
|
throw new Error("hash");
|
|
97660
98050
|
files.push({ rel, bytes, ...typeof w.runner === "string" ? { runner: w.runner } : {} });
|
|
@@ -97670,7 +98060,7 @@ function unitWalls(repoDir, gid, branches) {
|
|
|
97670
98060
|
const runDir = join159(repoDir, ".loki", "groups", gid, "group", "units", id2);
|
|
97671
98061
|
let root = `${repoDir}-backlog/${br2.replace(/^loki\//, "")}`;
|
|
97672
98062
|
try {
|
|
97673
|
-
const f = (JSON.parse(
|
|
98063
|
+
const f = (JSON.parse(readFileSync144(join159(runDir, "receipt.json"), "utf8")).wall?.files ?? [])[0]?.path;
|
|
97674
98064
|
const m = typeof f === "string" ? /^(.*-backlog\/unit-[^/]+-\d+)\//.exec(f) : null;
|
|
97675
98065
|
if (m)
|
|
97676
98066
|
root = m[1];
|
|
@@ -97687,7 +98077,7 @@ function changedFiles(repoDir, baseSha, skip2) {
|
|
|
97687
98077
|
}
|
|
97688
98078
|
function sha256File2(abs) {
|
|
97689
98079
|
const st2 = lstatSync35(abs);
|
|
97690
|
-
return st2.isSymbolicLink() ? `link:${readlinkSync8(abs)}` : st2.size > 4000000 ? `big:${st2.size}` : createHash38("sha256").update(
|
|
98080
|
+
return st2.isSymbolicLink() ? `link:${readlinkSync8(abs)}` : st2.size > 4000000 ? `big:${st2.size}` : createHash38("sha256").update(readFileSync144(abs)).digest("hex");
|
|
97691
98081
|
}
|
|
97692
98082
|
function fileHashes(repoDir, files) {
|
|
97693
98083
|
return Object.fromEntries(files.map((f) => {
|
|
@@ -97792,7 +98182,7 @@ function execFiles(repoDir) {
|
|
|
97792
98182
|
}
|
|
97793
98183
|
function ignoreSource(path) {
|
|
97794
98184
|
try {
|
|
97795
|
-
return { path, state: existsSync113(path) ? createHash38("sha256").update(
|
|
98185
|
+
return { path, state: existsSync113(path) ? createHash38("sha256").update(readFileSync144(path)).digest("hex") : "missing" };
|
|
97796
98186
|
} catch {
|
|
97797
98187
|
return { path, state: "unreadable" };
|
|
97798
98188
|
}
|
|
@@ -97829,7 +98219,7 @@ function pureToolCache(repoDir, dir) {
|
|
|
97829
98219
|
if (text4 === undefined)
|
|
97830
98220
|
return false;
|
|
97831
98221
|
try {
|
|
97832
|
-
if (
|
|
98222
|
+
if (readFileSync144(join159(repoDir, dir, ".gitignore"), "utf8") !== text4)
|
|
97833
98223
|
return false;
|
|
97834
98224
|
let seen = 0;
|
|
97835
98225
|
const walk = (rel) => {
|
|
@@ -97926,7 +98316,7 @@ function diffFiles(repoDir, baseSha, skip2) {
|
|
|
97926
98316
|
return f;
|
|
97927
98317
|
let n10 = 0;
|
|
97928
98318
|
try {
|
|
97929
|
-
n10 =
|
|
98319
|
+
n10 = readFileSync144(join159(repoDir, path), "utf8").split(`
|
|
97930
98320
|
`).length;
|
|
97931
98321
|
} catch {}
|
|
97932
98322
|
return { path, added: n10, deleted: 0, status: "added" };
|
|
@@ -97949,7 +98339,7 @@ function diffFiles(repoDir, baseSha, skip2) {
|
|
|
97949
98339
|
let text4 = added.get(f.path) ?? "";
|
|
97950
98340
|
if (!text4 && f.status === "added") {
|
|
97951
98341
|
try {
|
|
97952
|
-
text4 =
|
|
98342
|
+
text4 = readFileSync144(join159(repoDir, f.path), "utf8");
|
|
97953
98343
|
} catch {}
|
|
97954
98344
|
}
|
|
97955
98345
|
const rule = criticalRuleFor(f.path, text4, rules);
|
|
@@ -97961,7 +98351,7 @@ function diffFiles(repoDir, baseSha, skip2) {
|
|
|
97961
98351
|
continue;
|
|
97962
98352
|
try {
|
|
97963
98353
|
const oldText = f.status === "added" ? "" : safeGit(repoDir, ["show", `${baseSha}:${f.path}`]);
|
|
97964
|
-
const newText =
|
|
98354
|
+
const newText = readFileSync144(join159(repoDir, f.path), "utf8");
|
|
97965
98355
|
const patch = f.status === "added" ? newText.split(`
|
|
97966
98356
|
`).map((l) => `+${l}`).join(`
|
|
97967
98357
|
`) : safeGit(repoDir, ["diff", "-U0", baseSha, "--", f.path]);
|
|
@@ -98031,7 +98421,7 @@ function pytestCollectionIsRed(output, repoDir) {
|
|
|
98031
98421
|
return moduleToBeCreated(output, repoDir);
|
|
98032
98422
|
const real3 = (p) => {
|
|
98033
98423
|
try {
|
|
98034
|
-
return
|
|
98424
|
+
return realpathSync44(isAbsolute25(p) ? p : join159(repoDir, p));
|
|
98035
98425
|
} catch {
|
|
98036
98426
|
return null;
|
|
98037
98427
|
}
|
|
@@ -98134,7 +98524,7 @@ function moduleToBeCreated(output, repoDir) {
|
|
|
98134
98524
|
if (/(^|\/)loki_wall_/.test(f))
|
|
98135
98525
|
return false;
|
|
98136
98526
|
try {
|
|
98137
|
-
return importsName(
|
|
98527
|
+
return importsName(readFileSync144(join159(repoDir, f), "utf8"), name);
|
|
98138
98528
|
} catch {
|
|
98139
98529
|
return false;
|
|
98140
98530
|
}
|
|
@@ -98566,7 +98956,7 @@ function toolFallbacks(repoDir, tool, env = process.env) {
|
|
|
98566
98956
|
function resolveTool(repoDir, bin, fallback, lastResort = fallback) {
|
|
98567
98957
|
const inRepo2 = (p) => {
|
|
98568
98958
|
try {
|
|
98569
|
-
const r = relative34(
|
|
98959
|
+
const r = relative34(realpathSync44(repoDir), realpathSync44(p));
|
|
98570
98960
|
return r !== "" && !r.startsWith("..") && !isAbsolute25(r);
|
|
98571
98961
|
} catch {
|
|
98572
98962
|
return false;
|
|
@@ -98578,7 +98968,7 @@ function resolveTool(repoDir, bin, fallback, lastResort = fallback) {
|
|
|
98578
98968
|
}
|
|
98579
98969
|
function goTestNames(file) {
|
|
98580
98970
|
try {
|
|
98581
|
-
return [...new Set([...
|
|
98971
|
+
return [...new Set([...readFileSync144(file, "utf8").matchAll(/^func\s+((?:Test|Fuzz|Example)[\p{L}\p{N}_]*)\s*\(/gmu)].map((m) => m[1]).filter((n10) => n10 !== "TestMain"))];
|
|
98582
98972
|
} catch {
|
|
98583
98973
|
return [];
|
|
98584
98974
|
}
|
|
@@ -98657,7 +99047,7 @@ function ownVitestSite(repoDir, path) {
|
|
|
98657
99047
|
const conf = readdirSync52(abs).find((n10) => cfg.test(n10));
|
|
98658
99048
|
if (!conf)
|
|
98659
99049
|
continue;
|
|
98660
|
-
if (/^vitest/.test(conf) || /\btest\s*:/.test(
|
|
99050
|
+
if (/^vitest/.test(conf) || /\btest\s*:/.test(readFileSync144(join159(abs, conf), "utf8").slice(0, 200000)))
|
|
98661
99051
|
return { cwd: abs, root: d, file: relative34(d, path) };
|
|
98662
99052
|
} catch {}
|
|
98663
99053
|
}
|
|
@@ -98669,7 +99059,7 @@ function rootProjectsBreakSite(repoDir, site) {
|
|
|
98669
99059
|
return false;
|
|
98670
99060
|
const read3 = (dir) => {
|
|
98671
99061
|
const n10 = readdirSync52(dir).find((x10) => VITEST_CFG.test(x10));
|
|
98672
|
-
return n10 ?
|
|
99062
|
+
return n10 ? readFileSync144(join159(dir, n10), "utf8").slice(0, 200000) : null;
|
|
98673
99063
|
};
|
|
98674
99064
|
const root = read3(repoDir), own = read3(site.cwd);
|
|
98675
99065
|
return root !== null && own !== null && /\bprojects\s*:/.test(root) && /from\s+["'](?:\.\.\/)+vite(?:st)?\.config/.test(own);
|
|
@@ -98823,7 +99213,7 @@ async function publishWall(git14, runId2, repoDir, files, done) {
|
|
|
98823
99213
|
for (const f of files) {
|
|
98824
99214
|
const abs = join159(repoDir, f.rel);
|
|
98825
99215
|
try {
|
|
98826
|
-
if (!
|
|
99216
|
+
if (!realpathSync44(dirname67(abs)).startsWith(realpathSync44(repoDir)))
|
|
98827
99217
|
return false;
|
|
98828
99218
|
} catch {}
|
|
98829
99219
|
rmSync49(abs, { force: true });
|
|
@@ -98849,7 +99239,7 @@ function firstFileLineAnchor(desc2) {
|
|
|
98849
99239
|
}
|
|
98850
99240
|
var NO_TESTS_REASON = "no tests executed", sealedWallDir = (runDir) => join159(runDir, "wall"), sealedWallCopy = (runDir, path) => join159(sealedWallDir(runDir), basename46(path)), NO_RUNNER_REASON = "no runner of this repo runs this file", harnessSkipCode = (env = process.env) => env.LOKI_WALL_HARNESS_RUNNER === "0" ? "harness_runner_disabled" : Bun.which("bun", { PATH: env.PATH ?? "" }) ? "no_toolchain" : "bun_not_on_path", GO_EXIT0_REASON = "test count could not be confirmed: go test output is produced by the code under test and cannot confirm execution (a Go exit 0 is never a pass)", UNCONFIRMED_REASON = "test count could not be confirmed", FAIL_EVIDENCE, GO_FAIL_EVIDENCE, UNMEASURED_REASON = "executed count unmeasured (Loki could not parse the runner summary, harness-owned)", pytestPrettyOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_PYTEST_PRETTY"] ?? "").trim()), stripAnsi = (s) => s.replace(/\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)/g, "").replace(/(?:\u001b\[|\u009b)[0-9;?]*[ -\/]*[@-~]/g, "").replace(/\r\n?/g, `
|
|
98851
99241
|
`), tailLines = (out2) => out2.split(`
|
|
98852
|
-
`).filter((x10) => x10.trim()).slice(-12), CARGO_NOISE, cargoMergedDoctestOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_CARGO_MERGED_DOCTEST"] ?? "").trim()), DOCTEST_NOTE, cargoNoise = (l) => CARGO_NOISE.test(l) || cargoMergedDoctestOn() && DOCTEST_NOTE.test(l), GO_PKG_RE, GO_SRC, GO_DIR, GO_PKG_AFTER, GO_MAIN_BEFORE, GO_IDENT, GO_MAJOR, GO_KEYWORDS, goRel = (r) => r.replace(/^(?:\.\/)+/, ""), GO_NON_PKG_WORD, goIgnoredPath = (rel) => rel.split("/").some((g10) => g10 === "testdata" || g10.startsWith("_") || g10.startsWith(".")), goSiblingPkg = (dir) => existsSync113(dir) ? readdirSync52(dir).filter((f) => f.endsWith(".go") && !f.endsWith("_test.go")).map((f) => /^package\s+(\w+)/m.exec(
|
|
99242
|
+
`).filter((x10) => x10.trim()).slice(-12), CARGO_NOISE, cargoMergedDoctestOn = (env = process.env) => !/^(0|off|false|no)$/i.test((env["LOKI_E10_CARGO_MERGED_DOCTEST"] ?? "").trim()), DOCTEST_NOTE, cargoNoise = (l) => CARGO_NOISE.test(l) || cargoMergedDoctestOn() && DOCTEST_NOTE.test(l), GO_PKG_RE, GO_SRC, GO_DIR, GO_PKG_AFTER, GO_MAIN_BEFORE, GO_IDENT, GO_MAJOR, GO_KEYWORDS, goRel = (r) => r.replace(/^(?:\.\/)+/, ""), GO_NON_PKG_WORD, goIgnoredPath = (rel) => rel.split("/").some((g10) => g10 === "testdata" || g10.startsWith("_") || g10.startsWith(".")), goSiblingPkg = (dir) => existsSync113(dir) ? readdirSync52(dir).filter((f) => f.endsWith(".go") && !f.endsWith("_test.go")).map((f) => /^package\s+(\w+)/m.exec(readFileSync144(join159(dir, f), "utf8"))?.[1]).find(Boolean) : undefined, goDirPackage = (dir) => goSiblingPkg(dir) ?? (existsSync113(dir) ? readdirSync52(dir).filter((f) => f.endsWith("_test.go")).map((f) => /^package\s+(\w+)/m.exec(readFileSync144(join159(dir, f), "utf8"))?.[1]?.replace(/_test$/, "")).find(Boolean) : undefined), goPackageBrief = (repoDir, targetDir, runners, texts, importPathOf) => {
|
|
98853
99243
|
if (!runners.includes("go"))
|
|
98854
99244
|
return "";
|
|
98855
99245
|
const p = plannedGoDir(repoDir, texts);
|
|
@@ -98915,7 +99305,7 @@ exit $st`, wrapperOr = (repoDir, w, bare) => existsSync113(join159(repoDir, w))
|
|
|
98915
99305
|
return path.endsWith(".go") || /^(?:index|__init__|mod|lib|main)$/.test(base2) ? parts2.pop() ?? base2 : base2;
|
|
98916
99306
|
}, printable = (s) => s.replace(UNSAFE_TERMINAL_CHARS_RE, "?"), SENSITIVE, API, TEST_CFG, RANK4, FILES_MEDIUM = 4, FILES_HIGH = 15, LINES_MEDIUM = 100, LINES_HIGH = 500, RAN_ALWAYS, REVIEWER_ITEM = "one reviewer", PLAN, LOW_SKIPPED, deferredOf = (tier, selected, executed) => (tier === "low" ? LOW_SKIPPED : selected).filter((c) => !RAN_ALWAYS.includes(c) && !executed.includes(c)), DEEP_ITEMS, NOT_SELECTED = "not selected by risk tier: ", SECURITY_SCAN = "security scan", MANIFEST_LOCKS, dirOf2 = (p) => p.includes("/") ? p.slice(0, p.lastIndexOf("/")) : "", PKG_DEP_KEYS, PYPROJECT_NONDEP, SEM_RULES, DOC_FILE, readOr = (p) => {
|
|
98917
99307
|
try {
|
|
98918
|
-
return
|
|
99308
|
+
return readFileSync144(p, "utf8");
|
|
98919
99309
|
} catch {
|
|
98920
99310
|
return null;
|
|
98921
99311
|
}
|
|
@@ -99091,7 +99481,7 @@ var init_check_result = __esm(() => {
|
|
|
99091
99481
|
});
|
|
99092
99482
|
|
|
99093
99483
|
// ../../loki-ts/src/council/finding_schema.ts
|
|
99094
|
-
import { existsSync as existsSync114, readdirSync as readdirSync53, readFileSync as
|
|
99484
|
+
import { existsSync as existsSync114, readdirSync as readdirSync53, readFileSync as readFileSync145, statSync as statSync47 } from "fs";
|
|
99095
99485
|
import { resolve as resolvePath3, dirname as dirname68, relative as relative35, isAbsolute as isAbsolute26, join as join160, sep as sep28 } from "path";
|
|
99096
99486
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
99097
99487
|
function resolveSchemaDataDir(moduleDir = _moduleDir, candidates = SCHEMA_DATA_DIR_CANDIDATES) {
|
|
@@ -99131,7 +99521,7 @@ function staticLiterals() {
|
|
|
99131
99521
|
const out2 = { values: new Set, patterns: new Set };
|
|
99132
99522
|
for (const f of readdirSync53(_dataDir).filter((n10) => n10.endsWith("-schema.json"))) {
|
|
99133
99523
|
try {
|
|
99134
|
-
collectLiterals(JSON.parse(
|
|
99524
|
+
collectLiterals(JSON.parse(readFileSync145(resolvePath3(_dataDir, f), "utf8")), out2);
|
|
99135
99525
|
} catch {}
|
|
99136
99526
|
}
|
|
99137
99527
|
return _static = out2;
|
|
@@ -99173,7 +99563,7 @@ var init_finding_schema = __esm(() => {
|
|
|
99173
99563
|
SCHEMA_DATA_DIR_CANDIDATES = [["..", "..", "data"], ["..", "data"]];
|
|
99174
99564
|
_dataDir = resolveSchemaDataDir();
|
|
99175
99565
|
_schemaPath = resolvePath3(_dataDir, "finding-schema.json");
|
|
99176
|
-
FINDING_SCHEMA = Object.freeze(JSON.parse(
|
|
99566
|
+
FINDING_SCHEMA = Object.freeze(JSON.parse(readFileSync145(_schemaPath, "utf8")));
|
|
99177
99567
|
SchemaLiteralError = class SchemaLiteralError extends Error {
|
|
99178
99568
|
kind;
|
|
99179
99569
|
path;
|
|
@@ -99195,7 +99585,7 @@ var init_finding_schema = __esm(() => {
|
|
|
99195
99585
|
|
|
99196
99586
|
// ../../loki-ts/src/runner/oauth_dev.ts
|
|
99197
99587
|
import { execFileSync as execFileSync13 } from "child_process";
|
|
99198
|
-
import { readFileSync as
|
|
99588
|
+
import { readFileSync as readFileSync146 } from "fs";
|
|
99199
99589
|
import { homedir as homedir17 } from "os";
|
|
99200
99590
|
function oauthDevEnabled(env = process.env) {
|
|
99201
99591
|
const flag = (env["LOKI_SDK_OAUTH_DEV"] || "").trim().toLowerCase();
|
|
@@ -99226,7 +99616,7 @@ function readFreshOauthToken(env = process.env) {
|
|
|
99226
99616
|
}
|
|
99227
99617
|
try {
|
|
99228
99618
|
const dir = env["CLAUDE_CONFIG_DIR"] || `${homedir17()}/.claude`;
|
|
99229
|
-
const raw2 =
|
|
99619
|
+
const raw2 = readFileSync146(`${dir}/.credentials.json`, "utf8");
|
|
99230
99620
|
const t = tokenFromBlob(raw2);
|
|
99231
99621
|
if (t)
|
|
99232
99622
|
return t;
|
|
@@ -122272,11 +122662,11 @@ __export(exports_opus_consult, {
|
|
|
122272
122662
|
CONSULT_MODEL_DEFAULT: () => CONSULT_MODEL_DEFAULT,
|
|
122273
122663
|
CONSULT_FILE: () => CONSULT_FILE
|
|
122274
122664
|
});
|
|
122275
|
-
import { mkdirSync as mkdirSync87, readFileSync as
|
|
122665
|
+
import { mkdirSync as mkdirSync87, readFileSync as readFileSync147, writeFileSync as writeFileSync84 } from "fs";
|
|
122276
122666
|
import { join as join162 } from "path";
|
|
122277
122667
|
function readConsults(runDir) {
|
|
122278
122668
|
try {
|
|
122279
|
-
const j10 = JSON.parse(
|
|
122669
|
+
const j10 = JSON.parse(readFileSync147(join162(runDir, CONSULT_FILE), "utf8"));
|
|
122280
122670
|
return Array.isArray(j10) ? j10 : [];
|
|
122281
122671
|
} catch {
|
|
122282
122672
|
return [];
|
|
@@ -122365,7 +122755,7 @@ var init_opus_consult = __esm(() => {
|
|
|
122365
122755
|
// ../../loki-ts/src/util/conflict_resume.ts
|
|
122366
122756
|
import { createHash as createHash39 } from "crypto";
|
|
122367
122757
|
import { execFileSync as execFileSync14 } from "child_process";
|
|
122368
|
-
import { chmodSync as chmodSync8, existsSync as existsSync115, mkdirSync as mkdirSync88, mkdtempSync as mkdtempSync25, readdirSync as readdirSync54, readFileSync as
|
|
122758
|
+
import { chmodSync as chmodSync8, existsSync as existsSync115, mkdirSync as mkdirSync88, mkdtempSync as mkdtempSync25, readdirSync as readdirSync54, readFileSync as readFileSync148, rmSync as rmSync50, statSync as statSync48, symlinkSync as symlinkSync6, writeFileSync as writeFileSync85 } from "fs";
|
|
122369
122759
|
import { tmpdir as tmpdir33 } from "os";
|
|
122370
122760
|
import { basename as basename47, dirname as dirname70, isAbsolute as isAbsolute28, join as join163, relative as relative36 } from "path";
|
|
122371
122761
|
function answerMark(events2, assumeNext = false) {
|
|
@@ -122516,7 +122906,7 @@ function siteHints(ctx) {
|
|
|
122516
122906
|
return null;
|
|
122517
122907
|
return editShapeBrief(editShapeSites(g10.stdout, (p) => {
|
|
122518
122908
|
try {
|
|
122519
|
-
return
|
|
122909
|
+
return readFileSync148(join163(ctx.repoDir, p), "utf8");
|
|
122520
122910
|
} catch {
|
|
122521
122911
|
return null;
|
|
122522
122912
|
}
|
|
@@ -122633,7 +123023,7 @@ async function refereeSession(ctx, first, id2, task, files, ask, keep = []) {
|
|
|
122633
123023
|
if (ok2)
|
|
122634
123024
|
for (const n10 of keep) {
|
|
122635
123025
|
try {
|
|
122636
|
-
out2[n10] =
|
|
123026
|
+
out2[n10] = readFileSync148(join163(cwd, n10), "utf8");
|
|
122637
123027
|
} catch {}
|
|
122638
123028
|
}
|
|
122639
123029
|
return { verdict: ok2 ? readJson9(join163(cwd, "verdict.json")) : null, out: out2, ids: [id2], durationS: s.durationS };
|
|
@@ -122706,7 +123096,7 @@ async function adjudicateWallConflict(ctx, first, firstSession, wall, deps = {})
|
|
|
122706
123096
|
if (existsSync115(dirname70(sealedCopy)))
|
|
122707
123097
|
writeFileSync85(sealedCopy, next, "utf8");
|
|
122708
123098
|
sf2.sha256 = createHash39("sha256").update(next).digest("hex");
|
|
122709
|
-
const sealedNow = existsSync115(sealedCopy) ?
|
|
123099
|
+
const sealedNow = existsSync115(sealedCopy) ? readFileSync148(sealedCopy, "utf8") : null;
|
|
122710
123100
|
if (sealedNow !== next) {
|
|
122711
123101
|
restore();
|
|
122712
123102
|
if (sealedNow !== null)
|
|
@@ -122767,7 +123157,7 @@ async function legacyReauthor(ctx, first, firstSession, f, a, reason, task) {
|
|
|
122767
123157
|
|
|
122768
123158
|
`)
|
|
122769
123159
|
});
|
|
122770
|
-
const next = !au.killed && au.exit === 0 && existsSync115(join163(cwd, name)) ?
|
|
123160
|
+
const next = !au.killed && au.exit === 0 && existsSync115(join163(cwd, name)) ? readFileSync148(join163(cwd, name), "utf8") : "";
|
|
122771
123161
|
if (next.trim() === "" || next === f.content)
|
|
122772
123162
|
return null;
|
|
122773
123163
|
f.content = next;
|
|
@@ -122837,7 +123227,7 @@ async function deliverOverWallConflict(o, repoDir, reverify, emit2, opts = {}) {
|
|
|
122837
123227
|
const reason = conflict ? WALL_CONFLICT_DISCARD : WALL_ONLY_DISCARD, gone = (p) => files.includes(isAbsolute28(p) ? relative36(repoDir, p) : p);
|
|
122838
123228
|
const read3 = (p) => {
|
|
122839
123229
|
try {
|
|
122840
|
-
return
|
|
123230
|
+
return readFileSync148(p);
|
|
122841
123231
|
} catch {
|
|
122842
123232
|
return null;
|
|
122843
123233
|
}
|
|
@@ -122938,7 +123328,7 @@ async function resumeForPrecedence(ctx, first, firstSession, env2 = process.env)
|
|
|
122938
123328
|
};
|
|
122939
123329
|
const sites = editShapeSites(g10.stdout, (p) => {
|
|
122940
123330
|
try {
|
|
122941
|
-
return
|
|
123331
|
+
return readFileSync148(join163(ctx.repoDir, p), "utf8");
|
|
122942
123332
|
} catch {
|
|
122943
123333
|
return null;
|
|
122944
123334
|
}
|
|
@@ -122974,7 +123364,7 @@ var refereeModel = (ctx) => capToRunTier(wallPinModel(), ctx.model, ["LOKI_E10_W
|
|
|
122974
123364
|
return r.fail > 0 ? "fail" : r.pass > 0 && (r.not_run ?? 0) === 0 ? "pass" : "not_run";
|
|
122975
123365
|
}, readJson9 = (p) => {
|
|
122976
123366
|
try {
|
|
122977
|
-
const v10 = JSON.parse(
|
|
123367
|
+
const v10 = JSON.parse(readFileSync148(p, "utf8"));
|
|
122978
123368
|
return v10 && typeof v10 === "object" ? v10 : null;
|
|
122979
123369
|
} catch {
|
|
122980
123370
|
return null;
|
|
@@ -123092,7 +123482,7 @@ __export(exports_run_outputs, {
|
|
|
123092
123482
|
});
|
|
123093
123483
|
import { execFile as execFile3, spawnSync as spawnSync27 } from "child_process";
|
|
123094
123484
|
import { createHash as createHash40 } from "crypto";
|
|
123095
|
-
import { existsSync as existsSync116, lstatSync as lstatSync36, mkdirSync as mkdirSync89, readdirSync as readdirSync55, readFileSync as
|
|
123485
|
+
import { existsSync as existsSync116, lstatSync as lstatSync36, mkdirSync as mkdirSync89, readdirSync as readdirSync55, readFileSync as readFileSync149, statSync as statSync49, writeFileSync as writeFileSync86 } from "fs";
|
|
123096
123486
|
import { basename as basename48, join as join164, resolve as resolve45 } from "path";
|
|
123097
123487
|
function intentRevisionsBlock(revs) {
|
|
123098
123488
|
const r = (revs ?? []).filter((r10) => r10.unapplied !== true).map(({ rev, source, actor, sha: sha6 }) => ({ rev, source, actor, sha: sha6 }));
|
|
@@ -123101,11 +123491,11 @@ function intentRevisionsBlock(revs) {
|
|
|
123101
123491
|
function seededCorpusBlock(env2 = process.env) {
|
|
123102
123492
|
const dir = env2["LOKI_SEEDED_DEFECTS_DIR"] || join164(REPO_ROOT, "benchmarks", "seeded-defects");
|
|
123103
123493
|
try {
|
|
123104
|
-
const bytes =
|
|
123494
|
+
const bytes = readFileSync149(join164(dir, "manifest.json")), version2 = createHash40("sha256").update(bytes).digest("hex");
|
|
123105
123495
|
const ids = (JSON.parse(bytes.toString("utf8")).defects ?? []).map((d) => d.id);
|
|
123106
123496
|
let rate = null;
|
|
123107
123497
|
try {
|
|
123108
|
-
const res = JSON.parse(
|
|
123498
|
+
const res = JSON.parse(readFileSync149(join164(dir, "results", "wrong-pass.json"), "utf8"));
|
|
123109
123499
|
const runs2 = res.manifest_sha256 === version2 && Array.isArray(res.runs) ? res.runs : [];
|
|
123110
123500
|
const complete = (o) => !!o && Object.keys(o).length === ids.length && ids.every((id2) => typeof id2 === "string" && (o[id2] === "SEALED" || o[id2] === "NOT_SEALED"));
|
|
123111
123501
|
const top = runs2.filter((r) => r.setup === "top"), floor = runs2.filter((r) => r.setup === "floor");
|
|
@@ -123122,8 +123512,8 @@ function seededCorpusBlock(env2 = process.env) {
|
|
|
123122
123512
|
function sealAccuracyLine(changed, checks, model, env2 = process.env, nowMs = Date.now()) {
|
|
123123
123513
|
try {
|
|
123124
123514
|
const dir = env2["LOKI_SEEDED_DEFECTS_DIR"] || join164(REPO_ROOT, "benchmarks", "seeded-defects"), file = join164(dir, "results", "wrong-pass.json");
|
|
123125
|
-
const corpus2 = createHash40("sha256").update(
|
|
123126
|
-
const res = JSON.parse(
|
|
123515
|
+
const corpus2 = createHash40("sha256").update(readFileSync149(join164(dir, "manifest.json"))).digest("hex");
|
|
123516
|
+
const res = JSON.parse(readFileSync149(file, "utf8"));
|
|
123127
123517
|
if (res.manifest_sha256 !== corpus2 || !Array.isArray(res.runs))
|
|
123128
123518
|
return SEAL_ACCURACY_NOT_MEASURED;
|
|
123129
123519
|
const first = changed.map((f) => basename48(f)).find((b) => !SPEC_PREFIXES.some((p) => b.startsWith(p)));
|
|
@@ -123156,7 +123546,7 @@ function outputsFromEvents(events2) {
|
|
|
123156
123546
|
}
|
|
123157
123547
|
function readText2(path4) {
|
|
123158
123548
|
try {
|
|
123159
|
-
return existsSync116(path4) ?
|
|
123549
|
+
return existsSync116(path4) ? readFileSync149(path4, "utf8") : null;
|
|
123160
123550
|
} catch {
|
|
123161
123551
|
return null;
|
|
123162
123552
|
}
|
|
@@ -123290,7 +123680,7 @@ function findInterrupted(repoDir, runId2, includeCancelled = false, why) {
|
|
|
123290
123680
|
if (foreign)
|
|
123291
123681
|
return no(`run ${top.id} holds an event from run ${String(foreign.run)}; its log is not its own`);
|
|
123292
123682
|
try {
|
|
123293
|
-
const raw2 =
|
|
123683
|
+
const raw2 = readFileSync149(join164(repoDir, eventsRelPath(top.id)), "utf8"), torn = raw2.split(`
|
|
123294
123684
|
`).filter((l) => l.trim() !== "").length !== events2.length;
|
|
123295
123685
|
if (torn && phase === "publish")
|
|
123296
123686
|
return no(`run ${top.id} has a torn or unparsable event log`);
|
|
@@ -123443,7 +123833,7 @@ async function resumeFlag(runId2, noPr = false, deps = {}, answer) {
|
|
|
123443
123833
|
}
|
|
123444
123834
|
let raw2 = "";
|
|
123445
123835
|
try {
|
|
123446
|
-
raw2 =
|
|
123836
|
+
raw2 = readFileSync149(join164(repoDir, eventsRelPath(it2.runId)), "utf8");
|
|
123447
123837
|
} catch {
|
|
123448
123838
|
return cannotResume(out2, it2.runId, "its event log is unreadable");
|
|
123449
123839
|
}
|
|
@@ -123576,7 +123966,7 @@ async function signedReceiptFacts(runDir, runId2, events2) {
|
|
|
123576
123966
|
}
|
|
123577
123967
|
let r;
|
|
123578
123968
|
try {
|
|
123579
|
-
r = JSON.parse(
|
|
123969
|
+
r = JSON.parse(readFileSync149(file, "utf8"));
|
|
123580
123970
|
} catch {
|
|
123581
123971
|
return { problem: "receipt.json is missing or unreadable" };
|
|
123582
123972
|
}
|
|
@@ -123720,7 +124110,7 @@ function stagesResumable(repoDir, runId2, events2) {
|
|
|
123720
124110
|
if (!branchExists2(repoDir, runId2) || cancelTailProblem(events2))
|
|
123721
124111
|
return false;
|
|
123722
124112
|
try {
|
|
123723
|
-
const tl2 = trustedLog(events2,
|
|
124113
|
+
const tl2 = trustedLog(events2, readFileSync149(join164(repoDir, eventsRelPath(runId2)), "utf8")), rp2 = resumePoint(tl2.events, tl2.raw);
|
|
123724
124114
|
if (!rp2.ok || rp2.skip.length === 0)
|
|
123725
124115
|
return false;
|
|
123726
124116
|
const base2 = tl2.events.findLast((e10) => e10.type === "stage.completed" && e10.stage === "intake")?.data["base_sha"];
|
|
@@ -123884,7 +124274,7 @@ function runIntent(repoDir, env2 = process.env) {
|
|
|
123884
124274
|
let policy = null;
|
|
123885
124275
|
if (pf2) {
|
|
123886
124276
|
try {
|
|
123887
|
-
policy = createHash40("sha256").update(
|
|
124277
|
+
policy = createHash40("sha256").update(readFileSync149(pf2)).digest("hex");
|
|
123888
124278
|
} catch {}
|
|
123889
124279
|
}
|
|
123890
124280
|
const parent = /^[A-Za-z0-9._-]{1,128}$/.test(env2.LOKI_PARENT_RUN ?? "") ? env2.LOKI_PARENT_RUN : null;
|
|
@@ -123999,7 +124389,7 @@ function prWorkflowsSkipping(repoDir, base2) {
|
|
|
123999
124389
|
for (const f of files) {
|
|
124000
124390
|
let doc;
|
|
124001
124391
|
try {
|
|
124002
|
-
doc = Bun.YAML.parse(
|
|
124392
|
+
doc = Bun.YAML.parse(readFileSync149(join164(dir, f), "utf8"));
|
|
124003
124393
|
} catch {
|
|
124004
124394
|
return [];
|
|
124005
124395
|
}
|
|
@@ -124090,7 +124480,7 @@ async function sealRefusal(o) {
|
|
|
124090
124480
|
provider,
|
|
124091
124481
|
model: "",
|
|
124092
124482
|
resumed: false,
|
|
124093
|
-
events_sha256: seal.sha256(
|
|
124483
|
+
events_sha256: seal.sha256(readFileSync149(log2.path)),
|
|
124094
124484
|
log_seal: true,
|
|
124095
124485
|
toolchain: signer.collectToolchain()
|
|
124096
124486
|
};
|
|
@@ -124118,7 +124508,7 @@ var SEAL_ACCURACY_NOT_MEASURED = "Seal accuracy: not measured", SEAL_ACCURACY_MA
|
|
|
124118
124508
|
return typeof v10 === "string" && /^Seal accuracy[^\x00-\x1f\x7f]{0,300}$/.test(v10) ? v10 : SEAL_ACCURACY_NOT_MEASURED;
|
|
124119
124509
|
}, sealAccuracyOfFile = (path4) => {
|
|
124120
124510
|
try {
|
|
124121
|
-
return receiptSealAccuracy(JSON.parse(
|
|
124511
|
+
return receiptSealAccuracy(JSON.parse(readFileSync149(path4 ?? "", "utf8")));
|
|
124122
124512
|
} catch {
|
|
124123
124513
|
return SEAL_ACCURACY_NOT_MEASURED;
|
|
124124
124514
|
}
|
|
@@ -124172,14 +124562,14 @@ var init_run_outputs = __esm(() => {
|
|
|
124172
124562
|
});
|
|
124173
124563
|
|
|
124174
124564
|
// ../../loki-ts/src/util/composite_seal.ts
|
|
124175
|
-
import { existsSync as existsSync117, readFileSync as
|
|
124565
|
+
import { existsSync as existsSync117, readFileSync as readFileSync150 } from "fs";
|
|
124176
124566
|
import { basename as basename49, dirname as dirname71, join as join165 } from "path";
|
|
124177
124567
|
function logProblem(runDir, integ) {
|
|
124178
124568
|
if (typeof integ["log_sha256"] !== "string")
|
|
124179
124569
|
return null;
|
|
124180
124570
|
let b;
|
|
124181
124571
|
try {
|
|
124182
|
-
b =
|
|
124572
|
+
b = readFileSync150(join165(runDir, "integration.log"));
|
|
124183
124573
|
} catch {
|
|
124184
124574
|
return "integration.log is missing but integration.json records its hash";
|
|
124185
124575
|
}
|
|
@@ -124197,7 +124587,7 @@ function composeComposite(runDir, rh, toolchain = collectToolchain()) {
|
|
|
124197
124587
|
const ip2 = join165(runDir, "integration.json");
|
|
124198
124588
|
let ibytes;
|
|
124199
124589
|
try {
|
|
124200
|
-
ibytes =
|
|
124590
|
+
ibytes = readFileSync150(ip2);
|
|
124201
124591
|
} catch {
|
|
124202
124592
|
throw new Error("integration.json missing; the workspace run did not finish");
|
|
124203
124593
|
}
|
|
@@ -124226,7 +124616,7 @@ function composeComposite(runDir, rh, toolchain = collectToolchain()) {
|
|
|
124226
124616
|
const id2 = ids[ids.length - 1];
|
|
124227
124617
|
if (!id2)
|
|
124228
124618
|
throw new Error(`repo ${text3(repo, 80)} has no receipt.json under worktrees/${slugOf(repo)}/.loki/runs`);
|
|
124229
|
-
const rp2 = join165(runsDir, id2, "receipt.json"), bytes =
|
|
124619
|
+
const rp2 = join165(runsDir, id2, "receipt.json"), bytes = readFileSync150(rp2), r = readJson6(rp2);
|
|
124230
124620
|
if (jsonTooDeep(r))
|
|
124231
124621
|
throw new Error(`repo ${text3(repo, 80)} receipt cannot be hashed (nested too deeply); no composite`);
|
|
124232
124622
|
if (!isObj10(r) || typeof r["receipt_sha256"] !== "string" || rh(r) !== r["receipt_sha256"])
|
|
@@ -124263,7 +124653,7 @@ async function verifyComposite(receiptPath, receipt, rh, verifyOne, deps = {}) {
|
|
|
124263
124653
|
return bad("body malformed");
|
|
124264
124654
|
let ibytes;
|
|
124265
124655
|
try {
|
|
124266
|
-
ibytes =
|
|
124656
|
+
ibytes = readFileSync150(join165(runDir, "integration.json"));
|
|
124267
124657
|
} catch {
|
|
124268
124658
|
return bad("integration.json missing");
|
|
124269
124659
|
}
|
|
@@ -124309,7 +124699,7 @@ async function verifyComposite(receiptPath, receipt, rh, verifyOne, deps = {}) {
|
|
|
124309
124699
|
const rp2 = join165(runDir, rel);
|
|
124310
124700
|
let bytes;
|
|
124311
124701
|
try {
|
|
124312
|
-
bytes =
|
|
124702
|
+
bytes = readFileSync150(rp2);
|
|
124313
124703
|
} catch {
|
|
124314
124704
|
return bad(`child ${repo} receipt missing`);
|
|
124315
124705
|
}
|
|
@@ -124372,7 +124762,7 @@ __export(exports_verify_cmd, {
|
|
|
124372
124762
|
checkEventLog: () => checkEventLog,
|
|
124373
124763
|
checkAttestation: () => checkAttestation
|
|
124374
124764
|
});
|
|
124375
|
-
import { existsSync as existsSync118, readFileSync as
|
|
124765
|
+
import { existsSync as existsSync118, readFileSync as readFileSync151, renameSync as renameSync29, statSync as statSync50, writeFileSync as writeFileSync87 } from "fs";
|
|
124376
124766
|
import { basename as basename50, dirname as dirname72, join as join166 } from "path";
|
|
124377
124767
|
import { createHash as createHash41, verify as verify5 } from "crypto";
|
|
124378
124768
|
function checkAttestation(jwt, expectedHash, given) {
|
|
@@ -124405,7 +124795,7 @@ function wallTamperProblem(receiptPath, receipt) {
|
|
|
124405
124795
|
const copy = sealedWallCopy(dirname72(receiptPath), f.path);
|
|
124406
124796
|
let cur;
|
|
124407
124797
|
try {
|
|
124408
|
-
cur = createHash41("sha256").update(
|
|
124798
|
+
cur = createHash41("sha256").update(readFileSync151(copy)).digest("hex");
|
|
124409
124799
|
} catch {
|
|
124410
124800
|
if (haveWallDir)
|
|
124411
124801
|
return `sealed Wall file ${basename50(f.path)} is missing from the run's wall directory: it was deleted after the seal`;
|
|
@@ -124435,7 +124825,7 @@ function checkEventLog(receiptPath, receipt) {
|
|
|
124435
124825
|
const path4 = join166(dirname72(receiptPath), "events.jsonl");
|
|
124436
124826
|
if (!existsSync118(path4))
|
|
124437
124827
|
return "events.jsonl is missing";
|
|
124438
|
-
const raw2 =
|
|
124828
|
+
const raw2 = readFileSync151(path4, "utf8"), events2 = readEvents(path4), all = raw2.split(`
|
|
124439
124829
|
`).filter((l) => l.trim() !== ""), lines2 = tornTail(raw2) ? all.slice(0, -1) : all;
|
|
124440
124830
|
if (events2.length !== lines2.length || events2.some((e10, i) => e10.seq !== i))
|
|
124441
124831
|
return "events.jsonl has a forged, edited or missing line";
|
|
@@ -124475,7 +124865,7 @@ function checkLogSeal(receiptPath, hash, kid, given) {
|
|
|
124475
124865
|
return n10 === undefined ? s === rs2 : answeredBlockedBetween(events2, s, n10);
|
|
124476
124866
|
}))
|
|
124477
124867
|
return { verdict: "TAMPERED", reason: "events.jsonl holds more than one receipt.sealed event without an answered BLOCKED run between them; a run seals exactly one receipt" };
|
|
124478
|
-
const raw2 =
|
|
124868
|
+
const raw2 = readFileSync151(path4, "utf8"), whole = tornTail(raw2) ? raw2.slice(0, raw2.lastIndexOf(`
|
|
124479
124869
|
`) + 1) : raw2;
|
|
124480
124870
|
const chain = verifyLogSeals(whole, events2, { kid, given, expectSeal: true });
|
|
124481
124871
|
if (chain)
|
|
@@ -124487,7 +124877,7 @@ function checkLogSeal(receiptPath, hash, kid, given) {
|
|
|
124487
124877
|
const seal = events2[done + 1], d = seal?.type === "log.sealed" ? seal.data : null;
|
|
124488
124878
|
if (!d)
|
|
124489
124879
|
return { verdict: "TAMPERED", reason: "events.jsonl has no signed log.sealed line after run.completed" };
|
|
124490
|
-
const lines2 =
|
|
124880
|
+
const lines2 = readFileSync151(path4, "utf8").split(`
|
|
124491
124881
|
`).filter((l) => l.trim() !== ""), sha7 = createHash41("sha256").update(lines2.slice(0, done + 1).join(`
|
|
124492
124882
|
`) + `
|
|
124493
124883
|
`).digest("hex");
|
|
@@ -124509,7 +124899,7 @@ async function verifyReceipt(receiptPath, deps = {}) {
|
|
|
124509
124899
|
return { verdict: "UNCHECKED", reasons: [`receipt not found: ${receiptPath}`] };
|
|
124510
124900
|
let receipt;
|
|
124511
124901
|
try {
|
|
124512
|
-
receipt = JSON.parse((deps.read ?? ((p) =>
|
|
124902
|
+
receipt = JSON.parse((deps.read ?? ((p) => readFileSync151(p, "utf8")))(receiptPath));
|
|
124513
124903
|
} catch {
|
|
124514
124904
|
return { verdict: "UNCHECKED", reasons: ["receipt.json is not valid JSON"] };
|
|
124515
124905
|
}
|
|
@@ -124620,7 +125010,7 @@ ${compositeLines(out2).join(`
|
|
|
124620
125010
|
function independentLine(receiptPath) {
|
|
124621
125011
|
let checks = [];
|
|
124622
125012
|
try {
|
|
124623
|
-
const c = JSON.parse(
|
|
125013
|
+
const c = JSON.parse(readFileSync151(receiptPath, "utf8")).checks;
|
|
124624
125014
|
if (Array.isArray(c))
|
|
124625
125015
|
checks = c;
|
|
124626
125016
|
} catch {}
|
|
@@ -124632,7 +125022,7 @@ function independentLine(receiptPath) {
|
|
|
124632
125022
|
}
|
|
124633
125023
|
function signedRunIdProblem(receiptPath, runId2) {
|
|
124634
125024
|
try {
|
|
124635
|
-
const r = JSON.parse(
|
|
125025
|
+
const r = JSON.parse(readFileSync151(receiptPath, "utf8")), s = r["run_id"];
|
|
124636
125026
|
return isEnvelope(r) || typeof s !== "string" || s === runId2 ? null : `receipt run_id ${JSON.stringify(printable(s).slice(0, 128))} does not match the run id ${JSON.stringify(runId2)} it was found under (a sealed run copied under another id)`;
|
|
124637
125027
|
} catch {
|
|
124638
125028
|
return null;
|
|
@@ -124708,7 +125098,7 @@ verdict: TAMPERED
|
|
|
124708
125098
|
if (result.verdict === "VERIFIED" || result.verdict === "UNSIGNED") {
|
|
124709
125099
|
const d = (() => {
|
|
124710
125100
|
try {
|
|
124711
|
-
return sealDrift(receiptPath, JSON.parse(
|
|
125101
|
+
return sealDrift(receiptPath, JSON.parse(readFileSync151(receiptPath, "utf8")));
|
|
124712
125102
|
} catch {
|
|
124713
125103
|
return null;
|
|
124714
125104
|
}
|
|
@@ -124721,7 +125111,7 @@ verdict: TAMPERED
|
|
|
124721
125111
|
{
|
|
124722
125112
|
const id2 = (() => {
|
|
124723
125113
|
try {
|
|
124724
|
-
const r = JSON.parse(
|
|
125114
|
+
const r = JSON.parse(readFileSync151(receiptPath, "utf8"));
|
|
124725
125115
|
const j10 = r["verification"]?.jwt;
|
|
124726
125116
|
const k10 = result.verdict === "VERIFIED" && typeof j10 === "string" ? JSON.parse(Buffer.from(j10.split(".")[0], "base64url").toString()).kid : null;
|
|
124727
125117
|
return { kid: typeof k10 === "string" ? k10 : null, head: typeof r["head_sha"] === "string" ? r["head_sha"] : null, verdict: typeof r["verdict"] === "string" ? r["verdict"] : null, run: typeof r["run_id"] === "string" ? r["run_id"] : null };
|
|
@@ -124739,7 +125129,7 @@ verdict: TAMPERED
|
|
|
124739
125129
|
if (result.verdict === "VERIFIED" || result.verdict === "UNSIGNED") {
|
|
124740
125130
|
const outcome = (() => {
|
|
124741
125131
|
try {
|
|
124742
|
-
return outcomeOf(JSON.parse(
|
|
125132
|
+
return outcomeOf(JSON.parse(readFileSync151(receiptPath, "utf8")));
|
|
124743
125133
|
} catch {
|
|
124744
125134
|
return "UNREADABLE";
|
|
124745
125135
|
}
|
|
@@ -124773,7 +125163,7 @@ verdict: ${result.verdict}
|
|
|
124773
125163
|
`);
|
|
124774
125164
|
if (result.verdict !== "TAMPERED")
|
|
124775
125165
|
try {
|
|
124776
|
-
const r = JSON.parse(
|
|
125166
|
+
const r = JSON.parse(readFileSync151(receiptPath, "utf8"));
|
|
124777
125167
|
if (isComposite(r))
|
|
124778
125168
|
for (const l of compositeLines(r))
|
|
124779
125169
|
process.stdout.write(`${l}
|
|
@@ -124836,7 +125226,7 @@ var init_verify_cmd = __esm(() => {
|
|
|
124836
125226
|
});
|
|
124837
125227
|
|
|
124838
125228
|
// src/server/app.ts
|
|
124839
|
-
import { existsSync as existsSync120, readFileSync as
|
|
125229
|
+
import { existsSync as existsSync120, readFileSync as readFileSync154, statSync as statSync51 } from "fs";
|
|
124840
125230
|
import { join as join169, resolve as resolve46, sep as sep30 } from "path";
|
|
124841
125231
|
|
|
124842
125232
|
// node_modules/hono/dist/request/constants.js
|
|
@@ -135288,7 +135678,7 @@ function mount20(ctx) {
|
|
|
135288
135678
|
}
|
|
135289
135679
|
|
|
135290
135680
|
// src/server/routes/verify.ts
|
|
135291
|
-
import { readFileSync as
|
|
135681
|
+
import { readFileSync as readFileSync152, realpathSync as realpathSync45 } from "fs";
|
|
135292
135682
|
import { createPublicKey as createPublicKey9 } from "crypto";
|
|
135293
135683
|
import { join as join167, sep as sep29 } from "path";
|
|
135294
135684
|
init_verify_cmd();
|
|
@@ -135317,11 +135707,11 @@ function mount21(ctx) {
|
|
|
135317
135707
|
return done(404, "receipt not available", "not_found");
|
|
135318
135708
|
let runDir, file;
|
|
135319
135709
|
try {
|
|
135320
|
-
const root =
|
|
135321
|
-
runDir =
|
|
135710
|
+
const root = realpathSync45(join167(repo.p, ".loki", "runs"));
|
|
135711
|
+
runDir = realpathSync45(join167(root, run2));
|
|
135322
135712
|
if (runDir !== join167(root, run2))
|
|
135323
135713
|
return done(404, "receipt not found", "not_found");
|
|
135324
|
-
file =
|
|
135714
|
+
file = realpathSync45(join167(runDir, "receipt.json"));
|
|
135325
135715
|
} catch {
|
|
135326
135716
|
return done(404, "receipt not found", "not_found");
|
|
135327
135717
|
}
|
|
@@ -135340,7 +135730,7 @@ function mount21(ctx) {
|
|
|
135340
135730
|
sha7 = r.receiptSha256 ?? null;
|
|
135341
135731
|
}
|
|
135342
135732
|
try {
|
|
135343
|
-
outcome = outcomeOf(JSON.parse(
|
|
135733
|
+
outcome = outcomeOf(JSON.parse(readFileSync152(file, "utf8")));
|
|
135344
135734
|
} catch {
|
|
135345
135735
|
outcome = "UNREADABLE";
|
|
135346
135736
|
}
|
|
@@ -135402,7 +135792,7 @@ function ttlCache(ttlMs = PROBE_CACHE_MS, now2 = Date.now) {
|
|
|
135402
135792
|
}
|
|
135403
135793
|
|
|
135404
135794
|
// src/server/legacy/shim.ts
|
|
135405
|
-
import { existsSync as existsSync119, readFileSync as
|
|
135795
|
+
import { existsSync as existsSync119, readFileSync as readFileSync153 } from "fs";
|
|
135406
135796
|
import { join as join168 } from "path";
|
|
135407
135797
|
|
|
135408
135798
|
// src/server/legacy/routes.ts
|
|
@@ -135784,7 +136174,7 @@ var repoVersion = () => {
|
|
|
135784
136174
|
for (const f of [join168(import.meta.dir, "../../../../../VERSION")]) {
|
|
135785
136175
|
try {
|
|
135786
136176
|
if (existsSync119(f))
|
|
135787
|
-
return
|
|
136177
|
+
return readFileSync153(f, "utf8").trim();
|
|
135788
136178
|
} catch {}
|
|
135789
136179
|
}
|
|
135790
136180
|
return "unknown";
|
|
@@ -135998,7 +136388,7 @@ function createApp(opts) {
|
|
|
135998
136388
|
for (const f of [process.env.LOKI_VERSION_FILE, join169(import.meta.dir, "../../../../VERSION")]) {
|
|
135999
136389
|
try {
|
|
136000
136390
|
if (f)
|
|
136001
|
-
return
|
|
136391
|
+
return readFileSync154(f, "utf8").trim() || "unknown";
|
|
136002
136392
|
} catch {}
|
|
136003
136393
|
}
|
|
136004
136394
|
return "unknown";
|