Skip to content

feat(wasm-sdk): composite document queries on the JS surface - #4601

Closed
QuantumExplorer wants to merge 0 commit into
feat/composite-document-queries-drivefrom
feat/composite-document-queries-wasm
Closed

feat(wasm-sdk): composite document queries on the JS surface#4601
QuantumExplorer wants to merge 0 commit into
feat/composite-document-queries-drivefrom
feat/composite-document-queries-wasm

Conversation

@QuantumExplorer

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

Last platform PR 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. feat(sdk): composite document queries, the client stack #4600 (client stack: dash-platform-queries, proof verifier, rs-sdk)
  6. this PR (wasm-sdk + js-evo-sdk surface, e2e spec)

What was done?

  • wasm-sdk: getCompositeDocuments(query) and getCompositeDocumentsWithProofInfo(query), mirroring the chained surface. The query object is the page (dataContractId, documentType, where, orderBy, a required limit) plus subQueries, each with an optional dataContractId (defaults to the page's), documentType, kind: 'documents' | 'counts', fixed where / orderBy, an optional per-value limit, and an optional bind: { source?: 'page' | index, sourceProperty, field }. Sub-query contracts are fetched through the same contract cache as the page's. The result is { pageDocuments, subResults }, each sub-result a discriminated union: { kind: 'documents', documents } or { kind: 'counts', counts: Map<base58 id, bigint> }. TypeScript declarations ride the usual custom section. parse_order_clause becomes crate-visible next to parse_where_clause.
  • js-evo-sdk: sdk.documents.composite(query) and sdk.documents.compositeWithProof(query), plus a README section with the feed-page example and the four sub-query shapes.
  • platform-test-suite: a composite case in the IndexOnlyDocument spec, right after the chained one: the dash posts page, one like count per post from the countable [hashtag, postId] index, and the viewer's own likes through the byLiker terminal (value-bounded, no limit).

Usage:

const page = await sdk.documents.composite({
  dataContractId: YAPPR,
  documentType: 'post',
  where: [['hashtag', '==', 'dash']],
  limit: 20,
  subQueries: [
    { documentType: 'like', kind: 'counts', where: [['hashtag', '==', 'dash']], bind: { sourceProperty: '$id', field: 'postId' } },
    { documentType: 'post', bind: { sourceProperty: 'quotedPostId', field: '$id' } },
    { dataContractId: DASHPAY, documentType: 'profile', bind: { sourceProperty: '$ownerId', field: '$ownerId' } },
  ],
});

How Has This Been Tested?

Breaking Changes

None. New methods only.

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: 704f01ad-f90a-4487-9639-baa922475973

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 — 57 ahead in queue (commit 9636331)
Queue position: 58/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-wasm branch from 3f20bf2 to 93967fd Compare September 5, 2026 03:55
@QuantumExplorer
QuantumExplorer force-pushed the feat/composite-document-queries-sdk branch 2 times, most recently from 4997361 to 1d474a4 Compare September 5, 2026 03:56
@QuantumExplorer
QuantumExplorer force-pushed the feat/composite-document-queries-wasm branch 2 times, most recently from 5dc2287 to efcca1b Compare September 5, 2026 09:12
@QuantumExplorer
QuantumExplorer force-pushed the feat/composite-document-queries-sdk branch 2 times, most recently from fb1cf8c to 7df75fb Compare September 5, 2026 09:20
@QuantumExplorer
QuantumExplorer force-pushed the feat/composite-document-queries-wasm branch 2 times, most recently from 14ef5e9 to 9636331 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-sdk to feat/composite-document-queries-drive September 5, 2026 09:32
@QuantumExplorer
QuantumExplorer force-pushed the feat/composite-document-queries-wasm branch from 9636331 to cf11e97 Compare September 5, 2026 09:32
@QuantumExplorer

Copy link
Copy Markdown
Member Author

Closed by GitHub when a mistaken force-push briefly collapsed the stack's branches onto one commit. Replacement with the same branch and content: #4605.

QuantumExplorer pushed a commit to QuantumExplorer/yappr that referenced this pull request Sep 8, 2026
One composite `getDocuments` request now answers a For You page and
everything a card needs to render it, under a single merged proof: the
posts, their like/repost/reply/quote counts, the posts they quote, the
authors' profiles and DPNS names, and (logged in) the viewer's own
likes, reposts and bookmarks on the page. The SDK derives every
sub-query from the proven page, so the responding node cannot steer
any of it. About ten round trips per page become one.

- lib/feed/composite-feed-page.ts builds the query from the contract
  topology, decodes the result into the page plus a
  `PreloadedEnrichment`, seeds the DPNS and profile caches, attaches
  quoted posts, and reports `null` when the surface is unavailable
  (an evo-sdk without `documents.composite`, a pre-v6 contract, or a
  recent failure with a one-minute backoff), so the legacy loaders
  keep working unchanged.
- lib/feed/load-for-you-feed.ts tries the composite page first and
  translates the feed's id cursors into the range clause the
  composite surface paginates with.
- useProgressiveEnrichment accepts the preloaded slices, merges them
  at once and only queries what they did not cover; PostCard and the
  per-card fallbacks are untouched.
- dpnsService.seedUsernames and
  unifiedProfileService.seedProfileDocuments let proven lookups warm
  the batch resolvers (with a short negative cache for proven
  absences).

Needs an evo-sdk release carrying the composite surface
(dashpay/platform#4601 and its stack) and nodes serving it
(dashpay/platform#4599); until then the capability check keeps this
change inert.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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