forgedock 1.52.0 → 1.54.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 (233) hide show
  1. package/.claude-plugin/marketplace.json +51 -0
  2. package/README.md +8 -2
  3. package/bin/auth/app-manifest.mjs +89 -0
  4. package/bin/auth/app-manifest.test.mjs +75 -0
  5. package/bin/auth/app-token.mjs +256 -0
  6. package/bin/auth/app-token.test.mjs +232 -0
  7. package/bin/brand.mjs +7 -0
  8. package/bin/config-history.mjs +151 -0
  9. package/bin/config-schema.mjs +115 -0
  10. package/bin/demo.mjs +65 -11
  11. package/bin/engine/outcome-codes.mjs +9 -3
  12. package/bin/engine/telemetry-seam.mjs +11 -3
  13. package/bin/engine/telemetry-seam.test.mjs +17 -0
  14. package/bin/engine-cli.mjs +110 -36
  15. package/bin/experiment.mjs +58 -6
  16. package/bin/first-run.mjs +122 -0
  17. package/bin/forge-utils.mjs +6 -2
  18. package/bin/forgedock.mjs +138 -142
  19. package/bin/help-text.mjs +144 -0
  20. package/bin/hooks/pre-tool-use.mjs +7 -0
  21. package/bin/journey.mjs +82 -83
  22. package/bin/lean/acceptance.mjs +313 -0
  23. package/bin/lean/acceptance.test.mjs +215 -0
  24. package/bin/lean/account-watch.mjs +28 -0
  25. package/bin/lean/account-watch.test.mjs +30 -0
  26. package/bin/lean/activation.mjs +38 -0
  27. package/bin/lean/activation.test.mjs +36 -1
  28. package/bin/lean/basered.mjs +115 -0
  29. package/bin/lean/basered.test.mjs +66 -0
  30. package/bin/lean/batch-health.mjs +114 -7
  31. package/bin/lean/batch-health.test.mjs +87 -1
  32. package/bin/lean/batch.mjs +41 -2
  33. package/bin/lean/batch.test.mjs +115 -11
  34. package/bin/lean/branchlock.mjs +54 -0
  35. package/bin/lean/branchlock.test.mjs +49 -0
  36. package/bin/lean/ceiling.mjs +72 -0
  37. package/bin/lean/ceiling.test.mjs +54 -0
  38. package/bin/lean/checkpoint-reconcile.mjs +43 -0
  39. package/bin/lean/checkpoint-reconcile.test.mjs +95 -0
  40. package/bin/lean/ci-budget.mjs +366 -0
  41. package/bin/lean/ci-budget.test.mjs +167 -0
  42. package/bin/lean/conformance.e2e.test.mjs +8 -1
  43. package/bin/lean/conformance.mjs +269 -38
  44. package/bin/lean/conformance.test.mjs +280 -7
  45. package/bin/lean/context.mjs +35 -6
  46. package/bin/lean/context.test.mjs +27 -1
  47. package/bin/lean/depcache.mjs +25 -1
  48. package/bin/lean/depcache.test.mjs +26 -0
  49. package/bin/lean/e2e.mjs +18 -2
  50. package/bin/lean/e2e.test.mjs +26 -1
  51. package/bin/lean/effects.mjs +47 -14
  52. package/bin/lean/execution.mjs +19 -3
  53. package/bin/lean/execution.test.mjs +63 -0
  54. package/bin/lean/facts.mjs +3 -3
  55. package/bin/lean/facts.test.mjs +5 -0
  56. package/bin/lean/findinglabel.mjs +16 -0
  57. package/bin/lean/findinglabel.test.mjs +39 -0
  58. package/bin/lean/fixround.mjs +14 -0
  59. package/bin/lean/fixround.test.mjs +25 -2
  60. package/bin/lean/gh-assoc.test.mjs +2 -1
  61. package/bin/lean/integration.mjs +100 -9
  62. package/bin/lean/integration.test.mjs +98 -0
  63. package/bin/lean/issuewatch-parity.mjs +64 -0
  64. package/bin/lean/issuewatch-parity.test.mjs +127 -0
  65. package/bin/lean/issuewatch-release.mjs +6 -2
  66. package/bin/lean/issuewatch-release.test.mjs +17 -1
  67. package/bin/lean/issuewatch.mjs +45 -6
  68. package/bin/lean/issuewatch.test.mjs +3 -2
  69. package/bin/lean/lanelock.mjs +14 -0
  70. package/bin/lean/lean.mjs +473 -100
  71. package/bin/lean/lean.test.mjs +686 -33
  72. package/bin/lean/light.mjs +48 -7
  73. package/bin/lean/light.test.mjs +37 -3
  74. package/bin/lean/limits.test.mjs +142 -9
  75. package/bin/lean/mechfix.mjs +124 -0
  76. package/bin/lean/mechfix.test.mjs +75 -0
  77. package/bin/lean/orchestrate-cancel.test.mjs +143 -0
  78. package/bin/lean/orchestrate.mjs +116 -28
  79. package/bin/lean/phaseledger.mjs +47 -5
  80. package/bin/lean/phaseledger.test.mjs +30 -1
  81. package/bin/lean/postdeploy-check.test.mjs +39 -0
  82. package/bin/lean/precheck.mjs +23 -4
  83. package/bin/lean/precheck.test.mjs +14 -1
  84. package/bin/lean/prereq.mjs +28 -0
  85. package/bin/lean/prereq.test.mjs +20 -0
  86. package/bin/lean/probe.mjs +4 -2
  87. package/bin/lean/prodparity.mjs +52 -0
  88. package/bin/lean/prodparity.test.mjs +67 -0
  89. package/bin/lean/prompts.mjs +77 -19
  90. package/bin/lean/quota.mjs +39 -0
  91. package/bin/lean/recovery.test.mjs +11 -1
  92. package/bin/lean/relaxation.mjs +73 -0
  93. package/bin/lean/relaxation.test.mjs +54 -0
  94. package/bin/lean/release-io.test.mjs +42 -0
  95. package/bin/lean/release-postmerge.mjs +125 -0
  96. package/bin/lean/release-preflight.mjs +58 -0
  97. package/bin/lean/release-preflight.test.mjs +114 -0
  98. package/bin/lean/release-rehearsal.mjs +64 -0
  99. package/bin/lean/release-rehearsal.test.mjs +93 -0
  100. package/bin/lean/release-review.e2e.test.mjs +77 -0
  101. package/bin/lean/release-review.mjs +254 -0
  102. package/bin/lean/release-review.test.mjs +307 -0
  103. package/bin/lean/release-snapshot.mjs +188 -0
  104. package/bin/lean/release-snapshot.test.mjs +190 -0
  105. package/bin/lean/release.mjs +296 -0
  106. package/bin/lean/release.test.mjs +387 -0
  107. package/bin/lean/render.mjs +1 -1
  108. package/bin/lean/replan.mjs +184 -0
  109. package/bin/lean/replan.test.mjs +110 -0
  110. package/bin/lean/resume.mjs +9 -7
  111. package/bin/lean/resume.test.mjs +16 -0
  112. package/bin/lean/rotator.mjs +150 -31
  113. package/bin/lean/rotator.test.mjs +105 -2
  114. package/bin/lean/sandbox-remote.mjs +9 -2
  115. package/bin/lean/schedd.mjs +83 -5
  116. package/bin/lean/schedd.test.mjs +108 -7
  117. package/bin/lean/selfreview.mjs +94 -0
  118. package/bin/lean/selfreview.test.mjs +58 -1
  119. package/bin/lean/selftest-gate.mjs +22 -0
  120. package/bin/lean/selftest-gate.test.mjs +18 -1
  121. package/bin/lean/selftest-journey.mjs +234 -0
  122. package/bin/lean/selftest-journey.test.mjs +130 -0
  123. package/bin/lean/selftest-live.mjs +2 -1
  124. package/bin/lean/seqlease.mjs +35 -1
  125. package/bin/lean/seqlease.test.mjs +15 -0
  126. package/bin/lean/seqreserve.e2e.test.mjs +135 -0
  127. package/bin/lean/seqreserve.mjs +73 -0
  128. package/bin/lean/seqreserve.test.mjs +134 -0
  129. package/bin/lean/sequence.mjs +35 -6
  130. package/bin/lean/seqversioned.mjs +147 -0
  131. package/bin/lean/stagestamp.mjs +28 -0
  132. package/bin/lean/stagestamp.test.mjs +32 -0
  133. package/bin/lean/surfaces.mjs +75 -0
  134. package/bin/lean/surfaces.test.mjs +59 -0
  135. package/bin/lean/toolplace.mjs +28 -0
  136. package/bin/lean/toolplace.test.mjs +24 -0
  137. package/bin/lean/toolstats.mjs +3 -1
  138. package/bin/lean/toolstats.test.mjs +11 -0
  139. package/bin/lean/validatebest.mjs +28 -0
  140. package/bin/lean/validatebest.test.mjs +27 -0
  141. package/bin/lean/verifier.mjs +3 -2
  142. package/bin/lean/verify.mjs +2 -1
  143. package/bin/lean/verify.test.mjs +6 -0
  144. package/bin/pool/agent.mjs +27 -4
  145. package/bin/pool/docker.mjs +5 -0
  146. package/bin/pool/router.mjs +74 -28
  147. package/bin/prereqs.mjs +111 -0
  148. package/bin/replay-timelapse.mjs +149 -0
  149. package/bin/review-staging.mjs +123 -16
  150. package/bin/review-staging.test.mjs +18 -0
  151. package/bin/runner.mjs +43 -6
  152. package/bin/splash-install.mjs +157 -0
  153. package/bin/stats/aggregate.mjs +8 -1
  154. package/bin/stats/conformance-outcomes.mjs +289 -0
  155. package/bin/stats/conformance-outcomes.test.mjs +274 -0
  156. package/bin/stats/depth.mjs +275 -0
  157. package/bin/stats/depth.test.mjs +158 -0
  158. package/bin/stats/efficiency.mjs +26 -5
  159. package/bin/stats/efficiency.test.mjs +45 -1
  160. package/bin/stats/experiment.mjs +7 -5
  161. package/bin/stats/first-review.mjs +77 -0
  162. package/bin/stats/first-review.test.mjs +36 -0
  163. package/bin/stats/firstmerge.mjs +40 -0
  164. package/bin/stats/firstmerge.test.mjs +41 -0
  165. package/bin/stats/github-source.mjs +53 -15
  166. package/bin/stats/index.mjs +147 -9
  167. package/bin/stats/local-source.mjs +12 -0
  168. package/bin/stats/origin.mjs +80 -0
  169. package/bin/stats/origin.test.mjs +58 -0
  170. package/bin/stats/query.mjs +69 -0
  171. package/bin/stats/render.mjs +3 -1
  172. package/bin/stats/scoreboard.mjs +137 -0
  173. package/bin/stats/scoreboard.test.mjs +87 -0
  174. package/bin/stats/selffiled.mjs +52 -0
  175. package/bin/stats/selffiled.test.mjs +71 -0
  176. package/bin/stats/stats.test.mjs +80 -0
  177. package/bin/tui.mjs +3 -2
  178. package/commands/bootstrap.md +15 -14
  179. package/commands/deploy-pr.md +18 -3
  180. package/commands/forge-stats.md +1 -1
  181. package/commands/forgedock-ci-setup.md +28 -0
  182. package/commands/forgedock-init.md +4 -5
  183. package/commands/issue.md +2 -0
  184. package/commands/milestone.md +9 -1
  185. package/commands/orchestrate.md +1 -1
  186. package/commands/replay.md +2 -0
  187. package/commands/review-pr-agents/security.md +4 -0
  188. package/commands/review-pr-staging.md +6 -1
  189. package/commands/work-on/build.md +4 -6
  190. package/commands/work-on/close.md +8 -0
  191. package/docs/CONFIG.md +170 -18
  192. package/docs/ISSUE-WATCH.md +25 -0
  193. package/docs/OUTCOME-CODES.md +4 -0
  194. package/docs/REPLAY.md +9 -0
  195. package/docs/SELFTEST.md +11 -0
  196. package/docs/STATS.md +61 -0
  197. package/docs/TELEMETRY.md +1 -1
  198. package/docs/eval/README.md +6 -0
  199. package/docs/eval/adversarial-bench.md +68 -0
  200. package/docs/eval/corpus/adversarial-v1.json +285 -0
  201. package/docs/eval/feature-bench.md +42 -0
  202. package/docs/eval/feature-specs/crud-auth/journeys/notes-crud-isolated.mjs +21 -0
  203. package/docs/eval/feature-specs/crud-auth/journeys/register-login.mjs +12 -0
  204. package/docs/eval/feature-specs/crud-auth/spec.md +15 -0
  205. package/docs/site/start-a-new-project.md +2 -1
  206. package/package.json +5 -2
  207. package/plugins/forgedock-splash/.claude-plugin/plugin.json +10 -0
  208. package/plugins/forgedock-splash/README.md +27 -0
  209. package/plugins/forgedock-splash/hooks/hooks.json +1 -0
  210. package/plugins/forgedock-splash/hooks/register.tsx +74 -0
  211. package/plugins/forgedock-splash/hooks/scene.ts +222 -0
  212. package/plugins/forgedock-splash/types/index.d.ts +10 -0
  213. package/pool/README.md +1 -1
  214. package/pool/image/cs-cred +14 -1
  215. package/scripts/backfill-finding-labels.mjs +50 -0
  216. package/scripts/backfill-finding-labels.test.mjs +36 -0
  217. package/scripts/bench-adversarial.mjs +216 -0
  218. package/scripts/bench-feature.mjs +170 -0
  219. package/scripts/bench-lightlane.mjs +2 -2
  220. package/scripts/bootstrap-create.mjs +2 -2
  221. package/scripts/bootstrap-validate.mjs +35 -2
  222. package/scripts/check-spec-size.sh +4 -3
  223. package/scripts/check-spec-size.test.sh +3 -0
  224. package/scripts/doctor-pipeline-state.sh +21 -6
  225. package/scripts/file-deferred-followups.sh +59 -251
  226. package/scripts/file-deferred-followups.test.sh +85 -206
  227. package/scripts/followup-route.mjs +12 -0
  228. package/scripts/owner-route-parity.test.sh +17 -1
  229. package/scripts/plan-validate-live.mjs +40 -6
  230. package/scripts/review-pr-side-effects.test.sh +40 -0
  231. package/scripts/review-pr-staging-scope.test.sh +1 -1
  232. package/scripts/review-staging-post.sh +23 -0
  233. package/scripts/review-staging-post.test.sh +8 -0
