forgedock 1.56.0 → 1.58.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/bin/config-schema.mjs +1 -1
  2. package/bin/engine/outcome-codes.mjs +2 -1
  3. package/bin/engine/phases.mjs +4 -3
  4. package/bin/engine-cli.mjs +48 -12
  5. package/bin/forgedock.mjs +52 -3
  6. package/bin/gc.mjs +43 -6
  7. package/bin/help-text.mjs +4 -2
  8. package/bin/lean/batch-health.mjs +5 -1
  9. package/bin/lean/batch-health.test.mjs +7 -1
  10. package/bin/lean/batch.mjs +7 -2
  11. package/bin/lean/batch.test.mjs +45 -0
  12. package/bin/lean/conformance.e2e.test.mjs +3 -2
  13. package/bin/lean/conformance.mjs +118 -20
  14. package/bin/lean/conformance.test.mjs +172 -3
  15. package/bin/lean/decisions.mjs +98 -1
  16. package/bin/lean/decisions.test.mjs +30 -1
  17. package/bin/lean/depcache.mjs +124 -13
  18. package/bin/lean/depcache.test.mjs +121 -3
  19. package/bin/lean/design-gate.mjs +144 -0
  20. package/bin/lean/design-gate.test.mjs +169 -0
  21. package/bin/lean/effects-cap.test.mjs +17 -0
  22. package/bin/lean/effects.mjs +58 -13
  23. package/bin/lean/heavy.mjs +25 -8
  24. package/bin/lean/hostload.test.mjs +28 -0
  25. package/bin/lean/intake.mjs +97 -0
  26. package/bin/lean/intake.test.mjs +105 -0
  27. package/bin/lean/interfaces.mjs +181 -0
  28. package/bin/lean/interfaces.test.mjs +192 -0
  29. package/bin/lean/issuewatch-install.mjs +52 -12
  30. package/bin/lean/issuewatch-install.test.mjs +50 -0
  31. package/bin/lean/issuewatch-parity.mjs +16 -3
  32. package/bin/lean/issuewatch-parity.test.mjs +32 -0
  33. package/bin/lean/issuewatch-reconcile.mjs +29 -1
  34. package/bin/lean/issuewatch-reconcile.test.mjs +21 -0
  35. package/bin/lean/issuewatch.mjs +34 -3
  36. package/bin/lean/issuewatch.test.mjs +49 -1
  37. package/bin/lean/lanecheck.test.mjs +15 -4
  38. package/bin/lean/lean.mjs +110 -24
  39. package/bin/lean/lean.test.mjs +183 -4
  40. package/bin/lean/orchestrate-blocked.test.mjs +18 -2
  41. package/bin/lean/orchestrate-owned.test.mjs +14 -5
  42. package/bin/lean/orchestrate.mjs +26 -4
  43. package/bin/lean/orphan-pr.mjs +3 -2
  44. package/bin/lean/orphan-pr.test.mjs +8 -1
  45. package/bin/lean/pagegate.mjs +35 -12
  46. package/bin/lean/pagegate.test.mjs +39 -1
  47. package/bin/lean/preflight.mjs +35 -1
  48. package/bin/lean/preflight.test.mjs +27 -1
  49. package/bin/lean/prompts.mjs +2 -1
  50. package/bin/lean/reap.test.mjs +39 -0
  51. package/bin/lean/recovery.test.mjs +28 -3
  52. package/bin/lean/release-config.mjs +169 -0
  53. package/bin/lean/release-config.test.mjs +132 -0
  54. package/bin/lean/release-control.mjs +171 -0
  55. package/bin/lean/release-control.test.mjs +167 -0
  56. package/bin/lean/release-deploy.mjs +209 -0
  57. package/bin/lean/release-deploy.test.mjs +217 -0
  58. package/bin/lean/release-fence.mjs +50 -0
  59. package/bin/lean/release-fence.test.mjs +105 -0
  60. package/bin/lean/release-flakes.mjs +139 -0
  61. package/bin/lean/release-flakes.test.mjs +116 -0
  62. package/bin/lean/release-gates.mjs +230 -0
  63. package/bin/lean/release-gates.test.mjs +146 -0
  64. package/bin/lean/release-ledger.mjs +176 -0
  65. package/bin/lean/release-ledger.test.mjs +226 -0
  66. package/bin/lean/release-minutes.mjs +102 -0
  67. package/bin/lean/release-minutes.test.mjs +107 -0
  68. package/bin/lean/release-nightly.mjs +75 -0
  69. package/bin/lean/release-nightly.test.mjs +48 -0
  70. package/bin/lean/release-postmerge.mjs +8 -2
  71. package/bin/lean/release-review.e2e.test.mjs +1 -0
  72. package/bin/lean/release-review.mjs +54 -7
  73. package/bin/lean/release-review.test.mjs +76 -7
  74. package/bin/lean/release-status.mjs +300 -0
  75. package/bin/lean/release-status.test.mjs +220 -0
  76. package/bin/lean/release-unitmap.mjs +35 -0
  77. package/bin/lean/release-unitmap.test.mjs +41 -0
  78. package/bin/lean/release-verify.mjs +221 -0
  79. package/bin/lean/release-verify.test.mjs +176 -0
  80. package/bin/lean/release.mjs +244 -22
  81. package/bin/lean/release.test.mjs +44 -0
  82. package/bin/lean/render.mjs +3 -1
  83. package/bin/lean/run-issue-placement.test.mjs +82 -0
  84. package/bin/lean/sandbox-remote.mjs +16 -0
  85. package/bin/lean/schedd.mjs +1 -1
  86. package/bin/lean/seam.mjs +115 -0
  87. package/bin/lean/seam.test.mjs +118 -0
  88. package/bin/lean/selftest-journey.mjs +40 -2
  89. package/bin/lean/selftest-journey.test.mjs +43 -3
  90. package/bin/lean/statuscomment.mjs +168 -0
  91. package/bin/lean/statuscomment.test.mjs +133 -0
  92. package/bin/lean/ui-quality.mjs +57 -0
  93. package/bin/lean/ui-quality.test.mjs +55 -0
  94. package/bin/lean/visual-gate.test.mjs +63 -0
  95. package/bin/pool/agent.mjs +16 -2
  96. package/bin/pool/router.mjs +5 -1
  97. package/bin/review-staging.mjs +5 -3
  98. package/bin/stats/card.mjs +117 -0
  99. package/bin/stats/card.test.mjs +109 -0
  100. package/bin/stats/conformance-outcomes.test.mjs +2 -1
  101. package/bin/stats/depth.mjs +1 -1
  102. package/bin/stats/gh-retry.test.mjs +152 -0
  103. package/bin/stats/github-source.mjs +147 -14
  104. package/bin/stats/index.mjs +35 -2
  105. package/bin/stats/stats.test.mjs +31 -3
  106. package/bin/vendor/js-yaml/LICENSE +21 -0
  107. package/bin/vendor/js-yaml/PIN.md +7 -0
  108. package/bin/vendor/js-yaml/js-yaml.mjs +3851 -0
  109. package/commands/design-render-critique-loop.md +2 -0
  110. package/commands/design.md +2 -0
  111. package/commands/issue.md +1 -1
  112. package/commands/milestone.md +1 -1
  113. package/commands/review-pr-agents/frontend.md +1 -0
  114. package/commands/review-pr-staging.md +5 -0
  115. package/docs/CONFIG.md +95 -2
  116. package/docs/ISSUE-WATCH.md +7 -0
  117. package/docs/OUTCOME-CODES.md +1 -0
  118. package/docs/STATS.md +10 -0
  119. package/docs/design/visual-gate.md +25 -0
  120. package/docs/eval/adversarial-bench.md +2 -2
  121. package/docs/eval/corpus/adversarial-v1.json +3 -3
  122. package/docs/site/start-a-new-project.md +7 -0
  123. package/docs/spec/forge-protocol-v1.md +31 -0
  124. package/package.json +1 -1
  125. package/pool/README.md +2 -0
  126. package/scripts/acceptance-red-green.sh +15 -1
  127. package/scripts/acceptance-red-green.test.sh +12 -0
  128. package/scripts/bench-adversarial.mjs +4 -0
  129. package/scripts/bench-lightlane.mjs +4 -1
  130. package/scripts/bootstrap-create.mjs +8 -2
  131. package/scripts/ci-local/scoping.mjs +19 -0
  132. package/scripts/ci-local.test.sh +16 -3
  133. package/scripts/fixtures/ci-local/gha-dorny/.github/workflows/ci.yml +4 -0
  134. package/scripts/plan-validate-live.mjs +9 -6
  135. package/scripts/review-prepare.sh +7 -1
  136. package/scripts/review-roster.sh +5 -2
  137. package/scripts/review-roster.test.sh +9 -0
  138. package/scripts/visual-gate.mjs +64 -0
  139. package/templates/bootstrap/technical-spike.md +17 -0
  140. package/templates/contracts/seam-check.mjs +236 -0
