From 12da48c2dcb3e1fdf077c0cf3f09f67404375203 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 28 Nov 2026 02:32:41 +0100 Subject: [PATCH] Thing 2.0 cut 4b: committed provider-state stores, fixture README rows, the contract crate docs name the stack hazard --- crates/thing-contract/src/lib.rs | 6 ++++++ crates/thing-testkit/fixtures/README.md | 4 +++- .../fixtures/state-swarm-members-empty.state.cc | 3 +++ .../thing-testkit/fixtures/state-swarm.state.cc | Bin 0 -> 1072 bytes 4 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 crates/thing-testkit/fixtures/state-swarm-members-empty.state.cc create mode 100644 crates/thing-testkit/fixtures/state-swarm.state.cc diff --git a/crates/thing-contract/src/lib.rs b/crates/thing-contract/src/lib.rs index 39c72a0..602e81a 100644 --- a/crates/thing-contract/src/lib.rs +++ b/crates/thing-contract/src/lib.rs @@ -8,6 +8,12 @@ //! `Deserialize` (CultCache's `DatabaseEntry` requires it). The domains therefore live in the //! field types (`Seq`, `Version`, `Count`, `Segment`), whose `Deserialize` calls the same //! `new` the constructors call, so no door skips a check. +//! +//! Stack hazard: `Node` nests without a bound of its own, and serde's `Deserialize` recurses +//! once per level, so a hostile payload nested deep enough overflows the stack of a caller that +//! decodes it directly. CultCache refuses such a payload on read and on write +//! (`cultcache_rs::check_payload_depth`, 256 containers); a caller that decodes bytes outside a +//! CultCache must run that check first. mod asset; mod command; diff --git a/crates/thing-testkit/fixtures/README.md b/crates/thing-testkit/fixtures/README.md index 21ca217..dbc345d 100644 --- a/crates/thing-testkit/fixtures/README.md +++ b/crates/thing-testkit/fixtures/README.md @@ -20,6 +20,8 @@ frozen, and a normal test run only compares and reads them. The rows are the fix | `f11-deep.surface.cc` | One surface: the deepest Box chain whose payload CultCache's `check_payload_depth` accepts, found by the builder | - | | `f11-deep-refused.bin` | The payload of the same chain one Box level deeper, raw: `check_payload_depth` refuses it at depth 257 and so does CultCache. No store can hold it | - | | `f12-text-edge.surface.cc` | One surface of five Text nodes: bidi (Hebrew and Arabic in Latin), CJK wide characters, combining marks, emoji ZWJ sequences, and a paragraph long enough to wrap | - | +| `state-swarm.state.cc` | Provider state, not contract documents: f01's four swarm records (`summary`, `mind-1`..`mind-3`, schema `gamecult.thing.test.swarm.v1`) written with the test type registered, so the store's catalog publishes the member rows `Id`, `Name`, `Load` | - | +| `state-swarm-members-empty.state.cc` | The same four records written through a hand-implemented twin of the type, whose catalog publishes `[]`: every read of it is refused | - | A payload the contract refuses cannot live in a store: f11's refused payload is a raw file here, and an unknown union arm is `crates/thing-contract/tests/goldens/node-unknown-arm.bin`, read in place and fed to @@ -28,5 +30,5 @@ unknown union arm is `crates/thing-contract/tests/goldens/node-unknown-arm.bin`, ## Regenerate `THING_BLESS=1 cargo test -p thing-testkit --test fixtures every_fixture_round_trips` rewrites -the files through `golden::check`, the one bless door; review the diff before committing. Run +the files (the two state stores: `--test state the_committed_stores`) through `golden::check`, the one bless door; review the diff before committing. Run the tests without `THING_BLESS` to compare. diff --git a/crates/thing-testkit/fixtures/state-swarm-members-empty.state.cc b/crates/thing-testkit/fixtures/state-swarm-members-empty.state.cc new file mode 100644 index 0000000..27e8b29 --- /dev/null +++ b/crates/thing-testkit/fixtures/state-swarm-members-empty.state.cc @@ -0,0 +1,3 @@ +“²cultcache.store.v1‘—¹gamecult.thing.test.swarm¹gamecult.thing.test.swarm¼gamecult.thing.test.swarm.v1¹gamecult.thing.test.swarmÙf{"schemaName":"gamecult.thing.test.swarm","schemaVersion":"gamecult.thing.test.swarm.v1","members":[]}‘¹gamecult.thing.test.swarm�””¦mind-1¹gamecult.thing.test.swarm´2026-01-01T00:00:00ZÄ“¦mind-1¦EurekaË?Ó× +=p£×”¦mind-2¹gamecult.thing.test.swarm´2026-01-01T00:00:00ZÄ“¦mind-2¥LibbyË?â=p£× +=”¦mind-3¹gamecult.thing.test.swarm´2026-01-01T00:00:00ZÄ“¦mind-3¤KikoË?´záG®{”§summary¹gamecult.thing.test.swarm´2026-01-01T00:00:00ZÄ“§summary¥SwarmË?ÚáG®zá \ No newline at end of file diff --git a/crates/thing-testkit/fixtures/state-swarm.state.cc b/crates/thing-testkit/fixtures/state-swarm.state.cc new file mode 100644 index 0000000000000000000000000000000000000000..822fd0d4060dc603c8a9ba730b6ad331d95fcc3b GIT binary patch literal 1072 zcmc(eu}{K46vl;-*(h^oXi7;OnvljsV~E7T8V8NTwH(mUYf0~_7Q!DvAdy)CCmjrn zi31^S9UVy6@GtST6rz!mFc_0tdf)qg-+Oo0_KW5iOhZ})^ORXO=C3oYyVo)z*cW(K z(akc?Fl9WwK{kn2-XcAKjJ8eVu?9yWo}d#5eW!==K)b8J)HGS}5YCX^FQRH)^o zOUN)R#z{hoGv_h+A`~#U=0_?nWti{^vte4;*6ArOVH=wos3l}j3@l{2%MXU^GG@xR zwoS({z-Sin?Y^NS$P9Pre5`=dOfCAzEc*!Lf9ynDc2cm=?=v~D9M!;oc_vrQR`l~| zcen2I#it(^G#-z}qi(F{pWG@X-t#9}DDwdVPp2~=a6{=e&v7UU;$B+Fz&aBIDOeZp z$#!TQ96C0xB2WI9ByzQfNeC392Urc<4S{06psT9u$)7$gkqdd*O?f*ZFWWoTtClAZ g>$9Wh?MCO3I)otG-ISMXFPweF|Lr|_>I3VuFT_idEC2ui literal 0 HcmV?d00001