Thing contract, Rust: Node::Slot(SlotNode { param: ParamName }) at arm 13; unknown-arm golden moves to 14
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
31f324f738
commit
54d5f0adac
7 changed files with 35 additions and 13 deletions
|
|
@ -1,12 +1,14 @@
|
|||
//! Thing Script: the closed node union, the surface document that holds a tree of nodes, and the
|
||||
//! composition document that names a reusable subtree. Arm keys are fixed for v1.
|
||||
//! composition document that names a reusable subtree. Arm keys are fixed: Slot (13) is the arm
|
||||
//! added after the first twelve, and a decoder from before it refuses a record holding one
|
||||
//! (CultCache's unknown-arm rule).
|
||||
|
||||
use cultcache_rs::{CultSlots, CultUnion, DatabaseEntry};
|
||||
|
||||
use crate::domain::{Count, Segment, Version};
|
||||
use crate::command::{CommandDecl, CommandRef};
|
||||
use crate::keys::{NodeId, ProviderId, composition_key, surface_key};
|
||||
use crate::source::{Bind, BoolSource, CollectionSource, MemberPath, NumberSource, TextSource};
|
||||
use crate::source::{Bind, BoolSource, CollectionSource, MemberPath, NumberSource, ParamName, TextSource};
|
||||
use crate::style::{BoxStyle, Paint, Role};
|
||||
|
||||
/// What every node carries.
|
||||
|
|
@ -48,6 +50,8 @@ pub enum Node {
|
|||
Embed(EmbedNode),
|
||||
#[cultcache(key = 12)]
|
||||
Use(UseNode),
|
||||
#[cultcache(key = 13)]
|
||||
Slot(SlotNode),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, CultSlots)]
|
||||
|
|
@ -321,6 +325,15 @@ pub struct UseNode {
|
|||
pub args: Vec<Arg>,
|
||||
}
|
||||
|
||||
/// Where a composition body places the nodes passed for its Slot parameter `param`. Only a child
|
||||
/// list of a composition body holds one, and resolve refuses it elsewhere. It carries no
|
||||
/// `NodeCommon`: the argument's nodes, keeping their caller-scope ids, replace it.
|
||||
#[derive(Clone, Debug, PartialEq, CultSlots)]
|
||||
pub struct SlotNode {
|
||||
#[cultcache(key = 0)]
|
||||
pub param: ParamName,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, CultSlots)]
|
||||
pub struct Arg {
|
||||
#[cultcache(key = 0)]
|
||||
|
|
|
|||
|
|
@ -366,7 +366,10 @@ fn full_composition() -> CompositionDocument {
|
|||
.into_iter()
|
||||
.map(|(name, kind)| ParamDecl { name: name.into(), kind })
|
||||
.collect(),
|
||||
body: boxed("panel-root", vec![text("panel-title", "t"), inner_use]),
|
||||
body: boxed(
|
||||
"panel-root",
|
||||
vec![text("panel-title", "t"), inner_use, Node::Slot(SlotNode { param: param("body") })],
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -518,10 +521,11 @@ fn refusal_payloads() -> Vec<(&'static str, Vec<u8>)> {
|
|||
let root = text("root", "x");
|
||||
vec![
|
||||
("result-thing1-flat", rmp_serde::to_vec_named(&flat).unwrap()),
|
||||
// A surface whose root is an arm key the Node union does not declare.
|
||||
// A surface whose root is an arm key the Node union does not declare: 14 is the first key
|
||||
// Node does not declare (Slot is 13).
|
||||
(
|
||||
"node-unknown-arm",
|
||||
rmp_serde::to_vec(&("provider.a", "main", 1i64, CANARY, (13i32, (CANARY,)), unit)).unwrap(),
|
||||
rmp_serde::to_vec(&("provider.a", "main", 1i64, CANARY, (14i32, (CANARY,)), unit)).unwrap(),
|
||||
),
|
||||
// A result whose outcome is an arm key the Outcome union does not declare.
|
||||
("outcome-unknown-arm", rmp_serde::to_vec(&("inv-1", 1i32, (4i32, (CANARY,)))).unwrap()),
|
||||
|
|
@ -588,7 +592,7 @@ fn refusal_cases() {
|
|||
}
|
||||
|
||||
// Decoded directly, the refusal names the union and the arm key, and never the payload.
|
||||
for (name, union, key) in [("node-unknown-arm", "Node", "13"), ("outcome-unknown-arm", "Outcome", "4")] {
|
||||
for (name, union, key) in [("node-unknown-arm", "Node", "14"), ("outcome-unknown-arm", "Outcome", "4")] {
|
||||
let bytes = committed(name);
|
||||
let message = if union == "Node" {
|
||||
rmp_serde::from_slice::<SurfaceDocument>(&bytes).unwrap_err().to_string()
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ when absent. Arm keys are fixed for v1.
|
|||
|
||||
| File | Kind | Decodes to |
|
||||
|---|---|---|
|
||||
| `surface-all-arms.bin` | `gamecult.thing.surface.v1` | One surface with all 13 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), 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 |
|
||||
| `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 |
|
||||
| `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 |
|
||||
|
|
@ -30,7 +30,7 @@ when absent. Arm keys are fixed for v1.
|
|||
| File | Payload | Expected |
|
||||
|---|---|---|
|
||||
| `result-thing1-flat.bin` | a MessagePack map with named members, the shape a Thing 1 provider wrote for a command result | refused when stored as a command result; the error names the kind and the record key and never a value |
|
||||
| `node-unknown-arm.bin` | a surface whose root node has arm key 13, which Node does not declare | refused; the error names the kind and the record key, and decoded directly it names the union Node and the key 13, and never a value |
|
||||
| `node-unknown-arm.bin` | a surface whose root node has arm key 14, which Node does not declare | refused; the error names the kind and the record key, and decoded directly it names the union Node and the key 14, and never a value |
|
||||
| `outcome-unknown-arm.bin` | a result whose outcome has arm key 4, which Outcome does not declare | refused in the same way, naming the union Outcome and the key 4 |
|
||||
| `result-extra-slot.bin` | a Pending result with a fourth slot past the last one declared | read: it decodes to the Pending result with seq 1 (CultLib's extra-trailing-slots ruling: read, never written back) |
|
||||
| `result-seq-zero.bin` | a result whose seq slot is 0 | refused; the error names the kind and the record key, decoded directly it names Seq, and never a value |
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -2384,9 +2384,9 @@ composition-all-params 3.6.0 76 81 REFUSE
|
|||
composition-all-params 3.6.1 81 84 REFUSE
|
||||
composition-all-params 3.6.1.0 82 83 REFUSE
|
||||
composition-all-params 3.6.1.1 83 84 REFUSE
|
||||
composition-all-params 4 84 812 REFUSE
|
||||
composition-all-params 4 84 821 REFUSE
|
||||
composition-all-params 4.0 85 86 REFUSE
|
||||
composition-all-params 4.1 86 812 REFUSE
|
||||
composition-all-params 4.1 86 821 REFUSE
|
||||
composition-all-params 4.1.0 87 104 REFUSE
|
||||
composition-all-params 4.1.0.0 88 99 REFUSE
|
||||
composition-all-params 4.1.0.1 99 103 REFUSE
|
||||
|
|
@ -2512,7 +2512,7 @@ composition-all-params 4.1.2.2 308 317 REFUSE
|
|||
composition-all-params 4.1.3 317 320 REFUSE
|
||||
composition-all-params 4.1.3.0 318 319 REFUSE
|
||||
composition-all-params 4.1.3.1 319 320 REFUSE
|
||||
composition-all-params 4.1.4 320 812 REFUSE
|
||||
composition-all-params 4.1.4 320 821 REFUSE
|
||||
composition-all-params 4.1.4.0 321 355 REFUSE
|
||||
composition-all-params 4.1.4.0.0 322 323 REFUSE
|
||||
composition-all-params 4.1.4.0.1 323 355 REFUSE
|
||||
|
|
@ -2753,6 +2753,11 @@ composition-all-params 4.1.4.1.1.2.6.1.1.0.1.1.3 808 811 REFUSE
|
|||
composition-all-params 4.1.4.1.1.2.6.1.1.0.1.1.3.0 809 810 REFUSE
|
||||
composition-all-params 4.1.4.1.1.2.6.1.1.0.1.1.3.1 810 811 REFUSE
|
||||
composition-all-params 4.1.4.1.1.2.6.1.1.0.1.1.4 811 812 REFUSE
|
||||
composition-all-params 4.1.4.2 812 821 REFUSE
|
||||
composition-all-params 4.1.4.2.0 813 814 REFUSE
|
||||
composition-all-params 4.1.4.2.1 814 821 REFUSE
|
||||
composition-all-params 4.1.4.2.1.0 815 821 REFUSE
|
||||
composition-all-params 4.1.4.2.1.0.0 816 821 REFUSE
|
||||
invocation-all-inputs 0 1 39 REFUSE
|
||||
invocation-all-inputs 1 39 69 REFUSE
|
||||
invocation-all-inputs 2 69 70 REFUSE
|
||||
|
|
|
|||
|
|
|
@ -1 +1 @@
|
|||
–ªprovider.a¤main¯CANARY-7f3a91c2’
‘¯CANARY-7f3a91c2<63>
|
||||
–ªprovider.a¤main¯CANARY-7f3a91c2’‘¯CANARY-7f3a91c2<63>
|
||||
Binary file not shown.
Loading…
Reference in a new issue