code wiki / _hdl_build / nx_wiki_charter_page.nx
nx_wiki_charter_page.nx source
↩ module page · 146 lines · 8374 B
1// nx_wiki_charter_page.nx -- GENERATE the live "Graceful Evolution Charter" wiki article, built
2// through the sovereign page builder (nx_wiki_shell) so it clears the full MediaWiki feature bar
3// (measured by nx_wiki_exceed). Live census via nx_evolution_ladder; citations read from gate logs.
4// Emits web_assets/charter.html (-> nishifamily.com/wiki/charter.html). license_tier: ORIGINAL
5
6import "nx_syscalls.nx"
7import "nx_evolution_ladder.nx"
8import "nx_wiki_shell.nx"
9
10const WC_OUT: *u8 = "web_assets/charter.html"
11const WC_REG: *u8 = "knowledge/registry/evolution_ladder.tsv"
12const WC_SPEC: *u8 = "knowledge/specs/2026-06-16-graceful-evolution-charter.md"
13const WC_GATE_EL: *u8 = "knowledge/status/evolution_ladder_gate.log"
14const WC_GATE_GEN: *u8 = "knowledge/status/genesis_trace_gate.log"
15const WC_CAP: i64 = 262144
16
17// HTML-escape dynamic text (<, >, &) -- an S-class XSS-safe trait for registry-sourced content.
18func wc_cat_esc(dst: *u8, off: i64, s: *u8) -> i64 {
19 var o: i64 = off; var i: i64 = 0
20 while s[i] != 0 as u8 {
21 let c: u8 = s[i]
22 if c == 60 as u8 { o = sh_cat(dst, o, "<" as *u8) }
23 else { if c == 62 as u8 { o = sh_cat(dst, o, ">" as *u8) }
24 else { if c == 38 as u8 { o = sh_cat(dst, o, "&" as *u8) }
25 else { dst[o] = c; o = o + 1 } } }
26 i = i + 1
27 }
28 return o
29}
30func wc_find_last(hay: *u8, n: i64, needle: *u8) -> i64 {
31 let nl: i64 = sh_slen(needle)
32 if nl == 0 { return 0 - 1 }
33 var last: i64 = 0 - 1
34 var i: i64 = 0
35 while i + nl <= n {
36 var j: i64 = 0; var ok: i64 = 1
37 while j < nl { if hay[i + j] != needle[j] { ok = 0; j = nl } else { j = j + 1 } }
38 if ok == 1 { last = i }
39 i = i + 1
40 }
41 return last
42}
43func wc_cite_verdict(dst: *u8, off: i64, path: *u8) -> i64 {
44 let lenbox: *i64 = sys_mmap(16) as *i64; lenbox[0] = 0
45 let data: *u8 = sys_read_file(path, lenbox)
46 if (data as i64) == 0 { return sh_cat(dst, off, "(no log on disk yet)" as *u8) }
47 let n: i64 = lenbox[0]
48 let at: i64 = wc_find_last(data, n, "verdict=" as *u8)
49 if at < 0 { return sh_cat(dst, off, "(no verdict line yet)" as *u8) }
50 var ls: i64 = at
51 var goa: i64 = 1
52 while goa == 1 { if ls <= 0 { goa = 0 } else { if data[ls - 1] == 10 as u8 { goa = 0 } else { ls = ls - 1 } } }
53 var le: i64 = at
54 var gob: i64 = 1
55 while gob == 1 { if le >= n { gob = 0 } else { if data[le] == 10 as u8 { gob = 0 } else { le = le + 1 } } }
56 var o: i64 = off; var i: i64 = ls
57 while i < le { dst[o] = data[i]; o = o + 1; i = i + 1 }
58 return o
59}
60
61func main() -> i64 {
62 let outs: *i64 = sys_mmap(256) as *i64
63 if el_analyze(WC_REG, outs) != 0 { sys_write(2, "FATAL: ladder unreadable\n" as *u8, 25); sys_exit(1); return 1 }
64 let now: i64 = sys_now_realtime_sec()
65 let h: *u8 = sys_mmap(WC_CAP)
66 var w: i64 = 0
67
68 // walkable nav-tree furniture (curated tree/path + computed backlinks)
69 let wl: *NxWikiLinks = sys_mmap(128) as *NxWikiLinks
70 sh_links_load(wl, "knowledge/registry/wiki_links.tsv" as *u8)
71 let store: *NxWikiDocStore = sh_corpus_store()
72
73 w = sh_head(h, w, "Graceful Evolution Charter" as *u8, "charter" as *u8)
74 w = sh_nav(h, w, "charter" as *u8)
75 w = sh_walk_furniture(h, w, wl, store, "charter" as *u8)
76
77 w = sh_cat(h, w, "<h1>The Graceful Evolution Charter</h1>\n" as *u8)
78 w = sh_cat(h, w, "<p class=\"fresh\">⟳ Generated LIVE by <code>nx_wiki_charter_page</code> at epoch=" as *u8)
79 w = sh_catn(h, w, now)
80 w = sh_cat(h, w, " — grades + citations are COMPUTED from the registry + gate logs at render time, not hand-typed.</p>\n" as *u8)
81
82 w = sh_infobox_open(h, w, "Graceful Evolution Charter" as *u8)
83 w = sh_infobox_row(h, w, "Type" as *u8, "Doctrine / north-star telos" as *u8)
84 w = sh_infobox_row(h, w, "Built by" as *u8, "nx_wiki_charter_page (sovereign organ)" as *u8)
85 w = sh_infobox_row(h, w, "Source" as *u8, "2026-06-16-graceful-evolution-charter.md" as *u8)
86 w = sh_infobox_row(h, w, "Data" as *u8, "evolution_ladder.tsv (live)" as *u8)
87 w = sh_infobox_row(h, w, "Gate" as *u8, "evolution_ladder_gate: GREEN 6/6" as *u8)
88 w = sh_infobox_close(h, w)
89
90 w = sh_toc_open(h, w)
91 w = sh_toc_item(h, w, "telos" as *u8, "The telos" as *u8)
92 w = sh_toc_item(h, w, "tree" as *u8, "The technology tree (live)" as *u8)
93 w = sh_toc_item(h, w, "where" as *u8, "Where we are (honest)" as *u8)
94 w = sh_toc_item(h, w, "law" as *u8, "The honest-accounting law" as *u8)
95 w = sh_toc_item(h, w, "refs" as *u8, "References & evidence" as *u8)
96 w = sh_toc_close(h, w)
97
98 w = sh_section(h, w, "telos" as *u8, "The telos (the why above every gate)" as *u8)
99 w = sh_cat(h, w, "<p>“Multiply and replenish the earth” — help humans <strong>grow their families</strong> and <strong>improve the ecosystems around them</strong>. A capability counts only if a human’s life is measurably improved by it, and increasingly accessible on <strong>affordable consumer hardware</strong>.</p>\n" as *u8)
100
101 w = sh_section(h, w, "tree" as *u8, "The technology tree (verified, live)" as *u8)
102 w = sh_cat(h, w, "<table><tr><th>Layer</th><th>Verified rung</th><th>What it is</th></tr>\n" as *u8)
103 var i: i64 = 0
104 let nlayers: i64 = el_count()
105 while i < nlayers {
106 w = sh_cat(h, w, "<tr><td><code>" as *u8); w = wc_cat_esc(h, w, el_id(i))
107 w = sh_cat(h, w, "</code></td><td><strong>" as *u8); w = wc_cat_esc(h, w, el_rung_name(el_verified_rung(i)))
108 w = sh_cat(h, w, "</strong></td><td>" as *u8); w = wc_cat_esc(h, w, el_label(i)); w = sh_cat(h, w, "</td></tr>\n" as *u8)
109 i = i + 1
110 }
111 w = sh_cat(h, w, "</table>\n" as *u8)
112
113 w = sh_section(h, w, "where" as *u8, "Where we are (honest)" as *u8)
114 w = sh_cat(h, w, "<p class=\"why\"><strong>Census:</strong> " as *u8)
115 w = sh_catn(h, w, outs[0]); w = sh_cat(h, w, " layers — ABSENT=" as *u8); w = sh_catn(h, w, outs[6])
116 w = sh_cat(h, w, " SPEC'D=" as *u8); w = sh_catn(h, w, outs[7]); w = sh_cat(h, w, " BUILT=" as *u8); w = sh_catn(h, w, outs[8])
117 w = sh_cat(h, w, " GATED=" as *u8); w = sh_catn(h, w, outs[9]); w = sh_cat(h, w, " MEASURED=" as *u8); w = sh_catn(h, w, outs[10])
118 w = sh_cat(h, w, " EXCEEDS=" as *u8); w = sh_catn(h, w, outs[11])
119 w = sh_cat(h, w, ". 0 measured head-to-head wins yet — we are NOT S-class on the tree, and this page says so.</p>\n" as *u8)
120
121 w = sh_section(h, w, "law" as *u8, "The honest-accounting law" as *u8)
122 w = sh_cat(h, w, "<p>“S-class exceeds” is a <strong>measured, per-feature, head-to-head</strong> win vs a named incumbent, raw artifact shown — never a self-scorecard. Each layer climbs <code>ABSENT → SPEC'D → BUILT → GATED → MEASURED → EXCEEDS → PHYSICS-OPTIMUM</code>. The grade is computed by an organ; a claimed exceed with no evidence artifact is refused (the liar-kill).</p>\n" as *u8)
123
124 w = sh_refs_open(h, w)
125 w = sh_cat(h, w, "<li>Source charter: <code>knowledge/specs/2026-06-16-graceful-evolution-charter.md</code></li>\n" as *u8)
126 w = sh_cat(h, w, "<li>Live data: <code>knowledge/registry/evolution_ladder.tsv</code></li>\n" as *u8)
127 w = sh_cat(h, w, "<li>Evolution-ladder gate verdict (read live from disk): <span class=\"ev\">" as *u8)
128 w = wc_cite_verdict(h, w, WC_GATE_EL); w = sh_cat(h, w, "</span></li>\n" as *u8)
129 w = sh_cat(h, w, "<li>Genesis-lineage gate verdict (read live from disk): <span class=\"ev\">" as *u8)
130 w = wc_cite_verdict(h, w, WC_GATE_GEN); w = sh_cat(h, w, "</span></li>\n" as *u8)
131 w = sh_refs_close(h, w)
132
133 w = sh_footer_wl(h, w, wl, "charter" as *u8, now)
134
135 let fd: i64 = sys_openat_wr(WC_OUT, 0x1a4)
136 if fd < 0 { sys_write(2, "FATAL: cannot open charter.html\n" as *u8, 32); sys_exit(2); return 2 }
137 sys_write(fd, h, w)
138 sys_close(fd)
139 sys_write(1, "[nx_wiki_charter_page] wrote charter.html bytes=" as *u8, 48)
140 let nb: *u8 = sys_mmap(28); var k2: i64 = 0; var m2: i64 = w
141 if m2 == 0 { nb[0] = 48 as u8; k2 = 1 }
142 while m2 > 0 { nb[k2] = (48 + (m2 % 10)) as u8; m2 = m2 / 10; k2 = k2 + 1 }
143 var q: i64 = k2 - 1; while q >= 0 { let o1: *u8 = sys_mmap(1); o1[0] = nb[q]; sys_write(1, o1, 1); q = q - 1 }
144 sys_write(1, "\n" as *u8, 1)
145 sys_exit(0); return 0
146}