forgedock 1.59.2 → 1.60.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/engine/outcome-codes.mjs +3 -3
- package/bin/engine-cli.mjs +50 -10
- package/bin/labels.json +5 -0
- package/bin/lean/batch.mjs +21 -2
- package/bin/lean/batch.test.mjs +116 -1
- package/bin/lean/conformance.mjs +12 -5
- package/bin/lean/conformance.test.mjs +30 -2
- package/bin/lean/depcache.mjs +34 -15
- package/bin/lean/depcache.test.mjs +100 -1
- package/bin/lean/design-gate.mjs +15 -10
- package/bin/lean/design-gate.test.mjs +21 -0
- package/bin/lean/effects.mjs +18 -2
- package/bin/lean/execution.mjs +23 -5
- package/bin/lean/execution.test.mjs +81 -1
- package/bin/lean/gatewatch.test.mjs +5 -5
- package/bin/lean/issuewatch-triage.mjs +68 -0
- package/bin/lean/issuewatch-triage.test.mjs +98 -0
- package/bin/lean/issuewatch.mjs +34 -6
- package/bin/lean/issuewatch.test.mjs +11 -0
- package/bin/lean/lanelock.mjs +5 -4
- package/bin/lean/lean.mjs +123 -17
- package/bin/lean/lean.test.mjs +154 -6
- package/bin/lean/orchestrate-cancel.test.mjs +33 -0
- package/bin/lean/orchestrate-hostfallback.test.mjs +41 -0
- package/bin/lean/orchestrate-recovering.test.mjs +42 -0
- package/bin/lean/orchestrate.mjs +23 -10
- package/bin/lean/pagegate.mjs +50 -12
- package/bin/lean/pagegate.test.mjs +38 -1
- package/bin/lean/phaseledger.mjs +65 -2
- package/bin/lean/phaseledger.test.mjs +70 -2
- package/bin/lean/preflight.mjs +5 -2
- package/bin/lean/preflight.test.mjs +7 -0
- package/bin/lean/prompts.mjs +2 -1
- package/bin/lean/recovery.test.mjs +11 -6
- package/bin/lean/release-classify.mjs +143 -0
- package/bin/lean/release-classify.test.mjs +130 -0
- package/bin/lean/release-conductor.mjs +163 -0
- package/bin/lean/release-conductor.test.mjs +194 -0
- package/bin/lean/release-config.mjs +60 -8
- package/bin/lean/release-config.test.mjs +43 -1
- package/bin/lean/release-control.mjs +22 -5
- package/bin/lean/release-control.test.mjs +22 -0
- package/bin/lean/release-credentials.mjs +40 -0
- package/bin/lean/release-credentials.test.mjs +42 -0
- package/bin/lean/release-deploy.mjs +3 -3
- package/bin/lean/release-deploy.test.mjs +8 -0
- package/bin/lean/release-docs.test.mjs +93 -0
- package/bin/lean/release-fence.mjs +2 -0
- package/bin/lean/release-gate.mjs +88 -0
- package/bin/lean/release-gate.test.mjs +116 -0
- package/bin/lean/release-gates.mjs +5 -1
- package/bin/lean/release-ledger.mjs +47 -1
- package/bin/lean/release-ledger.test.mjs +33 -1
- package/bin/lean/release-mergeback.mjs +148 -0
- package/bin/lean/release-mergeback.test.mjs +129 -0
- package/bin/lean/release-p0.mjs +193 -0
- package/bin/lean/release-p0.test.mjs +127 -0
- package/bin/lean/release-plan.mjs +267 -0
- package/bin/lean/release-plan.test.mjs +202 -0
- package/bin/lean/release-preflight.mjs +16 -0
- package/bin/lean/release-regate.mjs +141 -0
- package/bin/lean/release-regate.test.mjs +149 -0
- package/bin/lean/release-review.mjs +5 -3
- package/bin/lean/release-rollback.mjs +277 -0
- package/bin/lean/release-rollback.test.mjs +245 -0
- package/bin/lean/release-snapshot.mjs +48 -9
- package/bin/lean/release-snapshot.test.mjs +43 -1
- package/bin/lean/release-start.mjs +164 -0
- package/bin/lean/release-start.test.mjs +171 -0
- package/bin/lean/release-status.mjs +6 -2
- package/bin/lean/release-train.mjs +159 -0
- package/bin/lean/release-train.test.mjs +139 -0
- package/bin/lean/release.mjs +127 -5
- package/bin/lean/release.test.mjs +80 -0
- package/bin/lean/sandbox-remote.mjs +2 -0
- package/bin/lean/schedd-load.test.mjs +82 -0
- package/bin/lean/schedd.mjs +67 -31
- package/bin/lean/schedd.test.mjs +80 -1
- package/bin/lean/validate-catalog.mjs +94 -0
- package/bin/lean/validate-catalog.test.mjs +42 -0
- package/bin/pool/agent.mjs +4 -1
- package/bin/pool/lane-tools.mjs +115 -0
- package/bin/pool/lane-tools.test.mjs +26 -0
- package/bin/pool/warm.mjs +1 -1
- package/docs/CONFIG.md +225 -1
- package/docs/ISSUE-WATCH.md +1 -0
- package/docs/design/visual-gate.md +10 -0
- package/docs/eval/adversarial-bench.md +1 -0
- package/package.json +1 -1
- package/pool/README.md +2 -0
- package/scripts/bench-adversarial.mjs +4 -0
- package/scripts/bench-lightlane.mjs +2 -1
- package/templates/github-actions/forge-conductor.scopes.json +7 -0
- package/templates/github-actions/forge-conductor.yml +57 -0
package/bin/lean/depcache.mjs
CHANGED
|
@@ -144,7 +144,9 @@ export function pySatisfies(spec, v) {
|
|
|
144
144
|
}
|
|
145
145
|
/** Full frozen install on a miss, and the warm no-op repair pass on a hit (null: nothing path-dependent to repair). */
|
|
146
146
|
function commands(d, py = null) {
|
|
147
|
-
|
|
147
|
+
// #5651: with an in-range interpreter poetry itself runs under it (`<py> -m poetry`), so its resolver never sees the host default python.
|
|
148
|
+
const poetry = (args) => (py ? [py.cmd, ["-m", "poetry", ...args]] : ["poetry", args]);
|
|
149
|
+
const use = py ? [poetry(["env", "use", py.cmd])] : [];
|
|
148
150
|
switch (d.eco) {
|
|
149
151
|
case "pnpm": return { install: [["pnpm", ["install", "--frozen-lockfile"]]], repair: [["pnpm", ["install", "--frozen-lockfile", "--offline"]]] };
|
|
150
152
|
// npm/yarn node_modules hold only relative links; npm's hidden lockfile is rewritten in place, which the read-only
|
|
@@ -152,7 +154,7 @@ function commands(d, py = null) {
|
|
|
152
154
|
case "npm": return { install: [["npm", ["ci", "--no-audit", "--no-fund"]]], repair: null };
|
|
153
155
|
case "yarn": return { install: [["yarn", ["install", d.berry ? "--immutable" : "--frozen-lockfile"]]], repair: null };
|
|
154
156
|
case "uv": return { install: [["uv", ["venv", "--relocatable", ...(py ? ["--python", py.cmd] : []), ".venv"]], ["uv", ["sync", "--frozen"]]], repair: [["uv", ["sync", "--frozen"]]] };
|
|
155
|
-
case "poetry": return { install: [...use,
|
|
157
|
+
case "poetry": return { install: [...use, poetry(["install", "--sync"])], repair: [...use, poetry(["install", "--sync"])] };
|
|
156
158
|
default: return null;
|
|
157
159
|
}
|
|
158
160
|
}
|
|
@@ -189,32 +191,36 @@ export function makeDepCache({ root = depcacheRoot(), exec, fs = nodeFs, now = (
|
|
|
189
191
|
}
|
|
190
192
|
|
|
191
193
|
/**
|
|
192
|
-
* #5590: for a Python project whose pyproject declares a range the
|
|
193
|
-
*
|
|
194
|
+
* #5590/#5651: for a Python project whose pyproject declares a range, {py: null} (no range, or the default python3 is in range),
|
|
195
|
+
* {py: {cmd, version}} (the interpreter that satisfies it: pythonX.Y on PATH, then `uv python find`) or {missing: {range, probed}}
|
|
196
|
+
* (nothing in range: the caller stops, the out-of-range default is never used).
|
|
194
197
|
*/
|
|
195
198
|
async function pythonFor(wt, d) {
|
|
196
|
-
if (!PY.has(d.eco)) return null;
|
|
199
|
+
if (!PY.has(d.eco)) return { py: null };
|
|
197
200
|
let range = null;
|
|
198
201
|
try { range = pyRange(String(fs.readFileSync(join(wt, "pyproject.toml"))), d.eco); } catch { /* no pyproject */ }
|
|
199
|
-
if (!range) return null;
|
|
202
|
+
if (!range) return { py: null };
|
|
203
|
+
const probed = [];
|
|
200
204
|
const probe = async (cmd) => {
|
|
201
205
|
try {
|
|
202
206
|
const version = String(await exec(cmd, ["--version"], { timeoutMs: 30000 })).trim();
|
|
203
207
|
const m = /(\d+)\.(\d+)(?:\.(\d+))?/.exec(version);
|
|
204
|
-
|
|
205
|
-
} catch {
|
|
208
|
+
if (m) { probed.push(`${cmd} (${version})`); return { cmd, version, v: [Number(m[1]), Number(m[2]), Number(m[3] ?? 0)] }; }
|
|
209
|
+
} catch { /* not installed */ }
|
|
210
|
+
probed.push(`${cmd} (not found)`);
|
|
211
|
+
return null;
|
|
206
212
|
};
|
|
207
213
|
const def = await probe("python3");
|
|
208
|
-
if (def && pySatisfies(range, def.v)) return null;
|
|
214
|
+
if (def && pySatisfies(range, def.v)) return { py: null };
|
|
209
215
|
const minors = [14, 13, 12, 11, 10, 9, 8];
|
|
210
|
-
for (const x of minors) { const c = await probe(`python3.${x}`); if (c && pySatisfies(range, c.v)) return c; }
|
|
216
|
+
for (const x of minors) { const c = await probe(`python3.${x}`); if (c && pySatisfies(range, c.v)) return { py: c }; }
|
|
211
217
|
for (const x of minors) {
|
|
212
218
|
let path = "";
|
|
213
|
-
try { path = String(await exec("uv", ["python", "find", `3.${x}`], { timeoutMs: 30000 })).trim().split("\n")[0]; } catch { break; } // no uv
|
|
219
|
+
try { path = String(await exec("uv", ["python", "find", `3.${x}`], { timeoutMs: 30000 })).trim().split("\n")[0]; } catch { probed.push("uv python find (unavailable)"); break; } // no uv
|
|
214
220
|
const c = path ? await probe(path) : null;
|
|
215
|
-
if (c && pySatisfies(range, c.v)) return c;
|
|
221
|
+
if (c && pySatisfies(range, c.v)) return { py: c };
|
|
216
222
|
}
|
|
217
|
-
return
|
|
223
|
+
return { missing: { range, probed } };
|
|
218
224
|
}
|
|
219
225
|
|
|
220
226
|
async function keyOf(wt, d, pkgs, py = null) {
|
|
@@ -352,7 +358,18 @@ export function makeDepCache({ root = depcacheRoot(), exec, fs = nodeFs, now = (
|
|
|
352
358
|
const done = (status, extra = {}) => ({ status, eco: d.eco, key: extra.key ?? null, ms: now() - t0, reason: extra.reason ?? repaired, ...(extra.published === undefined ? {} : { published: extra.published }) });
|
|
353
359
|
if (d.skip) return done("skipped", { reason: d.skip });
|
|
354
360
|
const pkgs = JS.has(d.eco) ? await manifests(wt) : [];
|
|
355
|
-
const
|
|
361
|
+
const found = await pythonFor(wt, d);
|
|
362
|
+
if (found.missing) {
|
|
363
|
+
// #5651: never resolve under an out-of-range default interpreter (poetry dies in _finalize_license_expression on python 3.14).
|
|
364
|
+
const { range, probed } = found.missing;
|
|
365
|
+
return { ...done("failed", { reason: `no python satisfying the declared range "${range}" was found (probed: ${probed.join(", ")}); install one (for example \`uv python install\`) or put pythonX.Y on PATH` }), code: "env.tool_missing" };
|
|
366
|
+
}
|
|
367
|
+
const py = found.py;
|
|
368
|
+
if (py && d.eco === "poetry") {
|
|
369
|
+
try { await exec(py.cmd, ["-m", "poetry", "--version"], { timeoutMs: 30000 }); } catch {
|
|
370
|
+
return { ...done("failed", { reason: `poetry is not available under ${py.cmd} (${py.version}), the interpreter satisfying the declared python range; install it there (for example \`${py.cmd} -m pip install poetry\`) or provide poetry on that interpreter` }), code: "env.tool_missing" };
|
|
371
|
+
}
|
|
372
|
+
}
|
|
356
373
|
const key = await keyOf(wt, d, pkgs, py);
|
|
357
374
|
const snap = join(keyRoot, `${d.eco}-${key}`);
|
|
358
375
|
const cmds = commands(d, py);
|
|
@@ -371,7 +388,9 @@ export function makeDepCache({ root = depcacheRoot(), exec, fs = nodeFs, now = (
|
|
|
371
388
|
const runList = async (list) => {
|
|
372
389
|
for (const [c, a] of list) {
|
|
373
390
|
try { await run(c, a, wt, laneEnv); } catch (e) {
|
|
374
|
-
|
|
391
|
+
const wrapped = py && c === py.cmd && a[0] === "-m" && a[1] === "poetry"; // #5651: `<py> -m poetry ...`
|
|
392
|
+
const sub = wrapped ? a.slice(2) : a;
|
|
393
|
+
if (!(c === "poetry" || wrapped) || sub[0] !== "install" || sub.includes("--no-root") || !NO_ROOT_RE.test(`${msg(e)}\n${e?.stderr ?? ""}\n${e?.stdout ?? ""}`)) throw e;
|
|
375
394
|
await run(c, [...a, "--no-root"], wt, laneEnv);
|
|
376
395
|
repaired = repaired ?? "poetry install --no-root (project is not package-mode)";
|
|
377
396
|
}
|
|
@@ -52,7 +52,9 @@ function fakeExec({ failInstall = false, failRepair = false, installDelayMs = 0,
|
|
|
52
52
|
replace(join(v, "lib/python3.12/site-packages/_proj.pth"), `${cwd}/src\n`); // editable project: per worktree
|
|
53
53
|
};
|
|
54
54
|
const exec = async (cmd, args, { cwd } = {}) => {
|
|
55
|
-
|
|
55
|
+
let via = null; // #5651: `<python> -m poetry ...` is recorded as the poetry call it wraps, with the interpreter in `via`
|
|
56
|
+
if (/^python/.test(cmd) && args[0] === "-m" && args[1] === "poetry") { via = cmd; cmd = "poetry"; args = args.slice(2); if (pythons && args[0] === "--version") return "Poetry 1.8.0\n"; }
|
|
57
|
+
calls.push({ cmd, args: [...args], cwd, via });
|
|
56
58
|
if (cmd === "git" && args[0] === "ls-files") {
|
|
57
59
|
const out = [];
|
|
58
60
|
const walk = (d) => { for (const e of readdirSync(d, { withFileTypes: true })) { if (e.name === "node_modules" || e.name.startsWith(".")) continue; const p = join(d, e.name); if (e.isDirectory()) walk(p); else if (e.name === "package.json") out.push(relative(cwd, p)); } };
|
|
@@ -589,3 +591,100 @@ describe("depcache (#5592 3c): poetry --no-root fallback", () => {
|
|
|
589
591
|
assert.deepEqual(tried, ["install --sync"]);
|
|
590
592
|
});
|
|
591
593
|
});
|
|
594
|
+
|
|
595
|
+
describe("depcache (#5651): no silent fallback to an out-of-range default python", () => {
|
|
596
|
+
const FINALIZE = "AttributeError: module 'packaging' has no attribute '_finalize_license_expression'";
|
|
597
|
+
/** poetry/uv installs that die the way the 3.14 host toolchain did, so an install attempted under the default python is visible. */
|
|
598
|
+
const hostExec = (pythons, tried) => {
|
|
599
|
+
const f = fakeExec({ pythons });
|
|
600
|
+
return { f, exec: async (cmd, args, o) => {
|
|
601
|
+
if ((cmd === "poetry" && args[0] === "install") || (cmd === "uv" && args[0] === "sync")) { tried.push(`${cmd} ${args.join(" ")}`); throw Object.assign(new Error("failed"), { stderr: FINALIZE }); }
|
|
602
|
+
return f.exec(cmd, args, o);
|
|
603
|
+
} };
|
|
604
|
+
};
|
|
605
|
+
const project = (eco, range) => { const base = scratch(), wt = join(base, "wt"); mkdirSync(wt, { recursive: true }); FIXTURES[eco](wt); put(join(wt, "pyproject.toml"), eco === "poetry" ? `[tool.poetry.dependencies]\npython = "${range}"\n` : `[project]\nrequires-python = "${range}"\n`); return { base, wt }; };
|
|
606
|
+
|
|
607
|
+
it("#5651 poetry project with host python outside the range and no in-range interpreter stops with env.tool_missing", async () => {
|
|
608
|
+
const tried = [];
|
|
609
|
+
const { exec, f } = hostExec({ python3: "3.14.0" }, tried);
|
|
610
|
+
const { base, wt } = project("poetry", "~3.11");
|
|
611
|
+
const [r] = await makeDepCache({ root: join(base, "cache"), exec, env: {}, pollMs: 5 }).prepare({ wt, repoKey: "repo-5651" });
|
|
612
|
+
assert.equal(r.status, "failed", JSON.stringify(r));
|
|
613
|
+
assert.equal(r.code, "env.tool_missing");
|
|
614
|
+
assert.match(r.reason, /~3\.11/, "names the declared range");
|
|
615
|
+
assert.match(r.reason, /python3 \(Python 3\.14\.0\)/, "names the interpreters probed");
|
|
616
|
+
assert.match(r.reason, /uv python install/, "says how to provide one");
|
|
617
|
+
assert.deepEqual(tried, [], "the resolver never ran under the default interpreter");
|
|
618
|
+
assert.ok(!f.calls.some((c) => c.cmd === "poetry"), "no poetry call at all");
|
|
619
|
+
});
|
|
620
|
+
it("#5651 uv project with no in-range interpreter stops the same way", async () => {
|
|
621
|
+
const tried = [];
|
|
622
|
+
const { exec, f } = hostExec({ python3: "3.14.0" }, tried);
|
|
623
|
+
const { base, wt } = project("uv", ">=3.10,<3.12");
|
|
624
|
+
const [r] = await makeDepCache({ root: join(base, "cache"), exec, env: {}, pollMs: 5 }).prepare({ wt, repoKey: "repo-5651uv" });
|
|
625
|
+
assert.equal(r.code, "env.tool_missing", JSON.stringify(r));
|
|
626
|
+
assert.ok(!f.calls.some((c) => c.cmd === "uv" && c.args[0] !== "python"), "no uv venv/sync call");
|
|
627
|
+
});
|
|
628
|
+
it("#5651 an in-range interpreter is handed to poetry env use and to uv venv --python", async () => {
|
|
629
|
+
for (const [eco, range, want] of [["poetry", "~3.11", "python3.11 -m poetry env use python3.11"], ["uv", ">=3.10,<3.12", "uv venv --relocatable --python python3.11 .venv"]]) {
|
|
630
|
+
const f = fakeExec({ pythons: { python3: "3.14.0", "python3.11": "3.11.8" } });
|
|
631
|
+
const { base, wt } = project(eco, range);
|
|
632
|
+
const [r] = await makeDepCache({ root: join(base, "cache"), exec: f.exec, env: {}, pollMs: 5 }).prepare({ wt, repoKey: `repo-5651-${eco}` });
|
|
633
|
+
assert.notEqual(r.status, "failed", JSON.stringify(r));
|
|
634
|
+
assert.equal(f.installs().map((c) => `${c.via ? `${c.via} -m ` : ""}${c.cmd} ${c.args.join(" ")}`)[0], want);
|
|
635
|
+
}
|
|
636
|
+
});
|
|
637
|
+
it("#5651 key differs by interpreter version for the same lockfile", async () => {
|
|
638
|
+
const keys = [];
|
|
639
|
+
for (const v of ["3.11.8", "3.11.9"]) {
|
|
640
|
+
const f = fakeExec({ pythons: { python3: "3.14.0", "python3.11": v } });
|
|
641
|
+
const { base, wt } = project("poetry", "~3.11");
|
|
642
|
+
keys.push((await makeDepCache({ root: join(base, "cache"), exec: f.exec, env: {}, pollMs: 5 }).prepare({ wt, repoKey: "repo-5651k" }))[0].key);
|
|
643
|
+
}
|
|
644
|
+
assert.notEqual(keys[0], keys[1]);
|
|
645
|
+
});
|
|
646
|
+
it("#5651 every prepare call (launch, re-place, recovery) probes the interpreter through the same path", async () => {
|
|
647
|
+
const tried = [];
|
|
648
|
+
const { exec, f } = hostExec({ python3: "3.14.0" }, tried);
|
|
649
|
+
const { base, wt } = project("poetry", "~3.11");
|
|
650
|
+
const cache = makeDepCache({ root: join(base, "cache"), exec, env: {}, pollMs: 5 });
|
|
651
|
+
for (const n of [1, 2, 3]) await cache.prepare({ wt, repoKey: "repo-5651e" });
|
|
652
|
+
assert.equal(f.calls.filter((c) => c.cmd === "python3" && c.args[0] === "--version").length, 3, "each entry reaches pythonFor");
|
|
653
|
+
});
|
|
654
|
+
it("#5651 poetry runs under the in-range interpreter, never bare under the host default python", async () => {
|
|
655
|
+
const f = fakeExec({ pythons: { python3: "3.14.0", "python3.11": "3.11.8" } });
|
|
656
|
+
const exec = async (cmd, args, o) => {
|
|
657
|
+
if (cmd === "poetry" && args[0] !== "env") throw Object.assign(new Error("failed"), { stderr: FINALIZE }); // bare poetry = host python 3.14
|
|
658
|
+
return f.exec(cmd, args, o);
|
|
659
|
+
};
|
|
660
|
+
const { base, wt } = project("poetry", "~3.11");
|
|
661
|
+
const [r] = await makeDepCache({ root: join(base, "cache"), exec, env: {}, pollMs: 5 }).prepare({ wt, repoKey: "repo-5651p" });
|
|
662
|
+
assert.notEqual(r.status, "failed", JSON.stringify(r));
|
|
663
|
+
const pc = f.calls.filter((c) => c.cmd === "poetry");
|
|
664
|
+
assert.ok(pc.length >= 2 && pc.every((c) => c.via === "python3.11"), JSON.stringify(pc));
|
|
665
|
+
});
|
|
666
|
+
it("#5651 poetry missing from the in-range interpreter is env.tool_missing", async () => {
|
|
667
|
+
const f = fakeExec({ pythons: { python3: "3.14.0", "python3.11": "3.11.8" } });
|
|
668
|
+
const exec = async (cmd, args, o) => {
|
|
669
|
+
if (cmd === "python3.11" && args[1] === "poetry") throw Object.assign(new Error("No module named poetry"), { code: 1 });
|
|
670
|
+
return f.exec(cmd, args, o);
|
|
671
|
+
};
|
|
672
|
+
const { base, wt } = project("poetry", "~3.11");
|
|
673
|
+
const [r] = await makeDepCache({ root: join(base, "cache"), exec, env: {}, pollMs: 5 }).prepare({ wt, repoKey: "repo-5651m" });
|
|
674
|
+
assert.equal(r.code, "env.tool_missing", JSON.stringify(r));
|
|
675
|
+
assert.match(r.reason, /python3\.11 -m pip install poetry/);
|
|
676
|
+
assert.ok(!f.calls.some((c) => c.cmd === "poetry"));
|
|
677
|
+
});
|
|
678
|
+
it("#5651 --no-root retry works through the wrapped poetry", async () => {
|
|
679
|
+
const f = fakeExec({ pythons: { python3: "3.14.0", "python3.11": "3.11.8" } });
|
|
680
|
+
let first = true;
|
|
681
|
+
const exec = async (cmd, args, o) => {
|
|
682
|
+
if (cmd === "python3.11" && args[1] === "poetry" && args[2] === "install" && !args.includes("--no-root") && first) { first = false; throw Object.assign(new Error("failed"), { stderr: "No file/folder found for package" }); }
|
|
683
|
+
return f.exec(cmd, args, o);
|
|
684
|
+
};
|
|
685
|
+
const { base, wt } = project("poetry", "~3.11");
|
|
686
|
+
const [r] = await makeDepCache({ root: join(base, "cache"), exec, env: {}, pollMs: 5 }).prepare({ wt, repoKey: "repo-5651n" });
|
|
687
|
+
assert.notEqual(r.status, "failed", JSON.stringify(r));
|
|
688
|
+
assert.match(r.reason ?? "", /--no-root/);
|
|
689
|
+
});
|
|
690
|
+
});
|
package/bin/lean/design-gate.mjs
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import { OUTCOME_CODES } from "../engine/outcome-codes.mjs";
|
|
16
16
|
import { globToRegex } from "../../scripts/ci-local/lib.mjs";
|
|
17
|
-
import { designSpecApproved, pageRouteOf } from "./pagegate.mjs";
|
|
17
|
+
import { designSpecApproved, pageRouteOf, pageChange } from "./pagegate.mjs";
|
|
18
18
|
|
|
19
19
|
export const DEFAULT_VIEWPORTS = Object.freeze([390, 1440]);
|
|
20
20
|
const PAGE_ENTRY_RE = /(?:^|\/)page\.[cm]?[jt]sx?$|\.(?:vue|svelte)$/i;
|
|
@@ -60,8 +60,10 @@ export function specApproved({ comments = [], labels = [], cfg = null } = {}) {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
/** Lane-time routing: { route, blocked, pages, reason }. route when a predicted page matches design.routes and has no spec; blocked only with gate: blocking. */
|
|
63
|
-
export function designGate({ files = [], cfg = null, comments = [], labels = [] } = {}) {
|
|
64
|
-
|
|
63
|
+
export function designGate({ files = [], cfg = null, comments = [], labels = [], baseFiles = null } = {}) {
|
|
64
|
+
// #5648: a page already on the base is modified (the precheck judges rewrite vs copy from the diff), generated pages are exempt
|
|
65
|
+
const onBase = new Set(Array.isArray(baseFiles) ? baseFiles.map(norm) : []);
|
|
66
|
+
const pages = designPages(files, cfg).filter((f) => !onBase.has(f) && pageChange(f, { added: [f] }) !== "generated");
|
|
65
67
|
if (!pages.length || specApproved({ comments, labels, cfg })) return { route: false, blocked: false, pages, reason: "" };
|
|
66
68
|
return { route: true, blocked: cfg.gate === "blocking", pages, reason: `page ${pages.slice(0, 3).join(", ")} is under design.routes and the issue has no FORGE:DESIGN_SPEC (label ${cfg.specLabel}); route it to /design before building` };
|
|
67
69
|
}
|
|
@@ -104,15 +106,17 @@ const hasShot = (shots, vp) => (shots ?? []).some((s) => new RegExp(`(?:^|[^0-9]
|
|
|
104
106
|
* `evidence`: { [route]: { screenshots: [paths], verdict: "PASS"|"ITERATE"|"BUDGET-EXHAUSTED" } } from the render critique, consulted only with `rendered: true`.
|
|
105
107
|
* -> { gate, verdict: "SKIP"|"PASS"|"ADVISORY"|"FAIL", routes, rows: [{kind, route, detail}] }. Rows are failures when gate is blocking, warnings otherwise.
|
|
106
108
|
*/
|
|
107
|
-
export function visualGate({ cfg = null, files = [], specs = false, sources = {}, evidence = {}, rendered = false } = {}) {
|
|
109
|
+
export function visualGate({ cfg = null, files = [], specs = false, sources = {}, evidence = {}, rendered = false, changes = {} } = {}) {
|
|
108
110
|
if (!designOn(cfg)) return { gate: null, verdict: "SKIP", routes: [], rows: [], reason: "design.routes is unset" };
|
|
109
|
-
|
|
111
|
+
// #5648: `changes` {file: pageChange class}: generated files are exempt, a copy-only edit needs the visual check but no spec
|
|
112
|
+
const routeFiles = designFiles(files, cfg).filter((f) => changes[f] !== "generated");
|
|
110
113
|
const routes = routeFiles.map((file) => ({ file, route: routeOf(file), page: PAGE_ENTRY_RE.test(file) }));
|
|
111
114
|
const rows = [], add = (kind, route, detail) => rows.push({ kind, route, detail });
|
|
112
115
|
for (const r of routes) {
|
|
113
116
|
const spec = typeof specs === "object" && specs !== null ? Boolean(specs[r.route] ?? specs[r.file]) : Boolean(specs);
|
|
114
|
-
|
|
115
|
-
if (r.page &&
|
|
117
|
+
const copy = changes[r.file] === "copy";
|
|
118
|
+
if (r.page && !spec && !copy) add("design_spec_missing", r.route, `${r.file} has no approved FORGE:DESIGN_SPEC (label ${cfg.specLabel}): run /design first`);
|
|
119
|
+
if (r.page && !copy && sources[r.file] != null) {
|
|
116
120
|
for (const f of critiqueMarkup(sources[r.file])) if (f.severity === "block") add("visual_critique_failed", r.route, `${r.file}: ${f.id}: ${f.detail}`);
|
|
117
121
|
}
|
|
118
122
|
if (rendered && cfg.requireVisual) {
|
|
@@ -129,11 +133,12 @@ export function visualGate({ cfg = null, files = [], specs = false, sources = {}
|
|
|
129
133
|
}
|
|
130
134
|
|
|
131
135
|
/** Lane precheck rows (conformance.unimplemented) for the diff's user-visible routes; [] unless design.routes is set and gate is blocking. */
|
|
132
|
-
export function designFailures({ cfg = null, files = [], specs = false, readFile = () => "" } = {}) {
|
|
136
|
+
export function designFailures({ cfg = null, files = [], specs = false, readFile = () => "", added = null, diff = "" } = {}) {
|
|
133
137
|
if (!designOn(cfg) || cfg.gate !== "blocking") return [];
|
|
134
|
-
const sources = {};
|
|
138
|
+
const sources = {}, changes = {};
|
|
139
|
+
for (const f of designFiles(files, cfg)) changes[f] = pageChange(f, { added, diff, readFile }); // no added list: "new", fail closed
|
|
135
140
|
for (const f of designPages(files, cfg)) sources[f] = String(readFile(f) ?? "");
|
|
136
|
-
return visualGate({ cfg, files, specs, sources }).rows.map((r) => ({ code: OUTCOME_CODES.CONFORMANCE_UNIMPLEMENTED, kind: r.kind, detail: r.detail }));
|
|
141
|
+
return visualGate({ cfg, files, specs, sources, changes }).rows.map((r) => ({ code: OUTCOME_CODES.CONFORMANCE_UNIMPLEMENTED, kind: r.kind, detail: r.detail }));
|
|
137
142
|
}
|
|
138
143
|
|
|
139
144
|
/** Markdown for the FORGE:VISUAL_GATE comment (review-pr-staging). Rendered screenshots are listed by path. */
|
|
@@ -167,3 +167,24 @@ describe("visual gate (#5330 R12, R14; shared with #5369)", () => {
|
|
|
167
167
|
assert.match(c, /FORGE:VISUAL_GATE/); assert.match(c, /Visual gate: PASS/); assert.match(c, /hands-390\.png/);
|
|
168
168
|
});
|
|
169
169
|
});
|
|
170
|
+
|
|
171
|
+
describe("copy-only edits to existing pages (#5648)", () => {
|
|
172
|
+
const P = "web/src/app/(site)/docs/api/search/page.tsx", G = "web/src/app/(site)/docs/api/generated/search/page.tsx";
|
|
173
|
+
const diff = `+++ b/${P}\n-Google\n+the web\n+++ b/${G}\n-Google\n+the web\n`;
|
|
174
|
+
it("visualGate: a copy change needs no spec, generated is exempt, unknown still needs a spec", () => {
|
|
175
|
+
assert.deepEqual(visualGate({ cfg, files: [P, G], specs: false, changes: { [P]: "copy", [G]: "generated" } }).rows, []);
|
|
176
|
+
assert.ok(visualGate({ cfg, files: [P], specs: false, changes: { [P]: "rewrite" } }).rows.some((r) => r.kind === "design_spec_missing"));
|
|
177
|
+
assert.ok(visualGate({ cfg, files: [P], specs: false }).rows.some((r) => r.kind === "design_spec_missing"));
|
|
178
|
+
});
|
|
179
|
+
it("designFailures: modified copy passes without a spec; new or unknown fails closed", () => {
|
|
180
|
+
const a = { ...cfg, gate: "blocking" }, rd = () => Array.from({ length: 30 }, (_, i) => `row ${i}`).join("\n");
|
|
181
|
+
assert.deepEqual(designFailures({ cfg: a, files: [P, G], added: [], diff, readFile: rd }), []);
|
|
182
|
+
assert.ok(designFailures({ cfg: a, files: [P], added: [P], diff, readFile: rd }).some((r) => r.kind === "design_spec_missing"));
|
|
183
|
+
assert.ok(designFailures({ cfg: a, files: [P], readFile: rd }).some((r) => r.kind === "design_spec_missing"));
|
|
184
|
+
});
|
|
185
|
+
it("designGate: a page already on the base is not routed to /design; a generated page is exempt", () => {
|
|
186
|
+
assert.equal(designGate({ files: [P], cfg, baseFiles: [P] }).route, false);
|
|
187
|
+
assert.equal(designGate({ files: [G], cfg }).route, false);
|
|
188
|
+
assert.equal(designGate({ files: [P], cfg }).route, true);
|
|
189
|
+
});
|
|
190
|
+
});
|
package/bin/lean/effects.mjs
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
3
|
/** Core work-on: the real effects behind runCore's injected `io`. Argv only, no shell. */
|
|
4
4
|
import { execFile, execFileSync, spawn } from "node:child_process";
|
|
5
|
-
import { promisify } from "node:util";
|
|
6
5
|
import { readFileSync, appendFileSync, mkdirSync, mkdtempSync, statSync, existsSync, rmSync, writeFileSync, renameSync, readdirSync, lstatSync, readlinkSync, realpathSync } from "node:fs";
|
|
7
6
|
import { homedir, hostname, freemem, loadavg, cpus, tmpdir } from "node:os";
|
|
8
7
|
import { promises as fsp } from "node:fs";
|
|
@@ -31,14 +30,31 @@ import { followupMap } from "./conformance.mjs";
|
|
|
31
30
|
import { toolStats } from "./toolstats.mjs";
|
|
32
31
|
import { detectApiShape } from "./apishape.mjs";
|
|
33
32
|
|
|
34
|
-
|
|
33
|
+
/** #5531: children started by this process's gh/script helpers still running; the schedd kills them on close so none outlives the daemon. */
|
|
34
|
+
const liveChildren = new Set();
|
|
35
|
+
export function killTrackedChildren(signal = "SIGKILL") {
|
|
36
|
+
let n = 0;
|
|
37
|
+
for (const c of liveChildren) { try { if (c.kill(signal)) n++; } catch { /* gone */ } }
|
|
38
|
+
liveChildren.clear();
|
|
39
|
+
return n;
|
|
40
|
+
}
|
|
41
|
+
export const trackedChildCount = () => liveChildren.size;
|
|
42
|
+
const pexec = (bin, args, opts) => new Promise((res, rej) => {
|
|
43
|
+
const child = execFile(bin, args, opts, (err, stdout, stderr) => {
|
|
44
|
+
liveChildren.delete(child);
|
|
45
|
+
if (err) { err.stdout = stdout; err.stderr = stderr; rej(err); } else res({ stdout, stderr });
|
|
46
|
+
});
|
|
47
|
+
liveChildren.add(child);
|
|
48
|
+
});
|
|
35
49
|
const script = (n) => fileURLToPath(new URL(`../../scripts/${n}`, import.meta.url));
|
|
36
50
|
/** Argv-only child with stdin input; resolves stdout, rejects on a non-zero exit with stderr attached. */
|
|
37
51
|
export function runWithInput(bin, args, input, timeout = 120000, env = undefined) {
|
|
38
52
|
return new Promise((res, rej) => {
|
|
39
53
|
const child = execFile(bin, args, { timeout, maxBuffer: 10 * 1024 * 1024, ...(env ? { env } : {}) }, (err, stdout, stderr) => {
|
|
54
|
+
liveChildren.delete(child);
|
|
40
55
|
if (err) { err.stdout = stdout; err.stderr = stderr; rej(err); } else res(String(stdout));
|
|
41
56
|
});
|
|
57
|
+
liveChildren.add(child);
|
|
42
58
|
// A child that exits before reading stdin closes the pipe: EPIPE must reject via the exit callback, never crash the lane.
|
|
43
59
|
child.stdin.on("error", () => {});
|
|
44
60
|
child.stdin.end(input);
|
package/bin/lean/execution.mjs
CHANGED
|
@@ -58,6 +58,7 @@ import { isLaneAlive, launchLane, writeAtomic } from "./batch.mjs";
|
|
|
58
58
|
import { schedDir } from "./sched.mjs";
|
|
59
59
|
import { dockerLabels, safeSegment } from "./ledger.mjs";
|
|
60
60
|
import { OUTCOME_CODES } from "../engine/outcome-codes.mjs";
|
|
61
|
+
import { validateLaneTools } from "../pool/lane-tools.mjs";
|
|
61
62
|
import { resolveCredential, memoKeychain, defaultKeychain } from "./credentials.mjs";
|
|
62
63
|
import { httpTransport, isActionsEndpoint, remoteProvider } from "./sandbox-remote.mjs";
|
|
63
64
|
import { ADMISSION_DEFAULTS } from "./admission.mjs";
|
|
@@ -135,12 +136,14 @@ export function parseExecution(sec = {}) {
|
|
|
135
136
|
.filter((x) => CAPABILITY_RE.test(x.name) && x.pattern && safeRegExp(x.pattern));
|
|
136
137
|
const wsN = Number(str(s.warm_sandboxes));
|
|
137
138
|
const warmSandboxes = str(s.warm_sandboxes) !== "" && Number.isInteger(wsN) && wsN > 0 ? wsN : 0; // #4912: warm sandboxes the pool agent keeps ready; 0 = off
|
|
139
|
+
const lt = validateLaneTools(s.lane_tools); // #5650: invalid entries are dropped here and reported in laneToolsErrors; the remote provider refuses to start with them
|
|
140
|
+
const hfRaw = str(s.host_fallback).toLowerCase(), hostFallback = hfRaw === "true" ? true : hfRaw === "false" ? false : null; // #5652: unset defers to host.role
|
|
138
141
|
const relay = Object.fromEntries(Object.entries(parseRelayCommands(s.relay_commands)).filter(([c]) => CAPABILITY_RE.test(c))); // #4778
|
|
139
142
|
const uw = Number(str(s.unreachable_window_min));
|
|
140
143
|
// #5094: rotator.mjs reads its per-account quota state; #5205: off/none/false disables auto-detection, anything else is unset (auto)
|
|
141
144
|
const rot = str(s.account_rotator).toLowerCase(), accountRotator = rot === "tokenbaton" ? "tokenbaton" : ["off", "none", "false"].includes(rot) ? "off" : null;
|
|
142
145
|
const unreachableWindowMin = str(s.unreachable_window_min) !== "" && Number.isFinite(uw) && uw >= 0 ? uw : null; // unset: providerLanes defaults to 5
|
|
143
|
-
return { mode, maxRemote, provider, image, secrets, budget, ...(hostCapabilities.length ? { hostCapabilities } : {}), ...(hostCapabilityPatterns.length ? { hostCapabilityPatterns } : {}), ...(endpoint ? { endpoint } : {}), ...(tokenEnv ? { tokenEnv } : {}), ...(tokenFile ? { tokenFile } : {}), ...(cacheStore ? { cacheStore } : {}), ...(allowActions ? { allowActions } : {}), ...(fallbackLocal ? { fallbackLocal } : {}), ...(capacityFallbackAfter !== null ? { capacityFallbackAfter } : {}), ...(heavy !== null ? { heavy } : {}), ...(unreachableWindowMin !== null ? { unreachableWindowMin } : {}), ...(Object.keys(relay).length ? { relay } : {}), ...(warmSandboxes ? { warmSandboxes } : {}), ...(accountRotator ? { accountRotator } : {}) };
|
|
146
|
+
return { mode, maxRemote, provider, image, secrets, budget, ...(hostFallback !== null ? { hostFallback } : {}), ...(hostCapabilities.length ? { hostCapabilities } : {}), ...(hostCapabilityPatterns.length ? { hostCapabilityPatterns } : {}), ...(endpoint ? { endpoint } : {}), ...(tokenEnv ? { tokenEnv } : {}), ...(tokenFile ? { tokenFile } : {}), ...(cacheStore ? { cacheStore } : {}), ...(allowActions ? { allowActions } : {}), ...(fallbackLocal ? { fallbackLocal } : {}), ...(capacityFallbackAfter !== null ? { capacityFallbackAfter } : {}), ...(heavy !== null ? { heavy } : {}), ...(unreachableWindowMin !== null ? { unreachableWindowMin } : {}), ...(Object.keys(relay).length ? { relay } : {}), ...(warmSandboxes ? { warmSandboxes } : {}), ...(accountRotator ? { accountRotator } : {}), ...(lt.tools.length ? { laneTools: lt.tools } : {}), ...(lt.errors.length ? { laneToolsErrors: lt.errors } : {}) };
|
|
144
147
|
}
|
|
145
148
|
|
|
146
149
|
const round1 = (x) => Math.round(x * 10) / 10;
|
|
@@ -234,6 +237,15 @@ export function detectNeeds(text, exec = null) {
|
|
|
234
237
|
return [...found].sort();
|
|
235
238
|
}
|
|
236
239
|
|
|
240
|
+
/**
|
|
241
|
+
* #5652: may a remote lane that lacks a tool or host capability be re-placed on the dispatching host? An explicit
|
|
242
|
+
* `execution.host_fallback` wins; else off when forge.yaml `host.role` is `orchestrator`; else on (existing repos unchanged).
|
|
243
|
+
*/
|
|
244
|
+
export function hostFallbackAllowed({ hostFallback = null, hostRole = null } = {}) {
|
|
245
|
+
if (typeof hostFallback === "boolean") return hostFallback;
|
|
246
|
+
return String(hostRole ?? "").trim().toLowerCase() !== "orchestrator";
|
|
247
|
+
}
|
|
248
|
+
|
|
237
249
|
/** Declared host capabilities a remote lane's block summary names (#4542); empty when it names none the host has. */
|
|
238
250
|
export function hostCapabilityBlock(summary, caps = null) {
|
|
239
251
|
// #5080: with no declared capabilities, the read-only prod monitor (the dispatching host's, never a secret) still counts
|
|
@@ -602,6 +614,8 @@ export function usageLimitInTail(tail) {
|
|
|
602
614
|
return { resetAt: RESETS_RE.exec(t)?.[1]?.trim() ?? null };
|
|
603
615
|
}
|
|
604
616
|
|
|
617
|
+
const HALTED = { terminalReason: "deferred", detail: "batch halted (schedd handover); sandbox kept for adopt" }; // #5669: dropped by orchestrate's settle
|
|
618
|
+
|
|
605
619
|
/**
|
|
606
620
|
* Lane seams for `orchestrate()` over a provider, the same contract as batch.mjs `detachedLanes`. `ledgerFor(issue)`
|
|
607
621
|
* returns that sandbox's ledger (ledger.mjs `makeLedger`). #5095: with `holdId` every `rate_limited` result is held under it
|
|
@@ -649,8 +663,10 @@ export function providerLanes({ provider, laneArgs, ledgerFor, env = process.env
|
|
|
649
663
|
detail: `sandbox ${h.id} ${errText(e)}; kept for adopt on resume` });
|
|
650
664
|
const tailOf = async (h) => { try { return typeof logTail === "function" ? String(await logTail(h) ?? "") : ""; } catch { return ""; } };
|
|
651
665
|
const settleClone = (r, id) => (r?.terminalReason === "engine-error" && r.code === undefined && isCloneFailure(r.detail) ? cloneDeferred(id, errLine(r.detail)) : r);
|
|
652
|
-
|
|
666
|
+
// #5669: a halted batch (schedd handover) stops polling; the sandbox is neither torn down nor released, so the next daemon adopts it.
|
|
667
|
+
const wait = async (h, g = guard({ waited: 0, tries: 0 }), sig = null) => {
|
|
653
668
|
for (;;) {
|
|
669
|
+
if (sig?.aborted) return null;
|
|
654
670
|
const r = await g(() => provider.fetchResult(h));
|
|
655
671
|
if (r) return r;
|
|
656
672
|
const st = await g(() => provider.status(h));
|
|
@@ -678,7 +694,7 @@ export function providerLanes({ provider, laneArgs, ledgerFor, env = process.env
|
|
|
678
694
|
: e?.retryable === true
|
|
679
695
|
? { terminalReason: "deferred", code: OUTCOME_CODES.SANDBOX_CAPACITY, detail: `sandbox ${id} could not start (capacity): ${errText(e)}`, ...(Number(e.retryInSeconds) > 0 ? { retryInSeconds: Number(e.retryInSeconds) } : {}) }
|
|
680
696
|
// #5095: a 5xx from the pool router or agent is infrastructure: deferred with backoff (capped), never needs-human
|
|
681
|
-
: (Number.isInteger(e?.status) && e.status >= 500 && e.status <= 599) || e?.transient === true
|
|
697
|
+
: (Number.isInteger(e?.status) && e.status >= 500 && e.status <= 599) || e?.transient === true || (isTransportError(e) && !isCloneFailure(errText(e))) // #5656: fetch failed, ECONNRESET, ETIMEDOUT; a clone timeout keeps its own code
|
|
682
698
|
? { terminalReason: "deferred", code: OUTCOME_CODES.SANDBOX_TRANSIENT, retryInSeconds: Number(e.retryInSeconds) > 0 ? Number(e.retryInSeconds) : TRANSIENT_RETRY_S,
|
|
683
699
|
detail: `sandbox ${id} could not start (transient${Number.isInteger(e?.status) ? ` HTTP ${e.status}` : ""}): ${errText(e)}` }
|
|
684
700
|
: isCloneFailure(errText(e)) ? cloneDeferred(id, errText(e))
|
|
@@ -713,7 +729,8 @@ export function providerLanes({ provider, laneArgs, ledgerFor, env = process.env
|
|
|
713
729
|
if (!Number.isFinite(h.startedAt)) h.startedAt = base.startedAt;
|
|
714
730
|
started = true;
|
|
715
731
|
ctx.onStart?.({ ...(Number.isInteger(h.pid) ? { pid: h.pid } : {}), handle: h, remote: true });
|
|
716
|
-
r = settleClone(await wait(h), base.id);
|
|
732
|
+
r = settleClone(await wait(h, undefined, ctx.signal), base.id);
|
|
733
|
+
if (ctx.signal?.aborted) return HALTED; // #5669: the sandbox stays for adopt, whatever `r` is
|
|
717
734
|
} catch (e) {
|
|
718
735
|
if (started && e?.unreachable) return withUsage(unreachable(h, e), h); // #4672: no tear, the ledger keeps it
|
|
719
736
|
r = started ? settleClone({ terminalReason: "engine-error", detail: `sandbox ${base.id}: ${errText(e)}` }, base.id) : startFailed(base.id, e);
|
|
@@ -741,7 +758,8 @@ export function providerLanes({ provider, laneArgs, ledgerFor, env = process.env
|
|
|
741
758
|
try {
|
|
742
759
|
const ended = await g(() => provider.fetchResult(h));
|
|
743
760
|
if (!ended && (await g(() => provider.status(h))) !== "running") r = null; // relaunched
|
|
744
|
-
else { if (!ended) ctx.onLive?.(); r = await wait(h, g); } // #4504: a live sandbox is awaited in the background
|
|
761
|
+
else { if (!ended) ctx.onLive?.(); r = await wait(h, g, ctx.signal); } // #4504: a live sandbox is awaited in the background
|
|
762
|
+
if (ctx.signal?.aborted) return null; // #5669: halted: left for the next adopt, no tear
|
|
745
763
|
} catch (e) {
|
|
746
764
|
if (e?.unreachable) return withUsage(unreachable(h, e), h); // #4672: same tolerance; no tear, left for the next adopt
|
|
747
765
|
r = { terminalReason: "engine-error", detail: `sandbox ${h.id}: ${errText(e)}` };
|
|
@@ -7,7 +7,8 @@ import { mkdirSync, writeFileSync, existsSync, readFileSync } from "node:fs";
|
|
|
7
7
|
import { join } from "node:path";
|
|
8
8
|
import { tmpDir } from "../tests/_tmp.mjs";
|
|
9
9
|
import { renderContract } from "./render.mjs";
|
|
10
|
-
import { parseExecution, SANDBOX_PROVIDERS, detectNeeds, hostCapabilityBlock, placementText, contractHostNeeds, placement, placeLane, validationWeight, hostHeadroom, scopedEnv, providerLanes, remoteHoldId, usageLimitInTail, isTransportError, isCloneFailure, containerProvider, providerByName, openExecutionBudget, poolCredential, remoteTransportFor } from "./execution.mjs";
|
|
10
|
+
import { parseExecution, hostFallbackAllowed, SANDBOX_PROVIDERS, detectNeeds, hostCapabilityBlock, placementText, contractHostNeeds, placement, placeLane, validationWeight, hostHeadroom, scopedEnv, providerLanes, remoteHoldId, usageLimitInTail, isTransportError, isCloneFailure, containerProvider, providerByName, openExecutionBudget, poolCredential, remoteTransportFor } from "./execution.mjs";
|
|
11
|
+
import { remoteProvider } from "./sandbox-remote.mjs";
|
|
11
12
|
import { makeLedger, countLiveLanes } from "./ledger.mjs";
|
|
12
13
|
import { openBatch } from "./batch.mjs";
|
|
13
14
|
import { orchestrate, formatTable, formatSandboxSummary } from "./orchestrate.mjs";
|
|
@@ -770,6 +771,21 @@ describe("hybrid placement (#4256)", () => {
|
|
|
770
771
|
});
|
|
771
772
|
});
|
|
772
773
|
|
|
774
|
+
describe("#5652: host fallback policy", () => {
|
|
775
|
+
it("parseExecution reads execution.host_fallback only when explicit", () => {
|
|
776
|
+
assert.equal(parseExecution({ mode: "remote" }).hostFallback, undefined);
|
|
777
|
+
assert.equal(parseExecution({ mode: "remote", host_fallback: "true" }).hostFallback, true);
|
|
778
|
+
assert.equal(parseExecution({ mode: "remote", host_fallback: "false" }).hostFallback, false);
|
|
779
|
+
});
|
|
780
|
+
it("hostFallbackAllowed: role orchestrator is off, role unset is on, explicit opt-in overrides", () => {
|
|
781
|
+
assert.equal(hostFallbackAllowed({ hostRole: "orchestrator" }), false);
|
|
782
|
+
assert.equal(hostFallbackAllowed({}), true);
|
|
783
|
+
assert.equal(hostFallbackAllowed({ hostRole: "worker" }), true);
|
|
784
|
+
assert.equal(hostFallbackAllowed({ hostRole: "orchestrator", hostFallback: true }), true);
|
|
785
|
+
assert.equal(hostFallbackAllowed({ hostFallback: false }), false);
|
|
786
|
+
});
|
|
787
|
+
});
|
|
788
|
+
|
|
773
789
|
describe("#4547: fallback_local and agent liveness", () => {
|
|
774
790
|
it("parseExecution: fallback_local is opt-in", () => {
|
|
775
791
|
assert.equal(parseExecution({ mode: "remote", max_remote: "2" }).fallbackLocal, undefined);
|
|
@@ -945,6 +961,29 @@ describe("#5095: launch 5xx and a pool usage limit are deferred, never needs-hum
|
|
|
945
961
|
assert.equal((await lanesFor(prov).runOne(7, null)).retryInSeconds, 12);
|
|
946
962
|
});
|
|
947
963
|
|
|
964
|
+
it("#5656 start transport error (fetch failed, ECONNRESET, ETIMEDOUT): deferred sandbox.transient, never needs-human", async () => {
|
|
965
|
+
const errs = [
|
|
966
|
+
Object.assign(new TypeError("fetch failed"), { cause: Object.assign(new Error("read ECONNRESET"), { code: "ECONNRESET" }) }),
|
|
967
|
+
new TypeError("fetch failed"),
|
|
968
|
+
Object.assign(new Error("connect ETIMEDOUT"), { code: "ETIMEDOUT" }),
|
|
969
|
+
];
|
|
970
|
+
for (const e of errs) {
|
|
971
|
+
const prov = fakeProvider();
|
|
972
|
+
prov.start = async () => { throw e; };
|
|
973
|
+
const r = await lanesFor(prov).runOne(7, null);
|
|
974
|
+
assert.deepEqual([r.terminalReason, r.code, r.retryInSeconds], ["deferred", "sandbox.transient", 60], e.message);
|
|
975
|
+
}
|
|
976
|
+
});
|
|
977
|
+
|
|
978
|
+
it("#5656 a clone timeout on start keeps its clone deferral, not sandbox.transient", async () => {
|
|
979
|
+
const prov = fakeProvider();
|
|
980
|
+
prov.start = async () => { throw new Error("git clone timed out after 120s"); };
|
|
981
|
+
const r = await lanesFor(prov).runOne(7, null);
|
|
982
|
+
assert.equal(r.terminalReason, "deferred");
|
|
983
|
+
assert.notEqual(r.code, "sandbox.transient");
|
|
984
|
+
assert.match(r.detail, /could not clone/);
|
|
985
|
+
});
|
|
986
|
+
|
|
948
987
|
it("a non-auth 4xx config error stays needs-human sandbox.start_failed; 429/503 stay sandbox.capacity", async () => {
|
|
949
988
|
const r = await lanesFor(fakeProvider({ startThrows: 422 })).runOne(7, null);
|
|
950
989
|
assert.deepEqual([r.terminalReason, r.code], ["needs-human", "sandbox.start_failed"]);
|
|
@@ -1124,3 +1163,44 @@ describe("remote/pool credential resolver (#5131)", () => {
|
|
|
1124
1163
|
assert.throws(() => remoteTransportFor({}, { env: {}, router: null }), (e) => e.code === "execution.provider.misconfigured");
|
|
1125
1164
|
});
|
|
1126
1165
|
});
|
|
1166
|
+
|
|
1167
|
+
describe("#5650: execution.lane_tools", () => {
|
|
1168
|
+
it("parses name and name@version, sorted and deduped", () => {
|
|
1169
|
+
assert.deepEqual(parseExecution({ lane_tools: ["promtool@2.54.1", "playwright", "playwright"] }).laneTools, ["playwright", "promtool@2.54.1"]);
|
|
1170
|
+
assert.deepEqual(parseExecution({ lane_tools: "postgresql-client, python@3.12" }).laneTools, ["postgresql-client", "python@3.12"]);
|
|
1171
|
+
});
|
|
1172
|
+
it("invalid entries are dropped and reported by name; empty or absent leaves the shape unchanged", () => {
|
|
1173
|
+
const e = parseExecution({ lane_tools: ["ok", "bad;rm", ""] });
|
|
1174
|
+
assert.deepEqual(e.laneTools, ["ok"]);
|
|
1175
|
+
assert.equal(e.laneToolsErrors.length, 2);
|
|
1176
|
+
assert.ok(e.laneToolsErrors[0].includes("bad;rm"));
|
|
1177
|
+
for (const sec of [{}, { lane_tools: [] }]) { const x = parseExecution(sec); assert.equal("laneTools" in x, false); assert.equal("laneToolsErrors" in x, false); }
|
|
1178
|
+
});
|
|
1179
|
+
it("the remote launch spec carries lane_tools only when set, and start refuses invalid entries", async () => {
|
|
1180
|
+
const mk = (settings) => { const launched = []; const p = remoteProvider({ batch: { id: "b", logFile: () => "/dev/null" }, repo: "o/r", settings, transport: { launch: async (s) => launched.push(s), status: async () => ({ state: "running" }) }, credentials: () => "", gitIdentity: () => ({}) }); return { p, launched }; };
|
|
1181
|
+
const a = mk({ laneTools: ["promtool@2.54.1"] }); await a.p.start({ issue: 1, args: ["--lane", "main"] });
|
|
1182
|
+
assert.deepEqual(a.launched[0].lane_tools, ["promtool@2.54.1"]);
|
|
1183
|
+
const b = mk({}); await b.p.start({ issue: 1, args: [] });
|
|
1184
|
+
assert.equal("lane_tools" in b.launched[0], false);
|
|
1185
|
+
const c = mk({ laneToolsErrors: ['invalid execution.lane_tools entry "x;y"'] });
|
|
1186
|
+
await assert.rejects(c.p.start({ issue: 1 }), (err) => err.code === "lane_tools.invalid" && err.message.includes("x;y"));
|
|
1187
|
+
assert.equal(c.launched.length, 0);
|
|
1188
|
+
});
|
|
1189
|
+
});
|
|
1190
|
+
|
|
1191
|
+
describe("providerLanes: a halted batch keeps its sandbox for adopt (#5669)", () => {
|
|
1192
|
+
it("#5669: a halt while the sandbox runs neither tears it down nor releases the ledger; adopt reattaches", async () => {
|
|
1193
|
+
const prov = fakeProvider(); const root = tmpDir("exec-halt-"); const ledgerFor = ledgerIn(root);
|
|
1194
|
+
const l = providerLanes({ provider: prov, laneArgs: () => [], ledgerFor, pollMs: 5 });
|
|
1195
|
+
const ac = new AbortController();
|
|
1196
|
+
const run = l.runOne(8, "main", { signal: ac.signal });
|
|
1197
|
+
await new Promise((r) => setTimeout(r, 30));
|
|
1198
|
+
ac.abort();
|
|
1199
|
+
prov.results[8] = { terminalReason: "merged", pr: 8 }; prov.live.delete(8);
|
|
1200
|
+
await run;
|
|
1201
|
+
assert.deepEqual(prov.calls.filter((c) => c[0] === "teardown"), [], "no teardown after the halt");
|
|
1202
|
+
assert.ok(ledgerFor(8).entries("sandbox").some((e) => e.value === "fake-8"), "ledger entry kept");
|
|
1203
|
+
const r = await l.adopt(8, { handle: { provider: "fake", id: "fake-8", issue: 8 } }, {});
|
|
1204
|
+
assert.equal(r.terminalReason, "merged");
|
|
1205
|
+
});
|
|
1206
|
+
});
|
|
@@ -17,7 +17,7 @@ describe("#4656 gate watchdog", () => {
|
|
|
17
17
|
it("the batch runner reports GATE_DEADLOCK once per (gate, issue) for a parked issue on the gate, instead of waiting", async () => {
|
|
18
18
|
const rows = [], decisions = [];
|
|
19
19
|
const runOne = async (n) => n === 1
|
|
20
|
-
? { terminalReason: "needs-human", code: "conformance.
|
|
20
|
+
? { terminalReason: "needs-human", code: "conformance.guard_broken", detail: "unknown requirement", pr: 9 }
|
|
21
21
|
: { terminalReason: "merged", pr: 10 };
|
|
22
22
|
const _unused = async (n) => n === 1
|
|
23
23
|
? { terminalReason: "needs-human", code: "ci.red", detail: "lint failed", pr: 9 }
|
|
@@ -29,13 +29,13 @@ describe("#4656 gate watchdog", () => {
|
|
|
29
29
|
assert.equal(dl.length, 1);
|
|
30
30
|
assert.match(dl[0].detail, /GATE_DEADLOCK issue=#1 gate=ship/);
|
|
31
31
|
assert.ok(Array.isArray(res));
|
|
32
|
-
assert.deepEqual(relabels.map((r) => r.parked?.code), ["conformance.
|
|
32
|
+
assert.deepEqual(relabels.map((r) => r.parked?.code), ["conformance.guard_broken"]);
|
|
33
33
|
});
|
|
34
34
|
});
|
|
35
35
|
|
|
36
36
|
describe("#4656 parked class and migration", () => {
|
|
37
37
|
it("parked is opt-in and leaves the default classes untouched", () => {
|
|
38
|
-
const row = { outcome: "needs-human", code: "conformance.
|
|
38
|
+
const row = { outcome: "needs-human", code: "conformance.guard_broken" };
|
|
39
39
|
assert.equal(classifyNeedsHuman(row), "terminal");
|
|
40
40
|
assert.equal(classifyNeedsHuman(row, { parked: true }), "parked");
|
|
41
41
|
assert.equal(classifyNeedsHuman({ outcome: "needs-human", code: "builder.blocked" }, { parked: true }), "human");
|
|
@@ -53,7 +53,7 @@ describe("#4656 parked class and migration", () => {
|
|
|
53
53
|
describe("#4656 report routing", () => {
|
|
54
54
|
it("a parked row past recovery is listed on the remediation queue line, not unrecovered or escalations", async () => {
|
|
55
55
|
const { formatOutcomeLists } = await import("./orchestrate.mjs");
|
|
56
|
-
const lines = formatOutcomeLists([{ issue: 1, outcome: "needs-human", code: "conformance.
|
|
57
|
-
assert.deepEqual(lines, ["remediation queue (/work-on:remediate): #1 (parked:conformance.
|
|
56
|
+
const lines = formatOutcomeLists([{ issue: 1, outcome: "needs-human", code: "conformance.guard_broken", pr: 9, parkedQueued: true }]);
|
|
57
|
+
assert.deepEqual(lines, ["remediation queue (/work-on:remediate): #1 (parked:conformance.guard_broken PR #9)"]);
|
|
58
58
|
});
|
|
59
59
|
});
|