forgedock 1.63.0 → 1.65.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 +5 -0
- package/bin/engine-cli.mjs +88 -12
- package/bin/env/cli.mjs +18 -1
- package/bin/lean/basered.mjs +56 -11
- package/bin/lean/basered.test.mjs +58 -5
- package/bin/lean/batch-health.mjs +46 -4
- package/bin/lean/batch-health.test.mjs +55 -1
- package/bin/lean/batch.mjs +8 -1
- package/bin/lean/batch.test.mjs +71 -6
- package/bin/lean/ceiling.mjs +47 -3
- package/bin/lean/ceiling.test.mjs +32 -1
- package/bin/lean/clear-breaker.mjs +15 -0
- package/bin/lean/clear-breaker.test.mjs +100 -0
- package/bin/lean/conformance.e2e.test.mjs +32 -6
- package/bin/lean/conformance.mjs +57 -13
- package/bin/lean/conformance.test.mjs +93 -1
- package/bin/lean/execution.mjs +18 -8
- package/bin/lean/execution.test.mjs +44 -3
- package/bin/lean/issuewatch-reconcile.mjs +2 -0
- package/bin/lean/issuewatch-reconcile.test.mjs +25 -0
- package/bin/lean/issuewatch.mjs +3 -0
- package/bin/lean/lanecheck.test.mjs +13 -1
- package/bin/lean/lean.mjs +157 -28
- package/bin/lean/lean.test.mjs +289 -21
- package/bin/lean/live-execution.mjs +25 -0
- package/bin/lean/live-execution.test.mjs +35 -1
- package/bin/lean/merged-park.mjs +76 -0
- package/bin/lean/merged-park.test.mjs +64 -0
- package/bin/lean/mergetrain.mjs +357 -0
- package/bin/lean/mergetrain.test.mjs +348 -0
- package/bin/lean/mirror-bundle.mjs +84 -0
- package/bin/lean/orchestrate-envhold.test.mjs +62 -0
- package/bin/lean/orchestrate-stacking.test.mjs +23 -1
- package/bin/lean/orchestrate-train.test.mjs +130 -0
- package/bin/lean/orchestrate-transient-git.test.mjs +53 -0
- package/bin/lean/orchestrate.mjs +170 -13
- package/bin/lean/prompts.mjs +4 -3
- package/bin/lean/release-review.mjs +8 -1
- package/bin/lean/release-review.test.mjs +42 -2
- package/bin/lean/release-status.test.mjs +53 -1
- package/bin/lean/release.mjs +6 -3
- package/bin/lean/render.mjs +6 -1
- package/bin/lean/sandbox-provider.contract.test.mjs +6 -0
- package/bin/lean/sandbox-remote.mjs +43 -3
- package/bin/lean/sched.mjs +19 -2
- package/bin/lean/sched.test.mjs +33 -1
- package/bin/lean/schedd-health.mjs +2 -1
- package/bin/lean/schedd-health.test.mjs +7 -0
- package/bin/lean/schedd.mjs +58 -7
- package/bin/lean/schedd.test.mjs +78 -1
- package/bin/lean/stacking.mjs +45 -0
- package/bin/lean/stacking.test.mjs +25 -1
- package/bin/lean/statuscomment.mjs +14 -8
- package/bin/lean/statuscomment.test.mjs +18 -1
- package/bin/lean/validate-catalog.mjs +1 -1
- package/bin/lean/validate-catalog.test.mjs +3 -0
- package/bin/lean/worktree.mjs +8 -3
- package/bin/lean/worktree.test.mjs +18 -0
- package/bin/pool/agent.mjs +309 -33
- package/bin/pool/cache-sweep.mjs +4 -2
- package/bin/pool/cli.mjs +125 -6
- package/bin/pool/disk.mjs +43 -0
- package/bin/pool/docker.mjs +11 -0
- package/bin/pool/health.mjs +95 -0
- package/bin/pool/mirror-seed.mjs +103 -0
- package/bin/pool/router.mjs +301 -27
- package/bin/runner.mjs +3 -1
- package/bin/stats/chains.mjs +101 -0
- package/bin/stats/chains.test.mjs +53 -0
- package/bin/stats/efficiency.mjs +7 -6
- package/bin/stats/efficiency.test.mjs +48 -7
- package/bin/stats/index.mjs +11 -3
- package/bin/stats/stats.test.mjs +9 -0
- package/docs/CONFIG.md +8 -1
- package/docs/OUTCOME-CODES.md +4 -0
- package/package.json +1 -1
- package/pool/README.md +10 -0
- package/pool/image/Dockerfile +2 -1
- package/pool/image/entrypoint.sh +25 -6
- package/pool/image/mirror.sh +71 -0
- package/pool/install/install-agent-linux.sh +57 -5
- package/pool/install/install-agent-macos.sh +148 -0
- package/pool/install/install-agent.ps1 +11 -0
- package/pool/install/install-agent.sh +59 -7
- package/pool/install/uninstall-agent-linux.sh +75 -0
- package/pool/install/uninstall-agent-macos.sh +60 -0
- package/pool/install/uninstall-agent.ps1 +1 -0
- package/scripts/transition-label.sh +11 -0
|
@@ -7,7 +7,7 @@ import { mkdirSync, writeFileSync, existsSync, readFileSync } from "node:fs";
|
|
|
7
7
|
import { join } from "node:path";
|
|
8
8
|
import { tmpDir } from "../tests/_tmp.mjs";
|
|
9
9
|
import { renderContract } from "./render.mjs";
|
|
10
|
-
import { parseExecution, hostFallbackAllowed, SANDBOX_PROVIDERS, detectNeeds, hostCapabilityBlock, placementText, contractHostNeeds, placement, placeLane, validationWeight, hostHeadroom, scopedEnv, providerLanes, remoteHoldId, usageLimitInTail, isTransportError, isCloneFailure, containerProvider, providerByName, openExecutionBudget, poolCredential, remoteTransportFor, resolveDefaultExecution, repoIsPublic } from "./execution.mjs";
|
|
10
|
+
import { parseExecution, hostFallbackAllowed, SANDBOX_PROVIDERS, detectNeeds, hostCapabilityBlock, placementText, contractHostNeeds, placement, placeLane, validationWeight, hostHeadroom, scopedEnv, providerLanes, remoteHoldId, usageLimitInTail, isTransportError, isCloneFailure, isEgressTimeout, SANDBOX_EGRESS_TIMEOUT_CODE, containerProvider, providerByName, openExecutionBudget, poolCredential, remoteTransportFor, resolveDefaultExecution, repoIsPublic } from "./execution.mjs";
|
|
11
11
|
import * as executionModule from "./execution.mjs";
|
|
12
12
|
import { remoteProvider } from "./sandbox-remote.mjs";
|
|
13
13
|
import { makeLedger, countLiveLanes } from "./ledger.mjs";
|
|
@@ -62,9 +62,17 @@ describe("execution config (#4253)", () => {
|
|
|
62
62
|
assert.equal(parseExecution({ mode: "remote", provider: "My Provider" }).provider, "container");
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
+
it("remote mode with max_remote 0 pauses starts (#5933)", () => {
|
|
66
|
+
assert.notEqual(placement({ mode: "remote", maxRemote: 0 }), "local");
|
|
67
|
+
assert.equal(placeLane({ exec: { mode: "remote", maxRemote: 0 } }).where, "remote");
|
|
68
|
+
});
|
|
69
|
+
it("#5933 hybrid max_remote 0 stays local", () => {
|
|
70
|
+
assert.deepEqual(placeLane({ exec: { mode: "hybrid", maxRemote: 0 } }), { where: "local", reason: "max_remote 0" });
|
|
71
|
+
});
|
|
72
|
+
|
|
65
73
|
it("placement: remote only for mode remote with max_remote >= 1; hybrid is placed per lane by placeLane (#4256)", () => {
|
|
66
74
|
assert.equal(placement(parseExecution({})), "local");
|
|
67
|
-
assert.equal(placement(parseExecution({ mode: "remote", max_remote: "0" })), "
|
|
75
|
+
assert.equal(placement(parseExecution({ mode: "remote", max_remote: "0" })), "remote");
|
|
68
76
|
assert.equal(placement(parseExecution({ mode: "hybrid", max_remote: "3" })), "local");
|
|
69
77
|
assert.equal(placement(parseExecution({ mode: "remote", max_remote: "3" })), "remote");
|
|
70
78
|
assert.equal(placement(undefined), "local");
|
|
@@ -242,6 +250,29 @@ describe("providerLanes: sandbox ledger and teardown on every exit path (#4253)"
|
|
|
242
250
|
assert.equal(led.read(), null);
|
|
243
251
|
});
|
|
244
252
|
|
|
253
|
+
it("#5859 lost without a result: the engine-error carries the pool agent; usage-limit and clone-failure mappings stay", async () => {
|
|
254
|
+
const lost = async (tail, agent = "legion") => {
|
|
255
|
+
const prov = fakeProvider({ finish: () => null });
|
|
256
|
+
const start = prov.start; prov.start = async (o) => ({ ...(await start(o)), agent });
|
|
257
|
+
const lanes = providerLanes({ provider: prov, laneArgs: () => [], ledgerFor: ledgerIn(tmpDir("exec-lost-")), pollMs: 1, now: () => 1000, sleep: async () => {}, logTail: async () => tail });
|
|
258
|
+
const r = await lanes.runOne(7, "staging", {});
|
|
259
|
+
await r.postRun?.();
|
|
260
|
+
return r;
|
|
261
|
+
};
|
|
262
|
+
const r = await lost("");
|
|
263
|
+
assert.equal(r.terminalReason, "engine-error");
|
|
264
|
+
assert.equal(r.agent, "legion");
|
|
265
|
+
assert.equal(r.lostWithoutResult, true);
|
|
266
|
+
assert.match(r.detail, /^sandbox fake-7 exited without a result$/, "detail text unchanged");
|
|
267
|
+
const lim = await lost("x\n[lane] deferred: usage limit hit; resets at 3:20pm (UTC)\n");
|
|
268
|
+
assert.equal(lim.terminalReason, "deferred");
|
|
269
|
+
assert.equal(lim.code, "rate_limited");
|
|
270
|
+
assert.equal(lim.lostWithoutResult, undefined);
|
|
271
|
+
const clone = await lost("git clone failed: early EOF");
|
|
272
|
+
assert.equal(clone.terminalReason, "deferred");
|
|
273
|
+
assert.equal(clone.lostWithoutResult, undefined);
|
|
274
|
+
});
|
|
275
|
+
|
|
245
276
|
it("#4685 start refused with HTTP 401: deferred sandbox.auth with a long retry, never needs-human", async () => {
|
|
246
277
|
const { r } = await run({ startThrows: 401 });
|
|
247
278
|
assert.equal(r.terminalReason, "deferred");
|
|
@@ -410,6 +441,7 @@ describe("container provider (#4253)", () => {
|
|
|
410
441
|
const p = containerProvider({ batch, image: "i", gitDir: "/g", docker });
|
|
411
442
|
const h = { provider: "container", id: "fdsbx-bt-1", issue: 1 };
|
|
412
443
|
assert.equal(await p.status(h), "running");
|
|
444
|
+
state = "paused"; assert.equal(await p.status(h), "running"); // #5957
|
|
413
445
|
state = "exited"; assert.equal(await p.status(h), "exited");
|
|
414
446
|
state = null; assert.equal(await p.status(h), "gone");
|
|
415
447
|
assert.equal(await p.teardown(h), true);
|
|
@@ -682,7 +714,7 @@ describe("hybrid placement (#4256)", () => {
|
|
|
682
714
|
const cases = [
|
|
683
715
|
[{ exec: parseExecution({}) }, "local", "mode local"],
|
|
684
716
|
[{ exec: parseExecution({ mode: "remote", max_remote: "3" }), weight: LIGHT }, "remote", "mode remote"],
|
|
685
|
-
[{ exec: parseExecution({ mode: "remote", max_remote: "0" }) }, "
|
|
717
|
+
[{ exec: parseExecution({ mode: "remote", max_remote: "0" }) }, "remote", "mode remote"],
|
|
686
718
|
[{ exec: hy("0"), weight: HEAVY }, "local", "max_remote 0"],
|
|
687
719
|
[{ exec: hy(), verifyMode: "ci", weight: HEAVY, headroom: BUSY }, "local", "verify.mode ci: validation runs on CI, not billed twice"],
|
|
688
720
|
[{ exec: hy(), labels: ["Documentation"], weight: HEAVY, headroom: BUSY }, "local", "docs-only lane"],
|
|
@@ -817,6 +849,15 @@ describe("hybrid placement (#4256)", () => {
|
|
|
817
849
|
});
|
|
818
850
|
});
|
|
819
851
|
|
|
852
|
+
describe("#5923: egress timeout classification", () => {
|
|
853
|
+
it("isEgressTimeout matches network hangs only", () => {
|
|
854
|
+
assert.equal(SANDBOX_EGRESS_TIMEOUT_CODE, "sandbox.egress_timeout");
|
|
855
|
+
assert.equal(isEgressTimeout("ssh: connect: Connection timed out"), true);
|
|
856
|
+
assert.equal(isEgressTimeout("fatal: unable to access: Failed to connect to github.com"), true);
|
|
857
|
+
assert.equal(isEgressTimeout("fatal: repository not found"), false);
|
|
858
|
+
});
|
|
859
|
+
});
|
|
860
|
+
|
|
820
861
|
describe("#5652: host fallback policy", () => {
|
|
821
862
|
it("parseExecution reads execution.host_fallback only when explicit", () => {
|
|
822
863
|
assert.equal(parseExecution({ mode: "remote" }).hostFallback, undefined);
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* FORGE:DECISION or a newer comment) is released so the next pass re-claims it. `status --stuck` lists the old claims. Gh, the clock and the
|
|
9
9
|
* lane launch are injected; the state callbacks (`fail`, `settle`, `release`) belong to the caller.
|
|
10
10
|
*/
|
|
11
|
+
import { mergedEvidence } from "./merged-park.mjs";
|
|
11
12
|
import { classifyNeedsHuman, REMEDIATION_QUEUE_LABEL } from "../engine/outcome-codes.mjs";
|
|
12
13
|
|
|
13
14
|
const HOUR_MS = 3600_000;
|
|
@@ -121,6 +122,7 @@ export async function remediateStep({ watch, repo, io, state, handles, lanes = {
|
|
|
121
122
|
r.status = "failed";
|
|
122
123
|
const reason = `remediation lane for \`${r.code}\` exited ${res.code}`;
|
|
123
124
|
state.outcomes[n] = { kind: "needs-human", code: r.code, at: now, reason };
|
|
125
|
+
if (await mergedEvidence({ gh: io.gh, repo, issue: Number(n) })) { fail(Number(n)); continue; } // #5759: a merged fix is not parked after the fact
|
|
124
126
|
try {
|
|
125
127
|
await io.gh(["issue", "edit", String(n), "-R", repo, "--add-label", NEEDS_HUMAN_LABEL, "--remove-label", REMEDIATION_QUEUE_LABEL]);
|
|
126
128
|
await io.gh(["issue", "comment", String(n), "-R", repo, "--body", `## Needs human\nissue-watch ${watch.name} remediated this parked issue once (${reason}); a person has to take it from here.`]);
|
|
@@ -79,3 +79,28 @@ test("remediateStep: a remediation exit 0 posts one FORGE:TRACKED hand-off while
|
|
|
79
79
|
await run({ outcomes: { 7: { kind: "parked", code: "x" } } });
|
|
80
80
|
assert.equal(comments.length, 0);
|
|
81
81
|
});
|
|
82
|
+
|
|
83
|
+
test("remediateStep: a failed remediation on a merged issue adds no needs-human; one reopened after the merge does (#5759)", async () => {
|
|
84
|
+
const { remediateStep } = await import("./issuewatch-reconcile.mjs");
|
|
85
|
+
const run = async (events) => {
|
|
86
|
+
const edits = [];
|
|
87
|
+
const io = {
|
|
88
|
+
remediate: () => ({ poll: () => ({ code: 1 }) }),
|
|
89
|
+
gh: async (a) => {
|
|
90
|
+
if (a[0] === "issue" && a[1] === "view") return JSON.stringify({ state: "OPEN", labels: [{ name: "workflow:merged" }] });
|
|
91
|
+
if (a[0] === "api") return events;
|
|
92
|
+
if (a[1] === "edit") edits.push(a.join(" "));
|
|
93
|
+
return "";
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
const state = { outcomes: { 7: { kind: "parked", code: "ci.red" } } }, failed = [], handles = new Map();
|
|
97
|
+
const step = () => remediateStep({ watch: { name: "w" }, repo: "o/r", io, state, handles, now: 1, settle: () => {}, fail: (n) => failed.push(n) });
|
|
98
|
+
await step(); await step();
|
|
99
|
+
return { edits, failed };
|
|
100
|
+
};
|
|
101
|
+
const merged = await run("labeled\t2026-11-17T00:00:00.000Z\tworkflow:merged");
|
|
102
|
+
assert.deepEqual(merged.edits, []);
|
|
103
|
+
assert.deepEqual(merged.failed, [7]);
|
|
104
|
+
const reopened = await run("labeled\t2026-11-17T00:00:00.000Z\tworkflow:merged\nreopened\t2026-11-18T00:00:00.000Z\t");
|
|
105
|
+
assert.ok(reopened.edits.some((e) => e.includes("--add-label needs-human")));
|
|
106
|
+
});
|
package/bin/lean/issuewatch.mjs
CHANGED
|
@@ -23,6 +23,7 @@ import { triageTick } from "./issuewatch-triage.mjs";
|
|
|
23
23
|
import { releaseRoot } from "./release.mjs";
|
|
24
24
|
import { loadPolicy } from "./decision-engine.mjs";
|
|
25
25
|
import { decisionContext, decisionsActive, decisionStep, decisionCounts, formatDecisionDryRun, claimsUsed } from "./issuewatch-decisions.mjs";
|
|
26
|
+
import { repairMergedParked } from "./merged-park.mjs";
|
|
26
27
|
import { reconcileClaims, remediateStep, reclaimStep, redriveStep, claimCounts, stuckClaims, formatStuck } from "./issuewatch-reconcile.mjs";
|
|
27
28
|
import { APP_SLUG } from "../init-repo.mjs";
|
|
28
29
|
import { noComments } from "./render.mjs";
|
|
@@ -366,6 +367,8 @@ export async function tick({ watch, repo, io, state, dir, branches = {}, default
|
|
|
366
367
|
else if (r.code === 75 && (state.retries[n] = (state.retries[n] ?? 0) + 1) <= RETRIES) handles.set(n, io.launch(n, state.lanes[n]));
|
|
367
368
|
else fail(n);
|
|
368
369
|
}
|
|
370
|
+
// #5759: an open issue with workflow:merged still carrying park labels is inconsistent; clear them
|
|
371
|
+
try { for (const r of await repairMergedParked({ gh: io.gh, repo })) (state.repaired ??= []).push({ issue: r.issue, labels: r.flagged, at: now }); } catch { /* best effort */ }
|
|
369
372
|
if (watch.mode === "batch") {
|
|
370
373
|
await remediateStep({ watch, repo, io, state, handles, now, settle, fail });
|
|
371
374
|
await reclaimStep({ repo, io, state, trusted: (c) => TRUSTED.has(c?.authorAssociation), release: (n) => { releaseClaims(repoDir(repo, io.env), [n], watch.name); state.claimed = state.claimed.filter((x) => x !== n); delete state.lanes[n]; unsettle(state, n); } });
|
|
@@ -10,7 +10,7 @@ import { checkPoolAuth, checkPoolVersion, checkPathLoop, checkGhFields, availabl
|
|
|
10
10
|
import { which } from "./toolchain.mjs";
|
|
11
11
|
import { findShimLoops, heavyShimScript } from "./heavy.mjs";
|
|
12
12
|
import { orchestrate, deferPolicy } from "./orchestrate.mjs";
|
|
13
|
-
import { providerLanes, isCloneFailure } from "./execution.mjs";
|
|
13
|
+
import { providerLanes, isCloneFailure, isEgressTimeout } from "./execution.mjs";
|
|
14
14
|
|
|
15
15
|
const pool = { mode: "remote", provider: "pool", tokenEnv: null, endpoint: null };
|
|
16
16
|
const until = async (f, ms = 3000) => { const t = Date.now(); while (!f()) { if (Date.now() - t > ms) throw new Error("timeout"); await new Promise((r) => setTimeout(r, 5)); } };
|
|
@@ -187,6 +187,18 @@ describe("sandbox.clone", () => {
|
|
|
187
187
|
assert.equal(o.terminalReason, "engine-error");
|
|
188
188
|
assert.equal(isCloneFailure("clone of repo ok"), false);
|
|
189
189
|
});
|
|
190
|
+
it("#5923: an ls-remote/fetch timeout ends deferred sandbox.egress_timeout with retry-in; other failures stay engine-error", async () => {
|
|
191
|
+
for (const t of ["fatal: unable to access 'https://github.com/o/r/': Failed to connect to github.com port 443: Connection timed out", "git ls-remote timed out after 60s", "git fetch hung: timeout"]) {
|
|
192
|
+
const r = await lanes(prov(), { logTail: () => t }).runOne(7, {}, {});
|
|
193
|
+
assert.equal(r.terminalReason, "deferred", t); assert.equal(r.code, "sandbox.egress_timeout", t); assert.ok(r.retryInSeconds > 0);
|
|
194
|
+
}
|
|
195
|
+
const e = await lanes(prov({ fetchResult: async () => ({ terminalReason: "engine-error", detail: "git fetch failed: Connection timed out" }) })).runOne(7, {}, {});
|
|
196
|
+
assert.equal(e.code, "sandbox.egress_timeout");
|
|
197
|
+
const o = await lanes(prov(), { logTail: () => "npm ERR! build failed" }).runOne(7, {}, {});
|
|
198
|
+
assert.equal(o.terminalReason, "engine-error");
|
|
199
|
+
assert.equal(isEgressTimeout("fetch of cache ok"), false);
|
|
200
|
+
assert.equal(isEgressTimeout("git clone timed out after 300s"), false);
|
|
201
|
+
});
|
|
190
202
|
it("is requeued with its retry-in and is not an engine-error (breaker input)", () => {
|
|
191
203
|
const p = deferPolicy({ terminalReason: "deferred", code: "sandbox.clone", retryInSeconds: 120 }, { now: 0 });
|
|
192
204
|
assert.equal(p.delayMs, 120000);
|
package/bin/lean/lean.mjs
CHANGED
|
@@ -25,7 +25,7 @@ import { stampText, checkStamp } from "./stagestamp.mjs";
|
|
|
25
25
|
import { acquireBranchLock, waitPidsExit } from "./branchlock.mjs";
|
|
26
26
|
import { parseRecurrenceConfig, recurrenceFacts, recursLinks, designLaneNote } from "./recurrence.mjs"; // #5751
|
|
27
27
|
import { areaOf, acquireHotArea, countCounters } from "./hotarea.mjs"; // #5751
|
|
28
|
-
import { contractRuleCounts, onlyTestPlanProblems, isTestPath, applyValidateRecipes, rewriteProjectDirCommand, deferChecklessPostDeploy, autoPostDeployE2e, applyRequirementDecisions, dedupeAddRequirements, loneE2eRows, reproEnvMiss, resolveForgedockPaths, resolvingIo, portableForgedockPaths, FORGEDOCK_CHECKS_VAR, FORGEDOCK_ENTRY_VAR, describesUnrunnableCommand, removedPathsOf, TRACKED, normalizeKindModes, blockingFailures, unverifiedRequirements, mutationTargets, mutationFailures, runMutationCheck, MUTATION_SURVIVED, isBugIssue, scopeText, explainFailures, inIssue, validateContract, snapQuotes, cliUsageError, normalizeRunnerCommand, applyAmendments, amendmentKindProblems, precheck, alreadyFixedOnBase, READONLY_PROD_RE, EXTERNAL_NEED_RE, intakeHostWork, repoTracks, dropScopeValidates, tagOutOfBand, parseReview, decide, mergeReviewRows, reaskable, criterionLines, closePlan, followupItems, renderPendingFollowups, bucketTally, pendingTracking, unnamedEdges, structureNote, impliedDocDeliverables, convertDelivered } from "./conformance.mjs";
|
|
28
|
+
import { isEnvValidateFailure, outputTail, contractRuleCounts, onlyTestPlanProblems, isTestPath, applyValidateRecipes, rewriteProjectDirCommand, deferChecklessPostDeploy, autoPostDeployE2e, applyRequirementDecisions, dedupeAddRequirements, loneE2eRows, reproEnvMiss, resolveForgedockPaths, resolvingIo, portableForgedockPaths, FORGEDOCK_CHECKS_VAR, FORGEDOCK_ENTRY_VAR, describesUnrunnableCommand, removedPathsOf, TRACKED, normalizeKindModes, blockingFailures, unverifiedRequirements, mutationTargets, mutationFailures, runMutationCheck, MUTATION_SURVIVED, isBugIssue, scopeText, explainFailures, inIssue, validateContract, snapQuotes, cliUsageError, normalizeRunnerCommand, applyAmendments, amendmentKindProblems, precheck, alreadyFixedOnBase, READONLY_PROD_RE, EXTERNAL_NEED_RE, intakeHostWork, repoTracks, dropScopeValidates, tagOutOfBand, parseReview, decide, mergeReviewRows, reaskable, criterionLines, closePlan, followupItems, renderPendingFollowups, bucketTally, pendingTracking, unnamedEdges, structureNote, impliedDocDeliverables, convertDelivered } from "./conformance.mjs";
|
|
29
29
|
import { checkAdmission, hostParallelism, ADMISSION_RETRY_SECONDS } from "./admission.mjs";
|
|
30
30
|
import { namedPaths, isTrustedIssueComment, prodFailureSignal } from "./prefilter.mjs";
|
|
31
31
|
import { writeStatus, postUpsert, isStatusPost, isUpsertPost, hasSection, clearPipelineLabels } from "./statuscomment.mjs";
|
|
@@ -37,7 +37,7 @@ import { hasRecipe, installLaneTools, RECIPES } from "../pool/lane-tools.mjs";
|
|
|
37
37
|
import { testRunnerProblems, preflightProbes, preflightProblems, unsetEnvVars, runPreflight, knownToContract, declaredEnv, depInstallFailures, toolMissingInstalls, testRunSummary, projectBinDirs, withLocalBins, manifestDepOwner } from "./preflight.mjs";
|
|
38
38
|
import { resolveLane, isDefaultLane, isShippedLane, DEFAULT_STAGING_BRANCH } from "./lane.mjs";
|
|
39
39
|
import { splitGate, rationaleLine } from "./decompose.mjs";
|
|
40
|
-
import { ceilingFor, predictRestart, handoffFacts, routeHandoff, buildReadsOf, NARROW_NOTE } from "./ceiling.mjs";
|
|
40
|
+
import { ceilingFor, modelInfo, restartDecision, DEFAULT_CEILING, WINDOW_SHARE, RESTART_COST_USD, CACHE_READ_USD, REAL_LIMIT_SHARE, predictRestart, handoffFacts, routeHandoff, buildReadsOf, NARROW_NOTE } from "./ceiling.mjs";
|
|
41
41
|
import { dockerLabels, LEDGER_TTL_MS } from "./ledger.mjs";
|
|
42
42
|
import { batchImageCache, envNamesOf, provisionSandboxes } from "./testsandbox.mjs";
|
|
43
43
|
import { repoKey, estimateCostUsd } from "../runner.mjs";
|
|
@@ -87,7 +87,7 @@ import { makeTurnBudget, TURN_BUDGET_DEFAULTS, scaledExtra, laneSize, recoverySi
|
|
|
87
87
|
import { pendingPitfall, pitfallRecord, foldPitfalls, selectPitfalls, failureLog } from "./pitfalls.mjs";
|
|
88
88
|
import { unjustified } from "./enumerating.mjs";
|
|
89
89
|
import { applyEnumerating, renameDuplicates, verifyApplied } from "./mechfix.mjs"; // #5348
|
|
90
|
-
import { addLaneWorktree, DEFAULT_SPARSE_MAX_KB } from "./worktree.mjs";
|
|
90
|
+
import { addLaneWorktree, DEFAULT_SPARSE_MAX_KB, isSpawnError, repoMissing } from "./worktree.mjs";
|
|
91
91
|
import { ceilingEnv, listedWorktree } from "./laneconfine.mjs";
|
|
92
92
|
import { claimWarm, refillWarm, warmTreeCount, NO_HOOKS } from "./warmtree.mjs";
|
|
93
93
|
import { ciSignal, cancelDecision, eventLog } from "./ci-watch.mjs";
|
|
@@ -124,7 +124,7 @@ import { reconcileCheckpoints } from "./checkpoint-reconcile.mjs";
|
|
|
124
124
|
import { guardStagedDeletions, deletionEvidence, maxForeignDeletions } from "./delguard.mjs";
|
|
125
125
|
import { createLedger, flattenPhases } from "./phaseledger.mjs";
|
|
126
126
|
import { DEFAULT_CATALOG_SOURCES, deriveCatalog, mergeRecipes, rewriteMissed, isDriftFailure, rewriteSubprojectVenv } from "./validate-catalog.mjs";
|
|
127
|
-
import { planStale, stackedBaseBlock, validStackedOn } from "./stacking.mjs";
|
|
127
|
+
import { planStale, stackedBaseBlock, validStackedOn, cascadeDecision, invalidatedChecks } from "./stacking.mjs";
|
|
128
128
|
import { runLightStep, runLightTests, lightBuildPrompt, upgradeNote, renderLiteReceipt } from "./lightlane.mjs";
|
|
129
129
|
|
|
130
130
|
/**
|
|
@@ -338,11 +338,21 @@ const defaultCredExec = (args) => {
|
|
|
338
338
|
* posts FORGE:DECISION and resumes the open PR on the rerun path with a recovery note. `final`
|
|
339
339
|
* (default true) is false when the runner may launch another attempt: the lane then never relabels (#4302)
|
|
340
340
|
*/
|
|
341
|
+
/** #5836: the post-merge steps shared by the lane and the merge train: close the issue as completed, then (label) `workflow:merged` and (branch) delete the lane branch on origin. All best effort. */
|
|
342
|
+
export async function closeMergedIssue({ gh, repo, issue, label = true, branch = null }) {
|
|
343
|
+
try { await gh(["issue", "close", String(issue), "-R", repo, "--reason", "completed"]); } catch { /* the issue stays open for the sweep */ }
|
|
344
|
+
if (label) {
|
|
345
|
+
await clearPipelineLabels({ gh, repo, issue });
|
|
346
|
+
try { await gh(["issue", "edit", String(issue), "-R", repo, "--add-label", "workflow:merged"]); } catch { /* best effort */ }
|
|
347
|
+
}
|
|
348
|
+
if (branch) { try { await gh(["api", "-X", "DELETE", `repos/${repo}/git/refs/heads/${branch}`]); } catch { /* already gone */ } }
|
|
349
|
+
}
|
|
350
|
+
|
|
341
351
|
export async function runCore(o) {
|
|
342
352
|
const armed = applyArmOverrides(o, o.issue); o = armed.options; // #5206: the arm's overrides shape the lane before any config is parsed
|
|
343
353
|
o = { ...o, io: resolvingIo(o.io, { exists: existsSync, checksCli: CHECKS_CLI, forgedockCli: FORGEDOCK_CLI }) }; // #5727: every executed command names this install's forgedock entry points
|
|
344
354
|
const { issue, repo, lane: requestedLane = null, laneOverride = false, branches = {}, cwd, dir, io, builderModel = null, reviewerModel = DEFAULT_REVIEWER_MODEL, fixModel = null,
|
|
345
|
-
toolchainOverride = null, testRunners = null, coupledFiles = null, validateRecipes = null, validateRegenerate = null, validateCatalogSources = null, routeReachability = null, docsConfig = null, outcomeEvidenceConfig = null, ciBudget = null, pagesConfig = null, designConfig = null, prodParity = null, envSetup = null, ciMaxMinutes = 360, holdMergesDuringReleaseCi = true, conformance = "shadow", conformanceKinds = null, conformanceMutation = "off", reviewIncomplete = "needs-human", reproTest = "prefer", reproQuality = "shadow", closeParent = false, mergeWait = "required", maxSessionLimitPauses = DEFAULT_MAX_SESSION_LIMIT_PAUSES, cliIdleMinutes = 15, cliMaxMinutes = 180, cliBusyMinutes = 45, contextCeilingTokens =
|
|
355
|
+
toolchainOverride = null, testRunners = null, coupledFiles = null, validateRecipes = null, validateRegenerate = null, validateCatalogSources = null, routeReachability = null, docsConfig = null, outcomeEvidenceConfig = null, ciBudget = null, pagesConfig = null, designConfig = null, prodParity = null, envSetup = null, ciMaxMinutes = 360, mergeTrain = "off", holdMergesDuringReleaseCi = true, conformance = "shadow", conformanceKinds = null, conformanceMutation = "off", reviewIncomplete = "needs-human", reproTest = "prefer", reproQuality = "shadow", closeParent = false, mergeWait = "required", maxSessionLimitPauses = DEFAULT_MAX_SESSION_LIMIT_PAUSES, cliIdleMinutes = 15, cliMaxMinutes = 180, cliBusyMinutes = 45, contextCeilingTokens = null, contextWindowShare = WINDOW_SHARE, contextRestartCostUsd = RESTART_COST_USD, contextCeilingBySize = null, routeHandoffTokens = 40000, turnBudgets = null, laneLimits = null, maxMergeRetries = 5, contractMaxCorrections = 3, reviewMaxResumes = 3, sessionLimitMaxWaitMs = DEFAULT_SESSION_LIMIT_WAIT_MS, contextWaitSeconds = 5, onProgress = () => {}, emitTelemetry = null, random = Math.random } = o;
|
|
346
356
|
const now = io.now ?? (() => Date.now());
|
|
347
357
|
const rotator = io.rotator !== undefined ? io.rotator : openRotator({ kind: o.accountRotator }); // #5094
|
|
348
358
|
// #5205: a rotator with pick() relaunches a limited phase pinned to another account; lane-level rotations and limited accounts
|
|
@@ -375,6 +385,8 @@ export async function runCore(o) {
|
|
|
375
385
|
const stackPlanned = o.planned && typeof o.planned.contractHash === "string" && typeof o.planned.baseSha === "string" ? o.planned : null;
|
|
376
386
|
// #5832 stacked lanes phase 2: `stackedOn` ({dependency, branch, sha}) builds on the dependency's PR-ready lane head and opens the PR on its branch.
|
|
377
387
|
let stackedOn = planOnly ? null : validStackedOn(o.stackedOn);
|
|
388
|
+
const cascadeLog = { kinds: [], costUsd: 0, ms: 0 }; // #5833: cascades of this stacked lane and what the rework cost
|
|
389
|
+
let stackInvalidation = null; // #5833: {changedPaths} narrows postMergeGate to the checks the dependency's final diff invalidates
|
|
378
390
|
const withLink = (body) => `${issuePrMarker(issue)}\n${body}`; // #5505: the issue → PR link GitHub does not record for a staging PR
|
|
379
391
|
const closeBlockers = (reason, exceptPr = null) => openPrBlockingClose({ repo, io: { gh: ghw }, issue, reason, exceptPr }).catch(() => []); // #5505: fail open
|
|
380
392
|
let branch = `feat/issue-${issue}-lean`; // #5469: an adopted PR's own head branch replaces it
|
|
@@ -422,6 +434,7 @@ export async function runCore(o) {
|
|
|
422
434
|
};
|
|
423
435
|
let pageVisual = null; // #5770: the engine's visual capture {sha, screenshots, errors, rows}, kept for the page gate and the PR body
|
|
424
436
|
|
|
437
|
+
const ctxStats = { restarts: 0, continues: 0, compactions: 0, turns: 0 }; // #5829: reported on the lane result
|
|
425
438
|
const builderTriggers = []; // #4362: implement-attempt triggers in order, for the lane's first-pass flag
|
|
426
439
|
let usageUnknown = false, inflight = null; // #5334: a killed session streamed nothing; the builder call in flight (flushed when a signal ends the run)
|
|
427
440
|
const impl = { cost: 0, models: new Set() }; // #4397: implement spend and reported models, for the verifier
|
|
@@ -436,7 +449,7 @@ export async function runCore(o) {
|
|
|
436
449
|
const rec = { event: "PHASE_ATTEMPT_USAGE", phase, attempt: n, trigger, ...(restartOf ? { restart_of: restartOf } : {}), usage: r?.usage ?? null, duration_ms: num(r?.durationMs) ?? 0,
|
|
437
450
|
cost_usd: est ?? num(r?.costUsd), cost_usd_delta: c.delta, ...(est != null ? { cost_estimated: true } : {}), ...(killed && !r?.usage ? { usage_unknown: true } : {}), cost_usd_session: c.session, model: r?.model ?? null, turns: num(r?.turns), ...(mode ? { mode } : {}),
|
|
438
451
|
...(num(r?.baselineTokens) != null ? { baseline_tokens: num(r.baselineTokens) } : {}), ...(r?.tools ? { tools: r.tools } : {}), lane_profile: r?.laneProfile ?? laneProfile.name, ...expTag }; // #4410, #4629
|
|
439
|
-
if (phase === "implement") { builderTriggers.push({ trigger, restart_of: restartOf }); impl.cost += c.delta ?? 0; if (r?.model && r.model !== "default") impl.models.add(r.model); tb.note(num(r?.turns), stage === "implement"); }
|
|
452
|
+
if (phase === "implement") { ctxStats.turns += num(r?.turns) ?? 0; builderTriggers.push({ trigger, restart_of: restartOf }); impl.cost += c.delta ?? 0; if (r?.model && r.model !== "default") impl.models.add(r.model); tb.note(num(r?.turns), stage === "implement"); }
|
|
440
453
|
ev(rec); await emit(rec);
|
|
441
454
|
modelMs += rec.duration_ms; // #4451: model time next to the lane's wall time
|
|
442
455
|
const ledgerNow = phaseLedger.current(); // #5649: model time of contract and fix calls lands in those phases
|
|
@@ -764,12 +777,12 @@ export async function runCore(o) {
|
|
|
764
777
|
if (deferTail) { postRun.add("lane-facts", postLaneFacts); postRun.add("trajectory", postTrajectory); } else await postTrajectory();
|
|
765
778
|
}
|
|
766
779
|
if (deferTail) postRun.add("teardown", () => teardown(reason, extra)); // last: the structure delta and guard read the worktree
|
|
767
|
-
if (reason === "merged" || reason === "invalid") await clearPipelineLabels({ gh: ghc, repo, issue }); // #5592: a merged or closed issue keeps no needs-human / parked:* / remediation-queue
|
|
780
|
+
if (reason === "merged" || reason === "invalid") await clearPipelineLabels({ gh: ghc, repo, issue, onFail: (n, e) => T.anomalies.push(`pipeline labels not cleared${n.length ? `: ${n.join(", ")}` : ""} (${String(e?.message ?? e).slice(0, 120)})`) }); // #5592/#5759: a merged or closed issue keeps no needs-human / parked:* / remediation-queue
|
|
768
781
|
await releaseLease(reason, code, extra.mergedTo ?? null);
|
|
769
|
-
done = { terminalReason: reason, detail, branch, worktree: wt, cost_usd: usage.cost_usd, tokens: { input: usage.input, output: usage.output, cache: usage.cache }, wall_ms: now() - t0, model_ms: modelMs, phases: phaseLedger.snapshot(),
|
|
782
|
+
done = { terminalReason: reason, detail, branch, worktree: wt, ...(cascadeLog.kinds.length ? { cascade: cascadeLog.kinds[cascadeLog.kinds.length - 1], cascades: [...cascadeLog.kinds], cascade_cost_usd: Math.round(cascadeLog.costUsd * 1e6) / 1e6, cascade_minutes: Math.round(cascadeLog.ms / 6000) / 10 } : {}), cost_usd: usage.cost_usd, tokens: { input: usage.input, output: usage.output, cache: usage.cache }, wall_ms: now() - t0, model_ms: modelMs, phases: phaseLedger.snapshot(),
|
|
770
783
|
...(laneHead && reason !== "merged" ? { laneHead: { ...laneHead } } : {}), light, ...(lightVerdict ? { light_eligibility: lightVerdict } : {}), ...(lightUpgrade ? { light_upgrade: lightUpgrade } : {}), // #4453
|
|
771
784
|
...(Object.keys(waits).length ? { waits: { ...waits } } : {}), ...(followupsFiled.length ? { followups: followupsFiled.map((f) => ({ ...f })) } : {}), ...(pendingRecord().length ? { pendingFollowups: pendingRecord() } : {}), ...(heavyQueueMax ? { heavyQueueMax } : {}), ...(precheckRan ? { precheckMs, precheckDeferred } : {}),
|
|
772
|
-
...(firstPassOf(builderTriggers) != null ? { firstPass: firstPassOf(builderTriggers) } : {}), ...(tb.record() ? { turns: tb.record() } : {}), // #4392
|
|
785
|
+
...(firstPassOf(builderTriggers) != null ? { firstPass: firstPassOf(builderTriggers) } : {}), ...(tb.record() ? { turns: tb.record() } : {}), context: { ...ctxStats, cost_usd: impl.cost }, // #4392, #5829
|
|
773
786
|
...(route ? { builderRoute: { tier: route.tier, class: route.class, escalated, model: route.model ?? "default" } } : {}),
|
|
774
787
|
...(gateRan ? { conformance: { mode: conformance === "enforce" || riskEnforced ? "enforce" : "shadow", would: shadowWould, ...(adequacyCounts(adequacy) ? { test_adequacy: adequacyCounts(adequacy) } : {}), risk: Boolean(riskEnforced), ...(Object.keys(kinds).length ? { kinds: [...failureClasses] } : {}) } } : {}), ...extra };
|
|
775
788
|
if (extra.planned) done.planned = extra.planned; // #5831
|
|
@@ -1150,8 +1163,10 @@ export async function runCore(o) {
|
|
|
1150
1163
|
try { await killedAttempt(cur.n, snap ?? {}, cur.opts, cur.at); } catch { /* telemetry never blocks the teardown */ }
|
|
1151
1164
|
}
|
|
1152
1165
|
/** #4390: builder calls stopped at the context ceiling restart fresh; planning (and its corrections) run uncapped. */
|
|
1153
|
-
let laneCeiling = contextCeilingTokens; // #5346: set to the lane size's ceiling once the contract is frozen
|
|
1154
|
-
|
|
1166
|
+
let laneCeiling = contextCeilingTokens ?? DEFAULT_CEILING; // #5346: set to the lane size's ceiling once the contract is frozen; #5829: model-aware when no explicit one
|
|
1167
|
+
let ceilingExplicit = contextCeilingTokens != null || contextCeilingBySize != null; // #5829
|
|
1168
|
+
let laneModelInfo = null; // #5829: the routed model's static window and cache-read price (null = unknown: kill-and-restart at the ceiling)
|
|
1169
|
+
const UNCEILED = ["plan", "contract_correction", "block_correction"], CONTEXT_RESTARTS_MAX = 3, CONTEXT_COMPACT_MAX = 2;
|
|
1155
1170
|
/** #5812: the planning session's last-turn context, the files it read and its final reply, for the route hand-off. */
|
|
1156
1171
|
let planSession = null;
|
|
1157
1172
|
const notePlanSession = (r, trigger) => { planSession = { endTokens: num(r.endTokens), read: [...new Set([...(planSession?.read ?? []), ...handoffFacts(r.toolUses).read])], text: trigger === "plan" ? String(r.text ?? "") : planSession?.text ?? "" }; };
|
|
@@ -1165,16 +1180,36 @@ export async function runCore(o) {
|
|
|
1165
1180
|
const budgeted = stage === "implement" && tb.on(); // #4392: the build and its restarts spend the implement turn budget
|
|
1166
1181
|
if (budgeted && tb.remaining() <= 0) return await budgetWrapup(n, opts);
|
|
1167
1182
|
opts.turnMax = budgeted ? tb.remaining() : 0;
|
|
1168
|
-
|
|
1183
|
+
let continued = null; // #5829: the cost gate lets the session run past the ceiling, up to the model's real limit
|
|
1184
|
+
if (opts.contextMax > 0 && laneModelInfo && !ceilingExplicit) { // an explicit ceiling is an override: the gate only moves a model-derived one
|
|
1185
|
+
const limit = Math.floor(laneModelInfo.window * REAL_LIMIT_SHARE);
|
|
1186
|
+
const g = restartDecision({ context: opts.contextMax, turnsLeft: budgeted ? tb.remaining() : 20, cachePrice: laneModelInfo.cacheRead ?? CACHE_READ_USD, restartCost: contextRestartCostUsd, window: laneModelInfo.window });
|
|
1187
|
+
if (g.action === "continue" && limit > opts.contextMax) { continued = { before: opts.contextMax, limit }; opts.contextMax = limit; ctxStats.continues++; ev({ event: "CONTEXT_CONTINUE", ceiling: continued.before, limit, continue_cost_usd: g.continueCost, restart_cost_usd: g.restartCost, trigger: opts.trigger ?? null }); }
|
|
1188
|
+
}
|
|
1189
|
+
try { const r = await builderOnce(n, p, resume, live, opts); if (continued && num(r?.endTokens) > continued.before) ev({ event: "CONTEXT_CONTINUED", tokens_before: continued.before, tokens_after: num(r.endTokens), limit: continued.limit }); return r; } catch (e) {
|
|
1169
1190
|
if (e?.code === "CLI_TURNS") {
|
|
1170
1191
|
await attempt("implement", n, { usage: e.usage ?? null, turns: e.turns ?? null, tools: toolStats(e.toolUses), costUsd: null, model: opts.model ?? builderModel ?? null }, opts.mode, opts.trigger, opts.restartOf);
|
|
1171
1192
|
return await budgetWrapup(n, opts);
|
|
1172
1193
|
}
|
|
1173
1194
|
if (e?.code === "CLI_CONTEXT") {
|
|
1174
|
-
contextRestarts++;
|
|
1175
|
-
ev({ event: "CONTEXT_CEILING", context_tokens: e.context ?? null, ceiling: laneCeiling, turns: e.turns ?? null, trigger: opts.trigger ?? null, restart: contextRestarts, last_tool: e.lastTool?.name ?? null });
|
|
1195
|
+
contextRestarts++; ctxStats.restarts++;
|
|
1196
|
+
ev({ event: "CONTEXT_CEILING", context_tokens: e.context ?? null, ceiling: e.contextMax ?? laneCeiling, real_limit: Boolean(continued), turns: e.turns ?? null, trigger: opts.trigger ?? null, restart: contextRestarts, last_tool: e.lastTool?.name ?? null });
|
|
1176
1197
|
await attempt("implement", n, { usage: e.usage ?? null, turns: e.turns ?? null, tools: toolStats(e.toolUses), costUsd: null, model: opts.model ?? laneModel() ?? null }, opts.mode, opts.trigger, opts.restartOf);
|
|
1177
1198
|
await checkpoint("context ceiling");
|
|
1199
|
+
// #5829: compact the stopped session in place (the CLI's /compact on a resume) and continue it; any failure falls through to the digest restart
|
|
1200
|
+
if (e.sessionId && ctxStats.compactions < CONTEXT_COMPACT_MAX) {
|
|
1201
|
+
ctxStats.compactions++;
|
|
1202
|
+
let c = null; try { c = await builderOnce(n, "/compact", e.sessionId, live, { model: opts.model ?? null, mode: opts.mode ?? null, keepSession: true, trigger: "context_compact", restartOf: opts.restartOf ?? opts.trigger ?? null }); } catch { c = null; }
|
|
1203
|
+
const after = num(c?.endTokens);
|
|
1204
|
+
if (after != null && num(e.context) != null && after < e.context * 0.8) {
|
|
1205
|
+
ev({ event: "CONTEXT_COMPACTED", tokens_before: e.context, tokens_after: after, session_id: e.sessionId });
|
|
1206
|
+
T.decisions.push(`Builder session reached ${e.context} context tokens: compacted in place to ${after} and continued the same session`);
|
|
1207
|
+
p = "The session context was compacted. Continue the task from where you left off; .forge-lean/contract.json stays the authority and the work so far is checkpointed on the branch."; resume = e.sessionId; opts.restartOf ??= opts.trigger ?? null; opts.trigger = "context_compact_continue";
|
|
1208
|
+
contextRestarts--; ctxStats.restarts--; // a compaction is not a restart
|
|
1209
|
+
continue;
|
|
1210
|
+
}
|
|
1211
|
+
ev({ event: "CONTEXT_COMPACT_FAILED", tokens_before: e.context ?? null, tokens_after: after, session_id: e.sessionId });
|
|
1212
|
+
}
|
|
1178
1213
|
T.decisions.push(`Builder session reached ${e.context ?? "?"} context tokens (ceiling ${laneCeiling}): checkpointed, restarted fresh from the contract, diff and last validate result`);
|
|
1179
1214
|
p = restart() + await contextRestartNote(handoffFacts(e.toolUses, e.lastTool)); resume = null; opts.restartOf ??= opts.trigger ?? null; opts.trigger = "context_restart";
|
|
1180
1215
|
continue;
|
|
@@ -1563,12 +1598,19 @@ export async function runCore(o) {
|
|
|
1563
1598
|
|
|
1564
1599
|
try {
|
|
1565
1600
|
// ---- 1. claim ----
|
|
1601
|
+
// #5890: a missing or non-git repo cwd ends the lane deferred (sandbox.repo_missing), before any lane git call
|
|
1602
|
+
if (io.fs?.exists) {
|
|
1603
|
+
let why = null;
|
|
1604
|
+
if (!(await io.fs.exists(cwd))) why = `repo directory ${cwd} does not exist`;
|
|
1605
|
+
else { try { await io.git(["rev-parse", "--git-dir"], { cwd }); } catch (e) { if (isSpawnError(e) || /not a git repository/i.test(String(e?.stderr ?? e?.message ?? ""))) why = `${cwd} is not a usable git repository`; } }
|
|
1606
|
+
if (why) throw Object.assign(new Error(why), { deferCode: OUTCOME_CODES.SANDBOX_REPO_MISSING, deferDetail: `${why}; the lane is requeued`, retryInSeconds: 120 });
|
|
1607
|
+
}
|
|
1566
1608
|
// #5435: the lane fetch is independent of the claim's GitHub writes; start it now and await it before the resume probe.
|
|
1567
1609
|
const fetchP = step("fetch", async () => { try { await io.git(["fetch", "origin", lane], { cwd }); } catch { /* offline: use the local ref */ } });
|
|
1568
1610
|
await step("claim", async () => {
|
|
1569
1611
|
await label("investigating");
|
|
1570
1612
|
// #5592: a live lane is not parked: needs-human, needs-human:*, parked:* and remediation-queue from an earlier run come off (a later park puts them back)
|
|
1571
|
-
await clearPipelineLabels({ gh: ghc, repo, issue, labels: iss.labels });
|
|
1613
|
+
await clearPipelineLabels({ gh: ghc, repo, issue, labels: iss.labels, onFail: (n, e) => T.anomalies.push(`pipeline labels not cleared${n.length ? `: ${n.join(", ")}` : ""} (${String(e?.message ?? e).slice(0, 120)})`) });
|
|
1572
1614
|
await post("FORGE:STARTED", `Started work on #${issue} (base \`${lane}\`).`);
|
|
1573
1615
|
if (recover) {
|
|
1574
1616
|
// #4267: the batch decided to recover this issue itself; the label goes so the issue is live again.
|
|
@@ -2658,7 +2700,8 @@ export async function runCore(o) {
|
|
|
2658
2700
|
{ // #4392, #4505: next size on a budget recovery; #4587: a big L contract and an L recovery get extra turns
|
|
2659
2701
|
const sz = recoverySize(laneSize({ contract: frozen, labels: (iss?.labels ?? []).map((l) => l?.name ?? l) }), recover);
|
|
2660
2702
|
tb.setSize(sz, scaledExtra({ size: sz, contract: frozen, recover, base: (turnBudgets ?? {}).L ?? TURN_BUDGET_DEFAULTS.L }));
|
|
2661
|
-
laneCeiling = ceilingFor(sz, { tokens: contextCeilingTokens, bySize: contextCeilingBySize }); // #5346
|
|
2703
|
+
laneCeiling = ceilingFor(sz, { tokens: contextCeilingTokens, bySize: contextCeilingBySize, model: laneModel(), share: contextWindowShare }); // #5346, #5829
|
|
2704
|
+
laneModelInfo = modelInfo(laneModel());
|
|
2662
2705
|
}
|
|
2663
2706
|
if (io.fs.write) { try { await io.fs.write(`${wt}/${CONTRACT_FILE}`, `${contractJson(frozen)}\n`); } catch { /* the prompt still names it */ } }
|
|
2664
2707
|
// #4364: what `forgedock check` needs from the operator's forge.yaml (gitignored, so not in the worktree)
|
|
@@ -3042,7 +3085,8 @@ export async function runCore(o) {
|
|
|
3042
3085
|
await i18nGate("hand-off");
|
|
3043
3086
|
/** #4406: verify.post_merge (else the scoped typecheck) on the merged tree before the base-sync push; fix rounds up to verify.max_rounds. */
|
|
3044
3087
|
async function postMergeGate(trigger) {
|
|
3045
|
-
|
|
3088
|
+
let commands = io.runCommand && !isSplit ? [...new Set([...postMergeCommands({ configured: vcfg.postMerge, scoped: (await io.postMergeChecks?.({ cwd: wt, base }).catch(() => [])) ?? [], mode: vcfg.mode }), ...(guardOn() ? vcfg.invariants : [])])] : [];
|
|
3089
|
+
if (stackInvalidation) { const all = commands; commands = invalidatedChecks({ changedPaths: stackInvalidation.changedPaths, checks: commands }); if (commands.length < all.length) T.decisions.push(`Stacked lane: ${all.length - commands.length} check(s) not re-run, the dependency's final diff does not touch them`); } // #5833 // #5239: the guard set also runs on the merged tree
|
|
3046
3090
|
let fixed = false, results = [];
|
|
3047
3091
|
for (let round = 0; commands.length; round++) {
|
|
3048
3092
|
await renew();
|
|
@@ -3073,12 +3117,27 @@ export async function runCore(o) {
|
|
|
3073
3117
|
const g = failed.filter((f) => guardFailing([f]));
|
|
3074
3118
|
if (!g.length || isSplit || !io.runCommand) return null;
|
|
3075
3119
|
const baseRuns = await heavyStep("precheck", () => runOnBase({ commands: g.map((f) => f.command), git, runCommand: io.runCommand, mergeBase: base, cwd: wt, env: laneEnv(), timeoutMs: vcfg.precheckTimeoutSeconds * 1000 }));
|
|
3076
|
-
const { baseRed } = classifyBaseRed({ failed: g, baseRuns });
|
|
3120
|
+
const { baseRed: red, env: envRed } = classifyBaseRed({ failed: g, baseRuns });
|
|
3121
|
+
const tailOf = (c) => String(baseRuns.find((b) => b.command === c)?.output ?? "").slice(-4096);
|
|
3122
|
+
if (envRed.length) {
|
|
3123
|
+
T.decisions.push(`env.base_probe: guard command(s) ${envRed.map((f) => `\`${f.command}\``).join(", ")} failed on ${base} with an environment signature, not a red base; the failure stays the lane's. Base output tail: ${envRed.map((f) => tailOf(f.command).slice(-500)).join(" | ")}`);
|
|
3124
|
+
ev({ event: "BASE_PROBE_ENV", code: "env.base_probe", commands: envRed.map((f) => f.command), output: envRed.map((f) => tailOf(f.command).slice(-500)) });
|
|
3125
|
+
}
|
|
3126
|
+
let baseRed = red;
|
|
3127
|
+
if (baseRed.length && typeof io.verifyBaseOnHost === "function") { // R6: a pass on the bare base tip at the host makes the sandbox result environment
|
|
3128
|
+
const ok = [];
|
|
3129
|
+
for (const f of baseRed) { let r = null; try { r = await io.verifyBaseOnHost({ command: f.command, base }); } catch { /* no verdict */ } if (Number(r?.rc) === 0) ok.push(f); }
|
|
3130
|
+
if (ok.length) { T.decisions.push(`env.base_probe: guard command(s) ${ok.map((f) => `\`${f.command}\``).join(", ")} pass on the bare ${base} tip at the host; the sandbox base failure is environment, no issue filed`); baseRed = baseRed.filter((f) => !ok.includes(f)); }
|
|
3131
|
+
}
|
|
3077
3132
|
if (!baseRed.length) return null;
|
|
3078
3133
|
const att = await attributeBaseRed({ failed: baseRed, git, base });
|
|
3079
|
-
|
|
3134
|
+
let baseSha = "", commitDate = "";
|
|
3135
|
+
try { baseSha = String(await git(["rev-parse", base])).trim(); } catch { /* key falls back to the attributed sha */ }
|
|
3136
|
+
try { if (att?.sha) commitDate = String(await git(["show", "-s", "--format=%cI", att.sha])).trim(); } catch { /* no reopen */ }
|
|
3137
|
+
const cmds = baseRed.map((f) => f.command), outputs = Object.fromEntries(cmds.map((c) => [c, tailOf(c)]));
|
|
3138
|
+
const n = await reportBaseRed({ ghc: ghw, repo, base, att, laneIssue: issue, commands: cmds, outputs, baseSha, commitDate });
|
|
3080
3139
|
T.decisions.push(`Guard command(s) ${cmds.map((c) => `\`${c}\``).join(", ")} also fail on ${base}${att ? ` (last change ${att.sha.slice(0, 12)}${att.issue ? `, #${att.issue}` : ""})` : ""}; lane deferred behind ${n ? `#${n}` : "the base fix"}`);
|
|
3081
|
-
ev({ event: "BASE_RED", commands: cmds, sha: att?.sha ?? null, issue: att?.issue ?? null, tracked: n });
|
|
3140
|
+
ev({ event: "BASE_RED", commands: cmds, output: cmds.map((c) => tailOf(c).slice(-500)), sha: att?.sha ?? null, issue: att?.issue ?? null, tracked: n });
|
|
3082
3141
|
return await finish("deferred", `base ${base} is red on guard command(s) ${cmds.join(", ")}; deferred behind ${n ? `#${n}` : "the base fix"}`, { code: OUTCOME_CODES.BASE_RED, retryInSeconds: 900 }, OUTCOME_CODES.BASE_RED);
|
|
3083
3142
|
}
|
|
3084
3143
|
const structureLine = structureNote(structure);
|
|
@@ -3717,9 +3776,10 @@ export async function runCore(o) {
|
|
|
3717
3776
|
if (outcome.state === "spec-only") return await needsHuman(`The page gate needs an approved FORGE:DESIGN_SPEC (run /design) or visual evidence a builder resume cannot produce, so no resume or recovery lane was spent:\n\n${list}`, OUTCOME_CODES.DESIGN_SPEC_REQUIRED, { ask: `Run /design for #${issue}` });
|
|
3718
3777
|
// #5371: a remote sandbox is a different environment from the host: its failed frozen validate is rerun once in a local recovery lane before it counts
|
|
3719
3778
|
// #5732: so is a repro head failure whose output carries no assertion text (an env error of the sandbox, not a red test)
|
|
3720
|
-
if (o.placement?.where === "remote" && !recover && outcome.failures?.length && outcome.failures.every((f) => f?.kind === "validate_failed" || (f?.kind === "repro_red_green" && f.head === "FAILED" && f.assertion === false))) {
|
|
3779
|
+
if (o.placement?.where === "remote" && !recover && outcome.failures?.length && outcome.failures.every((f) => (f?.kind === "validate_failed" && isEnvValidateFailure(f.output)) || (f?.kind === "repro_red_green" && f.head === "FAILED" && f.assertion === false))) {
|
|
3780
|
+
const sandboxTail = outcome.failures.filter((f) => f?.kind === "validate_failed" && f.output).map((f) => `\nSandbox output tail (the host replay starts from this):${outputTail(f.output)}`).join(""); // #5730
|
|
3721
3781
|
T.anomalies.push("Remote validate failure: rerun on the host in a local recovery lane before it is terminal");
|
|
3722
|
-
return await needsHuman(`A frozen validate command failed in the remote sandbox (exit non-zero on the engine's rerun). The sandbox is a different environment from the host, so no builder resume was spent; the branch is pushed and a local recovery lane reruns the frozen command on the host (pass: the change stands; fail: conformance.unimplemented):\n${list}`, ENV_VALIDATE_PLACEMENT);
|
|
3782
|
+
return await needsHuman(`A frozen validate command failed in the remote sandbox (exit non-zero on the engine's rerun). The sandbox is a different environment from the host, so no builder resume was spent; the branch is pushed and a local recovery lane reruns the frozen command on the host (pass: the change stands; fail: conformance.unimplemented):\n${list}${sandboxTail}`, ENV_VALIDATE_PLACEMENT);
|
|
3723
3783
|
}
|
|
3724
3784
|
const reproProdFail = outcome.state === "already-fixed" ? prodFailureSignal(trustedComments) : null; // #5734: a passing repro is no prod outcome
|
|
3725
3785
|
if (reproProdFail) return await needsHuman(prodFailNote("already-fixed (repro passes on the base)", reproProdFail), OUTCOME_CODES.BUILDER_NO_EVIDENCE);
|
|
@@ -4135,30 +4195,94 @@ export async function runCore(o) {
|
|
|
4135
4195
|
return null;
|
|
4136
4196
|
}
|
|
4137
4197
|
|
|
4198
|
+
// #5839: with the train on every lane kind but a split hands over at PR-ready (a split is never resolved by an LLM and is re-split on the new base, so it stays in-lane).
|
|
4199
|
+
// The merge-time work of e2e, sequence-file and close-record lanes travels as a persisted post-merge record the train replays.
|
|
4200
|
+
async function trainPlain() { return !isSplit; }
|
|
4201
|
+
function postMergeRecord() {
|
|
4202
|
+
const pend = pendingRecord(), notes = [];
|
|
4203
|
+
const keepOpen = Boolean(closing.checklist || closing.liveBlocked || closing.transferred || pend.length);
|
|
4204
|
+
if (pend.length) notes.push({ marker: "FORGE:FOLLOWUP_PENDING", body: renderPendingFollowups(pend, pr) });
|
|
4205
|
+
if (closing.checklist) notes.push({ marker: "FORGE:TRACKED", body: `## Left open: partial\nMerged by PR #${pr}, but these acceptance criteria are not met by it:\n${(closing.unticked ?? []).map((u) => `- [ ] ${u}`).join("\n")}${closing.tracked?.length ? `\n\nTracked in ${closing.tracked.join(", ")}.` : ""}` });
|
|
4206
|
+
if (closing.transferred) notes.push({ marker: "FORGE:TRACKED", body: `## Left open: transferred, not met\nMerged by PR #${pr}, but these end-to-end/manual requirements were not run in the lane:\n${(closing.transfer ?? closing.open ?? []).map((r) => `- ${r.id}`).join("\n")}` });
|
|
4207
|
+
if (closing.liveBlocked) notes.push({ marker: "FORGE:TRACKED", body: `## Left open: live acceptance deferred on a default-on change\nMerged by PR #${pr}, but these requirements still need live verification:\n${(closing.blocks ?? []).map((b) => `- ${b.id} (flag ${b.flag})`).join("\n")}` });
|
|
4208
|
+
if (!keepOpen && closing.tracked?.length) notes.push({ marker: "FORGE:TRACKED", body: `## Remaining work tracked\nClosed as completed by PR #${pr}. The contracted deferred and post-deploy requirements are tracked in ${closing.tracked.join(", ")}.` });
|
|
4209
|
+
return { keepOpen, notes, ...(pend.length ? { pendingFollowups: pend } : {}), ...(seqLease ? { sequence: true } : {}) };
|
|
4210
|
+
}
|
|
4211
|
+
async function trainHandover(why, conflicting = false) {
|
|
4212
|
+
if (!conflicting && e2eHead !== localHead) { const g = await e2eGate(); if (g?.done) return g.done; if (g?.again) return { again: true }; } // the e2e gate runs at the head in the lane; its merge-time record is replayed by the train
|
|
4213
|
+
ev({ event: "PR_READY", pr, head: localHead, required, policy });
|
|
4214
|
+
T.merge = [policyText, `pr-ready: ${why}, merge handed to the train at ${localHead.slice(0, 12)}`];
|
|
4215
|
+
return await finish("pr-ready", `PR #${pr} reviewed at ${localHead.slice(0, 12)}; ${why}, merge handed to the merge train`, { pr, head: localHead, required, policy, lane: resumed?.base ?? lane, ...(milestone ? { milestone } : {}), postMerge: postMergeRecord(), laneSide: { syncs, baseConflicts: conflicting ? 1 : 0 } });
|
|
4216
|
+
}
|
|
4217
|
+
|
|
4138
4218
|
// ---- 7. (sync) wait per policy, (sync) merge at the reviewed head ----
|
|
4139
4219
|
let lastStates = null; // the last required-check poll, reused by the DCO gate (#4651)
|
|
4140
4220
|
// #5832: review passed and precheck green: this head is PR-ready (FORGE:STATE `prReady`, read by the orchestrator's stacked admission).
|
|
4141
4221
|
try { if (finishing) throw new Error("finishing"); leaseState = { ...leaseState, prReady: { pr, branch, sha: localHead } }; await writeLease(leaseObj()); ev({ event: "PR_READY", pr, branch, sha: localHead }); } catch { /* best effort */ }
|
|
4142
4222
|
const stackedState = stackedOn ?? validStackedOn(leaseState?.stackedOn);
|
|
4143
|
-
const
|
|
4144
|
-
try {
|
|
4223
|
+
const depInfo = async () => { // #5833: the dependency's PRs from its branch -> {state: merged|closed|open, head}
|
|
4224
|
+
try {
|
|
4225
|
+
const l = JSON.parse(String(await ghc(["pr", "list", "-R", repo, "--head", stackedState.branch, "--state", "all", "--json", "number,state,headRefOid"])) || "[]");
|
|
4226
|
+
const open = l.find((x) => x?.state === "OPEN");
|
|
4227
|
+
if (open) return { state: "open", head: open.headRefOid ?? null }; // #5908: an open PR is the current dependency; a stale MERGED PR from a reused branch name must not satisfy it
|
|
4228
|
+
if (l.some((x) => x?.state === "MERGED")) return { state: "merged", head: null };
|
|
4229
|
+
return { state: l.length ? "closed" : "unknown", head: null };
|
|
4230
|
+
} catch { return { state: "unknown", head: null }; }
|
|
4231
|
+
};
|
|
4232
|
+
const depMerged = async () => (await depInfo()).state === "merged";
|
|
4233
|
+
const cascade = (kind, t1) => { cascadeLog.kinds.push(kind); cascadeLog.costUsd += Math.max(0, usage.cost_usd - t1.cost); cascadeLog.ms += now() - t1.at; ev({ event: "STACK_CASCADE", cascade: kind, pr, dependency: stackedState.dependency }); T.decisions.push(`Stacked lane cascade: ${kind} (dependency #${stackedState.dependency})`); };
|
|
4234
|
+
const dropStacked = async (why) => { // drop the stacked PR and branch; the rerun starts from the frozen contract
|
|
4235
|
+
try { await ghw(["pr", "close", String(pr), "-R", repo, "--comment", why]); } catch { /* best effort */ }
|
|
4236
|
+
try { await gitPush(["push", "origin", "--delete", branch]); } catch { /* best effort */ }
|
|
4145
4237
|
};
|
|
4146
4238
|
if (stackedState) { // wait for the dependency to merge, then move the PR onto the lane (merge.stacked_base never merges it before)
|
|
4147
4239
|
const since = now();
|
|
4148
|
-
|
|
4240
|
+
let curSha = stackedState.sha;
|
|
4241
|
+
for (;;) {
|
|
4242
|
+
const di = await depInfo(), t1 = { cost: usage.cost_usd, at: now() };
|
|
4243
|
+
if (di.state === "merged") break;
|
|
4244
|
+
if (di.state === "closed") { // ended unsatisfied: re-plan the dependent on the lane base
|
|
4245
|
+
cascade("replan", t1); await dropStacked(`stacked dependency #${stackedState.dependency} ended without merging; re-planning on ${lane}`);
|
|
4246
|
+
return await finish("deferred", `stacked dependency #${stackedState.dependency} ended unsatisfied; dependent re-planned on ${lane}`, { code: "stack.replan", pr, cascade: "replan" });
|
|
4247
|
+
}
|
|
4248
|
+
if (cascadeDecision({ depState: di.state, depHeadSha: di.head, stackedSha: curSha })) { // the dependency head moved: rebase and re-verify, or restart on a conflict
|
|
4249
|
+
try { await git(["fetch", "origin", stackedState.branch]); } catch { /* offline: use the local ref */ }
|
|
4250
|
+
let conflict = false;
|
|
4251
|
+
try { await git(["merge", "--no-commit", "--no-ff", base]); } catch { conflict = true; }
|
|
4252
|
+
try { await gitOut(["merge", "--abort"]); } catch { /* nothing to abort */ }
|
|
4253
|
+
const kind = cascadeDecision({ depState: "open", depHeadSha: di.head, stackedSha: curSha, rebaseConflict: conflict });
|
|
4254
|
+
if (kind === "restart") {
|
|
4255
|
+
cascade("restart", t1); await dropStacked(`rebase onto the moved head of #${stackedState.dependency} conflicts; restarting from the frozen contract`);
|
|
4256
|
+
return await finish("deferred", `stacked dependency #${stackedState.dependency} head moved and the rebase conflicts; restarting from the frozen contract`, { code: "stack.restart", pr, cascade: "restart" });
|
|
4257
|
+
}
|
|
4258
|
+
const r1 = await baseSync("stacked dependency head moved"); if (r1) return r1;
|
|
4259
|
+
const rv = await doReview(); // the review delta
|
|
4260
|
+
if (rv.env) return await envNeedsHuman(rv.env);
|
|
4261
|
+
if (rv.unusable || rv.fail) return await needsHuman(`Review ${rv.fail ? "FAIL" : "unusable"} after rebasing onto the moved head of #${stackedState.dependency}: ${rv.reason ?? rv.unusable}`, rv.fail ? OUTCOME_CODES.REVIEW_FAILED : UNUSABLE_REVIEW_CODES[rv.unusable]);
|
|
4262
|
+
await gatePassed("review");
|
|
4263
|
+
curSha = di.head; localHead = await gitOut(["rev-parse", "HEAD"]);
|
|
4264
|
+
leaseState = { ...leaseState, stackedOn: { ...stackedState, sha: curSha }, prReady: { pr, branch, sha: localHead } }; try { await writeLease(leaseObj()); } catch { /* best effort */ }
|
|
4265
|
+
cascade("reverify", t1); continue;
|
|
4266
|
+
}
|
|
4149
4267
|
if (now() - since >= ciMaxMinutes * 60000) return await finish("ci-pending", `stacked PR #${pr} waited ${ciMaxMinutes} min for dependency #${stackedState.dependency} to merge; rerun resumes the PR`, { pr });
|
|
4150
4268
|
onProgress({ event: "phase_paused", phase: "merge", detail: `merge.stacked_base: waiting for #${stackedState.dependency} to merge` });
|
|
4151
4269
|
await sleep(30000);
|
|
4152
4270
|
await renew();
|
|
4153
4271
|
}
|
|
4272
|
+
const t2 = { cost: usage.cost_usd, at: now() };
|
|
4154
4273
|
try { await ghw(["pr", "edit", String(pr), "-R", repo, "--base", lane]); ev({ event: "STACK_RETARGET", pr, from: stackedState.branch, to: lane }); }
|
|
4155
4274
|
catch (e) { return await finish("deferred", `stacked PR #${pr}: retarget to ${lane} failed: ${String(e?.message ?? e).slice(0, 200)}`, { pr }); }
|
|
4156
|
-
|
|
4275
|
+
base = `origin/${lane}`; // the PR now targets the lane: later syncs merge the lane, not the dependency branch
|
|
4276
|
+
try { await git(["fetch", "origin", lane]); stackInvalidation = { changedPaths: String(await git(["diff", "--name-only", curSha, `origin/${lane}`])).split("\n").map((x) => x.trim()).filter(Boolean) }; } catch { stackInvalidation = null; } // unknown diff: every check re-runs
|
|
4277
|
+
let r0; try { r0 = await baseSync("stacked PR moved onto the lane"); } finally { stackInvalidation = null; }
|
|
4278
|
+
cascade("rebase", t2); if (r0) return r0;
|
|
4157
4279
|
}
|
|
4158
4280
|
// A rerun on an existing PR goes through the same conflict check, so a conflicting PR from an earlier run recovers.
|
|
4159
4281
|
for (;;) {
|
|
4160
4282
|
const c0 = await prConflicting();
|
|
4283
|
+
if (c0 && mergeTrain === "on" && !isSplit && await trainPlain()) return await trainHandover(c0 === "conflict" ? "PR conflicts with the base, handed to the train as base.conflict" : "no lane base-sync", c0 === "conflict"); // #5839
|
|
4161
4284
|
if (c0) { const r = await baseSync(c0 === "unknown" ? "PR mergeability unknown" : "PR is conflicting", c0 === "unknown"); if (r) return r; }
|
|
4285
|
+
if (mergeTrain === "on" && await trainPlain() && (policy === "none" || (policy === "required" && !required.length))) { const h = await trainHandover("no required checks"); if (h?.again) continue; return h; } // #5839
|
|
4162
4286
|
if (policy === "none" || (policy === "required" && !required.length)) {
|
|
4163
4287
|
// merge right after review
|
|
4164
4288
|
T.merge = [policyText, "merged right after review"];
|
|
@@ -4188,7 +4312,7 @@ export async function runCore(o) {
|
|
|
4188
4312
|
if (policy === "all") {
|
|
4189
4313
|
// #4270: the lane's own report-only check never gates its own merge
|
|
4190
4314
|
const w = await io.waitCiGreen(pr, repo, 0, ...(vcfg.checkRun === true ? [{ ignore: [VERIFY_CHECK_NAME] }] : [])).catch(() => ({ rc: 2, text: "" }));
|
|
4191
|
-
if (w.rc === 0) { gateHead = /CI_GATE_HEAD:\s*([0-9a-f]{7,40})/.exec(w.text ?? "")?.[1] ?? null; break; }
|
|
4315
|
+
if (w.rc === 0) { gateHead = /CI_GATE_HEAD:\s*([0-9a-f]{7,40})/.exec(w.text ?? "")?.[1] ?? null; if (mergeTrain === "on" && await trainPlain()) { const h = await trainHandover("CI green"); if (h?.again) continue; return h; } break; }
|
|
4192
4316
|
if (w.rc === 1) return await needsHuman(`Remote CI failed on PR #${pr}:\n${String(w.text).slice(-2000)}`, OUTCOME_CODES.CI_RED);
|
|
4193
4317
|
} else {
|
|
4194
4318
|
try { states = (await io.checkStates(pr)) ?? []; } catch { states = []; }
|
|
@@ -4202,6 +4326,10 @@ export async function runCore(o) {
|
|
|
4202
4326
|
startedAt = now(); pollIndex = 0; // the fixed head gets the full wait budget
|
|
4203
4327
|
continue;
|
|
4204
4328
|
}
|
|
4329
|
+
// #5836/#5839: with the merge train on, a green or pending PR leaves the slot; the train is the one merge queue per base
|
|
4330
|
+
if (mergeTrain === "on" && required.length && await trainPlain()) {
|
|
4331
|
+
const h = await trainHandover(required.every((n) => st(n) === "success") ? "required checks green" : "required checks pending"); if (h?.again) continue; return h;
|
|
4332
|
+
}
|
|
4205
4333
|
if (required.every((n) => st(n) === "success")) break;
|
|
4206
4334
|
}
|
|
4207
4335
|
// #4266: a PR that turns conflicting gets no merge ref, so its pull_request workflows never start: base-sync now.
|
|
@@ -4349,7 +4477,7 @@ export async function runCore(o) {
|
|
|
4349
4477
|
try { await post("FORGE:TRACKED", `## Left open: live acceptance deferred on a default-on change\nMerged by PR #${pr}, but the rollout is live and these requirements still need live verification:\n${closing.blocks.map((b) => `- ${b.id} (flag ${b.flag})`).join("\n")}\n\nKeep the flag default-off until they are verified, or verify them and close.${closing.tracked.length ? ` Tracked in ${closing.tracked.join(", ")}.` : ""}`); } catch { /* the trajectory decision records it too */ }
|
|
4350
4478
|
}
|
|
4351
4479
|
// #5152: a merged change is `completed` even when partial: the remainder is tracked (FORGE:TRACKED), not dropped
|
|
4352
|
-
if (!keepOpen && !(await closeBlockers("completed", pr)).length) await
|
|
4480
|
+
if (!keepOpen && !(await closeBlockers("completed", pr)).length) await closeMergedIssue({ gh: ghw, repo, issue, label: false }); // #5505: not while another own PR is open
|
|
4353
4481
|
if (closing.transferred) { // #5339: record what is transferred, not met
|
|
4354
4482
|
try { await post("FORGE:TRACKED", `## Left open: transferred, not met\nMerged by PR #${pr}, but these end-to-end/manual requirements were not run in the lane:\n${(closing.transfer ?? closing.open).map((r) => `- ${r.id}: ${r.transferred ? `transferred to epic #${r.transferred} (post-deploy journey)` : "no epic to take it"}`).join("\n")}${closing.tracked.length ? `\n\nTracked in ${closing.tracked.join(", ")}.` : ""}`); } catch { /* the PR body carries them too */ }
|
|
4355
4483
|
} else if (closing.liveBlocked) { /* #5285: posted above */ } else if (closing.checklist) { // #5240: partial: left open; the unticked criteria, tracked follow-ups and any inert rollout are the record
|
|
@@ -4393,6 +4521,7 @@ export async function runCore(o) {
|
|
|
4393
4521
|
const when = e.resetAt || (Number.isFinite(e.resetAtEpochMs) ? new Date(e.resetAtEpochMs).toISOString() : "unknown");
|
|
4394
4522
|
return finish("deferred", `usage limit hit; resets at ${when}`, { code: OUTCOME_CODES.RATE_LIMITED, resetAt: when, resetAtEpochMs: Number.isFinite(e.resetAtEpochMs) ? e.resetAtEpochMs : null, backendId: laneBackendId(process.env, rotator) }, OUTCOME_CODES.RATE_LIMITED);
|
|
4395
4523
|
}
|
|
4524
|
+
if (!e?.deferCode && isSpawnError(e) && String(e?.path ?? e?.spawnargs?.[0] ?? e?.message).match(/git/i)) repoMissing(e); // #5890: a raw spawn ENOENT/EACCES is never an untyped engine-error
|
|
4396
4525
|
if (e?.deferCode) return finish("deferred", e.deferDetail ?? String(e.message), { code: e.deferCode, ...(e.retryInSeconds ? { retryInSeconds: e.retryInSeconds } : {}), ...(e.backendId ? { backendId: e.backendId } : {}), ...(e.cliResult != null ? { cliResult: e.cliResult } : {}), ...(typeof e.cliIsError === "boolean" ? { cliIsError: e.cliIsError } : {}), ...(e.account ? { account: e.account } : {}), ...quotaFacts(e) }, e.deferCode); // #5168: backendId keys the account hold; #5236 reset
|
|
4397
4526
|
// #4505: a turn overrun is mechanical: a non-human end the batch recovers, needs-human only once a budget recovery failed too
|
|
4398
4527
|
if (e?.laneCode === OUTCOME_CODES.BUDGET_EXCEEDED && !(recover?.final && recover.code === OUTCOME_CODES.BUDGET_EXCEEDED)) {
|