code wiki / (root) / nx_coindex_core.nx

nx_coindex_core.nx

buildroot/runtime/nx_coindex_core.nx

8545 B181 linesdepth 4pulls 4 transitivereach 6 importersview sourcekind librarytopic coindex
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_crashresume_census_core.nx nx_coindex_core.nx nx_coindex.nx nx_coindex_bench_gate.nx nx_coindex_gate.nx nx_coindex_vs_git_gate.nx nx_memindex_emit.nx nx_memindex_put.nx

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

18const CI_ENTRY_CAP: i64 = 500
22const K_MAGIC_8192: i64 = 8192 // slug/line scratch
23const K_MAGIC_262144: i64 = 262144 // whole-journal read buffer
24const K_MAGIC_262143: i64 = 262143 // ...minus the NUL terminator

functions

27func ci_lock(lockpath: *u8) -> i64
33func ci_unlock(fd: i64) -> i64 { if fd >= 0 { sys_flock(fd, SYS_LOCK_UN); sys_close(fd) } return 0 }
38func ci_append(journal: *u8, lockpath: *u8, slug: *u8, entry: *u8) -> i64
56func ci_slug_end(buf: *u8, ls: i64, le: i64) -> i64
called by 1: ci_emit
63func ci_slug_eq(buf: *u8, as_: i64, ae: i64, bs: i64, be: i64) -> i64
called by 1: ci_emit
74func ci_emit(journal: *u8, out: *u8, outcap: i64) -> i64
141func ci_split_at_budget(block: *u8, bn: i64, budget: i64) -> i64
called by 1: main
173func ci_count(journal: *u8) -> i64
called by 3: mainmainmain calls 2: sys_mmapccz_read