v0.7.0 — token-burn: Fix pr-reviewer base-branch detection so diff scopes correctly
Problem
pr-reviewer's spawn prompt does not reliably pass an explicit diff base. In multi-MR sessions (like v0.6.0 release with 11+ in-flight MRs), pr-reviewer has been observed running git diff against the wrong target — comparing the current branch against main when the correct comparison is against dev, or against a stale upstream pointer.
The bigger the diff pr-reviewer ingests, the more tokens burn AND the lower the review quality (signal lost in noise).
Evidence (verified against live source)
agents/pr-reviewer.mdfrontmatter declarestools: Read, Glob, Grep, Bash, Task, mcp__plugin_tmb_trajectory-serverandskills: [tmb_review]— pr-reviewer runs as a CC subagent, has Bash access, and loadstmb_review(274 LOC) at spawn.skills/tmb_review/SKILL.md§A "Worktree discipline" and §A Phase 1 reasoning sections cover correctness/design/pattern reasoning, but do not prescribe how to compute the diff base — they assume bro passes commits.skills/tmb_review/SKILL.md§C "Spawning pr-reviewer (bro-side discipline)" — bro's spawn prompt construction lives here but base-ref discipline is implicit.templates/agents/pr-reviewer.mdmatchesagents/pr-reviewer.mdexactly (project-local mirror).- This was identified as Cause C/D contributor in !2900 (closed in v0.6.0); the workflow doctrine was tightened but diff-base detection itself was not addressed.
Plan
- Spawn-prompt contract: extend
tmb_review §Cso bro MUST passbase_ref(e.g.origin/dev) explicitly. pr-reviewer MUST refuse ifbase_refis missing. - Diff scope rule in
tmb_review §A: "Compute diff exactly asgit diff <base_ref>...HEAD— nevergit diff mainorgit diff HEAD~Norgit diff origin." - Diff-size cap: if
git diff <base>...HEAD | wc -lreturns >2000 LOC, pr-reviewer refuses and asks bro to split the push. - Schema column
pr_review_runs.diff_loc INTEGER— recorded by pr-reviewer at start of review. Enables post-fix measurement. - L4 simulation: spawn pr-reviewer with intentionally-stale upstream pointer or no
base_ref; verify it refuses cleanly.
Acceptance criteria
- New L4 test: pr-reviewer spawned without
base_refrefuses with structured error. - New L4 test: pr-reviewer spawned with diff >2000 LOC refuses with "diff too large; split push" message.
- Schema v3 includes
pr_review_runs.diff_loc. - L5 dogfood verifies pr-reviewer diff size is bounded.
Out of scope
- Auto-splitting commits into smaller chunks.
- Per-file vs per-commit review modes.
Coordination
- !2900 (closed in v0.6.0) covered workflow/protocol gaps. This covers the diff scope gap that remained.
- Pairs with #2906 (schema v3) —
pr_review_runs.diff_locwould ship in that migration.
Note on source
Verified against agents/pr-reviewer.md, templates/agents/pr-reviewer.md, skills/tmb_review/SKILL.md (sections A, C). Previous description had the right symptom but didn't cite the specific section/file lines.
Edited by Zax Shen