You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Work order: integrate the Cupcake Render Gateway (shared queue) into Directors Desktop
Supersedes the direct-ComfyUI mode of #86 (that plumbing knowledge stays valid for benchmarks/emergencies). Robert's requirement: DD and Directors Palette both generate video on cupcake through ONE queue both apps can see, fully integrated and tested.
DD-specific scope: the 'Directors Desktop' section + test battery below. The gateway itself is built on cupcake (repo of record there: ~/machine-king-ai-os/docs/render-gateway-spec.md).
Goal: Directors Palette (web) AND Directors Desktop (Electron) generate video on cupcake,
through ONE shared queue that both apps can see, fully integrated in each app's native UI.
This document is the source of truth. Per-app work orders: Directors-Desktop issue (gateway
integration; supersedes the direct-mode parts of #86) and directors-palette-v2 issue.
One global FIFO-with-priorities queue; GPU work serialized (one render at a time).
State = filesystem (/srv/ai/gateway/jobs/{queued,running,done}/<job_id>.json + artifacts
pointer into /srv/ai/outputs/comfy/). No database. Survives restart by re-scanning dirs.
Worker drives ComfyUI with the PROVEN graphs — port them from DD's ltx_comfy_client_impl._build_graph / h3_local_client_impl._build_graph verbatim
(they embed every paid-for fix). Reference images arrive via upload, staged into ComfyUI input.
API
Route
Purpose
GET /
agents.md — the gateway teaches its callers (hub law)
GET /v1/health
engines, warmth (hot/cold per engine), queue depth, disk level (reads /srv/ai/logs/disk-status.json)
POST /v1/video
submit → {job_id, position, eta_s}
POST /v1/uploads
reference image → {upload_id} (used in submit)
GET /v1/jobs
the shared queue view — tenant sees own jobs in full + others as {position, engine, eta_s, tenant_label} (no prompts leaked across tenants)
ETAs: seed the table from measured benchmarks (LTX 480p: 52/93/153s for 5/10/15s; H3 480p:
~300/760s; 720p from the matrix battery), then learn: rolling per-(engine,tier,seconds-bucket)
average of actual walls, warm/cold buckets — DD's model-timing v2 pattern, server-side. Engine routing default when engine omitted: reference image present → h3; else ltx.
Queue visibility (the requirement both apps share)
GET /v1/jobs returns for every queued/running job: position, engine, eta_s, tenant_label ("Desktop", "Palette", "Robert"), and is_yours. Both apps poll (2–5s) or
consume GET /v1/events (SSE, nice-to-have v1.1). A Palette user SEES "2 jobs ahead (Desktop)";
a DD user SEES "1 ahead (Palette)". Prompts/thumbnails never cross tenants.
When on: gpu-slot jobs (ltx-comfy, h3-local) submit to the gateway instead of local
ComfyUI; job model/params map 1:1; result downloaded into outputs_dir → Gallery unchanged.
Queue strip + Playground queue show gateway position/eta and foreign-job count chips.
Warmth pill: "cupcake · N in queue". Cancel maps to DELETE. Local 4090 path remains the
fallback when the field is Off (or gateway unreachable → offer local).
New provider in the video provider abstraction: cupcake (server-side route, mirrors the
fal/replicate provider shape). Env: CUPCAKE_GATEWAY_URL (tunnel hostname) + CUPCAKE_GATEWAY_KEY (tenant palette) + Cloudflare Access service token headers.
Points: deduct server-side BEFORE submit (existing points law); price cupcake renders at
a nominal internal rate (e.g. 1–3 pts) or 0 for Robert's account — decision flagged to Robert.
Shot Creator / Playground video calls gain "Render on cupcake" model option; job status UI
shows queue position; result ingested like any provider output.
Cloud→home path: cloudflared tunnel on cupcake exposing ONLY :8700 as render.machinekinglabs.com, Cloudflare Access service-token policy (Palette's server is
the only allowed caller). No router ports. LAN browser sessions may hit the LAN URL directly.
Non-goals v1
Parallel rendering (memory allows it; queue-level change later) · image/LLM routes (video
only; the API is shaped so /v1/image can join) · public self-serve signup · billing.
Test battery ("fully integrated and tested" = this list green)
Gateway: unit (queue order, priorities, tenancy filter, idempotency, cancel-in-queue,
cancel-running, restart-rescan) + live (one LTX + one H3 render end-to-end, ref upload → h3
identity output exists).
DD: suites green (pytest/vitest/pyright/tsc) + live: submit from Playground with gateway on →
mp4 in Gallery; queue strip shows a foreign job injected via curl; cancel works; gateway
unreachable → clean fallback offer.
Palette: provider unit tests + live: points deducted → job visible with position → mp4 lands
in gallery; Access-token rejected without header (verify from outside the tunnel).
Cross-app: submit from BOTH apps simultaneously → both see each other's position; order honored.
Rollout order
Gateway v1 on cupcake (localhost + LAN) + local tenant → agents/scripts can use it day one.
Work order: integrate the Cupcake Render Gateway (shared queue) into Directors Desktop
Supersedes the direct-ComfyUI mode of #86 (that plumbing knowledge stays valid for benchmarks/emergencies). Robert's requirement: DD and Directors Palette both generate video on cupcake through ONE queue both apps can see, fully integrated and tested.
DD-specific scope: the 'Directors Desktop' section + test battery below. The gateway itself is built on cupcake (repo of record there: ~/machine-king-ai-os/docs/render-gateway-spec.md).
Cupcake Render Gateway — canonical spec (v1, 2026-08-07)
Goal: Directors Palette (web) AND Directors Desktop (Electron) generate video on cupcake,
through ONE shared queue that both apps can see, fully integrated in each app's native UI.
This document is the source of truth. Per-app work orders: Directors-Desktop issue (gateway
integration; supersedes the direct-mode parts of #86) and directors-palette-v2 issue.
Shape (follows the proven dramatis-hub pattern: zero-dep node, filesystem state, key tenancy)
/srv/ai/gateway/jobs/{queued,running,done}/<job_id>.json+ artifactspointer into
/srv/ai/outputs/comfy/). No database. Survives restart by re-scanning dirs.Authorization: Bearer <key>→ sha256 → tenant inkeys.json(tenants:
dd,palette,local; localhost-no-key =local, the hub law).ltx_comfy_client_impl._build_graph/h3_local_client_impl._build_graphverbatim(they embed every paid-for fix). Reference images arrive via upload, staged into ComfyUI input.
API
GET /GET /v1/health/srv/ai/logs/disk-status.json)POST /v1/video{job_id, position, eta_s}POST /v1/uploads{upload_id}(used in submit)GET /v1/jobs{position, engine, eta_s, tenant_label}(no prompts leaked across tenants)GET /v1/jobs/:idqueued(position) / running(phase,pct) / done(result_url) / error(msg)GET /v1/jobs/:id/resultDELETE /v1/jobs/:id/interruptif running; own-tenant only)POST /v1/videobody:{ "engine": "ltx" | "h3", // callers may omit → routed by rule below "prompt": "...", "negative_prompt": "...", "width": 832, "height": 480, // /32 (LTX) or proven H3 tiers "seconds": 10, "seed": 123, // seed omitted → random (frozen-seed lesson) "reference_upload_id": "...", // optional → LTX first-frame / H3 omni-ref "lora": {"name": "...", "strength": 1.0}, // LTX only, v1 "priority": "interactive" | "batch", // interactive jumps batch, never preempts running "idempotency_key": "..." // resubmit-safe }ETAs: seed the table from measured benchmarks (LTX 480p: 52/93/153s for 5/10/15s; H3 480p:
~300/760s; 720p from the matrix battery), then learn: rolling per-(engine,tier,seconds-bucket)
average of actual walls, warm/cold buckets — DD's model-timing v2 pattern, server-side.
Engine routing default when
engineomitted: reference image present →h3; elseltx.Queue visibility (the requirement both apps share)
GET /v1/jobsreturns for every queued/running job:position,engine,eta_s,tenant_label("Desktop", "Palette", "Robert"), andis_yours. Both apps poll (2–5s) orconsume
GET /v1/events(SSE, nice-to-have v1.1). A Palette user SEES "2 jobs ahead (Desktop)";a DD user SEES "1 ahead (Palette)". Prompts/thumbnails never cross tenants.
Per-app integration
Directors Desktop (owner: DD repo issue)
Render node= Off /Gateway URL(defaulthttp://192.168.1.249:8700).ltx-comfy,h3-local) submit to the gateway instead of localComfyUI; job model/params map 1:1; result downloaded into
outputs_dir→ Gallery unchanged.position/etaand foreign-job count chips.fallback when the field is Off (or gateway unreachable → offer local).
emergencies/benchmarks).
Directors Palette v2 (owner: palette repo issue)
cupcake(server-side route, mirrors thefal/replicate provider shape). Env:
CUPCAKE_GATEWAY_URL(tunnel hostname) +CUPCAKE_GATEWAY_KEY(tenantpalette) + Cloudflare Access service token headers.a nominal internal rate (e.g. 1–3 pts) or 0 for Robert's account — decision flagged to Robert.
shows queue position; result ingested like any provider output.
cloudflaredtunnel on cupcake exposing ONLY :8700 asrender.machinekinglabs.com, Cloudflare Access service-token policy (Palette's server isthe only allowed caller). No router ports. LAN browser sessions may hit the LAN URL directly.
Non-goals v1
Parallel rendering (memory allows it; queue-level change later) · image/LLM routes (video
only; the API is shaped so
/v1/imagecan join) · public self-serve signup · billing.Test battery ("fully integrated and tested" = this list green)
Gateway: unit (queue order, priorities, tenancy filter, idempotency, cancel-in-queue,
cancel-running, restart-rescan) + live (one LTX + one H3 render end-to-end, ref upload → h3
identity output exists).
DD: suites green (pytest/vitest/pyright/tsc) + live: submit from Playground with gateway on →
mp4 in Gallery; queue strip shows a foreign job injected via curl; cancel works; gateway
unreachable → clean fallback offer.
Palette: provider unit tests + live: points deducted → job visible with position → mp4 lands
in gallery; Access-token rejected without header (verify from outside the tunnel).
Cross-app: submit from BOTH apps simultaneously → both see each other's position; order honored.
Rollout order
localtenant → agents/scripts can use it day one.