code wiki / (root) / nx_libdata.nx

nx_libdata.nx

buildroot/runtime/nx_libdata.nx

67181 B1476 linesdepth 21pulls 153 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_libdata.nx -- THE SELF-SUFFICIENCY DATA LIBRARY ENGINE (ws=library-datasets, 2026-07-31). Operator goal: collect the datasets that were NOT coming in, ranked MOST VALUABLE to LEAST for household self-sufficiency against the cost-of-living crisis (gardening, NSF, manufacturing, ...). WHY: the library answered 'gardening' with garden-centre shop pages, and knowledge/fetched/ held 44 Wikipedia pages. Root cause (debt 1785516741/1785516905) was TRANSPORT, not a missing list: every ingester called the TLS-1.3-only fetch entry point, so TLS-1.2-only hosts -- exactly where US federal open data lives -- were unreachable. This organ deliberately calls the WIDE-REACH nx_https_fetch_follow_best so it can never regress to the narrow path. DATA-DRIVEN BY CONSTRUCTION (rule 11): the source list is knowledge/registry/selfsuff_datasets.tsv and the ranking weights are knowledge/status/selfsuff_axes.conf. Adding a dataset is ONE ROW and zero code; re-prioritising the whole library is editing four weights. Contrast nx_supply_research_fetch, which hardcodes 44 URLs in its body. verbs: rank | gaps | fetch [maxn] | status | selftest expect_exit: 0 license_tier: ORIGINAL

dependencies 9 imports · 0 importers

nx_syscalls.nx nx_x509_trust_store.nx nx_trust_store_load_from_certdata. nx_https_fetch_follow.nx nx_sha256.nx nx_store_seed_lib.nx nx_lib_openalex.nx nx_lib_search.nx nx_gzip_wrap.nx nx_libdata.nx

imports: nx_syscalls.nxnx_x509_trust_store.nxnx_trust_store_load_from_certdata.nxnx_https_fetch_follow.nxnx_sha256.nxnx_store_seed_lib.nxnx_lib_openalex.nxnx_lib_search.nxnx_gzip_wrap.nx

imported by: nobody (leaf or entry point)

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

main ld_puts ld_emit ld_vlen sys_write sys_exit ld_vlen ↻ sys_mmap ld_load ld_read sys_openat_rd sys_read sys_close ld_conf_int ld_vlen ↻ ld_eol ld_atoi ld_parse ld_eol ↻ ld_score ld_field_i ld_atoi ↻ ld_order ld_lit_eq ld_vlen ↻ ld_putn sys_write ↻ sys_mmap ↻ ld_outpath ld_vlen ↻ ld_row_line ld_putn ↻ ld_puts ↻ ld_write_n sys_write ↻ ld_have sys_openat_rd ↻ sys_close ↻ ld_atoi ↻ nx_trust_store_load_from_c

structs

none

consts

27const LD_MAGIC_2048: i64 = 2048
28const LD_MAGIC_65558: i64 = 65558
29const LD_MAGIC_4096: i64 = 4096
31const LD_BUF: i64 = 262144
32const LD_AXBUF: i64 = 16384
33const LD_ROWS: i64 = 256
38const LD_NF: i64 = 15
39const LD_FETCH: i64 = 134217728
40const LD_PATH: i64 = 1024
41const LD_CERT: i64 = 4194304
42const LD_MODE_644: i64 = 420
43const LD_PERMIL: i64 = 1000
44const LD_TAB: i64 = 9
45const LD_NL: i64 = 10
46const LD_HASH: i64 = 35
47const LD_ACCESS_FULL: i64 = 10
48const LD_HOPS: i64 = 6
50const LD_CHUNK: i64 = 131072
51const LD_MAXCHUNKS: i64 = 1100
52const LD_WINDOW_TRIES: i64 = 4
54const LD_BACKOFF_MS: i64 = 1500
55const LD_REFETCH_MS: i64 = 8000
58const F_ID: i64 = 0
59const F_DOMAIN: i64 = 1
60const F_URL: i64 = 3
61const F_SAVE: i64 = 6
62const F_BREADTH: i64 = 7
63const F_DUR: i64 = 8
64const F_UNSUB: i64 = 9
65const F_ACCESS: i64 = 10
66const F_STATUS: i64 = 11
67const F_MINBYTES: i64 = 13
68const F_MAXAGE: i64 = 14
69const LD_SECS_DAY: i64 = 86400
72const LD_SCANHEAD: i64 = 2048
73const LD_CATALOG: *u8 = "knowledge/store/libdata-" as *u8
74const LD_REJCONF: *u8 = "knowledge/status/selfsuff_reject.conf" as *u8
75const LD_PROV: *u8 = "knowledge/status/selfsuff_provenance.tsv" as *u8

