code wiki / _hdl_build / nx_maturity_board.nx
nx_maturity_board.nx source
↩ module page · 330 lines · 16214 B
1// nx_maturity_board.nx -- THE MATURITY BOARD (operator 2026-07-16: "those high end are all liars, they
2// don't have a maturity analysis"). Publishes /compare/maturity: EVERY matrix domain graded by the
3// evidence-capped maturity census (nx_swarm_maturity engine, built as nx_maturity_census.elf) NEXT TO its
4// feature-presence score -- so a 1000-presence domain publicly shows its honest gate-only floor and the
5// inflation ratio. This is the standing anti-navel-gazing surface the 2026-07-15 doctrine banked as NEXT
6// ([[feedback-maturity-not-feature-presence-ecosystem-2026-07-15]]); the old sweep was a volatile
7// scratchpad bash script -- THIS is the sovereign organ replacing it, wired into nx_compare_regen so every
8// evaluation refresh re-measures maturity too.
9//
10// Reads knowledge/compare/maturity_board.list (domain per line). Per domain: fork+exec the census
11// (stdout -> .matboard.out, the proven capture pattern), parse the LAST "= <n>/1000" (works for both the
12// auto-floor line and the hand-authored evidence path), read the published presence permille from
13// <droot><dom>/api.json when present ("coverage" int). Emits <droot>maturity/api.json + index.html
14// (PLAIN ENGLISH per the dashboards law: bars, ratios, one-sentence meanings -- no ledger keys).
15// FAIL-CLOSED: <10 domains graded -> exit 1, nothing published (regen treats nonzero as RED).
16// usage: nx_maturity_board [droot] [listfile] (defaults ../sites/nishifamily/compare/ + the list SSOT)
17// license_tier: ORIGINAL module: nishi-core.compare.maturity_board
18import "nx_sovjson_lib.nx"
19import "nx_syscalls.nx"
20const MB_MAGIC_20000: i64 = 20000
21const MB_MAGIC_8192: i64 = 8192
22const MB_MAGIC_65536: i64 = 65536
23const MB_MAGIC_262144: i64 = 262144
24
25const MB_LIST_DEF: *u8 = "knowledge/compare/maturity_board.list" as *u8
26const MB_DROOT_DEF: *u8 = "../sites/nishifamily/compare/" as *u8
27const MB_CENSUS: *u8 = "_offc/nx_maturity_census.elf" as *u8
28const MB_CAP_FILE: *u8 = ".matboard.out" as *u8
29const MB_MAXD: i64 = 64
30const MB_OUTCAP: i64 = 262144
31
32func mb_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
33func mb_p(s: *u8) -> i64 { sys_write(1, s, mb_len(s)); return 0 }
34func mb_cat(dst: *u8, o: i64, s: *u8) -> i64 { return sj_cat(dst, o, s) }
35func mb_catn(dst: *u8, o: i64, v: i64) -> i64 { return sj_catn(dst, o, v) }
36func mb_read(path: *u8, buf: *u8, cap: i64) -> i64 {
37 let fd: i64 = sys_openat_rd(path)
38 if fd < 0 { return 0 - 1 }
39 var t: i64 = 0
40 var r: i64 = 1
41 while r > 0 { r = sys_read(fd, (buf as i64 + t) as *u8, cap - 1 - t); if r > 0 { t = t + r } if t >= cap - 1 { r = 0 } }
42 sys_close(fd)
43 return t
44}
45func mb_write_atomic(path: *u8, buf: *u8, n: i64) -> i64 {
46 let np: *u8 = sys_mmap(600)
47 var o: i64 = mb_cat(np, 0, path)
48 o = mb_cat(np, o, ".nxnew" as *u8)
49 np[o] = 0 as u8
50 let fd: i64 = sys_openat_wr(np, 420)
51 if fd < 0 { return 0 - 1 }
52 var off: i64 = 0
53 while off < n {
54 let w2: i64 = sys_write(fd, (buf as i64 + off) as *u8, n - off)
55 if w2 <= 0 { sys_close(fd); return 0 - 2 }
56 off = off + w2
57 }
58 sys_close(fd)
59 return sys_renameat(np, path)
60}
61func mb_line_end(buf: *u8, pos: i64, end: i64) -> i64 {
62 var p: i64 = pos
63 while p < end { if (buf[p] as i64) == 10 { return p } p = p + 1 }
64 return end
65}
66// fork+exec the census for one domain, stdout -> MB_CAP_FILE (cwd-relative), bounded wait
67func mb_run_census(dom: *u8) -> i64 {
68 let pid: i64 = sys_fork()
69 if pid == 0 {
70 let ofd: i64 = sys_openat_wr(MB_CAP_FILE, 420)
71 if ofd < 0 { sys_exit(125) }
72 sys_dup3(ofd, 1, 0)
73 sys_dup3(ofd, 2, 0)
74 let av: *i64 = sys_mmap(8 * 4) as *i64
75 av[0] = MB_CENSUS as i64
76 av[1] = dom as i64
77 av[2] = 0
78 let ev: *i64 = sys_mmap(8 * 2) as *i64
79 ev[0] = 0
80 sys_execve(MB_CENSUS, av, ev)
81 sys_exit(127)
82 }
83 if pid < 0 { return 0 - 1 }
84 let st: *i64 = sys_mmap(8) as *i64
85 var waited: i64 = 0
86 var done: i64 = 0
87 var rc: i64 = 0 - 1
88 while done == 0 {
89 let r: i64 = sys_wait4(pid, st, 1)
90 if r == pid { rc = 0; done = 1 }
91 else {
92 if waited >= MB_MAGIC_20000 { nx_kill(pid, 9); sys_wait4(pid, st, 0); done = 1 }
93 sys_sleep_ms(100)
94 waited = waited + 100
95 }
96 }
97 sys_munmap(st as *u8, 8)
98 return rc
99}
100// parse digits immediately after the first occurrence of `label` in buf[0..n) -> value, or -1
101func mb_after_label(buf: *u8, n: i64, label: *u8) -> i64 {
102 let ll: i64 = mb_len(label)
103 var i: i64 = 0
104 while i + ll <= n {
105 var j: i64 = 0
106 var ok: i64 = 1
107 while j < ll { if buf[i+j] != label[j] { ok = 0; j = ll } j = j + 1 }
108 if ok == 1 {
109 var k: i64 = i + ll
110 var v: i64 = 0
111 var got: i64 = 0
112 while k < n { let c: i64 = buf[k] as i64; if c >= 48 { if c <= 57 { v = v * 10 + (c - 48); got = 1; k = k + 1 } else { break } } else { break } }
113 if got == 1 { if v <= 1000 { return v } }
114 return 0 - 1
115 }
116 i = i + 1
117 }
118 return 0 - 1
119}
120// the census score line, ANCHORED on its labels (never the parenthetical comparison number):
121// evidence path: "=== COMBINED HONEST MATURITY = 356/1000 (vs the 944/1000 ...)"
122// auto-floor: "honest maturity FLOOR = 69/1000 ..."
123func mb_parse_score(buf: *u8, n: i64) -> i64 {
124 let v1: i64 = mb_after_label(buf, n, "HONEST MATURITY = " as *u8)
125 if v1 >= 0 { return v1 }
126 return mb_after_label(buf, n, "FLOOR = " as *u8)
127}
128// find "coverage" then the first integer after it in buf[0..n) -> permille, or -1
129func mb_parse_presence(buf: *u8, n: i64) -> i64 {
130 let key: *u8 = "coverage" as *u8
131 var i: i64 = 0
132 while i + 8 <= n {
133 var j: i64 = 0
134 var ok: i64 = 1
135 while j < 8 { if buf[i+j] != key[j] { ok = 0; j = 8 } j = j + 1 }
136 if ok == 1 {
137 var k: i64 = i + 8
138 while k < n { let c: i64 = buf[k] as i64; if c >= 48 { if c <= 57 { break } } if k - i > 40 { return 0 - 1 } k = k + 1 }
139 var v: i64 = 0
140 while k < n { let c2: i64 = buf[k] as i64; if c2 >= 48 { if c2 <= 57 { v = v * 10 + (c2 - 48); k = k + 1 } else { break } } else { break } }
141 if v > 0 { if v <= 1000 { return v } }
142 return 0 - 1
143 }
144 i = i + 1
145 }
146 return 0 - 1
147}
148
149func main(argc: i64, argv: *i64) -> i64 {
150 var droot: *u8 = MB_DROOT_DEF
151 var listf: *u8 = MB_LIST_DEF
152 if argc >= 2 { droot = argv[1] as *u8 }
153 if argc >= 3 { listf = argv[2] as *u8 }
154 mb_p("=== NX-MATURITY-BOARD -- evidence-capped maturity vs feature-presence, every matrix domain ===\n" as *u8)
155 let lst: *u8 = sys_mmap(MB_MAGIC_8192)
156 let ln: i64 = mb_read(listf, lst, MB_MAGIC_8192)
157 if ln <= 0 { mb_p("FAIL: maturity_board.list missing\n" as *u8); return 1 }
158 // parallel arrays
159 let dnames: *i64 = sys_mmap(MB_MAXD * 8) as *i64
160 let dmat: *i64 = sys_mmap(MB_MAXD * 8) as *i64
161 let dpres: *i64 = sys_mmap(MB_MAXD * 8) as *i64
162 var nd: i64 = 0
163 let cap: *u8 = sys_mmap(MB_OUTCAP)
164 let pj: *u8 = sys_mmap(MB_MAGIC_65536)
165 let ppath: *u8 = sys_mmap(600)
166 var pos: i64 = 0
167 while pos < ln {
168 let le: i64 = mb_line_end(lst, pos, ln)
169 if le > pos { if (lst[pos] as i64) != 35 { if nd < MB_MAXD {
170 // persist NUL-terminated domain name
171 let nm: *u8 = sys_mmap(64)
172 var o: i64 = 0
173 var k: i64 = pos
174 while k < le { if (lst[k] as i64) != 13 { nm[o] = lst[k]; o = o + 1 } k = k + 1 }
175 nm[o] = 0 as u8
176 // census
177 var mat: i64 = 0 - 1
178 if mb_run_census(nm) == 0 {
179 let cn: i64 = mb_read(MB_CAP_FILE, cap, MB_OUTCAP)
180 if cn > 0 { mat = mb_parse_score(cap, cn) }
181 }
182 // presence from published api.json
183 var po: i64 = mb_cat(ppath, 0, droot)
184 po = mb_cat(ppath, po, nm)
185 po = mb_cat(ppath, po, "/api.json" as *u8)
186 ppath[po] = 0 as u8
187 var pres: i64 = 0 - 1
188 let pn: i64 = mb_read(ppath, pj, MB_MAGIC_65536)
189 if pn > 0 { pres = mb_parse_presence(pj, pn) }
190 dnames[nd] = nm as i64
191 dmat[nd] = mat
192 dpres[nd] = pres
193 mb_p(" " as *u8); mb_p(nm)
194 mb_p(": maturity=" as *u8)
195 let tb: *u8 = sys_mmap(28)
196 var tn: i64 = mb_catn(tb, 0, mat); sys_write(1, tb, tn)
197 mb_p(" presence=" as *u8)
198 tn = mb_catn(tb, 0, pres); sys_write(1, tb, tn)
199 mb_p("\n" as *u8)
200 nd = nd + 1
201 } } }
202 pos = le + 1
203 }
204 if nd < 10 { mb_p("FAIL-CLOSED: fewer than 10 domains graded -- refusing to publish\n" as *u8); return 1 }
205 // sort by maturity desc (simple selection sort; nd <= 64)
206 var a: i64 = 0
207 while a < nd {
208 var best: i64 = a
209 var b: i64 = a + 1
210 while b < nd { if dmat[b] > dmat[best] { best = b } b = b + 1 }
211 if best != a {
212 let t1: i64 = dnames[a]; dnames[a] = dnames[best]; dnames[best] = t1
213 let t2: i64 = dmat[a]; dmat[a] = dmat[best]; dmat[best] = t2
214 let t3: i64 = dpres[a]; dpres[a] = dpres[best]; dpres[best] = t3
215 }
216 a = a + 1
217 }
218 // aggregates (only rows with both numbers for the ratio)
219 var msum: i64 = 0
220 var mcnt: i64 = 0
221 var psum: i64 = 0
222 var pcnt: i64 = 0
223 a = 0
224 while a < nd {
225 if dmat[a] >= 0 { msum = msum + dmat[a]; mcnt = mcnt + 1 }
226 if dpres[a] >= 0 { psum = psum + dpres[a]; pcnt = pcnt + 1 }
227 a = a + 1
228 }
229 var mavg: i64 = 0
230 if mcnt > 0 { mavg = msum / mcnt }
231 var pavg: i64 = 0
232 if pcnt > 0 { pavg = psum / pcnt }
233 var ratio10: i64 = 0
234 if mavg > 0 { ratio10 = pavg * 10 / mavg }
235 // ---- api.json ----
236 let out: *u8 = sys_mmap(MB_MAGIC_262144)
237 var w: i64 = 0
238 w = mb_cat(out, w, "{\"v\":1,\"api\":\"nishi-compare\",\"resource\":\"maturity\",\"meaning\":\"evidence-capped maturity (L0-L5 census, gate-only floors) vs feature-presence coverage per domain -- the inflation ratio is the navel-gazing gap\",\"avg_maturity\":" as *u8)
239 w = mb_catn(out, w, mavg)
240 w = mb_cat(out, w, ",\"avg_presence\":" as *u8)
241 w = mb_catn(out, w, pavg)
242 w = mb_cat(out, w, ",\"inflation_x10\":" as *u8)
243 w = mb_catn(out, w, ratio10)
244 w = mb_cat(out, w, ",\"domains\":[" as *u8)
245 a = 0
246 while a < nd {
247 if a > 0 { w = mb_cat(out, w, "," as *u8) }
248 w = mb_cat(out, w, "{\"domain\":\"" as *u8)
249 w = mb_cat(out, w, dnames[a] as *u8)
250 w = mb_cat(out, w, "\",\"maturity\":" as *u8)
251 w = mb_catn(out, w, dmat[a])
252 w = mb_cat(out, w, ",\"presence\":" as *u8)
253 w = mb_catn(out, w, dpres[a])
254 w = mb_cat(out, w, "}" as *u8)
255 a = a + 1
256 }
257 w = mb_cat(out, w, "]}" as *u8)
258 let jp: *u8 = sys_mmap(600)
259 var jo: i64 = mb_cat(jp, 0, droot)
260 jo = mb_cat(jp, jo, "maturity/api.json" as *u8)
261 jp[jo] = 0 as u8
262 if mb_write_atomic(jp, out, w) != 0 { mb_p("WRITE-FAIL api.json\n" as *u8); return 1 }
263 mb_p("published " as *u8); mb_p(jp); mb_p("\n" as *u8)
264 // ---- index.html (plain english, bars, chips) ----
265 w = 0
266 w = mb_cat(out, w, "<!doctype html><html><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width,initial-scale=1\"><title>Nishi Compare -- Honest Maturity Board</title><style>body{font-family:system-ui,sans-serif;margin:2rem auto;max-width:1000px;padding:0 1rem;background:rgb(13,17,23);color:rgb(230,237,243)}h1{font-size:1.5rem}p.lead{color:rgb(139,148,158)}table{width:100%;border-collapse:collapse;margin-top:1rem}th,td{text-align:left;padding:.45rem .6rem;border-bottom:1px solid rgb(48,54,61);font-size:.92rem}th{color:rgb(139,148,158);font-weight:600}.bar{height:10px;border-radius:5px;background:rgb(48,54,61);position:relative;min-width:120px}.bar>i{position:absolute;left:0;top:0;bottom:0;border-radius:5px;background:rgb(63,185,80)}.bar>b{position:absolute;left:0;top:0;bottom:0;border-radius:5px;background:rgb(88,166,255);opacity:.35}.chip{display:inline-block;padding:.1rem .5rem;border-radius:999px;font-size:.75rem;font-weight:600}.floor{background:rgb(60,40,10);color:rgb(240,180,80)}.earned{background:rgb(10,50,25);color:rgb(63,185,80)}.gap{color:rgb(240,120,100);font-weight:700}</style></head><body><h1>Honest Maturity Board</h1><p class=\"lead\">Every compare domain graded by the evidence-capped maturity census (a gate-only feature counts L1 of 5; live, MCP-callable, multi-node and hardened levels must be PROVEN) next to its feature-presence score. A high presence with a low maturity means the domain has forms of the features but has not proven them in production -- that gap is the honest work remaining.</p>" as *u8)
267 w = mb_cat(out, w, "<p><b>Across " as *u8)
268 w = mb_catn(out, w, nd)
269 w = mb_cat(out, w, " domains: average honest maturity " as *u8)
270 w = mb_catn(out, w, mavg)
271 w = mb_cat(out, w, " / 1000 vs average feature-presence " as *u8)
272 w = mb_catn(out, w, pavg)
273 w = mb_cat(out, w, " / 1000 -- presence overstates maturity about " as *u8)
274 w = mb_catn(out, w, ratio10 / 10)
275 w = mb_cat(out, w, "." as *u8)
276 w = mb_catn(out, w, ratio10 % 10)
277 w = mb_cat(out, w, "x.</b></p><table><tr><th>domain</th><th>honest maturity</th><th></th><th>presence</th><th>gap</th><th>standing</th></tr>" as *u8)
278 a = 0
279 while a < nd {
280 w = mb_cat(out, w, "<tr><td><a style=\"color:rgb(88,166,255)\" href=\"/compare/" as *u8)
281 w = mb_cat(out, w, dnames[a] as *u8)
282 w = mb_cat(out, w, "\">" as *u8)
283 w = mb_cat(out, w, dnames[a] as *u8)
284 w = mb_cat(out, w, "</a></td><td>" as *u8)
285 if dmat[a] >= 0 { w = mb_catn(out, w, dmat[a]) } else { w = mb_cat(out, w, "not measured" as *u8) }
286 w = mb_cat(out, w, "</td><td><div class=\"bar\">" as *u8)
287 if dpres[a] > 0 {
288 w = mb_cat(out, w, "<b style=\"width:" as *u8)
289 w = mb_catn(out, w, dpres[a] / 10)
290 w = mb_cat(out, w, "%\"></b>" as *u8)
291 }
292 if dmat[a] > 0 {
293 w = mb_cat(out, w, "<i style=\"width:" as *u8)
294 w = mb_catn(out, w, dmat[a] / 10)
295 w = mb_cat(out, w, "%\"></i>" as *u8)
296 }
297 w = mb_cat(out, w, "</div></td><td>" as *u8)
298 if dpres[a] >= 0 { w = mb_catn(out, w, dpres[a]) } else { w = mb_cat(out, w, "-" as *u8) }
299 w = mb_cat(out, w, "</td><td class=\"gap\">" as *u8)
300 if dmat[a] > 0 { if dpres[a] > 0 {
301 let r10: i64 = dpres[a] * 10 / dmat[a]
302 w = mb_catn(out, w, r10 / 10)
303 w = mb_cat(out, w, "." as *u8)
304 w = mb_catn(out, w, r10 % 10)
305 w = mb_cat(out, w, "x" as *u8)
306 } }
307 if dmat[a] <= 0 { w = mb_cat(out, w, "-" as *u8) }
308 w = mb_cat(out, w, "</td><td>" as *u8)
309 if dmat[a] > 220 { w = mb_cat(out, w, "<span class=\"chip earned\">evidence above floor</span>" as *u8) }
310 else { w = mb_cat(out, w, "<span class=\"chip floor\">gate-only floor</span>" as *u8) }
311 w = mb_cat(out, w, "</td></tr>" as *u8)
312 a = a + 1
313 }
314 w = mb_cat(out, w, "</table><p class=\"lead\">Green bar = honest maturity. Blue shadow = feature presence. A domain climbs above its floor only by declaring live/MCP/multi-node evidence the census can verify (proof files + symbols on disk) -- never by asserting.</p></body></html>" as *u8)
315 let hp: *u8 = sys_mmap(600)
316 var ho: i64 = mb_cat(hp, 0, droot)
317 ho = mb_cat(hp, ho, "maturity/index.html" as *u8)
318 hp[ho] = 0 as u8
319 if mb_write_atomic(hp, out, w) != 0 { mb_p("WRITE-FAIL index.html\n" as *u8); return 1 }
320 mb_p("published " as *u8); mb_p(hp); mb_p("\n" as *u8)
321 mb_p("MATURITY-BOARD domains=" as *u8)
322 let fb: *u8 = sys_mmap(28)
323 var fn: i64 = mb_catn(fb, 0, nd); sys_write(1, fb, fn)
324 mb_p(" avg_maturity=" as *u8)
325 fn = mb_catn(fb, 0, mavg); sys_write(1, fb, fn)
326 mb_p(" avg_presence=" as *u8)
327 fn = mb_catn(fb, 0, pavg); sys_write(1, fb, fn)
328 mb_p(" verdict=MEASURED-HONEST\n" as *u8)
329 return 0
330}