Repository navigation
feat(indexed-tree)!: accept a bare SumItem under a ProvableCountProvableSumIndexedTree (GROVE_V4) - #1003
Conversation
…bleSumIndexedTree (GROVE_V4) A ProvableCountProvableSumIndexedTree primary only accepted children that carry a count and a sum explicitly (ItemWithSumItem, ReferenceWithSumItem, the count-sum trees) and refused a bare SumItem as sum-only. A SumItem in a count-and-sum tree counts one and adds its sum, which is every input the count, sum and average axes read (count_sum_value_or_default), so the refusal kept per-group counters out of the one tree that ranks groups by how many counters they hold, their total and their average. From GROVE_V4 the child rule accepts it on the direct and the batch path, through the new insert.validate_indexed_child_for_variant slot (0 for V1..V3, which keep refusing it; 1 for V4). A wrapped SumItem stays refused. Breaking: GroveDBOperationsInsertVersions gains a field. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (11)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe change adds versioned validation for bare ChangesPCPSIT SumItem child validation
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Feature Merge Risk: ⚪ Minimal · up to This change enables bare SumItem children in provable count/sum indexed trees only under GROVE_V4, leaving earlier versions unchanged. No merge-blocking risk was found in the reviewed code. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to This is a bounded, version-gated behavior change. Existing structural checks remain enforced, and no introduced security flaw was established. Compatibility after using the new behavior, especially during downgrade, remains incompletely demonstrated. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
🕓 Queued for automated review — 2nd in line, estimated start in ~10 min (commit 076b3f9)
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1003 +/- ##
===========================================
+ Coverage 93.10% 93.13% +0.02%
===========================================
Files 336 336
Lines 105421 105623 +202
===========================================
+ Hits 98153 98367 +214
+ Misses 7268 7256 -12
🚀 New features to boost your workflow:
|
Basic explanation
What this does: GroveDB has a tree that ranks its children three ways at once: by how many things each child counts, by their total, and by their average. It refuses a
SumItem(a stored number) as a child, saying the number carries no count. But in that tree aSumItemcounts as one and adds its number to the total, which is all the tree needs. This lets the tree accept it fromGROVE_V4on.Value: Platform can keep one counter per post (a
SumItemholding the post's like count) and rank authors and hashtags by number of posts, total likes and likes per post, all from one tree, without wrapping each counter in an empty item. It replaces #1002, which added a new element for this; plainSumItems do the job with no new element type.Risks: Low. Only
GROVE_V4accepts the new child;GROVE_V1..GROVE_V3keep refusing it through a version slot, so no released version changes behaviour. The tree already aggregates aSumItemcorrectly: the count, sum and average rankings all readcount_sum_value_or_default, which returns(1, n)for it. ASumItemwrapped inNonCountedor another wrapper stays refused. Code that buildsGroveDBOperationsInsertVersionsby hand needs the new field.Issue being fixed or feature implemented
A
ProvableCountProvableSumIndexedTree(PCPSIT) primary only accepted children that carry a count and a sum explicitly:ItemWithSumItem,ReferenceWithSumItemand the count-and-sum trees (validate_indexed_child_for_variant→is_count_and_sum_bearing_child). A bareSumItemwas refused as "sum-only", although in a count-and-sum tree it already contributes a count of one.Platform's count-only indexes keep one counter per group: one per post, holding the number of likes. Ranking authors by posts, likes and likes per post needs those counters under a PCPSIT:
Before: inserting
SumItem(3)atp1fails with "ProvableCountProvableSumIndexedTree only accepts children that contribute both count and sum".After (
GROVE_V4): it is accepted.aliceaggregates(2, 8), andpostAuthorranks by count, sum and average from it.What was done?
validate_indexed_child_for_varianttakes the grove version. For a PCPSIT primary it accepts a bareSumItemwhen the new slotgrovedb_versions.operations.insert.validate_indexed_child_for_variantis1. Both callers pass the version:insert_into_*_indexed_treepath;capture_indexed_pre_state→validate_indexed_child_ops.0forGROVE_V1..GROVE_V3(keep refusing) and1forGROVE_V4. It is documented in theGROVE_V4module docs.SumItemqualifies: a wrapper would suppress the count or the sum it exists to give.How Has This Been Tested?
pcpsit_accepts_a_bare_sum_item_from_grove_v4: replacespcpsit_rejects_sum_only_item, which pinned the old refusal at the latest version. The parent then aggregates(1, 42)andverify_grovedbis clean.pcpsit_child_rule_refuses_a_bare_sum_item_before_grove_v4: the rule refuses onGROVE_V1,GROVE_V2andGROVE_V3, and accepts at the latest version.pcpsit_refuses_a_wrapped_sum_item:NonCounted(SumItem)is still refused.pcpsit_sum_item_children_testsbuilds the shape above:p1to 13: the author ranking flips to alice 18 / bob 10, post counts don't move, bob still leads per post (10 against 9), and p1 leads alice's posts;verify_grovedbis clean throughout.cargo test -p grovedb -p grovedb-version --all-features: 3626 passed.cargo clippy --all-features --all-targetsandcargo fmt --checkclean.Breaking Changes
GroveDBOperationsInsertVersionsgainsvalidate_indexed_child_for_variant.GROVE_V4: a bareSumItemunder a PCPSIT primary is accepted. No released grove version changes outcome.Checklist:
For repository code-owners and collaborators only
🤖 Generated with Claude Code
PR Hygiene ·
076b3f9/skip-botsproceeds without the ones not yet reported/self-reviewedonce the bots are doneWhen every box is checked the
PR Hygienecheck passes and this can merge.Summary by CodeRabbit
SumItemchildren. Each child contributes a count of one and its sum, enabling rankings such as total and average values.SumItemchildren. WrappedSumItemchildren remain unsupported across all versions.