pin the emptied-leaflet and NumBig-gate check ordering - #1642
Conversation
The gate and the rebuild that drops retracted partitions have to compose, and the load-bearing detail is an ordering one: the directory walk skips an entry on row_count == 0 || lead_group_count == 0 before it consults leaflet_may_hold_non_identifying_o_key, so an emptied leaflet whose key range still spans NUM_BIG_OVERFLOW cannot trip the gate. That is not hypothetical. Inverting the two checks makes this case fail: after retracting every decimal the rebuilt index still carries leaflets whose range covers the NumBig o_type, so a gate consulted first would decline whole-graph COUNT(DISTINCT ?o) forever on any ledger that had ever held a decimal. Nothing else in the file would catch it — every other case runs on a freshly imported ledger with nothing retracted. Seed six distinct objects of which two are decimals, index, assert the gate declines and the general pipeline answers 6; retract both decimals, reindex, assert the answer is 4 and the site proceeds again. The first half doubles as the lane probe, so the second half cannot pass vacuously.
|
This looks like it's no longer needed — #1644 (merged 2026-08-20, after this branch's last commit) redesigned the exact code path this PR pins. For context: this PR pins the check ordering in the directory walk this test exercises — #1644 replaced that decline-outright behavior with an exact NumBig counter that runs alongside the plain object count (
So the specific composition risk this PR guards against looks like it's already covered by whatever test discipline landed with #1644, and the emptied-leaflet interaction this PR is about doesn't currently distinguish correct from swapped ordering anymore. If there's a scenario #1644's own tests don't reach where the ordering still matters, happy to be pointed at it — otherwise this looks safe to close in favor of #1644's coverage. |
Test-only. #1624 lets a rebuild leave emptied leaflets behind, and #1628 added a gate that declines the whole-graph
COUNT(DISTINCT ?o)fast path when a leaflet's key range coversOType::NUM_BIG_OVERFLOW. Those two compose only because the directory walk skips an entry onrow_count == 0 || lead_group_count == 0before it consultsleaflet_may_hold_non_identifying_o_key— bplatz checked that by reading during #1628's review, and this pins it by execution instead.It is not a no-op confirmation. Reordering the two checks turns this test red, which means the emptied leaflets really do still carry key ranges spanning the NumBig
o_type— so a gate consulted first would decline whole-graphCOUNT(DISTINCT ?o)permanently on any ledger that has ever held a decimal. Nothing else in the file would catch that, since every other case runs on a freshly imported ledger with nothing retracted.The shape is decline-then-proceed across a retract-and-reindex cycle: seed six distinct objects of which two are decimals, index, assert the gate declines and the general pipeline answers 6; retract both decimals, reindex, assert the answer is 4 and
distinct object COUNTproceeds again. The first half doubles as the lane probe, so the second half can't pass vacuously on a ledger that never made it onto the indexed lane.Related: the exact NumBig-aware counter that would restore the fast path for decimal-bearing ledgers is tracked separately in #1638; this PR only pins the ordering the current gate depends on.