From 4224a82df93aafea6f1d016fb9f4a69c2739f5d3 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 29 Sep 2026 14:21:29 +0200 Subject: [PATCH] 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 --- .../BrokkrCommandLedgerTests.cs | 34 +++++++++++++++++++ docs/provider-contract.md | 19 +++++++++++ 2 files changed, 53 insertions(+) diff --git a/brokkr-contracts.Tests/BrokkrCommandLedgerTests.cs b/brokkr-contracts.Tests/BrokkrCommandLedgerTests.cs index 46ba42c..6d090b1 100644 --- a/brokkr-contracts.Tests/BrokkrCommandLedgerTests.cs +++ b/brokkr-contracts.Tests/BrokkrCommandLedgerTests.cs @@ -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() { diff --git a/docs/provider-contract.md b/docs/provider-contract.md index 713442d..f1a3dd1 100644 --- a/docs/provider-contract.md +++ b/docs/provider-contract.md @@ -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 +`/.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