## 8a. Gemini Verification (Video Review)

**Prerequisite:** `GEMINI_API_KEY` or `GOOGLE_API_KEY` environment variable must be set.
Get a free key at: https://aistudio.google.com/apikey

**Important:** Gemini CLI (`gemini` command) does NOT support video — its `read_file` tool cannot pass video through the function-calling protocol. We use the Gemini API directly via `apt-proof-video`.

Check if video analysis is available:
```bash
apt-proof-video --version 2>/dev/null && echo "AVAILABLE" || echo "NOT AVAILABLE"
```

**What Gemini uniquely does:** Gemini is the only major model family that can process video files. It samples frames at 1 FPS and analyzes the visual content. A 5-minute recording costs ~$0.005. WebM (Playwright's default) is natively supported — no conversion needed.

**Model presets (benchmarked on 3 videos, 3 models):**
- `default` → `gemini-2.5-flash` — best detail-to-speed ratio, most thorough text extraction
- `thorough` → `gemini-3.1-pro-preview` — best interaction precision, catches real UI bugs
- `fast` → `gemini-3.1-flash-lite-preview` — 3x faster (~6s), good for CI pass/fail

For each `.webm` file found in the proof directory or Playwright test results:

```bash
apt-proof-video analyze "${PROOF_DIR}/screenshots/recording.webm" \
  --model default \
  --spec "{one-line spec summary}"
```

The tool returns structured JSON:
```json
{
  "status": "ok",
  "model": "gemini-2.5-flash",
  "elapsed": 18.4,
  "analysis": {
    "pages": [{ "url_or_description": "...", "timestamp_start": "00:01", "timestamp_end": "00:05" }],
    "ui_elements": [{ "type": "button", "text": "Submit", "location": "main" }],
    "interactions": [{ "timestamp": "00:03", "action": "click", "target": "Submit button", "result": "Form submitted" }],
    "anomalies": [],
    "verdict": { "result": "pass", "confidence": 0.95, "summary": "...", "details": "..." }
  }
}
```

Map the Gemini response to a `ModelVerdict`:
```json
{
  "model": "gemini-2.5-flash",
  "provider": "gemini",
  "role": "video-review",
  "verdict": "{analysis.verdict.result}",
  "confidence": "{analysis.verdict.confidence}",
  "summary": "{analysis.verdict.summary}",
  "findings": ["{mapped from analysis.interactions and analysis.anomalies}"]
}
```

## 8b. Codex Verification (Second Opinion)

If the user has Codex CLI installed:

```bash
which codex 2>/dev/null
```

If available, use the Agent tool or the codex:rescue skill to get an independent code review:

**What Codex uniquely does:** Independent code analysis from a different model family (GPT/o3). Catches different categories of issues than Claude.

Create a prompt for Codex focusing on:
- Logic correctness in the changed files
- Security vulnerabilities Claude might have missed
- API contract compliance
- Edge cases in error handling

Record Codex's response as a `ModelVerdict`:
```json
{
  "model": "codex",
  "provider": "codex",
  "role": "second-opinion",
  "verdict": "pass",
  "confidence": 0.88,
  "summary": "Code changes are correct and well-structured.",
  "findings": ["Error handling covers all edge cases", "No security issues found"]
}
```

## 8c. Claude Verdict (Primary)

Claude's own verification is always the primary verdict:

```json
{
  "model": "claude-opus-4-6",
  "provider": "claude",
  "role": "code-analysis",
  "verdict": "pass",
  "confidence": 0.95,
  "summary": "All dimensions pass. Tests green, types clean, evidence confirms UI works.",
  "findings": []
}
```

## 8d. Compute Quorum

Determine the final quorum result:
- If ALL models agree: `unanimous: true`, use shared verdict
- If majority agree: `unanimous: false`, use majority verdict
- If no majority: `finalVerdict: "partial"`, flag for human review

```json
{
  "quorum": {
    "modelsUsed": ["claude-opus-4-6", "gemini-2.5-pro", "codex"],
    "unanimous": true,
    "finalVerdict": "pass"
  }
}
```
