Engineering · the architecture
From a written script to a finished film, checked at every step.
Optra Studio turns a script into an animated film on our own GPUs: Qwen boards every shot, the farm draws and animates them, the rules held in code decide what may reach a GPU, nothing waits for a person before a picture or a clip is drawn, and the movie is cut first and then goes to a person's review, shot by shot. This page is built from the code. Every part below names the file that does it, and every number was counted from that code on 4 November 2026 (commit 582162496d).
studio/kit.pyTwo programs that never share a process
The studio is a web server and a farm. The web server is a Node service (studio/app/: Express 5 on
MySQL, its tables made by 203 numbered migrations in studio/schema/). It listens on loopback only, behind nginx and
TLS, as its own service (studio_deploy.py). The farm is the live checkout of the code on our Windows machine:
the scheduler (farm_run.py), the engine (studio/kit.py, started as studiokit.py) and the feed (studio_push.py).
The page never calls the farm. A press on the page is only recorded: studio/app/src/actions.js stores it, and the
feed collects it, carries it out with the farm's own commands and answers. The feed also posts each project's
progress, which studio/app/src/ingest.js makes the truth in one transaction. So the web server needs no way into the farm. Stills,
clips and cuts go to a media store; a customer's files are never at a public address, and the page reaches them only
through an address studio/app/src/mediasign.js has signed.
Work is pulled, not pushed. A stage puts what a project owes into the web server's pull door
(studio/app/src/pull.js) as jobs, each named by its content, so the same job is one job however often it is asked for: the clips
(studio/pullrun.py), the stills, the voices and the segment encodes of a cut (studio/cutpull.py) go this way, and so do upscales. A worker
(farm_pull/worker.py) on a card claims a job of a kind it takes, draws it on its own box and reports it done. The worker dials out
to the door, so nothing reaches into the card's machine. At 10:32 UTC on 4 November 2026 the door's worker list showed
14 cards with a live worker claiming work (read then, so it is as old as that time:
a card joins when its worker starts), and farm_pull/leaserule.py keeps such a card out of the scheduler's push plan. A door that does
not answer is said, and the stage falls back to the leased cards, so a pull that cannot start never stops the work.
The text model is reached through a gateway. Every call to the Qwen goes through optra_llm.py to the
gateway (portal/gateway.py) with a key, over our private network, never a public address. The gateway holds ONE SSH link to
the Qwen box (tools/hosts/boxlink.py) and dials it again only when it breaks, so a call never opens a connection of its own.
- A person → The page: presses
- The page → The API: requests
- The feed → The API: polls the presses GET /api/farm/actions
- The feed → The API: posts progress POST /api/farm/ingest
- The feed → The API: posts usage rows POST /api/farm/usage
- The feed → The studio's steps: apply_actions: a redo or a pick goes through the pipeline type's hook (names: farm_pipelines/hooks.py)
- The feed → The queue: apply_actions: a queue press
- The studio's steps → The scheduler: the next steps for each project
- The scheduler ↔ farm.db: reads and writes
- The watchdog → farm.db: checks every 15 s (a dotted line)
- The scheduler → The engine's stages: launch(step) studiokit.py --project p stage
- The engine's stages → The pull door: the work owed, as jobs: clips, stills, voices, a cut's encodes (with no door answering, the leased cards instead) studio/pullrun.py
- Pull workers → The pull door: claims, draws, reports done: the worker dials out, nothing dials in
- The scheduler → Pull workers: a card with a live worker leaves the push plan farm_pull/leaserule.py (a dotted line)
- The text model → The gateway: over the tailnet
- The gateway → The Qwen box: one held SSH link per box tools/hosts/boxlink.py
- The rules and a person's Wrong → The picture reader: reads a picture against a person's Wrong
- The rules and a person's Wrong → The text model: rewrites a shot a person marked wrong
- The engine's stages → The project folder: writes the files
- The project folder → The feed: media() lists them
- The feed → The media store (the NAS): copies them, posts POST /api/farm/media
- The media store (the NAS) → The media door: signed address
- The media door → The page: the page draws it
A project's path, script to finished film
The farm runs a project's steps in this order. farm_pipelines/studio.py decides which step is next for each project, and the
engine does the work. One engine and that one module drive every project; nothing is written per project.
- The script. It arrives in the studio's scene format, and
studio/scriptmd.pyreads it back into its scenes and lines.studio/analyse.pybreaks it down on Qwen into every character, place, prop, scene and spoken line, held to the script word for word. - The scene plan. In
studio/scene.py, Qwen plans each scene under rules Claude writes: its coverage, a continuity ledger per shot, and the beats it must show. - The board.
studio/board.pywrites every shot from the plan, on Qwen. Claude writes the rules, never the shots. - The review.
studio/rules.pyholds every reason a shot must not reach a GPU that the text alone can show. - The rewrite, then STUCK. Where QA is the approval, a shot that fails is rewritten with its reasons: code
fixers first, then Qwen, at most 3 times, and last, Claude rewrites that one shot's words once
(
studio/clauderung.py; the call is the Claude Code command line, instudio/claude_write.py), checked by code before they are used. A shot that still fails waits on the page as STUCK: a problem for the code to fix, never a loop and never a hand edit. These are rules about words; no model reads a drawn picture or a clip to decide anything. - The approval to draw. The rules passing is the approval for what reaches a GPU (the studio's rule is "QA is
the approval"): when every shot passes, the farm records its own approval of exactly that board version and starts
drawing, with no person and no vision model before it. The approval is pinned, and
render_gate.pyrefuses any render it does not cover by exact name, before a GPU is spent on it. - Cast, places and voices. Character sheets, and place pictures where a project turns them on, are drawn
and screened first.
studio/voices.pyspeaks each character through the voice model the character's own data names: Chatterbox is the default and the others are Audar Turbo (Arabic and English) and Veena (Hindi and English) and Maya 2 Native (Indian languages). OmniVoice, which designs a voice from a sex and an age, speaks a child character's lines on a project that sets it, and 6 more voice models (for the Indian languages, and for Mandarin and Japanese) are built and not offered: each waits to be measured by ear before a project can name it. - Stills. Every shot is drawn from its references. No take is screened: the still screen went with the vision QA, and a person reviews the shots in the cut.
- Clips. A new project starts on MiniMax H3 image-to-video; the project can choose another at its
start (
studio/models.py). A shot with a spoken line is drawn lip-synced by Wan 2.2 S2V (lip sync). The clips go to the pull door and are drawn by the workers on the cards, or on the leased cards (comfy_farm.py) when no door answers; the graphs are instudio/graphs.py. MiniMax H3 has two file sets, FP8 (the card-sized files) and INT8 (the full ones), and a project draws all its clips on one of them (studio/plan.py; a new project starts on FP8), so no two clips of a film come from different versions. No frame is read: the 24 fps read went with the vision QA. A picture is read only against a person's Wrong, and for the customer content screen (studio/seeing.py). - The cut. One file: the picked clips, one mastered voice track and a subtitle file. The movie is cut first:
the cut is made as soon as every clip is made, and the review comes after. A project can set its cut gate to
"person", and then the cut waits until every shot is accepted and the reviewer presses Cut. The cut's sound is data:
studio/audiotimeline.pylists every cue (voice, narration, music, effects and ambience), each tied to a shot's edge so a re-timed shot moves its cues. Behind an owner-only setting, off by default, the cut lays its score through that timeline (studio/cutsound.py); voices, narration and beds are laid as before. A person's own sound edit (move, level or swap one cue) is read bystudio/audioedits.pyand laid by the next cut, with no video redrawn. A cut short of its length is owed story: new scenes are written once, andstudio/addstory.pyadds them by code to a script that stays exactly as it was. - Review. The finished movie goes to a person's review and is given to them shot by shot: a fault found there is a Wrong, which the engine carries out.
The rules decide what reaches a GPU; a person reviews the finished movie
The approval to draw is the farm's own. When a script and its board pass the rules held in code, the
farm pins that board version, and no job that approval does not cover by name is ever sent to a card. Nothing waits for
a person before a picture or a clip is drawn, and since 15 October 2026 no model reads a drawn picture or a clip to
decide anything: the general vision QA is gone. The person comes after the cut. The movie is cut first,
as soon as every clip is made, and a person reviews the finished movie and is given it shot by shot: the page shows each
shot as Accepted or Needs you (studio/app/public/app.js), and a fault found there is a Wrong, which the engine carries out. Who reviews a
project's shots is one setting with one reader, studio/reviewmode.py.
One setting can hold the cut for a person (studio/reviewcut.py; studio/kit.py, "Who releases the cut"): where a producer sets the cut
gate to "person", the cut is made only when every shot of the board has an accepted take that still holds (a shot with a
clip needs its clip accepted, since the clip is what the cut is made of) and a person pressed Cut after the last accept.
The default releases the cut with no accept and no Cut press, and the setting changes nothing else: no shot is rewritten,
redrawn or reopened because of it.
What the code checks is held in four places:
The contract
qa_contract.py lists what must be true of a finished film, for every
production the farm renders: 59 properties, each decided at one of 5 rungs (script, board, still, clip and cut). gatekit.py
builds one gate per rung, the same gate for every production.
One registry of checks
studio/checks.py decides whether each check blocks, and nothing else
does: 191 checks, each blocking or only reporting, and 4 more in the making. A check is measured against
a truth written by eye before it may block; the bar is 90% precision.
Derived means current
In derive.py, a derived file records what it was made from and is
rebuilt when that changes, because "it exists" was once read as "it is current". And in studio/item.py, one shot's fault is
said and held, and never stops the rest of its film.
What is never made
Two screens read a customer's work for what Optra Studio never
makes: studio/wordsafety.py reads the brief and the script before anything is built from them, and studio/safety.py reads every
picture.
The scheduler, and only the scheduler, starts work
farm_run.py starts every generation on the farm, and nothing else does: no stage is launched by hand, and no model is
loaded by hand. It serves farm_queue.py, every piece of production in the order the farm should serve it, and
farm_lease.py says which piece of work owns each generation card right now. Their state is one SQLite database that
every reader and writer goes through (farmdb.py). Every 15 seconds, farm_watchdog.py asks whether every GPU is being
used and whether the pipeline is actually moving. Every production type answers the page's 80 hooks
(farm_pipelines/hooks.py).
| Job | Model | Reached through |
|---|---|---|
| Boards and reviews | optra-coder (Qwen3.8-27B) | optra_llm.py, with a key, through the gateway (portal/gateway.py); at most 24 calls in flight across every process (optra_llm_slots.py) |
| A person's Wrong against its picture; the content screen | optra-coder (Qwen3.8-27B) | studio/seeing.py |
| Stills | FLUX.2 klein 9B for a new project; Qwen-Image 2.1 can be chosen | the pull door and a worker on the card, or ComfyUI on a leased card, studio/graphs.py |
| Clips | MiniMax H3 image-to-video for a new project; Wan 2.1 image-to-video, InfiniteTalk (every shot), LTX 2.5 image-to-video, LTX 2.5 (two passes), Wan 2.2 image-to-video and Wan 2.2 5B image-to-video can be chosen; Wan 2.2 S2V (lip sync) for a spoken line | the pull door and a worker on the card, or ComfyUI on a leased card, studio/graphs.py |
| Voices | the voice model each character's data names: Chatterbox by default, then Audar Turbo (Arabic and English) and Veena (Hindi and English) and Maya 2 Native (Indian languages) | studio/voices.py |
| The last rewrite of a STUCK shot's words | Claude | studio/claude_write.py, metered and logged |
Customers: the same engine, metered and capped
A customer's project runs on the same engine as ours, and QA is the approval for its shots. studio/app/src/usage.js keeps every
customer's GPU time and model calls by the unit; the farm reports quantities, never money. studio/app/src/plans.js is the one
plan table: 3 plans, each setting how many projects a customer runs at the same time (1, 5 or 20). A project
holds its place from the moment it is made until it is finished or deleted (studio/app/src/slots.js). A customer's own Claude, or any
client that speaks MCP, can connect to the studio's MCP server (studio/app/src/mcp.js), and can do exactly what that customer can do
on the page, never more (studio/app/src/mcptools.js).
How a change reaches the farm and the web server
Every change is made in its own worktree and handed over as READY, and one session, the deployer, ships it from a CI box, and ship.py catches that box's checkout up to origin before every ship. It
merges the branch onto
the newest main under one lock and runs the smoke (every changed file compiles, the modules the farm starts from
import, the source guards run) before the live checkout moves. deploy_guard.py refuses a deploy from any other session
but the main agent, the deployer's fallback, and 114 entry points ask it first. The main gate in promote.py is off by default, so a passing smoke moves main;
with it on, a change lands on staging and main moves only if no test that passed on main fails on it. After every
landing the farm reloads what changed, and tools/agents/sentinel.py runs the whole suite on the CI box and names the landing that
turned a test red.
- The car → The deployer: READY
- The smoke → The live tree: passes: fast-forward (the main gate is off today)
- The smoke → The live tree: main gate on, promote.py gate_on: the car lands on staging, and main moves only if no test that passed on main fails on it (a dotted line)
- The smoke → The car: refused: exact words go back
- The live tree → The live tree: the farm reloads what changed
- The live tree → The web release: when studio/app changed
- The whole suite → A developer's branch: a red names its landing
About this page
This page is written by tools/site/architecture_page.py from the code on main. Its two drawings are drawn from docs/optra-studio/architecture/data-flow.mmd and docs/optra-studio/architecture/deploy-line.mmd,
the same files the project's README draws, and a test holds the page's drawings to them. Every part names its file,
and a test refuses the page when a file no longer says what the page says it does.