Skip to content

refactor(review): split review_diff_inner into prepare / judge / finalize with the LLM as the seam #649

Closed

Description

@ajianaz

From the architecture audit. Part 2 of 6. Depends on 1/6 (finalize).

Problem

engine/review.rs::review_diff_inner (~L79-384) does sanitize, deterministic scanners, context chain, language/profile/memory/brain context, cache, the LLM call, merge, path guard and postprocess in one function. valid_files and the deterministic report are computed and never returned, so nobody else can finalize a result. HttpTransport is built inline in review_diff, review_diff_stream, scan_files, chat_completion_raw; the Transport trait is pub(crate) with no injection point, so there is no end-to-end test of review. llm::review_diff also owns the spinner (terminal UI inside the LLM module).

Proposal

Split into three steps with the LLM as the seam:

  • prepare(diff|files, config) -> Packet: hardened system prompt, user prompt (fenced), valid_files, deterministic findings, diff chunks, response schema.
  • judge(Packet) -> Vec<ReviewIssue>: the seam. Adapters: HttpLlm (today's behavior, owns retry/stream/spinner), None (deterministic only), Agent (see 6/6).
  • finalize(Packet, issues) -> Verdict: merge, hallucinated-path guard, postprocess, 1/6 tail.

Three adapters means a real seam. Inject the transport so review gets a test seam (fake judge).

Done when

  • review_diff_inner is replaced by prepare/judge/finalize with identical output for the HttpLlm adapter (existing behavior tests pass).
  • A test drives review end to end with a fake judge, no network.
  • llm module no longer prints.
  • review --stream still works.

Activity

  1. added
    type:task
    scope:core
    on Oct 15, 2026
  2. ajianaz commented on Oct 15, 2026

    @ajianaz
    CollaboratorAuthor

    Series map (sequential, one PR each): 1/6 finalize #648 → 2/6 prepare/judge/finalize #649 → 3/6 untrusted judge output + cache #644 → 4/6 scan deterministic family #645 (can parallel 3/6) → 5/6 select_judge #646 → 6/6 MCP agent tools + skill #647.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope:coretype:task

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions