# Audit Log — starsend
Started: 2026-03-14
Working directory: /Users/joeturnerlin/Dropbox/CLAUDE_PROJECTS/starsend
Validation: python3 -m pytest tests/ (112 core tests)
Linters: none configured
Dev server: python3 editors/review_server.py --project starsend-test
Visual mode: yes (DESIGN_SYSTEM.md present)

---

## Pre-Audit: Bug Investigation

JT reported: "Location and prop prompt references were getting dropped completely along with most reference images when I made a change to the prompt in the interface."

Root cause analysis traced the issue through 3 pipeline stages:

### Bugs Found & Fixed (Pre-Audit)

| # | File | Bug | Fix |
|---|------|-----|-----|
| 1 | `lib/previz_context.py` `build_keyframe_refs()` | **Props completely absent from keyframe ref stack** — previz included props at slot [5] but keyframe generation had zero prop refs | Added prop ref injection (1 max, budget-gated by char count ≤1) |
| 2 | `lib/previz_context.py` `resolve_all_character_refs()` | **"side"→"profile" fallback missing** — KIT's casting uses "profile" not "side", angle silently dropped | Added `turnaround.get("profile")` fallback when "side" not found |
| 3 | `lib/keyframe_context.py` `build_extrapolation_refs()` | **Hero identity refs dropped** — `character_refs[:3]` took the 3 LEAST useful angles (back, 3qb, side). Hero always last, always dropped. | Changed to `character_refs[-3:]` to preserve hero (last in list) |
| 4 | `editors/review_server.py` `_api_extract_frame()` | **Extraction hint replaced entire prompt** — user's brief hint became the full NBP prompt, losing all location/prop/context text | Now appends hint as `DIRECTOR NOTE:` to the built extrapolation prompt |
| 5 | `editors/review_server.py` `_api_extract_frame()` | **Extraction had zero prop refs** — `build_extrapolation_refs()` was never passed props | Added `extract_mentioned_props()` call, passes `prop_refs=` to builder |

---

## Round 1: Opus Audit

- Status: FOUND_2_ISSUES
- Strategy: Opus sub-agent (deep code review)
- Issues found: 2
- Issues fixed: 2
- Files modified: `editors/tabs/canvas/main.js`, `lib/previz_context.py`

### Findings

| # | File | Bug | Fix |
|---|------|-----|-----|
| 6 | `editors/tabs/canvas/main.js` `actionGenerateKeyframe()` | **Keyframe gen 400s when user hasn't edited prompt** — `body.prompt` only set when `draft !== undefined`. Normal workflow (approve previz → generate hero) sends no prompt, server returns 400. | Added fallback chain: draft → `shot.keyframe_nbp` → `shot.prompt`. If all empty, auto-calls `/api/smart-prompt` first. |
| 7 | `lib/previz_context.py` `_resolve_phase()` | **Wrong `end_ep` default (0 vs 9999)** — phases without `end_ep` key computed `start <= ep <= 0` = always False. `jit_prompt.py` correctly uses 9999. Caused wardrobe phase mismatch between bible context and hydrated prompt. | Changed default from `0` to `9999` |

### Validation
- 112 core tests: PASS
- review_server.py: compiles clean
- All 7 fixes verified by Opus sub-agent as correct, no regressions

---

## Summary
- Rounds: 1 (Opus audit)
- Total issues found: 7 (5 pre-audit investigation + 2 audit round)
- Total issues fixed: 7
- Exit reason: All critical bugs fixed, convergence pending Round 2
- Files modified: `lib/previz_context.py`, `lib/keyframe_context.py`, `editors/review_server.py`, `editors/tabs/canvas/main.js`
