forgedock 1.54.0 → 1.55.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 (114) hide show
  1. package/bin/auth/app-token.mjs +2 -0
  2. package/bin/auth/app-token.test.mjs +9 -1
  3. package/bin/engine/events.mjs +1 -0
  4. package/bin/engine/events.test.mjs +5 -1
  5. package/bin/engine/outcome-codes.mjs +3 -0
  6. package/bin/engine-cli.mjs +126 -34
  7. package/bin/forgedock.mjs +56 -4
  8. package/bin/gc-schedule.mjs +83 -0
  9. package/bin/gc.mjs +56 -8
  10. package/bin/help-text.mjs +1 -1
  11. package/bin/hooks/pre-tool-use.mjs +1 -0
  12. package/bin/init-detect.mjs +73 -2
  13. package/bin/labels.json +5 -0
  14. package/bin/lean/admission.mjs +21 -1
  15. package/bin/lean/baselines.mjs +43 -0
  16. package/bin/lean/baselines.test.mjs +33 -0
  17. package/bin/lean/batch-health.mjs +43 -6
  18. package/bin/lean/batch-health.test.mjs +41 -1
  19. package/bin/lean/batch.mjs +41 -4
  20. package/bin/lean/batch.test.mjs +106 -3
  21. package/bin/lean/conformance.mjs +131 -12
  22. package/bin/lean/conformance.test.mjs +172 -3
  23. package/bin/lean/depcache.mjs +23 -2
  24. package/bin/lean/depcache.test.mjs +22 -0
  25. package/bin/lean/docsgate.mjs +137 -0
  26. package/bin/lean/docsgate.test.mjs +78 -0
  27. package/bin/lean/effects.mjs +31 -2
  28. package/bin/lean/enumerating.mjs +39 -13
  29. package/bin/lean/enumerating.test.mjs +20 -0
  30. package/bin/lean/execution.test.mjs +3 -3
  31. package/bin/lean/fastforward.mjs +93 -0
  32. package/bin/lean/fastforward.test.mjs +73 -0
  33. package/bin/lean/guardgate.mjs +38 -7
  34. package/bin/lean/guardgate.test.mjs +39 -0
  35. package/bin/lean/issuewatch-install.mjs +92 -0
  36. package/bin/lean/issuewatch-install.test.mjs +31 -0
  37. package/bin/lean/issuewatch-parity.mjs +33 -3
  38. package/bin/lean/issuewatch-parity.test.mjs +30 -5
  39. package/bin/lean/issuewatch-reconcile.mjs +123 -0
  40. package/bin/lean/issuewatch-reconcile.test.mjs +30 -0
  41. package/bin/lean/issuewatch-verify.mjs +51 -9
  42. package/bin/lean/issuewatch.mjs +153 -33
  43. package/bin/lean/issuewatch.test.mjs +243 -22
  44. package/bin/lean/lean.mjs +381 -75
  45. package/bin/lean/lean.test.mjs +437 -20
  46. package/bin/lean/light.mjs +11 -3
  47. package/bin/lean/light.test.mjs +27 -0
  48. package/bin/lean/lightlane.mjs +8 -3
  49. package/bin/lean/lightlane.test.mjs +20 -0
  50. package/bin/lean/mechfix.mjs +35 -4
  51. package/bin/lean/mechfix.test.mjs +48 -1
  52. package/bin/lean/orchestrate-children.test.mjs +10 -0
  53. package/bin/lean/orchestrate-owned.test.mjs +73 -0
  54. package/bin/lean/orchestrate.mjs +28 -4
  55. package/bin/lean/overlap.mjs +20 -0
  56. package/bin/lean/overlap.test.mjs +49 -0
  57. package/bin/lean/pagegate.mjs +152 -0
  58. package/bin/lean/pagegate.test.mjs +77 -0
  59. package/bin/lean/parked-relabel.mjs +32 -0
  60. package/bin/lean/parked-relabel.test.mjs +45 -0
  61. package/bin/lean/phaseledger.mjs +17 -2
  62. package/bin/lean/postdeploy-check.mjs +27 -0
  63. package/bin/lean/postdeploy-check.test.mjs +13 -1
  64. package/bin/lean/postrun.mjs +32 -0
  65. package/bin/lean/postrun.test.mjs +41 -0
  66. package/bin/lean/preflight.mjs +46 -0
  67. package/bin/lean/preflight.test.mjs +30 -1
  68. package/bin/lean/prompts.mjs +36 -6
  69. package/bin/lean/recovery.test.mjs +16 -0
  70. package/bin/lean/release.mjs +30 -3
  71. package/bin/lean/release.test.mjs +36 -0
  72. package/bin/lean/render.mjs +17 -6
  73. package/bin/lean/reproquality.mjs +116 -0
  74. package/bin/lean/reproquality.test.mjs +85 -0
  75. package/bin/lean/review-trigger.mjs +8 -3
  76. package/bin/lean/sandbox-budget.test.mjs +27 -0
  77. package/bin/lean/schedd.mjs +40 -11
  78. package/bin/lean/schedd.test.mjs +12 -1
  79. package/bin/lean/testadequacy.mjs +97 -0
  80. package/bin/lean/testadequacy.test.mjs +92 -0
  81. package/bin/lean/testsandbox.mjs +202 -0
  82. package/bin/lean/testsandbox.test.mjs +157 -0
  83. package/bin/lean/toolplace.mjs +5 -2
  84. package/bin/lean/toolplace.test.mjs +6 -0
  85. package/bin/lean/verify.mjs +6 -1
  86. package/bin/lean/verify.test.mjs +18 -2
  87. package/bin/lean/warmtree.mjs +77 -0
  88. package/bin/lean/warmtree.test.mjs +81 -0
  89. package/bin/runner.mjs +6 -1
  90. package/bin/stats/conformance-outcomes.mjs +12 -2
  91. package/bin/stats/depth.mjs +24 -1
  92. package/bin/stats/depth.test.mjs +21 -1
  93. package/bin/stats/index.mjs +5 -2
  94. package/bin/stats/query.mjs +2 -1
  95. package/commands/cleanup.md +18 -0
  96. package/commands/fd-introspect.md +19 -0
  97. package/commands/milestone.md +5 -1
  98. package/commands/pipeline-health/phase-2-metrics.md +4 -0
  99. package/commands/recover-orphans.md +31 -1
  100. package/commands/review-pr-staging.md +9 -0
  101. package/commands/review-pr.md +2 -0
  102. package/docs/CI.md +1 -1
  103. package/docs/CONFIG.md +26 -1
  104. package/docs/EVENTS.md +1 -0
  105. package/docs/ISSUE-WATCH.md +12 -3
  106. package/docs/eval/adversarial-bench.md +1 -1
  107. package/docs/eval/published/adversarial-2026-11-11.md +58 -0
  108. package/package.json +1 -1
  109. package/scripts/bench-lightlane.mjs +3 -2
  110. package/scripts/hotspots.sh +7 -4
  111. package/scripts/hotspots.test.sh +12 -0
  112. package/scripts/recover-orphans-stateless.test.sh +79 -0
  113. package/scripts/transition-label.sh +2 -0
  114. package/templates/workflows/forgedock-reopen-clean.yml +33 -0
