loki-mode 11.122.0 → 11.124.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/SKILL.md +2 -2
- package/VERSION +1 -1
- package/autonomy/loki +16 -10
- package/bin/loki +25 -4
- package/dashboard/__init__.py +1 -1
- package/docs/CLI-REFERENCE.md +1 -1
- package/docs/COMPARE-OPENCODE.md +1 -1
- package/docs/INSTALLATION.md +1 -1
- package/docs/v10/GUIDE.md +17 -3
- package/loki-ts/data/child-env.json +0 -1
- package/loki-ts/dist/loki.js +1469 -1461
- package/mcp/__init__.py +1 -1
- package/package.json +2 -2
- package/packages/control-plane/dist/server.js +546 -150
- package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
- package/web-app/dist/assets/{AdminPage-ELJcLtkb.js → AdminPage-BvAm4ySc.js} +1 -1
- package/web-app/dist/assets/{Avatar-CsqnCi_p.js → Avatar-kQUzeStP.js} +1 -1
- package/web-app/dist/assets/{Badge-C_AmZbBO.js → Badge-D4eUYCgq.js} +1 -1
- package/web-app/dist/assets/{Button-BtGxa4qB.js → Button-WH99mfd7.js} +1 -1
- package/web-app/dist/assets/{CockpitPage-nS3WP8mA.js → CockpitPage-Cv5zO98w.js} +1 -1
- package/web-app/dist/assets/{ComparePage-DFmhp7ZQ.js → ComparePage-EV5xJmmI.js} +1 -1
- package/web-app/dist/assets/{ErrorBoundary-CIxZiWVd.js → ErrorBoundary-L6iR8_c-.js} +1 -1
- package/web-app/dist/assets/{EvidenceReceiptPanel-BhxfDSCB.js → EvidenceReceiptPanel-BM5r70lI.js} +1 -1
- package/web-app/dist/assets/{GitHubIssuesPanel-Be1-OBZV.js → GitHubIssuesPanel--YZfG6dZ.js} +1 -1
- package/web-app/dist/assets/{GitHubPRsPanel-CQ7GJtyd.js → GitHubPRsPanel-B-6TqaEm.js} +1 -1
- package/web-app/dist/assets/{HomePage-zH8kd4P5.js → HomePage-DvwjUEnK.js} +2 -2
- package/web-app/dist/assets/{LoginPage-ZjJnKrHl.js → LoginPage-ko7MeVCY.js} +1 -1
- package/web-app/dist/assets/{MagicPage-DI3TPf-S.js → MagicPage-XhL6MTuJ.js} +1 -1
- package/web-app/dist/assets/{MetricsPage-CeR0x61k.js → MetricsPage-HcC3Or73.js} +1 -1
- package/web-app/dist/assets/{NotFoundPage-BvKY8u-G.js → NotFoundPage-CeJEgHjE.js} +1 -1
- package/web-app/dist/assets/{ProjectPage-BbIFH1-O.js → ProjectPage-CKU5LEDo.js} +3 -3
- package/web-app/dist/assets/{ProjectsPage-CEUgVVLS.js → ProjectsPage-BgDkiPRW.js} +1 -1
- package/web-app/dist/assets/{SettingsPage-tTkVUAal.js → SettingsPage-No-vQaFb.js} +1 -1
- package/web-app/dist/assets/{ShowcasePage-15PBVhXm.js → ShowcasePage-CHP4rl-j.js} +1 -1
- package/web-app/dist/assets/{SystemSettingsPage-DWTYrIOO.js → SystemSettingsPage-BKf5UPHR.js} +1 -1
- package/web-app/dist/assets/{TeamsPage-DIzu8nMF.js → TeamsPage-Cnp-tYk0.js} +1 -1
- package/web-app/dist/assets/{TemplatesPage-BqeLAU68.js → TemplatesPage-BpYzTNGm.js} +1 -1
- package/web-app/dist/assets/{TerminalOutput-oqqL1P5w.js → TerminalOutput-CBQV2pLD.js} +1 -1
- package/web-app/dist/assets/{activity-YIEhaE4F.js → activity-mdcFMSaL.js} +1 -1
- package/web-app/dist/assets/{bell-DYUkKCEP.js → bell-Wg2pH1yn.js} +1 -1
- package/web-app/dist/assets/{bot-CtgoOtgo.js → bot-DKBlvxJ7.js} +1 -1
- package/web-app/dist/assets/{check-DdihsgbN.js → check-Xc05lcnu.js} +1 -1
- package/web-app/dist/assets/{chevron-left-C68KK6Gu.js → chevron-left-DltqPq5E.js} +1 -1
- package/web-app/dist/assets/{circle-alert-vhaF7mcu.js → circle-alert-BVh-fhvu.js} +1 -1
- package/web-app/dist/assets/{clock-D9W45YOn.js → clock-B5cBSKWU.js} +1 -1
- package/web-app/dist/assets/{cloud-Dxz7iDTW.js → cloud-BSX6IFA2.js} +1 -1
- package/web-app/dist/assets/{code-xml-BqkN83_U.js → code-xml-B9hQtfJY.js} +1 -1
- package/web-app/dist/assets/{database-3yX88OUR.js → database-BaZUbYQA.js} +1 -1
- package/web-app/dist/assets/{dollar-sign-CF0rEEKZ.js → dollar-sign-DwQy7yIO.js} +1 -1
- package/web-app/dist/assets/{file-code-corner-Ce7TAquR.js → file-code-corner-DA2DZ0pw.js} +1 -1
- package/web-app/dist/assets/{file-plus-2A_4XZn7.js → file-plus-C1ACdrL7.js} +1 -1
- package/web-app/dist/assets/{globe-CD9NOOOM.js → globe-DPYmKYx6.js} +1 -1
- package/web-app/dist/assets/{hammer-Bih-uaC_.js → hammer-CeiyISLC.js} +1 -1
- package/web-app/dist/assets/{index-DIs2i7KF.js → index-CDMhTULK.js} +3 -3
- package/web-app/dist/assets/{layers-BKK3PIBk.js → layers-Cx7Y47_Z.js} +1 -1
- package/web-app/dist/assets/{loader-circle-bGpRrwX7.js → loader-circle-upNH5P_M.js} +1 -1
- package/web-app/dist/assets/{lock-QNU37P0J.js → lock-DdZ3BKZK.js} +1 -1
- package/web-app/dist/assets/{package-Br0MWvyj.js → package-DbsEgrVK.js} +1 -1
- package/web-app/dist/assets/{plus-D7_32jEf.js → plus-Cqvnwkwf.js} +1 -1
- package/web-app/dist/assets/{refresh-cw-YfmCgQZp.js → refresh-cw-BPCT2xXe.js} +1 -1
- package/web-app/dist/assets/{rotate-ccw-DRkA8aQa.js → rotate-ccw-D3dUoyD4.js} +1 -1
- package/web-app/dist/assets/{scroll-text-yMs1sJD4.js → scroll-text-XglXNYfV.js} +1 -1
- package/web-app/dist/assets/{server-DQJajJt9.js → server-oNbEjlvC.js} +1 -1
- package/web-app/dist/assets/{shield-alert-BuXMkNPa.js → shield-alert-DQpkGKgb.js} +1 -1
- package/web-app/dist/assets/{thumbs-up-BjWoo0Rp.js → thumbs-up-MpxIM2sF.js} +1 -1
- package/web-app/dist/assets/{trash-2-CCuQNkX7.js → trash-2-B_9Ytb-g.js} +1 -1
- package/web-app/dist/assets/{trending-down-CXHO9K8m.js → trending-down-CywJR3Xl.js} +1 -1
- package/web-app/dist/assets/{trending-up-Csfmj8CR.js → trending-up-BgB1GV4J.js} +1 -1
- package/web-app/dist/assets/{upload-ZOszdITh.js → upload-DWfOCF-u.js} +1 -1
- package/web-app/dist/assets/{usePolling-DbEhYhl9.js → usePolling-BcMEuu-8.js} +1 -1
- package/web-app/dist/assets/{user-DPJ9LSGJ.js → user-Dxf7avUA.js} +1 -1
- package/web-app/dist/index.html +1 -1
|
@@ -855,13 +855,24 @@ function routerMode(env = process.env) {
|
|
|
855
855
|
return "opt-out";
|
|
856
856
|
if (v === "1" || v === "true" || v === "on")
|
|
857
857
|
return "on";
|
|
858
|
+
if (v === "auto")
|
|
859
|
+
return "auto";
|
|
858
860
|
return "off";
|
|
859
861
|
}
|
|
862
|
+
function presetExecutor(env = process.env) {
|
|
863
|
+
const fixed = (env.LOKI_ROUTER_EXECUTOR ?? "").trim();
|
|
864
|
+
if (fixed)
|
|
865
|
+
return { model: fixed, reason: "LOKI_ROUTER=auto, executor from LOKI_ROUTER_EXECUTOR" };
|
|
866
|
+
return env.LOKI_ALLOW_HAIKU === "false" ? { model: "sonnet", reason: "LOKI_ROUTER=auto with LOKI_ALLOW_HAIKU=false: Sonnet executes implement and fix" } : { model: "haiku", reason: "LOKI_ROUTER=auto: Haiku executes implement and fix" };
|
|
867
|
+
}
|
|
860
868
|
function advisorOnlyEnabled(env = process.env) {
|
|
861
869
|
const v = (env.LOKI_ADVISOR ?? "").trim().toLowerCase();
|
|
862
870
|
return v === "1" || v === "true" || v === "on";
|
|
863
871
|
}
|
|
864
|
-
var routerEnabled = (env = process.env) =>
|
|
872
|
+
var routerEnabled = (env = process.env) => {
|
|
873
|
+
const m = routerMode(env);
|
|
874
|
+
return m === "on" || m === "auto";
|
|
875
|
+
}, routerPreset = (env = process.env) => routerMode(env) === "auto", sessionPlanEnabled = (env = process.env) => routerEnabled(env) || advisorOnlyEnabled(env);
|
|
865
876
|
|
|
866
877
|
// ../../loki-ts/src/providers/price_table.ts
|
|
867
878
|
import { readFileSync as readFileSync2, statSync as statSync2 } from "fs";
|
|
@@ -12709,7 +12720,7 @@ function parseRoute(input, advisorAvailable) {
|
|
|
12709
12720
|
return { route: { executor: r.executor, reason: r.reason, risk: r.risk, source: r.source }, notProven: null };
|
|
12710
12721
|
}
|
|
12711
12722
|
function envOverride(env) {
|
|
12712
|
-
for (const k of ["LOKI_MODEL_OVERRIDE", "LOKI_CLAUDE_MODEL_DEVELOPMENT"]) {
|
|
12723
|
+
for (const k of ["LOKI_MODEL_OVERRIDE", "LOKI_CLAUDE_MODEL_DEVELOPMENT", "LOKI_MODEL_DEVELOPMENT", "LOKI_SESSION_MODEL"]) {
|
|
12713
12724
|
const v = (env[k] ?? "").trim();
|
|
12714
12725
|
if (v)
|
|
12715
12726
|
return v;
|
|
@@ -12831,23 +12842,19 @@ function cascadeDowngrade(runModel, env = process.env) {
|
|
|
12831
12842
|
const to = cascadeImplementModel(env);
|
|
12832
12843
|
return cascadeEnabled(env) && modelRank(to) < modelRank(runModel) ? { from: runModel, to, note: `model downgraded by cascade: ${runModel} -> ${to} (opt-in)` } : null;
|
|
12833
12844
|
}
|
|
12834
|
-
function haikuFirstDowngrade(runModel, env = process.env) {
|
|
12835
|
-
const to = resolveModelAlias("haiku");
|
|
12836
|
-
return haikuFirstEnabled(env) && modelRank(to) < modelRank(runModel) ? { from: runModel, to, note: `model downgraded by haiku-first: ${runModel} -> ${to} (opt-in; a failed verify escalates to ${runModel})` } : null;
|
|
12837
|
-
}
|
|
12838
12845
|
function climb(unit, current, trigger, evidence) {
|
|
12839
12846
|
const k = klass(current);
|
|
12840
12847
|
const model = k.includes("haiku") ? "haiku" : k.includes("sonnet") ? "sonnet" : null;
|
|
12841
12848
|
if (!model)
|
|
12842
12849
|
return null;
|
|
12843
12850
|
const t = nextState({ model, swapped: false }, EVENT[trigger]);
|
|
12844
|
-
const next = t.action === "none" || t.action === "blocked" || t.action === "stalled" ? model === "sonnet" && trigger === "escalate_marker" ? "opus" : null : t.state.model;
|
|
12845
|
-
return next && next !== model ? { unit, from: current, to: resolveModelAlias(next), trigger, evidence: evidence.slice(0, 300) } : null;
|
|
12851
|
+
const next = t.action === "none" || t.action === "blocked" || t.action === "stalled" ? model === "sonnet" && (trigger === "escalate_marker" || trigger === "already_done_claim") ? "opus" : null : t.state.model;
|
|
12852
|
+
return next && next !== model ? { unit, from: current, to: resolveModelAlias(next), trigger, evidence: redactSecrets(evidence).slice(0, 300) } : null;
|
|
12846
12853
|
}
|
|
12847
12854
|
var modelRank = (m) => {
|
|
12848
12855
|
const id = resolveModelAlias(m).toLowerCase();
|
|
12849
12856
|
return ["haiku", "sonnet", "opus", "fable"].findIndex((t) => id.includes(t)) + (id.match(/haiku|sonnet|opus|fable/) ? 0 : 5);
|
|
12850
|
-
}, escalationModel = (runModel) => sessionPinModel() ? runModel : runModel !== PROVIDER_DEFAULT_MODEL && modelRank(runModel) > modelRank("opus") ? runModel : resolveModelAlias("opus"),
|
|
12857
|
+
}, escalationModel = (runModel) => sessionPinModel() ? runModel : runModel !== PROVIDER_DEFAULT_MODEL && modelRank(runModel) > modelRank("opus") ? runModel : resolveModelAlias("opus"), capToRunTier = (pin, runModel, pinKeys, env = process.env) => pinKeys.some((k) => !!env[k]) || !runModel || modelRank(pin) <= modelRank(runModel) ? pin : runModel, capToSessionPin = (model, env = process.env) => {
|
|
12851
12858
|
const pin = sessionPinModel(env);
|
|
12852
12859
|
return model && pin && modelRank(model) > modelRank(pin) ? pin : model;
|
|
12853
12860
|
}, klass = (m) => resolveModelAlias(m).toLowerCase(), EVENT;
|
|
@@ -12855,7 +12862,8 @@ var init_model_rank = __esm(() => {
|
|
|
12855
12862
|
init_sizing();
|
|
12856
12863
|
init_session();
|
|
12857
12864
|
init_decision();
|
|
12858
|
-
|
|
12865
|
+
init_redact();
|
|
12866
|
+
EVENT = { code_fail: { kind: "code_fail_repeat" }, escalate_marker: { kind: "escalate_marker" }, spec_conflict: { kind: "spec_conflict" }, limit_kill: { kind: "limit_kill" }, stall: { kind: "stall" }, already_done_claim: { kind: "escalate_marker" } };
|
|
12859
12867
|
});
|
|
12860
12868
|
|
|
12861
12869
|
// ../../loki-ts/src/engine10/sizing.ts
|
|
@@ -12883,6 +12891,18 @@ function sizeTask(task, map, tests) {
|
|
|
12883
12891
|
].filter((w) => typeof w === "string");
|
|
12884
12892
|
return why.length ? { size: "normal", reasons: why } : { size: "small", reasons: [`task ${task.length} chars, names ${named} files`] };
|
|
12885
12893
|
}
|
|
12894
|
+
function namedDistinct(task, map) {
|
|
12895
|
+
const text3 = task.toLowerCase(), named = namedFiles(task, map).filter((f) => !isTestFile(f)).map((f) => f.toLowerCase());
|
|
12896
|
+
const spelled = new Set(named.filter((f) => f.includes("/") && new RegExp(`(?<![\\w./-])${escRe(f)}(?![\\w-]|\\.\\w)`).test(text3)));
|
|
12897
|
+
const spelledBase = new Set([...spelled].map((f) => basename11(f)));
|
|
12898
|
+
return spelled.size + new Set(named.map((f) => basename11(f)).filter((b) => !spelledBase.has(b))).size;
|
|
12899
|
+
}
|
|
12900
|
+
function hardReason(size, map, task) {
|
|
12901
|
+
if (size === "large")
|
|
12902
|
+
return "task sized large";
|
|
12903
|
+
const n3 = namedDistinct(task, map);
|
|
12904
|
+
return n3 > HARD_NAMED_FILES ? `task names ${n3} distinct non-test files > ${HARD_NAMED_FILES}` : null;
|
|
12905
|
+
}
|
|
12886
12906
|
function loadRepoMap(repomapRef) {
|
|
12887
12907
|
try {
|
|
12888
12908
|
return repomapRef && existsSync22(repomapRef) ? JSON.parse(readFileSync33(repomapRef, "utf8")) : null;
|
|
@@ -12915,7 +12935,7 @@ var escRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), LARGE_NAMED_FILES =
|
|
|
12915
12935
|
return n3;
|
|
12916
12936
|
noteOnce("LOKI_E10_SMALL_MAX_CHARS", env.LOKI_E10_SMALL_MAX_CHARS, "is not a positive number; using 600");
|
|
12917
12937
|
return 600;
|
|
12918
|
-
}, WALL_TINY_MAX_CHARS = 300, WALL_TINY_BOUND = "Tiny task: write exactly one test file with at most 6 assertions unless more acceptance lines exist, then exactly one per acceptance line.", isTinyGreenfield = (size, task, tests) => size === "small" && task.length <= WALL_TINY_MAX_CHARS && !tests?.runners.length && !tests?.tests.length, smallTaskPath = (size, relevantTests) => size !== "large" && relevantTests ? "lean" : "wall", knob = (v, words) => words.includes((v ?? "").toLowerCase()), planMode = (env = process.env) => knob(env.LOKI_E10_PLAN, ["0", "off", "never", "false"]) ? "never" : knob(env.LOKI_E10_PLAN, ["1", "on", "always", "true"]) ? "always" : "auto", wallEnabled = (env = process.env) => !knob(env.LOKI_E10_WALL, ["0", "off", "false"]), wallLimitS = (size, env = process.env) => {
|
|
12938
|
+
}, HARD_NAMED_FILES = 4, WALL_TINY_MAX_CHARS = 300, WALL_TINY_BOUND = "Tiny task: write exactly one test file with at most 6 assertions unless more acceptance lines exist, then exactly one per acceptance line.", isTinyGreenfield = (size, task, tests) => size === "small" && task.length <= WALL_TINY_MAX_CHARS && !tests?.runners.length && !tests?.tests.length, smallTaskPath = (size, relevantTests) => size !== "large" && relevantTests ? "lean" : "wall", knob = (v, words) => words.includes((v ?? "").toLowerCase()), planMode = (env = process.env) => knob(env.LOKI_E10_PLAN, ["0", "off", "never", "false"]) ? "never" : knob(env.LOKI_E10_PLAN, ["1", "on", "always", "true"]) ? "always" : "auto", wallEnabled = (env = process.env) => !knob(env.LOKI_E10_WALL, ["0", "off", "false"]), wallLimitS = (size, env = process.env) => {
|
|
12919
12939
|
const raw2 = env.LOKI_E10_WALL_LIMIT_S, n3 = Number(raw2), dflt = size === "small" ? 90 : 180;
|
|
12920
12940
|
if (Number.isFinite(n3) && n3 > 0) {
|
|
12921
12941
|
if (n3 > 300)
|
|
@@ -12934,6 +12954,7 @@ var init_sizing = __esm(() => {
|
|
|
12934
12954
|
init_lean_select();
|
|
12935
12955
|
init_decompose();
|
|
12936
12956
|
init_claude_model();
|
|
12957
|
+
init_test_file_text();
|
|
12937
12958
|
init_wall_knobs();
|
|
12938
12959
|
init_model_rank();
|
|
12939
12960
|
init_wall_knobs();
|
|
@@ -13202,13 +13223,10 @@ function modelDowngrades(provider, env = process.env, runModel = env.LOKI_CLAUDE
|
|
|
13202
13223
|
const out2 = [];
|
|
13203
13224
|
if (cascadeEnabled(env))
|
|
13204
13225
|
out2.push({ stage: "implement,fix", model: cascadeImplementModel(env), reason: "LOKI_E10_CASCADE opt-in" });
|
|
13205
|
-
if (
|
|
13206
|
-
|
|
13207
|
-
|
|
13208
|
-
|
|
13209
|
-
out2.push({ stage: "implement", model: cascadeImplementModel(env), reason: "LOKI_IMPLEMENT_HAIKU_FIRST overridden by LOKI_E10_CASCADE" });
|
|
13210
|
-
else
|
|
13211
|
-
out2.push({ stage: "implement", model: resolveModelAlias("haiku"), reason: "LOKI_IMPLEMENT_HAIKU_FIRST opt-in" });
|
|
13226
|
+
if (routerPreset(env) && routerActive(env)) {
|
|
13227
|
+
const p = presetExecutor(env);
|
|
13228
|
+
if (weak(p.model))
|
|
13229
|
+
out2.push({ stage: "implement,fix", model: resolveModelAlias(p.model), reason: "LOKI_ROUTER=auto preset (climbs on a code-owned failure)" });
|
|
13212
13230
|
}
|
|
13213
13231
|
if (leanEnabled(env) && routerActive(env))
|
|
13214
13232
|
out2.push({ stage: "implement", model: resolveModelAlias("sonnet"), reason: "LOKI_LEAN opt-in (small and normal units; one rung up after a failed verify)" });
|
|
@@ -13225,7 +13243,6 @@ function modelDowngrades(provider, env = process.env, runModel = env.LOKI_CLAUDE
|
|
|
13225
13243
|
var weak = (m) => !!m && /sonnet|haiku/i.test(m);
|
|
13226
13244
|
var init_model_downgrades = __esm(() => {
|
|
13227
13245
|
init_sizing();
|
|
13228
|
-
init_model_rank();
|
|
13229
13246
|
init_claude_model();
|
|
13230
13247
|
init_unit_model();
|
|
13231
13248
|
init_decision();
|
|
@@ -17985,7 +18002,7 @@ const done = (code, sig) => { if (fin) return; fin = true; kill("SIGKILL"); try
|
|
|
17985
18002
|
setTimeout(() => { to = true; kill("SIGTERM"); setTimeout(() => done(null, 1), 1000); }, ms);
|
|
17986
18003
|
const over = () => { if (out.length > MAX || err.length > MAX) { to = true; kill("SIGKILL"); } };
|
|
17987
18004
|
c.stdout.on("data", (d) => { out += d; over(); }); c.stderr.on("data", (d) => { err += d; over(); });
|
|
17988
|
-
c.on("error", () => done(null, 1)); c.on("close", done); c.on("exit", (a, b) => setTimeout(() => done(a, b), 500)); `, FULL_SUITE_STATIC, BUILD_TOOL_RUNNERS, ALREADY_FAILING_ON_BASE = "already failing on base, not caused by this change", SKIPPED_BY_REPO = "skipped by the repo on base and head", checkResultLabel = (result, preRed, repoSkipped = false) => result === "fail" && preRed ? `fail (${ALREADY_FAILING_ON_BASE})` : result === "not_run" && repoSkipped ? `not_run (${SKIPPED_BY_REPO})` : result, blobSha = (b, hex) => createHash13(hex === 64 ? "sha256" : "sha1").update(Buffer.concat([Buffer.from(`blob ${b.length}\x00`), b])).digest("hex"), URL_RE, ANCHOR_RE, EXTENSIONLESS;
|
|
18005
|
+
c.on("error", () => done(null, 1)); c.on("close", done); c.on("exit", (a, b) => setTimeout(() => done(a, b), 500)); `, FULL_SUITE_STATIC, BUILD_TOOL_RUNNERS, WALL_FAILURE_TAIL_FILE = "wall-failure-tail.txt", ALREADY_FAILING_ON_BASE = "already failing on base, not caused by this change", SKIPPED_BY_REPO = "skipped by the repo on base and head", checkResultLabel = (result, preRed, repoSkipped = false) => result === "fail" && preRed ? `fail (${ALREADY_FAILING_ON_BASE})` : result === "not_run" && repoSkipped ? `not_run (${SKIPPED_BY_REPO})` : result, blobSha = (b, hex) => createHash13(hex === 64 ? "sha256" : "sha1").update(Buffer.concat([Buffer.from(`blob ${b.length}\x00`), b])).digest("hex"), URL_RE, ANCHOR_RE, EXTENSIONLESS;
|
|
17989
18006
|
var init_check_result = __esm(() => {
|
|
17990
18007
|
init_stack_tools();
|
|
17991
18008
|
init_dotnet_test();
|
|
@@ -18922,6 +18939,10 @@ function validHaikuRoute(plan) {
|
|
|
18922
18939
|
return { reason: String(units[0]["reason"]) };
|
|
18923
18940
|
}
|
|
18924
18941
|
function routeRecord(runModel, plan, historyFloor, size, env = process.env) {
|
|
18942
|
+
if (routerPreset(env)) {
|
|
18943
|
+
const p = presetExecutor(env);
|
|
18944
|
+
return { model: resolveModelAlias(p.model), source: "preset", reason: p.reason, valid: true };
|
|
18945
|
+
}
|
|
18925
18946
|
const v = validHaikuRoute(plan);
|
|
18926
18947
|
const h = v && historyFloor ? historyRaisedRoute(v.reason, historyFloor()) : null;
|
|
18927
18948
|
if (h)
|
|
@@ -18933,14 +18954,15 @@ function routeRecord(runModel, plan, historyFloor, size, env = process.env) {
|
|
|
18933
18954
|
}
|
|
18934
18955
|
function routedFix(runModel, out2, o) {
|
|
18935
18956
|
const rec = routeRecord(runModel, out2["plan"]);
|
|
18936
|
-
const
|
|
18957
|
+
const impl = String(out2["implement"]?.["route_model"] ?? rec.model), last = String(out2["fix"]?.["model"] ?? impl);
|
|
18958
|
+
const carried = modelRank(last) >= modelRank(impl) ? last : impl;
|
|
18937
18959
|
const floor = runFloor(runModel);
|
|
18938
18960
|
const cur = !rec.valid && modelRank(carried) < modelRank(floor) ? floor : carried;
|
|
18939
18961
|
const lean = leanEnabled() && routerPinsAllowed() && modelRank(carried) >= modelRank("sonnet") && modelRank(carried) < modelRank(floor);
|
|
18940
18962
|
const tests = o.groups.filter((g) => !g.signature.startsWith("lint:") && g.signature !== "select-tests").length;
|
|
18941
18963
|
if (lean && tests > 0) {
|
|
18942
18964
|
const to = runModel === PROVIDER_DEFAULT_MODEL ? undefined : runModel;
|
|
18943
|
-
return { pin: to, climbed: { unit: "run", from: carried, to: to ?? floor, trigger: o.stall ? "stall" : "code_fail", evidence: o.reason.slice(0, 300) } };
|
|
18965
|
+
return { pin: to, climbed: { unit: "run", from: carried, to: to ?? floor, trigger: o.stall ? "stall" : "code_fail", evidence: redactSecrets(o.reason).slice(0, 300) } };
|
|
18944
18966
|
}
|
|
18945
18967
|
if (lean)
|
|
18946
18968
|
return { pin: carried, climbed: null };
|
|
@@ -18963,6 +18985,7 @@ var init_unit_model = __esm(() => {
|
|
|
18963
18985
|
init_decision();
|
|
18964
18986
|
init_history();
|
|
18965
18987
|
init_model_rank();
|
|
18988
|
+
init_redact();
|
|
18966
18989
|
});
|
|
18967
18990
|
|
|
18968
18991
|
// ../../loki-ts/src/runner/router/session_route.ts
|
|
@@ -21386,6 +21409,13 @@ var init_install = __esm(() => {
|
|
|
21386
21409
|
STATUS_MAX_BUFFER = 64 * 1024 * 1024;
|
|
21387
21410
|
});
|
|
21388
21411
|
|
|
21412
|
+
// ../../loki-ts/src/contrib/wall_snapshot.ts
|
|
21413
|
+
var MANIFESTS2;
|
|
21414
|
+
var init_wall_snapshot = __esm(() => {
|
|
21415
|
+
init_safe_git();
|
|
21416
|
+
MANIFESTS2 = /(^|\/)(package\.json|package-lock\.json|npm-shrinkwrap\.json|yarn\.lock|pnpm-lock\.yaml|bun\.lockb?|pyproject\.toml|poetry\.lock|Pipfile(\.lock)?|requirements[^/]*\.txt|setup\.py|setup\.cfg|go\.(mod|sum)|Cargo\.(toml|lock))$/;
|
|
21417
|
+
});
|
|
21418
|
+
|
|
21389
21419
|
// ../../loki-ts/src/features/runner_config.ts
|
|
21390
21420
|
import { createHash as createHash19 } from "crypto";
|
|
21391
21421
|
import { readdirSync as readdirSync24, readFileSync as readFileSync55 } from "fs";
|
|
@@ -22743,6 +22773,10 @@ function routeStartLine(env, provider) {
|
|
|
22743
22773
|
return null;
|
|
22744
22774
|
const fixed = (env["LOKI_ROUTER_EXECUTOR"] ?? "").trim();
|
|
22745
22775
|
const why = advisorUnavailableReason(env, provider);
|
|
22776
|
+
if (routerPreset(env)) {
|
|
22777
|
+
const p = presetExecutor(env);
|
|
22778
|
+
return `route: auto preset, ${modelLabel(p.model)} executes implement and fix, Opus plans a hard task, climbs on failure${why ? `, advisor unavailable: ${why}` : ", advisor opus on plan and fix"}`;
|
|
22779
|
+
}
|
|
22746
22780
|
const exec = `route: decided at plan time, per-unit executors not applied (stages run the run model)${fixed ? `, ${modelLabel(fixed)} requested by LOKI_ROUTER_EXECUTOR` : ""}`;
|
|
22747
22781
|
if (why)
|
|
22748
22782
|
return `${exec}, advisor unavailable: ${why}`;
|
|
@@ -23450,7 +23484,7 @@ function commitUnsealedWork(intact, repoDir, workerEnv, runId, intake) {
|
|
|
23450
23484
|
const keys = (o) => o && typeof o === "object" ? Object.keys(o) : [];
|
|
23451
23485
|
const users = [...keys(intake["preexisting_dirty"]), ...keys(intake["preexisting_untracked_blobs"]), ...Array.isArray(intake["preexisting_untracked"]) ? intake["preexisting_untracked"].map(String) : []];
|
|
23452
23486
|
g(["add", "-A", "--", "."]);
|
|
23453
|
-
const keep = g(["--literal-pathspecs", "ls-files", "--cached", "-z", "--", "
|
|
23487
|
+
const spec = ["--", ".loki", ...new Set(users)], keep = [...new Set([...g(["--literal-pathspecs", "ls-files", "--cached", "-z", ...spec]).split("\x00"), ...g(["--literal-pathspecs", "diff", "--cached", "--name-only", "--no-renames", "-z", ...spec]).split("\x00")].filter(Boolean))];
|
|
23454
23488
|
if (keep.length > 0)
|
|
23455
23489
|
g(["--literal-pathspecs", "reset", "-q", "HEAD", "--", ...keep]);
|
|
23456
23490
|
try {
|
|
@@ -27036,7 +27070,7 @@ function* installCore(ctx, a, baseDir, opts) {
|
|
|
27036
27070
|
}
|
|
27037
27071
|
ctx.wallSealed = true;
|
|
27038
27072
|
ctx.emit("wall.sealed", "wall", { files: sealedFiles, ...a.manifestSha256 ? { manifest_sha256: a.manifestSha256 } : {} });
|
|
27039
|
-
const baseRunner = opts.baseRunner ?? new RealBaseTestRunner, baseRun = { pass: 0, fail: 0, not_run: discarded.length }, notRunFiles = [];
|
|
27073
|
+
const baseRunner = opts.baseRunner ?? new RealBaseTestRunner(baseDir !== ctx.repoDir ? loadProjectApi(ctx.repoDir) : undefined), baseRun = { pass: 0, fail: 0, not_run: discarded.length }, notRunFiles = [];
|
|
27040
27074
|
for (const f of sealedFiles) {
|
|
27041
27075
|
const rel = relative16(ctx.repoDir, f.path);
|
|
27042
27076
|
if (!wallTests.some((t) => t.path === rel))
|
|
@@ -29392,6 +29426,8 @@ import { join as join91 } from "path";
|
|
|
29392
29426
|
function buildRouteRecord(i) {
|
|
29393
29427
|
const notProven = [...i.notProven, ...i.planModelNote ? [`plan model: NOT PROVEN (owner provider): ${i.planModelNote}`] : []];
|
|
29394
29428
|
const base2 = { plan_model: i.planModel, shape_key: i.shapeKey, route_not_proven: notProven, applied: PER_UNIT_EXECUTORS_APPLIED };
|
|
29429
|
+
if (i.preset)
|
|
29430
|
+
return { ...base2, applied: true, routed: true, executor: i.preset.model, source: "preset", reason: `${i.preset.reason}${i.skipReason ? `; ${i.skipReason}` : ""}`, units: [] };
|
|
29395
29431
|
if (i.units.length === 0) {
|
|
29396
29432
|
const why = i.skipReason ?? i.notProven[0] ?? "no per-unit routes returned";
|
|
29397
29433
|
return { ...base2, routed: false, executor: "sonnet", source: "default", reason: `no plan route (NOT PROVEN): ${why}`, units: [] };
|
|
@@ -30191,7 +30227,7 @@ function supplyVerdict(verdict, r) {
|
|
|
30191
30227
|
return r.blocked && verdict === "VERIFIED" ? "FAILED" : verdict;
|
|
30192
30228
|
}
|
|
30193
30229
|
function isManifestPath(path) {
|
|
30194
|
-
return
|
|
30230
|
+
return MANIFESTS3.test(basename25(path));
|
|
30195
30231
|
}
|
|
30196
30232
|
function readDeclared(repoDir) {
|
|
30197
30233
|
const p = join94(repoDir, ".loki", DECLARED_FILE);
|
|
@@ -30389,7 +30425,7 @@ async function supplyGuard(repoDir, changedFiles2, declared, env, opts = {}) {
|
|
|
30389
30425
|
}
|
|
30390
30426
|
return { block: { guard: "v2", warn_age_days: MIN_AGE_DAYS, fail_age_days: failAge, declared: declared.deps.length, entries }, notProven, blocked };
|
|
30391
30427
|
}
|
|
30392
|
-
var MIN_AGE_DAYS = 7, DECLARED_FILE = "supply-declared.json", MAX_CHECKED = 50, MAX_DECLARED = 200, MAX_FILE_BYTES, DAY_MS = 86400000,
|
|
30428
|
+
var MIN_AGE_DAYS = 7, DECLARED_FILE = "supply-declared.json", MAX_CHECKED = 50, MAX_DECLARED = 200, MAX_FILE_BYTES, DAY_MS = 86400000, MANIFESTS3, ECO, NAME2, defaultResolver = async (dep, cwd) => {
|
|
30393
30429
|
const argv = {
|
|
30394
30430
|
npm: ["npm", "view", dep.name, "time.created", "--json"],
|
|
30395
30431
|
pypi: ["pip", "index", "versions", "--pre", "--ignore-requires-python", dep.name],
|
|
@@ -30415,7 +30451,7 @@ var MIN_AGE_DAYS = 7, DECLARED_FILE = "supply-declared.json", MAX_CHECKED = 50,
|
|
|
30415
30451
|
var init_supply_guard = __esm(() => {
|
|
30416
30452
|
init_shell();
|
|
30417
30453
|
MAX_FILE_BYTES = 64 * 1024;
|
|
30418
|
-
|
|
30454
|
+
MANIFESTS3 = /^(package\.json|package-lock\.json|npm-shrinkwrap\.json|yarn\.lock|pnpm-lock\.yaml|bun\.lockb?|requirements.*\.txt|pyproject\.toml|poetry\.lock|uv\.lock|Pipfile|Pipfile\.lock|go\.mod|go\.sum|Cargo\.toml|Cargo\.lock|Gemfile|Gemfile\.lock|composer\.json|composer\.lock|pom\.xml|build\.gradle(\.kts)?)$/;
|
|
30419
30455
|
ECO = { npm: "npm", node: "npm", pypi: "pypi", pip: "pypi", python: "pypi", cargo: "cargo", crates: "cargo", go: "go", golang: "go" };
|
|
30420
30456
|
NAME2 = /^[A-Za-z0-9@][A-Za-z0-9@._/~+-]{0,213}$/;
|
|
30421
30457
|
PUBLIC_HOSTS = new Set(["registry.npmjs.org", "registry.npmjs.com", "registry.yarnpkg.com", "npmjs.com", "npmjs.org", "pypi.org", "pypi.python.org", "files.pythonhosted.org", "crates.io", "index.crates.io", "static.crates.io", "proxy.golang.org", "golang.org", "pkg.go.dev"]);
|
|
@@ -32306,15 +32342,17 @@ async function planRoute(runDir, provider, env = process.env, repoDir = "") {
|
|
|
32306
32342
|
cached = bad ? { units: [], notProven: [bad] } : parseUnits(scope, advisorAvailable);
|
|
32307
32343
|
return cached;
|
|
32308
32344
|
};
|
|
32345
|
+
const preset = routerPreset(env);
|
|
32309
32346
|
const out2 = {
|
|
32310
32347
|
routed,
|
|
32348
|
+
preset,
|
|
32311
32349
|
advisor,
|
|
32312
32350
|
pinOpus,
|
|
32313
32351
|
pin: pinOpus ? { model: "opus" } : {},
|
|
32314
32352
|
pinFor: (onSonnet, runModel) => onSonnet ? { model: planFallbackModel(runModel) } : out2.pin,
|
|
32315
32353
|
planModel: (fastModel) => pinOpus ? "opus" : provider === "claude" ? fastModel : "provider default",
|
|
32316
32354
|
units: () => {
|
|
32317
|
-
if (!routed)
|
|
32355
|
+
if (!routed || preset)
|
|
32318
32356
|
return {};
|
|
32319
32357
|
const parsed = parse3();
|
|
32320
32358
|
return { units: parsed.units, route_not_proven: parsed.notProven };
|
|
@@ -32322,15 +32360,15 @@ async function planRoute(runDir, provider, env = process.env, repoDir = "") {
|
|
|
32322
32360
|
record: (o) => {
|
|
32323
32361
|
if (!routed)
|
|
32324
32362
|
return null;
|
|
32325
|
-
const parsed = o.skipReason ? { units: [], notProven: [] } : parse3();
|
|
32326
|
-
const rec2 = buildRouteRecord({ units: parsed.units, notProven: parsed.notProven, planModel: o.planModel, planModelNote: o.planModelNote ?? null, shapeKey: shapeKey2, skipReason: o.skipReason });
|
|
32363
|
+
const parsed = o.skipReason || preset ? { units: [], notProven: [] } : parse3();
|
|
32364
|
+
const rec2 = buildRouteRecord({ units: parsed.units, notProven: parsed.notProven, planModel: o.planModel, planModelNote: o.planModelNote ?? null, shapeKey: shapeKey2, skipReason: o.skipReason, ...preset ? { preset: presetExecutor(env) } : {} });
|
|
32327
32365
|
writeRouteRecord(runDir, rec2);
|
|
32328
32366
|
return rec2;
|
|
32329
32367
|
}
|
|
32330
32368
|
};
|
|
32331
32369
|
return out2;
|
|
32332
32370
|
}
|
|
32333
|
-
var ROUTER_UNITS_INSTRUCTION = 'In the same JSON file (<scope>) also add "units": [{"id":"<unit id>","kind":"<short kind>","executor":"sonnet"|"haiku","reason":"<=200 chars"}], one entry per work unit of your plan. The default executor is sonnet. Assign haiku to a unit only when you judge it safe for that unit and say why in reason. Give the Wall acceptance-test unit the id "wall".', planFallbackModel = (runModel) => {
|
|
32371
|
+
var ROUTER_UNITS_INSTRUCTION = 'In the same JSON file (<scope>) also add "units": [{"id":"<unit id>","kind":"<short kind>","executor":"sonnet"|"haiku","reason":"<=200 chars"}], one entry per work unit of your plan. The default executor is sonnet. Assign haiku to a unit only when you judge it safe for that unit and say why in reason. Give the Wall acceptance-test unit the id "wall".', PRESET_PLAN_INSTRUCTION = "A smaller model will implement your plan without re-deriving it. In those lines name the exact files and functions to change, the steps, the pitfalls (edge cases the task implies, behaviour that must not change) and the test to add or run that proves the fix.", planFallbackModel = (runModel) => {
|
|
32334
32372
|
const floor = runModel ? runFloor(runModel) : "sonnet";
|
|
32335
32373
|
const r = modelRank(clampToMaxTier(floor));
|
|
32336
32374
|
return r > modelRank("sonnet") && modelRank(floor) < modelRank("unknown-id") ? floor : "sonnet";
|
|
@@ -32423,11 +32461,12 @@ var init_plan = __esm(() => {
|
|
|
32423
32461
|
const sz = sizeTask(task, loaded, testMap);
|
|
32424
32462
|
const mode = planMode();
|
|
32425
32463
|
const pr = await planRoute(ctx.runDir, ctx.provider, process.env, ctx.repoDir);
|
|
32426
|
-
const
|
|
32464
|
+
const hard = pr.preset ? hardReason(sz.size, loaded, task) : null, routedPlan = pr.routed && (!pr.preset || hard !== null);
|
|
32465
|
+
const skip = mode === "never" || mode === "auto" && sz.size !== "large" && !routedPlan && !keepsPlanForConsentOrCap(process.env, process.stderr.isTTY === true, sz.size, () => namedFiles(task, loaded).length, () => loadProjectApi(ctx.repoDir)?.packages().length ?? 0);
|
|
32427
32466
|
const path = mode === "always" ? "wall" : smallTaskPath(sz.size, hasRelevantTests(task, loaded, testMap, ctx.tests.impacted));
|
|
32428
32467
|
ctx.emit("variant", null, { size: sz.size, reasons: sz.reasons, plan_mode: mode, plan_skipped: skip, wall_model: wallEnabled() ? wallFirstModel(sz.size) : null, wall_model_reauthor: wallEnabled() ? wallModel() : null, small_task_path: path, cascade: cascadeEnabled() });
|
|
32429
32468
|
if (skip)
|
|
32430
|
-
pr.record({ planModel: "none", skipReason: "plan stage skipped (LOKI_E10_PLAN=0)" });
|
|
32469
|
+
pr.record({ planModel: "none", skipReason: mode === "never" || !pr.preset ? "plan stage skipped (LOKI_E10_PLAN=0)" : `no plan session: task sized ${sz.size} and not hard` });
|
|
32431
32470
|
if (skip && mode === "auto")
|
|
32432
32471
|
seedPlanScope(ctx.runDir, namedFiles(task, loaded));
|
|
32433
32472
|
if (skip)
|
|
@@ -32438,7 +32477,9 @@ var init_plan = __esm(() => {
|
|
|
32438
32477
|
const cardOn = intentCardEnabled(process.env);
|
|
32439
32478
|
const runPlan = (onSonnet) => ctx.sessions.run({
|
|
32440
32479
|
stage: "plan",
|
|
32441
|
-
brief: buildPlanBrief(task, relevantFiles, outputPath, join102(ctx.runDir, PLAN_SCOPE_FILE), pr.routed, cardOn, mutationStrict(), reviewerBriefEnabled(), prior.intake?.assumptions)
|
|
32480
|
+
brief: buildPlanBrief(task, relevantFiles, outputPath, join102(ctx.runDir, PLAN_SCOPE_FILE), pr.routed && !pr.preset, cardOn, mutationStrict(), reviewerBriefEnabled(), prior.intake?.assumptions) + (pr.preset ? `
|
|
32481
|
+
|
|
32482
|
+
${PRESET_PLAN_INSTRUCTION}` : ""),
|
|
32442
32483
|
tier: "fast",
|
|
32443
32484
|
iterationId,
|
|
32444
32485
|
limitS: planStage.limitS,
|
|
@@ -32491,9 +32532,10 @@ function routeStart(ctx, first, plan, size) {
|
|
|
32491
32532
|
ctx.emit("route", "implement", { unit: UNIT, model: rr.model, source: rr.source, reason: rr.reason });
|
|
32492
32533
|
return { current: rr.model, escalations: [] };
|
|
32493
32534
|
}
|
|
32494
|
-
async function routeEscalate(ctx, first, session, rt, ids) {
|
|
32495
|
-
const
|
|
32496
|
-
const
|
|
32535
|
+
async function routeEscalate(ctx, first, session, rt, ids, noDiff = () => false) {
|
|
32536
|
+
const claim = !session.killed && session.markers.alreadyDone !== null && routerPreset() && noDiff();
|
|
32537
|
+
const trig = session.killed ? "limit_kill" : session.markers.escalate ? "escalate_marker" : session.markers.specConflict ? "spec_conflict" : claim ? "already_done_claim" : null;
|
|
32538
|
+
const esc4 = trig ? climb(UNIT, rt.current, trig, session.markers.escalate ?? session.markers.specConflict ?? (claim ? `already-done claim with no diff: ${session.markers.alreadyDone}` : "implement session limit kill")) : null;
|
|
32497
32539
|
if (!esc4)
|
|
32498
32540
|
return session;
|
|
32499
32541
|
rt.escalations.push(esc4);
|
|
@@ -32675,7 +32717,7 @@ var init_implement = __esm(() => {
|
|
|
32675
32717
|
const impacted = impactedTests(ctx);
|
|
32676
32718
|
const readOnly = prior.wall?.readOnlyFiles ?? [];
|
|
32677
32719
|
const routed = routerActive();
|
|
32678
|
-
const downgrade = routed ? null : cascadeDowngrade(ctx.model)
|
|
32720
|
+
const downgrade = routed ? null : cascadeDowngrade(ctx.model);
|
|
32679
32721
|
const cascade = downgrade !== null;
|
|
32680
32722
|
if (downgrade)
|
|
32681
32723
|
process.stderr.write(`${downgrade.note}
|
|
@@ -32726,7 +32768,7 @@ var init_implement = __esm(() => {
|
|
|
32726
32768
|
session = await ctx.sessions.run({ ...unchained(), iterationId: retry });
|
|
32727
32769
|
}
|
|
32728
32770
|
if (rt && !signal.aborted)
|
|
32729
|
-
session = await routeEscalate(ctx, first, session, rt, ids);
|
|
32771
|
+
session = await routeEscalate(ctx, first, session, rt, ids, () => treeIsEmpty(ctx));
|
|
32730
32772
|
if (session.markers.specConflict && !session.killed) {
|
|
32731
32773
|
const r = await resumeAfterConflict(ctx, { ...unchained(), iterationId: ids[ids.length - 1] }, session);
|
|
32732
32774
|
session = r.session;
|
|
@@ -32819,6 +32861,13 @@ function defaultLoader(dir) {
|
|
|
32819
32861
|
return mod ? mod.stage ?? mod.default ?? null : null;
|
|
32820
32862
|
};
|
|
32821
32863
|
}
|
|
32864
|
+
function stillFailing(groups, kept) {
|
|
32865
|
+
const g2 = Array.isArray(groups) ? groups : [], green = (Array.isArray(kept) ? kept : []).filter((c) => c?.result === "pass" || c?.result === "flaky").map((c) => String(c.name));
|
|
32866
|
+
return g2.filter((x) => {
|
|
32867
|
+
const s = String(x?.signature ?? "");
|
|
32868
|
+
return !green.some((n3) => s === n3 || s.startsWith(`${n3} `));
|
|
32869
|
+
});
|
|
32870
|
+
}
|
|
32822
32871
|
function softCapS(capS) {
|
|
32823
32872
|
const plain = capS * 14 / 15, budget = backstopS(capS) - ((STAGE_BUDGETS.commit.targetS ?? 0) + (STAGE_BUDGETS.seal.targetS ?? 0) + KILL_GRACE_MS3 / 1000 + 2);
|
|
32824
32873
|
return Math.max(0, Math.min(plain, budget));
|
|
@@ -32879,6 +32928,7 @@ ${timeBudgetNote(limitS)}`;
|
|
|
32879
32928
|
};
|
|
32880
32929
|
let implementBudgetS = 0;
|
|
32881
32930
|
const implementLimitS = (floorS) => Math.max(floorS, Math.floor(softCapS(ctx.capS) - elapsedS2() - (STAGE_BUDGETS.verify.limitS ?? 0)));
|
|
32931
|
+
const fixLimitS = (baseS) => Math.max(baseS, Math.min(2 * baseS, Math.round(baseS * ctx.capS / DEFAULT_CAP_S)));
|
|
32882
32932
|
const verifyLimitS = (floorS) => Math.max(floorS, Math.floor(softCapS(ctx.capS) - elapsedS2() - VERIFY_RESERVE_S));
|
|
32883
32933
|
const runStage = async (name, underCap) => {
|
|
32884
32934
|
const st = await load(name);
|
|
@@ -32890,7 +32940,7 @@ ${timeBudgetNote(limitS)}`;
|
|
|
32890
32940
|
markCap(name);
|
|
32891
32941
|
return null;
|
|
32892
32942
|
}
|
|
32893
|
-
const limitS = name === "implement" ? ctx.deep ? DEEP_IMPLEMENT_LIMIT_S : st.limitS >= STAGE_BUDGETS.implement.limitS ? implementLimitS(st.limitS) : st.limitS : (name === "verify" && st.limitS >= STAGE_BUDGETS.verify.limitS ? verifyLimitS(st.limitS) : st.limitS) + (st.extraLimitS?.(sctx) ?? 0);
|
|
32943
|
+
const limitS = name === "implement" ? ctx.deep ? DEEP_IMPLEMENT_LIMIT_S : st.limitS >= STAGE_BUDGETS.implement.limitS ? implementLimitS(st.limitS) : st.limitS : (name === "verify" && st.limitS >= STAGE_BUDGETS.verify.limitS ? verifyLimitS(st.limitS) : name === "fix" ? fixLimitS(st.limitS) : st.limitS) + (st.extraLimitS?.(sctx) ?? 0);
|
|
32894
32944
|
if (name === "implement") {
|
|
32895
32945
|
implementBudgetS = limitS;
|
|
32896
32946
|
implementStartMs = ctx.clock.now();
|
|
@@ -32949,7 +32999,7 @@ ${timeBudgetNote(limitS)}`;
|
|
|
32949
32999
|
const kept = name === "verify" ? settled?.status === "completed" ? settled.data : partials.verify : undefined;
|
|
32950
33000
|
if (kept) {
|
|
32951
33001
|
const prev = outputs.verify;
|
|
32952
|
-
outputs.verify = { ...kept, failures_grouped: prev?.failures_grouped
|
|
33002
|
+
outputs.verify = { ...kept, failures_grouped: stillFailing(prev?.failures_grouped, kept.checks), holdout_failed: prev?.holdout_failed ?? 0, not_proven: [...Array.isArray(kept.not_proven) ? kept.not_proven : [], VERIFY_STOPPED_NOTE[why]], stopped_at: why, duration_s: dur() };
|
|
32953
33003
|
}
|
|
32954
33004
|
if (name === "implement" && why === "limit") {
|
|
32955
33005
|
const ro = outputs.wall?.readOnlyFiles ?? [], reverted = [...restoreReadOnly(ro).map((f) => relative24(ctx.repoDir, f)), ...restoreBaseTests(ctx.repoDir, ctx.baseSha, outputs.intake)];
|
|
@@ -33149,6 +33199,7 @@ ${timeBudgetNote(limitS)}`;
|
|
|
33149
33199
|
let extraRounds = 0;
|
|
33150
33200
|
let noopSig = null;
|
|
33151
33201
|
for (let round2 = 1;round2 <= MAX_FIX_ROUNDS + extraRounds && hasFailures(outputs.verify) && outputs.implement?.exit !== "spec_conflict" && outputs.implement?.exit !== "external"; round2++) {
|
|
33202
|
+
const wallBefore = wallSignature(outputs, ctx.repoDir);
|
|
33152
33203
|
const fx = await runStage("fix", true);
|
|
33153
33204
|
if (!fx || mustJump("fix", fx) || fatal)
|
|
33154
33205
|
break;
|
|
@@ -33169,6 +33220,8 @@ ${timeBudgetNote(limitS)}`;
|
|
|
33169
33220
|
sigs.push(sigOf(outputs.verify, v));
|
|
33170
33221
|
if (mustJump("verify", v))
|
|
33171
33222
|
break;
|
|
33223
|
+
if (wallOnlyAfterFix(outputs, ctx.repoDir) && wallSignature(outputs, ctx.repoDir) === wallBefore)
|
|
33224
|
+
break;
|
|
33172
33225
|
if (hasFailures(outputs.verify) && sigs.length >= 2 && sigs.slice(-2).every((x) => x === sigs[sigs.length - 1])) {
|
|
33173
33226
|
const up = stallClimb(ctx.model, outputs, sigs[sigs.length - 1] ?? "");
|
|
33174
33227
|
if (up) {
|
|
@@ -33181,7 +33234,8 @@ ${timeBudgetNote(limitS)}`;
|
|
|
33181
33234
|
break;
|
|
33182
33235
|
}
|
|
33183
33236
|
}
|
|
33184
|
-
|
|
33237
|
+
const wasConflict = outputs.implement?.exit === "spec_conflict";
|
|
33238
|
+
if (!fatal && !capHit && stopped === null && await deliverOverWallConflict(outputs, ctx.repoDir, () => runStage("verify", true), (path, why) => ctx.emit("wall.arbitrated", "wall", { path, discarded: why }), { runDir: ctx.runDir, restored: (v) => ctx.emit("stage.completed", "verify", { ...v, restored: true }) }) && wasConflict)
|
|
33185
33239
|
ctx.emit("spec.conflict", "implement", { delivered: true, reason: outputs.implement?.spec_conflict_reason ?? null });
|
|
33186
33240
|
if (fatal) {
|
|
33187
33241
|
stopped = fatal;
|
|
@@ -38820,16 +38874,17 @@ function parseDecomposition(text4) {
|
|
|
38820
38874
|
seen.add(o.id);
|
|
38821
38875
|
if (typeof o.title !== "string" || !o.title.trim() || o.title.length > 200)
|
|
38822
38876
|
return { ok: false, reason: `${o.id}: title must be a non-empty string of at most 200 characters` };
|
|
38823
|
-
const acceptance2 = strList(o.acceptance, 20);
|
|
38877
|
+
const acceptance2 = strList(o.acceptance, 20, true);
|
|
38824
38878
|
if (!acceptance2 || acceptance2.length === 0)
|
|
38825
|
-
return { ok: false, reason: `${o.id}: acceptance must be
|
|
38826
|
-
const deps = o.depends_on === undefined ? [] : strList(o.depends_on,
|
|
38879
|
+
return { ok: false, reason: `${o.id}: acceptance must be a list holding at least one non-empty string` };
|
|
38880
|
+
const deps = o.depends_on === undefined ? [] : strList(o.depends_on, Infinity);
|
|
38827
38881
|
if (!deps)
|
|
38828
38882
|
return { ok: false, reason: `${o.id}: depends_on must be a list of slice ids` };
|
|
38829
38883
|
const files = o.files === undefined ? [] : strList(o.files, 50);
|
|
38830
38884
|
if (!files)
|
|
38831
38885
|
return { ok: false, reason: `${o.id}: files must be a list of paths` };
|
|
38832
|
-
|
|
38886
|
+
const listed = Array.isArray(o.files) ? new Set(o.files.filter((x) => typeof x === "string").map(oneLine3).filter((x) => x !== "")).size : 0, dropped2 = listed - files.length;
|
|
38887
|
+
slices.push({ id: o.id, title: oneLine3(o.title), acceptance: acceptance2, depends_on: [...new Set(deps)], files, ...dropped2 > 0 ? { files_dropped: dropped2 } : {} });
|
|
38833
38888
|
}
|
|
38834
38889
|
for (const s of slices)
|
|
38835
38890
|
for (const d of s.depends_on)
|
|
@@ -38896,6 +38951,7 @@ function sliceTask(slug, epic, s, index2, total, parent) {
|
|
|
38896
38951
|
`This is slice ${index2 + 1} of a larger issue that was split into ${total} pull requests. Implement only this slice.` + (parent ? ` The branch already contains slice ${parent} and everything it depends on.` : ""),
|
|
38897
38952
|
`Acceptance criteria: ${s.acceptance.map((a, k) => `(${k + 1}) ${a}`).join("; ")}`,
|
|
38898
38953
|
s.files.length ? `Likely files: ${s.files.join(", ")}` : "",
|
|
38954
|
+
s.files_dropped ? `${s.files_dropped} more ${s.files_dropped === 1 ? "path was" : "paths were"} listed for this slice and dropped (past the 50-path cap, or too long to be a path); find the rest from the criteria.` : "",
|
|
38899
38955
|
`Parent issue: ${oneLine3(epic.title)}`
|
|
38900
38956
|
].filter(Boolean).join(`
|
|
38901
38957
|
|
|
@@ -39017,7 +39073,14 @@ function epicOutcome(rows, planUsd = [], env = process.env) {
|
|
|
39017
39073
|
`)}
|
|
39018
39074
|
` };
|
|
39019
39075
|
}
|
|
39020
|
-
var ID_RE2, MIN_SLICES = 2, MAX_SLICES = 4, oneLine3 = (s) => s.replace(/[\x00-\x1f\x7f]+/g, " ").replace(/\s+/g, " ").trim(),
|
|
39076
|
+
var ID_RE2, MIN_SLICES = 2, MAX_SLICES = 4, oneLine3 = (s) => s.replace(/[\x00-\x1f\x7f]+/g, " ").replace(/\s+/g, " ").trim(), PATH_MAX = 500, strList = (v, max, merge = false) => {
|
|
39077
|
+
if (!Array.isArray(v))
|
|
39078
|
+
return null;
|
|
39079
|
+
const items2 = [...new Set(v.filter((x) => typeof x === "string").map(oneLine3).filter((x) => x !== "" && (merge || x.length <= PATH_MAX)))];
|
|
39080
|
+
if (merge && items2.length > max)
|
|
39081
|
+
items2.splice(max - 1, items2.length, items2.slice(max - 1).join("; "));
|
|
39082
|
+
return items2.slice(0, max);
|
|
39083
|
+
}, overCapNote = (got) => `Your previous split had ${got} slices but the limit is ${MAX_SLICES}. Merge related slices so the plan has at most ${MAX_SLICES}, and write the corrected JSON object to the file.`, invalidSplitNote = (reason) => `Your previous split was refused: ${oneLine3(reason)}. Fix that and write the corrected JSON object to the file, in the same form.`, stacksOn = (r, needPr = true) => !!r && (!needPr || !!r.pr) && !!r.branch && !/^(FAILED|BLOCKED|SKIPPED)/.test(r.outcome), progressLine = (n3, p) => `#${n3} epic: ${p.done}/${p.total} slices done, ${p.running} running, ${p.waiting} waiting`;
|
|
39021
39084
|
var init_issues_epic = __esm(() => {
|
|
39022
39085
|
init_output();
|
|
39023
39086
|
ID_RE2 = /^[A-Za-z0-9_-]{1,32}$/;
|
|
@@ -39029,6 +39092,7 @@ __export(exports_issues_run, {
|
|
|
39029
39092
|
wholeRunTooLarge: () => wholeRunTooLarge,
|
|
39030
39093
|
triageBrief: () => triageBrief,
|
|
39031
39094
|
startIssueEpic: () => startIssueEpic,
|
|
39095
|
+
splitWithReask: () => splitWithReask,
|
|
39032
39096
|
runIssues: () => runIssues,
|
|
39033
39097
|
renderIssuesDigest: () => renderIssuesDigest,
|
|
39034
39098
|
parseTriage: () => parseTriage,
|
|
@@ -39378,10 +39442,11 @@ digest: ${join117(runDir, "digest.md")}
|
|
|
39378
39442
|
async function splitWithReask(d, slug, i, reason) {
|
|
39379
39443
|
try {
|
|
39380
39444
|
let p = parseDecomposition(await d.decompose(slug, i, reason));
|
|
39381
|
-
if (!p.ok
|
|
39382
|
-
d.out(`#${i.number} split had ${p.over} slices, over the cap; asking once more
|
|
39445
|
+
if (!p.ok) {
|
|
39446
|
+
d.out(p.over !== undefined ? `#${i.number} split had ${p.over} slices, over the cap; asking once more
|
|
39447
|
+
` : `#${i.number} split refused (${clip6(p.reason, 160)}); asking once more
|
|
39383
39448
|
`);
|
|
39384
|
-
p = parseDecomposition(await d.decompose(slug, i, reason, overCapNote(p.over)));
|
|
39449
|
+
p = parseDecomposition(await d.decompose(slug, i, reason, p.over !== undefined ? overCapNote(p.over) : invalidSplitNote(p.reason)));
|
|
39385
39450
|
}
|
|
39386
39451
|
return p;
|
|
39387
39452
|
} catch (e) {
|
|
@@ -46408,6 +46473,7 @@ __export(exports_base_guard, {
|
|
|
46408
46473
|
stackedOnLokiRun: () => stackedOnLokiRun,
|
|
46409
46474
|
splitDeclaredAdvisories: () => splitDeclaredAdvisories,
|
|
46410
46475
|
resolveBase: () => resolveBase,
|
|
46476
|
+
removeOwnWallFiles: () => removeOwnWallFiles,
|
|
46411
46477
|
noteOf: () => noteOf,
|
|
46412
46478
|
lazyZeroBaseline: () => lazyZeroBaseline,
|
|
46413
46479
|
keepRunBranch: () => keepRunBranch,
|
|
@@ -46417,9 +46483,11 @@ __export(exports_base_guard, {
|
|
|
46417
46483
|
envChangedSince: () => envChangedSince,
|
|
46418
46484
|
depsSeeHead: () => depsSeeHead,
|
|
46419
46485
|
baseLine: () => baseLine,
|
|
46486
|
+
baseDepsLinker: () => baseDepsLinker,
|
|
46420
46487
|
addedSymlinkNotes: () => addedSymlinkNotes
|
|
46421
46488
|
});
|
|
46422
46489
|
import { execFileSync as execFileSync9 } from "child_process";
|
|
46490
|
+
import { createHash as createHash39 } from "crypto";
|
|
46423
46491
|
import { existsSync as existsSync98, mkdirSync as mkdirSync73, mkdtempSync as mkdtempSync19, readdirSync as readdirSync44, readFileSync as readFileSync124, readlinkSync as readlinkSync7, realpathSync as realpathSync34, rmSync as rmSync37, statSync as statSync40, symlinkSync as symlinkSync4, utimesSync, writeFileSync as writeFileSync71 } from "fs";
|
|
46424
46492
|
import { tmpdir as tmpdir25 } from "os";
|
|
46425
46493
|
import { basename as basename36, dirname as dirname54, join as join143, relative as relative28, resolve as resolve38, sep as sep23 } from "path";
|
|
@@ -46510,7 +46578,8 @@ function baseLine(repoDir) {
|
|
|
46510
46578
|
const t = resolveBase(repoDir, undefined, false);
|
|
46511
46579
|
const sk = stackedOnLokiRun(repoDir, t);
|
|
46512
46580
|
const b = git13(repoDir, ["symbolic-ref", "-q", "--short", "HEAD"]) ?? "detached HEAD";
|
|
46513
|
-
|
|
46581
|
+
const same = !sk && t && /^loki\//.test(b) && git13(repoDir, ["rev-parse", "-q", "--verify", "HEAD^{commit}"]) === git13(repoDir, ["rev-parse", "-q", "--verify", `${t.ref}^{commit}`]);
|
|
46582
|
+
return `PR target: ${t ? t.ref : "unresolved"}, base: ${sk ? `${sk.target} (${sk.message})` : same ? t.ref : b}`;
|
|
46514
46583
|
}
|
|
46515
46584
|
function noteOf(intake) {
|
|
46516
46585
|
const m = intake?.["unmerged_loki_work"]?.message ?? intake?.["stacked_loki_skip"]?.message;
|
|
@@ -46626,22 +46695,10 @@ function envChangedSince(repoDir, pkgDir, sinceMs, ignored) {
|
|
|
46626
46695
|
}
|
|
46627
46696
|
}
|
|
46628
46697
|
async function zeroOnBase(cands, baseDir, repoDir, run2, note, gate = {}) {
|
|
46629
|
-
const zero = [],
|
|
46630
|
-
const moved = (src) => {
|
|
46631
|
-
if (!envMoved.has(src))
|
|
46632
|
-
envMoved.set(src, envChangedSince(repoDir, src, gate.sinceMs, gate.ignored ?? null));
|
|
46633
|
-
return envMoved.get(src);
|
|
46634
|
-
};
|
|
46698
|
+
const zero = [], link = baseDepsLinker(baseDir, repoDir, gate);
|
|
46635
46699
|
for (const c of cands) {
|
|
46636
|
-
|
|
46637
|
-
if (depsSeeHead(src, repoDir) || gate.sinceMs !== undefined && moved(src))
|
|
46700
|
+
if (!link(c.cwd))
|
|
46638
46701
|
continue;
|
|
46639
|
-
for (const d of ["node_modules", ".venv"]) {
|
|
46640
|
-
try {
|
|
46641
|
-
if (existsSync98(join143(src, d)) && !existsSync98(join143(c.cwd, d)))
|
|
46642
|
-
symlinkSync4(join143(src, d), join143(c.cwd, d));
|
|
46643
|
-
} catch {}
|
|
46644
|
-
}
|
|
46645
46702
|
if (isZeroRun(c, await run2(c))) {
|
|
46646
46703
|
zero.push(c.name);
|
|
46647
46704
|
note(c.name);
|
|
@@ -46649,6 +46706,23 @@ async function zeroOnBase(cands, baseDir, repoDir, run2, note, gate = {}) {
|
|
|
46649
46706
|
}
|
|
46650
46707
|
return zero;
|
|
46651
46708
|
}
|
|
46709
|
+
function baseDepsLinker(baseDir, repoDir, gate = {}) {
|
|
46710
|
+
const seen = new Map;
|
|
46711
|
+
return (cwd) => {
|
|
46712
|
+
const src = join143(repoDir, relative28(baseDir, cwd));
|
|
46713
|
+
if (!seen.has(src))
|
|
46714
|
+
seen.set(src, !(depsSeeHead(src, repoDir) || gate.sinceMs !== undefined && envChangedSince(repoDir, src, gate.sinceMs, gate.ignored ?? null)));
|
|
46715
|
+
if (!seen.get(src))
|
|
46716
|
+
return false;
|
|
46717
|
+
for (const d of ["node_modules", ".venv"]) {
|
|
46718
|
+
try {
|
|
46719
|
+
if (existsSync98(join143(src, d)) && !existsSync98(join143(cwd, d)))
|
|
46720
|
+
symlinkSync4(join143(src, d), join143(cwd, d));
|
|
46721
|
+
} catch {}
|
|
46722
|
+
}
|
|
46723
|
+
return true;
|
|
46724
|
+
};
|
|
46725
|
+
}
|
|
46652
46726
|
function isZeroRun(c, b) {
|
|
46653
46727
|
const last = c.args[c.args.length - 1] ?? "";
|
|
46654
46728
|
const k = classifyCheck({ kind: "test", ok: b.ok, cut: b.cut, missing: b.missing, out: b.out, ...goRunner(c.cmd, c.args), path: /\.[cm]?[jt]s$/.test(last) ? last : undefined });
|
|
@@ -46765,12 +46839,43 @@ function returnCheckout(repoDir, branch, orig) {
|
|
|
46765
46839
|
if (!orig || orig === branch)
|
|
46766
46840
|
return `engine10: the checkout stays on ${branch}: the run did not record the branch it started from
|
|
46767
46841
|
`;
|
|
46768
|
-
|
|
46842
|
+
let dirty;
|
|
46843
|
+
try {
|
|
46844
|
+
dirty = safeGit(repoDir, ["status", "--porcelain", "-z", "--untracked-files=no", "--no-renames"], { timeout: 20000 });
|
|
46845
|
+
} catch {
|
|
46846
|
+
dirty = null;
|
|
46847
|
+
}
|
|
46848
|
+
if (dirty === null || dirty.split("\x00").filter(Boolean).some((l) => !l.slice(3).startsWith(".loki/")))
|
|
46769
46849
|
return `engine10: the checkout stays on ${branch}: it has uncommitted changes; return with: git checkout ${orig}
|
|
46770
46850
|
`;
|
|
46771
46851
|
return git13(repoDir, ["checkout", "-q", orig]) === null ? `engine10: the checkout stays on ${branch}: git checkout ${orig} failed; return with: git checkout ${orig}
|
|
46772
46852
|
` : null;
|
|
46773
46853
|
}
|
|
46854
|
+
function removeOwnWallFiles(repoDir, runId2) {
|
|
46855
|
+
let files = [];
|
|
46856
|
+
try {
|
|
46857
|
+
files = JSON.parse(readFileSync124(join143(repoDir, ".loki", "runs", runId2, "receipt.json"), "utf8")).wall?.files ?? [];
|
|
46858
|
+
} catch {
|
|
46859
|
+
return [];
|
|
46860
|
+
}
|
|
46861
|
+
const gone = [];
|
|
46862
|
+
for (const f of files) {
|
|
46863
|
+
if (typeof f.path !== "string" || typeof f.sha256 !== "string")
|
|
46864
|
+
continue;
|
|
46865
|
+
const abs = resolve38(repoDir, f.path), rel = relative28(repoDir, abs);
|
|
46866
|
+
if (rel.startsWith("..") || rel.startsWith(".loki/") || !basename36(rel).startsWith("loki_wall_"))
|
|
46867
|
+
continue;
|
|
46868
|
+
if (git13(repoDir, ["ls-files", "--error-unmatch", "--", rel]) !== null)
|
|
46869
|
+
continue;
|
|
46870
|
+
try {
|
|
46871
|
+
if (createHash39("sha256").update(readFileSync124(abs)).digest("hex") !== f.sha256)
|
|
46872
|
+
continue;
|
|
46873
|
+
rmSync37(abs);
|
|
46874
|
+
gone.push(rel);
|
|
46875
|
+
} catch {}
|
|
46876
|
+
}
|
|
46877
|
+
return gone;
|
|
46878
|
+
}
|
|
46774
46879
|
function workLine(repoDir, branch, orig) {
|
|
46775
46880
|
if (!tipOf(repoDir, `refs/heads/${branch}`) || currentBranch(repoDir) === branch)
|
|
46776
46881
|
return "";
|
|
@@ -46792,6 +46897,10 @@ function finishRunBranch(repoDir, runId2, end, env = process.env) {
|
|
|
46792
46897
|
removeRunWorktrees(repoDir, end.baseSha);
|
|
46793
46898
|
migrateSessionFiles(repoDir, runLive);
|
|
46794
46899
|
let notes = "";
|
|
46900
|
+
const wallGone = removeOwnWallFiles(repoDir, runId2);
|
|
46901
|
+
if (wallGone.length)
|
|
46902
|
+
notes += `engine10: removed Loki's own acceptance test ${wallGone.join(", ")} from your tree; its sealed copy is under .loki/runs/${runId2}/wall/
|
|
46903
|
+
`;
|
|
46795
46904
|
const keepHere = end.keepWork === true && tip !== null && tipOf(repoDir, end.baseSha ?? "") !== tip;
|
|
46796
46905
|
const stay = tip ? returnCheckout(repoDir, branch, end.orig) : null;
|
|
46797
46906
|
if (stay)
|
|
@@ -46890,25 +46999,31 @@ var exports_verify = {};
|
|
|
46890
46999
|
__export(exports_verify, {
|
|
46891
47000
|
writeWallFailureTail: () => writeWallFailureTail,
|
|
46892
47001
|
wallTailOf: () => wallTailOf,
|
|
47002
|
+
vitestFileText: () => vitestFileText,
|
|
47003
|
+
vitestBatch: () => vitestBatch,
|
|
46893
47004
|
verifyStage: () => verifyStage,
|
|
47005
|
+
verifyBatchOn: () => verifyBatchOn,
|
|
46894
47006
|
testConfigChanged: () => testConfigChanged,
|
|
46895
47007
|
testCheckName: () => testCheckName,
|
|
46896
47008
|
stage: () => stage9,
|
|
46897
47009
|
skipped: () => skipped,
|
|
47010
|
+
sameErrors: () => sameErrors,
|
|
46898
47011
|
runnerCmd: () => runnerCmd,
|
|
46899
47012
|
runOnce: () => runOnce3,
|
|
46900
47013
|
runLintChecks: () => runLintChecks,
|
|
46901
47014
|
runCheck: () => runCheck,
|
|
46902
47015
|
ran: () => ran,
|
|
46903
47016
|
firstError: () => firstError,
|
|
47017
|
+
feedsFixRound: () => feedsFixRound,
|
|
47018
|
+
errorsById: () => errorsById,
|
|
46904
47019
|
commandFor: () => commandFor,
|
|
46905
47020
|
changedFiles: () => changedFiles,
|
|
46906
47021
|
WALL_FAILURE_TAIL_FILE: () => WALL_FAILURE_TAIL_FILE,
|
|
46907
47022
|
WALL_FAILURE_TAIL_CAP: () => WALL_FAILURE_TAIL_CAP
|
|
46908
47023
|
});
|
|
46909
|
-
import { existsSync as existsSync99, mkdtempSync as mkdtempSync20, readFileSync as readFileSync125, rmSync as rmSync38 } from "fs";
|
|
47024
|
+
import { existsSync as existsSync99, mkdtempSync as mkdtempSync20, readFileSync as readFileSync125, realpathSync as realpathSync35, rmSync as rmSync38 } from "fs";
|
|
46910
47025
|
import { tmpdir as tmpdir26 } from "os";
|
|
46911
|
-
import { basename as basename37, isAbsolute as isAbsolute21, join as join144, relative as relative29 } from "path";
|
|
47026
|
+
import { basename as basename37, isAbsolute as isAbsolute21, join as join144, relative as relative29, resolve as resolve39 } from "path";
|
|
46912
47027
|
function writeWallFailureTail(runDir, failed2) {
|
|
46913
47028
|
const file = join144(runDir, WALL_FAILURE_TAIL_FILE);
|
|
46914
47029
|
try {
|
|
@@ -47001,6 +47116,7 @@ async function runCheck(ctx, name, cmd2, args, signal, checks, opts = {}) {
|
|
|
47001
47116
|
if (result === "fail" && !opts.opaque && !isHold(check)) {
|
|
47002
47117
|
excerpts.set(check, failureExcerpt(attempt.out, ctx.repoDir));
|
|
47003
47118
|
failTails.set(check, wallTailOf(attempt.out, ctx.repoDir));
|
|
47119
|
+
headErrors.set(check, errorsById(attempt.out));
|
|
47004
47120
|
}
|
|
47005
47121
|
checks.push(check);
|
|
47006
47122
|
if (opts.opaque && check.result !== "pass" && check.reason)
|
|
@@ -47008,8 +47124,154 @@ async function runCheck(ctx, name, cmd2, args, signal, checks, opts = {}) {
|
|
|
47008
47124
|
ctx.emit("test.result", "verify", opts.opaque ? { ...pubHold(check) } : { ...check });
|
|
47009
47125
|
return check;
|
|
47010
47126
|
}
|
|
47127
|
+
function vitestFileText(rel, asserts) {
|
|
47128
|
+
const st = (a) => String(a.status ?? ""), path = (a) => [...Array.isArray(a.ancestorTitles) ? a.ancestorTitles.map(String) : [], String(a.title ?? "")].join(" > ");
|
|
47129
|
+
const failed2 = asserts.filter((a) => st(a) === "failed"), passed = asserts.filter((a) => st(a) === "passed").length, skippedN = asserts.length - failed2.length - passed;
|
|
47130
|
+
const lines2 = [` ${failed2.length ? "\u276F" : "\u2713"} ${rel} (${asserts.length} tests${failed2.length ? ` | ${failed2.length} failed` : ""}${skippedN ? ` | ${skippedN} skipped` : ""}) 0ms`];
|
|
47131
|
+
for (const a of asserts)
|
|
47132
|
+
if (st(a) === "passed" || st(a) === "failed")
|
|
47133
|
+
lines2.push(` ${st(a) === "failed" ? "\xD7" : "\u2713"} ${String(a.title ?? "")} 0ms`);
|
|
47134
|
+
lines2.push("");
|
|
47135
|
+
for (const a of failed2)
|
|
47136
|
+
lines2.push(` FAIL ${rel} > ${path(a)}`, ...Array.isArray(a.failureMessages) ? a.failureMessages.map((m) => String(m).slice(0, 4000)) : [], "");
|
|
47137
|
+
const parts2 = [failed2.length ? `${failed2.length} failed` : "", passed ? `${passed} passed` : "", skippedN ? `${skippedN} skipped` : ""].filter(Boolean).join(" | ");
|
|
47138
|
+
lines2.push(` Test Files ${failed2.length ? "1 failed" : "1 passed"} (1)`, ` Tests ${parts2} (${asserts.length})`);
|
|
47139
|
+
return { ok: failed2.length === 0, out: lines2.join(`
|
|
47140
|
+
`) };
|
|
47141
|
+
}
|
|
47142
|
+
async function vitestBatch(cwd, rels, signal, opts = {}) {
|
|
47143
|
+
const dir = mkdtempSync20(join144(tmpdir26(), "loki-vbatch-")), file = join144(dir, "report.json");
|
|
47144
|
+
try {
|
|
47145
|
+
const r = await runOnce3("npx", ["--no-install", "vitest", "run", "--reporter=json", "--reporter=default", `--outputFile.json=${file}`, ...rels], cwd, signal, { timeoutMs: opts.timeoutMs ?? batchTimeoutMs(rels.length), group: true, ...opts.path ? { path: opts.path } : {} });
|
|
47146
|
+
if (r.cut || r.missing || !existsSync99(file) || UNHANDLED_RE.test(r.out))
|
|
47147
|
+
return null;
|
|
47148
|
+
const rep = JSON.parse(readFileSync125(file, "utf8"));
|
|
47149
|
+
const tests = rep.testResults ?? [], failedFile = (tr) => tr.status === "failed";
|
|
47150
|
+
if (!r.ok && !tests.some(failedFile))
|
|
47151
|
+
return null;
|
|
47152
|
+
const real3 = (p) => {
|
|
47153
|
+
try {
|
|
47154
|
+
return realpathSync35(p);
|
|
47155
|
+
} catch {
|
|
47156
|
+
return p;
|
|
47157
|
+
}
|
|
47158
|
+
}, byAbs = new Map;
|
|
47159
|
+
for (const rel of rels)
|
|
47160
|
+
for (const p of [resolve39(cwd, rel), real3(resolve39(cwd, rel))])
|
|
47161
|
+
byAbs.set(p, rel);
|
|
47162
|
+
const out2 = new Map;
|
|
47163
|
+
for (const tr of tests) {
|
|
47164
|
+
const rel = byAbs.get(String(tr.name ?? "")), asserts = Array.isArray(tr.assertionResults) ? tr.assertionResults : [], f = rel ? vitestFileText(rel, asserts) : null;
|
|
47165
|
+
if (!rel || !f || asserts.length === 0 || typeof tr.message === "string" && tr.message.trim() !== "")
|
|
47166
|
+
continue;
|
|
47167
|
+
if (f.ok ? tr.status === "passed" : failedFile(tr))
|
|
47168
|
+
out2.set(rel, f);
|
|
47169
|
+
}
|
|
47170
|
+
return out2;
|
|
47171
|
+
} catch {
|
|
47172
|
+
return null;
|
|
47173
|
+
} finally {
|
|
47174
|
+
rmSync38(dir, { recursive: true, force: true });
|
|
47175
|
+
}
|
|
47176
|
+
}
|
|
47177
|
+
async function runVitestBatches(ctx, tests, api, signal, onCheck) {
|
|
47178
|
+
const got = new Map, groups = new Map;
|
|
47179
|
+
for (const t of tests) {
|
|
47180
|
+
const tc = commandFor(t, ctx.repoDir, api);
|
|
47181
|
+
if (vitestFile(t, tc))
|
|
47182
|
+
groups.set(tc.cwd, [...groups.get(tc.cwd) ?? [], { t, tc }]);
|
|
47183
|
+
}
|
|
47184
|
+
for (const [cwd, g2] of groups) {
|
|
47185
|
+
if (g2.length < BATCH_MIN || signal.aborted)
|
|
47186
|
+
continue;
|
|
47187
|
+
const rel = (x) => x.tc.args[x.tc.args.length - 1], t0 = Date.now();
|
|
47188
|
+
const first = await vitestBatch(cwd, g2.map(rel), signal);
|
|
47189
|
+
if (!first)
|
|
47190
|
+
continue;
|
|
47191
|
+
const classify3 = (f) => classifyCheck({ kind: "test", ok: f.ok, cut: false, missing: false, out: f.out });
|
|
47192
|
+
const failing = g2.filter((x) => {
|
|
47193
|
+
const f = first.get(rel(x));
|
|
47194
|
+
return f !== undefined && classify3(f).result === "fail" && classifyRunnerOutput(f.out).kind !== "load_error";
|
|
47195
|
+
});
|
|
47196
|
+
const second = failing.length && !signal.aborted ? await vitestBatch(cwd, failing.map(rel), signal) : null;
|
|
47197
|
+
const share = (Date.now() - t0) / 1000 / g2.length;
|
|
47198
|
+
for (const x of g2) {
|
|
47199
|
+
const a = first.get(rel(x));
|
|
47200
|
+
if (!a)
|
|
47201
|
+
continue;
|
|
47202
|
+
const ca = classify3(a), b = ca.result === "fail" && failing.includes(x) ? second?.get(rel(x)) : undefined, cb = b ? classify3(b) : null;
|
|
47203
|
+
const result = ca.result === "pass" && (ca.n ?? 0) > 0 ? "pass" : cb?.result === "pass" ? "flaky" : cb?.result === "fail" ? "fail" : null;
|
|
47204
|
+
if (!result)
|
|
47205
|
+
continue;
|
|
47206
|
+
const outText = b?.out ?? a.out, anchor = result === "fail" ? firstFileLineAnchor(outText) : null;
|
|
47207
|
+
const check = { name: testCheckName(x.t), cmd: x.tc.argv.join(" "), result, duration_s: share, ...result === "fail" ? { first_error: firstError(outText), ids: failIds(outText), ...anchor ? { anchor } : {} } : result === "pass" ? { n: ca.n ?? 0, sk: skipped(a.out) } : {} };
|
|
47208
|
+
if (result === "fail") {
|
|
47209
|
+
excerpts.set(check, failureExcerpt(outText, ctx.repoDir));
|
|
47210
|
+
failTails.set(check, wallTailOf(outText, ctx.repoDir));
|
|
47211
|
+
headErrors.set(check, errorsById(outText));
|
|
47212
|
+
}
|
|
47213
|
+
got.set(check.name, check);
|
|
47214
|
+
ctx.emit("test.result", "verify", { ...check });
|
|
47215
|
+
onCheck(check);
|
|
47216
|
+
}
|
|
47217
|
+
}
|
|
47218
|
+
return got;
|
|
47219
|
+
}
|
|
47220
|
+
function changedSymbolsFirst(ctx, tests, changed) {
|
|
47221
|
+
const code = changed.filter((f) => CODE_FILE_EXT.test(f) && !isTestFile(f));
|
|
47222
|
+
if (code.length === 0 || tests.length < 2)
|
|
47223
|
+
return tests;
|
|
47224
|
+
let names = [];
|
|
47225
|
+
try {
|
|
47226
|
+
names = changedSymbols(safeGit(ctx.repoDir, ["diff", "-U0", "--no-color", "--no-ext-diff", "--no-textconv", "--no-renames", ctx.baseSha, "--", ...code], { timeout: 20000 })).filter((n3) => n3.length >= 3);
|
|
47227
|
+
} catch {
|
|
47228
|
+
return tests;
|
|
47229
|
+
}
|
|
47230
|
+
if (names.length === 0)
|
|
47231
|
+
return tests;
|
|
47232
|
+
const re = new RegExp(`\\b(?:${names.map((n3) => n3.replace(/[$]/g, "\\$")).join("|")})\\b`);
|
|
47233
|
+
const hits = tests.filter((t) => {
|
|
47234
|
+
try {
|
|
47235
|
+
return re.test(readFileSync125(join144(ctx.repoDir, t.path), "utf8"));
|
|
47236
|
+
} catch {
|
|
47237
|
+
return false;
|
|
47238
|
+
}
|
|
47239
|
+
});
|
|
47240
|
+
return [...hits, ...tests.filter((t) => !hits.includes(t))];
|
|
47241
|
+
}
|
|
47242
|
+
function errorsById(out2) {
|
|
47243
|
+
const norm5 = (l) => l.replace(/\b\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?/g, "<ts>").replace(/\b\d{1,2}:\d{2}:\d{2}(?:\.\d+)?\b/g, "<ts>").replace(/(^|[\s(])\/(?:[\w.@-]+\/)*[\w.@-]+(?::\d+){0,2}/g, "$1<path>").replace(/\b\d+(?:\.\d+)?\s?(?:ms|s|us|\u00B5s|ns|min)\b/g, "<dur>").replace(/\s+/g, " ").trim();
|
|
47244
|
+
const lines2 = stripAnsi(out2).split(`
|
|
47245
|
+
`).map((l) => l.trim()), m = new Map, add3 = (id, e) => {
|
|
47246
|
+
m.set(id, [...m.get(id) ?? [], e]);
|
|
47247
|
+
};
|
|
47248
|
+
for (const [i, l] of lines2.entries()) {
|
|
47249
|
+
const py = /^FAILED (\S+::\S*) - (.+)$/.exec(l);
|
|
47250
|
+
if (py) {
|
|
47251
|
+
add3(py[1], norm5(py[2]));
|
|
47252
|
+
continue;
|
|
47253
|
+
}
|
|
47254
|
+
const v = /^FAIL\s+(.+)$/.exec(l);
|
|
47255
|
+
if (!v)
|
|
47256
|
+
continue;
|
|
47257
|
+
const next = lines2.slice(i + 1).find((x) => x !== "" && !/^FAIL\s/.test(x));
|
|
47258
|
+
if (next !== undefined)
|
|
47259
|
+
add3(v[1].trim(), norm5(next));
|
|
47260
|
+
}
|
|
47261
|
+
for (const [k, e] of m)
|
|
47262
|
+
m.set(k, e.sort());
|
|
47263
|
+
return m;
|
|
47264
|
+
}
|
|
47265
|
+
function sameErrors(head, base2, ids) {
|
|
47266
|
+
const h = typeof head === "string" ? errorsById(head) : head, b = errorsById(base2), all = ids ?? [], eq2 = (x = [], y = []) => x.length === y.length && x.every((e, n3) => e === y[n3]);
|
|
47267
|
+
const keys = (i) => h.has(i) ? [i] : [...h.keys()].filter((k) => k.endsWith(` > ${i}`));
|
|
47268
|
+
return all.length > 0 && all.every((i) => {
|
|
47269
|
+
const ks = keys(i);
|
|
47270
|
+
return ks.length > 0 && ks.every((k) => eq2(b.get(k), h.get(k)));
|
|
47271
|
+
});
|
|
47272
|
+
}
|
|
47011
47273
|
async function subtractBase(ctx, api, checks, tests, changed, wall, rel, signal, zeroOk = true, zeroIntake = zeroGate(null), dep = new Set) {
|
|
47012
|
-
const out2 = { ids: [], names: [], weak: [], zero: [], cnt: {} };
|
|
47274
|
+
const out2 = { ids: [], names: [], knownRed: [], sameError: [], weak: [], zero: [], cnt: {} };
|
|
47013
47275
|
const pairs = checks.flatMap((c) => {
|
|
47014
47276
|
const t = tests.find((x) => testCheckName(x) === c.name);
|
|
47015
47277
|
return t ? [{ c, t }] : [];
|
|
@@ -47026,12 +47288,37 @@ async function subtractBase(ctx, api, checks, tests, changed, wall, rel, signal,
|
|
|
47026
47288
|
try {
|
|
47027
47289
|
git14(["-c", "core.hooksPath=/dev/null", "worktree", "add", "--detach", dir, ctx.baseSha]);
|
|
47028
47290
|
const base2 = new Map;
|
|
47029
|
-
|
|
47291
|
+
const record = (c, b) => {
|
|
47292
|
+
base2.set(c, { red: !b.ok && !b.cut ? failIds(b.out) : [], n: ran(b.out) ?? summaryPassFailCount(b.out), sk: skipped(b.out), out: b.cut ? "" : b.out });
|
|
47293
|
+
};
|
|
47294
|
+
for (const { c, t } of sus) {
|
|
47030
47295
|
const bc = commandFor(t, dir, api);
|
|
47031
|
-
|
|
47032
|
-
|
|
47033
|
-
|
|
47296
|
+
record(c, await runOnce3(bc.cmd, bc.args, bc.cwd, signal, {}));
|
|
47297
|
+
}
|
|
47298
|
+
const red = un.filter(({ c }) => c.result === "fail" && c.ids?.length && !base2.has(c));
|
|
47299
|
+
const link = changed.some((f) => MANIFESTS2.test(f)) ? null : baseDepsLinker(dir, ctx.repoDir, zeroIntake);
|
|
47300
|
+
const cmds = red.map((p) => ({ ...p, bc: commandFor(p.t, dir, api) }));
|
|
47301
|
+
for (const bc of new Set(cmds.map((x) => x.bc.cwd)))
|
|
47302
|
+
link?.(bc);
|
|
47303
|
+
if (verifyBatchOn() && !signal.aborted) {
|
|
47304
|
+
const byCwd = new Map;
|
|
47305
|
+
for (const x of cmds)
|
|
47306
|
+
if (vitestFile(x.t, x.bc))
|
|
47307
|
+
byCwd.set(x.bc.cwd, [...byCwd.get(x.bc.cwd) ?? [], x]);
|
|
47308
|
+
for (const [cwd, g2] of byCwd) {
|
|
47309
|
+
if (g2.length < BATCH_MIN || signal.aborted)
|
|
47310
|
+
continue;
|
|
47311
|
+
const res = await vitestBatch(cwd, g2.map((x) => x.bc.args[3]), signal);
|
|
47312
|
+
for (const x of g2) {
|
|
47313
|
+
const f = res?.get(x.bc.args[3]);
|
|
47314
|
+
if (f)
|
|
47315
|
+
record(x.c, f);
|
|
47316
|
+
}
|
|
47317
|
+
}
|
|
47034
47318
|
}
|
|
47319
|
+
for (const { c, bc } of cmds)
|
|
47320
|
+
if (!base2.has(c) && !signal.aborted)
|
|
47321
|
+
record(c, await runOnce3(bc.cmd, bc.args, bc.cwd, signal, {}));
|
|
47035
47322
|
out2.zero = await zeroOnBase(zc.map(({ c, t }) => ({ name: c.name, ...commandFor(t, dir, api) })), dir, ctx.repoDir, (r) => runOnce3(r.cmd, r.args, r.cwd, signal, {}), (n3) => ctx.emit("test.skipped_on_base", "verify", { note: `skipped on base: ${n3}`, check: n3 }), zeroIntake);
|
|
47036
47323
|
out2.weak = sus.filter(({ c }) => (c.sk ?? 0) > base2.get(c).sk || (c.n ?? 0) < base2.get(c).n).map(({ c }) => c.name);
|
|
47037
47324
|
for (const { c } of sus) {
|
|
@@ -47040,7 +47327,12 @@ async function subtractBase(ctx, api, checks, tests, changed, wall, rel, signal,
|
|
|
47040
47327
|
const progress = checks.some((c) => wall.has(c.name) && c.result === "pass") || sus.some(({ c }) => !out2.weak.includes(c.name) && base2.get(c).red.length > 0 && (c.n ?? 0) >= base2.get(c).n);
|
|
47041
47328
|
{
|
|
47042
47329
|
for (const { c } of un) {
|
|
47043
|
-
if (
|
|
47330
|
+
if (rel.has(c.name) || c.result !== "fail" || !c.ids?.length || !c.ids.every((i) => base2.get(c)?.red.includes(i)))
|
|
47331
|
+
continue;
|
|
47332
|
+
out2.knownRed.push(c.name);
|
|
47333
|
+
if (sameErrors(headErrors.get(c) ?? "", base2.get(c).out, c.ids))
|
|
47334
|
+
out2.sameError.push(c.name);
|
|
47335
|
+
if (progress || dep.has(c.name)) {
|
|
47044
47336
|
out2.names.push(c.name);
|
|
47045
47337
|
out2.ids.push(...c.ids);
|
|
47046
47338
|
}
|
|
@@ -47102,7 +47394,7 @@ async function runLintChecks(ctx, changed, signal, checks, opts = {}) {
|
|
|
47102
47394
|
}
|
|
47103
47395
|
return pre;
|
|
47104
47396
|
}
|
|
47105
|
-
var CHECK_TIMEOUT_MS = 60000, excerpts, suites, failTails,
|
|
47397
|
+
var CHECK_TIMEOUT_MS = 60000, excerpts, suites, failTails, headErrors, WALL_FAILURE_TAIL_CAP = 16384, wallTailOf = (out2, repoDir) => redactSecrets(stripAnsi(out2).replace(/\r/g, "").split(repoDir.replace(/\/+$/, "") + "/").join("")).slice(-WALL_FAILURE_TAIL_CAP), isHold = (c) => isHoldoutCheck(c.name), pubHold = (c) => ({ name: "holdout", cmd: "holdout", result: c.result, duration_s: c.duration_s, ...c.n !== undefined ? { n: c.n } : {}, ...c.sk !== undefined ? { sk: c.sk } : {}, ...c.owner ? { owner: c.owner, reason: "holdout infrastructure failure" } : {} }), testCheckName = (t) => `${t.runner}:${t.path}`, dedupeTests = (tests) => [...new Map(tests.map((t) => [`${t.runner}:${t.path}`, t])).values()], verifyBatchOn = (env = process.env) => env["LOKI_E10_VERIFY_BATCH"] !== "0", BATCH_MIN = 2, UNHANDLED_RE, batchTimeoutMs = (files) => Math.max(CHECK_TIMEOUT_MS, Math.min(300000, files * 5000)), vitestFile = (t, c) => t.runner === "vitest" && c.cmd === "npx" && c.args.length === 4 && c.args[0] === "--no-install" && c.args[1] === "vitest" && c.args[2] === "run", feedsFixRound = (c, pre) => c.result === "fail" && !pre.names.includes(c.name) && !pre.sameError.includes(c.name) && !isHoldoutCheck(c.name), ESLINT_CONFIGS, excuseLint = (ctx, signal, c, tool, cmd2, prefix, cwd, rel, opts) => c.result !== "fail" || signal.aborted ? Promise.resolve(false) : staticPreExisting(tool, prefix, rel, { run: async (a, stdin) => {
|
|
47106
47398
|
if (signal.aborted)
|
|
47107
47399
|
return null;
|
|
47108
47400
|
const r = await runOnce3(cmd2, a, cwd, AbortSignal.any([signal, AbortSignal.timeout(opts.timeoutMs ?? CHECK_TIMEOUT_MS)]), { ...opts, ...stdin !== undefined ? { stdin } : {} });
|
|
@@ -47120,6 +47412,8 @@ var init_verify = __esm(() => {
|
|
|
47120
47412
|
init_redact();
|
|
47121
47413
|
init_install();
|
|
47122
47414
|
init_scope();
|
|
47415
|
+
init_wall_snapshot();
|
|
47416
|
+
init_runner_errors();
|
|
47123
47417
|
init_runner_config();
|
|
47124
47418
|
init_assert_delta();
|
|
47125
47419
|
init_failures();
|
|
@@ -47141,10 +47435,14 @@ var init_verify = __esm(() => {
|
|
|
47141
47435
|
init_package_suite();
|
|
47142
47436
|
init_check_result();
|
|
47143
47437
|
init_check_result();
|
|
47438
|
+
init_check_result();
|
|
47439
|
+
init_check_result();
|
|
47144
47440
|
init_runner_config();
|
|
47145
47441
|
excerpts = new WeakMap;
|
|
47146
47442
|
suites = new WeakSet;
|
|
47147
47443
|
failTails = new WeakMap;
|
|
47444
|
+
headErrors = new WeakMap;
|
|
47445
|
+
UNHANDLED_RE = /Unhandled (?:Errors?|Rejection)\b/;
|
|
47148
47446
|
ESLINT_CONFIGS = [".eslintrc", ".eslintrc.json", ".eslintrc.js", ".eslintrc.cjs", "eslint.config.js", "eslint.config.mjs", "eslint.config.cjs"];
|
|
47149
47447
|
verifyStage = {
|
|
47150
47448
|
name: "verify",
|
|
@@ -47191,7 +47489,7 @@ var init_verify = __esm(() => {
|
|
|
47191
47489
|
return runner && (runner !== "bun" || map.runners.includes("bun") || /[._](?:test|spec)\.[cm]?[jt]sx?$/.test(p)) ? [{ runner, path: p }] : [];
|
|
47192
47490
|
});
|
|
47193
47491
|
const dep = dependentTests(ctx.repoDir, map, changed, [...impacted, ...changedTestFiles, ...wallTests, ...relevant2]), depNames = new Set(dep.tests.map(testCheckName));
|
|
47194
|
-
const tests = failedFirst(dedupeTests([...wallTests, ...relevant2, ...changedTestFiles, ...impacted, ...dep.tests]), ctx.outputs().verify?.checks);
|
|
47492
|
+
const tests = failedFirst(dedupeTests([...wallTests, ...relevant2, ...changedTestFiles, ...changedSymbolsFirst(ctx, impacted, changed), ...dep.tests]), ctx.outputs().verify?.checks);
|
|
47195
47493
|
const hashes = fileHashes(ctx.repoDir, changed), qs = quickScope(ctx.outputs(), hashes), keep = new Set([...qs?.blocking ?? [], ...[...wallTests, ...relevant2].map(testCheckName)]);
|
|
47196
47494
|
const sinceTests = qs ? [...ctx.tests.impacted(map, qs.since), ...map.tests.filter((t) => qs.since.includes(t.path))] : [], split2 = qs ? quickSplit(tests, keep, sinceTests) : { first: tests, rest: [] };
|
|
47197
47495
|
const done = [], wallNames0 = new Set(wallTests.map(testCheckName)), targets0 = new Set([...wallTests, ...relevant2].map(testCheckName)), wallDropped0 = [...wallPaths].filter((p) => !wallTests.some((t) => t.path === p));
|
|
@@ -47206,14 +47504,31 @@ var init_verify = __esm(() => {
|
|
|
47206
47504
|
const scopedOut = scopedOutOf(map);
|
|
47207
47505
|
if (scopedOut.length)
|
|
47208
47506
|
ctx.emit("test.scoped_out", "verify", { tests: scopedOut });
|
|
47507
|
+
const batchable = (t) => verifyBatchOn() && t.runner === "vitest" && !wallNames0.has(testCheckName(t));
|
|
47209
47508
|
const runTests = async (list) => {
|
|
47210
|
-
|
|
47211
|
-
|
|
47212
|
-
await
|
|
47213
|
-
|
|
47214
|
-
|
|
47215
|
-
|
|
47216
|
-
|
|
47509
|
+
const byName = new Map;
|
|
47510
|
+
const alone = async (l) => {
|
|
47511
|
+
(await mapPool(l, verifyJobs(), async (t) => {
|
|
47512
|
+
const tc = commandFor(t, ctx.repoDir, api), slot = [];
|
|
47513
|
+
await runCheck(ctx, testCheckName(t), tc.cmd, tc.args, signal, slot, { ...tc.interpreter ? { interpreter: tc.interpreter } : {}, protect: [...wallTests, ...relevant2].includes(t), ...tc.pkgRoot !== "." ? { cwd: tc.cwd } : {} });
|
|
47514
|
+
done.push(...slot);
|
|
47515
|
+
publish();
|
|
47516
|
+
return slot;
|
|
47517
|
+
}, () => signal.aborted)).forEach((sl, i) => {
|
|
47518
|
+
if (sl)
|
|
47519
|
+
byName.set(testCheckName(l[i]), sl);
|
|
47520
|
+
});
|
|
47521
|
+
};
|
|
47522
|
+
await alone(list.filter((t) => !batchable(t)));
|
|
47523
|
+
for (const part of [list.filter((t) => batchable(t) && targets0.has(testCheckName(t))), list.filter((t) => batchable(t) && !targets0.has(testCheckName(t)))]) {
|
|
47524
|
+
for (const [n3, c] of await runVitestBatches(ctx, part, api, signal, (c2) => {
|
|
47525
|
+
done.push(c2);
|
|
47526
|
+
publish();
|
|
47527
|
+
}))
|
|
47528
|
+
byName.set(n3, [c]);
|
|
47529
|
+
}
|
|
47530
|
+
await alone(list.filter((t) => batchable(t) && !byName.has(testCheckName(t))));
|
|
47531
|
+
checks.push(...list.flatMap((t) => byName.get(testCheckName(t)) ?? []));
|
|
47217
47532
|
};
|
|
47218
47533
|
await runTests(split2.first);
|
|
47219
47534
|
const decisive = qs !== null && checks.some((c) => c.result === "fail" && (keep.has(c.name) || changed.includes(c.name.slice(c.name.indexOf(":") + 1))));
|
|
@@ -47288,6 +47603,12 @@ var init_verify = __esm(() => {
|
|
|
47288
47603
|
risk = markExecuted(risk, ranDeeper);
|
|
47289
47604
|
recordRisk(ctx.repoDir, risk);
|
|
47290
47605
|
}
|
|
47606
|
+
const known = new Set(checks.filter((c) => c.result === "fail" && (preRed.sameError.includes(c.name) || wallNames0.has(c.name))).flatMap((c) => c.ids ?? []));
|
|
47607
|
+
for (const c of full)
|
|
47608
|
+
if (c.result === "fail" && c.ids?.length && c.ids.every((i) => known.has(i)) && !preRed.names.includes(c.name)) {
|
|
47609
|
+
preRed.knownRed.push(c.name);
|
|
47610
|
+
preRed.sameError.push(c.name);
|
|
47611
|
+
}
|
|
47291
47612
|
}
|
|
47292
47613
|
if (risk && risk.tier === "high" && !signal.aborted && complete) {
|
|
47293
47614
|
const { runSecretScan: runSecretScan2 } = await Promise.resolve().then(() => (init_deep(), exports_deep));
|
|
@@ -47307,7 +47628,7 @@ var init_verify = __esm(() => {
|
|
|
47307
47628
|
const covered = (f) => ctx.tests.impacted(map, [f]).some((t) => checks.some((c) => c.name === testCheckName(t) && hasExecutedProof([c])));
|
|
47308
47629
|
const uncoveredChanged = changed.filter((f) => CODE_FILE_EXT.test(f) && !isTestFile(f) && !wallPaths.has(f) && !cfgChanged.includes(f) && !covered(f));
|
|
47309
47630
|
const flaky = checks.filter((c) => c.result === "flaky").map((c) => isHold(c) ? "holdout" : c.name);
|
|
47310
|
-
const { groups: failuresGrouped, names: blockingNames } = briefGroups(checks.filter((c) => c
|
|
47631
|
+
const { groups: failuresGrouped, names: blockingNames } = briefGroups(checks.filter((c) => feedsFixRound(c, preRed)), (c) => excerpts.get(c) ?? "", (c) => suites.has(c), EXCERPT_TOTAL_CAP, qs && !complete ? { prev: ctx.outputs().verify, ran: new Set(checks.map((c) => c.name)) } : undefined);
|
|
47311
47632
|
const pub = checks.map((c) => isHold(c) ? pubHold(c) : c), holdoutFailed = checks.filter((c) => c.result === "fail" && isHold(c) && !preRed.names.includes(c.name)).length;
|
|
47312
47633
|
const inBase = (f) => {
|
|
47313
47634
|
try {
|
|
@@ -47329,7 +47650,7 @@ var init_verify = __esm(() => {
|
|
|
47329
47650
|
const wallDropped = [...wallPaths].filter((p) => !wallTests.some((t) => t.path === p));
|
|
47330
47651
|
notProven.push(...wallDropped.map((p) => `Wall test not executed: ${p}: ${NO_RUNNER_REASON}`));
|
|
47331
47652
|
const wallNames = new Set(wallTests.map(testCheckName)), wallRun = checks.filter((c) => wallNames.has(c.name) || isHold(c)), wallFailTail = writeWallFailureTail(ctx.runDir, checks.filter((c) => wallNames.has(c.name) && c.result === "fail" && !isHold(c) && !preRed.names.includes(c.name)).map((c) => ({ name: c.name, out: failTails.get(c) ?? "" }))), wallPassed = wallRun.some((c) => c.result === "fail") ? false : wallRun.length > 0 && wallDropped.length === 0 && wallRun.every((c) => c.result === "pass") ? true : undefined;
|
|
47332
|
-
return { status: "completed", data: { checks: pub, flaky, verify_scope: complete ? "complete" : "quick", file_hashes: hashes, blocking_checks: blockingNames, ...wallFailTail ? { wall_failure_tail: wallFailTail } : {}, ...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 } };
|
|
47653
|
+
return { status: "completed", data: { checks: pub, flaky, verify_scope: complete ? "complete" : "quick", file_hashes: hashes, blocking_checks: blockingNames, ...wallFailTail ? { wall_failure_tail: wallFailTail } : {}, ...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, ...preRed.knownRed.length ? { known_red_checks: preRed.knownRed } : {}, ...preRed.sameError.length ? { known_red_same_error: preRed.sameError } : {}, 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 } };
|
|
47333
47654
|
}
|
|
47334
47655
|
};
|
|
47335
47656
|
stage9 = verifyStage;
|
|
@@ -88299,8 +88620,8 @@ __export(exports_providers, {
|
|
|
88299
88620
|
SDK_BUNDLED_CLAUDE_CODE: () => SDK_BUNDLED_CLAUDE_CODE,
|
|
88300
88621
|
PROVIDER_COMMIT_HYGIENE: () => PROVIDER_COMMIT_HYGIENE
|
|
88301
88622
|
});
|
|
88302
|
-
import { mkdirSync as mkdirSync77, existsSync as existsSync102, readFileSync as readFileSync128, realpathSync as
|
|
88303
|
-
import { delimiter as delimiter4, dirname as dirname57, isAbsolute as isAbsolute24, relative as relative31, resolve as
|
|
88623
|
+
import { mkdirSync as mkdirSync77, existsSync as existsSync102, readFileSync as readFileSync128, realpathSync as realpathSync37, appendFileSync as appendFileSync17 } from "fs";
|
|
88624
|
+
import { delimiter as delimiter4, dirname as dirname57, isAbsolute as isAbsolute24, relative as relative31, resolve as resolve41, sep as sep25 } from "path";
|
|
88304
88625
|
function mergeDisallowedTools(policy, stageCsv) {
|
|
88305
88626
|
return [...new Set([...policy ?? [], ...stageCsv.split(",").filter(Boolean)])];
|
|
88306
88627
|
}
|
|
@@ -88431,9 +88752,9 @@ function ensureParentDir(path) {
|
|
|
88431
88752
|
}
|
|
88432
88753
|
function physicalPath(path) {
|
|
88433
88754
|
try {
|
|
88434
|
-
return
|
|
88755
|
+
return realpathSync37(path);
|
|
88435
88756
|
} catch {
|
|
88436
|
-
return
|
|
88757
|
+
return resolve41(path);
|
|
88437
88758
|
}
|
|
88438
88759
|
}
|
|
88439
88760
|
function hostGuardRequired(cwd) {
|
|
@@ -88489,6 +88810,8 @@ function planRouterSession(args) {
|
|
|
88489
88810
|
const routed = routerEnabled(env);
|
|
88490
88811
|
if (!routed && !advisorOnlyEnabled(env))
|
|
88491
88812
|
return null;
|
|
88813
|
+
if (routed && routerPreset(env) && /opus/i.test(args.model))
|
|
88814
|
+
return null;
|
|
88492
88815
|
const probe = probeAdvisor(env, "claude", args.claudeCodeVersion, args.runDir, advisorPair(env, args.model));
|
|
88493
88816
|
if (!routed)
|
|
88494
88817
|
return probe.available ? { model: args.model, settings: { advisorModel: ROUTER_ADVISOR_MODEL } } : null;
|
|
@@ -88502,6 +88825,8 @@ function planRouterSession(args) {
|
|
|
88502
88825
|
}
|
|
88503
88826
|
};
|
|
88504
88827
|
}
|
|
88828
|
+
if (routerPreset(env) && env["LOKI_ADVISOR_SCOPE"] === "off")
|
|
88829
|
+
return null;
|
|
88505
88830
|
return { model: isHaikuModel(args.model) ? "sonnet" : args.model, advisorReason: probe.reason };
|
|
88506
88831
|
}
|
|
88507
88832
|
function cliSettingsJson(hostGuard2, router, fence2) {
|
|
@@ -88533,7 +88858,7 @@ function claudeProvider() {
|
|
|
88533
88858
|
const baseModel = claudeModelFor(call);
|
|
88534
88859
|
const routed = sessionPlanEnabled() ? planRouterSession({
|
|
88535
88860
|
model: baseModel,
|
|
88536
|
-
runDir: process.env["LOKI_DIR"] ??
|
|
88861
|
+
runDir: process.env["LOKI_DIR"] ?? resolve41(call.cwd, ".loki"),
|
|
88537
88862
|
claudeCodeVersion: await installedClaudeCodeVersion(cli)
|
|
88538
88863
|
}) : null;
|
|
88539
88864
|
const model = routed ? routed.model : baseModel;
|
|
@@ -88604,7 +88929,7 @@ function providerCallTimeoutMs(env) {
|
|
|
88604
88929
|
}
|
|
88605
88930
|
function emitSdkDegradationEvent(cwd, payload) {
|
|
88606
88931
|
try {
|
|
88607
|
-
const lokiRoot = process.env["LOKI_DIR"] ??
|
|
88932
|
+
const lokiRoot = process.env["LOKI_DIR"] ?? resolve41(cwd, ".loki");
|
|
88608
88933
|
mkdirSync77(lokiRoot, { recursive: true });
|
|
88609
88934
|
const record = {
|
|
88610
88935
|
type: "capability_degraded",
|
|
@@ -88612,7 +88937,7 @@ function emitSdkDegradationEvent(cwd, payload) {
|
|
|
88612
88937
|
timestamp: new Date().toISOString(),
|
|
88613
88938
|
payload: { capability: "sdk_query", fail_closed: true, ...payload }
|
|
88614
88939
|
};
|
|
88615
|
-
appendFileSync17(
|
|
88940
|
+
appendFileSync17(resolve41(lokiRoot, "events.jsonl"), `${JSON.stringify(record)}
|
|
88616
88941
|
`);
|
|
88617
88942
|
} catch {}
|
|
88618
88943
|
}
|
|
@@ -88624,7 +88949,7 @@ function buildSdkLoopOptions(args) {
|
|
|
88624
88949
|
const out2 = {};
|
|
88625
88950
|
const router = sessionPlanEnabled() ? planRouterSession({
|
|
88626
88951
|
model: args.model,
|
|
88627
|
-
runDir: args.runDir ?? process.env["LOKI_DIR"] ??
|
|
88952
|
+
runDir: args.runDir ?? process.env["LOKI_DIR"] ?? resolve41(args.cwd, ".loki"),
|
|
88628
88953
|
claudeCodeVersion: args.claudeCodeVersion ?? bundledClaudeCodeVersion2()
|
|
88629
88954
|
}) : null;
|
|
88630
88955
|
if (router) {
|
|
@@ -89065,7 +89390,7 @@ function createSessionRunner(cfg) {
|
|
|
89065
89390
|
}, cfg.heartbeatMs ?? HEARTBEAT_MS_DEFAULT);
|
|
89066
89391
|
opts.signal.addEventListener("abort", onAbort, { once: true });
|
|
89067
89392
|
const untrack = trackSession(() => kill("aborted"));
|
|
89068
|
-
return new Promise((
|
|
89393
|
+
return new Promise((resolve42) => {
|
|
89069
89394
|
child.on("exit", () => reapLiveGroup(pgid, () => cfg.emit?.("session.group_reaped", opts.stage, { session_id: sessionId, pgid })));
|
|
89070
89395
|
child.on("close", (code) => {
|
|
89071
89396
|
clearTimeout(limitTimer);
|
|
@@ -89092,7 +89417,7 @@ function createSessionRunner(cfg) {
|
|
|
89092
89417
|
rememberSessionEffort(psid, ran2);
|
|
89093
89418
|
recordCost(cfg, opts, killed ? "killed" : code === 0 ? "completed" : "failed", durationS, stdout + logText);
|
|
89094
89419
|
untrack();
|
|
89095
|
-
|
|
89420
|
+
resolve42({ exit: guard.ok ? code : 1, markers, durationS, killed, summary: (stdout + logText).trim().slice(-4096), stderrTail: (guard.ok ? "" : `guard violation: ${guard.violations.map((v) => v.detail).join("; ")}
|
|
89096
89421
|
`) + stderrTail.toString("utf8") + (logText.match(/^\[sdk-loop error: .*\]$/gm) ?? []).join(`
|
|
89097
89422
|
`) });
|
|
89098
89423
|
});
|
|
@@ -89329,9 +89654,9 @@ var init_session_resume = __esm(() => {
|
|
|
89329
89654
|
});
|
|
89330
89655
|
|
|
89331
89656
|
// ../../loki-ts/src/util/conflict_resume.ts
|
|
89332
|
-
import { createHash as
|
|
89657
|
+
import { createHash as createHash40 } from "crypto";
|
|
89333
89658
|
import { execFileSync as execFileSync10 } from "child_process";
|
|
89334
|
-
import { existsSync as existsSync105, mkdirSync as mkdirSync80, mkdtempSync as mkdtempSync21, readFileSync as readFileSync131, rmSync as rmSync41, symlinkSync as symlinkSync5, writeFileSync as writeFileSync75 } from "fs";
|
|
89659
|
+
import { chmodSync as chmodSync8, existsSync as existsSync105, mkdirSync as mkdirSync80, mkdtempSync as mkdtempSync21, readFileSync as readFileSync131, rmSync as rmSync41, statSync as statSync43, symlinkSync as symlinkSync5, writeFileSync as writeFileSync75 } from "fs";
|
|
89335
89660
|
import { tmpdir as tmpdir27 } from "os";
|
|
89336
89661
|
import { basename as basename40, dirname as dirname60, isAbsolute as isAbsolute25, join as join150, relative as relative32 } from "path";
|
|
89337
89662
|
function answerMark(events2, assumeNext = false) {
|
|
@@ -89388,7 +89713,7 @@ function applyArbitrations(wall, events2) {
|
|
|
89388
89713
|
if (e10.type !== "wall.arbitrated")
|
|
89389
89714
|
continue;
|
|
89390
89715
|
const a = e10.data["arbitration"], path = e10.data["path"], content = e10.data["content"];
|
|
89391
|
-
if (!a || typeof a.sha256 !== "string" || typeof path !== "string" || typeof content !== "string" ||
|
|
89716
|
+
if (!a || typeof a.sha256 !== "string" || typeof path !== "string" || typeof content !== "string" || createHash40("sha256").update(content).digest("hex") !== a.sha256)
|
|
89392
89717
|
continue;
|
|
89393
89718
|
const sf2 = files?.find((x10) => x10.path === path);
|
|
89394
89719
|
if (!sf2)
|
|
@@ -89506,20 +89831,20 @@ async function adjudicateWallConflict(ctx, first, firstSession, wall, deps = {})
|
|
|
89506
89831
|
const sealedCopy = join150(sealedWallDir(ctx.runDir), name);
|
|
89507
89832
|
if (existsSync105(dirname60(sealedCopy)))
|
|
89508
89833
|
writeFileSync75(sealedCopy, next, "utf8");
|
|
89509
|
-
sf2.sha256 =
|
|
89834
|
+
sf2.sha256 = createHash40("sha256").update(next).digest("hex");
|
|
89510
89835
|
const sealedNow = existsSync105(sealedCopy) ? readFileSync131(sealedCopy, "utf8") : null;
|
|
89511
89836
|
if (sealedNow !== next) {
|
|
89512
89837
|
restore();
|
|
89513
89838
|
if (sealedNow !== null)
|
|
89514
89839
|
writeFileSync75(sealedCopy, original, "utf8");
|
|
89515
|
-
sf2.sha256 =
|
|
89840
|
+
sf2.sha256 = createHash40("sha256").update(original).digest("hex");
|
|
89516
89841
|
return null;
|
|
89517
89842
|
}
|
|
89518
89843
|
writeFileSync75(f.path, sealedNow, "utf8");
|
|
89519
89844
|
if (runCheck2(ctx.repoDir, ref) !== "pass") {
|
|
89520
89845
|
restore();
|
|
89521
89846
|
writeFileSync75(sealedCopy, original, "utf8");
|
|
89522
|
-
sf2.sha256 =
|
|
89847
|
+
sf2.sha256 = createHash40("sha256").update(original).digest("hex");
|
|
89523
89848
|
return null;
|
|
89524
89849
|
}
|
|
89525
89850
|
const ch = changedAssertion(original, next), arb = { check: a.file, test, old_assertion: ch.old, new_assertion: ch.new, spec_quote: String(v.spec_quote), spec_quote_2: String(B10.verdict.spec_quote), sha256: sf2.sha256 };
|
|
@@ -89573,7 +89898,7 @@ async function legacyReauthor(ctx, first, firstSession, f, a, reason, task) {
|
|
|
89573
89898
|
return null;
|
|
89574
89899
|
f.content = next;
|
|
89575
89900
|
writeFileSync75(f.path, next, "utf8");
|
|
89576
|
-
const sf2 = o.wall?.files?.find((x10) => x10.path === f.path), sha6 =
|
|
89901
|
+
const sf2 = o.wall?.files?.find((x10) => x10.path === f.path), sha6 = createHash40("sha256").update(next).digest("hex");
|
|
89577
89902
|
if (sf2)
|
|
89578
89903
|
sf2.sha256 = sha6;
|
|
89579
89904
|
mkdirSync80(sealedWallDir(ctx.runDir), { recursive: true });
|
|
@@ -89596,41 +89921,112 @@ ${brief}`, ...sid ? { resumeSessionId: sid } : {} });
|
|
|
89596
89921
|
rmSync41(cwd, { recursive: true, force: true });
|
|
89597
89922
|
}
|
|
89598
89923
|
}
|
|
89599
|
-
function
|
|
89600
|
-
const
|
|
89601
|
-
if (
|
|
89602
|
-
return
|
|
89603
|
-
if (
|
|
89924
|
+
function wallOnlyAfterFix(o, repoDir) {
|
|
89925
|
+
const v = o.verify;
|
|
89926
|
+
if (o.implement?.exit !== "done" || Number(o.fix?.round ?? 0) < 1 || !v || v.stopped_at || wallFailures(o, repoDir, true) === null)
|
|
89927
|
+
return false;
|
|
89928
|
+
if (v.verify_scope === "quick")
|
|
89929
|
+
return !(v.failures_grouped ?? []).some((g10) => g10.carried === true);
|
|
89930
|
+
return (Array.isArray(v.checks) ? v.checks : []).some((c) => ownTestPassed(c, wallRelOf(o, repoDir)));
|
|
89931
|
+
}
|
|
89932
|
+
function wallSignature(o, repoDir) {
|
|
89933
|
+
const wall = wallRelOf(o, repoDir), checks = Array.isArray(o.verify?.checks) ? o.verify.checks : [];
|
|
89934
|
+
return JSON.stringify(checks.filter((c) => c.result === "fail" && wall.has(String(c.name).slice(String(c.name).indexOf(":") + 1))).map((c) => [String(c.name), [...strList2(c.ids)].sort(), String(c.first_error ?? "")]).sort());
|
|
89935
|
+
}
|
|
89936
|
+
function wallFailures(o, repoDir, strict = false) {
|
|
89937
|
+
const { verify: v, wall: w } = o;
|
|
89938
|
+
if (!v || !w || o.plan?.out_of_repo === true || Number(v.holdout_failed ?? 0) > 0)
|
|
89604
89939
|
return null;
|
|
89605
|
-
const wallRel =
|
|
89606
|
-
const fileOf = (n10) => n10.slice(n10.indexOf(":") + 1), checks = Array.isArray(v.checks) ? v.checks : [], preRed = strList2(v.pre_red_checks);
|
|
89940
|
+
const wallRel = wallRelOf(o, repoDir), fileOf = (n10) => n10.slice(n10.indexOf(":") + 1), checks = Array.isArray(v.checks) ? v.checks : [], excused = new Set([...strList2(v.pre_red_checks), ...strList2(v.known_red_same_error)]);
|
|
89607
89941
|
const isWall = (c) => wallRel.has(fileOf(String(c.name))), wallFail = checks.filter((c) => isWall(c) && c.result === "fail");
|
|
89608
|
-
const own = checks.filter((c) => !isWall(c) && !String(c.name).startsWith("holdout") && !String(c.name).startsWith("full suite"));
|
|
89609
|
-
if (!wallFail.length || own.some((c) => c.result === "fail" && c.owner !== "harness" && !
|
|
89942
|
+
const own = checks.filter((c) => !isWall(c) && !String(c.name).startsWith("holdout") && (strict || !String(c.name).startsWith("full suite")));
|
|
89943
|
+
if (!wallFail.length || own.some((c) => c.result === "fail" && c.owner !== "harness" && !excused.has(String(c.name))))
|
|
89610
89944
|
return null;
|
|
89611
89945
|
if (!strList2(v.changed_files).some((f) => !wallRel.has(f) && !f.startsWith(".loki/")))
|
|
89612
89946
|
return null;
|
|
89613
89947
|
return [...new Set(wallFail.map((c) => fileOf(String(c.name))))];
|
|
89614
89948
|
}
|
|
89615
|
-
|
|
89616
|
-
const
|
|
89949
|
+
function wallConflictDefects(o, repoDir) {
|
|
89950
|
+
const { implement: imp, verify: v, fix: fx2 } = o;
|
|
89951
|
+
if (imp?.exit !== "spec_conflict")
|
|
89952
|
+
return wallOnlyAfterFix(o, repoDir) ? wallFailures(o, repoDir, true) : null;
|
|
89953
|
+
if (!v || v.stopped_at)
|
|
89954
|
+
return null;
|
|
89955
|
+
if (fx2?.exit === "spec_conflict" && !(typeof fx2.tree_before === "string" && fx2.tree_before === fx2.tree_after))
|
|
89956
|
+
return null;
|
|
89957
|
+
return wallFailures(o, repoDir);
|
|
89958
|
+
}
|
|
89959
|
+
async function deliverOverWallConflict(o, repoDir, reverify, emit, opts = {}) {
|
|
89960
|
+
const files = wallConflictDefects(o, repoDir), w = o.wall, conflict = o.implement?.exit === "spec_conflict";
|
|
89617
89961
|
if (!files || !w)
|
|
89618
89962
|
return null;
|
|
89619
|
-
const gone = (p) => files.includes(isAbsolute25(p) ? relative32(repoDir, p) : p);
|
|
89963
|
+
const reason = conflict ? WALL_CONFLICT_DISCARD : WALL_ONLY_DISCARD, gone = (p) => files.includes(isAbsolute25(p) ? relative32(repoDir, p) : p);
|
|
89964
|
+
const read3 = (p) => {
|
|
89965
|
+
try {
|
|
89966
|
+
return readFileSync131(p);
|
|
89967
|
+
} catch {
|
|
89968
|
+
return null;
|
|
89969
|
+
}
|
|
89970
|
+
}, modeOf = (p) => {
|
|
89971
|
+
try {
|
|
89972
|
+
return statSync43(p).mode & 4095;
|
|
89973
|
+
} catch {
|
|
89974
|
+
return null;
|
|
89975
|
+
}
|
|
89976
|
+
};
|
|
89977
|
+
const tailFile = opts.runDir ? join150(opts.runDir, WALL_FAILURE_TAIL_FILE) : null;
|
|
89978
|
+
const saved = { files: w.files, readOnlyFiles: w.readOnlyFiles, verify: o.verify, bytes: files.map((f) => read3(join150(repoDir, f))), modes: files.map((f) => modeOf(join150(repoDir, f))), tail: tailFile ? read3(tailFile) : null };
|
|
89979
|
+
const record = () => {
|
|
89980
|
+
w.discarded = [...w.discarded ?? [], ...files.map((file) => ({ file, reason }))];
|
|
89981
|
+
for (const f of files)
|
|
89982
|
+
emit(f, reason);
|
|
89983
|
+
};
|
|
89620
89984
|
for (const f of files)
|
|
89621
89985
|
rmSync41(join150(repoDir, f), { force: true });
|
|
89622
89986
|
w.files = (w.files ?? []).filter((f) => !gone(f.path));
|
|
89623
89987
|
w.readOnlyFiles = (w.readOnlyFiles ?? []).filter((f) => !gone(f.path));
|
|
89624
|
-
|
|
89625
|
-
|
|
89626
|
-
emit(f, WALL_CONFLICT_DISCARD);
|
|
89988
|
+
if (conflict)
|
|
89989
|
+
record();
|
|
89627
89990
|
await reverify();
|
|
89628
|
-
const v = o.verify, wallLeft =
|
|
89629
|
-
|
|
89630
|
-
|
|
89631
|
-
if (!
|
|
89991
|
+
const v = o.verify, wallLeft = wallRelOf(o, repoDir), checks = Array.isArray(v?.checks) ? v.checks : [];
|
|
89992
|
+
const pre2 = strList2(v?.pre_red_checks), same = new Set(strList2(v?.known_red_same_error)), kr2 = strList2(v?.known_red_checks).filter((n10) => same.has(n10) && !pre2.includes(n10)), excused = new Set([...pre2, ...kr2]);
|
|
89993
|
+
const delivered = !!v && !v.stopped_at && (v.failures_grouped ?? []).length === 0 && Number(v.holdout_failed ?? 0) === 0 && checks.every((c) => c.result !== "fail" || c.owner === "harness" || excused.has(String(c.name))) && checks.some((c) => ownTestPassed(c, wallLeft));
|
|
89994
|
+
if (!delivered || !v) {
|
|
89995
|
+
if (!conflict) {
|
|
89996
|
+
files.forEach((f, i) => {
|
|
89997
|
+
const b = saved.bytes[i], m = saved.modes[i];
|
|
89998
|
+
if (b) {
|
|
89999
|
+
writeFileSync75(join150(repoDir, f), b);
|
|
90000
|
+
if (m !== null && m !== undefined) {
|
|
90001
|
+
try {
|
|
90002
|
+
chmodSync8(join150(repoDir, f), m);
|
|
90003
|
+
} catch {}
|
|
90004
|
+
}
|
|
90005
|
+
}
|
|
90006
|
+
});
|
|
90007
|
+
if (tailFile) {
|
|
90008
|
+
try {
|
|
90009
|
+
if (saved.tail)
|
|
90010
|
+
writeFileSync75(tailFile, saved.tail);
|
|
90011
|
+
else
|
|
90012
|
+
rmSync41(tailFile, { force: true });
|
|
90013
|
+
} catch {}
|
|
90014
|
+
}
|
|
90015
|
+
w.files = saved.files;
|
|
90016
|
+
w.readOnlyFiles = saved.readOnlyFiles;
|
|
90017
|
+
o.verify = saved.verify;
|
|
90018
|
+
if (saved.verify)
|
|
90019
|
+
opts.restored?.(saved.verify);
|
|
90020
|
+
}
|
|
89632
90021
|
return null;
|
|
89633
|
-
|
|
90022
|
+
}
|
|
90023
|
+
if (!conflict)
|
|
90024
|
+
record();
|
|
90025
|
+
v.not_proven = [...strList2(v.not_proven), conflict ? `Delivered over an implementer conflict with the Wall: ${files.join(", ")} discarded as a Wall defect, so this change is proven only by the repo's own tests (${oneLine4(String(o.implement?.spec_conflict_reason ?? ""))})` : `Loki's own acceptance tests still failed after a fix round: ${files.join(", ")} set aside, so this change is proven only by the repo's own tests`];
|
|
90026
|
+
if (kr2.length) {
|
|
90027
|
+
v.pre_red_checks = [...pre2, ...kr2];
|
|
90028
|
+
v.pre_red = [...strList2(v.pre_red), ...checks.filter((c) => kr2.includes(String(c.name))).flatMap((c) => strList2(c.ids))];
|
|
90029
|
+
}
|
|
89634
90030
|
o.implement = { ...o.implement, exit: "done", conflict_delivered: files };
|
|
89635
90031
|
return files;
|
|
89636
90032
|
}
|
|
@@ -89653,12 +90049,12 @@ var refereeModel = (ctx) => capToRunTier(wallModel(), ctx.model, ["LOKI_E10_WALL
|
|
|
89653
90049
|
`${name}.orig is a test file and ${name}.new is a proposed replacement of it. Decide, from task.md alone, whether the change is a correction that task.md requires: the old assertion contradicts task.md and the new one follows from it.`,
|
|
89654
90050
|
'Write verdict.json: {"agree":true,"spec_quote":"<one sentence copied verbatim from task.md that the old assertion contradicts>"} or {"agree":false}. Say agree only when the old assertion is wrong per task.md and the new one is right per task.md.'
|
|
89655
90051
|
].join(`
|
|
89656
|
-
`), WALL_CONFLICT_DISCARD = "the implementer reported it conflicts with the task while the repo's own tests pass on the change: Wall defect, discarded", ownTestPassed = (c, wall) => {
|
|
90052
|
+
`), WALL_CONFLICT_DISCARD = "the implementer reported it conflicts with the task while the repo's own tests pass on the change: Wall defect, discarded", WALL_ONLY_DISCARD = "only Loki's own acceptance test still failed after a fix round while the repo's own tests pass on the change: set aside, delivered as PARTIAL", ownTestPassed = (c, wall) => {
|
|
89657
90053
|
const name = String(c.name ?? "");
|
|
89658
90054
|
if (c.result !== "pass" || /^(lint:|security scan|select-tests|holdout)/.test(name) || wall.has(name.slice(name.indexOf(":") + 1)))
|
|
89659
90055
|
return false;
|
|
89660
90056
|
return name.startsWith("full suite:") || typeof c.n === "number" && c.n > 0;
|
|
89661
|
-
}, strList2 = (v) => Array.isArray(v) ? v.filter((x10) => typeof x10 === "string") : [];
|
|
90057
|
+
}, strList2 = (v) => Array.isArray(v) ? v.filter((x10) => typeof x10 === "string") : [], wallRelOf = (o, repoDir) => new Set((o.wall?.files ?? []).map((f) => isAbsolute25(f.path) ? relative32(repoDir, f.path) : f.path));
|
|
89662
90058
|
var init_conflict_resume = __esm(() => {
|
|
89663
90059
|
init_session_resume();
|
|
89664
90060
|
init_sizing();
|
|
@@ -89731,9 +90127,9 @@ __export(exports_run_outputs, {
|
|
|
89731
90127
|
RECOVERY_ABORT: () => RECOVERY_ABORT
|
|
89732
90128
|
});
|
|
89733
90129
|
import { execFile as execFile3, spawnSync as spawnSync24 } from "child_process";
|
|
89734
|
-
import { createHash as
|
|
89735
|
-
import { existsSync as existsSync106, lstatSync as lstatSync32, mkdirSync as mkdirSync81, readdirSync as readdirSync47, readFileSync as readFileSync132, statSync as
|
|
89736
|
-
import { basename as basename41, join as join151, resolve as
|
|
90130
|
+
import { createHash as createHash41 } from "crypto";
|
|
90131
|
+
import { existsSync as existsSync106, lstatSync as lstatSync32, mkdirSync as mkdirSync81, readdirSync as readdirSync47, readFileSync as readFileSync132, statSync as statSync44, writeFileSync as writeFileSync76 } from "fs";
|
|
90132
|
+
import { basename as basename41, join as join151, resolve as resolve42 } from "path";
|
|
89737
90133
|
function intentRevisionsBlock(revs) {
|
|
89738
90134
|
const r = (revs ?? []).filter((r10) => r10.unapplied !== true).map(({ rev, source, actor, sha: sha6 }) => ({ rev, source, actor, sha: sha6 }));
|
|
89739
90135
|
return r.length ? { intent_revisions: r } : {};
|
|
@@ -89741,7 +90137,7 @@ function intentRevisionsBlock(revs) {
|
|
|
89741
90137
|
function seededCorpusBlock(env = process.env) {
|
|
89742
90138
|
const dir = env["LOKI_SEEDED_DEFECTS_DIR"] || join151(REPO_ROOT, "benchmarks", "seeded-defects");
|
|
89743
90139
|
try {
|
|
89744
|
-
const bytes = readFileSync132(join151(dir, "manifest.json")), version2 =
|
|
90140
|
+
const bytes = readFileSync132(join151(dir, "manifest.json")), version2 = createHash41("sha256").update(bytes).digest("hex");
|
|
89745
90141
|
const ids = (JSON.parse(bytes.toString("utf8")).defects ?? []).map((d) => d.id);
|
|
89746
90142
|
let rate = null;
|
|
89747
90143
|
try {
|
|
@@ -89762,7 +90158,7 @@ function seededCorpusBlock(env = process.env) {
|
|
|
89762
90158
|
function sealAccuracyLine(changed, checks, model, env = process.env, nowMs = Date.now()) {
|
|
89763
90159
|
try {
|
|
89764
90160
|
const dir = env["LOKI_SEEDED_DEFECTS_DIR"] || join151(REPO_ROOT, "benchmarks", "seeded-defects"), file = join151(dir, "results", "wrong-pass.json");
|
|
89765
|
-
const corpus =
|
|
90161
|
+
const corpus = createHash41("sha256").update(readFileSync132(join151(dir, "manifest.json"))).digest("hex");
|
|
89766
90162
|
const res = JSON.parse(readFileSync132(file, "utf8"));
|
|
89767
90163
|
if (res.manifest_sha256 !== corpus || !Array.isArray(res.runs))
|
|
89768
90164
|
return SEAL_ACCURACY_NOT_MEASURED;
|
|
@@ -89914,7 +90310,7 @@ function findInterrupted(repoDir, runId2, includeCancelled = false, why) {
|
|
|
89914
90310
|
} catch {
|
|
89915
90311
|
return null;
|
|
89916
90312
|
}
|
|
89917
|
-
const rows = ids.filter((id2) => /^e10-[A-Za-z0-9-]+$/.test(id2) && existsSync106(join151(repoDir, eventsRelPath(id2)))).map((id2) => ({ id: id2, m:
|
|
90313
|
+
const rows = ids.filter((id2) => /^e10-[A-Za-z0-9-]+$/.test(id2) && existsSync106(join151(repoDir, eventsRelPath(id2)))).map((id2) => ({ id: id2, m: statSync44(join151(repoDir, eventsRelPath(id2))).mtimeMs })).sort((a, b) => b.m - a.m);
|
|
89918
90314
|
const top = rows[0];
|
|
89919
90315
|
if (!top)
|
|
89920
90316
|
return null;
|
|
@@ -90192,7 +90588,7 @@ async function resumeFlag(runId2, noPr = false, deps = {}, answer) {
|
|
|
90192
90588
|
};
|
|
90193
90589
|
const supervise = deps.supervise ?? (async (o) => (await Promise.resolve().then(() => (init_supervisor(), exports_supervisor))).runSupervisor(o));
|
|
90194
90590
|
const { exitCodeOf: exitCodeOf2 } = await Promise.resolve().then(() => (init_output(), exports_output));
|
|
90195
|
-
const res = await supervise({ runId: it2.runId, repoDir, env, resume: true, capS: capS === undefined ? undefined : Math.floor(capS), capCeilingS: ceilS === undefined ? undefined : Math.floor(ceilS), restoreBranch: origBranch, workerArgv: [process.execPath, ...SAFE_BUN_FLAGS,
|
|
90591
|
+
const res = await supervise({ runId: it2.runId, repoDir, env, resume: true, capS: capS === undefined ? undefined : Math.floor(capS), capCeilingS: ceilS === undefined ? undefined : Math.floor(ceilS), restoreBranch: origBranch, workerArgv: [process.execPath, ...SAFE_BUN_FLAGS, resolve42(process.argv[1] ?? ""), "engine10", "worker", it2.runId, provider, model, deep ? "deep" : "fast"], started: { ...st2, resumed_from: rp2.stage, ...answer !== undefined ? { answered: true, answer: redactSecrets(answer), answer_sha256: createHash41("sha256").update(redactSecrets(answer)).digest("hex"), question: String(conflictReasonOf(it2.events) ?? "the run is blocked on a spec conflict").replace(/[\x00-\x1f\x7f]+/g, " ").trim().slice(0, 500) } : {} }, pr: pr2 });
|
|
90196
90592
|
out2(`engine10: resumed run ${it2.runId}: ${res.outcome}
|
|
90197
90593
|
`);
|
|
90198
90594
|
return exitCodeOf2(res.outcome);
|
|
@@ -90524,7 +90920,7 @@ function runIntent(repoDir, env = process.env) {
|
|
|
90524
90920
|
let policy = null;
|
|
90525
90921
|
if (pf2) {
|
|
90526
90922
|
try {
|
|
90527
|
-
policy =
|
|
90923
|
+
policy = createHash41("sha256").update(readFileSync132(pf2)).digest("hex");
|
|
90528
90924
|
} catch {}
|
|
90529
90925
|
}
|
|
90530
90926
|
const parent = /^[A-Za-z0-9._-]{1,128}$/.test(env.LOKI_PARENT_RUN ?? "") ? env.LOKI_PARENT_RUN : null;
|
|
@@ -90579,7 +90975,7 @@ function issueStatusProjector(o) {
|
|
|
90579
90975
|
return r.catch(() => null);
|
|
90580
90976
|
};
|
|
90581
90977
|
}
|
|
90582
|
-
function policyGate(repoDir, action, env = process.env, checkJs =
|
|
90978
|
+
function policyGate(repoDir, action, env = process.env, checkJs = resolve42(import.meta.dir, "../../../src/policies/check.js"), timeoutMs = 30000) {
|
|
90583
90979
|
if (policyFile(repoDir, env) === null)
|
|
90584
90980
|
return { decision: "allow", reason: "no policy file" };
|
|
90585
90981
|
if (env.LOKI_POLICY_REQUIRE_NODE === "0" && spawnSync24("node", ["--version"], { env: { PATH: env.PATH }, encoding: "utf8" }).status !== 0)
|
|
@@ -90739,7 +91135,7 @@ var SEAL_ACCURACY_NOT_MEASURED = "Seal accuracy: not measured", SEAL_ACCURACY_MA
|
|
|
90739
91135
|
} catch {
|
|
90740
91136
|
return SEAL_ACCURACY_NOT_MEASURED;
|
|
90741
91137
|
}
|
|
90742
|
-
}, REVERTED = "unrelated edit reverted:", STALE_S2, isCancelDone = (e10) => e10.type === "run.completed" && e10.data["cancelled"] === true, isResumableDone = (e10) => isCancelDone(e10) || e10.type === "run.completed" && e10.data["verdict"] === "SPEC_CONFLICT", DISCARD_MARK = "discarded", isDiscarded = (runsDir, runId2) => existsSync106(join151(runsDir, runId2, DISCARD_MARK)), STAGE_ORDER, sha6 = (v) =>
|
|
91138
|
+
}, REVERTED = "unrelated edit reverted:", STALE_S2, isCancelDone = (e10) => e10.type === "run.completed" && e10.data["cancelled"] === true, isResumableDone = (e10) => isCancelDone(e10) || e10.type === "run.completed" && e10.data["verdict"] === "SPEC_CONFLICT", DISCARD_MARK = "discarded", isDiscarded = (runsDir, runId2) => existsSync106(join151(runsDir, runId2, DISCARD_MARK)), STAGE_ORDER, sha6 = (v) => createHash41("sha256").update(JSON.stringify(v) ?? "null").digest("hex"), settled = (events2, s) => events2.some((e10) => e10.stage === s && (e10.type === "stage.completed" || e10.type === "stage.skipped")), cannotResume = (out2, id2, reason) => {
|
|
90743
91139
|
out2(`resume: run ${plainLine(id2, 80)} cannot be resumed (${plainLine(reason, 400)}); its work is on branch loki/${plainLine(id2, 80)}. Start a new run: loki start <task>
|
|
90744
91140
|
`);
|
|
90745
91141
|
return 4;
|
|
@@ -90989,9 +91385,9 @@ __export(exports_verify_cmd, {
|
|
|
90989
91385
|
checkEventLog: () => checkEventLog,
|
|
90990
91386
|
checkAttestation: () => checkAttestation
|
|
90991
91387
|
});
|
|
90992
|
-
import { existsSync as existsSync108, readFileSync as readFileSync134, renameSync as renameSync26, statSync as
|
|
91388
|
+
import { existsSync as existsSync108, readFileSync as readFileSync134, renameSync as renameSync26, statSync as statSync45, writeFileSync as writeFileSync77 } from "fs";
|
|
90993
91389
|
import { basename as basename43, dirname as dirname62, join as join153 } from "path";
|
|
90994
|
-
import { createHash as
|
|
91390
|
+
import { createHash as createHash42, verify as verify5 } from "crypto";
|
|
90995
91391
|
function checkAttestation(jwt, expectedHash, given) {
|
|
90996
91392
|
const bad = (reason) => ({ status: "tampered", reason });
|
|
90997
91393
|
const [h10, p, s, ...rest] = jwt.split(".");
|
|
@@ -91022,7 +91418,7 @@ function wallTamperProblem(receiptPath, receipt) {
|
|
|
91022
91418
|
const copy = sealedWallCopy(dirname62(receiptPath), f.path);
|
|
91023
91419
|
let cur;
|
|
91024
91420
|
try {
|
|
91025
|
-
cur =
|
|
91421
|
+
cur = createHash42("sha256").update(readFileSync134(copy)).digest("hex");
|
|
91026
91422
|
} catch {
|
|
91027
91423
|
if (haveWallDir)
|
|
91028
91424
|
return `sealed Wall file ${basename43(f.path)} is missing from the run's wall directory: it was deleted after the seal`;
|
|
@@ -91044,7 +91440,7 @@ function checkEventLog(receiptPath, receipt) {
|
|
|
91044
91440
|
}
|
|
91045
91441
|
if (typeof bound !== "string")
|
|
91046
91442
|
return null;
|
|
91047
|
-
if (bound ===
|
|
91443
|
+
if (bound === createHash42("sha256").digest("hex")) {
|
|
91048
91444
|
const st2 = receipt["time"]?.stages;
|
|
91049
91445
|
const claims = st2 !== null && typeof st2 === "object" && Object.keys(st2).length > 0;
|
|
91050
91446
|
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;
|
|
@@ -91063,7 +91459,7 @@ function checkEventLog(receiptPath, receipt) {
|
|
|
91063
91459
|
return "events.jsonl has bytes the engine never writes (a blank line or stray whitespace); it was appended to after the seal";
|
|
91064
91460
|
if (events2.some((e10) => e10.type === "tamper.detected"))
|
|
91065
91461
|
return "the supervisor detected events.jsonl being modified during the run";
|
|
91066
|
-
const h10 =
|
|
91462
|
+
const h10 = createHash42("sha256");
|
|
91067
91463
|
for (const l of lines2) {
|
|
91068
91464
|
if (h10.copy().digest("hex") === bound)
|
|
91069
91465
|
return null;
|
|
@@ -91105,7 +91501,7 @@ function checkLogSeal(receiptPath, hash, kid, given) {
|
|
|
91105
91501
|
if (!d)
|
|
91106
91502
|
return { verdict: "TAMPERED", reason: "events.jsonl has no signed log.sealed line after run.completed" };
|
|
91107
91503
|
const lines2 = readFileSync134(path, "utf8").split(`
|
|
91108
|
-
`).filter((l) => l.trim() !== ""), sha7 =
|
|
91504
|
+
`).filter((l) => l.trim() !== ""), sha7 = createHash42("sha256").update(lines2.slice(0, done + 1).join(`
|
|
91109
91505
|
`) + `
|
|
91110
91506
|
`).digest("hex");
|
|
91111
91507
|
const pub = d["kid"] === kid ? pubFor(kid, given) : undefined;
|
|
@@ -91304,7 +91700,7 @@ ${/^(unknown option|expected at most one)/.test(pk2.error) ? `Usage: loki verify
|
|
|
91304
91700
|
if (!runId2)
|
|
91305
91701
|
return process.stderr.write(`loki verify: no runs found
|
|
91306
91702
|
`), 66;
|
|
91307
|
-
const isFile = existsSync108(runId2) &&
|
|
91703
|
+
const isFile = existsSync108(runId2) && statSync45(runId2).isFile();
|
|
91308
91704
|
const isPath = isFile || /[\\/]/.test(runId2) || runId2.endsWith(".json");
|
|
91309
91705
|
const receiptPath = isPath ? runId2 : join153(runsRoot2, runId2, "receipt.json");
|
|
91310
91706
|
const byRunId = !isPath;
|
|
@@ -91450,8 +91846,8 @@ var init_verify_cmd = __esm(() => {
|
|
|
91450
91846
|
});
|
|
91451
91847
|
|
|
91452
91848
|
// src/server/app.ts
|
|
91453
|
-
import { existsSync as existsSync110, readFileSync as readFileSync137, statSync as
|
|
91454
|
-
import { join as join156, resolve as
|
|
91849
|
+
import { existsSync as existsSync110, readFileSync as readFileSync137, statSync as statSync46 } from "fs";
|
|
91850
|
+
import { join as join156, resolve as resolve43, sep as sep27 } from "path";
|
|
91455
91851
|
|
|
91456
91852
|
// node_modules/hono/dist/request/constants.js
|
|
91457
91853
|
var GET_MATCH_RESULT = Symbol();
|
|
@@ -101901,7 +102297,7 @@ function mount20(ctx) {
|
|
|
101901
102297
|
}
|
|
101902
102298
|
|
|
101903
102299
|
// src/server/routes/verify.ts
|
|
101904
|
-
import { readFileSync as readFileSync135, realpathSync as
|
|
102300
|
+
import { readFileSync as readFileSync135, realpathSync as realpathSync38 } from "fs";
|
|
101905
102301
|
import { createPublicKey as createPublicKey8 } from "crypto";
|
|
101906
102302
|
import { join as join154, sep as sep26 } from "path";
|
|
101907
102303
|
init_verify_cmd();
|
|
@@ -101930,11 +102326,11 @@ function mount21(ctx) {
|
|
|
101930
102326
|
return done(404, "receipt not available", "not_found");
|
|
101931
102327
|
let runDir, file;
|
|
101932
102328
|
try {
|
|
101933
|
-
const root =
|
|
101934
|
-
runDir =
|
|
102329
|
+
const root = realpathSync38(join154(repo.p, ".loki", "runs"));
|
|
102330
|
+
runDir = realpathSync38(join154(root, run2));
|
|
101935
102331
|
if (runDir !== join154(root, run2))
|
|
101936
102332
|
return done(404, "receipt not found", "not_found");
|
|
101937
|
-
file =
|
|
102333
|
+
file = realpathSync38(join154(runDir, "receipt.json"));
|
|
101938
102334
|
} catch {
|
|
101939
102335
|
return done(404, "receipt not found", "not_found");
|
|
101940
102336
|
}
|
|
@@ -102720,9 +103116,9 @@ function createApp(opts) {
|
|
|
102720
103116
|
}
|
|
102721
103117
|
if (!uiDir || p.startsWith("/v1/"))
|
|
102722
103118
|
return c.json({ error: "not found" }, 404);
|
|
102723
|
-
const root =
|
|
102724
|
-
const f =
|
|
102725
|
-
if (f.startsWith(root + sep27) && existsSync110(f) &&
|
|
103119
|
+
const root = resolve43(uiDir);
|
|
103120
|
+
const f = resolve43(root, `.${p}`);
|
|
103121
|
+
if (f.startsWith(root + sep27) && existsSync110(f) && statSync46(f).isFile())
|
|
102726
103122
|
return new Response(Bun.file(f));
|
|
102727
103123
|
if (/\.[a-z0-9]+$/i.test(p))
|
|
102728
103124
|
return c.json({ error: "not found" }, 404);
|