feat(pipeline): render queue, worker service and automated preview generation

One "Queue Export" click now renders the EXR sequence, then rebuilds the shot
headlessly with the studio slate/overlay template to produce the delivery MOV
and review MP4. Implements RenderPipeline2 phases 1-2 plus the preview stage.

Server:
- New models Export, RenderJob, ExportEvent, Machine, WorkerHeartbeat, plus
  Project.deliveryConfig and per-submission slate fields (Export.vfxScope,
  Export.submissionNote, inherited from the shot's previous export).
  Both migrations are purely additive; no existing column is touched.
- lib/render-pipeline: server-enforced state machine, transactional version
  increment with supersede, atomic FOR UPDATE SKIP LOCKED claim gated by
  machine availability windows, and a lease reaper run from instrumentation.ts.
- /api/ext/* endpoints for the panel and workers; session-auth mirrors under
  /api/render and /api/machines for the web UI.
- Pipeline pages: render queue, export detail, machine monitoring, plus an
  Exports tab on shot detail.

RenderWorker (.NET 8 Windows service, new):
- Registration, heartbeat as cancel channel, claim loop, aerender runner with
  progress parsing and stall watchdog, crash recovery and disk-spooled
  reporting that survives server downtime.
- Preview stage: headless AE assembles the preview comp into a throwaway AEP
  with both output modules queued, then a single aerender pass renders them.
  Preview jobs are not claimed while an interactive AE session is open, so an
  artist's project is never taken over.

AE panel: Queue Export with live status polling, urgent flag, retry, and the
VFX Scope / Submission Note fields. Every existing panel action is unchanged.

Preview chaining ships disabled behind SystemConfig preview.enabled.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
twotalesanimation
2026-08-02 14:34:34 +02:00
parent 0d0f3e1a33
commit ae58dc0366
71 changed files with 11767 additions and 1 deletions
@@ -0,0 +1,21 @@
import { NextRequest, NextResponse } from "next/server";
import { toErrorResponse } from "@/lib/render-pipeline/errors";
import { requirePipelineUser } from "@/lib/render-pipeline/session-auth";
import { cancelExport } from "@/lib/render-pipeline/exports";
// ── POST /api/render/exports/{exportId}/cancel (E15 / T18) ───────────────────
export async function POST(
_req: NextRequest,
{ params }: { params: Promise<{ exportId: string }> }
) {
try {
const user = await requirePipelineUser();
const { exportId } = await params;
const result = await cancelExport(exportId, { type: "USER", id: user.id, note: "Cancelled from web UI" });
return NextResponse.json(result);
} catch (err) {
const { body, status } = toErrorResponse(err);
return NextResponse.json(body, { status });
}
}
@@ -0,0 +1,31 @@
import { NextRequest, NextResponse } from "next/server";
import { toErrorResponse } from "@/lib/render-pipeline/errors";
import { requirePipelineAdmin } from "@/lib/render-pipeline/session-auth";
import { markExportDoneManually } from "@/lib/render-pipeline/exports";
// ── POST /api/render/exports/{exportId}/mark-done ────────────────────────────
//
// Phase 1 stopgap (§17.1): lets the studio keep using the old manual render
// path while the queue is validated. Remove once workers render for real.
export async function POST(
req: NextRequest,
{ params }: { params: Promise<{ exportId: string }> }
) {
try {
const user = await requirePipelineAdmin();
const { exportId } = await params;
let note: string | undefined;
try {
const body = await req.json();
if (typeof body?.note === "string") note = body.note;
} catch {
// empty body is fine
}
const result = await markExportDoneManually(exportId, user.id, note);
return NextResponse.json(result);
} catch (err) {
const { body, status } = toErrorResponse(err);
return NextResponse.json(body, { status });
}
}
@@ -0,0 +1,21 @@
import { NextRequest, NextResponse } from "next/server";
import { toErrorResponse } from "@/lib/render-pipeline/errors";
import { requirePipelineUser } from "@/lib/render-pipeline/session-auth";
import { retryExport } from "@/lib/render-pipeline/exports";
// ── POST /api/render/exports/{exportId}/retry (E15) ──────────────────────────
export async function POST(
_req: NextRequest,
{ params }: { params: Promise<{ exportId: string }> }
) {
try {
const user = await requirePipelineUser();
const { exportId } = await params;
const result = await retryExport(exportId, { type: "USER", id: user.id, note: "Retry from web UI" });
return NextResponse.json(result);
} catch (err) {
const { body, status } = toErrorResponse(err);
return NextResponse.json(body, { status });
}
}
@@ -0,0 +1,23 @@
import { NextRequest, NextResponse } from "next/server";
import { toErrorResponse } from "@/lib/render-pipeline/errors";
import { requirePipelineUser } from "@/lib/render-pipeline/session-auth";
import { getExportDetail } from "@/lib/render-pipeline/exports";
// ── GET /api/render/exports/{exportId} ───────────────────────────────────────
//
// Export detail for the web Export page (internal mirror of E3).
export async function GET(
_req: NextRequest,
{ params }: { params: Promise<{ exportId: string }> }
) {
try {
await requirePipelineUser();
const { exportId } = await params;
const result = await getExportDetail(exportId);
return NextResponse.json(result);
} catch (err) {
const { body, status } = toErrorResponse(err);
return NextResponse.json(body, { status });
}
}