feat(generations): add worker claim and status endpoint#46
Open
Abdulmuiz44 wants to merge 18 commits into
Open
feat(generations): add worker claim and status endpoint#46Abdulmuiz44 wants to merge 18 commits into
Abdulmuiz44 wants to merge 18 commits into
Conversation
Add machine-readable API spec
Improve asset rerender logging
Improve billing failure logging
Codex/api openapi spec
Implement billing verification state
Day 12 / PR 2 of async migration foundation: - generation status contract and public response mapper - conditional worker claim helper (queued -> analyzing) - GET /api/v1/projects/[projectId]/generations/[generationId] - unit tests for claim, status mapping, and project scoping No async execution, queue, or 202 response changes.
Day 13 / PR 3 of async migration: POST /generate returns 202 Accepted with generationId, queued status, and poll URL. Durable enqueue via generations row + usage_events audit trail. No worker execution yet.
Create async submissions as draft, consume credit, then promote to queued and mark the project queued before enqueue returns 202. Prevents workers from claiming unpaid generations and keeps project list status aligned with accepted jobs.
feat(generations): enqueue generation requests
Keep split generation runner modules and integrate main logging. Fix docs typed-route links and align generate API docs with 202 enqueue.
Addresses Codex P1 on PR #48: async 202 acceptance no longer ships without a runtime processor. v1 POST runs runGenerationForProject (201) by default; LAUNCHPIX_ASYNC_GENERATION enables 202 enqueue with claim-based worker via POST /api/internal/worker/generations/process or inline when configured.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Day 12 / PR 2 of the async generation migration plan.
Adds safe primitives for a future async worker without changing generation execution behavior.
What changed
Worker claim helper (
lib/services/generations/claim.ts)claimGenerationForProcessing({ supabase, generationId, workerId? })status = "queued"analyzingon success{ claimed: true, generation }or{ claimed: false, reason }not_found,terminal,in_progress,not_claimableGeneration status contract (
lib/services/generations/status.ts)draft,queued,analyzing,generating_copy,rendering_assets,completed,failedisTerminalGenerationStatus,isClaimableGenerationStatus,getGenerationPhasemapGenerationToPublicStatusai_summary,copy_json, or rawstyle_jsonGET by generation id
GET /api/v1/projects/[projectId]/generations/[generationId]x-launchpix-api-key,x-launchpix-user-id)projectId + generationIdstatus,phase,assets,downloadUrl,errorQuery helper
getGenerationForProject(projectId, generationId)inqueries.tsIntentionally not included
202 Acceptedon POST /generaterunGenerationForProjectbehaviorGET /api/v1/projects/[projectId]/generate(latest generation) unchangedValidation
npm run typechecknpm run buildnpm testNext step
Day 13: POST returns
202+ enqueue. Day 14: worker executes using Day 11 modules + Day 12 claim/status contract.