How it works

One engine, many clients.

The desktop UI is not special. It uses the same command API as AI agents over MCP, the command line and plugins. Every edit is a registered command, applied to one project document by one Rust engine.

Pre-alpha, Phase 1 of 7 This page describes the design. Each fact below says what is built, and built is not the same as usable: nothing decodes real video yet.

Trace a path

Select a client to trace its path through the engine.

Cutweave architecture: clients, API layer, engine and outputsAPI layer: one local axum server on 127.0.0.1, token authEngine: cutweave, one Rust processcommandsdoc.patched{rev, actor, ops}Desktop UIElectron and ReactAI agentsMCP, stdio or HTTPcutweave CLIJSON in, JSON outPluginsWASM, JS, WGSL, UI panelsJSON-RPC over WebSocket/rpcMCP/mcpHTTP media endpoints/media/{id}/thumb, /frameShared-memory previewring buffer to a WebGPU canvasCommand busvalidate, actor from credentialTransaction (Tx)forward and inverse patchesProject documentimmutable snapshots, one writerPlugin hostwasmtime, QuickJS, WGSLJob managerexport, analysis, AI, proxiesRender pipelinewgpu and WGSLAudio enginedevice clock is masterMedia layerFFmpeg, frame index, proxiesAI gatewayHTTPS to cloud modelsPreviewExportAgent frameCutweave architecture: clients, API layer, engine and outputsAPI layer: local axum, 127.0.0.1, token authEngine: cutweave, one Rust processAlso in the engineDesktop UIElectron and ReactAI agentsMCPcutweave CLIJSON in, JSON outPluginsWASM, JS, WGSLJSON-RPCWebSocket /rpcMCP/mcpHTTP media/media/{id}/...Shared memorypreview ringCommand busvalidate, actor from credentialTransaction (Tx)forward and inverse patchesProject documentimmutable snapshotsRenderwgpu and WGSLAudiodevice clockPreviewExportAgent framePlugin hostwasmtime, QuickJSJob managerexport, AI, analysisMedia layerFFmpeg, proxiesAI gatewaycloud models, HTTPS
  • Client
  • Engine component
  • Output
  • Command or call
  • Events streamed back
  • Agent path
  • Selected path
Text description of the diagram

The diagram has four rows, read top to bottom.

  1. Clients. The desktop UI (Electron and React), AI agents over MCP, the cutweave CLI, and plugins (WASM, JS, WGSL and UI panels).
  2. API layer. One local axum server on 127.0.0.1 with token auth. It offers JSON-RPC over WebSocket at /rpc, MCP at /mcp, HTTP media endpoints (thumbnails, filmstrips, waveforms, frames), and a shared-memory ring for the preview.
  3. Engine. One Rust process. Every client sends commands to the API, then to the command bus, which validates them. The transaction records forward and inverse patches and applies them to the project document, a single writer that holds immutable snapshots. The document feeds the render pipeline and the audio engine. The job manager calls media, AI and render. The plugin host calls the command bus, render and the AI gateway. The AI gateway reaches cloud models over HTTPS. The media layer wraps FFmpeg.
  4. Outputs. The render pipeline produces the preview, an export, and the agent frame.

Events such as doc.patched{rev, actor, ops} stream from the engine back to every subscriber, and the UI keeps a read-only projection that updates from them.

Desktop UI. commands over JSON-RPC on a WebSocket, media over HTTP, preview frames through a shared-memory ring. Then command bus, Tx, project document, render pipeline and audio engine, out to the preview.

AI agents. MCP over stdio or HTTP. Then command bus, Tx and project document. Image tools come from the render pipeline as an agent frame.

CLI. JSON in, JSON out. It attaches to the running engine or starts a headless one, and goes through the same command bus. Export runs as a job through the render pipeline.

Plugins. run in the plugin host (wasmtime, QuickJS, a WGSL loader), which calls the command bus and the render pipeline. A plugin effect shows up in the preview.

Life of an edit

From command to pixels

