feat: remix worker engine (t0.5) — RemixJob orchestration + claim/report/upload#19
Open
mtmtian wants to merge 3 commits into
Open
feat: remix worker engine (t0.5) — RemixJob orchestration + claim/report/upload#19mtmtian wants to merge 3 commits into
mtmtian wants to merge 3 commits into
Conversation
Add an independent worker-engine RemixJob path alongside the existing
Seedance2-direct remix: control plane creates a pending RemixJob + brief via
POST /api/creatives/remix-jobs, an external HMAC-authenticated worker claims
it, generates beats, assembles/QCs the clip, and reports progress/results
back via /api/worker/remix-jobs/{claim,report,upload}. Purely additive —
reuses buildRemixBrief/competitorCreativeToAnalysis from remix-brief.ts
without touching any existing files.
…n upload Close the code-review gaps on the worker-facing RemixJob surface: report/ now enforces an atomic ALLOWED_PREV transition table (succeeded/failed are terminal), validates outputUrl against the canonical GCS upload path, and surfaces brand-QC failures via Creative.reviewNotes instead of silently promoting. upload/ pre-checks HMAC headers and content-length before buffering the body. claim/ recycles stale in-flight jobs after a configurable lease window and collapses the duplicated jobId/queue branches into one atomic updateMany. De-dupes asJson + canvas-dims math into src/lib/growth/remix-job.ts, and shares the e2e HMAC-signing helper between remix-jobs.spec.ts and competitor-ingest.spec.ts.
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.
What
Adds a second, worker-driven remix engine alongside the existing in-app single-shot text2video path (which is untouched). This phase ships tier t0.5 only: per-beat text-described regeneration — the storyboard from
buildRemixBriefis generated beat-by-beat by an external worker (Cloud Run Job, separate repo), assembled with ffmpeg, brand-QC re-scanned (whisper + OCR), and lands as the same review-gatedCreative(source:'remix', reviewStatus:'pending'). Competitor material stays analysis-only — no competitor pixels enter generation, consistent with the "borrow structure, not pixels" rules inremix-brief.ts/competitor-media.ts.RemixJobmodel + migration: brief snapshot, per-beat progress,qcReport,costTokens;tier/segmentPlanfields reserved for later tiers (API rejects anything butt0_5for now).POST/GET /api/creatives/remix-jobs(session auth): reusesbuildRemixBrief/competitorCreativeToAnalysis; shares the existing remix burst + daily-cap guardrails./api/worker/remix-jobs/*(HMAC viaingest-auth.verifyHmac, newWORKER_WEBHOOK_SECRET):claim— atomic pickup (updateManycount check) withREMIX_JOB_LEASE_MINUTESstale-lease recyclingreport— atomic status state machine (pending→claimed→running→assembling→qc→succeeded/failed, terminal states locked, 409 on illegal transitions);outputUrlmust match the canonical upload path; QC-fail is surfaced to reviewers viaCreative.reviewNotes(promotion not blocked — reviewer decides)upload— raw mp4 → GCS via server-sideuploadToGCS(content-sha256-bound HMAC, pre-buffer header checks, 100MB cap)Design notes
storage.tsgains one additive export (gcsPublicPrefix)./creatives/reviewgate; remix history keeps working viaCreative(source:'remix').Test plan
npm run lint/npx tsc --noEmitclean; migration verified against schema withprisma migrate diff(no drift).e2e/remix-jobs.spec.ts: 15 passed — happy path (ingest → job → claim → running/assembling/qc → succeeded promotes Creative to ready), claim atomicity, HMAC rejection, terminal-state 409, unclaimed→succeeded 409, non-canonical outputUrl 400, QC-fail reviewNotes.Context: this is the first slice of the tier-ladder proposal (t0 = your existing path / t0.5 = this PR / t1 & t2 gated pending the policy question in the alignment doc we shared). Happy to adjust
RemixJobmodeling orStoryboardBeatintegration to your preference.🤖 Generated with Claude Code