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:
- Pending: The user edits a cell, appending a pending
EditedProductsoperation to the outbox. The overlay draws the new value immediately. - 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 hasrevision < n. - Applied to the table: The server's
settleworker writes the cell and updatesrevision := n(refusing to move backward ifrevision > n). Once Remote re-reads the row, the row itself carries the value. - Absorbed: On a periodic tick,
absorbappends anAbsorbedEdits { through }operation. Replicas drop edits withat <= 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.