Skip to content

feat(#1520): 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 - #1587

Merged
admarble merged 10 commits into
mainfrom
feature/1520-feat-run-review-by-exception-a-computed-read-first
Oct 26, 2026

Conversation

@admarble

@admarble admarble commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Mutation-verified: AC-2 — removed src/lib/alpha.ts from AC-1's evidence in the fixture issue body; review-residue.test.ts > buildReviewResidue > explains the 2 files AC-1's evidence names and leaves 3 as residue failed (only that test); restored.

(parseMutationMarkers classifies this marker valid.)

After QA, every PR the orchestrator opens gets one comment starting ## Read first, with three sections in this order:

  • Residue: files no AC's evidence names, hot files, deleted or weakened tests, tautology hits, and diffs over 400 lines.
  • Tests: each test file's seam class (real, mock or prose), any mocked module the project doesn't own, and its mutation record.
  • Explained: files an AC's evidence names, with the AC id.

Every line under Residue and Tests ends with the command that produced it. Before posting, it reads the PR's comments and skips if a Read-first comment is already there. If the git reads fail, it logs a warning and posts nothing.

AC Status Evidence
AC-1 ✅ scripts/qa/ac-attribution-rate.ts; the evidence command prints ok. Result posted on #1520: 346 of 622 ACs (55.6%) across 215 issues.
AC-2 ✅ review-residue.test.ts: 11 passed
AC-3 ✅ -t "command": 2 cases
AC-4 ✅ review-residue.post.test.ts: 4 passed. Runs QA, loop, QA through runIssueWithLogging on a temp git repo and a fake provider: one post, none on a re-run, none when no qa ran, none when the git reads fail.
AC-5 ⬜ Runner-owned (testbed PR)
AC-6 ✅ scripts/qa/residue-outcomes.ts --since 2026-10-24 --json prints ok; all four counters are 0 today
AC-7 ✅ The grep count is 0
AC-8 ✅ The grep count is 3

Files:

  • New: src/lib/workflow/review-residue.ts (the partition, no I/O) and review-residue.post.ts (git reads and the post).
  • Changed: batch-executor.ts, where the new postReadFirstForPR runs after the post-QA PR update.
  • types.ts: a readFirstProvider test hook on the issue context.
  • github.ts: two read-only list methods; the gh output buffer is raised to 32 MB because lists with bodies passed the 1 MB default.
  • Two captured gh fixtures, the two scripts and their tests.
  • docs/reference/review-residue.md, ADR-0021 and a CHANGELOG entry.

Checks:

  • npm run build, npm run lint and npm run lint:health pass ("no metric rose above the baseline").
  • Affected tests: npx vitest run --changed origin/main in 3 shards (205 files) plus the whole-tree scanners and the tests that read changed files. 4,760 pass, 1 fails.

The one failure is in a file this branch doesn't touch:

Settled against base

Ref Result
Head 5ba85c18d FAIL
Base origin/main @ 683ce66e1 FAIL

driver-conformance.test.ts › codex › "git add and git commit succeed inside the driver's default sandbox": it was already failing on main, and #1480 tracks it.

Weakest part: the comment isn't refreshed. A later run that changes the diff leaves the first comment in place, and only the commit field in its marker shows it's stale (see ADR-0021). The path matching also only counts exact paths or path suffixes in evidence; a directory named in evidence explains nothing.

Coverage gaps: the two new provider methods are tested through the scripts' fixture tests only, not in github.test.ts.

Branch: feature/1520-feat-run-review-by-exception-a-computed-read-first.

Fixes #1520

QA verdict: AC_MET_BUT_NOT_A_PLUS — acceptance criteria met, but not A+. The run broke to this PR for review rather than entering the quality loop; see the QA review comment for improvement notes.

Follow-ups

  • The test-line command does not reproduce the classification it sits beside — dropped: advisory polish, R-3 satisfied in form
  • Attribution rate counts directory/ref tokens that explain nothing in the comment — dropped: rate is reported, not gated (R-2)

🤖 Generated by sequant run


Runner verification (2026-10-25, head 1858c1273)

History. QA 1 on 5ba85c18d: AC_NOT_MET. Its class finding was real and visible on this PR: the Read-first post sat inside the success-only PR branch of deliverIssueBranch, so a run ending AC_NOT_MET (this PR's own run; it got no comment) or a failing qa-only re-run never posted. Owner's word: runner fixes, then qa-only re-runs.

  • b5957373a: postReadFirstForPR runs after the last QA iteration on every verdict and resolves the PR itself (post-QA PR, else the PR opened after exec, kept on IssueRunState.earlyPr, else the state record); mutation records merge the PR body (fetchIssue on the PR number) with this run's exec output; the prose seam uses fix(qa): the proseGate metric counts any test file that mentions SKILL.md — 34 of 76 counted files are not prose gates; count only files that read a SKILL.md and assert on it #1566's isProseGate, moved to src/lib/prose-gate.ts and imported by health-report.ts too; two new AC-4 cases cover the failing-verdict paths.
  • QA 2 on b5957373a: AC_MET_BUT_NOT_A_PLUS, 7/8 (AC-5 runner-owned).
  • 2a5a5f7bd: hot files are counted from history up to the diff base, so a PR made of fix(...) commits no longer flags its own files; the rendered command names the base.
  • Independent code review (high) of the PR: 10 findings, 8 fixed in 57928b907: a SEQUANT_MUTATION record matches its test file by the feat(qa): mutation-verification becomes a parseable §7 gate instead of honor-system prose #939 classifier's rule (equal or bare-name suffix); a bare file name in evidence explains only a root-level file (R-2); __tests__/fixtures and __tests__/helpers are not test files; the state-record fallback posts only on a PR that is still open; the dedup read runs before the git collection; core.quotepath=off on the numstat and the log; the log is restricted to the diff's paths so it is the query the comment prints; MOCK_CALL_RE recognises vi.mock(import("x")). Left as follow-ups: the live GitHubProvider default on the test path (the same pattern as the existing postComment seam) and a fourth local git() wrapper.
  • 1858c1273: the bare-name attribution case carries its own issue body, so AC-2's mutation fails exactly the gate test.
  • QA 3 on 1858c1273: AC_MET_BUT_NOT_A_PLUS, 8/8. Its two fix_now items are test gaps on runner code, left as follow-ups by the owner's merge decision: no unit test feeds a PR body with a SEQUANT_MUTATION record through deliverReadFirstComment, and none drives resolveReadFirstPR's state-record fallback and open-PR guard (the fake provider always answers open and stateManager is null in the post tests). Its advisory notes: the test-line grep does not reproduce the classifier (doMock, vi.mock(import()), the prose rule); the attribution rate counts directory and ref tokens the comment rejects (reported, not gated); the verdict link names the issue, not the comment; rendered paths are not shell-quoted; residue-outcomes.ts counts issue-thread comments only.
  • QA 2's Follow-ups: hot-file count → fixed in 2a5a5f7bd; the PR-body marker merge and the state-manager fallback have no dedicated unit test (the fake-provider cases in review-residue.post.test.ts and the testbed runs exercise the paths); the tautology command names a sequant-repo script (the issue's R-4 choice; a project without it gets an empty tautology line).

ACs re-run on 1858c1273 (branch worktree): AC-1 ok (346 of 622, 55.6%, posted on #1520); AC-2 13 passed; AC-3 2 passed; AC-4 6 passed; AC-6 ok (four zero counters); AC-7 0; AC-8 3. Execution-verification record for both scripts is on #1520.

AC-5 (testbed). ad-motion #285 "(run 6)" on this head's dist: PR admarble/ad-motion#291; gh pr view 291 --json comments --jq '[.comments[].body | select(startswith("## Read first"))] | length' → 1, and it is comment index 0, the only comment. Sections: Residue none, Tests none, Explained docs/golden-run.md — AC-1, AC-2, verdict link, marker {"pr":291,"commit":"75b483d"}. suppressed 12/other as in runs 3 to 5. Run 5 (#290) gave the same result on 2a5a5f7bd. Both PRs closed unmerged; testbed reset. Details on #1520.

Mutation reproduced by the runner on 1858c1273: removed `src/lib/alpha.ts` exports it from AC-1's evidence in the fixture issue body; review-residue.test.ts > buildReviewResidue > explains the 2 files AC-1's evidence names and leaves 3 as residue was the only failure (1 failed, 12 passed); restored; 13 pass.

Other checks. Freeze grep 0; no session links, attribution lines or home paths in the diff or commit messages; branch 0 behind main; tsc, eslint on the changed sources, lint:health ("no metric rose above the baseline") and npm run build pass; batch-executor.test.ts, model-ladder, suppressed-integration and mutation-marker.test.ts pass. knip-advisory fails with the pre-existing list, as on #1578 and #1585. The one known local failure is codex driver-conformance (#1480), also failing on main.

…, AC-explained files

Entire-Checkpoint: fa8cef753adc
…d by reading the PR

Entire-Checkpoint: bcc791fbf411
…o read-only provider lists

Entire-Checkpoint: b42b05e59f36
…nexport internals

Entire-Checkpoint: f9fcc48db225
…on records from the PR body, class prose seams by the #1566 rule

QA on PR #1587 found the receipt missed two paths: a run ending AC_NOT_MET and a failing qa-only re-run never reached the post, which sat in the success-only PR branch. postReadFirstForPR now runs after the last QA iteration and resolves the PR itself: the post-QA PR, else the PR opened after exec (kept on IssueRunState.earlyPr), else the PR the state recorded. Mutation records merge the PR body with this run's exec output, so the cited gh pr view command is the real source. The prose seam class uses isProseGate, moved from health-report.ts to src/lib/prose-gate.ts so both surfaces count the same files. Two new AC-4 cases cover the failing-verdict paths.

Entire-Checkpoint: f8fdd21b7523
… PR's own fix commits

QA 2 risk finding: git log on HEAD included the branch's own commits, so a PR made of fix(...) commits flagged its own files as hot. The log now ends at the diff base, and the rendered command names that base.

Entire-Checkpoint: 9aae3c696852
…ribution, fixtures are not tests, open-PR gate on the state fallback, dedup before collection, quotepath off, typed vi.mock form, log restricted to the diff's paths

From the independent review of PR #1587. The Tests line now matches a SEQUANT_MUTATION record by the #939 classifier's rule (equal or bare-name suffix). A bare file name in evidence explains only a root-level file (R-2). __tests__/fixtures and __tests__/helpers are inputs, not tests. The state-record fallback posts only on a PR that is still open. The dedup read runs before the git collection. numstat and log run with core.quotepath=off; the log is restricted to the diff's paths so it is the query the comment prints. MOCK_CALL_RE recognises vi.mock(import("x")). Left as follow-ups: the live-provider default on the test path (same pattern as the postComment seam) and the fourth local git() wrapper.

Entire-Checkpoint: 4dce7585c645
So AC-2's recorded mutation (removing src/lib/alpha.ts from the shared fixture's AC-1 evidence) fails exactly the gate test, as the record says, and no other case.

Entire-Checkpoint: 6e2c4bad49ac
@admarble
admarble merged commit 7f44ec4 into main Oct 26, 2026
9 of 10 checks passed
@admarble
admarble deleted the feature/1520-feat-run-review-by-exception-a-computed-read-first branch October 26, 2026 05:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant