forgedock 1.52.0 → 1.54.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/.claude-plugin/marketplace.json +51 -0
  2. package/README.md +8 -2
  3. package/bin/auth/app-manifest.mjs +89 -0
  4. package/bin/auth/app-manifest.test.mjs +75 -0
  5. package/bin/auth/app-token.mjs +256 -0
  6. package/bin/auth/app-token.test.mjs +232 -0
  7. package/bin/brand.mjs +7 -0
  8. package/bin/config-history.mjs +151 -0
  9. package/bin/config-schema.mjs +115 -0
  10. package/bin/demo.mjs +65 -11
  11. package/bin/engine/outcome-codes.mjs +9 -3
  12. package/bin/engine/telemetry-seam.mjs +11 -3
  13. package/bin/engine/telemetry-seam.test.mjs +17 -0
  14. package/bin/engine-cli.mjs +110 -36
  15. package/bin/experiment.mjs +58 -6
  16. package/bin/first-run.mjs +122 -0
  17. package/bin/forge-utils.mjs +6 -2
  18. package/bin/forgedock.mjs +138 -142
  19. package/bin/help-text.mjs +144 -0
  20. package/bin/hooks/pre-tool-use.mjs +7 -0
  21. package/bin/journey.mjs +82 -83
  22. package/bin/lean/acceptance.mjs +313 -0
  23. package/bin/lean/acceptance.test.mjs +215 -0
  24. package/bin/lean/account-watch.mjs +28 -0
  25. package/bin/lean/account-watch.test.mjs +30 -0
  26. package/bin/lean/activation.mjs +38 -0
  27. package/bin/lean/activation.test.mjs +36 -1
  28. package/bin/lean/basered.mjs +115 -0
  29. package/bin/lean/basered.test.mjs +66 -0
  30. package/bin/lean/batch-health.mjs +114 -7
  31. package/bin/lean/batch-health.test.mjs +87 -1
  32. package/bin/lean/batch.mjs +41 -2
  33. package/bin/lean/batch.test.mjs +115 -11
  34. package/bin/lean/branchlock.mjs +54 -0
  35. package/bin/lean/branchlock.test.mjs +49 -0
  36. package/bin/lean/ceiling.mjs +72 -0
  37. package/bin/lean/ceiling.test.mjs +54 -0
  38. package/bin/lean/checkpoint-reconcile.mjs +43 -0
  39. package/bin/lean/checkpoint-reconcile.test.mjs +95 -0
  40. package/bin/lean/ci-budget.mjs +366 -0
  41. package/bin/lean/ci-budget.test.mjs +167 -0
  42. package/bin/lean/conformance.e2e.test.mjs +8 -1
  43. package/bin/lean/conformance.mjs +269 -38
  44. package/bin/lean/conformance.test.mjs +280 -7
  45. package/bin/lean/context.mjs +35 -6
  46. package/bin/lean/context.test.mjs +27 -1
  47. package/bin/lean/depcache.mjs +25 -1
  48. package/bin/lean/depcache.test.mjs +26 -0
  49. package/bin/lean/e2e.mjs +18 -2
  50. package/bin/lean/e2e.test.mjs +26 -1
  51. package/bin/lean/effects.mjs +47 -14
  52. package/bin/lean/execution.mjs +19 -3
  53. package/bin/lean/execution.test.mjs +63 -0
  54. package/bin/lean/facts.mjs +3 -3
  55. package/bin/lean/facts.test.mjs +5 -0
  56. package/bin/lean/findinglabel.mjs +16 -0
  57. package/bin/lean/findinglabel.test.mjs +39 -0
  58. package/bin/lean/fixround.mjs +14 -0
  59. package/bin/lean/fixround.test.mjs +25 -2
  60. package/bin/lean/gh-assoc.test.mjs +2 -1
  61. package/bin/lean/integration.mjs +100 -9
  62. package/bin/lean/integration.test.mjs +98 -0
  63. package/bin/lean/issuewatch-parity.mjs +64 -0
  64. package/bin/lean/issuewatch-parity.test.mjs +127 -0
  65. package/bin/lean/issuewatch-release.mjs +6 -2
  66. package/bin/lean/issuewatch-release.test.mjs +17 -1
  67. package/bin/lean/issuewatch.mjs +45 -6
  68. package/bin/lean/issuewatch.test.mjs +3 -2
  69. package/bin/lean/lanelock.mjs +14 -0
  70. package/bin/lean/lean.mjs +473 -100
  71. package/bin/lean/lean.test.mjs +686 -33
  72. package/bin/lean/light.mjs +48 -7
  73. package/bin/lean/light.test.mjs +37 -3
  74. package/bin/lean/limits.test.mjs +142 -9
  75. package/bin/lean/mechfix.mjs +124 -0
  76. package/bin/lean/mechfix.test.mjs +75 -0
  77. package/bin/lean/orchestrate-cancel.test.mjs +143 -0
  78. package/bin/lean/orchestrate.mjs +116 -28
  79. package/bin/lean/phaseledger.mjs +47 -5
  80. package/bin/lean/phaseledger.test.mjs +30 -1
  81. package/bin/lean/postdeploy-check.test.mjs +39 -0
  82. package/bin/lean/precheck.mjs +23 -4
  83. package/bin/lean/precheck.test.mjs +14 -1
  84. package/bin/lean/prereq.mjs +28 -0
  85. package/bin/lean/prereq.test.mjs +20 -0
  86. package/bin/lean/probe.mjs +4 -2
  87. package/bin/lean/prodparity.mjs +52 -0
  88. package/bin/lean/prodparity.test.mjs +67 -0
  89. package/bin/lean/prompts.mjs +77 -19
  90. package/bin/lean/quota.mjs +39 -0
  91. package/bin/lean/recovery.test.mjs +11 -1
  92. package/bin/lean/relaxation.mjs +73 -0
  93. package/bin/lean/relaxation.test.mjs +54 -0
  94. package/bin/lean/release-io.test.mjs +42 -0
  95. package/bin/lean/release-postmerge.mjs +125 -0
  96. package/bin/lean/release-preflight.mjs +58 -0
  97. package/bin/lean/release-preflight.test.mjs +114 -0
  98. package/bin/lean/release-rehearsal.mjs +64 -0
  99. package/bin/lean/release-rehearsal.test.mjs +93 -0
  100. package/bin/lean/release-review.e2e.test.mjs +77 -0
  101. package/bin/lean/release-review.mjs +254 -0
  102. package/bin/lean/release-review.test.mjs +307 -0
  103. package/bin/lean/release-snapshot.mjs +188 -0
  104. package/bin/lean/release-snapshot.test.mjs +190 -0
  105. package/bin/lean/release.mjs +296 -0
  106. package/bin/lean/release.test.mjs +387 -0
  107. package/bin/lean/render.mjs +1 -1
  108. package/bin/lean/replan.mjs +184 -0
  109. package/bin/lean/replan.test.mjs +110 -0
  110. package/bin/lean/resume.mjs +9 -7
  111. package/bin/lean/resume.test.mjs +16 -0
  112. package/bin/lean/rotator.mjs +150 -31
  113. package/bin/lean/rotator.test.mjs +105 -2
  114. package/bin/lean/sandbox-remote.mjs +9 -2
  115. package/bin/lean/schedd.mjs +83 -5
  116. package/bin/lean/schedd.test.mjs +108 -7
  117. package/bin/lean/selfreview.mjs +94 -0
  118. package/bin/lean/selfreview.test.mjs +58 -1
  119. package/bin/lean/selftest-gate.mjs +22 -0
  120. package/bin/lean/selftest-gate.test.mjs +18 -1
  121. package/bin/lean/selftest-journey.mjs +234 -0
  122. package/bin/lean/selftest-journey.test.mjs +130 -0
  123. package/bin/lean/selftest-live.mjs +2 -1
  124. package/bin/lean/seqlease.mjs +35 -1
  125. package/bin/lean/seqlease.test.mjs +15 -0
  126. package/bin/lean/seqreserve.e2e.test.mjs +135 -0
  127. package/bin/lean/seqreserve.mjs +73 -0
  128. package/bin/lean/seqreserve.test.mjs +134 -0
  129. package/bin/lean/sequence.mjs +35 -6
  130. package/bin/lean/seqversioned.mjs +147 -0
  131. package/bin/lean/stagestamp.mjs +28 -0
  132. package/bin/lean/stagestamp.test.mjs +32 -0
  133. package/bin/lean/surfaces.mjs +75 -0
  134. package/bin/lean/surfaces.test.mjs +59 -0
  135. package/bin/lean/toolplace.mjs +28 -0
  136. package/bin/lean/toolplace.test.mjs +24 -0
  137. package/bin/lean/toolstats.mjs +3 -1
  138. package/bin/lean/toolstats.test.mjs +11 -0
  139. package/bin/lean/validatebest.mjs +28 -0
  140. package/bin/lean/validatebest.test.mjs +27 -0
  141. package/bin/lean/verifier.mjs +3 -2
  142. package/bin/lean/verify.mjs +2 -1
  143. package/bin/lean/verify.test.mjs +6 -0
  144. package/bin/pool/agent.mjs +27 -4
  145. package/bin/pool/docker.mjs +5 -0
  146. package/bin/pool/router.mjs +74 -28
  147. package/bin/prereqs.mjs +111 -0
  148. package/bin/replay-timelapse.mjs +149 -0
  149. package/bin/review-staging.mjs +123 -16
  150. package/bin/review-staging.test.mjs +18 -0
  151. package/bin/runner.mjs +43 -6
  152. package/bin/splash-install.mjs +157 -0
  153. package/bin/stats/aggregate.mjs +8 -1
  154. package/bin/stats/conformance-outcomes.mjs +289 -0
  155. package/bin/stats/conformance-outcomes.test.mjs +274 -0
  156. package/bin/stats/depth.mjs +275 -0
  157. package/bin/stats/depth.test.mjs +158 -0
  158. package/bin/stats/efficiency.mjs +26 -5
  159. package/bin/stats/efficiency.test.mjs +45 -1
  160. package/bin/stats/experiment.mjs +7 -5
  161. package/bin/stats/first-review.mjs +77 -0
  162. package/bin/stats/first-review.test.mjs +36 -0
  163. package/bin/stats/firstmerge.mjs +40 -0
  164. package/bin/stats/firstmerge.test.mjs +41 -0
  165. package/bin/stats/github-source.mjs +53 -15
  166. package/bin/stats/index.mjs +147 -9
  167. package/bin/stats/local-source.mjs +12 -0
  168. package/bin/stats/origin.mjs +80 -0
  169. package/bin/stats/origin.test.mjs +58 -0
  170. package/bin/stats/query.mjs +69 -0
  171. package/bin/stats/render.mjs +3 -1
  172. package/bin/stats/scoreboard.mjs +137 -0
  173. package/bin/stats/scoreboard.test.mjs +87 -0
  174. package/bin/stats/selffiled.mjs +52 -0
  175. package/bin/stats/selffiled.test.mjs +71 -0
  176. package/bin/stats/stats.test.mjs +80 -0
  177. package/bin/tui.mjs +3 -2
  178. package/commands/bootstrap.md +15 -14
  179. package/commands/deploy-pr.md +18 -3
  180. package/commands/forge-stats.md +1 -1
  181. package/commands/forgedock-ci-setup.md +28 -0
  182. package/commands/forgedock-init.md +4 -5
  183. package/commands/issue.md +2 -0
  184. package/commands/milestone.md +9 -1
  185. package/commands/orchestrate.md +1 -1
  186. package/commands/replay.md +2 -0
  187. package/commands/review-pr-agents/security.md +4 -0
  188. package/commands/review-pr-staging.md +6 -1
  189. package/commands/work-on/build.md +4 -6
  190. package/commands/work-on/close.md +8 -0
  191. package/docs/CONFIG.md +170 -18
  192. package/docs/ISSUE-WATCH.md +25 -0
  193. package/docs/OUTCOME-CODES.md +4 -0
  194. package/docs/REPLAY.md +9 -0
  195. package/docs/SELFTEST.md +11 -0
  196. package/docs/STATS.md +61 -0
  197. package/docs/TELEMETRY.md +1 -1
  198. package/docs/eval/README.md +6 -0
  199. package/docs/eval/adversarial-bench.md +68 -0
  200. package/docs/eval/corpus/adversarial-v1.json +285 -0
  201. package/docs/eval/feature-bench.md +42 -0
  202. package/docs/eval/feature-specs/crud-auth/journeys/notes-crud-isolated.mjs +21 -0
  203. package/docs/eval/feature-specs/crud-auth/journeys/register-login.mjs +12 -0
  204. package/docs/eval/feature-specs/crud-auth/spec.md +15 -0
  205. package/docs/site/start-a-new-project.md +2 -1
  206. package/package.json +5 -2
  207. package/plugins/forgedock-splash/.claude-plugin/plugin.json +10 -0
  208. package/plugins/forgedock-splash/README.md +27 -0
  209. package/plugins/forgedock-splash/hooks/hooks.json +1 -0
  210. package/plugins/forgedock-splash/hooks/register.tsx +74 -0
  211. package/plugins/forgedock-splash/hooks/scene.ts +222 -0
  212. package/plugins/forgedock-splash/types/index.d.ts +10 -0
  213. package/pool/README.md +1 -1
  214. package/pool/image/cs-cred +14 -1
  215. package/scripts/backfill-finding-labels.mjs +50 -0
  216. package/scripts/backfill-finding-labels.test.mjs +36 -0
  217. package/scripts/bench-adversarial.mjs +216 -0
  218. package/scripts/bench-feature.mjs +170 -0
  219. package/scripts/bench-lightlane.mjs +2 -2
  220. package/scripts/bootstrap-create.mjs +2 -2
  221. package/scripts/bootstrap-validate.mjs +35 -2
  222. package/scripts/check-spec-size.sh +4 -3
  223. package/scripts/check-spec-size.test.sh +3 -0
  224. package/scripts/doctor-pipeline-state.sh +21 -6
  225. package/scripts/file-deferred-followups.sh +59 -251
  226. package/scripts/file-deferred-followups.test.sh +85 -206
  227. package/scripts/followup-route.mjs +12 -0
  228. package/scripts/owner-route-parity.test.sh +17 -1
  229. package/scripts/plan-validate-live.mjs +40 -6
  230. package/scripts/review-pr-side-effects.test.sh +40 -0
  231. package/scripts/review-pr-staging-scope.test.sh +1 -1
  232. package/scripts/review-staging-post.sh +23 -0
  233. package/scripts/review-staging-post.test.sh +8 -0
