Some checks failed
build-images / web (push) Has been cancelled
vision2026-ci / Python SDK resource tests (push) Has been cancelled
build-images / api (push) Has been cancelled
build-images / worker-gpu (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Has been cancelled
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Has been cancelled
codeql / Analyze (javascript-typescript) (push) Has been cancelled
codeql / Analyze (python) (push) Has been cancelled
perf / API hot-path micro-smoke (budgeted) (push) Has been cancelled
perf / Desktop engine crates (release build check) (push) Has been cancelled
vision2026-ci / API phase modules (ruff + pytest) (push) Has been cancelled
vision2026-ci / Alembic upgrade + drift check (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Has been cancelled
Paid, hosted product at menivor.com, now retired as a company project. Fresh squashed history of the cleaned working tree (secret-scanned, no .env, no customer data, no outreach logs). Built on MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
656 lines
37 KiB
Markdown
656 lines
37 KiB
Markdown
# ReelForge Desktop — Vision 2026 Architecture (Additive)
|
||
|
||
> Scope: the NEW desktop subsystems that turn the existing GPUI generation
|
||
> workspace into a **local render farm + heavy-export engine + ComfyUI worker
|
||
> bridge + bulk clipfarm operator console + offline project store +
|
||
> screen-recording capture + drag-drop asset pipeline + plugin host**.
|
||
>
|
||
> This document plans strictly **additively**. It assumes everything under
|
||
> `apps/desktop/src/{api,app,config,domain,media,security,telemetry,ui,workspace}`
|
||
> already exists and is correct, and designs only what is missing. It does not
|
||
> restate shipped modules. `electron-legacy/` stays frozen and out of scope.
|
||
|
||
---
|
||
|
||
## 1. Overview
|
||
|
||
### 1.1 What exists today (seams, not scope)
|
||
|
||
The shipped desktop app is a single-crate GPUI (Rust) client. Its load-bearing
|
||
conventions — which every new module below MUST follow — are:
|
||
|
||
- **One background owner.** The GPUI shell (`ui/`) never does IO. It sends
|
||
immutable `WorkerCommand`s to a single worker (`workspace/worker.rs`) which
|
||
owns HTTP, polling, uploads, credentials, and persistence. The worker emits
|
||
immutable `WorkerUpdate`s reduced into `DesktopState` snapshots
|
||
(`workspace/reducer.rs`) that drive the UI.
|
||
- **Contract-only backend access.** The desktop calls only the canonical
|
||
`/api/v1/jobs` and `/api/v1/generation/broll/*` product contracts via
|
||
`api/`. It never imports backend engine code. Direct uploads use the shared
|
||
presign → R2 PUT → ownership-register handshake.
|
||
- **Secrets never persist to config.** API keys live only in the OS credential
|
||
store (`security/`); only the normalized API base is written to disk.
|
||
- **Small, cohesive files.** `//!` module headers, `pub(crate)` visibility,
|
||
`mod.rs` re-export barrels, 200–400 lines/file.
|
||
|
||
### 1.2 The desktop wedge (why a heavy native app exists)
|
||
|
||
The web/mobile surfaces are thin cloud clients. The desktop is the **operator's
|
||
power tool**: it turns the user's own hardware into a *free render node and GPU
|
||
model host*, and turns one human into a *clipfarm of hundreds of daily reels*.
|
||
Its four native superpowers, none of which the browser can offer:
|
||
|
||
1. **Local heavy render / export** — bulk FFmpeg + hardware-encoder pipelines,
|
||
watermark-safe per-platform masters, zero cloud-render spend on compositing.
|
||
2. **Local ComfyUI GPU host** — drive a local (or LAN) ComfyUI/Wan 2.2 install
|
||
as a *first-class provider* behind the same routing/wallet semantics, so
|
||
BYO-GPU work is billed at $0 to the wallet.
|
||
3. **Screen-recording + capture** — native ScreenCaptureKit / Windows Graphics
|
||
Capture / PipeWire feeds for the avatar-PiP-over-screen genre and gameplay
|
||
B-roll manufacturing.
|
||
4. **Offline-first bulk operator console** — a project store, batch matrix, and
|
||
drag-drop asset intake that keep working on a plane and reconcile to cloud on
|
||
reconnect.
|
||
|
||
### 1.3 Architectural evolution: single crate → internal workspace
|
||
|
||
The heavy engines (render, comfy, capture, project format) must run **headless**
|
||
inside a `render-node` daemon as well as inside the GUI. To avoid a monolith and
|
||
keep files small and reusable, `apps/desktop` becomes an **internal Cargo
|
||
workspace**: reusable, UI-free engine crates under `apps/desktop/crates/`, and
|
||
thin binaries under `apps/desktop/src/bin/` that wire engines into GUI shells or
|
||
daemons. The existing `src/` GUI modules keep their layout; new GUI glue is
|
||
added alongside them.
|
||
|
||
```
|
||
apps/desktop/
|
||
├── Cargo.toml # (edit) becomes [workspace] + members
|
||
├── src/ # GUI binary crate (existing modules unchanged)
|
||
│ ├── bin/ # NEW: additional binaries (headless nodes/daemons)
|
||
│ ├── runtime/ # NEW: GUI↔engine glue, local job scheduler
|
||
│ ├── render/ comfy/ capture/ assets/ project/ clipfarm/
|
||
│ ├── plugins/ sync/ hardware/ ffmpeg/ updater/ ipc/ # NEW GUI-side glue
|
||
│ └── ui/… # NEW view subtrees appended to existing ui/
|
||
└── crates/ # NEW: reusable, headless, UI-free engine crates
|
||
├── rf-jobs/ rf-render/ rf-encode/ rf-comfy/ rf-capture/
|
||
├── rf-assets/ rf-project/ rf-clipfarm/ rf-plugins/ rf-sync/
|
||
├── rf-hardware/ rf-ffmpeg/ rf-devproto/ rf-testkit/
|
||
```
|
||
|
||
Rule of thumb: **anything that must run without a window lives in a `crates/`
|
||
engine; anything that touches GPUI lives in `src/`.** Engines never depend on
|
||
`gpui`; GUI glue depends on engines and adapts them to `WorkerCommand`/
|
||
`WorkerUpdate`.
|
||
|
||
---
|
||
|
||
## 2. New Cargo workspace layout
|
||
|
||
| Path | Responsibility |
|
||
|------|----------------|
|
||
| `apps/desktop/Cargo.toml` | (edit) declare `[workspace]` with `src` GUI crate + all `crates/*`; shared `[workspace.dependencies]` for new deps (ffmpeg-sidecar, cpal, symphonia, rusqlite, extism, tokio, reqwest, ashpd, image, blake3, notify, zip). |
|
||
| `apps/desktop/crates/README.md` | Explains the UI-free engine boundary and the "no `gpui` in crates" rule. |
|
||
| `apps/desktop/src/bin/render-node.rs` | Headless render-farm worker binary; joins a coordinator, pulls render/encode jobs, streams progress. |
|
||
| `apps/desktop/src/bin/comfy-node.rs` | Headless ComfyUI-host worker binary; advertises local GPU models, executes graph jobs. |
|
||
| `apps/desktop/src/bin/devd.rs` | Local device daemon exposing the on-device API + MCP over a loopback socket for external agents and the GUI. |
|
||
| `apps/desktop/src/bin/rfctl.rs` | Operator CLI (headless batch submit, node status, cache prune) for power users and CI. |
|
||
|
||
New workspace dependency additions (declared once in root `[workspace.dependencies]`):
|
||
`tokio`, `reqwest` (local ComfyUI/daemon HTTP, not the product API), `ffmpeg-sidecar`,
|
||
`cpal`, `symphonia`, `image`, `rusqlite` (bundled), `blake3`, `notify`, `zip`,
|
||
`extism` (WASM plugin host), `ashpd` (Linux portals), `zbus`, `sysinfo`, `wgpu`
|
||
(hardware probe), `time`, `uuid`.
|
||
|
||
---
|
||
|
||
## 3. Subsystem: Unified local job envelope (`crates/rf-jobs`)
|
||
|
||
The spine. Mirrors the cloud async envelope (`IN_QUEUE → IN_PROGRESS →
|
||
COMPLETED/FAILED`, poll/webhook) locally so a locally-rendered job and a
|
||
cloud-routed job are indistinguishable to the reducer and to publishing.
|
||
|
||
### `crates/rf-jobs/src/`
|
||
|
||
| Path | Responsibility |
|
||
|------|----------------|
|
||
| `lib.rs` | Crate root; re-exports envelope, ids, status, ports. |
|
||
| `envelope.rs` | `LocalJob` immutable envelope (id, kind, spec hash, inputs, priority, deadline). |
|
||
| `status.rs` | `JobPhase` state machine (`Queued/Leased/Running/Uploading/Complete/Failed/Canceled`) + legal transitions. |
|
||
| `kind.rs` | `LocalJobKind` enum (Render, Encode, ComfyGraph, Capture, AssetImport, Proxy, Thumbnail, PluginTask). |
|
||
| `progress.rs` | Immutable `ProgressTick` (fraction, stage label, ETA, throughput) + coalescing rules. |
|
||
| `result.rs` | `JobResult` / `JobError`, retry-eligibility classification, artifact refs. |
|
||
| `priority.rs` | Priority + fairness weights (interactive vs batch clipfarm lane). |
|
||
| `lease.rs` | Node lease tokens, heartbeat TTL, requeue-on-expiry logic. |
|
||
| `spec_hash.rs` | Deterministic content hash of a job spec for dedupe + result caching. |
|
||
| `ids.rs` | Typed newtypes: `LocalJobId`, `NodeId`, `LeaseId`, `ArtifactId`. |
|
||
| `ports.rs` | Traits (`JobSink`, `JobSource`, `ProgressReporter`, `ArtifactWriter`) engines implement. |
|
||
| `clock.rs` | Injectable clock for deterministic tests. |
|
||
| `error.rs` | Crate error taxonomy. |
|
||
|
||
---
|
||
|
||
## 4. Subsystem: Local render farm + heavy export (`crates/rf-render`, `crates/rf-encode`)
|
||
|
||
Turns the machine (and LAN peers) into a render pool that composites reels,
|
||
bakes captions/VFX, and emits watermark-safe per-platform masters — all locally.
|
||
|
||
### `crates/rf-encode/src/` — codec + hardware-encoder layer
|
||
|
||
| Path | Responsibility |
|
||
|------|----------------|
|
||
| `lib.rs` | Crate root; re-exports encoder selection + ffmpeg command model. |
|
||
| `hwaccel.rs` | Detect/select VideoToolbox (macOS), NVENC/QSV/AMF (Win/Linux), fallback libx264/265. |
|
||
| `codec.rs` | Codec profiles (H.264/HEVC/AV1/VP9) with platform-safe presets. |
|
||
| `params.rs` | Bitrate ladders, CRF/CQ mapping, keyframe cadence, color/range flags. |
|
||
| `command.rs` | Immutable FFmpeg arg-graph builder (no shell string concat). |
|
||
| `filtergraph.rs` | Typed `-filter_complex` builder (scale, pad, overlay, chromakey, ass, aduck). |
|
||
| `probe.rs` | ffprobe wrapper → typed `MediaProbe` (streams, duration, fps, HDR, rotation). |
|
||
| `progress_parse.rs` | Parse `-progress pipe:` frames into `ProgressTick`s. |
|
||
| `audio_mix.rs` | Ducking/loudnorm/-14 LUFS normalization graph for narration+BGM. |
|
||
| `error.rs` | Encode failure classification (transient vs spec-invalid). |
|
||
|
||
### `crates/rf-render/src/` — render orchestration + export
|
||
|
||
| Path | Responsibility |
|
||
|------|----------------|
|
||
| `lib.rs` | Crate root; render engine facade + trait exports. |
|
||
| `engine.rs` | Executes a `RenderJob` end-to-end: resolve inputs → build graph → run → verify. |
|
||
| `plan.rs` | `RenderPlan` immutable model: track stack, layers, timings, output targets. |
|
||
| `compose/mod.rs` | Compose-track assembly (avatar PiP over screen-rec, karaoke ASS, watermark, BGM). |
|
||
| `compose/pip.rs` | Chromakey avatar picture-in-picture placement + scaling math. |
|
||
| `compose/captions.rs` | Burn word-level ASS/karaoke (consumes caption JSON; styling only, no ASR). |
|
||
| `compose/watermark.rs` | Free-tier badge + short-link overlay compositor (toggleable). |
|
||
| `compose/vfx.rs` | Apply camera-motion / VFX preset descriptors at render time. |
|
||
| `compose/loopback.rs` | Enforce last-frame==first-frame seam for loop-back exports. |
|
||
| `export/mod.rs` | Export orchestrator; fan-out one master to N platform variants. |
|
||
| `export/presets.rs` | Per-platform export presets (TikTok/Reels/Shorts/X aspect, size caps, fps). |
|
||
| `export/watermark_safe.rs` | Re-encode uniquely per platform (metadata strip, GOP jitter) to dodge foreign-watermark suppression. |
|
||
| `export/safe_zone.rs` | Caption/CTA safe-zone insets per platform baked into layout. |
|
||
| `export/loop_export.rs` | Seamless-loop exporter: validate zero visible discontinuity for ~5s ASMR. |
|
||
| `export/manifest.rs` | Emit an export manifest (which master → which variant → sha) for sync/publish. |
|
||
| `farm/mod.rs` | Local render-farm pool facade. |
|
||
| `farm/coordinator.rs` | Owns the queue, leases jobs to nodes, requeues on lease expiry. |
|
||
| `farm/node.rs` | A render node (local process or LAN peer): capacity, health, current lease. |
|
||
| `farm/scheduler.rs` | Fairness scheduler: interactive lane vs bulk clipfarm lane, concurrency caps. |
|
||
| `farm/discovery.rs` | LAN node discovery (mDNS) + manual node registration. |
|
||
| `farm/transport.rs` | Node↔coordinator wire protocol (over `rf-devproto`) for job lease/progress/artifact. |
|
||
| `farm/throttle.rs` | Thermal/battery/power-source aware throttling (pause on battery). |
|
||
| `cache/mod.rs` | Content-addressed render-result cache keyed on `spec_hash`. |
|
||
| `cache/store.rs` | On-disk cache store + LRU eviction by size budget. |
|
||
| `verify.rs` | Post-render QC: duration match, audio present, no black frames, loop seam. |
|
||
| `error.rs` | Render error taxonomy + retry policy. |
|
||
|
||
---
|
||
|
||
## 5. Subsystem: ComfyUI local worker bridge (`crates/rf-comfy`)
|
||
|
||
Drives a local/LAN ComfyUI (with vendored Wan 2.2 / worker-comfyui async
|
||
pattern) as a first-class provider. Versioned workflows are pinned artifacts.
|
||
|
||
### `crates/rf-comfy/src/`
|
||
|
||
| Path | Responsibility |
|
||
|------|----------------|
|
||
| `lib.rs` | Crate root; bridge facade + provider adapter export. |
|
||
| `discovery.rs` | Find a running ComfyUI (localhost/LAN), health/ping, version fingerprint. |
|
||
| `launcher.rs` | Optionally launch/attach a managed ComfyUI process (venv/path config). |
|
||
| `client.rs` | Async HTTP+WS client: `/prompt`, `/queue`, `/history`, WS progress stream. |
|
||
| `queue.rs` | Queue/poll/webhook adapter mapping ComfyUI prompts to `LocalJob` phases. |
|
||
| `graph/mod.rs` | Workflow-graph model (nodes, links, inputs) as typed data, not raw JSON. |
|
||
| `graph/patch.rs` | Immutable input-override patcher (seed, prompt, refs, frame count). |
|
||
| `graph/validate.rs` | Validate graph against installed node set before submit. |
|
||
| `workflows/mod.rs` | Versioned workflow registry (comfyui-deploy style pinned artifacts). |
|
||
| `workflows/registry.rs` | Resolve `workflow@version` → pinned graph + required node commits + weights. |
|
||
| `workflows/wan_i2v.rs` | Wan 2.2 image-to-video ~5s clip workflow descriptor. |
|
||
| `workflows/wan_flf2v.rs` | Wan FLF2V start+end→81-frame + RIFE/FILM 2x + upscale descriptor. |
|
||
| `workflows/flux_first_frame.rs` | Flux T2I/I2I first-frame with locked character-ref injection. |
|
||
| `workflows/interpolate.rs` | RIFE/FILM frame-interpolation pass descriptor. |
|
||
| `workflows/upscale.rs` | Latent/ESRGAN upscale pass descriptor. |
|
||
| `models/mod.rs` | Local model/weights inventory facade. |
|
||
| `models/scanner.rs` | Scan ComfyUI `models/` dirs, hash + catalog checkpoints/LoRAs/VAEs. |
|
||
| `models/license.rs` | Tag each local weight commercial-safe/non-commercial/territorial (license-first gate). |
|
||
| `models/lora.rs` | Track character/style LoRAs trained locally, map to Character entities. |
|
||
| `vram.rs` | VRAM budgeting + model-swap planning to avoid OOM across queued graphs. |
|
||
| `warm_pool.rs` | Keep hot checkpoints resident; warm-start policy across jobs. |
|
||
| `provider.rs` | Expose the bridge as a `$0-wallet` local provider matching the routing adapter contract. |
|
||
| `error.rs` | ComfyUI error mapping (node error, OOM, missing weight → retry class). |
|
||
|
||
---
|
||
|
||
## 6. Subsystem: Screen-recording capture (`crates/rf-capture`)
|
||
|
||
Native capture for avatar-PiP-over-screen reels and gameplay B-roll production.
|
||
|
||
### `crates/rf-capture/src/`
|
||
|
||
| Path | Responsibility |
|
||
|------|----------------|
|
||
| `lib.rs` | Crate root; capture session facade + backend trait. |
|
||
| `session.rs` | `CaptureSession` lifecycle (arm → record → pause → stop → finalize). |
|
||
| `config.rs` | Capture spec: source, region, fps, resolution, cursor, audio sources. |
|
||
| `source.rs` | Enumerate capturable sources (displays, windows, regions, cameras). |
|
||
| `sink.rs` | Write captured frames/audio to a container via `rf-encode`. |
|
||
| `region.rs` | Region/window geometry math + DPI scaling. |
|
||
| `webcam.rs` | Webcam capture (for avatar PiP) via platform backend. |
|
||
| `audio.rs` | System audio + mic capture/mux via `cpal`, per-source gain. |
|
||
| `countdown.rs` | Pre-roll countdown + hotkey arm/stop hooks. |
|
||
| `backends/mod.rs` | Backend trait + platform selection. |
|
||
| `backends/macos_sck.rs` | ScreenCaptureKit backend (displays/windows/system audio). |
|
||
| `backends/windows_wgc.rs` | Windows.Graphics.Capture + WASAPI loopback backend. |
|
||
| `backends/linux_pipewire.rs` | PipeWire/xdg-desktop-portal screencast backend (via `ashpd`). |
|
||
| `backends/camera.rs` | Cross-platform camera capture abstraction. |
|
||
| `permissions.rs` | Request/verify OS screen+mic+camera permissions, surface actionable state. |
|
||
| `postprocess.rs` | Auto-trim silence/dead-air, mark loop points, handoff to asset pipeline. |
|
||
| `error.rs` | Capture error taxonomy (permission denied, source lost, encoder stall). |
|
||
|
||
---
|
||
|
||
## 7. Subsystem: Drag-drop asset pipeline + content store (`crates/rf-assets`)
|
||
|
||
Ingests dropped files/folders, transcodes-on-import, generates proxies +
|
||
thumbnails, dedupes by hash into a content-addressed local store.
|
||
|
||
### `crates/rf-assets/src/`
|
||
|
||
| Path | Responsibility |
|
||
|------|----------------|
|
||
| `lib.rs` | Crate root; importer + library facade. |
|
||
| `intake.rs` | Drag-drop / folder-watch intake queue (immutable `IntakeItem`s). |
|
||
| `import.rs` | Import pipeline: classify → hash → dedupe → transcode → proxy → thumb → catalog. |
|
||
| `classify.rs` | MIME/type classification (video/image/audio/lut/font/srt/psd). |
|
||
| `hashing.rs` | `blake3` content hashing for dedupe + content-addressed keys. |
|
||
| `transcode.rs` | Normalize odd inputs (HEVC/ProRes/10-bit) to editable intermediates. |
|
||
| `proxy.rs` | Generate low-res editing proxies for smooth timeline scrub. |
|
||
| `thumbnail.rs` | Poster/thumbnail + sprite-sheet (scrub strip) generation. |
|
||
| `metadata.rs` | Extract + persist probe metadata, EXIF, duration, loudness. |
|
||
| `store/mod.rs` | Content-addressed store (CAS) facade. |
|
||
| `store/cas.rs` | On-disk CAS layout (`objects/ab/cdef…`), atomic writes. |
|
||
| `store/index.rs` | Asset index (hash → paths, refcount, tags) backed by SQLite. |
|
||
| `store/gc.rs` | Refcount GC + orphan sweep + size-budget eviction. |
|
||
| `library.rs` | Query API: search/filter by type, tag, project, loop-capable. |
|
||
| `tagging.rs` | Manual + auto tags (gameplay type, loopable, license class). |
|
||
| `gameplay.rs` | Gameplay-B-roll library helpers (Minecraft/Subway/GTA/power-wash) + loop metadata. |
|
||
| `watch.rs` | `notify`-based hot-folder watcher for auto-import. |
|
||
| `error.rs` | Asset pipeline error taxonomy. |
|
||
|
||
---
|
||
|
||
## 8. Subsystem: Offline project files + local DB (`crates/rf-project`)
|
||
|
||
The `.reelforge` bundle format and the offline-first project store that keeps the
|
||
operator productive without a network.
|
||
|
||
### `crates/rf-project/src/`
|
||
|
||
| Path | Responsibility |
|
||
|------|----------------|
|
||
| `lib.rs` | Crate root; project model + store facade. |
|
||
| `model/mod.rs` | Immutable `Project` aggregate root re-exports. |
|
||
| `model/project.rs` | Project header (id, title, genre template, aspect, cloud id, revision). |
|
||
| `model/timeline.rs` | Local EDL/timeline model (tracks, clips, transitions) interop-ready. |
|
||
| `model/shot.rs` | Per-shot record (script/beat, character refs, first-frame, motion params). |
|
||
| `model/character.rs` | Local Character/Style lock entity (refs, LoRA id, cross-model identity). |
|
||
| `model/asset_ref.rs` | Reference from project → CAS hash (never embeds bytes). |
|
||
| `model/render_target.rs` | Declared export targets/platforms per project. |
|
||
| `bundle/mod.rs` | `.reelforge` bundle read/write facade. |
|
||
| `bundle/format.rs` | Bundle spec: zip container, `manifest.json`, versioned schema. |
|
||
| `bundle/writer.rs` | Atomic bundle writer (temp → fsync → rename), relative asset refs. |
|
||
| `bundle/reader.rs` | Bundle reader + schema-version detection. |
|
||
| `bundle/migrate.rs` | Forward migrations across bundle schema versions. |
|
||
| `db/mod.rs` | Local project DB facade. |
|
||
| `db/schema.rs` | SQLite schema (projects, revisions, shots, assets, jobs, outbox). |
|
||
| `db/migrations.rs` | Embedded, ordered migrations runner. |
|
||
| `db/store.rs` | CRUD + transactional revision commits (immutable revision log). |
|
||
| `db/query.rs` | Read queries for GUI browser/console. |
|
||
| `history.rs` | Local revision/version history + revert (append-only revisions). |
|
||
| `autosave.rs` | Debounced autosave + crash-recovery journal. |
|
||
| `outbox.rs` | Durable outbox of local changes awaiting cloud reconciliation. |
|
||
| `error.rs` | Project store error taxonomy. |
|
||
|
||
---
|
||
|
||
## 9. Subsystem: Bulk clipfarm operator console (`crates/rf-clipfarm`)
|
||
|
||
One human → hundreds of daily reels. A batch matrix engine that fans a body ×
|
||
templates × hooks × accounts into hundreds of local jobs and hands finished
|
||
masters to the cloud publishing scheduler.
|
||
|
||
### `crates/rf-clipfarm/src/`
|
||
|
||
| Path | Responsibility |
|
||
|------|----------------|
|
||
| `lib.rs` | Crate root; batch engine facade. |
|
||
| `batch.rs` | `BatchRun` immutable model: source rows × template × variant axes. |
|
||
| `matrix.rs` | Cartesian expansion of (bodies × hooks × templates × platforms) → job specs. |
|
||
| `source/mod.rs` | Batch-source adapters facade. |
|
||
| `source/csv.rs` | CSV/TSV row source (topics, scripts, subreddit URLs). |
|
||
| `source/sheet.rs` | Google-Sheet/Airtable pull adapter (read-only) for batch inputs. |
|
||
| `source/reddit.rs` | Reddit/URL story ingest rows → multi-voice narration specs. |
|
||
| `source/rss.rs` | RSS/news feed → recap batch rows. |
|
||
| `plan.rs` | Build ordered `LocalJob`s from the matrix, respecting wallet + license gates. |
|
||
| `dedupe.rs` | Skip specs already rendered (via `spec_hash`) for idempotent re-runs. |
|
||
| `pacing.rs` | Per-account self-cannibalization spacing + daily-cap awareness at plan time. |
|
||
| `variants/mod.rs` | Variant generators facade. |
|
||
| `variants/hooks.rs` | "1 body, N hooks" hook-variant expander for A/B packs. |
|
||
| `variants/aspects.rs` | Multi-aspect variant fan-out. |
|
||
| `progress.rs` | Roll up per-job progress into batch throughput + ETA + failure buckets. |
|
||
| `retry.rs` | Batch-level retry/backoff + partial-resume of failed rows. |
|
||
| `handoff.rs` | Push completed masters + metadata to cloud publishing/schedule via `/api/v1`. |
|
||
| `report.rs` | Batch report (rendered/failed/cost-saved-vs-cloud) export. |
|
||
| `error.rs` | Batch error taxonomy. |
|
||
|
||
---
|
||
|
||
## 10. Subsystem: Plugin host (`crates/rf-plugins`)
|
||
|
||
A sandboxed WASM (Extism) plugin runtime so the community can ship export
|
||
presets, caption styles, source adapters, and render post-passes without forking.
|
||
|
||
### `crates/rf-plugins/src/`
|
||
|
||
| Path | Responsibility |
|
||
|------|----------------|
|
||
| `lib.rs` | Crate root; plugin host facade. |
|
||
| `runtime.rs` | Extism/WASM runtime: instantiate, call, fuel/time limits, teardown. |
|
||
| `manifest.rs` | Plugin manifest schema (id, version, kind, permissions, entrypoints). |
|
||
| `registry.rs` | Installed-plugin registry + enable/disable + version pinning. |
|
||
| `loader.rs` | Load/verify plugin bundles (signature + checksum) from disk. |
|
||
| `sandbox.rs` | Capability sandbox: deny-by-default fs/net, scoped grants. |
|
||
| `permissions.rs` | Permission model + user consent prompts surfaced to GUI. |
|
||
| `abi/mod.rs` | Stable host ABI versioning. |
|
||
| `abi/types.rs` | Wire types crossing the WASM boundary (serde-stable DTOs). |
|
||
| `host_api/mod.rs` | Host-function surface exposed to plugins. |
|
||
| `host_api/assets.rs` | Read-only asset/library access for plugins (scoped). |
|
||
| `host_api/render.rs` | Register render post-passes / export presets. |
|
||
| `host_api/captions.rs` | Register caption-style providers. |
|
||
| `host_api/source.rs` | Register batch-source adapters (new content feeds). |
|
||
| `host_api/log.rs` | Structured logging + telemetry from plugins. |
|
||
| `kinds.rs` | Plugin-kind taxonomy (ExportPreset, CaptionStyle, Source, PostPass, PanelWidget). |
|
||
| `install.rs` | Install/update/remove from the creator preset marketplace bundle. |
|
||
| `error.rs` | Plugin host error taxonomy + fault isolation. |
|
||
|
||
---
|
||
|
||
## 11. Subsystem: Cloud reconciliation / hybrid sync (`crates/rf-sync`)
|
||
|
||
Keeps the offline project store and local artifacts consistent with the cloud
|
||
account, and routes each job local-vs-cloud by wallet/policy.
|
||
|
||
### `crates/rf-sync/src/`
|
||
|
||
| Path | Responsibility |
|
||
|------|----------------|
|
||
| `lib.rs` | Crate root; sync engine facade. |
|
||
| `engine.rs` | Reconcile loop: drain outbox, pull remote deltas, resolve, apply. |
|
||
| `outbox_drain.rs` | Ship queued local changes to `/api/v1` with idempotency keys. |
|
||
| `pull.rs` | Pull remote project/job/library deltas since last cursor. |
|
||
| `merge.rs` | Deterministic merge of local vs remote revisions. |
|
||
| `conflict.rs` | Conflict detection + resolution policy (last-writer, field-merge, manual). |
|
||
| `artifact_upload.rs` | Upload locally-rendered masters via presign → PUT → register handshake. |
|
||
| `routing.rs` | Local-vs-cloud job routing decision (BYO-GPU/$0 local vs routed provider). |
|
||
| `wallet_guard.rs` | Pre-flight wallet check for cloud-routed jobs; never charge for local render. |
|
||
| `cursor.rs` | Durable sync cursors + resumable transfer state. |
|
||
| `offline_queue.rs` | Persist intent while offline; auto-flush on reconnect. |
|
||
| `error.rs` | Sync error taxonomy (conflict, auth, transient). |
|
||
|
||
---
|
||
|
||
## 12. Subsystem: Hardware probe + FFmpeg sidecar (`crates/rf-hardware`, `crates/rf-ffmpeg`)
|
||
|
||
### `crates/rf-hardware/src/`
|
||
|
||
| Path | Responsibility |
|
||
|------|----------------|
|
||
| `lib.rs` | Crate root; hardware capability snapshot. |
|
||
| `cpu.rs` | CPU core/thread + feature detection (via `sysinfo`). |
|
||
| `gpu.rs` | GPU enumeration + VRAM (via `wgpu`/platform APIs) for render/comfy planning. |
|
||
| `encoders.rs` | Probe available hardware encoders (VideoToolbox/NVENC/QSV/AMF). |
|
||
| `thermal.rs` | Thermal/power-source/battery state for throttle decisions. |
|
||
| `disk.rs` | Free-space + throughput probe for cache/CAS budgeting. |
|
||
| `snapshot.rs` | Immutable `HardwareSnapshot` consumed by schedulers + burn preview. |
|
||
|
||
### `crates/rf-ffmpeg/src/`
|
||
|
||
| Path | Responsibility |
|
||
|------|----------------|
|
||
| `lib.rs` | Crate root; sidecar manager facade. |
|
||
| `locate.rs` | Locate bundled/system ffmpeg+ffprobe; version gate. |
|
||
| `download.rs` | Fetch/verify a pinned static ffmpeg build on first run (checksum). |
|
||
| `runner.rs` | Spawn/kill/monitor ffmpeg child processes with cancellation. |
|
||
| `stream.rs` | Line/stderr streaming into progress + error parsers. |
|
||
| `error.rs` | Sidecar error taxonomy. |
|
||
|
||
---
|
||
|
||
## 13. Subsystem: Device protocol + on-device API/MCP (`crates/rf-devproto`, `src/ipc`)
|
||
|
||
The daemon (`devd`) exposes the device's local capabilities to the GUI, to
|
||
external AI agents (MCP), and to LAN render/comfy nodes.
|
||
|
||
### `crates/rf-devproto/src/`
|
||
|
||
| Path | Responsibility |
|
||
|------|----------------|
|
||
| `lib.rs` | Crate root; wire protocol types + framing. |
|
||
| `message.rs` | Request/response/event envelope (serde), version-tagged. |
|
||
| `frame.rs` | Length-prefixed framing over loopback socket / LAN TLS. |
|
||
| `auth.rs` | Loopback token + LAN node pairing/auth. |
|
||
| `topics.rs` | Topic taxonomy (jobs, nodes, capture, render, comfy, sync). |
|
||
| `error.rs` | Protocol error taxonomy. |
|
||
|
||
### `src/ipc/` (GUI/daemon glue)
|
||
|
||
| Path | Responsibility |
|
||
|------|----------------|
|
||
| `mod.rs` | IPC module barrel. |
|
||
| `server.rs` | `devd` loopback server wiring engines to `rf-devproto`. |
|
||
| `mcp.rs` | MCP server exposing on-device tools (start_capture, local_render, list_nodes, comfy_run). |
|
||
| `mcp_tools.rs` | Tool schemas + handlers mapping to `LocalJob`s. |
|
||
| `client.rs` | GUI client to `devd` (so GUI and daemon share one engine instance). |
|
||
|
||
---
|
||
|
||
## 14. Subsystem: Auto-update + packaging (`src/updater`)
|
||
|
||
| Path | Responsibility |
|
||
|------|----------------|
|
||
| `src/updater/mod.rs` | Updater module barrel. |
|
||
| `src/updater/checker.rs` | Poll release channel; compare versions; respect user channel (stable/beta). |
|
||
| `src/updater/download.rs` | Download + verify signed update artifacts. |
|
||
| `src/updater/apply.rs` | Stage + swap on next launch; rollback on failed health check. |
|
||
| `src/updater/channel.rs` | Channel config + signature trust roots. |
|
||
|
||
Packaging (build config, not Rust modules):
|
||
|
||
| Path | Responsibility |
|
||
|------|----------------|
|
||
| `apps/desktop/packaging/macos/Info.plist` | Screen/mic/camera usage strings + entitlements for ScreenCaptureKit. |
|
||
| `apps/desktop/packaging/macos/entitlements.plist` | Hardened-runtime entitlements. |
|
||
| `apps/desktop/packaging/windows/reelforge.wxs` | WiX installer definition. |
|
||
| `apps/desktop/packaging/linux/reelforge.desktop` | Desktop entry + MIME registration for `.reelforge`. |
|
||
| `apps/desktop/packaging/linux/AppImageBuilder.yml` | AppImage recipe. |
|
||
| `apps/desktop/packaging/README.md` | Signing/notarization + code-signing runbook. |
|
||
|
||
---
|
||
|
||
## 15. GUI-side glue (`src/*`) — engines ↔ GPUI worker
|
||
|
||
These `src/` modules are the thin adapter layer: they translate engine events
|
||
into `WorkerUpdate`s and `WorkerCommand`s into engine calls, honoring the
|
||
existing single-worker pattern. They depend on `crates/*`; engines never depend
|
||
on them.
|
||
|
||
### `src/runtime/` — local job scheduler + engine wiring
|
||
|
||
| Path | Responsibility |
|
||
|------|----------------|
|
||
| `mod.rs` | Runtime barrel; boots engines, owns the local job scheduler handle. |
|
||
| `bootstrap.rs` | Initialize engines (ffmpeg, hardware, project db, CAS) at startup. |
|
||
| `scheduler.rs` | Local scheduler bridging `rf-jobs` phases into `WorkerUpdate::Progress/Complete/Failed`. |
|
||
| `commands.rs` | New `WorkerCommand` variants (additive): `StartCapture`, `LocalRender`, `RunComfyGraph`, `ImportAssets`, `RunBatch`, `OpenProject`, `SaveProject`, `InstallPlugin`, `AddNode`. |
|
||
| `updates.rs` | New `WorkerUpdate` variants (additive): `NodeState`, `CaptureState`, `RenderProgress`, `BatchProgress`, `AssetImported`, `ProjectLoaded`, `PluginState`. |
|
||
| `dispatch.rs` | Route new commands to the right engine off the render thread. |
|
||
| `job_bridge.rs` | Map `LocalJob` ↔ existing `JobSnapshot`/`JobKind` so the library view shows local jobs uniformly. |
|
||
|
||
### New per-engine GUI glue barrels
|
||
|
||
| Path | Responsibility |
|
||
|------|----------------|
|
||
| `src/render/mod.rs` | GUI adapter for `rf-render`: submit render/export, stream progress. |
|
||
| `src/render/burn_preview.rs` | Local burn preview: "$0 wallet (local GPU)" vs cloud cost, keepers-left. |
|
||
| `src/comfy/mod.rs` | GUI adapter for `rf-comfy`: connect, pick workflow, run, stream. |
|
||
| `src/comfy/settings.rs` | Manage ComfyUI path/host/model roots (non-secret prefs; extends `config/`). |
|
||
| `src/capture/mod.rs` | GUI adapter for `rf-capture`: source picker, arm/stop, permission prompts. |
|
||
| `src/assets/mod.rs` | GUI adapter for `rf-assets`: drop handling, import progress, library queries. |
|
||
| `src/project/mod.rs` | GUI adapter for `rf-project`: open/save, autosave wiring, history. |
|
||
| `src/clipfarm/mod.rs` | GUI adapter for `rf-clipfarm`: batch config, launch, throughput. |
|
||
| `src/plugins/mod.rs` | GUI adapter for `rf-plugins`: install, enable, permission consent. |
|
||
| `src/sync/mod.rs` | GUI adapter for `rf-sync`: online/offline banner, reconcile status. |
|
||
| `src/hardware/mod.rs` | GUI adapter for `rf-hardware`: capability badges, throttle state. |
|
||
| `src/ffmpeg/mod.rs` | GUI first-run ffmpeg setup flow wiring `rf-ffmpeg`. |
|
||
|
||
### New GPUI view subtrees (appended under existing `src/ui/`)
|
||
|
||
| Path | Responsibility |
|
||
|------|----------------|
|
||
| `src/ui/console/mod.rs` | Operator-console view barrel (the desktop "power" workspace). |
|
||
| `src/ui/console/queue.rs` | Live local job/render queue with per-job progress + cancel. |
|
||
| `src/ui/console/nodes.rs` | Render-farm node panel (local + LAN peers, capacity, health). |
|
||
| `src/ui/console/throughput.rs` | Throughput/ETA/cost-saved dashboard. |
|
||
| `src/ui/capture/mod.rs` | Capture panel barrel. |
|
||
| `src/ui/capture/source_picker.rs` | Display/window/region/webcam picker + preview. |
|
||
| `src/ui/capture/controls.rs` | Arm/record/pause/stop + countdown + hotkeys. |
|
||
| `src/ui/capture/permissions.rs` | Permission-state prompts and remediation links. |
|
||
| `src/ui/comfy/mod.rs` | ComfyUI panel barrel. |
|
||
| `src/ui/comfy/connection.rs` | Connect/launch + health + version display. |
|
||
| `src/ui/comfy/workflow_picker.rs` | Pick pinned workflow@version + input overrides. |
|
||
| `src/ui/comfy/model_browser.rs` | Local weights browser with license-class badges. |
|
||
| `src/ui/comfy/vram_meter.rs` | VRAM/thermal live meter. |
|
||
| `src/ui/batch/mod.rs` | Clipfarm batch-matrix view barrel. |
|
||
| `src/ui/batch/source_config.rs` | Choose CSV/sheet/reddit/rss source + preview rows. |
|
||
| `src/ui/batch/matrix_editor.rs` | Configure template × hook × aspect × account axes. |
|
||
| `src/ui/batch/run_monitor.rs` | Batch run monitor: per-row status, retry, partial resume. |
|
||
| `src/ui/assets/mod.rs` | Asset library view barrel. |
|
||
| `src/ui/assets/dropzone.rs` | Drag-drop target + import progress. |
|
||
| `src/ui/assets/grid.rs` | Content-addressed library grid with scrub thumbnails. |
|
||
| `src/ui/assets/inspector.rs` | Asset metadata/tags/loop-metadata inspector. |
|
||
| `src/ui/projects/mod.rs` | Project browser view barrel. |
|
||
| `src/ui/projects/list.rs` | Local projects list + open/new/duplicate. |
|
||
| `src/ui/projects/history.rs` | Revision/version-history panel + revert. |
|
||
| `src/ui/plugins/mod.rs` | Plugin manager view barrel. |
|
||
| `src/ui/plugins/catalog.rs` | Installed + marketplace plugin catalog. |
|
||
| `src/ui/plugins/permissions.rs` | Per-plugin permission consent UI. |
|
||
| `src/ui/export/mod.rs` | Export dialog barrel. |
|
||
| `src/ui/export/target_picker.rs` | Choose platform targets + watermark-safe options. |
|
||
| `src/ui/export/progress.rs` | Multi-variant export progress + open-in-finder. |
|
||
| `src/ui/sync/status_bar.rs` | Online/offline + reconcile status strip (extends existing shell). |
|
||
|
||
---
|
||
|
||
## 16. Key data models & APIs (new)
|
||
|
||
### 16.1 Local job envelope (the spine)
|
||
|
||
```
|
||
LocalJob { id, kind, spec_hash, inputs[], priority, deadline?, lease? }
|
||
JobPhase = Queued | Leased | Running | Uploading | Complete | Failed | Canceled
|
||
ProgressTick { fraction: f32, stage: &str, eta_ms: u64, throughput: Throughput }
|
||
```
|
||
|
||
Bridged 1:1 into the existing `WorkerUpdate::Queued/Progress/Complete/Failed`
|
||
so local render, ComfyUI, capture, and cloud jobs render identically in the
|
||
library/queue.
|
||
|
||
### 16.2 `.reelforge` bundle (offline project file)
|
||
|
||
Zip container: `manifest.json` (schema-versioned header), `timeline.json`,
|
||
`shots/`, `characters/`, `asset-refs.json` (CAS hashes only — bytes live in the
|
||
content store, never embedded), `revisions/` append-only log. Registered as an OS
|
||
file type so double-click opens the app.
|
||
|
||
### 16.3 New `WorkerCommand` / `WorkerUpdate` variants (additive)
|
||
|
||
Extends the existing enums in `workspace/commands.rs` — old variants unchanged.
|
||
`StartCapture`, `LocalRender`, `RunComfyGraph`, `ImportAssets`, `RunBatch`,
|
||
`OpenProject`, `SaveProject`, `InstallPlugin`, `AddNode` (commands);
|
||
`NodeState`, `CaptureState`, `RenderProgress`, `BatchProgress`, `AssetImported`,
|
||
`ProjectLoaded`, `PluginState` (updates).
|
||
|
||
### 16.4 On-device API/MCP surface (`devd`)
|
||
|
||
Loopback + optional LAN. MCP tools: `start_capture`, `local_render`,
|
||
`comfy_run`, `list_nodes`, `run_batch`, `import_assets`. Auth by loopback token;
|
||
LAN nodes pair explicitly. This makes the desktop an **agent-controllable render
|
||
appliance**.
|
||
|
||
### 16.5 Node↔coordinator protocol (`rf-devproto`)
|
||
|
||
Length-prefixed, version-tagged envelopes over loopback (GUI↔devd) and TLS
|
||
(LAN nodes): `LeaseRequest`, `LeaseGrant`, `ProgressEvent`, `ArtifactReady`,
|
||
`Heartbeat`, `Release`.
|
||
|
||
---
|
||
|
||
## 17. Integration seams into what already exists
|
||
|
||
| Existing seam | How new work attaches |
|
||
|---------------|-----------------------|
|
||
| `workspace/worker.rs` single owner | Engines are owned by the worker (or the shared `devd`), never by the UI. New commands dispatch to engines off-thread; results become `WorkerUpdate`s. |
|
||
| `workspace/reducer.rs` → `DesktopState` | New updates reduce into new `DesktopState` sub-snapshots (queue, nodes, capture, batch, project) consumed by new views. |
|
||
| `api/` (`/api/v1` only) | Cloud handoff (publish/schedule/register artifacts, wallet checks) goes through `api/`; **no backend engine imports**, unchanged rule. `rf-comfy`/`rf-render` talk to *local* ComfyUI/ffmpeg only, never the product API. |
|
||
| Upload handshake (presign→PUT→register) | `rf-sync/artifact_upload.rs` reuses the exact handshake for locally-rendered masters. |
|
||
| `security/` credential store | Any LAN pairing tokens / plugin signing keys route through the OS credential store; never written to prefs. |
|
||
| `config/` non-secret prefs | ComfyUI path/host, node roster, cache budgets, capture defaults extend the persisted-prefs pattern (atomic write, no secrets). |
|
||
| `media/` selection/probe | `rf-assets`/`rf-encode` supersede the ad-hoc probe for heavy paths; `media/probe.rs` stays for the light upload path. |
|
||
| `domain/JobSnapshot`/`JobKind` | `runtime/job_bridge.rs` maps `LocalJob` into these so local + cloud jobs share one library. |
|
||
| `telemetry/` event vocabulary | New events (capture_started, local_render_completed, batch_run, node_joined, plugin_installed) extend the existing vocabulary. |
|
||
| Genre shot-templates / caption presets (cloud) | Desktop consumes template + caption JSON from `/api/v1`; `rf-render/compose/captions.rs` only *styles/burns*, keeping ASR server-side. |
|
||
| `electron-legacy/` | Untouched, frozen, excluded from build + packaging. |
|
||
|
||
---
|
||
|
||
## 18. Phasing
|
||
|
||
**Phase D1 — Local export foundation (fastest ROI).**
|
||
`rf-jobs`, `rf-ffmpeg`, `rf-encode`, `rf-hardware`, `rf-render` (compose+export
|
||
single-node), `src/render` glue, `ui/console/queue`, `ui/export`. Outcome:
|
||
watermark-safe per-platform masters render locally at $0 wallet.
|
||
|
||
**Phase D2 — Offline project store + drag-drop assets.**
|
||
`rf-assets` (+CAS), `rf-project` (bundle+db+autosave), `src/assets`/`src/project`
|
||
glue, `ui/assets`, `ui/projects`. Outcome: offline-first editing with a local
|
||
content-addressed library and `.reelforge` files.
|
||
|
||
**Phase D3 — Capture + ComfyUI local host.**
|
||
`rf-capture` (platform backends), `rf-comfy` (bridge+workflows+models+vram),
|
||
`src/capture`/`src/comfy` glue, `ui/capture`, `ui/comfy`. Outcome: BYO-GPU
|
||
generation and native screen/webcam capture for avatar-PiP + gameplay B-roll.
|
||
|
||
**Phase D4 — Bulk clipfarm + render farm + sync.**
|
||
`rf-clipfarm`, `rf-render/farm/*`, `rf-sync`, `src/bin/render-node`,
|
||
`ui/batch`, `ui/console/nodes`, `ui/sync`. Outcome: hundreds of daily reels
|
||
across a LAN pool, reconciled to cloud and handed to publishing.
|
||
|
||
**Phase D5 — Plugin host, device MCP, auto-update.**
|
||
`rf-plugins`, `rf-devproto`, `src/ipc` (`devd` + MCP), `src/bin/devd`,
|
||
`src/bin/comfy-node`, `src/bin/rfctl`, `src/updater`, `ui/plugins`, packaging.
|
||
Outcome: extensible, agent-controllable render appliance with signed updates.
|
||
|
||
---
|
||
|
||
## 19. Testing & quality (per rules)
|
||
|
||
Each engine crate ships `tests/` with unit + integration coverage (deterministic
|
||
via injected `rf-jobs/clock.rs`), and `crates/rf-testkit` provides shared
|
||
fixtures (fake ffmpeg, fake ComfyUI server, sample bundles, temp CAS). Golden
|
||
tests validate export presets (dimensions/fps/GOP) and loop-seam detection.
|
||
Target ≥80% on engine crates; GUI glue verified via reducer snapshot tests.
|
||
|
||
| Path | Responsibility |
|
||
|------|----------------|
|
||
| `crates/rf-testkit/src/lib.rs` | Shared test fixtures barrel. |
|
||
| `crates/rf-testkit/src/fake_ffmpeg.rs` | Deterministic fake ffmpeg emitting scripted progress. |
|
||
| `crates/rf-testkit/src/fake_comfy.rs` | In-process fake ComfyUI HTTP/WS server. |
|
||
| `crates/rf-testkit/src/fixtures.rs` | Sample projects, assets, batch CSVs. |
|
||
| `crates/rf-testkit/src/temp_env.rs` | Temp CAS/db/cache scaffolding. |
|