loki-mode 11.121.0 → 11.123.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SKILL.md +2 -2
- package/VERSION +1 -1
- package/dashboard/__init__.py +1 -1
- package/docs/CLI-REFERENCE.md +1 -1
- package/docs/INSTALLATION.md +1 -1
- package/loki-ts/dist/loki.js +1462 -1458
- package/mcp/__init__.py +1 -1
- package/package.json +2 -2
- package/packages/control-plane/dist/server.js +474 -117
- package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
- package/web-app/dist/assets/{AdminPage-BfxkhFXl.js → AdminPage-D1Pq4MQi.js} +1 -1
- package/web-app/dist/assets/{Avatar-xV4rK0ps.js → Avatar-A2BFZ8T8.js} +1 -1
- package/web-app/dist/assets/{Badge-Ds_E82Ka.js → Badge-BeAiw5Sl.js} +1 -1
- package/web-app/dist/assets/{Button-BXAwY0ni.js → Button-DprfqpF8.js} +1 -1
- package/web-app/dist/assets/{CockpitPage-y3R9sk_M.js → CockpitPage-C4h6TT-c.js} +1 -1
- package/web-app/dist/assets/{ComparePage-BGbCno4C.js → ComparePage-apBsndqK.js} +1 -1
- package/web-app/dist/assets/{ErrorBoundary-DGqkzHdy.js → ErrorBoundary-B6mK7ggZ.js} +1 -1
- package/web-app/dist/assets/{EvidenceReceiptPanel-Bj57TWoJ.js → EvidenceReceiptPanel-DNEXfKYK.js} +1 -1
- package/web-app/dist/assets/{GitHubIssuesPanel-CVbtUCRI.js → GitHubIssuesPanel-BHMnS0dv.js} +1 -1
- package/web-app/dist/assets/{GitHubPRsPanel-DuNxI0k8.js → GitHubPRsPanel-Bg1hQTBZ.js} +1 -1
- package/web-app/dist/assets/{HomePage-DogFuRvt.js → HomePage-C0uIfnbC.js} +2 -2
- package/web-app/dist/assets/{LoginPage-U-r-YNKC.js → LoginPage-C5W1PwxV.js} +1 -1
- package/web-app/dist/assets/{MagicPage-C5iDqK4d.js → MagicPage-B9v5J6kn.js} +1 -1
- package/web-app/dist/assets/{MetricsPage-COVYOGfr.js → MetricsPage-TyFW2Mi7.js} +1 -1
- package/web-app/dist/assets/{NotFoundPage-CZii6Z0s.js → NotFoundPage-fhomLjyo.js} +1 -1
- package/web-app/dist/assets/{ProjectPage-QwOZzVqj.js → ProjectPage-B7Q9_E7J.js} +3 -3
- package/web-app/dist/assets/{ProjectsPage-BcxVfXVW.js → ProjectsPage-BRlw-ztJ.js} +1 -1
- package/web-app/dist/assets/{SettingsPage-CBY9JiAE.js → SettingsPage-DBS-DpXz.js} +1 -1
- package/web-app/dist/assets/{ShowcasePage-D1YPQOp7.js → ShowcasePage-C609Y2vd.js} +1 -1
- package/web-app/dist/assets/{SystemSettingsPage-DcpAC9Lg.js → SystemSettingsPage-CpZ_F3Pz.js} +1 -1
- package/web-app/dist/assets/{TeamsPage-BTiJPkD4.js → TeamsPage-C8gdvyoH.js} +1 -1
- package/web-app/dist/assets/{TemplatesPage-LUa3bH-A.js → TemplatesPage-JcmMFDss.js} +1 -1
- package/web-app/dist/assets/{TerminalOutput-BM8LH-RG.js → TerminalOutput-DeKTksvK.js} +1 -1
- package/web-app/dist/assets/{activity-mZHuLoR5.js → activity-fohF0bEH.js} +1 -1
- package/web-app/dist/assets/{bell-BR_y_nMB.js → bell-DXoB51yh.js} +1 -1
- package/web-app/dist/assets/{bot-Ct3caGMX.js → bot-ozfD3tc3.js} +1 -1
- package/web-app/dist/assets/{check-DuQpq9PN.js → check-DJIvauO5.js} +1 -1
- package/web-app/dist/assets/{chevron-left-CWSfVWba.js → chevron-left-DubgZZGE.js} +1 -1
- package/web-app/dist/assets/{circle-alert-C7TCj9Jm.js → circle-alert-DVP3spwP.js} +1 -1
- package/web-app/dist/assets/{clock-BFsj3bRT.js → clock-D0y8bHsc.js} +1 -1
- package/web-app/dist/assets/{cloud-78sYPXff.js → cloud-AZw6GZdP.js} +1 -1
- package/web-app/dist/assets/{code-xml-DuwBCDz-.js → code-xml-lxx2SVRo.js} +1 -1
- package/web-app/dist/assets/{database-CwRTYKVV.js → database-DSHk51Pu.js} +1 -1
- package/web-app/dist/assets/{dollar-sign-COXAsjgd.js → dollar-sign-jBZCz460.js} +1 -1
- package/web-app/dist/assets/{file-code-corner-A8LPVBBy.js → file-code-corner-HGtDqBI1.js} +1 -1
- package/web-app/dist/assets/{file-plus-D9IXE7YW.js → file-plus-L3tAznio.js} +1 -1
- package/web-app/dist/assets/{globe-Ce6xgdLR.js → globe-f50xCoGa.js} +1 -1
- package/web-app/dist/assets/{hammer-Dtq836Al.js → hammer-Btdop6UY.js} +1 -1
- package/web-app/dist/assets/{index-uce16-nn.js → index-alvwtVBH.js} +3 -3
- package/web-app/dist/assets/{layers-BOQdqOXk.js → layers-WZi-3fiX.js} +1 -1
- package/web-app/dist/assets/{loader-circle-D3y4SHAn.js → loader-circle-B13s_pbT.js} +1 -1
- package/web-app/dist/assets/{lock-miFONHLo.js → lock-DPzrJtGd.js} +1 -1
- package/web-app/dist/assets/{package-ckZFIHTG.js → package-q3dYbP9u.js} +1 -1
- package/web-app/dist/assets/{plus-COJKSbOp.js → plus-nLd8kLVM.js} +1 -1
- package/web-app/dist/assets/{refresh-cw-rPt-Oa4a.js → refresh-cw-T4m4o3p9.js} +1 -1
- package/web-app/dist/assets/{rotate-ccw-Dy50K31A.js → rotate-ccw-BsPRTRVr.js} +1 -1
- package/web-app/dist/assets/{scroll-text-CbczPkkS.js → scroll-text-BKYY62-4.js} +1 -1
- package/web-app/dist/assets/{server-HkfTEf2O.js → server-WY0czRua.js} +1 -1
- package/web-app/dist/assets/{shield-alert-DjKF0yba.js → shield-alert-JFzWB4HO.js} +1 -1
- package/web-app/dist/assets/{thumbs-up-aObjUDQm.js → thumbs-up-DY-6b3kG.js} +1 -1
- package/web-app/dist/assets/{trash-2-CQfI6Z-c.js → trash-2-Rij5mMzF.js} +1 -1
- package/web-app/dist/assets/{trending-down-CP7J5aPV.js → trending-down-BwEIkU-x.js} +1 -1
- package/web-app/dist/assets/{trending-up-CTJHoPnm.js → trending-up-Coe2CO4y.js} +1 -1
- package/web-app/dist/assets/{upload-i1zoXd2k.js → upload-CPuWWzzF.js} +1 -1
- package/web-app/dist/assets/{usePolling-CZG-IV1Y.js → usePolling-Ce5XHOw4.js} +1 -1
- package/web-app/dist/assets/{user-CJwbwmPE.js → user-D1q10hes.js} +1 -1
- package/web-app/dist/index.html +1 -1
|
@@ -17985,7 +17985,7 @@ const done = (code, sig) => { if (fin) return; fin = true; kill("SIGKILL"); try
|
|
|
17985
17985
|
setTimeout(() => { to = true; kill("SIGTERM"); setTimeout(() => done(null, 1), 1000); }, ms);
|
|
17986
17986
|
const over = () => { if (out.length > MAX || err.length > MAX) { to = true; kill("SIGKILL"); } };
|
|
17987
17987
|
c.stdout.on("data", (d) => { out += d; over(); }); c.stderr.on("data", (d) => { err += d; over(); });
|
|
17988
|
-
c.on("error", () => done(null, 1)); c.on("close", done); c.on("exit", (a, b) => setTimeout(() => done(a, b), 500)); `, FULL_SUITE_STATIC, BUILD_TOOL_RUNNERS, ALREADY_FAILING_ON_BASE = "already failing on base, not caused by this change", SKIPPED_BY_REPO = "skipped by the repo on base and head", checkResultLabel = (result, preRed, repoSkipped = false) => result === "fail" && preRed ? `fail (${ALREADY_FAILING_ON_BASE})` : result === "not_run" && repoSkipped ? `not_run (${SKIPPED_BY_REPO})` : result, blobSha = (b, hex) => createHash13(hex === 64 ? "sha256" : "sha1").update(Buffer.concat([Buffer.from(`blob ${b.length}\x00`), b])).digest("hex"), URL_RE, ANCHOR_RE, EXTENSIONLESS;
|
|
17988
|
+
c.on("error", () => done(null, 1)); c.on("close", done); c.on("exit", (a, b) => setTimeout(() => done(a, b), 500)); `, FULL_SUITE_STATIC, BUILD_TOOL_RUNNERS, WALL_FAILURE_TAIL_FILE = "wall-failure-tail.txt", ALREADY_FAILING_ON_BASE = "already failing on base, not caused by this change", SKIPPED_BY_REPO = "skipped by the repo on base and head", checkResultLabel = (result, preRed, repoSkipped = false) => result === "fail" && preRed ? `fail (${ALREADY_FAILING_ON_BASE})` : result === "not_run" && repoSkipped ? `not_run (${SKIPPED_BY_REPO})` : result, blobSha = (b, hex) => createHash13(hex === 64 ? "sha256" : "sha1").update(Buffer.concat([Buffer.from(`blob ${b.length}\x00`), b])).digest("hex"), URL_RE, ANCHOR_RE, EXTENSIONLESS;
|
|
17989
17989
|
var init_check_result = __esm(() => {
|
|
17990
17990
|
init_stack_tools();
|
|
17991
17991
|
init_dotnet_test();
|
|
@@ -21386,6 +21386,13 @@ var init_install = __esm(() => {
|
|
|
21386
21386
|
STATUS_MAX_BUFFER = 64 * 1024 * 1024;
|
|
21387
21387
|
});
|
|
21388
21388
|
|
|
21389
|
+
// ../../loki-ts/src/contrib/wall_snapshot.ts
|
|
21390
|
+
var MANIFESTS2;
|
|
21391
|
+
var init_wall_snapshot = __esm(() => {
|
|
21392
|
+
init_safe_git();
|
|
21393
|
+
MANIFESTS2 = /(^|\/)(package\.json|package-lock\.json|npm-shrinkwrap\.json|yarn\.lock|pnpm-lock\.yaml|bun\.lockb?|pyproject\.toml|poetry\.lock|Pipfile(\.lock)?|requirements[^/]*\.txt|setup\.py|setup\.cfg|go\.(mod|sum)|Cargo\.(toml|lock))$/;
|
|
21394
|
+
});
|
|
21395
|
+
|
|
21389
21396
|
// ../../loki-ts/src/features/runner_config.ts
|
|
21390
21397
|
import { createHash as createHash19 } from "crypto";
|
|
21391
21398
|
import { readdirSync as readdirSync24, readFileSync as readFileSync55 } from "fs";
|
|
@@ -23450,7 +23457,7 @@ function commitUnsealedWork(intact, repoDir, workerEnv, runId, intake) {
|
|
|
23450
23457
|
const keys = (o) => o && typeof o === "object" ? Object.keys(o) : [];
|
|
23451
23458
|
const users = [...keys(intake["preexisting_dirty"]), ...keys(intake["preexisting_untracked_blobs"]), ...Array.isArray(intake["preexisting_untracked"]) ? intake["preexisting_untracked"].map(String) : []];
|
|
23452
23459
|
g(["add", "-A", "--", "."]);
|
|
23453
|
-
const keep = g(["--literal-pathspecs", "ls-files", "--cached", "-z", "--", "
|
|
23460
|
+
const spec = ["--", ".loki", ...new Set(users)], keep = [...new Set([...g(["--literal-pathspecs", "ls-files", "--cached", "-z", ...spec]).split("\x00"), ...g(["--literal-pathspecs", "diff", "--cached", "--name-only", "--no-renames", "-z", ...spec]).split("\x00")].filter(Boolean))];
|
|
23454
23461
|
if (keep.length > 0)
|
|
23455
23462
|
g(["--literal-pathspecs", "reset", "-q", "HEAD", "--", ...keep]);
|
|
23456
23463
|
try {
|
|
@@ -27036,7 +27043,7 @@ function* installCore(ctx, a, baseDir, opts) {
|
|
|
27036
27043
|
}
|
|
27037
27044
|
ctx.wallSealed = true;
|
|
27038
27045
|
ctx.emit("wall.sealed", "wall", { files: sealedFiles, ...a.manifestSha256 ? { manifest_sha256: a.manifestSha256 } : {} });
|
|
27039
|
-
const baseRunner = opts.baseRunner ?? new RealBaseTestRunner, baseRun = { pass: 0, fail: 0, not_run: discarded.length }, notRunFiles = [];
|
|
27046
|
+
const baseRunner = opts.baseRunner ?? new RealBaseTestRunner(baseDir !== ctx.repoDir ? loadProjectApi(ctx.repoDir) : undefined), baseRun = { pass: 0, fail: 0, not_run: discarded.length }, notRunFiles = [];
|
|
27040
27047
|
for (const f of sealedFiles) {
|
|
27041
27048
|
const rel = relative16(ctx.repoDir, f.path);
|
|
27042
27049
|
if (!wallTests.some((t) => t.path === rel))
|
|
@@ -30191,7 +30198,7 @@ function supplyVerdict(verdict, r) {
|
|
|
30191
30198
|
return r.blocked && verdict === "VERIFIED" ? "FAILED" : verdict;
|
|
30192
30199
|
}
|
|
30193
30200
|
function isManifestPath(path) {
|
|
30194
|
-
return
|
|
30201
|
+
return MANIFESTS3.test(basename25(path));
|
|
30195
30202
|
}
|
|
30196
30203
|
function readDeclared(repoDir) {
|
|
30197
30204
|
const p = join94(repoDir, ".loki", DECLARED_FILE);
|
|
@@ -30389,7 +30396,7 @@ async function supplyGuard(repoDir, changedFiles2, declared, env, opts = {}) {
|
|
|
30389
30396
|
}
|
|
30390
30397
|
return { block: { guard: "v2", warn_age_days: MIN_AGE_DAYS, fail_age_days: failAge, declared: declared.deps.length, entries }, notProven, blocked };
|
|
30391
30398
|
}
|
|
30392
|
-
var MIN_AGE_DAYS = 7, DECLARED_FILE = "supply-declared.json", MAX_CHECKED = 50, MAX_DECLARED = 200, MAX_FILE_BYTES, DAY_MS = 86400000,
|
|
30399
|
+
var MIN_AGE_DAYS = 7, DECLARED_FILE = "supply-declared.json", MAX_CHECKED = 50, MAX_DECLARED = 200, MAX_FILE_BYTES, DAY_MS = 86400000, MANIFESTS3, ECO, NAME2, defaultResolver = async (dep, cwd) => {
|
|
30393
30400
|
const argv = {
|
|
30394
30401
|
npm: ["npm", "view", dep.name, "time.created", "--json"],
|
|
30395
30402
|
pypi: ["pip", "index", "versions", "--pre", "--ignore-requires-python", dep.name],
|
|
@@ -30415,7 +30422,7 @@ var MIN_AGE_DAYS = 7, DECLARED_FILE = "supply-declared.json", MAX_CHECKED = 50,
|
|
|
30415
30422
|
var init_supply_guard = __esm(() => {
|
|
30416
30423
|
init_shell();
|
|
30417
30424
|
MAX_FILE_BYTES = 64 * 1024;
|
|
30418
|
-
|
|
30425
|
+
MANIFESTS3 = /^(package\.json|package-lock\.json|npm-shrinkwrap\.json|yarn\.lock|pnpm-lock\.yaml|bun\.lockb?|requirements.*\.txt|pyproject\.toml|poetry\.lock|uv\.lock|Pipfile|Pipfile\.lock|go\.mod|go\.sum|Cargo\.toml|Cargo\.lock|Gemfile|Gemfile\.lock|composer\.json|composer\.lock|pom\.xml|build\.gradle(\.kts)?)$/;
|
|
30419
30426
|
ECO = { npm: "npm", node: "npm", pypi: "pypi", pip: "pypi", python: "pypi", cargo: "cargo", crates: "cargo", go: "go", golang: "go" };
|
|
30420
30427
|
NAME2 = /^[A-Za-z0-9@][A-Za-z0-9@._/~+-]{0,213}$/;
|
|
30421
30428
|
PUBLIC_HOSTS = new Set(["registry.npmjs.org", "registry.npmjs.com", "registry.yarnpkg.com", "npmjs.com", "npmjs.org", "pypi.org", "pypi.python.org", "files.pythonhosted.org", "crates.io", "index.crates.io", "static.crates.io", "proxy.golang.org", "golang.org", "pkg.go.dev"]);
|
|
@@ -32819,6 +32826,13 @@ function defaultLoader(dir) {
|
|
|
32819
32826
|
return mod ? mod.stage ?? mod.default ?? null : null;
|
|
32820
32827
|
};
|
|
32821
32828
|
}
|
|
32829
|
+
function stillFailing(groups, kept) {
|
|
32830
|
+
const g2 = Array.isArray(groups) ? groups : [], green = (Array.isArray(kept) ? kept : []).filter((c) => c?.result === "pass" || c?.result === "flaky").map((c) => String(c.name));
|
|
32831
|
+
return g2.filter((x) => {
|
|
32832
|
+
const s = String(x?.signature ?? "");
|
|
32833
|
+
return !green.some((n3) => s === n3 || s.startsWith(`${n3} `));
|
|
32834
|
+
});
|
|
32835
|
+
}
|
|
32822
32836
|
function softCapS(capS) {
|
|
32823
32837
|
const plain = capS * 14 / 15, budget = backstopS(capS) - ((STAGE_BUDGETS.commit.targetS ?? 0) + (STAGE_BUDGETS.seal.targetS ?? 0) + KILL_GRACE_MS3 / 1000 + 2);
|
|
32824
32838
|
return Math.max(0, Math.min(plain, budget));
|
|
@@ -32879,6 +32893,7 @@ ${timeBudgetNote(limitS)}`;
|
|
|
32879
32893
|
};
|
|
32880
32894
|
let implementBudgetS = 0;
|
|
32881
32895
|
const implementLimitS = (floorS) => Math.max(floorS, Math.floor(softCapS(ctx.capS) - elapsedS2() - (STAGE_BUDGETS.verify.limitS ?? 0)));
|
|
32896
|
+
const fixLimitS = (baseS) => Math.max(baseS, Math.min(2 * baseS, Math.round(baseS * ctx.capS / DEFAULT_CAP_S)));
|
|
32882
32897
|
const verifyLimitS = (floorS) => Math.max(floorS, Math.floor(softCapS(ctx.capS) - elapsedS2() - VERIFY_RESERVE_S));
|
|
32883
32898
|
const runStage = async (name, underCap) => {
|
|
32884
32899
|
const st = await load(name);
|
|
@@ -32890,7 +32905,7 @@ ${timeBudgetNote(limitS)}`;
|
|
|
32890
32905
|
markCap(name);
|
|
32891
32906
|
return null;
|
|
32892
32907
|
}
|
|
32893
|
-
const limitS = name === "implement" ? ctx.deep ? DEEP_IMPLEMENT_LIMIT_S : st.limitS >= STAGE_BUDGETS.implement.limitS ? implementLimitS(st.limitS) : st.limitS : (name === "verify" && st.limitS >= STAGE_BUDGETS.verify.limitS ? verifyLimitS(st.limitS) : st.limitS) + (st.extraLimitS?.(sctx) ?? 0);
|
|
32908
|
+
const limitS = name === "implement" ? ctx.deep ? DEEP_IMPLEMENT_LIMIT_S : st.limitS >= STAGE_BUDGETS.implement.limitS ? implementLimitS(st.limitS) : st.limitS : (name === "verify" && st.limitS >= STAGE_BUDGETS.verify.limitS ? verifyLimitS(st.limitS) : name === "fix" ? fixLimitS(st.limitS) : st.limitS) + (st.extraLimitS?.(sctx) ?? 0);
|
|
32894
32909
|
if (name === "implement") {
|
|
32895
32910
|
implementBudgetS = limitS;
|
|
32896
32911
|
implementStartMs = ctx.clock.now();
|
|
@@ -32949,7 +32964,7 @@ ${timeBudgetNote(limitS)}`;
|
|
|
32949
32964
|
const kept = name === "verify" ? settled?.status === "completed" ? settled.data : partials.verify : undefined;
|
|
32950
32965
|
if (kept) {
|
|
32951
32966
|
const prev = outputs.verify;
|
|
32952
|
-
outputs.verify = { ...kept, failures_grouped: prev?.failures_grouped
|
|
32967
|
+
outputs.verify = { ...kept, failures_grouped: stillFailing(prev?.failures_grouped, kept.checks), holdout_failed: prev?.holdout_failed ?? 0, not_proven: [...Array.isArray(kept.not_proven) ? kept.not_proven : [], VERIFY_STOPPED_NOTE[why]], stopped_at: why, duration_s: dur() };
|
|
32953
32968
|
}
|
|
32954
32969
|
if (name === "implement" && why === "limit") {
|
|
32955
32970
|
const ro = outputs.wall?.readOnlyFiles ?? [], reverted = [...restoreReadOnly(ro).map((f) => relative24(ctx.repoDir, f)), ...restoreBaseTests(ctx.repoDir, ctx.baseSha, outputs.intake)];
|
|
@@ -33149,6 +33164,7 @@ ${timeBudgetNote(limitS)}`;
|
|
|
33149
33164
|
let extraRounds = 0;
|
|
33150
33165
|
let noopSig = null;
|
|
33151
33166
|
for (let round2 = 1;round2 <= MAX_FIX_ROUNDS + extraRounds && hasFailures(outputs.verify) && outputs.implement?.exit !== "spec_conflict" && outputs.implement?.exit !== "external"; round2++) {
|
|
33167
|
+
const wallBefore = wallSignature(outputs, ctx.repoDir);
|
|
33152
33168
|
const fx = await runStage("fix", true);
|
|
33153
33169
|
if (!fx || mustJump("fix", fx) || fatal)
|
|
33154
33170
|
break;
|
|
@@ -33169,6 +33185,8 @@ ${timeBudgetNote(limitS)}`;
|
|
|
33169
33185
|
sigs.push(sigOf(outputs.verify, v));
|
|
33170
33186
|
if (mustJump("verify", v))
|
|
33171
33187
|
break;
|
|
33188
|
+
if (wallOnlyAfterFix(outputs, ctx.repoDir) && wallSignature(outputs, ctx.repoDir) === wallBefore)
|
|
33189
|
+
break;
|
|
33172
33190
|
if (hasFailures(outputs.verify) && sigs.length >= 2 && sigs.slice(-2).every((x) => x === sigs[sigs.length - 1])) {
|
|
33173
33191
|
const up = stallClimb(ctx.model, outputs, sigs[sigs.length - 1] ?? "");
|
|
33174
33192
|
if (up) {
|
|
@@ -33181,7 +33199,8 @@ ${timeBudgetNote(limitS)}`;
|
|
|
33181
33199
|
break;
|
|
33182
33200
|
}
|
|
33183
33201
|
}
|
|
33184
|
-
|
|
33202
|
+
const wasConflict = outputs.implement?.exit === "spec_conflict";
|
|
33203
|
+
if (!fatal && !capHit && stopped === null && await deliverOverWallConflict(outputs, ctx.repoDir, () => runStage("verify", true), (path, why) => ctx.emit("wall.arbitrated", "wall", { path, discarded: why }), { runDir: ctx.runDir, restored: (v) => ctx.emit("stage.completed", "verify", { ...v, restored: true }) }) && wasConflict)
|
|
33185
33204
|
ctx.emit("spec.conflict", "implement", { delivered: true, reason: outputs.implement?.spec_conflict_reason ?? null });
|
|
33186
33205
|
if (fatal) {
|
|
33187
33206
|
stopped = fatal;
|
|
@@ -38820,16 +38839,17 @@ function parseDecomposition(text4) {
|
|
|
38820
38839
|
seen.add(o.id);
|
|
38821
38840
|
if (typeof o.title !== "string" || !o.title.trim() || o.title.length > 200)
|
|
38822
38841
|
return { ok: false, reason: `${o.id}: title must be a non-empty string of at most 200 characters` };
|
|
38823
|
-
const acceptance2 = strList(o.acceptance, 20);
|
|
38842
|
+
const acceptance2 = strList(o.acceptance, 20, true);
|
|
38824
38843
|
if (!acceptance2 || acceptance2.length === 0)
|
|
38825
|
-
return { ok: false, reason: `${o.id}: acceptance must be
|
|
38826
|
-
const deps = o.depends_on === undefined ? [] : strList(o.depends_on,
|
|
38844
|
+
return { ok: false, reason: `${o.id}: acceptance must be a list holding at least one non-empty string` };
|
|
38845
|
+
const deps = o.depends_on === undefined ? [] : strList(o.depends_on, Infinity);
|
|
38827
38846
|
if (!deps)
|
|
38828
38847
|
return { ok: false, reason: `${o.id}: depends_on must be a list of slice ids` };
|
|
38829
38848
|
const files = o.files === undefined ? [] : strList(o.files, 50);
|
|
38830
38849
|
if (!files)
|
|
38831
38850
|
return { ok: false, reason: `${o.id}: files must be a list of paths` };
|
|
38832
|
-
|
|
38851
|
+
const listed = Array.isArray(o.files) ? new Set(o.files.filter((x) => typeof x === "string").map(oneLine3).filter((x) => x !== "")).size : 0, dropped2 = listed - files.length;
|
|
38852
|
+
slices.push({ id: o.id, title: oneLine3(o.title), acceptance: acceptance2, depends_on: [...new Set(deps)], files, ...dropped2 > 0 ? { files_dropped: dropped2 } : {} });
|
|
38833
38853
|
}
|
|
38834
38854
|
for (const s of slices)
|
|
38835
38855
|
for (const d of s.depends_on)
|
|
@@ -38896,6 +38916,7 @@ function sliceTask(slug, epic, s, index2, total, parent) {
|
|
|
38896
38916
|
`This is slice ${index2 + 1} of a larger issue that was split into ${total} pull requests. Implement only this slice.` + (parent ? ` The branch already contains slice ${parent} and everything it depends on.` : ""),
|
|
38897
38917
|
`Acceptance criteria: ${s.acceptance.map((a, k) => `(${k + 1}) ${a}`).join("; ")}`,
|
|
38898
38918
|
s.files.length ? `Likely files: ${s.files.join(", ")}` : "",
|
|
38919
|
+
s.files_dropped ? `${s.files_dropped} more ${s.files_dropped === 1 ? "path was" : "paths were"} listed for this slice and dropped (past the 50-path cap, or too long to be a path); find the rest from the criteria.` : "",
|
|
38899
38920
|
`Parent issue: ${oneLine3(epic.title)}`
|
|
38900
38921
|
].filter(Boolean).join(`
|
|
38901
38922
|
|
|
@@ -39017,7 +39038,14 @@ function epicOutcome(rows, planUsd = [], env = process.env) {
|
|
|
39017
39038
|
`)}
|
|
39018
39039
|
` };
|
|
39019
39040
|
}
|
|
39020
|
-
var ID_RE2, MIN_SLICES = 2, MAX_SLICES = 4, oneLine3 = (s) => s.replace(/[\x00-\x1f\x7f]+/g, " ").replace(/\s+/g, " ").trim(),
|
|
39041
|
+
var ID_RE2, MIN_SLICES = 2, MAX_SLICES = 4, oneLine3 = (s) => s.replace(/[\x00-\x1f\x7f]+/g, " ").replace(/\s+/g, " ").trim(), PATH_MAX = 500, strList = (v, max, merge = false) => {
|
|
39042
|
+
if (!Array.isArray(v))
|
|
39043
|
+
return null;
|
|
39044
|
+
const items2 = [...new Set(v.filter((x) => typeof x === "string").map(oneLine3).filter((x) => x !== "" && (merge || x.length <= PATH_MAX)))];
|
|
39045
|
+
if (merge && items2.length > max)
|
|
39046
|
+
items2.splice(max - 1, items2.length, items2.slice(max - 1).join("; "));
|
|
39047
|
+
return items2.slice(0, max);
|
|
39048
|
+
}, overCapNote = (got) => `Your previous split had ${got} slices but the limit is ${MAX_SLICES}. Merge related slices so the plan has at most ${MAX_SLICES}, and write the corrected JSON object to the file.`, invalidSplitNote = (reason) => `Your previous split was refused: ${oneLine3(reason)}. Fix that and write the corrected JSON object to the file, in the same form.`, stacksOn = (r, needPr = true) => !!r && (!needPr || !!r.pr) && !!r.branch && !/^(FAILED|BLOCKED|SKIPPED)/.test(r.outcome), progressLine = (n3, p) => `#${n3} epic: ${p.done}/${p.total} slices done, ${p.running} running, ${p.waiting} waiting`;
|
|
39021
39049
|
var init_issues_epic = __esm(() => {
|
|
39022
39050
|
init_output();
|
|
39023
39051
|
ID_RE2 = /^[A-Za-z0-9_-]{1,32}$/;
|
|
@@ -39029,6 +39057,7 @@ __export(exports_issues_run, {
|
|
|
39029
39057
|
wholeRunTooLarge: () => wholeRunTooLarge,
|
|
39030
39058
|
triageBrief: () => triageBrief,
|
|
39031
39059
|
startIssueEpic: () => startIssueEpic,
|
|
39060
|
+
splitWithReask: () => splitWithReask,
|
|
39032
39061
|
runIssues: () => runIssues,
|
|
39033
39062
|
renderIssuesDigest: () => renderIssuesDigest,
|
|
39034
39063
|
parseTriage: () => parseTriage,
|
|
@@ -39378,10 +39407,11 @@ digest: ${join117(runDir, "digest.md")}
|
|
|
39378
39407
|
async function splitWithReask(d, slug, i, reason) {
|
|
39379
39408
|
try {
|
|
39380
39409
|
let p = parseDecomposition(await d.decompose(slug, i, reason));
|
|
39381
|
-
if (!p.ok
|
|
39382
|
-
d.out(`#${i.number} split had ${p.over} slices, over the cap; asking once more
|
|
39410
|
+
if (!p.ok) {
|
|
39411
|
+
d.out(p.over !== undefined ? `#${i.number} split had ${p.over} slices, over the cap; asking once more
|
|
39412
|
+
` : `#${i.number} split refused (${clip6(p.reason, 160)}); asking once more
|
|
39383
39413
|
`);
|
|
39384
|
-
p = parseDecomposition(await d.decompose(slug, i, reason, overCapNote(p.over)));
|
|
39414
|
+
p = parseDecomposition(await d.decompose(slug, i, reason, p.over !== undefined ? overCapNote(p.over) : invalidSplitNote(p.reason)));
|
|
39385
39415
|
}
|
|
39386
39416
|
return p;
|
|
39387
39417
|
} catch (e) {
|
|
@@ -46408,6 +46438,7 @@ __export(exports_base_guard, {
|
|
|
46408
46438
|
stackedOnLokiRun: () => stackedOnLokiRun,
|
|
46409
46439
|
splitDeclaredAdvisories: () => splitDeclaredAdvisories,
|
|
46410
46440
|
resolveBase: () => resolveBase,
|
|
46441
|
+
removeOwnWallFiles: () => removeOwnWallFiles,
|
|
46411
46442
|
noteOf: () => noteOf,
|
|
46412
46443
|
lazyZeroBaseline: () => lazyZeroBaseline,
|
|
46413
46444
|
keepRunBranch: () => keepRunBranch,
|
|
@@ -46417,9 +46448,11 @@ __export(exports_base_guard, {
|
|
|
46417
46448
|
envChangedSince: () => envChangedSince,
|
|
46418
46449
|
depsSeeHead: () => depsSeeHead,
|
|
46419
46450
|
baseLine: () => baseLine,
|
|
46451
|
+
baseDepsLinker: () => baseDepsLinker,
|
|
46420
46452
|
addedSymlinkNotes: () => addedSymlinkNotes
|
|
46421
46453
|
});
|
|
46422
46454
|
import { execFileSync as execFileSync9 } from "child_process";
|
|
46455
|
+
import { createHash as createHash39 } from "crypto";
|
|
46423
46456
|
import { existsSync as existsSync98, mkdirSync as mkdirSync73, mkdtempSync as mkdtempSync19, readdirSync as readdirSync44, readFileSync as readFileSync124, readlinkSync as readlinkSync7, realpathSync as realpathSync34, rmSync as rmSync37, statSync as statSync40, symlinkSync as symlinkSync4, utimesSync, writeFileSync as writeFileSync71 } from "fs";
|
|
46424
46457
|
import { tmpdir as tmpdir25 } from "os";
|
|
46425
46458
|
import { basename as basename36, dirname as dirname54, join as join143, relative as relative28, resolve as resolve38, sep as sep23 } from "path";
|
|
@@ -46510,7 +46543,8 @@ function baseLine(repoDir) {
|
|
|
46510
46543
|
const t = resolveBase(repoDir, undefined, false);
|
|
46511
46544
|
const sk = stackedOnLokiRun(repoDir, t);
|
|
46512
46545
|
const b = git13(repoDir, ["symbolic-ref", "-q", "--short", "HEAD"]) ?? "detached HEAD";
|
|
46513
|
-
|
|
46546
|
+
const same = !sk && t && /^loki\//.test(b) && git13(repoDir, ["rev-parse", "-q", "--verify", "HEAD^{commit}"]) === git13(repoDir, ["rev-parse", "-q", "--verify", `${t.ref}^{commit}`]);
|
|
46547
|
+
return `PR target: ${t ? t.ref : "unresolved"}, base: ${sk ? `${sk.target} (${sk.message})` : same ? t.ref : b}`;
|
|
46514
46548
|
}
|
|
46515
46549
|
function noteOf(intake) {
|
|
46516
46550
|
const m = intake?.["unmerged_loki_work"]?.message ?? intake?.["stacked_loki_skip"]?.message;
|
|
@@ -46626,22 +46660,10 @@ function envChangedSince(repoDir, pkgDir, sinceMs, ignored) {
|
|
|
46626
46660
|
}
|
|
46627
46661
|
}
|
|
46628
46662
|
async function zeroOnBase(cands, baseDir, repoDir, run2, note, gate = {}) {
|
|
46629
|
-
const zero = [],
|
|
46630
|
-
const moved = (src) => {
|
|
46631
|
-
if (!envMoved.has(src))
|
|
46632
|
-
envMoved.set(src, envChangedSince(repoDir, src, gate.sinceMs, gate.ignored ?? null));
|
|
46633
|
-
return envMoved.get(src);
|
|
46634
|
-
};
|
|
46663
|
+
const zero = [], link = baseDepsLinker(baseDir, repoDir, gate);
|
|
46635
46664
|
for (const c of cands) {
|
|
46636
|
-
|
|
46637
|
-
if (depsSeeHead(src, repoDir) || gate.sinceMs !== undefined && moved(src))
|
|
46665
|
+
if (!link(c.cwd))
|
|
46638
46666
|
continue;
|
|
46639
|
-
for (const d of ["node_modules", ".venv"]) {
|
|
46640
|
-
try {
|
|
46641
|
-
if (existsSync98(join143(src, d)) && !existsSync98(join143(c.cwd, d)))
|
|
46642
|
-
symlinkSync4(join143(src, d), join143(c.cwd, d));
|
|
46643
|
-
} catch {}
|
|
46644
|
-
}
|
|
46645
46667
|
if (isZeroRun(c, await run2(c))) {
|
|
46646
46668
|
zero.push(c.name);
|
|
46647
46669
|
note(c.name);
|
|
@@ -46649,6 +46671,23 @@ async function zeroOnBase(cands, baseDir, repoDir, run2, note, gate = {}) {
|
|
|
46649
46671
|
}
|
|
46650
46672
|
return zero;
|
|
46651
46673
|
}
|
|
46674
|
+
function baseDepsLinker(baseDir, repoDir, gate = {}) {
|
|
46675
|
+
const seen = new Map;
|
|
46676
|
+
return (cwd) => {
|
|
46677
|
+
const src = join143(repoDir, relative28(baseDir, cwd));
|
|
46678
|
+
if (!seen.has(src))
|
|
46679
|
+
seen.set(src, !(depsSeeHead(src, repoDir) || gate.sinceMs !== undefined && envChangedSince(repoDir, src, gate.sinceMs, gate.ignored ?? null)));
|
|
46680
|
+
if (!seen.get(src))
|
|
46681
|
+
return false;
|
|
46682
|
+
for (const d of ["node_modules", ".venv"]) {
|
|
46683
|
+
try {
|
|
46684
|
+
if (existsSync98(join143(src, d)) && !existsSync98(join143(cwd, d)))
|
|
46685
|
+
symlinkSync4(join143(src, d), join143(cwd, d));
|
|
46686
|
+
} catch {}
|
|
46687
|
+
}
|
|
46688
|
+
return true;
|
|
46689
|
+
};
|
|
46690
|
+
}
|
|
46652
46691
|
function isZeroRun(c, b) {
|
|
46653
46692
|
const last = c.args[c.args.length - 1] ?? "";
|
|
46654
46693
|
const k = classifyCheck({ kind: "test", ok: b.ok, cut: b.cut, missing: b.missing, out: b.out, ...goRunner(c.cmd, c.args), path: /\.[cm]?[jt]s$/.test(last) ? last : undefined });
|
|
@@ -46765,12 +46804,43 @@ function returnCheckout(repoDir, branch, orig) {
|
|
|
46765
46804
|
if (!orig || orig === branch)
|
|
46766
46805
|
return `engine10: the checkout stays on ${branch}: the run did not record the branch it started from
|
|
46767
46806
|
`;
|
|
46768
|
-
|
|
46807
|
+
let dirty;
|
|
46808
|
+
try {
|
|
46809
|
+
dirty = safeGit(repoDir, ["status", "--porcelain", "-z", "--untracked-files=no", "--no-renames"], { timeout: 20000 });
|
|
46810
|
+
} catch {
|
|
46811
|
+
dirty = null;
|
|
46812
|
+
}
|
|
46813
|
+
if (dirty === null || dirty.split("\x00").filter(Boolean).some((l) => !l.slice(3).startsWith(".loki/")))
|
|
46769
46814
|
return `engine10: the checkout stays on ${branch}: it has uncommitted changes; return with: git checkout ${orig}
|
|
46770
46815
|
`;
|
|
46771
46816
|
return git13(repoDir, ["checkout", "-q", orig]) === null ? `engine10: the checkout stays on ${branch}: git checkout ${orig} failed; return with: git checkout ${orig}
|
|
46772
46817
|
` : null;
|
|
46773
46818
|
}
|
|
46819
|
+
function removeOwnWallFiles(repoDir, runId2) {
|
|
46820
|
+
let files = [];
|
|
46821
|
+
try {
|
|
46822
|
+
files = JSON.parse(readFileSync124(join143(repoDir, ".loki", "runs", runId2, "receipt.json"), "utf8")).wall?.files ?? [];
|
|
46823
|
+
} catch {
|
|
46824
|
+
return [];
|
|
46825
|
+
}
|
|
46826
|
+
const gone = [];
|
|
46827
|
+
for (const f of files) {
|
|
46828
|
+
if (typeof f.path !== "string" || typeof f.sha256 !== "string")
|
|
46829
|
+
continue;
|
|
46830
|
+
const abs = resolve38(repoDir, f.path), rel = relative28(repoDir, abs);
|
|
46831
|
+
if (rel.startsWith("..") || rel.startsWith(".loki/") || !basename36(rel).startsWith("loki_wall_"))
|
|
46832
|
+
continue;
|
|
46833
|
+
if (git13(repoDir, ["ls-files", "--error-unmatch", "--", rel]) !== null)
|
|
46834
|
+
continue;
|
|
46835
|
+
try {
|
|
46836
|
+
if (createHash39("sha256").update(readFileSync124(abs)).digest("hex") !== f.sha256)
|
|
46837
|
+
continue;
|
|
46838
|
+
rmSync37(abs);
|
|
46839
|
+
gone.push(rel);
|
|
46840
|
+
} catch {}
|
|
46841
|
+
}
|
|
46842
|
+
return gone;
|
|
46843
|
+
}
|
|
46774
46844
|
function workLine(repoDir, branch, orig) {
|
|
46775
46845
|
if (!tipOf(repoDir, `refs/heads/${branch}`) || currentBranch(repoDir) === branch)
|
|
46776
46846
|
return "";
|
|
@@ -46792,6 +46862,10 @@ function finishRunBranch(repoDir, runId2, end, env = process.env) {
|
|
|
46792
46862
|
removeRunWorktrees(repoDir, end.baseSha);
|
|
46793
46863
|
migrateSessionFiles(repoDir, runLive);
|
|
46794
46864
|
let notes = "";
|
|
46865
|
+
const wallGone = removeOwnWallFiles(repoDir, runId2);
|
|
46866
|
+
if (wallGone.length)
|
|
46867
|
+
notes += `engine10: removed Loki's own acceptance test ${wallGone.join(", ")} from your tree; its sealed copy is under .loki/runs/${runId2}/wall/
|
|
46868
|
+
`;
|
|
46795
46869
|
const keepHere = end.keepWork === true && tip !== null && tipOf(repoDir, end.baseSha ?? "") !== tip;
|
|
46796
46870
|
const stay = tip ? returnCheckout(repoDir, branch, end.orig) : null;
|
|
46797
46871
|
if (stay)
|
|
@@ -46890,25 +46964,31 @@ var exports_verify = {};
|
|
|
46890
46964
|
__export(exports_verify, {
|
|
46891
46965
|
writeWallFailureTail: () => writeWallFailureTail,
|
|
46892
46966
|
wallTailOf: () => wallTailOf,
|
|
46967
|
+
vitestFileText: () => vitestFileText,
|
|
46968
|
+
vitestBatch: () => vitestBatch,
|
|
46893
46969
|
verifyStage: () => verifyStage,
|
|
46970
|
+
verifyBatchOn: () => verifyBatchOn,
|
|
46894
46971
|
testConfigChanged: () => testConfigChanged,
|
|
46895
46972
|
testCheckName: () => testCheckName,
|
|
46896
46973
|
stage: () => stage9,
|
|
46897
46974
|
skipped: () => skipped,
|
|
46975
|
+
sameErrors: () => sameErrors,
|
|
46898
46976
|
runnerCmd: () => runnerCmd,
|
|
46899
46977
|
runOnce: () => runOnce3,
|
|
46900
46978
|
runLintChecks: () => runLintChecks,
|
|
46901
46979
|
runCheck: () => runCheck,
|
|
46902
46980
|
ran: () => ran,
|
|
46903
46981
|
firstError: () => firstError,
|
|
46982
|
+
feedsFixRound: () => feedsFixRound,
|
|
46983
|
+
errorsById: () => errorsById,
|
|
46904
46984
|
commandFor: () => commandFor,
|
|
46905
46985
|
changedFiles: () => changedFiles,
|
|
46906
46986
|
WALL_FAILURE_TAIL_FILE: () => WALL_FAILURE_TAIL_FILE,
|
|
46907
46987
|
WALL_FAILURE_TAIL_CAP: () => WALL_FAILURE_TAIL_CAP
|
|
46908
46988
|
});
|
|
46909
|
-
import { existsSync as existsSync99, mkdtempSync as mkdtempSync20, readFileSync as readFileSync125, rmSync as rmSync38 } from "fs";
|
|
46989
|
+
import { existsSync as existsSync99, mkdtempSync as mkdtempSync20, readFileSync as readFileSync125, realpathSync as realpathSync35, rmSync as rmSync38 } from "fs";
|
|
46910
46990
|
import { tmpdir as tmpdir26 } from "os";
|
|
46911
|
-
import { basename as basename37, isAbsolute as isAbsolute21, join as join144, relative as relative29 } from "path";
|
|
46991
|
+
import { basename as basename37, isAbsolute as isAbsolute21, join as join144, relative as relative29, resolve as resolve39 } from "path";
|
|
46912
46992
|
function writeWallFailureTail(runDir, failed2) {
|
|
46913
46993
|
const file = join144(runDir, WALL_FAILURE_TAIL_FILE);
|
|
46914
46994
|
try {
|
|
@@ -47001,6 +47081,7 @@ async function runCheck(ctx, name, cmd2, args, signal, checks, opts = {}) {
|
|
|
47001
47081
|
if (result === "fail" && !opts.opaque && !isHold(check)) {
|
|
47002
47082
|
excerpts.set(check, failureExcerpt(attempt.out, ctx.repoDir));
|
|
47003
47083
|
failTails.set(check, wallTailOf(attempt.out, ctx.repoDir));
|
|
47084
|
+
headErrors.set(check, errorsById(attempt.out));
|
|
47004
47085
|
}
|
|
47005
47086
|
checks.push(check);
|
|
47006
47087
|
if (opts.opaque && check.result !== "pass" && check.reason)
|
|
@@ -47008,8 +47089,154 @@ async function runCheck(ctx, name, cmd2, args, signal, checks, opts = {}) {
|
|
|
47008
47089
|
ctx.emit("test.result", "verify", opts.opaque ? { ...pubHold(check) } : { ...check });
|
|
47009
47090
|
return check;
|
|
47010
47091
|
}
|
|
47092
|
+
function vitestFileText(rel, asserts) {
|
|
47093
|
+
const st = (a) => String(a.status ?? ""), path = (a) => [...Array.isArray(a.ancestorTitles) ? a.ancestorTitles.map(String) : [], String(a.title ?? "")].join(" > ");
|
|
47094
|
+
const failed2 = asserts.filter((a) => st(a) === "failed"), passed = asserts.filter((a) => st(a) === "passed").length, skippedN = asserts.length - failed2.length - passed;
|
|
47095
|
+
const lines2 = [` ${failed2.length ? "\u276F" : "\u2713"} ${rel} (${asserts.length} tests${failed2.length ? ` | ${failed2.length} failed` : ""}${skippedN ? ` | ${skippedN} skipped` : ""}) 0ms`];
|
|
47096
|
+
for (const a of asserts)
|
|
47097
|
+
if (st(a) === "passed" || st(a) === "failed")
|
|
47098
|
+
lines2.push(` ${st(a) === "failed" ? "\xD7" : "\u2713"} ${String(a.title ?? "")} 0ms`);
|
|
47099
|
+
lines2.push("");
|
|
47100
|
+
for (const a of failed2)
|
|
47101
|
+
lines2.push(` FAIL ${rel} > ${path(a)}`, ...Array.isArray(a.failureMessages) ? a.failureMessages.map((m) => String(m).slice(0, 4000)) : [], "");
|
|
47102
|
+
const parts2 = [failed2.length ? `${failed2.length} failed` : "", passed ? `${passed} passed` : "", skippedN ? `${skippedN} skipped` : ""].filter(Boolean).join(" | ");
|
|
47103
|
+
lines2.push(` Test Files ${failed2.length ? "1 failed" : "1 passed"} (1)`, ` Tests ${parts2} (${asserts.length})`);
|
|
47104
|
+
return { ok: failed2.length === 0, out: lines2.join(`
|
|
47105
|
+
`) };
|
|
47106
|
+
}
|
|
47107
|
+
async function vitestBatch(cwd, rels, signal, opts = {}) {
|
|
47108
|
+
const dir = mkdtempSync20(join144(tmpdir26(), "loki-vbatch-")), file = join144(dir, "report.json");
|
|
47109
|
+
try {
|
|
47110
|
+
const r = await runOnce3("npx", ["--no-install", "vitest", "run", "--reporter=json", "--reporter=default", `--outputFile.json=${file}`, ...rels], cwd, signal, { timeoutMs: opts.timeoutMs ?? batchTimeoutMs(rels.length), group: true, ...opts.path ? { path: opts.path } : {} });
|
|
47111
|
+
if (r.cut || r.missing || !existsSync99(file) || UNHANDLED_RE.test(r.out))
|
|
47112
|
+
return null;
|
|
47113
|
+
const rep = JSON.parse(readFileSync125(file, "utf8"));
|
|
47114
|
+
const tests = rep.testResults ?? [], failedFile = (tr) => tr.status === "failed";
|
|
47115
|
+
if (!r.ok && !tests.some(failedFile))
|
|
47116
|
+
return null;
|
|
47117
|
+
const real3 = (p) => {
|
|
47118
|
+
try {
|
|
47119
|
+
return realpathSync35(p);
|
|
47120
|
+
} catch {
|
|
47121
|
+
return p;
|
|
47122
|
+
}
|
|
47123
|
+
}, byAbs = new Map;
|
|
47124
|
+
for (const rel of rels)
|
|
47125
|
+
for (const p of [resolve39(cwd, rel), real3(resolve39(cwd, rel))])
|
|
47126
|
+
byAbs.set(p, rel);
|
|
47127
|
+
const out2 = new Map;
|
|
47128
|
+
for (const tr of tests) {
|
|
47129
|
+
const rel = byAbs.get(String(tr.name ?? "")), asserts = Array.isArray(tr.assertionResults) ? tr.assertionResults : [], f = rel ? vitestFileText(rel, asserts) : null;
|
|
47130
|
+
if (!rel || !f || asserts.length === 0 || typeof tr.message === "string" && tr.message.trim() !== "")
|
|
47131
|
+
continue;
|
|
47132
|
+
if (f.ok ? tr.status === "passed" : failedFile(tr))
|
|
47133
|
+
out2.set(rel, f);
|
|
47134
|
+
}
|
|
47135
|
+
return out2;
|
|
47136
|
+
} catch {
|
|
47137
|
+
return null;
|
|
47138
|
+
} finally {
|
|
47139
|
+
rmSync38(dir, { recursive: true, force: true });
|
|
47140
|
+
}
|
|
47141
|
+
}
|
|
47142
|
+
async function runVitestBatches(ctx, tests, api, signal, onCheck) {
|
|
47143
|
+
const got = new Map, groups = new Map;
|
|
47144
|
+
for (const t of tests) {
|
|
47145
|
+
const tc = commandFor(t, ctx.repoDir, api);
|
|
47146
|
+
if (vitestFile(t, tc))
|
|
47147
|
+
groups.set(tc.cwd, [...groups.get(tc.cwd) ?? [], { t, tc }]);
|
|
47148
|
+
}
|
|
47149
|
+
for (const [cwd, g2] of groups) {
|
|
47150
|
+
if (g2.length < BATCH_MIN || signal.aborted)
|
|
47151
|
+
continue;
|
|
47152
|
+
const rel = (x) => x.tc.args[x.tc.args.length - 1], t0 = Date.now();
|
|
47153
|
+
const first = await vitestBatch(cwd, g2.map(rel), signal);
|
|
47154
|
+
if (!first)
|
|
47155
|
+
continue;
|
|
47156
|
+
const classify3 = (f) => classifyCheck({ kind: "test", ok: f.ok, cut: false, missing: false, out: f.out });
|
|
47157
|
+
const failing = g2.filter((x) => {
|
|
47158
|
+
const f = first.get(rel(x));
|
|
47159
|
+
return f !== undefined && classify3(f).result === "fail" && classifyRunnerOutput(f.out).kind !== "load_error";
|
|
47160
|
+
});
|
|
47161
|
+
const second = failing.length && !signal.aborted ? await vitestBatch(cwd, failing.map(rel), signal) : null;
|
|
47162
|
+
const share = (Date.now() - t0) / 1000 / g2.length;
|
|
47163
|
+
for (const x of g2) {
|
|
47164
|
+
const a = first.get(rel(x));
|
|
47165
|
+
if (!a)
|
|
47166
|
+
continue;
|
|
47167
|
+
const ca = classify3(a), b = ca.result === "fail" && failing.includes(x) ? second?.get(rel(x)) : undefined, cb = b ? classify3(b) : null;
|
|
47168
|
+
const result = ca.result === "pass" && (ca.n ?? 0) > 0 ? "pass" : cb?.result === "pass" ? "flaky" : cb?.result === "fail" ? "fail" : null;
|
|
47169
|
+
if (!result)
|
|
47170
|
+
continue;
|
|
47171
|
+
const outText = b?.out ?? a.out, anchor = result === "fail" ? firstFileLineAnchor(outText) : null;
|
|
47172
|
+
const check = { name: testCheckName(x.t), cmd: x.tc.argv.join(" "), result, duration_s: share, ...result === "fail" ? { first_error: firstError(outText), ids: failIds(outText), ...anchor ? { anchor } : {} } : result === "pass" ? { n: ca.n ?? 0, sk: skipped(a.out) } : {} };
|
|
47173
|
+
if (result === "fail") {
|
|
47174
|
+
excerpts.set(check, failureExcerpt(outText, ctx.repoDir));
|
|
47175
|
+
failTails.set(check, wallTailOf(outText, ctx.repoDir));
|
|
47176
|
+
headErrors.set(check, errorsById(outText));
|
|
47177
|
+
}
|
|
47178
|
+
got.set(check.name, check);
|
|
47179
|
+
ctx.emit("test.result", "verify", { ...check });
|
|
47180
|
+
onCheck(check);
|
|
47181
|
+
}
|
|
47182
|
+
}
|
|
47183
|
+
return got;
|
|
47184
|
+
}
|
|
47185
|
+
function changedSymbolsFirst(ctx, tests, changed) {
|
|
47186
|
+
const code = changed.filter((f) => CODE_FILE_EXT.test(f) && !isTestFile(f));
|
|
47187
|
+
if (code.length === 0 || tests.length < 2)
|
|
47188
|
+
return tests;
|
|
47189
|
+
let names = [];
|
|
47190
|
+
try {
|
|
47191
|
+
names = changedSymbols(safeGit(ctx.repoDir, ["diff", "-U0", "--no-color", "--no-ext-diff", "--no-textconv", "--no-renames", ctx.baseSha, "--", ...code], { timeout: 20000 })).filter((n3) => n3.length >= 3);
|
|
47192
|
+
} catch {
|
|
47193
|
+
return tests;
|
|
47194
|
+
}
|
|
47195
|
+
if (names.length === 0)
|
|
47196
|
+
return tests;
|
|
47197
|
+
const re = new RegExp(`\\b(?:${names.map((n3) => n3.replace(/[$]/g, "\\$")).join("|")})\\b`);
|
|
47198
|
+
const hits = tests.filter((t) => {
|
|
47199
|
+
try {
|
|
47200
|
+
return re.test(readFileSync125(join144(ctx.repoDir, t.path), "utf8"));
|
|
47201
|
+
} catch {
|
|
47202
|
+
return false;
|
|
47203
|
+
}
|
|
47204
|
+
});
|
|
47205
|
+
return [...hits, ...tests.filter((t) => !hits.includes(t))];
|
|
47206
|
+
}
|
|
47207
|
+
function errorsById(out2) {
|
|
47208
|
+
const norm5 = (l) => l.replace(/\b\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?/g, "<ts>").replace(/\b\d{1,2}:\d{2}:\d{2}(?:\.\d+)?\b/g, "<ts>").replace(/(^|[\s(])\/(?:[\w.@-]+\/)*[\w.@-]+(?::\d+){0,2}/g, "$1<path>").replace(/\b\d+(?:\.\d+)?\s?(?:ms|s|us|\u00B5s|ns|min)\b/g, "<dur>").replace(/\s+/g, " ").trim();
|
|
47209
|
+
const lines2 = stripAnsi(out2).split(`
|
|
47210
|
+
`).map((l) => l.trim()), m = new Map, add3 = (id, e) => {
|
|
47211
|
+
m.set(id, [...m.get(id) ?? [], e]);
|
|
47212
|
+
};
|
|
47213
|
+
for (const [i, l] of lines2.entries()) {
|
|
47214
|
+
const py = /^FAILED (\S+::\S*) - (.+)$/.exec(l);
|
|
47215
|
+
if (py) {
|
|
47216
|
+
add3(py[1], norm5(py[2]));
|
|
47217
|
+
continue;
|
|
47218
|
+
}
|
|
47219
|
+
const v = /^FAIL\s+(.+)$/.exec(l);
|
|
47220
|
+
if (!v)
|
|
47221
|
+
continue;
|
|
47222
|
+
const next = lines2.slice(i + 1).find((x) => x !== "" && !/^FAIL\s/.test(x));
|
|
47223
|
+
if (next !== undefined)
|
|
47224
|
+
add3(v[1].trim(), norm5(next));
|
|
47225
|
+
}
|
|
47226
|
+
for (const [k, e] of m)
|
|
47227
|
+
m.set(k, e.sort());
|
|
47228
|
+
return m;
|
|
47229
|
+
}
|
|
47230
|
+
function sameErrors(head, base2, ids) {
|
|
47231
|
+
const h = typeof head === "string" ? errorsById(head) : head, b = errorsById(base2), all = ids ?? [], eq2 = (x = [], y = []) => x.length === y.length && x.every((e, n3) => e === y[n3]);
|
|
47232
|
+
const keys = (i) => h.has(i) ? [i] : [...h.keys()].filter((k) => k.endsWith(` > ${i}`));
|
|
47233
|
+
return all.length > 0 && all.every((i) => {
|
|
47234
|
+
const ks = keys(i);
|
|
47235
|
+
return ks.length > 0 && ks.every((k) => eq2(b.get(k), h.get(k)));
|
|
47236
|
+
});
|
|
47237
|
+
}
|
|
47011
47238
|
async function subtractBase(ctx, api, checks, tests, changed, wall, rel, signal, zeroOk = true, zeroIntake = zeroGate(null), dep = new Set) {
|
|
47012
|
-
const out2 = { ids: [], names: [], weak: [], zero: [], cnt: {} };
|
|
47239
|
+
const out2 = { ids: [], names: [], knownRed: [], sameError: [], weak: [], zero: [], cnt: {} };
|
|
47013
47240
|
const pairs = checks.flatMap((c) => {
|
|
47014
47241
|
const t = tests.find((x) => testCheckName(x) === c.name);
|
|
47015
47242
|
return t ? [{ c, t }] : [];
|
|
@@ -47026,12 +47253,37 @@ async function subtractBase(ctx, api, checks, tests, changed, wall, rel, signal,
|
|
|
47026
47253
|
try {
|
|
47027
47254
|
git14(["-c", "core.hooksPath=/dev/null", "worktree", "add", "--detach", dir, ctx.baseSha]);
|
|
47028
47255
|
const base2 = new Map;
|
|
47029
|
-
|
|
47256
|
+
const record = (c, b) => {
|
|
47257
|
+
base2.set(c, { red: !b.ok && !b.cut ? failIds(b.out) : [], n: ran(b.out) ?? summaryPassFailCount(b.out), sk: skipped(b.out), out: b.cut ? "" : b.out });
|
|
47258
|
+
};
|
|
47259
|
+
for (const { c, t } of sus) {
|
|
47030
47260
|
const bc = commandFor(t, dir, api);
|
|
47031
|
-
|
|
47032
|
-
|
|
47033
|
-
|
|
47261
|
+
record(c, await runOnce3(bc.cmd, bc.args, bc.cwd, signal, {}));
|
|
47262
|
+
}
|
|
47263
|
+
const red = un.filter(({ c }) => c.result === "fail" && c.ids?.length && !base2.has(c));
|
|
47264
|
+
const link = changed.some((f) => MANIFESTS2.test(f)) ? null : baseDepsLinker(dir, ctx.repoDir, zeroIntake);
|
|
47265
|
+
const cmds = red.map((p) => ({ ...p, bc: commandFor(p.t, dir, api) }));
|
|
47266
|
+
for (const bc of new Set(cmds.map((x) => x.bc.cwd)))
|
|
47267
|
+
link?.(bc);
|
|
47268
|
+
if (verifyBatchOn() && !signal.aborted) {
|
|
47269
|
+
const byCwd = new Map;
|
|
47270
|
+
for (const x of cmds)
|
|
47271
|
+
if (vitestFile(x.t, x.bc))
|
|
47272
|
+
byCwd.set(x.bc.cwd, [...byCwd.get(x.bc.cwd) ?? [], x]);
|
|
47273
|
+
for (const [cwd, g2] of byCwd) {
|
|
47274
|
+
if (g2.length < BATCH_MIN || signal.aborted)
|
|
47275
|
+
continue;
|
|
47276
|
+
const res = await vitestBatch(cwd, g2.map((x) => x.bc.args[3]), signal);
|
|
47277
|
+
for (const x of g2) {
|
|
47278
|
+
const f = res?.get(x.bc.args[3]);
|
|
47279
|
+
if (f)
|
|
47280
|
+
record(x.c, f);
|
|
47281
|
+
}
|
|
47282
|
+
}
|
|
47034
47283
|
}
|
|
47284
|
+
for (const { c, bc } of cmds)
|
|
47285
|
+
if (!base2.has(c) && !signal.aborted)
|
|
47286
|
+
record(c, await runOnce3(bc.cmd, bc.args, bc.cwd, signal, {}));
|
|
47035
47287
|
out2.zero = await zeroOnBase(zc.map(({ c, t }) => ({ name: c.name, ...commandFor(t, dir, api) })), dir, ctx.repoDir, (r) => runOnce3(r.cmd, r.args, r.cwd, signal, {}), (n3) => ctx.emit("test.skipped_on_base", "verify", { note: `skipped on base: ${n3}`, check: n3 }), zeroIntake);
|
|
47036
47288
|
out2.weak = sus.filter(({ c }) => (c.sk ?? 0) > base2.get(c).sk || (c.n ?? 0) < base2.get(c).n).map(({ c }) => c.name);
|
|
47037
47289
|
for (const { c } of sus) {
|
|
@@ -47040,7 +47292,12 @@ async function subtractBase(ctx, api, checks, tests, changed, wall, rel, signal,
|
|
|
47040
47292
|
const progress = checks.some((c) => wall.has(c.name) && c.result === "pass") || sus.some(({ c }) => !out2.weak.includes(c.name) && base2.get(c).red.length > 0 && (c.n ?? 0) >= base2.get(c).n);
|
|
47041
47293
|
{
|
|
47042
47294
|
for (const { c } of un) {
|
|
47043
|
-
if (
|
|
47295
|
+
if (rel.has(c.name) || c.result !== "fail" || !c.ids?.length || !c.ids.every((i) => base2.get(c)?.red.includes(i)))
|
|
47296
|
+
continue;
|
|
47297
|
+
out2.knownRed.push(c.name);
|
|
47298
|
+
if (sameErrors(headErrors.get(c) ?? "", base2.get(c).out, c.ids))
|
|
47299
|
+
out2.sameError.push(c.name);
|
|
47300
|
+
if (progress || dep.has(c.name)) {
|
|
47044
47301
|
out2.names.push(c.name);
|
|
47045
47302
|
out2.ids.push(...c.ids);
|
|
47046
47303
|
}
|
|
@@ -47102,7 +47359,7 @@ async function runLintChecks(ctx, changed, signal, checks, opts = {}) {
|
|
|
47102
47359
|
}
|
|
47103
47360
|
return pre;
|
|
47104
47361
|
}
|
|
47105
|
-
var CHECK_TIMEOUT_MS = 60000, excerpts, suites, failTails,
|
|
47362
|
+
var CHECK_TIMEOUT_MS = 60000, excerpts, suites, failTails, headErrors, WALL_FAILURE_TAIL_CAP = 16384, wallTailOf = (out2, repoDir) => redactSecrets(stripAnsi(out2).replace(/\r/g, "").split(repoDir.replace(/\/+$/, "") + "/").join("")).slice(-WALL_FAILURE_TAIL_CAP), isHold = (c) => isHoldoutCheck(c.name), pubHold = (c) => ({ name: "holdout", cmd: "holdout", result: c.result, duration_s: c.duration_s, ...c.n !== undefined ? { n: c.n } : {}, ...c.sk !== undefined ? { sk: c.sk } : {}, ...c.owner ? { owner: c.owner, reason: "holdout infrastructure failure" } : {} }), testCheckName = (t) => `${t.runner}:${t.path}`, dedupeTests = (tests) => [...new Map(tests.map((t) => [`${t.runner}:${t.path}`, t])).values()], verifyBatchOn = (env = process.env) => env["LOKI_E10_VERIFY_BATCH"] !== "0", BATCH_MIN = 2, UNHANDLED_RE, batchTimeoutMs = (files) => Math.max(CHECK_TIMEOUT_MS, Math.min(300000, files * 5000)), vitestFile = (t, c) => t.runner === "vitest" && c.cmd === "npx" && c.args.length === 4 && c.args[0] === "--no-install" && c.args[1] === "vitest" && c.args[2] === "run", feedsFixRound = (c, pre) => c.result === "fail" && !pre.names.includes(c.name) && !pre.sameError.includes(c.name) && !isHoldoutCheck(c.name), ESLINT_CONFIGS, excuseLint = (ctx, signal, c, tool, cmd2, prefix, cwd, rel, opts) => c.result !== "fail" || signal.aborted ? Promise.resolve(false) : staticPreExisting(tool, prefix, rel, { run: async (a, stdin) => {
|
|
47106
47363
|
if (signal.aborted)
|
|
47107
47364
|
return null;
|
|
47108
47365
|
const r = await runOnce3(cmd2, a, cwd, AbortSignal.any([signal, AbortSignal.timeout(opts.timeoutMs ?? CHECK_TIMEOUT_MS)]), { ...opts, ...stdin !== undefined ? { stdin } : {} });
|
|
@@ -47120,6 +47377,8 @@ var init_verify = __esm(() => {
|
|
|
47120
47377
|
init_redact();
|
|
47121
47378
|
init_install();
|
|
47122
47379
|
init_scope();
|
|
47380
|
+
init_wall_snapshot();
|
|
47381
|
+
init_runner_errors();
|
|
47123
47382
|
init_runner_config();
|
|
47124
47383
|
init_assert_delta();
|
|
47125
47384
|
init_failures();
|
|
@@ -47141,10 +47400,14 @@ var init_verify = __esm(() => {
|
|
|
47141
47400
|
init_package_suite();
|
|
47142
47401
|
init_check_result();
|
|
47143
47402
|
init_check_result();
|
|
47403
|
+
init_check_result();
|
|
47404
|
+
init_check_result();
|
|
47144
47405
|
init_runner_config();
|
|
47145
47406
|
excerpts = new WeakMap;
|
|
47146
47407
|
suites = new WeakSet;
|
|
47147
47408
|
failTails = new WeakMap;
|
|
47409
|
+
headErrors = new WeakMap;
|
|
47410
|
+
UNHANDLED_RE = /Unhandled (?:Errors?|Rejection)\b/;
|
|
47148
47411
|
ESLINT_CONFIGS = [".eslintrc", ".eslintrc.json", ".eslintrc.js", ".eslintrc.cjs", "eslint.config.js", "eslint.config.mjs", "eslint.config.cjs"];
|
|
47149
47412
|
verifyStage = {
|
|
47150
47413
|
name: "verify",
|
|
@@ -47191,7 +47454,7 @@ var init_verify = __esm(() => {
|
|
|
47191
47454
|
return runner && (runner !== "bun" || map.runners.includes("bun") || /[._](?:test|spec)\.[cm]?[jt]sx?$/.test(p)) ? [{ runner, path: p }] : [];
|
|
47192
47455
|
});
|
|
47193
47456
|
const dep = dependentTests(ctx.repoDir, map, changed, [...impacted, ...changedTestFiles, ...wallTests, ...relevant2]), depNames = new Set(dep.tests.map(testCheckName));
|
|
47194
|
-
const tests = failedFirst(dedupeTests([...wallTests, ...relevant2, ...changedTestFiles, ...impacted, ...dep.tests]), ctx.outputs().verify?.checks);
|
|
47457
|
+
const tests = failedFirst(dedupeTests([...wallTests, ...relevant2, ...changedTestFiles, ...changedSymbolsFirst(ctx, impacted, changed), ...dep.tests]), ctx.outputs().verify?.checks);
|
|
47195
47458
|
const hashes = fileHashes(ctx.repoDir, changed), qs = quickScope(ctx.outputs(), hashes), keep = new Set([...qs?.blocking ?? [], ...[...wallTests, ...relevant2].map(testCheckName)]);
|
|
47196
47459
|
const sinceTests = qs ? [...ctx.tests.impacted(map, qs.since), ...map.tests.filter((t) => qs.since.includes(t.path))] : [], split2 = qs ? quickSplit(tests, keep, sinceTests) : { first: tests, rest: [] };
|
|
47197
47460
|
const done = [], wallNames0 = new Set(wallTests.map(testCheckName)), targets0 = new Set([...wallTests, ...relevant2].map(testCheckName)), wallDropped0 = [...wallPaths].filter((p) => !wallTests.some((t) => t.path === p));
|
|
@@ -47206,14 +47469,31 @@ var init_verify = __esm(() => {
|
|
|
47206
47469
|
const scopedOut = scopedOutOf(map);
|
|
47207
47470
|
if (scopedOut.length)
|
|
47208
47471
|
ctx.emit("test.scoped_out", "verify", { tests: scopedOut });
|
|
47472
|
+
const batchable = (t) => verifyBatchOn() && t.runner === "vitest" && !wallNames0.has(testCheckName(t));
|
|
47209
47473
|
const runTests = async (list) => {
|
|
47210
|
-
|
|
47211
|
-
|
|
47212
|
-
await
|
|
47213
|
-
|
|
47214
|
-
|
|
47215
|
-
|
|
47216
|
-
|
|
47474
|
+
const byName = new Map;
|
|
47475
|
+
const alone = async (l) => {
|
|
47476
|
+
(await mapPool(l, verifyJobs(), async (t) => {
|
|
47477
|
+
const tc = commandFor(t, ctx.repoDir, api), slot = [];
|
|
47478
|
+
await runCheck(ctx, testCheckName(t), tc.cmd, tc.args, signal, slot, { ...tc.interpreter ? { interpreter: tc.interpreter } : {}, protect: [...wallTests, ...relevant2].includes(t), ...tc.pkgRoot !== "." ? { cwd: tc.cwd } : {} });
|
|
47479
|
+
done.push(...slot);
|
|
47480
|
+
publish();
|
|
47481
|
+
return slot;
|
|
47482
|
+
}, () => signal.aborted)).forEach((sl, i) => {
|
|
47483
|
+
if (sl)
|
|
47484
|
+
byName.set(testCheckName(l[i]), sl);
|
|
47485
|
+
});
|
|
47486
|
+
};
|
|
47487
|
+
await alone(list.filter((t) => !batchable(t)));
|
|
47488
|
+
for (const part of [list.filter((t) => batchable(t) && targets0.has(testCheckName(t))), list.filter((t) => batchable(t) && !targets0.has(testCheckName(t)))]) {
|
|
47489
|
+
for (const [n3, c] of await runVitestBatches(ctx, part, api, signal, (c2) => {
|
|
47490
|
+
done.push(c2);
|
|
47491
|
+
publish();
|
|
47492
|
+
}))
|
|
47493
|
+
byName.set(n3, [c]);
|
|
47494
|
+
}
|
|
47495
|
+
await alone(list.filter((t) => batchable(t) && !byName.has(testCheckName(t))));
|
|
47496
|
+
checks.push(...list.flatMap((t) => byName.get(testCheckName(t)) ?? []));
|
|
47217
47497
|
};
|
|
47218
47498
|
await runTests(split2.first);
|
|
47219
47499
|
const decisive = qs !== null && checks.some((c) => c.result === "fail" && (keep.has(c.name) || changed.includes(c.name.slice(c.name.indexOf(":") + 1))));
|
|
@@ -47288,6 +47568,12 @@ var init_verify = __esm(() => {
|
|
|
47288
47568
|
risk = markExecuted(risk, ranDeeper);
|
|
47289
47569
|
recordRisk(ctx.repoDir, risk);
|
|
47290
47570
|
}
|
|
47571
|
+
const known = new Set(checks.filter((c) => c.result === "fail" && (preRed.sameError.includes(c.name) || wallNames0.has(c.name))).flatMap((c) => c.ids ?? []));
|
|
47572
|
+
for (const c of full)
|
|
47573
|
+
if (c.result === "fail" && c.ids?.length && c.ids.every((i) => known.has(i)) && !preRed.names.includes(c.name)) {
|
|
47574
|
+
preRed.knownRed.push(c.name);
|
|
47575
|
+
preRed.sameError.push(c.name);
|
|
47576
|
+
}
|
|
47291
47577
|
}
|
|
47292
47578
|
if (risk && risk.tier === "high" && !signal.aborted && complete) {
|
|
47293
47579
|
const { runSecretScan: runSecretScan2 } = await Promise.resolve().then(() => (init_deep(), exports_deep));
|
|
@@ -47307,7 +47593,7 @@ var init_verify = __esm(() => {
|
|
|
47307
47593
|
const covered = (f) => ctx.tests.impacted(map, [f]).some((t) => checks.some((c) => c.name === testCheckName(t) && hasExecutedProof([c])));
|
|
47308
47594
|
const uncoveredChanged = changed.filter((f) => CODE_FILE_EXT.test(f) && !isTestFile(f) && !wallPaths.has(f) && !cfgChanged.includes(f) && !covered(f));
|
|
47309
47595
|
const flaky = checks.filter((c) => c.result === "flaky").map((c) => isHold(c) ? "holdout" : c.name);
|
|
47310
|
-
const { groups: failuresGrouped, names: blockingNames } = briefGroups(checks.filter((c) => c
|
|
47596
|
+
const { groups: failuresGrouped, names: blockingNames } = briefGroups(checks.filter((c) => feedsFixRound(c, preRed)), (c) => excerpts.get(c) ?? "", (c) => suites.has(c), EXCERPT_TOTAL_CAP, qs && !complete ? { prev: ctx.outputs().verify, ran: new Set(checks.map((c) => c.name)) } : undefined);
|
|
47311
47597
|
const pub = checks.map((c) => isHold(c) ? pubHold(c) : c), holdoutFailed = checks.filter((c) => c.result === "fail" && isHold(c) && !preRed.names.includes(c.name)).length;
|
|
47312
47598
|
const inBase = (f) => {
|
|
47313
47599
|
try {
|
|
@@ -47329,7 +47615,7 @@ var init_verify = __esm(() => {
|
|
|
47329
47615
|
const wallDropped = [...wallPaths].filter((p) => !wallTests.some((t) => t.path === p));
|
|
47330
47616
|
notProven.push(...wallDropped.map((p) => `Wall test not executed: ${p}: ${NO_RUNNER_REASON}`));
|
|
47331
47617
|
const wallNames = new Set(wallTests.map(testCheckName)), wallRun = checks.filter((c) => wallNames.has(c.name) || isHold(c)), wallFailTail = writeWallFailureTail(ctx.runDir, checks.filter((c) => wallNames.has(c.name) && c.result === "fail" && !isHold(c) && !preRed.names.includes(c.name)).map((c) => ({ name: c.name, out: failTails.get(c) ?? "" }))), wallPassed = wallRun.some((c) => c.result === "fail") ? false : wallRun.length > 0 && wallDropped.length === 0 && wallRun.every((c) => c.result === "pass") ? true : undefined;
|
|
47332
|
-
return { status: "completed", data: { checks: pub, flaky, verify_scope: complete ? "complete" : "quick", file_hashes: hashes, blocking_checks: blockingNames, ...wallFailTail ? { wall_failure_tail: wallFailTail } : {}, ...wallPassed === undefined ? {} : { wall_passed: wallPassed }, failures_grouped: failuresGrouped, holdout_failed: holdoutFailed, changed_files: changed, ...depNames.size ? { dependent_checks: [...depNames] } : {}, not_proven: notProven, ...fullNotProven.size ? { not_applicable: [...fullNotProven].filter(naNote).map(naText) } : {}, pre_red: preRed.ids, pre_red_checks: preRed.names, skipped_on_base: preRed.zero, ...attr.line ? { baseline_line: attr.line, introduced_checks: attr.introducedChecks } : {}, test_counts: testCounts, uncovered_changed: uncoveredChanged, target_checks: checks.filter((c) => c.result === "pass" && targetNames.has(c.name)).map((c) => isHold(c) ? "holdout" : c.name), risk } };
|
|
47618
|
+
return { status: "completed", data: { checks: pub, flaky, verify_scope: complete ? "complete" : "quick", file_hashes: hashes, blocking_checks: blockingNames, ...wallFailTail ? { wall_failure_tail: wallFailTail } : {}, ...wallPassed === undefined ? {} : { wall_passed: wallPassed }, failures_grouped: failuresGrouped, holdout_failed: holdoutFailed, changed_files: changed, ...depNames.size ? { dependent_checks: [...depNames] } : {}, not_proven: notProven, ...fullNotProven.size ? { not_applicable: [...fullNotProven].filter(naNote).map(naText) } : {}, pre_red: preRed.ids, pre_red_checks: preRed.names, ...preRed.knownRed.length ? { known_red_checks: preRed.knownRed } : {}, ...preRed.sameError.length ? { known_red_same_error: preRed.sameError } : {}, skipped_on_base: preRed.zero, ...attr.line ? { baseline_line: attr.line, introduced_checks: attr.introducedChecks } : {}, test_counts: testCounts, uncovered_changed: uncoveredChanged, target_checks: checks.filter((c) => c.result === "pass" && targetNames.has(c.name)).map((c) => isHold(c) ? "holdout" : c.name), risk } };
|
|
47333
47619
|
}
|
|
47334
47620
|
};
|
|
47335
47621
|
stage9 = verifyStage;
|
|
@@ -88299,8 +88585,8 @@ __export(exports_providers, {
|
|
|
88299
88585
|
SDK_BUNDLED_CLAUDE_CODE: () => SDK_BUNDLED_CLAUDE_CODE,
|
|
88300
88586
|
PROVIDER_COMMIT_HYGIENE: () => PROVIDER_COMMIT_HYGIENE
|
|
88301
88587
|
});
|
|
88302
|
-
import { mkdirSync as mkdirSync77, existsSync as existsSync102, readFileSync as readFileSync128, realpathSync as
|
|
88303
|
-
import { delimiter as delimiter4, dirname as dirname57, isAbsolute as isAbsolute24, relative as relative31, resolve as
|
|
88588
|
+
import { mkdirSync as mkdirSync77, existsSync as existsSync102, readFileSync as readFileSync128, realpathSync as realpathSync37, appendFileSync as appendFileSync17 } from "fs";
|
|
88589
|
+
import { delimiter as delimiter4, dirname as dirname57, isAbsolute as isAbsolute24, relative as relative31, resolve as resolve41, sep as sep25 } from "path";
|
|
88304
88590
|
function mergeDisallowedTools(policy, stageCsv) {
|
|
88305
88591
|
return [...new Set([...policy ?? [], ...stageCsv.split(",").filter(Boolean)])];
|
|
88306
88592
|
}
|
|
@@ -88431,9 +88717,9 @@ function ensureParentDir(path) {
|
|
|
88431
88717
|
}
|
|
88432
88718
|
function physicalPath(path) {
|
|
88433
88719
|
try {
|
|
88434
|
-
return
|
|
88720
|
+
return realpathSync37(path);
|
|
88435
88721
|
} catch {
|
|
88436
|
-
return
|
|
88722
|
+
return resolve41(path);
|
|
88437
88723
|
}
|
|
88438
88724
|
}
|
|
88439
88725
|
function hostGuardRequired(cwd) {
|
|
@@ -88533,7 +88819,7 @@ function claudeProvider() {
|
|
|
88533
88819
|
const baseModel = claudeModelFor(call);
|
|
88534
88820
|
const routed = sessionPlanEnabled() ? planRouterSession({
|
|
88535
88821
|
model: baseModel,
|
|
88536
|
-
runDir: process.env["LOKI_DIR"] ??
|
|
88822
|
+
runDir: process.env["LOKI_DIR"] ?? resolve41(call.cwd, ".loki"),
|
|
88537
88823
|
claudeCodeVersion: await installedClaudeCodeVersion(cli)
|
|
88538
88824
|
}) : null;
|
|
88539
88825
|
const model = routed ? routed.model : baseModel;
|
|
@@ -88604,7 +88890,7 @@ function providerCallTimeoutMs(env) {
|
|
|
88604
88890
|
}
|
|
88605
88891
|
function emitSdkDegradationEvent(cwd, payload) {
|
|
88606
88892
|
try {
|
|
88607
|
-
const lokiRoot = process.env["LOKI_DIR"] ??
|
|
88893
|
+
const lokiRoot = process.env["LOKI_DIR"] ?? resolve41(cwd, ".loki");
|
|
88608
88894
|
mkdirSync77(lokiRoot, { recursive: true });
|
|
88609
88895
|
const record = {
|
|
88610
88896
|
type: "capability_degraded",
|
|
@@ -88612,7 +88898,7 @@ function emitSdkDegradationEvent(cwd, payload) {
|
|
|
88612
88898
|
timestamp: new Date().toISOString(),
|
|
88613
88899
|
payload: { capability: "sdk_query", fail_closed: true, ...payload }
|
|
88614
88900
|
};
|
|
88615
|
-
appendFileSync17(
|
|
88901
|
+
appendFileSync17(resolve41(lokiRoot, "events.jsonl"), `${JSON.stringify(record)}
|
|
88616
88902
|
`);
|
|
88617
88903
|
} catch {}
|
|
88618
88904
|
}
|
|
@@ -88624,7 +88910,7 @@ function buildSdkLoopOptions(args) {
|
|
|
88624
88910
|
const out2 = {};
|
|
88625
88911
|
const router = sessionPlanEnabled() ? planRouterSession({
|
|
88626
88912
|
model: args.model,
|
|
88627
|
-
runDir: args.runDir ?? process.env["LOKI_DIR"] ??
|
|
88913
|
+
runDir: args.runDir ?? process.env["LOKI_DIR"] ?? resolve41(args.cwd, ".loki"),
|
|
88628
88914
|
claudeCodeVersion: args.claudeCodeVersion ?? bundledClaudeCodeVersion2()
|
|
88629
88915
|
}) : null;
|
|
88630
88916
|
if (router) {
|
|
@@ -89065,7 +89351,7 @@ function createSessionRunner(cfg) {
|
|
|
89065
89351
|
}, cfg.heartbeatMs ?? HEARTBEAT_MS_DEFAULT);
|
|
89066
89352
|
opts.signal.addEventListener("abort", onAbort, { once: true });
|
|
89067
89353
|
const untrack = trackSession(() => kill("aborted"));
|
|
89068
|
-
return new Promise((
|
|
89354
|
+
return new Promise((resolve42) => {
|
|
89069
89355
|
child.on("exit", () => reapLiveGroup(pgid, () => cfg.emit?.("session.group_reaped", opts.stage, { session_id: sessionId, pgid })));
|
|
89070
89356
|
child.on("close", (code) => {
|
|
89071
89357
|
clearTimeout(limitTimer);
|
|
@@ -89092,7 +89378,7 @@ function createSessionRunner(cfg) {
|
|
|
89092
89378
|
rememberSessionEffort(psid, ran2);
|
|
89093
89379
|
recordCost(cfg, opts, killed ? "killed" : code === 0 ? "completed" : "failed", durationS, stdout + logText);
|
|
89094
89380
|
untrack();
|
|
89095
|
-
|
|
89381
|
+
resolve42({ exit: guard.ok ? code : 1, markers, durationS, killed, summary: (stdout + logText).trim().slice(-4096), stderrTail: (guard.ok ? "" : `guard violation: ${guard.violations.map((v) => v.detail).join("; ")}
|
|
89096
89382
|
`) + stderrTail.toString("utf8") + (logText.match(/^\[sdk-loop error: .*\]$/gm) ?? []).join(`
|
|
89097
89383
|
`) });
|
|
89098
89384
|
});
|
|
@@ -89329,9 +89615,9 @@ var init_session_resume = __esm(() => {
|
|
|
89329
89615
|
});
|
|
89330
89616
|
|
|
89331
89617
|
// ../../loki-ts/src/util/conflict_resume.ts
|
|
89332
|
-
import { createHash as
|
|
89618
|
+
import { createHash as createHash40 } from "crypto";
|
|
89333
89619
|
import { execFileSync as execFileSync10 } from "child_process";
|
|
89334
|
-
import { existsSync as existsSync105, mkdirSync as mkdirSync80, mkdtempSync as mkdtempSync21, readFileSync as readFileSync131, rmSync as rmSync41, symlinkSync as symlinkSync5, writeFileSync as writeFileSync75 } from "fs";
|
|
89620
|
+
import { chmodSync as chmodSync8, existsSync as existsSync105, mkdirSync as mkdirSync80, mkdtempSync as mkdtempSync21, readFileSync as readFileSync131, rmSync as rmSync41, statSync as statSync43, symlinkSync as symlinkSync5, writeFileSync as writeFileSync75 } from "fs";
|
|
89335
89621
|
import { tmpdir as tmpdir27 } from "os";
|
|
89336
89622
|
import { basename as basename40, dirname as dirname60, isAbsolute as isAbsolute25, join as join150, relative as relative32 } from "path";
|
|
89337
89623
|
function answerMark(events2, assumeNext = false) {
|
|
@@ -89388,7 +89674,7 @@ function applyArbitrations(wall, events2) {
|
|
|
89388
89674
|
if (e10.type !== "wall.arbitrated")
|
|
89389
89675
|
continue;
|
|
89390
89676
|
const a = e10.data["arbitration"], path = e10.data["path"], content = e10.data["content"];
|
|
89391
|
-
if (!a || typeof a.sha256 !== "string" || typeof path !== "string" || typeof content !== "string" ||
|
|
89677
|
+
if (!a || typeof a.sha256 !== "string" || typeof path !== "string" || typeof content !== "string" || createHash40("sha256").update(content).digest("hex") !== a.sha256)
|
|
89392
89678
|
continue;
|
|
89393
89679
|
const sf2 = files?.find((x10) => x10.path === path);
|
|
89394
89680
|
if (!sf2)
|
|
@@ -89506,20 +89792,20 @@ async function adjudicateWallConflict(ctx, first, firstSession, wall, deps = {})
|
|
|
89506
89792
|
const sealedCopy = join150(sealedWallDir(ctx.runDir), name);
|
|
89507
89793
|
if (existsSync105(dirname60(sealedCopy)))
|
|
89508
89794
|
writeFileSync75(sealedCopy, next, "utf8");
|
|
89509
|
-
sf2.sha256 =
|
|
89795
|
+
sf2.sha256 = createHash40("sha256").update(next).digest("hex");
|
|
89510
89796
|
const sealedNow = existsSync105(sealedCopy) ? readFileSync131(sealedCopy, "utf8") : null;
|
|
89511
89797
|
if (sealedNow !== next) {
|
|
89512
89798
|
restore();
|
|
89513
89799
|
if (sealedNow !== null)
|
|
89514
89800
|
writeFileSync75(sealedCopy, original, "utf8");
|
|
89515
|
-
sf2.sha256 =
|
|
89801
|
+
sf2.sha256 = createHash40("sha256").update(original).digest("hex");
|
|
89516
89802
|
return null;
|
|
89517
89803
|
}
|
|
89518
89804
|
writeFileSync75(f.path, sealedNow, "utf8");
|
|
89519
89805
|
if (runCheck2(ctx.repoDir, ref) !== "pass") {
|
|
89520
89806
|
restore();
|
|
89521
89807
|
writeFileSync75(sealedCopy, original, "utf8");
|
|
89522
|
-
sf2.sha256 =
|
|
89808
|
+
sf2.sha256 = createHash40("sha256").update(original).digest("hex");
|
|
89523
89809
|
return null;
|
|
89524
89810
|
}
|
|
89525
89811
|
const ch = changedAssertion(original, next), arb = { check: a.file, test, old_assertion: ch.old, new_assertion: ch.new, spec_quote: String(v.spec_quote), spec_quote_2: String(B10.verdict.spec_quote), sha256: sf2.sha256 };
|
|
@@ -89573,7 +89859,7 @@ async function legacyReauthor(ctx, first, firstSession, f, a, reason, task) {
|
|
|
89573
89859
|
return null;
|
|
89574
89860
|
f.content = next;
|
|
89575
89861
|
writeFileSync75(f.path, next, "utf8");
|
|
89576
|
-
const sf2 = o.wall?.files?.find((x10) => x10.path === f.path), sha6 =
|
|
89862
|
+
const sf2 = o.wall?.files?.find((x10) => x10.path === f.path), sha6 = createHash40("sha256").update(next).digest("hex");
|
|
89577
89863
|
if (sf2)
|
|
89578
89864
|
sf2.sha256 = sha6;
|
|
89579
89865
|
mkdirSync80(sealedWallDir(ctx.runDir), { recursive: true });
|
|
@@ -89596,41 +89882,112 @@ ${brief}`, ...sid ? { resumeSessionId: sid } : {} });
|
|
|
89596
89882
|
rmSync41(cwd, { recursive: true, force: true });
|
|
89597
89883
|
}
|
|
89598
89884
|
}
|
|
89599
|
-
function
|
|
89600
|
-
const
|
|
89601
|
-
if (
|
|
89602
|
-
return
|
|
89603
|
-
if (
|
|
89885
|
+
function wallOnlyAfterFix(o, repoDir) {
|
|
89886
|
+
const v = o.verify;
|
|
89887
|
+
if (o.implement?.exit !== "done" || Number(o.fix?.round ?? 0) < 1 || !v || v.stopped_at || wallFailures(o, repoDir, true) === null)
|
|
89888
|
+
return false;
|
|
89889
|
+
if (v.verify_scope === "quick")
|
|
89890
|
+
return !(v.failures_grouped ?? []).some((g10) => g10.carried === true);
|
|
89891
|
+
return (Array.isArray(v.checks) ? v.checks : []).some((c) => ownTestPassed(c, wallRelOf(o, repoDir)));
|
|
89892
|
+
}
|
|
89893
|
+
function wallSignature(o, repoDir) {
|
|
89894
|
+
const wall = wallRelOf(o, repoDir), checks = Array.isArray(o.verify?.checks) ? o.verify.checks : [];
|
|
89895
|
+
return JSON.stringify(checks.filter((c) => c.result === "fail" && wall.has(String(c.name).slice(String(c.name).indexOf(":") + 1))).map((c) => [String(c.name), [...strList2(c.ids)].sort(), String(c.first_error ?? "")]).sort());
|
|
89896
|
+
}
|
|
89897
|
+
function wallFailures(o, repoDir, strict = false) {
|
|
89898
|
+
const { verify: v, wall: w } = o;
|
|
89899
|
+
if (!v || !w || o.plan?.out_of_repo === true || Number(v.holdout_failed ?? 0) > 0)
|
|
89604
89900
|
return null;
|
|
89605
|
-
const wallRel =
|
|
89606
|
-
const fileOf = (n10) => n10.slice(n10.indexOf(":") + 1), checks = Array.isArray(v.checks) ? v.checks : [], preRed = strList2(v.pre_red_checks);
|
|
89901
|
+
const wallRel = wallRelOf(o, repoDir), fileOf = (n10) => n10.slice(n10.indexOf(":") + 1), checks = Array.isArray(v.checks) ? v.checks : [], excused = new Set([...strList2(v.pre_red_checks), ...strList2(v.known_red_same_error)]);
|
|
89607
89902
|
const isWall = (c) => wallRel.has(fileOf(String(c.name))), wallFail = checks.filter((c) => isWall(c) && c.result === "fail");
|
|
89608
|
-
const own = checks.filter((c) => !isWall(c) && !String(c.name).startsWith("holdout") && !String(c.name).startsWith("full suite"));
|
|
89609
|
-
if (!wallFail.length || own.some((c) => c.result === "fail" && c.owner !== "harness" && !
|
|
89903
|
+
const own = checks.filter((c) => !isWall(c) && !String(c.name).startsWith("holdout") && (strict || !String(c.name).startsWith("full suite")));
|
|
89904
|
+
if (!wallFail.length || own.some((c) => c.result === "fail" && c.owner !== "harness" && !excused.has(String(c.name))))
|
|
89610
89905
|
return null;
|
|
89611
89906
|
if (!strList2(v.changed_files).some((f) => !wallRel.has(f) && !f.startsWith(".loki/")))
|
|
89612
89907
|
return null;
|
|
89613
89908
|
return [...new Set(wallFail.map((c) => fileOf(String(c.name))))];
|
|
89614
89909
|
}
|
|
89615
|
-
|
|
89616
|
-
const
|
|
89910
|
+
function wallConflictDefects(o, repoDir) {
|
|
89911
|
+
const { implement: imp, verify: v, fix: fx2 } = o;
|
|
89912
|
+
if (imp?.exit !== "spec_conflict")
|
|
89913
|
+
return wallOnlyAfterFix(o, repoDir) ? wallFailures(o, repoDir, true) : null;
|
|
89914
|
+
if (!v || v.stopped_at)
|
|
89915
|
+
return null;
|
|
89916
|
+
if (fx2?.exit === "spec_conflict" && !(typeof fx2.tree_before === "string" && fx2.tree_before === fx2.tree_after))
|
|
89917
|
+
return null;
|
|
89918
|
+
return wallFailures(o, repoDir);
|
|
89919
|
+
}
|
|
89920
|
+
async function deliverOverWallConflict(o, repoDir, reverify, emit, opts = {}) {
|
|
89921
|
+
const files = wallConflictDefects(o, repoDir), w = o.wall, conflict = o.implement?.exit === "spec_conflict";
|
|
89617
89922
|
if (!files || !w)
|
|
89618
89923
|
return null;
|
|
89619
|
-
const gone = (p) => files.includes(isAbsolute25(p) ? relative32(repoDir, p) : p);
|
|
89924
|
+
const reason = conflict ? WALL_CONFLICT_DISCARD : WALL_ONLY_DISCARD, gone = (p) => files.includes(isAbsolute25(p) ? relative32(repoDir, p) : p);
|
|
89925
|
+
const read3 = (p) => {
|
|
89926
|
+
try {
|
|
89927
|
+
return readFileSync131(p);
|
|
89928
|
+
} catch {
|
|
89929
|
+
return null;
|
|
89930
|
+
}
|
|
89931
|
+
}, modeOf = (p) => {
|
|
89932
|
+
try {
|
|
89933
|
+
return statSync43(p).mode & 4095;
|
|
89934
|
+
} catch {
|
|
89935
|
+
return null;
|
|
89936
|
+
}
|
|
89937
|
+
};
|
|
89938
|
+
const tailFile = opts.runDir ? join150(opts.runDir, WALL_FAILURE_TAIL_FILE) : null;
|
|
89939
|
+
const saved = { files: w.files, readOnlyFiles: w.readOnlyFiles, verify: o.verify, bytes: files.map((f) => read3(join150(repoDir, f))), modes: files.map((f) => modeOf(join150(repoDir, f))), tail: tailFile ? read3(tailFile) : null };
|
|
89940
|
+
const record = () => {
|
|
89941
|
+
w.discarded = [...w.discarded ?? [], ...files.map((file) => ({ file, reason }))];
|
|
89942
|
+
for (const f of files)
|
|
89943
|
+
emit(f, reason);
|
|
89944
|
+
};
|
|
89620
89945
|
for (const f of files)
|
|
89621
89946
|
rmSync41(join150(repoDir, f), { force: true });
|
|
89622
89947
|
w.files = (w.files ?? []).filter((f) => !gone(f.path));
|
|
89623
89948
|
w.readOnlyFiles = (w.readOnlyFiles ?? []).filter((f) => !gone(f.path));
|
|
89624
|
-
|
|
89625
|
-
|
|
89626
|
-
emit(f, WALL_CONFLICT_DISCARD);
|
|
89949
|
+
if (conflict)
|
|
89950
|
+
record();
|
|
89627
89951
|
await reverify();
|
|
89628
|
-
const v = o.verify, wallLeft =
|
|
89629
|
-
|
|
89630
|
-
|
|
89631
|
-
if (!
|
|
89952
|
+
const v = o.verify, wallLeft = wallRelOf(o, repoDir), checks = Array.isArray(v?.checks) ? v.checks : [];
|
|
89953
|
+
const pre2 = strList2(v?.pre_red_checks), same = new Set(strList2(v?.known_red_same_error)), kr2 = strList2(v?.known_red_checks).filter((n10) => same.has(n10) && !pre2.includes(n10)), excused = new Set([...pre2, ...kr2]);
|
|
89954
|
+
const delivered = !!v && !v.stopped_at && (v.failures_grouped ?? []).length === 0 && Number(v.holdout_failed ?? 0) === 0 && checks.every((c) => c.result !== "fail" || c.owner === "harness" || excused.has(String(c.name))) && checks.some((c) => ownTestPassed(c, wallLeft));
|
|
89955
|
+
if (!delivered || !v) {
|
|
89956
|
+
if (!conflict) {
|
|
89957
|
+
files.forEach((f, i) => {
|
|
89958
|
+
const b = saved.bytes[i], m = saved.modes[i];
|
|
89959
|
+
if (b) {
|
|
89960
|
+
writeFileSync75(join150(repoDir, f), b);
|
|
89961
|
+
if (m !== null && m !== undefined) {
|
|
89962
|
+
try {
|
|
89963
|
+
chmodSync8(join150(repoDir, f), m);
|
|
89964
|
+
} catch {}
|
|
89965
|
+
}
|
|
89966
|
+
}
|
|
89967
|
+
});
|
|
89968
|
+
if (tailFile) {
|
|
89969
|
+
try {
|
|
89970
|
+
if (saved.tail)
|
|
89971
|
+
writeFileSync75(tailFile, saved.tail);
|
|
89972
|
+
else
|
|
89973
|
+
rmSync41(tailFile, { force: true });
|
|
89974
|
+
} catch {}
|
|
89975
|
+
}
|
|
89976
|
+
w.files = saved.files;
|
|
89977
|
+
w.readOnlyFiles = saved.readOnlyFiles;
|
|
89978
|
+
o.verify = saved.verify;
|
|
89979
|
+
if (saved.verify)
|
|
89980
|
+
opts.restored?.(saved.verify);
|
|
89981
|
+
}
|
|
89632
89982
|
return null;
|
|
89633
|
-
|
|
89983
|
+
}
|
|
89984
|
+
if (!conflict)
|
|
89985
|
+
record();
|
|
89986
|
+
v.not_proven = [...strList2(v.not_proven), conflict ? `Delivered over an implementer conflict with the Wall: ${files.join(", ")} discarded as a Wall defect, so this change is proven only by the repo's own tests (${oneLine4(String(o.implement?.spec_conflict_reason ?? ""))})` : `Loki's own acceptance tests still failed after a fix round: ${files.join(", ")} set aside, so this change is proven only by the repo's own tests`];
|
|
89987
|
+
if (kr2.length) {
|
|
89988
|
+
v.pre_red_checks = [...pre2, ...kr2];
|
|
89989
|
+
v.pre_red = [...strList2(v.pre_red), ...checks.filter((c) => kr2.includes(String(c.name))).flatMap((c) => strList2(c.ids))];
|
|
89990
|
+
}
|
|
89634
89991
|
o.implement = { ...o.implement, exit: "done", conflict_delivered: files };
|
|
89635
89992
|
return files;
|
|
89636
89993
|
}
|
|
@@ -89653,12 +90010,12 @@ var refereeModel = (ctx) => capToRunTier(wallModel(), ctx.model, ["LOKI_E10_WALL
|
|
|
89653
90010
|
`${name}.orig is a test file and ${name}.new is a proposed replacement of it. Decide, from task.md alone, whether the change is a correction that task.md requires: the old assertion contradicts task.md and the new one follows from it.`,
|
|
89654
90011
|
'Write verdict.json: {"agree":true,"spec_quote":"<one sentence copied verbatim from task.md that the old assertion contradicts>"} or {"agree":false}. Say agree only when the old assertion is wrong per task.md and the new one is right per task.md.'
|
|
89655
90012
|
].join(`
|
|
89656
|
-
`), WALL_CONFLICT_DISCARD = "the implementer reported it conflicts with the task while the repo's own tests pass on the change: Wall defect, discarded", ownTestPassed = (c, wall) => {
|
|
90013
|
+
`), WALL_CONFLICT_DISCARD = "the implementer reported it conflicts with the task while the repo's own tests pass on the change: Wall defect, discarded", WALL_ONLY_DISCARD = "only Loki's own acceptance test still failed after a fix round while the repo's own tests pass on the change: set aside, delivered as PARTIAL", ownTestPassed = (c, wall) => {
|
|
89657
90014
|
const name = String(c.name ?? "");
|
|
89658
90015
|
if (c.result !== "pass" || /^(lint:|security scan|select-tests|holdout)/.test(name) || wall.has(name.slice(name.indexOf(":") + 1)))
|
|
89659
90016
|
return false;
|
|
89660
90017
|
return name.startsWith("full suite:") || typeof c.n === "number" && c.n > 0;
|
|
89661
|
-
}, strList2 = (v) => Array.isArray(v) ? v.filter((x10) => typeof x10 === "string") : [];
|
|
90018
|
+
}, strList2 = (v) => Array.isArray(v) ? v.filter((x10) => typeof x10 === "string") : [], wallRelOf = (o, repoDir) => new Set((o.wall?.files ?? []).map((f) => isAbsolute25(f.path) ? relative32(repoDir, f.path) : f.path));
|
|
89662
90019
|
var init_conflict_resume = __esm(() => {
|
|
89663
90020
|
init_session_resume();
|
|
89664
90021
|
init_sizing();
|
|
@@ -89731,9 +90088,9 @@ __export(exports_run_outputs, {
|
|
|
89731
90088
|
RECOVERY_ABORT: () => RECOVERY_ABORT
|
|
89732
90089
|
});
|
|
89733
90090
|
import { execFile as execFile3, spawnSync as spawnSync24 } from "child_process";
|
|
89734
|
-
import { createHash as
|
|
89735
|
-
import { existsSync as existsSync106, lstatSync as lstatSync32, mkdirSync as mkdirSync81, readdirSync as readdirSync47, readFileSync as readFileSync132, statSync as
|
|
89736
|
-
import { basename as basename41, join as join151, resolve as
|
|
90091
|
+
import { createHash as createHash41 } from "crypto";
|
|
90092
|
+
import { existsSync as existsSync106, lstatSync as lstatSync32, mkdirSync as mkdirSync81, readdirSync as readdirSync47, readFileSync as readFileSync132, statSync as statSync44, writeFileSync as writeFileSync76 } from "fs";
|
|
90093
|
+
import { basename as basename41, join as join151, resolve as resolve42 } from "path";
|
|
89737
90094
|
function intentRevisionsBlock(revs) {
|
|
89738
90095
|
const r = (revs ?? []).filter((r10) => r10.unapplied !== true).map(({ rev, source, actor, sha: sha6 }) => ({ rev, source, actor, sha: sha6 }));
|
|
89739
90096
|
return r.length ? { intent_revisions: r } : {};
|
|
@@ -89741,7 +90098,7 @@ function intentRevisionsBlock(revs) {
|
|
|
89741
90098
|
function seededCorpusBlock(env = process.env) {
|
|
89742
90099
|
const dir = env["LOKI_SEEDED_DEFECTS_DIR"] || join151(REPO_ROOT, "benchmarks", "seeded-defects");
|
|
89743
90100
|
try {
|
|
89744
|
-
const bytes = readFileSync132(join151(dir, "manifest.json")), version2 =
|
|
90101
|
+
const bytes = readFileSync132(join151(dir, "manifest.json")), version2 = createHash41("sha256").update(bytes).digest("hex");
|
|
89745
90102
|
const ids = (JSON.parse(bytes.toString("utf8")).defects ?? []).map((d) => d.id);
|
|
89746
90103
|
let rate = null;
|
|
89747
90104
|
try {
|
|
@@ -89762,7 +90119,7 @@ function seededCorpusBlock(env = process.env) {
|
|
|
89762
90119
|
function sealAccuracyLine(changed, checks, model, env = process.env, nowMs = Date.now()) {
|
|
89763
90120
|
try {
|
|
89764
90121
|
const dir = env["LOKI_SEEDED_DEFECTS_DIR"] || join151(REPO_ROOT, "benchmarks", "seeded-defects"), file = join151(dir, "results", "wrong-pass.json");
|
|
89765
|
-
const corpus =
|
|
90122
|
+
const corpus = createHash41("sha256").update(readFileSync132(join151(dir, "manifest.json"))).digest("hex");
|
|
89766
90123
|
const res = JSON.parse(readFileSync132(file, "utf8"));
|
|
89767
90124
|
if (res.manifest_sha256 !== corpus || !Array.isArray(res.runs))
|
|
89768
90125
|
return SEAL_ACCURACY_NOT_MEASURED;
|
|
@@ -89914,7 +90271,7 @@ function findInterrupted(repoDir, runId2, includeCancelled = false, why) {
|
|
|
89914
90271
|
} catch {
|
|
89915
90272
|
return null;
|
|
89916
90273
|
}
|
|
89917
|
-
const rows = ids.filter((id2) => /^e10-[A-Za-z0-9-]+$/.test(id2) && existsSync106(join151(repoDir, eventsRelPath(id2)))).map((id2) => ({ id: id2, m:
|
|
90274
|
+
const rows = ids.filter((id2) => /^e10-[A-Za-z0-9-]+$/.test(id2) && existsSync106(join151(repoDir, eventsRelPath(id2)))).map((id2) => ({ id: id2, m: statSync44(join151(repoDir, eventsRelPath(id2))).mtimeMs })).sort((a, b) => b.m - a.m);
|
|
89918
90275
|
const top = rows[0];
|
|
89919
90276
|
if (!top)
|
|
89920
90277
|
return null;
|
|
@@ -90192,7 +90549,7 @@ async function resumeFlag(runId2, noPr = false, deps = {}, answer) {
|
|
|
90192
90549
|
};
|
|
90193
90550
|
const supervise = deps.supervise ?? (async (o) => (await Promise.resolve().then(() => (init_supervisor(), exports_supervisor))).runSupervisor(o));
|
|
90194
90551
|
const { exitCodeOf: exitCodeOf2 } = await Promise.resolve().then(() => (init_output(), exports_output));
|
|
90195
|
-
const res = await supervise({ runId: it2.runId, repoDir, env, resume: true, capS: capS === undefined ? undefined : Math.floor(capS), capCeilingS: ceilS === undefined ? undefined : Math.floor(ceilS), restoreBranch: origBranch, workerArgv: [process.execPath, ...SAFE_BUN_FLAGS,
|
|
90552
|
+
const res = await supervise({ runId: it2.runId, repoDir, env, resume: true, capS: capS === undefined ? undefined : Math.floor(capS), capCeilingS: ceilS === undefined ? undefined : Math.floor(ceilS), restoreBranch: origBranch, workerArgv: [process.execPath, ...SAFE_BUN_FLAGS, resolve42(process.argv[1] ?? ""), "engine10", "worker", it2.runId, provider, model, deep ? "deep" : "fast"], started: { ...st2, resumed_from: rp2.stage, ...answer !== undefined ? { answered: true, answer: redactSecrets(answer), answer_sha256: createHash41("sha256").update(redactSecrets(answer)).digest("hex"), question: String(conflictReasonOf(it2.events) ?? "the run is blocked on a spec conflict").replace(/[\x00-\x1f\x7f]+/g, " ").trim().slice(0, 500) } : {} }, pr: pr2 });
|
|
90196
90553
|
out2(`engine10: resumed run ${it2.runId}: ${res.outcome}
|
|
90197
90554
|
`);
|
|
90198
90555
|
return exitCodeOf2(res.outcome);
|
|
@@ -90524,7 +90881,7 @@ function runIntent(repoDir, env = process.env) {
|
|
|
90524
90881
|
let policy = null;
|
|
90525
90882
|
if (pf2) {
|
|
90526
90883
|
try {
|
|
90527
|
-
policy =
|
|
90884
|
+
policy = createHash41("sha256").update(readFileSync132(pf2)).digest("hex");
|
|
90528
90885
|
} catch {}
|
|
90529
90886
|
}
|
|
90530
90887
|
const parent = /^[A-Za-z0-9._-]{1,128}$/.test(env.LOKI_PARENT_RUN ?? "") ? env.LOKI_PARENT_RUN : null;
|
|
@@ -90579,7 +90936,7 @@ function issueStatusProjector(o) {
|
|
|
90579
90936
|
return r.catch(() => null);
|
|
90580
90937
|
};
|
|
90581
90938
|
}
|
|
90582
|
-
function policyGate(repoDir, action, env = process.env, checkJs =
|
|
90939
|
+
function policyGate(repoDir, action, env = process.env, checkJs = resolve42(import.meta.dir, "../../../src/policies/check.js"), timeoutMs = 30000) {
|
|
90583
90940
|
if (policyFile(repoDir, env) === null)
|
|
90584
90941
|
return { decision: "allow", reason: "no policy file" };
|
|
90585
90942
|
if (env.LOKI_POLICY_REQUIRE_NODE === "0" && spawnSync24("node", ["--version"], { env: { PATH: env.PATH }, encoding: "utf8" }).status !== 0)
|
|
@@ -90739,7 +91096,7 @@ var SEAL_ACCURACY_NOT_MEASURED = "Seal accuracy: not measured", SEAL_ACCURACY_MA
|
|
|
90739
91096
|
} catch {
|
|
90740
91097
|
return SEAL_ACCURACY_NOT_MEASURED;
|
|
90741
91098
|
}
|
|
90742
|
-
}, REVERTED = "unrelated edit reverted:", STALE_S2, isCancelDone = (e10) => e10.type === "run.completed" && e10.data["cancelled"] === true, isResumableDone = (e10) => isCancelDone(e10) || e10.type === "run.completed" && e10.data["verdict"] === "SPEC_CONFLICT", DISCARD_MARK = "discarded", isDiscarded = (runsDir, runId2) => existsSync106(join151(runsDir, runId2, DISCARD_MARK)), STAGE_ORDER, sha6 = (v) =>
|
|
91099
|
+
}, REVERTED = "unrelated edit reverted:", STALE_S2, isCancelDone = (e10) => e10.type === "run.completed" && e10.data["cancelled"] === true, isResumableDone = (e10) => isCancelDone(e10) || e10.type === "run.completed" && e10.data["verdict"] === "SPEC_CONFLICT", DISCARD_MARK = "discarded", isDiscarded = (runsDir, runId2) => existsSync106(join151(runsDir, runId2, DISCARD_MARK)), STAGE_ORDER, sha6 = (v) => createHash41("sha256").update(JSON.stringify(v) ?? "null").digest("hex"), settled = (events2, s) => events2.some((e10) => e10.stage === s && (e10.type === "stage.completed" || e10.type === "stage.skipped")), cannotResume = (out2, id2, reason) => {
|
|
90743
91100
|
out2(`resume: run ${plainLine(id2, 80)} cannot be resumed (${plainLine(reason, 400)}); its work is on branch loki/${plainLine(id2, 80)}. Start a new run: loki start <task>
|
|
90744
91101
|
`);
|
|
90745
91102
|
return 4;
|
|
@@ -90989,9 +91346,9 @@ __export(exports_verify_cmd, {
|
|
|
90989
91346
|
checkEventLog: () => checkEventLog,
|
|
90990
91347
|
checkAttestation: () => checkAttestation
|
|
90991
91348
|
});
|
|
90992
|
-
import { existsSync as existsSync108, readFileSync as readFileSync134, renameSync as renameSync26, statSync as
|
|
91349
|
+
import { existsSync as existsSync108, readFileSync as readFileSync134, renameSync as renameSync26, statSync as statSync45, writeFileSync as writeFileSync77 } from "fs";
|
|
90993
91350
|
import { basename as basename43, dirname as dirname62, join as join153 } from "path";
|
|
90994
|
-
import { createHash as
|
|
91351
|
+
import { createHash as createHash42, verify as verify5 } from "crypto";
|
|
90995
91352
|
function checkAttestation(jwt, expectedHash, given) {
|
|
90996
91353
|
const bad = (reason) => ({ status: "tampered", reason });
|
|
90997
91354
|
const [h10, p, s, ...rest] = jwt.split(".");
|
|
@@ -91022,7 +91379,7 @@ function wallTamperProblem(receiptPath, receipt) {
|
|
|
91022
91379
|
const copy = sealedWallCopy(dirname62(receiptPath), f.path);
|
|
91023
91380
|
let cur;
|
|
91024
91381
|
try {
|
|
91025
|
-
cur =
|
|
91382
|
+
cur = createHash42("sha256").update(readFileSync134(copy)).digest("hex");
|
|
91026
91383
|
} catch {
|
|
91027
91384
|
if (haveWallDir)
|
|
91028
91385
|
return `sealed Wall file ${basename43(f.path)} is missing from the run's wall directory: it was deleted after the seal`;
|
|
@@ -91044,7 +91401,7 @@ function checkEventLog(receiptPath, receipt) {
|
|
|
91044
91401
|
}
|
|
91045
91402
|
if (typeof bound !== "string")
|
|
91046
91403
|
return null;
|
|
91047
|
-
if (bound ===
|
|
91404
|
+
if (bound === createHash42("sha256").digest("hex")) {
|
|
91048
91405
|
const st2 = receipt["time"]?.stages;
|
|
91049
91406
|
const claims = st2 !== null && typeof st2 === "object" && Object.keys(st2).length > 0;
|
|
91050
91407
|
return claims ? "the receipt records stages but binds the empty-log hash, so no events.jsonl can back it (missing, empty or non-empty); the receipt is forged or was sealed without a log. Re-run the task to produce a fresh receipt" : null;
|
|
@@ -91063,7 +91420,7 @@ function checkEventLog(receiptPath, receipt) {
|
|
|
91063
91420
|
return "events.jsonl has bytes the engine never writes (a blank line or stray whitespace); it was appended to after the seal";
|
|
91064
91421
|
if (events2.some((e10) => e10.type === "tamper.detected"))
|
|
91065
91422
|
return "the supervisor detected events.jsonl being modified during the run";
|
|
91066
|
-
const h10 =
|
|
91423
|
+
const h10 = createHash42("sha256");
|
|
91067
91424
|
for (const l of lines2) {
|
|
91068
91425
|
if (h10.copy().digest("hex") === bound)
|
|
91069
91426
|
return null;
|
|
@@ -91105,7 +91462,7 @@ function checkLogSeal(receiptPath, hash, kid, given) {
|
|
|
91105
91462
|
if (!d)
|
|
91106
91463
|
return { verdict: "TAMPERED", reason: "events.jsonl has no signed log.sealed line after run.completed" };
|
|
91107
91464
|
const lines2 = readFileSync134(path, "utf8").split(`
|
|
91108
|
-
`).filter((l) => l.trim() !== ""), sha7 =
|
|
91465
|
+
`).filter((l) => l.trim() !== ""), sha7 = createHash42("sha256").update(lines2.slice(0, done + 1).join(`
|
|
91109
91466
|
`) + `
|
|
91110
91467
|
`).digest("hex");
|
|
91111
91468
|
const pub = d["kid"] === kid ? pubFor(kid, given) : undefined;
|
|
@@ -91304,7 +91661,7 @@ ${/^(unknown option|expected at most one)/.test(pk2.error) ? `Usage: loki verify
|
|
|
91304
91661
|
if (!runId2)
|
|
91305
91662
|
return process.stderr.write(`loki verify: no runs found
|
|
91306
91663
|
`), 66;
|
|
91307
|
-
const isFile = existsSync108(runId2) &&
|
|
91664
|
+
const isFile = existsSync108(runId2) && statSync45(runId2).isFile();
|
|
91308
91665
|
const isPath = isFile || /[\\/]/.test(runId2) || runId2.endsWith(".json");
|
|
91309
91666
|
const receiptPath = isPath ? runId2 : join153(runsRoot2, runId2, "receipt.json");
|
|
91310
91667
|
const byRunId = !isPath;
|
|
@@ -91450,8 +91807,8 @@ var init_verify_cmd = __esm(() => {
|
|
|
91450
91807
|
});
|
|
91451
91808
|
|
|
91452
91809
|
// src/server/app.ts
|
|
91453
|
-
import { existsSync as existsSync110, readFileSync as readFileSync137, statSync as
|
|
91454
|
-
import { join as join156, resolve as
|
|
91810
|
+
import { existsSync as existsSync110, readFileSync as readFileSync137, statSync as statSync46 } from "fs";
|
|
91811
|
+
import { join as join156, resolve as resolve43, sep as sep27 } from "path";
|
|
91455
91812
|
|
|
91456
91813
|
// node_modules/hono/dist/request/constants.js
|
|
91457
91814
|
var GET_MATCH_RESULT = Symbol();
|
|
@@ -101901,7 +102258,7 @@ function mount20(ctx) {
|
|
|
101901
102258
|
}
|
|
101902
102259
|
|
|
101903
102260
|
// src/server/routes/verify.ts
|
|
101904
|
-
import { readFileSync as readFileSync135, realpathSync as
|
|
102261
|
+
import { readFileSync as readFileSync135, realpathSync as realpathSync38 } from "fs";
|
|
101905
102262
|
import { createPublicKey as createPublicKey8 } from "crypto";
|
|
101906
102263
|
import { join as join154, sep as sep26 } from "path";
|
|
101907
102264
|
init_verify_cmd();
|
|
@@ -101930,11 +102287,11 @@ function mount21(ctx) {
|
|
|
101930
102287
|
return done(404, "receipt not available", "not_found");
|
|
101931
102288
|
let runDir, file;
|
|
101932
102289
|
try {
|
|
101933
|
-
const root =
|
|
101934
|
-
runDir =
|
|
102290
|
+
const root = realpathSync38(join154(repo.p, ".loki", "runs"));
|
|
102291
|
+
runDir = realpathSync38(join154(root, run2));
|
|
101935
102292
|
if (runDir !== join154(root, run2))
|
|
101936
102293
|
return done(404, "receipt not found", "not_found");
|
|
101937
|
-
file =
|
|
102294
|
+
file = realpathSync38(join154(runDir, "receipt.json"));
|
|
101938
102295
|
} catch {
|
|
101939
102296
|
return done(404, "receipt not found", "not_found");
|
|
101940
102297
|
}
|
|
@@ -102720,9 +103077,9 @@ function createApp(opts) {
|
|
|
102720
103077
|
}
|
|
102721
103078
|
if (!uiDir || p.startsWith("/v1/"))
|
|
102722
103079
|
return c.json({ error: "not found" }, 404);
|
|
102723
|
-
const root =
|
|
102724
|
-
const f =
|
|
102725
|
-
if (f.startsWith(root + sep27) && existsSync110(f) &&
|
|
103080
|
+
const root = resolve43(uiDir);
|
|
103081
|
+
const f = resolve43(root, `.${p}`);
|
|
103082
|
+
if (f.startsWith(root + sep27) && existsSync110(f) && statSync46(f).isFile())
|
|
102726
103083
|
return new Response(Bun.file(f));
|
|
102727
103084
|
if (/\.[a-z0-9]+$/i.test(p))
|
|
102728
103085
|
return c.json({ error: "not found" }, 404);
|