Audit Phase 1: correctness and scheduling safety

Implements every P0 from AUDIT.md plus four P1s, across both halves of the
pipeline. Verified by CPU-only self-checks and the orchestrator test suite.
No GPU work ran and no pipeline ran.

workpc:
- worker_scene: read speaker_ref, not the rewritten speaker field. Every line
  narrated as "Someone" before this. Emit `actions` for the verifier.
- worker_script: declare beat + verifier_feedback (pydantic dropped both, so
  the retry was blind) and render them as a repair prompt.
- worker_vision: gate face->identity pairing on containment, assign globally
  shortest-first, map an out-of-range resolver index to `unresolved` instead
  of minting a character, parse JSON with raw_decode.
- session_manager: tear down a server whose lease vanished mid-load, and spawn
  the supervisor respawn unlocked.

orchestrator (edited in place, NOT committed there):
- tracklets: canonicalize gender, add co-presence cannot-links, block
  transitive bridges across a hard constraint.
- correctness: stop failing valid narration on sentence-initial capitals and
  short quotes; read action evidence from the singular key.
- db: stop orphan flags leaking into every chapter; resolve by flag id.
- service: TTS returns instead of raising under GATES, auto-resolves under
  autonomous mode; job admission control; registry names on dialogue resume.
- session_proxy: queue on 409 instead of stealing the lease; run heartbeats.

Docs restructured per the repo-structure layout: CLAUDE.md is a pointer table,
NEXT.md replaces HANDOFF.md, plus ROADMAP.md, JOURNAL.md, decisions/ and
caveats/. AUDIT.md now points at those instead of restating them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XD7cAy81MZrc7gCr6aZGWr
This commit is contained in:
2026-08-11 10:16:24 +04:00
parent 6d9df5bf2f
commit 0cc6302245
14 changed files with 787 additions and 219 deletions
-54
View File
@@ -1,54 +0,0 @@
# HANDOFF: audit second pass (2026-08-11)
## What was asked
Review `AUDIT.md` (untracked, first pass, 565 lines) and add anything missing.
## What was done
Read both halves of the pipeline and checked the first pass against source. No code changed.
No GPU work, no pipeline run, no tests executed.
Files read in full:
- workpc: `worker_vision.py` (1008), `worker_identity.py` (322), `worker_script.py` (300),
`worker_scene.py` (170), `worker_tts.py` (241), `session_manager.py` (238), `transport.py` (216),
`worker_crop.py` (first 120 of 359).
- homesrv `/mnt/server/home/kami/docker-apps/manga-infra/orchestrator/`: `service.py` (2048),
`db.py` (815), `session_proxy.py` (302), `correctness.py` (116), `tracklets.py` (121),
`minio_layout.py` (105), `grouping.py` (75).
Result: `AUDIT.md` grew from 565 to 745 lines. New section `## Second-pass findings (2026-08-11)`
at line 566. 4 new P0, 6 new P1, 13 P2, plus 5 additions to the Phase 1 list and 1 to the
acceptance criteria.
Four first-pass claims were confirmed in source and are not restated in the new section:
- tracklet gender enum: `tracklets.py:43` uses `male|female`, vision emits `m|f|unknown`.
- missing action evidence: `worker_scene.py:85` emits `action`, `correctness.py:91` reads `actions`.
- dropped verifier feedback: `worker_script.py:13-23` defines neither field.
- 409 lease stealing: `session_proxy.py:40-49`.
## Top 4 new findings
1. `worker_scene.py:78` reads `speaker` as a local id, but `correctness.py:47` already rewrote it
to a character_id. Every lookup returns None, so all narration says `Someone`.
2. `correctness.py:106-115` fails valid narration on sentence-initial capitals and on short
quotes, and `service.py:1384-1386` turns that into a halted chapter.
3. `service.py:1419-1423` blocks TTS on correctness flags that only `/review/approve` can clear,
while `GATES` defaults to off (`service.py:312`).
4. `session_manager.py:108-119` can orphan a llama-server that keeps its VRAM.
## Still open
- Nothing from this session is half-finished. `AUDIT.md` is complete as written.
- No finding has been fixed. All are report-only.
- `AUDIT.md` is still untracked as of this session's start. Decide whether it belongs in git.
- Prose linter reports ~97 style hits in `AUDIT.md`. Almost all are in the first-pass sections
(lines 1-565), which were left as the author wrote them.
- Carried over from the earlier reconstruction handoff of the same day:
- `.venv/` is gone. Rebuild it, then install the ROCm torch wheel the way workpc had it.
- `dots.tts/` and `legacy/` are not recoverable from transcripts.
- `RESUME_SPEC.md`, `pipeline-design-notes.md`, and `spec-v2.md` are unrecoverable.
## Next command
```
cd /home/kami/Programs/n8n-worker
sed -n '566,745p' AUDIT.md # read the new section
```
Then pick the Phase 1 order at `AUDIT.md:511` as amended at the end of the new section.