Follow one command, clip.split, through the engine. Every client takes this same path.

  1. Validate

    Built

    The client sends the command over JSON-RPC, or an agent calls the matching MCP tool. params._meta carries a request_id, which every change needs, and optionally the expected_rev the client last saw. The engine checks the arguments against the JSON Schema, then runs semantic checks, such as whether the clip exists and the time falls strictly inside it. The actor comes from the credential, not from anything the client claims.

    {"jsonrpc":"2.0","id":7,"method":"clip.split",
     "params":{"item":"itm_…","at":"4s",
               "_meta":{"request_id":"0190f5c2-…","expected_rev":41}}}
  2. Tx records forward and inverse patches

    Built

    The command runs inside a transaction. The Tx records the forward patch ops with the values they replace, so each can be inverted (RFC 6902, addressed by ID). A gesture, such as a drag, and a proposal, which is an agent turn, are transaction kinds that still commit as one undo step.

    forward:  replace …/items/itm_a/duration   7056000000 → 2822400000
              add     …/items/itm_b            // the right half
    inverse:  remove  …/items/itm_b
              replace …/items/itm_a/duration   2822400000 → 7056000000
  3. A new snapshot revision

    Built

    One writer owns the project document. It writes the commit to the journal, applies the patch and publishes an immutable snapshot at the next revision. Readers hold an Arc to a revision, so the hot path takes no locks.

    rev 41  →  rev 42   // earlier snapshots stay valid for readers
  4. Event: doc.patched

    Built

    The engine streams the change to every subscriber, with the revision, the one before it, who made it and the patch ops.

    {"method":"doc.patched",
     "params":{"rev":42,"prev_rev":41,"committed_rev":42,
               "actor":"agent:mcp","tx_id":"tx_9","cause":"command",
               "request_id":"0190f5c2-…","ops":[…]}}
  5. UI projection updates

    Built

    The editor keeps a read-only mirror of the document. If an event continues from its revision it applies the ops, and if it missed one it fetches a fresh snapshot. It never writes to the mirror directly, and any other client can follow the same stream.

    if (prev_rev === mirror.rev) applyPatch(mirror, ops)   // @cutweave/protocol
    else resync()                                          // project.snapshot
  6. Render

    Wiring pending

    Rendering is a pure function of the snapshot, the sequence, the time and the quality. The same revision gives the same frame, so frames can be cached. The compositor and the frame readback are built and tested on synthetic test cards. They are not wired to the engine yet, and nothing decodes real video.

    render(snapshot@42, sequence, t, quality) → frame

What protects a retry or a race

  • request_id makes a command idempotent. A repeat inside 10 minutes by the same actor, with the same method and parameters, returns the original result, so a client can resend after an engine restart.
  • expected_rev is optimistic concurrency. If the document has moved on, the command fails with conflict and the current revision instead of overwriting.
  • Errors are typed: not_found, locked, conflict, invalid (with a JSON Pointer to the bad parameter), forbidden, unsupported and internal, each with a human message.

The message shapes are real, from the JSON-RPC reference and the engine’s generated patch fixtures. IDs, revisions and the request id are invented.

Time

Time is a whole number

Cutweave measures time in flicks: 1/705,600,000 of a second, stored as an i64. Pick a rate to see the exact count.

A flick is 1/705,600,000 of a second. Cutweave stores every time as a whole number of flicks in an i64. The number was chosen so that every common frame rate and audio sample rate divides it exactly.

Flicks per frame or sample, for every supported rate
RateExact rateFlicks per frame or sampleDivides exactly
23.976 fps24,000/1,001 per second29,429,400Yes
24 fps24 per second29,400,000Yes
25 fps25 per second28,224,000Yes
29.97 fps30,000/1,001 per second23,543,520Yes
30 fps30 per second23,520,000Yes
50 fps50 per second14,112,000Yes
59.94 fps60,000/1,001 per second11,771,760Yes
60 fps60 per second11,760,000Yes
120 fps120 per second5,880,000Yes
44.1 kHz44,100 per second16,000Yes
48 kHz48,000 per second14,700Yes
96 kHz96,000 per second7,350Yes