@@ -46,6 +46,18 @@ function fakeIo(world = {}) {
46
46
  }
47
47
  const ok = async () => ({ ok: true });
48
48
 
49
+ describe("unmanaged release carries no epoch (#5553)", () => {
50
+ it("promotion merges with the plain argv and makes no ledger call", async () => {
51
+ const mod = await import("./release.mjs");
52
+ const io = fakeIo();
53
+ io.api = async () => { throw new Error("no ledger call expected"); };
54
+ 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 }) });
55
+ assert.equal(out.status, "done");
56
+ const merge = io.calls.find((a) => a[0] === "pr" && a[1] === "merge");
57
+ assert.deepEqual(merge, ["pr", "merge", "7", "--repo", REPO, "--merge", "--match-head-commit", HEAD]);
58
+ });
59
+ });
60
+
49
61
  describe("release job (#5211)", () => {
50
62
  const promote = async (world, { opts = {}, config = {} } = {}) => {
51
63
  const io = fakeIo(world), root = tmp(), id = newReleaseId();
@@ -208,6 +220,18 @@ describe("release job (#5211)", () => {
208
220
  assert.equal(readReleaseConfig("release:\n publish_workflow: pub.yml\n").publishWorkflow, "pub.yml");
209
221
  });
210
222
 
223
+ it("#5550: managed is off by default (config shape unchanged) and then no ledger call or GitHub write is made", async () => {
224
+ assert.equal("managed" in readReleaseConfig("release:\n auto_merge: true\n"), false);
225
+ assert.equal(readReleaseConfig("release:\n managed: false\n").managed, undefined);
226
+ assert.equal(readReleaseConfig("release:\n managed: true\n").managed, true);
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
+ 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, deploy: async () => ({ skipped: true }) } });
230
+ assert.equal(out.status, "done");
231
+ assert.deepEqual(apiCalls, []);
232
+ assert.deepEqual(ghCalls, []);
233
+ });
234
+
211
235
  it("CLI: rejects unknown options and exits 3 on a blocked step, naming the resume command", async () => {
212
236
  const root = tmp(), io = fakeIo();
213
237
  await assert.rejects(() => releaseFromCli(["--bogus"], { io, env: { FORGEDOCK_RELEASE_DIR: root }, cwd: root, mounts: DISK }), /unknown option/);
@@ -420,6 +444,10 @@ describe("snapshot releases (#5276)", () => {
420
444
  assert.equal(create[create.indexOf("--head") + 1], "staging");
421
445
  });
422
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
+ });
423
451
  it("R10: `release verify <sha>` exits 0 for a head that is the snapshot, 1 for a PR without a record", async () => {
424
452
  const rec = { v: 1, snapshot: S, picks: [] };
425
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; };
@@ -445,3 +473,19 @@ describe("snapshot releases (#5276)", () => {
445
473
  assert.deepEqual((await step(undefined)).pushes, []);
446
474
  });
447
475
  });
476
+
477
+
478
+ describe("release control routing (#5556)", () => {
479
+ it("`release hold` and `release control hold` share one implementation and refuse without --reason", async () => {
480
+ for (const argv of [["hold", "r20260101-000000-1"], ["control", "hold", "r20260101-000000-1"]]) {
481
+ const out = [];
482
+ const io = { print: (l) => out.push(l), gh: async () => JSON.stringify({ nameWithOwner: "o/r" }), api: async () => { throw new Error("no api"); }, git: () => { throw new Error("none"); }, now: () => 1 };
483
+ assert.equal(await releaseFromCli([...argv, "--json"], { io, cwd: tmp() }), 1);
484
+ assert.match(out[0], /forgedock.release.control\/v1/);
485
+ assert.match(out[0], /--reason is required/);
486
+ }
487
+ });
488
+ it("an unknown control verb is an error", async () => {
489
+ await assert.rejects(releaseFromCli(["control", "nope"], { io: { print() {}, gh: async () => "" }, cwd: tmp() }), /unknown control verb/);
490
+ });
491
+ });
@@ -2,6 +2,8 @@
2
2
  // SPDX-License-Identifier: AGPL-3.0-or-later
3
3
  /** Fixed comment templates for the core work-on. Pure functions, no model calls. Missing fields read "not reported". */
4
4
 
5
+ import { visualSection } from "./ui-quality.mjs";
6
+
5
7
  export const NR = "not reported";
6
8
  export const MAX_COMMENT_CHARS = 60000;
7
9
 
@@ -192,7 +194,7 @@ export function renderPrBody({ issue, investigation, contract, implementation, r
192
194
  // #4404: requirements measured outside the lane; the change delivers their instrumentation, the named job the result
193
195
  const oob = (contract?.requirements ?? []).filter((r) => r?.verify === "out_of_band");
194
196
  const outOfBand = oob.length ? `\n\n## Verified out of band\n${oob.map((r) => `- ${escl(r.id)}: ${escl(r.quote)} (job ${r.evidence ? `\`${escl(r.evidence).replace(/`/g, "'")}\`` : "not named"})`).join("\n")}` : "";
195
- return `## Root cause\n${root}\n\n## Deliverables\n${deliver}\n\n## Verification\n${verify}${remaining}${outOfBand}\n\nCloses #${issue}`;
197
+ return `## Root cause\n${root}\n\n## Deliverables\n${deliver}\n\n## Verification\n${verify}${remaining}${outOfBand}${visualSection(implementation)}\n\nCloses #${issue}`;
196
198
  }
197
199
 
198
200
  // ---- trajectory ----
