code wiki / (root) / nx_pub_lib.nx

nx_pub_lib.nx

buildroot/runtime/nx_pub_lib.nx

51664 B1105 linesdepth 5pulls 6 transitivereach 6 importersview sourcekind librarytopic pub
docsdependenciesstructsconstsfunctions

about

nx_pub_lib.nx -- THE PUBLISHING PLANE CORE (multi-site, 2026-07-30). THE OPERATOR'S DIAGNOSIS: "how we publish in these workstreams to nishifamily.com is random and arbitrary -- we want nishifamily and all our client sites to have SOTA capabilities so we and the client can focus on work, not on where something was put." MEASURED FIRST (2026-07-30, nx_pub_desk census + live edge fetches), which is why this file exists: nishifamily: FOUR different answers to "what pages does this site have" -- the nav/sitemap page says 23 surfaces (hardcoded in nx_site_chrome), sitemap.xml says 96 urls, the registry says 157 rows, the docroot holds 135 pages (+61 .prev artifacts +11 debris). 54 pages are SERVED but in NO registry. andelinwest (a CLIENT): registry 0 rows, no sitemap.xml, no robots.txt (404), and https://andelinwest.com/index.html.bak-v1 returns 200 with a whole previous homepage. THE ELITE PATTERN (news-org + docs-as-code + headless-CMS sweep, July 2026): ONE machine-readable registry per site is the SSOT; every discovery artifact -- sitemap.xml, robots.txt, llms.txt, nav, hubs, feeds -- is DERIVED from it and never hand-curated; and content reaches the docroot only through a gate that maintains the registry. Astro content collections make it a build error, the NYT Gateway makes it a publish refusal. Same law: THE DERIVED ARTIFACT MUST NOT BE AUTHORABLE. THIS FILE is the derivation core, site-agnostic. It reads TWO data sources and writes NO policy: 1. the SITE TABLE (knowledge/pub_sites.conf, TSV): site <TAB> docroot <TAB> regprefix <TAB> baseurl <TAB> title <TAB> disallow-csv 2. the per-site REGISTRY plane at regprefix (the ecosystem row convention, status@col3): id <TAB> title <TAB> owner <TAB> status <TAB> section <TAB> path <TAB> note status vocabulary: live (indexable page) | asset (served, never in the sitemap) | draft | withdrawn | redirect | debris WHAT IT FIXES vs the pd_sitemap it supersedes (both stay until nx_pub_desk migrates, F-debt filed): * REAL XML ESCAPING. pd_esc maps & < > to '.' -- lossy by design for JSON/HTML attributes, but in a <loc> it silently CORRUPTS any URL carrying them. Here &amp; &lt; &gt; &quot; &apos; are emitted. * NO PER-ROW ALLOCATION. pd_sitemap calls sys_mmap INSIDE the row loop (a 512B path buffer per registry row). That is the exact per-call-alloc-in-a-primitive class that leaked 8KB/call through ss_hget across 205 sites. Every buffer here is hoisted above the loop. * HONEST LOAD. sts_load_honest, not sts_load: a stale q:n silently truncates a registry, and a truncated registry emits a SHORT SITEMAP that looks perfectly well-formed. Callers get the flags. * MULTI-SITE BY CONSTRUCTION. No docroot, prefix, domain or disallow rule is compiled in (rule 11). license_tier: ORIGINAL No hw writes (Rule 26). DEPENDENCIES ARE runtime/-ONLY ON PURPOSE (measured 2026-07-30): import resolution reaches _hdl_build/ -> runtime/ but NOT runtime/ -> _hdl_build/. This lib is imported by

dependencies 3 imports · 4 importers

nx_store_seed_lib.nx nx_seg_store.nx nx_syscalls.nx nx_pub_lib.nx nx_asset_page.nx nx_pub_plane.nx nx_pub_plane_gate.nx nx_site_publish_lib.nx

imports: nx_store_seed_lib.nxnx_seg_store.nxnx_syscalls.nx

imported by: nx_asset_page.nxnx_pub_plane.nxnx_pub_plane_gate.nxnx_site_publish_lib.nx

structs

none

consts

