forgedock 1.43.1 → 1.44.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 (47) hide show
  1. package/bin/engine/outcome-codes.mjs +2 -2
  2. package/bin/engine/telemetry-seam.mjs +1 -1
  3. package/bin/engine-cli.mjs +44 -8
  4. package/bin/forgedock.mjs +50 -24
  5. package/bin/gc.mjs +3 -1
  6. package/bin/hooks/pre-tool-use.mjs +54 -3
  7. package/bin/lean/autochildren.mjs +13 -5
  8. package/bin/lean/autochildren.test.mjs +36 -18
  9. package/bin/lean/batch.test.mjs +46 -0
  10. package/bin/lean/conformance.mjs +55 -14
  11. package/bin/lean/conformance.test.mjs +69 -10
  12. package/bin/lean/decision-engine.mjs +1 -1
  13. package/bin/lean/decision-engine.test.mjs +11 -0
  14. package/bin/lean/gatewatch.test.mjs +5 -5
  15. package/bin/lean/lane.mjs +22 -4
  16. package/bin/lean/lane.test.mjs +33 -1
  17. package/bin/lean/lean.mjs +22 -6
  18. package/bin/lean/lean.test.mjs +31 -0
  19. package/bin/lean/orchestrate-blocked.test.mjs +12 -0
  20. package/bin/lean/orchestrate-children.test.mjs +16 -4
  21. package/bin/lean/orchestrate.mjs +58 -11
  22. package/bin/lean/pmap.mjs +17 -0
  23. package/bin/lean/pmap.test.mjs +27 -0
  24. package/bin/lean/prodwatch-triage.mjs +6 -0
  25. package/bin/lean/prodwatch-triage.test.mjs +14 -1
  26. package/bin/lean/prodwatch.mjs +1 -3
  27. package/bin/lean/recovery.test.mjs +21 -4
  28. package/bin/lean/retry.mjs +11 -0
  29. package/bin/lean/retry.test.mjs +16 -0
  30. package/bin/lean/sched.mjs +25 -2
  31. package/bin/lean/sched.test.mjs +58 -1
  32. package/bin/lean/selftest-live.mjs +56 -31
  33. package/bin/lean/selftest-live.test.mjs +48 -6
  34. package/bin/lean/selftest-nightly.mjs +7 -3
  35. package/bin/lean/selftest-nightly.test.mjs +24 -2
  36. package/bin/lean/selftest-static.mjs +18 -11
  37. package/bin/lean/selftest-static.test.mjs +8 -0
  38. package/bin/lean/signoff.mjs +5 -3
  39. package/bin/lean/signoff.test.mjs +21 -0
  40. package/bin/pool/cli.mjs +29 -1
  41. package/commands/orchestrate.md +5 -2
  42. package/docs/CONFIG.md +9 -4
  43. package/docs/DECISIONS.md +5 -1
  44. package/docs/OUTCOME-CODES.md +2 -2
  45. package/docs/TELEMETRY.md +1 -1
  46. package/package.json +1 -1
  47. package/scripts/plan-validate-live.mjs +15 -8
@@ -10,10 +10,14 @@ import { fileURLToPath } from "node:url";
10
10
  import { spawn, spawnSync } from "node:child_process";
11
11
  import { batchRoot, listBatches, openBatch } from "./batch.mjs";
12
12
  import { staticCheck, formatStatic, realGh } from "./selftest-static.mjs";
13
+ import { pollUntil } from "./retry.mjs";
13
14
  import { postMarker } from "./selftest-gate.mjs";
14
15
  import { reportNightly } from "./selftest-nightly.mjs";
15
16
  import { parseForgeYaml } from "../forge-utils.mjs";
16
17
 
18
+ const BATCH_WAIT_TRIES = 60, BATCH_WAIT_MS = 1000;
19
+ const DEFAULT_TIMEOUT_MS = 45 * 60 * 1000, DEFAULT_POLL_MS = 5000, GH_MAX_BUFFER = 64 * 1024 * 1024;
20
+
17
21
  export class StepError extends Error {
18
22
  constructor(step, message) { super(message); this.step = step; }
19
23
  }
@@ -33,20 +37,31 @@ export const FIXTURES = {
33
37
  },
34
38
  };
35
39
 
40
+ /**
41
+ * The fixture with every path and title made unique to this run (#4952): a merged run leaves its files on the sandbox
42
+ * default branch, and the next run's "the test fails on the current code" premise must still hold.
43
+ */
44
+ export function uniqueFixture(fx, lang, runId) {
45
+ const re = lang === "python" ? /`((?:test_)?[ab]\.py)`/g : /`src\/([ab](?:\.test)?\.js)`/g;
46
+ const dir = (m, f) => (lang === "python" ? `\`${runId}/${f}\`` : `\`src/${runId}/${f}\``);
47
+ const one = (i) => ({ title: `${i.title} (${runId})`, body: i.body.replace(re, dir) });
48
+ return { files: fx.files, a: one(fx.a), b: one(fx.b) };
49
+ }
50
+
51
+ /** Whether a batch plan is the one this harness started: the sandbox repo and every issue it passed (#4952). */
52
+ export const isOwnBatch = (plan, repo, issues) =>
53
+ String(plan?.repo ?? "").toLowerCase() === repo.toLowerCase() && issues.every((n) => (plan?.argv ?? []).map(String).includes(String(n)));
54
+
36
55
  /** The issue body with its FORGE:STATE annotation removed. */
37
56
  export const stripState = (body) => String(body ?? "").replace(/<!--\s*FORGE:STATE[\s\S]*?-->/g, "").trim();
38
57
 
39
58
  const num = (out) => { const m = /\/issues\/(\d+)/.exec(String(out)) ?? /^(\d+)$/m.exec(String(out)); if (!m) throw new Error(`no issue number in: ${String(out).slice(0, 120)}`); return Number(m[1]); };
40
59
 
41
60
  async function waitFor(ctx, step, what, cond, onTick) {
42
- const { io, timeoutMs } = ctx, t0 = io.now();
43
- for (;;) {
44
- if (onTick) await onTick();
45
- const v = await cond();
46
- if (v) return v;
47
- if (io.now() - t0 > timeoutMs) fail(step, `timed out waiting for ${what}`);
48
- await io.sleep(ctx.pollMs);
49
- }
61
+ const { io, timeoutMs, pollMs } = ctx;
62
+ const v = await pollUntil(async () => { if (onTick) await onTick(); return cond(); }, { timeoutMs, pollMs, sleep: io.sleep, now: io.now });
63
+ if (!v) fail(step, `timed out waiting for ${what}`);
64
+ return v;
50
65
  }
