forgedock 1.67.0 → 1.69.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 +103 -21
- 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 +39 -15
- 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.mjs +11 -1
- package/bin/lean/batch.test.mjs +51 -2
- package/bin/lean/capsample.mjs +25 -0
- 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 +62 -197
- package/bin/lean/conformance.test.mjs +46 -376
- package/bin/lean/depcache.mjs +102 -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 +57 -25
- package/bin/lean/engine-readmit.test.mjs +35 -0
- package/bin/lean/envgap.mjs +111 -0
- package/bin/lean/envgap.test.mjs +64 -0
- package/bin/lean/execution.mjs +13 -4
- package/bin/lean/execution.test.mjs +33 -0
- package/bin/lean/failure-census.mjs +170 -0
- package/bin/lean/failure-census.test.mjs +59 -0
- package/bin/lean/failure-stop.mjs +12 -1
- package/bin/lean/failure-stop.test.mjs +14 -1
- 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/hostconfig.mjs +54 -0
- package/bin/lean/hostconfig.test.mjs +67 -0
- 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 +52 -0
- package/bin/lean/lane-audit-llm.test.mjs +57 -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 +247 -152
- package/bin/lean/lean.test.mjs +502 -206
- package/bin/lean/limits.mjs +17 -0
- package/bin/lean/limits.test.mjs +15 -1
- package/bin/lean/live-execution.mjs +24 -2
- package/bin/lean/live-execution.test.mjs +62 -0
- package/bin/lean/orchestrate-attempts.test.mjs +17 -9
- package/bin/lean/orchestrate-dispatch-placement.test.mjs +81 -0
- package/bin/lean/orchestrate-envhold.test.mjs +62 -1
- 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 +215 -42
- package/bin/lean/postdeploy-check.test.mjs +1 -3
- package/bin/lean/precheck.mjs +20 -0
- package/bin/lean/preflight.mjs +110 -14
- package/bin/lean/preflight.test.mjs +64 -4
- package/bin/lean/prompts.mjs +11 -21
- package/bin/lean/recurrence.mjs +6 -148
- package/bin/lean/recurrence.test.mjs +11 -147
- package/bin/lean/release-deploy.mjs +35 -5
- package/bin/lean/release-deploy.test.mjs +50 -3
- package/bin/lean/release-flakes.mjs +48 -2
- package/bin/lean/release-flakes.test.mjs +45 -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 +45 -15
- 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 +51 -13
- package/bin/lean/schedd.mjs +13 -8
- 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 +247 -23
- package/bin/pool/cache-sweep.mjs +31 -10
- package/bin/pool/ci-autoscale.mjs +160 -0
- package/bin/pool/cli.mjs +56 -9
- package/bin/pool/docker.mjs +5 -0
- package/bin/pool/engine-placement.test.mjs +94 -0
- package/bin/pool/image-manifest.mjs +24 -0
- package/bin/pool/image-manifest.test.mjs +20 -0
- package/bin/pool/lane-target.mjs +41 -0
- package/bin/pool/lane-tools.mjs +29 -5
- package/bin/pool/lane-tools.test.mjs +36 -7
- package/bin/pool/mirror-seed.mjs +15 -11
- package/bin/pool/project-layer.mjs +142 -0
- package/bin/pool/project-layer.test.mjs +73 -0
- package/bin/pool/router.mjs +106 -36
- package/bin/pool/version.mjs +72 -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/bin/stats/tool-parks.mjs +29 -0
- package/bin/stats/tool-parks.test.mjs +21 -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 +15 -3
- 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 +14 -2
- 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" : "";
|
|
@@ -195,6 +198,7 @@ function world(o = {}) {
|
|
|
195
198
|
return "";
|
|
196
199
|
},
|
|
197
200
|
runner: async (c) => {
|
|
201
|
+
if (c.role === "lane-audit") return { text: "" }; // #6079: the post-terminal audit classification is not a lane session
|
|
198
202
|
w.calls.push(["runner", c.role, c.resume ?? null, c.model ?? null, c.prompt, c.readOnly ?? false, c.system]);
|
|
199
203
|
w.seq.push(c.role + (c.resume ? "-resume" : ""));
|
|
200
204
|
w.envs.push(c.env ?? null);
|
|
@@ -219,7 +223,7 @@ function world(o = {}) {
|
|
|
219
223
|
if (fix && n > 2 && /does not conform/.test(c.prompt) && o.resumeChanged) w.changed = o.resumeChanged;
|
|
220
224
|
if (/Merging origin\//.test(c.prompt) && o.syncChanged) w.changed = o.syncChanged;
|
|
221
225
|
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" })),
|
|
226
|
+
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
227
|
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
228
|
}
|
|
225
229
|
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 +241,10 @@ function world(o = {}) {
|
|
|
237
241
|
};
|
|
238
242
|
return w;
|
|
239
243
|
}
|
|
244
|
+
// #6083: the codes the gate cut made advisory. Tests of the resume and needs-human mechanics exercise a blocking code, so they
|
|
245
|
+
// re-promote these with engine.conformance_kinds enforce (ENF); the advisory default itself is pinned by the "gate cut (#6083)" tests.
|
|
246
|
+
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"]));
|
|
247
|
+
const ENF = { conformanceKinds: LEGACY_ENFORCE };
|
|
240
248
|
const run = (w, extra = {}) => runCore({ issue: 7, repo: "o/r", lane: "staging", cwd: "/repo", worktreeRoot: "/wt", dir: tmpDir("core-"), conformance: "enforce",
|
|
241
249
|
io: w.io, emitTelemetry: async (r) => w.telemetry.push(r), random: () => 0.5, ...extra });
|
|
242
250
|
/** #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 +398,11 @@ describe("core work-on", () => {
|
|
|
390
398
|
assert.match(t, /\| Plan \| not reached \|/);
|
|
391
399
|
});
|
|
392
400
|
|
|
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
401
|
|
|
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
402
|
|
|
409
403
|
it("nonconforming review -> builder resumed in its session with the failed rows -> re-review conforms -> merge; the note is re-posted", async () => {
|
|
410
404
|
const w = world({ reviews: [bad("src/foo.js:9 still wrong"), ok()] });
|
|
411
|
-
const r = await run(w);
|
|
405
|
+
const r = await run(w, ENF);
|
|
412
406
|
assert.equal(r.terminalReason, "merged");
|
|
413
407
|
const b = builders(w);
|
|
414
408
|
assert.equal(b.length, 3);
|
|
@@ -427,7 +421,7 @@ describe("core work-on", () => {
|
|
|
427
421
|
|
|
428
422
|
it("nonconforming twice -> needs-human with the specific code, no PR, issue left open", async () => {
|
|
429
423
|
const w = world({ reviews: [bad(), bad("still bad")] });
|
|
430
|
-
const r = await run(w, { reviewMaxResumes: 1 });
|
|
424
|
+
const r = await run(w, { ...ENF, reviewMaxResumes: 1 });
|
|
431
425
|
assert.equal(r.terminalReason, "needs-human");
|
|
432
426
|
assert.equal(r.code, "conformance.unimplemented");
|
|
433
427
|
assert.equal(w.closed.length, 0);
|
|
@@ -478,16 +472,15 @@ describe("core work-on", () => {
|
|
|
478
472
|
|
|
479
473
|
it("a CONFORMS verdict whose rows fail is not conforming (the engine computes the verdict)", async () => {
|
|
480
474
|
const w = world({ reviews: [bad("half done", "CONFORMS"), ok()] });
|
|
481
|
-
assert.equal((await run(w)).terminalReason, "merged");
|
|
475
|
+
assert.equal((await run(w, ENF)).terminalReason, "merged");
|
|
482
476
|
assert.equal(builders(w).length, 3);
|
|
483
|
-
assert.match(traj(w)[0], /reviewer verdict contradicted its rows/);
|
|
484
477
|
});
|
|
485
478
|
|
|
486
479
|
it("a reviewer that judges a deferral unjustified gets the builder resumed to implement it; nothing is filed for it", async () => {
|
|
487
480
|
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
481
|
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
482
|
const w = world({ contract: k, claims: [{ id: "R1", status: "implemented" }], reviews: [rej, rej] });
|
|
490
|
-
const r = await run(w);
|
|
483
|
+
const r = await run(w, ENF);
|
|
491
484
|
assert.equal(r.code, "conformance.unjustified_deferral"); assert.equal(w.followups.length, 0); assert.equal(w.merges.length, 0);
|
|
492
485
|
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
486
|
});
|
|
@@ -567,6 +560,38 @@ describe("core work-on", () => {
|
|
|
567
560
|
assert.equal(real.code, "builder.blocked");
|
|
568
561
|
});
|
|
569
562
|
|
|
563
|
+
it("#6122 a FORGE:DECISION posted after the park resets the repeat: the next identical failure is a first (NEEDS_HUMAN), not failure.repeated", async () => {
|
|
564
|
+
const block = { status: "blocked", summary: "need creds", block: { kind: "human", why: "credentials" } };
|
|
565
|
+
const first = world({ changed: [] });
|
|
566
|
+
await run(first);
|
|
567
|
+
const nh = first.comments.find((c) => c.includes("<!-- FORGE:NEEDS_HUMAN -->"));
|
|
568
|
+
const bot = (body) => ({ author: { login: "rapiercraft-forgedock" }, body });
|
|
569
|
+
const decision = bot('<!-- FORGE:DECISION {"requirement":"R4","disposition":"post-deploy","quote":"x"} -->');
|
|
570
|
+
const after = world({ changed: [], viewComments: [bot(nh), decision] });
|
|
571
|
+
const r = await run(after);
|
|
572
|
+
assert.notEqual(r.code, "failure.repeated");
|
|
573
|
+
assert.ok(after.comments.some((c) => c.includes("<!-- FORGE:NEEDS_HUMAN -->")));
|
|
574
|
+
const before = world({ changed: [], viewComments: [decision, bot(nh)] });
|
|
575
|
+
assert.equal((await run(before)).code, "failure.repeated", "a decision older than the park does not clear it");
|
|
576
|
+
});
|
|
577
|
+
|
|
578
|
+
it("#6076 an unhappy terminal posts one FORGE:LANE_AUDIT; a failing audit post leaves the terminal reason unchanged", async () => {
|
|
579
|
+
const block = { status: "blocked", summary: "need creds", block: { kind: "human", why: "credentials" } };
|
|
580
|
+
const w = world({ changed: [], result: block });
|
|
581
|
+
const r = await run(w);
|
|
582
|
+
assert.equal(r.terminalReason, "needs-human");
|
|
583
|
+
const audits = w.comments.filter((c) => c.includes("<!-- FORGE:LANE_AUDIT -->"));
|
|
584
|
+
assert.equal(audits.length, 1);
|
|
585
|
+
assert.match(audits[0], /"status": "proposed"/);
|
|
586
|
+
assert.match(audits[0], /"engine_version"/);
|
|
587
|
+
const bad = world({ changed: [], result: block });
|
|
588
|
+
const gh = bad.io.gh;
|
|
589
|
+
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); };
|
|
590
|
+
const r2 = await run(bad);
|
|
591
|
+
assert.equal(r2.terminalReason, "needs-human");
|
|
592
|
+
assert.equal(r2.code, r.code);
|
|
593
|
+
});
|
|
594
|
+
|
|
570
595
|
// #4124: a builder block is typed; only kind "human" with an allowed reason may reach needs-human.
|
|
571
596
|
const depWorld = (o, deps) => {
|
|
572
597
|
const w = world(o);
|
|
@@ -733,14 +758,6 @@ describe("core work-on", () => {
|
|
|
733
758
|
assert.ok(w.comments.some((c) => /FORGE:DECOMPOSED/.test(c) && /size: 40 files, 4000 lines .* oversize yes/.test(c)));
|
|
734
759
|
});
|
|
735
760
|
|
|
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
761
|
it("#5342 classifyBlock: design-invalidated needs a decision and a why; the other kinds are unchanged", () => {
|
|
745
762
|
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
763
|
assert.deepEqual([ok.kind, ok.epic, ok.paths], ["design-invalidated", 5, ["src/a.ts"]]);
|
|
@@ -1023,11 +1040,11 @@ describe("core work-on", () => {
|
|
|
1023
1040
|
assert.notEqual(r.code, "env.tool_missing");
|
|
1024
1041
|
assert.notEqual(r.terminalReason, "needs-human");
|
|
1025
1042
|
});
|
|
1026
|
-
it("#5764 a
|
|
1027
|
-
const w = world({ contract: withTool("
|
|
1043
|
+
it("#5764 a pip3 miss maps to the python recipe: installed in the sandbox and re-probed, no needs-human", async () => {
|
|
1044
|
+
const w = world({ contract: withTool("pip3") }); let ok = false; const cmds = [];
|
|
1028
1045
|
const base = w.io.runCommand;
|
|
1029
1046
|
w.io.runCommand = async (a) => { if (/apt-get install/.test(a.command) && /python3 python3-venv/.test(a.command)) { cmds.push(a.command); ok = true; return { rc: 0 }; } return base(a); };
|
|
1030
|
-
probing(w, "
|
|
1047
|
+
probing(w, "pip3", () => ok);
|
|
1031
1048
|
const r = await run(w, { dir: tmpDir("lean-5764a-"), ...remote });
|
|
1032
1049
|
assert.equal(cmds.length, 1);
|
|
1033
1050
|
assert.notEqual(r.code, "env.tool_missing");
|
|
@@ -1087,7 +1104,15 @@ describe("core work-on", () => {
|
|
|
1087
1104
|
// #4685: a missing tool is never a credential block on a remote lane; local lanes and real credential needs stay human.
|
|
1088
1105
|
assert.equal(await rb("validate V1 needs promtool via docker; no docker daemon in this sandbox", remote), "env.tool_missing");
|
|
1089
1106
|
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" } }), "
|
|
1107
|
+
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
|
|
1108
|
+
// #6106: the two real block texts are env gaps whatever reason the builder typed; a genuine human reason stays human
|
|
1109
|
+
const pd = (summary) => code(world({ result: { status: "blocked", summary, block: { kind: "human", why: "product-decision" } } }));
|
|
1110
|
+
assert.equal(await pd("the yaml lane-tools recipe lives in the engine, so the lane cannot install it"), "env.tool_missing");
|
|
1111
|
+
assert.equal(await rb("no Python 3.11 interpreter in the sandbox (only 3.12.3)"), "env.tool_missing");
|
|
1112
|
+
assert.equal(await pd("needs a user-approved merge of staging (CLAUDE.md forbids agent git merge)"), "base.conflict"); // #6137
|
|
1113
|
+
assert.equal(await pd("needs a user-approved merge of staging, plus owner approval of the Stripe pricing"), "builder.blocked");
|
|
1114
|
+
assert.equal(await pd("needs Stripe approval before the pricing change ships"), "builder.blocked");
|
|
1115
|
+
assert.equal(await rb("needs the production API key and credentials from the owner"), "builder.blocked");
|
|
1091
1116
|
assert.equal(await rb("this lane has no sops/age key", { ...remote, hostCaps: undefined }), "builder.blocked");
|
|
1092
1117
|
assert.equal(await rb("this lane has no sops/age key", { ...remote, placement: { where: "local", reason: "x" } }), "builder.blocked");
|
|
1093
1118
|
assert.equal(await code(world({ changed: [] })), "builder.no_commit");
|
|
@@ -1375,7 +1400,7 @@ describe("conformance gate (frozen contract, precheck, structured review)", () =
|
|
|
1375
1400
|
|
|
1376
1401
|
it("a claimed 'follow-up' with no typed deferral is needs-human conformance.untracked_deferral; nothing is filed or merged", async () => {
|
|
1377
1402
|
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);
|
|
1403
|
+
const r = await run(w, ENF);
|
|
1379
1404
|
assert.equal(r.code, "conformance.untracked_deferral"); assert.equal(reviewers(w).length, 0); assert.equal(w.followups.length, 0);
|
|
1380
1405
|
assert.match(nhBody(w), /R2 was contracted as deliver but reported "deferred" without a typed amendment/);
|
|
1381
1406
|
blockedNothingMerged(w);
|
|
@@ -1385,7 +1410,7 @@ describe("conformance gate (frozen contract, precheck, structured review)", () =
|
|
|
1385
1410
|
const w = world({ contract: two(), changed: files2, claims: [{ id: "R1", status: "implemented" }, { id: "R2", status: "deferred" }],
|
|
1386
1411
|
resumeAmendments: [{ kind: "defer", requirement: "R2", why: "callers live in another module's release train" }],
|
|
1387
1412
|
reviews: [conf({}, two("defer", { tracked: "#900" }), files2)] });
|
|
1388
|
-
const r = await run(w);
|
|
1413
|
+
const r = await run(w, ENF);
|
|
1389
1414
|
assert.equal(r.terminalReason, "merged");
|
|
1390
1415
|
assert.equal(w.followups.length, 1);
|
|
1391
1416
|
assert.deepEqual(w.followups[0].items.map((i) => i.key), ["R2: Existing callers of foo keep working."]);
|
|
@@ -1704,14 +1729,6 @@ describe("devdocs freshness gate (the repo's own scripts/check-devdocs-freshness
|
|
|
1704
1729
|
};
|
|
1705
1730
|
const STALE = { ok: false, output: "STALE: bin/lean/lean.mjs changed but no dossier matching it was touched (devdocs/modules/lean.md)" };
|
|
1706
1731
|
|
|
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
1732
|
|
|
1716
1733
|
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
1734
|
for (const [extra, code] of [[[], null], [["src/billing.js"], null]]) {
|
|
@@ -1723,12 +1740,6 @@ describe("devdocs freshness gate (the repo's own scripts/check-devdocs-freshness
|
|
|
1723
1740
|
}
|
|
1724
1741
|
});
|
|
1725
1742
|
|
|
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
1743
|
|
|
1733
1744
|
it("no script in the repo, or it cannot run (null): no resume, the run is unchanged", async () => {
|
|
1734
1745
|
const w = dworld([null]);
|
|
@@ -1736,22 +1747,6 @@ describe("devdocs freshness gate (the repo's own scripts/check-devdocs-freshness
|
|
|
1736
1747
|
assert.equal(builders(w).length, 2);
|
|
1737
1748
|
});
|
|
1738
1749
|
|
|
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
1750
|
});
|
|
1756
1751
|
|
|
1757
1752
|
describe("review row skeleton and targeted retry (#4160)", () => {
|
|
@@ -1992,10 +1987,10 @@ describe("conformance shadow mode (the default)", () => {
|
|
|
1992
1987
|
|
|
1993
1988
|
it("shadow still blocks what the previous reviewer blocked on: a requirement not implemented gets one resume, then needs-human", async () => {
|
|
1994
1989
|
const w = world({ reviews: [bad("still null-derefs"), bad("still null-derefs")] });
|
|
1995
|
-
const r = await runShadow(w);
|
|
1990
|
+
const r = await runShadow(w, ENF);
|
|
1996
1991
|
assert.equal(r.code, "conformance.unimplemented"); assert.equal(builders(w).length, 3); assert.equal(w.merges.length, 0);
|
|
1997
1992
|
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");
|
|
1993
|
+
assert.equal((await runShadow(w2, ENF)).terminalReason, "merged"); assert.equal(builders(w2).length, 3, "a regression is resumed in shadow too");
|
|
1999
1994
|
});
|
|
2000
1995
|
|
|
2001
1996
|
it("shadow blocks a failed validate command (#4160): one resume, then needs-human, and no reviewer tokens are spent", async () => {
|
|
@@ -2013,12 +2008,12 @@ describe("conformance shadow mode (the default)", () => {
|
|
|
2013
2008
|
const w = world({ validation: v }); let provisioned = 0, installed = false;
|
|
2014
2009
|
w.io.deps = { prepare: async () => { provisioned++; installed = true; return []; } };
|
|
2015
2010
|
w.io.runCommand = async () => (installed ? { rc: 0, output: "" } : { rc: 1, output: "ModuleNotFoundError: No module named 'pytest'" });
|
|
2016
|
-
const ok = await run(w, { conformance: "enforce" });
|
|
2011
|
+
const ok = await run(w, { ...ENF, conformance: "enforce" });
|
|
2017
2012
|
assert.notEqual(ok.code, OUTCOME_CODES.ENV_TOOL_MISSING); assert.equal(provisioned >= 1, true);
|
|
2018
2013
|
const w2 = world({ validation: v }); let again = 0;
|
|
2019
2014
|
w2.io.deps = { prepare: async () => { again++; return []; } };
|
|
2020
2015
|
w2.io.runCommand = async () => ({ rc: 1, output: "ModuleNotFoundError: No module named 'yaml'" });
|
|
2021
|
-
const r = await run(w2, { conformance: "enforce" });
|
|
2016
|
+
const r = await run(w2, { ...ENF, conformance: "enforce" });
|
|
2022
2017
|
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
2018
|
});
|
|
2024
2019
|
|
|
@@ -2039,13 +2034,13 @@ describe("conformance shadow mode (the default)", () => {
|
|
|
2039
2034
|
const v = [{ id: "V1", command: "node --test test/foo.test.js", exit: 0 }];
|
|
2040
2035
|
const w = world({ validation: v }); let calls = 0;
|
|
2041
2036
|
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" });
|
|
2037
|
+
const r = await run(w, { ...ENF, conformance: "enforce" });
|
|
2043
2038
|
assert.equal(r.code, OUTCOME_CODES.ENV_TOOL_MISSING); assert.equal(w.merges.length, 0);
|
|
2044
2039
|
assert.equal(calls, 2, "the toolchain prepare plus exactly one provisioning retry");
|
|
2045
2040
|
assert.match(nhBody(w), /dependency install failed \(npm: install failed: ERESOLVE\) for a package the changed file/);
|
|
2046
2041
|
const w2 = world({ validation: v });
|
|
2047
2042
|
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" });
|
|
2043
|
+
const r2 = await run(w2, { ...ENF, conformance: "enforce" });
|
|
2049
2044
|
assert.notEqual(r2.code, OUTCOME_CODES.ENV_TOOL_MISSING);
|
|
2050
2045
|
});
|
|
2051
2046
|
|
|
@@ -2054,7 +2049,7 @@ describe("conformance shadow mode (the default)", () => {
|
|
|
2054
2049
|
for (const conformance of ["shadow", "enforce"]) {
|
|
2055
2050
|
const w = world({ validation: v }), ran = [];
|
|
2056
2051
|
w.io.runCommand = async (a) => { ran.push(a); return { rc: 1, output: "ModuleNotFoundError: No module named 'yaml'" }; };
|
|
2057
|
-
const r = await run(w, { conformance });
|
|
2052
|
+
const r = await run(w, { ...ENF, conformance });
|
|
2058
2053
|
assert.equal(r.code, OUTCOME_CODES.ENV_TOOL_MISSING, conformance); assert.equal(w.merges.length, 0);
|
|
2059
2054
|
assert.equal(builders(w).length, 2, "plan + implement only"); assert.equal(reviewers(w).length, 0);
|
|
2060
2055
|
assert.match(nhBody(w), /Environment error \(not a conformance failure\): the host is missing yaml/);
|
|
@@ -2078,11 +2073,10 @@ describe("conformance shadow mode (the default)", () => {
|
|
|
2078
2073
|
const ok = world({ validation: v }); ok.io.runCommand = async () => ({ rc: 0, output: "" });
|
|
2079
2074
|
assert.equal((await run(ok, { conformance: "enforce", placement: { where: "local", reason: "x" }, recover: { code: ENV_VALIDATE_PLACEMENT, attempt: 1, final: true } })).terminalReason, "merged");
|
|
2080
2075
|
});
|
|
2081
|
-
const remoteV = { conformance: "enforce", placement: { where: "remote", reason: "mode remote" } };
|
|
2076
|
+
const remoteV = { ...ENF, conformance: "enforce", placement: { where: "remote", reason: "mode remote" } };
|
|
2082
2077
|
const v5730 = [{ id: "V1", command: "node --test test/foo.test.js", exit: 1 }];
|
|
2083
2078
|
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"]) {
|
|
2079
|
+
for (const output of ["not ok 1 - foo\n AssertionError: expected 3, got 4"]) { // #6083: a stale generated artifact (validate_drift) is advisory
|
|
2086
2080
|
const w = world({ validation: v5730 }); w.io.runCommand = async () => ({ rc: 1, output });
|
|
2087
2081
|
const r = await run(w, remoteV);
|
|
2088
2082
|
assert.notEqual(r.code, ENV_VALIDATE_PLACEMENT, output); assert.ok(builders(w).length >= 3, "the builder resumes");
|
|
@@ -2106,31 +2100,13 @@ describe("conformance shadow mode (the default)", () => {
|
|
|
2106
2100
|
for (const conformance of ["shadow", "enforce"]) {
|
|
2107
2101
|
const w = world({ validation: v });
|
|
2108
2102
|
w.io.runCommand = async () => ({ rc: 124, output: "(timed out after 1s)" });
|
|
2109
|
-
const r = await run(w, { conformance });
|
|
2103
|
+
const r = await run(w, { ...ENF, conformance });
|
|
2110
2104
|
assert.equal(r.code, ENV_VALIDATE_TIMEOUT, conformance); assert.equal(r.terminalReason, "needs-human");
|
|
2111
2105
|
assert.equal(classifyNeedsHuman(r), "recoverable"); assert.equal(w.merges.length, 0);
|
|
2112
2106
|
assert.equal(builders(w).length, 2, "plan + implement only"); assert.equal(reviewers(w).length, 0);
|
|
2113
2107
|
assert.match(nhBody(w), /timed out \(exit 124\) even after one longer retry/);
|
|
2114
2108
|
}
|
|
2115
2109
|
});
|
|
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
2110
|
it("#4323 a rerun that fails for a repo reason stays conformance.unimplemented; one that passes merges", async () => {
|
|
2135
2111
|
const v = [{ id: "V1", command: "node --test test/foo.test.js", exit: 1 }];
|
|
2136
2112
|
const w = world({ validation: v, resumeValidation: v });
|
|
@@ -2162,7 +2138,7 @@ describe("conformance shadow mode (the default)", () => {
|
|
|
2162
2138
|
const GC = { ...CONTRACT, validate: [...CONTRACT.validate, { id: "G1", command: "node --test test/bar.test.js", regression: true }] };
|
|
2163
2139
|
const w = world({ contract: GC, validation: [{ id: "V1", command: CONTRACT.validate[0].command, exit: 0 }] });
|
|
2164
2140
|
delete w.io.runCommand;
|
|
2165
|
-
const r = await runShadow(w);
|
|
2141
|
+
const r = await runShadow(w, ENF);
|
|
2166
2142
|
assert.notEqual(r.terminalReason, "merged"); assert.ok(builders(w).length >= 3, "validate_missing resumes the builder");
|
|
2167
2143
|
});
|
|
2168
2144
|
it("#5728 a fix resume that hits the context ceiling restarts with the failure list, not the full build prompt", async () => {
|
|
@@ -2274,17 +2250,18 @@ describe("conformance shadow mode (the default)", () => {
|
|
|
2274
2250
|
assert.ok(traj(s).some((t) => /Validate preflight: the host lacks yaml after the contract correction/.test(t)));
|
|
2275
2251
|
// every tool present: no correction, no event
|
|
2276
2252
|
const dir3 = tmpDir("preflight-");
|
|
2277
|
-
const
|
|
2253
|
+
const rgC = { ...CONTRACT, validate: [{ id: "V1", command: "ripgrep foo" }] };
|
|
2254
|
+
const ok = world({ contract: rgC, validation: [{ id: "V1", command: rgC.validate[0].command, exit: 0 }] }); const ran3 = probe(ok);
|
|
2278
2255
|
assert.equal((await run(ok, { dir: dir3 })).terminalReason, "merged"); assert.equal(builders(ok).length, 2);
|
|
2279
|
-
assert.deepEqual(ran3.map((a) => a.command), ["command -v -- '
|
|
2256
|
+
assert.deepEqual(ran3.map((a) => a.command), ["command -v -- 'ripgrep' >/dev/null 2>&1"]);
|
|
2280
2257
|
assert.equal(readLog(dir3, 7).filter((e) => e.event === "VALIDATE_PREFLIGHT").length, 0);
|
|
2281
2258
|
});
|
|
2282
2259
|
it("#4328 an invalid contract and a preflight miss share one correction; still invalid is contract.invalid as before", async () => {
|
|
2283
|
-
const bad = { ...CONTRACT, requirements: [{ id: "R1", quote: "make foo nicer", disposition: "deliver" }], validate: [{ id: "V1", command: "
|
|
2260
|
+
const bad = { ...CONTRACT, requirements: [{ id: "R1", quote: "make foo nicer", disposition: "deliver" }], validate: [{ id: "V1", command: "ripgrep . a.json" }] };
|
|
2284
2261
|
const w = world({ contract: bad, fixedContract: bad });
|
|
2285
2262
|
w.io.probeCommand = async () => ({ rc: 1, output: "" });
|
|
2286
2263
|
assert.equal((await run(w)).code, "contract.invalid"); assert.equal(builders(w).length, 2, "plan + one correction");
|
|
2287
|
-
assert.match(builders(w)[1][4], /R1: quote is not verbatim[\s\S]*V1: needs command '
|
|
2264
|
+
assert.match(builders(w)[1][4], /R1: quote is not verbatim[\s\S]*V1: needs command 'ripgrep'/);
|
|
2288
2265
|
});
|
|
2289
2266
|
it("#4393 replaying the AlterLab#36619 contract flags V4 at preflight, before the builder starts", async () => {
|
|
2290
2267
|
const V4 = "uv run --no-project --python 3.12 python -m shared.detection.corpus.tools.check_manifest";
|
|
@@ -2403,26 +2380,26 @@ describe("conformance shadow mode (the default)", () => {
|
|
|
2403
2380
|
|
|
2404
2381
|
it("#4160 shadow blocks a validate step with no recorded result and an invalid amendment like a reviewer-found unimplemented requirement", async () => {
|
|
2405
2382
|
const w = world({ validation: [] });
|
|
2406
|
-
const r = await runShadow(w);
|
|
2383
|
+
const r = await runShadow(w, ENF);
|
|
2407
2384
|
assert.equal(r.code, "conformance.unimplemented"); assert.equal(w.merges.length, 0);
|
|
2408
2385
|
assert.equal(builders(w).length, 3, "one builder resume"); assert.equal(reviewers(w).length, 0, "no reviewer tokens on a precheck block");
|
|
2409
2386
|
assert.match(builders(w)[2][4], /validate V1 .*has no recorded result/);
|
|
2410
2387
|
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");
|
|
2388
|
+
assert.equal((await runShadow(fixed, ENF)).terminalReason, "merged", "recorded by the resume, then merges");
|
|
2412
2389
|
const a = world({ amendments: [{ kind: "add-deliverable", path: "src/x.js" }] });
|
|
2413
2390
|
const ra = await runShadow(a);
|
|
2414
|
-
assert.equal(ra.terminalReason, "merged", "
|
|
2391
|
+
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
2392
|
});
|
|
2416
2393
|
it("#4737 decision records are persisted after the merge, never at gate time", async () => {
|
|
2417
2394
|
const dir = tmpDir("dec-"); const prev = process.env.FORGEDOCK_DECISIONS_DIR; process.env.FORGEDOCK_DECISIONS_DIR = dir;
|
|
2418
2395
|
try {
|
|
2419
2396
|
const amendments = [{ kind: "decision", why: "w", decision: { choice: "use X", anchors: ["src/db.ts"], why: "w" } }];
|
|
2420
2397
|
const bad = world({ validation: [], amendments });
|
|
2421
|
-
assert.equal((await runShadow(bad)).code, "conformance.unimplemented");
|
|
2398
|
+
assert.equal((await runShadow(bad, ENF)).code, "conformance.unimplemented");
|
|
2422
2399
|
assert.ok(!bad.comments.some((c) => c.includes("FORGE:DECISION")), "a lane that never merges records nothing");
|
|
2423
2400
|
assert.equal(readdirSync(dir).length, 0, "no index written");
|
|
2424
2401
|
const ok = world({ amendments });
|
|
2425
|
-
assert.equal((await runShadow(ok)).terminalReason, "merged");
|
|
2402
|
+
assert.equal((await runShadow(ok, ENF)).terminalReason, "merged");
|
|
2426
2403
|
assert.ok(ok.comments.some((c) => c.includes("FORGE:DECISION")), "recorded after the merge");
|
|
2427
2404
|
assert.equal(readdirSync(dir).length, 1);
|
|
2428
2405
|
} finally { if (prev === undefined) delete process.env.FORGEDOCK_DECISIONS_DIR; else process.env.FORGEDOCK_DECISIONS_DIR = prev; }
|
|
@@ -2500,7 +2477,7 @@ describe("conformance shadow mode (the default)", () => {
|
|
|
2500
2477
|
it("#5207 shadow: an in-lane engineering deferral (bucket new-issue) resumes the builder once and is never filed", async () => {
|
|
2501
2478
|
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
2479
|
const w = world({ contract: k, claims: [{ id: "R1", status: "implemented" }], reviews: [conf({}, k), conf({}, k)] });
|
|
2503
|
-
const r = await runShadow(w);
|
|
2480
|
+
const r = await runShadow(w, ENF);
|
|
2504
2481
|
assert.equal(r.code, "conformance.unjustified_deferral"); assert.equal(w.followups.length, 0); assert.equal(w.merges.length, 0);
|
|
2505
2482
|
assert.match(builders(w)[2][4], /R2 is in-lane engineering work \(bucket new-issue\): deliver it/);
|
|
2506
2483
|
});
|
|
@@ -2726,23 +2703,10 @@ describe("hotspot prevention (forge#4195): plan facts, build rule, unexempted gr
|
|
|
2726
2703
|
assert.equal(hotspotBuildRule(null), ""); assert.equal(hotspotBuildRule(facts([], { enabled: false })), "");
|
|
2727
2704
|
const plan = builderPlanPrompt(7) + hotspotPlanNote(facts([HOT, { ...HOT, path: "a/b.py" }, { ...HOT, path: "c/d.py" }]));
|
|
2728
2705
|
// 2750: #5750 (outcome vs guidance rows). 2650: #5557 (classification record line) on top of the base's growth. 1850: #4404 (verify out_of_band) and #4396 (split size rule) grew the plan prompt to ~1803 tokens on CI paths; 1900: #4589 (check timeout is not a block, one block-rule line). 2050: #4724 (deferred-row bucket rule). 1675 (hotspot case): #5284 (rubric prod_parity clause). 2375/1825: #5345 (self-check and pitfall lines).
|
|
2729
|
-
assert.ok(approxTokens(plan) <=
|
|
2706
|
+
assert.ok(approxTokens(plan) <= 2800, `plan prompt with hotspots is ${approxTokens(plan)} tokens`); // 2800: #6137 (base merge is base-sync)
|
|
2730
2707
|
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
2708
|
});
|
|
2732
2709
|
|
|
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
2710
|
|
|
2747
2711
|
it("the plan prompt carries the facts, the implement prompt the configured rule; growth within the limit merges; no extra runner calls", async () => {
|
|
2748
2712
|
const w = hworld(facts([HOT, COLD], { file_lines: 2000, growth_lines: 150 }), [facts([SMALL])]);
|
|
@@ -2757,15 +2721,6 @@ describe("hotspot prevention (forge#4195): plan facts, build rule, unexempted gr
|
|
|
2757
2721
|
assert.equal(plain.calls.filter((c) => c[0] === "runner").length, w.calls.filter((c) => c[0] === "runner").length, "no extra LLM calls");
|
|
2758
2722
|
});
|
|
2759
2723
|
|
|
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
2724
|
|
|
2770
2725
|
it("growth moved out on the resume merges; an exemption in the contract or a failed/missing script never blocks", async () => {
|
|
2771
2726
|
const w = hworld(facts([HOT]), [facts([GROWN]), facts([SMALL])]);
|
|
@@ -2830,7 +2785,8 @@ describe("bug lanes freeze a red-green repro_test (#4271)", () => {
|
|
|
2830
2785
|
const prev = process.env.FORGE_HOST_PARALLELISM; process.env.FORGE_HOST_PARALLELISM = "3";
|
|
2831
2786
|
try { assert.equal((await run(w, { envSetup: "make setup", precheck: { commands: ["npm run lint"] } })).terminalReason, "merged"); }
|
|
2832
2787
|
finally { if (prev === undefined) delete process.env.FORGE_HOST_PARALLELISM; else process.env.FORGE_HOST_PARALLELISM = prev; }
|
|
2833
|
-
const
|
|
2788
|
+
const cfg = (d) => ({ POETRY_CONFIG_DIR: `${d}/hostconfig/poetry`, npm_config_userconfig: `${d}/hostconfig/npmrc`, PIP_CONFIG_FILE: `${d}/hostconfig/pip.conf`, UV_CONFIG_FILE: `${d}/hostconfig/uv.toml`, GIT_CONFIG_GLOBAL: `${d}/hostconfig/gitconfig` }); // #5917
|
|
2789
|
+
const lane = { ...cfg(w.envs[0].TMPDIR), UV_CACHE_DIR: "/c/uv", TMPDIR: w.envs[0].TMPDIR, FORGE_HOST_PARALLELISM: "3", FORGE_LANE_WORKTREE: "1", GIT_CEILING_DIRECTORIES: w.envs[0].GIT_CEILING_DIRECTORIES, FORGEDOCK_CHECKS_CLI: CHECKS_CLI, FORGEDOCK_ENTRY_CLI: FORGEDOCK_CLI, PATH: "/rt/toolchain/bin:/usr/bin" };
|
|
2834
2790
|
assert.equal(lane.GIT_CEILING_DIRECTORIES.split(":")[0], "/wt", "#5825: lane children are ceiled at the worktree parent");
|
|
2835
2791
|
assert.match(lane.TMPDIR, /\/runs\/7-/, "the builder ran with the run TMPDIR");
|
|
2836
2792
|
assert.deepEqual(w.rgCalls.map((x) => x.env), [lane], "red-green gets the lane env, not the daemon's");
|
|
@@ -2855,10 +2811,39 @@ describe("bug lanes freeze a red-green repro_test (#4271)", () => {
|
|
|
2855
2811
|
assert.equal((await run(fixed, { conformance: "shadow" })).terminalReason, "merged"); assert.equal(fixed.rgCalls.length, 2);
|
|
2856
2812
|
});
|
|
2857
2813
|
|
|
2814
|
+
describe("#6058 a requirement with no status row is skipped, not failed", () => {
|
|
2815
|
+
const two2 = { ...CONTRACT, preserve: [], requirements: [CONTRACT.requirements[0], { id: "R2", quote: "Existing callers of foo keep working.", disposition: "deliver" }],
|
|
2816
|
+
deliverables: [...CONTRACT.deliverables, { id: "D2", path: "src/bar.js", change: "keep callers", requirements: ["R2"] }] };
|
|
2817
|
+
const row = (id) => ({ id, status: "implemented", evidence: "src/foo.js:3" }), runShadow = (w) => run(w, { conformance: "shadow" });
|
|
2818
|
+
it("the one resume names R2 and its quote; a resume that adds the row merges", async () => {
|
|
2819
|
+
const w = world({ contract: two2, claims: [row("R1")], resumeClaims: [row("R1"), row("R2")], reviews: [conf({}, two2)] });
|
|
2820
|
+
const r = await runShadow(w);
|
|
2821
|
+
assert.equal(r.terminalReason, "merged");
|
|
2822
|
+
const resume = builders(w)[2][4];
|
|
2823
|
+
assert.match(resume, /no status row for R2/); assert.match(resume, /R2: "Existing callers of foo keep working\."/);
|
|
2824
|
+
assert.doesNotMatch(resume, /R1:/);
|
|
2825
|
+
});
|
|
2826
|
+
it("still skipped after the targeted resume: a distinct park kind and a detail that says the builder did not address it", async () => {
|
|
2827
|
+
const w = world({ contract: two2, claims: [row("R1")], reviews: [conf({}, two2)] });
|
|
2828
|
+
const r = await runShadow(w);
|
|
2829
|
+
assert.equal(r.terminalReason, "needs-human"); assert.equal(r.kind, "requirement_no_status"); assert.deepEqual(r.requirements, ["R2"]);
|
|
2830
|
+
assert.equal(builders(w).length, 3, "plan + implement + one targeted resume");
|
|
2831
|
+
assert.match(r.detail, /The builder did not address R2: no status row/);
|
|
2832
|
+
assert.match(r.detail, /reported "no status"/, "the census still buckets it");
|
|
2833
|
+
});
|
|
2834
|
+
it("a failing row (not a missing one) keeps the generic resume and park", async () => {
|
|
2835
|
+
const w = world({ contract: two2, claims: [row("R1"), { id: "R2", status: "partial" }], reviews: [conf({}, two2)] });
|
|
2836
|
+
const r = await runShadow(w);
|
|
2837
|
+
assert.equal(r.code, "conformance.unimplemented"); assert.equal(r.kind, undefined);
|
|
2838
|
+
assert.doesNotMatch(builders(w)[2][4], /no status row/);
|
|
2839
|
+
assert.match(builders(w)[2][4], /does not conform/);
|
|
2840
|
+
});
|
|
2841
|
+
});
|
|
2842
|
+
|
|
2858
2843
|
it("#5732 a head that failed on an absent interpreter is env.repro_unrunnable with its output, no builder resume", async () => {
|
|
2859
2844
|
const w = rworld([{ base: "SKIPPED", head: "FAILED" }]);
|
|
2860
2845
|
w.io.runCommand = async () => ({ rc: 1, output: "Creating virtualenv\npoetry env use: python3.11 not found" });
|
|
2861
|
-
const r = await run(w, { conformance: "enforce" });
|
|
2846
|
+
const r = await run(w, { ...ENF, conformance: "enforce" });
|
|
2862
2847
|
assert.equal(r.code, "env.repro_unrunnable"); assert.equal(w.merges.length, 0);
|
|
2863
2848
|
assert.equal(builders(w).length, 2, "plan + implement only");
|
|
2864
2849
|
assert.match(nh(w), /output tail/); assert.match(nh(w), /python3\.11 not found/);
|
|
@@ -2907,7 +2892,7 @@ describe("bug lanes freeze a red-green repro_test (#4271)", () => {
|
|
|
2907
2892
|
for (const conformance of ["enforce", "shadow"]) {
|
|
2908
2893
|
for (const rg of [{ base: "SKIPPED", head: "UNRUNNABLE" }, null]) {
|
|
2909
2894
|
const w = rworld([rg]);
|
|
2910
|
-
const r = await run(w, { conformance });
|
|
2895
|
+
const r = await run(w, { ...ENF, conformance });
|
|
2911
2896
|
assert.equal(r.code, "env.repro_unrunnable", `${conformance} ${JSON.stringify(rg)}`); assert.equal(r.terminalReason, "needs-human");
|
|
2912
2897
|
assert.equal(classifyNeedsHuman(r), "recoverable");
|
|
2913
2898
|
assert.equal(w.merges.length, 0); assert.equal(builders(w).length, 2, "plan + implement, no resume"); assert.equal(reviewers(w).length, 0);
|
|
@@ -3177,17 +3162,17 @@ describe("comment templates", () => {
|
|
|
3177
3162
|
|
|
3178
3163
|
it("#5644 review findings get up to 3 builder resume rounds: replay of a fixable finding that clears in round 3 merges", async () => {
|
|
3179
3164
|
const w = world({ reviews: [bad("round 1"), bad("round 2"), conf()] });
|
|
3180
|
-
const r = await run(w);
|
|
3165
|
+
const r = await run(w, ENF);
|
|
3181
3166
|
assert.equal(r.terminalReason, "merged"); assert.equal(builders(w).length, 4, "build plus two resume rounds");
|
|
3182
3167
|
});
|
|
3183
3168
|
|
|
3184
3169
|
it("#5644 rounds are spent: a changing but never fixed finding ends needs-human after reviewMaxResumes rounds; an unchanged one stops early", async () => {
|
|
3185
3170
|
const w = world({ reviews: [bad("a"), bad("b"), bad("c"), bad("d")] });
|
|
3186
|
-
const r = await run(w);
|
|
3171
|
+
const r = await run(w, ENF);
|
|
3187
3172
|
assert.equal(r.terminalReason, "needs-human"); assert.equal(builders(w).length, 5);
|
|
3188
3173
|
assert.match(traj(w)[0], /after 3 builder resumes/);
|
|
3189
3174
|
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);
|
|
3175
|
+
assert.equal((await run(w2, { ...ENF, reviewMaxResumes: 1 })).terminalReason, "needs-human"); assert.equal(builders(w2).length, 3);
|
|
3191
3176
|
});
|
|
3192
3177
|
|
|
3193
3178
|
it("#5644 builderFixable: regression, deferral, scope are fixable; environment and empty sets are not", () => {
|
|
@@ -3198,7 +3183,7 @@ describe("comment templates", () => {
|
|
|
3198
3183
|
|
|
3199
3184
|
it("a merged run's trajectory and a needs-human run's trajectory carry the right rows", async () => {
|
|
3200
3185
|
const w = world({ reviews: [bad(), bad("still bad")] });
|
|
3201
|
-
await run(w, { reviewMaxResumes: 1 });
|
|
3186
|
+
await run(w, { ...ENF, reviewMaxResumes: 1 });
|
|
3202
3187
|
const t = traj(w)[0];
|
|
3203
3188
|
assert.match(t, /\| Validate \| CONFIRMED \|/);
|
|
3204
3189
|
assert.match(t, /\| Plan \| contract [0-9a-f]{12} \| 1 requirement\(s\) \|/);
|
|
@@ -4237,6 +4222,16 @@ describe("base-sync (#4100)", () => {
|
|
|
4237
4222
|
noRebaseNoForce(w);
|
|
4238
4223
|
});
|
|
4239
4224
|
|
|
4225
|
+
it("#5898 a failed FORGE:BASE_SYNC comment after a resolved base-sync is an anomaly, not an engine-error: the lane merges", async () => {
|
|
4226
|
+
const w = world({ prView: [CONFLICTING, OKSTATE], mergeResults: ["conflict"], reviews: [ok(), ok()] });
|
|
4227
|
+
const post = w.io.gh;
|
|
4228
|
+
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));
|
|
4229
|
+
const r = await run(w);
|
|
4230
|
+
assert.equal(r.terminalReason, "merged");
|
|
4231
|
+
assert.equal(w.merges.length, 1);
|
|
4232
|
+
assert.match(traj(w).join("\n"), /FORGE:BASE_SYNC comment not posted: HTTP 502/);
|
|
4233
|
+
});
|
|
4234
|
+
|
|
4240
4235
|
it("#5583 follow-up: a builder-resolved base-sync with only documentation conflicts and an unchanged code diff skips the re-review", async () => {
|
|
4241
4236
|
const w = world({ prView: [CONFLICTING, OKSTATE], mergeResults: ["conflict"], conflictFiles: ["devdocs/modules/lean.md"], reviews: [ok(), ok()] });
|
|
4242
4237
|
const git = w.io.git;
|
|
@@ -4265,7 +4260,7 @@ describe("base-sync (#4100)", () => {
|
|
|
4265
4260
|
|
|
4266
4261
|
it("conflict resolution that the re-review FAILs gets one retry then merges on PASS", async () => {
|
|
4267
4262
|
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");
|
|
4263
|
+
assert.equal((await run(w, ENF)).terminalReason, "merged");
|
|
4269
4264
|
assert.equal(reviewers(w).length, 3);
|
|
4270
4265
|
assert.equal(builders(w).length, 4);
|
|
4271
4266
|
});
|
|
@@ -4559,6 +4554,33 @@ describe("usage limit, lease takeover, worktree setup, run tmp (#4101-#4104)", (
|
|
|
4559
4554
|
assert.equal(r.account, "3");
|
|
4560
4555
|
});
|
|
4561
4556
|
|
|
4557
|
+
it("#6105 a builder session ended api_error is resumed by id with backoff; the lane continues and nothing is relaunched", async () => {
|
|
4558
|
+
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); };
|
|
4559
|
+
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" });
|
|
4560
|
+
const orig = w.io.runner; let n = 0; const sent = [];
|
|
4561
|
+
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); };
|
|
4562
|
+
const r = await run(w, { dir });
|
|
4563
|
+
assert.equal(r.terminalReason, "merged");
|
|
4564
|
+
const resumed = sent.filter((x) => x.resume === "sess-api");
|
|
4565
|
+
assert.equal(resumed.length, 1, "the failed session is resumed by id");
|
|
4566
|
+
assert.match(resumed[0].prompt, /transient API error/);
|
|
4567
|
+
assert.ok(sleeps.includes(20_000), "backoff before the resume");
|
|
4568
|
+
const log = readLog(dir, 7);
|
|
4569
|
+
assert.equal(log.filter((e) => e.event === "API_ERROR_RESUME").length, 1);
|
|
4570
|
+
assert.equal(log.find((e) => e.event === "RUN_TERMINAL").api_resumes, 1, "resumes are counted apart from relaunches");
|
|
4571
|
+
});
|
|
4572
|
+
|
|
4573
|
+
it("#6105 an api_error that keeps recurring defers backend.cli_failed after the capped resumes (never engine-error)", async () => {
|
|
4574
|
+
const w = world(); projector(w, null);
|
|
4575
|
+
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" });
|
|
4576
|
+
const orig = w.io.runner; let resumes = 0;
|
|
4577
|
+
w.io.runner = async (c) => { if (c.role === "builder") { if (c.resume === "sess-api") resumes++; throw apiErr(); } return orig(c); };
|
|
4578
|
+
const r = await run(w);
|
|
4579
|
+
assert.equal(r.terminalReason, "deferred"); assert.equal(r.code, "backend.cli_failed");
|
|
4580
|
+
assert.equal(resumes, 3, "three resumes, then the deferral");
|
|
4581
|
+
assert.match(r.detail, /transient API error/);
|
|
4582
|
+
});
|
|
4583
|
+
|
|
4562
4584
|
it("#5168 an error that is both a usage limit and auth-like stays rate_limited", async () => {
|
|
4563
4585
|
const w = world();
|
|
4564
4586
|
failFirstBuilder(w, limitErr({ authFailure: true, resetAtEpochMs: 3 * 3600 * 1000, resetAt: "8:30pm" }));
|
|
@@ -4807,7 +4829,7 @@ describe("usage limit, lease takeover, worktree setup, run tmp (#4101-#4104)", (
|
|
|
4807
4829
|
};
|
|
4808
4830
|
for (const [reason, prep] of Object.entries(cases)) {
|
|
4809
4831
|
const w = world(); mk(w); prep(w);
|
|
4810
|
-
const r = await run(w);
|
|
4832
|
+
const r = await run(w, ENF);
|
|
4811
4833
|
assert.equal(r.terminalReason, reason);
|
|
4812
4834
|
assert.equal(w.pruned, true);
|
|
4813
4835
|
assert.equal(w.tmpMade.length, 1);
|
|
@@ -5566,20 +5588,12 @@ describe("batch robustness (#4112-#4115)", () => {
|
|
|
5566
5588
|
|
|
5567
5589
|
it("#5653 a validate command freeze preflight finds unrunnable is rewritten from the CI-derived catalogue before any builder correction", async () => {
|
|
5568
5590
|
const d = tmpDir("lean-5653-"); const src = join(d, "ci.yml"); writeFileSync(src, "run: uv run --with-requirements r.txt pytest tests\n");
|
|
5569
|
-
const contract = { ...CONTRACT, validate: [...CONTRACT.validate, { id: "V2", command: "
|
|
5570
|
-
const w = world({ contract }); w.io.probeCommand = async (a) => ({ rc: /
|
|
5571
|
-
const r = await run(w, { dir: d, validateCatalogSources: [`../..${src}`] });
|
|
5591
|
+
const contract = { ...CONTRACT, validate: [...CONTRACT.validate, { id: "V2", command: "pipenv run pytest t.py" }] };
|
|
5592
|
+
const w = world({ contract }); w.io.probeCommand = async (a) => ({ rc: /pipenv/.test(JSON.stringify(a)) ? 127 : 0, output: "" });
|
|
5593
|
+
const r = await run(w, { dir: d, validateRecipes: [{ match: "\\bpipenv run pytest\\b", replace: "uv run --with-requirements r.txt pytest" }], validateCatalogSources: [`../..${src.replace(/^[A-Za-z]:/, "").split("\\").join("/")}`] }); // #5753: drive-less posix path on Windows
|
|
5572
5594
|
assert.notEqual(r.code, "env.tool_missing");
|
|
5573
5595
|
assert.ok(w.comments.some((c) => c.includes("FORGE:CONTRACT") && c.includes("uv run --with-requirements r.txt pytest t.py")));
|
|
5574
|
-
assert.ok(!w.comments.some((c) => c.includes("FORGE:CONTRACT") && c.includes("
|
|
5575
|
-
});
|
|
5576
|
-
|
|
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/);
|
|
5596
|
+
assert.ok(!w.comments.some((c) => c.includes("FORGE:CONTRACT") && c.includes("pipenv run pytest")));
|
|
5583
5597
|
});
|
|
5584
5598
|
|
|
5585
5599
|
// ---- #4112 ----
|
|
@@ -5770,6 +5784,23 @@ describe("batch robustness (#4112-#4115)", () => {
|
|
|
5770
5784
|
assert.ok(!w.comments.some((c) => c.includes("FORGE:CONTRACT")), "not re-posted");
|
|
5771
5785
|
assert.match(traj(w)[0], /frozen contract [0-9a-f]{12} recovered from the issue/);
|
|
5772
5786
|
});
|
|
5787
|
+
it("#5920 a reused frozen contract gets the validate.recipes rewrite and an audit amendment, once", async () => {
|
|
5788
|
+
const recipes = [{ match: "^node --test ", replace: "node --test --test-reporter=dot " }];
|
|
5789
|
+
const w = world({ prList: [], remote: "abc\trefs/heads/feat/issue-7-lean", lastSubject: "wip(forge): checkpoint after idle timeout", issueComments: [frozenComment()] });
|
|
5790
|
+
const r = await run(w, { validateRecipes: recipes });
|
|
5791
|
+
assert.equal(r.terminalReason, "merged");
|
|
5792
|
+
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");
|
|
5793
|
+
const am = w.comments.filter((c) => c.includes("FORGE:AMENDMENT") && c.includes("rewrite-validate"));
|
|
5794
|
+
assert.equal(am.length, 1);
|
|
5795
|
+
assert.match(am[0], new RegExp(`frozen contract ${contractHash(contractJson(CONTRACT))}`));
|
|
5796
|
+
assert.ok(!am[0].includes("AMENDMENT-STATE"), "audit only: never replayed as an amendment");
|
|
5797
|
+
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" } }] });
|
|
5798
|
+
await run(w2, { validateRecipes: recipes });
|
|
5799
|
+
assert.equal(w2.comments.filter((c) => c.includes("rewrite-validate")).length, 0, "a second reuse posts nothing new");
|
|
5800
|
+
const w3 = world({ prList: [], remote: "abc\trefs/heads/feat/issue-7-lean", lastSubject: "wip(forge): checkpoint after idle timeout", issueComments: [frozenComment()] });
|
|
5801
|
+
await run(w3);
|
|
5802
|
+
assert.ok(!w3.comments.some((c) => c.includes("rewrite-validate")), "no recipe, no amendment");
|
|
5803
|
+
});
|
|
5773
5804
|
it("recovery lane replays accepted supersedes amendment (#4899)", async () => {
|
|
5774
5805
|
const sup = { kind: "supersedes", guard: "#4785", why: "behaviour changed on purpose" };
|
|
5775
5806
|
const state = { contract: contractHash(contractJson(CONTRACT)), amendments: [sup] };
|
|
@@ -5847,11 +5878,11 @@ describe("batch robustness (#4112-#4115)", () => {
|
|
|
5847
5878
|
});
|
|
5848
5879
|
it("#5752 a declared outcome-evidence area touched without a before/after result row blocks with a clear reason", async () => {
|
|
5849
5880
|
const w = world({ prList: [] });
|
|
5850
|
-
await run(w, { outcomeEvidenceConfig: { paths: { core: ["src/**"] }, corpus: { core: ["corpus/**"] } } });
|
|
5881
|
+
await run(w, { ...ENF, outcomeEvidenceConfig: { paths: { core: ["src/**"] }, corpus: { core: ["corpus/**"] } } });
|
|
5851
5882
|
assert.ok(builders(w).length >= 2, "the missing evidence resumes the builder");
|
|
5852
5883
|
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
5884
|
const off = world({ prList: [] });
|
|
5854
|
-
await run(off);
|
|
5885
|
+
await run(off, ENF);
|
|
5855
5886
|
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
5887
|
});
|
|
5857
5888
|
it("#5752 the builder prompt carries the negative-examples rule and the mechanism supersedes amendment", async () => {
|
|
@@ -6265,14 +6296,14 @@ describe("verify-by-CI (#4167): ci mode runs the heavy checks on CI and feeds fa
|
|
|
6265
6296
|
|
|
6266
6297
|
it("without the fix, a validate id left to CI is missing under enforce (the regression this guards)", async () => {
|
|
6267
6298
|
const w = world({ validation: ciValidation });
|
|
6268
|
-
const r = await run(w);
|
|
6299
|
+
const r = await run(w, ENF);
|
|
6269
6300
|
assert.equal(r.terminalReason, "needs-human"); assert.equal(w.merges.length, 0);
|
|
6270
6301
|
});
|
|
6271
6302
|
|
|
6272
6303
|
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
6304
|
const CONFLICTING = { mergeable: "CONFLICTING", mergeStateStatus: "DIRTY" }, OKSTATE = { mergeable: "MERGEABLE", mergeStateStatus: "CLEAN" };
|
|
6274
6305
|
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 });
|
|
6306
|
+
const r = await run(w, { ...ENF, verify: CI });
|
|
6276
6307
|
assert.equal(r.terminalReason, "merged", r.reason);
|
|
6277
6308
|
assert.equal(reviewers(w).length, 3);
|
|
6278
6309
|
assert.equal(new Set(w.ci.runs.map((x) => x.headSha)).size, w.ci.runs.length, "every reviewed head was verified once");
|
|
@@ -6665,9 +6696,17 @@ describe("two repos with the same issue number on one host (#4432)", () => {
|
|
|
6665
6696
|
});
|
|
6666
6697
|
|
|
6667
6698
|
describe("host-aware verification concurrency (#4182)", () => {
|
|
6668
|
-
const host = (o = {}) => ({ memAvailableMb: () => 8192, freeMb: async () => 8192, loadAvg1: () => o.load ?? 1, cores: () => o.cores ?? 4, activeLanes: o.activeLanes ?? (() => o.lanes ?? 2), tmpPaths: () => ["/tmp"] });
|
|
6669
|
-
const withEnv = async (v, fn) => { const prev = process.env.FORGE_HOST_PARALLELISM; if (v === undefined) delete process.env.FORGE_HOST_PARALLELISM; else process.env.FORGE_HOST_PARALLELISM = v;
|
|
6670
|
-
try { return await fn(); } finally { if (prev === undefined) delete process.env.FORGE_HOST_PARALLELISM; else process.env.FORGE_HOST_PARALLELISM = prev; } };
|
|
6699
|
+
const host = (o = {}) => ({ memAvailableMb: () => 8192, freeMb: async () => 8192, loadAvg1: () => o.load ?? 1, cores: () => o.cores ?? 4, activeLanes: o.activeLanes ?? (() => o.lanes ?? 2), tmpPaths: () => ["/tmp"], readFile: o.readFile ?? (() => { throw new Error("ENOENT"); }) });
|
|
6700
|
+
const withEnv = async (v, fn) => { const prev = process.env.FORGE_HOST_PARALLELISM, prevQ = process.env.CS_CPU_QUOTA; delete process.env.CS_CPU_QUOTA; if (v === undefined) delete process.env.FORGE_HOST_PARALLELISM; else process.env.FORGE_HOST_PARALLELISM = v;
|
|
6701
|
+
try { return await fn(); } finally { if (prev === undefined) delete process.env.FORGE_HOST_PARALLELISM; else process.env.FORGE_HOST_PARALLELISM = prev; if (prevQ !== undefined) process.env.CS_CPU_QUOTA = prevQ; } };
|
|
6702
|
+
|
|
6703
|
+
it("#4182 a cgroup cpu quota below the VM cores caps the workers (read through io.host.readFile)", async () => {
|
|
6704
|
+
await withEnv(undefined, async () => {
|
|
6705
|
+
const w = world(); w.io.host = host({ cores: 8, lanes: 1, readFile: (f) => { if (f === "/sys/fs/cgroup/cpu.max") return "200000 100000"; throw new Error("ENOENT"); } });
|
|
6706
|
+
await run(w, { governor: false });
|
|
6707
|
+
for (const e of w.envs) assert.equal(e?.FORGE_HOST_PARALLELISM, "2");
|
|
6708
|
+
});
|
|
6709
|
+
});
|
|
6671
6710
|
|
|
6672
6711
|
it("#4182 hostParallelism = max(1, floor(cores / lanes)); bad inputs count as 1", () => {
|
|
6673
6712
|
assert.equal(hostParallelism({ cores: 4, lanes: 2 }), 2);
|
|
@@ -6961,7 +7000,7 @@ describe("local-mode CI fix rounds at merge and declared pre-PR check commands (
|
|
|
6961
7000
|
it("pre-PR: declared commands run in the lane worktree; a failing one goes back to the builder before PR_OPENED", async () => {
|
|
6962
7001
|
const w = world(); const ran = [];
|
|
6963
7002
|
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
|
|
7003
|
+
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
7004
|
const inner = w.io.runner;
|
|
6966
7005
|
w.io.runner = async (c) => { if (/declared check commands failed/.test(c.prompt)) rc = 0; return inner(c); };
|
|
6967
7006
|
const dir = tmpDir("core-");
|
|
@@ -6970,7 +7009,7 @@ describe("local-mode CI fix rounds at merge and declared pre-PR check commands (
|
|
|
6970
7009
|
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
7010
|
assert.equal(ran[0][2], 300000);
|
|
6972
7011
|
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
|
|
7012
|
+
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
7013
|
assert.ok(w.seq.indexOf("builder", w.seq.indexOf("check:1")) < w.seq.indexOf("pr"), "the fix runs before the PR is opened");
|
|
6975
7014
|
const log = readLog(dir, 7);
|
|
6976
7015
|
const pre = log.filter((e) => e.event === "PRECHECK_COMMANDS");
|
|
@@ -7058,6 +7097,28 @@ describe("local-mode CI fix rounds at merge and declared pre-PR check commands (
|
|
|
7058
7097
|
assert.equal(builders(w).length, 2, "no builder fix round spent on a base failure");
|
|
7059
7098
|
});
|
|
7060
7099
|
|
|
7100
|
+
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 () => {
|
|
7101
|
+
const w = world({ changed: ["app/routers/listing_feeds.py", "test/foo.test.js"] }); let laneRuns = 0;
|
|
7102
|
+
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: "" });
|
|
7103
|
+
const r = await run(w, { verify: { invariants: ["bash scripts/guard.sh"] } });
|
|
7104
|
+
assert.notEqual(r.code, "base.red"); assert.ok(laneRuns >= 2, "the guard was re-run on the lane tree");
|
|
7105
|
+
});
|
|
7106
|
+
|
|
7107
|
+
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 () => {
|
|
7108
|
+
const w = world({ changed: ["app/routers/listing_feeds.py"] });
|
|
7109
|
+
w.io.runCommand = async () => ({ rc: 1, output: "bare 429 at app/routers/listing_feeds.py" });
|
|
7110
|
+
const r = await run(w, { verify: { invariants: ["bash scripts/guard.sh"] } });
|
|
7111
|
+
assert.equal(r.code, "base.red"); assert.equal(w.merges.length, 0);
|
|
7112
|
+
assert.match(JSON.stringify(r), /--owner-requested/);
|
|
7113
|
+
});
|
|
7114
|
+
|
|
7115
|
+
it("#5913 diffTouchesGuard is true only when a changed file is named by the failing guard", () => {
|
|
7116
|
+
const failed = [{ command: "bash scripts/guard.sh", output: "bare 429 at app/routers/listing_feeds.py" }];
|
|
7117
|
+
assert.equal(diffTouchesGuard({ changed: ["./app/routers/listing_feeds.py"], failed }), true);
|
|
7118
|
+
assert.equal(diffTouchesGuard({ changed: ["src/foo.js"], failed }), false);
|
|
7119
|
+
assert.equal(diffTouchesGuard({ changed: [], failed }), false);
|
|
7120
|
+
});
|
|
7121
|
+
|
|
7061
7122
|
it("#5945 an env-signature base failure is not base.red and files nothing; a host verify pass skips filing", async () => {
|
|
7062
7123
|
for (const hook of [false, true]) {
|
|
7063
7124
|
const w = world(); const filed = [], gh = w.io.gh;
|
|
@@ -7640,12 +7701,12 @@ describe("context pack modes (forge#4275)", () => {
|
|
|
7640
7701
|
it("write-back: the terminal FORGE:STATE carries the typed outcome code and failure classes the compiler reads", async () => {
|
|
7641
7702
|
const w = world({ reviews: [bad(), bad()] });
|
|
7642
7703
|
w.leaseWrites = []; w.io.projector = { readState: async () => null, writeState: async (_i, st) => { w.leaseWrites.push(st); } };
|
|
7643
|
-
const r = await run(w);
|
|
7704
|
+
const r = await run(w, ENF);
|
|
7644
7705
|
assert.equal(r.terminalReason, "needs-human");
|
|
7645
7706
|
const last = w.leaseWrites.at(-1);
|
|
7646
7707
|
assert.deepEqual([last.terminal, last.terminalReason, last.terminalCode, last.failureClasses], [true, "needs-human", OUTCOME_CODES.CONFORMANCE_UNIMPLEMENTED, [OUTCOME_CODES.CONFORMANCE_UNIMPLEMENTED]]);
|
|
7647
7708
|
const m = world(); m.leaseWrites = []; m.io.projector = { readState: async () => null, writeState: async (_i, st) => { m.leaseWrites.push(st); } };
|
|
7648
|
-
await run(m);
|
|
7709
|
+
await run(m, ENF);
|
|
7649
7710
|
assert.deepEqual([m.leaseWrites.at(-1).terminalCode, m.leaseWrites.at(-1).failureClasses], [OUTCOME_CODES.COMPLETED, []]);
|
|
7650
7711
|
});
|
|
7651
7712
|
|
|
@@ -8077,7 +8138,7 @@ describe("#4363 fresh fix sessions", () => {
|
|
|
8077
8138
|
const FRESH = /no earlier session/;
|
|
8078
8139
|
const prechecked = (o = {}) => {
|
|
8079
8140
|
const w = world(o); let rc = 1;
|
|
8080
|
-
w.io.runCommand = async () => ({ rc, output: rc ? `${"
|
|
8141
|
+
w.io.runCommand = async () => ({ rc, output: rc ? `${"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n".repeat(4700)}lint: src/foo.js:3 unused var` /* many lines: one unbroken 300K line makes the output redaction quadratic and stalls the file */ : "" });
|
|
8081
8142
|
const inner = w.io.runner;
|
|
8082
8143
|
w.io.runner = async (c) => { const res = await inner(c); if (/declared check commands failed/.test(c.prompt) && !o.freshNoCommit) rc = 0; return res; };
|
|
8083
8144
|
return w;
|
|
@@ -8121,15 +8182,15 @@ describe("#4363 fresh fix sessions", () => {
|
|
|
8121
8182
|
|
|
8122
8183
|
it("a conformance FAIL citing file:line is fresh; one without a file:line resumes; the one review retry is unchanged", async () => {
|
|
8123
8184
|
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");
|
|
8185
|
+
assert.equal((await run(w1, { ...ENF, dir: d1 })).terminalReason, "merged");
|
|
8125
8186
|
assert.deepEqual(usage(d1).map((e) => e.mode ?? null), [null, null, "fresh"]);
|
|
8126
8187
|
const vague = conf({ verdict: "NONCONFORMING", requirements: [{ id: "R1", status: "partial", evidence: "the foo module", validated_by: "V1", note: "null still throws" }] });
|
|
8127
8188
|
const w2 = world({ reviews: [vague, ok()] }); const d2 = tmpDir("core-");
|
|
8128
|
-
assert.equal((await run(w2, { dir: d2 })).terminalReason, "merged");
|
|
8189
|
+
assert.equal((await run(w2, { ...ENF, dir: d2 })).terminalReason, "merged");
|
|
8129
8190
|
assert.equal(builders(w2)[2][2], "sess-1");
|
|
8130
8191
|
assert.deepEqual(usage(d2).map((e) => e.mode ?? null), [null, null, "resume"]);
|
|
8131
8192
|
const w3 = world({ reviews: [bad(), bad(), bad()] });
|
|
8132
|
-
const r3 = await run(w3);
|
|
8193
|
+
const r3 = await run(w3, ENF);
|
|
8133
8194
|
assert.equal(r3.terminalReason, "needs-human"); assert.equal(reviewers(w3).length, 2, "still one review retry");
|
|
8134
8195
|
});
|
|
8135
8196
|
});
|
|
@@ -8868,14 +8929,14 @@ describe("#4394 builder model routing", () => {
|
|
|
8868
8929
|
|
|
8869
8930
|
it("a conformance fix round on the mid tier does not escalate and keeps the fix model", async () => {
|
|
8870
8931
|
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");
|
|
8932
|
+
assert.equal((await run(w, { ...ENF, dir, builderModel: "opus-b", fixModel: "haiku-fix" })).terminalReason, "merged");
|
|
8872
8933
|
assert.equal(builders(w)[2][3], "haiku-fix");
|
|
8873
8934
|
assert.deepEqual(events(dir, "BUILDER_ESCALATED"), []);
|
|
8874
8935
|
});
|
|
8875
8936
|
|
|
8876
8937
|
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
8938
|
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" } });
|
|
8939
|
+
await run(w, { ...ENF, dir, builderModel: "opus-b", builderRouting: { mode: "off" } });
|
|
8879
8940
|
assert.ok(builders(w).length >= 3);
|
|
8880
8941
|
assert.ok(builders(w).every((b) => b[3] === "opus-b"));
|
|
8881
8942
|
const term = events(dir, "RUN_TERMINAL").at(-1);
|
|
@@ -9121,28 +9182,6 @@ describe("#4450 light lane: one builder session, derived contract, upgrade to th
|
|
|
9121
9182
|
const events = (dir, name) => readLog(dir, 7).filter((e) => e.event === name);
|
|
9122
9183
|
const ON = { light: { mode: "on", source: "text" } };
|
|
9123
9184
|
|
|
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
9185
|
|
|
9147
9186
|
it("#5751 recurrence: no matching history keeps the light lane and the plan prompt unchanged", async () => {
|
|
9148
9187
|
const w = lworld(), dir = tmpDir("light-");
|
|
@@ -9492,7 +9531,7 @@ describe("#5237 relaxation gate", () => {
|
|
|
9492
9531
|
};
|
|
9493
9532
|
it("relaxation without a negative test blocks (relaxation_untested) in a risk path", async () => {
|
|
9494
9533
|
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/**"] } });
|
|
9534
|
+
const r = await run(w, { ...ENF, dir: tmpDir("relax-"), reviewTrigger: { mode: "shadow", riskPaths: ["src/**"] } });
|
|
9496
9535
|
assert.equal(w.merges.length, 0); assert.equal(r.code, "conformance.unimplemented");
|
|
9497
9536
|
});
|
|
9498
9537
|
it("a negative test lets it through, and the verifier runs even with review.verifier off, fed the hunk", async () => {
|
|
@@ -9903,22 +9942,6 @@ describe("spec-only page gate failures end design.spec_required (#5729)", () =>
|
|
|
9903
9942
|
const pagesConfig = { ...parsePagesConfig(undefined, { hasAppPages: true }), require: ["design"] };
|
|
9904
9943
|
const link = (h, x = "") => `<Link href="${h}"${x}>Book a demo</Link>`;
|
|
9905
9944
|
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
9945
|
});
|
|
9923
9946
|
|
|
9924
9947
|
describe("classification record in the plan prompt (#5557)", () => {
|
|
@@ -10152,6 +10175,30 @@ describe("#5820 required CI checks run in the lane before the PR opens", () => {
|
|
|
10152
10175
|
assert.match(p2.unrunnable[0].reason, /CI check plan unavailable: yq not found/);
|
|
10153
10176
|
});
|
|
10154
10177
|
|
|
10178
|
+
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 () => {
|
|
10179
|
+
const fmt = ciJob("fmt", "Format check", "black --check .");
|
|
10180
|
+
const plan = { version: 1, repo: WT, jobs: [ciJob("lint", "Lint", "pnpm lint"), fmt] };
|
|
10181
|
+
let broken = true; const asked = [];
|
|
10182
|
+
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" }) });
|
|
10183
|
+
const byBranch = []; w.io.requiredChecks = async (b) => { byBranch.push(b); return b === "main" ? ["Format check", "Wiring audit"] : ["Lint"]; };
|
|
10184
|
+
const inner = w.io.runner;
|
|
10185
|
+
w.io.runner = async (c) => { if (/declared check commands failed/.test(c.prompt)) broken = false; return inner(c); };
|
|
10186
|
+
const issues = []; const gh = w.io.gh;
|
|
10187
|
+
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); };
|
|
10188
|
+
const dir = tmpDir("core-");
|
|
10189
|
+
await run(w, { dir });
|
|
10190
|
+
assert.ok(byBranch.includes("main"), `the release branch's required checks are read (read: ${byBranch})`);
|
|
10191
|
+
const log = readLog(dir, 7);
|
|
10192
|
+
const p = log.find((e) => e.event === "CI_PRECHECK_PLAN");
|
|
10193
|
+
assert.ok(p.commands.some((c) => c.job === "gha:ci:fmt" && /on release branch/.test(c.why)));
|
|
10194
|
+
assert.ok(log.filter((e) => e.event === "CI_PRECHECK_RESULT")[0].results.some((x) => x.status === "fail"));
|
|
10195
|
+
assert.ok(w.seq.indexOf("ci-precheck") < w.seq.indexOf("pr"));
|
|
10196
|
+
const par = log.filter((e) => e.event === "CI_PRECHECK_PARITY");
|
|
10197
|
+
assert.deepEqual(par[0].gaps.map((g) => g.context), ["Wiring audit"]);
|
|
10198
|
+
assert.equal(issues.length, 1, "one issue per gap, not re-filed on the fix round");
|
|
10199
|
+
assert.match(issues[0].body, /FORGE:PARITY_GAP Wiring audit/);
|
|
10200
|
+
});
|
|
10201
|
+
|
|
10155
10202
|
it("lean.ci_precheck off runs nothing and logs no plan", async () => {
|
|
10156
10203
|
const w = ciWorld(); const dir = tmpDir("core-");
|
|
10157
10204
|
await run(w, { dir, precheck: { ci: { mode: "off", include: [], exclude: [], maxJobs: 8 } } });
|
|
@@ -10160,6 +10207,234 @@ describe("#5820 required CI checks run in the lane before the PR opens", () => {
|
|
|
10160
10207
|
});
|
|
10161
10208
|
});
|
|
10162
10209
|
|
|
10210
|
+
describe("#5749 freeze-time runnability: host-only commands, recipes, check tails", () => {
|
|
10211
|
+
const remote = { placement: { where: "remote", reason: "mode remote" } };
|
|
10212
|
+
const V2 = (command) => ({ ...CONTRACT, validate: [...CONTRACT.validate, { id: "V2", command }] });
|
|
10213
|
+
it("#5749 host-only validate is rejected at freeze", async () => {
|
|
10214
|
+
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'`) });
|
|
10215
|
+
const r = await run(w, { dir: tmpDir("lean-5749a-"), ...remote });
|
|
10216
|
+
assert.equal(r.code, "contract.invalid"); assert.equal(w.merges.length, 0);
|
|
10217
|
+
assert.ok(builders(w).some((b) => /legion-run/.test(b[4])), "the correction prompt names the host-only wrapper");
|
|
10218
|
+
assert.equal((await run(world({ contract: V2("npx vitest run a.test.ts") }), { dir: tmpDir("lean-5749a2-"), ...remote })).terminalReason, "merged");
|
|
10219
|
+
});
|
|
10220
|
+
it("#5749 remote probe installs a recipe tool or re-places before the builder", async () => {
|
|
10221
|
+
const installed = []; let ok = false;
|
|
10222
|
+
const w = world({ contract: V2("pg_dump x") });
|
|
10223
|
+
w.io.runCommand = async ({ command }) => { if (/apt-get/.test(command)) { installed.push(command); ok = true; } return { rc: 0, output: "" }; };
|
|
10224
|
+
w.io.probeCommand = async (a) => ({ rc: /pg_dump/.test(JSON.stringify(a)) && !ok ? 127 : 0, output: "" });
|
|
10225
|
+
assert.notEqual((await run(w, { dir: tmpDir("lean-5749b-"), ...remote })).code, "env.tool_missing");
|
|
10226
|
+
assert.equal(installed.length, 1);
|
|
10227
|
+
const n = world({ contract: V2("nopetool-5749 x") }); n.io.probeCommand = async (a) => ({ rc: /nopetool-5749/.test(JSON.stringify(a)) ? 127 : 0, output: "" });
|
|
10228
|
+
const r = await run(n, { dir: tmpDir("lean-5749b2-"), ...remote });
|
|
10229
|
+
assert.equal(r.code, "env.tool_missing");
|
|
10230
|
+
});
|
|
10231
|
+
it("#5749 remote lane with every tool keeps remote placement", async () => {
|
|
10232
|
+
const w = world({ contract: V2("shellcheck scripts/x.sh") }); w.io.probeCommand = async () => ({ rc: 0, output: "" });
|
|
10233
|
+
const installs = []; w.io.runCommand = async ({ command }) => { installs.push(command); return { rc: 0, output: "" }; };
|
|
10234
|
+
const r = await run(w, { dir: tmpDir("lean-5749c-"), ...remote });
|
|
10235
|
+
assert.equal(r.terminalReason, "merged"); assert.ok(!installs.some((c) => /apt-get/.test(c)));
|
|
10236
|
+
});
|
|
10237
|
+
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 () => {
|
|
10238
|
+
const w = world(); const prepared = [];
|
|
10239
|
+
w.io.deps = { prepare: async () => { prepared.push(1); return []; } };
|
|
10240
|
+
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" });
|
|
10241
|
+
const r = await atIdleLoad(() => run(w, { precheck: { commands: ["make lint"] }, verify: { ...parseVerify({}), precheckBlock: true } }));
|
|
10242
|
+
assert.equal(r.code, "env.tool_missing"); assert.equal(r.terminalReason, "needs-human");
|
|
10243
|
+
assert.ok(prepared.length >= 2, "deps prepared at setup and once more after the missing tool");
|
|
10244
|
+
assert.equal(builders(w).filter((b) => /declared check commands failed/.test(b[4])).length, 0, "no builder resume");
|
|
10245
|
+
});
|
|
10246
|
+
it("#6138 a module missing at run time (isolated interpreter) is installed system-wide once, then env.tool_missing, never ci.red", async () => {
|
|
10247
|
+
const w = world(); const cmds = [];
|
|
10248
|
+
w.io.runCommand = async ({ command }) => { cmds.push(command); return /pip install/.test(command) ? { rc: 0, output: "" } : { rc: 1, output: "Traceback\nModuleNotFoundError: No module named 'yaml'" }; };
|
|
10249
|
+
const r = await atIdleLoad(() => run(w, { precheck: { commands: ["python3 -I check.py"] }, verify: { ...parseVerify({}), precheckBlock: true } }));
|
|
10250
|
+
assert.equal(r.code, "env.tool_missing");
|
|
10251
|
+
const installs = cmds.filter((c) => /pip install/.test(c));
|
|
10252
|
+
assert.equal(installs.length, 1); assert.doesNotMatch(installs[0], /--user/);
|
|
10253
|
+
});
|
|
10254
|
+
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 () => {
|
|
10255
|
+
const out = "not ok 3 - ten concurrent\n location: '/w/bin/tests/mirror-script.test.mjs:48:3'";
|
|
10256
|
+
const w = world(); let n = 0;
|
|
10257
|
+
w.io.runCommand = async () => (++n === 1 ? { rc: 1, output: out } : { rc: 0, output: "" });
|
|
10258
|
+
const r = await atIdleLoad(() => run(w, { precheck: { commands: ["make test"] }, verify: { ...parseVerify({}), precheckBlock: true } }));
|
|
10259
|
+
assert.equal(r.terminalReason, "merged"); assert.equal(n, 2);
|
|
10260
|
+
assert.equal(builders(w).filter((b) => /declared check commands failed/.test(b[4])).length, 0);
|
|
10261
|
+
const w2 = world(), dir2 = tmpDir("lean-6094-");
|
|
10262
|
+
w2.io.runCommand = async () => ({ rc: 1, output: out });
|
|
10263
|
+
const r2 = await atIdleLoad(() => run(w2, { dir: dir2, precheck: { commands: ["make test"] }, verify: { ...parseVerify({}), precheckBlock: true } }));
|
|
10264
|
+
assert.equal(r2.code, "ci.red"); assert.equal(readLog(dir2, 7).filter((e) => e.event === "PRECHECK_FLAKE_RERUN").length, 1, "exactly one rerun");
|
|
10265
|
+
const w3 = world(), dir3 = tmpDir("lean-6094b-"); // a failure in a test the diff touches is the lane's: no rerun
|
|
10266
|
+
w3.io.runCommand = async () => ({ rc: 1, output: "not ok 1 - x\n location: 'test/foo.test.js:4:1'" });
|
|
10267
|
+
await atIdleLoad(() => run(w3, { dir: dir3, precheck: { commands: ["make test"] }, verify: { ...parseVerify({}), precheckBlock: true } }));
|
|
10268
|
+
assert.equal(readLog(dir3, 7).filter((e) => e.event === "PRECHECK_FLAKE_RERUN").length, 0);
|
|
10269
|
+
});
|
|
10270
|
+
it("#5749 precheck_block detail carries the failing check tail", async () => {
|
|
10271
|
+
const w = world();
|
|
10272
|
+
w.io.runCommand = async () => ({ rc: 1, output: `${"noise\n".repeat(60)}FAILED lane-check shellcheck scripts/x.sh` });
|
|
10273
|
+
const r = await atIdleLoad(() => run(w, { precheck: { commands: ["make lanecheck"] }, verify: { ...parseVerify({}), precheckBlock: true } }));
|
|
10274
|
+
assert.equal(r.code, "ci.red");
|
|
10275
|
+
assert.match((w.comments.find((c) => c.includes("FORGE:NEEDS_HUMAN")) ?? ""), /`make lanecheck`[\s\S]*FAILED lane-check shellcheck scripts\/x\.sh/);
|
|
10276
|
+
});
|
|
10277
|
+
});
|
|
10278
|
+
|
|
10279
|
+
describe("#6107 precheck parks carry the failing check; a ci.red recovery runs the checks on a synced tree", () => {
|
|
10280
|
+
const block = { precheck: { commands: ["make lanecheck"] }, verify: { ...parseVerify({}), precheckBlock: true } };
|
|
10281
|
+
const nhOf = (w) => w.comments.find((c) => c.includes("FORGE:NEEDS_HUMAN")) ?? "";
|
|
10282
|
+
it("the park names the failing check and carries only its last 40 lines, secrets redacted, and the run log has them too", async () => {
|
|
10283
|
+
const w = world(); const dir = tmpDir("lean-6107-");
|
|
10284
|
+
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` });
|
|
10285
|
+
const r = await atIdleLoad(() => run(w, { dir, ...block }));
|
|
10286
|
+
assert.equal(r.code, "ci.red");
|
|
10287
|
+
const nh = nhOf(w);
|
|
10288
|
+
assert.match(nh, /Failing check `make lanecheck`, exit 1, last 40 lines/);
|
|
10289
|
+
assert.match(nh, /FAILED lane-check shellcheck scripts\/x\.sh/);
|
|
10290
|
+
assert.doesNotMatch(nh, /EARLY-NOISE-MARKER/); assert.doesNotMatch(nh, /hunter2hunter2|abcdefghijklmnop/);
|
|
10291
|
+
const rec = readLog(dir, 7).find((e) => e.event === "PRECHECK_FAILED");
|
|
10292
|
+
assert.equal(rec.checks[0].command, "make lanecheck"); assert.match(rec.checks[0].tail, /FAILED lane-check/); assert.doesNotMatch(rec.checks[0].tail, /hunter2hunter2/);
|
|
10293
|
+
});
|
|
10294
|
+
it("a ci.red recovery that is behind its base merges the base before any check runs", async () => {
|
|
10295
|
+
const w = world({ behind: 2 }); const order = [];
|
|
10296
|
+
w.io.runCommand = async () => { order.push("check"); return { rc: 0, output: "" }; };
|
|
10297
|
+
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); };
|
|
10298
|
+
const r = await atIdleLoad(() => run(w, { recover: { code: "ci.red", attempt: 1 }, precheck: { commands: ["make lanecheck"] } }));
|
|
10299
|
+
assert.equal(r.terminalReason, "merged");
|
|
10300
|
+
assert.ok(order.indexOf("merge") >= 0 && order.indexOf("merge") < order.indexOf("check"), `merge before check: ${order}`);
|
|
10301
|
+
});
|
|
10302
|
+
it("a ci.red recovery whose branch conflicts with the base ends base.conflict and never runs the checks on the stale tree", async () => {
|
|
10303
|
+
const w = world({ behind: 3, mergeResults: ["conflict"], conflictFiles: [".github/workflows/ci.yml"] }); let checks = 0;
|
|
10304
|
+
w.io.runCommand = async () => { checks++; return { rc: 1, output: "stale tree failure" }; };
|
|
10305
|
+
const r = await atIdleLoad(() => run(w, { recover: { code: "ci.red", attempt: 1 }, ...block }));
|
|
10306
|
+
assert.equal(r.code, "base.conflict"); assert.equal(checks, 0); assert.equal(w.merges.length, 0);
|
|
10307
|
+
assert.ok(w.calls.some((c) => c[0] === "git" && c[1] === "merge" && c[2] === "--abort"));
|
|
10308
|
+
});
|
|
10309
|
+
it("a first lane (no recovery) does not base-sync before the checks", async () => {
|
|
10310
|
+
const w = world({ behind: 2 });
|
|
10311
|
+
w.io.runCommand = async () => ({ rc: 0, output: "" });
|
|
10312
|
+
await atIdleLoad(() => run(w, { precheck: { commands: ["make lanecheck"] } }));
|
|
10313
|
+
assert.equal(w.calls.filter((c) => c[0] === "git" && c[1] === "merge" && c[2] === "--no-edit").length, 0);
|
|
10314
|
+
});
|
|
10315
|
+
});
|
|
10316
|
+
|
|
10317
|
+
describe("#6153 a failing precheck on a lane behind its base is rerun once on the merged tree", () => {
|
|
10318
|
+
const block = { precheck: { commands: ["make lanecheck"] }, verify: { ...parseVerify({}), precheckBlock: true } };
|
|
10319
|
+
const track = (w, rcFor) => { const st = { merged: 0, checks: 0 }; const orig = w.io.git; w.io.git = async (a, ...rest) => { if (a[0] === "merge" && a[1] === "--no-edit") st.merged++; return orig(a, ...rest); }; w.io.runCommand = async () => { st.checks++; return rcFor(st); }; return st; };
|
|
10320
|
+
it("a check the base fixed passes after the base-sync: no ci.red, no builder round", async () => {
|
|
10321
|
+
const w = world({ behind: 2 });
|
|
10322
|
+
const st = track(w, (s) => (s.merged ? { rc: 0, output: "" } : { rc: 1, output: "lane-checks exit 1 (old guard script)" }));
|
|
10323
|
+
const r = await atIdleLoad(() => run(w, block));
|
|
10324
|
+
assert.equal(r.terminalReason, "merged"); assert.equal(st.merged, 1); assert.equal(st.checks, 2);
|
|
10325
|
+
});
|
|
10326
|
+
it("a tool_missing-shaped failure is also rerun on the merged tree before env.tool_missing", async () => {
|
|
10327
|
+
const w = world({ behind: 1 });
|
|
10328
|
+
const st = track(w, (s) => (s.merged ? { rc: 0, output: "" } : { rc: 127, output: "bash: shellcheck: command not found" }));
|
|
10329
|
+
const r = await atIdleLoad(() => run(w, block));
|
|
10330
|
+
assert.equal(r.terminalReason, "merged"); assert.equal(st.merged, 1);
|
|
10331
|
+
});
|
|
10332
|
+
it("still failing after the sync is classified as before, with exactly one sync", async () => {
|
|
10333
|
+
const w = world({ behind: 2 });
|
|
10334
|
+
const st = track(w, () => ({ rc: 1, output: "FAILED real failure" }));
|
|
10335
|
+
const r = await atIdleLoad(() => run(w, block));
|
|
10336
|
+
assert.equal(r.code, "ci.red"); assert.equal(st.merged, 1);
|
|
10337
|
+
});
|
|
10338
|
+
it("a lane not behind its base is not synced and fails as before", async () => {
|
|
10339
|
+
const w = world({ behind: 0 });
|
|
10340
|
+
const st = track(w, () => ({ rc: 1, output: "FAILED real failure" }));
|
|
10341
|
+
const r = await atIdleLoad(() => run(w, block));
|
|
10342
|
+
assert.equal(r.code, "ci.red"); assert.equal(st.merged, 0);
|
|
10343
|
+
});
|
|
10344
|
+
it("a base the resolvers cannot merge does not park the lane: the merge is aborted and the checks are judged as before", async () => {
|
|
10345
|
+
const w = world({ behind: 2, mergeResults: ["conflict"], conflictFiles: ["scripts/lane-checks.sh"] });
|
|
10346
|
+
track(w, () => ({ rc: 1, output: "old guard" }));
|
|
10347
|
+
const r = await atIdleLoad(() => run(w, block));
|
|
10348
|
+
assert.notEqual(r.code, "base.conflict", "the early sync never parks on a conflict; the PR-time base-sync lets the builder resolve it");
|
|
10349
|
+
assert.equal(r.code, "ci.red");
|
|
10350
|
+
});
|
|
10351
|
+
it("an env.tool_missing recovery base-syncs before its first check", async () => {
|
|
10352
|
+
const w = world({ behind: 2 }); const order = [];
|
|
10353
|
+
w.io.runCommand = async () => { order.push("check"); return { rc: 0, output: "" }; };
|
|
10354
|
+
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); };
|
|
10355
|
+
const r = await atIdleLoad(() => run(w, { recover: { code: "env.tool_missing", attempt: 1 }, precheck: { commands: ["make lanecheck"] } }));
|
|
10356
|
+
assert.equal(r.terminalReason, "merged");
|
|
10357
|
+
assert.ok(order.indexOf("merge") >= 0 && order.indexOf("merge") < order.indexOf("check"), `merge before check: ${order}`);
|
|
10358
|
+
});
|
|
10359
|
+
});
|
|
10360
|
+
|
|
10361
|
+
describe("#5844 a busy host is not an absent CLI", () => {
|
|
10362
|
+
const base = { role: "builder", issue: 5844, cwd: "/tmp/x", model: "m", prompt: "p", system: "s" };
|
|
10363
|
+
it("probe timeout does not spawn a bare name", async () => {
|
|
10364
|
+
const { makeLeanRunner } = await import("./effects.mjs");
|
|
10365
|
+
let spawned = 0;
|
|
10366
|
+
const runner = makeLeanRunner({ runCli: async () => { spawned++; return {}; }, probe: () => false, resolveBin: () => null, probeTimedOut: () => true });
|
|
10367
|
+
await assert.rejects(runner(base), (e) => e.deferCode === OUTCOME_CODES.HOST_BUSY && e.retryInSeconds > 0 && e.spawnDeterministic !== true);
|
|
10368
|
+
assert.equal(spawned, 0);
|
|
10369
|
+
});
|
|
10370
|
+
it("a probe that answered absent still spawns, so the deterministic path stays reachable", async () => {
|
|
10371
|
+
const { makeLeanRunner } = await import("./effects.mjs");
|
|
10372
|
+
let spawned = 0;
|
|
10373
|
+
const runner = makeLeanRunner({ runCli: async () => { spawned++; return {}; }, probe: () => false, resolveBin: () => null, probeTimedOut: () => false });
|
|
10374
|
+
await runner(base);
|
|
10375
|
+
assert.equal(spawned, 1);
|
|
10376
|
+
});
|
|
10377
|
+
it("win32 bare name unresolved while the CLI is present defers host.busy, nothing spawned", async () => {
|
|
10378
|
+
const { makeLeanRunner } = await import("./effects.mjs");
|
|
10379
|
+
let spawned = 0;
|
|
10380
|
+
const runner = makeLeanRunner({ runCli: async () => { spawned++; return {}; }, probe: () => false, resolveBin: () => null, probeTimedOut: () => false, platform: "win32", binMissing: () => false });
|
|
10381
|
+
await assert.rejects(runner(base), (e) => e.deferCode === OUTCOME_CODES.HOST_BUSY && e.spawnDeterministic !== true);
|
|
10382
|
+
assert.equal(spawned, 0);
|
|
10383
|
+
const absent = makeLeanRunner({ runCli: async () => { spawned++; return {}; }, probe: () => false, resolveBin: () => null, probeTimedOut: () => false, platform: "win32", binMissing: () => true });
|
|
10384
|
+
await absent(base);
|
|
10385
|
+
assert.equal(spawned, 1, "proven absence still spawns so cli.spawn_failed stays reachable");
|
|
10386
|
+
});
|
|
10387
|
+
it("ENOENT with the CLI present is not cli.spawn_failed", async () => {
|
|
10388
|
+
const { runCliBackend } = await import("../runner.mjs");
|
|
10389
|
+
const dir = tmpDir("core-5844-");
|
|
10390
|
+
writeFileSync(join(dir, "claude"), "");
|
|
10391
|
+
const prev = process.env.PATH; process.env.PATH = dir;
|
|
10392
|
+
let err;
|
|
10393
|
+
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; }
|
|
10394
|
+
assert.equal(err.spawnDeterministic, undefined);
|
|
10395
|
+
assert.notEqual(err.code, "CLI_SPAWN_FAILED");
|
|
10396
|
+
const w = world(); w.io.runner = async () => { throw err; };
|
|
10397
|
+
const res = await run(w);
|
|
10398
|
+
assert.notEqual(res.code, OUTCOME_CODES.CLI_SPAWN_FAILED);
|
|
10399
|
+
});
|
|
10400
|
+
});
|
|
10401
|
+
|
|
10402
|
+
describe("#5753 frozen pytest commands run in the env CI runs them in", () => {
|
|
10403
|
+
const saved = {}; // #5753: a host ~/.forge/guards/o_r.json (another run's leftovers) must not add H-rows to these runs
|
|
10404
|
+
before(() => { for (const k of ["HOME", "USERPROFILE"]) saved[k] = process.env[k]; process.env.HOME = process.env.USERPROFILE = tmpDir("lean-5753-home-"); });
|
|
10405
|
+
after(() => { for (const [k, v] of Object.entries(saved)) if (v === undefined) delete process.env[k]; else process.env[k] = v; });
|
|
10406
|
+
it("#5753 a shared/ pytest validate is rewritten at freeze to the services/worker CI env and the freeze records it", async () => {
|
|
10407
|
+
const d = tmpDir("lean-5753a-"); const src = join(d, "ci.yml");
|
|
10408
|
+
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");
|
|
10409
|
+
const contract = { ...CONTRACT, validate: [...CONTRACT.validate, { id: "V2", command: "python -m pytest shared/detection/test_x.py" }] };
|
|
10410
|
+
const w = world({ contract }); w.io.probeCommand = async () => ({ rc: 0, output: "" });
|
|
10411
|
+
await run(w, { dir: d, validateCatalogSources: [`../..${src.replace(/^[A-Za-z]:/, "").replace(/\\/g, "/")}`] });
|
|
10412
|
+
assert.ok(w.comments.some((c) => c.includes("FORGE:CONTRACT") && c.includes("cd services/worker && poetry run pytest ../../shared/detection/test_x.py")));
|
|
10413
|
+
assert.ok(!w.comments.some((c) => c.includes("FORGE:CONTRACT") && c.includes("python -m pytest shared/detection/test_x.py")));
|
|
10414
|
+
});
|
|
10415
|
+
it("#5753 a collect-only ImportError is a preflight miss corrected before the implement builder", async () => {
|
|
10416
|
+
const V2 = "python3 -m pytest -q tests/test_corpus.py";
|
|
10417
|
+
const c = { ...CONTRACT, validate: [...CONTRACT.validate, { id: "V2", command: V2 }] };
|
|
10418
|
+
const fixed = { ...c, validate: [c.validate[0], { id: "V2", command: "uv run pytest -q tests/test_corpus.py" }] };
|
|
10419
|
+
const dir = tmpDir("lean-5753b-");
|
|
10420
|
+
const w = world({ contract: c, fixedContract: fixed, validation: fixed.validate.map((v) => ({ id: v.id, command: v.command, exit: 0 })) });
|
|
10421
|
+
const collected = [];
|
|
10422
|
+
w.io.probeCommand = async () => ({ rc: 0, output: "" });
|
|
10423
|
+
w.io.preflightRun = async (a) => {
|
|
10424
|
+
if (/--collect-only/.test(a.command)) collected.push([a.command, w.seq.length]);
|
|
10425
|
+
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" };
|
|
10426
|
+
};
|
|
10427
|
+
assert.equal((await run(w, { dir })).terminalReason, "merged");
|
|
10428
|
+
const b = builders(w);
|
|
10429
|
+
assert.equal(b.length, 3, "plan + one contract correction + implement");
|
|
10430
|
+
assert.match(b[1][4], /V2: importing its test modules on the base worktree \(pytest --collect-only\) failed: needs Python module 'html2text'/);
|
|
10431
|
+
assert.ok(collected.some(([cmd]) => cmd === "python3 -m pytest --collect-only -q -q tests/test_corpus.py"));
|
|
10432
|
+
const firstImpl = w.seq.indexOf("builder-resume", w.seq.indexOf("builder-resume") + 1);
|
|
10433
|
+
assert.ok(collected.every(([, at]) => at < firstImpl), "every collect-only run happens before the implement session");
|
|
10434
|
+
const pf = readLog(dir, 7).filter((e) => e.event === "VALIDATE_PREFLIGHT");
|
|
10435
|
+
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"]]]]);
|
|
10436
|
+
});
|
|
10437
|
+
});
|
|
10163
10438
|
describe("#5992 verify.guard_bypass: a lane clear of the red guard's files proceeds", () => {
|
|
10164
10439
|
it("bypasses only when opted in and the lane diff misses the guarded files", async () => {
|
|
10165
10440
|
for (const opt of [false, true]) {
|
|
@@ -10223,3 +10498,24 @@ describe("#6008 lease/hold/pause guard before push and merge (kept sandbox)", ()
|
|
|
10223
10498
|
assert.equal((await run(w)).terminalReason, "merged");
|
|
10224
10499
|
});
|
|
10225
10500
|
});
|
|
10501
|
+
|
|
10502
|
+
describe("gate cut (#6083): advisory by default, enforce re-promotes", () => {
|
|
10503
|
+
it("a reviewer unimplemented row without a failing assertion is recorded and the lane merges; enforce makes it block", async () => {
|
|
10504
|
+
const w = world({ reviews: [bad("still null-derefs")] });
|
|
10505
|
+
const r = await run(w);
|
|
10506
|
+
assert.equal(r.terminalReason, "merged"); assert.equal(builders(w).length, 2, "no resume spent");
|
|
10507
|
+
assert.match(traj(w).join("\n"), /Advisory \(not blocking\)[^\n]*conformance\.unimplemented/);
|
|
10508
|
+
const w2 = world({ reviews: [bad("still null-derefs"), bad("still null-derefs")] });
|
|
10509
|
+
assert.equal((await run(w2, ENF)).terminalReason, "needs-human");
|
|
10510
|
+
});
|
|
10511
|
+
it("a validate step with no recorded result is advisory: the lane merges without a resume", async () => {
|
|
10512
|
+
const w = world({ validation: [] });
|
|
10513
|
+
const r = await run(w);
|
|
10514
|
+
assert.equal(r.terminalReason, "merged"); assert.equal(builders(w).length, 2);
|
|
10515
|
+
assert.match(traj(w).join("\n"), /Advisory \(not blocking\)[^\n]*validate_missing/);
|
|
10516
|
+
});
|
|
10517
|
+
it("a reviewer regression row still blocks", async () => {
|
|
10518
|
+
const w = world({ reviews: [conf({ regressions: [{ at: "src/bar.js:4", failure: "caller passes undefined" }] }), ok()] });
|
|
10519
|
+
assert.equal((await run(w)).terminalReason, "merged"); assert.equal(builders(w).length, 3, "the regression is resumed");
|
|
10520
|
+
});
|
|
10521
|
+
});
|