@@ -9,7 +9,7 @@
9
9
  * batch (batch.mjs `addIssues`, so K, the `Depends on` DAG and the report apply) and starts a new one after it reports.
10
10
  * No LLM calls.
11
11
  */
12
- import { existsSync, mkdirSync, readFileSync, rmdirSync } from "node:fs";
12
+ import { existsSync, mkdirSync, readFileSync, readdirSync, rmdirSync } from "node:fs";
13
13
  import { execFileSync, spawn, spawnSync } from "node:child_process";
14
14
  import { homedir, hostname } from "node:os";
15
15
  import { dirname, join } from "node:path";
@@ -18,14 +18,16 @@ import { writeAtomic, batchRoot, openBatch, listBatches } from "./batch.mjs";
18
18
  import { milestoneSlug, readBranches, isDefaultLane, defaultBranches, DEFAULT_STAGING_BRANCH, DEFAULT_FEATURE_PATTERN } from "./lane.mjs";
19
19
  import { postDeployOnly } from "./prefilter.mjs";
20
20
  import { releaseTick, formatDryRun } from "./issuewatch-release.mjs";
21
+ import { releaseRoot } from "./release.mjs";
21
22
  import { loadPolicy } from "./decision-engine.mjs";
22
23
  import { decisionContext, decisionsActive, decisionStep, decisionCounts, formatDecisionDryRun, claimsUsed } from "./issuewatch-decisions.mjs";
