forgedock 1.69.0 → 1.71.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.
@@ -18,15 +18,17 @@ import { lowerPriority } from "./hostload.mjs";
18
18
  import { reviewStagingJson, reviewStagingIo, CI_EXCLUDED_CHECKS } from "../review-staging.mjs";
19
19
  import { pickFixes, recut, revertLast } from "./release-snapshot.mjs";
20
20
  import { parseFixConfig, collectFindings, blockingOf, compileBrief, roundsAt, recordRound, secondPush, secondPushOf, holdForOwner, jobsToRerun, inputHash, deferredOf } from "./release-fixloop.mjs";
21
- import { coStartCi } from "./release-preflight.mjs";
22
21
  import { laneEnv } from "./release-credentials.mjs";
22
+ import { ciGreenWait, addTiming, blockSetOf } from "./release-cigreen.mjs";
23
23
 
24
24
  /** Delta passes after a head move: past it the job blocks for the manual path. Fix rounds are `ci.fix.max_rounds` (release-fixloop.mjs, default 1, #5567). */
25
25
  export const MAX_DELTA_PASSES = 2;
26
26
  const REVIEW_MS = 45 * 60_000, LANE_MS = 3 * 60 * 60_000;
27
27
  const CI_WAIT_MS = 10 * 60_000, CI_POLL_MS = 60_000; // #5779: bounded fail-late CI wait of the fix step
28
28
  const ROOT = fileURLToPath(new URL("../..", import.meta.url));
29
- const SEVERE = new Set(["CRITICAL", "HIGH"]);
29
+ const DEFAULT_BLOCK = new Set(["CRITICAL", "HIGH"]);
30
+ /** Default policy (no off switch): a finding blocks only when CONFIRMED and at or above the blocking severity (default HIGH; forge.yaml release.block_severity tightens or loosens it). Everything else is filed for the next release. */
31
+ const isBlocking = (item, st, set) => set.has(String(item.severity ?? "").toUpperCase()) && (!Array.isArray(st.confirmedIds) || st.confirmedIds.includes(item.id));
30
32
  const MANUAL = "use the manual path: forgedock review-staging <PR> (commands/review-pr-staging.md)";
31
33
  const blocked = (why) => ({ blocked: true, reason: `${why}; ${MANUAL}` });
32
34
 
@@ -177,35 +179,49 @@ async function reviewRound({ seam, pr, def, delta }) {
177
179
  }
178
180
 
179
181
  /** The whole review of PR `pr`: rounds until one finalizes at its own head. @returns the step result or `{blocked}`. */
