2026-06-12 12:19:28 +01:00
# Brokkr Unity Adapter
2026-06-12 16:30:41 +01:00
This package lets the Unity Editor publish its scene, component, asset, command,
2026-10-22 20:14:59 +02:00
receipt, and Quest state as typed CultCache documents synced through
2026-06-12 16:30:41 +01:00
CultMesh.
2026-06-12 12:19:28 +01:00
## Install By Local Path
Add this package to a Unity project's `Packages/manifest.json` :
```json
2026-09-29 13:50:23 +02:00
"com.gamecult.brokkr": "file:F:/Projects/Brokkr/surfaces/unity/Packages/com.gamecult.brokkr"
2026-06-12 12:19:28 +01:00
```
2026-09-29 13:50:23 +02:00
The package ships no assemblies. Its CultCache, CultNet and CultMesh runtime
comes from `org.gamecult.cultlib` , which the host manifest must also resolve:
2026-06-12 12:19:28 +01:00
2026-09-29 13:50:23 +02:00
```json
"org.gamecult.cultlib": "https://github.com/GameCult/CultLib.git?path=/unity/org.gamecult.cultlib#cultlib -unity-v1.0.60"
2026-06-12 12:19:28 +01:00
```
2026-06-12 16:30:41 +01:00
Then open `GameCult > Brokkr` .
## Local Smoke
2026-06-12 12:19:28 +01:00
In Unity:
1. Open `GameCult > Brokkr` .
2026-06-12 16:30:41 +01:00
2. Confirm `Broker URI` is `cultmesh://brokkr` .
3. Confirm `CultMesh Cache` points at `.brokkr/unity-editor.ccmp` .
4. Click `Start CultMesh Mirror` .
5. Click `Capture Snapshot` .
6. Click `Publish Mirror` .
2026-09-29 14:49:09 +02:00
7. To create a ScriptableObject through the mirror (tick `Agent Commands` first, and add `createScriptableObject` to `Allowed Actions` ), fill `ScriptableObject Type` ,
2026-06-15 01:24:18 +01:00
`Asset Name` , and `Asset Path` , then click `Create ScriptableObject Asset` .
2026-06-15 01:30:32 +01:00
8. To instantiate or variant a prefab through the mirror, fill `Prefab Asset
Path`, optional ` Instance Name`, and optional ` Variant Path`, then click the
matching prefab command.
2026-06-15 03:20:28 +01:00
9. To publish object sync policy, select a GameObject, set the object lane
toggles including transform, parent, active state, material, and property
lanes, then click `Publish Object Sync` .
2026-09-29 14:49:09 +02:00
10. With the mirror running, run `brokkr-daemon sync-once` or `sync-loop` ; the window
shows the latest daemon
2026-06-15 02:23:55 +01:00
sync pass receipt.
2026-06-15 03:20:28 +01:00
11. To publish an ad hoc sync variable, fill `Ad Hoc Sync Var` with a binding id
2026-06-15 02:37:03 +01:00
or leave it blank for a generated id, set kind/paths/authority/interpolation,
then click `Publish Sync Var` .
2026-06-12 12:19:28 +01:00
2026-06-12 16:30:41 +01:00
The Unity adapter writes the latest editor snapshot to:
2026-06-12 12:19:28 +01:00
```text
2026-06-12 16:30:41 +01:00
unity/host/current
2026-06-12 12:19:28 +01:00
```
2026-06-15 02:23:55 +01:00
Brokkr daemon sync receipts are read from:
```text
sync/receipts/{receiptId}
```
2026-06-15 02:37:03 +01:00
Ad hoc sync variables are written to:
```text
sync/vars/{syncVarId}
```
2026-06-12 16:30:41 +01:00
Verse-side command clients write `brokkr.unity.command_intent.v0` documents to:
2026-06-12 13:26:14 +01:00
```text
2026-06-12 16:30:41 +01:00
unity/commands/{commandId}
2026-06-12 13:26:14 +01:00
```
2026-09-29 14:49:09 +02:00
The editor service pulls the store about once a second while `Agent Commands` is on, admits each intent through the project policy, mutates the editor, and publishes receipts
2026-06-12 16:30:41 +01:00
to:
2026-06-12 13:26:14 +01:00
2026-06-12 16:30:41 +01:00
```text
unity/receipts/{commandId}
2026-06-12 13:26:14 +01:00
```
2026-06-15 01:24:18 +01:00
Recognized Unity asset commands include:
- `instantiatePrefab`
- `createPrefabVariant`
- `createScriptableObject`
2026-06-12 16:30:41 +01:00
The Unity plugin is still an adapter. Unity owns Unity editor truth; Brokkr owns
provider discovery; CultCache and CultMesh own the live mirror lane.
2026-09-29 14:49:09 +02:00
## Agent Commands
The editor executes intents that other processes write into `.brokkr/` only
while `Agent Commands` is ticked in the Brokkr window. It is off for every
project until you tick it, and the host snapshot reports the flag. Nothing
listens on the network: callers reach the editor through the directory store
at `.brokkr/unity-editor.ccmp` .
`Allowed Actions` lists what an agent may run. The default allows scene
mutation and editor lifecycle; `createScriptableObject` , `createPrefabVariant`
and `saveScene` are off until you add them. A refused intent gets a receipt
with `status: denied` . Captures land under `.brokkr/captures/` .
From a shell, with the project's cache path:
```powershell
dotnet run --project F:/Projects/Brokkr/brokkr-command/Brokkr.Command.csproj -- --unity-cache <project>/.brokkr/unity-editor.ccmp --action readHost
dotnet run --project F:/Projects/Brokkr/brokkr-command/Brokkr.Command.csproj -- --unity-cache <project>/.brokkr/unity-editor.ccmp --action createGameObject --name Marker
```
2026-09-29 17:14:52 +02:00
Turning `Agent Commands` on expires every intent already in `.brokkr/` : each
gets a receipt with `status: expired` and none runs, so enabling the sink
Soul pass 3: conditional enable in Runtime, receipt floor, one write path
- The enable commit is conditional (ExpectUnchanged) and lives in the new
Runtime BrokkrCommandStore, with the pull-recompute-retry loop in
BrokkrCommandDrain.EnableAsync, so the tests exercise the shipped code. An
intent landing between the pull and the commit is expired, not run; eight
refusals in a row fail the enable loudly with the sink off. The probe is now
a thin fault-injecting wrapper over the real store, not a copy of it.
- Every editor write to the command lane is one cache commit; durable shard
logs are off (no server, no reader).
- No receipt is pruned before ten minutes, whatever the count, and the CLI
refuses a wait over five minutes. Fixed the comments that claimed otherwise.
- Pending and Prunable count a document only under the key its own id names.
- README and snapshot comment: the token stops stale EditorPrefs, it does not
authenticate writers; a restored or sync-conflict copy of the editor's own
store can rerun answered intents.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-29 17:52:34 +02:00
cannot execute anything you did not see. The expiry is one commit that only
lands if the store is exactly what the editor just read; an intent that arrives
mid-enable makes it read again, and if writers never let the store settle
(eight tries) the enable fails with a message and the sink stays off. Intents
that arrive after the tick are fresh, whatever clock wrote them. With about
2000 waiting intents the tick takes several seconds (the store writes one
receipt each); after that the editor handles at most 16 intents per update
tick.
2026-09-29 17:14:52 +02:00
The tick also writes an enable marker into `.brokkr/unity-editor.ccmp` , and the
editor keeps the matching token in its own preferences. The sink runs only
while the store carries that marker. If you re-clone the project, or copy a
`.brokkr/` folder in, the marker is missing or foreign, so the editor turns the
sink off and logs why; tick `Agent Commands` again to run intents from that
Soul pass 3: conditional enable in Runtime, receipt floor, one write path
- The enable commit is conditional (ExpectUnchanged) and lives in the new
Runtime BrokkrCommandStore, with the pull-recompute-retry loop in
BrokkrCommandDrain.EnableAsync, so the tests exercise the shipped code. An
intent landing between the pull and the commit is expired, not run; eight
refusals in a row fail the enable loudly with the sink off. The probe is now
a thin fault-injecting wrapper over the real store, not a copy of it.
- Every editor write to the command lane is one cache commit; durable shard
logs are off (no server, no reader).
- No receipt is pruned before ten minutes, whatever the count, and the CLI
refuses a wait over five minutes. Fixed the comments that claimed otherwise.
- Pending and Prunable count a document only under the key its own id names.
- README and snapshot comment: the token stops stale EditorPrefs, it does not
authenticate writers; a restored or sync-conflict copy of the editor's own
store can rerun answered intents.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-29 17:52:34 +02:00
store. The token is not authentication and does not identify who wrote an
intent: anyone who can write `.brokkr/` can write intents, and `Allowed
Actions` is what limits them. Restoring a backup, checking out ` .brokkr/` from
git, or a sync-conflict copy of the editor's own store carries a valid marker
and can bring back intents that were already answered, which then run again.
2026-09-29 16:26:17 +02:00
Before the editor runs an intent it writes a receipt with `status: attempted` .
If the editor stops, or cannot record the result, that intent is reported as
2026-09-29 17:14:52 +02:00
`interrupted` and is not run again automatically. Check the project first:
`interrupted` does not say whether the action happened, and some actions are
not idempotent. Re-sending `createGameObject` after an `interrupted` receipt
can create the object twice; a domain reload during `refreshAssets` can also
end as `interrupted` although the refresh completed. If the editor could not
Soul pass 3: conditional enable in Runtime, receipt floor, one write path
- The enable commit is conditional (ExpectUnchanged) and lives in the new
Runtime BrokkrCommandStore, with the pull-recompute-retry loop in
BrokkrCommandDrain.EnableAsync, so the tests exercise the shipped code. An
intent landing between the pull and the commit is expired, not run; eight
refusals in a row fail the enable loudly with the sink off. The probe is now
a thin fault-injecting wrapper over the real store, not a copy of it.
- Every editor write to the command lane is one cache commit; durable shard
logs are off (no server, no reader).
- No receipt is pruned before ten minutes, whatever the count, and the CLI
refuses a wait over five minutes. Fixed the comments that claimed otherwise.
- Pending and Prunable count a document only under the key its own id names.
- README and snapshot comment: the token stops stale EditorPrefs, it does not
authenticate writers; a restored or sync-conflict copy of the editor's own
store can rerun answered intents.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-29 17:52:34 +02:00
write the `attempted` receipt, the intent normally never started and is retried
on the next tick; if the store fails in a way that leaves the marker behind,
it is reported as `interrupted` instead.
Receipts are kept for the newest 1000 answered intents, and no receipt is
deleted before it is ten minutes old, whatever the count (`brokkr-command`
refuses a `--wait-ms` over five minutes, so the receipt a caller waits on is
always still there). Older intents beyond the count are deleted together with
their receipts, at most 128 per tick. A `--command-id` is refused only while
its receipt exists, so an id can be reused after its receipt has been pruned.
2026-09-29 16:26:17 +02:00
`brokkr-command` exits 0 when the receipt is `accepted` , 1 for any other
receipt status (`failed` , `denied` , `expired` , `interrupted` ), and 2 for bad
usage, a timeout, a store that cannot be opened, or any other failure. A
2026-09-29 17:14:52 +02:00
`--command-id` that already has a receipt is refused with exit 2; the check and
the write are two steps, so two callers naming the same new id in the same
instant can still collide.