forgedock 1.53.0 → 1.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +51 -0
- package/README.md +8 -2
- package/bin/auth/app-manifest.mjs +89 -0
- package/bin/auth/app-manifest.test.mjs +75 -0
- package/bin/auth/app-token.mjs +256 -0
- package/bin/auth/app-token.test.mjs +232 -0
- package/bin/brand.mjs +7 -0
- package/bin/config-history.mjs +151 -0
- package/bin/config-schema.mjs +115 -0
- package/bin/demo.mjs +65 -11
- package/bin/engine/outcome-codes.mjs +6 -3
- package/bin/engine/telemetry-seam.mjs +8 -2
- package/bin/engine/telemetry-seam.test.mjs +17 -0
- package/bin/engine-cli.mjs +57 -20
- package/bin/first-run.mjs +122 -0
- package/bin/forgedock.mjs +128 -146
- package/bin/help-text.mjs +144 -0
- package/bin/hooks/pre-tool-use.mjs +7 -0
- package/bin/journey.mjs +82 -83
- package/bin/lean/acceptance.mjs +313 -0
- package/bin/lean/acceptance.test.mjs +215 -0
- package/bin/lean/activation.mjs +18 -0
- package/bin/lean/activation.test.mjs +23 -1
- package/bin/lean/batch-health.mjs +74 -1
- package/bin/lean/batch-health.test.mjs +54 -1
- package/bin/lean/batch.test.mjs +11 -9
- package/bin/lean/branchlock.mjs +54 -0
- package/bin/lean/branchlock.test.mjs +49 -0
- package/bin/lean/ceiling.mjs +72 -0
- package/bin/lean/ceiling.test.mjs +54 -0
- package/bin/lean/ci-budget.mjs +366 -0
- package/bin/lean/ci-budget.test.mjs +167 -0
- package/bin/lean/conformance.e2e.test.mjs +7 -0
- package/bin/lean/conformance.mjs +77 -19
- package/bin/lean/conformance.test.mjs +129 -3
- package/bin/lean/context.mjs +35 -6
- package/bin/lean/context.test.mjs +27 -1
- package/bin/lean/depcache.mjs +25 -1
- package/bin/lean/depcache.test.mjs +26 -0
- package/bin/lean/e2e.mjs +18 -2
- package/bin/lean/e2e.test.mjs +26 -1
- package/bin/lean/effects.mjs +40 -11
- package/bin/lean/execution.test.mjs +24 -0
- package/bin/lean/facts.mjs +3 -3
- package/bin/lean/facts.test.mjs +5 -0
- package/bin/lean/fixround.mjs +14 -0
- package/bin/lean/fixround.test.mjs +25 -2
- package/bin/lean/gh-assoc.test.mjs +2 -1
- package/bin/lean/integration.mjs +100 -9
- package/bin/lean/integration.test.mjs +98 -0
- package/bin/lean/issuewatch-parity.mjs +64 -0
- package/bin/lean/issuewatch-parity.test.mjs +127 -0
- package/bin/lean/issuewatch-release.test.mjs +1 -1
- package/bin/lean/issuewatch.mjs +34 -5
- package/bin/lean/issuewatch.test.mjs +3 -2
- package/bin/lean/lean.mjs +316 -74
- package/bin/lean/lean.test.mjs +397 -24
- package/bin/lean/mechfix.mjs +124 -0
- package/bin/lean/mechfix.test.mjs +75 -0
- package/bin/lean/orchestrate.mjs +20 -2
- package/bin/lean/phaseledger.mjs +47 -5
- package/bin/lean/phaseledger.test.mjs +30 -1
- package/bin/lean/precheck.mjs +23 -4
- package/bin/lean/precheck.test.mjs +14 -1
- package/bin/lean/prereq.mjs +28 -0
- package/bin/lean/prereq.test.mjs +20 -0
- package/bin/lean/probe.mjs +4 -2
- package/bin/lean/prodparity.mjs +52 -0
- package/bin/lean/prodparity.test.mjs +67 -0
- package/bin/lean/prompts.mjs +69 -12
- package/bin/lean/recovery.test.mjs +1 -1
- package/bin/lean/release-io.test.mjs +42 -0
- package/bin/lean/release-postmerge.mjs +6 -0
- package/bin/lean/release-preflight.mjs +58 -0
- package/bin/lean/release-preflight.test.mjs +114 -0
- package/bin/lean/release-rehearsal.mjs +8 -7
- package/bin/lean/release-review.mjs +67 -11
- package/bin/lean/release-review.test.mjs +128 -1
- package/bin/lean/release-snapshot.mjs +188 -0
- package/bin/lean/release-snapshot.test.mjs +190 -0
- package/bin/lean/release.mjs +80 -12
- package/bin/lean/release.test.mjs +95 -0
- package/bin/lean/render.mjs +1 -1
- package/bin/lean/replan.mjs +184 -0
- package/bin/lean/replan.test.mjs +110 -0
- package/bin/lean/resume.mjs +9 -7
- package/bin/lean/resume.test.mjs +16 -0
- package/bin/lean/schedd.mjs +34 -1
- package/bin/lean/schedd.test.mjs +21 -1
- package/bin/lean/selfreview.mjs +94 -0
- package/bin/lean/selfreview.test.mjs +58 -1
- package/bin/lean/selftest-gate.mjs +22 -0
- package/bin/lean/selftest-gate.test.mjs +18 -1
- package/bin/lean/selftest-journey.mjs +234 -0
- package/bin/lean/selftest-journey.test.mjs +130 -0
- package/bin/lean/selftest-live.mjs +2 -1
- package/bin/lean/seqlease.mjs +35 -1
- package/bin/lean/seqlease.test.mjs +15 -0
- package/bin/lean/seqreserve.e2e.test.mjs +135 -0
- package/bin/lean/seqreserve.mjs +73 -0
- package/bin/lean/seqreserve.test.mjs +134 -0
- package/bin/lean/sequence.mjs +35 -6
- package/bin/lean/seqversioned.mjs +147 -0
- package/bin/lean/stagestamp.mjs +28 -0
- package/bin/lean/stagestamp.test.mjs +32 -0
- package/bin/lean/surfaces.mjs +75 -0
- package/bin/lean/surfaces.test.mjs +59 -0
- package/bin/lean/toolplace.mjs +28 -0
- package/bin/lean/toolplace.test.mjs +24 -0
- package/bin/lean/toolstats.mjs +3 -1
- package/bin/lean/toolstats.test.mjs +11 -0
- package/bin/lean/validatebest.mjs +28 -0
- package/bin/lean/validatebest.test.mjs +27 -0
- package/bin/pool/agent.mjs +9 -0
- package/bin/pool/docker.mjs +5 -0
- package/bin/pool/router.mjs +8 -4
- package/bin/prereqs.mjs +111 -0
- package/bin/replay-timelapse.mjs +149 -0
- package/bin/review-staging.mjs +100 -16
- package/bin/review-staging.test.mjs +18 -0
- package/bin/runner.mjs +43 -6
- package/bin/splash-install.mjs +157 -0
- package/bin/stats/aggregate.mjs +8 -1
- package/bin/stats/conformance-outcomes.mjs +100 -19
- package/bin/stats/conformance-outcomes.test.mjs +87 -1
- package/bin/stats/depth.mjs +88 -31
- package/bin/stats/depth.test.mjs +63 -38
- package/bin/stats/efficiency.mjs +26 -5
- package/bin/stats/efficiency.test.mjs +45 -1
- package/bin/stats/first-review.mjs +77 -0
- package/bin/stats/first-review.test.mjs +36 -0
- package/bin/stats/firstmerge.mjs +40 -0
- package/bin/stats/firstmerge.test.mjs +41 -0
- package/bin/stats/github-source.mjs +51 -13
- package/bin/stats/index.mjs +91 -15
- package/bin/stats/local-source.mjs +1 -0
- package/bin/stats/origin.mjs +80 -0
- package/bin/stats/origin.test.mjs +58 -0
- package/bin/stats/render.mjs +3 -1
- package/bin/stats/scoreboard.mjs +137 -0
- package/bin/stats/scoreboard.test.mjs +87 -0
- package/bin/stats/stats.test.mjs +80 -0
- package/bin/tui.mjs +3 -2
- package/commands/bootstrap.md +15 -14
- package/commands/deploy-pr.md +18 -3
- package/commands/forge-stats.md +1 -1
- package/commands/forgedock-ci-setup.md +28 -0
- package/commands/forgedock-init.md +4 -5
- package/commands/issue.md +2 -0
- package/commands/milestone.md +9 -1
- package/commands/replay.md +2 -0
- package/commands/review-pr-staging.md +4 -1
- package/commands/work-on/close.md +8 -0
- package/docs/CONFIG.md +105 -10
- package/docs/ISSUE-WATCH.md +23 -0
- package/docs/OUTCOME-CODES.md +1 -0
- package/docs/REPLAY.md +9 -0
- package/docs/SELFTEST.md +11 -0
- package/docs/STATS.md +19 -2
- package/docs/eval/README.md +6 -0
- package/docs/eval/adversarial-bench.md +68 -0
- package/docs/eval/corpus/adversarial-v1.json +285 -0
- package/docs/eval/feature-bench.md +42 -0
- package/docs/eval/feature-specs/crud-auth/journeys/notes-crud-isolated.mjs +21 -0
- package/docs/eval/feature-specs/crud-auth/journeys/register-login.mjs +12 -0
- package/docs/eval/feature-specs/crud-auth/spec.md +15 -0
- package/docs/site/start-a-new-project.md +2 -1
- package/package.json +5 -2
- package/plugins/forgedock-splash/.claude-plugin/plugin.json +10 -0
- package/plugins/forgedock-splash/README.md +27 -0
- package/plugins/forgedock-splash/hooks/hooks.json +1 -0
- package/plugins/forgedock-splash/hooks/register.tsx +74 -0
- package/plugins/forgedock-splash/hooks/scene.ts +222 -0
- package/plugins/forgedock-splash/types/index.d.ts +10 -0
- package/scripts/bench-adversarial.mjs +216 -0
- package/scripts/bench-feature.mjs +170 -0
- package/scripts/bench-lightlane.mjs +2 -2
- package/scripts/bootstrap-create.mjs +2 -2
- package/scripts/bootstrap-validate.mjs +35 -2
- package/scripts/check-spec-size.sh +4 -3
- package/scripts/check-spec-size.test.sh +3 -0
- package/scripts/plan-validate-live.mjs +40 -6
- package/scripts/review-pr-staging-scope.test.sh +1 -1
- package/scripts/review-staging-post.sh +23 -0
- package/scripts/review-staging-post.test.sh +8 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* bin/splash-install.mjs — default install of the forgedock-splash Claude Code
|
|
3
|
+
* plugin during `npx forgedock` setup (forge#5312).
|
|
4
|
+
*
|
|
5
|
+
* The plugin is staged, together with a generated local marketplace manifest
|
|
6
|
+
* named `forgedock-local`, into ~/.forge/splash-marketplace (the persisted
|
|
7
|
+
* toolset home, so the path survives npx cache changes). The `claude` CLI then
|
|
8
|
+
* registers that directory as a marketplace and installs the plugin at user
|
|
9
|
+
* scope. Every step is best-effort: nothing here ever throws or fails setup,
|
|
10
|
+
* and re-running setup retries and refreshes the staged copy.
|
|
11
|
+
*/
|
|
12
|
+
import { execFileSync } from "child_process";
|
|
13
|
+
import { cpSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "fs";
|
|
14
|
+
import { join } from "path";
|
|
15
|
+
import { resolveClaudeConfigDir } from "./journey.mjs";
|
|
16
|
+
|
|
17
|
+
export const SPLASH_PLUGIN = "forgedock-splash";
|
|
18
|
+
export const LOCAL_MARKETPLACE = "forgedock-local";
|
|
19
|
+
const GITHUB_MARKETPLACE = "forgedock";
|
|
20
|
+
const TURN_OFF = `turn off: /plugin disable ${SPLASH_PLUGIN}`;
|
|
21
|
+
|
|
22
|
+
export const splashStageDir = (home) => join(home, ".forge", "splash-marketplace");
|
|
23
|
+
|
|
24
|
+
/** `--no-splash` or FORGEDOCK_NO_SPLASH=1 (also FORGEDOCK_SPLASH=0/false/off) opts out. */
|
|
25
|
+
export function splashOptedOut(argv = [], env = process.env) {
|
|
26
|
+
if (argv.includes("--no-splash")) return true;
|
|
27
|
+
if (/^(1|true|yes|on)$/i.test(env.FORGEDOCK_NO_SPLASH ?? "")) return true;
|
|
28
|
+
return /^(0|false|no|off)$/i.test(env.FORGEDOCK_SPLASH ?? "");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function readJson(path) {
|
|
32
|
+
try {
|
|
33
|
+
return JSON.parse(readFileSync(path, "utf-8"));
|
|
34
|
+
} catch {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Real `claude` runner; the plugin CLI reads CLAUDE_CONFIG_DIR and HOME from env. */
|
|
40
|
+
export function defaultSplashExec(cmd, args, env = process.env) {
|
|
41
|
+
return execFileSync(cmd, args, {
|
|
42
|
+
encoding: "utf-8",
|
|
43
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
44
|
+
timeout: 60000,
|
|
45
|
+
env,
|
|
46
|
+
shell: process.platform === "win32",
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Plugin state from the user's settings.json `enabledPlugins`:
|
|
52
|
+
* "disabled" when any forgedock-splash@* entry is false, "installed" when one is true.
|
|
53
|
+
*/
|
|
54
|
+
export function splashState({ home, env = process.env }) {
|
|
55
|
+
const settings = readJson(join(resolveClaudeConfigDir(env, home), "settings.json"));
|
|
56
|
+
const entries = Object.entries(settings?.enabledPlugins ?? {}).filter(([k]) => k.startsWith(`${SPLASH_PLUGIN}@`));
|
|
57
|
+
if (entries.some(([, v]) => v === false)) return "disabled";
|
|
58
|
+
return entries.some(([, v]) => v === true) ? "installed" : "not installed";
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function knownMarketplaces(home, env) {
|
|
62
|
+
return readJson(join(resolveClaudeConfigDir(env, home), "plugins", "known_marketplaces.json")) ?? {};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** True when the already-added GitHub-backed `forgedock` marketplace lists the plugin. */
|
|
66
|
+
function githubMarketplaceHasSplash(home, env) {
|
|
67
|
+
const entry = knownMarketplaces(home, env)[GITHUB_MARKETPLACE];
|
|
68
|
+
if (!entry?.installLocation) return false;
|
|
69
|
+
const manifest = readJson(join(entry.installLocation, ".claude-plugin", "marketplace.json"));
|
|
70
|
+
return Array.isArray(manifest?.plugins) && manifest.plugins.some((p) => p?.name === SPLASH_PLUGIN);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Copy the plugin (without tests/) and a generated local marketplace manifest into ~/.forge. */
|
|
74
|
+
export function stageSplash({ pkgRoot, home }) {
|
|
75
|
+
const src = join(pkgRoot, "plugins", SPLASH_PLUGIN);
|
|
76
|
+
if (!existsSync(join(src, ".claude-plugin", "plugin.json"))) return null;
|
|
77
|
+
const stage = splashStageDir(home);
|
|
78
|
+
rmSync(stage, { recursive: true, force: true });
|
|
79
|
+
mkdirSync(join(stage, ".claude-plugin"), { recursive: true });
|
|
80
|
+
cpSync(src, join(stage, "plugins", SPLASH_PLUGIN), {
|
|
81
|
+
recursive: true,
|
|
82
|
+
filter: (p) => !/[\\/]tests([\\/]|$)/.test(p.slice(src.length)),
|
|
83
|
+
});
|
|
84
|
+
const manifest = {
|
|
85
|
+
name: LOCAL_MARKETPLACE,
|
|
86
|
+
description: "ForgeDock splash plugin, installed locally by npx forgedock.",
|
|
87
|
+
owner: { name: "RapierCraft Studios" },
|
|
88
|
+
plugins: [{ name: SPLASH_PLUGIN, source: `./plugins/${SPLASH_PLUGIN}`, description: "ForgeDock startup splash for Claude Code." }],
|
|
89
|
+
};
|
|
90
|
+
writeFileSync(join(stage, ".claude-plugin", "marketplace.json"), JSON.stringify(manifest, null, 2) + "\n");
|
|
91
|
+
return stage;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Install or refresh the splash. Returns { status, line } where status is one of
|
|
96
|
+
* opted-out | disabled | no-source | no-claude | failed | installed | already-installed.
|
|
97
|
+
* Never throws.
|
|
98
|
+
*/
|
|
99
|
+
export function installSplash({ pkgRoot, home, env = process.env, argv = [], exec = defaultSplashExec }) {
|
|
100
|
+
try {
|
|
101
|
+
if (splashOptedOut(argv, env)) return { status: "opted-out", line: "startup splash skipped (--no-splash)" };
|
|
102
|
+
const state = splashState({ home, env });
|
|
103
|
+
if (state === "disabled") {
|
|
104
|
+
return { status: "disabled", line: `startup splash left disabled re-enable: /plugin enable ${SPLASH_PLUGIN}` };
|
|
105
|
+
}
|
|
106
|
+
const stage = stageSplash({ pkgRoot, home });
|
|
107
|
+
if (!stage) return { status: "no-source", line: "" };
|
|
108
|
+
const run = (...args) => exec("claude", args, env);
|
|
109
|
+
try {
|
|
110
|
+
run("--version");
|
|
111
|
+
} catch {
|
|
112
|
+
return { status: "no-claude", line: "startup splash skipped: claude CLI not found re-run npx forgedock after installing Claude Code" };
|
|
113
|
+
}
|
|
114
|
+
let market = LOCAL_MARKETPLACE;
|
|
115
|
+
if (githubMarketplaceHasSplash(home, env)) {
|
|
116
|
+
market = GITHUB_MARKETPLACE;
|
|
117
|
+
try { run("plugin", "marketplace", "update", market); } catch { /* best-effort refresh */ }
|
|
118
|
+
} else if (LOCAL_MARKETPLACE in knownMarketplaces(home, env)) {
|
|
119
|
+
run("plugin", "marketplace", "update", market);
|
|
120
|
+
} else {
|
|
121
|
+
try {
|
|
122
|
+
run("plugin", "marketplace", "add", stage);
|
|
123
|
+
} catch {
|
|
124
|
+
run("plugin", "marketplace", "update", market); // already added under another record
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const ref = `${SPLASH_PLUGIN}@${market}`;
|
|
128
|
+
if (state === "installed") {
|
|
129
|
+
try { run("plugin", "update", ref); } catch { /* best-effort refresh */ }
|
|
130
|
+
return { status: "already-installed", line: `startup splash already installed ${TURN_OFF}` };
|
|
131
|
+
}
|
|
132
|
+
run("plugin", "install", ref, "--scope", "user");
|
|
133
|
+
return { status: "installed", line: `startup splash installed ${TURN_OFF}` };
|
|
134
|
+
} catch (err) {
|
|
135
|
+
const why = String(err?.stderr || err?.message || err).split("\n")[0].slice(0, 120);
|
|
136
|
+
return { status: "failed", line: `startup splash skipped: ${why} re-run npx forgedock to retry` };
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Remove the plugin and the local marketplace this installer added. Never throws. */
|
|
141
|
+
export function uninstallSplash({ home, env = process.env, exec = defaultSplashExec }) {
|
|
142
|
+
const lines = [];
|
|
143
|
+
const stage = splashStageDir(home);
|
|
144
|
+
const hadLocal = LOCAL_MARKETPLACE in knownMarketplaces(home, env) || existsSync(stage);
|
|
145
|
+
if (!hadLocal) return { removed: false, lines };
|
|
146
|
+
const run = (...args) => exec("claude", args, env);
|
|
147
|
+
let cli = true;
|
|
148
|
+
try { run("--version"); } catch { cli = false; }
|
|
149
|
+
if (cli) {
|
|
150
|
+
try { run("plugin", "uninstall", `${SPLASH_PLUGIN}@${LOCAL_MARKETPLACE}`); lines.push("Removed startup splash plugin"); } catch { /* not installed */ }
|
|
151
|
+
try { run("plugin", "marketplace", "remove", LOCAL_MARKETPLACE); lines.push(`Removed ${LOCAL_MARKETPLACE} marketplace`); } catch { /* not added */ }
|
|
152
|
+
} else {
|
|
153
|
+
lines.push(`claude CLI not found: run /plugin uninstall ${SPLASH_PLUGIN}@${LOCAL_MARKETPLACE} manually`);
|
|
154
|
+
}
|
|
155
|
+
try { rmSync(stage, { recursive: true, force: true }); } catch { /* best-effort */ }
|
|
156
|
+
return { removed: true, lines };
|
|
157
|
+
}
|
package/bin/stats/aggregate.mjs
CHANGED
|
@@ -109,9 +109,16 @@ function flowSection(runs) {
|
|
|
109
109
|
for (const r of runs) if (r.code) { codes[r.code] = (codes[r.code] ?? 0) + 1; coded++; }
|
|
110
110
|
const top = Object.entries(codes).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))
|
|
111
111
|
.map(([code, count]) => ({ code, count, pct: count / coded }));
|
|
112
|
+
// #5339: verified = merged with no transferred or unverified requirement; an older run without the field counts as verified
|
|
113
|
+
const merged = runs.filter((r) => r.reason === "merged");
|
|
114
|
+
const isVerified = (r) => r.verified !== false;
|
|
115
|
+
const ms = new Map();
|
|
116
|
+
for (const r of merged) { const k = r.milestone ?? "(none)"; const g = ms.get(k) ?? { milestone: k, merged: 0, verified: 0 }; g.merged++; if (isVerified(r)) g.verified++; ms.set(k, g); }
|
|
112
117
|
return {
|
|
113
118
|
n,
|
|
114
|
-
mergedPct: ratio(
|
|
119
|
+
mergedPct: ratio(merged.length, n),
|
|
120
|
+
verifiedPct: ratio(merged.filter(isVerified).length, n),
|
|
121
|
+
milestones: [...ms.values()].sort((a, b) => a.milestone.localeCompare(b.milestone)),
|
|
115
122
|
needsHumanPct: ratio(runs.filter((r) => r.reason === "needs-human").length, n),
|
|
116
123
|
remediationPct: ratio(runs.filter((r) => r.remediated).length, n),
|
|
117
124
|
codesN: coded, codes: top,
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
* and a Wilson 95% interval; a cell under min n prints n/a. Read only: GitHub reads are one GraphQL search per page of 100
|
|
14
14
|
* merged PRs, no writes. The report core is pure; `gatherConformanceOutcomes` supplies the GitHub and git inputs.
|
|
15
15
|
*/
|
|
16
|
+
import { pathDomains, riskClassOf, riskPathHits, parseEnforceDomains, parseRiskPaths } from "../lean/review-trigger.mjs";
|
|
17
|
+
|
|
16
18
|
export const DEFAULT_OUTCOME_MIN_N = 20;
|
|
17
19
|
export const DEFAULT_WINDOW_DAYS = 7;
|
|
18
20
|
export const DEFAULT_LOOKBACK_DAYS = 30;
|
|
@@ -56,7 +58,7 @@ function twoByTwo(rows, minN) {
|
|
|
56
58
|
const refsOf = (p) => [p.number, ...(p.closingIssues ?? []).map((i) => i.number)].filter((x) => Number.isSafeInteger(x));
|
|
57
59
|
const text = (q) => `${q.title ?? ""}\n${q.body ?? ""}`;
|
|
58
60
|
const isRevert = (q) => /^revert\b/i.test(q.title ?? "");
|
|
59
|
-
const isFix = (q) => /^(fix|hotfix|bugfix)\b/i.test(q.title ?? "") || /^revert\b/i.test(q.title ?? "");
|
|
61
|
+
export const isFix = (q) => /^(fix|hotfix|bugfix)\b/i.test(q.title ?? "") || /^revert\b/i.test(q.title ?? "");
|
|
60
62
|
|
|
61
63
|
/** True when a later PR `q` reverts `p`. */
|
|
62
64
|
export function reverts(q, p, repo) {
|
|
@@ -77,22 +79,52 @@ export function cites(q, p) {
|
|
|
77
79
|
return false;
|
|
78
80
|
}
|
|
79
81
|
|
|
82
|
+
const blameMemo = new WeakMap();
|
|
83
|
+
|
|
84
|
+
/** Merge shas that a fix PR's old-side lines blame to, computed once per fix sha per git probe object (#5372); null when unresolved. */
|
|
85
|
+
function blamedBy(q, git) {
|
|
86
|
+
let memo = blameMemo.get(git);
|
|
87
|
+
if (!memo) blameMemo.set(git, (memo = new Map()));
|
|
88
|
+
if (memo.has(q.mergeSha)) return memo.get(q.mergeSha);
|
|
89
|
+
const ranges = q.mergeSha ? git.oldRanges(q.mergeSha) : null;
|
|
90
|
+
let entry = null;
|
|
91
|
+
if (ranges) {
|
|
92
|
+
entry = { shas: new Set(), unresolved: false };
|
|
93
|
+
for (const r of ranges) {
|
|
94
|
+
const shas = git.blame(`${q.mergeSha}^`, r.file, r.start, r.end);
|
|
95
|
+
if (shas == null) { entry.unresolved = true; continue; }
|
|
96
|
+
for (const s of shas) entry.shas.add(s);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
memo.set(q.mergeSha, entry);
|
|
100
|
+
return entry;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Blame each fix PR once up front, reporting {phase: "same-hunks", done, total, etaMs} so a long run is not silent. */
|
|
104
|
+
export function warmSameHunks(fixes, git, onProgress, now = Date.now) {
|
|
105
|
+
const todo = fixes.filter((q) => q.mergeSha);
|
|
106
|
+
const t0 = now();
|
|
107
|
+
todo.forEach((q, i) => {
|
|
108
|
+
blamedBy(q, git);
|
|
109
|
+
const done = i + 1;
|
|
110
|
+
onProgress?.({ phase: "same-hunks", done, total: todo.length, etaMs: done < todo.length ? ((now() - t0) / done) * (todo.length - done) : 0 });
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
80
114
|
/**
|
|
81
115
|
* Same-hunks: a later fix PR whose old-side lines blame to `p`'s merge commit. true on a hit, false when every later fix PR
|
|
82
|
-
* resolved without one (or there is none), null when git is missing or a needed probe could not resolve.
|
|
116
|
+
* resolved without one (or there is none), null when git is missing or a needed probe could not resolve. Each fix PR is
|
|
117
|
+
* blamed once per git probe object, not once per lane PR.
|
|
83
118
|
*/
|
|
84
119
|
export function sameHunks(p, laterFixes, git) {
|
|
85
120
|
if (!laterFixes.length) return false;
|
|
86
121
|
if (!git || !p.mergeSha) return null;
|
|
87
122
|
let unresolved = false;
|
|
88
123
|
for (const q of laterFixes) {
|
|
89
|
-
const
|
|
90
|
-
if (!
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (shas == null) { unresolved = true; continue; }
|
|
94
|
-
if (shas.includes(p.mergeSha)) return true;
|
|
95
|
-
}
|
|
124
|
+
const entry = blamedBy(q, git);
|
|
125
|
+
if (!entry) { unresolved = true; continue; }
|
|
126
|
+
if (entry.shas.has(p.mergeSha)) return true;
|
|
127
|
+
if (entry.unresolved) unresolved = true;
|
|
96
128
|
}
|
|
97
129
|
return unresolved ? null : false;
|
|
98
130
|
}
|
|
@@ -102,10 +134,11 @@ export function sameHunks(p, laterFixes, git) {
|
|
|
102
134
|
* verdicts: Map from conformanceVerdicts (keys pr:N, issue:N). A PR whose window has not elapsed by `now` is pending and left
|
|
103
135
|
* out of the cells. A PR with no verdict is not a lane PR.
|
|
104
136
|
*/
|
|
105
|
-
export function conformanceOutcomes({ prs = [], verdicts = new Map(), minN = DEFAULT_OUTCOME_MIN_N, windowDays = DEFAULT_WINDOW_DAYS, now = Date.now(), git = null, graphqlCalls = null, since = null }) {
|
|
137
|
+
export function conformanceOutcomes({ prs = [], verdicts = new Map(), minN = DEFAULT_OUTCOME_MIN_N, windowDays = DEFAULT_WINDOW_DAYS, now = Date.now(), git = null, graphqlCalls = null, since = null, surfacesOf = surfacesOfFiles, onProgress = null }) {
|
|
106
138
|
const win = windowDays * DAY;
|
|
107
139
|
const merged = prs.filter((p) => ms(p.mergedAt) != null).sort((a, b) => ms(a.mergedAt) - ms(b.mergedAt));
|
|
108
140
|
const sinceMs = ms(since);
|
|
141
|
+
if (git) warmSameHunks(merged.filter((q) => isFix(q) && (sinceMs == null || ms(q.mergedAt) >= sinceMs)), git, onProgress);
|
|
109
142
|
const rows = [];
|
|
110
143
|
let unjoined = 0, pending = 0, unresolved = 0;
|
|
111
144
|
for (const p of merged) {
|
|
@@ -123,7 +156,7 @@ export function conformanceOutcomes({ prs = [], verdicts = new Map(), minN = DEF
|
|
|
123
156
|
};
|
|
124
157
|
if (signals.same_hunks === null) unresolved++;
|
|
125
158
|
rows.push({ repo: p.repo ?? null, pr: p.number, issue: v.issue ?? null, merged_at: p.mergedAt, mode: v.mode ?? null, state: v.state, kinds: v.kinds ?? [],
|
|
126
|
-
source: v.source ?? null, signals, defect: SIGNALS.some((s) => signals[s] === true) });
|
|
159
|
+
source: v.source ?? null, signals, defect: SIGNALS.some((s) => signals[s] === true), ...(p.files?.length ? { surfaces: surfacesOf(p.files) } : {}) });
|
|
127
160
|
}
|
|
128
161
|
const repos = {};
|
|
129
162
|
for (const repo of [...new Set(rows.map((r) => r.repo ?? "unknown"))].sort()) {
|
|
@@ -137,7 +170,9 @@ export function conformanceOutcomes({ prs = [], verdicts = new Map(), minN = DEF
|
|
|
137
170
|
}
|
|
138
171
|
const by_mode = {};
|
|
139
172
|
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);
|
|
140
|
-
|
|
173
|
+
const by_surface = {};
|
|
174
|
+
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 };
|
|
141
176
|
}
|
|
142
177
|
const overall = twoByTwo(rows, minN);
|
|
143
178
|
return {
|
|
@@ -147,6 +182,41 @@ export function conformanceOutcomes({ prs = [], verdicts = new Map(), minN = DEF
|
|
|
147
182
|
};
|
|
148
183
|
}
|
|
149
184
|
|
|
185
|
+
/** #5283: the risk surfaces a PR's files touch: `domain:<d>` (review-roster path rules) and `risk:<class>` (built-in risk words). */
|
|
186
|
+
export function surfacesOfFiles(files = []) {
|
|
187
|
+
const domains = pathDomains(files) ?? [];
|
|
188
|
+
const classes = files.map(riskClassOf).filter(Boolean);
|
|
189
|
+
return [...new Set([...domains.map((d) => `domain:${d}`), ...classes.map((c) => `risk:${c}`)])].sort();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* #5283: replay named PRs against a would-be enforcement config (review.enforce_domains / review.risk_paths), window-free.
|
|
194
|
+
* Per PR: `enforced` = a configured surface was hit and the shadow verdict is nonconforming (the lane would block);
|
|
195
|
+
* `flagged` = a configured surface was hit but the verdict would pass (enforce cannot block a passing review);
|
|
196
|
+
* `none` = no configured surface hit. `missing` lists numbers not among `prs`.
|
|
197
|
+
*/
|
|
198
|
+
export function replayPrs({ prs = [], verdicts = new Map(), numbers = [], enforceDomains = [], riskPaths = [], surfacesOf = surfacesOfFiles }) {
|
|
199
|
+
const doms = parseEnforceDomains(enforceDomains), globs = parseRiskPaths(riskPaths);
|
|
200
|
+
const rows = [], missing = [];
|
|
201
|
+
for (const n of numbers) {
|
|
202
|
+
const p = prs.find((x) => x.number === n);
|
|
203
|
+
if (!p) { missing.push(n); continue; }
|
|
204
|
+
const v = verdicts.get(`pr:${n}`) ?? (p.closingIssues ?? []).map((i) => verdicts.get(`issue:${i.number}`)).find(Boolean) ?? null;
|
|
205
|
+
const surfaces = surfacesOf(p.files ?? []);
|
|
206
|
+
const hits = [...surfaces.filter((s) => s.startsWith("domain:") && doms.includes(s.slice(7))), ...riskPathHits(p.files ?? [], globs).map((f) => `path:${f}`)];
|
|
207
|
+
const state = v?.state ?? null;
|
|
208
|
+
rows.push({ repo: p.repo ?? null, pr: n, mode: v?.mode ?? null, state, surfaces, hits, outcome: !hits.length ? "none" : state === "nonconforming" ? "enforced" : "flagged" });
|
|
209
|
+
}
|
|
210
|
+
return { enforce_domains: doms, risk_paths: globs, prs: rows, missing };
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export function renderReplay(r) {
|
|
214
|
+
const out = [`replay (enforce_domains: ${r.enforce_domains.join(",") || "-"}; risk_paths: ${r.risk_paths.join(",") || "-"})`, "", "| PR | mode | shadow verdict | surfaces | outcome |", "|---|---|---|---|---|",
|
|
215
|
+
...r.prs.map((x) => `| #${x.pr} | ${x.mode ?? "n/a"} | ${x.state ?? "no verdict"} | ${x.surfaces.join(", ") || "-"} | ${x.outcome} |`)];
|
|
216
|
+
if (r.missing.length) out.push("", `not found in the fetched PRs (widen --since): ${r.missing.map((n) => `#${n}`).join(", ")}`);
|
|
217
|
+
return out.join("\n");
|
|
218
|
+
}
|
|
219
|
+
|
|
150
220
|
const pct = (x) => (x == null ? "n/a" : `${Math.round(x * 1000) / 10}%`);
|
|
151
221
|
const fmtCell = (c) => `${c.defects}/${c.n} ${pct(c.rate)}${c.interval ? ` [${pct(c.interval[0])}, ${pct(c.interval[1])}]` : ""}`;
|
|
152
222
|
const row = (label, x) => `| ${label} | ${fmtCell(x.nonconforming)} | ${fmtCell(x.conforming)} | ${x.conclusion} |`;
|
|
@@ -158,7 +228,7 @@ export function renderConformanceOutcomes(r) {
|
|
|
158
228
|
+ `, same-hunks ${s.git ? `${s.same_hunks_unresolved} unresolved` : "n/a (no local clone of the repo)"}${s.graphql_calls != null ? `, ${s.graphql_calls} GraphQL call(s)` : ""}`];
|
|
159
229
|
for (const [repo, x] of Object.entries(r.repos)) {
|
|
160
230
|
out.push("", `## ${repo}`, "", ...HEAD, row("all", x.overall), ...Object.entries(x.by_mode).map(([m, y]) => row(`mode ${m}`, y)),
|
|
161
|
-
...Object.entries(x.by_kind).map(([k, y]) => row(`kind ${k}`, y)));
|
|
231
|
+
...Object.entries(x.by_kind).map(([k, y]) => row(`kind ${k}`, y)), ...Object.entries(x.by_surface ?? {}).map(([k, y]) => row(`surface ${k}`, y)));
|
|
162
232
|
}
|
|
163
233
|
if (!Object.keys(r.repos).length) out.push("", "no merged lane PR with an elapsed window");
|
|
164
234
|
out.push("", `conclusion: ${r.conclusion}`);
|
|
@@ -168,15 +238,19 @@ export function renderConformanceOutcomes(r) {
|
|
|
168
238
|
const QUERY = `query($q: String!, $first: Int!, $after: String) {
|
|
169
239
|
search(type: ISSUE, query: $q, first: $first, after: $after) {
|
|
170
240
|
pageInfo { hasNextPage endCursor }
|
|
171
|
-
nodes { ... on PullRequest { number title body mergedAt mergeCommit { oid } repository { nameWithOwner }
|
|
241
|
+
nodes { ... on PullRequest { number title body mergedAt mergeCommit { oid } repository { nameWithOwner } files(first: 100) { nodes { path } }
|
|
172
242
|
closingIssuesReferences(first: 10) { nodes { number timelineItems(itemTypes: [REOPENED_EVENT], first: 10) { nodes { ... on ReopenedEvent { createdAt } } } } } } }
|
|
173
243
|
}
|
|
174
244
|
}`;
|
|
175
245
|
|
|
246
|
+
/** Sorted unique PR and closing-issue numbers of `prs`: the only items whose telemetry the report needs (#5363). */
|
|
247
|
+
export const joinedNumbers = (prs = []) => [...new Set(prs.flatMap(refsOf))].sort((a, b) => a - b);
|
|
248
|
+
|
|
176
249
|
/** One GraphQL search page -> normalized PRs. */
|
|
177
250
|
export function prsOfPage(data, repo) {
|
|
178
251
|
return (data?.data?.search?.nodes ?? []).filter((n) => Number.isSafeInteger(n?.number) && n.mergedAt).map((n) => ({
|
|
179
252
|
repo: n.repository?.nameWithOwner ?? repo, number: n.number, title: n.title ?? "", body: n.body ?? "", mergedAt: n.mergedAt, mergeSha: n.mergeCommit?.oid ?? null,
|
|
253
|
+
files: (n.files?.nodes ?? []).map((f) => f?.path).filter(Boolean),
|
|
180
254
|
closingIssues: (n.closingIssuesReferences?.nodes ?? []).filter((i) => Number.isSafeInteger(i?.number))
|
|
181
255
|
.map((i) => ({ number: i.number, reopenedAt: (i.timelineItems?.nodes ?? []).map((e) => e?.createdAt).filter(Boolean) })),
|
|
182
256
|
}));
|
|
@@ -187,16 +261,23 @@ export function prsOfPage(data, repo) {
|
|
|
187
261
|
* reverts and fixes inside the window are in the candidate set. Exactly one `gh api graphql` search call per page of 100 PRs.
|
|
188
262
|
* GitHub search returns at most 1000 results: `capped` reports when that bound was hit.
|
|
189
263
|
*/
|
|
264
|
+
const MIN_PAGE_SIZE = 25;
|
|
190
265
|
export async function gatherConformanceOutcomes({ repo, gh, since = null, now = Date.now() }) {
|
|
191
266
|
const from = (since ? new Date(ms(since) ?? now - DEFAULT_LOOKBACK_DAYS * DAY) : new Date(now - DEFAULT_LOOKBACK_DAYS * DAY)).toISOString().slice(0, 10);
|
|
192
267
|
const q = `repo:${repo} is:pr is:merged merged:>=${from}`;
|
|
193
268
|
const prs = [];
|
|
194
|
-
let after = null, calls = 0, capped = false;
|
|
269
|
+
let after = null, calls = 0, capped = false, size = PAGE_SIZE;
|
|
195
270
|
for (;;) {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
271
|
+
let data;
|
|
272
|
+
for (;;) { // #5363: a 502/timeout retries the same cursor with half the page (100 -> 50 -> 25), then fails
|
|
273
|
+
const args = ["api", "graphql", "-f", `query=${QUERY}`, "-f", `q=${q}`, "-F", `first=${size}`, ...(after ? ["-f", `after=${after}`] : [])];
|
|
274
|
+
calls++;
|
|
275
|
+
try { data = JSON.parse(String(await gh(args) ?? "").trim() || "{}"); break; } catch (err) {
|
|
276
|
+
if (!/\b50[234]\b|bad gateway|timed? ?out|timeout|ETIMEDOUT/i.test(String(err?.message ?? err))) throw err;
|
|
277
|
+
if (size <= MIN_PAGE_SIZE) throw new Error(`GitHub keeps failing the PR search at first=${size} (${String(err?.message ?? err).split("\n")[0]}); retry with a narrower --since`);
|
|
278
|
+
size = Math.max(MIN_PAGE_SIZE, Math.floor(size / 2));
|
|
279
|
+
}
|
|
280
|
+
}
|
|
200
281
|
if (Array.isArray(data.errors) && data.errors.length && !data.data) throw new Error(`GraphQL: ${data.errors.map((e) => e?.message).join("; ")}`);
|
|
201
282
|
prs.push(...prsOfPage(data, repo));
|
|
202
283
|
const pi = data?.data?.search?.pageInfo;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
3
|
import { describe, it } from "node:test";
|
|
4
4
|
import assert from "node:assert/strict";
|
|
5
|
-
import { conformanceOutcomes, gatherConformanceOutcomes, renderConformanceOutcomes, wilson, cites, reverts, sameHunks, OUTCOME_INSUFFICIENT, HIGHER, NOT_HIGHER, DEFAULT_OUTCOME_MIN_N } from "./conformance-outcomes.mjs";
|
|
5
|
+
import { conformanceOutcomes, gatherConformanceOutcomes, renderConformanceOutcomes, replayPrs, renderReplay, prsOfPage, joinedNumbers, wilson, cites, reverts, sameHunks, warmSameHunks, OUTCOME_INSUFFICIENT, HIGHER, NOT_HIGHER, DEFAULT_OUTCOME_MIN_N } from "./conformance-outcomes.mjs";
|
|
6
6
|
import { conformanceVerdicts, verdictOf } from "./query.mjs";
|
|
7
7
|
import { summariseLog } from "./local-source.mjs";
|
|
8
8
|
import { buildReport, parseArgs, runStats } from "./index.mjs";
|
|
@@ -179,6 +179,20 @@ describe("conformance outcomes: read only (#5210 R3)", () => {
|
|
|
179
179
|
{ gh: graphqlGh(0), env: {}, now: () => NOW, git: null, releaseTimes: [], onProgress: () => {} });
|
|
180
180
|
assert.equal(r.query.conformance_outcomes.min_n, 3);
|
|
181
181
|
});
|
|
182
|
+
it("a 502 at first=100 retries the same page smaller and completes (#5363)", async () => {
|
|
183
|
+
const calls = [];
|
|
184
|
+
const inner = graphqlGh(150, calls);
|
|
185
|
+
const gh = async (args) => {
|
|
186
|
+
if (args.includes("first=100")) throw new Error("gh: HTTP 502: Bad Gateway");
|
|
187
|
+
return inner(args);
|
|
188
|
+
};
|
|
189
|
+
const out = await gatherConformanceOutcomes({ repo: "o/r", gh, since: at(0), now: NOW });
|
|
190
|
+
assert.ok(out.prs.length > 0);
|
|
191
|
+
assert.ok(calls.some((a) => a.includes("first=50")));
|
|
192
|
+
});
|
|
193
|
+
it("a persistent 502 fails naming a narrower --since (#5363)", async () => {
|
|
194
|
+
await assert.rejects(gatherConformanceOutcomes({ repo: "o/r", gh: async () => { throw new Error("HTTP 502"); }, since: at(0), now: NOW }), /narrower --since/);
|
|
195
|
+
});
|
|
182
196
|
it("flag parsing", () => {
|
|
183
197
|
assert.equal(parseArgs(["--conformance-outcomes"]).conformanceOutcomes, true);
|
|
184
198
|
assert.equal(parseArgs(["--conformance-outcomes", "--window-days", "14"]).windowDays, 14);
|
|
@@ -186,3 +200,75 @@ describe("conformance outcomes: read only (#5210 R3)", () => {
|
|
|
186
200
|
assert.throws(() => parseArgs(["--conformance-outcomes", "--window-days", "0"]), /positive integer/);
|
|
187
201
|
});
|
|
188
202
|
});
|
|
203
|
+
|
|
204
|
+
describe("conformance outcomes: surfaces and replay (#5283)", () => {
|
|
205
|
+
const stub = (files) => files.map((f) => (f.includes("migrations/") ? "domain:database" : f.includes("auth") ? "domain:auth" : f.endsWith(".tsx") ? "domain:frontend" : null)).filter(Boolean).sort();
|
|
206
|
+
const lane = (n, d, files) => pr(n, d, { files });
|
|
207
|
+
it("by_surface compares nonconforming vs conforming among PRs touching that surface; n/a under min n", () => {
|
|
208
|
+
const prs = [lane(1, 0, ["db/migrations/0543.sql"]), lane(2, 0, ["db/migrations/0544.sql"]), lane(3, 0, ["web/a.tsx"]), pr(4, 0)];
|
|
209
|
+
const v = verdicts([[1, "nonconforming", ["conformance.unimplemented"]], [2, "conforms"], [3, "conforms"], [4, "conforms"]]);
|
|
210
|
+
const r = conformanceOutcomes({ prs, verdicts: v, minN: 1, now: NOW, surfacesOf: stub });
|
|
211
|
+
const s = r.repos["o/r"].by_surface;
|
|
212
|
+
assert.deepEqual(Object.keys(s).sort(), ["domain:database", "domain:frontend"]);
|
|
213
|
+
assert.equal(s["domain:database"].nonconforming.n, 1);
|
|
214
|
+
assert.equal(s["domain:database"].conforming.n, 1);
|
|
215
|
+
assert.match(renderConformanceOutcomes(r), /surface domain:database/);
|
|
216
|
+
assert.equal(conformanceOutcomes({ prs, verdicts: v, minN: 5, now: NOW, surfacesOf: stub }).repos["o/r"].by_surface["domain:database"].nonconforming.rate, null);
|
|
217
|
+
});
|
|
218
|
+
it("replay: enforced when a configured surface is hit and the verdict is nonconforming, flagged when it would pass, none otherwise", () => {
|
|
219
|
+
const prs = [lane(1, 0, ["db/migrations/0543.sql"]), lane(2, 0, ["web/(site)/layout.tsx"]), lane(3, 0, ["docs/x.md"])];
|
|
220
|
+
const v = verdicts([[1, "nonconforming", ["conformance.unimplemented"]], [2, "conforms"], [3, "conforms"]]);
|
|
221
|
+
const r = replayPrs({ prs, verdicts: v, numbers: [1, 2, 3, 9], enforceDomains: "database,frontend", surfacesOf: stub });
|
|
222
|
+
assert.deepEqual(r.prs.map((x) => x.outcome), ["enforced", "flagged", "none"]);
|
|
223
|
+
assert.deepEqual(r.missing, [9]);
|
|
224
|
+
assert.equal(replayPrs({ prs, verdicts: v, numbers: [3], riskPaths: "docs/**", surfacesOf: stub }).prs[0].outcome, "flagged");
|
|
225
|
+
assert.match(renderReplay(r), /\| #2 \| shadow \| conforms \| domain:frontend \| flagged \|/);
|
|
226
|
+
});
|
|
227
|
+
it("buildReport wires --replay into the report (JSON) and reports PRs outside the fetched range as missing", async () => {
|
|
228
|
+
const r = await buildReport({ ...parseArgs(["--conformance-outcomes", "--replay", "1,99", "--enforce-domains", "frontend"]), repo: "o/r", cache: false, local: false },
|
|
229
|
+
{ gh: graphqlGh(0), env: {}, now: () => NOW, git: null, releaseTimes: [], onProgress: () => {} });
|
|
230
|
+
const rp = r.query.conformance_outcomes.replay;
|
|
231
|
+
assert.deepEqual(rp.enforce_domains, ["frontend"]);
|
|
232
|
+
assert.ok(rp.missing.includes(99));
|
|
233
|
+
});
|
|
234
|
+
it("prsOfPage keeps changed file paths; parseArgs validates --replay and its companions", () => {
|
|
235
|
+
const data = { data: { search: { nodes: [{ number: 5, mergedAt: at(0), files: { nodes: [{ path: "a.ts" }] } }] } } };
|
|
236
|
+
assert.deepEqual(prsOfPage(data, "o/r")[0].files, ["a.ts"]);
|
|
237
|
+
assert.deepEqual(parseArgs(["--conformance-outcomes", "--replay", "1,2", "--enforce-domains", "auth"]).replay, [1, 2]);
|
|
238
|
+
assert.throws(() => parseArgs(["--replay", "1"]), /need --conformance-outcomes/);
|
|
239
|
+
assert.throws(() => parseArgs(["--conformance-outcomes", "--enforce-domains", "auth"]), /need --replay/);
|
|
240
|
+
assert.throws(() => parseArgs(["--conformance-outcomes", "--replay", "x"]), /comma list/);
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
describe("joinedNumbers (#5363)", () => {
|
|
245
|
+
it("lists each merged PR and its closing issues once, sorted", () => {
|
|
246
|
+
assert.deepEqual(joinedNumbers([{ number: 9, closingIssues: [{ number: 3 }, { number: 5 }] }, { number: 4, closingIssues: [{ number: 3 }] }]), [3, 4, 5, 9]);
|
|
247
|
+
assert.deepEqual(joinedNumbers(), []);
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
it("same-hunks blames each fix PR once (#5372)", () => {
|
|
252
|
+
const at = (d) => new Date(Date.UTC(2026, 0, 1 + d)).toISOString();
|
|
253
|
+
const NOW2 = Date.parse(at(60));
|
|
254
|
+
const lanes = Array.from({ length: 10 }, (_, i) => ({ repo: "o/r", number: 100 + i, title: `feat: ${i}`, body: "", mergedAt: at(i), mergeSha: `lane${i}`, closingIssues: [{ number: 200 + i }] }));
|
|
255
|
+
const fixes = Array.from({ length: 3 }, (_, i) => ({ repo: "o/r", number: 300 + i, title: `fix: ${i}`, body: "", mergedAt: at(i + 3), mergeSha: `fix${i}`, closingIssues: [] }));
|
|
256
|
+
const calls = { ranges: 0, blame: 0 };
|
|
257
|
+
const git = { oldRanges: () => { calls.ranges++; return [{ file: "a", start: 1, end: 2 }, { file: "b", start: 1, end: 2 }]; }, blame: (rev) => { calls.blame++; return rev === "fix1^" ? ["lane0"] : []; } };
|
|
258
|
+
const verdicts = new Map(lanes.map((l, i) => [`pr:${l.number}`, { state: "conforms", issue: 200 + i, kinds: [] }]));
|
|
259
|
+
const events = [];
|
|
260
|
+
const r = conformanceOutcomes({ prs: [...lanes, ...fixes], verdicts, now: NOW2, git, minN: 1, onProgress: (e) => events.push(e) });
|
|
261
|
+
assert.equal(calls.ranges, 3, "oldRanges once per fix PR");
|
|
262
|
+
assert.equal(calls.blame, 6, "blame calls are fix PRs x hunks");
|
|
263
|
+
assert.equal(r.prs.find((x) => x.pr === 100).signals.same_hunks, true);
|
|
264
|
+
assert.equal(r.prs.find((x) => x.pr === 101).signals.same_hunks, false);
|
|
265
|
+
assert.deepEqual(events.map((e) => [e.phase, e.done, e.total]), [["same-hunks", 1, 3], ["same-hunks", 2, 3], ["same-hunks", 3, 3]]);
|
|
266
|
+
warmSameHunks(fixes, git);
|
|
267
|
+
assert.equal(calls.blame, 6, "a second warm reuses the memo");
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
it("same-hunks keeps a hit when another range of the fix PR is unresolved (#5372)", () => {
|
|
271
|
+
const git = { oldRanges: () => [{ file: "a", start: 1, end: 2 }, { file: "b", start: 1, end: 2 }], blame: (_r, f) => (f === "a" ? null : ["lane0"]) };
|
|
272
|
+
assert.equal(sameHunks({ mergeSha: "lane0" }, [{ mergeSha: "fixU" }], git), true);
|
|
273
|
+
assert.equal(sameHunks({ mergeSha: "other" }, [{ mergeSha: "fixU" }], git), null);
|
|
274
|
+
});
|