forgedock 1.68.0 → 1.70.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/engine-cli.mjs +4 -9
- package/bin/lean/advisory.test.mjs +14 -5
- package/bin/lean/batch.mjs +11 -1
- package/bin/lean/capsample.mjs +25 -0
- package/bin/lean/conformance.mjs +9 -1
- package/bin/lean/conformance.test.mjs +7 -0
- package/bin/lean/depcache.mjs +2 -0
- package/bin/lean/effects.mjs +15 -1
- package/bin/lean/envgap.mjs +18 -0
- package/bin/lean/envgap.test.mjs +12 -1
- package/bin/lean/execution.mjs +3 -0
- package/bin/lean/execution.test.mjs +21 -0
- package/bin/lean/failure-stop.mjs +12 -1
- package/bin/lean/failure-stop.test.mjs +14 -1
- package/bin/lean/hostconfig.mjs +54 -0
- package/bin/lean/hostconfig.test.mjs +67 -0
- package/bin/lean/issuewatch-parity.test.mjs +1 -1
- package/bin/lean/lane-audit-llm.mjs +51 -4
- package/bin/lean/lane-audit-llm.test.mjs +57 -0
- package/bin/lean/lane-audit.mjs +1 -1
- package/bin/lean/lean.mjs +63 -26
- package/bin/lean/lean.test.mjs +100 -19
- package/bin/lean/live-execution.mjs +3 -0
- package/bin/lean/live-execution.test.mjs +23 -0
- package/bin/lean/orchestrate-dispatch-placement.test.mjs +81 -0
- package/bin/lean/orchestrate-envhold.test.mjs +15 -1
- package/bin/lean/orchestrate.mjs +27 -9
- package/bin/lean/preflight.mjs +10 -3
- package/bin/lean/preflight.test.mjs +21 -1
- package/bin/lean/prompts.mjs +1 -0
- package/bin/lean/release-cigreen.mjs +204 -0
- package/bin/lean/release-cigreen.test.mjs +115 -0
- package/bin/lean/release-deploy.mjs +35 -5
- package/bin/lean/release-deploy.test.mjs +50 -3
- package/bin/lean/release-fixloop.mjs +1 -1
- package/bin/lean/release-flakes.mjs +34 -0
- package/bin/lean/release-flakes.test.mjs +28 -0
- package/bin/lean/release-ledger.test.mjs +4 -4
- package/bin/lean/release-preflight.test.mjs +2 -2
- package/bin/lean/release-rehearsal.test.mjs +1 -1
- package/bin/lean/release-review.e2e.test.mjs +4 -3
- package/bin/lean/release-review.mjs +136 -56
- package/bin/lean/release-review.test.mjs +97 -12
- package/bin/lean/release-status.mjs +3 -2
- package/bin/lean/release-status.test.mjs +2 -2
- package/bin/lean/release.mjs +6 -3
- package/bin/lean/release.test.mjs +33 -12
- package/bin/lean/sandbox-remote.mjs +35 -4
- package/bin/lean/schedd.mjs +2 -2
- package/bin/pool/agent.mjs +105 -15
- package/bin/pool/cli.mjs +22 -4
- package/bin/pool/docker.mjs +2 -0
- package/bin/pool/image-manifest.mjs +24 -0
- package/bin/pool/image-manifest.test.mjs +20 -0
- package/bin/pool/lane-tools.mjs +23 -4
- package/bin/pool/lane-tools.test.mjs +27 -7
- package/bin/pool/project-layer.mjs +142 -0
- package/bin/pool/project-layer.test.mjs +73 -0
- package/bin/pool/router.mjs +20 -6
- package/bin/pool/version.mjs +45 -2
- package/bin/review-staging.mjs +63 -21
- package/bin/stats/tool-parks.mjs +29 -0
- package/bin/stats/tool-parks.test.mjs +21 -0
- package/commands/review-pr-staging.md +1 -1
- package/docs/CONFIG.md +20 -0
- package/package.json +1 -1
- package/pool/image/Dockerfile +1 -1
- package/scripts/ci-local.test.sh +3 -2
|
@@ -29,6 +29,8 @@ function fakeSeam({ heads = [H1], fins = [fin()], summary, lanes = [], jobs = []
|
|
|
29
29
|
runAgent: async (a) => { agentCalls.push(a); agents.push(a.role + (a.prompt.includes("findings block required") ? ":reask" : "")); return { text: "ok" }; },
|
|
30
30
|
fileIssue: async ({ item }) => { log.push(["file", item.title]); return n++; },
|
|
31
31
|
failedJobs: async () => jobs,
|
|
32
|
+
queueBlockers: async () => ({ batch: null }),
|
|
33
|
+
holdReleasePr: async () => ({ closed: true }),
|
|
32
34
|
fileDeferred: async ({ items }) => { log.push(["deferred", items.map((i) => i.title)]); return []; },
|
|
33
35
|
fileFixIssue: async () => { log.push(["fix-issue"]); return n++; },
|
|
34
36
|
issueMerged: async () => false,
|
|
@@ -36,7 +38,10 @@ function fakeSeam({ heads = [H1], fins = [fin()], summary, lanes = [], jobs = []
|
|
|
36
38
|
runLane: async (a) => { log.push(["lane", a.issue, a.lane]); return lanes[l++] ?? { terminalReason: "merged" }; },
|
|
37
39
|
};
|
|
38
40
|
}
|
|
39
|
-
|
|
41
|
+
/** ci-green seam fake: every required check green at once (no CI to wait for). */
|
|
42
|
+
export const greenCi = (over = {}) => ({ now: () => 0, sleep: async () => {}, isDraft: async () => false, headOf: async () => H1, checks: async () => [], required: async () => [], ...over });
|
|
43
|
+
/** Legacy suite: `config.reviewFixes` (the #5212 fix lanes and delta passes) is on; the default flow is tested under "default flow (v1.0 contract)". */
|
|
44
|
+
const ctx = (seam, steps = {}, extra = {}) => ({ config: { reviewFixes: true }, io: { review: seam, ciGreen: greenCi() }, ...extra, repo: "o/r", def: "main", staging: "staging", state: { steps: { "release-pr": { result: { pr: 7 } }, ...steps } }, save() {} });
|
|
40
45
|
|
|
41
46
|
describe("#6098 reviewer fan-out is capped and niced", () => {
|
|
42
47
|
it("mapLimit never has more than the cap in flight and keeps order", async () => {
|
|
@@ -207,14 +212,39 @@ describe("fixStep", () => {
|
|
|
207
212
|
assert.equal((brief.match(/ci:lint/g) ?? []).length, 1);
|
|
208
213
|
});
|
|
209
214
|
|
|
210
|
-
it("
|
|
211
|
-
const
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
assert.
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
assert.
|
|
215
|
+
it("only CONFIRMED CRITICAL/HIGH blocks; MEDIUM, LOW and unconfirmed findings are filed and never trigger a fix or head move (#6164)", async () => {
|
|
216
|
+
const s = fakeSeam({ fins: [fin({ toFile: [{ id: "m", title: "med", severity: "MEDIUM" }, { id: "l", title: "unconfirmed", severity: "HIGH" }, { id: "c", title: "real", severity: "HIGH" }], confirmedIds: ["m", "c"] })] });
|
|
217
|
+
const r = await reviewStep(ctx(s));
|
|
218
|
+
assert.equal(s.log.filter((e) => e[0] === "file").length, 3, "all are filed for the next release");
|
|
219
|
+
assert.deepEqual(r.blocking, [102], "only the confirmed HIGH blocks");
|
|
220
|
+
const s2 = fakeSeam({ fins: [fin({ toFile: [{ id: "m", title: "med", severity: "MEDIUM" }], confirmedIds: ["m"] })], summary: { code: 0, data: { verdict: "APPROVE FOR DEPLOY", marker: "FORGE:GATE_PASS", ciFailing: 0 }, lines: [] } });
|
|
221
|
+
const r2 = await reviewStep(ctx(s2));
|
|
222
|
+
assert.deepEqual(r2.blocking, []);
|
|
223
|
+
assert.equal((await fixStep(ctx(s2, { review: { result: r2 } }))).verdict, "APPROVE FOR DEPLOY");
|
|
224
|
+
assert.equal(s2.log.filter((e) => e[0] === "lane").length, 0, "no fix lane");
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
it("legacy review_fixes: a head move during review goes back through ci-green before the delta review (#6164)", async () => {
|
|
228
|
+
const order = [];
|
|
229
|
+
const s = fakeSeam({ heads: [H2, H2, H2], fins: [fin({ head: H2 })] });
|
|
230
|
+
const pre = s.pre; s.pre = async (a) => { order.push(a.delta ? "delta-review" : "review"); return pre(a); };
|
|
231
|
+
const c = ctx(s);
|
|
232
|
+
c.io.ciGreen = greenCi({ checks: async () => { order.push("ci-green"); return []; } });
|
|
233
|
+
await reviewStep(c);
|
|
234
|
+
assert.deepEqual(order, ["ci-green", "review", "ci-green", "delta-review"], "legacy knob: ci-green before the review and again before the delta");
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
it("the delta review after the fix round is preceded by ci-green on the new head and records timing", async () => {
|
|
238
|
+
const order = [];
|
|
239
|
+
const s = fakeSeam({ heads: [H2], fins: [fin({ head: H2 })] });
|
|
240
|
+
const pre = s.pre; s.pre = async (a) => { order.push(a.delta ? "delta" : "pre"); return pre(a); };
|
|
241
|
+
const c = ctx(s, { review: { result: { ...failed, blocking: [], ciFailing: 2 } } });
|
|
242
|
+
c.io.ciGreen = greenCi({ checks: async () => { order.push("ci-green"); return []; } });
|
|
243
|
+
await fixStep(c);
|
|
244
|
+
assert.deepEqual(order, ["ci-green", "delta"]);
|
|
245
|
+
assert.equal(c.state.timing.fix_rounds, 1);
|
|
246
|
+
assert.equal(c.state.timing.review_passes, 1);
|
|
247
|
+
assert.equal(typeof c.state.timing.review_min, "number");
|
|
218
248
|
});
|
|
219
249
|
|
|
220
250
|
it("blocks when a lane does not merge", async () => {
|
|
@@ -393,7 +423,7 @@ describe("fixStep one-round loop (#5567)", () => {
|
|
|
393
423
|
it("ci.fix.max_rounds raises the round budget", async () => {
|
|
394
424
|
const s = fakeSeam({ heads: [H2], summary: bad, jobs: [{ name: "unit", conclusion: "failure", log: "AssertionError" }] });
|
|
395
425
|
const c = ctx(s, { review: { result: failed } });
|
|
396
|
-
c.config = { fix: { maxRounds: 2 } };
|
|
426
|
+
c.config = { reviewFixes: true, fix: { maxRounds: 2 } };
|
|
397
427
|
await fixStep(c);
|
|
398
428
|
assert.equal(s.log.filter((e) => e[0] === "lane").length, 2);
|
|
399
429
|
});
|
|
@@ -425,7 +455,7 @@ describe("fixStep one-round loop (#5567)", () => {
|
|
|
425
455
|
let call = 0;
|
|
426
456
|
s.failedJobs = async () => (call++ === 0 ? [{ name: "unit", conclusion: "failure", log: "x" }] : [{ name: "unit", conclusion: "failure", log: "x" }, { name: "e2e", conclusion: "failure", log: "y" }]);
|
|
427
457
|
const c = ctx(s, { review: { result: failed } });
|
|
428
|
-
c.config = { mode: "snapshot" };
|
|
458
|
+
c.config = { reviewFixes: true, mode: "snapshot" };
|
|
429
459
|
c.git = (a) => { git.push(a); if (a[0] === "commit-tree") return `${RV}\n`; return `${"6".repeat(40)}\n`; };
|
|
430
460
|
c.io = { ...c.io, git: c.git, gh: async (a) => (a[1] === "list" ? "[]" : JSON.stringify({ body: "" })) };
|
|
431
461
|
c.state.release = { branch: "release/x", snapshot: SNAP, range: {}, picks: [{ sha: PK, orig: "3".repeat(40), kind: "fix" }] };
|
|
@@ -492,7 +522,7 @@ describe("fixStep in snapshot mode (#5276)", () => {
|
|
|
492
522
|
const c = ctx(seam, { review: { result: failed } });
|
|
493
523
|
c.io = { ...c.io, ...w.io };
|
|
494
524
|
c.git = w.io.git;
|
|
495
|
-
c.config = { mode: "snapshot", ...(fixMode ? { fixMode } : {}) };
|
|
525
|
+
c.config = { reviewFixes: true, mode: "snapshot", ...(fixMode ? { fixMode } : {}) };
|
|
496
526
|
c.state.release = { branch: "release/x", snapshot: SNAP, range: {}, picks: [] };
|
|
497
527
|
return c;
|
|
498
528
|
};
|
|
@@ -609,3 +639,58 @@ describe("#5516 makeLeanRunner fullSession", () => {
|
|
|
609
639
|
if (lean.length) assert.ok(lean.some((f) => /slash|tools|mcp/i.test(f)), `lean flags restrict the session: ${lean.join(" ")}`);
|
|
610
640
|
});
|
|
611
641
|
});
|
|
642
|
+
|
|
643
|
+
describe("default flow (v1.0 contract, dcfb86bf): one review pass, nothing found by review is fixed in the release PR (#6164)", () => {
|
|
644
|
+
const def = (seam, steps = {}) => ctx(seam, steps, { config: {} });
|
|
645
|
+
const blockFin = fin({ toFile: [{ id: "A", title: "leak", severity: "HIGH" }, { id: "B", title: "nit", severity: "MEDIUM" }], confirmedIds: ["A", "B"] });
|
|
646
|
+
const bad = { code: 0, data: { verdict: "BLOCK DEPLOY", marker: "FORGE:GATE_FAILURE", ciFailing: 0 }, lines: [] };
|
|
647
|
+
it("reviews once, files every finding, and a confirmed HIGH is the only blocker", async () => {
|
|
648
|
+
const s = fakeSeam({ fins: [blockFin] });
|
|
649
|
+
const r = await reviewStep(def(s));
|
|
650
|
+
assert.equal(s.log.filter((e) => e[0] === "file").length, 2, "Phase 7: every finding is filed");
|
|
651
|
+
assert.deepEqual(r.blocking, [100]);
|
|
652
|
+
assert.equal(s.log.filter((e) => e[0] === "pre").length, 1);
|
|
653
|
+
});
|
|
654
|
+
it("a head that moves during the review is never delta-reviewed in place: the job stops and the release is re-run", async () => {
|
|
655
|
+
const s = fakeSeam({ heads: [H2, H2, H2] });
|
|
656
|
+
const r = await reviewStep(def(s));
|
|
657
|
+
assert.equal(r.blocked, true); assert.match(r.reason, /moved during the review/);
|
|
658
|
+
assert.deepEqual(s.log.filter((e) => e[0] === "pre"), [["pre", null]], "no --delta pass");
|
|
659
|
+
});
|
|
660
|
+
it("GATE_PASS passes with no lane", async () => {
|
|
661
|
+
const s = fakeSeam();
|
|
662
|
+
const c = def(s); const r = await reviewStep(c); c.state.steps.review = { done: true, result: r };
|
|
663
|
+
assert.equal((await fixStep(c)).verdict, "APPROVE FOR DEPLOY");
|
|
664
|
+
assert.equal(s.log.filter((e) => e[0] === "lane" || e[0] === "fix-issue").length, 0);
|
|
665
|
+
});
|
|
666
|
+
it("a confirmed blocker stops the release: no fix lane, blockers queued into the open batch, release PR closed, status names the blockers", async () => {
|
|
667
|
+
const s = fakeSeam({ fins: [blockFin], summary: bad });
|
|
668
|
+
const calls = [];
|
|
669
|
+
s.queueBlockers = async (a) => { calls.push(["queue", a.blockers]); return { batch: "b-1" }; };
|
|
670
|
+
s.holdReleasePr = async (a) => { calls.push(["hold", a.pr]); return { closed: true }; };
|
|
671
|
+
const c = def(s); c.state.steps.review = { done: true, result: await reviewStep(c) };
|
|
672
|
+
const r = await fixStep(c);
|
|
673
|
+
assert.equal(r.blocked, true); assert.match(r.reason, /^review blockers #100 \(queued in batch b-1\); release PR #7 closed/);
|
|
674
|
+
assert.deepEqual(calls, [["queue", [100]], ["hold", 7]]);
|
|
675
|
+
assert.equal(s.log.filter((e) => e[0] === "lane" || e[0] === "fix-issue").length, 0, "nothing is fixed inside the release PR");
|
|
676
|
+
assert.equal(s.log.filter((e) => e[0] === "pre").length, 1, "no delta pass");
|
|
677
|
+
assert.equal((await fixStep(c)).reason, r.reason); assert.equal(calls.length, 2, "a resume queues nothing twice");
|
|
678
|
+
});
|
|
679
|
+
it("no open batch: the blockers are still named and the PR held", async () => {
|
|
680
|
+
const s = fakeSeam({ fins: [blockFin], summary: bad });
|
|
681
|
+
s.queueBlockers = async () => ({ batch: null }); s.holdReleasePr = async () => ({ closed: false });
|
|
682
|
+
const c = def(s); c.state.steps.review = { done: true, result: await reviewStep(c) };
|
|
683
|
+
assert.match((await fixStep(c)).reason, /^review blockers #100; release PR #7 held/);
|
|
684
|
+
});
|
|
685
|
+
it("MEDIUM, LOW and unconfirmed findings never block: GATE_PASS stays a pass", async () => {
|
|
686
|
+
const s = fakeSeam({ fins: [fin({ toFile: [{ id: "u", title: "maybe", severity: "HIGH" }, { id: "m", title: "med", severity: "MEDIUM" }], confirmedIds: ["m"] })] });
|
|
687
|
+
const r = await reviewStep(def(s));
|
|
688
|
+
assert.deepEqual(r.blocking, []);
|
|
689
|
+
});
|
|
690
|
+
it("coStartCi is not run in the default flow", async () => {
|
|
691
|
+
const s = fakeSeam(); const c = def(s); c.config.fix = { coStart: true };
|
|
692
|
+
const gh = []; c.io.gh = async (a) => { gh.push(a); return "{}"; };
|
|
693
|
+
await reviewStep(c);
|
|
694
|
+
assert.ok(!gh.some((a) => a[0] === "workflow" || a[1] === "ready"));
|
|
695
|
+
});
|
|
696
|
+
});
|
|
@@ -17,7 +17,7 @@ export const STATUS_SCHEMA = "forgedock.release.status/v1";
|
|
|
17
17
|
export const EXPLAIN_SCHEMA = "forgedock.release.explain/v1";
|
|
18
18
|
export const TERMINAL = ["done", "refused", "blocked", "cancelled"];
|
|
19
19
|
export const SKIP_LABELS = ["epic", "needs-human", "post-deploy", "workflow:merged", "awaiting-promotion", "host-task"];
|
|
20
|
-
const STEPS = ["preflight", "host-preflight", "release-pr", "review", "fixes", "mark-ready", "rehearsal", "promotion", "post-merge"];
|
|
20
|
+
const STEPS = ["preflight", "host-preflight", "release-pr", "ci-green", "review", "fixes", "mark-ready", "rehearsal", "promotion", "post-merge"];
|
|
21
21
|
/** The verbs `release <verb>` runs (#5556, `release-control.mjs`): the one source for what `next_actions[]` may name. */
|
|
22
22
|
export const CONTROL_VERBS = VERBS;
|
|
23
23
|
const OK = ["success", "neutral", "skipped"];
|
|
@@ -76,6 +76,7 @@ export async function collectStatus({ io, repo, id, config = {}, local, gateStat
|
|
|
76
76
|
merge_hold_release_ci: pr?.ci && !TERMINAL.includes(status) && pr.ci.pending > 0 ? { pr: pr.number, pending: pr.ci.pending } : null, // #5709: lanes hold merges into the integration branch while this runs
|
|
77
77
|
intake: active?.intake ? (active.intake.paused ? "paused" : "open") : "unknown",
|
|
78
78
|
cut_sha: unk(state.release?.snapshot),
|
|
79
|
+
timing: state.timing ?? "unknown", // ci_green_min, review_min, fix_rounds, review_passes
|
|
79
80
|
review: verdict ? { verdict, head: pr?.head ?? "unknown" } : "unknown",
|
|
80
81
|
merge_sha: unk(state.steps?.promotion?.result?.sha ?? state.merge_sha),
|
|
81
82
|
deploy: state.deploy ? { run: unk(state.deploy.run), stage: unk(state.deploy.stage), attempt: unk(state.deploy.attempt) } : "unknown",
|
|
@@ -129,7 +130,7 @@ export function renderReleaseStatus(s) {
|
|
|
129
130
|
lines.push(` wave: ${s.wave} lane: ${s.lane}`, ` lease: ${show(s.lease)}`, ` cut: ${s.cut_sha}`);
|
|
130
131
|
for (const st of s.steps) lines.push(` ${st.done ? "[x]" : "[ ]"} ${st.step}${st.at ? ` ${st.at}` : ""}`);
|
|
131
132
|
lines.push(s.pr ? ` PR #${s.pr.number} head ${s.pr.head ?? "unknown"} gate marker=${s.pr.gate?.marker ?? "none"} deploy-gate=${s.pr.gate?.deployGate ?? "none"} ci: ${s.pr.ci ? show(s.pr.ci) : "unknown"}` : " PR: unknown");
|
|
132
|
-
lines.push(` review: ${show(s.review)}`, ` merge: ${s.merge_sha}`, ` deploy: ${show(s.deploy)}`, ` rollback: target=${s.rollback_target} auto=${s.auto_rollback}`);
|
|
133
|
+
lines.push(` timing: ${show(s.timing)}`, ` review: ${show(s.review)}`, ` merge: ${s.merge_sha}`, ` deploy: ${show(s.deploy)}`, ` rollback: target=${s.rollback_target} auto=${s.auto_rollback}`);
|
|
133
134
|
if (s.release) lines.push(` release set: ${s.release.issues.map((n) => `#${n}`).join(" ") || "(none recorded)"} picks=${s.release.picks}`);
|
|
134
135
|
}
|
|
135
136
|
if (s.waiting_host?.length) lines.push(` waiting on a host: ${s.waiting_host.join(", ")}`);
|
|
@@ -65,9 +65,9 @@ describe("release status / explain (#5554)", () => {
|
|
|
65
65
|
assert.equal(out, [
|
|
66
66
|
`${ID} o/r status=running next=promotion source=ledger hold=no intake=unknown`,
|
|
67
67
|
" wave: unknown lane: unknown", " lease: holder=h epoch=2 heartbeat_age_s=unknown", " cut: s1",
|
|
68
|
-
" [x] preflight T1", " [ ] host-preflight", " [x] release-pr T2", " [ ] review", " [ ] fixes", " [ ] mark-ready", " [ ] rehearsal", " [ ] promotion T3", " [ ] post-merge",
|
|
68
|
+
" [x] preflight T1", " [ ] host-preflight", " [x] release-pr T2", " [ ] ci-green", " [ ] review", " [ ] fixes", " [ ] mark-ready", " [ ] rehearsal", " [ ] promotion T3", " [ ] post-merge",
|
|
69
69
|
` PR #7 head ${HEAD} gate marker=pass deploy-gate=success ci: total=1 failed=0 pending=0`,
|
|
70
|
-
` review: verdict=GATE_PASS head=${HEAD}`, " merge: unknown", " deploy: unknown", " rollback: target=unknown auto=unknown",
|
|
70
|
+
" timing: unknown", ` review: verdict=GATE_PASS head=${HEAD}`, " merge: unknown", " deploy: unknown", " rollback: target=unknown auto=unknown",
|
|
71
71
|
" release set: #5 #12 picks=0",
|
|
72
72
|
" next:",
|
|
73
73
|
` forgedock release --resume ${ID} --repo o/r`,
|
package/bin/lean/release.mjs
CHANGED
|
@@ -18,6 +18,7 @@ import { readBranches, DEFAULT_STAGING_BRANCH } from "./lane.mjs";
|
|
|
18
18
|
import { ghRunner } from "./issuewatch.mjs";
|
|
19
19
|
import { parseForgeYaml } from "../forge-utils.mjs";
|
|
20
20
|
import { reviewStep, fixStep } from "./release-review.mjs";
|
|
21
|
+
import { ciGreenStep, ciGreenKeys } from "./release-cigreen.mjs";
|
|
21
22
|
import { postMergeStep } from "./release-postmerge.mjs";
|
|
22
23
|
import { deployStep } from "./release-deploy.mjs";
|
|
23
24
|
import { riskClass } from "./release-verify.mjs";
|
|
@@ -29,7 +30,7 @@ import { cutSnapshot, writeRecord, checkChain, verifyRelease, defaultBehind, DEF
|
|
|
29
30
|
import { createReleaseLedger, writeRelease, readLedger, acquireLease, heartbeat, recordReleaseRound } from "./release-ledger.mjs";
|
|
30
31
|
import { fenced, epochTrailer } from "./release-fence.mjs";
|
|
31
32
|
import { holdCheck, exemptionsSection, runControl, VERBS as CONTROL_VERBS } from "./release-control.mjs";
|
|
32
|
-
import { parseFlakeConfig, classifyFailure, planRerun, flakeEntry, recordFlakes, readFlakes } from "./release-flakes.mjs";
|
|
33
|
+
import { parseFlakeConfig, classifyFailure, planRerun, flakeEntry, recordFlakes, readFlakes, isDeployWorkflow } from "./release-flakes.mjs";
|
|
33
34
|
import { readActive } from "./release-ledger.mjs";
|
|
34
35
|
import { statusFromCli, policyFromYaml } from "./release-status.mjs";
|
|
35
36
|
import { parseFixConfig } from "./release-fixloop.mjs";
|
|
@@ -37,7 +38,7 @@ import { hostPreflightStep, markReadyStep, stagingHealthStep, parsePreflightConf
|
|
|
37
38
|
import { roleRefusal } from "./release-credentials.mjs";
|
|
38
39
|
import { mergeGuard } from "./release-gate.mjs";
|
|
39
40
|
|
|
40
|
-
export const RELEASE_STEPS = ["preflight", "host-preflight", "release-pr", "review", "fixes", "mark-ready", "rehearsal", "promotion", "post-merge", "deploy"];
|
|
41
|
+
export const RELEASE_STEPS = ["preflight", "host-preflight", "release-pr", "ci-green", "review", "fixes", "mark-ready", "rehearsal", "promotion", "post-merge", "deploy"];
|
|
41
42
|
const ID_RE = /^r\d{8}-\d{6}-\d+$/;
|
|
42
43
|
const BLOCKED_EXIT = 3;
|
|
43
44
|
|
|
@@ -65,7 +66,7 @@ export function readReleaseConfig(raw) {
|
|
|
65
66
|
let r = {};
|
|
66
67
|
try { r = parseForgeYaml(String(raw ?? ""))?.release ?? {}; } catch { r = {}; }
|
|
67
68
|
const off = (v) => ["false", "off", "no", "0", ""].includes(String(v ?? "").trim().toLowerCase());
|
|
68
|
-
return { autoMerge: !off(r.auto_merge), artifactCheck: r.artifact_check || null, versionSync: !off(r.version_sync), publishWorkflow: r.publish_workflow || null, ...(r.managed !== undefined && !off(r.managed) ? { managed: true } : {}), ...managedKeys(raw, r), ...freezeKeys(raw, r), ...optKeys(r), ...snapshotKeys(r) };
|
|
69
|
+
return { autoMerge: !off(r.auto_merge), artifactCheck: r.artifact_check || null, versionSync: !off(r.version_sync), publishWorkflow: r.publish_workflow || null, ...(r.managed !== undefined && !off(r.managed) ? { managed: true } : {}), ...managedKeys(raw, r), ...freezeKeys(raw, r), ...optKeys(r), ...snapshotKeys(r), ...ciGreenKeys(r) };
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
/** `{nightly, budget}` (#5569) only when `release.managed` is on: the forge.yaml `nightly:` and `budget:` blocks. */
|
|
@@ -286,6 +287,7 @@ export async function rerunInfraFlakes({ io, repo, head, fence, policy }) {
|
|
|
286
287
|
const at = new Date(io.now?.() ?? Date.now()).toISOString(), entries = [];
|
|
287
288
|
let spentMin = 0;
|
|
288
289
|
for (const r of runs) {
|
|
290
|
+
if (isDeployWorkflow(r.name)) { out.skipped.push({ name: r.name, why: "deploy-class: handled by release-deploy recover" }); continue; } // #6015: never a log-regex rerun
|
|
289
291
|
const log = String(await io.gh(["run", "view", String(r.databaseId), "--repo", repo, "--log-failed"]).catch(() => "")).slice(-20_000);
|
|
290
292
|
const c = classifyFailure(log);
|
|
291
293
|
const [d] = planRerun({ jobs: [{ key: `${head}:${r.name}`, name: r.name, class: c.class, attempt: r.attempt }], done, spentMin, budgetMin: cfg.rerunBudgetMin });
|
|
@@ -376,6 +378,7 @@ const STEP_FNS = {
|
|
|
376
378
|
preflight: preflightStep,
|
|
377
379
|
"host-preflight": hostPreflightStep,
|
|
378
380
|
"release-pr": releasePrStep,
|
|
381
|
+
"ci-green": (ctx) => ciGreenStep(ctx),
|
|
379
382
|
review: (ctx) => reviewStep(ctx),
|
|
380
383
|
fixes: (ctx) => fixStep(ctx),
|
|
381
384
|
"mark-ready": markReadyStep,
|
|
@@ -42,6 +42,7 @@ function fakeIo(world = {}) {
|
|
|
42
42
|
throw new Error(`unexpected gh ${j}`);
|
|
43
43
|
},
|
|
44
44
|
};
|
|
45
|
+
io.ciGreen = { isDraft: async () => true }; // real ci-green steps skip like a draft PR: CI waiting is tested in release-cigreen.test.mjs
|
|
45
46
|
if (w.scorecard) io.scorecard = w.scorecard;
|
|
46
47
|
return io;
|
|
47
48
|
}
|
|
@@ -52,7 +53,7 @@ describe("unmanaged release carries no epoch (#5553)", () => {
|
|
|
52
53
|
const mod = await import("./release.mjs");
|
|
53
54
|
const io = fakeIo();
|
|
54
55
|
io.api = async () => { throw new Error("no ledger call expected"); };
|
|
55
|
-
const out = await mod.runRelease({ io, repo: REPO, root: tmp(), mounts: DISK, id: newReleaseId(), opts: { merge: true }, config: {}, branches: { staging: "staging", default: "main" }, steps: mod.withStubs({ review: ok, fixes: ok, "post-merge": ok }) });
|
|
56
|
+
const out = await mod.runRelease({ io, repo: REPO, root: tmp(), mounts: DISK, id: newReleaseId(), opts: { merge: true }, config: {}, branches: { staging: "staging", default: "main" }, steps: mod.withStubs({ "ci-green": ok, review: ok, fixes: ok, "post-merge": ok }) });
|
|
56
57
|
assert.equal(out.status, "done");
|
|
57
58
|
const merge = io.calls.find((a) => a[0] === "pr" && a[1] === "merge");
|
|
58
59
|
assert.deepEqual(merge, ["pr", "merge", "7", "--repo", REPO, "--merge", "--match-head-commit", HEAD]);
|
|
@@ -65,7 +66,7 @@ describe("legacy managed promotion without a fence (#5561 regression)", () => {
|
|
|
65
66
|
const io = fakeIo({ gate: "failure" });
|
|
66
67
|
const shown = [];
|
|
67
68
|
io.git = (a) => { if (a[0] === "show") shown.push(a[1]); throw new Error("no git"); };
|
|
68
|
-
await mod.runRelease({ io, repo: REPO, root: tmp(), mounts: DISK, id: newReleaseId(), opts: { merge: true }, config: { managed: true }, branches: { staging: "staging", default: "main" }, steps: mod.withStubs({ review: ok, fixes: ok, "post-merge": ok }) });
|
|
69
|
+
await mod.runRelease({ io, repo: REPO, root: tmp(), mounts: DISK, id: newReleaseId(), opts: { merge: true }, config: { managed: true }, branches: { staging: "staging", default: "main" }, steps: mod.withStubs({ "ci-green": ok, review: ok, fixes: ok, "post-merge": ok }) });
|
|
69
70
|
assert.ok(shown.some((x) => x.startsWith("origin/main:")), "policy read for the flake rerun");
|
|
70
71
|
});
|
|
71
72
|
});
|
|
@@ -75,7 +76,7 @@ describe("release job (#5211)", () => {
|
|
|
75
76
|
const io = fakeIo(world), root = tmp(), id = newReleaseId();
|
|
76
77
|
// Real preflight/release-pr/promotion, with review/fixes/post-merge replaced by no-ops.
|
|
77
78
|
const mod = await import("./release.mjs");
|
|
78
|
-
const out = await mod.runRelease({ io, repo: REPO, root, mounts: DISK, id, opts, config, branches: { staging: "staging", default: "main" }, steps: mod.withStubs({ review: ok, fixes: ok, "post-merge": ok }) });
|
|
79
|
+
const out = await mod.runRelease({ io, repo: REPO, root, mounts: DISK, id, opts, config, branches: { staging: "staging", default: "main" }, steps: mod.withStubs({ "ci-green": ok, review: ok, fixes: ok, "post-merge": ok }) });
|
|
79
80
|
return { io, out, root, id };
|
|
80
81
|
};
|
|
81
82
|
|
|
@@ -139,7 +140,7 @@ describe("release job (#5211)", () => {
|
|
|
139
140
|
const io = fakeIo({ prState: "MERGED" }), root = tmp(), id = newReleaseId();
|
|
140
141
|
const mod = await import("./release.mjs");
|
|
141
142
|
let seen = null;
|
|
142
|
-
const out = await mod.runRelease({ io, repo: REPO, root, mounts: DISK, id, opts: {}, config: {}, branches: { staging: "staging", default: "main" }, steps: mod.withStubs({ review: ok, fixes: ok, "post-merge": async (c) => { seen = c.state.steps.promotion.result; return {}; } }) });
|
|
143
|
+
const out = await mod.runRelease({ io, repo: REPO, root, mounts: DISK, id, opts: {}, config: {}, branches: { staging: "staging", default: "main" }, steps: mod.withStubs({ "ci-green": ok, review: ok, fixes: ok, "post-merge": async (c) => { seen = c.state.steps.promotion.result; return {}; } }) });
|
|
143
144
|
assert.equal(out.status, "done");
|
|
144
145
|
assert.equal(seen.alreadyMerged, true);
|
|
145
146
|
assert.equal(seen.mergeCommit, "m".repeat(40));
|
|
@@ -210,12 +211,12 @@ describe("release job (#5211)", () => {
|
|
|
210
211
|
const mod = await import("./release.mjs");
|
|
211
212
|
const ran = [];
|
|
212
213
|
const rec = (n, fn) => async (ctx) => { ran.push(n); return fn(ctx); };
|
|
213
|
-
const base = mod.withStubs({ review: ok, fixes: ok, "post-merge": ok });
|
|
214
|
+
const base = mod.withStubs({ "ci-green": ok, review: ok, fixes: ok, "post-merge": ok });
|
|
214
215
|
const kill = async () => { throw new Error("killed"); };
|
|
215
216
|
const first = { ...base, preflight: rec("preflight", base.preflight), "release-pr": rec("release-pr", base["release-pr"]), review: kill };
|
|
216
217
|
await assert.rejects(() => mod.runRelease({ io, repo: REPO, root, mounts: DISK, id, opts: { merge: true }, config: {}, branches: {}, steps: first }), /killed/);
|
|
217
218
|
const st = openRelease(root, id).load();
|
|
218
|
-
assert.deepEqual(Object.keys(st.steps), ["preflight", "release-pr"]);
|
|
219
|
+
assert.deepEqual(Object.keys(st.steps), ["preflight", "release-pr", "ci-green"]);
|
|
219
220
|
const second = { ...base, preflight: rec("preflight2", base.preflight), "release-pr": rec("release-pr2", base["release-pr"]) };
|
|
220
221
|
const out = await mod.runRelease({ io, repo: REPO, root, mounts: DISK, id, opts: { merge: true }, config: {}, branches: {}, steps: second });
|
|
221
222
|
assert.equal(out.status, "done");
|
|
@@ -226,7 +227,7 @@ describe("release job (#5211)", () => {
|
|
|
226
227
|
const root = tmp(), id = newReleaseId(), io = fakeIo(), mod = await import("./release.mjs");
|
|
227
228
|
const at = new Date(io.now()).toISOString();
|
|
228
229
|
const review = { pr: 7, head: HEAD, verdict: "BLOCK DEPLOY", marker: "FORGE:GATE_FAILURE", blocking: [101], filed: [101], ciFailing: 1, items: [] };
|
|
229
|
-
openRelease(root, id, DISK).save({ v: 1, id, repo: REPO, startedAt: at, held: [], steps: { preflight: { done: true, at, result: {} }, "release-pr": { done: true, at, result: { pr: 7, head: HEAD } }, review: { done: true, at, result: review } } });
|
|
230
|
+
openRelease(root, id, DISK).save({ v: 1, id, repo: REPO, startedAt: at, held: [], steps: { preflight: { done: true, at, result: {} }, "release-pr": { done: true, at, result: { pr: 7, head: HEAD } }, "ci-green": { done: true, at, result: {} }, review: { done: true, at, result: review } } });
|
|
230
231
|
const stuckGh = (a) => {
|
|
231
232
|
if (a[0] === "run" && a[1] === "list") return JSON.stringify([{ databaseId: 1, name: "Shell Compatibility", status: "in_progress", conclusion: "" }, { databaseId: 2, name: "CI", status: "completed", conclusion: "failure" }]);
|
|
232
233
|
if (a[0] === "run" && a[1] === "view") return "boom";
|
|
@@ -234,6 +235,7 @@ describe("release job (#5211)", () => {
|
|
|
234
235
|
};
|
|
235
236
|
const waits = [], log = [];
|
|
236
237
|
const real = realSeam({ repo: REPO, def: "main", env: {}, cwd: "/tmp", gh: stuckGh, io: { now: () => 0, sleep: async (ms) => { waits.push(ms); }, print: () => {} } });
|
|
238
|
+
io.ciGreen = { now: () => 0, sleep: async () => {}, isDraft: async () => false, headOf: async () => HEAD, checks: async () => [], required: async () => [] };
|
|
237
239
|
io.review = {
|
|
238
240
|
failedJobs: real.failedJobs, headOf: async () => HEAD, issueMerged: async () => false,
|
|
239
241
|
fileDeferred: async () => [], fileFixIssue: async () => { log.push("fix-issue"); return 200; },
|
|
@@ -241,7 +243,7 @@ describe("release job (#5211)", () => {
|
|
|
241
243
|
pre: async () => ({ code: 1, data: null, lines: ["stopped"] }), // ends the delta review right after the fix lane
|
|
242
244
|
};
|
|
243
245
|
const timer = new Promise((_, rej) => setTimeout(() => rej(new Error("still waiting after 5000ms")), 5000).unref());
|
|
244
|
-
const out = await Promise.race([mod.runRelease({ io, repo: REPO, root, mounts: DISK, id, opts: { merge: true }, config: {}, branches: { staging: "staging", default: "main" }, steps: mod.withStubs({ "post-merge": ok }) }), timer]);
|
|
246
|
+
const out = await Promise.race([mod.runRelease({ io, repo: REPO, root, mounts: DISK, id, opts: { merge: true }, config: { reviewFixes: true }, branches: { staging: "staging", default: "main" }, steps: mod.withStubs({ "post-merge": ok }) }), timer]);
|
|
245
247
|
assert.deepEqual(log, ["fix-issue", "lane"]);
|
|
246
248
|
assert.deepEqual(waits, []);
|
|
247
249
|
assert.equal(out.step, "fixes"); // reached the fix step and ran it, not stopped at review
|
|
@@ -276,7 +278,7 @@ describe("release job (#5211)", () => {
|
|
|
276
278
|
assert.equal(readReleaseConfig("release:\n managed: true\n").managed, true);
|
|
277
279
|
const apiCalls = [], ghCalls = [], io = { print() {}, now: () => 1_700_000_000_000, runningLanes: async () => [], batches: async () => [], setParallel: async () => {}, gh: async (a) => { ghCalls.push(a); return ""; }, api: async (...a) => { apiCalls.push(a); return {}; } };
|
|
278
280
|
const ok = async () => ({});
|
|
279
|
-
const out = await (await import("./release.mjs")).runRelease({ io, repo: REPO, root: tmp(), mounts: DISK, id: newReleaseId(), opts: {}, config: {}, branches: {}, steps: { preflight: ok, "host-preflight": ok, "release-pr": ok, review: ok, fixes: ok, "mark-ready": ok, rehearsal: ok, promotion: ok, "post-merge": ok, deploy: async () => ({ skipped: true }) } });
|
|
281
|
+
const out = await (await import("./release.mjs")).runRelease({ io, repo: REPO, root: tmp(), mounts: DISK, id: newReleaseId(), opts: {}, config: {}, branches: {}, steps: { preflight: ok, "host-preflight": ok, "release-pr": ok, "ci-green": ok, review: ok, fixes: ok, "mark-ready": ok, rehearsal: ok, promotion: ok, "post-merge": ok, deploy: async () => ({ skipped: true }) } });
|
|
280
282
|
assert.equal(out.status, "done");
|
|
281
283
|
assert.deepEqual(apiCalls, []);
|
|
282
284
|
assert.deepEqual(ghCalls, []);
|
|
@@ -418,7 +420,7 @@ describe("release post-merge step (#5213)", () => {
|
|
|
418
420
|
const go = async (runs) => {
|
|
419
421
|
const io = fakeIo({ pm: world(runs).pm });
|
|
420
422
|
const config = { postMerge: { publishPolls: 1, runPolls: 1 } };
|
|
421
|
-
return mod.runRelease({ io, repo: REPO, root, mounts: DISK, id, opts: { merge: true }, config, branches: { staging: "staging", default: "main" }, steps: mod.withStubs({ review: ok, fixes: ok }) });
|
|
423
|
+
return mod.runRelease({ io, repo: REPO, root, mounts: DISK, id, opts: { merge: true }, config, branches: { staging: "staging", default: "main" }, steps: mod.withStubs({ "ci-green": ok, review: ok, fixes: ok }) });
|
|
422
424
|
};
|
|
423
425
|
assert.equal((await go([[{ databaseId: 1, status: "completed", conclusion: "failure" }]])).status, "blocked");
|
|
424
426
|
assert.equal((await go([[{ databaseId: 2, status: "completed", conclusion: "success" }]])).status, "done");
|
|
@@ -441,7 +443,7 @@ describe("snapshot releases (#5276)", () => {
|
|
|
441
443
|
const io = fakeIo(world);
|
|
442
444
|
if (world.git) io.git = world.git;
|
|
443
445
|
const mod = await import("./release.mjs");
|
|
444
|
-
const out = await mod.runRelease({ io, repo: REPO, root: tmp(), mounts: DISK, id: newReleaseId(), opts, config, branches: { staging: "staging", default: "main" }, steps: mod.withStubs({ review: ok, fixes: ok, "post-merge": ok }) });
|
|
446
|
+
const out = await mod.runRelease({ io, repo: REPO, root: tmp(), mounts: DISK, id: newReleaseId(), opts, config, branches: { staging: "staging", default: "main" }, steps: mod.withStubs({ "ci-green": ok, review: ok, fixes: ok, "post-merge": ok }) });
|
|
445
447
|
return { io, out };
|
|
446
448
|
};
|
|
447
449
|
|
|
@@ -615,7 +617,7 @@ describe("preflight staging-health gate (#6013)", () => {
|
|
|
615
617
|
it("refuses a snapshot cut on a red staging head and proceeds when green", async () => {
|
|
616
618
|
const mod = await import("./release.mjs");
|
|
617
619
|
const root = tmp(), id = newReleaseId();
|
|
618
|
-
const base = (io) => ({ io, repo: REPO, root, mounts: DISK, id, opts: {}, config: snap, branches: { staging: "staging", default: "main" }, steps: mod.withStubs({ "release-pr": ok, review: ok, fixes: ok, promotion: ok, "post-merge": ok }) });
|
|
620
|
+
const base = (io) => ({ io, repo: REPO, root, mounts: DISK, id, opts: {}, config: snap, branches: { staging: "staging", default: "main" }, steps: mod.withStubs({ "release-pr": ok, "ci-green": ok, review: ok, fixes: ok, promotion: ok, "post-merge": ok }) });
|
|
619
621
|
const reds = await mod.runRelease(base(fakeIo(world([{ name: "black", status: "completed", conclusion: "failure", text: "" }]))));
|
|
620
622
|
assert.equal(reds.status, "refused");
|
|
621
623
|
assert.match(JSON.stringify(reds), /black/);
|
|
@@ -626,3 +628,22 @@ describe("preflight staging-health gate (#6013)", () => {
|
|
|
626
628
|
assert.notEqual(green.status, "refused");
|
|
627
629
|
});
|
|
628
630
|
});
|
|
631
|
+
|
|
632
|
+
describe("default ci-green flow in the conductor (#6164)", () => {
|
|
633
|
+
it("runs ci-green after release-pr and before review; a review blocker stops the job as blocked (exit 3) with the blockers named", async () => {
|
|
634
|
+
const mod = await import("./release.mjs");
|
|
635
|
+
const order = [], io = fakeIo();
|
|
636
|
+
const rec = (n, r = {}) => async () => { order.push(n); return r; };
|
|
637
|
+
const steps = mod.withStubs({ "ci-green": rec("ci-green"), review: rec("review"), fixes: async () => ({ blocked: true, held: true, reason: "review blockers #101 #102; release PR #7 closed; the next release starts fresh after they merge" }), "post-merge": ok });
|
|
638
|
+
const out = await mod.runRelease({ io, repo: REPO, root: tmp(), mounts: DISK, id: newReleaseId(), opts: { merge: true }, config: {}, branches: { staging: "staging", default: "main" }, steps: { ...steps, preflight: ok, "release-pr": rec("release-pr", { pr: 7, head: HEAD }) } });
|
|
639
|
+
assert.deepEqual(order, ["release-pr", "ci-green", "review"]);
|
|
640
|
+
assert.equal(out.status, "blocked"); assert.equal(out.step, "fixes"); assert.match(out.reason, /^review blockers #101 #102/);
|
|
641
|
+
});
|
|
642
|
+
it("release.block_severity and release.ci_green_max_wait_min only tune the default; absent keys leave it on", () => {
|
|
643
|
+
const c = readReleaseConfig("release:\n block_severity: medium\n ci_green_max_wait_min: 15\n");
|
|
644
|
+
assert.equal(c.blockSeverity, "MEDIUM"); assert.deepEqual(c.ciGreen, { maxWaitMin: 15 });
|
|
645
|
+
assert.equal(readReleaseConfig("release:\n auto_merge: true\n").ciGreen, undefined);
|
|
646
|
+
assert.equal(readReleaseConfig("release:\n auto_merge: true\n").reviewFixes, undefined, "review fix lanes are off unless release.review_fixes: true (compatibility)");
|
|
647
|
+
assert.equal(readReleaseConfig("release:\n review_fixes: true\n").reviewFixes, true);
|
|
648
|
+
});
|
|
649
|
+
});
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* or a session gateway fronts. Tests use an in-memory transport.
|
|
17
17
|
*/
|
|
18
18
|
import { execFileSync } from "node:child_process";
|
|
19
|
-
import { appendFileSync, mkdirSync } from "node:fs";
|
|
19
|
+
import { appendFileSync, mkdirSync, writeFileSync } from "node:fs";
|
|
20
20
|
import { homedir } from "node:os";
|
|
21
21
|
import { dirname, join } from "node:path";
|
|
22
22
|
import { mergeRemoteLog } from "../engine/runlog.mjs";
|
|
@@ -105,6 +105,8 @@ export function httpTransport({ endpoint, token = null, fetchFn = globalThis.fet
|
|
|
105
105
|
},
|
|
106
106
|
async logs(id, cursor = 0) { const r = await call("GET", `${p(id)}/logs?cursor=${encodeURIComponent(cursor)}`); return r.ok ? { text: String(r.data?.text ?? ""), cursor: r.data?.cursor ?? cursor } : { text: "", cursor }; },
|
|
107
107
|
async result(id) { const r = await call("GET", `${p(id)}/result`); if (r.status === 401) throw Object.assign(fail("result", r), { transient: true }); if (r.ok && r.data?.disk_pressure === true) return { terminalReason: "deferred", code: OUTCOME_CODES.SANDBOX_DISK_PRESSURE, retryInSeconds: 120, cost_usd: 0, detail: `sandbox ${id} was stopped to save the host drive (disk pressure); worktree and volume kept, requeued to resume` }; /* #5891 */ if (r.ok && r.data?.drained === true) return { terminalReason: "deferred", code: OUTCOME_CODES.SANDBOX_CAPACITY, retryInSeconds: 60, cost_usd: 0, detail: `sandbox ${id} was drained to free capacity for reserved work (${String(r.data.reason ?? "").slice(0, 120)}); rescheduled` }; /* #5856 */ if (r.ok && r.data && typeof r.data === "object") { const v = r.data.engineVersion ?? r.data.engine_version ?? r.data.forge_version ?? /ForgeDock\s*[·-]\s*v?(\d+\.\d+(?:\.\d+)?)/.exec(String(r.data.banner ?? r.data.log ?? ""))?.[1]; const pv = v ?? placedEngine.get(id); return pv && !r.data.engineVersion ? { ...r.data, engineVersion: String(pv) } : r.data; } return null; }, /* #5931 */
|
|
108
|
+
/** #6117: the lane's run log (jsonl text, capped) and the last ~200 lines of its stderr/stdout; null from a pool without the endpoint (404/405) or any error. Kept by the agent for a grace period after destroy. */
|
|
109
|
+
async runlog(id) { const r = await call("GET", `${p(id)}/runlog`); return r.ok && r.data && typeof r.data === "object" ? { runLog: String(r.data.run_log ?? ""), tail: String(r.data.tail ?? "") } : null; },
|
|
108
110
|
async usage(id) { const r = await call("GET", `${p(id)}/usage`); return r.ok && Number.isFinite(Number(r.data?.minutes)) ? { minutes: Number(r.data.minutes), ...(typeof r.data.agent === "string" && r.data.agent ? { agent: r.data.agent } : {}) } : null; }, // agent: #4549, optional
|
|
109
111
|
async stop(id) { const r = await call("POST", `${p(id)}/stop`); if (r.ok) return true; if (r.status === 404 || r.status === 405) return false; throw fail("stop", r); },
|
|
110
112
|
async destroy(id) { const r = await call("DELETE", p(id)); if (r.ok || r.status === 404) return true; throw fail("destroy", r); },
|
|
@@ -259,13 +261,41 @@ export function remoteProvider({ batch, repo, settings = {}, name = "remote", tr
|
|
|
259
261
|
}
|
|
260
262
|
return b64 ? { CS_RELAY_PREFETCH_B64: b64 } : {};
|
|
261
263
|
};
|
|
264
|
+
/** Appends the sandbox log chunk past the handle's cursor to the lane log. {ok, bytes}: ok=false when the pool could not answer. */
|
|
262
265
|
const pullLogs = async (h) => {
|
|
263
|
-
if (!transport.logs) return;
|
|
266
|
+
if (!transport.logs) return { ok: false, bytes: 0 };
|
|
264
267
|
try {
|
|
265
268
|
const { text, cursor } = (await transport.logs(h.id, h.logCursor ?? 0)) ?? {};
|
|
266
269
|
if (text) { const f = batch.logFile(h.issue); mkdirSync(dirname(f), { recursive: true }); appendFileSync(f, redact(text, [...known])); }
|
|
267
270
|
if (cursor !== undefined) h.logCursor = cursor;
|
|
268
|
-
|
|
271
|
+
return { ok: true, bytes: text ? String(text).length : 0 };
|
|
272
|
+
} catch { return { ok: false, bytes: 0 }; /* the next poll retries */ }
|
|
273
|
+
};
|
|
274
|
+
/** #6117: `<n>.runlog.jsonl` beside the lane log (`<n>.log`): the sandbox's own run log, so an env park stays triageable after teardown. */
|
|
275
|
+
const runLogFile = (issue) => { const f = batch.logFile(issue); return /\.log$/.test(f) ? f.replace(/\.log$/, ".runlog.jsonl") : `${f}.runlog.jsonl`; };
|
|
276
|
+
const keepRunLog = (h, runLog) => {
|
|
277
|
+
if (!runLog) return;
|
|
278
|
+
try { const f = runLogFile(h.issue); mkdirSync(dirname(f), { recursive: true }); writeFileSync(f, redact(String(runLog), [...known])); } catch { /* evidence only */ }
|
|
279
|
+
mergeRemoteLog(env.FORGE_RUNS_DIR || join(homedir(), ".forge", "runs"), h.issue, runLog, { repo });
|
|
280
|
+
};
|
|
281
|
+
/**
|
|
282
|
+
* #6117: everything the sandbox still holds, copied to the dispatcher BEFORE it is destroyed: the rest of the lane log
|
|
283
|
+
* (chunks past the cursor, until drained), the run log, and (when the log could not be drained) the stderr tail.
|
|
284
|
+
* Runs on every terminal path (teardown is their one choke point) and never throws.
|
|
285
|
+
*/
|
|
286
|
+
const collectEvidence = async (h) => {
|
|
287
|
+
try {
|
|
288
|
+
let drained = false;
|
|
289
|
+
for (let i = 0; i < 64; i++) { const r = await pullLogs(h); drained = r.ok; if (!r.ok || r.bytes === 0) break; }
|
|
290
|
+
if (typeof transport.runlog !== "function") return;
|
|
291
|
+
const e = await transport.runlog(h.id).catch(() => null);
|
|
292
|
+
if (!e) return;
|
|
293
|
+
keepRunLog(h, e.runLog);
|
|
294
|
+
if (!drained && e.tail) {
|
|
295
|
+
const f = batch.logFile(h.issue); mkdirSync(dirname(f), { recursive: true });
|
|
296
|
+
appendFileSync(f, redact(`\n[sandbox ${h.id}] last lines of its log (the live stream could not be drained before teardown):\n${e.tail}${e.tail.endsWith("\n") ? "" : "\n"}`, [...known]));
|
|
297
|
+
}
|
|
298
|
+
} catch { /* teardown goes on */ }
|
|
269
299
|
};
|
|
270
300
|
return {
|
|
271
301
|
name,
|
|
@@ -330,7 +360,7 @@ export function remoteProvider({ batch, repo, settings = {}, name = "remote", tr
|
|
|
330
360
|
if (r) { await pullLogs(h); await minutesOf(h); }
|
|
331
361
|
if (!r) return null;
|
|
332
362
|
const { runLog, ...rest } = r; // #5697: the lane's run log goes to the host run log, not into the result
|
|
333
|
-
|
|
363
|
+
keepRunLog(h, runLog); // #6117: the host run log and `<n>.runlog.jsonl` beside the lane log
|
|
334
364
|
return rest;
|
|
335
365
|
},
|
|
336
366
|
/** #5991: is the pool agent of this handle answering? Unknown (null) without transport support; transport errors propagate. */
|
|
@@ -357,6 +387,7 @@ export function remoteProvider({ batch, repo, settings = {}, name = "remote", tr
|
|
|
357
387
|
/** #5241: why the last `stop(h)` returned false (null when it succeeded or never ran), so a cancel can report it. */
|
|
358
388
|
stopReason: (h) => stopWhy.get(h?.id) ?? null,
|
|
359
389
|
async teardown(h) {
|
|
390
|
+
await collectEvidence(h); // #6117: the run log and the log tail leave the sandbox before it is destroyed
|
|
360
391
|
await minutesOf(h);
|
|
361
392
|
try { return (await transport.destroy(h.id)) !== false; } catch { return false; }
|
|
362
393
|
},
|
package/bin/lean/schedd.mjs
CHANGED
|
@@ -78,7 +78,7 @@ export function batchVerdicts(root, { now = Date.now(), windowMin = DEFAULT_STAL
|
|
|
78
78
|
try {
|
|
79
79
|
const b = openBatch(root, id);
|
|
80
80
|
if (!b.readPlan()?.daemon || b.isTerminal()) continue;
|
|
81
|
-
const state = b.store.peek(), stall = evaluateDispatchStall(state, { held: b.readHeld(), parallel: b.readParallel(), hosted: false, paused: b.readPause?.() ?? null, lastProgressMs: b.
|
|
81
|
+
const state = b.store.peek(), stall = evaluateDispatchStall(state, { held: b.readHeld(), parallel: b.readParallel(), hosted: false, paused: b.readPause?.() ?? null, lastProgressMs: b.lastDispatchClockMs(), now, windowMin, lanesAliveMs: lanesAlive(b, state) });
|
|
82
82
|
const decision = stall ? decideStallAction(stall, { recovery: readHealth(b.dir)?.stallRecovery ?? null, hosted: false, now, windowMin }) : null;
|
|
83
83
|
out.push(batchVerdict(id, stall, decision));
|
|
84
84
|
} catch { /* one unreadable batch has no verdict */ }
|
|
@@ -657,7 +657,7 @@ export async function startDaemon({ dir = schedDir(), runBatch, idleMs = Number(
|
|
|
657
657
|
if (b.isTerminal() && (!Number.isFinite(created) || now - created >= 24 * 3600_000)) continue; // nothing left to report or re-host
|
|
658
658
|
const reported = !!b.readReport(), cancelled = !!b.readCancel(), state = b.store.peek(), isHosted = hosted.has(id) || starting.has(id);
|
|
659
659
|
await efficiencyTick(b, plan, state, { now, reported, cancelled }); // #5987: advisory; never throws, never changes dispatch
|
|
660
|
-
const stallOpts = { held: b.readHeld(), paused: b.readPause?.() ?? null, parallel: b.readParallel(), hosted: isHosted, lastProgressMs: b.
|
|
660
|
+
const stallOpts = { held: b.readHeld(), paused: b.readPause?.() ?? null, parallel: b.readParallel(), hosted: isHosted, lastProgressMs: b.lastDispatchClockMs(), now, windowMin: stallMin, cancelled, reported, lanesAliveMs: lanesAlive(b, state) };
|
|
661
661
|
let stall = evaluateDispatchStall(state, stallOpts);
|
|
662
662
|
if (stall && preflight) { // #5745: name the preflight gate holding admission (advisory; dispatch decisions are unchanged)
|
|
663
663
|
let gates = [];
|