@@ -0,0 +1,157 @@
1
+ // SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
2
+ // SPDX-License-Identifier: AGPL-3.0-or-later
3
+ import { test } from "node:test";
4
+ import assert from "node:assert/strict";
5
+ import { envNamesOf, parseSandboxes, planNeeds, provisionSandboxes, sandboxFromCli, sandboxLine } from "./testsandbox.mjs";
6
+
7
+ const specs = parseSandboxes({
8
+ postgres: "{ image: postgres:16, init: \"make migrate DB_URL=$SANDBOX_URL\", ttl: 30m }",
9
+ redis: "{ image: redis:7 }",
10
+ api: "{ compose: docker-compose.test.yml, service: api, needs: [postgres, redis] }",
11
+ "http-replay": "{ fixtures: tests/fixtures/http/, for: integration }",
12
+ broken: "{ ttl: 1m }",
13
+ });
14
+ const fakeDocker = () => {
15
+ const calls = [], live = new Set();
16
+ const docker = async (a) => {
17
+ calls.push(a.join(" "));
18
+ if (a[0] === "run") live.add(a[a.indexOf("--name") + 1]);
19
+ if (a[0] === "rm") { live.delete(a[a.length - 1]); return ""; }
20
+ if (a[0] === "compose" && a.includes("up")) live.add(a[2]);
21
+ if (a[0] === "compose" && a.includes("down")) live.delete(a[2]);
22
+ if (a[0] === "port") return "127.0.0.1:55432\n";
23
+ return "";
24
+ };
25
+ return { docker, calls, live };
26
+ };
27
+ const fakeLedger = () => { const log = [], set = new Set(); return { log, set, register: (k, v) => { log.push(`register ${v}`); set.add(v); return true; }, release: (k, v) => { log.push(`release ${v}`); set.delete(v); return true; } }; };
28
+
29
+ test("parseSandboxes keeps valid entries, parses needs and drops invalid ones", () => {
30
+ assert.deepEqual(Object.keys(specs).sort(), ["api", "http-replay", "postgres", "redis"]);
31
+ assert.deepEqual(specs.api.needs, ["postgres", "redis"]);
32
+ assert.equal(specs.postgres.init, "make migrate DB_URL=$SANDBOX_URL");
33
+ assert.deepEqual(parseSandboxes(undefined), {});
34
+ });
35
+ test("envNamesOf collects unique env names across validate entries", () => {
36
+ assert.deepEqual(envNamesOf({ validate: [{ id: "V1", env: ["postgres"] }, { id: "V2", env: "postgres, redis" }, { id: "V3" }] }), ["postgres", "redis"]);
37
+ assert.deepEqual(envNamesOf({ validate: [{ id: "V1", command: "x" }] }), []);
38
+ });
39
+ test("planNeeds orders dependencies first and reports undefined names", () => {
40
+ assert.deepEqual(planNeeds(["api", "nope"], specs), { order: ["postgres", "redis", "api"], missing: ["nope"] });
41
+ });
42
+ test("a lane whose plan has no env creates nothing and never calls the provider", async () => {
43
+ const d = fakeDocker();
44
+ const r = await provisionSandboxes({ names: [], specs, lane: "lean-1", docker: d.docker, exec: async () => ({ rc: 0 }) });
45
+ assert.equal(r.ok, true);
46
+ assert.deepEqual(d.calls, []);
47
+ });
48
+ test("postgres gets a migrated throwaway DB, the test env, and nothing is left running", async () => {
49
+ const d = fakeDocker(), led = fakeLedger(), execs = [];
50
+ const r = await provisionSandboxes({ names: ["postgres"], specs, lane: "lean-5", docker: d.docker, ledger: led, labels: ["forgedock.owner=1"], exec: async (a) => { execs.push(a); return { rc: 0 }; }, sleep: async () => {} });
51
+ assert.equal(r.ok, true);
52
+ assert.equal(r.env.SANDBOX_POSTGRES_URL, "postgresql://postgres:sandbox@127.0.0.1:55432/postgres");
53
+ assert.equal(execs[0].command, "make migrate DB_URL=$SANDBOX_URL");
54
+ assert.equal(execs[0].env.SANDBOX_URL, r.env.SANDBOX_POSTGRES_URL);
55
+ assert.ok(d.calls.some((c) => c.includes("--label forgedock.owner=1") && c.includes("--name forge-sbx-lean-5-postgres")));
56
+ assert.ok(led.log.indexOf("register forge-sbx-lean-5-postgres") < d.calls.length); // registered before `docker run`
57
+ assert.equal(d.live.size, 1);
58
+ assert.match(r.lines[0], /^FORGE:SANDBOX \{"name":"postgres"/);
59
+ await r.down();
60
+ assert.equal(d.live.size, 0);
61
+ assert.equal(led.set.size, 0);
62
+ });
63
+ test("the ledger entry is written before the container exists", async () => {
64
+ const order = [], led = { register: (k, v) => order.push(`ledger ${v}`), release() {} };
65
+ const docker = async (a) => { if (a[0] === "run") order.push("run"); if (a[0] === "port") return "0.0.0.0:1\n"; return ""; };
66
+ await provisionSandboxes({ names: ["redis"], specs, lane: "lean-2", docker, ledger: led, exec: async () => ({ rc: 0 }), sleep: async () => {} });
67
+ assert.deepEqual(order, ["ledger forge-sbx-lean-2-redis", "run"]);
68
+ });
69
+ test("two lanes get distinct container names", async () => {
70
+ const names = [];
71
+ const docker = async (a) => { if (a[0] === "run") names.push(a[a.indexOf("--name") + 1]); if (a[0] === "port") return "127.0.0.1:1\n"; return ""; };
72
+ for (const lane of ["lean-1", "lean-2"]) await provisionSandboxes({ names: ["redis"], specs, lane, docker, exec: async () => ({ rc: 0 }), sleep: async () => {} });
73
+ assert.equal(new Set(names).size, 2);
74
+ });
75
+ test("an env name no entry defines is a typed unavailable result, not a skip", async () => {
76
+ const d = fakeDocker();
77
+ const r = await provisionSandboxes({ names: ["mysql"], specs, lane: "lean-1", docker: d.docker, exec: async () => ({ rc: 0 }) });
78
+ assert.equal(r.ok, false);
79
+ assert.equal(r.reason, "unknown_env");
80
+ assert.deepEqual(d.calls, []);
81
+ });
82
+ test("a host without docker is a typed no_docker result and nothing is created", async () => {
83
+ const r = await provisionSandboxes({ names: ["postgres"], specs, lane: "lean-1", docker: async () => { throw new Error("docker: command not found"); }, exec: async () => ({ rc: 0 }) });
84
+ assert.equal(r.reason, "no_docker");
85
+ });
86
+ test("a failing init tears down what was created and reports failed", async () => {
87
+ const d = fakeDocker();
88
+ const r = await provisionSandboxes({ names: ["postgres"], specs, lane: "lean-1", docker: d.docker, exec: async () => ({ rc: 2 }), sleep: async () => {} });
89
+ assert.equal(r.reason, "failed");
90
+ assert.equal(d.live.size, 0);
91
+ });
92
+ test("needs start first and compose services come up and go down", async () => {
93
+ const d = fakeDocker();
94
+ const r = await provisionSandboxes({ names: ["api"], specs, lane: "lean-9", docker: d.docker, exec: async () => ({ rc: 0 }), sleep: async () => {} });
95
+ assert.equal(r.ok, true);
96
+ const runs = d.calls.filter((c) => c.startsWith("run")).map((c) => c.match(/--name (\S+)/)[1]);
97
+ assert.deepEqual(runs, ["forge-sbx-lean-9-postgres", "forge-sbx-lean-9-redis"]);
98
+ assert.ok(d.calls.some((c) => c.startsWith("compose -p forge-sbx-lean-9-api")));
99
+ await r.down();
100
+ assert.equal(d.live.size, 0);
101
+ });
102
+ test("a fixtures entry exports the replay dir and needs no docker", async () => {
103
+ const r = await provisionSandboxes({ names: ["http-replay"], specs, lane: "lean-1", docker: async () => { throw new Error("no docker"); }, exec: async () => ({ rc: 0 }), cwd: "/work/wt" });
104
+ assert.equal(r.ok, true);
105
+ assert.equal(r.env.SANDBOX_HTTP_REPLAY_DIR, "/work/wt/tests/fixtures/http");
106
+ });
107
+ test("sandboxLine carries name, duration and cost", () => {
108
+ assert.equal(sandboxLine({ name: "redis", kind: "container", ms: 5 }), 'FORGE:SANDBOX {"name":"redis","kind":"container","ms":5,"cost_usd":0}');
109
+ });
110
+ test("forgedock sandbox up prints the env, ls lists and down removes", async () => {
111
+ const d = fakeDocker(), led = fakeLedger(), out = [];
112
+ const entries = [];
113
+ const ledger = { register: (k, v, x) => { entries.push({ value: v, ...x }); led.register(k, v); }, release: (k, v) => { const i = entries.findIndex((e) => e.value === v); if (i >= 0) entries.splice(i, 1); }, entries: () => entries, remove: () => true };
114
+ const o = (t) => out.push(t);
115
+ assert.equal(await sandboxFromCli(["up", "redis"], { specs, out: o, docker: d.docker, exec: async () => ({ rc: 0 }), ledger }), 0);
116
+ assert.ok(out.some((l) => l.startsWith("SANDBOX_REDIS_URL=redis://127.0.0.1:55432")));
117
+ out.length = 0;
118
+ await sandboxFromCli(["ls"], { specs, out: o, ledger });
119
+ assert.match(out[0], /forge-sbx-operator-redis/);
120
+ assert.equal(await sandboxFromCli(["down"], { specs, out: o, docker: d.docker, ledger }), 0);
121
+ assert.equal(d.live.size, 0);
122
+ assert.equal(await sandboxFromCli(["up"], { specs, out: o, ledger }), 2);
123
+ });
124
+
125
+ test("lanes sharing the batch image cache inspect an image once", async () => {
126
+ const { batchImageCache } = await import("./testsandbox.mjs");
127
+ batchImageCache.clear();
128
+ let inspects = 0;
129
+ const docker = async (a) => { if (a[0] === "image") inspects++; if (a[0] === "port") return "0.0.0.0:49160\n"; return ""; };
130
+ const specs = parseSandboxes({ redis: { image: "redis:7" } });
131
+ for (const lane of ["a", "b"]) {
132
+ const r = await provisionSandboxes({ names: ["redis"], specs, lane, docker, exec: async () => ({ rc: 0 }), cache: batchImageCache, sleep: async () => {} });
133
+ assert.equal(r.ok, true);
134
+ await r.down();
135
+ }
136
+ assert.equal(inspects, 1);
137
+ });
138
+
139
+ test("each lane gets its own network, joined by its containers and removed on down", async () => {
140
+ const calls = [];
141
+ const docker = async (a) => { calls.push(a.join(" ")); if (a[0] === "port") return "0.0.0.0:49161\n"; return ""; };
142
+ const specs = parseSandboxes({ redis: { image: "redis:7" } });
143
+ const r = await provisionSandboxes({ names: ["redis"], specs, lane: "lane-9", docker, exec: async () => ({ rc: 0 }), sleep: async () => {}, cache: new Set() });
144
+ assert.ok(calls.some((c) => c.startsWith("network create") && c.endsWith("forge-sbx-lane-9-net")));
145
+ assert.ok(calls.some((c) => c.startsWith("run ") && c.includes("--network forge-sbx-lane-9-net")));
146
+ await r.down();
147
+ assert.ok(calls.includes("network rm forge-sbx-lane-9-net"));
148
+ });
149
+
150
+ test("a fixtures entry exports replay mode, and record: true switches it to record", async () => {
151
+ const run = async (raw) => provisionSandboxes({ names: ["http-replay"], specs: parseSandboxes({ "http-replay": raw }), lane: "l", docker: async () => "", exec: async () => ({ rc: 0 }), cwd: "/w" });
152
+ const a = await run("{ fixtures: tests/fx/ }");
153
+ assert.equal(a.env.SANDBOX_HTTP_REPLAY_MODE, "replay");
154
+ const b = await run("{ fixtures: tests/fx/, record: true }");
155
+ assert.equal(b.env.SANDBOX_HTTP_REPLAY_MODE, "record");
156
+ assert.equal(b.env.SANDBOX_HTTP_REPLAY_DIR, "/w/tests/fx");
157
+ });
@@ -5,7 +5,7 @@
5
5
  * validate step. Pure, never throws. `toolMisses` filters the validate preflight's misses (run where the lane runs) to the
6
6
  * tools a different placement could supply; `lackedTools` names the contract's tools a target is known to lack.
7
7
  */
8
- import { preflightProbes } from "./preflight.mjs";
8
+ import { preflightProbes, declaredEnv } from "./preflight.mjs";
9
9
 
10
10
  const TOOL_KINDS = new Set(["command", "python-module", "node-module"]);
11
11
 
@@ -24,5 +24,8 @@ export function toolMisses(misses) {
24
24
  export function lackedTools(contract, lacks) {
25
25
  const lack = new Set((Array.isArray(lacks) ? lacks : lacks ? [...lacks] : []).map(String));
26
26
  if (!lack.size || !contract || typeof contract !== "object") return { tools: [], ids: [] };
27
- try { return toolMisses(preflightProbes(contract, { cap: 1000 }).probes.filter((p) => lack.has(p.tool))); } catch { return { tools: [], ids: [] }; }
27
+ try {
28
+ const declared = declaredEnv(contract).filter((t) => lack.has(t)).map((tool) => ({ kind: "command", tool, ids: ["test_plan.env"] })); // #5447
29
+ return toolMisses([...preflightProbes(contract, { cap: 1000 }).probes.filter((p) => lack.has(p.tool)), ...declared]);
30
+ } catch { return { tools: [], ids: [] }; }
28
31
  }
@@ -22,3 +22,9 @@ describe("remote tool placement (#5331)", () => {
22
22
  assert.deepEqual(lackedTools(null, ["promtool"]), { tools: [], ids: [] });
23
23
  });
24
24
  });
