code wiki / _hdl_build / nx_lib_uxf_ingest.nx

nx_lib_uxf_ingest.nx

buildroot/runtime/_hdl_build/nx_lib_uxf_ingest.nx

7461 B151 linesdepth 7pulls 8 transitivereach 0 importersview sourcekind tooltopic lib
docsdependenciesstructsconstsfunctions

about

nx_lib_uxf_ingest.nx -- Library arc R4a: content-address the CALIBRE CATALOG into the UXF envelope ("everything in our superior format"). Reads the book index (idx_book.wsl), and for each book builds a canonical UXF DOC record {bk=path, ti=basename, fmt=ext} -> uxf_cid_profiled(UXF_DOC) -> append to a content-addressed seg_store (batched across segments because ss_begin's writer is 1 MiB). Then a gate proves it: count, retrieve-by-CID byte-faithful, no-fabrication (absent CID -> not found), tamper-evident (one flipped byte -> different CID), distinct books -> distinct CIDs. This makes each book a tamper-evident, dedupable, retrievable UXF record (the LIB02/LIB04 moat applied to the real 5761-book catalog). HONEST: metadata records here; per-book CONTENT conversion (epub/pdf text -> UXF doc) is R4b. Reuses nx_canon_cid + nx_uxf_cid + nx_seg_store. No hardware writes (Rule 26). license_tier: ORIGINAL

dependencies 4 imports · 0 importers

nx_syscalls.nx nx_canon_cid.nx nx_uxf_cid.nx nx_seg_store.nx nx_lib_uxf_ingest.nx

imports: nx_syscalls.nxnx_canon_cid.nxnx_uxf_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 iu_p sys_write sys_mmap iu_read sys_openat_rd sys_read sys_close sys_exit ss_begin ss_begin_cap sys_mmap ↻ iu_record sys_mmap ↻ iu_last canon_encode sys_mmap ↻ cc_cmp cc_w32 cc_len sys_munmap uxf_cid_profiled 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 ↻ uxf_nib_hex ss_add ss_add2

structs

none

consts

16const IU_MAGIC_2097152: i64 = 2097152
17const IU_MAGIC_8192: i64 = 8192
18const IU_MAGIC_8000: i64 = 8000
20const IU_IDX: *u8 = "knowledge/staging/media/idx_book.wsl"
21const IU_PREFIX: *u8 = "knowledge/staging/media/uxf_lib/"

functions

23func iu_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 1: main calls 1: sys_write
24func iu_n(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)} let t: *u8=sys_mmap(28); 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; while i<k{bb[i]=t[k-1-i];i=i+1} sys_write(1,bb,k); return 0 }
called by 1: main calls 2: sys_mmapsys_write
26func iu_read(path: *u8, buf: *u8, cap: i64) -> i64
called by 1: main calls 3: sys_openat_rdsys_readsys_close
36func iu_last(s: *u8, len: i64, b: i64) -> i64 { var i: i64=0; var r: i64=0-1; while i<len { if s[i]==(b as u8) { r=i } i=i+1 } return r }
called by 1: iu_record
38func iu_eq(a: *u8, an: i64, bp: *u8, bn: i64) -> i64 { if an!=bn { return 0 } var i: i64=0; while i<an { if a[i]!=bp[i] { return 0 } i=i+1 } return 1 }
called by 1: main
42func iu_record(path: *u8, plen: i64, canon: *u8, cid: *u8) -> i64
59func main() -> i64