From e4c61fee12d48ec75561127442ee84f8dd14cd16 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 28 Nov 2026 09:28:24 +0100 Subject: [PATCH] thing-contract: CommandInvocation gains source and items (Rust, goldens, fixtures) Co-Authored-By: Claude Sonnet 5.5 --- crates/thing-contract/src/command.rs | 8 ++++++++ crates/thing-contract/tests/goldens/README.md | 2 +- .../tests/goldens/invocation-all-inputs.bin | Bin 211 -> 234 bytes .../tests/goldens/nil-positions.tsv | 4 ++++ crates/thing-testkit/fixtures/README.md | 4 ++-- .../fixtures/f02-login-effect.surface.cc | Bin 5555 -> 5997 bytes .../fixtures/f04-form.surface.cc | Bin 5580 -> 6015 bytes crates/thing-testkit/src/build.rs | 2 ++ crates/thing-testkit/src/fixture.rs | 6 +++++- tests/thing-contract-parity/written-by-rs.cc | Bin 13003 -> 13452 bytes 10 files changed, 22 insertions(+), 4 deletions(-) diff --git a/crates/thing-contract/src/command.rs b/crates/thing-contract/src/command.rs index 9daf1c3..29bc9d2 100644 --- a/crates/thing-contract/src/command.rs +++ b/crates/thing-contract/src/command.rs @@ -115,6 +115,14 @@ pub struct CommandInvocation { pub issued_at: String, #[cultcache(key = 8)] pub delegation: Option, + /// 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. + #[cultcache(key = 9)] + pub source: NodeId, + /// The key of each Repeat instance enclosing the source, outermost first; empty outside any Repeat. + #[cultcache(key = 10, type_name = "System.Collections.Immutable.ImmutableArray")] + pub items: Vec, } impl CommandInvocation { diff --git a/crates/thing-contract/tests/goldens/README.md b/crates/thing-contract/tests/goldens/README.md index 711f3d0..6e2ed8e 100644 --- a/crates/thing-contract/tests/goldens/README.md +++ b/crates/thing-contract/tests/goldens/README.md @@ -14,7 +14,7 @@ when absent. Arm keys are fixed for v1. |---|---|---| | `surface-all-arms.bin` | `gamecult.thing.surface.v1` | One surface with 13 of the 14 node arms (Box 0, Text 1, Image 2, Button 3, Toggle 4, Slider 5, TextInput 6 as both input kinds, Text 0 and Number 1, Select 7, Repeat 8, Overlay 9, Plot 10, Embed 11, Use 12; Slot 13 is in `composition-all-params`, a body being where a slot stands), a Box chain four levels deep, every text, number and bool source arm, every Format arm, both state sources, both member steps, every dimension and colour arm, and two declared commands | | `composition-all-params.bin` | `gamecult.thing.composition.v1` | A composition with one parameter of each of the 7 kinds, whose body uses a composition with one argument of each of the 7 argument arms and places the body slot (Slot 13) last in its root's children | -| `invocation-all-inputs.bin` | `gamecult.thing.command_invocation.v1` | An invocation with a payload record of bin bytes and one captured input of each of the 4 input arms | +| `invocation-all-inputs.bin` | `gamecult.thing.command_invocation.v1` | An invocation with a payload record of bin bytes and one captured input of each of the 4 input arms, source `go-button` and items `[outer, inner]` | | `result-pending.bin` | `gamecult.thing.command_result.v1` | Outcome Pending, seq 1 | | `result-completed.bin` | same | Outcome Completed with source version 8, drafts cleared, no effect | | `result-completed-open-surface.bin` | same | Completed with no source version and the OpenSurface effect | diff --git a/crates/thing-contract/tests/goldens/invocation-all-inputs.bin b/crates/thing-contract/tests/goldens/invocation-all-inputs.bin index 52c059074e5875e980e06a2c1b1f1b27c93d9cbf..5eb52d79dbcac9d1dc153115249feccfdcf65557 100644 GIT binary patch delta 33 pcmcc2_==Hn_C&@@;w#hhb(2a{S)41Kl#`k= KVKcYTL1qA3fI~z8 delta 45 zcmV+|0Mh^eF3c;CrUC`ov8dMtlf(xm0hyDG3?#D;2vPyF#t9V(0@<09-4fWdz7xR% DxHl58 diff --git a/crates/thing-testkit/src/build.rs b/crates/thing-testkit/src/build.rs index f042d9f..4e02889 100644 --- a/crates/thing-testkit/src/build.rs +++ b/crates/thing-testkit/src/build.rs @@ -140,5 +140,7 @@ pub fn invocation() -> CommandInvocation { client: "renderer.web".into(), issued_at: "2026-01-01T00:00:00Z".into(), delegation: Some("delegate-1".into()), + source: nid("go-button"), + items: vec!["outer".into(), "inner".into()], } } diff --git a/crates/thing-testkit/src/fixture.rs b/crates/thing-testkit/src/fixture.rs index ded1572..d2a59d8 100644 --- a/crates/thing-testkit/src/fixture.rs +++ b/crates/thing-testkit/src/fixture.rs @@ -470,7 +470,7 @@ fn surface(provider: &str, label: &str, root: Node, commands: Vec) } /// An invocation of `command` on `surface`, issued at the pinned clock. -fn invoke(surface: &SurfaceDocument, id: &str, command: &str, captured: Vec) -> CommandInvocation { +fn invoke(surface: &SurfaceDocument, id: &str, command: &str, source: &str, captured: Vec) -> CommandInvocation { CommandInvocation { invocation_id: id.into(), surface_key: surface.record_key(), @@ -485,6 +485,8 @@ fn invoke(surface: &SurfaceDocument, id: &str, command: &str, captured: Vec FixtureSet { &login, "6d1c0f52-7a0e-4b53-8f3d-2a9e4c7b1d10", "sign-in", + "sign-in-button", vec![captured("username", InputValue::Text(TextValue { value: "ada".into() }))], ); // The answer arrives in two steps: Pending, then Completed, whose effect sends the user to @@ -641,6 +644,7 @@ fn form() -> FixtureSet { &form, "0b7e44aa-31c9-4e0d-a6f2-95d8c3e1b277", "save", + "enabled", vec![ captured("enabled", InputValue::Bool(BoolValue { value: true })), captured("volume", InputValue::Number(NumberValue { value: 0.75 })), diff --git a/tests/thing-contract-parity/written-by-rs.cc b/tests/thing-contract-parity/written-by-rs.cc index a0f7d1b20565c262229b184e24fdba30ba1cdb9d..7373ed71ee3b898eb7172f5a9f859b73926dafc0 100644 GIT binary patch delta 169 zcmX?|+LO8A9t#t@+~x-?*I6eCaq?U0DCH&QrYcz}1?QI*B~KEpC0SqxpF delta 58 zcmV-A0LA}|Y0G7>-UI>#*|XpT*9DXO3nl@Xlf)1tvqub40Ror3lK~7DvlkAL4g%Ae Qlm8tilh7Qjvy&b97Q+b_tpET3