@@ -0,0 +1,82 @@
1
+ // SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
2
+ // SPDX-License-Identifier: AGPL-3.0-or-later
3
+ // #5542: `run-issue` follows forge.yaml `execution:` like `orchestrate`, and `--local` keeps the lane on this host.
4
+ import { describe, it } from "node:test";
5
+ import assert from "node:assert/strict";
6
+ import { readFileSync } from "node:fs";
7
+ import { join } from "node:path";
8
+ import { tmpDir } from "../tests/_tmp.mjs";
9
+ import { parseExecution, openExecutionBudget } from "./execution.mjs";
10
+ import { makeLedger } from "./ledger.mjs";
11
+ import { runFromCli } from "../engine-cli.mjs";
12
+
13
+ const logs = async (fn) => { const out = [], l = console.log; console.log = (x) => out.push(String(x)); try { return { res: await fn(), out }; } finally { console.log = l; } };
14
+
15
+ function fakeProvider(finish) {
16
+ const p = { name: "fake", calls: [], live: new Set(), results: {}, idFor: (n) => `fake-${n}`,
17
+ async start({ issue }) { p.calls.push(["start", issue]); p.results[issue] = finish(issue); return { provider: "fake", id: `fake-${issue}`, issue }; },
18
+ async status() { return "exited"; }, async fetchResult(h) { return p.results[h.issue] ?? null; }, async teardown() { return true; } };
19
+ return p;
20
+ }
21
+
22
+ const leanIo = { gh: async (a) => (a.includes("milestone") ? JSON.stringify({ milestone: null }) : a[0] === "repo" ? "main\n" : JSON.stringify({ body: "" })),
23
+ git: async (a) => (a[0] === "ls-remote" ? "abc\trefs/heads/staging\n" : a[0] === "rev-parse" ? ".git\n" : "") };
24
+ const setup = (name, prov, extra = {}) => {
25
+ const work = tmpDir(name);
26
+ const ran = [];
27
+ return { work, ran, deps: { env: {}, batchRoot: join(work, "batches"), allowTmpfs: true, pollMs: 5, orchestration: { breaker: null, maxDeferrals: 3 }, io: { gh: async () => "o/r\n" }, leanIo, sched: null, maintenance: null,
28
+ executionBudget: openExecutionBudget({ file: join(work, "budget.json") }), emitTelemetry: () => {}, dir: join(work, "runs"), batchId: `rp-${name}`,
29
+ execution: parseExecution({ mode: "remote", max_remote: "1", provider: "container" }), sandboxProvider: prov,
30
+ sandboxLedger: (n) => makeLedger({ root: join(work, "ledger"), batch: `rp-${name}`, lane: `sandbox-${n}`, owner: "t", issue: n }),
31
+ ...extra } };
32
+ };
33
+ const core = (ran) => ({ runCore: async (o) => { ran.push(o.placement ?? null); return { terminalReason: "merged", pr: 1 }; } });
34
+
35
+ describe("run-issue placement (#5542)", () => {
36
+ it("remote execution routes run-issue to the provider", async () => {
37
+ const prov = fakeProvider((n) => ({ terminalReason: "merged", pr: 100 + n, cost_usd: 0 }));
38
+ const { deps, work } = setup("remote", prov);
39
+ const rf = join(work, "result.json");
40
+ const { res, out } = await logs(() => runFromCli(["7", "--repo", "o/r", "--no-prefilter", "--result-file", rf], deps));
41
+ assert.deepEqual(prov.calls.filter((c) => c[0] === "start").map((c) => c[1]), [7]);
42
+ assert.equal(res.terminalReason, "merged");
43
+ assert.ok(out.some((l) => /^placement: remote/.test(l)), out.join("\n"));
44
+ });
45
+
46
+ it("--local forces local placement", async () => {
47
+ const prov = fakeProvider(() => ({ terminalReason: "merged" }));
48
+ const { deps, ran } = setup("local", prov, {});
49
+ const { out } = await logs(() => runFromCli(["7", "--repo", "o/r", "--lane", "staging", "--local"], { ...deps, leanModule: core(ran) }));
50
+ assert.equal(ran.length, 1);
51
+ assert.deepEqual(prov.calls, []);
52
+ assert.ok(out.includes("placement: local (--local)"));
53
+ });
54
+
55
+ it("an already placed lane (--placement) is not re-delegated", async () => {
56
+ const prov = fakeProvider(() => ({ terminalReason: "merged" }));
57
+ const { deps, ran } = setup("placed", prov);
58
+ await logs(() => runFromCli(["7", "--repo", "o/r", "--lane", "staging", "--placement", "remote", "--placement-reason", "mode remote"], { ...deps, leanModule: core(ran) }));
59
+ assert.equal(ran.length, 1);
60
+ assert.equal(ran[0].where, "remote");
61
+ assert.deepEqual(prov.calls, []);
62
+ });
63
+
64
+ it("no execution config runs locally and says so", async () => {
65
+ const prov = fakeProvider(() => ({ terminalReason: "merged" }));
66
+ const { deps, ran } = setup("none", prov, { execution: undefined });
67
+ const { out } = await logs(() => runFromCli(["7", "--repo", "o/r", "--lane", "staging"], { ...deps, leanModule: core(ran) }));
68
+ assert.equal(ran.length, 1);
69
+ assert.ok(out.some((l) => /^placement: local/.test(l)));
70
+ });
71
+
72
+ it("remote run-issue result file carries bench fields", async () => {
73
+ const prov = fakeProvider((n) => ({ terminalReason: "merged", pr: `https://x/pull/${n}`, cost_usd: 1.5, wall_ms: 1200, model_ms: 900 }));
74
+ const { deps, work } = setup("bench", prov);
75
+ const rf = join(work, "result.json");
76
+ await logs(() => runFromCli(["8", "--repo", "o/r", "--no-prefilter", "--result-file", rf], deps));
77
+ const r = JSON.parse(readFileSync(rf, "utf8"));
78
+ assert.equal(r.terminalReason, "merged");
79
+ assert.equal(r.cost_usd, 1.5); assert.equal(r.wall_ms, 1200); assert.equal(r.model_ms, 900);
80
+ assert.match(String(r.pr), /8$/);
81
+ });
82
+ });
@@ -47,6 +47,7 @@ export function isActionsEndpoint(endpoint) {
47
47
  * (`token` is a string, or a function called per request, #5144).
48
48
  * 429/503 on launch is a retryable capacity error (`Retry-After` seconds). Error text never carries the token.
49
49
  * Optional `POST /sandboxes/:id/stop` (#4612) asks the pool to SIGTERM the lane so its teardown checkpoints and it reports `deferred run.interrupted`; 2xx = sent, 404/405 = unsupported or gone (never a DELETE fallback).
50
+ * `GET /agents -> {sandboxes}` is the router's live sandbox list (#5422, `inventory()`; malformed or any error throws).
50
51
  * Optional relay (#4778): `GET /sandboxes/:id/relay -> {requests: [{rid, argv}]}` lists a sandbox's pending read-only capability
51
52
  * requests (404/405 or malformed = none, an older router) and `POST /sandboxes/:id/relay/:rid` `{rc, stdout, stderr}` answers one.
52
53
  * Optional `GET /status -> {free: N, online?, total?}` is the pool's free slots (#4540); without `online` the agents of `GET /agents` give it (#4788). Anything else (404, error, malformed) is unknown (null).
@@ -94,6 +95,21 @@ export function httpTransport({ endpoint, token = null, fetchFn = globalThis.fet
94
95
  async usage(id) { const r = await call("GET", `${p(id)}/usage`); return r.ok && Number.isFinite(Number(r.data?.minutes)) ? { minutes: Number(r.data.minutes), ...(typeof r.data.agent === "string" && r.data.agent ? { agent: r.data.agent } : {}) } : null; }, // agent: #4549, optional
95
96
  async stop(id) { const r = await call("POST", `${p(id)}/stop`); if (r.ok) return true; if (r.status === 404 || r.status === 405) return false; throw fail("stop", r); },
96
97
  async destroy(id) { const r = await call("DELETE", p(id)); if (r.ok || r.status === 404) return true; throw fail("destroy", r); },
98
+ /** #5422: the sandboxes the router knows (`GET /agents` -> `sandboxes`, id -> {agent, issue, batch}) as [{id, issue}]. Anything but a well-formed answer throws: an unknown list is never an empty one. */
99
+ async inventory() {
100
+ const r = await call("GET", "/agents");
101
+ if (!r.ok) throw fail("inventory", r);
102
+ const m = r.data?.sandboxes;
103
+ if (!m || typeof m !== "object" || Array.isArray(m)) throw new Error("sandbox inventory: malformed router answer");
104
+ return Object.entries(m).map(([id, x]) => ({ id, issue: x?.issue ?? null, disk_used_mb: Number.isFinite(x?.disk_used_mb) ? x.disk_used_mb : null })); // #5535: null = old agent
105
+ },
106
+ /** #5535: each pool agent's free disk from `GET /agents` -> `agents[]` as [{name, disk_free_gb|null}]; a bad answer throws. */
107
+ async agentDisk() {
108
+ const r = await call("GET", "/agents");
109
+ if (!r.ok) throw fail("agent disk", r);
110
+ if (!Array.isArray(r.data?.agents)) throw new Error("agent disk: malformed router answer");
111
+ return r.data.agents.map((a) => ({ name: String(a?.name ?? "?"), disk_free_gb: Number.isFinite(a?.disk_free_gb) ? a.disk_free_gb : null }));
112
+ },
97
113
  async relayPending(id) { const r = await call("GET", `${p(id)}/relay`); return r.ok && Array.isArray(r.data?.requests) ? r.data.requests : []; },
98
114
  async relayAnswer(id, rid, out) { const r = await call("POST", `${p(id)}/relay/${encodeURIComponent(rid)}`, out); if (!r.ok) throw fail("relay answer", r); return true; },
99
115
  async capacity() {
@@ -343,7 +343,7 @@ export async function startDaemon({ dir = schedDir(), runBatch, idleMs = Number(
343
343
  const b = openBatch(root, req.id);
344
344
  if (!b.exists()) throw new Error(`no batch ${req.id} in ${root}`);
345
345
  const changed = req.op === "hold" ? b.holdIssues(req.issues ?? [], req.meta ?? null) : b.releaseIssues(req.issues ?? []);
346
- return send({ type: "ok", changed, hosted: hosted.has(req.id) }, true);
346
+ return send({ type: "ok", changed, held: b.readHeld(), hosted: hosted.has(req.id) }, true);
347
347
  }
348
348
  if (req.op === "gc-orphans") { // #5469: cancel every orphaned batch (unhosted, pending issues, idle past the threshold)
349
349
  const { orphaned } = unhostedBatches(Date.now(), Number.isFinite(req.minAgeMs) ? req.minAgeMs : ORPHAN_AGE_MS);
@@ -0,0 +1,115 @@
1
+ // SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
2
+ // SPDX-License-Identifier: AGPL-3.0-or-later
3
+ /**
4
+ * #5338: the machine form of an interface. A spike/epic `Interfaces` row whose signature cell is an HTTP route
5
+ * (`POST /v1/search`), a function signature (`refund(job_id, amount_micro)`) or a typed payload / queue message
6
+ * (`queue research.jobs {query, device, city, uule}`) is parsed into a `seam` and becomes (1) a generated contract test
7
+ * that provider and consumer CI both run against the real source, nothing mocked, and (2) a deterministic precheck at
8
+ * lane review (`seamFailures`), so a mismatch is flagged when the lane that causes it is reviewed, not at release review.
9
+ * The checker itself is templates/contracts/seam-check.mjs (self-contained, copied next to the generated tests).
10
+ * Pure except where an injected read/list is given; no LLM, gh or git here.
11
+ */
12
+ import { OUTCOME_CODES } from "../engine/outcome-codes.mjs";
13
+ import { checkSeam, authMode, anchorMatches } from "../../templates/contracts/seam-check.mjs";
14
+
15
+ export { checkSeam, authMode };
16
+ export const SEAM_KINDS = ["symbol", "route", "payload"];
17
+ const IDENT = /^[A-Za-z_$][\w$]*$/;
18
+ const METHODS = /^(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS)\s+(\/[^\s`]*)/i;
19
+
20
+ const unTick = (s) => String(s ?? "").trim().replace(/^`+|`+$/g, "").trim();
21
+
22
+ function topSplit(s) {
23
+ const out = []; let depth = 0, cur = "";
24
+ for (const c of s) {
25
+ if ("([{<".includes(c)) depth++; else if (")]}>".includes(c)) depth = Math.max(0, depth - 1);
26
+ if (c === "," && depth === 0) { out.push(cur); cur = ""; } else cur += c;
27
+ }
28
+ if (cur.trim()) out.push(cur);
29
+ return out.map((x) => x.trim()).filter(Boolean);
30
+ }
31
+
32
+ /** {kind, symbol|route|payload} for a signature cell with a machine form, else null. */
33
+ export function parseSeamForm(signature) {
34
+ const t = unTick(signature);
35
+ const r = METHODS.exec(t);
36
+ if (r) return { kind: "route", route: { method: r[1].toUpperCase(), path: r[2].replace(/[.,;]+$/, "") } };
37
+ const f = /^(?:(?:async|def|function|fn)\s+)?([A-Za-z_$][\w$.]*)\s*\(([^)]*)\)/.exec(t);
38
+ if (f) {
39
+ const name = f[1].split(".").at(-1);
40
+ const params = [];
41
+ for (const raw of topSplit(f[2])) {
42
+ if (raw === "*" || raw === "/") continue;
43
+ const variadic = /^(\*\*?|\.\.\.)/.test(raw);
44
+ const m = /^([A-Za-z_$][\w$]*)(\?)?/.exec(raw.replace(/^(\*\*?|\.\.\.)/, ""));
45
+ if (!m) return null;
46
+ params.push({ name: m[1], optional: Boolean(m[2]) || /(^|[^=!<>])=(?!=)/.test(raw) || variadic, variadic });
47
+ }
48
+ if (IDENT.test(name)) return { kind: "symbol", symbol: { name, params } };
49
+ }
50
+ const p = /^(?:(?:queue|topic|message|payload|event)\s+)?(?:[\w.:\-/]+\s+)?\{([^}]*)\}/i.exec(t);
51
+ if (p) {
52
+ const fields = [...new Set(topSplit(p[1]).map((x) => /^["']?([A-Za-z_$][\w$]*)/.exec(x)?.[1]).filter(Boolean))];
53
+ if (fields.length) return { kind: "payload", payload: { fields } };
54
+ }
55
+ return null;
56
+ }
57
+
58
+ /** Anchor cell tokens: `provider:path` / `consumer:path` set the side; a bare path is governed but on neither side. {all, provider, consumer}. */
59
+ export function roleAnchors(tokens) {
60
+ const all = [], provider = [], consumer = [];
61
+ for (const raw of tokens ?? []) {
62
+ const m = /^(provider|consumer)\s*:\s*(.+)$/i.exec(String(raw).trim());
63
+ const path = (m ? m[2] : String(raw)).trim();
64
+ if (!path) continue;
65
+ all.push(path);
66
+ if (m?.[1].toLowerCase() === "provider") provider.push(path);
67
+ if (m?.[1].toLowerCase() === "consumer") consumer.push(path);
68
+ }
69
+ return { all: [...new Set(all)], provider: [...new Set(provider)], consumer: [...new Set(consumer)] };
70
+ }
71
+
72
+ /** The stored seam of a decision from its parsed form and role anchors; null when no form or a side is undeclared. */
73
+ export function buildSeam(form, roles, auth) {
74
+ if (!form || !roles?.provider?.length || !roles?.consumer?.length) return null;
75
+ return { ...form, auth: String(auth ?? "").slice(0, 160), provider: roles.provider, consumer: roles.consumer };
76
+ }
77
+
78
+ /** The contract the checker and the generated test take, from a decision record with a `seam`. */
79
+ export const seamContract = (rec) => ({ v: 1, id: rec.id, kind: rec.seam.kind, boundary: String(rec.choice ?? "").slice(0, 160), auth: rec.seam.auth ?? "", [rec.seam.kind]: rec.seam[rec.seam.kind], provider: rec.seam.provider, consumer: rec.seam.consumer });
80
+
81
+ /** Source of `contracts/<id>.contract.test.mjs`: one node:test file that reads both sides' real source. */
82
+ export function renderSeamTest(contract) {
83
+ const lit = JSON.stringify(contract, null, 2).replace(/</g, "\\u003c");
84
+ return `// Generated by \`npx forgedock interfaces contract\` for interface decision ${contract.id} (forgedock #5338).
85
+ // Both sides of the seam run this file (\`node --test contracts/*.contract.test.mjs\`); it reads the real source and mocks nothing.
86
+ // Changing the interface means a \`supersedes\` decision and regenerating this file, not editing it by hand.
87
+ import { test } from "node:test";
88
+ import assert from "node:assert/strict";
89
+ import { fileURLToPath } from "node:url";
90
+ import { checkSeamAt, formatFindings } from "./seam-check.mjs";
91
+
92
+ const contract = ${lit};
93
+
94
+ test(\`interface \${contract.id}: \${contract.boundary}\`, () => {
95
+ const r = checkSeamAt(contract, fileURLToPath(new URL("../", import.meta.url)));
96
+ assert.equal(r.unchecked, undefined, r.unchecked);
97
+ assert.equal(r.findings.length, 0, \`the provider and consumer disagree on \${contract.id}:\\n\${formatFindings(r.findings)}\`);
98
+ });
99
+ `;
100
+ }
101
+
102
+ /**
103
+ * Lane-review failures: for every active decision with a `seam` whose anchors a changed file touches (and that the lane
104
+ * does not supersede), run the checker on the lane's worktree. `read(path)`/`list()` give the worktree files. Pure.
105
+ */
106
+ export function seamFailures({ records, changedFiles, read, list, superseded = [] }) {
107
+ const gone = new Set(superseded), out = [];
108
+ for (const rec of records ?? []) {
109
+ if (!rec?.seam || rec.status === "superseded" || gone.has(rec.id)) continue;
110
+ if (!(changedFiles ?? []).some((f) => (rec.anchors ?? []).some((a) => anchorMatches(a, f)))) continue;
111
+ const r = checkSeam(seamContract(rec), { read, list });
112
+ for (const f of r.findings) out.push({ code: OUTCOME_CODES.CONFORMANCE_PRESERVE_VIOLATED, kind: "interface_seam", detail: `decision ${rec.id} (${rec.choice.slice(0, 80)}): ${f.side}${f.file ? ` ${f.file}${f.line ? `:${f.line}` : ""}` : ""}: ${f.detail}; amend {kind:"decision", decision:{choice, anchors, supersedes:"${rec.id}"}, why} when the interface really changes` });
113
+ }
114
+ return out;
115
+ }
@@ -0,0 +1,118 @@
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 { spawnSync } from "node:child_process";
6
+ import { mkdirSync, writeFileSync, readFileSync } from "node:fs";
7
+ import { dirname, join } from "node:path";
8
+ import { tmpDir } from "../tests/_tmp.mjs";
9
+ import { parseSeamForm, roleAnchors, buildSeam, seamContract, renderSeamTest, seamFailures, checkSeam, authMode } from "./seam.mjs";
10
+ import { anchorMatches } from "./decisions.mjs";
11
+ import { anchorMatches as checkerAnchorMatches } from "../../templates/contracts/seam-check.mjs";
12
+ import { normaliseDecision } from "./decisions.mjs";
13
+
14
+ const io = (files) => ({ list: () => Object.keys(files), read: (p) => files[p] });
15
+ const contract = (o) => ({ v: 1, id: "i1-1", boundary: "b", auth: "", ...o });
16
+
17
+ describe("seam forms (#5338)", () => {
18
+ it("parses a route, a function signature and a typed payload; prose has no machine form", () => {
19
+ assert.deepEqual(parseSeamForm("`POST /v1/search/{id}`"), { kind: "route", route: { method: "POST", path: "/v1/search/{id}" } });
20
+ assert.deepEqual(parseSeamForm("refund(job_id: str, amount_micro: int, *, reason=None)").symbol, { name: "refund", params: [{ name: "job_id", optional: false, variadic: false }, { name: "amount_micro", optional: false, variadic: false }, { name: "reason", optional: true, variadic: false }] });
21
+ assert.equal(parseSeamForm("billing.refund(a)").symbol.name, "refund");
22
+ assert.deepEqual(parseSeamForm("queue research.jobs {query, device?: string, city}").payload.fields, ["query", "device", "city"]);
23
+ assert.equal(parseSeamForm("a JSON document with the results"), null);
24
+ });
25
+ it("roles: provider:/consumer: prefixes set the side, a bare anchor is governed but on neither; a seam needs both sides", () => {
26
+ const r = roleAnchors(["provider:worker/", "consumer:api/", "shared/"]);
27
+ assert.deepEqual(r.all, ["worker/", "api/", "shared/"]);
28
+ assert.deepEqual(r.provider, ["worker/"]);
29
+ assert.deepEqual(r.consumer, ["api/"]);
30
+ assert.equal(buildSeam(parseSeamForm("POST /x"), roleAnchors(["provider:a/"]), "k"), null);
31
+ assert.equal(buildSeam(null, r, "k"), null);
32
+ assert.equal(buildSeam(parseSeamForm("POST /x"), r, "k").kind, "route");
33
+ });
34
+ it("the checker's anchor rule is the register's (parity)", () => {
35
+ for (const [a, p] of [["src/a.js", "src/a.js"], ["src/a/", "src/a/b.js"], ["src/**", "src/a/b.js"], ["src/*.js", "src/a/b.js"], ["src/a", "src/a/b.js"], ["./x/", "x/y"], ["", "x"]]) assert.equal(checkerAnchorMatches(a, p), anchorMatches(a, p), `${a} ${p}`);
36
+ });
37
+ it("auth mode: an API key with a negated session is api-key; a session is not", () => {
38
+ assert.equal(authMode("API key only, no session cookie"), "api-key");
39
+ assert.equal(authMode("x-api-key header"), "api-key");
40
+ assert.equal(authMode("session cookie or API key"), "session");
41
+ assert.equal(authMode("internal"), "other");
42
+ });
43
+ });
44
+
45
+ describe("seam checker: the three mismatches the audit found (#5338)", () => {
46
+ const refund = contract({ kind: "symbol", symbol: parseSeamForm("refund(job_id, amount_micro)").symbol, provider: ["worker/"], consumer: ["api/"] });
47
+ it("symbol: a refund primitive with the wrong signature, and a call that does not fit, are findings; a matching pair is clean", () => {
48
+ const bad = io({ "worker/refund.py": "async def refund(self, job_id: str) -> None:\n ...\n", "api/research.py": "await refund(job.id, amount_micro=5)\nawait refund(job.id, 5, 6)\n" });
49
+ const r = checkSeam(refund, bad);
50
+ assert.deepEqual(r.findings.map((f) => [f.side, f.file, f.line]), [["provider", "worker/refund.py", 1], ["consumer", "api/research.py", 2]]);
51
+ assert.match(r.findings[0].detail, /TypeError/);
52
+ assert.match(r.findings[1].detail, /too many arguments/);
53
+ const good = io({ "worker/refund.py": "async def refund(job_id: str, amount_micro: int, *, reason=None):\n ...\n", "api/research.py": "await refund(job.id, amount_micro=5)\nawait refund(job.id, 7)\n", "api/other.py": "refund(**kw)\n" });
54
+ assert.deepEqual(checkSeam(refund, good).findings, []);
55
+ assert.match(checkSeam(refund, io({ "worker/x.py": "pass", "api/y.py": "pass" })).findings[0].detail, /no definition of refund/);
56
+ });
57
+ it("symbol: TypeScript functions, arrow bindings and methods are definitions", () => {
58
+ const c = contract({ kind: "symbol", symbol: parseSeamForm("charge(id, cents)").symbol, provider: ["lib/"], consumer: ["app/"] });
59
+ for (const def of ["export async function charge(id: string, cents: number) {}", "export const charge = async (id: string, cents: number) => {}", "class B {\n async charge(id: string, cents: number): Promise<void> {}\n}"]) {
60
+ assert.deepEqual(checkSeam(c, io({ "lib/a.ts": def, "app/b.ts": "await charge(a, 3)" })).findings, [], def);
61
+ }
62
+ assert.equal(checkSeam(c, io({ "lib/a.ts": "export function charge(id: string) {}", "app/b.ts": "charge(a, 3)" })).findings.length, 1);
63
+ });
64
+ it("route: a web proxy that forwards the session cookie / JWT to an API-key-only route is flagged, one that sends the key is clean", () => {
65
+ const route = contract({ kind: "route", auth: "API key only, no session cookie", route: { method: "POST", path: "/v1/search" }, provider: ["api/"], consumer: ["web/"] });
66
+ const api = { "api/routes.py": "@router.post('/v1/search')\nasync def search(): ...\n" };
67
+ const cookie = checkSeam(route, io({ ...api, "web/app/api/search/route.ts": "export async function POST(req) {\n return fetch(`${API}/v1/search`, { headers: { cookie: req.headers.get('cookie') } });\n}" }));
68
+ assert.deepEqual(cookie.findings.map((f) => f.side), ["consumer", "consumer"]);
69
+ assert.match(cookie.findings[0].detail, /Cookie header/);
70
+ assert.match(cookie.findings[1].detail, /never sends one/);
71
+ const jwt = checkSeam(route, io({ ...api, "web/lib/s.ts": "const session = await getServerSession();\nfetch(`${API}/v1/search`, { headers: { Authorization: `Bearer ${session.accessToken}` } })" }));
72
+ assert.ok(jwt.findings.some((f) => /session token|session JWT/.test(f.detail)));
73
+ assert.deepEqual(checkSeam(route, io({ ...api, "web/lib/s.ts": "fetch(`${API}/v1/search`, { headers: { 'x-api-key': process.env.ALTERLAB_API_KEY } })" })).findings, []);
74
+ assert.match(checkSeam(route, io({ "api/other.py": "pass", "web/x.ts": "pass" })).findings[0].detail, /no handler for POST \/v1\/search/);
75
+ const next = checkSeam(contract({ ...route, route: { method: "GET", path: "/v1/jobs/{id}" } }), io({ "api/v1/jobs/[id]/route.ts": "export async function GET() {}", "web/a.ts": "x" }));
76
+ assert.deepEqual(next.findings, []);
77
+ });
78
+ it("payload: fields the API accepts and the worker handler drops are flagged on the side that drops them", () => {
79
+ const p = contract({ kind: "payload", payload: parseSeamForm("queue research.jobs {query, device, city, uule}").payload, provider: ["worker/"], consumer: ["api/"] });
80
+ const r = checkSeam(p, io({ "worker/handler.py": "def handle(job):\n return job['query'], job['device']\n", "api/search.py": "enqueue({'query': q, 'device': d, 'city': c, 'uule': u})\n" }));
81
+ assert.deepEqual(r.findings.map((f) => [f.side, /"(\w+)"/.exec(f.detail)[1]]), [["provider", "city"], ["provider", "uule"]]);
82
+ assert.deepEqual(checkSeam(p, io({ "worker/handler.py": "job['query'] job['device'] job['city'] job['uule']", "api/search.py": "query device city uule" })).findings, []);
83
+ });
84
+ it("a side with no source files is unchecked, never a silent pass", () => {
85
+ assert.match(checkSeam(refund, io({ "worker/refund.py": "def refund(job_id, amount_micro): ..." })).unchecked, /consumer anchors/);
86
+ });
87
+ });
88
+
89
+ describe("seamFailures at lane review and the generated contract test (#5338)", () => {
90
+ const rec = normaliseDecision({ id: "i9-1", choice: "Interface api -> worker: refund(job_id, amount_micro)", anchors: ["worker/", "api/"], issue: 9, seam: { kind: "symbol", auth: "internal", symbol: parseSeamForm("refund(job_id, amount_micro)").symbol, provider: ["worker/"], consumer: ["api/"] } });
91
+ const files = { "worker/refund.py": "def refund(job_id): ...", "api/r.py": "refund(a, b)", "docs/a.md": "x" };
92
+ it("flags a mismatch only when the lane touches the anchors, and not for a superseded record", () => {
93
+ assert.ok(rec.seam);
94
+ const f = seamFailures({ records: [rec], changedFiles: ["worker/refund.py"], ...io(files) });
95
+ assert.equal(f.length, 1);
96
+ assert.equal(f[0].kind, "interface_seam");
97
+ assert.equal(f[0].code, "conformance.preserve_violated");
98
+ assert.match(f[0].detail, /i9-1.*worker\/refund\.py:1.*supersedes:"i9-1"/);
99
+ assert.deepEqual(seamFailures({ records: [rec], changedFiles: ["docs/a.md"], ...io(files) }), []);
100
+ assert.deepEqual(seamFailures({ records: [rec], changedFiles: ["worker/refund.py"], superseded: ["i9-1"], ...io(files) }), []);
101
+ assert.deepEqual(seamFailures({ records: [{ ...rec, status: "superseded" }], changedFiles: ["worker/refund.py"], ...io(files) }), []);
102
+ });
103
+ it("the generated test file runs under node --test and fails for a broken seam, passes for a sound one (nothing mocked)", () => {
104
+ const root = tmpDir("seam-");
105
+ const write = (rel, text) => { mkdirSync(dirname(join(root, rel)), { recursive: true }); writeFileSync(join(root, rel), text); };
106
+ spawnSync("git", ["init", "-q"], { cwd: root });
107
+ write("contracts/seam-check.mjs", readFileSync(new URL("../../templates/contracts/seam-check.mjs", import.meta.url), "utf8"));
108
+ write("contracts/i9-1.contract.test.mjs", renderSeamTest(seamContract(rec)));
109
+ for (const [rel, t] of Object.entries(files)) write(rel, t);
110
+ const run = () => spawnSync(process.execPath, ["--test", "contracts/i9-1.contract.test.mjs"], { cwd: root, encoding: "utf8", env: Object.fromEntries(Object.entries(process.env).filter(([k]) => k !== "NODE_TEST_CONTEXT")) });
111
+ const red = run();
112
+ assert.notEqual(red.status, 0);
113
+ assert.match(red.stdout + red.stderr, /provider and consumer disagree on i9-1/);
114
+ write("worker/refund.py", "def refund(job_id, amount_micro): ...");
115
+ const green = run();
116
+ assert.equal(green.status, 0, green.stdout + green.stderr);
117
+ });
118
+ });
@@ -23,8 +23,16 @@ export const CASES = [
23
23
  { name: "help", args: ["help"], file: "help.txt" },
24
24
  { name: "doctor", args: ["doctor"], file: "doctor.txt" },
25
25
  { name: "errors", args: ["nosuchcommand"], file: "errors.txt" },
26
+ { name: "no-splash", args: ["--no-splash"], file: "no-splash.txt" },
26
27
  ];
27
28
 
29
+ // The startup splash lines `npx forgedock` prints (#5312, bin/splash-install.mjs) and doctor's state line (#5532).
30
+ const SPLASH_NO_CLAUDE = /startup splash skipped: claude CLI not found/;
31
+ const SPLASH_OPTED_OUT = /startup splash skipped \(--no-splash\)/;
32
+ const SPLASH_INSTALLED = /startup splash (installed|already installed)\b/;
33
+ const DOCTOR_SPLASH = (state) => new RegExp(`Startup splash\\s+${state}\\b`);
34
+ const splashPlugins = (settings) => { try { return Object.entries(JSON.parse(settings).enabledPlugins ?? {}).filter(([k]) => k.startsWith("forgedock-splash@")); } catch { return []; } };
35
+
28
36
  // Success wording that must not appear while node/git are all a clean machine has (the false banner of 2026-11-10).
29
37
  const FALSE_SUCCESS = /(all checks passed|you'?re all set|setup complete|✔\s+(Claude Code|gh\b|GitHub CLI)\b)/i;
30
38
  const JARGON = /\b(ENOENT|EACCES|ERR_[A-Z_]+|TypeError|ReferenceError|SyntaxError|undefined|\[object Object\])\b|\n\s+at \S+ \(/;
@@ -56,6 +64,14 @@ export function assertStage1(results) {
56
64
  if (doctor && doctor.code === 0) bad.push(["doctor", "doctor exits 0 on a machine without gh and Claude Code"]);
57
65
  if (doctor && !/claude/i.test(doctor.output)) bad.push(["doctor", "doctor output never names Claude Code"]);
58
66
  if (doctor && !/\bgh\b|github cli/i.test(doctor.output)) bad.push(["doctor", "doctor output never names the gh CLI"]);
67
+ const banner = results.cases.banner, nosplash = results.cases["no-splash"];
68
+ // When setup stops at the not-ready screen (exit 1) it never reaches the splash step: only an install line is wrong then.
69
+ if (banner && SPLASH_INSTALLED.test(banner.output)) bad.push(["splash", "splash reported installed on a machine without the claude CLI"]);
70
+ if (banner?.code === 0 && !SPLASH_NO_CLAUDE.test(banner.output)) bad.push(["splash", "setup without the claude CLI never printed the splash skip line"]);
71
+ if (nosplash && SPLASH_INSTALLED.test(nosplash.output)) bad.push(["splash", "--no-splash still installed the splash"]);
72
+ if (nosplash?.code === 0 && !SPLASH_OPTED_OUT.test(nosplash.output)) bad.push(["splash", "--no-splash did not report the skip"]);
73
+ if (nosplash && nosplash.code !== 0 && nosplash.code !== banner?.code) bad.push(["splash", `setup with --no-splash exited ${nosplash.code}, setup without it ${banner?.code}`]);
74
+ if (doctor && !DOCTOR_SPLASH("not installed").test(doctor.output)) bad.push(["splash", "doctor does not report the splash state as not installed"]);
59
75
  const errs = results.cases.errors;
60
76
  if (errs && errs.code === 0) bad.push(["errors", "an unknown command exits 0"]);
61
77
  for (const [path, content] of Object.entries(results.files)) {
@@ -114,6 +130,7 @@ export async function stage2(ctx) {
114
130
  };
115
131
  await run("setup", ["demo", dir, "--repo", repo]);
116
132
  await run("doctor", ["doctor"]);
133
+ await splashStage(ctx, dir);
117
134
  await run("first-merge", ["demo", dir, "--repo", repo, "--run"]);
118
135
  const prs = JSON.parse(await io.gh(["pr", "list", "-R", repo, "--state", "merged", "--json", "number,mergedAt", "--limit", "20"]));
119
136
  const merged = prs.map((p) => Date.parse(p.mergedAt)).filter((t) => t >= start).sort((a, b) => a - b)[0];
@@ -121,8 +138,28 @@ export async function stage2(ctx) {
121
138
  ctx.ttfmMs = merged - start;
122
139
  }
123
140
 
141
+ /** Setup with claude available installs forgedock-splash at user scope and doctor reports it; --no-splash installs nothing. Each run gets a throwaway HOME. */
142
+ async function splashStage(ctx, dir) {
143
+ const { io } = ctx;
144
+ const go = async (args, home) => {
145
+ const r = await io.cli(args, { cwd: dir, env: { HOME: home, CLAUDE_CONFIG_DIR: "" } });
146
+ return { ...r, text: `${r.stdout}\n${r.stderr}`, settings: await io.readFile(join(home, ".claude", "settings.json")) };
147
+ };
148
+ const home = await io.mkdir(), bare = await io.mkdir();
149
+ ctx.homes.push(home, bare);
150
+ const on = await go([], home);
151
+ if (!SPLASH_INSTALLED.test(on.text)) fail("splash", `setup with claude available did not report the splash installed: ${scrub(on.text).slice(0, 200)}`);
152
+ if (!splashPlugins(on.settings).some(([, v]) => v === true)) fail("splash", "forgedock-splash is not enabled at user scope in settings.json after setup");
153
+ const doc = await io.cli(["doctor"], { cwd: dir, env: { HOME: home, CLAUDE_CONFIG_DIR: "" } });
154
+ if (!DOCTOR_SPLASH("installed").test(`${doc.stdout}\n${doc.stderr}`)) fail("splash", "doctor does not report the splash as installed");
155
+ const off = await go(["--no-splash"], bare);
156
+ if (!SPLASH_OPTED_OUT.test(off.text)) fail("splash", "--no-splash did not report the skip");
157
+ if (SPLASH_INSTALLED.test(off.text) || splashPlugins(off.settings).length) fail("splash", "--no-splash still installed the splash");
158
+ }
159
+
124
160
  async function cleanup2(ctx, errors) {
125
161
  const { io, repo } = ctx;
162
+ for (const h of ctx.homes) try { await io.rm(h); } catch (e) { errors.push(`remove ${h}: ${String(e.message ?? e).slice(0, 120)}`); }
126
163
  if (ctx.dir) try { await io.rm(ctx.dir); } catch (e) { errors.push(`remove ${ctx.dir}: ${String(e.message ?? e).slice(0, 120)}`); }
127
164
  if (ctx.startedStage2) {
128
165
  try {
@@ -134,7 +171,7 @@ async function cleanup2(ctx, errors) {
134
171
 
135
172
  /** Run both stages; the first failure stops them, cleanup always runs. */
136
173
  export async function runNewUserJourney({ repo, io, snapshotDir = SNAPSHOT_DIR, update = false }) {
137
- const ctx = { io, repo, snapshotDir, update, notes: [], prompts: [], ttfmMs: null, dir: null, startedStage2: null };
174
+ const ctx = { io, repo, snapshotDir, update, notes: [], prompts: [], homes: [], ttfmMs: null, dir: null, startedStage2: null };
138
175
  let out = { ok: true, step: null, message: null };
139
176
  try {
140
177
  await stage1(ctx);
@@ -195,7 +232,8 @@ export function realJourneyIo(env = process.env, { docker } = {}) {
195
232
  gh: async (args) => { const r = sh("gh", args); if (r.status !== 0) throw new Error(r.stderr.trim() || `gh exited ${r.status}`); return r.stdout; },
196
233
  mkdir: async () => mkdtempSync(join(scratch, "demo-")),
197
234
  rm: async (d) => rmSync(d, { recursive: true, force: true }),
198
- cli: async (args, { cwd } = {}) => { const r = sh(process.execPath, [cliPath, ...args], { cwd, env, timeout: 45 * 60 * 1000, input: "" }); return { code: r.status ?? 1, stdout: r.stdout ?? "", stderr: r.stderr ?? "" }; },
235
+ readFile: async (p) => { try { return readFileSync(p, "utf8"); } catch { return null; } },
236
+ cli: async (args, { cwd, env: extra } = {}) => { const r = sh(process.execPath, [cliPath, ...args], { cwd, env: { ...env, ...extra }, timeout: 45 * 60 * 1000, input: "" }); return { code: r.status ?? 1, stdout: r.stdout ?? "", stderr: r.stderr ?? "" }; },
199
237
  dispose: () => rmSync(scratch, { recursive: true, force: true }),
200
238
  };
201
239
  }
@@ -9,19 +9,22 @@ import { selftestFromCli } from "./selftest-live.mjs";
9
9
  import { tmpDir } from "../tests/_tmp.mjs";
10
10
 
11
11
  const GOOD = {
12
- banner: { code: 0, output: "ForgeDock v1.2.3\n ✖ Claude Code not found\n" },
12
+ banner: { code: 0, output: "ForgeDock v1.2.3\n ✖ Claude Code not found\n ! startup splash skipped: claude CLI not found re-run npx forgedock after installing Claude Code\n" },
13
13
  help: { code: 0, output: "Usage: forgedock <command>\n" },
14
- doctor: { code: 1, output: " ✗ gh CLI\n ✗ Claude Code settings\n" },
14
+ doctor: { code: 1, output: " ✗ gh CLI\n ✗ Claude Code settings\n ✔ Startup splash not installed (forgedock-splash)\n" },
15
15
  errors: { code: 1, output: "Unknown command: nosuchcommand\n" },
16
+ "no-splash": { code: 0, output: " ! startup splash skipped (--no-splash)\n" },
16
17
  };
17
18
  const stage1Io = (over = {}, files = { "./forge.yaml": 'owner: "acme"\n' }) => ({
18
19
  pack: async () => "/x/f.tgz",
19
20
  clean: async (_t, args) => { const c = CASES.find((k) => k.args.join(" ") === args.join(" ")); return { ...(over[c.name] ?? GOOD[c.name]), files: c.name === "banner" ? files : {} }; },
20
21
  });
21
22
  const now = (() => { let t = 1000; return () => (t += 10); })();
23
+ let lastNoSplash = false;
22
24
  const io2 = (over = {}) => ({
23
25
  now, ghAuthed: async () => true, claudeAvailable: async () => true, mkdir: async () => "/d", rm: async () => {},
24
- cli: async (args) => ({ code: 0, stdout: args.includes("--run") ? "Proceed? [y/N]\nmerged\n" : "ok\n", stderr: "" }),
26
+ readFile: async () => (lastNoSplash ? null : JSON.stringify({ enabledPlugins: { "forgedock-splash@forgedock-local": true } })),
27
+ cli: async (args) => (lastNoSplash = args.includes("--no-splash"), { code: 0, stdout: args.includes("--run") ? "Proceed? [y/N]\nmerged\n" : args[0] === "doctor" ? " ✔ Startup splash installed (forgedock-splash)\n" : args.includes("--no-splash") ? " ! startup splash skipped (--no-splash)\n" : " ✔ startup splash installed turn off: x\n", stderr: "" }),
25
28
  gh: async (a) => (a[0] === "pr" ? JSON.stringify([{ number: 1, mergedAt: new Date(5000).toISOString() }]) : "[]"),
26
29
  ...over,
27
30
  });
@@ -53,6 +56,43 @@ describe("assertStage1 (the 2026-11-10 regression classes)", () => {
53
56
  });
54
57
  });
55
58
 
59
+ describe("splash assertions (#5312 R17)", () => {
60
+ const ok = { cases: GOOD, files: {} };
61
+ const msgs = (cases) => assertStage1({ ...ok, cases: { ...GOOD, ...cases } }).map((b) => b[1]).join("|");
62
+ it("stage 1 passes with the skip lines and fails when they are missing or an install is reported", () => {
63
+ assert.deepEqual(assertStage1(ok), []);
64
+ assert.match(msgs({ banner: { code: 0, output: "ForgeDock\n" } }), /never printed the splash skip line/);
65
+ assert.match(msgs({ banner: { code: 0, output: "startup splash skipped: claude CLI not found\nstartup splash installed" } }), /reported installed/);
66
+ assert.match(msgs({ "no-splash": { code: 0, output: "nothing" } }), /did not report the skip/);
67
+ assert.match(msgs({ "no-splash": { code: 0, output: "startup splash skipped (--no-splash)\nstartup splash installed" } }), /still installed/);
68
+ assert.deepEqual(msgs({ banner: { code: 1, output: "Not ready yet" }, "no-splash": { code: 1, output: "Not ready yet" } }), "");
69
+ assert.match(msgs({ banner: { code: 1, output: "Not ready yet" }, "no-splash": { code: 0, output: "x" } }), /exited 0|did not report/);
70
+ assert.match(msgs({ doctor: { code: 1, output: "gh claude" } }), /splash state/);
71
+ });
72
+ it("stage 2 asserts the install at user scope, doctor's state and the --no-splash skip", async () => {
73
+ const homes = [], envs = [];
74
+ const base = io2({ mkdir: async () => { const h = `/h${homes.length}`; homes.push(h); return h; }, cli: async (args, o = {}) => { envs.push(o.env?.HOME); return io2().cli(args, o); } });
75
+ let r = await run({ ...stage1Io(), ...base });
76
+ assert.equal(r.ok, true, r.message);
77
+ assert.ok(envs.includes("/h1") && envs.includes("/h2"), "setup runs under throwaway homes");
78
+ const bad = async (over) => run({ ...stage1Io(), ...io2(over) });
79
+ r = await bad({ readFile: async () => JSON.stringify({ enabledPlugins: {} }) });
80
+ assert.equal(r.step, "splash");
81
+ assert.match(r.message, /not enabled at user scope/);
82
+ r = await bad({ cli: async (a) => ({ code: 0, stdout: a[0] === "doctor" ? "nothing" : "startup splash installed", stderr: "" }) });
83
+ assert.match(r.message, /doctor does not report/);
84
+ r = await bad({ cli: async (a) => ({ code: 0, stdout: a.includes("--no-splash") ? "startup splash installed" : a[0] === "doctor" ? "Startup splash installed" : "startup splash installed", stderr: "" }) });
85
+ assert.match(r.message, /--no-splash did not report/);
86
+ r = await bad({ cli: async () => ({ code: 0, stdout: "ok", stderr: "" }) });
87
+ assert.match(r.message, /did not report the splash installed/);
88
+ });
89
+ it("removes the throwaway homes", async () => {
90
+ const removed = [];
91
+ await run({ ...stage1Io(), ...io2({ rm: async (d) => removed.push(d) }) });
92
+ assert.ok(removed.length >= 3);
93
+ });
94
+ });
95
+
56
96
  describe("snapshots", () => {
57
97
  it("a missing snapshot fails naming the update flag; a changed one names the line", () => {
58
98
  const dir = tmpDir("jt-");