Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (1)No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughCarrier aggregate proof verification now uses server-matching limits for range-outer and In-outer queries. Tests cover default and explicit limits, rejected limits, and capped range-outer proof verification. ChangesCarrier proof limit handling
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The SDK now accepts valid proofs for grouped COUNT queries with two range clauses when the outer range has more than ten keys. It does this by using the same limit rule as the server. Tests cover the change, and no blocking issues remain. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 2 systems. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 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 |
|
|
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (50.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## v4.2-dev #4432 +/- ##
============================================
- Coverage 78.02% 77.70% -0.32%
============================================
Files 2914 2914
Lines 417863 419815 +1952
============================================
+ Hits 326025 326218 +193
- Misses 91838 93597 +1759
🚀 New features to boost your workflow:
|
thepastaclaw
left a comment
There was a problem hiding this comment.
Preliminary review — Codex only
The COUNT carrier conversion now matches the server's G7/G8 path-query shapes, but the new shared gate treats the configurable default of 100 as a universal server ceiling. This rejects valid proofs from servers configured above 100 and cannot establish the claimed request/server parity for servers configured below 100, so the limit policy must be made fixed on the server or conveyed to the verifier through authenticated input. Source: Codex reviewer lanes codex-general, codex-security-auditor, and codex-rust-quality (exact backend model identifiers were not present in the supplied evidence); final verifier: Anthropic Claude Agent SDK (exact model identifier not exposed); openclaw-agent/cliproxy/gpt-5.6-sol is orchestration-only and not reviewer evidence.
Validated blockers were found in the Codex precheck. Opus is deferred until a fresh Codex revalidation clears the blocker gate.
Review provenance
- Codex reviewers:
gpt-5.6-sol— general (completed),gpt-5.6-sol— security-auditor (completed),gpt-5.6-sol— rust-quality (completed) - Verifier:
gpt-5.6-sol— verifier - Sonnet: not run (deferred by blocker gate)
🔴 1 blocking | 🟡 2 suggestion(s)
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `packages/dash-platform-queries/src/documents/aggregate_limit.rs`:
- [BLOCKING] packages/dash-platform-queries/src/documents/aggregate_limit.rs:62-68: The default limit is not the server's actual cap
`DEFAULT_MAX_QUERY_LIMIT` is only the default for the environment-configurable `DriveConfig::max_query_limit`; `PlatformConfig` flattens that configuration and the COUNT, SUM, and AVG proof dispatchers compare requests against `request.drive_config.max_query_limit`. For example, a server configured with `max_query_limit = 200` can legitimately produce a RangeDistinctProof for an explicit limit of 101, but this verifier rejects that authentic response before verification. Conversely, a server configured with a cap of 50 refuses a limit of 75 while this gate accepts it, so the gate does not provide the claimed server-policy binding. Make the proof-serving policy a shared compile-time ceiling on the server as well, or provide the effective policy to the verifier through authenticated input; using the configuration default as though it were every server's runtime value is neither parity-preserving nor backward-compatible.
In `packages/dash-platform-queries/src/documents/count_proof_helpers.rs`:
- [SUGGESTION] packages/dash-platform-queries/src/documents/count_proof_helpers.rs:282-288: Exercise COUNT carrier shape translation through the real verifier path
The proof-sensitive behavior depends on both deriving `has_outer_range` from the request clauses and passing the converted limit into `verify_carrier_aggregate_count_proof`. The new unit tests bypass that composition by supplying `true` or `false` directly, while the integration test only exercises the shared over-100 gate before mode detection. A transposed predicate, incorrect mode route, or wrong argument at the proof call would therefore leave all new tests passing while valid G7/G8 proofs fail. Add entry-point coverage for G8 with unset, 10, and 11 limits and G7 with unset and explicit limits; server-produced or checked-in proof fixtures should also verify that the reconstructed `SizedQuery::limit` matches end to end.
In `packages/dash-platform-queries/tests/aggregate_limit_parity.rs`:
- [SUGGESTION] packages/dash-platform-queries/tests/aggregate_limit_parity.rs:93-98: Assert the typed RequestError instead of only its Display text
The regression test checks only the formatted error text, so another error variant containing the same substring would satisfy it. Destructure `drive_proof_verifier::Error::RequestError` first and then inspect its payload; this pins both the typed API result and the intended limit-gate message.
7769e31 to
7a9991d
Compare
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 2 only (queue backlog)
At head 7a9991d, the SDK's carrier-limit translation matches the server's range-outer and In-outer policies; no blocking correctness or security issues were identified. Local validation passed all 59 dash-platform-queries library tests and the new Drive capped-proof regression test. One non-blocking maintainability suggestion remains: share the proof-sensitive limit policy between the dispatcher and SDK adapter.
🟡 1 suggestion(s)
Review provenance
Source: reviewer 1: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); reviewer 4: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); reviewer 5: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 6: gpt-6-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 7: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); reviewer 8: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6-astra (agent: astra-verifier, role: final-verifier)
- Triage:
normalbygpt-6-astra(effort low) — This is a contained SDK proof-verification logic fix with substantial targeted tests, but it does not modify consensus rules, cryptography, signatures, funds, peer-facing deserialization, or storage migrations. - Phase 1 reviewers: not run (skipped for throughput: 20 PRs queued, above the 10 limit)
- Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
- Fresh verifier:
gpt-6-astra— final-verifier; agentastra-verifier - Phase 2 reviewers:
gpt-6-astra— general (completed, effort high); agentphase2-reviewer,gpt-6-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6-astra— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6-astra— security-auditor (completed, effort high); agentphase2-reviewer,gpt-6-astra— general (completed, effort high); agentphase2-reviewer,gpt-6-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6-astra— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6-astra— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `packages/dash-platform-queries/src/documents/count_proof_helpers.rs`:
- [SUGGESTION] packages/dash-platform-queries/src/documents/count_proof_helpers.rs:125-138: Share carrier-limit lowering with the Drive dispatcher
This helper duplicates the shape predicate and limit defaulting/rejection rules in `rs-drive/src/query/drive_document_count_query/drive_dispatcher.rs:510–552`. The implementations agree today, but sharing only the cap constant leaves two independently maintained versions of the proof-sensitive policy whose disagreement caused this bug. The helper tests and Drive round-trip test cover each implementation separately rather than enforcing their equivalence. Extract this calculation into a pure helper under `rs-drive::query::drive_document_count_query`, available with both `server` and `verify`, and call it from both locations. Accept `Option<u32>` and return a Drive query error, leaving the SDK's zero-to-None conversion and error mapping here. Keep the low-level proof verifier's explicit effective-limit contract unchanged.
|
Your move: thepastaclaw left review threads unresolved; resolve them. |
7a9991d to
2c0234e
Compare
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Independently reviewed the complete four-file diff at 2c0234e and found no in-scope defects. The shared Drive helper preserves the server's limit policy and error behavior while correcting SDK reconstruction of capped carrier COUNT proofs, resolving the prior architecture finding. Local validation passed all 59 dash-platform-queries library tests, all 69 Drive COUNT-query tests, and git diff --check; the worktree remains unchanged.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: architecture-layering); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 4: muse-spark-1.3-contributor (agent: phase1-reviewer, role: security-auditor); reviewer 5: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 6: gpt-6-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 7: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); reviewer 8: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); reviewer 9: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 10: gpt-6-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 11: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); reviewer 12: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6-astra (agent: astra-verifier, role: final-verifier)
- Triage:
normalbygpt-6-astra(effort low) — The diff changes proof-query limit reconstruction and shares dispatcher validation across Drive and the SDK with regression tests, but it is a contained logic fix rather than a large or intricate change to cryptography or consensus rules. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— architecture-layering (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— security-auditor (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity below 15% reserve: weekly 13% left, 5h 100% left),glm-5.3-flash(not used above high effort; tier asks max) - Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
- Fresh verifier:
gpt-6-astra— final-verifier; agentastra-verifier - Phase 2 reviewers:
gpt-6-astra— general (completed, effort high); agentphase2-reviewer,gpt-6-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6-astra— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6-astra— security-auditor (completed, effort high); agentphase2-reviewer,gpt-6-astra— general (completed, effort high); agentphase2-reviewer,gpt-6-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6-astra— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6-astra— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.
No unresolved findings remain from the prior review on this head.
|
Bots are done — your move: post |
…ng range-outer carrier proofs A grouped COUNT with two range clauses on distinct fields (`bucket > X AND score > Y`, `GROUP BY bucket`, proofs on) is served by the range-outer carrier-aggregate proof. On that shape the server caps the outer walk at the compile-time MAX_CARRIER_AGGREGATE_OUTER_RANGE_LIMIT (10): an unset request limit is lowered to the cap and the prover stops after ten outer keys, abridging the rest of the tree. The SDK verifier rebuilt the path query with `limit: None` for every carrier shape, so once the outer range held more than ten keys the merk walker expected an unbounded walk, ran into the abridged region, and rejected an honest proof with "proof is missing data for query range". Ranges of ten keys or fewer verified by accident because the prover never truncated. Derive the outer-walk limit the way the dispatcher does. Range-outer: unset lowers to the cap, explicit limits pass through up to the cap, anything above the cap is refused before a proof is inspected (the server refuses those requests too, so no proof can belong to them). In-outer: unset stays `None` because the In array already bounds the walk, and every explicit limit is refused, as on the server. Add an rs-drive prove-then-verify round trip over twelve outer keys that pins the dispatcher lowering, verifies with the capped limit, and shows the same bytes failing under `limit: None`. No such round trip existed; the only caller of the carrier count verifier was the SDK, and the SDK's own tests for this shape go through a mock transport that never runs it. Reproduced on testnet (Drive 4.1.0, protocol 13) against contract 6TjweyPbxLNB4BhyVBcAzTxo54jDn33s5Y5j78WKM43Z with twelve documents: the previous verifier fails on the unset-limit query and passes with explicit limits 5 and 10; this verifier passes all three and returns ten entries for the unset case. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…e SDK verifier The range-outer carrier COUNT bug came from the SDK verifier and the COUNT dispatcher deriving `SizedQuery::limit` independently. The previous commit fixed it by mirroring the dispatcher's rule in the SDK, which still left two copies of a proof-sensitive policy to keep in sync. Move the rule into `DriveDocumentCountQuery::carrier_aggregate_outer_limit` in `mode_detection.rs`, next to `detect_mode`, built for both `server` and `verify` like the rest of that module. The dispatcher's `RangeAggregateCarrierProof` arm now calls it; its behaviour and error messages are unchanged. The SDK's `carrier_walk_limit` becomes a thin adapter that maps its `0` sentinel to `None` and wraps the Drive error. The rs-drive round-trip test derives its verify limit through the same helper, so a proof produced by the dispatcher is now checked against the limit the verifier actually computes. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2c0234e to
b36acbd
Compare
|
Waiting for bot review — coderabbitai ✓ · thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
|
/self-reviewed |
|
@thepastaclaw review No review for |
|
Closing this in favour of a different approach. The issue itself is still real: a grouped range-over-range COUNT ( The fix here makes the SDK reproduce the server's limit exactly. That works, but only because GroveDB's verifier treats One correction to the description above: the limit is not hashed into the proof. It only tells the verifier where a hidden tail is allowed. The proof already shows where the prover stopped, so the client doesn't need to know the server's limit to verify it. New approach:
The prove-then-verify test from this PR ( 🤖 Posted autonomously by Codex on behalf of pasta. |
|
The GroveDB side of the new approach is up: dashpay/grovedb#1008 adds an opt-in verification mode where 🤖 Posted autonomously by Codex on behalf of pasta. |
Issue being fixed or feature implemented
A grouped COUNT over two range clauses on distinct fields cannot be verified by the SDK once the outer range holds more than ten distinct keys. The server answers with a valid proof; the client rejects it.
The shape is any
rangeCountableindex of at least two properties queried asDrive serves this with the range-outer carrier-aggregate proof and caps the outer walk at the compile-time
MAX_CARRIER_AGGREGATE_OUTER_RANGE_LIMIT(10). When the request leaves the limit unset the dispatcher lowers it to the cap, the prover walks ten outer keys and abridges the rest of the tree, and thatSome(10)becomes part of the path query the proof commits to.The SDK verifier rebuilt the path query with
limit: Nonefor every carrier shape. With eleven or more outer keys the merk walker expected an unbounded walk, reached the abridged region, and failed with:Ten keys or fewer verified by accident because the prover never truncated, which is why this was not caught: the cap only matters once real data exceeds it, and no prove-then-verify test for this shape existed. The only caller of the carrier count verifier is the SDK, and the SDK's tests for this shape run through a mock transport that never executes it.
Why it matters
SizedQuery::limitis committed to by the proof. A client that reconstructs it differently from the server cannot verify honest answers, and a client that accepts limits the server refuses can be handed a proof for a narrower query than it asked for. Both sides must derive the value from the same rule.What was done?
The SDK COUNT verifier now derives the outer-walk limit exactly as the dispatcher does, keyed on the request's where-clause shape:
MAX_CARRIER_AGGREGATE_OUTER_RANGE_LIMIT; explicit limits pass through up to the cap; anything above the cap is refused before a proof is inspected, because the server refuses those requests and no proof can belong to them.Nonebecause the In array already bounds the walk; every explicit limit is refused, as on the server.The rule lives in one place:
DriveDocumentCountQuery::carrier_aggregate_outer_limitin rs-drive'smode_detection.rs, next todetect_mode, built for bothserverandverify. The dispatcher'sRangeAggregateCarrierProofarm calls it, with the same behaviour and error messages as the inline code it replaces. The SDK'scarrier_walk_limitis a thin adapter that maps its0"unset" sentinel toNoneand wraps the Drive error. Sharing it means prover and verifier cannot drift on this rule again, which is how this bug arose. SUM and AVG are untouched: their dispatchers do not apply the range-outer lowering, so their verifiers already agree with the server.Tests
test_range_outer_carrier_proof_verifies_with_capped_limit_not_none: the first prove-then-verify round trip for this proof shape. Twelve outer keys, unset limit. Pins that the dispatcher lowers to the cap, that the limit the verifier derives through the shared helper is that cap and verifies to exactly ten entries, and that the same bytes fail underlimit: None.RequestError.Verified on testnet
Reproduced against testnet (Drive 4.1.0, protocol 13) with contract
6TjweyPbxLNB4BhyVBcAzTxo54jDn33s5Y5j78WKM43Z(bucketeddocument type, index(bucket, score)markedrangeCountable) holding twelve documents with distinctbucketvalues, queryCOUNT(*) WHERE bucket > 0 AND score > 0 GROUP BY bucket:InvalidLimitFollow-ups deliberately not in this PR
An earlier revision of this PR also added a client-side gate at the compile-time default of
max_query_limitfor all three aggregate verifiers. Review pointed out thatmax_query_limitis operator-configurable and the server compares against the runtime value, so a fixed client-side cap would reject authentic proofs from nodes configured above the default and still admit limits nodes configured below it refuse. That gate is dropped; the existingu16narrowing plus server-side rejection is the honest amount of validation the client can do without an authenticated view of server configuration.Still open, unchanged from before:
DocumentQuerywith no wire-request wrapper.Aggregatemode and for SUM/AVG, where alimit: 50request still verifies against a proof produced forlimit: None.Breaking Changes
None. Requests an honest server serves verify exactly as before, plus the range-outer shape now verifies past ten keys. The newly rejected requests are ones the server already refuses with
InvalidLimit.Checklist:
Summary by CodeRabbit
Bug Fixes
Tests
PR Hygiene ·
b36acbd/skip-botsproceeds without the ones not yet reportedpackages/dash-platform-queries/src/documents/count_proof_helpers.rs) — QuantumExplorer or shumkovrs-drive(packages/rs-drive/src/query/drive_document_count_query/drive_dispatcher.rs,packages/rs-drive/src/query/drive_document_count_query/mode_detection.rs,packages/rs-drive/src/query/drive_document_count_query/tests.rs) — QuantumExplorer or shumkovWhen every box is checked the
PR Hygienecheck passes and this can merge.