thing-contract: CommandInvocation gains source and items (Rust, goldens, fixtures)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-28 09:28:24 +01:00
commit e4c61fee12
10 changed files with 22 additions and 4 deletions

View file

@ -115,6 +115,14 @@ pub struct CommandInvocation {
pub issued_at: String,
#[cultcache(key = 8)]
pub delegation: Option<String>,
/// 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<System.String>")]
pub items: Vec<String>,
}
impl CommandInvocation {

View file

@ -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 |

View file

@ -2793,6 +2793,10 @@ invocation-all-inputs 5.3.1.1.0 164 166 REFUSE
invocation-all-inputs 6 166 179 REFUSE
invocation-all-inputs 7 179 200 REFUSE
invocation-all-inputs 8 200 211 ACCEPT
invocation-all-inputs 9 211 221 REFUSE
invocation-all-inputs 10 221 234 REFUSE
invocation-all-inputs 10.0 222 228 REFUSE
invocation-all-inputs 10.1 228 234 REFUSE
result-pending 0 1 39 REFUSE
result-pending 1 39 40 REFUSE
result-pending 2 40 51 REFUSE

1 surface-all-arms 0 1 12 REFUSE
2793 invocation-all-inputs 6 166 179 REFUSE
2794 invocation-all-inputs 7 179 200 REFUSE
2795 invocation-all-inputs 8 200 211 ACCEPT
2796 invocation-all-inputs 9 211 221 REFUSE
2797 invocation-all-inputs 10 221 234 REFUSE
2798 invocation-all-inputs 10.0 222 228 REFUSE
2799 invocation-all-inputs 10.1 228 234 REFUSE
2800 result-pending 0 1 39 REFUSE
2801 result-pending 1 39 40 REFUSE
2802 result-pending 2 40 51 REFUSE

View file

@ -8,9 +8,9 @@ frozen, and a normal test run only compares and reads them. The rows are the fix
| File | Holds | Map rules |
|---|---|---|
| `f01-swarm-dashboard.surface.cc` | One surface: a Grid Box root, a Text bound with a Number Format, a Repeat over a RecordsSource prefix whose template binds Item members, and a Button whose CommandRef is declared | 6, 9 |
| `f02-login-effect.surface.cc` | One surface (a Text TextInput and a Button whose command captures it, plus the declared resume command), the CommandInvocation of it, and its two results: Pending, then Completed with an `OpenExternal` effect whose `resume` names the declared command | 1, 2 |
| `f02-login-effect.surface.cc` | One surface (a Text TextInput and a Button whose command captures it, plus the declared resume command), the CommandInvocation of it (source `sign-in-button`, no items), and its two results: Pending, then Completed with an `OpenExternal` effect whose `resume` names the declared command | 1, 2 |
| `f03-input-target.surface.cc` | One surface (an Image over a position: absolute Box with insets, holding a bound label) and the AssetCatalog the Image names | - |
| `f04-form.surface.cc` | One surface (Toggle, Slider, Select with literal options, TextInput of Number kind) and one command capturing all four, its invocation, and a Completed result declaring `clear_drafts` | 1 |
| `f04-form.surface.cc` | One surface (Toggle, Slider, Select with literal options, TextInput of Number kind) and one command capturing all four, its invocation (source `enabled`, no items), and a Completed result declaring `clear_drafts` | 1 |
| `f05-modal-overlay.surface.cc` | One surface with a modal Overlay anchored to the viewport, a dismiss CommandRef and two Buttons inside | - |
| `f06-scroll-list.surface.cc` | One surface: a Box with `overflow: scroll` holding a Repeat over a RecordsSource prefix, template keyed by the item's `id` (the 1,000 items are provider state, not here) | - |
| `f07-plot.surface.cc` | One surface with a Plot of each mark (Line, Bar, Area) over a bound series, with and without axis bounds | - |

View file

@ -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()],
}
}

View file

@ -470,7 +470,7 @@ fn surface(provider: &str, label: &str, root: Node, commands: Vec<CommandDecl>)
}
/// An invocation of `command` on `surface`, issued at the pinned clock.
fn invoke(surface: &SurfaceDocument, id: &str, command: &str, captured: Vec<CapturedInput>) -> CommandInvocation {
fn invoke(surface: &SurfaceDocument, id: &str, command: &str, source: &str, captured: Vec<CapturedInput>) -> 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<Capt
client: "renderer.web".into(),
issued_at: store::PINNED_CLOCK.into(),
delegation: None,
source: nid(source),
items: Vec::new(),
}
}
@ -530,6 +532,7 @@ fn login_effect() -> 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 })),