nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

Agentic /review: ground findings against the codebase (tier 2)

Open will-lamerton opened this issue 2 months ago • 6 comments

Follow-up to #1002 and #1099.

#1099 lands /review as a deliberate v1: one client.chat() over a diff, empty tool registry, no file reads. That caps review quality. The system prompt asks the model not to hallucinate issues, but gives it no way to check a finding against the surrounding code.

This issue covers the next tier: a review that can ground its findings.

Shape to settle here:

  • Default /review becomes a find-then-verify loop with a read-only tool profile (git_diff, git_log, read_file, search_file_contents, lsp_get_diagnostics) and a tool-call budget.
  • The current one-shot stays available as /review quick or equivalent.
  • Optional /review deep fans out finder subagents plus an independent per-finding verification pass.
  • Mandatory file:line citation per finding, with a confidence threshold that drops what cannot be verified.

@puri-adityakumar proposed this in detail in https://github.com/Nano-Collective/nanocoder/issues/1002#issuecomment-5553770805 and wants to work on it. @soumojit-D48 owns #1099. Please coordinate here rather than in the PR so #1099 can land as v1.

Also worth covering: nanocoder review is currently TTY-only, so CLI output cannot be redirected to a file. Teaching the plain shell to dispatch built-in commands would fix that and is a reasonable thing to fold into this work.

will-lamerton avatar Sep 13 '26 20:09 will-lamerton

Hi @will-lamerton, thank you for this. A few questions before I start:

  1. Could you assign #1287 to me so ownership is official?
  2. OK to ship as 3 stacked PRs (below)?
  3. Is plain-shell dispatch in scope for the first PR, or its own PR? It touches source/plain/shell.ts, which is core plumbing rather than review code, so happy to isolate either way.
  4. Confirming: verifiers can run a cheaper model than finders via the per-subagent model override (reviewModel knob)?

Plan:

  • Phase 0: spike: prove SubagentExecutor + read-only tool whitelist reviews a real diff productively (done, all checks passed)
  • Phase 1 → PR 1 (default tier): extract resolveReviewTarget() from #1099 (v1 behavior unchanged), review-finder + review-verifier subagents with read-only tools + tool-call budget, independent verifier per finding (CONFIRM / REJECT / INSUFFICIENT), tier dispatch (/review → default, /review quick → v1 one-shot), mandatory file:line citations, tests + changeset
  • Phase 2 → PR 2 (deep tier, on PR 1): three isolated finders (bugs / standards / spec), verifier fan-out, dedupe + sectioned report, /review deep, tests + changeset
  • Phase 3 → PR 3 (output + CLI, mostly independent): --output-format json + plain-shell dispatch so nanocoder review > file.md works, tests + changeset

Benchmark results (catch rate, false positives, citation validity, token cost) will be posted here once the default tier runs.

Since #1099 hasn't landed yet, PR 1 starts on my fork and rebases onto v1 when it merges. Nothing in the one-shot path or parseReviewCliArgs gets touched.

@soumojit-D48, would you like to stay involved in this work once #1099 lands, or is handing it over fine? Either works for me.

puri-adityakumar avatar Sep 16 '26 14:09 puri-adityakumar

I tested the current implementation in the TUI and found a few gaps before opening the replacement PR stack:

  • /review quick 1467 fails to fetch an upstream PR when origin points to my fork. A PR URL is not currently understood as a PR target.
  • Quick is intentionally a one-shot, diff-only review. I want to preserve that behavior, while fixing target resolution and clearly showing the reviewed scope and any diff truncation.
  • Default /review runs a finder/verifier pipeline, but the TUI does not show which agent is running or its tool/API calls. When an investigation hits its budget, the result can still look like a clean review. That should be labeled incomplete, not “no issues found.”
  • The review result’s raw Markdown styling also differs from normal chat output.

On main, /review reports no branch changes, then prints fatal: Needed a single revision.

Review on main shows no changes followed by a git revision error

On the feature branch, the finder hits its turn budget after a truncated diff, but the report says “No verified issues found” and displays raw Markdown beside normally rendered chat.

Grounded review reports no verified issues after budget exhaustion and renders raw Markdown

puri-adityakumar avatar Sep 24 '26 18:09 puri-adityakumar

Following up on the proposed replacement stack above, here is what I intend each PR to contain. I’d appreciate feedback on the boundaries before opening them.

  • Q — Quick fixes: Correct fork/upstream PR lookup, support explicit PR URLs, reject ambiguous or extra target text, and show the resolved scope and truncation. Quick remains one-shot: no finder, verifier, or tool calls.
  • 1 — Foundation: Give default/deep a read-only coordinator for natural requests, remote branches, and PR URLs. Validate and pin the target before review. Add compact live progress that can expand into agent, tool-call, and API-call details.
  • 2 — Grounded default: Bring the finder → citation validation → independent verifier flow onto that foundation. Show incomplete or failed investigations honestly and render the result consistently with the TUI.
  • 3 — Deep: Add the specialist finders and deduplication, reusing the same target, verification, and activity infrastructure.
  • 4 — Headless: Support non-TTY review with final text/JSON on stdout and progress on stderr.

The branches would be stacked Q → 1 → 2 → 3 → 4, with each PR initially based on the preceding branch. They would merge into upstream main in that order, retargeting the next PR to main after each merge. The existing feat/1287-grounded-review branch remains a reference; I’ll move relevant work selectively rather than merge it wholesale.

puri-adityakumar avatar Sep 24 '26 18:09 puri-adityakumar

Where this stands

The /review stack for this issue was planned as 5 PRs: Q → Foundation → Grounded default → Deep → Headless (plan).

  • Q landed in #1478.
  • Foundation landed in #1768.
  • The remaining 3 stages (Grounded default, Deep, Headless) never made it upstream, so the Foundation code was never wired into /review.
  • Because of that, @will-lamerton removed it in #2032, which makes sense given nothing was using it.

Next steps

@akramcodez, could you assign this issue to me first? After that, which approach would you prefer:

  1. One larger PR to main that brings back the Foundation along with the remaining stages, or
  2. A feature branch you create, where the remaining stages land one by one and then merge into main together?

Status

The implementation and testing for all remaining stages are already done on my side. Once we've decided on the approach, I just need to put it together in that shape, and then it's ready for review and merge.

puri-adityakumar avatar Nov 17 '26 20:11 puri-adityakumar

Thanks @puri-adityakumar, you're assigned. Please go with the feature branch approach: I'll create feat/1287-grounded-review on the main repo. Open each stage (Foundation, Grounded default, Deep, Headless) as its own PR against that branch so they can be reviewed in small pieces, and we merge the branch into main once all of them are in and tested together.

akramcodez avatar Nov 19 '26 09:11 akramcodez

Hey @akramcodez, all four PRs are up against feat/1287-grounded-review:

  1. #2297 Foundation
  2. #2298 Grounded
  3. #2299 Deep
  4. #2300 Headless

One thing first: the branch is 16 commits behind main. Could you rebase it on main? Once that's done, I'll update the four PRs and rerun the checks.

Please merge in the order above, since each PR builds on the one before. Once all four are in, the branch can go into main.

Does that work for you?

puri-adityakumar avatar Nov 19 '26 20:11 puri-adityakumar