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.
@@ -42,6 +42,7 @@ function fakeIo(world = {}) {
42
42
  throw new Error(`unexpected gh ${j}`);
43
43
  },
44
44
  };
45
+ io.ciGreen = { isDraft: async () => true }; // real ci-green steps skip like a draft PR: CI waiting is tested in release-cigreen.test.mjs
45
46
  if (w.scorecard) io.scorecard = w.scorecard;
46
47
  return io;
47
48
  }
@@ -52,7 +53,7 @@ describe("unmanaged release carries no epoch (#5553)", () => {
52
53
  const mod = await import("./release.mjs");
53
54
  const io = fakeIo();
54
55
  io.api = async () => { throw new Error("no ledger call expected"); };
55
- const out = await mod.runRelease({ io, repo: REPO, root: tmp(), mounts: DISK, id: newReleaseId(), opts: { merge: true }, config: {}, branches: { staging: "staging", default: "main" }, steps: mod.withStubs({ review: ok, fixes: ok, "post-merge": ok }) });
56
+ const out = await mod.runRelease({ io, repo: REPO, root: tmp(), mounts: DISK, id: newReleaseId(), opts: { merge: true }, config: {}, branches: { staging: "staging", default: "main" }, steps: mod.withStubs({ "ci-green": ok, review: ok, fixes: ok, "post-merge": ok }) });
56
57
  assert.equal(out.status, "done");
57
58
  const merge = io.calls.find((a) => a[0] === "pr" && a[1] === "merge");
58
59
  assert.deepEqual(merge, ["pr", "merge", "7", "--repo", REPO, "--merge", "--match-head-commit", HEAD]);
@@ -65,7 +66,7 @@ describe("legacy managed promotion without a fence (#5561 regression)", () => {
65
66
  const io = fakeIo({ gate: "failure" });
66
67
  const shown = [];
67
68
  io.git = (a) => { if (a[0] === "show") shown.push(a[1]); throw new Error("no git"); };
68
- await mod.runRelease({ io, repo: REPO, root: tmp(), mounts: DISK, id: newReleaseId(), opts: { merge: true }, config: { managed: true }, branches: { staging: "staging", default: "main" }, steps: mod.withStubs({ review: ok, fixes: ok, "post-merge": ok }) });
69
+ await mod.runRelease({ io, repo: REPO, root: tmp(), mounts: DISK, id: newReleaseId(), opts: { merge: true }, config: { managed: true }, branches: { staging: "staging", default: "main" }, steps: mod.withStubs({ "ci-green": ok, review: ok, fixes: ok, "post-merge": ok }) });
69
70
  assert.ok(shown.some((x) => x.startsWith("origin/main:")), "policy read for the flake rerun");
70
71
  });
71
72
  });
