GameCult.Thing.Contract: CommandInvocation gains Source and Items
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e4c61fee12
commit
2df0dfce8c
4 changed files with 13 additions and 5 deletions
|
|
@ -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; }
|
||||
/// <summary>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.</summary>
|
||||
[Key(9)] public string Source { get; }
|
||||
/// <summary>The key of each Repeat instance enclosing the source, outermost first; empty outside any Repeat.</summary>
|
||||
[Key(10)] public ImmutableArray<string> Items { get; }
|
||||
|
||||
public CommandInvocation(string invocationId, string surfaceKey, long surfaceVersion, string command, RecordPayload payload, IReadOnlyList<CapturedInput> captured, string client, string issuedAt, string? delegation)
|
||||
public CommandInvocation(string invocationId, string surfaceKey, long surfaceVersion, string command, RecordPayload payload, IReadOnlyList<CapturedInput> captured, string client, string issuedAt, string? delegation, string source, IReadOnlyList<string> 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);
|
||||
|
|
|
|||
|
|
@ -100,12 +100,14 @@ internal static class Builders
|
|||
},
|
||||
"renderer.web",
|
||||
"2026-01-01T00:00:00Z",
|
||||
"delegate-1");
|
||||
"delegate-1",
|
||||
"go-button",
|
||||
new List<string> { "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<CapturedInput>(), "renderer.web", "2026-01-01T00:00:00Z", null);
|
||||
new List<CapturedInput>(), "renderer.web", "2026-01-01T00:00:00Z", null, "go-button", new List<string>());
|
||||
|
||||
public static List<BindParts> BindAllFormats()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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<byte>()), new List<CapturedInput>(), "c", "t", null));
|
||||
() => new CommandInvocation("i", "k", -1, "go", new RecordPayload("s", Array.Empty<byte>()), new List<CapturedInput>(), "c", "t", null, "s", new List<string>()));
|
||||
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<CommandDecl>()));
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@ public sealed class ReadOnlyListTests
|
|||
{
|
||||
Assert.Throws<MessagePackSerializationException>(() => MessagePackSerializer.Deserialize<RecordPayload>(new byte[] { 0x92, 0xA1, (byte)'s', 0xC0 }, Wire.Options));
|
||||
|
||||
var empty = new CommandInvocation("i", "k", 1, "go", new RecordPayload("s", Array.Empty<byte>()), new List<CapturedInput>(), "c", "t", null);
|
||||
var empty = new CommandInvocation("i", "k", 1, "go", new RecordPayload("s", Array.Empty<byte>()), new List<CapturedInput>(), "c", "t", null, "s", new List<string>());
|
||||
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)));
|
||||
|
|
|
|||
Loading…
Reference in a new issue