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/orchestrate.mjs
CHANGED
|
@@ -124,7 +124,8 @@
|
|
|
124
124
|
* then queue order. A sub-issue's estimate is the parent's ÷ N, floored at the M default. Without `estimate` the order is
|
|
125
125
|
* the queue order except that decomposed sub-issues go first. A settled row carries `est_minutes` (estimated vs. actual).
|
|
126
126
|
*/
|
|
127
|
-
import { decideClear } from "./clear-breaker.mjs";
|
|
127
|
+
import { decideClear, decideAutoReset } from "./clear-breaker.mjs";
|
|
128
|
+
import { RECONCILE_MS, BREAKER_COOLDOWN_MS, diffSelection, readmitDue, needsDecisionDigest, environmentalDetail, closesManually } from "./reconcile.mjs";
|
|
128
129
|
import { parseDependsOn } from "../engine/phases.mjs";
|
|
129
130
|
import { classifyNeedsHuman, recoveryCodeOf, recoveryClassOf, OUTCOME_CODES, ENV_VALIDATE_PLACEMENT, ENV_VALIDATE_TIMEOUT, MECHANICAL_CODES } from "../engine/outcome-codes.mjs";
|
|
130
131
|
import { detectGateDeadlock, formatGateDeadlock } from "./gatewatch.mjs";
|
|
@@ -135,19 +136,24 @@ import { laneSize, SIZES } from "./budget.mjs";
|
|
|
135
136
|
import { requeueKey, REQUEUABLE } from "./batch.mjs";
|
|
136
137
|
import { makeCapWait } from "./capwait.mjs";
|
|
137
138
|
import { mapLimit } from "./pmap.mjs";
|
|
138
|
-
import { quotaRequeue } from "./rotator.mjs";
|
|
139
|
+
import { quotaRequeue, nextAccountAfterAuthFailure } from "./rotator.mjs";
|
|
140
|
+
import { holdExpiryWarnings } from "./limits.mjs";
|
|
139
141
|
import { joinsDecomposed, addsEpicChildren, selectChildren, edgeText, DEFAULT_POLL_S } from "./autochildren.mjs";
|
|
140
142
|
import { formatOverload } from "./hostload.mjs";
|
|
141
143
|
import { normalizeStacking, planAdmissible, stackAdmissible } from "./stacking.mjs";
|
|
142
144
|
import { lackedTools } from "./toolplace.mjs";
|
|
143
145
|
import { openPrerequisites } from "./prereq.mjs";
|
|
146
|
+
import { makeController, classifyRepo, formatConcurrency } from "./concurrency.mjs";
|
|
147
|
+
import { admitInput, breach, recordFailure, blockerSignature, markEscalated, NO_NEW_INPUT } from "./attempts.mjs";
|
|
144
148
|
|
|
145
149
|
// A dependency that finished like this no longer blocks its dependents.
|
|
146
150
|
const SATISFIED = new Set(["merged", "invalid"]);
|
|
151
|
+
const PLAN_VERDICT = new Set(["invalid", "needs-human", "decomposed", "budget-exceeded"]); // #5909: plan-lane ends that settle the issue
|
|
147
152
|
const DEFAULT_TRAIN_EVERY_MS = 30000; // #5836: merge-train poll period
|
|
148
153
|
// #5836: a lane that ended pr-ready is waiting on the merge train, not failed: its dependents wait
|
|
149
154
|
const WAITING_ON_TRAIN = (row) => row?.outcome === "pr-ready";
|
|
150
155
|
// #5162: a dependent of a root that ended like this is held (resumable), not skipped. #5805: also behind a root held on an engine/env change.
|
|
156
|
+
const ATTEMPT_FAILED = ["needs-human", "engine-error", "budget-exceeded", "failed"]; // #5986: final lane outcomes that count as a failed attempt
|
|
151
157
|
const HOLD_ROOT = new Set(["needs-human", "engine-error", "deferred", "budget-exceeded", "held"]);
|
|
152
158
|
/** #5162: members of a real dependency cycle (a nontrivial SCC or a self-loop) among `nodes`; `edgesOf(n)` lists n's dependencies. */
|
|
153
159
|
export function cyclicNodes(nodes, edgesOf) {
|
|
@@ -179,11 +185,17 @@ export const ENGINE_ERROR_RELAUNCHES = 1;
|
|
|
179
185
|
export const AGENT_LOST_MIN = 3;
|
|
180
186
|
export const AGENT_LOST_WINDOW_MS = 60000;
|
|
181
187
|
export const AGENT_LOST_REQUEUE_MS = 60000;
|
|
188
|
+
// #5988: a backend.auth outage is probed every AUTH_PROBE_MS, holds admissions at most AUTH_ESCALATE_MS, then escalates once.
|
|
189
|
+
export const AUTH_PROBE_MS = 5 * 60000;
|
|
190
|
+
export const AUTH_ESCALATE_MS = 30 * 60000;
|
|
191
|
+
export const HOLD_RAMP_STEP_MS = 30000; // #5988: hold-expiry release ramp: one more lane per step
|
|
192
|
+
/** #5988: a cause that belongs to one placement host: errors are counted per (signature, agent), not batch-wide. */
|
|
193
|
+
const hostSignature = (r, detail) => (/\bsandbox\.exited\b/.test(`${r?.code ?? ""} ${detail ?? ""}`) ? "sandbox.exited" : null);
|
|
182
194
|
export const HOST_BUSY_RETRY_S = 60;
|
|
183
195
|
// #4528: a busy host or a full sandbox pool is a wait, not a failure: requeued after its retry-in, never capped.
|
|
184
196
|
// A lane that could not be resolved because gh/git failed (network blip) is the same kind of wait (#4791).
|
|
185
197
|
// #4788: an unreachable pool is a wait too (the lane already retried for unreachable_window_min); a stall is reported by poolStall.
|
|
186
|
-
const UNCAPPED_DEFERRALS = new Set(["host.busy", "sandbox.capacity", "sandbox.unreachable", "sandbox.repo_missing", "lane.unresolved"]);
|
|
198
|
+
const UNCAPPED_DEFERRALS = new Set(["host.busy", "sandbox.capacity", "sandbox.unreachable", "sandbox.repo_missing", "lane.unresolved", "base.red"]); // #5992: a red base is the base's wait, never the issue's
|
|
187
199
|
export const POOL_OFFLINE_ALERT_MIN = 10;
|
|
188
200
|
// #5112: `sandbox.capacity` deferrals of one issue after which `execution.fallback_local` runs it on the host (headroom permitting).
|
|
189
201
|
export const CAPACITY_FALLBACK_AFTER = 3;
|
|
@@ -287,6 +299,7 @@ export function deferPolicy(r, { now, deferrals = 0, maxDeferrals = DEFAULT_MAX_
|
|
|
287
299
|
const STOP_RETRY_MS = 15 * 1000;
|
|
288
300
|
const STOP_TIMEOUT_MS = 120 * 1000;
|
|
289
301
|
|
|
302
|
+
const OVERLOAD_RECOVERY_MAX_MS = 30 * 60 * 1000; // #5749: longest an env.validate_timeout recovery waits for the host to stop being overloaded
|
|
290
303
|
const cancellableSleep = (ms, signal) => new Promise((res) => {
|
|
291
304
|
const t = setTimeout(res, ms);
|
|
292
305
|
signal?.addEventListener("abort", () => { clearTimeout(t); res(); }, { once: true });
|
|
@@ -336,12 +349,12 @@ const toMap = (o) => new Map(Object.entries(o ?? {}).map(([k, v]) => [Number(k),
|
|
|
336
349
|
* @returns {Promise<Array<{issue:number, outcome:string, pr:?number, cost_usd:number, minutes:number, detail?:string}>>}
|
|
337
350
|
*/
|
|
338
351
|
export async function orchestrate({ issues, parallel = 3, runOne, readBody, prefilter = null, resolveLane = null, now = () => Date.now(), blockedRefreshMs = 60000, onUpdate = () => {}, onCrossLane = () => {},
|
|
339
|
-
store = null, adopt = null, getParallel = null, getAdded = null, getRequeued = null, breaker = null, maxDeferrals = DEFAULT_MAX_DEFERRALS, sleep = cancellableSleep, pollMs = 5000, getClearBreaker = null, consumeClearBreaker = null, ackClearBreaker = null,
|
|
340
|
-
classify = null, maintenance = null, limits = null, identity = () => "default", batchId = null, drift = null, integration = null, sched = null, priorityOf = null, remote = null, beforeAdmit = null, preflight = null,
|
|
341
|
-
recovery = null, decide = () => {}, conflicting = null, relabelNeedsHuman = null, markRecovering = null, onExit = null, issueLabels = null, issueState = null, getCancelled = null, getHeld = null, expireHolds = null, getPause = null, expirePause = null, getHoldInfo = null, getBlocked = null, trusted = null, getGates = null, stopLane = null, releaseLease = null, stopRetryMs = STOP_RETRY_MS, stopTimeoutMs = STOP_TIMEOUT_MS,
|
|
352
|
+
store = null, adopt = null, getParallel = null, usageRows = null, repoSlug = null, repoOf = null, getAdded = null, getRequeued = null, reconcile = null, select = null, breaker = null, maxDeferrals = DEFAULT_MAX_DEFERRALS, sleep = cancellableSleep, pollMs = 5000, getClearBreaker = null, consumeClearBreaker = null, ackClearBreaker = null,
|
|
353
|
+
classify = null, maintenance = null, limits = null, identity = () => "default", batchId = null, drift = null, integration = null, sched = null, priorityOf = null, remote = null, beforeAdmit = null, preflight = null, baseProbe = null,
|
|
354
|
+
recovery = null, decide = () => {}, conflicting = null, relabelNeedsHuman = null, markRecovering = null, onExit = null, issueLabels = null, heldFacts = null, issueState = null, getCancelled = null, getHeld = null, expireHolds = null, getPause = null, expirePause = null, getHoldInfo = null, authProbe = null, onEscalate = null, quarantineAgent = null, reseedCache = null, suspendLane = null, getBlocked = null, trusted = null, getGates = null, stopLane = null, releaseLease = null, stopRetryMs = STOP_RETRY_MS, stopTimeoutMs = STOP_TIMEOUT_MS,
|
|
342
355
|
estimate = null, starveMs = DEFAULT_STARVE_MS, setupConcurrency = DEFAULT_SETUP_CONCURRENCY, signal = null, dispatchCheck = null, syncParked = null, syncEveryMs = DEFAULT_SYNC_EVERY_MS, lifecycle = null,
|
|
343
356
|
getChildren = null, autoChildren = null, baseWait = null, rotator = null, stacking = "off", readPrReady = null, transientRetries = DEFAULT_TRANSIENT_RETRIES, overload = null, version = null, onInterrupted = null, envHold = null, envIssue = null, logicalDeps = null,
|
|
344
|
-
train = null, trainEveryMs = DEFAULT_TRAIN_EVERY_MS }) {
|
|
357
|
+
train = null, trainEveryMs = DEFAULT_TRAIN_EVERY_MS, attempts = null }) {
|
|
345
358
|
const saved = store?.load?.() ?? null;
|
|
346
359
|
if (train && saved?.train) train.restore(saved.train); // #5836: the merge train resumes with the batch
|
|
347
360
|
const order = saved ? [...saved.order] : [];
|
|
@@ -351,8 +364,10 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
351
364
|
const crossSeen = new Set(saved?.crossSeen ?? []);
|
|
352
365
|
const results = toMap(saved?.results); // issue -> final row
|
|
353
366
|
const running = new Map(); // issue -> promise
|
|
367
|
+
const keptBoxes = toMap(saved?.kept); // #6008: issue -> {issue, since, phase}: sandboxes kept for adopt (no dispatcher lease)
|
|
354
368
|
const runRecs = toMap(saved?.running); // issue -> {startedAt, lane, pid?}: persisted so a restart can adopt the lane
|
|
355
369
|
const pending = [...(saved?.pending ?? [])];
|
|
370
|
+
const selMatched = new Set(saved?.selMatched ?? []); // #6029: issues the selector has matched (persisted: a resumed runner keeps the leave provenance)
|
|
356
371
|
const notBefore = toMap(saved?.notBefore);
|
|
357
372
|
const requeues = toMap(saved?.requeues);
|
|
358
373
|
const deferrals = toMap(saved?.deferrals);
|
|
@@ -370,11 +385,17 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
370
385
|
// filed or updated); affected product issues are held on it (never needs-human) and 2+ issues on a signature stop admitting lanes that need it.
|
|
371
386
|
const envSigs = toMap(saved?.envSigs);
|
|
372
387
|
const engineSigs = toMap(saved?.engineSigs);
|
|
388
|
+
const heldSigs = toMap(saved?.heldSigs); // #5893: root -> {sig, removedAt} of the needs-human block last released; an identical block needs a newer removal event
|
|
389
|
+
const readmit = toMap(saved?.readmit); // #5978: re-admission policy state (backoff step, version and base seen) per ended issue
|
|
390
|
+
const ledgers = toMap(saved?.attempts); // #5986: issue -> attempts ledger; never cleared by releaseHeld, --requeue or --set-env (see attempts.mjs)
|
|
373
391
|
const deterministic = new Set(saved?.deterministicSigs ?? []);
|
|
374
392
|
const toolReadmits = new Set(saved?.toolReadmits ?? []);
|
|
375
393
|
const ehMaxMs = Number(envHold?.maxMs) > 0 ? Number(envHold.maxMs) : ENV_HOLD_MAX_MS;
|
|
376
394
|
const ehWatchMs = Number(envHold?.watchMs) > 0 ? Number(envHold.watchMs) : ENV_WATCH_MS;
|
|
377
395
|
const curVersion = () => { try { return envHold?.version?.() ?? version ?? null; } catch { return version ?? null; } };
|
|
396
|
+
const vmm2 = (x) => (/^v?(\d+\.\d+)/.exec(String(x ?? "")) ?? [])[1] ?? null;
|
|
397
|
+
const agentVersionOf = async () => { try { return (await envHold?.agentVersion?.()) ?? null; } catch { return null; } };
|
|
398
|
+
const curEnvValues = () => { try { return envHold?.envValues?.() ?? null; } catch { return null; } }; // #5931
|
|
378
399
|
const curEnv = () => { try { return envHold?.envFingerprint?.() ?? null; } catch { return null; } };
|
|
379
400
|
const missingTools = async (tools) => { if (typeof envHold?.missingTools !== "function") return null; try { const m = await envHold.missingTools(tools); return Array.isArray(m) ? m : null; } catch { return null; } };
|
|
380
401
|
const checked = toMap(saved?.prefilter); // issue -> pre-filter result
|
|
@@ -382,6 +403,8 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
382
403
|
const enqueued = toMap(saved?.enqueued); // #4409: issue -> when it last entered the queue (starvation guard)
|
|
383
404
|
const heads = new Set(saved?.heads ?? []); // #4409: decomposed sub-issues not started yet: the head of their priority band
|
|
384
405
|
let errorTimes = [...(saved?.errorTimes ?? [])];
|
|
406
|
+
const ceilingK = () => { let k = null; try { k = getParallel?.(); } catch { k = null; } return Number.isInteger(k) && k >= 1 ? k : parallel; }; // #5988: declared early: refreshHeld reads it
|
|
407
|
+
const holdWarned = new Set(); let holdRamp = null; // #5988: declared early: the hoisted refreshHeld reads them from finish/recovery callbacks
|
|
385
408
|
// #5859: agent restarts of this batch (one record each, shown by `status --batch`) and the lanes already requeued as `sandbox.lost`
|
|
386
409
|
const agentRestarts = [...(saved?.agentRestarts ?? [])];
|
|
387
410
|
const lostOnce = new Set(saved?.lostRequeued ?? []); // a lane lost again after its requeue is an ordinary engine-error
|
|
@@ -405,6 +428,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
405
428
|
const quota = toMap(saved?.quota); // issue -> {cost_usd, minutes, resumeAt (epoch ms), rotations}
|
|
406
429
|
let tripped = saved?.breaker ?? null;
|
|
407
430
|
let pfAll = false, pfRemote = false, pfNoted = new Set(); // #4866: lane preflight holds
|
|
431
|
+
let baseRedHold = null; // #5992: {sha, issue, detail}: the base is red; only the attributed fixer is admitted until the sha moves or the guard passes
|
|
408
432
|
let opHeld = new Set(); // #4592: operator-held issues this pass (the batch `hold` file is the authority)
|
|
409
433
|
const opHeldHit = new Set(); // held issues that were pending this pass
|
|
410
434
|
let opPause = null, pauseHit = false; // #5975: the batch-level pause (the `pause` file is the authority); pauseHit: an issue was pending behind it this pass
|
|
@@ -424,6 +448,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
424
448
|
const priorities = toMap(saved?.priorities); // issue -> priority number; only with the registry
|
|
425
449
|
// #5138: read on every grant, so `--set-max-remote` reaches a running batch (a getter on `remote`); running lanes are never stopped.
|
|
426
450
|
const remoteMax = () => { const m = remote?.max; return Number.isInteger(m) && m >= 0 ? m : 0; };
|
|
451
|
+
const maxHeldNoted = new Set(); // #5746: issues already announced as waiting on max_remote 0
|
|
427
452
|
const remoteCapped = new Set(); // #5138: issues waiting for a max_remote slot; polled so a raised live max_remote admits them
|
|
428
453
|
let poolOfflineSince = null, poolStallNoted = false; // #4788: when sampled online first read 0, and whether the stall was reported
|
|
429
454
|
const capWait = makeCapWait({ now }); // #4909: a lane refused for capacity waits for a free slot, recorded as queue time
|
|
@@ -441,10 +466,16 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
441
466
|
const rec = recovering.get(n);
|
|
442
467
|
if (rec?.code === OUTCOME_CODES.ENV_TOOL_MISSING && rec.where === "remote" && !rec.toolNoRecipe && (rec.attempt ?? 1) <= 1 && !budgetLocal) return { where: "remote", reason: "retry remotely after sandbox provisioning" };
|
|
443
468
|
// #5652: with host fallback off (execution.host_fallback / host.role: orchestrator) the host is orchestrator-only: no re-placement here
|
|
444
|
-
|
|
469
|
+
// #5931: a credentials block pinned the issue to the host (ledger hostPin): applied on readmit whatever host fallback says
|
|
470
|
+
if (ledgers.get(n)?.hostPin) return { where: "local", reason: "host pin: ops_credentials block" };
|
|
471
|
+
if (hostFallbackOn() && [OUTCOME_CODES.ENV_CAPABILITY_REMOTE, OUTCOME_CODES.ENV_TOOL_MISSING, OUTCOME_CODES.ENV_ENGINE_SKEW].includes(recovering.get(n)?.code)) return { where: "local", reason: `host capability: recovering ${recovering.get(n).code}` };
|
|
445
472
|
// #5371: a mechanical recovery never repeats the placement of the run that failed (a remote sandbox env defect recurs there), and a remote validate failure is rerun on the host
|
|
446
|
-
if (recovering.get(n)?.code === ENV_VALIDATE_PLACEMENT || (MECHANICAL_CODES.includes(recovering.get(n)?.code) && recovering.get(n)?.where === "remote"))
|
|
447
|
-
|
|
473
|
+
if (recovering.get(n)?.code === ENV_VALIDATE_PLACEMENT || (MECHANICAL_CODES.includes(recovering.get(n)?.code) && recovering.get(n)?.where === "remote")) {
|
|
474
|
+
if (hostFallbackOn()) return { where: "local", reason: `different placement: recovering ${rec.code} off the remote run` };
|
|
475
|
+
// #5746: the host is not allowed: retry remotely (a fresh sandbox) instead of the orchestrator
|
|
476
|
+
if (!budgetLocal) return { where: "remote", reason: `retry remotely, host fallback off: recovering ${rec.code}` };
|
|
477
|
+
}
|
|
478
|
+
if (hostFallbackOn()) { // #5331: a frozen contract naming a tool the sandbox is known to lack runs on the host (`remote.lacks`, `remote.contractOf(n)`; both optional)
|
|
448
479
|
const lk = lackedTools(remote.contractOf?.(n), remote.lacks);
|
|
449
480
|
if (lk.tools.length) return { where: "local", reason: `host tool: sandbox lacks ${lk.tools.join(", ")}` };
|
|
450
481
|
}
|
|
@@ -455,7 +486,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
455
486
|
return { where: p?.where === "remote" ? "remote" : "local", reason: String(p?.reason ?? "") };
|
|
456
487
|
}
|
|
457
488
|
return remote.isRemote?.(n) ? { where: "remote", reason: "mode remote" } : { where: "local", reason: "local" };
|
|
458
|
-
} catch { return { where: "local", reason: "placement failed" }; }
|
|
489
|
+
} catch { return hostFallbackOn() ? { where: "local", reason: "placement failed" } : { where: "remote", reason: "placement failed, host fallback off: retry remotely" }; } // #5746
|
|
459
490
|
};
|
|
460
491
|
const isRemote = (n) => placeOf(n)?.where === "remote";
|
|
461
492
|
const placed = new Map(); // issue -> {where, reason} granted this pass, picked up by start()
|
|
@@ -470,7 +501,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
470
501
|
// #5592: env.tool_missing repeats are the same defect when the same tools are missing, whatever else the detail says (probe lines, ids, paths vary per run)
|
|
471
502
|
const toolsOf = (d) => { const m = /(?:host|sandbox) is missing ([^\n]+?), so validate command/i.exec(String(d ?? "")); return m ? m[1].split(/\s*,\s*/).sort().join(",") : null; };
|
|
472
503
|
const envSig = (code, d) => (code === OUTCOME_CODES.ENV_TOOL_MISSING ? toolsOf(d) : null) ?? sigOf(d);
|
|
473
|
-
const ENV_ALL_CODES = [...REPEAT_ENV_CODES, ENV_VALIDATE_TIMEOUT, OUTCOME_CODES.ENV_CAPABILITY_REMOTE]; // #5755
|
|
504
|
+
const ENV_ALL_CODES = [...REPEAT_ENV_CODES, ENV_VALIDATE_TIMEOUT, OUTCOME_CODES.ENV_CAPABILITY_REMOTE, OUTCOME_CODES.ENV_ENGINE_SKEW]; // #5755, #5931
|
|
474
505
|
const envKey = (code, d) => `${code}|${code === OUTCOME_CODES.ENV_TOOL_MISSING && toolsOf(d) ? toolsOf(d) : failureSignature(code, d).split("|").slice(1).join("|")}`;
|
|
475
506
|
const maxFor = (cls) => (cls === "mechanical" ? mechMax : recoveryMax);
|
|
476
507
|
const classUsed = toMap(saved?.recoveryClasses); // `${issue}:${class}` -> recovery lanes launched in that class
|
|
@@ -493,6 +524,10 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
493
524
|
const everRelabelled = new Set(saved?.relabelled ?? []); // #4656: issues the runner already relabelled; never parked on top
|
|
494
525
|
const relabelled = new Set(saved?.relabelled ?? []); // #4315: queued recoveries relabelled needs-human when a batch stopped
|
|
495
526
|
// #4267: decisions are recorded, never awaited: a failing or slow recorder cannot block the batch.
|
|
527
|
+
// #5985: the controller moves are persisted to log.jsonl with their inputs (the post-deploy check reads them)
|
|
528
|
+
const conc = makeController({ ceiling: parallel, now });
|
|
529
|
+
let heavyHeldHit = false;
|
|
530
|
+
const concEmit = (e) => { if (!e) return; const ev = { ...e, batch: batchId ?? null, running: running.size, line: formatConcurrency({ running: running.size, k: e.k, ceiling: e.ceiling, factor: e.factor }) }; try { store?.log?.(ev); } catch { /* advisory */ } onUpdate(ev); };
|
|
496
531
|
const decided = (d) => { try { Promise.resolve(decide?.(d)).catch(() => {}); } catch { /* best effort */ } };
|
|
497
532
|
const firstLine = (x) => String(x ?? "").split("\n")[0].slice(0, 300);
|
|
498
533
|
|
|
@@ -500,7 +535,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
500
535
|
let halted = false; // #4454: stopped by `signal`; the batch's state is no longer this process's to write
|
|
501
536
|
const save = () => {
|
|
502
537
|
if (!store || halted) return;
|
|
503
|
-
store.save({ v: 1, ...(setup ? { phase: "setup", setup: { ...setup } } : {}), engineVersion: version, order, deps: toObj(deps), lanes: toObj(lanes), crossSeen: [...crossSeen], results: toObj(results), running: toObj(runRecs),
|
|
538
|
+
store.save({ v: 1, ...(setup ? { phase: "setup", setup: { ...setup } } : {}), engineVersion: version, order, deps: toObj(deps), lanes: toObj(lanes), crossSeen: [...crossSeen], results: toObj(results), running: toObj(runRecs), ...(keptBoxes.size ? { kept: toObj(keptBoxes) } : {}),
|
|
504
539
|
pending, notBefore: toObj(notBefore), requeues: toObj(requeues), deferrals: toObj(deferrals), engineErrors: toObj(engineErrors), ...(transients.size ? { transientRetries: toObj(transients) } : {}), ...(quota.size ? { quota: toObj(quota) } : {}), ...(limitedAccounts.size ? { limitedAccounts: toObj(limitedAccounts) } : {}), ...(capDefers.size ? { capDeferrals: toObj(capDefers) } : {}), ...(capReasons.size ? { capReasons: toObj(capReasons) } : {}),
|
|
505
540
|
prefilter: toObj(checked), errorTimes, breaker: tripped, ...(agentRestarts.length ? { agentRestarts, lostRequeued: [...lostOnce] } : {}), ...(budget ? { classes: toObj(classes), dispatch: { ...dispatch } } : {}),
|
|
506
541
|
...(reg ? { priorities: toObj(priorities) } : {}), ...(sandboxUse.size ? { sandbox: toObj(sandboxUse) } : {}),
|
|
@@ -510,9 +545,14 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
510
545
|
...(requeueApplied.size ? { requeueApplied: [...requeueApplied], requeued: toObj(requeuedInfo) } : {}),
|
|
511
546
|
...(relabelled.size ? { relabelled: [...relabelled] } : {}), ...(cancelled ? { cancelled } : {}), ...(train ? { train: train.snapshot() } : {}),
|
|
512
547
|
...(estimate ? { estimates: toObj(estimates), enqueued: toObj(enqueued) } : {}), ...(heads.size ? { heads: [...heads] } : {}),
|
|
513
|
-
...(engineSigs.size ? { engineSigs: toObj(engineSigs) } : {}), ...(deterministic.size ? { deterministicSigs: [...deterministic] } : {}), ...(toolReadmits.size ? { toolReadmits: [...toolReadmits] } : {}), ...(envSigs.size ? { envSigs: toObj(envSigs) } : {}) });
|
|
548
|
+
...(engineSigs.size ? { engineSigs: toObj(engineSigs) } : {}), ...(heldSigs.size ? { heldSigs: toObj(heldSigs) } : {}), ...(deterministic.size ? { deterministicSigs: [...deterministic] } : {}), ...(toolReadmits.size ? { toolReadmits: [...toolReadmits] } : {}), ...(select ? { select } : {}), ...(readmit.size ? { readmit: toObj(readmit) } : {}), ...(envSigs.size ? { envSigs: toObj(envSigs) } : {}), ...(ledgers.size ? { attempts: toObj(ledgers) } : {}), ...(selMatched.size ? { selMatched: [...selMatched] } : {}) });
|
|
514
549
|
};
|
|
515
550
|
const update = (row) => { store?.log?.(row); onUpdate(row); };
|
|
551
|
+
// #5978 R11: a merge into a staging lane branch does not fire `Closes`: the seam closes the issue and folds its post-deploy checks into the release rollup.
|
|
552
|
+
const closeOnLane = async (n, lane, row) => {
|
|
553
|
+
if (!reconcile?.closeIssue || !closesManually(lane)) return;
|
|
554
|
+
try { await reconcile.closeIssue(n, { lane, row }); update({ issue: n, outcome: "closed", detail: `closed on merge into ${lane}` }); } catch (err) { update({ issue: n, outcome: "close-failed", detail: String(err?.message ?? err).slice(0, 200) }); }
|
|
555
|
+
};
|
|
516
556
|
/** #5755: records `issue` on its signature and files or updates the one env issue (seam `envIssue.ensure`); the issue number, or null when none could be filed. */
|
|
517
557
|
const fileEnvIssue = async ({ sig, code, issue, tools, evidence }) => {
|
|
518
558
|
const e = envSigs.get(sig) ?? { issues: [], number: null };
|
|
@@ -745,7 +785,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
745
785
|
// #5112: opt-in (`execution.fallback_local`): an issue the pool refused `capacityFallbackAfter` times (default CAPACITY_FALLBACK_AFTER)
|
|
746
786
|
// for `sandbox.capacity` runs on the host when the host-busy guard (`remote.headroom()`, absent = allowed) passes; not ok or a throw waits.
|
|
747
787
|
const capacityFallback = (n) => {
|
|
748
|
-
if (!remote?.offlineFallback) return false;
|
|
788
|
+
if (!remote?.offlineFallback || !hostFallbackOn()) return false; // #5746: host_fallback: false keeps the lane on the pool
|
|
749
789
|
const after = Number.isInteger(remote.capacityFallbackAfter) && remote.capacityFallbackAfter > 0 ? remote.capacityFallbackAfter : CAPACITY_FALLBACK_AFTER;
|
|
750
790
|
if ((capDefers.get(n) ?? 0) < after) return false;
|
|
751
791
|
// #5592: an overloaded host holds every local admission (host_overloaded), so falling back would park the lane indefinitely: keep retrying the pool
|
|
@@ -780,7 +820,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
780
820
|
let cap = null, probeFailed = false;
|
|
781
821
|
try { cap = remote.capacity?.() ?? null; } catch { probeFailed = true; }
|
|
782
822
|
// #5048: only a failed probe (a throw) marks the pool down; null is unknown (first pass, no capacity()) and leaves the state; a sample clears it.
|
|
783
|
-
if (probeFailed) notePool(true, "capacity probe failed"); else if (cap !== null) notePool(false);
|
|
823
|
+
if (probeFailed) notePool(true, "capacity probe failed"); else if (cap !== null) { notePool(false); concEmit(conc.observe(cap)); } // #5985: the live sample moves the operating point
|
|
784
824
|
// #4788: zero live agents for longer than `remote.poolOfflineMin` (default 10): one loud batch event, none while online > 0.
|
|
785
825
|
if (cap && cap.online === 0) {
|
|
786
826
|
poolOfflineSince ??= now();
|
|
@@ -791,7 +831,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
791
831
|
}
|
|
792
832
|
} else if (cap && cap.online > 0) { poolOfflineSince = null; poolStallNoted = false; }
|
|
793
833
|
// #4547: opt-in (`execution.fallback_local`): every pool agent offline or asleep (sampled online 0) runs the lane on the host.
|
|
794
|
-
if (remote.offlineFallback && cap && cap.online === 0) {
|
|
834
|
+
if (remote.offlineFallback && hostFallbackOn() && cap && cap.online === 0) {
|
|
795
835
|
p = { where: "local", reason: `fallback to local: no pool agent online (${p.reason})` };
|
|
796
836
|
} else if (capacityFallback(n)) {
|
|
797
837
|
p = { where: "local", reason: `fallback to local: pool at capacity after ${capDefers.get(n)} deferrals (${p.reason})` };
|
|
@@ -800,17 +840,21 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
800
840
|
decided({ issue: n, what: `run #${n} on the host: the pool refused it ${capDefers.get(n)} times for capacity (execution.fallback_local)`, why: "sustained sandbox.capacity and the host has headroom",
|
|
801
841
|
alternative: "keep deferring until a pool slot frees" });
|
|
802
842
|
}
|
|
803
|
-
} else if (cap && Number.isInteger(cap.free)) {
|
|
843
|
+
} else if (cap && (Number.isInteger(cap.free) || capWait.conditional(n, cap))) {
|
|
804
844
|
if (cap.at !== capAt) { capAt = cap.at; capAdmits = 0; }
|
|
805
|
-
|
|
806
|
-
if (
|
|
845
|
+
// #5985: a refusal's named condition (load < 1.0, free mem > floor) and the per-lane refusal hold gate the relaunch, not the timer
|
|
846
|
+
if (capWait.blocked(n, cap) || conc.holding(n, cap)) { notBefore.set(n, now() + Math.max(pollMs, 1)); return false; }
|
|
847
|
+
if (Number.isInteger(cap.free) && capAdmits >= cap.free && remoteRun.size < remoteMax()) { notBefore.set(n, now() + Math.max(pollMs, 1)); return false; }
|
|
807
848
|
}
|
|
808
849
|
if (p.where === "remote" && remoteRun.size < remoteMax()) { remoteCapped.delete(n); capWait.admitted(n); remoteRun.add(n); capAdmits++; placed.set(n, p); return true; }
|
|
809
|
-
if (p.where === "remote" && !remote.fallbackLocal
|
|
850
|
+
if (p.where === "remote" && (!remote.fallbackLocal || !hostFallbackOn())) { // #5746: host_fallback: false never runs a capped remote lane on the host
|
|
851
|
+
if (remoteMax() < 1 && !maxHeldNoted.has(n)) { maxHeldNoted.add(n); decided({ issue: n, what: `waiting: max_remote 0 (#${n} is queued, not run on the host)`, why: "remote mode holds admissions while max_remote is 0", alternative: "raise max_remote or set execution.host_fallback: true" }); }
|
|
852
|
+
remoteCapped.add(n); return false;
|
|
853
|
+
}
|
|
810
854
|
if (p.where === "remote") p = { where: "local", reason: `fallback to local: max_remote ${remoteMax()} reached (${p.reason})` }; // #4256: hybrid runs it on the host
|
|
811
855
|
} else {
|
|
812
856
|
noteBudget(adm.reason);
|
|
813
|
-
if (remote.onBudget !== "local" && !remote.fallbackLocal) { budgetStop = adm.reason; return false; }
|
|
857
|
+
if ((remote.onBudget !== "local" && !remote.fallbackLocal) || !hostFallbackOn()) { budgetStop = adm.reason; return false; } // #5746: host_fallback: false stops instead of using the host
|
|
814
858
|
budgetLocal = true; // falls through to the host path
|
|
815
859
|
p = { where: "local", reason: `fallback to local: execution budget: ${adm.reason}` };
|
|
816
860
|
}
|
|
@@ -849,14 +893,16 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
849
893
|
const requeue = (n, delayMs) => { pending.push(n); enqueued.set(n, now()); if (delayMs > 0) notBefore.set(n, now() + delayMs); else notBefore.delete(n); };
|
|
850
894
|
const TRANSPORT_COOLDOWN_MS = 5 * 60000;
|
|
851
895
|
const netTransients = new Map(); // #5947: issue -> net.transient deferrals (backoff step)
|
|
896
|
+
const envDetails = []; // #5978: the details of the recent engine-errors, for the breaker auto-reset
|
|
852
897
|
let transportErrors = 0; // #4685: engine-errors in the current window that were link failures
|
|
853
898
|
const noteEngineError = (detail = "") => {
|
|
854
899
|
if (!breaker) return;
|
|
855
900
|
const t = now(), windowMs = breaker.window_min * 60000;
|
|
856
901
|
errorTimes = [...errorTimes.filter((x) => t - x < windowMs), t];
|
|
902
|
+
envDetails.push(detail); if (envDetails.length > breaker.errors) envDetails.shift();
|
|
857
903
|
transportErrors = isTransientEngineError(detail) ? Math.min(transportErrors + 1, errorTimes.length) : 0;
|
|
858
904
|
if (!tripped && errorTimes.length >= breaker.errors) {
|
|
859
|
-
tripped = { at: t, ...(transportErrors >= errorTimes.length ? { transport: true } : {}), detail: `circuit breaker: ${errorTimes.length} engine-errors within ${breaker.window_min} min; admissions stopped` };
|
|
905
|
+
tripped = { at: t, ...(envDetails.length && envDetails.every(environmentalDetail) ? { environmental: true } : {}), ...(transportErrors >= errorTimes.length ? { transport: true } : {}), detail: `circuit breaker: ${errorTimes.length} engine-errors within ${breaker.window_min} min; admissions stopped` };
|
|
860
906
|
update({ issue: null, outcome: "breaker", detail: tripped.detail });
|
|
861
907
|
}
|
|
862
908
|
return t;
|
|
@@ -864,6 +910,51 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
864
910
|
// #5859: sandboxes of one pool agent ending without a result in a burst (AGENT_LOST_MIN within AGENT_LOST_WINDOW_MS) are an agent/VM
|
|
865
911
|
// restart: `sandbox.lost`, requeued once (after `remote.agentHealthy(agent)` answers, when the provider has it), never counted by the
|
|
866
912
|
// breaker or the engine-error relaunch. Lanes of the burst that settled as engine-errors first are rolled back. One batch event each.
|
|
913
|
+
// #5988: one backend.auth outage at a time: probed on a clock, rotated, escalated once; `authPass` runs every loop pass.
|
|
914
|
+
let authOutage = null;
|
|
915
|
+
const authPass = async () => {
|
|
916
|
+
const o = authOutage; if (!o) return;
|
|
917
|
+
const t = now();
|
|
918
|
+
if (!o.escalated && t - o.since >= AUTH_ESCALATE_MS) {
|
|
919
|
+
o.escalated = true;
|
|
920
|
+
const detail = `backend.auth: the claude login has failed for ${Math.round((t - o.since) / 60000)} min (accounts tried: ${[...o.failed].join(", ") || "none"}); admissions no longer held, operator action needed`;
|
|
921
|
+
try { holds.clear(o.key); } catch { /* fail-open */ }
|
|
922
|
+
for (const m of o.issues) notBefore.delete(m);
|
|
923
|
+
for (const f of o.failed) limitedAccounts.delete(f);
|
|
924
|
+
update({ issue: null, outcome: "auth-escalation", detail });
|
|
925
|
+
try { await onEscalate?.({ detail, issues: [...o.issues], batch: batchId ?? null }); } catch { /* advisory */ }
|
|
926
|
+
return;
|
|
927
|
+
}
|
|
928
|
+
if (o.escalated || !authProbe || t < o.nextProbe) return;
|
|
929
|
+
const next = nextAccountAfterAuthFailure(rotator, o.last ? [o.last] : []); // the account after the one that failed last
|
|
930
|
+
let ok = false; try { ok = Boolean((await authProbe({ account: next, configDir: next ? rotator?.configDir?.(next) ?? null : null }))?.ok); } catch { ok = false; }
|
|
931
|
+
if (ok) {
|
|
932
|
+
try { holds.clear(o.key); } catch { /* fail-open */ }
|
|
933
|
+
for (const m of o.issues) notBefore.delete(m);
|
|
934
|
+
for (const f of o.failed) limitedAccounts.delete(f);
|
|
935
|
+
authOutage = null;
|
|
936
|
+
update({ issue: null, outcome: "auth-resumed", detail: `backend.auth recovered after ${Math.round((t - o.since) / 60000)} min; admissions resumed${next ? ` on account ${next}` : ""}` });
|
|
937
|
+
} else {
|
|
938
|
+
if (next) o.last = next;
|
|
939
|
+
o.nextProbe = t + AUTH_PROBE_MS;
|
|
940
|
+
}
|
|
941
|
+
};
|
|
942
|
+
// #5988: engine-errors with one host-bound signature on one agent are counted per (signature, agent): at the breaker's threshold only that
|
|
943
|
+
// agent is quarantined (its cache reseeded once); the batch breaker never sees them, so unaffected agents keep admitting.
|
|
944
|
+
const QUARANTINE_REQUEUES = 3, quarantineRequeues = new Map(), scopedSeen = new Map(), quarantined = new Map(), reseeded = new Set(); // quarantined: key -> until
|
|
945
|
+
const scopedEngineError = async (agent, sig) => {
|
|
946
|
+
const t = now(), key = `${sig}|${agent}`, windowMs = breaker.window_min * 60000, win = [...(scopedSeen.get(key) ?? []).filter((x) => t - x < windowMs), t];
|
|
947
|
+
scopedSeen.set(key, win);
|
|
948
|
+
if (quarantined.get(key) > t) return { quarantined: true };
|
|
949
|
+
if (win.length >= breaker.errors) {
|
|
950
|
+
quarantined.set(key, t + windowMs);
|
|
951
|
+
if (!reseeded.has(agent)) { reseeded.add(agent); try { await reseedCache?.({ agent, signature: sig }); } catch { /* advisory */ } }
|
|
952
|
+
try { await quarantineAgent?.({ agent, signature: sig, errors: win.length }); } catch { /* advisory */ }
|
|
953
|
+
update({ issue: null, outcome: "agent-quarantine", detail: `agent ${agent} quarantined: ${win.length} engine-errors (${sig}) within ${breaker.window_min} min; other agents keep admitting` });
|
|
954
|
+
return { quarantined: true };
|
|
955
|
+
}
|
|
956
|
+
return { quarantined: false };
|
|
957
|
+
};
|
|
867
958
|
const lostSeen = new Map(); // agent -> [{n, at, err, ee, tr, sig}]: lost lanes settled as ordinary engine-errors in the window
|
|
868
959
|
const openRestart = (agent, t) => agentRestarts.find((g) => g.agent === agent && !g.closed && t - g.last < AGENT_LOST_WINDOW_MS);
|
|
869
960
|
const markLost = (agent, n, row, why) => {
|
|
@@ -901,6 +992,26 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
901
992
|
if (changed) save();
|
|
902
993
|
};
|
|
903
994
|
|
|
995
|
+
// #5986: a failed lane lands in the issue's ledger; a lifetime-budget breach escalates once (FORGE:ESCALATION, needs-human) and parks the row.
|
|
996
|
+
const recordAttempt = async (n, row, r) => {
|
|
997
|
+
try {
|
|
998
|
+
if (row.placement?.where === "remote" && r?.engineVersion) attempts.noteSandboxVersion?.(r.engineVersion); // #5931: the version the lane ran feeds the input hash
|
|
999
|
+
const hash = (await attempts.hash?.(n)) ?? null;
|
|
1000
|
+
let l = ledgers.get(n) ?? (await attempts.load?.(n)) ?? null;
|
|
1001
|
+
l = recordFailure(l, { signature: failureSignature(row.code ?? r?.code, row.detail), hash, spend: Number(row.cost_usd) || 0, run: r?.runUrl ?? null,
|
|
1002
|
+
blocker: blockerSignature({ code: row.code ?? r?.code, detail: row.detail, contractHash: r?.contractHash ?? null, engineVersion: r?.engineVersion ?? (row.placement?.where === "remote" ? null : curVersion()), placement: row.placement?.where ?? null, env: curEnvValues() }) });
|
|
1003
|
+
const b = breach(l, attempts.cfg);
|
|
1004
|
+
if (b && !l.escalated) {
|
|
1005
|
+
l = markEscalated(l);
|
|
1006
|
+
await attempts.notify?.({ issue: n, code: "escalate", ledger: l, reason: b.detail });
|
|
1007
|
+
if (row.outcome !== "needs-human") { row.detail = `attempts.exhausted: ${b.detail}\n${String(row.detail ?? "")}`; row.outcome = "needs-human"; }
|
|
1008
|
+
decided({ issue: n, what: `escalated #${n} to a person: ${b.detail}`, why: "lifetime attempt budget (#5986)", alternative: "run another lane on the same input" });
|
|
1009
|
+
}
|
|
1010
|
+
ledgers.set(n, l);
|
|
1011
|
+
const comments = await attempts.mirror?.(n, l);
|
|
1012
|
+
if (Number.isInteger(comments)) ledgers.set(n, { ...l, comments });
|
|
1013
|
+
} catch { /* the ledger is best effort: a failed write never changes the lane's outcome */ }
|
|
1014
|
+
};
|
|
904
1015
|
// Apply one lane's result: requeue it (deferred, dependency-open, engine-error) or record its final row.
|
|
905
1016
|
const settleLane = async (n, r, rec, pf) => {
|
|
906
1017
|
if (halted) return; // #4454: a resume adopts the lane and settles it
|
|
@@ -954,7 +1065,11 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
954
1065
|
results.set(n, row); done(); save(); update(row);
|
|
955
1066
|
return;
|
|
956
1067
|
}
|
|
957
|
-
|
|
1068
|
+
const planVerdict = rec?.plan && r?.terminalReason !== "planned" && PLAN_VERDICT.has(row.outcome);
|
|
1069
|
+
if (planVerdict) { // #5909: a verdict end (invalid, needs-human, ...) is the issue's answer: it settles as a final row below, no build lane
|
|
1070
|
+
planMs.set(n, (planMs.get(n) ?? 0) + Math.max(0, now() - rec.startedAt));
|
|
1071
|
+
store?.log?.({ event: "STACK_PLAN_FAILED", issue: n, reason: row.outcome });
|
|
1072
|
+
} else if (rec?.plan) {
|
|
958
1073
|
// #5831: a plan lane ends `planned` or `plan-failed` and goes back to pending for its build lane. It is never a final row and
|
|
959
1074
|
// never counts toward the breaker, the engine-error relaunch, the deferral or the requeue budgets (it returns before them).
|
|
960
1075
|
done();
|
|
@@ -983,6 +1098,15 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
983
1098
|
alternative: kind === "engine" ? "relaunch into the same engine-error, or end engine-error and wait for a manual --requeue" : "launch a recovery that fails the same way, or end needs-human and wait for a manual --requeue" });
|
|
984
1099
|
update(final);
|
|
985
1100
|
};
|
|
1101
|
+
// #5931: a remote lane that ran another engine version than the host is an environment outcome, never conformance (gates fixed in the host version still fire there)
|
|
1102
|
+
const ranVersion = r?.engineVersion ?? /ForgeDock\s*[·-]\s*v?(\d+\.\d+(?:\.\d+)?)/.exec(String(r?.banner ?? row.detail ?? ""))?.[1] ?? null;
|
|
1103
|
+
if (ranVersion && row.placement?.where === "remote") row.engineVersion = String(ranVersion); // R3: the engine that actually ran stays on the row
|
|
1104
|
+
const vmm = (v) => (/^v?(\d+\.\d+)/.exec(String(v ?? "")) ?? [])[1] ?? null;
|
|
1105
|
+
if (row.placement?.where === "remote" && ranVersion && vmm(curVersion()) && vmm(ranVersion) !== vmm(curVersion()) && ["needs-human", "failed", "invalid", "budget-exceeded"].includes(row.outcome)) {
|
|
1106
|
+
row.code = OUTCOME_CODES.ENV_ENGINE_SKEW;
|
|
1107
|
+
row.detail = `${OUTCOME_CODES.ENV_ENGINE_SKEW}: the sandbox ran engine v${ranVersion}, the host is v${curVersion()}; not a conformance result. Place it locally or upgrade the agent.\n${String(row.detail ?? "")}`;
|
|
1108
|
+
if (ehOn) return holdEnv({ kind: "env", sig: `${OUTCOME_CODES.ENV_ENGINE_SKEW}|${ranVersion}|${curVersion()}`, why: `sandbox engine v${ranVersion} differs from the host v${curVersion()}` });
|
|
1109
|
+
}
|
|
986
1110
|
if (row.outcome === "dependency-open" && depList.length) {
|
|
987
1111
|
// #4387: a parked dependency is not pulled in again (fail-open on an unreadable label).
|
|
988
1112
|
let parked;
|
|
@@ -1027,6 +1151,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1027
1151
|
update({ ...row, detail: `stopped by cancel: ${r?.code ?? row.outcome}${r?.detail ? ` ${r.detail}` : ""}` });
|
|
1028
1152
|
return;
|
|
1029
1153
|
}
|
|
1154
|
+
if (!(row.outcome === "deferred" && r?.code === "sandbox.capacity")) capDefers.delete(n); // #5746: a lane the pool accepted resets the capacity count
|
|
1030
1155
|
if (row.outcome === "deferred" && (r?.code === "stack.replan" || r?.code === "stack.restart") && !cancelled) {
|
|
1031
1156
|
// #5833: the stacked dependent's PR and branch were dropped. replan: it builds as a normal lane on the lane base (today's held/skipped
|
|
1032
1157
|
// rules decide while its dependency is unsatisfied); restart: it may stack again on the dependency's new head, from the frozen contract.
|
|
@@ -1043,11 +1168,16 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1043
1168
|
const pol = deferPolicy(r, { now: now(), deferrals: deferrals.get(n) ?? 0, maxDeferrals });
|
|
1044
1169
|
let capGated = false; // #4909: the pool reports free slots, so the slot (not the retry-in timer) gates the relaunch
|
|
1045
1170
|
if (r?.code === "sandbox.unreachable") notePool(true, r.detail ?? "sandbox unreachable");
|
|
1171
|
+
if (r?.code === "base.red" && baseProbe && !baseRedHold) { // #5992: a lane's base.red result raises the one batch hold at once (its guardRed verdict is cached, so this runs no second probe)
|
|
1172
|
+
try { const v = await baseProbe(); if (v?.red) { const issue = Number.isInteger(v.att?.issue) ? v.att.issue : null, detail = `base.red: base ${String(v.sha).slice(0, 12)} is red on ${(v.commands ?? []).join(", ") || "a guard command"}${v.att ? `; last change ${String(v.att.sha).slice(0, 12)}${issue ? ` (#${issue})` : ""}` : ""}; admissions paused until the base moves`; update({ issue: null, outcome: "preflight", code: "base.red", detail }); baseRedHold = { sha: v.sha, issue, detail }; } } catch { /* the next pass probes */ }
|
|
1173
|
+
}
|
|
1046
1174
|
if (r?.code === "sandbox.capacity") {
|
|
1047
|
-
capWait.refused(n);
|
|
1175
|
+
capWait.refused(n, r.reason ?? null);
|
|
1176
|
+
concEmit(conc.refused({ issue: n, code: r.code, reason: r.reason, live: r.live ?? null })); // #5985
|
|
1048
1177
|
if (r.detail) capReasons.set(n, String(r.detail).slice(0, 300));
|
|
1049
|
-
|
|
1050
|
-
|
|
1178
|
+
// #5112: counted for the fallback_local capacity fallback; #5746: a host-busy refusal is not pool capacity
|
|
1179
|
+
if (!/host[ _-]?busy|headroom/i.test(String(r.detail ?? ""))) capDefers.set(n, (capDefers.get(n) ?? 0) + 1);
|
|
1180
|
+
try { const c = remote?.capacity?.(); capGated = Number.isInteger(c?.free) || capWait.conditional(n, c); } catch { capGated = false; }
|
|
1051
1181
|
}
|
|
1052
1182
|
if (!pol.capped) {
|
|
1053
1183
|
if (!pol.host && !pol.hold) deferrals.set(n, (deferrals.get(n) ?? 0) + 1);
|
|
@@ -1069,12 +1199,21 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1069
1199
|
if (!(Number.isFinite(rotAt) && rotAt > now())) rotAt = null;
|
|
1070
1200
|
}
|
|
1071
1201
|
// #5203: no account has headroom: the hold lasts until the earliest reset across accounts, not this lane's own reset.
|
|
1072
|
-
|
|
1202
|
+
let holdMs = usage && rotAt !== null ? rotAt - now() : pol.delayMs;
|
|
1203
|
+
if (r?.code === "backend.auth") { // #5988: probe every 5 min, never hold past the 30 min escalation, rotate to the next account
|
|
1204
|
+
const t0 = now();
|
|
1205
|
+
if (!authOutage) authOutage = { since: t0, nextProbe: t0 + AUTH_PROBE_MS, failed: new Set(), escalated: false, key: r?.backendId ?? identity(), issues: new Set() };
|
|
1206
|
+
authOutage.issues.add(n);
|
|
1207
|
+
try { const cur = authOutage.escalated ? null : rotator?.current?.(); if (cur) { authOutage.failed.add(cur); authOutage.last = cur; limitedAccounts.set(cur, t0 + AUTH_PROBE_MS); try { rotator.markLimited?.(cur, t0 + AUTH_PROBE_MS); } catch { /* best effort */ } } } catch { /* fail-open */ }
|
|
1208
|
+
holdMs = Math.min(holdMs, AUTH_PROBE_MS);
|
|
1209
|
+
if (t0 - authOutage.since >= AUTH_ESCALATE_MS) { await authPass(); holdMs = 0; }
|
|
1210
|
+
}
|
|
1073
1211
|
if (rq) {
|
|
1074
1212
|
delayMs = rq.delayMs;
|
|
1075
1213
|
// #5095 + #5094: the pool account's own hold (not the host's) still routes hybrid lanes local until its reset.
|
|
1076
1214
|
try { const pool = remote?.identity?.(); if (!rq.rotated && pool && r?.backendId === pool) holds.set(pool, now() + pol.delayMs, `batch ${batchId ?? "?"} #${n}`); } catch { /* fail-open */ }
|
|
1077
|
-
} else try { holds.set(r?.backendId ?? identity(), rotAt ?? now() + holdMs, `batch ${batchId ?? "?"} #${n}`); delayMs = 0; } catch { /* fail-open */ }
|
|
1215
|
+
} else if (holdMs > 0 || r?.code !== "backend.auth") try { holds.set(r?.backendId ?? identity(), rotAt ?? now() + holdMs, `batch ${batchId ?? "?"} #${n}`); delayMs = 0; } catch { /* fail-open */ }
|
|
1216
|
+
else delayMs = AUTH_PROBE_MS; // #5988: escalated: no hold; the lane retries as its own probe
|
|
1078
1217
|
const q = quota.get(n) ?? { cost_usd: 0, minutes: 0, rotations: 0 };
|
|
1079
1218
|
const resumeAt = usage ? now() + (rq ? rq.delayMs : holdMs) : Math.max(now() + (rq ? rq.delayMs : pol.delayMs), rotAt ?? 0);
|
|
1080
1219
|
quota.set(n, { cost_usd: Math.round(((Number(q.cost_usd) || 0) + (Number(row.cost_usd) || 0)) * 1e6) / 1e6, minutes: Math.round(((Number(q.minutes) || 0) + (Number(row.minutes) || 0)) * 10) / 10,
|
|
@@ -1091,6 +1230,14 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1091
1230
|
}
|
|
1092
1231
|
row.detail = `gave up after ${deferrals.get(n) ?? 0} deferrals: ${r?.detail ?? r?.code ?? ""}`;
|
|
1093
1232
|
}
|
|
1233
|
+
// #6081: a held issue whose lane died without a result was stopped by the operator (SIGTERM / kill / sandbox stop), not by the engine:
|
|
1234
|
+
// a hold row, no engine-error, no breaker count, no relaunch budget spent; the issue waits pending for --release.
|
|
1235
|
+
if (row.outcome === "engine-error" && !cancelled && (r?.lostWithoutResult || /exited without a result|interrupted by SIG/i.test(String(r?.detail ?? ""))) && (refreshHeld(), opHeld.has(n))) {
|
|
1236
|
+
requeue(n, 0); done(); save();
|
|
1237
|
+
decided({ issue: n, what: `#${n} stopped while held by the operator; not an engine-error, not counted toward the breaker`, why: firstLine(row.detail) || "lane ended without a result", alternative: "count it as an engine-error and relaunch" });
|
|
1238
|
+
update({ ...row, outcome: "hold", detail: `#${n} stopped by operator hold: ${firstLine(row.detail) || "lane ended without a result"}` });
|
|
1239
|
+
return;
|
|
1240
|
+
}
|
|
1094
1241
|
const la = row.outcome === "engine-error" && r?.lostWithoutResult && !cancelled && !lostOnce.has(n) ? (r.agent ?? r.sandbox?.agent ?? null) : null;
|
|
1095
1242
|
let lostNow = null;
|
|
1096
1243
|
if (la) { // #5859
|
|
@@ -1110,7 +1257,15 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1110
1257
|
lostSeen.set(la, [...win, lostNow]);
|
|
1111
1258
|
}
|
|
1112
1259
|
if (row.outcome === "engine-error") {
|
|
1113
|
-
const
|
|
1260
|
+
const ag = r?.agent ?? r?.sandbox?.agent ?? null, hs = ag && breaker ? hostSignature(r, row.detail) : null;
|
|
1261
|
+
const sc = hs ? await scopedEngineError(ag, hs) : null;
|
|
1262
|
+
const qn = sc?.quarantined ? (quarantineRequeues.get(n) ?? 0) + 1 : 0; // a lane waits out the quarantine a bounded number of times, then counts as an ordinary engine-error (batch breaker included)
|
|
1263
|
+
if (sc?.quarantined && qn <= QUARANTINE_REQUEUES) { quarantineRequeues.set(n, qn); // #5988: an agent in quarantine: its lane waits and is requeued without a relaunch or breaker count; unaffected agents keep admitting
|
|
1264
|
+
requeue(n, AGENT_LOST_REQUEUE_MS); done(); save();
|
|
1265
|
+
update({ ...row, outcome: "requeued", detail: `requeued: agent ${ag} is quarantined (${hs}); retried in ${Math.round(AGENT_LOST_REQUEUE_MS / 1000)}s` });
|
|
1266
|
+
return;
|
|
1267
|
+
}
|
|
1268
|
+
const errAt = hs && !sc?.quarantined ? undefined : noteEngineError(r?.detail);
|
|
1114
1269
|
if (lostNow) lostNow.err = errAt;
|
|
1115
1270
|
// #5161: a transient failure (gateway 5xx, reset) waits out the outage with backoff instead of the single immediate relaunch.
|
|
1116
1271
|
if (transientMax > 0 && isTransientEngineError(row.detail)) {
|
|
@@ -1221,7 +1376,17 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1221
1376
|
// #5652: a remote lane's tool/capability end is not recovered on the host when host fallback is off; the lane message names the fix
|
|
1222
1377
|
const noHostRecovery = !hostFallbackOn() && row.placement?.where === "remote" && [OUTCOME_CODES.ENV_CAPABILITY_REMOTE, OUTCOME_CODES.ENV_TOOL_MISSING].includes(row.code);
|
|
1223
1378
|
if (noHostRecovery) decided({ issue: n, what: `no host re-placement for ${row.code}: host fallback is off (execution.host_fallback / host.role: orchestrator)`, why: firstLine(row.detail), alternative: "re-place the lane on the host" });
|
|
1224
|
-
|
|
1379
|
+
// #5749: an env.validate_timeout is host load, so its recovery lane is not started while the host is overloaded (it would time out again)
|
|
1380
|
+
if (overload && row.code === ENV_VALIDATE_TIMEOUT && classifyNeedsHuman(facts) === "recoverable" && used < max) {
|
|
1381
|
+
const isOver = () => { try { return overload()?.overloaded === true; } catch { return false; } };
|
|
1382
|
+
const t0 = now();
|
|
1383
|
+
if (isOver()) {
|
|
1384
|
+
decided({ issue: n, what: `recovery for ${row.code} deferred: the host is overloaded`, why: firstLine(row.detail) || row.code, alternative: "start the recovery lane under load and time out again" });
|
|
1385
|
+
while (isOver() && now() - t0 < OVERLOAD_RECOVERY_MAX_MS) await sleep(Math.max(pollMs, 1));
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
// #5979: failure.repeated is a typed park (not in RECOVERABLE_CODES): never relaunched, reported parked below
|
|
1389
|
+
if (!repeatEnv && !noHostRecovery && !sameHostReplay && row.code !== OUTCOME_CODES.FAILURE_REPEATED && classifyNeedsHuman(facts) === "recoverable" && used < max) {
|
|
1225
1390
|
// #5727: the first remote end on a tool no recipe can install, before any build work, is re-placed on the host without spending an attempt
|
|
1226
1391
|
const free = !prior && r?.toolNoRecipe === true && row.code === OUTCOME_CODES.ENV_TOOL_MISSING && row.placement?.where === "remote" && !freeRecovered.has(n);
|
|
1227
1392
|
const code = recoveryCodeOf(facts), attempt = used + 1;
|
|
@@ -1250,8 +1415,10 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1250
1415
|
if (row.outcome === "needs-human" && !row.parkedQueued && !row.securityEscalated && !everRelabelled.has(n) && typeof relabelNeedsHuman === "function" && (cls => cls === "parked" || (cls === "recoverable" && prior))(classifyNeedsHuman({ ...row, issueEdited: r?.issueEdited === true }, { parked: true }))) { // a recoverable row with a finished recovery has used its attempts
|
|
1251
1416
|
try { const res = await relabelNeedsHuman({ issue: n, parked: { code: row.code, pr: Number.isInteger(row.pr) ? row.pr : null }, evidence: `Mechanical park \`${row.code}\`${Number.isInteger(row.pr) ? ` (PR #${row.pr})` : ""}:\n${String(row.detail ?? "")}` }); if (res !== false && res !== "failed" && res !== "skipped") row.parkedQueued = true; else if (res === false || res === "failed") { const ev = { event: "relabel.failed", issue: n, batch: batchId ?? null, detail: `parked relabel failed (${row.code}): needs-human kept` }; try { store?.log?.(ev); } catch { /* best effort */ } onUpdate(ev); } } catch { /* best effort */ }
|
|
1252
1417
|
}
|
|
1418
|
+
if (attempts && ATTEMPT_FAILED.includes(row.outcome)) await recordAttempt(n, row, r); // #5986
|
|
1253
1419
|
results.set(n, row);
|
|
1254
1420
|
if (row.outcome === "merged" && lifecycle && r?.milestone) lifecycleTitles.add(String(r.milestone)); // #4657
|
|
1421
|
+
if (row.outcome === "merged") await closeOnLane(n, rec?.lane ?? r?.lane, row);
|
|
1255
1422
|
if (row.outcome === "merged" && integration?.onMerged && String(rec?.lane ?? r?.lane ?? "").startsWith("milestone/")) {
|
|
1256
1423
|
// #4667: counts the merge toward the milestone's integration run; an error is a row, never the outcome.
|
|
1257
1424
|
try { await integration.onMerged(n, { ...row, lane: rec?.lane ?? r?.lane }, r); } catch (e) { update({ issue: n, outcome: "integration", detail: `integration check failed: ${String(e?.message ?? e).slice(0, 300)}` }); }
|
|
@@ -1269,6 +1436,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1269
1436
|
// #5437: a lane's post-run bookkeeping (r.postRun) starts once its slot is free; the batch waits for it before it ends.
|
|
1270
1437
|
const postRuns = new Set();
|
|
1271
1438
|
const settle = async (n, r, rec, pf) => {
|
|
1439
|
+
if (r?.kept) keptBoxes.set(n, r.kept); // #6008
|
|
1272
1440
|
await settleLane(n, r, rec, pf);
|
|
1273
1441
|
if (typeof r?.postRun !== "function") return;
|
|
1274
1442
|
const p = Promise.resolve().then(() => r.postRun()).catch(() => {}).finally(() => postRuns.delete(p));
|
|
@@ -1300,7 +1468,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1300
1468
|
heads.delete(n); enqueued.delete(n); busyNoted.delete(n);
|
|
1301
1469
|
const rec = { startedAt: now(), ...(plan ? { plan: true } : {}), ...(stackedOn ? { stackedOn } : {}), ...(queueMs != null ? { queueMs } : {}), ...(lane ? { lane } : {}), ...(remoteRun.has(n) ? { remote: true } : {}), ...(pl ? { placement: pl } : {}) };
|
|
1302
1470
|
if (!firstAdmit.has(n)) firstAdmit.set(n, rec.startedAt); // #5834: chain wall time starts at the first admission, plan lane included
|
|
1303
|
-
runRecs.set(n, rec); notBefore.delete(n); capReasons.delete(n); save();
|
|
1471
|
+
runRecs.set(n, rec); keptBoxes.delete(n); notBefore.delete(n); capReasons.delete(n); save();
|
|
1304
1472
|
track(n, (async () => {
|
|
1305
1473
|
// Pre-filter once per issue (a requeued issue is not re-checked); fail-open: an error means a normal lane.
|
|
1306
1474
|
if (prefilter && !checked.has(n)) { let pf = null; try { pf = await prefilter(n, lane); } catch { pf = null; } checked.set(n, pf); save(); }
|
|
@@ -1312,7 +1480,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1312
1480
|
if (!["merged", "invalid", "deferred"].includes(gone?.outcome)) gone = null; // #4920: deferred = another lane owns the issue (lease or open PR on GitHub)
|
|
1313
1481
|
}
|
|
1314
1482
|
// #5526: a hold placed since the pass read is honoured at launch: the issue goes back to pending, no lane
|
|
1315
|
-
if (!cancelled && !halted) { refreshHeld(); refreshPause(); if (opHeld.has(n) || opPause) { running.delete(n); runRecs.delete(n); releaseSlot(n); endRemote(n); requeue(n, 0); save(); return; } }
|
|
1483
|
+
if (!cancelled && !halted) { refreshHeld(); refreshPause(); if (opHeld.has(n) || opPause) { await null; /* #6081: track() registers this promise after the sync prefix; delete after it, or the entry leaks and the runner never ends */ running.delete(n); runRecs.delete(n); releaseSlot(n); endRemote(n); requeue(n, 0); save(); return; } }
|
|
1316
1484
|
if (halted) return; // #4454: stopped before launch; no pid, so a resume queues it again
|
|
1317
1485
|
let r;
|
|
1318
1486
|
if (cancelled) r = { terminalReason: "deferred", code: "run.interrupted", cost_usd: 0, detail: "cancelled before launch" }; // #4376
|
|
@@ -1417,11 +1585,49 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1417
1585
|
if (typeof onExit === "function") { try { onExit(relabelQueued); } catch { /* best effort */ } }
|
|
1418
1586
|
|
|
1419
1587
|
// #4408: issues added to the running batch; returns how many joined. Re-reading the cumulative list is a no-op.
|
|
1588
|
+
// #5978: standing order (`--select`): one reconcile per interval. Matching open issues and engine-filed env.* issues join through
|
|
1589
|
+
// the `getAdded` path below; closed or moved pending issues leave; ended deferred/held/engine-error/conformance rows are requeued
|
|
1590
|
+
// through `drainRequeues` by policy (reconcile.mjs). Same DAG, priority and lane rules as an operator `--add`/`--requeue`.
|
|
1591
|
+
let nextReconcile = 0, parkedDigest = "";
|
|
1592
|
+
const selFresh = [], autoRequeues = []; // #6022: selMatched (declared with the restores) = issues the selector has matched
|
|
1593
|
+
const reconcileTick = async () => {
|
|
1594
|
+
if (!reconcile) return;
|
|
1595
|
+
const t = now();
|
|
1596
|
+
if (t < nextReconcile) return;
|
|
1597
|
+
nextReconcile = t + (reconcile.everyMs ?? RECONCILE_MS);
|
|
1598
|
+
let open = null;
|
|
1599
|
+
try { open = await reconcile.list(); } catch { open = null; } // a failed read never makes anything leave
|
|
1600
|
+
const labels = new Map((open ?? []).map((o) => [o.number, o.labels ?? []]));
|
|
1601
|
+
if (open) {
|
|
1602
|
+
const { join, leave } = diffSelection({ open, members: [...set], pending, running, results, matched: selMatched });
|
|
1603
|
+
const matchedBefore = selMatched.size;
|
|
1604
|
+
for (const o of open) selMatched.add(o.number);
|
|
1605
|
+
selFresh.push(...join);
|
|
1606
|
+
for (const n of leave) {
|
|
1607
|
+
pending.splice(pending.indexOf(n), 1);
|
|
1608
|
+
skip(n, "left the selector: closed or moved");
|
|
1609
|
+
}
|
|
1610
|
+
if (leave.length || selMatched.size > matchedBefore) save();
|
|
1611
|
+
}
|
|
1612
|
+
for (const e of envSigs.values()) if (Number.isInteger(e.number) && !set.has(e.number)) selFresh.push(e.number); // R7: the engine-filed env.* issue joins the order
|
|
1613
|
+
let base = null;
|
|
1614
|
+
try { base = (await reconcile.base?.()) ?? null; } catch { base = null; }
|
|
1615
|
+
const agentV = await agentVersionOf(); // R6: the agent that would run the lane, so an agent upgrade re-admits
|
|
1616
|
+
const { requeue, parked } = readmitDue({ results, state: readmit, now: t, version: agentV ? `${reconcile.version?.() ?? ""}|agent=${agentV}` : reconcile.version?.() ?? null, base, labels: (n) => labels.get(n) ?? [] });
|
|
1617
|
+
for (const q of requeue) autoRequeues.push({ issue: q.issue, at: `reconcile-${t}`, reason: q.reason, by: "reconcile" });
|
|
1618
|
+
const digest = needsDecisionDigest(parked);
|
|
1619
|
+
if (digest !== parkedDigest) {
|
|
1620
|
+
parkedDigest = digest;
|
|
1621
|
+
if (digest) decided({ issue: null, what: digest, why: "one recovery attempt used; parked for an operator instead of lost", alternative: "forgedock orchestrate --requeue after deciding" });
|
|
1622
|
+
}
|
|
1623
|
+
if (requeue.length || parked.length) save();
|
|
1624
|
+
};
|
|
1420
1625
|
const drainAdds = async () => {
|
|
1421
1626
|
const kids = await drainChildren();
|
|
1422
|
-
|
|
1627
|
+
await reconcileTick();
|
|
1628
|
+
if (!getAdded && !selFresh.length) return kids;
|
|
1423
1629
|
let got = [];
|
|
1424
|
-
try { got = getAdded() ?? []; } catch { got = []; }
|
|
1630
|
+
try { got = [...(getAdded?.() ?? []), ...selFresh.splice(0)]; } catch { got = []; }
|
|
1425
1631
|
const fresh = [...new Set((Array.isArray(got) ? got : []).filter((n) => Number.isSafeInteger(n) && n > 0 && !set.has(n)))];
|
|
1426
1632
|
if (!fresh.length) return kids;
|
|
1427
1633
|
// An edge an operator wrote into a pending issue after the batch started (it waits on an added issue) holds too.
|
|
@@ -1475,9 +1681,9 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1475
1681
|
// #4550: `--requeue` entries (batch `requeue` file) not applied yet: a terminal issue and the dependents skipped behind it
|
|
1476
1682
|
// return to pending, the prior rows kept in history; their `Depends on` edges are re-read from the body and replaced (#5112).
|
|
1477
1683
|
const drainRequeues = async () => {
|
|
1478
|
-
if (!getRequeued) return 0;
|
|
1684
|
+
if (!getRequeued && !autoRequeues.length) return 0;
|
|
1479
1685
|
let got = [];
|
|
1480
|
-
try { got = getRequeued() ?? []; } catch { got = []; }
|
|
1686
|
+
try { got = [...(getRequeued?.() ?? []), ...autoRequeues.splice(0)]; } catch { got = []; }
|
|
1481
1687
|
const fresh = (Array.isArray(got) ? got : []).filter((e) => Number.isSafeInteger(e?.issue) && !requeueApplied.has(requeueKey(e)));
|
|
1482
1688
|
let n = 0;
|
|
1483
1689
|
for (const e of fresh) {
|
|
@@ -1550,6 +1756,8 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1550
1756
|
s.at = t;
|
|
1551
1757
|
try { Promise.resolve(stopLane(n, rec)).then((ok) => { if (ok !== false) s.accepted = true; }, () => {}); } catch { /* best effort */ }
|
|
1552
1758
|
}
|
|
1759
|
+
// #6008: hold and pause reach a kept sandbox through the durable marker on its issue (the sandbox cannot read batch files); cleared on release/unpause.
|
|
1760
|
+
const markKept = (ns, on, reason) => { if (!suspendLane) return; for (const n of ns) { try { Promise.resolve(suspendLane(n, on, reason)).catch(() => {}); } catch { /* best effort */ } } };
|
|
1553
1761
|
// #5975: the batch pause. `paused (reason, until …)`, the one text every surface shows.
|
|
1554
1762
|
function pauseText(p = opPause) { return `paused (${p?.reason ?? "no reason given"}, until ${p?.expiresAt ?? "unpause"})`; }
|
|
1555
1763
|
function refreshPause() {
|
|
@@ -1571,6 +1779,8 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1571
1779
|
decided({ issue: null, what: "batch unpaused (forgedock orchestrate --unpause); admission resumed", why: "operator request", alternative: "resume the batch" });
|
|
1572
1780
|
update({ issue: null, outcome: "unpause", detail: "admission resumed" });
|
|
1573
1781
|
}
|
|
1782
|
+
if (next && !opPause) markKept([...keptBoxes.keys()], true, "paused");
|
|
1783
|
+
else if (!next && opPause) markKept([...keptBoxes.keys()].filter((n) => !opHeld.has(n)), false, "paused");
|
|
1574
1784
|
opPause = next;
|
|
1575
1785
|
}
|
|
1576
1786
|
// #4592: re-read the hold set; one decision and one row when it changes.
|
|
@@ -1580,18 +1790,29 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1580
1790
|
if (!getHeld) return;
|
|
1581
1791
|
if (expireHolds) { // #5469: a hold past its expiry is released here; the diff below then admits it. A dead owner session is an alert.
|
|
1582
1792
|
let due = []; try { due = expireHolds() ?? []; } catch { due = []; }
|
|
1793
|
+
if (due.length > 1) holdRamp = { at: now() };
|
|
1794
|
+
if (due.length > 1) concEmit({ event: "concurrency", change: "hold-release", k: conc.operating("light"), ceiling: ceilingK(), factor: "hold expiry", inputs: { released: due.length } }); // #5988: the release is paced by K(), never all at once
|
|
1583
1795
|
for (const e of due) {
|
|
1584
1796
|
decided({ issue: null, what: `hold on #${e.issue} expired (held by ${e.owner} since ${e.since}${e.reason ? `: ${e.reason}` : ""}); re-admitted`, why: "hold expiry (--hold --for)", alternative: "hold it again" });
|
|
1585
1797
|
update({ issue: null, outcome: "hold-expired", detail: `#${e.issue} (${e.owner}, since ${e.since})` });
|
|
1586
1798
|
if (e.ownerGone) update({ issue: null, outcome: "hold-alert", detail: `#${e.issue}: the hold owner session (${e.owner}) is gone; the hold expired and the issue was re-admitted` });
|
|
1587
1799
|
}
|
|
1588
1800
|
}
|
|
1801
|
+
if (expireHolds) { // #5988: one alert per hold at T-30 min
|
|
1802
|
+
let info = null; try { info = getHoldInfo?.() ?? null; } catch { info = null; }
|
|
1803
|
+
for (const w of holdExpiryWarnings(info, { now: now(), warned: holdWarned })) {
|
|
1804
|
+
holdWarned.add(w.key);
|
|
1805
|
+
update({ issue: null, outcome: "hold-alert", detail: `#${w.issue}: the hold expires at ${w.expiresAt} (in ${Math.round(w.inMs / 60000)} min); release or extend it, or it re-admits through the concurrency controller` });
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1589
1808
|
let got = [];
|
|
1590
1809
|
try { got = getHeld() ?? []; } catch { got = opHeld.size ? [...opHeld] : []; }
|
|
1591
1810
|
const next = new Set((Array.isArray(got) ? got : []).filter((n) => Number.isSafeInteger(n) && n > 0));
|
|
1592
1811
|
const fmt = (ns) => ns.map((n) => `#${n}`).join(", ");
|
|
1593
1812
|
const held = [...next].filter((n) => !opHeld.has(n)), freed = [...opHeld].filter((n) => !next.has(n));
|
|
1594
1813
|
opHeld = next;
|
|
1814
|
+
markKept(held.filter((n) => keptBoxes.has(n)), true, "held");
|
|
1815
|
+
markKept(freed.filter((n) => keptBoxes.has(n) && !opPause), false, "held");
|
|
1595
1816
|
for (const n of held) if (running.has(n)) update({ issue: n, outcome: "hold", detail: `#${n} held after launch: lane still running` }); // #5526
|
|
1596
1817
|
if (held.length) {
|
|
1597
1818
|
decided({ issue: null, what: `held ${fmt(held)} (forgedock orchestrate --hold)`, why: "operator request", alternative: "cancel the batch" });
|
|
@@ -1691,6 +1912,26 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1691
1912
|
const readmitted = new Set(); // "n:b": re-admit n on blocker b once; a lane that re-skips on b stays skipped
|
|
1692
1913
|
const blockerOf = (n) => { const r = results.get(n); const m = r?.outcome === "skipped" ? /^dependency #(\d+) /.exec(r.detail ?? "") : null; return m ? Number(m[1]) : null; };
|
|
1693
1914
|
const watchable = () => !!dispatchCheck && [...results.keys()].some((n) => blockerOf(n) !== null);
|
|
1915
|
+
// #5986: readmission needs a new input hash. false = refused (loop.no_new_input: the label stays, one note per hash); a missing ledger or unreadable input admits.
|
|
1916
|
+
const refusedNoted = new Set();
|
|
1917
|
+
const gateAdmit = async (n, { relabel = false } = {}) => {
|
|
1918
|
+
if (!attempts) return true;
|
|
1919
|
+
try {
|
|
1920
|
+
let l = ledgers.get(n) ?? null;
|
|
1921
|
+
if (!l) { l = (await attempts.load?.(n)) ?? null; if (l) ledgers.set(n, l); }
|
|
1922
|
+
if (!l) return true;
|
|
1923
|
+
const hash = (await attempts.hash?.(n)) ?? null, a = admitInput(l, hash, attempts.cfg, { engineVersion: curVersion(), placement: placeOf(n)?.where ?? null, env: curEnvValues() });
|
|
1924
|
+
if (a.ok) { if (a.reason) update({ issue: n, event: "readmit.signature_changed", detail: `readmitted: ${a.reason}`, batch: batchId ?? null }); return true; }
|
|
1925
|
+
const key = `${n}|${hash}|${a.code}`;
|
|
1926
|
+
if (!refusedNoted.has(key)) {
|
|
1927
|
+
refusedNoted.add(key);
|
|
1928
|
+
if (a.code === "escalate") { l = markEscalated(l); ledgers.set(n, l); save(); await attempts.mirror?.(n, l); }
|
|
1929
|
+
await attempts.notify?.({ issue: n, code: a.code, ledger: l, reason: a.reason, relabel });
|
|
1930
|
+
update({ issue: n, event: NO_NEW_INPUT, code: NO_NEW_INPUT, detail: `${NO_NEW_INPUT}: ${a.reason}`, batch: batchId ?? null });
|
|
1931
|
+
}
|
|
1932
|
+
return false;
|
|
1933
|
+
} catch { return true; }
|
|
1934
|
+
};
|
|
1694
1935
|
// #5162: held rows behind `root` return to pending (and the root too when `withRoot`: requeued, counters reset), parents first via the edges.
|
|
1695
1936
|
const releaseHeld = (root, withRoot, why) => {
|
|
1696
1937
|
const moved = withRoot && results.has(root) ? [root] : [];
|
|
@@ -1733,10 +1974,17 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1733
1974
|
}
|
|
1734
1975
|
let why = null;
|
|
1735
1976
|
if (h.envIssue && typeof envIssue?.isClosed === "function") { let c = false; try { c = (await envIssue.isClosed(h.envIssue)) === true; } catch { c = false; } if (c) why = `env issue #${h.envIssue} closed`; }
|
|
1736
|
-
|
|
1977
|
+
// R6/R8: a remote lane runs on a pool agent, so its engine is the agent's, not this host's. While every placeable agent is below the engine
|
|
1978
|
+
// the lane needs, the hold stays; an agent upgrade (not the orchestrator's) is the trigger.
|
|
1979
|
+
const av = r.placement?.where === "remote" ? await agentVersionOf() : null;
|
|
1980
|
+
if (av) {
|
|
1981
|
+
const needMM = vmm2(v), ranV = String(h.sig ?? "").startsWith(`${OUTCOME_CODES.ENV_ENGINE_SKEW}|`) ? h.sig.split("|")[1] : null;
|
|
1982
|
+
if (ranV) { if (vmm2(av) === needMM && vmm2(av) !== vmm2(ranV)) why = `agent engine upgraded v${ranV} → v${av}`; }
|
|
1983
|
+
else if (needMM && vmm2(av) === needMM && v && h.version && v !== h.version) why = `engine version changed v${h.version} → v${v}`;
|
|
1984
|
+
} else if (!why && v && h.version && v !== h.version) why = `engine version changed v${h.version} → v${v}`;
|
|
1737
1985
|
if (why) { /* env issue closed */ } else if (fp && h.env && fp !== h.env) why = "batch env changed (--set-env)";
|
|
1738
1986
|
else if (h.tools?.length && !toolReadmits.has(`${n}|${h.sig}`) && (await missingTools(h.tools))?.length === 0) { why = `${h.tools.join(", ")} now found on the host`; toolReadmits.add(`${n}|${h.sig}`); }
|
|
1739
|
-
if (why) { engineSigs.delete(n); releaseHeld(n, true, `re-admitted: ${why}`); continue; }
|
|
1987
|
+
if (why) { if (!(await gateAdmit(n))) continue; engineSigs.delete(n); releaseHeld(n, true, `re-admitted: ${why}`); continue; }
|
|
1740
1988
|
if (now() - (Number(h.since) || 0) >= ehMaxMs && !/no engine\/env change within/.test(r.detail ?? "")) { // the wait is over: the row stays held (resumable, --requeue), the batch may end
|
|
1741
1989
|
const { waiting, ...rest } = r;
|
|
1742
1990
|
const [head, ...tail] = String(rest.detail ?? "").split("\n");
|
|
@@ -1752,8 +2000,19 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1752
2000
|
if (ro === undefined || running.has(root) || settled.has(root)) continue;
|
|
1753
2001
|
if (restoredHeld.has(root) && ["needs-human", "budget-exceeded"].includes(ro) && typeof issueLabels === "function") { // label removed: requeue the root, its subtree follows
|
|
1754
2002
|
let names = null;
|
|
1755
|
-
try { names = await issueLabels(root); } catch { names = null; }
|
|
1756
|
-
if (Array.isArray(names) && !names.includes("needs-human")) {
|
|
2003
|
+
try { names = await issueLabels(root, { fresh: true }); } catch { names = null; } // #5893: never the memoized read
|
|
2004
|
+
if (Array.isArray(names) && !names.includes("needs-human")) {
|
|
2005
|
+
let sig = null;
|
|
2006
|
+
if (typeof heldFacts === "function") { // the removal must post-date the block; unreadable evidence fails closed
|
|
2007
|
+
let f = null; try { f = (await heldFacts(root)) ?? null; } catch { f = null; }
|
|
2008
|
+
if (!f || !Number.isFinite(f.removedAt) || !Number.isFinite(f.blockedAt) || f.removedAt <= f.blockedAt) continue;
|
|
2009
|
+
const prev = heldSigs.get(root);
|
|
2010
|
+
sig = { sig: `${ro}:${f.askKey ?? ""}`, removedAt: f.removedAt };
|
|
2011
|
+
if (prev && prev.sig === sig.sig && f.removedAt <= prev.removedAt) continue; // identical block, no new removal event
|
|
2012
|
+
}
|
|
2013
|
+
if (await gateAdmit(root, { relabel: true })) { if (sig) heldSigs.set(root, sig); releaseHeld(root, true, "needs-human label removed"); }
|
|
2014
|
+
continue;
|
|
2015
|
+
}
|
|
1757
2016
|
}
|
|
1758
2017
|
if (!dispatchCheck) continue;
|
|
1759
2018
|
let g = null;
|
|
@@ -1812,7 +2071,12 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1812
2071
|
}
|
|
1813
2072
|
if (back.size) save();
|
|
1814
2073
|
};
|
|
1815
|
-
|
|
2074
|
+
// #5985: K is the ceiling; the controller's operating point (and a lower heavy-lane cap) sits under it. A pool with no load/memory data leaves K unchanged.
|
|
2075
|
+
// #5985: light/heavy per lane (its repo's recent cpu_avg from usage-history rows, array or getter); heavy lanes have their own concurrent cap
|
|
2076
|
+
const laneClassOf = (n) => { let rows = null; try { rows = typeof usageRows === "function" ? usageRows() : usageRows; } catch { rows = null; } let repo = repoSlug; try { repo = repoOf?.(n) ?? repoSlug; } catch { repo = repoSlug; } return rows && repo ? classifyRepo(rows, repo) : "light"; };
|
|
2077
|
+
const heavyFull = (n) => { if (laneClassOf(n) !== "heavy") return false; let h = 0; for (const m of running.keys()) if (m !== n && laneClassOf(m) === "heavy") h++; if (h < conc.heavyLimit()) return false; if (!heavyHeldHit) { heavyHeldHit = true; concEmit({ event: "concurrency", change: "heavy-cap", k: conc.operating("light"), ceiling: ceilingK(), factor: "heavy cap", inputs: { heavy_limit: conc.heavyLimit() } }); } return true; };
|
|
2078
|
+
// #5988: a hold expiry releasing several issues re-admits them on a ramp (one more lane per HOLD_RAMP_STEP_MS), as new work ramps, not all at once.
|
|
2079
|
+
const K = () => { conc.setCeiling(ceilingK()); const k = conc.operating("light"); if (!holdRamp) return k; const step = 1 + Math.floor((now() - holdRamp.at) / HOLD_RAMP_STEP_MS); if (step >= k) { holdRamp = null; return k; } return step; };
|
|
1816
2080
|
// #5836: one train poll (throttled): a merged PR becomes a merged row; a red, conflicting or moved-head PR is handed back as a
|
|
1817
2081
|
// needs-human row through the normal settle path, so in-batch recovery requeues a fix lane.
|
|
1818
2082
|
let lastTrainTick = -Infinity;
|
|
@@ -1828,6 +2092,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1828
2092
|
const row = { ...rest, outcome: "merged", detail: e.detail };
|
|
1829
2093
|
results.set(n, row);
|
|
1830
2094
|
if (lifecycle && e.entry.milestone) lifecycleTitles.add(String(e.entry.milestone));
|
|
2095
|
+
await closeOnLane(n, e.entry.lane, row);
|
|
1831
2096
|
if (integration?.onMerged && String(e.entry.lane ?? "").startsWith("milestone/")) {
|
|
1832
2097
|
try { await integration.onMerged(n, { ...row, lane: e.entry.lane }, { milestone: e.entry.milestone }); } catch (err) { update({ issue: n, outcome: "integration", detail: `integration check failed: ${String(err?.message ?? err).slice(0, 300)}` }); }
|
|
1833
2098
|
}
|
|
@@ -1858,6 +2123,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1858
2123
|
firstPass = false;
|
|
1859
2124
|
if (!pending.length && !running.size && !train?.size()) {
|
|
1860
2125
|
if (envWaiting() && !signal?.aborted) { await nap(ehWatchMs); continue; } // #5805: only engine/env holds remain: keep re-checking them
|
|
2126
|
+
if (reconcile && !signal?.aborted && !cancelled && !tripped) { await nap(reconcile.everyMs ?? RECONCILE_MS); continue; } // #5978: a standing order stays open: the next reconcile may bring issues
|
|
1861
2127
|
break;
|
|
1862
2128
|
}
|
|
1863
2129
|
// Resolve skips first: a dependency that finished unsatisfied (or never can) skips its dependents.
|
|
@@ -1887,6 +2153,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1887
2153
|
baseHit.clear();
|
|
1888
2154
|
refreshHeld();
|
|
1889
2155
|
refreshPause();
|
|
2156
|
+
await authPass(); // #5988
|
|
1890
2157
|
await refreshBlocked();
|
|
1891
2158
|
await refreshBaseWaits();
|
|
1892
2159
|
checkGates();
|
|
@@ -1902,15 +2169,28 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1902
2169
|
if (pfNoted.size && !keys.size) update({ issue: null, outcome: "preflight", detail: "preflight cleared; admissions resumed" });
|
|
1903
2170
|
pfNoted = keys;
|
|
1904
2171
|
}
|
|
2172
|
+
// #5992: one dispatcher probe per (repo, base sha) while lanes wait; red holds every admission but the attributed fixer's.
|
|
2173
|
+
if (baseProbe && !tripped && !cancelled && !holdUntil && pending.length) {
|
|
2174
|
+
let v = null;
|
|
2175
|
+
try { v = await baseProbe(); } catch { v = null; }
|
|
2176
|
+
if (v?.red) {
|
|
2177
|
+
const issue = Number.isInteger(v.att?.issue) ? v.att.issue : null;
|
|
2178
|
+
const detail = `base.red: base ${String(v.sha).slice(0, 12)} is red on ${(v.commands ?? []).join(", ") || "a guard command"}${v.att ? `; last change ${String(v.att.sha).slice(0, 12)}${issue ? ` (#${issue})` : ""}` : ""}; admissions paused until the base moves`;
|
|
2179
|
+
if (baseRedHold?.sha !== v.sha) update({ issue: null, outcome: "preflight", code: "base.red", detail });
|
|
2180
|
+
baseRedHold = { sha: v.sha, issue, detail };
|
|
2181
|
+
} else if (baseRedHold) { update({ issue: null, outcome: "preflight", detail: "base.red cleared; admissions resumed" }); baseRedHold = null; }
|
|
2182
|
+
}
|
|
1905
2183
|
let planPass = false; // #5831: the plan pass evaluates every other gate but the in-batch dependencies
|
|
1906
2184
|
await gateEnvSigs(); // #5755
|
|
1907
2185
|
const isReady = (n) => {
|
|
1908
2186
|
if (pfAll || (pfRemote && isRemote(n))) return false;
|
|
2187
|
+
if (baseRedHold && n !== baseRedHold.issue) return false; // #5992
|
|
1909
2188
|
if (opPause) { pauseHit = true; return false; } // #5975: every admission path (dependency merge, env/engine re-admit, requeue, add, recovery) ends here
|
|
1910
2189
|
if (opHeld.has(n)) { opHeldHit.add(n); return false; }
|
|
1911
2190
|
if (blocked.has(n)) { blockedHit.add(n); return false; } // #4773
|
|
1912
2191
|
if (baseHeld.has(n)) { baseHit.add(n); return false; } // #5031
|
|
1913
2192
|
if (!((notBefore.get(n) ?? 0) <= t && (planPass || edges(n).every((d) => results.has(d) && SATISFIED.has(results.get(d).outcome))))) return false;
|
|
2193
|
+
if (heavyFull(n)) return false; // #5985: a wave of heavy (test-suite) lanes never takes the whole ceiling
|
|
1914
2194
|
if (integration?.holds) {
|
|
1915
2195
|
let why = null;
|
|
1916
2196
|
try { why = integration.holds(n, { lane: lanes.get(n)?.lane ?? null }); } catch { why = null; }
|
|
@@ -1950,6 +2230,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1950
2230
|
for (const n of want) wanted.add(n);
|
|
1951
2231
|
for (const n of ready) {
|
|
1952
2232
|
if (running.size >= K()) break;
|
|
2233
|
+
if (heavyFull(n)) continue; // #5985
|
|
1953
2234
|
const g = grant(n, wanted);
|
|
1954
2235
|
if (g === "busy") continue; // #4481
|
|
1955
2236
|
if (!g && (notBefore.get(n) ?? 0) > t) continue; // #5592: per-issue wait, not a full host queue
|
|
@@ -1959,6 +2240,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1959
2240
|
} else if (!tripped && !cancelled && !holdUntil) {
|
|
1960
2241
|
for (const n of rank(pending.filter(isReady))) {
|
|
1961
2242
|
if (running.size >= K()) break;
|
|
2243
|
+
if (heavyFull(n)) continue; // #5985
|
|
1962
2244
|
if (grant(n, new Set()) === true) { pending.splice(pending.indexOf(n), 1); start(n); started++; }
|
|
1963
2245
|
}
|
|
1964
2246
|
}
|
|
@@ -1977,6 +2259,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1977
2259
|
try { sc = rank(pending.filter((n) => stackAdmissible({ n, edges: edges(n), results, pending, running, prReady, stackedTried, satisfied: SATISFIED }) && isReady(n))); } finally { planPass = false; }
|
|
1978
2260
|
for (const n of sc) {
|
|
1979
2261
|
if (running.size >= K()) break;
|
|
2262
|
+
if (heavyFull(n)) continue; // #5985
|
|
1980
2263
|
if (lanes.get(n)?.ok === false || (notBefore.get(n) ?? 0) > t) continue;
|
|
1981
2264
|
const so = stackAdmissible({ n, edges: edges(n), results, pending, running, prReady, stackedTried, satisfied: SATISFIED });
|
|
1982
2265
|
if (!so || grant(n, new Set()) !== true) continue;
|
|
@@ -1996,6 +2279,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1996
2279
|
try { cands = rank(pending.filter((n) => planAdmissible({ n, edges: edges(n), results, pending, running, planTried, satisfied: SATISFIED }) && isReady(n))); } finally { planPass = false; }
|
|
1997
2280
|
for (const n of cands) {
|
|
1998
2281
|
if (running.size >= K()) break;
|
|
2282
|
+
if (heavyFull(n)) continue; // #5985
|
|
1999
2283
|
if (lanes.get(n)?.ok === false || (notBefore.get(n) ?? 0) > t) continue;
|
|
2000
2284
|
if (grant(n, new Set()) !== true) continue;
|
|
2001
2285
|
pending.splice(pending.indexOf(n), 1);
|
|
@@ -2010,6 +2294,17 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
2010
2294
|
if (reg) withdrawExcept(wanted);
|
|
2011
2295
|
// #4685: a breaker tripped only by link failures (a router restart) closes itself after a cooldown
|
|
2012
2296
|
if (tripped?.transport && now() - tripped.at >= TRANSPORT_COOLDOWN_MS) { tripped = null; errorTimes = []; transportErrors = 0; save(); }
|
|
2297
|
+
// #5978: a standing order's breaker closes itself after a cooldown when the failures were environmental and the pool is healthy
|
|
2298
|
+
if (tripped && !tripped.transport) { // #6042: every batch, not only a standing order
|
|
2299
|
+
let healthy = true; try { healthy = reconcile?.poolHealthy ? reconcile.poolHealthy() !== false : true; } catch { healthy = true; }
|
|
2300
|
+
const d = decideAutoReset({ tripped, now: now(), cooldownMs: BREAKER_COOLDOWN_MS, environmental: tripped.environmental === true, poolHealthy: healthy });
|
|
2301
|
+
if (d.reset) {
|
|
2302
|
+
tripped = null; errorTimes = []; transportErrors = 0; save();
|
|
2303
|
+
decided({ issue: null, what: `circuit breaker reset automatically: ${d.why}`, why: "FORGE:DECISION: the engine-errors were environmental (VM restart, mirror, network) and the pool is healthy again", alternative: "forgedock orchestrate --clear-breaker" });
|
|
2304
|
+
update({ issue: null, outcome: "breaker", detail: `circuit breaker cleared automatically: ${d.why}` });
|
|
2305
|
+
continue;
|
|
2306
|
+
}
|
|
2307
|
+
}
|
|
2013
2308
|
// #5947: --clear-breaker on a schedd-hosted batch reaches this runner through the batch's request file
|
|
2014
2309
|
if (getClearBreaker) { // #5964: time-scoped; the request is consumed only after the decision, so a long pass never loses it
|
|
2015
2310
|
let req = null; try { req = getClearBreaker(); } catch { req = null; }
|
|
@@ -2022,6 +2317,9 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
2022
2317
|
if (d.clear && wasTripped) continue; // admission ran before this check: re-run the pass so the cleared batch resumes instead of falling to the "nothing runnable" skip
|
|
2023
2318
|
}
|
|
2024
2319
|
}
|
|
2320
|
+
// #6042: a breaker pauses admission; it ends the run only when nothing can clear it (a non-environmental trip with no hosted clear channel)
|
|
2321
|
+
const breakerClearable = Boolean(tripped && pending.length && !cancelled && !budgetStop && !signal?.aborted && (tripped.environmental || tripped.transport || getClearBreaker));
|
|
2322
|
+
if (tripped && !running.size && breakerClearable) { await nap(pollMs); continue; }
|
|
2025
2323
|
if (tripped && !running.size) { await drainAdds(); break; } // breaker: let running lanes finish, keep the rest pending for a resume
|
|
2026
2324
|
if (cancelled && !running.size) { await drainAdds(); break; } // #4376: cancel: the rest end held for a resume
|
|
2027
2325
|
if (budgetStop && !running.size) { await drainAdds(); break; } // execution budget (stop): the same, the rest end held
|
|
@@ -2050,7 +2348,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
2050
2348
|
if (pending.some((n) => remoteCapped.has(n))) wake = Math.min(wake ?? pollMs, pollMs); // #5138: a live --set-max-remote raise
|
|
2051
2349
|
if ((getAdded || getRequeued || (getChildren && addsEpicChildren(autoChildren?.mode))) && running.size) wake = Math.min(wake ?? pollMs, pollMs); // #4408/#4550: an add or requeue while only lanes run
|
|
2052
2350
|
if (getRequeued && pending.some((n) => quota.has(n) || notBefore.has(n))) wake = Math.min(wake ?? pollMs, pollMs); // #5203: a --requeue releasing a quota pause
|
|
2053
|
-
if ((pfAll || pfRemote) && pending.length) wake = Math.min(wake ?? pollMs, pollMs); // #4866
|
|
2351
|
+
if ((pfAll || pfRemote || baseRedHold) && pending.length) wake = Math.min(wake ?? pollMs, pollMs); // #4866
|
|
2054
2352
|
if (baseWait && pending.length && baseHeld.size) wake = Math.min(wake ?? pollMs, pollMs); // #5031: a landed commit releases on the next tick
|
|
2055
2353
|
if (getBlocked && pending.length && blockedHit.size) wake = Math.min(wake ?? pollMs, pollMs); // #4773: a removed label releases on the next tick
|
|
2056
2354
|
if (getHeld && running.size) wake = Math.min(wake ?? pollMs, pollMs); // #4592: a release while only lanes run
|
|
@@ -2058,7 +2356,8 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
2058
2356
|
if (running.size && watchable()) wake = Math.min(wake ?? WATCH_EVERY_MS, WATCH_EVERY_MS); // #4595: re-check the blockers of skipped rows
|
|
2059
2357
|
if (running.size && envWaiting()) wake = Math.min(wake ?? ehWatchMs, ehWatchMs); // #5805: re-check engine/env holds while lanes run
|
|
2060
2358
|
if (train?.size()) wake = Math.min(wake ?? trainEveryMs, Math.max(0, trainEveryMs - (now() - lastTrainTick))); // #5836
|
|
2061
|
-
if (
|
|
2359
|
+
if (reconcile && running.size) wake = Math.min(wake ?? reconcile.everyMs ?? RECONCILE_MS, reconcile.everyMs ?? RECONCILE_MS); // #5978
|
|
2360
|
+
if (tripped) wake = getClearBreaker || tripped.environmental || tripped.transport ? Math.min(wake ?? pollMs, pollMs) : null;
|
|
2062
2361
|
if (getCancelled && running.size && (!cancelled || [...running.keys()].some((n) => { const x = stopSent.get(n); return x && !(x.accepted && x.reported); }))) wake = Math.min(wake ?? pollMs, pollMs); // #5241: a cancel keeps polling a lane whose stop is unconfirmed // #4376: notice a cancel while lanes run
|
|
2063
2362
|
if (running.size) {
|
|
2064
2363
|
if (wake === null) await race(running.values());
|
|
@@ -2066,7 +2365,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
2066
2365
|
} else if (started) continue; // only lane-refused rows settled (synchronously): re-resolve skips first
|
|
2067
2366
|
else if (train?.size()) await nap(wake ?? trainEveryMs); // #5836: only train-held PRs are left: poll the train
|
|
2068
2367
|
else if (pending.length && offered.size) await nap(wake); // waiting for a host slot
|
|
2069
|
-
else if (pending.length && (pfAll || pfRemote)) await nap(Math.min(wake ?? pollMs, pollMs)); // #4866: a failing lane preflight is re-checked on the next poll
|
|
2368
|
+
else if (pending.length && (pfAll || pfRemote || baseRedHold)) await nap(Math.min(wake ?? pollMs, pollMs)); // #4866: a failing lane preflight is re-checked on the next poll
|
|
2070
2369
|
else if (pending.length && blockedHit.size) await nap(wake ?? pollMs); // #4773: only blocked issues wait: poll for the label's removal
|
|
2071
2370
|
else if (pending.length && baseHit.size) await nap(wake ?? pollMs); // #5031: only issues waiting for a base commit: poll for it
|
|
2072
2371
|
else if (pending.length && waits.length) await nap(Math.min(wake, getCancelled ? pollMs : Infinity)); // wake is poll-capped by a hold or a live K; #4454: nap wakes on a stop
|