code wiki / (root) / nx_memory_lib.nx

nx_memory_lib.nx

buildroot/runtime/nx_memory_lib.nx

6062 B113 linesdepth 3pulls 4 transitivereach 2 importersview sourcekind librarytopic memory
docsdependenciesstructsconstsfunctions

about

nx_memory_lib.nx -- CONSOLIDATED memory tool (MCP name: nx_memory, tool #6 of the 15), LIBRARY half. READ-ONLY first increment over the sovereign seg-stores (the ecosystem's memory substrate): stores <dir> -> discover every seg-store under a dir (by its manifest) + live segment count get <prefix> <key> -> LATEST value bytes (version-resolved by the store, not raw file bytes) history <prefix> <key> -> every version's kind+len (the time-travel surface, metadata only) index <prefix> <idxkey> -> a registry's newline id-index (e.g. __toolidx__ / __works__ / __blidx__) This is STRUCTURED state over MCP -- what raw file reads (nx_fs) cannot give: latest-version resolution, tombstone semantics, version history. put/tombstone = a LATER increment behind its own write-cap. license_tier: ORIGINAL

dependencies 3 imports · 2 importers

nx_syscalls.nx nx_itoa_lib.nx nx_seg_store.nx nx_memory_lib.nx nx_memory.nx nx_memory_gate.nx

imports: nx_syscalls.nxnx_itoa_lib.nxnx_seg_store.nx

imported by: nx_memory.nxnx_memory_gate.nx

structs

none

consts

14const MX_IDX_CAP: i64 = 1048576 // index copy buffer (mirrors reg_index sizing)
15const MX_VER_SLOTS: i64 = 260 // per-key version metadata slots (mirrors SS_VER_SLOTS)
16const MX_PATH_CAP: i64 = 1024
17const MX_DENT_BUF: i64 = 65536 // getdents64 batch buffer (proven sizing)
18const MX_ASCII_0: i64 = 48 // '0'

functions

20func mx_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
25func mx_putn(v: i64) -> i64 { nxi_out(v); return 0 }
called by 3: mainmx_historymx_stores calls 1: nxi_out
26func mx_seq(a: *u8, b: *u8) -> i64 { var i: i64 = 0; while a[i] != (0 as u8) { if a[i] != b[i] { return 0 } i = i + 1 } if b[i] != (0 as u8) { return 0 } return 1 }
called by 1: main
27func mx_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
29func mx_ends(s: *u8, suf: *u8) -> i64
called by 1: mx_stores calls 1: mx_slen
39func mx_get(prefix: *u8, key: *u8) -> i64
49func mx_history(prefix: *u8, key: *u8) -> i64
66func mx_index(prefix: *u8, idxkey: *u8) -> i64
75func mx_stores(dir: *u8) -> i64