Skip to content

feat(feed): batch For You page enrichment with composite queries - #369

Draft
QuantumExplorer wants to merge 2 commits into
PastaPastaPasta:stagingfrom
QuantumExplorer:feat/composite-feed-page
Draft

feat(feed): batch For You page enrichment with composite queries#369
QuantumExplorer wants to merge 2 commits into
PastaPastaPasta:stagingfrom
QuantumExplorer:feat/composite-feed-page

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Batch For You posts and their card enrichment through the composite document-query API merged in dashpay/platform#4605. The first page uses one composite document request for posts, four engagement counts, quoted posts, author profiles/DPNS names and, when signed in, the viewer's likes, reposts and bookmarks. Anonymous queries use eight subqueries; signed-in queries use the maximum ten.

Subsequent pages use the existing timeline startAfter cursor to select the next 20 document IDs, then one composite by-ID request for those exact posts and their enrichment. This preserves posts with identical timestamps and keeps pagination advancing past tombstones. Results are restored to timeline order after the by-ID lookup. If composite queries are unavailable, the loader reuses the timeline result and falls back to ordinary enrichment.

This reduces the page/enrichment requests; it does not imply a fixed total for loading the UI. Repost attribution, block/follow checks, trending, quoted-author names, signed-in quoted-author profiles, and quoted replies/blogs can still require separate requests. Live-network savings have not yet been measured.

Correctness and compatibility

  • Rebased onto current staging, retaining its PostService timeline loader, loading-author placeholders and TTL caches.
  • Treat the DPNS limit as a shared 100-document budget, with capacity reserved for empty identity branches. Near the cap, do not preload partial primary names or cache missing names. The normal resolver retries crowded batches per identity and paginates aliases before selecting primary names.
  • Cache complete DPNS absences for five minutes; registration, cache clearing and fresh positive results invalidate those misses. Profile seeds also replace stale positive/negative cache entries.
  • Pass preloaded names, profiles, avatars, counts and viewer interactions into progressive enrichment so covered keys skip duplicate queries.
  • Fall back on older SDKs, unsupported nodes and incomplete composite responses, with a one-minute backoff after failure.

Activation prerequisites

This remains preparatory with the current dependency pins. Both @dashevo/evo-sdk and @dashevo/wasm-sdk are still 4.2.0-dev.8; the published SDK lacks documents.composite, and no newer compatible release was available when this update was validated.

Activation requires compatible SDK releases, nodes serving V1 document sub_queries, and the configured enforced-reference contract topology. The ordinary path remains active until those prerequisites are met. No SDK release or node deployment is included here.

Validation

  • npm run lint — clean.
  • npm run test — 142 tests passed, including timestamp ties over three pages, raw tombstone cursors, four named authors, crowded alias batches, empty-branch capacity, cache invalidation/expiry, old SDKs and unsupported/incomplete responses.
  • npm run lint:dead — clean.
  • npm run build and npm run build:testing — passed.
  • npm run test:e2e — six read-only browser checks passed; 41 write tests skipped without signing credentials.

Composite behavior is covered with an in-memory SDK boundary; it has not been exercised against composite-enabled live nodes.

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

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.

Quantum Explorer and others added 2 commits September 8, 2026 15:53
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>
@QuantumExplorer
QuantumExplorer force-pushed the feat/composite-feed-page branch from 3dfd13e to f8ff5c2 Compare September 8, 2026 09:05
@QuantumExplorer QuantumExplorer changed the title feat(feed): load For You pages through one composite document query feat(feed): batch For You page enrichment with composite queries Sep 8, 2026
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.

1 participant