48const PL_CAP: i64 = 1048576
49const PL_CONFCAP: i64 = 65536
50const PL_PATHCAP: i64 = 1024
51const PL_SPAN: i64 = 16
52const PL_STATB: i64 = 144
53const PL_MT_OFF: i64 = 88
54const PL_MODE: i64 = 420
55const PL_SECMAX: i64 = 128
56const PL_I64B: i64 = 8
57const PL_STDERR: i64 = 2
58const PL_NUMCAP: i64 = 32
59const PL_BASE10: i64 = 10
60const PL_TAB: i64 = 9
61const PL_NL: i64 = 10
62const PL_SLASH: i64 = 47
63const PL_HASH: i64 = 35
64const PL_COMMA: i64 = 44
65const PL_DASH: i64 = 45
66const PL_DOT: i64 = 46
67const PL_ZERO: i64 = 48
68const PL_SPACE: i64 = 32
69const PL_AMP: i64 = 38
70const PL_LT: i64 = 60
71const PL_GT: i64 = 62
72const PL_QUOTE: i64 = 34
73const PL_APOS: i64 = 39
74const PL_HTML_EXT: i64 = 5
75const PL_INDEX_LEN: i64 = 10
77const PL_DBUF: i64 = 65536
78const PL_DE_RLO: i64 = 16
79const PL_DE_RHI: i64 = 17
80const PL_DE_TYPE: i64 = 18
81const PL_DE_NAME: i64 = 19
82const PL_DT_DIR: i64 = 4
83const PL_BYTE: i64 = 256
84const PL_NAMES: i64 = 262144
85const PL_MAXN: i64 = 4096
88const PL_MAXDEPTH: i64 = 8
89const PL_ENVB: i64 = 64
90const PL_NAME_PAD: i64 = 2
91const PL_I64B: i64 = 8
92const PL_DAY: i64 = 86400
93const PL_TWO_DIG: i64 = 10
95const PL_EPOCH_SHIFT: i64 = 719468
96const PL_ERA_DAYS: i64 = 146097
97const PL_CENT_DAYS: i64 = 36524
98const PL_QUAD_DAYS: i64 = 1460
99const PL_YEAR_DAYS: i64 = 365
100const PL_ERA_YEARS: i64 = 400
101const PL_LEAP4: i64 = 4
102const PL_LEAP100: i64 = 100
103const PL_MONTH_SLOPE: i64 = 153
104const PL_MP_BIAS: i64 = 2
105const PL_MP_SCALE: i64 = 5
106const PL_MP_CUT: i64 = 10
107const PL_MAR_OFF: i64 = 3
108const PL_DEC_WRAP: i64 = 9
110const PL_C_ID: i64 = 0
111const PL_C_TITLE: i64 = 1
112const PL_C_OWNER: i64 = 2
113const PL_C_STATUS: i64 = 3
114const PL_C_SECTION: i64 = 4
115const PL_C_PATH: i64 = 5
116const PL_C_NOTE: i64 = 6
118const PL_S_SITE: i64 = 0
119const PL_S_DOCROOT: i64 = 1
120const PL_S_PREFIX: i64 = 2
121const PL_S_BASEURL: i64 = 3
122const PL_S_TITLE: i64 = 4
123const PL_S_DISALLOW: i64 = 5
125const PL_OK: i64 = 0
126const PL_REFUSED: i64 = 3

functions

128func pl_vlen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
129func pl_puts(s: *u8) -> i64 { sys_write(1, s, pl_vlen(s)); return 0 }
130func pl_werr(s: *u8) -> i64 { sys_write(PL_STDERR, s, pl_vlen(s)); return 0 }
called by 2: pp_werrmain calls 2: sys_writepl_vlen
131func pl_cat(d: *u8, o: i64, s: *u8) -> i64
137func pl_catn(d: *u8, o: i64, v: i64) -> i64
152func pl_le(q: *u8, i: i64, n: i64) -> i64
158func pl_col(q: *u8, ls: i64, le: i64, c: i64, out: *i64) -> i64
174func pl_lit_eq(q: *u8, s: i64, e: i64, lit: *u8) -> i64
called by 2: pl_site_lookupmain
180func pl_span_eq(a: *u8, s1: i64, e1: i64, b: *u8, s2: i64, e2: i64) -> i64
186func pl_ends(q: *u8, s: i64, n: i64, suf: *u8) -> i64
called by 1: pl_clean_url calls 1: pl_vlen
193func pl_find(buf: *u8, n: i64, needle: *u8) -> i64
called by 1: pg_has calls 1: pl_vlen
207func pl_span_cstr(q: *u8, s: i64, e: i64, out: *u8) -> i64
214func pl_span_put(d: *u8, o: i64, q: *u8, s: i64, e: i64) -> i64
called by 1: pp_board
221func pl_xesc(d: *u8, o: i64, q: *u8, s: i64, e: i64) -> i64
called by 1: pl_clean_url calls 1: pl_cat
242func pl_mesc(d: *u8, o: i64, q: *u8, s: i64, e: i64) -> i64
257func pl_wfile(path: *u8, buf: *u8, n: i64) -> i64
269func pl_rfile(path: *u8, buf: *u8, cap: i64) -> i64
282func pl_commit(path: *u8, buf: *u8, n: i64) -> i64
292func pl_join(out: *u8, dir: *u8, name: *u8) -> i64
called by 3: pp_emit_sitepg_fixfilemain calls 1: pl_cat
302func pl_mtime_path(path: *u8) -> i64
311func pl_iso(d: *u8, o: i64, epoch: i64) -> i64
calls 1: pl_catn
343func pl_clean_url(d: *u8, o: i64, q: *u8, s: i64, e: i64) -> i64
calls 2: pl_endspl_xesc
354func pl_site_lookup(confpath: *u8, site: *u8, conf: *u8, spans: *i64) -> i64
391func pl_sitemap(docroot: *u8, prefix: *u8, baseurl: *u8, outpath: *u8, flags: *i64) -> i64
441func pl_robots(baseurl: *u8, disallow: *u8, ds: i64, de: i64, outpath: *u8) -> i64
477func pl_llms(docroot: *u8, prefix: *u8, baseurl: *u8, title: *u8, outpath: *u8) -> i64
582func pl_scan(docroot: *u8, arena: *u8, arena_cap: i64, offs: *i64, maxn: i64, envp: *i64) -> i64
630func pl_adopt_refuse(cap: *u8, n: i64) -> i64
660func pl_scan_tree(docroot: *u8, arena: *u8, arena_cap: i64, offs: *i64, maxn: i64, envp: *i64) -> i64
769func pl_reg_has(reg: *u8, rn: i64, arena: *u8, off: i64) -> i64
786func pl_find_at(q: *u8, off: i64, n: i64, needle: *u8) -> i64
802func pl_classify(arena: *u8, off: i64) -> *u8
824func pl_adopt(docroot: *u8, prefix: *u8, counts: *i64) -> i64
938func pl_register_asset(prefix: *u8, relpath: *u8, note: *u8) -> i64
990func pl_status_counts(prefix: *u8, c: *i64) -> i64
1022func pl_reg_has_prefix(reg: *u8, rn: i64, arena: *u8, off: i64) -> i64
1044func pl_disk_counts(docroot: *u8, prefix: *u8, d: *i64) -> i64
1080func pl_check(prefix: *u8, relpath: *u8) -> i64