loki-mode 11.81.0 → 11.82.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/loki-ts/dist/loki.js +1212 -1212
- package/loki-ts/package.json +1 -1
- package/mcp/__init__.py +1 -1
- package/package.json +2 -2
- package/packages/control-plane/dist/server.js +631 -544
- package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
- package/web-app/dist/assets/{AdminPage-DTV2dhiB.js → AdminPage-BDwJkrfT.js} +1 -1
- package/web-app/dist/assets/{Avatar-CuRNeLZm.js → Avatar-Bjb7tmLG.js} +1 -1
- package/web-app/dist/assets/{Badge-ByJ4qXbr.js → Badge-BYWNt-lF.js} +1 -1
- package/web-app/dist/assets/{Button-CLlcM2Xy.js → Button-CEKS68UU.js} +1 -1
- package/web-app/dist/assets/{CockpitPage-D0Papd79.js → CockpitPage-fAeYAB91.js} +1 -1
- package/web-app/dist/assets/{ComparePage-9BlgyTa5.js → ComparePage-DRiaB5aq.js} +1 -1
- package/web-app/dist/assets/{ErrorBoundary-Cz-ecOMw.js → ErrorBoundary-C_ts0y6d.js} +1 -1
- package/web-app/dist/assets/{EvidenceReceiptPanel-CW65uMId.js → EvidenceReceiptPanel-CAM2bOHh.js} +1 -1
- package/web-app/dist/assets/{GitHubIssuesPanel-BCK2TwVX.js → GitHubIssuesPanel-eTpdboWA.js} +1 -1
- package/web-app/dist/assets/{GitHubPRsPanel-BGX_7fik.js → GitHubPRsPanel-ufk1eqQm.js} +1 -1
- package/web-app/dist/assets/{HomePage-Dh0Vf3xE.js → HomePage-D8Cg8c0d.js} +2 -2
- package/web-app/dist/assets/{LoginPage-CJS1CI2d.js → LoginPage-DWVzDN9I.js} +1 -1
- package/web-app/dist/assets/{MagicPage-vzszNi5D.js → MagicPage-bmS03_51.js} +1 -1
- package/web-app/dist/assets/{MetricsPage-BkjDzD2o.js → MetricsPage-ffCkhsSV.js} +1 -1
- package/web-app/dist/assets/{NotFoundPage-m-TFfjZB.js → NotFoundPage-CqluOiCR.js} +1 -1
- package/web-app/dist/assets/{ProjectPage-RxcuWm0p.js → ProjectPage-D5XbTRQt.js} +3 -3
- package/web-app/dist/assets/{ProjectsPage-H84CnWb9.js → ProjectsPage-BK4mJziQ.js} +1 -1
- package/web-app/dist/assets/{SettingsPage-CCDW8ypI.js → SettingsPage-BoH4mS-n.js} +1 -1
- package/web-app/dist/assets/{ShowcasePage-DbiGAkJQ.js → ShowcasePage-B7xHXyht.js} +1 -1
- package/web-app/dist/assets/{SystemSettingsPage-BY4AS1p0.js → SystemSettingsPage-BFyzSmVR.js} +1 -1
- package/web-app/dist/assets/{TeamsPage-CTIHVI1l.js → TeamsPage-DkuTf7Pm.js} +1 -1
- package/web-app/dist/assets/{TemplatesPage-B3Dll4hk.js → TemplatesPage-DqC4qY5U.js} +1 -1
- package/web-app/dist/assets/{TerminalOutput-jbcO9Bsi.js → TerminalOutput-CiERRLAB.js} +1 -1
- package/web-app/dist/assets/{activity-DXbXld5V.js → activity-BBdRZTad.js} +1 -1
- package/web-app/dist/assets/{bell-BzvWvgDR.js → bell-CvIl2nxi.js} +1 -1
- package/web-app/dist/assets/{bot-ltT4ATbp.js → bot-CWMB2JQE.js} +1 -1
- package/web-app/dist/assets/{check-BQy4vV4C.js → check-CSVvxOtd.js} +1 -1
- package/web-app/dist/assets/{chevron-left-D-8R7fpT.js → chevron-left-B7MXj-CB.js} +1 -1
- package/web-app/dist/assets/{circle-alert-BfP0EZVt.js → circle-alert-DlegpSSz.js} +1 -1
- package/web-app/dist/assets/{clock-Cg9sjQNA.js → clock-CO7alYth.js} +1 -1
- package/web-app/dist/assets/{cloud-BYE6NS7N.js → cloud-CmCwC9tD.js} +1 -1
- package/web-app/dist/assets/{code-xml-BgyGtnXD.js → code-xml-CttGX_KN.js} +1 -1
- package/web-app/dist/assets/{database-DUG1ZeOC.js → database-BFoEsl1d.js} +1 -1
- package/web-app/dist/assets/{dollar-sign-BVr-KRUq.js → dollar-sign-CsX8E6iv.js} +1 -1
- package/web-app/dist/assets/{file-code-corner-DxuH5o2n.js → file-code-corner-AD_LP7Sr.js} +1 -1
- package/web-app/dist/assets/{file-plus-C-lCUDgD.js → file-plus-D1lrSELb.js} +1 -1
- package/web-app/dist/assets/{globe-DqKuQkyN.js → globe-BO79vdlK.js} +1 -1
- package/web-app/dist/assets/{hammer-BqwVJBn2.js → hammer-ByRAYTmN.js} +1 -1
- package/web-app/dist/assets/{index-BW7zDSIx.js → index-Dhf-7-HA.js} +3 -3
- package/web-app/dist/assets/{layers-CU4GmS7C.js → layers-Ch8twnaQ.js} +1 -1
- package/web-app/dist/assets/{loader-circle-CgGtlk-q.js → loader-circle-jCLtMahM.js} +1 -1
- package/web-app/dist/assets/{lock-Cn208PMq.js → lock-DYipaQub.js} +1 -1
- package/web-app/dist/assets/{package-DjTyJpyz.js → package-DTU2eDJk.js} +1 -1
- package/web-app/dist/assets/{plus-ChnvK7EJ.js → plus-Dwtg85R2.js} +1 -1
- package/web-app/dist/assets/{refresh-cw-fM4zKbbz.js → refresh-cw-B2BZn7xv.js} +1 -1
- package/web-app/dist/assets/{rotate-ccw-Dve_P_7C.js → rotate-ccw-BnDgsF2l.js} +1 -1
- package/web-app/dist/assets/{scroll-text-D3n4diXE.js → scroll-text-CHcWlkC1.js} +1 -1
- package/web-app/dist/assets/{server-Bdos2U9d.js → server-DGbuh4v5.js} +1 -1
- package/web-app/dist/assets/{shield-alert-BnfY762y.js → shield-alert-BGxG6i1x.js} +1 -1
- package/web-app/dist/assets/{thumbs-up-DxWy1t-9.js → thumbs-up-C4_XsjwR.js} +1 -1
- package/web-app/dist/assets/{trash-2-DzPQ9F3N.js → trash-2-CXkZKiJ3.js} +1 -1
- package/web-app/dist/assets/{trending-down-C9NXDBkU.js → trending-down-Ca8gOfqE.js} +1 -1
- package/web-app/dist/assets/{trending-up-BuuMWCy7.js → trending-up-BwTtd3Ft.js} +1 -1
- package/web-app/dist/assets/{upload-zBn3mjxr.js → upload-DK47bkj8.js} +1 -1
- package/web-app/dist/assets/{usePolling-DKhd6jST.js → usePolling-CrEvFOnC.js} +1 -1
- package/web-app/dist/assets/{user-B-YyoAjg.js → user-Ck5fqwRB.js} +1 -1
- package/web-app/dist/index.html +1 -1
|
@@ -63711,11 +63711,19 @@ function wallAnchor(reason, wall) {
|
|
|
63711
63711
|
}
|
|
63712
63712
|
return null;
|
|
63713
63713
|
}
|
|
63714
|
+
function defectsOf(s) {
|
|
63715
|
+
const many = Array.isArray(s?.wall_defects) ? s.wall_defects : [], one2 = s?.wall_defect;
|
|
63716
|
+
return [...many, ...one2 ? [one2] : []];
|
|
63717
|
+
}
|
|
63718
|
+
function accumulateWallDefects(prior, current) {
|
|
63719
|
+
const all = [...defectsOf(prior), ...current ? [current] : []], seen = new Set;
|
|
63720
|
+
return all.filter((d) => {
|
|
63721
|
+
const k3 = `${d.action}|${d.file}|${d.line}|${d.reason}`;
|
|
63722
|
+
return seen.has(k3) ? false : (seen.add(k3), true);
|
|
63723
|
+
});
|
|
63724
|
+
}
|
|
63714
63725
|
function wallDropped(o) {
|
|
63715
|
-
return [...new Set([o.implement, o.fix].flatMap((s) => {
|
|
63716
|
-
const d = s?.wall_defect;
|
|
63717
|
-
return d?.action === "dropped" ? [`${WALL_DROPPED}: ${d.file}:${d.line}: ${d.reason}`] : [];
|
|
63718
|
-
}))];
|
|
63726
|
+
return [...new Set([o.implement, o.fix].flatMap((s) => defectsOf(s).filter((d) => d.action === "dropped").map((d) => `${WALL_DROPPED}: ${d.file}:${d.line}: ${d.reason}`)))];
|
|
63719
63727
|
}
|
|
63720
63728
|
var WALL_COMPILE_REASON = "wall test did not compile under the package config", ANSI2, WALL_DROPPED = "Wall assertion dropped (harness-owned conflict persisted after one re-author)";
|
|
63721
63729
|
var init_wall_owned = __esm(() => {
|
|
@@ -65310,27 +65318,102 @@ var init_select = __esm(() => {
|
|
|
65310
65318
|
RANK_LABELS = ["wallPasses", "deterministicFails", "passesInS", "flakyInS", "lintFails", "diffLines", "index"];
|
|
65311
65319
|
});
|
|
65312
65320
|
|
|
65321
|
+
// ../../loki-ts/src/features/dependents.ts
|
|
65322
|
+
import { readFileSync as readFileSync73 } from "fs";
|
|
65323
|
+
import { dirname as dirname33, join as join82, normalize as normalize5 } from "path";
|
|
65324
|
+
function importTargets(rel, text3) {
|
|
65325
|
+
const out3 = [], dir = dirname33(rel);
|
|
65326
|
+
if (JS2.test(rel))
|
|
65327
|
+
for (const m of text3.matchAll(JS_SPEC_RE)) {
|
|
65328
|
+
const spec = m[1] ?? "";
|
|
65329
|
+
if (!spec.startsWith("."))
|
|
65330
|
+
continue;
|
|
65331
|
+
const p = posix3(join82(dir, spec)), stem = p.replace(/\.[cm]?[jt]sx?$/, "");
|
|
65332
|
+
out3.push(p, ...JS_EXT2.flatMap((e10) => [stem + e10, `${p}/index${e10}`]));
|
|
65333
|
+
}
|
|
65334
|
+
else if (PY3.test(rel)) {
|
|
65335
|
+
const add3 = (dots, mod, names) => {
|
|
65336
|
+
const up2 = dots > 0 ? join82(dir, ...Array(dots - 1).fill("..")) : "", roots = dots > 0 ? [up2] : [".", dir], path = mod.split(".").filter(Boolean).join("/");
|
|
65337
|
+
for (const r of roots) {
|
|
65338
|
+
const b = join82(r, path);
|
|
65339
|
+
if (path)
|
|
65340
|
+
out3.push(...pyMod(posix3(b)).map(posix3));
|
|
65341
|
+
for (const n10 of names)
|
|
65342
|
+
out3.push(...pyMod(posix3(join82(b, n10))));
|
|
65343
|
+
}
|
|
65344
|
+
};
|
|
65345
|
+
for (const m of text3.matchAll(PY_FROM)) {
|
|
65346
|
+
const dots = /^\.*/.exec(m[1])[0].length;
|
|
65347
|
+
add3(dots, m[1].slice(dots), m[2].replace(/[()]/g, "").split(",").map((s) => s.trim().split(/\s+as\s+/)[0]).filter((s) => /^\w+$/.test(s)));
|
|
65348
|
+
}
|
|
65349
|
+
for (const m of text3.matchAll(PY_IMP))
|
|
65350
|
+
for (const part of m[1].split(","))
|
|
65351
|
+
add3(0, part.trim().split(/\s+as\s+/)[0], []);
|
|
65352
|
+
}
|
|
65353
|
+
return out3;
|
|
65354
|
+
}
|
|
65355
|
+
function dependentTests(repoDir, map, changed, already) {
|
|
65356
|
+
const chg = new Set(changed.map(posix3).filter((f) => JS2.test(f) || PY3.test(f))), none = { tests: [], dropped: 0, truncated: false };
|
|
65357
|
+
if (chg.size === 0)
|
|
65358
|
+
return none;
|
|
65359
|
+
const isTest = new Set(map.tests.map((t) => t.path)), have = new Set(already.map((t) => t.path)), t02 = Date.now();
|
|
65360
|
+
let bytes = 0, truncated = false;
|
|
65361
|
+
const deps = new Set;
|
|
65362
|
+
for (const rel of listProjectFiles(repoDir)) {
|
|
65363
|
+
if (!(JS2.test(rel) || PY3.test(rel)) || isTest.has(rel) || chg.has(rel))
|
|
65364
|
+
continue;
|
|
65365
|
+
if (bytes > SCAN_MAX_BYTES || Date.now() - t02 > SCAN_MAX_MS) {
|
|
65366
|
+
truncated = true;
|
|
65367
|
+
break;
|
|
65368
|
+
}
|
|
65369
|
+
const text3 = read2(repoDir, rel);
|
|
65370
|
+
bytes += text3.length;
|
|
65371
|
+
if (importsAny(text3, rel, chg))
|
|
65372
|
+
deps.add(rel);
|
|
65373
|
+
}
|
|
65374
|
+
if (deps.size === 0)
|
|
65375
|
+
return { ...none, truncated };
|
|
65376
|
+
const all = map.tests.filter((t) => !have.has(t.path) && importsAny(read2(repoDir, t.path), t.path, deps)).sort((a, b) => a.path.localeCompare(b.path));
|
|
65377
|
+
return { tests: all.slice(0, MAX_DEPENDENT_TESTS), dropped: Math.max(0, all.length - MAX_DEPENDENT_TESTS), truncated };
|
|
65378
|
+
}
|
|
65379
|
+
var MAX_DEPENDENT_TESTS = 20, SCAN_MAX_BYTES = 48000000, SCAN_MAX_MS = 4000, FILE_MAX_BYTES = 256000, JS2, PY3, JS_EXT2, PY_FROM, PY_IMP, posix3 = (p) => normalize5(p).split("\\").join("/").replace(/^\.\//, ""), pyMod = (base) => [`${base}.py`, `${base}/__init__.py`], read2 = (repoDir, rel) => {
|
|
65380
|
+
try {
|
|
65381
|
+
return readFileSync73(join82(repoDir, rel), "utf8").slice(0, FILE_MAX_BYTES);
|
|
65382
|
+
} catch {
|
|
65383
|
+
return "";
|
|
65384
|
+
}
|
|
65385
|
+
}, importsAny = (text3, rel, set) => importTargets(rel, text3).some((t) => set.has(t)), dependentNotes = (d) => [...d.truncated ? ["reverse-dependent scan hit its byte or time bound: some importers of changed files may not have been tested"] : [], ...d.dropped ? [`reverse-dependent tests dropped by the ${MAX_DEPENDENT_TESTS}-file cap: ${d.dropped}`] : []];
|
|
65386
|
+
var init_dependents = __esm(() => {
|
|
65387
|
+
init_safe_git();
|
|
65388
|
+
init_test_file_text();
|
|
65389
|
+
JS2 = /\.(?:[cm]?[jt]sx?)$/;
|
|
65390
|
+
PY3 = /\.py$/;
|
|
65391
|
+
JS_EXT2 = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
|
|
65392
|
+
PY_FROM = /^[ \t]*from[ \t]+(\.*[\w.]*)[ \t]+import[ \t]+(\([^)]*\)|[^\n#]+)/gm;
|
|
65393
|
+
PY_IMP = /^[ \t]*import[ \t]+([\w., \t]+)/gm;
|
|
65394
|
+
});
|
|
65395
|
+
|
|
65313
65396
|
// ../../loki-ts/src/util/app_probe.ts
|
|
65314
65397
|
import { spawnSync as spawnSync9 } from "child_process";
|
|
65315
|
-
import { existsSync as existsSync56, mkdirSync as mkdirSync40, readFileSync as
|
|
65316
|
-
import { join as
|
|
65398
|
+
import { existsSync as existsSync56, mkdirSync as mkdirSync40, readFileSync as readFileSync74, renameSync as renameSync18, writeFileSync as writeFileSync38 } from "fs";
|
|
65399
|
+
import { join as join83 } from "path";
|
|
65317
65400
|
function readJson5(p) {
|
|
65318
65401
|
try {
|
|
65319
|
-
const v3 = JSON.parse(
|
|
65402
|
+
const v3 = JSON.parse(readFileSync74(p, "utf8"));
|
|
65320
65403
|
return v3 && typeof v3 === "object" ? v3 : null;
|
|
65321
65404
|
} catch {
|
|
65322
65405
|
return null;
|
|
65323
65406
|
}
|
|
65324
65407
|
}
|
|
65325
65408
|
function stopApp(repoDir, opts = {}) {
|
|
65326
|
-
const runner = opts.runnerPath ??
|
|
65327
|
-
if (!existsSync56(runner) || !existsSync56(
|
|
65409
|
+
const runner = opts.runnerPath ?? join83(REPO_ROOT, "autonomy", "app-runner.sh");
|
|
65410
|
+
if (!existsSync56(runner) || !existsSync56(join83(repoDir, ".loki", "app-runner", "app.pid")))
|
|
65328
65411
|
return;
|
|
65329
65412
|
spawnSync9("bash", ["-c", STOP, "app-probe", repoDir, runner], { cwd: repoDir, env: plainTestEnv(), timeout: opts.timeoutMs ?? 60000, killSignal: "SIGKILL", stdio: "ignore" });
|
|
65330
65413
|
}
|
|
65331
65414
|
async function appProbe(repoDir, lokiDir2, opts = {}) {
|
|
65332
|
-
const timeoutMs = opts.timeoutMs ?? 60000, runner = opts.runnerPath ??
|
|
65333
|
-
const dir =
|
|
65415
|
+
const timeoutMs = opts.timeoutMs ?? 60000, runner = opts.runnerPath ?? join83(REPO_ROOT, "autonomy", "app-runner.sh");
|
|
65416
|
+
const dir = join83(repoDir, ".loki", "app-runner"), checks = [];
|
|
65334
65417
|
const t02 = Date.now();
|
|
65335
65418
|
const mk3 = (name, result, reason) => ({ name, cmd: "autonomy/app-runner.sh", result, duration_s: (Date.now() - t02) / 1000, reason });
|
|
65336
65419
|
const sh3 = (script) => {
|
|
@@ -65348,9 +65431,9 @@ async function appProbe(repoDir, lokiDir2, opts = {}) {
|
|
|
65348
65431
|
return { checks, pid, url };
|
|
65349
65432
|
}
|
|
65350
65433
|
const ir2 = Number(m[1]), sr2 = Number(m[2]), hr = Number(m[3]), noApp = m[4] === "1";
|
|
65351
|
-
const pidTxt = existsSync56(
|
|
65434
|
+
const pidTxt = existsSync56(join83(dir, "app.pid")) ? readFileSync74(join83(dir, "app.pid"), "utf8").trim() : "";
|
|
65352
65435
|
pid = /^\d+$/.test(pidTxt) && sr2 >= 0 ? Number(pidTxt) : null;
|
|
65353
|
-
const st2 = readJson5(
|
|
65436
|
+
const st2 = readJson5(join83(dir, "state.json"));
|
|
65354
65437
|
url = typeof st2?.["url"] === "string" ? st2["url"] : null;
|
|
65355
65438
|
if (sr2 < 0) {
|
|
65356
65439
|
checks.push(noApp ? mk3("app boot", "n/a", "app-runner detected no app") : mk3("app boot", "not_run", ir2 === 0 ? "app-runner detected no app" : "no runnable app detected or runtime missing"), mk3("http probe", noApp ? "n/a" : "not_run", "app not booted"));
|
|
@@ -65361,7 +65444,7 @@ async function appProbe(repoDir, lokiDir2, opts = {}) {
|
|
|
65361
65444
|
return { checks, pid, url };
|
|
65362
65445
|
}
|
|
65363
65446
|
checks.push(mk3("app boot", "pass", "app process started"));
|
|
65364
|
-
const health = readJson5(
|
|
65447
|
+
const health = readJson5(join83(dir, "health.json"));
|
|
65365
65448
|
checks.push(hr === 0 && health?.["ok"] === true ? mk3("http probe", "pass", "health.json ok") : mk3("http probe", "fail", "app-runner health check failed"));
|
|
65366
65449
|
if (opts.specText !== undefined && checks[1]?.result === "pass" && url)
|
|
65367
65450
|
checks.push(await functionalVerify(opts, url, dir, lokiDir2, timeoutMs));
|
|
@@ -65374,10 +65457,10 @@ async function appProbe(repoDir, lokiDir2, opts = {}) {
|
|
|
65374
65457
|
async function functionalVerify(opts, url, dir, lokiDir2, timeoutMs) {
|
|
65375
65458
|
const t02 = Date.now();
|
|
65376
65459
|
const res = (result, reason) => ({ name: "functional verify", cmd: "autonomy/lib/functional-verify.py", result, duration_s: (Date.now() - t02) / 1000, reason });
|
|
65377
|
-
const py2 = await findPython3(), script = opts.verifyPath ??
|
|
65460
|
+
const py2 = await findPython3(), script = opts.verifyPath ?? join83(REPO_ROOT, "autonomy", "lib", "functional-verify.py");
|
|
65378
65461
|
if (!py2 || !existsSync56(script))
|
|
65379
65462
|
return res("not_run", "python3 or functional-verify.py unavailable");
|
|
65380
|
-
const specFile =
|
|
65463
|
+
const specFile = join83(dir, "spec.txt");
|
|
65381
65464
|
writeFileSync38(specFile, opts.specText ?? "");
|
|
65382
65465
|
const r = spawnSync9(py2, ["-I", script, specFile, url], { env: plainTestEnv(), encoding: "utf8", timeout: timeoutMs, killSignal: "SIGKILL", stdio: ["ignore", "pipe", "ignore"] });
|
|
65383
65466
|
let out3 = null;
|
|
@@ -65389,11 +65472,11 @@ async function functionalVerify(opts, url, dir, lokiDir2, timeoutMs) {
|
|
|
65389
65472
|
}
|
|
65390
65473
|
if (!out3 || r.status !== 0)
|
|
65391
65474
|
return res("not_run", "functional harness produced no result");
|
|
65392
|
-
const q10 =
|
|
65475
|
+
const q10 = join83(lokiDir2, "quality");
|
|
65393
65476
|
mkdirSync40(q10, { recursive: true });
|
|
65394
|
-
const tmp =
|
|
65477
|
+
const tmp = join83(q10, `functional-results.json.tmp.${process.pid}`);
|
|
65395
65478
|
writeFileSync38(tmp, JSON.stringify(out3, null, 2));
|
|
65396
|
-
renameSync18(tmp,
|
|
65479
|
+
renameSync18(tmp, join83(q10, "functional-results.json"));
|
|
65397
65480
|
const s = String(out3["functional_status"] ?? "inconclusive");
|
|
65398
65481
|
return res(s === "verified" ? "pass" : s === "failed" ? "fail" : "not_run", `functional_status ${s}`);
|
|
65399
65482
|
}
|
|
@@ -65425,15 +65508,15 @@ app_runner_stop >/dev/null 2>&1
|
|
|
65425
65508
|
});
|
|
65426
65509
|
|
|
65427
65510
|
// ../../loki-ts/src/util/secure_scan.ts
|
|
65428
|
-
import { copyFileSync as copyFileSync5, existsSync as existsSync57, lstatSync as lstatSync23, mkdirSync as mkdirSync41, mkdtempSync as mkdtempSync9, readFileSync as
|
|
65511
|
+
import { copyFileSync as copyFileSync5, existsSync as existsSync57, lstatSync as lstatSync23, mkdirSync as mkdirSync41, mkdtempSync as mkdtempSync9, readFileSync as readFileSync75, realpathSync as realpathSync26, rmSync as rmSync21, statSync as statSync25, writeFileSync as writeFileSync39 } from "fs";
|
|
65429
65512
|
import { randomBytes as randomBytes6 } from "crypto";
|
|
65430
65513
|
import { tmpdir as tmpdir12 } from "os";
|
|
65431
|
-
import { basename as basename22, dirname as
|
|
65514
|
+
import { basename as basename22, dirname as dirname34, join as join84, resolve as resolve28, sep as sep17 } from "path";
|
|
65432
65515
|
function fail(error) {
|
|
65433
65516
|
return { ok: false, findings: [], error };
|
|
65434
65517
|
}
|
|
65435
65518
|
async function runSecureScan(targetDir, opts = {}) {
|
|
65436
|
-
const script = opts.scriptPath ??
|
|
65519
|
+
const script = opts.scriptPath ?? join84(REPO_ROOT, "autonomy", "lib", "secure-scan.py");
|
|
65437
65520
|
if (!existsSync57(script))
|
|
65438
65521
|
return fail(`secure-scan script not found: ${script}`);
|
|
65439
65522
|
const py2 = await findPython3();
|
|
@@ -65477,12 +65560,12 @@ async function runSecureScan(targetDir, opts = {}) {
|
|
|
65477
65560
|
return fail(`secure-scan failed (exit ${res.exitCode}): ${tail2}`);
|
|
65478
65561
|
}
|
|
65479
65562
|
async function secureScanChanged(repoDir, changed, scriptPath) {
|
|
65480
|
-
const dir = mkdtempSync9(
|
|
65563
|
+
const dir = mkdtempSync9(join84(tmpdir12(), "loki-deep-secure-"));
|
|
65481
65564
|
try {
|
|
65482
65565
|
for (const f of changed)
|
|
65483
|
-
if (existsSync57(
|
|
65484
|
-
mkdirSync41(
|
|
65485
|
-
copyFileSync5(
|
|
65566
|
+
if (existsSync57(join84(repoDir, f)) && lstatSync23(join84(repoDir, f)).isFile()) {
|
|
65567
|
+
mkdirSync41(dirname34(join84(dir, f)), { recursive: true });
|
|
65568
|
+
copyFileSync5(join84(repoDir, f), join84(dir, f));
|
|
65486
65569
|
}
|
|
65487
65570
|
return await runSecureScan(dir, { ...scriptPath ? { scriptPath } : {}, timeoutMs: 60000 });
|
|
65488
65571
|
} finally {
|
|
@@ -65616,7 +65699,7 @@ async function scanAddedLines(repoDir, opts = {}) {
|
|
|
65616
65699
|
const skipped2 = [];
|
|
65617
65700
|
for (const p of untracked2.split("\x00").filter(Boolean)) {
|
|
65618
65701
|
try {
|
|
65619
|
-
const st2 = statSync25(
|
|
65702
|
+
const st2 = statSync25(join84(repoDir, p));
|
|
65620
65703
|
if (!st2.isFile())
|
|
65621
65704
|
continue;
|
|
65622
65705
|
if (st2.size > MAX_ADDED_FILE_BYTES) {
|
|
@@ -65631,14 +65714,14 @@ async function scanAddedLines(repoDir, opts = {}) {
|
|
|
65631
65714
|
continue;
|
|
65632
65715
|
}
|
|
65633
65716
|
const lines2 = new Map;
|
|
65634
|
-
|
|
65717
|
+
readFileSync75(join84(repoDir, p), "utf8").split(`
|
|
65635
65718
|
`).forEach((t, i) => lines2.set(i + 1, t));
|
|
65636
65719
|
added.set(p, lines2);
|
|
65637
65720
|
} catch {}
|
|
65638
65721
|
}
|
|
65639
65722
|
if (added.size === 0)
|
|
65640
65723
|
return { ok: true, findings: skipped2 };
|
|
65641
|
-
const mirror = mkdtempSync9(
|
|
65724
|
+
const mirror = mkdtempSync9(join84(tmpdir12(), "loki-secure-added-"));
|
|
65642
65725
|
try {
|
|
65643
65726
|
const root = resolve28(mirror) + sep17;
|
|
65644
65727
|
const chunkMap = new Map;
|
|
@@ -65684,12 +65767,12 @@ async function scanAddedLines(repoDir, opts = {}) {
|
|
|
65684
65767
|
chunks.push(cur);
|
|
65685
65768
|
const whole = chunks.length === 1;
|
|
65686
65769
|
for (const c of chunks) {
|
|
65687
|
-
const rel = whole ? p :
|
|
65770
|
+
const rel = whole ? p : join84(chunkRoot, String(chunkSeq++), basename22(p));
|
|
65688
65771
|
const out3 = whole ? dest : resolve28(mirror, rel);
|
|
65689
65772
|
if (!out3.startsWith(root))
|
|
65690
65773
|
break;
|
|
65691
65774
|
chunkMap.set(rel, { file: p, lines: c.orig });
|
|
65692
|
-
mkdirSync41(
|
|
65775
|
+
mkdirSync41(dirname34(out3), { recursive: true });
|
|
65693
65776
|
writeFileSync39(out3, c.body.join(`
|
|
65694
65777
|
`) + `
|
|
65695
65778
|
`);
|
|
@@ -65736,14 +65819,14 @@ var init_secure_scan = __esm(() => {
|
|
|
65736
65819
|
});
|
|
65737
65820
|
|
|
65738
65821
|
// ../../loki-ts/src/util/run_control.ts
|
|
65739
|
-
import { existsSync as existsSync58, readFileSync as
|
|
65740
|
-
import { join as
|
|
65822
|
+
import { existsSync as existsSync58, readFileSync as readFileSync76, renameSync as renameSync19, writeFileSync as writeFileSync40 } from "fs";
|
|
65823
|
+
import { join as join85 } from "path";
|
|
65741
65824
|
function readRunControl(runDir) {
|
|
65742
|
-
const p =
|
|
65825
|
+
const p = join85(runDir, RUN_CONTROL_FILE);
|
|
65743
65826
|
if (!existsSync58(p))
|
|
65744
65827
|
return null;
|
|
65745
65828
|
try {
|
|
65746
|
-
const a = JSON.parse(
|
|
65829
|
+
const a = JSON.parse(readFileSync76(p, "utf8")).action;
|
|
65747
65830
|
return typeof a === "string" && ACTIONS2.has(a) ? a : null;
|
|
65748
65831
|
} catch {
|
|
65749
65832
|
return null;
|
|
@@ -65801,8 +65884,8 @@ var init_run_control = __esm(() => {
|
|
|
65801
65884
|
});
|
|
65802
65885
|
|
|
65803
65886
|
// ../../loki-ts/src/project_model/conventions.ts
|
|
65804
|
-
import { existsSync as existsSync59, readdirSync as readdirSync27, readFileSync as
|
|
65805
|
-
import { basename as basename23, dirname as
|
|
65887
|
+
import { existsSync as existsSync59, readdirSync as readdirSync27, readFileSync as readFileSync77 } from "fs";
|
|
65888
|
+
import { basename as basename23, dirname as dirname35, isAbsolute as isAbsolute15, join as join86, relative as relative16, resolve as resolve29 } from "path";
|
|
65806
65889
|
function parseJsonc(text3) {
|
|
65807
65890
|
let out3 = "", i = 0;
|
|
65808
65891
|
while (i < text3.length) {
|
|
@@ -65837,7 +65920,7 @@ function moduleOf(file, depth = 0) {
|
|
|
65837
65920
|
const ext = typeof j10.extends === "string" ? j10.extends : null;
|
|
65838
65921
|
if (!ext || !ext.startsWith("."))
|
|
65839
65922
|
return null;
|
|
65840
|
-
const next =
|
|
65923
|
+
const next = join86(dirname35(file), ext.endsWith(".json") ? ext : `${ext}.json`);
|
|
65841
65924
|
return existsSync59(next) ? moduleOf(next, depth + 1) : null;
|
|
65842
65925
|
}
|
|
65843
65926
|
function readPackageConventions(pkgDir, runner = null) {
|
|
@@ -65849,13 +65932,13 @@ function readPackageConventions(pkgDir, runner = null) {
|
|
|
65849
65932
|
}
|
|
65850
65933
|
let packageType = null, tsModule = null;
|
|
65851
65934
|
for (const n10 of names) {
|
|
65852
|
-
const j10 = readJson6(
|
|
65935
|
+
const j10 = readJson6(join86(pkgDir, n10));
|
|
65853
65936
|
if (!j10)
|
|
65854
65937
|
continue;
|
|
65855
65938
|
if (packageType === null && typeof j10.type === "string" && typeof j10.name === "string")
|
|
65856
65939
|
packageType = j10.type;
|
|
65857
65940
|
if (tsModule === null && j10.compilerOptions !== undefined)
|
|
65858
|
-
tsModule = moduleOf(
|
|
65941
|
+
tsModule = moduleOf(join86(pkgDir, n10));
|
|
65859
65942
|
}
|
|
65860
65943
|
if (packageType === null && tsModule === null)
|
|
65861
65944
|
return null;
|
|
@@ -65961,13 +66044,13 @@ function vacuousCheck(fileName, content) {
|
|
|
65961
66044
|
function nearestPackageRoot(testDir, repoDir, fileName) {
|
|
65962
66045
|
const api = loadProjectApi(repoDir);
|
|
65963
66046
|
if (api)
|
|
65964
|
-
return siteFor(api, repoDir, relative16(repoDir,
|
|
66047
|
+
return siteFor(api, repoDir, relative16(repoDir, join86(testDir, fileName)))?.cwd ?? repoDir;
|
|
65965
66048
|
const shaped = (d) => {
|
|
65966
66049
|
try {
|
|
65967
66050
|
return readdirSync27(d).some((f) => {
|
|
65968
66051
|
if (!f.endsWith(".json"))
|
|
65969
66052
|
return false;
|
|
65970
|
-
const j10 = readJson6(
|
|
66053
|
+
const j10 = readJson6(join86(d, f));
|
|
65971
66054
|
return !!j10 && typeof j10.name === "string" && Object.keys(j10).length > 1;
|
|
65972
66055
|
});
|
|
65973
66056
|
} catch {
|
|
@@ -65975,8 +66058,8 @@ function nearestPackageRoot(testDir, repoDir, fileName) {
|
|
|
65975
66058
|
}
|
|
65976
66059
|
};
|
|
65977
66060
|
let pkg = testDir;
|
|
65978
|
-
while (pkg !== repoDir && pkg !==
|
|
65979
|
-
pkg =
|
|
66061
|
+
while (pkg !== repoDir && pkg !== dirname35(pkg) && !shaped(pkg))
|
|
66062
|
+
pkg = dirname35(pkg);
|
|
65980
66063
|
return pkg;
|
|
65981
66064
|
}
|
|
65982
66065
|
function phantomRepoPaths(content, fileName, testDir, repoDir, planText) {
|
|
@@ -66028,7 +66111,7 @@ function phantomRepoPaths(content, fileName, testDir, repoDir, planText) {
|
|
|
66028
66111
|
};
|
|
66029
66112
|
const strayInTestDir = (out3) => {
|
|
66030
66113
|
const first = relative16(testDir, out3).split("/")[0];
|
|
66031
|
-
return !!first && first !== "__self__" && !existsSync59(
|
|
66114
|
+
return !!first && first !== "__self__" && !existsSync59(join86(testDir, first)) && [pkg, repoDir].some((d) => d !== testDir && existsSync59(join86(d, first)));
|
|
66032
66115
|
};
|
|
66033
66116
|
const scan = (cwd) => {
|
|
66034
66117
|
const vars = new Map, walk = new Set, taint = new Set, reports = new Map, created = [];
|
|
@@ -66043,7 +66126,7 @@ function phantomRepoPaths(content, fileName, testDir, repoDir, planText) {
|
|
|
66043
66126
|
if (env)
|
|
66044
66127
|
return ev2(env[1], report);
|
|
66045
66128
|
if (e10 === "fileURLToPath(import.meta.url)" || e10 === "__filename")
|
|
66046
|
-
return
|
|
66129
|
+
return join86(testDir, "__self__");
|
|
66047
66130
|
const url = /^fileURLToPath\(new URL\((["'])([^"']*)\1\s*,\s*import\.meta\.url\)\)$/.exec(e10);
|
|
66048
66131
|
if (url)
|
|
66049
66132
|
return resolve29(testDir, url[2]);
|
|
@@ -66059,11 +66142,11 @@ function phantomRepoPaths(content, fileName, testDir, repoDir, planText) {
|
|
|
66059
66142
|
if (args.some((a) => a === null))
|
|
66060
66143
|
return null;
|
|
66061
66144
|
if (call[1] === "dirname")
|
|
66062
|
-
return
|
|
66145
|
+
return dirname35(args[0]);
|
|
66063
66146
|
const out3 = resolve29(...args);
|
|
66064
|
-
const first = parts.slice(1).map((a) => /^\s*["'`]([^"'`]*)["'`]\s*$/.exec(a)?.[1]).find((x3) => x3), viaWalk = !!first && walk.has(parts[0].trim()) && [pkg, repoDir].some((d) => existsSync59(
|
|
66147
|
+
const first = parts.slice(1).map((a) => /^\s*["'`]([^"'`]*)["'`]\s*$/.exec(a)?.[1]).find((x3) => x3), viaWalk = !!first && walk.has(parts[0].trim()) && [pkg, repoDir].some((d) => existsSync59(join86(d, first.split("/").filter(Boolean)[0] ?? "\x00")));
|
|
66065
66148
|
if (report && (viaWalk || !parts.some((a) => walk.has(a.trim()) || taint.has(a.trim())) && (relative16(testDir, out3).startsWith("..") || strayInTestDir(out3))) && parts.some((a) => /^\s*["'`]/.test(a)))
|
|
66066
|
-
reports.set(`${ln2}|${e10}`, { out: out3, rel: relative16(repoDir, out3), tail: viaWalk ?
|
|
66149
|
+
reports.set(`${ln2}|${e10}`, { out: out3, rel: relative16(repoDir, out3), tail: viaWalk ? join86(...args.slice(1)) : undefined });
|
|
66067
66150
|
return out3;
|
|
66068
66151
|
};
|
|
66069
66152
|
for (const line2 of walkCode.split(`
|
|
@@ -66111,7 +66194,7 @@ function phantomRepoPaths(content, fileName, testDir, repoDir, planText) {
|
|
|
66111
66194
|
const runs2 = [...new Set([pkg, repoDir])].map(scan);
|
|
66112
66195
|
const planned = (rel) => !!planText && rel.split("/").some((_, i, a) => {
|
|
66113
66196
|
const pre2 = a.slice(0, i + 1).join("/");
|
|
66114
|
-
return (i > 0 || a.length === 1) && !existsSync59(
|
|
66197
|
+
return (i > 0 || a.length === 1) && !existsSync59(join86(repoDir, pre2)) && new RegExp(`(?<![\\w-])${pre2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?![\\w-])`).test(planText);
|
|
66115
66198
|
});
|
|
66116
66199
|
const phantom = (r, created) => {
|
|
66117
66200
|
const rel = r.rel;
|
|
@@ -66121,11 +66204,11 @@ function phantomRepoPaths(content, fileName, testDir, repoDir, planText) {
|
|
|
66121
66204
|
const seen = (from) => {
|
|
66122
66205
|
let d = from;
|
|
66123
66206
|
for (let i = 0;i < 64; i++) {
|
|
66124
|
-
if (existsSync59(
|
|
66207
|
+
if (existsSync59(join86(d, r.tail)))
|
|
66125
66208
|
return true;
|
|
66126
|
-
if (d === repoDir || d ===
|
|
66209
|
+
if (d === repoDir || d === dirname35(d))
|
|
66127
66210
|
return false;
|
|
66128
|
-
d =
|
|
66211
|
+
d = dirname35(d);
|
|
66129
66212
|
}
|
|
66130
66213
|
return false;
|
|
66131
66214
|
};
|
|
@@ -66163,7 +66246,7 @@ function phantomReason(miss, repoFiles, testDir = "", pkgRoot = "") {
|
|
|
66163
66246
|
}
|
|
66164
66247
|
var readJson6 = (p) => {
|
|
66165
66248
|
try {
|
|
66166
|
-
const v3 = parseJsonc(
|
|
66249
|
+
const v3 = parseJsonc(readFileSync77(p, "utf8"));
|
|
66167
66250
|
return v3 && typeof v3 === "object" && !Array.isArray(v3) ? v3 : null;
|
|
66168
66251
|
} catch {
|
|
66169
66252
|
return null;
|
|
@@ -66172,8 +66255,8 @@ var readJson6 = (p) => {
|
|
|
66172
66255
|
${bad.map((b) => `- ${b.name}: ${b.why}`).join(`
|
|
66173
66256
|
`)}`, `Point every reference at the repository code with repo-relative paths (for example join(import.meta.dir, "..", "<repo path>") or the equivalent for this runner). Do not read the home directory, $HOME or an environment variable that falls back to one. Write nothing else.`].join(`
|
|
66174
66257
|
|
|
66175
|
-
`), outOfRepoTests = (repoDir, changed) => changed.filter((f) => /(^|[\/._-])(test|spec)s?[\/._-]|_test\./i.test(f) && existsSync59(
|
|
66176
|
-
const why = outOfRepoTarget(
|
|
66258
|
+
`), outOfRepoTests = (repoDir, changed) => changed.filter((f) => /(^|[\/._-])(test|spec)s?[\/._-]|_test\./i.test(f) && existsSync59(join86(repoDir, f))).flatMap((name) => {
|
|
66259
|
+
const why = outOfRepoTarget(readFileSync77(join86(repoDir, name), "utf8"));
|
|
66177
66260
|
return why ? [{ name, why }] : [];
|
|
66178
66261
|
}), CREATORS;
|
|
66179
66262
|
var init_conventions = __esm(() => {
|
|
@@ -66183,16 +66266,16 @@ var init_conventions = __esm(() => {
|
|
|
66183
66266
|
});
|
|
66184
66267
|
|
|
66185
66268
|
// ../../loki-ts/src/util/pr_lessons.ts
|
|
66186
|
-
import { existsSync as existsSync60, mkdirSync as mkdirSync42, mkdtempSync as mkdtempSync10, readFileSync as
|
|
66269
|
+
import { existsSync as existsSync60, mkdirSync as mkdirSync42, mkdtempSync as mkdtempSync10, readFileSync as readFileSync78, rmSync as rmSync22, writeFileSync as writeFileSync41 } from "fs";
|
|
66187
66270
|
import { homedir as homedir10, tmpdir as tmpdir13 } from "os";
|
|
66188
|
-
import { dirname as
|
|
66271
|
+
import { dirname as dirname36, join as join87 } from "path";
|
|
66189
66272
|
import { createHash as createHash26 } from "crypto";
|
|
66190
66273
|
function loadLessons(repoDir) {
|
|
66191
66274
|
const p = lessonsPath(repoDir);
|
|
66192
66275
|
if (!existsSync60(p))
|
|
66193
66276
|
return [];
|
|
66194
66277
|
try {
|
|
66195
|
-
const j10 = JSON.parse(
|
|
66278
|
+
const j10 = JSON.parse(readFileSync78(p, "utf-8"));
|
|
66196
66279
|
return Array.isArray(j10.lessons) ? j10.lessons : [];
|
|
66197
66280
|
} catch {
|
|
66198
66281
|
return [];
|
|
@@ -66200,12 +66283,12 @@ function loadLessons(repoDir) {
|
|
|
66200
66283
|
}
|
|
66201
66284
|
function save3(repoDir, lessons) {
|
|
66202
66285
|
const p = lessonsPath(repoDir);
|
|
66203
|
-
mkdirSync42(
|
|
66286
|
+
mkdirSync42(dirname36(p), { recursive: true });
|
|
66204
66287
|
atomicWriteJson(p, { version: 2, lessons });
|
|
66205
66288
|
}
|
|
66206
66289
|
function loadPromoted() {
|
|
66207
66290
|
try {
|
|
66208
|
-
const j10 = JSON.parse(
|
|
66291
|
+
const j10 = JSON.parse(readFileSync78(promotedPath(), "utf-8"));
|
|
66209
66292
|
return Array.isArray(j10.lessons) ? j10.lessons : [];
|
|
66210
66293
|
} catch {
|
|
66211
66294
|
return [];
|
|
@@ -66316,7 +66399,7 @@ ${body}
|
|
|
66316
66399
|
function learningsBlock(repoDir, limit = 5) {
|
|
66317
66400
|
let items2 = [];
|
|
66318
66401
|
try {
|
|
66319
|
-
const parsed = JSON.parse(
|
|
66402
|
+
const parsed = JSON.parse(readFileSync78(join87(repoDir, ".loki", "state", "relevant-learnings.json"), "utf-8"));
|
|
66320
66403
|
if (Array.isArray(parsed.learnings))
|
|
66321
66404
|
items2 = parsed.learnings;
|
|
66322
66405
|
} catch {
|
|
@@ -66346,7 +66429,7 @@ ${lines2.join(`
|
|
|
66346
66429
|
</untrusted-learnings>
|
|
66347
66430
|
`;
|
|
66348
66431
|
}
|
|
66349
|
-
var lessonsPath = (repoDir) =>
|
|
66432
|
+
var lessonsPath = (repoDir) => join87(repoDir, ".loki", "memory", "semantic", "pr-lessons.json"), promotedPath = () => join87(process.env["LOKI_PROMOTED_DIR"] || join87(homedir10(), ".loki"), "memory", "semantic", "promoted-lessons.json"), DEMOTE_AFTER = 3, demoteOn = () => process.env["LOKI_PR_LESSON_DEMOTE"] !== "0", HEX642, KINDS, VERDICT_BASE, words = (s) => new Set(s.toLowerCase().match(/[a-z0-9_]{4,}/g) ?? []), fence = (s) => s.replace(/[<>]/g, "");
|
|
66350
66433
|
var init_pr_lessons = __esm(() => {
|
|
66351
66434
|
init_redact();
|
|
66352
66435
|
init_atomic();
|
|
@@ -66366,7 +66449,7 @@ import {
|
|
|
66366
66449
|
lstatSync as lstatSync24,
|
|
66367
66450
|
mkdirSync as mkdirSync43,
|
|
66368
66451
|
openSync as openSync13,
|
|
66369
|
-
readFileSync as
|
|
66452
|
+
readFileSync as readFileSync79,
|
|
66370
66453
|
readlinkSync as readlinkSync5,
|
|
66371
66454
|
realpathSync as realpathSync27,
|
|
66372
66455
|
rmSync as rmSync23,
|
|
@@ -66374,7 +66457,7 @@ import {
|
|
|
66374
66457
|
unlinkSync as unlinkSync8,
|
|
66375
66458
|
writeFileSync as writeFileSync42
|
|
66376
66459
|
} from "fs";
|
|
66377
|
-
import { dirname as
|
|
66460
|
+
import { dirname as dirname37, isAbsolute as isAbsolute16, join as join88, relative as relative17, resolve as resolve30, sep as sep18 } from "path";
|
|
66378
66461
|
function git8(root, args) {
|
|
66379
66462
|
return safeGit(root, args);
|
|
66380
66463
|
}
|
|
@@ -66414,7 +66497,7 @@ function safeJoin(root, relPath) {
|
|
|
66414
66497
|
const segment = segments[i];
|
|
66415
66498
|
if (segment === undefined)
|
|
66416
66499
|
continue;
|
|
66417
|
-
cur =
|
|
66500
|
+
cur = join88(cur, segment);
|
|
66418
66501
|
if (i < segments.length - 1) {
|
|
66419
66502
|
let st2;
|
|
66420
66503
|
try {
|
|
@@ -66431,7 +66514,7 @@ function safeJoin(root, relPath) {
|
|
|
66431
66514
|
function assertSymlinkWithinRoot(root, relPath, target) {
|
|
66432
66515
|
if (isAbsolute16(target))
|
|
66433
66516
|
throw new TreeSwapUnsafePathError(`symlink ${relPath} has an absolute target`);
|
|
66434
|
-
const resolvedTarget = resolve30(
|
|
66517
|
+
const resolvedTarget = resolve30(dirname37(join88(resolve30(root), relPath)), target);
|
|
66435
66518
|
const rel = relative17(resolve30(root), resolvedTarget);
|
|
66436
66519
|
if (rel === ".." || rel.startsWith(`..${"/"}`) || isAbsolute16(rel)) {
|
|
66437
66520
|
throw new TreeSwapUnsafePathError(`symlink ${relPath} escapes tree root`);
|
|
@@ -66450,7 +66533,7 @@ function readEntry(root, relPath) {
|
|
|
66450
66533
|
}
|
|
66451
66534
|
const fd2 = openSync13(abs, fsc.O_RDONLY | fsc.O_NOFOLLOW);
|
|
66452
66535
|
try {
|
|
66453
|
-
return { content:
|
|
66536
|
+
return { content: readFileSync79(fd2), mode: st2.mode & 511 };
|
|
66454
66537
|
} finally {
|
|
66455
66538
|
closeSync13(fd2);
|
|
66456
66539
|
}
|
|
@@ -66469,7 +66552,7 @@ function writeEntry(root, relPath, entry2) {
|
|
|
66469
66552
|
assertSymlinkWithinRoot(root, relPath, entry2.symlinkTarget);
|
|
66470
66553
|
}
|
|
66471
66554
|
const abs = safeJoin(root, relPath);
|
|
66472
|
-
mkdirSync43(
|
|
66555
|
+
mkdirSync43(dirname37(abs), { recursive: true });
|
|
66473
66556
|
removeEntry(root, relPath);
|
|
66474
66557
|
if (entry2.symlinkTarget !== undefined) {
|
|
66475
66558
|
symlinkSync4(entry2.symlinkTarget, abs);
|
|
@@ -66592,7 +66675,7 @@ function swapLocked(opts, excludes) {
|
|
|
66592
66675
|
pre2.push({ path, kind: "file", content: e10.content, mode: e10.mode, symlinkTarget: e10.symlinkTarget });
|
|
66593
66676
|
}
|
|
66594
66677
|
mkdirSync43(opts.runDir, { recursive: true });
|
|
66595
|
-
const undoPath =
|
|
66678
|
+
const undoPath = join88(opts.runDir, UNDO_FILE);
|
|
66596
66679
|
const enc = (l) => l.map((e10) => ({ ...e10, content: e10.content?.toString("base64") }));
|
|
66597
66680
|
let fd2;
|
|
66598
66681
|
try {
|
|
@@ -66632,7 +66715,7 @@ function removeLenient(root, relPath) {
|
|
|
66632
66715
|
}
|
|
66633
66716
|
}
|
|
66634
66717
|
function restoreFromUndo(primaryRoot, runDir, excludes = DEFAULT_EXCLUDES) {
|
|
66635
|
-
const rec2 = JSON.parse(
|
|
66718
|
+
const rec2 = JSON.parse(readFileSync79(join88(runDir, UNDO_FILE), "utf8"));
|
|
66636
66719
|
const dec = (l) => l.map((e10) => ({ ...e10, content: e10.content === undefined ? undefined : Buffer.from(e10.content, "base64") }));
|
|
66637
66720
|
const entries = dec(rec2.entries);
|
|
66638
66721
|
const errors2 = [];
|
|
@@ -66652,7 +66735,7 @@ function restoreFromUndo(primaryRoot, runDir, excludes = DEFAULT_EXCLUDES) {
|
|
|
66652
66735
|
throw new AggregateError(errors2, "treeswap: rollback incomplete");
|
|
66653
66736
|
}
|
|
66654
66737
|
function cleanupAttempt(primaryRoot, runDir, attemptDir) {
|
|
66655
|
-
const attemptsRoot =
|
|
66738
|
+
const attemptsRoot = join88(realpathSync27(resolve30(runDir)), "attempts");
|
|
66656
66739
|
let attemptsLst;
|
|
66657
66740
|
try {
|
|
66658
66741
|
attemptsLst = lstatSync24(attemptsRoot);
|
|
@@ -66669,17 +66752,17 @@ function cleanupAttempt(primaryRoot, runDir, attemptDir) {
|
|
|
66669
66752
|
if (isPrimaryOrAncestor(realpathSync27(attemptsRoot)))
|
|
66670
66753
|
throw new TreeSwapUnsafePathError(`attempts dir ${attemptsRoot} resolves to the primary tree`);
|
|
66671
66754
|
const lexical = resolve30(attemptDir);
|
|
66672
|
-
const parent =
|
|
66755
|
+
const parent = dirname37(lexical);
|
|
66673
66756
|
let real3;
|
|
66674
66757
|
try {
|
|
66675
|
-
real3 =
|
|
66758
|
+
real3 = join88(realpathSync27(parent), lexical.slice(parent.length + 1));
|
|
66676
66759
|
lstatSync24(real3);
|
|
66677
66760
|
} catch (err) {
|
|
66678
66761
|
if (err.code === "ENOENT")
|
|
66679
66762
|
return;
|
|
66680
66763
|
throw err;
|
|
66681
66764
|
}
|
|
66682
|
-
if (
|
|
66765
|
+
if (dirname37(real3) !== attemptsRoot)
|
|
66683
66766
|
throw new TreeSwapUnsafePathError(`${attemptDir} is not a direct child of ${attemptsRoot}`);
|
|
66684
66767
|
if (isPrimaryOrAncestor(real3))
|
|
66685
66768
|
throw new TreeSwapUnsafePathError(`${attemptDir} is or contains the primary tree`);
|
|
@@ -66690,7 +66773,7 @@ function cleanupAttempt(primaryRoot, runDir, attemptDir) {
|
|
|
66690
66773
|
throw new TreeSwapUnsafePathError(`${attemptDir} is not a directory`);
|
|
66691
66774
|
if (process.getuid && lst.uid !== process.getuid())
|
|
66692
66775
|
throw new TreeSwapUnsafePathError(`refusing to remove ${attemptDir}: not owned by the current user`);
|
|
66693
|
-
const gitFile =
|
|
66776
|
+
const gitFile = join88(real3, ".git");
|
|
66694
66777
|
let isLinkedWorktree = false;
|
|
66695
66778
|
try {
|
|
66696
66779
|
isLinkedWorktree = lstatSync24(gitFile).isFile();
|
|
@@ -66717,8 +66800,8 @@ var init_treeswap = __esm(() => {
|
|
|
66717
66800
|
});
|
|
66718
66801
|
|
|
66719
66802
|
// ../../loki-ts/src/features/attempts.ts
|
|
66720
|
-
import { existsSync as existsSync61, mkdirSync as mkdirSync44, readFileSync as
|
|
66721
|
-
import { join as
|
|
66803
|
+
import { existsSync as existsSync61, mkdirSync as mkdirSync44, readFileSync as readFileSync80 } from "fs";
|
|
66804
|
+
import { join as join89 } from "path";
|
|
66722
66805
|
function assertScrubbedEnv(env) {
|
|
66723
66806
|
for (const v3 of GITHUB_TOKEN_VARS) {
|
|
66724
66807
|
const val = env[v3] ?? "";
|
|
@@ -66769,19 +66852,19 @@ async function runTwoAttempts(ops, S, wall, signal, env = process.env) {
|
|
|
66769
66852
|
}
|
|
66770
66853
|
}
|
|
66771
66854
|
function treeswapOps(a) {
|
|
66772
|
-
const attemptsDir =
|
|
66855
|
+
const attemptsDir = join89(a.runDir, "attempts"), bDir = join89(attemptsDir, "B");
|
|
66773
66856
|
mkdirSync44(attemptsDir, { recursive: true });
|
|
66774
66857
|
safeGit(a.primary, ["worktree", "add", "--detach", bDir, a.base]);
|
|
66775
66858
|
const pre2 = new Set(untracked2(a.primary));
|
|
66776
66859
|
let snapA = null;
|
|
66777
66860
|
const wallWeakened = (root, isPrimary, p, touched) => {
|
|
66778
|
-
const sealed = a.wallContent?.get(p), f =
|
|
66861
|
+
const sealed = a.wallContent?.get(p), f = join89(root, p);
|
|
66779
66862
|
if (!existsSync61(f))
|
|
66780
66863
|
return isPrimary ? sealed !== undefined || touched.has(p) : false;
|
|
66781
66864
|
if (sealed === undefined)
|
|
66782
66865
|
return touched.has(p);
|
|
66783
66866
|
try {
|
|
66784
|
-
return
|
|
66867
|
+
return readFileSync80(f, "utf8") !== sealed;
|
|
66785
66868
|
} catch {
|
|
66786
66869
|
return true;
|
|
66787
66870
|
}
|
|
@@ -66859,8 +66942,8 @@ var init_attempts = __esm(() => {
|
|
|
66859
66942
|
});
|
|
66860
66943
|
|
|
66861
66944
|
// ../../loki-ts/src/runner/router/route_record.ts
|
|
66862
|
-
import { existsSync as existsSync62, lstatSync as lstatSync25, mkdirSync as mkdirSync45, readFileSync as
|
|
66863
|
-
import { join as
|
|
66945
|
+
import { existsSync as existsSync62, lstatSync as lstatSync25, mkdirSync as mkdirSync45, readFileSync as readFileSync81, writeFileSync as writeFileSync43 } from "fs";
|
|
66946
|
+
import { join as join90 } from "path";
|
|
66864
66947
|
function buildRouteRecord(i) {
|
|
66865
66948
|
const notProven = [...i.notProven, ...i.planModelNote ? [`plan model: NOT PROVEN (owner provider): ${i.planModelNote}`] : []];
|
|
66866
66949
|
const base = { plan_model: i.planModel, shape_key: i.shapeKey, route_not_proven: notProven, applied: PER_UNIT_EXECUTORS_APPLIED };
|
|
@@ -66881,16 +66964,16 @@ function buildRouteRecord(i) {
|
|
|
66881
66964
|
function writeRouteRecord(runDir, record) {
|
|
66882
66965
|
try {
|
|
66883
66966
|
mkdirSync45(runDir, { recursive: true });
|
|
66884
|
-
writeFileSync43(
|
|
66967
|
+
writeFileSync43(join90(runDir, ROUTE_RECORD_FILE), `${JSON.stringify(record, null, 2)}
|
|
66885
66968
|
`);
|
|
66886
66969
|
} catch {}
|
|
66887
66970
|
}
|
|
66888
66971
|
function loadRouteRecord(runDir) {
|
|
66889
66972
|
try {
|
|
66890
|
-
const p =
|
|
66973
|
+
const p = join90(runDir, ROUTE_RECORD_FILE);
|
|
66891
66974
|
if (!existsSync62(p) || !lstatSync25(p).isFile())
|
|
66892
66975
|
return;
|
|
66893
|
-
const v3 = JSON.parse(
|
|
66976
|
+
const v3 = JSON.parse(readFileSync81(p, "utf8"));
|
|
66894
66977
|
return typeof v3 === "object" && v3 !== null && !Array.isArray(v3) ? v3 : undefined;
|
|
66895
66978
|
} catch {
|
|
66896
66979
|
return;
|
|
@@ -66965,10 +67048,10 @@ __export(exports_plan, {
|
|
|
66965
67048
|
planStage: () => planStage,
|
|
66966
67049
|
buildPlanBrief: () => buildPlanBrief
|
|
66967
67050
|
});
|
|
66968
|
-
import { existsSync as existsSync63, mkdirSync as mkdirSync46, readFileSync as
|
|
66969
|
-
import { join as
|
|
67051
|
+
import { existsSync as existsSync63, mkdirSync as mkdirSync46, readFileSync as readFileSync82, writeFileSync as writeFileSync44 } from "fs";
|
|
67052
|
+
import { join as join91 } from "path";
|
|
66970
67053
|
function planOutputPath(runDir) {
|
|
66971
|
-
return
|
|
67054
|
+
return join91(runDir, PLAN_OUTPUT_FILENAME);
|
|
66972
67055
|
}
|
|
66973
67056
|
function truncatePlan(raw2, max = MAX_PLAN_LINES) {
|
|
66974
67057
|
const lines2 = raw2.split(`
|
|
@@ -67038,7 +67121,7 @@ var init_plan = __esm(() => {
|
|
|
67038
67121
|
const cardOn = intentCardEnabled(process.env);
|
|
67039
67122
|
const runPlan = (onSonnet) => ctx.sessions.run({
|
|
67040
67123
|
stage: "plan",
|
|
67041
|
-
brief: buildPlanBrief(task, relevantFiles, outputPath,
|
|
67124
|
+
brief: buildPlanBrief(task, relevantFiles, outputPath, join91(ctx.runDir, PLAN_SCOPE_FILE), pr2.routed, cardOn, mutationStrict(), reviewerBriefEnabled()),
|
|
67042
67125
|
tier: "fast",
|
|
67043
67126
|
iterationId,
|
|
67044
67127
|
limitS: planStage.limitS,
|
|
@@ -67057,11 +67140,11 @@ var init_plan = __esm(() => {
|
|
|
67057
67140
|
if (!session.killed && session.exit !== 0) {
|
|
67058
67141
|
pr2.record({ planModel, planModelNote, skipReason: `plan session failed (exit ${session.exit})` });
|
|
67059
67142
|
mkdirSync46(ctx.runDir, { recursive: true });
|
|
67060
|
-
const stderrPath =
|
|
67143
|
+
const stderrPath = join91(ctx.runDir, `${iterationId}.stderr.log`);
|
|
67061
67144
|
writeFileSync44(stderrPath, session.stderrTail ?? "", "utf8");
|
|
67062
67145
|
return { status: "failed", reason: classifyExitCause(session.exit, false), data: { iteration_ids: [iterationId], duration_s: session.durationS, stderr_path: stderrPath } };
|
|
67063
67146
|
}
|
|
67064
|
-
const rawPlan = existsSync63(outputPath) ?
|
|
67147
|
+
const rawPlan = existsSync63(outputPath) ? readFileSync82(outputPath, "utf8") : "";
|
|
67065
67148
|
const ic2 = await applyIntent(rawPlan, cardOn, ctx.runDir, (d) => ctx.emit("variant", "plan", d));
|
|
67066
67149
|
const plan = truncatePlan(ic2.rest);
|
|
67067
67150
|
const route_record = pr2.record({ planModel, planModelNote }), oor = planOutOfRepo(ctx.runDir);
|
|
@@ -67086,9 +67169,9 @@ var init_plan = __esm(() => {
|
|
|
67086
67169
|
|
|
67087
67170
|
// ../../loki-ts/src/util/conflict_resume.ts
|
|
67088
67171
|
import { createHash as createHash27 } from "crypto";
|
|
67089
|
-
import { existsSync as existsSync64, mkdtempSync as mkdtempSync11, readFileSync as
|
|
67172
|
+
import { existsSync as existsSync64, mkdtempSync as mkdtempSync11, readFileSync as readFileSync83, rmSync as rmSync24, writeFileSync as writeFileSync45 } from "fs";
|
|
67090
67173
|
import { tmpdir as tmpdir14 } from "os";
|
|
67091
|
-
import { basename as basename24, join as
|
|
67174
|
+
import { basename as basename24, join as join92, relative as relative18 } from "path";
|
|
67092
67175
|
async function resumeAfterConflict(ctx, first, firstSession) {
|
|
67093
67176
|
if ((ctx.implementLeftS?.() ?? Infinity) < RESUME_MIN_LEFT_S)
|
|
67094
67177
|
return { session: firstSession, iterationId: first.iterationId };
|
|
@@ -67112,9 +67195,9 @@ async function adjudicateWallConflict(ctx, first, firstSession, wall) {
|
|
|
67112
67195
|
const reason = firstSession.markers.specConflict, rels = wall.map((f10) => relative18(ctx.repoDir, f10.path)), a = reason ? wallAnchor(reason, rels) : null;
|
|
67113
67196
|
if (!reason || !a)
|
|
67114
67197
|
return null;
|
|
67115
|
-
const f = wall[rels.indexOf(a.file)], ids = [], o = ctx.outputs(), cwd = mkdtempSync11(
|
|
67198
|
+
const f = wall[rels.indexOf(a.file)], ids = [], o = ctx.outputs(), cwd = mkdtempSync11(join92(tmpdir14(), "loki-e15-wall-")), name = basename24(f.path);
|
|
67116
67199
|
try {
|
|
67117
|
-
writeFileSync45(
|
|
67200
|
+
writeFileSync45(join92(cwd, name), f.content, "utf8");
|
|
67118
67201
|
const id2 = `${first.iterationId}-wa`;
|
|
67119
67202
|
ids.push(id2);
|
|
67120
67203
|
const au2 = await ctx.sessions.run({
|
|
@@ -67134,7 +67217,7 @@ async function adjudicateWallConflict(ctx, first, firstSession, wall) {
|
|
|
67134
67217
|
|
|
67135
67218
|
`)
|
|
67136
67219
|
});
|
|
67137
|
-
const next = !au2.killed && au2.exit === 0 && existsSync64(
|
|
67220
|
+
const next = !au2.killed && au2.exit === 0 && existsSync64(join92(cwd, name)) ? readFileSync83(join92(cwd, name), "utf8") : "";
|
|
67138
67221
|
const rewritten = next.trim() !== "" && next !== f.content;
|
|
67139
67222
|
if (rewritten) {
|
|
67140
67223
|
f.content = next;
|
|
@@ -67229,8 +67312,8 @@ __export(exports_implement, {
|
|
|
67229
67312
|
briefCtx: () => briefCtx,
|
|
67230
67313
|
applyExternalPatch: () => applyExternalPatch
|
|
67231
67314
|
});
|
|
67232
|
-
import { existsSync as existsSync65, mkdirSync as mkdirSync47, readFileSync as
|
|
67233
|
-
import { join as
|
|
67315
|
+
import { existsSync as existsSync65, mkdirSync as mkdirSync47, readFileSync as readFileSync84, rmSync as rmSync25, writeFileSync as writeFileSync46 } from "fs";
|
|
67316
|
+
import { join as join93, relative as relative19 } from "path";
|
|
67234
67317
|
function impactedTests(ctx) {
|
|
67235
67318
|
const o = ctx.outputs();
|
|
67236
67319
|
const map = o.intake?.testmap;
|
|
@@ -67258,7 +67341,7 @@ ${plan}` : "No separate plan was made: plan the change yourself in this session,
|
|
|
67258
67341
|
function restoreReadOnly(files) {
|
|
67259
67342
|
const reverted = [];
|
|
67260
67343
|
for (const f of files) {
|
|
67261
|
-
const current = existsSync65(f.path) ?
|
|
67344
|
+
const current = existsSync65(f.path) ? readFileSync84(f.path, "utf8") : null;
|
|
67262
67345
|
if (current !== f.content) {
|
|
67263
67346
|
writeFileSync46(f.path, f.content, "utf8");
|
|
67264
67347
|
reverted.push(f.path);
|
|
@@ -67277,7 +67360,7 @@ function specFor(ctx) {
|
|
|
67277
67360
|
if (!process.env.LOKI_E10_SPEC_SHA256)
|
|
67278
67361
|
return null;
|
|
67279
67362
|
try {
|
|
67280
|
-
return loadSpecFile(
|
|
67363
|
+
return loadSpecFile(join93(ctx.runDir, "spec.snapshot.md"));
|
|
67281
67364
|
} catch {
|
|
67282
67365
|
return null;
|
|
67283
67366
|
}
|
|
@@ -67290,7 +67373,7 @@ function applyExternalPatch(ctx, patchPath) {
|
|
|
67290
67373
|
`)[0]}` };
|
|
67291
67374
|
}
|
|
67292
67375
|
const testsReverted = restoreReadOnly(ctx.outputs().wall?.readOnlyFiles ?? []);
|
|
67293
|
-
return { status: "completed", data: { exit: "external", external: true, patch_sha256: sha2562(
|
|
67376
|
+
return { status: "completed", data: { exit: "external", external: true, patch_sha256: sha2562(readFileSync84(patchPath, "utf8")), tests_reverted: testsReverted, impacted_tests: impactedTests(ctx), iteration_ids: [] } };
|
|
67294
67377
|
}
|
|
67295
67378
|
var briefCtx = (ctx) => briefContext(ctx, { select: selectRelevantFiles, cmd: (t, repoDir) => {
|
|
67296
67379
|
const c = commandFor(t, repoDir, loadProjectApi(repoDir));
|
|
@@ -67322,7 +67405,7 @@ var init_implement = __esm(() => {
|
|
|
67322
67405
|
targetS: 180,
|
|
67323
67406
|
limitS: 480,
|
|
67324
67407
|
async run(ctx, signal) {
|
|
67325
|
-
rmSync25(
|
|
67408
|
+
rmSync25(join93(ctx.repoDir, ".loki", "supply-declared.json"), { force: true });
|
|
67326
67409
|
if (ctx.externalPatch)
|
|
67327
67410
|
return applyExternalPatch(ctx, ctx.externalPatch);
|
|
67328
67411
|
const prior = ctx.outputs();
|
|
@@ -67451,7 +67534,7 @@ var init_implement = __esm(() => {
|
|
|
67451
67534
|
return { status: "completed", data };
|
|
67452
67535
|
const stderrTail = session.stderrTail ?? "";
|
|
67453
67536
|
mkdirSync47(ctx.runDir, { recursive: true });
|
|
67454
|
-
const stderrPath =
|
|
67537
|
+
const stderrPath = join93(ctx.runDir, `${iterationId}.stderr.log`);
|
|
67455
67538
|
writeFileSync46(stderrPath, stderrTail, "utf8");
|
|
67456
67539
|
data.stderr_path = stderrPath;
|
|
67457
67540
|
return { status: "failed", reason: classifyExitCause(session.exit, false), data };
|
|
@@ -67462,17 +67545,17 @@ var init_implement = __esm(() => {
|
|
|
67462
67545
|
|
|
67463
67546
|
// ../../loki-ts/src/engine10/machine.ts
|
|
67464
67547
|
import { existsSync as existsSync66, mkdirSync as mkdirSync48, rmSync as rmSync26, writeFileSync as writeFileSync47 } from "fs";
|
|
67465
|
-
import { isAbsolute as isAbsolute17, join as
|
|
67548
|
+
import { isAbsolute as isAbsolute17, join as join94, relative as relative20 } from "path";
|
|
67466
67549
|
async function optional(path) {
|
|
67467
|
-
const abs = isAbsolute17(path) ? path :
|
|
67550
|
+
const abs = isAbsolute17(path) ? path : join94(import.meta.dir, path);
|
|
67468
67551
|
if (!existsSync66(abs))
|
|
67469
67552
|
return null;
|
|
67470
67553
|
return await import(abs);
|
|
67471
67554
|
}
|
|
67472
67555
|
function defaultLoader(dir) {
|
|
67473
67556
|
return async (name) => {
|
|
67474
|
-
const reg = dir ===
|
|
67475
|
-
const mod = reg ? await reg() : await optional(
|
|
67557
|
+
const reg = dir === join94(import.meta.dir, "stages") ? REGISTRY[`./stages/${name}.ts`] : undefined;
|
|
67558
|
+
const mod = reg ? await reg() : await optional(join94(dir, `${name}.ts`));
|
|
67476
67559
|
return mod ? mod.stage ?? mod.default ?? null : null;
|
|
67477
67560
|
};
|
|
67478
67561
|
}
|
|
@@ -67481,7 +67564,7 @@ function softCapS(capS) {
|
|
|
67481
67564
|
return Math.max(0, Math.min(plain2, budget));
|
|
67482
67565
|
}
|
|
67483
67566
|
async function runMachine(ctx, opts = {}) {
|
|
67484
|
-
const load = opts.load ?? defaultLoader(opts.stagesDir ??
|
|
67567
|
+
const load = opts.load ?? defaultLoader(opts.stagesDir ?? join94(import.meta.dir, "stages"));
|
|
67485
67568
|
const outputs = {};
|
|
67486
67569
|
let capHit = false, fatal = null;
|
|
67487
67570
|
if (opts.restored)
|
|
@@ -67697,9 +67780,9 @@ ${timeBudgetNote(limitS)}`;
|
|
|
67697
67780
|
else
|
|
67698
67781
|
try {
|
|
67699
67782
|
const w = a;
|
|
67700
|
-
mkdirSync48(
|
|
67783
|
+
mkdirSync48(join94(base, relative20(ctx.repoDir, w.targetDir)), { recursive: true });
|
|
67701
67784
|
for (const [n10, c] of w.contents)
|
|
67702
|
-
writeFileSync47(
|
|
67785
|
+
writeFileSync47(join94(base, relative20(ctx.repoDir, w.targetDir), n10), c, "utf8");
|
|
67703
67786
|
r = j10.split.install(sctx, a, base);
|
|
67704
67787
|
const changed = hooks.wall.changedSinceBase(ctx.repoDir, ctx.baseSha);
|
|
67705
67788
|
if (r.status === "completed") {
|
|
@@ -68006,8 +68089,8 @@ __export(exports_worker, {
|
|
|
68006
68089
|
main: () => main2,
|
|
68007
68090
|
assertWorkerEnv: () => assertWorkerEnv
|
|
68008
68091
|
});
|
|
68009
|
-
import { readFileSync as
|
|
68010
|
-
import { join as
|
|
68092
|
+
import { readFileSync as readFileSync85 } from "fs";
|
|
68093
|
+
import { join as join95 } from "path";
|
|
68011
68094
|
function assertWorkerEnv(env = process.env) {
|
|
68012
68095
|
if (env.LOKI_ALLOW_AGENT_GITHUB_TOKEN === "1")
|
|
68013
68096
|
return;
|
|
@@ -68037,7 +68120,7 @@ async function main2(args) {
|
|
|
68037
68120
|
return 2;
|
|
68038
68121
|
}
|
|
68039
68122
|
const repoDir = process.cwd();
|
|
68040
|
-
const lokiRoot =
|
|
68123
|
+
const lokiRoot = join95(repoDir, ".loki");
|
|
68041
68124
|
const deep = mode === "deep";
|
|
68042
68125
|
globalThis[Symbol.for("loki.ownsStopSignals")] = true;
|
|
68043
68126
|
for (const sig of ["SIGTERM", "SIGINT"])
|
|
@@ -68065,7 +68148,7 @@ async function main2(args) {
|
|
|
68065
68148
|
externalPatch,
|
|
68066
68149
|
runId,
|
|
68067
68150
|
repoDir,
|
|
68068
|
-
runDir:
|
|
68151
|
+
runDir: join95(lokiRoot, "runs", runId),
|
|
68069
68152
|
branch: `loki/${runId}`,
|
|
68070
68153
|
provider,
|
|
68071
68154
|
model,
|
|
@@ -68079,7 +68162,7 @@ async function main2(args) {
|
|
|
68079
68162
|
tests: new RealTestMapProvider,
|
|
68080
68163
|
cost: {
|
|
68081
68164
|
read(dir, ids) {
|
|
68082
|
-
const c = sumResultCosts(
|
|
68165
|
+
const c = sumResultCosts(join95(dir, ".loki"), liveArchivedCosts(join95(dir, ".loki"), ids, UNMETERED));
|
|
68083
68166
|
return costTotalsOf(c);
|
|
68084
68167
|
}
|
|
68085
68168
|
},
|
|
@@ -68089,7 +68172,7 @@ async function main2(args) {
|
|
|
68089
68172
|
const resize = deep ? undefined : () => resizeCap(ctx.runDir, loadProjectApi(repoDir), !(Number(parseCapUsd(process.env.LOKI_E10_MAX_COST_USD)) > 0), Number(process.env.LOKI_E10_CAP_FIXED_S) || undefined);
|
|
68090
68173
|
let flow = FLOW.filter((s) => s !== "pr"), restored;
|
|
68091
68174
|
if (process.env.LOKI_E10_RESUME === "1") {
|
|
68092
|
-
const p =
|
|
68175
|
+
const p = join95(repoDir, eventsRelPath(runId)), r = (await Promise.resolve().then(() => (init_run_outputs(), exports_run_outputs))).resumeMachineOpts(ctx, readEvents(p), readFileSync85(p, "utf8"), flow);
|
|
68093
68176
|
if (!r.ok) {
|
|
68094
68177
|
emit("escalated", null, { stop: `resume refused: ${r.reason}` });
|
|
68095
68178
|
return;
|
|
@@ -68137,12 +68220,12 @@ __export(exports_deep, {
|
|
|
68137
68220
|
});
|
|
68138
68221
|
import { existsSync as existsSync67, mkdirSync as mkdirSync49, mkdtempSync as mkdtempSync12, rmSync as rmSync27, writeFileSync as writeFileSync48 } from "fs";
|
|
68139
68222
|
import { tmpdir as tmpdir15 } from "os";
|
|
68140
|
-
import { join as
|
|
68223
|
+
import { join as join96 } from "path";
|
|
68141
68224
|
function sessionCouncil(sessions) {
|
|
68142
68225
|
return { async run(input, signal) {
|
|
68143
|
-
const cwd = mkdtempSync12(
|
|
68226
|
+
const cwd = mkdtempSync12(join96(tmpdir15(), "loki-deep-council-"));
|
|
68144
68227
|
try {
|
|
68145
|
-
writeFileSync48(
|
|
68228
|
+
writeFileSync48(join96(cwd, "diff.patch"), input.diff, "utf8");
|
|
68146
68229
|
const r = await sessions.run({
|
|
68147
68230
|
stage: "deep",
|
|
68148
68231
|
tier: "development",
|
|
@@ -68212,7 +68295,7 @@ ${r.stderr}`), lr2 = r.exitCode === 0 ? undefined : await harnessLoadReason({ re
|
|
|
68212
68295
|
async function runAppBoot(ctx, opts, checks, notProven) {
|
|
68213
68296
|
let r;
|
|
68214
68297
|
try {
|
|
68215
|
-
r = await (opts.appProbe ?? appProbe)(ctx.repoDir,
|
|
68298
|
+
r = await (opts.appProbe ?? appProbe)(ctx.repoDir, join96(ctx.repoDir, ".loki"));
|
|
68216
68299
|
} catch (err) {
|
|
68217
68300
|
r = { checks: [{ name: "app boot", cmd: "autonomy/app-runner.sh", result: "not_run", duration_s: 0, reason: `app probe threw: ${err.message}` }], pid: null, url: null };
|
|
68218
68301
|
}
|
|
@@ -68270,7 +68353,7 @@ async function runSecretScan(ctx, changed, opts, checks, notProven) {
|
|
|
68270
68353
|
}
|
|
68271
68354
|
const inline = 'script="$1"; shift; . "$script" || exit 3; hit=0; for f in "$@"; do if _commit_scan_secret_file "$f" || _commit_path_looks_secret "$f"; then printf "%s\\n" "$f"; hit=1; fi; done; exit "$hit"';
|
|
68272
68355
|
const started = Date.now();
|
|
68273
|
-
const r = await run(["bash", "-c", inline, "_", scriptPath, ...changed.map((f) =>
|
|
68356
|
+
const r = await run(["bash", "-c", inline, "_", scriptPath, ...changed.map((f) => join96(ctx.repoDir, f))], { cwd: ctx.repoDir, timeoutMs: 30000 });
|
|
68274
68357
|
const sec = await secureScanChanged(ctx.repoDir, changed, opts.secureScanPath), gaps = [], reasons = [];
|
|
68275
68358
|
const hits = r.exitCode === 3 ? [] : r.stdout.split(`
|
|
68276
68359
|
`).map((l) => l.trim()).filter(Boolean), high = sec.findings.filter((f) => String(f.severity).toUpperCase() === "HIGH");
|
|
@@ -68323,7 +68406,7 @@ async function runDeep(ctx, signal, opts = {}) {
|
|
|
68323
68406
|
const sig = signReceipt(`${ctx.runId}-deep`, addendumSha256);
|
|
68324
68407
|
const addendum = { ...addendumBody, addendum_sha256: addendumSha256, verification: { jwt: sig.jwt, kid: sig.kid } };
|
|
68325
68408
|
mkdirSync49(ctx.runDir, { recursive: true });
|
|
68326
|
-
writeFileSync48(
|
|
68409
|
+
writeFileSync48(join96(ctx.runDir, "receipt-addendum-1.json"), JSON.stringify(addendum, null, 2) + `
|
|
68327
68410
|
`);
|
|
68328
68411
|
const headSha = (await safeGitRun(ctx.repoDir, ["rev-parse", "HEAD"], { timeoutMs: 1e4 })).stdout.trim();
|
|
68329
68412
|
const pushNotProven = await postDeepResults({
|
|
@@ -68349,11 +68432,11 @@ async function deepWorker(args, deps = {}) {
|
|
|
68349
68432
|
`);
|
|
68350
68433
|
return 2;
|
|
68351
68434
|
}
|
|
68352
|
-
const repoDir = process.cwd(), lokiRoot =
|
|
68435
|
+
const repoDir = process.cwd(), lokiRoot = join96(repoDir, ".loki"), runDir = join96(lokiRoot, "runs", runId);
|
|
68353
68436
|
const { readEvents: readEvents2 } = await Promise.resolve().then(() => (init_events(), exports_events)), { eventsRelPath: eventsRelPath2 } = await Promise.resolve().then(() => (init_engine_origin(), exports_engine_origin)), { outputsFromEvents: outputsFromEvents2 } = await Promise.resolve().then(() => (init_run_outputs(), exports_run_outputs));
|
|
68354
68437
|
let outputs;
|
|
68355
68438
|
try {
|
|
68356
|
-
outputs = outputsFromEvents2(readEvents2(
|
|
68439
|
+
outputs = outputsFromEvents2(readEvents2(join96(repoDir, eventsRelPath2(runId))));
|
|
68357
68440
|
} catch (err) {
|
|
68358
68441
|
process.stderr.write(`engine10 deep-worker: cannot read run events: ${err.message}
|
|
68359
68442
|
`);
|
|
@@ -68443,9 +68526,9 @@ __export(exports_verify, {
|
|
|
68443
68526
|
commandFor: () => commandFor,
|
|
68444
68527
|
changedFiles: () => changedFiles
|
|
68445
68528
|
});
|
|
68446
|
-
import { existsSync as existsSync68, mkdtempSync as mkdtempSync13, readFileSync as
|
|
68529
|
+
import { existsSync as existsSync68, mkdtempSync as mkdtempSync13, readFileSync as readFileSync86, rmSync as rmSync28 } from "fs";
|
|
68447
68530
|
import { tmpdir as tmpdir16 } from "os";
|
|
68448
|
-
import { basename as basename25, isAbsolute as isAbsolute18, join as
|
|
68531
|
+
import { basename as basename25, isAbsolute as isAbsolute18, join as join97, relative as relative21 } from "path";
|
|
68449
68532
|
async function runOnce3(cmd, args, cwd, signal, opts) {
|
|
68450
68533
|
if (!Bun.which(cmd, { PATH: opts.path ?? process.env["PATH"] ?? "" }))
|
|
68451
68534
|
return { ok: false, missing: true, cut: false, out: "" };
|
|
@@ -68527,7 +68610,7 @@ async function probeZeroChecks(repoDir, tests, signal, budgetS = 120, cap = 300)
|
|
|
68527
68610
|
rmNewUntracked(repoDir, before);
|
|
68528
68611
|
return { measured: measured.sort(), zero: zero.sort() };
|
|
68529
68612
|
}
|
|
68530
|
-
async function subtractBase(ctx, api, checks, tests, changed, wall, rel, signal, zeroOk = true, zeroIntake = new Set) {
|
|
68613
|
+
async function subtractBase(ctx, api, checks, tests, changed, wall, rel, signal, zeroOk = true, zeroIntake = new Set, dep = new Set) {
|
|
68531
68614
|
const out3 = { ids: [], names: [], weak: [], zero: [], cnt: {} };
|
|
68532
68615
|
const pairs = checks.flatMap((c) => {
|
|
68533
68616
|
const t = tests.find((x3) => testCheckName(x3) === c.name);
|
|
@@ -68538,7 +68621,7 @@ async function subtractBase(ctx, api, checks, tests, changed, wall, rel, signal,
|
|
|
68538
68621
|
const zc2 = zeroOk ? un2.filter(({ c, t }) => c.result === "not_run" && !c.owner && (c.reason ?? "").startsWith(NO_TESTS_REASON) && !wall.has(c.name) && !isHoldoutCheck(c.name) && !changed.includes(t.path) && zeroIntake.has(c.name)) : [];
|
|
68539
68622
|
if (!(un2.some(({ c }) => c.result === "fail" && c.ids?.length) || sus.length || zc2.length) || signal.aborted)
|
|
68540
68623
|
return out3;
|
|
68541
|
-
const dir = mkdtempSync13(
|
|
68624
|
+
const dir = mkdtempSync13(join97(tmpdir16(), "e10-base-"));
|
|
68542
68625
|
const git9 = (args) => {
|
|
68543
68626
|
safeGit(ctx.repoDir, args, { stdio: "ignore", repoDrivers: true });
|
|
68544
68627
|
};
|
|
@@ -68557,9 +68640,9 @@ async function subtractBase(ctx, api, checks, tests, changed, wall, rel, signal,
|
|
|
68557
68640
|
out3.cnt[c.name] = { b: { run: base.get(c).n, skipped: base.get(c).sk }, h: { run: c.n ?? 0, skipped: c.sk ?? 0 } };
|
|
68558
68641
|
}
|
|
68559
68642
|
const progress = checks.some((c) => wall.has(c.name) && c.result === "pass") || sus.some(({ c }) => !out3.weak.includes(c.name) && base.get(c).red.length > 0 && (c.n ?? 0) >= base.get(c).n);
|
|
68560
|
-
|
|
68643
|
+
{
|
|
68561
68644
|
for (const { c } of un2) {
|
|
68562
|
-
if (!rel.has(c.name) && c.result === "fail" && c.ids?.length && c.ids.every((i) => base.get(c).red.includes(i))) {
|
|
68645
|
+
if ((progress || dep.has(c.name)) && !rel.has(c.name) && c.result === "fail" && c.ids?.length && c.ids.every((i) => base.get(c).red.includes(i))) {
|
|
68563
68646
|
out3.names.push(c.name);
|
|
68564
68647
|
out3.ids.push(...c.ids);
|
|
68565
68648
|
}
|
|
@@ -68577,15 +68660,15 @@ async function subtractBase(ctx, api, checks, tests, changed, wall, rel, signal,
|
|
|
68577
68660
|
return out3;
|
|
68578
68661
|
}
|
|
68579
68662
|
function isLokiModeRepo(repoDir) {
|
|
68580
|
-
return existsSync68(
|
|
68663
|
+
return existsSync68(join97(repoDir, "scripts", "select-tests.sh"));
|
|
68581
68664
|
}
|
|
68582
68665
|
function projectDeclaresRuff(repoDir) {
|
|
68583
|
-
if (["ruff.toml", ".ruff.toml"].some((f) => existsSync68(
|
|
68666
|
+
if (["ruff.toml", ".ruff.toml"].some((f) => existsSync68(join97(repoDir, f))))
|
|
68584
68667
|
return true;
|
|
68585
68668
|
const files = ["pyproject.toml", "setup.cfg", "tox.ini", ".pre-commit-config.yaml", "Pipfile", "requirements.txt", "requirements-dev.txt", "dev-requirements.txt"];
|
|
68586
68669
|
return files.some((f) => {
|
|
68587
68670
|
try {
|
|
68588
|
-
return /\bruff\b/i.test(
|
|
68671
|
+
return /\bruff\b/i.test(readFileSync86(join97(repoDir, f), "utf8"));
|
|
68589
68672
|
} catch {
|
|
68590
68673
|
return false;
|
|
68591
68674
|
}
|
|
@@ -68611,9 +68694,9 @@ async function runLintChecks(ctx, changed, signal, checks, opts = {}) {
|
|
|
68611
68694
|
}
|
|
68612
68695
|
for (const g of groupByPackage(api, ctx.repoDir, changed.filter((f) => /\.(ts|tsx|js|jsx)$/.test(f)))) {
|
|
68613
68696
|
const sfx = g.root === "." ? "" : `:${g.root}`, co = g.root === "." ? opts : { ...opts, cwd: g.cwd };
|
|
68614
|
-
if (existsSync68(
|
|
68697
|
+
if (existsSync68(join97(g.cwd, "tsconfig.json")))
|
|
68615
68698
|
await runCheck(ctx, `lint:tsc${sfx}`, "npx", ["--no-install", "tsc", "--noEmit", "-p", "."], signal, checks, { ...co, kind: "static" });
|
|
68616
|
-
if (ESLINT_CONFIGS.some((f) => existsSync68(
|
|
68699
|
+
if (ESLINT_CONFIGS.some((f) => existsSync68(join97(g.cwd, f)))) {
|
|
68617
68700
|
const c = await runCheck(ctx, `lint:eslint${sfx}`, "npx", ["--no-install", "eslint", ...g.rel], signal, checks, { ...co, kind: "static" });
|
|
68618
68701
|
if (await excuseLint(ctx, signal, c, "eslint", "npx", ["--no-install", "eslint"], g.cwd, g.rel, co))
|
|
68619
68702
|
pre2.push(c.name);
|
|
@@ -68628,7 +68711,7 @@ var CHECK_TIMEOUT_MS = 60000, excerpts, isHold = (c) => isHoldoutCheck(c.name),
|
|
|
68628
68711
|
return r.missing || r.cut ? null : r;
|
|
68629
68712
|
}, base: (f) => {
|
|
68630
68713
|
try {
|
|
68631
|
-
return safeGit(ctx.repoDir, ["show", `${ctx.baseSha}:${relative21(ctx.repoDir,
|
|
68714
|
+
return safeGit(ctx.repoDir, ["show", `${ctx.baseSha}:${relative21(ctx.repoDir, join97(cwd, f))}`], { stdio: ["ignore", "pipe", "ignore"] });
|
|
68632
68715
|
} catch {
|
|
68633
68716
|
return null;
|
|
68634
68717
|
}
|
|
@@ -68640,6 +68723,7 @@ var init_verify = __esm(() => {
|
|
|
68640
68723
|
init_assert_delta();
|
|
68641
68724
|
init_failures();
|
|
68642
68725
|
init_select();
|
|
68726
|
+
init_dependents();
|
|
68643
68727
|
init_load_owner();
|
|
68644
68728
|
init_sizing();
|
|
68645
68729
|
init_testmap();
|
|
@@ -68703,7 +68787,8 @@ var init_verify = __esm(() => {
|
|
|
68703
68787
|
const runner = rec2 ?? guessRunner(basename25(p), map.runners, p);
|
|
68704
68788
|
return runner && (runner !== "bun" || map.runners.includes("bun") || /[._](?:test|spec)\.[cm]?[jt]sx?$/.test(p)) ? [{ runner, path: p }] : [];
|
|
68705
68789
|
});
|
|
68706
|
-
const
|
|
68790
|
+
const dep = dependentTests(ctx.repoDir, map, changed, [...impacted, ...changedTestFiles, ...wallTests, ...relevant2]), depNames = new Set(dep.tests.map(testCheckName));
|
|
68791
|
+
const tests = failedFirst(dedupeTests([...impacted, ...dep.tests, ...changedTestFiles, ...wallTests, ...relevant2]), ctx.outputs().verify?.checks);
|
|
68707
68792
|
const scopedOut = scopedOutOf(map);
|
|
68708
68793
|
if (scopedOut.length)
|
|
68709
68794
|
ctx.emit("test.scoped_out", "verify", { tests: scopedOut });
|
|
@@ -68732,7 +68817,7 @@ var init_verify = __esm(() => {
|
|
|
68732
68817
|
}
|
|
68733
68818
|
const targetNames = new Set([...[...wallTests, ...relevant2].map(testCheckName), ...checks.filter(isHold).map((c) => c.name)]);
|
|
68734
68819
|
const cfgChanged = testConfigChanged(ctx.repoDir, ctx.baseSha, changed);
|
|
68735
|
-
const preRed = await subtractBase(ctx, api, checks, tests, changed, new Set(wallTests.map(testCheckName)), new Set(relevant2.map(testCheckName)), signal, cfgChanged.length === 0, new Set(ctx.outputs().intake?.zero_baseline?.zero ?? []));
|
|
68820
|
+
const preRed = await subtractBase(ctx, api, checks, tests, changed, new Set(wallTests.map(testCheckName)), new Set(relevant2.map(testCheckName)), signal, cfgChanged.length === 0, new Set(ctx.outputs().intake?.zero_baseline?.zero ?? []), depNames);
|
|
68736
68821
|
const attr = attribute(ctx.repoDir, ctx.baseSha, checks.filter((c) => c.result === "fail" && !preRed.names.includes(c.name)).map((c) => ({ name: c.name, ids: c.ids, eligible: !targetNames.has(c.name) && !changed.includes(c.name.slice(c.name.indexOf(":") + 1)) })));
|
|
68737
68822
|
attr.introducedChecks = [...new Set(attr.introducedChecks.map((n10) => isHoldoutCheck(n10) ? "holdout" : n10))];
|
|
68738
68823
|
preRed.names.push(...attr.preExistingChecks);
|
|
@@ -68800,11 +68885,11 @@ ${x3}` : c.cmd };
|
|
|
68800
68885
|
return [`weakened test: ${t.path}`, ...assertDeltaNotes(ctx.repoDir, ctx.baseSha, null, t.path, intake?.task ?? "", k3?.b, k3?.h) ?? []];
|
|
68801
68886
|
});
|
|
68802
68887
|
const weakened = [...modifiedRel, ...cfgChanged.map((f) => `test configuration changed: ${f}`), ...preRed.weak.map((n10) => `skipped or fewer tests than base: ${n10}`)];
|
|
68803
|
-
const notProven = [...weakened, ...intake?.deps_not_proven ?? [], ...pub.filter((c) => c.name === "holdout" && c.result !== "pass").map((c) => c.result === "not_run" ? "holdout not executed" : "holdout check failed"), ...[...fullNotProven].filter((n10) => !naNote(n10)), ...pub.filter((c) => c.owner === "harness" && c.name !== "holdout").map((c) => `${c.reason} (${c.name}; harness-owned, no fix rounds)`), ...new Set(checks.filter((c) => c.interpreter === "system" && c.result !== "not_run").map((c) => c.name.startsWith("lint:") ? "lint ran on the system ruff" : "tests ran on the system interpreter"))];
|
|
68888
|
+
const notProven = [...weakened, ...dependentNotes(dep), ...intake?.deps_not_proven ?? [], ...pub.filter((c) => c.name === "holdout" && c.result !== "pass").map((c) => c.result === "not_run" ? "holdout not executed" : "holdout check failed"), ...[...fullNotProven].filter((n10) => !naNote(n10)), ...pub.filter((c) => c.owner === "harness" && c.name !== "holdout").map((c) => `${c.reason} (${c.name}; harness-owned, no fix rounds)`), ...new Set(checks.filter((c) => c.interpreter === "system" && c.result !== "not_run").map((c) => c.name.startsWith("lint:") ? "lint ran on the system ruff" : "tests ran on the system interpreter"))];
|
|
68804
68889
|
const wallDropped2 = [...wallPaths].filter((p) => !wallTests.some((t) => t.path === p));
|
|
68805
68890
|
notProven.push(...wallDropped2.map((p) => `Wall test not executed: ${p}: ${NO_RUNNER_REASON}`));
|
|
68806
68891
|
const wallNames = new Set(wallTests.map(testCheckName)), wallRun = checks.filter((c) => wallNames.has(c.name) || isHold(c)), wallPassed = wallRun.some((c) => c.result === "fail") ? false : wallRun.length > 0 && wallDropped2.length === 0 && wallRun.every((c) => c.result === "pass") ? true : undefined;
|
|
68807
|
-
return { status: "completed", data: { checks: pub, flaky, ...wallPassed === undefined ? {} : { wall_passed: wallPassed }, failures_grouped: failuresGrouped, holdout_failed: holdoutFailed, changed_files: changed, not_proven: notProven, ...fullNotProven.size ? { not_applicable: [...fullNotProven].filter(naNote).map(naText) } : {}, pre_red: preRed.ids, pre_red_checks: preRed.names, skipped_on_base: preRed.zero, ...attr.line ? { baseline_line: attr.line, introduced_checks: attr.introducedChecks } : {}, test_counts: testCounts, uncovered_changed: uncoveredChanged, target_checks: checks.filter((c) => c.result === "pass" && targetNames.has(c.name)).map((c) => isHold(c) ? "holdout" : c.name), risk } };
|
|
68892
|
+
return { status: "completed", data: { checks: pub, flaky, ...wallPassed === undefined ? {} : { wall_passed: wallPassed }, failures_grouped: failuresGrouped, holdout_failed: holdoutFailed, changed_files: changed, ...depNames.size ? { dependent_checks: [...depNames] } : {}, not_proven: notProven, ...fullNotProven.size ? { not_applicable: [...fullNotProven].filter(naNote).map(naText) } : {}, pre_red: preRed.ids, pre_red_checks: preRed.names, skipped_on_base: preRed.zero, ...attr.line ? { baseline_line: attr.line, introduced_checks: attr.introducedChecks } : {}, test_counts: testCounts, uncovered_changed: uncoveredChanged, target_checks: checks.filter((c) => c.result === "pass" && targetNames.has(c.name)).map((c) => isHold(c) ? "holdout" : c.name), risk } };
|
|
68808
68893
|
}
|
|
68809
68894
|
};
|
|
68810
68895
|
stage5 = verifyStage;
|
|
@@ -68835,9 +68920,9 @@ __export(exports_wall, {
|
|
|
68835
68920
|
BASE_RUN_TIMEOUT_MS: () => BASE_RUN_TIMEOUT_MS
|
|
68836
68921
|
});
|
|
68837
68922
|
import { spawnSync as spawnSync10 } from "child_process";
|
|
68838
|
-
import { existsSync as existsSync69, mkdirSync as mkdirSync50, mkdtempSync as mkdtempSync14, readFileSync as
|
|
68923
|
+
import { existsSync as existsSync69, mkdirSync as mkdirSync50, mkdtempSync as mkdtempSync14, readFileSync as readFileSync87, readdirSync as readdirSync28, rmSync as rmSync29, writeFileSync as writeFileSync49 } from "fs";
|
|
68839
68924
|
import { tmpdir as tmpdir17 } from "os";
|
|
68840
|
-
import { dirname as
|
|
68925
|
+
import { dirname as dirname39, join as join98, relative as relative22 } from "path";
|
|
68841
68926
|
|
|
68842
68927
|
class RealBaseTestRunner {
|
|
68843
68928
|
api;
|
|
@@ -68903,10 +68988,10 @@ ${acceptance2.map((a) => `Acceptance: ${a}`).join(`
|
|
|
68903
68988
|
function loadTaskText(ctx, fromPrior) {
|
|
68904
68989
|
if (fromPrior)
|
|
68905
68990
|
return fromPrior;
|
|
68906
|
-
const issueJsonPath = process.env.LOKI_E10_ISSUE_JSON ??
|
|
68991
|
+
const issueJsonPath = process.env.LOKI_E10_ISSUE_JSON ?? join98(ctx.runDir, "issue.json");
|
|
68907
68992
|
if (existsSync69(issueJsonPath)) {
|
|
68908
68993
|
try {
|
|
68909
|
-
const issue = JSON.parse(
|
|
68994
|
+
const issue = JSON.parse(readFileSync87(issueJsonPath, "utf8"));
|
|
68910
68995
|
const text3 = [issue.title, issue.body].filter((s) => typeof s === "string" && s.length > 0).join(`
|
|
68911
68996
|
|
|
68912
68997
|
`);
|
|
@@ -68918,7 +69003,7 @@ function loadTaskText(ctx, fromPrior) {
|
|
|
68918
69003
|
}
|
|
68919
69004
|
function wallTargetDir(repoDir, existingTests) {
|
|
68920
69005
|
const first = existingTests[0];
|
|
68921
|
-
return first ?
|
|
69006
|
+
return first ? join98(repoDir, dirname39(first.path)) : join98(repoDir, "tests");
|
|
68922
69007
|
}
|
|
68923
69008
|
async function wallAuthor(ctx, signal, retry) {
|
|
68924
69009
|
const done = (result) => ({ kind: "done", result });
|
|
@@ -68944,11 +69029,11 @@ async function wallAuthor(ctx, signal, retry) {
|
|
|
68944
69029
|
const tree = prior.intake?.tree;
|
|
68945
69030
|
const repomapText = repoMapText(ctx.repoDir, tree, repomapRef, WALL_MAP_MAX_LINES);
|
|
68946
69031
|
const targetDir = wallTargetDir(ctx.repoDir, existingTests), pkg = loadProjectApi(ctx.repoDir)?.packageOf(`${relative22(ctx.repoDir, targetDir)}/x`);
|
|
68947
|
-
const conv2 = readPackageConventions(
|
|
68948
|
-
const cwd = mkdtempSync14(
|
|
69032
|
+
const conv2 = readPackageConventions(join98(ctx.repoDir, pkg?.root ?? "."), pkg?.runner ?? null);
|
|
69033
|
+
const cwd = mkdtempSync14(join98(tmpdir17(), "loki-e15-wall-"));
|
|
68949
69034
|
const wm2 = wallManifestFor(ctx.repoDir, tree, task);
|
|
68950
69035
|
for (const [n10, c] of [["task.md", task], ["repomap.txt", repomapText], ...wm2 ? [["wall_manifest.txt", wm2.text]] : []])
|
|
68951
|
-
writeFileSync49(
|
|
69036
|
+
writeFileSync49(join98(cwd, n10), c, "utf8");
|
|
68952
69037
|
const clauseSet = extractClauses(task);
|
|
68953
69038
|
const model = retry?.model ?? wallFirstModel(sz2.size), iterationId = `${ctx.runId}-wall${retry?.suffix ?? ""}`;
|
|
68954
69039
|
const session = await ctx.sessions.run({
|
|
@@ -68967,21 +69052,21 @@ async function wallAuthor(ctx, signal, retry) {
|
|
|
68967
69052
|
}
|
|
68968
69053
|
const planText = typeof prior.plan?.plan === "string" ? prior.plan.plan : null, repoFiles = repoMap?.files ?? [];
|
|
68969
69054
|
const oor = () => readdirSync28(cwd).filter((f) => f.startsWith(WALL_PREFIX)).flatMap((name) => {
|
|
68970
|
-
const text3 =
|
|
69055
|
+
const text3 = readFileSync87(join98(cwd, name), "utf8"), why = outOfRepoTarget(text3) ?? vacuousCheck(name, text3) ?? phantomReason(phantomRepoPaths(text3, name, targetDir, ctx.repoDir, planText), repoFiles, relative22(ctx.repoDir, targetDir), pkg?.root ?? "");
|
|
68971
69056
|
return why ? [{ name, why }] : [];
|
|
68972
69057
|
});
|
|
68973
69058
|
const bad1 = oor();
|
|
68974
69059
|
if (bad1.length > 0 && !signal.aborted && !ctx.overCap?.())
|
|
68975
69060
|
await ctx.sessions.run({ stage: "wall", brief: withStagePrefix(outOfRepoReask("Rewrite these Wall files in place, keeping the same names and acceptance coverage.", bad1)), tier: "development", model, iterationId: `${iterationId}-oor`, limitS: wallLimitS(sz2.size), signal, cwd });
|
|
68976
|
-
const oorBad = new Map(oor().map((b) => [b.name, b.why])), all = readdirSync28(cwd).filter((f) => f.startsWith(WALL_PREFIX)), held = stashHoldout({ runId: ctx.runId, repoDir: ctx.repoDir, srcDir: cwd, targetDir, names: all.filter((n10) => !oorBad.has(n10) && !conventionViolation(conv2, n10,
|
|
68977
|
-
const sealedDir =
|
|
69061
|
+
const oorBad = new Map(oor().map((b) => [b.name, b.why])), all = readdirSync28(cwd).filter((f) => f.startsWith(WALL_PREFIX)), held = stashHoldout({ runId: ctx.runId, repoDir: ctx.repoDir, srcDir: cwd, targetDir, names: all.filter((n10) => !oorBad.has(n10) && !conventionViolation(conv2, n10, readFileSync87(join98(cwd, n10), "utf8"))), runnerOf: (n10) => guessRunner(n10, runners) }), generated = all.filter((n10) => !held?.names.has(n10));
|
|
69062
|
+
const sealedDir = join98(ctx.runDir, "wall");
|
|
68978
69063
|
if (generated.length > 0)
|
|
68979
69064
|
mkdirSync50(sealedDir, { recursive: true });
|
|
68980
69065
|
const contents = new Map;
|
|
68981
69066
|
const discarded = [];
|
|
68982
69067
|
for (const name of generated) {
|
|
68983
|
-
const content =
|
|
68984
|
-
writeFileSync49(
|
|
69068
|
+
const content = readFileSync87(join98(cwd, name), "utf8"), oorWhy = oorBad.get(name), bad = oorWhy ?? conventionViolation(conv2, name, content);
|
|
69069
|
+
writeFileSync49(join98(sealedDir, name), content, "utf8");
|
|
68985
69070
|
if (oorWhy)
|
|
68986
69071
|
discarded.push({ file: name, reason: `${oorWhy}; wall test discarded after one rewrite request` });
|
|
68987
69072
|
else if (bad)
|
|
@@ -69010,7 +69095,7 @@ function* installCore(ctx, a, baseDir, opts) {
|
|
|
69010
69095
|
const content = contents.get(name);
|
|
69011
69096
|
if (content === undefined)
|
|
69012
69097
|
continue;
|
|
69013
|
-
const dest =
|
|
69098
|
+
const dest = join98(targetDir, name), runner = guessRunner(name, runners, relative22(ctx.repoDir, dest));
|
|
69014
69099
|
writeFileSync49(dest, content, "utf8");
|
|
69015
69100
|
sealedFiles.push({ path: dest, sha256: sha2562(content), ...runner ? { runner } : {} });
|
|
69016
69101
|
readOnlyFiles.push({ path: dest, content });
|
|
@@ -69027,7 +69112,7 @@ function* installCore(ctx, a, baseDir, opts) {
|
|
|
69027
69112
|
}
|
|
69028
69113
|
const each = yield { runner: baseRunner, tests: wallTests };
|
|
69029
69114
|
for (const [i, t] of wallTests.entries()) {
|
|
69030
|
-
const e10 = each?.[i], r = e10 ?? baseRunner.run(baseDir, [t]), abs =
|
|
69115
|
+
const e10 = each?.[i], r = e10 ?? baseRunner.run(baseDir, [t]), abs = join98(ctx.repoDir, t.path);
|
|
69031
69116
|
baseRun.pass += r.pass;
|
|
69032
69117
|
baseRun.fail += r.fail;
|
|
69033
69118
|
baseRun.not_run += r.not_run ?? 0;
|
|
@@ -69070,7 +69155,7 @@ async function runWall(ctx, signal, opts = {}) {
|
|
|
69070
69155
|
if (a.kind === "authored") {
|
|
69071
69156
|
for (const f of first.data.files ?? [])
|
|
69072
69157
|
rmSync29(f.path, { force: true });
|
|
69073
|
-
rmSync29(
|
|
69158
|
+
rmSync29(join98(ctx.runDir, "wall"), { recursive: true, force: true });
|
|
69074
69159
|
ctx.wallSealed = false;
|
|
69075
69160
|
}
|
|
69076
69161
|
removeHoldout(ctx.runId, ctx.repoDir);
|
|
@@ -69110,15 +69195,15 @@ var init_wall = __esm(() => {
|
|
|
69110
69195
|
});
|
|
69111
69196
|
|
|
69112
69197
|
// ../../loki-ts/src/e10ext/discard.ts
|
|
69113
|
-
import { chmodSync as chmodSync6, closeSync as closeSync14, lstatSync as lstatSync26, mkdirSync as mkdirSync51, openSync as openSync14, readFileSync as
|
|
69114
|
-
import { dirname as
|
|
69198
|
+
import { chmodSync as chmodSync6, closeSync as closeSync14, lstatSync as lstatSync26, mkdirSync as mkdirSync51, openSync as openSync14, readFileSync as readFileSync88, realpathSync as realpathSync29, rmdirSync, unlinkSync as unlinkSync9, writeFileSync as writeFileSync50 } from "fs";
|
|
69199
|
+
import { dirname as dirname40, join as join99, relative as relative23, sep as sep19 } from "path";
|
|
69115
69200
|
function safeRestore(repoDir, f, want, mode) {
|
|
69116
|
-
const root = realpathSync29(repoDir), fp2 =
|
|
69201
|
+
const root = realpathSync29(repoDir), fp2 = join99(root, f), rel = relative23(root, dirname40(fp2));
|
|
69117
69202
|
if (rel.startsWith(".."))
|
|
69118
69203
|
throw new Error("outside repo");
|
|
69119
69204
|
let cur = root;
|
|
69120
69205
|
for (const part of rel === "" ? [] : rel.split(sep19)) {
|
|
69121
|
-
cur =
|
|
69206
|
+
cur = join99(cur, part);
|
|
69122
69207
|
let st3;
|
|
69123
69208
|
try {
|
|
69124
69209
|
st3 = lstatSync26(cur);
|
|
@@ -69135,7 +69220,7 @@ function safeRestore(repoDir, f, want, mode) {
|
|
|
69135
69220
|
} catch {
|
|
69136
69221
|
st2 = null;
|
|
69137
69222
|
}
|
|
69138
|
-
if (st2?.isFile() &&
|
|
69223
|
+
if (st2?.isFile() && readFileSync88(fp2).equals(want)) {
|
|
69139
69224
|
chmodSync6(fp2, mode);
|
|
69140
69225
|
return;
|
|
69141
69226
|
}
|
|
@@ -69172,7 +69257,7 @@ async function discardIfSatisfied(git9, base, o, staged, keep, repoDir) {
|
|
|
69172
69257
|
return { status: "failed", data: {}, reason: "already-satisfied discard failed" };
|
|
69173
69258
|
const notProven = [];
|
|
69174
69259
|
for (const [f, v3] of Object.entries(o.intake?.preexisting_untracked_blobs ?? {})) {
|
|
69175
|
-
const fp2 =
|
|
69260
|
+
const fp2 = join99(repoDir, f);
|
|
69176
69261
|
try {
|
|
69177
69262
|
if (v3.startsWith("!")) {
|
|
69178
69263
|
const st2 = lstatSync26(fp2);
|
|
@@ -69191,7 +69276,7 @@ async function discardIfSatisfied(git9, base, o, staged, keep, repoDir) {
|
|
|
69191
69276
|
try {
|
|
69192
69277
|
let m = 420;
|
|
69193
69278
|
try {
|
|
69194
|
-
const l = lstatSync26(
|
|
69279
|
+
const l = lstatSync26(join99(repoDir, f));
|
|
69195
69280
|
if (l.isFile())
|
|
69196
69281
|
m = l.mode & 511;
|
|
69197
69282
|
} catch {}
|
|
@@ -69207,7 +69292,7 @@ var init_discard = __esm(() => {
|
|
|
69207
69292
|
});
|
|
69208
69293
|
|
|
69209
69294
|
// ../../loki-ts/src/e10ext/scope.ts
|
|
69210
|
-
import { basename as basename26, dirname as
|
|
69295
|
+
import { basename as basename26, dirname as dirname41 } from "path";
|
|
69211
69296
|
function contractText(o) {
|
|
69212
69297
|
const c = o.intake?.contract_snapshot?.contract;
|
|
69213
69298
|
return Array.isArray(c?.criteria) ? c.criteria.map((x3) => typeof x3?.text === "string" ? x3.text : "").join(`
|
|
@@ -69221,8 +69306,8 @@ function outsideScope(o, staged) {
|
|
|
69221
69306
|
const text3 = `${plan}
|
|
69222
69307
|
${typeof o.intake?.task === "string" ? o.intake.task : ""}
|
|
69223
69308
|
${contractText(o)}`, pre2 = o.intake?.preexisting_dirty ?? {};
|
|
69224
|
-
const toks = surfaceTokens(text3), plannedDirs = new Set(rel.map((r) =>
|
|
69225
|
-
return staged.filter(({ st: st2, f }) => st2 !== "A" && !isTestFile(f) && !Object.hasOwn(pre2, f) && !rel.includes(f) && !mentions(text3, f) && !mentions(text3, basename26(f)) && !plannedDirs.has(
|
|
69309
|
+
const toks = surfaceTokens(text3), plannedDirs = new Set(rel.map((r) => dirname41(r)).filter((d) => d !== "."));
|
|
69310
|
+
return staged.filter(({ st: st2, f }) => st2 !== "A" && !isTestFile(f) && !Object.hasOwn(pre2, f) && !rel.includes(f) && !mentions(text3, f) && !mentions(text3, basename26(f)) && !plannedDirs.has(dirname41(f)) && !dirSegs(f).some((d) => toks.has(d))).map(({ f }) => f);
|
|
69226
69311
|
}
|
|
69227
69312
|
function flagOutsideScope(o, staged) {
|
|
69228
69313
|
const unit = unitFlags(staged, process.env, o.intake?.preexisting_dirty ?? {});
|
|
@@ -69237,14 +69322,14 @@ var init_scope2 = __esm(() => {
|
|
|
69237
69322
|
});
|
|
69238
69323
|
|
|
69239
69324
|
// ../../loki-ts/src/council/role_agents.ts
|
|
69240
|
-
import { existsSync as existsSync70, readdirSync as readdirSync29, readFileSync as
|
|
69325
|
+
import { existsSync as existsSync70, readdirSync as readdirSync29, readFileSync as readFileSync89 } from "fs";
|
|
69241
69326
|
import { homedir as homedir11 } from "os";
|
|
69242
|
-
import { join as
|
|
69327
|
+
import { join as join100 } from "path";
|
|
69243
69328
|
function agentDirs(repoDir, env = process.env) {
|
|
69244
|
-
return [env["LOKI_AGENTS_PROJECT_DIR"] ||
|
|
69329
|
+
return [env["LOKI_AGENTS_PROJECT_DIR"] || join100(repoDir, ".loki", "agents"), env["LOKI_AGENTS_USER_DIR"] || join100(env["XDG_CONFIG_HOME"] || join100(homedir11(), ".config"), "loki", "agents")];
|
|
69245
69330
|
}
|
|
69246
69331
|
function parseAgent(file, stem2) {
|
|
69247
|
-
const m = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/.exec(
|
|
69332
|
+
const m = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/.exec(readFileSync89(file, "utf8"));
|
|
69248
69333
|
if (!m)
|
|
69249
69334
|
return null;
|
|
69250
69335
|
const body = m[2].trim();
|
|
@@ -69269,7 +69354,7 @@ function loadRoleAgent(repoDir, role, env = process.env) {
|
|
|
69269
69354
|
const ordered = [...names.filter((n10) => n10 === `${role}.md`), ...names.filter((n10) => n10 !== `${role}.md`)];
|
|
69270
69355
|
for (const n10 of ordered) {
|
|
69271
69356
|
try {
|
|
69272
|
-
const a = parseAgent(
|
|
69357
|
+
const a = parseAgent(join100(d, n10), n10.slice(0, -3));
|
|
69273
69358
|
if (a && a.role === role)
|
|
69274
69359
|
return a;
|
|
69275
69360
|
} catch {}
|
|
@@ -69288,11 +69373,11 @@ function explicitReview(repoDir, env) {
|
|
|
69288
69373
|
if (flag && isOff(ev2))
|
|
69289
69374
|
return "off";
|
|
69290
69375
|
for (const f of ["loki.yaml", "loki.yml"]) {
|
|
69291
|
-
const p =
|
|
69376
|
+
const p = join100(repoDir, f);
|
|
69292
69377
|
if (!existsSync70(p))
|
|
69293
69378
|
continue;
|
|
69294
69379
|
try {
|
|
69295
|
-
const m = /^review:[ \t]*["']?([A-Za-z]+)["']?[ \t]*(?:#.*)?$/m.exec(
|
|
69380
|
+
const m = /^review:[ \t]*["']?([A-Za-z]+)["']?[ \t]*(?:#.*)?$/m.exec(readFileSync89(p, "utf8"));
|
|
69296
69381
|
const v3 = asProvider(m?.[1]);
|
|
69297
69382
|
if (v3)
|
|
69298
69383
|
return v3;
|
|
@@ -69325,7 +69410,7 @@ var init_role_agents = __esm(() => {
|
|
|
69325
69410
|
|
|
69326
69411
|
// ../../loki-ts/src/util/child_ledger.ts
|
|
69327
69412
|
import { appendFileSync as appendFileSync10, mkdirSync as mkdirSync52 } from "fs";
|
|
69328
|
-
import { join as
|
|
69413
|
+
import { join as join101 } from "path";
|
|
69329
69414
|
function unmeasuredRecord(phase, model, source) {
|
|
69330
69415
|
return { phase, model, input_tokens: 0, output_tokens: 0, cache_creation_tokens: 0, cache_read_tokens: 0, source, cost_status: "unmeasured" };
|
|
69331
69416
|
}
|
|
@@ -69350,9 +69435,9 @@ function recordFromClaudeResult(phase, payload, source = "claude-json") {
|
|
|
69350
69435
|
}
|
|
69351
69436
|
function appendChildLedger(lokiDir2, rec2) {
|
|
69352
69437
|
try {
|
|
69353
|
-
const dir =
|
|
69438
|
+
const dir = join101(lokiDir2, "metrics");
|
|
69354
69439
|
mkdirSync52(dir, { recursive: true });
|
|
69355
|
-
appendFileSync10(
|
|
69440
|
+
appendFileSync10(join101(dir, "child-sessions.jsonl"), `${JSON.stringify(rec2)}
|
|
69356
69441
|
`);
|
|
69357
69442
|
return true;
|
|
69358
69443
|
} catch {
|
|
@@ -69382,7 +69467,7 @@ var init_child_ledger = __esm(() => {
|
|
|
69382
69467
|
});
|
|
69383
69468
|
|
|
69384
69469
|
// ../../loki-ts/src/engine10/stages/xreview.ts
|
|
69385
|
-
import { join as
|
|
69470
|
+
import { join as join102 } from "path";
|
|
69386
69471
|
function minVerdict(verdict, review) {
|
|
69387
69472
|
const ceiling = review?.level === "block" ? "PARTIAL" : verdict;
|
|
69388
69473
|
return RANK4[ceiling] < RANK4[verdict] ? ceiling : verdict;
|
|
@@ -69480,9 +69565,9 @@ Review ONLY the diff below. Do not modify files.` : "You are an independent code
|
|
|
69480
69565
|
try {
|
|
69481
69566
|
if (p === "claude")
|
|
69482
69567
|
await ensureClaudeHelpCache();
|
|
69483
|
-
const r = await withChildLedger(run,
|
|
69568
|
+
const r = await withChildLedger(run, join102(ctx.repoDir, ".loki"), "xreview")(reviewArgv(p, prompt, process.env, p === "claude" ? agent?.model || pin : undefined), { cwd: ctx.repoDir, timeoutMs: boxFor(ctx) * 1000, group: true, signal });
|
|
69484
69569
|
const costId = `${ctx.runId}-xreview-${p}`;
|
|
69485
|
-
writeReviewerCost(
|
|
69570
|
+
writeReviewerCost(join102(ctx.repoDir, ".loki"), costId, { reviewer: `xreview-${p}`, provider: p, model: p === "claude" ? agent?.model || pin : undefined, stdout: r.stdout, stderr: r.stderr });
|
|
69486
69571
|
if (r.exitCode !== 0)
|
|
69487
69572
|
return { ...tag({ provider: p, level: "not_run", notes: [`cross-review not run: ${p} exited ${r.exitCode}`] }), cost_iteration: costId };
|
|
69488
69573
|
return { ...tag(parseReview(p, r.stdout)), cost_iteration: costId };
|
|
@@ -69663,9 +69748,9 @@ __export(exports_contract, {
|
|
|
69663
69748
|
MAX_CONTRACT_BYTES: () => MAX_CONTRACT_BYTES,
|
|
69664
69749
|
CONSTRAINT_KINDS: () => CONSTRAINT_KINDS
|
|
69665
69750
|
});
|
|
69666
|
-
import { existsSync as existsSync71, lstatSync as lstatSync27, mkdirSync as mkdirSync53, readFileSync as
|
|
69751
|
+
import { existsSync as existsSync71, lstatSync as lstatSync27, mkdirSync as mkdirSync53, readFileSync as readFileSync90, rmSync as rmSync30, writeFileSync as writeFileSync51 } from "fs";
|
|
69667
69752
|
import { spawnSync as spawnSync11 } from "child_process";
|
|
69668
|
-
import { dirname as
|
|
69753
|
+
import { dirname as dirname42, join as join103 } from "path";
|
|
69669
69754
|
import { createHash as createHash28 } from "crypto";
|
|
69670
69755
|
function contractEnabled(env = process.env) {
|
|
69671
69756
|
return env["LOKI_CONTRACT"] !== "0";
|
|
@@ -69732,7 +69817,7 @@ function assignCriteria(units, criteria2) {
|
|
|
69732
69817
|
return { units: out3, orphans: criteria2.filter((c) => !owned.has(c.id)) };
|
|
69733
69818
|
}
|
|
69734
69819
|
function groupContractPath(repoDir, groupId) {
|
|
69735
|
-
return
|
|
69820
|
+
return join103(repoDir, ".loki", "groups", groupId.replace(/[^A-Za-z0-9._-]/g, "_"), "contract.json");
|
|
69736
69821
|
}
|
|
69737
69822
|
function freezeGroupContract(repoDir, groupId, units, contract) {
|
|
69738
69823
|
const a = assignCriteria(units, contract.criteria);
|
|
@@ -69740,7 +69825,7 @@ function freezeGroupContract(repoDir, groupId, units, contract) {
|
|
|
69740
69825
|
return { ok: false, reason: `NOT PROVEN: group contract has ${a.orphans.length} criterion owned by no unit: ${a.orphans.map((o) => `${sanitizeCriterion(o.id)} ${sanitizeCriterion(o.text)}`).join("; ")}`, orphans: a.orphans };
|
|
69741
69826
|
const gc2 = { group: groupId, units: a.units, orphans: [] };
|
|
69742
69827
|
const path = groupContractPath(repoDir, groupId);
|
|
69743
|
-
mkdirSync53(
|
|
69828
|
+
mkdirSync53(dirname42(path), { recursive: true });
|
|
69744
69829
|
atomicWriteJson(path, gc2);
|
|
69745
69830
|
return { ok: true, path, contract: gc2 };
|
|
69746
69831
|
}
|
|
@@ -69797,7 +69882,7 @@ function untracedLines(trace) {
|
|
|
69797
69882
|
return trace.criteria.filter((c) => c.status === "no_match").map((c) => `contract ${sanitizeCriterion(c.id)} untraced (no keyword match in changed files): ${sanitizeCriterion(c.text)}`);
|
|
69798
69883
|
}
|
|
69799
69884
|
function contractPath(repoDir) {
|
|
69800
|
-
return
|
|
69885
|
+
return join103(repoDir, ".loki", "contract.json");
|
|
69801
69886
|
}
|
|
69802
69887
|
function readContract(repoDir) {
|
|
69803
69888
|
const p = contractPath(repoDir);
|
|
@@ -69813,7 +69898,7 @@ function readContract(repoDir) {
|
|
|
69813
69898
|
return { contract: null, notes: ["contract unreadable: too large"], sha256: null };
|
|
69814
69899
|
let raw2;
|
|
69815
69900
|
try {
|
|
69816
|
-
raw2 =
|
|
69901
|
+
raw2 = readFileSync90(p);
|
|
69817
69902
|
} catch {
|
|
69818
69903
|
return { contract: null, notes: ["contract unreadable: read failed"], sha256: null };
|
|
69819
69904
|
}
|
|
@@ -69885,9 +69970,9 @@ function main3(args) {
|
|
|
69885
69970
|
`);
|
|
69886
69971
|
return 2;
|
|
69887
69972
|
}
|
|
69888
|
-
const contract = parseContract(
|
|
69973
|
+
const contract = parseContract(readFileSync90(file, "utf8"), file);
|
|
69889
69974
|
const out3 = contractPath(repoRoot(process.cwd()));
|
|
69890
|
-
mkdirSync53(
|
|
69975
|
+
mkdirSync53(dirname42(out3), { recursive: true });
|
|
69891
69976
|
writeFileSync51(out3, JSON.stringify(contract, null, 2) + `
|
|
69892
69977
|
`);
|
|
69893
69978
|
process.stdout.write(renderContract(contract));
|
|
@@ -69944,7 +70029,7 @@ function fromSpecText(raw2) {
|
|
|
69944
70029
|
}
|
|
69945
70030
|
}
|
|
69946
70031
|
function fromPrdText(text3, python = "python3") {
|
|
69947
|
-
const script =
|
|
70032
|
+
const script = join103(REPO_ROOT, "autonomy", "lib", "requirements_contract.py");
|
|
69948
70033
|
if (!existsSync71(script))
|
|
69949
70034
|
return null;
|
|
69950
70035
|
const code = `import sys,json,importlib.util as u
|
|
@@ -69987,12 +70072,12 @@ function mapRequirements(reqs, ran2, revision) {
|
|
|
69987
70072
|
return { version: 1, revision, requirements: out3 };
|
|
69988
70073
|
}
|
|
69989
70074
|
function fromChecklist(lokiDir2) {
|
|
69990
|
-
const p =
|
|
70075
|
+
const p = join103(lokiDir2, "checklist", "checklist.json");
|
|
69991
70076
|
if (!existsSync71(p))
|
|
69992
70077
|
return null;
|
|
69993
70078
|
let doc;
|
|
69994
70079
|
try {
|
|
69995
|
-
doc = JSON.parse(
|
|
70080
|
+
doc = JSON.parse(readFileSync90(p, "utf8"));
|
|
69996
70081
|
} catch {
|
|
69997
70082
|
return null;
|
|
69998
70083
|
}
|
|
@@ -70024,7 +70109,7 @@ function writeRequirementsMap(repoDir, lokiDir2, reqs, ran2) {
|
|
|
70024
70109
|
if (!reqs || reqs.length === 0)
|
|
70025
70110
|
return null;
|
|
70026
70111
|
const m = mapRequirements(reqs, ran2, currentRevision(repoDir));
|
|
70027
|
-
atomicWriteJson(
|
|
70112
|
+
atomicWriteJson(join103(lokiDir2, "state", "requirements-map.json"), m);
|
|
70028
70113
|
return m;
|
|
70029
70114
|
} catch {
|
|
70030
70115
|
return null;
|
|
@@ -70036,17 +70121,17 @@ function writeFromChecklist(repoDir, lokiDir2) {
|
|
|
70036
70121
|
}
|
|
70037
70122
|
function writeFromEngine10(repoDir, lokiDir2, runDir, task, events2) {
|
|
70038
70123
|
let reqs = null;
|
|
70039
|
-
const snap =
|
|
70124
|
+
const snap = join103(runDir, "spec.snapshot.md");
|
|
70040
70125
|
if (existsSync71(snap)) {
|
|
70041
70126
|
try {
|
|
70042
|
-
reqs = fromSpecText(
|
|
70127
|
+
reqs = fromSpecText(readFileSync90(snap, "utf8"));
|
|
70043
70128
|
} catch {
|
|
70044
70129
|
reqs = null;
|
|
70045
70130
|
}
|
|
70046
70131
|
}
|
|
70047
70132
|
if (!reqs && task)
|
|
70048
70133
|
reqs = fromPrdText(task);
|
|
70049
|
-
const mapPath =
|
|
70134
|
+
const mapPath = join103(lokiDir2, "state", "requirements-map.json");
|
|
70050
70135
|
if (!reqs || reqs.length === 0) {
|
|
70051
70136
|
try {
|
|
70052
70137
|
rmSync30(mapPath, { force: true });
|
|
@@ -70072,7 +70157,7 @@ function uncoveredCount(m) {
|
|
|
70072
70157
|
}
|
|
70073
70158
|
function readRequirementsMap(lokiDir2) {
|
|
70074
70159
|
try {
|
|
70075
|
-
const m = JSON.parse(
|
|
70160
|
+
const m = JSON.parse(readFileSync90(join103(lokiDir2, "state", "requirements-map.json"), "utf8"));
|
|
70076
70161
|
return m.version === 1 && Array.isArray(m.requirements) ? m : null;
|
|
70077
70162
|
} catch {
|
|
70078
70163
|
return null;
|
|
@@ -70100,17 +70185,17 @@ var init_contract = __esm(() => {
|
|
|
70100
70185
|
BULLET = /^\s*(?:[-*+]|\d+[.)])\s+(.+)$/;
|
|
70101
70186
|
STOP3 = new Set(["the", "and", "for", "with", "that", "this", "must", "should", "shall", "when", "then", "are", "was", "all", "any", "can", "not", "has", "have", "from", "into", "each", "user", "users"]);
|
|
70102
70187
|
MAX_CONTRACT_BYTES = 1024 * 1024;
|
|
70103
|
-
REQ_MAP_REL =
|
|
70188
|
+
REQ_MAP_REL = join103(".loki", "state", "requirements-map.json");
|
|
70104
70189
|
REQ_STOP = new Set(["with", "that", "this", "from", "have", "will", "should", "must", "when", "then", "into", "each", "every", "user", "users", "page", "able", "allow", "support", "ensure", "using", "their", "there", "which", "shall"]);
|
|
70105
70190
|
LINK_RE = /\s*\[checks?:\s*([^\]]+)\]\s*$/i;
|
|
70106
70191
|
});
|
|
70107
70192
|
|
|
70108
70193
|
// ../../loki-ts/src/features/speed/seal_group.ts
|
|
70109
70194
|
import { createHash as createHash29 } from "crypto";
|
|
70110
|
-
import { existsSync as existsSync72, mkdirSync as mkdirSync54, readdirSync as readdirSync30, readFileSync as
|
|
70111
|
-
import { dirname as
|
|
70195
|
+
import { existsSync as existsSync72, mkdirSync as mkdirSync54, readdirSync as readdirSync30, readFileSync as readFileSync91, renameSync as renameSync20, statSync as statSync26, writeFileSync as writeFileSync52 } from "fs";
|
|
70196
|
+
import { dirname as dirname43, join as join104 } from "path";
|
|
70112
70197
|
function sealGroup(runDir, rh) {
|
|
70113
|
-
const manifestPath =
|
|
70198
|
+
const manifestPath = join104(runDir, "group", "manifest.json");
|
|
70114
70199
|
if (!existsSync72(manifestPath))
|
|
70115
70200
|
return { section: undefined, notProven: [], problems: 0, allUnitsPass: true };
|
|
70116
70201
|
const notProven = [];
|
|
@@ -70135,10 +70220,10 @@ function sealGroup(runDir, rh) {
|
|
|
70135
70220
|
return fail2(`unit ${index2} has an invalid, duplicate or case-colliding id`);
|
|
70136
70221
|
seen.add(id2);
|
|
70137
70222
|
seenLower.add(id2.toLowerCase());
|
|
70138
|
-
const dir =
|
|
70223
|
+
const dir = join104(unitsDir(runDir), id2), rp = join104(dir, "receipt.json"), ep2 = join104(dir, "events.jsonl");
|
|
70139
70224
|
let bytes;
|
|
70140
70225
|
try {
|
|
70141
|
-
bytes =
|
|
70226
|
+
bytes = readFileSync91(rp);
|
|
70142
70227
|
} catch {
|
|
70143
70228
|
return fail2(`unit ${id2} sub-receipt missing`);
|
|
70144
70229
|
}
|
|
@@ -70157,7 +70242,7 @@ function sealGroup(runDir, rh) {
|
|
|
70157
70242
|
unit_id: id2,
|
|
70158
70243
|
sub_receipt_sha256: sha4(bytes),
|
|
70159
70244
|
receipt_sha256: sub["receipt_sha256"],
|
|
70160
|
-
events_file_sha256: existsSync72(ep2) ? sha4(
|
|
70245
|
+
events_file_sha256: existsSync72(ep2) ? sha4(readFileSync91(ep2)) : null,
|
|
70161
70246
|
verdict,
|
|
70162
70247
|
goal: text3(u10["goal"], 200),
|
|
70163
70248
|
files: (Array.isArray(u10["files"]) ? u10["files"] : []).map((f) => text3(f, 200)).filter(Boolean).slice(0, 50),
|
|
@@ -70177,12 +70262,12 @@ function capGroupVerdict(v3, g) {
|
|
|
70177
70262
|
return !g.allUnitsPass && (v3 === "VERIFIED" || v3 === "ALREADY_SATISFIED") ? "PARTIAL" : v3;
|
|
70178
70263
|
}
|
|
70179
70264
|
async function verifyGroup(receiptPath, receipt, rh, verifyOne, deps = {}) {
|
|
70180
|
-
const runDir =
|
|
70265
|
+
const runDir = dirname43(receiptPath);
|
|
70181
70266
|
const signed = isObj10(receipt["verification"]) && typeof receipt["verification"]["jwt"] === "string";
|
|
70182
70267
|
const bad = (reason) => ({ verdict: "TAMPERED", reason: `group: ${reason}` });
|
|
70183
70268
|
const g = receipt["group"];
|
|
70184
70269
|
if (g === undefined)
|
|
70185
|
-
return existsSync72(
|
|
70270
|
+
return existsSync72(join104(runDir, "group", "manifest.json")) ? bad("group directory present but the receipt has no group section") : null;
|
|
70186
70271
|
if (!isObj10(g) || !ID_RE.test(String(g["group_id"] ?? "")) || !Array.isArray(g["units"]) || g["units"].length === 0)
|
|
70187
70272
|
return bad("group section malformed");
|
|
70188
70273
|
const entries = g["units"];
|
|
@@ -70194,20 +70279,20 @@ async function verifyGroup(receiptPath, receipt, rh, verifyOne, deps = {}) {
|
|
|
70194
70279
|
return bad("unit directories do not match the receipt (missing or extra unit)");
|
|
70195
70280
|
let unchecked = null;
|
|
70196
70281
|
for (let i = 0;i < entries.length; i++) {
|
|
70197
|
-
const e10 = entries[i], id2 = ids[i], dir =
|
|
70282
|
+
const e10 = entries[i], id2 = ids[i], dir = join104(unitsDir(runDir), id2), rp = join104(dir, "receipt.json"), ep2 = join104(dir, "events.jsonl");
|
|
70198
70283
|
if (e10["index"] !== i)
|
|
70199
70284
|
return bad(`unit ${id2} is out of order (index ${String(e10["index"])} at position ${i})`);
|
|
70200
70285
|
let bytes;
|
|
70201
70286
|
try {
|
|
70202
70287
|
if (!statSync26(dir).isDirectory())
|
|
70203
70288
|
return bad(`unit ${id2} is not a directory`);
|
|
70204
|
-
bytes =
|
|
70289
|
+
bytes = readFileSync91(rp);
|
|
70205
70290
|
} catch {
|
|
70206
70291
|
return bad(`unit ${id2} sub-receipt missing`);
|
|
70207
70292
|
}
|
|
70208
70293
|
if (sha4(bytes) !== e10["sub_receipt_sha256"])
|
|
70209
70294
|
return bad(`unit ${id2} sub-receipt does not match its recorded hash`);
|
|
70210
|
-
const evSha = existsSync72(ep2) ? sha4(
|
|
70295
|
+
const evSha = existsSync72(ep2) ? sha4(readFileSync91(ep2)) : null;
|
|
70211
70296
|
if (evSha !== (e10["events_file_sha256"] ?? null))
|
|
70212
70297
|
return bad(`unit ${id2} events.jsonl does not match its recorded hash`);
|
|
70213
70298
|
const sub = readJson7(rp);
|
|
@@ -70236,7 +70321,7 @@ function composeGroupReceipt(groupDir, rh, o) {
|
|
|
70236
70321
|
const body = { schema: GROUP_SCHEMA, run_id: gid, verdict, base_sha: o.baseRef, head_sha: o.head, not_proven: seal.notProven, group: seal.section };
|
|
70237
70322
|
const hash = rh(body), sig = signReceipt(gid, hash);
|
|
70238
70323
|
const receipt = { ...body, receipt_sha256: hash, verification: { jwt: sig.jwt, kid: sig.kid } };
|
|
70239
|
-
const path =
|
|
70324
|
+
const path = join104(groupDir, "receipt.json"), tmp = `${path}.${process.pid}.tmp`;
|
|
70240
70325
|
mkdirSync54(groupDir, { recursive: true });
|
|
70241
70326
|
writeFileSync52(tmp, JSON.stringify(receipt, null, 2) + `
|
|
70242
70327
|
`);
|
|
@@ -70248,9 +70333,9 @@ function compositeVerdict(childVerdicts) {
|
|
|
70248
70333
|
const failed2 = childVerdicts.filter((v3) => v3 === "FAILED" || !["VERIFIED", "ALREADY_SATISFIED", "PARTIAL", "SPEC_CONFLICT"].includes(v3)).length;
|
|
70249
70334
|
return capGroupVerdict(base, { section: undefined, notProven: [], problems: failed2, allUnitsPass: childVerdicts.every((v3) => PASSING.has(v3)) });
|
|
70250
70335
|
}
|
|
70251
|
-
var ID_RE, PASSING, sha4 = (b) => createHash29("sha256").update(b).digest("hex"), isObj10 = (v3) => v3 !== null && typeof v3 === "object" && !Array.isArray(v3), text3 = (v3, cap) => typeof v3 === "string" ? v3.replace(/[\x00-\x1f\x7f]+/g, " ").trim().slice(0, cap) : "", num4 = (v3) => typeof v3 === "number" && Number.isFinite(v3) && v3 >= 0 ? v3 : 0, unitsDir = (runDir) =>
|
|
70336
|
+
var ID_RE, PASSING, sha4 = (b) => createHash29("sha256").update(b).digest("hex"), isObj10 = (v3) => v3 !== null && typeof v3 === "object" && !Array.isArray(v3), text3 = (v3, cap) => typeof v3 === "string" ? v3.replace(/[\x00-\x1f\x7f]+/g, " ").trim().slice(0, cap) : "", num4 = (v3) => typeof v3 === "number" && Number.isFinite(v3) && v3 >= 0 ? v3 : 0, unitsDir = (runDir) => join104(runDir, "group", "units"), readJson7 = (p) => {
|
|
70252
70337
|
try {
|
|
70253
|
-
return JSON.parse(
|
|
70338
|
+
return JSON.parse(readFileSync91(p, "utf8"));
|
|
70254
70339
|
} catch {
|
|
70255
70340
|
return;
|
|
70256
70341
|
}
|
|
@@ -70268,8 +70353,8 @@ var init_seal_group = __esm(() => {
|
|
|
70268
70353
|
});
|
|
70269
70354
|
|
|
70270
70355
|
// ../../loki-ts/src/supply/supply_guard.ts
|
|
70271
|
-
import { existsSync as existsSync73, readFileSync as
|
|
70272
|
-
import { basename as basename27, join as
|
|
70356
|
+
import { existsSync as existsSync73, readFileSync as readFileSync92, statSync as statSync27 } from "fs";
|
|
70357
|
+
import { basename as basename27, join as join105 } from "path";
|
|
70273
70358
|
function supplyEnabled(env) {
|
|
70274
70359
|
return env["LOKI_SUPPLY_GUARD"] !== "0";
|
|
70275
70360
|
}
|
|
@@ -70284,13 +70369,13 @@ function isManifestPath(path) {
|
|
|
70284
70369
|
return MANIFESTS2.test(basename27(path));
|
|
70285
70370
|
}
|
|
70286
70371
|
function readDeclared(repoDir) {
|
|
70287
|
-
const p =
|
|
70372
|
+
const p = join105(repoDir, ".loki", DECLARED_FILE);
|
|
70288
70373
|
if (!existsSync73(p))
|
|
70289
70374
|
return { deps: [], problem: null };
|
|
70290
70375
|
try {
|
|
70291
70376
|
if (statSync27(p).size > MAX_FILE_BYTES)
|
|
70292
70377
|
return { deps: [], problem: "declaration file too large" };
|
|
70293
|
-
const j10 = JSON.parse(
|
|
70378
|
+
const j10 = JSON.parse(readFileSync92(p, "utf8"));
|
|
70294
70379
|
if (!Array.isArray(j10))
|
|
70295
70380
|
return { deps: [], problem: "declaration is not a JSON array" };
|
|
70296
70381
|
const deps = [];
|
|
@@ -70310,11 +70395,11 @@ function readDeclared(repoDir) {
|
|
|
70310
70395
|
}
|
|
70311
70396
|
}
|
|
70312
70397
|
function readAllowlist(repoDir) {
|
|
70313
|
-
const p =
|
|
70398
|
+
const p = join105(repoDir, ".loki", "supply-allowlist");
|
|
70314
70399
|
if (!existsSync73(p))
|
|
70315
70400
|
return new Set;
|
|
70316
70401
|
try {
|
|
70317
|
-
return new Set(
|
|
70402
|
+
return new Set(readFileSync92(p, "utf8").split(`
|
|
70318
70403
|
`).map((l) => l.replace(/#.*$/, "").trim()).filter(Boolean));
|
|
70319
70404
|
} catch {
|
|
70320
70405
|
return new Set;
|
|
@@ -70355,7 +70440,7 @@ function userConfigPrivate(eco, repoDir, env, goEnv = {}, name = "") {
|
|
|
70355
70440
|
if (eco === "npm") {
|
|
70356
70441
|
if (privateUrlList([env["npm_config_registry"] ?? "", env["NPM_CONFIG_REGISTRY"] ?? ""]))
|
|
70357
70442
|
return true;
|
|
70358
|
-
return files(
|
|
70443
|
+
return files(join105(repoDir, ".npmrc"), home ? join105(home, ".npmrc") : "").some((t) => t.split(`
|
|
70359
70444
|
`).some((l) => {
|
|
70360
70445
|
const m = /^\s*(?:(@[^:\s]+):)?registry\s*=\s*(\S+)/.exec(l);
|
|
70361
70446
|
return !!m && privateUrl(m[2]) && (m[1] === undefined || name.startsWith(`${m[1]}/`));
|
|
@@ -70364,7 +70449,7 @@ function userConfigPrivate(eco, repoDir, env, goEnv = {}, name = "") {
|
|
|
70364
70449
|
if (eco === "pypi") {
|
|
70365
70450
|
if (privateUrlList([env["PIP_INDEX_URL"] ?? "", env["PIP_EXTRA_INDEX_URL"] ?? ""]))
|
|
70366
70451
|
return true;
|
|
70367
|
-
const cfg = [env["PIP_CONFIG_FILE"] ?? "", home ?
|
|
70452
|
+
const cfg = [env["PIP_CONFIG_FILE"] ?? "", home ? join105(home, ".config", "pip", "pip.conf") : "", home ? join105(home, ".pip", "pip.conf") : "", join105(repoDir, "pip.conf")];
|
|
70368
70453
|
return files(...cfg).some((t) => t.split(`
|
|
70369
70454
|
`).some((l) => {
|
|
70370
70455
|
const m = /^\s*(?:extra-)?index-url\s*[=:]\s*(.+)$/.exec(l);
|
|
@@ -70374,7 +70459,7 @@ function userConfigPrivate(eco, repoDir, env, goEnv = {}, name = "") {
|
|
|
70374
70459
|
if (eco === "cargo") {
|
|
70375
70460
|
if (Object.keys(env).some((k3) => /^CARGO_REGISTRIES_.+_INDEX$/.test(k3) || /^CARGO_SOURCE_/.test(k3)))
|
|
70376
70461
|
return true;
|
|
70377
|
-
return files(
|
|
70462
|
+
return files(join105(repoDir, ".cargo", "config.toml"), join105(repoDir, ".cargo", "config"), home ? join105(home, ".cargo", "config.toml") : "", home ? join105(home, ".cargo", "config") : "").some((t) => /^\s*\[(registries\.|source\.)/m.test(t) || /replace-with\s*=/.test(t));
|
|
70378
70463
|
}
|
|
70379
70464
|
if (eco === "go") {
|
|
70380
70465
|
const gp2 = goEnv["GOPROXY"] ?? env["GOPROXY"] ?? "";
|
|
@@ -70497,7 +70582,7 @@ var MIN_AGE_DAYS = 7, DECLARED_FILE = "supply-declared.json", MAX_CHECKED = 50,
|
|
|
70497
70582
|
}
|
|
70498
70583
|
}, PUBLIC_HOSTS, hostOf = (u10) => u10.trim().toLowerCase().replace(/^[a-z][a-z0-9+.-]*:\/\//, "").replace(/^www\./, "").split(/[/?#\s]/)[0].replace(/^[^@]*@/, "").replace(/:\d+$/, ""), privateUrl = (u10) => /[a-z0-9]/i.test(u10) && !PUBLIC_HOSTS.has(hostOf(u10)), readSmall = (p) => {
|
|
70499
70584
|
try {
|
|
70500
|
-
return statSync27(p).size <= MAX_FILE_BYTES ?
|
|
70585
|
+
return statSync27(p).size <= MAX_FILE_BYTES ? readFileSync92(p, "utf8") : "";
|
|
70501
70586
|
} catch {
|
|
70502
70587
|
return "";
|
|
70503
70588
|
}
|
|
@@ -70536,8 +70621,8 @@ __export(exports_seal, {
|
|
|
70536
70621
|
AGENT_ONLY_REASON: () => AGENT_ONLY_REASON
|
|
70537
70622
|
});
|
|
70538
70623
|
import { createHash as createHash30 } from "crypto";
|
|
70539
|
-
import { existsSync as existsSync74, readdirSync as readdirSync31, mkdirSync as mkdirSync55, readFileSync as
|
|
70540
|
-
import { basename as basename28, isAbsolute as isAbsolute20, join as
|
|
70624
|
+
import { existsSync as existsSync74, readdirSync as readdirSync31, mkdirSync as mkdirSync55, readFileSync as readFileSync93 } from "fs";
|
|
70625
|
+
import { basename as basename28, isAbsolute as isAbsolute20, join as join106, relative as relative24 } from "path";
|
|
70541
70626
|
async function leanSymbolGap(ctx, o, rawDiff, head, vraw) {
|
|
70542
70627
|
if (externalRun(o) || Array.isArray(o.wall?.files) && o.wall.files.length > 0 || o.intake?.already_satisfied === true || o.implement?.exit === "already_done")
|
|
70543
70628
|
return [];
|
|
@@ -70558,7 +70643,7 @@ async function leanSymbolGap(ctx, o, rawDiff, head, vraw) {
|
|
|
70558
70643
|
const n11 = String(c.name ?? ""), p = n11.slice(n11.indexOf(":") + 1);
|
|
70559
70644
|
if (n11.includes(":") && isTestFile(p))
|
|
70560
70645
|
try {
|
|
70561
|
-
sources2.push(
|
|
70646
|
+
sources2.push(readFileSync93(join106(ctx.repoDir, p), "utf8"));
|
|
70562
70647
|
} catch {}
|
|
70563
70648
|
}
|
|
70564
70649
|
return symbolGap(changedSymbols(d.stdout), sources2);
|
|
@@ -70641,7 +70726,7 @@ function renderReceiptMd(r) {
|
|
|
70641
70726
|
`);
|
|
70642
70727
|
}
|
|
70643
70728
|
var SIGNING_UNAVAILABLE = "receipt signing unavailable (no usable signing key: invalid key or unwritable ~/.loki/keys)", AGENT_ONLY_REASON = "only agent-authored tests executed (no agent-independent proof)", WALL_GREEN_ON_BASE_REASON = "Wall green on base: no Wall test discriminates the change", EXCLUDE_LOKI = ":(exclude).loki", sha2562 = (s) => createHash30("sha256").update(s).digest("hex"), str3 = (v3) => typeof v3 === "string" && v3 !== "" ? v3 : null, EXTERNAL_MODEL_LABEL = "external (no Loki implement session)", EXTERNAL_DIFF_NOT_ISOLATED = "Wall author not filesystem-isolated from the external diff", EXTERNAL_NO_WALL = "external diff sealed with no Wall file that ran; the only checks are the repo's existing tests", externalRun = (o) => o.implement?.exit === "external", LEAN_NO_SYMBOL = "no passing check references a changed symbol and no Wall file ran", strs2 = (v3) => Array.isArray(v3) ? v3.filter((x3) => typeof x3 === "string" && x3 !== "") : [], g = (ctx) => (a) => git9(ctx, a), receiptRel = (ctx) => {
|
|
70644
|
-
const r = relative24(ctx.repoDir,
|
|
70729
|
+
const r = relative24(ctx.repoDir, join106(ctx.runDir, "receipt.json"));
|
|
70645
70730
|
return r.startsWith("..") || isAbsolute20(r) ? `.loki/runs/${ctx.runId}/receipt.json` : r;
|
|
70646
70731
|
}, commitStage, wallGreenOnBaseOf = (o) => {
|
|
70647
70732
|
const b = o.wall?.base_run ?? {};
|
|
@@ -70783,7 +70868,7 @@ var init_seal = __esm(() => {
|
|
|
70783
70868
|
if (wallNotRun > 0) {
|
|
70784
70869
|
try {
|
|
70785
70870
|
const kept = new Set((Array.isArray(o.wall?.files) ? o.wall.files : []).map((f) => basename28(String(f.path))));
|
|
70786
|
-
for (const n11 of readdirSync31(
|
|
70871
|
+
for (const n11 of readdirSync31(join106(ctx.runDir, "wall")).sort())
|
|
70787
70872
|
if (!kept.has(n11))
|
|
70788
70873
|
notProven.add(`wall test discarded: ${n11} (not_run)`);
|
|
70789
70874
|
} catch {}
|
|
@@ -70854,19 +70939,19 @@ var init_seal = __esm(() => {
|
|
|
70854
70939
|
for (const [s, d] of Object.entries(o))
|
|
70855
70940
|
if (typeof d?.duration_s === "number")
|
|
70856
70941
|
stages[s] = d.duration_s;
|
|
70857
|
-
const T = hooks.time, time = T ? T.build(ctx, stages, T.firstEventMs(
|
|
70942
|
+
const T = hooks.time, time = T ? T.build(ctx, stages, T.firstEventMs(join106(ctx.runDir, "events.jsonl"))) : { wall_s: Object.values(stages).reduce((a, b) => a + (b ?? 0), 0), stages }, totalS = T?.reconciled(time) ?? null;
|
|
70858
70943
|
const iterIds = [...new Set([...Object.values(o).flatMap((d) => [...strs2(d?.iteration_ids), ...strs2([d?.iteration_id])]), ...ctx.sessionIds?.() ?? [], ...xr2?.cost_iteration ? [xr2.cost_iteration] : []])];
|
|
70859
70944
|
if (iterIds.length === 0)
|
|
70860
70945
|
notProven.add("cost not measured (no iteration ids recorded)");
|
|
70861
70946
|
const cost = ctx.cost.read(ctx.repoDir, iterIds);
|
|
70862
70947
|
if (cost.unmetered)
|
|
70863
70948
|
notProven.add("cost unmetered (CLI invoker; recorded as 0)");
|
|
70864
|
-
const eventsPath =
|
|
70949
|
+
const eventsPath = join106(ctx.runDir, "events.jsonl");
|
|
70865
70950
|
const wallFiles = Array.isArray(o.wall?.files) ? o.wall.files : [];
|
|
70866
70951
|
const wallPassed = typeof o.verify?.wall_passed === "boolean" ? o.verify.wall_passed : null;
|
|
70867
70952
|
if (wallFiles.length > 0 && wallPassed === null)
|
|
70868
70953
|
notProven.add("wall result not recorded by verify");
|
|
70869
|
-
const routeBlock = buildRouteBlock(process.env, ctx.provider, o.implement?.route ?? o.plan?.route_record ?? (routerEnabled(process.env) ? loadRouteRecord(ctx.runDir) : undefined), cost.router ?? (routerEnabled(process.env) ? sumResultCosts(
|
|
70954
|
+
const routeBlock = buildRouteBlock(process.env, ctx.provider, o.implement?.route ?? o.plan?.route_record ?? (routerEnabled(process.env) ? loadRouteRecord(ctx.runDir) : undefined), cost.router ?? (routerEnabled(process.env) ? sumResultCosts(join106(ctx.repoDir, ".loki"), liveArchivedCosts(join106(ctx.repoDir, ".loki"), iterIds, UNMETERED)).router : undefined), ctx.model);
|
|
70870
70955
|
if (routeBlock)
|
|
70871
70956
|
for (const l of routeNotProven(routeBlock))
|
|
70872
70957
|
notProven.add(l);
|
|
@@ -70909,7 +70994,7 @@ var init_seal = __esm(() => {
|
|
|
70909
70994
|
model: externalRun(o) ? EXTERNAL_MODEL_LABEL : ctx.model,
|
|
70910
70995
|
...externalRun(o) ? { implement: { exit: "external", patch_sha256: str3(o.implement?.patch_sha256) ?? "" } } : {},
|
|
70911
70996
|
resumed: o.intake?.resumed === true,
|
|
70912
|
-
events_sha256: sha2562(existsSync74(eventsPath) ?
|
|
70997
|
+
events_sha256: sha2562(existsSync74(eventsPath) ? readFileSync93(eventsPath) : ""),
|
|
70913
70998
|
...await sealEvidence(ctx.repoDir, ctx.runDir, o, notProven, signal, ctx.emit),
|
|
70914
70999
|
log_seal: true,
|
|
70915
71000
|
toolchain: collectToolchain(),
|
|
@@ -70937,10 +71022,10 @@ var init_seal = __esm(() => {
|
|
|
70937
71022
|
}
|
|
70938
71023
|
const receipt = { ...body, receipt_sha256: hash, verification: { jwt: sig.jwt, kid: sig.kid } };
|
|
70939
71024
|
mkdirSync55(ctx.runDir, { recursive: true });
|
|
70940
|
-
const path =
|
|
71025
|
+
const path = join106(ctx.runDir, "receipt.json");
|
|
70941
71026
|
atomicWriteText(path, JSON.stringify(receipt, null, 2) + `
|
|
70942
71027
|
`);
|
|
70943
|
-
atomicWriteText(
|
|
71028
|
+
atomicWriteText(join106(ctx.runDir, "receipt.md"), renderReceiptMd(receipt));
|
|
70944
71029
|
recordRun(process.env, ctx.repoDir, ranModel(o.implement, ctx.model, o.fix), verdict, cost.usd, cost.unmetered === true, totalS);
|
|
70945
71030
|
try {
|
|
70946
71031
|
hooks.sealed?.(ctx.runDir, JSON.parse(JSON.stringify(receipt), (_k2, v3) => v3 && typeof v3 === "object" ? Object.freeze(v3) : v3));
|
|
@@ -71014,7 +71099,7 @@ var init_github_token = __esm(() => {
|
|
|
71014
71099
|
// ../../loki-ts/src/engine10/fetch_issue.ts
|
|
71015
71100
|
import { execFileSync as execFileSync7 } from "child_process";
|
|
71016
71101
|
import { writeFileSync as writeFileSync54 } from "fs";
|
|
71017
|
-
import { join as
|
|
71102
|
+
import { join as join107 } from "path";
|
|
71018
71103
|
function defaultExec(cmd, args) {
|
|
71019
71104
|
const ms = Number(process.env.LOKI_FETCH_ISSUE_TIMEOUT_MS) || 60000;
|
|
71020
71105
|
return execFileSync7(cmd, args, { encoding: "utf8", env: process.env, timeout: ms, killSignal: "SIGKILL" });
|
|
@@ -71041,7 +71126,7 @@ function fetchIssueToFile(ref, outFile, exec = defaultExec) {
|
|
|
71041
71126
|
var ISSUE_PROVIDERS_SH;
|
|
71042
71127
|
var init_fetch_issue = __esm(() => {
|
|
71043
71128
|
init_paths();
|
|
71044
|
-
ISSUE_PROVIDERS_SH =
|
|
71129
|
+
ISSUE_PROVIDERS_SH = join107(REPO_ROOT, "autonomy/issue-providers.sh");
|
|
71045
71130
|
if (false) {}
|
|
71046
71131
|
});
|
|
71047
71132
|
|
|
@@ -71589,14 +71674,14 @@ var init_capability = __esm(() => {
|
|
|
71589
71674
|
var init_raster = () => {};
|
|
71590
71675
|
|
|
71591
71676
|
// ../../loki-ts/src/commands/doctor.ts
|
|
71592
|
-
import { appendFileSync as appendFileSync11, writeFileSync as writeFileSync56, mkdirSync as mkdirSync56, accessSync as accessSync2, constants as fsConstants2, existsSync as existsSync75, lstatSync as lstatSync28, readdirSync as readdirSync32, readFileSync as
|
|
71677
|
+
import { appendFileSync as appendFileSync11, writeFileSync as writeFileSync56, mkdirSync as mkdirSync56, accessSync as accessSync2, constants as fsConstants2, existsSync as existsSync75, lstatSync as lstatSync28, readdirSync as readdirSync32, readFileSync as readFileSync94, readlinkSync as readlinkSync6, realpathSync as realpathSync31, statSync as statSync29, statfsSync } from "fs";
|
|
71593
71678
|
import { spawnSync as spawnSync12 } from "child_process";
|
|
71594
71679
|
import { homedir as homedir12, tmpdir as tmpdir18 } from "os";
|
|
71595
|
-
import { join as
|
|
71680
|
+
import { join as join108, resolve as resolve31 } from "path";
|
|
71596
71681
|
function loadRequirements(file = REQUIREMENTS_FILE) {
|
|
71597
71682
|
if (file === REQUIREMENTS_FILE && cached)
|
|
71598
71683
|
return cached;
|
|
71599
|
-
const t = JSON.parse(
|
|
71684
|
+
const t = JSON.parse(readFileSync94(file, "utf8"));
|
|
71600
71685
|
if (file === REQUIREMENTS_FILE)
|
|
71601
71686
|
cached = t;
|
|
71602
71687
|
return t;
|
|
@@ -71627,7 +71712,7 @@ function providerLoginIssue(provider, cli, env) {
|
|
|
71627
71712
|
const said = `${r.stdout}${r.stderr}`;
|
|
71628
71713
|
return /not logged in/i.test(said) || classifyFailure(said).reason === "auth" ? { fatal: "codex is not logged in; run: codex login (or set OPENAI_API_KEY)" } : { warn: "could not confirm the Codex login (codex login status gave no answer); continuing" };
|
|
71629
71714
|
}
|
|
71630
|
-
if (PROVIDER_API_KEY_VARS.some(key) || provider === "opencode" && existsSync75(
|
|
71715
|
+
if (PROVIDER_API_KEY_VARS.some(key) || provider === "opencode" && existsSync75(join108(env.XDG_DATA_HOME || join108(home, ".local", "share"), "opencode", "auth.json")) || provider === "cline" && existsSync75(join108(home, ".cline")))
|
|
71631
71716
|
return null;
|
|
71632
71717
|
return provider === "aider" || provider === "opencode" || provider === "cline" ? { warn: `no ${provider} login or API key found (set a provider API key such as ANTHROPIC_API_KEY or OPENAI_API_KEY${provider === "opencode" ? ", or run: opencode auth login" : ""}); continuing` } : null;
|
|
71633
71718
|
}
|
|
@@ -71638,9 +71723,9 @@ function providerAuthPath(provider, env) {
|
|
|
71638
71723
|
const v3 = own.find(set);
|
|
71639
71724
|
if (v3)
|
|
71640
71725
|
return `${v3 === "CLAUDE_CODE_OAUTH_TOKEN" ? "oauth_token" : "api_key"}:${v3}`;
|
|
71641
|
-
if (provider === "opencode" && existsSync75(
|
|
71726
|
+
if (provider === "opencode" && existsSync75(join108(env.XDG_DATA_HOME || join108(home, ".local", "share"), "opencode", "auth.json")))
|
|
71642
71727
|
return "cli_login:opencode";
|
|
71643
|
-
if (provider === "cline" && existsSync75(
|
|
71728
|
+
if (provider === "cline" && existsSync75(join108(home, ".cline")))
|
|
71644
71729
|
return "cli_login:cline";
|
|
71645
71730
|
return provider === "claude" || provider === "codex" ? `cli_login:${provider}` : "none";
|
|
71646
71731
|
}
|
|
@@ -71665,9 +71750,9 @@ function claudeAuthStatusLoggedIn(cli = "claude", env = process.env) {
|
|
|
71665
71750
|
}
|
|
71666
71751
|
}
|
|
71667
71752
|
function claudeLoginProbeCached(cli, env = process.env, now2 = Date.now()) {
|
|
71668
|
-
const file =
|
|
71753
|
+
const file = join108(env.HOME || homedir12(), ".loki", "claude-login-ok.json");
|
|
71669
71754
|
try {
|
|
71670
|
-
const c = JSON.parse(
|
|
71755
|
+
const c = JSON.parse(readFileSync94(file, "utf8"));
|
|
71671
71756
|
if (c?.cli === cli && typeof c.at === "number" && now2 - c.at >= 0 && now2 - c.at < CLAUDE_LOGIN_TTL_MS)
|
|
71672
71757
|
return "yes";
|
|
71673
71758
|
} catch {}
|
|
@@ -71676,7 +71761,7 @@ function claudeLoginProbeCached(cli, env = process.env, now2 = Date.now()) {
|
|
|
71676
71761
|
li2 = claudeAuthStatusLoggedIn(cli, env);
|
|
71677
71762
|
if (li2 === "yes") {
|
|
71678
71763
|
try {
|
|
71679
|
-
mkdirSync56(
|
|
71764
|
+
mkdirSync56(join108(file, ".."), { recursive: true });
|
|
71680
71765
|
writeFileSync56(file, JSON.stringify({ cli, at: now2 }));
|
|
71681
71766
|
} catch {}
|
|
71682
71767
|
}
|
|
@@ -71685,16 +71770,16 @@ function claudeLoginProbeCached(cli, env = process.env, now2 = Date.now()) {
|
|
|
71685
71770
|
async function ghAuthProbeCached(env, probe, now2 = Date.now()) {
|
|
71686
71771
|
const bin = "gh";
|
|
71687
71772
|
const gh = Bun.which(bin, { PATH: env.PATH ?? process.env.PATH ?? "" }) ?? bin;
|
|
71688
|
-
const file =
|
|
71773
|
+
const file = join108(env.HOME || homedir12(), ".loki", "gh-auth-ok.json");
|
|
71689
71774
|
try {
|
|
71690
|
-
const c = JSON.parse(
|
|
71775
|
+
const c = JSON.parse(readFileSync94(file, "utf8"));
|
|
71691
71776
|
if (c?.gh === gh && typeof c.at === "number" && now2 - c.at >= 0 && now2 - c.at < CLAUDE_LOGIN_TTL_MS)
|
|
71692
71777
|
return true;
|
|
71693
71778
|
} catch {}
|
|
71694
71779
|
const ok3 = await probe();
|
|
71695
71780
|
if (ok3) {
|
|
71696
71781
|
try {
|
|
71697
|
-
mkdirSync56(
|
|
71782
|
+
mkdirSync56(join108(file, ".."), { recursive: true });
|
|
71698
71783
|
writeFileSync56(file, JSON.stringify({ gh, at: now2 }));
|
|
71699
71784
|
} catch {}
|
|
71700
71785
|
}
|
|
@@ -71769,7 +71854,7 @@ var init_first_run_repo = __esm(() => {
|
|
|
71769
71854
|
|
|
71770
71855
|
// ../../loki-ts/src/engine10/preflight.ts
|
|
71771
71856
|
import { accessSync as accessSync3, constants as fsc2, mkdirSync as mkdirSync57, statfsSync as statfsSync2, writeFileSync as writeFileSync57 } from "fs";
|
|
71772
|
-
import { join as
|
|
71857
|
+
import { join as join109 } from "path";
|
|
71773
71858
|
async function sh3(argv, opts) {
|
|
71774
71859
|
try {
|
|
71775
71860
|
return await run(argv, opts);
|
|
@@ -71853,7 +71938,7 @@ async function checkPreflight(o) {
|
|
|
71853
71938
|
if (o.runDir) {
|
|
71854
71939
|
try {
|
|
71855
71940
|
mkdirSync57(o.runDir, { recursive: true });
|
|
71856
|
-
writeFileSync57(
|
|
71941
|
+
writeFileSync57(join109(o.runDir, "preflight.json"), JSON.stringify({ provider: o.provider, auth_path, probe }) + `
|
|
71857
71942
|
`);
|
|
71858
71943
|
} catch {}
|
|
71859
71944
|
}
|
|
@@ -71901,7 +71986,7 @@ var exports_ship_hook = {};
|
|
|
71901
71986
|
__export(exports_ship_hook, {
|
|
71902
71987
|
startShip: () => startShip
|
|
71903
71988
|
});
|
|
71904
|
-
import { dirname as
|
|
71989
|
+
import { dirname as dirname45 } from "path";
|
|
71905
71990
|
async function startShip(repoDir, eventsPath, env) {
|
|
71906
71991
|
let url = shipEnabled(env);
|
|
71907
71992
|
if (!url) {
|
|
@@ -71911,7 +71996,7 @@ async function startShip(repoDir, eventsPath, env) {
|
|
|
71911
71996
|
}
|
|
71912
71997
|
if (!url)
|
|
71913
71998
|
return;
|
|
71914
|
-
startShipLoop({ runDir:
|
|
71999
|
+
startShipLoop({ runDir: dirname45(eventsPath), url, source: sourceId(repoDir), token: env.LOKI_CONTROL_TOKEN });
|
|
71915
72000
|
}
|
|
71916
72001
|
var init_ship_hook = __esm(() => {
|
|
71917
72002
|
init_discover();
|
|
@@ -72518,10 +72603,10 @@ __export(exports_run_group, {
|
|
|
72518
72603
|
groupCostLine: () => groupCostLine,
|
|
72519
72604
|
NOT_PROVEN: () => NOT_PROVEN
|
|
72520
72605
|
});
|
|
72521
|
-
import { cpSync as cpSync2, existsSync as existsSync76, mkdirSync as mkdirSync58, readdirSync as readdirSync34, readFileSync as
|
|
72606
|
+
import { cpSync as cpSync2, existsSync as existsSync76, mkdirSync as mkdirSync58, readdirSync as readdirSync34, readFileSync as readFileSync95, rmSync as rmSync32, statSync as statSync30 } from "fs";
|
|
72522
72607
|
import { createHash as createHash31 } from "crypto";
|
|
72523
72608
|
import { spawn as spawn12 } from "child_process";
|
|
72524
|
-
import { join as
|
|
72609
|
+
import { join as join110, resolve as resolve32 } from "path";
|
|
72525
72610
|
function scopedEnv(env) {
|
|
72526
72611
|
const out3 = {};
|
|
72527
72612
|
for (const [k3, v3] of Object.entries(env))
|
|
@@ -72558,7 +72643,7 @@ function groupCostLine(costs, provider = "claude") {
|
|
|
72558
72643
|
`;
|
|
72559
72644
|
}
|
|
72560
72645
|
function writeGroupCostRecord(repoDir, name, costs, provider) {
|
|
72561
|
-
const dir =
|
|
72646
|
+
const dir = join110(repoDir, ".loki", "metrics", "efficiency");
|
|
72562
72647
|
const timestamp = new Date().toISOString();
|
|
72563
72648
|
try {
|
|
72564
72649
|
const base = { phase: "implement", provider, status: "group", kind: "group_cost", timestamp };
|
|
@@ -72572,7 +72657,7 @@ function writeGroupCostRecord(repoDir, name, costs, provider) {
|
|
|
72572
72657
|
if (recs.length === 0)
|
|
72573
72658
|
return;
|
|
72574
72659
|
mkdirSync58(dir, { recursive: true });
|
|
72575
|
-
recs.forEach((r, k3) => atomicWriteJson(
|
|
72660
|
+
recs.forEach((r, k3) => atomicWriteJson(join110(dir, `iteration-group-${name}-${String(k3).padStart(3, "0")}.json`), r));
|
|
72576
72661
|
} catch {}
|
|
72577
72662
|
}
|
|
72578
72663
|
function testCommand(repoDir, env) {
|
|
@@ -72585,7 +72670,7 @@ function testCommand(repoDir, env) {
|
|
|
72585
72670
|
return [];
|
|
72586
72671
|
}
|
|
72587
72672
|
function findResumable(repoDir, specSha, unitIds) {
|
|
72588
|
-
const root =
|
|
72673
|
+
const root = join110(repoDir, ".loki", "groups");
|
|
72589
72674
|
let names = [];
|
|
72590
72675
|
try {
|
|
72591
72676
|
names = readdirSync34(root);
|
|
@@ -72596,7 +72681,7 @@ function findResumable(repoDir, specSha, unitIds) {
|
|
|
72596
72681
|
for (const gid of names) {
|
|
72597
72682
|
if (!GID_RE.test(gid))
|
|
72598
72683
|
continue;
|
|
72599
|
-
const p =
|
|
72684
|
+
const p = join110(root, gid, "dag.json"), d = readJson8(p);
|
|
72600
72685
|
if (!d || (unitIds ? JSON.stringify((Array.isArray(d["units"]) ? d["units"] : []).filter((u10) => !u10.fixKind).map((u10) => u10.id)) !== JSON.stringify(unitIds) : d["spec_sha256"] !== specSha) || typeof d["base_ref"] !== "string" || !Array.isArray(d["units"]))
|
|
72601
72686
|
continue;
|
|
72602
72687
|
let at2 = 0;
|
|
@@ -72613,7 +72698,7 @@ function findResumable(repoDir, specSha, unitIds) {
|
|
|
72613
72698
|
async function unitDone(verifyReceipt, repoDir, gid, n11, id2) {
|
|
72614
72699
|
if (!UNIT_ID_RE.test(id2))
|
|
72615
72700
|
return false;
|
|
72616
|
-
const rp =
|
|
72701
|
+
const rp = join110(repoDir, ".loki", "groups", gid, "group", "units", id2, "receipt.json");
|
|
72617
72702
|
const rec2 = readJson8(rp);
|
|
72618
72703
|
if (!rec2 || rec2["verdict"] !== "VERIFIED")
|
|
72619
72704
|
return false;
|
|
@@ -72628,7 +72713,7 @@ async function adoptJournaled(verifyReceipt, repoDir, dir, key, gid, n11, id2, t
|
|
|
72628
72713
|
return false;
|
|
72629
72714
|
if (!await unitDone(verifyReceipt, repoDir, e10.gid, e10.n, id2))
|
|
72630
72715
|
return false;
|
|
72631
|
-
const signed = readJson8(
|
|
72716
|
+
const signed = readJson8(join110(repoDir, ".loki", "groups", e10.gid, "group", "units", id2, "receipt.json"));
|
|
72632
72717
|
const signedTask = (signed?.["task"] ?? {}).sha256;
|
|
72633
72718
|
const signedSpec = (signed?.["unit_spec"] ?? {}).sha256;
|
|
72634
72719
|
if (typeof signedSpec !== "string" || signedSpec === "" || signedSpec !== specSha)
|
|
@@ -72638,9 +72723,9 @@ async function adoptJournaled(verifyReceipt, repoDir, dir, key, gid, n11, id2, t
|
|
|
72638
72723
|
const tip = git11(repoDir, ["rev-parse", "--verify", "--quiet", `refs/heads/loki/unit-${e10.gid}-${e10.n}`]);
|
|
72639
72724
|
if (tip === "" || tip !== e10.head)
|
|
72640
72725
|
return false;
|
|
72641
|
-
const dst =
|
|
72726
|
+
const dst = join110(repoDir, ".loki", "groups", gid, "group", "units", id2);
|
|
72642
72727
|
rmSync32(dst, { recursive: true, force: true });
|
|
72643
|
-
cpSync2(
|
|
72728
|
+
cpSync2(join110(repoDir, ".loki", "groups", e10.gid, "group", "units", id2), dst, { recursive: true });
|
|
72644
72729
|
if (safeGitSpawn(repoDir, ["update-ref", `refs/heads/loki/unit-${gid}-${n11}`, tip], { encoding: "utf8" }).status !== 0)
|
|
72645
72730
|
return false;
|
|
72646
72731
|
if (!await unitDone(verifyReceipt, repoDir, gid, n11, id2))
|
|
@@ -72675,8 +72760,8 @@ async function runGroup(launcher, dag, ctx) {
|
|
|
72675
72760
|
const revised = resumable !== null && exact === null;
|
|
72676
72761
|
const changed = new Set;
|
|
72677
72762
|
const groupId = resumable?.gid ?? `g${Date.now().toString(36)}`;
|
|
72678
|
-
const groupDir =
|
|
72679
|
-
const receiptPath =
|
|
72763
|
+
const groupDir = join110(repoDir, ".loki", "groups", groupId);
|
|
72764
|
+
const receiptPath = join110(groupDir, "receipt.json");
|
|
72680
72765
|
const slugOf = () => originSlug(repoDir);
|
|
72681
72766
|
let baseRef;
|
|
72682
72767
|
let startBranch = "";
|
|
@@ -72768,10 +72853,10 @@ async function runGroup(launcher, dag, ctx) {
|
|
|
72768
72853
|
const accOf = new Map;
|
|
72769
72854
|
for (const cu2 of Array.isArray(gc2?.["units"]) ? gc2["units"] : [])
|
|
72770
72855
|
accOf.set(cu2.id, cu2.criteria.map((c) => c.text));
|
|
72771
|
-
const specDir =
|
|
72856
|
+
const specDir = join110(groupDir, "unit_specs");
|
|
72772
72857
|
mkdirSync58(specDir, { recursive: true });
|
|
72773
72858
|
for (const u10 of units) {
|
|
72774
|
-
const spec =
|
|
72859
|
+
const spec = join110(specDir, `${u10.id}.json`);
|
|
72775
72860
|
const isFix = !!u10.fixKind;
|
|
72776
72861
|
if (!isFix)
|
|
72777
72862
|
u10.base = baseRef;
|
|
@@ -72797,19 +72882,19 @@ async function runGroup(launcher, dag, ctx) {
|
|
|
72797
72882
|
say(`loki: unit ${u10.id} skipped-unchanged
|
|
72798
72883
|
`);
|
|
72799
72884
|
} else if (resumable && UNIT_ID_RE.test(u10.id))
|
|
72800
|
-
rmSync32(
|
|
72885
|
+
rmSync32(join110(groupDir, "group", "units", u10.id), { recursive: true, force: true });
|
|
72801
72886
|
}
|
|
72802
72887
|
const cut2 = units.findIndex((u10) => u10.fixKind && !u10.done);
|
|
72803
72888
|
if (cut2 >= 0)
|
|
72804
72889
|
for (const u10 of units.splice(cut2)) {
|
|
72805
72890
|
if (u10.done)
|
|
72806
72891
|
doneCount--;
|
|
72807
|
-
rmSync32(
|
|
72892
|
+
rmSync32(join110(groupDir, "group", "units", u10.id), { recursive: true, force: true });
|
|
72808
72893
|
}
|
|
72809
72894
|
if (resumable)
|
|
72810
72895
|
say(`loki: resuming group ${groupId}: ${doneCount} of ${units.length} units already VERIFIED
|
|
72811
72896
|
`);
|
|
72812
|
-
const dagPath =
|
|
72897
|
+
const dagPath = join110(groupDir, "dag.json");
|
|
72813
72898
|
atomicWriteJson(dagPath, { group: groupId, spec_sha256: specSha, base_ref: baseRef, start_branch: startBranch, ...full, units });
|
|
72814
72899
|
try {
|
|
72815
72900
|
const chk = await checkDecomposable(full, { map: (() => {
|
|
@@ -72839,7 +72924,7 @@ async function runGroup(launcher, dag, ctx) {
|
|
|
72839
72924
|
const n11 = Math.min(slots, pending);
|
|
72840
72925
|
say(`loki: group ${groupId}: ${units.length} units, ${n11} parallel slot(s) (provider ${provider})
|
|
72841
72926
|
`);
|
|
72842
|
-
const backlog =
|
|
72927
|
+
const backlog = join110(REPO_ROOT, "autonomy", "lib", "backlog.py");
|
|
72843
72928
|
const feed = createGroupFeed(groupId, units, createGroupRenderer({ write: say, isTTY: false }));
|
|
72844
72929
|
const res = await run2([backlog, slug, "--dag", dagPath, "--group", groupId, "--slots", String(n11), "--provider", provider], scopedEnv({ ...env, LOKI_PROVIDER: provider }), repoDir, (c) => feed.feed(c));
|
|
72845
72930
|
launchCode = res.code;
|
|
@@ -72879,7 +72964,7 @@ async function runGroup(launcher, dag, ctx) {
|
|
|
72879
72964
|
const testCmd = testCommand(repoDir, env), fixes = units.filter((u10) => u10.fixKind);
|
|
72880
72965
|
const putDag = (us2) => atomicWriteJson(dagPath, { group: groupId, spec_sha256: specSha, base_ref: baseRef, start_branch: startBranch, ...full, units: us2 });
|
|
72881
72966
|
const launchFix = async (fix) => {
|
|
72882
|
-
const key = `unit-${groupId}-${units.length + 1}`, spec =
|
|
72967
|
+
const key = `unit-${groupId}-${units.length + 1}`, spec = join110(specDir, `${fix.id}.json`), slug = slugOf();
|
|
72883
72968
|
if (!slug)
|
|
72884
72969
|
return null;
|
|
72885
72970
|
atomicWriteJson(spec, { id: fix.id, writeSet: fix.writeSet, pack: fix.writeSet, tokenBudget: 1e9, acceptance: fix.acceptance });
|
|
@@ -72888,7 +72973,7 @@ async function runGroup(launcher, dag, ctx) {
|
|
|
72888
72973
|
fix.base = git11(repoDir, ["rev-parse", "HEAD"]);
|
|
72889
72974
|
units.push(fix);
|
|
72890
72975
|
putDag(units.map((u10) => u10 === fix ? u10 : { ...u10, done: true }));
|
|
72891
|
-
const res = await run2([
|
|
72976
|
+
const res = await run2([join110(REPO_ROOT, "autonomy", "lib", "backlog.py"), slug, "--dag", dagPath, "--group", groupId, "--slots", "1", "--provider", provider], scopedEnv({ ...env, LOKI_PROVIDER: provider }), repoDir);
|
|
72892
72977
|
costs.push(parseGroupCost(res.stdout));
|
|
72893
72978
|
if (res.code !== 0 || !new RegExp(`^backlog: ${key} (VERIFIED|PR \\S+)$`, "m").test(res.stdout)) {
|
|
72894
72979
|
units.pop();
|
|
@@ -72922,7 +73007,7 @@ async function runGroup(launcher, dag, ctx) {
|
|
|
72922
73007
|
return 1;
|
|
72923
73008
|
}
|
|
72924
73009
|
const order2 = units.map((u10) => ({ unit_id: u10.id, goal: u10.items.join("; "), files: u10.writeSet }));
|
|
72925
|
-
atomicWriteJson(
|
|
73010
|
+
atomicWriteJson(join110(groupDir, "group", "manifest.json"), { group_id: groupId, units: order2 });
|
|
72926
73011
|
const head = git11(repoDir, ["rev-parse", "--verify", `refs/heads/${r.branch}`]);
|
|
72927
73012
|
let verdict = "", unitVerdicts = [], why = "";
|
|
72928
73013
|
try {
|
|
@@ -72968,7 +73053,7 @@ var NOT_PROVEN = 4, ENV_KEEP, defaultLauncher = (argv, env, cwd, onOut) => new P
|
|
|
72968
73053
|
return r.status === 0 ? String(r.stdout).trim() : "";
|
|
72969
73054
|
}, SLUG_RE, originSlug = (repoDir) => SLUG_RE.exec(git11(repoDir, ["remote", "get-url", "origin"]))?.[1], sha2563 = (s) => createHash31("sha256").update(s).digest("hex"), UNIT_ID_RE, GID_RE, readJson8 = (p) => {
|
|
72970
73055
|
try {
|
|
72971
|
-
const v3 = JSON.parse(
|
|
73056
|
+
const v3 = JSON.parse(readFileSync95(p, "utf8"));
|
|
72972
73057
|
return v3 !== null && typeof v3 === "object" && !Array.isArray(v3) ? v3 : null;
|
|
72973
73058
|
} catch {
|
|
72974
73059
|
return null;
|
|
@@ -73003,7 +73088,7 @@ __export(exports_route, {
|
|
|
73003
73088
|
MAX_SPEC_BYTES: () => MAX_SPEC_BYTES2,
|
|
73004
73089
|
MAX_SEQ_TASK_BYTES: () => MAX_SEQ_TASK_BYTES
|
|
73005
73090
|
});
|
|
73006
|
-
import { closeSync as closeSync15, constants as constants5, fstatSync as fstatSync8, openSync as openSync15, readFileSync as
|
|
73091
|
+
import { closeSync as closeSync15, constants as constants5, fstatSync as fstatSync8, openSync as openSync15, readFileSync as readFileSync96, realpathSync as realpathSync32 } from "fs";
|
|
73007
73092
|
import { isAbsolute as isAbsolute21, relative as relative25, resolve as resolve33 } from "path";
|
|
73008
73093
|
function providerSlots(env, provider) {
|
|
73009
73094
|
provider = (provider || env.LOKI_PROVIDER || "claude").toLowerCase();
|
|
@@ -73030,7 +73115,7 @@ function readSpec(task, repoDir, cwd) {
|
|
|
73030
73115
|
return { kind: "text" };
|
|
73031
73116
|
if (st2.size > MAX_SPEC_BYTES2)
|
|
73032
73117
|
return { kind: "reject", reason: `spec file over ${MAX_SPEC_BYTES2} bytes` };
|
|
73033
|
-
const buf =
|
|
73118
|
+
const buf = readFileSync96(fd2);
|
|
73034
73119
|
if (buf.length > MAX_SPEC_BYTES2)
|
|
73035
73120
|
return { kind: "reject", reason: `spec file over ${MAX_SPEC_BYTES2} bytes` };
|
|
73036
73121
|
if (buf.includes(0))
|
|
@@ -73149,15 +73234,15 @@ var init_route = __esm(() => {
|
|
|
73149
73234
|
});
|
|
73150
73235
|
|
|
73151
73236
|
// ../../loki-ts/src/contrib/forecast.ts
|
|
73152
|
-
import { appendFileSync as appendFileSync12, existsSync as existsSync77, mkdirSync as mkdirSync59, readFileSync as
|
|
73153
|
-
import { join as
|
|
73237
|
+
import { appendFileSync as appendFileSync12, existsSync as existsSync77, mkdirSync as mkdirSync59, readFileSync as readFileSync97 } from "fs";
|
|
73238
|
+
import { join as join111 } from "path";
|
|
73154
73239
|
function readWindowDeltas(lokiDir2) {
|
|
73155
73240
|
const p = historyPath2(lokiDir2);
|
|
73156
73241
|
if (!existsSync77(p))
|
|
73157
73242
|
return [];
|
|
73158
73243
|
const out3 = [];
|
|
73159
73244
|
try {
|
|
73160
|
-
for (const line2 of
|
|
73245
|
+
for (const line2 of readFileSync97(p, "utf8").split(`
|
|
73161
73246
|
`)) {
|
|
73162
73247
|
if (!line2.trim())
|
|
73163
73248
|
continue;
|
|
@@ -73208,17 +73293,17 @@ function forecastLine(reading, history, opts = {}) {
|
|
|
73208
73293
|
const w = range(history.map((h10) => h10.week));
|
|
73209
73294
|
return fit(`forecast: ~${s}% of session window, ~${w}% of week (basis: ${history.length} past runs; ${used})`, width);
|
|
73210
73295
|
}
|
|
73211
|
-
async function printForecast(lokiDir2,
|
|
73296
|
+
async function printForecast(lokiDir2, read3, write, env = process.env) {
|
|
73212
73297
|
if (!forecastOn(env))
|
|
73213
73298
|
return;
|
|
73214
73299
|
try {
|
|
73215
|
-
const line2 = forecastLine(await
|
|
73300
|
+
const line2 = forecastLine(await read3(), readWindowDeltas(lokiDir2), { env });
|
|
73216
73301
|
if (line2)
|
|
73217
73302
|
write(line2 + `
|
|
73218
73303
|
`);
|
|
73219
73304
|
} catch {}
|
|
73220
73305
|
}
|
|
73221
|
-
var MIN_FORECAST_RUNS = 3, KEEP_RUNS = 20, forecastOn = (env = process.env) => env["LOKI_FORECAST"] !== "0", finite = (v3) => typeof v3 === "number" && Number.isFinite(v3), historyPath2 = (lokiDir2) =>
|
|
73306
|
+
var MIN_FORECAST_RUNS = 3, KEEP_RUNS = 20, forecastOn = (env = process.env) => env["LOKI_FORECAST"] !== "0", finite = (v3) => typeof v3 === "number" && Number.isFinite(v3), historyPath2 = (lokiDir2) => join111(lokiDir2, "quota-runs.jsonl"), range = (xs2) => {
|
|
73222
73307
|
const lo = Math.floor(Math.min(...xs2)), hi2 = Math.ceil(Math.max(...xs2));
|
|
73223
73308
|
return lo === hi2 ? `${hi2}` : `${lo}-${hi2}`;
|
|
73224
73309
|
};
|
|
@@ -73227,8 +73312,8 @@ var init_forecast = __esm(() => {
|
|
|
73227
73312
|
});
|
|
73228
73313
|
|
|
73229
73314
|
// ../../loki-ts/src/commands/queue.ts
|
|
73230
|
-
import { existsSync as existsSync78, mkdirSync as mkdirSync60, readFileSync as
|
|
73231
|
-
import { join as
|
|
73315
|
+
import { existsSync as existsSync78, mkdirSync as mkdirSync60, readFileSync as readFileSync98, readdirSync as readdirSync35, renameSync as renameSync21, statSync as statSync31, writeFileSync as writeFileSync58 } from "fs";
|
|
73316
|
+
import { join as join112, resolve as resolve34 } from "path";
|
|
73232
73317
|
function normalizeRef(raw2) {
|
|
73233
73318
|
const m = URL_RE2.exec(raw2);
|
|
73234
73319
|
if (m)
|
|
@@ -73238,11 +73323,11 @@ function normalizeRef(raw2) {
|
|
|
73238
73323
|
return /^0+$/.test(raw2.replace(/^.*#/, "")) ? null : raw2;
|
|
73239
73324
|
}
|
|
73240
73325
|
function queuePath(lokiDir2) {
|
|
73241
|
-
return
|
|
73326
|
+
return join112(lokiDir2, "issue-queue.json");
|
|
73242
73327
|
}
|
|
73243
73328
|
function readQueue(lokiDir2) {
|
|
73244
73329
|
try {
|
|
73245
|
-
const d = JSON.parse(
|
|
73330
|
+
const d = JSON.parse(readFileSync98(queuePath(lokiDir2), "utf8"));
|
|
73246
73331
|
return Array.isArray(d.items) ? d.items.filter((i) => typeof i?.ref === "string") : [];
|
|
73247
73332
|
} catch {
|
|
73248
73333
|
return [];
|
|
@@ -73253,7 +73338,7 @@ function quarantineCorruptQueue(lokiDir2, now2, warn) {
|
|
|
73253
73338
|
if (!existsSync78(p))
|
|
73254
73339
|
return;
|
|
73255
73340
|
try {
|
|
73256
|
-
const d = JSON.parse(
|
|
73341
|
+
const d = JSON.parse(readFileSync98(p, "utf8"));
|
|
73257
73342
|
if (d !== null && typeof d === "object" && Array.isArray(d.items))
|
|
73258
73343
|
return;
|
|
73259
73344
|
} catch {}
|
|
@@ -73455,8 +73540,8 @@ ${QUEUE_USAGE}`);
|
|
|
73455
73540
|
try {
|
|
73456
73541
|
mkdirSync60(d.lokiDir, { recursive: true });
|
|
73457
73542
|
const stamp2 = finished.toISOString().replace(/[:.]/g, "-");
|
|
73458
|
-
writeFileSync58(
|
|
73459
|
-
writeFileSync58(
|
|
73543
|
+
writeFileSync58(join112(d.lokiDir, `queue-digest-${stamp2}.txt`), text4);
|
|
73544
|
+
writeFileSync58(join112(d.lokiDir, "queue-digest-latest.txt"), text4);
|
|
73460
73545
|
} catch (e10) {
|
|
73461
73546
|
d.err(`loki queue: could not write digest: ${e10 instanceof Error ? e10.message : String(e10)}
|
|
73462
73547
|
`);
|
|
@@ -73466,11 +73551,11 @@ ${QUEUE_USAGE}`);
|
|
|
73466
73551
|
}
|
|
73467
73552
|
function newestRecord(lokiDir2, since) {
|
|
73468
73553
|
for (const [sub2, file] of [["runs", "receipt.json"], ["proofs", "proof.json"]]) {
|
|
73469
|
-
const dir =
|
|
73554
|
+
const dir = join112(lokiDir2, sub2);
|
|
73470
73555
|
let best = null;
|
|
73471
73556
|
try {
|
|
73472
73557
|
for (const name of readdirSync35(dir)) {
|
|
73473
|
-
const p =
|
|
73558
|
+
const p = join112(dir, name, file);
|
|
73474
73559
|
if (!existsSync78(p))
|
|
73475
73560
|
continue;
|
|
73476
73561
|
const t = statSync31(p).mtimeMs;
|
|
@@ -73479,7 +73564,7 @@ function newestRecord(lokiDir2, since) {
|
|
|
73479
73564
|
}
|
|
73480
73565
|
if (!best)
|
|
73481
73566
|
continue;
|
|
73482
|
-
const d = JSON.parse(
|
|
73567
|
+
const d = JSON.parse(readFileSync98(best.p, "utf8"));
|
|
73483
73568
|
const usd = d.cost?.usd;
|
|
73484
73569
|
const unmetered = d.cost?.source === "cli-invoker-unmetered";
|
|
73485
73570
|
return {
|
|
@@ -73513,7 +73598,7 @@ function makeDefaultRunner(lokiDir2) {
|
|
|
73513
73598
|
return async (ref, opts) => {
|
|
73514
73599
|
const since = Date.now();
|
|
73515
73600
|
const argv = [resolve34(REPO_ROOT, "bin", "loki"), ...queueStartArgs(ref, !!opts.pr)];
|
|
73516
|
-
const runLoki = opts.cwd ?
|
|
73601
|
+
const runLoki = opts.cwd ? join112(opts.cwd, ".loki") : lokiDir2;
|
|
73517
73602
|
const env = runnerEnv(opts, runLoki);
|
|
73518
73603
|
const proc = Bun.spawn(argv, { stdout: "pipe", stderr: "pipe", stdin: "ignore", env, ...opts.cwd ? { cwd: opts.cwd } : {} });
|
|
73519
73604
|
const mins2 = itemTimeoutMin(process.env["LOKI_QUEUE_ITEM_TIMEOUT_MIN"]);
|
|
@@ -73523,9 +73608,9 @@ function makeDefaultRunner(lokiDir2) {
|
|
|
73523
73608
|
clearTimeout(timer);
|
|
73524
73609
|
const output = so + se2;
|
|
73525
73610
|
try {
|
|
73526
|
-
const logDir =
|
|
73611
|
+
const logDir = join112(lokiDir2, "queue-logs");
|
|
73527
73612
|
mkdirSync60(logDir, { recursive: true });
|
|
73528
|
-
writeFileSync58(
|
|
73613
|
+
writeFileSync58(join112(logDir, `${(opts.logName ?? ref).replace(/[^A-Za-z0-9_.-]/g, "_").slice(0, 120)}.log`), output);
|
|
73529
73614
|
} catch {}
|
|
73530
73615
|
const proof = newestRecord(runLoki, since);
|
|
73531
73616
|
return { rc: rc2, output, verdict: proof.verdict, costUsd: proof.costUsd, runId: proof.runId ?? null };
|
|
@@ -73705,13 +73790,13 @@ function renderEpicTree(n11, title, rows) {
|
|
|
73705
73790
|
}
|
|
73706
73791
|
function makeSessionDecompose(repoDir, lokiDir2, provider) {
|
|
73707
73792
|
return async (slug, issue, triageReason) => {
|
|
73708
|
-
const { mkdirSync: mkdirSync61, readFileSync:
|
|
73709
|
-
const { join:
|
|
73793
|
+
const { mkdirSync: mkdirSync61, readFileSync: readFileSync99, existsSync: existsSync79 } = await import("fs");
|
|
73794
|
+
const { join: join113 } = await import("path");
|
|
73710
73795
|
const { createSessionRunner: createSessionRunner2 } = await Promise.resolve().then(() => (init_session(), exports_session));
|
|
73711
73796
|
const { envOverride: envOverride2 } = await Promise.resolve().then(() => (init_decision(), exports_decision));
|
|
73712
|
-
const dir =
|
|
73797
|
+
const dir = join113(lokiDir2, "issues-run", "decompose");
|
|
73713
73798
|
mkdirSync61(dir, { recursive: true });
|
|
73714
|
-
const outPath =
|
|
73799
|
+
const outPath = join113(dir, `issue-${issue.number}-${Date.now()}.json`);
|
|
73715
73800
|
const runner = createSessionRunner2({ provider, lokiRoot: lokiDir2 });
|
|
73716
73801
|
const r = await runner.run({
|
|
73717
73802
|
stage: "plan",
|
|
@@ -73724,7 +73809,7 @@ function makeSessionDecompose(repoDir, lokiDir2, provider) {
|
|
|
73724
73809
|
...provider === "claude" && envOverride2(process.env) === null ? { model: "opus" } : {}
|
|
73725
73810
|
});
|
|
73726
73811
|
if (existsSync79(outPath))
|
|
73727
|
-
return
|
|
73812
|
+
return readFileSync99(outPath, "utf8");
|
|
73728
73813
|
return r.summary ?? "";
|
|
73729
73814
|
};
|
|
73730
73815
|
}
|
|
@@ -73751,7 +73836,7 @@ __export(exports_issues_run, {
|
|
|
73751
73836
|
import { spawnSync as spawnSync15 } from "child_process";
|
|
73752
73837
|
import { cpSync as cpSync3, existsSync as existsSync79, mkdirSync as mkdirSync61, mkdtempSync as mkdtempSync15, rmSync as rmSync33, writeFileSync as writeFileSync59 } from "fs";
|
|
73753
73838
|
import { tmpdir as tmpdir19 } from "os";
|
|
73754
|
-
import { join as
|
|
73839
|
+
import { join as join113, resolve as resolve35 } from "path";
|
|
73755
73840
|
import { createInterface as createInterface3 } from "readline";
|
|
73756
73841
|
function parseIssuesArgs(args) {
|
|
73757
73842
|
const a = { slug: null, label: null, milestone: null, limit: DEFAULT_LIMIT, parallel: 1, draft: false, dryRun: false, yes: false, comment: false, split: true, json: false };
|
|
@@ -74007,7 +74092,7 @@ ${USAGE}`);
|
|
|
74007
74092
|
}
|
|
74008
74093
|
}
|
|
74009
74094
|
const stamp2 = started.toISOString().replace(/[:.]/g, "-");
|
|
74010
|
-
const runDir =
|
|
74095
|
+
const runDir = join113(d.lokiDir, "issues-run", stamp2);
|
|
74011
74096
|
mkdirSync61(runDir, { recursive: true });
|
|
74012
74097
|
const byRef = new Map(actionable.map((i) => [`${slug}#${i.number}`, i]));
|
|
74013
74098
|
const sink = () => {};
|
|
@@ -74097,14 +74182,14 @@ ${USAGE}`);
|
|
|
74097
74182
|
${trees.join(`
|
|
74098
74183
|
`)}` : "");
|
|
74099
74184
|
try {
|
|
74100
|
-
writeFileSync59(
|
|
74185
|
+
writeFileSync59(join113(runDir, "digest.md"), text4);
|
|
74101
74186
|
} catch (e10) {
|
|
74102
74187
|
d.err(`loki issues run: could not write digest: ${e10 instanceof Error ? e10.message : String(e10)}
|
|
74103
74188
|
`);
|
|
74104
74189
|
}
|
|
74105
74190
|
d.out(`
|
|
74106
74191
|
${text4}
|
|
74107
|
-
digest: ${
|
|
74192
|
+
digest: ${join113(runDir, "digest.md")}
|
|
74108
74193
|
`);
|
|
74109
74194
|
return 0;
|
|
74110
74195
|
}
|
|
@@ -74114,11 +74199,11 @@ function perRun(est) {
|
|
|
74114
74199
|
return est.prior ? { usd: est.prior.usd, tilde: "~", label: " (rough prior)" } : null;
|
|
74115
74200
|
}
|
|
74116
74201
|
function keepReceipt(wt, runId2, runDir, err) {
|
|
74117
|
-
const src =
|
|
74202
|
+
const src = join113(wt, ".loki", "runs", runId2);
|
|
74118
74203
|
if (!/^[A-Za-z0-9_.-]+$/.test(runId2) || !existsSync79(src))
|
|
74119
74204
|
return;
|
|
74120
74205
|
try {
|
|
74121
|
-
cpSync3(src,
|
|
74206
|
+
cpSync3(src, join113(runDir, "receipts", runId2), { recursive: true });
|
|
74122
74207
|
} catch (e10) {
|
|
74123
74208
|
err(`loki issues run: could not keep the receipt of ${runId2}: ${e10 instanceof Error ? e10.message : String(e10)}
|
|
74124
74209
|
`);
|
|
@@ -74165,8 +74250,8 @@ function makeWorktrees(repoDir) {
|
|
|
74165
74250
|
let root = null;
|
|
74166
74251
|
return {
|
|
74167
74252
|
create: (name, base) => {
|
|
74168
|
-
root ??= mkdtempSync15(
|
|
74169
|
-
const p =
|
|
74253
|
+
root ??= mkdtempSync15(join113(tmpdir19(), "loki-issues-"));
|
|
74254
|
+
const p = join113(root, name);
|
|
74170
74255
|
safeGit(repoDir, ["worktree", "add", "-B", `loki/${name}`, p, base]);
|
|
74171
74256
|
return p;
|
|
74172
74257
|
},
|
|
@@ -74259,7 +74344,7 @@ __export(exports_satisfaction, {
|
|
|
74259
74344
|
});
|
|
74260
74345
|
import { appendFileSync as appendFileSync13, mkdirSync as mkdirSync62 } from "fs";
|
|
74261
74346
|
import { homedir as homedir13 } from "os";
|
|
74262
|
-
import { join as
|
|
74347
|
+
import { join as join114 } from "path";
|
|
74263
74348
|
import { createInterface as createInterface4 } from "readline";
|
|
74264
74349
|
function satisfactionEnabled(env, tty) {
|
|
74265
74350
|
if (!tty)
|
|
@@ -74279,9 +74364,9 @@ function parseScore(line2) {
|
|
|
74279
74364
|
return { score: Number(m[1]), again: m[2] ? m[2].toLowerCase() === "y" : null };
|
|
74280
74365
|
}
|
|
74281
74366
|
function recordSatisfaction(home, row) {
|
|
74282
|
-
const dir =
|
|
74367
|
+
const dir = join114(home, ".loki");
|
|
74283
74368
|
mkdirSync62(dir, { recursive: true, mode: 448 });
|
|
74284
|
-
appendFileSync13(
|
|
74369
|
+
appendFileSync13(join114(dir, "satisfaction.jsonl"), `${JSON.stringify(row)}
|
|
74285
74370
|
`, { mode: 384 });
|
|
74286
74371
|
}
|
|
74287
74372
|
async function maybeAsk(o) {
|
|
@@ -74352,8 +74437,8 @@ __export(exports_supervisor, {
|
|
|
74352
74437
|
});
|
|
74353
74438
|
import { spawn as spawn13, spawnSync as spawnSync16 } from "child_process";
|
|
74354
74439
|
import { createHash as createHash32, createPublicKey as createPublicKey3, sign as sign2 } from "crypto";
|
|
74355
|
-
import { existsSync as existsSync80, mkdirSync as mkdirSync63, readFileSync as
|
|
74356
|
-
import { join as
|
|
74440
|
+
import { existsSync as existsSync80, mkdirSync as mkdirSync63, readFileSync as readFileSync99, writeFileSync as writeFileSync60 } from "fs";
|
|
74441
|
+
import { join as join115, relative as relative26, resolve as resolve36 } from "path";
|
|
74357
74442
|
async function slackEvent(...a) {
|
|
74358
74443
|
try {
|
|
74359
74444
|
await (await Promise.resolve().then(() => (init_slack_events(), exports_slack_events))).notifyEvent(...a);
|
|
@@ -74382,7 +74467,7 @@ class SupervisorLog {
|
|
|
74382
74467
|
this.log = new EventLog(path, runId2);
|
|
74383
74468
|
this.hash = createHash32("sha256");
|
|
74384
74469
|
try {
|
|
74385
|
-
this.hash.update(
|
|
74470
|
+
this.hash.update(readFileSync99(path));
|
|
74386
74471
|
} catch {}
|
|
74387
74472
|
}
|
|
74388
74473
|
implementOpen = false;
|
|
@@ -74437,7 +74522,7 @@ class SupervisorLog {
|
|
|
74437
74522
|
const expected = this.hash.copy().digest("hex");
|
|
74438
74523
|
let actual = "";
|
|
74439
74524
|
try {
|
|
74440
|
-
actual = createHash32("sha256").update(
|
|
74525
|
+
actual = createHash32("sha256").update(readFileSync99(this.path)).digest("hex");
|
|
74441
74526
|
} catch {}
|
|
74442
74527
|
if (actual === expected)
|
|
74443
74528
|
return true;
|
|
@@ -74459,15 +74544,15 @@ async function runSupervisor(opts) {
|
|
|
74459
74544
|
const t02 = Date.now();
|
|
74460
74545
|
const startedProvider = opts.started?.["provider"];
|
|
74461
74546
|
const env = opts.env ?? process.env;
|
|
74462
|
-
await assertPreflight({ repoDir: opts.repoDir, provider: typeof startedProvider === "string" ? startedProvider : "claude", pr: opts.pr !== undefined, env, runDir:
|
|
74547
|
+
await assertPreflight({ repoDir: opts.repoDir, provider: typeof startedProvider === "string" ? startedProvider : "claude", pr: opts.pr !== undefined, env, runDir: join115(opts.repoDir, ".loki", "runs", opts.runId) });
|
|
74463
74548
|
writeEngineMarker(opts.repoDir, opts.runId);
|
|
74464
74549
|
const origin = readOriginUrl(opts.repoDir);
|
|
74465
|
-
const rmRunPid = writeRunPid(
|
|
74550
|
+
const rmRunPid = writeRunPid(join115(opts.repoDir, ".loki", "runs", opts.runId), opts.runId);
|
|
74466
74551
|
process.once("exit", rmRunPid);
|
|
74467
|
-
const log = new SupervisorLog(
|
|
74552
|
+
const log = new SupervisorLog(join115(opts.repoDir, eventsRelPath(opts.runId)), opts.runId);
|
|
74468
74553
|
if ((env.LOKI_CONTROL ?? process.env.LOKI_CONTROL) !== "0")
|
|
74469
74554
|
Promise.resolve().then(() => (init_ship_hook(), exports_ship_hook)).then((m) => m.startShip(opts.repoDir, log.path, env)).catch(() => {});
|
|
74470
|
-
const aliveDir =
|
|
74555
|
+
const aliveDir = join115(opts.repoDir, ".loki", "runs", opts.runId), lastAlive = opts.resume ? readAliveBeat(aliveDir) : null;
|
|
74471
74556
|
log.append(opts.resume ? "run.resumed" : "run.started", null, { ...opts.started, ...opts.resume ? { phase: "stage", ...lastAlive ? { last_alive_ts: new Date(lastAlive).toISOString() } : {} } : {}, origin_repo: githubRepoFromUrl(origin) });
|
|
74472
74557
|
if (!opts.resume)
|
|
74473
74558
|
Promise.resolve().then(() => (init_writeback(), exports_writeback)).then((m) => m.writeBack({ phase: "started", verdict: "", prUrl: null, receiptSha256: null, task: "" }, env));
|
|
@@ -74502,7 +74587,7 @@ async function runSupervisor(opts) {
|
|
|
74502
74587
|
if (e10?.type === "receipt.sealed")
|
|
74503
74588
|
sealed = e10.data;
|
|
74504
74589
|
if (e10?.type === "variant" && e10.data.intent_confirm === true && workerEnv.LOKI_INTENT_TTY === "1") {
|
|
74505
|
-
askIntent(String(e10.data.card ?? ""),
|
|
74590
|
+
askIntent(String(e10.data.card ?? ""), join115(opts.repoDir, ".loki", "runs", opts.runId));
|
|
74506
74591
|
}
|
|
74507
74592
|
}, (stopped) => {
|
|
74508
74593
|
for (const g10 of sessionGroups)
|
|
@@ -74601,8 +74686,8 @@ async function runSupervisor(opts) {
|
|
|
74601
74686
|
}
|
|
74602
74687
|
log.append("run.completed", null, { verdict, ...cancelled2 ? { cancelled: true, signal: cancelled2, outcome: "CANCELLED" } : {}, pr_url: prUrl, not_proven: notProven, cost_usd: costUsd, wall_s: wallS, pre_model: preModelTiming(allEvents, t02) });
|
|
74603
74688
|
log.sealLog();
|
|
74604
|
-
recordFingerprints(
|
|
74605
|
-
const stages = allEvents.filter((e10) => e10.type === "stage.completed" && typeof e10.data.duration_s === "number").map((e10) => ({ label: String(e10.stage), seconds: e10.data.duration_s })), pc2 = partialCost(allEvents, log.tampered), summary = { pr: prUrl ? { url: prUrl, draft: verdict !== "VERIFIED" } : null, verdict, outcome, notProven, flaky: recordFingerprints(
|
|
74689
|
+
recordFingerprints(join115(opts.repoDir, ".loki", "state"), opts.runId, "failed", failedCheckNames(folded.stages["verify"]?.data.checks, folded.stages["verify"]?.data.pre_red_checks), cleanTreeId(opts.repoDir));
|
|
74690
|
+
const stages = allEvents.filter((e10) => e10.type === "stage.completed" && typeof e10.data.duration_s === "number").map((e10) => ({ label: String(e10.stage), seconds: e10.data.duration_s })), pc2 = partialCost(allEvents, log.tampered), summary = { pr: prUrl ? { url: prUrl, draft: verdict !== "VERIFIED" } : null, verdict, outcome, notProven, flaky: recordFingerprints(join115(opts.repoDir, ".loki", "state"), opts.runId, "flaky", folded.stages["verify"]?.data.flaky, cleanTreeId(opts.repoDir)), wallS, stages, cost: { usd: costUsd, provider: String(opts.started?.provider ?? ""), tokens: summaryTokens(folded, allEvents.some((e10) => e10.type === "cost")), ...summaryCache(allEvents, log.tampered), partialUsd: pc2.usd, measuredSessions: pc2.measured, totalSessions: pc2.total, stageShares: log.tampered ? null : stageShareText(allEvents), capUsd: Number(opts.started?.["max_cost_usd"]) > 0 ? Number(opts.started?.["max_cost_usd"]) : undefined } };
|
|
74606
74691
|
await slackEvent(env, "finished", { summary: formatSummary(summary), outcome: String(outcome), cost: summary.cost.usd != null ? `$${summary.cost.usd.toFixed(2)}` : "not measured", time: `${Math.round(wallS)}s`, receipt: log.tampered ? "TAMPERED" : receiptVerdict ? verdict : undefined });
|
|
74607
74692
|
rmRunPid();
|
|
74608
74693
|
process.off("exit", rmRunPid);
|
|
@@ -74732,7 +74817,7 @@ usage: loki "<task>" [--no-pr] [--deep] [--json] [--verbose] [--quiet] [--max-co
|
|
|
74732
74817
|
return rec2;
|
|
74733
74818
|
}
|
|
74734
74819
|
const runId2 = `e10-${new Date().toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z")}-${Math.random().toString(16).slice(2, 6)}`;
|
|
74735
|
-
const runDir =
|
|
74820
|
+
const runDir = join115(repoDir, ".loki", "runs", runId2);
|
|
74736
74821
|
const cap = resolveCap(maxCost, repoDir);
|
|
74737
74822
|
if ("error" in cap) {
|
|
74738
74823
|
process.stderr.write(`engine10: ${cap.error}
|
|
@@ -74770,7 +74855,7 @@ usage: loki "<task>" [--no-pr] [--deep] [--json] [--verbose] [--quiet] [--max-co
|
|
|
74770
74855
|
}
|
|
74771
74856
|
if (spec) {
|
|
74772
74857
|
mkdirSync63(runDir, { recursive: true });
|
|
74773
|
-
writeFileSync60(
|
|
74858
|
+
writeFileSync60(join115(runDir, "spec.snapshot.md"), spec.raw);
|
|
74774
74859
|
for (const e10 of [env, process.env]) {
|
|
74775
74860
|
e10.LOKI_E10_SPEC_PATH = relative26(repoDir, spec.path);
|
|
74776
74861
|
e10.LOKI_E10_SPEC_SHA256 = spec.sha256;
|
|
@@ -74795,9 +74880,9 @@ usage: loki "<task>" [--no-pr] [--deep] [--json] [--verbose] [--quiet] [--max-co
|
|
|
74795
74880
|
mkdirSync63(runDir, { recursive: true });
|
|
74796
74881
|
try {
|
|
74797
74882
|
if (trackerRef)
|
|
74798
|
-
await fetchTrackerIssueToFile(trackerRef,
|
|
74883
|
+
await fetchTrackerIssueToFile(trackerRef, join115(runDir, "issue.json"));
|
|
74799
74884
|
else
|
|
74800
|
-
fetchIssueToFile(task,
|
|
74885
|
+
fetchIssueToFile(task, join115(runDir, "issue.json"));
|
|
74801
74886
|
} catch (err) {
|
|
74802
74887
|
process.stderr.write(`engine10: issue fetch failed: ${err.message.split(`
|
|
74803
74888
|
`)[0]}
|
|
@@ -74827,7 +74912,7 @@ usage: loki "<task>" [--no-pr] [--deep] [--json] [--verbose] [--quiet] [--max-co
|
|
|
74827
74912
|
process.stdout.write(`${capLine}
|
|
74828
74913
|
`);
|
|
74829
74914
|
const t02 = Date.now();
|
|
74830
|
-
const eventsPath =
|
|
74915
|
+
const eventsPath = join115(repoDir, eventsRelPath(runId2));
|
|
74831
74916
|
const live2 = (e10) => {
|
|
74832
74917
|
const clockS = (Date.parse(e10.ts) - t02) / 1000;
|
|
74833
74918
|
const d = e10.data;
|
|
@@ -74874,7 +74959,7 @@ usage: loki "<task>" [--no-pr] [--deep] [--json] [--verbose] [--quiet] [--max-co
|
|
|
74874
74959
|
const reqOnce = async (evs) => {
|
|
74875
74960
|
if (reqMap === undefined) {
|
|
74876
74961
|
const rq2 = await Promise.resolve().then(() => (init_contract(), exports_contract));
|
|
74877
|
-
reqMap = rq2.writeFromEngine10(repoDir,
|
|
74962
|
+
reqMap = rq2.writeFromEngine10(repoDir, join115(repoDir, ".loki"), runDir, isIssue ? null : task, evs);
|
|
74878
74963
|
}
|
|
74879
74964
|
return reqMap;
|
|
74880
74965
|
};
|
|
@@ -74937,7 +75022,7 @@ usage: loki "<task>" [--no-pr] [--deep] [--json] [--verbose] [--quiet] [--max-co
|
|
|
74937
75022
|
comment: noPr ? undefined : async ({ issueRef, reason, prUrl }) => {
|
|
74938
75023
|
const { DEFAULT_PUSH_SH: DEFAULT_PUSH_SH2 } = await Promise.resolve().then(() => (init_pr(), exports_pr));
|
|
74939
75024
|
mkdirSync63(runDir, { recursive: true });
|
|
74940
|
-
const bodyFile =
|
|
75025
|
+
const bodyFile = join115(runDir, "backstop-comment.md");
|
|
74941
75026
|
writeFileSync60(bodyFile, `<!-- loki-backstop -->
|
|
74942
75027
|
Loki 10 run ${runId2} ${prUrl ? `opened draft PR ${prUrl}` : "ended without a PR"}.
|
|
74943
75028
|
|
|
@@ -74999,7 +75084,7 @@ ${prUrl ? "One question" : "Reason"}: ${reason}
|
|
|
74999
75084
|
const rr2 = resultOf(res.outcome);
|
|
75000
75085
|
if (res.outcome === "BUDGET_STOP" && cap.usd > 0)
|
|
75001
75086
|
writeBudgetStop(repoDir, runId2, { task: task.trim(), cap_usd: cap.usd, spent_usd: seed + (usd ?? 0), source: cap.source });
|
|
75002
|
-
const ui2 = { result: rr2, filesChanged: ds2?.files ?? null, insertions: ds2?.ins, deletions: ds2?.del, costUsd: usd, elapsedS: Number(f.run.completed?.data.wall_s ?? (Date.now() - t02) / 1000), receiptPath: res.receiptSha ?
|
|
75087
|
+
const ui2 = { result: rr2, filesChanged: ds2?.files ?? null, insertions: ds2?.ins, deletions: ds2?.del, costUsd: usd, elapsedS: Number(f.run.completed?.data.wall_s ?? (Date.now() - t02) / 1000), receiptPath: res.receiptSha ? join115(runDir, "receipt.json") : null, next: res.outcome === "BUDGET_STOP" && cap.usd > 0 ? budgetNext(seed + (usd ?? 0), cap.usd) : nextOf(rr2, ds2?.files ?? null, reasonOf(events2, res.tampered, res.stop, res.outcome), provider, runId2), uncovered };
|
|
75003
75088
|
const rdy = events2.find((e10) => e10.type === "stage.completed" && e10.stage === "intake")?.data.readiness, foldTail = [handoffRef, typeof rdy === "string" ? rdy : ""].filter(Boolean).join("; ");
|
|
75004
75089
|
const riskLine = readRiskSummary(repoDir, t02);
|
|
75005
75090
|
process.stdout.write(json2 ? `${JSON.stringify({ ...JSON.parse(out3), summary: { ...summaryObject(ui2), ...riskLine ? { risk: riskLine } : {} } })}
|
|
@@ -75054,8 +75139,8 @@ var init_supervisor = __esm(() => {
|
|
|
75054
75139
|
});
|
|
75055
75140
|
|
|
75056
75141
|
// ../../loki-ts/src/e10ext/compound_match.ts
|
|
75057
|
-
import { readFileSync as
|
|
75058
|
-
import { basename as basename29, join as
|
|
75142
|
+
import { readFileSync as readFileSync100 } from "fs";
|
|
75143
|
+
import { basename as basename29, join as join116 } from "path";
|
|
75059
75144
|
function parts(s) {
|
|
75060
75145
|
return s.replace(/([a-z0-9])([A-Z])/g, "$1 $2").toLowerCase().match(/[a-z0-9]+/g) ?? [];
|
|
75061
75146
|
}
|
|
@@ -75082,7 +75167,7 @@ function linkedHits(word, repoMap, testMap, repoDir) {
|
|
|
75082
75167
|
continue;
|
|
75083
75168
|
let body;
|
|
75084
75169
|
try {
|
|
75085
|
-
body = importLines(
|
|
75170
|
+
body = importLines(readFileSync100(join116(repoDir, t.path), "utf8"));
|
|
75086
75171
|
} catch {
|
|
75087
75172
|
continue;
|
|
75088
75173
|
}
|
|
@@ -75103,8 +75188,8 @@ var init_compound_match = __esm(() => {
|
|
|
75103
75188
|
});
|
|
75104
75189
|
|
|
75105
75190
|
// ../../loki-ts/src/util/already_done_evidence.ts
|
|
75106
|
-
import { existsSync as existsSync81, readFileSync as
|
|
75107
|
-
import { basename as basename30, join as
|
|
75191
|
+
import { existsSync as existsSync81, readFileSync as readFileSync101 } from "fs";
|
|
75192
|
+
import { basename as basename30, join as join117 } from "path";
|
|
75108
75193
|
function keywords2(task) {
|
|
75109
75194
|
const words3 = task.toLowerCase().match(/[a-z0-9_]+/g) ?? [];
|
|
75110
75195
|
return Array.from(new Set(words3.filter((w) => w.length > 2 && !STOP_WORDS.has(w))));
|
|
@@ -75136,7 +75221,7 @@ function docEvidence(words3, repoDir) {
|
|
|
75136
75221
|
for (const name of DOC_FILES) {
|
|
75137
75222
|
let text4;
|
|
75138
75223
|
try {
|
|
75139
|
-
text4 =
|
|
75224
|
+
text4 = readFileSync101(join117(repoDir, name), "utf8");
|
|
75140
75225
|
} catch {
|
|
75141
75226
|
continue;
|
|
75142
75227
|
}
|
|
@@ -75198,7 +75283,7 @@ function citesToken(text4, token) {
|
|
|
75198
75283
|
function citesRealHit(text4, hit, repoDir) {
|
|
75199
75284
|
if (hit.source === "changelog")
|
|
75200
75285
|
return false;
|
|
75201
|
-
return (citesToken(text4, hit.path) || citesToken(text4, basename30(hit.path))) && existsSync81(
|
|
75286
|
+
return (citesToken(text4, hit.path) || citesToken(text4, basename30(hit.path))) && existsSync81(join117(repoDir, hit.path));
|
|
75202
75287
|
}
|
|
75203
75288
|
function renderAlreadyDoneComment(evidence) {
|
|
75204
75289
|
return ["Loki 10: no change needed. This already appears to be implemented.", "", "Evidence:", ...evidence.map((e10) => `- ${e10}`), ""].join(`
|
|
@@ -75400,9 +75485,9 @@ __export(exports_warm, {
|
|
|
75400
75485
|
WarmEngine: () => WarmEngine
|
|
75401
75486
|
});
|
|
75402
75487
|
import { createHash as createHash33 } from "crypto";
|
|
75403
|
-
import { existsSync as existsSync82, mkdirSync as mkdirSync64, readFileSync as
|
|
75488
|
+
import { existsSync as existsSync82, mkdirSync as mkdirSync64, readFileSync as readFileSync102, statSync as statSync32, unlinkSync as unlinkSync11 } from "fs";
|
|
75404
75489
|
import { createServer as createServer2 } from "net";
|
|
75405
|
-
import { dirname as
|
|
75490
|
+
import { dirname as dirname46, resolve as resolve37 } from "path";
|
|
75406
75491
|
function speedEnabled() {
|
|
75407
75492
|
return process.env["LOKI_SPEED"] !== "0";
|
|
75408
75493
|
}
|
|
@@ -75430,7 +75515,7 @@ function dirtyHash(repoDir) {
|
|
|
75430
75515
|
try {
|
|
75431
75516
|
const p = resolve37(repoDir, rel);
|
|
75432
75517
|
if (existsSync82(p) && statSync32(p).isFile() && statSync32(p).size <= MAX_HASHED_BYTES)
|
|
75433
|
-
h10.update(
|
|
75518
|
+
h10.update(readFileSync102(p));
|
|
75434
75519
|
} catch {}
|
|
75435
75520
|
}
|
|
75436
75521
|
return h10.digest("hex");
|
|
@@ -75483,7 +75568,7 @@ function startWarmIfEnabled() {
|
|
|
75483
75568
|
}
|
|
75484
75569
|
}
|
|
75485
75570
|
function startWarmServer(path = warmSocketPath(), engine = new WarmEngine) {
|
|
75486
|
-
mkdirSync64(
|
|
75571
|
+
mkdirSync64(dirname46(path), { recursive: true });
|
|
75487
75572
|
try {
|
|
75488
75573
|
unlinkSync11(path);
|
|
75489
75574
|
} catch {}
|
|
@@ -75542,7 +75627,7 @@ var init_warm = __esm(() => {
|
|
|
75542
75627
|
import { execFile as execFile3 } from "child_process";
|
|
75543
75628
|
import { mkdirSync as mkdirSync65, mkdtempSync as mkdtempSync16, rmSync as rmSync34 } from "fs";
|
|
75544
75629
|
import { tmpdir as tmpdir20 } from "os";
|
|
75545
|
-
import { join as
|
|
75630
|
+
import { join as join118 } from "path";
|
|
75546
75631
|
function hitsUnchangedFromBase(repoDir, baseSha, paths) {
|
|
75547
75632
|
if (paths.length === 0 || !baseSha)
|
|
75548
75633
|
return false;
|
|
@@ -75580,23 +75665,23 @@ function dropRoot(root) {
|
|
|
75580
75665
|
function pinBaseTree(ctx, signal) {
|
|
75581
75666
|
let root;
|
|
75582
75667
|
try {
|
|
75583
|
-
root = mkdtempSync16(
|
|
75668
|
+
root = mkdtempSync16(join118(tmpdir20(), "loki-already-done-"));
|
|
75584
75669
|
} catch {
|
|
75585
75670
|
return Promise.resolve(null);
|
|
75586
75671
|
}
|
|
75587
75672
|
trackRoot(root);
|
|
75588
75673
|
try {
|
|
75589
|
-
mkdirSync65(
|
|
75674
|
+
mkdirSync65(join118(root, "tree"));
|
|
75590
75675
|
} catch {
|
|
75591
75676
|
dropRoot(root);
|
|
75592
75677
|
return Promise.resolve(null);
|
|
75593
75678
|
}
|
|
75594
|
-
const tarball =
|
|
75679
|
+
const tarball = join118(root, "base.tar");
|
|
75595
75680
|
const step = (cmd2, args, cwd) => new Promise((res) => {
|
|
75596
75681
|
execFile3(cmd2, args, { env: process.env, signal, cwd }, (err) => res(!err));
|
|
75597
75682
|
});
|
|
75598
75683
|
return (async () => {
|
|
75599
|
-
if (!ctx.baseSha || (await safeGitRun(ctx.repoDir, ["archive", "-o", tarball, ctx.baseSha], { signal })).exitCode !== 0 || !await step("tar", ["-x", "-f", tarball, "-C",
|
|
75684
|
+
if (!ctx.baseSha || (await safeGitRun(ctx.repoDir, ["archive", "-o", tarball, ctx.baseSha], { signal })).exitCode !== 0 || !await step("tar", ["-x", "-f", tarball, "-C", join118(root, "tree")], root)) {
|
|
75600
75685
|
dropRoot(root);
|
|
75601
75686
|
return null;
|
|
75602
75687
|
}
|
|
@@ -75654,7 +75739,7 @@ function deferAlreadyDone(ctx, signal, task, repoMap, testMap, apply) {
|
|
|
75654
75739
|
if (!root)
|
|
75655
75740
|
return;
|
|
75656
75741
|
try {
|
|
75657
|
-
const r = await checkAlreadyDone({ ...ctx, repoDir:
|
|
75742
|
+
const r = await checkAlreadyDone({ ...ctx, repoDir: join118(root, "tree"), sessions: inner }, check.signal, task, repoMap, testMap);
|
|
75658
75743
|
const ph = phase;
|
|
75659
75744
|
if (r && ph !== "done" && !check.signal.aborted) {
|
|
75660
75745
|
hit = r;
|
|
@@ -75680,8 +75765,8 @@ __export(exports_intake, {
|
|
|
75680
75765
|
stage: () => stage8,
|
|
75681
75766
|
runIntake: () => runIntake
|
|
75682
75767
|
});
|
|
75683
|
-
import { appendFileSync as appendFileSync14, existsSync as existsSync83, mkdirSync as mkdirSync66, readFileSync as
|
|
75684
|
-
import { dirname as
|
|
75768
|
+
import { appendFileSync as appendFileSync14, existsSync as existsSync83, mkdirSync as mkdirSync66, readFileSync as readFileSync103, writeFileSync as writeFileSync61 } from "fs";
|
|
75769
|
+
import { dirname as dirname47, join as join119, resolve as resolve38 } from "path";
|
|
75685
75770
|
function issueRefOf(raw2) {
|
|
75686
75771
|
return typeof raw2.repo === "string" && raw2.repo && typeof raw2.number === "number" ? `${raw2.repo}#${raw2.number}` : null;
|
|
75687
75772
|
}
|
|
@@ -75701,15 +75786,15 @@ function ensureBranch(repoDir, branch, from) {
|
|
|
75701
75786
|
}
|
|
75702
75787
|
}
|
|
75703
75788
|
function excludeLokiDir(repoDir) {
|
|
75704
|
-
let path =
|
|
75789
|
+
let path = join119(repoDir, ".git", "info", "exclude");
|
|
75705
75790
|
try {
|
|
75706
75791
|
path = resolve38(repoDir, git13(repoDir, ["rev-parse", "--git-path", "info/exclude"]));
|
|
75707
75792
|
} catch {}
|
|
75708
|
-
const existing = existsSync83(path) ?
|
|
75793
|
+
const existing = existsSync83(path) ? readFileSync103(path, "utf8") : "";
|
|
75709
75794
|
if (existing.split(`
|
|
75710
75795
|
`).some((l) => l.trim() === ".loki/"))
|
|
75711
75796
|
return;
|
|
75712
|
-
mkdirSync66(
|
|
75797
|
+
mkdirSync66(dirname47(path), { recursive: true });
|
|
75713
75798
|
const sep20 = existing.length > 0 && !existing.endsWith(`
|
|
75714
75799
|
`) ? `
|
|
75715
75800
|
` : "";
|
|
@@ -75717,7 +75802,7 @@ function excludeLokiDir(repoDir) {
|
|
|
75717
75802
|
`);
|
|
75718
75803
|
}
|
|
75719
75804
|
function loadIssue(path) {
|
|
75720
|
-
const raw2 = JSON.parse(
|
|
75805
|
+
const raw2 = JSON.parse(readFileSync103(path, "utf8"));
|
|
75721
75806
|
return { state: typeof raw2.state === "string" ? raw2.state.toLowerCase() : null, closed_by_merged_pr: raw2.closed_by_merged_pr === true };
|
|
75722
75807
|
}
|
|
75723
75808
|
function isAlreadyDone(issue) {
|
|
@@ -75767,7 +75852,7 @@ async function runIntakeBody(ctx, signal, opts, held) {
|
|
|
75767
75852
|
ensureBranch(ctx.repoDir, ctx.branch);
|
|
75768
75853
|
const tree = git13(ctx.repoDir, ["rev-parse", "HEAD^{tree}"]);
|
|
75769
75854
|
excludeLokiDir(ctx.repoDir);
|
|
75770
|
-
const issueJsonPath = opts.issueJsonPath ?? process.env.LOKI_E10_ISSUE_JSON ??
|
|
75855
|
+
const issueJsonPath = opts.issueJsonPath ?? process.env.LOKI_E10_ISSUE_JSON ?? join119(ctx.runDir, "issue.json");
|
|
75771
75856
|
const taskText = opts.taskText ?? process.env.LOKI_E10_TASK_TEXT;
|
|
75772
75857
|
let source;
|
|
75773
75858
|
let taskSha256;
|
|
@@ -75776,7 +75861,7 @@ async function runIntakeBody(ctx, signal, opts, held) {
|
|
|
75776
75861
|
let issueRef = null;
|
|
75777
75862
|
if (existsSync83(issueJsonPath)) {
|
|
75778
75863
|
source = "issue";
|
|
75779
|
-
const raw2 =
|
|
75864
|
+
const raw2 = readFileSync103(issueJsonPath, "utf8");
|
|
75780
75865
|
taskSha256 = sha2562(raw2);
|
|
75781
75866
|
const i = JSON.parse(raw2);
|
|
75782
75867
|
task = [i.title, i.body].filter((x3) => typeof x3 === "string" && x3 !== "").join(`
|
|
@@ -75797,7 +75882,7 @@ async function runIntakeBody(ctx, signal, opts, held) {
|
|
|
75797
75882
|
return { status: "completed", data: { ...common, task_sha256: taskSha256, source, base_sha: baseSha, tree, branch: ctx.branch, already_satisfied: true } };
|
|
75798
75883
|
}
|
|
75799
75884
|
mkdirSync66(ctx.runDir, { recursive: true });
|
|
75800
|
-
const repomapRef =
|
|
75885
|
+
const repomapRef = join119(ctx.runDir, "repomap.json");
|
|
75801
75886
|
const cacheDir = repoCacheDir(repoKey(null, ctx.repoDir));
|
|
75802
75887
|
const repoMap = cachedRepoMap(cacheDir, tree, () => buildRepoMap(ctx.repoDir));
|
|
75803
75888
|
writeFileSync61(repomapRef, JSON.stringify(repoMap));
|
|
@@ -75818,7 +75903,7 @@ async function runIntakeBody(ctx, signal, opts, held) {
|
|
|
75818
75903
|
const already = speedEnabled() ? null : await checkAlreadyDone(ctx, signal, task, repoMap, testmap);
|
|
75819
75904
|
const alreadyData = (already2) => {
|
|
75820
75905
|
const comment = renderAlreadyDoneComment(already2.evidence);
|
|
75821
|
-
const bodyFile =
|
|
75906
|
+
const bodyFile = join119(ctx.runDir, "already-done-comment.md");
|
|
75822
75907
|
writeFileSync61(bodyFile, comment, "utf8");
|
|
75823
75908
|
const commentArgv = source === "issue" && issueRef ? buildAlreadyDoneCommentArgv(ctx.runId, issueRef, bodyFile) : undefined;
|
|
75824
75909
|
return { already_satisfied: true, evidence: already2.evidence, iteration_ids: [`${ctx.runId}-already-done`], comment, ...commentArgv ? { comment_argv: commentArgv } : {} };
|
|
@@ -75915,6 +76000,7 @@ var init_fix = __esm(() => {
|
|
|
75915
76000
|
init_anti_loop();
|
|
75916
76001
|
init_session_resume();
|
|
75917
76002
|
init_conflict_resume();
|
|
76003
|
+
init_wall_owned();
|
|
75918
76004
|
init_implement();
|
|
75919
76005
|
init_install();
|
|
75920
76006
|
fixStage = {
|
|
@@ -75962,7 +76048,7 @@ var init_fix = __esm(() => {
|
|
|
75962
76048
|
const ro = prior.wall?.readOnlyFiles ?? [], wd2 = r.session.markers.specConflict && !r.session.killed ? await adjudicateWallConflict(ctx, { ...sessionBase, iterationId: r.ids[r.ids.length - 1], brief: fullBrief }, r.session, ro) : null;
|
|
75963
76049
|
if (wd2)
|
|
75964
76050
|
r = { ...r, session: wd2.session, ids: [...r.ids, ...wd2.ids] };
|
|
75965
|
-
const testsReverted = restoreReadOnly(ro), wallDefect = wd2?.defect ?? prior.fix?.wall_defect;
|
|
76051
|
+
const testsReverted = restoreReadOnly(ro), wallDefect = wd2?.defect ?? prior.fix?.wall_defect, wallDefects = accumulateWallDefects(prior.fix, wd2?.defect);
|
|
75966
76052
|
const treeAfter = treeFingerprint(ctx.repoDir, ctx.baseSha), conflict = r.session.markers.specConflict && !r.session.killed && treeBefore !== null && treeBefore === treeAfter ? r.session.markers.specConflict : null;
|
|
75967
76053
|
ctx.emit("fix.round", "fix", {
|
|
75968
76054
|
round: round2,
|
|
@@ -75988,6 +76074,7 @@ var init_fix = __esm(() => {
|
|
|
75988
76074
|
killed: r.session.killed,
|
|
75989
76075
|
tests_reverted: testsReverted,
|
|
75990
76076
|
...wallDefect ? { wall_defect: wallDefect } : {},
|
|
76077
|
+
...wallDefects.length ? { wall_defects: wallDefects } : {},
|
|
75991
76078
|
cascade: repeated,
|
|
75992
76079
|
model: actualModel,
|
|
75993
76080
|
...stallEsc ? { stall_escalated: true } : {},
|
|
@@ -76010,7 +76097,7 @@ __export(exports_keys_cmd, {
|
|
|
76010
76097
|
takePubkey: () => takePubkey,
|
|
76011
76098
|
main: () => main5
|
|
76012
76099
|
});
|
|
76013
|
-
import { readFileSync as
|
|
76100
|
+
import { readFileSync as readFileSync104 } from "fs";
|
|
76014
76101
|
import { parseArgs } from "util";
|
|
76015
76102
|
import { createPublicKey as createPublicKey4 } from "crypto";
|
|
76016
76103
|
function takePubkey(args) {
|
|
@@ -76023,7 +76110,7 @@ function takePubkey(args) {
|
|
|
76023
76110
|
return { args: rest };
|
|
76024
76111
|
if (!(file = pubkey[0]))
|
|
76025
76112
|
throw new Error("--pubkey requires a file argument");
|
|
76026
|
-
const t =
|
|
76113
|
+
const t = readFileSync104(file, "utf8"), key = createPublicKey4(t.trim().startsWith("{") ? { key: JSON.parse(t), format: "jwk" } : t);
|
|
76027
76114
|
return key.asymmetricKeyType === "ed25519" ? { args: rest, pubkey: key } : { args: rest, error: `cannot read an Ed25519 public key from ${file}` };
|
|
76028
76115
|
} catch (e10) {
|
|
76029
76116
|
return { args: [], error: file ? `cannot read an Ed25519 public key from ${file}` : e10.message.replace(/^./, (c) => c.toLowerCase()) };
|
|
@@ -76281,7 +76368,7 @@ var groupRoute = async (repoDir, rawGroup) => {
|
|
|
76281
76368
|
};
|
|
76282
76369
|
|
|
76283
76370
|
// ../../loki-ts/src/engine10/modernize/types.ts
|
|
76284
|
-
import { join as
|
|
76371
|
+
import { join as join120 } from "path";
|
|
76285
76372
|
function makeModernizeId(now2 = new Date) {
|
|
76286
76373
|
const utc = now2.toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z");
|
|
76287
76374
|
const short = Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0");
|
|
@@ -76291,13 +76378,13 @@ function isModernizeId(mid) {
|
|
|
76291
76378
|
return MID_RE.test(mid);
|
|
76292
76379
|
}
|
|
76293
76380
|
function modernizeRoot(repoDir, mid) {
|
|
76294
|
-
return
|
|
76381
|
+
return join120(repoDir, ".loki", "modernize", mid);
|
|
76295
76382
|
}
|
|
76296
76383
|
function modernizeEventsPath(repoDir, mid) {
|
|
76297
|
-
return
|
|
76384
|
+
return join120(modernizeRoot(repoDir, mid), "events.jsonl");
|
|
76298
76385
|
}
|
|
76299
76386
|
function planPath(repoDir, mid) {
|
|
76300
|
-
return
|
|
76387
|
+
return join120(modernizeRoot(repoDir, mid), "plan.json");
|
|
76301
76388
|
}
|
|
76302
76389
|
function isSafeUnitId(unit) {
|
|
76303
76390
|
return typeof unit === "string" && unit.length <= MAX_UNIT_ID && UNIT_ID_RE2.test(unit) && !unit.includes("..");
|
|
@@ -76308,13 +76395,13 @@ function encodeUnitId(unit) {
|
|
|
76308
76395
|
return unit.replace(/\//g, "%2F");
|
|
76309
76396
|
}
|
|
76310
76397
|
function oracleDir(repoDir, mid, unit) {
|
|
76311
|
-
return
|
|
76398
|
+
return join120(modernizeRoot(repoDir, mid), "oracle", encodeUnitId(unit));
|
|
76312
76399
|
}
|
|
76313
76400
|
function reportJsonPath(repoDir, mid) {
|
|
76314
|
-
return
|
|
76401
|
+
return join120(modernizeRoot(repoDir, mid), "report.json");
|
|
76315
76402
|
}
|
|
76316
76403
|
function reportMdPath(repoDir, mid) {
|
|
76317
|
-
return
|
|
76404
|
+
return join120(modernizeRoot(repoDir, mid), "report.md");
|
|
76318
76405
|
}
|
|
76319
76406
|
var MID_RE, UNIT_ID_SEGMENT = "[A-Za-z0-9][A-Za-z0-9_.-]*", UNIT_ID_RE2, MAX_UNIT_ID = 128;
|
|
76320
76407
|
var init_types2 = __esm(() => {
|
|
@@ -76354,9 +76441,9 @@ __export(exports_dashboard, {
|
|
|
76354
76441
|
listModernizeIds: () => listModernizeIds
|
|
76355
76442
|
});
|
|
76356
76443
|
import { existsSync as existsSync84, readdirSync as readdirSync36 } from "fs";
|
|
76357
|
-
import { join as
|
|
76444
|
+
import { join as join121 } from "path";
|
|
76358
76445
|
function modernizeDir(repoDir) {
|
|
76359
|
-
return
|
|
76446
|
+
return join121(repoDir, ".loki", "modernize");
|
|
76360
76447
|
}
|
|
76361
76448
|
function listModernizeIds(repoDir) {
|
|
76362
76449
|
const dir = modernizeDir(repoDir);
|
|
@@ -76691,11 +76778,11 @@ var init_engine10_dashboard = __esm(() => {
|
|
|
76691
76778
|
});
|
|
76692
76779
|
|
|
76693
76780
|
// ../../loki-ts/src/engine10/modernize/inventory.ts
|
|
76694
|
-
import { readFileSync as
|
|
76695
|
-
import { extname as extname4, join as
|
|
76781
|
+
import { readFileSync as readFileSync105 } from "fs";
|
|
76782
|
+
import { extname as extname4, join as join122 } from "path";
|
|
76696
76783
|
function readCapped2(absPath) {
|
|
76697
76784
|
try {
|
|
76698
|
-
return
|
|
76785
|
+
return readFileSync105(absPath, "utf8").slice(0, MAX_SCAN_BYTES2);
|
|
76699
76786
|
} catch {
|
|
76700
76787
|
return "";
|
|
76701
76788
|
}
|
|
@@ -76712,9 +76799,9 @@ function detectEntryPoints(repoDir, files) {
|
|
|
76712
76799
|
const out3 = [];
|
|
76713
76800
|
for (const rel of files) {
|
|
76714
76801
|
const ext = extname4(rel);
|
|
76715
|
-
if (ext === ".py" && PY_MAIN_RE.test(readCapped2(
|
|
76802
|
+
if (ext === ".py" && PY_MAIN_RE.test(readCapped2(join122(repoDir, rel))))
|
|
76716
76803
|
out3.push(rel);
|
|
76717
|
-
else if (ext === ".java" && JAVA_MAIN_RE.test(readCapped2(
|
|
76804
|
+
else if (ext === ".java" && JAVA_MAIN_RE.test(readCapped2(join122(repoDir, rel))))
|
|
76718
76805
|
out3.push(rel);
|
|
76719
76806
|
}
|
|
76720
76807
|
return out3;
|
|
@@ -76764,7 +76851,7 @@ var init_inventory = __esm(() => {
|
|
|
76764
76851
|
});
|
|
76765
76852
|
|
|
76766
76853
|
// ../../loki-ts/src/engine10/modernize/lang/python.ts
|
|
76767
|
-
import { join as
|
|
76854
|
+
import { join as join123 } from "path";
|
|
76768
76855
|
async function buildPythonGraph(repoDir, files, opts = {}) {
|
|
76769
76856
|
if (files.length === 0)
|
|
76770
76857
|
return { graph: { nodes: [], edges: [] }, unresolved: [] };
|
|
@@ -76803,7 +76890,7 @@ var init_python2 = __esm(() => {
|
|
|
76803
76890
|
init_paths();
|
|
76804
76891
|
init_python();
|
|
76805
76892
|
init_shell();
|
|
76806
|
-
SCRIPT =
|
|
76893
|
+
SCRIPT = join123(REPO_ROOT, "autonomy", "lib", "modernize", "py_imports.py");
|
|
76807
76894
|
});
|
|
76808
76895
|
|
|
76809
76896
|
// ../../loki-ts/src/engine10/modernize/cluster.ts
|
|
@@ -76982,8 +77069,8 @@ var init_codemod = __esm(() => {
|
|
|
76982
77069
|
|
|
76983
77070
|
// ../../loki-ts/src/engine10/modernize/oracle/seal.ts
|
|
76984
77071
|
import { createHash as createHash34 } from "crypto";
|
|
76985
|
-
import { existsSync as existsSync85, mkdirSync as mkdirSync67, readFileSync as
|
|
76986
|
-
import { join as
|
|
77072
|
+
import { existsSync as existsSync85, mkdirSync as mkdirSync67, readFileSync as readFileSync106, writeFileSync as writeFileSync62 } from "fs";
|
|
77073
|
+
import { join as join124 } from "path";
|
|
76987
77074
|
function normalizersSha(n11) {
|
|
76988
77075
|
return sha2564(JSON.stringify({
|
|
76989
77076
|
float_tolerance: n11.float_tolerance,
|
|
@@ -77045,9 +77132,9 @@ function alreadySealedInLog(repoDir, mid, unit) {
|
|
|
77045
77132
|
}
|
|
77046
77133
|
function sealOracle(repoDir, mid, unit, log, normalizers = DEFAULT_NORMALIZERS) {
|
|
77047
77134
|
const dir = oracleDir(repoDir, mid, unit);
|
|
77048
|
-
const casesPath =
|
|
77049
|
-
const coveragePath =
|
|
77050
|
-
const sealedPath =
|
|
77135
|
+
const casesPath = join124(dir, "cases.jsonl");
|
|
77136
|
+
const coveragePath = join124(dir, "coverage.json");
|
|
77137
|
+
const sealedPath = join124(dir, "sealed.json");
|
|
77051
77138
|
if (alreadySealedInLog(repoDir, mid, unit)) {
|
|
77052
77139
|
throw new Error(`oracle seal: ${unit} already has a sealing event in the modernize log; re-seal refused (seal is write-once)`);
|
|
77053
77140
|
}
|
|
@@ -77058,8 +77145,8 @@ function sealOracle(repoDir, mid, unit, log, normalizers = DEFAULT_NORMALIZERS)
|
|
|
77058
77145
|
throw new Error(`oracle seal: missing ${casesPath}`);
|
|
77059
77146
|
if (!existsSync85(coveragePath))
|
|
77060
77147
|
throw new Error(`oracle seal: missing ${coveragePath}`);
|
|
77061
|
-
const casesRaw =
|
|
77062
|
-
const coverageRaw =
|
|
77148
|
+
const casesRaw = readFileSync106(casesPath, "utf8");
|
|
77149
|
+
const coverageRaw = readFileSync106(coveragePath, "utf8");
|
|
77063
77150
|
const normalizersHash = normalizersSha(normalizers);
|
|
77064
77151
|
const sealed = buildSealedOracle(unit, casesRaw, coverageRaw, normalizersHash);
|
|
77065
77152
|
mkdirSync67(dir, { recursive: true });
|
|
@@ -77078,9 +77165,9 @@ function sealOracle(repoDir, mid, unit, log, normalizers = DEFAULT_NORMALIZERS)
|
|
|
77078
77165
|
}
|
|
77079
77166
|
function verifySeal(repoDir, mid, unit) {
|
|
77080
77167
|
const dir = oracleDir(repoDir, mid, unit);
|
|
77081
|
-
const sealedPath =
|
|
77082
|
-
const casesPath =
|
|
77083
|
-
const coveragePath =
|
|
77168
|
+
const sealedPath = join124(dir, "sealed.json");
|
|
77169
|
+
const casesPath = join124(dir, "cases.jsonl");
|
|
77170
|
+
const coveragePath = join124(dir, "coverage.json");
|
|
77084
77171
|
if (!existsSync85(sealedPath))
|
|
77085
77172
|
return { ok: false, reason: "no sealed.json" };
|
|
77086
77173
|
if (!existsSync85(casesPath))
|
|
@@ -77091,11 +77178,11 @@ function verifySeal(repoDir, mid, unit) {
|
|
|
77091
77178
|
if (!sealEvent) {
|
|
77092
77179
|
return { ok: false, reason: "no sealing event for this unit in the modernize log; sealed.json is not anchored" };
|
|
77093
77180
|
}
|
|
77094
|
-
const casesRaw =
|
|
77181
|
+
const casesRaw = readFileSync106(casesPath, "utf8");
|
|
77095
77182
|
if (sha2564(casesRaw) !== sealEvent.data.cases_sha256) {
|
|
77096
77183
|
return { ok: false, reason: "cases.jsonl does not match the sealing event's hash (tampered or re-captured)" };
|
|
77097
77184
|
}
|
|
77098
|
-
const coverageRaw =
|
|
77185
|
+
const coverageRaw = readFileSync106(coveragePath, "utf8");
|
|
77099
77186
|
if (sha2564(coverageRaw) !== sealEvent.data.coverage_sha256) {
|
|
77100
77187
|
return { ok: false, reason: "coverage.json does not match the sealing event's hash (tampered or re-captured)" };
|
|
77101
77188
|
}
|
|
@@ -77111,7 +77198,7 @@ function verifySeal(repoDir, mid, unit) {
|
|
|
77111
77198
|
reason: `verdict does not match the sealing event (event type ${sealEvent.type}, recomputed verdict ${recomputed.verdict})`
|
|
77112
77199
|
};
|
|
77113
77200
|
}
|
|
77114
|
-
const sealed = JSON.parse(
|
|
77201
|
+
const sealed = JSON.parse(readFileSync106(sealedPath, "utf8"));
|
|
77115
77202
|
if (JSON.stringify(sealed) !== JSON.stringify(recomputed)) {
|
|
77116
77203
|
return { ok: false, reason: "sealed.json does not match the record recomputed from cases.jsonl and coverage.json (hand-edited)" };
|
|
77117
77204
|
}
|
|
@@ -77127,9 +77214,9 @@ var init_seal2 = __esm(() => {
|
|
|
77127
77214
|
|
|
77128
77215
|
// ../../loki-ts/src/engine10/modernize/oracle/search.ts
|
|
77129
77216
|
import { spawnSync as spawnSync18 } from "child_process";
|
|
77130
|
-
import { copyFileSync as copyFileSync6, existsSync as existsSync86, linkSync as linkSync4, mkdirSync as mkdirSync68, mkdtempSync as mkdtempSync17, readFileSync as
|
|
77217
|
+
import { copyFileSync as copyFileSync6, existsSync as existsSync86, linkSync as linkSync4, mkdirSync as mkdirSync68, mkdtempSync as mkdtempSync17, readFileSync as readFileSync107, renameSync as renameSync22, rmSync as rmSync35, rmdirSync as rmdirSync2, writeFileSync as writeFileSync63 } from "fs";
|
|
77131
77218
|
import { tmpdir as tmpdir21 } from "os";
|
|
77132
|
-
import { basename as basename31, dirname as
|
|
77219
|
+
import { basename as basename31, dirname as dirname48, join as join125 } from "path";
|
|
77133
77220
|
function search(unitSource, seedCases, propose, runCapture, opts = {}) {
|
|
77134
77221
|
const maxRounds = opts.maxRounds ?? 10;
|
|
77135
77222
|
const plateauLimit = opts.plateauRounds ?? 2;
|
|
@@ -77186,10 +77273,10 @@ function realCaptureRunner(unitPath, cases, outPath) {
|
|
|
77186
77273
|
return captureFailed("old runtime unavailable");
|
|
77187
77274
|
let dir = "";
|
|
77188
77275
|
try {
|
|
77189
|
-
dir = mkdtempSync17(
|
|
77190
|
-
const casesFile =
|
|
77191
|
-
const outFile =
|
|
77192
|
-
const covFile =
|
|
77276
|
+
dir = mkdtempSync17(join125(tmpdir21(), "m10-search-"));
|
|
77277
|
+
const casesFile = join125(dir, "cases.jsonl");
|
|
77278
|
+
const outFile = join125(dir, "out.jsonl");
|
|
77279
|
+
const covFile = join125(dir, "coverage.json");
|
|
77193
77280
|
const lines2 = cases.map((c) => JSON.stringify({ entry: c.entry, args: c.args, kwargs: c.kwargs }));
|
|
77194
77281
|
writeFileSync63(casesFile, lines2.length ? lines2.join(`
|
|
77195
77282
|
`) + `
|
|
@@ -77210,7 +77297,7 @@ function realCaptureRunner(unitPath, cases, outPath) {
|
|
|
77210
77297
|
`).find((l) => l.trim().length > 0) ?? "(no stderr)";
|
|
77211
77298
|
return captureFailed(`py_capture.py exit ${r.status}: ${firstErrLine}`);
|
|
77212
77299
|
}
|
|
77213
|
-
const raw2 = JSON.parse(
|
|
77300
|
+
const raw2 = JSON.parse(readFileSync107(covFile, "utf8"));
|
|
77214
77301
|
if (outPath)
|
|
77215
77302
|
copyFileSync6(outFile, outPath);
|
|
77216
77303
|
return {
|
|
@@ -77237,13 +77324,13 @@ function resolveOldRuntimeSync() {
|
|
|
77237
77324
|
}
|
|
77238
77325
|
function makeProposeInputs(session, cap = 20) {
|
|
77239
77326
|
return (unitPath, missing, round2) => {
|
|
77240
|
-
const cwd = mkdtempSync17(
|
|
77327
|
+
const cwd = mkdtempSync17(join125(tmpdir21(), "m27-propose-"));
|
|
77241
77328
|
try {
|
|
77242
|
-
const unitFile =
|
|
77329
|
+
const unitFile = join125(cwd, basename31(unitPath));
|
|
77243
77330
|
copyFileSync6(unitPath, unitFile);
|
|
77244
77331
|
session({ cwd, env: tokenFreeEnv(), unitFile, missing, round: round2 });
|
|
77245
77332
|
const out3 = [];
|
|
77246
|
-
for (const line2 of
|
|
77333
|
+
for (const line2 of readFileSync107(join125(cwd, "proposals.jsonl"), "utf8").split(`
|
|
77247
77334
|
`)) {
|
|
77248
77335
|
try {
|
|
77249
77336
|
const c = JSON.parse(line2);
|
|
@@ -77261,7 +77348,7 @@ function makeProposeInputs(session, cap = 20) {
|
|
|
77261
77348
|
}
|
|
77262
77349
|
function captureUnitOracle(a) {
|
|
77263
77350
|
const dir = oracleDir(a.repoDir, a.mid, a.unit);
|
|
77264
|
-
if (existsSync86(
|
|
77351
|
+
if (existsSync86(join125(dir, "cases.jsonl")) || alreadySealedInLog(a.repoDir, a.mid, a.unit)) {
|
|
77265
77352
|
return { ok: false, reason: "oracle already captured (write-once)" };
|
|
77266
77353
|
}
|
|
77267
77354
|
const run2 = a.runCapture ?? realCaptureRunner;
|
|
@@ -77281,21 +77368,21 @@ function captureUnitOracle(a) {
|
|
|
77281
77368
|
}
|
|
77282
77369
|
if (r.cases.length === 0)
|
|
77283
77370
|
return { ok: false, reason: "no cases captured" };
|
|
77284
|
-
const scratch = mkdtempSync17(
|
|
77285
|
-
const t12 =
|
|
77371
|
+
const scratch = mkdtempSync17(join125(tmpdir21(), "m27-replay-"));
|
|
77372
|
+
const t12 = join125(scratch, "cases"), t22 = join125(scratch, "replay");
|
|
77286
77373
|
const created = [];
|
|
77287
|
-
for (let p = dir;!existsSync86(p) && !created.includes(p); p =
|
|
77374
|
+
for (let p = dir;!existsSync86(p) && !created.includes(p); p = dirname48(p))
|
|
77288
77375
|
created.push(p);
|
|
77289
|
-
const
|
|
77376
|
+
const read3 = (p) => readFileSync107(p, "utf8").split(`
|
|
77290
77377
|
`).filter(Boolean).map((l) => JSON.parse(l));
|
|
77291
|
-
const tmpCases =
|
|
77292
|
-
const tmpCov =
|
|
77378
|
+
const tmpCases = join125(dir, `.cases.${process.pid}.tmp`);
|
|
77379
|
+
const tmpCov = join125(dir, `.coverage.${process.pid}.tmp`);
|
|
77293
77380
|
try {
|
|
77294
77381
|
const cov = run2(a.unitPath, r.cases, t12);
|
|
77295
77382
|
const cov2 = run2(a.unitPath, r.cases, t22);
|
|
77296
77383
|
if (cov.branchesTotal < 0 || cov2.branchesTotal < 0)
|
|
77297
77384
|
return { ok: false, reason: cov.error ?? cov2.error ?? "replay failed" };
|
|
77298
|
-
const recs =
|
|
77385
|
+
const recs = read3(t12), again = read3(t22);
|
|
77299
77386
|
if (recs.length !== r.cases.length || again.length !== recs.length)
|
|
77300
77387
|
return { ok: false, reason: "capture records missing" };
|
|
77301
77388
|
recs.forEach((rec2, i) => {
|
|
@@ -77317,10 +77404,10 @@ function captureUnitOracle(a) {
|
|
|
77317
77404
|
branch_pct: cov.branchPct,
|
|
77318
77405
|
missing: cov.missing
|
|
77319
77406
|
}));
|
|
77320
|
-
if (existsSync86(
|
|
77407
|
+
if (existsSync86(join125(dir, "cases.jsonl")))
|
|
77321
77408
|
return { ok: false, reason: "oracle already captured (write-once)" };
|
|
77322
|
-
renameSync22(tmpCov,
|
|
77323
|
-
(a.link ?? linkSync4)(tmpCases,
|
|
77409
|
+
renameSync22(tmpCov, join125(dir, "coverage.json"));
|
|
77410
|
+
(a.link ?? linkSync4)(tmpCases, join125(dir, "cases.jsonl"));
|
|
77324
77411
|
return { ok: true, cases: r.cases.length, branchPct: cov.branchPct, stoppedReason: r.stoppedReason };
|
|
77325
77412
|
} catch (e10) {
|
|
77326
77413
|
return { ok: false, reason: `capture error: ${e10 instanceof Error ? e10.message : String(e10)}` };
|
|
@@ -77328,8 +77415,8 @@ function captureUnitOracle(a) {
|
|
|
77328
77415
|
rmSync35(scratch, { recursive: true, force: true });
|
|
77329
77416
|
for (const t of [tmpCases, tmpCov])
|
|
77330
77417
|
rmSync35(t, { force: true });
|
|
77331
|
-
if (created[0] === dir && !existsSync86(
|
|
77332
|
-
rmSync35(
|
|
77418
|
+
if (created[0] === dir && !existsSync86(join125(dir, "cases.jsonl")))
|
|
77419
|
+
rmSync35(join125(dir, "coverage.json"), { force: true });
|
|
77333
77420
|
for (const p of created) {
|
|
77334
77421
|
try {
|
|
77335
77422
|
rmdirSync2(p);
|
|
@@ -77345,12 +77432,12 @@ var init_search = __esm(() => {
|
|
|
77345
77432
|
init_safe_git();
|
|
77346
77433
|
init_types2();
|
|
77347
77434
|
init_seal2();
|
|
77348
|
-
PY_CAPTURE_SCRIPT =
|
|
77435
|
+
PY_CAPTURE_SCRIPT = join125(REPO_ROOT, "autonomy", "lib", "modernize", "py_capture.py");
|
|
77349
77436
|
});
|
|
77350
77437
|
|
|
77351
77438
|
// ../../loki-ts/src/engine10/modernize/equiv.ts
|
|
77352
|
-
import { readFileSync as
|
|
77353
|
-
import { join as
|
|
77439
|
+
import { readFileSync as readFileSync108 } from "fs";
|
|
77440
|
+
import { join as join126 } from "path";
|
|
77354
77441
|
function parseCases(raw2) {
|
|
77355
77442
|
const out3 = [];
|
|
77356
77443
|
for (const line2 of raw2.split(`
|
|
@@ -77545,11 +77632,11 @@ function checkEquivalence(repoDir, mid, unit, newTreeDir, normalizers, runNew, l
|
|
|
77545
77632
|
return notProvenResult(unit, "normalizers invalid: skip_fields covers every field, nothing would be compared", log);
|
|
77546
77633
|
}
|
|
77547
77634
|
const dir = oracleDir(repoDir, mid, unit);
|
|
77548
|
-
const sealed = JSON.parse(
|
|
77635
|
+
const sealed = JSON.parse(readFileSync108(join126(dir, "sealed.json"), "utf8"));
|
|
77549
77636
|
const normCheck = verifyNormalizersAgainstSeal(sealed, normalizers);
|
|
77550
77637
|
if (!normCheck.ok)
|
|
77551
77638
|
return notProvenResult(unit, `normalizers: ${normCheck.reason ?? "check failed"}`, log);
|
|
77552
|
-
const records = parseCases(
|
|
77639
|
+
const records = parseCases(readFileSync108(join126(dir, "cases.jsonl"), "utf8"));
|
|
77553
77640
|
const heldOutSet = new Set(sealed.held_out);
|
|
77554
77641
|
let pass = 0;
|
|
77555
77642
|
let fail2 = 0;
|
|
@@ -77740,7 +77827,7 @@ var init_reslice = __esm(() => {
|
|
|
77740
77827
|
});
|
|
77741
77828
|
|
|
77742
77829
|
// ../../loki-ts/src/engine10/modernize/scheduler.ts
|
|
77743
|
-
import { join as
|
|
77830
|
+
import { join as join127 } from "path";
|
|
77744
77831
|
function mergeOnce(unit, ops, log, completed, worktree) {
|
|
77745
77832
|
if (completed.has(unit))
|
|
77746
77833
|
return "already_completed";
|
|
@@ -77861,7 +77948,7 @@ async function schedule(plan, opts) {
|
|
|
77861
77948
|
reason = hit ? "budget stop" : "per-unit cost cap reached";
|
|
77862
77949
|
break;
|
|
77863
77950
|
}
|
|
77864
|
-
const path =
|
|
77951
|
+
const path = join127(modernizeRoot(opts.repoDir, opts.mid), "wt", variant === 0 ? encodeUnitId(unit.id) : `${encodeUnitId(unit.id)}${VARIANT_SEP}${variant}`);
|
|
77865
77952
|
let outcome;
|
|
77866
77953
|
attempts++;
|
|
77867
77954
|
let resumeRunId;
|
|
@@ -77970,21 +78057,21 @@ var init_scheduler = __esm(() => {
|
|
|
77970
78057
|
});
|
|
77971
78058
|
|
|
77972
78059
|
// ../../loki-ts/src/engine10/modernize/resume.ts
|
|
77973
|
-
import { existsSync as existsSync87, readFileSync as
|
|
78060
|
+
import { existsSync as existsSync87, readFileSync as readFileSync109 } from "fs";
|
|
77974
78061
|
function loadResumeState(repoDir, mid) {
|
|
77975
78062
|
const path = modernizeEventsPath(repoDir, mid);
|
|
77976
78063
|
if (!existsSync87(path))
|
|
77977
78064
|
return { ok: false, reason: `no modernize log at ${path}` };
|
|
77978
78065
|
let text4;
|
|
77979
78066
|
try {
|
|
77980
|
-
text4 =
|
|
78067
|
+
text4 = readFileSync109(path, "utf8");
|
|
77981
78068
|
} catch (e10) {
|
|
77982
78069
|
return { ok: false, reason: `modernize log unreadable: ${e10 instanceof Error ? e10.message : String(e10)}` };
|
|
77983
78070
|
}
|
|
77984
78071
|
const pj2 = planPath(repoDir, mid);
|
|
77985
78072
|
if (existsSync87(pj2)) {
|
|
77986
78073
|
try {
|
|
77987
|
-
JSON.parse(
|
|
78074
|
+
JSON.parse(readFileSync109(pj2, "utf8"));
|
|
77988
78075
|
} catch {
|
|
77989
78076
|
return { ok: false, reason: `plan.json is corrupt or partial: ${pj2}` };
|
|
77990
78077
|
}
|
|
@@ -78097,8 +78184,8 @@ var init_resume = __esm(() => {
|
|
|
78097
78184
|
});
|
|
78098
78185
|
|
|
78099
78186
|
// ../../loki-ts/src/engine10/modernize/report.ts
|
|
78100
|
-
import { mkdirSync as mkdirSync69, readFileSync as
|
|
78101
|
-
import { dirname as
|
|
78187
|
+
import { mkdirSync as mkdirSync69, readFileSync as readFileSync110, writeFileSync as writeFileSync64 } from "fs";
|
|
78188
|
+
import { dirname as dirname49 } from "path";
|
|
78102
78189
|
function buildReport(o) {
|
|
78103
78190
|
const units = o.units.map((x3) => ({ unit: x3.unit, verdict: x3.verdict, not_proven: [...x3.not_proven], rate: x3.rate, branchPct: x3.branchPct, receiptPath: x3.receiptPath, receiptSha256: x3.receiptSha256 }));
|
|
78104
78191
|
const waves = o.waves.map((w) => ({
|
|
@@ -78141,7 +78228,7 @@ function renderReportMd(r) {
|
|
|
78141
78228
|
function writeReport(o) {
|
|
78142
78229
|
const sealed = sealReport(buildReport(o), o.sign);
|
|
78143
78230
|
const jp2 = reportJsonPath(o.repoDir, o.mid);
|
|
78144
|
-
mkdirSync69(
|
|
78231
|
+
mkdirSync69(dirname49(jp2), { recursive: true });
|
|
78145
78232
|
writeFileSync64(jp2, JSON.stringify(sealed, null, 2) + `
|
|
78146
78233
|
`, "utf8");
|
|
78147
78234
|
writeFileSync64(reportMdPath(o.repoDir, o.mid), renderReportMd(sealed), "utf8");
|
|
@@ -78158,7 +78245,7 @@ var init_report = __esm(() => {
|
|
|
78158
78245
|
|
|
78159
78246
|
// ../../loki-ts/src/engine10/modernize/ship.ts
|
|
78160
78247
|
import { mkdirSync as mkdirSync70, writeFileSync as writeFileSync65 } from "fs";
|
|
78161
|
-
import { join as
|
|
78248
|
+
import { join as join128 } from "path";
|
|
78162
78249
|
function waveIsDraft(verdict, units) {
|
|
78163
78250
|
return verdict === null || verdict.verified !== true || units.length === 0 || units.some((x3) => x3.verdict !== "PROVEN");
|
|
78164
78251
|
}
|
|
@@ -78179,9 +78266,9 @@ function shipWave(o) {
|
|
|
78179
78266
|
return fail2("no pinned origin: refusing to push (Rule of Two)");
|
|
78180
78267
|
if (draft)
|
|
78181
78268
|
return fail2("wave not verified: branch stays local, not pushed");
|
|
78182
|
-
const dir =
|
|
78269
|
+
const dir = join128(o.repoDir, ".loki", "modernize", o.mid);
|
|
78183
78270
|
mkdirSync70(dir, { recursive: true });
|
|
78184
|
-
const bodyFile =
|
|
78271
|
+
const bodyFile = join128(dir, `wave-${o.wave}-pr-body.md`);
|
|
78185
78272
|
writeFileSync65(bodyFile, renderWaveBody(o.wave, o.verdict, o.units), "utf8");
|
|
78186
78273
|
const r = (o.push ?? runPushPr)({ repoDir: o.repoDir, branch: o.branch, title: `Loki modernize: wave ${o.wave}`, bodyFile, draft, pinnedOrigin });
|
|
78187
78274
|
if (!r.ok)
|
|
@@ -78201,8 +78288,8 @@ var init_ship2 = __esm(() => {
|
|
|
78201
78288
|
});
|
|
78202
78289
|
|
|
78203
78290
|
// ../../loki-ts/src/engine10/modernize/presealed_wall.ts
|
|
78204
|
-
import { existsSync as existsSync88, mkdirSync as mkdirSync71, readFileSync as
|
|
78205
|
-
import { join as
|
|
78291
|
+
import { existsSync as existsSync88, mkdirSync as mkdirSync71, readFileSync as readFileSync111, writeFileSync as writeFileSync66 } from "fs";
|
|
78292
|
+
import { join as join129 } from "path";
|
|
78206
78293
|
function isRealFailCount(n11) {
|
|
78207
78294
|
return typeof n11 === "number" && Number.isInteger(n11) && n11 >= 1;
|
|
78208
78295
|
}
|
|
@@ -78225,7 +78312,7 @@ function classifyBaseRun(o, repoDir) {
|
|
|
78225
78312
|
return "not_run";
|
|
78226
78313
|
}
|
|
78227
78314
|
function preSealedPath(repoDir, mid, unit) {
|
|
78228
|
-
return
|
|
78315
|
+
return join129(oracleDir(repoDir, mid, unit), "presealed_wall.json");
|
|
78229
78316
|
}
|
|
78230
78317
|
function alreadySealed(repoDir, mid, unit) {
|
|
78231
78318
|
return readModernizeEvents(repoDir, mid).some((e10) => e10.type === SEALED_EVENT && e10.data.unit === unit);
|
|
@@ -78239,7 +78326,7 @@ function sealPreSealedWall(repoDir, mid, unit, target, runConformance, log, base
|
|
|
78239
78326
|
if (!oracleCheck.ok)
|
|
78240
78327
|
return refuse(`oracle seal invalid: ${oracleCheck.reason ?? "unknown"}; presealed wall refused`);
|
|
78241
78328
|
const dir = oracleDir(repoDir, mid, unit);
|
|
78242
|
-
const oracleSealed = JSON.parse(
|
|
78329
|
+
const oracleSealed = JSON.parse(readFileSync111(join129(dir, "sealed.json"), "utf8"));
|
|
78243
78330
|
if (oracleSealed.verdict !== "PROVEN_ORACLE") {
|
|
78244
78331
|
return refuse(`oracle seal invalid: oracle is ${oracleSealed.verdict} (${oracleSealed.not_proven ?? "no reason recorded"}); presealed wall refused`);
|
|
78245
78332
|
}
|
|
@@ -78308,7 +78395,7 @@ function verifyPreSealedWall(repoDir, mid, unit) {
|
|
|
78308
78395
|
const expectedSha = event.data.sealed_sha256;
|
|
78309
78396
|
if (typeof expectedSha !== "string")
|
|
78310
78397
|
return { ok: false, reason: "sealing event has no sealed_sha256" };
|
|
78311
|
-
const sealedRaw =
|
|
78398
|
+
const sealedRaw = readFileSync111(sealedPath, "utf8");
|
|
78312
78399
|
const actualSha = sha2564(sealedRaw);
|
|
78313
78400
|
if (actualSha !== expectedSha) {
|
|
78314
78401
|
return { ok: false, reason: "presealed_wall.json does not match the sealing event's hash (tampered or rewritten)" };
|
|
@@ -78317,7 +78404,7 @@ function verifyPreSealedWall(repoDir, mid, unit) {
|
|
|
78317
78404
|
if (!oracleCheck.ok) {
|
|
78318
78405
|
return { ok: false, reason: `bound oracle seal is no longer valid: ${oracleCheck.reason ?? "unknown"}` };
|
|
78319
78406
|
}
|
|
78320
|
-
const oracleSealed = JSON.parse(
|
|
78407
|
+
const oracleSealed = JSON.parse(readFileSync111(join129(oracleDir(repoDir, mid, unit), "sealed.json"), "utf8"));
|
|
78321
78408
|
const carried = JSON.parse(sealedRaw);
|
|
78322
78409
|
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) {
|
|
78323
78410
|
return { ok: false, reason: "carried oracle hashes do not match the current oracle seal" };
|
|
@@ -78343,9 +78430,9 @@ var init_presealed_wall = __esm(() => {
|
|
|
78343
78430
|
// ../../loki-ts/src/engine10/modernize/unit.ts
|
|
78344
78431
|
import { spawnSync as spawnSync19 } from "child_process";
|
|
78345
78432
|
import { createHash as createHash35 } from "crypto";
|
|
78346
|
-
import { lstatSync as lstatSync29, readFileSync as
|
|
78433
|
+
import { lstatSync as lstatSync29, readFileSync as readFileSync112, readdirSync as readdirSync37, readlinkSync as readlinkSync7, realpathSync as realpathSync33, rmSync as rmSync36 } from "fs";
|
|
78347
78434
|
import { tmpdir as tmpdir22 } from "os";
|
|
78348
|
-
import { join as
|
|
78435
|
+
import { join as join130, sep as sep20 } from "path";
|
|
78349
78436
|
function isSealedName(rel) {
|
|
78350
78437
|
return TEST_FILE2.test(rel) || PYTEST_CFG.test(rel);
|
|
78351
78438
|
}
|
|
@@ -78360,7 +78447,7 @@ function purgePycache(dir) {
|
|
|
78360
78447
|
for (const e10 of ents) {
|
|
78361
78448
|
if (!e10.isDirectory())
|
|
78362
78449
|
continue;
|
|
78363
|
-
const full =
|
|
78450
|
+
const full = join130(d, e10.name);
|
|
78364
78451
|
if (e10.name === "__pycache__")
|
|
78365
78452
|
rmSync36(full, { recursive: true, force: true });
|
|
78366
78453
|
else if (!skipName(e10.name))
|
|
@@ -78415,13 +78502,13 @@ function outsideTargetDigest(dir, full) {
|
|
|
78415
78502
|
}
|
|
78416
78503
|
for (const n11 of names) {
|
|
78417
78504
|
h10.update("D" + n11);
|
|
78418
|
-
walk(
|
|
78505
|
+
walk(join130(p, n11));
|
|
78419
78506
|
}
|
|
78420
78507
|
return;
|
|
78421
78508
|
}
|
|
78422
78509
|
if (st2.isFile()) {
|
|
78423
78510
|
try {
|
|
78424
|
-
h10.update(
|
|
78511
|
+
h10.update(readFileSync112(p));
|
|
78425
78512
|
} catch {
|
|
78426
78513
|
h10.update("unreadable");
|
|
78427
78514
|
}
|
|
@@ -78436,7 +78523,7 @@ function conformanceHashes(dir) {
|
|
|
78436
78523
|
const walk = (sub2, inSkip) => {
|
|
78437
78524
|
let ents;
|
|
78438
78525
|
try {
|
|
78439
|
-
ents = readdirSync37(
|
|
78526
|
+
ents = readdirSync37(join130(dir, sub2), { withFileTypes: true });
|
|
78440
78527
|
} catch {
|
|
78441
78528
|
return;
|
|
78442
78529
|
}
|
|
@@ -78467,14 +78554,14 @@ function conformanceHashes(dir) {
|
|
|
78467
78554
|
for (const rel of rels) {
|
|
78468
78555
|
let data;
|
|
78469
78556
|
try {
|
|
78470
|
-
const st2 = lstatSync29(
|
|
78557
|
+
const st2 = lstatSync29(join130(dir, rel));
|
|
78471
78558
|
if (st2.isSymbolicLink()) {
|
|
78472
|
-
out3[rel] = `${LINK}${readlinkSync7(
|
|
78559
|
+
out3[rel] = `${LINK}${readlinkSync7(join130(dir, rel))}|${outsideTargetDigest(dir, join130(dir, rel))}`;
|
|
78473
78560
|
continue;
|
|
78474
78561
|
}
|
|
78475
78562
|
if (!st2.isFile())
|
|
78476
78563
|
continue;
|
|
78477
|
-
data =
|
|
78564
|
+
data = readFileSync112(join130(dir, rel));
|
|
78478
78565
|
} catch {
|
|
78479
78566
|
continue;
|
|
78480
78567
|
}
|
|
@@ -78533,7 +78620,7 @@ function notProvenUnitResult(unit, reason, oracle, wall) {
|
|
|
78533
78620
|
return { unit, verdict: "NOT_PROVEN", oracle, wall, equiv: null, not_proven: [reason], conformance: null };
|
|
78534
78621
|
}
|
|
78535
78622
|
function readOracleSealed(repoDir, mid, unit) {
|
|
78536
|
-
return JSON.parse(
|
|
78623
|
+
return JSON.parse(readFileSync112(join130(oracleDir(repoDir, mid, unit), "sealed.json"), "utf8"));
|
|
78537
78624
|
}
|
|
78538
78625
|
function runUnit(card, log, runConformance, implement, runNew, runStub, collect) {
|
|
78539
78626
|
const { repoDir, mid, unit } = card;
|
|
@@ -78644,8 +78731,8 @@ var init_unit = __esm(() => {
|
|
|
78644
78731
|
|
|
78645
78732
|
// ../../loki-ts/src/engine10/modernize/wave.ts
|
|
78646
78733
|
import { spawnSync as spawnSync20 } from "child_process";
|
|
78647
|
-
import { readFileSync as
|
|
78648
|
-
import { join as
|
|
78734
|
+
import { readFileSync as readFileSync113, statSync as statSync33 } from "fs";
|
|
78735
|
+
import { join as join131 } from "path";
|
|
78649
78736
|
function clampTimeout(ms) {
|
|
78650
78737
|
if (ms === undefined || !Number.isFinite(ms) || ms <= 0)
|
|
78651
78738
|
return DEFAULT_STEP_TIMEOUT_MS;
|
|
@@ -78714,7 +78801,7 @@ function detectWaveCommands(inv, target) {
|
|
|
78714
78801
|
const none = { build: null, integration: null, original_suite: null };
|
|
78715
78802
|
const text4 = () => {
|
|
78716
78803
|
try {
|
|
78717
|
-
return
|
|
78804
|
+
return readFileSync113(join131(target, marker ?? ""), "utf8");
|
|
78718
78805
|
} catch {
|
|
78719
78806
|
return "";
|
|
78720
78807
|
}
|
|
@@ -78726,7 +78813,7 @@ function detectWaveCommands(inv, target) {
|
|
|
78726
78813
|
if (system === "gradle") {
|
|
78727
78814
|
let gw2 = "gradle";
|
|
78728
78815
|
try {
|
|
78729
|
-
if (inv.files.includes("gradlew") && (statSync33(
|
|
78816
|
+
if (inv.files.includes("gradlew") && (statSync33(join131(target, "gradlew")).mode & 73) !== 0)
|
|
78730
78817
|
gw2 = "./gradlew";
|
|
78731
78818
|
} catch {}
|
|
78732
78819
|
return { build: { argv: [gw2, "assemble"] }, integration: text4().includes("integrationTest") ? { argv: [gw2, "integrationTest"] } : null, original_suite: { argv: [gw2, "test"] } };
|
|
@@ -78738,7 +78825,7 @@ function detectWaveCommands(inv, target) {
|
|
|
78738
78825
|
let toxIni = "";
|
|
78739
78826
|
if (inv.files.includes("tox.ini")) {
|
|
78740
78827
|
try {
|
|
78741
|
-
toxIni =
|
|
78828
|
+
toxIni = readFileSync113(join131(target, "tox.ini"), "utf8");
|
|
78742
78829
|
} catch {}
|
|
78743
78830
|
}
|
|
78744
78831
|
const integration = toxIni.includes("[testenv:integration") ? { argv: ["tox", "-e", "integration"] } : itDir && pytest ? { argv: ["python3", "-m", "pytest", "-q", itDir] } : null;
|
|
@@ -78770,9 +78857,9 @@ var init_wave = __esm(() => {
|
|
|
78770
78857
|
|
|
78771
78858
|
// ../../loki-ts/src/util/modernize_unit.ts
|
|
78772
78859
|
import { spawnSync as spawnSync21 } from "child_process";
|
|
78773
|
-
import { existsSync as existsSync89, lstatSync as lstatSync30, mkdtempSync as mkdtempSync18, readFileSync as
|
|
78860
|
+
import { existsSync as existsSync89, lstatSync as lstatSync30, mkdtempSync as mkdtempSync18, readFileSync as readFileSync114, realpathSync as realpathSync34, rmSync as rmSync37, statSync as statSync34, writeFileSync as writeFileSync67 } from "fs";
|
|
78774
78861
|
import { tmpdir as tmpdir23 } from "os";
|
|
78775
|
-
import { join as
|
|
78862
|
+
import { join as join132, sep as sep21 } from "path";
|
|
78776
78863
|
function parseUnitArgs(args) {
|
|
78777
78864
|
const f = {};
|
|
78778
78865
|
for (let i = 0;i < args.length; i++) {
|
|
@@ -78844,7 +78931,7 @@ function makeUnitRunners(o) {
|
|
|
78844
78931
|
}
|
|
78845
78932
|
function makeSessionRunner(o) {
|
|
78846
78933
|
const limitS = o.sessionLimitS ?? SESSION_LIMIT_S2;
|
|
78847
|
-
const cli = import.meta.path.endsWith("modernize_unit.ts") ?
|
|
78934
|
+
const cli = import.meta.path.endsWith("modernize_unit.ts") ? join132(import.meta.dir, "..", "cli.ts") : import.meta.path;
|
|
78848
78935
|
return o.session ?? ((_brief, cwd, env) => spawnSync21(process.execPath, [...SAFE_BUN_FLAGS, cli, "engine10", "session"], { cwd, env, stdio: ["ignore", "ignore", "pipe"], timeout: limitS * 1000 }));
|
|
78849
78936
|
}
|
|
78850
78937
|
function defaultUnitFile(unitId, newTreeDir) {
|
|
@@ -78852,7 +78939,7 @@ function defaultUnitFile(unitId, newTreeDir) {
|
|
|
78852
78939
|
return null;
|
|
78853
78940
|
try {
|
|
78854
78941
|
const root = realpathSync34(newTreeDir);
|
|
78855
|
-
const real3 = realpathSync34(
|
|
78942
|
+
const real3 = realpathSync34(join132(root, unitId));
|
|
78856
78943
|
return real3.startsWith(root + sep21) ? real3 : null;
|
|
78857
78944
|
} catch {
|
|
78858
78945
|
return null;
|
|
@@ -78889,16 +78976,16 @@ function runPythonCase(o, unitId, newTreeDir, rec2, stub) {
|
|
|
78889
78976
|
const src = o.unitFile ? o.unitFile(unitId, newTreeDir) : defaultUnitFile(unitId, newTreeDir);
|
|
78890
78977
|
if (!src || !src.endsWith(".py") || !existsSync89(src))
|
|
78891
78978
|
throw new Error(`cannot locate the source of unit ${unitId} in the new tree`);
|
|
78892
|
-
const dir = mkdtempSync18(
|
|
78979
|
+
const dir = mkdtempSync18(join132(tmpdir23(), "loki-newcase-"));
|
|
78893
78980
|
try {
|
|
78894
|
-
const cases =
|
|
78981
|
+
const cases = join132(dir, "in.jsonl"), out3 = join132(dir, "out.jsonl");
|
|
78895
78982
|
writeFileSync67(cases, JSON.stringify({ entry: rec2.entry, args: rec2.args, kwargs: rec2.kwargs, boundaries: boundariesFromCase(rec2) }) + `
|
|
78896
78983
|
`, "utf8");
|
|
78897
|
-
const r = spawnSync21(o.pythonBin ?? "python3", [
|
|
78984
|
+
const r = spawnSync21(o.pythonBin ?? "python3", [join132(REPO_ROOT, "autonomy", "lib", "modernize", "py_capture.py"), "--unit", src, "--cases", cases, "--out", out3, ...stub ? ["--stub"] : []], { cwd: newTreeDir, encoding: "utf8", timeout: CASE_TIMEOUT_MS, env: { ...tokenFreeEnv(), PYTHONDONTWRITEBYTECODE: "1" } });
|
|
78898
78985
|
if (r.status !== 0 || !existsSync89(out3))
|
|
78899
78986
|
throw new Error(`new-tree case runner failed (${r.status ?? r.signal ?? "no status"}): ${String(r.stderr ?? "").trim().split(`
|
|
78900
78987
|
`).pop() ?? ""}`);
|
|
78901
|
-
const line2 =
|
|
78988
|
+
const line2 = readFileSync114(out3, "utf8").split(`
|
|
78902
78989
|
`).find((l) => l.trim() !== "");
|
|
78903
78990
|
if (!line2)
|
|
78904
78991
|
throw new Error("new-tree case runner produced no record");
|
|
@@ -78924,7 +79011,7 @@ Usage: ${UNIT_USAGE}
|
|
|
78924
79011
|
const root = u10.tmpRoot ?? (runTmp !== "" && isRealDir(runTmp) ? runTmp : tmpdir23());
|
|
78925
79012
|
let repoDir;
|
|
78926
79013
|
try {
|
|
78927
|
-
repoDir = mkdtempSync18(
|
|
79014
|
+
repoDir = mkdtempSync18(join132(root, "loki-unit-"));
|
|
78928
79015
|
} catch (e10) {
|
|
78929
79016
|
process.stderr.write(`modernize unit: cannot create a temp checkout directory: ${e10.message}
|
|
78930
79017
|
`);
|
|
@@ -79020,11 +79107,11 @@ var init_modernize_unit = __esm(() => {
|
|
|
79020
79107
|
|
|
79021
79108
|
// ../../loki-ts/src/util/modernize_coordinator.ts
|
|
79022
79109
|
import { createHash as createHash36 } from "crypto";
|
|
79023
|
-
import { existsSync as existsSync90, mkdtempSync as mkdtempSync19, readFileSync as
|
|
79110
|
+
import { existsSync as existsSync90, mkdtempSync as mkdtempSync19, readFileSync as readFileSync115, rmSync as rmSync38 } from "fs";
|
|
79024
79111
|
import { tmpdir as tmpdir24 } from "os";
|
|
79025
|
-
import { join as
|
|
79112
|
+
import { join as join133 } from "path";
|
|
79026
79113
|
function shipUnitOf(d, unit, o) {
|
|
79027
|
-
const sealed =
|
|
79114
|
+
const sealed = join133(oracleDir(d.repoDir, d.mid, unit), "sealed.json");
|
|
79028
79115
|
const eq3 = o?.result?.equiv;
|
|
79029
79116
|
return {
|
|
79030
79117
|
unit,
|
|
@@ -79041,7 +79128,7 @@ function scopeBuildToWave(cmd2, repoDir, units) {
|
|
|
79041
79128
|
const x3 = cmd2?.argv.indexOf("-x") ?? -1;
|
|
79042
79129
|
if (!cmd2 || !cmd2.argv.includes("compileall") || x3 < 0)
|
|
79043
79130
|
return cmd2;
|
|
79044
|
-
const files = [...new Set(units.flatMap((u10) => u10.nodes))].filter((n11) => n11.endsWith(".py") && isSafeUnitId(n11) && existsSync90(
|
|
79131
|
+
const files = [...new Set(units.flatMap((u10) => u10.nodes))].filter((n11) => n11.endsWith(".py") && isSafeUnitId(n11) && existsSync90(join133(repoDir, n11)));
|
|
79045
79132
|
return files.length ? { ...cmd2, argv: [...cmd2.argv.slice(0, x3 + 2), ...files] } : cmd2;
|
|
79046
79133
|
}
|
|
79047
79134
|
async function runWaves(plan, d) {
|
|
@@ -79200,16 +79287,16 @@ function makeAttemptRunner(o) {
|
|
|
79200
79287
|
}
|
|
79201
79288
|
function makeUnitPrep(o) {
|
|
79202
79289
|
const runtimeOk = o.runtimeOk ?? (() => {
|
|
79203
|
-
const dir = mkdtempSync19(
|
|
79290
|
+
const dir = mkdtempSync19(join133(tmpdir24(), "loki-probe-"));
|
|
79204
79291
|
try {
|
|
79205
|
-
return realCaptureRunner(
|
|
79292
|
+
return realCaptureRunner(join133(dir, "probe.py"), []).error !== "old runtime unavailable";
|
|
79206
79293
|
} finally {
|
|
79207
79294
|
rmSync38(dir, { recursive: true, force: true });
|
|
79208
79295
|
}
|
|
79209
79296
|
});
|
|
79210
79297
|
let runtime = null;
|
|
79211
79298
|
return (unit) => {
|
|
79212
|
-
if (existsSync90(
|
|
79299
|
+
if (existsSync90(join133(oracleDir(o.repoDir, o.mid, unit.id), "cases.jsonl")) || alreadySealedInLog(o.repoDir, o.mid, unit.id))
|
|
79213
79300
|
return null;
|
|
79214
79301
|
runtime ??= runtimeOk();
|
|
79215
79302
|
if (!runtime)
|
|
@@ -79217,7 +79304,7 @@ function makeUnitPrep(o) {
|
|
|
79217
79304
|
const node = unit.nodes.length === 1 ? unit.nodes[0] : "";
|
|
79218
79305
|
if (!node.endsWith(".py") || !isSafeUnitId(node))
|
|
79219
79306
|
return MULTI_FILE_REASON;
|
|
79220
|
-
const r = (o.capture ?? captureUnitOracle)({ repoDir: o.repoDir, mid: o.mid, unit: unit.id, unitPath:
|
|
79307
|
+
const r = (o.capture ?? captureUnitOracle)({ repoDir: o.repoDir, mid: o.mid, unit: unit.id, unitPath: join133(o.repoDir, node), propose: o.propose });
|
|
79221
79308
|
return r.ok ? null : r.reason;
|
|
79222
79309
|
};
|
|
79223
79310
|
}
|
|
@@ -79276,7 +79363,7 @@ function productionWaveDeps(o) {
|
|
|
79276
79363
|
}
|
|
79277
79364
|
};
|
|
79278
79365
|
}
|
|
79279
|
-
var productionReslice, sha2565 = (p) => existsSync90(p) ? createHash36("sha256").update(
|
|
79366
|
+
var productionReslice, sha2565 = (p) => existsSync90(p) ? createHash36("sha256").update(readFileSync115(p)).digest("hex") : "n/a", MULTI_FILE_REASON = "multi-file unit: capture not supported (founder default)";
|
|
79280
79367
|
var init_modernize_coordinator = __esm(() => {
|
|
79281
79368
|
init_codemod();
|
|
79282
79369
|
init_search();
|
|
@@ -79609,8 +79696,8 @@ __export(exports_export_sarif, {
|
|
|
79609
79696
|
preRedFromEvents: () => preRedFromEvents,
|
|
79610
79697
|
main: () => main8
|
|
79611
79698
|
});
|
|
79612
|
-
import { existsSync as existsSync92, readFileSync as
|
|
79613
|
-
import { join as
|
|
79699
|
+
import { existsSync as existsSync92, readFileSync as readFileSync116, writeFileSync as writeFileSync68 } from "fs";
|
|
79700
|
+
import { join as join134 } from "path";
|
|
79614
79701
|
function scanDiff(diff) {
|
|
79615
79702
|
const out3 = [];
|
|
79616
79703
|
let file = "";
|
|
@@ -79641,7 +79728,7 @@ function scanDiff(diff) {
|
|
|
79641
79728
|
function preRedFromEvents(runDir) {
|
|
79642
79729
|
try {
|
|
79643
79730
|
let pre2 = [];
|
|
79644
|
-
for (const l of
|
|
79731
|
+
for (const l of readFileSync116(join134(runDir, "events.jsonl"), "utf8").split(`
|
|
79645
79732
|
`)) {
|
|
79646
79733
|
if (!l.includes('"stage.completed"'))
|
|
79647
79734
|
continue;
|
|
@@ -79670,19 +79757,19 @@ async function main8(args, deps = {}) {
|
|
|
79670
79757
|
if (bad || rest.length > 1)
|
|
79671
79758
|
return process.stderr.write(`loki export --sarif: ${bad ? `unknown flag ${bad}` : "more than one run-id"}
|
|
79672
79759
|
`), 2;
|
|
79673
|
-
const runsRoot2 = deps.runsRoot ??
|
|
79760
|
+
const runsRoot2 = deps.runsRoot ?? join134(lokiDir(), "runs");
|
|
79674
79761
|
const runId2 = rest[0] ?? latestRunId(runsRoot2);
|
|
79675
79762
|
if (!runId2)
|
|
79676
79763
|
return process.stderr.write(`loki export --sarif: no runs found
|
|
79677
79764
|
`), 66;
|
|
79678
|
-
const runDir =
|
|
79679
|
-
const receiptPath =
|
|
79765
|
+
const runDir = join134(runsRoot2, runId2);
|
|
79766
|
+
const receiptPath = join134(runDir, "receipt.json");
|
|
79680
79767
|
if (runId2.includes("/") || runId2.includes("..") || !existsSync92(receiptPath))
|
|
79681
79768
|
return process.stderr.write(`loki export --sarif: unknown run ${runId2}
|
|
79682
79769
|
`), 66;
|
|
79683
79770
|
let receipt;
|
|
79684
79771
|
try {
|
|
79685
|
-
receipt = JSON.parse(
|
|
79772
|
+
receipt = JSON.parse(readFileSync116(receiptPath, "utf8"));
|
|
79686
79773
|
} catch {
|
|
79687
79774
|
return process.stderr.write(`loki export --sarif: unreadable receipt for ${runId2}
|
|
79688
79775
|
`), 66;
|
|
@@ -79699,9 +79786,9 @@ async function main8(args, deps = {}) {
|
|
|
79699
79786
|
findings.push(...receiptFindings(receipt, preRedFromEvents(runDir)));
|
|
79700
79787
|
let version2 = "0.0.0";
|
|
79701
79788
|
try {
|
|
79702
|
-
version2 =
|
|
79789
|
+
version2 = readFileSync116(join134(REPO_ROOT, "VERSION"), "utf8").trim() || version2;
|
|
79703
79790
|
} catch {}
|
|
79704
|
-
const out3 =
|
|
79791
|
+
const out3 = join134(runDir, "findings.sarif");
|
|
79705
79792
|
writeFileSync68(out3, JSON.stringify(toSarif(findings, version2, deps.repoDir ?? process.cwd()), null, 2) + `
|
|
79706
79793
|
`);
|
|
79707
79794
|
process.stdout.write(`run: ${runId2}
|
|
@@ -79920,7 +80007,7 @@ var init_output = __esm(() => {
|
|
|
79920
80007
|
|
|
79921
80008
|
// ../../loki-ts/src/features/receipt_dsse.ts
|
|
79922
80009
|
import { createPublicKey as createPublicKey5, sign as sign3, verify as verify3 } from "crypto";
|
|
79923
|
-
import { readFileSync as
|
|
80010
|
+
import { readFileSync as readFileSync117 } from "fs";
|
|
79924
80011
|
function pae2(payloadType, body) {
|
|
79925
80012
|
const t = Buffer.from(payloadType, "utf8");
|
|
79926
80013
|
return Buffer.concat([Buffer.from(`DSSEv1 ${t.length} `), t, Buffer.from(` ${body.length} `), body]);
|
|
@@ -80016,7 +80103,7 @@ function verifyDsseReceipt(env, d) {
|
|
|
80016
80103
|
}
|
|
80017
80104
|
function runIdGuard(receiptPath, runId2) {
|
|
80018
80105
|
try {
|
|
80019
|
-
return envelopeRunIdProblem(JSON.parse(
|
|
80106
|
+
return envelopeRunIdProblem(JSON.parse(readFileSync117(receiptPath, "utf8")), runId2);
|
|
80020
80107
|
} catch {
|
|
80021
80108
|
return null;
|
|
80022
80109
|
}
|
|
@@ -80024,7 +80111,7 @@ function runIdGuard(receiptPath, runId2) {
|
|
|
80024
80111
|
async function exportDsseReceipt(a) {
|
|
80025
80112
|
const fail2 = (rc2, m) => (process.stderr.write(`loki verify --export-dsse: ${m}
|
|
80026
80113
|
`), rc2);
|
|
80027
|
-
const rd2 = a.deps.read ?? ((p) =>
|
|
80114
|
+
const rd2 = a.deps.read ?? ((p) => readFileSync117(p, "utf8"));
|
|
80028
80115
|
let text4;
|
|
80029
80116
|
try {
|
|
80030
80117
|
text4 = rd2(a.receiptPath);
|
|
@@ -80081,10 +80168,10 @@ var init_undo = __esm(() => {
|
|
|
80081
80168
|
});
|
|
80082
80169
|
|
|
80083
80170
|
// ../../loki-ts/src/commands/run_status.ts
|
|
80084
|
-
import { existsSync as existsSync93, readdirSync as readdirSync38, readFileSync as
|
|
80085
|
-
import { basename as basename32, dirname as
|
|
80171
|
+
import { existsSync as existsSync93, readdirSync as readdirSync38, readFileSync as readFileSync118, statSync as statSync36 } from "fs";
|
|
80172
|
+
import { basename as basename32, dirname as dirname50, join as join135, resolve as resolve39 } from "path";
|
|
80086
80173
|
function runsRoot(env, repoDir) {
|
|
80087
|
-
return env.LOKI_DIR ?
|
|
80174
|
+
return env.LOKI_DIR ? join135(resolve39(repoDir, env.LOKI_DIR), "runs") : join135(repoDir, ".loki", "runs");
|
|
80088
80175
|
}
|
|
80089
80176
|
function listRunIds(root) {
|
|
80090
80177
|
if (!existsSync93(root))
|
|
@@ -80096,7 +80183,7 @@ function latestRunId(root) {
|
|
|
80096
80183
|
return ids.length ? ids[ids.length - 1] : null;
|
|
80097
80184
|
}
|
|
80098
80185
|
function eventsPath(root, runId2) {
|
|
80099
|
-
return
|
|
80186
|
+
return join135(root, runId2, "events.jsonl");
|
|
80100
80187
|
}
|
|
80101
80188
|
var TERMINAL2;
|
|
80102
80189
|
var init_run_status = __esm(() => {
|
|
@@ -80113,8 +80200,8 @@ var init_run_status = __esm(() => {
|
|
|
80113
80200
|
|
|
80114
80201
|
// ../../loki-ts/src/util/seal_drift.ts
|
|
80115
80202
|
import { createHash as createHash38 } from "crypto";
|
|
80116
|
-
import { existsSync as existsSync94, readFileSync as
|
|
80117
|
-
import { basename as basename33, dirname as
|
|
80203
|
+
import { existsSync as existsSync94, readFileSync as readFileSync119, realpathSync as realpathSync35 } from "fs";
|
|
80204
|
+
import { basename as basename33, dirname as dirname51, join as join136, relative as relative27 } from "path";
|
|
80118
80205
|
function tornTail(raw2) {
|
|
80119
80206
|
if (raw2 === "" || raw2.endsWith(`
|
|
80120
80207
|
`))
|
|
@@ -80133,7 +80220,7 @@ function tornTail(raw2) {
|
|
|
80133
80220
|
function boundEvents(log, bound) {
|
|
80134
80221
|
if (!existsSync94(log))
|
|
80135
80222
|
return null;
|
|
80136
|
-
const lines2 =
|
|
80223
|
+
const lines2 = readFileSync119(log, "utf8").split(`
|
|
80137
80224
|
`).filter((l) => l.trim() !== ""), h10 = createHash38("sha256");
|
|
80138
80225
|
let n11 = -1;
|
|
80139
80226
|
for (let i = 0;i <= lines2.length; i++) {
|
|
@@ -80161,7 +80248,7 @@ function fabricatedPass(receiptPath, r) {
|
|
|
80161
80248
|
const bound = r["events_sha256"];
|
|
80162
80249
|
if (typeof bound !== "string" || bound === EMPTY_SHA || !Array.isArray(r["checks"]))
|
|
80163
80250
|
return null;
|
|
80164
|
-
const events2 = boundEvents(
|
|
80251
|
+
const events2 = boundEvents(join136(dirname51(receiptPath), "events.jsonl"), bound);
|
|
80165
80252
|
if (!events2 || !events2.some((e10) => e10.stage === "verify"))
|
|
80166
80253
|
return null;
|
|
80167
80254
|
const passed = new Set(events2.filter((e10) => e10.type === "test.result" && e10.stage === "verify" && e10.data["result"] === "pass").map((e10) => String(e10.data["name"])));
|
|
@@ -80169,12 +80256,12 @@ function fabricatedPass(receiptPath, r) {
|
|
|
80169
80256
|
return missing.length ? `receipt claims pass with no test.result pass in events.jsonl: ${missing.join(", ")}` : null;
|
|
80170
80257
|
}
|
|
80171
80258
|
function currentTaskSha(runDir, source, env) {
|
|
80172
|
-
const f = source === "issue" ?
|
|
80173
|
-
return f && existsSync94(f) ? sha6(
|
|
80259
|
+
const f = source === "issue" ? join136(runDir, "issue.json") : env["LOKI_VERIFY_TASK_FILE"];
|
|
80260
|
+
return f && existsSync94(f) ? sha6(readFileSync119(f)) : null;
|
|
80174
80261
|
}
|
|
80175
80262
|
function repoOf(receiptPath) {
|
|
80176
|
-
const runs2 =
|
|
80177
|
-
return basename33(runs2) === "runs" && basename33(
|
|
80263
|
+
const runs2 = dirname51(dirname51(receiptPath));
|
|
80264
|
+
return basename33(runs2) === "runs" && basename33(dirname51(runs2)) === ".loki" ? dirname51(dirname51(runs2)) : null;
|
|
80178
80265
|
}
|
|
80179
80266
|
function overlap(repo, base, sealedHead, head) {
|
|
80180
80267
|
if (typeof base !== "string" || !/^[0-9a-f]{40,64}$/.test(base) || !/^[0-9a-f]{40,64}$/.test(sealedHead))
|
|
@@ -80200,7 +80287,7 @@ function onlyWallPublish(repo, r, sealedHead, head) {
|
|
|
80200
80287
|
} catch {
|
|
80201
80288
|
return x3;
|
|
80202
80289
|
}
|
|
80203
|
-
}, rr2 = real3(repo), want = new Map(wall.map((w) => [relative27(rr2,
|
|
80290
|
+
}, rr2 = real3(repo), want = new Map(wall.map((w) => [relative27(rr2, join136(real3(dirname51(String(w.path))), basename33(String(w.path)))), String(w.sha256)]));
|
|
80204
80291
|
const commits = safeGit(repo, ["rev-list", "--reverse", "--topo-order", `${sealedHead}..${head}`]).split(`
|
|
80205
80292
|
`).filter(Boolean);
|
|
80206
80293
|
if (commits.length === 0 || safeGit(repo, ["rev-list", "--merges", "--count", `${sealedHead}..${head}`]).trim() !== "0")
|
|
@@ -80238,18 +80325,18 @@ function claimsWallPublish(repo, r, sealedHead, head) {
|
|
|
80238
80325
|
function sealDrift(given, r, env = process.env) {
|
|
80239
80326
|
let receiptPath = given;
|
|
80240
80327
|
try {
|
|
80241
|
-
receiptPath =
|
|
80328
|
+
receiptPath = join136(realpathSync35(dirname51(given)), basename33(given));
|
|
80242
80329
|
} catch {}
|
|
80243
80330
|
const fab = fabricatedPass(receiptPath, r);
|
|
80244
80331
|
if (fab)
|
|
80245
80332
|
return { verdict: "TAMPERED", reason: fab };
|
|
80246
80333
|
try {
|
|
80247
|
-
const log =
|
|
80248
|
-
if (existsSync94(log) && tornTail(
|
|
80334
|
+
const log = join136(dirname51(receiptPath), "events.jsonl");
|
|
80335
|
+
if (existsSync94(log) && tornTail(readFileSync119(log, "utf8")))
|
|
80249
80336
|
return { verdict: "UNCHECKED", reason: "events.jsonl ends in a torn, unterminated line (an append cut mid-write); every complete line is intact but the log is not whole" };
|
|
80250
80337
|
} catch {}
|
|
80251
80338
|
const task = r["task"] ?? {};
|
|
80252
|
-
const cur = currentTaskSha(
|
|
80339
|
+
const cur = currentTaskSha(dirname51(receiptPath), task.source, env);
|
|
80253
80340
|
if (cur !== null && typeof task.sha256 === "string" && task.sha256 !== "" && cur !== task.sha256)
|
|
80254
80341
|
return { verdict: "UNCHECKED", reason: `intent drift: sealed task sha256 ${task.sha256} differs from the current spec ${cur}` };
|
|
80255
80342
|
const repo = repoOf(receiptPath);
|
|
@@ -80279,14 +80366,14 @@ var init_seal_drift = __esm(() => {
|
|
|
80279
80366
|
});
|
|
80280
80367
|
|
|
80281
80368
|
// ../../loki-ts/src/util/composite_seal.ts
|
|
80282
|
-
import { existsSync as existsSync95, readFileSync as
|
|
80283
|
-
import { basename as basename34, dirname as
|
|
80369
|
+
import { existsSync as existsSync95, readFileSync as readFileSync120 } from "fs";
|
|
80370
|
+
import { basename as basename34, dirname as dirname52, join as join137 } from "path";
|
|
80284
80371
|
function logProblem(runDir, integ) {
|
|
80285
80372
|
if (typeof integ["log_sha256"] !== "string")
|
|
80286
80373
|
return null;
|
|
80287
80374
|
let b;
|
|
80288
80375
|
try {
|
|
80289
|
-
b =
|
|
80376
|
+
b = readFileSync120(join137(runDir, "integration.log"));
|
|
80290
80377
|
} catch {
|
|
80291
80378
|
return "integration.log is missing but integration.json records its hash";
|
|
80292
80379
|
}
|
|
@@ -80301,10 +80388,10 @@ function integrationProblem(integ) {
|
|
|
80301
80388
|
return null;
|
|
80302
80389
|
}
|
|
80303
80390
|
function composeComposite(runDir, rh, toolchain = collectToolchain()) {
|
|
80304
|
-
const ip =
|
|
80391
|
+
const ip = join137(runDir, "integration.json");
|
|
80305
80392
|
let ibytes;
|
|
80306
80393
|
try {
|
|
80307
|
-
ibytes =
|
|
80394
|
+
ibytes = readFileSync120(ip);
|
|
80308
80395
|
} catch {
|
|
80309
80396
|
throw new Error("integration.json missing; the workspace run did not finish");
|
|
80310
80397
|
}
|
|
@@ -80328,12 +80415,12 @@ function composeComposite(runDir, rh, toolchain = collectToolchain()) {
|
|
|
80328
80415
|
const outcome = String(integ["outcomes"][repo] ?? "");
|
|
80329
80416
|
if (outcome !== "ok")
|
|
80330
80417
|
throw new Error(`repo ${text3(repo, 80)} did not finish (${text3(outcome, 80) || "no outcome"}); no composite`);
|
|
80331
|
-
const runsDir =
|
|
80332
|
-
const ids = (dirNames(runsDir) ?? []).filter((n11) => existsSync95(
|
|
80418
|
+
const runsDir = join137(runDir, "worktrees", slugOf(repo), ".loki", "runs");
|
|
80419
|
+
const ids = (dirNames(runsDir) ?? []).filter((n11) => existsSync95(join137(runsDir, n11, "receipt.json")));
|
|
80333
80420
|
const id2 = ids[ids.length - 1];
|
|
80334
80421
|
if (!id2)
|
|
80335
80422
|
throw new Error(`repo ${text3(repo, 80)} has no receipt.json under worktrees/${slugOf(repo)}/.loki/runs`);
|
|
80336
|
-
const rp =
|
|
80423
|
+
const rp = join137(runsDir, id2, "receipt.json"), bytes = readFileSync120(rp), r = readJson7(rp);
|
|
80337
80424
|
if (jsonTooDeep(r))
|
|
80338
80425
|
throw new Error(`repo ${text3(repo, 80)} receipt cannot be hashed (nested too deeply); no composite`);
|
|
80339
80426
|
if (!isObj10(r) || typeof r["receipt_sha256"] !== "string" || rh(r) !== r["receipt_sha256"])
|
|
@@ -80351,7 +80438,7 @@ function composeComposite(runDir, rh, toolchain = collectToolchain()) {
|
|
|
80351
80438
|
throw new Error("workspace has no repos");
|
|
80352
80439
|
return {
|
|
80353
80440
|
schema: COMPOSITE_SCHEMA,
|
|
80354
|
-
workspace: basename34(
|
|
80441
|
+
workspace: basename34(dirname52(runDir)),
|
|
80355
80442
|
run_id: basename34(runDir),
|
|
80356
80443
|
integration_sha256: sha4(ibytes),
|
|
80357
80444
|
integration: { status: String(integ["status"]), exit_code: typeof integ["exit_code"] === "number" ? integ["exit_code"] : null, log_sha256: typeof integ["log_sha256"] === "string" ? integ["log_sha256"] : null, heads },
|
|
@@ -80361,7 +80448,7 @@ function composeComposite(runDir, rh, toolchain = collectToolchain()) {
|
|
|
80361
80448
|
};
|
|
80362
80449
|
}
|
|
80363
80450
|
async function verifyComposite(receiptPath, receipt, rh, verifyOne, deps = {}) {
|
|
80364
|
-
const runDir =
|
|
80451
|
+
const runDir = dirname52(receiptPath);
|
|
80365
80452
|
const signed = isObj10(receipt["verification"]) && typeof receipt["verification"]["jwt"] === "string";
|
|
80366
80453
|
const bad = (reason) => ({ problem: { verdict: "TAMPERED", reason: `composite: ${reason}` }, verdict: "FAILED" });
|
|
80367
80454
|
const deep = (what) => ({ problem: { verdict: "UNCHECKED", reason: `composite: ${what} cannot be hashed (nested too deeply)` }, verdict: "FAILED" });
|
|
@@ -80370,13 +80457,13 @@ async function verifyComposite(receiptPath, receipt, rh, verifyOne, deps = {}) {
|
|
|
80370
80457
|
return bad("body malformed");
|
|
80371
80458
|
let ibytes;
|
|
80372
80459
|
try {
|
|
80373
|
-
ibytes =
|
|
80460
|
+
ibytes = readFileSync120(join137(runDir, "integration.json"));
|
|
80374
80461
|
} catch {
|
|
80375
80462
|
return bad("integration.json missing");
|
|
80376
80463
|
}
|
|
80377
80464
|
if (sha4(ibytes) !== receipt["integration_sha256"])
|
|
80378
80465
|
return bad("integration.json does not match its recorded hash");
|
|
80379
|
-
const integ = readJson7(
|
|
80466
|
+
const integ = readJson7(join137(runDir, "integration.json"));
|
|
80380
80467
|
if (jsonTooDeep(integ))
|
|
80381
80468
|
return deep("integration.json");
|
|
80382
80469
|
if (!isObj10(integ) || !isObj10(integ["outcomes"]))
|
|
@@ -80413,10 +80500,10 @@ async function verifyComposite(receiptPath, receipt, rh, verifyOne, deps = {}) {
|
|
|
80413
80500
|
return bad(`child ${text3(repo, 80) || "?"} has an invalid receipt path`);
|
|
80414
80501
|
if (outcomes[repo] !== "ok")
|
|
80415
80502
|
return bad(`child ${text3(repo, 80)} did not finish ok in integration.json`);
|
|
80416
|
-
const rp =
|
|
80503
|
+
const rp = join137(runDir, rel);
|
|
80417
80504
|
let bytes;
|
|
80418
80505
|
try {
|
|
80419
|
-
bytes =
|
|
80506
|
+
bytes = readFileSync120(rp);
|
|
80420
80507
|
} catch {
|
|
80421
80508
|
return bad(`child ${repo} receipt missing`);
|
|
80422
80509
|
}
|
|
@@ -80476,8 +80563,8 @@ __export(exports_verify_cmd, {
|
|
|
80476
80563
|
main: () => main9,
|
|
80477
80564
|
computeReceiptHash: () => computeReceiptHash
|
|
80478
80565
|
});
|
|
80479
|
-
import { existsSync as existsSync96, readFileSync as
|
|
80480
|
-
import { basename as basename35, dirname as
|
|
80566
|
+
import { existsSync as existsSync96, readFileSync as readFileSync121, renameSync as renameSync23, statSync as statSync37, writeFileSync as writeFileSync69 } from "fs";
|
|
80567
|
+
import { basename as basename35, dirname as dirname53, join as join138 } from "path";
|
|
80481
80568
|
import { createHash as createHash39, createPublicKey as createPublicKey6, verify as verify4 } from "crypto";
|
|
80482
80569
|
function pubFor(kid, given) {
|
|
80483
80570
|
if (given)
|
|
@@ -80485,7 +80572,7 @@ function pubFor(kid, given) {
|
|
|
80485
80572
|
const active = loadSigningKey(false);
|
|
80486
80573
|
const pubs = (process.env["LOKI_RECEIPT_RETIRED_PUBKEYS"] ?? "").split(":").map((f) => f.trim()).filter(Boolean).flatMap((f) => {
|
|
80487
80574
|
try {
|
|
80488
|
-
return [createPublicKey6(
|
|
80575
|
+
return [createPublicKey6(readFileSync121(f))];
|
|
80489
80576
|
} catch {
|
|
80490
80577
|
return [];
|
|
80491
80578
|
}
|
|
@@ -80515,14 +80602,14 @@ function checkAttestation(jwt, expectedHash, given) {
|
|
|
80515
80602
|
}
|
|
80516
80603
|
function wallTamperProblem(receiptPath, receipt) {
|
|
80517
80604
|
const wall = receipt["wall"], files = Array.isArray(wall?.files) ? wall.files : [];
|
|
80518
|
-
const wallDir =
|
|
80605
|
+
const wallDir = join138(dirname53(receiptPath), "wall"), haveWallDir = existsSync96(wallDir);
|
|
80519
80606
|
for (const f of files) {
|
|
80520
80607
|
if (typeof f?.path !== "string" || typeof f.sha256 !== "string")
|
|
80521
80608
|
continue;
|
|
80522
|
-
const copy =
|
|
80609
|
+
const copy = join138(wallDir, basename35(f.path));
|
|
80523
80610
|
let cur;
|
|
80524
80611
|
try {
|
|
80525
|
-
cur = createHash39("sha256").update(
|
|
80612
|
+
cur = createHash39("sha256").update(readFileSync121(copy)).digest("hex");
|
|
80526
80613
|
} catch {
|
|
80527
80614
|
if (haveWallDir)
|
|
80528
80615
|
return `sealed Wall file ${basename35(f.path)} is missing from the run's wall directory: it was deleted after the seal`;
|
|
@@ -80549,10 +80636,10 @@ function checkEventLog(receiptPath, receipt) {
|
|
|
80549
80636
|
const claims = st2 !== null && typeof st2 === "object" && Object.keys(st2).length > 0;
|
|
80550
80637
|
return claims ? "the receipt records stages but binds the empty-log hash, so no events.jsonl can back it (missing, empty or non-empty); the receipt is forged or was sealed without a log. Re-run the task to produce a fresh receipt" : null;
|
|
80551
80638
|
}
|
|
80552
|
-
const path =
|
|
80639
|
+
const path = join138(dirname53(receiptPath), "events.jsonl");
|
|
80553
80640
|
if (!existsSync96(path))
|
|
80554
80641
|
return "events.jsonl is missing";
|
|
80555
|
-
const raw2 =
|
|
80642
|
+
const raw2 = readFileSync121(path, "utf8"), events2 = readEvents(path), all = raw2.split(`
|
|
80556
80643
|
`).filter((l) => l.trim() !== ""), lines2 = tornTail(raw2) ? all.slice(0, -1) : all;
|
|
80557
80644
|
if (events2.length !== lines2.length || events2.some((e10, i) => e10.seq !== i))
|
|
80558
80645
|
return "events.jsonl has a forged, edited or missing line";
|
|
@@ -80572,7 +80659,7 @@ function checkEventLog(receiptPath, receipt) {
|
|
|
80572
80659
|
return h10.digest("hex") === bound ? null : "events.jsonl does not match the hash recorded at seal";
|
|
80573
80660
|
}
|
|
80574
80661
|
function checkLogSeal(receiptPath, hash, kid, given) {
|
|
80575
|
-
const path =
|
|
80662
|
+
const path = join138(dirname53(receiptPath), "events.jsonl"), events2 = readEvents(path), done = events2.findIndex((e10) => e10.type === "run.completed");
|
|
80576
80663
|
if (!events2.some((e10) => e10.type === "receipt.sealed" && e10.data["receipt_sha256"] === hash))
|
|
80577
80664
|
return { verdict: "TAMPERED", reason: "events.jsonl has no receipt.sealed event for this receipt" };
|
|
80578
80665
|
if (done < 0)
|
|
@@ -80580,7 +80667,7 @@ function checkLogSeal(receiptPath, hash, kid, given) {
|
|
|
80580
80667
|
const seal = events2[done + 1], d = seal?.type === "log.sealed" ? seal.data : null;
|
|
80581
80668
|
if (!d)
|
|
80582
80669
|
return { verdict: "TAMPERED", reason: "events.jsonl has no signed log.sealed line after run.completed" };
|
|
80583
|
-
const lines2 =
|
|
80670
|
+
const lines2 = readFileSync121(path, "utf8").split(`
|
|
80584
80671
|
`).filter((l) => l.trim() !== ""), sha7 = createHash39("sha256").update(lines2.slice(0, done + 1).join(`
|
|
80585
80672
|
`) + `
|
|
80586
80673
|
`).digest("hex");
|
|
@@ -80594,7 +80681,7 @@ async function verifyReceipt(receiptPath, deps = {}) {
|
|
|
80594
80681
|
return { verdict: "UNCHECKED", reasons: [`receipt not found: ${receiptPath}`] };
|
|
80595
80682
|
let receipt;
|
|
80596
80683
|
try {
|
|
80597
|
-
receipt = JSON.parse((deps.read ?? ((p) =>
|
|
80684
|
+
receipt = JSON.parse((deps.read ?? ((p) => readFileSync121(p, "utf8")))(receiptPath));
|
|
80598
80685
|
} catch {
|
|
80599
80686
|
return { verdict: "UNCHECKED", reasons: ["receipt.json is not valid JSON"] };
|
|
80600
80687
|
}
|
|
@@ -80689,7 +80776,7 @@ function sealCompositeCmd(runDir) {
|
|
|
80689
80776
|
`), 2;
|
|
80690
80777
|
}
|
|
80691
80778
|
const hash = compositeHash(body), sig = signReceipt(body.run_id, hash);
|
|
80692
|
-
const out3 = { ...body, composite_sha256: hash, verification: { jwt: sig.jwt, kid: sig.kid } }, path =
|
|
80779
|
+
const out3 = { ...body, composite_sha256: hash, verification: { jwt: sig.jwt, kid: sig.kid } }, path = join138(runDir, "composite.json");
|
|
80693
80780
|
writeFileSync69(`${path}.tmp`, JSON.stringify(out3, null, 2) + `
|
|
80694
80781
|
`);
|
|
80695
80782
|
renameSync23(`${path}.tmp`, path);
|
|
@@ -80705,7 +80792,7 @@ ${compositeLines(out3).join(`
|
|
|
80705
80792
|
function independentLine(receiptPath) {
|
|
80706
80793
|
let checks = [];
|
|
80707
80794
|
try {
|
|
80708
|
-
const c = JSON.parse(
|
|
80795
|
+
const c = JSON.parse(readFileSync121(receiptPath, "utf8")).checks;
|
|
80709
80796
|
if (Array.isArray(c))
|
|
80710
80797
|
checks = c;
|
|
80711
80798
|
} catch {}
|
|
@@ -80762,14 +80849,14 @@ ${/^(unknown option|expected at most one)/.test(pk2.error) ? `Usage: loki verify
|
|
|
80762
80849
|
args = pk2.args;
|
|
80763
80850
|
if (pk2.pubkey)
|
|
80764
80851
|
deps = { ...deps, pubkey: pk2.pubkey };
|
|
80765
|
-
const runsRoot2 = deps.runsRoot ??
|
|
80852
|
+
const runsRoot2 = deps.runsRoot ?? join138(lokiDir(), "runs");
|
|
80766
80853
|
const runId2 = args[0] ?? latestRunId(runsRoot2) ?? undefined;
|
|
80767
80854
|
if (!runId2)
|
|
80768
80855
|
return process.stderr.write(`loki verify: no runs found
|
|
80769
80856
|
`), 66;
|
|
80770
80857
|
const isFile = existsSync96(runId2) && statSync37(runId2).isFile();
|
|
80771
80858
|
const isPath = isFile || /[\\/]/.test(runId2) || runId2.endsWith(".json");
|
|
80772
|
-
const receiptPath = isPath ? runId2 :
|
|
80859
|
+
const receiptPath = isPath ? runId2 : join138(runsRoot2, runId2, "receipt.json");
|
|
80773
80860
|
const byRunId = !isPath;
|
|
80774
80861
|
rec2.runId = runId2;
|
|
80775
80862
|
rec2.receiptPath = receiptPath;
|
|
@@ -80785,7 +80872,7 @@ verdict: TAMPERED
|
|
|
80785
80872
|
if (result.verdict === "VERIFIED" || result.verdict === "UNSIGNED") {
|
|
80786
80873
|
const d = (() => {
|
|
80787
80874
|
try {
|
|
80788
|
-
return sealDrift(receiptPath, JSON.parse(
|
|
80875
|
+
return sealDrift(receiptPath, JSON.parse(readFileSync121(receiptPath, "utf8")));
|
|
80789
80876
|
} catch {
|
|
80790
80877
|
return null;
|
|
80791
80878
|
}
|
|
@@ -80798,7 +80885,7 @@ verdict: TAMPERED
|
|
|
80798
80885
|
{
|
|
80799
80886
|
const id2 = (() => {
|
|
80800
80887
|
try {
|
|
80801
|
-
const r = JSON.parse(
|
|
80888
|
+
const r = JSON.parse(readFileSync121(receiptPath, "utf8"));
|
|
80802
80889
|
const j10 = r["verification"]?.jwt;
|
|
80803
80890
|
const k3 = result.verdict === "VERIFIED" && typeof j10 === "string" ? JSON.parse(Buffer.from(j10.split(".")[0], "base64url").toString()).kid : null;
|
|
80804
80891
|
return { kid: typeof k3 === "string" ? k3 : null, head: typeof r["head_sha"] === "string" ? r["head_sha"] : null, verdict: typeof r["verdict"] === "string" ? r["verdict"] : null, run: typeof r["run_id"] === "string" ? r["run_id"] : null };
|
|
@@ -80816,7 +80903,7 @@ verdict: TAMPERED
|
|
|
80816
80903
|
if (result.verdict === "VERIFIED" || result.verdict === "UNSIGNED") {
|
|
80817
80904
|
const outcome = (() => {
|
|
80818
80905
|
try {
|
|
80819
|
-
return outcomeOf2(JSON.parse(
|
|
80906
|
+
return outcomeOf2(JSON.parse(readFileSync121(receiptPath, "utf8")));
|
|
80820
80907
|
} catch {
|
|
80821
80908
|
return "UNREADABLE";
|
|
80822
80909
|
}
|
|
@@ -80845,7 +80932,7 @@ verdict: ${result.verdict}
|
|
|
80845
80932
|
`);
|
|
80846
80933
|
if (result.verdict !== "TAMPERED")
|
|
80847
80934
|
try {
|
|
80848
|
-
const r = JSON.parse(
|
|
80935
|
+
const r = JSON.parse(readFileSync121(receiptPath, "utf8"));
|
|
80849
80936
|
if (isComposite(r))
|
|
80850
80937
|
for (const l of compositeLines(r))
|
|
80851
80938
|
process.stdout.write(`${l}
|
|
@@ -80903,8 +80990,8 @@ var init_verify_cmd = __esm(() => {
|
|
|
80903
80990
|
});
|
|
80904
80991
|
|
|
80905
80992
|
// src/server/app.ts
|
|
80906
|
-
import { existsSync as existsSync98, readFileSync as
|
|
80907
|
-
import { join as
|
|
80993
|
+
import { existsSync as existsSync98, readFileSync as readFileSync124, statSync as statSync38 } from "fs";
|
|
80994
|
+
import { join as join141, resolve as resolve40, sep as sep23 } from "path";
|
|
80908
80995
|
|
|
80909
80996
|
// node_modules/hono/dist/request/constants.js
|
|
80910
80997
|
var GET_MATCH_RESULT = Symbol();
|
|
@@ -91215,9 +91302,9 @@ function mount20(ctx) {
|
|
|
91215
91302
|
}
|
|
91216
91303
|
|
|
91217
91304
|
// src/server/routes/verify.ts
|
|
91218
|
-
import { readFileSync as
|
|
91305
|
+
import { readFileSync as readFileSync122, realpathSync as realpathSync36 } from "fs";
|
|
91219
91306
|
import { createPublicKey as createPublicKey7 } from "crypto";
|
|
91220
|
-
import { join as
|
|
91307
|
+
import { join as join139, sep as sep22 } from "path";
|
|
91221
91308
|
init_verify_cmd();
|
|
91222
91309
|
init_seal();
|
|
91223
91310
|
init_receipt_dsse();
|
|
@@ -91244,11 +91331,11 @@ function mount21(ctx) {
|
|
|
91244
91331
|
return done(404, "receipt not available", "not_found");
|
|
91245
91332
|
let runDir, file;
|
|
91246
91333
|
try {
|
|
91247
|
-
const root = realpathSync36(
|
|
91248
|
-
runDir = realpathSync36(
|
|
91249
|
-
if (runDir !==
|
|
91334
|
+
const root = realpathSync36(join139(repo.p, ".loki", "runs"));
|
|
91335
|
+
runDir = realpathSync36(join139(root, run2));
|
|
91336
|
+
if (runDir !== join139(root, run2))
|
|
91250
91337
|
return done(404, "receipt not found", "not_found");
|
|
91251
|
-
file = realpathSync36(
|
|
91338
|
+
file = realpathSync36(join139(runDir, "receipt.json"));
|
|
91252
91339
|
} catch {
|
|
91253
91340
|
return done(404, "receipt not found", "not_found");
|
|
91254
91341
|
}
|
|
@@ -91267,7 +91354,7 @@ function mount21(ctx) {
|
|
|
91267
91354
|
sha7 = r.receiptSha256 ?? null;
|
|
91268
91355
|
}
|
|
91269
91356
|
try {
|
|
91270
|
-
outcome = outcomeOf2(JSON.parse(
|
|
91357
|
+
outcome = outcomeOf2(JSON.parse(readFileSync122(file, "utf8")));
|
|
91271
91358
|
} catch {
|
|
91272
91359
|
outcome = "UNREADABLE";
|
|
91273
91360
|
}
|
|
@@ -91329,8 +91416,8 @@ function ttlCache(ttlMs = PROBE_CACHE_MS, now2 = Date.now) {
|
|
|
91329
91416
|
}
|
|
91330
91417
|
|
|
91331
91418
|
// src/server/legacy/shim.ts
|
|
91332
|
-
import { existsSync as existsSync97, readFileSync as
|
|
91333
|
-
import { join as
|
|
91419
|
+
import { existsSync as existsSync97, readFileSync as readFileSync123 } from "fs";
|
|
91420
|
+
import { join as join140 } from "path";
|
|
91334
91421
|
|
|
91335
91422
|
// src/server/legacy/routes.ts
|
|
91336
91423
|
var LEGACY_ROUTES = [
|
|
@@ -91708,10 +91795,10 @@ var logged = new Set;
|
|
|
91708
91795
|
var toHono = (p) => p.replace(/\{([A-Za-z_]+):path\}/g, ":$1{.+}").replace(/\{([A-Za-z_]+)\}/g, ":$1");
|
|
91709
91796
|
var NOT_SUPPORTED = "not yet supported by the Control Plane";
|
|
91710
91797
|
var repoVersion = () => {
|
|
91711
|
-
for (const f of [
|
|
91798
|
+
for (const f of [join140(import.meta.dir, "../../../../../VERSION")]) {
|
|
91712
91799
|
try {
|
|
91713
91800
|
if (existsSync97(f))
|
|
91714
|
-
return
|
|
91801
|
+
return readFileSync123(f, "utf8").trim();
|
|
91715
91802
|
} catch {}
|
|
91716
91803
|
}
|
|
91717
91804
|
return "unknown";
|
|
@@ -91893,7 +91980,7 @@ function legacyShim(opts) {
|
|
|
91893
91980
|
|
|
91894
91981
|
// src/server/app.ts
|
|
91895
91982
|
var MAX_BODY2 = 1e6;
|
|
91896
|
-
var defaultUiDir = () => [
|
|
91983
|
+
var defaultUiDir = () => [join141(import.meta.dir, "../../ui/dist"), join141(import.meta.dir, "../ui/dist")].find((d) => existsSync98(join141(d, "index.html")));
|
|
91897
91984
|
function createApp(opts) {
|
|
91898
91985
|
const uiDir = opts.uiDir ?? defaultUiDir();
|
|
91899
91986
|
const { db: db2, sqlite } = openDb(opts.dbPath);
|
|
@@ -91922,10 +92009,10 @@ function createApp(opts) {
|
|
|
91922
92009
|
await next();
|
|
91923
92010
|
});
|
|
91924
92011
|
const readInstalled = () => {
|
|
91925
|
-
for (const f of [process.env.LOKI_VERSION_FILE,
|
|
92012
|
+
for (const f of [process.env.LOKI_VERSION_FILE, join141(import.meta.dir, "../../../../VERSION")]) {
|
|
91926
92013
|
try {
|
|
91927
92014
|
if (f)
|
|
91928
|
-
return
|
|
92015
|
+
return readFileSync124(f, "utf8").trim() || "unknown";
|
|
91929
92016
|
} catch {}
|
|
91930
92017
|
}
|
|
91931
92018
|
return "unknown";
|
|
@@ -92040,7 +92127,7 @@ function createApp(opts) {
|
|
|
92040
92127
|
return new Response(Bun.file(f));
|
|
92041
92128
|
if (/\.[a-z0-9]+$/i.test(p))
|
|
92042
92129
|
return c.json({ error: "not found" }, 404);
|
|
92043
|
-
return new Response(Bun.file(
|
|
92130
|
+
return new Response(Bun.file(join141(root, "index.html")));
|
|
92044
92131
|
});
|
|
92045
92132
|
return { app, db: db2, close: () => {
|
|
92046
92133
|
clearInterval(reconciler);
|