forgedock 1.51.0 → 1.53.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 (103) hide show
  1. package/bin/engine/outcome-codes.mjs +3 -0
  2. package/bin/engine/telemetry-seam.mjs +4 -2
  3. package/bin/engine-cli.mjs +61 -17
  4. package/bin/experiment.mjs +58 -6
  5. package/bin/forge-utils.mjs +6 -2
  6. package/bin/forgedock.mjs +25 -1
  7. package/bin/lean/account-watch.mjs +28 -0
  8. package/bin/lean/account-watch.test.mjs +30 -0
  9. package/bin/lean/activation.mjs +20 -0
  10. package/bin/lean/activation.test.mjs +14 -1
  11. package/bin/lean/basered.mjs +115 -0
  12. package/bin/lean/basered.test.mjs +66 -0
  13. package/bin/lean/batch-health.mjs +40 -6
  14. package/bin/lean/batch-health.test.mjs +34 -1
  15. package/bin/lean/batch.mjs +41 -2
  16. package/bin/lean/batch.test.mjs +104 -2
  17. package/bin/lean/checkpoint-reconcile.mjs +43 -0
  18. package/bin/lean/checkpoint-reconcile.test.mjs +95 -0
  19. package/bin/lean/conformance.e2e.test.mjs +1 -1
  20. package/bin/lean/conformance.mjs +205 -23
  21. package/bin/lean/conformance.test.mjs +164 -3
  22. package/bin/lean/context.mjs +27 -17
  23. package/bin/lean/context.test.mjs +15 -0
  24. package/bin/lean/effects.mjs +11 -7
  25. package/bin/lean/execution.mjs +19 -3
  26. package/bin/lean/execution.test.mjs +39 -0
  27. package/bin/lean/findinglabel.mjs +16 -0
  28. package/bin/lean/findinglabel.test.mjs +39 -0
  29. package/bin/lean/heavy.mjs +6 -3
  30. package/bin/lean/hostload.mjs +78 -0
  31. package/bin/lean/hostload.test.mjs +117 -0
  32. package/bin/lean/hotspots-remote.e2e.test.mjs +71 -0
  33. package/bin/lean/issuewatch-release.mjs +6 -2
  34. package/bin/lean/issuewatch-release.test.mjs +16 -0
  35. package/bin/lean/issuewatch.mjs +11 -1
  36. package/bin/lean/lanelock.mjs +14 -0
  37. package/bin/lean/lean.mjs +171 -36
  38. package/bin/lean/lean.test.mjs +302 -10
  39. package/bin/lean/light.mjs +48 -7
  40. package/bin/lean/light.test.mjs +37 -3
  41. package/bin/lean/limits.test.mjs +142 -9
  42. package/bin/lean/orchestrate-cancel.test.mjs +143 -0
  43. package/bin/lean/orchestrate.mjs +110 -26
  44. package/bin/lean/postdeploy-check.test.mjs +39 -0
  45. package/bin/lean/prompts.mjs +8 -7
  46. package/bin/lean/quota.mjs +39 -0
  47. package/bin/lean/recovery.test.mjs +10 -0
  48. package/bin/lean/relaxation.mjs +73 -0
  49. package/bin/lean/relaxation.test.mjs +54 -0
  50. package/bin/lean/release-postmerge.mjs +119 -0
  51. package/bin/lean/release-rehearsal.mjs +63 -0
  52. package/bin/lean/release-rehearsal.test.mjs +93 -0
  53. package/bin/lean/release-review.e2e.test.mjs +77 -0
  54. package/bin/lean/release-review.mjs +198 -0
  55. package/bin/lean/release-review.test.mjs +180 -0
  56. package/bin/lean/release.mjs +228 -0
  57. package/bin/lean/release.test.mjs +292 -0
  58. package/bin/lean/rotator.mjs +150 -31
  59. package/bin/lean/rotator.test.mjs +105 -2
  60. package/bin/lean/sandbox-remote.mjs +9 -2
  61. package/bin/lean/schedd.mjs +56 -6
  62. package/bin/lean/schedd.test.mjs +108 -6
  63. package/bin/lean/verifier.mjs +3 -2
  64. package/bin/lean/verify.mjs +2 -1
  65. package/bin/lean/verify.test.mjs +6 -0
  66. package/bin/pool/agent.mjs +18 -4
  67. package/bin/pool/router.mjs +68 -25
  68. package/bin/review-staging.mjs +23 -0
  69. package/bin/stats/conformance-outcomes.mjs +208 -0
  70. package/bin/stats/conformance-outcomes.test.mjs +188 -0
  71. package/bin/stats/depth.mjs +218 -0
  72. package/bin/stats/depth.test.mjs +133 -0
  73. package/bin/stats/experiment.mjs +7 -5
  74. package/bin/stats/github-source.mjs +2 -2
  75. package/bin/stats/index.mjs +64 -2
  76. package/bin/stats/local-source.mjs +11 -0
  77. package/bin/stats/query.mjs +69 -0
  78. package/bin/stats/selffiled.mjs +52 -0
  79. package/bin/stats/selffiled.test.mjs +71 -0
  80. package/commands/orchestrate.md +1 -1
  81. package/commands/review-pr-agents/security.md +4 -0
  82. package/commands/review-pr-staging.md +2 -0
  83. package/commands/work-on/build.md +4 -6
  84. package/docs/CONFIG.md +66 -8
  85. package/docs/ISSUE-WATCH.md +2 -0
  86. package/docs/OUTCOME-CODES.md +3 -0
  87. package/docs/STATS.md +44 -0
  88. package/docs/TELEMETRY.md +1 -1
  89. package/package.json +1 -1
  90. package/pool/README.md +1 -1
  91. package/pool/image/cs-cred +14 -1
  92. package/pool/install/install-agent.ps1 +6 -2
  93. package/scripts/backfill-finding-labels.mjs +50 -0
  94. package/scripts/backfill-finding-labels.test.mjs +36 -0
  95. package/scripts/doctor-pipeline-state.sh +21 -6
  96. package/scripts/file-deferred-followups.sh +60 -238
  97. package/scripts/file-deferred-followups.test.sh +99 -187
  98. package/scripts/followup-route.mjs +12 -0
  99. package/scripts/hotspots.sh +12 -8
  100. package/scripts/hotspots.test.sh +22 -0
  101. package/scripts/owner-route-parity.test.sh +17 -1
  102. package/scripts/prior-attempts.test.mjs +1 -1
  103. package/scripts/review-pr-side-effects.test.sh +40 -0