51
66
 
52
67
  /** Step "body": every issue body still holds its creation text (#4860). */
@@ -59,16 +74,16 @@ async function checkBodies(ctx, step = "body") {
59
74
 
60
75
  export const STEPS = [
61
76
  { name: "create", run: async (ctx) => {
62
- const { io, repo, fx } = ctx;
77
+ const { io, repo } = ctx, fx = ctx.fx = uniqueFixture(ctx.fx, ctx.lang, ctx.runId);
63
78
  for (const [path, content] of Object.entries(fx.files)) {
64
79
  await io.gh(["api", "-X", "PUT", `repos/${repo}/contents/${path}`, "-f", `message=selftest fixture ${path}`, "-f", `content=${Buffer.from(content).toString("base64")}`]).catch(() => { /* already present */ });
65
80
  }
66
- const mk = async (t, body) => num(await io.gh(["issue", "create", "-R", repo, "--title", t, "--body", body]));
81
+ // Tracked the moment it exists: if B's create fails, A is still cleaned up.
82
+ const mk = async (t, body) => { const n = num(await io.gh(["issue", "create", "-R", repo, "--title", t, "--body", body])); ctx.created.push(n); return n; };
67
83
  const a = await mk(fx.a.title, fx.a.body);
68
84
  const b = await mk(fx.b.title, `${fx.b.body}\n\n**Depends on**: #${a}`);
69
85
  ctx.issues = { A: a, B: b };
70
86
  ctx.bodies = { [a]: fx.a.body, [b]: fx.b.body };
71
- ctx.created.push(a, b);
72
87
  } },
73
88
  { name: "add", run: async (ctx) => {
74
89
  const { io, repo, issues } = ctx;
@@ -84,12 +99,13 @@ export const STEPS = [
84
99
  const { io, issues } = ctx;
85
100
  const pid = async () => (await io.orchestrate.state(ctx.run.id))?.running?.[issues.A]?.pid ?? null;
86
101
  const before = await waitFor(ctx, "resume", `a live lane for #${issues.A}`, pid);
102
+ // The batch runs inside schedd: killing the client stops nothing, so the batch itself is cancelled (#4952).
87
103
  await ctx.run.kill();
104
+ await io.orchestrate.stop(ctx.run.id);
105
+ await waitFor(ctx, "resume", `the lane of #${issues.A} (pid ${before}) to stop after the cancel`, async () => ((await pid()) ? null : { stopped: true }));
88
106
  ctx.run = await io.orchestrate.resume(ctx.run.id);
89
- await io.sleep(ctx.pollMs);
90
- const st = await io.orchestrate.state(ctx.run.id), after = st?.running?.[issues.A]?.pid ?? null;
91
- const done = st?.results?.[issues.A];
92
- if (!done && after !== before) fail("resume", `#${issues.A} was launched again after --resume (pid ${before} -> ${after}), not re-adopted`);
107
+ const st = await waitFor(ctx, "resume", `the batch to pick #${issues.A} up again after --resume`, async () => { const s = await io.orchestrate.state(ctx.run.id); return s?.results?.[issues.A] || s?.running?.[issues.A]?.pid ? s : null; });
108
+ if (!st.results?.[issues.A] && st.running?.[issues.A]?.pid === before) fail("resume", `#${issues.A} still has its pre-cancel lane (pid ${before}) after --resume: the batch was never stopped`);
93
109
  await checkBodies(ctx, "body");
94
110
  } },
95
111
  { name: "merge", run: async (ctx) => {
@@ -127,26 +143,31 @@ export const STEPS = [
127
143
  * Run the steps in order; the first failure stops them, cleanup always runs.
128
144
  * @returns {{ok:boolean, step:string|null, message:string|null, notes:string[], cleanupErrors:string[]}}
129
145
  */
130
- export async function runSelftestLive({ repo, lang = "node", io, timeoutMs = 45 * 60 * 1000, pollMs = 5000 }) {
146
+ export async function runSelftestLive({ repo, lang = "node", io, timeoutMs = DEFAULT_TIMEOUT_MS, pollMs = DEFAULT_POLL_MS }) {
131
147
  const fx = FIXTURES[lang];
132
148
  if (!fx) return { ok: false, step: "setup", message: `unknown fixture language ${lang} (node|python)`, notes: [], cleanupErrors: [] };
133
- const ctx = { io, repo, fx, timeoutMs, pollMs, issues: {}, bodies: {}, created: [], notes: [], run: null };
149
+ const ctx = { io, repo, fx, lang, runId: `r${io.now?.().toString(36) ?? "0"}`, timeoutMs, pollMs, issues: {}, bodies: {}, created: [], notes: [], run: null };
134
150
  let out = { ok: true, step: null, message: null };
135
151
  for (const s of STEPS) {
136
152
  try { await s.run(ctx); } catch (e) { out = { ok: false, step: e.step ?? s.name, message: String(e.message ?? e) }; break; }
137
153
  }
138
154
  const cleanupErrors = [];
139
155
  const tryC = async (what, f) => { try { await f(); } catch (e) { cleanupErrors.push(`${what}: ${String(e.message ?? e).slice(0, 120)}`); } };
140
- if (ctx.run) await tryC("stop orchestrate", () => ctx.run.kill());
156
+ if (ctx.run) {
157
+ await tryC("kill orchestrate client", () => ctx.run.kill());
158
+ await tryC("stop batch", () => io.orchestrate.stop(ctx.run.id));
159
+ }
141
160
  for (const n of ctx.created) {
142
161
  await tryC(`close #${n}`, () => io.gh(["issue", "close", String(n), "-R", repo]));
143
- await tryC(`delete branches of #${n}`, async () => {
144
- const refs = String(await io.gh(["api", `repos/${repo}/git/matching-refs/heads/forge/issue-${n}`, "--jq", ".[].ref"])).split("\n").filter(Boolean);
145
- for (const ref of refs) await io.gh(["api", "-X", "DELETE", `repos/${repo}/git/${ref}`]);
146
- });
147
- await tryC(`close PRs of #${n}`, async () => {
148
- const prs = String(await io.gh(["pr", "list", "-R", repo, "--search", `#${n} in:title,body`, "--state", "open", "--json", "number", "--jq", ".[].number"])).split("\n").filter(Boolean);
149
- for (const p of prs) await io.gh(["pr", "close", p, "-R", repo, "--delete-branch"]);
162
+ // The prefix search over-matches (issue-5 lists issue-50): keep only this issue's own branches, then find PRs by head.
163
+ const own = new RegExp(`^refs/heads/forge/issue-${n}(?![0-9])`);
164
+ const lines = async (args) => String(await io.gh(args)).split("\n").filter(Boolean);
165
+ await tryC(`clean up branches of #${n}`, async () => {
166
+ const refs = (await lines(["api", `repos/${repo}/git/matching-refs/heads/forge/issue-${n}`, "--jq", ".[].ref"])).filter((r) => own.test(r));
167
+ for (const ref of refs) {
168
+ for (const p of await lines(["pr", "list", "-R", repo, "--head", ref.replace(/^refs\/heads\//, ""), "--state", "open", "--json", "number", "--jq", ".[].number"])) await io.gh(["pr", "close", p, "-R", repo]);
169
+ await io.gh(["api", "-X", "DELETE", `repos/${repo}/git/${ref}`]);
170
+ }
150
171
  });
151
172
  }
152
173
  return { ...out, notes: ctx.notes, cleanupErrors };
@@ -159,28 +180,32 @@ export function realIo(env = process.env, { pool = false } = {}) {
159
180
  let self;
160
181
  const root = batchRoot(env);
161
182
  const detached = (args) => { const p = spawn(process.execPath, [CLI, ...args], { detached: true, windowsHide: true, stdio: "ignore", env }); p.unref(); return { kill: async () => { try { process.kill(-p.pid, "SIGTERM"); } catch { /* gone */ } } }; };
162
- const waitBatch = async (before) => { for (let i = 0; i < 60; i++) { const id = listBatches(root).find((b) => !before.has(b)); if (id) return id; await new Promise((r) => setTimeout(r, 1000)); } throw new Error("orchestrate did not create a batch within 60s"); };
183
+ // The batch of THIS start: new on disk, for the sandbox repo, and naming the issue we passed. A concurrent real batch is never adopted (#4952).
184
+ const ownBatch = (id, repo, issues) => { try { return isOwnBatch(openBatch(root, id).readPlan(), repo, issues); } catch { return false; } };
185
+ const waitBatch = async (before, repo, issues) => { const id = await pollUntil(() => listBatches(root).find((b) => !before.has(b) && ownBatch(b, repo, issues)), { timeoutMs: BATCH_WAIT_TRIES * BATCH_WAIT_MS, pollMs: BATCH_WAIT_MS }); if (id) return id; throw new Error(`orchestrate did not create a batch for ${repo} ${issues.join(",")} within ${BATCH_WAIT_TRIES * BATCH_WAIT_MS / 1000}s`); };
163
186
  return (self = {
164
187
  now: () => Date.now(), sleep: (ms) => new Promise((r) => setTimeout(r, ms)),
165
- gh: async (args) => { const r = spawnSync("gh", args, { encoding: "utf8", maxBuffer: 64 * 1024 * 1024 }); if (r.status !== 0) throw new Error(r.stderr.trim() || `gh exited ${r.status}`); return r.stdout; },
188
+ gh: async (args) => { const r = spawnSync("gh", args, { encoding: "utf8", maxBuffer: GH_MAX_BUFFER }); if (r.status !== 0) throw new Error(r.stderr.trim() || `gh exited ${r.status}`); return r.stdout; },
166
189
  cli: async (args) => { const r = spawnSync(process.execPath, [CLI, ...args], { encoding: "utf8", env }); return { code: r.status ?? 1, stdout: r.stdout, stderr: r.stderr }; },
167
190
  cliVersion: async () => JSON.parse(readFileSync(join(dirname(CLI), "..", "package.json"), "utf8")).version,
168
191
  orchestrate: {
169
192
  start: async (repo, issues, parallel) => {
170
193
  const before = new Set(listBatches(root)), h = detached(["orchestrate", ...issues.map(String), "--parallel", String(parallel), "--repo", repo]);
171
- return { id: await waitBatch(before), kill: h.kill };
194
+ return { id: await waitBatch(before, repo, issues), kill: h.kill };
172
195
  },
196
+ // The batch lives in schedd, not in the client: `--cancel` is what stops it (its lanes tear down, the rest is held for --resume).
197
+ stop: async (id) => { const r = await self.cli(["orchestrate", "--cancel", id]); if (r.code !== 0) throw new Error(`orchestrate --cancel ${id} exited ${r.code}: ${String(r.stderr || r.stdout).slice(0, 160)}`); },
173
198
  resume: async (id) => ({ id, ...detached(["orchestrate", "--resume", id]) }),
174
199
  state: async (id) => openBatch(root, id).store.load(),
175
200
  },
176
201
  // Step 6: one lane through the pool. The issue's FORGE:STATE records the placement and the lane's FORGE:TELEMETRY rows
177
202
  // carry the engine's forge_version (the sandbox's, not the CLI's: the #4818 stale-image defect).
178
203
  remote: pool ? { run: async ({ repo, issue, timeoutMs, pollMs }) => {
179
- const run = await self.orchestrate.start(repo, [issue], 1), t0 = Date.now();
204
+ const run = await self.orchestrate.start(repo, [issue], 1);
180
205
  let row = null;
181
206
  try {
182
- while (!row && Date.now() - t0 < timeoutMs) { row = (await self.orchestrate.state(run.id))?.results?.[issue] ?? null; if (!row) await self.sleep(pollMs); }
183
- } finally { await run.kill(); }
207
+ row = await pollUntil(async () => (await self.orchestrate.state(run.id))?.results?.[issue] ?? null, { timeoutMs, pollMs, sleep: self.sleep, now: self.now });
208
+ } finally { await run.kill(); await self.orchestrate.stop(run.id).catch(() => {}); }
184
209
  if (!row) throw new Error(`#${issue} produced no result within ${Math.round(timeoutMs / 1000)}s`);
185
210
  const v = JSON.parse(await self.gh(["issue", "view", String(issue), "-R", repo, "--json", "body,comments"]));
186
211
  const text = `${v.body}\n${v.comments.map((c) => c.body).join("\n")}`;
@@ -5,11 +5,11 @@ import assert from "node:assert/strict";
5
5
  import { writeFileSync } from "node:fs";
6
6
  import { join } from "node:path";
7
7
  import { tmpDir } from "../tests/_tmp.mjs";
8
- import { runSelftestLive, stripState, selftestFromCli, STEPS } from "./selftest-live.mjs";
8
+ import { runSelftestLive, stripState, selftestFromCli, STEPS, FIXTURES, uniqueFixture, isOwnBatch } from "./selftest-live.mjs";
9
9
 
10
10
  /** A fake sandbox world. `d` toggles a defect: add4859 (--add skips), wipe4860 (body wiped), double (resume relaunches), orderBA, noRemoteAuth. */
11
11
  function world(d = {}) {
12
- const w = { issues: {}, closed: [], calls: [], killed: 0, pid: 100, results: {}, order: [], deps: {}, running: {}, clock: 0, pool: !!d.pool };
12
+ const w = { issues: {}, closed: [], calls: [], killed: 0, stops: [], pid: 100, results: {}, order: [], deps: {}, running: {}, clock: 0, pool: !!d.pool };
13
13
  const gh = async (a) => {
14
14
  w.calls.push(a.join(" "));
15
15
  if (a[0] === "api" && a[1] === "-X" && a[2] === "PUT") return "{}";
@@ -36,7 +36,9 @@ function world(d = {}) {
36
36
  },
37
37
  orchestrate: {
38
38
  start: async (repo, issues) => { w.order.push(...issues); w.running[issues[0]] = { pid: ++w.pid }; w.a = issues[0]; return { id: "b1", kill: async () => { w.killed++; } }; },
39
- resume: async (id) => { w.resumedAt = w.tick ?? 0; if (d.double) w.running[w.a] = { pid: ++w.pid }; return { id, kill: async () => { w.killed++; } }; },
39
+ // stop = `orchestrate --cancel`: the lane is torn down (d.nostop: the defect where only the client dies and the lane lives on)
40
+ stop: async (id) => { w.stops.push(id); if (!d.nostop) delete w.running[w.a]; },
41
+ resume: async (id) => { w.resumedAt = w.tick ?? 0; w.running[w.a] = { pid: d.nostop ? w.running[w.a]?.pid ?? ++w.pid : ++w.pid }; return { id, kill: async () => { w.killed++; } }; },
40
42
  state: async () => ({ order: w.order, deps: w.deps, running: w.running, results: w.results }),
41
43
  },
42
44
  remote: w.pool ? { run: async ({ issue }) => { w.remoteIssue = issue; return { where: d.local ? "local" : "remote", authenticated: !d.noRemoteAuth, engineVersion: d.oldEngine ? "1.37.0" : "1.39.0" }; } } : null,
@@ -73,9 +75,14 @@ describe("selftest --live steps (#4865)", () => {
73
75
  const { r } = await run({ wipe4860: true });
74
76
  assert.equal(r.ok, false); assert.equal(r.step, "body"); assert.match(r.message, /lost its body text/);
75
77
  });
76
- it("a lane launched twice after --resume fails the resume step", async () => {
77
- const { r } = await run({ double: true });
78
- assert.equal(r.step, "resume"); assert.match(r.message, /launched again/);
78
+ it("resume really stops the batch (not just the client) and cleanup stops it again (#4952)", async () => {
79
+ const { r, w } = await run({});
80
+ assert.equal(r.ok, true, JSON.stringify(r));
81
+ assert.deepEqual(w.stops, ["b1", "b1"], "once in the resume step, once in cleanup");
82
+ });
83
+ it("a stop that leaves the lane running fails the resume step instead of passing vacuously (#4952)", async () => {
84
+ const { r } = await run({ nostop: true }, { timeoutMs: 20000 });
85
+ assert.equal(r.step, "resume"); assert.match(r.message, /to stop after the cancel/);
79
86
  });
80
87
  it("B merging before A fails the merge step", async () => {
81
88
  const { r } = await run({ orderBA: true });
@@ -89,6 +96,41 @@ describe("selftest --live steps (#4865)", () => {
89
96
  const ok = await run({ pool: true });
90
97
  assert.equal(ok.w.remoteIssue, 12); assert.deepEqual(ok.w.closed, ["10", "11", "12"]);
91
98
  });
99
+ it("fixtures are run-unique, so a merged run leaves nothing the next run trips on (#4952)", async () => {
100
+ const x = uniqueFixture(FIXTURES.node, "node", "r1"), y = uniqueFixture(FIXTURES.python, "python", "r1");
101
+ assert.match(x.a.body, /`src\/r1\/a\.js`.*`src\/r1\/a\.test\.js`/); assert.match(x.a.title, /\(r1\)/);
102
+ assert.match(y.b.body, /`r1\/b\.py`.*`r1\/test_b\.py`/);
103
+ const { w } = await run({});
104
+ assert.match(w.issues[10].body, /src\/r[0-9a-z]+\/a\.js/);
105
+ });
106
+ it("the created issue is tracked at once: A is closed when B's create fails (#4952)", async () => {
107
+ const { w, io } = world({}), gh = io.gh; let creates = 0;
108
+ io.gh = async (a) => { if (a[0] === "issue" && a[1] === "create" && ++creates === 2) throw new Error("rate limited"); return gh(a); };
109
+ const r = await runSelftestLive({ repo: "o/sandbox", io, pollMs: 1, timeoutMs: 60000 });
110
+ assert.equal(r.step, "create"); assert.deepEqual(w.closed, ["10"]);
111
+ });
112
+ it("cleanup matches branches exactly and finds PRs by the head branch it created (#4952)", async () => {
113
+ const { w, io } = world({ add4859: true }), gh = io.gh, log = [];
114
+ io.gh = async (a) => {
115
+ if (a[0] === "api" && a[1].includes("matching-refs/heads/forge/issue-10")) return "refs/heads/forge/issue-10\nrefs/heads/forge/issue-100\nrefs/heads/forge/issue-10-x\n";
116
+ if (a[0] === "api" && a[2] === "DELETE") { log.push(`del ${a[3].split("git/")[1]}`); return ""; }
117
+ if (a[0] === "api") return "";
118
+ if (a[0] === "pr" && a[1] === "list") { log.push(`list ${a[a.indexOf("--head") + 1]}`); return a.includes("forge/issue-10") ? "7\n" : ""; }
119
+ if (a[0] === "pr" && a[1] === "close") { log.push(`close ${a[2]}`); return ""; }
120
+ return gh(a);
121
+ };
122
+ const r = await runSelftestLive({ repo: "o/sandbox", io, pollMs: 1, timeoutMs: 60000 });
123
+ assert.deepEqual(r.cleanupErrors, []);
124
+ assert.deepEqual(log, ["list forge/issue-10", "close 7", "del refs/heads/forge/issue-10", "list forge/issue-10-x", "del refs/heads/forge/issue-10-x"]);
125
+ assert.ok(!w.calls.some((c) => /search/.test(c)), "no text search for PRs");
126
+ });
127
+ it("own batch is picked by repo and issues: a foreign concurrent batch is never adopted (#4952)", () => {
128
+ const mine = { repo: "o/Sandbox", argv: ["orchestrate", "10", "11", "--repo", "o/Sandbox"] };
129
+ assert.ok(isOwnBatch(mine, "o/sandbox", [10, 11]));
130
+ assert.ok(!isOwnBatch({ repo: "o/real", argv: ["orchestrate", "10", "11"] }, "o/sandbox", [10, 11]));
131
+ assert.ok(!isOwnBatch({ repo: "o/sandbox", argv: ["orchestrate", "7"] }, "o/sandbox", [10, 11]));
132
+ assert.ok(!isOwnBatch(null, "o/sandbox", [10]));
133
+ });
92
134
  it("unknown fixture language fails at setup", async () => {
93
135
  assert.equal((await runSelftestLive({ repo: "o/r", lang: "ruby", io: {} })).step, "setup");
94
136
  });
@@ -9,9 +9,9 @@ import { spawn } from "node:child_process";
9
9
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
10
10
  import { join } from "node:path";
11
11
  import { schedDir } from "./sched.mjs";
12
+ import { neutralize, findMarked } from "./prodwatch-triage.mjs";
12
13
 
13
14
  export const NIGHTLY_MARKER = "<!-- FORGE:SELFTEST_NIGHTLY -->";
14
- const neutralize = (s) => String(s ?? "").replace(/</g, "&lt;").replace(/>/g, "&gt;");
15
15
  /** One last-run file per repo: two repos on one host never share (and so never skip) each other's schedule. */
16
16
  const stateFile = (repo) => `selftest-nightly-${String(repo).replace(/[^\w.-]+/g, "_")}.json`;
17
17
 
@@ -49,8 +49,12 @@ export async function reportNightly({ repo, io, now = () => Date.now(), result }
49
49
  const step = result?.step ?? "unknown";
50
50
  const title = `selftest --live failed at step ${step} (nightly)`;
51
51
  const body = `The nightly \`forgedock selftest --live\` failed at step **${neutralize(step)}**.\n\n${neutralize(String(result?.message ?? "").slice(0, 2000))}\n\nLast failure: ${new Date(now()).toISOString()}\n\n${NIGHTLY_MARKER}\n`;
52
- const open = JSON.parse(String(await io.gh(["issue", "list", "-R", repo, "--state", "open", "--search", `"FORGE:SELFTEST_NIGHTLY" in:body`, "--limit", "30", "--json", "number,body"])))
53
- .find((i) => String(i.body ?? "").includes(NIGHTLY_MARKER));
52
+ // #4952: the marker is public text, so only an issue authored by the actor running the harness is edited; an unreadable
53
+ // login trusts nobody (a new issue is filed instead).
54
+ let me = "";
55
+ try { me = String(await io.gh(["api", "user", "--jq", ".login"])).trim().toLowerCase(); } catch { /* untrusted */ }
56
+ const issues = JSON.parse(String(await io.gh(["issue", "list", "-R", repo, "--state", "open", "--search", `"FORGE:SELFTEST_NIGHTLY" in:body`, "--limit", "30", "--json", "number,body,author"])));
57
+ const open = findMarked(issues, NIGHTLY_MARKER, (i) => me && String(i.author?.login ?? "").toLowerCase() === me);
54
58
  if (open) {
55
59
  await io.gh(["issue", "edit", String(open.number), "-R", repo, "--title", title, "--body", body]);
56
60
  return { issue: open.number, action: "edit" };
@@ -8,7 +8,7 @@ import { nightlyConfig, nightlyDue, launchNightly, NIGHTLY_MARKER } from "./self
8
8
 
9
9
  const setup = (yaml) => { const cwd = tmpDir("nt-"), stateDir = tmpDir("ns-"); if (yaml) writeFileSync(join(cwd, "forge.yaml"), yaml); return { cwd, stateDir }; };
10
10
  const YAML = "selftest:\n sandbox_repo: a/b\n nightly_interval_hours: 24\n";
11
- const fakeIo = (open = []) => { const calls = []; return { calls, gh: async (a) => { calls.push(a); if (a[1] === "list") return JSON.stringify(open); if (a[1] === "create") return "https://github.com/o/r/issues/77\n"; return ""; } }; };
11
+ const fakeIo = (open = []) => { const calls = []; return { calls, gh: async (a) => { calls.push(a); if (a[0] === "api") return "bot\n"; if (a[1] === "list") return JSON.stringify(open); if (a[1] === "create") return "https://github.com/o/r/issues/77\n"; return ""; } }; };
12
12
 
13
13
  test("nightlyConfig: unset, zero and other sections are off", () => {
14
14
  assert.equal(nightlyConfig(""), null);
@@ -42,7 +42,7 @@ test("failure files one issue naming the step; the second failure edits it", asy
42
42
  assert.match(create.join(" "), /step body/); assert.ok(create.join(" ").includes(NIGHTLY_MARKER));
43
43
  assert.ok(!create[create.indexOf("--body") + 1].includes("<!-- x"));
44
44
  t += 25 * 3600_000;
45
- const io2 = fakeIo([{ number: 77, body: `x\n${NIGHTLY_MARKER}` }]);
45
+ const io2 = fakeIo([{ number: 77, body: `x\n${NIGHTLY_MARKER}`, author: { login: "Bot" } }]);
46
46
  const r2 = await nightlyDue({ ...s, repo: "o/r", io: io2, now: () => t, runLive: async () => ({ ok: false, step: "add", message: "m" }) });
47
47
  assert.deepEqual([r2.action, r2.issue], ["edit", 77]);
48
48
  assert.ok(!io2.calls.some((a) => a[1] === "create"));
@@ -82,3 +82,25 @@ test("launchNightly: detached, unref'd, and an async spawn error never escapes (
82
82
  assert.doesNotThrow(() => child.emit("error", Object.assign(new Error("spawn EAGAIN"), { code: "EAGAIN" })));
83
83
  assert.equal(launchNightly({ cli: "c", repo: "o/r", spawnFn: () => { throw new Error("EMFILE"); } }), null);
84
84
  });
85
+
86
+ test("the dedupe never edits a marker-bearing issue authored by someone else (#4952)", async () => {
87
+ const s = setup(YAML), io = fakeIo([{ number: 5, body: `evil\n${NIGHTLY_MARKER}`, author: { login: "mallory" } }, { number: 6, body: `no marker`, author: { login: "bot" } }]);
88
+ const r = await nightlyDue({ ...s, repo: "o/r", io, runLive: async () => ({ ok: false, step: "add", message: "m" }) });
89
+ assert.deepEqual([r.action, r.issue], ["create", 77]);
90
+ assert.ok(!io.calls.some((a) => a[1] === "edit"));
91
+ assert.ok(io.calls.find((a) => a[1] === "list").join(" ").includes("number,body,author"));
92
+ });
93
+
94
+ test("an unreadable login trusts nobody: a new issue is filed", async () => {
95
+ const s = setup(YAML), io = fakeIo([{ number: 5, body: NIGHTLY_MARKER, author: { login: "bot" } }]), gh = io.gh;
96
+ io.gh = async (a) => { if (a[0] === "api") throw new Error("no token user"); return gh(a); };
97
+ const r = await nightlyDue({ ...s, repo: "o/r", io, runLive: async () => ({ ok: false, step: "add", message: "m" }) });
98
+ assert.equal(r.action, "create");
99
+ });
100
+
101
+ test("a marker quoted mid-body by the trusted author is not a dedupe hit (shared trailer rule)", async () => {
102
+ const s = setup(YAML), io = fakeIo([{ number: 5, body: `quote: ${NIGHTLY_MARKER}\nmore text`, author: { login: "bot" } }]);
103
+ const r = await nightlyDue({ ...s, repo: "o/r", io, runLive: async () => ({ ok: false, step: "add", message: "m" }) });
104
+ assert.equal(r.action, "create");
105
+ assert.ok(!io.calls.some((a) => a[1] === "edit"));
106
+ });
@@ -18,15 +18,20 @@ export function listSources(dir) {
18
18
  return out.sort();
19
19
  }
20
20
 
21
- /** @returns {{cmd:string, fields:string[], line:number}[]} the literal gh `--json` field lists of `text` (cmd e.g. "issue view"). */
21
+ /**
22
+ * The `gh issue|pr view|list --json <fields>` uses of `text`. A literal field list is `{cmd, fields, line}`; a list the
23
+ * scan cannot read (a variable or template, e.g. `"--json", fields`) is `{cmd, fields: [], unchecked: true, line}`.
24
+ * @returns {{cmd:string, fields:string[], line:number, unchecked?:true}[]} cmd e.g. "issue view"
25
+ */
22
26
  export function extractJsonFields(text) {
23
- const out = [];
24
- const re = /\[([^[\]]*?)["'`]--json["'`]\s*,\s*["'`]([A-Za-z0-9_,]+)["'`]/g;
27
+ const out = [], re = /["'`]--json["'`]\s*,\s*/g;
25
28
  for (let m; (m = re.exec(text));) {
26
- const words = [...m[1].matchAll(/["'`]([a-z-]+)["'`]/g)].map((x) => x[1]);
27
- const i = words.findIndex((w, k) => (w === "issue" || w === "pr") && (words[k + 1] === "view" || words[k + 1] === "list"));
28
- if (i < 0) continue;
29
- out.push({ cmd: `${words[i]} ${words[i + 1]}`, fields: m[2].split(",").filter(Boolean), line: text.slice(0, m.index).split("\n").length });
29
+ const before = text.slice(Math.max(0, m.index - 300), m.index), seg = before.slice(before.lastIndexOf(";") + 1);
30
+ const cmds = [...seg.matchAll(/["'`](issue|pr)["'`]\s*,\s*["'`](view|list)["'`]/g)];
31
+ if (!cmds.length) continue;
32
+ const c = cmds.at(-1), lit = /^["'`]([A-Za-z0-9_,]+)["'`]\s*[,\])]/.exec(text.slice(m.index + m[0].length));
33
+ const row = { cmd: `${c[1]} ${c[2]}`, fields: lit ? lit[1].split(",").filter(Boolean) : [], line: text.slice(0, m.index).split("\n").length };
34
+ out.push(lit ? row : { ...row, unchecked: true });
30
35
  }
31
36
  return out;
32
37
  }
@@ -47,14 +52,15 @@ export function parseHelpFields(help) {
47
52
 
48
53
  /**
49
54
  * @param {{root:string, io:{gh:(args:string[])=>string, read?:(p:string)=>string, list?:(d:string)=>string[]}}} a
50
- * @returns {{ok:boolean, checked:number, missing:{file:string,line:number,cmd:string,field:string}[], errors:string[]}}
55
+ * @returns {{ok:boolean, checked:number, unchecked:{file:string,line:number,cmd:string}[], missing:{file:string,line:number,cmd:string,field:string}[], errors:string[]}}
51
56
  */
52
57
  export function staticCheck({ root, io }) {
53
58
  const read = io.read ?? ((p) => readFileSync(p, "utf8")), list = io.list ?? listSources;
54
- const known = new Map(), errors = [], missing = [];
59
+ const known = new Map(), errors = [], missing = [], unchecked = [];
55
60
  let checked = 0;
56
61
  for (const file of list(root)) {
57
62
  for (const u of extractJsonFields(read(file))) {
63
+ if (u.unchecked) { unchecked.push({ file, line: u.line, cmd: u.cmd }); continue; } // reported, never silently skipped (#4952)
58
64
  if (!known.has(u.cmd)) {
59
65
  let fields = [];
60
66
  try { fields = parseHelpFields(io.gh([...u.cmd.split(" "), "--help"])); } catch (e) { errors.push(`gh ${u.cmd} --help failed: ${e.message}`); }
@@ -67,7 +73,7 @@ export function staticCheck({ root, io }) {
67
73
  for (const field of u.fields) if (!set.has(field)) missing.push({ file, line: u.line, cmd: u.cmd, field });
68
74
  }
69
75
  }
70
- return { ok: !missing.length && !errors.length, checked, missing, errors };
76
+ return { ok: !missing.length && !errors.length, checked, unchecked, missing, errors };
71
77
  }
72
78
 
73
79
  export const realGh = (args) => execFileSync("gh", args, { encoding: "utf8", maxBuffer: 16 * 1024 * 1024 });
@@ -76,6 +82,7 @@ export function formatStatic(r) {
76
82
  return [
77
83
  ...r.missing.map((m) => `${m.file}:${m.line}: gh ${m.cmd} --json field "${m.field}" is not offered by this gh`),
78
84
  ...r.errors,
79
- `static check: ${r.ok ? "ok" : "FAILED"} (${r.checked} field lists checked)`,
85
+ ...(r.unchecked ?? []).map((u) => `${u.file}:${u.line}: gh ${u.cmd} --json field list is not a string literal: unchecked`),
86
+ `static check: ${r.ok ? "ok" : "FAILED"} (${r.checked} field lists checked, ${(r.unchecked ?? []).length} unchecked)`,
80
87
  ].join("\n");
81
88
  }
@@ -29,4 +29,12 @@ describe("selftest static check (#4865)", () => {
29
29
  const r = staticCheck({ root: "/bin", io: { gh: () => { throw new Error("no gh"); }, list: () => ["/a.mjs"], read: () => 'x(["pr", "view", "--json", "title"])' } });
30
30
  assert.equal(r.ok, false);
31
31
  });
32
+ it("reports a non-literal --json list as unchecked, not as checked (#4952)", () => {
33
+ const t = 'x();\ngh(["issue", "view", String(n), ...(repo ? ["-R", repo] : []), "--json", fields]);\ngh(["pr", "list", "--json", `a,${f}`]);';
34
+ assert.deepEqual(extractJsonFields(t), [{ cmd: "issue view", fields: [], line: 2, unchecked: true }, { cmd: "pr list", fields: [], line: 3, unchecked: true }]);
35
+ const r = staticCheck({ root: "/bin", io: { gh, list: () => ["/bin/a.mjs"], read: () => t } });
36
+ assert.equal(r.ok, true); assert.equal(r.checked, 0); assert.equal(r.unchecked.length, 2);
37
+ assert.match(formatStatic(r), /a\.mjs:2: gh issue view --json field list is not a string literal: unchecked/);
38
+ assert.match(formatStatic(r), /0 field lists checked, 2 unchecked/);
39
+ });
32
40
  });
@@ -61,16 +61,18 @@ export async function ensureSignedOff({ git, lane, branch, env = process.env })
61
61
  }
62
62
  const fenv = { FD_BAD: bad.map((c) => c.sha).join(" "), FD_NAME: name, FD_EMAIL: email, FILTER_BRANCH_SQUELCH_WARNING: "1" };
63
63
  // filter-branch refuses a dirty tree (lockfile churn, build output): park tracked changes on a private ref, never the shared stash stack
64
- const saved = await ok(["status", "--porcelain", "--untracked-files=no"]) ? await ok(["stash", "create"]) : "";
64
+ const porcelain = await ok(["status", "--porcelain", "--untracked-files=no"]);
65
+ const dirty = porcelain ? porcelain.split("\n").map((l) => l.replace(/^\s*\S+\s+/, "")).slice(0, 20) : []; // #4905: the dirty paths are reported so the source of the dirt (validate/format output) is visible
66
+ const saved = porcelain ? await ok(["stash", "create"]) : "";
65
67
  if (saved) { await git(["update-ref", STASH_REF, saved]); await git(["reset", "-q", "--hard", "HEAD"]); }
66
68
  let failure = null;
67
69
  try { await git(["filter-branch", "-f", "--env-filter", ENV_FILTER, "--msg-filter", MSG_FILTER, "--", "HEAD", ...exclude], { env: fenv }); }
68
- catch (e) { failure = `could not rewrite ${bad.length} unpushed commit(s) for DCO: ${String(e?.stderr ?? e?.message ?? e).slice(0, 300)}`; }
70
+ catch (e) { failure = `could not rewrite ${bad.length} unpushed commit(s) for DCO: ${String(e?.stderr ?? e?.message ?? e).slice(0, 300)}${dirty.length ? ` (dirty tracked files: ${dirty.join(", ")})` : ""}`; }
69
71
  if (saved) {
70
72
  try { await git(["stash", "apply", saved]); await ok(["update-ref", "-d", STASH_REF]); }
71
73
  catch { failure = `${failure ? `${failure}; ` : ""}could not restore the lane's uncommitted changes after the DCO rewrite; they are kept as ${saved} (${STASH_REF})`; }
72
74
  }
73
75
  if (failure) throw Object.assign(new Error(failure), { noIdentity: false, engineCode: "engine.dco_rewrite" });
74
76
  await ok(["for-each-ref", "--format=delete %(refname)", "refs/original/"]).then(async (l) => { for (const r of l.split("\n").map((x) => x.replace(/^delete /, "")).filter(Boolean)) await ok(["update-ref", "-d", r]); });
75
- return { rewritten: bad.length };
77
+ return { rewritten: bad.length, ...(dirty.length ? { dirty } : {}) };
76
78
  }
@@ -99,6 +99,27 @@ describe("ensureSignedOff", () => {
99
99
  await assert.rejects(ensureSignedOff({ git: f.git, lane: "staging", branch: "feat/x", env: {} }), (e) => e.noIdentity === true);
100
100
  assert.equal(f.sh("rev-parse", "HEAD"), bad);
101
101
  });
102
+ it("rewrites on a dirty worktree and keeps the dirty tracked and untracked files (#4905)", async () => {
103
+ const f = fixture();
104
+ f.commit("b.txt", "unpushed placeholder", "placeholder");
105
+ writeFileSync(join(f.wt, "base.txt"), "modified\n");
106
+ writeFileSync(join(f.wt, "new.txt"), "untracked\n");
107
+ const r = await ensureSignedOff({ git: f.git, lane: "staging", branch: "feat/x", env: {} });
108
+ assert.equal(r.rewritten, 1);
109
+ assert.deepEqual(r.dirty, ["base.txt"]); // the source of the dirt is reported
110
+ assert.equal(readFileSync(join(f.wt, "base.txt"), "utf8"), "modified\n");
111
+ assert.equal(readFileSync(join(f.wt, "new.txt"), "utf8"), "untracked\n");
112
+ assert.match(f.sh("status", "--porcelain"), /M base\.txt/);
113
+ assert.equal(f.sh("log", "-1", "--format=%ae"), "lane@example.com");
114
+ });
115
+ it("restores the dirty file when the rewrite itself fails (#4905)", async () => {
116
+ const f = fixture();
117
+ f.commit("b.txt", "unpushed placeholder", "placeholder");
118
+ writeFileSync(join(f.wt, "base.txt"), "modified\n");
119
+ const git = async (a, o) => { if (a[0] === "filter-branch") throw Object.assign(new Error("boom"), { stderr: "boom" }); return f.git(a, o); };
120
+ await assert.rejects(ensureSignedOff({ git, lane: "staging", branch: "feat/x", env: {} }), /could not rewrite 1 unpushed.*dirty tracked files: base\.txt/s);
121
+ assert.equal(readFileSync(join(f.wt, "base.txt"), "utf8"), "modified\n");
122
+ });
102
123
 
103
124
  it("rewrites on a dirty tree (#4997): unstaged and staged tracked changes survive, no stash entry is left", async () => {
104
125
  const f = fixture();
package/bin/pool/cli.mjs CHANGED
@@ -15,10 +15,38 @@ import { call as httpCall } from "./http.mjs";
15
15
  const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..", "..");
16
16
  const loadJson = (p) => JSON.parse(readFileSync(p, "utf8"));
17
17
 
18
+ const USAGE = "usage: forgedock pool router [install] | enroll [--cpus N --mem GB] | status | upgrade [agent] | remove <agent> [--config path]";
19
+ const HELP_FLAGS = ["--help", "-h"];
20
+ // Flags each verb accepts: `value` flags consume the next token, `bool` flags stand alone. Anything else dash-prefixed is rejected (#5008).
21
+ const VERB_FLAGS = {
22
+ router: { value: ["--config"], bool: [] },
23
+ agent: { value: ["--config"], bool: [] },
24
+ status: { value: ["--config"], bool: [] },
25
+ upgrade: { value: ["--config"], bool: [] },
26
+ remove: { value: ["--config"], bool: [] },
27
+ enroll: { value: ["--config", "--cpus", "--mem"], bool: [] },
28
+ "install-command": { value: ["--config", "--cpus", "--mem"], bool: [] },
29
+ resize: { value: ["--config", "--cpus", "--mem", "--vm-cpus", "--vm-mem", "--vm-swap"], bool: ["--drain"] },
30
+ };
31
+
32
+ function rejectUnknownFlags(cmd, rest) {
33
+ const spec = VERB_FLAGS[cmd];
34
+ if (!spec) return;
35
+ for (let i = 0; i < rest.length; i++) {
36
+ const t = rest[i];
37
+ if (spec.value.includes(t)) { i++; continue; }
38
+ if (spec.bool.includes(t)) continue;
39
+ if (t.startsWith("-") && !/^-\d/.test(t)) throw new Error(`usage: unknown flag ${t} for 'forgedock pool ${cmd}'. ${USAGE.slice("usage: ".length)}`);
40
+ }
41
+ }
42
+
18
43
  /** The `forgedock pool` verbs (and the `computeshare` script). Throws on usage or router errors; `deps` injects the HTTP client and config. */
19
44
  export async function runPoolCli(argv, deps = {}) {
20
45
  const [cmd, ...rest] = argv;
21
46
  const call = deps.call ?? httpCall;
47
+ // Help never reaches the router or starts a service (#5008).
48
+ if (HELP_FLAGS.includes(cmd) || cmd === "help" || rest.some((x) => HELP_FLAGS.includes(x))) { console.log(USAGE); return; }
49
+ rejectUnknownFlags(cmd, rest);
22
50
  const flag = (name, dflt) => { const i = rest.indexOf(`--${name}`); return i >= 0 ? rest[i + 1] : dflt; };
23
51
 
24
52
  function routerConfig() {
@@ -103,7 +131,7 @@ export async function runPoolCli(argv, deps = {}) {
103
131
  break;
104
132
  }
105
133
  default:
106
- throw new Error("usage: forgedock pool router [install] | enroll [--cpus N --mem GB] | status | upgrade [agent] | remove <agent> [--config path]");
134
+ throw new Error(USAGE);
107
135
  }
108
136
  }
109
137
 
@@ -150,7 +150,10 @@ When a lane finishes (agent lanes; the batch runner applies the same rules itsel
150
150
  - `needs-human` with a **recoverable code**: `ci.red`, `base.conflict` (merge conflict), `ci-pending` on a conflicting
151
151
  PR, `contract.invalid` caused by an issue edited mid-run, `builder.block_untyped` (an in-scope technical choice),
152
152
  and the environment codes `env.tool_missing` (a validate command the host cannot run) and `env.repro_unrunnable`
153
- (the repro harness could not run the repro test).
153
+ (the repro harness could not run the repro test), and the conformance gaps `conformance.unimplemented`,
154
+ `conformance.omission` and `conformance.unjustified_deferral` (the recovery lane delivers the gap, or defers an optional
155
+ clause with a why so a tracked follow-up is filed; `conformance.regression`, `guard_broken`, `scope_creep` and
156
+ `e2e_unverified` stay terminal).
154
157
  These are mechanical. **Do not ask for confirmation on them.** The batch runner recovers each one itself
155
158
  (`orchestration.recovery.max_attempts`, default 1 per issue). It launches one recovery lane under the same lease, lane
156
159
  and admission rules as any lane, with `run-issue --recover <code> [--recover-attempt n]` (core path only:
@@ -166,7 +169,7 @@ When a lane finishes (agent lanes; the batch runner applies the same rules itsel
166
169
  the issue's last comment for the reason, mark its dependents skipped, and add it to the escalation list (step 4). Only
167
170
  explicit or logical edges skip a dependent (after you decide the block in scope, clear the label and run
168
171
  `forgedock orchestrate --requeue <id> N... --reason "..."`, never a second batch); an issue that merely overlaps the same file keeps running.
169
- - `needs-human` with a **terminal code** that is neither recoverable nor human (for example a `conformance.*` code, or
172
+ - `needs-human` with a **terminal code** that is neither recoverable nor human (for example `conformance.regression`, or
170
173
  `contract.invalid` without a mid-run issue edit): the runner does not recover it and it is not an escalation. The
171
174
  batch report lists it as `unrecovered: #N (<code>: <detail>)`, like a recovery that did not merge. Mark its dependents
172
175
  skipped and leave the issue for a later run once its cause is fixed.