Sync / Editing server data
The mental model
cell shown = the row's value, unless an edit of that cell is
pending (no `at`), or
committed after the row's revision (at > row.revision)device server
------ -----------------------------------------
cell edit -> EditedProducts (pending) -> journal: validate -> sequence n -> stamp {at: n, by}
shown at once, kept in the outbox |
+-> settle -> table: row, revision := n
| (only where revision <= n)
+-> reply and notice -> every replica: edit {at: n}
Remote read <----------------------------- the row {..., revision}
shown = row + edits where at is none or at > row.revision
on a clock: AbsorbedEdits {through} -> replicas drop at <= through; the log compactsAn edit is in one of four states:
- Pending. On this device only, in its outbox. Shown at once.
- Committed, not yet in the row. The journal has it; the table has not written it, or this device has not read the row since. Shown.
- In the row. A read of the row is at or past its sequence. The row shows it; the edit is not needed.
- Absorbed. The server has recorded that the table holds it. Every replica drops it, and the log behind it compacts.
The revision is per row, not one checkpoint for the table, because Remote caches rows read at different moments. Recovery applies edits in commit order and stops at the first failure, so a row at revision 7 holds every edit to it up to 7.