# Iterative Fix-Verify Loop for Presentation QA

Pattern for achieving zero-defect presentations through repeated visual QA cycles.
Derived from a 17-slide deck QA session (5 cycles, 6 issues → 0 issues).

## The Loop

```
┌─────────────────────────────────────────┐
│  1. GENERATE  →  node main.js           │
│  2. RENDER    →  soffice → pdftoppm     │
│  3. BATCH QA  →  batch_vision_qa.py     │
│  4. TARGETED  →  vision_analyze (deep)   │
│  5. FIX       →  patch source files      │
│  6. REPEAT 2-5 until ALL CLEAN          │
└─────────────────────────────────────────┘
```

## Cycle Progression (Real Example)

| Cycle | Issues Found | Action | Remaining |
|-------|-------------|--------|-----------|
| 1 | 1 (batch) + 6 (targeted) | Fixed all 6 | 3 remaining |
| 2 | 3 (targeted) | Fixed all 3 | 1 remaining |
| 3 | 1 (targeted) | Fixed | 1 remaining |
| 4 | 1 (targeted) | Fixed | 0 |
| 5 | 0 (full batch) | Done | 0 ✅ |

## Why Multiple Cycles Are Needed

Fixes introduce new problems:
- Moving a subtitle down to fix overlap may push it into content below
- Enlarging a badge circle may overlap neighboring elements
- Changing line color for visibility may reduce contrast with another element
- Shortening a label to prevent wrapping may lose meaning

**Never declare success after the first fix-and-verify.** Always re-render and re-QA.

## Batch + Targeted Prompt Division

### Batch Prompt (Tier 1 — Breadth)
Generic, checks all slides quickly (~25s for 17 slides). Uses expanded 6-category prompt:
overlap, overflow, contrast, layout, content, symbols.

### Targeted Prompts (Tier 2 — Depth)
Element-specific questions for slides with:
- **Diagrams**: "Are the connecting lines visible? What color?"
- **Badges/icons**: "Do the letters inside circles render correctly?"
- **Tables**: "Are all cells populated? Any placeholder text?"
- **Examples**: "Does the example value match the description?"
- **Arrows/connectors**: "Do arrows render properly between elements?"

## Efficiency Tips

- Only re-render and re-QA slides that were changed (not the entire deck)
- But ALWAYS do a full batch scan at the end to confirm no regressions
- Batch QA via direct API calls is 10-20x faster than sequential vision_analyze calls
- Save QA results to JSON for comparison between cycles
