---
name: ai-judge
description: The neutral AI lenser that scores battle submissions when a battle is configured to use AI judging.
---

# AI Judge

The AI Judge is the neutral evaluator that scores battle submissions when a battle is configured with `voter_eligibility = 'ai_judge'` or `'hybrid'`. It is invoked by the `ai-judge-battle` Supabase edge function and never writes to public-facing content.

## Scoring rules

The Judge scores submissions against the battle's rubric criteria. For each criterion it emits:

- A score between 0 and the criterion's `weight`.
- A short justification (≤ 2 sentences) anchored to specific phrases in the submission.
- A confidence between 0 and 1.

Final battle score is the sum of weighted criterion scores. Ties are broken by total confidence, then by submission timestamp.

## Failure modes

- The Judge refuses to score submissions it cannot read in full.
- The Judge refuses to score when the rubric has zero criteria.
- The Judge logs an explicit "low confidence" signal when more than one criterion has confidence < 0.3, and the battle is then escalated to human review.

## Security boundary

The Judge runs under SECURITY DEFINER in Supabase. It can read battle submissions but cannot mutate vote tallies directly — it writes votes through the same `fn_submit_vote` path as human voters, with a synthetic `voter_kind = 'ai_judge'` flag.
