Skip to content
Source
Sign inSign up
TanStack/db

test: repair structural identity oracle normal form #2153

MergedKyleAMathewsmerged 9 commits intomain fromrefs/pull/2153/headmerged by KyleAMathews

Showing 5 changed files with 177 additions and 1 deletion (loading 2).

x
0 of 5 viewed, 5 left
175 additions and 0 deletionsdocs/contributing/oracle-reviews/2026-10-14-ivm-structural-identity-normal-form.mdAdded
View file
@@ -0,0 +1,175 @@
+# Structural identity oracle review — 2026-10-14
+​
+Reviewed executable head: `e1cd28afb6b9bd76641b42a06110eb184b5fac1a`.
+Base: `87bc07354fa47df48e9b05c599f24dad74dea0f3` (`origin/main` at review).
+The binary diff for the oracle, replay registry and manifest, and coverage map
+has SHA-256 `9e94b37b8a03caa07f457d80d82a7aff399f70e3b47a6c59fe10190b43071c84`.
+This record is added after the reviewed executable head; it changes no test or
+production behavior.
+​
+## Law, failure, and observation
+​
+`structuralIdentity` must give equal D2 values the same result, including two
+undefined results, and must not give unequal values the same defined string.
+The contract is stated beside `structuralIdentity` in `hash.ts`; `groupBy`
+depends on it when it merges contributions. The oracle checks the direct
+`structuralIdentity` and `equalHashValues` return values after each call. It
+does not claim to prove `groupBy` integration, which the incrementalization
+law owns.
+​
+On untouched main, the independent-pair property failed at seed `1158727847`,
+path `255`: an explicit array around `deep(5, value)` and `deep(6, value)`
+built equal arrays, but the model gave their specs different normal forms. This
+was an oracle model error. The repair expands `deep` shorthand into repeated
+one-element array normal forms. A named equal pair preserves the original
+witness, and an adjacent-depth pair checks that the model still distinguishes
+one missing array level. The equal-pair grammar now generates both same-spec
+and explicit-array/`deep` spellings. A structural grammar filter excludes