feat(feed): load For You pages through one composite document query - #369
Draft
QuantumExplorer wants to merge 1 commit into
Draft
feat(feed): load For You pages through one composite document query#369QuantumExplorer wants to merge 1 commit into
QuantumExplorer wants to merge 1 commit into
Conversation
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>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Loads a For You feed page through ONE composite
getDocumentsrequest instead of about ten: the page, its like/repost/reply/quote counts, the posts it quotes, the authors' profiles and DPNS names, and (logged in) the viewer's own likes, reposts and bookmarks on the page, all under a single merged proof. The SDK derives every sub-query from the proven page, so the responding node cannot substitute, omit or inject any of it.Cold anonymous
/feedgoes from 15 to 19 DAPI calls to about 4 (bootstrap 2, composite page 1, trending 1); a logged-in load drops by a similar amount.Blocked on
@dashevo/evo-sdkrelease carryingdocuments.composite(feat(wasm-sdk): composite document queries on the JS surface dashpay/platform#4605, on top of #4596 to #4604 and feat: merge a limited path query below a key another branch already owns dashpay/grovedb#850).sub_querieson the V1 documents wire (feat(dapi): composite document queries on the getDocuments V1 wire dashpay/platform#4603).Until then the change is inert:
loadCompositeFeedPagechecks fordocuments.compositeat runtime and the v6 (refersTo-enforced) topology, and returnsnullso the legacy loaders run exactly as today. It also backs off for a minute after any composite failure. Bumping the evo-sdk dependency lights it up; no other switch is needed.How
lib/feed/composite-feed-page.ts: builds the query from the contract topology helpers (likeIndexFor,repostIndexFor,bookmarkIndexFor,quoteFieldFor,replyCountFieldFor), decodes the result into the raw page plus aPreloadedEnrichment, seeds the DPNS and profile caches with the proven documents (including proven absences), attaches quoted posts, and stamps counts and the viewer's marks onto the posts. Anonymous pages also chain the quoted posts' authors' profiles off the join so embedded cards need no straggler hop; logged-in pages spend those request slots on the viewer's marks instead (the platform caps a request at 10 sub-queries).lib/feed/load-for-you-feed.ts: tries the composite page first, for the first batch and the background top-ups. The feed paginates by document id while the composite surface paginates with a range clause on$createdAt, so the loader remembers the$createdAtof every cursor it handed out and translates; an unknown cursor takes the legacy path.hooks/use-progressive-enrichment.ts:enrichProgressively(posts, preloaded?)merges the preloaded slices at once and only queries what they did not cover (per author for names/profiles/avatars, per post for stats/interactions). Same state shape, soPostCardand every per-card fallback are untouched.hooks/use-feed-data.tspasses the preload through and the viewer id down.dpnsService.seedUsernamesandunifiedProfileService.seedProfileDocuments: let proven lookups warm the batch resolvers; DPNS gains a five-minute negative cache so proven "no name" identities stop re-querying.Repost attribution ("X reposted") stays on its own query: the repost count and a repost documents lookup would both read
repost.byPost, which the composite rules forbid on one request, and the count is the better use of the slot. Quoted replies and blog quotes keep resolving throughattachQuotedPosts, which now only runs for posts the composite did not already resolve.Testing
npx tsc --noEmitclean;next linton the touched files reports only the pre-existing warnings.getDocumentsfor the page where it showed the page query, four grouped counts, the profile and DPNS batches and the quoted-post fetch.🤖 Generated with Claude Code