# S04: [B] Reindex Existing Corpus Through LightRAG — UAT

**Milestone:** M019
**Written:** 2026-04-03T22:55:22.749Z

## UAT: S04 — Reindex Existing Corpus Through LightRAG

### Preconditions
- SSH access to ub01
- All chrysopedia Docker services running and healthy
- LightRAG service accessible at localhost:9621

### Test 1: Dry-Run Mode
1. Run: `ssh ub01 'docker exec chrysopedia-api python3 /app/scripts/reindex_lightrag.py --dry-run --limit 3'`
2. **Expected:** Exit code 0. Output includes formatted text for 3 technique pages with Title, Creator, Category, Tags, Summary, body sections, and key moments.
3. **Expected:** No HTTP requests made to LightRAG (dry-run only formats).

### Test 2: Resume Support
1. Run: `ssh ub01 'docker exec chrysopedia-api python3 /app/scripts/reindex_lightrag.py --limit 2'`
2. **Expected:** Script checks GET /documents, identifies already-processed technique:{slug} entries, skips them.
3. **Expected:** Only unprocessed pages are submitted. Log shows "Skipping (already processed)" for known pages.

### Test 3: Document Processing Verification
1. Run: `ssh ub01 'curl -sf http://localhost:9621/documents/status_counts'`
2. **Expected:** `processed` count > 4 (2 from S01 test docs + pages from reindex).
3. **Expected:** No `failed` count > 0.

### Test 4: Entity Extraction Quality
1. Run: `ssh ub01 'curl -sf http://localhost:9621/graph/label/list'`
2. **Expected:** Returns JSON array with 100+ entity labels.
3. **Expected:** Entities include creator names, plugin names (Serum, Ableton tools), and technique concepts.

### Test 5: Service Health During Reindex
1. Run: `ssh ub01 'docker ps --filter name=chrysopedia --format "{{.Names}} {{.Status}}"'`
2. **Expected:** All 10 chrysopedia services show "Up" with "(healthy)" status.
3. **Expected:** No services restarting or in unhealthy state.

### Test 6: Query After Indexing Complete
1. Wait for reindex to complete: `ssh ub01 'curl -sf http://localhost:9621/documents/status_counts'` shows processed ≈ 90.
2. Run: `ssh ub01 'curl -sf --max-time 60 -X POST http://localhost:9621/query -H "Content-Type: application/json" -d "{\"query\":\"What plugins are used for bass sound design?\"}"'`
3. **Expected:** Returns JSON response with relevant technique information citing multiple creators.

### Test 7: v1 and v2 Body Section Handling
1. Run dry-run on a known v1 page and a known v2 page (check body_sections_format in DB).
2. **Expected:** v1 pages produce heading:content pairs. v2 pages produce nested heading/content/subsection output.

### Edge Cases
- **LLM backend busy:** Query endpoint may time out during active indexing. This is expected — retry after indexing completes.
- **Container restart:** Script is baked into the Docker image. After restart, reindex can resume (skips already-processed docs).
- **Empty body_sections:** Script handles pages with None/empty body_sections gracefully (outputs only metadata + key moments).
