code wiki / (root) / nx_relate_store.nx

nx_relate_store.nx

buildroot/runtime/nx_relate_store.nx

8982 B165 linesdepth 6pulls 7 transitivereach 0 importersview sourcekind tooltopic relate
docsdependenciesstructsconstsfunctions

about

nx_relate_store.nx -- PERSISTENCE for the relationship graph (turns nx_relate from pure logic into a REAL stored data layer). Entities + edges are saved as content-addressed canon records on the sovereign APPEND-ONLY seg_store: additive (never delete -> tombstone), tamper-evident (content-addressed CID), on YOUR hardware. This is the CRM "sovereign exceed" (E9) made concrete for the graph, not just the notify ledger. Proves: persist a graph, read it back byte-exact, and additivity (a second commit preserves the first). Composes nx_canon_cid + nx_seg_store (the exact pattern proven in nx_vizsla_notify). Records: key "ent:"+cid, fields {kind=ent, type, name, tenant} ; key "edg:"+cid, fields {kind=edg, from, rel, to, ctx, role}. Commands: selftest (argless -- persist+readback+additive gate). Durable use = same calls with a knowledge/ prefix. expect_exit: 0 license_tier: ORIGINAL

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_canon_cid.nx nx_seg_store.nx nx_relate_store.nx

imports: nx_syscalls.nxnx_canon_cid.nxnx_seg_store.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main p sys_write sys_mmap rs_cat rs_catn sys_mmap ↻ sys_now_us sys_mmap ↻ sys_clock_gettime_mono ss_begin ss_begin_cap sys_mmap ↻ rs_save_entity sys_mmap ↻ canon_encode sys_mmap ↻ cc_cmp cc_w32 cc_len sys_munmap cid_of sys_mmap ↻ sha256_digest sys_mmap ↻ sha256_init sys_mmap ↻ sha256_k sha256_update sha256_compress_ni_blocks blk_set_byte sha256_compress sha256_compress_ni blk_word sha256_final blk_set_byte ↻ sha256_compress ↻ cid_from_digest sys_munmap ↻ rs_cat ↻

structs

none

consts

13const K_MAGIC_2048: i64 = 2048

functions

15func p(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 2: pnmain calls 1: sys_write
16func pn(v: i64) -> i64
called by 1: main calls 3: psys_mmapsys_write
22func rs_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 1: rs_kmemeq
23func rs_eq(a: *u8, b: *u8) -> i64
called by 1: rs_count
29func rs_cat(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { dst[off+i] = s[i]; i = i + 1 } return off + i }
30func rs_catn(dst: *u8, off: i64, v: i64) -> i64
called by 1: main calls 1: sys_mmap
37func rs_kmemeq(b: *u8, off: i64, n: i64, s: *u8) -> i64
called by 2: rs_iskindrs_field calls 1: rs_slen
43func rs_iskind(b: *u8, koff: i64, kl: i64, pfx: *u8) -> i64
called by 1: rs_count calls 1: rs_kmemeq
48func rs_field(rec: *u8, rl: i64, want: *u8, out: *u8, cap: i64) -> i64
called by 1: rs_count calls 2: ss_r32rs_kmemeq
68func rs_save_entity(w: *i64, etype: *u8, name: *u8, tenant: *u8) -> i64
78func rs_save_edge(w: *i64, from: *u8, rel: *u8, to: *u8, ctx: *u8, role: *u8) -> i64
90func rs_count(prefix: *u8, kpfx: *u8, wantname: *u8, foundp: *i64) -> i64
123func main() -> i64