# S07: Search — Per-Section Embeddings + Deep Linking — UAT

**Milestone:** M014
**Written:** 2026-04-03T02:16:37.295Z

## UAT: Search — Per-Section Embeddings + Deep Linking

### Preconditions
- Chrysopedia stack running on ub01 (docker compose up)
- At least one v2 technique page exists (body_sections_format = 'v2') with multiple H2 sections
- Stage 6 has been run after S07 deployment (to generate section embeddings)
- Web UI accessible at http://ub01:8096

### Test 1: Section-Level Search Results Appear
1. Navigate to http://ub01:8096
2. Type a query matching a known section heading (e.g., a specific technique sub-topic like "grain position" or "LFO routing")
3. **Expected:** Search results include items with a "Section" badge alongside existing "Technique" and "Key Moment" badges
4. **Expected:** Section results show the section heading as context text

### Test 2: Section Deep Link Navigation
1. From search results, click a result with the "Section" badge
2. **Expected:** Browser navigates to `/techniques/{slug}#{section-anchor}`
3. **Expected:** Page scrolls smoothly to the target section heading
4. **Expected:** The URL contains the hash fragment (e.g., `#grain-position-control`)

### Test 3: Autocomplete Section Results
1. Navigate to any page with the nav search bar (Topics, Creators, etc.)
2. Type a query that matches a section heading
3. **Expected:** Autocomplete dropdown shows results with "Section" type label
4. Click a section result from the autocomplete dropdown
5. **Expected:** Navigates to technique page with correct hash anchor and scrolls to section

### Test 4: Key Moment Hash Scroll Still Works
1. Navigate to a technique page via a key moment search result (e.g., from search results with "Key Moment" badge)
2. **Expected:** Page scrolls to the key moment section (hash like `#km-some-moment`)
3. **Expected:** No regression — existing key moment deep links still work

### Test 5: Cmd+K Search Shortcut with Section Results
1. On any non-homepage page, press Cmd+K (or /)
2. Type a section-related query
3. **Expected:** Search bar focuses, results include section-level matches
4. Click a section result
5. **Expected:** Correct deep link navigation with scroll

### Test 6: v1 Pages Produce No Section Points
1. Verify in the database: `SELECT id, body_sections_format FROM technique_pages WHERE body_sections_format = 'v1' OR body_sections_format IS NULL`
2. Search for content known to be only on a v1 page
3. **Expected:** No "Section" badge results for v1-only content — only "Technique" page-level results

### Edge Cases
- **Empty section heading:** Sections with empty headings in body_sections JSONB should be skipped during embedding (no Qdrant points created)
- **Section heading rename after re-index:** After a page is re-processed with changed headings, old section points should be deleted (delete_sections_by_page_id runs before upsert)
- **Qdrant unavailable:** Stage 6 should complete without error even if Qdrant is down — section embedding is non-blocking (check worker logs for WARNING, not ERROR/exception)
