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
package/bin/lean/limits.mjs
CHANGED
|
@@ -60,3 +60,20 @@ export function openLimits(file = limitsFile(), { now = () => Date.now() } = {})
|
|
|
60
60
|
list: () => Object.entries(read()).map(([id, h]) => ({ id, until: h.until, source: h.source ?? null, setAt: h.setAt ?? null })),
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
+
|
|
64
|
+
/** #5988: a hold expiry alert is posted this long before `expiresAt` (T-30 min). */
|
|
65
|
+
export const HOLD_EXPIRY_WARN_MS = 30 * 60000;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* #5988: hold-info entries (`{issue: {expiresAt, ...}}`) whose expiry is within `leadMs` and not yet warned. `warned` is the
|
|
69
|
+
* caller's marker set (an issue is warned once per expiresAt). Pure; an entry without a valid future expiry is never listed.
|
|
70
|
+
* @returns {Array<{issue:number, expiresAt:string, inMs:number, key:string}>}
|
|
71
|
+
*/
|
|
72
|
+
export function holdExpiryWarnings(info, { now = Date.now(), leadMs = HOLD_EXPIRY_WARN_MS, warned = new Set() } = {}) {
|
|
73
|
+
const out = [];
|
|
74
|
+
for (const [n, e] of Object.entries(info ?? {})) {
|
|
75
|
+
const at = Date.parse(e?.expiresAt), key = `${n}@${e?.expiresAt}`;
|
|
76
|
+
if (Number.isFinite(at) && at > now && at - now <= leadMs && !warned.has(key)) out.push({ issue: Number(n), expiresAt: e.expiresAt, inMs: at - now, key });
|
|
77
|
+
}
|
|
78
|
+
return out;
|
|
79
|
+
}
|
package/bin/lean/limits.test.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import assert from "node:assert/strict";
|
|
|
5
5
|
import { readFileSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { join } from "node:path";
|
|
7
7
|
import { tmpDir } from "../tests/_tmp.mjs";
|
|
8
|
-
import { openLimits, laneBackendId, limitsFile } from "./limits.mjs";
|
|
8
|
+
import { openLimits, laneBackendId, limitsFile, holdExpiryWarnings, HOLD_EXPIRY_WARN_MS } from "./limits.mjs";
|
|
9
9
|
import { orchestrate } from "./orchestrate.mjs";
|
|
10
10
|
import { limitsFromCli } from "../engine-cli.mjs";
|
|
11
11
|
|
|
@@ -402,3 +402,17 @@ describe("tokenbaton rotation holds (#5205)", () => {
|
|
|
402
402
|
onUpdate: (u) => { if (u.outcome === "paused") assert.equal(limits.holdUntil("A"), until); } });
|
|
403
403
|
});
|
|
404
404
|
});
|
|
405
|
+
|
|
406
|
+
describe("#5988: hold expiry warning", () => {
|
|
407
|
+
const at = (ms) => new Date(ms).toISOString();
|
|
408
|
+
it("lists a hold within 30 min of expiry once; never an open-ended, expired or distant hold", () => {
|
|
409
|
+
const now = 1_000_000, warned = new Set();
|
|
410
|
+
const info = { 1: { expiresAt: at(now + 20 * 60000) }, 2: { expiresAt: at(now + 3 * 3600000) }, 3: { expiresAt: null }, 4: { expiresAt: at(now - 1) } };
|
|
411
|
+
const w = holdExpiryWarnings(info, { now, warned });
|
|
412
|
+
assert.deepEqual(w.map((x) => x.issue), [1]);
|
|
413
|
+
assert.equal(HOLD_EXPIRY_WARN_MS, 30 * 60000);
|
|
414
|
+
warned.add(w[0].key);
|
|
415
|
+
assert.deepEqual(holdExpiryWarnings(info, { now, warned }), []);
|
|
416
|
+
assert.deepEqual(holdExpiryWarnings(null, { now }), []);
|
|
417
|
+
});
|
|
418
|
+
});
|
|
@@ -135,12 +135,25 @@ export function lazyWeight({ initial = null, compute = null } = {}) {
|
|
|
135
135
|
* `placeLane` with the remote or hybrid facts); mode `local` places every new lane on the host. `onChange(exec)` is
|
|
136
136
|
* called once each time the effective `{mode, maxRemote}` differs from the last one seen (the pinned one first).
|
|
137
137
|
*/
|
|
138
|
-
export
|
|
138
|
+
export const BELOW_PINNED_WARN_HOURS = 6;
|
|
139
|
+
export function liveRemote(base, { exec, readOverride = () => null, place, onChange = null, onBelowPinned = null, belowPinnedHours = BELOW_PINNED_WARN_HOURS, now = Date.now }) {
|
|
139
140
|
const keyOf = (e) => `${e.mode}|${e.maxRemote}`;
|
|
140
141
|
let last = keyOf(effectiveExecution(exec, null));
|
|
142
|
+
let live = null; // the override applied by the last current() call
|
|
143
|
+
let belowSince = null, belowWarned = false; // #5746: since when a live max_remote has been below the pinned value
|
|
144
|
+
const noteBelow = () => {
|
|
145
|
+
const pinned = exec?.maxRemote;
|
|
146
|
+
if (!(live?.maxRemote !== undefined && Number.isInteger(pinned) && live.maxRemote < pinned)) { belowSince = null; belowWarned = false; return; }
|
|
147
|
+
const t = now();
|
|
148
|
+
belowSince ??= t;
|
|
149
|
+
const hours = Number(belowPinnedHours) > 0 ? Number(belowPinnedHours) : BELOW_PINNED_WARN_HOURS;
|
|
150
|
+
if (!belowWarned && t - belowSince > hours * 3600000) { belowWarned = true; try { onBelowPinned?.({ maxRemote: live.maxRemote, pinned, hours }); } catch { /* advisory */ } }
|
|
151
|
+
};
|
|
141
152
|
const current = () => {
|
|
142
153
|
let o = null;
|
|
143
154
|
try { o = readOverride() ?? null; } catch { o = null; }
|
|
155
|
+
live = sanitizeOverride(o);
|
|
156
|
+
noteBelow();
|
|
144
157
|
const e = effectiveExecution(exec, o);
|
|
145
158
|
const k = keyOf(e);
|
|
146
159
|
if (k !== last) { last = k; try { onChange?.(e); } catch { /* advisory */ } }
|
|
@@ -153,7 +166,13 @@ export function liveRemote(base, { exec, readOverride = () => null, place, onCha
|
|
|
153
166
|
value: (n) => {
|
|
154
167
|
const e = current();
|
|
155
168
|
if (e.mode === "local") return { where: "local", reason: "live placement: local" };
|
|
156
|
-
|
|
169
|
+
const p = place(e, n);
|
|
170
|
+
// #5746: remote mode with no remote slots holds the lane when the host is not allowed; else names the real cause
|
|
171
|
+
if (e.mode === "remote" && p?.where === "local" && !(Number.isInteger(e.maxRemote) && e.maxRemote >= 1)) {
|
|
172
|
+
const reason = live?.maxRemote !== undefined ? "max_remote 0 (live override)" : "max_remote 0";
|
|
173
|
+
return base.hostFallback === false ? { where: "remote", reason, hold: true } : { ...p, reason };
|
|
174
|
+
}
|
|
175
|
+
return p;
|
|
157
176
|
},
|
|
158
177
|
enumerable: true, configurable: true, writable: true,
|
|
159
178
|
},
|
|
@@ -83,6 +83,45 @@ describe("#5138 live execution control", () => {
|
|
|
83
83
|
});
|
|
84
84
|
});
|
|
85
85
|
|
|
86
|
+
describe("#5746 live max_remote 0 in remote mode", () => {
|
|
87
|
+
const exec = { mode: "remote", maxRemote: 4 };
|
|
88
|
+
const place = (e) => ({ where: e.maxRemote >= 1 ? "remote" : "local", reason: e.maxRemote >= 1 ? "mode remote" : "max_remote 0" });
|
|
89
|
+
it("holds with the live-override reason when the host is not allowed", () => {
|
|
90
|
+
const r = liveRemote({ hostFallback: false }, { exec, readOverride: () => ({ maxRemote: 0 }), place });
|
|
91
|
+
assert.deepEqual(r.place(1), { where: "remote", reason: "max_remote 0 (live override)", hold: true });
|
|
92
|
+
});
|
|
93
|
+
it("names the live override but stays local when the host is allowed", () => {
|
|
94
|
+
const r = liveRemote({ hostFallback: true }, { exec, readOverride: () => ({ maxRemote: 0 }), place });
|
|
95
|
+
assert.deepEqual(r.place(1), { where: "local", reason: "max_remote 0 (live override)" });
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
describe("#5746 live max_remote below the pinned value warns once after N hours", () => {
|
|
100
|
+
it("warns once past the threshold, not before, and re-arms when restored", () => {
|
|
101
|
+
let t = 0, o = { maxRemote: 0 };
|
|
102
|
+
const warned = [];
|
|
103
|
+
const r = liveRemote({ onBudget: "stop" }, { exec: { mode: "remote", maxRemote: 3 }, readOverride: () => o, place: () => ({ where: "remote", reason: "r" }),
|
|
104
|
+
belowPinnedHours: 2, now: () => t, onBelowPinned: (w) => warned.push(w) });
|
|
105
|
+
void r.max;
|
|
106
|
+
t = 2 * 3600000; void r.max;
|
|
107
|
+
assert.equal(warned.length, 0);
|
|
108
|
+
t += 1; void r.max; void r.max;
|
|
109
|
+
assert.deepEqual(warned, [{ maxRemote: 0, pinned: 3, hours: 2 }]);
|
|
110
|
+
o = { maxRemote: 3 }; void r.max;
|
|
111
|
+
o = { maxRemote: 1 }; void r.max;
|
|
112
|
+
t += 3 * 3600000; void r.max;
|
|
113
|
+
assert.equal(warned.length, 2);
|
|
114
|
+
});
|
|
115
|
+
it("no warning without an override or with an override at or above the pinned value", () => {
|
|
116
|
+
let t = 0, o = null;
|
|
117
|
+
const warned = [];
|
|
118
|
+
const r = liveRemote({}, { exec: { mode: "remote", maxRemote: 2 }, readOverride: () => o, place: () => ({ where: "remote" }), belowPinnedHours: 1, now: () => t, onBelowPinned: (w) => warned.push(w) });
|
|
119
|
+
void r.max; t = 10 * 3600000; void r.max;
|
|
120
|
+
o = { maxRemote: 4 }; void r.max; t *= 2; void r.max;
|
|
121
|
+
assert.equal(warned.length, 0);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
|
|
86
125
|
describe("#5735 remoteLaneNote", () => {
|
|
87
126
|
const lanes = (agents, total) => ({ agents, total });
|
|
88
127
|
it("warns when max_remote exceeds the summed host lane ceiling and always prints the total", () => {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
|
+
/**
|
|
4
|
+
* #5991: owner-based liveness under the clock fallbacks (25 min lease TTL, 300 s unreachable window, per-attempt budget key).
|
|
5
|
+
* Pure helpers; the callers supply the facts (live batches, agent online state).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** The transport-failure window once the pool agent answers: the sandbox is gone, not the network. */
|
|
9
|
+
export const AGENT_UP_WINDOW_MS = 90000;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A lease whose holder batch is provably not live. `liveBatches` is the ids of the batches that still own the issue
|
|
13
|
+
* (array or Set); `null`/`undefined` means unknown, and a lease without a `batch` has no owner to ask: both keep the TTL.
|
|
14
|
+
*/
|
|
15
|
+
export function holderGone(lease, { liveBatches = null } = {}) {
|
|
16
|
+
const batch = typeof lease?.batch === "string" && lease.batch ? lease.batch : null;
|
|
17
|
+
if (!batch || liveBatches == null) return false;
|
|
18
|
+
const live = liveBatches instanceof Set ? liveBatches.has(batch) : Array.isArray(liveBatches) ? liveBatches.includes(batch) : null;
|
|
19
|
+
return live === false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* What a transport failure means after `waitedMs` in a row: "unreachable" ends the wait, "wait" keeps retrying. With the pool
|
|
24
|
+
* agent online (`agentOnline === true`) the window shrinks to 90 s; offline or unknown (`false`/`null`) keeps `windowMs`.
|
|
25
|
+
*/
|
|
26
|
+
export function classifyTransportLoss({ agentOnline = null, waitedMs = 0, windowMs = 300000 } = {}) {
|
|
27
|
+
const limit = agentOnline === true ? Math.min(windowMs, AGENT_UP_WINDOW_MS) : windowMs;
|
|
28
|
+
return waitedMs >= limit ? "unreachable" : "wait";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* One budget row per sandbox lifetime. #6023: a pool reuses the sandbox id across an issue's attempts, so the attempt's
|
|
33
|
+
* start time is part of the key; a replay of the same attempt keeps its key (the record keeps the larger usage).
|
|
34
|
+
*/
|
|
35
|
+
export function sandboxBudgetKey(batchId, sandboxId, startedAt = null) {
|
|
36
|
+
return `${batchId}#${sandboxId}${startedAt != null && startedAt !== "" ? `#${startedAt}` : ""}`;
|
|
37
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
|
+
import { describe, it } from "node:test";
|
|
4
|
+
import assert from "node:assert/strict";
|
|
5
|
+
import { holderGone, classifyTransportLoss, sandboxBudgetKey } from "./liveness.mjs";
|
|
6
|
+
|
|
7
|
+
describe("#5991 liveness helpers", () => {
|
|
8
|
+
it("holderGone: only a lease whose batch is known not live", () => {
|
|
9
|
+
assert.equal(holderGone({ batch: "b1" }, { liveBatches: ["b2"] }), true);
|
|
10
|
+
assert.equal(holderGone({ batch: "b1" }, { liveBatches: new Set(["b1"]) }), false);
|
|
11
|
+
assert.equal(holderGone({ batch: "b1" }, { liveBatches: [] }), true);
|
|
12
|
+
// negative examples: unknown liveness, no batch on the lease, no lease
|
|
13
|
+
assert.equal(holderGone({ batch: "b1" }, { liveBatches: null }), false);
|
|
14
|
+
assert.equal(holderGone({ batch: "b1" }), false);
|
|
15
|
+
assert.equal(holderGone({ by: "x" }, { liveBatches: ["b2"] }), false);
|
|
16
|
+
assert.equal(holderGone(null, { liveBatches: [] }), false);
|
|
17
|
+
});
|
|
18
|
+
it("classifyTransportLoss: 90 s with the agent answering, the window otherwise", () => {
|
|
19
|
+
assert.equal(classifyTransportLoss({ agentOnline: true, waitedMs: 90000, windowMs: 300000 }), "unreachable");
|
|
20
|
+
assert.equal(classifyTransportLoss({ agentOnline: true, waitedMs: 89999, windowMs: 300000 }), "wait");
|
|
21
|
+
assert.equal(classifyTransportLoss({ agentOnline: false, waitedMs: 200000, windowMs: 300000 }), "wait");
|
|
22
|
+
assert.equal(classifyTransportLoss({ agentOnline: null, waitedMs: 299999, windowMs: 300000 }), "wait");
|
|
23
|
+
assert.equal(classifyTransportLoss({ agentOnline: null, waitedMs: 300000, windowMs: 300000 }), "unreachable");
|
|
24
|
+
assert.equal(classifyTransportLoss({ agentOnline: true, waitedMs: 5000, windowMs: 5000 }), "unreachable"); // a shorter window still wins
|
|
25
|
+
});
|
|
26
|
+
it("sandboxBudgetKey is stable per sandbox lifetime", () => {
|
|
27
|
+
assert.equal(sandboxBudgetKey("b1", "fdrsbx-9"), sandboxBudgetKey("b1", "fdrsbx-9"));
|
|
28
|
+
assert.notEqual(sandboxBudgetKey("b1", "fdrsbx-9"), sandboxBudgetKey("b2", "fdrsbx-9"));
|
|
29
|
+
// #6023: a reused sandbox id on a later attempt is a new row; the same attempt replayed is the same row
|
|
30
|
+
assert.notEqual(sandboxBudgetKey("b1", "fdrsbx-9", 1000), sandboxBudgetKey("b1", "fdrsbx-9", 2000));
|
|
31
|
+
assert.equal(sandboxBudgetKey("b1", "fdrsbx-9", 1000), sandboxBudgetKey("b1", "fdrsbx-9", 1000));
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
|
+
// #5986: the attempts ledger in the batch runner: readmission needs a new input hash, a lifetime budget breach escalates once,
|
|
4
|
+
// and the ledger survives a resume (state.json) because releaseHeld never clears it.
|
|
5
|
+
import { describe, it } from "node:test";
|
|
6
|
+
import assert from "node:assert/strict";
|
|
7
|
+
import { orchestrate } from "./orchestrate.mjs";
|
|
8
|
+
|
|
9
|
+
const memStore = () => { let st = null; return { load: () => (st ? JSON.parse(JSON.stringify(st)) : null), save: (s) => { st = JSON.parse(JSON.stringify(s)); }, log: () => {}, peek: () => st }; };
|
|
10
|
+
const FAIL = { terminalReason: "needs-human", code: "ci.red", detail: "ci red: same failure" };
|
|
11
|
+
const MERGED = { terminalReason: "merged", pr: 1 };
|
|
12
|
+
const seam = (h, extra = {}) => { const notes = [], mirrored = []; return { cfg: { maxAttempts: 4, maxIdentical: 2 }, hash: async () => h.v, notify: async (x) => { notes.push(x); }, mirror: async (n, l) => { mirrored.push([n, l]); }, notes, mirrored, ...extra }; };
|
|
13
|
+
const run = (store, a, runOne, labels = []) => {
|
|
14
|
+
const updates = [];
|
|
15
|
+
return orchestrate({ issues: [1, 2], parallel: 1, pollMs: 5, store, readBody: async (n) => (n === 2 ? "**Depends on**: #1" : ""), // 2 is held behind 1: a root with a held subtree is what the label watch readmits
|
|
16
|
+
attempts: a, issueLabels: async () => labels, runOne: (n, ...x) => (n === 1 ? runOne(n, ...x) : Promise.resolve(MERGED)), onUpdate: (r) => updates.push(r) }).then((rows) => ({ rows, updates }));
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
describe("#5986 attempts ledger in the batch runner", () => {
|
|
20
|
+
it("needs-human label removed with an unchanged input hash: not readmitted, loop.no_new_input, label kept", async () => {
|
|
21
|
+
const store = memStore(), h = { v: "H1" }, a = seam(h);
|
|
22
|
+
await run(store, a, async () => FAIL);
|
|
23
|
+
let ran = 0;
|
|
24
|
+
const r = await run(store, a, async () => { ran++; return MERGED; });
|
|
25
|
+
assert.equal(ran, 0, "no lane ran");
|
|
26
|
+
assert.equal(r.rows[0].outcome, "needs-human");
|
|
27
|
+
assert.ok(r.updates.some((u) => u.code === "loop.no_new_input"), JSON.stringify(r.updates));
|
|
28
|
+
const refused = a.notes.filter((n) => n.code === "loop.no_new_input");
|
|
29
|
+
assert.equal(refused.length, 1);
|
|
30
|
+
assert.equal(refused[0].relabel, true, "the needs-human label is put back");
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("a changed input hash readmits the issue", async () => {
|
|
34
|
+
const store = memStore(), h = { v: "H1" }, a = seam(h);
|
|
35
|
+
await run(store, a, async () => FAIL);
|
|
36
|
+
h.v = "H2";
|
|
37
|
+
const r = await run(store, a, async () => MERGED);
|
|
38
|
+
assert.deepEqual(r.rows.map((x) => x.outcome), ["merged", "merged"], "root and its held dependent");
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("the 2nd identical-signature failure escalates once with one comment and stops; counters survive resumes (state.json)", async () => {
|
|
42
|
+
const store = memStore(), h = { v: "H1" }, a = seam(h);
|
|
43
|
+
await run(store, a, async () => FAIL);
|
|
44
|
+
assert.equal(a.notes.filter((n) => n.code === "escalate").length, 0);
|
|
45
|
+
h.v = "H2"; const second = await run(store, a, async () => FAIL);
|
|
46
|
+
assert.equal(second.rows[0].outcome, "needs-human");
|
|
47
|
+
assert.equal(a.notes.filter((n) => n.code === "escalate").length, 1, "one escalation");
|
|
48
|
+
assert.equal(store.peek().attempts[1].attempts, 2);
|
|
49
|
+
assert.equal(store.peek().attempts[1].signatures.length, 2);
|
|
50
|
+
let ran = 0;
|
|
51
|
+
const again = await run(store, a, async () => { ran++; return MERGED; }); // same hash H2, label removed
|
|
52
|
+
assert.equal(ran, 0);
|
|
53
|
+
assert.equal(again.rows[0].outcome, "needs-human");
|
|
54
|
+
assert.equal(a.notes.filter((n) => n.code === "escalate").length, 1, "still one escalation");
|
|
55
|
+
h.v = "H3";
|
|
56
|
+
assert.equal((await run(store, a, async () => MERGED)).rows[0].outcome, "merged", "a new input hash readmits");
|
|
57
|
+
});
|
|
58
|
+
it("#5931 a remote lane on another engine version ends env.engine_skew, never conformance", async () => {
|
|
59
|
+
const store = memStore();
|
|
60
|
+
const rows = await orchestrate({ issues: [1], parallel: 1, pollMs: 5, store, version: "1.63.0",
|
|
61
|
+
envHold: { version: () => "1.63.0", maxMs: 1, watchMs: 1 },
|
|
62
|
+
runOne: async () => ({ terminalReason: "needs-human", code: "recurrence.design_missing", detail: "gate fired", engineVersion: "1.61.2" }),
|
|
63
|
+
remote: { max: 2, isRemote: () => true, admit: () => ({ ok: true }), onBudget: "stop", costPerMinute: 0 } });
|
|
64
|
+
assert.equal(rows[0].code, "env.engine_skew");
|
|
65
|
+
assert.match(rows[0].detail, /env\.engine_skew/);
|
|
66
|
+
assert.equal(rows[0].outcome, "held");
|
|
67
|
+
});
|
|
68
|
+
it("an engine-error that breaches the lifetime attempts cap ends needs-human (escalated)", async () => {
|
|
69
|
+
const store = memStore(), h = { v: "H1" }, a = seam(h, { cfg: { maxAttempts: 1, maxIdentical: 5 } });
|
|
70
|
+
const r = await run(store, a, async () => ({ terminalReason: "engine-error", detail: "boom" }));
|
|
71
|
+
assert.equal(r.rows[0].outcome, "needs-human");
|
|
72
|
+
assert.equal(a.notes.filter((n) => n.code === "escalate").length, 1);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("no seam or no ledger admits (a merged-first-try issue sees nothing)", async () => {
|
|
76
|
+
const a = seam({ v: "H1" });
|
|
77
|
+
const r = await run(memStore(), a, async () => MERGED);
|
|
78
|
+
assert.equal(r.rows[0].outcome, "merged");
|
|
79
|
+
assert.equal(a.notes.length, 0);
|
|
80
|
+
assert.equal((await run(memStore(), null, async () => MERGED)).rows[0].outcome, "merged");
|
|
81
|
+
});
|
|
82
|
+
});
|
|
@@ -292,6 +292,22 @@ describe("#5859 agent restart: correlated sandbox loss is sandbox.lost, not engi
|
|
|
292
292
|
for (const n of issues) assert.equal(r.byIssue[n].outcome, "merged");
|
|
293
293
|
});
|
|
294
294
|
|
|
295
|
+
// #5988: three sandboxes destroyed for max lifetime together are one batch-level event; the breaker stays closed and each lane is requeued.
|
|
296
|
+
it("3 sandboxes destroyed for max lifetime within 30 s: no breaker trip, lanes requeued, reported once (#5988)", async () => {
|
|
297
|
+
const MAXLIFE = (n) => ({ ...LOST(n), detail: `sandbox fake-${n} destroyed: max lifetime reached` });
|
|
298
|
+
const issues = [1, 2, 3], script = Object.fromEntries(issues.map((n) => [n, [MAXLIFE(n), MERGED]]));
|
|
299
|
+
const store = memStore(), logged = [];
|
|
300
|
+
store.log = (ev) => logged.push(ev);
|
|
301
|
+
const r = await harness({ script, issues, parallel: 3, store, envHold: undefined, extra: { envHold: null, breaker: BREAKER, remote: { agentHealthy: async () => true } } });
|
|
302
|
+
assert.ok(!r.updates.some((u) => u.outcome === "breaker"), "the breaker never trips");
|
|
303
|
+
for (const n of issues) assert.equal(r.byIssue[n].outcome, "merged", `#${n} requeued and relaunched`);
|
|
304
|
+
const st = store.load();
|
|
305
|
+
assert.deepEqual(st.errorTimes, []);
|
|
306
|
+
assert.equal(st.breaker, null);
|
|
307
|
+
assert.equal(logged.filter((e) => e.event === "agent.restarted").length, 1, "one batch-level event");
|
|
308
|
+
assert.equal(st.agentRestarts[0].requeued, 3);
|
|
309
|
+
});
|
|
310
|
+
|
|
295
311
|
it("agent restart: failure after healthy is an ordinary engine-error", async () => {
|
|
296
312
|
const store = memStore();
|
|
297
313
|
const r = await harness({ script: { 1: [LOST(1), LOST(1), MERGED], 2: [LOST(2), MERGED], 3: [LOST(3), MERGED] }, issues: [1, 2, 3], parallel: 3, store,
|
|
@@ -322,3 +338,34 @@ describe("#5859 agent restart: correlated sandbox loss is sandbox.lost, not engi
|
|
|
322
338
|
assert.ok(r.updates.some((u) => u.outcome === "breaker"));
|
|
323
339
|
});
|
|
324
340
|
});
|
|
341
|
+
|
|
342
|
+
describe("#5988: breaker scoped by signature and agent", () => {
|
|
343
|
+
it("12 sandbox.exited engine-errors on one agent quarantine only that agent; other agents keep admitting", async () => {
|
|
344
|
+
const issues = [...Array.from({ length: 12 }, (_, i) => i + 1), 50], quarantined = [], reseeds = [];
|
|
345
|
+
const sick = (n) => ({ terminalReason: "engine-error", code: "sandbox.exited", detail: `sandbox.exited before a result (run ${n})`, agent: "vm-a" });
|
|
346
|
+
const script = Object.fromEntries(issues.slice(0, 12).map((n) => [n, [sick(n), MERGED]]));
|
|
347
|
+
const r = await harness({ script, issues, parallel: 1, envHold: undefined,
|
|
348
|
+
extra: { envHold: null, breaker: { errors: 3, window_min: 10 }, quarantineAgent: (q) => quarantined.push(q), reseedCache: (q) => reseeds.push(q) } });
|
|
349
|
+
assert.deepEqual(quarantined.map((q) => q.agent), ["vm-a"], "that agent only, once");
|
|
350
|
+
assert.equal(reseeds.length, 1, "the cache is reseeded once");
|
|
351
|
+
assert.ok(!r.updates.some((u) => u.outcome === "breaker"), "the batch breaker never trips");
|
|
352
|
+
assert.equal(r.byIssue[50].outcome, "merged", "unaffected work keeps admitting");
|
|
353
|
+
assert.ok(r.updates.some((u) => u.outcome === "agent-quarantine"));
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
it("without placement callbacks the agent is still quarantined in-batch: its lanes are requeued, the breaker stays closed", async () => {
|
|
357
|
+
const sick = (n) => ({ terminalReason: "engine-error", code: "sandbox.exited", detail: `sandbox.exited (run ${n})`, agent: "vm-a" });
|
|
358
|
+
const r = await harness({ script: { 1: [sick(1), MERGED], 2: [sick(2), MERGED], 3: [sick(3), MERGED], 4: [sick(4), MERGED] }, issues: [1, 2, 3, 4, 50], parallel: 1, envHold: undefined,
|
|
359
|
+
extra: { envHold: null, breaker: { errors: 3, window_min: 10 } } });
|
|
360
|
+
assert.ok(r.updates.some((u) => u.outcome === "agent-quarantine"));
|
|
361
|
+
assert.ok(!r.updates.some((u) => u.outcome === "breaker"));
|
|
362
|
+
assert.equal(r.byIssue[50].outcome, "merged");
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
it("a persistently sick agent without placement callbacks cannot loop forever: the batch breaker counts it after bounded requeues", async () => {
|
|
366
|
+
const sick = (n) => ({ terminalReason: "engine-error", code: "sandbox.exited", detail: `sandbox.exited (run ${n})`, agent: "vm-a" });
|
|
367
|
+
const r = await harness({ script: Object.fromEntries([1, 2, 3, 4, 5].map((n) => [n, [sick(n)]])), issues: [1, 2, 3, 4, 5], parallel: 1, envHold: undefined,
|
|
368
|
+
extra: { envHold: null, breaker: { errors: 3, window_min: 10 } } });
|
|
369
|
+
assert.ok(r.updates.some((u) => u.outcome === "breaker"), "bounded: the batch breaker trips");
|
|
370
|
+
});
|
|
371
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
|
+
// #5893: a needs-human root with held dependents is readmitted only when the label is really gone (fresh read) and its removal
|
|
4
|
+
// event post-dates the newest FORGE:NEEDS_HUMAN; an identical block (outcome code + ask key) needs a newer removal event.
|
|
5
|
+
import { describe, it } from "node:test";
|
|
6
|
+
import assert from "node:assert/strict";
|
|
7
|
+
import { orchestrate } from "./orchestrate.mjs";
|
|
8
|
+
|
|
9
|
+
const memStore = () => { let st = null; return { load: () => (st ? JSON.parse(JSON.stringify(st)) : null), save: (s) => { st = JSON.parse(JSON.stringify(s)); }, log: () => {}, peek: () => st }; };
|
|
10
|
+
const FAIL = { terminalReason: "needs-human", code: "spend.cap", detail: "needs a spend decision" };
|
|
11
|
+
const MERGED = { terminalReason: "merged", pr: 1 };
|
|
12
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
13
|
+
|
|
14
|
+
// Run 1 blocks root 1 (2 is held behind it); run 2 resumes the batch and watches the held root.
|
|
15
|
+
const resume = async (store, { issueLabels, heldFacts, ran, watchMs = 60 }) => {
|
|
16
|
+
const updates = [];
|
|
17
|
+
const p = orchestrate({ issues: [1, 2], parallel: 1, pollMs: 5, store, readBody: async (n) => (n === 2 ? "**Depends on**: #1" : ""), issueLabels, ...(heldFacts ? { heldFacts } : {}),
|
|
18
|
+
runOne: async (n) => { ran.push(n); return MERGED; }, onUpdate: (r) => updates.push(r) });
|
|
19
|
+
await Promise.race([p, sleep(watchMs)]);
|
|
20
|
+
return { updates, p };
|
|
21
|
+
};
|
|
22
|
+
const block = async (store) => orchestrate({ issues: [1, 2], parallel: 1, pollMs: 5, store, readBody: async (n) => (n === 2 ? "**Depends on**: #1" : ""), issueLabels: async () => ["needs-human"], runOne: async (n) => (n === 1 ? FAIL : MERGED) });
|
|
23
|
+
|
|
24
|
+
describe("#5893 held needs-human root readmit", () => {
|
|
25
|
+
it("no readmit while needs-human label is still on (stale cache vs fresh read)", async () => {
|
|
26
|
+
const store = memStore(); await block(store);
|
|
27
|
+
const ran = []; const calls = [];
|
|
28
|
+
// the memoized read lacks the label; only a fresh read sees it
|
|
29
|
+
const issueLabels = async (n, o) => { calls.push(o?.fresh === true); return o?.fresh ? ["needs-human"] : []; };
|
|
30
|
+
const { updates } = await resume(store, { issueLabels, ran });
|
|
31
|
+
assert.deepEqual(ran, []);
|
|
32
|
+
assert.ok(!updates.some((u) => u.outcome === "readmitted"));
|
|
33
|
+
assert.ok(calls.every(Boolean), "every held-root label read is fresh");
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("removal event before the NEEDS_HUMAN comment: no readmit; unreadable events: no readmit", async () => {
|
|
37
|
+
for (const heldFacts of [async () => ({ removedAt: 10, blockedAt: 20, askKey: "k" }), async () => { throw new Error("gh down"); }, async () => null]) {
|
|
38
|
+
const store = memStore(); await block(store);
|
|
39
|
+
const ran = [];
|
|
40
|
+
const { updates } = await resume(store, { issueLabels: async () => [], heldFacts, ran });
|
|
41
|
+
assert.deepEqual(ran, []);
|
|
42
|
+
assert.ok(!updates.some((u) => u.outcome === "readmitted"));
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("removal event after the block readmits once and the subtree follows", async () => {
|
|
47
|
+
const store = memStore(); await block(store);
|
|
48
|
+
const ran = [];
|
|
49
|
+
const { updates, p } = await resume(store, { issueLabels: async () => [], heldFacts: async () => ({ removedAt: 30, blockedAt: 20, askKey: "k" }), ran, watchMs: 200 });
|
|
50
|
+
await Promise.race([p, sleep(500)]);
|
|
51
|
+
assert.equal(updates.filter((u) => u.outcome === "readmitted" && u.issue === 1).length, 1);
|
|
52
|
+
assert.ok(ran.includes(1));
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("identical block is not readmitted twice without a newer removal event; sig survives resume", async () => {
|
|
56
|
+
const store = memStore(); await block(store);
|
|
57
|
+
const ran = [];
|
|
58
|
+
const facts = { removedAt: 30, blockedAt: 20, askKey: "k" };
|
|
59
|
+
const first = await resume(store, { issueLabels: async () => [], heldFacts: async () => facts, ran, watchMs: 200 });
|
|
60
|
+
await Promise.race([first.p, sleep(500)]);
|
|
61
|
+
assert.deepEqual(store.peek().heldSigs?.[1], { sig: "needs-human:k", removedAt: 30 }.sig ? { sig: "needs-human:k", removedAt: 30 } : null);
|
|
62
|
+
// the lane blocks again with the same ask; the old removal event is the only one
|
|
63
|
+
const st = store.peek();
|
|
64
|
+
st.results = { ...st.results, 1: { issue: 1, outcome: "needs-human", code: "spend.cap" }, 2: { issue: 2, outcome: "held", root: 1, waiting: [1] } };
|
|
65
|
+
st.pending = []; st.running = {};
|
|
66
|
+
const store2 = memStore(); store2.save(st);
|
|
67
|
+
const ran2 = [];
|
|
68
|
+
const again = await resume(store2, { issueLabels: async () => [], heldFacts: async () => facts, ran: ran2 });
|
|
69
|
+
assert.deepEqual(ran2, []);
|
|
70
|
+
assert.ok(!again.updates.some((u) => u.outcome === "readmitted"));
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -6,7 +6,7 @@ import { orchestrate } from "./orchestrate.mjs";
|
|
|
6
6
|
import { hostFallbackAllowed } from "./execution.mjs";
|
|
7
7
|
|
|
8
8
|
// #5652: host re-placement of a remote lane's env.tool_missing / env.capability_remote end follows host.role / execution.host_fallback.
|
|
9
|
-
const go = async (code, cfg) => {
|
|
9
|
+
const go = async (code, cfg, rec = {}) => {
|
|
10
10
|
const calls = [];
|
|
11
11
|
const rows = await orchestrate({ issues: [5], parallel: 2, recovery: { maxAttempts: 1 }, readBody: async () => "",
|
|
12
12
|
remote: { max: 2, isRemote: () => true, hostFallback: hostFallbackAllowed(cfg), place: () => ({ where: "remote", reason: "mode remote" }), admit: () => ({ ok: true }), onBudget: "stop", costPerMinute: 0 },
|
|
@@ -17,6 +17,18 @@ const go = async (code, cfg) => {
|
|
|
17
17
|
return { rows, calls };
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
+
// #5746: remote mode with host fallback off never re-places a mechanical recovery on the host
|
|
21
|
+
const goMech = async (hostFallback) => {
|
|
22
|
+
const calls = [];
|
|
23
|
+
await orchestrate({ issues: [5], parallel: 2, recovery: { maxAttempts: 1, mechanicalMaxAttempts: 2 }, readBody: async () => "",
|
|
24
|
+
remote: { max: 2, isRemote: () => true, hostFallback, admit: () => ({ ok: true }), onBudget: "stop", costPerMinute: 0 },
|
|
25
|
+
runOne: async (n, _l, ctx = {}) => {
|
|
26
|
+
calls.push(ctx.placement?.where);
|
|
27
|
+
return ctx.recover ? { terminalReason: "merged", pr: 9 } : { terminalReason: "needs-human", code: "env.repro_unrunnable", detail: "x", placement: { where: "remote" } };
|
|
28
|
+
} });
|
|
29
|
+
return calls;
|
|
30
|
+
};
|
|
31
|
+
|
|
20
32
|
describe("#5652 host fallback placement", () => {
|
|
21
33
|
for (const code of ["env.capability_remote", "env.tool_missing"]) {
|
|
22
34
|
it(`${code}: host.role unset keeps the host re-placement`, async () => {
|
|
@@ -38,6 +50,52 @@ describe("#5652 host fallback placement", () => {
|
|
|
38
50
|
const r = await go("env.repro_unrunnable", { hostRole: "orchestrator" });
|
|
39
51
|
assert.ok(r.calls.length >= 1);
|
|
40
52
|
});
|
|
53
|
+
it("#5746: remote mode with nothing set disallows the host; hybrid keeps it; explicit true wins", () => {
|
|
54
|
+
assert.equal(hostFallbackAllowed({ mode: "remote" }), false);
|
|
55
|
+
assert.equal(hostFallbackAllowed({ mode: "hybrid" }), true);
|
|
56
|
+
assert.equal(hostFallbackAllowed({ mode: "remote", hostFallback: true }), true);
|
|
57
|
+
assert.equal(hostFallbackAllowed({ mode: "remote", fallbackLocal: true }), false);
|
|
58
|
+
});
|
|
59
|
+
it("#5746: a #5371 mechanical recovery with host_fallback false retries remotely, not on the host", async () => {
|
|
60
|
+
const calls = await goMech(false);
|
|
61
|
+
assert.ok(calls.length >= 2);
|
|
62
|
+
assert.ok(calls.every((w) => w !== "local"), JSON.stringify(calls));
|
|
63
|
+
});
|
|
64
|
+
it("#5746: with host fallback on the #5371 recovery still goes to the host", async () => {
|
|
65
|
+
const calls = await goMech(true);
|
|
66
|
+
assert.equal(calls[1], "local");
|
|
67
|
+
});
|
|
68
|
+
for (const [name, remoteCfg] of [
|
|
69
|
+
["fallback_local with max_remote 0", { max: 0, fallbackLocal: true, offlineFallback: true, admit: () => ({ ok: true }), onBudget: "stop" }],
|
|
70
|
+
["execution budget under on_budget local", { max: 2, admit: () => ({ ok: false, reason: "budget cap" }), onBudget: "local" }],
|
|
71
|
+
]) {
|
|
72
|
+
it(`#5746: host_fallback false: ${name} never runs the lane on the host`, async () => {
|
|
73
|
+
const ac = new AbortController(), where = [];
|
|
74
|
+
const run = orchestrate({ issues: [5], parallel: 2, readBody: async () => "", pollMs: 5, signal: ac.signal,
|
|
75
|
+
remote: { isRemote: () => true, hostFallback: false, place: () => ({ where: "remote", reason: "mode remote" }), costPerMinute: 0, ...remoteCfg },
|
|
76
|
+
runOne: async (_n, _l, ctx = {}) => { where.push(ctx.placement?.where); return { terminalReason: "merged", pr: 1 }; } }).catch(() => {});
|
|
77
|
+
await new Promise((r) => setTimeout(r, 120));
|
|
78
|
+
ac.abort();
|
|
79
|
+
await Promise.race([run, new Promise((r) => setTimeout(r, 1000))]);
|
|
80
|
+
assert.ok(!where.includes("local"), JSON.stringify(where));
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
it("#5746: remote mode with nothing set ends a host-capability lane without a host re-placement", async () => {
|
|
84
|
+
const r = await go("env.capability_remote", { mode: "remote" });
|
|
85
|
+
assert.equal(r.calls.length, 1);
|
|
86
|
+
});
|
|
87
|
+
it("#5746: max_remote 0 holds the lane (no host run) and announces waiting", async () => {
|
|
88
|
+
const events = [], ac = new AbortController();
|
|
89
|
+
let ran = 0;
|
|
90
|
+
const run = orchestrate({ issues: [5], parallel: 2, readBody: async () => "", pollMs: 5, signal: ac.signal, decide: (d) => events.push(d.what),
|
|
91
|
+
remote: { max: 0, isRemote: () => true, hostFallback: false, place: () => ({ where: "remote", reason: "max_remote 0 (live override)", hold: true }), admit: () => ({ ok: true }), onBudget: "stop", costPerMinute: 0 },
|
|
92
|
+
runOne: async () => { ran++; return { terminalReason: "merged", pr: 1 }; } }).catch(() => {});
|
|
93
|
+
await new Promise((r) => setTimeout(r, 150));
|
|
94
|
+
ac.abort();
|
|
95
|
+
await Promise.race([run, new Promise((r) => setTimeout(r, 1000))]);
|
|
96
|
+
assert.equal(ran, 0);
|
|
97
|
+
assert.ok(events.some((w) => /waiting: max_remote 0/.test(w)), JSON.stringify(events));
|
|
98
|
+
});
|
|
41
99
|
});
|
|
42
100
|
|
|
43
101
|
// #5808: a lane's slow post-result work (teardown) is its postRun: the dependent starts at once, the batch still waits for it.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
|
+
// #5749: an env.validate_timeout recovery lane waits while the host is overloaded; other recoveries are unchanged.
|
|
4
|
+
import { describe, it } from "node:test";
|
|
5
|
+
import assert from "node:assert/strict";
|
|
6
|
+
import { orchestrate } from "./orchestrate.mjs";
|
|
7
|
+
|
|
8
|
+
const harness = ({ script, overloadedUntil }) => {
|
|
9
|
+
let t = 1_000_000; const calls = [], decisions = [];
|
|
10
|
+
return orchestrate({ issues: [7], parallel: 1, readBody: async () => "", now: () => t, pollMs: 1000,
|
|
11
|
+
sleep: async (ms) => { t += Math.max(1, Number(ms) || 0); },
|
|
12
|
+
recovery: { maxAttempts: 1, mechanicalMaxAttempts: 3 },
|
|
13
|
+
overload: () => ({ overloaded: overloadedUntil > 0 && t >= 1_000_500 && t < overloadedUntil }), // the first admission precedes the load spike
|
|
14
|
+
runOne: async (n, _l, ctx = {}) => { calls.push({ recover: ctx.recover?.attempt ?? 0, at: t }); t += 1000; const k = calls.length - 1; return script[Math.min(k, script.length - 1)]; },
|
|
15
|
+
decide: (d) => decisions.push(d), onUpdate: () => {} }).then((rows) => ({ rows, calls, decisions, start: 1_000_000 }));
|
|
16
|
+
};
|
|
17
|
+
const TIMEOUT = { terminalReason: "needs-human", code: "env.validate_timeout", detail: "timed out", cost_usd: 1 };
|
|
18
|
+
const UNIMPL = { terminalReason: "needs-human", code: "conformance.unimplemented", detail: "V1 missing", cost_usd: 1 };
|
|
19
|
+
const MERGED = { terminalReason: "merged", pr: 1 };
|
|
20
|
+
|
|
21
|
+
describe("#5749 overload defers env.validate_timeout recovery", () => {
|
|
22
|
+
it("#5749 env.validate_timeout recovery waits while overloaded", async () => {
|
|
23
|
+
const o = await harness({ script: [TIMEOUT, MERGED], overloadedUntil: 1_000_000 + 60_000 });
|
|
24
|
+
assert.equal(o.calls.length, 2);
|
|
25
|
+
assert.ok(o.calls[1].at >= 1_000_000 + 60_000, `recovery started at +${o.calls[1].at - o.start} ms, before the overload cleared`);
|
|
26
|
+
assert.ok(o.decisions.some((d) => /deferred: the host is overloaded/.test(d.what)));
|
|
27
|
+
const n = await harness({ script: [TIMEOUT, MERGED], overloadedUntil: 0 });
|
|
28
|
+
assert.ok(n.calls[1].at < 1_000_000 + 10_000, "no overload: the recovery starts at once");
|
|
29
|
+
assert.ok(!n.decisions.some((d) => /overloaded/.test(d.what)));
|
|
30
|
+
});
|
|
31
|
+
it("#5749 conformance.unimplemented keeps resume counts under overload", async () => {
|
|
32
|
+
const o = await harness({ script: [UNIMPL, MERGED], overloadedUntil: 1_000_000 + 60_000 });
|
|
33
|
+
assert.equal(o.calls.length, 2);
|
|
34
|
+
assert.equal(o.calls[1].recover, 1, "the same single recovery attempt as before");
|
|
35
|
+
assert.ok(!o.decisions.some((d) => /overloaded/.test(d.what)));
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// #5975: a batch-level pause stops admission for every issue (dependency merge, engine/env re-admit, expiry), never a running lane.
|
|
4
4
|
import { describe, it } from "node:test";
|
|
5
5
|
import assert from "node:assert/strict";
|
|
6
|
-
import { orchestrate } from "./orchestrate.mjs";
|
|
6
|
+
import { orchestrate, AUTH_PROBE_MS, AUTH_ESCALATE_MS, HOLD_RAMP_STEP_MS } from "./orchestrate.mjs";
|
|
7
7
|
|
|
8
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
9
|
const EE = (detail) => ({ terminalReason: "engine-error", detail });
|
|
@@ -59,3 +59,78 @@ describe("#5975: batch pause", () => {
|
|
|
59
59
|
assert.deepEqual(r.calls, [1, 2]);
|
|
60
60
|
});
|
|
61
61
|
});
|
|
62
|
+
|
|
63
|
+
// #5988: a backend.auth outage is probed every 5 min, rotated, escalated once at 30 min; hold expiry is paced and warned at T-30.
|
|
64
|
+
describe("#5988: auth outage probe and hold expiry", () => {
|
|
65
|
+
const AUTH = { terminalReason: "deferred", code: "backend.auth", retryInSeconds: 56 * 3600, detail: "login failed" };
|
|
66
|
+
const rot = (cur = { n: 1 }) => ({ accounts: [{ n: 1 }, { n: 2 }], current: () => cur.n, headroom: (ex) => [1, 2].some((n) => !(ex instanceof Map ? ex : new Map()).has(n)), resumeAt: (ex) => Math.max(0, ...[...(ex ?? new Map()).values()]) || null, isAccount: () => true,
|
|
67
|
+
pick: ({ exclude } = {}) => { const ex = new Set([...(exclude instanceof Map ? exclude.keys() : exclude ?? [])].map(Number)); const a = [1, 2].find((n) => !ex.has(n)); return a ? { account: a } : { account: null }; }, markLimited: (n) => { cur.n = n === 1 ? 2 : 1; return true; } });
|
|
68
|
+
|
|
69
|
+
it("login failure recovering at 10 min resumes within 5 min on the next account first, no operator action", async () => {
|
|
70
|
+
const resumed = await (async () => {
|
|
71
|
+
const c = { t: 5_000_000 }, s0 = c.t, ps = [], rows = [];
|
|
72
|
+
const out = await orchestrate({ issues: [1], parallel: 1, pollMs: 1000, readBody: async () => "", trusted: () => true, now: () => c.t, store: memStore(), rotator: rot(),
|
|
73
|
+
sleep: async (ms) => { c.t += Math.max(1, Number(ms) || 0); }, recovery: { maxAttempts: 1, mechanicalMaxAttempts: 3 },
|
|
74
|
+
authProbe: async ({ account }) => { ps.push({ account, at: c.t - s0 }); return { ok: c.t - s0 >= 10 * 60000 }; },
|
|
75
|
+
runOne: async () => { c.t += 1000; return c.t - s0 < 10 * 60000 ? AUTH : MERGED; }, onUpdate: (x) => rows.push({ ...x, at: c.t - s0 }) });
|
|
76
|
+
return { out, ps, rows };
|
|
77
|
+
})();
|
|
78
|
+
assert.equal(resumed.out[0].outcome, "merged");
|
|
79
|
+
assert.ok(Number.isInteger(resumed.ps[0].account), "the probe runs on the next rotator account, picked before the lane retries");
|
|
80
|
+
const back = resumed.rows.find((x) => x.outcome === "merged");
|
|
81
|
+
assert.ok(back && back.at <= 10 * 60000 + AUTH_PROBE_MS + 5000, "resumed within one probe interval of the recovery");
|
|
82
|
+
assert.ok(!resumed.rows.some((x) => x.outcome === "auth-escalation"));
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("a 56 h outage pauses at most 30 min and escalates exactly once", async () => {
|
|
86
|
+
const c = { t: 9_000_000 }, s0 = c.t, rows = [], esc = []; let k = 0;
|
|
87
|
+
await orchestrate({ issues: [1], parallel: 1, pollMs: 1000, readBody: async () => "", trusted: () => true, now: () => c.t, store: memStore(), rotator: rot(),
|
|
88
|
+
sleep: async (ms) => { c.t += Math.max(1, Number(ms) || 0); }, recovery: { maxAttempts: 1, mechanicalMaxAttempts: 3 },
|
|
89
|
+
authProbe: async () => ({ ok: false }), onEscalate: async (e) => esc.push(e),
|
|
90
|
+
runOne: async () => { c.t += 1000; return ++k <= 12 ? AUTH : MERGED; }, onUpdate: (x) => rows.push({ ...x, at: c.t - s0 }) });
|
|
91
|
+
assert.equal(esc.length, 1);
|
|
92
|
+
assert.equal(rows.filter((x) => x.outcome === "auth-escalation").length, 1);
|
|
93
|
+
assert.ok(rows.find((x) => x.outcome === "auth-escalation").at <= AUTH_ESCALATE_MS + 2 * AUTH_PROBE_MS);
|
|
94
|
+
assert.ok(c.t - s0 < 3 * 3600_000, "never a multi-hour pause");
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("expiry of 100 holds is announced once at T-30 and released at the controller's pace, not all at once", async () => {
|
|
98
|
+
const issues = Array.from({ length: 100 }, (_, i) => i + 1), clock = { t: 2_000_000 };
|
|
99
|
+
let held = new Set(issues), live = 0, peak = 0; const starts = [], release = clock.t + 20 * 60000;
|
|
100
|
+
const info = Object.fromEntries(issues.map((n) => [n, { owner: "op", since: "x", expiresAt: new Date(clock.t + 20 * 60000).toISOString() }]));
|
|
101
|
+
const rows = [];
|
|
102
|
+
await orchestrate({ issues, parallel: 4, pollMs: 1000, readBody: async () => "", trusted: () => true, now: () => clock.t, store: memStore(),
|
|
103
|
+
sleep: async (ms) => { clock.t += Math.max(1, Number(ms) || 0); }, recovery: { maxAttempts: 1, mechanicalMaxAttempts: 3 },
|
|
104
|
+
getHeld: () => [...held], getHoldInfo: () => info,
|
|
105
|
+
expireHolds: () => { if (clock.t < Date.parse(info[1].expiresAt) || !held.size) return []; const due = [...held].map((n) => ({ issue: n, owner: "op", since: "x" })); held = new Set(); return due; },
|
|
106
|
+
runOne: async () => { live++; peak = Math.max(peak, live); starts.push({ live, since: clock.t - release }); clock.t += 1000; await Promise.resolve(); live--; return MERGED; }, onUpdate: (x) => rows.push(x) });
|
|
107
|
+
assert.equal(rows.filter((x) => x.outcome === "hold-alert").length, 100, "one T-30 alert per hold");
|
|
108
|
+
assert.ok(peak <= 4, `peak ${peak} never exceeds the controller's cap`);
|
|
109
|
+
const early = starts.filter((x) => x.since < HOLD_RAMP_STEP_MS);
|
|
110
|
+
assert.ok(early.length > 0 && early.every((x) => x.live === 1), "the first step after expiry admits one lane, not the parallel cap of 4");
|
|
111
|
+
assert.equal(rows.filter((x) => x.outcome === "merged").length, 100);
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
describe("#6008: hold and pause cover deferred retries and kept sandboxes", () => {
|
|
116
|
+
const CAP = { terminalReason: "deferred", code: "sandbox.capacity", retryInSeconds: 30, detail: "no sandbox capacity" };
|
|
117
|
+
it("a sandbox.capacity-deferred issue is not dispatched while held, including when its timer fires", async () => {
|
|
118
|
+
const held = { v: [] };
|
|
119
|
+
const r = await run({ script: { 1: [CAP, MERGED] }, issues: [1], extra: { getHeld: () => held.v }, onRow: (row) => { if (row.issue === 1 && row.outcome === "deferred") held.v = [1]; } });
|
|
120
|
+
assert.deepEqual(r.calls, [1], "the retry timer fired (clock advanced) but the held issue was not dispatched");
|
|
121
|
+
assert.notEqual(r.byIssue[1].outcome, "merged");
|
|
122
|
+
});
|
|
123
|
+
it("a sandbox.capacity-deferred issue is not dispatched while the batch is paused, including when its timer fires", async () => {
|
|
124
|
+
const pause = { v: null };
|
|
125
|
+
const r = await run({ script: { 1: [CAP, MERGED] }, issues: [1], pause, onRow: (row) => { if (row.issue === 1 && row.outcome === "deferred") pause.v = REC; } });
|
|
126
|
+
assert.deepEqual(r.calls, [1]);
|
|
127
|
+
assert.notEqual(r.byIssue[1].outcome, "merged");
|
|
128
|
+
});
|
|
129
|
+
it("a paused batch suspends its kept sandboxes; unpause lifts it", async () => {
|
|
130
|
+
const pause = { v: null }, marks = [];
|
|
131
|
+
const KEPT = { terminalReason: "deferred", code: "sandbox.unreachable", retryInSeconds: 60, detail: "kept for adopt", kept: { issue: 1, since: 1_000_000, phase: "implement" } };
|
|
132
|
+
await run({ script: { 1: [KEPT, MERGED] }, issues: [1], pause, extra: { suspendLane: (n, on, why) => marks.push([n, on, why]) },
|
|
133
|
+
onRow: (row) => { if (row.issue === 1 && row.outcome === "deferred") pause.v = REC; } });
|
|
134
|
+
assert.deepEqual(marks, [[1, true, "paused"]]);
|
|
135
|
+
});
|
|
136
|
+
});
|