Rendering

One pipeline for preview, export and agents

What you scrub is what you export, and what an agent sees.

  • Preview and export share one pipeline

    There is no separate, faster preview renderer to drift from the export. Preview frames are downscaled into a shared-memory ring and drawn on a WebGPU canvas. Export goes to the encoder. An agent’s frame goes to JPEG or PNG.

    In progress The compositor, the readback and the preview transport are built. Export is not.

  • Deterministic by construction

    A frame is a pure function of the snapshot, the sequence, the time and the quality. Randomness is seeded from item IDs, and nothing reads the wall clock. That makes frame caching, parallel chunked export and golden tests possible.

    Built In the production compositor, which renders test cards for now.

  • Linear light, in float

    The working space is Rgba16Float in linear light. PQ and HLG sources are tone-mapped to SDR.

    Built In the production compositor.

  • Same pixels across GPU vendors

    In the S4 compositor spike, output on an NVIDIA GPU and an AMD GPU differed by at most one code value. The production compositor’s golden test now holds each GPU to its own frames bit for bit, and every set within one 8-bit code of the software renderer.

    Measured in a spike Informal, one Windows laptop. Formal runs pending.

    Measured in a work package test Informal, one dev machine. Formal runs pending.

Real frames from the production compositor

These are the compositor’s own test goldens, drawn on an RTX 3080 laptop GPU. The sources are synthetic test cards, because nothing decodes video yet.

A grid of six frames with timecodes burned in from 00:00:00:00 to 00:00:06:20. Color bars and a gradient sweep are layered with a solid blue clip.
Rendered by the production compositor (test golden)What an agent gets from render.contact_sheet: six frames spread over 8 seconds, with timecodes burned in. Color bars, a gradient sweep and a solid blue clip are layered on the timeline.
Color bars with a smaller gradient test card laid over them, tilted, cropped and partly transparent.
Rendered by the production compositor (test golden)A picture-in-picture layer rotated 17 degrees, cropped and at 80% opacity, composited in linear light.

Engineering facts

What is built, and what is a plan

Each fact carries its status and the document it comes from.

Model

  • Time is flicks

    Built

    1/705,600,000 s as an i64. Every common frame rate (23.976 to 120) and audio rate (44.1k, 48k, 96k) divides it exactly, so there is no float drift.

    In cutweave-model. Commands accept 4s, a frame number or a timecode and snap to the sequence’s frame grid.

    arch §4.1, ADR-0004

  • Entities are addressed by ID, never by index

    Built

    IDs are prefixed UUIDv7: med_, seq_, trk_, itm_.

    arch §4.2, ADR-0004

  • No overlaps within a track, ever

    Built

    Property-tested after every random request. An agent’s timeline.insert is refused if it would overlap. The editor’s drag and drop asks for a new track instead, like CapCut.

    Model invariants and the timeline.insert overlap policy.

    arch §4.3

Commands

  • Every edit is undoable and invertible

    Built

    Undo applies stored inverse patch ops (RFC 6902). A property harness runs random command sequences over every registered command and checks undo(apply(doc)) == doc.

    43 commands registered. Built in cutweave-commands and cutweave-ops.

    arch §5.2, ADR-0005

  • Per-actor history

    Built

    Actors are user, agent:<label> and plugin:<id>. The actor comes from the credential, never from the client, so you can undo the agent’s last change without touching your own edits.

    Built in the engine: the editor is user and an MCP session is agent:mcp. Undo refuses when a later change touched the same fields.

    arch §5.2, ADR-0016

  • Soft locks while you drag

    Built

    An open gesture locks the items it touches. An agent’s edit to the same clip is refused with a retry hint, and edits to other clips go through.

    Built in the engine. A gesture that goes idle for 30 s is rolled back.

    arch §5.2, ADR-0017

  • Idempotent commands

    Built

    request_id is deduplicated for 10 minutes, so retries after an engine restart are safe.

    The window survives a restart through the journal, and the editor resends unacknowledged commands exactly once.

    arch §5.1, ADR-0015

  • Deterministic IDs for tests

    Built

    --deterministic-ids <seed> lets CLI, MCP and RPC paths produce byte-identical project documents.

    Seeded streams for entities, requests and jobs. A GUI engine refuses the flag.

    arch §5.1, M1 exit

