forgedock 1.56.0 → 1.57.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/config-schema.mjs +1 -1
- package/bin/engine/outcome-codes.mjs +1 -0
- package/bin/engine/phases.mjs +4 -3
- package/bin/engine-cli.mjs +46 -10
- package/bin/forgedock.mjs +52 -3
- package/bin/gc.mjs +43 -6
- package/bin/help-text.mjs +3 -1
- package/bin/lean/batch-health.mjs +5 -1
- package/bin/lean/batch-health.test.mjs +7 -1
- package/bin/lean/batch.mjs +7 -2
- package/bin/lean/batch.test.mjs +45 -0
- package/bin/lean/conformance.e2e.test.mjs +3 -2
- package/bin/lean/conformance.mjs +88 -17
- package/bin/lean/conformance.test.mjs +98 -3
- package/bin/lean/decisions.mjs +86 -1
- package/bin/lean/decisions.test.mjs +21 -1
- package/bin/lean/depcache.mjs +124 -13
- package/bin/lean/depcache.test.mjs +121 -3
- package/bin/lean/design-gate.mjs +144 -0
- package/bin/lean/design-gate.test.mjs +169 -0
- package/bin/lean/effects-cap.test.mjs +17 -0
- package/bin/lean/effects.mjs +58 -13
- package/bin/lean/heavy.mjs +25 -8
- package/bin/lean/hostload.test.mjs +28 -0
- package/bin/lean/intake.mjs +97 -0
- package/bin/lean/intake.test.mjs +105 -0
- package/bin/lean/interfaces.mjs +181 -0
- package/bin/lean/interfaces.test.mjs +192 -0
- package/bin/lean/issuewatch-install.mjs +52 -12
- package/bin/lean/issuewatch-install.test.mjs +50 -0
- package/bin/lean/issuewatch-parity.mjs +12 -2
- package/bin/lean/issuewatch-parity.test.mjs +26 -0
- package/bin/lean/issuewatch-reconcile.mjs +29 -1
- package/bin/lean/issuewatch-reconcile.test.mjs +21 -0
- package/bin/lean/issuewatch.mjs +34 -3
- package/bin/lean/issuewatch.test.mjs +49 -1
- package/bin/lean/lanecheck.test.mjs +15 -4
- package/bin/lean/lean.mjs +72 -21
- package/bin/lean/lean.test.mjs +149 -3
- package/bin/lean/orchestrate-blocked.test.mjs +18 -2
- package/bin/lean/orchestrate-owned.test.mjs +14 -5
- package/bin/lean/orchestrate.mjs +26 -4
- package/bin/lean/orphan-pr.mjs +3 -2
- package/bin/lean/orphan-pr.test.mjs +8 -1
- package/bin/lean/pagegate.mjs +35 -12
- package/bin/lean/pagegate.test.mjs +39 -1
- package/bin/lean/preflight.mjs +35 -1
- package/bin/lean/preflight.test.mjs +27 -1
- package/bin/lean/prompts.mjs +2 -1
- package/bin/lean/reap.test.mjs +39 -0
- package/bin/lean/recovery.test.mjs +25 -0
- package/bin/lean/release-config.mjs +158 -0
- package/bin/lean/release-config.test.mjs +109 -0
- package/bin/lean/release-control.mjs +148 -0
- package/bin/lean/release-control.test.mjs +143 -0
- package/bin/lean/release-fence.mjs +50 -0
- package/bin/lean/release-fence.test.mjs +105 -0
- package/bin/lean/release-flakes.mjs +139 -0
- package/bin/lean/release-flakes.test.mjs +116 -0
- package/bin/lean/release-ledger.mjs +160 -0
- package/bin/lean/release-ledger.test.mjs +226 -0
- package/bin/lean/release-minutes.mjs +92 -0
- package/bin/lean/release-minutes.test.mjs +99 -0
- package/bin/lean/release-nightly.mjs +75 -0
- package/bin/lean/release-nightly.test.mjs +48 -0
- package/bin/lean/release-postmerge.mjs +8 -2
- package/bin/lean/release-review.e2e.test.mjs +1 -0
- package/bin/lean/release-review.mjs +54 -7
- package/bin/lean/release-review.test.mjs +76 -7
- package/bin/lean/release-unitmap.mjs +35 -0
- package/bin/lean/release-unitmap.test.mjs +41 -0
- package/bin/lean/release.mjs +177 -19
- package/bin/lean/release.test.mjs +40 -0
- package/bin/lean/render.mjs +3 -1
- package/bin/lean/run-issue-placement.test.mjs +82 -0
- package/bin/lean/sandbox-remote.mjs +16 -0
- package/bin/lean/schedd.mjs +1 -1
- package/bin/lean/seam.mjs +115 -0
- package/bin/lean/seam.test.mjs +118 -0
- package/bin/lean/selftest-journey.mjs +40 -2
- package/bin/lean/selftest-journey.test.mjs +43 -3
- package/bin/lean/statuscomment.mjs +168 -0
- package/bin/lean/statuscomment.test.mjs +133 -0
- package/bin/lean/ui-quality.mjs +57 -0
- package/bin/lean/ui-quality.test.mjs +55 -0
- package/bin/lean/visual-gate.test.mjs +63 -0
- package/bin/pool/agent.mjs +16 -2
- package/bin/pool/router.mjs +5 -1
- package/bin/review-staging.mjs +5 -3
- package/bin/stats/card.mjs +117 -0
- package/bin/stats/card.test.mjs +109 -0
- package/bin/stats/conformance-outcomes.test.mjs +2 -1
- package/bin/stats/depth.mjs +1 -1
- package/bin/stats/gh-retry.test.mjs +152 -0
- package/bin/stats/github-source.mjs +147 -14
- package/bin/stats/index.mjs +35 -2
- package/bin/stats/stats.test.mjs +31 -3
- package/bin/vendor/js-yaml/LICENSE +21 -0
- package/bin/vendor/js-yaml/PIN.md +7 -0
- package/bin/vendor/js-yaml/js-yaml.mjs +3851 -0
- package/commands/design-render-critique-loop.md +2 -0
- package/commands/design.md +2 -0
- package/commands/issue.md +1 -1
- package/commands/milestone.md +1 -1
- package/commands/review-pr-agents/frontend.md +1 -0
- package/commands/review-pr-staging.md +5 -0
- package/docs/CONFIG.md +75 -1
- package/docs/ISSUE-WATCH.md +7 -0
- package/docs/OUTCOME-CODES.md +1 -0
- package/docs/STATS.md +10 -0
- package/docs/design/visual-gate.md +25 -0
- package/docs/eval/adversarial-bench.md +2 -2
- package/docs/eval/corpus/adversarial-v1.json +3 -3
- package/docs/site/start-a-new-project.md +7 -0
- package/docs/spec/forge-protocol-v1.md +31 -0
- package/package.json +1 -1
- package/pool/README.md +2 -0
- package/scripts/acceptance-red-green.sh +15 -1
- package/scripts/acceptance-red-green.test.sh +12 -0
- package/scripts/bench-adversarial.mjs +4 -0
- package/scripts/bench-lightlane.mjs +4 -1
- package/scripts/bootstrap-create.mjs +8 -2
- package/scripts/ci-local.test.sh +3 -3
- package/scripts/fixtures/ci-local/gha-dorny/.github/workflows/ci.yml +4 -0
- package/scripts/plan-validate-live.mjs +9 -6
- package/scripts/review-prepare.sh +7 -1
- package/scripts/review-roster.sh +5 -2
- package/scripts/review-roster.test.sh +9 -0
- package/scripts/visual-gate.mjs +64 -0
- package/templates/bootstrap/technical-spike.md +17 -0
- package/templates/contracts/seam-check.mjs +236 -0
package/bin/lean/lean.test.mjs
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
|
|
2
2
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
|
+
import { parseStatus } from "./statuscomment.mjs";
|
|
3
4
|
import { foldRegression } from "./baselines.mjs";
|
|
4
5
|
import { describe, it } from "node:test";
|
|
5
6
|
import { laneBackendId } from "./limits.mjs";
|
|
6
7
|
import { parseExperiment, assignArm } from "../experiment.mjs";
|
|
7
8
|
import assert from "node:assert/strict";
|
|
8
9
|
import { tmpDir } from "../tests/_tmp.mjs";
|
|
10
|
+
import { normaliseDecision, writeDecisionIndex } from "./decisions.mjs"; // #5338
|
|
9
11
|
import { execFileSync } from "node:child_process";
|
|
10
12
|
import { writeFileSync, existsSync, readFileSync, mkdirSync, symlinkSync, readdirSync, chmodSync } from "node:fs";
|
|
11
13
|
import { join } from "node:path";
|
|
@@ -71,9 +73,18 @@ const bad = (note = "src/foo.js:9 still wrong", verdict = "NONCONFORMING") => co
|
|
|
71
73
|
const genericPass = () => fence({ verdict: "PASS", fixes_issue: true, regression: false, reason: "looks good" });
|
|
72
74
|
|
|
73
75
|
/** In-memory world with fake gh, git, fs and runner. */
|
|
76
|
+
/** #5592: `w.comments` stays the list of logical per-marker comments (what the lane wrote), whether it posted them or edited them into the FORGE:STATUS comment. */
|
|
77
|
+
function statusLogical(w, body) {
|
|
78
|
+
w.statusBody = body;
|
|
79
|
+
for (const [key, { markers, text }] of parseStatus(body)) {
|
|
80
|
+
if (w.statusSections[key] === text) continue;
|
|
81
|
+
w.statusSections[key] = text;
|
|
82
|
+
w.comments.push(`${markers.map((m) => `<!-- ${m} -->`).join("\n")}\n${text}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
74
85
|
function world(o = {}) {
|
|
75
86
|
const w = {
|
|
76
|
-
comments: [], labels: [], closed: [], edits: [], prs: [], merges: [], calls: [], telemetry: [], files: {}, head: "aaaa1111aaaa1111", followups: [], prEdits: [], patches: [],
|
|
87
|
+
comments: [], rawComments: [], statusPatches: [], statusSections: {}, labels: [], closed: [], edits: [], prs: [], merges: [], calls: [], telemetry: [], files: {}, head: "aaaa1111aaaa1111", followups: [], prEdits: [], patches: [],
|
|
77
88
|
contract: o.contract ?? CONTRACT, issueComments: o.issueComments, issueStates: o.issueStates,
|
|
78
89
|
changed: o.changed ?? ["src/foo.js", "test/foo.test.js"], reviews: [...(o.reviews ?? [])], waits: [...(o.waits ?? [])], clock: 0,
|
|
79
90
|
result: o.result ?? { status: "fixed", summary: "fixed foo", evidence: [], tests: ["test/foo.test.js"] },
|
|
@@ -91,17 +102,19 @@ function world(o = {}) {
|
|
|
91
102
|
const k = a.slice(0, 2).join(" ");
|
|
92
103
|
if (opts?.env) (w.ghEnvs ??= []).push(opts.env);
|
|
93
104
|
if (k === "pr view" && a.at(-1) === "state" && a.at(-2) === "--json") return JSON.stringify({ state: o.prState ?? "OPEN" });
|
|
105
|
+
if (a[0] === "api" && a.includes("PATCH") && a.some((x) => /\/comments\/9000$/.test(x))) { statusLogical(w, a[a.indexOf("-f") + 1].replace(/^body=/, "")); w.statusPatches.push(a); return "{}"; } // #5592: the one FORGE:STATUS comment
|
|
94
106
|
if (a[0] === "api" && a.includes("PATCH")) { w.patches.push(a); return "{}"; }
|
|
95
107
|
if (a[0] === "api") return a.some((x) => /\/comments$/.test(x)) ? (w.issueComments ?? []).map((c) => JSON.stringify(c)).join("\n") : "";
|
|
96
108
|
if (k === "pr list") return JSON.stringify(w.prList);
|
|
97
109
|
if (k === "repo view") return `${o.defaultBranch ?? "main"}\n`;
|
|
98
110
|
if (k === "issue view" && a.includes("milestone")) { w.seq.push("lane"); return JSON.stringify({ milestone: o.milestone ? { title: o.milestone } : null }); }
|
|
99
|
-
if (k === "issue view" && o.issueBodies && a[2] === "7" && a.some((x) => String(x).startsWith("number,title,body,state,comments"))) { const b = o.issueBodies.length > 1 ? o.issueBodies.shift() : o.issueBodies[0]; return JSON.stringify({ number: 7, title: o.title ?? "foo breaks", body: b, state: "OPEN", comments: o.viewComments ?? [] }); }
|
|
111
|
+
if (k === "issue view" && o.issueBodies && a[2] === "7" && a.some((x) => String(x).startsWith("number,title,body,state,comments"))) { const b = o.issueBodies.length > 1 ? o.issueBodies.shift() : o.issueBodies[0]; return JSON.stringify({ number: 7, title: o.title ?? "foo breaks", body: b, state: "OPEN", comments: o.viewComments ?? [], ...(o.labels ? { labels: o.labels } : {}) }); }
|
|
100
112
|
if (k === "issue view") return JSON.stringify({ number: Number(a[2]), title: a[2] === "7" && o.title ? o.title : "foo breaks", body: a[2] === "7" && o.body ? o.body : ISSUE_BODY, state: w.issueStates?.[a[2]] ?? "OPEN", comments: [], ...(o.labels && a[2] === "7" ? { labels: o.labels } : {}) });
|
|
101
113
|
if (k === "pr edit") { w.prEdits.push(a); return ""; }
|
|
102
114
|
if (k === "label create") { w.labelCreates = [...(w.labelCreates ?? []), a]; return ""; }
|
|
103
115
|
if (k === "issue comment" && w.commentErrors.length) throw new Error(w.commentErrors.shift());
|
|
104
|
-
if (k === "issue comment") { w.
|
|
116
|
+
if (k === "issue comment" && a[a.indexOf("--body") + 1].startsWith("<!-- FORGE:STATUS -->")) { w.rawComments.push(a[a.indexOf("--body") + 1]); statusLogical(w, a[a.indexOf("--body") + 1]); w.seq.push("comment"); return "https://github.com/o/r/issues/7#issuecomment-9000\n"; }
|
|
117
|
+
if (k === "issue comment") { w.comments.push(a[a.indexOf("--body") + 1]); w.rawComments.push(a[a.indexOf("--body") + 1]); w.seq.push("comment"); return `https://github.com/o/r/issues/7#issuecomment-${w.comments.length}\n`; }
|
|
105
118
|
if (k === "issue close") { w.closed.push(a); w.seq.push("close"); return ""; }
|
|
106
119
|
if (k === "issue edit") { w.edits.push(a); return ""; }
|
|
107
120
|
if (k === "pr create") { w.prs.push(a); w.seq.push("pr"); return "https://github.com/o/r/pull/77\n"; }
|
|
@@ -295,6 +308,16 @@ describe("core work-on", () => {
|
|
|
295
308
|
assert.equal(reviewers(w).length, 0);
|
|
296
309
|
});
|
|
297
310
|
|
|
311
|
+
it("#5518 already-fixed on a resumed lane closes the issue: the lane's own open PR is not a close blocker, another own PR still is", async () => {
|
|
312
|
+
const own = { number: 77, headRefOid: "x", headRefName: "feat/issue-7-lean", baseRefName: "staging", body: "Closes #7" };
|
|
313
|
+
const w = world({ changed: [], prList: [own], remote: "abc\trefs/heads/feat/issue-7-lean", result: { status: "already-fixed", summary: "done upstream", evidence: ["a.js:1"], tests: [] } });
|
|
314
|
+
assert.equal((await run(w)).terminalReason, "invalid");
|
|
315
|
+
assert.deepEqual(w.closed.map((a) => a[a.indexOf("--reason") + 1]), ["completed"]);
|
|
316
|
+
const w2 = world({ changed: [], prList: [own, { number: 78, headRefName: "feat/other", body: "<!-- FORGE:ISSUE_PR issue=7 -->" }], remote: "abc\trefs/heads/feat/issue-7-lean", result: { status: "already-fixed", summary: "done upstream", evidence: ["a.js:1"], tests: [] } });
|
|
317
|
+
await run(w2);
|
|
318
|
+
assert.equal(w2.closed.length, 0, "a different open PR for the issue still blocks");
|
|
319
|
+
});
|
|
320
|
+
|
|
298
321
|
it("already-fixed with evidence also closes, as completed (#5152)", async () => {
|
|
299
322
|
const w = world({ changed: [], result: { status: "already-fixed", summary: "done upstream", evidence: ["a.js:1"], tests: [] } });
|
|
300
323
|
assert.equal((await run(w)).terminalReason, "invalid");
|
|
@@ -1857,6 +1880,31 @@ describe("conformance shadow mode (the default)", () => {
|
|
|
1857
1880
|
assert.equal(readdirSync(dir).length, 1);
|
|
1858
1881
|
} finally { if (prev === undefined) delete process.env.FORGEDOCK_DECISIONS_DIR; else process.env.FORGEDOCK_DECISIONS_DIR = prev; }
|
|
1859
1882
|
});
|
|
1883
|
+
it("#5338 a merged supersedes decision on an interface reopens its closed consumers, notifies open ones and files one issue per named consumer", async () => {
|
|
1884
|
+
const dir = tmpDir("ifc-"); const prev = process.env.FORGEDOCK_DECISIONS_DIR; process.env.FORGEDOCK_DECISIONS_DIR = dir;
|
|
1885
|
+
try {
|
|
1886
|
+
const seeded = normaliseDecision({ id: "i40-1", choice: "Interface web -> api: POST /v1/search", anchors: ["src/"], issue: 40, consumers: ["#12", "#13", "search-sdk"], seam: { kind: "payload", auth: "k", payload: { fields: ["q"] }, provider: ["src/"], consumer: ["web/"] } });
|
|
1887
|
+
writeDecisionIndex("o/r", [seeded]);
|
|
1888
|
+
const amendments = [{ kind: "decision", why: "v2", decision: { choice: "Interface web -> api: POST /v2/search", anchors: ["src/db.ts"], supersedes: "i40-1" } }];
|
|
1889
|
+
const w = world({ amendments, issueStates: { 12: "CLOSED", 13: "OPEN" } });
|
|
1890
|
+
const base = w.io.gh, calls = [];
|
|
1891
|
+
w.io.gh = async (a, opts) => {
|
|
1892
|
+
const k = a.slice(0, 2).join(" ");
|
|
1893
|
+
if (k === "issue reopen") { calls.push(a.join(" ")); return ""; }
|
|
1894
|
+
if (k === "issue list") return "[]";
|
|
1895
|
+
if (k === "issue create") { calls.push(a.join(" ")); return "https://github.com/o/r/issues/99\n"; }
|
|
1896
|
+
return base(a, opts);
|
|
1897
|
+
};
|
|
1898
|
+
const r = await runShadow(w);
|
|
1899
|
+
assert.equal(r.terminalReason, "merged");
|
|
1900
|
+
assert.ok(calls.includes("issue reopen 12 -R o/r"), "the closed consumer is reopened");
|
|
1901
|
+
assert.ok(!calls.some((c) => c.startsWith("issue reopen 13")), "an open consumer is only told");
|
|
1902
|
+
assert.ok(calls.some((c) => c.startsWith("issue create") && /Adapt search-sdk to interface change/.test(c)), "one issue for the named consumer");
|
|
1903
|
+
assert.ok(w.comments.some((c) => c.includes("FORGE:INTERFACE_CHANGED") && c.includes("consumer=#12")));
|
|
1904
|
+
assert.ok(w.comments.some((c) => c.includes("FORGE:INTERFACE_CHANGED") && c.includes("consumer=#13")));
|
|
1905
|
+
assert.ok(w.comments.some((c) => /Interface i40-1 superseded by d\S+: #12 reopened #12, #13 notified #13, search-sdk filed #99/.test(c)), "the trajectory records it");
|
|
1906
|
+
} finally { if (prev === undefined) delete process.env.FORGEDOCK_DECISIONS_DIR; else process.env.FORGEDOCK_DECISIONS_DIR = prev; }
|
|
1907
|
+
});
|
|
1860
1908
|
it("#4160 scope creep found by the precheck stays recorded-only in shadow", async () => {
|
|
1861
1909
|
const w = world({ changed: ["src/foo.js", "src/billing.js", "test/foo.test.js"], reviews: [conf({}, CONTRACT, ["src/foo.js", "src/billing.js", "test/foo.test.js"])] });
|
|
1862
1910
|
assert.equal((await runShadow(w)).terminalReason, "merged");
|
|
@@ -2271,6 +2319,14 @@ describe("bug lanes freeze a red-green repro_test (#4271)", () => {
|
|
|
2271
2319
|
}
|
|
2272
2320
|
});
|
|
2273
2321
|
|
|
2322
|
+
it("#5544 test-only fix whose base version fails is merged, not already-fixed", async () => {
|
|
2323
|
+
const contract = { ...CONTRACT, repro_test: RT, deliverables: [{ id: "D1", path: "test/foo.test.js", change: "fix the test", requirements: ["R1"] }] }; // the bug is in the test itself
|
|
2324
|
+
const w = rworld([{ base: "RAN", head: "RAN", pristine: "FAILED" }], { changed: ["test/foo.test.js"], contract });
|
|
2325
|
+
const r = await run(w);
|
|
2326
|
+
assert.equal(r.terminalReason, "merged"); assert.equal(w.merges.length, 1);
|
|
2327
|
+
assert.equal(w.closed.some((c) => /Already fixed on the base/.test(c.join(" "))), false, "not closed as already fixed");
|
|
2328
|
+
});
|
|
2329
|
+
|
|
2274
2330
|
it("a repro test the harness cannot run on head (or no harness result) is env.repro_unrunnable: recoverable, no resume, no reviewer (#4334)", async () => {
|
|
2275
2331
|
for (const conformance of ["enforce", "shadow"]) {
|
|
2276
2332
|
for (const rg of [{ base: "SKIPPED", head: "UNRUNNABLE" }, null]) {
|
|
@@ -8567,3 +8623,93 @@ describe("#5469: --adopt takes over a hand-built open PR", () => {
|
|
|
8567
8623
|
assert.equal(r.terminalReason, "merged");
|
|
8568
8624
|
});
|
|
8569
8625
|
});
|
|
8626
|
+
|
|
8627
|
+
describe("design gate routing in the lane (#5330 R11, R13, R15)", () => {
|
|
8628
|
+
const PAGE = "web/app/hands/page.tsx";
|
|
8629
|
+
const pageContract = { ...CONTRACT, deliverables: [{ id: "D1", path: PAGE, change: "new hands page", requirements: ["R1"] }] };
|
|
8630
|
+
const dg = (gate = "blocking") => ({ system: [], routes: ["web/app/**/page.tsx"], exclude: [], gate, specLabel: "design:approved", neededLabel: "design:needed", viewports: [390, 1440], requireVisual: true });
|
|
8631
|
+
const mk = (o = {}) => world({ contract: pageContract, changed: [PAGE, "test/foo.test.js"], reviews: [conf({}, pageContract, [PAGE, "test/foo.test.js"])], ...o });
|
|
8632
|
+
|
|
8633
|
+
it("blocking: a predicted new page under design.routes with no FORGE:DESIGN_SPEC stops pending /design, before any build", async () => {
|
|
8634
|
+
const w = mk(), r = await run(w, { designConfig: dg("blocking") });
|
|
8635
|
+
assert.equal(r.terminalReason, "needs-human");
|
|
8636
|
+
assert.equal(r.code, OUTCOME_CODES.DESIGN_SPEC_REQUIRED);
|
|
8637
|
+
assert.ok(w.comments.some((c) => c.includes("FORGE:NEEDS_HUMAN") && /Run \/design/.test(c) && c.includes(PAGE)));
|
|
8638
|
+
assert.equal(builders(w).length, 1, "only the plan call ran; the implement call never started");
|
|
8639
|
+
});
|
|
8640
|
+
|
|
8641
|
+
it("the design:approved label lifts the hold: the lane builds", async () => {
|
|
8642
|
+
const w = mk({ labels: [{ name: "design:approved" }] }), r = await run(w, { designConfig: dg("blocking") });
|
|
8643
|
+
assert.notEqual(r.code, OUTCOME_CODES.DESIGN_SPEC_REQUIRED);
|
|
8644
|
+
assert.ok(builders(w).length >= 2);
|
|
8645
|
+
});
|
|
8646
|
+
|
|
8647
|
+
it("advisory: routed to /design in the implement prompt, never blocked", async () => {
|
|
8648
|
+
const w = mk(), r = await run(w, { designConfig: dg("advisory") });
|
|
8649
|
+
assert.notEqual(r.code, OUTCOME_CODES.DESIGN_SPEC_REQUIRED);
|
|
8650
|
+
assert.ok(builders(w).some((c) => /Design gate: page web\/app\/hands\/page\.tsx/.test(c[4])));
|
|
8651
|
+
});
|
|
8652
|
+
|
|
8653
|
+
it("opt-in: with no design.routes the lane is today's (no design prompt, no block)", async () => {
|
|
8654
|
+
for (const extra of [{}, { designConfig: { ...dg(), routes: [] } }]) {
|
|
8655
|
+
const w = mk(), r = await run(w, extra);
|
|
8656
|
+
assert.notEqual(r.code, OUTCOME_CODES.DESIGN_SPEC_REQUIRED);
|
|
8657
|
+
assert.ok(!builders(w).some((c) => /Design gate:/.test(c[4])));
|
|
8658
|
+
}
|
|
8659
|
+
});
|
|
8660
|
+
});
|
|
8661
|
+
|
|
8662
|
+
describe("#5592 (8) comment and label spam", () => {
|
|
8663
|
+
const BOTC = { author: { login: "rapiercraft-forgedock" }, authorAssociation: "CONTRIBUTOR" };
|
|
8664
|
+
const SEP = "<!-- FORGE:STATUS:SEP -->";
|
|
8665
|
+
const oldStatus = `<!-- FORGE:STATUS -->\n${SEP}\n<!-- FORGE:STARTED -->\nStarted work on #7 (base \`staging\`).\n${SEP}\n<!-- FORGE:TRAJECTORY -->\n<!-- FORGE:WORK-ON -->\nold run trajectory`;
|
|
8666
|
+
const statusComments = (w) => w.rawComments.filter((c) => c.startsWith("<!-- FORGE:STATUS -->"));
|
|
8667
|
+
|
|
8668
|
+
it("a fresh run puts STARTED, TRAJECTORY (and LANE_BRANCH/CONTEXT/DECISION) into ONE status comment, edited in place", async () => {
|
|
8669
|
+
const w = world();
|
|
8670
|
+
const r = await run(w);
|
|
8671
|
+
assert.equal(r.terminalReason, "merged");
|
|
8672
|
+
assert.equal(statusComments(w).length, 1, "the status comment is created once");
|
|
8673
|
+
assert.ok(w.statusPatches.length >= 1, "later machine-state markers PATCH it");
|
|
8674
|
+
const body = w.statusBody;
|
|
8675
|
+
assert.match(body, /<!-- FORGE:STARTED -->\nStarted work on #7/);
|
|
8676
|
+
assert.match(body, /<!-- FORGE:TRAJECTORY -->\n<!-- FORGE:WORK-ON -->/);
|
|
8677
|
+
assert.ok(!w.rawComments.some((c) => c.startsWith("<!-- FORGE:STARTED") || c.startsWith("<!-- FORGE:TRAJECTORY")), "no separate STARTED / TRAJECTORY comment");
|
|
8678
|
+
assert.ok(w.rawComments.length <= 10, `a run posts at most 10 comments, got ${w.rawComments.length}: ${w.rawComments.map((c) => c.split("\n")[0]).join(" | ")}`);
|
|
8679
|
+
});
|
|
8680
|
+
|
|
8681
|
+
it("a requeued run edits the existing trusted status comment: STARTED and TRAJECTORY are replaced, nothing new is posted for them", async () => {
|
|
8682
|
+
const w = world({ issueBodies: [ISSUE_BODY], viewComments: [{ ...BOTC, url: "https://github.com/o/r/issues/7#issuecomment-9000", body: oldStatus }] });
|
|
8683
|
+
w.statusSections = {};
|
|
8684
|
+
const r = await run(w);
|
|
8685
|
+
assert.equal(r.terminalReason, "merged");
|
|
8686
|
+
assert.equal(statusComments(w).length, 0, "no second status comment");
|
|
8687
|
+
assert.ok(w.statusPatches.length >= 2);
|
|
8688
|
+
assert.doesNotMatch(w.statusBody, /old run trajectory/, "the newest run's trajectory replaced the old one");
|
|
8689
|
+
assert.equal((w.statusBody.match(/<!-- FORGE:TRAJECTORY -->/g) ?? []).length, 1);
|
|
8690
|
+
});
|
|
8691
|
+
|
|
8692
|
+
it("an untrusted comment carrying the status marker is never edited", async () => {
|
|
8693
|
+
const w = world({ issueBodies: [ISSUE_BODY], viewComments: [{ author: { login: "drive-by" }, authorAssociation: "NONE", url: "https://github.com/o/r/issues/7#issuecomment-9000", body: oldStatus }] });
|
|
8694
|
+
await run(w);
|
|
8695
|
+
assert.equal(statusComments(w).length, 1, "a fresh status comment is posted instead");
|
|
8696
|
+
assert.ok(!w.statusPatches.some((a) => a.some((x) => /comments\/9000$/.test(x)) && false));
|
|
8697
|
+
});
|
|
8698
|
+
|
|
8699
|
+
it("start clears needs-human, needs-human:external, parked:* and remediation-queue; other labels stay", async () => {
|
|
8700
|
+
const w = world({ issueBodies: [ISSUE_BODY], labels: [{ name: "bug" }, { name: "needs-human" }, { name: "needs-human:external" }, { name: "parked:ci.red" }, { name: "remediation-queue" }] });
|
|
8701
|
+
await run(w);
|
|
8702
|
+
const rm = w.edits.find((e) => e.includes("--remove-label") && e.some((x) => /needs-human/.test(x)));
|
|
8703
|
+
assert.ok(rm, "labels cleared");
|
|
8704
|
+
assert.deepEqual(rm[rm.indexOf("--remove-label") + 1].split(","), ["needs-human", "needs-human:external", "parked:ci.red", "remediation-queue"]);
|
|
8705
|
+
});
|
|
8706
|
+
|
|
8707
|
+
it("a merged run re-reads the labels and clears a parked label added meanwhile", async () => {
|
|
8708
|
+
const w = world();
|
|
8709
|
+
const gh = w.io.gh;
|
|
8710
|
+
w.io.gh = async (a, o) => (a[0] === "issue" && a[1] === "view" && a.includes("labels") && a[a.indexOf("--json") + 1] === "labels" ? JSON.stringify({ labels: [{ name: "parked:ci.red" }] }) : gh(a, o));
|
|
8711
|
+
const r = await run(w);
|
|
8712
|
+
assert.equal(r.terminalReason, "merged");
|
|
8713
|
+
assert.ok(w.edits.some((e) => e.join(" ") === "issue edit 7 -R o/r --remove-label parked:ci.red"));
|
|
8714
|
+
});
|
|
8715
|
+
});
|
|
@@ -42,7 +42,7 @@ describe("#4773: Blocked by edges and the blocked label", () => {
|
|
|
42
42
|
it("a blocked-labelled issue is admitted but not dispatched; removing the label releases it on the next tick", async () => {
|
|
43
43
|
let blocked = [1];
|
|
44
44
|
const started = [], log = [];
|
|
45
|
-
const done = orchestrate({ issues: [1, 2], parallel: 3, pollMs: 5, readBody: async () => "", getBlocked: async () => blocked, onUpdate: (r) => log.push(r),
|
|
45
|
+
const done = orchestrate({ issues: [1, 2], parallel: 3, pollMs: 5, readBody: async () => "", blockedRefreshMs: 0, getBlocked: async () => blocked, onUpdate: (r) => log.push(r),
|
|
46
46
|
runOne: async (n) => { started.push(n); return merged; } });
|
|
47
47
|
await until(() => started.includes(2));
|
|
48
48
|
await new Promise((r) => setTimeout(r, 40));
|
|
@@ -57,7 +57,7 @@ describe("#4773: Blocked by edges and the blocked label", () => {
|
|
|
57
57
|
it("a failed label read keeps the last set instead of releasing", async () => {
|
|
58
58
|
let fail = false, set = [1], reads = 0;
|
|
59
59
|
const started = [];
|
|
60
|
-
const done = orchestrate({ issues: [1], parallel: 1, pollMs: 5, readBody: async () => "", getBlocked: async () => { reads++; if (fail) throw new Error("gh down"); return set; },
|
|
60
|
+
const done = orchestrate({ issues: [1], parallel: 1, pollMs: 5, readBody: async () => "", blockedRefreshMs: 0, getBlocked: async () => { reads++; if (fail) throw new Error("gh down"); return set; },
|
|
61
61
|
runOne: async (n) => { started.push(n); return merged; } });
|
|
62
62
|
await until(() => reads > 0);
|
|
63
63
|
fail = true;
|
|
@@ -166,4 +166,20 @@ describe("#5162: failed roots hold their subtree; only real cycles are cycles",
|
|
|
166
166
|
const lines = formatOutcomeLists([{ issue: 1, outcome: "engine-error" }, { issue: 2, outcome: "held", root: 1 }, { issue: 3, outcome: "held", root: 1 }]);
|
|
167
167
|
assert.ok(lines.some((l) => /held subtree: #1 \(engine-error\) holds #2 #3; release: forgedock orchestrate --requeue <batch> 1/.test(l)), lines.join("\n"));
|
|
168
168
|
});
|
|
169
|
+
|
|
170
|
+
it("the blocked-label list is read at most once per blockedRefreshMs, not on every pass", async () => {
|
|
171
|
+
let reads = 0, t = 0;
|
|
172
|
+
const started = [];
|
|
173
|
+
let open;
|
|
174
|
+
const g = new Promise((r) => { open = r; });
|
|
175
|
+
const done = orchestrate({ issues: [1, 2], parallel: 1, pollMs: 5, now: () => t, blockedRefreshMs: 60000, readBody: async () => "",
|
|
176
|
+
getBlocked: async () => { reads++; return []; }, runOne: async (n) => { started.push(n); if (n === 1) await g; return merged; } });
|
|
177
|
+
await until(() => started.includes(1));
|
|
178
|
+
await new Promise((r) => setTimeout(r, 60));
|
|
179
|
+
assert.equal(reads, 1, "many passes inside the window make one read");
|
|
180
|
+
t = 60001;
|
|
181
|
+
open();
|
|
182
|
+
await done;
|
|
183
|
+
assert.ok(reads >= 2, "a pass after the window reads again");
|
|
184
|
+
});
|
|
169
185
|
});
|
|
@@ -43,15 +43,24 @@ describe("cross-batch ownership (#5471)", () => {
|
|
|
43
43
|
assert.equal(ownerOf(root, "o/r", 6, "bB"), null);
|
|
44
44
|
assert.deepEqual(b.readAdded(), [5, 6]);
|
|
45
45
|
});
|
|
46
|
-
it("requeue refuses an issue another live batch runs
|
|
46
|
+
it("requeue refuses an issue another live batch runs; a batch that only holds it does not own it (#5592)", async () => {
|
|
47
47
|
const root = tmpDir("owned-requeue-");
|
|
48
48
|
seed(root, "bA", { order: [5, 7], pending: [7], running: { 5: {} }, held: [7] });
|
|
49
49
|
const b = seed(root, "bB", { order: [5, 7], results: { 5: { outcome: "needs-human" }, 7: { outcome: "needs-human" } } });
|
|
50
|
-
assert.equal(ownerOf(root, "o/r", 7, "bB"), "
|
|
50
|
+
assert.equal(ownerOf(root, "o/r", 7, "bB"), null, "held only: not an owner");
|
|
51
51
|
const res = await queued(quiet(() => orchestrateFromCli(["--requeue", "bB", "5", "7", "--reason", "r"], { batchRoot: root, io })));
|
|
52
|
-
assert.deepEqual(res.requeued, []);
|
|
53
|
-
assert.deepEqual(res.refused.map((x) => [x.issue, x.reason]), [[5, "owned by bA"]
|
|
54
|
-
assert.deepEqual(b.readRequeued(), []);
|
|
52
|
+
assert.deepEqual(res.requeued, [7]);
|
|
53
|
+
assert.deepEqual(res.refused.map((x) => [x.issue, x.reason]), [[5, "owned by bA"]]);
|
|
54
|
+
assert.deepEqual(b.readRequeued().map((e) => e.issue), [7]);
|
|
55
|
+
});
|
|
56
|
+
it("#5592: held in A, force-started in B: B requeues it; A's refusal names B instead of a bare 'not terminal'", async () => {
|
|
57
|
+
const root = tmpDir("owned-moved-");
|
|
58
|
+
const a = seed(root, "bA", { order: [7], pending: [7], held: [7] });
|
|
59
|
+
seed(root, "bB", { order: [7], results: { 7: { outcome: "needs-human" } } });
|
|
60
|
+
const res = await queued(quiet(() => orchestrateFromCli(["--requeue", "bB", "7", "--reason", "r"], { batchRoot: root, io })));
|
|
61
|
+
assert.deepEqual(res.requeued, [7]);
|
|
62
|
+
seed(root, "bC", { order: [7], running: { 7: {} } });
|
|
63
|
+
assert.deepEqual(a.requeue([7]).refused.map((x) => x.reason), ["not terminal: held here, run by bC; requeue it there"]);
|
|
55
64
|
});
|
|
56
65
|
it("dispatch defers an issue another batch runs (or holds pending with a lower id) and admits it once the owner is done", async () => {
|
|
57
66
|
const root = tmpDir("owned-dispatch-");
|
package/bin/lean/orchestrate.mjs
CHANGED
|
@@ -308,7 +308,7 @@ const toMap = (o) => new Map(Object.entries(o ?? {}).map(([k, v]) => [Number(k),
|
|
|
308
308
|
/**
|
|
309
309
|
* @returns {Promise<Array<{issue:number, outcome:string, pr:?number, cost_usd:number, minutes:number, detail?:string}>>}
|
|
310
310
|
*/
|
|
311
|
-
export async function orchestrate({ issues, parallel = 3, runOne, readBody, prefilter = null, resolveLane = null, now = () => Date.now(), onUpdate = () => {}, onCrossLane = () => {},
|
|
311
|
+
export async function orchestrate({ issues, parallel = 3, runOne, readBody, prefilter = null, resolveLane = null, now = () => Date.now(), blockedRefreshMs = 60000, onUpdate = () => {}, onCrossLane = () => {},
|
|
312
312
|
store = null, adopt = null, getParallel = null, getAdded = null, getRequeued = null, breaker = null, maxDeferrals = DEFAULT_MAX_DEFERRALS, sleep = cancellableSleep, pollMs = 5000,
|
|
313
313
|
classify = null, maintenance = null, limits = null, identity = () => "default", batchId = null, drift = null, integration = null, sched = null, priorityOf = null, remote = null, beforeAdmit = null, preflight = null,
|
|
314
314
|
recovery = null, decide = () => {}, conflicting = null, relabelNeedsHuman = null, onExit = null, issueLabels = null, issueState = null, getCancelled = null, getHeld = null, expireHolds = null, getHoldInfo = null, getBlocked = null, trusted = null, getGates = null, stopLane = null, releaseLease = null, stopRetryMs = STOP_RETRY_MS, stopTimeoutMs = STOP_TIMEOUT_MS,
|
|
@@ -415,6 +415,9 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
415
415
|
const mechMax = recoveryMax && Number.isInteger(recovery?.mechanicalMaxAttempts) && recovery.mechanicalMaxAttempts > 0 ? Math.max(recovery.mechanicalMaxAttempts, recoveryMax) : recoveryMax;
|
|
416
416
|
const REPEAT_ENV_CODES = [OUTCOME_CODES.ENV_REPRO_UNRUNNABLE, OUTCOME_CODES.ENV_TOOL_MISSING]; // #5232: deterministic for a frozen command (a timeout is load, not listed)
|
|
417
417
|
const sigOf = (d) => String(d ?? "").replace(/\s+/g, " ").trim();
|
|
418
|
+
// #5592: env.tool_missing repeats are the same defect when the same tools are missing, whatever else the detail says (probe lines, ids, paths vary per run)
|
|
419
|
+
const toolsOf = (d) => { const m = /(?:host|sandbox) is missing ([^\n]+?), so validate command/i.exec(String(d ?? "")); return m ? m[1].split(/\s*,\s*/).sort().join(",") : null; };
|
|
420
|
+
const envSig = (code, d) => (code === OUTCOME_CODES.ENV_TOOL_MISSING ? toolsOf(d) : null) ?? sigOf(d);
|
|
418
421
|
const maxFor = (cls) => (cls === "mechanical" ? mechMax : recoveryMax);
|
|
419
422
|
const classUsed = toMap(saved?.recoveryClasses); // `${issue}:${class}` -> recovery lanes launched in that class
|
|
420
423
|
const recoveries = toMap(saved?.recoveries); // issue -> recovery lanes launched (#4267)
|
|
@@ -626,6 +629,8 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
626
629
|
if (!remote?.offlineFallback) return false;
|
|
627
630
|
const after = Number.isInteger(remote.capacityFallbackAfter) && remote.capacityFallbackAfter > 0 ? remote.capacityFallbackAfter : CAPACITY_FALLBACK_AFTER;
|
|
628
631
|
if ((capDefers.get(n) ?? 0) < after) return false;
|
|
632
|
+
// #5592: an overloaded host holds every local admission (host_overloaded), so falling back would park the lane indefinitely: keep retrying the pool
|
|
633
|
+
if (overload) { try { if (overload()?.overloaded) return false; } catch { /* unknown load: the headroom guard decides */ } }
|
|
629
634
|
if (typeof remote.headroom !== "function") return true;
|
|
630
635
|
try { return remote.headroom()?.ok !== false; } catch { return false; }
|
|
631
636
|
};
|
|
@@ -915,7 +920,10 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
915
920
|
try { await relabelNeedsHuman({ issue: n, evidence: evidence() }); } catch { /* best effort */ }
|
|
916
921
|
}
|
|
917
922
|
}
|
|
918
|
-
|
|
923
|
+
// #5526: the hold is re-read here (it is only read once per pass): a held issue's terminal outcome starts no recovery lane.
|
|
924
|
+
const heldNow = recoveryMax && ["needs-human", "ci-pending", "budget-exceeded"].includes(row.outcome) && (refreshHeld(), opHeld.has(n));
|
|
925
|
+
if (heldNow) decided({ issue: n, what: `no recovery lane for #${n}: ${heldByOperator(n)}`, why: firstLine(row.detail) || row.outcome, alternative: "recover while the operator holds it" });
|
|
926
|
+
if (recoveryMax && !heldNow && ["needs-human", "ci-pending", "budget-exceeded"].includes(row.outcome)) {
|
|
919
927
|
let isConflicting = false;
|
|
920
928
|
if (row.outcome === "ci-pending" && typeof conflicting === "function" && Number.isInteger(row.pr)) {
|
|
921
929
|
try { isConflicting = (await conflicting(n, row.pr)) === true; } catch { isConflicting = false; }
|
|
@@ -924,12 +932,18 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
924
932
|
if (prior) { const pk = `${n}:${recoveryClassOf({ code: prior.code })}`; classUsed.set(pk, Math.max(classUsed.get(pk) ?? 0, prior.attempt)); } // state saved before #4725 has no class counts
|
|
925
933
|
const cls = recoveryClassOf(facts), max = maxFor(cls), used = classUsed.get(`${n}:${cls}`) ?? 0;
|
|
926
934
|
// #5232: a deterministic env defect of the frozen command that a recovery attempt repeated verbatim is not rebuilt again
|
|
927
|
-
const repeatEnv = prior && REPEAT_ENV_CODES.includes(row.code) && prior.code === row.code &&
|
|
935
|
+
const repeatEnv = prior && REPEAT_ENV_CODES.includes(row.code) && prior.code === row.code && envSig(row.code, prior.detail) === envSig(row.code, row.detail);
|
|
936
|
+
// #5592: a first env.tool_missing that ran on this host (not a remote sandbox) would be replayed with the identical frozen contract on the same host and fail identically: not launched as-is
|
|
937
|
+
const sameHostReplay = !repeatEnv && !prior && row.code === OUTCOME_CODES.ENV_TOOL_MISSING && row.placement?.where !== "remote" && toolsOf(row.detail) !== null;
|
|
938
|
+
if (sameHostReplay) {
|
|
939
|
+
row.detail = `Environment defect: the run already executed on the host that lacks ${toolsOf(row.detail)}, and a recovery would replay the identical frozen contract on that same host, so none is launched. Install the tool or fix the dependency install on the host (or amend the contract's validate/env), then requeue.\n${String(row.detail ?? "")}`;
|
|
940
|
+
decided({ issue: n, what: `no recovery for ${row.code}: the frozen contract would fail identically on the same host`, why: firstLine(row.detail), alternative: "requeue a recovery lane that replays the same frozen contract on the same host" });
|
|
941
|
+
}
|
|
928
942
|
if (repeatEnv) {
|
|
929
943
|
row.detail = `Environment defect: the recovery attempt failed with the same \`${row.code}\` as the run before it, so no further rebuild is spent; run the command below on the host with the project's real dependencies.\n${String(row.detail ?? "")}`;
|
|
930
944
|
decided({ issue: n, what: `no further recovery for ${row.code}: the same failure repeated`, why: firstLine(row.detail), alternative: "requeue another recovery lane that rebuilds against the same frozen command" });
|
|
931
945
|
}
|
|
932
|
-
if (!repeatEnv && classifyNeedsHuman(facts) === "recoverable" && used < max) {
|
|
946
|
+
if (!repeatEnv && !sameHostReplay && classifyNeedsHuman(facts) === "recoverable" && used < max) {
|
|
933
947
|
const code = recoveryCodeOf(facts), attempt = used + 1;
|
|
934
948
|
classUsed.set(`${n}:${cls}`, attempt);
|
|
935
949
|
// #4315: the full lane detail is kept (never firstLine) for the relabel when the batch stops before this attempt
|
|
@@ -1014,6 +1028,8 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1014
1028
|
try { gone = (await dispatchCheck(n)) ?? null; } catch { gone = null; }
|
|
1015
1029
|
if (!["merged", "invalid", "deferred"].includes(gone?.outcome)) gone = null; // #4920: deferred = another lane owns the issue (lease or open PR on GitHub)
|
|
1016
1030
|
}
|
|
1031
|
+
// #5526: a hold placed since the pass read is honoured at launch: the issue goes back to pending, no lane
|
|
1032
|
+
if (!cancelled && !halted) { refreshHeld(); if (opHeld.has(n)) { running.delete(n); runRecs.delete(n); releaseSlot(n); endRemote(n); requeue(n, 0); save(); return; } }
|
|
1017
1033
|
if (halted) return; // #4454: stopped before launch; no pid, so a resume queues it again
|
|
1018
1034
|
let r;
|
|
1019
1035
|
if (cancelled) r = { terminalReason: "deferred", code: "run.interrupted", cost_usd: 0, detail: "cancelled before launch" }; // #4376
|
|
@@ -1264,6 +1280,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1264
1280
|
const fmt = (ns) => ns.map((n) => `#${n}`).join(", ");
|
|
1265
1281
|
const held = [...next].filter((n) => !opHeld.has(n)), freed = [...opHeld].filter((n) => !next.has(n));
|
|
1266
1282
|
opHeld = next;
|
|
1283
|
+
for (const n of held) if (running.has(n)) update({ issue: n, outcome: "hold", detail: `#${n} held after launch: lane still running` }); // #5526
|
|
1267
1284
|
if (held.length) {
|
|
1268
1285
|
decided({ issue: null, what: `held ${fmt(held)} (forgedock orchestrate --hold)`, why: "operator request", alternative: "cancel the batch" });
|
|
1269
1286
|
update({ issue: null, outcome: "hold", detail: fmt(held) });
|
|
@@ -1291,8 +1308,11 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1291
1308
|
baseDone.add(n);
|
|
1292
1309
|
}
|
|
1293
1310
|
};
|
|
1311
|
+
let blockedReadAt = -Infinity; // #5592 follow-up: the label list is one `gh issue list` per call; a waiting batch makes several passes a second
|
|
1294
1312
|
const refreshBlocked = async () => {
|
|
1295
1313
|
if (!getBlocked) return;
|
|
1314
|
+
if (now() - blockedReadAt < blockedRefreshMs) return;
|
|
1315
|
+
blockedReadAt = now();
|
|
1296
1316
|
let got;
|
|
1297
1317
|
try { got = await getBlocked(); } catch { return; }
|
|
1298
1318
|
const next = new Set((Array.isArray(got) ? got : [...(got ?? [])]).filter((n) => Number.isSafeInteger(n) && n > 0));
|
|
@@ -1518,6 +1538,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1518
1538
|
if (n === null) { budgetHeld = ready.length > 0; break; }
|
|
1519
1539
|
const g = grant(n, wanted);
|
|
1520
1540
|
if (g === "busy") continue; // #4481: not ready any more this pass (notBefore), so `ready` drops it
|
|
1541
|
+
if (!g && (notBefore.get(n) ?? 0) > t) continue; // #5592: this issue waits on its own (host overload, pool slots): the issues behind it are still tried
|
|
1521
1542
|
if (!g) break;
|
|
1522
1543
|
pending.splice(pending.indexOf(n), 1);
|
|
1523
1544
|
if (lanes.get(n)?.ok !== false) { dispatch.started++; if (clsOf(classes, n).maintenance) dispatch.maint++; }
|
|
@@ -1533,6 +1554,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1533
1554
|
if (running.size >= K()) break;
|
|
1534
1555
|
const g = grant(n, wanted);
|
|
1535
1556
|
if (g === "busy") continue; // #4481
|
|
1557
|
+
if (!g && (notBefore.get(n) ?? 0) > t) continue; // #5592: per-issue wait, not a full host queue
|
|
1536
1558
|
if (!g) break;
|
|
1537
1559
|
pending.splice(pending.indexOf(n), 1); start(n); started++;
|
|
1538
1560
|
}
|
package/bin/lean/orphan-pr.mjs
CHANGED
|
@@ -29,9 +29,10 @@ export function classifyOrphanPr(pr, ctx) {
|
|
|
29
29
|
return { kind: "undelivered", detail: `the change is not on \`${ctx.base}\`` };
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
/** `{ count, oldestAgeMs, alert }` over rows with an `ageMs`; alert when any orphan is older than 24h. Kept PRs (backport-pending) do not count. */
|
|
32
|
+
/** `{ count, oldestAgeMs, alert }` over rows with an `ageMs`; alert when any orphan is older than 24h. Kept PRs (backport-pending) and cleanup rows (backport-merged) do not count. */
|
|
33
|
+
const NOT_ORPHAN_KINDS = new Set(["backport-pending", "backport-merged"]);
|
|
33
34
|
export function orphanTelemetry(rows) {
|
|
34
|
-
const r = (rows ?? []).filter((x) => x.kind && x.kind
|
|
35
|
+
const r = (rows ?? []).filter((x) => x.kind && !NOT_ORPHAN_KINDS.has(x.kind));
|
|
35
36
|
const oldestAgeMs = r.reduce((m, x) => Math.max(m, x.ageMs ?? 0), 0);
|
|
36
37
|
return { count: r.length, oldestAgeMs, alert: r.length > 0 && oldestAgeMs > ALERT_AGE_MS };
|
|
37
38
|
}
|
|
@@ -66,8 +66,9 @@ describe("orphan-PR sweep (#5505)", () => {
|
|
|
66
66
|
|
|
67
67
|
it("pattern 3b: the backport merged -> label cleared and the issue closed", async () => {
|
|
68
68
|
const w = world({ labelled: [{ number: 39450, state: "OPEN" }], all: [{ number: 5, state: "MERGED", headRefName: "hotfix/google-mobile-pool-39450" }] });
|
|
69
|
-
await run(w);
|
|
69
|
+
const rows = await run(w);
|
|
70
70
|
assert.ok(w.edits.some((a) => a.includes("--remove-label")) && w.edits.some((a) => a[1] === "close"));
|
|
71
|
+
assert.equal(orphanTelemetry(rows).count, 0);
|
|
71
72
|
});
|
|
72
73
|
|
|
73
74
|
it("pattern 4: lane PR left behind after decompose, never delivered -> follow-up filed first, then PR closed", async () => {
|
|
@@ -118,6 +119,12 @@ describe("orphan-PR sweep (#5505)", () => {
|
|
|
118
119
|
assert.match(formatOrphanSummary([{ kind: "undelivered", pr: 4, ageMs: 90000000, closed: true }]), /ALERT oldest 25h/);
|
|
119
120
|
assert.equal(formatOrphanSummary([]), "");
|
|
120
121
|
});
|
|
122
|
+
|
|
123
|
+
it("a backport-merged cleanup row is not an orphan (#5517)", () => {
|
|
124
|
+
const rows = [{ issue: 7, kind: "backport-merged", detail: "label cleared" }];
|
|
125
|
+
assert.deepEqual(orphanTelemetry(rows), { count: 0, oldestAgeMs: 0, alert: false });
|
|
126
|
+
assert.equal(formatOrphanSummary(rows), "");
|
|
127
|
+
});
|
|
121
128
|
});
|
|
122
129
|
|
|
123
130
|
describe("one live PR per issue and the close gate (#5505)", () => {
|
package/bin/lean/pagegate.mjs
CHANGED
|
@@ -37,7 +37,7 @@ export function parsePagesConfig(raw, { hasAppPages = false } = {}) {
|
|
|
37
37
|
const req = list(obj.require).map((k) => k.toLowerCase()).filter((k) => PAGE_REQUIRE.includes(k));
|
|
38
38
|
const pick = (v, d) => { const l = list(v); return l.length ? l : d; };
|
|
39
39
|
return {
|
|
40
|
-
routes, icp_doc: typeof obj.icp_doc === "string" && obj.icp_doc.trim() ? obj.icp_doc.trim() : null,
|
|
40
|
+
routes, exclude: list(obj.exclude).map(norm), design_only: list(obj.design_only).map(norm), icp_doc: typeof obj.icp_doc === "string" && obj.icp_doc.trim() ? obj.icp_doc.trim() : null,
|
|
41
41
|
require: raw && obj.require !== undefined && req.length ? [...new Set(req)] : [...PAGE_REQUIRE],
|
|
42
42
|
sitemap: pick(obj.sitemap, DEFAULTS.sitemap).map(norm), metadata_patterns: pick(obj.metadata_patterns, DEFAULTS.metadata),
|
|
43
43
|
canonical_patterns: pick(obj.canonical_patterns, DEFAULTS.canonical), structured_data_patterns: pick(obj.structured_data_patterns, DEFAULTS.structured),
|
|
@@ -45,18 +45,41 @@ export function parsePagesConfig(raw, { hasAppPages = false } = {}) {
|
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
const NOINDEX_RE = /robots\s*:\s*\{[^}]*index\s*:\s*false|noindex/i;
|
|
49
|
+
/** #5585: true when the page file or an ancestor layout declares noindex (needs `readFile`; without it a page stays public). */
|
|
50
|
+
function noindexed(f, readFile) {
|
|
51
|
+
if (typeof readFile !== "function") return false;
|
|
52
|
+
const dirs = f.split("/").slice(0, -1);
|
|
53
|
+
const cands = [f];
|
|
54
|
+
for (let i = dirs.length; i > 0; i--) for (const ext of ["tsx", "ts", "jsx", "js"]) cands.push(`${dirs.slice(0, i).join("/")}/layout.${ext}`);
|
|
55
|
+
return cands.some((p) => { try { return NOINDEX_RE.test(String(readFile(p) ?? "")); } catch { return false; } });
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** The public page files among `files`: built-in Next `app/**\/page.*` plus `pages.routes` globs, tests excluded; `pages.exclude`, `pages.design_only` and (with `readFile`) noindex pages dropped. */
|
|
59
|
+
export function pageFiles(files, cfg, { readFile = null } = {}) {
|
|
50
60
|
if (!cfg) return [];
|
|
51
|
-
|
|
61
|
+
const ex = cfg.exclude ?? [], dz = cfg.design_only ?? [];
|
|
62
|
+
return [...new Set((files ?? []).map(norm).filter((f) => f && !TEST_RE.test(f) && (PAGE_RE.test(f) || anyGlob(cfg.routes, f)) && !anyGlob(ex, f) && !anyGlob(dz, f) && !noindexed(f, readFile)))];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** #5585: files under `pages.design_only`: not public pages (no SEO/GEO), but the design requirement still applies. */
|
|
66
|
+
export function designOnlyFiles(files, cfg) {
|
|
67
|
+
if (!cfg?.design_only?.length) return [];
|
|
68
|
+
return [...new Set((files ?? []).map(norm).filter((f) => f && !TEST_RE.test(f) && anyGlob(cfg.design_only, f) && !anyGlob(cfg.exclude ?? [], f)))];
|
|
52
69
|
}
|
|
53
70
|
|
|
54
71
|
const present = (o, ks) => ks.filter((k) => blank(o?.[k]));
|
|
55
72
|
|
|
56
73
|
/** Contract-time problems: a deliverable that is a page needs `page_gate` {design_spec, seo, geo} per `pages.require`. [] when off or no page deliverable. */
|
|
57
|
-
export function contractBriefProblems(contract, cfg) {
|
|
58
|
-
const
|
|
59
|
-
|
|
74
|
+
export function contractBriefProblems(contract, cfg, { readFile = null } = {}) {
|
|
75
|
+
const paths = (contract?.deliverables ?? []).map((d) => d?.path);
|
|
76
|
+
const pages = pageFiles(paths, cfg, { readFile }), dOnly = designOnlyFiles(paths, cfg);
|
|
77
|
+
if (!pages.length && !dOnly.length) return [];
|
|
78
|
+
if (!pages.length) {
|
|
79
|
+
const g = contract?.page_gate;
|
|
80
|
+
return cfg.require.includes("design") && blank(g && typeof g === "object" ? g.design_spec : null)
|
|
81
|
+
? [`deliverable page ${dOnly.slice(0, 3).join(", ")} (pages.design_only) needs contract.page_gate.design_spec: the approved FORGE:DESIGN_SPEC (run /design first; issue or comment ref)`] : [];
|
|
82
|
+
}
|
|
60
83
|
const g = contract?.page_gate, out = [], at = `deliverable page ${pages.slice(0, 3).join(", ")} needs contract.page_gate`;
|
|
61
84
|
if (!g || typeof g !== "object" || Array.isArray(g)) return [`${at}: {"design_spec":"<FORGE:DESIGN_SPEC ref>","seo":{...},"geo":{...}} (forge.yaml pages.require: ${cfg.require.join(", ")})`];
|
|
62
85
|
if (cfg.require.includes("design") && blank(g.design_spec)) out.push(`${at}.design_spec: the approved FORGE:DESIGN_SPEC (run /design first; issue or comment ref)`);
|
|
@@ -107,17 +130,17 @@ const LINK_RE = /href\s*=\s*\{?\s*["'`](\/[^"'`#?\s{}$]*)/g;
|
|
|
107
130
|
* `tracked` the repo's files; `designApproved` true/false/null (unknown skips); `run({command})` -> {rc, output} for `pages.lint`.
|
|
108
131
|
*/
|
|
109
132
|
export async function pageFailures({ cfg, files = [], diff = "", result = null, readFile = () => "", tracked = null, designApproved = null, run = null }) {
|
|
110
|
-
const pages = pageFiles(files, cfg);
|
|
111
|
-
if (!cfg || !
|
|
133
|
+
const pages = pageFiles(files, cfg, { readFile }), dOnly = designOnlyFiles(files, cfg), uiFiles = [...pages, ...dOnly];
|
|
134
|
+
if (!cfg || !uiFiles.length) return [];
|
|
112
135
|
const C = OUTCOME_CODES.CONFORMANCE_UNIMPLEMENTED, out = [], j = result?.page_gate ?? {};
|
|
113
136
|
const row = (kind, detail) => out.push({ code: C, kind, detail });
|
|
114
137
|
if (cfg.require.includes("design")) {
|
|
115
|
-
if (designApproved === false) row("page_design_missing", `${
|
|
138
|
+
if (designApproved === false) row("page_design_missing", `${uiFiles.slice(0, 3).join(", ")} is a public page but the issue has no approved FORGE:DESIGN_SPEC: run /design before building`);
|
|
116
139
|
const shots = list(j.screenshots).join(" ");
|
|
117
|
-
if (!/390/.test(shots) || !/1440/.test(shots)) row("page_visual_missing", `${
|
|
140
|
+
if (!/390/.test(shots) || !/1440/.test(shots)) row("page_visual_missing", `${uiFiles.slice(0, 3).join(", ")}: the result's page_gate.screenshots must name a 390px and a 1440px visual check attached to the PR`);
|
|
118
141
|
}
|
|
119
142
|
const all = [...new Set([...(tracked ?? []), ...files].map(norm))];
|
|
120
|
-
if (cfg.require.includes("seo_intent")) {
|
|
143
|
+
if (pages.length && cfg.require.includes("seo_intent")) {
|
|
121
144
|
const meta = regexes(cfg.metadata_patterns), canon = regexes(cfg.canonical_patterns), sd = regexes(cfg.structured_data_patterns);
|
|
122
145
|
for (const f of pages) {
|
|
123
146
|
const dir = f.split("/").slice(0, -1);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
3
|
import { describe, it } from "node:test";
|
|
4
4
|
import assert from "node:assert/strict";
|
|
5
|
-
import { parsePagesConfig, pageFiles, contractBriefProblems, pageFailures, designSpecApproved, designHold, designLabelApproved } from "./pagegate.mjs";
|
|
5
|
+
import { parsePagesConfig, pageFiles, designOnlyFiles, contractBriefProblems, pageFailures, designSpecApproved, designHold, designLabelApproved } from "./pagegate.mjs";
|
|
6
6
|
import { pagePlanNote, domainChecksBlock } from "./prompts.mjs";
|
|
7
7
|
import { pathDomains } from "./review-trigger.mjs";
|
|
8
8
|
import { validateContract, precheck } from "./conformance.mjs";
|
|
@@ -75,3 +75,41 @@ describe("design hold (#5442)", () => {
|
|
|
75
75
|
assert.equal(designLabelApproved([]), false);
|
|
76
76
|
});
|
|
77
77
|
});
|
|
78
|
+
|
|
79
|
+
describe("page gate exclusions (#5585)", () => {
|
|
80
|
+
const admin = "web/src/app/(site)/admin/page.tsx", pub = storeFiles[0];
|
|
81
|
+
const ex = parsePagesConfig({ exclude: ["web/src/app/**/admin/**"], design_only: ["web/src/app/**/dash/**"] }, { hasAppPages: true });
|
|
82
|
+
const dash = "web/src/app/dash/page.tsx";
|
|
83
|
+
it("parses exclude and design_only, default empty", () => {
|
|
84
|
+
assert.deepEqual([cfg.exclude, cfg.design_only], [[], []]);
|
|
85
|
+
assert.deepEqual(ex.exclude, ["web/src/app/**/admin/**"]);
|
|
86
|
+
});
|
|
87
|
+
it("an excluded route is not a public page at contract time or in precheck", async () => {
|
|
88
|
+
assert.deepEqual(pageFiles([admin, pub], ex), [pub]);
|
|
89
|
+
assert.deepEqual(pageFiles([admin], cfg), [admin]);
|
|
90
|
+
const c = { deliverables: [{ id: "D1", path: admin, change: "x", requirements: ["R1"] }] };
|
|
91
|
+
assert.deepEqual(contractBriefProblems(c, ex), []);
|
|
92
|
+
assert.equal(contractBriefProblems(c, cfg).length, 1);
|
|
93
|
+
assert.deepEqual(await pageFailures({ cfg: ex, files: [admin], diff: `+++ b/${admin}\n+[[null]]\n`, tracked: [admin], designApproved: false }), []);
|
|
94
|
+
});
|
|
95
|
+
it("auto-excludes a noindex page or layout when the file can be read", async () => {
|
|
96
|
+
const rd = (p) => (p === admin ? "export const metadata = { robots: { index: false } }" : p === "web/app/x/layout.tsx" ? "<meta name=robots content=noindex>" : "");
|
|
97
|
+
assert.deepEqual(pageFiles([admin], cfg, { readFile: rd }), []);
|
|
98
|
+
assert.deepEqual(pageFiles(["web/app/x/page.tsx"], cfg, { readFile: rd }), []);
|
|
99
|
+
assert.deepEqual(pageFiles([admin], cfg), [admin]);
|
|
100
|
+
assert.deepEqual(pageFiles([pub], cfg, { readFile: rd }), [pub]);
|
|
101
|
+
const c = { deliverables: [{ id: "D1", path: admin, change: "x", requirements: ["R1"] }] };
|
|
102
|
+
assert.deepEqual(contractBriefProblems(c, cfg, { readFile: rd }), []);
|
|
103
|
+
assert.deepEqual(await pageFailures({ cfg, files: [admin], diff: "", readFile: rd, tracked: [admin], designApproved: false }), []);
|
|
104
|
+
});
|
|
105
|
+
it("design_only keeps the design requirement but not SEO/GEO", async () => {
|
|
106
|
+
assert.deepEqual(designOnlyFiles([dash, pub], ex), [dash]);
|
|
107
|
+
assert.deepEqual(pageFiles([dash], ex), []);
|
|
108
|
+
const c = { deliverables: [{ id: "D1", path: dash, change: "x", requirements: ["R1"] }] };
|
|
109
|
+
const p = contractBriefProblems(c, ex);
|
|
110
|
+
assert.equal(p.length, 1); assert.match(p[0], /design_spec/);
|
|
111
|
+
assert.deepEqual(contractBriefProblems({ ...c, page_gate: { design_spec: "#1 FORGE:DESIGN_SPEC" } }, ex), []);
|
|
112
|
+
const f = await pageFailures({ cfg: ex, files: [dash], diff: "", tracked: [dash], designApproved: false });
|
|
113
|
+
assert.deepEqual(f.map((x) => x.kind).sort(), ["page_design_missing", "page_visual_missing"]);
|
|
114
|
+
});
|
|
115
|
+
});
|
package/bin/lean/preflight.mjs
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
* env leaves empty (#4325).
|
|
11
11
|
*/
|
|
12
12
|
import { builtinModules } from "node:module";
|
|
13
|
+
import { existsSync } from "node:fs";
|
|
14
|
+
import { join, dirname, delimiter } from "node:path";
|
|
13
15
|
import { missingTool } from "./conformance.mjs";
|
|
14
16
|
|
|
15
17
|
export const PREFLIGHT_CAP = 20;
|
|
@@ -306,5 +308,37 @@ export function declaredEnv(contract) {
|
|
|
306
308
|
const plan = contract?.test_plan;
|
|
307
309
|
const raw = Array.isArray(plan) ? plan.map((r) => r?.env) : [plan?.env];
|
|
308
310
|
const names = raw.flatMap((e) => (Array.isArray(e) ? e : typeof e === "string" ? e.split(",") : [])).map((e) => String(typeof e === "string" ? e : e?.tool ?? "").trim());
|
|
309
|
-
return [...new Set(names.filter((t) => /^[\w.+-]+$/.test(t)))];
|
|
311
|
+
return [...new Set(names.filter((t) => /^[\w.+-]+$/.test(t) && isExecutableName(t)))];
|
|
310
312
|
}
|
|
313
|
+
|
|
314
|
+
/** #5590: pytest's built-in fixtures, never host executables. */
|
|
315
|
+
const PYTEST_FIXTURES = new Set(["caplog", "capsys", "capfd", "capsysbinary", "capfdbinary", "monkeypatch", "tmp_path", "tmp_path_factory", "tmpdir", "tmpdir_factory", "request", "recwarn", "pytestconfig", "mocker", "doctest_namespace", "cache", "testdir"]);
|
|
316
|
+
/** #5590: `env` lists executables only; CamelCase (a class such as FakeRedis), snake_case and pytest-fixture names are libraries/fixtures that come from the lockfile. Pure. */
|
|
317
|
+
export function isExecutableName(t) {
|
|
318
|
+
return !/[A-Z]/.test(t) && !t.includes("_") && !PYTEST_FIXTURES.has(t);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* #5592: the project-local executable dirs a lane can run tools from: `node_modules/.bin` and a Python in-project `.venv/bin`
|
|
323
|
+
* at the worktree root and next to every tracked manifest (`files`: tracked paths; package.json, pyproject.toml, poetry.lock,
|
|
324
|
+
* uv.lock mark a project dir, so `services/<svc>/.venv/bin` in a monorepo counts). Only dirs that exist; nearest-to-root first.
|
|
325
|
+
* The tool probe and the heavy-shim writer resolve through these (appended after PATH), so both agree on what is runnable.
|
|
326
|
+
*/
|
|
327
|
+
export function projectBinDirs(wt, files = [], { exists = existsSync, cap = 24 } = {}) {
|
|
328
|
+
const dirs = new Set(["."]);
|
|
329
|
+
for (const f of files) {
|
|
330
|
+
const base = String(f).split("/").pop();
|
|
331
|
+
if (["package.json", "pyproject.toml", "poetry.lock", "uv.lock"].includes(base) && !String(f).split("/").includes("node_modules")) dirs.add(dirname(f));
|
|
332
|
+
}
|
|
333
|
+
const out = [];
|
|
334
|
+
for (const d of [...dirs].sort((a, b) => a.split("/").length - b.split("/").length || a.localeCompare(b))) {
|
|
335
|
+
for (const rel of [".venv/bin", "node_modules/.bin"]) {
|
|
336
|
+
const p = d === "." ? join(wt, rel) : join(wt, d, rel);
|
|
337
|
+
if (exists(p) && out.length < cap) out.push(p);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return out;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/** #5592: `base` PATH with the project-local executable dirs appended (never ahead of what the lane already resolves). */
|
|
344
|
+
export const withLocalBins = (base, dirs) => [...String(base ?? "").split(delimiter).filter(Boolean), ...dirs.filter((d) => !String(base ?? "").split(delimiter).includes(d))].join(delimiter);
|