@@ -0,0 +1,95 @@
1
+ // SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
2
+ // SPDX-License-Identifier: AGPL-3.0-or-later
3
+ // #5202: a pushed checkpoint the lane amended locally is merged back in before the push, on a real temp git repo (bare origin + clone).
4
+ import { describe, it } from "node:test";
5
+ import assert from "node:assert/strict";
6
+ import { execFileSync } from "node:child_process";
7
+ import { writeFileSync } from "node:fs";
8
+ import { join } from "node:path";
9
+ import { tmpDir } from "../tests/_tmp.mjs";
10
+ import { reconcileCheckpoints } from "./checkpoint-reconcile.mjs";
11
+
12
+ const CLEAN = Object.fromEntries(Object.entries(process.env).filter(([k]) => !/^GIT_(AUTHOR|COMMITTER)_/.test(k)));
13
+ const ENV = { ...CLEAN, GIT_CONFIG_GLOBAL: "/dev/null", GIT_CONFIG_SYSTEM: "/dev/null" };
14
+ const sh = (cwd, ...a) => execFileSync("git", a, { cwd, encoding: "utf8", env: ENV, stdio: ["ignore", "pipe", "pipe"] }).trim();
15
+ const CKPT = "wip(forge): checkpoint after context ceiling";
16
+
17
+ function fixture() {
18
+ const root = tmpDir("reconcile-"), origin = join(root, "origin.git"), wt = join(root, "wt");
19
+ sh(root, "init", "--bare", "-b", "staging", origin);
20
+ sh(root, "clone", "-q", origin, wt);
21
+ sh(wt, "config", "user.name", "Lane Bot"); sh(wt, "config", "user.email", "lane@example.com");
22
+ const commit = (file, msg, dir = wt) => { writeFileSync(join(dir, file), `${file}\n`); sh(dir, "add", file); sh(dir, "commit", "-q", "-m", msg); return sh(dir, "rev-parse", "HEAD"); };
23
+ commit("base.txt", "base");
24
+ sh(wt, "push", "-q", "origin", "HEAD:staging");
25
+ sh(wt, "checkout", "-q", "-b", "feat/x");
26
+ const git = async (a) => execFileSync("git", a, { cwd: wt, encoding: "utf8", env: ENV, stdio: ["ignore", "pipe", "pipe"] }).trim();
27
+ return { root, origin, wt, commit, git, sh: (...a) => sh(wt, ...a) };
28
+ }
29
+ const isAncestor = (f, a, b) => { try { f.sh("merge-base", "--is-ancestor", a, b); return true; } catch { return false; } };
30
+
31
+ describe("reconcileCheckpoints (#5202)", () => {
32
+ it("#5202 a pushed checkpoint the lane amended is merged in: HEAD descends from it, the tree is kept, a plain push succeeds", async () => {
33
+ const f = fixture();
34
+ const ckpt = f.commit("a.txt", CKPT);
35
+ f.sh("push", "-q", "-u", "origin", "feat/x");
36
+ f.sh("commit", "-q", "--amend", "-m", "fix: a proper message");
37
+ f.commit("b.txt", "feat: more");
38
+ const tree = f.sh("rev-parse", "HEAD^{tree}");
39
+ assert.equal(isAncestor(f, ckpt, "HEAD"), false);
40
+ const r = await reconcileCheckpoints({ git: f.git, branch: "feat/x" });
41
+ assert.equal(r.state, "reconciled");
42
+ assert.equal(r.sha, ckpt);
43
+ assert.equal(r.commits.length, 1);
44
+ assert.equal(isAncestor(f, ckpt, "HEAD"), true);
45
+ assert.equal(f.sh("rev-parse", "HEAD^{tree}"), tree);
46
+ f.sh("push", "-q", "origin", "feat/x"); // plain push, no force
47
+ assert.equal(sh(f.origin, "rev-parse", "feat/x"), f.sh("rev-parse", "HEAD"));
48
+ });
49
+
50
+ it("#5202 a branch already ahead of origin is left alone", async () => {
51
+ const f = fixture();
52
+ f.commit("a.txt", CKPT);
53
+ f.sh("push", "-q", "-u", "origin", "feat/x");
54
+ const head = f.commit("b.txt", "feat: more");
55
+ assert.equal((await reconcileCheckpoints({ git: f.git, branch: "feat/x" })).state, "ok");
56
+ assert.equal(f.sh("rev-parse", "HEAD"), head);
57
+ });
58
+
59
+ it("#5202 an unpushed branch is 'none'", async () => {
60
+ const f = fixture();
61
+ f.commit("a.txt", "feat: a");
62
+ assert.equal((await reconcileCheckpoints({ git: f.git, branch: "feat/x" })).state, "none");
63
+ });
64
+
65
+ it("#5202 a remote-only commit that is not a checkpoint is 'foreign' and HEAD is unchanged", async () => {
66
+ const f = fixture();
67
+ f.commit("a.txt", "feat: a");
68
+ f.sh("push", "-q", "-u", "origin", "feat/x");
69
+ f.sh("commit", "-q", "--amend", "-m", "feat: a reworded");
70
+ const head = f.sh("rev-parse", "HEAD");
71
+ const r = await reconcileCheckpoints({ git: f.git, branch: "feat/x" });
72
+ assert.equal(r.state, "foreign");
73
+ assert.equal(f.sh("rev-parse", "HEAD"), head);
74
+ });
75
+
76
+ it("#5202 a checkpoint pushed from another clone (not in this reflog) is 'foreign'", async () => {
77
+ const f = fixture();
78
+ f.commit("a.txt", "feat: a");
79
+ f.sh("push", "-q", "-u", "origin", "feat/x");
80
+ const other = join(f.root, "other");
81
+ sh(f.root, "clone", "-q", "-b", "feat/x", f.origin, other);
82
+ sh(other, "config", "user.name", "Other"); sh(other, "config", "user.email", "other@example.com");
83
+ f.commit("c.txt", CKPT, other);
84
+ sh(other, "push", "-q", "origin", "feat/x");
85
+ const head = f.commit("b.txt", "feat: b");
86
+ const r = await reconcileCheckpoints({ git: f.git, branch: "feat/x" });
87
+ assert.equal(r.state, "foreign");
88
+ assert.equal(f.sh("rev-parse", "HEAD"), head);
89
+ });
90
+
91
+ it("#5202 git failures never throw", async () => {
92
+ const r = await reconcileCheckpoints({ git: async (a) => { if (a[0] === "fetch") throw new Error("offline"); if (a[0] === "rev-parse") return "x"; if (a[0] === "merge-base") throw new Error("no"); throw new Error("boom"); }, branch: "feat/x" });
93
+ assert.equal(r.state, "error");
94
+ });
95
+ });
@@ -56,7 +56,7 @@ const contract = (reqs) => ({ requirements: reqs, deliverables: reqs.filter((r)
56
56
  preserve: [{ id: "P1", what: `${Q.AC3} (src/billing.js price())` }, { id: "P2", what: `${Q.AC2} (test/routes.test.js)` }], validate: [{ id: "V1", command: V1 }] });
57
57
  const FULL = () => contract([req("R1"), req("R2"), req("R3"), req("R4"), req("R5")]);
58
58
  const OMIT = () => contract([req("R1"), req("R2"), req("R4"), req("R5")]);
59
- const DEFER = () => contract([req("R1"), req("R2"), req("R3", "defer", { bucket: "new-issue", why: "export.js ships on the data-export module's own release train" }), req("R4"), req("R5")]);
59
+ const DEFER = () => contract([req("R1"), req("R2"), req("R3", "defer", { bucket: "owner:the data-export team ships export.js", why: "export.js ships on the data-export module's own release train" }), req("R4"), req("R5")]);
60
60
 
61
61
  // ---- world ----
62
62
  function makeWorld(dir, script) {
@@ -69,10 +69,62 @@ const ITEM_PREFIX_RE = /^\s*(?:[-*+]\s+)?(?:\[[ xX]\]\s+)?(?:\d+[.)]\s+)?/;
69
69
  */
70
70
  export function inIssue(quote, issueText) {
71
71
  const q = norm(quote);
72
- if (q.length >= MIN_QUOTE_CHARS) return norm(issueText).includes(q);
72
+ if (q.length >= MIN_QUOTE_CHARS) return norm(issueText).includes(q) || elidedIn(q, norm(issueText)) || compact(issueText).includes(compact(q));
73
73
  if (q.length < 3) return false;
74
74
  return String(issueText ?? "").split("\n").some((l) => norm(l.replace(ITEM_PREFIX_RE, "")) === q);
75
75
  }
76
+ /** #5244: alphanumerics only, so `SLI_X` retyped as "SLI X" or a dropped punctuation mark still compares equal. */
77
+ const compact = (s) => norm(s).replace(/[^a-z0-9]/g, "");
78
+ /** #5244: a quote shortened with "..." (norm folds the ellipsis char): every segment is in the issue, in order, and one is a full-length quote. */
79
+ function elidedIn(q, issue) {
80
+ if (!q.includes("...")) return false;
81
+ const segs = q.split("...").map((x) => x.trim()).filter(Boolean);
82
+ if (!segs.some((x) => x.length >= MIN_QUOTE_CHARS)) return false;
83
+ let at = 0;
84
+ for (const seg of segs) { const i = issue.indexOf(seg, at); if (i < 0) return false; at = i + seg.length; }
85
+ return true;
86
+ }
87
+ const SNAP_MIN = 0.9;
88
+ const tokens = (s) => norm(String(s ?? "").replace(/_/g, " ")).match(/[a-z0-9]+/g) ?? [];
89
+ /**
90
+ * #5244: the issue's exact line or sentence a near-verbatim quote stands for, or null. At least SNAP_MIN of the quote's tokens must be
91
+ * in exactly one line or sentence (the shortest of the best scorers; a rival that is not nested in it makes the match ambiguous).
92
+ */
93
+ export function snapQuote(quote, issueText) {
94
+ const qt = [...new Set(tokens(quote))];
95
+ if (qt.length < 4) return null;
96
+ const seen = new Set(), cands = [];
97
+ for (const line of String(noComments(String(issueText ?? ""))).split("\n")) {
98
+ const l = line.replace(ITEM_PREFIX_RE, "").trim();
99
+ for (const raw of [l, ...l.split(/(?<=[.!?])\s+/)]) {
100
+ const n = norm(raw);
101
+ if (n.length < MIN_QUOTE_CHARS || seen.has(n)) continue;
102
+ seen.add(n);
103
+ const ct = new Set(tokens(raw));
104
+ cands.push({ raw, n, score: qt.filter((w) => ct.has(w)).length / qt.length });
105
+ }
106
+ }
107
+ const ok = cands.filter((c) => c.score >= SNAP_MIN);
108
+ if (!ok.length) return null;
109
+ const top = Math.max(...ok.map((c) => c.score));
110
+ const best = ok.filter((c) => c.score === top).sort((a, b) => a.n.length - b.n.length)[0];
111
+ const rival = ok.some((c) => c !== best && !c.n.includes(best.n) && !best.n.includes(c.n));
112
+ return rival ? null : best.raw;
113
+ }
114
+ /** #5244: replaces each failing requirement quote with the issue line it snaps to (original kept as `requoted`). */
115
+ export function snapQuotes(contract, issueText) {
116
+ const reqs = contract?.requirements;
117
+ if (!Array.isArray(reqs) || issueText == null) return { contract, snapped: [] };
118
+ const snapped = [];
119
+ const requirements = reqs.map((r) => {
120
+ if (!r || typeof r.quote !== "string" || inIssue(r.quote, issueText)) return r;
121
+ const to = snapQuote(r.quote, issueText);
122
+ if (!to || !inIssue(to, issueText)) return r;
123
+ snapped.push({ id: r.id, from: r.quote, to });
124
+ return { ...r, quote: to, requoted: r.quote };
125
+ });
126
+ return { contract: snapped.length ? { ...contract, requirements } : contract, snapped };
127
+ }
76
128
  /** #5164: the issue's list or checklist item lines (item marker stripped), or every non-empty line when it has none. */
77
129
  export function criterionLines(issueText) {
78
130
  const lines = String(noComments(String(issueText ?? ""))).split("\n");
@@ -263,8 +315,8 @@ const TMP_PATH = /\$(?:\{TMPDIR(?::-[^}]*)?\}|TMPDIR)\/([^\s"'`;|&<>()=]+)/g;
263
315
  * #4325: the `$TMPDIR/<name>` paths a frozen command reads without creating them itself. The run TMPDIR is per run, so such
264
316
  * a file (written by the builder before) is gone for the engine's red-green check and for any rerun. A path counts as
265
317
  * created when it, or a directory above it, was earlier the target of `>`/`>>`, `tee`, `touch|mkdir|mktemp`, the last
266
- * argument of `cp|mv|ln|install`, an output-like option (`-o`, `--output`, `--basetemp`, `--junitxml`, `--cache-dir`…) or an
267
- * env assignment (`X=$TMPDIR/y`). Returns the read paths in first-use order (deduped), e.g. ["$TMPDIR/req.txt"].
318
+ * argument of `cp|mv|ln|install`, an output-like option (`-o`, `--output`, `--basetemp`, `--junitxml`, `--cache-dir`…), the dir argument of
319
+ * `uv venv`, `virtualenv`, `python[3] -m venv`, `git worktree add` (first) or `git clone` (last), or an env assignment (`X=$TMPDIR/y`). Returns the read paths in first-use order (deduped), e.g. ["$TMPDIR/req.txt"].
268
320
  */
269
321
  export function tmpdirInputs(command) {
270
322
  const made = [], reads = [];
@@ -273,6 +325,12 @@ export function tmpdirInputs(command) {
273
325
  const toks = seg.trim().split(/\s+/).filter(Boolean).map((t) => t.replace(/^["']+|["']+$/g, ""));
274
326
  const words = toks.filter((t) => !/^[A-Za-z_]\w*=/.test(t));
275
327
  const cmd = (words[0] ?? "").replace(/^.*\//, "");
328
+ // #5230: tools whose positional dir argument they create: the first $TMPDIR token (clone: the last token) is made.
329
+ const makesDir = (cmd === "uv" && words[1] === "venv") || cmd === "virtualenv"
330
+ || (/^python[\d.]*$/.test(cmd) && words.includes("-m") && words[words.indexOf("-m") + 1] === "venv")
331
+ || (cmd === "git" && words[1] === "worktree" && words[2] === "add");
332
+ const cloneDir = cmd === "git" && words[1] === "clone";
333
+ const firstTmp = toks.findIndex((t) => /\$(?:\{TMPDIR|TMPDIR)/.test(t));
276
334
  toks.forEach((tok, i) => {
277
335
  for (const m of tok.matchAll(TMP_PATH)) {
278
336
  const path = m[1].replace(/\/+$/, "");
@@ -281,7 +339,8 @@ export function tmpdirInputs(command) {
281
339
  const write = /\d*>>?$|&>$/.test(before) || (before === "" && /^(?:\d*>>?|&>)$/.test(prev))
282
340
  || /^[A-Za-z_]\w*=["']?$/.test(before) || (opt !== null && WRITE_OPT.test(opt))
283
341
  || cmd === "tee" || ["touch", "mkdir", "mktemp"].includes(cmd)
284
- || (["cp", "mv", "ln", "install"].includes(cmd) && i === toks.length - 1);
342
+ || (["cp", "mv", "ln", "install"].includes(cmd) && i === toks.length - 1)
343
+ || (makesDir && i === firstTmp) || (cloneDir && i === toks.length - 1);
285
344
  if (write) made.push(path);
286
345
  else if (!createdAbove(path) && !reads.includes(`$TMPDIR/${path}`)) reads.push(`$TMPDIR/${path}`);
287
346
  }
@@ -299,7 +358,10 @@ const MOCKED_RE = new RegExp(String.raw`\b${MOCKED_TERM}\b`, "i");
299
358
  // #5116: a negated mock ("do not mock", "no stubs") or a fake clock is not a substitute for the e2e check.
300
359
  const NEG_MOCK_RE = /\b(?:do(?:es)? not|don't|never|no|not|without)\s+(?:use\s+|any\s+)?(?:mock\w*|stub\w*|fake\w*)/gi;
301
360
  // #5130: a negated weakener ("do not skip the e2e suite", "e2e tests are not replaced") keeps the e2e check.
302
- const NEG_DROP_RE = /\b(?:do(?:es)? not|don't|never|not)\s+(?:be\s+|been\s+|being\s+)?(?:skip|drop|replac|swap|downgrad)\w*/gi;
361
+ const NEG_LEAD = String.raw`(?:be\s+|been\s+|being\s+|(?:going|planning|intending|about|trying)\s+to\s+|intend\w*\s+to\s+)?`;
362
+ const NEG_DROP_RE = new RegExp(String.raw`\b(?:do(?:es)? not|don't|won't|never|not)\s+${NEG_LEAD}(?:skip|drop|replac|swap|downgrad)\w*`, "gi");
363
+ // A negated omission ("will not forget to add the e2e test") is a double negative: the e2e check stays.
364
+ const NEG_OMIT_RE = new RegExp(String.raw`\b(?:do(?:es)? not|don't|won't|never|not)\s+${NEG_LEAD}(?:forget|fail|omit|neglect)\w*`, "gi");
303
365
  const FAKE_CLOCK_RE = /\bfake[- ](?:timers?|clocks?)\b/gi;
304
366
  // A weakener governs the e2e term only within a few words and the same clause (no . or ; between them).
305
367
  const GAP = String.raw`(?:[\s,]+\w+){0,5}?[\s,]+`;
@@ -311,6 +373,63 @@ const DROP_AFTER_RE = new RegExp(String.raw`\b${E2E_TERM}${GAP}(?:replaced|dropp
311
373
  const INSTEAD_OF_RE = new RegExp(String.raw`\b${MOCKED_TERM}[^.;]{0,60}?\b(?:instead of|rather than|in lieu of)\b${GAP}${E2E_TERM}\b`, "i");
312
374
  const PROBE_RE = /forge-probe|acceptance[- ]probe/i;
313
375
  const NEG_PROBE_RE = /\b(?:no|not|without|never)\b[^.;]{0,30}(?:forge-probe|acceptance[- ]probe)/i;
376
+ /**
377
+ * #5232: a `uv run --no-project --offline` command whose dependencies are a hand-picked `--with` list (no
378
+ * `--with-requirements`) cannot import a project's full dependency set; true for such a command. The environment must come
379
+ * from the repo's lockfile or toolchain (`uv run --with-requirements <export>`, the project runner, forge.yaml validate.recipes).
380
+ */
381
+ export function guessedUvEnv(command) {
382
+ const c = String(command ?? "");
383
+ return /\buv\s+run\b/.test(c) && /--no-project\b/.test(c) && /--offline\b/.test(c) && /--with(?:\s|=)/.test(c) && !/--with-requirements\b/.test(c);
384
+ }
385
+ const guessedUvProblem = (id) => `${id}: the command builds its environment from a hand-picked \`uv run --offline --no-project --with ...\` list, which cannot import the project's full dependency set (env.repro_unrunnable); derive it from the repo's lockfile or toolchain (\`--with-requirements\` of an export, the project runner, or a forge.yaml validate.recipes entry)`;
386
+ const PROJECT_DIR_RE = /^(?:\.\/)?(.+?)\/?$/;
387
+ const ARG_PATH_LIKE_RE = /\/|\.py(?:::|$)|::/;
388
+ const stripDot = (t) => String(t).replace(PROJECT_DIR_RE, "$1");
389
+ /**
390
+ * #5234: the project dir a segment moves into (`poetry -C D run ...`, `poetry --directory D`, `uv run --project D`, `uv --directory D`)
391
+ * with its token indexes, or null.
392
+ */
393
+ function projectDirOf(tokens) {
394
+ const runner = tokens.findIndex((t) => t === "poetry" || t === "uv");
395
+ if (runner < 0) return null;
396
+ const flags = tokens[runner] === "poetry" ? ["-C", "--directory"] : ["--project", "--directory"];
397
+ for (let i = runner + 1; i < tokens.length; i++) {
398
+ const t = tokens[i], eq = flags.find((f) => t.startsWith(`${f}=`));
399
+ if (eq) return { dir: stripDot(t.slice(eq.length + 1)), at: [i] };
400
+ if (flags.includes(t) && tokens[i + 1]) return { dir: stripDot(tokens[i + 1]), at: [i, i + 1] };
401
+ }
402
+ return null;
403
+ }
404
+ /**
405
+ * #5234: a frozen command that moves its cwd with `poetry -C D` / `uv run --project D` but names pytest paths relative to the
406
+ * repo root (`D/tests/x.py`), which do not exist from D: pytest exits 4. Returns {dir, paths} (the D-prefixed path args) or null.
407
+ * Pure string check, one runner segment at a time.
408
+ */
409
+ export function projectDirPathMiss(command) {
410
+ for (const seg of String(command ?? "").split(/&&|\|\||;|\|/)) {
411
+ const tokens = seg.trim().split(/\s+/), pd = projectDirOf(tokens);
412
+ const py = tokens.findIndex((t) => t === "pytest" || t === "py.test");
413
+ if (!pd || py < 0) continue;
414
+ const paths = tokens.slice(py + 1).filter((t) => !t.startsWith("-") && ARG_PATH_LIKE_RE.test(t) && stripDot(t).startsWith(`${pd.dir}/`));
415
+ if (paths.length) return { dir: pd.dir, paths };
416
+ }
417
+ return null;
418
+ }
419
+ /**
420
+ * #5234: `poetry -C D run pytest D/x.py` -> `cd D && poetry run pytest x.py` (uv: `cd D && uv run pytest x.py`) when the command is
421
+ * one segment and every path-like pytest arg is D-prefixed; any other command comes back unchanged (validateContract rejects it).
422
+ */
423
+ export function rewriteProjectDirCommand(command) {
424
+ const cmd = String(command ?? "");
425
+ if (/&&|\|\||;|\||[\n'"]/.test(cmd) || !projectDirPathMiss(cmd)) return cmd;
426
+ const tokens = cmd.trim().split(/\s+/), pd = projectDirOf(tokens), py = tokens.findIndex((t) => t === "pytest" || t === "py.test");
427
+ const like = (t) => !t.startsWith("-") && ARG_PATH_LIKE_RE.test(t);
428
+ if (tokens.slice(py + 1).some((t) => like(t) && !stripDot(t).startsWith(`${pd.dir}/`))) return cmd;
429
+ const out = tokens.map((t, i) => (i > py && like(t) ? stripDot(t).slice(pd.dir.length + 1) : t)).filter((_, i) => !pd.at.includes(i));
430
+ return `cd ${pd.dir} && ${out.join(" ")}`;
431
+ }
432
+ const projectDirProblem = (id, m) => `${id}: the command moves its cwd to \`${m.dir}\` (poetry -C / uv --project) but names repo-root-relative paths (${m.paths.map((x) => `\`${x}\``).join(", ")}) that do not exist from there, so pytest exits 4 before any test runs; use \`cd ${m.dir} && poetry run pytest <${m.dir}-relative paths>\` instead`;
314
433
  /**
315
434
  * #5087: a plan decision whose effect is to drop an e2e/integration check for mocked tests ("no Playwright e2e; integration
316
435
  * coverage via route and component tests"). The #4726 rule keys on the `[type:e2e]` tag, which a reworded criterion
@@ -323,7 +442,7 @@ export function weakenedE2eDecisions(c) {
323
442
  return decisions.filter((k) => {
324
443
  const choice = String(k?.choice ?? "");
325
444
  if (!E2E_WORD_RE.test(choice)) return false;
326
- const mocked = choice.replace(NEG_MOCK_RE, " ").replace(FAKE_CLOCK_RE, " ").replace(NEG_DROP_RE, " ");
445
+ const mocked = choice.replace(NEG_MOCK_RE, " ").replace(FAKE_CLOCK_RE, " ").replace(NEG_DROP_RE, " ").replace(NEG_OMIT_RE, " ");
327
446
  if (!MOCKED_RE.test(mocked) || !(DROP_BEFORE_RE.test(mocked) || DROP_AFTER_RE.test(mocked) || INSTEAD_OF_RE.test(mocked))) return false;
328
447
  const own = `${choice} ${k?.justification ?? ""}`;
329
448
  return !((PROBE_RE.test(own) && !NEG_PROBE_RE.test(own)) || /forge-probe/i.test(elsewhere(k?.id)));
@@ -368,6 +487,9 @@ export function validateContract(c, issueText, { repro = false } = {}) {
368
487
  const ref = movingBaseDiff(v.command);
369
488
  if (ref) problems.push(`${v.id}: \`git diff\` against the moving ${ref} tip fails as soon as the base moves on, even when the change is fine; compare against the merge base instead (\`${ref}...HEAD\` or \`$(git merge-base HEAD ${ref})\`)`);
370
489
  for (const p of tmpdirInputs(v.command)) problems.push(tmpInputProblem(v.id, p));
490
+ if (guessedUvEnv(v.command)) problems.push(guessedUvProblem(v.id));
491
+ const pdm = projectDirPathMiss(v.command);
492
+ if (pdm) problems.push(projectDirProblem(v.id, pdm));
371
493
  if (vitestQuietFlag(v.command)) problems.push(`${v.id}: vitest 3 rejects -q/--quiet (usage error before any test runs); use --reporter=dot`);
372
494
  const syn = shellSyntaxError(v.command);
373
495
  if (syn) problems.push(`${v.id}: the command is not valid shell (bash -n: ${syn}); keep notes out of the command`);
@@ -378,6 +500,9 @@ export function validateContract(c, issueText, { repro = false } = {}) {
378
500
  else if (!t || typeof t !== "object" || Array.isArray(t) || blank(t.path) || blank(t.command)) problems.push(`this is a bug: repro_test must be {"path","id","command"} (a test that fails on the base and passes after the fix) or "none" with a repro_test_reason`);
379
501
  else {
380
502
  for (const p of tmpdirInputs(t.command)) problems.push(tmpInputProblem("repro_test", p));
503
+ if (guessedUvEnv(t.command)) problems.push(guessedUvProblem("repro_test"));
504
+ const pdr = projectDirPathMiss(t.command);
505
+ if (pdr) problems.push(projectDirProblem("repro_test", pdr));
381
506
  if (vitestQuietFlag(t.command)) problems.push("repro_test: vitest 3 rejects -q/--quiet; use --reporter=dot");
382
507
  const syn = shellSyntaxError(t.command);
383
508
  if (syn) problems.push(`repro_test: the command is not valid shell (bash -n: ${syn})`);
@@ -527,8 +652,12 @@ export function applyAmendments(frozen, amendments, issueText = null, { generate
527
652
  continue;
528
653
  } else if (a.kind === "add-requirement" && a.requirement?.id && !blank(a.requirement?.quote)) {
529
654
  if (c.requirements.some((r) => r.id === a.requirement.id)) { problems.push(`add-requirement reuses id ${a.requirement.id}`); continue; }
530
- if (issueText != null && !inIssue(a.requirement.quote, issueText)) { problems.push(`add-requirement ${a.requirement.id}: quote is not verbatim from the issue`); continue; }
531
- const r = { disposition: "deliver", ...a.requirement, amended: true };
655
+ let snapTo = null;
656
+ if (issueText != null && !inIssue(a.requirement.quote, issueText)) {
657
+ snapTo = snapQuote(a.requirement.quote, issueText);
658
+ if (!snapTo) { problems.push(`add-requirement ${a.requirement.id}: quote is not verbatim from the issue`); continue; }
659
+ }
660
+ const r = { disposition: "deliver", ...a.requirement, ...(snapTo ? { quote: snapTo, requoted: a.requirement.quote } : {}), amended: true };
532
661
  if (!DISPOSITIONS.includes(r.disposition)) { problems.push(`add-requirement ${r.id}: bad disposition ${r.disposition}`); continue; }
533
662
  if (TRACKED.includes(r.disposition) && blank(r.why)) r.why = a.why;
534
663
  if (tagsOutOfBand(r)) r.verify = "out_of_band"; // #4404: same freeze-time tag as the planned requirements
@@ -674,7 +803,7 @@ export function noopCommand(command) {
674
803
  */
675
804
  export function substituteVerdict(run, { repoHas = () => false, command = "" } = {}) {
676
805
  if (!run) return "unverified";
677
- if (run.rc === 0 || run.rc === 127 || unrunnableValidate(run) || cliUsageError(run) || missingTool(run, { repoHas, command })) return "ok";
806
+ if (run.rc === 0 || run.rc === 127 || unrunnableValidate(run, command) || cliUsageError(run) || missingTool(run, { repoHas, command })) return "ok";
678
807
  return run.rc === 124 ? "timeout" : "runs";
679
808
  }
680
809
  /**
@@ -712,9 +841,11 @@ export async function removedPathsOf(git, base) {
712
841
  }
713
842
  return gone;
714
843
  }
715
- const UNRUNNABLE_RE = /no tests ran|collected 0 items|no tests found|could not find (?:the )?pyproject|poetry could not find|syntax error near|unexpected EOF while looking/i;
844
+ const UNRUNNABLE_RE = /ERROR: file or directory not found|ERROR: not found:|no tests ran|collected 0 items|no tests found|could not find (?:the )?pyproject|poetry could not find|syntax error near|unexpected EOF while looking/i;
716
845
  /** #4857: a failed rerun that died before any test ran (no tests selected, no project at the cwd, invalid shell): a defect of the frozen command. */
717
- export function unrunnableValidate({ rc, output } = {}) {
846
+ export function unrunnableValidate({ rc, output } = {}, command = "") {
847
+ // #5234: pytest's own exit 4 (usage error, path not found) and 5 (no tests collected) are never a test failure
848
+ if ((rc === 4 || rc === 5) && /\b(?:py\.?test|pytest)\b/.test(String(command ?? ""))) return true;
718
849
  return rc !== 0 && rc !== 124 && UNRUNNABLE_RE.test(String(output ?? ""));
719
850
  }
720
851
  const BLOCK_VALIDATE_RE = /\b(?:V\d+|validate|repro)\b/i;
@@ -800,7 +931,7 @@ export function repoTracks(paths) {
800
931
  * `ciCovered` (#4527): the validate ids accepted only because the head is CI-verified (no local result, or a missing host
801
932
  * tool), for the trajectory; always an array.
802
933
  */
803
- export function precheck({ contract, result, changedFiles, ignore = [], ciVerified = false, hotspots = null, repro = null, validateRuns = null, repoHas = () => false, frozen = null, checkIds = null, guardFailures = null, coupledFailures = null, routeFailures = null, newOffKeys = null, substitutedRuns = null, removedPaths = [], baseFiles = [] }) {
934
+ export function precheck({ contract, result, changedFiles, ignore = [], ciVerified = false, hotspots = null, repro = null, validateRuns = null, repoHas = () => false, frozen = null, checkIds = null, guardFailures = null, coupledFailures = null, relaxationFailures = null, routeFailures = null, newOffKeys = null, substitutedRuns = null, removedPaths = [], baseFiles = [] }) {
804
935
  const failures = [], superseded = [], ciCovered = [];
805
936
  // #4626: a post-deploy check id must be on the default branch or added by this PR (`checkIds`: ids of both checks files; null = not resolved)
806
937
  if (checkIds) for (const r of contract.requirements ?? []) {
@@ -836,7 +967,7 @@ export function precheck({ contract, result, changedFiles, ignore = [], ciVerifi
836
967
  const rerun = validateRuns?.[v.id];
837
968
  if (rerun?.rc === 0) continue;
838
969
  if (rerun && cliUsageError(rerun)) { failures.push({ code: C.CONTRACT_INVALID_COMMAND, kind: "validate_command_invalid", detail: `validate ${v.id} (\`${v.command}\`) is a CLI usage error of the runner, a defect of the frozen command rather than of the change` }); continue; }
839
- if (rerun && unrunnableValidate(rerun)) { failures.push({ code: C.CONTRACT_INVALID_COMMAND, kind: "validate_command_invalid", detail: `validate ${v.id} (\`${v.command}\`) died before any test ran (no tests selected, no project at its cwd or invalid shell), a defect of the frozen command rather than of the change; substitute a runnable equivalent with a substitute-validate amendment` }); continue; }
970
+ if (rerun && unrunnableValidate(rerun, v.command)) { failures.push({ code: C.CONTRACT_INVALID_COMMAND, kind: "validate_command_invalid", detail: `validate ${v.id} (\`${v.command}\`) died before any test ran (no tests selected, no project at its cwd or invalid shell), a defect of the frozen command rather than of the change; substitute a runnable equivalent with a substitute-validate amendment` }); continue; }
840
971
  // #4906: the rerun timed out (even after the longer retry): host load, not a verdict on the change. A CI-verified head covers it; else an environment error.
841
972
  if (rerun?.rc === 124) {
842
973
  if (ciVerified) { ciCovered.push(v.id); continue; }
@@ -870,6 +1001,7 @@ export function precheck({ contract, result, changedFiles, ignore = [], ciVerifi
870
1001
  const retired = new Set((contract.supersedes ?? []).map((s) => s.guard));
871
1002
  for (const f of guardFailures ?? []) if (!retired.has(f.guard)) failures.push(f);
872
1003
  for (const f of coupledFailures ?? []) failures.push(f); // #5079
1004
+ for (const f of relaxationFailures ?? []) failures.push(f); // #5237
873
1005
  failures.push(...(routeFailures ?? [])); // #5087: topology.route_reachability, blocking when declared
874
1006
  return { ok: failures.length === 0, failures, superseded, ciCovered };
875
1007
  }
@@ -1160,7 +1292,9 @@ export function decide(raw, ctx) {
1160
1292
  } else if (r.disposition === "deliver" && wantsE2e(r) && !e2eVerified(row, ctx.contract, ctx.e2e)) {
1161
1293
  f.push({ code: C.CONFORMANCE_E2E_UNVERIFIED, detail: `${r.id} is a [type:e2e] criterion but ${row.validated_by || "its validated_by"} is not a real end-to-end check (the repo's e2e set, Playwright/browser/live stack); run one, or mark ${r.id} post-deploy with a tracked follow-up` });
1162
1294
  }
1163
- if (TRACKED.includes(r.disposition) && row.deferral_ok === false) f.push({ code: C.CONFORMANCE_UNJUSTIFIED_DEFERRAL, detail: `${r.id} ${r.disposition} is not justified${row.note ? `: ${row.note}` : ""}; implement it` });
1295
+ // #5207: in-lane engineering work is never deferrable, whatever the reviewer says; one failure per row.
1296
+ if (inLaneDeferral(r)) f.push({ code: C.CONFORMANCE_UNJUSTIFIED_DEFERRAL, detail: `${r.id} is in-lane engineering work (bucket ${r.bucket ?? "none"}): deliver it (amend-requirement to deliver); only post-deploy, owner and external items may be deferred (#5207)` });
1297
+ else if (TRACKED.includes(r.disposition) && row.deferral_ok === false) f.push({ code: C.CONFORMANCE_UNJUSTIFIED_DEFERRAL, detail: `${r.id} ${r.disposition} is not justified${row.note ? `: ${row.note}` : ""}; implement it` });
1164
1298
  }
1165
1299
  for (const s of rv.scope) {
1166
1300
  if (!blank(s.authorized_by)) continue;
@@ -1221,7 +1355,8 @@ export function reviewSkeleton(contract, changedFiles = [], ignore = []) {
1221
1355
  }
1222
1356
 
1223
1357
  /** Requirements the reviewer accepted as deferred or post-deploy that still need a tracking issue. */
1224
- export const pendingTracking = (contract) => (contract.requirements ?? []).filter((r) => TRACKED.includes(r.disposition) && !r.tracked);
1358
+ /** #5207: in-lane engineering deferrals are never filed (decide() sends them back to the builder). */
1359
+ export const pendingTracking = (contract) => (contract.requirements ?? []).filter((r) => TRACKED.includes(r.disposition) && !r.tracked && !inLaneDeferral(r));
1225
1360
 
1226
1361
  /** #4398: an `investigate(` (or `investigate:`) issue, whose stated question must be answered before it closes as completed. */
1227
1362
  export const isInvestigation = (title) => /^\s*investigate[(:]/i.test(String(title ?? ""));
@@ -1231,16 +1366,40 @@ export const isInvestigation = (title) => /^\s*investigate[(:]/i.test(String(tit
1231
1366
  * post-deploy requirement, or a deliver requirement whose review row is not implemented, closes "partial" instead; `open`
1232
1367
  * holds those requirements (the open question, carried forward). A null review (reviewer skipped) judges dispositions only.
1233
1368
  */
1234
- export function closePlan(contract, { title = null, review = null } = {}) {
1369
+ export function closePlan(contract, { title = null, review = null, issueText = null } = {}) {
1235
1370
  const reqs = contract.requirements ?? [];
1236
1371
  const tracked = [...new Set(reqs.filter((r) => TRACKED.includes(r.disposition)).map((r) => r.tracked).filter(Boolean))];
1237
- if (!isInvestigation(title)) return { reason: "completed", tracked };
1238
1372
  const rows = Array.isArray(review?.requirements) ? review.requirements : null;
1373
+ if (!isInvestigation(title)) {
1374
+ const unticked = unmetChecklist(reqs, rows, issueText);
1375
+ return unticked.length ? { reason: "partial", tracked, checklist: true, open: unticked.map((u) => u.req), unticked: unticked.map((u) => u.item) } : { reason: "completed", tracked };
1376
+ }
1239
1377
  const open = reqs.filter((r) => TRACKED.includes(r.disposition)
1240
1378
  || (r.disposition === "deliver" && rows && rows.find((x) => x?.id === r.id)?.status !== "implemented"));
1241
1379
  return open.length ? { reason: "partial", tracked, open } : { reason: "completed", tracked };
1242
1380
  }
1243
1381
 
1382
+ const UNTICKED_RE = /^\s*[-*+]\s+\[ \]\s+(.+?)\s*$/;
1383
+ /**
1384
+ * #5240: the issue's unticked `- [ ]` acceptance items whose requirement is not settled: a deliver row the review did not mark
1385
+ * implemented, or a defer/post-deploy row with no tracking issue. An item no contract quote matches is not judged here (the
1386
+ * reviewer's issue_coverage gate owns coverage), and a skipped review (null rows) judges dispositions only.
1387
+ */
1388
+ function unmetChecklist(reqs, rows, issueText) {
1389
+ if (!issueText) return [];
1390
+ const out = [];
1391
+ for (const line of String(noComments(String(issueText))).split("\n")) {
1392
+ const item = UNTICKED_RE.exec(line)?.[1];
1393
+ if (!item) continue;
1394
+ const req = reqs.find((r) => r?.quote && matchCriterion(String(r.quote).replace(ITEM_PREFIX_RE, ""), item) !== null);
1395
+ if (!req) continue;
1396
+ const unmet = TRACKED.includes(req.disposition) ? !req.tracked
1397
+ : req.disposition === "deliver" && rows && rows.find((x) => x?.id === req.id)?.status !== "implemented";
1398
+ if (unmet) out.push({ item, req });
1399
+ }
1400
+ return out;
1401
+ }
1402
+
1244
1403
  const UNUSABLE_REVIEW = ["review.incomplete", "review.inconsistent", "review.unparseable"];
1245
1404
  /**
1246
1405
  * #4398 batch-report line from the lane rows' `conformance` ({mode, would, risk}): shadow lanes, how many the enforced
@@ -1261,7 +1420,7 @@ export function formatShadowSummary(rows) {
1261
1420
  return `conformance: ${sh.length} shadow lane${sh.length === 1 ? "" : "s"}, would block ${would} (${pct(would)}), false-block ${falseB} (${pct(falseB)}: would-block on an incomplete/inconsistent/unparseable review); risk-path enforced: ${risk}${kinds.length ? `; per kind: ${kinds.join(", ")}` : ""}`;
1262
1421
  }
1263
1422
 
1264
- /** #4664: follow-up classes, one issue each per parent (scripts/file-deferred-followups.sh); post-deploy is one rollup per release lane (#4724), external one aggregate per batch and host a `host-task` (#5078). */
1423
+ /** #4664/#5207: follow-up classes (scripts/file-deferred-followups.sh files aggregates only, never a per-parent issue): post-deploy is one rollup per release lane (#4724), external and ops one aggregate per batch, host one host-task aggregate per batch (#5078); engineering is never filed, it is built in-lane. */
1265
1424
  export const FOLLOWUP_CLASSES = ["engineering", "post-deploy", "external", "ops", "host"];
1266
1425
  /** #4724: the bucket every deferred row gets at contract time. `date:<YYYY-MM-DD>` and `owner:<action>` carry a value. */
1267
1426
  export const BUCKETS = Object.freeze(["post-deploy", "verify-now", "date", "owner", "new-issue", "host"]);
@@ -1284,11 +1443,11 @@ export function bucketProblems(r) {
1284
1443
  if (k === "owner" && r.class != null && r.class !== "external" && r.class !== "ops") out.push("an owner bucket belongs in class external or ops, never post-deploy");
1285
1444
  return out;
1286
1445
  }
1287
- /** #5078: post-promotion / production-verify / rollout text (the rollup) and read-only production data or capture (the host: the prod_monitor signals of execution.mjs plus a read-only prod query). Mirrored in scripts/file-deferred-followups.sh. */
1446
+ /** #5078: post-promotion / production-verify / rollout text (the rollup) and read-only production data or capture (the host: the prod_monitor signals of execution.mjs plus a read-only prod query). Single source: scripts/file-deferred-followups.sh routes through scripts/followup-route.mjs (#5197). */
1288
1447
  const POST_PROMOTION_RE = /(?:after|post)[- ]?(?:promotion|release|deploy)|in production after|production[- ]verif|promot(?:e|ion)|rollout|purge|deploy[- ]time/i;
1289
1448
  export const READONLY_PROD_RE = /\bssh\s+[\w.-]*-monitor\b|\bobs-psql\b|\bprod(?:uction)?[ _-]monitor\b|\bread[- ]only\b[^.]{0,40}\bprod(?:uction)?\b|\bprod(?:uction)?\b[^.]{0,30}\b(?:query|queries|capture|telemetry|logs?)\b/i;
1290
1449
  /** An item that truly needs the outside world (or a write to production) stays external even when it also reads production. */
1291
- export const EXTERNAL_NEED_RE = /credential|secret|api[- ]?key|token|password|passphrase|ssh[- ]?keys?\b|private[- ]key|\blogin\b|\bsudo\b|spend|budget|billing|purchase|payment|account|third[- ]party|vendor|customer|contract sign|legal|\b(?:delete|drop|truncate|wipe|destroy|modify|migrate|write|update|restart|rotate|remove|grant|alter)\b/i;
1450
+ export const EXTERNAL_NEED_RE = /credential|secret|api[- ]?key|token|password|passphrase|ssh[- ]?keys?\b|private[- ]key|\blogin\b|\bsudo\b|spend|budget|purchase|payment|account|third[- ]party|vendor|customer|contract sign|legal|\b(?:delete|drop|truncate|wipe|destroy|modify|migrate|write|update|restart|rotate|remove|grant|alter)\b/i;
1292
1451
  /**
1293
1452
  * #5078: where an owner deferral goes. `owner:orchestrator`, `owner:promote:*` or post-promotion text -> post-deploy (the
1294
1453
  * rollup); read-only production data or capture (with no credential/spend/account/third-party/customer need) -> host; else external (credentials, spend, an account, a third party or a customer).
@@ -1301,15 +1460,38 @@ export function ownerRoute(r) {
1301
1460
  if (POST_PROMOTION_RE.test(text) && !EXTERNAL_NEED_RE.test(text)) return "post-deploy";
1302
1461
  return READONLY_PROD_RE.test(text) && !EXTERNAL_NEED_RE.test(text) ? "host" : "external";
1303
1462
  }
1304
- /** The follow-up class of a requirement: owner -> ownerRoute (ops kept), host -> host, new-issue -> engineering, other buckets post-deploy; else its `class`, else post-deploy for that disposition, else engineering. */
1463
+ /** #5250: an acceptance criterion that can only be met by measuring live production or capturing in a real browser. */
1464
+ const LIVE_EVIDENCE_RE = /\b(?:measur\w*|capture\w*)\b[^.\n]{0,60}\b(?:production|prod|live)\b|\b(?:production|prod|live)\b[^.\n]{0,40}\b(?:measur\w*|capture\w*|clear rate|success rate|latency|traffic)\b|\breal[- ](?:browser|chrome|device)s?\b|\b(?:real|headless)[- ]browser\b[^.\n]{0,40}\bcaptures?\b/i;
1465
+ /**
1466
+ * #5250: intake triage. `{host:true, items}` when the issue's acceptance checklist is non-empty and EVERY item needs live
1467
+ * production measurement or a real-browser capture (and none needs a credential, spend or write: EXTERNAL_NEED_RE). One
1468
+ * code-shaped item keeps it a code lane. Backlog aggregates (FORGE:DEFERRED_FROM / BACKLOG_BATCH) only quote such text and are never host work.
1469
+ */
1470
+ export function intakeHostWork(body) {
1471
+ const text = String(body ?? "");
1472
+ if (/FORGE:(?:DEFERRED_FROM|BACKLOG_BATCH)/.test(text)) return { host: false, items: [] };
1473
+ const section = noComments(text).split(/^#{1,2}\s+(?=\S)/m).find((s) => /^acceptance\b/i.test(s)) ?? "";
1474
+ const items = [...section.matchAll(/^\s*[-*]\s+\[[ xX]\]\s+(.+)$/gm)].map((m) => m[1].trim());
1475
+ const host = items.length > 0 && items.every((t) => (LIVE_EVIDENCE_RE.test(t) || READONLY_PROD_RE.test(t)) && !EXTERNAL_NEED_RE.test(t));
1476
+ return { host, items: host ? items : [] };
1477
+ }
1478
+ const PRE_PROMOTION_RE = /(?:before|pre)[- ]?(?:promotion|release|deploy)/i;
1479
+ /** #5186: an explicit host deferral that is post-promotion text (and needs nothing external) joins the release rollup; work needed before promotion stays host. Single source for scripts/file-deferred-followups.sh host_route (#5197). */
1480
+ export function hostRoute(r) {
1481
+ const text = `${r?.bucket ?? ""} ${r?.why ?? ""}`;
1482
+ return POST_PROMOTION_RE.test(text) && !PRE_PROMOTION_RE.test(text) && !EXTERNAL_NEED_RE.test(text) ? "post-deploy" : "host";
1483
+ }
1484
+ /** The follow-up class of a requirement: owner -> ownerRoute (ops kept), host -> hostRoute, new-issue -> engineering (#5207: built in-lane, never filed), other buckets post-deploy; else its `class`, else post-deploy for that disposition, else engineering. */
1305
1485
  export function followupClass(r) {
1306
1486
  const k = bucketKind(r?.bucket);
1307
1487
  if (k === "owner") return r?.class === "ops" ? "ops" : ownerRoute(r);
1308
- if (k === "host") return "host";
1309
- if (k === "new-issue") return r?.class && r.class !== "post-deploy" && FOLLOWUP_CLASSES.includes(r.class) ? r.class : "engineering";
1488
+ if (k === "host") return hostRoute(r);
1489
+ if (k === "new-issue") return "engineering"; // #5207: anything this lane can build in this repo is delivered, not deferred
1310
1490
  if (k) return "post-deploy";
1311
1491
  return FOLLOWUP_CLASSES.includes(r?.class) ? r.class : r?.disposition === "post-deploy" ? "post-deploy" : "engineering";
1312
1492
  }
1493
+ /** #5207: a defer/post-deploy row that is in-lane engineering work (bucket new-issue, or no bucket and no out-of-lane class): not deliverable as a deferral. */
1494
+ export const inLaneDeferral = (r) => TRACKED.includes(r?.disposition) && followupClass(r) === "engineering";
1313
1495
  /** #4724: deferred items per bucket kind (`none` = no bucket), for the batch telemetry line. */
1314
1496
  export const bucketTally = (reqs) => (reqs ?? []).reduce((t, r) => { const k = bucketKind(r?.bucket) ?? "none"; t[k] = (t[k] ?? 0) + 1; return t; }, {});
1315
1497