forgedock 1.53.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 (185) 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 +6 -3
  12. package/bin/engine/telemetry-seam.mjs +8 -2
  13. package/bin/engine/telemetry-seam.test.mjs +17 -0
  14. package/bin/engine-cli.mjs +57 -20
  15. package/bin/first-run.mjs +122 -0
  16. package/bin/forgedock.mjs +128 -146
  17. package/bin/help-text.mjs +144 -0
  18. package/bin/hooks/pre-tool-use.mjs +7 -0
  19. package/bin/journey.mjs +82 -83
  20. package/bin/lean/acceptance.mjs +313 -0
  21. package/bin/lean/acceptance.test.mjs +215 -0
  22. package/bin/lean/activation.mjs +18 -0
  23. package/bin/lean/activation.test.mjs +23 -1
  24. package/bin/lean/batch-health.mjs +74 -1
  25. package/bin/lean/batch-health.test.mjs +54 -1
  26. package/bin/lean/batch.test.mjs +11 -9
  27. package/bin/lean/branchlock.mjs +54 -0
  28. package/bin/lean/branchlock.test.mjs +49 -0
  29. package/bin/lean/ceiling.mjs +72 -0
  30. package/bin/lean/ceiling.test.mjs +54 -0
  31. package/bin/lean/ci-budget.mjs +366 -0
  32. package/bin/lean/ci-budget.test.mjs +167 -0
  33. package/bin/lean/conformance.e2e.test.mjs +7 -0
  34. package/bin/lean/conformance.mjs +77 -19
  35. package/bin/lean/conformance.test.mjs +129 -3
  36. package/bin/lean/context.mjs +35 -6
  37. package/bin/lean/context.test.mjs +27 -1
  38. package/bin/lean/depcache.mjs +25 -1
  39. package/bin/lean/depcache.test.mjs +26 -0
  40. package/bin/lean/e2e.mjs +18 -2
  41. package/bin/lean/e2e.test.mjs +26 -1
  42. package/bin/lean/effects.mjs +40 -11
  43. package/bin/lean/execution.test.mjs +24 -0
  44. package/bin/lean/facts.mjs +3 -3
  45. package/bin/lean/facts.test.mjs +5 -0
  46. package/bin/lean/fixround.mjs +14 -0
  47. package/bin/lean/fixround.test.mjs +25 -2
  48. package/bin/lean/gh-assoc.test.mjs +2 -1
  49. package/bin/lean/integration.mjs +100 -9
  50. package/bin/lean/integration.test.mjs +98 -0
  51. package/bin/lean/issuewatch-parity.mjs +64 -0
  52. package/bin/lean/issuewatch-parity.test.mjs +127 -0
  53. package/bin/lean/issuewatch-release.test.mjs +1 -1
  54. package/bin/lean/issuewatch.mjs +34 -5
  55. package/bin/lean/issuewatch.test.mjs +3 -2
  56. package/bin/lean/lean.mjs +316 -74
  57. package/bin/lean/lean.test.mjs +397 -24
  58. package/bin/lean/mechfix.mjs +124 -0
  59. package/bin/lean/mechfix.test.mjs +75 -0
  60. package/bin/lean/orchestrate.mjs +20 -2
  61. package/bin/lean/phaseledger.mjs +47 -5
  62. package/bin/lean/phaseledger.test.mjs +30 -1
  63. package/bin/lean/precheck.mjs +23 -4
  64. package/bin/lean/precheck.test.mjs +14 -1
  65. package/bin/lean/prereq.mjs +28 -0
  66. package/bin/lean/prereq.test.mjs +20 -0
  67. package/bin/lean/probe.mjs +4 -2
  68. package/bin/lean/prodparity.mjs +52 -0
  69. package/bin/lean/prodparity.test.mjs +67 -0
  70. package/bin/lean/prompts.mjs +69 -12
  71. package/bin/lean/recovery.test.mjs +1 -1
  72. package/bin/lean/release-io.test.mjs +42 -0
  73. package/bin/lean/release-postmerge.mjs +6 -0
  74. package/bin/lean/release-preflight.mjs +58 -0
  75. package/bin/lean/release-preflight.test.mjs +114 -0
  76. package/bin/lean/release-rehearsal.mjs +8 -7
  77. package/bin/lean/release-review.mjs +67 -11
  78. package/bin/lean/release-review.test.mjs +128 -1
  79. package/bin/lean/release-snapshot.mjs +188 -0
  80. package/bin/lean/release-snapshot.test.mjs +190 -0
  81. package/bin/lean/release.mjs +80 -12
  82. package/bin/lean/release.test.mjs +95 -0
  83. package/bin/lean/render.mjs +1 -1
  84. package/bin/lean/replan.mjs +184 -0
  85. package/bin/lean/replan.test.mjs +110 -0
  86. package/bin/lean/resume.mjs +9 -7
  87. package/bin/lean/resume.test.mjs +16 -0
  88. package/bin/lean/schedd.mjs +34 -1
  89. package/bin/lean/schedd.test.mjs +21 -1
  90. package/bin/lean/selfreview.mjs +94 -0
  91. package/bin/lean/selfreview.test.mjs +58 -1
  92. package/bin/lean/selftest-gate.mjs +22 -0
  93. package/bin/lean/selftest-gate.test.mjs +18 -1
  94. package/bin/lean/selftest-journey.mjs +234 -0
  95. package/bin/lean/selftest-journey.test.mjs +130 -0
  96. package/bin/lean/selftest-live.mjs +2 -1
  97. package/bin/lean/seqlease.mjs +35 -1
  98. package/bin/lean/seqlease.test.mjs +15 -0
  99. package/bin/lean/seqreserve.e2e.test.mjs +135 -0
  100. package/bin/lean/seqreserve.mjs +73 -0
  101. package/bin/lean/seqreserve.test.mjs +134 -0
  102. package/bin/lean/sequence.mjs +35 -6
  103. package/bin/lean/seqversioned.mjs +147 -0
  104. package/bin/lean/stagestamp.mjs +28 -0
  105. package/bin/lean/stagestamp.test.mjs +32 -0
  106. package/bin/lean/surfaces.mjs +75 -0
  107. package/bin/lean/surfaces.test.mjs +59 -0
  108. package/bin/lean/toolplace.mjs +28 -0
  109. package/bin/lean/toolplace.test.mjs +24 -0
  110. package/bin/lean/toolstats.mjs +3 -1
  111. package/bin/lean/toolstats.test.mjs +11 -0
  112. package/bin/lean/validatebest.mjs +28 -0
  113. package/bin/lean/validatebest.test.mjs +27 -0
  114. package/bin/pool/agent.mjs +9 -0
  115. package/bin/pool/docker.mjs +5 -0
  116. package/bin/pool/router.mjs +8 -4
  117. package/bin/prereqs.mjs +111 -0
  118. package/bin/replay-timelapse.mjs +149 -0
  119. package/bin/review-staging.mjs +100 -16
  120. package/bin/review-staging.test.mjs +18 -0
  121. package/bin/runner.mjs +43 -6
  122. package/bin/splash-install.mjs +157 -0
  123. package/bin/stats/aggregate.mjs +8 -1
  124. package/bin/stats/conformance-outcomes.mjs +100 -19
  125. package/bin/stats/conformance-outcomes.test.mjs +87 -1
  126. package/bin/stats/depth.mjs +88 -31
  127. package/bin/stats/depth.test.mjs +63 -38
  128. package/bin/stats/efficiency.mjs +26 -5
  129. package/bin/stats/efficiency.test.mjs +45 -1
  130. package/bin/stats/first-review.mjs +77 -0
  131. package/bin/stats/first-review.test.mjs +36 -0
  132. package/bin/stats/firstmerge.mjs +40 -0
  133. package/bin/stats/firstmerge.test.mjs +41 -0
  134. package/bin/stats/github-source.mjs +51 -13
  135. package/bin/stats/index.mjs +91 -15
  136. package/bin/stats/local-source.mjs +1 -0
  137. package/bin/stats/origin.mjs +80 -0
  138. package/bin/stats/origin.test.mjs +58 -0
  139. package/bin/stats/render.mjs +3 -1
  140. package/bin/stats/scoreboard.mjs +137 -0
  141. package/bin/stats/scoreboard.test.mjs +87 -0
  142. package/bin/stats/stats.test.mjs +80 -0
  143. package/bin/tui.mjs +3 -2
  144. package/commands/bootstrap.md +15 -14
  145. package/commands/deploy-pr.md +18 -3
  146. package/commands/forge-stats.md +1 -1
  147. package/commands/forgedock-ci-setup.md +28 -0
  148. package/commands/forgedock-init.md +4 -5
  149. package/commands/issue.md +2 -0
  150. package/commands/milestone.md +9 -1
  151. package/commands/replay.md +2 -0
  152. package/commands/review-pr-staging.md +4 -1
  153. package/commands/work-on/close.md +8 -0
  154. package/docs/CONFIG.md +105 -10
  155. package/docs/ISSUE-WATCH.md +23 -0
  156. package/docs/OUTCOME-CODES.md +1 -0
  157. package/docs/REPLAY.md +9 -0
  158. package/docs/SELFTEST.md +11 -0
  159. package/docs/STATS.md +19 -2
  160. package/docs/eval/README.md +6 -0
  161. package/docs/eval/adversarial-bench.md +68 -0
  162. package/docs/eval/corpus/adversarial-v1.json +285 -0
  163. package/docs/eval/feature-bench.md +42 -0
  164. package/docs/eval/feature-specs/crud-auth/journeys/notes-crud-isolated.mjs +21 -0
  165. package/docs/eval/feature-specs/crud-auth/journeys/register-login.mjs +12 -0
  166. package/docs/eval/feature-specs/crud-auth/spec.md +15 -0
  167. package/docs/site/start-a-new-project.md +2 -1
  168. package/package.json +5 -2
  169. package/plugins/forgedock-splash/.claude-plugin/plugin.json +10 -0
  170. package/plugins/forgedock-splash/README.md +27 -0
  171. package/plugins/forgedock-splash/hooks/hooks.json +1 -0
  172. package/plugins/forgedock-splash/hooks/register.tsx +74 -0
  173. package/plugins/forgedock-splash/hooks/scene.ts +222 -0
  174. package/plugins/forgedock-splash/types/index.d.ts +10 -0
  175. package/scripts/bench-adversarial.mjs +216 -0
  176. package/scripts/bench-feature.mjs +170 -0
  177. package/scripts/bench-lightlane.mjs +2 -2
  178. package/scripts/bootstrap-create.mjs +2 -2
  179. package/scripts/bootstrap-validate.mjs +35 -2
  180. package/scripts/check-spec-size.sh +4 -3
  181. package/scripts/check-spec-size.test.sh +3 -0
  182. package/scripts/plan-validate-live.mjs +40 -6
  183. package/scripts/review-pr-staging-scope.test.sh +1 -1
  184. package/scripts/review-staging-post.sh +23 -0
  185. package/scripts/review-staging-post.test.sh +8 -0
