Brokkr/docs/live-collab-target.md
Meta Vens 861edd3195 Stop: a sink-off add-on answers arriving intents stopped; Agents under Stop; pending zero after Stop; survivors pinned
Soul s1: post-stop-queue-runs (ruling sink-off-answers-stopped), agents-section-buried, pending-stale-after-stop,
stop-survivors-unpinned. The live harness now sends a concurrent burst with the sink on, cuts it with Stop, and
shows a later send answered stopped at once (wait exit 3) with nothing firing on re-enable.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-27 21:53:10 +01:00

21 KiB

Brokkr live collaboration: target

Campaign brokkr-live (Nibu's mind). Working branch nibu/live-collab-target, base origin/main 5e279b2. This document holds the rationale, the design truths the campaign produces, and the identity, lifecycle and authority table. The typed target in the mind holds the labelled invariants and the not-in-scope list; the text below is their source. Revision 2 adds phase two (the authoring surface) and takes in the operator's rulings of 2026-11-27.

Rulings in force: brokkr-live:ruling:no-free-form-python, :act-then-undo, :scene-last-writer-wins, :brokkr-ctl-blender-built-here, :cc-is-hull-authority-scene-pushes-deltas.

Why

Operator, 2026-11-27: Brokkr "is meant to give an agent hands into the same Blender scene I'm looking at, enabling live collaboration work". Her original vision for it: "use Blender as an authoring environment, since it exposes typed access to all of the assets we need over CultMesh. Certain collections within the Blender scene would mirror their data into the exact documents Aetheria needs for its ships."

So the campaign has two phases. Phase one makes the live session a collaboration: the agent's edits are undoable and attributed, she can stop it, and it sees what she sees. Phase two makes the scene an authoring surface over a ship's .cc: scene collections map to the ship's records, the scene opens from the .cc at a known revision, and pushes go back through AetherDb.

Brokkr already runs inside her live Blender: a depsgraph_update_post handler publishes a host snapshot and a persistent 1 s bpy.app.timers callback drains command intents (surfaces/blender/brokkr_bridge/__init__.py:610-647, :668-671). What it lacks: an agent edit is not an undo step (nibu-body:research:blender-live-collab.brokkr-undo); nobody can tell who made an edit (.brokkr-attribution-gate); the human can stop an agent only by unticking a preference; the agent sees names and counts, not the viewport or the Edit Mode selection (.brokkr-perception); and the agent has no hands, since brokkr-ctl has no source (.brokkr-no-agent-surface). Its strengths stay: typed, validated actions with no free-form Python, path confinement, loopback bind and an optional session token (.brokkr-security).

Prior art the design stands on

  • mcp-for-blender's UserEditRecorder (.mcp4b-human-edits): the agent learns what the human did between its actions. We keep the idea as snapshot fields, without a trajectory log.
  • blender-copilot (.copilot-undo-cancel): one undo step per agent turn, a Stop button, visible turns and an undo receipt, no approval gate. Its Stop cannot interrupt a blocking native call; ours cannot either.
  • Multi-User (.humans-multiuser, .humans-others): presence of the other party. We show presence in a panel; human-to-human replication is theirs.
  • Blender Lab MCP and mcp-for-blender (.lab-official, .mcp4b-perception-safe): viewport screenshots as perception. Their arbitrary-code path is refused here (no-free-form-python).
  • ceeyang/blender_mcp (.ceeyang-159): 159 typed tools, every write undoable; a typed vocabulary can be wide.
  • Aetheria's ship package path (Aetheria origin/master 6702b01bf, packager on nibu/hull-packager 7101b5cec): AetherDb ship-authoring (create, stats, price, product, regenerate with a dry-run default, validate, inspect) loads a ship.cc through the game's own types; tools/blender/package_hull.py drives the aetheria_ships add-on and AetherDb from a manifest; tools/blender/aetheria_ships/ship_cc.py reads and writes ship.cc envelopes directly, with a layout revision hash for its layout write.
  • CultCache compare-exchange and element ids (CultLib origin/main baf4ecf7, src/GameCult.Caching/CultCache.cs:2228-2235 Expect/ExpectUnchanged; CultElementIds.cs). HardpointData.Id is a [CultElementId] (Aetheria Assets/Scripts/ServerShared/ItemData.cs:648).

What probing established

Blender 5.3.0, Starfire, GUI, --factory-startup, each step in its own timer tick. Scripts in docs/research/live-collab/. Research notes brokkr-live:research:live-collab-probes.*.

  1. An unpushed write from a timer is not an undo step and survives undo; the next push absorbs it, so it is misattributed (.timer-undo, case A).
  2. An explicit ed.undo_push from a timer makes a correct step, and undo and redo walk it (case B).
  3. UNDO-flagged operators push their own step; called ("EXEC_DEFAULT", False) they push none, and one explicit push covers several (cases C, E). This is how one intent becomes one step.
  4. Edit Mode: an agent bmesh write plus push is reverted by one undo, which also left the Edit Mode the agent had entered (case D).
  5. Driving ed.undo/ed.redo from code crashed Blender 2 of 2 times in the long sequence, in UI draw after a memfile undo (.programmatic-undo-crash).
  6. The agent can see her view: screenshot_area on her 3D view, median 72.5 ms at 1574x888, about 609 KB, popups included; Edit Mode selection reads live without leaving Edit Mode (.look-capture).
  7. Depsgraph updates from an agent edit arrive inside the timer turn and name indirect dependents; after an undo every object is listed and only the transform and geometry flags show what changed (.depsgraph-timing).
  8. cultcache-rs writes the add-on's single-file .ccmp under the shared lock, and a live cultmesh-py node pulls Rust writes; no runtime has a directory store (.rust-store-writer).

Not yet probed, owed before the cut that depends on it: the latency of one AetherDb ship-authoring call on Starfire (phase two decides between a CLI call per push and a resident service on that number); reading a record's stored version through AetherDb.

Phase one: the live session

One agent turn primitive. Every agent mutation in Blender goes through one function in the add-on: admit (sink enabled, requestedBy present, id unused, action typed and valid), run the action with every operator called undo=False, push exactly one undo step labelled Brokkr <requestedBy>: <action> <commandId[-8:]>, write the receipt. A refusal caught before any write pushes nothing and leaves the scene unchanged; an action that fails after writing pushes one step labelled (failed), so the partial write is one undoable step. There is no second writer and no script action (no-free-form-python): what the typed actions do not cover waits for a new typed action.

The agent acts; the human undoes (act-then-undo). Admitted intents apply without asking. Blender's one linear undo stack is the shared history; agent steps sit in it, labelled, between hers, and she takes them back with Ctrl+Z. The agent never calls ed.undo or ed.redo (probe 5); it backs out by sending a compensating intent.

Last writer wins in the scene (scene-last-writer-wins). An agent intent applies even if she changed the scene since the agent looked. Her edit is never lost: it stays in the undo history below the agent's step, and one Ctrl+Z takes the agent's step back. This is scene-level only; the .cc keeps its revision refusal (phase two).

Stop is one control, and only the human holds it. Stop turns the command sink off and gives every pending intent a stopped receipt without running it. An action already running finishes as one undo step, so Stop plus Ctrl+Z always returns her scene. No intent can turn the sink on; intents queued before Stop never run, and an intent that arrives while the sink is off gets a stopped receipt at once (brokkr-live:ruling:sink-off-answers-stopped), so nothing queues to fire on re-enable.

The agent sees her view and her edits. look is a read intent: it captures her 3D view to a scratch PNG named by command id (brush-tree:ruling:look-files-are-scratch) and returns the path. The snapshot gains the Edit Mode selection, a Blender session id, and human-edit sequence numbers (a session counter and, per object, the last sequence at which she changed it, from depsgraph updates outside agent turns and flagged transform, geometry or shading). These tell the agent what she did since it last looked; they gate nothing.

Presence is derived. The panel shows active agents, the running or last intent with its one-line note, and recent receipts with their undo labels, read from the intent and receipt documents.

Hands are a CLI (brokkr-ctl-blender-built-here). brokkr-ctl blender is a Rust binary in this repo (brush-tree:ruling:fitting-home-ruled) that writes intents and reads receipts and snapshots in the add-on's single-file store (probe 8), prints plain text or paths, and whose --help is the schema (brush-tree:ruling:cli-not-mcp, :help-is-the-schema). It owns no state, policy or ledger. Libby's brush-tree adds its tree commands to the same binary later.

Phase two: the authoring surface

The .cc is the authority; the scene is a surface over it (cc-is-hull-authority-scene-pushes-deltas). A ship's records live in its ship.cc: HullData, ShipAuthoring (model asset, anchors, schematic lines) and its product records (ShipAuthoringStore.Load returns exactly these three). A Blender scene may be bound to one ship.cc as its authoring surface. The scene never becomes truth: it is an edit buffer that opens from the store and pushes back to it.

Collections carry roles. Scene collections are tagged with the role they author: hull shape (the hull source and its raster), hardpoint rows (one object per row, carrying aetheria.id, the HardpointData element id, and its kind, cell, footprint, rotation, armor and arc), schematic lines, and anchors. Stats, price and product live on the binding. These are the fields the packager manifest already names (tools/blender/package_hull.md), so the manifest and a push describe a ship in one vocabulary.

Open reads through the game's code. Opening runs AetherDb ship-authoring to read the three records and their stored versions, builds the tagged collections, and records on the binding the version of each record it read. Nothing reads a .cc by scraping envelopes (operator 2026-11-17).

A push is one AetherDb call, dry-run then apply. The surface pipes the authoring state of its tagged collections (the manifest vocabulary, plus the record versions it opened at) as a structural JSON dump on stdin to AetherDb ship-authoring push <ship.cc>, as the material path does (aetheria-release:ruling:blender-dump-stdin): never written to disk, parsed and judged only in C#, so the schema exists once. Without apply AetherDb loads the store, derives the records the request describes, validates them, and prints the per-record, per-field changes; nothing is written. With apply it does the same and writes under compare-exchange on each record's stored version (Expect). One CLI call per push is the starting shape; a resident service is built only if the measured latency of that call demands it.

A stale revision is refused, never merged. If any record changed in the store since the scene opened it (another push, a CLI stats call, a packager --replace), the push is refused with the records named; the surface reopens and the author re-applies. On a successful apply the binding takes the new versions.

One owner turns a hull into records. AetherDb's ship-authoring code (C#, the game's own types) is the only code that derives HullData, ShipAuthoring and product records from authoring input, and the only writer of .cc stores. The packager and the authoring surface both call it. The direct envelope writes in aetheria_ships/ship_cc.py (replace_lines, replace_visual, replace_layout, and the first Save Layout that creates ship.cc) and its layout_revision hash are demoted: ship_cc.py keeps no write path and no revision of its own, and package_hull.py's Save Layout steps become push calls. Whether the request is the delta of the ruling, or a whole-record replace, is fork Q5 below.

