forgedock 1.66.0 → 1.67.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 +2 -0
- package/bin/engine/outcome-codes.mjs +1 -0
- package/bin/engine-cli.mjs +96 -17
- package/bin/forgedock.mjs +7 -0
- package/bin/help-text.mjs +3 -3
- package/bin/introspect-schedule.mjs +98 -0
- package/bin/introspect-schedule.test.mjs +67 -0
- package/bin/lean/advisory.test.mjs +49 -0
- package/bin/lean/amendment-schema.mjs +31 -0
- package/bin/lean/attempts.mjs +159 -0
- package/bin/lean/attempts.test.mjs +127 -0
- package/bin/lean/basered.mjs +55 -0
- package/bin/lean/basered.test.mjs +68 -1
- package/bin/lean/batch-health.mjs +3 -0
- package/bin/lean/batch-health.test.mjs +16 -0
- package/bin/lean/batch.mjs +45 -0
- package/bin/lean/batch.test.mjs +54 -3
- package/bin/lean/capwait.mjs +14 -3
- package/bin/lean/capwait.test.mjs +20 -0
- package/bin/lean/clear-breaker.mjs +14 -0
- package/bin/lean/commentstate.mjs +41 -0
- package/bin/lean/commentstate.test.mjs +32 -0
- package/bin/lean/concurrency.mjs +89 -0
- package/bin/lean/concurrency.test.mjs +113 -0
- package/bin/lean/conformance.e2e.test.mjs +4 -2
- package/bin/lean/conformance.mjs +35 -3
- package/bin/lean/conformance.test.mjs +52 -0
- package/bin/lean/efficiency.mjs +162 -0
- package/bin/lean/efficiency.test.mjs +79 -0
- package/bin/lean/execution.mjs +31 -13
- package/bin/lean/execution.test.mjs +46 -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/lean.mjs +123 -24
- package/bin/lean/lean.test.mjs +137 -46
- package/bin/lean/liveness.mjs +37 -0
- package/bin/lean/liveness.test.mjs +33 -0
- package/bin/lean/orchestrate-attempts.test.mjs +74 -0
- package/bin/lean/orchestrate-pause.test.mjs +23 -0
- package/bin/lean/orchestrate-reconcile.test.mjs +147 -0
- package/bin/lean/orchestrate.mjs +170 -26
- package/bin/lean/phaseledger.mjs +6 -0
- package/bin/lean/phaseledger.test.mjs +13 -1
- package/bin/lean/prompts.mjs +6 -10
- package/bin/lean/reconcile.mjs +90 -0
- package/bin/lean/recurrence.mjs +38 -2
- package/bin/lean/recurrence.test.mjs +56 -1
- package/bin/lean/sandbox-remote.mjs +33 -2
- 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 +34 -2
- package/bin/lean/schedd.test.mjs +55 -2
- package/bin/lean/slo.mjs +126 -0
- package/bin/lean/slo.test.mjs +112 -0
- package/bin/lean/statuscomment.mjs +37 -0
- package/bin/lean/statuscomment.test.mjs +48 -1
- package/bin/lean/verify.mjs +2 -1
- package/bin/pool/agent.mjs +2 -2
- package/bin/pool/cli.mjs +16 -1
- package/bin/pool/lane-tools.mjs +21 -0
- 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/commands/orchestrate.md +21 -18
- package/docs/OUTCOME-CODES.md +1 -0
- package/package.json +1 -1
- package/scripts/check-devdocs-freshness.sh +1 -1
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";
|
|
@@ -141,6 +142,8 @@ import { formatOverload } from "./hostload.mjs";
|
|
|
141
142
|
import { normalizeStacking, planAdmissible, stackAdmissible } from "./stacking.mjs";
|
|
142
143
|
import { lackedTools } from "./toolplace.mjs";
|
|
143
144
|
import { openPrerequisites } from "./prereq.mjs";
|
|
145
|
+
import { makeController, classifyRepo, formatConcurrency } from "./concurrency.mjs";
|
|
146
|
+
import { admitInput, breach, recordFailure, markEscalated, NO_NEW_INPUT } from "./attempts.mjs";
|
|
144
147
|
|
|
145
148
|
// A dependency that finished like this no longer blocks its dependents.
|
|
146
149
|
const SATISFIED = new Set(["merged", "invalid"]);
|
|
@@ -148,6 +151,7 @@ const DEFAULT_TRAIN_EVERY_MS = 30000; // #5836: merge-train poll period
|
|
|
148
151
|
// #5836: a lane that ended pr-ready is waiting on the merge train, not failed: its dependents wait
|
|
149
152
|
const WAITING_ON_TRAIN = (row) => row?.outcome === "pr-ready";
|
|
150
153
|
// #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.
|
|
154
|
+
const ATTEMPT_FAILED = ["needs-human", "engine-error", "budget-exceeded", "failed"]; // #5986: final lane outcomes that count as a failed attempt
|
|
151
155
|
const HOLD_ROOT = new Set(["needs-human", "engine-error", "deferred", "budget-exceeded", "held"]);
|
|
152
156
|
/** #5162: members of a real dependency cycle (a nontrivial SCC or a self-loop) among `nodes`; `edgesOf(n)` lists n's dependencies. */
|
|
153
157
|
export function cyclicNodes(nodes, edgesOf) {
|
|
@@ -183,7 +187,7 @@ export const HOST_BUSY_RETRY_S = 60;
|
|
|
183
187
|
// #4528: a busy host or a full sandbox pool is a wait, not a failure: requeued after its retry-in, never capped.
|
|
184
188
|
// A lane that could not be resolved because gh/git failed (network blip) is the same kind of wait (#4791).
|
|
185
189
|
// #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"]);
|
|
190
|
+
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
191
|
export const POOL_OFFLINE_ALERT_MIN = 10;
|
|
188
192
|
// #5112: `sandbox.capacity` deferrals of one issue after which `execution.fallback_local` runs it on the host (headroom permitting).
|
|
189
193
|
export const CAPACITY_FALLBACK_AFTER = 3;
|
|
@@ -336,12 +340,12 @@ const toMap = (o) => new Map(Object.entries(o ?? {}).map(([k, v]) => [Number(k),
|
|
|
336
340
|
* @returns {Promise<Array<{issue:number, outcome:string, pr:?number, cost_usd:number, minutes:number, detail?:string}>>}
|
|
337
341
|
*/
|
|
338
342
|
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,
|
|
343
|
+
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,
|
|
344
|
+
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,
|
|
345
|
+
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, suspendLane = null, stopRetryMs = STOP_RETRY_MS, stopTimeoutMs = STOP_TIMEOUT_MS,
|
|
342
346
|
estimate = null, starveMs = DEFAULT_STARVE_MS, setupConcurrency = DEFAULT_SETUP_CONCURRENCY, signal = null, dispatchCheck = null, syncParked = null, syncEveryMs = DEFAULT_SYNC_EVERY_MS, lifecycle = null,
|
|
343
347
|
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 }) {
|
|
348
|
+
train = null, trainEveryMs = DEFAULT_TRAIN_EVERY_MS, attempts = null }) {
|
|
345
349
|
const saved = store?.load?.() ?? null;
|
|
346
350
|
if (train && saved?.train) train.restore(saved.train); // #5836: the merge train resumes with the batch
|
|
347
351
|
const order = saved ? [...saved.order] : [];
|
|
@@ -351,6 +355,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
351
355
|
const crossSeen = new Set(saved?.crossSeen ?? []);
|
|
352
356
|
const results = toMap(saved?.results); // issue -> final row
|
|
353
357
|
const running = new Map(); // issue -> promise
|
|
358
|
+
const keptBoxes = toMap(saved?.kept); // #6008: issue -> {issue, since, phase}: sandboxes kept for adopt (no dispatcher lease)
|
|
354
359
|
const runRecs = toMap(saved?.running); // issue -> {startedAt, lane, pid?}: persisted so a restart can adopt the lane
|
|
355
360
|
const pending = [...(saved?.pending ?? [])];
|
|
356
361
|
const notBefore = toMap(saved?.notBefore);
|
|
@@ -370,6 +375,8 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
370
375
|
// 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
376
|
const envSigs = toMap(saved?.envSigs);
|
|
372
377
|
const engineSigs = toMap(saved?.engineSigs);
|
|
378
|
+
const readmit = toMap(saved?.readmit); // #5978: re-admission policy state (backoff step, version and base seen) per ended issue
|
|
379
|
+
const ledgers = toMap(saved?.attempts); // #5986: issue -> attempts ledger; never cleared by releaseHeld, --requeue or --set-env (see attempts.mjs)
|
|
373
380
|
const deterministic = new Set(saved?.deterministicSigs ?? []);
|
|
374
381
|
const toolReadmits = new Set(saved?.toolReadmits ?? []);
|
|
375
382
|
const ehMaxMs = Number(envHold?.maxMs) > 0 ? Number(envHold.maxMs) : ENV_HOLD_MAX_MS;
|
|
@@ -405,6 +412,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
405
412
|
const quota = toMap(saved?.quota); // issue -> {cost_usd, minutes, resumeAt (epoch ms), rotations}
|
|
406
413
|
let tripped = saved?.breaker ?? null;
|
|
407
414
|
let pfAll = false, pfRemote = false, pfNoted = new Set(); // #4866: lane preflight holds
|
|
415
|
+
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
416
|
let opHeld = new Set(); // #4592: operator-held issues this pass (the batch `hold` file is the authority)
|
|
409
417
|
const opHeldHit = new Set(); // held issues that were pending this pass
|
|
410
418
|
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
|
|
@@ -493,6 +501,10 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
493
501
|
const everRelabelled = new Set(saved?.relabelled ?? []); // #4656: issues the runner already relabelled; never parked on top
|
|
494
502
|
const relabelled = new Set(saved?.relabelled ?? []); // #4315: queued recoveries relabelled needs-human when a batch stopped
|
|
495
503
|
// #4267: decisions are recorded, never awaited: a failing or slow recorder cannot block the batch.
|
|
504
|
+
// #5985: the controller moves are persisted to log.jsonl with their inputs (the post-deploy check reads them)
|
|
505
|
+
const conc = makeController({ ceiling: parallel, now });
|
|
506
|
+
let heavyHeldHit = false;
|
|
507
|
+
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
508
|
const decided = (d) => { try { Promise.resolve(decide?.(d)).catch(() => {}); } catch { /* best effort */ } };
|
|
497
509
|
const firstLine = (x) => String(x ?? "").split("\n")[0].slice(0, 300);
|
|
498
510
|
|
|
@@ -500,7 +512,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
500
512
|
let halted = false; // #4454: stopped by `signal`; the batch's state is no longer this process's to write
|
|
501
513
|
const save = () => {
|
|
502
514
|
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),
|
|
515
|
+
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
516
|
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
517
|
prefilter: toObj(checked), errorTimes, breaker: tripped, ...(agentRestarts.length ? { agentRestarts, lostRequeued: [...lostOnce] } : {}), ...(budget ? { classes: toObj(classes), dispatch: { ...dispatch } } : {}),
|
|
506
518
|
...(reg ? { priorities: toObj(priorities) } : {}), ...(sandboxUse.size ? { sandbox: toObj(sandboxUse) } : {}),
|
|
@@ -510,9 +522,14 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
510
522
|
...(requeueApplied.size ? { requeueApplied: [...requeueApplied], requeued: toObj(requeuedInfo) } : {}),
|
|
511
523
|
...(relabelled.size ? { relabelled: [...relabelled] } : {}), ...(cancelled ? { cancelled } : {}), ...(train ? { train: train.snapshot() } : {}),
|
|
512
524
|
...(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) } : {}) });
|
|
525
|
+
...(engineSigs.size ? { engineSigs: toObj(engineSigs) } : {}), ...(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) } : {}) });
|
|
514
526
|
};
|
|
515
527
|
const update = (row) => { store?.log?.(row); onUpdate(row); };
|
|
528
|
+
// #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.
|
|
529
|
+
const closeOnLane = async (n, lane, row) => {
|
|
530
|
+
if (!reconcile?.closeIssue || !closesManually(lane)) return;
|
|
531
|
+
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) }); }
|
|
532
|
+
};
|
|
516
533
|
/** #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
534
|
const fileEnvIssue = async ({ sig, code, issue, tools, evidence }) => {
|
|
518
535
|
const e = envSigs.get(sig) ?? { issues: [], number: null };
|
|
@@ -780,7 +797,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
780
797
|
let cap = null, probeFailed = false;
|
|
781
798
|
try { cap = remote.capacity?.() ?? null; } catch { probeFailed = true; }
|
|
782
799
|
// #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);
|
|
800
|
+
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
801
|
// #4788: zero live agents for longer than `remote.poolOfflineMin` (default 10): one loud batch event, none while online > 0.
|
|
785
802
|
if (cap && cap.online === 0) {
|
|
786
803
|
poolOfflineSince ??= now();
|
|
@@ -800,10 +817,11 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
800
817
|
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
818
|
alternative: "keep deferring until a pool slot frees" });
|
|
802
819
|
}
|
|
803
|
-
} else if (cap && Number.isInteger(cap.free)) {
|
|
820
|
+
} else if (cap && (Number.isInteger(cap.free) || capWait.conditional(n, cap))) {
|
|
804
821
|
if (cap.at !== capAt) { capAt = cap.at; capAdmits = 0; }
|
|
805
|
-
|
|
806
|
-
if (
|
|
822
|
+
// #5985: a refusal's named condition (load < 1.0, free mem > floor) and the per-lane refusal hold gate the relaunch, not the timer
|
|
823
|
+
if (capWait.blocked(n, cap) || conc.holding(n, cap)) { notBefore.set(n, now() + Math.max(pollMs, 1)); return false; }
|
|
824
|
+
if (Number.isInteger(cap.free) && capAdmits >= cap.free && remoteRun.size < remoteMax()) { notBefore.set(n, now() + Math.max(pollMs, 1)); return false; }
|
|
807
825
|
}
|
|
808
826
|
if (p.where === "remote" && remoteRun.size < remoteMax()) { remoteCapped.delete(n); capWait.admitted(n); remoteRun.add(n); capAdmits++; placed.set(n, p); return true; }
|
|
809
827
|
if (p.where === "remote" && !remote.fallbackLocal) { remoteCapped.add(n); return false; }
|
|
@@ -849,14 +867,16 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
849
867
|
const requeue = (n, delayMs) => { pending.push(n); enqueued.set(n, now()); if (delayMs > 0) notBefore.set(n, now() + delayMs); else notBefore.delete(n); };
|
|
850
868
|
const TRANSPORT_COOLDOWN_MS = 5 * 60000;
|
|
851
869
|
const netTransients = new Map(); // #5947: issue -> net.transient deferrals (backoff step)
|
|
870
|
+
const envDetails = []; // #5978: the details of the recent engine-errors, for the breaker auto-reset
|
|
852
871
|
let transportErrors = 0; // #4685: engine-errors in the current window that were link failures
|
|
853
872
|
const noteEngineError = (detail = "") => {
|
|
854
873
|
if (!breaker) return;
|
|
855
874
|
const t = now(), windowMs = breaker.window_min * 60000;
|
|
856
875
|
errorTimes = [...errorTimes.filter((x) => t - x < windowMs), t];
|
|
876
|
+
envDetails.push(detail); if (envDetails.length > breaker.errors) envDetails.shift();
|
|
857
877
|
transportErrors = isTransientEngineError(detail) ? Math.min(transportErrors + 1, errorTimes.length) : 0;
|
|
858
878
|
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` };
|
|
879
|
+
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
880
|
update({ issue: null, outcome: "breaker", detail: tripped.detail });
|
|
861
881
|
}
|
|
862
882
|
return t;
|
|
@@ -901,6 +921,24 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
901
921
|
if (changed) save();
|
|
902
922
|
};
|
|
903
923
|
|
|
924
|
+
// #5986: a failed lane lands in the issue's ledger; a lifetime-budget breach escalates once (FORGE:ESCALATION, needs-human) and parks the row.
|
|
925
|
+
const recordAttempt = async (n, row, r) => {
|
|
926
|
+
try {
|
|
927
|
+
const hash = (await attempts.hash?.(n)) ?? null;
|
|
928
|
+
let l = ledgers.get(n) ?? (await attempts.load?.(n)) ?? null;
|
|
929
|
+
l = recordFailure(l, { signature: failureSignature(row.code ?? r?.code, row.detail), hash, spend: Number(row.cost_usd) || 0, run: r?.runUrl ?? null });
|
|
930
|
+
const b = breach(l, attempts.cfg);
|
|
931
|
+
if (b && !l.escalated) {
|
|
932
|
+
l = markEscalated(l);
|
|
933
|
+
await attempts.notify?.({ issue: n, code: "escalate", ledger: l, reason: b.detail });
|
|
934
|
+
if (row.outcome !== "needs-human") { row.detail = `attempts.exhausted: ${b.detail}\n${String(row.detail ?? "")}`; row.outcome = "needs-human"; }
|
|
935
|
+
decided({ issue: n, what: `escalated #${n} to a person: ${b.detail}`, why: "lifetime attempt budget (#5986)", alternative: "run another lane on the same input" });
|
|
936
|
+
}
|
|
937
|
+
ledgers.set(n, l);
|
|
938
|
+
const comments = await attempts.mirror?.(n, l);
|
|
939
|
+
if (Number.isInteger(comments)) ledgers.set(n, { ...l, comments });
|
|
940
|
+
} catch { /* the ledger is best effort: a failed write never changes the lane's outcome */ }
|
|
941
|
+
};
|
|
904
942
|
// Apply one lane's result: requeue it (deferred, dependency-open, engine-error) or record its final row.
|
|
905
943
|
const settleLane = async (n, r, rec, pf) => {
|
|
906
944
|
if (halted) return; // #4454: a resume adopts the lane and settles it
|
|
@@ -1043,11 +1081,15 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1043
1081
|
const pol = deferPolicy(r, { now: now(), deferrals: deferrals.get(n) ?? 0, maxDeferrals });
|
|
1044
1082
|
let capGated = false; // #4909: the pool reports free slots, so the slot (not the retry-in timer) gates the relaunch
|
|
1045
1083
|
if (r?.code === "sandbox.unreachable") notePool(true, r.detail ?? "sandbox unreachable");
|
|
1084
|
+
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)
|
|
1085
|
+
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 */ }
|
|
1086
|
+
}
|
|
1046
1087
|
if (r?.code === "sandbox.capacity") {
|
|
1047
|
-
capWait.refused(n);
|
|
1088
|
+
capWait.refused(n, r.reason ?? null);
|
|
1089
|
+
concEmit(conc.refused({ issue: n, code: r.code, reason: r.reason, live: r.live ?? null })); // #5985
|
|
1048
1090
|
if (r.detail) capReasons.set(n, String(r.detail).slice(0, 300));
|
|
1049
1091
|
capDefers.set(n, (capDefers.get(n) ?? 0) + 1); // #5112: counted for the fallback_local capacity fallback
|
|
1050
|
-
try {
|
|
1092
|
+
try { const c = remote?.capacity?.(); capGated = Number.isInteger(c?.free) || capWait.conditional(n, c); } catch { capGated = false; }
|
|
1051
1093
|
}
|
|
1052
1094
|
if (!pol.capped) {
|
|
1053
1095
|
if (!pol.host && !pol.hold) deferrals.set(n, (deferrals.get(n) ?? 0) + 1);
|
|
@@ -1221,7 +1263,8 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1221
1263
|
// #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
1264
|
const noHostRecovery = !hostFallbackOn() && row.placement?.where === "remote" && [OUTCOME_CODES.ENV_CAPABILITY_REMOTE, OUTCOME_CODES.ENV_TOOL_MISSING].includes(row.code);
|
|
1223
1265
|
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
|
-
|
|
1266
|
+
// #5979: failure.repeated is a typed park (not in RECOVERABLE_CODES): never relaunched, reported parked below
|
|
1267
|
+
if (!repeatEnv && !noHostRecovery && !sameHostReplay && row.code !== OUTCOME_CODES.FAILURE_REPEATED && classifyNeedsHuman(facts) === "recoverable" && used < max) {
|
|
1225
1268
|
// #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
1269
|
const free = !prior && r?.toolNoRecipe === true && row.code === OUTCOME_CODES.ENV_TOOL_MISSING && row.placement?.where === "remote" && !freeRecovered.has(n);
|
|
1227
1270
|
const code = recoveryCodeOf(facts), attempt = used + 1;
|
|
@@ -1250,8 +1293,10 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1250
1293
|
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
1294
|
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
1295
|
}
|
|
1296
|
+
if (attempts && ATTEMPT_FAILED.includes(row.outcome)) await recordAttempt(n, row, r); // #5986
|
|
1253
1297
|
results.set(n, row);
|
|
1254
1298
|
if (row.outcome === "merged" && lifecycle && r?.milestone) lifecycleTitles.add(String(r.milestone)); // #4657
|
|
1299
|
+
if (row.outcome === "merged") await closeOnLane(n, rec?.lane ?? r?.lane, row);
|
|
1255
1300
|
if (row.outcome === "merged" && integration?.onMerged && String(rec?.lane ?? r?.lane ?? "").startsWith("milestone/")) {
|
|
1256
1301
|
// #4667: counts the merge toward the milestone's integration run; an error is a row, never the outcome.
|
|
1257
1302
|
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 +1314,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1269
1314
|
// #5437: a lane's post-run bookkeeping (r.postRun) starts once its slot is free; the batch waits for it before it ends.
|
|
1270
1315
|
const postRuns = new Set();
|
|
1271
1316
|
const settle = async (n, r, rec, pf) => {
|
|
1317
|
+
if (r?.kept) keptBoxes.set(n, r.kept); // #6008
|
|
1272
1318
|
await settleLane(n, r, rec, pf);
|
|
1273
1319
|
if (typeof r?.postRun !== "function") return;
|
|
1274
1320
|
const p = Promise.resolve().then(() => r.postRun()).catch(() => {}).finally(() => postRuns.delete(p));
|
|
@@ -1300,7 +1346,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1300
1346
|
heads.delete(n); enqueued.delete(n); busyNoted.delete(n);
|
|
1301
1347
|
const rec = { startedAt: now(), ...(plan ? { plan: true } : {}), ...(stackedOn ? { stackedOn } : {}), ...(queueMs != null ? { queueMs } : {}), ...(lane ? { lane } : {}), ...(remoteRun.has(n) ? { remote: true } : {}), ...(pl ? { placement: pl } : {}) };
|
|
1302
1348
|
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();
|
|
1349
|
+
runRecs.set(n, rec); keptBoxes.delete(n); notBefore.delete(n); capReasons.delete(n); save();
|
|
1304
1350
|
track(n, (async () => {
|
|
1305
1351
|
// Pre-filter once per issue (a requeued issue is not re-checked); fail-open: an error means a normal lane.
|
|
1306
1352
|
if (prefilter && !checked.has(n)) { let pf = null; try { pf = await prefilter(n, lane); } catch { pf = null; } checked.set(n, pf); save(); }
|
|
@@ -1417,11 +1463,47 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1417
1463
|
if (typeof onExit === "function") { try { onExit(relabelQueued); } catch { /* best effort */ } }
|
|
1418
1464
|
|
|
1419
1465
|
// #4408: issues added to the running batch; returns how many joined. Re-reading the cumulative list is a no-op.
|
|
1466
|
+
// #5978: standing order (`--select`): one reconcile per interval. Matching open issues and engine-filed env.* issues join through
|
|
1467
|
+
// the `getAdded` path below; closed or moved pending issues leave; ended deferred/held/engine-error/conformance rows are requeued
|
|
1468
|
+
// through `drainRequeues` by policy (reconcile.mjs). Same DAG, priority and lane rules as an operator `--add`/`--requeue`.
|
|
1469
|
+
let nextReconcile = 0, parkedDigest = "";
|
|
1470
|
+
const selFresh = [], autoRequeues = [], selMatched = new Set(); // #6022: issues the selector has matched in this run
|
|
1471
|
+
const reconcileTick = async () => {
|
|
1472
|
+
if (!reconcile) return;
|
|
1473
|
+
const t = now();
|
|
1474
|
+
if (t < nextReconcile) return;
|
|
1475
|
+
nextReconcile = t + (reconcile.everyMs ?? RECONCILE_MS);
|
|
1476
|
+
let open = null;
|
|
1477
|
+
try { open = await reconcile.list(); } catch { open = null; } // a failed read never makes anything leave
|
|
1478
|
+
const labels = new Map((open ?? []).map((o) => [o.number, o.labels ?? []]));
|
|
1479
|
+
if (open) {
|
|
1480
|
+
const { join, leave } = diffSelection({ open, members: [...set], pending, running, results, matched: selMatched });
|
|
1481
|
+
for (const o of open) selMatched.add(o.number);
|
|
1482
|
+
selFresh.push(...join);
|
|
1483
|
+
for (const n of leave) {
|
|
1484
|
+
pending.splice(pending.indexOf(n), 1);
|
|
1485
|
+
skip(n, "left the selector: closed or moved");
|
|
1486
|
+
}
|
|
1487
|
+
if (leave.length) save();
|
|
1488
|
+
}
|
|
1489
|
+
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
|
|
1490
|
+
let base = null;
|
|
1491
|
+
try { base = (await reconcile.base?.()) ?? null; } catch { base = null; }
|
|
1492
|
+
const { requeue, parked } = readmitDue({ results, state: readmit, now: t, version: reconcile.version?.() ?? null, base, labels: (n) => labels.get(n) ?? [] });
|
|
1493
|
+
for (const q of requeue) autoRequeues.push({ issue: q.issue, at: `reconcile-${t}`, reason: q.reason, by: "reconcile" });
|
|
1494
|
+
const digest = needsDecisionDigest(parked);
|
|
1495
|
+
if (digest !== parkedDigest) {
|
|
1496
|
+
parkedDigest = digest;
|
|
1497
|
+
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" });
|
|
1498
|
+
}
|
|
1499
|
+
if (requeue.length || parked.length) save();
|
|
1500
|
+
};
|
|
1420
1501
|
const drainAdds = async () => {
|
|
1421
1502
|
const kids = await drainChildren();
|
|
1422
|
-
|
|
1503
|
+
await reconcileTick();
|
|
1504
|
+
if (!getAdded && !selFresh.length) return kids;
|
|
1423
1505
|
let got = [];
|
|
1424
|
-
try { got = getAdded() ?? []; } catch { got = []; }
|
|
1506
|
+
try { got = [...(getAdded?.() ?? []), ...selFresh.splice(0)]; } catch { got = []; }
|
|
1425
1507
|
const fresh = [...new Set((Array.isArray(got) ? got : []).filter((n) => Number.isSafeInteger(n) && n > 0 && !set.has(n)))];
|
|
1426
1508
|
if (!fresh.length) return kids;
|
|
1427
1509
|
// An edge an operator wrote into a pending issue after the batch started (it waits on an added issue) holds too.
|
|
@@ -1475,9 +1557,9 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1475
1557
|
// #4550: `--requeue` entries (batch `requeue` file) not applied yet: a terminal issue and the dependents skipped behind it
|
|
1476
1558
|
// return to pending, the prior rows kept in history; their `Depends on` edges are re-read from the body and replaced (#5112).
|
|
1477
1559
|
const drainRequeues = async () => {
|
|
1478
|
-
if (!getRequeued) return 0;
|
|
1560
|
+
if (!getRequeued && !autoRequeues.length) return 0;
|
|
1479
1561
|
let got = [];
|
|
1480
|
-
try { got = getRequeued() ?? []; } catch { got = []; }
|
|
1562
|
+
try { got = [...(getRequeued?.() ?? []), ...autoRequeues.splice(0)]; } catch { got = []; }
|
|
1481
1563
|
const fresh = (Array.isArray(got) ? got : []).filter((e) => Number.isSafeInteger(e?.issue) && !requeueApplied.has(requeueKey(e)));
|
|
1482
1564
|
let n = 0;
|
|
1483
1565
|
for (const e of fresh) {
|
|
@@ -1550,6 +1632,8 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1550
1632
|
s.at = t;
|
|
1551
1633
|
try { Promise.resolve(stopLane(n, rec)).then((ok) => { if (ok !== false) s.accepted = true; }, () => {}); } catch { /* best effort */ }
|
|
1552
1634
|
}
|
|
1635
|
+
// #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.
|
|
1636
|
+
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
1637
|
// #5975: the batch pause. `paused (reason, until …)`, the one text every surface shows.
|
|
1554
1638
|
function pauseText(p = opPause) { return `paused (${p?.reason ?? "no reason given"}, until ${p?.expiresAt ?? "unpause"})`; }
|
|
1555
1639
|
function refreshPause() {
|
|
@@ -1571,6 +1655,8 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1571
1655
|
decided({ issue: null, what: "batch unpaused (forgedock orchestrate --unpause); admission resumed", why: "operator request", alternative: "resume the batch" });
|
|
1572
1656
|
update({ issue: null, outcome: "unpause", detail: "admission resumed" });
|
|
1573
1657
|
}
|
|
1658
|
+
if (next && !opPause) markKept([...keptBoxes.keys()], true, "paused");
|
|
1659
|
+
else if (!next && opPause) markKept([...keptBoxes.keys()].filter((n) => !opHeld.has(n)), false, "paused");
|
|
1574
1660
|
opPause = next;
|
|
1575
1661
|
}
|
|
1576
1662
|
// #4592: re-read the hold set; one decision and one row when it changes.
|
|
@@ -1592,6 +1678,8 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1592
1678
|
const fmt = (ns) => ns.map((n) => `#${n}`).join(", ");
|
|
1593
1679
|
const held = [...next].filter((n) => !opHeld.has(n)), freed = [...opHeld].filter((n) => !next.has(n));
|
|
1594
1680
|
opHeld = next;
|
|
1681
|
+
markKept(held.filter((n) => keptBoxes.has(n)), true, "held");
|
|
1682
|
+
markKept(freed.filter((n) => keptBoxes.has(n) && !opPause), false, "held");
|
|
1595
1683
|
for (const n of held) if (running.has(n)) update({ issue: n, outcome: "hold", detail: `#${n} held after launch: lane still running` }); // #5526
|
|
1596
1684
|
if (held.length) {
|
|
1597
1685
|
decided({ issue: null, what: `held ${fmt(held)} (forgedock orchestrate --hold)`, why: "operator request", alternative: "cancel the batch" });
|
|
@@ -1691,6 +1779,26 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1691
1779
|
const readmitted = new Set(); // "n:b": re-admit n on blocker b once; a lane that re-skips on b stays skipped
|
|
1692
1780
|
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
1781
|
const watchable = () => !!dispatchCheck && [...results.keys()].some((n) => blockerOf(n) !== null);
|
|
1782
|
+
// #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.
|
|
1783
|
+
const refusedNoted = new Set();
|
|
1784
|
+
const gateAdmit = async (n, { relabel = false } = {}) => {
|
|
1785
|
+
if (!attempts) return true;
|
|
1786
|
+
try {
|
|
1787
|
+
let l = ledgers.get(n) ?? null;
|
|
1788
|
+
if (!l) { l = (await attempts.load?.(n)) ?? null; if (l) ledgers.set(n, l); }
|
|
1789
|
+
if (!l) return true;
|
|
1790
|
+
const hash = (await attempts.hash?.(n)) ?? null, a = admitInput(l, hash, attempts.cfg);
|
|
1791
|
+
if (a.ok) return true;
|
|
1792
|
+
const key = `${n}|${hash}|${a.code}`;
|
|
1793
|
+
if (!refusedNoted.has(key)) {
|
|
1794
|
+
refusedNoted.add(key);
|
|
1795
|
+
if (a.code === "escalate") { l = markEscalated(l); ledgers.set(n, l); save(); await attempts.mirror?.(n, l); }
|
|
1796
|
+
await attempts.notify?.({ issue: n, code: a.code, ledger: l, reason: a.reason, relabel });
|
|
1797
|
+
update({ issue: n, event: NO_NEW_INPUT, code: NO_NEW_INPUT, detail: `${NO_NEW_INPUT}: ${a.reason}`, batch: batchId ?? null });
|
|
1798
|
+
}
|
|
1799
|
+
return false;
|
|
1800
|
+
} catch { return true; }
|
|
1801
|
+
};
|
|
1694
1802
|
// #5162: held rows behind `root` return to pending (and the root too when `withRoot`: requeued, counters reset), parents first via the edges.
|
|
1695
1803
|
const releaseHeld = (root, withRoot, why) => {
|
|
1696
1804
|
const moved = withRoot && results.has(root) ? [root] : [];
|
|
@@ -1736,7 +1844,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1736
1844
|
if (!why && v && h.version && v !== h.version) why = `engine version changed v${h.version} → v${v}`;
|
|
1737
1845
|
if (why) { /* env issue closed */ } else if (fp && h.env && fp !== h.env) why = "batch env changed (--set-env)";
|
|
1738
1846
|
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; }
|
|
1847
|
+
if (why) { if (!(await gateAdmit(n))) continue; engineSigs.delete(n); releaseHeld(n, true, `re-admitted: ${why}`); continue; }
|
|
1740
1848
|
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
1849
|
const { waiting, ...rest } = r;
|
|
1742
1850
|
const [head, ...tail] = String(rest.detail ?? "").split("\n");
|
|
@@ -1753,7 +1861,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1753
1861
|
if (restoredHeld.has(root) && ["needs-human", "budget-exceeded"].includes(ro) && typeof issueLabels === "function") { // label removed: requeue the root, its subtree follows
|
|
1754
1862
|
let names = null;
|
|
1755
1863
|
try { names = await issueLabels(root); } catch { names = null; }
|
|
1756
|
-
if (Array.isArray(names) && !names.includes("needs-human")) { releaseHeld(root, true, "needs-human label removed"); continue; }
|
|
1864
|
+
if (Array.isArray(names) && !names.includes("needs-human")) { if (await gateAdmit(root, { relabel: true })) releaseHeld(root, true, "needs-human label removed"); continue; }
|
|
1757
1865
|
}
|
|
1758
1866
|
if (!dispatchCheck) continue;
|
|
1759
1867
|
let g = null;
|
|
@@ -1812,7 +1920,12 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1812
1920
|
}
|
|
1813
1921
|
if (back.size) save();
|
|
1814
1922
|
};
|
|
1815
|
-
const
|
|
1923
|
+
const ceilingK = () => { let k = null; try { k = getParallel?.(); } catch { k = null; } return Number.isInteger(k) && k >= 1 ? k : parallel; };
|
|
1924
|
+
// #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.
|
|
1925
|
+
// #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
|
|
1926
|
+
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"; };
|
|
1927
|
+
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; };
|
|
1928
|
+
const K = () => { conc.setCeiling(ceilingK()); return conc.operating("light"); };
|
|
1816
1929
|
// #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
1930
|
// needs-human row through the normal settle path, so in-batch recovery requeues a fix lane.
|
|
1818
1931
|
let lastTrainTick = -Infinity;
|
|
@@ -1828,6 +1941,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1828
1941
|
const row = { ...rest, outcome: "merged", detail: e.detail };
|
|
1829
1942
|
results.set(n, row);
|
|
1830
1943
|
if (lifecycle && e.entry.milestone) lifecycleTitles.add(String(e.entry.milestone));
|
|
1944
|
+
await closeOnLane(n, e.entry.lane, row);
|
|
1831
1945
|
if (integration?.onMerged && String(e.entry.lane ?? "").startsWith("milestone/")) {
|
|
1832
1946
|
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
1947
|
}
|
|
@@ -1858,6 +1972,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1858
1972
|
firstPass = false;
|
|
1859
1973
|
if (!pending.length && !running.size && !train?.size()) {
|
|
1860
1974
|
if (envWaiting() && !signal?.aborted) { await nap(ehWatchMs); continue; } // #5805: only engine/env holds remain: keep re-checking them
|
|
1975
|
+
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
1976
|
break;
|
|
1862
1977
|
}
|
|
1863
1978
|
// Resolve skips first: a dependency that finished unsatisfied (or never can) skips its dependents.
|
|
@@ -1902,15 +2017,28 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1902
2017
|
if (pfNoted.size && !keys.size) update({ issue: null, outcome: "preflight", detail: "preflight cleared; admissions resumed" });
|
|
1903
2018
|
pfNoted = keys;
|
|
1904
2019
|
}
|
|
2020
|
+
// #5992: one dispatcher probe per (repo, base sha) while lanes wait; red holds every admission but the attributed fixer's.
|
|
2021
|
+
if (baseProbe && !tripped && !cancelled && !holdUntil && pending.length) {
|
|
2022
|
+
let v = null;
|
|
2023
|
+
try { v = await baseProbe(); } catch { v = null; }
|
|
2024
|
+
if (v?.red) {
|
|
2025
|
+
const issue = Number.isInteger(v.att?.issue) ? v.att.issue : null;
|
|
2026
|
+
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`;
|
|
2027
|
+
if (baseRedHold?.sha !== v.sha) update({ issue: null, outcome: "preflight", code: "base.red", detail });
|
|
2028
|
+
baseRedHold = { sha: v.sha, issue, detail };
|
|
2029
|
+
} else if (baseRedHold) { update({ issue: null, outcome: "preflight", detail: "base.red cleared; admissions resumed" }); baseRedHold = null; }
|
|
2030
|
+
}
|
|
1905
2031
|
let planPass = false; // #5831: the plan pass evaluates every other gate but the in-batch dependencies
|
|
1906
2032
|
await gateEnvSigs(); // #5755
|
|
1907
2033
|
const isReady = (n) => {
|
|
1908
2034
|
if (pfAll || (pfRemote && isRemote(n))) return false;
|
|
2035
|
+
if (baseRedHold && n !== baseRedHold.issue) return false; // #5992
|
|
1909
2036
|
if (opPause) { pauseHit = true; return false; } // #5975: every admission path (dependency merge, env/engine re-admit, requeue, add, recovery) ends here
|
|
1910
2037
|
if (opHeld.has(n)) { opHeldHit.add(n); return false; }
|
|
1911
2038
|
if (blocked.has(n)) { blockedHit.add(n); return false; } // #4773
|
|
1912
2039
|
if (baseHeld.has(n)) { baseHit.add(n); return false; } // #5031
|
|
1913
2040
|
if (!((notBefore.get(n) ?? 0) <= t && (planPass || edges(n).every((d) => results.has(d) && SATISFIED.has(results.get(d).outcome))))) return false;
|
|
2041
|
+
if (heavyFull(n)) return false; // #5985: a wave of heavy (test-suite) lanes never takes the whole ceiling
|
|
1914
2042
|
if (integration?.holds) {
|
|
1915
2043
|
let why = null;
|
|
1916
2044
|
try { why = integration.holds(n, { lane: lanes.get(n)?.lane ?? null }); } catch { why = null; }
|
|
@@ -1950,6 +2078,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1950
2078
|
for (const n of want) wanted.add(n);
|
|
1951
2079
|
for (const n of ready) {
|
|
1952
2080
|
if (running.size >= K()) break;
|
|
2081
|
+
if (heavyFull(n)) continue; // #5985
|
|
1953
2082
|
const g = grant(n, wanted);
|
|
1954
2083
|
if (g === "busy") continue; // #4481
|
|
1955
2084
|
if (!g && (notBefore.get(n) ?? 0) > t) continue; // #5592: per-issue wait, not a full host queue
|
|
@@ -1959,6 +2088,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1959
2088
|
} else if (!tripped && !cancelled && !holdUntil) {
|
|
1960
2089
|
for (const n of rank(pending.filter(isReady))) {
|
|
1961
2090
|
if (running.size >= K()) break;
|
|
2091
|
+
if (heavyFull(n)) continue; // #5985
|
|
1962
2092
|
if (grant(n, new Set()) === true) { pending.splice(pending.indexOf(n), 1); start(n); started++; }
|
|
1963
2093
|
}
|
|
1964
2094
|
}
|
|
@@ -1977,6 +2107,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1977
2107
|
try { sc = rank(pending.filter((n) => stackAdmissible({ n, edges: edges(n), results, pending, running, prReady, stackedTried, satisfied: SATISFIED }) && isReady(n))); } finally { planPass = false; }
|
|
1978
2108
|
for (const n of sc) {
|
|
1979
2109
|
if (running.size >= K()) break;
|
|
2110
|
+
if (heavyFull(n)) continue; // #5985
|
|
1980
2111
|
if (lanes.get(n)?.ok === false || (notBefore.get(n) ?? 0) > t) continue;
|
|
1981
2112
|
const so = stackAdmissible({ n, edges: edges(n), results, pending, running, prReady, stackedTried, satisfied: SATISFIED });
|
|
1982
2113
|
if (!so || grant(n, new Set()) !== true) continue;
|
|
@@ -1996,6 +2127,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
1996
2127
|
try { cands = rank(pending.filter((n) => planAdmissible({ n, edges: edges(n), results, pending, running, planTried, satisfied: SATISFIED }) && isReady(n))); } finally { planPass = false; }
|
|
1997
2128
|
for (const n of cands) {
|
|
1998
2129
|
if (running.size >= K()) break;
|
|
2130
|
+
if (heavyFull(n)) continue; // #5985
|
|
1999
2131
|
if (lanes.get(n)?.ok === false || (notBefore.get(n) ?? 0) > t) continue;
|
|
2000
2132
|
if (grant(n, new Set()) !== true) continue;
|
|
2001
2133
|
pending.splice(pending.indexOf(n), 1);
|
|
@@ -2010,6 +2142,17 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
2010
2142
|
if (reg) withdrawExcept(wanted);
|
|
2011
2143
|
// #4685: a breaker tripped only by link failures (a router restart) closes itself after a cooldown
|
|
2012
2144
|
if (tripped?.transport && now() - tripped.at >= TRANSPORT_COOLDOWN_MS) { tripped = null; errorTimes = []; transportErrors = 0; save(); }
|
|
2145
|
+
// #5978: a standing order's breaker closes itself after a cooldown when the failures were environmental and the pool is healthy
|
|
2146
|
+
if (tripped && reconcile && !tripped.transport) {
|
|
2147
|
+
let healthy = true; try { healthy = reconcile.poolHealthy ? reconcile.poolHealthy() !== false : true; } catch { healthy = true; }
|
|
2148
|
+
const d = decideAutoReset({ tripped, now: now(), cooldownMs: BREAKER_COOLDOWN_MS, environmental: tripped.environmental === true, poolHealthy: healthy });
|
|
2149
|
+
if (d.reset) {
|
|
2150
|
+
tripped = null; errorTimes = []; transportErrors = 0; save();
|
|
2151
|
+
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" });
|
|
2152
|
+
update({ issue: null, outcome: "breaker", detail: `circuit breaker cleared automatically: ${d.why}` });
|
|
2153
|
+
continue;
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2013
2156
|
// #5947: --clear-breaker on a schedd-hosted batch reaches this runner through the batch's request file
|
|
2014
2157
|
if (getClearBreaker) { // #5964: time-scoped; the request is consumed only after the decision, so a long pass never loses it
|
|
2015
2158
|
let req = null; try { req = getClearBreaker(); } catch { req = null; }
|
|
@@ -2050,7 +2193,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
2050
2193
|
if (pending.some((n) => remoteCapped.has(n))) wake = Math.min(wake ?? pollMs, pollMs); // #5138: a live --set-max-remote raise
|
|
2051
2194
|
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
2195
|
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
|
|
2196
|
+
if ((pfAll || pfRemote || baseRedHold) && pending.length) wake = Math.min(wake ?? pollMs, pollMs); // #4866
|
|
2054
2197
|
if (baseWait && pending.length && baseHeld.size) wake = Math.min(wake ?? pollMs, pollMs); // #5031: a landed commit releases on the next tick
|
|
2055
2198
|
if (getBlocked && pending.length && blockedHit.size) wake = Math.min(wake ?? pollMs, pollMs); // #4773: a removed label releases on the next tick
|
|
2056
2199
|
if (getHeld && running.size) wake = Math.min(wake ?? pollMs, pollMs); // #4592: a release while only lanes run
|
|
@@ -2058,6 +2201,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
2058
2201
|
if (running.size && watchable()) wake = Math.min(wake ?? WATCH_EVERY_MS, WATCH_EVERY_MS); // #4595: re-check the blockers of skipped rows
|
|
2059
2202
|
if (running.size && envWaiting()) wake = Math.min(wake ?? ehWatchMs, ehWatchMs); // #5805: re-check engine/env holds while lanes run
|
|
2060
2203
|
if (train?.size()) wake = Math.min(wake ?? trainEveryMs, Math.max(0, trainEveryMs - (now() - lastTrainTick))); // #5836
|
|
2204
|
+
if (reconcile && running.size) wake = Math.min(wake ?? reconcile.everyMs ?? RECONCILE_MS, reconcile.everyMs ?? RECONCILE_MS); // #5978
|
|
2061
2205
|
if (tripped) wake = getClearBreaker ? Math.min(wake ?? pollMs, pollMs) : null;
|
|
2062
2206
|
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
2207
|
if (running.size) {
|
|
@@ -2066,7 +2210,7 @@ export async function orchestrate({ issues, parallel = 3, runOne, readBody, pref
|
|
|
2066
2210
|
} else if (started) continue; // only lane-refused rows settled (synchronously): re-resolve skips first
|
|
2067
2211
|
else if (train?.size()) await nap(wake ?? trainEveryMs); // #5836: only train-held PRs are left: poll the train
|
|
2068
2212
|
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
|
|
2213
|
+
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
2214
|
else if (pending.length && blockedHit.size) await nap(wake ?? pollMs); // #4773: only blocked issues wait: poll for the label's removal
|
|
2071
2215
|
else if (pending.length && baseHit.size) await nap(wake ?? pollMs); // #5031: only issues waiting for a base commit: poll for it
|
|
2072
2216
|
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
|
package/bin/lean/phaseledger.mjs
CHANGED
|
@@ -93,6 +93,12 @@ export const laneSum = (phases) => Object.entries(phases ?? {}).reduce((s, [id,
|
|
|
93
93
|
/** True when the lane phases sum to within `tol` of `wallMs`. */
|
|
94
94
|
export const withinWall = (phases, wallMs, tol = 0.05) => isNum(wallMs) && wallMs >= 0 && Math.abs(laneSum(phases) - wallMs) <= Math.max(1, wallMs * tol);
|
|
95
95
|
|
|
96
|
+
/** Fixed overhead = lane wall time not spent in a model call (never negative); model_share = model time / wall (0 when wall <= 0). */
|
|
97
|
+
export function overheadStats(_phases, wallMs, modelMs) {
|
|
98
|
+
const wall = isNum(wallMs) ? wallMs : 0, model = isNum(modelMs) ? modelMs : 0;
|
|
99
|
+
return { fixed_overhead_ms: Math.max(0, wall - model), model_share: wall > 0 ? Math.round((model / wall) * 1000) / 1000 : 0 };
|
|
100
|
+
}
|
|
101
|
+
|
|
96
102
|
export function flattenPhases(phases) {
|
|
97
103
|
const out = {};
|
|
98
104
|
for (const [id, v] of Object.entries(phases ?? {})) {
|
|
@@ -7,7 +7,7 @@ import { tmpDir } from "../tests/_tmp.mjs";
|
|
|
7
7
|
import { join } from "node:path";
|
|
8
8
|
import { phasesOf } from "./orchestrate.mjs";
|
|
9
9
|
import { aggregate } from "../stats/aggregate.mjs";
|
|
10
|
-
import { LANE_PHASES, createLedger, laneSum, withinWall, flattenPhases, unflattenPhases, summarizePhases, formatLedgerSummary, WAIT_CAUSES, summarizeWaits, comparePhases, formatPhaseComparison, readBaselineRows } from "./phaseledger.mjs";
|
|
10
|
+
import { LANE_PHASES, createLedger, laneSum, withinWall, flattenPhases, unflattenPhases, overheadStats, summarizePhases, formatLedgerSummary, WAIT_CAUSES, summarizeWaits, comparePhases, formatPhaseComparison, readBaselineRows } from "./phaseledger.mjs";
|
|
11
11
|
|
|
12
12
|
const clock = () => { let t = 1000; const f = () => t; f.tick = (ms) => { t += ms; }; return f; };
|
|
13
13
|
|
|
@@ -167,3 +167,15 @@ describe("phase comparison vs previous 7 days (#5649)", () => {
|
|
|
167
167
|
assert.equal(readBaselineRows({ root: join(root, "missing"), now }), null);
|
|
168
168
|
});
|
|
169
169
|
});
|
|
170
|
+
|
|
171
|
+
describe("overheadStats", () => {
|
|
172
|
+
it("splits wall into model share and fixed overhead", () => {
|
|
173
|
+
assert.deepEqual(overheadStats({}, 1000, 320), { fixed_overhead_ms: 680, model_share: 0.32 });
|
|
174
|
+
});
|
|
175
|
+
it("zero wall gives zero share", () => {
|
|
176
|
+
assert.deepEqual(overheadStats({}, 0, 50), { fixed_overhead_ms: 0, model_share: 0 });
|
|
177
|
+
});
|
|
178
|
+
it("model > wall clamps overhead to 0", () => {
|
|
179
|
+
assert.equal(overheadStats({}, 100, 150).fixed_overhead_ms, 0);
|
|
180
|
+
});
|
|
181
|
+
});
|
package/bin/lean/prompts.mjs
CHANGED
|
@@ -10,6 +10,7 @@ import { capText, FIX_CAPS, FIX_PROMPT_MAX, NARROW_CAPS, NARROW_PROMPT_MAX } fro
|
|
|
10
10
|
import { SPLIT_MIN_FILES, SPLIT_MIN_LINES } from "./decompose.mjs";
|
|
11
11
|
import { relaxationBlock } from "./relaxation.mjs";
|
|
12
12
|
import { visualReviewCheck } from "./ui-quality.mjs";
|
|
13
|
+
import { amendmentPromptLines, AMEND_KINDS } from "./amendment-schema.mjs"; // #5979
|
|
13
14
|
import { stampRule } from "./stagestamp.mjs";
|
|
14
15
|
import { FINDING_PITFALLS, PLANNER_TIGHTENING } from "./selfreview.mjs";
|
|
15
16
|
import { isTrustedIssueComment } from "./prefilter.mjs"; // call-time use only: prefilter.mjs imports this module
|
|
@@ -262,12 +263,7 @@ export function builderImplementPrompt(mode = "local", { toolchain = null, spars
|
|
|
262
263
|
${HOST_RULES}${toolchainRule(toolchain)}${sparseRule(sparse)}${factsRule(facts)}${stampRule(stamp)}${remote ? `\n\n${VERIFY_RULES[mode]}` : ""}
|
|
263
264
|
|
|
264
265
|
The contract changes only through typed amendments in ${RESULT_FILE}, each with a why:
|
|
265
|
-
|
|
266
|
-
- {"kind":"add-requirement","requirement":{"id":"R9","quote":"<verbatim from the issue>","disposition":"deliver|defer|post-deploy"},"why":""}: a missed requirement.
|
|
267
|
-
- {"kind":"defer|post-deploy","requirement":"R#","why":"","check":"<id>"}: separate work or a post-deploy check, filed as a follow-up. Not "type"; unknown kinds are rejected. One requirement id per row. An impossible deliverable is a defer, not a new kind.
|
|
268
|
-
- {"kind":"amend-requirement","requirement":"R#","text":"<revised wording>","why":""}: reworded.
|
|
269
|
-
- {"kind":"supersedes","guard":"#N","why":""}: overrides a guard_broken failure; {"kind":"supersedes","mechanism":"<name>","why":""} retires every guard whose test this lane deletes.
|
|
270
|
-
- {"kind":"decision","decision":{"choice":"","anchors":["<base path>"],"supersedes":"<id>"},"why":""}: supersedes changes an H-row.
|
|
266
|
+
${amendmentPromptLines()}
|
|
271
267
|
New keys: translate, never copy English; status entries in place.
|
|
272
268
|
Never report a deliver requirement as "deferred" or "follow-up" without an amendment.
|
|
273
269
|
Never name or number migration files by hand; use the generator.
|
|
@@ -276,7 +272,7 @@ A [type:e2e] requirement needs a validate that runs a real e2e check (repo e2e s
|
|
|
276
272
|
A new keyword/regex classifier ships negative examples (inputs it must not match).
|
|
277
273
|
A forge.yaml outcome_evidence area change needs result outcome_evidence [{area,metric,corpus,before,after,better}] measured on recorded real inputs; its post-deploy checks get a numeric baseline.
|
|
278
274
|
A new workspace-package dependency in a package.json no deliverable names is blocked by the engine: add it through add-deliverable with a why naming the package, or do not add it.
|
|
279
|
-
If scripts/check-devdocs-freshness.sh exists, a behaviour change under its paths
|
|
275
|
+
If scripts/check-devdocs-freshness.sh exists, a behaviour change under its paths adds a new devdocs/decisions/<issue>-<slug>.md in the same change (a new file never conflicts with parallel lanes); run it against the base first.
|
|
280
276
|
|
|
281
277
|
Before writing ${RESULT_FILE}, after your last edit, run \`node ${FORGEDOCK_CLI} check\` in the worktree and fix until it passes; if it cannot pass, report the problem as blocked.
|
|
282
278
|
A \`FAIL review\` line from check is a finding the reviewer would raise; fix it. Also:
|
|
@@ -432,7 +428,7 @@ export function contractCorrectionPrompt(problems) {
|
|
|
432
428
|
|
|
433
429
|
/** #5089: the builder's amendments name an unknown kind or miss a field; one correction before the conformance gate. */
|
|
434
430
|
export function amendmentCorrectionPrompt(problems) {
|
|
435
|
-
return `The amendments in ${RESULT_FILE} are not valid:\n${problems.slice(0, 20).map((p) => `- ${p}`).join("\n")}\n\nRewrite them with a valid kind
|
|
431
|
+
return `The amendments in ${RESULT_FILE} are not valid:\n${problems.slice(0, 20).map((p) => `- ${p}`).join("\n")}\n\nRewrite them with a valid kind (${AMEND_KINDS.join(", ")}). A validate-row id (G2) is never a supersedes guard: use {"kind":"substitute-validate","validate":"G2","command":"<runnable equivalent>","why":""}. A deliverable that is impossible on this platform is {"kind":"defer","requirement":"R#","why":""}, not a changed deliverable. Edit only ${RESULT_FILE} (commit nothing else) and stop. Do not push or touch GitHub.`;
|
|
436
432
|
}
|
|
437
433
|
|
|
438
434
|
/** The one bounded correction round, in the builder's own session. */
|
|
@@ -448,9 +444,9 @@ export function structurePrompt(edges, mode = "local") {
|
|
|
448
444
|
return `This change adds dependencies between workspace packages that the frozen contract does not name:\n${edges.slice(0, 30).map((e) => `- ${e.from} -> ${e.to} (${e.kind}, ${e.manifest})`).join("\n")}\n\nFor each one, add it to the contract with a reason, or remove it: either record {"kind":"add-deliverable","path":"<that package.json>","why":"<names the package and why this dependency is right>"} in ${RESULT_FILE}, or drop the dependency from the package.json and the code that needs it. ${rerun(mode)}, commit, and update ${IMPLEMENTATION_FILE} and ${RESULT_FILE}. Do not push or touch GitHub.`;
|
|
449
445
|
}
|
|
450
446
|
|
|
451
|
-
/** The repo's devdocs freshness rule failed on the committed change:
|
|
447
|
+
/** The repo's devdocs freshness rule failed on the committed change: add a decision record (conflict-free) and commit. */
|
|
452
448
|
export function docsPrompt(output, mode = "local") {
|
|
453
|
-
return `The repository's docs freshness check (scripts/check-devdocs-freshness.sh) fails on this change:\n${String(output ?? "").slice(0, 4000)}\n\
|
|
449
|
+
return `The repository's docs freshness check (scripts/check-devdocs-freshness.sh) fails on this change:\n${String(output ?? "").slice(0, 4000)}\n\nAdd a new devdocs/decisions/<issue>-<slug>.md describing the behaviour you changed in a few lines (a new file never conflicts with parallel lanes; edit a shared dossier only when the check accepts nothing else). ${rerun(mode)}, commit, and update ${IMPLEMENTATION_FILE} and ${RESULT_FILE}. Do not push or touch GitHub.`;
|
|
454
450
|
}
|
|
455
451
|
|
|
456
452
|
/**
|