Skip to content

refactor(review): one finalize module for the result tail (should_block, severity, gate, debt, persist) #648

Closed

Description

@ajianaz

From the architecture audit (deep module / seam vocabulary). Part 1 of 6 of the "agent as reviewer" series (see the tracking list at the bottom).

Problem

The result-shaping tail of a review is re-implemented in 6 places and has already drifted:

  • commands/review.rs single path (~L260-355) and the chunked path (~L647-710) are copy-pasted; chunked review sums should_block across chunks and then recomputes it again.
  • commands/commit_cmd.rs filters severity from config only, computes no should_block, skips history persist.
  • mcp/tools.rs::handle_review_diff never reads its own min_severity param and evaluates the quality gate on unfiltered issues; no debt snapshot, no persist.
  • commands/scan.rs has its own should_block, its own persist with inline git rev-parse calls, no gate, no debt.
  • engine/review.rs recomputes should_block in the LLM-failure fallback and the main path.
    ReviewRecord, the gate_status string mapping, git context, token summing and DebtSnapshot::from_review are rebuilt by hand at each site.

Proposal

One finalize module: merged issues + options in, a Verdict out (filtered issues, should_block, gate result, exit code), with the best-effort side effects (debt snapshot, cora.db history) behind it. Review (single + chunked), commit, scan and MCP each make one call.

Done when

  • should_block, severity filtering, gate evaluation, exit code and persistence each exist once.
  • MCP honors min_severity; commit persists history; behavior otherwise unchanged (tests pin exit codes for review, review --ci, gate fail, chunked).
  • finalize has unit tests with no LLM.

Tracking: 1/6 finalize (this) → 2/6 prepare/judge/finalize → 3/6 untrusted judge output + cache → 4/6 scan deterministic family → 5/6 select_judge → 6/6 MCP agent tools + skill.

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