code wiki / _hdl_build / nx_library_foundation.nx

nx_library_foundation.nx

buildroot/runtime/_hdl_build/nx_library_foundation.nx

9925 B150 linesdepth 11pulls 22 transitivereach 1 importersview sourcekind tooltopic library
docsdependenciesstructsconstsfunctions

about

nx_library_foundation.nx -- close the foundationing gap: every harvested doc on disk must be FOUNDATIONED (CID + ed25519 provenance + lineage traced to god) before it counts as library knowledge. Operator law: "we dont want to ingest non foundationed data -- if we consume we trace + build its lineage properly back to god." This auto-discovers every knowledge/library/*.txt (getdents64, so the running index grows itself), and for each: ingest_foundation (cid_of + prov_make[DOWNLOADED] + ed25519 sign + verify with 3 liar-kill negatives + walk genesis_lineage UNI-WIRE->ORIGIN) AND lib_ingest (store by CID in the no-link-rot corpus). Idempotent: lib_ingest returns DUP for docs already stored, so re-running only foundations, never double-adds. Honest provenance: source is the VERIFIABLE origin class from the filename (wiki-article / source-readme / nishi-internal-research / external-doc) -- never a fabricated upstream URL. license_tier: ORIGINAL

dependencies 3 imports · 1 importers

nx_syscalls.nx nx_library.nx nx_ingest_foundation.nx nx_library_foundation.nx nx_library_foundation_gate.nx

imports: nx_syscalls.nxnx_library.nxnx_ingest_foundation.nx

imported by: nx_library_foundation_gate.nx

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

main lf_w sys_write sys_mmap lib_count cat_count ss_open_cached ssc_init sys_mmap ↻ ssc_sig_of ss_cat sys_fstatat ssc_streq ss_open ss_open2 sys_mmap ↻ ss_manifest_dyn ss_cat ↻ ss_loadfile ss_load_aux2 ssl_total_keys ssl_pow2 ssl_build ss_r32 ssl_lookup ss_manifest_free sys_munmap ssc_retire_handle sys_mmap ↻ cat_idx_load sys_mmap ↻ ss_hget sys_mmap ↻ ss_idx_find ss_r32 ↻ ss_len ss_kcmp cat_idx_key lf_run sys_mmap ↻

structs

none

consts

13const LF_MAGIC_65536: i64 = 65536
15const LF_DIR: *u8 = "knowledge/library"
16const LF_LOG: *u8 = "knowledge/status/library_foundation.log"
17const LF_CREDDIR: *u8 = "knowledge/foundation/cred"
18const LF_DATE: *u8 = "2026-06-20"
19const LF_AGENT: *u8 = "nishi-librarian"

functions

21func lf_getdents(fd: i64, buf: *u8, count: i64) -> i64 { return __syscall(217, fd, buf, count, 0, 0, 0) }
called by 1: lf_run
22func lf_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 2: lf_endslf_has
23func lf_cat(dst: *u8, o: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){dst[o]=s[i];o=o+1;i=i+1} dst[o]=0 as u8; return o }
called by 2: lf_sourcelf_one
25func lf_ends(name: *u8, suf: *u8) -> i64
called by 2: lf_is_txtlf_source calls 1: lf_slen
29func lf_has(name: *u8, lit: *u8) -> i64
called by 1: lf_source calls 1: lf_slen
35func lf_is_txt(name: *u8) -> i64 { return lf_ends(name, ".txt" as *u8) }
called by 1: lf_run calls 1: lf_ends
38func lf_source(name: *u8, out: *u8) -> i64
called by 1: lf_one calls 3: lf_endslf_catlf_has
51func lf_one(name: *u8, counts: *i64) -> i64
82func lf_run(counts: *i64) -> i64
122func lf_w(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: lf_nmain calls 1: sys_write
123func lf_n(v: i64) -> i64 { var m: i64=v; if m<0{lf_w("-");m=0-m} let t:*u8=sys_mmap(24); var k:i64=0; if m==0{t[0]=48 as u8;k=1}; while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1}; var i:i64=0; let o:*u8=sys_mmap(24); while i<k{o[i]=t[k-1-i];i=i+1}; sys_write(1,o,k); return 0 }
called by 1: main calls 3: lf_wsys_mmapsys_write
125func main() -> i64