forgedock 1.59.1 → 1.60.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.
Files changed (94) hide show
  1. package/bin/engine/outcome-codes.mjs +3 -3
  2. package/bin/engine-cli.mjs +50 -10
  3. package/bin/labels.json +5 -0
  4. package/bin/lean/batch.mjs +21 -2
  5. package/bin/lean/batch.test.mjs +116 -1
  6. package/bin/lean/conformance.mjs +12 -5
  7. package/bin/lean/conformance.test.mjs +30 -2
  8. package/bin/lean/depcache.mjs +34 -15
  9. package/bin/lean/depcache.test.mjs +100 -1
  10. package/bin/lean/design-gate.mjs +15 -10
  11. package/bin/lean/design-gate.test.mjs +21 -0
  12. package/bin/lean/effects.mjs +18 -2
  13. package/bin/lean/execution.mjs +23 -5
  14. package/bin/lean/execution.test.mjs +81 -1
  15. package/bin/lean/gatewatch.test.mjs +5 -5
  16. package/bin/lean/issuewatch-triage.mjs +68 -0
  17. package/bin/lean/issuewatch-triage.test.mjs +98 -0
  18. package/bin/lean/issuewatch.mjs +34 -6
  19. package/bin/lean/issuewatch.test.mjs +11 -0
  20. package/bin/lean/lanelock.mjs +5 -4
  21. package/bin/lean/lean.mjs +123 -17
  22. package/bin/lean/lean.test.mjs +154 -6
  23. package/bin/lean/orchestrate-cancel.test.mjs +33 -0
  24. package/bin/lean/orchestrate-hostfallback.test.mjs +41 -0
  25. package/bin/lean/orchestrate-recovering.test.mjs +42 -0
  26. package/bin/lean/orchestrate.mjs +23 -10
  27. package/bin/lean/pagegate.mjs +50 -12
  28. package/bin/lean/pagegate.test.mjs +38 -1
  29. package/bin/lean/phaseledger.mjs +65 -2
  30. package/bin/lean/phaseledger.test.mjs +70 -2
  31. package/bin/lean/preflight.mjs +5 -2
  32. package/bin/lean/preflight.test.mjs +7 -0
  33. package/bin/lean/prompts.mjs +2 -1
  34. package/bin/lean/recovery.test.mjs +11 -6
  35. package/bin/lean/release-classify.mjs +143 -0
  36. package/bin/lean/release-classify.test.mjs +130 -0
  37. package/bin/lean/release-conductor.mjs +163 -0
  38. package/bin/lean/release-conductor.test.mjs +194 -0
  39. package/bin/lean/release-config.mjs +60 -8
  40. package/bin/lean/release-config.test.mjs +43 -1
  41. package/bin/lean/release-control.mjs +22 -5
  42. package/bin/lean/release-control.test.mjs +22 -0
  43. package/bin/lean/release-credentials.mjs +40 -0
  44. package/bin/lean/release-credentials.test.mjs +42 -0
  45. package/bin/lean/release-deploy.mjs +3 -3
  46. package/bin/lean/release-deploy.test.mjs +8 -0
  47. package/bin/lean/release-docs.test.mjs +93 -0
  48. package/bin/lean/release-fence.mjs +2 -0
  49. package/bin/lean/release-gate.mjs +88 -0
  50. package/bin/lean/release-gate.test.mjs +116 -0
  51. package/bin/lean/release-gates.mjs +5 -1
  52. package/bin/lean/release-ledger.mjs +47 -1
  53. package/bin/lean/release-ledger.test.mjs +33 -1
  54. package/bin/lean/release-mergeback.mjs +148 -0
  55. package/bin/lean/release-mergeback.test.mjs +129 -0
  56. package/bin/lean/release-p0.mjs +193 -0
  57. package/bin/lean/release-p0.test.mjs +127 -0
  58. package/bin/lean/release-plan.mjs +267 -0
  59. package/bin/lean/release-plan.test.mjs +202 -0
  60. package/bin/lean/release-preflight.mjs +16 -0
  61. package/bin/lean/release-regate.mjs +141 -0
  62. package/bin/lean/release-regate.test.mjs +149 -0
  63. package/bin/lean/release-review.mjs +5 -3
  64. package/bin/lean/release-rollback.mjs +277 -0
  65. package/bin/lean/release-rollback.test.mjs +245 -0
  66. package/bin/lean/release-snapshot.mjs +48 -9
  67. package/bin/lean/release-snapshot.test.mjs +43 -1
  68. package/bin/lean/release-start.mjs +164 -0
  69. package/bin/lean/release-start.test.mjs +171 -0
  70. package/bin/lean/release-status.mjs +6 -2
  71. package/bin/lean/release-train.mjs +159 -0
  72. package/bin/lean/release-train.test.mjs +139 -0
  73. package/bin/lean/release.mjs +127 -5
  74. package/bin/lean/release.test.mjs +80 -0
  75. package/bin/lean/sandbox-remote.mjs +2 -0
  76. package/bin/lean/schedd-load.test.mjs +82 -0
  77. package/bin/lean/schedd.mjs +67 -31
  78. package/bin/lean/schedd.test.mjs +80 -1
  79. package/bin/lean/validate-catalog.mjs +94 -0
  80. package/bin/lean/validate-catalog.test.mjs +42 -0
  81. package/bin/pool/agent.mjs +4 -1
  82. package/bin/pool/lane-tools.mjs +115 -0
  83. package/bin/pool/lane-tools.test.mjs +26 -0
  84. package/bin/pool/warm.mjs +1 -1
  85. package/docs/CONFIG.md +225 -1
  86. package/docs/ISSUE-WATCH.md +1 -0
  87. package/docs/design/visual-gate.md +10 -0
  88. package/docs/eval/adversarial-bench.md +1 -0
  89. package/package.json +5 -2
  90. package/pool/README.md +2 -0
  91. package/scripts/bench-adversarial.mjs +4 -0
  92. package/scripts/bench-lightlane.mjs +2 -1
  93. package/templates/github-actions/forge-conductor.scopes.json +7 -0
  94. package/templates/github-actions/forge-conductor.yml +57 -0
@@ -0,0 +1,267 @@
1
+ // SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
2
+ // SPDX-License-Identifier: AGPL-3.0-or-later
3
+ /**
4
+ * `forgedock release plan` (#5559): a deterministic, read-only dry run. A snapshot of open issues + the default-branch policy + the live sha
5
+ * becomes ordered waves, exclusions with machine-readable reason keys and a `plan_hash` an approval binds to (I2).
6
+ * `buildPlan` is pure (no clock, no I/O): the same inputs give a byte-identical plan whatever the input order. Effects (gh, git, ledger) live in `planFromCli`.
7
+ */
8
+ import { createHash } from "node:crypto";
9
+ import { resolvePath } from "./release-unitmap.mjs";
10
+ import { deriveFacts, riskOf } from "./release-classify.mjs";
11
+ import { priorityOf } from "./issuewatch-release.mjs";
12
+ import { trailingMedian, applyOnExceed, parseBudgetConfig } from "./release-minutes.mjs";
13
+
14
+ export const PLAN_SCHEMA = "forgedock.release.plan/v1";
15
+ export const PLAN_LABEL = "release-plan"; // tracking issue(s) whose comments carry FORGE:DECISION plan <hash>; never a candidate
16
+ export const DECISION_RE = /<!--\s*FORGE:DECISION\s+plan\s+([0-9a-f]{64})\s*-->/i;
17
+ export const BATCH_SKIP_LABELS = ["needs-human", "post-deploy", "workflow:merged", "awaiting-promotion", "host-task"];
18
+ export const EXCLUSION_KEYS = ["epic", "plan.skip_labels", "design_gate", "dependency_open", "ready_no", "unclassified", "dependency_cycle", "max_issues", "lane_force_exclude", "p0"];
19
+ export const LANE_FORCE_TTL_MS = 24 * 3_600_000; // a `lane --force` decision without `until` is honoured this long after `at`
20
+ const SEV = { P0: 0, P1: 1, P2: 2, P3: 3 };
21
+
22
+ const sha = (s) => createHash("sha256").update(s).digest("hex");
23
+ /** JSON with sorted object keys: the byte-stable form the hash and the output use. */
24
+ export const stableJson = (v) => JSON.stringify(v, (_k, x) => (x && typeof x === "object" && !Array.isArray(x) ? Object.fromEntries(Object.keys(x).sort().map((k) => [k, x[k]])) : x));
25
+ const names = (i) => (i.labels ?? []).map((l) => (typeof l === "string" ? l : l?.name)).filter(Boolean);
26
+ const depsOf = (i) => [...new Set([...String(i.body ?? "").matchAll(/^\s*(?:[-*]\s*)?\**depends on\**:?\s*(.+)$/gim)].flatMap((m) => [...m[1].matchAll(/#(\d+)/g)].map((x) => +x[1])).filter((n) => n !== i.number))].sort((a, b) => a - b);
27
+
28
+ /** The latest `FORGE:CLASSIFY` record in an issue's comments (JSON body), or null. */
29
+ export function recordOf(comments) {
30
+ const c = (comments ?? []).map((x) => String(x?.body ?? "")).filter((b) => b.includes("FORGE:CLASSIFY")).at(-1);
31
+ if (!c) return null;
32
+ let body = c; // drop every <!-- ... --> span (an unterminated one drops the rest) without a regex sanitizer
33
+ for (let i = body.indexOf("<!--"); i >= 0; i = body.indexOf("<!--", i)) { const j = body.indexOf("-->", i + 4); body = body.slice(0, i) + (j < 0 ? "" : body.slice(j + 3)); }
34
+ try { const o = JSON.parse(body.slice(body.indexOf("{"), body.lastIndexOf("}") + 1)); return o && typeof o === "object" ? o : null; } catch { return null; }
35
+ }
36
+
37
+ /**
38
+ * The units a set of changed files rolls (design 4.4), as one pure function. `units` is a superset of the units owning or coupled to the files and of every
39
+ * contract producer and consumer touched; `contract.order` is producer first; `pipeline` is `full` when any `forces` entry or a `service_pipeline: false` unit is involved.
40
+ */
41
+ export function rollSet(policy, files) {
42
+ const res = (files ?? []).map((f) => resolvePath(policy, f));
43
+ const units = new Set(), contracts = [], forced = [];
44
+ for (const r of res) {
45
+ r.units.forEach((u) => units.add(u));
46
+ r.affects.forEach((u) => units.add(u)); // shared paths roll the full couplings consumer set
47
+ for (const c of r.contracts) { if (!contracts.includes(c)) contracts.push(c); }
48
+ for (const f of r.forces) forced.push(f.reason ?? f.pipeline ?? "forces");
49
+ }
50
+ const order = [];
51
+ for (const c of contracts) { for (const u of [c.producer, ...(c.consumers ?? [])]) { if (u) { units.add(u); if (!order.includes(u)) order.push(u); } } }
52
+ const all = [...units].sort();
53
+ const noService = all.filter((u) => policy?.units?.[u]?.service_pipeline === false);
54
+ const hosts = {};
55
+ for (const u of all) {
56
+ const h = policy?.units?.[u]?.hosts;
57
+ if (Array.isArray(h) && h.length) hosts[u] = h.length > 1 && policy.units[u].single_host_ok ? [h[0]] : [...h]; // a two-host unit rolls on both unless single_host_ok
58
+ }
59
+ const additive = contracts.every((c) => c.additive_only === true);
60
+ return {
61
+ units: all,
62
+ contract: { atomic: contracts.length > 0, order, additive_only: additive, release_only: contracts.length > 0 && !additive },
63
+ pipeline: !all.length && !forced.length ? "none" : forced.length || noService.length ? "full" : "service",
64
+ forced: [...new Set(forced)].sort(), no_service: noService, hosts,
65
+ };
66
+ }
67
+
68
+ /** `lane --force` entries (`{force, actor, at, until?}`) still in force at `now` and from a trusted actor (when `trust.actors` is set). */
69
+ export function honouredLanes(lanes, policy, now) {
70
+ const trusted = policy?.trust?.actors ?? [], out = {};
71
+ for (const [n, e] of Object.entries(lanes ?? {})) {
72
+ if (!e?.actor || !["train", "release", "p0", "exclude"].includes(e.force)) continue;
73
+ if (trusted.length && !trusted.includes(e.actor)) continue;
74
+ const end = Date.parse(e.until ?? "") || (Date.parse(e.at ?? "") + LANE_FORCE_TTL_MS);
75
+ if (!(end > now)) continue; // expired or no usable timestamp
76
+ out[n] = { force: e.force, actor: e.actor, until: new Date(end).toISOString() };
77
+ }
78
+ return out;
79
+ }
80
+
81
+ function sccs(nodes, edges) { // Tarjan; edges: n -> [dependency numbers]
82
+ let idx = 0; const st = [], on = new Set(), low = new Map(), num = new Map(), out = [];
83
+ const visit = (v) => {
84
+ num.set(v, idx); low.set(v, idx++); st.push(v); on.add(v);
85
+ for (const w of edges.get(v) ?? []) {
86
+ if (!num.has(w)) { visit(w); low.set(v, Math.min(low.get(v), low.get(w))); } else if (on.has(w)) low.set(v, Math.min(low.get(v), num.get(w)));
87
+ }
88
+ if (low.get(v) === num.get(v)) { const c = []; let w; do { w = st.pop(); on.delete(w); c.push(w); } while (w !== v); out.push(c); }
89
+ };
90
+ for (const v of nodes) if (!num.has(v)) visit(v);
91
+ return out;
92
+ }
93
+
94
+ /**
95
+ * @param {{issues: object[], policy: object, policySha: string, liveSha: string|null, lanes?: object, now?: number, investigate?: (issue) => object|null, verifiedLive?: (n: number) => boolean}} input
96
+ * issues: `{number, title, body, labels, createdAt, updatedAt, comments?}`; PRs (`pullRequest`/`pull_request`/`isPullRequest`) are never candidates.
97
+ * @returns the plan: `{schema, plan_hash, policy_sha, live_sha, snapshot, waves, issues, excluded}`.
98
+ */
99
+ export function buildPlan({ issues, policy, policySha, liveSha, lanes = {}, now = 0, investigate, verifiedLive }) {
100
+ const pool = (issues ?? []).filter((i) => !(i.pullRequest || i.pull_request || i.isPullRequest) && !names(i).includes(PLAN_LABEL)).sort((a, b) => a.number - b.number);
101
+ const byNum = new Map(pool.map((i) => [i.number, i]));
102
+ const forces = honouredLanes(lanes, policy, now);
103
+ const snapshot = pool.map((i) => ({ number: i.number, updated_at: i.updatedAt ?? null, body_sha: sha(String(i.body ?? "")) }));
104
+ const hashed = { snapshot, policy_sha: policySha ?? null, live_sha: liveSha ?? null, ...(Object.keys(forces).length ? { lane_forces: forces } : {}) };
105
+ const excluded = new Map(), info = new Map();
106
+ const exclude = (n, key, detail) => { if (!excluded.has(n)) excluded.set(n, { number: n, key, detail }); };
107
+ const skip = [...new Set([...(policy?.plan?.skip_labels ?? BATCH_SKIP_LABELS), "hold"])], min = policy?.classify?.min_confidence;
108
+ const alive = [];
109
+ for (const i of pool) {
110
+ const n = i.number, ls = names(i);
111
+ if (ls.includes("epic")) { exclude(n, "epic", "epics are not built"); continue; }
112
+ const hit = ls.filter((l) => skip.includes(l) || l.startsWith("parked:"));
113
+ if (hit.length) { exclude(n, "plan.skip_labels", `labelled ${hit.join(", ")}`); continue; }
114
+ if (policy?.plan?.require_design_gate !== false && ls.includes("design:needed") && !ls.includes("design:approved")) { exclude(n, "design_gate", "design:needed without design:approved"); continue; }
115
+ let rec = recordOf(i.comments);
116
+ if (rec?.ready === false || ls.includes("ready:no")) { exclude(n, "ready_no", "classified ready: no"); continue; }
117
+ const low = (r) => !r || (min !== undefined && !(Number(r.confidence) >= min));
118
+ if (low(rec) && investigate) { const r = investigate(i); if (r && typeof r === "object") rec = { ...(rec ?? {}), ...r }; }
119
+ if (low(rec)) { exclude(n, "unclassified", rec ? `confidence ${rec.confidence ?? "unknown"} below classify.min_confidence ${min}` : "no FORGE:CLASSIFY record"); continue; }
120
+ if (forces[n]?.force === "exclude") { exclude(n, "lane_force_exclude", `lane --force exclude by ${forces[n].actor}`); continue; }
121
+ info.set(n, { rec });
122
+ alive.push(n);
123
+ }
124
+ // dependencies: a dependency that is excluded (or not verified live) blocks; cycles are found among the survivors
125
+ const edges = new Map();
126
+ for (const n of alive) {
127
+ edges.set(n, depsOf(byNum.get(n)).filter((d) => byNum.has(d)));
128
+ }
129
+ let live = new Set(alive);
130
+ for (const comp of sccs(alive, new Map([...edges].map(([k, v]) => [k, v.filter((d) => live.has(d))])))) {
131
+ if (comp.length > 1) comp.sort((a, b) => a - b).forEach((n) => { exclude(n, "dependency_cycle", `cycle ${comp.map((x) => `#${x}`).join(" -> ")}`); live.delete(n); });
132
+ }
133
+ for (let changed = true; changed;) {
134
+ changed = false;
135
+ for (const n of [...live]) {
136
+ const bad = depsOf(byNum.get(n)).filter((d) => (byNum.has(d) && !live.has(d)) || (!byNum.has(d) && verifiedLive && !verifiedLive(d)));
137
+ if (bad.length) { exclude(n, "dependency_open", `depends on ${bad.map((d) => `#${d}`).join(", ")} (unresolved, not verified live nor in an earlier wave)`); live.delete(n); changed = true; }
138
+ }
139
+ }
140
+ // topological order: dependency first, then severity, then age
141
+ const sev = (n) => SEV[info.get(n).rec.severity ?? priorityOf(byNum.get(n))] ?? 3;
142
+ const rank = (a, b) => sev(a) - sev(b) || String(byNum.get(a).createdAt ?? "").localeCompare(String(byNum.get(b).createdAt ?? "")) || a - b;
143
+ const pending = new Map([...live].map((n) => [n, new Set(depsOf(byNum.get(n)).filter((d) => live.has(d)))]));
144
+ const order = [];
145
+ while (pending.size) {
146
+ const ready = [...pending].filter(([, d]) => !d.size).map(([n]) => n).sort(rank);
147
+ const n = ready[0];
148
+ order.push(n); pending.delete(n); for (const d of pending.values()) d.delete(n);
149
+ }
150
+ // lane assignment, first match wins (design 4.5)
151
+ const plan = new Map(), trainMax = policy?.lanes?.train?.train_max_units ?? 3, unitsMax = policy?.lanes?.train?.units_max ?? trainMax;
152
+ for (const n of order) {
153
+ const { rec } = info.get(n), files = Array.isArray(rec.files) ? rec.files : [];
154
+ const rs = files.length ? rollSet(policy, files) : { ...rollSet(policy, []), units: [...(rec.units ?? [])].sort() };
155
+ const facts = files.length ? deriveFacts(policy, files, { diffLines: Number(rec.diff_lines) || 0 }) : null;
156
+ const risk = facts ? riskOf(policy, facts).risk : (rec.risk ?? "low");
157
+ const migrations = facts ? facts.migrations : (rec.migrations ?? "none");
158
+ const e = { number: n, lane: "release", reason: "", risk, units: rs.units, pipeline: rs.pipeline, severity: rec.severity ?? priorityOf(byNum.get(n)) ?? "P3" };
159
+ if (rs.contract.atomic) e.atomic = { order: rs.contract.order, additive_only: rs.contract.additive_only };
160
+ if (Object.keys(rs.hosts).length) e.hosts = rs.hosts;
161
+ const forced = forces[n];
162
+ const bug = rec.type === "bug";
163
+ if (forced && forced.force !== "exclude") { e.lane = forced.force; e.reason = `lane --force ${forced.force} by ${forced.actor} until ${forced.until}`; e.forced = true; }
164
+ else if (bug && e.severity === "P0") { exclude(n, "p0", "call p0"); continue; }
165
+ else if (bug) {
166
+ const why = [];
167
+ if (rec.exists_in !== "live") why.push(rec.exists_in === "staging-only" ? "staging-only" : `exists_in=${rec.exists_in ?? "unknown"}`);
168
+ if (migrations !== "none") why.push(`migrations=${migrations}`);
169
+ if (rs.contract.atomic || rec.contract_changed) why.push("contract change");
170
+ if (rs.units.length > unitsMax) why.push(`rolled set ${rs.units.length} > units_max ${unitsMax}`);
171
+ if (risk === "high") why.push("risk high");
172
+ e.lane = why.length ? "release" : "train"; e.reason = why.length ? why.join("; ") : "bug live, no migrations, no contract change, small rolled set";
173
+ } else if (rec.type === "docs" && !rs.units.length) { e.reason = "docs-only"; e.docs_only = true; }
174
+ else e.reason = `${rec.type ?? "unknown"} rolls with the release wave`;
175
+ if (rs.contract.release_only && e.lane === "train") { e.lane = "release"; e.reason = "contract change is not additive-only"; }
176
+ const late = depsOf(byNum.get(n)).find((d) => plan.get(d)?.lane === "release");
177
+ if (e.lane === "train" && late !== undefined) { e.lane = "release"; e.reason = `depends on #${late} (release wave)`; }
178
+ plan.set(n, e);
179
+ }
180
+ // waves: train waves (overflow opens the next), then the release wave
181
+ const waves = [], trainIds = order.filter((n) => plan.get(n)?.lane === "train");
182
+ const maxIssues = policy?.lanes?.train?.train_max_issues ?? 15;
183
+ let cur = null;
184
+ for (const n of trainIds) {
185
+ const u = plan.get(n).units;
186
+ const merged = cur ? new Set([...cur.units, ...u]) : null;
187
+ if (!cur || cur.issues.length >= maxIssues || merged.size > trainMax) { cur = { lane: "train", issues: [], units: [] }; waves.push(cur); }
188
+ cur.issues.push(n); cur.units = [...new Set([...cur.units, ...u])].sort();
189
+ }
190
+ const rel = order.filter((n) => plan.get(n)?.lane === "release");
191
+ if (rel.length) waves.push({ lane: "release", issues: rel, units: [...new Set(rel.flatMap((n) => plan.get(n).units))].sort() });
192
+ const cap = policy?.plan?.max_issues ?? 60;
193
+ let left = cap;
194
+ for (const w of waves) {
195
+ const keep = w.issues.slice(0, Math.max(0, left)); left -= keep.length;
196
+ for (const n of w.issues.slice(keep.length)) { exclude(n, "max_issues", `plan.max_issues ${cap} reached`); plan.delete(n); }
197
+ w.issues = keep; w.units = [...new Set(keep.flatMap((n) => plan.get(n).units))].sort();
198
+ }
199
+ const kept = waves.filter((w) => w.issues.length);
200
+ let t = 0;
201
+ kept.forEach((w) => { w.id = w.lane === "train" ? `train-${++t}` : "release"; });
202
+ return {
203
+ schema: PLAN_SCHEMA, plan_hash: sha(stableJson(hashed)), policy_sha: policySha ?? null, live_sha: liveSha ?? null, snapshot,
204
+ waves: kept, issues: Object.fromEntries([...plan].sort((a, b) => a[0] - b[0]).map(([n, e]) => [n, e])),
205
+ excluded: [...excluded.values()].sort((a, b) => a.number - b.number), lane_forces: forces,
206
+ };
207
+ }
208
+
209
+ /** The approval state of `plan` from typed decision comments (`{author, body}`): only an actor in `trust.actors` counts (none trusted = nobody). */
210
+ export function approvalOf(plan, decisions, policy) {
211
+ const trusted = policy?.trust?.actors ?? [], ignored = [];
212
+ let stale = false, by = null;
213
+ for (const d of decisions ?? []) {
214
+ const m = DECISION_RE.exec(String(d?.body ?? ""));
215
+ if (!m) continue;
216
+ if (!trusted.includes(d.author)) { ignored.push(d.author ?? "unknown"); continue; }
217
+ if (m[1].toLowerCase() === plan.plan_hash) by = d.author; else stale = true;
218
+ }
219
+ return { state: by ? "approved" : stale ? "stale" : "none", by, ignored };
220
+ }
221
+
222
+ /** Minutes forecast per wave from the trailing median of the lane's history, and the `budget.on_exceed` action. Not part of the hash. */
223
+ export function forecastPlan(plan, history, { remaining = null, cfg = parseBudgetConfig(null) } = {}) {
224
+ const per = plan.waves.map((w) => ({ wave: w.id, minutes: trailingMedian(history ?? [], w.lane) }));
225
+ const known = per.filter((p) => p.minutes != null);
226
+ const forecast = known.length ? known.reduce((s, p) => s + p.minutes, 0) : null;
227
+ return { per_wave: per, forecast, remaining, ...applyOnExceed({ lane: "release", forecast, remaining, cfg }) };
228
+ }
229
+
230
+ export function renderReleasePlan(plan, { approval, forecast, lane = "auto" } = {}) {
231
+ const out = [`release plan ${plan.plan_hash.slice(0, 12)} policy ${String(plan.policy_sha ?? "none").slice(0, 7)} live ${String(plan.live_sha ?? "unknown").slice(0, 7)}`];
232
+ for (const w of plan.waves.filter((x) => lane === "auto" || x.lane === lane)) {
233
+ out.push(`wave ${w.id} (${w.issues.length} issue(s); units ${w.units.join(",") || "none"})`);
234
+ for (const n of w.issues) { const e = plan.issues[n]; out.push(` #${n} ${e.lane} risk=${e.risk} ${e.reason}`); }
235
+ }
236
+ for (const x of plan.excluded.filter((e) => lane === "auto" || (lane === "p0" && e.key === "p0"))) out.push(`${x.key === "p0" ? "call p0" : "excluded"}: #${x.number} [${x.key}] ${x.detail}`);
237
+ if (forecast) out.push(`forecast: ${forecast.forecast ?? "unknown"} min (${forecast.action}: ${forecast.why})`);
238
+ if (approval) out.push(`approval: ${approval.state}${approval.by ? ` by ${approval.by}` : ""}${approval.ignored.length ? ` (ignored untrusted: ${approval.ignored.join(", ")})` : ""}`);
239
+ return out;
240
+ }
241
+
242
+ const flagOf = (argv, f) => { const i = argv.indexOf(f); return i >= 0 ? argv[i + 1] : null; };
243
+
244
+ /**
245
+ * `forgedock release plan [--lane auto|train|release|p0] [--milestone <slug>] [--issues N,N] [--repo R] [--json]`. Read-only (gh issue list, the live-release command);
246
+ * only with `managed` the plan record is committed to a `forge-ledger/<id>` branch through the ledger writer. @returns the exit code.
247
+ */
248
+ export async function planFromCli(argv, { io, policy, policySha, managed = false, newId, history = [], budget = {}, readLanes, ledger }) {
249
+ const lane = flagOf(argv, "--lane") ?? "auto";
250
+ if (!["auto", "train", "release", "p0"].includes(lane)) throw new Error(`release plan: --lane must be auto|train|release|p0`);
251
+ if (!policy || !policySha) { io.print("release plan: refused: no valid .forge/release.yaml on the default branch (run release check-config)"); return 1; }
252
+ const repo = flagOf(argv, "--repo") ?? JSON.parse(String(await io.gh(["repo", "view", "--json", "nameWithOwner"]))).nameWithOwner;
253
+ const ms = flagOf(argv, "--milestone"), only = flagOf(argv, "--issues");
254
+ const list = JSON.parse(String(await io.gh(["issue", "list", "--repo", repo, "--state", "open", "--limit", "500", ...(ms ? ["--milestone", ms] : []), "--json", "number,title,body,labels,createdAt,updatedAt,comments"])) || "[]");
255
+ const picked = only ? new Set(only.split(",").map((s) => +s.replace("#", "")).filter(Boolean)) : null;
256
+ const decisions = list.filter((i) => names(i).includes(PLAN_LABEL)).flatMap((i) => (i.comments ?? []).map((c) => ({ author: c.author?.login ?? c.user?.login, body: c.body })));
257
+ const { readTarget } = await import("./release-deploy.mjs");
258
+ const liveSha = (await readTarget(io, policy.deploy?.live_release_command))?.sha ?? null;
259
+ const lanes = (readLanes ? await readLanes() : null) ?? {};
260
+ const plan = buildPlan({ issues: picked ? list.filter((i) => picked.has(i.number) || names(i).includes(PLAN_LABEL)) : list, policy, policySha, liveSha, lanes, now: io.now?.() ?? 0 });
261
+ const approval = approvalOf(plan, decisions, policy);
262
+ const fc = forecastPlan(plan, history, { remaining: budget.remaining ?? null, cfg: budget.cfg });
263
+ if (argv.includes("--json")) io.print(stableJson({ ...plan, approval, forecast: fc }));
264
+ else renderReleasePlan(plan, { approval, forecast: fc, lane }).forEach((l) => io.print(l));
265
+ if (managed && ledger && newId) await ledger({ id: newId, repo, plan, approval });
266
+ return 0;
267
+ }
@@ -0,0 +1,202 @@
1
+ // SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
2
+ // SPDX-License-Identifier: AGPL-3.0-or-later
3
+ import { describe, it } from "node:test";
4
+ import assert from "node:assert/strict";
5
+ import { buildPlan, rollSet, approvalOf, honouredLanes, forecastPlan, planFromCli, stableJson, EXCLUSION_KEYS } from "./release-plan.mjs";
6
+ import { deriveFacts } from "./release-classify.mjs";
7
+ import { resolvePath } from "./release-unitmap.mjs";
8
+
9
+ const POLICY = {
10
+ schema: 1,
11
+ trust: { actors: ["owner"] },
12
+ units: {
13
+ api: { paths: ["services/api/**"] }, worker: { paths: ["services/worker/**"] }, cron: { paths: ["services/cron/**"] },
14
+ web: { paths: ["web/**"], hosts: ["h1", "h2"] }, edge: { paths: ["edge/**"], hosts: ["h1", "h2"], single_host_ok: true },
15
+ legacy: { paths: ["legacy/**"], service_pipeline: false },
16
+ },
17
+ couplings: [{ paths: ["shared/**"], affects: ["api", "worker", "cron", "web"] }],
18
+ contracts: [{ producer: "api", consumers: ["web"], paths: ["contracts/strict/**"] }, { producer: "worker", consumers: ["cron"], paths: ["contracts/add/**"], additive_only: true }],
19
+ forces: [{ paths: ["infra/**"], pipeline: "full", reason: "infra" }],
20
+ classify: { min_confidence: 0.6 },
21
+ plan: { max_issues: 60 },
22
+ lanes: { train: { train_max_units: 3, train_max_issues: 15, units_max: 3 } },
23
+ };
24
+ const POLICY_SHA = "p".repeat(64), LIVE = "a".repeat(40);
25
+
26
+ const rec = (o) => ({ type: "bug", severity: "P2", exists_in: "live", confidence: 0.9, files: [], ...o });
27
+ let created = 0;
28
+ const mk = (n, o = {}) => ({
29
+ number: n, title: `t${n}`, body: o.body ?? "", labels: (o.labels ?? []).map((name) => ({ name })), createdAt: `2026-01-${String(1 + (created++ % 28)).padStart(2, "0")}T00:00:00Z`, updatedAt: `2026-02-01T00:00:${String(n % 60).padStart(2, "0")}Z`,
30
+ comments: o.rec === null ? [] : [{ author: { login: "bot" }, body: `<!-- FORGE:CLASSIFY -->\n\`\`\`json\n${JSON.stringify(rec(o.rec ?? {}))}\n\`\`\`` }],
31
+ });
32
+ const train = (n, file, extra = {}) => mk(n, { rec: { files: [file], ...extra } });
33
+
34
+ function fixture() {
35
+ created = 0;
36
+ const f = [
37
+ mk(1, { labels: ["epic"] }), mk(2, { labels: ["needs-human"] }), mk(3, { labels: ["parked:q3"] }), mk(4, { labels: ["hold"] }),
38
+ mk(5, { labels: ["design:needed"] }), mk(6, { rec: { ready: false } }), mk(7, { rec: null }), mk(8, { rec: { confidence: 0.1 } }),
39
+ mk(9, { body: "Depends on #2", rec: { files: ["services/api/a.py"] } }),
40
+ mk(10, { body: "Depends on #11", rec: { files: ["services/api/a.py"] } }), mk(11, { body: "Depends on #10", rec: { files: ["services/api/b.py"] } }),
41
+ mk(12, { rec: { severity: "P0", files: ["services/api/a.py"] } }),
42
+ train(13, "services/api/ok.py"), train(14, "services/api/st.py", { exists_in: "staging-only" }),
43
+ train(15, "infra/migrations/001.sql"), train(16, "contracts/strict/x.proto"), train(17, "shared/util.py"), train(18, "shared/billing.py"),
44
+ mk(19, { rec: { type: "feature", files: ["services/api/feat.py"] } }), mk(20, { rec: { type: "infra", files: ["infra/ci.yml"] } }),
45
+ mk(21, { rec: { type: "chore", files: ["services/worker/c.py"] } }), mk(22, { rec: { type: "docs", files: ["docs/readme.md"] } }),
46
+ mk(23, { body: "Depends on #19", rec: { files: ["services/worker/b.py"] } }),
47
+ mk(24, { rec: { type: "bug", files: ["services/cron/x.py"] } }), mk(25, { rec: { type: "bug", files: ["web/x.ts"] } }),
48
+ mk(26, { body: "depends on #1", rec: { files: ["services/api/z.py"] } }),
49
+ mk(27, { labels: ["design:needed", "design:approved"], rec: { files: ["services/api/d.py"] } }),
50
+ mk(28, { rec: { files: ["contracts/add/x.proto"] } }),
51
+ ];
52
+ for (let n = 29; n <= 46; n++) f.push(train(n, `services/${["api", "worker"][n % 2]}/f${n}.py`));
53
+ f.push({ ...mk(47, {}), pullRequest: true }, mk(48, { labels: ["release-plan"] }));
54
+ return f;
55
+ }
56
+ const run = (over = {}) => buildPlan({ issues: fixture(), policy: POLICY, policySha: POLICY_SHA, liveSha: LIVE, now: Date.parse("2026-03-01T00:00:00Z"), ...over });
57
+ const excl = (p) => Object.fromEntries(p.excluded.map((e) => [e.number, e.key]));
58
+
59
+ describe("buildPlan (#5559)", () => {
60
+ it("plans or excludes every candidate with a key, never a PR or the tracking issue", () => {
61
+ const p = run(), ex = excl(p), planned = Object.keys(p.issues).map(Number);
62
+ const cands = fixture().filter((i) => !i.pullRequest && !i.labels.some((l) => l.name === "release-plan")).map((i) => i.number);
63
+ assert.ok(cands.length >= 40);
64
+ assert.deepEqual([...planned, ...Object.keys(ex).map(Number)].sort((a, b) => a - b), cands);
65
+ for (const k of Object.values(ex)) assert.ok(EXCLUSION_KEYS.includes(k), k);
66
+ assert.deepEqual({ 1: ex[1], 2: ex[2], 3: ex[3], 4: ex[4], 5: ex[5], 6: ex[6], 7: ex[7], 8: ex[8], 9: ex[9], 10: ex[10], 11: ex[11], 12: ex[12], 26: ex[26] },
67
+ { 1: "epic", 2: "plan.skip_labels", 3: "plan.skip_labels", 4: "plan.skip_labels", 5: "design_gate", 6: "ready_no", 7: "unclassified", 8: "unclassified", 9: "dependency_open", 10: "dependency_cycle", 11: "dependency_cycle", 12: "p0", 26: "dependency_open" });
68
+ assert.equal(ex[47], undefined); assert.equal(ex[48], undefined);
69
+ });
70
+ it("assigns lanes: first match wins and the reason is recorded", () => {
71
+ const { issues: l } = run();
72
+ assert.equal(l[13].lane, "train");
73
+ for (const n of [14, 15, 16, 17, 18]) assert.equal(l[n].lane, "release", `#${n}`);
74
+ assert.match(l[14].reason, /staging-only/); assert.match(l[15].reason, /migrations/); assert.match(l[16].reason, /contract/); assert.match(l[17].reason, /units_max/); assert.match(l[18].reason, /risk high/);
75
+ for (const n of [19, 20, 21]) assert.equal(l[n].lane, "release");
76
+ assert.equal(l[22].docs_only, true); assert.deepEqual(l[22].units, []);
77
+ assert.equal(l[23].lane, "release"); assert.match(l[23].reason, /#19/); // a bug depending on a feature moves to the release wave
78
+ assert.equal(l[19].lane, "release"); // a feature never moves earlier
79
+ assert.equal(l[27].lane, "train"); assert.equal(l[28].lane, "release"); assert.deepEqual(l[28].atomic.order, ["worker", "cron"]);
80
+ });
81
+ it("orders trains before the release wave, dependencies first, and overflows train waves", () => {
82
+ const p = run(), ids = p.waves.map((w) => w.id);
83
+ assert.equal(ids.at(-1), "release");
84
+ assert.ok(ids.filter((i) => i.startsWith("train-")).length >= 2);
85
+ assert.ok(p.waves.filter((w) => w.lane === "train").every((w) => w.issues.length <= 15 && w.units.length <= 3));
86
+ const pos = (n) => p.waves.findIndex((w) => w.issues.includes(n));
87
+ assert.ok(pos(19) <= pos(23));
88
+ const rel = p.waves.at(-1).issues; assert.ok(rel.indexOf(19) < rel.indexOf(23));
89
+ });
90
+ it("is byte-identical for the same inputs and unaffected by input order", () => {
91
+ const a = stableJson(run()), shuffled = fixture().reverse();
92
+ assert.equal(stableJson(run({ issues: shuffled })), a);
93
+ assert.equal(stableJson(run()), a);
94
+ });
95
+ it("any change to the snapshot, policy sha or live sha yields a new hash", () => {
96
+ const base = run().plan_hash, f = fixture();
97
+ assert.notEqual(run({ policySha: "q".repeat(64) }).plan_hash, base);
98
+ assert.notEqual(run({ liveSha: "b".repeat(40) }).plan_hash, base);
99
+ assert.notEqual(run({ issues: f.map((i) => (i.number === 13 ? { ...i, body: "edited" } : i)) }).plan_hash, base);
100
+ assert.notEqual(run({ issues: f.map((i) => (i.number === 13 ? { ...i, updatedAt: "2027-01-01T00:00:00Z" } : i)) }).plan_hash, base);
101
+ });
102
+ it("caps the plan at plan.max_issues in wave order and keeps dependents behind their dependencies", () => {
103
+ const p = run({ policy: { ...POLICY, plan: { max_issues: 10 } } });
104
+ assert.equal(Object.keys(p.issues).length, 10);
105
+ assert.ok(p.excluded.some((e) => e.key === "max_issues"));
106
+ });
107
+ it("runs the injectable investigation seam before declaring an issue unclassified", () => {
108
+ const p = run({ investigate: (i) => (i.number === 7 ? { type: "bug", exists_in: "live", confidence: 0.9, files: ["services/api/q.py"], severity: "P2" } : null) });
109
+ assert.ok(p.issues[7]); assert.equal(excl(p)[8], "unclassified");
110
+ });
111
+ it("honours an unexpired trusted lane --force and ignores expired or untrusted ones", () => {
112
+ const now = Date.parse("2026-03-01T00:00:00Z"), at = new Date(now - 3_600_000).toISOString();
113
+ const lanes = { 13: { force: "release", actor: "owner", at }, 14: { force: "train", actor: "owner", at: new Date(now - 90_000_000).toISOString() }, 24: { force: "exclude", actor: "owner", at }, 25: { force: "release", actor: "mallory", at } };
114
+ assert.deepEqual(Object.keys(honouredLanes(lanes, POLICY, now)), ["13", "24"]);
115
+ const p = run({ lanes, now });
116
+ assert.equal(p.issues[13].lane, "release"); assert.equal(p.issues[13].forced, true);
117
+ assert.equal(p.issues[14].lane, "release"); assert.equal(excl(p)[24], "lane_force_exclude"); assert.equal(p.issues[25].lane, "train");
118
+ assert.notEqual(p.plan_hash, run({ now }).plan_hash);
119
+ });
120
+ });
121
+
122
+ describe("rollSet (#5559)", () => {
123
+ it("shared paths roll the full coupling set; contracts are atomic, producer first", () => {
124
+ assert.deepEqual(rollSet(POLICY, ["shared/x.py"]).units, ["api", "cron", "web", "worker"]);
125
+ const c = rollSet(POLICY, ["contracts/strict/a.proto"]);
126
+ assert.deepEqual(c.contract.order, ["api", "web"]); assert.equal(c.contract.atomic, true); assert.equal(c.contract.release_only, true);
127
+ const add = rollSet(POLICY, ["contracts/add/a.proto"]);
128
+ assert.equal(add.contract.release_only, false); assert.equal(add.contract.order[0], "worker");
129
+ });
130
+ it("forces, service_pipeline: false and two-host units", () => {
131
+ assert.equal(rollSet(POLICY, ["infra/x.yml"]).pipeline, "full");
132
+ assert.equal(rollSet(POLICY, ["legacy/x.py"]).pipeline, "full");
133
+ assert.equal(rollSet(POLICY, ["services/api/x.py"]).pipeline, "service");
134
+ assert.equal(rollSet(POLICY, ["docs/x.md"]).pipeline, "none");
135
+ assert.deepEqual(rollSet(POLICY, ["web/a.ts"]).hosts, { web: ["h1", "h2"] });
136
+ assert.deepEqual(rollSet(POLICY, ["edge/a.ts"]).hosts, { edge: ["h1"] });
137
+ });
138
+ it("property: the rolled set is a superset of every unit the files affect (I4, planning side)", () => {
139
+ const corpus = ["services/api/a.py", "services/worker/b.py", "services/cron/c.py", "web/x.ts", "edge/e.ts", "legacy/l.py", "shared/s.py", "shared/billing.py", "contracts/strict/a", "contracts/add/b", "infra/migrations/1.sql", "infra/ci.yml", "docs/a.md", "README.md"];
140
+ for (let mask = 1; mask < 1 << 8; mask++) for (let shift = 0; shift < corpus.length; shift++) {
141
+ const files = corpus.filter((_, i) => mask & (1 << ((i + shift) % 8)) && (i + shift) % 2 === 0 || mask & (1 << ((i + shift) % 8)) && i % 3 === 0);
142
+ const rolled = new Set(rollSet(POLICY, files).units);
143
+ for (const u of deriveFacts(POLICY, files).units) assert.ok(rolled.has(u), `${u} from ${files}`);
144
+ for (const f of files) { const r = resolvePath(POLICY, f); for (const u of [...r.units, ...r.affects, ...r.contracts.flatMap((c) => [c.producer, ...c.consumers])]) assert.ok(rolled.has(u), `${u} from ${f}`); }
145
+ }
146
+ });
147
+ });
148
+
149
+ describe("approval (#5559, I2)", () => {
150
+ const dec = (plan, author) => ({ author, body: `<!-- FORGE:DECISION plan ${plan.plan_hash} -->` });
151
+ it("binds to the hash for a trusted actor and goes stale on any edit", () => {
152
+ const p = run(), d = [dec(p, "owner")];
153
+ assert.deepEqual(approvalOf(p, d, POLICY), { state: "approved", by: "owner", ignored: [] });
154
+ assert.equal(approvalOf(run({ policySha: "q".repeat(64) }), d, POLICY).state, "stale");
155
+ assert.equal(approvalOf(run({ liveSha: "c".repeat(40) }), d, POLICY).state, "stale");
156
+ assert.equal(approvalOf(run({ issues: fixture().map((i) => (i.number === 13 ? { ...i, body: "edited" } : i)) }), d, POLICY).state, "stale");
157
+ assert.equal(approvalOf(run({ policy: POLICY }), d, POLICY).state, "approved");
158
+ });
159
+ it("ignores a decision from a non-trusted actor", () => {
160
+ const p = run(), a = approvalOf(p, [dec(p, "mallory")], POLICY);
161
+ assert.equal(a.state, "none"); assert.deepEqual(a.ignored, ["mallory"]);
162
+ assert.equal(approvalOf(p, [dec(p, "owner")], { ...POLICY, trust: {} }).state, "none");
163
+ });
164
+ });
165
+
166
+ describe("forecast and planFromCli (#5559)", () => {
167
+ const io = (w = {}) => {
168
+ const calls = [];
169
+ return { calls, now: () => Date.parse("2026-03-01T00:00:00Z"), print: (l) => calls.push(["print", l]), gh: async (a) => { calls.push(["gh", a]); return a[0] === "issue" ? JSON.stringify(w.issues ?? fixture()) : JSON.stringify({ nameWithOwner: "o/r" }); },
170
+ api: async (...a) => { calls.push(["api", a]); return { tree: { sha: "t" }, sha: "c" }; }, rehearse: async () => ({ ok: true, output: LIVE }) };
171
+ };
172
+ const pol = { ...POLICY, deploy: { live_release_command: "echo live" } };
173
+ it("forecasts minutes per wave and applies on_exceed", () => {
174
+ const p = run(), f = forecastPlan(p, [{ lane: "train", minutes: 10 }, { lane: "release", minutes: 40 }], { remaining: 30, cfg: { onExceed: "hold" } });
175
+ assert.equal(f.forecast, 10 * p.waves.filter((w) => w.lane === "train").length + 40); assert.equal(f.action, "hold");
176
+ assert.equal(forecastPlan(p, [], {}).forecast, null);
177
+ });
178
+ it("makes zero GitHub writes with managed off and prints the plan", async () => {
179
+ const i = io();
180
+ assert.equal(await planFromCli(["--repo", "o/r"], { io: i, policy: pol, policySha: POLICY_SHA }), 0);
181
+ assert.equal(i.calls.filter((c) => c[0] === "api").length, 0);
182
+ assert.ok(i.calls.filter((c) => c[0] === "gh").every((c) => c[1][0] === "issue" || c[1][0] === "repo"));
183
+ assert.match(i.calls.find((c) => c[0] === "print")[1], /^release plan [0-9a-f]{12}/);
184
+ assert.ok(i.calls.some((c) => c[0] === "print" && /call p0: #12/.test(c[1])));
185
+ });
186
+ it("persists through the ledger writer only when managed", async () => {
187
+ const seen = [], ledger = async (r) => { seen.push(r.id); };
188
+ await planFromCli(["--repo", "o/r", "--json"], { io: io(), policy: pol, policySha: POLICY_SHA, managed: true, newId: "r20260301-000000-1", ledger });
189
+ assert.deepEqual(seen, ["r20260301-000000-1"]);
190
+ await planFromCli(["--repo", "o/r", "--json"], { io: io(), policy: pol, policySha: POLICY_SHA, managed: false, newId: "r20260301-000000-2", ledger });
191
+ assert.equal(seen.length, 1);
192
+ });
193
+ it("--issues narrows the candidates, --json is stable, a missing policy refuses", async () => {
194
+ const i = io();
195
+ await planFromCli(["--repo", "o/r", "--issues", "13,14", "--json"], { io: i, policy: pol, policySha: POLICY_SHA });
196
+ const out = JSON.parse(i.calls.find((c) => c[0] === "print")[1]);
197
+ assert.deepEqual(Object.keys(out.issues), ["13", "14"]); assert.equal(out.approval.state, "none"); assert.equal(out.live_sha, LIVE);
198
+ const j = io();
199
+ assert.equal(await planFromCli(["--repo", "o/r"], { io: j, policy: null, policySha: null }), 1);
200
+ await assert.rejects(planFromCli(["--lane", "bogus", "--repo", "o/r"], { io: j, policy: pol, policySha: POLICY_SHA }), /--lane/);
201
+ });
202
+ });
@@ -35,6 +35,22 @@ export async function runHostPreflight(ctx, { head, pr }) {
35
35
  return kept;
36
36
  }
37
37
 
38
+ const shq = (f) => `'${String(f).replace(/'/g, `'\\''`)}'`;
39
+
40
+ /**
41
+ * Targeted preflight (#5566): runs `preflight.command` with `{files}` replaced by the quoted target set. A command without `{files}`
42
+ * is not targeted, so it covers nothing: the caller counts that as unvalidated. Files no blocker issue (the caller decides).
43
+ * @returns {Promise<{ok, head, command, covered: string[], code}>}
44
+ */
45
+ export async function runTargetedPreflight(ctx, { head, target }) {
46
+ const cfg = ctx.config?.preflight;
47
+ if (!cfg) return { ok: false, head, covered: [], why: "no release.preflight_command configured" };
48
+ const targeted = cfg.command.includes("{files}");
49
+ const command = cfg.command.split("{files}").join(target.map(shq).join(" "));
50
+ const run = await ctx.io.rehearse(command, { timeout: cfg.timeoutMs });
51
+ return { ok: !!run.ok, head, command, covered: run.ok && targeted ? [...target] : [], code: run.code ?? null };
52
+ }
53
+
38
54
  const stopOf = (r) => ({ stopped: true, why: `release preflight failed at ${r.head} (release-blocker #${r.issue}); fix it, then resume`, ...r });
39
55
 
40
56
  /** Step before `release-pr`: preflight on the staging head, so no release PR is opened on a failing head. */