code wiki / _hdl_build / nx_ims_search_publish.nx

nx_ims_search_publish.nx source

↩ module page · 62 lines · 3748 B

1// nx_ims_search_publish.nx -- land /wiki/search.html LIVE through the GUARDED + VERSIONED publish path 2// (vpub): snapshot a content-addressed rollback version, then the A3 fail-closed guard must ALLOW before the 3// NAS push runs. ADDITIVE. Publishes the re-emitted START hub first (so its rendered tree's <a href> to the 4// new search child is LIVE -> keeps reachability=100), then search.html. The corpus set = all 13 live wiki 5// slugs; a missing/dead slug => the guard rejects with PG_REJECT_DEAD_LINK (fail-closed) -- the safety net. 6// REUSE: nx_wiki_versioned_publish vpub. Mirrors nx_ims_batch1_publish exactly. license_tier: ORIGINAL 7import "nx_wiki_versioned_publish.nx" 8import "nx_itoa_lib.nx" // shared MSB-first emitter (zero-alloc) 9import "nx_syscalls.nx" 10 11func p_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 12// MIGRATED to the shared emitter (debt 1785563586). The old body mmapped a scratch buffer 13// per call and never freed it. At PAGE granularity that is 4096B leaked PER CALL -- the 14// defect that took 28.5GB of a 36GB host in nx_ts_lumadiff (2MB input, ~3.66M calls). 15// nxi_* is MSB-first, allocates NOTHING, and emits identical bytes including the sign. 16func p_num(v: i64) -> i64 { nxi_out(v); return 0 } 17 18// fixed epoch for deterministic version records (NO wall-clock in the version index). 19const SP_EPOCH: i64 = 1781860000 20 21func sp_publish(slug: *u8, path: *u8, cs_ptr: *i64, cs_len: *i64, ncorpus: i64) -> i64 { 22 let res: *PubResult = sys_mmap(64) as *PubResult 23 let vout: *i64 = sys_mmap(16) as *i64 24 let rc: i64 = vpub(slug, path, cs_ptr, cs_len, ncorpus, SP_EPOCH, 1, res, vout) 25 p_w(" vpub("); p_w(slug); p_w(") rc="); p_w(vp_status_name(rc)) 26 p_w(" version#="); p_num(vout[0]) 27 p_w(" | push="); p_w(pub_status_name(res.status)) 28 p_w(" push_invoked="); p_num(res.push_invoked) 29 p_w(" push_rc="); p_num(res.push_rc) 30 p_w(" bytes="); p_num(res.bytes); p_w("\n") 31 if rc == VP_OK { if res.push_invoked == 1 { return 0 } } 32 return 0 - 1 33} 34 35func main() -> i64 { 36 // corpus set = all 13 live wiki slugs. Every href in start/search must resolve to one of these or the A3 37 // guard fail-closes the publish. 38 let cs_ptr: *i64 = sys_mmap(24 * 8) as *i64 39 let cs_len: *i64 = sys_mmap(24 * 8) as *i64 40 cs_ptr[0] = "start" as *u8 as i64; cs_len[0] = 5 41 cs_ptr[1] = "charter" as *u8 as i64; cs_len[1] = 7 42 cs_ptr[2] = "nist_stem" as *u8 as i64; cs_len[2] = 9 43 cs_ptr[3] = "roadmap" as *u8 as i64; cs_len[3] = 7 44 cs_ptr[4] = "board" as *u8 as i64; cs_len[4] = 5 45 cs_ptr[5] = "devlog" as *u8 as i64; cs_len[5] = 6 46 cs_ptr[6] = "econsim" as *u8 as i64; cs_len[6] = 7 47 cs_ptr[7] = "products" as *u8 as i64; cs_len[7] = 8 48 cs_ptr[8] = "genesis_genealogy" as *u8 as i64; cs_len[8] = 17 49 cs_ptr[9] = "access_wall" as *u8 as i64; cs_len[9] = 11 50 cs_ptr[10] = "formats_uxf" as *u8 as i64; cs_len[10] = 11 51 cs_ptr[11] = "media_studio" as *u8 as i64; cs_len[11] = 12 52 cs_ptr[12] = "search" as *u8 as i64; cs_len[12] = 6 53 let ncorpus: i64 = 13 54 55 p_w("=== IMS SEARCH PUBLISH: re-emit start hub + search.html -> LIVE (guarded+versioned) ===\n") 56 var ok: i64 = 0 57 if sp_publish("start" as *u8, "web_assets/ai_start.html" as *u8, cs_ptr, cs_len, ncorpus) == 0 { ok = ok + 1 } 58 if sp_publish("search" as *u8, "web_assets/search.html" as *u8, cs_ptr, cs_len, ncorpus) == 0 { ok = ok + 1 } 59 p_w("=== published "); p_num(ok); p_w("/2 LIVE (start + search; fail-closed if any) ===\n") 60 if ok == 2 { sys_exit(0); return 0 } 61 sys_exit(1); return 1 62}