loki-mode 11.67.1 → 11.67.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SKILL.md +2 -2
- package/VERSION +1 -1
- package/dashboard/__init__.py +1 -1
- package/docs/CLI-REFERENCE.md +1 -1
- package/docs/INSTALLATION.md +1 -1
- package/docs/v10/FAILURE-CLASSES.md +9 -0
- package/loki-ts/dist/loki.js +993 -993
- package/mcp/__init__.py +1 -1
- package/package.json +2 -2
- package/packages/control-plane/dist/server.js +251 -237
- package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
- package/web-app/dist/assets/{AdminPage-BtVpg8_T.js → AdminPage-C46ofbAS.js} +1 -1
- package/web-app/dist/assets/{Avatar-C3I7YiJ1.js → Avatar-Bp9Qz0dU.js} +1 -1
- package/web-app/dist/assets/{Badge-DsjUF4b1.js → Badge-CntbV0CS.js} +1 -1
- package/web-app/dist/assets/{Button-Cv_fLuDO.js → Button-Du8pRb9b.js} +1 -1
- package/web-app/dist/assets/{CockpitPage-CPccpsAb.js → CockpitPage-D64LrM01.js} +1 -1
- package/web-app/dist/assets/{ComparePage-Bg0PwPg5.js → ComparePage-YtT-xUEo.js} +1 -1
- package/web-app/dist/assets/{ErrorBoundary-CCDg-ONt.js → ErrorBoundary-D7I4Ti8h.js} +1 -1
- package/web-app/dist/assets/{EvidenceReceiptPanel-8_bvJsKL.js → EvidenceReceiptPanel-ChoNUIfD.js} +1 -1
- package/web-app/dist/assets/{GitHubIssuesPanel-Dx7gh4rO.js → GitHubIssuesPanel-DGf0NDBc.js} +1 -1
- package/web-app/dist/assets/{GitHubPRsPanel-CnLE8VPU.js → GitHubPRsPanel-BUiIb7mj.js} +1 -1
- package/web-app/dist/assets/{HomePage-zENRZ2D1.js → HomePage-DhY0jzM-.js} +2 -2
- package/web-app/dist/assets/{LoginPage-BiOqKbkH.js → LoginPage-ssyJUT0E.js} +1 -1
- package/web-app/dist/assets/{MagicPage-jLmkP87D.js → MagicPage-PF08_HMv.js} +1 -1
- package/web-app/dist/assets/{MetricsPage-CVEoZoC6.js → MetricsPage-CiM5zWdx.js} +1 -1
- package/web-app/dist/assets/{NotFoundPage-mmQRmD8R.js → NotFoundPage-B6Q6Dstc.js} +1 -1
- package/web-app/dist/assets/{ProjectPage-CJmupIud.js → ProjectPage-DVfoHpwd.js} +3 -3
- package/web-app/dist/assets/{ProjectsPage-BARdLMPp.js → ProjectsPage-CMZR9FUb.js} +1 -1
- package/web-app/dist/assets/{SettingsPage-Cmrmt2KR.js → SettingsPage-CAVhgiv1.js} +1 -1
- package/web-app/dist/assets/{ShowcasePage-uwsZdS5N.js → ShowcasePage-D88jHQg7.js} +1 -1
- package/web-app/dist/assets/{SystemSettingsPage-7tt-pqsE.js → SystemSettingsPage-D64iaP56.js} +1 -1
- package/web-app/dist/assets/{TeamsPage-CQDznmbk.js → TeamsPage-BjZQpwig.js} +1 -1
- package/web-app/dist/assets/{TemplatesPage-DvUcZiJJ.js → TemplatesPage-BISgULi2.js} +1 -1
- package/web-app/dist/assets/{TerminalOutput-CsnBC0fm.js → TerminalOutput-C0SV10LP.js} +1 -1
- package/web-app/dist/assets/{activity-B0fkdbAZ.js → activity-CT_J0Cnm.js} +1 -1
- package/web-app/dist/assets/{bell-Cmx08Gc7.js → bell-DNx5Zzgl.js} +1 -1
- package/web-app/dist/assets/{bot-mHlwlDBE.js → bot-V7Uwf3WI.js} +1 -1
- package/web-app/dist/assets/{check-CHbtOnFG.js → check-C5RjHdKz.js} +1 -1
- package/web-app/dist/assets/{chevron-left-CmaIVO-9.js → chevron-left-CnBKrgil.js} +1 -1
- package/web-app/dist/assets/{circle-alert-CleAQ1iS.js → circle-alert-CP4nyfvZ.js} +1 -1
- package/web-app/dist/assets/{clock-BZNwavS8.js → clock-CtB1ycFb.js} +1 -1
- package/web-app/dist/assets/{cloud-DmPDssWE.js → cloud-ujqDHiyy.js} +1 -1
- package/web-app/dist/assets/{code-xml-C1wP07qL.js → code-xml-Btu0XbN2.js} +1 -1
- package/web-app/dist/assets/{database-Cudj812p.js → database-BQAmZq9h.js} +1 -1
- package/web-app/dist/assets/{dollar-sign-ClfPDwwb.js → dollar-sign-DSGZce3f.js} +1 -1
- package/web-app/dist/assets/{file-code-corner-BjLiR_DM.js → file-code-corner-b_bfd3oV.js} +1 -1
- package/web-app/dist/assets/{file-plus-B3S15wdF.js → file-plus-CeQts95h.js} +1 -1
- package/web-app/dist/assets/{globe-FLJd7IqB.js → globe-DgYnTtw-.js} +1 -1
- package/web-app/dist/assets/{hammer-uXcz6raP.js → hammer-Bqw9qf2F.js} +1 -1
- package/web-app/dist/assets/{index-8LjkUT_r.js → index-B2nulMlN.js} +3 -3
- package/web-app/dist/assets/{layers-BPi2kYUA.js → layers-CkfP4OPt.js} +1 -1
- package/web-app/dist/assets/{loader-circle-BI5Jgauk.js → loader-circle-gzlKNTSg.js} +1 -1
- package/web-app/dist/assets/{lock-XYI8VTfk.js → lock-BScSvL3k.js} +1 -1
- package/web-app/dist/assets/{package-D5dabXGu.js → package-C0NHBtGA.js} +1 -1
- package/web-app/dist/assets/{plus-C3uOyi3T.js → plus-DdG6h339.js} +1 -1
- package/web-app/dist/assets/{refresh-cw-emf7OJ8L.js → refresh-cw-BCQ_2rt4.js} +1 -1
- package/web-app/dist/assets/{rotate-ccw-BHrmxW3U.js → rotate-ccw-C82d01Lo.js} +1 -1
- package/web-app/dist/assets/{scroll-text-0AFHZ8SW.js → scroll-text-n8cDoTat.js} +1 -1
- package/web-app/dist/assets/{server-DNeU7_2A.js → server-B7VIlROY.js} +1 -1
- package/web-app/dist/assets/{shield-alert-DnACnSDh.js → shield-alert-CemksL-g.js} +1 -1
- package/web-app/dist/assets/{thumbs-up-BjHFuW7u.js → thumbs-up-Hf2d2pqV.js} +1 -1
- package/web-app/dist/assets/{trash-2-BdNn79gn.js → trash-2-D9n8zTsp.js} +1 -1
- package/web-app/dist/assets/{trending-down-LQcvJtlW.js → trending-down-CjGJv4rE.js} +1 -1
- package/web-app/dist/assets/{trending-up-DnAsnTeg.js → trending-up-BWXaHJzW.js} +1 -1
- package/web-app/dist/assets/{upload-CywYeREK.js → upload-JTugBdNT.js} +1 -1
- package/web-app/dist/assets/{usePolling-B7sPkY8h.js → usePolling-Dyx97zW4.js} +1 -1
- package/web-app/dist/assets/{user-oYnoDRHM.js → user-DUivgQ1A.js} +1 -1
- package/web-app/dist/index.html +1 -1
|
@@ -7649,33 +7649,10 @@ var init_paths = __esm(() => {
|
|
|
7649
7649
|
REPO_ROOT = findRepoRoot();
|
|
7650
7650
|
});
|
|
7651
7651
|
|
|
7652
|
-
// ../../loki-ts/src/
|
|
7652
|
+
// ../../loki-ts/src/util/producer_fingerprint.ts
|
|
7653
7653
|
import { createHash as createHash6 } from "crypto";
|
|
7654
|
-
import {
|
|
7655
|
-
import {
|
|
7656
|
-
function repoKey(originUrl, repoDir) {
|
|
7657
|
-
const basis = originUrl && originUrl.trim() !== "" ? originUrl : resolve8(repoDir);
|
|
7658
|
-
return createHash6("sha256").update(basis).digest("hex");
|
|
7659
|
-
}
|
|
7660
|
-
function defaultCacheRoot() {
|
|
7661
|
-
return resolve8(homeLokiDir(), "cache", "v10");
|
|
7662
|
-
}
|
|
7663
|
-
function repoCacheDir(key, cacheRoot = defaultCacheRoot()) {
|
|
7664
|
-
return resolve8(cacheRoot, key);
|
|
7665
|
-
}
|
|
7666
|
-
function readJson3(path, isValid = (_v) => true) {
|
|
7667
|
-
if (!existsSync15(path))
|
|
7668
|
-
return null;
|
|
7669
|
-
try {
|
|
7670
|
-
const parsed = JSON.parse(readFileSync18(path, "utf8"));
|
|
7671
|
-
return isValid(parsed) ? parsed : null;
|
|
7672
|
-
} catch {
|
|
7673
|
-
return null;
|
|
7674
|
-
}
|
|
7675
|
-
}
|
|
7676
|
-
function isRepoMap(v) {
|
|
7677
|
-
return typeof v === "object" && v !== null && Array.isArray(v.files) && Array.isArray(v.entries);
|
|
7678
|
-
}
|
|
7654
|
+
import { readdirSync as readdirSync9, readFileSync as readFileSync18 } from "fs";
|
|
7655
|
+
import { relative, resolve as resolve8 } from "path";
|
|
7679
7656
|
function sourceFingerprint(root) {
|
|
7680
7657
|
const h = createHash6("sha256");
|
|
7681
7658
|
const walk = (dir) => {
|
|
@@ -7703,9 +7680,40 @@ function computeProducerFingerprint(root = resolve8(import.meta.dir, ".."), inje
|
|
|
7703
7680
|
function producerFingerprint() {
|
|
7704
7681
|
return producerFp ??= computeProducerFingerprint();
|
|
7705
7682
|
}
|
|
7706
|
-
var producerFp = null
|
|
7683
|
+
var producerFp = null;
|
|
7684
|
+
var init_producer_fingerprint = () => {};
|
|
7685
|
+
|
|
7686
|
+
// ../../loki-ts/src/engine10/cache.ts
|
|
7687
|
+
import { createHash as createHash7 } from "crypto";
|
|
7688
|
+
import { chmodSync as chmodSync4, existsSync as existsSync15, mkdirSync as mkdirSync5, readdirSync as readdirSync10, readFileSync as readFileSync19, renameSync as renameSync4, statSync as statSync12, unlinkSync as unlinkSync3, writeFileSync as writeFileSync8 } from "fs";
|
|
7689
|
+
import { basename as basename8, resolve as resolve9 } from "path";
|
|
7690
|
+
function repoKey(originUrl, repoDir) {
|
|
7691
|
+
const basis = originUrl && originUrl.trim() !== "" ? originUrl : resolve9(repoDir);
|
|
7692
|
+
return createHash7("sha256").update(basis).digest("hex");
|
|
7693
|
+
}
|
|
7694
|
+
function defaultCacheRoot() {
|
|
7695
|
+
return resolve9(homeLokiDir(), "cache", "v10");
|
|
7696
|
+
}
|
|
7697
|
+
function repoCacheDir(key, cacheRoot = defaultCacheRoot()) {
|
|
7698
|
+
return resolve9(cacheRoot, key);
|
|
7699
|
+
}
|
|
7700
|
+
function readJson3(path, isValid = (_v) => true) {
|
|
7701
|
+
if (!existsSync15(path))
|
|
7702
|
+
return null;
|
|
7703
|
+
try {
|
|
7704
|
+
const parsed = JSON.parse(readFileSync19(path, "utf8"));
|
|
7705
|
+
return isValid(parsed) ? parsed : null;
|
|
7706
|
+
} catch {
|
|
7707
|
+
return null;
|
|
7708
|
+
}
|
|
7709
|
+
}
|
|
7710
|
+
function isRepoMap(v) {
|
|
7711
|
+
return typeof v === "object" && v !== null && Array.isArray(v.files) && Array.isArray(v.entries);
|
|
7712
|
+
}
|
|
7713
|
+
var cacheFileName = (kind, tree, fp = producerFingerprint()) => `${kind}-${fp.slice(0, 16)}-${tree}.json`, readRepoMapCache = (dir, tree, fp = producerFingerprint()) => readJson3(resolve9(dir, cacheFileName("repomap", tree, fp)), isRepoMap);
|
|
7707
7714
|
var init_cache = __esm(() => {
|
|
7708
7715
|
init_paths();
|
|
7716
|
+
init_producer_fingerprint();
|
|
7709
7717
|
});
|
|
7710
7718
|
|
|
7711
7719
|
// ../../loki-ts/src/engine10/repomap.ts
|
|
@@ -7818,12 +7826,12 @@ var init_lean_select = __esm(() => {
|
|
|
7818
7826
|
});
|
|
7819
7827
|
|
|
7820
7828
|
// ../../loki-ts/src/util/claude_model.ts
|
|
7821
|
-
import { readFileSync as
|
|
7822
|
-
import { resolve as
|
|
7829
|
+
import { readFileSync as readFileSync20 } from "fs";
|
|
7830
|
+
import { resolve as resolve10 } from "path";
|
|
7823
7831
|
function resolveClaudeModel(want) {
|
|
7824
7832
|
try {
|
|
7825
|
-
const path = process.env["LOKI_MODEL_CATALOG"] ||
|
|
7826
|
-
return JSON.parse(
|
|
7833
|
+
const path = process.env["LOKI_MODEL_CATALOG"] || resolve10(REPO_ROOT, "providers/model_catalog.json");
|
|
7834
|
+
return JSON.parse(readFileSync20(path, "utf8")).providers?.claude?.cli_aliases?.[want] ?? want;
|
|
7827
7835
|
} catch {
|
|
7828
7836
|
return want;
|
|
7829
7837
|
}
|
|
@@ -7900,18 +7908,18 @@ var init_price_table = __esm(() => {
|
|
|
7900
7908
|
});
|
|
7901
7909
|
|
|
7902
7910
|
// ../../loki-ts/src/providers/provider_cost.ts
|
|
7903
|
-
import { existsSync as existsSync16, mkdirSync as mkdirSync6, readdirSync as
|
|
7911
|
+
import { existsSync as existsSync16, mkdirSync as mkdirSync6, readdirSync as readdirSync11, readFileSync as readFileSync21, renameSync as renameSync5, writeFileSync as writeFileSync9 } from "fs";
|
|
7904
7912
|
import { dirname as dirname7, join as join27 } from "path";
|
|
7905
7913
|
function withArchivedCosts(lokiRoot, ids, keep = () => true) {
|
|
7906
7914
|
let files = [];
|
|
7907
7915
|
try {
|
|
7908
|
-
files =
|
|
7916
|
+
files = readdirSync11(join27(lokiRoot, "metrics"));
|
|
7909
7917
|
} catch {}
|
|
7910
7918
|
return [...new Set([...ids, ...ids.flatMap((id) => files.filter((f) => f.startsWith(`result-cost-${id}-q`) && f.endsWith(".json")).map((f) => f.slice("result-cost-".length, -".json".length)).filter(keep))])];
|
|
7911
7919
|
}
|
|
7912
7920
|
function neverRan(path, unmeteredMarker) {
|
|
7913
7921
|
try {
|
|
7914
|
-
const r = JSON.parse(
|
|
7922
|
+
const r = JSON.parse(readFileSync21(path, "utf8")), n2 = (v) => typeof v === "number" && Number.isFinite(v) ? v : 0;
|
|
7915
7923
|
return r["total_cost_usd"] === 0 && r["source"] !== unmeteredMarker && ["input_tokens", "output_tokens", "cache_read_tokens", "cache_creation_tokens"].every((k) => n2(r[k]) === 0);
|
|
7916
7924
|
} catch {
|
|
7917
7925
|
return false;
|
|
@@ -7928,13 +7936,13 @@ var init_provider_cost = __esm(() => {
|
|
|
7928
7936
|
});
|
|
7929
7937
|
|
|
7930
7938
|
// ../../loki-ts/src/providers/model_routes.ts
|
|
7931
|
-
import { readFileSync as
|
|
7932
|
-
import { dirname as dirname8, resolve as
|
|
7939
|
+
import { readFileSync as readFileSync22 } from "fs";
|
|
7940
|
+
import { dirname as dirname8, resolve as resolve11 } from "path";
|
|
7933
7941
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
7934
7942
|
function inferenceGeoTable() {
|
|
7935
7943
|
try {
|
|
7936
|
-
const p =
|
|
7937
|
-
const t = JSON.parse(
|
|
7944
|
+
const p = resolve11(dirname8(fileURLToPath2(import.meta.url)), "..", "..", "data", "model-pricing.json");
|
|
7945
|
+
const t = JSON.parse(readFileSync22(p, "utf8")).inference_geo_multipliers;
|
|
7938
7946
|
if (t && typeof t === "object")
|
|
7939
7947
|
return t;
|
|
7940
7948
|
} catch {}
|
|
@@ -7970,7 +7978,7 @@ function advisorOnlyEnabled(env = process.env) {
|
|
|
7970
7978
|
var routerEnabled = (env = process.env) => routerMode(env) === "on", sessionPlanEnabled = (env = process.env) => routerEnabled(env) || advisorOnlyEnabled(env);
|
|
7971
7979
|
|
|
7972
7980
|
// ../../loki-ts/src/engine10/cost.ts
|
|
7973
|
-
import { readdirSync as
|
|
7981
|
+
import { readdirSync as readdirSync12, readFileSync as readFileSync23 } from "fs";
|
|
7974
7982
|
import { join as join28 } from "path";
|
|
7975
7983
|
function routerTelemetryOn(env = process.env) {
|
|
7976
7984
|
return sessionPlanEnabled(env);
|
|
@@ -8010,7 +8018,7 @@ function sumResultCosts(lokiRoot, iterations, context = []) {
|
|
|
8010
8018
|
const parsed = new Map;
|
|
8011
8019
|
for (const iter of iterations) {
|
|
8012
8020
|
try {
|
|
8013
|
-
parsed.set(iter, JSON.parse(
|
|
8021
|
+
parsed.set(iter, JSON.parse(readFileSync23(resultCostPath(lokiRoot, iter), "utf8")));
|
|
8014
8022
|
} catch {}
|
|
8015
8023
|
}
|
|
8016
8024
|
const own = new Set(iterations);
|
|
@@ -8019,7 +8027,7 @@ function sumResultCosts(lokiRoot, iterations, context = []) {
|
|
|
8019
8027
|
if (own.has(iter))
|
|
8020
8028
|
continue;
|
|
8021
8029
|
try {
|
|
8022
|
-
lookup.push({ iter, rec: JSON.parse(
|
|
8030
|
+
lookup.push({ iter, rec: JSON.parse(readFileSync23(resultCostPath(lokiRoot, iter), "utf8")) });
|
|
8023
8031
|
} catch {}
|
|
8024
8032
|
}
|
|
8025
8033
|
const verdicts = hooks.costRecords?.resumeVerdicts(lookup) ?? { ambiguous: [], separate: [] };
|
|
@@ -8312,21 +8320,21 @@ var init_atomic = __esm(() => {
|
|
|
8312
8320
|
});
|
|
8313
8321
|
|
|
8314
8322
|
// ../../loki-ts/src/runner/budget.ts
|
|
8315
|
-
import { existsSync as existsSync17, mkdirSync as mkdirSync9, readdirSync as
|
|
8316
|
-
import { dirname as dirname10, join as join29, resolve as
|
|
8323
|
+
import { existsSync as existsSync17, mkdirSync as mkdirSync9, readdirSync as readdirSync13, readFileSync as readFileSync24, writeFileSync as writeFileSync12 } from "fs";
|
|
8324
|
+
import { dirname as dirname10, join as join29, resolve as resolve12 } from "path";
|
|
8317
8325
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
8318
8326
|
function loadDefaultMaxCostUsd(dataDirs = [["..", "..", "data"], ["..", "data"]]) {
|
|
8319
8327
|
const here = dirname10(fileURLToPath3(import.meta.url));
|
|
8320
8328
|
for (const rel of dataDirs) {
|
|
8321
8329
|
try {
|
|
8322
|
-
const j = JSON.parse(
|
|
8330
|
+
const j = JSON.parse(readFileSync24(resolve12(here, ...rel, "model-pricing.json"), "utf8"));
|
|
8323
8331
|
if (typeof j.default_max_cost_usd === "number" && Number.isFinite(j.default_max_cost_usd) && j.default_max_cost_usd > 0)
|
|
8324
8332
|
return j.default_max_cost_usd;
|
|
8325
8333
|
} catch {}
|
|
8326
8334
|
}
|
|
8327
8335
|
if (!pricingFallbackWarned) {
|
|
8328
8336
|
pricingFallbackWarned = true;
|
|
8329
|
-
process.stderr.write(`loki: warning: model-pricing.json is missing or unreadable (looked in ${dataDirs.map((r) =>
|
|
8337
|
+
process.stderr.write(`loki: warning: model-pricing.json is missing or unreadable (looked in ${dataDirs.map((r) => resolve12(here, ...r)).join(", ")}); using fallback default max cost $${DEFAULT_FALLBACK_USD}
|
|
8330
8338
|
`);
|
|
8331
8339
|
}
|
|
8332
8340
|
return DEFAULT_FALLBACK_USD;
|
|
@@ -8334,10 +8342,10 @@ function loadDefaultMaxCostUsd(dataDirs = [["..", "..", "data"], ["..", "data"]]
|
|
|
8334
8342
|
function _loadPricing() {
|
|
8335
8343
|
try {
|
|
8336
8344
|
const moduleDir = dirname10(fileURLToPath3(import.meta.url));
|
|
8337
|
-
const jsonPath =
|
|
8345
|
+
const jsonPath = resolve12(moduleDir, "..", "..", "data", "model-pricing.json");
|
|
8338
8346
|
if (!existsSync17(jsonPath))
|
|
8339
8347
|
return _FALLBACK_PRICING;
|
|
8340
|
-
const raw2 = JSON.parse(
|
|
8348
|
+
const raw2 = JSON.parse(readFileSync24(jsonPath, "utf8"));
|
|
8341
8349
|
const pricing2 = raw2["pricing"];
|
|
8342
8350
|
if (!pricing2 || typeof pricing2 !== "object")
|
|
8343
8351
|
return _FALLBACK_PRICING;
|
|
@@ -8648,8 +8656,8 @@ var init_schema = __esm(() => {
|
|
|
8648
8656
|
});
|
|
8649
8657
|
|
|
8650
8658
|
// ../../loki-ts/src/runner/router/history_store.ts
|
|
8651
|
-
import { existsSync as existsSync19, mkdirSync as mkdirSync10, readFileSync as
|
|
8652
|
-
import { resolve as
|
|
8659
|
+
import { existsSync as existsSync19, mkdirSync as mkdirSync10, readFileSync as readFileSync25, renameSync as renameSync7, rmSync as rmSync6, writeFileSync as writeFileSync13 } from "fs";
|
|
8660
|
+
import { resolve as resolve13 } from "path";
|
|
8653
8661
|
function validRun(v) {
|
|
8654
8662
|
if (typeof v !== "object" || v === null)
|
|
8655
8663
|
return false;
|
|
@@ -8657,14 +8665,14 @@ function validRun(v) {
|
|
|
8657
8665
|
return typeof r["shape"] === "string" && typeof r["executor"] === "string" && EXECUTORS.includes(r["executor"]) && typeof r["verdict"] === "string" && VERDICTS.includes(r["verdict"]) && (r["owner"] === null || typeof r["owner"] === "string" && OWNERS.includes(r["owner"])) && typeof r["escalated"] === "boolean" && typeof r["usd"] === "number" && Number.isFinite(r["usd"]) && typeof r["wallS"] === "number" && Number.isFinite(r["wallS"]);
|
|
8658
8666
|
}
|
|
8659
8667
|
function historyPath(key, cacheRoot) {
|
|
8660
|
-
return
|
|
8668
|
+
return resolve13(repoCacheDir(key, cacheRoot), HISTORY_FILE);
|
|
8661
8669
|
}
|
|
8662
8670
|
function readRunHistory(key, cacheRoot) {
|
|
8663
8671
|
const path = historyPath(key, cacheRoot);
|
|
8664
8672
|
if (!existsSync19(path))
|
|
8665
8673
|
return [];
|
|
8666
8674
|
try {
|
|
8667
|
-
const parsed = JSON.parse(
|
|
8675
|
+
const parsed = JSON.parse(readFileSync25(path, "utf8"));
|
|
8668
8676
|
const runs2 = parsed?.runs;
|
|
8669
8677
|
return Array.isArray(runs2) ? runs2.filter(validRun) : [];
|
|
8670
8678
|
} catch {
|
|
@@ -8701,8 +8709,8 @@ var init_history_store = __esm(() => {
|
|
|
8701
8709
|
});
|
|
8702
8710
|
|
|
8703
8711
|
// ../../loki-ts/src/project_model/gather.ts
|
|
8704
|
-
import { createHash as
|
|
8705
|
-
import { closeSync as closeSync6, lstatSync as lstatSync7, openSync as openSync6, readFileSync as
|
|
8712
|
+
import { createHash as createHash8 } from "crypto";
|
|
8713
|
+
import { closeSync as closeSync6, lstatSync as lstatSync7, openSync as openSync6, readFileSync as readFileSync26, readSync as readSync5 } from "fs";
|
|
8706
8714
|
import { dirname as dirname11, join as join31 } from "path";
|
|
8707
8715
|
function listShallow(repoDir) {
|
|
8708
8716
|
try {
|
|
@@ -8716,7 +8724,7 @@ function shallowDirs(repoDir) {
|
|
|
8716
8724
|
return [...new Set(listShallow(repoDir).map((p) => dirname11(p)))].sort();
|
|
8717
8725
|
}
|
|
8718
8726
|
function computeKey(repoDir, fingerprintFiles, dirs, committedHash = null) {
|
|
8719
|
-
const h =
|
|
8727
|
+
const h = createHash8("sha256");
|
|
8720
8728
|
h.update(`${MODEL_REV}
|
|
8721
8729
|
`);
|
|
8722
8730
|
if (committedHash !== null)
|
|
@@ -8731,7 +8739,7 @@ function computeKey(repoDir, fingerprintFiles, dirs, committedHash = null) {
|
|
|
8731
8739
|
else {
|
|
8732
8740
|
const abs = join31(repoDir, f);
|
|
8733
8741
|
const size = lstatSync7(abs).size;
|
|
8734
|
-
h.update(size <= GATHER_CAPS.maxHashBytes ?
|
|
8742
|
+
h.update(size <= GATHER_CAPS.maxHashBytes ? readFileSync26(abs) : `too-large:${size}`);
|
|
8735
8743
|
}
|
|
8736
8744
|
} catch {
|
|
8737
8745
|
h.update("missing");
|
|
@@ -8756,7 +8764,7 @@ function committedModelHash(raw2) {
|
|
|
8756
8764
|
if (typeof raw2 !== "object" || raw2 === null || Array.isArray(raw2))
|
|
8757
8765
|
return null;
|
|
8758
8766
|
const { key: _key, expiresAt: _exp, ...rest } = raw2;
|
|
8759
|
-
return
|
|
8767
|
+
return createHash8("sha256").update(JSON.stringify(rest)).digest("hex");
|
|
8760
8768
|
}
|
|
8761
8769
|
var GATHER_CAPS, depthOf = (p) => p.split("/").length, MODEL_REV = "model-rev:2";
|
|
8762
8770
|
var init_gather = __esm(() => {
|
|
@@ -8913,7 +8921,7 @@ var init_engine_origin = __esm(() => {
|
|
|
8913
8921
|
});
|
|
8914
8922
|
|
|
8915
8923
|
// ../../loki-ts/src/runner/router/history.ts
|
|
8916
|
-
import { dirname as dirname12, join as join32, resolve as
|
|
8924
|
+
import { dirname as dirname12, join as join32, resolve as resolve14 } from "path";
|
|
8917
8925
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
8918
8926
|
function shapeKey(model) {
|
|
8919
8927
|
if (!model || model.status !== "ok")
|
|
@@ -8945,7 +8953,7 @@ var init_history = __esm(() => {
|
|
|
8945
8953
|
init_cache();
|
|
8946
8954
|
init_engine_origin();
|
|
8947
8955
|
init_history_store();
|
|
8948
|
-
SHAPE_DEFAULTS_FILE =
|
|
8956
|
+
SHAPE_DEFAULTS_FILE = resolve14(dirname12(fileURLToPath4(import.meta.url)), "..", "..", "..", "data", "router-shape-defaults.json");
|
|
8949
8957
|
});
|
|
8950
8958
|
|
|
8951
8959
|
// ../../loki-ts/src/runner/router/unit_model.ts
|
|
@@ -8972,7 +8980,7 @@ var init_mcp_config = __esm(() => {
|
|
|
8972
8980
|
});
|
|
8973
8981
|
|
|
8974
8982
|
// ../../loki-ts/src/providers/claude_flags.ts
|
|
8975
|
-
import { existsSync as existsSync20, readFileSync as
|
|
8983
|
+
import { existsSync as existsSync20, readFileSync as readFileSync27 } from "fs";
|
|
8976
8984
|
import { resolve as resolvePath, dirname as dirname13 } from "path";
|
|
8977
8985
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
8978
8986
|
function claudeFlagSupported(flag, helpText) {
|
|
@@ -9027,7 +9035,7 @@ function designArchetypesText() {
|
|
|
9027
9035
|
]) {
|
|
9028
9036
|
const p = resolvePath(moduleDir, ...rel);
|
|
9029
9037
|
if (existsSync20(p))
|
|
9030
|
-
return
|
|
9038
|
+
return readFileSync27(p, "utf8");
|
|
9031
9039
|
}
|
|
9032
9040
|
} catch {}
|
|
9033
9041
|
return "";
|
|
@@ -9208,7 +9216,7 @@ var init_model_rank = __esm(() => {
|
|
|
9208
9216
|
});
|
|
9209
9217
|
|
|
9210
9218
|
// ../../loki-ts/src/engine10/sizing.ts
|
|
9211
|
-
import { existsSync as existsSync21, readFileSync as
|
|
9219
|
+
import { existsSync as existsSync21, readFileSync as readFileSync28 } from "fs";
|
|
9212
9220
|
import { basename as basename9 } from "path";
|
|
9213
9221
|
function namedFiles(task, map) {
|
|
9214
9222
|
return (map?.files ?? []).filter((f) => task.toLowerCase().includes(basename9(f).toLowerCase()));
|
|
@@ -9230,7 +9238,7 @@ function sizeTask(task, map, tests) {
|
|
|
9230
9238
|
}
|
|
9231
9239
|
function loadRepoMap(repomapRef) {
|
|
9232
9240
|
try {
|
|
9233
|
-
return repomapRef && existsSync21(repomapRef) ? JSON.parse(
|
|
9241
|
+
return repomapRef && existsSync21(repomapRef) ? JSON.parse(readFileSync28(repomapRef, "utf8")) : null;
|
|
9234
9242
|
} catch {
|
|
9235
9243
|
return null;
|
|
9236
9244
|
}
|
|
@@ -9292,14 +9300,14 @@ var init_model_downgrades = __esm(() => {
|
|
|
9292
9300
|
});
|
|
9293
9301
|
|
|
9294
9302
|
// ../../loki-ts/src/project_model/discover.ts
|
|
9295
|
-
import { existsSync as existsSync22, mkdirSync as mkdirSync11, readFileSync as
|
|
9303
|
+
import { existsSync as existsSync22, mkdirSync as mkdirSync11, readFileSync as readFileSync29, rmSync as rmSync7, writeFileSync as writeFileSync14 } from "fs";
|
|
9296
9304
|
import { join as join34 } from "path";
|
|
9297
9305
|
function projectModelEnabled(env = process.env) {
|
|
9298
9306
|
return env["LOKI_E10_PROJECT_MODEL"] !== "0";
|
|
9299
9307
|
}
|
|
9300
9308
|
function loadCached(repoDir, now2 = Date.now()) {
|
|
9301
9309
|
try {
|
|
9302
|
-
return parseCached(repoDir, JSON.parse(
|
|
9310
|
+
return parseCached(repoDir, JSON.parse(readFileSync29(join34(repoDir, PROJECT_FILE), "utf8")), now2);
|
|
9303
9311
|
} catch {
|
|
9304
9312
|
return null;
|
|
9305
9313
|
}
|
|
@@ -9314,7 +9322,7 @@ function loadCommitted(repoDir) {
|
|
|
9314
9322
|
};
|
|
9315
9323
|
let raw2;
|
|
9316
9324
|
try {
|
|
9317
|
-
raw2 = JSON.parse(
|
|
9325
|
+
raw2 = JSON.parse(readFileSync29(join34(repoDir, PROJECT_FILE), "utf8"));
|
|
9318
9326
|
} catch (e) {
|
|
9319
9327
|
return ignore(`unreadable JSON (${e instanceof Error ? e.message : String(e)})`);
|
|
9320
9328
|
}
|
|
@@ -9455,7 +9463,7 @@ var init_test_file_text = __esm(() => {
|
|
|
9455
9463
|
});
|
|
9456
9464
|
|
|
9457
9465
|
// ../../loki-ts/src/engine10/testmap.ts
|
|
9458
|
-
import { existsSync as existsSync23, readFileSync as
|
|
9466
|
+
import { existsSync as existsSync23, readFileSync as readFileSync30, realpathSync as realpathSync15 } from "fs";
|
|
9459
9467
|
import { basename as basename11, dirname as dirname14, extname, isAbsolute as isAbsolute2, join as join36, relative as relative2, sep as sep10 } from "path";
|
|
9460
9468
|
function guessRunner(fileName, runners, relPath) {
|
|
9461
9469
|
if (fileName.endsWith(".py"))
|
|
@@ -9488,8 +9496,8 @@ var init_testmap = __esm(() => {
|
|
|
9488
9496
|
|
|
9489
9497
|
// ../../loki-ts/src/util/check_result.ts
|
|
9490
9498
|
import { spawn as spawn7 } from "child_process";
|
|
9491
|
-
import { createHash as
|
|
9492
|
-
import { existsSync as existsSync24, mkdirSync as mkdirSync12, readFileSync as
|
|
9499
|
+
import { createHash as createHash9 } from "crypto";
|
|
9500
|
+
import { existsSync as existsSync24, mkdirSync as mkdirSync12, readFileSync as readFileSync31, realpathSync as realpathSync16, renameSync as renameSync8, rmSync as rmSync8, writeFileSync as writeFileSync15 } from "fs";
|
|
9493
9501
|
import { basename as basename12, dirname as dirname15, isAbsolute as isAbsolute3, join as join37, relative as relative3 } from "path";
|
|
9494
9502
|
function plainTestEnv(base = process.env) {
|
|
9495
9503
|
const e = {};
|
|
@@ -9683,7 +9691,7 @@ function exitCodedId(cmd, out2, repoDir = "") {
|
|
|
9683
9691
|
const norm2 = (x) => roots.reduce((t, r) => t.split(r).join(""), x).replace(/(?<=\.[A-Za-z0-9]+):\d+(?::\d+)?/g, "").replace(/\s+/g, " ").trim();
|
|
9684
9692
|
const lines = stripAnsi(out2).split(`
|
|
9685
9693
|
`).map(norm2).filter(Boolean).sort();
|
|
9686
|
-
return lines.length ? `exit-coded:${cmd.trim()}:${
|
|
9694
|
+
return lines.length ? `exit-coded:${cmd.trim()}:${createHash9("sha256").update(lines.join(`
|
|
9687
9695
|
`)).digest("hex")}` : null;
|
|
9688
9696
|
}
|
|
9689
9697
|
function classifyCheck(i) {
|
|
@@ -9956,8 +9964,8 @@ function publishableWall(repoDir, runDir, o, env = process.env) {
|
|
|
9956
9964
|
if (!hit || rel.startsWith("..") || isAbsolute3(rel) || rel.startsWith(".loki/") || !basename12(rel).startsWith("loki_wall_"))
|
|
9957
9965
|
continue;
|
|
9958
9966
|
try {
|
|
9959
|
-
const bytes =
|
|
9960
|
-
if (
|
|
9967
|
+
const bytes = readFileSync31(join37(runDir, "wall", basename12(rel)));
|
|
9968
|
+
if (createHash9("sha256").update(bytes).digest("hex") !== w["sha256"])
|
|
9961
9969
|
throw new Error("hash");
|
|
9962
9970
|
out2.files.push({ rel, bytes, cmd: String(hit["cmd"]) });
|
|
9963
9971
|
} catch {
|
|
@@ -9995,7 +10003,7 @@ function diffFiles(repoDir, baseSha, skip) {
|
|
|
9995
10003
|
return f;
|
|
9996
10004
|
let n2 = 0;
|
|
9997
10005
|
try {
|
|
9998
|
-
n2 =
|
|
10006
|
+
n2 = readFileSync31(join37(repoDir, path), "utf8").split(`
|
|
9999
10007
|
`).length;
|
|
10000
10008
|
} catch {}
|
|
10001
10009
|
return { path, added: n2, deleted: 0, status: "added" };
|
|
@@ -10018,7 +10026,7 @@ function diffFiles(repoDir, baseSha, skip) {
|
|
|
10018
10026
|
let text2 = added.get(f.path) ?? "";
|
|
10019
10027
|
if (!text2 && f.status === "added") {
|
|
10020
10028
|
try {
|
|
10021
|
-
text2 =
|
|
10029
|
+
text2 = readFileSync31(join37(repoDir, f.path), "utf8");
|
|
10022
10030
|
} catch {}
|
|
10023
10031
|
}
|
|
10024
10032
|
const rule = criticalRuleFor(f.path, text2, rules);
|
|
@@ -10030,7 +10038,7 @@ function diffFiles(repoDir, baseSha, skip) {
|
|
|
10030
10038
|
continue;
|
|
10031
10039
|
try {
|
|
10032
10040
|
const oldText = f.status === "added" ? "" : safeGit(repoDir, ["show", `${baseSha}:${f.path}`]);
|
|
10033
|
-
const newText =
|
|
10041
|
+
const newText = readFileSync31(join37(repoDir, f.path), "utf8");
|
|
10034
10042
|
const patch = f.status === "added" ? newText.split(`
|
|
10035
10043
|
`).map((l) => `+${l}`).join(`
|
|
10036
10044
|
`) : safeGit(repoDir, ["diff", "-U0", baseSha, "--", f.path]);
|
|
@@ -10195,13 +10203,13 @@ async function mapPool(items, jobs, fn, stop = () => false) {
|
|
|
10195
10203
|
return out2;
|
|
10196
10204
|
}
|
|
10197
10205
|
function spawnCollect(cmd, args, o) {
|
|
10198
|
-
return new Promise((
|
|
10206
|
+
return new Promise((resolve15) => {
|
|
10199
10207
|
let out2 = "", err = "", error = false, done = false;
|
|
10200
10208
|
const MAX = 1024 * 1024;
|
|
10201
10209
|
const fin = (status) => {
|
|
10202
10210
|
if (!done) {
|
|
10203
10211
|
done = true;
|
|
10204
|
-
|
|
10212
|
+
resolve15({ status: error ? null : status, output: `${out2}
|
|
10205
10213
|
${err}` });
|
|
10206
10214
|
}
|
|
10207
10215
|
};
|
|
@@ -10242,7 +10250,7 @@ function resolveTool(repoDir, bin, fallback, lastResort = fallback) {
|
|
|
10242
10250
|
}
|
|
10243
10251
|
function goTestNames(file) {
|
|
10244
10252
|
try {
|
|
10245
|
-
return [...new Set([...
|
|
10253
|
+
return [...new Set([...readFileSync31(file, "utf8").matchAll(/^func\s+((?:Test|Fuzz|Example)[\p{L}\p{N}_]*)\s*\(/gmu)].map((m) => m[1]).filter((n2) => n2 !== "TestMain"))];
|
|
10246
10254
|
} catch {
|
|
10247
10255
|
return [];
|
|
10248
10256
|
}
|
|
@@ -10305,7 +10313,7 @@ async function wallChild(git, runId, repoDir, wallFiles) {
|
|
|
10305
10313
|
return false;
|
|
10306
10314
|
for (const n2 of names) {
|
|
10307
10315
|
const h = want.get(n2);
|
|
10308
|
-
if (h === undefined ||
|
|
10316
|
+
if (h === undefined || createHash9("sha256").update((await git(["cat-file", "blob", `HEAD:${n2}`])).out).digest("hex") !== h)
|
|
10309
10317
|
return false;
|
|
10310
10318
|
}
|
|
10311
10319
|
return true;
|
|
@@ -10363,7 +10371,7 @@ var NO_TESTS_REASON = "no tests executed", NO_RUNNER_REASON = "no runner of this
|
|
|
10363
10371
|
return out2.filter((n2) => !NOT_A_NAME.has(n2));
|
|
10364
10372
|
}, SENSITIVE, API, TEST_CFG, RANK2, FILES_MEDIUM = 4, FILES_HIGH = 15, LINES_MEDIUM = 100, LINES_HIGH = 500, RAN_ALWAYS, REVIEWER_ITEM = "one reviewer", PLAN, LOW_SKIPPED, deferredOf = (tier, selected, executed) => (tier === "low" ? LOW_SKIPPED : selected).filter((c) => !RAN_ALWAYS.includes(c) && !executed.includes(c)), DEEP_ITEMS, NOT_SELECTED = "not selected by risk tier: ", MANIFEST_LOCKS, dirOf = (p) => p.includes("/") ? p.slice(0, p.lastIndexOf("/")) : "", PKG_DEP_KEYS, PYPROJECT_NONDEP, SEM_RULES, DOC_FILE, readOr = (p) => {
|
|
10365
10373
|
try {
|
|
10366
|
-
return
|
|
10374
|
+
return readFileSync31(p, "utf8");
|
|
10367
10375
|
} catch {
|
|
10368
10376
|
return null;
|
|
10369
10377
|
}
|
|
@@ -10376,7 +10384,7 @@ var NO_TESTS_REASON = "no tests executed", NO_RUNNER_REASON = "no runner of this
|
|
|
10376
10384
|
}, EXCERPT_GROUP_CAP = 1500, EXCERPT_TOTAL_CAP = 6144, verifyJobs = () => {
|
|
10377
10385
|
const n2 = Number.parseInt(process.env["LOKI_E10_VERIFY_JOBS"] ?? "", 10);
|
|
10378
10386
|
return Number.isFinite(n2) && n2 >= 1 ? Math.min(n2, 8) : 1;
|
|
10379
|
-
}, FULL_SUITE_STATIC, 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) =>
|
|
10387
|
+
}, FULL_SUITE_STATIC, 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) => createHash9(hex === 64 ? "sha256" : "sha1").update(Buffer.concat([Buffer.from(`blob ${b.length}\x00`), b])).digest("hex");
|
|
10380
10388
|
var init_check_result = __esm(() => {
|
|
10381
10389
|
init_resolve();
|
|
10382
10390
|
init_testmap();
|
|
@@ -10444,8 +10452,8 @@ var init_check_result = __esm(() => {
|
|
|
10444
10452
|
});
|
|
10445
10453
|
|
|
10446
10454
|
// ../../loki-ts/src/util/receipt_signer.ts
|
|
10447
|
-
import { createHash as
|
|
10448
|
-
import { chmodSync as chmodSync5, linkSync, mkdirSync as mkdirSync13, readdirSync as
|
|
10455
|
+
import { createHash as createHash10, randomBytes as randomBytes3, createPrivateKey, createPublicKey as createPublicKey2, generateKeyPairSync, sign, verify as verify2 } from "crypto";
|
|
10456
|
+
import { chmodSync as chmodSync5, linkSync, mkdirSync as mkdirSync13, readdirSync as readdirSync15, readFileSync as readFileSync32, renameSync as renameSync9, statSync as statSync15, unlinkSync as unlinkSync5, writeFileSync as writeFileSync16 } from "fs";
|
|
10449
10457
|
import { homedir as homedir8 } from "os";
|
|
10450
10458
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
10451
10459
|
import { dirname as dirname16, join as join38 } from "path";
|
|
@@ -10471,7 +10479,7 @@ function loadSigningKey(generate = true) {
|
|
|
10471
10479
|
const given = process.env["LOKI_RECEIPT_SIGNING_KEY_FILE"]?.trim();
|
|
10472
10480
|
const file = given || join38(process.env["HOME"] || homedir8(), ".loki", "keys", RECEIPT_SIGNER_BASENAME);
|
|
10473
10481
|
try {
|
|
10474
|
-
pem =
|
|
10482
|
+
pem = readFileSync32(file);
|
|
10475
10483
|
if (!given) {
|
|
10476
10484
|
for (const [f, m] of [[file, 384], [dirname16(file), 448]])
|
|
10477
10485
|
if (statSync15(f).mode & 63)
|
|
@@ -10494,7 +10502,7 @@ function loadSigningKey(generate = true) {
|
|
|
10494
10502
|
} finally {
|
|
10495
10503
|
unlinkSync5(tmp);
|
|
10496
10504
|
}
|
|
10497
|
-
pem =
|
|
10505
|
+
pem = readFileSync32(file);
|
|
10498
10506
|
}
|
|
10499
10507
|
}
|
|
10500
10508
|
stage = "parse";
|
|
@@ -10552,7 +10560,7 @@ function collectToolchain(probe) {
|
|
|
10552
10560
|
}
|
|
10553
10561
|
return { ...memo };
|
|
10554
10562
|
}
|
|
10555
|
-
var RECEIPT_SIGNER_BASENAME = "receipt-ed25519.pem", b64u = (b) => Buffer.from(b).toString("base64url"), kidOf2 = (pub) => b64u(
|
|
10563
|
+
var RECEIPT_SIGNER_BASENAME = "receipt-ed25519.pem", b64u = (b) => Buffer.from(b).toString("base64url"), kidOf2 = (pub) => b64u(createHash10("sha256").update(`{"crv":"Ed25519","kty":"OKP","x":"${pub.export({ format: "jwk" }).x}"}`).digest()), lastProblem = null, TOOLCHAIN_KEYS, probeRuns = 0, memo = null;
|
|
10556
10564
|
var init_receipt_signer = __esm(() => {
|
|
10557
10565
|
init_check_result();
|
|
10558
10566
|
TOOLCHAIN_KEYS = ["bun", "node", "python3", "git"];
|
|
@@ -10627,12 +10635,12 @@ var init_stop_restore = __esm(() => {
|
|
|
10627
10635
|
});
|
|
10628
10636
|
|
|
10629
10637
|
// ../../loki-ts/src/util/base_guard.ts
|
|
10630
|
-
import { existsSync as existsSync25, readdirSync as
|
|
10631
|
-
import { basename as basename13, join as join39, relative as relative4, resolve as
|
|
10638
|
+
import { existsSync as existsSync25, readdirSync as readdirSync16, readFileSync as readFileSync33, readlinkSync, realpathSync as realpathSync17, symlinkSync } from "fs";
|
|
10639
|
+
import { basename as basename13, join as join39, relative as relative4, resolve as resolve15, sep as sep11 } from "path";
|
|
10632
10640
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
10633
10641
|
function insideAny(p, roots) {
|
|
10634
10642
|
const under = (q) => roots.some((r) => q === r || q.startsWith(r + sep11));
|
|
10635
|
-
if (under(
|
|
10643
|
+
if (under(resolve15(p)))
|
|
10636
10644
|
return true;
|
|
10637
10645
|
try {
|
|
10638
10646
|
return under(realpathSync17(p));
|
|
@@ -10650,18 +10658,18 @@ function namedPaths(file, text2) {
|
|
|
10650
10658
|
function depsSeeHead(pkgDir, repoDir) {
|
|
10651
10659
|
let roots;
|
|
10652
10660
|
try {
|
|
10653
|
-
roots = [...new Set([
|
|
10661
|
+
roots = [...new Set([resolve15(repoDir), realpathSync17(repoDir)])];
|
|
10654
10662
|
} catch {
|
|
10655
10663
|
return true;
|
|
10656
10664
|
}
|
|
10657
10665
|
let seen = 0;
|
|
10658
10666
|
const walk = (dir, own) => {
|
|
10659
|
-
for (const e of
|
|
10667
|
+
for (const e of readdirSync16(dir, { withFileTypes: true })) {
|
|
10660
10668
|
if (++seen > WALK_BOUND)
|
|
10661
10669
|
return true;
|
|
10662
10670
|
const p = join39(dir, e.name);
|
|
10663
10671
|
if (e.isSymbolicLink()) {
|
|
10664
|
-
const t =
|
|
10672
|
+
const t = resolve15(dir, readlinkSync(p));
|
|
10665
10673
|
let rt = t;
|
|
10666
10674
|
try {
|
|
10667
10675
|
rt = realpathSync17(t);
|
|
@@ -10672,7 +10680,7 @@ function depsSeeHead(pkgDir, repoDir) {
|
|
|
10672
10680
|
if (walk(p, own))
|
|
10673
10681
|
return true;
|
|
10674
10682
|
} else if (REPO_LINK_FILE.test(e.name)) {
|
|
10675
|
-
const text2 =
|
|
10683
|
+
const text2 = readFileSync33(p, "utf8");
|
|
10676
10684
|
if (roots.some((r) => text2.includes(r)) || namedPaths(p, text2).some((n2) => insideAny(n2, roots)))
|
|
10677
10685
|
return true;
|
|
10678
10686
|
}
|
|
@@ -10683,7 +10691,7 @@ function depsSeeHead(pkgDir, repoDir) {
|
|
|
10683
10691
|
return ["node_modules", ".venv"].some((d) => {
|
|
10684
10692
|
try {
|
|
10685
10693
|
const top = join39(pkgDir, d);
|
|
10686
|
-
return walk(top, [...new Set([
|
|
10694
|
+
return walk(top, [...new Set([resolve15(top), realpathSync17(top)])]);
|
|
10687
10695
|
} catch (e) {
|
|
10688
10696
|
if (e.code === "ENOENT")
|
|
10689
10697
|
return false;
|
|
@@ -10740,7 +10748,7 @@ var init_base_guard = __esm(() => {
|
|
|
10740
10748
|
});
|
|
10741
10749
|
|
|
10742
10750
|
// ../../loki-ts/src/features/speed/unit_mode.ts
|
|
10743
|
-
import { createHash as
|
|
10751
|
+
import { createHash as createHash11 } from "crypto";
|
|
10744
10752
|
import { closeSync as closeSync7, constants, fstatSync as fstatSync5, lstatSync as lstatSync9, openSync as openSync7, readSync as readSync6, realpathSync as realpathSync18 } from "fs";
|
|
10745
10753
|
function readBounded(path) {
|
|
10746
10754
|
const l = lstatSync9(path);
|
|
@@ -10798,7 +10806,7 @@ function unitSpec(env = process.env) {
|
|
|
10798
10806
|
return memo2.get(path) ?? null;
|
|
10799
10807
|
}
|
|
10800
10808
|
function unitSpecSha256(s) {
|
|
10801
|
-
return
|
|
10809
|
+
return createHash11("sha256").update(JSON.stringify({ id: typeof s.id === "string" ? s.id : "", items: arr2(s.items), acceptance: arr2(s.acceptance), writeSet: arr2(s.writeSet), base: typeof s.base === "string" ? s.base : "" })).digest("hex");
|
|
10802
10810
|
}
|
|
10803
10811
|
function unitSpecReceiptBlock(env = process.env) {
|
|
10804
10812
|
const path = env["LOKI_UNIT_SPEC"], frozen = env["LOKI_UNIT_SPEC_FROZEN"];
|
|
@@ -11663,8 +11671,8 @@ var init_state = __esm(() => {
|
|
|
11663
11671
|
|
|
11664
11672
|
// ../../loki-ts/src/runner/repo_profile.ts
|
|
11665
11673
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
11666
|
-
import { existsSync as existsSync26, lstatSync as lstatSync10, readFileSync as
|
|
11667
|
-
import { basename as basename14, join as join40, resolve as
|
|
11674
|
+
import { existsSync as existsSync26, lstatSync as lstatSync10, readFileSync as readFileSync34, mkdirSync as mkdirSync14, readdirSync as readdirSync17, renameSync as renameSync10, rmSync as rmSync9, writeFileSync as writeFileSync17 } from "fs";
|
|
11675
|
+
import { basename as basename14, join as join40, resolve as resolve16, isAbsolute as isAbsolute4 } from "path";
|
|
11668
11676
|
function detectFormatters(repoDir) {
|
|
11669
11677
|
const out2 = [];
|
|
11670
11678
|
const has = (...fs2) => fs2.some((f) => existsSync26(join40(repoDir, f)));
|
|
@@ -11676,7 +11684,7 @@ function detectFormatters(repoDir) {
|
|
|
11676
11684
|
prettierKey = pj !== "" && "prettier" in JSON.parse(pj);
|
|
11677
11685
|
} catch {}
|
|
11678
11686
|
const local = join40(repoDir, "node_modules", ".bin", "prettier");
|
|
11679
|
-
if ((prettierKey ||
|
|
11687
|
+
if ((prettierKey || readdirSync17(repoDir).some((f) => /^(\.prettierrc(\.[a-z0-9]+)?|prettier\.config\.[cm]?[jt]s)$/.test(f))) && existsSync26(local))
|
|
11680
11688
|
out2.push({ tool: "prettier", argv: [local, "--write"], exts: /\.(?:[cm]?[jt]sx?|json|css|scss|md|ya?ml|html)$/ });
|
|
11681
11689
|
if (has("go.mod"))
|
|
11682
11690
|
out2.push({ tool: "gofmt", argv: ["gofmt", "-w"], exts: /\.go$/ });
|
|
@@ -11703,7 +11711,7 @@ function runFormatters(repoDir, files, env) {
|
|
|
11703
11711
|
}
|
|
11704
11712
|
function loadProfile(repoDir) {
|
|
11705
11713
|
try {
|
|
11706
|
-
const p = JSON.parse(
|
|
11714
|
+
const p = JSON.parse(readFileSync34(commandProfilePath(repoDir), "utf8"));
|
|
11707
11715
|
return p?.version === 1 && Array.isArray(p.commands) && p.baseline ? p : null;
|
|
11708
11716
|
} catch {
|
|
11709
11717
|
return null;
|
|
@@ -11733,7 +11741,7 @@ function goIdTouched(repoDir, id, changed) {
|
|
|
11733
11741
|
const pkg = id.split("::")[0] ?? "";
|
|
11734
11742
|
const modOf = (dir) => {
|
|
11735
11743
|
try {
|
|
11736
|
-
return /^module\s+(\S+)/m.exec(
|
|
11744
|
+
return /^module\s+(\S+)/m.exec(readFileSync34(join40(repoDir, dir, "go.mod"), "utf8"))?.[1] ?? null;
|
|
11737
11745
|
} catch {
|
|
11738
11746
|
return null;
|
|
11739
11747
|
}
|
|
@@ -11845,7 +11853,7 @@ async function staticPreExisting(tool, prefix, files, io) {
|
|
|
11845
11853
|
}
|
|
11846
11854
|
var commandProfilePath = (repoDir) => join40(repoDir, ".loki", "state", "repo-profile.json"), read = (p) => {
|
|
11847
11855
|
try {
|
|
11848
|
-
return
|
|
11856
|
+
return readFileSync34(p, "utf8");
|
|
11849
11857
|
} catch {
|
|
11850
11858
|
return "";
|
|
11851
11859
|
}
|
|
@@ -11879,7 +11887,7 @@ var init_context = __esm(() => {
|
|
|
11879
11887
|
"Rules:",
|
|
11880
11888
|
"- The Wall tests are read-only: do not edit or delete them. Existing test files are append-only: you may add new test functions, but never edit or delete an existing one.",
|
|
11881
11889
|
"- Exception: when the task text itself states the new expected value of an existing assertion, change only that literal in that assertion; never remove, skip or loosen an assertion, and never edit one the task text does not name.",
|
|
11882
|
-
"- Run any tests you need, including the package's full suite (the Project Model commands below say how). The impacted tests named below are a starting hint, not a limit. The harness re-runs those checks after you stop; a pass that exists only in your reply does not count. Run
|
|
11890
|
+
"- Run any tests you need, including the package's full suite (the Project Model commands below say how). The impacted tests named below are a starting hint, not a limit. The harness re-runs those checks after you stop; a pass that exists only in your reply does not count. Run tests with the exact command the Project Model lists, never a shortened variant that changes how imports resolve; never create files or symlinks in a test directory to make an import work.",
|
|
11883
11891
|
"- Never leave a long-lived server running.",
|
|
11884
11892
|
"- Never kill processes.",
|
|
11885
11893
|
"- Write no documentation unless the task explicitly asks for it. Never write documentation, changelog or README text that announces a behavior the code does not have, even to make a test pass: if the task needs code that is not in this repository, finish with LOKI_SPEC_CONFLICT.",
|
|
@@ -11891,8 +11899,8 @@ var init_context = __esm(() => {
|
|
|
11891
11899
|
});
|
|
11892
11900
|
|
|
11893
11901
|
// ../../loki-ts/src/util/steer.ts
|
|
11894
|
-
import { appendFileSync as appendFileSync2, closeSync as closeSync8, constants as constants2, fstatSync as fstatSync6, readdirSync as
|
|
11895
|
-
import { createHash as
|
|
11902
|
+
import { appendFileSync as appendFileSync2, closeSync as closeSync8, constants as constants2, fstatSync as fstatSync6, readdirSync as readdirSync18, lstatSync as lstatSync11, mkdirSync as mkdirSync15, linkSync as linkSync2, openSync as openSync8, readFileSync as readFileSync35, readSync as readSync7, renameSync as renameSync11, statSync as statSync16, lutimesSync, rmSync as rmSync10, unlinkSync as unlinkSync6, writeFileSync as writeFileSync18, existsSync as existsSync27 } from "fs";
|
|
11903
|
+
import { createHash as createHash12, randomBytes as randomBytes4 } from "crypto";
|
|
11896
11904
|
import { basename as basename15, join as join41 } from "path";
|
|
11897
11905
|
function archiveTo(logs, prefix, src, link = linkSync2, onLinked) {
|
|
11898
11906
|
for (let i = 0;; i++) {
|
|
@@ -11921,7 +11929,7 @@ function orphanAlreadyArchived(logs, claim) {
|
|
|
11921
11929
|
const c = lstatSync11(claim);
|
|
11922
11930
|
if (!c.isFile())
|
|
11923
11931
|
return false;
|
|
11924
|
-
for (const a of
|
|
11932
|
+
for (const a of readdirSync18(logs)) {
|
|
11925
11933
|
if (!/^human-input-.*\.md$/.test(a))
|
|
11926
11934
|
continue;
|
|
11927
11935
|
try {
|
|
@@ -11937,7 +11945,7 @@ function orphanAlreadyArchived(logs, claim) {
|
|
|
11937
11945
|
function sweepOrphans(logs, stamp2, unapplied, link, nowMs = Date.now()) {
|
|
11938
11946
|
let names;
|
|
11939
11947
|
try {
|
|
11940
|
-
names =
|
|
11948
|
+
names = readdirSync18(logs);
|
|
11941
11949
|
} catch {
|
|
11942
11950
|
return;
|
|
11943
11951
|
}
|
|
@@ -12109,7 +12117,7 @@ function recordRevisions(repoDir, text2, archived, at) {
|
|
|
12109
12117
|
const file = join41(repoDir, ".loki", "intent-revisions.jsonl");
|
|
12110
12118
|
let last = 0;
|
|
12111
12119
|
try {
|
|
12112
|
-
for (const l of
|
|
12120
|
+
for (const l of readFileSync35(file, "utf8").split(`
|
|
12113
12121
|
`)) {
|
|
12114
12122
|
try {
|
|
12115
12123
|
last = Math.max(last, Number(JSON.parse(l).rev) || 0);
|
|
@@ -12131,7 +12139,7 @@ function recordRevisions(repoDir, text2, archived, at) {
|
|
|
12131
12139
|
`).trim();
|
|
12132
12140
|
if (p.rev === null && body === "")
|
|
12133
12141
|
continue;
|
|
12134
|
-
const rev = p.rev !== null && p.rev > last ? p.rev : last + 1, sha2 =
|
|
12142
|
+
const rev = p.rev !== null && p.rev > last ? p.rev : last + 1, sha2 = createHash12("sha256").update(body).digest("hex");
|
|
12135
12143
|
last = rev;
|
|
12136
12144
|
recs.push({ rev, source: p.source, actor: p.actor, sha: sha2, at: at.getTime() });
|
|
12137
12145
|
out2.push(JSON.stringify({ rev, ts: p.ts, actor: p.actor, source: p.source, chars: body.length, sha256: sha2, consumed_at: at.toISOString(), archived }));
|
|
@@ -12174,9 +12182,9 @@ var init_steer = __esm(() => {
|
|
|
12174
12182
|
});
|
|
12175
12183
|
|
|
12176
12184
|
// ../../loki-ts/src/util/run_outputs.ts
|
|
12177
|
-
import { createHash as
|
|
12178
|
-
import { existsSync as existsSync28, mkdirSync as mkdirSync16, readdirSync as
|
|
12179
|
-
import { join as join42, resolve as
|
|
12185
|
+
import { createHash as createHash13 } from "crypto";
|
|
12186
|
+
import { existsSync as existsSync28, mkdirSync as mkdirSync16, readdirSync as readdirSync19, readFileSync as readFileSync36, statSync as statSync17, writeFileSync as writeFileSync19 } from "fs";
|
|
12187
|
+
import { join as join42, resolve as resolve17 } from "path";
|
|
12180
12188
|
function intentRevisionsBlock(revs) {
|
|
12181
12189
|
const r = (revs ?? []).filter((r2) => r2.unapplied !== true).map(({ rev, source, actor, sha: sha2 }) => ({ rev, source, actor, sha: sha2 }));
|
|
12182
12190
|
return r.length ? { intent_revisions: r } : {};
|
|
@@ -12184,11 +12192,11 @@ function intentRevisionsBlock(revs) {
|
|
|
12184
12192
|
function seededCorpusBlock(env = process.env) {
|
|
12185
12193
|
const dir = env["LOKI_SEEDED_DEFECTS_DIR"] || join42(REPO_ROOT, "benchmarks", "seeded-defects");
|
|
12186
12194
|
try {
|
|
12187
|
-
const bytes =
|
|
12195
|
+
const bytes = readFileSync36(join42(dir, "manifest.json")), version2 = createHash13("sha256").update(bytes).digest("hex");
|
|
12188
12196
|
const ids = (JSON.parse(bytes.toString("utf8")).defects ?? []).map((d) => d.id);
|
|
12189
12197
|
let rate = null;
|
|
12190
12198
|
try {
|
|
12191
|
-
const res = JSON.parse(
|
|
12199
|
+
const res = JSON.parse(readFileSync36(join42(dir, "results", "wrong-pass.json"), "utf8"));
|
|
12192
12200
|
const runs2 = res.manifest_sha256 === version2 && Array.isArray(res.runs) ? res.runs : [];
|
|
12193
12201
|
const complete = (o) => !!o && Object.keys(o).length === ids.length && ids.every((id) => typeof id === "string" && (o[id] === "SEALED" || o[id] === "NOT_SEALED"));
|
|
12194
12202
|
const top = runs2.filter((r) => r.setup === "top"), floor = runs2.filter((r) => r.setup === "floor");
|
|
@@ -12473,7 +12481,7 @@ var init_registry2 = __esm(() => {
|
|
|
12473
12481
|
|
|
12474
12482
|
// ../../loki-ts/src/features/receipt_dsse.ts
|
|
12475
12483
|
import { createPublicKey as createPublicKey3, sign as sign2, verify as verify3 } from "crypto";
|
|
12476
|
-
import { readFileSync as
|
|
12484
|
+
import { readFileSync as readFileSync37 } from "fs";
|
|
12477
12485
|
function pae(payloadType, body) {
|
|
12478
12486
|
const t = Buffer.from(payloadType, "utf8");
|
|
12479
12487
|
return Buffer.concat([Buffer.from(`DSSEv1 ${t.length} `), t, Buffer.from(` ${body.length} `), body]);
|
|
@@ -12550,7 +12558,7 @@ function verifyDsseReceipt(env, d) {
|
|
|
12550
12558
|
}
|
|
12551
12559
|
function runIdGuard(receiptPath, runId2) {
|
|
12552
12560
|
try {
|
|
12553
|
-
return envelopeRunIdProblem(JSON.parse(
|
|
12561
|
+
return envelopeRunIdProblem(JSON.parse(readFileSync37(receiptPath, "utf8")), runId2);
|
|
12554
12562
|
} catch {
|
|
12555
12563
|
return null;
|
|
12556
12564
|
}
|
|
@@ -12609,11 +12617,11 @@ var init_run_status = __esm(() => {
|
|
|
12609
12617
|
});
|
|
12610
12618
|
|
|
12611
12619
|
// ../../loki-ts/src/util/seal_drift.ts
|
|
12612
|
-
import { createHash as
|
|
12620
|
+
import { createHash as createHash14 } from "crypto";
|
|
12613
12621
|
var EMPTY_SHA;
|
|
12614
12622
|
var init_seal_drift = __esm(() => {
|
|
12615
12623
|
init_safe_git();
|
|
12616
|
-
EMPTY_SHA =
|
|
12624
|
+
EMPTY_SHA = createHash14("sha256").digest("hex");
|
|
12617
12625
|
});
|
|
12618
12626
|
|
|
12619
12627
|
// ../../loki-ts/src/util/spec_file.ts
|
|
@@ -12679,7 +12687,7 @@ var init_run_cap = __esm(() => {
|
|
|
12679
12687
|
});
|
|
12680
12688
|
|
|
12681
12689
|
// ../../loki-ts/src/util/mutation_proof.ts
|
|
12682
|
-
import { existsSync as existsSync29, mkdirSync as mkdirSync17, mkdtempSync as mkdtempSync3, readFileSync as
|
|
12690
|
+
import { existsSync as existsSync29, mkdirSync as mkdirSync17, mkdtempSync as mkdtempSync3, readFileSync as readFileSync38, rmSync as rmSync11, symlinkSync as symlinkSync2, writeFileSync as writeFileSync20 } from "fs";
|
|
12683
12691
|
import { tmpdir as tmpdir4 } from "os";
|
|
12684
12692
|
import { basename as basename16, dirname as dirname17, isAbsolute as isAbsolute6, join as join44, relative as relative6 } from "path";
|
|
12685
12693
|
function mutationProof(i) {
|
|
@@ -12710,7 +12718,7 @@ function mutationProof(i) {
|
|
|
12710
12718
|
if (!existsSync29(src))
|
|
12711
12719
|
return np(`Wall file missing: ${rel}`);
|
|
12712
12720
|
mkdirSync17(dirname17(join44(wt, rel)), { recursive: true });
|
|
12713
|
-
writeFileSync20(join44(wt, rel),
|
|
12721
|
+
writeFileSync20(join44(wt, rel), readFileSync38(src));
|
|
12714
12722
|
}
|
|
12715
12723
|
for (const rel of rels) {
|
|
12716
12724
|
const parts = rel.split("/").slice(0, -1);
|
|
@@ -12769,7 +12777,7 @@ var init_mutation_proof = __esm(() => {
|
|
|
12769
12777
|
});
|
|
12770
12778
|
|
|
12771
12779
|
// ../../loki-ts/src/util/python.ts
|
|
12772
|
-
import { accessSync, constants as constants3, existsSync as existsSync30, mkdtempSync as mkdtempSync4, readFileSync as
|
|
12780
|
+
import { accessSync, constants as constants3, existsSync as existsSync30, mkdtempSync as mkdtempSync4, readFileSync as readFileSync39, realpathSync as realpathSync19, rmSync as rmSync12, statSync as statSync18 } from "fs";
|
|
12773
12781
|
import { spawnSync as spawnSync4 } from "child_process";
|
|
12774
12782
|
import { tmpdir as tmpdir5 } from "os";
|
|
12775
12783
|
async function findPython3() {
|
|
@@ -13126,7 +13134,7 @@ var init_wall_manifest = __esm(() => {
|
|
|
13126
13134
|
});
|
|
13127
13135
|
|
|
13128
13136
|
// ../../loki-ts/src/features/wall_manifest_wire.ts
|
|
13129
|
-
import { createHash as
|
|
13137
|
+
import { createHash as createHash15 } from "crypto";
|
|
13130
13138
|
import { basename as basename17, dirname as dirname18 } from "path";
|
|
13131
13139
|
function blobEntries(ls) {
|
|
13132
13140
|
const out2 = [];
|
|
@@ -13186,7 +13194,7 @@ function wallManifestFor(repoDir, tree, task, env = process.env) {
|
|
|
13186
13194
|
if (at !== cat.length)
|
|
13187
13195
|
return null;
|
|
13188
13196
|
const text2 = buildWallManifest([...files, ...listed.map((e) => ({ path: e.path, content: "" }))], named.map((e) => e.path), matched.map((e) => e.path));
|
|
13189
|
-
return { text: text2, sha256:
|
|
13197
|
+
return { text: text2, sha256: createHash15("sha256").update(text2).digest("hex") };
|
|
13190
13198
|
} catch {
|
|
13191
13199
|
return null;
|
|
13192
13200
|
}
|
|
@@ -13218,8 +13226,8 @@ Example: test('name', () => { assert.strictEqual(fn(1), 2); }); Run: node --tes
|
|
|
13218
13226
|
});
|
|
13219
13227
|
|
|
13220
13228
|
// ../../loki-ts/src/util/holdout.ts
|
|
13221
|
-
import { createHash as
|
|
13222
|
-
import { appendFileSync as appendFileSync3, copyFileSync as copyFileSync2, existsSync as existsSync31, mkdirSync as mkdirSync18, readFileSync as
|
|
13229
|
+
import { createHash as createHash16 } from "crypto";
|
|
13230
|
+
import { appendFileSync as appendFileSync3, copyFileSync as copyFileSync2, existsSync as existsSync31, mkdirSync as mkdirSync18, readFileSync as readFileSync40, rmSync as rmSync13, writeFileSync as writeFileSync21 } from "fs";
|
|
13223
13231
|
import { tmpdir as tmpdir6 } from "os";
|
|
13224
13232
|
import { basename as basename18, join as join45, relative as relative7 } from "path";
|
|
13225
13233
|
function wallHoldoutRatio(env = process.env) {
|
|
@@ -13254,7 +13262,7 @@ function stashHoldout(o) {
|
|
|
13254
13262
|
const files = held.map((name) => {
|
|
13255
13263
|
copyFileSync2(join45(o.srcDir, name), join45(dir, name));
|
|
13256
13264
|
rmSync13(join45(o.srcDir, name), { force: true });
|
|
13257
|
-
return { name, runner: o.runnerOf(name), sha256: sha2(
|
|
13265
|
+
return { name, runner: o.runnerOf(name), sha256: sha2(readFileSync40(join45(dir, name), "utf8")) };
|
|
13258
13266
|
});
|
|
13259
13267
|
writeFileSync21(join45(dir, MANIFEST), JSON.stringify({ targetDir: o.targetDir, files }));
|
|
13260
13268
|
return { dir, names: new Set(held) };
|
|
@@ -13263,14 +13271,14 @@ function stageHoldout(dir, repoDir) {
|
|
|
13263
13271
|
const put = [], tests = [], missing = [];
|
|
13264
13272
|
let man = null;
|
|
13265
13273
|
try {
|
|
13266
|
-
man = JSON.parse(
|
|
13274
|
+
man = JSON.parse(readFileSync40(join45(dir, MANIFEST), "utf8"));
|
|
13267
13275
|
} catch {}
|
|
13268
13276
|
if (!man)
|
|
13269
13277
|
return { tests, missing: [`holdout store unreadable: ${basename18(dir)}`], cleanup: () => {} };
|
|
13270
13278
|
mkdirSync18(man.targetDir, { recursive: true });
|
|
13271
13279
|
man.files.forEach((f, i) => {
|
|
13272
13280
|
const src = join45(dir, f.name);
|
|
13273
|
-
if (!existsSync31(src) || sha2(
|
|
13281
|
+
if (!existsSync31(src) || sha2(readFileSync40(src, "utf8")) !== f.sha256) {
|
|
13274
13282
|
missing.push(`holdout ${i + 1} missing or altered`);
|
|
13275
13283
|
return;
|
|
13276
13284
|
}
|
|
@@ -13291,7 +13299,7 @@ function recordHoldoutTriage(runDir, entry) {
|
|
|
13291
13299
|
`, { mode: 384 });
|
|
13292
13300
|
} catch {}
|
|
13293
13301
|
}
|
|
13294
|
-
var sha2 = (s) =>
|
|
13302
|
+
var sha2 = (s) => createHash16("sha256").update(s).digest("hex"), WALL_HOLDOUT_DEFAULT_RATIO = 0.2, isHoldoutCheck = (name) => name.startsWith("holdout:"), holdoutDirFor = (runId2, repoDir) => join45(tmpdir6(), `loki-e10-holdout-${sha2(`${runId2}:${repoDir}`).slice(0, 16)}`), MANIFEST = "manifest.json", WALL_HOLDOUT_MIN = 5, HOLDOUT_TRIAGE_FILE = "holdout-triage.jsonl";
|
|
13295
13303
|
var init_holdout = () => {};
|
|
13296
13304
|
|
|
13297
13305
|
// ../../loki-ts/src/util/lock_ecosystems.ts
|
|
@@ -13598,7 +13606,7 @@ var init_install = __esm(() => {
|
|
|
13598
13606
|
});
|
|
13599
13607
|
|
|
13600
13608
|
// ../../loki-ts/src/features/runner_config.ts
|
|
13601
|
-
import { readFileSync as
|
|
13609
|
+
import { readFileSync as readFileSync41 } from "fs";
|
|
13602
13610
|
import { dirname as dirname19, join as join48, normalize as normalize2 } from "path";
|
|
13603
13611
|
function tomlKey2(s, i = 0, eq2 = true) {
|
|
13604
13612
|
const parts = [], ws = () => {
|
|
@@ -13957,7 +13965,7 @@ var PKG_KEYS, RAW_CONFIGS, RUNNER_CONFIGS, DEP_MAPS, RUNNER_DEP, LOCAL_SPEC, dep
|
|
|
13957
13965
|
}
|
|
13958
13966
|
}, headText = (dir, f) => {
|
|
13959
13967
|
try {
|
|
13960
|
-
return
|
|
13968
|
+
return readFileSync41(join48(dir, f), "utf8");
|
|
13961
13969
|
} catch {
|
|
13962
13970
|
return "";
|
|
13963
13971
|
}
|
|
@@ -13997,7 +14005,7 @@ var init_runner_config = __esm(() => {
|
|
|
13997
14005
|
|
|
13998
14006
|
// ../../loki-ts/src/e10ext/assert_delta.ts
|
|
13999
14007
|
import { execFileSync as execFileSync4 } from "child_process";
|
|
14000
|
-
import { mkdtempSync as mkdtempSync6, readFileSync as
|
|
14008
|
+
import { mkdtempSync as mkdtempSync6, readFileSync as readFileSync42, rmSync as rmSync15 } from "fs";
|
|
14001
14009
|
import { tmpdir as tmpdir8 } from "os";
|
|
14002
14010
|
import { join as join49 } from "path";
|
|
14003
14011
|
import { basename as basename20 } from "path";
|
|
@@ -14040,7 +14048,7 @@ function assertDeltaNotes(repoDir, baseSha, headRef, path, task, baseCounts, hea
|
|
|
14040
14048
|
return null;
|
|
14041
14049
|
try {
|
|
14042
14050
|
const show = (ref) => safeGit(repoDir, ["show", `${ref}:${path}`]);
|
|
14043
|
-
const head = headRef ? show(headRef) :
|
|
14051
|
+
const head = headRef ? show(headRef) : readFileSync42(join49(repoDir, path), "utf8");
|
|
14044
14052
|
const r = classifyTestEdit(path, show(baseSha), head, task, baseCounts, headCounts);
|
|
14045
14053
|
return r[0]?.kind === "literal-only" ? r.map((e) => `assertion value changed (not shown to be required by the task): ${e.file}:${e.line} ${e.old} -> ${e.new}`) : null;
|
|
14046
14054
|
} catch {
|
|
@@ -14269,11 +14277,11 @@ var init_wall_owned = __esm(() => {
|
|
|
14269
14277
|
|
|
14270
14278
|
// ../../loki-ts/src/util/app_probe.ts
|
|
14271
14279
|
import { spawnSync as spawnSync6 } from "child_process";
|
|
14272
|
-
import { existsSync as existsSync32, mkdirSync as mkdirSync19, readFileSync as
|
|
14280
|
+
import { existsSync as existsSync32, mkdirSync as mkdirSync19, readFileSync as readFileSync43, renameSync as renameSync12, writeFileSync as writeFileSync22 } from "fs";
|
|
14273
14281
|
import { join as join51 } from "path";
|
|
14274
14282
|
function readJson4(p) {
|
|
14275
14283
|
try {
|
|
14276
|
-
const v = JSON.parse(
|
|
14284
|
+
const v = JSON.parse(readFileSync43(p, "utf8"));
|
|
14277
14285
|
return v && typeof v === "object" ? v : null;
|
|
14278
14286
|
} catch {
|
|
14279
14287
|
return null;
|
|
@@ -14305,7 +14313,7 @@ async function appProbe(repoDir, lokiDir2, opts = {}) {
|
|
|
14305
14313
|
return { checks, pid, url };
|
|
14306
14314
|
}
|
|
14307
14315
|
const ir = Number(m[1]), sr = Number(m[2]), hr = Number(m[3]), noApp = m[4] === "1";
|
|
14308
|
-
const pidTxt = existsSync32(join51(dir, "app.pid")) ?
|
|
14316
|
+
const pidTxt = existsSync32(join51(dir, "app.pid")) ? readFileSync43(join51(dir, "app.pid"), "utf8").trim() : "";
|
|
14309
14317
|
pid = /^\d+$/.test(pidTxt) && sr >= 0 ? Number(pidTxt) : null;
|
|
14310
14318
|
const st = readJson4(join51(dir, "state.json"));
|
|
14311
14319
|
url = typeof st?.["url"] === "string" ? st["url"] : null;
|
|
@@ -14382,10 +14390,10 @@ app_runner_stop >/dev/null 2>&1
|
|
|
14382
14390
|
});
|
|
14383
14391
|
|
|
14384
14392
|
// ../../loki-ts/src/util/secure_scan.ts
|
|
14385
|
-
import { existsSync as existsSync33, mkdirSync as mkdirSync20, mkdtempSync as mkdtempSync7, readFileSync as
|
|
14393
|
+
import { existsSync as existsSync33, mkdirSync as mkdirSync20, mkdtempSync as mkdtempSync7, readFileSync as readFileSync44, realpathSync as realpathSync21, rmSync as rmSync16, statSync as statSync19, writeFileSync as writeFileSync23 } from "fs";
|
|
14386
14394
|
import { randomBytes as randomBytes5 } from "crypto";
|
|
14387
14395
|
import { tmpdir as tmpdir9 } from "os";
|
|
14388
|
-
import { basename as basename21, dirname as dirname20, join as join52, resolve as
|
|
14396
|
+
import { basename as basename21, dirname as dirname20, join as join52, resolve as resolve18, sep as sep12 } from "path";
|
|
14389
14397
|
function fail(error) {
|
|
14390
14398
|
return { ok: false, findings: [], error };
|
|
14391
14399
|
}
|
|
@@ -14575,7 +14583,7 @@ async function scanAddedLines(repoDir, opts = {}) {
|
|
|
14575
14583
|
continue;
|
|
14576
14584
|
}
|
|
14577
14585
|
const lines2 = new Map;
|
|
14578
|
-
|
|
14586
|
+
readFileSync44(join52(repoDir, p), "utf8").split(`
|
|
14579
14587
|
`).forEach((t, i) => lines2.set(i + 1, t));
|
|
14580
14588
|
added.set(p, lines2);
|
|
14581
14589
|
} catch {}
|
|
@@ -14584,14 +14592,14 @@ async function scanAddedLines(repoDir, opts = {}) {
|
|
|
14584
14592
|
return { ok: true, findings: skipped2 };
|
|
14585
14593
|
const mirror = mkdtempSync7(join52(tmpdir9(), "loki-secure-added-"));
|
|
14586
14594
|
try {
|
|
14587
|
-
const root =
|
|
14595
|
+
const root = resolve18(mirror) + sep12;
|
|
14588
14596
|
const chunkMap = new Map;
|
|
14589
14597
|
const chunkRoot = `.loki-chunks-${randomBytes5(6).toString("hex")}`;
|
|
14590
14598
|
let chunkSeq = 0;
|
|
14591
14599
|
for (const [p, lines2] of added) {
|
|
14592
14600
|
if (lines2.size === 0)
|
|
14593
14601
|
continue;
|
|
14594
|
-
const dest =
|
|
14602
|
+
const dest = resolve18(mirror, p);
|
|
14595
14603
|
if (!dest.startsWith(root))
|
|
14596
14604
|
continue;
|
|
14597
14605
|
let max = 0;
|
|
@@ -14629,7 +14637,7 @@ async function scanAddedLines(repoDir, opts = {}) {
|
|
|
14629
14637
|
const whole = chunks.length === 1;
|
|
14630
14638
|
for (const c of chunks) {
|
|
14631
14639
|
const rel = whole ? p : join52(chunkRoot, String(chunkSeq++), basename21(p));
|
|
14632
|
-
const out2 = whole ? dest :
|
|
14640
|
+
const out2 = whole ? dest : resolve18(mirror, rel);
|
|
14633
14641
|
if (!out2.startsWith(root))
|
|
14634
14642
|
break;
|
|
14635
14643
|
chunkMap.set(rel, { file: p, lines: c.orig });
|
|
@@ -14680,8 +14688,8 @@ var init_secure_scan = __esm(() => {
|
|
|
14680
14688
|
});
|
|
14681
14689
|
|
|
14682
14690
|
// ../../loki-ts/src/project_model/conventions.ts
|
|
14683
|
-
import { existsSync as existsSync34, readdirSync as
|
|
14684
|
-
import { basename as basename22, dirname as dirname21, isAbsolute as isAbsolute9, join as join53, relative as relative10, resolve as
|
|
14691
|
+
import { existsSync as existsSync34, readdirSync as readdirSync20, readFileSync as readFileSync45 } from "fs";
|
|
14692
|
+
import { basename as basename22, dirname as dirname21, isAbsolute as isAbsolute9, join as join53, relative as relative10, resolve as resolve19 } from "path";
|
|
14685
14693
|
function parseJsonc(text2) {
|
|
14686
14694
|
let out2 = "", i = 0;
|
|
14687
14695
|
while (i < text2.length) {
|
|
@@ -14722,7 +14730,7 @@ function moduleOf(file, depth = 0) {
|
|
|
14722
14730
|
function readPackageConventions(pkgDir, runner = null) {
|
|
14723
14731
|
let names = [];
|
|
14724
14732
|
try {
|
|
14725
|
-
names =
|
|
14733
|
+
names = readdirSync20(pkgDir).filter((f) => f.endsWith(".json")).sort((x, y) => x.length - y.length || x.localeCompare(y));
|
|
14726
14734
|
} catch {
|
|
14727
14735
|
return null;
|
|
14728
14736
|
}
|
|
@@ -14776,7 +14784,7 @@ function nearestPackageRoot(testDir, repoDir, fileName) {
|
|
|
14776
14784
|
return siteFor(api, repoDir, relative10(repoDir, join53(testDir, fileName)))?.cwd ?? repoDir;
|
|
14777
14785
|
const shaped = (d) => {
|
|
14778
14786
|
try {
|
|
14779
|
-
return
|
|
14787
|
+
return readdirSync20(d).some((f) => {
|
|
14780
14788
|
if (!f.endsWith(".json"))
|
|
14781
14789
|
return false;
|
|
14782
14790
|
const j = readJson5(join53(d, f));
|
|
@@ -14858,7 +14866,7 @@ function phantomRepoPaths(content, fileName, testDir, repoDir, planText) {
|
|
|
14858
14866
|
return join53(testDir, "__self__");
|
|
14859
14867
|
const url = /^fileURLToPath\(new URL\((["'])([^"']*)\1\s*,\s*import\.meta\.url\)\)$/.exec(e);
|
|
14860
14868
|
if (url)
|
|
14861
|
-
return
|
|
14869
|
+
return resolve19(testDir, url[2]);
|
|
14862
14870
|
const lit = /^(["'`])((?:\\.|(?!\1)[^\\])*)\1$/.exec(e);
|
|
14863
14871
|
if (lit)
|
|
14864
14872
|
return lit[2].includes("${") ? null : lit[2];
|
|
@@ -14872,7 +14880,7 @@ function phantomRepoPaths(content, fileName, testDir, repoDir, planText) {
|
|
|
14872
14880
|
return null;
|
|
14873
14881
|
if (call[1] === "dirname")
|
|
14874
14882
|
return dirname21(args[0]);
|
|
14875
|
-
const out2 =
|
|
14883
|
+
const out2 = resolve19(...args);
|
|
14876
14884
|
const first = parts.slice(1).map((a) => /^\s*["'`]([^"'`]*)["'`]\s*$/.exec(a)?.[1]).find((x) => x), viaWalk = !!first && walk.has(parts[0].trim()) && [pkg, repoDir].some((d) => existsSync34(join53(d, first.split("/").filter(Boolean)[0] ?? "\x00")));
|
|
14877
14885
|
if (report && (viaWalk || !parts.some((a) => walk.has(a.trim()) || taint.has(a.trim())) && (relative10(testDir, out2).startsWith("..") || strayInTestDir(out2))) && parts.some((a) => /^\s*["'`]/.test(a)))
|
|
14878
14886
|
reports.set(`${ln}|${e}`, { out: out2, rel: relative10(repoDir, out2), tail: viaWalk ? join53(...args.slice(1)) : undefined });
|
|
@@ -14975,7 +14983,7 @@ function phantomReason(miss, repoFiles, testDir = "", pkgRoot = "") {
|
|
|
14975
14983
|
}
|
|
14976
14984
|
var readJson5 = (p) => {
|
|
14977
14985
|
try {
|
|
14978
|
-
const v = parseJsonc(
|
|
14986
|
+
const v = parseJsonc(readFileSync45(p, "utf8"));
|
|
14979
14987
|
return v && typeof v === "object" && !Array.isArray(v) ? v : null;
|
|
14980
14988
|
} catch {
|
|
14981
14989
|
return null;
|
|
@@ -14997,6 +15005,23 @@ var init_version = __esm(() => {
|
|
|
14997
15005
|
});
|
|
14998
15006
|
|
|
14999
15007
|
// ../../loki-ts/src/e10ext/preexisting_dirty.ts
|
|
15008
|
+
function untouchedSinceIntake(repoDir, recorded, env = process.env) {
|
|
15009
|
+
if (!recorded || typeof recorded !== "object")
|
|
15010
|
+
return [];
|
|
15011
|
+
return Object.entries(recorded).filter(([p, h]) => {
|
|
15012
|
+
try {
|
|
15013
|
+
return blob2(repoDir, p, env) === h;
|
|
15014
|
+
} catch {
|
|
15015
|
+
return false;
|
|
15016
|
+
}
|
|
15017
|
+
}).map(([p]) => p);
|
|
15018
|
+
}
|
|
15019
|
+
var blob2 = (repoDir, path, env = process.env) => safeGit(repoDir, ["hash-object", "-w", "--no-filters", "--", path], { env }).trim();
|
|
15020
|
+
var init_preexisting_dirty = __esm(() => {
|
|
15021
|
+
init_safe_git();
|
|
15022
|
+
});
|
|
15023
|
+
|
|
15024
|
+
// ../../loki-ts/src/features/untouched_untracked.ts
|
|
15000
15025
|
import { lstatSync as lstatSync12 } from "fs";
|
|
15001
15026
|
import { join as join54 } from "path";
|
|
15002
15027
|
function untouchedUntracked(repoDir, recorded, env = process.env) {
|
|
@@ -15016,20 +15041,8 @@ function untouchedUntracked(repoDir, recorded, env = process.env) {
|
|
|
15016
15041
|
}
|
|
15017
15042
|
}).map(([p]) => p);
|
|
15018
15043
|
}
|
|
15019
|
-
|
|
15020
|
-
|
|
15021
|
-
return [];
|
|
15022
|
-
return Object.entries(recorded).filter(([p, h]) => {
|
|
15023
|
-
try {
|
|
15024
|
-
return blob2(repoDir, p, env) === h;
|
|
15025
|
-
} catch {
|
|
15026
|
-
return false;
|
|
15027
|
-
}
|
|
15028
|
-
}).map(([p]) => p);
|
|
15029
|
-
}
|
|
15030
|
-
var blob2 = (repoDir, path, env = process.env) => safeGit(repoDir, ["hash-object", "-w", "--no-filters", "--", path], { env }).trim();
|
|
15031
|
-
var init_preexisting_dirty = __esm(() => {
|
|
15032
|
-
init_safe_git();
|
|
15044
|
+
var init_untouched_untracked = __esm(() => {
|
|
15045
|
+
init_preexisting_dirty();
|
|
15033
15046
|
});
|
|
15034
15047
|
|
|
15035
15048
|
// ../../loki-ts/src/e10ext/commit_filter.ts
|
|
@@ -15041,6 +15054,7 @@ function dropSet(repoDir, staged, preexistingDirty, env = process.env, installCr
|
|
|
15041
15054
|
var WALL_FILE, parseStaged = (out2) => out2.split("\x00").reduce((a, t, i, all) => i % 2 === 0 && t ? [...a, { st: t, f: all[i + 1] }] : a, []), formatChanged = (repoDir, staged, dropped2, env = process.env) => runFormatters(repoDir, staged.filter(({ st, f }) => (st === "A" || st === "M") && !dropped2.has(f) && !f.startsWith(".loki/")).map(({ f }) => f), tokenFreeEnv(env));
|
|
15042
15055
|
var init_commit_filter = __esm(() => {
|
|
15043
15056
|
init_preexisting_dirty();
|
|
15057
|
+
init_untouched_untracked();
|
|
15044
15058
|
init_install();
|
|
15045
15059
|
init_repo_profile();
|
|
15046
15060
|
init_safe_git();
|
|
@@ -15142,8 +15156,8 @@ var init_route_block = __esm(() => {
|
|
|
15142
15156
|
|
|
15143
15157
|
// ../../loki-ts/src/features/visual_evidence.ts
|
|
15144
15158
|
import { spawn as spawn8 } from "child_process";
|
|
15145
|
-
import { createHash as
|
|
15146
|
-
import { existsSync as existsSync35, lstatSync as lstatSync13, mkdirSync as mkdirSync21, readdirSync as
|
|
15159
|
+
import { createHash as createHash17, randomBytes as randomBytes6 } from "crypto";
|
|
15160
|
+
import { existsSync as existsSync35, lstatSync as lstatSync13, mkdirSync as mkdirSync21, readdirSync as readdirSync21, readFileSync as readFileSync46, writeFileSync as writeFileSync24 } from "fs";
|
|
15147
15161
|
import { createServer } from "net";
|
|
15148
15162
|
import { dirname as dirname23, isAbsolute as isAbsolute10, join as join55, normalize as normalize3, relative as relative11, sep as sep13 } from "path";
|
|
15149
15163
|
function routeFor(file) {
|
|
@@ -15222,7 +15236,7 @@ function openapiPaths(repoDir) {
|
|
|
15222
15236
|
if (!existsSync35(p))
|
|
15223
15237
|
continue;
|
|
15224
15238
|
try {
|
|
15225
|
-
const txt =
|
|
15239
|
+
const txt = readFileSync46(p, "utf8");
|
|
15226
15240
|
const paths = f.endsWith(".json") ? Object.keys(JSON.parse(txt).paths ?? {}) : [...txt.matchAll(/^ {2}(\/[^\s:]*):\s*$/gm)].map((m) => m[1]);
|
|
15227
15241
|
return paths.filter((x) => !x.includes("{")).slice(0, 10);
|
|
15228
15242
|
} catch {
|
|
@@ -15245,7 +15259,7 @@ async function recordE2eMedia(repoDir, runDir, relDir, base, routes, ms, signal)
|
|
|
15245
15259
|
return { rels: [], skipped: "playwright e2e video and trace skipped: the run failed or timed out" };
|
|
15246
15260
|
const rels = [];
|
|
15247
15261
|
const walk = (d) => {
|
|
15248
|
-
for (const e of
|
|
15262
|
+
for (const e of readdirSync21(d, { withFileTypes: true })) {
|
|
15249
15263
|
const full = join55(d, e.name);
|
|
15250
15264
|
if (e.isDirectory())
|
|
15251
15265
|
walk(full);
|
|
@@ -15340,14 +15354,14 @@ async function captureVisualEvidence(repoDir, runDir, changed, opts = {}) {
|
|
|
15340
15354
|
const subs = ["backend", "frontend"].filter((d) => existsSync35(join55(repoDir, d, "package.json")));
|
|
15341
15355
|
const has2 = (d) => {
|
|
15342
15356
|
try {
|
|
15343
|
-
return pickScript(JSON.parse(
|
|
15357
|
+
return pickScript(JSON.parse(readFileSync46(join55(repoDir, d, "package.json"), "utf8"))) !== null;
|
|
15344
15358
|
} catch {
|
|
15345
15359
|
return false;
|
|
15346
15360
|
}
|
|
15347
15361
|
};
|
|
15348
15362
|
return skip(noRootReason(subs, subs.filter((d) => !has2(d))));
|
|
15349
15363
|
}
|
|
15350
|
-
script = pickScript(JSON.parse(
|
|
15364
|
+
script = pickScript(JSON.parse(readFileSync46(pkgPath, "utf8")));
|
|
15351
15365
|
if (!script)
|
|
15352
15366
|
return skip("no dev, preview or start script");
|
|
15353
15367
|
}
|
|
@@ -15444,7 +15458,7 @@ function receiptScreensProblem(receiptPath, receipt) {
|
|
|
15444
15458
|
return `visual evidence failed (LOKI_VISUAL_GATE=1): ${receipt["evidence_failed"]}`;
|
|
15445
15459
|
return receipt["evidence_screens"] === undefined ? null : checkScreens(dirname23(receiptPath), receipt["evidence_screens"]);
|
|
15446
15460
|
}
|
|
15447
|
-
var visualEvidenceEnabled = (env = process.env) => env["LOKI_VISUAL_EVIDENCE"] !== "0", visualGateEnabled = (env = process.env) => env["LOKI_VISUAL_GATE"] === "1", PAGE_RE, isPageFile = (p) => PAGE_RE.test(p), screenName = (route) => (route === "/" ? "index" : route.slice(1).replace(/[^A-Za-z0-9._-]+/g, "_")) || "index", sha256File = (p) =>
|
|
15461
|
+
var visualEvidenceEnabled = (env = process.env) => env["LOKI_VISUAL_EVIDENCE"] !== "0", visualGateEnabled = (env = process.env) => env["LOKI_VISUAL_GATE"] === "1", PAGE_RE, isPageFile = (p) => PAGE_RE.test(p), screenName = (route) => (route === "/" ? "index" : route.slice(1).replace(/[^A-Za-z0-9._-]+/g, "_")) || "index", sha256File = (p) => createHash17("sha256").update(readFileSync46(p)).digest("hex"), playwrightBin = (repoDir) => {
|
|
15448
15462
|
const bin = join55(repoDir, "node_modules", ".bin", "playwright");
|
|
15449
15463
|
return existsSync35(bin) ? bin : null;
|
|
15450
15464
|
}, playwrightTestPkg = (repoDir) => {
|
|
@@ -15522,15 +15536,15 @@ var init_pr = __esm(() => {
|
|
|
15522
15536
|
});
|
|
15523
15537
|
|
|
15524
15538
|
// ../../loki-ts/src/util/pr_lessons.ts
|
|
15525
|
-
import { existsSync as existsSync36, mkdirSync as mkdirSync22, mkdtempSync as mkdtempSync8, readFileSync as
|
|
15539
|
+
import { existsSync as existsSync36, mkdirSync as mkdirSync22, mkdtempSync as mkdtempSync8, readFileSync as readFileSync47, rmSync as rmSync17, writeFileSync as writeFileSync25 } from "fs";
|
|
15526
15540
|
import { dirname as dirname24, join as join57 } from "path";
|
|
15527
|
-
import { createHash as
|
|
15541
|
+
import { createHash as createHash18 } from "crypto";
|
|
15528
15542
|
function loadLessons(repoDir) {
|
|
15529
15543
|
const p = lessonsPath(repoDir);
|
|
15530
15544
|
if (!existsSync36(p))
|
|
15531
15545
|
return [];
|
|
15532
15546
|
try {
|
|
15533
|
-
const j = JSON.parse(
|
|
15547
|
+
const j = JSON.parse(readFileSync47(p, "utf-8"));
|
|
15534
15548
|
return Array.isArray(j.lessons) ? j.lessons : [];
|
|
15535
15549
|
} catch {
|
|
15536
15550
|
return [];
|
|
@@ -15542,7 +15556,7 @@ function save(repoDir, lessons) {
|
|
|
15542
15556
|
atomicWriteJson(p, { version: 2, lessons });
|
|
15543
15557
|
}
|
|
15544
15558
|
function appendReceiptFact(repoDir, f, now2 = () => new Date) {
|
|
15545
|
-
const id = `rcp-${
|
|
15559
|
+
const id = `rcp-${createHash18("sha256").update(f.runId).digest("hex").slice(0, 12)}`;
|
|
15546
15560
|
const lessons = loadLessons(repoDir);
|
|
15547
15561
|
if (lessons.some((l) => l.id === id))
|
|
15548
15562
|
return false;
|
|
@@ -15596,14 +15610,14 @@ var init_attempts = __esm(() => {
|
|
|
15596
15610
|
});
|
|
15597
15611
|
|
|
15598
15612
|
// ../../loki-ts/src/runner/router/route_record.ts
|
|
15599
|
-
import { existsSync as existsSync37, lstatSync as lstatSync14, mkdirSync as mkdirSync23, readFileSync as
|
|
15613
|
+
import { existsSync as existsSync37, lstatSync as lstatSync14, mkdirSync as mkdirSync23, readFileSync as readFileSync48, writeFileSync as writeFileSync26 } from "fs";
|
|
15600
15614
|
import { join as join58 } from "path";
|
|
15601
15615
|
function loadRouteRecord(runDir) {
|
|
15602
15616
|
try {
|
|
15603
15617
|
const p = join58(runDir, ROUTE_RECORD_FILE);
|
|
15604
15618
|
if (!existsSync37(p) || !lstatSync14(p).isFile())
|
|
15605
15619
|
return;
|
|
15606
|
-
const v = JSON.parse(
|
|
15620
|
+
const v = JSON.parse(readFileSync48(p, "utf8"));
|
|
15607
15621
|
return typeof v === "object" && v !== null && !Array.isArray(v) ? v : undefined;
|
|
15608
15622
|
} catch {
|
|
15609
15623
|
return;
|
|
@@ -16026,7 +16040,7 @@ var init_deep = __esm(() => {
|
|
|
16026
16040
|
});
|
|
16027
16041
|
|
|
16028
16042
|
// ../../loki-ts/src/engine10/stages/verify.ts
|
|
16029
|
-
import { existsSync as existsSync39, mkdtempSync as mkdtempSync10, readFileSync as
|
|
16043
|
+
import { existsSync as existsSync39, mkdtempSync as mkdtempSync10, readFileSync as readFileSync49, rmSync as rmSync19 } from "fs";
|
|
16030
16044
|
import { tmpdir as tmpdir11 } from "os";
|
|
16031
16045
|
import { basename as basename23, isAbsolute as isAbsolute11, join as join60, relative as relative12 } from "path";
|
|
16032
16046
|
async function runOnce2(cmd2, args, cwd, signal, opts) {
|
|
@@ -16149,7 +16163,7 @@ function projectDeclaresRuff(repoDir) {
|
|
|
16149
16163
|
const files = ["pyproject.toml", "setup.cfg", "tox.ini", ".pre-commit-config.yaml", "Pipfile", "requirements.txt", "requirements-dev.txt", "dev-requirements.txt"];
|
|
16150
16164
|
return files.some((f) => {
|
|
16151
16165
|
try {
|
|
16152
|
-
return /\bruff\b/i.test(
|
|
16166
|
+
return /\bruff\b/i.test(readFileSync49(join60(repoDir, f), "utf8"));
|
|
16153
16167
|
} catch {
|
|
16154
16168
|
return false;
|
|
16155
16169
|
}
|
|
@@ -16375,7 +16389,7 @@ ${x}` : c.cmd };
|
|
|
16375
16389
|
|
|
16376
16390
|
// ../../loki-ts/src/engine10/stages/wall.ts
|
|
16377
16391
|
import { spawnSync as spawnSync7 } from "child_process";
|
|
16378
|
-
import { existsSync as existsSync40, mkdirSync as mkdirSync25, mkdtempSync as mkdtempSync11, readFileSync as
|
|
16392
|
+
import { existsSync as existsSync40, mkdirSync as mkdirSync25, mkdtempSync as mkdtempSync11, readFileSync as readFileSync50, readdirSync as readdirSync22, rmSync as rmSync20, writeFileSync as writeFileSync28 } from "fs";
|
|
16379
16393
|
import { tmpdir as tmpdir12 } from "os";
|
|
16380
16394
|
import { dirname as dirname26, join as join61, relative as relative13 } from "path";
|
|
16381
16395
|
|
|
@@ -16445,7 +16459,7 @@ function loadTaskText(ctx, fromPrior) {
|
|
|
16445
16459
|
const issueJsonPath = process.env.LOKI_E10_ISSUE_JSON ?? join61(ctx.runDir, "issue.json");
|
|
16446
16460
|
if (existsSync40(issueJsonPath)) {
|
|
16447
16461
|
try {
|
|
16448
|
-
const issue = JSON.parse(
|
|
16462
|
+
const issue = JSON.parse(readFileSync50(issueJsonPath, "utf8"));
|
|
16449
16463
|
const text2 = [issue.title, issue.body].filter((s) => typeof s === "string" && s.length > 0).join(`
|
|
16450
16464
|
|
|
16451
16465
|
`);
|
|
@@ -16504,21 +16518,21 @@ async function wallAuthor(ctx, signal, retry) {
|
|
|
16504
16518
|
return done({ status: "failed", data: { iteration_ids: [iterationId], model }, reason: "wall session aborted, killed, or timed out", killed: true });
|
|
16505
16519
|
}
|
|
16506
16520
|
const planText = typeof prior.plan?.plan === "string" ? prior.plan.plan : null, repoFiles = repoMap?.files ?? [];
|
|
16507
|
-
const oor = () =>
|
|
16508
|
-
const text2 =
|
|
16521
|
+
const oor = () => readdirSync22(cwd).filter((f) => f.startsWith(WALL_PREFIX)).flatMap((name) => {
|
|
16522
|
+
const text2 = readFileSync50(join61(cwd, name), "utf8"), why = outOfRepoTarget(text2) ?? phantomReason(phantomRepoPaths(text2, name, targetDir, ctx.repoDir, planText), repoFiles, relative13(ctx.repoDir, targetDir), pkg?.root ?? "");
|
|
16509
16523
|
return why ? [{ name, why }] : [];
|
|
16510
16524
|
});
|
|
16511
16525
|
const bad1 = oor();
|
|
16512
16526
|
if (bad1.length > 0 && !signal.aborted && !ctx.overCap?.())
|
|
16513
16527
|
await ctx.sessions.run({ stage: "wall", brief: withStagePrefix(outOfRepoReask("Rewrite these Wall files in place, keeping the same names and acceptance coverage.", bad1)), tier: "development", model, iterationId: `${iterationId}-oor`, limitS: wallLimitS(sz.size), signal, cwd });
|
|
16514
|
-
const oorBad = new Map(oor().map((b) => [b.name, b.why])), all =
|
|
16528
|
+
const oorBad = new Map(oor().map((b) => [b.name, b.why])), all = readdirSync22(cwd).filter((f) => f.startsWith(WALL_PREFIX)), held = stashHoldout({ runId: ctx.runId, repoDir: ctx.repoDir, srcDir: cwd, targetDir, names: all.filter((n2) => !oorBad.has(n2) && !conventionViolation(conv2, n2, readFileSync50(join61(cwd, n2), "utf8"))), runnerOf: (n2) => guessRunner(n2, runners) }), generated = all.filter((n2) => !held?.names.has(n2));
|
|
16515
16529
|
const sealedDir = join61(ctx.runDir, "wall");
|
|
16516
16530
|
if (generated.length > 0)
|
|
16517
16531
|
mkdirSync25(sealedDir, { recursive: true });
|
|
16518
16532
|
const contents = new Map;
|
|
16519
16533
|
const discarded = [];
|
|
16520
16534
|
for (const name of generated) {
|
|
16521
|
-
const content =
|
|
16535
|
+
const content = readFileSync50(join61(cwd, name), "utf8"), oorWhy = oorBad.get(name), bad = oorWhy ?? conventionViolation(conv2, name, content);
|
|
16522
16536
|
writeFileSync28(join61(sealedDir, name), content, "utf8");
|
|
16523
16537
|
if (oorWhy)
|
|
16524
16538
|
discarded.push({ file: name, reason: `${oorWhy}; wall test discarded after one rewrite request` });
|
|
@@ -16642,7 +16656,7 @@ var init_wall = __esm(() => {
|
|
|
16642
16656
|
});
|
|
16643
16657
|
|
|
16644
16658
|
// ../../loki-ts/src/e10ext/discard.ts
|
|
16645
|
-
import { chmodSync as chmodSync6, closeSync as closeSync9, lstatSync as lstatSync16, mkdirSync as mkdirSync26, openSync as openSync9, readFileSync as
|
|
16659
|
+
import { chmodSync as chmodSync6, closeSync as closeSync9, lstatSync as lstatSync16, mkdirSync as mkdirSync26, openSync as openSync9, readFileSync as readFileSync51, realpathSync as realpathSync23, rmdirSync, unlinkSync as unlinkSync7, writeFileSync as writeFileSync29 } from "fs";
|
|
16646
16660
|
import { dirname as dirname27, join as join62, relative as relative14, sep as sep14 } from "path";
|
|
16647
16661
|
function safeRestore(repoDir, f, want, mode) {
|
|
16648
16662
|
const root = realpathSync23(repoDir), fp = join62(root, f), rel = relative14(root, dirname27(fp));
|
|
@@ -16667,7 +16681,7 @@ function safeRestore(repoDir, f, want, mode) {
|
|
|
16667
16681
|
} catch {
|
|
16668
16682
|
st = null;
|
|
16669
16683
|
}
|
|
16670
|
-
if (st?.isFile() &&
|
|
16684
|
+
if (st?.isFile() && readFileSync51(fp).equals(want)) {
|
|
16671
16685
|
chmodSync6(fp, mode);
|
|
16672
16686
|
return;
|
|
16673
16687
|
}
|
|
@@ -16769,14 +16783,14 @@ var init_scope2 = __esm(() => {
|
|
|
16769
16783
|
});
|
|
16770
16784
|
|
|
16771
16785
|
// ../../loki-ts/src/council/role_agents.ts
|
|
16772
|
-
import { existsSync as existsSync41, readdirSync as
|
|
16786
|
+
import { existsSync as existsSync41, readdirSync as readdirSync23, readFileSync as readFileSync52 } from "fs";
|
|
16773
16787
|
import { homedir as homedir9 } from "os";
|
|
16774
16788
|
import { join as join63 } from "path";
|
|
16775
16789
|
function agentDirs(repoDir, env = process.env) {
|
|
16776
16790
|
return [env["LOKI_AGENTS_PROJECT_DIR"] || join63(repoDir, ".loki", "agents"), env["LOKI_AGENTS_USER_DIR"] || join63(env["XDG_CONFIG_HOME"] || join63(homedir9(), ".config"), "loki", "agents")];
|
|
16777
16791
|
}
|
|
16778
16792
|
function parseAgent(file, stem2) {
|
|
16779
|
-
const m = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/.exec(
|
|
16793
|
+
const m = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/.exec(readFileSync52(file, "utf8"));
|
|
16780
16794
|
if (!m)
|
|
16781
16795
|
return null;
|
|
16782
16796
|
const body = m[2].trim();
|
|
@@ -16794,7 +16808,7 @@ function loadRoleAgent(repoDir, role, env = process.env) {
|
|
|
16794
16808
|
continue;
|
|
16795
16809
|
let names;
|
|
16796
16810
|
try {
|
|
16797
|
-
names =
|
|
16811
|
+
names = readdirSync23(d).filter((n2) => n2.endsWith(".md") && !n2.startsWith(".")).sort();
|
|
16798
16812
|
} catch {
|
|
16799
16813
|
continue;
|
|
16800
16814
|
}
|
|
@@ -16896,14 +16910,14 @@ var init_colors = __esm(() => {
|
|
|
16896
16910
|
});
|
|
16897
16911
|
|
|
16898
16912
|
// ../../loki-ts/src/util/run_summary.ts
|
|
16899
|
-
import { existsSync as existsSync42, mkdirSync as mkdirSync28, readFileSync as
|
|
16913
|
+
import { existsSync as existsSync42, mkdirSync as mkdirSync28, readFileSync as readFileSync53, renameSync as renameSync13, statSync as statSync20, writeFileSync as writeFileSync30 } from "fs";
|
|
16900
16914
|
import { join as join65 } from "path";
|
|
16901
16915
|
function readRiskRecord(repoDir, sinceMs = 0) {
|
|
16902
16916
|
try {
|
|
16903
16917
|
const p = join65(repoDir, ".loki", "state", "risk-tier.json");
|
|
16904
16918
|
if (statSync20(p).mtimeMs < sinceMs)
|
|
16905
16919
|
return null;
|
|
16906
|
-
const r = JSON.parse(
|
|
16920
|
+
const r = JSON.parse(readFileSync53(p, "utf8"));
|
|
16907
16921
|
return r && typeof r === "object" ? r : null;
|
|
16908
16922
|
} catch {
|
|
16909
16923
|
return null;
|
|
@@ -16919,7 +16933,7 @@ var init_run_summary = __esm(() => {
|
|
|
16919
16933
|
});
|
|
16920
16934
|
|
|
16921
16935
|
// ../../loki-ts/src/engine10/stages/xreview.ts
|
|
16922
|
-
import { existsSync as existsSync43, readFileSync as
|
|
16936
|
+
import { existsSync as existsSync43, readFileSync as readFileSync54 } from "fs";
|
|
16923
16937
|
import { join as join66 } from "path";
|
|
16924
16938
|
function minVerdict(verdict, review) {
|
|
16925
16939
|
const ceiling = review?.level === "block" ? "PARTIAL" : verdict;
|
|
@@ -16937,7 +16951,7 @@ function explicitReview(repoDir, env) {
|
|
|
16937
16951
|
if (!existsSync43(p))
|
|
16938
16952
|
continue;
|
|
16939
16953
|
try {
|
|
16940
|
-
const m = /^review:[ \t]*["']?([A-Za-z]+)["']?[ \t]*(?:#.*)?$/m.exec(
|
|
16954
|
+
const m = /^review:[ \t]*["']?([A-Za-z]+)["']?[ \t]*(?:#.*)?$/m.exec(readFileSync54(p, "utf8"));
|
|
16941
16955
|
const v = asProvider(m?.[1]);
|
|
16942
16956
|
if (v)
|
|
16943
16957
|
return v;
|
|
@@ -17132,9 +17146,9 @@ See also: loki cost --detail (what a run ALREADY spent)
|
|
|
17132
17146
|
});
|
|
17133
17147
|
|
|
17134
17148
|
// ../../loki-ts/src/features/contract.ts
|
|
17135
|
-
import { existsSync as existsSync44, lstatSync as lstatSync17, mkdirSync as mkdirSync29, readFileSync as
|
|
17149
|
+
import { existsSync as existsSync44, lstatSync as lstatSync17, mkdirSync as mkdirSync29, readFileSync as readFileSync55, rmSync as rmSync21, writeFileSync as writeFileSync31 } from "fs";
|
|
17136
17150
|
import { dirname as dirname29, join as join67 } from "path";
|
|
17137
|
-
import { createHash as
|
|
17151
|
+
import { createHash as createHash19 } from "crypto";
|
|
17138
17152
|
function contractEnabled(env = process.env) {
|
|
17139
17153
|
return env["LOKI_CONTRACT"] !== "0";
|
|
17140
17154
|
}
|
|
@@ -17181,11 +17195,11 @@ function readContract(repoDir) {
|
|
|
17181
17195
|
return { contract: null, notes: ["contract unreadable: too large"], sha256: null };
|
|
17182
17196
|
let raw2;
|
|
17183
17197
|
try {
|
|
17184
|
-
raw2 =
|
|
17198
|
+
raw2 = readFileSync55(p);
|
|
17185
17199
|
} catch {
|
|
17186
17200
|
return { contract: null, notes: ["contract unreadable: read failed"], sha256: null };
|
|
17187
17201
|
}
|
|
17188
|
-
const sha2563 =
|
|
17202
|
+
const sha2563 = createHash19("sha256").update(raw2).digest("hex");
|
|
17189
17203
|
let j;
|
|
17190
17204
|
try {
|
|
17191
17205
|
j = JSON.parse(raw2.toString("utf8"));
|
|
@@ -17255,8 +17269,8 @@ var init_contract = __esm(() => {
|
|
|
17255
17269
|
});
|
|
17256
17270
|
|
|
17257
17271
|
// ../../loki-ts/src/features/speed/seal_group.ts
|
|
17258
|
-
import { createHash as
|
|
17259
|
-
import { existsSync as existsSync45, mkdirSync as mkdirSync30, readdirSync as
|
|
17272
|
+
import { createHash as createHash20 } from "crypto";
|
|
17273
|
+
import { existsSync as existsSync45, mkdirSync as mkdirSync30, readdirSync as readdirSync24, readFileSync as readFileSync56, renameSync as renameSync14, statSync as statSync21, writeFileSync as writeFileSync32 } from "fs";
|
|
17260
17274
|
import { dirname as dirname30, join as join68 } from "path";
|
|
17261
17275
|
function sealGroup(runDir, rh) {
|
|
17262
17276
|
const manifestPath = join68(runDir, "group", "manifest.json");
|
|
@@ -17287,7 +17301,7 @@ function sealGroup(runDir, rh) {
|
|
|
17287
17301
|
const dir = join68(unitsDir(runDir), id), rp = join68(dir, "receipt.json"), ep = join68(dir, "events.jsonl");
|
|
17288
17302
|
let bytes;
|
|
17289
17303
|
try {
|
|
17290
|
-
bytes =
|
|
17304
|
+
bytes = readFileSync56(rp);
|
|
17291
17305
|
} catch {
|
|
17292
17306
|
return fail2(`unit ${id} sub-receipt missing`);
|
|
17293
17307
|
}
|
|
@@ -17304,7 +17318,7 @@ function sealGroup(runDir, rh) {
|
|
|
17304
17318
|
unit_id: id,
|
|
17305
17319
|
sub_receipt_sha256: sha3(bytes),
|
|
17306
17320
|
receipt_sha256: sub2["receipt_sha256"],
|
|
17307
|
-
events_file_sha256: existsSync45(ep) ? sha3(
|
|
17321
|
+
events_file_sha256: existsSync45(ep) ? sha3(readFileSync56(ep)) : null,
|
|
17308
17322
|
verdict,
|
|
17309
17323
|
goal: text2(u["goal"], 200),
|
|
17310
17324
|
files: (Array.isArray(u["files"]) ? u["files"] : []).map((f) => text2(f, 200)).filter(Boolean).slice(0, 50),
|
|
@@ -17348,13 +17362,13 @@ async function verifyGroup(receiptPath, receipt, rh, verifyOne, deps = {}) {
|
|
|
17348
17362
|
try {
|
|
17349
17363
|
if (!statSync21(dir).isDirectory())
|
|
17350
17364
|
return bad(`unit ${id} is not a directory`);
|
|
17351
|
-
bytes =
|
|
17365
|
+
bytes = readFileSync56(rp);
|
|
17352
17366
|
} catch {
|
|
17353
17367
|
return bad(`unit ${id} sub-receipt missing`);
|
|
17354
17368
|
}
|
|
17355
17369
|
if (sha3(bytes) !== e["sub_receipt_sha256"])
|
|
17356
17370
|
return bad(`unit ${id} sub-receipt does not match its recorded hash`);
|
|
17357
|
-
const evSha = existsSync45(ep) ? sha3(
|
|
17371
|
+
const evSha = existsSync45(ep) ? sha3(readFileSync56(ep)) : null;
|
|
17358
17372
|
if (evSha !== (e["events_file_sha256"] ?? null))
|
|
17359
17373
|
return bad(`unit ${id} events.jsonl does not match its recorded hash`);
|
|
17360
17374
|
const sub2 = readJson6(rp);
|
|
@@ -17377,15 +17391,15 @@ function compositeVerdict(childVerdicts) {
|
|
|
17377
17391
|
const failed2 = childVerdicts.filter((v) => v === "FAILED" || !["VERIFIED", "ALREADY_SATISFIED", "PARTIAL", "SPEC_CONFLICT"].includes(v)).length;
|
|
17378
17392
|
return capGroupVerdict(base, { section: undefined, notProven: [], problems: failed2, allUnitsPass: childVerdicts.every((v) => PASSING.has(v)) });
|
|
17379
17393
|
}
|
|
17380
|
-
var ID_RE, PASSING, sha3 = (b) =>
|
|
17394
|
+
var ID_RE, PASSING, sha3 = (b) => createHash20("sha256").update(b).digest("hex"), isObj10 = (v) => v !== null && typeof v === "object" && !Array.isArray(v), text2 = (v, cap) => typeof v === "string" ? v.replace(/[\x00-\x1f\x7f]+/g, " ").trim().slice(0, cap) : "", num4 = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 ? v : 0, unitsDir = (runDir) => join68(runDir, "group", "units"), readJson6 = (p) => {
|
|
17381
17395
|
try {
|
|
17382
|
-
return JSON.parse(
|
|
17396
|
+
return JSON.parse(readFileSync56(p, "utf8"));
|
|
17383
17397
|
} catch {
|
|
17384
17398
|
return;
|
|
17385
17399
|
}
|
|
17386
17400
|
}, dirNames = (d) => {
|
|
17387
17401
|
try {
|
|
17388
|
-
return
|
|
17402
|
+
return readdirSync24(d).filter((n3) => !n3.startsWith(".")).sort();
|
|
17389
17403
|
} catch {
|
|
17390
17404
|
return null;
|
|
17391
17405
|
}
|
|
@@ -17397,7 +17411,7 @@ var init_seal_group = __esm(() => {
|
|
|
17397
17411
|
});
|
|
17398
17412
|
|
|
17399
17413
|
// ../../loki-ts/src/supply/supply_guard.ts
|
|
17400
|
-
import { existsSync as existsSync46, readFileSync as
|
|
17414
|
+
import { existsSync as existsSync46, readFileSync as readFileSync57, statSync as statSync22 } from "fs";
|
|
17401
17415
|
import { basename as basename25, join as join69 } from "path";
|
|
17402
17416
|
function supplyEnabled(env) {
|
|
17403
17417
|
return env["LOKI_SUPPLY_GUARD"] !== "0";
|
|
@@ -17419,7 +17433,7 @@ function readDeclared(repoDir) {
|
|
|
17419
17433
|
try {
|
|
17420
17434
|
if (statSync22(p).size > MAX_FILE_BYTES)
|
|
17421
17435
|
return { deps: [], problem: "declaration file too large" };
|
|
17422
|
-
const j = JSON.parse(
|
|
17436
|
+
const j = JSON.parse(readFileSync57(p, "utf8"));
|
|
17423
17437
|
if (!Array.isArray(j))
|
|
17424
17438
|
return { deps: [], problem: "declaration is not a JSON array" };
|
|
17425
17439
|
const deps = [];
|
|
@@ -17443,7 +17457,7 @@ function readAllowlist(repoDir) {
|
|
|
17443
17457
|
if (!existsSync46(p))
|
|
17444
17458
|
return new Set;
|
|
17445
17459
|
try {
|
|
17446
|
-
return new Set(
|
|
17460
|
+
return new Set(readFileSync57(p, "utf8").split(`
|
|
17447
17461
|
`).map((l) => l.replace(/#.*$/, "").trim()).filter(Boolean));
|
|
17448
17462
|
} catch {
|
|
17449
17463
|
return new Set;
|
|
@@ -17626,7 +17640,7 @@ var MIN_AGE_DAYS = 7, DECLARED_FILE = "supply-declared.json", MAX_CHECKED = 50,
|
|
|
17626
17640
|
}
|
|
17627
17641
|
}, PUBLIC_HOSTS, hostOf = (u) => u.trim().toLowerCase().replace(/^[a-z][a-z0-9+.-]*:\/\//, "").replace(/^www\./, "").split(/[/?#\s]/)[0].replace(/^[^@]*@/, "").replace(/:\d+$/, ""), privateUrl = (u) => /[a-z0-9]/i.test(u) && !PUBLIC_HOSTS.has(hostOf(u)), readSmall = (p) => {
|
|
17628
17642
|
try {
|
|
17629
|
-
return statSync22(p).size <= MAX_FILE_BYTES ?
|
|
17643
|
+
return statSync22(p).size <= MAX_FILE_BYTES ? readFileSync57(p, "utf8") : "";
|
|
17630
17644
|
} catch {
|
|
17631
17645
|
return "";
|
|
17632
17646
|
}
|
|
@@ -17641,8 +17655,8 @@ var init_supply_guard = __esm(() => {
|
|
|
17641
17655
|
});
|
|
17642
17656
|
|
|
17643
17657
|
// ../../loki-ts/src/engine10/stages/seal.ts
|
|
17644
|
-
import { createHash as
|
|
17645
|
-
import { existsSync as existsSync47, readdirSync as
|
|
17658
|
+
import { createHash as createHash21 } from "crypto";
|
|
17659
|
+
import { existsSync as existsSync47, readdirSync as readdirSync25, mkdirSync as mkdirSync31, readFileSync as readFileSync58 } from "fs";
|
|
17646
17660
|
import { basename as basename26, isAbsolute as isAbsolute13, join as join70, relative as relative15 } from "path";
|
|
17647
17661
|
async function leanSymbolGap(ctx, o, rawDiff, head, vraw) {
|
|
17648
17662
|
if (externalRun(o) || Array.isArray(o.wall?.files) && o.wall.files.length > 0 || o.intake?.already_satisfied === true || o.implement?.exit === "already_done")
|
|
@@ -17664,7 +17678,7 @@ async function leanSymbolGap(ctx, o, rawDiff, head, vraw) {
|
|
|
17664
17678
|
const n3 = String(c.name ?? ""), p = n3.slice(n3.indexOf(":") + 1);
|
|
17665
17679
|
if (n3.includes(":") && isTestFile(p))
|
|
17666
17680
|
try {
|
|
17667
|
-
sources2.push(
|
|
17681
|
+
sources2.push(readFileSync58(join70(ctx.repoDir, p), "utf8"));
|
|
17668
17682
|
} catch {}
|
|
17669
17683
|
}
|
|
17670
17684
|
return symbolGap(changedSymbols(d.stdout), sources2);
|
|
@@ -17746,7 +17760,7 @@ function renderReceiptMd(r) {
|
|
|
17746
17760
|
].join(`
|
|
17747
17761
|
`);
|
|
17748
17762
|
}
|
|
17749
|
-
var SIGNING_UNAVAILABLE = "receipt signing unavailable (no usable signing key: invalid key or unwritable ~/.loki/keys)", AGENT_ONLY_REASON = "only agent-authored tests executed (no agent-independent proof)", WALL_GREEN_ON_BASE_REASON = "Wall green on base: no Wall test discriminates the change", EXCLUDE_LOKI = ":(exclude).loki", sha2562 = (s) =>
|
|
17763
|
+
var SIGNING_UNAVAILABLE = "receipt signing unavailable (no usable signing key: invalid key or unwritable ~/.loki/keys)", AGENT_ONLY_REASON = "only agent-authored tests executed (no agent-independent proof)", WALL_GREEN_ON_BASE_REASON = "Wall green on base: no Wall test discriminates the change", EXCLUDE_LOKI = ":(exclude).loki", sha2562 = (s) => createHash21("sha256").update(s).digest("hex"), str4 = (v) => typeof v === "string" && v !== "" ? v : null, EXTERNAL_MODEL_LABEL = "external (no Loki implement session)", EXTERNAL_DIFF_NOT_ISOLATED = "Wall author not filesystem-isolated from the external diff", EXTERNAL_NO_WALL = "external diff sealed with no Wall file that ran; the only checks are the repo's existing tests", externalRun = (o) => o.implement?.exit === "external", LEAN_NO_SYMBOL = "no passing check references a changed symbol and no Wall file ran", strs2 = (v) => Array.isArray(v) ? v.filter((x) => typeof x === "string" && x !== "") : [], g = (ctx) => (a) => git4(ctx, a), receiptRel = (ctx) => {
|
|
17750
17764
|
const r = relative15(ctx.repoDir, join70(ctx.runDir, "receipt.json"));
|
|
17751
17765
|
return r.startsWith("..") || isAbsolute13(r) ? `.loki/runs/${ctx.runId}/receipt.json` : r;
|
|
17752
17766
|
}, commitStage, wallGreenOnBaseOf = (o) => {
|
|
@@ -17880,7 +17894,7 @@ var init_seal = __esm(() => {
|
|
|
17880
17894
|
if (wallNotRun > 0) {
|
|
17881
17895
|
try {
|
|
17882
17896
|
const kept = new Set((Array.isArray(o.wall?.files) ? o.wall.files : []).map((f) => basename26(String(f.path))));
|
|
17883
|
-
for (const n3 of
|
|
17897
|
+
for (const n3 of readdirSync25(join70(ctx.runDir, "wall")).sort())
|
|
17884
17898
|
if (!kept.has(n3))
|
|
17885
17899
|
notProven.add(`wall test discarded: ${n3} (not_run)`);
|
|
17886
17900
|
} catch {}
|
|
@@ -18006,7 +18020,7 @@ var init_seal = __esm(() => {
|
|
|
18006
18020
|
model: externalRun(o) ? EXTERNAL_MODEL_LABEL : ctx.model,
|
|
18007
18021
|
...externalRun(o) ? { implement: { exit: "external", patch_sha256: str4(o.implement?.patch_sha256) ?? "" } } : {},
|
|
18008
18022
|
resumed: o.intake?.resumed === true,
|
|
18009
|
-
events_sha256: sha2562(existsSync47(eventsPath) ?
|
|
18023
|
+
events_sha256: sha2562(existsSync47(eventsPath) ? readFileSync58(eventsPath) : ""),
|
|
18010
18024
|
...await sealEvidence(ctx.repoDir, ctx.runDir, o, notProven, signal, ctx.emit),
|
|
18011
18025
|
log_seal: true,
|
|
18012
18026
|
toolchain: collectToolchain(),
|
|
@@ -18062,14 +18076,14 @@ var init_seal = __esm(() => {
|
|
|
18062
18076
|
});
|
|
18063
18077
|
|
|
18064
18078
|
// ../../loki-ts/src/util/composite_seal.ts
|
|
18065
|
-
import { existsSync as existsSync48, readFileSync as
|
|
18079
|
+
import { existsSync as existsSync48, readFileSync as readFileSync59 } from "fs";
|
|
18066
18080
|
import { basename as basename27, dirname as dirname32, join as join71 } from "path";
|
|
18067
18081
|
function logProblem(runDir, integ) {
|
|
18068
18082
|
if (typeof integ["log_sha256"] !== "string")
|
|
18069
18083
|
return null;
|
|
18070
18084
|
let b;
|
|
18071
18085
|
try {
|
|
18072
|
-
b =
|
|
18086
|
+
b = readFileSync59(join71(runDir, "integration.log"));
|
|
18073
18087
|
} catch {
|
|
18074
18088
|
return "integration.log is missing but integration.json records its hash";
|
|
18075
18089
|
}
|
|
@@ -18092,7 +18106,7 @@ async function verifyComposite(receiptPath, receipt, rh, verifyOne, deps = {}) {
|
|
|
18092
18106
|
return bad("body malformed");
|
|
18093
18107
|
let ibytes;
|
|
18094
18108
|
try {
|
|
18095
|
-
ibytes =
|
|
18109
|
+
ibytes = readFileSync59(join71(runDir, "integration.json"));
|
|
18096
18110
|
} catch {
|
|
18097
18111
|
return bad("integration.json missing");
|
|
18098
18112
|
}
|
|
@@ -18136,7 +18150,7 @@ async function verifyComposite(receiptPath, receipt, rh, verifyOne, deps = {}) {
|
|
|
18136
18150
|
const rp = join71(runDir, rel);
|
|
18137
18151
|
let bytes;
|
|
18138
18152
|
try {
|
|
18139
|
-
bytes =
|
|
18153
|
+
bytes = readFileSync59(rp);
|
|
18140
18154
|
} catch {
|
|
18141
18155
|
return bad(`child ${repo} receipt missing`);
|
|
18142
18156
|
}
|
|
@@ -18185,16 +18199,16 @@ var init_keys_cmd = __esm(() => {
|
|
|
18185
18199
|
});
|
|
18186
18200
|
|
|
18187
18201
|
// ../../loki-ts/src/engine10/verify_cmd.ts
|
|
18188
|
-
import { existsSync as existsSync49, readFileSync as
|
|
18202
|
+
import { existsSync as existsSync49, readFileSync as readFileSync60, renameSync as renameSync15, statSync as statSync24, writeFileSync as writeFileSync34 } from "fs";
|
|
18189
18203
|
import { basename as basename28, dirname as dirname33, join as join72 } from "path";
|
|
18190
|
-
import { createHash as
|
|
18204
|
+
import { createHash as createHash22, createPublicKey as createPublicKey4, verify as verify4 } from "crypto";
|
|
18191
18205
|
function pubFor(kid, given) {
|
|
18192
18206
|
if (given)
|
|
18193
18207
|
return kidOf2(given) === kid ? given : undefined;
|
|
18194
18208
|
const active = loadSigningKey(false);
|
|
18195
18209
|
const pubs = (process.env["LOKI_RECEIPT_RETIRED_PUBKEYS"] ?? "").split(":").map((f) => f.trim()).filter(Boolean).flatMap((f) => {
|
|
18196
18210
|
try {
|
|
18197
|
-
return [createPublicKey4(
|
|
18211
|
+
return [createPublicKey4(readFileSync60(f))];
|
|
18198
18212
|
} catch {
|
|
18199
18213
|
return [];
|
|
18200
18214
|
}
|
|
@@ -18233,7 +18247,7 @@ function checkEventLog(receiptPath, receipt) {
|
|
|
18233
18247
|
}
|
|
18234
18248
|
if (typeof bound !== "string")
|
|
18235
18249
|
return null;
|
|
18236
|
-
if (bound ===
|
|
18250
|
+
if (bound === createHash22("sha256").digest("hex")) {
|
|
18237
18251
|
const st = receipt["time"]?.stages;
|
|
18238
18252
|
const claims = st !== null && typeof st === "object" && Object.keys(st).length > 0;
|
|
18239
18253
|
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;
|
|
@@ -18241,13 +18255,13 @@ function checkEventLog(receiptPath, receipt) {
|
|
|
18241
18255
|
const path = join72(dirname33(receiptPath), "events.jsonl");
|
|
18242
18256
|
if (!existsSync49(path))
|
|
18243
18257
|
return "events.jsonl is missing";
|
|
18244
|
-
const raw2 =
|
|
18258
|
+
const raw2 = readFileSync60(path, "utf8"), events2 = readEvents(path), lines2 = raw2.split(`
|
|
18245
18259
|
`).filter((l) => l.trim() !== "");
|
|
18246
18260
|
if (events2.length !== lines2.length || events2.some((e, i) => e.seq !== i))
|
|
18247
18261
|
return "events.jsonl has a forged, edited or missing line";
|
|
18248
18262
|
if (events2.some((e) => e.type === "tamper.detected"))
|
|
18249
18263
|
return "the supervisor detected events.jsonl being modified during the run";
|
|
18250
|
-
const h =
|
|
18264
|
+
const h = createHash22("sha256");
|
|
18251
18265
|
for (const l of lines2) {
|
|
18252
18266
|
if (h.copy().digest("hex") === bound)
|
|
18253
18267
|
return null;
|
|
@@ -18265,8 +18279,8 @@ function checkLogSeal(receiptPath, hash, kid, given) {
|
|
|
18265
18279
|
const seal = events2[done + 1], d = seal?.type === "log.sealed" ? seal.data : null;
|
|
18266
18280
|
if (!d)
|
|
18267
18281
|
return { verdict: "TAMPERED", reason: "events.jsonl has no signed log.sealed line after run.completed" };
|
|
18268
|
-
const lines2 =
|
|
18269
|
-
`).filter((l) => l.trim() !== ""), sha4 =
|
|
18282
|
+
const lines2 = readFileSync60(path, "utf8").split(`
|
|
18283
|
+
`).filter((l) => l.trim() !== ""), sha4 = createHash22("sha256").update(lines2.slice(0, done + 1).join(`
|
|
18270
18284
|
`) + `
|
|
18271
18285
|
`).digest("hex");
|
|
18272
18286
|
const pub = d["kid"] === kid ? pubFor(kid, given) : undefined;
|
|
@@ -18279,7 +18293,7 @@ async function verifyReceipt(receiptPath, deps = {}) {
|
|
|
18279
18293
|
return { verdict: "UNCHECKED", reasons: [`receipt not found: ${receiptPath}`] };
|
|
18280
18294
|
let receipt;
|
|
18281
18295
|
try {
|
|
18282
|
-
receipt = JSON.parse((deps.read ?? ((p) =>
|
|
18296
|
+
receipt = JSON.parse((deps.read ?? ((p) => readFileSync60(p, "utf8")))(receiptPath));
|
|
18283
18297
|
} catch {
|
|
18284
18298
|
return { verdict: "UNCHECKED", reasons: ["receipt.json is not valid JSON"] };
|
|
18285
18299
|
}
|
|
@@ -18368,8 +18382,8 @@ var init_verify_cmd = __esm(() => {
|
|
|
18368
18382
|
});
|
|
18369
18383
|
|
|
18370
18384
|
// src/server/app.ts
|
|
18371
|
-
import { existsSync as existsSync51, readFileSync as
|
|
18372
|
-
import { join as join75, resolve as
|
|
18385
|
+
import { existsSync as existsSync51, readFileSync as readFileSync63, statSync as statSync25 } from "fs";
|
|
18386
|
+
import { join as join75, resolve as resolve20, sep as sep16 } from "path";
|
|
18373
18387
|
|
|
18374
18388
|
// node_modules/hono/dist/request/constants.js
|
|
18375
18389
|
var GET_MATCH_RESULT = Symbol();
|
|
@@ -28680,7 +28694,7 @@ function mount20(ctx) {
|
|
|
28680
28694
|
}
|
|
28681
28695
|
|
|
28682
28696
|
// src/server/routes/verify.ts
|
|
28683
|
-
import { readFileSync as
|
|
28697
|
+
import { readFileSync as readFileSync61, realpathSync as realpathSync25 } from "fs";
|
|
28684
28698
|
import { createPublicKey as createPublicKey5 } from "crypto";
|
|
28685
28699
|
import { join as join73, sep as sep15 } from "path";
|
|
28686
28700
|
init_verify_cmd();
|
|
@@ -28732,7 +28746,7 @@ function mount21(ctx) {
|
|
|
28732
28746
|
sha4 = r.receiptSha256 ?? null;
|
|
28733
28747
|
}
|
|
28734
28748
|
try {
|
|
28735
|
-
outcome = outcomeOf(JSON.parse(
|
|
28749
|
+
outcome = outcomeOf(JSON.parse(readFileSync61(file, "utf8")));
|
|
28736
28750
|
} catch {
|
|
28737
28751
|
outcome = "UNREADABLE";
|
|
28738
28752
|
}
|
|
@@ -28794,7 +28808,7 @@ function ttlCache(ttlMs = PROBE_CACHE_MS, now2 = Date.now) {
|
|
|
28794
28808
|
}
|
|
28795
28809
|
|
|
28796
28810
|
// src/server/legacy/shim.ts
|
|
28797
|
-
import { existsSync as existsSync50, readFileSync as
|
|
28811
|
+
import { existsSync as existsSync50, readFileSync as readFileSync62 } from "fs";
|
|
28798
28812
|
import { join as join74 } from "path";
|
|
28799
28813
|
|
|
28800
28814
|
// src/server/legacy/routes.ts
|
|
@@ -29176,7 +29190,7 @@ var repoVersion = () => {
|
|
|
29176
29190
|
for (const f of [join74(import.meta.dir, "../../../../../VERSION")]) {
|
|
29177
29191
|
try {
|
|
29178
29192
|
if (existsSync50(f))
|
|
29179
|
-
return
|
|
29193
|
+
return readFileSync62(f, "utf8").trim();
|
|
29180
29194
|
} catch {}
|
|
29181
29195
|
}
|
|
29182
29196
|
return "unknown";
|
|
@@ -29390,7 +29404,7 @@ function createApp(opts) {
|
|
|
29390
29404
|
for (const f of [process.env.LOKI_VERSION_FILE, join75(import.meta.dir, "../../../../VERSION")]) {
|
|
29391
29405
|
try {
|
|
29392
29406
|
if (f)
|
|
29393
|
-
return
|
|
29407
|
+
return readFileSync63(f, "utf8").trim() || "unknown";
|
|
29394
29408
|
} catch {}
|
|
29395
29409
|
}
|
|
29396
29410
|
return "unknown";
|
|
@@ -29499,8 +29513,8 @@ function createApp(opts) {
|
|
|
29499
29513
|
}
|
|
29500
29514
|
if (!uiDir || p.startsWith("/v1/"))
|
|
29501
29515
|
return c.json({ error: "not found" }, 404);
|
|
29502
|
-
const root =
|
|
29503
|
-
const f =
|
|
29516
|
+
const root = resolve20(uiDir);
|
|
29517
|
+
const f = resolve20(root, `.${p}`);
|
|
29504
29518
|
if (f.startsWith(root + sep16) && existsSync51(f) && statSync25(f).isFile())
|
|
29505
29519
|
return new Response(Bun.file(f));
|
|
29506
29520
|
if (/\.[a-z0-9]+$/i.test(p))
|