Skip to content

feat(version): add GROVE_V4, behaviourally identical to V3 - #777

Merged
QuantumExplorer merged 2 commits into
developfrom
feat/grove-v4
Jul 30, 2026
Merged

feat(version): add GROVE_V4, behaviourally identical to V3#777
QuantumExplorer merged 2 commits into
developfrom
feat/grove-v4

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Jul 30, 2026

Copy link
Copy Markdown
Member

Why

GROVE_V3 is live. A fix that changes an accepted/rejected outcome, a committed root hash, or a tracked cost therefore cannot be applied unconditionally — nodes carrying it would diverge from nodes that do not. Today there is nowhere for such a fix to land, which has left several stuck:

Fix Why it cannot land ungated
#776 — bare Reference overwrite skips indexed secondary cleanup costs an extra stored-element read on every reference overwrite (+1 seek, +79 storage_loaded_bytes, measured by the refresh-reference cost tests); references over plain trees are shipped
Batch DeleteTree trusts the caller-declared tree type when selecting cleanup namespaces reading the stored element instead fixes an indexed type-confusion and a live CommitmentTree wrong-emptiness-path bug, but adds a read to a released path
#726, #730, #732, #734, #739 currently gated on v3; need re-gating before they can merge

What this does

Adds the version and nothing else. Every method-version slot is copied from V3 unchanged, so activating protocol version 4 today is a no-op. Each future gate is a deliberate, separately-reviewable slot bump — the same pattern add_element_on_transaction: 1 already uses in v3.rs.

Landing it standalone rather than inside a feature branch means all six of the PRs above can target it independently, and avoids a multi-way conflict in v4.rs.

Verification

Registering V4 changes what GroveVersion::latest() resolves to, and the whole test suite defaults to latest — so "identical to V3" needed checking, not assuming.

The full workspace suite passes with V4 as latest (2459 grovedb + 705 merk + the rest). The only two failures were the version registry's own self-describing tests, grove_version_latest_returns_v3 and grove_versions_count, both updated here. That the behavioural suite is untouched is the evidence this change is inert.

Also adds grove_v4_is_behaviourally_identical_to_v3_until_a_gate_is_added, which compares every slot and fails the moment one is bumped — the intended prompt to document a gate rather than let V4 accrete behaviour silently.

Note for reviewers

This does not activate anything. Platform must adopt protocol version 4 for any future gate to take effect, and until then V1–V3 behaviour is entirely unchanged. Worth deciding the full gate list before activation so "what changes when we turn on 4?" has one answer.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added protocol version 4 support.
    • GroveDB now recognizes protocol V4 as the latest available version.
    • Introduced V4 version definitions for GroveDB and Merk operations, initially preserving V3 behavior where no explicit changes are gated.
  • Tests

    • Expanded version-selection coverage to include V4.
    • Added regression checks confirming V4’s initial behavior matches V3.

GROVE_V3 is live, so a fix that changes an accepted/rejected outcome, a
committed root hash, or a tracked cost cannot be applied unconditionally —
nodes carrying it would diverge from nodes that do not. There is currently
nowhere for such a fix to land, which has left several of them stuck:

  - #776: overwriting an indexed tree with a bare Reference skips the
    per-axis secondary cleanup. Closing it costs an extra stored-element read
    on EVERY reference overwrite (+1 seek, +79 storage_loaded_bytes, measured
    by the refresh-reference cost tests), and references over plain trees are
    shipped functionality.
  - Batch DeleteTree treats the caller-declared tree type as authoritative
    when selecting cleanup namespaces. Reading the stored element instead
    fixes both an indexed type-confusion and a live CommitmentTree
    wrong-emptiness-path bug, but adds a read to a released path.
  - Per project notes, five audit-fix PRs (#726, #730, #732, #734, #739)
    are gated on v3 and need re-gating before they can merge.

This adds the version and nothing else. Every method-version slot is copied
from V3 unchanged, so activating protocol version 4 today is a no-op; each
gate is a deliberate, separately-reviewable slot bump.

Verified rather than assumed: registering V4 changes what
`GroveVersion::latest()` resolves to, and the whole test suite defaults to
latest. The full workspace suite passes with V4 as latest (2459 grovedb + 705
merk + the rest), and the only two failures were the version registry's own
self-describing tests — `grove_version_latest_returns_v3` and
`grove_versions_count` — which are updated here. That is the evidence the
change is inert.

Adds `grove_v4_is_behaviourally_identical_to_v3_until_a_gate_is_added`, which
compares every slot and fails the moment one is bumped. That failure is the
intended prompt to document the gate rather than let V4 accrete behaviour
silently.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@QuantumExplorer, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 55 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 22f93991-6398-4e0a-9aab-ab4291f92869

📥 Commits

Reviewing files that changed from the base of the PR and between 98c8e75 and 543fb39.

📒 Files selected for processing (1)
  • grovedb-version/src/tests.rs
📝 Walkthrough

Walkthrough

Protocol V4 is added as a public Grove version constant, registered in GROVE_VERSIONS, and selected as the latest version. Tests verify the registry size, latest protocol, and V4 slot compatibility with V3.

Changes

Grove protocol V4

Layer / File(s) Summary
Define and register protocol V4
grovedb-version/src/version/v4.rs, grovedb-version/src/version/mod.rs
Defines GROVE_V4 with explicit Grovedb and Merk method-version slots, exports the module, and adds V4 to GROVE_VERSIONS.
Validate V4 selection and compatibility
grovedb-version/src/tests.rs
Verifies V4 is the latest registered protocol, updates the registry count to four versions, and compares V4 slots with V3.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • dashpay/grovedb#669: Adds code paths gated by the Merk proof version slots introduced for V4.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly states the main change: adding GROVE_V4 and noting it matches V3 behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/grove-v4

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

It pinned V4's initial state as inert, which was worth verifying once but
becomes churn the moment a gate is added — and the DeleteTree read and #776
are both queued to gate on V4 next, so it would fail immediately and be
deleted anyway.

The evidence it provided is preserved where it belongs: the PR description
records that the full workspace suite passed with V4 as latest and that only
the registry's own self-describing tests changed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@QuantumExplorer
QuantumExplorer merged commit 4fef572 into develop Jul 30, 2026
8 checks passed
@QuantumExplorer
QuantumExplorer deleted the feat/grove-v4 branch July 30, 2026 10:57
@codecov

codecov Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.49%. Comparing base (cc60ac9) to head (543fb39).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #777   +/-   ##
========================================
  Coverage    91.49%   91.49%           
========================================
  Files          240      240           
  Lines        67763    67763           
========================================
  Hits         62003    62003           
  Misses        5760     5760           
Components Coverage Δ
grovedb-core 89.07% <ø> (ø)
merk 92.32% <ø> (ø)
storage 86.52% <ø> (ø)
commitment-tree 96.05% <ø> (ø)
mmr 96.79% <ø> (ø)
bulk-append-tree 89.82% <ø> (ø)
element 97.38% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant