From 0c9c0442cc6c01d89309f3916bb2469579e71e7c Mon Sep 17 00:00:00 2001 From: Libby Date: Wed, 11 Nov 2026 09:56:06 +0000 Subject: [PATCH] unique-index refusals vector: rows 20-22 load rows 14, 15, 17; README gives the real schema ids Rows 20-22 open stores holding the records of rows 14, 15 and 17, so a runtime with no batch commit (TS) still walks cross-group key order. Over the TS-walkable rows (5, 8-13, 19-22), hand mutants of CompareRefusals' first-key compare fail: code point row 22; OrdinalIgnoreCase 20, 22; InvariantCulture 20, 21; InvariantCultureIgnoreCase 20, 21. Rows 1-19 are byte-identical. The README now names the sha256 schema ids the store catalogs carry, not the versions, and counts tests.uq_alias's unique Alt. Co-Authored-By: Claude Opus 5.5 --- .../UniqueIndexVectorTests.cs | 23 ++++++++++---- tests/vectors/unique-index/README.md | 30 +++++++++++------- tests/vectors/unique-index/key-case-store.cc | Bin 0 -> 1177 bytes .../unique-index/key-punctuation-store.cc | Bin 0 -> 1177 bytes tests/vectors/unique-index/refusals.msgpack | Bin 2438 -> 2676 bytes .../unique-index/surrogate-groups-store.cc | Bin 0 -> 1189 bytes 6 files changed, 35 insertions(+), 18 deletions(-) create mode 100644 tests/vectors/unique-index/key-case-store.cc create mode 100644 tests/vectors/unique-index/key-punctuation-store.cc create mode 100644 tests/vectors/unique-index/surrogate-groups-store.cc diff --git a/tests/GameCult.Caching.Tests/UniqueIndexVectorTests.cs b/tests/GameCult.Caching.Tests/UniqueIndexVectorTests.cs index 3e499f0f..44aef30d 100644 --- a/tests/GameCult.Caching.Tests/UniqueIndexVectorTests.cs +++ b/tests/GameCult.Caching.Tests/UniqueIndexVectorTests.cs @@ -350,11 +350,16 @@ namespace GameCult.Caching.Tests private static readonly Rec[] AliasRecords = { new("item:a", Alias, "S", "X"), new("item:b", Alias, "S", "Y"), new("item:c", Alias, "T", "Y") }; private static readonly Rec[] RepullBefore = Items_(("item:a1", "A"), ("item:b1", "C")); private static readonly Rec[] RepullAfter = Items_(("item:a1", "A"), ("item:b1", "B"), ("item:b2", "B"), ("item:c1", "A")); + private static readonly Rec[] KeyCaseRecords = Items_(("a", "S"), ("z", "S"), ("B", "T"), ("C", "T")); + private static readonly Rec[] KeyPunctuationRecords = Items_(("_", "S"), ("a", "S"), ("Z", "T"), ("b", "T")); + private static readonly Rec[] SurrogateGroupRecords = Items_(("\uE000", "S"), ("\uE000b", "S"), ("\U0001F600", "T"), ("\U0001F600b", "T")); private static readonly (string File, Rec[] Records)[] RefusalStores = { ("pair-store.cc", PairRecords), ("surrogate-store.cc", SurrogateRecords), ("types-store.cc", TypeRecords), ("repull-before.cc", RepullBefore), ("repull-after.cc", RepullAfter), ("alias-store.cc", AliasRecords), + ("key-case-store.cc", KeyCaseRecords), ("key-punctuation-store.cc", KeyPunctuationRecords), + ("surrogate-groups-store.cc", SurrogateGroupRecords), }; private static readonly Refusal SurrogateRefusal = new("k\U0001F600", "k\uE000", Item, "Sku"); @@ -362,6 +367,9 @@ namespace GameCult.Caching.Tests private static readonly Refusal PairRefusal = new("item:b", "item:c", Pair, "Alt"); private static readonly Refusal AliasRefusal = new("item:a", "item:b", Alias, "Sku"); private static readonly Refusal RepullRefusal = new("item:a1", "item:c1", Item, "Sku"); + private static readonly Refusal KeyCaseRefusal = new("B", "C", Item, "Sku"); + private static readonly Refusal KeyPunctuationRefusal = new("Z", "b", Item, "Sku"); + private static readonly Refusal SurrogateGroupRefusal = new("\U0001F600", "\U0001F600b", Item, "Sku"); private static readonly Case[] Cases = { @@ -383,16 +391,17 @@ namespace GameCult.Caching.Tests new("commit-onto-a-loaded-holder", new[] { Open("repull-before.cc"), Commit(Items_(("item:z", "A"))) }, new Refusal("item:a1", "item:z", Item, "Sku")), // Rows 14-19 extend the spec's floor of 13: orderings a code-point, case-insensitive or culture compare would flip. - new("batch-key-case", new[] { Open(), Commit(Items_(("a", "S"), ("z", "S"), ("B", "T"), ("C", "T"))) }, - new Refusal("B", "C", Item, "Sku")), - new("batch-key-punctuation", new[] { Open(), Commit(Items_(("_", "S"), ("a", "S"), ("Z", "T"), ("b", "T"))) }, - new Refusal("Z", "b", Item, "Sku")), + new("batch-key-case", new[] { Open(), Commit(KeyCaseRecords) }, KeyCaseRefusal), + new("batch-key-punctuation", new[] { Open(), Commit(KeyPunctuationRecords) }, KeyPunctuationRefusal), new("batch-key-case-in-a-group", new[] { Open(), Commit(Items_(("a", "S"), ("B", "S"))) }, new Refusal("B", "a", Item, "Sku")), - new("batch-surrogate-groups", new[] { Open(), Commit(Items_(("\uE000", "S"), ("\uE000b", "S"), ("\U0001F600", "T"), ("\U0001F600b", "T"))) }, - new Refusal("\U0001F600", "\U0001F600b", Item, "Sku")), + new("batch-surrogate-groups", new[] { Open(), Commit(SurrogateGroupRecords) }, SurrogateGroupRefusal), new("batch-alias-case", new[] { Open(), Commit(AliasRecords) }, AliasRefusal), new("load-alias-case", new[] { Open("alias-store.cc") }, AliasRefusal), + // Rows 20-22 load rows 14, 15 and 17's records, so a runtime with no batch commit still walks cross-group key order. + new("load-key-case", new[] { Open("key-case-store.cc") }, KeyCaseRefusal), + new("load-key-punctuation", new[] { Open("key-punctuation-store.cc") }, KeyPunctuationRefusal), + new("load-surrogate-groups", new[] { Open("surrogate-groups-store.cc") }, SurrogateGroupRefusal), }; private static byte[] RefusalStoreBytes(Rec[] records) @@ -580,7 +589,7 @@ namespace GameCult.Caching.Tests } } - Assert.That(walked, Is.EqualTo(19)); + Assert.That(walked, Is.EqualTo(22)); } } } diff --git a/tests/vectors/unique-index/README.md b/tests/vectors/unique-index/README.md index 8c706de2..ac4a40cd 100644 --- a/tests/vectors/unique-index/README.md +++ b/tests/vectors/unique-index/README.md @@ -18,11 +18,17 @@ reviewed commit. Other runtimes are held to the same canonical text and the same stored-at pinned to `2026-01-01T00:00:00Z`. Records `item:a` and `item:b` both hold Sku `S-1`; `item:c` holds Sku `" "` and `item:d` holds Sku `U+0085`. Written through a role Sku. - `blank-store.cc`: the same, only `item:c` and `item:d`. -- `pair-store.cc`, `surrogate-store.cc`, `types-store.cc`, `repull-before.cc`, `repull-after.cc`, `alias-store.cc`: single-file stores - written like `duplicate-store.cc`, through roles, for the rows of `refusals.msgpack` that open or pull them. Schemas +- `pair-store.cc`, `surrogate-store.cc`, `types-store.cc`, `repull-before.cc`, `repull-after.cc`, `alias-store.cc`, + `key-case-store.cc`, `key-punctuation-store.cc`, `surrogate-groups-store.cc`: single-file stores written like + `duplicate-store.cc`, through roles, for the rows of `refusals.msgpack` that open or pull them. Schemas `tests.unique_item`, `tests.uq_pair` (Sku and Alt both unique), `tests.uq_alias` (Sku and `alt` both unique), - `tests.uq_alpha` and `tests.uq_beta`, each slots `[0: Sku string, 1: second string]`; schema ids are the schema name - plus `.v1` (`tests.unique_item.v1`, `tests.uq_pair.v1`, `tests.uq_alias.v1`, `tests.uq_alpha.v1`, `tests.uq_beta.v1`). + `tests.uq_alpha` and `tests.uq_beta`, each slots `[0: Sku string, 1: second string]`, schema version the name plus + `.v1`. The schema ids C# writes in the store catalogs and on every record: + - `tests.unique_item`: `sha256:93bb890de83069061af696b23f94fd32fb3c2dad3c91ee645e8add56085f1882` + - `tests.uq_pair`: `sha256:2538cceafb6dcbce22ef11b932ecb804af5f96bc3aaedff692a52d3640433e60` + - `tests.uq_alias`: `sha256:77a77a394ebd8bf71e14b9b6f2cea4978c25d4e705fd12364f660edbf6c63b1f` + - `tests.uq_alpha`: `sha256:53aeaf2ea9b25e85ade6b15fc04c7653e7b206c87e258f1aa74dd32a840a1389` + - `tests.uq_beta`: `sha256:45ed62a64c91f6d815d3ec975c4a4a1b2ce07b6e7262a32d828673cf10899586` - `outcomes.msgpack`: rows `[file, unique alias or nil, open|refused, k1 or nil, k2 or nil]`. Opening `file` with that alias a unique index (nil: a role, no unique alias) yields the verdict. A refusal reads, byte for byte, `Records and (tests.unique_item) both hold unique index ''; an index value names one record.` @@ -42,20 +48,22 @@ fresh path with no file, and open a cache on it), `["pull", file]` (overwrite th file, then pull every backing store again) or `["commit", [[key, schema, sku, second], ...]]` (one batch, staged in row order; schema is the schema name). `refusal` is nil (every op succeeds) or `[k1, k2, schema, alias]`: every op but the last succeeds and the last refuses with exactly the RULE text built from those fields, leaving the file -byte-identical. Schemas are those of the store files above; `second` is `Category` (plain) except in `tests.uq_pair`, -where it is `Alt` (unique). +byte-identical. Schemas are those of the store files above; `second` is `Category` (plain) except in `tests.uq_pair` +and `tests.uq_alias`, where it is `Alt` (unique, alias `Alt` and `alt` respectively). -The 13 rows of the spec are a floor; rows 14-19 extend it with orderings that a code-point, case-insensitive or +The 13 rows of the spec are a floor; rows 14-22 extend it with orderings that a code-point, case-insensitive or culture compare would flip. Rows, in file order: 1 batch-later-value-staged-first, 2 batch-surrogate-keys, 3 batch-interleaved-types, 4 batch-two-aliases, 5 held-then-landing, 6 held-in-the-least-group, 7 swap-off-a-held-value, 8 load-two-aliases, 9 load-surrogate-keys, 10 load-interleaved-types, 11 repull-held-pair, 12 load-repull-after, 13 commit-onto-a-loaded-holder, 14 batch-key-case (`B` before `a`), 15 batch-key-punctuation (`Z` before `_` before `a`), 16 batch-key-case-in-a-group, 17 batch-surrogate-groups (U+1F600 before U+E000, the reverse of code-point order), 18 -batch-alias-case (alias `Sku` before `alt`), 19 load-alias-case. +batch-alias-case (alias `Sku` before `alt`), 19 load-alias-case, 20 load-key-case, 21 load-key-punctuation, 22 +load-surrogate-groups. Rows 19-22 open a store holding the records of rows 18, 14, 15 and 17, so a runtime with no batch +commit still walks alias and cross-group key order. A runtime performs every row its API can perform and asserts the count it walked: -- C# and Rust: all 19. -- Python: 18, every row but 3 (`put_envelopes` takes one type). -- TypeScript: 8, rows 5, 8, 9, 10, 11, 12, 13 and 19 (no batch commit, so no row 1-4, 6, 7 or 14-18; +- C# and Rust: all 22. +- Python: 21, every row but 3 (`put_envelopes` takes one type). +- TypeScript: 11, rows 5, 8, 9, 10, 11, 12, 13, 19, 20, 21 and 22 (no batch commit, so no row 1-4, 6, 7 or 14-18; `variants:idea:unique-index-runtimes.ts-batch-commit`). diff --git a/tests/vectors/unique-index/key-case-store.cc b/tests/vectors/unique-index/key-case-store.cc new file mode 100644 index 0000000000000000000000000000000000000000..b5032c8d4041f05dfb9dd52d09842bda4b0710b1 GIT binary patch literal 1177 zcmc(d%}(1u6oo z^#M@Sm!MC>B?%EI-IX6}HgkREeCOEn^G3C$Q=t0jTQ_LXKMYQO-EG@G@K~fW%=1Jt zjY-IaWFi0~q{w+_WMp*6O&%()L5E5Ph$4zH0j*=flGp@E!mk}#XZ^M=zO}etIIMmz zO^CSQMTs`3Arw3U7O^OoG2f3S|l^5hl`DariU(jlCy5hk`C4yk3Nsxnm*f!(ZJoBrUDl}UEXuA#IM)7tGot1!qE9~i{a{*M`;d@Pu73#Z*R)!`PL;h{{HA&&gZxD#q@mp+e6Jw!R>T9 w+kdhgcP}{IxLp>}8ZeeGSIAb+%jNFJ&gpD$F`XSgH?$xq{12#lZs_3R7daGo4gdfE literal 0 HcmV?d00001 diff --git a/tests/vectors/unique-index/refusals.msgpack b/tests/vectors/unique-index/refusals.msgpack index 6820a694ea540cfd7731fdfd48ddfb761e71a13a..d3cf4d3edf2a853644fc9707d421f4a95b01ca6e 100644 GIT binary patch delta 180 zcmZn@{vyJBhe2#3b2F#z_D*BXv|U` zN||t?AqffNgayJd&Lj;DkBknfk)fhm=uq(hfJHGRLhG23BsM{k&~pdYS-+|B9}RrV z9h8@I6C}=fQKAiK5i%MH5|K#qm{68*6@f759kVtwOtc|jF=CZ8tW6D#lng>V!EYDK z-=4)XrT8RD@KSFM=d~UMU!b;mxB8m~BcZH>QliF7zoKW+bzVwZUNyDNzBj0Fy{$1L z>sf5(XRgkx4vusC84T1=DST^0VFArV)thacs5{`YXF02;DDYsV;n&9^7YOyHh}=$# zOl-DWPf3DVl2zfL)2(}N9Op6Mi!>YCyR$#{+MBXBSUAGQXD`0xXmm9iPX~*qPc`QS zSN;C+{lQ@8pGCP@rg-UANPugdkaV(qGJQTwcGpXLhwH=s$(Squ1Ni7}=iU2e!~QX1 J-@R@&d;n6NfQ$eD literal 0 HcmV?d00001