nx_crdt_sync.nx
buildroot/runtime/nx_crdt_sync.nx
about
nx_crdt_sync.nx -- CRDT SYNC op-log: the rung that makes two replicas MERGE instead of collide. Each edit is
recorded as an op record (kind, id, value, ref) in an append-only log; a replica APPLIES any op-log (its own or a
peer's) into a sequence-CRDT doc. Because apply is idempotent + order-independent (the CRDT property), two actors
that each make edits, then exchange logs and apply the union, CONVERGE to the identical document -- with BOTH sets
of edits present. This is the operational answer to "two Claude sessions edited the same file": no lock, no
rejection, no lost edit. Composes nx_crdt_seq + nx_lamport_clock. 100% integer. license_tier: ORIGINAL
dependencies 3 imports · 1 importers
imports: nx_syscalls.nxnx_crdt_seq.nxnx_lamport_clock.nx
imported by: nx_crdt_sync_gate.nx
structs
| none |
consts
| 11 | const OPLOG_MAX: i64 = 1024 |
functions
| 14 | func op_rec(log: *i64, i: i64) -> *i64 { return (log as i64 + (1 + i*6)*8) as *i64 } |
| 16 | func oplog_new() -> *i64 |
| 21 | func oplog_count(log: *i64) -> i64 { return log[0] } |
| 23 | func oplog_append(log: *i64, kind: i64, idc: i64, ida: i64, value: i64, refc: i64, refa: i64) -> i64 |
| 34 | func sync_insert(doc: *i64, log: *i64, clk: *i64, value: i64, refc: i64, refa: i64) -> i64 |
| 41 | func sync_delete(doc: *i64, log: *i64, clk: *i64, idc: i64, ida: i64) -> i64 |
| 49 | func sync_apply_log(doc: *i64, clk: *i64, log: *i64) -> i64 |