Remote / Server-derived state

Worked examples and limits

  • examples/remote is a worked entity → select → Data → App.surface → prefetch → refresh → query page → render → mutate → retain trace against an in-process client, and examples/kitchen-sink runs the same path over foldkit-remote-server and foldkit-remote-drizzle (a nested selection, the live hub, an optimistic insert confirmed in place, hydration, retention). Both are asserted line by line. The test suites remain the exhaustive executable specification: pnpm exec vitest run packages/remote/test packages/remote-server/test packages/remote-drizzle/test.
  • examples/cloudflare runs the reads on a Worker: serveFetch over D1, and a live stream that re-reads D1 from inside the subscriber's own request, because one worker request cannot wake another's stream. The Pages list writes through Remote mutations (foldkit-entity, foldkit-form, foldkit-crud) and paints them before the POST returns.
  • The transport is Effect RPC and nothing else; a wire change is a protocol version bump (REMOTE_PROTOCOL_VERSION), and a request is bounded in fields per entity, relation depth, and ids per entity.
  • Coalescing is per RemoteClient layer, and retention keeps what the active Surfaces reach (Data.subscriptions) or Remote.retain lists.
  • The live hub subscribes the requirements' own entities, not nested relation targets; a change to a target reaches a subscriber through its own requirement or a refetch.

See the APIs

The package READMEs document the full surface: foldkit-surface, foldkit-remote, foldkit-remote-server, and foldkit-remote-drizzle. The worked trace is in examples/remote.