Skip to content

fix(drive): reject zero effective distinct count limit#4197

Merged
QuantumExplorer merged 3 commits into
v4.1-devfrom
claude/aggregate-limit-followups
Jul 22, 2026
Merged

fix(drive): reject zero effective distinct count limit#4197
QuantumExplorer merged 3 commits into
v4.1-devfrom
claude/aggregate-limit-followups

Conversation

@QuantumExplorer

Copy link
Copy Markdown
Member

What

  • reject a zero effective limit on the no-proof distinct COUNT walk before it reaches storage, mirroring the sum-side effective_no_proof_distinct_limit policy (with a regression test)
  • return CorruptedCodeExecution instead of unreachable! ahead of the distinct SUM storage walk
  • strengthen the distinct-SUM limit regression so the max-clamp case actually truncates at storage (four matching values against max_query_limit: 3)

Why

Review follow-ups to #4149, which merged while they were being prepared:

  • A max_query_limit: 0 config (or explicit zero limit) previously reached grovedb with a zero bound on the count path, which returns nothing and masquerades as an empty result set. The sum side already failed closed; the count side now matches.
  • The unreachable! was provably dead, but a future early-exit in the aggregate branch would have turned it into a query-path panic rather than an error.
  • The prior clamp test case matched only three distinct values, so it passed identically with or without the storage bound.

Checks

  • cargo test -p drive --features server drive_document_sum_query (30 passed)
  • cargo test -p drive --features server drive_document_count_query (49 passed)
  • cargo clippy -p drive --features server --all-targets
  • cargo check -p drive --no-default-features --features verify
  • cargo fmt --all -- --check

🤖 Generated with Claude Code

QuantumExplorer and others added 3 commits July 22, 2026 14:43
With four colors and the `> "blue"` predicate only three distinct
values matched, so the Some(10_000) clamp case passed identically
whether the storage walk was bounded or not. A fifth color makes the
predicate match four values — one more than max_query_limit — so the
clamp case now fails against an unbounded walk.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The walk-mode destructure is provably dead today (both aggregate arms
return earlier in the function), but a future early-exit added to the
aggregate branch would turn the unreachable! into a panic on the query
path. Return CorruptedCodeExecution instead, matching how rs-drive
reports defensive impossibilities elsewhere.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Port the sum-side zero-limit fail-closed check to the count dispatcher:
a max_query_limit of 0 (or an explicit limit of 0) previously reached
grovedb with a zero bound, which returns nothing and masquerades as an
empty result set. Now rejected as InvalidLimit before the storage walk,
mirroring effective_no_proof_distinct_limit on the sum side.

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

thepastaclaw commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

🕓 Ready for review — 36 ahead in queue (commit 0b19b3f)
Queue position: 37/72 · 2 reviews active
ETA: start ~04:21 UTC · complete ~04:50 UTC (median 28m across 30 recent reviews; 2 slots)
Queued 12h 55m ago · Last checked: 2026-07-22 19:40 UTC

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

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

Next review available in: 15 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 31e8d9fc-5fa5-45f9-b3a7-25a8a0f665cc

📥 Commits

Reviewing files that changed from the base of the PR and between 4f245ff and 0b19b3f.

📒 Files selected for processing (4)
  • packages/rs-drive/src/query/drive_document_count_query/drive_dispatcher.rs
  • packages/rs-drive/src/query/drive_document_count_query/tests.rs
  • packages/rs-drive/src/query/drive_document_sum_query/execute_range_sum.rs
  • packages/rs-drive/src/query/drive_document_sum_query/tests.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/aggregate-limit-followups

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.

@github-actions github-actions Bot added this to the v4.1.0 milestone Jul 22, 2026
@QuantumExplorer
QuantumExplorer merged commit 8fb632e into v4.1-dev Jul 22, 2026
20 of 21 checks passed
@QuantumExplorer
QuantumExplorer deleted the claude/aggregate-limit-followups branch July 22, 2026 07:14
@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.72727% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.49%. Comparing base (4f245ff) to head (0b19b3f).
⚠️ Report is 37 commits behind head on v4.1-dev.

Files with missing lines Patch % Lines
...uery/drive_document_sum_query/execute_range_sum.rs 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           v4.1-dev    #4197      +/-   ##
============================================
+ Coverage     87.48%   87.49%   +0.01%     
============================================
  Files          2651     2663      +12     
  Lines        334673   336422    +1749     
============================================
+ Hits         292793   294360    +1567     
- Misses        41880    42062     +182     
Components Coverage Δ
dpp 88.44% <ø> (-0.01%) ⬇️
drive 86.24% <72.72%> (+0.07%) ⬆️
drive-abci 89.55% <ø> (-0.10%) ⬇️
sdk ∅ <ø> (∅)
dapi-client ∅ <ø> (∅)
platform-version ∅ <ø> (∅)
platform-value 92.90% <ø> (ø)
platform-wallet ∅ <ø> (∅)
drive-proof-verifier 49.79% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

2 participants