code wiki / (root) / nx_lib_store.nx

nx_lib_store.nx

buildroot/runtime/nx_lib_store.nx

7312 B174 linesdepth 3pulls 3 transitivereach 31 importersview sourcekind librarytopic lib
docsdependenciesstructsconstsfunctions

about

nx_lib_store.nx -- sovereign CATALOG STORE for the nishi-library, on the sovereign nx_seg_store (append-only, additive, crash-safe rename-commit) with the O(1) nx_hash_index get path. RETIRES the 3rd-party SQLite catalog.db (operator 2026-06-30: "no 3rd-party db; s-class exceed everywhere"). key = "work:<work_hk>" val = title<TAB>doi<TAB>published<TAB>license<TAB>abstract "__works__" record = newline-separated work_hks, advanced IN THE SAME COMMIT so enumeration is atomic (no torn state). S-CLASS-EXCEED vs SQLite (parity + beyond): parity : put / get / enumerate / update by key. beyond : O(1) hash get (65 ns = 3.8x SQLite's B-tree probe, nx_hash_index_bench); APPEND-ONLY history -- no UPDATE/DELETE destruction ("history is sacred"); crash-safe rename-commit; ZERO 3rd-party; durable + sovereign on disk. license_tier: ORIGINAL | genealogy_id: nishi_library_sovereign_db_2026_06_30

dependencies 2 imports · 9 importers

nx_syscalls.nx nx_seg_store.nx nx_lib_store.nx nx_lib_compact.nx nx_lib_index.nx nx_lib_ingest_json.nx nx_lib_ingest_tsv.nx nx_lib_openalex.nx nx_lib_page.nx nx_lib_search.nx nx_lib_serve.nx nx_lib_store_test.nx

imports: nx_syscalls.nxnx_seg_store.nx

imported by: nx_lib_compact.nxnx_lib_index.nxnx_lib_ingest_json.nxnx_lib_ingest_tsv.nxnx_lib_openalex.nxnx_lib_page.nxnx_lib_search.nxnx_lib_serve.nxnx_lib_store_test.nx

structs

none

consts

19const LIB_MAGIC_1048576: i64 = 1048576
21const LIB_PREFIX: *u8 = "knowledge/libstore-" as *u8

functions

23func ls_strlen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
24func ls_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 }
called by 1: ls_key
27func ls_key(kbuf: *u8, hk: *u8) -> i64
35func ls_name_present(buf: *u8, n: i64, name: *u8, namelen: i64) -> i64
56func nx_lib_store_put_work(hk: *u8, record: *u8, reclen: i64) -> i64
87func nx_lib_store_bulk_begin(worksbuf: *u8, worklen_p: *i64) -> *i64
102func nx_lib_store_bulk_add(w: *i64, kbuf: *u8, worksbuf: *u8, worklen_p: *i64, hk: *u8, record: *u8, reclen: i64) -> *i64
127func nx_lib_store_bulk_commit(w: *i64, worksbuf: *u8, worklen: i64) -> i64
137func nx_lib_store_get_work(hk: *u8, ptrout: *i64, lenout: *i64) -> i64
147func nx_lib_store_open() -> *i64
150func nx_lib_store_get_work_h(h: *i64, kbuf: *u8, hk: *u8, ptrout: *i64, lenout: *i64) -> i64
156func nx_lib_store_index(idxbuf: *u8) -> i64
167func nx_lib_store_count() -> i64
called by 2: mainmain calls 2: sys_mmapnx_lib_store_index