Skip to content

Guardian: chunked review path has never run — routing is flag-based, needs bench evidence before enabling #277

Description

@zaebee

The chunked review path has never run in production

Split out of #275, where it was originally (and wrongly) blamed for a timeout. It is not a crash cause — it is dead code in practice.

src/cgis/guardian/chunked.py:207:

chunked = "chunked" in collector.features

Routing is purely opt-in, with no size threshold anywhere. GUARDIAN_FEATURES is unset as a repo variable, so the flag is never on.

Evidence from guardian_metrics.jsonl on data/guardian-metrics: 41 recorded runs, 41 with chunk_count: null. The connected-subgraph chunker built in #154 / #185 — union-find over IMPORTS/CALLS, per-chunk context collection, honest per-chunk degradation, MAX_CHUNKS capping, dedup and merge — has never executed on a real review.

Why it still matters

Single-pass puts the entire diff in one request, so one failed call loses the whole review. The chunked path fails per chunk: a chunk whose finder call raises contributes zero findings and a ⚠ bullet, and the rest of the review survives. That failure isolation is worth having independently of prompt size.

On #274's diff the chunker produces 6 chunks, largest ~11k tokens against 32.8k for the single prompt — roughly a 3× reduction in per-call size.

Why it is not a quick fix

Turning chunking on changes the default review path for every PR, and with it the finder's context: collect_for_chunk assembles per-chunk files and graph context rather than one whole-PR prompt. This project's recall behaviour is prompt-sensitive — see the recall work on #246 / #270, where finder precision-bias was traced to the prompt rather than the model.

So this needs bench evidence, not a threshold. scripts/guardian_bench.py replays past PRs against curated ground truth; the question to answer is whether chunked review finds the same defects as single-pass on the same PRs, and what it costs in API calls.

Suggested shape

  1. Bench both paths over the existing ground-truth set; report recall and call count per path.
  2. Only then decide routing: always-chunk-when-a-graph-DB-exists, or size-escalation with a threshold justified by the bench.
  3. Whatever is chosen, record chunk_count behaviour in the metrics so the next question has data.

One observation for step 1: on #274 the largest chunk was a 1182-line implementation-plan markdown file. Docs-only chunks consume a finder call and cannot contain code defects — worth checking whether the chunker should skip non-source files entirely.

Related: #275 (timeout/retry — the actual cause of the #274 failure), #154 and #185 (chunker lineage).

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions