forgedock 1.57.0 → 1.59.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/outcome-codes.mjs +1 -1
- package/bin/engine-cli.mjs +2 -2
- package/bin/help-text.mjs +1 -1
- package/bin/lean/conformance.mjs +37 -5
- package/bin/lean/conformance.test.mjs +93 -0
- package/bin/lean/decisions.mjs +12 -0
- package/bin/lean/decisions.test.mjs +9 -0
- package/bin/lean/issuewatch-parity.mjs +4 -1
- package/bin/lean/issuewatch-parity.test.mjs +6 -0
- package/bin/lean/lean.mjs +44 -8
- package/bin/lean/lean.test.mjs +37 -4
- package/bin/lean/prompts.mjs +1 -1
- package/bin/lean/recovery.test.mjs +3 -3
- package/bin/lean/release-config.mjs +19 -8
- package/bin/lean/release-config.test.mjs +31 -0
- package/bin/lean/release-control.mjs +26 -3
- package/bin/lean/release-control.test.mjs +24 -0
- package/bin/lean/release-deploy.mjs +209 -0
- package/bin/lean/release-deploy.test.mjs +217 -0
- package/bin/lean/release-fixloop.mjs +108 -0
- package/bin/lean/release-fixloop.test.mjs +80 -0
- package/bin/lean/release-gates.mjs +230 -0
- package/bin/lean/release-gates.test.mjs +146 -0
- package/bin/lean/release-ledger.mjs +16 -0
- package/bin/lean/release-ledger.test.mjs +3 -3
- package/bin/lean/release-minutes.mjs +12 -2
- package/bin/lean/release-minutes.test.mjs +8 -0
- package/bin/lean/release-preflight.mjs +22 -0
- package/bin/lean/release-preflight.test.mjs +18 -2
- package/bin/lean/release-review.e2e.test.mjs +3 -2
- package/bin/lean/release-review.mjs +114 -31
- package/bin/lean/release-review.test.mjs +107 -20
- package/bin/lean/release-snapshot.mjs +32 -1
- package/bin/lean/release-snapshot.test.mjs +18 -1
- package/bin/lean/release-status.mjs +300 -0
- package/bin/lean/release-status.test.mjs +220 -0
- package/bin/lean/release-verify.mjs +221 -0
- package/bin/lean/release-verify.test.mjs +176 -0
- package/bin/lean/release.mjs +77 -7
- package/bin/lean/release.test.mjs +5 -1
- package/docs/CONFIG.md +20 -1
- package/package.json +1 -1
- package/scripts/ci-local/scoping.mjs +19 -0
- package/scripts/ci-local.test.sh +13 -0
|
@@ -0,0 +1,176 @@
|
|
|
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 { readFileSync } from "node:fs";
|
|
6
|
+
import { verifyStep, closeIssues, hasVerified, verifiedMarker, soakMinutes, sliBreaches, verifyConfigured, verifyReleaseById, SOAK_MIN } from "./release-verify.mjs";
|
|
7
|
+
import { validatePolicy } from "./release-config.mjs";
|
|
8
|
+
|
|
9
|
+
const SHA = "a".repeat(40);
|
|
10
|
+
const TABLE = { smoke1: { run: "check smoke1", timeout: 5 }, win1: { run: "check win1", for: "7d" } };
|
|
11
|
+
|
|
12
|
+
/** World: `runs` by workflow, `issues` by number {state, body, comments[]}; records every gh call and rehearsed command. */
|
|
13
|
+
function world(o = {}) {
|
|
14
|
+
const w = { runs: {}, issues: { 7: { state: "OPEN", body: "does X [check:smoke1]", comments: [] } }, gh: [], ran: [], logs: {}, rollups: [{ number: 99 }], metrics: undefined, table: TABLE, checkOk: true, ...o };
|
|
15
|
+
const io = {
|
|
16
|
+
print: () => {}, sleep: async () => {}, now: () => 1_000,
|
|
17
|
+
git: (a) => { if (w.table == null) throw new Error("no such file"); return JSON.stringify(w.table); },
|
|
18
|
+
rehearse: async (cmd) => { w.ran.push(cmd); return { ok: w.checkOk, output: "boom" }; },
|
|
19
|
+
gh: async (a) => {
|
|
20
|
+
w.gh.push(a.join(" "));
|
|
21
|
+
if (a[0] === "run" && a[1] === "list") { if (w.unreadable) throw new Error("HTTP 502"); const r = w.runs[a[a.indexOf("--workflow") + 1]]; return JSON.stringify(r ? [r] : []); }
|
|
22
|
+
if (a[0] === "run" && a[1] === "view") return w.logs[a[2]] ?? "";
|
|
23
|
+
if (a[0] === "workflow") { const wf = a[2]; w.runs[wf] ??= w.dispatchRun ?? { databaseId: 50, status: "completed", conclusion: "success" }; return ""; }
|
|
24
|
+
if (a[0] === "issue" && a[1] === "view") { const i = w.issues[a[2]]; if (!i) throw new Error("not found"); return JSON.stringify(i); }
|
|
25
|
+
if (a[0] === "issue" && a[1] === "list") return JSON.stringify(w.rollups);
|
|
26
|
+
if (a[0] === "issue" && a[1] === "comment") { const i = w.issues[a[2]]; if (i) i.comments.push({ body: a[a.indexOf("--body") + 1] }); return ""; }
|
|
27
|
+
if (a[0] === "issue" && (a[1] === "close" || a[1] === "create")) { if (a[1] === "close") w.issues[a[2]].state = "CLOSED"; return ""; }
|
|
28
|
+
throw new Error(`unexpected gh ${a.join(" ")}`);
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
if (w.metrics) io.metrics = w.metrics;
|
|
32
|
+
return { w, io };
|
|
33
|
+
}
|
|
34
|
+
const ok = { databaseId: 5, status: "completed", conclusion: "success" };
|
|
35
|
+
const mk = (io, verify, over = {}) => ({ io, repo: "o/r", def: "main", config: { verify, verifyRisk: "full", deployBounds: { pollMs: 1, runPollMs: 1 } }, state: { id: "r1", repo: "o/r", release: { issues: [7] }, deploy: { merge: SHA, phase: "VERIFYING" } }, save() {}, ...over });
|
|
36
|
+
|
|
37
|
+
describe("release verify (#5562)", () => {
|
|
38
|
+
it("defaults: soak minutes by risk class, overridable; verifyConfigured is off for an empty block", () => {
|
|
39
|
+
assert.deepEqual(SOAK_MIN, { low: 10, medium: 20, full: 30, p0: 15 });
|
|
40
|
+
assert.equal(soakMinutes("p0"), 15); assert.equal(soakMinutes("full", 45), 45); assert.equal(soakMinutes("low", { low: 3 }), 3);
|
|
41
|
+
assert.equal(verifyConfigured({}), false); assert.equal(verifyConfigured({ slis: [] }), false); assert.equal(verifyConfigured({ close_requires: "verified" }), true);
|
|
42
|
+
});
|
|
43
|
+
it("the policy schema accepts the verify layer keys", () => {
|
|
44
|
+
const r = validatePolicy({ schema: 1, verify: { workflow: "v.yml", results: [{ workflow: "smoke.yml", kind: "smoke" }], flags: [{ flag: "F", off_command: "x" }], slis: [], close_requires: "verified" } });
|
|
45
|
+
assert.ok(!JSON.stringify(r).includes("verify."), JSON.stringify(r));
|
|
46
|
+
});
|
|
47
|
+
it("layer 1: green results pass; an unreadable source blocks (I5); a missing run blocks", async () => {
|
|
48
|
+
const v = { results: [{ workflow: "smoke.yml", kind: "smoke" }], close_requires: "deployed" };
|
|
49
|
+
let { w, io } = world({ runs: { "smoke.yml": ok } });
|
|
50
|
+
assert.equal((await verifyStep(mk(io, v), SHA)).verified, true);
|
|
51
|
+
({ w, io } = world({ unreadable: true }));
|
|
52
|
+
assert.match((await verifyStep(mk(io, v), SHA)).reason, /cannot read smoke.yml results \(I5\)/);
|
|
53
|
+
({ io } = world({ runs: {} }));
|
|
54
|
+
assert.match((await verifyStep(mk(io, v), SHA)).reason, /no completed run/);
|
|
55
|
+
});
|
|
56
|
+
it("layer 1: a real smoke failure emits the rollback trigger once", async () => {
|
|
57
|
+
const v = { results: [{ workflow: "smoke.yml", kind: "smoke" }] };
|
|
58
|
+
const { io } = world({ runs: { "smoke.yml": { databaseId: 5, status: "completed", conclusion: "failure" } }, logs: { 5: "assertion failed: /health returned wrong body" } });
|
|
59
|
+
const trig = []; const c = mk(io, v, { rollbackTrigger: (t) => trig.push(t) });
|
|
60
|
+
const r = await verifyStep(c, SHA); const r2 = await verifyStep(c, SHA);
|
|
61
|
+
assert.ok(r.rollback); assert.ok(r2.rollback); assert.equal(trig.length, 1);
|
|
62
|
+
});
|
|
63
|
+
it("smoke identity/transport failure: one re-verify, then hold, never a rollback", async () => {
|
|
64
|
+
const v = { results: [{ workflow: "smoke.yml", kind: "smoke" }] };
|
|
65
|
+
const { w, io } = world({ runs: { "smoke.yml": { databaseId: 5, status: "completed", conclusion: "failure" } }, logs: { 5: "HTTP 401 unauthorized" } });
|
|
66
|
+
const c = mk(io, v), trig = []; c.rollbackTrigger = (t) => trig.push(t);
|
|
67
|
+
const r = await verifyStep(c, SHA);
|
|
68
|
+
assert.equal(r.hold?.label, "needs-agent"); assert.equal(c.state.verify.reverifies, 1); assert.equal(trig.length, 0); assert.equal(r.rollback, undefined);
|
|
69
|
+
assert.equal(w.gh.filter((g) => g.startsWith("run list")).length, 2, "exactly one re-verify read");
|
|
70
|
+
});
|
|
71
|
+
it("a convergence failure with smoke green is released-with-convergence-failures: repair issue, no rollback", async () => {
|
|
72
|
+
const v = { results: [{ workflow: "smoke.yml", kind: "smoke" }, { workflow: "conv.yml", kind: "convergence" }], close_requires: "deployed" };
|
|
73
|
+
const { w, io } = world({ runs: { "smoke.yml": ok, "conv.yml": { databaseId: 6, status: "completed", conclusion: "failure" } } });
|
|
74
|
+
const r = await verifyStep(mk(io, v), SHA);
|
|
75
|
+
assert.equal(r.outcome, "released-with-convergence-failures");
|
|
76
|
+
assert.equal(w.gh.filter((g) => g.startsWith("issue create")).length, 1);
|
|
77
|
+
});
|
|
78
|
+
it("layer 2: the verification workflow is dispatched once through fenced() and its failure triggers rollback", async () => {
|
|
79
|
+
const v = { workflow: "verify.yml", close_requires: "deployed" };
|
|
80
|
+
let { w, io } = world();
|
|
81
|
+
const calls = []; const fence = { lctx: { io: { api: async () => ({ content: Buffer.from(JSON.stringify({ epoch: 3, lease: { holder: "h", epoch: 3 } })).toString("base64") }) }, repo: "o/r" }, lease: { holder: "h", epoch: 3, release: "r" }, now: () => "t", record: async (r) => calls.push(r) };
|
|
82
|
+
const c = mk(io, v, { fence });
|
|
83
|
+
assert.equal((await verifyStep(c, SHA)).verified, true);
|
|
84
|
+
assert.equal(w.gh.filter((g) => g.startsWith("workflow run")).length, 1);
|
|
85
|
+
assert.ok(calls.some((i) => i.action === "dispatch" && i.epoch === 3 && /verify:/.test(i.key)));
|
|
86
|
+
({ w, io } = world({ dispatchRun: { databaseId: 50, status: "completed", conclusion: "failure" } }));
|
|
87
|
+
assert.ok((await verifyStep(mk(io, v), SHA)).rollback);
|
|
88
|
+
});
|
|
89
|
+
it("layer 2: a dispatch intent already recorded is never repeated on resume", async () => {
|
|
90
|
+
const { w, io } = world();
|
|
91
|
+
const c = mk(io, { workflow: "verify.yml" }, { state: { id: "r1", release: { issues: [] }, deploy: { merge: SHA }, intents: [{ action: "dispatch", key: `r1:deploy:0:verify:${SHA}` }] } });
|
|
92
|
+
const r = await verifyStep(c, SHA);
|
|
93
|
+
assert.match(r.reason, /already recorded/); assert.equal(w.gh.filter((g) => g.startsWith("workflow run")).length, 0);
|
|
94
|
+
});
|
|
95
|
+
it("layer 3: an SLI breach in a fixture series emits the rollback trigger; within tolerance passes", async () => {
|
|
96
|
+
const slis = [{ name: "5xx", tolerance: 0.1 }, { name: "success", worse: "lower", tolerance: 0.05 }];
|
|
97
|
+
const series = (cur) => async ({ sli }) => ({ baseline: 100, current: cur[sli.name] });
|
|
98
|
+
let { io } = world({ metrics: series({ "5xx": 150, success: 100 }) });
|
|
99
|
+
const trig = []; const c = mk(io, { slis, close_requires: "deployed" }); c.rollbackTrigger = (t) => trig.push(t);
|
|
100
|
+
const r = await verifyStep(c, SHA);
|
|
101
|
+
assert.match(r.reason, /SLI breach over 30 min: 5xx 150/); assert.equal(trig.length, 1);
|
|
102
|
+
({ io } = world({ metrics: series({ "5xx": 105, success: 97 }) }));
|
|
103
|
+
const ok2 = await verifyStep(mk(io, { slis, close_requires: "deployed" }), SHA);
|
|
104
|
+
assert.equal(ok2.verified, true); assert.match(ok2.sli, /pass \(30 min soak, 2 sli\)/);
|
|
105
|
+
assert.deepEqual(sliBreaches([{ name: "a" }], { a: { baseline: 10, current: 13 } }).map((x) => x.sli), ["a"]);
|
|
106
|
+
});
|
|
107
|
+
it("layer 3: no metric source skips and says so; an unreadable metric blocks (I5)", async () => {
|
|
108
|
+
const v = { slis: [{ name: "5xx" }], close_requires: "deployed" };
|
|
109
|
+
let { io } = world();
|
|
110
|
+
const lines = []; io.print = (l) => lines.push(l);
|
|
111
|
+
const r = await verifyStep(mk(io, v), SHA);
|
|
112
|
+
assert.equal(r.sli, "skipped (no host)"); assert.ok(lines.some((l) => l.includes("sli: skipped (no host)")));
|
|
113
|
+
({ io } = world({ metrics: async () => { throw new Error("prometheus down"); } }));
|
|
114
|
+
assert.match((await verifyStep(mk(io, v), SHA)).reason, /cannot read SLI 5xx \(I5\)/);
|
|
115
|
+
});
|
|
116
|
+
it("layer 4: each check runs once, from the default branch; an unreadable registry blocks; windowed checks become follow-ups", async () => {
|
|
117
|
+
const v = { post_deploy_checks_file: ".forge/post-deploy-checks.json", close_requires: "deployed" };
|
|
118
|
+
let { w, io } = world({ issues: { 7: { state: "OPEN", body: "[check:smoke1] [check:win1]", comments: [] }, 8: { state: "OPEN", body: "[check:smoke1]", comments: [] } } });
|
|
119
|
+
const c = mk(io, v); c.state.release.issues = [7, 8];
|
|
120
|
+
assert.equal((await verifyStep(c, SHA)).verified, true);
|
|
121
|
+
assert.deepEqual(w.ran, ["check smoke1"], "smoke1 runs once for two issues; windowed win1 never runs");
|
|
122
|
+
assert.ok(w.gh.some((g) => g.startsWith("issue comment 99") && g.includes("[check:win1]")));
|
|
123
|
+
({ io } = world({ table: null }));
|
|
124
|
+
assert.match((await verifyStep(mk(io, v), SHA)).reason, /cannot read .* from origin\/main \(I13, I5\)/);
|
|
125
|
+
({ io } = world({ checkOk: false }));
|
|
126
|
+
assert.equal((await verifyStep(mk(io, v), SHA)).hold?.kind, "check");
|
|
127
|
+
});
|
|
128
|
+
it("layer 5: a flag-gated feature is verified off and never activated", async () => {
|
|
129
|
+
const { w, io } = world();
|
|
130
|
+
const r = await verifyStep(mk(io, { flags: [{ flag: "NEW_UI", off_command: "flag-state NEW_UI off" }], close_requires: "deployed" }), SHA);
|
|
131
|
+
assert.equal(r.verified, true); assert.deepEqual(w.ran, ["flag-state NEW_UI off"]);
|
|
132
|
+
const bad = world({ checkOk: false });
|
|
133
|
+
assert.equal((await verifyStep(mk(bad.io, { flags: [{ flag: "NEW_UI", off_command: "x" }] }), SHA)).hold?.kind, "flag");
|
|
134
|
+
});
|
|
135
|
+
it("I19: close is refused without FORGE:VERIFIED naming the deploy sha, allowed with it; deployed mode opts out", async () => {
|
|
136
|
+
const { w, io } = world({ issues: { 7: { state: "OPEN", body: "", comments: [{ body: verifiedMarker("b".repeat(40)) }] } } });
|
|
137
|
+
const c = mk(io, {});
|
|
138
|
+
let r = await closeIssues(c, { issues: [7], sha: SHA });
|
|
139
|
+
assert.equal(r.closed.length, 0); assert.match(r.refused[0].why, /no FORGE:VERIFIED/); assert.ok(!w.gh.some((g) => g.startsWith("issue close")));
|
|
140
|
+
w.issues[7].comments.push({ body: verifiedMarker(SHA) });
|
|
141
|
+
r = await closeIssues(c, { issues: [7], sha: SHA }); assert.deepEqual(r.closed, [7]);
|
|
142
|
+
w.issues[7].state = "OPEN"; w.issues[7].comments = [];
|
|
143
|
+
assert.deepEqual((await closeIssues(c, { issues: [7], sha: SHA, mode: "deployed" })).closed, [7]);
|
|
144
|
+
assert.equal(hasVerified([{ body: "<!-- FORGE:VERIFIED fp=abc123 -->" }], SHA), false);
|
|
145
|
+
});
|
|
146
|
+
it("end to end: verified issue gets the marker comment then closes; resume repeats no dispatch, check or comment", async () => {
|
|
147
|
+
const v = { workflow: "verify.yml", post_deploy_checks_file: "f.json" };
|
|
148
|
+
const { w, io } = world();
|
|
149
|
+
const c = mk(io, v);
|
|
150
|
+
const r = await verifyStep(c, SHA);
|
|
151
|
+
assert.equal(r.verified, true); assert.deepEqual(r.closed, [7]);
|
|
152
|
+
assert.ok(hasVerified(w.issues[7].comments, SHA));
|
|
153
|
+
const before = w.gh.filter((g) => /^(workflow run|issue comment)/.test(g)).length, ran = w.ran.length;
|
|
154
|
+
w.issues[7].state = "OPEN"; await verifyStep(c, SHA);
|
|
155
|
+
assert.equal(w.gh.filter((g) => /^(workflow run|issue comment)/.test(g)).length, before); assert.equal(w.ran.length, ran);
|
|
156
|
+
});
|
|
157
|
+
it("verifyReleaseById refuses before LIVE_CHECK and runs the layers after it", async () => {
|
|
158
|
+
const { io } = world();
|
|
159
|
+
assert.match((await verifyReleaseById({ io, state: { id: "r1", deploy: { phase: "DEPLOYING" } }, save() {}, def: "main", policy: {} })).reason, /LIVE_CHECK/);
|
|
160
|
+
const state = { id: "r1", repo: "o/r", release: { issues: [] }, deploy: { phase: "LIVE", merge: SHA } };
|
|
161
|
+
assert.equal((await verifyReleaseById({ io, state, save() {}, def: "main", policy: { verify: { close_requires: "deployed" } }, lane: "p0" })).verified, true);
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
/** I22 scanner: write verbs against production in a module's source. */
|
|
166
|
+
const WRITE_VERBS = [/\bssh\s/, /\bscp\s/, /\bsystemctl\b/, /\bdocker\s+(run|exec|rm|stop|restart|kill|compose|build|push|cp)\b/, /\b(INSERT\s+INTO|UPDATE\s+\w+\s+SET|DELETE\s+FROM|DROP\s+TABLE|ALTER\s+TABLE|TRUNCATE)\b/i, /\bkubectl\s+(apply|delete|scale|rollout)\b/];
|
|
167
|
+
const writeVerbs = (src) => WRITE_VERBS.filter((re) => re.test(src)).map(String);
|
|
168
|
+
|
|
169
|
+
describe("release verify I22: no write path to production", () => {
|
|
170
|
+
it("the module has no write verbs", () => {
|
|
171
|
+
assert.deepEqual(writeVerbs(readFileSync(new URL("./release-verify.mjs", import.meta.url), "utf8")), []);
|
|
172
|
+
});
|
|
173
|
+
it("the scan fails on a seeded violation", () => {
|
|
174
|
+
for (const bad of ["await sh('ssh prod systemctl restart api')", "run(`docker exec app sh`)", "q('DELETE FROM users')"]) assert.ok(writeVerbs(bad).length, bad);
|
|
175
|
+
});
|
|
176
|
+
});
|
package/bin/lean/release.mjs
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* live in release-review.mjs / release-postmerge.mjs (stubs that block until their parts land). Promotion is opt-in: without
|
|
9
9
|
* `--merge` or forge.yaml `release.auto_merge: true` the job stops at GATE_PASS and prints the merge command.
|
|
10
10
|
*/
|
|
11
|
-
import { existsSync, mkdirSync, readFileSync } from "node:fs";
|
|
11
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync } from "node:fs";
|
|
12
12
|
import { execFileSync } from "node:child_process";
|
|
13
13
|
import { homedir } from "node:os";
|
|
14
14
|
import { join } from "node:path";
|
|
@@ -18,19 +18,23 @@ import { ghRunner } from "./issuewatch.mjs";
|
|
|
18
18
|
import { parseForgeYaml } from "../forge-utils.mjs";
|
|
19
19
|
import { reviewStep, fixStep } from "./release-review.mjs";
|
|
20
20
|
import { postMergeStep } from "./release-postmerge.mjs";
|
|
21
|
+
import { deployStep } from "./release-deploy.mjs";
|
|
22
|
+
import { riskClass } from "./release-verify.mjs";
|
|
21
23
|
import { rehearsalStep, parseRehearsalConfig } from "./release-rehearsal.mjs";
|
|
22
24
|
import { budgetReportLine, releaseRuns, detectBudget, readCiPolicy } from "./ci-budget.mjs";
|
|
23
25
|
import { parseNightlyConfig, readNightly, blocksRelease, fileNightlyRed } from "./release-nightly.mjs";
|
|
24
|
-
import { parseBudgetConfig, applyOnExceed, waveReport, trailingMedian, historyFromRoot, releaseMinutes } from "./release-minutes.mjs";
|
|
26
|
+
import { parseBudgetConfig, applyOnExceed, waveReport, trailingMedian, historyFromRoot, gateHistoryFromRoot, releaseMinutes } from "./release-minutes.mjs";
|
|
25
27
|
import { cutSnapshot, writeRecord, checkChain, verifyRelease, DEFAULT_PATTERN } from "./release-snapshot.mjs";
|
|
26
28
|
import { createReleaseLedger, writeRelease, readLedger, acquireLease, heartbeat } from "./release-ledger.mjs";
|
|
27
29
|
import { fenced, epochTrailer } from "./release-fence.mjs";
|
|
28
|
-
import { holdCheck, exemptionsSection, VERBS as CONTROL_VERBS } from "./release-control.mjs";
|
|
30
|
+
import { holdCheck, exemptionsSection, runControl, VERBS as CONTROL_VERBS } from "./release-control.mjs";
|
|
29
31
|
import { parseFlakeConfig, classifyFailure, planRerun, flakeEntry, recordFlakes, readFlakes } from "./release-flakes.mjs";
|
|
30
32
|
import { readActive } from "./release-ledger.mjs";
|
|
33
|
+
import { statusFromCli, policyFromYaml } from "./release-status.mjs";
|
|
34
|
+
import { parseFixConfig } from "./release-fixloop.mjs";
|
|
31
35
|
import { hostPreflightStep, markReadyStep, parsePreflightConfig } from "./release-preflight.mjs";
|
|
32
36
|
|
|
33
|
-
export const RELEASE_STEPS = ["preflight", "host-preflight", "release-pr", "review", "fixes", "mark-ready", "rehearsal", "promotion", "post-merge"];
|
|
37
|
+
export const RELEASE_STEPS = ["preflight", "host-preflight", "release-pr", "review", "fixes", "mark-ready", "rehearsal", "promotion", "post-merge", "deploy"];
|
|
34
38
|
const ID_RE = /^r\d{8}-\d{6}-\d+$/;
|
|
35
39
|
const BLOCKED_EXIT = 3;
|
|
36
40
|
|
|
@@ -299,7 +303,7 @@ async function promotionStep(ctx) {
|
|
|
299
303
|
return { merged: true, head, gate };
|
|
300
304
|
}
|
|
301
305
|
|
|
302
|
-
const OPTIONAL_STEPS = ["host-preflight", "mark-ready"];
|
|
306
|
+
const OPTIONAL_STEPS = ["host-preflight", "mark-ready", "deploy"];
|
|
303
307
|
|
|
304
308
|
const STEP_FNS = {
|
|
305
309
|
preflight: preflightStep,
|
|
@@ -311,6 +315,7 @@ const STEP_FNS = {
|
|
|
311
315
|
rehearsal: (ctx) => rehearsalStep(ctx),
|
|
312
316
|
promotion: promotionStep,
|
|
313
317
|
"post-merge": (ctx) => postMergeStep(ctx),
|
|
318
|
+
deploy: (ctx) => deployStep(ctx),
|
|
314
319
|
};
|
|
315
320
|
|
|
316
321
|
/** The step table with `over` replacing steps by name (tests stub the steps that need a real repo). */
|
|
@@ -351,6 +356,10 @@ export async function runRelease({ io, repo, opts = {}, config = {}, branches =
|
|
|
351
356
|
return null;
|
|
352
357
|
};
|
|
353
358
|
const ctx = { io, repo, opts: state.opts, config, state, staging: branches.staging || DEFAULT_STAGING_BRANCH, def: branches.default || "main", git: io.git, save: () => rel.save(state) };
|
|
359
|
+
if (lctx) { // #5567: the fix loop's HELD goes through the control path; an infra-flake rerun through the fenced rerun
|
|
360
|
+
ctx.hold = (ask) => runControl("hold", [id, "--reason", ask], { io, repo, policy: null, actor: holder, host: holder });
|
|
361
|
+
ctx.rerunInfra = ({ head }) => rerunInfraFlakes({ io, repo, head, fence: ctx.fence, policy: config.policy });
|
|
362
|
+
}
|
|
354
363
|
ctx.save();
|
|
355
364
|
let out;
|
|
356
365
|
try {
|
|
@@ -383,6 +392,15 @@ export async function runRelease({ io, repo, opts = {}, config = {}, branches =
|
|
|
383
392
|
if (lctx) { // #5569: Actions minutes of this release (sum of ceil per job), mirrored to the ledger below
|
|
384
393
|
try { const m = await releaseMinutes({ gh: (a) => io.gh(a), repo, sinceMs: Date.parse(state.startedAt) }); if (m) state.minutes = { runs: m.runs, total: m.minutes }; } catch { /* best effort */ }
|
|
385
394
|
}
|
|
395
|
+
{ // #5583: with a catalogue, the deploy-telemetry JSON lines of this release (FORGE_GATE_TELEMETRY file) are kept next to state.minutes; no catalogue, no write
|
|
396
|
+
const tf = process.env.FORGE_GATE_TELEMETRY;
|
|
397
|
+
try {
|
|
398
|
+
if (tf && existsSync(tf) && existsSync(join(process.cwd(), ".forge/gates.yaml"))) {
|
|
399
|
+
const recs = (await import("./release-gates.mjs")).parseTelemetry(readFileSync(tf, "utf8"));
|
|
400
|
+
if (recs.length) state.gates = [...(state.gates ?? []), ...recs];
|
|
401
|
+
}
|
|
402
|
+
} catch { /* best effort */ }
|
|
403
|
+
}
|
|
386
404
|
state.status = out.status; ctx.save();
|
|
387
405
|
if (lctx) await mirror(state);
|
|
388
406
|
return out;
|
|
@@ -419,7 +437,7 @@ export function realReleaseIo({ env = process.env, exec = execFileSync, print =
|
|
|
419
437
|
}
|
|
420
438
|
|
|
421
439
|
const flag = (argv, f) => { const i = argv.indexOf(f); return i >= 0 ? argv[i + 1] : null; };
|
|
422
|
-
export const RELEASE_USAGE = "usage: forgedock release [--repo owner/repo] [--merge] [--watch] [--resume <id>] | forgedock release verify <sha> [--repo owner/repo] | forgedock release check-config [--ref <git ref>] | forgedock release init | forgedock release control <hold|resume|cancel|lane|exempt|freeze|unfreeze> ... --reason <text> [--repo owner/repo] [--json] (the verbs also work as `forgedock release <verb>`) | forgedock release report";
|
|
440
|
+
export const RELEASE_USAGE = "usage: forgedock release [--repo owner/repo] [--merge] [--watch] [--resume <id>] | forgedock release verify <sha | release id> [--repo owner/repo] | forgedock release status [<id>] [--watch] [--interval s] [--json] | forgedock release explain <id | #issue | PR> [--json] | forgedock release check-config [--ref <git ref>] | forgedock release init | forgedock release control <hold|resume|cancel|lane|exempt|freeze|unfreeze> ... --reason <text> [--repo owner/repo] [--json] (the verbs also work as `forgedock release <verb>`) | forgedock release gates [check [--base <ref>] | demote] [--since 30d] [--json] | forgedock release gates record <release-id> --file <jsonl> | forgedock release report";
|
|
423
441
|
|
|
424
442
|
/** `forgedock release ...`; @returns the process exit code (0 done or stopped at GATE_PASS, 1 refused, 3 blocked on a manual step). */
|
|
425
443
|
export async function releaseFromCli(argv, deps = {}) {
|
|
@@ -430,7 +448,34 @@ export async function releaseFromCli(argv, deps = {}) {
|
|
|
430
448
|
for (const l of waveReport(historyFromRoot(releaseRoot(env)), parseBudgetConfig(y.budget)).lines) io.print(l);
|
|
431
449
|
return 0;
|
|
432
450
|
}
|
|
451
|
+
if (argv[0] === "verify" && ID_RE.test(String(argv[1] ?? ""))) { // #5562: a release id re-runs the deploy verification; a sha keeps the snapshot-chain check
|
|
452
|
+
const { verifyReleaseById } = await import("./release-verify.mjs");
|
|
453
|
+
const { readPolicy } = await import("./release-config.mjs");
|
|
454
|
+
const def = readBranches(cwd).default || "main", rel = openRelease(releaseRoot(env), argv[1]), state = rel.load();
|
|
455
|
+
if (!state) throw new Error(`no release ${argv[1]} in ${releaseRoot(env)}`);
|
|
456
|
+
const r = await verifyReleaseById({ io, state, save: () => rel.save(state), def, policy: readPolicy({ io, defaultBranch: def, cwd }).policy, lane: flag(argv, "--lane") ?? state.lane });
|
|
457
|
+
return r.verified ? 0 : BLOCKED_EXIT;
|
|
458
|
+
}
|
|
459
|
+
if (argv[0] === "gates") { // #5583: catalogue, telemetry report, admission check; release-gates is loaded lazily
|
|
460
|
+
const g = await import("./release-gates.mjs");
|
|
461
|
+
const { readPolicy } = await import("./release-config.mjs");
|
|
462
|
+
const defaultBranch = readBranches(cwd).default || "main", root = releaseRoot(env);
|
|
463
|
+
if (argv[1] === "record") { // merge a deploy-telemetry JSON-lines file into the release state; no catalogue, no write
|
|
464
|
+
const id = argv[2], file = flag(argv, "--file");
|
|
465
|
+
if (!id || !file || !existsSync(join(cwd, g.GATES_PATH))) { io.print(`release gates record: needs <release-id>, --file and ${g.GATES_PATH}`); return 1; }
|
|
466
|
+
const rel = openRelease(root, id), st = rel.load();
|
|
467
|
+
if (!st) { io.print(`release gates record: no release ${id}`); return 1; }
|
|
468
|
+
const recs = g.parseTelemetry(readFileSync(file, "utf8"));
|
|
469
|
+
rel.save({ ...st, gates: [...(st.gates ?? []), ...recs] });
|
|
470
|
+
io.print(`release gates record: ${recs.length} record(s) into ${id}`);
|
|
471
|
+
return 0;
|
|
472
|
+
}
|
|
473
|
+
const policy = readPolicy({ io, defaultBranch, cwd }).policy;
|
|
474
|
+
const repo = flag(argv, "--repo") ?? (argv[1] === "demote" ? JSON.parse(String(await io.gh(["repo", "view", "--json", "nameWithOwner"]))).nameWithOwner : undefined);
|
|
475
|
+
return g.gatesFromCli(argv.slice(1), { io, cwd, defaultBranch, policy, repo, history: gateHistoryFromRoot(root) });
|
|
476
|
+
}
|
|
433
477
|
if (argv[0] === "verify") return verifyFromCli(argv.slice(1), { io, cwd });
|
|
478
|
+
if (argv[0] === "status" || argv[0] === "explain") return statusCli(argv, { io, cwd, env, deps });
|
|
434
479
|
if (argv[0] === "check-config" || argv[0] === "init") { // #5551: policy file, loaded lazily (release-config imports this module)
|
|
435
480
|
const { checkConfigFromCli, initFromCli } = await import("./release-config.mjs");
|
|
436
481
|
return (argv[0] === "init" ? initFromCli : checkConfigFromCli)(argv.slice(1), { io, cwd });
|
|
@@ -443,8 +488,12 @@ export async function releaseFromCli(argv, deps = {}) {
|
|
|
443
488
|
return controlFromCli(cv, argv.slice(argv[0] === "control" ? 2 : 1), { io, policy, actor: deps.actor, host: deps.host });
|
|
444
489
|
}
|
|
445
490
|
if (argv[0] === "control") throw new Error(`unknown control verb ${argv[1] ?? ""}; ${RELEASE_USAGE}`);
|
|
446
|
-
const unknown = argv.filter((a, i) => a.startsWith("--") && !["--repo", "--merge", "--watch", "--resume", "--lane"].includes(a) && !(argv[i - 1] === "--resume" || argv[i - 1] === "--repo" || argv[i - 1] === "--lane"));
|
|
491
|
+
const unknown = argv.filter((a, i) => a.startsWith("--") && !["--repo", "--merge", "--watch", "--resume", "--lane", "--interval"].includes(a) && !(argv[i - 1] === "--resume" || argv[i - 1] === "--repo" || argv[i - 1] === "--lane" || argv[i - 1] === "--interval"));
|
|
447
492
|
if (unknown.length) throw new Error(`unknown option ${unknown[0]}; ${RELEASE_USAGE}`);
|
|
493
|
+
if (argv.includes("--watch")) { // the bare flag delegates to the status loop (#5554)
|
|
494
|
+
const pick = (f) => (flag(argv, f) ? [f, flag(argv, f)] : []);
|
|
495
|
+
return statusCli(["status", ...(flag(argv, "--resume") ? [flag(argv, "--resume")] : []), "--watch", ...pick("--repo"), ...pick("--interval")], { io, cwd, env, deps });
|
|
496
|
+
}
|
|
448
497
|
const root = releaseRoot(env);
|
|
449
498
|
const resume = flag(argv, "--resume");
|
|
450
499
|
let id = resume ?? newReleaseId(io.now());
|
|
@@ -452,6 +501,18 @@ export async function releaseFromCli(argv, deps = {}) {
|
|
|
452
501
|
let raw = ""; try { raw = readFileSync(join(cwd, "forge.yaml"), "utf8"); } catch { /* no forge.yaml: defaults */ }
|
|
453
502
|
const config = readReleaseConfig(raw);
|
|
454
503
|
if (config.managed) config.ciPolicy = readCiPolicy(cwd);
|
|
504
|
+
if (config.managed) { // #5560: deploy stages come from the default-branch policy only (I13)
|
|
505
|
+
const { readPolicy } = await import("./release-config.mjs");
|
|
506
|
+
const pol = readPolicy({ io, defaultBranch: readBranches(cwd).default || "main", cwd }).policy;
|
|
507
|
+
if (pol?.deploy) config.deploy = pol.deploy;
|
|
508
|
+
config.policy = pol; config.fix = parseFixConfig(pol?.ci?.fix); // #5567: ci.fix.max_rounds / co_start / full_run_workflow
|
|
509
|
+
config.deployPipeline = pol?.lanes?.[flag(argv, "--lane")]?.pipeline ?? "full"; // service/hotfix lanes dispatch with unit inputs
|
|
510
|
+
if (pol?.verify) { // #5562: verification layers; risk class picks the soak minutes
|
|
511
|
+
config.verify = pol.verify;
|
|
512
|
+
config.verifyRisk = riskClass(flag(argv, "--lane"), config.deployPipeline);
|
|
513
|
+
config.verifySoak = pol.lanes?.[flag(argv, "--lane")]?.soak_min;
|
|
514
|
+
}
|
|
515
|
+
}
|
|
455
516
|
if (resume) {
|
|
456
517
|
const st = openRelease(root, resume).load();
|
|
457
518
|
if (!st && !config.managed) throw new Error(`no release ${resume} in ${root}`); // managed: the ledger may hold it (another host)
|
|
@@ -479,3 +540,12 @@ async function verifyFromCli(argv, { io, cwd }) {
|
|
|
479
540
|
io.print(r.ok ? `release verify ${full}: ok (snapshot + ${r.picks} cherry-pick(s), PR #${r.pr})` : `release verify ${full}: FAILED: ${r.why}`);
|
|
480
541
|
return r.ok ? 0 : 1;
|
|
481
542
|
}
|
|
543
|
+
|
|
544
|
+
/** `release status|explain` (#5554): read-only; the local cache and the gate read are handed to release-status.mjs. */
|
|
545
|
+
function statusCli(argv, { io, cwd, env, deps }) {
|
|
546
|
+
let raw = ""; try { raw = readFileSync(join(cwd, "forge.yaml"), "utf8"); } catch { /* defaults */ }
|
|
547
|
+
const root = releaseRoot(env);
|
|
548
|
+
const local = { load: (id) => (ID_RE.test(String(id)) ? openRelease(root, id).load() : null), ids: () => { try { return readdirSync(root).filter((d) => ID_RE.test(d)); } catch { return []; } } };
|
|
549
|
+
const { policy, watch } = policyFromYaml(raw);
|
|
550
|
+
return statusFromCli(argv, { io, config: readReleaseConfig(raw), local, gateState, watch: deps.watch ?? watch, policy: deps.policy ?? policy, maxPolls: deps.maxPolls });
|
|
551
|
+
}
|
|
@@ -226,7 +226,7 @@ describe("release job (#5211)", () => {
|
|
|
226
226
|
assert.equal(readReleaseConfig("release:\n managed: true\n").managed, true);
|
|
227
227
|
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 {}; } };
|
|
228
228
|
const ok = async () => ({});
|
|
229
|
-
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 } });
|
|
229
|
+
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 }) } });
|
|
230
230
|
assert.equal(out.status, "done");
|
|
231
231
|
assert.deepEqual(apiCalls, []);
|
|
232
232
|
assert.deepEqual(ghCalls, []);
|
|
@@ -444,6 +444,10 @@ describe("snapshot releases (#5276)", () => {
|
|
|
444
444
|
assert.equal(create[create.indexOf("--head") + 1], "staging");
|
|
445
445
|
});
|
|
446
446
|
|
|
447
|
+
it("#5562: `release verify <id>` is routed to the deploy verification, not the sha check", async () => {
|
|
448
|
+
const io = { gh: async () => { throw new Error("gh must not be called"); }, print() {}, git: () => "", now: () => 0 };
|
|
449
|
+
await assert.rejects(releaseFromCli(["verify", "r20260101-000000-1"], { io, cwd: tmp(), env: { ...process.env, FORGEDOCK_RELEASE_DIR: tmp() } }), /no release r20260101-000000-1/);
|
|
450
|
+
});
|
|
447
451
|
it("R10: `release verify <sha>` exits 0 for a head that is the snapshot, 1 for a PR without a record", async () => {
|
|
448
452
|
const rec = { v: 1, snapshot: S, picks: [] };
|
|
449
453
|
const mk = (body) => { const io = fakeIo({ pm: (a) => (a[0] === "api" ? JSON.stringify([{ number: 9, body }]) : undefined) }); io.git = gitFake(); io.git = ((g) => (a, o) => (a[0] === "rev-parse" && !a[1].startsWith("refs/") ? `${S}\n` : g(a, o)))(io.git); return io; };
|
package/docs/CONFIG.md
CHANGED
|
@@ -758,7 +758,7 @@ gate:
|
|
|
758
758
|
|
|
759
759
|
## `release` (OPTIONAL)
|
|
760
760
|
|
|
761
|
-
Settings for `forgedock release [--repo owner/repo] [--merge] [--watch] [--resume <id>]` (#5208), which runs the `branches.staging` → `branches.default` release as one resumable job. State is kept in `~/.forge/releases/<id>/` (or `FORGEDOCK_RELEASE_DIR`); `--resume <id>` continues from the last completed step (preflight, release-pr, review, fixes, promotion, post-merge). Preflight refuses while lanes of the repo run or PRs to the staging branch are open, and sets the repo's batches to K=1 until the job ends. Review and fixes are not automated yet: the job stops there and tells you to use the manual path (`commands/review-pr-staging.md`). Post-merge is automated (#5213): it confirms a publish run for the merge commit (dispatching one when none appears), waits for `artifact_check`, then opens and merges the version-sync PR; a bound that runs out stops the job as blocked and `--resume <id>` retries. `--watch` is
|
|
761
|
+
Settings for `forgedock release [--repo owner/repo] [--merge] [--watch] [--resume <id>]` (#5208), which runs the `branches.staging` → `branches.default` release as one resumable job. State is kept in `~/.forge/releases/<id>/` (or `FORGEDOCK_RELEASE_DIR`); `--resume <id>` continues from the last completed step (preflight, release-pr, review, fixes, promotion, post-merge). Preflight refuses while lanes of the repo run or PRs to the staging branch are open, and sets the repo's batches to K=1 until the job ends. Review and fixes are not automated yet: the job stops there and tells you to use the manual path (`commands/review-pr-staging.md`). Post-merge is automated (#5213): it confirms a publish run for the merge commit (dispatching one when none appears), waits for `artifact_check`, then opens and merges the version-sync PR; a bound that runs out stops the job as blocked and `--resume <id>` retries. `forgedock release status [<id>] [--watch] [--interval s] [--json]` (bare `forgedock release --watch` runs the same loop) and `forgedock release explain <id | #issue | PR> [--json]` (#5554) are read-only: status reads the ledger (when `release.managed`) or the local cache plus the release PR's gate; `--watch` polls until the release is done, refused or blocked. `explain #N` prints the ordered rule trace (skip labels, priority, theme_map, `Depends on`, recorded release set, each with its config key), the lane and what would change it; `explain <PR>` prints the gate decision. `--json` output has schema `forgedock.release.status/v1` or `forgedock.release.explain/v1` and `next_actions[]`, the exact commands an agent may run; output carries no host name, so another host prints the same text. `status --watch [--interval s]` prints only when the output changes and stops at a terminal state; `forgedock release --watch` runs the same loop. Status prints `unknown` for any field the ledger does not hold. `explain #N` also reads the `FORGE:CLASSIFY` record (else `classification: absent`), `plan.skip_labels`, `classify.min_confidence`, `risk.rules[i]`, `forces[i]`, prints `planner: not installed` until the planner registers, and takes the lane from the latest `lane` entry in `controls.jsonl`; `explain <PR>` lists each required check with its outcome and any demotion (actor, expiry, reason, issue). `next_actions[]` carries `hold|resume|cancel` and `lane #N --force <lane>` commands (the `release-control.mjs` verbs) with `--reason <reason>` placeholders; there is no `rollback` verb yet, so none is emitted. `explain <PR>` reads the live `_active.exemptions` records (`release exempt`), `explain #N` the `_active.lanes` records.
|
|
762
762
|
|
|
763
763
|
```yaml
|
|
764
764
|
release:
|
|
@@ -779,6 +779,8 @@ release:
|
|
|
779
779
|
|
|
780
780
|
`forgedock release verify <sha> [--repo owner/repo]` reads the `FORGE:RELEASE` record from the PR that contains `<sha>` and exits 0 only when `<sha>` is the snapshot plus recorded picks, each a clean cherry-pick of a `branches.staging` commit (same tree as `git cherry-pick`), so a repo workflow that trusted `head.ref == staging` can call it instead.
|
|
781
781
|
|
|
782
|
+
`forgedock release verify <release id>` (#5562) re-runs the deploy verification of a release that passed LIVE_CHECK; a release id (`rYYYYMMDD-HHMMSS-N`) is never mistaken for a sha. Policy `verify` block (default branch, `.forge/release.yaml`): `results` (list of `{workflow, kind: smoke|edge|convergence}`, layer 1), `workflow` (verification workflow dispatched through the epoch fence, layer 2), `slis` (layer 3, entries `{name, tolerance, worse: higher|lower, abs}` read through an injected read-only metric source; without one the layer reports `sli: skipped (no host)`), `post_deploy_checks_file` (layer 4, each issue's `[check:id]` runs once; entries with `for` are windowed and become rollup follow-ups), `flags` (layer 5, `{flag, off_command}` verified in the off state, never activated) and `close_requires: verified|deployed`. With `verified` (default once the block is set) an issue is closed only after a `FORGE:VERIFIED <deploy sha>` comment; `deployed` closes without it. Soak minutes by risk class: low 10, medium 20, full 30, p0 15, overridden by `lanes.<lane>.soak_min` (a number or a map by class). An empty `verify` block leaves VERIFYING a bare transition to LIVE.
|
|
783
|
+
|
|
782
784
|
### `.forge/release.yaml` (#5551)
|
|
783
785
|
|
|
784
786
|
Nested release policy (`schema: 1`) lives in a committed `.forge/release.yaml`, not in the host-local forge.yaml. It is read from the default branch with `git show origin/<default>:.forge/release.yaml`, never from the PR head or the worktree, so a PR cannot weaken its own gates. The flat `release.*` keys above stay the fallback when the file is absent there. Sections: `branches`, `trust`, `state`, `units`, `couplings`, `contracts`, `forces`, `classify`, `risk`, `plan`, `lanes`, `merge`, `ci`, `preflight`, `deploy`, `verify`, `rollback`, `controls`.
|
|
@@ -833,6 +835,22 @@ budget:
|
|
|
833
835
|
|
|
834
836
|
The release state (and so the ledger) records `lane` and `minutes: {runs, total}`, where total is the sum of ceil(job minutes) of the Actions runs created since the release started, read from the jobs API.
|
|
835
837
|
|
|
838
|
+
|
|
839
|
+
### Deploy gate catalogue and false-block telemetry (#5583)
|
|
840
|
+
|
|
841
|
+
Optional; with no `.forge/gates.yaml` (on the ref) every command below is a no-op with zero writes. `forgedock release check-config` validates the file when present. Fields per gate under `gates:` (`schema: 1`): `id`, `protects_against` (origin issue), `where`, `determinism`, `pre_merge_artifact` (fixture), `version`, `mode` (`block|skip|rollback|freeze|warn|red`), `owner`, `review_by` (`YYYY-MM-DD`); admission also needs `on_uncertainty: inconclusive`, `failure_triggers` and `proportionality`.
|
|
842
|
+
|
|
843
|
+
`.forge/release.yaml` `gates:`: `demote_fb_rate` (percent, default 5), `demote_window` (runs, default 20), `safety` (never demoted; default `migration-immutability`, `identity-preflight`, `backup-freshness`, `health-auto-restore`, plus the unskippable classes).
|
|
844
|
+
|
|
845
|
+
A `deploy-telemetry` job prints one JSON line per gate per run: `{"schema":"forgedock.release.gate/v1","gate":"<id>","outcome":"pass|fail|inconclusive|skip","class":"TP|FB|unknown","minutes":<n>,"evidence":"<text>"}`. A `TP`/`FB` class without `evidence` is stored as `unknown`. `forgedock release gates record <release-id> --file <jsonl>` stores the lines in the release state (`gates`). When `FORGE_GATE_TELEMETRY` names such a JSON-lines file and a catalogue exists, the release run stores its lines in `state.gates` next to `state.minutes` automatically; `historyFromRoot` exposes them as its `gates` property.
|
|
846
|
+
|
|
847
|
+
| Command | Description |
|
|
848
|
+
|---------|-------------|
|
|
849
|
+
| `release gates [--since 30d] [--json]` | Per gate: `runs`, `fails`, `fb`, `fb_share` (FB runs / runs, in percent), `minutes`. Text: a tab-separated header `gate runs fails fb fb_share minutes` and one row per gate. JSON: one line `{"schema":"forgedock.release.gates/v1","gates":[{gate,runs,fails,fb,minutes,fb_share}]}`. |
|
|
850
|
+
| `release gates check [--base <ref>]` | Fails for a gate added or changed against the base ref (default `origin/<default>`) that lacks the fixture, version, `on_uncertainty: inconclusive`, failure trigger with proportionality, or owner and `review_by`. |
|
|
851
|
+
| `release gates demote` | A gate whose FB rate over the last `demote_window` runs (a full window) exceeds `demote_fb_rate` is demoted to `warn` for 14 days via the audited `release demote` control, and an issue is filed. Safety gates are never demoted. |
|
|
852
|
+
| `release promote <gate> --fixture <ref> --reason <text>` | Re-promotes a demoted gate; refused without a fixture reference. |
|
|
853
|
+
|
|
836
854
|
The result (pass or fail, head SHA, blocker issue) is recorded in the release state (`steps.rehearsal`) and in a `FORGE:REHEARSAL` section of the release PR body next to the gate result.
|
|
837
855
|
|
|
838
856
|
Repos that set `preflight_command` should skip their Actions CI while the release PR is a draft, so the paid run happens once, on the final head:
|
|
@@ -1014,6 +1032,7 @@ lean:
|
|
|
1014
1032
|
fix_model: claude-sonnet-5-5 # optional model of fresh fix-round sessions (default: the reviewer model)
|
|
1015
1033
|
builder_routing: on # on (default) | off: route the build to a mid-tier model by the frozen contract
|
|
1016
1034
|
builder_mid_model: claude-sonnet-5-5 # optional mid-tier builder model (default claude-sonnet-5-5)
|
|
1035
|
+
contract_max_corrections: 3 # #5623: builder correction rounds for a builder-correctable invalid contract before it ends contract.invalid (which a batch then requeues once with a fresh plan)
|
|
1017
1036
|
light:
|
|
1018
1037
|
mode: shadow # off | shadow (default) | on: light-lane eligibility (#4448; lane wiring #4450)
|
|
1019
1038
|
max_lines: 40 # upgrade to the full lane above this many non-test diff lines
|
package/package.json
CHANGED
|
@@ -265,10 +265,29 @@ function ecosystemTests(sctx, tests) {
|
|
|
265
265
|
// Which of testFiles can this change reach? { selected, total, widen } ; widen is a reason string or ''.
|
|
266
266
|
// `universe` is the repo-wide test set used only for the SEC-3 reach check: a step that runs ONE test must not widen just
|
|
267
267
|
// because the change does not reach that test, only because it reaches no test anywhere. Selection stays within testFiles.
|
|
268
|
+
// #5583 follow-up: a test that enumerates the tree itself (git ls-files, find -name/-path, git grep), directly or through a
|
|
269
|
+
// script it names, is a repo-wide lint: any change can trip it (a new file that breaks a convention names no test), so the
|
|
270
|
+
// reference graph can never select it. Such tests are always selected; they are cheap scans by nature.
|
|
271
|
+
const TREE_SCAN_RE = /\bgit\s+(ls-files|grep)\b|\bfind\s+\S+(\s+-maxdepth\s+\d+)?\s+-(name|path|iname|type)\b/;
|
|
272
|
+
export function treeScanTest(sctx, t) {
|
|
273
|
+
const memo = (sctx.cache.treeScan ??= new Map());
|
|
274
|
+
if (memo.has(t)) return memo.get(t);
|
|
275
|
+
const read = (f) => { try { return fs.readFileSync(path.join(sctx.repo, f), 'utf8'); } catch { return ''; } };
|
|
276
|
+
const body = read(t);
|
|
277
|
+
let hit = TREE_SCAN_RE.test(body);
|
|
278
|
+
if (!hit) { // one hop: scripts the test names (e.g. foo.test.sh runs foo.sh)
|
|
279
|
+
const named = [...new Set(body.match(/[\w./-]+\.(sh|bash|mjs|js|py)\b/g) ?? [])].flatMap((x) => x.split('/').map((_, i, a) => a.slice(i).join('/'))).filter((x) => x && x !== t && sctx.present.has(x)); // every path suffix: $ROOT/scripts/x.sh -> scripts/x.sh
|
|
280
|
+
hit = named.some((f) => TREE_SCAN_RE.test(read(f)));
|
|
281
|
+
}
|
|
282
|
+
memo.set(t, hit);
|
|
283
|
+
return hit;
|
|
284
|
+
}
|
|
285
|
+
|
|
268
286
|
export function impactedTests(sctx, testFiles, universe = testFiles) {
|
|
269
287
|
const r = reach(sctx);
|
|
270
288
|
if (r.widen) return { selected: [...testFiles], total: testFiles.length, widen: r.widen };
|
|
271
289
|
const selected = new Set();
|
|
290
|
+
if (sctx.changed.length) for (const t of testFiles) if (sctx.present.has(t) && treeScanTest(sctx, t)) selected.add(t);
|
|
272
291
|
for (const t of testFiles) if (r.files.has(t) && sctx.present.has(t)) selected.add(t);
|
|
273
292
|
for (const f of sctx.changed) if (!isTestFile(f)) for (const t of siblingTests(f, testFiles)) selected.add(t);
|
|
274
293
|
// forge#4040 (SEC-3, per file): every changed non-test source file must itself reach at least one test (reverse-reference
|
package/scripts/ci-local.test.sh
CHANGED
|
@@ -598,6 +598,19 @@ eq "SEC-3: the widened selection is the full set" 3 "$(printf '%s' "$R" | jq '.s
|
|
|
598
598
|
R=$(_imp README.md)
|
|
599
599
|
eq "SEC-3: a docs-only change still selects nothing (no widening)" '[]' "$(printf '%s' "$R" | jq -c '.sel')"
|
|
600
600
|
|
|
601
|
+
# #5583 follow-up: a tree-scanning lint test (find/git ls-files, directly or via a script it runs) is selected for any change
|
|
602
|
+
r=$(blank); mkdir -p "$r/scripts" "$r/bin"
|
|
603
|
+
printf '#!/bin/bash\nfind "$1/bin" -name "*.test.mjs" | while read -r f; do grep -q tmpDir "$f" || echo "VIOLATION: $f"; done\n' > "$r/scripts/check-tmp.sh"
|
|
604
|
+
printf '#!/bin/bash\nout=$(bash "$ROOT/scripts/check-tmp.sh" .)\n[ -z "$out" ]\n' > "$r/scripts/check-tmp.test.sh"
|
|
605
|
+
printf '#!/bin/bash\n[ 1 -eq 1 ]\n' > "$r/scripts/plain.test.sh"
|
|
606
|
+
commit_base "$r"
|
|
607
|
+
_imp2() { node -e "
|
|
608
|
+
import('$ROOT/scripts/ci-local/scoping.mjs').then(m=>{const c=process.argv.slice(1);const s=m.makeScopeCtx({repo:'$r',baseRef:'main',from:'main',changed:c});
|
|
609
|
+
const t=['scripts/check-tmp.test.sh','scripts/plain.test.sh'];const r=m.impactedTests(s,t);console.log(JSON.stringify({sel:r.selected,widen:r.widen}))})" "$@"; }
|
|
610
|
+
echo 'import x from "y";' > "$r/bin/new.test.mjs"
|
|
611
|
+
R=$(_imp2 bin/new.test.mjs)
|
|
612
|
+
eq "tree-scan: a new test file selects the lint that scans the tree (via the script it runs)" '["scripts/check-tmp.test.sh"]' "$(printf '%s' "$R" | jq -c '.sel')"
|
|
613
|
+
|
|
601
614
|
# item 4 (REG-3): the built-in bash-3.2/GNU portability job runs only when CI targets macOS/Windows
|
|
602
615
|
r=$(blank); mkdir -p "$r/.github/workflows" "$r/scripts"
|
|
603
616
|
cat > "$r/.github/workflows/ci.yml" <<'YML'
|