180
- async function runReview({ seam, pr, def, delta = null }) {
182
+ async function runReview({ seam, pr, def, delta = null, green = null, blockSet = DEFAULT_BLOCK, maxDelta = 0 }) {
181
183
  let st = null;
182
184
  for (let pass = 0; ; pass++) {
183
185
  const r = await reviewRound({ seam, pr, def, delta });
184
186
  if (r.fail) return blocked(r.fail);
185
187
  if (r.ok) { st = r.ok; break; }
186
- if (pass >= MAX_DELTA_PASSES) return blocked(`head of #${pr} kept moving during the review (${MAX_DELTA_PASSES} delta passes)`);
188
+ // Default flow: ONE review pass on the green head. A head that moves under the review is not reviewed again in place: re-run the release (ci-green re-checks the new head).
189
+ if (!maxDelta) return blocked(`head of #${pr} moved during the review (${String(r.moved).slice(0, 7)} -> ${String(await seam.headOf(pr)).slice(0, 7)}); re-run the release: ci-green re-checks the new head, then one review pass`);
190
+ if (pass >= maxDelta) return blocked(`head of #${pr} kept moving during the review (${maxDelta} delta passes)`);
187
191
  delta = r.moved;
192
+ if (green) { const g = await green(); if (g?.blocked) return g; } // a head move goes back through ci-green before the delta review
188
193
  }
189
194
  const filed = [], blocking = [];
190
195
  for (const item of st.toFile ?? []) {
191
196
  const n = await seam.fileIssue({ item, pr, head: st.head });
192
197
  if (!n) return blocked(`could not file the finding "${item.title ?? item.id}"`);
193
198
  filed.push(n);
194
- if (SEVERE.has(String(item.severity ?? "").toUpperCase())) blocking.push(n);
199
+ if (isBlocking(item, st, blockSet)) blocking.push(n);
195
200
  }
196
201
  if ((st.notes ?? []).length) await seam.addNotes(pr, st.notes);
197
202
  const sum = await seam.summary({ pr, filed });
198
203
  if (!sum.data) return blocked(`the gate summary was not posted (exit ${sum.code}): ${(sum.lines ?? []).slice(-1).join("").slice(0, 200)}`);
199
- return { pr, head: st.head, verdict: sum.data.verdict, marker: sum.data.marker, ciFailing: sum.data.ciFailing, ciCancelOnly: Boolean(sum.data.ciCancelOnly), ciPendingOnly: Boolean(sum.data.ciPendingOnly), filed, blocking, items: st.toFile ?? [], guards: st.guards ?? [], delta: st.delta?.from ?? null };
204
+ return { pr, head: st.head, verdict: sum.data.verdict, marker: sum.data.marker, ciFailing: sum.data.ciFailing, ciCancelOnly: Boolean(sum.data.ciCancelOnly), ciPendingOnly: Boolean(sum.data.ciPendingOnly), filed, blocking, items: (st.toFile ?? []).map((i) => ({ ...i, blocking: isBlocking(i, st, blockSet), filed: true })), guards: st.guards ?? [], delta: st.delta?.from ?? null };
200
205
  }
201
206
 
202
- /** Review step. @returns {{pr, head, verdict, marker, filed, blocking}|{blocked: true, reason: string}} */
207
+ /**
208
+ * Review step: ONE review pass on a head whose required checks are green (the v1.0 contract, commands/review-pr-staging.md at dcfb86bf).
209
+ * Every finding is filed (Phase 7) and nothing the review finds is fixed in the release PR. The `release.review_fixes` knob (default
210
+ * off) restores the #5212 delta passes. @returns {{pr, head, verdict, marker, filed, blocking}|{blocked: true, reason: string}}
211
+ */
212
+ export const seamOf = (ctx) => ctx.io.review ?? (ctx.seam ??= realSeam(ctx));
203
213
  export async function reviewStep(ctx) {
204
214
  const pr = ctx.state?.steps?.["release-pr"]?.result?.pr;
205
215
  if (!pr) return blocked("no release PR recorded by the release-pr step");
206
- const started = await coStartCi(ctx, { pr }); // #5567: CI and the panel start on the same head (off unless ci.fix is configured)
207
- if (started?.refused) return { refused: started.refused };
208
- return runReview({ seam: seamOf(ctx), pr, def: ctx.def });
216
+ const g = await ciGreenWait(ctx, pr); // cheap when already green; covers a head that moved since the ci-green step (a resume)
217
+ if (g.blocked) return g;
218
+ const legacy = Boolean(ctx.config?.reviewFixes);
219
+ return timedReview(ctx, () => runReview({ seam: seamOf(ctx), pr, def: ctx.def, green: () => ciGreenWait(ctx, pr), blockSet: blockSetOf(ctx.config), maxDelta: legacy ? MAX_DELTA_PASSES : 0 }));
220
+ }
221
+ /** Review minutes and passes of this release go to `state.timing` (read by release status and the ledger). */
222
+ async function timedReview(ctx, fn) {
223
+ const t0 = Date.now();
224
+ try { return await fn(); } finally { addTiming(ctx, "review_min", Date.now() - t0); addTiming(ctx, "review_passes", 1, { raw: true }); }
209
225
  }
210
226
 
211
227
  /** Re-read the gate summary into the review result (after a rerun or a re-summarise). */
@@ -243,7 +259,7 @@ async function secondRound(ctx, seam, r, cfg) {
243
259
  const head = await seam.headOf(r.pr);
244
260
  recordRound(ctx.state, { from: r.head, to: head, kind: "revert", failedBefore: rec.ci.map((j) => j.name) });
245
261
  ctx.save();
246
- const next = await runReview({ seam, pr: r.pr, def: ctx.def, delta: r.head });
262
+ const next = await runReview({ seam, pr: r.pr, def: ctx.def, delta: r.head, maxDelta: MAX_DELTA_PASSES });
247
263
  if (next.blocked) return next;
248
264
  ctx.state.steps.review = { ...ctx.state.steps.review, result: next };
249
265
  ctx.save();
@@ -251,11 +267,96 @@ async function secondRound(ctx, seam, r, cfg) {
251
267
  }
252
268
 
253
269
  /**
254
- * Fix step: nothing to do on GATE_PASS; else ONE round (`ci.fix.max_rounds`, counted per head sha): collect every failed job, finding
270
+ * One fix round on release PR `r.pr`: collect every failed CI job, blocking finding and guard on `r.head`, compile one brief, file one fix
271
+ * issue, run one lane, bring the fix onto the release branch and record the head move. No review here: the caller sends the new head back
272
+ * through ci-green and then ONE delta review. @returns {{head, rec}|{blocked: true, reason}}
273
+ */
274
+ export async function fixRound(ctx, seam, r) {
275
+ const cfg = parseFixConfig(ctx.config?.fix);
276
+ // #5779: with blocking findings in hand the fix round starts now (completed runs go into the brief); else the wait is bounded
277
+ const seen = r.ciFailing > 0 ? await seam.failedJobs({ pr: r.pr, head: r.head, wait: !r.blocking?.length }) : [];
278
+ // #6013: failures the staging-health gate named earlier ride along in the same brief, so all fixes are dispatched together.
279
+ const known = (ctx.state.knownFailures ?? []).filter((k) => !seen.some((j) => j.name === k.name)).map((k) => ({ name: k.name, conclusion: "failure", log: `failed on staging (${k.cause})` }));
280
+ const jobs = Object.assign([...seen, ...known], { pending: seen.pending });
281
+ const rec = collectFindings({ head: r.head, jobs, findings: r.items ?? [], guards: r.guards ?? [] });
282
+ const b = blockingOf(rec);
283
+ if (!b.ci.length && !b.review.length && !b.guards.length && !r.blocking?.length && jobs.pending?.length) return blocked(`required checks of #${r.pr} still running (${jobs.pending.join(", ")}), with no failure to fix yet; re-run the release once CI finishes`);
284
+ if (!b.ci.length && !b.review.length && !b.guards.length && !r.blocking?.length && !(r.ciFailing > 0)) return blocked(`${r.verdict} (${r.marker}) on #${r.pr} at ${String(r.head).slice(0, 7)} with neither a blocking finding nor red CI to fix: nothing is pending or failing, so the gate summary names the actual blocker; read it and re-run the release`);
285
+ const hashesNow = Object.fromEntries(rec.ci.map((j) => [j.name, j.inputHash ?? inputHash(j.name, r.head)]));
286
+ const brief = compileBrief(rec, { commands: ctx.config?.preflight ? [ctx.config.preflight.command] : [], rerunChecks: jobsToRerun(hashesNow, ctx.state.fixloop?.hashes ?? {}) });
287
+ // Non-blocking and out-of-wave findings become next-plan issues, once per head; they are never part of the fix and never merged after READY (I16).
288
+ const fl = (ctx.state.fixloop ??= { heads: {} });
289
+ fl.hashes = hashesNow;
290
+ if (!fl.deferred?.includes(r.head)) {
291
+ const later = deferredOf(rec).filter((x) => !x.filed); // review findings are already filed for the next release by the review round
292
+ if (later.length) await seam.fileDeferred?.({ pr: r.pr, head: r.head, items: later });
293
+ fl.deferred = [...(fl.deferred ?? []), r.head];
294
+ ctx.save();
295
+ }
296
+ // One issue carries the whole brief (blocking findings stay filed as their own issues and are referenced); its lane is the one fix lane.
297
+ const issue = await seam.fileFixIssue({ pr: r.pr, head: r.head, brief, blocking: r.blocking ?? [] });
298
+ if (!issue) return blocked(`could not file the fix issue for #${r.pr}`);
299
+ // A resume after the fix already merged (by this job or by an intake lane): its lane would end invalid on a closed issue.
300
+ if (!(await seam.issueMerged?.(issue))) {
301
+ const lane = await seam.runLane({ issue, lane: ctx.staging });
302
+ if (lane?.terminalReason !== "merged") return blocked(`fix lane for #${issue} ended ${lane?.terminalReason ?? "without a result"}`);
303
+ }
304
+ // Snapshot mode (#5276): the fixes are merged on staging; bring exactly those onto release/<id> (or recut it) before the delta review.
305
+ if (ctx.config?.mode === "snapshot") {
306
+ const moved = ctx.config.fixMode === "recut" ? await recut(ctx) : await pickFixes(ctx, { issues: [issue, ...(r.blocking ?? [])] });
307
+ if (moved.err) return blocked(moved.err);
308
+ }
309
+ // The host preflight re-runs on the head the fixes produced, before the delta review (the draft PR has no Actions CI yet, #5277).
310
+ const head = await seam.headOf(r.pr);
311
+ if (ctx.config?.preflight) {
312
+ const pf = await runHostPreflight(ctx, { head, pr: r.pr });
313
+ if (!pf.ok && pf.blocking) return blocked(`host preflight failed at ${pf.head} after the fix round (release-blocker #${pf.issue})`);
314
+ }
315
+ recordRound(ctx.state, { from: r.head, to: head, failedBefore: rec.ci.map((j) => j.name) });
316
+ ctx.save();
317
+ addTiming(ctx, "fix_rounds", Object.values(ctx.state.fixloop?.heads ?? {}).filter((h) => !h.second).length, { set: true });
318
+ return { head, rec };
319
+ }
320
+
321
+ /**
322
+ * Verdict step (default flow, the v1.0 contract at dcfb86bf): GATE_PASS passes. A CONFIRMED CRITICAL/HIGH blocker (or a failed guard)
323
+ * STOPS the release: no fix lane, no delta pass. The blocker issues are queued into the repo's open orchestrate batch, the release PR is
324
+ * closed with the verdict, and the next release starts fresh once they merge (the open-finding gate enforces that). Everything else the
325
+ * review found is already filed for later. The `release.review_fixes` knob (default off) restores the #5212 fix lanes below.
326
+ */
327
+ export async function fixStep(ctx) {
328
+ const r = ctx.state?.steps?.review?.result;
329
+ if (!r?.pr) return blocked("no review result recorded by the review step");
330
+ if (ctx.config?.reviewFixes) return legacyFixStep(ctx);
331
+ const seam = seamOf(ctx);
332
+ if (ctx.state.reviewBlocked?.head === r.head) return { blocked: true, reason: ctx.state.reviewBlocked.reason }; // a resume of a stopped release says the same thing, queues nothing twice
333
+ let res = r;
334
+ // #5912: a CI-only gap at an unmoved head is re-summarised once, so CI that finished green since posts GATE_PASS.
335
+ if (res.marker !== "FORGE:GATE_PASS" && !res.blocking?.length && !res.guards?.length && (res.ciPendingOnly || res.ciCancelOnly || !(res.ciFailing > 0)) && (await seam.headOf(res.pr)) === res.head) {
336
+ const s = await resummarise(ctx, seam, res);
337
+ if (s.err) return blocked(s.err);
338
+ res = s.r;
339
+ }
340
+ if (res.marker === "FORGE:GATE_PASS") return { verdict: res.verdict, head: res.head };
341
+ if (res.blocking?.length || res.guards?.length) {
342
+ const names = res.blocking?.length ? res.blocking.map((n) => `#${n}`).join(" ") : (res.guards ?? []).map((g) => g.name).join(", ");
343
+ const queued = res.blocking?.length ? await seam.queueBlockers?.({ pr: res.pr, blockers: res.blocking }) : null;
344
+ const closed = await seam.holdReleasePr?.({ pr: res.pr, blockers: res.blocking ?? [], guards: res.guards ?? [], queued, verdict: res.verdict });
345
+ const reason = `review blockers ${names}${queued?.batch ? ` (queued in batch ${queued.batch})` : ""}; release PR #${res.pr} ${closed?.closed ? "closed" : "held"}; the next release starts fresh after they merge`;
346
+ ctx.state.reviewBlocked = { head: res.head, blockers: res.blocking ?? [], batch: queued?.batch ?? null, reason };
347
+ ctx.save();
348
+ return { blocked: true, held: true, reason };
349
+ }
350
+ if (res.ciFailing > 0) return blocked(`required checks of #${res.pr} are not green at ${String(res.head).slice(0, 7)} (${res.ciPendingOnly ? "pending" : "red"}); re-run the release: ci-green waits and fixes CI once, then one review pass`);
351
+ return blocked(`${res.verdict} (${res.marker}) on #${res.pr} at ${String(res.head).slice(0, 7)} with no blocking finding and no red CI: the gate summary names the blocker; read it and re-run the release`);
352
+ }
353
+
354
+ /**
355
+ * Legacy review-fix step (#5212, #5567), only with `release.review_fixes: true` (default off): nothing to do on GATE_PASS; else ONE round (`ci.fix.max_rounds`, counted per head sha): collect every failed job, finding
255
356
  * and guard on the head, compile one invariant-grouped brief, file one fix issue, run one lane, push once, delta-review the fix commits.
256
357
  * A still-failing head after the budget gets only a mechanical revert or an infra-flake rerun, once; else HELD with an owner ask.
257
358
  */
258
- export async function fixStep(ctx) {
359
+ async function legacyFixStep(ctx) {
259
360
  let r = ctx.state?.steps?.review?.result;
260
361
  if (!r?.pr) return blocked("no review result recorded by the review step");
261
362
  const seam = seamOf(ctx);
@@ -285,48 +386,13 @@ export async function fixStep(ctx) {
285
386
  r = s.r;
286
387
  continue;
287
388
  }
288
- // #5779: with blocking findings in hand the fix round starts now (completed runs go into the brief); else the wait is bounded
289
- const seen = r.ciFailing > 0 ? await seam.failedJobs({ pr: r.pr, head: r.head, wait: !r.blocking?.length }) : [];
290
- // #6013: failures the staging-health gate named earlier ride along in the same brief, so all fixes are dispatched together.
291
- const known = (ctx.state.knownFailures ?? []).filter((k) => !seen.some((j) => j.name === k.name)).map((k) => ({ name: k.name, conclusion: "failure", log: `failed on staging (${k.cause})` }));
292
- const jobs = Object.assign([...seen, ...known], { pending: seen.pending });
293
- const rec = collectFindings({ head: r.head, jobs, findings: r.items ?? [], guards: r.guards ?? [] });
294
- const b = blockingOf(rec);
295
- if (!b.ci.length && !b.review.length && !b.guards.length && !r.blocking?.length && jobs.pending?.length) return blocked(`required checks of #${r.pr} still running (${jobs.pending.join(", ")}), with no failure to fix yet; re-run the release once CI finishes`);
296
- if (!b.ci.length && !b.review.length && !b.guards.length && !r.blocking?.length && !(r.ciFailing > 0)) return blocked(`${r.verdict} (${r.marker}) on #${r.pr} at ${String(r.head).slice(0, 7)} with neither a blocking finding nor red CI to fix: nothing is pending or failing, so the gate summary names the actual blocker; read it and re-run the release`);
297
- const hashesNow = Object.fromEntries(rec.ci.map((j) => [j.name, j.inputHash ?? inputHash(j.name, r.head)]));
298
- const brief = compileBrief(rec, { commands: ctx.config?.preflight ? [ctx.config.preflight.command] : [], rerunChecks: jobsToRerun(hashesNow, ctx.state.fixloop?.hashes ?? {}) });
299
- // Non-blocking and out-of-wave findings become next-plan issues, once per head; they are never part of the fix and never merged after READY (I16).
300
- const fl = (ctx.state.fixloop ??= { heads: {} });
301
- fl.hashes = hashesNow;
302
- if (!fl.deferred?.includes(r.head)) {
303
- const later = deferredOf(rec);
304
- if (later.length) await seam.fileDeferred?.({ pr: r.pr, head: r.head, items: later });
305
- fl.deferred = [...(fl.deferred ?? []), r.head];
306
- ctx.save();
307
- }
308
- // One issue carries the whole brief (blocking findings stay filed as their own issues and are referenced); its lane is the one fix lane.
309
- const issue = await seam.fileFixIssue({ pr: r.pr, head: r.head, brief, blocking: r.blocking ?? [] });
310
- if (!issue) return blocked(`could not file the fix issue for #${r.pr}`);
311
- // A resume after the fix already merged (by this job or by an intake lane): its lane would end invalid on a closed issue.
312
- if (!(await seam.issueMerged?.(issue))) {
313
- const lane = await seam.runLane({ issue, lane: ctx.staging });
314
- if (lane?.terminalReason !== "merged") return blocked(`fix lane for #${issue} ended ${lane?.terminalReason ?? "without a result"}`);
315
- }
316
- // Snapshot mode (#5276): the fixes are merged on staging; bring exactly those onto release/<id> (or recut it) before the delta review.
317
- if (ctx.config?.mode === "snapshot") {
318
- const moved = ctx.config.fixMode === "recut" ? await recut(ctx) : await pickFixes(ctx, { issues: [issue, ...(r.blocking ?? [])] });
319
- if (moved.err) return blocked(moved.err);
320
- }
321
- // The host preflight re-runs on the head the fixes produced, before the delta review (the draft PR has no Actions CI yet, #5277).
322
- const head = await seam.headOf(r.pr);
323
- if (ctx.config?.preflight) {
324
- const pf = await runHostPreflight(ctx, { head, pr: r.pr });
325
- if (!pf.ok && pf.blocking) return blocked(`host preflight failed at ${pf.head} after the fix round (release-blocker #${pf.issue})`);
326
- }
327
- recordRound(ctx.state, { from: r.head, to: head, failedBefore: rec.ci.map((j) => j.name) });
328
- ctx.save();
329
- const next = await runReview({ seam, pr: r.pr, def: ctx.def, delta: r.head });
389
+ const f = await fixRound(ctx, seam, r);
390
+ if (f.blocked) return f;
391
+ const { head, rec } = f;
392
+ // The fix moved the head: ci-green first (it never starts a second fix), then ONE delta review limited to what the fix touched.
393
+ const g = await ciGreenWait(ctx, r.pr, { noFix: true });
394
+ if (g.blocked || g.red) return g.blocked ? g : blocked(`required checks of #${r.pr} are still red after the fix round (${g.failing.join(", ")})`);
395
+ const next = await timedReview(ctx, () => runReview({ seam, pr: r.pr, def: ctx.def, delta: r.head, green: () => ciGreenWait(ctx, r.pr, { noFix: true }), blockSet: blockSetOf(ctx.config), maxDelta: MAX_DELTA_PASSES }));
330
396
  if (next.blocked) return next;
331
397
  if (next.head && next.head !== head) { recordRound(ctx.state, { from: r.head, to: next.head, failedBefore: rec.ci.map((j) => j.name) }); ctx.save(); } // the reviewed head is the one the budget is keyed on
332
398
  r = next;
@@ -336,7 +402,6 @@ export async function fixStep(ctx) {
336
402
  return { verdict: r.verdict, head: r.head };
337
403
  }
338
404
 
339
- const seamOf = (ctx) => ctx.io.review ?? (ctx.seam ??= realSeam(ctx));
340
405
 
341
406
  /** Real effects of the review steps: the review-staging library, the engine runner, the filing scripts, gh and a lane process. */
342
407
  /** #6098: CPU niceness of reviewer processes (ionice idle class is applied alongside). */
@@ -408,6 +473,21 @@ export function realSeam({ repo, def, env = process.env, laneStrip = [], cwd = p
408
473
  return Object.assign(jobs, { pending: open(runs) });
409
474
  },
410
475
  // #5567: findings that do not block (or lie outside the wave) are filed for the next plan, labelled so the release never picks them up
476
+ // Default flow: a blocking verdict queues the blocker issues into the repo's open orchestrate batch (when one exists) and closes the release PR.
477
+ queueBlockers: async ({ blockers }) => {
478
+ try {
479
+ const batches = (await io?.batches?.(repo)) ?? [];
480
+ if (!batches.length) return { batch: null };
481
+ const add = io?.addToBatch ?? (async (id, nums) => { const { orchestrateFromCli } = await import("../engine-cli.mjs"); await orchestrateFromCli(["--add", id, ...nums.map(String)]); });
482
+ await add(batches[0].id, blockers);
483
+ return { batch: batches[0].id };
484
+ } catch (e) { return { batch: null, error: String(e?.message ?? e).split("\n")[0] }; }
485
+ },
486
+ holdReleasePr: async ({ pr, blockers, guards, queued, verdict }) => {
487
+ const what = blockers.length ? `confirmed CRITICAL/HIGH finding(s) ${blockers.map((n) => `#${n}`).join(" ")}` : `failed guard(s) ${guards.map((g) => g.name).join(", ")}`;
488
+ const body = `Release stopped: ${verdict ?? "BLOCK DEPLOY"}. ${what} block this release. ${queued?.batch ? `They are queued in orchestrate batch ${queued.batch}.` : "No orchestrate batch is open: start one with `forgedock orchestrate " + blockers.join(" ") + "`."} Nothing found by the review is fixed inside the release PR; the next release starts fresh after they merge (the open-finding gate enforces it).`;
489
+ try { gh(["pr", "close", String(pr), "-R", repo, "--comment", body]); return { closed: true }; } catch { try { gh(["pr", "comment", String(pr), "-R", repo, "--body", body]); } catch { /* the blocked result still stops the job */ } return { closed: false }; }
490
+ },
411
491
  async fileDeferred({ pr, items }) {
412
492
  const out = [];
413
493
  for (const f of items) { const n = await this.fileIssue({ item: { title: `Next plan: ${f.title}`, severity: f.severity ?? "LOW", body: `Not blocking release PR #${pr} (non-blocking or outside the wave); deferred to the next plan.` }, pr }); if (n) out.push(n); }
@@ -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
- const ctx = (seam, steps = {}) => ({ io: { review: seam }, repo: "o/r", def: "main", staging: "staging", state: { steps: { "release-pr": { result: { pr: 7 } }, ...steps } }, save() {} });
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("is bounded: one round (ci.fix.max_rounds default 1), then HELD with an owner ask for a non-flake, non-regression failure", async () => {
211
- const bad = { code: 0, data: { verdict: "BLOCK DEPLOY", marker: "FORGE:GATE_FAILURE", ciFailing: 0 }, lines: [] };
212
- const s = fakeSeam({ heads: [H2], summary: bad, fins: [fin({ toFile: [{ title: "x", severity: "CRITICAL" }] })] });
213
- const r = await fixStep(ctx(s, { review: { result: failed } }));
214
- assert.equal(r.blocked, true);
215
- assert.equal(r.held, true);
216
- assert.match(r.reason, /^Owner: .*ci\.fix\.max_rounds=1/);
217
- assert.equal(s.log.filter((e) => e[0] === "lane").length, 1);
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`,
@@ -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";
@@ -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. */
@@ -377,6 +378,7 @@ const STEP_FNS = {
377
378
  preflight: preflightStep,
378
379
  "host-preflight": hostPreflightStep,
379
380
  "release-pr": releasePrStep,
381
+ "ci-green": (ctx) => ciGreenStep(ctx),
380
382
  review: (ctx) => reviewStep(ctx),
381
383
  fixes: (ctx) => fixStep(ctx),
382
384
  "mark-ready": markReadyStep,