functions

80func ld_vlen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
81func ld_emit(s: *u8) -> i64 { let n: i64 = ld_vlen(s); sys_write(1, s, n); return 0 }
called by 1: ld_puts calls 2: ld_vlensys_write
82func ld_lit_eq(s: *u8, off: i64, len: i64, lit: *u8) -> i64
called by 1: main calls 1: ld_vlen
90func ld_puts(s: *u8) -> i64 { ld_emit(s); return 0 }
called by 2: ld_row_linemain calls 1: ld_emit
95func ld_putn(v: i64) -> i64
called by 2: ld_row_linemain calls 2: sys_writesys_mmap
107func ld_write_n(s: *u8, n: i64) -> i64 { sys_write(1, s, n); return 0 }
called by 2: ld_row_linemain calls 1: sys_write
109func ld_read(path: *u8, buf: *u8, cap: i64) -> i64
119func ld_have(path: *u8) -> i64
called by 1: main calls 2: sys_openat_rdsys_close
127func ld_atoi(buf: *u8, o: i64, len: i64) -> i64
142func ld_eol(buf: *u8, from: i64, n: i64) -> i64
155func ld_conf_int(buf: *u8, n: i64, key: *u8, dflt: i64) -> i64
called by 1: ld_load calls 3: ld_vlenld_eolld_atoi
181func ld_parse(buf: *u8, n: i64, fo: *i64, fl: *i64) -> i64
called by 1: ld_load calls 1: ld_eol
221func ld_field_i(buf: *u8, fo: *i64, fl: *i64, r: i64, f: i64) -> i64
called by 2: ld_scoremain calls 1: ld_atoi
227func ld_score(buf: *u8, fo: *i64, fl: *i64, r: i64, ws: i64, wb: i64, wu: i64, wd: i64) -> i64
called by 2: ld_loadmain calls 1: ld_field_i
238func ld_order(sc: *i64, ord: *i64, rows: i64) -> i64
called by 1: ld_load
258func ld_outpath(dst: *u8, buf: *u8, fo: *i64, fl: *i64, r: i64) -> i64
called by 1: main calls 1: ld_vlen
276func ld_cstr(dst: *u8, buf: *u8, o: i64, len: i64) -> i64
called by 1: main
283func ld_load(rpath: *u8, apath: *u8, buf: *u8, ax: *u8, fo: *i64, fl: *i64, sc: *i64, ord: *i64, wout: *i64) -> i64
308func ld_find_last(b: *u8, n: i64, lit: *u8, litlen: i64, window: i64) -> i64
called by 2: ld_buf_completemain
325func ld_zip_eocd(b: *u8, n: i64) -> i64
called by 2: ld_buf_completemain
338func ld_json_closed(b: *u8, n: i64, want: i64) -> i64
called by 2: ld_buf_completemain
363func ld_buf_complete(vbuf: *u8, n: i64) -> i64
374func ld_file_complete(path: *u8, vbuf: *u8) -> i64
called by 1: main calls 2: ld_readld_buf_complete
383func ld_hexdig(v: i64) -> i64
called by 1: ld_sha_hex
389func ld_sha_hex(b: *u8, n: i64, outhex: *u8) -> i64
called by 1: main calls 3: sys_mmapsha256_digestld_hexdig
403func ld_app_str(d: *u8, o: i64, s2: *u8) -> i64
called by 2: ld_prov_appendmain
408func ld_app_n(d: *u8, o: i64, v: i64) -> i64
called by 2: ld_prov_appendmain calls 1: sys_mmap
424func ld_prov_append(idb: *u8, idlen: i64, url: *u8, status: i64, bytes: i64, hex: *u8, verdict: *u8) -> i64
451func ld_prov_last(idb: *u8, idlen: i64, pbuf: *u8) -> i64
called by 1: main calls 2: ld_readld_eol
478func ld_has_marker(b: *u8, n: i64, conf: *u8, cn: i64) -> i64
called by 1: main calls 1: ld_eol
505func ld_find_past(b: *u8, n: i64, needle: *u8) -> i64
called by 1: ld_next_cursor calls 1: ld_vlen
522func ld_copy_until_quote(b: *u8, n: i64, from: i64, out: *u8) -> i64
called by 1: ld_next_cursor
534func ld_next_cursor(b: *u8, n: i64, out: *u8) -> i64
543func ld_row_line(buf: *u8, fo: *i64, fl: *i64, r: i64, score: i64, rank: i64, have: i64) -> i64
called by 1: main calls 3: ld_putnld_putsld_write_n
559func main(argc: i64, argv: *i64) -> i64