forgedock 1.63.0 → 1.64.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 +3 -0
- package/bin/engine/outcome-codes.mjs +5 -0
- package/bin/engine-cli.mjs +88 -12
- package/bin/env/cli.mjs +18 -1
- package/bin/lean/basered.mjs +56 -11
- package/bin/lean/basered.test.mjs +58 -5
- package/bin/lean/batch-health.mjs +46 -4
- package/bin/lean/batch-health.test.mjs +55 -1
- package/bin/lean/batch.mjs +6 -1
- package/bin/lean/batch.test.mjs +71 -6
- package/bin/lean/ceiling.mjs +47 -3
- package/bin/lean/ceiling.test.mjs +32 -1
- package/bin/lean/conformance.e2e.test.mjs +32 -6
- package/bin/lean/conformance.mjs +57 -13
- package/bin/lean/conformance.test.mjs +93 -1
- package/bin/lean/execution.mjs +15 -6
- package/bin/lean/execution.test.mjs +44 -3
- package/bin/lean/issuewatch-reconcile.mjs +2 -0
- package/bin/lean/issuewatch-reconcile.test.mjs +25 -0
- package/bin/lean/issuewatch.mjs +3 -0
- package/bin/lean/lanecheck.test.mjs +13 -1
- package/bin/lean/lean.mjs +157 -28
- package/bin/lean/lean.test.mjs +289 -21
- package/bin/lean/live-execution.mjs +25 -0
- package/bin/lean/live-execution.test.mjs +35 -1
- package/bin/lean/merged-park.mjs +76 -0
- package/bin/lean/merged-park.test.mjs +64 -0
- package/bin/lean/mergetrain.mjs +357 -0
- package/bin/lean/mergetrain.test.mjs +348 -0
- package/bin/lean/orchestrate-envhold.test.mjs +62 -0
- package/bin/lean/orchestrate-stacking.test.mjs +23 -1
- package/bin/lean/orchestrate-train.test.mjs +130 -0
- package/bin/lean/orchestrate-transient-git.test.mjs +53 -0
- package/bin/lean/orchestrate.mjs +159 -13
- package/bin/lean/prompts.mjs +4 -3
- package/bin/lean/release-review.mjs +8 -1
- package/bin/lean/release-review.test.mjs +42 -2
- package/bin/lean/release-status.test.mjs +53 -1
- package/bin/lean/release.mjs +6 -3
- package/bin/lean/render.mjs +6 -1
- package/bin/lean/sandbox-provider.contract.test.mjs +6 -0
- package/bin/lean/sandbox-remote.mjs +12 -2
- package/bin/lean/sched.mjs +19 -2
- package/bin/lean/sched.test.mjs +33 -1
- package/bin/lean/schedd-health.mjs +2 -1
- package/bin/lean/schedd-health.test.mjs +7 -0
- package/bin/lean/schedd.mjs +55 -7
- package/bin/lean/schedd.test.mjs +42 -1
- package/bin/lean/stacking.mjs +45 -0
- package/bin/lean/stacking.test.mjs +25 -1
- package/bin/lean/statuscomment.mjs +14 -8
- package/bin/lean/statuscomment.test.mjs +18 -1
- package/bin/lean/validate-catalog.mjs +1 -1
- package/bin/lean/validate-catalog.test.mjs +3 -0
- package/bin/lean/worktree.mjs +8 -3
- package/bin/lean/worktree.test.mjs +18 -0
- package/bin/pool/agent.mjs +296 -31
- package/bin/pool/cli.mjs +120 -6
- package/bin/pool/disk.mjs +43 -0
- package/bin/pool/docker.mjs +10 -0
- package/bin/pool/health.mjs +95 -0
- package/bin/pool/router.mjs +274 -27
- package/bin/runner.mjs +3 -1
- package/bin/stats/chains.mjs +101 -0
- package/bin/stats/chains.test.mjs +53 -0
- package/bin/stats/efficiency.mjs +7 -6
- package/bin/stats/efficiency.test.mjs +48 -7
- package/bin/stats/index.mjs +11 -3
- package/bin/stats/stats.test.mjs +9 -0
- package/docs/CONFIG.md +8 -1
- package/docs/OUTCOME-CODES.md +4 -0
- package/package.json +1 -1
- package/pool/README.md +10 -0
- package/pool/image/Dockerfile +2 -1
- package/pool/image/entrypoint.sh +6 -6
- package/pool/image/mirror.sh +71 -0
- package/pool/install/install-agent-linux.sh +57 -5
- package/pool/install/install-agent-macos.sh +148 -0
- package/pool/install/install-agent.ps1 +11 -0
- package/pool/install/install-agent.sh +59 -7
- package/pool/install/uninstall-agent-linux.sh +75 -0
- package/pool/install/uninstall-agent-macos.sh +60 -0
- package/pool/install/uninstall-agent.ps1 +1 -0
- package/scripts/transition-label.sh +11 -0
package/bin/lean/lean.test.mjs
CHANGED
|
@@ -230,7 +230,7 @@ function world(o = {}) {
|
|
|
230
230
|
waitCiGreen: async () => (w.waits.length ? w.waits.shift() : { rc: 0, text: `CI_GATE_HEAD: ${w.head}` }),
|
|
231
231
|
transitionLabel: async (n, s) => { w.labels.push(s); w.seq.push(`label:${s}`); },
|
|
232
232
|
...(o.procs ? { proc: { inDir: async () => o.procs, alive: (pid) => w.alive.has(pid), kill: (pid, sig) => { w.kills.push([pid, sig]); w.seq.push(`kill-${sig}`); if (sig === "SIGKILL" || !o.stubborn) w.alive.delete(pid); } } } : {}),
|
|
233
|
-
fs: { ...(o.wtExists ? { exists: async (p) => posix(p).startsWith("/wt/lean-7") } : {}), stat: async (p) => (posix(p) in w.files ? { mtimeMs: w.mtimes[posix(p)] ?? 1 } : null), read: async (p) => { if (!(posix(p) in w.files)) throw new Error("ENOENT"); return w.files[posix(p)]; }, append: async (p, t) => { w.files[posix(p)] = (w.files[posix(p)] ?? "") + t; }, write: async (p, t) => { w.files[posix(p)] = t; }},
|
|
233
|
+
fs: { ...(o.wtExists ? { exists: async (p) => posix(p).startsWith("/wt/lean-7") || posix(p) === "/repo" } : {}), stat: async (p) => (posix(p) in w.files ? { mtimeMs: w.mtimes[posix(p)] ?? 1 } : null), read: async (p) => { if (!(posix(p) in w.files)) throw new Error("ENOENT"); return w.files[posix(p)]; }, append: async (p, t) => { w.files[posix(p)] = (w.files[posix(p)] ?? "") + t; }, write: async (p, t) => { w.files[posix(p)] = t; }},
|
|
234
234
|
fileFollowups: async ({ parent, items }) => { w.followups.push({ parent, items }); if (o.followupError) throw Object.assign(new Error(o.followupError), { stdout: o.followupStdout ?? "" });
|
|
235
235
|
if (o.followupRet) return o.followupRet(w.followups.length, items);
|
|
236
236
|
if (w.followups.length <= (o.followupFailTimes ?? 0)) throw new Error("DEFERRED_LOOKUP=FAILED"); if (w.followups.length <= (o.followupMissingTimes ?? 0)) return {}; return Object.fromEntries(items.filter((i) => !(o.followupSkip ?? []).some((q) => JSON.stringify(i).includes(q))).map((i) => [i.key, o.followupIssue ?? 900])); },
|
|
@@ -1211,6 +1211,68 @@ describe("core work-on", () => {
|
|
|
1211
1211
|
assert.equal(w.merges.length, 0);
|
|
1212
1212
|
assert.equal(r.code, "merge.stacked_base");
|
|
1213
1213
|
});
|
|
1214
|
+
/** #5833: the dependency's PR list entry follows `dep.list`; `pr close` and `push --delete` are recorded. */
|
|
1215
|
+
const cascading = (w, list) => {
|
|
1216
|
+
const gh = w.io.gh, git = w.io.git;
|
|
1217
|
+
w.closes = []; w.deletes = []; w.merged = [];
|
|
1218
|
+
w.io.gh = async (a) => {
|
|
1219
|
+
if (a[0] === "pr" && a[1] === "list" && a.includes("--head") && a[a.indexOf("--head") + 1] === STACK.branch) return JSON.stringify(list());
|
|
1220
|
+
if (a[0] === "pr" && a[1] === "close") { w.closes.push(a.join(" ")); return ""; }
|
|
1221
|
+
return gh(a);
|
|
1222
|
+
};
|
|
1223
|
+
w.io.git = async (a, o) => {
|
|
1224
|
+
if (a[0] === "push" && a.includes("--delete")) { w.deletes.push(a.join(" ")); return ""; }
|
|
1225
|
+
return git(a, o);
|
|
1226
|
+
};
|
|
1227
|
+
return w;
|
|
1228
|
+
};
|
|
1229
|
+
it("merge.stacked_base (#5908): an open dependency PR wins over an older merged PR on the reused branch name; nothing merges or retargets", async () => {
|
|
1230
|
+
const w = cascading(stacked(world(), { depState: "OPEN" }), () => [{ number: 3, state: "MERGED" }, { number: 5, state: "OPEN", headRefOid: STACK.sha }]);
|
|
1231
|
+
const r = await run(w, { stackedOn: STACK, ciMaxMinutes: 0 });
|
|
1232
|
+
assert.equal(w.merges.length, 0, "no gh pr merge");
|
|
1233
|
+
assert.equal(w.stack.base, STACK.branch, "never retargeted");
|
|
1234
|
+
assert.notEqual(r.terminalReason, "merged");
|
|
1235
|
+
});
|
|
1236
|
+
it("cascade replan: a dependency that ended without merging drops the stacked PR and branch, defers with stack.replan, never merges", async () => {
|
|
1237
|
+
const w = cascading(stacked(world(), { depState: "CLOSED" }), () => [{ number: 5, state: "CLOSED" }]);
|
|
1238
|
+
const r = await run(w, { stackedOn: STACK });
|
|
1239
|
+
assert.equal(r.terminalReason, "deferred");
|
|
1240
|
+
assert.equal(r.code, "stack.replan");
|
|
1241
|
+
assert.equal(r.cascade, "replan");
|
|
1242
|
+
assert.deepEqual(r.cascades, ["replan"]);
|
|
1243
|
+
assert.equal(w.closes.length, 1);
|
|
1244
|
+
assert.equal(w.deletes.length, 1);
|
|
1245
|
+
assert.equal(w.merges.length, 0);
|
|
1246
|
+
});
|
|
1247
|
+
it("cascade restart: the dependency head moved and the rebase conflicts: PR and branch dropped, deferred with stack.restart from the frozen contract", async () => {
|
|
1248
|
+
const w = cascading(stacked(world(), { depState: "OPEN" }), () => [{ number: 5, state: "OPEN", headRefOid: "b".repeat(40) }]);
|
|
1249
|
+
const git = w.io.git;
|
|
1250
|
+
w.io.git = async (a, o) => { if (a[0] === "merge" && a.includes("--no-commit")) throw new Error("CONFLICT"); return git(a, o); };
|
|
1251
|
+
const r = await run(w, { stackedOn: STACK });
|
|
1252
|
+
assert.equal(r.code, "stack.restart");
|
|
1253
|
+
assert.equal(r.cascade, "restart");
|
|
1254
|
+
assert.equal(w.closes.length, 1);
|
|
1255
|
+
assert.equal(w.merges.length, 0);
|
|
1256
|
+
});
|
|
1257
|
+
it("cascade rebase: the dependency merged: retargeted to the lane, the cascade and its rework are recorded on the result", async () => {
|
|
1258
|
+
const w = cascading(stacked(world(), { depState: "MERGED" }), () => [{ number: 5, state: "MERGED" }]);
|
|
1259
|
+
const r = await run(w, { stackedOn: STACK });
|
|
1260
|
+
assert.equal(r.terminalReason, "merged", r.detail);
|
|
1261
|
+
assert.equal(r.cascade, "rebase");
|
|
1262
|
+
assert.deepEqual(r.cascades, ["rebase"]);
|
|
1263
|
+
assert.ok(Number.isFinite(r.cascade_minutes) && Number.isFinite(r.cascade_cost_usd));
|
|
1264
|
+
assert.deepEqual(w.stack.edits, ["staging"]);
|
|
1265
|
+
});
|
|
1266
|
+
it("cascade reverify: a moved dependency head with a clean rebase re-verifies, then still merges only after the dependency merged", async () => {
|
|
1267
|
+
let polls = 0;
|
|
1268
|
+
const w = cascading(stacked(world(), { depState: "OPEN" }), () => (++polls === 1 ? [{ number: 5, state: "OPEN", headRefOid: "b".repeat(40) }] : [{ number: 5, state: "MERGED" }]));
|
|
1269
|
+
const r = await run(w, { stackedOn: STACK });
|
|
1270
|
+
assert.equal(r.terminalReason, "merged", r.detail);
|
|
1271
|
+
assert.deepEqual(r.cascades, ["reverify", "rebase"]);
|
|
1272
|
+
assert.equal(r.cascade, "rebase");
|
|
1273
|
+
assert.equal(w.merges.length, 1);
|
|
1274
|
+
assert.ok(w.stack.edits.length === 1, "retargeted once, after the dependency merged");
|
|
1275
|
+
});
|
|
1214
1276
|
it("without stackedOn the PR targets the lane and an open dependency still refuses (preserved)", async () => {
|
|
1215
1277
|
const w = stacked(world());
|
|
1216
1278
|
const r = await run(w);
|
|
@@ -1447,6 +1509,16 @@ describe("conformance gate (frozen contract, precheck, structured review)", () =
|
|
|
1447
1509
|
assert.doesNotMatch(traj(w).join("\n"), /left open as partial/);
|
|
1448
1510
|
});
|
|
1449
1511
|
|
|
1512
|
+
it("#5839 merge train on: close-time records (a still-pending follow-up) hand over with a keepOpen post-merge record", async () => {
|
|
1513
|
+
const k = two("defer", { why: "w" });
|
|
1514
|
+
const w = world({ contract: k, claims: [{ id: "R1", status: "implemented" }], reviews: [conf({}, k)], issueStates: { 900: "CLOSED" } });
|
|
1515
|
+
w.io.requiredChecks = async () => ["build"]; w.io.checkStates = async () => [{ name: "build", state: "pending" }];
|
|
1516
|
+
const r = await run(w, { mergeTrain: "on", ciMaxMinutes: 5 });
|
|
1517
|
+
assert.equal(r.terminalReason, "pr-ready"); assert.equal(w.merges.length, 0);
|
|
1518
|
+
assert.equal(r.postMerge.keepOpen, true); assert.ok(r.postMerge.pendingFollowups.length >= 1);
|
|
1519
|
+
assert.ok(r.postMerge.notes.some((n) => n.marker === "FORGE:FOLLOWUP_PENDING"));
|
|
1520
|
+
});
|
|
1521
|
+
|
|
1450
1522
|
it("a tracking issue that is not open is not a tracking issue: the item stays pending and is recorded", async () => {
|
|
1451
1523
|
const k = two("defer", { why: "w" });
|
|
1452
1524
|
const w = world({ contract: k, claims: [{ id: "R1", status: "implemented" }], reviews: [conf({}, k)], issueStates: { 900: "CLOSED" } });
|
|
@@ -1742,6 +1814,23 @@ describe("worktree salvage and orphaned processes (#4162)", () => {
|
|
|
1742
1814
|
assert.equal((await run(w)).terminalReason, "merged");
|
|
1743
1815
|
assert.equal(salvageRefs(w).length, 0);
|
|
1744
1816
|
});
|
|
1817
|
+
it("5890 repo_missing: a missing repo cwd ends deferred sandbox.repo_missing with a retry, before fetch or worktree add", async () => {
|
|
1818
|
+
const w = world({ wtExists: true });
|
|
1819
|
+
w.io.fs.exists = async () => false;
|
|
1820
|
+
const r = await run(w, { dir: tmpDir("core-5890-a-") });
|
|
1821
|
+
assert.equal(r.terminalReason, "deferred");
|
|
1822
|
+
assert.equal(r.code, "sandbox.repo_missing");
|
|
1823
|
+
assert.equal(r.retryInSeconds, 120);
|
|
1824
|
+
assert.ok(!w.calls.some((c) => c[0] === "git" && (c[1] === "fetch" || c[1] === "worktree")), "no fetch or worktree call ran");
|
|
1825
|
+
});
|
|
1826
|
+
it("5890 repo_missing: a raw spawn ENOENT from worktree add maps to the same code, never engine-error", async () => {
|
|
1827
|
+
const w = world();
|
|
1828
|
+
const git0 = w.io.git;
|
|
1829
|
+
w.io.git = async (a, o) => { if (a[0] === "worktree" && a[1] === "add") throw Object.assign(new Error("spawn git ENOENT"), { code: "ENOENT", syscall: "spawn git", path: "git" }); return git0(a, o); };
|
|
1830
|
+
const r = await run(w, { dir: tmpDir("core-5890-b-") });
|
|
1831
|
+
assert.equal(r.terminalReason, "deferred");
|
|
1832
|
+
assert.equal(r.code, "sandbox.repo_missing");
|
|
1833
|
+
});
|
|
1745
1834
|
// #5825: a lane folder that is not this repo's worktree is never salvaged or written to with git
|
|
1746
1835
|
const NOT_LINKED = { ok: false, why: "the lane folder has no .git link (not a git worktree)", evidence: { worktree: WT } };
|
|
1747
1836
|
const gitIdx5825 = (w, f) => w.calls.findIndex((c) => c[0] === "git" && f(c.slice(1)));
|
|
@@ -1749,7 +1838,7 @@ describe("worktree salvage and orphaned processes (#4162)", () => {
|
|
|
1749
1838
|
const dir = tmpDir("core-5825-q-");
|
|
1750
1839
|
const w = world({ wtExists: true, salvageTrees: [T1] });
|
|
1751
1840
|
let gone = false; const moved = [];
|
|
1752
|
-
w.io.fs.exists = async (p) => !gone && p.startsWith(WT);
|
|
1841
|
+
w.io.fs.exists = async (p) => p === "/repo" || (!gone && p.startsWith(WT));
|
|
1753
1842
|
const git0 = w.io.git;
|
|
1754
1843
|
w.io.git = async (a, o) => { if (a[0] === "worktree" && a[1] === "add") gone = false; return git0(a, o); };
|
|
1755
1844
|
w.io.confine = { verify: async () => (moved.length ? { ok: true } : NOT_LINKED), quarantine: async ({ wt }) => { moved.push(wt); gone = true; return "/wt/.quarantine/lean-7-1"; } };
|
|
@@ -1954,13 +2043,13 @@ describe("conformance shadow mode (the default)", () => {
|
|
|
1954
2043
|
assert.equal(r.code, OUTCOME_CODES.ENV_TOOL_MISSING, conformance); assert.equal(w.merges.length, 0);
|
|
1955
2044
|
assert.equal(builders(w).length, 2, "plan + implement only"); assert.equal(reviewers(w).length, 0);
|
|
1956
2045
|
assert.match(nhBody(w), /Environment error \(not a conformance failure\): the host is missing yaml/);
|
|
1957
|
-
assert.deepEqual(ran.map((a) => [a.command, a.cwd]), [["node --test test/foo.test.js", WT]], "only the failed contract validate is rerun, in the worktree");
|
|
2046
|
+
assert.deepEqual(ran.map((a) => [a.command, posix(a.cwd)]), [["node --test test/foo.test.js", WT]], "only the failed contract validate is rerun, in the worktree");
|
|
1958
2047
|
assert.ok(ran[0].env && typeof ran[0].env === "object", "the rerun gets the lane env");
|
|
1959
2048
|
}
|
|
1960
2049
|
});
|
|
1961
2050
|
it("#5371 a remote lane whose frozen validate fails ends env.validate_placement (output tail kept); the local recovery lane keeps the real failure terminal", async () => {
|
|
1962
2051
|
const v = [{ id: "V1", command: "node --test test/foo.test.js", exit: 1 }];
|
|
1963
|
-
const rerun = async () => ({ rc: 1, output: "1
|
|
2052
|
+
const rerun = async () => ({ rc: 1, output: "connect ECONNREFUSED 127.0.0.1:5432\nTOKEN=abcd1234secretvalue\nassertion x" });
|
|
1964
2053
|
const w = world({ validation: v }); w.io.runCommand = rerun;
|
|
1965
2054
|
const r = await run(w, { conformance: "enforce", placement: { where: "remote", reason: "mode remote" } });
|
|
1966
2055
|
assert.equal(r.code, ENV_VALIDATE_PLACEMENT); assert.equal(classifyNeedsHuman(r), "recoverable"); assert.equal(w.merges.length, 0);
|
|
@@ -1974,6 +2063,29 @@ describe("conformance shadow mode (the default)", () => {
|
|
|
1974
2063
|
const ok = world({ validation: v }); ok.io.runCommand = async () => ({ rc: 0, output: "" });
|
|
1975
2064
|
assert.equal((await run(ok, { conformance: "enforce", placement: { where: "local", reason: "x" }, recover: { code: ENV_VALIDATE_PLACEMENT, attempt: 1, final: true } })).terminalReason, "merged");
|
|
1976
2065
|
});
|
|
2066
|
+
const remoteV = { conformance: "enforce", placement: { where: "remote", reason: "mode remote" } };
|
|
2067
|
+
const v5730 = [{ id: "V1", command: "node --test test/foo.test.js", exit: 1 }];
|
|
2068
|
+
it("5730: remote validate_failed with stale-artifact output resumes the builder", async () => {
|
|
2069
|
+
const stale = "listings/official/maps/maps-places/agent.md: missing or out of date (run --render-agent-md --render-page)";
|
|
2070
|
+
for (const output of [stale, "not ok 1 - foo\n AssertionError: expected 3, got 4"]) {
|
|
2071
|
+
const w = world({ validation: v5730 }); w.io.runCommand = async () => ({ rc: 1, output });
|
|
2072
|
+
const r = await run(w, remoteV);
|
|
2073
|
+
assert.notEqual(r.code, ENV_VALIDATE_PLACEMENT, output); assert.ok(builders(w).length >= 3, "the builder resumes");
|
|
2074
|
+
}
|
|
2075
|
+
});
|
|
2076
|
+
it("5730: env-signature validate_failed hand-off includes the sandbox output tail", async () => {
|
|
2077
|
+
for (const output of ["sh: 1: foo-tool: command not found\nsandbox-only-line", "connect ECONNREFUSED 127.0.0.1:5432\nsandbox-only-line"]) {
|
|
2078
|
+
const w = world({ validation: v5730 }); w.io.runCommand = async () => ({ rc: 1, output });
|
|
2079
|
+
const r = await run(w, remoteV);
|
|
2080
|
+
assert.ok([ENV_VALIDATE_PLACEMENT, "env.tool_missing"].includes(r.code), r.code);
|
|
2081
|
+
if (r.code === ENV_VALIDATE_PLACEMENT) { assert.equal(builders(w).length, 2); assert.match(nhBody(w), /Sandbox output tail/); assert.match(nhBody(w), /sandbox-only-line/); }
|
|
2082
|
+
}
|
|
2083
|
+
});
|
|
2084
|
+
it("5730: a recovery lane whose host replay fails the same way ends conformance.unimplemented, not another placement hop", async () => {
|
|
2085
|
+
const w = world({ validation: v5730 }); w.io.runCommand = async () => ({ rc: 1, output: "connect ECONNREFUSED 127.0.0.1:5432" });
|
|
2086
|
+
const r = await run(w, { ...remoteV, recover: { code: ENV_VALIDATE_PLACEMENT, attempt: 1, final: true } });
|
|
2087
|
+
assert.equal(r.code, "conformance.unimplemented"); assert.equal(w.merges.length, 0); assert.equal(builders(w).length, 3);
|
|
2088
|
+
});
|
|
1977
2089
|
it("#4906 a validate rerun that times out (rc 124) ends env.validate_timeout: recoverable, no builder resume, never conformance.unimplemented", async () => {
|
|
1978
2090
|
const v = [{ id: "V1", command: "node --test test/foo.test.js", exit: 124 }];
|
|
1979
2091
|
for (const conformance of ["shadow", "enforce"]) {
|
|
@@ -1999,7 +2111,7 @@ describe("conformance shadow mode (the default)", () => {
|
|
|
1999
2111
|
const rb = await run(bad.w, { conformance: "enforce", dir });
|
|
2000
2112
|
assert.equal(rb.terminalReason, "needs-human"); assert.equal(bad.w.merges.length, 0);
|
|
2001
2113
|
assert.match(nhBody(bad.w), /frozen command runs and fails \(exit 1\)/);
|
|
2002
|
-
assert.ok(bad.ran.some((a) => a.command === "node --test test/foo.test.js" && a.cwd === WT && a.env), "the frozen command is rerun in the worktree with the lane env");
|
|
2114
|
+
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");
|
|
2003
2115
|
assert.deepEqual(readLog(dir, 7).filter((e) => e.event === "SUBSTITUTE_RERUN").map((e) => e.runs), [[{ id: "V1", rc: 1 }], [{ id: "V1", rc: 1 }]]);
|
|
2004
2116
|
const good = lane({ rc: 1, output: "no tests ran: no test files matched test/foo.test.js" });
|
|
2005
2117
|
assert.equal((await run(good.w, { conformance: "enforce" })).terminalReason, "merged");
|
|
@@ -2056,6 +2168,79 @@ describe("conformance shadow mode (the default)", () => {
|
|
|
2056
2168
|
assert.match(restart, /validate G1/); assert.match(restart, /fixing one failure/);
|
|
2057
2169
|
assert.doesNotMatch(restart, /The engine froze \.forge-lean\/contract\.json/);
|
|
2058
2170
|
});
|
|
2171
|
+
it("#5829 builder continues past 120K on a 1M model and emits tokens before and after", async () => {
|
|
2172
|
+
const w = world(), dir = tmpDir("core-ctx1m-"), orig = w.io.runner, seen = [];
|
|
2173
|
+
w.io.runner = async (c) => {
|
|
2174
|
+
if (c.role === "builder") seen.push(c.contextMax ?? 0);
|
|
2175
|
+
const r = await orig(c); return c.role === "builder" && c.contextMax > 0 ? { ...r, endTokens: 600000 } : r;
|
|
2176
|
+
};
|
|
2177
|
+
const r = await run(w, { dir, builderModel: "claude-opus-5-5[1m]", builderRouting: { mode: "off" }, contextRestartCostUsd: 10 });
|
|
2178
|
+
assert.equal(r.terminalReason, "merged");
|
|
2179
|
+
assert.equal(seen[1], 900000, "the gate lets the session run past the 500000 ceiling to the real limit");
|
|
2180
|
+
const log = readLog(dir, 7);
|
|
2181
|
+
assert.ok(log.some((e) => e.event === "CONTEXT_CONTINUED" && e.tokens_before === 500000 && e.tokens_after === 600000));
|
|
2182
|
+
assert.ok(!log.some((e) => e.event === "CONTEXT_CEILING"), "no restart");
|
|
2183
|
+
assert.equal(r.context.restarts, 0); assert.equal(r.context.continues, 1);
|
|
2184
|
+
});
|
|
2185
|
+
it("#5829 a 1M model with no explicit ceiling gets about 500K; at the real limit the builder restarts via the digest", async () => {
|
|
2186
|
+
const w = world({ dirty: true }), dir = tmpDir("core-ctxlim-"), orig = w.io.runner, seen = []; let n = 0;
|
|
2187
|
+
w.io.runner = async (c) => {
|
|
2188
|
+
if (c.role === "builder") seen.push({ contextMax: c.contextMax ?? 0, resume: c.resume ?? null, prompt: c.prompt });
|
|
2189
|
+
if (c.role === "builder" && n++ === 1) throw Object.assign(new Error("ctx"), { code: "CLI_CONTEXT", context: 950000, contextMax: 450000, turns: 80, usage: null });
|
|
2190
|
+
return orig(c);
|
|
2191
|
+
};
|
|
2192
|
+
const r = await run(w, { dir, builderModel: "claude-opus-5-5[1m]", builderRouting: { mode: "off" }, contextRestartCostUsd: 0.01 });
|
|
2193
|
+
assert.equal(seen[1].contextMax, 500000, "model-aware default ceiling");
|
|
2194
|
+
assert.equal(seen[2].resume, null); assert.match(seen[2].prompt, /The engine froze \.forge-lean\/contract\.json/);
|
|
2195
|
+
assert.equal(r.context.restarts, 1);
|
|
2196
|
+
});
|
|
2197
|
+
it("#5829 a session continued past the ceiling that reaches the real limit restarts via the digest", async () => {
|
|
2198
|
+
const w = world({ dirty: true }), dir = tmpDir("core-ctxreal-"), orig = w.io.runner, seen = []; let n = 0;
|
|
2199
|
+
w.io.runner = async (c) => {
|
|
2200
|
+
if (c.role === "builder") seen.push({ contextMax: c.contextMax ?? 0, resume: c.resume ?? null, prompt: c.prompt });
|
|
2201
|
+
if (c.role === "builder" && n++ === 1) throw Object.assign(new Error("ctx"), { code: "CLI_CONTEXT", context: 900000, contextMax: 900000, turns: 90, usage: null });
|
|
2202
|
+
return orig(c);
|
|
2203
|
+
};
|
|
2204
|
+
await run(w, { dir, builderModel: "claude-opus-5-5[1m]", builderRouting: { mode: "off" }, contextRestartCostUsd: 10 });
|
|
2205
|
+
assert.equal(seen[1].contextMax, 900000); assert.equal(seen[2].resume, null); assert.match(seen[2].prompt, /The engine froze/);
|
|
2206
|
+
assert.ok(readLog(dir, 7).some((e) => e.event === "CONTEXT_CEILING" && e.real_limit === true && e.context_tokens === 900000));
|
|
2207
|
+
});
|
|
2208
|
+
it("#5829 a session stopped at the ceiling is compacted in place and continues with tokens before and after; a failed compaction falls back to the digest restart", async () => {
|
|
2209
|
+
for (const ok of [true, false]) {
|
|
2210
|
+
const w = world({ dirty: true }), dir = tmpDir("core-ctxcompact-"), orig = w.io.runner, seen = []; let n = 0;
|
|
2211
|
+
w.io.runner = async (c) => {
|
|
2212
|
+
if (c.role === "builder") seen.push({ prompt: c.prompt, resume: c.resume ?? null });
|
|
2213
|
+
if (c.role === "builder" && c.prompt === "/compact") { if (!ok) throw new Error("compact unavailable"); return { ...(await orig(c)), endTokens: 30000 }; }
|
|
2214
|
+
if (c.role === "builder" && n++ === 1) throw Object.assign(new Error("ctx"), { code: "CLI_CONTEXT", sessionId: "sess-1", context: 130000, turns: 40, usage: null });
|
|
2215
|
+
return orig(c);
|
|
2216
|
+
};
|
|
2217
|
+
const r = await run(w, { dir, contextCeilingTokens: 120000 }), log = readLog(dir, 7);
|
|
2218
|
+
assert.equal(seen[2].prompt, "/compact"); assert.equal(seen[2].resume, "sess-1");
|
|
2219
|
+
if (ok) {
|
|
2220
|
+
assert.ok(log.some((e) => e.event === "CONTEXT_COMPACTED" && e.tokens_before === 130000 && e.tokens_after === 30000));
|
|
2221
|
+
assert.equal(seen[3].resume, "sess-1", "the same session continues"); assert.equal(r.context.restarts, 0); assert.equal(r.context.compactions, 1);
|
|
2222
|
+
} else {
|
|
2223
|
+
assert.ok(log.some((e) => e.event === "CONTEXT_COMPACT_FAILED")); assert.equal(seen[3].resume, null); assert.match(seen[3].prompt, /The engine froze/); assert.equal(r.context.restarts, 1);
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
});
|
|
2227
|
+
it("#5829 builder still kills and restarts at the ceiling on a small-window model", async () => {
|
|
2228
|
+
const w = world({ dirty: true }), dir = tmpDir("core-ctxsmall-"), orig = w.io.runner, seen = []; let n = 0;
|
|
2229
|
+
w.io.runner = async (c) => {
|
|
2230
|
+
if (c.role === "builder") seen.push({ contextMax: c.contextMax ?? 0, resume: c.resume ?? null });
|
|
2231
|
+
if (c.role === "builder" && n++ === 1) throw Object.assign(new Error("ctx"), { code: "CLI_CONTEXT", context: 130000, turns: 40, usage: null });
|
|
2232
|
+
return orig(c);
|
|
2233
|
+
};
|
|
2234
|
+
const r = await run(w, { dir, builderModel: "claude-sonnet-5-5", builderRouting: { mode: "off" }, contextCeilingTokens: 120000 });
|
|
2235
|
+
assert.equal(seen[1].contextMax, 120000); assert.equal(seen[2].resume, null);
|
|
2236
|
+
assert.ok(readLog(dir, 7).some((e) => e.event === "CONTEXT_CEILING" && e.context_tokens === 130000));
|
|
2237
|
+
assert.equal(r.context.restarts, 1); assert.equal(r.context.continues, 0);
|
|
2238
|
+
});
|
|
2239
|
+
it("#5829 lane summary reports restarts, turns and cost", async () => {
|
|
2240
|
+
const r = await run(world());
|
|
2241
|
+
assert.deepEqual(Object.keys(r.context).sort(), ["compactions", "continues", "cost_usd", "restarts", "turns"]);
|
|
2242
|
+
assert.equal(r.context.restarts, 0); assert.equal(typeof r.context.turns, "number"); assert.equal(typeof r.context.cost_usd, "number");
|
|
2243
|
+
});
|
|
2059
2244
|
it("#4328 freeze-time preflight: a validate needing a module the host lacks gets the one contract correction, before any build", async () => {
|
|
2060
2245
|
const pyC = { ...CONTRACT, validate: [{ id: "V1", command: `python3 -c "import yaml"` }] }, uvC = { ...CONTRACT, validate: [{ id: "V1", command: `uv run python -c "import yaml"` }] };
|
|
2061
2246
|
const probe = (w) => { const ran = []; w.io.probeCommand = async (a) => { ran.push(a); return { rc: /^'python3' .*'yaml'/.test(a.command) ? 3 : 0, output: "" }; }; return ran; };
|
|
@@ -2064,7 +2249,7 @@ describe("conformance shadow mode (the default)", () => {
|
|
|
2064
2249
|
assert.equal((await run(w, { dir })).terminalReason, "merged");
|
|
2065
2250
|
assert.equal(builders(w).length, 3, "plan + one contract correction + implement");
|
|
2066
2251
|
assert.match(builders(w)[1][4], /V1: needs Python module 'yaml' \(for python3\), which this host lacks[\s\S]*repo's own toolchain/);
|
|
2067
|
-
assert.ok(ran.every((a) => a.cwd === WT && a.env && typeof a.env === "object"), "probes run in the worktree with the lane env");
|
|
2252
|
+
assert.ok(ran.every((a) => posix(a.cwd) === WT && a.env && typeof a.env === "object"), "probes run in the worktree with the lane env");
|
|
2068
2253
|
assert.deepEqual(readLog(dir, 7).filter((e) => e.event === "VALIDATE_PREFLIGHT").map((e) => [e.corrected, e.misses.map((m) => m.tool)]), [[true, []]]);
|
|
2069
2254
|
// still missing after the correction: advisory only, the lane goes on (the post-build rerun is the gate)
|
|
2070
2255
|
const dir2 = tmpDir("preflight-");
|
|
@@ -2101,7 +2286,7 @@ describe("conformance shadow mode (the default)", () => {
|
|
|
2101
2286
|
assert.match(b[1][4], /V4: running it on the base worktree stopped before any test ran: needs Python module 'httpx'[\s\S]*repo's own toolchain/);
|
|
2102
2287
|
assert.doesNotMatch(b[1][4], /V[123]:/, "RED on base is not a miss");
|
|
2103
2288
|
assert.match(b[2][4], /The engine froze/, "the correction lands before the implement builder");
|
|
2104
|
-
assert.ok(ran.every(([, cwd]) => cwd === WT));
|
|
2289
|
+
assert.ok(ran.every(([, cwd]) => posix(cwd) === WT));
|
|
2105
2290
|
const firstImpl = w.seq.indexOf("builder-resume", w.seq.indexOf("builder-resume") + 1);
|
|
2106
2291
|
assert.ok(ran.every(([, , at]) => at < firstImpl), "every run happens before the implement session");
|
|
2107
2292
|
const pf = readLog(dir, 7).filter((e) => e.event === "VALIDATE_PREFLIGHT");
|
|
@@ -2412,7 +2597,7 @@ describe("structure delta (forge#4159): undeclared package edges block, import g
|
|
|
2412
2597
|
assert.equal(builders(w).length, 3); assert.equal(reviewers(w).length, 1);
|
|
2413
2598
|
assert.match(builders(w)[2][4], /@s\/db -> @s\/core \(dependencies, packages\/db\/package\.json\)[\s\S]*add it to the contract with a reason, or remove it/);
|
|
2414
2599
|
assert.equal(builders(w)[2][2], null, "#4363: a fresh fix session");
|
|
2415
|
-
assert.deepEqual(w.structureCalls[0], { cwd: "/wt/lean-7", base: "origin/staging" });
|
|
2600
|
+
assert.deepEqual({ ...w.structureCalls[0], cwd: posix(w.structureCalls[0].cwd) }, { cwd: "/wt/lean-7", base: "origin/staging" });
|
|
2416
2601
|
const e = readLog(dir, 7).find((x) => x.event === "STRUCTURE_DELTA");
|
|
2417
2602
|
assert.equal(e.edges_added, 1);
|
|
2418
2603
|
assert.ok(readLog(dir, 7).findIndex((x) => x.event === "STRUCTURE_DELTA") < readLog(dir, 7).findIndex((x) => x.event === "CONFORMANCE"), "before the conformance review");
|
|
@@ -2525,8 +2710,8 @@ describe("hotspot prevention (forge#4195): plan facts, build rule, unexempted gr
|
|
|
2525
2710
|
assert.equal(hotspotBuildRule(facts([], { file_lines: 1000, growth_lines: 50 })).trim(), "Don't grow a file over 1000 lines by more than 50 lines. Put new code next to it.");
|
|
2526
2711
|
assert.equal(hotspotBuildRule(null), ""); assert.equal(hotspotBuildRule(facts([], { enabled: false })), "");
|
|
2527
2712
|
const plan = builderPlanPrompt(7) + hotspotPlanNote(facts([HOT, { ...HOT, path: "a/b.py" }, { ...HOT, path: "c/d.py" }]));
|
|
2528
|
-
// 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).
|
|
2529
|
-
assert.ok(approxTokens(plan) <=
|
|
2713
|
+
// 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).
|
|
2714
|
+
assert.ok(approxTokens(plan) <= 2750, `plan prompt with hotspots is ${approxTokens(plan)} tokens`);
|
|
2530
2715
|
assert.ok(approxTokens(builderImplementPrompt() + hotspotBuildRule(facts([]))) <= 2025, `implement prompt with the hotspot rule is ${approxTokens(builderImplementPrompt() + hotspotBuildRule(facts([])))} of 2025 tokens`); // 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)
|
|
2531
2716
|
});
|
|
2532
2717
|
|
|
@@ -3066,7 +3251,7 @@ describe("comment templates", () => {
|
|
|
3066
3251
|
|
|
3067
3252
|
it("plan and implement prompts carry the stage templates and the contract schema within budget", () => {
|
|
3068
3253
|
const plan = builderPlanPrompt(7), impl = builderImplementPrompt();
|
|
3069
|
-
assert.ok(approxTokens(plan) <=
|
|
3254
|
+
assert.ok(approxTokens(plan) <= 2700, `plan prompt is ${approxTokens(plan)} tokens`); // 2700: #5750 (outcome vs guidance split) on top of 2650; 2550: first-pass check-id + dependency-block rule; 2500: #5445 (Test plan heading); 2475: staging; 2375: #5432 (duplicate rule); 2075: #5284 (prod_parity plan line); 2050: #4769 (activation-row rule); 2000: #4730 (owner-step remainder); 1950: #4724 (deferred-row bucket rule) // 2325: #5333 (git stash rule + stage stamp line)
|
|
3070
3255
|
assert.ok(approxTokens(impl) <= 2000, `implement prompt is ${approxTokens(impl)} of 2000 tokens`); // 2000: #5752 // 1650: #4726 e2e rule; 1550: #4596 i18n translate rule // 1850: #5333 (git stash rule + stage stamp) // 1900: #5760 (CI budget rule)
|
|
3071
3256
|
for (const h of ["### What Was Claimed", "### What We Found", "### Root Cause", "### Affected Files", "### Sibling Sweep", "### History", "### Recommendation", "### Related Issues", "### Test plan",
|
|
3072
3257
|
"investigation.md", "contract.json", "PLANNING ONLY", '"requirements"', '"deliverables"', '"preserve"', '"validate"', "verbatim", "defer", "post-deploy"]) assert.ok(plan.includes(h), h);
|
|
@@ -3111,6 +3296,56 @@ describe("merge_wait policy", () => {
|
|
|
3111
3296
|
const w2 = world(); w2.io.requiredChecks = async () => ["build"]; w2.io.checkStates = async () => states({ build: "pending" });
|
|
3112
3297
|
assert.equal((await run(w2, { ciMaxMinutes: 5 })).terminalReason, "ci-pending");
|
|
3113
3298
|
});
|
|
3299
|
+
describe("#5836 merge train: pr-ready exit", () => {
|
|
3300
|
+
it("on, pending required checks end pr-ready with the hand-over payload and no merge", async () => {
|
|
3301
|
+
const w = world(); w.io.requiredChecks = async () => ["build"]; w.io.checkStates = async () => states({ build: "pending" });
|
|
3302
|
+
const r = await run(w, { mergeTrain: "on" });
|
|
3303
|
+
assert.equal(r.terminalReason, "pr-ready");
|
|
3304
|
+
assert.deepEqual({ pr: r.pr, head: r.head, required: r.required, policy: r.policy, lane: r.lane }, { pr: 77, head: w.head, required: ["build"], policy: "required", lane: "staging" });
|
|
3305
|
+
assert.equal(w.merges.length, 0);
|
|
3306
|
+
});
|
|
3307
|
+
it("off (default) keeps waiting: pending checks end ci-pending at the budget, never pr-ready", async () => {
|
|
3308
|
+
const w = world(); w.io.requiredChecks = async () => ["build"]; w.io.checkStates = async () => states({ build: "pending" });
|
|
3309
|
+
assert.equal((await run(w, { ciMaxMinutes: 5 })).terminalReason, "ci-pending");
|
|
3310
|
+
const w2 = world(); w2.io.requiredChecks = async () => ["build"]; w2.io.checkStates = async () => states({ build: "pending" });
|
|
3311
|
+
assert.equal((await run(w2, { ciMaxMinutes: 5, mergeTrain: "off" })).terminalReason, "ci-pending");
|
|
3312
|
+
});
|
|
3313
|
+
it("on, already-green checks are handed to the train too (#5839): one queue per base, no lane merge", async () => {
|
|
3314
|
+
const w = world(); w.io.requiredChecks = async () => ["build"]; w.io.checkStates = async () => states({ build: "success" });
|
|
3315
|
+
const r = await run(w, { mergeTrain: "on" });
|
|
3316
|
+
assert.equal(r.terminalReason, "pr-ready"); assert.equal(w.merges.length, 0);
|
|
3317
|
+
assert.deepEqual(r.postMerge, { keepOpen: false, notes: [] }); assert.equal(r.laneSide.syncs, 0);
|
|
3318
|
+
});
|
|
3319
|
+
it("off, already-green checks merge in the lane (unchanged)", async () => {
|
|
3320
|
+
const w = world(); w.io.requiredChecks = async () => ["build"]; w.io.checkStates = async () => states({ build: "success" });
|
|
3321
|
+
const r = await run(w, { mergeTrain: "off" });
|
|
3322
|
+
assert.equal(r.terminalReason, "merged");
|
|
3323
|
+
assert.deepEqual(w.merges[0].slice(-2), ["--match-head-commit", w.head]);
|
|
3324
|
+
});
|
|
3325
|
+
it("on, a conflicting PR is handed over with no base-sync (the train hands back base.conflict)", async () => {
|
|
3326
|
+
const CONFLICTING = { mergeable: "CONFLICTING", mergeStateStatus: "DIRTY" }; const w = world({ prView: [CONFLICTING, CONFLICTING] }); w.io.requiredChecks = async () => ["build"]; w.io.checkStates = async () => states({ build: "success" });
|
|
3327
|
+
const r = await run(w, { mergeTrain: "on" });
|
|
3328
|
+
assert.equal(r.terminalReason, "pr-ready"); assert.equal(w.merges.length, 0);
|
|
3329
|
+
assert.equal(r.laneSide.baseConflicts, 1);
|
|
3330
|
+
assert.ok(!w.calls.some((c) => Array.isArray(c) && c[0] === "merge" && /origin\//.test(c.join(" "))), "no lane base-sync merge");
|
|
3331
|
+
});
|
|
3332
|
+
it("on, a red check still gets the lane's own outcome (never pr-ready)", async () => {
|
|
3333
|
+
const w = world(); w.io.requiredChecks = async () => ["build"]; w.io.checkStates = async () => states({ build: "failure" });
|
|
3334
|
+
assert.notEqual((await run(w, { mergeTrain: "on" })).terminalReason, "pr-ready");
|
|
3335
|
+
assert.equal(w.merges.length, 0);
|
|
3336
|
+
});
|
|
3337
|
+
});
|
|
3338
|
+
describe("#5839 merge train: every lane kind but a split hands over", () => {
|
|
3339
|
+
const pending = (w) => { w.io.requiredChecks = async () => ["build"]; w.io.checkStates = async () => states({ build: "pending" }); return w; };
|
|
3340
|
+
it("numbered sequence files hand over with a post-merge record", async () => {
|
|
3341
|
+
const w = pending(world());
|
|
3342
|
+
w.io.sequenceCheck = async () => []; w.io.sequenceLease = { acquire: async () => ({ waitMs: 0, timedOut: false, release: () => {} }) };
|
|
3343
|
+
w.io.sequenceSnapshot = async () => [{ path: "db/0007_usage.sql", blob: "b1" }];
|
|
3344
|
+
const r = await run(w, { mergeTrain: "on", ciMaxMinutes: 5 });
|
|
3345
|
+
assert.equal(r.terminalReason, "pr-ready"); assert.equal(w.merges.length, 0);
|
|
3346
|
+
assert.equal(typeof r.postMerge.keepOpen, "boolean");
|
|
3347
|
+
});
|
|
3348
|
+
});
|
|
3114
3349
|
describe("#4624 merge-time rerun / wait / flaky branch of mergeFixRound", () => {
|
|
3115
3350
|
const RUN = (n, attempt) => `https://github.com/o/r/actions/runs/${n}/job/${attempt}`;
|
|
3116
3351
|
const NO_FIX = { ...parseVerify({}), maxRounds: 0 };
|
|
@@ -4507,7 +4742,7 @@ describe("usage limit, lease takeover, worktree setup, run tmp (#4101-#4104)", (
|
|
|
4507
4742
|
|
|
4508
4743
|
it("#4103 a leftover unregistered worktree dir is removed (only this issue's lean dir) before add", async () => {
|
|
4509
4744
|
const w = world(); const removed = [];
|
|
4510
|
-
w.io.fs.exists = async (p) => p === "/wt/lean-7"; w.io.fs.rmdir = async (p) => { removed.push(p); };
|
|
4745
|
+
w.io.fs.exists = async (p) => p === "/repo" || p === "/wt/lean-7"; w.io.fs.rmdir = async (p) => { removed.push(p); };
|
|
4511
4746
|
await run(w);
|
|
4512
4747
|
assert.deepEqual(removed, ["/wt/lean-7"]);
|
|
4513
4748
|
// a registered worktree dir is left to `git worktree remove`
|
|
@@ -4526,7 +4761,7 @@ describe("usage limit, lease takeover, worktree setup, run tmp (#4101-#4104)", (
|
|
|
4526
4761
|
it("#4103 'already exists' on add cleans the leftover and retries; index.lock and packed-refs.lock are retried", async () => {
|
|
4527
4762
|
for (const msg of ["fatal: '/wt/lean-7' already exists", "fatal: Unable to create '/r/.git/index.lock': File exists.", "error: cannot lock ref: Unable to create '/r/.git/packed-refs.lock': File exists", "fatal: could not lock config file /r/.git/config: File exists"]) {
|
|
4528
4763
|
const w = world(); let failed = false, gone = false; const removed = [];
|
|
4529
|
-
w.io.fs.exists = async (p) => failed && !gone && p === "/wt/lean-7"; w.io.fs.rmdir = async (p) => { removed.push(p); gone = true; }; // #5825: a removed leftover is gone until the add
|
|
4764
|
+
w.io.fs.exists = async (p) => p === "/repo" || failed && !gone && p === "/wt/lean-7"; w.io.fs.rmdir = async (p) => { removed.push(p); gone = true; }; // #5825: a removed leftover is gone until the add
|
|
4530
4765
|
const g = w.io.git;
|
|
4531
4766
|
w.io.git = async (a, o2) => { if (a[0] === "worktree" && a[1] === "add" && !failed) { failed = true; throw Object.assign(new Error(msg), { stderr: msg }); } if (a[0] === "worktree" && a[1] === "add") gone = false; return g(a, o2); };
|
|
4532
4767
|
const r = await run(w);
|
|
@@ -6796,6 +7031,18 @@ describe("local-mode CI fix rounds at merge and declared pre-PR check commands (
|
|
|
6796
7031
|
assert.equal(builders(w).length, 2, "no builder fix round spent on a base failure");
|
|
6797
7032
|
});
|
|
6798
7033
|
|
|
7034
|
+
it("#5945 an env-signature base failure is not base.red and files nothing; a host verify pass skips filing", async () => {
|
|
7035
|
+
for (const hook of [false, true]) {
|
|
7036
|
+
const w = world(); const filed = [], gh = w.io.gh;
|
|
7037
|
+
w.io.runCommand = async ({ cwd }) => ({ rc: 1, output: hook ? "bare 429 at app/routers/listing_feeds.py" : "ModuleNotFoundError: No module named yaml" });
|
|
7038
|
+
if (hook) w.io.verifyBaseOnHost = async () => ({ rc: 0 });
|
|
7039
|
+
w.io.gh = async (a, o) => { if (a[0] === "issue" && ["create", "comment", "reopen"].includes(a[1]) && a.some((x) => /FORGE:BASE_RED/.test(x))) filed.push(a); return gh(a, o); };
|
|
7040
|
+
const r = await run(w, { verify: { invariants: ["bash scripts/guard.sh"] } });
|
|
7041
|
+
assert.notEqual(r.code, "base.red"); assert.equal(w.merges.length, 0);
|
|
7042
|
+
assert.equal(filed.length, 0, "no BASE_RED issue filed");
|
|
7043
|
+
}
|
|
7044
|
+
});
|
|
7045
|
+
|
|
6799
7046
|
it("#5239 verify.guard_block false keeps a failing invariant advisory", async () => {
|
|
6800
7047
|
const w = world(); w.io.runCommand = async () => ({ rc: 1, output: "x" });
|
|
6801
7048
|
const r = await run(w, { verify: { invariants: ["bash scripts/guard.sh"], guardBlock: false } });
|
|
@@ -6925,7 +7172,7 @@ describe("test map and repo facts caches (#4272)", () => {
|
|
|
6925
7172
|
});
|
|
6926
7173
|
|
|
6927
7174
|
it("neither file present: the same commands, events and prompts as without the feature", async () => {
|
|
6928
|
-
const w = world(); const ran = recorder(w); w.io.fs.exists = async (p) => p === WT;
|
|
7175
|
+
const w = world(); const ran = recorder(w); w.io.fs.exists = async (p) => p === WT || p === "/repo";
|
|
6929
7176
|
const dir = tmpDir("core-");
|
|
6930
7177
|
assert.equal((await run(w, { dir, precheck: { commands: ["true", "make lint"] } })).terminalReason, "merged");
|
|
6931
7178
|
assert.deepEqual(ran, ["true", "make lint"]);
|
|
@@ -6940,11 +7187,11 @@ describe("test map and repo facts caches (#4272)", () => {
|
|
|
6940
7187
|
it("repo-facts.json present: the builder prompts cite its path, never its content", async () => {
|
|
6941
7188
|
const w = world(); recorder(w);
|
|
6942
7189
|
w.files[FACTSF] = JSON.stringify({ version: 1, toolchain: { pm: { name: "pnpm", version: "9.9.9-SECRET" } } });
|
|
6943
|
-
w.io.fs.exists = async (p) => p === WT || p in w.files;
|
|
7190
|
+
w.io.fs.exists = async (p) => p === WT || p === "/repo" || p in w.files;
|
|
6944
7191
|
assert.equal((await run(w)).terminalReason, "merged");
|
|
6945
7192
|
const [plan, impl] = builders(w);
|
|
6946
7193
|
for (const b of [plan, impl]) { assert.ok(b[4].includes(`are cached in ${FACTSF}`)); assert.doesNotMatch(b[4], /9\.9\.9-SECRET/); }
|
|
6947
|
-
const w2 = world(); recorder(w2); w2.files["/repo/.forge/repo-facts.json"] = "{}"; w2.io.fs.exists = async (p) => p === WT || p in w2.files;
|
|
7194
|
+
const w2 = world(); recorder(w2); w2.files["/repo/.forge/repo-facts.json"] = "{}"; w2.io.fs.exists = async (p) => p === WT || p === "/repo" || p in w2.files;
|
|
6948
7195
|
assert.equal((await run(w2)).terminalReason, "merged");
|
|
6949
7196
|
assert.ok(builders(w2)[0][4].includes("are cached in /repo/.forge/repo-facts.json"));
|
|
6950
7197
|
});
|
|
@@ -7074,6 +7321,12 @@ describe("refactor:split lane routing (forge#4211)", () => {
|
|
|
7074
7321
|
const splitOk = (extra = {}) => ({ ok: true, target: "pkg/big.py", testCmd: "pytest", package: "pkg.big_parts", packageName: "big_parts", modules: { consts: ["A"], helpers: ["f", "g"] }, rest: null, verify: { ok: true, failures: [] }, grouped: true, lines: 120, ...extra });
|
|
7075
7322
|
const mod = (w, result) => ({ ...refactorMod, runSplitStep: async (ctx) => { w.splitCtx.push(ctx); if (result.ok) await ctx.callGrouper("INDEX-ONLY PROMPT", { cwd: "/tmp/empty" }); return result; } });
|
|
7076
7323
|
|
|
7324
|
+
it("#5836 merge train on: a split lane is never handed to the train (pending checks keep it waiting)", async () => {
|
|
7325
|
+
const w = splitWorld(); w.io.requiredChecks = async () => ["build"]; w.io.checkStates = async () => [{ name: "build", state: "pending" }];
|
|
7326
|
+
const r = await run(w, { mergeTrain: "on", ciMaxMinutes: 5, refactorModule: mod(w, splitOk()), precheck: { commands: ["pytest -q"] } });
|
|
7327
|
+
assert.equal(r.terminalReason, "ci-pending"); assert.equal(w.merges.length, 0);
|
|
7328
|
+
});
|
|
7329
|
+
|
|
7077
7330
|
it("a refactor:split issue never runs the builder or the reviewer: one tool-less grouping call, PR, merge", async () => {
|
|
7078
7331
|
const w = splitWorld();
|
|
7079
7332
|
const r = await run(w, { refactorModule: mod(w, splitOk()), precheck: { commands: ["pytest -q"] } });
|
|
@@ -7972,6 +8225,14 @@ describe("#4362 attempt triggers", () => {
|
|
|
7972
8225
|
assert.equal(r.firstPass, true);
|
|
7973
8226
|
});
|
|
7974
8227
|
|
|
8228
|
+
it("#5829: no ceiling configured and a builder model without a known window keeps the 120000 ceiling instead of switching it off", async () => {
|
|
8229
|
+
const w = world(); const orig = w.io.runner, caps = [];
|
|
8230
|
+
w.io.runner = async (c) => { if (c.role === "builder") caps.push(c.contextMax ?? 0); return orig(c); };
|
|
8231
|
+
assert.equal((await run(w, { dir: tmpDir("core-ctx-"), builderModel: "mystery-1", builderRouting: { mode: "off" } })).terminalReason, "merged");
|
|
8232
|
+
assert.equal(caps[0], 0, "the plan call runs uncapped");
|
|
8233
|
+
assert.equal(caps[1], 120000, "the build call carries the default ceiling");
|
|
8234
|
+
});
|
|
8235
|
+
|
|
7975
8236
|
it("#4390: context restarts are bounded; after three the call runs uncapped, and 0 disables the ceiling", async () => {
|
|
7976
8237
|
const w = world(); const dir = tmpDir("core-ctx-");
|
|
7977
8238
|
const orig = w.io.runner, caps = [];
|
|
@@ -8340,6 +8601,13 @@ describe("e2e merge gate (#4403)", () => {
|
|
|
8340
8601
|
assert.ok(w.seq.indexOf("merge") > -1);
|
|
8341
8602
|
});
|
|
8342
8603
|
|
|
8604
|
+
it("#5836 merge train on: an e2e gate keeps the lane waiting (never pr-ready)", async () => {
|
|
8605
|
+
const w = withE2e(world({ changed: SPECS, reviews: [conf({}, CONTRACT, SPECS)] }), ["pending"]);
|
|
8606
|
+
w.io.requiredChecks = async () => ["e2e"];
|
|
8607
|
+
const r = await go(w, { mergeTrain: "on", ciMaxMinutes: 5 });
|
|
8608
|
+
assert.notEqual(r.terminalReason, "pr-ready"); assert.equal(w.merges.length, 0);
|
|
8609
|
+
});
|
|
8610
|
+
|
|
8343
8611
|
it("the lane's own spec failing in e2e: builder fix round, re-review, then merged once e2e is green; no rounds left -> ci.red, nothing merged", async () => {
|
|
8344
8612
|
const w = withE2e(world({ changed: SPECS }), ["failure", "success"]);
|
|
8345
8613
|
const r = await go(w);
|
|
@@ -8788,7 +9056,7 @@ describe("#4395 lane profile", () => {
|
|
|
8788
9056
|
assert.match(p, /Read each file's ranges once .* and keep notes; don't re-read it\./);
|
|
8789
9057
|
}
|
|
8790
9058
|
assert.ok(approxTokens(builderImplementPrompt()) <= 2000, `implement prompt is ${approxTokens(builderImplementPrompt())} of 2000 tokens`); // 1900: #5760; 2000: #5752
|
|
8791
|
-
assert.ok(approxTokens(builderPlanPrompt(7)) <=
|
|
9059
|
+
assert.ok(approxTokens(builderPlanPrompt(7)) <= 2700, `plan prompt is ${approxTokens(builderPlanPrompt(7))} of 2125 tokens`);
|
|
8792
9060
|
});
|
|
8793
9061
|
|
|
8794
9062
|
it("runCliBackendAsync reports the first stream turn's context as baselineTokens; makeLeanRunner drops it on resume", async () => {
|
|
@@ -9289,7 +9557,7 @@ describe("#5347 builders open with one batch of independent reads", () => {
|
|
|
9289
9557
|
});
|
|
9290
9558
|
|
|
9291
9559
|
describe("#5347 lane: the build opens with its independent reads in one turn", () => {
|
|
9292
|
-
it("a lane whose contract names two deliverables hands the builder the opening batch; the builder's one-turn reads through the real stream parser record calls/turn >= 2", async () => {
|
|
9560
|
+
it("a lane whose contract names two deliverables hands the builder the opening batch; the builder's one-turn reads through the real stream parser record calls/turn >= 2", { skip: process.platform === "win32" && "the fake CLI is a #!/bin/sh script" }, async () => {
|
|
9293
9561
|
const { runCliBackendAsync } = await import("../runner.mjs");
|
|
9294
9562
|
const { toolStats } = await import("./toolstats.mjs");
|
|
9295
9563
|
const two = { ...CONTRACT, deliverables: [...CONTRACT.deliverables, { id: "D2", path: "src/bar.js", change: "keep callers", requirements: ["R1"] }] };
|
|
@@ -9729,9 +9997,9 @@ describe("#5592 (8) comment and label spam", () => {
|
|
|
9729
9997
|
it("start clears needs-human, needs-human:external, parked:* and remediation-queue; other labels stay", async () => {
|
|
9730
9998
|
const w = world({ issueBodies: [ISSUE_BODY], labels: [{ name: "bug" }, { name: "needs-human" }, { name: "needs-human:external" }, { name: "parked:ci.red" }, { name: "remediation-queue" }] });
|
|
9731
9999
|
await run(w);
|
|
9732
|
-
|
|
9733
|
-
|
|
9734
|
-
assert.deepEqual(rm
|
|
10000
|
+
// #5759: one removal call per label
|
|
10001
|
+
const rm = w.edits.filter((e) => e.includes("--remove-label")).map((e) => e[e.indexOf("--remove-label") + 1]);
|
|
10002
|
+
assert.deepEqual(rm.filter((x) => /needs-human|parked:|remediation-queue/.test(x)), ["needs-human", "needs-human:external", "parked:ci.red", "remediation-queue"]);
|
|
9735
10003
|
});
|
|
9736
10004
|
|
|
9737
10005
|
it("a merged run re-reads the labels and clears a parked label added meanwhile", async () => {
|
|
@@ -87,6 +87,31 @@ export function formatOverride(o) {
|
|
|
87
87
|
return [s.maxRemote !== undefined ? `max_remote ${s.maxRemote}` : null, s.mode ? `placement ${s.mode}` : null].filter(Boolean).join(", ") || "no change";
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
/** #5933: what `--set-max-remote <id> 0` does on a remote batch; null unless the patch sets 0 without a placement change. */
|
|
91
|
+
export function drainNote(patch) {
|
|
92
|
+
const s = sanitizeOverride(patch) ?? {};
|
|
93
|
+
return s.maxRemote === 0 && !s.mode ? "remote starts paused; nothing runs locally" : null;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* #5735: the `--set-max-remote` note from the pool router's lane view (`httpTransport.agentLanes()`: {agents: [{name, used,
|
|
98
|
+
* ceiling|null}], total}): the remote lane total across batches, per-agent used/ceiling, and a leading warning when every
|
|
99
|
+
* listed agent has a ceiling and `n` exceeds their sum. null lanes -> null. Never throws.
|
|
100
|
+
*/
|
|
101
|
+
export function remoteLaneNote(n, lanes) {
|
|
102
|
+
try {
|
|
103
|
+
if (!lanes || typeof lanes !== "object") return null;
|
|
104
|
+
const list = Array.isArray(lanes.agents) ? lanes.agents.filter((a) => a && typeof a === "object") : [];
|
|
105
|
+
const ceil = (a) => (Number.isInteger(a.ceiling) && a.ceiling >= 0 ? a.ceiling : null);
|
|
106
|
+
const total = Number.isInteger(lanes.total) ? lanes.total : list.reduce((s, a) => s + (Number.isInteger(a.used) ? a.used : 0), 0);
|
|
107
|
+
const per = list.map((a) => `${a.name}: lanes ${Number.isInteger(a.used) ? a.used : 0}/${ceil(a) ?? "-"}`);
|
|
108
|
+
const lines = [`remote lanes across batches: ${total}${per.length ? ` (${per.join(", ")})` : ""}`];
|
|
109
|
+
const sum = list.length && list.every((a) => ceil(a) !== null) ? list.reduce((s, a) => s + ceil(a), 0) : null;
|
|
110
|
+
if (sum !== null && Number.isInteger(n) && n > sum) lines.unshift(`warning: max_remote ${n} exceeds the pool host lane ceiling ${sum}; lanes beyond it are deferred`);
|
|
111
|
+
return lines.join(String.fromCharCode(10));
|
|
112
|
+
} catch { return null; }
|
|
113
|
+
}
|
|
114
|
+
|
|
90
115
|
/**
|
|
91
116
|
* Hybrid validation weight (#4256) that is computed only when first needed: `initial` (already computed) or `compute()`
|
|
92
117
|
* started on the first `get()`; until it resolves (or when it fails) a light weight is used.
|
|
@@ -4,7 +4,8 @@ import { describe, it } from "node:test";
|
|
|
4
4
|
import assert from "node:assert/strict";
|
|
5
5
|
import { tmpDir } from "../tests/_tmp.mjs";
|
|
6
6
|
import { openBatch } from "./batch.mjs";
|
|
7
|
-
import {
|
|
7
|
+
import { placeLane } from "./execution.mjs";
|
|
8
|
+
import { validateExecutionPatch, sanitizeOverride, effectiveExecution, parseSetExecution, applySetExecution, formatOverride, drainNote, lazyWeight, liveRemote, LIVE_MODES, remoteLaneNote } from "./live-execution.mjs";
|
|
8
9
|
|
|
9
10
|
describe("#5138 live execution control", () => {
|
|
10
11
|
it("validates patches: max_remote a non-negative integer, mode remote|hybrid|local", () => {
|
|
@@ -81,3 +82,36 @@ describe("#5138 live execution control", () => {
|
|
|
81
82
|
assert.deepEqual(failing.get(), { heavy: false, signals: [] });
|
|
82
83
|
});
|
|
83
84
|
});
|
|
85
|
+
|
|
86
|
+
describe("#5735 remoteLaneNote", () => {
|
|
87
|
+
const lanes = (agents, total) => ({ agents, total });
|
|
88
|
+
it("warns when max_remote exceeds the summed host lane ceiling and always prints the total", () => {
|
|
89
|
+
const note = remoteLaneNote(6, lanes([{ name: "legion", used: 2, ceiling: 2 }, { name: "box", used: 0, ceiling: 1 }], 2));
|
|
90
|
+
const [first, second] = note.split(String.fromCharCode(10));
|
|
91
|
+
assert.equal(first, "warning: max_remote 6 exceeds the pool host lane ceiling 3; lanes beyond it are deferred");
|
|
92
|
+
assert.equal(second, "remote lanes across batches: 2 (legion: lanes 2/2, box: lanes 0/1)");
|
|
93
|
+
});
|
|
94
|
+
it("no warning when n is within the ceiling or an agent is uncapped", () => {
|
|
95
|
+
assert.equal(remoteLaneNote(2, lanes([{ name: "legion", used: 1, ceiling: 2 }], 1)), "remote lanes across batches: 1 (legion: lanes 1/2)");
|
|
96
|
+
const uncapped = remoteLaneNote(9, lanes([{ name: "legion", used: 1, ceiling: 2 }, { name: "box", used: 3, ceiling: null }], 4));
|
|
97
|
+
assert.doesNotMatch(uncapped, /warning/);
|
|
98
|
+
assert.match(uncapped, /^remote lanes across batches: 4 /);
|
|
99
|
+
assert.equal(remoteLaneNote(3, lanes([], 0)), "remote lanes across batches: 0");
|
|
100
|
+
});
|
|
101
|
+
it("null or malformed lanes give null or a safe line; never throws", () => {
|
|
102
|
+
assert.equal(remoteLaneNote(3, null), null);
|
|
103
|
+
assert.equal(remoteLaneNote(3, undefined), null);
|
|
104
|
+
assert.equal(remoteLaneNote(3, { agents: "x" }), "remote lanes across batches: 0");
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
describe("#5933 drain semantics", () => {
|
|
109
|
+
it("#5933 liveRemote place by mode", () => {
|
|
110
|
+
assert.equal(drainNote({ maxRemote: 0 }), "remote starts paused; nothing runs locally");
|
|
111
|
+
assert.equal(drainNote({ maxRemote: 2 }), null);
|
|
112
|
+
assert.equal(drainNote({ maxRemote: 0, mode: "local" }), null);
|
|
113
|
+
const mk = (exec) => liveRemote({}, { exec, place: (e) => placeLane({ exec: e }) });
|
|
114
|
+
assert.equal(mk({ mode: "remote", maxRemote: 0 }).place(1).where, "remote");
|
|
115
|
+
assert.equal(mk({ mode: "hybrid", maxRemote: 0 }).place(1).where, "local");
|
|
116
|
+
});
|
|
117
|
+
});
|