23
24
  import { APP_SLUG } from "../init-repo.mjs";
24
25
  import { noComments } from "./render.mjs";
25
26
  import { listAssociations } from "./gh-assoc.mjs";
26
27
  import { verifyMerge, verifyComment } from "./issuewatch-verify.mjs";
28
+ import { DEFAULT_SKIP_LABELS, isPullRequest, searchesPullRequests, skipLabelHit, closingPrIssues, releaseInFlight, watchLiveness } from "./issuewatch-parity.mjs";
27
29
 
28
- const WATCH_KEYS = ["milestone", "labels", "exclude_labels", "search", "title_regex", "since", "version", "lane", "max_issues", "max_inflight", "until", "mode", "parallel", "include_followups", "postdeploy_rollup", "threshold", "immediate", "max_release_issues", "theme_map", "tracker", "sweep_needs_human", "max_launches", "trust_app", "trust_app_labels"];
30
+ const WATCH_KEYS = ["milestone", "labels", "exclude_labels", "search", "title_regex", "since", "version", "lane", "max_issues", "max_inflight", "until", "mode", "parallel", "include_followups", "postdeploy_rollup", "threshold", "immediate", "max_release_issues", "theme_map", "tracker", "sweep_needs_human", "max_launches", "trust_app", "trust_app_labels", "skip_labels", "release_pause"];
29
31
  export const TRUSTED = new Set(["OWNER", "MEMBER", "COLLABORATOR"]);
