code wiki / _hdl_build / nx_doc_member.nx

nx_doc_member.nx source

↩ module page · 36 lines · 2748 B

1// nx_doc_member.nx -- THE NISHI LIBRARIAN joins the team: registers the `docintel` DOMAIN into THE NISHI 2// BUILDER (alongside ad/web/game/finance) with a member card + the extract/catalog surfaces. Idempotent + 3// FAIL-CLOSED on nb_template_safe (no <script, no src=). The librarian reads/extracts/catalogs/manages 4// documents into structured data -- this banks it as a builder-emittable capability-member. license_tier: ORIGINAL 5import "nx_syscalls.nx" 6import "nx_itoa_lib.nx" // shared MSB-first emitter (zero-alloc) 7import "nx_nishi_builder.nx" 8 9func m_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 10// MIGRATED to the shared emitter (debt 1785563586). The old body mmapped a scratch buffer 11// per call and never freed it. At PAGE granularity that is 4096B leaked PER CALL -- the 12// defect that took 28.5GB of a 36GB host in nx_ts_lumadiff (2MB input, ~3.66M calls). 13// nxi_* is MSB-first, allocates NOTHING, and emits identical bytes including the sign. 14func m_putn(v: i64) -> i64 { nxi_out(v); return 0 } 15func m_reg(path: *u8, kind: *u8, id: *u8, label: *u8, tpl: *u8) -> i64 { 16 if nb_template_safe(tpl) == 0 { m_puts(" REFUSED (unsafe) "); m_puts(id); m_puts("\n"); return 0 - 9 } 17 let r: i64 = nb_register(path, "docintel\x00" as *u8, kind, id, label, tpl) 18 m_puts(" nb_register docintel/"); m_puts(kind); m_puts("/"); m_puts(id); m_puts(" -> "); m_putn(r); m_puts("\n") 19 return r 20} 21 22func main() -> i64 { 23 let path: *u8 = NB_PATH 24 m_puts("=== NISHI LIBRARIAN -> THE NISHI BUILDER: register the docintel domain ===\n") 25 m_reg(path, "member\x00" as *u8, "nishi-librarian\x00" as *u8, "Nishi Librarian (team member)\x00" as *u8, 26 "<section class=\"member doc\"><h2>Nishi Librarian</h2><p>Reads, extracts, catalogs and manages documents into structured data &mdash; sovereign, content-addressed, additive.</p></section>\x00" as *u8) 27 m_reg(path, "extract\x00" as *u8, "bill\x00" as *u8, "Bill to structured line-items\x00" as *u8, 28 "<table class=\"extract\"><thead><tr><th>Date</th><th>Code</th><th>Units</th><th>Amount</th></tr></thead><tbody></tbody></table>\x00" as *u8) 29 m_reg(path, "catalog\x00" as *u8, "card\x00" as *u8, "Document catalog card\x00" as *u8, 30 "<div class=\"doccard\"><span class=\"title\"></span><span class=\"cid\"></span><span class=\"current\">current</span></div>\x00" as *u8) 31 let total: i64 = nb_count(path, "docintel\x00" as *u8, "*\x00" as *u8) 32 m_puts("docintel domain entries in the builder catalog="); m_putn(total); m_puts("\n") 33 if total >= 3 { m_puts("NISHI LIBRARIAN: registered into the builder\n"); return 0 } 34 m_puts("NISHI LIBRARIAN: registration incomplete\n") 35 return 1 36}