forgedock 1.50.0 → 1.52.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 +2 -0
- package/bin/engine-cli.mjs +98 -10
- package/bin/forgedock.mjs +40 -2
- package/bin/lean/batch-health.mjs +219 -0
- package/bin/lean/batch-health.test.mjs +156 -0
- package/bin/lean/batch.mjs +3 -3
- package/bin/lean/batch.test.mjs +236 -8
- package/bin/lean/conformance.mjs +66 -12
- package/bin/lean/conformance.test.mjs +55 -3
- package/bin/lean/context.mjs +35 -19
- package/bin/lean/context.test.mjs +26 -1
- package/bin/lean/credentials.mjs +18 -0
- package/bin/lean/effects.mjs +3 -3
- package/bin/lean/execution.mjs +11 -6
- package/bin/lean/execution.test.mjs +28 -0
- package/bin/lean/fixclosereasons.mjs +52 -0
- package/bin/lean/fixclosereasons.test.mjs +64 -0
- package/bin/lean/heavy.mjs +6 -3
- package/bin/lean/hostload.mjs +78 -0
- package/bin/lean/hostload.test.mjs +117 -0
- package/bin/lean/hotspots-remote.e2e.test.mjs +71 -0
- package/bin/lean/lean.mjs +34 -19
- package/bin/lean/lean.test.mjs +87 -14
- package/bin/lean/orchestrate-blocked.test.mjs +47 -0
- package/bin/lean/orchestrate.mjs +138 -12
- package/bin/lean/prefilter.mjs +4 -3
- package/bin/lean/prefilter.test.mjs +5 -4
- package/bin/lean/prompts.mjs +4 -2
- package/bin/lean/recovery.test.mjs +5 -5
- package/bin/lean/sandbox-provider.contract.test.mjs +15 -1
- package/bin/lean/schedd.mjs +8 -3
- package/bin/lean/schedd.test.mjs +21 -0
- package/bin/pool/agent.mjs +3 -1
- package/bin/pool/router.mjs +74 -8
- package/bin/review-staging.mjs +2 -0
- package/bin/runner.mjs +24 -0
- package/commands/review-pr-staging.md +2 -2
- package/docs/CONFIG.md +41 -2
- package/docs/OUTCOME-CODES.md +2 -1
- package/package.json +1 -1
- package/pool/README.md +2 -0
- package/pool/image/cs-cred +8 -1
- package/pool/install/install-agent.ps1 +6 -2
- package/scripts/file-deferred-followups.sh +23 -9
- package/scripts/file-deferred-followups.test.sh +34 -1
- package/scripts/hotspots.sh +12 -8
- package/scripts/hotspots.test.sh +22 -0
- package/scripts/prior-attempts.test.mjs +1 -1
- package/scripts/review-staging-post.sh +70 -25
- package/scripts/review-staging-post.test.sh +40 -8
package/bin/lean/lean.test.mjs
CHANGED
|
@@ -188,7 +188,7 @@ function world(o = {}) {
|
|
|
188
188
|
fs: { ...(o.wtExists ? { exists: async (p) => p.startsWith("/wt/lean-7") } : {}), stat: async (p) => (p in w.files ? { mtimeMs: w.mtimes[p] ?? 1 } : null), read: async (p) => { if (!(p in w.files)) throw new Error("ENOENT"); return w.files[p]; }, append: async (p, t) => { w.files[p] = (w.files[p] ?? "") + t; }, write: async (p, t) => { w.files[p] = t; }},
|
|
189
189
|
fileFollowups: async ({ parent, items }) => { w.followups.push({ parent, items }); if (o.followupError) throw Object.assign(new Error(o.followupError), { stdout: o.followupStdout ?? "" });
|
|
190
190
|
if (o.followupRet) return o.followupRet(w.followups.length, items);
|
|
191
|
-
if (w.followups.length <= (o.followupFailTimes ?? 0)) throw new Error("DEFERRED_LOOKUP=FAILED"); if (w.followups.length <= (o.followupMissingTimes ?? 0)) return {}; return Object.fromEntries(items.map((i) => [i.key, o.followupIssue ?? 900])); },
|
|
191
|
+
if (w.followups.length <= (o.followupFailTimes ?? 0)) throw new Error("DEFERRED_LOOKUP=FAILED"); if (w.followups.length <= (o.followupMissingTimes ?? 0)) return {}; return Object.fromEntries(items.filter((i) => !(o.followupSkip ?? []).some((q) => JSON.stringify(i).includes(q))).map((i) => [i.key, o.followupIssue ?? 900])); },
|
|
192
192
|
};
|
|
193
193
|
return w;
|
|
194
194
|
}
|
|
@@ -281,13 +281,16 @@ describe("core work-on", () => {
|
|
|
281
281
|
const t = traj(w)[0];
|
|
282
282
|
for (const needle of ["| Validate | INVALID |", "| Plan | skipped |", "| Implement | skipped |", "| Review | skipped |", "| PR | none |", "| Close | issue closed (not planned) |"]) assert.ok(t.includes(needle), needle);
|
|
283
283
|
assert.equal(w.closed.length, 1);
|
|
284
|
+
assert.equal(w.closed[0][w.closed[0].indexOf("--reason") + 1], "not planned", "#5152: invalid keeps not planned");
|
|
284
285
|
assert.equal(w.prs.length, 0);
|
|
285
286
|
assert.equal(reviewers(w).length, 0);
|
|
286
287
|
});
|
|
287
288
|
|
|
288
|
-
it("already-fixed with evidence also closes", async () => {
|
|
289
|
+
it("already-fixed with evidence also closes, as completed (#5152)", async () => {
|
|
289
290
|
const w = world({ changed: [], result: { status: "already-fixed", summary: "done upstream", evidence: ["a.js:1"], tests: [] } });
|
|
290
291
|
assert.equal((await run(w)).terminalReason, "invalid");
|
|
292
|
+
assert.deepEqual(w.closed.map((a) => a[a.indexOf("--reason") + 1]), ["completed"], "#5152: already-fixed is delivered, never not planned");
|
|
293
|
+
assert.ok(traj(w)[0].includes("| Close | issue closed (completed) |"));
|
|
291
294
|
});
|
|
292
295
|
|
|
293
296
|
it("a failed needs-human comment is recorded as an anomaly and the lane still ends needs-human (#4905)", async () => {
|
|
@@ -383,6 +386,21 @@ describe("core work-on", () => {
|
|
|
383
386
|
assert.equal(r2.code, "review.incomplete"); assert.equal(reviewers(w2).length, 3, "at most three reviewer runs"); assert.equal(w2.merges.length, 0);
|
|
384
387
|
});
|
|
385
388
|
|
|
389
|
+
it("#5164 a coverage misquote gets one more targeted re-ask with the issue's criterion lines; a near-verbatim one is requoted without a re-ask", async () => {
|
|
390
|
+
const mis = () => conf({ issue_coverage: [{ quote: "foo copes when nothing at all is passed", contract_ids: ["R1"], status: "covered" }] });
|
|
391
|
+
const w = world({ reviews: [mis(), mis(), ok()] });
|
|
392
|
+
assert.equal((await run(w)).terminalReason, "merged");
|
|
393
|
+
const rv = reviewers(w);
|
|
394
|
+
assert.equal(rv.length, 3); assert.equal(builders(w).length, 2, "never charged to the builder");
|
|
395
|
+
for (const i of [1, 2]) { assert.match(rv[i][4], /<issue_criteria>/); assert.match(rv[i][4], /- foo must handle a null argument without throwing\./); }
|
|
396
|
+
assert.match(rv[1][4], /answer ONLY for these ids or sections: issue_coverage/);
|
|
397
|
+
const w2 = world({ reviews: [mis(), mis(), mis(), ok()] });
|
|
398
|
+
const r2 = await run(w2);
|
|
399
|
+
assert.equal(r2.code, "review.incomplete"); assert.equal(reviewers(w2).length, 3, "at most three reviewer runs"); assert.equal(w2.merges.length, 0);
|
|
400
|
+
const w3 = world({ reviews: [conf({ issue_coverage: [{ quote: "foo must handle null arguments without throwing", contract_ids: ["R1"], status: "covered" }] })] });
|
|
401
|
+
assert.equal((await run(w3)).terminalReason, "merged"); assert.equal(reviewers(w3).length, 1);
|
|
402
|
+
});
|
|
403
|
+
|
|
386
404
|
it("a CONFORMS verdict whose rows fail is not conforming (the engine computes the verdict)", async () => {
|
|
387
405
|
const w = world({ reviews: [bad("half done", "CONFORMS"), ok()] });
|
|
388
406
|
assert.equal((await run(w)).terminalReason, "merged");
|
|
@@ -689,13 +707,13 @@ describe("core work-on", () => {
|
|
|
689
707
|
assert.ok(w.labels.includes("decomposed"));
|
|
690
708
|
});
|
|
691
709
|
|
|
692
|
-
it("#4337 with decomposition.close_parent a split closes the parent
|
|
710
|
+
it("#4337 #5152 with decomposition.close_parent a split closes the parent completed after its FORGE:DECOMPOSED trail and label, listing every sub-issue", async () => {
|
|
693
711
|
const w = depWorld({ changed: [], result: splitBlock }, {});
|
|
694
712
|
const r = await run(w, { closeParent: true });
|
|
695
713
|
assert.equal(r.terminalReason, "decomposed");
|
|
696
714
|
assert.equal(w.closed.length, 1);
|
|
697
715
|
const c = w.closed[0];
|
|
698
|
-
assert.equal(c[c.indexOf("--reason") + 1], "not
|
|
716
|
+
assert.equal(c[c.indexOf("--reason") + 1], "completed", "#5152: the scope moved to the sub-issues, it was not dropped");
|
|
699
717
|
const note = c[c.indexOf("--comment") + 1];
|
|
700
718
|
assert.match(note, /#201/); assert.match(note, /#202/);
|
|
701
719
|
assert.ok(w.labels.includes("decomposed"));
|
|
@@ -998,6 +1016,9 @@ describe("conformance gate (frozen contract, precheck, structured review)", () =
|
|
|
998
1016
|
const note = w.comments.find((c) => c.includes("FORGE:FOLLOWUP_PENDING"));
|
|
999
1017
|
assert.match(note, /R2 \(defer\): Existing callers of foo keep working\..*`FORGE:DEFERRED_FROM: #7`/);
|
|
1000
1018
|
assert.ok(!w.edits.some((e) => e.includes("--add-label") && e.includes("needs-human")));
|
|
1019
|
+
assert.ok(!w.comments.some((c) => /Closed as/.test(c)), "#5159: no note says the kept-open issue was closed");
|
|
1020
|
+
assert.match(traj(w).join("\n"), /left open \(follow-up pending\)/, "#5159: the trajectory Close row says left open");
|
|
1021
|
+
assert.doesNotMatch(traj(w).join("\n"), /issue closed \(/);
|
|
1001
1022
|
});
|
|
1002
1023
|
|
|
1003
1024
|
it("#5141 a follow-up that keeps failing before the PR is filed by the close step after the merge", async () => {
|
|
@@ -1053,6 +1074,21 @@ describe("conformance gate (frozen contract, precheck, structured review)", () =
|
|
|
1053
1074
|
assert.equal(r2.code, "followup.unavailable"); assert.equal(w2.followups.length, 1); assert.equal(w2.prs.length, 0);
|
|
1054
1075
|
});
|
|
1055
1076
|
|
|
1077
|
+
it("#5159 one follow-up tracked, another still pending: FORGE:TRACKED says left open, never 'Closed as', and the trajectory says left open", async () => {
|
|
1078
|
+
const k0 = two("defer", { why: "w" });
|
|
1079
|
+
const k = { ...k0, requirements: [...k0.requirements, { id: "R3", quote: "foo crashes on null input.", disposition: "defer", bucket: "post-deploy", why: "w" }] };
|
|
1080
|
+
const w = world({ contract: k, claims: [{ id: "R1", status: "implemented" }], reviews: [conf({}, k)], followupSkip: ["foo crashes on null input."] });
|
|
1081
|
+
const r = await run(w);
|
|
1082
|
+
assert.equal(r.terminalReason, "merged");
|
|
1083
|
+
assert.deepEqual((r.pendingFollowups ?? []).map((p) => p.id), ["R3"]);
|
|
1084
|
+
assert.equal(w.closed.length, 0);
|
|
1085
|
+
const tracked = w.comments.find((c) => c.includes("FORGE:TRACKED"));
|
|
1086
|
+
assert.ok(tracked, "the tracked item is still recorded");
|
|
1087
|
+
assert.match(tracked, /Left open: follow-up pending/); assert.match(tracked, /#900/);
|
|
1088
|
+
assert.ok(!w.comments.some((c) => /Closed as/.test(c)));
|
|
1089
|
+
assert.match(traj(w).join("\n"), /left open \(follow-up pending\)/);
|
|
1090
|
+
});
|
|
1091
|
+
|
|
1056
1092
|
it("a tracking issue that is not open is not a tracking issue: the item stays pending and is recorded", async () => {
|
|
1057
1093
|
const k = two("defer", { why: "w" });
|
|
1058
1094
|
const w = world({ contract: k, claims: [{ id: "R1", status: "implemented" }], reviews: [conf({}, k)], issueStates: { 900: "CLOSED" } });
|
|
@@ -1712,13 +1748,13 @@ describe("conformance shadow mode (the default)", () => {
|
|
|
1712
1748
|
assert.deepEqual(rs.conformance, { mode: "shadow", would: "nonconforming", risk: false });
|
|
1713
1749
|
});
|
|
1714
1750
|
|
|
1715
|
-
it("#4398 an investigation whose question is deferred closes partial (
|
|
1751
|
+
it("#4398 #5152 an investigation whose question is deferred closes partial (completed), carried forward in the tracking issue", async () => {
|
|
1716
1752
|
const k = { ...CONTRACT, preserve: [], requirements: [CONTRACT.requirements[0], { id: "R2", quote: "Existing callers of foo keep working.", disposition: "defer", why: "w", bucket: "new-issue" }] };
|
|
1717
1753
|
const w = world({ title: "investigate(stealth): which signal is rejected", contract: k, claims: [{ id: "R1", status: "implemented" }], reviews: [conf({}, k)] });
|
|
1718
1754
|
const r = await runShadow(w);
|
|
1719
1755
|
assert.equal(r.terminalReason, "merged"); assert.equal(r.close, "partial");
|
|
1720
|
-
assert.deepEqual(w.closed.map((a) => a[a.indexOf("--reason") + 1]), ["
|
|
1721
|
-
assert.ok(w.comments.some((c) => c.includes("<!-- FORGE:TRACKED -->") && /Closed as partial[\s\S]*carried forward in #900/.test(c)));
|
|
1756
|
+
assert.deepEqual(w.closed.map((a) => a[a.indexOf("--reason") + 1]), ["completed"], "#5152: merged with a tracked remainder is completed");
|
|
1757
|
+
assert.ok(w.comments.some((c) => c.includes("<!-- FORGE:TRACKED -->") && /Closed as partial[\s\S]*Closed as completed by PR #[\s\S]*carried forward in #900/.test(c)));
|
|
1722
1758
|
assert.ok(traj(w)[0].includes("| Close | issue closed (partial) |"));
|
|
1723
1759
|
});
|
|
1724
1760
|
|
|
@@ -1747,7 +1783,7 @@ describe("conformance shadow mode (the default)", () => {
|
|
|
1747
1783
|
assert.equal(r.terminalReason, "merged"); assert.equal(r.close, "partial");
|
|
1748
1784
|
assert.equal(w.followups.length, 1); assert.match(w.followups[0].items[0].key, /^R1: /); assert.match(w.followups[0].items[0].why, /investigation question not answered/);
|
|
1749
1785
|
assert.match(w.prs[0].join(" "), /#900/);
|
|
1750
|
-
assert.deepEqual(w.closed.map((a) => a[a.indexOf("--reason") + 1]), ["
|
|
1786
|
+
assert.deepEqual(w.closed.map((a) => a[a.indexOf("--reason") + 1]), ["completed"]);
|
|
1751
1787
|
});
|
|
1752
1788
|
|
|
1753
1789
|
it("#4398 an answered investigation and a non-investigation with a deferral both close completed", async () => {
|
|
@@ -1959,7 +1995,7 @@ describe("hotspot prevention (forge#4195): plan facts, build rule, unexempted gr
|
|
|
1959
1995
|
assert.ok(!builders(w)[0][4].includes("src/bar.js: 300 lines"), "under-threshold files get no line");
|
|
1960
1996
|
assert.match(builders(w)[1][4], /Don't grow a file over 2000 lines by more than 150 lines\. Put new code next to it\./);
|
|
1961
1997
|
assert.equal(w.hotCalls[0].cwd, "/wt/lean-7"); assert.ok(Array.isArray(w.hotCalls[0].paths)); assert.equal(w.hotCalls[0].base, undefined);
|
|
1962
|
-
assert.deepEqual(w.hotCalls[1], { cwd: "/wt/lean-7", base: "origin/staging", paths: ["src/foo.js", "test/foo.test.js"] });
|
|
1998
|
+
assert.deepEqual(w.hotCalls[1], { cwd: "/wt/lean-7", config: null, base: "origin/staging", paths: ["src/foo.js", "test/foo.test.js"] });
|
|
1963
1999
|
const plain = world(); await run(plain);
|
|
1964
2000
|
assert.equal(plain.calls.filter((c) => c[0] === "runner").length, w.calls.filter((c) => c[0] === "runner").length, "no extra LLM calls");
|
|
1965
2001
|
});
|
|
@@ -1988,6 +2024,18 @@ describe("hotspot prevention (forge#4195): plan facts, build rule, unexempted gr
|
|
|
1988
2024
|
assert.equal(builders(wn)[0][4], builders(plain)[0][4], "no plan note"); assert.equal(builders(wn)[1][4], builders(plain)[1][4], "no build rule");
|
|
1989
2025
|
}
|
|
1990
2026
|
});
|
|
2027
|
+
|
|
2028
|
+
it("#5163: io.hotspots gets the host forge.yaml; a null config_source records one hotspot_config_missing anomaly", async () => {
|
|
2029
|
+
const w = hworld({ enabled: true, file_lines: 2000, growth_lines: 150, generated_paths: [], config_source: null, files: [] }, [{ enabled: true, file_lines: 2000, growth_lines: 150, generated_paths: [], config_source: null, files: [] }]);
|
|
2030
|
+
assert.equal((await run(w)).terminalReason, "merged");
|
|
2031
|
+
assert.ok(w.hotCalls.length >= 2);
|
|
2032
|
+
assert.ok(w.hotCalls.every((c) => c.config === null || /forge\.yaml$/.test(c.config)));
|
|
2033
|
+
assert.equal(w.comments.join("\n").split("hotspot_config_missing").length - 1, 1);
|
|
2034
|
+
const host = tmpDir("host-"); writeFileSync(join(host, "forge.yaml"), "maintenance: {}\n");
|
|
2035
|
+
const ok = hworld({ enabled: true, files: [], config_source: join(host, "forge.yaml") }, [{ enabled: true, files: [], config_source: join(host, "forge.yaml") }]);
|
|
2036
|
+
await run(ok, { cwd: host }); assert.ok(!ok.comments.join("\n").includes("hotspot_config_missing"));
|
|
2037
|
+
assert.ok(ok.hotCalls.length >= 2 && ok.hotCalls.every((c) => c.config === join(host, "forge.yaml") && c.cwd === "/wt/lean-7"), "the host checkout's forge.yaml, run in the worktree");
|
|
2038
|
+
});
|
|
1991
2039
|
});
|
|
1992
2040
|
|
|
1993
2041
|
describe("bug lanes freeze a red-green repro_test (#4271)", () => {
|
|
@@ -2649,10 +2697,10 @@ describe("orchestrate", () => {
|
|
|
2649
2697
|
assert.ok(h.log.ends.indexOf(1) < h.log.starts.indexOf(2), JSON.stringify(h.log));
|
|
2650
2698
|
});
|
|
2651
2699
|
|
|
2652
|
-
it("a dependent is
|
|
2700
|
+
it("a dependent is held, without running, when its dependency ends needs-human (transitively)", async () => {
|
|
2653
2701
|
const h = harness({ 2: "**Depends on**: #1", 3: "**Depends on**: #2" }, { 1: "needs-human" });
|
|
2654
2702
|
const rows = await orchestrate({ issues: [1, 2, 3, 4], parallel: 3, ...h });
|
|
2655
|
-
assert.deepEqual(rows.map((r) => r.outcome), ["needs-human", "
|
|
2703
|
+
assert.deepEqual(rows.map((r) => r.outcome), ["needs-human", "held", "held", "merged"]);
|
|
2656
2704
|
assert.ok(!h.log.starts.includes(2) && !h.log.starts.includes(3));
|
|
2657
2705
|
assert.match(rows[1].detail, /#1/);
|
|
2658
2706
|
});
|
|
@@ -2733,7 +2781,7 @@ describe("orchestrate", () => {
|
|
|
2733
2781
|
const rows = await orchestrate({ issues: [9, 1], parallel: 1, readBody: async (n) => (n === 1 ? "**Depends on**: #9" : ""), ...(dispatchCheck ? { dispatchCheck } : {}),
|
|
2734
2782
|
runOne: async (n) => { log.push(n); return { terminalReason: "needs-human", detail: "ci.red" }; } });
|
|
2735
2783
|
assert.deepEqual(log, [9]);
|
|
2736
|
-
assert.deepEqual(rows.map((r) => [r.issue, r.outcome]), [[9, "needs-human"], [1, "
|
|
2784
|
+
assert.deepEqual(rows.map((r) => [r.issue, r.outcome]), [[9, "needs-human"], [1, "held"]]);
|
|
2737
2785
|
}
|
|
2738
2786
|
});
|
|
2739
2787
|
|
|
@@ -2744,7 +2792,7 @@ describe("orchestrate", () => {
|
|
|
2744
2792
|
onUpdate: (r) => rowsSeen.push(r),
|
|
2745
2793
|
dispatchCheck: async (n) => (n === 9 && merged ? { outcome: "merged", pr: 90, detail: "PR #90 already merged" } : null),
|
|
2746
2794
|
runOne: async (n) => { if (n === 9) { merged = true; return { terminalReason: "needs-human", detail: "ci.red" }; } return { terminalReason: "merged", pr: 101 }; } });
|
|
2747
|
-
const skipRow = rowsSeen.find((r) => r.issue === 1 && r.outcome === "
|
|
2795
|
+
const skipRow = rowsSeen.find((r) => r.issue === 1 && r.outcome === "held");
|
|
2748
2796
|
assert.equal(skipRow.waiting, true);
|
|
2749
2797
|
assert.equal(skipRow.trigger, 9);
|
|
2750
2798
|
assert.ok(rowsSeen.some((r) => r.issue === 1 && r.outcome === "readmitted" && r.trigger === 9));
|
|
@@ -2756,7 +2804,7 @@ describe("orchestrate", () => {
|
|
|
2756
2804
|
const rows = await orchestrate({ issues: [9, 1], parallel: 1, readBody: async (n) => (n === 1 ? "**Depends on**: #9" : ""),
|
|
2757
2805
|
dispatchCheck: async (n) => { if (n === 9 && ran) { checks++; return { outcome: "invalid", detail: "issue closed (not planned)", final: true }; } return null; },
|
|
2758
2806
|
runOne: async () => { ran = true; return { terminalReason: "needs-human", detail: "ci.red" }; } });
|
|
2759
|
-
assert.deepEqual(rows.map((r) => [r.issue, r.outcome, r.waiting]), [[9, "needs-human", undefined], [1, "
|
|
2807
|
+
assert.deepEqual(rows.map((r) => [r.issue, r.outcome, r.waiting]), [[9, "needs-human", undefined], [1, "held", undefined]]);
|
|
2760
2808
|
assert.equal(checks, 1, "a final blocker is not re-checked");
|
|
2761
2809
|
});
|
|
2762
2810
|
|
|
@@ -3410,6 +3458,31 @@ describe("usage limit, lease takeover, worktree setup, run tmp (#4101-#4104)", (
|
|
|
3410
3458
|
assert.equal(w.merges.length, 0);
|
|
3411
3459
|
});
|
|
3412
3460
|
|
|
3461
|
+
it("#5168 a claude login failure ends the lane deferred/backend.auth with the account, not engine-error", async () => {
|
|
3462
|
+
const w = world(); projector(w, null); const sleeps = [];
|
|
3463
|
+
const s0 = w.io.sleep; w.io.sleep = async (ms) => { sleeps.push(ms); return s0(ms); };
|
|
3464
|
+
const authErr = Object.assign(new Error("claude CLI exited with status 1. Failed to authenticate. API Error: 401"), { code: "CLI_BACKEND_FAILED", authFailure: true });
|
|
3465
|
+
let tries = 0; const orig = w.io.runner; w.io.runner = async (c) => { if (c.role === "builder") { tries++; throw authErr; } return orig(c); };
|
|
3466
|
+
const r = await run(w);
|
|
3467
|
+
assert.equal(r.terminalReason, "deferred");
|
|
3468
|
+
assert.equal(r.code, "backend.auth");
|
|
3469
|
+
assert.equal(r.retryInSeconds, 900);
|
|
3470
|
+
assert.equal(r.backendId, laneBackendId(process.env), "the hold names the account whose login failed");
|
|
3471
|
+
assert.match(r.detail, /claude CLI authentication failed/);
|
|
3472
|
+
assert.equal(tries, 1, "no in-lane retry or pause on a dead login");
|
|
3473
|
+
assert.equal(sleeps.length, 0);
|
|
3474
|
+
assert.equal(w.edits.some((e) => e.includes("needs-human")), false);
|
|
3475
|
+
assert.equal(w.leaseWrites.at(-1).lease, null, "lease released");
|
|
3476
|
+
});
|
|
3477
|
+
|
|
3478
|
+
it("#5168 an error that is both a usage limit and auth-like stays rate_limited", async () => {
|
|
3479
|
+
const w = world();
|
|
3480
|
+
failFirstBuilder(w, limitErr({ authFailure: true, resetAtEpochMs: 3 * 3600 * 1000, resetAt: "8:30pm" }));
|
|
3481
|
+
const r = await run(w);
|
|
3482
|
+
assert.equal(r.terminalReason, "deferred");
|
|
3483
|
+
assert.equal(r.code, "rate_limited");
|
|
3484
|
+
});
|
|
3485
|
+
|
|
3413
3486
|
it("#4101 unknown reset pauses a bounded number of times, then defers", async () => {
|
|
3414
3487
|
const w = world(); let sleeps = 0;
|
|
3415
3488
|
const s0 = w.io.sleep; w.io.sleep = async (ms) => { sleeps++; return s0(ms); };
|
|
@@ -120,3 +120,50 @@ describe("#5048: the pool is unreachable only after a failed capacity probe", ()
|
|
|
120
120
|
assert.deepEqual(notes, ["down", "clear"]);
|
|
121
121
|
});
|
|
122
122
|
});
|
|
123
|
+
|
|
124
|
+
describe("#5162: failed roots hold their subtree; only real cycles are cycles", () => {
|
|
125
|
+
const memStore = () => { let st = null; return { load: () => st, save: (s) => { st = JSON.parse(JSON.stringify(s)); }, get: () => st }; };
|
|
126
|
+
const chain = { 1: "", 2: "**Depends on**: #1", 3: "**Depends on**: #2", 4: "**Depends on**: #1, #3" };
|
|
127
|
+
const outcome = (rows, n) => rows.find((r) => r.issue === n);
|
|
128
|
+
|
|
129
|
+
it("a DAG whose engine-error root ends marks no row dependency cycle; every dependent is held and names the root", async () => {
|
|
130
|
+
const rows = await orchestrate({ issues: [1, 2, 3, 4], parallel: 2, pollMs: 5, readBody: async (n) => chain[n], engineErrorRetries: 0, transientRetries: 0,
|
|
131
|
+
runOne: async () => ({ terminalReason: "engine-error", detail: "boom" }) });
|
|
132
|
+
assert.ok(!rows.some((r) => /dependency cycle/.test(r.detail ?? "")), JSON.stringify(rows));
|
|
133
|
+
for (const n of [2, 3, 4]) { assert.equal(outcome(rows, n).outcome, "held"); assert.match(outcome(rows, n).detail, /^blocked by #1 \(engine-error\)$/); }
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it("a genuine cycle is still labelled dependency cycle; its downstream names a member", async () => {
|
|
137
|
+
const bodies = { 1: "**Depends on**: #2", 2: "**Depends on**: #1", 3: "**Depends on**: #2" };
|
|
138
|
+
const rows = await orchestrate({ issues: [1, 2, 3], parallel: 2, pollMs: 5, readBody: async (n) => bodies[n], runOne: async () => merged });
|
|
139
|
+
assert.deepEqual(rows.map((r) => r.outcome), ["skipped", "skipped", "skipped"]);
|
|
140
|
+
assert.equal(outcome(rows, 1).detail, "dependency cycle");
|
|
141
|
+
assert.equal(outcome(rows, 2).detail, "dependency cycle");
|
|
142
|
+
assert.match(outcome(rows, 3).detail, /^blocked by #[12] \(dependency cycle\)$/);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it("dependents of a needs-human root end held; after the label is removed a resume admits root then dependents in order", async () => {
|
|
146
|
+
const store = memStore();
|
|
147
|
+
const first = await orchestrate({ issues: [1, 2, 3, 4], parallel: 2, pollMs: 5, store, readBody: async (n) => chain[n], runOne: async () => ({ terminalReason: "needs-human", code: "ci.red", detail: "red" }) });
|
|
148
|
+
assert.equal(outcome(first, 1).outcome, "needs-human");
|
|
149
|
+
for (const n of [2, 3, 4]) assert.deepEqual([outcome(first, n).outcome, outcome(first, n).detail], ["held", "blocked by #1 (needs-human)"]);
|
|
150
|
+
const started = [];
|
|
151
|
+
const rows = await orchestrate({ issues: [1, 2, 3, 4], parallel: 3, pollMs: 5, store, readBody: async (n) => chain[n], issueLabels: async () => [],
|
|
152
|
+
runOne: async (n) => { started.push(n); await new Promise((r) => setTimeout(r, 5)); return merged; } });
|
|
153
|
+
assert.deepEqual(started, [1, 2, 3, 4]);
|
|
154
|
+
assert.ok(rows.every((r) => r.outcome === "merged"), JSON.stringify(rows));
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it("a resume with the needs-human label still on the root keeps the subtree held", async () => {
|
|
158
|
+
const store = memStore();
|
|
159
|
+
await orchestrate({ issues: [1, 2], parallel: 1, pollMs: 5, store, readBody: async (n) => chain[n], runOne: async () => ({ terminalReason: "needs-human", detail: "x" }) });
|
|
160
|
+
const rows = await orchestrate({ issues: [1, 2], parallel: 1, pollMs: 5, store, readBody: async (n) => chain[n], issueLabels: async () => ["needs-human"], runOne: async () => merged });
|
|
161
|
+
assert.deepEqual(rows.map((r) => r.outcome), ["needs-human", "held"]);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it("the report lists a held subtree with its root and one --requeue command", async () => {
|
|
165
|
+
const { formatOutcomeLists } = await import("./orchestrate.mjs");
|
|
166
|
+
const lines = formatOutcomeLists([{ issue: 1, outcome: "engine-error" }, { issue: 2, outcome: "held", root: 1 }, { issue: 3, outcome: "held", root: 1 }]);
|
|
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
|
+
});
|
|
169
|
+
});
|
package/bin/lean/orchestrate.mjs
CHANGED
|
@@ -20,8 +20,10 @@
|
|
|
20
20
|
* A seam calls `onLive()` before it waits on a live lane (#4504); an adopt that resolves first is settled (or requeued on null)
|
|
21
21
|
* before scheduling, so a live lane does not hold up the others.
|
|
22
22
|
* `deferred` is a scheduling fact, not an end: each typed code is requeued with its retry-at (`deferPolicy`), a usage
|
|
23
|
-
* limit holds admissions for that account until its reset, and deferrals other than a wait (`host.busy`,
|
|
24
|
-
* `sandbox.capacity`, #4528; `sandbox.unreachable`, #4788; `rate_limited`, #4784) stop after `maxDeferrals`.
|
|
23
|
+
* limit (and #5168 a claude login failure, `backend.auth`) holds admissions for that account until its reset, and deferrals other than a wait (`host.busy`,
|
|
24
|
+
* `sandbox.capacity`, #4528; `sandbox.unreachable`, #4788; `rate_limited`, #4784; `backend.auth`, #5168) stop after `maxDeferrals`.
|
|
25
|
+
* #5161: an engine-error whose detail is a transport/gateway failure (`isTransientEngineError`) is requeued with backoff
|
|
26
|
+
* (`transientRetryDelayMs`) up to `transientRetries` times, not counted against `ENGINE_ERROR_RELAUNCHES`; then it ends engine-error.
|
|
25
27
|
* #5112: with `remote.offlineFallback` (`execution.fallback_local`), an issue deferred `remote.capacityFallbackAfter` times (default
|
|
26
28
|
* `CAPACITY_FALLBACK_AFTER`) for `sandbox.capacity` runs on the host when `remote.headroom()` (host-busy guard) allows it.
|
|
27
29
|
* Usage-limit holds (#4190) are keyed by backend identity in `limits` (the host store, shared by every batch on the
|
|
@@ -85,6 +87,8 @@
|
|
|
85
87
|
* With `remote.fallbackLocal`, a lane placed remote runs on the host path instead of waiting when `max` remote lanes run,
|
|
86
88
|
* and instead of stopping when the budget refuses. The final `{where, reason}` is kept on the run record and the row as
|
|
87
89
|
* `placement` and passed to `runOne` as `ctx.placement` (the lane records it in its FORGE:STATE).
|
|
90
|
+
* #5174: `overload() -> {overloaded, ...}` (hostload.mjs `liveOverload`) holds every new non-remote admission while the
|
|
91
|
+
* host is overloaded (retry after `pollMs`), with one `host-overloaded` row per episode; remote placements are never held.
|
|
88
92
|
*
|
|
89
93
|
* In-batch recovery (#4267), on by default: this module recovers only when `recovery: {maxAttempts}` is passed, and the
|
|
90
94
|
* CLI always passes it (forge.yaml `orchestration.recovery.max_attempts`, default 1; 0 disables): a row `classifyNeedsHuman` calls
|
|
@@ -125,9 +129,31 @@ import { makeCapWait } from "./capwait.mjs";
|
|
|
125
129
|
import { mapLimit } from "./pmap.mjs";
|
|
126
130
|
import { quotaRequeue } from "./rotator.mjs";
|
|
127
131
|
import { joinsDecomposed, addsEpicChildren, selectChildren, edgeText, DEFAULT_POLL_S } from "./autochildren.mjs";
|
|
132
|
+
import { formatOverload } from "./hostload.mjs";
|
|
128
133
|
|
|
129
134
|
// A dependency that finished like this no longer blocks its dependents.
|
|
130
135
|
const SATISFIED = new Set(["merged", "invalid"]);
|
|
136
|
+
// #5162: a dependent of a root that ended like this is held (resumable), not skipped.
|
|
137
|
+
const HOLD_ROOT = new Set(["needs-human", "engine-error", "deferred", "budget-exceeded"]);
|
|
138
|
+
/** #5162: members of a real dependency cycle (a nontrivial SCC or a self-loop) among `nodes`; `edgesOf(n)` lists n's dependencies. */
|
|
139
|
+
export function cyclicNodes(nodes, edgesOf) {
|
|
140
|
+
const inSet = new Set(nodes), idx = new Map(), low = new Map(), stack = [], on = new Set(), out = new Set();
|
|
141
|
+
let i = 0;
|
|
142
|
+
const visit = (v) => {
|
|
143
|
+
idx.set(v, i); low.set(v, i); i++; stack.push(v); on.add(v);
|
|
144
|
+
for (const w of edgesOf(v).filter((d) => inSet.has(d))) {
|
|
145
|
+
if (w === v) out.add(v);
|
|
146
|
+
if (!idx.has(w)) { visit(w); low.set(v, Math.min(low.get(v), low.get(w))); } else if (on.has(w)) low.set(v, Math.min(low.get(v), idx.get(w)));
|
|
147
|
+
}
|
|
148
|
+
if (low.get(v) === idx.get(v)) {
|
|
149
|
+
const comp = [];
|
|
150
|
+
for (let w; w !== v;) { w = stack.pop(); on.delete(w); comp.push(w); }
|
|
151
|
+
if (comp.length > 1) for (const c of comp) out.add(c);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
for (const n of nodes) if (!idx.has(n)) visit(n);
|
|
155
|
+
return out;
|
|
156
|
+
}
|
|
131
157
|
const WATCH_EVERY_MS = 60_000; // #4595
|
|
132
158
|
// Times one issue may be requeued behind a dependency before its dependency-open row is final.
|
|
133
159
|
export const MAX_REQUEUES = 2;
|
|
@@ -146,6 +172,15 @@ export const CAPACITY_FALLBACK_AFTER = 3;
|
|
|
146
172
|
export const RATE_LIMIT_FALLBACK_S = 15 * 60;
|
|
147
173
|
export const DEFER_BACKOFF_S = 120;
|
|
148
174
|
export const DEFER_BACKOFF_MAX_S = 30 * 60;
|
|
175
|
+
// #4685 + #5161: an engine-error detail that names a link or gateway failure (curl's "returned error: 502", HTTP/1.1 503, ...).
|
|
176
|
+
export const TRANSPORT_TEXT = /fetch failed|ECONNREFUSED|ECONNRESET|ETIMEDOUT|EAI_AGAIN|ENOTFOUND|socket hang up|HTTP 50[234]|returned error: 5\d\d|HTTP\/\d(\.\d)? 5\d\d|Bad Gateway|Service Unavailable|overloaded/i;
|
|
177
|
+
/** #5161: a transient engine failure (model gateway 5xx, connection reset): retried with backoff, not the single relaunch. */
|
|
178
|
+
export const isTransientEngineError = (detail) => TRANSPORT_TEXT.test(String(detail ?? ""));
|
|
179
|
+
// #5161: transient engine-error retries per issue (forge.yaml `orchestration.transient_retries`) and their backoff: 30s, 2m, 8m, then 15m.
|
|
180
|
+
export const DEFAULT_TRANSIENT_RETRIES = 4;
|
|
181
|
+
export const TRANSIENT_BACKOFF_S = 30;
|
|
182
|
+
export const TRANSIENT_BACKOFF_MAX_S = 15 * 60;
|
|
183
|
+
export const transientRetryDelayMs = (k) => Math.min(TRANSIENT_BACKOFF_S * 4 ** (Math.max(1, k) - 1), TRANSIENT_BACKOFF_MAX_S) * 1000;
|
|
149
184
|
// A dependency-open whose dependencies already finished satisfied (GitHub not yet closed): wait before relaunching.
|
|
150
185
|
export const DEP_REQUEUE_DELAY_S = 60;
|
|
151
186
|
|
|
@@ -204,6 +239,8 @@ export function deferPolicy(r, { now, deferrals = 0, maxDeferrals = DEFAULT_MAX_
|
|
|
204
239
|
const at = posNum(r?.resetAtEpochMs) && r.resetAtEpochMs > now ? r.resetAtEpochMs : now + (posNum(r?.retryInSeconds) ?? RATE_LIMIT_FALLBACK_S) * 1000;
|
|
205
240
|
return { delayMs: at - now, hold: true };
|
|
206
241
|
}
|
|
242
|
+
// #5168: a failed claude login is an account condition, not an engine fault: held like a usage limit, never capped.
|
|
243
|
+
if (code === "backend.auth") return { delayMs: (posNum(r?.retryInSeconds) ?? RATE_LIMIT_FALLBACK_S) * 1000, hold: true };
|
|
207
244
|
const k = deferrals + 1;
|
|
208
245
|
if (k > maxDeferrals) return { capped: true };
|
|
209
246
|
if (posNum(r?.retryInSeconds)) return { delayMs: r.retryInSeconds * 1000 };
|
|
@@ -267,7 +304,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
267
304
|
classify = null, maintenance = null, limits = null, identity = () => "default", batchId = null, drift = null, integration = null, sched = null, priorityOf = null, remote = null, beforeAdmit = null, preflight = null,
|
|
268
305
|
recovery = null, decide = () => {}, conflicting = null, relabelNeedsHuman = null, onExit = null, issueLabels = null, issueState = null, getCancelled = null, getHeld = null, getBlocked = null, trusted = null, getGates = null, stopLane = null,
|
|
269
306
|
estimate = null, starveMs = DEFAULT_STARVE_MS, setupConcurrency = DEFAULT_SETUP_CONCURRENCY, signal = null, dispatchCheck = null, syncParked = null, syncEveryMs = DEFAULT_SYNC_EVERY_MS, lifecycle = null,
|
|
270
|
-
getChildren = null, autoChildren = null, baseWait = null, rotator = null }) {
|
|
307
|
+
getChildren = null, autoChildren = null, baseWait = null, rotator = null, transientRetries = DEFAULT_TRANSIENT_RETRIES, overload = null }) {
|
|
271
308
|
const saved = store?.load?.() ?? null;
|
|
272
309
|
const order = saved ? [...saved.order] : [];
|
|
273
310
|
const set = new Set(order);
|
|
@@ -284,6 +321,8 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
284
321
|
const capDefers = toMap(saved?.capDeferrals); // #5112: issue -> `sandbox.capacity` deferrals (uncapped, so not in `deferrals`)
|
|
285
322
|
const capFellBack = new Set(); // #5112: issues already reported as a capacity fallback (one decision each)
|
|
286
323
|
const engineErrors = toMap(saved?.engineErrors);
|
|
324
|
+
const transients = toMap(saved?.transientRetries); // #5161: issue -> transient engine-error retries taken
|
|
325
|
+
const transientMax = Number.isInteger(transientRetries) && transientRetries >= 0 ? transientRetries : DEFAULT_TRANSIENT_RETRIES;
|
|
287
326
|
const checked = toMap(saved?.prefilter); // issue -> pre-filter result
|
|
288
327
|
const estimates = toMap(saved?.estimates); // #4409: issue -> estimated lane minutes; only with `estimate`
|
|
289
328
|
const enqueued = toMap(saved?.enqueued); // #4409: issue -> when it last entered the queue (starvation guard)
|
|
@@ -369,7 +408,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
369
408
|
const save = () => {
|
|
370
409
|
if (!store || halted) return;
|
|
371
410
|
store.save({ v: 1, ...(setup ? { phase: "setup", setup: { ...setup } } : {}), order, deps: toObj(deps), lanes: toObj(lanes), crossSeen: [...crossSeen], results: toObj(results), running: toObj(runRecs),
|
|
372
|
-
pending, notBefore: toObj(notBefore), requeues: toObj(requeues), deferrals: toObj(deferrals), engineErrors: toObj(engineErrors), ...(quota.size ? { quota: toObj(quota) } : {}), ...(capDefers.size ? { capDeferrals: toObj(capDefers) } : {}),
|
|
411
|
+
pending, notBefore: toObj(notBefore), requeues: toObj(requeues), deferrals: toObj(deferrals), engineErrors: toObj(engineErrors), ...(transients.size ? { transientRetries: toObj(transients) } : {}), ...(quota.size ? { quota: toObj(quota) } : {}), ...(capDefers.size ? { capDeferrals: toObj(capDefers) } : {}),
|
|
373
412
|
prefilter: toObj(checked), errorTimes, breaker: tripped, ...(budget ? { classes: toObj(classes), dispatch: { ...dispatch } } : {}),
|
|
374
413
|
...(reg ? { priorities: toObj(priorities) } : {}), ...(sandboxUse.size ? { sandbox: toObj(sandboxUse) } : {}),
|
|
375
414
|
...(recoveries.size || recovering.size ? { recoveries: toObj(recoveries), recovering: toObj(recovering), recoveryClasses: toObj(classUsed) } : {}),
|
|
@@ -558,6 +597,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
558
597
|
};
|
|
559
598
|
// A host slot for `n` (a lane-refused issue runs nothing and needs none); refused: `n` stays queued in the registry.
|
|
560
599
|
// true: start it; false: no capacity now; "busy" (#4481): another batch runs `n`, try the next issue.
|
|
600
|
+
let overloadNoted = false; // #5174: one host-overloaded row per overload episode
|
|
561
601
|
const grant = (n, wanted) => {
|
|
562
602
|
if (lanes.get(n)?.ok === false) return true;
|
|
563
603
|
let p = placeOf(n);
|
|
@@ -617,6 +657,16 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
617
657
|
p = { where: "local", reason: `fallback to local: execution budget: ${adm.reason}` };
|
|
618
658
|
}
|
|
619
659
|
}
|
|
660
|
+
if (p?.where !== "remote" && overload) {
|
|
661
|
+
let snap = null;
|
|
662
|
+
try { snap = overload(); } catch { snap = null; }
|
|
663
|
+
if (snap?.overloaded) {
|
|
664
|
+
if (!overloadNoted) { overloadNoted = true; update({ issue: null, outcome: "host-overloaded", detail: formatOverload(snap) }); }
|
|
665
|
+
notBefore.set(n, now() + Math.max(pollMs, 1));
|
|
666
|
+
return false;
|
|
667
|
+
}
|
|
668
|
+
overloadNoted = false;
|
|
669
|
+
}
|
|
620
670
|
if (!reg) { if (p) placed.set(n, p); return true; }
|
|
621
671
|
const r = reg.tryAcquire(keyOf(n), entryOf(n), liveCap());
|
|
622
672
|
if (!r?.ok && r?.conflict != null) return busy(n, r.conflict, wanted);
|
|
@@ -633,15 +683,19 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
633
683
|
results.set(n, { issue: n, outcome: "skipped", pr: null, cost_usd: 0, minutes: 0, detail, ...(trigger !== null && dispatchCheck ? { waiting: true } : {}) });
|
|
634
684
|
update({ ...results.get(n), ...(trigger !== null ? { trigger } : {}) });
|
|
635
685
|
};
|
|
686
|
+
// #5162: a dependent of a failed root ends held (trigger = the root, not the parent) and is released with the root.
|
|
687
|
+
const holdBehind = (n, root, rootOutcome) => {
|
|
688
|
+
results.set(n, { issue: n, outcome: "held", pr: null, cost_usd: 0, minutes: 0, detail: `blocked by #${root} (${rootOutcome})`, root, ...(dispatchCheck ? { waiting: true } : {}) });
|
|
689
|
+
update({ ...results.get(n), trigger: root });
|
|
690
|
+
};
|
|
636
691
|
const requeue = (n, delayMs) => { pending.push(n); enqueued.set(n, now()); if (delayMs > 0) notBefore.set(n, now() + delayMs); else notBefore.delete(n); };
|
|
637
|
-
const TRANSPORT_TEXT = /fetch failed|ECONNREFUSED|ECONNRESET|ETIMEDOUT|EAI_AGAIN|ENOTFOUND|socket hang up|HTTP 50[234]/i;
|
|
638
692
|
const TRANSPORT_COOLDOWN_MS = 5 * 60000;
|
|
639
693
|
let transportErrors = 0; // #4685: engine-errors in the current window that were link failures
|
|
640
694
|
const noteEngineError = (detail = "") => {
|
|
641
695
|
if (!breaker) return;
|
|
642
696
|
const t = now(), windowMs = breaker.window_min * 60000;
|
|
643
697
|
errorTimes = [...errorTimes.filter((x) => t - x < windowMs), t];
|
|
644
|
-
transportErrors =
|
|
698
|
+
transportErrors = isTransientEngineError(detail) ? Math.min(transportErrors + 1, errorTimes.length) : 0;
|
|
645
699
|
if (!tripped && errorTimes.length >= breaker.errors) {
|
|
646
700
|
tripped = { at: t, ...(transportErrors >= errorTimes.length ? { transport: true } : {}), detail: `circuit breaker: ${errorTimes.length} engine-errors within ${breaker.window_min} min; admissions stopped` };
|
|
647
701
|
update({ issue: null, outcome: "breaker", detail: tripped.detail });
|
|
@@ -757,7 +811,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
757
811
|
resumeAt, rotations: (q.rotations ?? 0) + (rq?.rotated ? 1 : 0) });
|
|
758
812
|
requeue(n, delayMs); done(); save();
|
|
759
813
|
const iso = new Date(resumeAt).toISOString();
|
|
760
|
-
update({ ...row, outcome: "paused", quota: { resumeAt: iso }, detail: `paused (quota) until ${iso}: ${r?.code ?? "deferred"}${r?.detail ? ` ${r.detail}` : ""}` });
|
|
814
|
+
update({ ...row, outcome: "paused", quota: { resumeAt: iso }, detail: `paused (${r?.code === "backend.auth" ? "backend.auth" : "quota"}) until ${iso}: ${r?.code ?? "deferred"}${r?.detail ? ` ${r.detail}` : ""}` });
|
|
761
815
|
return;
|
|
762
816
|
}
|
|
763
817
|
requeue(n, capGated ? 0 : delayMs); done(); save();
|
|
@@ -768,7 +822,20 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
768
822
|
}
|
|
769
823
|
if (row.outcome === "engine-error") {
|
|
770
824
|
noteEngineError(r?.detail);
|
|
771
|
-
|
|
825
|
+
// #5161: a transient failure (gateway 5xx, reset) waits out the outage with backoff instead of the single immediate relaunch.
|
|
826
|
+
if (transientMax > 0 && isTransientEngineError(row.detail)) {
|
|
827
|
+
const k = (transients.get(n) ?? 0) + 1;
|
|
828
|
+
if (k <= transientMax) {
|
|
829
|
+
const delayMs = transientRetryDelayMs(k), secs = Math.round(delayMs / 1000);
|
|
830
|
+
transients.set(n, k);
|
|
831
|
+
requeue(n, delayMs); done(); save();
|
|
832
|
+
decided({ issue: n, what: `retry after transient engine-error (${k}/${transientMax}) in ${secs}s`, why: `transient: ${firstLine(row.detail) || "engine-error"}`,
|
|
833
|
+
alternative: "end the issue engine-error and skip its dependents" });
|
|
834
|
+
update({ ...row, detail: `transient retry ${k}/${transientMax} in ${secs}s: ${row.detail ?? ""}` });
|
|
835
|
+
return;
|
|
836
|
+
}
|
|
837
|
+
row.detail = `gave up after ${transientMax} transient retries: ${row.detail ?? ""}`;
|
|
838
|
+
} else if ((engineErrors.get(n) ?? 0) < ENGINE_ERROR_RELAUNCHES) {
|
|
772
839
|
engineErrors.set(n, (engineErrors.get(n) ?? 0) + 1);
|
|
773
840
|
requeue(n, 0); done(); save();
|
|
774
841
|
decided({ issue: n, what: "relaunch once after engine-error", why: firstLine(row.detail) || "engine-error", alternative: "end the issue engine-error and skip its dependents" });
|
|
@@ -1039,12 +1106,13 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1039
1106
|
results.delete(e.issue);
|
|
1040
1107
|
for (let i = 0; i < moved.length; i++) { // dependents skipped behind a requeued issue (fixpoint)
|
|
1041
1108
|
for (const [m, r] of [...results]) {
|
|
1042
|
-
|
|
1109
|
+
const heldBehind = r?.outcome === "held" && r.root === moved[i]; // #5162
|
|
1110
|
+
if (!heldBehind && (r?.outcome !== "skipped" || Number(/^dependency #(\d+)/.exec(r.detail ?? "")?.[1]) !== moved[i])) continue;
|
|
1043
1111
|
priors.set(m, r); results.delete(m); moved.push(m);
|
|
1044
1112
|
}
|
|
1045
1113
|
}
|
|
1046
1114
|
for (const m of moved) {
|
|
1047
|
-
for (const x of [requeues, deferrals, capDefers, engineErrors, recoveries, recovering]) x.delete(m);
|
|
1115
|
+
for (const x of [requeues, deferrals, capDefers, engineErrors, transients, recoveries, recovering]) x.delete(m);
|
|
1048
1116
|
relabelled.delete(m);
|
|
1049
1117
|
if (m === e.issue) requeuedInfo.set(m, { reason: e.reason, by: e.by, at: e.at, prior: [...(requeuedInfo.get(m)?.prior ?? []), priors.get(m)] });
|
|
1050
1118
|
if (!pending.includes(m)) requeue(m, 0);
|
|
@@ -1182,7 +1250,45 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1182
1250
|
const readmitted = new Set(); // "n:b": re-admit n on blocker b once; a lane that re-skips on b stays skipped
|
|
1183
1251
|
const blockerOf = (n) => { const r = results.get(n); const m = r?.outcome === "skipped" ? /^dependency #(\d+) /.exec(r.detail ?? "") : null; return m ? Number(m[1]) : null; };
|
|
1184
1252
|
const watchable = () => !!dispatchCheck && [...results.keys()].some((n) => blockerOf(n) !== null);
|
|
1253
|
+
// #5162: held rows behind `root` return to pending (and the root too when `withRoot`: requeued, counters reset), parents first via the edges.
|
|
1254
|
+
const releaseHeld = (root, withRoot, why) => {
|
|
1255
|
+
const moved = withRoot && results.has(root) ? [root] : [];
|
|
1256
|
+
if (moved.length) results.delete(root);
|
|
1257
|
+
for (const [m, r] of [...results]) if (r?.outcome === "held" && r.root === root) { results.delete(m); moved.push(m); }
|
|
1258
|
+
for (const m of moved) {
|
|
1259
|
+
for (const x of [requeues, deferrals, capDefers, engineErrors, transients, recoveries, recovering]) x.delete(m);
|
|
1260
|
+
relabelled.delete(m);
|
|
1261
|
+
if (!pending.includes(m)) requeue(m, 0);
|
|
1262
|
+
update({ issue: m, outcome: "readmitted", detail: m === root ? why : `dependency #${root} ${why}`, trigger: root });
|
|
1263
|
+
}
|
|
1264
|
+
if (moved.length) { save(); decided({ issue: root, what: `released held subtree of #${root}: ${moved.filter((m) => m !== root).map((m) => `#${m}`).join(", ") || "none"}`, why, alternative: "leave it held until a --requeue" }); }
|
|
1265
|
+
};
|
|
1266
|
+
const restoredHeld = new Set([...results.values()].filter((r) => r?.outcome === "held" && Number.isInteger(r.root)).map((r) => r.root)); // roots held by an earlier run of this batch
|
|
1267
|
+
const watchHeldRoots = async () => {
|
|
1268
|
+
for (const root of new Set([...results.values()].filter((r) => r?.outcome === "held" && Number.isInteger(r.root)).map((r) => r.root))) {
|
|
1269
|
+
const ro = results.get(root)?.outcome;
|
|
1270
|
+
if (ro === undefined || running.has(root) || settled.has(root)) continue;
|
|
1271
|
+
if (restoredHeld.has(root) && ["needs-human", "budget-exceeded"].includes(ro) && typeof issueLabels === "function") { // label removed: requeue the root, its subtree follows
|
|
1272
|
+
let names = null;
|
|
1273
|
+
try { names = await issueLabels(root); } catch { names = null; }
|
|
1274
|
+
if (Array.isArray(names) && !names.includes("needs-human")) { releaseHeld(root, true, "needs-human label removed"); continue; }
|
|
1275
|
+
}
|
|
1276
|
+
if (!dispatchCheck) continue;
|
|
1277
|
+
let g = null;
|
|
1278
|
+
try { g = (await dispatchCheck(root)) ?? null; } catch { g = null; }
|
|
1279
|
+
if (g?.final) { // closed as not planned: terminal for its held dependents
|
|
1280
|
+
settled.add(root);
|
|
1281
|
+
for (const [m, r] of [...results]) if (r?.outcome === "held" && r.root === root && r.waiting) { const { waiting, ...rest } = r; results.set(m, rest); update({ ...rest, trigger: root }); }
|
|
1282
|
+
continue;
|
|
1283
|
+
}
|
|
1284
|
+
if (g && SATISFIED.has(g.outcome)) { // merged or closed outside the batch
|
|
1285
|
+
results.set(root, { ...results.get(root), outcome: g.outcome, pr: Number.isInteger(g.pr) ? g.pr : results.get(root).pr, detail: g.detail ?? results.get(root).detail });
|
|
1286
|
+
update(results.get(root)); releaseHeld(root, false, "merged or closed");
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
};
|
|
1185
1290
|
const watchBlockers = async (final) => {
|
|
1291
|
+
if (!cancelled && !tripped && (final || lastWatch === null || now() - lastWatch >= WATCH_EVERY_MS) && [...results.values()].some((r) => r?.outcome === "held" && Number.isInteger(r.root))) await watchHeldRoots();
|
|
1186
1292
|
if (!watchable() || cancelled || tripped) return;
|
|
1187
1293
|
const t0 = now();
|
|
1188
1294
|
if (!final && lastWatch !== null && t0 - lastWatch < WATCH_EVERY_MS) return;
|
|
@@ -1240,7 +1346,12 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1240
1346
|
const n = pending[i];
|
|
1241
1347
|
if (results.has(n)) { pending.splice(i, 1); continue; }
|
|
1242
1348
|
const bad = edges(n).find((d) => results.has(d) && !SATISFIED.has(results.get(d).outcome));
|
|
1243
|
-
if (bad !== undefined) {
|
|
1349
|
+
if (bad !== undefined) {
|
|
1350
|
+
pending.splice(i, 1); again = true;
|
|
1351
|
+
const br = results.get(bad), root = br.root ?? bad, ro = results.get(root)?.outcome ?? br.outcome;
|
|
1352
|
+
if (HOLD_ROOT.has(ro)) holdBehind(n, root, ro); // #5162
|
|
1353
|
+
else skip(n, `dependency #${bad} ended ${br.outcome}`, bad);
|
|
1354
|
+
}
|
|
1244
1355
|
}
|
|
1245
1356
|
}
|
|
1246
1357
|
const t = now();
|
|
@@ -1373,7 +1484,19 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1373
1484
|
else if (pending.length && (driftHeld.size || integHeld.size)) { if (await drainAdds()) continue; break; } // held by a drift flag (block_dispatch) or a red integration streak (#4667): pending for a later batch
|
|
1374
1485
|
else if (pending.some((n) => remoteCapped.has(n))) await nap(wake ?? pollMs); // #5138: live max_remote 0: wait for a raise or another placement
|
|
1375
1486
|
else if (pending.length) { // nothing runnable, nothing running, nothing waiting on time: a dependency cycle
|
|
1376
|
-
|
|
1487
|
+
// #5162: only real cycles are labelled so; the rest name the cycle member (or failed root) that blocks them
|
|
1488
|
+
const cyc = cyclicNodes(pending, edges), inP = new Set(pending);
|
|
1489
|
+
const blocker = (n, seen = new Set()) => {
|
|
1490
|
+
for (const d of edges(n)) {
|
|
1491
|
+
if (cyc.has(d)) return d;
|
|
1492
|
+
if (inP.has(d) && !seen.has(d)) { seen.add(d); const b = blocker(d, seen); if (b !== null) return b; }
|
|
1493
|
+
}
|
|
1494
|
+
return null;
|
|
1495
|
+
};
|
|
1496
|
+
for (const n of pending.splice(0)) {
|
|
1497
|
+
const b = cyc.has(n) ? null : blocker(n);
|
|
1498
|
+
skip(n, cyc.has(n) ? "dependency cycle" : b !== null ? `blocked by #${b} (dependency cycle)` : "blocked: no dependency path is runnable");
|
|
1499
|
+
}
|
|
1377
1500
|
save();
|
|
1378
1501
|
}
|
|
1379
1502
|
}
|
|
@@ -1444,6 +1567,9 @@ export function formatOutcomeLists(rows) {
|
|
|
1444
1567
|
const one = (x) => String(x ?? "").split("\n")[0].slice(0, OUTCOME_LINE_MAX);
|
|
1445
1568
|
const requeued = (rows ?? []).filter((r) => r?.requeued); // #4550: operator --requeue after a decision; the row is the latest outcome
|
|
1446
1569
|
if (requeued.length) out.push(`requeued: ${requeued.map((r) => `#${r.issue} (${one(r.requeued.reason)})`).join(" ")}`);
|
|
1570
|
+
const heldBy = new Map(); // #5162: held subtrees by root, one --requeue command each
|
|
1571
|
+
for (const r of rows ?? []) if (r?.outcome === "held" && Number.isInteger(r.root)) heldBy.set(r.root, [...(heldBy.get(r.root) ?? []), r.issue]);
|
|
1572
|
+
for (const [root, xs] of heldBy) { const ro = (rows ?? []).find((r) => r?.issue === root)?.outcome ?? "failed"; out.push(`held subtree: #${root} (${ro}) holds ${xs.map((x) => `#${x}`).join(" ")}; release: forgedock orchestrate --requeue <batch> ${root}`); }
|
|
1447
1573
|
const rec = (rows ?? []).filter((r) => r?.recovered);
|
|
1448
1574
|
if (rec.length) out.push(`recovered: ${rec.map((r) => `#${r.issue} (${r.recovered})`).join(" ")}`);
|
|
1449
1575
|
for (const r of rows ?? []) {
|
package/bin/lean/prefilter.mjs
CHANGED
|
@@ -455,11 +455,12 @@ export async function prefilterIssue({ issue, repo, lane, cwd, io, model = DEFAU
|
|
|
455
455
|
return { ...out, detail: "acceptance probe failed after promotion (FORGE:PROBE): no already-fixed close; lane" };
|
|
456
456
|
}
|
|
457
457
|
const sig = await collectSignals({ iss, repo, lane, io, cwd, selfLogins });
|
|
458
|
-
|
|
458
|
+
// #5152: `completed` for a delivered outcome (CI green again, ALREADY-FIXED); only an INVALID verdict is dropped scope
|
|
459
|
+
const close = async (kind, body, detail, reason = "completed") => {
|
|
459
460
|
let note = "";
|
|
460
461
|
if (!dryRun) {
|
|
461
462
|
// #4315: close first: the marker is posted only on an issue that was closed, so it always means "reopened" later
|
|
462
|
-
await io.gh(["issue", "close", String(issue), "-R", repo, "--reason",
|
|
463
|
+
await io.gh(["issue", "close", String(issue), "-R", repo, "--reason", reason]);
|
|
463
464
|
// #4314: the issue IS closed from here on: the result is closed:true whatever the comment does, so no lane starts on it.
|
|
464
465
|
// The comment is retried once, then a marker-only comment (a second, tiny payload) keeps the #4305 reopen guard working.
|
|
465
466
|
const comment = (text) => io.gh(["issue", "comment", String(issue), "-R", repo, "--body", text]);
|
|
@@ -498,7 +499,7 @@ export async function prefilterIssue({ issue, repo, lane, cwd, io, model = DEFAU
|
|
|
498
499
|
if (!v || v.verdict === "CONFIRMED" || !v.evidence.length) return keep(`candidate (${why}) ${v ? (v.verdict === "CONFIRMED" ? "confirmed" : "without evidence") : "unparseable verdict"}: lane`);
|
|
499
500
|
const ev = v.evidence.map((x) => `- ${sanitizeMd(x).replace(/\s+/g, " ").slice(0, 400)}`).join("\n");
|
|
500
501
|
return await close("validated", `## Pre-filter: ${v.verdict}\n**Signal:** ${why}\n**Summary:** ${sanitizeMd(v.summary).replace(/\s+/g, " ").slice(0, 600) || "not reported"}\n\n**Evidence:**\n${ev}\n\nValidated by a single read-only check (${model}), without a lane. Reopen if this is wrong.`,
|
|
501
|
-
`${v.verdict.toLowerCase()} (${why})
|
|
502
|
+
`${v.verdict.toLowerCase()} (${why})`, v.verdict === "INVALID" ? "not planned" : "completed");
|
|
502
503
|
} catch (e) {
|
|
503
504
|
return { ...out, detail: `pre-filter error (${String(e?.message ?? e).slice(0, 120)}): lane` };
|
|
504
505
|
}
|