A2: command ids are single-use (F6=A); pin it and state it in the contract

The dedup already retired an id once any receipt answered it. What changes
is that this is now the stated contract (docs/provider-contract.md, Unity
Command Transport) and two tests name it, so a later move to reusable
desired-state slots (F6=B) has to break them.

The Rust sync's stable_id slots are not touched here; see the report.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-09-29 14:21:29 +02:00
commit 4224a82df9
2 changed files with 53 additions and 0 deletions

View file

@ -45,6 +45,40 @@ public sealed class BrokkrCommandLedgerTests
Assert.False(ledger.TryNextPending(out _));
}
[Fact]
public async Task RewrittenCommandIdIsNotReExecuted()
{
// Command ids are single-use: a receipt retires the id, and a later intent written under it is a caller
// defect that the editor ignores. Callers that mean a new act mint a new id.
using var project = new ScratchProject();
await project.WriteCommandAsync("reused", "refreshAssets");
using var editor = project.OpenCache();
var ledger = new BrokkrCommandLedger(editor);
Assert.True(ledger.TryNextPending(out _));
await Answer(editor, "reused");
await project.WriteCommandAsync("reused", "setEditorPaused");
await ledger.PullAsync();
Assert.False(ledger.TryNextPending(out _));
}
[Fact]
public async Task FreshIdAfterAnAnsweredOneIsPending()
{
using var project = new ScratchProject();
await project.WriteCommandAsync("first");
using var editor = project.OpenCache();
var ledger = new BrokkrCommandLedger(editor);
await Answer(editor, "first");
await project.WriteCommandAsync("second", "setEditorPaused");
await ledger.PullAsync();
Assert.True(ledger.TryNextPending(out var pending));
Assert.Equal("second", pending.commandId);
}
[Fact]
public async Task ReceiptWrittenByAnotherProcessRetiresTheCommand()
{

View file

@ -150,6 +150,25 @@ destination prefab path.
`createScriptableObject` uses `componentType` as the ScriptableObject type and
`assetPath` as the destination asset path.
## Unity Command Transport
Commands reach the editor through the project's directory store at
`<project>/.brokkr/unity-editor.ccmp` (`.records/` beside it). There is no
network listener: admission starts at filesystem permissions, and the editor sees
a written intent on its next pull, about once a second.
The editor executes intents only while the operator has enabled agent commands
for that project (window toggle "Agent Commands"). The flag is off by default
and installing the package never turns it on. The host snapshot carries it as
`agentCommandsEnabled`, so a caller can see why nothing executes.
A command id is single-use. Every writer mints a fresh `commandId` for each
act, and a receipt at `unity/receipts/{commandId}` answers exactly that id.
Once an id has a receipt, the editor never executes it again, whatever is
later written under it: reusing an answered id is a caller defect, and its
receipt is the answer that stands. A writer that repeats an intent mints a new
id for each repetition.
## Blender Command Actions
All Blender writes use `brokkr.blender.command_intent.v0` and receive