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 0000000..822fd0d Binary files /dev/null and b/crates/thing-testkit/fixtures/state-swarm.state.cc differ