@@ -0,0 +1,222 @@
1
+ // SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
2
+ // SPDX-License-Identifier: AGPL-3.0-or-later
3
+ // Pure scene: frame number -> rows of coloured runs. No engine imports, so the
4
+ // same code drives the mod and the offline frame preview.
5
+
6
+ export type Run = { text: string; color?: string; bold?: boolean }
7
+ type Cell = { ch: string; color?: string; bold?: boolean }
8
+
9
+ export const TICK = 60
10
+
11
+ // The ForgeDock "F" mark, exactly as the CLI draws it (bin/cinema.mjs HERO_MARK).
12
+ const MARK = [
13
+ ' ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄',
14
+ ' ▄▄██████████████████',
15
+ ' ▄█████████████▀▀▀▀▀▀▀▀▀',
16
+ ' ▄██████████▀▀',
17
+ ' ▀▀▀▀▀ ▄▄███████▀',
18
+ ' ▄████████▀',
19
+ ' ▄██████▀',
20
+ ' ▀▀▀▀',
21
+ ]
22
+ const MW = 28 // mark width
23
+ const TOP = 1 // canvas row of the mark's first row (row 0 is headroom for sparks)
24
+ const H = MARK.length + TOP
25
+ const CW = 56 // canvas width
26
+ const TEXT_X = 33 // column of the wordmark block
27
+
28
+ // Brand stops (bin/cinema.mjs) and Claude's orange for the mascot.
29
+ const DARK = { chrome: ['#f7f3ea', '#d9cfba', '#a99a82', '#6e6252'], ember: ['#ff4d00', '#ff8c1a', '#ffd166'], hot: '#ffffff', bg: '#1a1714' }
30
+ // Light terminals: a darker steel and deeper embers so the mark reads on white; the "white-hot" flash becomes bright orange.
31
+ const LIGHT = { chrome: ['#6e6252', '#5c5144', '#4a4136', '#2f2922'], ember: ['#c43c00', '#e06600', '#f29d00'], hot: '#ff7a00', bg: '#f4f1ec' }
32
+ let CHROME = DARK.chrome
33
+ let EMBER = DARK.ember
34
+ let WHITE = DARK.hot
35
+ let BG = DARK.bg
36
+ const CLAUDE = '#d97757'
37
+
38
+ /** Pick the palette for the terminal's theme (Claude Code's `theme` setting). */
39
+ export function setTheme(light: boolean) {
40
+ const t = light ? LIGHT : DARK
41
+ CHROME = t.chrome
42
+ EMBER = t.ember
43
+ WHITE = t.hot
44
+ BG = t.bg
45
+ }
46
+
47
+ /** Smallest band the scene fits in. */
48
+ export const MIN_COLUMNS = 56
49
+ export const MIN_ROWS = 9
50
+ const WORD = 'F O R G E D O C K'
51
+
52
+ // Clawd poses (3 rows, 9 wide).
53
+ const P = {
54
+ stand: [' ▐▛███▜▌ ', '▝▜█████▛▘', ' ▘▘ ▝▝ '],
55
+ stepA: [' ▐▛███▜▌ ', '▝▜█████▛▘', ' ▘▘ ▝▝ '],
56
+ stepB: [' ▐▛███▜▌ ', '▝▜█████▛▘', ' ▘▘ ▝▝ '],
57
+ look: [' ▐▀███▀▌ ', '▝▜█████▛▘', ' ▘▘ ▝▝ '],
58
+ blink: [' ▐█████▌ ', '▝▜█████▛▘', ' ▘▘ ▝▝ '],
59
+ side: [' ▐█▜██▛▌ ', '▝▜█████▛▘', ' ▘▘ ▝▝ '],
60
+ crouch: [' ', ' ▐▛███▜▌ ', '▀▀█████▀▀'],
61
+ jump: ['▗▐▀███▀▌▖', ' ▜█████▛ ', ' ▝▘ ▝▘ '],
62
+ cheer: ['▗▐▛███▜▌▖', ' ▜█████▛ ', ' ▘▘ ▝▝ '],
63
+ }
64
+
65
+ // Beats (frame numbers).
66
+ const FORGE = 12 // the F is forged in, glowing then cooling
67
+ const WALK_END = FORGE + 18 // Clawd walks in under the overhang
68
+ const LOOK_END = WALK_END + 5 // looks up at the bar
69
+ const CROUCH_END = LOOK_END + 2
70
+ const BONK = CROUCH_END + 3 // head meets the bar
71
+ const LAND = BONK + 3
72
+ const SHINE_END = BONK + 18 // shine ring expands from the impact
73
+ const TYPE_START = BONK + 6
74
+ const TYPE_END = TYPE_START + WORD.length
75
+ const HOLD_START = TYPE_END + 4
76
+ const FADE_START = HOLD_START + 32
77
+ export const LAST = FADE_START + 10
78
+
79
+ const CLAWD_X = 21 // under the right end of the top bar, clear of the F's lower strokes
80
+ const START_X = CW // walks in from the right edge
81
+ const IMPACT = { r: TOP + 2, c: 25 } // underside of the top bar, above Clawd's head
82
+
83
+ const hex = (s: string) => [1, 3, 5].map(i => parseInt(s.slice(i, i + 2), 16))
84
+ export const mix = (a: string, b: string, t: number) => {
85
+ const x = hex(a), y = hex(b), k = Math.max(0, Math.min(1, t))
86
+ return '#' + x.map((v, i) => Math.round(v + ((y[i] ?? v) - v) * k).toString(16).padStart(2, '0')).join('')
87
+ }
88
+ const ramp = (stops: string[], t: number) => {
89
+ const u = Math.max(0, Math.min(1, t)) * (stops.length - 1)
90
+ const i = Math.min(stops.length - 2, Math.floor(u))
91
+ return mix(stops[i] ?? WHITE, stops[i + 1] ?? WHITE, u - i)
92
+ }
93
+ const easeOut = (t: number) => 1 - (1 - t) * (1 - t)
94
+
95
+ function markColor(r: number, c: number, f: number): string | null {
96
+ const chrome = ramp(CHROME, c / MW + r * 0.06)
97
+ if (f < FORGE + 6) {
98
+ const age = (f / FORGE) * (MW + 6) - r * 0.6 - c
99
+ if (age < 0) return null
100
+ if (age < 1.5) return EMBER[2] ?? WHITE
101
+ if (age < 3) return EMBER[1] ?? WHITE
102
+ if (age < 5) return EMBER[0] ?? WHITE
103
+ return mix(EMBER[0] ?? WHITE, chrome, (age - 5) / 5)
104
+ }
105
+ if (f >= BONK && f < SHINE_END) {
106
+ const t = f - BONK
107
+ const dr = (r + TOP - IMPACT.r) * 2 // rows are ~2x taller than columns are wide
108
+ const dist = Math.sqrt(dr * dr + (c - IMPACT.c) ** 2)
109
+ if (t < 2 && dist < 2.6) return WHITE // a small flash right at the point of impact
110
+ if (t < 7 && dist < 4) {
111
+ // the struck spot glows hot, then fades straight back to chrome (no muddy brown)
112
+ const heat = t < 4 ? (EMBER[2] ?? WHITE) : (EMBER[1] ?? WHITE)
113
+ return mix(heat, chrome, Math.min(1, (t - 2) / 4 + dist / 6))
114
+ }
115
+ const radius = (t - 1) * 2.4
116
+ const d = Math.abs(dist - radius)
117
+ if (d < 1.2) return WHITE
118
+ if (d < 3) return mix(WHITE, chrome, (d - 1.2) / 1.8)
119
+ }
120
+ return chrome
121
+ }
122
+
123
+ function clawd(f: number): { x: number; lift: number; pose: string[] } | null {
124
+ if (f < FORGE) return null
125
+ if (f < WALK_END) {
126
+ const t = (f - FORGE) / (WALK_END - FORGE)
127
+ const x = Math.round(START_X + (CLAWD_X - START_X) * easeOut(t))
128
+ return { x, lift: 0, pose: Math.floor(f / 2) % 2 ? P.stepA : P.stepB }
129
+ }
130
+ if (f < LOOK_END) return { x: CLAWD_X, lift: 0, pose: P.look }
131
+ if (f < CROUCH_END) return { x: CLAWD_X, lift: 0, pose: P.crouch }
132
+ if (f < BONK) return { x: CLAWD_X, lift: Math.min(2, f - CROUCH_END + 1), pose: P.jump }
133
+ if (f === BONK) return { x: CLAWD_X, lift: 2, pose: P.jump }
134
+ if (f < LAND) return { x: CLAWD_X, lift: LAND - f, pose: P.jump }
135
+ if (f === LAND) return { x: CLAWD_X, lift: 0, pose: P.crouch }
136
+ if (f < HOLD_START) {
137
+ const k = (f - LAND) % 6
138
+ return { x: CLAWD_X, lift: k === 2 || k === 3 ? 1 : 0, pose: P.cheer }
139
+ }
140
+ // Idle: glance at the wordmark, a happy hop, then a blink.
141
+ const k = f - HOLD_START
142
+ if (k >= 4 && k < 14) return { x: CLAWD_X, lift: 0, pose: P.side }
143
+ if (k >= 16 && k < 20) return { x: CLAWD_X, lift: k === 17 || k === 18 ? 1 : 0, pose: P.cheer }
144
+ return { x: CLAWD_X, lift: 0, pose: k === 24 || k === 25 ? P.blink : P.stand }
145
+ }
146
+
147
+ // Sparks thrown from the impact: analytic paths with a little gravity.
148
+ const SPARKS = [
149
+ [1.2, -1.1], [2.2, -0.8], [3.2, -0.35], [3.8, 0.15], [2.8, 0.55], [1.6, 0.9], [4.4, -0.6], [0.6, -1.4],
150
+ ]
151
+ function sparks(f: number, put: (r: number, c: number, cell: Cell) => void) {
152
+ const t = f - BONK
153
+ if (t < 1 || t > 11) return
154
+ // Plain glyphs every terminal font has.
155
+ const glyph = ['*', '*', '*', '+', '+', '+', '•', '•', '·', '·', '.', '.'][t] ?? '.'
156
+ const color = t < 3 ? WHITE : t < 5 ? (EMBER[2] ?? WHITE) : t < 8 ? (EMBER[1] ?? WHITE) : (EMBER[0] ?? WHITE)
157
+ for (const [vx, vy] of SPARKS) {
158
+ const c = Math.round(IMPACT.c + 2 + (vx ?? 0) * t * 1.3)
159
+ const r = Math.round(IMPACT.r + (vy ?? 0) * t * 0.6 + 0.05 * t * t)
160
+ put(r, c, { ch: glyph, color, bold: t < 4 })
161
+ }
162
+ }
163
+
164
+ export function scene(f: number): Run[][] {
165
+ const grid: Cell[][] = Array.from({ length: H }, () => Array.from({ length: CW }, () => ({ ch: ' ' })))
166
+ const put = (r: number, c: number, cell: Cell, over = false) => {
167
+ const row = grid[r]
168
+ if (!row || c < 0 || c >= CW) return
169
+ if (!over && row[c]?.ch !== ' ') return
170
+ row[c] = cell
171
+ }
172
+
173
+ MARK.forEach((line, r) =>
174
+ [...line].forEach((ch, c) => {
175
+ if (ch === ' ') return
176
+ const color = markColor(r, c, f)
177
+ if (color) put(r + TOP, c, { ch, color })
178
+ }),
179
+ )
180
+
181
+ // Wordmark block: letters land white-hot and cool to ember.
182
+ if (f >= TYPE_START) {
183
+ const n = Math.min(WORD.length, f - TYPE_START + 1)
184
+ ;[...WORD.slice(0, n)].forEach((ch, i) => {
185
+ const age = f - TYPE_START - i
186
+ const settled = ramp(EMBER, i / WORD.length)
187
+ put(TOP + 2, TEXT_X + i, { ch, color: age < 1 ? WHITE : age < 3 ? mix(WHITE, settled, age / 3) : settled, bold: true })
188
+ })
189
+ }
190
+ if (f >= TYPE_END) [...'for Claude Code'].forEach((ch, i) => put(TOP + 3, TEXT_X + i, { ch, color: CLAUDE, bold: true }))
191
+ if (f >= HOLD_START) {
192
+ const pulse = ramp(EMBER, 0.5 + 0.5 * Math.sin((f - HOLD_START) / 3))
193
+ ;[...'» supercharged'].forEach((ch, i) => put(TOP + 5, TEXT_X + i, { ch, color: pulse, bold: true }))
194
+ }
195
+
196
+ const cd = clawd(f)
197
+ if (cd) {
198
+ const top = H - 3 - cd.lift
199
+ cd.pose.forEach((line, i) =>
200
+ [...line].forEach((ch, j) => {
201
+ if (ch !== ' ') put(top + i, cd.x + j, { ch, color: CLAUDE }, true)
202
+ }),
203
+ )
204
+ }
205
+ sparks(f, put)
206
+
207
+ // Fade everything to the background over the last beat.
208
+ const fade = f >= FADE_START ? (f - FADE_START + 1) / (LAST - FADE_START + 1) : 0
209
+
210
+ return grid.map(row => {
211
+ const runs: Run[] = []
212
+ for (const cell of row) {
213
+ const color = cell.color && fade > 0 ? mix(cell.color, BG, fade) : cell.color
214
+ const last = runs[runs.length - 1]
215
+ if (last && last.color === color && last.bold === cell.bold) last.text += cell.ch
216
+ else runs.push({ text: cell.ch, color, bold: cell.bold })
217
+ }
218
+ // Drop trailing blanks so the band is no wider than it needs to be.
219
+ while (runs.length && !runs[runs.length - 1]?.color && !runs[runs.length - 1]?.text.trim()) runs.pop()
220
+ return runs
221
+ })
222
+ }
@@ -0,0 +1,10 @@
1
+ // SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
2
+ // SPDX-License-Identifier: AGPL-3.0-or-later
3
+ /** Animation frame of the splash; -1 when hidden. */
4
+ export type Frame = number
5
+
6
+ declare module 'claude-code' {
7
+ interface PluginState {
8
+ 'forgedock-splash': { frame: Frame }
9
+ }
10
+ }
@@ -0,0 +1,216 @@
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-adversarial.mjs — adversarial corpus: full lane vs a bare-agent control (#5292)
6
+ *
7
+ * Sibling of bench-lightlane.mjs (#4453), which it reuses for the arm runs. The corpus mixes valid issues with ones that
8
+ * must not be implemented (wrong premise, duplicate of an existing feature, already shipped) and with integration issues
9
+ * whose correct change touches more than one file. Grading is deterministic (diff paths and added lines), no LLM.
10
+ * Instructions: docs/eval/adversarial-bench.md. Corpus: docs/eval/corpus/adversarial-v1.json.
11
+ *
12
+ * Usage:
13
+ * node scripts/bench-adversarial.mjs validate --corpus <corpus.json>
14
+ * node scripts/bench-adversarial.mjs calibrate --corpus <corpus.json>
15
+ * node scripts/bench-adversarial.mjs run --corpus <corpus.json> --config <runcfg.json> --out <rows.jsonl> [--arms full,control] [--issues id,...] [--keep]
16
+ * node scripts/bench-adversarial.mjs aggregate <rows.jsonl|-> --corpus <corpus.json> --model <id> --date <YYYY-MM-DD> [--scorecard <file.md>]
17
+ *
18
+ * Exit codes: 0 ok | 1 invalid input or a failed run step | 2 a calibration check failed (output still emitted)
19
+ */
20
+
21
+ import { createHash } from "node:crypto";
22
+ import { appendFileSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
23
+ import { tmpdir } from "node:os";
24
+ import { join } from "node:path";
25
+ import { pathToFileURL } from "node:url";
26
+ import { benchDefaultRun, parseRows, runArm, validateRunConfig } from "./bench-lightlane.mjs";
27
+
28
+ export const ADV_ARMS = ["full", "control"];
29
+ export const KINDS = ["valid", "wrong-premise", "duplicate", "already-fixed", "integration"];
30
+ export const MIN_ISSUES = 20;
31
+ export const MIN_INVALID = 5;
32
+ const INVALID = new Set(["wrong-premise", "duplicate", "already-fixed"]);
33
+ const SHA_RE = /^[0-9a-f]{40}$/;
34
+
35
+ /** True for an issue that must be closed with evidence instead of implemented. */
36
+ export const isInvalid = (issue) => INVALID.has(issue?.kind);
37
+
38
+ const goodRegex = (p) => { try { new RegExp(p); return typeof p === "string" && p.length > 0; } catch { return false; } };
39
+
40
+ /** A parsed corpus, or a thrown Error naming the first bad field. */
41
+ export function validateAdversarialCorpus(c) {
42
+ if (!c || typeof c !== "object") throw new Error("corpus: not an object");
43
+ for (const k of ["version", "clone_url", "suite_command", "control_prompt"]) if (typeof c[k] !== "string" || !c[k].trim()) throw new Error(`corpus: missing ${k}`);
44
+ if (!SHA_RE.test(String(c.base))) throw new Error("corpus: base must be a full 40-hex sha");
45
+ if (!Array.isArray(c.issues) || c.issues.length < MIN_ISSUES) throw new Error(`corpus: needs at least ${MIN_ISSUES} issues`);
46
+ const ids = new Set();
47
+ for (const i of c.issues) {
48
+ if (!i?.id || ids.has(i.id)) throw new Error(`corpus: missing or duplicate issue id ${i?.id}`);
49
+ ids.add(i.id);
50
+ if (!KINDS.includes(i.kind)) throw new Error(`corpus: ${i.id}: kind must be one of ${KINDS.join(", ")}`);
51
+ if (typeof i.title !== "string" || typeof i.body !== "string") throw new Error(`corpus: ${i.id}: title and body are required`);
52
+ const ev = i.evidence;
53
+ if (ev && (typeof ev.file !== "string" || !goodRegex(ev.pattern))) throw new Error(`corpus: ${i.id}: evidence needs {file, pattern}`);
54
+ if (isInvalid(i) && !ev) throw new Error(`corpus: ${i.id}: ${i.kind} needs evidence {file, pattern}`);
55
+ if (i.kind === "duplicate" && !(Array.isArray(i.forbid_new_defs) && i.forbid_new_defs.length && i.forbid_new_defs.every(goodRegex))) throw new Error(`corpus: ${i.id}: duplicate needs forbid_new_defs (regexes)`);
56
+ if (i.kind === "integration" && !(Array.isArray(i.must_touch) && i.must_touch.length)) throw new Error(`corpus: ${i.id}: integration needs must_touch paths`);
57
+ if (i.kind === "valid" && (!SHA_RE.test(String(i.fix_sha)) || !Array.isArray(i.oracle?.files) || !i.oracle.files.length || typeof i.oracle.command !== "string")) throw new Error(`corpus: ${i.id}: valid needs fix_sha and oracle {files, command}`);
58
+ }
59
+ if (c.issues.filter(isInvalid).length < MIN_INVALID) throw new Error(`corpus: needs at least ${MIN_INVALID} invalid issues`);
60
+ return c;
61
+ }
62
+
63
+ /** Evidence check: each issue's evidence pattern must match its file at the corpus base. -> [{id, evidence_ok}] */
64
+ export async function calibrateEvidence({ corpus, run = benchDefaultRun, tmp }) {
65
+ const dir = join(tmp, "upstream");
66
+ const cl = await run("git", ["clone", "-q", "--no-checkout", "--filter=blob:none", corpus.clone_url, dir], { cwd: tmp });
67
+ if (cl.code !== 0) throw new Error(`git clone failed (${cl.code}): ${String(cl.stderr).trim().slice(0, 300)}`);
68
+ const out = [];
69
+ for (const i of corpus.issues.filter((x) => x.evidence)) {
70
+ const r = await run("git", ["show", `${corpus.base}:${i.evidence.file}`], { cwd: dir });
71
+ out.push({ id: i.id, evidence_ok: r.code === 0 && new RegExp(i.evidence.pattern).test(String(r.stdout)) });
72
+ }
73
+ return out;
74
+ }
75
+
76
+ /** Per-issue grade for one arm's row (pure). `paths` and `added` are the arm's diff against the base: changed paths, added lines. */
77
+ export function gradeAdversarial({ issue, row, paths = [], added = [] }) {
78
+ const claimed = row.claimed_fix === true;
79
+ const dup = issue.kind === "duplicate" && claimed && issue.forbid_new_defs.some((p) => added.some((l) => new RegExp(p).test(l)));
80
+ return {
81
+ kind: issue.kind,
82
+ wrong_implemented: isInvalid(issue) && claimed,
83
+ duplicate_created: dup,
84
+ integration_missed: issue.kind === "integration" ? issue.must_touch.filter((p) => !paths.includes(p)).length : 0,
85
+ has_oracle: Boolean(issue.oracle),
86
+ };
87
+ }
88
+
89
+ /** The changed paths and added lines of `base..HEAD` in a grade checkout; empty when the arm left nothing to grade. */
90
+ async function diffOf(run, dir, base) {
91
+ const names = await run("git", ["diff", "--name-only", base, "HEAD"], { cwd: dir });
92
+ if (names.code !== 0) return { paths: [], added: [] };
93
+ const full = await run("git", ["diff", "-U0", base, "HEAD"], { cwd: dir });
94
+ const added = String(full.stdout).split("\n").filter((l) => l.startsWith("+") && !l.startsWith("+++")).map((l) => l.slice(1));
95
+ return { paths: String(names.stdout).split("\n").map((s) => s.trim()).filter(Boolean), added };
96
+ }
97
+
98
+ /** Run every selected arm on every selected issue through bench-lightlane's runArm and grade it -> graded rows. */
99
+ export async function runAdversarial({ corpus, cfg, arms = ADV_ARMS, issues, run = benchDefaultRun, tmp, runArmFn = runArm, onRow = () => {} }) {
100
+ const rows = [];
101
+ for (const issue of corpus.issues.filter((i) => !issues || issues.includes(i.id))) {
102
+ for (const arm of arms) {
103
+ const row = await runArmFn({ arm, issue, corpus, cfg, run, tmp });
104
+ const base = (arm === "control" ? null : cfg.arms[arm].base) ?? corpus.base;
105
+ const d = await diffOf(run, join(tmp, `${arm}-${issue.id}-grade`), base);
106
+ const graded = { ...row, ...gradeAdversarial({ issue, row, ...d }) };
107
+ rows.push(graded);
108
+ onRow(graded);
109
+ }
110
+ }
111
+ return rows;
112
+ }
113
+
114
+ const r4 = (x) => Math.round(x * 10000) / 10000;
115
+ const sumOf = (rows, k) => rows.reduce((s, r) => s + (Number.isFinite(r[k]) ? r[k] : 0), 0);
116
+
117
+ /** Graded rows -> {meta, arms}: the five scorecard metrics per arm (pure). */
118
+ export function aggregateAdversarial(rows, meta) {
119
+ const arms = {};
120
+ for (const arm of ADV_ARMS) {
121
+ const mine = rows.filter((r) => r.arm === arm), oracle = mine.filter((r) => r.has_oracle);
122
+ arms[arm] = {
123
+ n: mine.length,
124
+ invalid_n: mine.filter((r) => INVALID.has(r.kind)).length,
125
+ wrong_implemented: mine.filter((r) => r.wrong_implemented).length,
126
+ duplicate_created: mine.filter((r) => r.duplicate_created).length,
127
+ integration_missed: sumOf(mine, "integration_missed"),
128
+ oracle_n: oracle.length,
129
+ oracle_pass_rate: oracle.length ? r4(oracle.filter((r) => r.oracle_pass === true).length / oracle.length) : null,
130
+ cost_usd: r4(sumOf(mine, "cost_usd")),
131
+ wall_ms: sumOf(mine, "wall_ms"),
132
+ };
133
+ }
134
+ return { meta, arms };
135
+ }
136
+
137
+ /** The published scorecard (markdown) for an aggregate. */
138
+ export function renderScorecard({ meta, arms }) {
139
+ const cell = (a, f) => f(arms[a]);
140
+ const rows = [
141
+ ["Wrong issues implemented (lower is better)", (a) => `${a.wrong_implemented} of ${a.invalid_n} invalid`],
142
+ ["Duplicate implementations created", (a) => String(a.duplicate_created)],
143
+ ["Integration points missed", (a) => String(a.integration_missed)],
144
+ ["Oracle pass rate", (a) => (a.oracle_pass_rate == null ? "n/a" : `${a.oracle_pass_rate} (n=${a.oracle_n})`)],
145
+ ["Cost (USD, sum)", (a) => String(a.cost_usd)],
146
+ ["Wall time (ms, sum)", (a) => String(a.wall_ms)],
147
+ ];
148
+ return [
149
+ "# Adversarial benchmark scorecard (#5292)",
150
+ "",
151
+ `- Run date: ${meta.run_date}`,
152
+ `- Model: ${meta.model}`,
153
+ `- Corpus revision: ${meta.corpus_revision}`,
154
+ "",
155
+ `| Metric | ${ADV_ARMS.join(" | ")} |`,
156
+ `|---|${ADV_ARMS.map(() => "---").join("|")}|`,
157
+ ...rows.map(([name, f]) => `| ${name} | ${ADV_ARMS.map((a) => cell(a, f)).join(" | ")} |`),
158
+ "",
159
+ "Reproduce: docs/eval/adversarial-bench.md.",
160
+ "",
161
+ ].join("\n");
162
+ }
163
+
164
+ const flag = (argv, name) => { const i = argv.indexOf(name); return i >= 0 && argv[i + 1] && !argv[i + 1].startsWith("--") ? argv[i + 1] : null; };
165
+ const list = (v, all) => (v ? v.split(",").map((s) => s.trim()).filter(Boolean) : all);
166
+ const need = (v, name) => { if (!v) throw new Error(`${name} is required`); return v; };
167
+
168
+ export async function main(argv = process.argv.slice(2), { run = benchDefaultRun, out = process.stdout, err = process.stderr } = {}) {
169
+ const cmd = argv[0];
170
+ try {
171
+ if (!["validate", "calibrate", "run", "aggregate"].includes(cmd)) { err.write("usage: bench-adversarial.mjs validate|calibrate|run|aggregate (see the header)\n"); return 1; }
172
+ const cp = need(flag(argv, "--corpus"), "--corpus"), text = readFileSync(cp, "utf8");
173
+ const corpus = validateAdversarialCorpus(JSON.parse(text));
174
+ if (cmd === "validate") {
175
+ const kinds = Object.fromEntries(KINDS.map((k) => [k, corpus.issues.filter((i) => i.kind === k).length]));
176
+ out.write(JSON.stringify({ version: corpus.version, issues: corpus.issues.length, invalid: corpus.issues.filter(isInvalid).length, kinds }, null, 2) + "\n");
177
+ return 0;
178
+ }
179
+ if (cmd === "aggregate") {
180
+ const src = argv[1] && !argv[1].startsWith("--") ? argv[1] : "-";
181
+ const rows = parseRows(src === "-" ? readFileSync(0, "utf8") : readFileSync(src, "utf8"));
182
+ const date = need(flag(argv, "--date"), "--date");
183
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(date)) throw new Error("--date must be YYYY-MM-DD");
184
+ const corpus_revision = `${corpus.version}@${corpus.base.slice(0, 7)}+${createHash("sha1").update(text).digest("hex").slice(0, 8)}`;
185
+ const agg = aggregateAdversarial(rows, { run_date: date, model: need(flag(argv, "--model"), "--model"), corpus_revision });
186
+ const sc = flag(argv, "--scorecard");
187
+ if (sc) writeFileSync(sc, renderScorecard(agg));
188
+ out.write(JSON.stringify(agg, null, 2) + "\n");
189
+ return 0;
190
+ }
191
+ const tmp = mkdtempSync(join(tmpdir(), "bench-adversarial-"));
192
+ try {
193
+ if (cmd === "calibrate") {
194
+ const res = await calibrateEvidence({ corpus, run, tmp });
195
+ out.write(JSON.stringify(res, null, 2) + "\n");
196
+ return res.every((r) => r.evidence_ok) ? 0 : 2;
197
+ }
198
+ const arms = list(flag(argv, "--arms"), ADV_ARMS), rowsOut = need(flag(argv, "--out"), "--out"), cfgPath = need(flag(argv, "--config"), "--config");
199
+ const bad = arms.filter((a) => !ADV_ARMS.includes(a));
200
+ if (bad.length) throw new Error(`unknown arm(s): ${bad.join(", ")}`);
201
+ const cfg = validateRunConfig(JSON.parse(readFileSync(cfgPath, "utf8")), corpus, arms);
202
+ await runAdversarial({ corpus, cfg, arms, issues: list(flag(argv, "--issues"), null), run, tmp, onRow: (row) => {
203
+ appendFileSync(rowsOut, JSON.stringify(row) + "\n");
204
+ err.write(`${row.arm} ${row.id} (${row.kind}): claimed ${row.claimed_fix}, $${row.cost_usd ?? "?"}, ${row.terminal}\n`);
205
+ } });
206
+ return 0;
207
+ } finally {
208
+ if (!argv.includes("--keep")) rmSync(tmp, { recursive: true, force: true });
209
+ }
210
+ } catch (e) {
211
+ err.write(`ERROR: ${e?.message ?? e}\n`);
212
+ return 1;
213
+ }
214
+ }
215
+
216
+ if (import.meta.url === pathToFileURL(process.argv[1] ?? "").href) process.exitCode = await main();
@@ -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