Skip to content

feat(sdk): composite document queries, the client stack - #4600

Merged
QuantumExplorer merged 1 commit into
feat/composite-document-queries-drivefrom
feat/composite-document-queries-sdk
Sep 5, 2026
Merged

feat(sdk): composite document queries, the client stack#4600
QuantumExplorer merged 1 commit into
feat/composite-document-queries-drivefrom
feat/composite-document-queries-sdk

Conversation

@QuantumExplorer

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

Part of the composite document query series (Yappr feed: one merged proof per feed page instead of 15 to 19 round trips). Stack:

  1. feat: merge a limited path query below a key another branch already owns grovedb#850 (recursive graft for colliding limited branches)
  2. chore: bump grovedb to 2d95c567 (#850 merged: limited branches graft below a shared key) #4597 (grovedb pin)
  3. feat(drive): composite document queries: a page plus derived sub-queries under one merged proof #4598 (rs-drive core: shapes, execution, merged proof, verifier)
  4. feat(dapi): composite document queries on the getDocuments V1 wire #4599 (wire: proto sub_queries, drive-abci dispatch)
  5. this PR (client stack: dash-platform-queries, proof verifier, rs-sdk)
  6. next: wasm-sdk + js-evo-sdk surface

What was done?

The client half of composite queries, mirroring the chained-query client stack shipped in #4552:

  • dash-platform-queries: CompositeDocumentQuery (a page DocumentQuery plus a list of CompositeSubQuery, each with a kind, fixed clauses, an optional per-value limit and an optional binding). The V1 wire encoder attaches sub_queries to the typed request and refuses the V0 wire, a zero page limit, cursors, offsets, projections, grouping and time ranges. The rich-to-drive conversion mirrors the server's sub-query limit contract ([1, 100], refused rather than clamped). FromProof<CompositeDocumentQuery> for CompositeDocuments verifies the single merged proof. Builders: CompositeSubQuery::documents(..) / ::count(..), .bound_to_page(source_property, field), .bound_to(CompositeBindingSource::SubQuery(n), ..), .with_where, .with_order_by, .with_limit.
  • rs-drive-proof-verifier: CompositeDocuments { page_documents, sub_results } and verify_composite_documents_tenderdash_proof, composing rs-drive's merged-proof verification (bootstrap subset pass on the page, re-derivation of every sub-query, one authoritative verify, routing with completeness checks) with the tenderdash root binding. CompositeSubQueryResult (rs-drive's SubQueryResult) is re-exported at the crate root, like SplitCountEntry.
  • rs-sdk: the Query impls, impl Fetch for CompositeDocuments, the mock round-trip (page and documents sub-results as per-document CBOR, count sub-results as triples, all order preserving), and the platform re-exports.
  • rs-drive-abci: a composite_trust_boundary suite that runs the actual SDK entry points against server-generated proofs, same split as the having and chained suites. It covers the wire encoding, the full FromProof composition (page, like counts, quoted-post by-id join, cross-contract profile lookup where one author's missing profile is a proven absence), a wrong quorum key, tampered metadata, and a plain page-only proof presented for the composite query.

Usage:

let page = DocumentQuery::new(feed.clone(), "post")?
    .with_where(WhereClause { field: "hashtag".into(), operator: WhereOperator::Equal, value: "dash".into() })
    .with_limit(20);
let query = CompositeDocumentQuery::new(page)
    .with_sub_query(CompositeSubQuery::count(feed.clone(), "like")?.bound_to_page("$id", "postId"))
    .with_sub_query(CompositeSubQuery::documents(feed.clone(), "post")?.bound_to_page("quotedPostId", "$id"))
    .with_sub_query(CompositeSubQuery::documents(dashpay, "profile")?.bound_to_page("$ownerId", "$ownerId"));
let feed_page = CompositeDocuments::fetch(&sdk, query).await?;

How Has This Been Tested?

  • cargo test -p dash-platform-queries composite: 7 offline tests (wire shape, source numbering, page-limit and page-feature refusals, drive conversion + shape validation, out-of-range sub-query limit, non-refersTo join refusal).
  • cargo test -p drive-abci --lib composite_trust_boundary: 5 tests, all green.
  • cargo clippy -p dash-platform-queries -p drive-proof-verifier -p dash-sdk -p drive-abci --features dash-sdk/mocks --tests: clean apart from the pre-existing rs-drive DocumentPropertyType unused import under verify-only features.

Breaking Changes

None. New types and functions only; the chained surface is untouched.

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation
  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: d95fea13-e8d4-4c47-b2fd-3d5964c13088

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@thepastaclaw

thepastaclaw commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

🕓 Ready for review — 56 ahead in queue (commit 2e24461)
Queue position: 57/59 · 2 reviews active
ETA: start ~2026-09-06 11:08 UTC · complete ~2026-09-06 12:03 UTC (median 54m across 30 recent reviews; 2 slots)
Queued 5m ago · Last checked: 2026-09-05 09:30 UTC

@QuantumExplorer
QuantumExplorer force-pushed the feat/composite-document-queries-wire branch from 8c20866 to ea1a00d Compare September 5, 2026 03:55
@QuantumExplorer
QuantumExplorer force-pushed the feat/composite-document-queries-sdk branch from 1529610 to 4997361 Compare September 5, 2026 03:55
@QuantumExplorer
QuantumExplorer force-pushed the feat/composite-document-queries-wire branch from ea1a00d to 87435c1 Compare September 5, 2026 03:56
@QuantumExplorer
QuantumExplorer force-pushed the feat/composite-document-queries-sdk branch 2 times, most recently from 1d474a4 to fb1cf8c Compare September 5, 2026 09:12
@QuantumExplorer
QuantumExplorer force-pushed the feat/composite-document-queries-wire branch from 87435c1 to 2d0eaf6 Compare September 5, 2026 09:12
@QuantumExplorer
QuantumExplorer force-pushed the feat/composite-document-queries-sdk branch from fb1cf8c to 7df75fb Compare September 5, 2026 09:20
@QuantumExplorer
QuantumExplorer force-pushed the feat/composite-document-queries-wire branch from 2d0eaf6 to 70e5ef4 Compare September 5, 2026 09:20
The client half of composite document queries (a page plus the
sub-queries derived from it, answered as ONE merged proof):

- dash-platform-queries: `CompositeDocumentQuery` (page +
  `CompositeSubQuery` list with kind, fixed clauses, per-value limit
  and binding), the V1 wire encoder (refuses V0, a zero page limit,
  cursors, offsets, projections, grouping and time ranges), the
  rich-to-drive conversion mirroring the server's limit contract, and
  `FromProof<CompositeDocumentQuery> for CompositeDocuments`.
- rs-drive-proof-verifier: `CompositeDocuments` plus
  `verify_composite_documents_tenderdash_proof`, which composes
  rs-drive's merged-proof verification with the tenderdash root
  binding; `CompositeSubQueryResult` re-exported at the crate root.
- rs-sdk: `Query` impls, `impl Fetch for CompositeDocuments`, the mock
  round-trip, and the `platform` re-exports.
- rs-drive-abci: a `composite_trust_boundary` suite running the SDK
  entry points against server-generated proofs: wire encoding,
  end-to-end FromProof (page, like counts, quoted-post join,
  cross-contract profile lookup with a proven absence), a wrong quorum
  key, tampered metadata, and a page-only proof presented for the
  composite query.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@QuantumExplorer
QuantumExplorer force-pushed the feat/composite-document-queries-wire branch from 70e5ef4 to 5d3b151 Compare September 5, 2026 09:23
@QuantumExplorer
QuantumExplorer force-pushed the feat/composite-document-queries-sdk branch from 7df75fb to 2e24461 Compare September 5, 2026 09:23
Base automatically changed from feat/composite-document-queries-wire to feat/composite-document-queries-drive September 5, 2026 09:32
@QuantumExplorer
QuantumExplorer merged commit 2e24461 into feat/composite-document-queries-drive Sep 5, 2026
4 of 5 checks passed
@QuantumExplorer

Copy link
Copy Markdown
Member Author

Closed by GitHub as merged when a mistaken force-push briefly collapsed the stack's branches onto one commit; nothing from this PR is in v4.2-dev. Replacement with the same branch and content: #4604.

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