Model dev channel
Status: current contract (Pygmalion G §9, §10, §11.4; built in delivery step 8). Native and browser games, Blockbench (desktop and web) and the Blender add-on speak it. In singleplayer the in-process server follows each applied package too (see Singleplayer server).
The dev channel carries saves from a modelling tool into running games on either host within seconds, and the games’ diagnostics back to the tool. It is the browser’s only hot reload. Artists use it through the tools; this page is the protocol and security reference. The workflow is in the model assets guide.
Topology
A browser page cannot listen on a socket and web Blockbench cannot write files, so every party connects to a relay as a client:
Blockbench (desktop or web) ─┐ ┌─ native game
Blender add-on ──────────────┼── ws://127.0.0.1 ───┼─ browser game tab
Asset Lab (in a game) ───────┘ relay └─ more games
│
assets root on disk (atomic writes)
| Party | How it runs |
|---|---|
| Relay | cargo mod dev [root] [--port 47801] [--open [url]] [--allow-origin <origin>], or embedded in a native game started with --dev-channel (or MANIFOLD_DEV_CHANNEL=1) when nothing listens on the port and MANIFOLD_ASSET_DEV_DIR names the root |
| Native game | --dev-channel / MANIFOLD_DEV_CHANNEL=1; port from MANIFOLD_DEV_CHANNEL_PORT, else <dev root>/.manifold-dev/port, else 47801; token from MANIFOLD_DEV_CHANNEL_TOKEN, the embedded relay, or <dev root>/.manifold-dev/token |
| Browser game | cargo mod dev --open [url] opens the build with #dev_channel=ws://127.0.0.1:<port>/&dev_token=<token> in the URL fragment, which no server receives; web/dev-channel.js dials it (loopback ws:// only) |
| Blockbench | Tools → Manifold Dev Channel…; desktop reads the token file under the assets root, web asks for the token |
| Blender | Sidebar → Manifold → Dev Channel → Connect; a background thread owns the socket and a bpy.app.timers callback drains it on the main thread |
The relay writes <root>/.manifold-dev/token (readable by the current user
only) and <root>/.manifold-dev/port when it starts; the token is new on every
start.
Wire format
Every message is one binary WebSocket frame: a little-endian u32 header
length, a JSON header, then an optional raw payload (GLB bytes, or a packed
pose). JSON keeps the JavaScript and Python clients trivial; the raw payload
carries multi-megabyte GLBs without base64. Headers are capped at 4 MiB and
payloads at 64 MiB. type names the message in snake case; optional fields
may be omitted.
| Message | From → to | Fields (payload) |
|---|---|---|
hello | any → relay, first | role (tool, game, lab), name, protocol (1), token |
welcome | relay → peer | session, protocol, assets_root, peers (session, role, name) |
put_package | tool → relay | request_id, id, fragment (an exporter fragment, merged) or recipe (whole text), base_recipe_hash (GLB) |
put_recipe | lab or tool → relay | request_id, id, recipe, base_recipe_hash |
result | relay → putting peer | request_id, id, written, glb_hash, recipe_hash, epoch, diagnostics (the cargo mod validate --json schema-1 document), refused (superseded, stale-base, missing, io), recipe (the recipe now on disk) |
package_changed | relay → games and labs | id, epoch, glb_hash, recipe_hash, recipe (GLB) |
fetch | game or lab → relay | id, or none for every model written in this relay session |
package | relay → fetching peer | as package_changed; epoch 0 when not written this session (GLB) |
applied | game → relay → tools and labs | id, epoch, ok, diagnostics (schema-1 entries), import_ms, visible_ms, local_preview, game (filled by the relay) |
refused | game → relay → tools and labs | id, reason (permission, remote-session, stale-epoch), game |
navigate | game or lab → tools | id, source (a diagnostic’s {kind, name, clip}) |
focus | tool → games and labs | id, object |
pose | tool → games and labs | id, layout, joints (names, when the layout changes) (40 bytes a joint) |
timeline | tool → games and labs, or game/lab → tools | id, clip, time, playing |
ping / pong | any | every 5 s; a peer silent for 15 s is dropped |
error | relay → peer | message; before welcome the relay then closes |
Hashes are 16 lowercase hex digits of FNV-1a 64 over the bytes
(manifold_model::authoring::hash_hex): deduplication, not security.
Flow
- The tool exports on command, or on save (debounced 300 ms).
- While a put for a model is queued, a newer one replaces it; the replaced
put is answered
superseded, so a burst of saves costs one merge. - The relay merges the fragment into the recipe on disk
(
manifold_model::authoring::merge_recipe; merging never loses authored work, so a stalebase_recipe_hashis fine here), validates the package with the runtime importer, and always writes it, GLB then recipe, each through<file>.tmpand a rename. Disk holds the artist’s latest export; a recipe the merge cannot parse is never rewritten (MODEL015). - The relay answers
resultand sendspackage_changedwith the model’s next epoch, which counts up within the relay session. A game ignores an epoch older than the one it holds (refused: stale-epoch). - Each game imports from the pushed bytes with the poller’s keep-last-good
rule (
manifold_model::apply_package): an import with errors keeps the last good model. It answersappliedwith its own diagnostics and timings. - The tool shows “visible in 2 games (native game 0.6 s, browser game 1.1 s)”, or the games’ diagnostics.
A game catches up with fetch when it connects. The native poller still
watches MANIFOLD_ASSET_DEV_DIR for edits made without the channel; it skips
the relay’s write of a package the channel already applied (the shared
content hash). The Asset Lab’s Reload fetches the model from the relay.
put_recipe (the Asset Lab’s save) is refused stale-base when the recipe
on disk changed since the lab opened it; result.recipe then carries the
current text, and the lab re-applies its unsaved edits on it and lists the
ones that no longer apply (G §11.4).
Pose streaming and the timeline
While a tool streams (opt-in, at most 30 Hz), pose carries the local
translation, rotation (x y z w) and scale of every joint, 40 bytes each,
little-endian f32, in the order of the joints names sent with the current
layout. Games map joints by node name, because the importer folds static
nodes and orders joints parent-first; a joint whose compiled rest also holds
folded parents gets the tool’s change relative to the node’s own rest
(manifold_client_state::push_model_preview_pose). The pose overrides the
Asset Lab preview and releases 2 s after the last frame, or at once on an
empty payload. Streamed poses are never saved. timeline moves the other
side’s clip and time when the model is the one selected; the Asset Lab sends
it when scrubbed.
Security
- Loopback only. The relay binds
127.0.0.1and::1and drops any other peer address. - Origin allowlist, checked at the handshake: no
Origin(native clients: Blender, the native game),https://web.blockbench.net,file://(Blockbench desktop), loopback pages (http(s)://127.0.0.1|localhost|[::1]with an optional port and nothing after it) and origins given with--allow-origin. Anything else, including a DNS-rebound page, gets 403. - Token. Every
hellocarries the relay’s 128-bit token, compared without an early exit. Loopback is shared by every account on a machine and native clients send noOrigin, so the token is what stops another local user or process. - Roles. Only tools put packages, focus or stream poses; only games and labs fetch, report or navigate.
- Confinement. Ids must parse as
ModelId(no.., no absolute paths), so every write lands under the root; the relay executes nothing it receives. - Games decide. A game applies a package only in singleplayer (as the
local host) or, as a client of a remote server, with operator rights there,
the default of H’s
animation.devnode, which stands in for it until H; any other client answersrefused: permission. A remote client’s changes are its own presentation only (local_preview, shown in the Asset Lab as “local preview, not shared”); the server keeps the agreed content.
Singleplayer server
A package a game applies (keep-last-good, manifold_model::apply_package)
also reaches its singleplayer server’s ServerModelCatalog, so the
authoritative hit volumes, sockets, gameplay events and root motion follow it
(G §9.7, issue 33):
- Native. The shared apply path (the poller under
MANIFOLD_ASSET_DEV_DIRand the channel) hands the imported model to the embedded server:ServerRunHandle::dev_apply_modelsendsTickControl::DevApplyModel, applied between two ticks, and the frame waits up to 500 ms for the answer. - Browser. The page forwards each package it applied to its server
worker (
{ type: 'devModelApply' }on the worker’s control port); the worker imports it with the server profile against the built-in graphs (dev_model_apply_server_worker) and postsdevModelAppliedback. - The rule (
manifold_server_state::anim::apply_dev_model). Only an in-process host reaches it; no network message carries a model. It is refused while any remote peer is connected (the session’s content is shared), and the game’sappliedthen sayslocal_preview. Every awake character running the model drops its graph state and history and restarts at the new model’s entry state, as waking from dormancy does, so clients in scope get anAnimSync; held-item caches naming it re-resolve. Nothing is saved (the catalog and graph state never are), and a live replay recording stops, since the swap is not a journaled input.
Limits
- A model deleted from the dev root leaves the server’s copy in place until a restart; only applied packages are forwarded.
- Browser packages resolve graph assets against the built-in library; native packages against the relay’s assets root, then the dev root.
welcomelists the peers at connect time only.- Web Blockbench reaching a loopback relay may meet a browser local-network permission prompt (G issue 11).
Source and tests
| Part | Source | Tests |
|---|---|---|
| Protocol, relay core, pose packing, Origin and token | crates/manifold-dev-channel/src/{protocol,relay,pose,security}.rs | unit tests in each module |
| Relay server and client (native) | crates/manifold-dev-channel/src/{server,client}.rs | server.rs tests: a put reaching a game and disk; wrong token, Origin and protocol refused |
cargo mod dev | tools/cargo-mod/src/dev.rs | URL fragment test |
| Native game | crates/manifold-host/src/dev_channel.rs, model_platform.rs (server forward) | |
| Singleplayer server update | crates/manifold-server-state/src/anim/reload.rs, crates/manifold-server/src/tick.rs (DevApplyModel), crates/manifold-host-web/src/worker_entry.rs | archetypes.rs test a_live_model_update_restarts_the_characters_running_it |
| Browser game | crates/manifold-host-web/src/driver/dev_channel.rs, web/dev-channel.js | crates/manifold-host-web/e2e/dev-channel.test.mjs |
| Blockbench | tools/blockbench-manifold/manifold_model.js | tools/blockbench-manifold/test/channel.test.mjs |
| Blender | tools/blender-manifold/{ws_client,channel}.py | tools/blender-manifold/tests/test_channel.py |