The scalable architecture (Cloud Tasks queues, IAM, infrastructure) was
deployed via Pulumi but never activated in the Cloud Run deployment.
Changes:
- Enable ENABLE_CLOUD_TASKS=true environment variable
- Set CLOUD_RUN_SERVICE_URL for Cloud Tasks callbacks
- Set GCP_REGION for queue location consistency
- Change concurrency from 4 to 1 for true container isolation
- Increase max-instances from 10 to 50 for higher throughput
This completes Phase 1 of the scalable architecture migration, ensuring
each job gets dedicated container resources with no contention.
1. _validate_url now handles None and non-string inputs safely
- Added early guard: if url is None or not isinstance(url, str)
- Updated function signature to accept Optional[str]
2. Fixed cookie tempfile leak in file_handler.py
- Use context manager pattern to safely write cookies
- Track cookie_file_path instead of cookie_file object
- Guaranteed cleanup in finally block
3. Removed unused style_params_path from submit_job_from_url
- URL-based jobs don't support custom styles (would need signed URL upload)
- Added warning when user provides --style_params_json with URL input
- Updated docstring to clarify limitation
Also merged latest main which added job_logging_context for log isolation.
Create comprehensive SCALABLE-ARCHITECTURE-PLAN.md covering:
- Cloud Tasks for guaranteed delivery and horizontal scaling
- Cloud Run Jobs for long-running video encoding tasks
- Shared pipeline architecture for code reuse (DRY, SOLID)
- Dedicated resources per job (no CPU/memory contention)
- Implementation roadmap with phased approach
- Resource configuration and cost estimates
Update BACKEND-FEATURE-PARITY-PLAN.md to reference new document.
Add support for searching and downloading audio by artist+title in remote mode,
enabling the same functionality as the local CLI's flacfetch integration.
New features:
- `karaoke-gen-remote "Artist" "Title"` - search for audio without providing a file
- `--auto-download` flag for automatic best-quality selection
- `-y` flag also triggers auto-download mode
- Interactive mode displays search results for user selection
Backend changes:
- New AudioSearchService integrating flacfetch library
- New API endpoints: POST /api/audio-search/search, GET /api/audio-search/{job_id}/results, POST /api/audio-search/{job_id}/select
- New job statuses: searching_audio, awaiting_audio_selection, downloading_audio
- Job model extended with audio_search_artist, audio_search_title, auto_download fields
Remote CLI changes:
- Detects artist+title input without file path
- Displays search results interactively
- Handles audio source selection flow
- Supports both interactive and auto-download modes
Tests:
- 20+ unit tests for AudioSearchService and Job model fields
- Tests for state transitions and API response handling
Documentation:
- Updated BACKEND-FEATURE-PARITY-PLAN.md with batch 5 status
Version bump: 0.71.26 -> 0.71.28
Resolves merge conflicts between Batch 4 (YouTube URL input) and Batch 3
(existing instrumental) which was merged while this branch was in progress.
Combined changes:
- Both Batch 3 and Batch 4 are now marked complete in documentation
- Remote CLI now supports both URL input AND existing_instrumental parameter
- Tests include both existing instrumental tests and URL input tests
- Updated poetry.lock with yt-dlp dependency
Implements YouTube URL input (P2 parameter) for the remote CLI and backend:
- Remote CLI: Detect URL input via is_url(), route to new submit_job_from_url() method
- Backend: New /api/jobs/create-from-url endpoint accepts URL with optional artist/title
- Backend: Audio worker downloads from URL using yt-dlp, auto-detects artist/title from metadata
- FileHandler: Added download_video() and extract_metadata_from_url() methods
- Dependencies: Added yt-dlp to pyproject.toml
Features:
- URL detection in remote CLI positional arguments
- Auto-detection of artist/title from YouTube video metadata
- Support for YouTube, Vimeo, SoundCloud, and other yt-dlp supported platforms
- Metadata cleanup (removes common suffixes like "Official Video")
- Cookie support for authenticated downloads (YOUTUBE_COOKIES env var)
Tests: 20+ unit tests covering URL validation, request/response models, Job URL field
Add --existing_instrumental parameter to remote CLI to allow users to upload
and use their own pre-made instrumental file instead of AI-separated audio.
Key changes:
- remote_cli.py: Add existing_instrumental parameter to submit_job()
- file_upload.py: Add existing_instrumental file type with duration validation (±0.5s)
- job.py: Add existing_instrumental_gcs_path field to Job and JobCreate models
- video_worker.py: Download and use user-provided instrumental for final video encoding
Backend still runs AI separation for stems (to provide consistent download outputs),
but uses the user-provided instrumental for the final karaoke video.
Includes 20+ unit tests and maintains >70% coverage.
Add support for custom audio separation models in remote CLI:
- `--clean_instrumental_model`: Stage 1 separation model
- `--backing_vocals_models`: Backing vocals separation models
- `--other_stems_models`: Multi-stem separation models (bass, drums, etc.)
Implementation:
- Remote CLI: Added 3 form fields to submit_job(), sends models as comma-separated strings
- Backend: Added 3 Form parameters to /api/jobs/upload, parses comma-separated lists
- Job model: Added clean_instrumental_model, backing_vocals_models, other_stems_models fields
- Audio worker: create_audio_processor() accepts model params from job, passes to Modal API
This enables A/B testing different models and using newer models as they release.
Models are sent to the Modal-hosted audio-separator API which can download any model
on demand and caches them.
Resolves: Batch 2 from BACKEND-FEATURE-PARITY-PLAN.md
Update BACKEND-FEATURE-PARITY-PLAN.md:
- Mark Batch 1 (Lyrics Configuration) as complete with PR #8
- Update Quick Parity Summary (Lyrics: 100%)
- Mark L1-L4 parameters as ✅ implemented
- Add "Instructions for Implementing a Batch" section:
- Test coverage requirements (>70%)
- Required documentation updates checklist
- Version bump requirement
- PR format guidelines
- Update Next Steps to reflect current progress
- Add Recent Changes entry for v0.71.22
- Change verbose N-GRAM, ANCHOR SEARCH, and FILTERING logs from INFO to DEBUG level
- Keep only high-level summary logs at INFO (start, completion, totals)
- Fix duplicate logging by removing redundant logger handlers from hierarchy
- job_log_context no longer adds handlers to root logger
- LYRICS_WORKER_LOGGERS reduced to top-level package loggers only
- Bump version to 0.71.20
- Update CI to use poetry instead of pip with frozen requirements
- Upgrade CI from Python 3.12 to 3.13 (matches pyproject.toml and dev env)
- Simplify Dockerfile.base to use pip install -e . directly
- Remove requirements-frozen.txt (caused Python version mismatches)
- Update documentation to reflect simpler setup
- Bundle lyrics-transcriber directly via pyproject.toml packages directive
instead of PyPI dependency, allowing rapid iteration without publishing
- Add all lyrics-transcriber dependencies to karaoke-gen's deps
- Optimize Docker builds: base image now contains only dependencies (no code),
app image adds code on top for fast ~1-2 min rebuilds
- Generate requirements-frozen.txt from poetry.lock for reproducible builds
- Update CI to use frozen requirements
- Add comprehensive documentation in docs/01-reference/VENDORED-LYRICS-TRANSCRIBER.md
with un-vendoring instructions for when changes are pushed upstream
This marks the first successful end-to-end run of karaoke-gen-remote with
the Google Cloud backend. All core features are now working:
- README.md completely rewritten with comprehensive documentation:
- Both CLI tools (karaoke-gen, karaoke-gen-remote) fully documented
- API reference for backend endpoints
- Infrastructure deployment guide with Pulumi
- Style configuration examples
- Output file structure
- BACKEND-FEATURE-PARITY-PLAN.md updated to reflect:
- All core processing features complete
- All distribution features working (YouTube, Dropbox, GDrive, Discord)
- Future architecture plans for shared pipeline refactor
- Comprehensive testing/deployment sections
- Job model enhanced with request_metadata field for operational tracking
- Device auth endpoints now read client_id/client_secret from Secret Manager
- New secrets: youtube-client-credentials, gdrive-client-credentials
- Passing credentials in request body is now optional (for backwards compat)
- Simpler API: just POST to /api/auth/youtube/device with empty body
- Updated documentation
Version bump to 0.70.26
Implements comprehensive OAuth credential management for the backend:
1. CredentialManager service:
- Validates YouTube, Google Drive, and Dropbox credentials
- Automatically refreshes expired tokens
- Device Authorization Flow for re-authentication
- Discord alerts when credentials need attention
2. API endpoints (/api/auth/*):
- GET /status - Check all credential statuses
- POST /validate - Validate specific services before job submission
- POST /youtube/device - Start YouTube device auth flow
- GET /youtube/device/{code} - Poll for auth completion
- Similar endpoints for Google Drive
3. Pre-job validation:
- Jobs requiring YouTube/Dropbox/GDrive are rejected if credentials invalid
- Clear error messages with auth_url for re-authorization
4. Startup validation:
- Validates all credentials on backend startup
- Sends Discord alert if any credentials need attention
5. Documentation:
- docs/00-current-plan/OAUTH-CREDENTIAL-MANAGEMENT.md
- Covers credential setup, device flow, troubleshooting
Version bump to 0.70.24
Phase 1: Native API Distribution Services
- Add dropbox_service.py with native Dropbox SDK for folder listing, upload, and sharing links
- Add gdrive_service.py with native Google Drive API for folder uploads and public share
- Add dropbox_path and gdrive_folder_id fields to Job model and JobCreate
- Update file_upload.py API to accept new distribution parameters
- Update video_worker.py to use native services for distribution
- Add --dropbox_path and --gdrive_folder_id CLI arguments to remote CLI
- Add dropbox>=11.0.0 dependency to backend requirements
Phase 2: Shared Pipeline Architecture
- Create karaoke_gen/pipeline/ module with base classes and context
- Implement PipelineStage protocol and StageResult for consistent stage execution
- Add PipelineContext dataclass for passing state through stages
- Create SeparationStage wrapping AudioProcessor
- Create TranscriptionStage wrapping LyricsProcessor
- Create ScreensStage for title/end screen generation
- Create RenderStage for video rendering with lyrics
- Create FinalizeStage wrapping KaraokeFinalise
- Add LocalExecutor for in-process stage execution
- Add RemoteExecutor for backend API stage execution
This enables:
- Remote CLI to use native Dropbox/GDrive APIs instead of rclone
- Same output locations and brand codes as local CLI
- Foundation for unified pipeline that works in both local and cloud contexts
- Added detailed specification for all 5 distribution features
- Clarified that remote mode uses APIs directly (not local filesystem)
- Updated implementation status to reflect reality
- Added target remote CLI alias showing final command
- Added testing checklist for verifying true parity
- Documented required secrets and their formats
Key insight: Same outputs must appear in same cloud locations
regardless of whether using karaoke-gen or karaoke-gen-remote
Phase 1 of Backend Feature Parity Plan:
Dropbox Upload (rclone):
- Add organised_dir_rclone_root field to Job model
- Create backend/services/rclone_service.py to load rclone.conf from Secret Manager
- Wire through from API to video_worker and KaraokeFinalise
YouTube Upload:
- Create backend/services/youtube_service.py for OAuth credential management
- Load credentials from Secret Manager (youtube-oauth-credentials secret)
- Add --enable_youtube_upload flag to CLI
- Update video_worker to pass credentials to KaraokeFinalise
Other changes:
- Update remote_cli.py to support new distribution parameters
- Update BACKEND-FEATURE-PARITY-PLAN.md with implementation status
- Bump version to 0.70.12
Cloud Build stores logs in a GCS bucket ({PROJECT_NUMBER}.cloudbuild-logs.googleusercontent.com).
The existing roles/cloudbuild.builds.editor role doesn't include storage read access to this bucket,
causing CI to fail to display build failure details.
- Add BucketIAMMember in Pulumi to grant roles/storage.objectViewer on the Cloud Build logs bucket
- Minor doc tweak to clarify "same outputs" principle
- Bump version to 0.70.9
- Create BACKEND-FEATURE-PARITY-PLAN.md with:
- Vision for unified karaoke-gen ecosystem (local CLI, remote CLI, web UI)
- Detailed implementation plan for YouTube upload, Dropbox sync, email draft
- Phase-based approach prioritizing distribution features
- Important files reference for new agents
- Shared pipeline architecture vision for future refactoring
- Archive CLI-FEATURE-PARITY.md with redirect to new document
- Bump version to 0.70.8
This commit implements the complete human review workflow for lyrics
correction, integrating the LyricsTranscriber React frontend with the
cloud backend.
Key changes:
- Add review.py router with endpoints compatible with LyricsTranscriber UI
- Add render_video_worker.py for post-review video generation
- Add RENDERING_VIDEO status and update state transitions
- Add fail_job() method to JobManager for proper error handling
- Fix lyrics_worker to upload corrections.json with correct filename
- Fix screens_worker to transition to AWAITING_REVIEW (not instrumental)
- Add storage_service methods: upload_json(), download_json()
The complete workflow now works:
1. Upload → parallel audio separation + lyrics transcription
2. Screen generation (title/end)
3. Human review via LyricsTranscriber UI (localhost:5173)
4. Preview video generation during review
5. Post-review video render with corrected lyrics
6. Instrumental selection (clean vs with_backing)
7. Final video encoding (4 formats: lossless mp4/mkv, lossy mp4, 720p)
8. Job completion
Tested end-to-end with local GCP emulators.
Changes:
- Add backend dependencies to root pyproject.toml
- Configure pytest to discover tests from tests/, backend/tests/
- Skip emulator/integration tests when services not available
- Add run-backend-local.sh for local development
- Add comprehensive TESTING-GUIDE.md documentation
Now you can:
- pytest # Run all 379 tests from repo root
- ./scripts/run-backend-local.sh # Run backend locally
Emulator tests auto-skip unless emulators are running.
Integration tests require RUN_INTEGRATION_TESTS=true.
Created detailed plan for actually implementing karaoke generation:
📋 Analysis:
- Reviewed karaoke_gen CLI workflow documentation
- Identified that karaoke_gen ALREADY calls remote APIs (Modal, AudioShake)
- Workers don't need to refactor karaoke_gen - just call same APIs
✅ Implementation Strategy:
Phase 1: Audio Worker - Call Modal API directly for stem separation
Phase 2: Lyrics Worker - Use AudioShake + lyrics_transcriber library
Phase 3: Human Interaction - Corrections submission + instrumental selection
Phase 4: Screens Worker - Generate title/end screens
Phase 5: Video Worker - Final video assembly and encoding
Phase 6: Optional - CDG/TXT generation
🔑 Key Insights:
- lyrics_transcriber is already available in lyrics_transcriber_local/
- Modal API can be called directly (no need for AudioProcessor class)
- AudioShake API can be called directly
- Video encoding fits within Cloud Run timeout (60 min)
- FFmpeg can be included in Docker image
Next: Implement audio worker with actual Modal API integration
✅ Features:
- Auto-deploy to Cloud Run after all tests pass
- Only deploys on push to replace-modal-with-google-cloud branch (not PRs)
- Builds Docker image with commit SHA tags for easy rollback
- Verifies deployment health automatically
- ~7 min total time from push to live
📚 Documentation:
- Comprehensive CD setup guide (docs/03-deployment/CD-SETUP.md)
- Automated setup script (scripts/setup-cd.sh)
- Updated GitHub Actions README with CD info
- Deployment status tracking document
🔐 Security:
- Uses GCP service account with minimal necessary permissions
- Requires GitHub secrets: GCP_SA_KEY, ADMIN_TOKENS
- Setup script creates service account and generates key
- Documentation includes security best practices
📋 Next Steps:
1. Run ./scripts/setup-cd.sh to create service account
2. Add GCP_SA_KEY and ADMIN_TOKENS to GitHub secrets
3. Push to branch → automatic deployment!
This completes the CI/CD pipeline:
- CI: 73 automated tests (unit + integration)
- CD: Automatic deployment on test success
- Add Pulumi infrastructure definition for all GCP resources
- Implement Docker build with layer caching via Cloud Build
- Fix Artifact Registry permissions for Cloud Build service accounts
- Remove deprecated manual setup scripts and docs
- Add comprehensive documentation:
- Infrastructure as Code migration guide
- Cloud Build permissions troubleshooting
- Next steps for Cloud Run deployment
- Session summary and cleanup verification
All GCP resources now managed in code:
- Firestore, Cloud Storage, Artifact Registry
- Service Account with IAM bindings
- Secret Manager secrets
- Cloud Build permissions
Resolves permission issues and establishes single source of truth for infrastructure.