code wiki / _hdl_build / nx_wiki_pub_board.nx

nx_wiki_pub_board.nx source

↩ module page · 45 lines · 2443 B

1// nx_wiki_pub_board.nx -- publish ONE page (board) LIVE through the GUARDED + VERSIONED publish path 2// (vpub): snapshot a content-addressed rollback version, then the A3 fail-closed guard must ALLOW before 3// the NAS push runs. ADDITIVE: writes exactly /wiki/board.html. Corpus set = the 9 walkable slugs every 4// page links to (a missing slug => PG_REJECT_DEAD_LINK). REUSE: nx_wiki_versioned_publish vpub. 5// license_tier: ORIGINAL 6import "nx_wiki_versioned_publish.nx" 7import "nx_itoa_lib.nx" // shared MSB-first emitter (zero-alloc) 8import "nx_syscalls.nx" 9 10func r_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 11// MIGRATED to the shared emitter (debt 1785563586). The old body mmapped a scratch buffer 12// per call and never freed it. At PAGE granularity that is 4096B leaked PER CALL -- the 13// defect that took 28.5GB of a 36GB host in nx_ts_lumadiff (2MB input, ~3.66M calls). 14// nxi_* is MSB-first, allocates NOTHING, and emits identical bytes including the sign. 15func r_num(v: i64) -> i64 { nxi_out(v); return 0 } 16 17const RP_EPOCH: i64 = 1781850000 18 19func main() -> i64 { 20 let cs_ptr: *i64 = sys_mmap(16 * 8) as *i64 21 let cs_len: *i64 = sys_mmap(16 * 8) as *i64 22 cs_ptr[0] = "start" as *u8 as i64; cs_len[0] = 5 23 cs_ptr[1] = "charter" as *u8 as i64; cs_len[1] = 7 24 cs_ptr[2] = "board" as *u8 as i64; cs_len[2] = 5 25 cs_ptr[3] = "devlog" as *u8 as i64; cs_len[3] = 6 26 cs_ptr[4] = "nist_stem" as *u8 as i64; cs_len[4] = 9 27 cs_ptr[5] = "roadmap" as *u8 as i64; cs_len[5] = 7 28 cs_ptr[6] = "econsim" as *u8 as i64; cs_len[6] = 7 29 cs_ptr[7] = "products" as *u8 as i64; cs_len[7] = 8 30 cs_ptr[8] = "search" as *u8 as i64; cs_len[8] = 6 31 let ncorpus: i64 = 9 32 33 let res: *PubResult = sys_mmap(64) as *PubResult 34 let vout: *i64 = sys_mmap(16) as *i64 35 let rc: i64 = vpub("devlog" as *u8, "web_assets/devlog.html" as *u8, cs_ptr, cs_len, ncorpus, RP_EPOCH, 1, res, vout) 36 r_w("vpub(devlog) rc="); r_w(vp_status_name(rc)) 37 r_w(" version#="); r_num(vout[0]) 38 r_w(" | push="); r_w(pub_status_name(res.status)) 39 r_w(" push_invoked="); r_num(res.push_invoked) 40 r_w(" push_rc="); r_num(res.push_rc) 41 r_w(" guard_code="); r_num(res.code) 42 r_w(" bytes="); r_num(res.bytes); r_w("\n") 43 if rc == VP_OK { if res.push_invoked == 1 { if res.push_rc == 0 { sys_exit(0); return 0 } } } 44 sys_exit(1); return 1 45}