diff --git a/.agents/replay/1210.json b/.agents/replay/1210.json new file mode 100644 index 000000000..91144701c --- /dev/null +++ b/.agents/replay/1210.json @@ -0,0 +1,23 @@ +{ + "pr": 1210, + "issue": 1204, + "rounds": { + "1": { + "head": "393a60211db4120affbdc8e2aa01bd3ac511a269", + "base": "e989c046cad27364a70ec3462aa22709f9f954c5", + "frozenAt": "2026-11-27T10:43:24.984Z", + "baseline": { + "runs": 5, + "seconds": 1894, + "costUsd": 8.3125, + "lenses": [ + "reviewer/-:claude-sonnet-5-5", + "spec/-:claude-sonnet-5-5", + "claims/-:claude-sonnet-5-5", + "code/behaviour:claude-opus-5-5", + "code/tests:claude-opus-5-5" + ] + } + } + } +} diff --git a/.agents/replay/1235.json b/.agents/replay/1235.json new file mode 100644 index 000000000..405804006 --- /dev/null +++ b/.agents/replay/1235.json @@ -0,0 +1,22 @@ +{ + "pr": 1235, + "issue": 1206, + "rounds": { + "1": { + "head": "9ecf4083c736b85362795217ab7a6fdf45462a76", + "base": "aa61f65c3b8391d41cee1efd1aeb71468e7fd5de", + "frozenAt": "2026-11-27T10:43:50.179Z", + "baseline": { + "runs": 4, + "seconds": 1221, + "costUsd": 4.3125, + "lenses": [ + "reviewer/-:claude-sonnet-5-5", + "spec/-:claude-sonnet-5-5", + "code/both:claude-opus-5-5", + "claims/-:claude-sonnet-5-5" + ] + } + } + } +} diff --git a/.agents/replay/1360.json b/.agents/replay/1360.json new file mode 100644 index 000000000..67ef40805 --- /dev/null +++ b/.agents/replay/1360.json @@ -0,0 +1,22 @@ +{ + "pr": 1360, + "issue": 1331, + "rounds": { + "1": { + "head": "9a1c178b60970cbfd72cd1e09687423d5a760e5a", + "base": "8c2a41f9feb3e9fe5f5250132c4f267d4f93da53", + "frozenAt": "2026-11-27T10:42:32.941Z", + "baseline": { + "runs": 4, + "seconds": 653, + "costUsd": 2.1107, + "lenses": [ + "reviewer/-:claude-sonnet-5-5", + "spec/-:claude-sonnet-5-5", + "code/both:claude-opus-5-5", + "claims/-:claude-sonnet-5-5" + ] + } + } + } +} diff --git a/.agents/replay/1446.json b/.agents/replay/1446.json new file mode 100644 index 000000000..23e8d0f5b --- /dev/null +++ b/.agents/replay/1446.json @@ -0,0 +1,17 @@ +{ + "pr": 1446, + "issue": 1433, + "rounds": { + "1": { + "head": "f3a6f1a27f278e20868ceeb9ab41bd0565a2b1ee", + "base": "fc5ac8c3e1d670689cb4eb14396850e7af691ccb", + "frozenAt": "2026-11-27T10:44:41.824Z", + "baseline": { + "runs": 0, + "seconds": null, + "costUsd": null, + "lenses": [] + } + } + } +} diff --git a/.agents/replay/1620.json b/.agents/replay/1620.json new file mode 100644 index 000000000..cce74c5d8 --- /dev/null +++ b/.agents/replay/1620.json @@ -0,0 +1,22 @@ +{ + "pr": 1620, + "issue": 1569, + "rounds": { + "1": { + "head": "9862f551afccf616d145315268f5c443fffd3055", + "base": "db8e65591abe67a01a33404d2e32a1d69500341d", + "frozenAt": "2026-11-27T10:45:11.626Z", + "baseline": { + "runs": 4, + "seconds": 978, + "costUsd": 2.8461, + "lenses": [ + "reviewer/-:claude-sonnet-5-5", + "spec/-:claude-sonnet-5-5", + "code/both:claude-opus-5-5", + "claims/-:claude-sonnet-5-5" + ] + } + } + } +} diff --git a/.agents/replay/1626.json b/.agents/replay/1626.json new file mode 100644 index 000000000..28e1ca8cc --- /dev/null +++ b/.agents/replay/1626.json @@ -0,0 +1,22 @@ +{ + "pr": 1626, + "issue": 1570, + "rounds": { + "1": { + "head": "3c09207d51a719c770b9cc56fb874323955d98d2", + "base": "31359f6fb7d9a103e4bd168d99ee13c91c451a3b", + "frozenAt": "2026-11-27T10:44:15.227Z", + "baseline": { + "runs": 4, + "seconds": 1903, + "costUsd": 3.4123, + "lenses": [ + "reviewer/-:claude-sonnet-5-5", + "spec/-:claude-sonnet-5-5", + "code/both:claude-opus-5-5", + "claims/-:claude-sonnet-5-5" + ] + } + } + } +} diff --git a/.agents/scripts/replay-freeze.mjs b/.agents/scripts/replay-freeze.mjs index b301811ba..49f462586 100755 --- a/.agents/scripts/replay-freeze.mjs +++ b/.agents/scripts/replay-freeze.mjs @@ -1,6 +1,6 @@ #!/usr/bin/env node // `node .agents/scripts/replay-freeze.mjs --pr --round <1|2|fix-check> --head --base -// [--previous ] [--issue ]`: freezes one review snapshot of a PR so review-replay.sh can +// [--previous ] [--issue ] [--escaped ] [--replace-truth]`: freezes one review snapshot of a PR so review-replay.sh can // review it again later, with today's or tomorrow's agents, and review-score.mjs can score the // result against what the real review found. // @@ -14,6 +14,19 @@ // are the defects, the others known non-defects), goes to origin too, as the blob // refs/replay//truth, and never into the checkout: the first replay's coordinator opened the // snapshot file and read the answers before its lenses ran. review-score.mjs fetches the blob. +// +// --escaped names a file kept outside the checkout: the bugs the round's review let through, +// `[{"bug": , "fix": "", "places": [{"file": "", "start": , "end": }], +// "note": ""}]`. A place is the smallest block of the round's head that holds the +// defect. The fix must be a local commit, every place must exist at the head, and one place of +// each bug must overlap a line the reviewed diff adds; anything else is refused and nothing is +// written or pushed. They go into the truth blob under `escaped`, tagged with the round; the +// blob keeps the entries it has for other rounds, and without --escaped this round's too. +// +// Git refuses to replace a pinned blob. A freeze whose truth differs from the one on origin is +// refused, nothing written or pushed, unless --replace-truth is given: the script then deletes +// refs/replay//truth and pins the new blob, built from the stored one first. Never delete +// that ref by hand: a freeze that finds none starts from an empty truth. import { execFileSync } from "node:child_process"; import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"; import { dirname, join } from "node:path"; @@ -26,15 +39,17 @@ const head = option("--head"); const base = option("--base"); const previous = option("--previous"); const issue = option("--issue"); +const escapedFile = option("--escaped"); if (!/^\d+$/.test(pr ?? "") || !round || !head || !base) { console.error( - "usage: replay-freeze.mjs --pr --round <1|2|fix-check> --head --base [--previous ] [--issue ]", + "usage: replay-freeze.mjs --pr --round <1|2|fix-check> --head --base [--previous ] [--issue ] [--escaped ] [--replace-truth]", ); process.exit(64); } const root = join(dirname(fileURLToPath(import.meta.url)), "..", ".."); -const git = (...a) => execFileSync("git", a, { cwd: root, encoding: "utf8" }).trim(); +const git = (...a) => + execFileSync("git", a, { cwd: root, encoding: "utf8", maxBuffer: 64 * 1024 * 1024 }).trim(); const gh = (...a) => execFileSync("gh", a, { cwd: root, encoding: "utf8" }); git("fetch", "-q", "origin", `+refs/pull/${pr}/head:refs/replay-freeze/${pr}`); @@ -55,6 +70,8 @@ try { process.exit(65); } git("update-ref", "-d", `refs/replay-freeze/${pr}`); +const escaped = + escapedFile === null ? null : escapedBugs(JSON.parse(readFileSync(escapedFile, "utf8"))); const nwo = process.env.GH_REPO ?? @@ -103,9 +120,15 @@ try { { encoding: "utf8" }, ), ); - const runs = metrics.runs.filter((r) => r.stage === "review" && r.round === round); + // why: --issue also brings the runs of a closed PR that held the same issue before this one. + const runs = metrics.runs.filter( + (r) => r.stage === "review" && r.round === round && (r.pr === pr || r.pr === "-"), + ); + // why: a PR whose review left no transcript on this machine has an unknown baseline, not a free one. const sum = (k) => - runs.some((r) => r[k] === null) ? null : runs.reduce((a, r) => a + (r[k] ?? 0), 0); + runs.length === 0 || runs.some((r) => r[k] === null) + ? null + : runs.reduce((a, r) => a + (r[k] ?? 0), 0); baseline = { runs: runs.length, seconds: sum("seconds"), @@ -114,6 +137,36 @@ try { }; } catch {} +const truthRef = `refs/replay/${pr}/truth`; +const pinned = git("ls-remote", "origin", truthRef).split(/\s/)[0] || null; +const stored = pinned === null ? null : storedTruth(); +const allEscaped = + escaped === null + ? (stored?.escaped ?? []) + : [...(stored?.escaped ?? []).filter((e) => e.round !== round), ...escaped]; +let blob = null; +if (findings !== null || allEscaped.length > 0) { + // why: a blob with no `escaped` key is what the earlier snapshots hold, so a freeze that adds + // no escaped bug writes the same bytes and replaces nothing. + const truth = { + pr: Number(pr), + findings: findings ?? stored?.findings ?? [], + ...(allEscaped.length === 0 ? {} : { escaped: allEscaped }), + }; + blob = execFileSync("git", ["hash-object", "-w", "--stdin"], { + cwd: root, + input: JSON.stringify(truth, null, 2) + "\n", + encoding: "utf8", + }).trim(); +} +const replaces = pinned !== null && blob !== null && blob !== pinned; +if (replaces && !process.argv.includes("--replace-truth")) { + console.error( + `${truthRef} on origin holds ${stored.findings?.length ?? 0} findings and ${stored.escaped?.length ?? 0} escaped bugs, and this freeze would pin ${findings?.length ?? stored.findings?.length ?? 0} and ${allEscaped.length}. Git refuses to replace a pinned blob: run again with --replace-truth, and never delete the ref by hand.`, + ); + process.exit(65); +} + const dir = join(root, ".agents/replay"); mkdirSync(dir, { recursive: true }); const file = join(dir, `${pr}.json`); @@ -125,19 +178,89 @@ delete snapshot.findings; writeFileSync(file, JSON.stringify(snapshot, null, 2) + "\n"); const refs = Object.entries(full).map(([name, sha]) => `${sha}:refs/replay/${pr}/${round}/${name}`); -if (findings !== null) { - const blob = execFileSync("git", ["hash-object", "-w", "--stdin"], { - cwd: root, - input: JSON.stringify({ pr: Number(pr), findings }, null, 2) + "\n", - encoding: "utf8", - }).trim(); - refs.push(`${blob}:refs/replay/${pr}/truth`); +if (blob !== null && blob !== pinned) refs.push(`${blob}:${truthRef}`); +if (replaces) git("push", "-q", "origin", `:${truthRef}`); +try { + git("push", "-q", "origin", ...refs); +} catch (error) { + if (replaces) + console.error( + `the old truth is deleted and the new one is not pinned: run \`git push origin ${blob}:${truthRef}\``, + ); + throw error; } -git("push", "-q", "origin", ...refs); console.log( `frozen PR #${pr} round ${round}: ${Object.entries(full) .map(([k, v]) => `${k} ${v.slice(0, 8)}`) .join( ", ", - )}; ${findings?.length ?? 0} ground-truth findings; pinned ${refs.length} refs on origin; ${file}`, + )}; ${findings?.length ?? 0} ground-truth findings, ${allEscaped.length} escaped bugs; pinned ${refs.length} refs on origin; ${file}`, ); + +function storedTruth() { + git("fetch", "-q", "origin", `+${truthRef}:${truthRef}`); + return JSON.parse(git("cat-file", "-p", truthRef)); +} + +function escapedBugs(list) { + if (!Array.isArray(list)) refuseEscaped("the file is not a list"); + const fork = git("merge-base", full.base, full.head); + return list.map((entry) => escapedBug(entry, fork)); +} + +function refuseEscaped(why) { + console.error( + `--escaped: ${why}. Each entry is {"bug": , "fix": "", "places": [{"file": "", "start": , "end": }]}`, + ); + process.exit(65); +} + +function escapedBug(entry, fork) { + const places = Array.isArray(entry.places) ? entry.places : []; + if (!Number.isInteger(entry.bug) || typeof entry.fix !== "string" || places.length === 0) + refuseEscaped(`${JSON.stringify(entry)} lacks a bug, a fix or a place`); + for (const place of places) checkPlace(entry.bug, place); + const reviewed = places.some(({ file, start, end }) => + addedLines(fork, file).some(([from, to]) => from <= end && to >= start), + ); + if (!reviewed) + refuseEscaped( + `bug #${entry.bug}: no place overlaps a line the diff ${fork.slice(0, 8)}..${full.head.slice(0, 8)} adds, so this review never saw the defect`, + ); + return { + bug: entry.bug, + fix: fixCommit(entry), + round, + places: places.map(({ file, start, end }) => ({ file, start, end })), + ...(typeof entry.note === "string" ? { note: entry.note } : {}), + }; +} + +function fixCommit(entry) { + try { + return git("rev-parse", "--verify", `${entry.fix}^{commit}`); + } catch { + return refuseEscaped( + `bug #${entry.bug}: fix ${entry.fix} is not a local commit; fetch origin/main`, + ); + } +} + +function checkPlace(bug, { file, start, end }) { + let lines; + try { + lines = git("show", `${full.head}:${file}`).split("\n").length; + } catch { + refuseEscaped(`bug #${bug}: ${file} is not a file at head ${full.head.slice(0, 8)}`); + } + if (!(Number.isInteger(start) && Number.isInteger(end) && start >= 1 && start <= end)) + refuseEscaped(`bug #${bug}: ${file} needs start and end line numbers, start first`); + if (end > lines) refuseEscaped(`bug #${bug}: ${file} has ${lines} lines at the head, not ${end}`); +} + +function addedLines(fork, file) { + const diff = git("diff", "-U0", fork, full.head, "--", file); + return [...diff.matchAll(/^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/gm)] + .map((m) => [Number(m[1]), Number(m[1]) + Number(m[2] ?? 1) - 1]) + .filter(([from, to]) => to >= from); +} diff --git a/.agents/scripts/review-ledger.mjs b/.agents/scripts/review-ledger.mjs index 62a255ee4..dde2db6b7 100644 --- a/.agents/scripts/review-ledger.mjs +++ b/.agents/scripts/review-ledger.mjs @@ -116,6 +116,8 @@ if (metrics.status !== 0) { const why = metrics.stderr.split("\n").find((l) => /^\w*Error: /.test(l)) ?? metrics.stderr; refuse(`review-metrics.mjs rejected the findings: ${why.trim()}`); } +// why: review-metrics.mjs wrote each normalised class back to the file, and the ledger posts those. +findings = JSON.parse(readFileSync(findingsFile, "utf8")); const comment = [ "## Review ledger", diff --git a/.agents/scripts/review-metrics.mjs b/.agents/scripts/review-metrics.mjs index 20939624c..c13a926e2 100644 --- a/.agents/scripts/review-metrics.mjs +++ b/.agents/scripts/review-metrics.mjs @@ -17,7 +17,15 @@ // --findings validates the coordinator's findings file (`{"findings": [...]}`, each with id, // role, class, outcome, path and, when present, round) and adds the outcome and class counts. --json prints the ledger // (runs, totals, findings) instead of the summary lines. -import { readFileSync } from "node:fs"; +// +// It also normalises each class and writes the file back when one changed, so the ledger counts +// one rule as one class: a class that starts with a rule file's name (docs/internal/agent-rules/) +// and a rule number becomes ` `, and the words after it move to `detail` +// (`testing 3: error path` is class `testing 3`, detail `error path`). A class that names a rule +// file with no number, alone or before a colon, is refused. +import { readdirSync, readFileSync, writeFileSync } from "node:fs"; +import { dirname, join } from "node:path"; +import { fileURLToPath } from "node:url"; import { parsed, projectsRoot, tagOf, transcripts } from "./transcripts.mjs"; import { option } from "./cli-args.mjs"; @@ -51,8 +59,7 @@ const runs = transcripts(root) .filter(({ tag }) => (tag.stage === "replay") === args.includes("--replay")) .map(({ file, tag }) => run(file, tag)) .sort((a, b) => Date.parse(a.startedAt ?? "") - Date.parse(b.startedAt ?? "")); -const findings = - findingsFile === null ? null : checked(JSON.parse(readFileSync(findingsFile, "utf8"))); +const findings = findingsFile === null ? null : normalised(findingsFile); const total = (values) => values.length === 0 || values.some((v) => v === null) @@ -153,6 +160,60 @@ function priced(model, counts, sofar) { return sofar + counts.reduce((sum, n, i) => sum + n * price[i], 0) / 1e6; } +function normalised(path) { + const text = readFileSync(path, "utf8"); + const file = JSON.parse(text); + const list = checked(file); + const rules = ruleFiles(); + let changed = false; + for (const f of list) { + const { class: name, detail } = classOf(f, rules); + if (name === f.class) continue; + changed = true; + f.class = name; + if (detail !== undefined) f.detail = f.detail === undefined ? detail : `${detail}; ${f.detail}`; + } + if (changed) writeFileSync(path, `${JSON.stringify(file, null, 2)}\n`); + return list; +} + +function ruleFiles() { + const dir = join( + dirname(fileURLToPath(import.meta.url)), + "..", + "..", + "docs/internal/agent-rules", + ); + try { + return readdirSync(dir) + .filter((name) => name.endsWith(".md")) + .map((name) => name.slice(0, -3)); + } catch { + return []; + } +} + +function classOf(finding, rules) { + const text = finding.class.trim().replace(/\s+/g, " "); + const lower = text.toLowerCase(); + // why: the longest name first, so no rule file is read as the start of another's name. + const rule = [...rules] + .sort((x, y) => y.length - x.length) + .find((name) => lower.startsWith(name) && !/^[\w.-]/.test(lower.slice(name.length))); + if (rule === undefined) return { class: text }; + const rest = text.slice(rule.length); + const numbered = /^(?: rule)? ?#? ?(\d+)(?!\d)(.*)$/i.exec(rest); + if (numbered !== null) { + const detail = numbered[2].replace(/^[\s:;,.()/-]+/, "").trim(); + return { class: `${rule} ${Number(numbered[1])}`, ...(detail === "" ? {} : { detail }) }; + } + // why: a rule file's name then plain words ("documentation contradicts code") is the general rule in the lens's own words. + if (/^ (?!rule\b)[a-z]/i.test(rest)) return { class: text }; + throw new Error( + `finding ${finding.id} has class "${finding.class}", which names the rule file ${rule} and no rule number. Accepted: "${rule} ", "${rule} : " (as in "testing 3: error path"), or the general rule in at most 8 words that do not start with "${rule}:"`, + ); +} + function checked(file) { const list = file.findings; if (!Array.isArray(list)) throw new Error("findings must be an array"); diff --git a/.agents/scripts/review-score.mjs b/.agents/scripts/review-score.mjs index e10d8118c..4c55aaf59 100644 --- a/.agents/scripts/review-score.mjs +++ b/.agents/scripts/review-score.mjs @@ -8,7 +8,14 @@ // matches a ground-truth one when both name the same file (the path before any `:line`) and // share a class word, or when the file has exactly one ground-truth finding of that role. Recall // is matched defects over defects; a replay finding matching nothing is `unmatched` and needs a -// person's adjudication (new true finding, or false positive). Cost and seconds come from the +// person's adjudication (new true finding, or false positive). +// +// Escaped bugs (the truth blob's `escaped`, from replay-freeze.mjs --escaped) are scored apart +// from the ledger findings, as their own recall: a bug is found only when a replay finding the +// review would block on (`open`, `fixed` or `duplicate`) names one of its places, the file and +// a line or range that overlaps the place's lines. A finding that names the file with no line, +// or as a note or a rejected candidate, is printed for a person and not counted. A finding that +// finds an escaped bug is never `unmatched`. Cost and seconds come from the // stage=replay runs review-metrics.mjs --replay reports, from --since on (the `started:` line // review-replay.sh printed), so replays of one snapshot stay apart. One row goes to // .agents/replay/results.jsonl. @@ -52,12 +59,15 @@ const replay = file.endsWith(".json") execFileSync("git", ["fetch", "-q", "origin", `+refs/replay/${pr}/truth:refs/replay/${pr}/truth`], { cwd: root, }); -const truthFindings = JSON.parse( +const truthBlob = JSON.parse( execFileSync("git", ["cat-file", "-p", `refs/replay/${pr}/truth`], { cwd: root, encoding: "utf8", }), -).findings; +); +const truthFindings = truthBlob.findings; +// why: a place's lines are those of the head its round reviewed, so another round cannot be scored on them. +const escapedBugs = (truthBlob.escaped ?? []).filter((e) => String(e.round) === String(round)); // why: a finding may name several places, "a.ts:12 (and b.ts:40, c.ts:7)", and each counts. const filesOf = (p) => [...String(p ?? "").matchAll(/[\w@./-]+\.[a-z]+/g)].map((m) => m[0]); @@ -109,6 +119,47 @@ const overlap = (a, b) => { return [...ra].some((r) => rb.has(r)); }; +// why: "a.ts:12", "a.ts:12-20" and "a.ts:12,40" each name lines of a.ts; a file with no number names none. +const placesOf = (p) => + [...String(p ?? "").matchAll(/([\w@./-]+\.[a-z]+)(?::(\d+(?:-\d+)?(?:,\d+(?:-\d+)?)*))?/g)].map( + (m) => ({ + file: m[1], + ranges: (m[2] ?? "") + .split(",") + .filter(Boolean) + .map((r) => r.split("-").map(Number)) + .map(([from, to = from]) => [from, to]), + }), + ); +const BLOCKING = ["open", "fixed", "duplicate"]; +// why: a lens often names a file by its basename alone ("main.ts:1177"). +const sameFile = (place, named) => + place.file === named.file || place.file.endsWith(`/${named.file}`); +const escapedHits = new Map(escapedBugs.map((e) => [e.bug, { found: [], seen: [] }])); +const foundEscaped = new Set(); +for (const r of replay) { + for (const bug of escapedBugs) { + const named = placesOf(r.path).filter((p) => bug.places.some((b) => sameFile(b, p))); + if (named.length === 0) continue; + const onLines = named.some((p) => + bug.places.some( + (b) => sameFile(b, p) && p.ranges.some(([from, to]) => from <= b.end && to >= b.start), + ), + ); + if (onLines && BLOCKING.includes(r.outcome)) { + escapedHits.get(bug.bug).found.push(r.id); + foundEscaped.add(r.id); + } else { + const why = onLines + ? r.outcome + : named.some((p) => p.ranges.length > 0) + ? "other lines" + : "no line"; + escapedHits.get(bug.bug).seen.push(`${r.id} (${why})`); + } + } +} + const truth = truthFindings.map((f) => ({ ...f, files: filesOf(f.path), @@ -134,7 +185,7 @@ for (const r of replay) { if (hit) { taken.add(hit.id); matches.push({ replay: r.id, truth: hit.id, truthOutcome: hit.outcome }); - } else unmatched.push(r); + } else if (!foundEscaped.has(r.id)) unmatched.push(r); } // why: a single lens is judged on the findings its role owned in the real review, and a later // round on the findings that round raised, when the ledger says which round that was. @@ -197,6 +248,20 @@ console.log( console.log( `Replay runs ${runs.runs}, seconds ${show(runs.seconds)}, USD ${show(runs.costUsd)}; real review: runs ${show(baseline?.runs)}, seconds ${show(baseline?.seconds)}, USD ${show(baseline?.costUsd)}.`, ); +const escapedFound = escapedBugs.filter((e) => escapedHits.get(e.bug).found.length > 0); +const escapedMissed = escapedBugs.filter((e) => escapedHits.get(e.bug).found.length === 0); +if (escapedBugs.length > 0) { + console.log(`Escaped bugs: recall ${escapedFound.length}/${escapedBugs.length}.`); + const where = (e) => e.places.map((p) => `${p.file}:${p.start}-${p.end}`).join(", "); + for (const e of escapedFound) + console.log(` escaped #${e.bug} found by ${escapedHits.get(e.bug).found.join(", ")}`); + for (const e of escapedMissed) { + const seen = escapedHits.get(e.bug).seen; + console.log( + ` ESCAPED #${e.bug} missed ${where(e)}${seen.length === 0 ? "" : `; same file: ${seen.join(", ")} (adjudicate)`}`, + ); + } +} for (const m of matches) console.log(` match ${m.replay} -> ${m.truth} (${m.truthOutcome})`); for (const t of missed) console.log(` MISSED ${t.id} ${t.role} [${t.class}] ${t.path}`); for (const r of unmatched) @@ -218,6 +283,13 @@ appendFileSync( missed: missed.map((t) => t.id), unmatched: unmatched.map((r) => `${r.id} ${r.path} [${r.class}]`), nonDefectHits: nonDefectHits.length, + ...(escapedBugs.length === 0 + ? {} + : { + escapedRecall: `${escapedFound.length}/${escapedBugs.length}`, + escapedFound: escapedFound.map((e) => e.bug), + escapedMissed: escapedMissed.map((e) => e.bug), + }), replay: runs, baseline: baseline ?? null, }) + "\n", diff --git a/docs/internal/REVIEW-EVALUATION.md b/docs/internal/REVIEW-EVALUATION.md index 3075768d4..b7eb740d6 100644 --- a/docs/internal/REVIEW-EVALUATION.md +++ b/docs/internal/REVIEW-EVALUATION.md @@ -28,12 +28,22 @@ as `refs/replay//...` on origin, `review-replay.sh` builds the blind inputs for that snapshot and prints the reviewer's prompt (tagged `stage=replay`, or one lens with `--lens`), and `review-score.mjs` scores the findings against the ledger and appends to `.agents/replay/results.jsonl`. + +`replay-freeze.mjs --escaped ` adds the bugs a round's review let +through to the pinned truth: the bug's issue, its fix commit, and the file +and lines of the reviewed head that held the defect. Record one only after +reading its fix: `git blame` names the last PR to touch a line, not the one +that made the defect. `review-score.mjs` reports recall on escaped bugs as +its own number: a bug is found only when a blocking finding names its file +and a line or range that overlaps those lines. Round 1 of #1210, #1235, #1626, #1446 and +#1620 holds 13 such entries for 12 bugs; #1360, #752 and #775 hold none. + A change to the review is judged by replaying each variant on every snapshot, three runs each. It is adopted when, against the current agents -on the same snapshots, recall over fixed findings does not drop, unmatched -findings (after adjudication) do not rise, and the number it targets -(minutes, USD, open rate, rule-cited findings) moves by the amount it -claims. Unknown data does not count as improvement. +on the same snapshots, recall over fixed findings and recall on escaped +bugs do not drop, unmatched findings (after adjudication) do not rise, and +the number it targets (minutes, USD, open rate, rule-cited findings) moves +by the amount it claims. Unknown data does not count as improvement. The design follows [Anthropic's review convergence findings](https://claude.dev/blog/solving-code-review-at-anthropic/), [Addy Osmani's risk-focused review](https://addyosmani.com/blog/agentic-code-review/), diff --git a/docs/internal/agent-rules/toolchain.md b/docs/internal/agent-rules/toolchain.md index a9ffb76dd..8ea744a5e 100644 --- a/docs/internal/agent-rules/toolchain.md +++ b/docs/internal/agent-rules/toolchain.md @@ -321,6 +321,8 @@ ledger: pr= issue= stage= ro ]` reads the runs so tagged from Claude Code's transcripts on this machine and prints their models, seconds, tokens and cost, and with `--findings` the outcome and class counts; [REVIEW.md](../REVIEW.md) says -what goes in the findings file and where the result is posted. It reports, -it checks nothing. Runs tagged `stage=replay` (a frozen snapshot reviewed +what goes in the findings file and where the result is posted. With +`--findings` it also checks the findings file and writes a class that +starts with a rule and its number back as that rule plus `detail`; the +script's header says what it refuses. Runs tagged `stage=replay` (a frozen snapshot reviewed again by `review-replay.sh`) are left out unless `--replay` is given. diff --git a/src/replay-freeze.test.ts b/src/replay-freeze.test.ts new file mode 100644 index 000000000..3e898e722 --- /dev/null +++ b/src/replay-freeze.test.ts @@ -0,0 +1,233 @@ +import { execFileSync, spawnSync } from "node:child_process"; +import { + copyFileSync, + existsSync, + mkdirSync, + mkdtempSync, + readFileSync, + writeFileSync, +} from "node:fs"; +import { tmpdir } from "node:os"; +import { dirname, join } from "node:path"; +import { fileURLToPath } from "node:url"; + +import { describe, expect, it } from "vitest"; + +import { fakeCommandEnv, writeFakeCommand } from "./test-support/fake-command.js"; + +const SCRIPTS = join(dirname(fileURLToPath(import.meta.url)), "..", ".agents", "scripts"); + +// why: the script asks only for the PR's comments; the one ledger comment is its ground truth. +const FAKE_GH = `#!/usr/bin/env node +const args = process.argv.slice(2); +if (args[0] !== "api" || !/\\/issues\\/7\\/comments$/.test(args[3])) process.exit(9); +const findings = [{ id: "R1", role: "code", class: "testing 3", outcome: "fixed", path: "src/a.ts" }]; +const body = "## Review ledger\\n\\n\`\`\`json\\n" + JSON.stringify({ findings }) + "\\n\`\`\`"; +process.stdout.write(JSON.stringify([{ body }])); +`; + +interface Checkout { + readonly base: string; + readonly head: string; + readonly later: string; + readonly origin: string; + readonly root: string; + readonly work: string; +} + +interface Truth { + readonly escaped?: readonly { bug: number; fix: string; round: string }[]; + readonly findings: readonly { id: string }[]; +} + +function git(cwd: string, ...args: string[]): string { + return execFileSync( + "git", + ["-c", "user.name=t", "-c", "user.email=t@t", "-c", "commit.gpgsign=false", ...args], + { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }, + ).trim(); +} + +// why: the script works on the checkout it sits in and pins on that checkout's origin, so each +// test gets both: a PR whose head adds lines 4 and 5 of src/a.ts, and a later commit on it. +function checkout(): Checkout { + const root = mkdtempSync(join(tmpdir(), "replay-freeze-")); + const origin = join(root, "origin.git"); + const work = join(root, "work"); + mkdirSync(origin); + git(origin, "init", "-q", "--bare"); + mkdirSync(join(work, ".agents", "scripts"), { recursive: true }); + mkdirSync(join(work, "src")); + mkdirSync(join(root, "bin")); + mkdirSync(join(root, "config")); + writeFakeCommand(join(root, "bin"), "gh", FAKE_GH); + for (const name of ["replay-freeze.mjs", "review-metrics.mjs", "transcripts.mjs", "cli-args.mjs"]) + copyFileSync(join(SCRIPTS, name), join(work, ".agents", "scripts", name)); + git(work, "init", "-q", "-b", "main"); + git(work, "remote", "add", "origin", origin); + const commit = (lines: string[]): string => { + writeFileSync(join(work, "src", "a.ts"), `${lines.join("\n")}\n`); + git(work, "add", "src/a.ts"); + git(work, "commit", "-q", "-m", `${String(lines.length)} lines`); + return git(work, "rev-parse", "HEAD"); + }; + const base = commit(["one", "two", "three"]); + const head = commit(["one", "two", "three", "four", "five"]); + const later = commit(["one", "two", "three", "four", "five", "six"]); + git(work, "push", "-q", "origin", `${later}:refs/pull/7/head`); + return { base, head, later, origin, root, work }; +} + +function freeze(at: Checkout, round: string, head: string, more: string[] = []) { + const run = spawnSync( + process.execPath, + [ + join(at.work, ".agents", "scripts", "replay-freeze.mjs"), + "--pr", + "7", + "--round", + round, + "--head", + head, + "--base", + at.base, + ...more, + ], + { + encoding: "utf8", + env: { + ...process.env, + ...fakeCommandEnv(join(at.root, "bin")), + CLAUDE_CONFIG_DIR: join(at.root, "config"), + GH_REPO: "o/r", + }, + }, + ); + return { code: run.status, err: run.stderr }; +} + +function escapedFile(at: Checkout, name: string, entries: object[]): string[] { + const file = join(at.root, name); + writeFileSync(file, JSON.stringify(entries)); + return ["--escaped", file]; +} + +function pinned(at: Checkout): string[] { + return git(at.origin, "for-each-ref", "--format=%(refname)", "refs/replay").split("\n"); +} + +function truth(at: Checkout): Truth { + return JSON.parse(git(at.origin, "cat-file", "-p", "refs/replay/7/truth")) as Truth; +} + +const place = (start: number, end: number, file = "src/a.ts") => ({ end, file, start }); + +describe("replay-freeze.mjs", () => { + it("pins the head, the base and a truth blob holding the ledger findings and each escaped bug with its fix commit and round", () => { + const at = checkout(); + + const run = freeze( + at, + "1", + at.head, + escapedFile(at, "escaped.json", [ + { bug: 31, fix: at.later.slice(0, 12), note: "why", places: [place(4, 5)] }, + ]), + ); + + expect(run).toMatchObject({ code: 0 }); + expect(pinned(at)).toEqual([ + "refs/replay/7/1/base", + "refs/replay/7/1/head", + "refs/replay/7/truth", + ]); + expect(git(at.origin, "rev-parse", "refs/replay/7/1/head")).toBe(at.head); + expect(truth(at)).toEqual({ + escaped: [{ bug: 31, fix: at.later, note: "why", places: [place(4, 5)], round: "1" }], + findings: [ + { class: "testing 3", id: "R1", outcome: "fixed", path: "src/a.ts", role: "code" }, + ], + pr: 7, + }); + }); + + it("records the real review's seconds and cost as unknown, not zero, when no transcript holds a run of the round", () => { + const at = checkout(); + + freeze(at, "1", at.head); + + const snapshot = JSON.parse( + readFileSync(join(at.work, ".agents", "replay", "7.json"), "utf8"), + ) as { rounds: Record }; + expect(snapshot.rounds["1"]?.baseline).toEqual({ + costUsd: null, + lenses: [], + runs: 0, + seconds: null, + }); + }); + + it("refuses an escaped bug it cannot place in the reviewed diff, says why, and writes and pins nothing", () => { + const at = checkout(); + const refused: [object, string][] = [ + [{ bug: 31, fix: at.later, places: [] }, "lacks a bug, a fix or a place"], + [{ bug: 31, fix: "0123abc", places: [place(4, 5)] }, "fix 0123abc is not a local commit"], + [{ bug: 31, fix: at.later, places: [place(1, 2, "src/b.ts")] }, "src/b.ts is not a file at"], + [{ bug: 31, fix: at.later, places: [place(5, 4)] }, "needs start and end line numbers"], + [{ bug: 31, fix: at.later, places: [place(4, 6)] }, "has 5 lines at the head, not 6"], + [{ bug: 31, fix: at.later, places: [place(1, 3)] }, "no place overlaps a line the diff"], + ]; + + const runs = refused.map(([entry]) => + freeze(at, "1", at.head, escapedFile(at, "escaped.json", [entry])), + ); + + expect(runs.map((run) => run.code)).toEqual(refused.map(() => 65)); + refused.forEach(([, why], index) => expect(runs[index]?.err).toContain(why)); + expect(pinned(at)).toEqual([""]); + expect(existsSync(join(at.work, ".agents", "replay", "7.json"))).toBe(false); + }); + + it("refuses to change a pinned truth without --replace-truth, and with it keeps the other rounds' escaped bugs", () => { + const at = checkout(); + const first = { bug: 31, fix: at.later, places: [place(4, 5)] }; + const second = { bug: 32, fix: at.later, places: [place(6, 6)] }; + freeze(at, "1", at.head, escapedFile(at, "one.json", [first])); + const before = git(at.origin, "rev-parse", "refs/replay/7/truth"); + + const refused = freeze(at, "2", at.later, escapedFile(at, "two.json", [second])); + + expect(refused.code).toBe(65); + expect(refused.err).toContain("run again with --replace-truth"); + expect(pinned(at)).not.toContain("refs/replay/7/2/head"); + expect(git(at.origin, "rev-parse", "refs/replay/7/truth")).toBe(before); + + const replaced = freeze(at, "2", at.later, [ + ...escapedFile(at, "two.json", [second]), + "--replace-truth", + ]); + + expect(replaced).toMatchObject({ code: 0 }); + expect(truth(at).escaped?.map((e) => [e.bug, e.round])).toEqual([ + [31, "1"], + [32, "2"], + ]); + }); + + it("keeps the pinned escaped bugs when a round is frozen again without --escaped", () => { + const at = checkout(); + freeze( + at, + "1", + at.head, + escapedFile(at, "one.json", [{ bug: 31, fix: at.later, places: [place(4, 5)] }]), + ); + const before = git(at.origin, "rev-parse", "refs/replay/7/truth"); + + const again = freeze(at, "1", at.head); + + expect(again).toMatchObject({ code: 0 }); + expect(git(at.origin, "rev-parse", "refs/replay/7/truth")).toBe(before); + expect(truth(at).escaped?.map((e) => e.bug)).toEqual([31]); + }); +}); diff --git a/src/review-ledger.test.ts b/src/review-ledger.test.ts new file mode 100644 index 000000000..1bf1de86d --- /dev/null +++ b/src/review-ledger.test.ts @@ -0,0 +1,76 @@ +import { execFileSync, spawnSync } from "node:child_process"; +import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { dirname, join } from "node:path"; +import { fileURLToPath } from "node:url"; + +import { describe, expect, it } from "vitest"; + +const SCRIPT = join( + dirname(fileURLToPath(import.meta.url)), + "..", + ".agents", + "scripts", + "review-ledger.mjs", +); + +function git(cwd: string, ...args: string[]): string { + return execFileSync( + "git", + ["-c", "user.name=t", "-c", "user.email=t@t", "-c", "commit.gpgsign=false", ...args], + { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }, + ).trim(); +} + +describe("review-ledger.mjs", () => { + it("posts the findings as review-metrics.mjs wrote them back: a class with words after its rule is the rule plus a detail", () => { + const root = mkdtempSync(join(tmpdir(), "review-ledger-")); + const origin = join(root, "origin.git"); + const work = join(root, "work"); + mkdirSync(origin); + mkdirSync(work); + mkdirSync(join(root, "config")); + git(origin, "init", "-q", "--bare"); + git(work, "init", "-q", "-b", "main"); + git(work, "remote", "add", "origin", origin); + git(work, "commit", "-q", "--allow-empty", "-m", "head"); + const head = git(work, "rev-parse", "HEAD"); + git(work, "push", "-q", "origin", `${head}:refs/pull/7/head`); + const findings = join(root, "findings.json"); + const finding = (id: string, name: string) => ({ + id, + role: "code", + class: name, + outcome: "fixed", + path: "src/a.ts:1", + round: "1", + }); + writeFileSync( + findings, + JSON.stringify({ + findings: [ + finding("R1", "testing 3: error path"), + finding("R2", "testing 3 wiring untested"), + ], + }), + ); + + const run = spawnSync( + process.execPath, + [SCRIPT, "7", "--issue", "5", "--findings", findings, "--round", `1:${head}`, "--dry-run"], + { + cwd: work, + encoding: "utf8", + env: { ...process.env, CLAUDE_CONFIG_DIR: join(root, "config"), GH_REPO: "o/r" }, + }, + ); + + const block = /```json\n(.*)\n```/.exec(run.stdout)?.[1] ?? "{}"; + const posted = JSON.parse(block) as { findings?: { class: string; detail?: string }[] }; + expect(posted.findings?.map((f) => [f.class, f.detail])).toEqual([ + ["testing 3", "error path"], + ["testing 3", "wiring untested"], + ]); + expect(run.stdout).toContain('Classes: {"testing 3":2}.'); + }); +}); diff --git a/src/review-metrics.test.ts b/src/review-metrics.test.ts index a66b98477..aeb64f7e5 100644 --- a/src/review-metrics.test.ts +++ b/src/review-metrics.test.ts @@ -1,5 +1,5 @@ import { spawnSync } from "node:child_process"; -import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs"; +import { mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { dirname, join } from "node:path"; import { fileURLToPath } from "node:url"; @@ -138,4 +138,64 @@ describe("review-metrics.mjs", () => { expect(refused.code).not.toBe(0); expect(refused.err).toContain("duplicate R1 must name a canonical finding"); }); + + it("with --findings writes a class that starts with a rule and its number back as that rule plus a detail, and leaves other classes alone", () => { + const config = home({}); + const file = join(mkdtempSync(join(tmpdir(), "findings-")), "findings.json"); + const finding = (id: string, name: string) => ({ + id, + role: "code", + class: name, + path: "src/a.ts:1", + outcome: "fixed", + }); + writeFileSync( + file, + JSON.stringify({ + findings: [ + finding("R1", "testing 3: error path"), + finding("R2", "Testing 10 time boundary not straddled"), + finding("R3", "safety 1, safety 9"), + finding("R4", "documentation contradicts code"), + finding("R5", "spec line undelivered"), + ], + }), + ); + + const run = metrics(config, "--pr", "7", "--findings", file); + + expect(run.out).toContain( + 'Classes: {"documentation contradicts code":1,"safety 1":1,"spec line undelivered":1,"testing 10":1,"testing 3":1}.', + ); + const written = JSON.parse(readFileSync(file, "utf8")) as { + findings: { class: string; detail?: string; id: string }[]; + }; + expect(written.findings.map((f) => [f.id, f.class, f.detail])).toEqual([ + ["R1", "testing 3", "error path"], + ["R2", "testing 10", "time boundary not straddled"], + ["R3", "safety 1", "safety 9"], + ["R4", "documentation contradicts code", undefined], + ["R5", "spec line undelivered", undefined], + ]); + }); + + it("with --findings refuses a class that names a rule file and no rule number, says the accepted forms, and leaves the file as it was", () => { + const config = home({}); + const file = join(mkdtempSync(join(tmpdir(), "findings-")), "findings.json"); + const text = JSON.stringify({ + findings: [ + { id: "R1", role: "code", class: "testing 3: error path", path: "a.ts:1", outcome: "open" }, + { id: "R2", role: "code", class: "testing: wiring", path: "a.ts:1", outcome: "open" }, + ], + }); + writeFileSync(file, text); + + const run = metrics(config, "--pr", "7", "--findings", file); + + expect(run.code).not.toBe(0); + expect(run.err).toContain( + 'finding R2 has class "testing: wiring", which names the rule file testing and no rule number. Accepted: "testing ", "testing : "', + ); + expect(readFileSync(file, "utf8")).toBe(text); + }); }); diff --git a/src/review-score.test.ts b/src/review-score.test.ts new file mode 100644 index 000000000..c6d4afe20 --- /dev/null +++ b/src/review-score.test.ts @@ -0,0 +1,178 @@ +import { execFileSync, spawnSync } from "node:child_process"; +import { copyFileSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { dirname, join } from "node:path"; +import { fileURLToPath } from "node:url"; + +import { beforeAll, describe, expect, it } from "vitest"; + +const SCRIPTS = join(dirname(fileURLToPath(import.meta.url)), "..", ".agents", "scripts"); + +const TRUTH = { + pr: 7, + findings: [ + { + id: "R1", + role: "code", + class: "testing 3", + outcome: "fixed", + path: "src/a.test.ts", + round: 1, + }, + { + id: "R2", + role: "claims", + class: "documentation 7", + outcome: "fixed", + path: "docs/a.md", + round: 1, + }, + ], + escaped: [ + { + bug: 31, + fix: "f".repeat(40), + round: "1", + places: [ + { file: "src/seeds.ts", start: 40, end: 48 }, + { file: "src/delete.ts", start: 10, end: 12 }, + ], + }, + { + bug: 32, + fix: "e".repeat(40), + round: "1", + places: [{ file: "src/copy.ts", start: 5, end: 9 }], + }, + { + bug: 33, + fix: "d".repeat(40), + round: "2", + places: [{ file: "src/late.ts", start: 1, end: 3 }], + }, + ], +}; + +let work: string; +let config: string; + +function git(cwd: string, ...args: string[]): string { + return execFileSync( + "git", + ["-c", "user.name=t", "-c", "user.email=t@t", "-c", "commit.gpgsign=false", ...args], + { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }, + ).trim(); +} + +// why: the script reads its snapshot beside itself and the truth from origin, so the test gives it a checkout of its own with a local origin. +function checkout(pr: number, truth: object): void { + const origin = join(work, "..", "origin.git"); + const blob = execFileSync("git", ["hash-object", "-w", "--stdin"], { + cwd: origin, + encoding: "utf8", + input: JSON.stringify(truth), + }).trim(); + git(origin, "update-ref", `refs/replay/${String(pr)}/truth`, blob); + writeFileSync( + join(work, ".agents", "replay", `${String(pr)}.json`), + JSON.stringify({ pr, issue: null, rounds: { "1": { head: "a", base: "b", baseline: null } } }), + ); +} + +function score(pr: number, findings: object[]) { + const file = join(mkdtempSync(join(tmpdir(), "replay-findings-")), "findings.json"); + writeFileSync(file, JSON.stringify({ findings })); + const run = spawnSync( + process.execPath, + [ + join(work, ".agents", "scripts", "review-score.mjs"), + "--pr", + String(pr), + "--round", + "1", + "--findings", + file, + "--role", + "code", + ], + { encoding: "utf8", env: { ...process.env, CLAUDE_CONFIG_DIR: config } }, + ); + const rows = readFileSync(join(work, ".agents", "replay", "results.jsonl"), "utf8"); + return { + out: run.stdout, + row: JSON.parse(rows.trim().split("\n").at(-1) ?? "{}") as Record, + }; +} + +const finding = (id: string, path: string, outcome = "open") => ({ + id, + role: "code", + class: "seed left behind", + outcome, + path, +}); + +beforeAll(() => { + const root = mkdtempSync(join(tmpdir(), "review-score-")); + config = join(root, "config"); + work = join(root, "work"); + mkdirSync(config); + mkdirSync(join(root, "origin.git")); + git(join(root, "origin.git"), "init", "-q", "--bare"); + mkdirSync(join(work, ".agents", "scripts"), { recursive: true }); + mkdirSync(join(work, ".agents", "replay")); + for (const name of [ + "review-score.mjs", + "review-metrics.mjs", + "transcripts.mjs", + "cli-args.mjs", + ]) { + copyFileSync(join(SCRIPTS, name), join(work, ".agents", "scripts", name)); + } + git(work, "init", "-q", "-b", "main"); + git(work, "remote", "add", "origin", join(root, "origin.git")); + git(work, "commit", "-q", "--allow-empty", "-m", "start"); + checkout(7, TRUTH); + checkout(8, { pr: 8, findings: TRUTH.findings }); +}); + +describe("review-score.mjs", () => { + it("counts an escaped bug as found only when a blocking finding names one of its files and a line or range that overlaps the place", () => { + const { out, row } = score(7, [ + finding("F1", "src/delete.ts:12"), + finding("F2", "src/copy.ts:30"), + finding("F3", "src/copy.ts"), + finding("F4", "src/copy.ts:6", "nonblocking"), + finding("F5", "src/a.test.ts:3"), + ]); + + expect(out).toContain("Escaped bugs: recall 1/2."); + expect(out).toContain("escaped #31 found by F1"); + expect(out).toContain( + "ESCAPED #32 missed src/copy.ts:5-9; same file: F2 (other lines), F3 (no line), F4 (nonblocking) (adjudicate)", + ); + expect(row).toMatchObject({ escapedFound: [31], escapedMissed: [32], escapedRecall: "1/2" }); + }); + + it("reports recall on ledger findings apart from the escaped bugs, and a finding that found a bug is not unmatched", () => { + const { out, row } = score(7, [ + finding("F1", "src/seeds.ts:44-60"), + finding("F2", "copy.ts:9"), + finding("F5", "src/a.test.ts:3"), + ]); + + expect(out).toContain( + "recall 1/1 defects; 0 unmatched replay findings; 0 hits on known non-defects.", + ); + expect(out).toContain("Escaped bugs: recall 2/2."); + expect(row).toMatchObject({ escapedRecall: "2/2", recall: "1/1", unmatched: [] }); + }); + + it("prints no escaped line and writes no escaped fields for a snapshot whose truth has no escaped bugs", () => { + const { out, row } = score(8, [finding("F5", "src/a.test.ts:3"), finding("F6", "src/b.ts:1")]); + + expect(out).toContain("recall 1/1 defects; 1 unmatched replay findings;"); + expect(out).not.toContain("Escaped"); + expect(Object.keys(row).filter((key) => key.startsWith("escaped"))).toEqual([]); + }); +});