Commit fb71003
refactor: extract cidx mutates check into exhaustive GroveOp method
Structural guard against the nested-cidx bug class (commit a8bb34f).
That bug existed because the pre-state capture in execute_ops_on_path
used an inline `matches!()` against a hand-maintained list of
mutating GroveOp variants. When `ReplaceCountIndexedTreeRootKeys`
was added as part of cidx primary bubble-up support, the inline
match wasn't updated — so the new variant silently fell through to
"doesn't mutate" and the outer's secondary stayed stale. The bug
passed H1-A integrity checks; only a manual audit caught it.
The fix in a8bb34f added the variant to the list, but the list is
still hand-maintained and the next new variant has the same trap.
This commit converts the inline `matches!()` into a method
`GroveOp::can_mutate_child_count(&self) -> bool` with an exhaustive
`match` and no wildcard arm. Adding any new `GroveOp` variant now
forces the author to classify it explicitly — the compiler will
refuse to compile until they do. Same protection the existing
`to_u8()` method already provides for ordering.
Each variant has a comment explaining why it's `true` or `false`:
- Leaf-level mutations (Insert/Replace/Patch/Delete/RefreshReference)
→ true: directly change a key's count_value.
- Bubble-up ops (ReplaceTreeRootKey, InsertTreeWithRootHash,
ReplaceNonMerkTreeRoot, InsertNonMerkTree, and the new
ReplaceCountIndexedTreeRootKeys) → true: each updates the child
element bytes which, for count-bearing trees, changes the
aggregated count_value (the secondary's sort key).
- Non-Merk-tree leaf inserts (Commitment/MMR/BulkAppend/DenseTree)
→ false: these trees use non-Merk storage and don't contribute
counts the same way; their propagation is tree-specific.
No behavior change. All 1576 grovedb tests still pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent dd90e6b commit fb71003
1 file changed
Lines changed: 67 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
425 | 425 | | |
426 | 426 | | |
427 | 427 | | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
428 | 489 | | |
429 | 490 | | |
430 | 491 | | |
| |||
1912 | 1973 | | |
1913 | 1974 | | |
1914 | 1975 | | |
1915 | | - | |
1916 | | - | |
1917 | | - | |
1918 | | - | |
1919 | | - | |
1920 | | - | |
1921 | | - | |
1922 | | - | |
1923 | | - | |
1924 | | - | |
1925 | | - | |
1926 | | - | |
1927 | | - | |
1928 | | - | |
1929 | | - | |
1930 | | - | |
1931 | | - | |
1932 | | - | |
1933 | | - | |
1934 | | - | |
1935 | | - | |
1936 | | - | |
1937 | | - | |
1938 | | - | |
1939 | | - | |
1940 | | - | |
1941 | | - | |
| 1976 | + | |
| 1977 | + | |
| 1978 | + | |
| 1979 | + | |
| 1980 | + | |
| 1981 | + | |
1942 | 1982 | | |
1943 | 1983 | | |
1944 | 1984 | | |
| |||
0 commit comments