@@ -75,7 +76,7 @@ describe("release job (#5211)", () => {
75
76
  const io = fakeIo(world), root = tmp(), id = newReleaseId();
76
77
  // Real preflight/release-pr/promotion, with review/fixes/post-merge replaced by no-ops.
77
78
  const mod = await import("./release.mjs");
78
- const out = await mod.runRelease({ io, repo: REPO, root, mounts: DISK, id, opts, config, branches: { staging: "staging", default: "main" }, steps: mod.withStubs({ review: ok, fixes: ok, "post-merge": ok }) });
79
+ const out = await mod.runRelease({ io, repo: REPO, root, mounts: DISK, id, opts, config, branches: { staging: "staging", default: "main" }, steps: mod.withStubs({ "ci-green": ok, review: ok, fixes: ok, "post-merge": ok }) });
79
80
  return { io, out, root, id };
80
81
  };
81
82
 
@@ -139,7 +140,7 @@ describe("release job (#5211)", () => {
139
140
  const io = fakeIo({ prState: "MERGED" }), root = tmp(), id = newReleaseId();
140
141
  const mod = await import("./release.mjs");
141
142
  let seen = null;
142
- const out = await mod.runRelease({ io, repo: REPO, root, mounts: DISK, id, opts: {}, config: {}, branches: { staging: "staging", default: "main" }, steps: mod.withStubs({ review: ok, fixes: ok, "post-merge": async (c) => { seen = c.state.steps.promotion.result; return {}; } }) });
143
+ const out = await mod.runRelease({ io, repo: REPO, root, mounts: DISK, id, opts: {}, config: {}, branches: { staging: "staging", default: "main" }, steps: mod.withStubs({ "ci-green": ok, review: ok, fixes: ok, "post-merge": async (c) => { seen = c.state.steps.promotion.result; return {}; } }) });
143
144
  assert.equal(out.status, "done");
144
145
  assert.equal(seen.alreadyMerged, true);
145
146
  assert.equal(seen.mergeCommit, "m".repeat(40));
@@ -210,12 +211,12 @@ describe("release job (#5211)", () => {
210
211
  const mod = await import("./release.mjs");
211
212
  const ran = [];
212
213
  const rec = (n, fn) => async (ctx) => { ran.push(n); return fn(ctx); };
213
- const base = mod.withStubs({ review: ok, fixes: ok, "post-merge": ok });
214
+ const base = mod.withStubs({ "ci-green": ok, review: ok, fixes: ok, "post-merge": ok });
214
215
  const kill = async () => { throw new Error("killed"); };
215
216
  const first = { ...base, preflight: rec("preflight", base.preflight), "release-pr": rec("release-pr", base["release-pr"]), review: kill };
216
217
  await assert.rejects(() => mod.runRelease({ io, repo: REPO, root, mounts: DISK, id, opts: { merge: true }, config: {}, branches: {}, steps: first }), /killed/);
217
218
  const st = openRelease(root, id).load();
218
- assert.deepEqual(Object.keys(st.steps), ["preflight", "release-pr"]);
219
+ assert.deepEqual(Object.keys(st.steps), ["preflight", "release-pr", "ci-green"]);
219
220
  const second = { ...base, preflight: rec("preflight2", base.preflight), "release-pr": rec("release-pr2", base["release-pr"]) };
220
221
  const out = await mod.runRelease({ io, repo: REPO, root, mounts: DISK, id, opts: { merge: true }, config: {}, branches: {}, steps: second });
221
222
  assert.equal(out.status, "done");
@@ -226,7 +227,7 @@ describe("release job (#5211)", () => {
226
227
  const root = tmp(), id = newReleaseId(), io = fakeIo(), mod = await import("./release.mjs");
227
228
  const at = new Date(io.now()).toISOString();
228
229
  const review = { pr: 7, head: HEAD, verdict: "BLOCK DEPLOY", marker: "FORGE:GATE_FAILURE", blocking: [101], filed: [101], ciFailing: 1, items: [] };
229
- openRelease(root, id, DISK).save({ v: 1, id, repo: REPO, startedAt: at, held: [], steps: { preflight: { done: true, at, result: {} }, "release-pr": { done: true, at, result: { pr: 7, head: HEAD } }, review: { done: true, at, result: review } } });
230
+ openRelease(root, id, DISK).save({ v: 1, id, repo: REPO, startedAt: at, held: [], steps: { preflight: { done: true, at, result: {} }, "release-pr": { done: true, at, result: { pr: 7, head: HEAD } }, "ci-green": { done: true, at, result: {} }, review: { done: true, at, result: review } } });
230
231
  const stuckGh = (a) => {
231
232
  if (a[0] === "run" && a[1] === "list") return JSON.stringify([{ databaseId: 1, name: "Shell Compatibility", status: "in_progress", conclusion: "" }, { databaseId: 2, name: "CI", status: "completed", conclusion: "failure" }]);
232
233
  if (a[0] === "run" && a[1] === "view") return "boom";
@@ -234,6 +235,7 @@ describe("release job (#5211)", () => {
234
235
  };
235
236
  const waits = [], log = [];
236
237
  const real = realSeam({ repo: REPO, def: "main", env: {}, cwd: "/tmp", gh: stuckGh, io: { now: () => 0, sleep: async (ms) => { waits.push(ms); }, print: () => {} } });
238
+ io.ciGreen = { now: () => 0, sleep: async () => {}, isDraft: async () => false, headOf: async () => HEAD, checks: async () => [], required: async () => [] };
237
239
  io.review = {
238
240
  failedJobs: real.failedJobs, headOf: async () => HEAD, issueMerged: async () => false,
239
241
  fileDeferred: async () => [], fileFixIssue: async () => { log.push("fix-issue"); return 200; },
@@ -241,7 +243,7 @@ describe("release job (#5211)", () => {
241
243
  pre: async () => ({ code: 1, data: null, lines: ["stopped"] }), // ends the delta review right after the fix lane
242
244
  };
243
245
  const timer = new Promise((_, rej) => setTimeout(() => rej(new Error("still waiting after 5000ms")), 5000).unref());
244
- const out = await Promise.race([mod.runRelease({ io, repo: REPO, root, mounts: DISK, id, opts: { merge: true }, config: {}, branches: { staging: "staging", default: "main" }, steps: mod.withStubs({ "post-merge": ok }) }), timer]);
246
+ const out = await Promise.race([mod.runRelease({ io, repo: REPO, root, mounts: DISK, id, opts: { merge: true }, config: { reviewFixes: true }, branches: { staging: "staging", default: "main" }, steps: mod.withStubs({ "post-merge": ok }) }), timer]);
245
247
  assert.deepEqual(log, ["fix-issue", "lane"]);
246
248
  assert.deepEqual(waits, []);
247
249
  assert.equal(out.step, "fixes"); // reached the fix step and ran it, not stopped at review
@@ -276,7 +278,7 @@ describe("release job (#5211)", () => {
276
278
  assert.equal(readReleaseConfig("release:\n managed: true\n").managed, true);
277
279
  const apiCalls = [], ghCalls = [], io = { print() {}, now: () => 1_700_000_000_000, runningLanes: async () => [], batches: async () => [], setParallel: async () => {}, gh: async (a) => { ghCalls.push(a); return ""; }, api: async (...a) => { apiCalls.push(a); return {}; } };
278
280
  const ok = async () => ({});
279
- const out = await (await import("./release.mjs")).runRelease({ io, repo: REPO, root: tmp(), mounts: DISK, id: newReleaseId(), opts: {}, config: {}, branches: {}, steps: { preflight: ok, "host-preflight": ok, "release-pr": ok, review: ok, fixes: ok, "mark-ready": ok, rehearsal: ok, promotion: ok, "post-merge": ok, deploy: async () => ({ skipped: true }) } });
281
+ const out = await (await import("./release.mjs")).runRelease({ io, repo: REPO, root: tmp(), mounts: DISK, id: newReleaseId(), opts: {}, config: {}, branches: {}, steps: { preflight: ok, "host-preflight": ok, "release-pr": ok, "ci-green": ok, review: ok, fixes: ok, "mark-ready": ok, rehearsal: ok, promotion: ok, "post-merge": ok, deploy: async () => ({ skipped: true }) } });
280
282
  assert.equal(out.status, "done");
281
283
  assert.deepEqual(apiCalls, []);
282
284
  assert.deepEqual(ghCalls, []);
@@ -418,7 +420,7 @@ describe("release post-merge step (#5213)", () => {
418
420
  const go = async (runs) => {
419
421
  const io = fakeIo({ pm: world(runs).pm });
420
422
  const config = { postMerge: { publishPolls: 1, runPolls: 1 } };
421
- return mod.runRelease({ io, repo: REPO, root, mounts: DISK, id, opts: { merge: true }, config, branches: { staging: "staging", default: "main" }, steps: mod.withStubs({ review: ok, fixes: ok }) });
423
+ return mod.runRelease({ io, repo: REPO, root, mounts: DISK, id, opts: { merge: true }, config, branches: { staging: "staging", default: "main" }, steps: mod.withStubs({ "ci-green": ok, review: ok, fixes: ok }) });
422
424
  };
423
425
  assert.equal((await go([[{ databaseId: 1, status: "completed", conclusion: "failure" }]])).status, "blocked");
424
426
  assert.equal((await go([[{ databaseId: 2, status: "completed", conclusion: "success" }]])).status, "done");
@@ -441,7 +443,7 @@ describe("snapshot releases (#5276)", () => {
441
443
  const io = fakeIo(world);
442
444
  if (world.git) io.git = world.git;
443
445
  const mod = await import("./release.mjs");
444
- const out = await mod.runRelease({ io, repo: REPO, root: tmp(), mounts: DISK, id: newReleaseId(), opts, config, branches: { staging: "staging", default: "main" }, steps: mod.withStubs({ review: ok, fixes: ok, "post-merge": ok }) });
446
+ const out = await mod.runRelease({ io, repo: REPO, root: tmp(), mounts: DISK, id: newReleaseId(), opts, config, branches: { staging: "staging", default: "main" }, steps: mod.withStubs({ "ci-green": ok, review: ok, fixes: ok, "post-merge": ok }) });
445
447
  return { io, out };
446
448
  };
447
449
 
@@ -615,7 +617,7 @@ describe("preflight staging-health gate (#6013)", () => {
615
617
  it("refuses a snapshot cut on a red staging head and proceeds when green", async () => {
616
618
  const mod = await import("./release.mjs");
617
619
  const root = tmp(), id = newReleaseId();
618
- const base = (io) => ({ io, repo: REPO, root, mounts: DISK, id, opts: {}, config: snap, branches: { staging: "staging", default: "main" }, steps: mod.withStubs({ "release-pr": ok, review: ok, fixes: ok, promotion: ok, "post-merge": ok }) });
620
+ const base = (io) => ({ io, repo: REPO, root, mounts: DISK, id, opts: {}, config: snap, branches: { staging: "staging", default: "main" }, steps: mod.withStubs({ "release-pr": ok, "ci-green": ok, review: ok, fixes: ok, promotion: ok, "post-merge": ok }) });
619
621
  const reds = await mod.runRelease(base(fakeIo(world([{ name: "black", status: "completed", conclusion: "failure", text: "" }]))));
620
622
  assert.equal(reds.status, "refused");
621
623
  assert.match(JSON.stringify(reds), /black/);
@@ -626,3 +628,22 @@ describe("preflight staging-health gate (#6013)", () => {
626
628
  assert.notEqual(green.status, "refused");
627
629
  });
628
630
  });
631
+
632
+ describe("default ci-green flow in the conductor (#6164)", () => {
633
+ it("runs ci-green after release-pr and before review; a review blocker stops the job as blocked (exit 3) with the blockers named", async () => {
634
+ const mod = await import("./release.mjs");
635
+ const order = [], io = fakeIo();
636
+ const rec = (n, r = {}) => async () => { order.push(n); return r; };
637
+ const steps = mod.withStubs({ "ci-green": rec("ci-green"), review: rec("review"), fixes: async () => ({ blocked: true, held: true, reason: "review blockers #101 #102; release PR #7 closed; the next release starts fresh after they merge" }), "post-merge": ok });
638
+ const out = await mod.runRelease({ io, repo: REPO, root: tmp(), mounts: DISK, id: newReleaseId(), opts: { merge: true }, config: {}, branches: { staging: "staging", default: "main" }, steps: { ...steps, preflight: ok, "release-pr": rec("release-pr", { pr: 7, head: HEAD }) } });
639
+ assert.deepEqual(order, ["release-pr", "ci-green", "review"]);
640
+ assert.equal(out.status, "blocked"); assert.equal(out.step, "fixes"); assert.match(out.reason, /^review blockers #101 #102/);
641
+ });
642
+ it("release.block_severity and release.ci_green_max_wait_min only tune the default; absent keys leave it on", () => {
643
+ const c = readReleaseConfig("release:\n block_severity: medium\n ci_green_max_wait_min: 15\n");
644
+ assert.equal(c.blockSeverity, "MEDIUM"); assert.deepEqual(c.ciGreen, { maxWaitMin: 15 });
645
+ assert.equal(readReleaseConfig("release:\n auto_merge: true\n").ciGreen, undefined);
646
+ assert.equal(readReleaseConfig("release:\n auto_merge: true\n").reviewFixes, undefined, "review fix lanes are off unless release.review_fixes: true (compatibility)");
647
+ assert.equal(readReleaseConfig("release:\n review_fixes: true\n").reviewFixes, true);
648
+ });
649
+ });
@@ -11,6 +11,7 @@ import { basename, dirname, join } from "node:path";
11
11
  import { cpus, hostname } from "node:os";
12
12
  import { bearerOk, call, readJson, route, sameSecret, send } from "./http.mjs";
13
13
  import { repoRoot, versionOf, laneImageTag, laneBuildArgs } from "./version.mjs";
14
+ import { provideLaneImage } from "./lane-image.mjs";
14
15
  import { jsonStore } from "./store.mjs";
15
16
  import { makeWarm } from "./warm.mjs";
16
17
  import { resolveLaneImage, laneImageNow, laneToolsTag, isLaneToolsTagOf } from "./lane-tools.mjs";
@@ -1060,10 +1061,10 @@ export function createAgent(cfg, { docker, now = () => Date.now(), log = console
1060
1061
  if (want.image !== running.image || want.version !== running.version) {
1061
1062
  const nextImage = cfg.image && cfg.image !== "computeshare-lane:1" ? cfg.image : laneImageTag(want.version);
1062
1063
  log.info?.(`rebuilding ${nextImage} (${running.version}/${running.image} -> ${want.version}/${want.image})`);
1063
- // 2026-11-26: a host pre-seeded with the image (docker load from another host) skips the build: on a slow or memory-tight
1064
- // host the build itself is the risk (an upgrade build coincided with a host crash)
1065
- if (await docker.hasImage?.(nextImage)) log.info?.(`${nextImage} already present; no build`);
1066
- else await buildWithRetry(() => docker.build(join(next, "pool", "image"), nextImage, laneBuildArgs(want.version)), { log }); // #5919
1064
+ // #6166: present (pre-seeded) -> pull the published image -> local build only as the fallback
1065
+ const how = await provideLaneImage({ docker, image: nextImage, version: want.version, recipe: want.image, publishable: nextImage === laneImageTag(want.version), log,
1066
+ build: () => buildWithRetry(() => docker.build(join(next, "pool", "image"), nextImage, laneBuildArgs(want.version, want.image)), { log }) }); // #5919
1067
+ log.info?.(`${nextImage}: ${how}`);
1067
1068
  }
1068
1069
  await pruneLaneImages([laneImageTag(want.version)]);
1069
1070
  await prepullImages();
@@ -1232,9 +1233,8 @@ export function createAgent(cfg, { docker, now = () => Date.now(), log = console
1232
1233
 
1233
1234
  /** Build the lane image for the running ForgeDock version when this host does not have it yet. */
1234
1235
  async function ensureImage() {
1235
- if (await docker.hasImage?.(image)) { await pruneLaneImages(); return; }
1236
- log.info?.(`building ${image}`);
1237
- await docker.build(join(cfg.code_root ?? repoRoot, "pool", "image"), image, laneBuildArgs(running.version));
1236
+ await provideLaneImage({ docker, image, version: running.version, recipe: running.image, publishable: image === laneImageTag(running.version), log,
1237
+ build: () => docker.build(join(cfg.code_root ?? repoRoot, "pool", "image"), image, laneBuildArgs(running.version, running.image)) });
1238
1238
  await pruneLaneImages();
1239
1239
  }
1240
1240
 
@@ -81,6 +81,10 @@ export const dockerCli = {
81
81
  return out ? out.split("\n").filter(Boolean) : [];
82
82
  },
83
83
  async pull(image) { return docker(["pull", "-q", image], { timeoutMs: 30 * 60000 }); },
84
+ /** #6166: retags a local image (the pulled ghcr.io image becomes forgedock-lane:<version>). */
85
+ async tag(src, dst) { return docker(["tag", src, dst], { timeoutMs: 30000 }); },
86
+ /** #6166: one label of a local image ("" when unset or the image is missing). */
87
+ async imageLabel(ref, label) { try { return await docker(["image", "inspect", "--format", `{{index .Config.Labels "${label}"}}`, ref], { timeoutMs: 20000 }); } catch { return ""; } },
84
88
  async load(file) { return docker(["load", "-q", "-i", file], { timeoutMs: 30 * 60000 }); },
85
89
  async hasImage(ref) { try { await docker(["image", "inspect", ref], { timeoutMs: 20000 }); return true; } catch { return false; } },
86
90
  /** {name: {cpu (cores), mem_gb}} for running containers with the label. */
@@ -0,0 +1,84 @@
1
+ // SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
2
+ // SPDX-License-Identifier: AGPL-3.0-or-later
3
+ // #6166: a pool host gets the lane image by PULLING the one publish.yml built (ghcr.io), and builds locally only when the pull fails.
4
+ import { readFileSync, writeFileSync } from "node:fs";
5
+ import { resolve4 } from "node:dns/promises";
6
+
7
+ export const LANE_REGISTRY_IMAGE = "ghcr.io/rapiercraftstudios/forgedock-lane";
8
+ /** Label the Dockerfile stamps with the recipe hash (versionOf().image); checked after a pull. */
9
+ export const RECIPE_LABEL = "forgedock.recipe";
10
+ /** Hosts dockerd contacts for a pull from ghcr.io and for a build FROM docker.io (the IPv4 pins cover exactly these). */
11
+ export const REGISTRY_HOSTS = ["ghcr.io", "pkg-containers.githubusercontent.com", "registry-1.docker.io", "auth.docker.io", "production.cloudflare.docker.com"];
12
+ /** dockerd/BuildKit dial the AAAA record and do not fall back to A (WSL mirrored networking has no IPv6 route). */
13
+ export const IPV6_DIAL_RE = /cannot assign requested address|network is unreachable|dial tcp \[[0-9a-f:]+\]/i;
14
+ const PIN_MARK = "# forgedock-ipv4-pin";
15
+
16
+ const errText = (e) => String(e?.stderr || e?.stdout || e?.message || e || "");
17
+
18
+ /** Remote ref of the lane image for a ForgeDock version. */
19
+ export const remoteLaneImage = (version) => `${LANE_REGISTRY_IMAGE}:${version}`;
20
+ /** Tag carrying the image recipe hash, pushed beside the version tag (identifies the recipe independent of a version bump). */
21
+ export const remoteRecipeImage = (recipe) => `${LANE_REGISTRY_IMAGE}:r-${recipe}`;
22
+
23
+ let pinDepth = 0; // concurrent pins share one /etc/hosts edit; the last one out removes it
24
+ /**
25
+ * Run `fn` with temporary /etc/hosts IPv4 pins for the registry hosts (lines tagged `# forgedock-ipv4-pin`), removed afterwards,
26
+ * also stale ones left by a crashed agent. Needs write access to the hosts file (the agent runs as root); throws when it has none.
27
+ */
28
+ export async function withIpv4Pins(fn, { hosts = REGISTRY_HOSTS, file = "/etc/hosts", resolve = resolve4, log = null } = {}) {
29
+ const strip = (t) => t.split("\n").filter((l) => !l.includes(PIN_MARK)).join("\n");
30
+ if (pinDepth === 0) {
31
+ const lines = [];
32
+ for (const h of hosts) { try { const [ip] = await resolve(h); if (ip) lines.push(`${ip} ${h} ${PIN_MARK}`); } catch { /* no A record: leave that host alone */ } }
33
+ if (!lines.length) throw new Error("ipv4 pins: no A records resolved");
34
+ const cur = readFileSync(file, "utf8");
35
+ writeFileSync(file, `${strip(cur).replace(/\n*$/, "\n")}${lines.join("\n")}\n`);
36
+ log?.info?.(`pinned IPv4 for ${lines.length} registry hosts in ${file}`);
37
+ }
38
+ pinDepth++;
39
+ try { return await fn(); } finally {
40
+ if (--pinDepth === 0) { try { writeFileSync(file, strip(readFileSync(file, "utf8")).replace(/\n*$/, "\n")); } catch (e) { log?.warn?.(`could not remove IPv4 pins from ${file}: ${errText(e)}`); } }
41
+ }
42
+ }
43
+
44
+ /** Run `op`; on an IPv6 dial error retry it once under temporary IPv4 pins. A host that cannot pin reports the original error. */
45
+ export async function withIpv4Fallback(op, pinOpts = {}) {
46
+ try { return await op(); } catch (e) {
47
+ if (!IPV6_DIAL_RE.test(errText(e))) throw e;
48
+ pinOpts.log?.warn?.(`IPv6 dial error; retrying with IPv4 pins: ${errText(e).slice(-300)}`);
49
+ try { return await withIpv4Pins(op, pinOpts); } catch (e2) { if (e2 === e || IPV6_DIAL_RE.test(errText(e2))) throw e2; throw e; }
50
+ }
51
+ }
52
+
53
+ /**
54
+ * Pull the published lane image, retag it as `image` and verify its recipe label equals `recipe`. Resolves true on success;
55
+ * a mismatched image is removed again (it must never serve lanes) and rejects.
56
+ */
57
+ export async function pullLaneImage({ docker, image, version, recipe, log = null, pinOpts = {} }) {
58
+ const remote = remoteLaneImage(version);
59
+ await withIpv4Fallback(() => docker.pull(remote), { ...pinOpts, log });
60
+ const got = await docker.imageLabel(remote, RECIPE_LABEL);
61
+ if (got !== recipe) {
62
+ try { await docker.removeImage?.(remote); } catch { /* best effort */ }
63
+ throw new Error(`pulled ${remote} has recipe ${got || "(none)"}, want ${recipe}`);
64
+ }
65
+ await docker.tag(remote, image);
66
+ return true;
67
+ }
68
+
69
+ /**
70
+ * Make `image` exist locally: already present, else pulled (only the default `forgedock-lane:<version>` tag has a published
71
+ * counterpart), else built by `build()`. Resolves "present" | "pulled" | "built". `build` is wrapped in the IPv4 fallback too.
72
+ */
73
+ export async function provideLaneImage({ docker, image, version, recipe, publishable = true, build, log = null, pinOpts = {} }) {
74
+ if (await docker.hasImage?.(image)) return "present";
75
+ if (publishable && recipe && docker.pull && docker.tag && docker.imageLabel) {
76
+ try {
77
+ await pullLaneImage({ docker, image, version, recipe, log, pinOpts });
78
+ log?.info?.(`${image} pulled from ${remoteLaneImage(version)}; no build`);
79
+ return "pulled";
80
+ } catch (e) { log?.warn?.(`pull of ${remoteLaneImage(version)} failed, building locally: ${errText(e).slice(-300)}`); }
81
+ }
82
+ await withIpv4Fallback(build, { ...pinOpts, log });
83
+ return "built";
84
+ }
@@ -25,7 +25,7 @@ export function versionOf(root = repoRoot) {
25
25
 
26
26
  /** The lane image is tagged and built from the ForgeDock package version (no separate pin). */
27
27
  export const laneImageTag = (version) => `forgedock-lane:${version}`;
28
- export const laneBuildArgs = (version) => ({ FORGEDOCK_VERSION: version });
28
+ export const laneBuildArgs = (version, recipe) => ({ FORGEDOCK_VERSION: version, ...(recipe ? { FORGEDOCK_RECIPE: recipe } : {}) });
29
29
 
30
30
  /** Numeric dotted-version compare (1.10 > 1.9): negative, 0 or positive; null when either side is not a version. */
31
31
  export function cmpVersion(a, b) {
@@ -33,7 +33,7 @@ import { attemptGuard } from "./lean/release-flakes.mjs";
33
33
  import { requiredChecksRead } from "./lean/effects.mjs";
34
34
 
35
35
  const INSTALL_ROOT = fileURLToPath(new URL("..", import.meta.url));
36
- const USAGE = "usage: forgedock review-staging [<PR number|PR URL>] [--thorough | --delta <from-sha>] [--json]\n" +
36
+ const USAGE = "usage: forgedock review-staging [<PR number|PR URL>] [--thorough | --delta <from-sha>] [--allow-ci-pending | --gate-only] [--json]\n" +
37
37
  " forgedock review-staging [<PR>] --finalize --test-gate-output <file> [--notes-dropped <n>] [--json]\n" +
38
38
  " forgedock review-staging [<PR>] --summary [--filed <issue>]... [--json]\n" +
39
39
  " forgedock review-staging [<PR>] --post-reviewer <domain> --body-file <file>";
@@ -53,13 +53,15 @@ class Stop extends Error {
53
53
 
54
54
  /** argv -> {pr, thorough, json, mode, testGateOutput, notesDropped, filed, delta}. Throws Stop(2) on anything else. */
55
55
  export function parseArgs(argv) {
56
- const o = { pr: null, thorough: false, json: false, mode: "pre", testGateOutput: null, notesDropped: 0, filed: [], delta: null, domain: null, bodyFile: null };
56
+ const o = { pr: null, thorough: false, json: false, mode: "pre", testGateOutput: null, notesDropped: 0, filed: [], delta: null, domain: null, bodyFile: null, allowCiPending: false, gateOnly: false };
57
57
  const setMode = (m, a) => { if (o.mode !== "pre") throw new Stop(2, [`review-staging: ${a} cannot be combined with --${o.mode}`, USAGE]); o.mode = m; };
58
58
  const value = (i, a) => { const v = argv[i + 1]; if (v == null || v.startsWith("--")) throw new Stop(2, [`review-staging: ${a} requires a value`, USAGE]); return v; };
59
59
  for (let i = 0; i < argv.length; i++) {
60
60
  const a = argv[i];
61
61
  if (a === "--thorough") o.thorough = true;
62
62
  else if (a === "--json") o.json = true;
63
+ else if (a === "--allow-ci-pending") o.allowCiPending = true;
64
+ else if (a === "--gate-only") o.gateOnly = true;
63
65
  else if (a === "--finalize") setMode("finalize", a);
64
66
  else if (a === "--summary") setMode("summary", a);
65
67
  else if (a === "--post-reviewer") { setMode("post-reviewer", a); o.domain = value(i++, a); }
@@ -90,6 +92,7 @@ export function parseArgs(argv) {
90
92
  if (o.mode !== "post-reviewer" && o.bodyFile) throw new Stop(2, ["review-staging: --body-file belongs to --post-reviewer", USAGE]);
91
93
  if (o.mode !== "finalize" && (o.testGateOutput != null || o.notesDropped)) throw new Stop(2, ["review-staging: --test-gate-output/--notes-dropped belong to --finalize", USAGE]);
92
94
  if (o.mode !== "summary" && o.filed.length) throw new Stop(2, ["review-staging: --filed belongs to --summary", USAGE]);
95
+ if (o.mode !== "pre" && (o.gateOnly || o.allowCiPending)) throw new Stop(2, ["review-staging: --allow-ci-pending belongs to the pre-dispatch", USAGE]);
93
96
  if (o.mode !== "pre" && o.thorough) throw new Stop(2, ["review-staging: --thorough belongs to the pre-dispatch", USAGE]);
94
97
  if (o.mode !== "pre" && o.delta) throw new Stop(2, ["review-staging: --delta belongs to the pre-dispatch (--finalize reads it from the review context)", USAGE]);
95
98
  if (o.thorough && o.delta) throw new Stop(2, ["review-staging: --delta cannot be combined with --thorough", USAGE]);
@@ -233,6 +236,28 @@ async function retryGh(io, args) {
233
236
  }
234
237
  }
235
238
 
239
+ /** Phase 0A: the bundle PR set, then the open review-finding gate. Throws Stop(1) on a block. @returns {{common, branches, prsFile, gate}} */
240
+ async function bundleAndGate(io, c, pr, sd, env) {
241
+ const common = ["--repo", c.ghRepo, "--pr", String(pr)];
242
+ const branches = ["--default", c.defaultBranch, "--staging", c.stagingBranch];
243
+ const prsFile = join(sd, `${pr}_bundle-prs.txt`);
244
+ const b = await bash(io, "review-staging-pre.sh", ["bundle", ...common, ...branches, "--sd", sd], env);
245
+ if (b.stdout.trim()) io.err(b.stdout.trim());
246
+ if (b.code !== 0) throw new Stop(1, [b.stderr.trim(), `REVIEW_RESULT: status: BLOCKED, blocker: bundle PR set failed (exit ${b.code})`].filter(Boolean));
247
+ let bundlePrs = "";
248
+ try { bundlePrs = io.readFile(prsFile); } catch { /* unreadable: fail closed below */ }
249
+ // An empty bundle would let the gate pass vacuously (forge#4470): nothing gated is never a pass.
250
+ if (!bundlePrs.split("\n").some((l) => /^\d+$/.test(l.trim()))) throw new Stop(1, [`REVIEW_RESULT: status: BLOCKED, blocker: bundle PR set is empty or unreadable (${prsFile}); nothing gated (fail closed)`]);
251
+ const g = await bash(io, "review-staging-pre.sh", ["gate", ...common, "--prs-file", prsFile], env);
252
+ if (g.code !== 0) {
253
+ const out = g.stdout.trim();
254
+ throw new Stop(1, [out, g.stderr.trim(), /RESULT: BLOCK DEPLOY/.test(out) ? "" : "RESULT: BLOCK DEPLOY"].filter(Boolean));
255
+ }
256
+ const gate = /human override/.test(g.stdout) ? "PASS (override)" : "PASS";
257
+
258
+ return { common, branches, prsFile, gate };
259
+ }
260
+
236
261
  async function main(argv, io) {
237
262
  const a = parseArgs(argv);
238
263
  if (a.mode === "finalize") return finalize(a, io);
@@ -249,6 +274,11 @@ async function main(argv, io) {
249
274
  const head = await headSha(io, c, pr);
250
275
  if (a.delta && a.delta === head) throw new Stop(1, [`REVIEW_RESULT: status: BLOCKED, blocker: --delta ${head} is the current head of PR #${pr}: nothing changed since that pass, nothing to review`]);
251
276
  const sha7 = head.slice(0, 7);
277
+ if (a.gateOnly) { // the release job's first check: an open review-finding issue blocks before CI or any reviewer; posts only the gate marker
278
+ const { gate } = await bundleAndGate(io, c, pr, sd, env);
279
+ io.out(a.json ? JSON.stringify({ pr, headSha: head, gate }) : `OPEN_FINDING_GATE: ${gate} on PR #${pr}`);
280
+ return 0;
281
+ }
252
282
  // #4865: with selftest.sandbox_repo set, the release needs a passing live selftest for exactly this head (fail closed).
253
283
  // Without a sandbox repo there is nothing the harness can run against, so the gate is skipped and says so.
254
284
  if (c.sandboxRepo) {
@@ -264,26 +294,14 @@ async function main(argv, io) {
264
294
  } catch { /* unreadable: treated as a first pass */ }
265
295
  const priorOpen = priorRoutes > 0 ? await priorFindings(io, c, pr, "open") : [];
266
296
  const priorResolved = priorRoutes > 0 ? await priorFindings(io, c, pr, "closed") : [];
267
- await retryGh(io, ["pr", "comment", String(pr), "-R", c.ghRepo, "--body", `<!-- FORGE:REVIEW_ROUTE mode=staging-deploy spec=review-pr-staging.md sha=${sha7} -->`]);
297
+ await retryGh(io, ["pr", "comment", String(pr), "-R", c.ghRepo, "--body", `<!-- FORGE:REVIEW_ROUTE mode=staging-deploy spec=review-pr-staging.md sha=${sha7}${a.allowCiPending ? " allow_ci_pending=true" : ""} -->`]);
268
298
  io.writeFile(join(sd, `staging_pr_number.${runKey(io.env)}`), `${pr}\n`);
269
299
 
270
- // 0A: bundle PR set, then the open review-finding gate
271
- const common = ["--repo", c.ghRepo, "--pr", String(pr)];
272
- const branches = ["--default", c.defaultBranch, "--staging", c.stagingBranch];
273
- const prsFile = join(sd, `${pr}_bundle-prs.txt`);
274
- const b = await bash(io, "review-staging-pre.sh", ["bundle", ...common, ...branches, "--sd", sd], env);
275
- if (b.stdout.trim()) io.err(b.stdout.trim());
276
- if (b.code !== 0) throw new Stop(1, [b.stderr.trim(), `REVIEW_RESULT: status: BLOCKED, blocker: bundle PR set failed (exit ${b.code})`].filter(Boolean));
277
- let bundlePrs = "";
278
- try { bundlePrs = io.readFile(prsFile); } catch { /* unreadable: fail closed below */ }
279
- // An empty bundle would let the gate pass vacuously (forge#4470): nothing gated is never a pass.
280
- if (!bundlePrs.split("\n").some((l) => /^\d+$/.test(l.trim()))) throw new Stop(1, [`REVIEW_RESULT: status: BLOCKED, blocker: bundle PR set is empty or unreadable (${prsFile}); nothing gated (fail closed)`]);
281
- const g = await bash(io, "review-staging-pre.sh", ["gate", ...common, "--prs-file", prsFile], env);
282
- if (g.code !== 0) {
283
- const out = g.stdout.trim();
284
- throw new Stop(1, [out, g.stderr.trim(), /RESULT: BLOCK DEPLOY/.test(out) ? "" : "RESULT: BLOCK DEPLOY"].filter(Boolean));
285
- }
286
- const gate = /human override/.test(g.stdout) ? "PASS (override)" : "PASS";
300
+ // 0A: bundle PR set, then the open review-finding gate (it runs first: an open finding blocks before CI or any reviewer)
301
+ const { common, branches, prsFile, gate } = await bundleAndGate(io, c, pr, sd, env);
302
+ // CI green next (default, no off switch): a review of a head whose required checks are pending or red is wasted when CI then moves the head.
303
+ const ciBlock = a.allowCiPending ? null : await ciNotGreen(io, c, pr, env);
304
+ if (ciBlock) throw new Stop(1, [`REVIEW_RESULT: status: BLOCKED, blocker: CI not green on ${sha7} (pending: ${ciBlock.pending.join(", ") || "none"}, failing: ${ciBlock.failing.join(", ") || "none"}); review starts after CI is green`]);
287
305
 
288
306
  // 0B.1: scope
289
307
  const s = await bash(io, "review-staging-pre.sh", ["scope", ...common, ...branches, "--prs-file", prsFile, "--sd", sd], env);
@@ -492,7 +510,7 @@ async function finalize(a, io) {
492
510
  const items = worklist.items;
493
511
  const state = {
494
512
  pr, head, bundle, codeBranch, scopeMode, delta, testGate: { verdict: tg.verdict, reason: tg.reason }, counts, notes,
495
- confirmedCritical: confirmed("CRITICAL"), confirmedHigh: confirmed("HIGH"), resolved,
513
+ confirmedCritical: confirmed("CRITICAL"), confirmedHigh: confirmed("HIGH"), confirmedMedium: confirmed("MEDIUM"), confirmedIds: findings.filter((f) => !resolvedBy.has(f.id) && upper(f.confidence) === "CONFIRMED").map((f) => f.id), resolved,
496
514
  toFile: items.filter((i) => i.action === "file"), skipped: items.filter((i) => String(i.action).startsWith("skip-")),
497
515
  };
498
516
  io.writeFile(join(sd, `${pr}_finalize.json`), JSON.stringify(state));
@@ -567,6 +585,30 @@ export function cancelOnlyChecks(checks, required = []) {
567
585
  return [...seen.values()];
568
586
  }
569
587
 
588
+ /** Required checks on the head, by state: `pending` (running, or required but not reported yet) and `failing` (fail/cancel and not pending). */
589
+ export function ciState(checks, required = []) {
590
+ const rows = redChecks(checks, required).blockRows;
591
+ const names = (f) => [...new Set(rows.filter(f).map((k) => String(k.name)))];
592
+ const pend = names((k) => k.bucket === "pending");
593
+ const seen = new Set(checks.map((k) => k?.name));
594
+ const missing = [...new Set(required)].filter((n) => !CI_EXCLUDED_CHECKS.includes(n) && !seen.has(n));
595
+ const pending = [...new Set([...pend, ...missing])];
596
+ return { pending, failing: names((k) => k.bucket === "fail" || k.bucket === "cancel").filter((n) => !pending.includes(n)), green: !pending.length && !rows.length };
597
+ }
598
+
599
+ /** Pre-dispatch CI read: `null` when green (or the PR has no checks), else `{pending, failing}`. An unreadable read fails closed. */
600
+ async function ciNotGreen(io, c, pr, env) {
601
+ const r = await io.run("gh", ["pr", "checks", String(pr), "-R", c.ghRepo, "--json", "name,bucket,link"], { env, cwd: io.cwd });
602
+ const checks = r.code === 0 || r.code === 8 ? parseChecks(r.stdout) : null;
603
+ if (!checks) {
604
+ if (/no checks reported/i.test(`${r.stderr ?? ""}${r.stdout ?? ""}`)) return null;
605
+ return { pending: [], failing: ["checks unreadable"] };
606
+ }
607
+ const read = await requiredChecksRead({ gh: io.gh, repo: c.ghRepo, lane: c.defaultBranch });
608
+ const st = ciState(checks, requiredSet(read, c.extraRequiredChecks));
609
+ return st.green ? null : st;
610
+ }
611
+
570
612
  const CI_POLL_MS = 20_000, CI_POLL_MAX = 45;
571
613
 
572
614
  /** One `gh run rerun --failed` per cancelled run of the cancel-only required checks (#6014: never past RERUN_ATTEMPT_CAP reruns of a run), then wait until none of them is pending. @returns the re-read checks, or `checks` when nothing could be rerun. */
@@ -89,7 +89,7 @@ The **Evidence-Based Review Protocol** and **Structured Findings Protocol** are
89
89
 
90
90
  ## Step 1: Pre-dispatch (`forgedock review-staging`)
91
91
 
92
- **This step is MANDATORY and runs first. No step may be skipped.** One CLI call runs the deterministic pre-dispatch (forge#4358): the `FORGE:REVIEW_ROUTE` marker (route assertion and audit trail), prior-finding awareness on re-entry, the Phase 0A bundle PR set and open review-finding gate (it posts `FORGE:GATE_FAILURE` / `FORGE:GATE_PASS` and stops on a block, including degraded bundle panels), the 0B.1 bundle review scope (`scripts/review-staging-pre.sh`), the 0C prepare (`scripts/review-prepare.sh --no-delta --build-gate advisory`) and the risk-tiered roster (`scripts/review-roster.sh`, inside prepare). It writes one reviewer brief per roster domain and truncates the PR-keyed launched-agent file. All state lives in `$FORGE_SCRATCHPAD` (default `$PWD/.forge-scratch`) under the PR-keyed names the later steps read. Every helper comes from the ForgeDock install, never from the repo under review.
92
+ **This step is MANDATORY and runs first. No step may be skipped.** Order: the open-finding gate, then CI green, then one review pass (the v1.0 contract). The call refuses (`REVIEW_RESULT: status: BLOCKED, blocker: CI not green on <sha> (pending: ..., failing: ...)`) while a required check on the head is pending or failing, also with `--delta`; wait for green (the release job does this in its `ci-green` step) and rerun. `--allow-ci-pending` overrides and is recorded in the `FORGE:REVIEW_ROUTE` marker. One CLI call runs the deterministic pre-dispatch (forge#4358): the `FORGE:REVIEW_ROUTE` marker (route assertion and audit trail), prior-finding awareness on re-entry, the Phase 0A bundle PR set and open review-finding gate (it posts `FORGE:GATE_FAILURE` / `FORGE:GATE_PASS` and stops on a block, including degraded bundle panels), the 0B.1 bundle review scope (`scripts/review-staging-pre.sh`), the 0C prepare (`scripts/review-prepare.sh --no-delta --build-gate advisory`) and the risk-tiered roster (`scripts/review-roster.sh`, inside prepare). It writes one reviewer brief per roster domain and truncates the PR-keyed launched-agent file. All state lives in `$FORGE_SCRATCHPAD` (default `$PWD/.forge-scratch`) under the PR-keyed names the later steps read. Every helper comes from the ForgeDock install, never from the repo under review.
93
93
 
94
94
  **Idempotent re-review (merge-train aware)**: <!-- Added: forge#1328, extended: forge#1332 --> This spec is safe to invoke multiple times on the same PR. Each invocation posts a new `FORGE:REVIEW_ROUTE` marker with the current SHA, so re-review passes are distinguished by SHA, not by PR number. Prior open findings are carried forward into the briefs (do not re-file them). Prior resolved findings are excluded from the verdict.
95
95
 
package/docs/CONFIG.md CHANGED
@@ -850,6 +850,26 @@ release:
850
850
 
851
851
  `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.
852
852
 
853
+ ### Default release flow: the v1.0 contract (#6164)
854
+
855
+ `forgedock release` and `forgedock review-staging` follow the original release contract of `commands/review-pr-staging.md` (commit dcfb86bf, 2026-06-05), restored as the default for every repo. There is no switch to turn it off.
856
+
857
+ 1. **Open-finding gate first**: an open `review-finding` issue blocks the release before CI or any reviewer.
858
+ 2. **`ci-green` step** before `review`: waits for every required check on the release PR head (protection, rulesets and `gate.required_checks`; `forgedock/verify`, `forge/deploy-gate` and the gate-marker check excluded). A failed check is rerun once; a pass on the rerun counts as green and files a `flaky-test` issue naming the test when the log shows it. A check still red after its rerun gets one CI fix round in the release PR, then CI is awaited again. A draft release PR (host preflight mode) has no Actions CI yet, so the step skips it.
859
+ 3. **One review pass** on the green head. Every finding is filed as an issue (Phase 7). Nothing the review finds is fixed inside the release PR: no review fix lanes and no review-driven delta passes. A head that moves during review stops the job; re-run it.
860
+ 4. **Verdict**: a CONFIRMED CRITICAL/HIGH finding (or a failed guard) means BLOCK. The job stops with `blocked: review blockers #A #B`, the release PR is closed, the blocker issues are added to the repo's open orchestrate batch (`orchestrate --add`) when one exists, and the next release starts fresh after they merge (the open-finding gate enforces it). Without blockers the release merges on GATE_PASS and everything else stays filed for later.
861
+ 5. `forgedock review-staging <PR>` pre-dispatch (also `--delta`) runs the gate, then refuses while a required check is pending or failing (`CI not green on <sha> (pending: ..., failing: ...)`); `--allow-ci-pending` overrides and is recorded in the route marker. `--gate-only` runs just the open-finding gate.
862
+ 6. `release status` prints `timing`: `ci_green_min`, `review_min`, `fix_rounds`, `review_passes`; the release ledger mirrors them.
863
+
864
+ Drift this removes: #4358 and #4360 (pre-dispatch and delta passes in the review loop), #5212 (review step fix lanes and delta passes), #5567 (CI and panel started on the same head, `ci.fix.co_start`, now ignored).
865
+
866
+ ```yaml
867
+ release:
868
+ block_severity: high # lowest blocking severity: critical | high | medium (default high)
869
+ ci_green_max_wait_min: 40 # how long ci-green waits for pending checks before it blocks (max 240)
870
+ review_fixes: false # compatibility only: true restores the #5212 review fix lanes and delta passes
871
+ ```
872
+
853
873
  ### `.forge/release.yaml` (#5551)
854
874
 
855
875
  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`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "forgedock",
3
- "version": "1.69.0",
3
+ "version": "1.71.0",
4
4
  "description": "An AI engineering team that ships to production",
5
5
  "bin": {
6
6
  "forgedock": "bin/forgedock.mjs"
@@ -16,13 +16,15 @@ ARG POETRY_VERSION=2.4.3
16
16
  ARG YQ_VERSION=4.44.3
17
17
  ARG PLAYWRIGHT_VERSION=1.49.1
18
18
 
19
- LABEL org.opencontainers.image.version=$FORGEDOCK_VERSION
19
+ # Image recipe hash (versionOf().image); pool agents check it after pulling the published image (#6166).
20
+ ARG FORGEDOCK_RECIPE=
21
+ LABEL org.opencontainers.image.version=$FORGEDOCK_VERSION forgedock.recipe=$FORGEDOCK_RECIPE
20
22
  RUN test -n "$FORGEDOCK_VERSION" || { echo "FORGEDOCK_VERSION build arg is required" >&2; exit 1; }
21
23
 
22
24
  ENV IS_SANDBOX=1 DEBIAN_FRONTEND=noninteractive LANG=C.UTF-8 PLAYWRIGHT_BROWSERS_PATH=/opt/playwright UV_PYTHON_INSTALL_DIR=/opt/uv-python PATH=/opt/cs/bin:/opt/node/bin:/root/.local/bin:$PATH
23
25
 
24
26
  RUN apt-get update && apt-get install -y --no-install-recommends \
25
- ca-certificates curl git jq xz-utils build-essential python3 python3-venv python3-dev python3-yaml pkg-config libpq-dev \
27
+ ca-certificates curl git jq xz-utils build-essential python3 python3-venv python3-dev python3-yaml gnupg pkg-config libpq-dev \
26
28
  shellcheck xvfb xauth postgresql-client redis-tools \
27
29
  && install -d -m 0755 /etc/apt/keyrings \
28
30
  && curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg -o /etc/apt/keyrings/githubcli.gpg \
@@ -34,8 +36,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
34
36
 
35
37
  RUN curl -fsSL "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz" | tar -xJ -C /opt \
36
38
  && mv "/opt/node-v${NODE_VERSION}-linux-x64" /opt/node \
37
- && npm install -g "corepack@${COREPACK_VERSION}" "forgedock@${FORGEDOCK_VERSION}" "@anthropic-ai/claude-code@${CLAUDE_CODE_VERSION}" \
38
- && npm cache clean --force
39
+ && NODE_OPTIONS=--dns-result-order=ipv4first npm install -g --include=optional "corepack@${COREPACK_VERSION}" "forgedock@${FORGEDOCK_VERSION}" "@anthropic-ai/claude-code@${CLAUDE_CODE_VERSION}" \
40
+ && npm cache clean --force \
41
+ && claude --version && forgedock --version # smoke: a missing native binary (failed optional download) fails the build, never a lane
39
42
 
40
43
  RUN curl -LsSf "https://astral.sh/uv/${UV_VERSION}/install.sh" | env UV_INSTALL_DIR=/usr/local/bin sh \
41
44
  && uv tool install "poetry==${POETRY_VERSION}" \