@@ -0,0 +1,170 @@
1
+ #!/usr/bin/env node
2
+ // SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
3
+ // SPDX-License-Identifier: AGPL-3.0-or-later
4
+ /**
5
+ * scripts/bench-feature.mjs — feature benchmark: spec in, running app out, graded by hidden journey tests (forge#5341)
6
+ *
7
+ * Two arms get the same spec (docs/eval/feature-specs/<id>/spec.md): `full` runs ForgeDock end to end (bootstrap, orchestrate,
8
+ * ship) on a sandbox repo, `control` is one bare `claude -p` session in an empty directory. The journeys
9
+ * (<spec>/journeys/*.mjs) are the oracle and never shown to either arm: each is run as `node <journey>` with cwd and BENCH_APP set
10
+ * to the arm's app directory; exit 0 is a pass. Grade: journeys passed, cost, wall time, human interventions.
11
+ * Zero dependencies; every process call goes through an injectable `run`, so tests use fakes. Instructions: docs/eval/feature-bench.md.
12
+ *
13
+ * Usage:
14
+ * node scripts/bench-feature.mjs run --spec <dir> --config <runcfg.json> --out <rows.jsonl> [--arms full,control] [--keep]
15
+ * node scripts/bench-feature.mjs aggregate <rows.jsonl|-> [--previous <scorecard.json>]
16
+ *
17
+ * The harness never writes to GitHub itself; the only GitHub writes are those of the full arm's own forgedock steps.
18
+ * Exit codes: 0 ok | 1 invalid input or a failed run step | 2 a target or the promotion gate failed (scorecard still emitted)
19
+ */
20
+ import { appendFileSync, existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync } from "node:fs";
21
+ import { tmpdir } from "node:os";
22
+ import { join, resolve } from "node:path";
23
+ import { pathToFileURL } from "node:url";
24
+ import { benchDefaultRun } from "./bench-lightlane.mjs";
25
+ import { benchRecord } from "../bin/experiment.mjs";
26
+
27
+ export const ARMS = ["full", "control"];
28
+ export const DEFAULT_STEPS = [
29
+ ["forgedock", "bootstrap", "--repo", "{repo}", "--spec", "{spec}"],
30
+ ["forgedock", "orchestrate", "--repo", "{repo}", "--result-file", "{result}"],
31
+ ["forgedock", "release", "--repo", "{repo}"],
32
+ ];
33
+
34
+ /** {id, prompt, journeys: [{name, path}]} of a spec directory, or a thrown Error naming the problem. */
35
+ export function loadSpec(dir) {
36
+ const d = resolve(dir), specFile = join(d, "spec.md"), jdir = join(d, "journeys");
37
+ if (!existsSync(specFile)) throw new Error(`spec: ${specFile} missing`);
38
+ const prompt = readFileSync(specFile, "utf8");
39
+ if (!prompt.trim()) throw new Error("spec: spec.md is empty");
40
+ const journeys = existsSync(jdir) ? readdirSync(jdir).filter((f) => f.endsWith(".mjs")).sort().map((f) => ({ name: f.replace(/\.mjs$/, ""), path: join(jdir, f) })) : [];
41
+ if (!journeys.length) throw new Error("spec: journeys/*.mjs must hold at least one journey");
42
+ return { id: d.split(/[\\/]/).pop(), file: specFile, prompt, journeys };
43
+ }
44
+
45
+ /** The run config for `arms`, or a thrown Error: full needs {repo}, control needs {model}. */
46
+ export function validateRunConfig(cfg, arms) {
47
+ const a = cfg?.arms;
48
+ if (!a || typeof a !== "object") throw new Error("config: missing arms");
49
+ for (const arm of arms) {
50
+ const x = a[arm];
51
+ if (!x) throw new Error(`config: missing arms.${arm}`);
52
+ if (arm === "control" && (typeof x.model !== "string" || !x.model)) throw new Error("config: arms.control.model is required");
53
+ if (arm === "full" && (typeof x.repo !== "string" || !/^[\w.-]+\/[\w.-]+$/.test(x.repo))) throw new Error("config: arms.full.repo must be owner/name");
54
+ }
55
+ return cfg;
56
+ }
57
+
58
+ const num = (x) => (Number.isFinite(Number(x)) && x !== null && x !== "" ? Number(x) : null);
59
+ const readJson = (p) => { try { return JSON.parse(readFileSync(p, "utf8")); } catch { return null; } };
60
+ const fill = (arg, vars) => Object.entries(vars).reduce((s, [k, v]) => s.replaceAll(`{${k}}`, v), arg);
61
+
62
+ /** Run every journey of `spec` against `app`; -> {name: boolean}. */
63
+ export async function gradeJourneys({ spec, app, run }) {
64
+ const out = {};
65
+ for (const j of spec.journeys) out[j.name] = (await run("node", [j.path], { cwd: app, env: { ...process.env, BENCH_APP: app } })).code === 0;
66
+ return out;
67
+ }
68
+
69
+ /** Run one arm on `spec` and grade it -> one row (see aggregate). `now` is injectable. */
70
+ export async function runArm({ arm, spec, cfg, run = benchDefaultRun, tmp, now = () => Date.now() }) {
71
+ const a = cfg.arms[arm], app = join(tmp, `${arm}-app`);
72
+ const row = { arm, spec: spec.id, journeys_total: spec.journeys.length, journeys_passed: 0, journeys: {}, cost_usd: null, wall_ms: null, interventions: null, terminal: null };
73
+ const t0 = now();
74
+ if (arm === "control") {
75
+ mkdirSync(app, { recursive: true });
76
+ const [bin, ...pre] = Array.isArray(a.command) && a.command.length ? a.command : ["claude"];
77
+ const r = await run(bin, [...pre, "-p", spec.prompt, "--output-format", "json", "--model", a.model, ...(a.args ?? [])], { cwd: app });
78
+ let j = null;
79
+ try { j = JSON.parse(String(r.stdout).trim().split("\n").pop()); } catch { /* reported as terminal below */ }
80
+ row.cost_usd = num(j?.total_cost_usd); row.wall_ms = num(j?.duration_ms) ?? now() - t0; row.interventions = 0;
81
+ row.terminal = r.code !== 0 ? `exit ${r.code}` : !j ? "no-json" : j.is_error ? "error" : "ok";
82
+ } else {
83
+ const rf = join(tmp, "full-result.json"), vars = { repo: a.repo, spec: spec.file, result: rf };
84
+ row.terminal = "ok";
85
+ for (const step of a.steps ?? DEFAULT_STEPS) {
86
+ const [bin, ...args] = step.map((x) => fill(x, vars));
87
+ const r = await run(bin, args, {});
88
+ if (r.code !== 0) { row.terminal = `${args[0] ?? bin} exit ${r.code}`; break; }
89
+ }
90
+ const res = readJson(rf);
91
+ row.cost_usd = num(res?.cost_usd); row.wall_ms = num(res?.wall_ms) ?? now() - t0; row.interventions = num(res?.interventions) ?? num(res?.needs_human) ?? 0;
92
+ const c = await run("git", ["clone", "-q", a.clone_url ?? `https://github.com/${a.repo}.git`, app], { cwd: tmp });
93
+ if (c.code !== 0) { row.terminal = `clone exit ${c.code}`; return row; }
94
+ }
95
+ row.journeys = await gradeJourneys({ spec, app, run });
96
+ row.journeys_passed = Object.values(row.journeys).filter(Boolean).length;
97
+ return row;
98
+ }
99
+
100
+ const r4 = (x) => (x == null ? null : Math.round(x * 10000) / 10000);
101
+ const sum = (xs) => xs.reduce((s, x) => s + x, 0);
102
+ const nums = (rows, k) => rows.map((r) => r[k]).filter((x) => Number.isFinite(x));
103
+
104
+ /** Per-arm metrics over rows (pure). */
105
+ export function armMetrics(rows) {
106
+ const total = sum(rows.map((r) => r.journeys_total ?? 0)), passed = sum(rows.map((r) => r.journeys_passed ?? 0));
107
+ const cost = nums(rows, "cost_usd"), wall = nums(rows, "wall_ms"), iv = nums(rows, "interventions");
108
+ return { n: rows.length, journeys_total: total, journeys_passed: passed, journey_pass_rate: total ? r4(passed / total) : null,
109
+ cost_usd: r4(sum(cost)), wall_ms: sum(wall), interventions: sum(iv) };
110
+ }
111
+
112
+ /**
113
+ * Rows -> {arms, targets, regression, record} (pure). `previous` is the last published scorecard: a full-arm journey pass rate
114
+ * below it is a regression, and the promotion gate (scoreboardGate in bin/stats/scoreboard.mjs) refuses a regressed scorecard.
115
+ * A target is {pass: true|false|null, value, limit}; null when an arm it needs has no rows.
116
+ */
117
+ export function aggregate(rows, { previous = null } = {}) {
118
+ const arms = Object.fromEntries(ARMS.map((a) => [a, armMetrics(rows.filter((r) => r.arm === a))]));
119
+ const F = arms.full, C = arms.control;
120
+ const t = (ok, value, limit) => ({ pass: ok == null ? null : ok, value, limit });
121
+ const targets = { full_journeys_ge_control: t(F.n && C.n ? F.journey_pass_rate >= C.journey_pass_rate : null, F.journey_pass_rate, C.journey_pass_rate) };
122
+ const prev = previous?.arms?.full?.journey_pass_rate;
123
+ const regression = F.n && Number.isFinite(prev) && F.journey_pass_rate < prev ? `full-arm journey pass rate ${F.journey_pass_rate} < previous ${prev}` : null;
124
+ return { arms, targets, regression, record: benchRecord({ source: "bench-feature", arms, targets }) };
125
+ }
126
+
127
+ /** JSONL (or a JSON array) -> rows. */
128
+ export function parseRows(text) {
129
+ const s = String(text).trim();
130
+ if (!s) return [];
131
+ if (s.startsWith("[")) return JSON.parse(s);
132
+ return s.split("\n").filter((l) => l.trim()).map((l) => JSON.parse(l));
133
+ }
134
+
135
+ const flag = (argv, name) => { const i = argv.indexOf(name); return i >= 0 && argv[i + 1] && !argv[i + 1].startsWith("--") ? argv[i + 1] : null; };
136
+
137
+ export async function main(argv = process.argv.slice(2), { run = benchDefaultRun, out = process.stdout, err = process.stderr } = {}) {
138
+ const cmd = argv[0];
139
+ try {
140
+ if (cmd === "aggregate") {
141
+ const src = argv[1] && !argv[1].startsWith("--") ? argv[1] : "-", prev = flag(argv, "--previous");
142
+ const agg = aggregate(parseRows(src === "-" ? readFileSync(0, "utf8") : readFileSync(src, "utf8")), { previous: prev ? JSON.parse(readFileSync(prev, "utf8")) : null });
143
+ out.write(JSON.stringify(agg, null, 2) + "\n");
144
+ return agg.regression || Object.values(agg.targets).some((x) => x.pass === false) ? 2 : 0;
145
+ }
146
+ if (cmd !== "run") { err.write("usage: bench-feature.mjs run|aggregate (see the header)\n"); return 1; }
147
+ const sp = flag(argv, "--spec"), cfgPath = flag(argv, "--config"), rowsOut = flag(argv, "--out");
148
+ if (!sp || !cfgPath || !rowsOut) throw new Error("--spec, --config and --out are required");
149
+ const arms = (flag(argv, "--arms") ?? ARMS.join(",")).split(",").map((s) => s.trim()).filter(Boolean);
150
+ const bad = arms.filter((a) => !ARMS.includes(a));
151
+ if (bad.length) throw new Error(`unknown arm(s): ${bad.join(", ")}`);
152
+ const spec = loadSpec(sp), cfg = validateRunConfig(JSON.parse(readFileSync(cfgPath, "utf8")), arms);
153
+ const tmp = mkdtempSync(join(tmpdir(), "bench-feature-"));
154
+ try {
155
+ for (const arm of arms) {
156
+ const row = await runArm({ arm, spec, cfg, run, tmp });
157
+ appendFileSync(rowsOut, JSON.stringify(row) + "\n");
158
+ err.write(`${arm} ${spec.id}: journeys ${row.journeys_passed}/${row.journeys_total}, $${row.cost_usd ?? "?"}, ${row.terminal}\n`);
159
+ }
160
+ return 0;
161
+ } finally {
162
+ if (!argv.includes("--keep")) rmSync(tmp, { recursive: true, force: true });
163
+ }
164
+ } catch (e) {
165
+ err.write(`ERROR: ${e?.message ?? e}\n`);
166
+ return 1;
167
+ }
168
+ }
169
+
170
+ if (import.meta.url === pathToFileURL(process.argv[1] ?? "").href) process.exitCode = await main();
@@ -123,13 +123,13 @@ async function grade({ run, src, head, base, corpus, issue, tmp, tag, apiShape }
123
123
  await git(run, ["branch", "-f", "bench-head", head], src);
124
124
  const dir = join(tmp, `${tag}-grade`);
125
125
  await git(run, ["clone", "-q", "-b", "bench-head", src, dir], tmp);
126
- await git(run, ["fetch", "-q", corpus.clone_url, issue.fix_sha], dir);
126
+ if (issue.fix_sha) await git(run, ["fetch", "-q", corpus.clone_url, issue.fix_sha], dir); // adversarial issues that must not be fixed have none (#5292)
127
127
  const changed = (await run("git", ["diff", "--quiet", base, "HEAD"], { cwd: dir })).code === 1;
128
128
  let shape;
129
129
  try { const r = await apiShape({ cwd: dir, base, head: "HEAD" }); shape = { status: r?.status ?? "unknown", changes: Array.isArray(r?.changes) ? r.changes : [] }; }
130
130
  catch (e) { shape = { status: "error", changes: [], error: String(e?.message ?? e).slice(0, 200) }; }
131
131
  const suite = (await sh(run, corpus.suite_command, dir)).code === 0;
132
- const oracle = await runOracle(run, dir, issue);
132
+ const oracle = issue.oracle ? await runOracle(run, dir, issue) : false;
133
133
  return { changed, suite_pass: suite, oracle_pass: oracle, api_shape: shape };
134
134
  }
