Remote / foldkit-remote

How the read loop works

The loop runs one way round:

  1. A Surface's Projection reads the current cache and declares requirements such as Project:p1.name and User:u7.name.
  2. An active Subscription compares those requirements with the cache and asks RemoteClient for missing or stale fields.
  3. The answer returns as a Remote Message.
  4. Data.reduce writes it into Remote.Model, and the next read of the Model sees the updated fields.

Rendering the same Projection twice keeps reads pure—fetching happens in Subscriptions outside render, and results enter the Model only through Data.reduce.

PieceResponsibility
Data.get / live(Data, …) / Data.querycreate pure Projections that declare what a consumer needs
Data.subscriptionsturn requirements of active Surfaces into reads, live streams, and retention roots
Data.reducereduce returned Remote Messages into the application's Remote.Model
RemoteClientperform the actual read/query/mutate/live I/O

One rule keeps the cache coherent: Data.reduce is the only writer. Local application state changes with modifyFields inside update, like anywhere else; a server fact only enters the cache as a Remote Message. Never install cache state with a ref set: requirements, staleness and tombstones stay consistent only because every fact arrives through the reducer.