forgedock 1.65.0 → 1.67.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 (80) hide show
  1. package/bin/config-schema.mjs +2 -0
  2. package/bin/engine/outcome-codes.mjs +1 -0
  3. package/bin/engine-cli.mjs +143 -19
  4. package/bin/forgedock.mjs +7 -0
  5. package/bin/help-text.mjs +3 -3
  6. package/bin/introspect-schedule.mjs +98 -0
  7. package/bin/introspect-schedule.test.mjs +67 -0
  8. package/bin/lean/advisory.test.mjs +49 -0
  9. package/bin/lean/amendment-schema.mjs +31 -0
  10. package/bin/lean/attempts.mjs +159 -0
  11. package/bin/lean/attempts.test.mjs +127 -0
  12. package/bin/lean/basered.mjs +55 -0
  13. package/bin/lean/basered.test.mjs +68 -1
  14. package/bin/lean/batch-health.mjs +13 -5
  15. package/bin/lean/batch-health.test.mjs +16 -0
  16. package/bin/lean/batch.mjs +62 -0
  17. package/bin/lean/batch.test.mjs +119 -3
  18. package/bin/lean/capwait.mjs +14 -3
  19. package/bin/lean/capwait.test.mjs +20 -0
  20. package/bin/lean/clear-breaker.mjs +14 -0
  21. package/bin/lean/commentstate.mjs +41 -0
  22. package/bin/lean/commentstate.test.mjs +32 -0
  23. package/bin/lean/concurrency.mjs +89 -0
  24. package/bin/lean/concurrency.test.mjs +113 -0
  25. package/bin/lean/conformance.e2e.test.mjs +4 -2
  26. package/bin/lean/conformance.mjs +35 -3
  27. package/bin/lean/conformance.test.mjs +52 -0
  28. package/bin/lean/depcache.mjs +9 -0
  29. package/bin/lean/efficiency.mjs +162 -0
  30. package/bin/lean/efficiency.test.mjs +79 -0
  31. package/bin/lean/execution.mjs +31 -13
  32. package/bin/lean/execution.test.mjs +46 -0
  33. package/bin/lean/failure-stop.mjs +46 -0
  34. package/bin/lean/failure-stop.test.mjs +45 -0
  35. package/bin/lean/fixtures/capacity-storm.json +609 -0
  36. package/bin/lean/lean.mjs +130 -30
  37. package/bin/lean/lean.test.mjs +138 -47
  38. package/bin/lean/liveness.mjs +37 -0
  39. package/bin/lean/liveness.test.mjs +33 -0
  40. package/bin/lean/orchestrate-attempts.test.mjs +74 -0
  41. package/bin/lean/orchestrate-envhold.test.mjs +17 -0
  42. package/bin/lean/orchestrate-pause.test.mjs +84 -0
  43. package/bin/lean/orchestrate-reconcile.test.mjs +147 -0
  44. package/bin/lean/orchestrate.mjs +202 -28
  45. package/bin/lean/phaseledger.mjs +6 -0
  46. package/bin/lean/phaseledger.test.mjs +13 -1
  47. package/bin/lean/prompts.mjs +6 -10
  48. package/bin/lean/reconcile.mjs +90 -0
  49. package/bin/lean/recurrence.mjs +38 -2
  50. package/bin/lean/recurrence.test.mjs +56 -1
  51. package/bin/lean/sandbox-remote.mjs +33 -2
  52. package/bin/lean/sched.mjs +19 -0
  53. package/bin/lean/sched.test.mjs +11 -1
  54. package/bin/lean/schedd-health.mjs +8 -1
  55. package/bin/lean/schedd-health.test.mjs +19 -0
  56. package/bin/lean/schedd.mjs +97 -10
  57. package/bin/lean/schedd.test.mjs +138 -1
  58. package/bin/lean/slo.mjs +126 -0
  59. package/bin/lean/slo.test.mjs +112 -0
  60. package/bin/lean/statuscomment.mjs +37 -0
  61. package/bin/lean/statuscomment.test.mjs +48 -1
  62. package/bin/lean/verify.mjs +2 -1
  63. package/bin/pool/agent.mjs +46 -8
  64. package/bin/pool/cache-sweep.mjs +41 -4
  65. package/bin/pool/cli.mjs +28 -1
  66. package/bin/pool/health.mjs +18 -0
  67. package/bin/pool/lane-tools.mjs +21 -0
  68. package/bin/pool/mirror-seed.mjs +21 -2
  69. package/bin/pool/router.mjs +6 -2
  70. package/bin/stats/attempts.mjs +54 -0
  71. package/bin/stats/attempts.test.mjs +30 -0
  72. package/bin/stats/churn.mjs +49 -0
  73. package/bin/stats/churn.test.mjs +31 -0
  74. package/bin/stats/index.mjs +11 -3
  75. package/commands/orchestrate.md +21 -18
  76. package/docs/CONFIG.md +1 -0
  77. package/docs/OUTCOME-CODES.md +1 -0
  78. package/package.json +1 -1
  79. package/pool/image/entrypoint.sh +2 -1
  80. package/scripts/check-devdocs-freshness.sh +1 -1
@@ -9,11 +9,15 @@
9
9
  */
10
10
  import { createHash } from "node:crypto";
11
11
  import { execFile } from "node:child_process";
12
- import { appendFileSync, existsSync, mkdirSync, readFileSync, rmSync, statSync } from "node:fs";
12
+ import { appendFileSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync } from "node:fs";
13
13
  import { join } from "node:path";
14
14
 
15
15
  /** Per-chunk cap on the decoded payload; base64 of it stays under the 1 MB JSON body limit of the router and agent. */
16
16
  export const SEED_CHUNK_MAX = 512 * 1024;