135
135
 
@@ -31,7 +31,7 @@
31
31
  import { execFileSync } from "node:child_process";
32
32
  import { existsSync, readFileSync } from "node:fs";
33
33
  import { fileURLToPath } from "node:url";
34
- import { validatePlan, formatErrors, resolvePlaceholders, isNeedsHuman } from "./bootstrap-validate.mjs";
34
+ import { validatePlan, formatErrors, resolvePlaceholders, isNeedsHuman, isSkeleton } from "./bootstrap-validate.mjs";
35
35
  import { milestoneSlug } from "../bin/lean/lane.mjs";
36
36
 
37
37
  const SELF_DIR = fileURLToPath(new URL(".", import.meta.url));
@@ -218,7 +218,7 @@ export function createBacklog(plan, { io, repo, config = {}, base }) {
218
218
 
219
219
  // Labels: create only the missing ones (never overwrite an existing label's colour or description).
220
220
  const haveLabels = new Set((json(["label", "list", "-R", repo, "--limit", "1000", "--json", "name"]) ?? []).map((l) => l.name));
221
- const issueLabels = (it) => [...(it.labels ?? []), priorityLabel(it), ...(isNeedsHuman(it) ? ["needs-human:external"] : [])].filter(Boolean); // #4660
221
+ const issueLabels = (it) => [...(it.labels ?? []), priorityLabel(it), ...(isNeedsHuman(it) ? ["needs-human:external"] : []), ...(isSkeleton(it) ? ["skeleton"] : [])].filter(Boolean); // #4660, #5337 (the label the admission hold and plan validate --live read)
222
222
  const wanted = new Set(plan.issues.flatMap(issueLabels));
223
223
  for (const l of wanted) if (!haveLabels.has(l)) gh(["label", "create", l, "-R", repo]);
224
224
 
@@ -19,6 +19,9 @@
19
19
  * missing-section, missing-type-tag, missing-parent, missing-labels, unknown-label, code-depends-on-needs-human,
20
20
  * missing-design-spec (a `ui` issue lacks a design-spec item), hero-not-routed (a `hero` issue never names `/design`),
21
21
  * missing-needs-human-section (a needs-human issue lacks setup steps, env var names or secret handling) (#4176).
22
+ * Skeleton (#5337): the first milestone holds exactly one `"skeleton": true` issue (also the `skeleton` label) whose body names the
23
+ * #5336 journey; every other issue depends on it transitively (exempt: the spike, needs-human issues, the skeleton's own
24
+ * ancestors): missing-skeleton, multiple-skeletons, skeleton-misplaced, skeleton-no-journey, not-behind-skeleton.
22
25
  * Warns (never fails; exit stays 0): deploy-last (#4665: every milestone holding deploy workflows comes after the feature
23
26
  * milestones, so nothing can be previewed or deployed until they all ship).
24
27
  * `Depends on` lines are read with the engine's own parser (bin/engine/phases.mjs parseDependsOn) after placeholder
@@ -74,6 +77,10 @@ const NEEDS_HUMAN_PARTS = [
74
77
  const DEPLOY_RE = /\.github\/workflows\/[^\s`'")]*deploy|\bdeploy(?:ment)? workflow\b|\bstaging environment\b/i;
75
78
  const isDeployIssue = (it) => DEPLOY_RE.test(`${it?.title ?? ""}\n${it?.body ?? ""}`);
76
79
 
80
+ export const SKELETON_LABEL = "skeleton";
81
+ /** #5337: the plan's walking-skeleton issue flag (`skeleton: true` or the `skeleton` label). */
82
+ export const isSkeleton = (it) => it?.skeleton === true || (Array.isArray(it?.labels) && it.labels.includes(SKELETON_LABEL));
83
+
77
84
  const isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
78
85
  const isNonEmptyString = (v) => typeof v === "string" && v.trim() !== "";
79
86
  const normHeading = (h) => h.replace(/\([^)]*\)\s*$/, "").trim().toLowerCase();
@@ -154,7 +161,7 @@ function checkStructure(plan) {
154
161
  at("`labels` must be an array of strings");
155
162
  }
156
163
  if (typeof it.body !== "string") at("needs a string `body`");
157
- for (const f of ["ui", "hero"]) if (it[f] !== undefined && typeof it[f] !== "boolean") at(`\`${f}\` must be a boolean`);
164
+ for (const f of ["ui", "hero", "skeleton"]) if (it[f] !== undefined && typeof it[f] !== "boolean") at(`\`${f}\` must be a boolean`);
158
165
  });
159
166
  return errors;
160
167
  }
