code wiki / _hdl_build / nx_wiki_walk_republish.nx
nx_wiki_walk_republish.nx source
↩ module page · 65 lines · 3805 B
1// nx_wiki_walk_republish.nx -- WALKABILITY arc: re-publish the 4 enriched pages
2// (start, charter, nist_stem, devlog) LIVE through the GUARDED + VERSIONED publish
3// path (vpub), so the new walk furniture (breadcrumb + tree + prev/next + related
4// + backlinks) lands on nishifamily.com/wiki/*. ADDITIVE: each publish FIRST snaps
5// a content-addressed rollback version (vpub), then the A3 fail-closed guard
6// (pg_decide) must ALLOW before the NAS push runs. board/roadmap/search untouched.
7//
8// REUSE (no publish/version/push substrate reinvented): nx_wiki_versioned_publish
9// vpub (snapshot -> A3 guard -> fork+exec nx_aw_push). license_tier: ORIGINAL
10import "nx_wiki_versioned_publish.nx"
11import "nx_itoa_lib.nx" // shared MSB-first emitter (zero-alloc)
12import "nx_syscalls.nx"
13
14func 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 }
15// MIGRATED to the shared emitter (debt 1785563586). The old body mmapped a scratch buffer
16// per call and never freed it. At PAGE granularity that is 4096B leaked PER CALL -- the
17// defect that took 28.5GB of a 36GB host in nx_ts_lumadiff (2MB input, ~3.66M calls).
18// nxi_* is MSB-first, allocates NOTHING, and emits identical bytes including the sign.
19func r_num(v: i64) -> i64 { nxi_out(v); return 0 }
20
21// fixed epoch for deterministic version records (NO wall-clock in the version index).
22const RP_EPOCH: i64 = 1781800000
23
24// publish ONE page through vpub (guarded + versioned, push LIVE).
25func rp_publish(slug: *u8, path: *u8, cs_ptr: *i64, cs_len: *i64, ncorpus: i64) -> i64 {
26 let res: *PubResult = sys_mmap(64) as *PubResult
27 let vout: *i64 = sys_mmap(16) as *i64
28 let rc: i64 = vpub(slug, path, cs_ptr, cs_len, ncorpus, RP_EPOCH, 1, res, vout)
29 r_w(" vpub("); r_w(slug); r_w(") rc="); r_w(vp_status_name(rc))
30 r_w(" version#="); r_num(vout[0])
31 r_w(" | push="); r_w(pub_status_name(res.status))
32 r_w(" push_invoked="); r_num(res.push_invoked)
33 r_w(" push_rc="); r_num(res.push_rc)
34 r_w(" bytes="); r_num(res.bytes); r_w("\n")
35 if rc == VP_OK { if res.push_invoked == 1 { return 0 } }
36 return 0 - 1
37}
38
39func main() -> i64 {
40 // corpus set = EVERY slug the enriched pages link to (breadcrumb/tree/related/
41 // prevnext/footer href all 8 + the nav search). A missing slug => PG_REJECT_DEAD_LINK.
42 let cs_ptr: *i64 = sys_mmap(16 * 8) as *i64
43 let cs_len: *i64 = sys_mmap(16 * 8) as *i64
44 cs_ptr[0] = "start" as *u8 as i64; cs_len[0] = 5
45 cs_ptr[1] = "charter" as *u8 as i64; cs_len[1] = 7
46 cs_ptr[2] = "board" as *u8 as i64; cs_len[2] = 5
47 cs_ptr[3] = "devlog" as *u8 as i64; cs_len[3] = 6
48 cs_ptr[4] = "nist_stem" as *u8 as i64; cs_len[4] = 9
49 cs_ptr[5] = "roadmap" as *u8 as i64; cs_len[5] = 7
50 cs_ptr[6] = "econsim" as *u8 as i64; cs_len[6] = 7
51 cs_ptr[7] = "products" as *u8 as i64; cs_len[7] = 8
52 cs_ptr[8] = "search" as *u8 as i64; cs_len[8] = 6
53 let ncorpus: i64 = 9
54
55 r_w("=== WALK REPUBLISH: 4 enriched pages -> LIVE (guarded+versioned, additive) ===\n")
56 var ok: i64 = 0
57 // ai_start emitter writes web_assets/ai_start.html for slug "start".
58 if rp_publish("start" as *u8, "web_assets/ai_start.html" as *u8, cs_ptr, cs_len, ncorpus) == 0 { ok = ok + 1 }
59 if rp_publish("charter" as *u8, "web_assets/charter.html" as *u8, cs_ptr, cs_len, ncorpus) == 0 { ok = ok + 1 }
60 if rp_publish("nist_stem" as *u8, "web_assets/nist_stem.html" as *u8, cs_ptr, cs_len, ncorpus) == 0 { ok = ok + 1 }
61 if rp_publish("devlog" as *u8, "web_assets/devlog.html" as *u8, cs_ptr, cs_len, ncorpus) == 0 { ok = ok + 1 }
62 r_w("=== republished "); r_num(ok); r_w("/4 pages LIVE (rest fail-closed if any) ===\n")
63 if ok == 4 { sys_exit(0); return 0 }
64 sys_exit(1); return 1
65}