30
32
  const NAME_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
31
33
  const RETRIES = 3;
@@ -80,8 +82,12 @@ export function validateWatch(name, cfg = {}) {
80
82
  since: cfg.since || null, version: cfg.version ? String(cfg.version) : null, lane: cfg.lane || null, max_issues: int("max_issues", null), max_inflight: int("max_inflight", 4),
81
83
  until: cfg.until || null, mode: cfg.mode || "per-issue", parallel: int("parallel", 4), include_followups: cfg.include_followups || "none", postdeploy_rollup: cfg.postdeploy_rollup ? Number(String(cfg.postdeploy_rollup).replace("#", "")) : null,
82
84
  max_launches: int("max_launches", null), sweep_needs_human: cfg.sweep_needs_human === true || String(cfg.sweep_needs_human).toLowerCase() === "true",
83
- trust_app: cfg.trust_app === true || String(cfg.trust_app).toLowerCase() === "true", trust_app_labels: list(cfg.trust_app_labels) };
85
+ trust_app: cfg.trust_app === true || String(cfg.trust_app).toLowerCase() === "true", trust_app_labels: list(cfg.trust_app_labels),
86
+ skip_labels: cfg.skip_labels === undefined ? (cfg.mode === "batch" ? DEFAULT_SKIP_LABELS : []) : list(cfg.skip_labels), // #5313: the bash watcher's skip list; batch watches take it by default
87
+ release_pause: cfg.release_pause === undefined ? cfg.mode === "batch" : /^true$/i.test(String(cfg.release_pause)) };
84
88
  if (cfg.sweep_needs_human !== undefined && !/^(true|false)$/i.test(String(cfg.sweep_needs_human))) throw new Error(`watch ${name}: sweep_needs_human must be true or false`);