@@ -232,7 +239,7 @@ export function validatePlan(plan) {
232
239
  if (labels.filter(isNonEmptyString).length === 0) err(it.key, "missing-labels", "issue has no labels");
233
240
  if (declaredLabels) {
234
241
  for (const l of labels) {
235
- if (isNonEmptyString(l) && !declaredLabels.has(l)) err(it.key, "unknown-label", `label ${l} is not in the plan's labels`);
242
+ if (isNonEmptyString(l) && l !== SKELETON_LABEL && !declaredLabels.has(l)) err(it.key, "unknown-label", `label ${l} is not in the plan's labels`);
236
243
  }
237
244
  }
238
245
 
@@ -288,9 +295,35 @@ export function validatePlan(plan) {
288
295
  }
289
296
  }
290
297
  }
298
+ for (const e of skeletonErrors(plan, byKey)) err(e.issue, e.code, e.message);
291
299
  return { ok: errors.length === 0, errors, warnings: deployWarnings(issues, milestones) };
292
300
  }
293
301
 
302
+ /** #5337: walking-skeleton rules (see the header). Needs a valid structure; cycles are reported separately and tolerated here. */
303
+ function skeletonErrors(plan, byKey) {
304
+ const out = [];
305
+ const add = (issue, code, message) => out.push({ issue, code, message });
306
+ const { issues, milestones } = plan;
307
+ const first = milestones[0].key;
308
+ const marked = issues.filter(isSkeleton);
309
+ const inFirst = marked.filter((it) => it.milestone === first);
310
+ for (const it of marked.filter((x) => x.milestone !== first)) add(it.key, "skeleton-misplaced", `skeleton issue is in milestone ${it.milestone}; it belongs in the first milestone ${first}`);
311
+ if (!inFirst.length) { add(issues.find((x) => x.milestone === first)?.key ?? null, "missing-skeleton", `first milestone ${first} has no skeleton issue (\`"skeleton": true\`): the thinnest real path that builds, boots and passes one journey`); return out; }
312
+ if (inFirst.length > 1) add(inFirst[1].key, "multiple-skeletons", `first milestone ${first} has ${inFirst.length} skeleton issues (${inFirst.map((x) => x.key).join(", ")}); exactly one is allowed`);
313
+ const sk = inFirst[0];
314
+ if (!/\bjourney\b/i.test(sk.body)) add(sk.key, "skeleton-no-journey", "skeleton issue acceptance names no journey (one #5336 journey must pass on the thinnest real path)");
315
+ const closure = (start, next) => { const seen = new Set(); const todo = [start]; while (todo.length) { for (const n of next(todo.pop())) if (!seen.has(n)) { seen.add(n); todo.push(n); } } return seen; };
316
+ const ancestors = closure(sk.key, (k) => (byKey.get(k)?.deps ?? []).filter((d) => byKey.has(d)));
317
+ const spike = plan.spike ?? "SPIKE";
318
+ for (const it of issues) {
319
+ if (it.key === sk.key || it.key === spike || isNeedsHuman(it) || ancestors.has(it.key) || isSkeleton(it)) continue;
320
+ if (!closure(it.key, (k) => (byKey.get(k)?.deps ?? []).filter((d) => byKey.has(d))).has(sk.key)) {
321
+ add(it.key, "not-behind-skeleton", `does not depend on skeleton issue ${sk.key}, directly or transitively`);
322
+ }
323
+ }
324
+ return out;
325
+ }
326
+
294
327
  /** #4665: `deploy-last` when deploy work exists but none of it sits in milestones 1-2 (needs >= 3 milestones). */
