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
@@ -68,6 +68,7 @@ export const OUTCOME_CODES = Object.freeze({
68
68
  SANDBOX_UNREACHABLE: "sandbox.unreachable", // forge#4672: the sandbox provider stayed unreachable past execution.unreachable_window_min; deferred, the sandbox is kept for adopt
69
69
  LEASE_HELD: "lease.held",
70
70
  DEPENDENCY_OPEN: "dependency.open",
71
+ DESIGN_INVALIDATED: "design.invalidated", // forge#5342: a lane found the plan wrong; one spike amendment filed, siblings held; the rework-share rollup counts it
71
72
  DEPENDENCY_UNREADABLE: "dependency.unreadable",
72
73
  DEPENDENCY_BLOCKED: "dependency.blocked",
73
74
  // Lane resolution refusals (#4125): before any lease, comment or worktree; terminal reason `lane-refused`.
@@ -200,12 +201,14 @@ export function codeForTerminalReason(reason) {
200
201
 
201
202
  /** forge#4906: a validate command timed out (exit 124) on the engine's rerun: infrastructure, not an unimplemented contract item. Kept outside OUTCOME_CODES (the base enum guard lists that enum); recoverable and mechanical like the other env codes. */
202
203
  export const ENV_VALIDATE_TIMEOUT = "env.validate_timeout";
204
+ /** forge#5371: a remote-placed lane's frozen validate failed in the sandbox; the host reruns it in a local recovery lane (a pass there is the change, a fail stays conformance.unimplemented). Outside OUTCOME_CODES like ENV_VALIDATE_TIMEOUT. */
205
+ export const ENV_VALIDATE_PLACEMENT = "env.validate_placement";
203
206
 
204
207
  /**
205
208
  * Batch recovery classes of a lane result (forge#4267). The batch runner recovers `recoverable` rows once
206
209
  * (`orchestration.recovery.max_attempts`) and re-queues them; only `human` rows are escalations.
207
210
  */
208
- export const RECOVERABLE_CODES = Object.freeze([OUTCOME_CODES.CI_RED, OUTCOME_CODES.BASE_CONFLICT, OUTCOME_CODES.BUILDER_BLOCK_UNTYPED, OUTCOME_CODES.CONTRACT_INVALID, OUTCOME_CODES.CONTRACT_INVALID_COMMAND, OUTCOME_CODES.ENV_TOOL_MISSING, OUTCOME_CODES.ENV_REPRO_UNRUNNABLE, ENV_VALIDATE_TIMEOUT, OUTCOME_CODES.ENV_CAPABILITY_REMOTE, OUTCOME_CODES.BUDGET_EXCEEDED, OUTCOME_CODES.CONFORMANCE_UNIMPLEMENTED, OUTCOME_CODES.CONFORMANCE_OMISSION, OUTCOME_CODES.CONFORMANCE_UNJUSTIFIED_DEFERRAL]);
211
+ export const RECOVERABLE_CODES = Object.freeze([OUTCOME_CODES.CI_RED, OUTCOME_CODES.BASE_CONFLICT, OUTCOME_CODES.BUILDER_BLOCK_UNTYPED, OUTCOME_CODES.CONTRACT_INVALID, OUTCOME_CODES.CONTRACT_INVALID_COMMAND, OUTCOME_CODES.ENV_TOOL_MISSING, OUTCOME_CODES.ENV_REPRO_UNRUNNABLE, ENV_VALIDATE_TIMEOUT, ENV_VALIDATE_PLACEMENT, OUTCOME_CODES.ENV_CAPABILITY_REMOTE, OUTCOME_CODES.BUDGET_EXCEEDED, OUTCOME_CODES.CONFORMANCE_UNIMPLEMENTED, OUTCOME_CODES.CONFORMANCE_OMISSION, OUTCOME_CODES.CONFORMANCE_UNJUSTIFIED_DEFERRAL]);
209
212
  /** `builder.blocked` is only reached by a typed human block: credentials, spend, promotion, customer, product-decision. */
210
213
  export const HUMAN_CODES = Object.freeze([OUTCOME_CODES.BUILDER_BLOCKED]);
211
214
 
@@ -237,7 +240,7 @@ function classifyNeedsHumanBase(row) {
237
240
  }
238
241
 
239
242
  /** forge#4725: mechanical/environment codes recover on their own budget (`recovery.mechanicalMaxAttempts`), apart from conformance failures. */
240
- export const MECHANICAL_CODES = Object.freeze([OUTCOME_CODES.BASE_CONFLICT, OUTCOME_CODES.CONTRACT_INVALID_COMMAND, OUTCOME_CODES.ENV_TOOL_MISSING, OUTCOME_CODES.ENV_REPRO_UNRUNNABLE, ENV_VALIDATE_TIMEOUT, OUTCOME_CODES.ENV_CAPABILITY_REMOTE]);
243
+ export const MECHANICAL_CODES = Object.freeze([OUTCOME_CODES.BASE_CONFLICT, OUTCOME_CODES.CONTRACT_INVALID_COMMAND, OUTCOME_CODES.ENV_TOOL_MISSING, OUTCOME_CODES.ENV_REPRO_UNRUNNABLE, ENV_VALIDATE_TIMEOUT, ENV_VALIDATE_PLACEMENT, OUTCOME_CODES.ENV_CAPABILITY_REMOTE]);
241
244
 
242
245
  /** `mechanical` | `conformance`: the recovery budget class of a lane result row (a conflicting `ci-pending` is a base conflict). */
243
246
  export function recoveryClassOf(row) {
@@ -246,7 +249,7 @@ export function recoveryClassOf(row) {
246
249
 
247
250
  /** The code a recovery lane works on: a conflicting `ci-pending` is recovered as a base conflict. */
248
251
  export function recoveryCodeOf(row) {
249
- return (row?.outcome ?? row?.terminalReason) === "ci-pending" ? OUTCOME_CODES.BASE_CONFLICT : normalizeCode(row?.code);
252
+ return (row?.outcome ?? row?.terminalReason) === "ci-pending" ? OUTCOME_CODES.BASE_CONFLICT : row?.code === ENV_VALIDATE_PLACEMENT ? ENV_VALIDATE_PLACEMENT : normalizeCode(row?.code); // #5371: kept outside OUTCOME_CODES, so normalizeCode alone would drop it
250
253
  }
251
254
 
252
255
  /** forge#4656: the label of a human-owned wait (an owner and an unblock condition are required in its comment). */
@@ -39,6 +39,12 @@ const pairs = (v) => (Array.isArray(v) ? v.map((e) => `${e?.from}:${e?.to}`).joi
39
39
  const nonEmpty = (v) => (v === "" ? "none" : v);
40
40
  /** forge#5206: an experiment arm's applied overrides (`k=v,...`); "" (none applied) is "none" so compact() keeps it. */
41
41
  const armOv = (v) => (typeof v === "string" ? nonEmpty(v) : undefined);
42
+ /** #5345: lean's first-round review record flattened to scalars (`fr_*`); `stats --first-review` rebuilds it. Lists are comma-joined. */
43
+ function firstReviewFlat(f) {
44
+ if (!f || typeof f !== "object") return {};
45
+ const list = (v) => (Array.isArray(v) ? nonEmpty(v.join(",").slice(0, 200)) : undefined), bit = (v) => (typeof v === "boolean" ? Number(v) : undefined);
46
+ return { fr_state: nonEmpty(f.state), fr_kinds: list(f.kinds) ?? "none", fr_rounds: f.rounds, fr_clean: bit(f.clean), fr_incomplete: bit(f.incomplete), fr_type: nonEmpty(f.type), fr_surfaces: list(f.surfaces) ?? "none" };
47
+ }
42
48
  /** Lean's forge#4165 extras of a STRUCTURE_DELTA record; {} for the implement-time counts-only shape. */
43
49
  function structureLists(rec) {
44
50
  if (!Array.isArray(rec.decisions) && !Array.isArray(rec.new_edges) && !Array.isArray(rec.deps_added)) return {};
@@ -68,10 +74,10 @@ export function mapRecord(rec, wallMs) {
68
74
  }
69
75
  if (rec.event === "RUN_TERMINAL") {
70
76
  return { event: "run_terminal", phase: null, ...prOf(rec), payload: compact({ reason: rec.reason, code: rec.code, wall_ms: wallMs, guard_added_ms: rec.guard_added_ms, // #4705
71
- milestone: rec.milestone, conformance_mode: rec.conformance_mode, shadow_would: rec.shadow_would,
77
+ milestone: rec.milestone, verified: typeof rec.verified === "boolean" ? Number(rec.verified) : undefined, conformance_mode: rec.conformance_mode, shadow_would: rec.shadow_would,
72
78
  builder_tier: rec.builder_tier, builder_class: rec.builder_class, builder_model: rec.builder_model, // #4394: the model per merge
73
79
  builder_escalated: typeof rec.builder_escalated === "boolean" ? Number(rec.builder_escalated) : undefined,
74
- experiment: rec.experiment, arm: rec.arm, arm_overrides: armOv(rec.arm_overrides) }) }; // #4629, #5206
80
+ experiment: rec.experiment, arm: rec.arm, arm_overrides: armOv(rec.arm_overrides), ...firstReviewFlat(rec.first_review) }) }; // #4629, #5206, #5345
75
81
  }
76
82
  if (rec.event === "SANDBOX_USAGE") {
77
83
  return { event: "sandbox_usage", phase: null, payload: compact({ provider: rec.provider, sandbox_id: rec.sandbox_id, minutes: rec.minutes,
@@ -67,6 +67,11 @@ describe("engine telemetry seam", () => {
67
67
  assert.deepEqual(calls[0][1], { reason: "needs-human", code: "review.escalated", wall_ms: 60000 });
68
68
  assert.equal(calls[0][2].phase, undefined);
69
69
  });
70
+ it("#5339: RUN_TERMINAL carries verified as 0/1, omitted when absent", () => {
71
+ assert.equal(mapRecord({ event: "RUN_TERMINAL", reason: "merged", verified: false, issue: 7 }, 10).payload.verified, 0);
72
+ assert.equal(mapRecord({ event: "RUN_TERMINAL", reason: "merged", verified: true, issue: 7 }, 10).payload.verified, 1);
73
+ assert.equal("verified" in mapRecord({ event: "RUN_TERMINAL", reason: "merged", issue: 7 }, 10).payload, false);
74
+ });
70
75
  it("maps STRUCTURE_DELTA (forge#4159) to structure_delta with scalar counts and 0/1 flags", () => {
71
76
  const m = mapRecord({ event: "STRUCTURE_DELTA", issue: 7, edges_added: 1, edges_removed: 0, import_files_added: 8, import_files_removed: 2, boundary_changed: true, boundary_loosened: false }, 10);
72
77
  assert.deepEqual(m, { event: "structure_delta", phase: "implement", payload: { edges_added: 1, edges_removed: 0, import_files_added: 8, import_files_removed: 2, boundary_changed: 1, boundary_loosened: 0 } });
@@ -121,3 +126,15 @@ describe("engine telemetry seam", () => {
121
126
  assert.equal(some.calls[0][2].repo, "a/b");
122
127
  });
123
128
  });
129
+
130
+ describe("first_review on run_terminal (#5345)", () => {
131
+ it("is flattened to scalar fr_* fields and read back by stats --first-review", async () => {
132
+ const { firstReviewLanes } = await import("../stats/first-review.mjs");
133
+ const first_review = { state: "fail", kinds: ["conformance.omission", "conformance.scope_creep"], rounds: 2, clean: false, incomplete: false, type: "bug", surfaces: ["auth"] };
134
+ const { payload } = mapRecord({ event: "RUN_TERMINAL", reason: "merged", code: 0, first_review }, 0);
135
+ assert.equal("first_review" in payload, false);
136
+ assert.deepEqual([payload.fr_state, payload.fr_kinds, payload.fr_rounds, payload.fr_clean, payload.fr_surfaces], ["fail", "conformance.omission,conformance.scope_creep", 2, 0, "auth"]);
137
+ const [lane] = firstReviewLanes([{ event: "run_terminal", issue: 7, ts: "2026-01-01", repo: "o/r", reason: "merged", ...payload }]);
138
+ assert.deepEqual([lane.clean, lane.rounds, lane.kinds, lane.surfaces, lane.type], [false, 2, first_review.kinds, ["auth"], "bug"]);
139
+ });
140
+ });
@@ -4,6 +4,7 @@
4
4
  * `forgedock resume-stalled [--dry-run] [--lane <lane>]` enumerates all in-flight
5
5
  * issues, calls scanStalls, and re-dispatches each stalled issue via run-issue.
6
6
  */
7
+ import { validateForgeYaml, formatFinding } from "./config-schema.mjs";
7
8
  import { execFile, spawn } from "node:child_process";
8
9
  import { promisify } from "node:util";
9
10
  import { readdirSync, statSync, readFileSync } from "node:fs";
@@ -24,6 +25,7 @@ import { makeEventEmitter, probeSweepEvents, experimentEvent } from "./engine/ev
24
25
  import { readExperiment } from "./experiment.mjs";
25
26
  import { readBranches, resolveLane, isDefaultLane, makeLaneCache } from "./lean/lane.mjs";
26
27
  import { parseVerify } from "./lean/verify.mjs";
28
+ import { coerceVerify as coerceCiVerify, budgetReportLine, recordHostCheck } from "./lean/ci-budget.mjs";
27
29
  import { normalizeKindModes } from "./lean/conformance.mjs";
28
30
  import { parseEnforceDomains } from "./lean/review-trigger.mjs";
29
31
  import { viewIssue } from "./lean/gh-assoc.mjs";
@@ -31,10 +33,12 @@ import { otherLaneOwner, clearLease } from "./lean/lanelock.mjs";
31
33
  import { parseExecution, detectNeeds, placementText } from "./lean/execution.mjs";
32
34
  import { openRotator, rotatorKind } from "./lean/rotator.mjs";
33
35
  import { relayPrefetchCommands } from "./lean/relay.mjs";
36
+ import { parseCeilingBySize } from "./lean/ceiling.mjs";
34
37
  import { parseTurnBudgets, formatTurnSummary, TURN_BUDGET_DEFAULTS } from "./lean/budget.mjs";
35
38
  import { writeAtomic as writeResultAtomic } from "./lean/batch.mjs";
36
39
  import { parseLightConfig, LIGHT_DEFAULTS } from "./lean/light.mjs";
37
40
  import { OUTCOME_CODES } from "./engine/outcome-codes.mjs";
41
+ import { USER_ERRORS } from "./help-text.mjs";
38
42
  import * as batchHealth from "./lean/batch-health.mjs";
39
43
  import * as _autoChildren from "./lean/autochildren.mjs";
40
44
 
@@ -290,6 +294,18 @@ export function readBaseMerge(cwd = process.cwd()) {
290
294
  export function readSequenceRegenerate(cwd = process.cwd()) {
291
295
  try { const l = parseForgeYaml(readFileSync(join(cwd, "forge.yaml"), "utf8"))?.lean ?? {}; return String(l.sequence_regenerate ?? l.regenerate ?? "").trim() || undefined; } catch { return undefined; }
292
296
  }
297
+ /**
298
+ * forge.yaml `lean.sequence.versioned` (#5235): versioned-dir sequence classes, `<dir>/v{N} -> companion[, companion]; ...`
299
+ * (`path` or `path=template` companions). The one-level parser flattens the block to `lean.versioned`; flat
300
+ * `lean.sequence_versioned` also works and wins. undefined when absent or unreadable.
301
+ */
302
+ export function readSequenceVersioned(cwd = process.cwd()) {
303
+ try { const l = parseForgeYaml(readFileSync(join(cwd, "forge.yaml"), "utf8"))?.lean ?? {}; return String(l.sequence_versioned ?? l.versioned ?? "").trim() || undefined; } catch { return undefined; }
304
+ }
305
+ /** #5340: forge.yaml `engine.shared_surfaces` (comma scalar or block list of globs, `glob => command` = generated registry), or undefined. */
306
+ export function readSharedSurfaces(cwd = process.cwd()) {
307
+ try { const v = parseForgeYaml(readFileSync(join(cwd, "forge.yaml"), "utf8"))?.engine?.shared_surfaces; const out = Array.isArray(v) ? v.map(String) : typeof v === "string" && v.trim() ? [v.trim()] : []; return out.length ? out : undefined; } catch { return undefined; }
308
+ }
293
309
  /** #4664: forge.yaml `followups.default_milestone` (milestone title for deferred follow-ups whose parent's milestone has shipped), or undefined. */
294
310
  export function readFollowupsDefaultMilestone(cwd = process.cwd()) {
295
311
  try { return String(parseForgeYaml(readFileSync(join(cwd, "forge.yaml"), "utf8"))?.followups?.default_milestone ?? "").trim() || undefined; } catch { return undefined; }
@@ -389,6 +405,7 @@ export function readHeavy(cwd = process.cwd()) {
389
405
  * `lane_limits_memory_max`/`lane_limits_cpu_quota`), plus `tasks_max` (#4690, default 1024). `engine.cli_idle_minutes` (default 15) and `engine.cli_max_minutes` (default 180).
390
406
  * `engine.cli_busy_minutes` (default 45, #4405): extra silence allowed while the builder has a live heavy step or heavy-queue entry.
391
407
  * #4390: `engine.context_ceiling_tokens` (default 120000 in runCore; 0 = off).
408
+ * #5346: `engine.context_ceiling_by_size` ("S=..,M=..,L=.."; a size without an entry uses context_ceiling_tokens).
392
409
  * #4392: `engine.turn_budget_s|m|l` (implement turn budget per lane size; defaults 25/60/100, always returned; 0 = off).
393
410
  */
394
411
  export function readCoreLimits(cwd = process.cwd()) {
@@ -404,6 +421,7 @@ export function readCoreLimits(cwd = process.cwd()) {
404
421
  ...(posNum(y.engine?.cli_max_minutes) ? { cliMaxMinutes: posNum(y.engine.cli_max_minutes) } : {}),
405
422
  ...(posNum(y.engine?.cli_busy_minutes) ? { cliBusyMinutes: posNum(y.engine.cli_busy_minutes) } : {}),
406
423
  ...(/^\d+$/.test(String(y.engine?.context_ceiling_tokens ?? "").trim()) ? { contextCeilingTokens: Number(y.engine.context_ceiling_tokens) } : {}),
424
+ ...(parseCeilingBySize(y.engine) ? { contextCeilingBySize: parseCeilingBySize(y.engine) } : {}), // #5346
407
425
  turnBudgets: parseTurnBudgets(y.engine) ?? { ...TURN_BUDGET_DEFAULTS }, // #4392: lanes are budgeted by default
408
426
  };
409
427
  } catch { return { laneLimits: {}, turnBudgets: { ...TURN_BUDGET_DEFAULTS } }; }
@@ -425,7 +443,7 @@ export function readVerify(cwd = process.cwd()) {
425
443
  const sec = parseForgeYaml(readFileSync(join(cwd, "forge.yaml"), "utf8"))?.verify;
426
444
  if (!sec || typeof sec !== "object") return undefined;
427
445
  const invariants = readInvariants(cwd), flaky = readYamlList(cwd, "verify", "flaky"), guard_command = readYamlMap(cwd, "verify", "guard_command");
428
- return parseVerify({ ...sec, ...(invariants ? { invariants } : {}), ...(flaky ? { flaky } : {}), ...(guard_command ? { guard_command } : {}) });
446
+ return coerceCiVerify(parseVerify({ ...sec, ...(invariants ? { invariants } : {}), ...(flaky ? { flaky } : {}), ...(guard_command ? { guard_command } : {}) }), { cwd }); // #5278: local-first never pushes for paid CI before review
429
447
  } catch { return undefined; }
430
448
  }
431
449
  /** #4542: forge.yaml `execution.host_capabilities` (+ patterns) for a lane's remote-block mapping; undefined when none are declared. */
@@ -543,11 +561,12 @@ export function readEnvConfig(cwd = process.cwd()) {
543
561
  const rm = readYamlMap(cwd, "validate", "recipes"); // #5020: y?.validate?.recipes, a block map {match regex: replacement} applied to frozen validate and repro commands
544
562
  const recipes = Object.entries(rm ?? {}).map(([match, replace]) => ({ match, replace }));
545
563
  const cf = readYamlMap(cwd, "verification", "coupled_files"); // #5079: {when glob: required glob[, glob]}
564
+ const pp = readYamlMap(cwd, "topology", "prod_parity"); // #5284: {path glob: command | "note: how to verify"} production-only facts
546
565
  const s = (v) => (typeof v === "string" && v.trim() ? v.trim() : undefined);
547
566
  const rr = s(y?.topology?.route_reachability); // #5087: repo-supplied command: exits non-zero when the ingress does not deliver the added route paths (args) to their service
548
567
  const kb = typeof e.sparse_max_kb === "string" && /^\d+$/.test(e.sparse_max_kb.trim()) ? Number(e.sparse_max_kb) : e.sparse_max_kb;
549
568
  return { ...(s(e.toolchain) ? { toolchainOverride: s(e.toolchain) } : {}), ...(s(e.setup) ? { envSetup: s(e.setup) } : {}),
550
- ...(Number.isInteger(kb) && kb >= 0 ? { sparseMaxKb: kb } : {}), ...(Object.keys(runners).length ? { testRunners: runners } : {}), ...(recipes.length ? { validateRecipes: recipes } : {}), ...(cf && Object.keys(cf).length ? { coupledFiles: cf } : {}), ...(rr ? { routeReachability: rr } : {}) };
569
+ ...(Number.isInteger(kb) && kb >= 0 ? { sparseMaxKb: kb } : {}), ...(Object.keys(runners).length ? { testRunners: runners } : {}), ...(recipes.length ? { validateRecipes: recipes } : {}), ...(cf && Object.keys(cf).length ? { coupledFiles: cf } : {}), ...(rr ? { routeReachability: rr } : {}), ...(pp && Object.keys(pp).length ? { prodParity: pp } : {}) };
551
570
  } catch { return {}; }
552
571
  }
553
572
  export const ENGINE_PATHS = ["core", "full", "lean", "auto"];
@@ -915,12 +934,12 @@ export async function runFromCli(argv, deps = {}) {
915
934
  if (pathFlag && !ENGINE_PATHS.includes(pathFlag)) throw new Error(`--path must be one of ${ENGINE_PATHS.join("|")}`);
916
935
  const enginePath = pathFlag ?? readEnginePath() ?? "core";
917
936
  if (enginePath !== "full" && (retry || waitLease)) {
918
- throw new Error("--retry and --wait-lease are not supported with the core path (a rerun resumes from the open PR or remote branch automatically); use --path full for them");
937
+ throw new Error(USER_ERRORS.retryUnsupported);
919
938
  }
920
939
  // The full path takes the lane as given (its spec runs classify-lane), so it must be explicit; no default.
921
- if (enginePath === "full" && !lane) throw new Error("--lane is required with --path full: staging or milestone/<slug>. No default to prevent accidental production targeting.");
940
+ if (enginePath === "full" && !lane) throw new Error(USER_ERRORS.laneRequired);
922
941
  // #4298: recovery lanes (#4267) exist only on the core path; the legacy full path would silently ignore --recover.
923
- if (enginePath === "full" && argv.includes("--recover")) throw new Error("--recover is not supported with --path full (recovery lanes run on the core path only)");
942
+ if (enginePath === "full" && argv.includes("--recover")) throw new Error(USER_ERRORS.recoverUnsupported);
924
943
  const io = deps.io ?? makeIo();
925
944
  const resultFile = flag(argv, "--result-file");
926
945
  // #4256: where the dispatcher placed this lane (hybrid execution), recorded in the lane's FORGE:STATE.
@@ -975,7 +994,7 @@ export async function runFromCli(argv, deps = {}) {
975
994
  if (enginePath !== "full") {
976
995
  // Core work-on (lean): one builder session, one reviewer, GitHub as the register.
977
996
  const leanRepo = logRepo;
978
- if (!leanRepo) throw new Error("core path needs the repo: pass --repo or run inside a checkout with a GitHub remote");
997
+ if (!leanRepo) throw new Error(USER_ERRORS.noRepo);
979
998
  const { runCore } = deps.leanModule ?? (await import("./lean/lean.mjs"));
980
999
  const leanIo = deps.leanIo ?? (await import("./lean/effects.mjs")).makeLeanIo({ repo: leanRepo });
981
1000
  // #4121: a batch lane reports its result through --result-file (written atomically, also for a thrown run).
@@ -1001,7 +1020,7 @@ export async function runFromCli(argv, deps = {}) {
1001
1020
  ...(rotatorKind({ execution: readExecution(process.cwd()), env }) ? { accountRotator: rotatorKind({ execution: readExecution(process.cwd()), env }) } : {}), // #5094, #5205: detected
1002
1021
  onTeardown: (fn) => { teardown = fn; }, ...(env.FORGEDOCK_BATCH_ID ? { batchId: env.FORGEDOCK_BATCH_ID } : {}), ...(placement ? { placement } : {}), ...(recover ? { recover } : {}),
1003
1022
  emitTelemetry: deps.emitTelemetry ?? composeEmit(makeEmitTelemetry({ repo: leanRepo }), makeEventEmitter({ repo: leanRepo, config: readEvents() }).emit),
1004
- admission: readAdmission(), heavy: readHeavy(), ...readCoreLimits(), ...readEnvConfig(), ...(readMergeWait() ? { mergeWait: readMergeWait() } : {}), ...(readConformanceMode() ? { conformance: readConformanceMode() } : {}), ...(readConformanceKinds() ? { conformanceKinds: readConformanceKinds() } : {}), ...(readConformanceMutation() ? { conformanceMutation: "report" } : {}), ...(readContextPack() ? { contextPack: readContextPack() } : {}), ...(readReviewIncomplete() ? { reviewIncomplete: readReviewIncomplete() } : {}), ...(readLaneInstructions() ? { laneInstructions: readLaneInstructions() } : {}), ...(readReproTest() ? { reproTest: readReproTest() } : {}), ...(readExplore() ? { explore: readExplore() } : {}), ...(readExperiment() ? { experiment: readExperiment() } : {}), light: readLight(), ...(readCloseParent() ? { closeParent: true } : {}), ...(readReviewTrigger() ? { reviewTrigger: readReviewTrigger() } : {}), ...(readVerify() ? { verify: readVerify() } : {}), ...readPrecheckOptions(), ...(model ? { builderModel: model } : {}), ...(readLeanSetting("reviewer_model") ? { reviewerModel: readLeanSetting("reviewer_model") } : {}), ...(readFixModel() ? { fixModel: readFixModel() } : {}), ...(readBuilderRouting() ? { builderRouting: readBuilderRouting() } : {}), ...(readVerifier() ? { verifier: readVerifier() } : {}), ...(readHostCaps() ? { hostCaps: readHostCaps() } : {}), ...readRelayCaps(), ...(readSequenceRegenerate() ? { sequenceRegenerate: readSequenceRegenerate() } : {}), ...(readBaseMerge() ? { baseMerge: readBaseMerge() } : {}), ...(readFollowupsDefaultMilestone() ? { followupsDefaultMilestone: readFollowupsDefaultMilestone() } : {}), ...(readFollowupsRollupLabel() ? { followupsRollupLabel: readFollowupsRollupLabel() } : {}) });
1023
+ admission: readAdmission(), heavy: readHeavy(), ...readCoreLimits(), ...readEnvConfig(), ...(readMergeWait() ? { mergeWait: readMergeWait() } : {}), ...(readConformanceMode() ? { conformance: readConformanceMode() } : {}), ...(readConformanceKinds() ? { conformanceKinds: readConformanceKinds() } : {}), ...(readConformanceMutation() ? { conformanceMutation: "report" } : {}), ...(readContextPack() ? { contextPack: readContextPack() } : {}), ...(readSequenceVersioned() ? { sequenceVersioned: readSequenceVersioned() } : {}), ...(readSharedSurfaces() ? { sharedSurfaces: readSharedSurfaces() } : {}), ...(readReviewIncomplete() ? { reviewIncomplete: readReviewIncomplete() } : {}), ...(readLaneInstructions() ? { laneInstructions: readLaneInstructions() } : {}), ...(readReproTest() ? { reproTest: readReproTest() } : {}), ...(readExplore() ? { explore: readExplore() } : {}), ...(readExperiment() ? { experiment: readExperiment() } : {}), light: readLight(), ...(readCloseParent() ? { closeParent: true } : {}), ...(readReviewTrigger() ? { reviewTrigger: readReviewTrigger() } : {}), ...(readVerify() ? { verify: readVerify() } : {}), ...readPrecheckOptions(), ...(model ? { builderModel: model } : {}), ...(readLeanSetting("reviewer_model") ? { reviewerModel: readLeanSetting("reviewer_model") } : {}), ...(readFixModel() ? { fixModel: readFixModel() } : {}), ...(readBuilderRouting() ? { builderRouting: readBuilderRouting() } : {}), ...(readVerifier() ? { verifier: readVerifier() } : {}), ...(readHostCaps() ? { hostCaps: readHostCaps() } : {}), ...readRelayCaps(), ...(readSequenceRegenerate() ? { sequenceRegenerate: readSequenceRegenerate() } : {}), ...(readBaseMerge() ? { baseMerge: readBaseMerge() } : {}), ...(readFollowupsDefaultMilestone() ? { followupsDefaultMilestone: readFollowupsDefaultMilestone() } : {}), ...(readFollowupsRollupLabel() ? { followupsRollupLabel: readFollowupsRollupLabel() } : {}) });
1005
1024
  } catch (e) { if (!interrupted) report({ terminalReason: "engine-error", detail: String(e?.message ?? e).slice(0, 500) }); throw e; }
1006
1025
  finally { if (!interrupted) for (const [sig, f] of Object.entries(handlers)) off(sig, f); }
1007
1026
  if (interrupted) return lres; // the signal handler reported and exits
@@ -1310,7 +1329,12 @@ const hostedLine = (id, res) => res.reopened ? `batch ${id}: finished batch reop
1310
1329
  : res.hosted ? `batch ${id}: hosted by the schedd; the runner picks it up on its next pass (within ~5s while lanes run; if it is finishing, the schedd re-hosts the batch)`
1311
1330
  : `batch ${id}: queued but NOT hosted (no schedd hosts it); run: forgedock orchestrate --resume ${id}`;
1312
1331
 
1313
- async function addToBatch({ id, tokens, root, io, viaDaemon = null, print = (l) => console.log(l) }) {
1332
+ /** #5314: `--add`/`--requeue` never exit 0 with nothing scheduled: no runner hosts the batch and none was started → a non-zero exit with the reason. */
1333
+ const unhostedFailure = (id, res, requireHost, result) => {
1334
+ if (requireHost && !res.hosted && !res.reopened) throw Object.assign(new Error(`batch ${id}: the issues are queued in the batch but NOTHING is scheduled: no schedd hosts it. Start the runner: forgedock orchestrate --resume ${id}`), { code: "batch.not-hosted", result });
1335
+ };
1336
+
1337
+ async function addToBatch({ id, tokens, root, io, viaDaemon = null, requireHost = false, print = (l) => console.log(l) }) {
1314
1338
  const batchMod = await import("./lean/batch.mjs");
1315
1339
  const b = batchMod.openBatch(root, id);
1316
1340
  if (!b.exists()) throw new Error(`no batch ${id} in ${root}`);
@@ -1343,6 +1367,7 @@ async function addToBatch({ id, tokens, root, io, viaDaemon = null, print = (l)
1343
1367
  print(`batch ${id}: added ${out.added.map((n) => `#${n}`).join(" ") || (out.requeued.length ? "" : "(none)")}${out.requeued.length ? `${out.added.length ? " " : ""}${out.requeued.map((n) => `requeued #${n}`).join(" ")}` : ""}${out.skipped.length ? `; skipped ${out.skipped.map((x) => `${/^\d+$/.test(String(x.issue)) ? "#" : ""}${x.issue} (${x.reason})`).join(", ")}` : ""}`);
1344
1368
  if (out.added.length || out.requeued.length) print(hostedLine(id, res));
1345
1369
  if (out.edges.length) print(`batch ${id}: edges ${out.edges.map((e) => `#${e.from} blocked by #${e.to}`).join(", ")}`);
1370
+ if (out.added.length || out.requeued.length) unhostedFailure(id, res, requireHost, out);
1346
1371
  return out;
1347
1372
  }
1348
1373
 
@@ -1400,7 +1425,7 @@ async function holdBatch({ op, id, tokens, root, viaDaemon = null, takeover = nu
1400
1425
  * written. Through the daemon (`viaDaemon`, null when none runs: the batch's `requeue` file, and a finished batch's report is
1401
1426
  * cleared so `--resume` runs it again). The runner applies the entries and posts the FORGE:DECISION.
1402
1427
  */
1403
- async function requeueBatch({ id, tokens, reason, root, io, viaDaemon = null, print = (l) => console.log(l) }) {
1428
+ async function requeueBatch({ id, tokens, reason, root, io, viaDaemon = null, requireHost = false, print = (l) => console.log(l) }) {
1404
1429
  if (!id || String(id).startsWith("--") || !tokens.length) throw new Error(ORCH_USAGE);
1405
1430
  const batchMod = await import("./lean/batch.mjs");
1406
1431
  const b = batchMod.openBatch(root, id);
@@ -1432,7 +1457,7 @@ async function requeueBatch({ id, tokens, reason, root, io, viaDaemon = null, pr
1432
1457
  const out = { ok: true, batch: id, requeued: res.requeued ?? [], refused: [...(res.refused ?? []), ...refused] };
1433
1458
  if (res.hosted !== undefined) { out.hosted = !!res.hosted; out.reopened = !!res.reopened; }
1434
1459
  print(`batch ${id}: ${out.requeued.map((n) => `requeued #${n}`).join(" ") || "requeued (none)"}${out.refused.length ? `; refused ${out.refused.map((x) => `${/^\d+$/.test(String(x.issue)) ? "#" : ""}${x.issue} (${x.reason})`).join(", ")}` : ""}`);
1435
- if (out.requeued.length) print(hostedLine(id, res));
1460
+ if (out.requeued.length) { print(hostedLine(id, res)); unhostedFailure(id, res, requireHost, out); }
1436
1461
  return out;
1437
1462
  }
1438
1463
 
@@ -1519,7 +1544,7 @@ async function orchestrateClient(argv, deps = {}) {
1519
1544
  }
1520
1545
  if (argv.includes("--requeue")) {
1521
1546
  const i = argv.indexOf("--requeue"), id = argv[i + 1];
1522
- return requeueBatch({ id, tokens: operandsOf(argv.slice(i + 2)), reason: flag(argv, "--reason"), root: await batchRootOf(), io: deps.io ?? makeIo(), viaDaemon: requeueVia(id) });
1547
+ return requeueBatch({ id, tokens: operandsOf(argv.slice(i + 2)), reason: flag(argv, "--reason"), root: await batchRootOf(), io: deps.io ?? makeIo(), viaDaemon: requeueVia(id), requireHost: true });
1523
1548
  }
1524
1549
  for (const op of ["hold", "release"]) if (argv.includes(`--${op}`)) {
1525
1550
  const id = flag(argv, `--${op}`);
@@ -1530,7 +1555,7 @@ async function orchestrateClient(argv, deps = {}) {
1530
1555
  if (argv.includes("--add")) {
1531
1556
  const i = argv.indexOf("--add"), id = argv[i + 1];
1532
1557
  if (!id || i + 2 >= argv.length) throw new Error(ORCH_USAGE);
1533
- return addToBatch({ id, tokens: operandsOf(argv.slice(i + 2)), root: await batchRootOf(), io: deps.io ?? makeIo(), viaDaemon: addVia(id) });
1558
+ return addToBatch({ id, tokens: operandsOf(argv.slice(i + 2)), root: await batchRootOf(), io: deps.io ?? makeIo(), viaDaemon: addVia(id), requireHost: true });
1534
1559
  }
1535
1560
  const resumeId = flag(argv, "--resume");
1536
1561
  const resumeExtra = resumeId ? operandsOf(argv.slice(argv.indexOf("--resume") + 2)) : [];
@@ -1546,7 +1571,7 @@ async function orchestrateClient(argv, deps = {}) {
1546
1571
  let sub = [...argv];
1547
1572
  if (!flag(sub, "--repo")) {
1548
1573
  const repo = await resolveDefaultRepo(deps.io ?? makeIo());
1549
- if (!repo) throw new Error("orchestrate needs the repo: pass --repo or run inside a checkout with a GitHub remote");
1574
+ if (!repo) throw new Error(USER_ERRORS.noRepoOrchestrate);
1550
1575
  sub = [...sub, "--repo", repo];
1551
1576
  }
1552
1577
  const pinned = schedd.batchEnv(process.env, readPinnedEnvConfig(process.cwd()));
@@ -1625,7 +1650,7 @@ export async function runBatch({ argv, cwd: callerCwd = process.cwd(), env: call
1625
1650
  if (argv.includes("--cancel")) return cancelBatch({ id: flag(argv, "--cancel"), root, stopRemote: argv.includes("--stop-remote"), print: (l) => sink.line(l) });
1626
1651
  if (argv.includes("--requeue")) {
1627
1652
  const i = argv.indexOf("--requeue");
1628
- return requeueBatch({ id: argv[i + 1], tokens: operandsOf(argv.slice(i + 2)), reason: flag(argv, "--reason"), root, io: deps.io ?? makeIo(), print: (l) => sink.line(l) });
1653
+ return requeueBatch({ id: argv[i + 1], tokens: operandsOf(argv.slice(i + 2)), reason: flag(argv, "--reason"), root, io: deps.io ?? makeIo(), requireHost: true, print: (l) => sink.line(l) });
1629
1654
  }
1630
1655
  for (const op of ["hold", "release"]) if (argv.includes(`--${op}`)) {
1631
1656
  const hid = flag(argv, `--${op}`);
@@ -1635,7 +1660,7 @@ export async function runBatch({ argv, cwd: callerCwd = process.cwd(), env: call
1635
1660
  if (argv.includes("--add")) {
1636
1661
  const i = argv.indexOf("--add");
1637
1662
  if (!argv[i + 1] || i + 2 >= argv.length) throw new Error(ORCH_USAGE);
1638
- return addToBatch({ id: argv[i + 1], tokens: operandsOf(argv.slice(i + 2)), root, io: deps.io ?? makeIo(), print: (l) => sink.line(l) });
1663
+ return addToBatch({ id: argv[i + 1], tokens: operandsOf(argv.slice(i + 2)), root, io: deps.io ?? makeIo(), requireHost: true, print: (l) => sink.line(l) });
1639
1664
  }
1640
1665
  const resumeId = flag(argv, "--resume");
1641
1666
  const resumeExtra = resumeId ? operandsOf(argv.slice(argv.indexOf("--resume") + 2)) : [];
@@ -1668,7 +1693,7 @@ export async function runBatch({ argv, cwd: callerCwd = process.cwd(), env: call
1668
1693
  const model = flag(argv, "--model");
1669
1694
  const io = deps.io ?? makeIo();
1670
1695
  const repo = flag(argv, "--repo") ?? plan?.repo ?? (await resolveDefaultRepo(io));
1671
- if (!repo) throw new Error("orchestrate needs the repo: pass --repo or run inside a checkout with a GitHub remote");
1696
+ if (!repo) throw new Error(USER_ERRORS.noRepoOrchestrate);
1672
1697
  const cwd = plan?.cwd ?? callerCwd;
1673
1698
  await assertLaneNotDefault(io, lane, repo, cwd);
1674
1699
  if (!deps.allowTmpfs && process.env.FORGEDOCK_BATCH_ALLOW_TMPFS !== "1") batchMod.assertDiskPath(root);
@@ -1776,7 +1801,7 @@ export async function runBatch({ argv, cwd: callerCwd = process.cwd(), env: call
1776
1801
  const emitTelemetry = deps.emitTelemetry ?? makeEmitTelemetry({ repo });
1777
1802
  lanes = { adopt: null, runOne: (n, ln, ctx = {}) => runCore({ issue: n, repo, lane: ln, laneOverride, ...(ctx.placement ? { placement: { ...ctx.placement, mode: execMode() } } : {}), ...(ctx.recover ? { recover: ctx.recover } : {}), branches, cwd, dir, io: leanIo, agentId: `orch_${process.pid}_${n}`, emitTelemetry, batchId: batch.id,
1778
1803
  ...(rotatorKind({ execution: readExecution(cwd), env }) ? { accountRotator: rotatorKind({ execution: readExecution(cwd), env }) } : {}), // #5094, #5205: detected
1779
- admission: readAdmission(cwd), heavy: readHeavy(cwd), ...readCoreLimits(cwd), ...readEnvConfig(cwd), ...(readMergeWait(cwd) ? { mergeWait: readMergeWait(cwd) } : {}), ...(readConformanceMode(cwd) ? { conformance: readConformanceMode(cwd) } : {}), ...(readConformanceKinds(cwd) ? { conformanceKinds: readConformanceKinds(cwd) } : {}), ...(readConformanceMutation(cwd) ? { conformanceMutation: "report" } : {}), ...(readContextPack(cwd) ? { contextPack: readContextPack(cwd) } : {}), ...(readReviewIncomplete(cwd) ? { reviewIncomplete: readReviewIncomplete(cwd) } : {}), ...(readLaneInstructions(cwd) ? { laneInstructions: readLaneInstructions(cwd) } : {}), ...(readReproTest(cwd) ? { reproTest: readReproTest(cwd) } : {}), ...(readExplore(cwd) ? { explore: readExplore(cwd) } : {}), ...(readExperiment(cwd) ? { experiment: readExperiment(cwd) } : {}), light: readLight(cwd), ...(readCloseParent(cwd) ? { closeParent: true } : {}), ...(readReviewTrigger(cwd) ? { reviewTrigger: readReviewTrigger(cwd) } : {}), ...(readVerify(cwd) ? { verify: readVerify(cwd) } : {}), ...readPrecheckOptions(cwd), ...(model ? { builderModel: model } : {}), ...(readLeanSetting("reviewer_model", cwd) ? { reviewerModel: readLeanSetting("reviewer_model", cwd) } : {}), ...(readFixModel(cwd) ? { fixModel: readFixModel(cwd) } : {}), ...(readBuilderRouting(cwd) ? { builderRouting: readBuilderRouting(cwd) } : {}), ...(readVerifier(cwd) ? { verifier: readVerifier(cwd) } : {}), ...(readHostCaps(cwd) ? { hostCaps: readHostCaps(cwd) } : {}), ...readRelayCaps(), ...(readSequenceRegenerate(cwd) ? { sequenceRegenerate: readSequenceRegenerate(cwd) } : {}), ...(readBaseMerge(cwd) ? { baseMerge: readBaseMerge(cwd) } : {}), ...(readFollowupsDefaultMilestone(cwd) ? { followupsDefaultMilestone: readFollowupsDefaultMilestone(cwd) } : {}), ...(readFollowupsRollupLabel(cwd) ? { followupsRollupLabel: readFollowupsRollupLabel(cwd) } : {}) }) };
1804
+ admission: readAdmission(cwd), heavy: readHeavy(cwd), ...readCoreLimits(cwd), ...readEnvConfig(cwd), ...(readMergeWait(cwd) ? { mergeWait: readMergeWait(cwd) } : {}), ...(readConformanceMode(cwd) ? { conformance: readConformanceMode(cwd) } : {}), ...(readConformanceKinds(cwd) ? { conformanceKinds: readConformanceKinds(cwd) } : {}), ...(readConformanceMutation(cwd) ? { conformanceMutation: "report" } : {}), ...(readContextPack(cwd) ? { contextPack: readContextPack(cwd) } : {}), ...(readSequenceVersioned(cwd) ? { sequenceVersioned: readSequenceVersioned(cwd) } : {}), ...(readSharedSurfaces(cwd) ? { sharedSurfaces: readSharedSurfaces(cwd) } : {}), ...(readReviewIncomplete(cwd) ? { reviewIncomplete: readReviewIncomplete(cwd) } : {}), ...(readLaneInstructions(cwd) ? { laneInstructions: readLaneInstructions(cwd) } : {}), ...(readReproTest(cwd) ? { reproTest: readReproTest(cwd) } : {}), ...(readExplore(cwd) ? { explore: readExplore(cwd) } : {}), ...(readExperiment(cwd) ? { experiment: readExperiment(cwd) } : {}), light: readLight(cwd), ...(readCloseParent(cwd) ? { closeParent: true } : {}), ...(readReviewTrigger(cwd) ? { reviewTrigger: readReviewTrigger(cwd) } : {}), ...(readVerify(cwd) ? { verify: readVerify(cwd) } : {}), ...readPrecheckOptions(cwd), ...(model ? { builderModel: model } : {}), ...(readLeanSetting("reviewer_model", cwd) ? { reviewerModel: readLeanSetting("reviewer_model", cwd) } : {}), ...(readFixModel(cwd) ? { fixModel: readFixModel(cwd) } : {}), ...(readBuilderRouting(cwd) ? { builderRouting: readBuilderRouting(cwd) } : {}), ...(readVerifier(cwd) ? { verifier: readVerifier(cwd) } : {}), ...(readHostCaps(cwd) ? { hostCaps: readHostCaps(cwd) } : {}), ...readRelayCaps(), ...(readSequenceRegenerate(cwd) ? { sequenceRegenerate: readSequenceRegenerate(cwd) } : {}), ...(readBaseMerge(cwd) ? { baseMerge: readBaseMerge(cwd) } : {}), ...(readFollowupsDefaultMilestone(cwd) ? { followupsDefaultMilestone: readFollowupsDefaultMilestone(cwd) } : {}), ...(readFollowupsRollupLabel(cwd) ? { followupsRollupLabel: readFollowupsRollupLabel(cwd) } : {}) }) };
1780
1805
  } else {
1781
1806
  const laneScript = deps.laneScript ?? fileURLToPath(new URL("./forgedock.mjs", import.meta.url));
1782
1807
  // #4690: lanes learn K (the default MemoryMax is derived from it); one line says so when no scope caps them.
@@ -1884,6 +1909,8 @@ export async function runBatch({ argv, cwd: callerCwd = process.cwd(), env: call
1884
1909
  // #4304: recovery lanes run on the core path only (run-issue throws on --recover with full), so a full-path repo gets none.
1885
1910
  const recoveryOn = Boolean(orch.recovery?.maxAttempts) && (deps.enginePath !== undefined ? deps.enginePath : readEnginePath(cwd)) !== "full";
1886
1911
  if (orch.recovery?.maxAttempts && !recoveryOn) sink.line("recovery: off (engine.path is full; recovery lanes run on the core path only)");
1912
+ // #5315: a forge.yaml key that is unknown, ignored by this engine path, mistyped or a deprecated alias is named at batch start, never silent.
1913
+ try { for (const f of validateForgeYaml(readFileSync(join(cwd, "forge.yaml"), "utf8"), { path: deps.enginePath !== undefined ? deps.enginePath : readEnginePath(cwd) })) sink.line(`config: ${formatFinding(f)}`); } catch { /* no forge.yaml: nothing to validate */ }
1887
1914
  // #4190: usage-limit holds live in the host store keyed by the account the next lane would use.
1888
1915
  const limitsMod = await import("./lean/limits.mjs");
1889
1916
  const limits = deps.limits ?? limitsMod.openLimits(limitsMod.limitsFile(env));
@@ -1934,7 +1961,9 @@ export async function runBatch({ argv, cwd: callerCwd = process.cwd(), env: call
1934
1961
  let integration = deps.integration;
1935
1962
  if (integration === undefined) {
1936
1963
  const { makeIntegration } = await import("./lean/integration.mjs");
1937
- integration = makeIntegration({ repo, io: leanIo, cfg: await readIntegration(cwd), pattern: branches.featurePattern ?? undefined,
1964
+ // forge#5336: the epic journeys run after each child merge (real runs only: injected test seams keep their own io).
1965
+ const journeys = deps.leanIo || deps.leanModule || deps.laneScript ? null : (await import("./lean/acceptance.mjs")).makeJourneyRunner({ repo, io: leanIo, cwd });
1966
+ integration = makeIntegration({ repo, io: leanIo, cfg: await readIntegration(cwd), pattern: branches.featurePattern ?? undefined, journeys, skeleton: !!journeys, // #5337: the skeleton hold rides the same real-run guard
1938
1967
  sleep: (ms) => new Promise((r) => setTimeout(r, ms)), onEvent: (e) => console.log(`#${e.issue} → ${e.detail}`) });
1939
1968
  try { await integration?.prime(); } catch { /* streaks unknown: nothing is held */ }
1940
1969
  }
@@ -2095,6 +2124,7 @@ export async function runBatch({ argv, cwd: callerCwd = process.cwd(), env: call
2095
2124
  const { batchEfficiency, formatEfficiencyLines } = await import("./stats/efficiency.mjs");
2096
2125
  report.push(...formatEfficiencyLines(await (deps.efficiency ?? batchEfficiency)({ batchDir: batch.dir, runsDir: dir, repo, gh: (a) => leanIo.gh(a), rows })));
2097
2126
  } catch (e) { report.push(`efficiency: n/a (${String(e?.message ?? e).split("\n")[0].slice(0, 160)})`); }
2127
+ report.push(await budgetReportLine({ cwd, repo, gh: (a) => leanIo.gh(a) })); // #5278: month usage, projection and any auto switch to local-first
2098
2128
  const shadowLine = formatShadowSummary(rows); // #4398
2099
2129
  if (shadowLine) report.push(shadowLine);
2100
2130
  const decompLine = formatDecompositionSummary(rows); // #4396
@@ -2436,7 +2466,9 @@ export async function checkFromCli(argv, deps = {}) {
2436
2466
  const picked = pre.planPrecheck({ testMap, files, learned, maxMinutes, verify });
2437
2467
  const par = String(env.FORGE_HOST_PARALLELISM ?? "").trim(), pinned = /^\d+$/.test(par) && Number(par) > 0;
2438
2468
  const runCommand = deps.runCommand ?? (await import("./lean/effects.mjs")).runCheckCommand;
2439
- const r = await pre.selfCheck({ contract, plan: { mode: verify.mode, commands: picked.commands, budgetMs: picked.budgetMs, perCommandMs: picked.perCommandMs },
2469
+ const { selfReviewFindings } = await import("./lean/selfreview.mjs"); // #5345: the reviewer's deterministic checks, before any reviewer
2470
+ const review = selfReviewFindings({ contract, result: await readJson(".forge-lean/result.json"), changedFiles: files });
2471
+ const r = await pre.selfCheck({ review, contract, plan: { mode: verify.mode, commands: picked.commands, budgetMs: picked.budgetMs, perCommandMs: picked.perCommandMs },
2440
2472
  parallelism: pinned ? Number(par) : 1, now: deps.now,
2441
2473
  run: ({ command, timeoutMs, workers }) => runCommand({ command, cwd: repo, timeoutMs, env: pinned ? { FORGE_HOST_PARALLELISM: String(workers) } : null }) });
2442
2474
  // #4390: each failure's full output goes to .forge-lean/logs/ (git-excluded); the table shows its tail, ids and the path
@@ -2454,8 +2486,12 @@ export async function checkFromCli(argv, deps = {}) {
2454
2486
  let fingerprint = null;
2455
2487
  try { fingerprint = await pre.worktreeFingerprint({ git, base }); } catch { /* recorded without one: the engine reads it as skipped */ }
2456
2488
  const strip = (x) => (x.status ? { ...(x.id ? { id: x.id } : {}), command: x.command, status: x.status } : { ...(x.id ? { id: x.id } : {}), command: x.command, rc: x.rc, ms: x.ms });
2457
- const record = { v: 1, at: new Date((deps.now ?? Date.now)()).toISOString(), base, fingerprint, ok: r.ok, validate: r.validate.map(strip), commands: [...r.commands.map(strip), ...r.deferred.map((command) => ({ command, status: "deferred-to-ci" }))] };
2489
+ const record = { v: 1, at: new Date((deps.now ?? Date.now)()).toISOString(), base, fingerprint, ok: r.ok, ...(r.review?.length ? { review: r.review.map((f) => ({ code: f.code, detail: f.detail })) } : {}), validate: r.validate.map(strip), commands: [...r.commands.map(strip), ...r.deferred.map((command) => ({ command, status: "deferred-to-ci" }))] };
2458
2490
  try { await (deps.writeFile ?? ((p, t) => fsp.writeFile(p, t)))(join(repo, pre.SELF_CHECK_FILE), `${JSON.stringify(record)}\n`); } catch { /* .forge-lean missing: still print */ }
2491
+ try { // #5278: parity row for the local green -> remote red hit rate; the attested status in ci.mode local-attested
2492
+ const suites = [...record.validate, ...record.commands].filter((x) => !x.status).map((x) => ({ name: x.id ?? x.command, ok: x.rc === 0 }));
2493
+ await recordHostCheck({ cwd: repo, head: String(await git(["rev-parse", "HEAD"])).trim(), ok: r.ok, suites });
2494
+ } catch { /* best effort */ }
2459
2495
  out(o.json ? JSON.stringify({ ...r, base, fingerprint }, null, 2) : pre.formatCheckTable(r));
2460
2496
  return { ...r, base, fingerprint, files, exitCode: r.ok ? 0 : 1 };
2461
2497
  }
@@ -2484,6 +2520,7 @@ export async function schedFromCli(argv, deps = {}) {
2484
2520
  for (const e of st.slots) console.log(` running ${who(e)} dispatcher ${e.pid}${e.lanePid ? ` lane ${e.lanePid}` : ""}`);
2485
2521
  for (const e of st.queue) console.log(` queued ${who(e)} dispatcher ${e.pid}`);
2486
2522
  for (const l of schedMod.remoteLines(st)) console.log(l); // #4964
2523
+ try { for (const l of (await import("./lean/batch-health.mjs")).summaryLines((await import("./lean/batch.mjs")).batchRoot())) console.log(l); } catch { /* advisory */ } // #5314
2487
2524
  return st;
2488
2525
  }
2489
2526
  if (sub === "cap") {
@@ -0,0 +1,122 @@
1
+ // SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
2
+ // SPDX-License-Identifier: AGPL-3.0-or-later
3
+ /**
4
+ * forgedock first-run (#5290): on the user's own repo, propose up to 3 small, verifiable issues found by
5
+ * deterministic scans (no model), file them on approval and run one to a PR. Each filed issue carries a
6
+ * FORGE:FIRST_RUN marker with the setup start time, so `forgedock stats --first-merge` can measure setup start to
7
+ * first merge from GitHub alone. Every failure ends with a plain-language next step (nextStep).
8
+ */
9
+ import { existsSync, readdirSync, readFileSync } from "node:fs";
10
+ import { dirname, join, relative, resolve } from "node:path";
11
+
12
+ export const MAX_PROPOSALS = 3;
13
+ export const FIRST_RUN_MARKER = "FORGE:FIRST_RUN";
14
+ const MARKER_RE = /<!--\s*FORGE:FIRST_RUN\s+(\{.*?\})\s*-->/;
15
+
16
+ /** The FORGE:FIRST_RUN marker for an issue body: {started: iso} or null. */
17
+ export function parseFirstRunMarker(body) {
18
+ const m = MARKER_RE.exec(String(body ?? ""));
19
+ if (!m) return null;
20
+ try {
21
+ const j = JSON.parse(m[1]);
22
+ return Number.isFinite(Date.parse(j?.started)) ? j : null;
23
+ } catch { return null; }
24
+ }
25
+ export const markerLine = (startedMs) => `<!-- ${FIRST_RUN_MARKER} ${JSON.stringify({ started: new Date(startedMs).toISOString() })} -->`;
26
+
27
+ const readJson = (p) => { try { return JSON.parse(readFileSync(p, "utf8")); } catch { return null; } };
28
+ const mdFiles = (cwd) => {
29
+ const out = ["README.md"].filter((f) => existsSync(join(cwd, f)));
30
+ try { for (const f of readdirSync(join(cwd, "docs"))) if (f.endsWith(".md")) out.push(`docs/${f}`); } catch { /* no docs dir */ }
31
+ return out;
32
+ };
33
+
34
+ /** Relative markdown links whose target is missing: [{file, target}]. */
35
+ export function findDeadLinks(cwd) {
36
+ const dead = [];
37
+ for (const file of mdFiles(cwd)) {
38
+ const text = readFileSync(join(cwd, file), "utf8").replace(/```[\s\S]*?```/g, "");
39
+ for (const m of text.matchAll(/\[[^\]]*\]\(([^)\s]+)\)/g)) {
40
+ const target = m[1].split("#")[0];
41
+ if (!target || /^[a-z][a-z0-9+.-]*:/i.test(target) || target.startsWith("/")) continue;
42
+ const abs = resolve(cwd, dirname(file), target);
43
+ if (relative(cwd, abs).startsWith("..")) continue;
44
+ if (!existsSync(abs)) dead.push({ file, target });
45
+ }
46
+ }
47
+ return dead;
48
+ }
49
+
50
+ /** Up to 3 small, verifiable candidates: [{kind, title, body}], most useful first. */
51
+ export function proposeIssues(cwd) {
52
+ const pkg = readJson(join(cwd, "package.json"));
53
+ const out = [];
54
+ const dead = findDeadLinks(cwd);
55
+ if (dead.length) {
56
+ const list = dead.slice(0, 10).map((d) => `- \`${d.file}\` links to \`${d.target}\`, which does not exist`).join("\n");
57
+ out.push({ kind: "dead-link", title: "docs: fix broken relative links", body: `Dead relative links found:\n\n${list}\n\nVerify: every relative link in the listed files resolves to an existing file.` });
58
+ }
59
+ if (!existsSync(join(cwd, "CONTRIBUTING.md"))) {
60
+ out.push({ kind: "doc-gap", title: "docs: add CONTRIBUTING.md", body: "The repo has no CONTRIBUTING.md. Add a short one: how to set up, run the tests and open a PR.\n\nVerify: CONTRIBUTING.md exists and is linked from the README." });
61
+ }
62
+ if (pkg?.scripts?.lint) {
63
+ out.push({ kind: "lint-debt", title: "chore: make `npm run lint` pass cleanly", body: "Run `npm run lint` and fix the reported findings without changing behaviour.\n\nVerify: `npm run lint` exits 0." });
64
+ }
65
+ if (pkg && !pkg.scripts?.test) {
66
+ out.push({ kind: "failing-test", title: "test: add a `test` script and one passing test", body: "package.json has no `test` script. Add one with a single smoke test for an existing module.\n\nVerify: `npm test` exits 0." });
67
+ }
68
+ return out.slice(0, MAX_PROPOSALS);
69
+ }
70
+
71
+ /** Plain-language next step for a failure message or error. Always returns a non-empty string. */
72
+ export function nextStep(err) {
73
+ const m = String(err?.stderr || err?.message || err || "");
74
+ if (/gh auth|not logged in|authentication|GH_TOKEN|HTTP 401|bad credentials/i.test(m)) return "GitHub CLI is not signed in. Run `gh auth login`, then re-run `npx forgedock first-run`.";
75
+ if (/gh: command not found|ENOENT.*gh|spawn gh/i.test(m)) return "The GitHub CLI (gh) is not installed. Install it from https://cli.github.com, run `gh auth login`, then re-run `npx forgedock first-run`.";
76
+ if (/protected branch|GH006|required status check|branch protection/i.test(m)) return "The base branch is protected, so ForgeDock cannot merge directly. That is fine: it opens a PR for you to review and merge. Check the PR with `gh pr list`.";
77
+ if (/no ci|no workflows|no checks/i.test(m)) return "This repo has no CI workflow, so nothing verifies the PR. Add a workflow under .github/workflows (or review the PR yourself) before merging.";
78
+ if (/remote|not a git repository|no github|could not resolve/i.test(m)) return "No GitHub remote found. Run this inside a clone of a GitHub repo, or add one with `git remote add origin <url>`.";
79
+ return "Something went wrong. Re-run `npx forgedock first-run`, or run `npx forgedock doctor` to check your setup.";
80
+ }
81
+
82
+ const issueNumber = (out) => { const m = /\/issues\/(\d+)/.exec(String(out ?? "")); return m ? Number(m[1]) : null; };
83
+
84
+ /** File each proposal with the start marker; returns [{number, title}]. exec(cmd, args) -> stdout. */
85
+ export function fileIssues({ exec, repo, proposals, startedMs }) {
86
+ const filed = [];
87
+ for (const p of proposals) {
88
+ const body = `${p.body}\n\n${markerLine(startedMs)}`;
89
+ const number = issueNumber(exec("gh", ["issue", "create", "-R", repo, "--title", p.title, "--body", body]));
90
+ if (!number) throw new Error(`could not read the issue number for "${p.title}" from gh output`);
91
+ filed.push({ number, title: p.title });
92
+ }
93
+ return filed;
94
+ }
95
+
96
+ /**
97
+ * Guided first run. Never throws: returns {status: "done"|"declined"|"nothing"|"error", issues, step?}.
98
+ * deps: exec(cmd,args), confirmFn(q, default), write(text), runIssueFn(n), startedMs.
99
+ */
100
+ export async function runFirstRun({ cwd = process.cwd(), exec, confirmFn, write = (t) => process.stdout.write(t), runIssueFn, startedMs = Date.now() } = {}) {
101
+ const fail = (err, issues = []) => { const step = nextStep(err); write(`\n ${String(err?.message ?? err).split("\n")[0]}\n Next step: ${step}\n`); return { status: "error", issues, step }; };
102
+ let repo;
103
+ try {
104
+ exec("gh", ["auth", "status"]);
105
+ } catch (err) { return fail(/not found|ENOENT/i.test(String(err?.message)) ? err : `gh auth: ${err?.stderr || err?.message}`); }
106
+ try {
107
+ repo = String(exec("gh", ["repo", "view", "--json", "nameWithOwner", "-q", ".nameWithOwner"])).trim();
108
+ if (!repo) throw new Error("could not resolve the GitHub repo");
109
+ } catch (err) { return fail(err); }
110
+ if (!existsSync(join(cwd, ".github", "workflows"))) write(` Note: ${nextStep("no CI")}\n`);
111
+ const proposals = proposeIssues(cwd);
112
+ if (!proposals.length) { write(" Nothing small and obvious to propose here. File an issue yourself, then run: npx forgedock run-issue <n>\n"); return { status: "nothing", issues: [] }; }
113
+ write(`\n ForgeDock proposes ${proposals.length} small issue${proposals.length === 1 ? "" : "s"} on ${repo}:\n`);
114
+ proposals.forEach((p, i) => write(` ${i + 1}. ${p.title}\n`));
115
+ if (!(await confirmFn(`File these issue${proposals.length === 1 ? "" : "s"} on ${repo}?`, false))) { write(" Nothing filed. Re-run anytime: npx forgedock first-run\n"); return { status: "declined", issues: [] }; }
116
+ let issues;
117
+ try { issues = fileIssues({ exec, repo, proposals, startedMs }); } catch (err) { return fail(err); }
118
+ write(` Filed ${issues.map((i) => `#${i.number}`).join(", ")}. Running #${issues[0].number} now.\n`);
119
+ try { await runIssueFn(issues[0].number); } catch (err) { return fail(err, issues); }
120
+ write(` Done. Review the PR with: gh pr list -R ${repo}\n`);
121
+ return { status: "done", issues };
122
+ }