mirror of
https://github.com/nomadkaraoke/karaoke-gen.git
synced 2026-12-05 01:26:07 +09:00
## Summary Enables the proactive pre-generation that PR #816 intended but couldn't deploy (the lyrics-job `--update-secrets` crashed on Cloud Run secret aliases). Per the chosen approach, the work now runs **on the API service** — which already has a working `ANTHROPIC_API_KEY` + `AUTO_CORRECT_COMPARE_MODELS` — instead of the lyrics job, sidestepping the secret-alias problem entirely. ## How it works 1. Lyrics worker finishes transcription → after `mark_lyrics_complete`, fires `WorkerService.trigger_auto_correct(job_id)` — a direct, awaited HTTP call (no Cloud Tasks / new queue). Best-effort: never blocks or fails the job. 2. New internal endpoint `POST /api/internal/workers/auto-correct` (admin auth) runs `process_proactive_auto_correct(job_id)` synchronously on the service: loads `corrections.json`, runs the multi-model `suggest()` with default settings (cache-aligned with the UI), caches it. Gated by `AUTO_CORRECT_PROACTIVE_ENABLED`, 180s timeout, swallows all errors. 3. `ci.yml`: `AUTO_CORRECT_PROACTIVE_ENABLED=true` added to the **service** env (deploys cleanly — the broken lyrics-job secret path is gone). Result: when a reviewer opens the lyrics UI, the auto-run-on-load request is an instant cache hit. ## Testing - Backend: **3462 passing** (emulator excluded), incl. rewritten `test_proactive_auto_correct.py` covering the service worker (flag gating, no-references skip, happy path multi-model, error-swallow) and the lyrics-worker trigger (fires / swallows errors). - CodeRabbit: trace-context propagation + defensive endpoint guard applied. ## Notes - Failure modes unchanged & graceful: flaky AI / out of credits / timeout → endpoint returns a status, job proceeds; UI falls back to on-demand generation. - Version bumped 0.180.0 → 0.181.0. @coderabbitai ignore --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>