code wiki / _hdl_build / nx_codewiki_lib.nx
nx_codewiki_lib.nx
buildroot/runtime/_hdl_build/nx_codewiki_lib.nx
about
nx_codewiki_lib.nx -- THE CODE WIKI: an always-regenerable wiki OF the source tree.
===== WHY THIS EXISTS ============================================
The ecosystem has a charter wiki (runtime/wiki/, ~100 curated pages) and a
corpus search (nishi_search), but NOTHING that answers, for a given module:
what does it do, what does it import, WHO IMPORTS IT, what functions does
it export, and where do I look next. That is the Google-Code-Wiki class of
artifact: generated FROM the code, never hand-maintained, stale-proof
because regeneration is one command and the output is deterministic.
It is deliberately a STATIC generator, not a daemon:
- the charter wiki daemon is sized for ~100 docs (docs_cap) and serves
public charter sites; 17k code pages do not belong in its pools
- static bytes are gateable (byte-identical re-run), diffable, and
servable by any route -- or browsable as local files with zero infra
===== WHAT IS REUSED (the dupfunc law: the tool must not duplicate) ======
gl_walk / gl_read (nx_gatelib) -- the ONE tree walk + file read
nis_scan (nx_import_scan) -- the ONE accurate import scanner
EcoGraph (nx_eco_graph) -- intern + CSR fan-in/fan-out
gl_walk's edge mode is NOT used: it interns import paths verbatim, so a
subdir import ("wiki/nx_foo.nx") would become a node DISTINCT from the
basename node of the actual file and every such link would dangle. We
intern the BASENAME of each import ourselves -- same convention as file
nodes -- so links resolve, and what still cannot resolve is reported as
an honest unresolved count instead of a dead href.
===== ENVELOPES (declared, per the scale law) =====================
CW_MAXNODE 24000 nodes | CW_EDGECAP 262144 edges | file cap GL_FILECAP
CW_PAGECAP 4 MiB/page -- overflow appends a LOUD PAGE-TRUNCATED banner
CW_MAXDIRS 256 | desc arena 2 MiB | per-file import dedup window 128
license_tier: ORIGINAL
dependencies 4 imports · 3 importers
imports: nx_syscalls.nxnx_eco_graph.nxnx_gatelib.nxnx_import_scan.nx
imported by: nx_codewiki.nxnx_codewiki_ask.nxnx_codewiki_gate.nx
structs
| none |
consts
| 41 | const CW_MAGIC_2166136261: i64 = 2166136261 |
| 42 | const CW_MAGIC_16777619: i64 = 16777619 |
| 43 | const CW_MAGIC_1024: i64 = 1024 |
| 44 | const CW_MAGIC_65536: i64 = 65536 |
| 45 | const CW_MAGIC_262144: i64 = 262144 |
| 46 | const CW_MAGIC_86400: i64 = 86400 |
| 47 | const CW_MAGIC_131072: i64 = 131072 |
| 48 | const CW_MAGIC_4096: i64 = 4096 |
| 49 | const CW_MAGIC_1469598103934665603: i64 = 1469598103934665603 |
| 50 | const CW_MAGIC_1099511628211: i64 = 1099511628211 |
| 52 | const CW_MAXNODE: i64 = 24000 // units=modules; tree measured 17,491 today (2026-07-29 census) = 37% headroom |
| 53 | const CW_ARENA: i64 = 4194304 |
| 54 | const CW_HASH: i64 = 65536 |
| 55 | const CW_PATHARENA: i64 = 8388608 |
| 56 | const CW_EDGECAP: i64 = 262144 // units=import edges; measured 44,399 (2026-07-27) = 5.9x headroom |
| 59 | const CW_PAGECAP: i64 = 4194304 // units=bytes; == the measured 4MB edge serving cap (a bigger page cannot ship); overflow -> loud banner (T8) |
| 60 | const CW_PAGERESERVE: i64 = 192 |
| 61 | const CW_MAXDIRS: i64 = 256 // units=dirs; tree measured 13 today -- headroom visible on purpose |
| 62 | const CW_DESCARENA: i64 = 2097152 |
| 63 | const CW_DESCMAX: i64 = 160 |
| 64 | const CW_TOPK: i64 = 20 |
| 65 | const CW_IMPDEDUP: i64 = 128 |
| 66 | const CW_SHOWIN: i64 = 100 |
| 68 | const CW_MAXFN: i64 = 131072 // units=funcs; measured 91,067 today (2026-07-29 regen) = 1.4x headroom; cap declared on the search page |
| 69 | const CW_FNARENA: i64 = 4194304 |
| 71 | const CW_SVGN: i64 = 36 |
| 73 | const CW_MAXFAM: i64 = 4096 // units=families; measured ~750 today (threshold-4 rule) = 5x headroom |
| 74 | const CW_FAMARENA: i64 = 131072 |
| 75 | const CW_FAMMIN: i64 = 4 |
| 76 | const CW_SBFAM: i64 = 16 |
| 78 | const CW_MAXSITE: i64 = 2097152 |
| 79 | const CW_SITEARENA: i64 = 33554432 |
| 80 | const CW_DEFHASH: i64 = 262144 |
| 81 | const CW_CALLSHOW: i64 = 6 |
| 82 | const CW_CALLDEDUP: i64 = 64 |
| 86 | const CW_NKIND: i64 = 11 |
| 87 | const CW_K_ARCHIVED: i64 = 0 |
| 88 | const CW_K_GATE: i64 = 1 |
| 89 | const CW_K_BENCH: i64 = 2 |
| 90 | const CW_K_PROBE: i64 = 3 |
| 91 | const CW_K_SMOKE: i64 = 4 |
| 92 | const CW_K_SKETCH: i64 = 5 |
| 93 | const CW_K_GENFIX: i64 = 6 |
| 94 | const CW_K_SERVICE: i64 = 7 |
| 95 | const CW_K_TOOL: i64 = 8 |
| 96 | const CW_K_LIB: i64 = 9 |
| 97 | const CW_K_ORPHAN: i64 = 10 |
| 98 | const CW_GENFIX_FAM: i64 = 200 |
| 99 | const CW_GENFIX_LOC: i64 = 40 |
| 100 | const CW_KINDSHOW: i64 = 24 |
| 106 | const CW_FINDCAP: i64 = 65536 // units=bytes; findings feed measured ~30 rows x ~200B today = 10x headroom |
| 107 | const CW_SPRAWLMAX: i64 = 12 |
| 112 | const CW_NCAT: i64 = 8 |
| 113 | const CW_CAT_LANDMINE: i64 = 0 |
| 114 | const CW_CAT_WORKAROUND: i64 = 1 |
| 115 | const CW_CAT_GOTCHA: i64 = 2 |
| 116 | const CW_CAT_TODO: i64 = 3 |
| 117 | const CW_CAT_THIRDPARTY: i64 = 4 |
| 118 | const CW_CAT_SECURITY: i64 = 5 |
| 119 | const CW_CAT_PERF: i64 = 6 |
| 120 | const CW_CAT_DEPRECATED: i64 = 7 |
| 121 | const CW_CATSHOW: i64 = 20 |
| 122 | const CW_LANGSHOW: i64 = 24 |
| 126 | const CW_TGTCAP: i64 = 8 |
| 127 | const CW_TGTSEV: i64 = 7 |
| 129 | const CW_EXPCONF: i64 = 1048576 |
| 130 | const CW_EXPELFS: i64 = 4096 // units=elfs; deployed set measured ~700 (496 exposed + 211 dark) = 5x headroom |
| 131 | const CW_EXPARENA: i64 = 262144 |
| 132 | const CW_EXPSHOW: i64 = 40 |
| 137 | const CW_SDOCMAX: i64 = 1400 |
| 138 | const CW_SDOCARENA: i64 = 41943040 |
| 139 | const CW_ASKDESCMAX: i64 = 150 |
| 140 | const CW_ASKCAP: i64 = 41943040 |
| 146 | const CW_ASKIDXCAP: i64 = 67108864 // units=bytes; sized for the measured 108.9k-record corpus w/ headroom; truncation REFUSES loudly (T33 + rc=4) |
| 147 | const CW_ASKTOP: i64 = 10 |
| 148 | const CW_ASKQTOK: i64 = 16 |
| 149 | const CW_ASKMINTOK: i64 = 3 |
| 154 | const CW_IDF_P1: i64 = 5 |
| 155 | const CW_IDF_W1: i64 = 12 |
| 156 | const CW_IDF_P2: i64 = 30 |
| 157 | const CW_IDF_W2: i64 = 8 |
| 158 | const CW_IDF_P3: i64 = 100 |
| 159 | const CW_IDF_W3: i64 = 5 |
| 160 | const CW_IDF_P4: i64 = 300 |
| 161 | const CW_IDF_W4: i64 = 3 |
| 162 | const CW_IDF_W5: i64 = 1 |
| 163 | const CW_ASKNAMEX: i64 = 2 |
functions
| 167 | func cw_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 170 | func cw_app(buf: *u8, pos: *i64, cap: i64, s: *u8, n: i64) -> i64 |
| 178 | func cw_apps(buf: *u8, pos: *i64, cap: i64, s: *u8) -> i64 { return cw_app(buf, pos, cap, s, cw_slen(s)) } |
| 181 | func cw_appn(buf: *u8, pos: *i64, cap: i64, v: i64) -> i64 |
| 198 | func cw_appe(buf: *u8, pos: *i64, cap: i64, s: *u8, n: i64) -> i64 |
| 216 | func cw_flush(path: *u8, buf: *u8, pos: *i64, cap: i64) -> i64 |
| 237 | func cw_base(path: *u8) -> i64 |
| 248 | func cw_stemlen(nm: *u8) -> i64 |
| 254 | func cw_rawcpy(dst: *u8, at: i64, s: *u8) -> i64 |
| 262 | func cw_pagepath(dst: *u8, outdir: *u8, nm: *u8) -> i64 |
| 284 | func cw_applink2(buf: *u8, pos: *i64, cap: i64, nm: *u8, noext: i64) -> i64 |
| 300 | func cw_applink(buf: *u8, pos: *i64, cap: i64, nm: *u8) -> i64 calls 1: cw_applink2 |
| 305 | func cw_appext(buf: *u8, pos: *i64, cap: i64, noext: i64) -> i64 |
| 312 | func cw_appjse(buf: *u8, pos: *i64, cap: i64, s: *u8, n: i64) -> i64 |
| 334 | func cw_css(buf: *u8, pos: *i64, cap: i64) -> i64 |
| 374 | func cw_head3(buf: *u8, pos: *i64, cap: i64, title: *u8, tn: i64, sb: *u8) -> i64 |
| 396 | func cw_crumb(buf: *u8, pos: *i64, cap: i64, noext: i64, dlabel: *u8, dslug: *u8, self: *u8, sn: i64) -> i64 |
| 416 | func cw_foot(buf: *u8, pos: *i64, cap: i64) -> i64 |
| 423 | func cw_filterjs(buf: *u8, pos: *i64, cap: i64) -> i64 |
| 432 | func cw_line_starts(buf: *u8, ls: i64, le: i64, kw: *u8) -> i64 calls 1: cw_slen |
| 441 | func cw_sigend(buf: *u8, ls: i64, le: i64) -> i64 |
| 458 | func cw_impquote(buf: *u8, ls: i64, le: i64, out: *i64) -> i64 |
| 474 | func cw_impbase(buf: *u8, s: i64, n: i64, out: *i64) -> i64 |
| 502 | func cw_reach_maxmt(g: *EcoGraph, start: i64, stampv: *i64, epoch: i64, stack: *i64, srcmt: *i64) -> i64 |
| 527 | func cw_reach_count(g: *EcoGraph, start: i64, dirn: i64, stampv: *i64, epoch: i64, stack: *i64) -> i64 |
| 556 | func cw_depth_of(g: *EcoGraph, u: i64, memo: *i64) -> i64 |
| 580 | func cw_namecmp(g: *EcoGraph, a: i64, b: i64) -> i64 called by 1: cw_sortnodes |
| 598 | func cw_sortnodes(g: *EcoGraph, idx: *i64, tmp: *i64, n: i64) -> i64 calls 1: cw_namecmp |
| 631 | func cw_appstem(buf: *u8, pos: *i64, cap: i64, nm: *u8) -> i64 |
| 643 | func cw_outpath(dst: *u8, outdir: *u8, name: *u8) -> i64 |
| 655 | func cwc_hash(s: *u8, n: i64) -> i64 called by 1: cwc_scan |
| 669 | func cwc_scan(strip: *u8, sn: i64, mod: i64, |
| 752 | func cw_famkey(nm: *u8, out: *u8) -> i64 |
| 774 | func cw_appdeflink(buf: *u8, pos: *i64, cap: i64, g: *EcoGraph, dmodv: *i64, dnamesv: *u8, dnoffv: *i64, dnlenv: *i64, dx: i64, noext: i64) -> i64 |
| 790 | func cw_callflow(buf: *u8, pos: *i64, cap: i64, g: *EcoGraph, dmodv: *i64, dnamesv: *u8, dnoffv: *i64, dnlenv: *i64, |
| 886 | func cw_nar_include(page: *u8, pos: *i64, cap: i64, outdir: *u8, opath: *u8, name: *u8) -> i64 |
| 908 | func cw_appsrclink(buf: *u8, pos: *i64, cap: i64, nm: *u8, ln: i64, noext: i64) -> i64 |
| 923 | func cw_nbr(buf: *u8, pos: *i64, cap: i64, g: *EcoGraph, v: i64, pathoff: *i64, noext: i64) -> i64 |
| 1022 | func cw_kindname(k: i64) -> *u8 |
| 1037 | func cw_namehas(nm: *u8, sub: *u8) -> i64 |
| 1053 | func cw_catname(k: i64) -> *u8 |
| 1064 | func cw_catdesc(k: i64) -> *u8 |
| 1074 | func cw_catsev(k: i64) -> i64 |
| 1094 | func cw_resolved(src: *u8, s: i64, e: i64) -> i64 |
| 1115 | func cw_secmit(src: *u8, s: i64, e: i64) -> i64 { return cw_resolved(src, s, e) } |
| 1120 | func cw_markscan(src: *u8, n: i64, m1: *u8, l1: i64, m2: *u8, l2: i64, m3: *u8, l3: i64, m4: *u8, l4: i64) -> i64 |
| 1160 | func cw_secscan(src: *u8, n: i64) -> i64 |
| 1166 | func cw_lmscan(src: *u8, n: i64) -> i64 |
| 1172 | func cw_catscan(src: *u8, n: i64) -> i64 |
| 1230 | func cw_mtime(path: *u8) -> i64 |
| 1273 | func cw_hasraw(src: *u8, s: i64, e: i64, needle: *u8, nl: i64) -> i64 |
| 1296 | func cw_substrclass(src: *u8, n: i64) -> i64 |
| 1330 | func cw_bs_prov(src: *u8, s: i64, e: i64) -> i64 |
| 1343 | func cw_boundscan(src: *u8, n: i64) -> i64 |
| 1398 | func cw_langscan(src: *u8, n: i64) -> i64 |
| 1420 | func cw_fnd_mod(fbuf: *u8, fpos: *i64, sev: i64, cat: *u8, mstem: *u8, mstem_n: i64) -> i64 |
| 1436 | func cw_fnd(fbuf: *u8, fpos: *i64, sev: i64, scope: *u8, desc: *u8) -> i64 |
| 1454 | func cw_atoi(b: *u8, s: i64, e: i64) -> i64 |
| 1465 | func cw_submatch(hay: *u8, hs: i64, he: i64, needle: *u8) -> i64 |
| 1482 | func cw_plpts(page: *u8, pos: *i64, cap: i64, vals: *i64, mx: i64, x0: i64, y0: i64, w: i64, h: i64) -> i64 |
| 1497 | func cw_spark(page: *u8, pos: *i64, cap: i64, vals: *i64) -> i64 |
| 1510 | func cw_dpill(page: *u8, pos: *i64, cap: i64, dv: i64, goodup: i64, unit: *u8) -> i64 |
| 1524 | func cw_pulse(page: *u8, pos: *i64, cap: i64, jrnlpath: *u8, meterpath: *u8, noext2: i64) -> i64 |
| 1762 | func cw_schemarow(sch: *u8, schn: i64, conf: *u8, ns: i64, ne: i64, box: *i64) -> i64 |
| 1799 | func cw_tools(page: *u8, pos: *i64, cap: i64, tix: *u8, tpos: *i64, |
| 1863 | func cw_asktools(abuf: *u8, apos: *i64, acap: i64, allowpath: *u8, schemapath: *u8) -> i64 |
| 1904 | func cw_atlas(page: *u8, pos: *i64, cap: i64, |
| 2042 | func cw_nameidx(name: *u8, needle: *u8) -> i64 |
| 2066 | func cw_has_base_sibling(earena: *u8, eoff: *i64, nelf: i64, cut: i64, snm: *u8) -> i64 |
| 2101 | func cw_exposure(page: *u8, pos: *i64, cap: i64, g: *EcoGraph, pathoff: *i64, |
| 2445 | func cw_apptsv(buf: *u8, pos: *i64, cap: i64, s: *u8, n: i64) -> i64 |
| 2456 | func cw_lc(c: i64) -> i64 |
| 2470 | func cw_hastok(hay: *u8, hs: i64, he: i64, tok: *u8, tl: i64) -> i64 |
| 2488 | func cw_fld(buf: *u8, s: i64, e: i64) -> i64 |
| 2502 | func cw_qtok(words: *i64, wn: i64, first: i64, toks: *u8, toff: *i64, tlen: *i64) -> i64 |
| 2537 | func cw_ask(idxpath: *u8, qtoks: *u8, qoff: *i64, qlen: *i64, nq: i64, urlbase: *u8, topname: *u8) -> i64 |
| 2802 | func cw_generate2(root: *u8, outdir: *u8, noext: i64, st: *i64, allowpath: *u8, schemapath: *u8, atlaspath: *u8) -> i64 |