nx_coindex_core.nx
buildroot/runtime/nx_coindex_core.nx
about
nx_coindex_core.nx -- CONFLICT-FREE co-edited index (07-15 operator: "we can't have conflicting
writes when we use you on parallel workstreams; we need SOTA orchestration everywhere"). The
root cause of the MEMORY.md / board merge-dance = many sessions HAND-EDIT the same file bytes.
The SOTA answer is append-and-derive (event-sourced / convergent): a session NEVER edits the
shared index; it APPENDS its own entry (keyed by a slug) to a journal -- atomic under the proven
flock floor (nx_framed_append / WMS R8, MEASURED exceed-git: concurrent lost 0/144 vs git 132/144)
-- and the index is DERIVED by a reducer that keeps the LAST entry per slug (last-write-wins). No
two sessions ever touch the same bytes, so there is nothing to conflict on, by construction.
Pure append + reduce funcs here (gate-locked); a CLI wires it to MEMORY.md / the board.
license_tier: ORIGINAL
dependencies 2 imports · 6 importers
imports: nx_syscalls.nxnx_crashresume_census_core.nx
imported by: nx_coindex.nxnx_coindex_bench_gate.nxnx_coindex_gate.nxnx_coindex_vs_git_gate.nxnx_memindex_emit.nxnx_memindex_put.nx
structs
| none |
consts
| 18 | const CI_ENTRY_CAP: i64 = 500 |
| 22 | const K_MAGIC_8192: i64 = 8192 // slug/line scratch |
| 23 | const K_MAGIC_262144: i64 = 262144 // whole-journal read buffer |
| 24 | const K_MAGIC_262143: i64 = 262143 // ...minus the NUL terminator |
functions
| 27 | func ci_lock(lockpath: *u8) -> i64 |
| 33 | func ci_unlock(fd: i64) -> i64 { if fd >= 0 { sys_flock(fd, SYS_LOCK_UN); sys_close(fd) } return 0 } |
| 38 | func ci_append(journal: *u8, lockpath: *u8, slug: *u8, entry: *u8) -> i64 called by 4: mainb_good_childmainmain calls 7: ci_locksys_openat_appendci_unlocksys_mmapccz_cat_strsys_write+1 |
| 56 | func ci_slug_end(buf: *u8, ls: i64, le: i64) -> i64 called by 1: ci_emit |
| 63 | func ci_slug_eq(buf: *u8, as_: i64, ae: i64, bs: i64, be: i64) -> i64 called by 1: ci_emit |
| 74 | func ci_emit(journal: *u8, out: *u8, outcap: i64) -> i64 |
| 141 | func ci_split_at_budget(block: *u8, bn: i64, budget: i64) -> i64 called by 1: main |
| 173 | func ci_count(journal: *u8) -> i64 |