Skip to content

feat(review): file triage stage — classify changed files to drive packing order and prompt selection [v0.8] #666

Description

@devops-thiago

Problem Statement

Batch packing is size-based only: DiffBudgetPlanner orders files by additions+deletions descending and packs First-Fit-Decreasing (DiffBudgetPlanner.java:609-736). Importance never enters the picture, so when the spend ceiling (REVIEW_MAX_TOKENS_PER_REVIEW), the call cap, or a batch failure forces degradation, what gets skipped is whatever happened to pack last — possibly the auth change, while a giant generated file got a full-budget batch.

Proposed Solution

Add a triage stage between diff load and budget planning that classifies every changed file:

  • Deterministic first (free): category from path/content signals — source / test / config / IaC / docs / generated / lockfile — plus coarse risk signals (security-sensitive paths, public API surface, migration files). Most files classify without any model call.
  • Optional cheap LLM call (concise binding, ledger-gated, counted in maxAiCalls accounting): rank only the ambiguous remainder by review priority. One small call with file paths + hunk headers, not diffs — predictable, tiny prompt. Config-gated, default off.

Consumers of the classification:

  1. Packing order: importance-first (risk tier, then size) instead of size-only, so degradation always sheds the lowest-value files. The existing disclosure machinery (omittedFiles, spendCeilingSkippedFiles, withheld-material notice) keeps reporting honestly.
  2. Dimension routing input: batch composition by category makes per-batch dimension selection (the v0.7 routing issue) sharper — e.g. pack config/IaC files together so only those batches carry IaC rules.
  3. Lightweight lane: docs/generated/lockfile tiers can share a minimal sanity-check prompt or be summarized-only, rather than consuming full-prompt budget.
  4. Model routing: the risk tier is exactly the signal feat(ai): risk-based model routing and fallback #43 (risk-based model routing) needs — this issue provides the classifier, feat(ai): risk-based model routing and fallback #43 consumes it.

Touchpoints

New review/FileTriage collaborator; review/DiffBudgetPlanner.java (ordering + lane assignment), review/FindingPipeline.java, config/ThrillhouseConfig.java (gate + tier globs, extensible via .github/thrillhousebot.yml like review.ignored-files).

Acceptance criteria

  • Deterministic classifier covered by unit tests over representative path sets; LLM ranking optional and fail-open (falls back to deterministic order).
  • Under a forced spend ceiling, high-risk files are demonstrably reviewed before low-risk ones (test via DiffBudgetPlanner plan inspection).
  • No change in behavior when the feature gate is off.

Alternatives Considered

  • Pure LLM classification — unpredictable cost and an extra call on every review; deterministic-first keeps the common case free.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestjavaPull requests that update java code

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions