Sync / Editing server data

How an edit moves from the screen to the table

A cell on screen shows the row's last read value unless a local or recently committed edit for that cell is still pending (no at yet) or committed after the row's revision (at > row.revision).

Each edit passes through four stages:

  1. Pending: The user edits a cell, appending a pending EditedProducts operation to the outbox. The overlay draws the new value immediately.
  2. Committed, not yet in the row: The server journal validates the edit, assigns sequence n, stamps { at: n, by }, and broadcasts it to every replica. Devices show the edit whenever their cached row has revision < n.
  3. Applied to the table: The server's settle worker writes the cell and updates revision := n (refusing to move backward if revision > n). Once Remote re-reads the row, the row itself carries the value.
  4. Absorbed: On a periodic tick, absorb appends an AbsorbedEdits { through } operation. Replicas drop edits with at <= through, and the journal compacts history behind them.

Tracking revision per row (instead of one global table checkpoint) matters because Remote fetches and caches individual rows at different times. Because recovery applies edits strictly in commit order and stops at the first failure, a row at revision: 7 is guaranteed to include every edit to that row up to sequence 7.