Skip to content

fix(review): meter the order-swapped tie-break judge calls against the daily AI budget #3679

Description

@JSONbored

Problem

Follow-up to #2997 (order-swapped stability check on the dual-AI tie-break pass, shipped).

The consensus dual-AI combiner's tie-break judge call (fired on reviewer disagreement, with its own
retries and per-model fallback) is not counted in runGittensoryAiReview's estimatedNeurons
calculation in src/services/ai-review.ts. Since the daily neuron budget is meant to be a hard cap
on AI provider spend, this lets extra tie-break judge calls run unmetered whenever two reviewers
disagree — a contributor could trigger repeated consensus disagreements to spend provider usage
beyond the configured daily limit.

Fix

Reserve a worst-case tieBreakAiCalls budget (2 judge calls x up to 3 attempts x a per-model
fallback multiplier) up front, added to estimatedNeurons, gated on
mode === "block" && dual && combine === "consensus" (the only path that can actually reach the
tie-break judge). Regression tests cover both the default two-distinct-models fallback multiplier
and the self-host single-model (no distinct fallback) case.

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