Remote / An event-sourced domain behind Remote

The loop

  1. Page: Data.mutate(model, ReserveStock, input). Remote predicts the result from the declaration and marks the write pending.
  2. Adapter: sends client.ReserveStock(id, input, { commandId }). The commandId is derived from who asks, the operation and the input.
  3. Domain: decide appends [StockReserved] and answers { reply, stream, version }, the receipt. A refusal is a Rejection.
  4. Adapter: asks ProductRow.snapshot(id, { atLeast }), the View at the receipt, for a bounded time.
  5. Domain: the View folds StockReserved when the Event reaches it.
  6. Adapter: answers the write with the View's row, or with the reply's fields and the receipt. A Rejection becomes the mutation's Refusal.
  7. Page: the answer replaces the prediction. Remote holds the row to the receipt, and a later read carries it until a read at the receipt answers.

The page never reads the Aggregate, and never folds an Event itself. It reads rows from a View and learns of its own write from the Command's reply.