forgedock 1.66.0 → 1.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/config-schema.mjs +3 -0
- package/bin/engine/outcome-codes.mjs +2 -0
- package/bin/engine-cli.mjs +193 -27
- package/bin/engine.mjs +10 -0
- package/bin/forgedock.mjs +24 -1
- package/bin/help-text.mjs +4 -3
- package/bin/introspect-schedule.mjs +98 -0
- package/bin/introspect-schedule.test.mjs +67 -0
- package/bin/lean/admission.mjs +21 -0
- package/bin/lean/admission.test.mjs +30 -0
- package/bin/lean/advisory.test.mjs +64 -0
- package/bin/lean/amendment-schema.mjs +30 -0
- package/bin/lean/attempts.mjs +162 -0
- package/bin/lean/attempts.test.mjs +141 -0
- package/bin/lean/basered.mjs +81 -0
- package/bin/lean/basered.test.mjs +68 -1
- package/bin/lean/batch-health.mjs +20 -12
- package/bin/lean/batch-health.test.mjs +55 -11
- package/bin/lean/batch.mjs +45 -0
- package/bin/lean/batch.test.mjs +105 -5
- package/bin/lean/capwait.mjs +14 -3
- package/bin/lean/capwait.test.mjs +20 -0
- package/bin/lean/ci-gate.mjs +2 -90
- package/bin/lean/ci-gate.test.mjs +1 -127
- package/bin/lean/ci-precheck.mjs +25 -8
- package/bin/lean/ci-precheck.test.mjs +24 -0
- package/bin/lean/clear-breaker.mjs +14 -0
- package/bin/lean/clear-breaker.test.mjs +4 -3
- package/bin/lean/commentstate.mjs +46 -0
- package/bin/lean/commentstate.test.mjs +43 -0
- package/bin/lean/concurrency.mjs +89 -0
- package/bin/lean/concurrency.test.mjs +113 -0
- package/bin/lean/conformance.e2e.test.mjs +13 -8
- package/bin/lean/conformance.mjs +73 -181
- package/bin/lean/conformance.test.mjs +61 -345
- package/bin/lean/depcache.mjs +100 -10
- package/bin/lean/depcache.test.mjs +105 -0
- package/bin/lean/docsgate.mjs +0 -32
- package/bin/lean/docsgate.test.mjs +2 -23
- package/bin/lean/effects-cap.test.mjs +9 -1
- package/bin/lean/effects-killtree.test.mjs +35 -0
- package/bin/lean/effects.mjs +42 -24
- package/bin/lean/efficiency.mjs +162 -0
- package/bin/lean/efficiency.test.mjs +79 -0
- package/bin/lean/engine-readmit.test.mjs +35 -0
- package/bin/lean/envgap.mjs +93 -0
- package/bin/lean/envgap.test.mjs +53 -0
- package/bin/lean/execution.mjs +41 -17
- package/bin/lean/execution.test.mjs +58 -0
- package/bin/lean/failure-census.mjs +170 -0
- package/bin/lean/failure-census.test.mjs +59 -0
- package/bin/lean/failure-stop.mjs +46 -0
- package/bin/lean/failure-stop.test.mjs +45 -0
- package/bin/lean/fixtures/capacity-storm.json +609 -0
- package/bin/lean/guardgate.test.mjs +2 -3
- package/bin/lean/heavy.mjs +33 -4
- package/bin/lean/heavy.test.mjs +38 -6
- package/bin/lean/hotarea.mjs +0 -36
- package/bin/lean/hotarea.test.mjs +1 -22
- package/bin/lean/issuewatch-verify.mjs +19 -4
- package/bin/lean/issuewatch.mjs +21 -4
- package/bin/lean/issuewatch.test.mjs +48 -1
- package/bin/lean/lane-audit-gap.mjs +66 -0
- package/bin/lean/lane-audit-gap.test.mjs +59 -0
- package/bin/lean/lane-audit-llm.mjs +5 -0
- package/bin/lean/lane-audit-query.mjs +47 -0
- package/bin/lean/lane-audit-query.test.mjs +44 -0
- package/bin/lean/lane-audit-signatures.mjs +33 -0
- package/bin/lean/lane-audit.mjs +110 -0
- package/bin/lean/lane-audit.test.mjs +97 -0
- package/bin/lean/lane-recovery.test.mjs +33 -0
- package/bin/lean/lanecheck.mjs +5 -3
- package/bin/lean/lanecheck.test.mjs +6 -0
- package/bin/lean/lean.mjs +311 -154
- package/bin/lean/lean.test.mjs +530 -223
- package/bin/lean/limits.mjs +17 -0
- package/bin/lean/limits.test.mjs +15 -1
- package/bin/lean/live-execution.mjs +21 -2
- package/bin/lean/live-execution.test.mjs +39 -0
- package/bin/lean/liveness.mjs +37 -0
- package/bin/lean/liveness.test.mjs +33 -0
- package/bin/lean/orchestrate-attempts.test.mjs +82 -0
- package/bin/lean/orchestrate-envhold.test.mjs +47 -0
- package/bin/lean/orchestrate-heldroot.test.mjs +72 -0
- package/bin/lean/orchestrate-hostfallback.test.mjs +59 -1
- package/bin/lean/orchestrate-overload-recovery.test.mjs +37 -0
- package/bin/lean/orchestrate-pause.test.mjs +76 -1
- package/bin/lean/orchestrate-reconcile.test.mjs +164 -0
- package/bin/lean/orchestrate-relaunch-gates.test.mjs +57 -0
- package/bin/lean/orchestrate-stacking.test.mjs +10 -0
- package/bin/lean/orchestrate.mjs +344 -45
- package/bin/lean/phaseledger.mjs +6 -0
- package/bin/lean/phaseledger.test.mjs +13 -1
- package/bin/lean/postdeploy-check.test.mjs +1 -3
- package/bin/lean/precheck.mjs +20 -0
- package/bin/lean/preflight.mjs +100 -11
- package/bin/lean/preflight.test.mjs +44 -4
- package/bin/lean/prompts.mjs +13 -28
- package/bin/lean/reconcile.mjs +90 -0
- package/bin/lean/recurrence.mjs +6 -112
- package/bin/lean/recurrence.test.mjs +11 -92
- package/bin/lean/release-flakes.mjs +14 -2
- package/bin/lean/release-flakes.test.mjs +17 -1
- package/bin/lean/release-ledger.mjs +19 -1
- package/bin/lean/release-ledger.test.mjs +23 -0
- package/bin/lean/release-preflight.mjs +28 -0
- package/bin/lean/release-preflight.test.mjs +42 -1
- package/bin/lean/release-review.mjs +40 -5
- package/bin/lean/release-review.test.mjs +43 -2
- package/bin/lean/release.mjs +43 -14
- package/bin/lean/release.test.mjs +32 -0
- package/bin/lean/retry.mjs +1 -1
- package/bin/lean/retry.test.mjs +6 -1
- package/bin/lean/rotator.mjs +9 -0
- package/bin/lean/rotator.test.mjs +11 -1
- package/bin/lean/sandbox-remote.mjs +49 -11
- package/bin/lean/sched.mjs +19 -0
- package/bin/lean/sched.test.mjs +11 -1
- package/bin/lean/schedd-health.mjs +4 -4
- package/bin/lean/schedd-health.test.mjs +8 -4
- package/bin/lean/schedd.mjs +45 -8
- package/bin/lean/schedd.test.mjs +120 -7
- package/bin/lean/selfreview.mjs +1 -1
- package/bin/lean/slo.mjs +126 -0
- package/bin/lean/slo.test.mjs +112 -0
- package/bin/lean/statuscomment.mjs +40 -0
- package/bin/lean/statuscomment.test.mjs +48 -1
- package/bin/lean/validate-catalog.mjs +108 -0
- package/bin/lean/validate-catalog.test.mjs +46 -1
- package/bin/lean/verify.mjs +3 -2
- package/bin/pool/affinity.test.mjs +91 -0
- package/bin/pool/agent.mjs +144 -10
- package/bin/pool/cache-sweep.mjs +31 -10
- package/bin/pool/ci-autoscale.mjs +160 -0
- package/bin/pool/cli.mjs +53 -9
- package/bin/pool/docker.mjs +3 -0
- package/bin/pool/engine-placement.test.mjs +94 -0
- package/bin/pool/lane-target.mjs +41 -0
- package/bin/pool/lane-tools.mjs +26 -0
- package/bin/pool/lane-tools.test.mjs +9 -0
- package/bin/pool/mirror-seed.mjs +15 -11
- package/bin/pool/router.mjs +88 -32
- package/bin/pool/version.mjs +29 -2
- package/bin/review-staging.mjs +11 -3
- package/bin/runner.mjs +59 -11
- package/bin/stats/attempts.mjs +54 -0
- package/bin/stats/attempts.test.mjs +30 -0
- package/bin/stats/churn.mjs +49 -0
- package/bin/stats/churn.test.mjs +31 -0
- package/bin/stats/index.mjs +11 -3
- package/bin/stats/release.mjs +7 -0
- package/bin/stats/release.test.mjs +20 -0
- package/bin/stats/scorecard.mjs +187 -0
- package/bin/stats/scorecard.test.mjs +89 -0
- package/commands/orchestrate.md +21 -18
- package/docs/CONFIG.md +41 -0
- package/docs/OUTCOME-CODES.md +2 -0
- package/docs/STATS.md +17 -0
- package/package.json +1 -1
- package/pool/image/Dockerfile +14 -2
- package/pool/image/manifest.json +25 -0
- package/pool/image/mirror.sh +11 -2
- package/pool/install/install-agent.ps1 +11 -4
- package/scripts/check-devdocs-freshness.sh +1 -1
- package/scripts/ci-local/adapters/github-actions.mjs +8 -0
- package/scripts/ci-local/cli.mjs +1 -1
- package/scripts/ci-local/plan.mjs +3 -2
- package/scripts/ci-local.test.sh +11 -0
- package/scripts/failure-census.mjs +67 -0
- package/scripts/review-finalize.sh +5 -5
- package/scripts/review-finalize.test.sh +8 -1
- package/scripts/verify-phase-trail.sh +11 -0
- package/scripts/verify-phase-trail.test.sh +9 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
|
+
// #5978: standing orders: selector join/leave, re-admission policy, env.* join, breaker auto-reset, staging-lane close, coverage.
|
|
4
|
+
import { describe, it } from "node:test";
|
|
5
|
+
import assert from "node:assert/strict";
|
|
6
|
+
import { orchestrate } from "./orchestrate.mjs";
|
|
7
|
+
import { readmitDue, backoffMs, humanCode, environmentalDetail, closesManually, needsDecisionDigest, diffSelection, parseSelected, selectArgs, DEFER_CAP_MS, HELD_COOLDOWN_MS } from "./reconcile.mjs";
|
|
8
|
+
import { decideAutoReset } from "./clear-breaker.mjs";
|
|
9
|
+
import { coverage } from "./batch.mjs";
|
|
10
|
+
|
|
11
|
+
const harness = ({ script = {}, issues = [], reconcile, extra = {} }) => {
|
|
12
|
+
let t = 1_000_000;
|
|
13
|
+
const calls = [], decisions = [], updates = [];
|
|
14
|
+
return orchestrate({ issues, parallel: 2, readBody: async () => "", now: () => t, pollMs: 1000, reconcile, select: reconcile ? "no:milestone" : null,
|
|
15
|
+
sleep: async (ms) => { t += Math.max(1, Number(ms) || 0); },
|
|
16
|
+
runOne: async (n) => { calls.push(n); t += 1000; const l = script[n] ?? [{ terminalReason: "merged", pr: 1 }]; return l[Math.min(calls.filter((c) => c === n).length - 1, l.length - 1)]; },
|
|
17
|
+
decide: (d) => decisions.push(d), onUpdate: (r) => updates.push(r), ...extra }).then((rows) => ({ rows, calls, decisions, updates }));
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const seeded = (results, more = {}) => ({ load: () => ({ v: 1, order: Object.keys(results).map(Number), pending: [], results, ...more }), save: () => {}, log: () => {} });
|
|
21
|
+
|
|
22
|
+
describe("selector reconcile (R2, R13)", () => {
|
|
23
|
+
it("a new matching issue joins within one interval, no operator command; a standing order ends only by stop", async () => {
|
|
24
|
+
let polls = 0;
|
|
25
|
+
const ac = new AbortController();
|
|
26
|
+
const list = async () => { polls++; if (polls >= 4) ac.abort(); return polls === 1 ? [{ number: 1 }] : [{ number: 1 }, { number: 2 }]; };
|
|
27
|
+
const r = await harness({ issues: [], reconcile: { everyMs: 5000, list }, extra: { signal: ac.signal } });
|
|
28
|
+
assert.deepEqual(r.calls.sort(), [1, 2]);
|
|
29
|
+
assert.ok(r.rows.every((x) => x.outcome === "merged"));
|
|
30
|
+
});
|
|
31
|
+
it("diffSelection joins matches and leaves closed pending issues, never running ones", () => {
|
|
32
|
+
const d = diffSelection({ open: [{ number: 5 }, { number: 6 }], members: [5, 7, 8], pending: [7], running: new Set([8]), results: new Map() });
|
|
33
|
+
assert.deepEqual(d, { join: [6], leave: [7] });
|
|
34
|
+
});
|
|
35
|
+
it("#6022 only a member the selector matched can leave: env.* issues, children, --add and argv members stay pending", () => {
|
|
36
|
+
const d = diffSelection({ open: [{ number: 5 }], members: [5, 7, 9], pending: [7, 9], running: new Set(), results: new Map(), matched: new Set([5, 7]) });
|
|
37
|
+
assert.deepEqual(d, { join: [], leave: [7] });
|
|
38
|
+
});
|
|
39
|
+
it("#6029 a selector-matched member closed during a resume's downtime leaves; unmatched pending members still run", async () => {
|
|
40
|
+
const saves = [];
|
|
41
|
+
const store = { load: () => ({ v: 1, order: [7, 9], pending: [7, 9], results: {}, selMatched: [7] }), save: (s) => saves.push(s), log: () => {} };
|
|
42
|
+
const ac = new AbortController();
|
|
43
|
+
let polls = 0;
|
|
44
|
+
const r = await harness({ issues: [], reconcile: { everyMs: 5000, list: async () => { if (++polls >= 3) ac.abort(); return [{ number: 9 }]; } }, extra: { store, signal: ac.signal } });
|
|
45
|
+
assert.deepEqual(r.calls, [9]);
|
|
46
|
+
assert.ok(r.rows.find((x) => x.issue === 7)?.outcome !== "merged");
|
|
47
|
+
assert.ok(saves.some((s) => Array.isArray(s.selMatched) && s.selMatched.includes(9)), "save() persists selMatched");
|
|
48
|
+
});
|
|
49
|
+
it("#6029 old state without selMatched restores an empty set: a closed pending member does not leave", async () => {
|
|
50
|
+
const store = { load: () => ({ v: 1, order: [7], pending: [7], results: {} }), save: () => {}, log: () => {} };
|
|
51
|
+
const ac = new AbortController();
|
|
52
|
+
let polls = 0;
|
|
53
|
+
const r = await harness({ issues: [], reconcile: { everyMs: 5000, list: async () => { if (++polls >= 3) ac.abort(); return []; } }, extra: { store, signal: ac.signal } });
|
|
54
|
+
assert.deepEqual(r.calls, [7]);
|
|
55
|
+
});
|
|
56
|
+
it("a failed read leaves nothing (parseSelected null)", () => {
|
|
57
|
+
assert.equal(parseSelected("not json"), null);
|
|
58
|
+
assert.deepEqual(parseSelected('[{"number":3,"labels":[{"name":"x"}]}]'), [{ number: 3, labels: ["x"] }]);
|
|
59
|
+
assert.ok(selectArgs("o/r", "no:milestone").includes("no:milestone"));
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
describe("re-admission policy (R5, R6, R8, R14)", () => {
|
|
64
|
+
const rows = (o) => new Map([[9, { issue: 9, outcome: o }]]);
|
|
65
|
+
it("deferred retries with exponential backoff capped at 2h", () => {
|
|
66
|
+
const state = new Map();
|
|
67
|
+
assert.equal(readmitDue({ results: rows("deferred"), state, now: 0 }).requeue.length, 0);
|
|
68
|
+
assert.equal(readmitDue({ results: rows("deferred"), state, now: backoffMs(0) }).requeue.length, 1);
|
|
69
|
+
assert.equal(backoffMs(30), DEFER_CAP_MS);
|
|
70
|
+
assert.ok(backoffMs(2) > backoffMs(1));
|
|
71
|
+
});
|
|
72
|
+
it("held / engine-error re-admit on a version change, or after the 6h cooldown", () => {
|
|
73
|
+
for (const o of ["held", "engine-error"]) {
|
|
74
|
+
const state = new Map();
|
|
75
|
+
readmitDue({ results: rows(o), state, now: 0, version: "1" });
|
|
76
|
+
assert.equal(readmitDue({ results: rows(o), state, now: 1000, version: "1" }).requeue.length, 0);
|
|
77
|
+
assert.equal(readmitDue({ results: rows(o), state, now: 2000, version: "2" }).requeue.length, 1);
|
|
78
|
+
const s2 = new Map();
|
|
79
|
+
readmitDue({ results: rows(o), state: s2, now: 0, version: "1" });
|
|
80
|
+
assert.equal(readmitDue({ results: rows(o), state: s2, now: HELD_COOLDOWN_MS, version: "1" }).requeue.length, 1);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
it("a human-coded needs-human is never re-admitted", () => {
|
|
84
|
+
const r = new Map([[4, { issue: 4, outcome: "needs-human", detail: "needs credentials for the payment API" }]]);
|
|
85
|
+
assert.equal(readmitDue({ results: r, state: new Map(), now: 0 }).requeue.length, 0);
|
|
86
|
+
assert.ok(humanCode({ outcome: "needs-human", detail: "product decision needed" }));
|
|
87
|
+
assert.ok(!humanCode({ outcome: "needs-human", detail: "tests failed on lint" })); // negative example
|
|
88
|
+
assert.ok(!humanCode({ outcome: "engine-error", detail: "customers table" }));
|
|
89
|
+
});
|
|
90
|
+
it("conformance: one more attempt after the base moves, then parked in one digest", () => {
|
|
91
|
+
const row = new Map([[7, { issue: 7, outcome: "needs-human", conformance: { failed: true } }]]);
|
|
92
|
+
const state = new Map();
|
|
93
|
+
assert.equal(readmitDue({ results: row, state, now: 0, base: "a" }).requeue.length, 0);
|
|
94
|
+
assert.equal(readmitDue({ results: row, state, now: 1, base: "a" }).requeue.length, 0);
|
|
95
|
+
assert.equal(readmitDue({ results: row, state, now: 2, base: "b" }).requeue.length, 1);
|
|
96
|
+
const again = readmitDue({ results: row, state, now: 3, base: "c" });
|
|
97
|
+
assert.equal(again.requeue.length, 0);
|
|
98
|
+
assert.deepEqual(again.parked.map((p) => p.issue), [7]);
|
|
99
|
+
assert.match(needsDecisionDigest(again.parked), /needs decision \(1\): #7/);
|
|
100
|
+
assert.equal(needsDecisionDigest([]), "");
|
|
101
|
+
});
|
|
102
|
+
it("runner requeues an ended held issue on a version change without an operator command", async () => {
|
|
103
|
+
let ver = "1", polls = 0;
|
|
104
|
+
const ac = new AbortController();
|
|
105
|
+
const r = await harness({ issues: [1], reconcile: { everyMs: 1000, version: () => ver, list: async () => { if (++polls === 3) ver = "2"; if (polls > 8) ac.abort(); return [{ number: 1 }]; } },
|
|
106
|
+
extra: { signal: ac.signal, store: seeded({ 1: { issue: 1, outcome: "held", detail: "x" } }) } });
|
|
107
|
+
assert.deepEqual(r.calls, [1]);
|
|
108
|
+
assert.ok(r.updates.some((u) => u.issue === 1 && u.outcome === "requeued"));
|
|
109
|
+
assert.equal(r.rows[0].outcome, "merged");
|
|
110
|
+
});
|
|
111
|
+
it("the env.* issue the engine filed joins the order", async () => {
|
|
112
|
+
const ac = new AbortController(); let polls = 0;
|
|
113
|
+
const r = await harness({ issues: [], reconcile: { everyMs: 1000, list: async () => { if (++polls > 3) ac.abort(); return []; } },
|
|
114
|
+
extra: { signal: ac.signal, store: seeded({}, { envSigs: { "env.tool:x": { issues: [1, 2], number: 77 } } }) } });
|
|
115
|
+
assert.deepEqual(r.calls, [77]);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
describe("breaker auto-reset (R9)", () => {
|
|
120
|
+
it("environmental signature + cooldown + healthy pool resets; anything else does not", () => {
|
|
121
|
+
const tripped = { at: 100 };
|
|
122
|
+
const base = { tripped, now: 100 + 1000, cooldownMs: 500, environmental: true, poolHealthy: true };
|
|
123
|
+
assert.equal(decideAutoReset(base).reset, true);
|
|
124
|
+
assert.equal(decideAutoReset({ ...base, environmental: false }).reset, false);
|
|
125
|
+
assert.equal(decideAutoReset({ ...base, now: 200 }).reset, false);
|
|
126
|
+
assert.equal(decideAutoReset({ ...base, poolHealthy: false }).reset, false);
|
|
127
|
+
assert.equal(decideAutoReset({ ...base, tripped: null }).reset, false);
|
|
128
|
+
});
|
|
129
|
+
it("environmental details are recognised; product failures are not", () => {
|
|
130
|
+
assert.ok(environmentalDetail("sandbox.lost: VM restart"));
|
|
131
|
+
assert.ok(environmentalDetail("mirror fetch ETIMEDOUT"));
|
|
132
|
+
assert.ok(!environmentalDetail("assertion failed in foo.test.mjs"));
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
describe("staging lane close (R11)", () => {
|
|
137
|
+
it("only a merge into a non-default staging/milestone lane closes by hand", () => {
|
|
138
|
+
assert.ok(closesManually("staging"));
|
|
139
|
+
assert.ok(closesManually("milestone/v2"));
|
|
140
|
+
assert.ok(!closesManually("main"));
|
|
141
|
+
assert.ok(!closesManually(""));
|
|
142
|
+
});
|
|
143
|
+
it("the runner closes the issue after a merge into a staging lane", async () => {
|
|
144
|
+
const closed = [];
|
|
145
|
+
let polls = 0;
|
|
146
|
+
const ac = new AbortController();
|
|
147
|
+
await harness({ issues: [3], script: { 3: [{ terminalReason: "merged", pr: 1, lane: "staging" }] },
|
|
148
|
+
reconcile: { everyMs: 1000, list: async () => { if (++polls > 2) ac.abort(); return [{ number: 3 }]; }, closeIssue: async (n, o) => closed.push([n, o.lane]) },
|
|
149
|
+
extra: { signal: ac.signal } }).catch(() => null);
|
|
150
|
+
assert.deepEqual(closed, [[3, "staging"]]);
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
describe("--status coverage (R12, R16)", () => {
|
|
155
|
+
it("0 unscheduled when each open match is running/queued/backing-off/waiting/human-blocked", () => {
|
|
156
|
+
const state = { pending: [2, 3, 4], running: { 1: {} }, notBefore: { 3: 9e15 }, deps: { 4: [2] }, results: { 5: { outcome: "needs-human", detail: "needs credentials" }, 6: { outcome: "deferred" } }, readmit: { 6: {} } };
|
|
157
|
+
const c = coverage({ state, open: [1, 2, 3, 4, 5, 6].map((number) => ({ number })), now: 1 });
|
|
158
|
+
assert.deepEqual([c.running, c.queued, c.backingOff, c.waitingDeps, c.humanBlocked, c.unscheduled], [[1], [2], [3, 6], [4], [5], []]);
|
|
159
|
+
});
|
|
160
|
+
it("a match nobody will run is unscheduled", () => {
|
|
161
|
+
const c = coverage({ state: { pending: [], results: { 8: { outcome: "needs-human", detail: "tests failed" } } }, open: [{ number: 8 }, { number: 9 }] });
|
|
162
|
+
assert.deepEqual(c.unscheduled, [8, 9]);
|
|
163
|
+
});
|
|
164
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
|
+
// #6081: relaunch, recovery and requeue honour holds and pauses like fresh admission; an operator-stopped held lane is a hold, not an engine-error.
|
|
4
|
+
import { describe, it } from "node:test";
|
|
5
|
+
import assert from "node:assert/strict";
|
|
6
|
+
import { orchestrate } from "./orchestrate.mjs";
|
|
7
|
+
|
|
8
|
+
const memStore = () => { let st = null; return { load: () => (st ? JSON.parse(JSON.stringify(st)) : null), save: (s) => { st = JSON.parse(JSON.stringify(s)); }, log: () => {} }; };
|
|
9
|
+
const EE = (detail) => ({ terminalReason: "engine-error", detail });
|
|
10
|
+
const STOPPED = EE("lane pid 4242 exited without a result; see lanes/1.log");
|
|
11
|
+
const MERGED = { terminalReason: "merged", pr: 9 };
|
|
12
|
+
const REC = { owner: "op@h", since: "2026-01-01T00:00:00.000Z", expiresAt: null, reason: "host reserved", ownerPid: null, ownerHost: null };
|
|
13
|
+
|
|
14
|
+
const run = ({ script, issues = [1], store = memStore(), held = { v: [] }, pause = { v: null }, onStart = () => {}, extra = {}, clock = { t: 1_000_000 } }) => {
|
|
15
|
+
const calls = [], updates = [];
|
|
16
|
+
const p = orchestrate({ issues, parallel: 2, pollMs: 1000, readBody: async () => "", trusted: () => true, now: () => clock.t, store,
|
|
17
|
+
sleep: async (ms) => { clock.t += Math.max(1, Number(ms) || 0); },
|
|
18
|
+
getHeld: () => held.v, getPause: () => pause.v, recovery: { maxAttempts: 1, mechanicalMaxAttempts: 3 },
|
|
19
|
+
breaker: { errors: 2, window_min: 30 },
|
|
20
|
+
runOne: async (n) => { calls.push(n); clock.t += 1000; onStart(n); const l = script[n] ?? [MERGED]; return l[Math.min(calls.filter((c) => c === n).length - 1, l.length - 1)]; },
|
|
21
|
+
onUpdate: (r) => updates.push(r), ...extra });
|
|
22
|
+
return p.then((rows) => ({ rows, calls, updates, byIssue: Object.fromEntries(rows.map((r) => [r.issue, r])) }));
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
describe("#6081: relaunch gates", () => {
|
|
26
|
+
it("held while running, then engine-error: no relaunch until --release", async () => {
|
|
27
|
+
const store = memStore(), held = { v: [] };
|
|
28
|
+
const a = await run({ script: { 1: [EE("boom"), MERGED] }, store, held, onStart: (n) => { if (n === 1) held.v = [1]; } });
|
|
29
|
+
assert.deepEqual(a.calls, [1], "the relaunch waits for the release");
|
|
30
|
+
assert.equal(a.byIssue[1].outcome, "held");
|
|
31
|
+
held.v = [];
|
|
32
|
+
const b = await run({ script: { 1: [MERGED] }, store, held });
|
|
33
|
+
assert.deepEqual(b.calls, [1]);
|
|
34
|
+
assert.equal(b.byIssue[1].outcome, "merged");
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("a batch pause blocks the engine-error relaunch; the running lane still finishes", async () => {
|
|
38
|
+
const store = memStore(), pause = { v: null };
|
|
39
|
+
const a = await run({ script: { 1: [EE("boom"), MERGED] }, store, pause, onStart: (n) => { if (n === 1) pause.v = REC; } });
|
|
40
|
+
assert.deepEqual(a.calls, [1]);
|
|
41
|
+
assert.equal(a.byIssue[1].outcome, "held");
|
|
42
|
+
pause.v = null;
|
|
43
|
+
const b = await run({ script: { 1: [MERGED] }, store, pause });
|
|
44
|
+
assert.equal(b.byIssue[1].outcome, "merged");
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("an operator-stopped held lane is a hold row, not an engine-error, and never counts toward the breaker", async () => {
|
|
48
|
+
const held = { v: [] };
|
|
49
|
+
const r = await run({ issues: [1, 2, 3], script: { 1: [STOPPED], 2: [STOPPED], 3: [MERGED] }, held,
|
|
50
|
+
onStart: (n) => { if (n === 1 || n === 2) held.v = [1, 2]; } });
|
|
51
|
+
assert.ok(!r.updates.some((u) => u.outcome === "breaker"), "no breaker trip");
|
|
52
|
+
assert.ok(!r.updates.some((u) => u.outcome === "engine-error"), "no engine-error row");
|
|
53
|
+
assert.ok(r.updates.some((u) => u.issue === 1 && u.outcome === "hold" && /stopped/.test(u.detail)));
|
|
54
|
+
assert.equal(r.byIssue[1].outcome, "held");
|
|
55
|
+
assert.equal(r.byIssue[3].outcome, "merged");
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -56,6 +56,16 @@ describe("orchestrate stacking (#5831)", () => {
|
|
|
56
56
|
await h.run();
|
|
57
57
|
assert.deepEqual(h.updates.filter((u) => u.issue === 2).map((u) => u.outcome), ["plan-failed", "merged"]);
|
|
58
58
|
});
|
|
59
|
+
for (const reason of ["invalid", "needs-human", "decomposed", "budget-exceeded"]) {
|
|
60
|
+
it(`plan (#5909): a ${reason} plan end settles the issue; no build lane, no plan-failed`, async () => {
|
|
61
|
+
const h = harness({ planResult: { terminalReason: reason, detail: "verdict" } });
|
|
62
|
+
await h.run();
|
|
63
|
+
assert.equal(h.calls.filter((c) => c.n === 2 && !c.ctx.plan).length, 0, "no build lane");
|
|
64
|
+
const outs = h.updates.filter((u) => u.issue === 2).map((u) => u.outcome);
|
|
65
|
+
assert.equal(outs.includes("plan-failed"), false);
|
|
66
|
+
assert.equal(outs.at(-1), reason);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
59
69
|
it("plan: planned/planTried are persisted for --resume", async () => {
|
|
60
70
|
let saved = null;
|
|
61
71
|
const store = { load: () => null, save: (s) => { if (s.planTried) saved = s; }, log: () => {} };
|