mirror of
https://github.com/nomadkaraoke/karaoke-gen.git
synced 2026-11-28 01:49:00 +09:00
62843f02861ba2154ff7b2b14e7763a635a950f2
80
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
5b5264dc54 |
Incident hardening: deploy/CI/runner resilience (R1/R2/R3/R4/C1/C2) (#987)
Part 3 of 3 of the **Incident hardening (post-NOMAD-1632)** initiative (plan: `docs/archive/2026-09-12-incident-hardening-plan.md`). Closes the deploy/CI/runner gaps: no functional gate, no codified rollback, bad revision serves 100% immediately, fire-and-forget runner stranding, and a flaky smoke. **No backend app code changed → no version bump.** ## ⚠️ Reviewer note — read first **R3/R4 rewrites the live `deploy-backend` step.** It's designed to be *auto-revert-safe* (a failed candidate smoke means we simply never migrate traffic, so the prior revision keeps serving 100% — a bad revision serves **0%**, not an outage). But it changes how **every** backend deploy works and **can't be fully exercised in CI**. This is the one to watch on first merge. If you'd rather de-risk, R3/R4 is the only item here that's safe to split out — the rest (R1/R2/C1/C2) are independent and lower-risk. ## R2 — codified fast rollback (`scripts/rollback.sh` + runbook) Dry-run-able, explicit-target-required rollback for the Cloud Run **service** (traffic-shift to a prior revision — instant, no rebuild) and the three **jobs** (image re-pin, correct per-job region/repo — verified against ci.yml). `--list` shows available revisions/tags; `--dry-run` prints every gcloud command. `docs/TROUBLESHOOTING.md` "Fast rollback" runbook added as the first section. ## R3/R4 — service traffic-canary `deploy-backend` now deploys `--no-traffic --tag candidate`, smokes the tagged candidate URL (health + expected version, with retries), then `update-traffic --to-latest` **only on pass**. Cloud Run Jobs can't traffic-split (noted inline) → they rely on R1 + R2. ## R1 — post-deploy functional canary, version-change-gated New `deploy-verify` job runs the real production happy-path (`happy-path-real-user.spec.ts`, admin-credit variant — reuses e2e-daily's impersonate token refresh, secret names verified identical) after a backend deploy, **only when the backend version actually changed** (new "Detect backend version change" step compares `poetry version` to the currently-served `/api/health/detailed`). Frontend/docs/infra-only merges short-circuit. On failure → Discord alert + loud fail printing the exact `scripts/rollback.sh` invocation. Per the plan's caveat, a fresh happy-path won't reproduce every incident class (e.g. Failure B's stale-cache) — an admin reset+retry variant is a noted follow-up. ## C1 — ephemeral-runner stranding fix `infrastructure/functions/runner_manager/ephemeral.py` now confirms the VM insert **operation** succeeded instead of fire-and-forget: a late stockout/quota/transient error raises → existing zone-fallback / webhook redelivery kicks in instead of silently stranding a queued job for ~15 min. An insert-confirm *timeout* is treated as "still provisioning" (not a failure); guarded for older clients. **+4 tests (46 pass).** ## C2 — de-flake the E2E smoke `networkidle` → `domcontentloaded` + explicit element waits (the marketing page's background requests made `networkidle` time out and redden real deploys). ## Validation (local only — no deploy) - `ci.yml` + `e2e-daily.yml` parse; **actionlint clean** on new code. - `rollback.sh`: `bash -n` + `shellcheck` clean; constants cross-checked against ci.yml. - `test_ephemeral.py`: **46 passed**. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
a344783376 |
gen: unify YouTube descriptions + automated back-catalogue rewrite (#978)
## Summary
Unifies the descriptions across all ~1.6k videos on
youtube.com/@nomadkaraoke to one consistent, conversion-focused
template, makes new uploads use it automatically, and adds a
**reusable** automated system to re-apply any future template change
across the whole channel.
Old descriptions were inconsistent: pre-2024 ones linked a dead $10
Fiverr gig; newer ones led with "AI-powered" (bad rep among viewers) and
linked nowhere useful.
## New template
Single source of truth: `Settings.default_youtube_description` rendered
by `backend/services/youtube_description.py` (placeholders `{title}
{artist} {artist_hashtag} {brand_code}`). Drops all "AI" framing; leads
with the craft; CTA to the requests board then the referral link
`nomadkaraoke.com/r/youtube` (50% off, tracked via referrals); Nomad
Discord + decide + KaraokeNerds; fair-use line; preserves the brand
code.
## Live pipeline (new uploads)
Both upload sites (`video_worker_orchestrator.py`,
`youtube_queue_processor.py`) now render via the shared module +
enriched tags — new uploads use the new template automatically.
## Bulk rewrite of the back catalogue
- Shared logic `backend/services/youtube_backfill.py` (classify / target
/ render / update-body / enumeration). **High-confidence-only**
eligibility (title ends in `(Karaoke)`) + curated `skip_ids.txt` /
`include_ids.txt` lists shipped in the package.
- **Manual CLI** `scripts/youtube-descriptions/` (`analyze` / `apply` /
`status`) — read-only report + full old→new diffs before any write.
- **Automated daily drain**
`backend/workers/youtube_description_backfill_worker.py` + `POST
/api/internal/youtube-backfill/run` + Cloud Scheduler (Pulumi). Progress
in Firestore keyed by a **template fingerprint**, so any future template
change auto-re-drains the whole channel with no manual reset.
Quota-coordinated with uploads (reserves headroom via
`YouTubeQuotaService`); Postmark progress + completion emails.
## Verified
- Analyzed all 1,631 videos → **1,614 to rewrite** (1,610 clean + 4
rescued truncated titles), **17 skipped** (lyrics-with-vocals, demos,
tutorials), zero false positives.
- One video (`PmwRXIZoCpg`) updated live and verified on YouTube (new
description + enriched tags; title/category preserved).
## Tests
42 new unit tests (renderer, classifier/targeting/update-body, worker:
full drain, budget cap, quota reserve, dry-run, completion/idempotency,
template-change cycle, quotaExceeded stop). Local review done via the
local code-review fallback (CodeRabbit CLI was rate-limited) — 3
findings fixed, 2 documented trade-offs.
## Deploy notes
- Backend auto-deploys on merge (worker + endpoint + config + data
files).
- **`pulumi up` required** to create the
`youtube-description-backfill-daily` Cloud Scheduler job.
- New config env (all defaulted): `YOUTUBE_BACKFILL_ENABLED`,
`..._DAILY_MAX_UPDATES`, `..._QUOTA_RESERVE`, `..._ENRICH_TAGS`,
`..._REPORT_EMAIL`.
Plan/architecture:
`docs/archive/2026-09-03-youtube-descriptions-plan.md`
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- **New Features**
- YouTube uploads now use standardized descriptions with artist, title,
brand-code, and hashtag details.
- Tags are generated consistently from karaoke, artist, and title
information.
- Existing channel videos can be analyzed and updated in quota-limited
batches, with dry-run support and progress reporting.
- Added scheduled daily backfills and administrative controls for update
limits, exclusions, and overrides.
- Added safeguards for low-confidence titles and explicitly skipped
videos.
- **Documentation**
- Added guidance for automated and manual YouTube description management
workflows.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
|
||
|
|
37b9e6088b |
ci(pypi): recurring storage-cap prune reminder (fix failing PyPI publish) (#960)
## Problem The `Deploy - Publish to PyPI` step on `main` has been failing: ``` HTTP Error 400: Project size too large. Limit for project 'karaoke-gen' total size is 10 GB. ``` This is a recurrence of the known 10 GB PyPI project cap. The project is at **10.71 GB / 479 releases**; each release is a ~62 MiB universal wheel (bundled 33-locale frontend) auto-published on every merge (~3 GB/month), so it refills the cap every few months. **Only the public `pip install` publish step fails** — Cloud Run and the GCE encoding worker (pulls the wheel from GCS) are unaffected. The prior fix (v0.187.5) was wheel-only publishing + a one-time manual deletion, which only bought ~2 months. This makes the cleanup **recurring and durable**. ## Why not just automate deletion in CI? PyPI has **no deletion API** (upload tokens / Trusted Publishing are upload-only, and 2FA is mandatory). Deletion is only possible from a logged-in browser session, which can't be safely/durably stored in CI. So we automate the *decision + reminder* and keep the *deletion* a ~1-minute human step. ## What this adds - **`scripts/prune_pypi_releases.py`** (stdlib-only) — reads the public JSON API and computes a retention plan: **keep last 60 days + newest release per older calendar month + latest overall**. Renders a table / JSON / Markdown report and a **paste-into-browser-console** deletion snippet. Never deletes anything itself. Today's plan: keep 82, delete 397, **10.71 GB → 4.17 GB**. - **`.github/workflows/pypi-prune-reminder.yml`** — monthly cron (+ manual dispatch) that runs the planner and, once the project crosses a 7 GB watermark, opens/updates a single tracking issue with the plan + snippet. No secrets. - **`docs/PYPI-STORAGE-PRUNE.md`** runbook + a `TROUBLESHOOTING.md` entry. - **`tests/unit/test_prune_pypi_releases.py`** — 13 tests covering the policy (recency window, per-month keeper, latest-overall, same-day timestamp ranking, empty/undated releases, sizes, rendering). ## Testing - `pytest tests/unit/test_prune_pypi_releases.py` → 13 passed. - Ran the planner against live PyPI data; generated JS validated with `node --check`. - `black` clean; workflow YAML validated; `should_nag` gate verified. ## Notes - **No version bump** — tooling/CI/docs only, nothing in the wheel changes. Merging therefore **skips** the publish step (tag `v0.209.1` already exists), so this PR does not itself add another fat wheel while we're over the cap. - **To unblock publishing now:** after merge, run the prune (locally via the script or trigger the workflow with `workflow_dispatch`), paste the snippet on the logged-in PyPI releases page, then re-run the publish. The monthly cron keeps it under the cap going forward. - Related: filed [pypi/support#12050](https://github.com/pypi/support/issues/12050) requesting a 50 GB limit as a one-off buffer; the recurring prune is the durable fix. @coderabbitai ignore --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
8ce0d39faa |
fix(lyrics-review): Tap To Sync timing corruption + padded edit-segment timeline (#956)
## Summary Fixes **Tap To Sync timing corruption** in the Edit Segment modal and reworks the segment timeline for easier re-timing of the first/last words. ### Tap To Sync fixes (`useManualSync`) - **Negative durations on re-sync** — the overlap-correction effect pulled a just-tapped word's end back to the *next* word's **stale** start (it hadn't been re-tapped yet), producing `end_time < start_time`. The sanitizer then reported *"Fixed N word timing(s) that fell outside this segment"* on reopen. Now guarded + clamped so it never inverts. - **First word squished / segment start ratcheting** — `clampSyncTime` forced every tap into the tight `[segStart, segEnd]`, so a legit tap in the 3s playback lead-in got shoved up to `segStart` and the start could never be re-synced earlier. Now allows taps in `[segStart − leadIn, segEnd + leadOut]` (floored at 0). - **Last word cut off** — symmetric lead-out + auto-stop no longer fires while the spacebar is held, so the last word can extend the segment (hold past the end / default-duration overshoot) instead of being truncated. - Both keyboard **and touch** sync paths use the widened window. ### Edit Segment timeline UX - ±1s **greyed context padding** on each side (dashed boundary), **faded waveform** outside the segment, and **neighbouring segments' words** as read-only context blocks. Word bars, drag, ruler, cursor and click-to-scrub all map over the padded view; words can be dragged/synced into the padding to extend the segment. - Modal widened `960px → 95vw / max 1400px`. - Header **play button** starts 1s before and auto-stops 1s after the segment. ### Dev tooling (dev-gated, no prod impact) - `&edit=1` makes a replay session editable locally (guarded by `NODE_ENV !== 'production'`) so the real review UI can be exercised against real job data + audio. Documented in `docs/REPLAY.md`. - `review_test_fixtures.py` now serves a synthetic **click-track** so Tap To Sync is exercisable offline. ## Testing - New/expanded unit tests in `hooks/__tests__/useManualSync*.ts(x)`: negative-duration regression (fails on old code, passes on fix), lead-in/lead-out clamp cases, and segment-end extension. All 13 pass; 178 lyrics-review + hook tests green. - Typecheck clean on touched files. - Verified end-to-end in the browser against a real completed job (replay + real vocals): tap-sync produces valid monotonic timings, no sanitizer banner, first/last words extend correctly, timeline padding + fade + neighbour words render as intended. ## Notes - CodeRabbit reviewed locally; its one finding (touch path missing the lead window) is fixed. @coderabbitai ignore --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
9b6c4f236e |
fix: Cloud Tasks queue region from GPU workers + REVIEW_COMPLETE lost-trigger recovery (v0.202.1) (#948)
## Summary Follow-up to #947, found by live-testing auto-approval in prod (job `b8bda9c2` — the first real fully-auto-approved job). **Bug:** the GPU `audio-separation-job` sets `GCP_REGION` to its GPU region, but every Cloud Tasks queue lives in `us-central1`. Any queue enqueue from inside that worker fails with `404 Queue does not exist` — which silently dropped the auto-approval render trigger (job auto-approved perfectly, then sat at `review_complete` forever). This is also a latent pre-existing bug for any other enqueue attempted from the GPU job. **Fixes:** 1. New `settings.cloud_tasks_region` (default `us-central1`, overridable via `CLOUD_TASKS_REGION`) used for all Cloud Tasks queue paths. `gcp_region` is still used for Cloud Run Job locations (correct). 2. `recover-stuck-jobs` cron gains a sweep for `REVIEW_COMPLETE` jobs stalled >10 min with no `render_progress` — re-triggers the render worker (idempotent via worker-generation fence). This closes the lost-trigger orphan gap for BOTH the human complete-review fire-and-forget task and the auto-approval path, and will auto-rescue `b8bda9c2` on the first tick after deploy. ## Testing - New unit tests: queue path uses `us-central1` even when `GCP_REGION=us-east4`; stall detector (stalled / fresh / render-underway). - Note: `test_internal_api.py` auth tests fail identically on pristine `main` in this local env (green in CI) — pre-existing, unrelated. @coderabbitai ignore 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com> |
||
|
|
f01213f5cb |
Fully-auto review for confident jobs: review_mode framework + auto-approval scorer/executor + replay tool (v0.202.0) (#947)
## Summary Ships the **fully-automated review framework**: jobs now default to `review_mode="auto"` — when the auto-approval scorer is fully confident on BOTH axes, the combined review screens are skipped entirely and the job renders straight through. Everything else falls back to human review exactly as before. **The confident class (deliberately narrow to start, ~5% of jobs expected):** - **Lyrics**: synced reference present, ≥90-99% anchor coverage, and every gap word covered by the pre-generated AI auto-correct suggestions (which the executor applies server-side — a faithful port of the review UI's on-load auto-apply, including conflict-group resolution) — OR zero gaps outright. - **Backing vocals**: non-subjective only — no audible backing content → clean instrumental. - **Never-auto gates**: vocalization sections (da-da-dun/woo-woo — P3), phantom/absurd-duration lines (P8), too-few-words, no/unsynced reference, errored backing analysis. **Calibrated against a 20-job human-review corpus** (all recent admin reviews replayed + annotated): safety 100% (every job that truly needed a human stays in review), lyrics-auto 3/20, overall-auto 1/20. ## How it works - `screens_worker` (pre-AWAITING_REVIEW) and `audio_worker` (post-stems, for the audio-lags-lyrics ordering) both call `maybe_auto_complete_review()`. Every job gets a verdict recorded in `processing_metadata.auto_approval` (shadow data keeps accumulating for calibration); enforcement additionally requires: flag on + `review_mode="auto"` + not made-for-you + no existing/custom instrumental + audio complete. - Enforce path mirrors a human "Complete Review": apply cached AI suggestions → sanity checks → `corrections_updated.json` → `instrumental_selection="clean"` → clear progress keys → `GENERATING_SCREENS→REVIEW_COMPLETE` (new legal edge; no review token or "ready for review" notification is ever issued) → trigger render worker. - **Fail-safe everywhere**: stale suggestions, duplicate-word artifacts (P1 self-conflict signature), state changed mid-enforce (human opened editor), any exception → normal human review. Auto-approval can never fail a job. - Kill switch: `AUTO_APPROVAL_ENFORCE_ENABLED=false` (scoring continues). Per-job: `review_mode="always_review"` (admin PATCH, validated). - Excluded from enforcement (still shadow-scored): made-for-you orders (human QC is part of that product), custom-instrumental jobs. ## Also in this PR (sessions 1-3 of the initiative) - **Review replay tool** (admin-only, prod-inert): `?replay=1` reopens the real lyrics/instrumental review UIs read-only for completed jobs — queue nav, Post-AI/Final toggle, edit-log action panel, dev-only audio byte-proxy (env-gated `REVIEW_AUDIO_PROXY`, path-anchored). This is what produced the calibration corpus. - `auto_approval` service package: scorer (anchor/gap/AI-coverage signals + P3/P8 gate detectors), apply engine, executor, lyrics-diff, offline capture script. ## Testing - 100+ new unit tests across scorer/apply/executor/replay routes; full backend suite 4000+ green locally (8 pre-existing emulator failures reproduce identically on pristine `main` — local-env only, green in CI). Frontend: 1196 Jest tests green. - Scorer validated read-only against the 20 real prod jobs in the private calibration corpus. @coderabbitai ignore 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com> |
||
|
|
70ea964ca9 |
feat(dev): full local backend for external contributors (no GCP creds needed) (#946)
## Summary Motivated by external contributor Martín (netux) asking "is there an easy way to run the full backend without GCS?" — he couldn't test PR #895's backend changes locally. This PR makes the whole backend runnable locally against emulators with **zero GCP credentials and zero paid API keys**. ### What was broken for contributors - Workers migrated to Cloud Run Jobs for prod robustness (audio-download, audio-separation, lyrics-transcription, bulk-search) silently bypassed the direct-HTTP dev mode → local jobs stalled at PENDING forever - Signed URL generation called `google.auth.default()` → crashed with no credentials (review audio, downloads, theme previews, upload URLs) - Magic-link login 503'd locally (console email provider counted as "not configured") - Fresh emulator had no default theme → every job create returned 422 - `docs/DEVELOPMENT.md` told people to `cp .env.example .env` but the file didn't exist — and nothing loaded `.env` anyway - `run-backend-local.sh` defaulted to the production GCP project ### Changes - **worker_service**: CRJ-based workers run as local subprocesses (`python -m backend.workers.X --job-id Y`, exact CRJ parity) when `ENABLE_CLOUD_TASKS=false` **and** not `is_production()` (regression-tested both ways) - **storage_service**: signed URLs → plain fake-gcs-server URLs when `STORAGE_EMULATOR_HOST` set (GET via JSON API download path; PUT via unvalidated-signature path, enabled by `-public-host` on the emulator) - **users route**: magic-link 503 only in production; dev prints the link to the console - **file_upload bugfix**: a theme with style params but no asset files never got `style_params_gcs_path` written (empty-dict falsiness in `elif theme_style_assets:`) — surfaced by the minimal seed theme, latent in prod - **scripts/seed-local-data.py** (new): creates bucket + default theme; wired into `run-backend-local.sh --with-emulators`, which now uses `test-project` - **config**: `load_dotenv()` so `.env` actually works; new root `.env.example` - **CONTRIBUTING.md** (new): no-credentials quickstart; README + DEVELOPMENT.md link to it ### Verified end-to-end locally (no GCP credentials) Upload job → local audio separation (real models) → transcription → screens → `awaiting_review`; review endpoints all working including `/api/review/{job}/audio/vocals` (the PR #895 endpoint) and 302 → emulator audio URLs. Magic-link login round-trip via console link. ### Tests - 224 tests across affected files pass; full backend unit suite: 3969 passed - `backend/tests/test_emulator_integration.py` has 8 pre-existing failures that reproduce identically on unmodified `main` locally (broken theme-service mock in that file) — unrelated to this PR - New tests: dev-mode subprocess dispatch (audio + bulk-search), prod-mode never-Popen guard, emulator URL generation (GET + PUT) @coderabbitai ignore --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com> |
||
|
|
7729d30937 |
build: build frontend into the wheel in CI instead of committing out/ to git (supersedes #892) (#926)
Build the Next.js frontend into the wheel in CI instead of committing the generated out/ to git (fixes #876; supersedes #892). Validated: package-build-test green (npm ci → make build-frontend → poetry build → verify_wheel_frontend guard → install). Thanks @netux for surfacing it. |
||
|
|
6f86b3d901 |
test(e2e): rewrite tenant daily E2E as a faithful frontend journey (#873)
## Why The daily tenant E2E (`scripts/e2e/tenant_e2e.py`) drove the whole flow via **direct backend API calls**, bypassing the frontend. Two problems: 1. **Not representative** — it never exercised the tenant portal UI a real operator uses. 2. **Intermittent stuck-render orphans** (Run #31 vocalstar, #32 singa) — because it never loaded the lyrics-review page, it never fired `encoding-worker/warmup`, so the encoder was cold when the render started and the job orphaned in `rendering_video` (no recovery). Root-caused this session; the fix is to make the test faithful, which fires the warmup a real user fires. ## What Replaces `tenant_e2e.py` with **`frontend/e2e/production/tenant-happy-path.spec.ts`** — a Playwright journey mirroring `happy-path-real-user.spec.ts`, run per-tenant via the existing `e2e-tenant-daily.yml` matrix (vocalstar, singa; `max-parallel: 1`): login (real magic-link UI) → submit track (tenant form + real audio upload) → wait for transcription → **open review UI (fires warmup)** → approve → wait for render → assert tenant distribution (Dropbox present, no YouTube, downloads, `is_private`) → cleanup. - **Tenant auth**: added `inbox.testmail.app` to both tenants' `allowed_email_domains` (setup scripts + live GCS config via `scripts/e2e/update_tenant_allowlist.py`) so the test signs in through the real magic-link UI. - **Test audio**: short 60s clips fetched from private GCS in CI (`scripts/e2e/fetch_test_audio.sh`) — fast, reliable uploads and quick renders. - Workflow reworked to Node/Playwright; `tenant_e2e.py` deleted; version `0.190.3 → 0.190.4`. ## Findings surfaced (validating the exercise) - **Browser upload was CORS-blocked in Playwright** by the shared config's global `x-playwright-test` header (it made the GCS signed-URL PUT preflight request a header the bucket's CORS doesn't allow). Verified the same PUT succeeds in a real browser — a **test-harness artifact, not a product bug**. Worked around by stripping the header for `storage.googleapis.com` requests. (Note: any prod E2E doing a browser signed-URL upload is affected by this global header.) ## Verification Both tenants run **green end-to-end against prod** locally (login → submit → review → render → distribution; render completed without orphaning). Reworked workflow dispatched on this branch to confirm CI wiring (Node setup + private-audio fetch + secrets). Test-only + CI + tenant-config change. No product code. 🤖 Generated with [Claude Code](https://claude.com/claude-code) @coderabbitai ignore --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |
||
|
|
21e8a05c61 |
test(tenant): retry daily E2E once on transient encoder failure (#834)
@coderabbitai ignore
The shared GCE encoder intermittently drops a job mid-encode ("lost
contact with worker ... not found") — a pre-existing,
**non-tenant-specific** transient (it hit the daily E2E twice but not
the manual runs; both tenants complete when the encoder cooperates). The
daily health check now detects that specific error and retries the whole
job once, so it doesn't false-alarm on encoder flakiness. Other failures
still fail immediately. Test-script only.
Separately worth a look (out of scope here): the encoder "lost contact /
job not found" reliability affects consumer renders too.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
||
|
|
1218337346 |
test(tenant): daily E2E asserts portal downloads via file_urls (#831)
@coderabbitai ignore The daily tenant E2E asserted on `job.download_urls` (backed by `output_files`, which the orchestrator pipeline never populates), so it failed even on fully-successful jobs. The `OutputLinks` UI reads `job.file_urls` (finals/packages) — assert that instead. Confirmed in prod: **both vocalstar and singa pass the full E2E** — job completes, Dropbox link present, no YouTube, and all downloads available (4K / 720p / with-vocals MP4 + CDG + TXT). Doc updated with the final outcome. Test/docs only — no production code change. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |
||
|
|
66dcfd7d19 |
fix(tenant): stage instrumental in the orchestrator encode path (#829)
@coderabbitai ignore Follow-up to #828. That PR staged the instrumental in `_encode_via_gce` (legacy `video_worker.py`), but production jobs run the **orchestrator** pipeline (`video_worker_orchestrator.py`), whose `_run_encoding` builds its own `EncodingInput` and never made the user-supplied instrumental available under `jobs/{job_id}/`. Tenant jobs still failed at the GCE encoder with "No instrumental audio found" (confirmed — the "Staged existing instrumental" log never appeared). **Fix:** in the orchestrator's `_run_encoding`, when using the GCE backend, upload the local instrumental (existing/custom — identified by the `(Instrumental User)` / `(Instrumental Custom)` filename) into `jobs/{job_id}/` so the encoder's recursive `find_file` locates it. Consumer `clean`/`backing` jobs are untouched (their stems already live under `jobs/{job_id}/`). Also: the daily E2E uses a tenant-specific title so the two matrix tenants don't share a `base_name` (the GCE encoder caches by base_name). Validated by re-running the full prod E2E to completion after deploy. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |
||
|
|
40c7960854 |
fix(tenant): stage instrumental for the GCE encoder + daily tenant E2E (#828)
@coderabbitai ignore ## Final render blocker (bug #8) With #824/#825/#826/#827, tenant jobs now render the karaoke video — but the GCE encoder failed with **"No instrumental audio found"**. **Root cause:** the user-supplied instrumental lives under `uploads/{job}/audio/`, but the encoder only pulls input from `jobs/{job}/` (`input_gcs_path`) and locates the instrumental via `find_file("*existing_instrumental*", "*Instrumental User*")`. On top of that, the running encoder VM (`encoding-worker-b`) boots a **2026-01-23 image** that predates the encoder's own `existing_instrumental` config-download path (added 2026-03-04), so it could never fetch it from `uploads/` either. **Fix (image-agnostic — no risky shared-VM recreation, no consumer impact):** `_encode_via_gce` server-side copies the instrumental into `jobs/{job_id}/existing_instrumental.<ext>` before submitting. The encoder downloads `jobs/{job}/` and its **recursive** `find_file` then locates it on any image version. Added `StorageService.copy_blob` + unit test. > Note: the stale encoder VM image is a separate infra item — the `encoding-worker` VMs should be recreated from the image family's newest image (which has 3 months of encoder fixes). Tracked for a Pulumi pass; not required for this fix. ## Daily tenant E2E (second ask) - `scripts/e2e/tenant_e2e.py` — full per-tenant prod health check: submit → approve review → render → assert (completes, Dropbox link present, no YouTube, downloads available) → clean up job + uploads. - `.github/workflows/e2e-tenant-daily.yml` — daily matrix (vocalstar, singa), WIF auth, Discord + email on failure. - `docs/archive/2026-06-15-tenant-portals-e2e.md` — the full story (8 bugs, all fixed). ## Testing - `copy_blob` unit test; storage suite green (20). - Full tenant E2E re-run to completion after deploy. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |
||
|
|
d6bd2f1787 |
fix(tenant): complete the render for jobs that supply their own instrumental (#827)
@coderabbitai ignore ## Two final render blockers (found by the Vocal Star E2E) With attribution (#824), the audio slot (#825), and transcription padding (#826) fixed, the first real tenant job advanced through transcription → screens → review → render, surfacing the last two never-exercised issues: ### 1. Render prerequisites — "No instrumental selected" existing-instrumental jobs (every tenant submission) have no instrumental-selection UI step, so `instrumental_selection` was never written to state_data. The video orchestrator then defaults to `'clean'` (a separated stem that was never produced for these jobs), and `_validate_prerequisites` rejects the job, leaving it stuck retrying. **Fix:** `complete-review` now defaults `instrumental_selection` to `'custom'` (use the provided instrumental) when `existing_instrumental_gcs_path` is set. An explicit request value still wins. The render path already supports `'custom'`. ### 2. Theme asset paths (reproducibility) The tenant setup scripts wrote full `gs://bucket/themes/.../assets/X` URLs, but `theme_service._build_style_assets_mapping` only resolves bare basenames (the consumer convention). With `gs://` URLs, `style_assets` came back empty → assets never downloaded → encoder failed with "Video background image not found". Scripts now emit basenames, and add the newly-required `extra_text_text_transform` field the strict theme validator expects. (The two live GCS themes — vocalstar, singa — were corrected out-of-band to match.) ## Testing - New regression tests: complete-review defaults to `custom` for existing-instrumental jobs; explicit selection still wins. - Review suites green (102). Full E2E re-run to completion after deploy. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |
||
|
|
fea6ebec1a |
fix(tenant): make white-label B2B portals attribute jobs to the tenant (Vocal Star + Singa) (#824)
@coderabbitai ignore ## Problem The white-label tenant portals (`vocalstar.nomadkaraoke.com`, `singa.nomadkaraoke.com`) looked "done" but **had never worked end-to-end**: 0 of the last 484 production jobs carried a `tenant_id`. No tenant job had ever run. **Root cause:** the frontend API client never sent the `X-Tenant-ID` header. Tenant portals call the shared `api.nomadkaraoke.com`, whose Host isn't the tenant subdomain, and the `?tenant=` query param is disabled in prod — so the backend could never detect the tenant. Every tenant sign-in and job submission silently fell back to consumer behavior (default theme, no tenant Dropbox, etc.). The `getTenantHeaders()` helper existed and was unit-tested, but was never wired into requests. ## Changes **Frontend** (`lib/api.ts`, `lib/tenant.ts`) - Attach `X-Tenant-ID` on all authenticated requests **and** the magic-link request, sourced from `window.__TENANT_CONFIG__` (edge-injected by the Cloudflare function; mirrored from the tenant store for dev/preview). Consumer build resolves no tenant → no header → **behavior unchanged**. **Backend** (`_apply_tenant_overrides` in `file_upload.py`) - Make tenant config **authoritative** over global distribution defaults. Prod sets `DEFAULT_DROPBOX_PATH` / `DEFAULT_GDRIVE_FOLDER_ID` / `DEFAULT_BRAND_PREFIX` globally; these seed `dist`, and the old "fill only when unset" overlay let them leak — so every tenant job would have landed in the **shared consumer Dropbox folder** and uploaded to the **global Google Drive**. Now Dropbox/GDrive routing is gated by the tenant feature flags and cleared when disabled. **Tenant configs** (GCS + setup scripts, Vocal Star + Singa) - Disable Google Drive (`gdrive_upload=false`, `gdrive_folder_id=null`), keep YouTube off, enable Dropbox to each tenant's own folder. B2B = locked theme, no YouTube/GDrive, Dropbox + portal download only. ## Why it's consumer-safe - Frontend: header only attached when a tenant is resolved (never on `gen.nomadkaraoke.com`). - Backend: `_apply_tenant_overrides` early-returns when `tenant_config is None` (all consumer jobs). ## Testing - New: frontend header-attachment tests (tenant build vs consumer); backend authoritative-override + feature-flag-gating regression guards (incl. the global-default-leak case). - Full suites green: **3466 backend**, **1013 frontend**. - Verified live tenant configs via API after update. Manual prod E2E (real track through each portal) + a daily per-tenant E2E workflow follow in a second PR, once this deploys and is verified in prod. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |
||
|
|
39fb93653f |
fix(auto-correct): switch active model from Fable 5 to Opus 4.8 (#822)
## Summary Claude **Fable 5** (`claude-fable-5`) is no longer available on the Anthropic API. Verified live against `api.anthropic.com`: ``` 404 not_found_error: "Claude Fable 5 is not available. Please use Opus 4.8. Learn more: https://www.anthropic.com/news/fable-mythos-access" ``` `claude-opus-4-8` responds normally and is the API's own prescribed replacement. Opus 4.8 was also ≈ Gemini 3.1 Pro in our 30-job offline eval, so switching to it preserves the two-model compare quality. ## Changes - **`.github/workflows/ci.yml`** (load-bearing): `AUTO_CORRECT_MODEL=claude-opus-4-8` and `AUTO_CORRECT_COMPARE_MODELS=claude-opus-4-8;gemini-3.1-pro-preview`. Compare mode now runs **Opus 4.8 + Gemini 3.1 Pro** instead of Fable + Gemini. - **`scripts/measure_autocorrect_cost.py`**: default models + docstring example → Opus, so the cost tool measures what prod runs. - **`docs/API.md`**: example auto-correct response reflects Opus. - **`pyproject.toml`**: `0.182.1` → `0.182.2`. ## Re-enable path Fable is **disabled, not deleted** — its pricing entry in `pricing.py` and all Fable unit tests are intentionally left intact. If access returns, flip it back by reverting the two env-var values in `ci.yml`. ## Testing - Auto-correct suite: 73 passed (`backend/tests/services/auto_correct/` + `test_proactive_auto_correct.py`). - Live API probe confirmed Fable 404s and Opus 4.8 works. - CodeRabbit (uncommitted): 0 findings. @coderabbitai ignore Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
364e4ebd5f |
feat(auto-correct): proactive multi-model suggestions + cost logging + de-AI-ified review UI (#816)
## Summary Makes AI lyrics auto-correction run **automatically on every job** (multi-model), so suggestions are cached and ready the moment the reviewer opens the lyrics UI — plus token/cost instrumentation and a UI cleanup that removes all "AI"/"model" wording. Measured cost first (`scripts/measure_autocorrect_cost.py`): **~$0.13/track** multi-model on normal songs — cheap enough to run proactively. ## Changes **Cost instrumentation** - Capture per-model `usage` from Anthropic + Gemini; log greppable `auto-correct usage` / `auto-correct cost … total_est_cost_usd=…` lines from `suggest()`. - `backend/services/auto_correct/pricing.py` (Anthropic rates authoritative; Gemini estimated) + `scripts/measure_autocorrect_cost.py` offline harness. **Proactive generation (every job)** - `lyrics_worker._run_proactive_auto_correct()` runs the multi-model path after `mark_lyrics_complete` (downstream already triggered → non-blocking), gated by `AUTO_CORRECT_PROACTIVE_ENABLED`, bounded by a 180s timeout, and **swallows every error** — it never blocks or fails the karaoke job (flaky AI / out of credits / timeout all degrade gracefully). - Cache-key aligned with the UI request, so the review page's on-load call is an instant cache hit (no double spend). - `ci.yml`: wires `AUTO_CORRECT_*` env + the `anthropic-api-key` secret onto `lyrics-transcription-job` (same SA as the API service — no IAM change). **Review UI** - Always multi-model (removed the model-selection toggle); button renamed **"Auto-correct"**; stripped model/consensus/cached attribution badges; reworded strings to drop "AI"/"model" (translated to all 32 locales). - Auto-runs once on review load so suggestions are ready without a click; the button stays for the paste-references-later flow. ## Testing - Backend: **3460 passed** (`backend/tests/`, emulator excluded) — incl. new `test_pricing.py` + `test_proactive_auto_correct.py` (gating, graceful failure, cache alignment). - Frontend: **1006 jest tests pass**; type-clean; 33-locale key parity verified. ## Notes / follow-ups - Proactive activates on the **next deploy** (the lyrics-job env/secret apply via this PR's ci.yml on merge). - Left "AI" wording in two *separate* features untouched (different subsystems): `lyricsReview.agenticMetrics` and `lyricsReview.modals.correctionAnnotation` — flagged for a separate decision. - The production E2E spec's click-to-open flow may want a tweak now that suggestions auto-run on load. @coderabbitai ignore --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |
||
|
|
e806616408 |
fix: idempotent session revoke, error-pattern script crash, mobile header overlap (#798)
## Summary Three independent fixes bundled together: 1. **`revoke_session` idempotency** — stops the recurring `Error revoking session` prod error on `karaoke-backend`. Firestore `document.update()` raises `NotFound` (404) when a session doc is already gone (logged out / expired / cleaned up); logout against an already-absent session now succeeds instead of erroring. 2. **`query-error-patterns.py` crash** — `last_seen`/`first_seen` are stored as ISO-8601 strings in Firestore, but the sort key and `--hours` filter did `float(value)`, raising `ValueError` and breaking the `--json` path that `/prod-investigate` relies on. Added a `_to_epoch()` helper handling datetime objects, ISO strings, and numeric epochs. 3. **Mobile header overlap** — `AppHeader` was `position: fixed` and each consumer cleared it with a hardcoded top padding. On narrow viewports the header wraps to 3 rows (149px on a 412px Pixel), exceeding the 112px offset, hiding the "Create Karaoke Video" heading and the top of the form behind it (worse across locales with longer button labels). Switched `AppHeader` to `position: sticky` (matching the already-working jobs-page header) so content always clears it at any height, and removed the now-redundant magic-number offsets. ## Changes - `backend/services/user_service.py` — catch `google_exceptions.NotFound` in `revoke_session`, return `True` - `backend/tests/test_revoke_session.py` — new unit tests (existing / missing / unexpected-error paths) - `scripts/query-error-patterns.py` — `_to_epoch()` helper for sort + `--hours` filter - `frontend/components/app-header.tsx` — `fixed` → `sticky` - `frontend/app/[locale]/app/page.tsx`, `frontend/app/[locale]/app/referrals/page.tsx` — drop hardcoded top padding - `pyproject.toml` — bump to 0.174.17 ## Testing - [x] Backend tests pass locally (47 passed incl. 3 new `revoke_session` tests) - [x] `query-error-patterns.py --json` and `--hours` verified against live Firestore - [x] Mobile header fix verified in Playwright at 412px (Pixel) and 1280px — overlap eliminated (title moves from 12px behind the header to a clear gap below it) - [x] CodeRabbit CLI review: 0 findings ## Review - [x] Local CodeRabbit review completed - [x] Review feedback addressed (none) @coderabbitai ignore --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |
||
|
|
a45798bb4d |
fix: remove SendGrid leftovers; consolidate on Postmark (#779)
## Summary - Fixes the failing e2e-daily notification job ([run #25983930960](https://github.com/nomadkaraoke/karaoke-gen/actions/runs/25983930960/job/76378786060)) which still used \`smtp.sendgrid.net\` — SendGrid was cancelled ~3 weeks ago - Drops the \`sendgrid\` Python dep, removes \`SendGridEmailProvider\`, simplifies provider selection in \`email_service.py\` - Removes \`SENDGRID_API_KEY\` env bindings from Pulumi (gdrive-validator Cloud Function + video Cloud Run Job) and from ci.yml's Cloud Run \`--set-secrets\` - \`sendgrid-api-key\` Secret resource intentionally kept in \`infrastructure/modules/secrets.py\` with a "delete manually" marker so an unrelated \`pulumi up\` doesn't destroy the live secret + versions - Version bumped 0.174.10 → 0.174.11 ## Pulumi applied \`pulumi up --target\` already run locally with the two affected resources (video-encoding-job + gdrive-validator-function). PR #776's runner-manager state intentionally untouched. @coderabbitai ignore ## Test plan - [x] Full backend test suite (3178 tests) passes locally - [x] CodeRabbit local review: no findings - [x] Pulumi up applied locally (clean) - [ ] CI green on this PR - [ ] After merge: e2e-daily.yml notification job should pass on next scheduled run - [ ] Verify gdrive-validator function still emails on next post-job trigger 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
e40f39f0c2 |
fix(referrals): handle TZ-aware referred_at in record_earning (#737)
## Summary - **Bug**: `record_earning()` in `referral_service.py` compared naive `datetime.utcnow()` against TZ-aware `earning_expires` (derived from Firestore's TZ-aware `referred_at`), raising `TypeError: can't compare offset-naive and offset-aware datetimes`. The exception was swallowed by a broad `except` in the Stripe webhook handler and only logged as a warning, so **every referral earning was silently lost** since the referral system shipped (~3 weeks). - **Symptom (user report)**: referral code `angel` showed 0 purchases on the admin referrals page despite `tnt.travistoo@gmail.com` (a real user referred by angel) paying $28 on 2026-04-27. Production logs at the exact webhook moment confirmed: `Referral earning recording failed: can't compare offset-naive and offset-aware datetimes`. - **Fix**: same pattern previously applied to `_build_user_public()` — promote `now` to TZ-aware before comparing. - **Regression test**: existing tests mocked `referred_at` with naive `datetime.utcnow()`, so the bug was invisible. Added two TZ-aware variants matching production reality. - **Backfill script**: `scripts/backfill_referral_earnings.py` retroactively creates the missed `ReferralEarning` records and bumps per-link `stats.purchases` / `stats.total_earned_cents`. Idempotent, dry-run by default. Skips purchases predating attribution and refunded sessions. ## Backfill dry-run output (verified) ``` Earnings to create: 20 Skipped (not credit_purchase): 7 Skipped (before attribution): 7 Skipped (refunded / unsuccessful / outside window / zero): 0 Stats updates per link: angel: +1 purchases, +$5.60 (Travis) e2etest70: +15 purchases, +$9.00 (e2e tests) loyalty50: +4 purchases, +$7.15 (Angelina + John) ``` ## Test plan - [x] Unit test `test_creates_earning_with_tz_aware_referred_at` reproduces the production `TypeError` before the fix and passes after. - [x] Unit test `test_no_earning_outside_window_with_tz_aware_referred_at` confirms expired-window path also handles TZ-aware datetimes cleanly. - [x] Full referral test suite passes (71 tests). - [x] Full backend test suite passes (2987 tests). - [ ] **Post-merge**: run `python scripts/backfill_referral_earnings.py --apply` with full Firestore write credentials (claude-readonly ADC blocks writes). Expect 20 earnings created, 4 link stats updated. - [ ] **Post-merge**: verify admin referrals page now shows `angel: 1 purchase / $5.60 earned`. @coderabbitai ignore Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
9a5c9d497a |
feat: production error monitor — log collection, LLM analysis, Discord alerts (#713)
## Summary - Add a production error monitoring service that runs as a Cloud Run Job every 15 minutes - Queries Cloud Logging across all NK services (Cloud Run, Jobs, Functions, GCE VMs), normalizes/deduplicates errors, uses Gemini Flash for incident grouping, sends Discord alerts, and auto-resolves silent patterns - Updates all `/prod-*` slash commands to use pre-computed Firestore patterns as primary data source ## Architecture Based on the proven Aquarius error bot system, adapted for Nomad Karaoke's multi-service architecture (20+ resources across 4 resource types). **New backend modules** (`backend/services/error_monitor/`): - `config.py` — constants, monitored services, env var overrides - `normalizer.py` — regex normalization + SHA-256 pattern hashing - `known_issues.py` — 8 ignore patterns for infrastructure noise - `firestore_adapter.py` — CRUD for `error_patterns`, `error_incidents`, `discord_alerts` - `discord.py` — webhook client with 5 alert formatters (new pattern, incident, spike, auto-resolved, daily digest) - `llm_analysis.py` — Gemini Flash incident grouping + near-duplicate detection - `monitor.py` — orchestrator entry point (`python -m backend.services.error_monitor.monitor`) **New infrastructure** (`infrastructure/modules/error_monitor.py`): - Cloud Run Job (`nomad-error-monitor`) sharing karaoke-backend image - Cloud Scheduler: every 15 min monitor + 08:00 UTC daily digest - Scheduler service account with `roles/run.invoker` - Backend SA gets `roles/logging.viewer` **New CLI scripts:** - `scripts/query-error-patterns.py` — query patterns from Firestore - `scripts/resolve-error-pattern.py` — mark patterns as fixed with PR reference ## Testing - 310 unit tests across 7 test modules (all passing) - Covers: config, normalizer, known issues, Firestore adapter, Discord formatting, LLM analysis, monitor orchestrator - P0/P1 caller-callee contract tests for monitor integration points - All tests use mocked external dependencies (no GCP calls) ## Review - [x] CodeRabbit CLI review completed locally (1 cycle, 3 issues fixed) - [x] Test review completed (P0/P1 gaps addressed) - [x] Documentation updated (README, ARCHITECTURE) - [x] Version bumped (0.168.2 → 0.169.0) ## Design Spec `docs/archive/2026-04-12-error-monitor-design.md` @coderabbitai ignore --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
591c050545 |
feat: Reference lyrics search with relevance filtering (#632)
## Summary
- Add relevance filtering to the correction pipeline — automatically
rejects wrong-song reference lyrics (below 30% word match threshold,
validated against 168 prod source pairs)
- New `POST /api/review/{job_id}/search-lyrics` endpoint lets users
search with alternate artist/title from the review UI, with force-add
override for edge cases
- Redesigned Add Reference Lyrics modal with Search (default) and Paste
tabs, plus inline empty state when no valid sources exist
## Changes
### Backend
- **Relevance filtering** (`correction/relevance.py`): Per-source
scoring based on anchor sequence word coverage. Integrated into
`LyricsCorrector.run()` after anchor finding — sources below threshold
removed before corrections computed
- **Search endpoint** (`routes/review.py`): Queries all providers
(Genius, Spotify, Musixmatch, LRCLIB) with user-supplied artist/title,
auto-filters results, returns added/rejected/not-found breakdown
- **Provider factory** (`operations.py`): `create_lyrics_providers()`
reads env vars, `search_lyrics_sources()` orchestrates
fetch+filter+correct
- **Force override**: `add-lyrics` and `search-lyrics` support `force`
flag to bypass threshold
### Frontend
- **Tabbed modal**: `AddLyricsModal` rewritten with Search (default) and
Paste tabs
- **SearchLyricsTab**: Artist/title inputs, provider search, rejected
source cards with force-add checkboxes
- **ReferenceEmptyState**: Inline search/paste UI when no valid
reference sources exist
- **API client**: New `searchLyrics()` method with
`SearchLyricsResponse` types
### Analysis
- Empirical threshold analysis script
(`scripts/analyze_reference_relevance.py`) + visual review tool
- 168 source pairs from 81 prod jobs: wrong-song max 3.5%, correct-song
min 26.8% → 30% threshold
## Testing
- 35 new backend tests (relevance scoring, filtering, corrector
integration, search operation, API endpoint)
- 717 existing frontend tests passing (no regressions)
- Edge case: all sources filtered out handled gracefully
## Review
- [x] Local CodeRabbit review completed (3 issues fixed: response
contract, force param coercion, null checks)
@coderabbitai ignore
---
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
||
|
|
19efa269a8 |
feat: blue-green encoding worker deployment with deep health checks (#595)
## Summary - Replaces single encoding worker VM with a blue-green pair (a/b) for zero-downtime deployments - VMs auto-start on demand (JIT warmup when user opens lyrics review) and auto-shutdown after 15 min idle - CI deploys to secondary VM, runs a real encode test, then swaps the Firestore pointer atomically - Deep health check catches issues like PR #587's pip crash before they reach users - Cloud Function checks idle VMs every 5 minutes and stops them to minimize cost (~$10-15/mo idle vs $800/mo always-on) ## Architecture - **Firestore config doc** (`config/encoding-worker`) is single source of truth for primary/secondary routing - **Backend** reads primary IP from Firestore (30s TTL cache), starts VM on demand via Compute API - **CI workflow** handles blue-green swap: deploy → health check → real encode test → atomic Firestore swap → drain & stop old - **Cloud Function** auto-stops idle VMs based on active jobs, user activity, and deploy status - **Frontend** sends warmup signal on lyrics review page load + heartbeat on interactions ## Changes ### New Files - `backend/services/encoding_worker_manager.py` — VM lifecycle + Firestore config management - `backend/api/routes/encoding_worker.py` — Warmup and heartbeat API endpoints - `infrastructure/functions/encoding_worker_idle/` — Idle shutdown Cloud Function - `infrastructure/modules/encoding_worker_manager.py` — Pulumi module for Cloud Function + Scheduler - `scripts/seed-encoding-worker-config.py` — Firestore config seeding script - `infrastructure/encoding-worker/test-assets/test-preview.ass` — Test file for deploy health check ### Modified Files - `infrastructure/compute/encoding_worker_vm.py` — Single VM → blue-green pair - `infrastructure/__main__.py` — Wire up new VMs, Cloud Function, IAM - `backend/services/encoding_service.py` — Dynamic URL from Firestore, warmup-aware retry - `.github/workflows/ci.yml` — Blue-green deploy flow - `frontend/` — Warmup signal on lyrics review, heartbeat, warming-up UI state - `docs/` — Architecture, development, troubleshooting, lessons learned ## Test plan - [x] 47 new backend tests pass (EncodingWorkerManager, routes, dynamic URL resolution) - [x] 9 Cloud Function unit tests pass - [x] All 2808 existing backend tests pass (1 pre-existing failure unrelated) - [x] All 1116 existing unit tests pass (3 pre-existing failures unrelated) - [ ] Pulumi preview shows expected resource changes - [ ] Pulumi up applied locally before merge - [ ] Firestore config seeded with VM IPs - [ ] End-to-end verification after deployment ## Migration Steps (post-merge) 1. `pulumi up` creates 2 VMs, removes old VM 2. Seed Firestore: `python scripts/seed-encoding-worker-config.py <ip-a> <ip-b>` 3. Start VM A, verify health 4. First CI deploy exercises the blue-green flow ## Design Docs - Spec: `docs/superpowers/specs/2026-03-24-blue-green-encoding-worker-design.md` - Plan: `docs/superpowers/plans/2026-03-24-blue-green-encoding-worker.md` @coderabbitai ignore 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
b4be5968c2 |
fix: payment dashboard date handling, chart rendering, and sidebar padding (#466)
@coderabbitai ignore
## Summary
- **Revenue chart showed nothing**: `store_payment()` used
`datetime.utcnow()` for `created_at` instead of the Stripe session's
actual `created` timestamp. All backfilled payments appeared on a single
date. Fixed to use `session["created"]`.
- **Single data point invisible**: Recharts AreaChart doesn't render a
visible area with only one point. Added `dot={chart.length === 1}` so
single points show as dots.
- **Payment detail sidebar had no padding**: `SheetContent` had no
padding class. Added `p-6`.
- **Backfill date fix script**: Added `scripts/fix_backfill_dates.py`
(already run against production to correct 32 records).
## Test plan
- [x] All 32 payment tests pass locally
- [x] Revenue chart verified visually via dev server — shows proper date
distribution (Dec 2025 - Mar 2026)
- [x] Payment detail sidebar verified visually — proper padding on all
sides
- [x] Production API confirmed returning correct date-bucketed data
after fix script
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
|
||
|
|
937f8f7ec1 |
feat: YouTube quota GCP monitoring + legacy beta cleanup (#460)
## Summary - Remove the deprecated beta enrollment system (endpoints, models, email templates, admin UI, rate limits) — ~20 files cleaned - Remove legacy count-based YouTube upload tracking from rate_limit_service and dead blocklist methods - Add GCP Cloud Monitoring integration to cross-reference YouTube API quota usage with Firestore tracking - Add drift detection (alerts when GCP reported vs Firestore tracked differs >10%) - Display GCP quota data in admin rate-limits dashboard ## Changes ### Backend (15 files) - **Removed:** 5 beta endpoints, `BetaTesterStatus` enum, beta User fields, beta email templates, `validate_email_for_beta()`, deprecated YouTube/beta rate limit methods, dead blocklist CRUD methods - **Added:** `get_gcp_quota_usage()` to `YouTubeQuotaService` with Cloud Monitoring API query, 5-min cache, and drift detection - **Updated:** Rate limits API response model with GCP quota fields (`gcp_quota_available`, `gcp_quota_units_consumed`, `quota_drift`, `quota_drift_alert`) ### Frontend (11 files) - **Deleted:** `frontend/app/admin/beta/page.tsx` (entire beta admin page) - **Removed:** Beta sidebar nav, layout breadcrumb, admin stats card, beta types/API methods, legacy YouTube stats cards - **Added:** GCP Cloud Monitoring section in rate-limits page showing reported usage, delay, and drift alerts ### Tests (4 files) - Removed 8 obsolete tests for deprecated methods - Created `test_gcp_quota_monitor.py` with 10 tests covering GCP quota querying, caching, fallbacks, and drift detection - Updated mock data and assertions across test files ### Docs (3 files) - Removed beta endpoint docs from API.md, added GCP quota fields - Updated ARCHITECTURE.md with Cloud Monitoring integration - Removed beta program section from PRODUCT-VISION.md ## Test plan - [x] All 2265 backend tests pass (1 pre-existing failure unrelated) - [x] All 516 frontend Jest tests pass - [x] New GCP quota monitor tests cover success, caching, fallbacks, drift alerts - [ ] Verify admin rate-limits page no longer shows beta/legacy cards - [ ] Verify GCP quota section shows "unavailable" gracefully when monitoring data not yet populated @coderabbitai ignore 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> |
||
|
|
d91c2c2b4e |
feat: Stripe admin dashboard with revenue analytics and payment management (#461)
<!-- @coderabbitai ignore --> ## Summary - Full Stripe payment admin dashboard with revenue analytics, payment history, refund management, payout tracking, dispute monitoring, and webhook event audit log - New `StripeAdminService` backend service for payment data storage and analytics - Enhanced webhook handler to store enriched payment data and handle refunds/disputes - User payment history integration on admin user detail page - Backfill script for migrating existing payment data - 32 new unit/endpoint tests covering all P0 critical paths (refund logic, payment storage, credit deduction) - Production E2E tests for payments page and API endpoints - Bug fix: `auth_data[0]` subscript error in refund endpoint (AuthResult not subscriptable) ## Changes ### Backend (7 phases) - **New:** `backend/services/stripe_admin_service.py` - Core payment admin service (store, list, detail, refund, revenue summary, payouts, disputes, webhook events) - **New:** `scripts/backfill_stripe_payments.py` - One-time migration script for existing payments - **Modified:** `backend/api/routes/admin.py` - 9 new admin endpoints with Pydantic models - **Modified:** `backend/api/routes/users.py` - Enhanced webhook handler with payment storage, refund/dispute handling, event logging ### Frontend - **New:** `frontend/app/admin/payments/page.tsx` - 4-tab payments page (Revenue, Transactions, Payouts, Webhooks) - **New:** `frontend/components/admin/payment-detail.tsx` - Payment detail slide-out sheet - **New:** `frontend/components/admin/refund-dialog.tsx` - Refund dialog with credit deduction warning - **Modified:** `frontend/lib/api.ts` - 11 new TypeScript interfaces + adminApi methods - **Modified:** `frontend/app/admin/users/detail/page.tsx` - Payment history section - **Modified:** `frontend/components/admin/admin-sidebar.tsx` - Payments nav item - **Modified:** `frontend/app/admin/page.tsx` - Revenue card on dashboard ### Tests - **New:** `backend/tests/test_stripe_admin_service.py` - 21 unit tests - **New:** `backend/tests/test_admin_payment_endpoints.py` - 11 endpoint tests - **New:** `frontend/e2e/production/admin-payments.spec.ts` - Production E2E tests ## Post-deploy steps 1. Register webhook events in Stripe Dashboard: `charge.refunded`, `charge.dispute.created`, `charge.dispute.closed` 2. Run backfill: `python scripts/backfill_stripe_payments.py` 3. Create Firestore indexes if prompted ## Test plan - [x] 32 new tests pass (service + endpoint) - [x] 181 total tests pass (full suite, 1 pre-existing skip) - [ ] Visual verification of payments page after deploy - [ ] Backfill script dry-run against production - [ ] Verify webhook events are logged after deploy 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> |
||
|
|
2615261672 |
feat: add Singa whitelabel tenant and fix tenant infrastructure (#453)
## Summary - Add Singa as second whitelabel tenant (green/black branding, file-upload-only, locked theme) - Fix critical Zustand getter bug where computed properties became stale after set() calls - Fix React hydration error #300 (conditional return between hooks) - Add TenantLandingPage component for minimal tenant portal - Add Cloudflare Pages cache control headers - Add gs:// URL conversion fallback in tenant-logo ## Test plan - 27 tenant unit tests pass (5 new regression tests for Zustand bug) - 181 E2E tests pass - Verified singa/vocalstar/gen domains all working correctly <!-- @coderabbitai ignore --> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> |
||
|
|
a38096e8cc |
fix: prevent test hanging from emulator prompts, zombies, port conflicts (#448)
## Summary - Add `--quiet` flag to `gcloud beta emulators firestore start` to prevent interactive prompts that hang CI/agent sessions - Fix `stop-emulators.sh` to kill Java child processes (`pkill -P`) with port-based fallback for orphans on port 8080 - Generate unique Playwright dev server port per worktree (3100-3199 hash range) to prevent cross-worktree conflicts ## Test plan - [ ] `./scripts/start-emulators.sh` starts without interactive prompts - [ ] `./scripts/stop-emulators.sh` kills Java emulator child processes (no orphans on port 8080) - [ ] Playwright config generates different ports for different worktree directories - [ ] `E2E_PORT` env var still overrides the default port <!-- @coderabbitai ignore --> 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> |
||
|
|
a8ea9e6d38 |
feat: in-app Buy Credits dialog and pricing updates (#434)
## Summary - Fix broken "Buy More Credits" flow for logged-in users — replaces redirect (which bounced back to `/app`) with an in-app dialog - Add `BuyCreditsDialog` component following the existing `FeedbackDialog` pattern - Make credits count in header clickable to open the buy dialog - Update "Made For You" pricing from $15 to $50 (frontend labels + Stripe backend) - Update hero section: "Create It Yourself ($5)", green "2 free credits" message, remove redundant line, tighten spacing ## Test plan - [ ] Log in, click "Buy More Credits" in dropdown — dialog opens with package grid - [ ] Click credits count in header — same dialog opens - [ ] Select package, click "Continue to Payment" — redirects to Stripe checkout - [ ] Landing page pricing still works for unauthenticated users - [ ] Made For You order form shows $50 pricing - [ ] Hero section shows updated copy and tighter spacing <!-- @coderabbitai ignore --> 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> |
||
|
|
e0c8645fea |
Add email alerts, manual trigger, and post-job check to GDrive validator (#419)
@coderabbitai ignore ## Summary - **Email notifications via SendGrid** — replaces Pushbullet as the primary notification channel for the GDrive validator cloud function. Pushbullet kept as secondary fallback. - **Post-job trigger** — the backend orchestrator now triggers GDrive validation after each job that uploads to the public share, catching duplicates within minutes instead of up to 24 hours. - **Manual CLI** — `python scripts/check_public_share.py` for on-demand validation checks with formatted output and `--json` flag. - **Comprehensive docs** — `docs/GDRIVE-VALIDATOR.md` with architecture, configuration, troubleshooting, and operational reference. Motivated by the NOMAD-1271 duplicate brand code incident where daily-only checks left a duplicate undetected for ~24 hours. ## Changes | File | Change | |------|--------| | `infrastructure/functions/gdrive_validator/main.py` | Add `send_email_notification()` via SendGrid, unified `send_notification()` sends both email + Pushbullet | | `infrastructure/functions/gdrive_validator/requirements.txt` | Add `sendgrid>=6.0.0` | | `infrastructure/functions/gdrive_validator/deploy.sh` | Add SendGrid secret + email env vars | | `infrastructure/__main__.py` | Add SendGrid secret to function, backend SA invoker IAM (Cloud Functions + Cloud Run) | | `infrastructure/modules/secrets.py` | Add `gdrive-validator-url` secret | | `.github/workflows/ci.yml` | Add `GDRIVE_VALIDATOR_URL` to Cloud Run deploy secrets | | `backend/services/gdrive_validator_client.py` | **New**: HTTP client with OIDC auth, fire-and-forget pattern | | `backend/workers/video_worker_orchestrator.py` | Add Stage 6: post-distribution GDrive validation (only when `gdrive_folder_id` set) | | `scripts/check_public_share.py` | **New**: CLI tool for manual validation checks | | `docs/GDRIVE-VALIDATOR.md` | **New**: Comprehensive validator documentation | | `pyproject.toml` | Version bump to 0.119.9 | ## Already deployed - Pulumi infrastructure applied (IAM bindings, secrets, function config) - Cloud Function redeployed with SendGrid support - `gdrive-validator-url` secret set in Secret Manager - Tested via `check_public_share.py` — validated 3,608 files, email sent successfully ## Test plan - [x] `make test` — 170 passed, 3 skipped (1 pre-existing failure in credit-enforcement unrelated to this PR) - [x] `pulumi preview` — clean, 3 creates + 1 update - [x] `pulumi up` — applied successfully - [x] Cloud Function deployed and tested end-to-end - [x] `python scripts/check_public_share.py` — formatted output works - [x] `python scripts/check_public_share.py --json` — JSON output works - [x] Email received at gen@nomadkaraoke.com (notification_sent: true) - [ ] Post-job trigger: will verify on next job completion (backend needs redeploy via CI merge) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> |
||
|
|
c7b7f4bee5 |
fix: gate brand code recycling on full GDrive cleanup confirmation (#418)
## Summary
- Brand code `NOMAD-1271` was reused for a real song (Hot Mulligan - Pop
Shuvit) while old E2E test job files still existed in Google Drive,
creating a duplicate in the public share
- Root cause: `cleanup-distribution` endpoint had two bugs that allowed
brand codes to be recycled before GDrive was confirmed clean
## Root Causes
1. **Empty dict was falsy**: `if gdrive_files:` skips cleanup when
`gdrive_files = {}` (empty dict). This happened when GDrive uploads
silently failed (pre-PR #417), so test job files accumulated in GDrive
without ever being cleaned
2. **Brand code recycled too early**: Brand code was recycled
immediately after Dropbox cleanup succeeded, *without* confirming GDrive
was also clean — a new job could claim the recycled code while old
GDrive files still existed
## Changes
- **`gdrive_service.py`**: Added `find_files_by_brand_code()` — searches
CDG/, MP4/, MP4-720p/ subfolders by brand code prefix as a fallback when
tracked file IDs aren't available (old jobs, or jobs where upload failed
silently). Raises `RuntimeError` if any subfolder search fails so
callers can't misread an incomplete search as "GDrive is clean"
- **`jobs.py` (`cleanup-distribution`)**: Now uses tracked file IDs
(fast path) OR falls back to brand_code search; brand code is only
recycled after **both** Dropbox AND GDrive are confirmed clean. Fixed
`method` key being lost when results dict was replaced (use local
variable instead of interim mutation)
- **`scripts/cleanup_test_job_gdrive.py`**: Remediation script to delete
existing stranded test job files from GDrive
## Testing
- 41 tests passing, 94% coverage on `gdrive_service.py`
- New `TestDeleteFile` class (5 tests for `delete_file`/`delete_files` —
previously uncovered)
- New `test_cleanup_distribution.py` (9 tests covering fast path,
fallback, and brand code gating logic)
- Updated error handling test to verify `RuntimeError` is raised (not
swallowed) on subfolder search failure
- [x] CodeRabbit CLI review completed, 2 findings fixed
@coderabbitai ignore
---
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude <noreply@anthropic.com>
|
||
|
|
0f5ddb0092 |
Fix silent Google Drive upload failures with retry + alerting (#417)
## Summary
- Added tenacity retry with connection reset to Google Drive API calls
(`get_or_create_folder`, `upload_file`, `delete_file`) to handle stale
HTTP connections on idle Cloud Run containers
- Added `distribution_warnings` field to `OrchestratorResult` and
`_handle_native_distribution()` to track non-fatal upload failures
(YouTube, Dropbox, GDrive)
- Added Pushbullet notification when distribution uploads fail, so
operator is alerted immediately
- Added backfill script (`scripts/backfill_gdrive_uploads.py`) for
affected jobs - already run successfully for 12 affected jobs
- Updated docs: LESSONS-LEARNED.md and TROUBLESHOOTING.md with GDrive
stale connection pattern
## Context
Every GDrive upload silently failed for ~1 month (64 errors, 12+
affected jobs). The root cause was the singleton `GoogleDriveService`
caching its HTTP connection, which went stale when Cloud Run containers
sat idle between jobs. The orchestrator caught all exceptions and
continued, so jobs completed with `gdrive_files: {}` and no alert was
sent.
## Test plan
- [x] 5 new retry behavior tests in `test_gdrive_service.py`
(BrokenPipeError, SSLError, give up after 3, service reset, no retry on
non-transient)
- [x] 3 new distribution warnings tests in
`test_video_worker_orchestrator.py`
- [x] All 76 affected tests pass
- [x] Full backend test suite passes
- [x] Backfill script already run successfully for all 12 affected jobs
@coderabbitai ignore
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
|
||
|
|
23a8b0fb98 |
Fix missing CDG ZIP packages: fail-fast validation + remediation (#416)
## Summary
- **Systemic fix**: Orchestrator now validates CDG/TXT outputs after
packaging, before encoding. If `enable_cdg=True` but no CDG ZIP was
produced, the job fails immediately with a clear error instead of
silently completing without the package.
- **Remediation**: Created `scripts/regenerate_cdg.py` to regenerate and
distribute CDG/TXT packages for affected jobs (5b6aba25, 5161b069).
Packages uploaded to GCS, GDrive, and Dropbox.
- **Root cause**: Before
|
||
|
|
29be83cb56 |
Combined review flow: lyrics + instrumental selection in one session (#351)
## Summary Merges the two-step human review process (lyrics review → instrumental selection) into a single unified flow. Users now review lyrics AND select instrumental track in one session. **Benefits:** - Better UX (one interaction vs two) - Reduced drop-off between steps - Single email notification instead of two - Simpler workflow ## Changes ### Backend - `complete_review` endpoint now accepts optional `instrumental_selection` in request body - Backing vocals analysis moved from `render_video_worker` to `screens_worker` (runs before review) - Removed standalone instrumental selection endpoints (now part of combined review) - Added `CompleteReviewRequest` model with validation ### Frontend - New `InstrumentalSelectorEmbedded` component for combined review UI - `LyricsAnalyzer` updated to proceed to instrumental review - `ReviewChangesModal` shows "Proceed to Instrumental Review" button - Mock data updated in E2E tests ### Local CLI - `gen_cli.py` refactored to use `run_combined_review()` instead of separate `run_instrumental_review()` - `ReviewServer` extended with instrumental options and analysis - Deleted standalone `InstrumentalReviewServer` ### Documentation - Updated `docs/README.md` with recent changes entry - Updated `docs/ARCHITECTURE.md` with new pipeline diagram - Updated `docs/API.md` with endpoint changes - Added lesson to `docs/LESSONS-LEARNED.md` ## Test plan - [x] Backend unit tests: 1742 passed - [x] Frontend unit tests: 234 passed - [x] New integration tests: 5 tests for combined flow - [x] New backend tests: 7 tests for CompleteReviewRequest and state_data - [x] New frontend E2E tests: 6 tests for combined flow UI 🤖 Generated with [Claude Code](https://claude.com/claude-code) @coderabbitai ignore --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> |
||
|
|
5da050e063 |
fix: resolve phantom gaps in anchor sequence finder (#345)
## Summary - Fix two bugs causing phantom gaps in lyrics correction - Add post-filtering gap extension to absorb single-word gaps into adjacent anchors - Add comprehensive test fixtures from 14 production jobs ## Bugs Fixed 1. **Initial gap creation bug** (line 986): The condition `if transcription_position > 0` was always False for position 0, causing the first word to be completely uncovered. Fixed to `if transcribed_word_ids`. 2. **Text normalization mismatch** (line 455): Transcription words used simple `lower().strip()` while references used `clean_text()` which removes apostrophes. This caused "Train's" != "trains" mismatches. Fixed to use consistent `clean_text()` for both. ## Results | Metric | Before | After | |--------|--------|-------| | Coverage (Nana Grizol) | 79.6% | 87.0% | | Phantom gaps at boundaries | Common | Eliminated | | Words with apostrophes | Mismatched | Correctly matched | ## Test plan - [x] All 1736 existing tests pass - [x] New test suite with 14 real production job fixtures - [x] Visual review of all test fixtures confirms improvement - [x] Coverage tests verify no regression @coderabbitai ignore 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> |
||
|
|
2ebe8503d7 |
fix(infra): remove unused Cloud Build IAM binding and legacy files (#337)
## Summary - Remove the `cloudbuild-deploy-as-backend` IAM resource that was causing Pulumi deployment failures - Delete legacy Cloud Build files that were never working ## Problem Every push to main has been failing in the "Deploy - Infrastructure (Pulumi)" step with: ``` Permission 'iam.serviceAccounts.setIamPolicy' denied on resource ``` This resource was added to grant Cloud Build permission to deploy Cloud Run services, but: 1. CI uses GitHub Actions for builds and deployments, not Cloud Build 2. The GitHub Actions SA doesn't have `iam.serviceAccounts.setIamPolicy` permission 3. The Cloud Build yaml files were legacy/unused ## Changes - Remove `cloudbuild-deploy-as-backend` IAM binding from Pulumi - Delete `cloudbuild.yaml`, `cloudbuild-base.yaml`, `scripts/deploy.sh` - Update README to note deployments happen via GitHub Actions CI ## Test plan - [x] Verify Python syntax: `cd infrastructure && python -c "import __main__"` - [ ] CI should pass - Pulumi will no longer try to create the problematic IAM binding @coderabbitai ignore 🤖 Generated with [Claude Code](https://claude.ai/code) --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> |
||
|
|
e2fc6b616a |
feat!: Remove default style constants, require explicit themes (BREAKING) (#332)
Auto-merging after CI passes. Phase 1 & 2 complete: - Theme validation added - All default fallback logic removed - 1088+ tests passing - CodeRabbit review passed - Documentation complete BREAKING CHANGE: Themes must now be complete with all required sections. |
||
|
|
404c6e6133 |
fix: make lyrics_transcriber a subpackage of karaoke_gen (#299)
## Summary Fixes the deployment failure from PR #297 by making lyrics_transcriber a proper subpackage of karaoke_gen instead of a separate vendored library. ### Changes - Move `libs/lyrics_transcriber/` to `karaoke_gen/lyrics_transcriber/` - Update all imports from `from lyrics_transcriber.X` to `from karaoke_gen.lyrics_transcriber.X` - Simplify Dockerfile (no separate `libs/` COPY needed) - Update pyproject.toml to remove separate package entry - Update test mocks and logger names ### Why this is better - Cleaner project structure - one package containing everything - Simpler Dockerfile - just COPY karaoke_gen/ - No confusion about vendored vs internal code ## Test plan - [x] `poetry install` succeeds - [x] All imports work correctly - [x] All 2614 tests pass - [ ] Backend deployment succeeds @coderabbitai ignore Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> |
||
|
|
a52ea006cb |
refactor: deprecate python-lyrics-transcriber, consolidate into karaoke-gen (#297)
## Summary - Moved lyrics_transcriber from lyrics_transcriber_temp/ to libs/ - Removed obsolete standalone package files - Updated pyproject.toml paths - Archived python-lyrics-transcriber repo ## Test plan - [x] poetry install succeeds - [x] Backend tests pass (2614) - [x] python-lyrics-transcriber archived @coderabbitai ignore --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> |
||
|
|
d89ccf0edd |
feat(stripe): Add payment method configuration for Google Pay and Link (#255)
## Summary - Add support for `STRIPE_PAYMENT_METHOD_CONFIG` environment variable to enable wallet payment methods (Google Pay, Apple Pay, Link) in Stripe Checkout sessions - Update `docs/STRIPE-SETUP.md` with configuration instructions - Add diagnostic scripts for testing Stripe payment method setup ## Context Investigation revealed that Google Pay and Link require the `payment_method_configuration` parameter to be passed to Stripe Checkout session creation. Without this, Stripe uses defaults which may not include all enabled wallet methods. Additional findings: - Link visibility is subject to Stripe A/B testing (confirmed by Stripe support) - Google Pay requires Chrome/Chromium browser (Firefox not supported) ## Test plan - [x] Tested checkout session creation with payment method config on Android Chrome - [x] Verified Google Pay and Link appear in checkout - [x] Verified made-for-you checkout flow shows all payment methods @coderabbitai ignore 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> |
||
|
|
42c304dcdf |
feat(multitenancy): Implement white-label B2B portal infrastructure (#241)
## Summary
Adds multi-tenant white-label portal infrastructure for B2B customers.
Vocal Star is the first tenant at `vocalstar.nomadkaraoke.com`.
## Changes
### Backend
- **Tenant Models** (`backend/models/tenant.py`): Pydantic models for
TenantConfig with branding, features, defaults, and auth settings
- **Tenant Service** (`backend/services/tenant_service.py`): GCS-backed
config loading with 5-min cache, signed URL generation for logos
- **Tenant API** (`backend/api/routes/tenant.py`): `GET
/api/tenant/config` and `GET /api/tenant/config/{tenant_id}` endpoints
- **Tenant Middleware** (`backend/middleware/tenant.py`): Extracts
tenant from X-Tenant-ID header, query param (dev only), or Host
subdomain
- **Auth Updates**: Email domain validation for tenant-restricted auth,
sender email override
- **Feature Enforcement**: Audio search endpoint checks
`features.audio_search`, returns 403 if disabled
- **Job Scoping**: Added `tenant_id` field to JobCreate
### Frontend
- **Tenant Store** (`frontend/lib/tenant.ts`): Zustand store with tenant
state, `useTenant()` hook, CSS variable application
- **TenantProvider** (`frontend/components/tenant-provider.tsx`):
Hydration-safe initialization via useEffect
- **TenantLogo** (`frontend/components/tenant-logo.tsx`): Dynamic logo
with fallback to Nomad Karaoke
- **Feature-Flagged UI**: Tabs conditionally rendered based on tenant
features, active tab sync
- **Locked Themes**: `defaults.locked_theme` hides theme selector and
enforces specific theme
- **Output Links**: Filtered based on distribution features
### Security
- Query param tenant detection disabled in production (prevents
spoofing)
- Strict subdomain patterns: only `{tenant}.nomadkaraoke.com` or
`{tenant}.gen.nomadkaraoke.com`
- PII masking in logs (`an***@vo***.com`)
- `is_active` check prevents inactive tenants from being used
### Documentation
- ARCHITECTURE.md: New Multitenancy section
- API.md: Tenant Config endpoints
- LESSONS-LEARNED.md: 3 new lessons on multitenancy patterns
- Archive: Comprehensive implementation document
### Setup
- `scripts/setup-vocalstar-tenant.py`: Uploads theme assets, creates
tenant/theme configs in GCS
## Vocal Star Configuration
- **Subdomain**: `vocalstar.nomadkaraoke.com`
- **Features**: File upload only (no audio search, no YouTube URL)
- **Distribution**: Download only (no YouTube/Dropbox/GDrive)
- **Theme**: Locked to "vocalstar" (yellow/blue)
- **Auth**: Restricted to `@vocal-star.com` and `@vocalstarmusic.com`
emails
## Testing
- [x] Frontend TypeScript build passes
- [x] CodeRabbit CLI review completed (3 cycles, all issues fixed)
- [x] Manual testing with `?tenant=vocalstar` query param
## Next Steps (post-merge)
1. Configure DNS: CNAME for `vocalstar.nomadkaraoke.com`
2. Update Cloudflare Pages for subdomain
3. Run setup script to upload Vocal Star assets to GCS
4. Test at `https://vocalstar.nomadkaraoke.com`
@coderabbitai ignore
---
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
|
||
|
|
2e71dc3158 |
feat(infra): Upgrade encoding worker to c4d-highcpu-32 (4.92x faster) (#244)
## Summary Upgrades the GCE encoding worker from c4-standard-8 (Intel Xeon) to c4d-highcpu-32 (AMD EPYC 9B45 Turin), achieving **4.92x faster encoding performance** based on rigorous benchmarking. ## Changes - **Infrastructure**: Updated `MachineTypes.ENCODING_WORKER` to `c4d-highcpu-32` in `config.py` - **Documentation**: Comprehensive benchmark results in `docs/archive/2026-01-08-performance-investigation.md` - **Lessons Learned**: Added "GCE Instance Type Selection for FFmpeg Encoding" section - **Benchmark Scripts**: Added reusable scripts for future infrastructure testing: - `scripts/benchmark_encoding.py` - Local Python benchmark using actual code paths - `scripts/benchmark_encoding_gce.sh` - Shell benchmark for GCE VMs - `scripts/benchmark_candidates.sh` - Multi-VM orchestration for comparative testing ## Benchmark Results | Instance | CPU | Total Time | vs Baseline | |----------|-----|------------|-------------| | c4-standard-8 (baseline) | Intel Xeon | 666s | 1.00x | | c4-highcpu-16 | Intel Xeon | 309s | 2.16x | | c4a-highcpu-16 | Google Axion ARM | 248s | 2.69x | | c4d-highcpu-16 | AMD EPYC 9B45 | 220s | 3.03x | | **c4d-highcpu-32** | **AMD EPYC 9B45** | **135s** | **4.92x** | Key finding: AMD EPYC Turin significantly outperforms Intel Granite Rapids for CPU-bound FFmpeg/libass workloads. ## Testing - [x] Benchmarked on actual GCE instances with production data - [x] Verified c4d-highcpu-32 uses hyperdisk-balanced (already configured) - [ ] Infrastructure deploys via CI after merge ## Deployment Impact ⚠️ Changing machine type will cause Pulumi to **replace** the VM (~1-2 min downtime). Jobs queued during restart will retry automatically. @coderabbitai ignore --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> |
||
|
|
f661b6a27b |
feat(branding): Implement consistent brand theming across all frontends (#231)
## Summary - Implement unified brand theming with brand pink (#ff7acc) as primary color across all Nomad Karaoke frontends - Create comprehensive brand style guide for human and LLM reference - Add proper light/dark mode support throughout - Update homepage content for transparency and accuracy - Create product communication guide for consistent messaging ## Changes ### Homepage Content Updates - Changed "in minutes" to "in under 30 minutes" for accuracy - Removed AI terminology per user preference (use "our system" instead) - Made review step clearly required, not optional polish - Fixed YouTube claim: videos go to Nomad Karaoke channel, not user's - Added demo video embed - Added placeholder sections for screenshots (job dashboard, lyrics review, etc.) ### Brand Style Guide (`docs/BRAND-STYLE-GUIDE.md`) - Comprehensive guide covering colors, typography, logo usage, UI components, email design - Updated to v1.1: radial background gradients, logo usage (SVG preferred), light/dark theme requirements - Fixed success color consistency (#22c55e) ### Product Communication Guide (`docs/PRODUCT-COMMUNICATION-GUIDE.md`) - Core principles: transparency over hype, avoid AI term, acknowledge user effort - Terminology preferences table - FAQ guidance for consistent answers - Referenced in CLAUDE.md for future agent sessions ### Main Frontend (`frontend/`) - Updated CSS variables in `globals.css` for brand colors and light/dark mode - Added ThemeProvider to layout for proper theme switching - Updated landing page, auth dialog, job cards with brand pink (#ff7acc) - Created Playwright screenshot tests for visual verification ### Lyrics Transcriber Frontend - Updated MUI theme with brand pink primary color - Fixed theme-aware colors in: EditModal, EditWordList, WordDivider, Word, CorrectedWordWithActions, TranscriptionView, ReferenceView, AIFeedbackModal - Fixed TapButton onMouseLeave race condition - Added clarifying tooltip to Undo Auto Corrections button ### Email Templates - Refactored to use reusable helper methods (`_build_email_html`, `_get_email_header`, `_get_email_footer`) - Updated all 7 email templates with brand pink headers, buttons, and accents - Fixed success color to match brand guide (#22c55e) - Updated preview script to use actual email service ### Other - Bumped versions: backend 0.96.0, frontend 0.81.0 - Added archive entry for brand consistency work ## Screenshots ### Homepage | Hero Section | Full Page | |--------------|-----------| |  |  | ### Lyrics Review UI  ### Instrumental Review UI  ### Email Templates | Job Completion | Action Reminder | Beta Welcome | |----------------|-----------------|--------------| |  |  |  | ## Test plan - [x] Playwright screenshots captured - [x] Visual verification of brand consistency - [x] Frontend build passes - [x] CodeRabbit review feedback addressed (3 cycles) @coderabbitai ignore 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
2ee3cabc92 | Added admin API script (#196) | ||
|
|
ab05ec8bee |
feat: Migrate user storage to gen_users collection (#173)
## Summary
Separates karaoke-gen user data from karaoke-decide by using a dedicated
`gen_users` collection instead of the shared `users` collection.
**Problem:** Both karaoke-gen and karaoke-decide were using the same
`users` collection in Firestore with incompatible schemas:
- karaoke-gen: email as doc ID, has `credits`, `role`, `is_active`
- karaoke-decide: hash as doc ID, has `user_id`, `is_guest`, `quiz_*`
fields
**Solution:** karaoke-gen now uses its own `gen_users` collection.
## Changes
- Updated `USERS_COLLECTION` constant from `"users"` to `"gen_users"`
- Updated all hardcoded `db.collection("users")` references to use the
constant
- Updated Pulumi Firestore indexes for `gen_users` collection
- Added migration script (already executed)
## Migration Status
✅ 42 karaoke-gen users migrated to `gen_users` collection
✅ 36 karaoke-decide users remain in `users` collection (untouched)
✅ Firestore indexes created for `gen_users`
## Test plan
- [ ] Admin dashboard loads user list from `gen_users`
- [ ] User login/signup works
- [ ] Credit operations work
@coderabbitai ignore
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
|
||
|
|
30f6fc6c05 |
perf: Improve cloud karaoke generation performance (#160)
## Summary Infrastructure changes to address 3x performance gap between local and cloud karaoke generation: - **Keep Cloud Run warm** with `min-instances: 4` (eliminates 77s cold starts) - **Upgrade FFmpeg** from Debian 5.1.8 to static 7.0.2 (~20-40% faster encoding) - **Add diagnostics** to `/api/health/detailed` endpoint (FFmpeg version, CPU info) - **Add performance scripts** for benchmarking and comparison ## Changes - `.github/workflows/ci.yml`: Changed `--min-instances` from 0 to 4 - `backend/Dockerfile.base`: Replace `apt-get install ffmpeg` with John Van Sickle's static build - `backend/api/routes/health.py`: Add `get_system_info()` and `get_ffmpeg_info()` to detailed health endpoint - `docs/DEVELOPMENT.md`: Add new scripts to Key Scripts table - `docs/LESSONS-LEARNED.md`: Document Cloud Run cold start and FFmpeg optimization findings - `scripts/benchmark_ffmpeg.py`: Isolated FFmpeg encoding benchmark - `scripts/compare_local_vs_remote.py`: Compare local vs cloud karaoke-gen performance ## Expected Performance Improvement | Metric | Before | After | |--------|--------|-------| | Cold start | 77s | 0s (warm instances) | | Video encoding | 174s | ~120-140s (FFmpeg 7.x) | ## Testing - [ ] Tests pass locally - [x] FFmpeg static build verified in Docker container - [ ] Manual testing after deploy @coderabbitai ignore --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> |
||
|
|
a4a9d46c83 |
feat(agentic): Add LangFuse prompt management for dynamic prompt iteration
Replace hardcoded LLM prompts with LangFuse-managed prompts to enable prompt iteration without redeploying. Key changes: - Add LangFusePromptService for fetching prompts and examples from LangFuse - Add fetch_prompt() and fetch_dataset() helpers with version fallback - Update classifier to use LangFuse prompts with hardcoded fallback for dev - Add migration script to upload prompts/examples to LangFuse - Delete legacy LLM handler code (llm.py, llm_providers.py) - Change default LangFuse host to US region (us.cloud.langfuse.com) - Add unit tests for prompt service 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> |
||
|
|
3b1984b8d4 |
fix(scripts): Improve debug-job.sh with accurate status display
- Use KARAOKE_GEN_AUTH_TOKEN env var instead of gcloud identity token - Use production API URL (api.nomadkaraoke.com) by default - Add HTTP status code checking with helpful error messages - Handle null/empty timeline gracefully - Add worker logs section (more accurate real-time status) - Compute enhanced status from state_data (like frontend does) - Show step-based progress (e.g., "[4/10] Transcribing") - Warn when backend status is stale vs actual worker progress - Show more useful job details (artist, title, dates, file URLs) The backend job.status field can be stale during parallel processing, but state_data contains accurate worker progress. This mirrors the frontend's approach in lib/job-status.ts. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> |
||
|
|
73e933d3b5 |
fix(agentic): Use Gemini 3 Flash with global region and fix response parsing
Changes: - Reverted to gemini-3-flash-preview (latest model with best capabilities) - Changed GCP_LOCATION default from us-central1 to global (required for Gemini 3) - Fixed multimodal response parsing for Gemini 3 models (returns list of content parts) - Added local test script for agentic correction workflow The test script (scripts/test_agentic_correction.py) allows testing the agentic correction locally without deploying to Cloud Run, making iteration faster. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> |
||
|
|
39b847465b |
chore: Fix datetime.utcnow() deprecation in investigate_user script
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> |