From e5cfb10674134846a68823245a53da07b0d626d6 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 11 Oct 2026 00:28:20 +0200 Subject: [PATCH] Union parity vectors: committed bytes written by the C# reference, outcomes as data, README Co-Authored-By: Claude Opus 5.5 --- tests/vectors/union-parity/.gitattributes | 2 + tests/vectors/union-parity/README.md | 59 ++++++++++++++++++ tests/vectors/union-parity/arm-arity.msgpack | Bin 0 -> 49 bytes .../union-parity/extra-slot-arm.msgpack | Bin 0 -> 167 bytes .../extra-slot-list-element.msgpack | Bin 0 -> 167 bytes .../extra-slot-nested-record.msgpack | Bin 0 -> 167 bytes .../union-parity/extra-slot-record.msgpack | Bin 0 -> 167 bytes .../inner-union-outer-key.msgpack | Bin 0 -> 156 bytes tests/vectors/union-parity/outcomes.msgpack | Bin 0 -> 502 bytes tests/vectors/union-parity/union-surface.cc | Bin 0 -> 2282 bytes .../union-parity/union-surface.msgpack | Bin 0 -> 156 bytes .../union-parity/unknown-arm-field.msgpack | Bin 0 -> 77 bytes .../union-parity/unknown-arm-list.msgpack | Bin 0 -> 177 bytes .../union-parity/unknown-arm-nested.msgpack | Bin 0 -> 103 bytes 14 files changed, 61 insertions(+) create mode 100644 tests/vectors/union-parity/.gitattributes create mode 100644 tests/vectors/union-parity/README.md create mode 100644 tests/vectors/union-parity/arm-arity.msgpack create mode 100644 tests/vectors/union-parity/extra-slot-arm.msgpack create mode 100644 tests/vectors/union-parity/extra-slot-list-element.msgpack create mode 100644 tests/vectors/union-parity/extra-slot-nested-record.msgpack create mode 100644 tests/vectors/union-parity/extra-slot-record.msgpack create mode 100644 tests/vectors/union-parity/inner-union-outer-key.msgpack create mode 100644 tests/vectors/union-parity/outcomes.msgpack create mode 100644 tests/vectors/union-parity/union-surface.cc create mode 100644 tests/vectors/union-parity/union-surface.msgpack create mode 100644 tests/vectors/union-parity/unknown-arm-field.msgpack create mode 100644 tests/vectors/union-parity/unknown-arm-list.msgpack create mode 100644 tests/vectors/union-parity/unknown-arm-nested.msgpack diff --git a/tests/vectors/union-parity/.gitattributes b/tests/vectors/union-parity/.gitattributes new file mode 100644 index 00000000..8af77cfe --- /dev/null +++ b/tests/vectors/union-parity/.gitattributes @@ -0,0 +1,2 @@ +*.msgpack binary +*.cc binary diff --git a/tests/vectors/union-parity/README.md b/tests/vectors/union-parity/README.md new file mode 100644 index 00000000..04499e04 --- /dev/null +++ b/tests/vectors/union-parity/README.md @@ -0,0 +1,59 @@ +# union-parity vectors + +Written only by the C# reference, `tests/GameCult.Caching.Tests/UnionParityVectorTests.cs`, with +`CULTCACHE_WRITE_VECTORS=1`. Every other run reads these files and compares them byte for byte; a changed +vector is a reviewed commit. Other runtimes decode them and are held to the same outcomes. + +Document `tests.union_surface` (schema `tests.union_surface.v1`), a positional array of +`[Id, Version, Root, Outcomes, Part, Crafted, Missing]`. A union value is `nil` or `[armKey, [armSlots...]]`. + +| Union | Arm keys | Arm slots | +|---|---|---| +| Node | 0 Box, 1 Text, 2 Use, 5 Image (3 and 4 retired) | Box `[Id, Children: Node list]`; Text `[Id, Content]`; Use `[Id, Composition, Slots: Node list]`; Image `[Id, Uri, nil (retired 2), Alt]` | +| Outcome | 0 Pending, 1 Completed, 2 Denied | Pending `[Message]`; Completed `[SourceVersion]`; Denied is a unit arm, `[2, []]` | +| Item | 0 Gem, 1 Tool, 2 Part | Gem `[Name]`; Tool `[Name, Uses]`; Part `[Name, Count]` | +| CraftedItem | 0 Tool, 1 Part | the same arms as Item under its own keys; a key only Item declares is unknown to it | + +Composition is a record, not an arm: `[Name, Body: Node]`. + +## Files + +- `union-surface.msgpack`: the payload. Value: Id `surface`, Version 3; Root is a Box `root` holding Text `t1`, a Use + `u1` and Image `i2`; the Use's Composition `comp` holds Box `inner` (Text `deep`, Image `img`), and its Slots are + Text `s1`, nil, Box `b2` (empty); Outcomes are Pending, Completed, Denied; Part is Tool `hammer`; Crafted (a + CraftedItem field) is Part `gear`; Missing is nil. A union inside a record inside a union, a unit arm, a list of + unions with a nil element, an inner union keyed apart from its outer. Written by C#. +- `union-surface.cc`: a single-file store written by the C# store holding that one record under key `surface`. Its + payload equals `union-surface.msgpack`; rewriting the loaded store is byte-identical. +- `outcomes.msgpack`: the expected outcome of every file below, as data. An array of entries + `[file, outcome, union, key, detail]`: `outcome` is `refused` or `read-only`; `union` is the union (or record) + named; `key` is the arm key or nil; `detail` is as in the tables below. + +## Refusals (outcome `refused`) + +A refusal names the union and the arm key and never echoes the payload. Each payload is `union-surface.msgpack` +with one part replaced. + +| File | Replaced part | detail | Must name | +|---|---|---|---| +| `unknown-arm-field.msgpack` | Root is an arm with the retired key 3 | unknown-arm | Node, key 3 | +| `unknown-arm-list.msgpack` | an Outcomes element has key 7 | unknown-arm | Outcome, key 7 | +| `unknown-arm-nested.msgpack` | key 9 three Boxes deep in Children | unknown-arm | Node, key 9 | +| `inner-union-outer-key.msgpack` | the Crafted field carries key 2, declared only by Item | unknown-arm | CraftedItem, key 2 | +| `arm-arity.msgpack` | Root is written `[1]`, an arm with no slots array | arity | a refusal of the arm as malformed (C#: MessagePack's "Invalid Union data") | + +## Extra trailing slot (outcome `read-only`) + +Each payload is `union-surface.msgpack` with one slot appended past the reader's last declared slot of one +record (ruling `cultlib-gaps:ruling:extra-trailing-slots`: the record is read, read-only at any depth, every write +of it refused). A reader decodes the value of `union-surface.msgpack` from each; `detail` says where the slot is. + +| File | detail | Record with the extra slot | +|---|---|---| +| `extra-slot-record.msgpack` | record | the document (slot 7) | +| `extra-slot-nested-record.msgpack` | nested-record | Composition `comp` | +| `extra-slot-arm.msgpack` | arm | the Root Box arm | +| `extra-slot-list-element.msgpack` | list-element | Text `s1`, an element of Use.Slots | + +The C# reference reads these today and its slot-tolerance cut is what makes them read-only; this cut asserts only +that the value is read. diff --git a/tests/vectors/union-parity/arm-arity.msgpack b/tests/vectors/union-parity/arm-arity.msgpack new file mode 100644 index 0000000000000000000000000000000000000000..337398c1fad01ace7dd1b4a56a4f5147256b7ca5 GIT binary patch literal 49 zcmbQfytuR|EipNjc_QQFNemO0lqY7EOk$kKK8b0&tLQgSJgWx%b8Q!PajSJ9l%=Pa2J5))zkhyaak@M@^g|fKQZwOw5e-_ v(msrAo(;iSp8Z+wpC9NoveQZoMWeeht|=Z5v>8JDT`?&EkLynf40rwu>{~~< literal 0 HcmV?d00001 diff --git a/tests/vectors/union-parity/extra-slot-list-element.msgpack b/tests/vectors/union-parity/extra-slot-list-element.msgpack new file mode 100644 index 0000000000000000000000000000000000000000..8151cd14ae8d32ccb1f1d56fc4c712e2c5014c3e GIT binary patch literal 167 zcmXYqK@Ng25JdqsZoG;iu=F+qj?ko~q?E`pU~1x4OOeD=^k|mE-Cw--{&Vemb%PRj z6p>R>YC|zuoh>zTE-5j#&&ZWhv;kOH)1ab2xGQ4&9_a9xnW)xYu}hkQpMh@yW4p|C wT1Je{wM@q&J|I{D^s?+vUA*j9o0qclIxc~qF literal 0 HcmV?d00001 diff --git a/tests/vectors/union-parity/extra-slot-nested-record.msgpack b/tests/vectors/union-parity/extra-slot-nested-record.msgpack new file mode 100644 index 0000000000000000000000000000000000000000..736d8f3ee585ffda4369143390c94df6aa9ed53b GIT binary patch literal 167 zcmXYqOAdlC6h*;LoVXQ3VCZfh_=F}cC8b1`0k0-bwG>HQMVDqtnBBoS=f0MaLv)KVnz6g`?Hx_|#a)~3Z9%V9?W zSyW0-6q3=&Qi2eQqRF%g*<8umgN0WWAbDZ00QIY~P-1*7d4*A$LNiUxmtmrP2)(>5=F;og0q*T~M>=L_I}N4Wq1 literal 0 HcmV?d00001 diff --git a/tests/vectors/union-parity/inner-union-outer-key.msgpack b/tests/vectors/union-parity/inner-union-outer-key.msgpack new file mode 100644 index 0000000000000000000000000000000000000000..721b506af137edb77a5f883196ac32479e8d9db3 GIT binary patch literal 156 zcmXZUK@Ng26h%=$jT84mVCZfNexXTANh#4~z^jQmg4MiG6kPx{Bx52v+ z!MlOZ*8KP9f6YVO1geSe2$Wc;G@A0ly4$HL>V;qx9F|X)T;fTS>Ec`V0i&HCGK;I= z3$}RL!`^d@(0TlO*;$YJ&_pN@NHYNkpWZdjh8vr)s45vwJlf+Pziyi;(f)wxnvI^j zS=`{g7X{9+2f>16pKU3qN?6)Y33N?sp65XlWstOI;RduxvYTY$}*iOS>ih&{m ziri?JgqpId(jTj9uWK9&3g|Wspk~#sNm$z`CHoL_gu7maSSSo2uu)aBo?%=+5;aTS zsD(x7mV*M(J;>AScDaB++7+=EwsG0xJK#bLA;Y&W^*LZH8g{Ecg2rtSyH`-d#P@My z=)mCv-=mnbT;WA2B2M6FV~U|v7}F~LWNC#$B{zdIDd-mqsaSR*Y*7WWg?(zG#iS;B z4ErMOO&swwcf=DKd!oA!42?HgUf+%!m|g#cy`kg%o4J`qo|R#KWoG5f9arpM9hD{=o3oXA#k)nMTcgrcv%=(NnuO?`jLMJg ze>?o~9U>Fst|H^JM~Fr0maI#fS=Tg^tjn?`%irIePSY-@3+XV%bML2%=|CtK9q|1q zUFr`KB^~0tJwU;Q7vfY+Q89D?4&EK6t0(7P&>khRXKilM?40^V0Im%44{wH>1~xfH o-M}NI%+B8S(}mvf74<~A*t?xB9b?4z9U24>ujRqpK;xC{C(NQdiU0rr literal 0 HcmV?d00001 diff --git a/tests/vectors/union-parity/union-surface.msgpack b/tests/vectors/union-parity/union-surface.msgpack new file mode 100644 index 0000000000000000000000000000000000000000..94ee6c5231f57fd2f3508a0977663da8cfc1f617 GIT binary patch literal 156 zcmXZUOAdlC6hKixjT84m%Fx{ud_t3!l71q~fL9ZzT8eC=OS4Aj=ibMrt-8_%c9>yM zQW}RjdPCL@IG0#BZwZD*iXnlO^*ty|B3uB5*NBJv!bH1S#m;3(<3jmwph?hNnwTPA lS5tDHRex5;r^9RxH_8m=^AU?F9p4=l0@Ud{Z-J_P`~cx2Li+#! literal 0 HcmV?d00001 diff --git a/tests/vectors/union-parity/unknown-arm-field.msgpack b/tests/vectors/union-parity/unknown-arm-field.msgpack new file mode 100644 index 0000000000000000000000000000000000000000..aed497c3c45be92ba7a80ba20b770b7fde60688e GIT binary patch literal 77 zcmbQfytuR|EipNjc@p!ag+)7@9sL}GB6UmiGV}9v)AMsuQuB08l8q84Phyz3q&zXR hWD?^<_DM_=CNWN0mXVm7n_9#JWG+chO)O$L005fG9ti*d literal 0 HcmV?d00001 diff --git a/tests/vectors/union-parity/unknown-arm-list.msgpack b/tests/vectors/union-parity/unknown-arm-list.msgpack new file mode 100644 index 0000000000000000000000000000000000000000..0fe58548af3bf443045f42a7e901c860a227d9a7 GIT binary patch literal 177 zcmXZVyAFad7=~ewaq(6NfjGGlcLz7e0>99t2U6PTWyp_-tCk|S;K-#}qxZmV)F^RL*nh0GcdF4S*g#d+KxE!E*UT}HqC@%)1=r#<=*b(+S zs3TW1sYgGuX?*q0()iEP@qsvL+?h~~tLD8+_Q~NG7(t~73dwR1!6u7|&%8>)IjHrw JSO8Ir@dK$uN}d1! literal 0 HcmV?d00001 diff --git a/tests/vectors/union-parity/unknown-arm-nested.msgpack b/tests/vectors/union-parity/unknown-arm-nested.msgpack new file mode 100644 index 0000000000000000000000000000000000000000..66213f656523828daa1d1cc234cb68746ab8de88 GIT binary patch literal 103 zcmbQfytuR|EipNjc@o289uBq@?EQnj{+~PM*XtaY=b%X2~SRiR_b@CQM?Sv@9brH#fD22gqEKo|;(1asU95 C94SNq literal 0 HcmV?d00001