nx_memory_lib.nx
buildroot/runtime/nx_memory_lib.nx
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
imports: nx_syscalls.nxnx_itoa_lib.nxnx_seg_store.nx
imported by: nx_memory.nxnx_memory_gate.nx
structs
| none |
consts
| 14 | const MX_IDX_CAP: i64 = 1048576 // index copy buffer (mirrors reg_index sizing) |
| 15 | const MX_VER_SLOTS: i64 = 260 // per-key version metadata slots (mirrors SS_VER_SLOTS) |
| 16 | const MX_PATH_CAP: i64 = 1024 |
| 17 | const MX_DENT_BUF: i64 = 65536 // getdents64 batch buffer (proven sizing) |
| 18 | const MX_ASCII_0: i64 = 48 // '0' |
functions
| 20 | func 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 } |
| 25 | func mx_putn(v: i64) -> i64 { nxi_out(v); return 0 } |
| 26 | func 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 |
| 27 | func mx_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 29 | func mx_ends(s: *u8, suf: *u8) -> i64 |
| 39 | func mx_get(prefix: *u8, key: *u8) -> i64 |
| 49 | func mx_history(prefix: *u8, key: *u8) -> i64 |
| 66 | func mx_index(prefix: *u8, idxkey: *u8) -> i64 |
| 75 | func mx_stores(dir: *u8) -> i64 called by 2: mainmain calls 11: sys_openat_rdmx_putssys_mmapsys_getdents64dirent_reclendirent_name+5 |