Repository navigation
feat(review): ground /review findings in the code and verify each one - #2298
Conversation
will-lamerton
left a comment
There was a problem hiding this comment.
Thanks @puri-adityakumar, this is a strong piece of work. I went through it closely:
- Read-only holds. Agents get a fixed five-tool allowlist (
review-context.ts) that never touches the tool manager, MCP, shell or network, and unknown tool names error out (review-agent.ts:334). - Reads are pinned. Everything comes from git objects at the pinned
headOidviaspawnwith fixed argv.normalizeCitationPathrejects.., absolute paths,~, drive letters and NUL. - Citations are enforced against the zero-context hunk map, including deletion anchors.
- It's bounded: at most 71 model calls and 88 tool calls, with the abort signal checked before every one.
/review quickis still there and documented.- Tests: on a trial merge with current
mainit typechecks and 392 specs pass, includinglayering.spec. The only conflict is two adjacent tests insession-history-renderer.spec.tsx; keep both.
Two changes before merge:
1. Run the finder and verifier on the shared turn engine. review-agent.ts:109-378 is a hand-rolled agent loop: text-mode tool-call parsing, malformed-call retries, and a forced final turn without tools. That's what source/agent-loop/turn-engine.ts (#2097) exists for. TUI, --plain, ACP and subagents (subagent-executor.ts) all run on it now, and the goal is no per-frontend copies, so fixes like the malformed-call caps or XML-parsing changes reach every loop at once. The review-specific parts fit the engine's adapter: the fixed tool allowlist and the 24-call budget in executeTools, and the turn ceiling via its options (#2125 added a turn ceiling for subagents). Please port the loop onto runTurnEngine and drop the bespoke retry and parsing logic.
2. Changeset level. .changeset/grounded-default-review.md is patch, but making grounded review the default for /review and nanocoder review changes user-facing behaviour, so it should be minor.
Should fix (fine as a follow-up):
- Context window: tool results aren't counted against the model's context. Only the initial diff is scaled (
run-grounded-review.ts:104). On a 32k-context model (common with Ollama), ~38k chars of diff plus up to 24 tool results of ~12k chars overflow around turn 7, and the whole review reportsfailedrather than incomplete. Budgeting tool output against the remaining context, or truncating older results, would fix it. - Docs: "cites a line inside the changed code" really means within ±3 lines of a changed line or deletion anchor; worth saying so.
Nit: ReviewFoundationTools.execGh is exposed to the review tools but unused.
|
Thanks @will-lamerton, appreciate the close review. You're right that keeping a second agent loop in I've pushed the updates in
I also checked a trial merge with current |
…CLI (#2417) * feat(review): restore the review foundation that grounded /review builds on (#2297) * feat(review): restore the review foundation * fix(review): catch same-second worktree edits in review snapshots * feat(review): ground /review findings in the code and verify each one (#2298) * feat(review): restore the review foundation * fix(review): catch same-second worktree edits in review snapshots * feat(review): make grounded review the default /review * fix(review): show incomplete reviews as incomplete in the activity line * refactor(review): run review agents on the shared turn engine * fix(review): keep offered text tool calls beside quoted markup and bound unknown context sizes --------- Co-authored-by: akramcodez <[email protected]> * feat(review): add /review deep so one finder's blind spots don't go unreviewed (#2299) * feat(review): restore the review foundation * fix(review): catch same-second worktree edits in review snapshots * feat(review): make grounded review the default /review * fix(review): show incomplete reviews as incomplete in the activity line * feat(review): add /review deep with specialist finders * refactor(review): run review agents on the shared turn engine * fix(review): keep offered text tool calls beside quoted markup and bound unknown context sizes * fix(review): share the diff size limit so deep review and the verifier bound unknown context sizes --------- Co-authored-by: akramcodez <[email protected]> * feat(review): let nanocoder review run in CI and pipes without a terminal (#2300) * feat(review): restore the review foundation * fix(review): catch same-second worktree edits in review snapshots * feat(review): make grounded review the default /review * fix(review): show incomplete reviews as incomplete in the activity line * feat(review): add /review deep with specialist finders * feat(review): run nanocoder review without a terminal * refactor(review): run review agents on the shared turn engine * fix(review): keep offered text tool calls beside quoted markup and bound unknown context sizes * fix(review): share the diff size limit so deep review and the verifier bound unknown context sizes * fix(review): keep the cancelled report and exit code when a headless review is interrupted --------- Co-authored-by: akramcodez <[email protected]> * fix(review): align review specs and docs with main after merge * fix(review): strip ANSI in review specs so they pass with color forced on * fix(review): stop headless quick review passing on empty or partial output --------- Co-authored-by: Aditya Kumar Puri <[email protected]>
Description
Part 2 of 4 for #1287. Targets
feat/1287-grounded-reviewand builds on part 1 (#2297), so please merge that first. Until #2297 is merged, this diff also shows its 2 commits; the new work here is the last 2 commits.Problem.
/reviewsends the diff to the model in one shot. The model can report issues that are not in the code, cite lines that do not exist, or say "looks good" after reading only part of the change, and nothing checks any of it.What this PR does.
/reviewnow runs a grounded review over the pinned revision from part 1:file:lineinside the changed code. Issues without a valid citation are dropped and listed as dropped.Other changes:
dfor details,Escto cancel)./review activityshows the trace of the last review, and the report is saved with the session so it comes back on resume./review quickkeeps the old one-shot review.docs/features/review.md,docs/features/commands.md,docs/getting-started/index.md..changeset/grounded-default-review.md.knip.jsonignores from part 1, since the files are now used.Type of Change
Changeset
pnpm changeset) describing this change for the changelogTesting
Automated Tests
.spec.ts/tsxfilespnpm test:allcompletes successfully)Run on macOS, Node 22:
test:format,test:lint,test:types,test:knip,build: pass.test:ava: 11,414 pass, 38 fail. The same 38 fail on plainfeat/1287-grounded-reviewin the same setup, so none come from this PR (34 incli-value-flags.cli-integrationwith a React duplicate-key error, 2--acptrust checks that need a trusted checkout, 2 auto-commit tests).Manual Testing
GMI Cloud (
zai-org/GLM-5.3-Flash) on a fixture repo whosefeature/usersbranch has four seeded bugs insrc/users.js./reviewcompleted with 5 agents, 17 tool calls and 12 model calls, and found and verified all four bugs.Live panel:
Report:
/review activity(from a second run, which completed with 4 agents and 3 verified issues):/review quickstill runs the one-shot review:Checklist
Not a breaking change in the API sense, but plain
/reviewnow does more work (several model calls instead of one)./review quickkeeps the old behavior. Logging: review steps go to the review activity store, which the live panel and/review activityread.Part of #1287.