forgedock 1.67.0 → 1.68.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/bin/config-schema.mjs +1 -0
- package/bin/engine/outcome-codes.mjs +1 -0
- package/bin/engine-cli.mjs +99 -12
- package/bin/engine.mjs +10 -0
- package/bin/forgedock.mjs +17 -1
- package/bin/help-text.mjs +1 -0
- package/bin/lean/admission.mjs +21 -0
- package/bin/lean/admission.test.mjs +30 -0
- package/bin/lean/advisory.test.mjs +25 -10
- package/bin/lean/amendment-schema.mjs +3 -4
- package/bin/lean/attempts.mjs +34 -31
- package/bin/lean/attempts.test.mjs +33 -19
- package/bin/lean/basered.mjs +26 -0
- package/bin/lean/batch-health.mjs +17 -12
- package/bin/lean/batch-health.test.mjs +39 -11
- package/bin/lean/batch.test.mjs +51 -2
- package/bin/lean/ci-gate.mjs +2 -90
- package/bin/lean/ci-gate.test.mjs +1 -127
- package/bin/lean/ci-precheck.mjs +25 -8
- package/bin/lean/ci-precheck.test.mjs +24 -0
- package/bin/lean/clear-breaker.test.mjs +4 -3
- package/bin/lean/commentstate.mjs +10 -5
- package/bin/lean/commentstate.test.mjs +12 -1
- package/bin/lean/conformance.e2e.test.mjs +9 -6
- package/bin/lean/conformance.mjs +56 -196
- package/bin/lean/conformance.test.mjs +40 -376
- package/bin/lean/depcache.mjs +100 -10
- package/bin/lean/depcache.test.mjs +105 -0
- package/bin/lean/docsgate.mjs +0 -32
- package/bin/lean/docsgate.test.mjs +2 -23
- package/bin/lean/effects-cap.test.mjs +9 -1
- package/bin/lean/effects-killtree.test.mjs +35 -0
- package/bin/lean/effects.mjs +42 -24
- package/bin/lean/engine-readmit.test.mjs +35 -0
- package/bin/lean/envgap.mjs +93 -0
- package/bin/lean/envgap.test.mjs +53 -0
- package/bin/lean/execution.mjs +10 -4
- package/bin/lean/execution.test.mjs +12 -0
- package/bin/lean/failure-census.mjs +170 -0
- package/bin/lean/failure-census.test.mjs +59 -0
- package/bin/lean/guardgate.test.mjs +2 -3
- package/bin/lean/heavy.mjs +33 -4
- package/bin/lean/heavy.test.mjs +38 -6
- package/bin/lean/hotarea.mjs +0 -36
- package/bin/lean/hotarea.test.mjs +1 -22
- package/bin/lean/issuewatch-verify.mjs +19 -4
- package/bin/lean/issuewatch.mjs +21 -4
- package/bin/lean/issuewatch.test.mjs +48 -1
- package/bin/lean/lane-audit-gap.mjs +66 -0
- package/bin/lean/lane-audit-gap.test.mjs +59 -0
- package/bin/lean/lane-audit-llm.mjs +5 -0
- package/bin/lean/lane-audit-query.mjs +47 -0
- package/bin/lean/lane-audit-query.test.mjs +44 -0
- package/bin/lean/lane-audit-signatures.mjs +33 -0
- package/bin/lean/lane-audit.mjs +110 -0
- package/bin/lean/lane-audit.test.mjs +97 -0
- package/bin/lean/lane-recovery.test.mjs +33 -0
- package/bin/lean/lanecheck.mjs +5 -3
- package/bin/lean/lanecheck.test.mjs +6 -0
- package/bin/lean/lean.mjs +206 -148
- package/bin/lean/lean.test.mjs +406 -190
- package/bin/lean/limits.mjs +17 -0
- package/bin/lean/limits.test.mjs +15 -1
- package/bin/lean/live-execution.mjs +21 -2
- package/bin/lean/live-execution.test.mjs +39 -0
- package/bin/lean/orchestrate-attempts.test.mjs +17 -9
- package/bin/lean/orchestrate-envhold.test.mjs +47 -0
- package/bin/lean/orchestrate-heldroot.test.mjs +72 -0
- package/bin/lean/orchestrate-hostfallback.test.mjs +59 -1
- package/bin/lean/orchestrate-overload-recovery.test.mjs +37 -0
- package/bin/lean/orchestrate-pause.test.mjs +53 -1
- package/bin/lean/orchestrate-reconcile.test.mjs +17 -0
- package/bin/lean/orchestrate-relaunch-gates.test.mjs +57 -0
- package/bin/lean/orchestrate-stacking.test.mjs +10 -0
- package/bin/lean/orchestrate.mjs +188 -33
- package/bin/lean/postdeploy-check.test.mjs +1 -3
- package/bin/lean/precheck.mjs +20 -0
- package/bin/lean/preflight.mjs +100 -11
- package/bin/lean/preflight.test.mjs +44 -4
- package/bin/lean/prompts.mjs +10 -21
- package/bin/lean/recurrence.mjs +6 -148
- package/bin/lean/recurrence.test.mjs +11 -147
- package/bin/lean/release-flakes.mjs +14 -2
- package/bin/lean/release-flakes.test.mjs +17 -1
- package/bin/lean/release-ledger.mjs +19 -1
- package/bin/lean/release-ledger.test.mjs +23 -0
- package/bin/lean/release-preflight.mjs +28 -0
- package/bin/lean/release-preflight.test.mjs +42 -1
- package/bin/lean/release-review.mjs +40 -5
- package/bin/lean/release-review.test.mjs +43 -2
- package/bin/lean/release.mjs +43 -14
- package/bin/lean/release.test.mjs +32 -0
- package/bin/lean/retry.mjs +1 -1
- package/bin/lean/retry.test.mjs +6 -1
- package/bin/lean/rotator.mjs +9 -0
- package/bin/lean/rotator.test.mjs +11 -1
- package/bin/lean/sandbox-remote.mjs +16 -9
- package/bin/lean/schedd.mjs +11 -6
- package/bin/lean/schedd.test.mjs +65 -5
- package/bin/lean/selfreview.mjs +1 -1
- package/bin/lean/statuscomment.mjs +4 -1
- package/bin/lean/validate-catalog.mjs +108 -0
- package/bin/lean/validate-catalog.test.mjs +46 -1
- package/bin/lean/verify.mjs +1 -1
- package/bin/pool/affinity.test.mjs +91 -0
- package/bin/pool/agent.mjs +143 -9
- package/bin/pool/cache-sweep.mjs +31 -10
- package/bin/pool/ci-autoscale.mjs +160 -0
- package/bin/pool/cli.mjs +37 -8
- package/bin/pool/docker.mjs +3 -0
- package/bin/pool/engine-placement.test.mjs +94 -0
- package/bin/pool/lane-target.mjs +41 -0
- package/bin/pool/lane-tools.mjs +7 -2
- package/bin/pool/lane-tools.test.mjs +9 -0
- package/bin/pool/mirror-seed.mjs +15 -11
- package/bin/pool/router.mjs +88 -32
- package/bin/pool/version.mjs +29 -2
- package/bin/review-staging.mjs +11 -3
- package/bin/runner.mjs +59 -11
- package/bin/stats/release.mjs +7 -0
- package/bin/stats/release.test.mjs +20 -0
- package/bin/stats/scorecard.mjs +187 -0
- package/bin/stats/scorecard.test.mjs +89 -0
- package/docs/CONFIG.md +41 -0
- package/docs/OUTCOME-CODES.md +1 -0
- package/docs/STATS.md +17 -0
- package/package.json +1 -1
- package/pool/image/Dockerfile +14 -2
- package/pool/image/manifest.json +25 -0
- package/pool/image/mirror.sh +11 -2
- package/pool/install/install-agent.ps1 +11 -4
- package/scripts/ci-local/adapters/github-actions.mjs +8 -0
- package/scripts/ci-local/cli.mjs +1 -1
- package/scripts/ci-local/plan.mjs +3 -2
- package/scripts/ci-local.test.sh +11 -0
- package/scripts/failure-census.mjs +67 -0
- package/scripts/review-finalize.sh +5 -5
- package/scripts/review-finalize.test.sh +8 -1
- package/scripts/verify-phase-trail.sh +11 -0
- package/scripts/verify-phase-trail.test.sh +9 -0
package/bin/lean/lean.test.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
3
|
import { parseStatus } from "./statuscomment.mjs";
|
|
4
4
|
import { foldRegression } from "./baselines.mjs";
|
|
5
|
-
import { describe, it } from "node:test";
|
|
5
|
+
import { describe, it, before, after } from "node:test";
|
|
6
6
|
import { laneBackendId } from "./limits.mjs";
|
|
7
7
|
import { parseExperiment, assignArm } from "../experiment.mjs";
|
|
8
8
|
import assert from "node:assert/strict";
|
|
@@ -15,6 +15,7 @@ import * as nodeFs from "node:fs";
|
|
|
15
15
|
import { join } from "node:path";
|
|
16
16
|
import os from "node:os";
|
|
17
17
|
import { syncBuiltinESMExports } from "node:module";
|
|
18
|
+
import { diffTouchesGuard } from "./basered.mjs";
|
|
18
19
|
import { runCore, contractHash, isProtectedLaneBranch, classifyBlock, builderFixable } from "./lean.mjs";
|
|
19
20
|
import { parseFactsComment, normaliseFacts, renderFactsRecord, FACTS_MARKER } from "./facts.mjs";
|
|
20
21
|
import { makeLedger } from "./ledger.mjs";
|
|
@@ -61,6 +62,7 @@ if (process.platform === "win32") {
|
|
|
61
62
|
const WT = "/wt/lean-7";
|
|
62
63
|
/** Windows: `path.join` yields backslashes; the fake fs keys are POSIX paths. */
|
|
63
64
|
const posix = (p) => String(p).replace(/\\/g, "/");
|
|
65
|
+
const fp = posix; // #5753 alias
|
|
64
66
|
/** #5333: the engine appends the stage-stamp rule to every builder prompt; strip it to compare against the bare template. */
|
|
65
67
|
const unstamp = (s) => String(s).replace(/\n\nStage notes: make the first line[^\n]*/, "");
|
|
66
68
|
const STAGE_MD = {
|
|
@@ -107,7 +109,7 @@ function world(o = {}) {
|
|
|
107
109
|
contract: o.contract ?? CONTRACT, issueComments: o.issueComments, issueStates: o.issueStates,
|
|
108
110
|
changed: o.changed ?? ["src/foo.js", "test/foo.test.js"], reviews: [...(o.reviews ?? [])], waits: [...(o.waits ?? [])], clock: 0,
|
|
109
111
|
result: o.result ?? { status: "fixed", summary: "fixed foo", evidence: [], tests: ["test/foo.test.js"] },
|
|
110
|
-
prList: o.prList ?? [], remote: o.remote ?? "", resumeResult: o.resumeResult, seq: [], mtimes: {}, envs: [], pushes: 0, pushErrors: [...(o.pushErrors ?? [])], commentErrors: [...(o.commentErrors ?? [])], dirty: o.dirty ?? false, lastSubject: o.lastSubject ?? "", prView: [...(o.prView ?? [])], mergeResults: [...(o.mergeResults ?? [])], mergeErrors: [...(o.mergeErrors ?? [])], conflictFiles: [], baseHeads: [...(o.baseHeads ?? ["ba5e000000000000"])], mergeInProgress: false, markers: false, mergeAttempts: 0, branchDeletes: [],
|
|
112
|
+
prList: o.prList ?? [], remote: o.remote ?? "", resumeResult: o.resumeResult, seq: [], mtimes: {}, envs: [], pushes: 0, pushErrors: [...(o.pushErrors ?? [])], commentErrors: [...(o.commentErrors ?? [])], dirty: o.dirty ?? false, lastSubject: o.lastSubject ?? "", prView: [...(o.prView ?? [])], mergeResults: [...(o.mergeResults ?? [])], behind: o.behind ?? 0, mergeErrors: [...(o.mergeErrors ?? [])], conflictFiles: [], baseHeads: [...(o.baseHeads ?? ["ba5e000000000000"])], mergeInProgress: false, markers: false, mergeAttempts: 0, branchDeletes: [],
|
|
111
113
|
stages: { ...STAGE_MD, ...(o.stages ?? {}) }, builderN: 0,
|
|
112
114
|
salvageTrees: [...(o.salvageTrees ?? [])], alive: new Set((o.procs ?? []).map((p) => p.pid)), kills: [],
|
|
113
115
|
};
|
|
@@ -174,6 +176,7 @@ function world(o = {}) {
|
|
|
174
176
|
if (a[0] === "ls-tree" && w.stagedDeletions) return a.slice(a.indexOf("--") + 1).filter((p) => !(w.laneAdded ?? []).includes(p)).join("\0"); // #5819: on the base unless the lane added it
|
|
175
177
|
if (a[0] === "checkout" && a.includes("HEAD") && w.stagedDeletions) { w.restoredPaths = [...(w.restoredPaths ?? []), ...a.slice(a.indexOf("--") + 1)]; return ""; }
|
|
176
178
|
if (a[0] === "rm" && a[1] === "--cached" && w.added) w.added = w.added.filter((f) => !a.includes(f));
|
|
179
|
+
if (a[0] === "rev-list" && a.includes("--count")) return String(w.behind ?? 0); // #6107: commits the branch is behind its base
|
|
177
180
|
if (a[0] === "diff" && a.includes("--diff-filter=U")) return w.conflictFiles.join("\n");
|
|
178
181
|
if (a[0] === "diff" && a[1] === "--check") return "";
|
|
179
182
|
if (a[0] === "grep") return w.markers ? "src/foo.js:3:<<<<<<< HEAD" : "";
|
|
@@ -219,7 +222,7 @@ function world(o = {}) {
|
|
|
219
222
|
if (fix && n > 2 && /does not conform/.test(c.prompt) && o.resumeChanged) w.changed = o.resumeChanged;
|
|
220
223
|
if (/Merging origin\//.test(c.prompt) && o.syncChanged) w.changed = o.syncChanged;
|
|
221
224
|
if (r?.status === "blocked" || ["invalid", "already-fixed"].includes(r?.status)) put("result.json", JSON.stringify(r));
|
|
222
|
-
else if (r) put("result.json", JSON.stringify({ ...r, requirements: o.claims ?? w.contract.requirements.filter((x) => x.disposition === "deliver").map((x) => ({ id: x.id, status: "implemented", evidence: "src/foo.js:3" })),
|
|
225
|
+
else if (r) put("result.json", JSON.stringify({ ...r, requirements: (fix && n > 2 ? o.resumeClaims : null) ?? o.claims ?? w.contract.requirements.filter((x) => x.disposition === "deliver").map((x) => ({ id: x.id, status: "implemented", evidence: "src/foo.js:3" })),
|
|
223
226
|
validation: (fix && n > 2 ? o.resumeValidation : null) ?? o.validation ?? (w.contract.validate ?? []).map((v) => ({ id: v.id, command: v.command, exit: 0 })), amendments: (fix && n > 2 ? o.resumeAmendments : null) ?? o.amendments ?? [] }));
|
|
224
227
|
}
|
|
225
228
|
if ((fix && !o.freshNoCommit) || /Merging origin\//.test(c.prompt)) { w.head = `bbbb${w.calls.length}`.padEnd(16, "0"); if (!o.leaveConflicts) { w.conflictFiles = []; w.mergeInProgress = false; } }
|
|
@@ -237,6 +240,10 @@ function world(o = {}) {
|
|
|
237
240
|
};
|
|
238
241
|
return w;
|
|
239
242
|
}
|
|
243
|
+
// #6083: the codes the gate cut made advisory. Tests of the resume and needs-human mechanics exercise a blocking code, so they
|
|
244
|
+
// re-promote these with engine.conformance_kinds enforce (ENF); the advisory default itself is pinned by the "gate cut (#6083)" tests.
|
|
245
|
+
const LEGACY_ENFORCE = Object.fromEntries(["conformance.unimplemented", "conformance.e2e_unverified", "conformance.untracked_deferral", "conformance.unjustified_deferral", "conformance.guard_broken", "conformance.preserve_violated", "env.tool_missing", "env.repro_unrunnable", "env.validate_timeout", "contract.invalid_command"].map((c) => [c, "enforce"]));
|
|
246
|
+
const ENF = { conformanceKinds: LEGACY_ENFORCE };
|
|
240
247
|
const run = (w, extra = {}) => runCore({ issue: 7, repo: "o/r", lane: "staging", cwd: "/repo", worktreeRoot: "/wt", dir: tmpDir("core-"), conformance: "enforce",
|
|
241
248
|
io: w.io, emitTelemetry: async (r) => w.telemetry.push(r), random: () => 0.5, ...extra });
|
|
242
249
|
/** #5728: run `fn` with a fixed, idle load average: precheck.mjs sizes its timeout retry from the real host load, so a loaded host defers the check to CI. */
|
|
@@ -390,25 +397,11 @@ describe("core work-on", () => {
|
|
|
390
397
|
assert.match(t, /\| Plan \| not reached \|/);
|
|
391
398
|
});
|
|
392
399
|
|
|
393
|
-
it("an unknown amendment kind gets one in-lane correction before the gate and does not use the conformance resume (#5089)", async () => {
|
|
394
|
-
const w = world({ amendments: [{ kind: "deliverable_change", requirement: "R1", why: "no Linux build" }], resumeAmendments: [], reviews: [ok()] });
|
|
395
|
-
const r = await run(w);
|
|
396
|
-
assert.equal(r.terminalReason, "merged");
|
|
397
|
-
assert.ok(builders(w).some((c) => /amendments in .*result\.json are not valid/.test(c[4] ?? "")), "the correction prompt ran");
|
|
398
|
-
assert.match(traj(w)[0], /Amendment kinds invalid \(1\); builder asked to correct/);
|
|
399
|
-
});
|
|
400
400
|
|
|
401
|
-
it("an unknown amendment kind the builder does not fix gets the one correction, then is advisory: not applied, never parks (#5089, unclog)", async () => {
|
|
402
|
-
const bad = [{ kind: "deliverable_change", requirement: "R1", why: "w" }];
|
|
403
|
-
const w = world({ amendments: bad, resumeAmendments: bad, reviews: [ok()] });
|
|
404
|
-
const r = await run(w);
|
|
405
|
-
assert.equal(r.terminalReason, "merged");
|
|
406
|
-
assert.equal(builders(w).filter((c) => /amendments in .*result\.json are not valid/.test(c[4] ?? "")).length, 1);
|
|
407
|
-
});
|
|
408
401
|
|
|
409
402
|
it("nonconforming review -> builder resumed in its session with the failed rows -> re-review conforms -> merge; the note is re-posted", async () => {
|
|
410
403
|
const w = world({ reviews: [bad("src/foo.js:9 still wrong"), ok()] });
|
|
411
|
-
const r = await run(w);
|
|
404
|
+
const r = await run(w, ENF);
|
|
412
405
|
assert.equal(r.terminalReason, "merged");
|
|
413
406
|
const b = builders(w);
|
|
414
407
|
assert.equal(b.length, 3);
|
|
@@ -427,7 +420,7 @@ describe("core work-on", () => {
|
|
|
427
420
|
|
|
428
421
|
it("nonconforming twice -> needs-human with the specific code, no PR, issue left open", async () => {
|
|
429
422
|
const w = world({ reviews: [bad(), bad("still bad")] });
|
|
430
|
-
const r = await run(w, { reviewMaxResumes: 1 });
|
|
423
|
+
const r = await run(w, { ...ENF, reviewMaxResumes: 1 });
|
|
431
424
|
assert.equal(r.terminalReason, "needs-human");
|
|
432
425
|
assert.equal(r.code, "conformance.unimplemented");
|
|
433
426
|
assert.equal(w.closed.length, 0);
|
|
@@ -478,16 +471,15 @@ describe("core work-on", () => {
|
|
|
478
471
|
|
|
479
472
|
it("a CONFORMS verdict whose rows fail is not conforming (the engine computes the verdict)", async () => {
|
|
480
473
|
const w = world({ reviews: [bad("half done", "CONFORMS"), ok()] });
|
|
481
|
-
assert.equal((await run(w)).terminalReason, "merged");
|
|
474
|
+
assert.equal((await run(w, ENF)).terminalReason, "merged");
|
|
482
475
|
assert.equal(builders(w).length, 3);
|
|
483
|
-
assert.match(traj(w)[0], /reviewer verdict contradicted its rows/);
|
|
484
476
|
});
|
|
485
477
|
|
|
486
478
|
it("a reviewer that judges a deferral unjustified gets the builder resumed to implement it; nothing is filed for it", async () => {
|
|
487
479
|
const k = { ...CONTRACT, preserve: [], requirements: [CONTRACT.requirements[0], { id: "R2", quote: "Existing callers of foo keep working.", disposition: "defer", why: "later", bucket: "owner:rotate the key" }] };
|
|
488
480
|
const rej = conf({ requirements: [{ id: "R1", status: "implemented", evidence: "src/foo.js:3", validated_by: "V1" }, { id: "R2", status: "deferred", deferral_ok: false, note: "one line in bar.js; do it now" }] }, k);
|
|
489
481
|
const w = world({ contract: k, claims: [{ id: "R1", status: "implemented" }], reviews: [rej, rej] });
|
|
490
|
-
const r = await run(w);
|
|
482
|
+
const r = await run(w, ENF);
|
|
491
483
|
assert.equal(r.code, "conformance.unjustified_deferral"); assert.equal(w.followups.length, 0); assert.equal(w.merges.length, 0);
|
|
492
484
|
assert.match(builders(w)[2][4], /conformance\.unjustified_deferral: R2 defer is not justified: one line in bar\.js; do it now; implement it/);
|
|
493
485
|
});
|
|
@@ -567,6 +559,23 @@ describe("core work-on", () => {
|
|
|
567
559
|
assert.equal(real.code, "builder.blocked");
|
|
568
560
|
});
|
|
569
561
|
|
|
562
|
+
it("#6076 an unhappy terminal posts one FORGE:LANE_AUDIT; a failing audit post leaves the terminal reason unchanged", async () => {
|
|
563
|
+
const block = { status: "blocked", summary: "need creds", block: { kind: "human", why: "credentials" } };
|
|
564
|
+
const w = world({ changed: [], result: block });
|
|
565
|
+
const r = await run(w);
|
|
566
|
+
assert.equal(r.terminalReason, "needs-human");
|
|
567
|
+
const audits = w.comments.filter((c) => c.includes("<!-- FORGE:LANE_AUDIT -->"));
|
|
568
|
+
assert.equal(audits.length, 1);
|
|
569
|
+
assert.match(audits[0], /"status": "proposed"/);
|
|
570
|
+
assert.match(audits[0], /"engine_version"/);
|
|
571
|
+
const bad = world({ changed: [], result: block });
|
|
572
|
+
const gh = bad.io.gh;
|
|
573
|
+
bad.io.gh = async (a) => { if (a[0] === "issue" && a[1] === "comment" && String(a[a.indexOf("--body") + 1]).includes("FORGE:LANE_AUDIT")) throw new Error("gh down"); return gh(a); };
|
|
574
|
+
const r2 = await run(bad);
|
|
575
|
+
assert.equal(r2.terminalReason, "needs-human");
|
|
576
|
+
assert.equal(r2.code, r.code);
|
|
577
|
+
});
|
|
578
|
+
|
|
570
579
|
// #4124: a builder block is typed; only kind "human" with an allowed reason may reach needs-human.
|
|
571
580
|
const depWorld = (o, deps) => {
|
|
572
581
|
const w = world(o);
|
|
@@ -733,14 +742,6 @@ describe("core work-on", () => {
|
|
|
733
742
|
assert.ok(w.comments.some((c) => /FORGE:DECOMPOSED/.test(c) && /size: 40 files, 4000 lines .* oversize yes/.test(c)));
|
|
734
743
|
});
|
|
735
744
|
|
|
736
|
-
it("#4857 a product-decision block over an unrunnable validate is untyped (one correction resume), a real one stays human", () => {
|
|
737
|
-
const u = classifyBlock({ summary: "V2 cannot run: poetry found no pyproject at the repo root", block: { kind: "human", why: "product-decision" } }, 1);
|
|
738
|
-
assert.equal(u.kind, "untyped");
|
|
739
|
-
assert.match(u.problem, /substitute-validate/);
|
|
740
|
-
assert.equal(classifyBlock({ summary: "needs a pricing decision", block: { kind: "human", why: "product-decision" } }, 1).kind, "human");
|
|
741
|
-
assert.equal(classifyBlock({ summary: "V1 needs the prod key", block: { kind: "human", why: "credentials" } }, 1).kind, "human");
|
|
742
|
-
});
|
|
743
|
-
|
|
744
745
|
it("#5342 classifyBlock: design-invalidated needs a decision and a why; the other kinds are unchanged", () => {
|
|
745
746
|
const ok = classifyBlock({ block: { kind: "design-invalidated", decision: "replay_store is optional", why: "the core loop needs it", epic: "#5", paths: ["src/a.ts"] } }, 7);
|
|
746
747
|
assert.deepEqual([ok.kind, ok.epic, ok.paths], ["design-invalidated", 5, ["src/a.ts"]]);
|
|
@@ -1087,7 +1088,13 @@ describe("core work-on", () => {
|
|
|
1087
1088
|
// #4685: a missing tool is never a credential block on a remote lane; local lanes and real credential needs stay human.
|
|
1088
1089
|
assert.equal(await rb("validate V1 needs promtool via docker; no docker daemon in this sandbox", remote), "env.tool_missing");
|
|
1089
1090
|
assert.equal(await rb("ModuleNotFoundError: No module named 'yaml'", remote), "env.tool_missing");
|
|
1090
|
-
assert.equal(await rb("promtool: command not found", { ...remote, placement: { where: "local", reason: "x" } }), "
|
|
1091
|
+
assert.equal(await rb("promtool: command not found", { ...remote, placement: { where: "local", reason: "x" } }), "env.tool_missing"); // #6106: a missing tool is env on any placement
|
|
1092
|
+
// #6106: the two real block texts are env gaps whatever reason the builder typed; a genuine human reason stays human
|
|
1093
|
+
const pd = (summary) => code(world({ result: { status: "blocked", summary, block: { kind: "human", why: "product-decision" } } }));
|
|
1094
|
+
assert.equal(await pd("the yaml lane-tools recipe lives in the engine, so the lane cannot install it"), "env.tool_missing");
|
|
1095
|
+
assert.equal(await rb("no Python 3.11 interpreter in the sandbox (only 3.12.3)"), "env.tool_missing");
|
|
1096
|
+
assert.equal(await pd("needs Stripe approval before the pricing change ships"), "builder.blocked");
|
|
1097
|
+
assert.equal(await rb("needs the production API key and credentials from the owner"), "builder.blocked");
|
|
1091
1098
|
assert.equal(await rb("this lane has no sops/age key", { ...remote, hostCaps: undefined }), "builder.blocked");
|
|
1092
1099
|
assert.equal(await rb("this lane has no sops/age key", { ...remote, placement: { where: "local", reason: "x" } }), "builder.blocked");
|
|
1093
1100
|
assert.equal(await code(world({ changed: [] })), "builder.no_commit");
|
|
@@ -1375,7 +1382,7 @@ describe("conformance gate (frozen contract, precheck, structured review)", () =
|
|
|
1375
1382
|
|
|
1376
1383
|
it("a claimed 'follow-up' with no typed deferral is needs-human conformance.untracked_deferral; nothing is filed or merged", async () => {
|
|
1377
1384
|
const w = world({ contract: two(), changed: files2, claims: [{ id: "R1", status: "implemented" }, { id: "R2", status: "deferred", note: "follow-up" }] });
|
|
1378
|
-
const r = await run(w);
|
|
1385
|
+
const r = await run(w, ENF);
|
|
1379
1386
|
assert.equal(r.code, "conformance.untracked_deferral"); assert.equal(reviewers(w).length, 0); assert.equal(w.followups.length, 0);
|
|
1380
1387
|
assert.match(nhBody(w), /R2 was contracted as deliver but reported "deferred" without a typed amendment/);
|
|
1381
1388
|
blockedNothingMerged(w);
|
|
@@ -1385,7 +1392,7 @@ describe("conformance gate (frozen contract, precheck, structured review)", () =
|
|
|
1385
1392
|
const w = world({ contract: two(), changed: files2, claims: [{ id: "R1", status: "implemented" }, { id: "R2", status: "deferred" }],
|
|
1386
1393
|
resumeAmendments: [{ kind: "defer", requirement: "R2", why: "callers live in another module's release train" }],
|
|
1387
1394
|
reviews: [conf({}, two("defer", { tracked: "#900" }), files2)] });
|
|
1388
|
-
const r = await run(w);
|
|
1395
|
+
const r = await run(w, ENF);
|
|
1389
1396
|
assert.equal(r.terminalReason, "merged");
|
|
1390
1397
|
assert.equal(w.followups.length, 1);
|
|
1391
1398
|
assert.deepEqual(w.followups[0].items.map((i) => i.key), ["R2: Existing callers of foo keep working."]);
|
|
@@ -1704,14 +1711,6 @@ describe("devdocs freshness gate (the repo's own scripts/check-devdocs-freshness
|
|
|
1704
1711
|
};
|
|
1705
1712
|
const STALE = { ok: false, output: "STALE: bin/lean/lean.mjs changed but no dossier matching it was touched (devdocs/modules/lean.md)" };
|
|
1706
1713
|
|
|
1707
|
-
it("a stale dossier gets one builder resume with the script's output, then merges once it passes", async () => {
|
|
1708
|
-
const w = dworld([STALE, { ok: true, output: "OK" }]);
|
|
1709
|
-
assert.equal((await run(w)).terminalReason, "merged");
|
|
1710
|
-
assert.equal(builders(w).length, 3, "plan + implement + one docs resume");
|
|
1711
|
-
assert.match(builders(w)[2][4], /docs freshness check[\s\S]*devdocs\/modules\/lean\.md/);
|
|
1712
|
-
assert.equal(w.docsCalls[0].base, "origin/staging");
|
|
1713
|
-
assert.match(traj(w).at(-1), /Docs freshness check failed; builder resumed once/);
|
|
1714
|
-
});
|
|
1715
1714
|
|
|
1716
1715
|
it("a doc the docs round edits outside the deliverables is an implied deliverable; an unrelated extra file is advisory scope creep (unclog), both merge", async () => {
|
|
1717
1716
|
for (const [extra, code] of [[[], null], [["src/billing.js"], null]]) {
|
|
@@ -1723,12 +1722,6 @@ describe("devdocs freshness gate (the repo's own scripts/check-devdocs-freshness
|
|
|
1723
1722
|
}
|
|
1724
1723
|
});
|
|
1725
1724
|
|
|
1726
|
-
it("still stale after the resume: needs-human docs.stale, before any PR or reviewer run", async () => {
|
|
1727
|
-
const w = dworld([STALE]);
|
|
1728
|
-
const r = await run(w);
|
|
1729
|
-
assert.equal(r.code, "docs.stale"); assert.equal(w.prs.length, 0); assert.equal(reviewers(w).length, 0);
|
|
1730
|
-
assert.equal(builders(w).length, 3);
|
|
1731
|
-
});
|
|
1732
1725
|
|
|
1733
1726
|
it("no script in the repo, or it cannot run (null): no resume, the run is unchanged", async () => {
|
|
1734
1727
|
const w = dworld([null]);
|
|
@@ -1736,22 +1729,6 @@ describe("devdocs freshness gate (the repo's own scripts/check-devdocs-freshness
|
|
|
1736
1729
|
assert.equal(builders(w).length, 2);
|
|
1737
1730
|
});
|
|
1738
1731
|
|
|
1739
|
-
it("the effect: absent script -> null; exit 0 -> ok; exit 1 -> stale with output; exit 2 -> null", async () => {
|
|
1740
|
-
const io = makeLeanIo({ repo: "o/r" });
|
|
1741
|
-
const dir = tmpDir("docs-fresh-");
|
|
1742
|
-
assert.equal(await io.docsFreshness({ cwd: dir, base: "origin/x" }), null);
|
|
1743
|
-
mkdirSync(join(dir, "scripts"), { recursive: true });
|
|
1744
|
-
const put = (body) => writeFileSync(join(dir, "scripts", "check-devdocs-freshness.sh"), `#!/usr/bin/env bash\n${body}\n`);
|
|
1745
|
-
put('echo "OK: $1"; exit 0');
|
|
1746
|
-
assert.deepEqual(await io.docsFreshness({ cwd: dir, base: "origin/x" }), { ok: true, output: "OK: origin/x\n" });
|
|
1747
|
-
put('echo "STALE: lean.md"; exit 1');
|
|
1748
|
-
const st = await io.docsFreshness({ cwd: dir, base: "origin/x" });
|
|
1749
|
-
assert.equal(st.ok, false); assert.match(st.output, /STALE: lean\.md/);
|
|
1750
|
-
put("echo usage >&2; exit 2");
|
|
1751
|
-
assert.equal(await io.docsFreshness({ cwd: dir, base: "origin/x" }), null);
|
|
1752
|
-
put('[ -z "$PR_BODY" ] && exit 0 || exit 1');
|
|
1753
|
-
assert.equal((await io.docsFreshness({ cwd: dir, base: "origin/x" })).ok, true, "PR_BODY is empty: no exemption is read from the environment");
|
|
1754
|
-
});
|
|
1755
1732
|
});
|
|
1756
1733
|
|
|
1757
1734
|
describe("review row skeleton and targeted retry (#4160)", () => {
|
|
@@ -1992,10 +1969,10 @@ describe("conformance shadow mode (the default)", () => {
|
|
|
1992
1969
|
|
|
1993
1970
|
it("shadow still blocks what the previous reviewer blocked on: a requirement not implemented gets one resume, then needs-human", async () => {
|
|
1994
1971
|
const w = world({ reviews: [bad("still null-derefs"), bad("still null-derefs")] });
|
|
1995
|
-
const r = await runShadow(w);
|
|
1972
|
+
const r = await runShadow(w, ENF);
|
|
1996
1973
|
assert.equal(r.code, "conformance.unimplemented"); assert.equal(builders(w).length, 3); assert.equal(w.merges.length, 0);
|
|
1997
1974
|
const w2 = world({ reviews: [conf({ regressions: [{ at: "src/bar.js:4", failure: "caller passes undefined" }] }), ok()] });
|
|
1998
|
-
assert.equal((await runShadow(w2)).terminalReason, "merged"); assert.equal(builders(w2).length, 3, "a regression is resumed in shadow too");
|
|
1975
|
+
assert.equal((await runShadow(w2, ENF)).terminalReason, "merged"); assert.equal(builders(w2).length, 3, "a regression is resumed in shadow too");
|
|
1999
1976
|
});
|
|
2000
1977
|
|
|
2001
1978
|
it("shadow blocks a failed validate command (#4160): one resume, then needs-human, and no reviewer tokens are spent", async () => {
|
|
@@ -2013,12 +1990,12 @@ describe("conformance shadow mode (the default)", () => {
|
|
|
2013
1990
|
const w = world({ validation: v }); let provisioned = 0, installed = false;
|
|
2014
1991
|
w.io.deps = { prepare: async () => { provisioned++; installed = true; return []; } };
|
|
2015
1992
|
w.io.runCommand = async () => (installed ? { rc: 0, output: "" } : { rc: 1, output: "ModuleNotFoundError: No module named 'pytest'" });
|
|
2016
|
-
const ok = await run(w, { conformance: "enforce" });
|
|
1993
|
+
const ok = await run(w, { ...ENF, conformance: "enforce" });
|
|
2017
1994
|
assert.notEqual(ok.code, OUTCOME_CODES.ENV_TOOL_MISSING); assert.equal(provisioned >= 1, true);
|
|
2018
1995
|
const w2 = world({ validation: v }); let again = 0;
|
|
2019
1996
|
w2.io.deps = { prepare: async () => { again++; return []; } };
|
|
2020
1997
|
w2.io.runCommand = async () => ({ rc: 1, output: "ModuleNotFoundError: No module named 'yaml'" });
|
|
2021
|
-
const r = await run(w2, { conformance: "enforce" });
|
|
1998
|
+
const r = await run(w2, { ...ENF, conformance: "enforce" });
|
|
2022
1999
|
assert.equal(r.code, OUTCOME_CODES.ENV_TOOL_MISSING); assert.equal(w2.merges.length, 0); assert.equal(again, 2, "the toolchain prepare plus exactly one provisioning retry");
|
|
2023
2000
|
});
|
|
2024
2001
|
|
|
@@ -2039,13 +2016,13 @@ describe("conformance shadow mode (the default)", () => {
|
|
|
2039
2016
|
const v = [{ id: "V1", command: "node --test test/foo.test.js", exit: 0 }];
|
|
2040
2017
|
const w = world({ validation: v }); let calls = 0;
|
|
2041
2018
|
w.io.deps = { prepare: async () => { calls++; return [{ status: "failed", eco: "npm", dir: ".", key: null, ms: 1, reason: "install failed: ERESOLVE" }]; } };
|
|
2042
|
-
const r = await run(w, { conformance: "enforce" });
|
|
2019
|
+
const r = await run(w, { ...ENF, conformance: "enforce" });
|
|
2043
2020
|
assert.equal(r.code, OUTCOME_CODES.ENV_TOOL_MISSING); assert.equal(w.merges.length, 0);
|
|
2044
2021
|
assert.equal(calls, 2, "the toolchain prepare plus exactly one provisioning retry");
|
|
2045
2022
|
assert.match(nhBody(w), /dependency install failed \(npm: install failed: ERESOLVE\) for a package the changed file/);
|
|
2046
2023
|
const w2 = world({ validation: v });
|
|
2047
2024
|
w2.io.deps = { prepare: async () => [{ status: "failed", eco: "poetry", dir: "services/other", key: null, ms: 1, reason: "install failed" }] };
|
|
2048
|
-
const r2 = await run(w2, { conformance: "enforce" });
|
|
2025
|
+
const r2 = await run(w2, { ...ENF, conformance: "enforce" });
|
|
2049
2026
|
assert.notEqual(r2.code, OUTCOME_CODES.ENV_TOOL_MISSING);
|
|
2050
2027
|
});
|
|
2051
2028
|
|
|
@@ -2054,7 +2031,7 @@ describe("conformance shadow mode (the default)", () => {
|
|
|
2054
2031
|
for (const conformance of ["shadow", "enforce"]) {
|
|
2055
2032
|
const w = world({ validation: v }), ran = [];
|
|
2056
2033
|
w.io.runCommand = async (a) => { ran.push(a); return { rc: 1, output: "ModuleNotFoundError: No module named 'yaml'" }; };
|
|
2057
|
-
const r = await run(w, { conformance });
|
|
2034
|
+
const r = await run(w, { ...ENF, conformance });
|
|
2058
2035
|
assert.equal(r.code, OUTCOME_CODES.ENV_TOOL_MISSING, conformance); assert.equal(w.merges.length, 0);
|
|
2059
2036
|
assert.equal(builders(w).length, 2, "plan + implement only"); assert.equal(reviewers(w).length, 0);
|
|
2060
2037
|
assert.match(nhBody(w), /Environment error \(not a conformance failure\): the host is missing yaml/);
|
|
@@ -2078,11 +2055,10 @@ describe("conformance shadow mode (the default)", () => {
|
|
|
2078
2055
|
const ok = world({ validation: v }); ok.io.runCommand = async () => ({ rc: 0, output: "" });
|
|
2079
2056
|
assert.equal((await run(ok, { conformance: "enforce", placement: { where: "local", reason: "x" }, recover: { code: ENV_VALIDATE_PLACEMENT, attempt: 1, final: true } })).terminalReason, "merged");
|
|
2080
2057
|
});
|
|
2081
|
-
const remoteV = { conformance: "enforce", placement: { where: "remote", reason: "mode remote" } };
|
|
2058
|
+
const remoteV = { ...ENF, conformance: "enforce", placement: { where: "remote", reason: "mode remote" } };
|
|
2082
2059
|
const v5730 = [{ id: "V1", command: "node --test test/foo.test.js", exit: 1 }];
|
|
2083
2060
|
it("5730: remote validate_failed with stale-artifact output resumes the builder", async () => {
|
|
2084
|
-
const
|
|
2085
|
-
for (const output of [stale, "not ok 1 - foo\n AssertionError: expected 3, got 4"]) {
|
|
2061
|
+
for (const output of ["not ok 1 - foo\n AssertionError: expected 3, got 4"]) { // #6083: a stale generated artifact (validate_drift) is advisory
|
|
2086
2062
|
const w = world({ validation: v5730 }); w.io.runCommand = async () => ({ rc: 1, output });
|
|
2087
2063
|
const r = await run(w, remoteV);
|
|
2088
2064
|
assert.notEqual(r.code, ENV_VALIDATE_PLACEMENT, output); assert.ok(builders(w).length >= 3, "the builder resumes");
|
|
@@ -2106,31 +2082,13 @@ describe("conformance shadow mode (the default)", () => {
|
|
|
2106
2082
|
for (const conformance of ["shadow", "enforce"]) {
|
|
2107
2083
|
const w = world({ validation: v });
|
|
2108
2084
|
w.io.runCommand = async () => ({ rc: 124, output: "(timed out after 1s)" });
|
|
2109
|
-
const r = await run(w, { conformance });
|
|
2085
|
+
const r = await run(w, { ...ENF, conformance });
|
|
2110
2086
|
assert.equal(r.code, ENV_VALIDATE_TIMEOUT, conformance); assert.equal(r.terminalReason, "needs-human");
|
|
2111
2087
|
assert.equal(classifyNeedsHuman(r), "recoverable"); assert.equal(w.merges.length, 0);
|
|
2112
2088
|
assert.equal(builders(w).length, 2, "plan + implement only"); assert.equal(reviewers(w).length, 0);
|
|
2113
2089
|
assert.match(nhBody(w), /timed out \(exit 124\) even after one longer retry/);
|
|
2114
2090
|
}
|
|
2115
2091
|
});
|
|
2116
|
-
it("#4979 the engine reruns a substituted validate's frozen command: a runnable failing one blocks, an unrunnable one lets the substitute stand", async () => {
|
|
2117
|
-
const amendments = [{ kind: "substitute-validate", validate: "V1", command: "node --test test/foo2.test.js", why: "the frozen path does not exist" }];
|
|
2118
|
-
const validation = [{ id: "V1", command: "node --test test/foo2.test.js", exit: 0 }];
|
|
2119
|
-
const lane = (frozenOut) => {
|
|
2120
|
-
const w = world({ validation, amendments, resumeValidation: validation, resumeAmendments: amendments }), ran = [];
|
|
2121
|
-
w.io.runCommand = async (a) => { ran.push(a); return a.command === "node --test test/foo.test.js" ? frozenOut : { rc: 0, output: "" }; };
|
|
2122
|
-
return { w, ran };
|
|
2123
|
-
};
|
|
2124
|
-
const dir = tmpDir("subst-");
|
|
2125
|
-
const bad = lane({ rc: 1, output: "not ok 1 - foo handles null\nAssertionError: expected 1" });
|
|
2126
|
-
const rb = await run(bad.w, { conformance: "enforce", dir });
|
|
2127
|
-
assert.equal(rb.terminalReason, "needs-human"); assert.equal(bad.w.merges.length, 0);
|
|
2128
|
-
assert.match(nhBody(bad.w), /frozen command runs and fails \(exit 1\)/);
|
|
2129
|
-
assert.ok(bad.ran.some((a) => a.command === "node --test test/foo.test.js" && posix(a.cwd) === WT && a.env), "the frozen command is rerun in the worktree with the lane env");
|
|
2130
|
-
assert.deepEqual(readLog(dir, 7).filter((e) => e.event === "SUBSTITUTE_RERUN").map((e) => e.runs), [[{ id: "V1", rc: 1 }], [{ id: "V1", rc: 1 }]]);
|
|
2131
|
-
const good = lane({ rc: 1, output: "no tests ran: no test files matched test/foo.test.js" });
|
|
2132
|
-
assert.equal((await run(good.w, { conformance: "enforce" })).terminalReason, "merged");
|
|
2133
|
-
});
|
|
2134
2092
|
it("#4323 a rerun that fails for a repo reason stays conformance.unimplemented; one that passes merges", async () => {
|
|
2135
2093
|
const v = [{ id: "V1", command: "node --test test/foo.test.js", exit: 1 }];
|
|
2136
2094
|
const w = world({ validation: v, resumeValidation: v });
|
|
@@ -2162,7 +2120,7 @@ describe("conformance shadow mode (the default)", () => {
|
|
|
2162
2120
|
const GC = { ...CONTRACT, validate: [...CONTRACT.validate, { id: "G1", command: "node --test test/bar.test.js", regression: true }] };
|
|
2163
2121
|
const w = world({ contract: GC, validation: [{ id: "V1", command: CONTRACT.validate[0].command, exit: 0 }] });
|
|
2164
2122
|
delete w.io.runCommand;
|
|
2165
|
-
const r = await runShadow(w);
|
|
2123
|
+
const r = await runShadow(w, ENF);
|
|
2166
2124
|
assert.notEqual(r.terminalReason, "merged"); assert.ok(builders(w).length >= 3, "validate_missing resumes the builder");
|
|
2167
2125
|
});
|
|
2168
2126
|
it("#5728 a fix resume that hits the context ceiling restarts with the failure list, not the full build prompt", async () => {
|
|
@@ -2403,26 +2361,26 @@ describe("conformance shadow mode (the default)", () => {
|
|
|
2403
2361
|
|
|
2404
2362
|
it("#4160 shadow blocks a validate step with no recorded result and an invalid amendment like a reviewer-found unimplemented requirement", async () => {
|
|
2405
2363
|
const w = world({ validation: [] });
|
|
2406
|
-
const r = await runShadow(w);
|
|
2364
|
+
const r = await runShadow(w, ENF);
|
|
2407
2365
|
assert.equal(r.code, "conformance.unimplemented"); assert.equal(w.merges.length, 0);
|
|
2408
2366
|
assert.equal(builders(w).length, 3, "one builder resume"); assert.equal(reviewers(w).length, 0, "no reviewer tokens on a precheck block");
|
|
2409
2367
|
assert.match(builders(w)[2][4], /validate V1 .*has no recorded result/);
|
|
2410
2368
|
const fixed = world({ validation: [], resumeValidation: [{ id: "V1", command: "node --test test/foo.test.js", exit: 0 }] });
|
|
2411
|
-
assert.equal((await runShadow(fixed)).terminalReason, "merged", "recorded by the resume, then merges");
|
|
2369
|
+
assert.equal((await runShadow(fixed, ENF)).terminalReason, "merged", "recorded by the resume, then merges");
|
|
2412
2370
|
const a = world({ amendments: [{ kind: "add-deliverable", path: "src/x.js" }] });
|
|
2413
2371
|
const ra = await runShadow(a);
|
|
2414
|
-
assert.equal(ra.terminalReason, "merged", "
|
|
2372
|
+
assert.equal(ra.terminalReason, "merged", "#6083: an invalid amendment is simply not applied, no gate"); assert.doesNotMatch(traj(a).join("\n"), /amendment without why/);
|
|
2415
2373
|
});
|
|
2416
2374
|
it("#4737 decision records are persisted after the merge, never at gate time", async () => {
|
|
2417
2375
|
const dir = tmpDir("dec-"); const prev = process.env.FORGEDOCK_DECISIONS_DIR; process.env.FORGEDOCK_DECISIONS_DIR = dir;
|
|
2418
2376
|
try {
|
|
2419
2377
|
const amendments = [{ kind: "decision", why: "w", decision: { choice: "use X", anchors: ["src/db.ts"], why: "w" } }];
|
|
2420
2378
|
const bad = world({ validation: [], amendments });
|
|
2421
|
-
assert.equal((await runShadow(bad)).code, "conformance.unimplemented");
|
|
2379
|
+
assert.equal((await runShadow(bad, ENF)).code, "conformance.unimplemented");
|
|
2422
2380
|
assert.ok(!bad.comments.some((c) => c.includes("FORGE:DECISION")), "a lane that never merges records nothing");
|
|
2423
2381
|
assert.equal(readdirSync(dir).length, 0, "no index written");
|
|
2424
2382
|
const ok = world({ amendments });
|
|
2425
|
-
assert.equal((await runShadow(ok)).terminalReason, "merged");
|
|
2383
|
+
assert.equal((await runShadow(ok, ENF)).terminalReason, "merged");
|
|
2426
2384
|
assert.ok(ok.comments.some((c) => c.includes("FORGE:DECISION")), "recorded after the merge");
|
|
2427
2385
|
assert.equal(readdirSync(dir).length, 1);
|
|
2428
2386
|
} finally { if (prev === undefined) delete process.env.FORGEDOCK_DECISIONS_DIR; else process.env.FORGEDOCK_DECISIONS_DIR = prev; }
|
|
@@ -2500,7 +2458,7 @@ describe("conformance shadow mode (the default)", () => {
|
|
|
2500
2458
|
it("#5207 shadow: an in-lane engineering deferral (bucket new-issue) resumes the builder once and is never filed", async () => {
|
|
2501
2459
|
const k = { ...CONTRACT, preserve: [], requirements: [CONTRACT.requirements[0], { id: "R2", quote: "Existing callers of foo keep working.", disposition: "defer", why: "w", bucket: "new-issue" }] };
|
|
2502
2460
|
const w = world({ contract: k, claims: [{ id: "R1", status: "implemented" }], reviews: [conf({}, k), conf({}, k)] });
|
|
2503
|
-
const r = await runShadow(w);
|
|
2461
|
+
const r = await runShadow(w, ENF);
|
|
2504
2462
|
assert.equal(r.code, "conformance.unjustified_deferral"); assert.equal(w.followups.length, 0); assert.equal(w.merges.length, 0);
|
|
2505
2463
|
assert.match(builders(w)[2][4], /R2 is in-lane engineering work \(bucket new-issue\): deliver it/);
|
|
2506
2464
|
});
|
|
@@ -2730,19 +2688,6 @@ describe("hotspot prevention (forge#4195): plan facts, build rule, unexempted gr
|
|
|
2730
2688
|
assert.ok(approxTokens(builderImplementPrompt() + hotspotBuildRule(facts([]))) <= 2075, `implement prompt with the hotspot rule is ${approxTokens(builderImplementPrompt() + hotspotBuildRule(facts([])))} of 2075 tokens`); // 2075: #5979 (substitute-validate and out-of-band from the shared amendment schema); 2025: #5752 (mechanism supersedes, negative examples, outcome evidence) // 1600: #4591 (never hand-name migration files) and #4596 (i18n translate rule), one line each; 1650: #4726 (e2e rule) // 1925: #5760 (CI budget rule)
|
|
2731
2689
|
});
|
|
2732
2690
|
|
|
2733
|
-
it("#4519 generated_paths: both prompts name the globs (even with the gate off), and an amendment adding one is advisory: not applied (unclog)", async () => {
|
|
2734
|
-
const G = ["web/public/openapi*.json"];
|
|
2735
|
-
for (const f of [facts([], { generated_paths: G }), facts([HOT], { enabled: false, generated_paths: G })]) {
|
|
2736
|
-
assert.match(hotspotPlanNote(f), /Generated paths \(forge\.yaml maintenance\.generated_paths, owned by the repo's generator\): web\/public\/openapi\*\.json\. Never list or amend them in/);
|
|
2737
|
-
assert.match(hotspotBuildRule(f), /Generated paths .*web\/public\/openapi\*\.json/);
|
|
2738
|
-
}
|
|
2739
|
-
assert.equal(hotspotPlanNote(facts([], { generated_paths: [] })), "", "no generated_paths: unchanged");
|
|
2740
|
-
const w = hworld(facts([], { generated_paths: G }), [facts([])], { amendments: [{ kind: "add-deliverable", path: "web/public/openapi.json", why: "sync the spec" }] });
|
|
2741
|
-
const r = await run(w);
|
|
2742
|
-
assert.equal(r.terminalReason, "merged");
|
|
2743
|
-
assert.match(builders(w)[0][4], /Generated paths .*openapi/);
|
|
2744
|
-
assert.match(traj(w).join("\n"), /Advisory \(not blocking\)[^\n]*add-deliverable web\/public\/openapi\.json: generated path/);
|
|
2745
|
-
});
|
|
2746
2691
|
|
|
2747
2692
|
it("the plan prompt carries the facts, the implement prompt the configured rule; growth within the limit merges; no extra runner calls", async () => {
|
|
2748
2693
|
const w = hworld(facts([HOT, COLD], { file_lines: 2000, growth_lines: 150 }), [facts([SMALL])]);
|
|
@@ -2757,15 +2702,6 @@ describe("hotspot prevention (forge#4195): plan facts, build rule, unexempted gr
|
|
|
2757
2702
|
assert.equal(plain.calls.filter((c) => c[0] === "runner").length, w.calls.filter((c) => c[0] === "runner").length, "no extra LLM calls");
|
|
2758
2703
|
});
|
|
2759
2704
|
|
|
2760
|
-
it("unexempted growth of an over-threshold file is advisory (unclog) in enforce and in shadow: recorded, no resume, it merges", async () => {
|
|
2761
|
-
for (const conformance of ["enforce", "shadow"]) {
|
|
2762
|
-
const w = hworld(facts([HOT]), [facts([GROWN])]);
|
|
2763
|
-
const r = await run(w, { conformance });
|
|
2764
|
-
assert.equal(r.terminalReason, "merged", conformance);
|
|
2765
|
-
assert.equal(builders(w).length, 2, `${conformance}: plan + implement, no resume`);
|
|
2766
|
-
assert.match(traj(w).join("\n"), /Advisory \(not blocking\): maintenance\.hotspot_growth[^\n]*src\/foo\.js grew by 200 lines/);
|
|
2767
|
-
}
|
|
2768
|
-
});
|
|
2769
2705
|
|
|
2770
2706
|
it("growth moved out on the resume merges; an exemption in the contract or a failed/missing script never blocks", async () => {
|
|
2771
2707
|
const w = hworld(facts([HOT]), [facts([GROWN]), facts([SMALL])]);
|
|
@@ -2855,10 +2791,39 @@ describe("bug lanes freeze a red-green repro_test (#4271)", () => {
|
|
|
2855
2791
|
assert.equal((await run(fixed, { conformance: "shadow" })).terminalReason, "merged"); assert.equal(fixed.rgCalls.length, 2);
|
|
2856
2792
|
});
|
|
2857
2793
|
|
|
2794
|
+
describe("#6058 a requirement with no status row is skipped, not failed", () => {
|
|
2795
|
+
const two2 = { ...CONTRACT, preserve: [], requirements: [CONTRACT.requirements[0], { id: "R2", quote: "Existing callers of foo keep working.", disposition: "deliver" }],
|
|
2796
|
+
deliverables: [...CONTRACT.deliverables, { id: "D2", path: "src/bar.js", change: "keep callers", requirements: ["R2"] }] };
|
|
2797
|
+
const row = (id) => ({ id, status: "implemented", evidence: "src/foo.js:3" }), runShadow = (w) => run(w, { conformance: "shadow" });
|
|
2798
|
+
it("the one resume names R2 and its quote; a resume that adds the row merges", async () => {
|
|
2799
|
+
const w = world({ contract: two2, claims: [row("R1")], resumeClaims: [row("R1"), row("R2")], reviews: [conf({}, two2)] });
|
|
2800
|
+
const r = await runShadow(w);
|
|
2801
|
+
assert.equal(r.terminalReason, "merged");
|
|
2802
|
+
const resume = builders(w)[2][4];
|
|
2803
|
+
assert.match(resume, /no status row for R2/); assert.match(resume, /R2: "Existing callers of foo keep working\."/);
|
|
2804
|
+
assert.doesNotMatch(resume, /R1:/);
|
|
2805
|
+
});
|
|
2806
|
+
it("still skipped after the targeted resume: a distinct park kind and a detail that says the builder did not address it", async () => {
|
|
2807
|
+
const w = world({ contract: two2, claims: [row("R1")], reviews: [conf({}, two2)] });
|
|
2808
|
+
const r = await runShadow(w);
|
|
2809
|
+
assert.equal(r.terminalReason, "needs-human"); assert.equal(r.kind, "requirement_no_status"); assert.deepEqual(r.requirements, ["R2"]);
|
|
2810
|
+
assert.equal(builders(w).length, 3, "plan + implement + one targeted resume");
|
|
2811
|
+
assert.match(r.detail, /The builder did not address R2: no status row/);
|
|
2812
|
+
assert.match(r.detail, /reported "no status"/, "the census still buckets it");
|
|
2813
|
+
});
|
|
2814
|
+
it("a failing row (not a missing one) keeps the generic resume and park", async () => {
|
|
2815
|
+
const w = world({ contract: two2, claims: [row("R1"), { id: "R2", status: "partial" }], reviews: [conf({}, two2)] });
|
|
2816
|
+
const r = await runShadow(w);
|
|
2817
|
+
assert.equal(r.code, "conformance.unimplemented"); assert.equal(r.kind, undefined);
|
|
2818
|
+
assert.doesNotMatch(builders(w)[2][4], /no status row/);
|
|
2819
|
+
assert.match(builders(w)[2][4], /does not conform/);
|
|
2820
|
+
});
|
|
2821
|
+
});
|
|
2822
|
+
|
|
2858
2823
|
it("#5732 a head that failed on an absent interpreter is env.repro_unrunnable with its output, no builder resume", async () => {
|
|
2859
2824
|
const w = rworld([{ base: "SKIPPED", head: "FAILED" }]);
|
|
2860
2825
|
w.io.runCommand = async () => ({ rc: 1, output: "Creating virtualenv\npoetry env use: python3.11 not found" });
|
|
2861
|
-
const r = await run(w, { conformance: "enforce" });
|
|
2826
|
+
const r = await run(w, { ...ENF, conformance: "enforce" });
|
|
2862
2827
|
assert.equal(r.code, "env.repro_unrunnable"); assert.equal(w.merges.length, 0);
|
|
2863
2828
|
assert.equal(builders(w).length, 2, "plan + implement only");
|
|
2864
2829
|
assert.match(nh(w), /output tail/); assert.match(nh(w), /python3\.11 not found/);
|
|
@@ -2907,7 +2872,7 @@ describe("bug lanes freeze a red-green repro_test (#4271)", () => {
|
|
|
2907
2872
|
for (const conformance of ["enforce", "shadow"]) {
|
|
2908
2873
|
for (const rg of [{ base: "SKIPPED", head: "UNRUNNABLE" }, null]) {
|
|
2909
2874
|
const w = rworld([rg]);
|
|
2910
|
-
const r = await run(w, { conformance });
|
|
2875
|
+
const r = await run(w, { ...ENF, conformance });
|
|
2911
2876
|
assert.equal(r.code, "env.repro_unrunnable", `${conformance} ${JSON.stringify(rg)}`); assert.equal(r.terminalReason, "needs-human");
|
|
2912
2877
|
assert.equal(classifyNeedsHuman(r), "recoverable");
|
|
2913
2878
|
assert.equal(w.merges.length, 0); assert.equal(builders(w).length, 2, "plan + implement, no resume"); assert.equal(reviewers(w).length, 0);
|
|
@@ -3177,17 +3142,17 @@ describe("comment templates", () => {
|
|
|
3177
3142
|
|
|
3178
3143
|
it("#5644 review findings get up to 3 builder resume rounds: replay of a fixable finding that clears in round 3 merges", async () => {
|
|
3179
3144
|
const w = world({ reviews: [bad("round 1"), bad("round 2"), conf()] });
|
|
3180
|
-
const r = await run(w);
|
|
3145
|
+
const r = await run(w, ENF);
|
|
3181
3146
|
assert.equal(r.terminalReason, "merged"); assert.equal(builders(w).length, 4, "build plus two resume rounds");
|
|
3182
3147
|
});
|
|
3183
3148
|
|
|
3184
3149
|
it("#5644 rounds are spent: a changing but never fixed finding ends needs-human after reviewMaxResumes rounds; an unchanged one stops early", async () => {
|
|
3185
3150
|
const w = world({ reviews: [bad("a"), bad("b"), bad("c"), bad("d")] });
|
|
3186
|
-
const r = await run(w);
|
|
3151
|
+
const r = await run(w, ENF);
|
|
3187
3152
|
assert.equal(r.terminalReason, "needs-human"); assert.equal(builders(w).length, 5);
|
|
3188
3153
|
assert.match(traj(w)[0], /after 3 builder resumes/);
|
|
3189
3154
|
const w2 = world({ reviews: [bad("a"), bad("b"), bad("c")] });
|
|
3190
|
-
assert.equal((await run(w2, { reviewMaxResumes: 1 })).terminalReason, "needs-human"); assert.equal(builders(w2).length, 3);
|
|
3155
|
+
assert.equal((await run(w2, { ...ENF, reviewMaxResumes: 1 })).terminalReason, "needs-human"); assert.equal(builders(w2).length, 3);
|
|
3191
3156
|
});
|
|
3192
3157
|
|
|
3193
3158
|
it("#5644 builderFixable: regression, deferral, scope are fixable; environment and empty sets are not", () => {
|
|
@@ -3198,7 +3163,7 @@ describe("comment templates", () => {
|
|
|
3198
3163
|
|
|
3199
3164
|
it("a merged run's trajectory and a needs-human run's trajectory carry the right rows", async () => {
|
|
3200
3165
|
const w = world({ reviews: [bad(), bad("still bad")] });
|
|
3201
|
-
await run(w, { reviewMaxResumes: 1 });
|
|
3166
|
+
await run(w, { ...ENF, reviewMaxResumes: 1 });
|
|
3202
3167
|
const t = traj(w)[0];
|
|
3203
3168
|
assert.match(t, /\| Validate \| CONFIRMED \|/);
|
|
3204
3169
|
assert.match(t, /\| Plan \| contract [0-9a-f]{12} \| 1 requirement\(s\) \|/);
|
|
@@ -4237,6 +4202,16 @@ describe("base-sync (#4100)", () => {
|
|
|
4237
4202
|
noRebaseNoForce(w);
|
|
4238
4203
|
});
|
|
4239
4204
|
|
|
4205
|
+
it("#5898 a failed FORGE:BASE_SYNC comment after a resolved base-sync is an anomaly, not an engine-error: the lane merges", async () => {
|
|
4206
|
+
const w = world({ prView: [CONFLICTING, OKSTATE], mergeResults: ["conflict"], reviews: [ok(), ok()] });
|
|
4207
|
+
const post = w.io.gh;
|
|
4208
|
+
w.io.gh = async (a) => (a[0] === "issue" && a[1] === "comment" && a[a.indexOf("--body") + 1].includes("FORGE:BASE_SYNC") ? Promise.reject(new Error("HTTP 502: unexpected EOF")) : post(a));
|
|
4209
|
+
const r = await run(w);
|
|
4210
|
+
assert.equal(r.terminalReason, "merged");
|
|
4211
|
+
assert.equal(w.merges.length, 1);
|
|
4212
|
+
assert.match(traj(w).join("\n"), /FORGE:BASE_SYNC comment not posted: HTTP 502/);
|
|
4213
|
+
});
|
|
4214
|
+
|
|
4240
4215
|
it("#5583 follow-up: a builder-resolved base-sync with only documentation conflicts and an unchanged code diff skips the re-review", async () => {
|
|
4241
4216
|
const w = world({ prView: [CONFLICTING, OKSTATE], mergeResults: ["conflict"], conflictFiles: ["devdocs/modules/lean.md"], reviews: [ok(), ok()] });
|
|
4242
4217
|
const git = w.io.git;
|
|
@@ -4265,7 +4240,7 @@ describe("base-sync (#4100)", () => {
|
|
|
4265
4240
|
|
|
4266
4241
|
it("conflict resolution that the re-review FAILs gets one retry then merges on PASS", async () => {
|
|
4267
4242
|
const w = world({ prView: [CONFLICTING, OKSTATE], mergeResults: ["conflict"], reviews: [ok(), bad("src/foo.js:4 lost base change"), ok()] });
|
|
4268
|
-
assert.equal((await run(w)).terminalReason, "merged");
|
|
4243
|
+
assert.equal((await run(w, ENF)).terminalReason, "merged");
|
|
4269
4244
|
assert.equal(reviewers(w).length, 3);
|
|
4270
4245
|
assert.equal(builders(w).length, 4);
|
|
4271
4246
|
});
|
|
@@ -4559,6 +4534,33 @@ describe("usage limit, lease takeover, worktree setup, run tmp (#4101-#4104)", (
|
|
|
4559
4534
|
assert.equal(r.account, "3");
|
|
4560
4535
|
});
|
|
4561
4536
|
|
|
4537
|
+
it("#6105 a builder session ended api_error is resumed by id with backoff; the lane continues and nothing is relaunched", async () => {
|
|
4538
|
+
const w = world(); const sleeps = []; const dir = tmpDir("core-"); const s0 = w.io.sleep; w.io.sleep = async (ms) => { sleeps.push(ms); return s0(ms); };
|
|
4539
|
+
const apiErr = Object.assign(new Error("claude CLI exited with status 1"), { code: "CLI_BACKEND_FAILED", apiError: true, cliIsError: true, cliTerminalReason: "api_error", cliSessionId: "sess-api" });
|
|
4540
|
+
const orig = w.io.runner; let n = 0; const sent = [];
|
|
4541
|
+
w.io.runner = async (c) => { if (c.role === "builder") { sent.push({ resume: c.resume ?? null, prompt: c.prompt }); if (++n === 2) throw apiErr; } return orig(c); };
|
|
4542
|
+
const r = await run(w, { dir });
|
|
4543
|
+
assert.equal(r.terminalReason, "merged");
|
|
4544
|
+
const resumed = sent.filter((x) => x.resume === "sess-api");
|
|
4545
|
+
assert.equal(resumed.length, 1, "the failed session is resumed by id");
|
|
4546
|
+
assert.match(resumed[0].prompt, /transient API error/);
|
|
4547
|
+
assert.ok(sleeps.includes(20_000), "backoff before the resume");
|
|
4548
|
+
const log = readLog(dir, 7);
|
|
4549
|
+
assert.equal(log.filter((e) => e.event === "API_ERROR_RESUME").length, 1);
|
|
4550
|
+
assert.equal(log.find((e) => e.event === "RUN_TERMINAL").api_resumes, 1, "resumes are counted apart from relaunches");
|
|
4551
|
+
});
|
|
4552
|
+
|
|
4553
|
+
it("#6105 an api_error that keeps recurring defers backend.cli_failed after the capped resumes (never engine-error)", async () => {
|
|
4554
|
+
const w = world(); projector(w, null);
|
|
4555
|
+
const apiErr = () => Object.assign(new Error("claude CLI exited with status 1"), { code: "CLI_BACKEND_FAILED", apiError: true, cliIsError: true, cliTerminalReason: "api_error", cliSessionId: "sess-api" });
|
|
4556
|
+
const orig = w.io.runner; let resumes = 0;
|
|
4557
|
+
w.io.runner = async (c) => { if (c.role === "builder") { if (c.resume === "sess-api") resumes++; throw apiErr(); } return orig(c); };
|
|
4558
|
+
const r = await run(w);
|
|
4559
|
+
assert.equal(r.terminalReason, "deferred"); assert.equal(r.code, "backend.cli_failed");
|
|
4560
|
+
assert.equal(resumes, 3, "three resumes, then the deferral");
|
|
4561
|
+
assert.match(r.detail, /transient API error/);
|
|
4562
|
+
});
|
|
4563
|
+
|
|
4562
4564
|
it("#5168 an error that is both a usage limit and auth-like stays rate_limited", async () => {
|
|
4563
4565
|
const w = world();
|
|
4564
4566
|
failFirstBuilder(w, limitErr({ authFailure: true, resetAtEpochMs: 3 * 3600 * 1000, resetAt: "8:30pm" }));
|
|
@@ -4807,7 +4809,7 @@ describe("usage limit, lease takeover, worktree setup, run tmp (#4101-#4104)", (
|
|
|
4807
4809
|
};
|
|
4808
4810
|
for (const [reason, prep] of Object.entries(cases)) {
|
|
4809
4811
|
const w = world(); mk(w); prep(w);
|
|
4810
|
-
const r = await run(w);
|
|
4812
|
+
const r = await run(w, ENF);
|
|
4811
4813
|
assert.equal(r.terminalReason, reason);
|
|
4812
4814
|
assert.equal(w.pruned, true);
|
|
4813
4815
|
assert.equal(w.tmpMade.length, 1);
|
|
@@ -5568,20 +5570,12 @@ describe("batch robustness (#4112-#4115)", () => {
|
|
|
5568
5570
|
const d = tmpDir("lean-5653-"); const src = join(d, "ci.yml"); writeFileSync(src, "run: uv run --with-requirements r.txt pytest tests\n");
|
|
5569
5571
|
const contract = { ...CONTRACT, validate: [...CONTRACT.validate, { id: "V2", command: "poetry run pytest t.py" }] };
|
|
5570
5572
|
const w = world({ contract }); w.io.probeCommand = async (a) => ({ rc: /poetry/.test(JSON.stringify(a)) ? 127 : 0, output: "" });
|
|
5571
|
-
const r = await run(w, { dir: d, validateCatalogSources: [`../..${src}`] });
|
|
5573
|
+
const r = await run(w, { dir: d, validateCatalogSources: [`../..${src.replace(/^[A-Za-z]:/, "").split("\\").join("/")}`] }); // #5753: drive-less posix path on Windows
|
|
5572
5574
|
assert.notEqual(r.code, "env.tool_missing");
|
|
5573
5575
|
assert.ok(w.comments.some((c) => c.includes("FORGE:CONTRACT") && c.includes("uv run --with-requirements r.txt pytest t.py")));
|
|
5574
5576
|
assert.ok(!w.comments.some((c) => c.includes("FORGE:CONTRACT") && c.includes("poetry run pytest")));
|
|
5575
5577
|
});
|
|
5576
5578
|
|
|
5577
|
-
it("#5653 the plan prompt tells the builder to prefer CI commands, record equivalent substitutes and never narrow time or production criteria", async () => {
|
|
5578
|
-
const { unrunnableValidateNote } = await import("./prompts.mjs");
|
|
5579
|
-
const n = unrunnableValidateNote();
|
|
5580
|
-
assert.match(n, /CI-derived command catalogue/);
|
|
5581
|
-
assert.match(n, /same test ids with the same result is recorded/);
|
|
5582
|
-
assert.match(n, /never narrow it/);
|
|
5583
|
-
});
|
|
5584
|
-
|
|
5585
5579
|
// ---- #4112 ----
|
|
5586
5580
|
const fakeCli = async (name, body) => {
|
|
5587
5581
|
const { writeFileSync, chmodSync } = await import("node:fs");
|
|
@@ -5770,6 +5764,23 @@ describe("batch robustness (#4112-#4115)", () => {
|
|
|
5770
5764
|
assert.ok(!w.comments.some((c) => c.includes("FORGE:CONTRACT")), "not re-posted");
|
|
5771
5765
|
assert.match(traj(w)[0], /frozen contract [0-9a-f]{12} recovered from the issue/);
|
|
5772
5766
|
});
|
|
5767
|
+
it("#5920 a reused frozen contract gets the validate.recipes rewrite and an audit amendment, once", async () => {
|
|
5768
|
+
const recipes = [{ match: "^node --test ", replace: "node --test --test-reporter=dot " }];
|
|
5769
|
+
const w = world({ prList: [], remote: "abc\trefs/heads/feat/issue-7-lean", lastSubject: "wip(forge): checkpoint after idle timeout", issueComments: [frozenComment()] });
|
|
5770
|
+
const r = await run(w, { validateRecipes: recipes });
|
|
5771
|
+
assert.equal(r.terminalReason, "merged");
|
|
5772
|
+
assert.match(w.files[`${WT}/.forge-lean/contract.json`], /node --test --test-reporter=dot test\/foo\.test\.js/, "the rewritten command is the one the lane runs");
|
|
5773
|
+
const am = w.comments.filter((c) => c.includes("FORGE:AMENDMENT") && c.includes("rewrite-validate"));
|
|
5774
|
+
assert.equal(am.length, 1);
|
|
5775
|
+
assert.match(am[0], new RegExp(`frozen contract ${contractHash(contractJson(CONTRACT))}`));
|
|
5776
|
+
assert.ok(!am[0].includes("AMENDMENT-STATE"), "audit only: never replayed as an amendment");
|
|
5777
|
+
const w2 = world({ prList: [], remote: "abc\trefs/heads/feat/issue-7-lean", lastSubject: "wip(forge): checkpoint after idle timeout", issueComments: [frozenComment(), { body: am[0], author_association: "OWNER", user: { type: "User", login: "op" } }] });
|
|
5778
|
+
await run(w2, { validateRecipes: recipes });
|
|
5779
|
+
assert.equal(w2.comments.filter((c) => c.includes("rewrite-validate")).length, 0, "a second reuse posts nothing new");
|
|
5780
|
+
const w3 = world({ prList: [], remote: "abc\trefs/heads/feat/issue-7-lean", lastSubject: "wip(forge): checkpoint after idle timeout", issueComments: [frozenComment()] });
|
|
5781
|
+
await run(w3);
|
|
5782
|
+
assert.ok(!w3.comments.some((c) => c.includes("rewrite-validate")), "no recipe, no amendment");
|
|
5783
|
+
});
|
|
5773
5784
|
it("recovery lane replays accepted supersedes amendment (#4899)", async () => {
|
|
5774
5785
|
const sup = { kind: "supersedes", guard: "#4785", why: "behaviour changed on purpose" };
|
|
5775
5786
|
const state = { contract: contractHash(contractJson(CONTRACT)), amendments: [sup] };
|
|
@@ -5847,11 +5858,11 @@ describe("batch robustness (#4112-#4115)", () => {
|
|
|
5847
5858
|
});
|
|
5848
5859
|
it("#5752 a declared outcome-evidence area touched without a before/after result row blocks with a clear reason", async () => {
|
|
5849
5860
|
const w = world({ prList: [] });
|
|
5850
|
-
await run(w, { outcomeEvidenceConfig: { paths: { core: ["src/**"] }, corpus: { core: ["corpus/**"] } } });
|
|
5861
|
+
await run(w, { ...ENF, outcomeEvidenceConfig: { paths: { core: ["src/**"] }, corpus: { core: ["corpus/**"] } } });
|
|
5851
5862
|
assert.ok(builders(w).length >= 2, "the missing evidence resumes the builder");
|
|
5852
5863
|
assert.match(JSON.stringify(w.calls.filter((c) => c[0] === "runner")), /outcome-evidence area 'core'.{0,200}src\/foo\.js.{0,200}no before\/after measurement/);
|
|
5853
5864
|
const off = world({ prList: [] });
|
|
5854
|
-
await run(off);
|
|
5865
|
+
await run(off, ENF);
|
|
5855
5866
|
assert.doesNotMatch(JSON.stringify([off.comments, off.calls.filter((c) => c[0] === "runner")]), /outcome_evidence_missing|outcome-evidence area/, "no outcome_evidence config: no new check");
|
|
5856
5867
|
});
|
|
5857
5868
|
it("#5752 the builder prompt carries the negative-examples rule and the mechanism supersedes amendment", async () => {
|
|
@@ -6265,14 +6276,14 @@ describe("verify-by-CI (#4167): ci mode runs the heavy checks on CI and feeds fa
|
|
|
6265
6276
|
|
|
6266
6277
|
it("without the fix, a validate id left to CI is missing under enforce (the regression this guards)", async () => {
|
|
6267
6278
|
const w = world({ validation: ciValidation });
|
|
6268
|
-
const r = await run(w);
|
|
6279
|
+
const r = await run(w, ENF);
|
|
6269
6280
|
assert.equal(r.terminalReason, "needs-human"); assert.equal(w.merges.length, 0);
|
|
6270
6281
|
});
|
|
6271
6282
|
|
|
6272
6283
|
it("#4527 base-sync re-review FAIL: the fix round's head is CI-verified before the retry review, which accepts validates left to CI and notes them", async () => {
|
|
6273
6284
|
const CONFLICTING = { mergeable: "CONFLICTING", mergeStateStatus: "DIRTY" }, OKSTATE = { mergeable: "MERGEABLE", mergeStateStatus: "CLEAN" };
|
|
6274
6285
|
const w = withCi(world({ validation: ciValidation, prView: [CONFLICTING, OKSTATE], mergeResults: ["conflict"], reviews: [ok(), bad("src/foo.js:4 lost base change"), ok()] }));
|
|
6275
|
-
const r = await run(w, { verify: CI });
|
|
6286
|
+
const r = await run(w, { ...ENF, verify: CI });
|
|
6276
6287
|
assert.equal(r.terminalReason, "merged", r.reason);
|
|
6277
6288
|
assert.equal(reviewers(w).length, 3);
|
|
6278
6289
|
assert.equal(new Set(w.ci.runs.map((x) => x.headSha)).size, w.ci.runs.length, "every reviewed head was verified once");
|
|
@@ -6961,7 +6972,7 @@ describe("local-mode CI fix rounds at merge and declared pre-PR check commands (
|
|
|
6961
6972
|
it("pre-PR: declared commands run in the lane worktree; a failing one goes back to the builder before PR_OPENED", async () => {
|
|
6962
6973
|
const w = world(); const ran = [];
|
|
6963
6974
|
let rc = 1;
|
|
6964
|
-
w.io.runCommand = async ({ command, cwd, timeoutMs }) => { ran.push([command, cwd, timeoutMs]); w.seq.push(`check:${rc}`); const r = { rc, output: "check-test-tmp-cleanup: mkdtempSync in
|
|
6975
|
+
w.io.runCommand = async ({ command, cwd, timeoutMs }) => { ran.push([command, cwd, timeoutMs]); w.seq.push(`check:${rc}`); const r = { rc, output: "check-test-tmp-cleanup: mkdtempSync in test/foo.test.js" }; return r; };
|
|
6965
6976
|
const inner = w.io.runner;
|
|
6966
6977
|
w.io.runner = async (c) => { if (/declared check commands failed/.test(c.prompt)) rc = 0; return inner(c); };
|
|
6967
6978
|
const dir = tmpDir("core-");
|
|
@@ -6970,7 +6981,7 @@ describe("local-mode CI fix rounds at merge and declared pre-PR check commands (
|
|
|
6970
6981
|
assert.deepEqual(ran.map((x) => x.slice(0, 2)), [["bash scripts/check-test-tmp-cleanup.sh", WT], ["bash scripts/check-test-tmp-cleanup.sh", WT]]);
|
|
6971
6982
|
assert.equal(ran[0][2], 300000);
|
|
6972
6983
|
const fix = builders(w).filter((b) => /declared check commands failed/.test(b[4]));
|
|
6973
|
-
assert.equal(fix.length, 1); assert.equal(fix[0][2], null); assert.match(fix[0][4], /mkdtempSync in
|
|
6984
|
+
assert.equal(fix.length, 1); assert.equal(fix[0][2], null); assert.match(fix[0][4], /mkdtempSync in test\/foo\.test\.js/); assert.match(fix[0][4], /exit 1/);
|
|
6974
6985
|
assert.ok(w.seq.indexOf("builder", w.seq.indexOf("check:1")) < w.seq.indexOf("pr"), "the fix runs before the PR is opened");
|
|
6975
6986
|
const log = readLog(dir, 7);
|
|
6976
6987
|
const pre = log.filter((e) => e.event === "PRECHECK_COMMANDS");
|
|
@@ -7058,6 +7069,28 @@ describe("local-mode CI fix rounds at merge and declared pre-PR check commands (
|
|
|
7058
7069
|
assert.equal(builders(w).length, 2, "no builder fix round spent on a base failure");
|
|
7059
7070
|
});
|
|
7060
7071
|
|
|
7072
|
+
it("#5913 a lane whose diff touches the failing guard's files and makes it pass on the lane tree is not deferred on base.red", async () => {
|
|
7073
|
+
const w = world({ changed: ["app/routers/listing_feeds.py", "test/foo.test.js"] }); let laneRuns = 0;
|
|
7074
|
+
w.io.runCommand = async ({ cwd }) => (/basered-/.test(cwd) ? { rc: 1, output: "bare 429 at app/routers/listing_feeds.py" } : ++laneRuns === 1 ? { rc: 1, output: "bare 429 at app/routers/listing_feeds.py" } : { rc: 0, output: "" });
|
|
7075
|
+
const r = await run(w, { verify: { invariants: ["bash scripts/guard.sh"] } });
|
|
7076
|
+
assert.notEqual(r.code, "base.red"); assert.ok(laneRuns >= 2, "the guard was re-run on the lane tree");
|
|
7077
|
+
});
|
|
7078
|
+
|
|
7079
|
+
it("#5913 a lane that touches the guard's files but still fails it is deferred on base.red and names the owner escape", async () => {
|
|
7080
|
+
const w = world({ changed: ["app/routers/listing_feeds.py"] });
|
|
7081
|
+
w.io.runCommand = async () => ({ rc: 1, output: "bare 429 at app/routers/listing_feeds.py" });
|
|
7082
|
+
const r = await run(w, { verify: { invariants: ["bash scripts/guard.sh"] } });
|
|
7083
|
+
assert.equal(r.code, "base.red"); assert.equal(w.merges.length, 0);
|
|
7084
|
+
assert.match(JSON.stringify(r), /--owner-requested/);
|
|
7085
|
+
});
|
|
7086
|
+
|
|
7087
|
+
it("#5913 diffTouchesGuard is true only when a changed file is named by the failing guard", () => {
|
|
7088
|
+
const failed = [{ command: "bash scripts/guard.sh", output: "bare 429 at app/routers/listing_feeds.py" }];
|
|
7089
|
+
assert.equal(diffTouchesGuard({ changed: ["./app/routers/listing_feeds.py"], failed }), true);
|
|
7090
|
+
assert.equal(diffTouchesGuard({ changed: ["src/foo.js"], failed }), false);
|
|
7091
|
+
assert.equal(diffTouchesGuard({ changed: [], failed }), false);
|
|
7092
|
+
});
|
|
7093
|
+
|
|
7061
7094
|
it("#5945 an env-signature base failure is not base.red and files nothing; a host verify pass skips filing", async () => {
|
|
7062
7095
|
for (const hook of [false, true]) {
|
|
7063
7096
|
const w = world(); const filed = [], gh = w.io.gh;
|
|
@@ -7640,12 +7673,12 @@ describe("context pack modes (forge#4275)", () => {
|
|
|
7640
7673
|
it("write-back: the terminal FORGE:STATE carries the typed outcome code and failure classes the compiler reads", async () => {
|
|
7641
7674
|
const w = world({ reviews: [bad(), bad()] });
|
|
7642
7675
|
w.leaseWrites = []; w.io.projector = { readState: async () => null, writeState: async (_i, st) => { w.leaseWrites.push(st); } };
|
|
7643
|
-
const r = await run(w);
|
|
7676
|
+
const r = await run(w, ENF);
|
|
7644
7677
|
assert.equal(r.terminalReason, "needs-human");
|
|
7645
7678
|
const last = w.leaseWrites.at(-1);
|
|
7646
7679
|
assert.deepEqual([last.terminal, last.terminalReason, last.terminalCode, last.failureClasses], [true, "needs-human", OUTCOME_CODES.CONFORMANCE_UNIMPLEMENTED, [OUTCOME_CODES.CONFORMANCE_UNIMPLEMENTED]]);
|
|
7647
7680
|
const m = world(); m.leaseWrites = []; m.io.projector = { readState: async () => null, writeState: async (_i, st) => { m.leaseWrites.push(st); } };
|
|
7648
|
-
await run(m);
|
|
7681
|
+
await run(m, ENF);
|
|
7649
7682
|
assert.deepEqual([m.leaseWrites.at(-1).terminalCode, m.leaseWrites.at(-1).failureClasses], [OUTCOME_CODES.COMPLETED, []]);
|
|
7650
7683
|
});
|
|
7651
7684
|
|
|
@@ -8121,15 +8154,15 @@ describe("#4363 fresh fix sessions", () => {
|
|
|
8121
8154
|
|
|
8122
8155
|
it("a conformance FAIL citing file:line is fresh; one without a file:line resumes; the one review retry is unchanged", async () => {
|
|
8123
8156
|
const w1 = world({ reviews: [bad("src/foo.js:9 still wrong"), ok()] }); const d1 = tmpDir("core-");
|
|
8124
|
-
assert.equal((await run(w1, { dir: d1 })).terminalReason, "merged");
|
|
8157
|
+
assert.equal((await run(w1, { ...ENF, dir: d1 })).terminalReason, "merged");
|
|
8125
8158
|
assert.deepEqual(usage(d1).map((e) => e.mode ?? null), [null, null, "fresh"]);
|
|
8126
8159
|
const vague = conf({ verdict: "NONCONFORMING", requirements: [{ id: "R1", status: "partial", evidence: "the foo module", validated_by: "V1", note: "null still throws" }] });
|
|
8127
8160
|
const w2 = world({ reviews: [vague, ok()] }); const d2 = tmpDir("core-");
|
|
8128
|
-
assert.equal((await run(w2, { dir: d2 })).terminalReason, "merged");
|
|
8161
|
+
assert.equal((await run(w2, { ...ENF, dir: d2 })).terminalReason, "merged");
|
|
8129
8162
|
assert.equal(builders(w2)[2][2], "sess-1");
|
|
8130
8163
|
assert.deepEqual(usage(d2).map((e) => e.mode ?? null), [null, null, "resume"]);
|
|
8131
8164
|
const w3 = world({ reviews: [bad(), bad(), bad()] });
|
|
8132
|
-
const r3 = await run(w3);
|
|
8165
|
+
const r3 = await run(w3, ENF);
|
|
8133
8166
|
assert.equal(r3.terminalReason, "needs-human"); assert.equal(reviewers(w3).length, 2, "still one review retry");
|
|
8134
8167
|
});
|
|
8135
8168
|
});
|
|
@@ -8868,14 +8901,14 @@ describe("#4394 builder model routing", () => {
|
|
|
8868
8901
|
|
|
8869
8902
|
it("a conformance fix round on the mid tier does not escalate and keeps the fix model", async () => {
|
|
8870
8903
|
const w = world({ reviews: [bad("src/foo.js:9 still wrong"), ok()] }); const dir = tmpDir("core-");
|
|
8871
|
-
assert.equal((await run(w, { dir, builderModel: "opus-b", fixModel: "haiku-fix" })).terminalReason, "merged");
|
|
8904
|
+
assert.equal((await run(w, { ...ENF, dir, builderModel: "opus-b", fixModel: "haiku-fix" })).terminalReason, "merged");
|
|
8872
8905
|
assert.equal(builders(w)[2][3], "haiku-fix");
|
|
8873
8906
|
assert.deepEqual(events(dir, "BUILDER_ESCALATED"), []);
|
|
8874
8907
|
});
|
|
8875
8908
|
|
|
8876
8909
|
it("builder_routing off: plan, build and the resume keep builderModel; the class is still recorded on the top tier", async () => { // #5810: the pre-route is top too
|
|
8877
8910
|
const w = world({ reviews: [conf({ verdict: "NONCONFORMING", requirements: [{ id: "R1", status: "partial", evidence: "the foo module", validated_by: "V1", note: "x" }] }), ok()] }); const dir = tmpDir("core-");
|
|
8878
|
-
await run(w, { dir, builderModel: "opus-b", builderRouting: { mode: "off" } });
|
|
8911
|
+
await run(w, { ...ENF, dir, builderModel: "opus-b", builderRouting: { mode: "off" } });
|
|
8879
8912
|
assert.ok(builders(w).length >= 3);
|
|
8880
8913
|
assert.ok(builders(w).every((b) => b[3] === "opus-b"));
|
|
8881
8914
|
const term = events(dir, "RUN_TERMINAL").at(-1);
|
|
@@ -9121,28 +9154,6 @@ describe("#4450 light lane: one builder session, derived contract, upgrade to th
|
|
|
9121
9154
|
const events = (dir, name) => readLog(dir, 7).filter((e) => e.event === name);
|
|
9122
9155
|
const ON = { light: { mode: "on", source: "text" } };
|
|
9123
9156
|
|
|
9124
|
-
it("#5751 recurrence: an issue matching two earlier merged fixes on its path skips the light lane, gets the design note and records the reason", async () => {
|
|
9125
|
-
const DESIGN = { why_failed: "#10 and #11 guarded one caller each", disposition: "replace", outcome: { metric: "null-input crashes in foo tests", target: "0" } };
|
|
9126
|
-
const ghApi = (a) => {
|
|
9127
|
-
const j = a.join(" ");
|
|
9128
|
-
if (j.includes("search/issues")) return [10, 11].map((n) => JSON.stringify({ number: n, title: `fix foo null ${n} ERR_NULL_INPUT`, pr: true, merged: true })).join("\n"); // #5979: a symptom match (the issue's backticked signature), not only the path
|
|
9129
|
-
if (/pulls\/1[01]\/files/.test(j)) return "src/foo.js\n";
|
|
9130
|
-
return null;
|
|
9131
|
-
};
|
|
9132
|
-
const w = lworld({ ghApi, body: `${BODY}\n\nThrows \`ERR_NULL_INPUT\`. Recurs #10`, contract: { ...CONTRACT, test_plan: TEST_PLAN, repro_test: RT, design: DESIGN } }), dir = tmpDir("light-");
|
|
9133
|
-
await run(w, { dir, ...ON });
|
|
9134
|
-
const rec = events(dir, "RECURRENCE");
|
|
9135
|
-
assert.equal(rec.length, 1);
|
|
9136
|
-
assert.deepEqual(rec[0].fixes.sort(), [10, 11]);
|
|
9137
|
-
assert.match(rec[0].reason, /^recurrence: 2 earlier merged fix\(es\) on the same symptom and area/);
|
|
9138
|
-
assert.equal(events(dir, "LIGHT_DONE").length, 0, "a recurrence never takes the light lane");
|
|
9139
|
-
const plan = builders(w).find((c) => /PLANNING ONLY/.test(c[4]));
|
|
9140
|
-
assert.ok(plan, "the full lane's plan session ran");
|
|
9141
|
-
assert.match(plan[4], /DESIGN LANE \(#5751\)/);
|
|
9142
|
-
assert.match(plan[4], /#10 fix foo null 10 ERR_NULL_INPUT/);
|
|
9143
|
-
assert.ok(w.comments.some((c) => c.includes("<!-- FORGE:RECURRENCE -->") && /Routed to a design lane: recurrence: 2/.test(c)), "the reason is posted on the issue");
|
|
9144
|
-
assert.ok(!readLog(dir, 7).some((e) => JSON.stringify(e).includes("design_missing")), "a contract with a design block passes the design check");
|
|
9145
|
-
});
|
|
9146
9157
|
|
|
9147
9158
|
it("#5751 recurrence: no matching history keeps the light lane and the plan prompt unchanged", async () => {
|
|
9148
9159
|
const w = lworld(), dir = tmpDir("light-");
|
|
@@ -9492,7 +9503,7 @@ describe("#5237 relaxation gate", () => {
|
|
|
9492
9503
|
};
|
|
9493
9504
|
it("relaxation without a negative test blocks (relaxation_untested) in a risk path", async () => {
|
|
9494
9505
|
const w = withV(world({ contract: { ...CONTRACT, preserve: [] }, reviews: [conf(), conf(), conf()] })); w.diffText = rescue;
|
|
9495
|
-
const r = await run(w, { dir: tmpDir("relax-"), reviewTrigger: { mode: "shadow", riskPaths: ["src/**"] } });
|
|
9506
|
+
const r = await run(w, { ...ENF, dir: tmpDir("relax-"), reviewTrigger: { mode: "shadow", riskPaths: ["src/**"] } });
|
|
9496
9507
|
assert.equal(w.merges.length, 0); assert.equal(r.code, "conformance.unimplemented");
|
|
9497
9508
|
});
|
|
9498
9509
|
it("a negative test lets it through, and the verifier runs even with review.verifier off, fed the hunk", async () => {
|
|
@@ -9903,22 +9914,6 @@ describe("spec-only page gate failures end design.spec_required (#5729)", () =>
|
|
|
9903
9914
|
const pagesConfig = { ...parsePagesConfig(undefined, { hasAppPages: true }), require: ["design"] };
|
|
9904
9915
|
const link = (h, x = "") => `<Link href="${h}"${x}>Book a demo</Link>`;
|
|
9905
9916
|
const mk = (diff) => { const w = world({ contract: pc, changed: [PAGE, "test/foo.test.js"], reviews: [conf({}, pc, [PAGE, "test/foo.test.js"])] }); w.diffText = `+++ b/${PAGE}\n${diff}`; return w; };
|
|
9906
|
-
it("spec-only precheck failures end design.spec_required with no resume for 5729", async () => {
|
|
9907
|
-
const w = mk(`-${link("/contact")}\n+${link("/contact")}<Badge />\n`), r = await run(w, { pagesConfig });
|
|
9908
|
-
assert.equal(r.terminalReason, "needs-human");
|
|
9909
|
-
assert.equal(r.code, OUTCOME_CODES.DESIGN_SPEC_REQUIRED);
|
|
9910
|
-
assert.ok(w.comments.some((c) => c.includes("FORGE:NEEDS_HUMAN") && /recovery lane was spent/.test(c)));
|
|
9911
|
-
assert.ok(!builders(w).some((c) => /resume|conformance\.unimplemented/i.test(c[4] ?? "")), "no builder resume");
|
|
9912
|
-
assert.equal(classifyNeedsHuman({ outcome: "needs-human", code: r.code }), "terminal", "no recovery lane");
|
|
9913
|
-
});
|
|
9914
|
-
it("replay of #40917 spends no resume or recovery for 5729", async () => {
|
|
9915
|
-
const w = mk(`-${link("https://calendly.com/x", ' target="_self"')}\n+${link("/contact", ' target="_blank"')}\n`), r = await run(w, { pagesConfig });
|
|
9916
|
-
assert.equal(r.code, OUTCOME_CODES.DESIGN_SPEC_REQUIRED); // only the screenshot row is left, and it is terminal too
|
|
9917
|
-
const note = w.comments.find((c) => c.includes("FORGE:NEEDS_HUMAN")) ?? "";
|
|
9918
|
-
assert.ok(!/is a public page but the issue has no approved/.test(note), "no spec row for a copy edit");
|
|
9919
|
-
assert.match(note, /visual check/);
|
|
9920
|
-
assert.ok(!builders(w).some((c) => /conformance\.unimplemented/i.test(c[4] ?? "")), "no builder resume");
|
|
9921
|
-
});
|
|
9922
9917
|
});
|
|
9923
9918
|
|
|
9924
9919
|
describe("classification record in the plan prompt (#5557)", () => {
|
|
@@ -10152,6 +10147,30 @@ describe("#5820 required CI checks run in the lane before the PR opens", () => {
|
|
|
10152
10147
|
assert.match(p2.unrunnable[0].reason, /CI check plan unavailable: yq not found/);
|
|
10153
10148
|
});
|
|
10154
10149
|
|
|
10150
|
+
it("#6049 a release-only required formatter fails the precheck before the PR; a required context with no job is a parity gap filed once", async () => {
|
|
10151
|
+
const fmt = ciJob("fmt", "Format check", "black --check .");
|
|
10152
|
+
const plan = { version: 1, repo: WT, jobs: [ciJob("lint", "Lint", "pnpm lint"), fmt] };
|
|
10153
|
+
let broken = true; const asked = [];
|
|
10154
|
+
const w = ciWorld({ plan: async (a) => { asked.push(a.releaseBranch ?? ""); return plan; }, ciRun: (c) => (broken ? { rc: 1, output: "would reformat a.py\nCI_LOCAL_FAIL: gha:ci:fmt | step: black --check . | exit 1" } : { rc: 0, output: "CI_LOCAL_RESULT: PASS" }) });
|
|
10155
|
+
const byBranch = []; w.io.requiredChecks = async (b) => { byBranch.push(b); return b === "main" ? ["Format check", "Wiring audit"] : ["Lint"]; };
|
|
10156
|
+
const inner = w.io.runner;
|
|
10157
|
+
w.io.runner = async (c) => { if (/declared check commands failed/.test(c.prompt)) broken = false; return inner(c); };
|
|
10158
|
+
const issues = []; const gh = w.io.gh;
|
|
10159
|
+
w.io.gh = async (args, ...x) => { if (args[0] === "issue" && args[1] === "list") return JSON.stringify(issues.map((i) => ({ ...i, number: 77, state: "OPEN", body: i.body }))); if (args[0] === "issue" && args[1] === "create") { issues.push({ body: args[args.indexOf("--body") + 1] }); return "https://github.com/o/r/issues/77"; } return gh(args, ...x); };
|
|
10160
|
+
const dir = tmpDir("core-");
|
|
10161
|
+
await run(w, { dir });
|
|
10162
|
+
assert.ok(byBranch.includes("main"), `the release branch's required checks are read (read: ${byBranch})`);
|
|
10163
|
+
const log = readLog(dir, 7);
|
|
10164
|
+
const p = log.find((e) => e.event === "CI_PRECHECK_PLAN");
|
|
10165
|
+
assert.ok(p.commands.some((c) => c.job === "gha:ci:fmt" && /on release branch/.test(c.why)));
|
|
10166
|
+
assert.ok(log.filter((e) => e.event === "CI_PRECHECK_RESULT")[0].results.some((x) => x.status === "fail"));
|
|
10167
|
+
assert.ok(w.seq.indexOf("ci-precheck") < w.seq.indexOf("pr"));
|
|
10168
|
+
const par = log.filter((e) => e.event === "CI_PRECHECK_PARITY");
|
|
10169
|
+
assert.deepEqual(par[0].gaps.map((g) => g.context), ["Wiring audit"]);
|
|
10170
|
+
assert.equal(issues.length, 1, "one issue per gap, not re-filed on the fix round");
|
|
10171
|
+
assert.match(issues[0].body, /FORGE:PARITY_GAP Wiring audit/);
|
|
10172
|
+
});
|
|
10173
|
+
|
|
10155
10174
|
it("lean.ci_precheck off runs nothing and logs no plan", async () => {
|
|
10156
10175
|
const w = ciWorld(); const dir = tmpDir("core-");
|
|
10157
10176
|
await run(w, { dir, precheck: { ci: { mode: "off", include: [], exclude: [], maxJobs: 8 } } });
|
|
@@ -10160,6 +10179,182 @@ describe("#5820 required CI checks run in the lane before the PR opens", () => {
|
|
|
10160
10179
|
});
|
|
10161
10180
|
});
|
|
10162
10181
|
|
|
10182
|
+
describe("#5749 freeze-time runnability: host-only commands, recipes, check tails", () => {
|
|
10183
|
+
const remote = { placement: { where: "remote", reason: "mode remote" } };
|
|
10184
|
+
const V2 = (command) => ({ ...CONTRACT, validate: [...CONTRACT.validate, { id: "V2", command }] });
|
|
10185
|
+
it("#5749 host-only validate is rejected at freeze", async () => {
|
|
10186
|
+
const w = world({ contract: V2(`legion-run bash -lc 'for i in $(seq $(nproc)); do (timeout 300 sh -c "while :; do :; done") & done; npx vitest run'`) });
|
|
10187
|
+
const r = await run(w, { dir: tmpDir("lean-5749a-"), ...remote });
|
|
10188
|
+
assert.equal(r.code, "contract.invalid"); assert.equal(w.merges.length, 0);
|
|
10189
|
+
assert.ok(builders(w).some((b) => /legion-run/.test(b[4])), "the correction prompt names the host-only wrapper");
|
|
10190
|
+
assert.equal((await run(world({ contract: V2("npx vitest run a.test.ts") }), { dir: tmpDir("lean-5749a2-"), ...remote })).terminalReason, "merged");
|
|
10191
|
+
});
|
|
10192
|
+
it("#5749 remote probe installs a recipe tool or re-places before the builder", async () => {
|
|
10193
|
+
const installed = []; let ok = false;
|
|
10194
|
+
const w = world({ contract: V2("shellcheck scripts/x.sh") });
|
|
10195
|
+
w.io.runCommand = async ({ command }) => { if (/apt-get/.test(command)) { installed.push(command); ok = true; } return { rc: 0, output: "" }; };
|
|
10196
|
+
w.io.probeCommand = async (a) => ({ rc: /shellcheck/.test(JSON.stringify(a)) && !ok ? 127 : 0, output: "" });
|
|
10197
|
+
assert.notEqual((await run(w, { dir: tmpDir("lean-5749b-"), ...remote })).code, "env.tool_missing");
|
|
10198
|
+
assert.equal(installed.length, 1);
|
|
10199
|
+
const n = world({ contract: V2("nopetool-5749 x") }); n.io.probeCommand = async (a) => ({ rc: /nopetool-5749/.test(JSON.stringify(a)) ? 127 : 0, output: "" });
|
|
10200
|
+
const r = await run(n, { dir: tmpDir("lean-5749b2-"), ...remote });
|
|
10201
|
+
assert.equal(r.code, "env.tool_missing");
|
|
10202
|
+
});
|
|
10203
|
+
it("#5749 remote lane with every tool keeps remote placement", async () => {
|
|
10204
|
+
const w = world({ contract: V2("shellcheck scripts/x.sh") }); w.io.probeCommand = async () => ({ rc: 0, output: "" });
|
|
10205
|
+
const installs = []; w.io.runCommand = async ({ command }) => { installs.push(command); return { rc: 0, output: "" }; };
|
|
10206
|
+
const r = await run(w, { dir: tmpDir("lean-5749c-"), ...remote });
|
|
10207
|
+
assert.equal(r.terminalReason, "merged"); assert.ok(!installs.some((c) => /apt-get/.test(c)));
|
|
10208
|
+
});
|
|
10209
|
+
it("#6106 a check that fails on a pass-through wrapper with no real binary is env.tool_missing after one dependency preparation, not ci.red", async () => {
|
|
10210
|
+
const w = world(); const prepared = [];
|
|
10211
|
+
w.io.deps = { prepare: async () => { prepared.push(1); return []; } };
|
|
10212
|
+
w.io.runCommand = async () => ({ rc: 127, output: "forgedock heavy: eslint at /w/web/node_modules/.bin/eslint is a PATH pass-through wrapper with no real binary behind it" });
|
|
10213
|
+
const r = await atIdleLoad(() => run(w, { precheck: { commands: ["make lint"] }, verify: { ...parseVerify({}), precheckBlock: true } }));
|
|
10214
|
+
assert.equal(r.code, "env.tool_missing"); assert.equal(r.terminalReason, "needs-human");
|
|
10215
|
+
assert.ok(prepared.length >= 2, "deps prepared at setup and once more after the missing tool");
|
|
10216
|
+
assert.equal(builders(w).filter((b) => /declared check commands failed/.test(b[4])).length, 0, "no builder resume");
|
|
10217
|
+
});
|
|
10218
|
+
it("#6094 a check that fails in a test file the diff does not touch is rerun once: green on rerun is no fix round; red twice stays ci.red", async () => {
|
|
10219
|
+
const out = "not ok 3 - ten concurrent\n location: '/w/bin/tests/mirror-script.test.mjs:48:3'";
|
|
10220
|
+
const w = world(); let n = 0;
|
|
10221
|
+
w.io.runCommand = async () => (++n === 1 ? { rc: 1, output: out } : { rc: 0, output: "" });
|
|
10222
|
+
const r = await atIdleLoad(() => run(w, { precheck: { commands: ["make test"] }, verify: { ...parseVerify({}), precheckBlock: true } }));
|
|
10223
|
+
assert.equal(r.terminalReason, "merged"); assert.equal(n, 2);
|
|
10224
|
+
assert.equal(builders(w).filter((b) => /declared check commands failed/.test(b[4])).length, 0);
|
|
10225
|
+
const w2 = world(), dir2 = tmpDir("lean-6094-");
|
|
10226
|
+
w2.io.runCommand = async () => ({ rc: 1, output: out });
|
|
10227
|
+
const r2 = await atIdleLoad(() => run(w2, { dir: dir2, precheck: { commands: ["make test"] }, verify: { ...parseVerify({}), precheckBlock: true } }));
|
|
10228
|
+
assert.equal(r2.code, "ci.red"); assert.equal(readLog(dir2, 7).filter((e) => e.event === "PRECHECK_FLAKE_RERUN").length, 1, "exactly one rerun");
|
|
10229
|
+
const w3 = world(), dir3 = tmpDir("lean-6094b-"); // a failure in a test the diff touches is the lane's: no rerun
|
|
10230
|
+
w3.io.runCommand = async () => ({ rc: 1, output: "not ok 1 - x\n location: 'test/foo.test.js:4:1'" });
|
|
10231
|
+
await atIdleLoad(() => run(w3, { dir: dir3, precheck: { commands: ["make test"] }, verify: { ...parseVerify({}), precheckBlock: true } }));
|
|
10232
|
+
assert.equal(readLog(dir3, 7).filter((e) => e.event === "PRECHECK_FLAKE_RERUN").length, 0);
|
|
10233
|
+
});
|
|
10234
|
+
it("#5749 precheck_block detail carries the failing check tail", async () => {
|
|
10235
|
+
const w = world();
|
|
10236
|
+
w.io.runCommand = async () => ({ rc: 1, output: `${"noise\n".repeat(60)}FAILED lane-check shellcheck scripts/x.sh` });
|
|
10237
|
+
const r = await atIdleLoad(() => run(w, { precheck: { commands: ["make lanecheck"] }, verify: { ...parseVerify({}), precheckBlock: true } }));
|
|
10238
|
+
assert.equal(r.code, "ci.red");
|
|
10239
|
+
assert.match((w.comments.find((c) => c.includes("FORGE:NEEDS_HUMAN")) ?? ""), /`make lanecheck`[\s\S]*FAILED lane-check shellcheck scripts\/x\.sh/);
|
|
10240
|
+
});
|
|
10241
|
+
});
|
|
10242
|
+
|
|
10243
|
+
describe("#6107 precheck parks carry the failing check; a ci.red recovery runs the checks on a synced tree", () => {
|
|
10244
|
+
const block = { precheck: { commands: ["make lanecheck"] }, verify: { ...parseVerify({}), precheckBlock: true } };
|
|
10245
|
+
const nhOf = (w) => w.comments.find((c) => c.includes("FORGE:NEEDS_HUMAN")) ?? "";
|
|
10246
|
+
it("the park names the failing check and carries only its last 40 lines, secrets redacted, and the run log has them too", async () => {
|
|
10247
|
+
const w = world(); const dir = tmpDir("lean-6107-");
|
|
10248
|
+
w.io.runCommand = async () => ({ rc: 1, output: `EARLY-NOISE-MARKER\n${"noise\n".repeat(60)}API_TOKEN=hunter2hunter2\nAuthorization: Bearer abcdefghijklmnop\nFAILED lane-check shellcheck scripts/x.sh` });
|
|
10249
|
+
const r = await atIdleLoad(() => run(w, { dir, ...block }));
|
|
10250
|
+
assert.equal(r.code, "ci.red");
|
|
10251
|
+
const nh = nhOf(w);
|
|
10252
|
+
assert.match(nh, /Failing check `make lanecheck`, exit 1, last 40 lines/);
|
|
10253
|
+
assert.match(nh, /FAILED lane-check shellcheck scripts\/x\.sh/);
|
|
10254
|
+
assert.doesNotMatch(nh, /EARLY-NOISE-MARKER/); assert.doesNotMatch(nh, /hunter2hunter2|abcdefghijklmnop/);
|
|
10255
|
+
const rec = readLog(dir, 7).find((e) => e.event === "PRECHECK_FAILED");
|
|
10256
|
+
assert.equal(rec.checks[0].command, "make lanecheck"); assert.match(rec.checks[0].tail, /FAILED lane-check/); assert.doesNotMatch(rec.checks[0].tail, /hunter2hunter2/);
|
|
10257
|
+
});
|
|
10258
|
+
it("a ci.red recovery that is behind its base merges the base before any check runs", async () => {
|
|
10259
|
+
const w = world({ behind: 2 }); const order = [];
|
|
10260
|
+
w.io.runCommand = async () => { order.push("check"); return { rc: 0, output: "" }; };
|
|
10261
|
+
const orig = w.io.git; w.io.git = async (a, ...rest) => { if (a[0] === "merge" && a[1] === "--no-edit") order.push("merge"); return orig(a, ...rest); };
|
|
10262
|
+
const r = await atIdleLoad(() => run(w, { recover: { code: "ci.red", attempt: 1 }, precheck: { commands: ["make lanecheck"] } }));
|
|
10263
|
+
assert.equal(r.terminalReason, "merged");
|
|
10264
|
+
assert.ok(order.indexOf("merge") >= 0 && order.indexOf("merge") < order.indexOf("check"), `merge before check: ${order}`);
|
|
10265
|
+
});
|
|
10266
|
+
it("a ci.red recovery whose branch conflicts with the base ends base.conflict and never runs the checks on the stale tree", async () => {
|
|
10267
|
+
const w = world({ behind: 3, mergeResults: ["conflict"], conflictFiles: [".github/workflows/ci.yml"] }); let checks = 0;
|
|
10268
|
+
w.io.runCommand = async () => { checks++; return { rc: 1, output: "stale tree failure" }; };
|
|
10269
|
+
const r = await atIdleLoad(() => run(w, { recover: { code: "ci.red", attempt: 1 }, ...block }));
|
|
10270
|
+
assert.equal(r.code, "base.conflict"); assert.equal(checks, 0); assert.equal(w.merges.length, 0);
|
|
10271
|
+
assert.ok(w.calls.some((c) => c[0] === "git" && c[1] === "merge" && c[2] === "--abort"));
|
|
10272
|
+
});
|
|
10273
|
+
it("a first lane (no recovery) does not base-sync before the checks", async () => {
|
|
10274
|
+
const w = world({ behind: 2 });
|
|
10275
|
+
w.io.runCommand = async () => ({ rc: 0, output: "" });
|
|
10276
|
+
await atIdleLoad(() => run(w, { precheck: { commands: ["make lanecheck"] } }));
|
|
10277
|
+
assert.equal(w.calls.filter((c) => c[0] === "git" && c[1] === "merge" && c[2] === "--no-edit").length, 0);
|
|
10278
|
+
});
|
|
10279
|
+
});
|
|
10280
|
+
|
|
10281
|
+
describe("#5844 a busy host is not an absent CLI", () => {
|
|
10282
|
+
const base = { role: "builder", issue: 5844, cwd: "/tmp/x", model: "m", prompt: "p", system: "s" };
|
|
10283
|
+
it("probe timeout does not spawn a bare name", async () => {
|
|
10284
|
+
const { makeLeanRunner } = await import("./effects.mjs");
|
|
10285
|
+
let spawned = 0;
|
|
10286
|
+
const runner = makeLeanRunner({ runCli: async () => { spawned++; return {}; }, probe: () => false, resolveBin: () => null, probeTimedOut: () => true });
|
|
10287
|
+
await assert.rejects(runner(base), (e) => e.deferCode === OUTCOME_CODES.HOST_BUSY && e.retryInSeconds > 0 && e.spawnDeterministic !== true);
|
|
10288
|
+
assert.equal(spawned, 0);
|
|
10289
|
+
});
|
|
10290
|
+
it("a probe that answered absent still spawns, so the deterministic path stays reachable", async () => {
|
|
10291
|
+
const { makeLeanRunner } = await import("./effects.mjs");
|
|
10292
|
+
let spawned = 0;
|
|
10293
|
+
const runner = makeLeanRunner({ runCli: async () => { spawned++; return {}; }, probe: () => false, resolveBin: () => null, probeTimedOut: () => false });
|
|
10294
|
+
await runner(base);
|
|
10295
|
+
assert.equal(spawned, 1);
|
|
10296
|
+
});
|
|
10297
|
+
it("win32 bare name unresolved while the CLI is present defers host.busy, nothing spawned", async () => {
|
|
10298
|
+
const { makeLeanRunner } = await import("./effects.mjs");
|
|
10299
|
+
let spawned = 0;
|
|
10300
|
+
const runner = makeLeanRunner({ runCli: async () => { spawned++; return {}; }, probe: () => false, resolveBin: () => null, probeTimedOut: () => false, platform: "win32", binMissing: () => false });
|
|
10301
|
+
await assert.rejects(runner(base), (e) => e.deferCode === OUTCOME_CODES.HOST_BUSY && e.spawnDeterministic !== true);
|
|
10302
|
+
assert.equal(spawned, 0);
|
|
10303
|
+
const absent = makeLeanRunner({ runCli: async () => { spawned++; return {}; }, probe: () => false, resolveBin: () => null, probeTimedOut: () => false, platform: "win32", binMissing: () => true });
|
|
10304
|
+
await absent(base);
|
|
10305
|
+
assert.equal(spawned, 1, "proven absence still spawns so cli.spawn_failed stays reachable");
|
|
10306
|
+
});
|
|
10307
|
+
it("ENOENT with the CLI present is not cli.spawn_failed", async () => {
|
|
10308
|
+
const { runCliBackend } = await import("../runner.mjs");
|
|
10309
|
+
const dir = tmpDir("core-5844-");
|
|
10310
|
+
writeFileSync(join(dir, "claude"), "");
|
|
10311
|
+
const prev = process.env.PATH; process.env.PATH = dir;
|
|
10312
|
+
let err;
|
|
10313
|
+
try { runCliBackend({ spec: { name: "t" }, userMessage: "go", args: ["1"], cwd: tmpDir("core-5844-"), bin: "claude", logger: { log() {} }, spawnFn: () => ({ status: null, error: Object.assign(new Error("spawn ENOENT"), { code: "ENOENT" }) }) }); } catch (e) { err = e; } finally { process.env.PATH = prev; }
|
|
10314
|
+
assert.equal(err.spawnDeterministic, undefined);
|
|
10315
|
+
assert.notEqual(err.code, "CLI_SPAWN_FAILED");
|
|
10316
|
+
const w = world(); w.io.runner = async () => { throw err; };
|
|
10317
|
+
const res = await run(w);
|
|
10318
|
+
assert.notEqual(res.code, OUTCOME_CODES.CLI_SPAWN_FAILED);
|
|
10319
|
+
});
|
|
10320
|
+
});
|
|
10321
|
+
|
|
10322
|
+
describe("#5753 frozen pytest commands run in the env CI runs them in", () => {
|
|
10323
|
+
const saved = {}; // #5753: a host ~/.forge/guards/o_r.json (another run's leftovers) must not add H-rows to these runs
|
|
10324
|
+
before(() => { for (const k of ["HOME", "USERPROFILE"]) saved[k] = process.env[k]; process.env.HOME = process.env.USERPROFILE = tmpDir("lean-5753-home-"); });
|
|
10325
|
+
after(() => { for (const [k, v] of Object.entries(saved)) if (v === undefined) delete process.env[k]; else process.env[k] = v; });
|
|
10326
|
+
it("#5753 a shared/ pytest validate is rewritten at freeze to the services/worker CI env and the freeze records it", async () => {
|
|
10327
|
+
const d = tmpDir("lean-5753a-"); const src = join(d, "ci.yml");
|
|
10328
|
+
writeFileSync(src, "jobs:\n worker:\n steps:\n - name: Test worker\n working-directory: services/worker\n run: poetry run pytest tests/ ../../shared -q\n");
|
|
10329
|
+
const contract = { ...CONTRACT, validate: [...CONTRACT.validate, { id: "V2", command: "python -m pytest shared/detection/test_x.py" }] };
|
|
10330
|
+
const w = world({ contract }); w.io.probeCommand = async () => ({ rc: 0, output: "" });
|
|
10331
|
+
await run(w, { dir: d, validateCatalogSources: [`../..${src.replace(/^[A-Za-z]:/, "").replace(/\\/g, "/")}`] });
|
|
10332
|
+
assert.ok(w.comments.some((c) => c.includes("FORGE:CONTRACT") && c.includes("cd services/worker && poetry run pytest ../../shared/detection/test_x.py")));
|
|
10333
|
+
assert.ok(!w.comments.some((c) => c.includes("FORGE:CONTRACT") && c.includes("python -m pytest shared/detection/test_x.py")));
|
|
10334
|
+
});
|
|
10335
|
+
it("#5753 a collect-only ImportError is a preflight miss corrected before the implement builder", async () => {
|
|
10336
|
+
const V2 = "python3 -m pytest -q tests/test_corpus.py";
|
|
10337
|
+
const c = { ...CONTRACT, validate: [...CONTRACT.validate, { id: "V2", command: V2 }] };
|
|
10338
|
+
const fixed = { ...c, validate: [c.validate[0], { id: "V2", command: "uv run pytest -q tests/test_corpus.py" }] };
|
|
10339
|
+
const dir = tmpDir("lean-5753b-");
|
|
10340
|
+
const w = world({ contract: c, fixedContract: fixed, validation: fixed.validate.map((v) => ({ id: v.id, command: v.command, exit: 0 })) });
|
|
10341
|
+
const collected = [];
|
|
10342
|
+
w.io.probeCommand = async () => ({ rc: 0, output: "" });
|
|
10343
|
+
w.io.preflightRun = async (a) => {
|
|
10344
|
+
if (/--collect-only/.test(a.command)) collected.push([a.command, w.seq.length]);
|
|
10345
|
+
return /--collect-only/.test(a.command) && !/uv run/.test(a.command) ? { rc: 2, output: "E ModuleNotFoundError: No module named 'html2text'\n" } : { rc: 1, output: "AssertionError: expected RED on base" };
|
|
10346
|
+
};
|
|
10347
|
+
assert.equal((await run(w, { dir })).terminalReason, "merged");
|
|
10348
|
+
const b = builders(w);
|
|
10349
|
+
assert.equal(b.length, 3, "plan + one contract correction + implement");
|
|
10350
|
+
assert.match(b[1][4], /V2: importing its test modules on the base worktree \(pytest --collect-only\) failed: needs Python module 'html2text'/);
|
|
10351
|
+
assert.ok(collected.some(([cmd]) => cmd === "python3 -m pytest --collect-only -q -q tests/test_corpus.py"));
|
|
10352
|
+
const firstImpl = w.seq.indexOf("builder-resume", w.seq.indexOf("builder-resume") + 1);
|
|
10353
|
+
assert.ok(collected.every(([, at]) => at < firstImpl), "every collect-only run happens before the implement session");
|
|
10354
|
+
const pf = readLog(dir, 7).filter((e) => e.event === "VALIDATE_PREFLIGHT");
|
|
10355
|
+
assert.deepEqual(pf.map((e) => [e.corrected, e.found.map((m) => [m.ids, m.tool, m.kind, m.source])]), [[true, [[["V2"], "html2text", "python-module", "collect"]]]]);
|
|
10356
|
+
});
|
|
10357
|
+
});
|
|
10163
10358
|
describe("#5992 verify.guard_bypass: a lane clear of the red guard's files proceeds", () => {
|
|
10164
10359
|
it("bypasses only when opted in and the lane diff misses the guarded files", async () => {
|
|
10165
10360
|
for (const opt of [false, true]) {
|
|
@@ -10223,3 +10418,24 @@ describe("#6008 lease/hold/pause guard before push and merge (kept sandbox)", ()
|
|
|
10223
10418
|
assert.equal((await run(w)).terminalReason, "merged");
|
|
10224
10419
|
});
|
|
10225
10420
|
});
|
|
10421
|
+
|
|
10422
|
+
describe("gate cut (#6083): advisory by default, enforce re-promotes", () => {
|
|
10423
|
+
it("a reviewer unimplemented row without a failing assertion is recorded and the lane merges; enforce makes it block", async () => {
|
|
10424
|
+
const w = world({ reviews: [bad("still null-derefs")] });
|
|
10425
|
+
const r = await run(w);
|
|
10426
|
+
assert.equal(r.terminalReason, "merged"); assert.equal(builders(w).length, 2, "no resume spent");
|
|
10427
|
+
assert.match(traj(w).join("\n"), /Advisory \(not blocking\)[^\n]*conformance\.unimplemented/);
|
|
10428
|
+
const w2 = world({ reviews: [bad("still null-derefs"), bad("still null-derefs")] });
|
|
10429
|
+
assert.equal((await run(w2, ENF)).terminalReason, "needs-human");
|
|
10430
|
+
});
|
|
10431
|
+
it("a validate step with no recorded result is advisory: the lane merges without a resume", async () => {
|
|
10432
|
+
const w = world({ validation: [] });
|
|
10433
|
+
const r = await run(w);
|
|
10434
|
+
assert.equal(r.terminalReason, "merged"); assert.equal(builders(w).length, 2);
|
|
10435
|
+
assert.match(traj(w).join("\n"), /Advisory \(not blocking\)[^\n]*validate_missing/);
|
|
10436
|
+
});
|
|
10437
|
+
it("a reviewer regression row still blocks", async () => {
|
|
10438
|
+
const w = world({ reviews: [conf({ regressions: [{ at: "src/bar.js:4", failure: "caller passes undefined" }] }), ok()] });
|
|
10439
|
+
assert.equal((await run(w)).terminalReason, "merged"); assert.equal(builders(w).length, 3, "the regression is resumed");
|
|
10440
|
+
});
|
|
10441
|
+
});
|