forgedock 1.54.1 → 1.55.1
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 +12 -0
- package/bin/engine/events.mjs +1 -0
- package/bin/engine/events.test.mjs +5 -1
- package/bin/engine/outcome-codes.mjs +3 -0
- package/bin/engine-cli.mjs +126 -34
- package/bin/forge-utils.mjs +37 -5
- package/bin/forgedock.mjs +54 -2
- package/bin/gc-schedule.mjs +83 -0
- package/bin/gc.mjs +66 -10
- package/bin/help-text.mjs +1 -1
- package/bin/hooks/pre-tool-use.mjs +1 -0
- package/bin/init-detect.mjs +73 -2
- package/bin/labels.json +5 -0
- package/bin/lean/admission.mjs +21 -1
- package/bin/lean/baselines.mjs +43 -0
- package/bin/lean/baselines.test.mjs +33 -0
- package/bin/lean/batch-health.mjs +43 -6
- package/bin/lean/batch-health.test.mjs +41 -1
- package/bin/lean/batch.mjs +41 -4
- package/bin/lean/batch.test.mjs +106 -3
- package/bin/lean/conformance.mjs +131 -12
- package/bin/lean/conformance.test.mjs +172 -3
- package/bin/lean/depcache.mjs +23 -2
- package/bin/lean/depcache.test.mjs +22 -0
- package/bin/lean/docsgate.mjs +137 -0
- package/bin/lean/docsgate.test.mjs +78 -0
- package/bin/lean/effects.mjs +31 -2
- package/bin/lean/enumerating.mjs +39 -13
- package/bin/lean/enumerating.test.mjs +20 -0
- package/bin/lean/execution.test.mjs +3 -3
- package/bin/lean/fastforward.mjs +93 -0
- package/bin/lean/fastforward.test.mjs +73 -0
- package/bin/lean/guardgate.mjs +38 -7
- package/bin/lean/guardgate.test.mjs +39 -0
- package/bin/lean/issuewatch-install.mjs +92 -0
- package/bin/lean/issuewatch-install.test.mjs +31 -0
- package/bin/lean/issuewatch-parity.mjs +33 -3
- package/bin/lean/issuewatch-parity.test.mjs +30 -5
- package/bin/lean/issuewatch-reconcile.mjs +123 -0
- package/bin/lean/issuewatch-reconcile.test.mjs +30 -0
- package/bin/lean/issuewatch-verify.mjs +51 -9
- package/bin/lean/issuewatch.mjs +153 -33
- package/bin/lean/issuewatch.test.mjs +243 -22
- package/bin/lean/lean.mjs +381 -75
- package/bin/lean/lean.test.mjs +437 -20
- package/bin/lean/light.mjs +11 -3
- package/bin/lean/light.test.mjs +27 -0
- package/bin/lean/lightlane.mjs +8 -3
- package/bin/lean/lightlane.test.mjs +20 -0
- package/bin/lean/mechfix.mjs +21 -2
- package/bin/lean/mechfix.test.mjs +28 -1
- package/bin/lean/orchestrate-children.test.mjs +10 -0
- package/bin/lean/orchestrate-owned.test.mjs +73 -0
- package/bin/lean/orchestrate.mjs +28 -4
- package/bin/lean/overlap.mjs +20 -0
- package/bin/lean/overlap.test.mjs +49 -0
- package/bin/lean/pagegate.mjs +152 -0
- package/bin/lean/pagegate.test.mjs +77 -0
- package/bin/lean/parked-relabel.mjs +32 -0
- package/bin/lean/parked-relabel.test.mjs +45 -0
- package/bin/lean/phaseledger.mjs +17 -2
- package/bin/lean/postdeploy-check.mjs +27 -0
- package/bin/lean/postdeploy-check.test.mjs +13 -1
- package/bin/lean/postrun.mjs +32 -0
- package/bin/lean/postrun.test.mjs +41 -0
- package/bin/lean/preflight.mjs +46 -0
- package/bin/lean/preflight.test.mjs +30 -1
- package/bin/lean/prompts.mjs +36 -6
- package/bin/lean/recovery.test.mjs +16 -0
- package/bin/lean/release-review.mjs +12 -1
- package/bin/lean/release-review.test.mjs +14 -0
- package/bin/lean/release.mjs +23 -2
- package/bin/lean/release.test.mjs +28 -1
- package/bin/lean/render.mjs +17 -6
- package/bin/lean/reproquality.mjs +116 -0
- package/bin/lean/reproquality.test.mjs +85 -0
- package/bin/lean/review-trigger.mjs +8 -3
- package/bin/lean/sandbox-budget.test.mjs +27 -0
- package/bin/lean/schedd.mjs +40 -11
- package/bin/lean/schedd.test.mjs +12 -1
- package/bin/lean/testadequacy.mjs +97 -0
- package/bin/lean/testadequacy.test.mjs +92 -0
- package/bin/lean/testsandbox.mjs +202 -0
- package/bin/lean/testsandbox.test.mjs +157 -0
- package/bin/lean/toolplace.mjs +5 -2
- package/bin/lean/toolplace.test.mjs +6 -0
- package/bin/lean/verify.mjs +6 -1
- package/bin/lean/verify.test.mjs +18 -2
- package/bin/lean/warmtree.mjs +77 -0
- package/bin/lean/warmtree.test.mjs +81 -0
- package/bin/review-staging.mjs +51 -9
- package/bin/stats/conformance-outcomes.mjs +12 -2
- package/bin/stats/depth.mjs +24 -1
- package/bin/stats/depth.test.mjs +21 -1
- package/bin/stats/index.mjs +5 -2
- package/bin/stats/query.mjs +2 -1
- package/commands/cleanup.md +18 -0
- package/commands/fd-introspect.md +19 -0
- package/commands/milestone.md +5 -1
- package/commands/pipeline-health/phase-2-metrics.md +4 -0
- package/commands/recover-orphans.md +31 -1
- package/commands/review-pr-staging.md +9 -0
- package/commands/review-pr.md +2 -0
- package/docs/CONFIG.md +26 -1
- package/docs/EVENTS.md +1 -0
- package/docs/ISSUE-WATCH.md +12 -3
- package/docs/eval/adversarial-bench.md +1 -1
- package/docs/eval/published/adversarial-2026-11-11.md +58 -0
- package/package.json +1 -1
- package/scripts/bench-lightlane.mjs +3 -2
- package/scripts/hotspots.sh +7 -4
- package/scripts/hotspots.test.sh +12 -0
- package/scripts/recover-orphans-stateless.test.sh +79 -0
- package/scripts/transition-label.sh +2 -0
- package/templates/workflows/forgedock-reopen-clean.yml +33 -0
|
@@ -5,8 +5,10 @@ import assert from "node:assert/strict";
|
|
|
5
5
|
import { mkdirSync, writeFileSync, existsSync, readFileSync } from "node:fs";
|
|
6
6
|
import { tmpDir } from "../tests/_tmp.mjs";
|
|
7
7
|
import { join } from "node:path";
|
|
8
|
-
import { unclaimedOrOwn, parseWatches, validateWatch, loadWatches, matchesSelectors, issueVersion, hasUnresolvedDefer, classifyIssue, laneFor, dagOrder, claimIssue, acquireLock, tick, runWatch, formatStatus, repoDir, watchDir, issueWatchFromCli, isOwnApp, selectorMiss, planClaims, ghFailureEffect, ghRunner } from "./issuewatch.mjs";
|
|
8
|
+
import { unclaimedOrOwn, parseWatches, validateWatch, loadWatches, matchesSelectors, issueVersion, hasUnresolvedDefer, classifyIssue, laneFor, dagOrder, claimIssue, acquireLock, tick, runWatch, formatStatus, repoDir, watchDir, issueWatchFromCli, isOwnApp, selectorMiss, planClaims, ghFailureEffect, ghRunner, isTransientGhError } from "./issuewatch.mjs";
|
|
9
9
|
import { openBatch } from "./batch.mjs";
|
|
10
|
+
import { stuckClaims, formatStuck } from "./issuewatch-reconcile.mjs";
|
|
11
|
+
const require_stuck = (s, now) => formatStuck(stuckClaims(s, now));
|
|
10
12
|
|
|
11
13
|
const tmp = () => tmpDir("iw-");
|
|
12
14
|
const iss = (n, o = {}) => ({ number: n, title: `t${n}`, body: "", labels: [], milestone: null, authorAssociation: "OWNER", author: { login: "me" }, createdAt: "2026-10-01T00:00:00Z", ...o });
|
|
@@ -20,7 +22,7 @@ const REVIEW_PASS = { author: { login: "rapiercraft-forgedock" }, authorAssociat
|
|
|
20
22
|
* issue has a merged `feat/issue-N-lean` PR into staging with a passing review and green CI unless `prs[n]` / `comments[n]` /
|
|
21
23
|
* `checks[sha]` / `compare` say otherwise.
|
|
22
24
|
*/
|
|
23
|
-
function fakeIo(env, issues, { closed = new Set(), exit = () => 0, bodies = {}, prs = {}, comments = {}, checks = {}, compare = "behind", failGh = () => false } = {}) {
|
|
25
|
+
function fakeIo(env, issues, { closed = new Set(), exit = () => 0, bodies = {}, prs = {}, comments = {}, checks = {}, compare = "behind", descendants = {}, failGh = () => false } = {}) {
|
|
24
26
|
const calls = [], launched = [], batchOps = [];
|
|
25
27
|
let clock = Date.parse("2026-10-30T00:00:00Z"), nb = 0;
|
|
26
28
|
const io = { env: { FORGEDOCK_WATCH_DIR: env }, calls, launched, batchOps, closed, bodies, prs, comments, checks, tickClock: (ms) => { clock += ms; }, now: () => clock, sleep: async () => {},
|
|
@@ -28,6 +30,8 @@ function fakeIo(env, issues, { closed = new Set(), exit = () => 0, bodies = {},
|
|
|
28
30
|
gh: async (a) => {
|
|
29
31
|
calls.push(a);
|
|
30
32
|
if (failGh(a)) throw new Error("gh transient");
|
|
33
|
+
const desc = a[0] === "api" && /\/compare\/([0-9a-f]+)\.\.\.staging/.exec(a[1]); // descendants of a commit, oldest first
|
|
34
|
+
if (desc) return (descendants[desc[1]] ?? []).join("\n");
|
|
31
35
|
if (a[0] === "api" && /\/compare\//.test(a[1])) return compare;
|
|
32
36
|
if (a[0] === "api" && /\/commits\/([0-9a-f]+)\/check-runs/.test(a.join(" "))) { const sha = /commits\/([0-9a-f]+)/.exec(a.join(" "))[1]; return (checks[sha] ?? []).map(([n, st, c], i) => `${i + 1}\t${n}\t${st}\t${c ?? ""}`).join("\n"); }
|
|
33
37
|
if (a[0] === "api" && /\/commits\/[0-9a-f]+\/status/.test(a[1])) return "";
|
|
@@ -43,7 +47,7 @@ function fakeIo(env, issues, { closed = new Set(), exit = () => 0, bodies = {},
|
|
|
43
47
|
return "";
|
|
44
48
|
},
|
|
45
49
|
launch: (n, lane) => { launched.push([n, lane]); return { poll: () => ({ code: exit(n) }) }; },
|
|
46
|
-
batch: { add: (id, nums) => batchOps.push(["add", id, nums]), start: async (nums, k, lane) => { batchOps.push(["start", nums, k, lane]); return `b${++nb}`; }, reported: (id) => io.reported?.has(id) ?? false } };
|
|
50
|
+
batch: { add: (id, nums) => batchOps.push(["add", id, nums]), start: async (nums, k, lane) => { batchOps.push(["start", nums, k, lane]); return `b${++nb}`; }, reported: (id) => io.reported?.has(id) ?? false, results: (id) => io.results?.[id] ?? null }, remediated: [], remediate: (n, lane, code) => { io.remediated.push([n, lane, code]); return { poll: () => (io.remediateExit === undefined ? null : { code: io.remediateExit }) }; } };
|
|
47
51
|
return io;
|
|
48
52
|
}
|
|
49
53
|
|
|
@@ -163,19 +167,74 @@ test("two named watches on one repo never double-claim", async () => {
|
|
|
163
167
|
assert.equal(claimIssue(repoDir("o/r", { FORGEDOCK_WATCH_DIR: dir }), 1, "c"), false);
|
|
164
168
|
});
|
|
165
169
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
170
|
+
const mkState = () => ({ claimed: [], inflight: [], merged: [], verified: [], failed: [], folded: [], retries: {}, lanes: {}, phase: "running" });
|
|
171
|
+
const slowStart = (io) => { io.batch.start = async () => { throw Object.assign(new Error("orchestrate did not create a batch within 60s"), { before: ["old"] }); }; };
|
|
172
|
+
|
|
173
|
+
test("#5425: max_inflight defaults to parallel in batch mode; an explicit value and other modes keep their own", () => {
|
|
174
|
+
assert.equal(validateWatch("w", { mode: "batch", parallel: "20" }).max_inflight, 20);
|
|
175
|
+
assert.equal(validateWatch("w", { mode: "batch" }).max_inflight, 4);
|
|
176
|
+
assert.equal(validateWatch("w", { mode: "batch", parallel: "20", max_inflight: "5" }).max_inflight, 5);
|
|
177
|
+
assert.equal(validateWatch("w", { parallel: "20" }).max_inflight, 4);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
test("#5425: a batch watch with parallel 6 claims six issues in one pass", async () => {
|
|
181
|
+
const io = fakeIo(tmp(), [1, 2, 3, 4, 5, 6, 7].map((n) => iss(n)));
|
|
182
|
+
const state = await tick({ watch: validateWatch("w", { mode: "batch", parallel: "6" }), repo: "o/r", io, state: mkState() });
|
|
183
|
+
assert.equal(state.claimed.length, 6);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
test("#5425: a throwing batch.start keeps the claims in a pending-start record; the pass does not throw", async () => {
|
|
187
|
+
const dir = tmp(), watch = validateWatch("w", { mode: "batch" }), io = fakeIo(dir, [iss(1), iss(2)]);
|
|
188
|
+
slowStart(io);
|
|
189
|
+
const state = await tick({ watch, repo: "o/r", io, state: mkState() });
|
|
190
|
+
assert.deepEqual(state.claimed.sort(), [1, 2]);
|
|
191
|
+
assert.deepEqual(state.pendingStart.issues, [1, 2]);
|
|
192
|
+
assert.deepEqual(state.pendingStart.before, ["old"]);
|
|
193
|
+
assert.match(formatStatus(state, watch, io.now()), /batch start pending for 2 claim/);
|
|
194
|
+
assert.equal(claimIssue(repoDir("o/r", { FORGEDOCK_WATCH_DIR: dir }), 1, "other"), false, "claims stay held");
|
|
195
|
+
// later pass: the batch appeared, so it is adopted and no second start happens
|
|
196
|
+
io.batch.find = (before) => (before.includes("old") ? "b9" : null);
|
|
197
|
+
await tick({ watch, repo: "o/r", io, state });
|
|
198
|
+
assert.equal(state.batch, "b9");
|
|
199
|
+
assert.equal(state.pendingStart, null);
|
|
200
|
+
assert.deepEqual(io.batchOps, []);
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
test("#5425: a pending start that never shows up releases its claims after the timeout", async () => {
|
|
204
|
+
const dir = tmp(), watch = validateWatch("w", { mode: "batch" }), io = fakeIo(dir, [iss(1)]);
|
|
205
|
+
slowStart(io);
|
|
206
|
+
const state = await tick({ watch, repo: "o/r", io, state: mkState() });
|
|
207
|
+
io.batch.find = () => null;
|
|
208
|
+
io.tickClock(5 * 60000);
|
|
209
|
+
await tick({ watch, repo: "o/r", io, state });
|
|
210
|
+
assert.ok(state.pendingStart, "still pending inside the window");
|
|
211
|
+
io.tickClock(6 * 60000);
|
|
212
|
+
io.batch.start = async (nums) => { io.batchOps.push(["start", nums]); return "b1"; };
|
|
213
|
+
await tick({ watch, repo: "o/r", io, state }); // releases, then re-claims and starts again
|
|
214
|
+
assert.equal(state.pendingStart, null);
|
|
215
|
+
assert.deepEqual(io.batchOps, [["start", [1]]]);
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
test("#5425: a running batch of the same repo and lane gets the claims by --add instead of a new start", async () => {
|
|
219
|
+
const io = fakeIo(tmp(), [iss(1)]);
|
|
220
|
+
io.batch.running = (lane) => (lane === "staging" ? "brun" : null);
|
|
221
|
+
const state = await tick({ watch: validateWatch("w", { mode: "batch" }), repo: "o/r", io, state: mkState() });
|
|
222
|
+
assert.equal(state.batch, "brun");
|
|
223
|
+
assert.deepEqual(io.batchOps, [["add", "brun", [1]]]);
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
test("#5425: runWatch survives a throwing pass, saves status.json with the error, and runs the next pass", async () => {
|
|
227
|
+
const dir = tmp(), watch = validateWatch("w", { until: "2026-10-30T00:10:00Z" }), io = fakeIo(dir, [iss(1)]);
|
|
228
|
+
let fail = true; const gh = io.gh;
|
|
229
|
+
io.gh = async (a) => { if (fail) throw new Error("gh boom"); return gh(a); };
|
|
230
|
+
const seen = [];
|
|
231
|
+
io.sleep = async () => { seen.push(JSON.parse(readFileSync(join(dir, "status.json"), "utf8")).passError); fail = false; io.tickClock(300000); };
|
|
232
|
+
const errs = console.error; console.error = () => {};
|
|
233
|
+
let state; try { state = await runWatch({ watch, repo: "o/r", io, dir, intervalMs: 300000 }); } finally { console.error = errs; }
|
|
234
|
+
assert.match(seen[0], /gh boom/);
|
|
235
|
+
assert.equal(state.passError, null);
|
|
236
|
+
assert.equal(state.phase, "done");
|
|
237
|
+
assert.match(formatStatus({ ...state, passError: "x boom" }, watch, io.now()), /last pass failed: x boom/);
|
|
179
238
|
});
|
|
180
239
|
|
|
181
240
|
test("max_issues stops claiming at N, drains, then finishes", async () => {
|
|
@@ -306,7 +365,7 @@ async function settleOne(opts = {}, { ticks = 1, gap = 0 } = {}) {
|
|
|
306
365
|
await tick({ watch, repo: "o/r", io, state, handles }); // claim + launch
|
|
307
366
|
for (let i = 0; i < ticks; i++) { await tick({ watch, repo: "o/r", io, state, handles }); io.tickClock(gap); }
|
|
308
367
|
const posted = io.calls.filter((a) => a[1] === "comment").map((a) => a[a.indexOf("--body") + 1]);
|
|
309
|
-
return { state, io, posted, reopened: io.calls.some((a) => a[1] === "reopen"), escalated: io.calls.some((a) => a[1] === "edit" && a.
|
|
368
|
+
return { state, io, posted, reopened: io.calls.some((a) => a[1] === "reopen"), escalated: io.calls.some((a) => a[1] === "edit" && a.some((x) => String(x).startsWith("needs-human"))) };
|
|
310
369
|
}
|
|
311
370
|
|
|
312
371
|
test("verify: a merged, reviewed, green lane PR is verified and the evidence is posted", async () => {
|
|
@@ -317,10 +376,18 @@ test("verify: a merged, reviewed, green lane PR is verified and the evidence is
|
|
|
317
376
|
assert.match(r.posted[0], /FORGE:WATCH_VERIFY[\s\S]*merge verified[\s\S]*PR #1001[\s\S]*CI green on the merge commit \(1 check/); // forgedock/verify is report-only
|
|
318
377
|
});
|
|
319
378
|
|
|
320
|
-
test("verify: a shadow `would BLOCK` review merged anyway is
|
|
379
|
+
test("verify: a shadow `would BLOCK` review merged anyway is advisory: verified, not reopened, no needs-human", async () => {
|
|
321
380
|
const block = { ...REVIEW_PASS, body: "<!-- FORGE:REVIEW -->\n**Gate verdict:** would BLOCK (nonconforming)." };
|
|
322
381
|
const r = await settleOne({ comments: { 1: [REVIEW_PASS, block] } });
|
|
323
|
-
assert.deepEqual(r.state.verified, []);
|
|
382
|
+
assert.deepEqual(r.state.verified, [1]);
|
|
383
|
+
assert.deepEqual(r.state.unverified ?? [], []);
|
|
384
|
+
assert.equal(r.reopened || r.escalated, false);
|
|
385
|
+
assert.match(r.posted[0], /merge verified[\s\S]*shadow `would BLOCK` \(advisory/);
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
test("verify: an enforced NONCONFORMING review is still NOT verified: reopened, needs-human, evidence", async () => {
|
|
389
|
+
const bad = { ...REVIEW_PASS, body: "<!-- FORGE:REVIEW -->\n**Verdict:** NONCONFORMING" };
|
|
390
|
+
const r = await settleOne({ comments: { 1: [REVIEW_PASS, bad] } });
|
|
324
391
|
assert.deepEqual(r.state.unverified, [1]);
|
|
325
392
|
assert.ok(r.reopened && r.escalated);
|
|
326
393
|
assert.match(r.posted[0], /merge NOT verified[\s\S]*FAIL: the latest FORGE:REVIEW did not pass/);
|
|
@@ -357,6 +424,31 @@ test("verify: review-degraded, wrong base, missing required check, merge commit
|
|
|
357
424
|
assert.match(io.calls.filter((a) => a[1] === "comment").at(-1).at(-1), /required check\(s\) not green on the merged head aa1: build=missing/);
|
|
358
425
|
});
|
|
359
426
|
|
|
427
|
+
test("verify: a cancelled merge-commit check resolved by a later descendant success is verified", async () => {
|
|
428
|
+
const r = await settleOne({ checks: { bb1: [["Regenerate", "completed", "cancelled"], ["test", "completed", "success"]], dd1: [["Regenerate", "completed", "cancelled"]], dd2: [["Regenerate", "completed", "success"]] }, descendants: { bb1: ["dd1", "dd2"] } });
|
|
429
|
+
assert.deepEqual(r.state.verified, [1]);
|
|
430
|
+
assert.match(r.posted[0], /Regenerate superseded by a success run on dd2/);
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
test("verify: a cancelled merge-commit check whose newest descendant run failed is red; none finished is pending", async () => {
|
|
434
|
+
const red = await settleOne({ checks: { bb1: [["Regenerate", "completed", "cancelled"]], dd1: [["Regenerate", "completed", "success"]], dd2: [["Regenerate", "completed", "failure"]] }, descendants: { bb1: ["dd1", "dd2"] } });
|
|
435
|
+
assert.deepEqual(red.state.unverified, [1]);
|
|
436
|
+
assert.match(red.posted[0], /superseded by a failing run: Regenerate=failure on dd2/);
|
|
437
|
+
const none = await settleOne({ checks: { bb1: [["Regenerate", "completed", "stale"]] } });
|
|
438
|
+
assert.deepEqual(none.state.pendingVerify, [1]);
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
test("verify: a required check cancelled on the head resolves against a later run like a post-merge one", async () => {
|
|
442
|
+
const dir = tmp();
|
|
443
|
+
const io = fakeIo(dir, [iss(1)], { exit: (n) => (io.closed.add(n), 0), checks: { aa1: [["build", "completed", "cancelled"]], bb1: [["build", "completed", "success"]], dd1: [["build", "completed", "success"]] }, descendants: { bb1: ["dd1"] } });
|
|
444
|
+
io.requiredChecks = async () => ["build"];
|
|
445
|
+
const state = { claimed: [], inflight: [], merged: [], verified: [], failed: [], folded: [], retries: {}, lanes: {}, phase: "running" };
|
|
446
|
+
const handles = new Map();
|
|
447
|
+
await tick({ watch: W(), repo: "o/r", io, state, handles });
|
|
448
|
+
await tick({ watch: W(), repo: "o/r", io, state, handles });
|
|
449
|
+
assert.deepEqual(state.verified, [1]);
|
|
450
|
+
});
|
|
451
|
+
|
|
360
452
|
test("verify: pending merge-commit CI waits, holds the drain, then fails after 60 minutes", async () => {
|
|
361
453
|
const r = await settleOne({ checks: { bb1: [["test", "in_progress"]] } }, { ticks: 2, gap: 30 * 60000 });
|
|
362
454
|
assert.deepEqual(r.state.pendingVerify, [1]);
|
|
@@ -379,9 +471,38 @@ test("verify: an issue closed with no merged lane PR is closed-unmerged, never v
|
|
|
379
471
|
assert.equal(r.posted.length, 0);
|
|
380
472
|
});
|
|
381
473
|
|
|
382
|
-
|
|
474
|
+
test("verify: failed verify swaps workflow:merged for workflow:merged-unverified", async () => {
|
|
475
|
+
const block = { ...REVIEW_PASS, body: "<!-- FORGE:REVIEW -->\n**Verdict:** NONCONFORMING" };
|
|
476
|
+
const r = await settleOne({ comments: { 1: [REVIEW_PASS, block] } });
|
|
477
|
+
const at = (f) => r.io.calls.findIndex(f);
|
|
478
|
+
const human = at((a) => a[1] === "edit" && a[a.indexOf("--add-label") + 1] === "needs-human");
|
|
479
|
+
const create = at((a) => a[0] === "label" && a[1] === "create" && a[2] === "workflow:merged-unverified" && a.includes("--force"));
|
|
480
|
+
const swap = at((a) => a[1] === "edit" && a[a.indexOf("--add-label") + 1] === "workflow:merged-unverified");
|
|
481
|
+
assert.ok(human >= 0 && create > human && swap > create, "needs-human edit, then label create, then swap edit");
|
|
482
|
+
assert.equal(r.io.calls[swap][r.io.calls[swap].indexOf("--remove-label") + 1], "workflow:merged");
|
|
483
|
+
assert.ok(at((a) => a[1] === "reopen") > swap);
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
test("verify: a missing workflow:merged-unverified label still reopens and flags needs-human (#5484)", async () => {
|
|
487
|
+
const block = { ...REVIEW_PASS, body: "<!-- FORGE:REVIEW -->\n**Verdict:** NONCONFORMING" };
|
|
488
|
+
const dir = tmp();
|
|
489
|
+
const missing = (a) => (a[1] === "edit" && a.some((x) => String(x).includes("workflow:merged-unverified"))) || (a[0] === "label" && a[1] === "create");
|
|
490
|
+
const io = fakeIo(dir, [iss(1)], { exit: (n) => (io.closed.add(n), 0), comments: { 1: [block] }, failGh: missing });
|
|
491
|
+
const state = { claimed: [], inflight: [], merged: [], verified: [], failed: [], folded: [], retries: {}, lanes: {}, phase: "running" };
|
|
492
|
+
const handles = new Map(), watch = W({ max_issues: "1" });
|
|
493
|
+
await tick({ watch, repo: "o/r", io, state, handles });
|
|
494
|
+
await tick({ watch, repo: "o/r", io, state, handles }); // on base this rejects: the combined edit names the missing label
|
|
495
|
+
const n = (f) => io.calls.filter(f).length;
|
|
496
|
+
assert.equal(n((a) => a[1] === "edit" && a[a.indexOf("--add-label") + 1] === "needs-human"), 1);
|
|
497
|
+
assert.equal(n((a) => a[1] === "reopen"), 1);
|
|
498
|
+
assert.deepEqual(state.unverified, [1]);
|
|
499
|
+
assert.deepEqual(state.pendingVerify, []);
|
|
500
|
+
assert.deepEqual(state.escalation ?? {}, {});
|
|
501
|
+
});
|
|
502
|
+
|
|
503
|
+
for (const [what, bad] of [["label", (a) => a[1] === "edit" && a.some((x) => String(x).startsWith("needs-human"))], ["comment", (a) => a[1] === "comment"]]) {
|
|
383
504
|
test(`verify: a failed ${what} call leaves the issue closed and the next tick completes the escalation`, async () => {
|
|
384
|
-
const block = { ...REVIEW_PASS, body: "<!-- FORGE:REVIEW -->\n**
|
|
505
|
+
const block = { ...REVIEW_PASS, body: "<!-- FORGE:REVIEW -->\n**Verdict:** NONCONFORMING" };
|
|
385
506
|
let failing = true;
|
|
386
507
|
const dir = tmp();
|
|
387
508
|
const io = fakeIo(dir, [iss(1)], { exit: (n) => (io.closed.add(n), 0), comments: { 1: [block] }, failGh: (a) => failing && bad(a) });
|
|
@@ -396,7 +517,7 @@ for (const [what, bad] of [["label", (a) => a[1] === "edit" && a.includes("needs
|
|
|
396
517
|
await tick({ watch, repo: "o/r", io, state, handles });
|
|
397
518
|
const n = (f) => io.calls.filter(f).length;
|
|
398
519
|
assert.equal(n((a) => a[1] === "comment"), what === "comment" ? 2 : 1); // the failed attempt is recorded too
|
|
399
|
-
assert.equal(n((a) => a[1] === "edit" && a.
|
|
520
|
+
assert.equal(n((a) => a[1] === "edit" && a.some((x) => String(x).startsWith("needs-human"))), what === "label" ? 2 : 1);
|
|
400
521
|
assert.equal(n((a) => a[1] === "reopen"), 1);
|
|
401
522
|
assert.deepEqual(state.unverified, [1]);
|
|
402
523
|
assert.deepEqual(state.pendingVerify, []);
|
|
@@ -542,3 +663,103 @@ test("#5088 ghRunner names the failing call; 401/403 also warn with the effect o
|
|
|
542
663
|
assert.equal(seen.cmd, "gh");
|
|
543
664
|
assert.deepEqual(seen.opts.stdio, ["ignore", "pipe", "pipe"]);
|
|
544
665
|
});
|
|
666
|
+
|
|
667
|
+
test("#5469 planClaims: an open closing PR from a foreign branch is adopted; the pipeline's own PR is still skipped", async () => {
|
|
668
|
+
const io = fakeIo(tmp(), [iss(3), iss(4)]);
|
|
669
|
+
io.openPrs = [{ number: 50, headRefName: "hand/fix-3", closingIssuesReferences: [{ number: 3 }] }, { number: 51, headRefName: "feat/issue-4-lean", closingIssuesReferences: [{ number: 4 }] }];
|
|
670
|
+
const p = await planClaims({ watch: W(), repo: "o/r", io, state: { claimed: [], inflight: [] }, room: 5 });
|
|
671
|
+
assert.deepEqual(p.claim.map((c) => [c.number, c.adopt === true]), [[3, true]]);
|
|
672
|
+
assert.deepEqual(p.skip, [{ number: 4, reason: "open closing PR #51" }]);
|
|
673
|
+
assert.deepEqual([...p.adopt], [3]);
|
|
674
|
+
});
|
|
675
|
+
|
|
676
|
+
test("#5469 tick: an adopted issue is launched with the adopt option", async () => {
|
|
677
|
+
const io = fakeIo(tmp(), [iss(3)]);
|
|
678
|
+
io.openPrs = [{ number: 50, headRefName: "hand/fix-3", closingIssuesReferences: [{ number: 3 }] }];
|
|
679
|
+
const opts = [];
|
|
680
|
+
io.launch = (n, lane, o) => { opts.push([n, o]); return { poll: () => null }; };
|
|
681
|
+
const state = { claimed: [], inflight: [], lanes: {}, retries: {}, phase: "running" };
|
|
682
|
+
await tick({ watch: W({ max_inflight: 2 }), repo: "o/r", io, state, dir: io.env.FORGEDOCK_WATCH_DIR, handles: new Map() });
|
|
683
|
+
assert.deepEqual(opts, [[3, { adopt: true }]]);
|
|
684
|
+
});
|
|
685
|
+
|
|
686
|
+
const TLS = Object.assign(new Error("gh failed"), { status: 1, stderr: 'Post "https://api.github.com/graphql": net/http: TLS handshake timeout\n' });
|
|
687
|
+
|
|
688
|
+
test("#5465 fault injection: ghRunner retries a transient TLS timeout with backoff, never a 4xx", () => {
|
|
689
|
+
const naps = []; let calls = 0;
|
|
690
|
+
const gh = ghRunner(() => { if (calls++ < 2) throw TLS; return "ok"; }, () => {}, { sleep: (ms) => naps.push(ms), delayMs: 10 });
|
|
691
|
+
assert.equal(gh(["issue", "view", "1"]), "ok");
|
|
692
|
+
assert.deepEqual(naps, [10, 20]);
|
|
693
|
+
let n = 0;
|
|
694
|
+
const hard = ghRunner(() => { n++; throw Object.assign(new Error("x"), { stderr: "gh: Not Found (HTTP 404)" }); }, () => {}, { sleep: () => {} });
|
|
695
|
+
assert.throws(() => hard(["issue", "view", "1"]), /failed: gh: Not Found/);
|
|
696
|
+
assert.equal(n, 1);
|
|
697
|
+
let m = 0;
|
|
698
|
+
assert.throws(() => ghRunner(() => { m++; throw TLS; }, () => {}, { sleep: () => {}, retries: 2 })(["api", "x"]), /TLS handshake timeout/);
|
|
699
|
+
assert.equal(m, 3);
|
|
700
|
+
for (const t of ["HTTP 502", "HTTP 429", "read: ECONNRESET", "You have exceeded a secondary rate limit"]) assert.ok(isTransientGhError(t), t);
|
|
701
|
+
assert.ok(!isTransientGhError("HTTP 403: Resource not accessible"));
|
|
702
|
+
});
|
|
703
|
+
|
|
704
|
+
test("#5465 fault injection: a TLS timeout on one gh call keeps the watch up and the next tick claims", async () => {
|
|
705
|
+
const dir = tmp(), watch = validateWatch("w", { until: "2026-10-30T00:10:00Z" }), io = fakeIo(dir, [iss(1)]);
|
|
706
|
+
let fail = true; const gh = io.gh;
|
|
707
|
+
io.gh = async (a) => { if (fail) { fail = false; throw TLS; } return gh(a); };
|
|
708
|
+
io.sleep = async () => { io.tickClock(300000); };
|
|
709
|
+
const errs = console.error; console.error = () => {};
|
|
710
|
+
let state; try { state = await runWatch({ watch, repo: "o/r", io, dir, intervalMs: 300000 }); } finally { console.error = errs; }
|
|
711
|
+
assert.deepEqual(state.claimed, [1]);
|
|
712
|
+
assert.notEqual(state.phase, "exited");
|
|
713
|
+
});
|
|
714
|
+
|
|
715
|
+
test("#5465 a crash or a single pass leaves phase exited with the reason, never running", async () => {
|
|
716
|
+
const dir = tmp(), io = fakeIo(dir, []);
|
|
717
|
+
io.sleep = async () => { throw new Error("disk gone"); };
|
|
718
|
+
const errs = console.error; console.error = () => {};
|
|
719
|
+
try { await assert.rejects(runWatch({ watch: W({}), repo: "o/r", io, dir, intervalMs: 1 }), /disk gone/); } finally { console.error = errs; }
|
|
720
|
+
const s = JSON.parse(readFileSync(join(dir, "status.json"), "utf8"));
|
|
721
|
+
assert.equal(s.phase, "exited"); assert.match(s.exitReason, /crashed: disk gone/);
|
|
722
|
+
const text = formatStatus(s, W({}), io.now());
|
|
723
|
+
assert.match(text, /\[exited,/); assert.match(text, /state: exited \(crashed: disk gone\)/);
|
|
724
|
+
});
|
|
725
|
+
|
|
726
|
+
const batchState = (o = {}) => ({ claimed: [1, 2, 3, 4], inflight: [1, 2, 3, 4], merged: [], verified: [], failed: [], folded: [], retries: {}, lanes: { 1: "staging", 2: "staging", 3: "staging", 4: "staging" }, phase: "running", batch: "b1", ...o });
|
|
727
|
+
const parkedRow = (code) => ({ outcome: "needs-human", code });
|
|
728
|
+
|
|
729
|
+
test("inflight drops issues whose batch result is final and parked lanes get remediation", async () => {
|
|
730
|
+
const io = fakeIo(tmp(), []);
|
|
731
|
+
io.results = { b1: { 1: parkedRow("conformance.e2e_unverified"), 2: parkedRow("conformance.unimplemented"), 3: parkedRow("maintenance.hotspot_growth"), 4: { outcome: "needs-human" } } };
|
|
732
|
+
const state = batchState();
|
|
733
|
+
await tick({ watch: W({ mode: "batch" }), repo: "o/r", io, state });
|
|
734
|
+
assert.deepEqual(state.inflight, []); // the batch has not reported, yet every result is final
|
|
735
|
+
assert.deepEqual(io.remediated.map((r) => r[0]), [1, 2, 3]);
|
|
736
|
+
assert.deepEqual(io.remediated[0], [1, "staging", "conformance.e2e_unverified"]);
|
|
737
|
+
assert.equal(state.outcomes[4].kind, "needs-human"); // no terminal code: not a mechanical park
|
|
738
|
+
const t = formatStatus(state, W({ mode: "batch" }), io.now());
|
|
739
|
+
assert.match(t, /parked 3/); assert.match(t, /needs-human 1/);
|
|
740
|
+
});
|
|
741
|
+
|
|
742
|
+
test("a failed remediation lane makes the parked issue needs-human with the reason; budget caps lanes", async () => {
|
|
743
|
+
const io = fakeIo(tmp(), []);
|
|
744
|
+
io.results = { b1: { 1: parkedRow("ci.red"), 2: parkedRow("ci.red") } };
|
|
745
|
+
io.remediateExit = 1;
|
|
746
|
+
const state = batchState({ claimed: [1, 2], inflight: [1, 2] });
|
|
747
|
+
await tick({ watch: W({ mode: "batch", max_remediations: "1" }), repo: "o/r", io, state });
|
|
748
|
+
assert.equal(io.remediated.length, 1);
|
|
749
|
+
assert.equal(state.outcomes[1].kind, "needs-human");
|
|
750
|
+
assert.match(state.outcomes[1].reason, /exited 1/);
|
|
751
|
+
assert.ok(io.calls.some((a) => a[1] === "edit" && a.includes("needs-human")));
|
|
752
|
+
});
|
|
753
|
+
|
|
754
|
+
test("a needs-human issue a person cleared with a new comment is re-claimed; stuck lists old claims", async () => {
|
|
755
|
+
const io = fakeIo(tmp(), []);
|
|
756
|
+
io.results = { b1: { 1: { outcome: "needs-human" } } };
|
|
757
|
+
const state = batchState({ claimed: [1], inflight: [1], started: io.now() - 30 * 3600_000 });
|
|
758
|
+
const w = W({ mode: "batch" });
|
|
759
|
+
await tick({ watch: w, repo: "o/r", io, state });
|
|
760
|
+
assert.match(require_stuck(state, io.now()), /#1 claimed 30h ago.*needs-human/);
|
|
761
|
+
const at = state.outcomes[1].at;
|
|
762
|
+
io.gh = ((orig) => async (a) => (a[1] === "view" && a.includes("state,labels,comments") ? JSON.stringify({ state: "OPEN", labels: [], comments: [{ authorAssociation: "OWNER", body: "fixed the cause", createdAt: new Date(at + 1000).toISOString() }] }) : orig(a)))(io.gh);
|
|
763
|
+
await tick({ watch: w, repo: "o/r", io, state });
|
|
764
|
+
assert.ok(!state.outcomes?.[1]); // released, then re-selected is up to planClaims
|
|
765
|
+
});
|