89
+ if (cfg.release_pause !== undefined && !/^(true|false)$/i.test(String(cfg.release_pause))) throw new Error(`watch ${name}: release_pause must be true or false`);
90
+ if (searchesPullRequests(w.search)) throw new Error(`watch ${name}: search must not select pull requests (a watch claims issues only)`);
85
91
  if (cfg.trust_app !== undefined && !/^(true|false)$/i.test(String(cfg.trust_app))) throw new Error(`watch ${name}: trust_app must be true or false`);
86
92
  if (w.trust_app_labels.length && !w.trust_app) throw new Error(`watch ${name}: trust_app_labels needs trust_app: true`);
87
93
  if (!["per-issue", "batch", "release"].includes(w.mode)) throw new Error(`watch ${name}: mode must be per-issue, batch or release`);
@@ -140,6 +146,14 @@ export function selectorMiss(issue, sel) {
140
146
  return null;
141
147
  }
142
148
 
149
+ /** #5313: why the bash watcher's rules skip `issue` (a PR, a skip label, an open closing PR), or null. */
150
+ export function parityMiss(issue, watch, closing = new Map()) {
151
+ if (isPullRequest(issue)) return "pull request (a watch claims issues only)";
152
+ const l = skipLabelHit(issue, watch.skip_labels);
153
+ if (l) return `skip label ${l}`;
154
+ return closing.has(issue.number) ? `open closing PR #${closing.get(issue.number)}` : null;
155
+ }
156
+
143
157
  /** AND of every set selector. `search` is applied by gh, not here. */
144
158
  export const matchesSelectors = (issue, sel) => !selectorMiss(issue, sel);
145
159
 