295
328
  function deployWarnings(issues, milestones) {
296
329
  const index = new Map(milestones.map((m, i) => [m.key, i]));
@@ -5,7 +5,7 @@
5
5
  #
6
6
  # Usage: check-spec-size.sh [base_ref] (default: $BASE_REF, else origin/staging)
7
7
  # Env: PR_LABELS comma-separated PR label names (untrusted; grep-matched only)
8
- # PR_HEAD_REF / PR_BASE_REF PR head and base branch names; staging -> main
8
+ # PR_HEAD_REF / PR_BASE_REF PR head and base branch names; staging|release/* -> main
9
9
  # (a release PR) is skipped: cumulative growth is not judged here
10
10
  # PR_SAME_REPO must be "true" for the release skip (a fork branch named
11
11
  # staging must not bypass the budget)
@@ -40,10 +40,11 @@ if ! git rev-parse --verify -q "$BASE^{commit}" >/dev/null; then
40
40
  fi
41
41
 
42
42
  # --- release PR skip (staging -> main) ---------------------------------------
43
- if [ "${PR_HEAD_REF:-}" = "staging" ] && [ "${PR_BASE_REF:-}" = "main" ] && [ "${PR_SAME_REPO:-}" = "true" ]; then
43
+ case "${PR_HEAD_REF:-}" in staging|release/*) _REL_HEAD=1 ;; *) _REL_HEAD=0 ;; esac
44
+ if [ "$_REL_HEAD" = "1" ] && [ "${PR_BASE_REF:-}" = "main" ] && [ "${PR_SAME_REPO:-}" = "true" ]; then
44
45
  out "## Spec-size budget"
45
46
  out ""
46
- out "Result: SKIPPED (release PR staging -> main; growth was checked per PR)"
47
+ out "Result: SKIPPED (release PR staging|release/* -> main; growth was checked per PR)"
47
48
  echo "spec-size: skipped for release PR staging -> main"
48
49
  exit 0
49
50
  fi
@@ -122,6 +122,9 @@ run "stub plus a re-pasted resolver block fails" 1
122
122
  # Release PR skip (staging -> main only)
123
123
  reset; gen 100 >> commands/review-pr.md
124
124
  run "release PR skipped" 0 PR_HEAD_REF=staging PR_BASE_REF=main PR_SAME_REPO=true; has "skip reported" "SKIPPED"
125
+ run "release/* branch to main skipped" 0 PR_HEAD_REF=release/20261110-2 PR_BASE_REF=main PR_SAME_REPO=true; has "skip reported" "SKIPPED"
126
+ run "release/* fork branch still checked" 1 PR_HEAD_REF=release/20261110-2 PR_BASE_REF=main PR_SAME_REPO=false
127
+ run "release/* to other base still checked" 1 PR_HEAD_REF=release/20261110-2 PR_BASE_REF=dev PR_SAME_REPO=true
125
128
  run "fork branch named staging still checked" 1 PR_HEAD_REF=staging PR_BASE_REF=main PR_SAME_REPO=false
126
129
  run "release PR without same-repo flag still checked" 1 PR_HEAD_REF=staging PR_BASE_REF=main
127
130
  run "hotfix to main still checked" 1 PR_HEAD_REF=hotfix PR_BASE_REF=main
@@ -41,9 +41,11 @@
41
41
  # I1 Issues stuck in workflow:investigating beyond threshold
42
42
  # I2 Issues stuck in workflow:building beyond threshold
43
43
  # I3 Issues stuck in workflow:in-review beyond threshold
44
- # I4 Issues in workflow:building with no FORGE:BUILDER annotation
44
+ # I4 Issues in workflow:building past the threshold with no builder evidence
45
+ # (FORGE:BUILDER, or the lean FORGE:CONTRACT / FORGE:PLAN / FORGE:WORK-ON)
45
46
  # I5 Issues in workflow:in-review with no open PR
46
- # I6 PRs open without a FORGE:CONTRACT or FORGE:BUILDER annotation
47
+ # I6 PRs open without a FORGE: marker that are not lane PRs (lean head branch or
48
+ # pipeline bot author) or dependency-bot PRs (dependabot, renovate)
47
49
  # I7 Orphaned worktree branches (local branches fix/* with no open PR)
48
50
  # I8 FORGE-referenced gists with public visibility (KNOWLEDGE_GIST, MILESTONE_INDEX,
49
51
  # PRIOR_GIST annotations in recent issue comments)
@@ -401,16 +403,21 @@ while IFS= read -r row; do
401
403
  done < <(echo "$ENGINE_ERRORS" | jq -c '.[]')
402
404
 
403
405
  # ---------------------------------------------------------------------------
404
- # I4: Issues in workflow:building with no FORGE:BUILDER annotation
406
+ # I4: Issues in workflow:building with no builder evidence
407
+ # Lean lanes never write FORGE:BUILDER; FORGE:CONTRACT / FORGE:PLAN / FORGE:WORK-ON
408
+ # count as evidence. Issues active within the stuck threshold are in flight, not broken.
405
409
  # ---------------------------------------------------------------------------
406
410
  while IFS= read -r row; do
407
411
  num=$(echo "$row" | jq -r '.number')
408
- # Check for FORGE:BUILDER annotation in issue comments.
412
+ if [ "$(hours_since "$(echo "$row" | jq -r '.updatedAt')")" -lt "$STUCK_HOURS" ]; then
413
+ continue
414
+ fi
415
+ # Check for builder evidence in issue comments.
409
416
  # Distinguish a confirmed-absent annotation from a gh API failure (rate limit,
410
417
  # network blip, auth issue) — an API failure must NOT be treated as confirmed-missing.
411
418
  if ! has_builder=$(gh issue view "$num" $GH_FLAG \
412
419
  --json comments \
413
- --jq '[.comments[].body | contains("FORGE:BUILDER")] | any' 2>"$GH_STDERR_TMP"); then
420
+ --jq '[.comments[].body | test("FORGE:(BUILDER|CONTRACT|PLAN|WORK-ON)")] | any' 2>"$GH_STDERR_TMP"); then
414
421
  echo "WARNING: gh issue view failed for #$num — I4 check inconclusive, skipping (not treated as missing): $(cat "$GH_STDERR_TMP")" >&2
415
422
  add_skip "I4" "$num" "gh issue view failed: $(bounded_reason "$(cat "$GH_STDERR_TMP")")"
416
423
  continue
@@ -458,7 +465,7 @@ done < <(echo "$IN_REVIEW" | jq -c '.[]')
458
465
  if ! OPEN_PRS=$(gh pr list $GH_FLAG \
459
466
  --state open \
460
467
  --limit 50 \
461
- --json number,title,body,createdAt 2>"$GH_STDERR_TMP"); then
468
+ --json number,title,body,createdAt,author,headRefName 2>"$GH_STDERR_TMP"); then
462
469
  echo "WARNING: gh pr list failed for open PRs — I6 check inconclusive, skipping (not treated as empty): $(cat "$GH_STDERR_TMP")" >&2
463
470
  add_skip "I6" "all" "gh pr list failed: $(bounded_reason "$(cat "$GH_STDERR_TMP")")"
464
471
  OPEN_PRS="[]"
@@ -474,6 +481,14 @@ while IFS= read -r row; do
474
481
  continue
475
482
  fi
476
483
  has_forge=$(echo "$body" | grep -c "FORGE:" || true)
484
+ # Lane PRs (lean head branch or pipeline bot app) and dependency-bot PRs are not hand-made.
485
+ head_ref=$(echo "$row" | jq -r '.headRefName // ""')
486
+ author=$(echo "$row" | jq -r '.author.login // ""')
487
+ if [[ "$head_ref" =~ ^(feat|fix)/issue-[0-9]+-lean$ ]] || \
488
+ [[ "$author" =~ ^(app/)?(rapiercraft-forgedock|forgedock)(\[bot\])?$ ]] || \
489
+ [[ "$author" =~ ^(app/)?(dependabot|renovate)(\[bot\])?$ ]]; then
490
+ continue
491
+ fi
477
492
  if [ "$has_forge" -eq 0 ]; then
478
493
  add_finding \
479
494
  "pr_missing_annotations" "warning" \