Sync / Replicated state

Lifecycle of a single edit

  1. Dispatched (visible): The view dispatches CreatedTodo({ id, title }); update updates Model immediately.
  2. Saved (saved): The mount replays the edit and writes it to the local outbox inside Sync's envelope (opId, document, replica, local sequence, baseCursor).
  3. Exchanged: replica.start sends the pending envelope and cursor to the server.
  4. Committed (committed): The server runs validate, authorize, reduce, and laws, assigns a global sequence and trusted actor, persists it, and returns the tail, acknowledgements, and rejections.
  5. Rebased: The replica advances its committed base, drops acknowledged or rejected edits, replays any remaining pending edits, and updates Model.