@@ -323,6 +337,7 @@ export async function tick({ watch, repo, io, state, dir, branches = {}, default
323
337
  }
324
338
  if (taken.length && watch.mode === "batch") {
325
339
  const nums = taken.map((t) => t.n);
340
+ if (state.batch && io.batch.reported(state.batch)) { state.inflight.filter((n) => !nums.includes(n)).forEach(fail); state.batch = null; } // #5313: it reported since the check above; never add to a finished batch
326
341
  if (state.batch) io.batch.add(state.batch, nums); else state.batch = await io.batch.start(nums, watch.parallel, taken[0].lane);
327
342
  } else for (const t of taken) handles.set(t.n, io.launch(t.n, t.lane));
328
343
  return state;
@@ -340,8 +355,11 @@ export async function planClaims({ watch, repo, io, state, branches = {}, defaul
340
355
  if (watch.search) args.push("--search", watch.search);
341
356
  const found = [], folds = [], skip = [], why = new Map();
342
357
  const assoc = await listAssociations(io.gh, repo); // #4859: not a `gh issue list` field
358
+ const closing = await closingPrIssues(io.gh, repo); // #5313
343
359
  for (const raw of JSON.parse(String(await io.gh(args)))) {
344
360
  const i = { ...raw, authorAssociation: assoc.get(raw.number) };
361
+ const parity = parityMiss(i, watch, closing);
362
+ if (parity) { skip.push({ number: i.number, reason: parity }); continue; }
345
363
  const miss = selectorMiss(i, watch);
346
364
  if (miss) { skip.push({ number: i.number, reason: miss }); continue; }
347
365
  const c = classifyWhy(i, watch);
@@ -380,13 +398,15 @@ async function releaseStep({ watch, repo, io, state, dir, branches = {}, default
380
398
  const args = ["issue", "list", "-R", repo, "--state", "open", "--limit", "200", "--json", "number,title,body,labels,milestone,author,createdAt"];
381
399
  if (watch.search) args.push("--search", watch.search);
382
400
  const registry = () => readJson(join(repoDir(repo, io.env), "claims.json")) ?? {};
401
+ let closing = new Map();
383
402
  const listOpen = async () => {
384
403
  const assoc = await listAssociations(io.gh, repo); // #4859
385
- const all = JSON.parse(String(await io.gh(args))).map((i) => ({ ...i, authorAssociation: assoc.get(i.number) }));
404
+ closing = await closingPrIssues(io.gh, repo); // #5313
405
+ const all = JSON.parse(String(await io.gh(args))).filter((i) => !isPullRequest(i)).map((i) => ({ ...i, authorAssociation: assoc.get(i.number) }));
386
406
  if (!dryRun) for (const i of all) if (matchesSelectors(i, watch) && classifyIssue(i, watch) === "fold") await fold({ issue: i, watch, repo, io, state });
387
407
  return all;
388
408
  };
389
- const eligible = (i) => matchesSelectors(i, watch) && classifyIssue(i, watch) === "claim" && !state.claimed.includes(i.number) && unclaimedOrOwn(registry(), i.number, watch.name); // release #4820 CONC-1: own claims stay eligible
409
+ const eligible = (i) => !parityMiss(i, watch, closing) && matchesSelectors(i, watch) && classifyIssue(i, watch) === "claim" && !state.claimed.includes(i.number) && unclaimedOrOwn(registry(), i.number, watch.name); // release #4820 CONC-1: own claims stay eligible
390
410
  const p = loadPolicy({ io: { readFile }, cwd });
391
411
  return releaseTick({ watch, repo, io, state, defaults, listOpen, eligible, claim: (n) => claimIssue(repoDir(repo, io.env), n, watch.name), laneFor: (i) => laneFor(i, watch, { branches, defaults }), dagOrder,
392
412
  policy: { path: p.policyPath, text: p.policyText }, dryRun });
@@ -405,7 +425,8 @@ async function fold({ issue, watch, repo, io, state }) {
405
425
  export function formatStatus(s, watch, now = Date.now()) {
406
426
  const sel = ["milestone", "labels", "exclude_labels", "search", "title_regex", "since", "version", "lane"].filter((k) => (Array.isArray(watch[k]) ? watch[k].length : watch[k])).map((k) => `${k}=${[].concat(watch[k]).join(",")}`).join(" ") || "(all trusted issues)";
407
427
  const left = watch.until ? `${Math.max(0, Math.round((Date.parse(watch.until) - now) / 60000))}m` : "forever";
408
- return [`watch ${s.name} (${s.repo}) [${s.phase}, ${watch.mode}]`, ` selector: ${sel}`,
428
+ const live = s.heartbeat || s.paused ? watchLiveness(s, now) : null;
429
+ return [`watch ${s.name} (${s.repo}) [${s.phase}, ${watch.mode}]`, ...(live ? [` state: ${live.state}${live.state === "paused" || live.state === "stale" ? ` (${live.reason})` : ""} last heartbeat: ${s.heartbeat ?? "never"}${live.ageMs != null ? ` (${Math.round(live.ageMs / 1000)}s ago)` : ""}`] : []), ` selector: ${sel}`,
409
430
  ` claims: ${s.claimed.length}/${watch.max_issues ?? "∞"} inflight: ${s.inflight.length} merged: ${s.merged.length} verified: ${s.verified.length} unverified: ${(s.unverified ?? []).length} closed unmerged: ${(s.closed ?? []).length} failed: ${s.failed.length}`, ` time remaining: ${left}`,
410
431
  ...(s.decisions ? [(({ decided, evidence, folded, external_kept: kept }) => ` needs-human decisions: decided ${decided} evidence-gathered ${evidence} folded ${folded} external-kept ${kept}`)(decisionCounts(s))] : []),
411
432
  ...(s.decisionError ? [` needs-human decisions: last round failed: ${s.decisionError}`] : []), // release #5068 CQ-1
@@ -450,6 +471,15 @@ export async function runWatch({ watch, repo, io, dir, branches, defaults, once
450
471
  const launch = (i) => decisionLaunch({ i, watch, repo, io, state, handles, branches, defaults });
451
472
  try {
452
473
  do {
474
+ state.heartbeat = new Date(io.now()).toISOString(); state.heartbeatEveryMs = intervalMs; // #5313: liveness lives in the state, not a process grep
475
+ const rel = watch.release_pause && state.phase === "running" ? (io.releaseInFlight ?? releaseInFlight)({ root: releaseRoot(io.env), repo, now: io.now() }) : null;
476
+ if (rel) { // a release job holds staging: no claims, retries or decisions until it ends; the next pass resumes by itself
477
+ state.paused = { reason: `release ${rel.id} in flight${rel.step ? ` (${rel.step})` : ""}`, release: rel.id, since: state.paused?.since ?? state.heartbeat };
478
+ writeAtomic(join(dir, "status.json"), JSON.stringify(state) + "\n");
479
+ if (once) break;
480
+ await io.sleep(intervalMs); continue;
481
+ }
482
+ state.paused = null;
453
483
  if (state.phase === "running" && decisionsActive(watch, ctx.policy)) { // #4793: a failed round must not stop the watch
454
484
  try { await decisionStep({ watch, repo, io, state, ctx, shared, launch }); state.decisionError = null; } catch (e) { state.decisionError = String(e?.message ?? e).slice(0, 200); }
455
485
  }
@@ -483,6 +513,15 @@ function realIo(repo, env = process.env) {
483
513
  p.on("close", (code) => { res = { code: code ?? 1 }; }); p.on("error", () => { res = { code: 1 }; });
484
514
  return { poll: () => res };
485
515
  },
516
+ release: {
517
+ // #5214: start the resumable `forgedock release` job for the deploy PR; no --merge (promotion is release.auto_merge only)
518
+ start: async ({ repo: r }) => {
519
+ const dir = releaseRoot(env), ls = () => { try { return readdirSync(dir); } catch { return []; } }, before = new Set(ls());
520
+ spawn(process.execPath, [CLI, "release", "--repo", r], { detached: true, windowsHide: true, stdio: "ignore", cwd: process.cwd(), env }).unref();
521
+ for (let i = 0; i < 10; i++) { const id = ls().find((x) => !before.has(x)); if (id) return id; await new Promise((res) => setTimeout(res, 500)); }
522
+ return "started";
523
+ },
524
+ },
486
525
  batch: {
487
526
  add: (id, issues) => openBatch(root, id).addIssues(issues),
488
527
  // release #5068 MAT-1: the CLI path checks the label, reopens a finished batch and hosts it on the schedd
@@ -32,6 +32,7 @@ function fakeIo(env, issues, { closed = new Set(), exit = () => 0, bodies = {},
32
32
  if (a[0] === "api" && /\/commits\/([0-9a-f]+)\/check-runs/.test(a.join(" "))) { const sha = /commits\/([0-9a-f]+)/.exec(a.join(" "))[1]; return (checks[sha] ?? []).map(([n, st, c], i) => `${i + 1}\t${n}\t${st}\t${c ?? ""}`).join("\n"); }
33
33
  if (a[0] === "api" && /\/commits\/[0-9a-f]+\/status/.test(a[1])) return "";
34
34
  if (a[0] === "api") return issues.filter((i) => !closed.has(i.number)).map((i) => `${i.number}\t${i.authorAssociation}`).join("\n"); // #4859: REST association list
35
+ if (a[0] === "pr" && a[1] === "list" && a.join(" ").includes("closingIssuesReferences")) return JSON.stringify(io.openPrs ?? []); // #5313: open PRs with their closing issues
35
36
  if (a[0] === "pr" && a[1] === "list") { const n = +/feat\/issue-(\d+)-lean/.exec(a.join(" "))[1]; return JSON.stringify(n in prs ? prs[n] : [{ number: 1000 + n, baseRefName: "staging", headRefOid: `aa${n}`, mergeCommit: { oid: `bb${n}` }, labels: [] }]); }
36
37
  if (a[1] === "list") return JSON.stringify(issues.filter((i) => !closed.has(i.number)).map(({ authorAssociation: _a, ...i }) => i));
37
38
  if (a[1] === "view" && a.includes("state")) return JSON.stringify({ state: closed.has(+a[2]) ? "CLOSED" : "OPEN" });
@@ -99,7 +100,7 @@ test("version: from the milestone title, from a version:x.y label, title wins",
99
100
  test("search is passed to gh", async () => {
100
101
  const dir = tmp(), io = fakeIo(dir, [iss(1)]);
101
102
  await tick({ watch: W({ search: "label:bug sort:created-asc" }), repo: "o/r", io, state: { claimed: [], inflight: [], merged: [], verified: [], failed: [], folded: [], retries: {}, lanes: {}, phase: "running" } });
102
- const list = io.calls.find((a) => a[1] === "list");
103
+ const list = io.calls.find((a) => a[0] === "issue" && a[1] === "list");
103
104
  assert.equal(list[list.indexOf("--search") + 1], "label:bug sort:created-asc");
104
105
  });
105
106
 
@@ -494,7 +495,7 @@ for (const mode of ["per-issue", "batch"]) {
494
495
  const r = await issueWatchFromCli(["run", "--name", "intake", "--dry-run"], { cwd, env: io.env, io, print: (l) => out.push(l) });
495
496
  const t = out.join("\n");
496
497
  assert.match(t, /would claim #1 -> staging: ForgeDock App author \(trust_app\)/);
497
- assert.match(t, /skip #2: excluded label epic/);
498
+ assert.match(t, /skip #2: (excluded|skip) label epic/);
498
499
  assert.match(t, /skip #3: untrusted author mallory \(NONE\)/);
499
500
  assert.match(t, /skip #4: already claimed by watch other/);
500
501
  assert.match(t, /skip #5: bot author dependabot\[bot\]/);
@@ -29,3 +29,17 @@ export async function otherLaneOwner({ gh, repo, issue, branch = `feat/issue-${i
29
29
  const other = Array.isArray(prs) ? prs.find((p) => Number.isInteger(p?.number) && p.number !== ownPr) : null;
30
30
  return other ? { kind: "pr", detail: `PR #${other.number} is open on ${branch} from another lane` } : null;
31
31
  }
32
+
33
+ /**
34
+ * #5241: clear the lease on `issue`'s FORGE:STATE when `shouldClear(lease)` agrees (a cancelled lane's, once it ended).
35
+ * @param {{projector: {readState: Function, writeState: Function}, issue: number, shouldClear?: (lease: object) => boolean}} a
36
+ * @returns {Promise<boolean>} true when a lease was cleared; false when none, kept by the guard, or GitHub is unreadable (fail-safe)
37
+ */
38
+ export async function clearLease({ projector, issue, shouldClear = () => true }) {
39
+ try {
40
+ const st = await projector.readState(issue);
41
+ if (!st?.lease || !shouldClear(st.lease)) return false;
42
+ await projector.writeState(issue, { ...st, lease: null });
43
+ return true;
44
+ } catch { return false; }
45
+ }