Rendering

  • Deterministic rendering

    Built

    render(snapshot, sequence, t, quality) is a pure function. Randomness is seeded from item IDs and there is no wall clock. That enables frame caching, parallel chunked export and golden tests.

    Built in the production compositor: each GPU reproduces its golden frames bit for bit. Caching and chunked export are not built.

    arch §8, WP-1F.02

  • Linear-light, float rendering

    Built

    Rgba16Float working space. PQ and HLG are tone-mapped to SDR.

    Built in the compositor. It renders synthetic test cards until media decoding lands.

    arch §8, WP-1F.02

  • Preview and export share one pipeline

    In progress

    What you scrub is what you export.

    The compositor, the frame readback and the preview transport are built. Export is not.

    brief, principle 4

  • Lock-free real-time audio thread

    Built

    No allocation on the audio callback. The audio device clock is the master clock; video follows audio.

    Built for generated audio. The mixer render allocates and locks nothing, and an offline mixdown equals the real-time output.

    arch §9, WP-1G.01, WP-1G.02

Process and safety

  • Engine in its own process

    Built

    A crash does not take the UI down. One Rust binary, cutweave, runs as GUI engine, MCP server, CLI or headless renderer.

    Built: the editor talks to the engine over a local WebSocket, and a supervisor restarts it and recovers from the journal. Decoder and plugin crashes are not exercised yet.

    arch §2, ADR-0002, WP-1L.03

  • Crash-safe saves

    Built

    Temp file, fsync, rename. Autosave after 2 s idle or every 30 s, with the last ten backups. A journal is replayed on restart.

    Built in the engine. A kill test stops a 500-operation session at 20 random points and checks that recovery matches.

    arch §17, ADR-0006

  • Agents only touch folders you allow

    Built

    An agent or CLI path must lie inside the allowed folders or the open project, after symlinks are resolved. Text taken from media files is marked untrusted before an agent sees it.

    Built in the engine and tested with links and junctions.

    arch §14, §18

  • Agents get frames, not screenshots

    In progress

    Image tools carry structured metadata: time, items visible, captions on screen.

    render.frame and render.contact_sheet are built in the render crate. They are not on the MCP tool list until WP-1J.02.

    arch §14, WP-1F.03

  • Secrets never leave the engine

    In progress

    #[secret] params are redacted before the journal. Keys are not visible to the renderer, plugins or MCP clients.

    Redaction before the journal is built and tested. There are no keys yet: the AI gateway and the keychain are not built.

    arch §14, §18

Performance budgets Targets

Budgets are features: each is benchmarked in CI on reference machines. The target column is a target. The measured column is what has been seen so far, informally, and many rows have nothing yet.

Performance budgets
WhatTargetMeasured so far
App start< 2.5 sEngine alone, cold start 64 ms (WP-1I.04) Work package test
Open a 1-hour, 400-item project< 2 sNot measured yet
Command round tripp95 < 16 msp95 0.81 ms over WebSocket, debug build (WP-1I.02) Work package test
Scrub, proxy mediap95 < 80 msp95 49.5 ms (S1) Spike
Scrub, 4K long-GOPp95 < 150 msNot measured yet
Timeline with 5,000 items≥ 55 fps60 fps, hit-test under 0.1 ms (WP-1M.05) Work package test
Audio/video sync< 40 ms; drift < 1 frame per 30 minNot measured yet
1080p H.264 export≥ 2× realtimeNot measured yet
Idle memory< 1.5 GBNot measured yet

In the real code Measured in a work package test

Results from work-package tests since Phase 0
Work packageResult
WP-1B.03 document actorA no-op command round trip on the actor: p95 26 µs. Eight writers submitted 10,000 commands, and the final document equals a sequential replay.
WP-1I.02 JSON-RPCA clip.trim round trip over WebSocket, with its change event, on a 400-item project with a journal: p50 0.63 ms, p95 0.81 ms, p99 0.95 ms (debug build, loaded machine). Fifty connections sent 100 pipelined commands each with no deadlock.
WP-1C.02 journalA 500-operation session killed at 20 random points: recovery equals the uninterrupted run. Group commit keeps a rename round trip at p95 148 µs, against 788 µs with a sync on every commit.
WP-1F.02 compositorEleven 384×216 golden frames per GPU: each GPU reproduces its own set bit for bit, and every set is within one 8-bit code of the software renderer (PSNR 69 dB or better).
WP-1F.03 render.frameA 1080p frame to a 768 px JPEG, end to end with a warm cache, p50: RTX 3080 laptop 8.2 to 8.6 ms, Radeon iGPU 7.8 to 8.2 ms, software 15.7 ms. Budget 150 ms.
WP-1H.03 preview bridgeThe present loop holds 60 fps with no gaps, and copying a 1080p frame out of shared memory takes about 0.7 to 0.9 ms.
WP-1G.01 mixerFour overlapping tones match the analytical sum to 4.4e-8. A 44.1 to 48 kHz resample of a 1 kHz sine has THD+N of -136.0 dB. Offline mixdown equals the real-time render within 1e-6.
WP-1G.02 audio outputOn a real WASAPI device at 48 kHz, a 10-minute soak of the eight-source mix: 0 underruns, 0 xruns, 0 heap operations in the callback, max clock residual 0.59 ms. Drift against the system timer is +10.9 ppm, the device crystal, as in S2.
WP-1J.01 MCP/mcp lists 18 tools in about 3.6k tokens (gate: 19 tools, 5k). /mcp/minimal lists 9 tools in about 1.2k tokens (budget: 12 tools, 3k).
WP-1L.03 supervisionThree edits, then the engine is killed: the editor recovers in under 5 s and each command applies once.

Informal, one dev machine. Formal runs pending.

Phase 0 spike numbers Measured in a spike

Results from Phase 0 spikes
SpikeResult
S1 preview pathElectron, Rust sidecar, shared memory and WebGPU: 60.00 fps with 0 skipped frames. Scrub to pixel p95 49.5 ms (budget 80). 0 blank frames over 119 live resizes.
S1 timeline stress5,000 clips, 50,000 keyframes and 200 thumbnails at 60 fps (vsync-capped). Draw p95 1.3 ms; hit-test under 0.01 ms.
S2 audio clock10-minute soak: 0 underruns, 0 real-time allocations, callback max 0.29 ms, drift +11 ppm.
S4 compositor, 1080pGPU p50/p95: RTX 3080 laptop 0.7/3.1 ms; AMD iGPU 6.5/8.1 ms (budget 8 ms, borderline). Cross-vendor difference at most 1 code value.
S4b compositions35 of 35 sandbox escapes contained. 200 fully animated nodes took 2.6 ms against a 1 ms budget: a conditional pass.
S5 command bus and MCP73 tests. Standard tools/list about 2.7k tokens for 13 tools. Claude Code passed 3 of 3 runs with no screenshots.
S3 decode, seek, hardware accelerationNot passed yet: unblocked and running since 2026-11-23, against generated test media.

Informal, one Windows laptop. Formal runs pending.

Stack

What it is built with

Engine
Rust (edition 2024), wgpu and WGSL, FFmpeg (not yet in), rmcp (official Rust MCP SDK), wasmtime (planned), axum, cpal
App
Electron, React 19, TypeScript (strict)

Read the design

The architecture doc is the contract the code is written against. Decisions are recorded as ADRs. The command reference is generated from the code, so it cannot drift from it.