25
+
26
+ describe("#5447 test_plan.env", () => {
27
+ it("a declared env tool the target lacks is named", () => {
28
+ assert.deepEqual(lackedTools({ test_plan: { env: ["pytest"] }, validate: [] }, ["pytest"]), { tools: ["pytest"], ids: ["test_plan.env"] });
29
+ });
30
+ });
@@ -7,6 +7,8 @@
7
7
  */
8
8
  import { ciPollDelayMs } from "../engine.mjs";
9
9
  import { parseE2e } from "./e2e.mjs";
10
+ import { parseSandboxes } from "./testsandbox.mjs";
11
+ import { parseBaselines } from "./baselines.mjs";
10
12
 
11
13
  export const VERIFY_MODES = Object.freeze(["local", "ci", "hybrid"]);
12
14
  /** Changed files that never need the CI matrix (docs-only lanes skip CI verification). */
@@ -59,6 +61,7 @@ export function parseVerify(sec = {}) {
59
61
  const rawFlaky = Array.isArray(s.flaky) ? s.flaky : str(s.flaky).trim().replace(/^\[(.*)\]$/s, "$1").split(",");
60
62
  const flaky = [...new Set(rawFlaky.map((x) => String(x ?? "").trim().replace(/^(["'])(.*)\1$/s, "$2").trim()).filter(Boolean))];
61
63
  const duplicateExports = str(s.duplicate_exports).toLowerCase() !== "false";
64
+ const enumeratingMechanical = str(s.enumerating_mechanical).toLowerCase() !== "false"; // #5480: forge.yaml lean.enumerating.mechanical
62
65
  const invariants = [...new Set((Array.isArray(s.invariants) ? s.invariants : []).map((x) => String(x ?? "").trim()).filter(Boolean))];
63
66
  // #4792: guard_command maps an extension (`.py` or `py`) to a test-file command template; read by engine-cli readYamlMap; the key is omitted when empty so unconfigured repos parse as before
64
67
  const guardCommand = {};
@@ -68,9 +71,11 @@ export function parseVerify(sec = {}) {
68
71
  if (ext.length > 1 && cmd) guardCommand[ext] = cmd;
69
72
  }
70
73
  }
74
+ const sandboxes = parseSandboxes(s.sandboxes); // #5450: omitted when none, so unconfigured repos parse as before
75
+ const baselines = parseBaselines(s.baselines); // #5448: suites validate runs when matching paths change
71
76
  const precheckBlock = str(s.precheck_block).toLowerCase() === "true"; // #5079: a still-failing declared check stops the lane (ci.red)
72
77
  const guardBlock = str(s.guard_block).toLowerCase() !== "false"; // #5239: verify.invariants (the pre-merge guard set) block the merge unless false
73
- return { mode, workflow, pathsInput, skipPaths, maxRounds, precheckTimeoutSeconds, precheckTotalSeconds, checkRun, checks, postMerge, flaky, duplicateExports, invariants, ...(precheckBlock ? { precheckBlock } : {}), ...(guardBlock ? {} : { guardBlock: false }), ...(Object.keys(guardCommand).length ? { guardCommand } : {}), e2e: parseE2e(s) };
78
+ return { mode, workflow, pathsInput, skipPaths, maxRounds, precheckTimeoutSeconds, precheckTotalSeconds, checkRun, checks, postMerge, flaky, duplicateExports, enumeratingMechanical, invariants, ...(precheckBlock ? { precheckBlock } : {}), ...(guardBlock ? {} : { guardBlock: false }), ...(Object.keys(guardCommand).length ? { guardCommand } : {}), ...(baselines.length ? { baselines } : {}), ...(Object.keys(sandboxes).length ? { sandboxes } : {}), e2e: parseE2e(s) };
74
79
  }
75
80
 
76
81
  const globRe = (g) => new RegExp(`^${g.split("**").map((p) => p.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]")).join(".*")}$`);
@@ -33,9 +33,9 @@ describe("verify-by-CI config (#4167)", () => {
33
33
  assert.equal("guardCommand" in parseVerify({ guard_command: "nope" }), false);
34
34
  });
35
35
  it("parseVerify defaults to local and rejects invalid values", () => {
36
- assert.deepEqual(parseVerify({}), { mode: "local", workflow: null, pathsInput: null, skipPaths: [...DEFAULT_SKIP_PATHS], maxRounds: 2, precheckTimeoutSeconds: 300, precheckTotalSeconds: 600, checkRun: false, checks: null, postMerge: null, flaky: [], duplicateExports: true, invariants: [], e2e: parseE2e({}) });
36
+ assert.deepEqual(parseVerify({}), { mode: "local", workflow: null, pathsInput: null, skipPaths: [...DEFAULT_SKIP_PATHS], maxRounds: 2, precheckTimeoutSeconds: 300, precheckTotalSeconds: 600, checkRun: false, checks: null, postMerge: null, flaky: [], duplicateExports: true, enumeratingMechanical: true, invariants: [], e2e: parseE2e({}) });
37
37
  const v = parseVerify({ mode: "ci", workflow: ".github/workflows/verify.yml", paths_input: "changed_paths", skip_paths: "*.md, docs/** ,", max_rounds: "3" });
38
- assert.deepEqual(v, { mode: "ci", workflow: ".github/workflows/verify.yml", pathsInput: "changed_paths", skipPaths: ["*.md", "docs/**"], maxRounds: 3, precheckTimeoutSeconds: 300, precheckTotalSeconds: 600, checkRun: false, checks: null, postMerge: null, flaky: [], duplicateExports: true, invariants: [], e2e: parseE2e({}) });
38
+ assert.deepEqual(v, { mode: "ci", workflow: ".github/workflows/verify.yml", pathsInput: "changed_paths", skipPaths: ["*.md", "docs/**"], maxRounds: 3, precheckTimeoutSeconds: 300, precheckTotalSeconds: 600, checkRun: false, checks: null, postMerge: null, flaky: [], duplicateExports: true, enumeratingMechanical: true, invariants: [], e2e: parseE2e({}) });
39
39
  assert.equal(parseVerify({ mode: "remote" }).mode, "local");
40
40
  assert.equal(parseVerify({ workflow: "x; rm -rf /" }).workflow, null);
41
41
  assert.equal(parseVerify({ max_rounds: "-1" }).maxRounds, 2);
@@ -301,3 +301,19 @@ describe("forgedock/verify check run (#4270)", () => {
301
301
  assert.equal((await runCiVerify(g.args({ verify: parseVerify({ mode: "ci" }) }))).detail, "1 check(s) green", "its own check alone is not CI");
302
302
  });
303
303
  });
304
+
305
+ it("parseVerify reads verify.sandboxes (#5450), drops invalid entries and omits the key when none", () => {
306
+ const v = parseVerify({ sandboxes: { postgres: "{ image: postgres:16, init: \"make migrate\" }", bad: "{ ttl: 1m }" } });
307
+ assert.deepEqual(Object.keys(v.sandboxes), ["postgres"]);
308
+ assert.equal(v.sandboxes.postgres.image, "postgres:16");
309
+ assert.equal("sandboxes" in parseVerify({}), false);
310
+ assert.equal("sandboxes" in parseVerify({ sandboxes: { bad: "{ ttl: 1m }" } }), false);
311
+ });
312
+
313
+ describe("#5480 enumerating_mechanical", () => {
314
+ it("is off only for the literal false", () => {
315
+ assert.equal(parseVerify({ enumerating_mechanical: "false" }).enumeratingMechanical, false);
316
+ assert.equal(parseVerify({}).enumeratingMechanical, true);
317
+ assert.equal(parseVerify({ enumerating_mechanical: "no" }).enumeratingMechanical, true);
318
+ });
319
+ });
@@ -0,0 +1,77 @@
1
+ // SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
2
+ // SPDX-License-Identifier: AGPL-3.0-or-later
3
+ /**
4
+ * Local warm lane worktrees (#5435). Up to N detached worktrees per repo sit under `<worktreeRoot>/warm/` at a recent
5
+ * base sha (sparse plan applied, #4221). A lane claims one with `git worktree move` + `checkout -B <branch> <base sha>`
6
+ * instead of a cold `worktree add`, then checks `HEAD` against the lane base's sha: a pooled tree is never trusted for
7
+ * its content, only for its checkout cost. Any failure removes the claimed tree and returns null (cold path); nothing
8
+ * here fails a lane. Refill runs after the claim and is best effort. Opt-in: `o.warmTrees` or FORGE_LOCAL_WARM_TREES.
9
+ */
10
+ import { existsSync, mkdirSync, readFileSync, writeFileSync, rmSync } from "node:fs";
11
+ import { join } from "node:path";
12
+ import { addLaneWorktree, DEFAULT_SPARSE_MAX_KB } from "./worktree.mjs";
13
+
14
+ export const MAX_WARM_TREES = 4;
15
+
16
+ /** Pool size from the option or env; 0 (off) for anything that is not a positive integer. */
17
+ export function warmTreeCount(opt, env = process.env) {
18
+ const n = Number(opt ?? env.FORGE_LOCAL_WARM_TREES ?? 0);
19
+ return Number.isInteger(n) && n > 0 ? Math.min(MAX_WARM_TREES, n) : 0;
20
+ }
21
+
22
+ const slot = (root, i) => join(root, "warm", `warm-${i}`);
23
+ const metaOf = (p) => `${p}.json`;
24
+ const sha = async (git, cwd, ref) => String(await git(["rev-parse", "--verify", `${ref}^{commit}`], { cwd })).trim();
25
+
26
+ /** Create missing slots (or move stale ones to `ref`) up to `n`. Returns the number of slots ready. */
27
+ export async function refillWarm({ git, cwd, root, ref, n, maxBlobBytes = DEFAULT_SPARSE_MAX_KB * 1024, write }) {
28
+ let ready = 0;
29
+ const m = /^origin\/(.+)$/.exec(ref);
30
+ if (m) { try { await git(["fetch", "origin", m[1]], { cwd }); } catch { /* offline: the local ref */ } } // refresh = fetch + checkout
31
+ const want = await sha(git, cwd, ref);
32
+ mkdirSync(join(root, "warm"), { recursive: true });
33
+ for (let i = 0; i < n; i++) {
34
+ const p = slot(root, i);
35
+ try {
36
+ if (existsSync(p)) {
37
+ if (await sha(git, p, "HEAD") !== want) await git(["checkout", "--detach", "-q", want], { cwd: p });
38
+ } else {
39
+ const info = await addLaneWorktree(git, write ?? (async (f, t) => writeFileSync(f, t)), { cwd, wt: p, addArgs: ["worktree", "add", "--detach", p, want], ref: want, maxBlobBytes });
40
+ writeFileSync(metaOf(p), JSON.stringify({ sparse: info.sparse, excluded: info.excluded, bytes: info.bytes }));
41
+ }
42
+ ready++;
43
+ } catch { /* slot busy (claimed or being made by another lane) or broken: skip */ }
44
+ }
45
+ return ready;
46
+ }
47
+
48
+ /**
49
+ * Claim a warm tree as `wt` on `branch` at `base`. Returns {sparse, excluded, bytes, warm: true, sha} or null (cold path).
50
+ * The base sha is resolved here and compared with the claimed tree's HEAD, so a stale pooled tree can never reach a lane.
51
+ */
52
+ export async function claimWarm({ git, cwd, root, wt, branch, base, n }) {
53
+ if (!(n > 0)) return null;
54
+ let want;
55
+ try { want = await sha(git, cwd, base); } catch { return null; }
56
+ for (let i = 0; i < n; i++) {
57
+ const p = slot(root, i);
58
+ if (!existsSync(p)) continue;
59
+ let moved = false;
60
+ try {
61
+ await git(["worktree", "move", p, wt], { cwd }); // fails when another lane claimed it first
62
+ moved = true;
63
+ await git(["checkout", "-q", "-B", branch, want], { cwd: wt });
64
+ if (await sha(git, wt, "HEAD") !== want) throw new Error("warm tree is not at the base sha");
65
+ let meta = {};
66
+ try { meta = JSON.parse(readFileSync(metaOf(p), "utf8")); } catch { /* unknown: treated as full */ }
67
+ try { rmSync(metaOf(p), { force: true }); } catch { /* best effort */ }
68
+ return { sparse: Boolean(meta.sparse), excluded: meta.excluded ?? 0, bytes: meta.bytes ?? 0, warm: true, sha: want };
69
+ } catch {
70
+ if (moved) { try { await git(["worktree", "remove", "--force", wt], { cwd }); } catch { /* cold path cleans leftovers */ } }
71
+ }
72
+ }
73
+ return null;
74
+ }
75
+
76
+ /** #5435: env that turns off the repo's git hooks for one call (the lane checkout never needs post-checkout installers). */
77
+ export const NO_HOOKS = { GIT_CONFIG_COUNT: "1", GIT_CONFIG_KEY_0: "core.hooksPath", GIT_CONFIG_VALUE_0: "/dev/null" };
@@ -0,0 +1,81 @@
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 { execFileSync } from "node:child_process";
6
+ import { mkdirSync, writeFileSync, existsSync, readFileSync } from "node:fs";
7
+ import { join } from "node:path";
8
+ import { tmpDir } from "../tests/_tmp.mjs";
9
+ import { claimWarm, refillWarm, warmTreeCount, NO_HOOKS } from "./warmtree.mjs";
10
+
11
+ const gitSync = (args, cwd) => execFileSync("git", args, { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });
12
+ const git = async (args, { cwd } = {}) => gitSync(args, cwd);
13
+ const commit = (r, f, c) => { writeFileSync(join(r, f), c); gitSync(["add", "-A"], r); gitSync(["-c", "user.name=t", "-c", "user.email=t@t", "commit", "-qm", f], r); return gitSync(["rev-parse", "HEAD"], r).trim(); };
14
+ function fixture() {
15
+ const dir = tmpDir("wt5435-"), r = join(dir, "r"), root = join(dir, "wts");
16
+ mkdirSync(r); mkdirSync(root);
17
+ gitSync(["init", "-q", "-b", "main"], r);
18
+ return { r, root, wt: join(root, "lean-1"), first: commit(r, "a.txt", "1") };
19
+ }
20
+
21
+ describe("local warm worktrees (#5435)", () => {
22
+ it("warmTreeCount is off unless a positive integer", () => {
23
+ assert.equal(warmTreeCount(undefined, {}), 0);
24
+ assert.equal(warmTreeCount("x", {}), 0);
25
+ assert.equal(warmTreeCount(2, {}), 2);
26
+ assert.equal(warmTreeCount(undefined, { FORGE_LOCAL_WARM_TREES: "99" }), 4);
27
+ });
28
+ it("claims a warm tree on the lane branch at the base sha", async () => {
29
+ const { r, root, wt, first } = fixture();
30
+ assert.equal(await refillWarm({ git, cwd: r, root, ref: "main", n: 1 }), 1);
31
+ const got = await claimWarm({ git, cwd: r, root, wt, branch: "feat/issue-1-lean", base: "main", n: 1 });
32
+ assert.equal(got.warm, true);
33
+ assert.equal(gitSync(["rev-parse", "HEAD"], wt).trim(), first);
34
+ assert.equal(gitSync(["branch", "--show-current"], wt).trim(), "feat/issue-1-lean");
35
+ });
36
+ it("never hands out a stale base: a pooled tree behind the base is moved to the base sha", async () => {
37
+ const { r, root, wt } = fixture();
38
+ await refillWarm({ git, cwd: r, root, ref: "main", n: 1 });
39
+ const tip = commit(r, "b.txt", "2");
40
+ const got = await claimWarm({ git, cwd: r, root, wt, branch: "feat/issue-1-lean", base: "main", n: 1 });
41
+ assert.equal(got.sha, tip);
42
+ assert.equal(gitSync(["rev-parse", "HEAD"], wt).trim(), tip);
43
+ assert.equal(readFileSync(join(wt, "b.txt"), "utf8"), "2");
44
+ });
45
+ it("refill moves a stale slot to the new tip", async () => {
46
+ const { r, root } = fixture();
47
+ await refillWarm({ git, cwd: r, root, ref: "main", n: 1 });
48
+ const tip = commit(r, "b.txt", "2");
49
+ await refillWarm({ git, cwd: r, root, ref: "main", n: 1 });
50
+ assert.equal(gitSync(["rev-parse", "HEAD"], join(root, "warm", "warm-0")).trim(), tip);
51
+ });
52
+ it("returns null (cold path) with an empty pool, an unknown base or a failing move", async () => {
53
+ const { r, root, wt } = fixture();
54
+ assert.equal(await claimWarm({ git, cwd: r, root, wt, branch: "b", base: "main", n: 1 }), null);
55
+ await refillWarm({ git, cwd: r, root, ref: "main", n: 1 });
56
+ assert.equal(await claimWarm({ git, cwd: r, root, wt, branch: "b", base: "origin/nope", n: 1 }), null);
57
+ const bad = async (args, o) => { if (args[1] === "move") throw new Error("claimed elsewhere"); return git(args, o); };
58
+ assert.equal(await claimWarm({ git: bad, cwd: r, root, wt, branch: "b", base: "main", n: 1 }), null);
59
+ assert.equal(existsSync(wt), false);
60
+ });
61
+ it("a failed verification removes the claimed tree", async () => {
62
+ const { r, root, wt } = fixture();
63
+ await refillWarm({ git, cwd: r, root, ref: "main", n: 1 });
64
+ const bad = async (args, o) => { if (args[0] === "checkout") throw new Error("boom"); return git(args, o); };
65
+ assert.equal(await claimWarm({ git: bad, cwd: r, root, wt, branch: "b", base: "main", n: 1 }), null);
66
+ assert.equal(existsSync(wt), false);
67
+ });
68
+ });
69
+
70
+ describe("cold add without the post-checkout hook (#5435 R2)", () => {
71
+ it("runs the hook normally but not under NO_HOOKS", () => {
72
+ const { r, root } = fixture();
73
+ const hook = join(r, ".git", "hooks", "post-checkout");
74
+ writeFileSync(hook, `#!/bin/sh\ntouch "${root}/hook-ran"\n`, { mode: 0o755 });
75
+ const run = (wt, env) => execFileSync("git", ["worktree", "add", "-q", "-b", wt.split("/").pop(), wt, "main"], { cwd: r, env: { ...process.env, ...env } });
76
+ run(join(root, "nohook"), NO_HOOKS);
77
+ assert.equal(existsSync(join(root, "hook-ran")), false);
78
+ run(join(root, "hooked"), {});
79
+ assert.equal(existsSync(join(root, "hook-ran")), true);
80
+ });
81
+ });
package/bin/runner.mjs CHANGED
@@ -1564,8 +1564,13 @@ export const CLI_ARGV_PROMPT_MAX_BYTES = 64 * 1024;
1564
1564
  */
1565
1565
  export const CLI_ARGV_PROMPT_MAX_BYTES_WIN32 = 16 * 1024;
1566
1566
 
1567
- /** forge#4763: true when the prompt must go over stdin: prompt bytes plus the other argv bytes exceed the platform bound. */
1567
+ /**
1568
+ * forge#4763: true when the prompt must go over stdin: prompt bytes plus the other argv bytes exceed the platform bound.
1569
+ * Also when the prompt starts with `-` (e.g. a brief opening with `---` front matter): as an argv word the CLI would
1570
+ * parse it as an option and exit 1 ("unknown option '---'").
1571
+ */
1568
1572
  export function promptGoesViaStdin(prompt, otherArgs = [], platform = process.platform) {
1573
+ if (/^\s*-/.test(String(prompt ?? ""))) return true;
1569
1574
  const max = platform === "win32" ? CLI_ARGV_PROMPT_MAX_BYTES_WIN32 : CLI_ARGV_PROMPT_MAX_BYTES;
1570
1575
  const rest = platform === "win32" ? otherArgs.reduce((n, a) => n + Buffer.byteLength(String(a), "utf-8") + 1, 0) : 0;
1571
1576
  return Buffer.byteLength(String(prompt ?? ""), "utf-8") + rest > max;
@@ -19,6 +19,9 @@ export const DEFAULT_OUTCOME_MIN_N = 20;
19
19
  export const DEFAULT_WINDOW_DAYS = 7;
20
20
  export const DEFAULT_LOOKBACK_DAYS = 30;
21
21
  export const PAGE_SIZE = 100;
22
+ /** #5449: the window of the reopened-by-test-adequacy-class split. */
23
+ export const ADEQUACY_WINDOW_DAYS = 14;
24
+ export const ADEQUACY_CLASSES = ["adequate", "weak", "missing"];
22
25
  export const SIGNALS = ["reverted", "reopened", "cited", "same_hunks"];
23
26
  export const OUTCOME_INSUFFICIENT = "insufficient data";
24
27
  export const HIGHER = "nonconforming merges show a higher defect rate";
@@ -139,13 +142,17 @@ export function conformanceOutcomes({ prs = [], verdicts = new Map(), minN = DEF
139
142
  const merged = prs.filter((p) => ms(p.mergedAt) != null).sort((a, b) => ms(a.mergedAt) - ms(b.mergedAt));
140
143
  const sinceMs = ms(since);
141
144
  if (git) warmSameHunks(merged.filter((q) => isFix(q) && (sinceMs == null || ms(q.mergedAt) >= sinceMs)), git, onProgress);
142
- const rows = [];
145
+ const rows = [], adequacyRows = [];
143
146
  let unjoined = 0, pending = 0, unresolved = 0;
144
147
  for (const p of merged) {
145
148
  const t = ms(p.mergedAt);
146
149
  if (sinceMs != null && t < sinceMs) continue;
147
150
  const v = verdicts.get(`pr:${p.number}`) ?? refsOf(p).slice(1).map((i) => verdicts.get(`issue:${i}`)).find(Boolean) ?? null;
148
151
  if (!v) { unjoined++; continue; }
152
+ // #5449: a lane's test-adequacy class (v.test_adequacy) against a reopen inside 14 days, whatever windowDays is
153
+ if (ADEQUACY_CLASSES.includes(v.test_adequacy) && t + ADEQUACY_WINDOW_DAYS * DAY <= now) {
154
+ adequacyRows.push({ repo: p.repo ?? "unknown", test_adequacy: v.test_adequacy, defect: (p.closingIssues ?? []).some((i) => (i.reopenedAt ?? []).some((ts) => ms(ts) > t && ms(ts) <= t + ADEQUACY_WINDOW_DAYS * DAY)) });
155
+ }
149
156
  if (t + win > now) { pending++; continue; }
150
157
  const later = merged.filter((q) => q !== p && q.number !== p.number && (p.repo == null || q.repo == null || q.repo === p.repo) && ms(q.mergedAt) > t && ms(q.mergedAt) <= t + win);
151
158
  const signals = {
@@ -172,7 +179,8 @@ export function conformanceOutcomes({ prs = [], verdicts = new Map(), minN = DEF
172
179
  for (const m of [...new Set(rs.map((r) => r.mode ?? "unknown"))].sort()) by_mode[m] = twoByTwo(rs.filter((r) => (r.mode ?? "unknown") === m), minN);
173
180
  const by_surface = {};
174
181
  for (const sf of [...new Set(rs.flatMap((r) => r.surfaces ?? []))].sort()) by_surface[sf] = twoByTwo(rs.filter((r) => r.surfaces?.includes(sf)), minN);
175
- repos[repo] = { overall: twoByTwo(rs, minN), by_kind, by_mode, by_surface };
182
+ const by_adequacy = Object.fromEntries(ADEQUACY_CLASSES.map((c) => [c, cell(adequacyRows.filter((r) => r.repo === repo && r.test_adequacy === c), minN)]).filter(([, x]) => x.n));
183
+ repos[repo] = { overall: twoByTwo(rs, minN), by_kind, by_mode, by_surface, by_adequacy };
176
184
  }
177
185
  const overall = twoByTwo(rows, minN);
178
186
  return {
@@ -229,6 +237,8 @@ export function renderConformanceOutcomes(r) {
229
237
  for (const [repo, x] of Object.entries(r.repos)) {
230
238
  out.push("", `## ${repo}`, "", ...HEAD, row("all", x.overall), ...Object.entries(x.by_mode).map(([m, y]) => row(`mode ${m}`, y)),
231
239
  ...Object.entries(x.by_kind).map(([k, y]) => row(`kind ${k}`, y)), ...Object.entries(x.by_surface ?? {}).map(([k, y]) => row(`surface ${k}`, y)));
240
+ const adq = Object.entries(x.by_adequacy ?? {});
241
+ if (adq.length) out.push("", `reopened within ${ADEQUACY_WINDOW_DAYS}d by test-adequacy class:`, ...adq.map(([c, y]) => `- ${c}: ${fmtCell(y)}`));
232
242
  }
233
243
  if (!Object.keys(r.repos).length) out.push("", "no merged lane PR with an elapsed window");
234
244
  out.push("", `conclusion: ${r.conclusion}`);
@@ -59,6 +59,7 @@ export function depthRows(events, { repo = null, sinceMs = null, issue = null }
59
59
  if (e.event === "RUN_START") { close(); cur = { start: e, elig: null, term: null, shape: "full", attempts: [], findings: 0, conf: 0, pr: null }; continue; }
60
60
  if (!cur) continue;
61
61
  if (e.event === "LIGHT_ELIGIBILITY") cur.elig = e;
62
+ else if (e.event === "FASTFORWARD_ELIGIBILITY") cur.ff = e; // #5426
62
63
  else if (e.event === "LIGHT_DONE") cur.shape = "light";
63
64
  else if (e.event === "LIGHT_UPGRADE") cur.shape = "upgraded";
64
65
  else if (e.event === "PHASE_ATTEMPT_USAGE") cur.attempts.push(e);
@@ -75,6 +76,7 @@ export function depthRows(events, { repo = null, sinceMs = null, issue = null }
75
76
  const t = s.term;
76
77
  return { issue: Number.isSafeInteger(s.start.issue) ? s.start.issue : issue, repo: s.start.repo ?? null, startTs: s.start.ts ?? null, endTs: t.ts ?? null,
77
78
  verdict: String(s.elig.verdict ?? "unknown"), mode: s.elig.mode ?? null, reasons: codesOf(s.elig.reasons), signals: codesOf(s.elig.signals),
79
+ ff: s.ff ? { verdict: String(s.ff.verdict ?? "unknown"), eligible: s.ff.eligible === true, shadow: s.ff.shadow === true } : null,
78
80
  shape: s.shape, outcome: t.reason ?? null, merged: t.reason === "merged", needsHuman: t.reason === "needs-human",
79
81
  firstPass: firstPassOf(impl.map((a) => ({ trigger: a.trigger ?? null, restart_of: a.restart_of ?? null }))),
80
82
  cost: s.attempts.reduce((n, a) => n + (costOf(a) ?? 0), 0), wallMs: num(t.wall_ms), modelMs: num(t.model_ms),
@@ -219,6 +221,22 @@ export function recommendation(rows, defects, prom) {
219
221
  return { decision, eligible_share: r(per(elig.length, rows.length)), eligible_n: elig.length, would_be_saving_usd: saving, eligible_defect_rate: depthCell(elig, defects).defect_rate };
220
222
  }
221
223
 
224
+ /**
225
+ * #5426: fast-forward eligibility (the investigation decided the depth) and the outcomes of fast-forwarded lanes. Lanes with a
226
+ * FASTFORWARD_ELIGIBILITY event are the base; `fast_forwarded` = a non-shadow eligible lane that ended light (LIGHT_DONE),
227
+ * `upgraded` = one that fell back to the full lane. Merged lanes carry their post-merge defect and revert signals.
228
+ */
229
+ export function fastForwardReport(rows, defects = new Map()) {
230
+ const withFf = rows.filter((x) => x.ff);
231
+ const elig = withFf.filter((x) => x.ff.eligible), live = elig.filter((x) => !x.ff.shadow);
232
+ const cell = (xs) => {
233
+ const known = xs.filter((x) => x.merged && typeof defects.get(x.issue)?.revert === "boolean");
234
+ return { ...depthCell(xs, defects), reverts_n: known.length, revert_rate: known.length ? r(per(known.filter((x) => defects.get(x.issue).revert).length, known.length)) : null };
235
+ };
236
+ return { lanes: withFf.length, eligible_n: elig.length, eligibility_rate: r(per(elig.length, withFf.length)), shadow_n: withFf.filter((x) => x.ff.shadow).length,
237
+ fast_forwarded: cell(live.filter((x) => x.shape === "light")), upgraded: cell(live.filter((x) => x.shape === "upgraded")), full_lane: cell(withFf.filter((x) => !x.ff.eligible || x.ff.shadow)) };
238
+ }
239
+
222
240
  /** Pure report: per verdict, per reason/signal code, and the promotion verdict. */
223
241
  export function depthReport({ rows = [], defects = new Map(), minN = DEFAULT_MIN_N, defectsSource = "github" } = {}) {
224
242
  const byVerdict = {};
@@ -230,7 +248,7 @@ export function depthReport({ rows = [], defects = new Map(), minN = DEFAULT_MIN
230
248
  for (const code of [...new Set(rows.flatMap((x) => [...x.reasons, ...x.signals]))].sort()) byCode[code] = depthCell(rows.filter((x) => x.reasons.includes(code) || x.signals.includes(code)), defects);
231
249
  const prom = promotion(rows, defects, minN);
232
250
  const unresolved = rows.filter((x) => x.merged && defects.get(x.issue)?.defect === null).length;
233
- return { lanes: rows.length, min_n: minN, defects_source: defectsSource, defects_unresolved: unresolved, by_verdict: byVerdict, by_code: byCode, promotion: prom, recommendation: recommendation(rows, defects, prom) };
251
+ return { lanes: rows.length, min_n: minN, defects_source: defectsSource, defects_unresolved: unresolved, by_verdict: byVerdict, by_code: byCode, promotion: prom, recommendation: recommendation(rows, defects, prom), fast_forward: fastForwardReport(rows, defects) };
234
252
  }
235
253
 
236
254
  const pct = (x) => (x == null ? "n/a" : `${Math.round(x * 100)}%`);
@@ -254,6 +272,11 @@ export function renderDepth(rep, { repo = null, since = null } = {}) {
254
272
  + ` (treatment light|upgraded n=${p.n_treatment}, control eligible full n=${p.n_control}, sizes ${p.sizes.length ? p.sizes.join(",") : "none"})`);
255
273
  out.push(fmt("cost ratio", ck.cost, "x"), fmt("wall/model", ck.wall, "x"), fmt("defect rate", ck.defects, ""));
256
274
  out.push(` ${p.note}`);
275
+ const ff = rep.fast_forward;
276
+ if (ff?.lanes) {
277
+ out.push(`fast-forward (#5426, investigation decides depth): ${ff.lanes} lane(s) with an investigation verdict, eligible ${pct(ff.eligibility_rate)} (n=${ff.eligible_n}, ${ff.shadow_n} shadow)`);
278
+ for (const [k, c] of [["fast-forwarded", ff.fast_forwarded], ["upgraded to full", ff.upgraded], ["full lane", ff.full_lane]]) out.push(`${cellLine(k, c)}, reverts ${pct(c.revert_rate)} (n=${c.reverts_n})`);
279
+ }
257
280
  const rc = rep.recommendation;
258
281
  if (rc) out.push(`recommendation: ${rc.decision}; eligible share ${pct(rc.eligible_share)} (n=${rc.eligible_n}), would-be saving ${rc.would_be_saving_usd == null ? "n/a" : `$${rc.would_be_saving_usd.toFixed(2)}`} over the window, defect rate on eligible lanes ${pct(rc.eligible_defect_rate)}`);
259
282
  return out.join("\n");
@@ -13,9 +13,10 @@ const iso = (ms) => new Date(ms).toISOString();
13
13
 
14
14
  /** One synthetic RUN_START..RUN_TERMINAL slice. */
15
15
  function slice({ issue = 1, repo = "o/r", at = T0, verdict = "eligible", reasons = [], signals = ["repro"], shape = "full", reason = "merged",
16
- cost = 1, wall = 30 * MIN, model = 25 * MIN, size = "S", pr = 100 + issue, rework = false, conformance = [], verifier = 0, elig = true } = {}) {
16
+ cost = 1, wall = 30 * MIN, model = 25 * MIN, size = "S", pr = 100 + issue, rework = false, conformance = [], verifier = 0, elig = true, ff = null } = {}) {
17
17
  const ev = [{ event: "RUN_START", issue, repo, ts: iso(at) }];
18
18
  if (elig) ev.push({ event: "LIGHT_ELIGIBILITY", mode: "shadow", verdict, light: false, reasons: reasons.map((code) => ({ code, detail: "" })), signals: signals.map((code) => ({ code, detail: "" })) });
19
+ if (ff) ev.push({ event: "FASTFORWARD_ELIGIBILITY", mode: "on", verdict: ff.eligible ? "eligible" : "ineligible", light: ff.eligible && !ff.shadow, reasons: [], signals: [], ...ff });
19
20
  if (shape === "light") ev.push({ event: "LIGHT_DONE" });
20
21
  if (shape === "upgraded") ev.push({ event: "LIGHT_UPGRADE", reasons: [] });
21
22
  ev.push({ event: "PHASE_ATTEMPT_USAGE", phase: "implement", trigger: "build", cost_usd_delta: cost });
@@ -156,3 +157,22 @@ test("depthReport recommendation: decision, eligible share, would-be saving and
156
157
  assert.match(renderDepth(rep), /^recommendation: .*eligible share 75% \(n=3\), would-be saving \$3\.00/m);
157
158
  assert.equal(depthReport({ rows: [], minN: 10 }).recommendation.decision, INSUFFICIENT);
158
159
  });
160
+
161
+ test("#5426 fast-forward report: eligibility rate over lanes with an investigation verdict, outcomes of fast-forwarded merges", () => {
162
+ const rows = rowsOf({ issue: 1, shape: "light", ff: { eligible: true } }, { issue: 2, shape: "light", ff: { eligible: true } },
163
+ { issue: 3, shape: "upgraded", ff: { eligible: true }, reason: "needs-human" }, { issue: 4, ff: { eligible: false } }, { issue: 5, ff: { eligible: true, shadow: true } },
164
+ { issue: 6 });
165
+ assert.deepEqual(rows.map((x) => x.ff?.eligible ?? null), [true, true, true, false, true, null]);
166
+ const defects = new Map([[1, { defect: true, revert: true }], [2, { defect: false, revert: false }]]);
167
+ const f = depthReport({ rows, defects }).fast_forward;
168
+ assert.equal(f.lanes, 5); assert.equal(f.eligible_n, 4); assert.equal(f.eligibility_rate, 0.8); assert.equal(f.shadow_n, 1);
169
+ assert.equal(f.fast_forwarded.n, 2); assert.equal(f.fast_forwarded.merge_rate, 1);
170
+ assert.equal(f.fast_forwarded.defect_rate, 0.5); assert.equal(f.fast_forwarded.revert_rate, 0.5); assert.equal(f.fast_forwarded.reverts_n, 2);
171
+ assert.equal(f.upgraded.n, 1); assert.equal(f.upgraded.needs_human_rate, 1);
172
+ assert.equal(f.full_lane.n, 2, "ineligible and shadow lanes ran the full lane");
173
+ const text = renderDepth(depthReport({ rows, defects }));
174
+ assert.match(text, /fast-forward \(#5426.*5 lane\(s\).*eligible 80% \(n=4, 1 shadow\)/);
175
+ assert.match(text, /fast-forwarded: n=2.*reverts 50% \(n=2\)/);
176
+ assert.equal(depthReport({ rows: rowsOf({ issue: 9 }) }).fast_forward.lanes, 0);
177
+ assert.ok(!/fast-forward \(#5426/.test(renderDepth(depthReport({ rows: rowsOf({ issue: 9 }) }))), "no line without data");
178
+ });
@@ -120,7 +120,9 @@ Lane depth (forge#5209; local run logs, gh only for post-merge defect signals, n
120
120
  defects (reopen, revert, a fix PR touching the same files within 7 days), grouped by verdict and
121
121
  by every reason/signal code, plus the #5052 light-lane promotion verdict: light-shaped lanes cost
122
122
  <= 1.2x and wall <= 1.3x model time, defect rate <= eligible full lanes of the same size;
123
- "insufficient data" under --min-n per cell. --offline skips the defect crawl (n/a);
123
+ "insufficient data" under --min-n per cell. With lean.light.source: investigation (#5426) it also
124
+ reports the fast-forward eligibility rate and the outcomes (merge, defects, reverts) of
125
+ fast-forwarded, upgraded and full lanes. --offline skips the defect crawl (n/a);
124
126
  --since defaults to the last 30 days; defect results of closed windows are cached
125
127
  (--no-cache / --refresh), progress goes to stderr; the output ends with a recommendation
126
128
  (promote, do not promote, insufficient data) with eligible share and would-be saving
@@ -137,7 +139,8 @@ Conformance outcomes (forge#5210; read only: one GraphQL search per 100 merged P
137
139
  signals inside the window (reverted, closing issue reopened, cited by a later fix, a later fix
138
140
  touching the same hunks via local git blame); defect rate, n and a Wilson 95% interval of
139
141
  nonconforming-merged vs conforming-merged per repo, mode and failure kind; n/a under --min-n
140
- (default ${DEFAULT_OUTCOME_MIN_N} per cell); the last line is the conclusion or "insufficient data"
142
+ (default ${DEFAULT_OUTCOME_MIN_N} per cell); a lane's test-adequacy class (adequate|weak|missing) is also split by
143
+ reopened within 14 days (#5449); the last line is the conclusion or "insufficient data"
141
144
  --replay <pr,...> with --conformance-outcomes: per named PR, its mode, shadow verdict and risk surfaces, and whether the
142
145
  --enforce-domains <list> / --risk-paths <globs> config would have enforced (nonconforming), only flagged
143
146
  (verdict would pass) or not touched it; the cells also gain per-surface rows (domain:*, risk:*)
@@ -311,7 +311,8 @@ export function conformanceVerdicts({ records = [], runs = [], batchRows = [] }
311
311
  const c = row?.conformance;
312
312
  if (!c || typeof c !== "object") continue;
313
313
  const v = verdictOf({ mode: c.mode, would: c.would, merged: row.outcome === "merged", failures: c.kinds });
314
- if (v) put({ issue: int(row.issue), pr: int(row.pr), ...v, ts: row.ts ?? row.created ?? "", source: "batch" });
314
+ const ta = c.test_adequacy; // #5449: the lane's worst test-adequacy class, for the reopened-by-class split
315
+ if (v) put({ issue: int(row.issue), pr: int(row.pr), ...v, ...(ta && typeof ta === "object" ? { test_adequacy: ta.missing > 0 ? "missing" : ta.weak > 0 ? "weak" : "adequate" } : {}), ts: row.ts ?? row.created ?? "", source: "batch" });
315
316
  }
316
317
  for (const r of runs) {
317
318
  if (!r?.finished) continue;