Skip to main content

max / goingson

1.1 KB · 23 lines History Blame Raw
1 -- Per-row committed HLC, for gating clean remote changes (deep A+ remediation).
2 --
3 -- "Clean" pulled changes (those with no contesting local *pending* edit) were
4 -- applied blindly. That can clobber a newer value already committed locally when
5 -- an older remote edit arrives for an already-applied row -- a latent multi-device
6 -- hazard the SyncKit audit flagged. SyncKit's CleanChanges gate now drops any clean
7 -- change whose HLC is older-or-equal to the row's committed HLC; this table is the
8 -- committed-clock store the gate reads.
9 --
10 -- Updated on every applied change -- a local stamp (hlc.rs::assign_pending_hlcs) or
11 -- a remote apply (pull.rs::apply_changes_inner) -- keeping the maximum HLC per row.
12 -- The node component is stored as its canonical lowercase UUID string, whose
13 -- lexicographic order matches the byte order SyncKit's Hlc compares on.
14
15 CREATE TABLE IF NOT EXISTS sync_committed_hlc (
16 table_name TEXT NOT NULL,
17 row_id TEXT NOT NULL,
18 hlc_wall INTEGER NOT NULL,
19 hlc_counter INTEGER NOT NULL,
20 hlc_node TEXT NOT NULL,
21 PRIMARY KEY (table_name, row_id)
22 ) WITHOUT ROWID;
23