17
+ /** Abandoned uploads: a `.part` untouched this long is swept; one upload and all uploads together are capped (#5970). */
18
+ export const SEED_PART_TTL_MS = 60 * 60000;
19
+ export const SEED_UPLOAD_MAX = 2 * 1024 ** 3;
20
+ export const SEED_TOTAL_MAX = 4 * 1024 ** 3;
17
21
  export const mirrorName = (slug) => String(slug).replace(/\//g, "_");
18
22
  const SLUG_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*(\/[A-Za-z0-9._-]+)?$/;
19
23
  const SHA_RE = /^[a-f0-9]{64}$/;
@@ -60,10 +64,23 @@ export function localRunner({ root, seedDir }) {
60
64
  }
61
65
 
62
66
  /** `runnerFor({slug, cache_key})` -> runner. Returns the agent's mirror seed handlers. */
63
- export function makeMirrorSeed({ seedDir, runnerFor }) {
67
+ export function makeMirrorSeed({ seedDir, runnerFor, partTtlMs = SEED_PART_TTL_MS, uploadMax = SEED_UPLOAD_MAX, totalMax = SEED_TOTAL_MAX }) {
64
68
  mkdirSync(seedDir, { recursive: true });
65
69
  const part = (up) => join(seedDir, `${up}.part`);
66
70
  const size = (up) => { try { return statSync(part(up)).size; } catch { return 0; } };
71
+ /** Removes `.part` files idle past the TTL; returns the bytes the remaining ones hold. */
72
+ const sweep = () => {
73
+ let total = 0;
74
+ for (const n of readdirSync(seedDir)) {
75
+ if (!n.endsWith(".part")) continue;
76
+ try {
77
+ const st = statSync(join(seedDir, n));
78
+ if (Date.now() - st.mtimeMs > partTtlMs) rmSync(join(seedDir, n), { force: true }); else total += st.size;
79
+ } catch { /* removed concurrently */ }
80
+ }
81
+ return total;
82
+ };
83
+ sweep();
67
84
  const check = (b) => {
68
85
  if (typeof b?.slug !== "string" || !SLUG_RE.test(b.slug)) throw fail(400, "slug required");
69
86
  if (typeof b.upload !== "string" || !SHA_RE.test(b.upload)) throw fail(400, "upload must be the bundle sha256");
@@ -84,6 +101,8 @@ export function makeMirrorSeed({ seedDir, runnerFor }) {
84
101
  if (sha256(buf) !== b.sha256) throw fail(422, "chunk checksum mismatch");
85
102
  const have = size(b.upload);
86
103
  if (b.offset !== have) throw fail(409, "offset mismatch", { offset: have });
104
+ if (have + buf.length > uploadMax) throw fail(413, `upload exceeds ${uploadMax} bytes`);
105
+ if (sweep() + buf.length > totalMax) throw fail(413, `seed dir exceeds ${totalMax} bytes`);
87
106
  appendFileSync(part(b.upload), buf);
88
107
  return { offset: have + buf.length };
89
108
  },
@@ -242,6 +242,8 @@ export function createRouter(cfg, { fetchFn = globalThis.fetch, now = () => Date
242
242
  }
243
243
  return out;
244
244
  }
245
+ /** #5967: host free memory and the other-VM (vmmem) working sets per agent. */
246
+ const memReport = (c) => Number.isFinite(c.host_mem_free_gb) ? { host_mem_free_gb: c.host_mem_free_gb, ...(Array.isArray(c.vmmem) && c.vmmem.length ? { vmmem: c.vmmem } : {}), ...(c.host_mem_low === true ? { host_mem_low: true } : {}) } : {};
245
247
  async function capacities() {
246
248
  const out = [];
247
249
  for (const [name, a] of Object.entries(agents())) {
@@ -256,7 +258,7 @@ export function createRouter(cfg, { fetchFn = globalThis.fetch, now = () => Date
256
258
  /** Agent liveness for the scheduler (#4547): an agent is online when it answers and is not paused. */
257
259
  async function status() {
258
260
  const caps = await capacities();
259
- const agentsView = caps.map((c) => ({ name: c.name, ok: c.ok, paused: Boolean(c.paused), transport: c.transport ?? "direct", ...diskReport(c) }));
261
+ const agentsView = caps.map((c) => ({ name: c.name, ok: c.ok, paused: Boolean(c.paused), transport: c.transport ?? "direct", ...diskReport(c), ...memReport(c) }));
260
262
  return { online: agentsView.filter((a) => a.ok && !a.paused).length, total: agentsView.length, agents: agentsView };
261
263
  }
262
264
 
@@ -368,7 +370,8 @@ export function createRouter(cfg, { fetchFn = globalThis.fetch, now = () => Date
368
370
  const sized = (await capacities()).filter((c) => c.ok && !c.paused && inAccount(c, spec) && fitsPriority(c, spec, size));
369
371
  const diskLow = sized.filter((c) => c.host_disk_low === true).map((c) => c.name); // #5733: never POST to a host whose drive is short
370
372
  const capped = sized.filter((c) => c.disk_capped === true && c.host_disk_low !== true).map((c) => c.name); // #5884: lane disk at its hard cap
371
- const fits = sized.filter((c) => c.host_disk_low !== true && c.disk_capped !== true).sort((a, b) => headroom(b, spec) - headroom(a, spec) || b.cpus_free - a.cpus_free || b.mem_free_gb - a.mem_free_gb);
373
+ const memLow = sized.filter((c) => c.host_mem_low === true && c.host_disk_low !== true && c.disk_capped !== true).map((c) => c.name); // #5967: host memory under the floor
374
+ const fits = sized.filter((c) => c.host_disk_low !== true && c.disk_capped !== true && c.host_mem_low !== true).sort((a, b) => headroom(b, spec) - headroom(a, spec) || b.cpus_free - a.cpus_free || b.mem_free_gb - a.mem_free_gb);
372
375
  const laneId = isLane(spec.id), laneCapped = []; // #5735: agents skipped because their lane ceiling is reached
373
376
  let busy = null; // the last agent 503 (e.g. lane_tools image building): its body and Retry-After are passed back
374
377
  const seeded = seedPick.get(spec.id)?.agent; // #5949: the agent holding this lane's seeded mirror goes first
@@ -387,6 +390,7 @@ export function createRouter(cfg, { fetchFn = globalThis.fetch, now = () => Date
387
390
  if (busy) return { status: 503, body: { ...agentBody(busy.r, busy.name), agent: busy.name }, retryAfter: busy.r.retryAfter ?? cfg.retry_after_s ?? 60 };
388
391
  if (diskLow.length) return { status: 503, body: { error: "no host has free disk", code: "pool.disk_low", agents: diskLow }, retryAfter: cfg.disk_low_retry_after_s ?? 300 }; // a capacity deferral, not a failure
389
392
  if (capped.length) return { status: 503, body: { error: "no host has lane disk below its cap", code: "pool.disk_cap", agents: capped }, retryAfter: cfg.disk_low_retry_after_s ?? 300 };
393
+ if (memLow.length) return { status: 503, body: { error: "no host has free memory", code: "pool.host_mem", reason: "host_mem", agents: memLow }, retryAfter: cfg.host_mem_retry_after_s ?? 60 }; // a capacity deferral, not a failure
390
394
  return { status: 503, body: { error: "no host has a free reservation", lane: size }, retryAfter: cfg.retry_after_s ?? 60 };
391
395
  }
392
396
 
@@ -0,0 +1,54 @@
1
+ // SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
2
+ // SPDX-License-Identifier: AGPL-3.0-or-later
3
+ /**
4
+ * #5986: attempts per merged issue and per-issue engine comment count for `forgedock stats --attempts`, from the repo's local batch
5
+ * files (state.json `attempts` ledger, report.json rows). No network, no model. The ledger counts failed lanes; the merging lane is
6
+ * one more, so a merged-first-try issue is 1 attempt.
7
+ */
8
+ import { existsSync, readFileSync } from "node:fs";
9
+ import { join } from "node:path";
10
+ import { listBatches } from "../lean/batch.mjs";
11
+ import { sameRepo, windowLabel } from "./efficiency.mjs";
12
+
13
+ const readJson = (f) => { try { return JSON.parse(readFileSync(f, "utf8")); } catch { return null; } };
14
+ const round1 = (x) => Math.round(x * 10) / 10;
15
+ const p50 = (xs) => { if (!xs.length) return null; const s = [...xs].sort((a, b) => a - b), m = s.length >> 1; return round1(s.length % 2 ? s[m] : (s[m - 1] + s[m]) / 2); };
16
+
17
+ /** Per issue (latest row wins across batches): attempts for merged issues, and the engine comment count where a ledger recorded it. */
18
+ export function attemptMetrics(rows, ledgers) {
19
+ const by = new Map();
20
+ for (const r of rows ?? []) if (Number.isSafeInteger(r?.issue)) by.set(r.issue, r);
21
+ const detail = [];
22
+ for (const [n, r] of by) {
23
+ if (r.outcome !== "merged") continue;
24
+ const l = ledgers?.[n] ?? null;
25
+ detail.push({ issue: n, attempts: (Number.isInteger(l?.attempts) ? l.attempts : 0) + 1, comments: Number.isInteger(l?.comments) ? l.comments : null });
26
+ }
27
+ const att = detail.map((d) => d.attempts), com = detail.map((d) => d.comments).filter((c) => c !== null);
28
+ return { merged: detail.length, attempts_p50: p50(att), attempts_mean: att.length ? round1(att.reduce((a, b) => a + b, 0) / att.length) : null, attempts_max: att.length ? Math.max(...att) : null,
29
+ comments_p50: p50(com), comments_max: com.length ? Math.max(...com) : null, detail };
30
+ }
31
+
32
+ export function attemptsReport({ batchRoot, repo = null, windows, now = Date.now() }) {
33
+ const batches = (existsSync(batchRoot) ? listBatches(batchRoot) : []).map((id) => {
34
+ const dir = join(batchRoot, id), plan = readJson(join(dir, "plan.json")) ?? {};
35
+ return { dir, plan, created: Date.parse(plan.created ?? "") };
36
+ }).filter((b) => Number.isFinite(b.created) && (!repo || sameRepo(b.plan.repo, repo))).sort((a, b) => a.created - b.created);
37
+ const out = {};
38
+ for (const w of windows) {
39
+ const inWin = batches.filter((b) => b.created <= now && now - b.created <= w), rows = [], ledgers = {};
40
+ for (const b of inWin) { // oldest first: a later batch's row and ledger replace an earlier one for the same issue
41
+ rows.push(...(readJson(join(b.dir, "report.json"))?.rows ?? []));
42
+ Object.assign(ledgers, readJson(join(b.dir, "state.json"))?.attempts ?? {});
43
+ }
44
+ const { detail, ...m } = attemptMetrics(rows, ledgers);
45
+ out[windowLabel(w)] = { batches: inWin.length, ...m, detail };
46
+ }
47
+ return out;
48
+ }
49
+
50
+ export function formatAttemptLines(windows) {
51
+ return Object.entries(windows).flatMap(([w, m]) => [`attempts ${w}: ${m.batches} batch${m.batches === 1 ? "" : "es"}, ${m.merged} merged issue${m.merged === 1 ? "" : "s"}`,
52
+ ` attempts per merged issue: ${m.attempts_mean == null ? "n/a" : `mean ${m.attempts_mean}, p50 ${m.attempts_p50}, max ${m.attempts_max}`}`,
53
+ ` engine comments per issue: ${m.comments_p50 == null ? "n/a" : `p50 ${m.comments_p50}, max ${m.comments_max}`}`]);
54
+ }
@@ -0,0 +1,30 @@
1
+ // SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
2
+ // SPDX-License-Identifier: AGPL-3.0-or-later
3
+ import { describe, it } from "node:test";
4
+ import assert from "node:assert/strict";
5
+ import { mkdirSync, writeFileSync } from "node:fs";
6
+ import { join } from "node:path";
7
+ import { tmpDir } from "../tests/_tmp.mjs";
8
+ import { attemptMetrics, attemptsReport, formatAttemptLines } from "./attempts.mjs";
9
+
10
+ describe("attempts per merged issue (#5986)", () => {
11
+ it("counts failed ledger lanes plus the merging lane, and the recorded comment count", () => {
12
+ const m = attemptMetrics([{ issue: 1, outcome: "merged" }, { issue: 2, outcome: "merged" }, { issue: 3, outcome: "needs-human" }], { 2: { attempts: 3, comments: 9 }, 3: { attempts: 4 } });
13
+ assert.equal(m.merged, 2);
14
+ assert.deepEqual(m.detail, [{ issue: 1, attempts: 1, comments: null }, { issue: 2, attempts: 4, comments: 9 }]);
15
+ assert.equal(m.attempts_max, 4); assert.equal(m.attempts_mean, 2.5); assert.equal(m.comments_max, 9);
16
+ });
17
+ it("attemptsReport reads report.json and state.json; the repo filter excludes other repos", () => {
18
+ const root = tmpDir("attempts-"), dir = join(root, "b1");
19
+ mkdirSync(dir);
20
+ const now = Date.parse("2026-11-23T00:00:00Z");
21
+ writeFileSync(join(dir, "plan.json"), JSON.stringify({ created: "2026-11-22T00:00:00Z", repo: "o/r" }));
22
+ writeFileSync(join(dir, "report.json"), JSON.stringify({ rows: [{ issue: 5, outcome: "merged" }] }));
23
+ writeFileSync(join(dir, "state.json"), JSON.stringify({ attempts: { 5: { attempts: 2, comments: 7 } } }));
24
+ const w = attemptsReport({ batchRoot: root, repo: "o/r", windows: [7 * 86400000], now });
25
+ assert.equal(w["7d"].merged, 1); assert.equal(w["7d"].attempts_max, 3); assert.equal(w["7d"].comments_max, 7);
26
+ assert.equal(attemptsReport({ batchRoot: root, repo: "x/y", windows: [86400000], now })["1d"].merged, 0);
27
+ assert.match(formatAttemptLines(w).join("\n"), /attempts per merged issue: mean 3, p50 3, max 3[\s\S]*comments per issue: p50 7, max 7/);
28
+ assert.match(formatAttemptLines(attemptsReport({ batchRoot: root, repo: "x/y", windows: [86400000], now })).join("\n"), /n\/a/);
29
+ });
30
+ });
@@ -0,0 +1,49 @@
1
+ // SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
2
+ // SPDX-License-Identifier: AGPL-3.0-or-later
3
+ /**
4
+ * #5979: comment churn per issue. Counts the engine's own comments (a `<!-- FORGE:... -->` marker) on each issue and the
5
+ * repeated failures (the same `sig=<hash>` on more than one NEEDS_HUMAN/PARKED comment), so a noisy issue is visible. Pure,
6
+ * except `readChurn`, which is read-only and best effort.
7
+ */
8
+ const FORGE_RE = /<!--\s*FORGE:[A-Z_:-]+/;
9
+ const FAIL_RE = /<!--\s*FORGE:(?:NEEDS_HUMAN|PARKED)(?![A-Za-z0-9_])/;
10
+ const SIG_RE = /\bsig=([0-9a-f]{12})\b/;
11
+
12
+ const median = (xs) => { const s = [...xs].sort((a, b) => a - b); return s.length ? (s.length % 2 ? s[(s.length - 1) / 2] : (s[s.length / 2 - 1] + s[s.length / 2]) / 2) : 0; };
13
+
14
+ /** @param {{issue:number, comments:{body:string}[]}[]} issues @returns {{perIssue:{issue:number, comments:number, repeats:number}[], max:number, median:number, repeated:number}} */
15
+ export function churnStats(issues) {
16
+ const perIssue = [];
17
+ for (const it of Array.isArray(issues) ? issues : []) {
18
+ const sigs = new Map();
19
+ let comments = 0;
20
+ for (const c of Array.isArray(it?.comments) ? it.comments : []) {
21
+ const body = String(c?.body ?? "");
22
+ if (!FORGE_RE.test(body)) continue;
23
+ comments++;
24
+ const sig = FAIL_RE.test(body) ? SIG_RE.exec(body)?.[1] : null;
25
+ if (sig) sigs.set(sig, (sigs.get(sig) ?? 0) + 1);
26
+ }
27
+ perIssue.push({ issue: it?.issue, comments, repeats: [...sigs.values()].filter((n) => n > 1).length });
28
+ }
29
+ const counts = perIssue.map((p) => p.comments);
30
+ return { perIssue, max: Math.max(0, ...counts), median: median(counts), repeated: perIssue.reduce((a, p) => a + p.repeats, 0) };
31
+ }
32
+
33
+ /** Report lines; none when there is nothing to count. */
34
+ export function formatChurnLines(stats) {
35
+ if (!stats?.perIssue?.length) return [];
36
+ const top = [...stats.perIssue].sort((a, b) => b.comments - a.comments).slice(0, 3).filter((p) => p.comments > 0);
37
+ return [`comments per issue: max ${stats.max}, median ${stats.median}${top.length ? ` (${top.map((p) => `#${p.issue}: ${p.comments}`).join(", ")})` : ""}; repeated failures: ${stats.repeated}`];
38
+ }
39
+
40
+ /** Read the comments of `issues` through `gh` and return the report lines; never throws. */
41
+ export async function readChurn({ gh, repo, issues }) {
42
+ try {
43
+ const out = [];
44
+ for (const n of (issues ?? []).slice(0, 50)) {
45
+ try { out.push({ issue: n, comments: JSON.parse(String(await gh(["issue", "view", String(n), "-R", repo, "--json", "comments"])))?.comments ?? [] }); } catch { /* skip an unreadable issue */ }
46
+ }
47
+ return formatChurnLines(churnStats(out));
48
+ } catch { return []; }
49
+ }
@@ -0,0 +1,31 @@
1
+ // SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
2
+ // SPDX-License-Identifier: AGPL-3.0-or-later
3
+ import { describe, it } from "node:test";
4
+ import assert from "node:assert/strict";
5
+ import { churnStats, formatChurnLines, readChurn } from "./churn.mjs";
6
+
7
+ const c = (marker, extra = "") => ({ body: `<!-- FORGE:${marker} -->\n${extra}` });
8
+ describe("comment churn (#5979)", () => {
9
+ const issues = [
10
+ { issue: 1, comments: [c("NEEDS_HUMAN", "sig=aaaaaaaaaaaa"), c("PARKED", "sig=aaaaaaaaaaaa"), c("DEPENDENCY"), { body: "a person wrote this" }] },
11
+ { issue: 2, comments: [c("STATUS")] },
12
+ ];
13
+ it("counts FORGE comments per issue and repeated failures", () => {
14
+ const s = churnStats(issues);
15
+ assert.deepEqual(s.perIssue, [{ issue: 1, comments: 3, repeats: 1 }, { issue: 2, comments: 1, repeats: 0 }]);
16
+ assert.equal(s.max, 3);
17
+ assert.equal(s.median, 2);
18
+ assert.equal(s.repeated, 1);
19
+ });
20
+ it("different signatures are not a repeat", () => {
21
+ assert.equal(churnStats([{ issue: 3, comments: [c("NEEDS_HUMAN", "sig=aaaaaaaaaaaa"), c("NEEDS_HUMAN", "sig=bbbbbbbbbbbb")] }]).repeated, 0);
22
+ });
23
+ it("formats lines, and none for no issues", () => {
24
+ assert.match(formatChurnLines(churnStats(issues))[0], /comments per issue: max 3, median 2 \(#1: 3, #2: 1\); repeated failures: 1/);
25
+ assert.deepEqual(formatChurnLines(churnStats([])), []);
26
+ });
27
+ it("readChurn never throws", async () => {
28
+ assert.deepEqual(await readChurn({ gh: async () => { throw new Error("x"); }, repo: "o/r", issues: [1] }), []);
29
+ assert.deepEqual(await readChurn({ gh: null, repo: "o/r", issues: null }), []);
30
+ });
31
+ });
@@ -23,6 +23,7 @@ import { readExperiment } from "../experiment.mjs";
23
23
  import { compoundingReport, gatherCompounding, renderCompounding, DEFAULT_BUCKETS, DEFAULT_WINDOW_MS } from "./compounding.mjs";
24
24
  import { poolUtilisation, formatPoolLines } from "./pool.mjs";
25
25
  import { chainsReport, formatChainLines } from "./chains.mjs";
26
+ import { attemptsReport, formatAttemptLines } from "./attempts.mjs";
26
27
  import { ciAwarenessReport, readCiLogs, renderCiAwareness } from "./ci-awareness.mjs";
27
28
  import { gatherIssues, selfFiledReport, renderSelfFiled } from "./selffiled.mjs";
28
29
  import { firstReviewReport, renderFirstReview } from "./first-review.mjs";
@@ -43,6 +44,7 @@ export const HELP = `Usage: forgedock stats [--since <version|date>] [--repo <ow
43
44
  forgedock stats --by version [--post-metrics <pr>] [--min-n N] [--repo <owner/repo>] [--json]
44
45
  forgedock stats --pool [--window 7d,30d] [--repo <owner/repo>] [--json]
45
46
  forgedock stats --chains [--window 7d,30d] [--repo <owner/repo>] [--json]
47
+ forgedock stats --attempts [--window 7d,30d] [--repo <owner/repo>] [--json]
46
48
  forgedock stats --ci-awareness [--repo <owner/repo>] [--since <date>] [--json]
47
49
  forgedock stats --first-review [--repo <owner/repo>] [--since <date>] [--min-n 20] [--json]
48
50
  forgedock stats --first-merge [--repo <owner/repo>[,<owner/repo>...]] [--json]
@@ -105,6 +107,7 @@ Pool (forge#4549; local batch reports, no gh):
105
107
  --ci-awareness median/p90 CI awareness latency, CI rounds per PR and wall per round, per engine version, from local run logs (#5692);
106
108
  --since <date> keeps only the lanes started on/after that date
107
109
  --pool remote lane minutes, lanes and share per pool agent over --window (default 7d,30d)
110
+ --attempts lanes per merged issue (failed lanes in the attempts ledger + the merging one) and engine comments per issue, from local batch files (#5986)
108
111
  --chains stacked-lane chains from local batch reports: wall time p50 by depth, per-link overlap, cascade rework rate (#5834)
109
112
 
110
113
  Efficiency (forge#4402; local batch dirs and run logs, gh only for merged issues' bodies, labels and probes):
@@ -174,7 +177,7 @@ Lane profile baseline (forge#4436; local run logs only, every run of each issue,
174
177
  export function experimentExit(opts, report) { return opts.requireMet && report.targets_met !== true ? 1 : 0; }
175
178
 
176
179
  export function parseArgs(argv) {
177
- const o = { card: false, week: false, month: false, includeRepoNames: false, publicRepo: false, out: null, depth: false, conformanceOutcomes: false, windowDays: null, since: null, repo: null, edge: null, milestone: null, contextAb: false, exploreAb: false, tiers: false, compounding: false, selfFiled: false, origin: false, firstMerge: false, bucket: null, laneProfile: false, issues: null, efficiency: false, pool: false, chains: false, ciAwareness: false, batch: null, windows: null, compare: null, by: null, experiment: null, emitEvent: false, requireMet: false, postMetrics: null, offline: false, json: false, refresh: false, compact: false, local: true, cache: true, minN: DEFAULT_MIN_N, releaseTimes: null, help: false };
180
+ const o = { card: false, week: false, month: false, includeRepoNames: false, publicRepo: false, out: null, depth: false, conformanceOutcomes: false, windowDays: null, since: null, repo: null, edge: null, milestone: null, contextAb: false, exploreAb: false, tiers: false, compounding: false, selfFiled: false, origin: false, firstMerge: false, bucket: null, laneProfile: false, issues: null, efficiency: false, pool: false, chains: false, attempts: false, ciAwareness: false, batch: null, windows: null, compare: null, by: null, experiment: null, emitEvent: false, requireMet: false, postMetrics: null, offline: false, json: false, refresh: false, compact: false, local: true, cache: true, minN: DEFAULT_MIN_N, releaseTimes: null, help: false };
178
181
  const val = (i, name) => {
179
182
  const v = argv[i + 1];
180
183
  if (v == null || v.startsWith("--")) throw new Error(`${name} needs a value`);
@@ -210,6 +213,7 @@ export function parseArgs(argv) {
210
213
  else if (name === "--depth") o.depth = true;
211
214
  else if (name === "--pool") o.pool = true;
212
215
  else if (name === "--chains") o.chains = true;
216
+ else if (name === "--attempts") o.attempts = true;
213
217
  else if (name === "--release-ledger") o.releaseLedger = true;
214
218
  else if (name === "--baseline") { const v = take(); if (v !== "save" && v !== "compare") throw new Error("--baseline must be save or compare"); o.baseline = v; }
215
219
  else if (name === "--baseline-file") o.baselineFile = take();
@@ -246,10 +250,10 @@ export function parseArgs(argv) {
246
250
  }
247
251
  if ((o.week || o.month || o.includeRepoNames || o.publicRepo || o.out) && !o.card) throw new Error("--week, --month, --include-repo-names, --public-repo and --out need --card");
248
252
  if (o.week && o.month) throw new Error("--week and --month are mutually exclusive");
249
- if (o.card && (o.depth || o.pool || o.chains || o.ciAwareness || o.efficiency || o.compounding || o.selfFiled || o.conformanceOutcomes || o.contextAb || o.exploreAb || o.tiers || o.laneProfile || o.edge || o.milestone || o.experiment || o.by)) throw new Error("--card cannot be combined with another query mode");
253
+ if (o.card && (o.depth || o.pool || o.chains || o.attempts || o.ciAwareness || o.efficiency || o.compounding || o.selfFiled || o.conformanceOutcomes || o.contextAb || o.exploreAb || o.tiers || o.laneProfile || o.edge || o.milestone || o.experiment || o.by)) throw new Error("--card cannot be combined with another query mode");
250
254
  if (o.card && (o.week || o.month) && o.since) throw new Error("--week/--month and --since are mutually exclusive");
251
255
  if (o.batch && !o.efficiency) throw new Error("--batch and --window need --efficiency");
252
- if (o.windows && !o.efficiency && !o.pool && !o.chains && !o.compounding) throw new Error("--batch and --window need --efficiency");
256
+ if (o.windows && !o.efficiency && !o.pool && !o.chains && !o.attempts && !o.compounding) throw new Error("--batch and --window need --efficiency");
253
257
  if (o.bucket && !o.compounding) throw new Error("--bucket needs --compounding");
254
258
  if (o.compare && !o.efficiency) throw new Error("--compare and --offline need --efficiency");
255
259
  if (o.offline && !o.efficiency && !o.depth) throw new Error("--compare and --offline need --efficiency (--offline also works with --depth)");
@@ -429,6 +433,9 @@ export async function buildReport(opts, deps = {}) {
429
433
  const pool = poolUtilisation({ batchRoot: deps.batchRoot ?? batchRoot(env), repo, windows: opts.windows ?? parseWindows("7d,30d"), now: deps.now?.() ?? Date.now() });
430
434
  return { repo, query: { pool } };
431
435
  }
436
+ if (opts.attempts) { // #5986: local batch files only
437
+ return { repo, query: { attempts: attemptsReport({ batchRoot: deps.batchRoot ?? batchRoot(env), repo, windows: opts.windows ?? parseWindows("7d,30d"), now: deps.now?.() ?? Date.now() }) } };
438
+ }
432
439
  if (opts.chains) { // #5834: local batch reports only
433
440
  return { repo, query: { chains: chainsReport({ batchRoot: deps.batchRoot ?? batchRoot(env), repo, windows: opts.windows ?? parseWindows("7d,30d"), now: deps.now?.() ?? Date.now() }) } };
434
441
  }
@@ -583,6 +590,7 @@ export async function runStats(argv, deps = {}) {
583
590
  if (report.query?.self_filed && !opts.json) { process.stdout.write(`${renderSelfFiled(report.query.self_filed)}\n`); return 0; }
584
591
  if (report.query?.depth && !opts.json) { process.stdout.write(`${renderDepth(report.query.depth, { repo: report.repo, since: opts.since })}\n`); return 0; }
585
592
  if (report.query?.ci_awareness && !opts.json) { process.stdout.write(`${renderCiAwareness(report.query.ci_awareness)}\n`); return 0; }
593
+ if (report.query?.attempts && !opts.json) { process.stdout.write(`${formatAttemptLines(report.query.attempts).join("\n")}\n`); return 0; }
586
594
  if (report.query?.chains && !opts.json) { process.stdout.write(`${formatChainLines(report.query.chains).join("\n")}\n`); return 0; }
587
595
  if (report.query?.pool && !opts.json) { process.stdout.write(`${formatPoolLines(report.query.pool).join("\n")}\n`); return 0; }
588
596
  if (report.query?.efficiency && !opts.json) {
@@ -58,12 +58,10 @@ Do this yourself. Spawn no sub-agents here.
58
58
  `K` = `--parallel` if given, otherwise `orchestration.max_concurrent` from the repo's `forge.yaml`
59
59
  (`yq '.orchestration.max_concurrent' forge.yaml`), otherwise 3.
60
60
 
61
- **Lanes (base branches).** Each issue has its own lane, and ForgeDock works it out: an issue with a milestone
62
- goes to forge.yaml `branches.feature_pattern` (`milestone/<slug>`, which must exist on origin), any other issue
63
- to `branches.staging`. The default (production) branch is never a lane. Do not pass `--lane`; a `--lane` that
64
- differs from the issue's lane is refused (`lane-refused`, `lane.mismatch`). A dependency edge between two lanes
65
- (for example a milestone issue waiting on a staging-lane fix) never gets that fix on its base: list it in the
66
- plan and either re-milestone the dependency or wait for a milestone sync. Never mix lanes silently.
61
+ **Lanes (base branches).** ForgeDock picks each issue's lane: a milestone issue goes to forge.yaml
62
+ `branches.feature_pattern` (`milestone/<slug>`, must exist on origin), any other to `branches.staging`, never the
63
+ default branch. Do not pass `--lane` (a mismatch is refused: `lane-refused`, `lane.mismatch`). A cross-lane dependency
64
+ never gets the fix on its base: list it, then re-milestone the dependency or wait for a milestone sync.
67
65
 
68
66
  ## 3. Launch lanes
69
67
 
@@ -119,14 +117,11 @@ remaining maintenance once no feature is pending; otherwise the rest ends `held
119
117
  When a lane finishes (agent lanes; the batch runner applies the same rules itself):
120
118
  - `deferred` (lease held by another or a dead session): put it back in the queue and retry after the
121
119
  lease time printed in its output.
122
- - `deferred` with "host busy" (code `host.busy`: the host is short of memory, tmp space or CPU headroom;
123
- no lease was taken and nothing was posted): put the issue back in the queue and lower the effective K by
124
- 1 for the next 5 minutes, never below 1. Before raising K back, start one lane and check that it is not
125
- host busy again.
126
- - `deferred` with `rate_limited` (usage limit; the last output line carries the reset time): stop launching
127
- new lanes until that reset time, let running lanes finish, then resume the queue.
128
- - `dependency-open`: the engine or the builder found a dependency you missed (its output names it). This is a
129
- scheduling fact, not a failure: add the edge and requeue the issue behind it. Do not skip its dependents.
120
+ - `deferred` `host.busy` (host short of memory, tmp or CPU; nothing taken or posted): requeue it and lower K by 1
121
+ for 5 minutes (never below 1); before raising K, check one lane is not host busy again.
122
+ - `deferred` `rate_limited`: launch nothing until the reset time on its last line; running lanes finish.
123
+ - `dependency-open`: the engine or the builder found a dependency you missed (its output names it). A
124
+ scheduling fact, not a failure: add the edge and requeue the issue behind it. Keep its dependents.
130
125
  If the dependency is outside the set and agents can resolve it, add it to the batch and launch it.
131
126
  - `lane-refused` (codes `lane.mismatch`, `lane.default_branch`, `lane.branch_missing`, `lane.unresolved`): nothing
132
127
  ran (no lease, comment or worktree). Report the code and its detail (for example a missing `milestone/<slug>`
@@ -191,10 +186,7 @@ other lane running meanwhile.
191
186
 
192
187
  ## 3b. Settle scope (#4665)
193
188
 
194
- When settle begins, freeze the milestone's issue set (`scripts/settle-scope.mjs` `freezeScope`). Issues filed later are
195
- classified by `classifyNew`: decomposition children of a frozen issue stay in the milestone and join the measured set;
196
- deferred follow-ups go to the next milestone or the backlog; review findings and others count as growth only.
197
- `convergence` measures the frozen set plus those children; a STOP prints `formatStopReport` (growth and sources).
189
+ At settle, freeze the milestone's issue set and classify later issues with `scripts/settle-scope.mjs` (its header documents the rules).
198
190
 
199
191
  ## 4. Report
200
192
 
@@ -207,3 +199,14 @@ show `invalid (pre-filter)`). Then print:
207
199
  5. one escalation list: the human-code `needs-human` issues only, asked once.
208
200
 
209
201
  Nothing else.
202
+
203
+ ## Standing orders (`--select`)
204
+
205
+ `forgedock orchestrate --select '<query>'` (a GitHub issue search: `no:milestone`, `milestone:X`, `label:Y`) stores the selector in the batch and keeps owning it; no watcher process is needed (the schedd-hosted runner reconciles every few minutes):
206
+
207
+ - matching open issues join under the same DAG, priority and lane rules as `--add`; closed or moved ones leave.
208
+ - an issue stays scheduled until it is closed, merged, or blocked by a human code (credentials, spend, customer, promotion, product decision). Re-admission needs no operator command: `deferred` retries with exponential backoff (cap 2 h); `held` / `engine-error` re-admit on an agent or lane-image version change or after a 6 h cooldown; a conformance failure gets one more attempt after the base moves, then is listed in a single "needs decision" digest; the engine's `env.*` issue joins the order and its closure re-admits the waiters.
209
+ - the breaker resets itself after a cooldown when the failures were environmental (VM restart, mirror, network) and the pool is healthy, with a FORGE:DECISION.
210
+ - a merge into a staging lane branch closes the issue (and notes it on the post-deploy rollup when `FORGE_POSTDEPLOY_ROLLUP=<issue>` is set).
211
+
212
+ `forgedock orchestrate --status <id>` shows the coverage: matching open = running + queued + backing-off + waiting on deps + human-blocked (listed) + unscheduled. `unscheduled: 0` is the healthy state.
package/docs/CONFIG.md CHANGED
@@ -2950,6 +2950,7 @@ Keys of the pool agent's JSON config (`forgedock pool agent`), not of `forge.yam
2950
2950
  |---|---|---|---|
2951
2951
  | `cache_max_age_days` | number | `14` | uv/npm/pip/poetry cache files, depcache and env snapshot entries older than this are deleted by the agent sweep, with no launch needed. The pnpm store is pruned and the git mirror gets `git gc --auto`. |
2952
2952
  | `cache_max_gb` | number | unset (no cap) | Per-volume cap. A volume over it is shrunk oldest-first below the cap; work dirs of live sandboxes are never touched. |
2953
+ | `depcache_max_gb` | number | `40` | Per-repo cap on `forge-depcache/<repo>/` (#5901). Over it, the least recently used snapshots (by their `last-used` stamp) are deleted, never one held by a lane lock. `/capacity` `cache_volumes.<volume>.depcache_gb` and `forgedock pool status` show each repo's depcache size. Snapshots are also aged out per snapshot by `cache_max_age_days`. |
2953
2954
  | `cache_idle_days` | number | `30` | A volume with no launch for this long and no referencing sandbox is removed. Evicted only when its last use is known (`/cache/.last-used`, written by the lane entrypoint). |
2954
2955
  | `cache_never_evict` | list of volume names | `[]` | Volumes (e.g. `cs-cache-marcode`) that are never swept or evicted. |
2955
2956
  | `cache_sweep_interval_s` | number | `3600` | Gap between cache sweeps. |
@@ -96,6 +96,7 @@ An absent or unknown code is recorded as `unclassified`, with the raw reason kep
96
96
  | `conformance.omission` | Core work-on: an issue requirement is missing from or narrowed by the frozen contract, after one builder resume | lean | Review `issue_coverage` row not `covered` |
97
97
  | `conformance.unimplemented` | Core work-on: a contracted requirement is partial, missing or unvalidated, or a validate command failed, after one builder resume (a validate the host cannot run for a missing tool or module is `env.tool_missing`, and a repro test the harness cannot run on head is `env.repro_unrunnable`, instead) | lean | Precheck (result.json, validation) or review requirement row |
98
98
  | `conformance.scope_creep` | Core work-on: a changed file is not authorized by a deliverable or typed amendment, after one builder resume | lean | Precheck changed files or review `scope` row `none` |
99
+ | `failure.repeated` | Core work-on: the same failure (code and normalised detail) ended a second lane of the issue; parked with one summary comment, never recovered (#5979) | lean | Second NEEDS_HUMAN/PARKED comment carrying the same `sig=` |
99
100
  | `conformance.untracked_deferral` | Core work-on: a requirement was deferred without a typed amendment or a tracking issue, after one builder resume | lean | Precheck or review requirement row `deferred` on a `deliver` requirement |
100
101
  | `conformance.e2e_unverified` | Core work-on: a `[type:e2e]` requirement is implemented but its validate is not a real end-to-end check (the repo's e2e set, Playwright, live stack), after one builder resume | lean | Review requirement row `implemented` with a unit-test `validated_by` (`bin/lean/conformance.mjs` `e2eVerified`) |
101
102
  | `conformance.unjustified_deferral` | Core work-on: the reviewer judged a deferred or post-deploy requirement unjustified (it belongs in this change), after one builder resume; nothing is filed or merged | lean | Review requirement row `deferral_ok: false` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "forgedock",
3
- "version": "1.65.0",
3
+ "version": "1.67.0",
4
4
  "description": "An AI engineering team that ships to production",
5
5
  "bin": {
6
6
  "forgedock": "bin/forgedock.mjs"
@@ -17,7 +17,8 @@ date +%s > /cache/.last-used 2>/dev/null || true # #5757: the agent evicts cache
17
17
  exec > >(tee -a /csout/lane.log) 2>&1
18
18
 
19
19
  export HOME=/root
20
- export UV_CACHE_DIR=/cache/uv npm_config_cache=/cache/npm POETRY_CACHE_DIR=/cache/poetry PIP_CACHE_DIR=/cache/pip
20
+ # #5969: same layout as depcache.mjs env(); the legacy /cache/{uv,npm,pip,poetry} stay swept for old volumes.
21
+ export UV_CACHE_DIR=/cache/forge-depcache/stores/uv-cache npm_config_cache=/cache/forge-depcache/stores/npm-cache POETRY_CACHE_DIR=/cache/forge-depcache/stores/poetry-cache PIP_CACHE_DIR=/cache/forge-depcache/stores/pip-cache
21
22
  export TMPDIR=/tmp
22
23
  # ForgeDock's dependency cache (its pnpm store and snapshots) and pnpm's own store live in the persistent per-repo
23
24
  # cache volume, so a lane installs from a warm store instead of downloading every package (a cold monorepo install
@@ -118,8 +118,8 @@ echo "ERROR: behaviour changed under bin/lean/ or scripts/ without a docs update
118
118
  printf '%s' "$MISSING" | sed 's/^/ - /'
119
119
  echo ""
120
120
  echo "Fix with one of:"
121
+ echo " - add devdocs/decisions/<issue>-<slug>.md (preferred: a new file never conflicts with parallel PRs)"
121
122
  echo " - edit the matching dossier (devdocs/index.yaml modules: glob -> devdocs/modules/*.md)"
122
123
  echo " - update NORTHSTAR.md § Runtime map"
123
- echo " - add devdocs/decisions/<issue>-<slug>.md"
124
124
  echo " - or add a line 'docs-not-needed: <reason>' to the PR body"
125
125
  exit 1