From 2df0dfce8c79ff19d996747a827e19ee3532a691 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 28 Nov 2026 09:29:00 +0100 Subject: [PATCH] GameCult.Thing.Contract: CommandInvocation gains Source and Items Co-Authored-By: Claude Sonnet 5.5 --- packages/GameCult.Thing.Contract/Command.cs | 8 +++++++- tests/GameCult.Thing.Contract.Tests/Builders.cs | 6 ++++-- tests/GameCult.Thing.Contract.Tests/DomainTests.cs | 2 +- tests/GameCult.Thing.Contract.Tests/ReadOnlyListTests.cs | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/GameCult.Thing.Contract/Command.cs b/packages/GameCult.Thing.Contract/Command.cs index eae7dbc..2951bfb 100644 --- a/packages/GameCult.Thing.Contract/Command.cs +++ b/packages/GameCult.Thing.Contract/Command.cs @@ -160,8 +160,12 @@ public sealed class CommandInvocation [Key(6)] public string Client { get; } [Key(7)] public string IssuedAt { get; } [Key(8)] public string? Delegation { get; } + /// The activating node's declared id in the resolved tree. For a node inside a Repeat it is the template's id, never an instance id. A confirmed invocation names the node confirmed; a resumed one carries the source and items of the invocation whose result carried the effect. + [Key(9)] public string Source { get; } + /// The key of each Repeat instance enclosing the source, outermost first; empty outside any Repeat. + [Key(10)] public ImmutableArray Items { get; } - public CommandInvocation(string invocationId, string surfaceKey, long surfaceVersion, string command, RecordPayload payload, IReadOnlyList captured, string client, string issuedAt, string? delegation) + public CommandInvocation(string invocationId, string surfaceKey, long surfaceVersion, string command, RecordPayload payload, IReadOnlyList captured, string client, string issuedAt, string? delegation, string source, IReadOnlyList items) { InvocationId = ThingDomain.Present(invocationId, "InvocationId"); SurfaceKey = ThingDomain.Present(surfaceKey, "SurfaceKey"); @@ -172,6 +176,8 @@ public sealed class CommandInvocation Client = ThingDomain.Present(client, "Client"); IssuedAt = ThingDomain.Present(issuedAt, "IssuedAt"); Delegation = delegation; + Source = ThingDomain.Present(source, "Source"); + Items = ThingDomain.Items(items, "Items"); } [IgnoreMember] public string RecordKey => ThingKeys.InvocationKey(InvocationId); diff --git a/tests/GameCult.Thing.Contract.Tests/Builders.cs b/tests/GameCult.Thing.Contract.Tests/Builders.cs index 6a6ce2d..5e606f3 100644 --- a/tests/GameCult.Thing.Contract.Tests/Builders.cs +++ b/tests/GameCult.Thing.Contract.Tests/Builders.cs @@ -100,12 +100,14 @@ internal static class Builders }, "renderer.web", "2026-01-01T00:00:00Z", - "delegate-1"); + "delegate-1", + "go-button", + new List { "outer", "inner" }); public static CommandInvocation InvocationNamed(string id) => new( id, "thing:surface:provider.a.main", 7, "go", new RecordPayload("gamecult.thing.test.go.v1", new byte[] { 0x91, 0x01, 0xff, 0x00 }), - new List(), "renderer.web", "2026-01-01T00:00:00Z", null); + new List(), "renderer.web", "2026-01-01T00:00:00Z", null, "go-button", new List()); public static List BindAllFormats() { diff --git a/tests/GameCult.Thing.Contract.Tests/DomainTests.cs b/tests/GameCult.Thing.Contract.Tests/DomainTests.cs index 85e94af..0917784 100644 --- a/tests/GameCult.Thing.Contract.Tests/DomainTests.cs +++ b/tests/GameCult.Thing.Contract.Tests/DomainTests.cs @@ -19,7 +19,7 @@ public sealed class DomainTests yield return Case("CompletedOutcome.SourceVersion", "Version must be at least 0", () => new CompletedOutcome(-1, false, null)); yield return Case("CommandResult.Completed source version", "Version must be at least 0", () => CommandResult.Completed(Inv(), 1, -1, false, null)); yield return Case("CommandInvocation.SurfaceVersion", "Version must be at least 0", - () => new CommandInvocation("i", "k", -1, "go", new RecordPayload("s", Array.Empty()), new List(), "c", "t", null)); + () => new CommandInvocation("i", "k", -1, "go", new RecordPayload("s", Array.Empty()), new List(), "c", "t", null, "s", new List())); yield return Case("SurfaceDocument.Label empty", "Segment must be non-empty", () => SurfaceOf("p", "")); yield return Case("SurfaceDocument.Label dotted", "Segment must be free of '.'", () => SurfaceOf("p", "a.b")); yield return Case("SurfaceDocument.Version", "Version must be at least 0", () => new SurfaceDocument("p", "l", -1, "t", Boxed("r"), new List())); diff --git a/tests/GameCult.Thing.Contract.Tests/ReadOnlyListTests.cs b/tests/GameCult.Thing.Contract.Tests/ReadOnlyListTests.cs index cd79648..24b5907 100644 --- a/tests/GameCult.Thing.Contract.Tests/ReadOnlyListTests.cs +++ b/tests/GameCult.Thing.Contract.Tests/ReadOnlyListTests.cs @@ -227,7 +227,7 @@ public sealed class ReadOnlyListTests { Assert.Throws(() => MessagePackSerializer.Deserialize(new byte[] { 0x92, 0xA1, (byte)'s', 0xC0 }, Wire.Options)); - var empty = new CommandInvocation("i", "k", 1, "go", new RecordPayload("s", Array.Empty()), new List(), "c", "t", null); + var empty = new CommandInvocation("i", "k", 1, "go", new RecordPayload("s", Array.Empty()), new List(), "c", "t", null, "s", new List()); var decoded = (CommandInvocation)Wire.Read(typeof(CommandInvocation), Wire.Write(empty)); Assert.That(decoded.Payload.Bytes.IsEmpty, Is.True); Assert.That(Wire.Write(decoded), Is.EqualTo(Wire.Write(empty)));