Repository navigation
Description
Epic: graph-2026-10-review-surface Tier: judgment Execution: split (unit evidence from phases; one testbed PR read by the runner) Blocked by: #1507 (file scope: the post call lands after the batch-executor split)
Problem
Agent PRs are merged fast here (median 3.7 h open-to-merge over the last 100 merged PRs) against a median fix of 132 test lines and 45 source lines, at roughly 55 issues a week. Reading every line is not possible at that volume, and the data says where the misses are: re-patches of the same artifact (~78% in the 2026-09-30 retrospective), the four workflow files that took 40 of 83 fixes, tests that mock the one subprocess seam or assert markdown wording, and errors dropped by policy. The per-AC verdict answers "did it do what I asked" and nothing else. The GTM brief's cold reader also named the constraint: the audience distrusts summaries written by the author of the code.
So the reviewer needs a computed partition of the diff, posted where the merge decision is made, with the residue first:
- Residue — hunks in files no AC's evidence cites; hot files (≥ 3 fix commits in 28 days, from
git log); deleted or weakened tests (--numstaton test paths); tautology-detector hits (--json); size over the budget; later, the run's suppressed-error count (feat(run): a dropped error leaves a trace — noteSuppressed() counts into the run log, batch-executor's 25 silent catches converted #1504). Each line carries the command that produced it. The human reads this in full. - Tests — each test file in the diff with its seam class (real dependency /
child_processor module mock / prose gate readingSKILL.md) and whether aSEQUANT_MUTATIONrecord exists for it (parseMutationMarkers). A mock of a type the project does not own is flagged. - Explained — files that an AC's declared
Evidence:(feat(spec/qa): explicit Evidence: clause on ACs — declared verification replaces keyword inference #938) or verdict line names, with the AC id. Sampled, not read.
Attribution is a parse, not a model: an AC "explains" a file only when its evidence clause names that path, test file or command whose arguments name it. Measured today over the 80 most recently closed issues: 258 ACs, 257 with an Evidence: clause, 149 (58%) name a file or command. The rest explain nothing, so their hunks fall into residue by default. Residue is the conservative default; explained is earned.
Decisions
| ID | Decision | Rejected alternative |
|---|---|---|
| R-1 | Posted as a PR comment through PlatformProvider.postPRComment, the path the merge-check report already uses |
editing the PR body's top (the exec skill writes the body; the edit needs the gh api PATCH path and "first thing seen" is GitHub's ordering, not ours) — follow-up after the freeze |
| R-2 | Unattributed → residue. A file is explained only by an AC whose evidence names it | heuristics or a model guessing which AC a hunk serves (the author-distrust constraint; the same-model blind spot) |
| R-3 | Every line is computed and shows its command; no narrative sentences | a generated summary (the brief: "summaries written by the thing that wrote the diff") |
| R-4 | Sources are in-repo: git log, git diff --numstat, tautology-detector-cli --json, parseMutationMarkers, the issue body's Evidence: clauses |
requiring accretion (personal tooling; cited, never required, as in #1501 D-C) |
| R-5 | Order: Residue, Tests, Explained, then a link to the AC verdict comment | AC table first (it answers the question the reviewer already trusts) |
Acceptance Criteria
- AC-1: The attribution rate is measured by a committed script before the partition ships, and recorded on this issue. Evidence:
npx tsx scripts/qa/ac-attribution-rate.ts --closed-since 2026-09-20 --json | jq -e '.acs > 0 and (.rate | type == "number")' > /dev/null && echo ok→ok(58% at filing, 149 of 258; the number is reported, not gated, because R-2 makes unattributed ACs residue) - AC-2: The partition is a pure function of diff + issue body + repo history. Evidence:
npx vitest run src/lib/workflow/review-residue.test.ts→≥ 6 passed, 0 failed(fixture: a diff touching 5 files, an issue body whose AC-1 evidence names 2 of them → 2 explained, 3 residue; a hot file is flagged from a fixturegit log; a deleted test line is flagged from--numstat; achild_processmock is classedmock; aSKILL.mdreader is classedprose; a file with a mutation record is marked; an AC with no path explains nothing) - AC-3: Every residue and test line carries its producing command. Evidence:
npx vitest run src/lib/workflow/review-residue.test.ts -t "command"→≥ 1 passed, 0 failed(every line under## Residueand## Testsmatches /[^]+`/) - AC-4: Every PR the orchestrator opens gets the comment after the QA phase, once per PR. Evidence:
npx vitest run src/lib/workflow/review-residue.post.test.ts→≥ 2 passed, 0 failed(a fakePlatformProviderrecords onepostPRCommentwhose body starts## Read first; a second QA iteration does not post a second one) - AC-5: On a real run the comment is present and first (runner, testbed). Evidence:
gh pr view "$PR" --json comments --jq '[.comments[].body | select(startswith("## Read first"))] | length'→1where$PRis the testbed PR the runner names on this issue - AC-6: The outcome is measured, lagging and confounded, over the 28 days after the first release that carries it. Evidence:
npx tsx scripts/qa/residue-outcomes.ts --since <release date> --json | jq -e '.withResidue.total >= 0 and .withResidue.commentedBeforeMerge >= 0 and .emptyResidue.total >= 0 and .emptyResidue.commentedBeforeMerge >= 0' > /dev/null && echo ok→ok(null result named: a residue nobody reads changes nothing, and this number will show it) - AC-7: No skill-directory edits. Evidence:
git diff --name-only $(git merge-base origin/main HEAD)..HEAD | grep -cE '^(plugin/|\.claude/skills/|templates/skills/)'→0(constraint) - One AC above is classified as a gate test by
isGateTestEvidence(the fixture-based AC-2); the PR body carries itsSEQUANT_MUTATIONrecord (remove the path from the fixture's AC-1 evidence → the "2 explained, 3 residue" case fails; restore). - AC-8: A public reference page explains the three sections and their commands. Evidence:
test -f docs/reference/review-residue.md && grep -cE '^## (Residue|Tests|Explained)' docs/reference/review-residue.md→3
Prior fixes / producers
- "The receipt reaches the PR" has three prior fixes: bug(run): orchestrated 'sequant run --phases qa' re-run computes a fresh verdict but never posts it, contradicting the stale comment left visible #964 built the verdict comment, fix(run): sequant run has two PR producers — exec opens the PR itself and createPR returns it untouched, dropping the QA note, ready-gate report and summary #1247 and fix(exec): under the orchestrator, a loop exec rewrites the PR body itself (gh api PATCH), so later sequant updates are dropped as "edited by hand" #1302 fixed the lost receipt, fix(#1311): drivers join agent text on line boundaries, so exec's ## Summary reaches the PR body #1340 fixed the PR-body placeholder. Class, not site: AC-4 states the outcome for every PR the orchestrator opens.
- Producers of PR comments today: the QA verdict comment (
buildQaVerdictComment, batch-executor.ts) and the merge-check report (merge-check/report.ts). This adds a third, through the same provider method; refactor(platform): every gh call goes through PlatformProvider; FakeGitHubProvider replays captured gh output so no test fakes gh through child_process #1506 moves all of them behindPlatformProvider. - Inputs that already exist:
parseAcceptanceCriteria+Evidence:(feat(spec/qa): explicit Evidence: clause on ACs — declared verification replaces keyword inference #938),parseMutationMarkers,tautology-detector-cli --json, the scope analyzer's directory-spread heuristics (reusable for the hot-file grouping), the per-AC state record (evidencefield, written but never rendered).
May touch
src/lib/workflow/review-residue.ts (new), review-residue.test.ts, review-residue.post.test.ts (new), the one post call after the QA phase (in batch-executor.ts after #1507, or a sibling module it calls), scripts/qa/ac-attribution-rate.ts (new), scripts/qa/residue-outcomes.ts (new), docs/reference/review-residue.md (new), CHANGELOG.
Non-Goals
- Rendering the per-AC table in the terminal,
sequant statusor the progress mod: a different object with a different consumer; follow-up after feat(run): a dropped error leaves a trace — noteSuppressed() counts into the run log, batch-executor's 25 silent catches converted #1504 makes the state record trustworthy. - Placing the partition at the top of the PR body (R-1 follow-up after the freeze).
- Any narrative summary, by any agent. Narrative stays in the QA verdict comment, written by the separate QA session.
- Any edit under
plugin/,.claude/skills/,templates/skills/. - Requiring accretion or the health report (feat(qa): health-report.ts — one script prints the fundamentals baseline, --check fails a raised metric, advisory CI job, release-checklist line #1502); their numbers are cited when present.
Done when
Every PR the orchestrator opens carries one ## Read first comment whose residue a reviewer can read in full, and the outcome script exists to tell us, a month later, whether anyone did.
Activity
admarble commentedon Oct 24, 2026
Runner context for the phases (posted 2026-10-24 before launch; main is
683ce66e1, #1507 and #1508 are merged).Where things are now
buildQaVerdictCommentinsrc/lib/workflow/batch-executor.ts(call site near line 981, after the refactor(workflow): split runIssueWithLogging (1,620 lines) into stage functions of ≤ 200 counted lines, behaviour-preserving #1507 stage split). The one post call for## Read firstgoes after the QA phase, once per PR, throughprovider.postPRComment(prId, body)(PlatformProvider,src/lib/workflow/platforms/platform-provider.ts:76; GitHub implementationgithub.ts:1106). Precedent:src/lib/merge-check/report.ts:320. Since refactor(platform): every gh call goes through PlatformProvider; FakeGitHubProvider replays captured gh output so no test fakes gh through child_process #1506 no test may fakeghthroughchild_process; use the provider interface orFakeGitHubProvider.parseAcceptanceCriteriaandisGateTestEvidence(src/lib/ac-parser.ts),parseMutationMarkers(src/lib/workflow/mutation-marker.ts),scripts/qa/tautology-detector-cli.ts --json.src/lib/workflow/**hasmax-lines-per-functionat 200 counted lines (refactor(workflow): split run, ensureWorktree, executePhaseWithRetry and executePhase to ≤ 200 counted lines; max-lines-per-function ratchet for src/lib/workflow #1508);npm run lint:healthfails iffunctions.over200rises above the baseline, which is 0. Keep stage functions small from the start.Constraints for exec
npx vitest run <file>); do not start the full suite, and never in the background.plugin/,.claude/skills/,templates/skills/(AC-7). NoCo-Authored-By, no session links in commits or the PR body.<!-- SEQUANT_MUTATION: {"ac":"AC-2","mutation":"<what you removed from the fixture>","failedTest":"src/lib/workflow/review-residue.test.ts > <describe> > <case>"} -->plus the prose lineMutation-verified: AC-2 — ...; ...; restored.Actually perform the mutation and restore before writing it.--since <date>and print the four fields with zeros when no release carries the feature yet.Runner-owned, leave unchecked
admarble commentedon Oct 24, 2026
Complexity: Standard (8 ACs, 5 directories)
AC Quality Check
lintAcceptanceCriteria: all 8 pass. Each AC has one line and anEvidence:clause. Run againstmain(683ce66e1): AC-1, AC-2, AC-3, AC-4, AC-6 and AC-8 fail today because the files do not exist. AC-7 passes today because it is a constraint, which is expected. AC-5 belongs to the runner.isGateTestEvidenceclassifies only AC-2 as a gate test, as the issue says.Scope Assessment
Non-Goals: present (no terminal, status or mod rendering; no PR-body placement; no narrative; no skill-directory edits; no accretion requirement).
src/lib/workflow,src/lib/workflow/platforms,scripts/qa,docs/reference, root)Verdict:⚠️ SCOPE_WARNING. This turns on the quality loop. Splitting is not needed: the two scripts are small and share the parse.
Acceptance Criteria
scripts/qa/ac-attribution-rate.tsreads closed issues, parses their ACs and counts the ACs whose evidence names a path or command. It prints{acs, attributed, rate}. Exec runs it and posts the JSON on feat(run): review by exception — a computed "Read first" PR comment partitions the diff into residue (nothing vouches for it), tests by seam class, and AC-explained hunks #1520. Assumption:listClosedIssuesSyncdoes not returnbody, so it needs a--closed-sincevariant that does (see Plan 1.1).buildReviewResidue(input)with no I/O.commandcase asserts that every line under## Residueand## Testsmatches/`[^`]+`/.PlatformProvider: a QA→loop→QA run records exactly onepostPRCommentwhose body starts with## Read first.scripts/qa/residue-outcomes.ts --since <date> --jsonprints the four counters. Each is0today.plugin/,.claude/skills/ortemplates/skills/.docs/reference/review-residue.mdhas## Residue,## Testsand## Explained.Implementation Plan
Phase 1: Inputs and provider (commit)
github.ts: addlistClosedIssuesWithBodySync(since)andlistMergedPRsWithCommentsSync(since)(number, mergedAt, body, comments{body,createdAt}). Each needs captured fixtures forFakeGitHubProvider(ADR-0019). The health metricghCallFilesOutsideProvidercoversscripts/, so neither script may spawnghitself.Phase 2: Pure partition (commit per file)
src/lib/workflow/review-residue.ts.{ numstat, testFileSources, issueBody, fixLog, tautology, mutationMarkers, verdictRef }. Every field is text or a parsed value; the function does no I/O.parseAcceptanceCriteria(issueBody). For each AC, pull path-shaped tokens out ofevidence, plus the arguments of any command in it, and match them against the diff paths. An AC with no path explains nothing (R-2).git log --since=28.days --format=%s --name-only, keeping commits whose subject starts withfix; a file with 3 or more counts as hot.--numstatfor test paths, deletions greater than additions, or the file was deleted.mockforvi.mock("child_process"|"node:child_process")or anyvi.mock;prosewhen the test readsSKILL.md;realotherwise. Avi.mockof a bare package specifier gets the flag "type not owned".parseMutationMarkers, matching on thefailedTestfile prefix.renderReadFirst()emits## Read first, then## Residue,## Tests,## Explained, then a link to the verdict, in R-5 order. Every residue and test line ends with its command in backticks. Last comes a<!-- SEQUANT_READ_FIRST: {"pr":N,"commit":"…"} -->marker.review-residue.test.ts: the AC-2 cases and the AC-3commandcase.Phase 3: Collect and post (commit)
collectReviewResidueInput(worktreePath, base)in the same module, or a siblingreview-residue.collect.ts. It runs the git commands, the library form of the tautology detector (src/lib/test-tautology-detector.ts) and reads the test file sources. The rendered line still names the CLI command (npx tsx scripts/qa/tautology-detector-cli.ts --json).postReadFirstComment(provider, prNumber, body). It readsgetIssueComments(String(prNumber)); GitHub PR comments are issue comments. If any comment body starts with## Read firstor carries the marker, it skips. Otherwise it posts withpostPRComment. A failure is logged throughwarnand never fails the run. That is the fix(platforms): PlatformProvider has no error contract — postPRComment is still unchecked and the ready gate's report-post catch is empty (#1312 follow-up) #1315 contract, the same onepostQaVerdictCommentfollows.deliverIssueBranchinbatch-executor.ts, right afteropenOrUpdatePRsucceeds. That point runs after the last QA iteration, on both the create path and the update path (qa-only re-run). Injectproviderthroughenv.ctx.servicesso the test passes a fake.review-residue.post.test.tscovers the AC-4 cases: one post; a second QA iteration does not post again; and a re-run where the comment already exists does not post again.Phase 4: Scripts, docs, ADR (commit each)
scripts/qa/ac-attribution-rate.ts(AC-1) reuses the attribution function from step 2, so the rate measures the same parse that ships.scripts/qa/residue-outcomes.ts(AC-6) splits merged PRs intowithResidueandemptyResidueby the marker comment.commentedBeforeMergecounts PRs where a human (non-bot) comment came after the Read-first comment and beforemergedAt.docs/reference/review-residue.md, a CHANGELOG entry, anddocs/adr/0021-review-residue-read-first.md(see Design Review).Design Review
src/lib/workflow/review-residue.ts. Batch-executor gets one call site and nothing else, sobatch-executor.tsdoes not grow past what refactor(workflow): split runIssueWithLogging (1,620 lines) into stage functions of ≤ 200 counted lines, behaviour-preserving #1507/refactor(workflow): split run, ensureWorktree, executePhaseWithRetry and executePhase to ≤ 200 counted lines; max-lines-per-function ratchet for src/lib/workflow #1508 split.recordLoopPhaseOutcome, besidepostQaVerdictComment). The PR does not exist yet during QA on a first run;openOrUpdatePRruns later, indeliverIssueBranch. A post there would have no PR to target.getGitDiffStats?" Reuse it fornumstat. Hot files and seam classes need the raw text inputs to keep the partition pure, so the collector gathers those separately. "Why not match evidence against filenames only?" Commands likenpx vitest run Xname X as an argument, and the issue counts those.merge-check/report.ts:320(postPRComment) and the ready-gate report. The QA verdict goes to the issue, not the PR, throughpostComment. This change adds a third PR producer through the same provider method. The consumers of the new marker areresidue-outcomes.tsand the dedup step in step 5, so there is one producer and two consumers, and no parity test is needed. ADR required: the post site and the dedup choice (step 6 vs the QA loop) are a design choice. Record them indocs/adr/0021-*.Feature Quality Planning
childProcessMockFilesis 26, so the new tests must useFakeGitHubProvideror an injected provider, not mockchild_process(refactor(platform): every gh call goes through PlatformProvider; FakeGitHubProvider replays captured gh output so no test fakes gh through child_process #1506).over200is 0.warn. Never post a residue that looks empty.changelog.d/. If it merges first, write a fragment instead of editingCHANGELOG.md.Open Questions
git diff --numstatcommand. If this is wrong, the threshold is cosmetic; it is easy to move to settings later.postCommentreturnsvoid, so no comment URL is available. Recommendation: link to#<issue>and name theSEQUANT_QA_VERDICTcommit. If this is wrong, the reviewer clicks once more.fixtype (^fix(\(|:)). If this is wrong, hot files come out over- or under-counted. The fixture covers the rule.Recommended Workflow
Phases: spec → testgen → exec → qa
Quality Loop: enabled
Reasoning: AC-2, AC-3 and AC-4 declare unit-test evidence, so testgen stubs them. SCOPE_WARNING and the 4-fix receipt class turn on the loop. AC-5 belongs to the runner.
Label Review
Current: enhancement, graph-2026-10-review-surface. Recommended: add
planned. No other change.admarble commentedon Oct 24, 2026
AC-1 attribution rate, measured by the committed script on branch
feature/1520-feat-run-review-by-exception-a-computed-read-first(2026-10-24):npx tsx scripts/qa/ac-attribution-rate.ts --closed-since 2026-09-20 --json{ "closedSince": "2026-09-20", "issues": 215, "acs": 622, "withEvidence": 481, "attributed": 346, "rate": 0.556 }attributedcounts ACs whoseEvidence:clause names at least one path, bare or as a command argument, using the sameevidenceTargetsparse the Read-first comment uses. 346 of 622 ACs (55.6%) over 215 issues. At filing the issue measured 58% (149 of 258) over 80 issues. Reported, not gated (R-2).admarble commentedon Oct 24, 2026
QA Verdict: AC_NOT_MET
AC coverage: 6/8 met
Gaps:
fix(#1520): post the Read-first comment on every verdict, read mutati…
admarble commentedon Oct 26, 2026
QA Verdict: AC_MET_BUT_NOT_A_PLUS
AC coverage: 7/8 met
Gaps:
fix(#1520): count hot files from history up to the PR's base, not the…
admarble commentedon Oct 26, 2026
Execution Verification (runner, 2026-10-25, PR #1587 head
2a5a5f7bd)Both committed scripts run from the branch worktree with the AC's own flags; outputs verbatim.
npx tsx scripts/qa/ac-attribution-rate.ts --closed-since 2026-09-20 --json{ "closedSince": "2026-09-20", "issues": 215, "acs": 622, "withEvidence": 481, "attributed": 346, "rate": 0.556 }npx tsx scripts/qa/residue-outcomes.ts --since 2026-10-24 --json{ "since": "2026-10-24", "prsMerged": 1, "withResidue": { "total": 0, "commentedBeforeMerge": 0 }, "emptyResidue": { "total": 0, "commentedBeforeMerge": 0 } }Their tests:
npx vitest run scripts/qa/ac-attribution-rate.test.ts scripts/qa/residue-outcomes.test.ts→ 2 files, 6 passed. AC-1's jq predicate and AC-6's jq predicate both printokon these outputs.Fix commits after QA 1 and QA 2:
b5957373a(post on every verdict; PR-body mutation records; #1566 prose rule) and2a5a5f7bd(hot files counted up to the base). AC-5's testbed run is in progress on ad-motion #285 (run 5) with this head's build; its result follows here.admarble commentedon Oct 26, 2026
AC-5 evidence (runner, 2026-10-25)
Testbed PR: admarble/ad-motion#290, opened by
sequant run 285 --phases spec,exec,qa --force --full-qaon PR #1587's head2a5a5f7bd(dist built from that commit; ad-motion #285 "(run 5)", reset before the run: no branch, no comments, noplanned,.sequantsnapshot restored). Run: spec 28 s, exec 33 s, qa 58 s, 1 passed;suppressed12/other, as in runs 3 and 4.PR=290; gh pr view "$PR" --json comments --jq '[.comments[].body | select(startswith("## Read first"))] | length'→1Order check (
.comments | to_entries[]): index 0 is the## Read firstcomment (2026-10-26T03:31:21Z); it is the only comment on the PR.The comment's sections: Residue
nonewith itsgit diff --numstatcommand; Testsno test files in the diffwith its command; Explaineddocs/golden-run.md — AC-1, AC-2; the verdict link; theSEQUANT_READ_FIRSTmarker{"pr":290,"commit":"720f176"}. PR #290 is closed unmerged (testbed; never merge). Run log kept outside the repos asrun-2026-10-26T03-29-06-58af4bd3-....json.fix(#1520): code-review fixes — marker suffix match, no bare-name att…
test(#1520): the bare-name attribution case carries its own issue body
admarble commentedon Oct 26, 2026
AC-5 evidence, final head (runner, 2026-10-25)
Three runner commits landed after the run-5 evidence above (
57928b907code-review fixes,1858c1273test isolation), so the testbed ran again on the final head. The testbed PR for AC-5 is admarble/ad-motion#291 (ad-motion #285 "(run 6)", reset before the run, dist built from PR #1587 head1858c1273). Run: spec 30 s, exec 26 s, qa 50 s, 1 passed;suppressed12/other.PR=291; gh pr view "$PR" --json comments --jq '[.comments[].body | select(startswith("## Read first"))] | length'→1Order: index 0 is the
## Read firstcomment (2026-10-26T03:45:46Z), the only comment on the PR. Sections as in run 5; marker{"pr":291,"commit":"75b483d"}. PR #291 closed unmerged; testbed reset. Run 5 (#290) stands as the same result on2a5a5f7bd.admarble commentedon Oct 26, 2026
QA Verdict: AC_MET_BUT_NOT_A_PLUS
AC coverage: 8/8 met
Gaps:
grep -nE 'vi\.mock|jest\.mock|SKILL\.md'. The classifier also matchesdoMockandvi.mock(import(...)), and decides "prose" by read plus assertion. So the printed command can disagree with the class shown. R-3 is met in form, but the command isn't exactly the one that produced the line.ac-attribution-rate.tscounts every path token, including directory tokens (plugin/) and refs likeorigin/main. The comment'snamesPathrejects those. The rate is reported, not gated, but it reads slightly high next to the comment's own rule.SEQUANT_QA_VERDICTcomment on #N", which links the issue rather than the comment itself (R-5).residue-outcomes.tsonly counts issue-thread comments. Inline review comments and approvals don't register as reviewer activity. This is worth naming in the reference page as a limit of the measurement.admarble commentedon Oct 26, 2026
Follow-ups filed 2026-10-26 (owner's word), from QA 3's
fix_nowitems and the independent code review of PR #1587: #1588 (unit tests for the PR-bodySEQUANT_MUTATIONmerge andresolveReadFirstPR's state-record fallback with its open-PR guard), #1589 (the Tests line's printed command reproduces the class beside it; rendered paths shell-quoted), #1590 (the verdict link names the comment itself;postCommentreturns the URL), #1591 (no test seam defaults to a liveGitHubProvider), #1592 (onerunGithelper replaces the four localgit()wrappers). Not filed: QA 3's two advisory notes on the scripts (the attribution rate counts directory and ref tokens the comment rejects;residue-outcomescounts issue-thread comments only).docs(#1523): HANDOFF.md for graph-2026-10-review-surface — W0 and #1520…