The agent's hands reach the surface through typed actions. Open, push dry-run and push apply are typed Brokkr actions like any other, admitted by the same primitive; a push changes no scene state and so pushes no undo step. Whether an agent may apply, not only dry-run, is fork Q7.

Variants and CultNet deltas: not the push primitive today

The coordinator asked whether Libby's variants delta records, or CultNet's deltas, are the primitive for the push.

  • Variants (variants target, Libby's mind): a variant is a persisted record stored as a base reference plus sparse overrides (CultVariantDelta, CultVariantOverride with Set/Insert/Remove at slot plus element-id paths, src/GameCult.Caching/CultVariants.cs:56-112), resolved by the cache at load, and a plain upsert at a variant's key is refused (variants:ruling:q1-refuse-plain-upsert). It describes a second document defined against a base, not a change to the base. Its nested paths and Insert/Remove are unbuilt (variants:follow_up:remaining-variant-cuts, C2b), C# alone resolves it, and Aetheria catalog content is out of its scope.
  • CultNet (contracts/cultnet/): the wire has whole-document document-put and document-put-raw, document-delete, and database-change-raw (added, updated, removed, with the whole document and a commit id). There is no delta message. The "delta" in cultnet-rs/src/replication.rs:97,789-829 and cultmesh-py/node.py:1649-1660 is a client-side reconciliation diff (predicted minus canonical, per top-level slot, numeric subtraction) handed to the caller to smooth a prediction; it is never sent.
  • One mechanism? Not today. They are two unrelated things that share a word. The operator's recollection matches the plan, not the code: variants' fork ruling 4 (cultnet-deltas) says variants travel on CultNet as deltas, and variants:ruling:hop-subscriptions-refuse-variants holds CultNet off variants until that cut (C5) lands. When it does, the override vocabulary will be both the stored variant and the wire delta.
  • Consequence for the push. The push invents no delta format. Its addressing is the variants override vocabulary (slot plus element id; HardpointData.Id is already a [CultElementId]) when CultLib can apply overrides to a record in place; until then it is a whole-record replace of the records that changed, guarded by Expect. Fork Q5.

Authority map

  • Owner. Phase one: the add-on's agent turn primitive owns whether and how an agent intent changes the live scene; Blender owns scene truth and the undo stack; the human owns the sink toggle, Stop and undo. Phase two: the ship.cc owns the ship; AetherDb's ship-authoring code alone derives and writes its records.
  • Inputs. Intent documents and the sink toggle (phase one). The tagged collections, the binding's opened versions and the stdin dump (phase two).
  • Outputs. One undo step per accepted mutating intent; one receipt per intent; the refreshed snapshot; look PNG paths; AetherDb's dry-run diff or its write.
  • Derived state. Presence; human-edit sequences; look PNGs; the scene's mapped collections (an edit buffer over the .cc); the stdin dump (a pipe, not state).
  • Forbidden writers. execute_command called around the primitive; operators run with undo on inside an agent action; unpushed agent writes; ed.undo/ed.redo from add-on code; any agent-sent Python; any reader that turns a file under the debug-mirror root into an intent (removed in cut-live-1); brokkr-ctl deciding anything; ship_cc.py's envelope writes and any other direct .cc writer; layout_revision as a revision.
  • Shared paths. brokkr-ctl intents, panel buttons that act on the scene, sync-organ intents and replayed intents use the one primitive. The packager, the authoring surface's buttons and an agent's push intent use the one AetherDb push.
  • Deletion line. The debug-mirror intent import goes before the primitive lands; drain_commands stops calling execute_command directly. ship_cc.py's write functions and layout_revision go when the push lands.

Identity, lifecycle and authority

Persistent kind What names it What happens to it over time Who decides
Blender command intent brokkr.blender.command_intent.v0 (gains requestedBy, note) blender/commands/{commandId}; ids single-use, minted by the writer (brush-tree:ruling:blender-sink-mirrors-unity) Written once by a caller. Executed at most once or refused. Removed when its receipt is written. Never rewritten. Callers write. The agent turn primitive alone decides admission and execution.
Blender command receipt brokkr.blender.command_receipt.v0 (gains requestedBy, outcome in accepted, denied, stopped, failed, undoLabel, lookPath) blender/receipts/{commandId}, one per intent Written once, after the primitive decides. Pruned by count with Unity's cap and prune rule. The primitive alone. Callers and the panel read.
Agent identity requestedBy <mind>/<agent> stated by the caller Carried on each intent into its receipt and undo label; not stored on its own. The caller states it; the primitive refuses an intent without it. The session token proves admission, not identity.
Agent undo step Blender undo entry Brokkr <requestedBy>: <action> <commandId[-8:]> One per accepted mutating intent; lives as Blender's stack does; never persisted by Brokkr. Blender owns the stack; the primitive pushes; only the human undoes or redoes.
Blender session id uuid minted at add-on register and on each load_post Replaced when Blender restarts or a file loads. The add-on alone.
Human-edit sequences (snapshot: humanEditSeq, per-object lastHumanEditSeq) Integers within a session id Monotonic within a session; reset with it. Information for the agent; they gate nothing. The add-on's depsgraph and undo handlers alone.
Host snapshot brokkr.blender.host_snapshot.v0 (gains Edit Mode selection, session id, sequences, sink state, authoring binding summary) blender/host/current, overwritten Refreshed on depsgraph update and after each intent. The add-on alone.
Command sink toggle (auto_drain_commands) Add-on preference, echoed in the snapshot Off by default. Stop turns it off; only the human turns it on. The human only.
Look PNG <scratch>/look/{commandId}.png Pruned by count; never read back as truth. The primitive writes; look-files-are-scratch governs.
Ship package store ship.cc (HullData, ShipAuthoring, product records) Its path, GameData/Mods/<ship id>/ship.cc; records by their keys Created by ship-authoring create; changed only by AetherDb commands, each write minting new stored versions (variants:ruling:storedat-on-change); replaced whole only by packager --replace. AetherDb's ship-authoring code is the only writer.
Record version The version CultCache's compare-exchange tests for each record key Changes on every write that changes the record's bytes. CultCache mints it; AetherDb reports it on open and tests it on apply.
Authoring binding A custom property on the Blender scene: the ship.cc path relative to the .blend, the ship id, and the record versions opened at Set on Open; versions replaced after each successful apply; cleared on Detach or reopen. Lives in the .blend. Open, apply and Detach (human buttons or agent actions through the primitive) alone write it.
Collection role A custom property on a collection: hull, hardpoints, lines or anchors Set when the surface builds or the author tags a collection; removed on Detach. The author; the surface's Open builds the defaults.
Hardpoint row identity aetheria.id on the row's object, equal to HardpointData.Id ([CultElementId]) Minted when the row is created; survives renames and moves; removing the object removes the row on the next push. AetherDb mints for a new row; the surface carries it.

Not in scope

Human-to-human replication or several Blender instances in one session. Agents on another host reaching the operator's Blender. Per-user or selective undo. An approval gate (act-then-undo). Stale-action refusal inside the live scene (scene-last-writer-wins). Any agent-sent Python (no-free-form-python). A 3D-view presence overlay. The Unity surface and brokkr-command. The brush-tree vocabulary, Geometry.Csg and OpenSCAD text (brush-tree owns them). Agent-initiated save and quit. Asset libraries and generators. An MCP server. Records outside a ship package (catalog loadouts, factions) unless Q6 rules them in. A new delta wire format.

Open forks (draft questions; Self admits)

  • Q5. What a push carries. (a) whole records that changed, under Expect, now; (b) variants override paths applied in place, after CultLib builds in-place apply and C2b; (c) (a) now with the request shaped so (b) replaces it without changing the surface. Recommend (c).
  • Q6. Does a ship's loadout belong in its package? A package holds hull, authoring and products today; loadouts are catalog records. Recommend not in r2.
  • Q7. May an agent apply a push, or only dry-run? A .cc write has no Ctrl+Z. Recommend dry-run for agents, apply by her button.
  • Q8. Where the authoring surface lives. (a) the aetheria_ships add-on in Aetheria, with Brokkr giving the agent typed actions that call it; (b) Brokkr's add-on gains Aetheria vocabulary. Recommend (a).