code wiki / _hdl_build / nx_sota_page.nx
nx_sota_page.nx source
↩ module page · 254 lines · 19839 B
1// nx_sota_page.nx -- GENERATE the SOTA page from the live instruments. Kills debt 1785514548.
2//
3// THE DEFECT: https://nishifamily.com/sota was HAND-COMPOSED PROSE. On 2026-07-31 it claimed "456
4// permil across 20 domains" while the live rollup said 434 across 26, with cited sources 12 days
5// stale. A derived artifact that a human can author WILL drift, and it drifts silently because
6// nothing compares it to its own source. Hand-editing that page to today's number is not a fix --
7// it re-arms the identical failure tomorrow. The fix is that no human writes this page at all.
8//
9// Every number below is read at generation time from the sovereign store and the durable ledger:
10// maturity from em_rollup_store, growth decomposition from em_trend, per-domain rows from the same
11// walk that nx_ecomat_domledger_gate proves reconciles with the headline. The page prints its own
12// generation epoch and its sources so a reader can re-derive it.
13// argv[1]=out_html argv[2]=store argv[3]=ledger. license_tier: ORIGINAL No hw writes (Rule 26).
14import "nx_ecomat_trend_lib.nx"
15import "nx_ecomat_domledger_lib.nx"
16import "nx_ecomat_domtrend_lib.nx"
17import "nx_rankmap.nx"
18
19// 2026-08-01: was "web_assets/sota.html" -- a directory NOTHING serves. The generator ran fine and
20// wrote a FRESH page (16168B at 11:17) while the public /sota served a 20-hour-old copy from
21// sites/nishifamily/sota.html (16175B, separate inode, not a link). Same defect class as the five
22// instances in reference-artifacts-never-placed-where-consumers-look: the work was DONE and simply
23// landed where no consumer looks. Every sibling emitter (nx_dora, nx_pm_cockpit, nx_eff_board,
24// nx_netobs) writes straight into sites/nishifamily -- this one was the outlier.
25// Fixed at the SOURCE rather than by adding a copy step: two paths would be two sources of truth.
26const SP_OUT: *u8 = "sites/nishifamily/sota.html"
27const SP_MODE: i64 = 0x1a4
28const SP_AUTOLOG: *u8 = "knowledge/status/autonomy_meter.log"
29
30func sp_pct_w(cur: i64, bar: i64) -> i64 {
31 if bar <= 0 { return 0 }
32 return (100 * cur) / bar
33}
34
35// per-domain rows straight from the store -- same walk the reconciliation gate proves.
36func sp_domains(fd: i64, prefix: *u8) -> i64 {
37 let h: *i64 = ss_open(prefix)
38 if (h as i64) == 0 { return 0 }
39 let pq: *i64 = sys_mmap(16) as *i64
40 let lq: *i64 = sys_mmap(16) as *i64
41 let dom: *u8 = sys_mmap(ECOMAT_DOM_CAP)
42 let nr: *u8 = sys_mmap(ECOMAT_NR_CAP)
43 var k: i64 = 0
44 var go: i64 = 1
45 var n: i64 = 0
46 while go == 1 {
47 let key: *u8 = sys_mmap(64)
48 ec_key(k, key)
49 if ss_hget(h, key, pq, lq) == 1 {
50 let v: *u8 = pq[0] as *u8
51 ec_str(v, 0, dom, ECOMAT_DOM_CAP)
52 ec_str(v, 2, nr, ECOMAT_NR_CAP)
53 var cur: i64 = ec_cur(v)
54 let bar: i64 = ec_bar(v)
55 let tout: *i64 = sys_mmap(16) as *i64
56 let dl: i64 = em_domain_level(v, tout)
57 if tout[0] != 0 { cur = dl }
58 _fp(fd, "<tr><td>" as *u8); _fp(fd, ec_axis_label(ec_axis(v)))
59 _fp(fd, "</td><td><b>" as *u8); _fp(fd, dom)
60 _fp(fd, "</b></td><td>" as *u8); _fp(fd, mat_label(cur))
61 _fp(fd, " → " as *u8); _fp(fd, mat_label(bar))
62 _fp(fd, "</td><td class='n'>" as *u8); _fn(fd, cur)
63 _fp(fd, "/" as *u8); _fn(fd, bar)
64 _fp(fd, "</td><td><div class='bar'><i style='width:" as *u8); _fn(fd, sp_pct_w(cur, bar))
65 _fp(fd, "%'></i></div></td><td class='ev" as *u8); _fn(fd, tout[0])
66 _fp(fd, "'>" as *u8); _fp(fd, em_tri_label(tout[0]))
67 _fp(fd, "</td><td class='nx'>" as *u8); _fp(fd, nr)
68 _fp(fd, "</td></tr>\n" as *u8)
69 n = n + 1
70 k = k + 1
71 } else { go = 0 }
72 }
73 return n
74}
75
76func main(argc: i64, argv: *i64) -> i64 {
77 var outp: *u8 = SP_OUT
78 var store: *u8 = ECOMAT_STORE
79 var ledger: *u8 = TR_LEDGER
80 if argc >= 2 { outp = argv[1] as *u8 }
81 if argc >= 3 { store = argv[2] as *u8 }
82 if argc >= 4 { ledger = argv[3] as *u8 }
83
84 _p("=== NX-SOTA-PAGE: generating the SOTA surface from live instruments ===\n" as *u8)
85
86 let roll: *i64 = sys_mmap(256) as *i64
87 em_rollup_store(store, SP_AUTOLOG, roll, 0)
88 if roll[2] == 0 {
89 _p("NX-SOTA-PAGE verdict=RED reason=empty-store (refusing to publish a page with no measurements)\n" as *u8)
90 sys_exit(101)
91 return 101
92 }
93
94 let tr: *i64 = sys_mmap(TR_OUT_SLOTS * TR_I64) as *i64
95 let trrc: i64 = em_trend(ledger, tr)
96
97 // PRE-FLIGHT: validate BEFORE opening, so a mismatch yields NO artifact at all rather than a
98 // partial page a later publish could pick up. edl_walk with fd<0 returns the count AND the sums
99 // without writing, so this costs one store walk and zero I/O. Checks LEVELS, not just the count.
100 let pre: *i64 = sys_mmap(EDL_SUMS * 8) as *i64
101 let pren: i64 = edl_walk(store, 0 - 1, 0, pre)
102 var okpre: i64 = 0
103 if pren == roll[2] { if pre[0] == roll[6] { if pre[1] == roll[7] { okpre = 1 } } }
104 if okpre == 0 {
105 _p("NX-SOTA-PAGE verdict=RED reason=store-disagrees-with-rollup walk=" as *u8); _fn(1, pren)
106 _p("/" as *u8); _fn(1, pre[0]); _p("/" as *u8); _fn(1, pre[1])
107 _p(" rollup=" as *u8); _fn(1, roll[2]); _p("/" as *u8); _fn(1, roll[6]); _p("/" as *u8); _fn(1, roll[7])
108 _p(" -- refusing to write a page whose halves disagree\n" as *u8)
109 sys_exit(104)
110 return 104
111 }
112 let fd: i64 = sys_openat_wr(outp, SP_MODE)
113 if fd < 0 {
114 _p("NX-SOTA-PAGE verdict=RED reason=unwritable path=" as *u8); _p(outp); _p("\n" as *u8)
115 sys_exit(102)
116 return 102
117 }
118 let now: i64 = sys_now_realtime_sec()
119
120 _fp(fd, "<!doctype html><html lang='en'><head><meta charset='utf-8'><meta name='viewport' content='width=device-width,initial-scale=1'><title>Nishi — SOTA, measured</title><style>\n" as *u8)
121 _fp(fd, ":root{--bg:#0b0e14;--pan:#141a24;--ink:#e6edf3;--dim:#8b98a9;--line:#232c3b;--g:#3fb950;--a:#d29922;--r:#f85149;--acc:#58a6ff}\n" as *u8)
122 _fp(fd, "@media(prefers-color-scheme:light){:root{--bg:#fff;--pan:#f6f8fb;--ink:#232936;--dim:#68748a;--line:#dfe4ec;--acc:#1a5dc8}}\n" as *u8)
123 _fp(fd, "*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--ink);font:15px/1.55 system-ui,-apple-system,Segoe UI,sans-serif;font-variant-numeric:tabular-nums}\n" as *u8)
124 _fp(fd, ".wrap{max-width:1060px;margin:0 auto;padding:26px 20px 70px}h1{font-size:25px;margin:0 0 4px;letter-spacing:-.01em}\n" as *u8)
125 _fp(fd, ".sub{color:var(--dim);font-size:13px;max-width:84ch;margin:0 0 6px}\n" as *u8)
126 _fp(fd, "h2{font-size:12px;letter-spacing:.1em;text-transform:uppercase;color:var(--acc);margin:34px 0 10px;border-bottom:1px solid var(--line);padding-bottom:7px}\n" as *u8)
127 _fp(fd, ".kpis{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:12px;margin:16px 0}\n" as *u8)
128 _fp(fd, ".pk{background:var(--pan);border:1px solid var(--line);border-radius:12px;padding:15px 17px}\n" as *u8)
129 _fp(fd, ".pk .lab{font-size:.75em;letter-spacing:.06em;text-transform:uppercase;color:var(--dim)}\n" as *u8)
130 _fp(fd, ".pk .val{font-size:2em;font-weight:700;margin:3px 0}.pk .goal{font-size:.76em;color:var(--dim)}\n" as *u8)
131 _fp(fd, ".scroll{overflow-x:auto}table{width:100%;border-collapse:collapse;font-size:13px;min-width:640px}\n" as *u8)
132 _fp(fd, "th,td{text-align:left;padding:6px 9px;border-bottom:1px solid var(--line);vertical-align:top}\n" as *u8)
133 _fp(fd, "th{color:var(--dim);font-size:11px;text-transform:uppercase;letter-spacing:.04em}td.n{text-align:right;color:var(--dim)}\n" as *u8)
134 _fp(fd, ".bar{height:9px;border-radius:5px;background:var(--line);min-width:90px;position:relative}\n" as *u8)
135 _fp(fd, ".bar>i{position:absolute;left:0;top:0;bottom:0;border-radius:5px;background:var(--g)}\n" as *u8)
136 _fp(fd, ".ev2{color:var(--g)}.ev1{color:var(--a)}.ev3{color:var(--r)}.ev4{color:var(--r)}.ev0{color:var(--dim)}\n" as *u8)
137 _fp(fd, ".nx{color:var(--dim);font-size:12px}.callout{background:var(--pan);border:1px solid var(--line);border-left:3px solid var(--acc);border-radius:8px;padding:12px 15px;margin:12px 0;font-size:13.5px}\n" as *u8)
138 _fp(fd, ".foot{margin-top:40px;padding-top:14px;border-top:1px solid var(--line);color:var(--dim);font-size:12px;line-height:1.7;font-family:ui-monospace,Consolas,monospace}\n" as *u8)
139 _fp(fd, "</style></head><body><div class='wrap'>\n" as *u8)
140
141 _fp(fd, "<h1>SOTA, measured</h1><p class='sub'>Every number on this page is read from the sovereign store and the durable ledger at the moment the page is generated. No human authors this file — the previous hand-written version drifted to a figure that was twelve days stale and pointed the wrong way, which is the whole reason it is generated now.</p>\n" as *u8)
142 _fp(fd, "<p class='sub'>Scope is deliberate. This page owns only what an instrument can measure. The external yardsticks — SWE-bench Verified, DORA, seL4, Vortex 3.0, with the false comparisons <b>refused</b> rather than fudged — are research output a human lane owns, and they live at <a href='/sota-benchmarks' style='color:var(--acc)'>/sota-benchmarks</a>. Borrowing those numbers into a generated page would make them look measured when they are cited.</p>\n" as *u8)
143
144 _fp(fd, "<h2>Ecosystem maturity toward S-class</h2><div class='kpis'>\n" as *u8)
145 _fp(fd, "<div class='pk'><div class='lab'>overall</div><div class='val'>" as *u8); _fn(fd, roll[0]); _fp(fd, "‰</div><div class='goal'>" as *u8)
146 _fn(fd, roll[6]); _fp(fd, " of " as *u8); _fn(fd, roll[7]); _fp(fd, " levels across " as *u8); _fn(fd, roll[2]); _fp(fd, " domains</div></div>\n" as *u8)
147 _fp(fd, "<div class='pk'><div class='lab'>levels earned</div><div class='val'>" as *u8); _fn(fd, roll[6])
148 _fp(fd, "</div><div class='goal'>monotone · rises only when a rung is climbed</div></div>\n" as *u8)
149 _fp(fd, "<div class='pk'><div class='lab'>at S-class</div><div class='val'>" as *u8); _fn(fd, roll[3])
150 _fp(fd, "</div><div class='goal'>of " as *u8); _fn(fd, roll[2]); _fp(fd, " domains</div></div>\n" as *u8)
151 _fp(fd, "<div class='pk'><div class='lab'>triangulated</div><div class='val'>" as *u8); _fn(fd, roll[8])
152 _fp(fd, "</div><div class='goal'>2+ independent sources · " as *u8); _fn(fd, roll[10]); _fp(fd, " single-source, " as *u8); _fn(fd, roll[11]); _fp(fd, " dangling</div></div>\n" as *u8)
153 _fp(fd, "</div>\n" as *u8)
154
155 if trrc == 0 {
156 _fp(fd, "<h2>Is that growth real? — advancement vs expansion</h2>\n" as *u8)
157 _fp(fd, "<div class='callout'>The headline is <code>levels earned / bar</code>, so <b>declaring a new frontier raises the denominator and pushes the percentage DOWN</b> even though nothing regressed. That makes the headline alone directionally misleading, so it is decomposed here. A span where the domain count held still is attributed EXACTLY; a span that added domains cannot be attributed from aggregates and is counted ambiguous rather than quietly claimed.</div>\n" as *u8)
158 _fp(fd, "<div class='kpis'>\n" as *u8)
159 _fp(fd, "<div class='pk'><div class='lab'>advancement (exact)</div><div class='val'>" as *u8); _fn(fd, tr[TRO_ADVANCE])
160 _fp(fd, "</div><div class='goal'>rungs genuinely climbed, over " as *u8); _fn(fd, tr[TRO_STABLE_SPANS]); _fp(fd, " stable-cohort spans</div></div>\n" as *u8)
161 _fp(fd, "<div class='pk'><div class='lab'>expansion</div><div class='val'>+" as *u8); _fn(fd, tr[TRO_EXPAND_BAR])
162 _fp(fd, "</div><div class='goal'>bar added by " as *u8); _fn(fd, tr[TRO_ADDED_DOM]); _fp(fd, " new domains · depresses the headline, adds no capability</div></div>\n" as *u8)
163 _fp(fd, "<div class='pk'><div class='lab'>ambiguous</div><div class='val'>" as *u8); _fn(fd, tr[TRO_AMBIG_CUR])
164 _fp(fd, "</div><div class='goal'>levels the aggregate ledger cannot attribute</div></div>\n" as *u8)
165 _fp(fd, "<div class='pk'><div class='lab'>decomposable</div><div class='val'>" as *u8); _fn(fd, tr[TRO_DECOMP_PERMIL])
166 _fp(fd, "‰</div><div class='goal'>share attributed exactly · rises as the per-domain ledger fills</div></div>\n" as *u8)
167 _fp(fd, "</div>\n" as *u8)
168 _fp(fd, "<p class='sub'>Window: headline " as *u8); _fn(fd, tr[TRO_FIRST_PERMIL]); _fp(fd, "‰ → " as *u8); _fn(fd, tr[TRO_LAST_PERMIL])
169 _fp(fd, "‰ · levels earned " as *u8); _fn(fd, tr[TRO_FIRST_CUR]); _fp(fd, " → " as *u8); _fn(fd, tr[TRO_LAST_CUR])
170 _fp(fd, " · domains " as *u8); _fn(fd, tr[TRO_FIRST_DOM]); _fp(fd, " → " as *u8); _fn(fd, tr[TRO_LAST_DOM])
171 _fp(fd, " · over " as *u8); _fn(fd, tr[TRO_ROWS]); _fp(fd, " measurable ledger rows of " as *u8); _fn(fd, tr[TRO_SCANNED]); _fp(fd, " scanned.</p>\n" as *u8)
172 } else {
173 _fp(fd, "<h2>Advancement vs expansion</h2><div class='callout'>The durable ledger could not be decomposed on this run, so no growth claim is made here. An absent measurement is reported as absent, never as zero.</div>\n" as *u8)
174 }
175
176 let dt: *i64 = sys_mmap(DT_OUT_SLOTS * 8) as *i64
177 let dtrc: i64 = em_domtrend(DT_LOG, dt)
178 if dtrc == 0 {
179 _fp(fd, "<h2>Exact attribution, by name</h2>\n" as *u8)
180 _fp(fd, "<div class='callout'>The section above is bounded by what an <i>aggregate</i> ledger can prove. This one is not. Because the per-domain ledger records which domain held which level at each beat, growth is settled by diffing domains <b>by name</b> — so climbed, declared, demoted and retired are four different things and are counted separately, with nothing left ambiguous.</div>\n" as *u8)
181 _fp(fd, "<div class='kpis'>\n" as *u8)
182 _fp(fd, "<div class='pk'><div class='lab'>climbed</div><div class='val'>" as *u8); _fn(fd, dt[DTO_ADVANCE])
183 _fp(fd, "</div><div class='goal'>levels earned by domains present at both ends · " as *u8); _fn(fd, dt[DTO_COMMON]); _fp(fd, " compared</div></div>\n" as *u8)
184 _fp(fd, "<div class='pk'><div class='lab'>declared</div><div class='val'>" as *u8); _fn(fd, dt[DTO_EXPAND_CUR])
185 _fp(fd, "</div><div class='goal'>levels arriving with " as *u8); _fn(fd, dt[DTO_NEW]); _fp(fd, " new domains · not capability gained</div></div>\n" as *u8)
186 _fp(fd, "<div class='pk'><div class='lab'>retired</div><div class='val'>" as *u8); _fn(fd, dt[DTO_RETIRED_CUR])
187 _fp(fd, "</div><div class='goal'>levels carried out by domains no longer declared</div></div>\n" as *u8)
188 _fp(fd, "<div class='pk'><div class='lab'>attributed</div><div class='val'>" as *u8); _fn(fd, dt[DTO_DECOMP_PERMIL])
189 _fp(fd, "‰</div><div class='goal'>over " as *u8); _fn(fd, dt[DTO_BEATS]); _fp(fd, " per-domain beats</div></div>\n" as *u8)
190 _fp(fd, "</div>\n" as *u8)
191 } else {
192 _fp(fd, "<h2>Exact attribution, by name</h2><div class='callout'>The per-domain ledger does not yet hold two beats, so exact attribution is not claimed here. It begins the moment a second beat lands; until then the bounded aggregate figures above are all that is honestly available.</div>\n" as *u8)
193 }
194
195 // WHAT THE RANKS MEAN, in industry terms. Emitted from nx_rankmap so the page and the organ can
196 // never disagree -- a legend written by hand would drift from the ladder it describes, which is
197 // the same authorable-derived-artifact defect this whole page exists to remove.
198 _fp(fd, "<h2>What the ranks mean</h2>\n" as *u8)
199 _fp(fd, "<div class='callout'>Levels 0-3 describe the <b>capability itself</b>. Levels 4-5 are <b>claims about a comparison</b> against a named best-in-class competitor — a different question entirely, which is why they read oddly beside PRODUCTION. Both map to <b>TRL 9</b>: readiness saturates there and only the comparison differs, so the two axes were never one scale. The industry anchor is <b>TRL 1-9</b> (NASA-origin, DoD procurement, ISO-canonized 2013), which measures readiness and deliberately says nothing about beating a competitor.</div>\n" as *u8)
200 _fp(fd, "<div class='scroll'><table>\n<tr><th>lvl</th><th>this board</th><th>capability graph</th><th>industry (TRL)</th><th>axis</th><th>reachable by a coverage %</th><th>evidence required</th></tr>\n" as *u8)
201 var rl: i64 = 0
202 while rl < MAT_NLEVELS {
203 _fp(fd, "<tr><td class='n'>" as *u8); _fn(fd, rl)
204 _fp(fd, "</td><td><b>" as *u8); _fp(fd, mat_label(rl))
205 _fp(fd, "</b></td><td class='nx'>" as *u8); _fp(fd, rm_capgraph(rl))
206 _fp(fd, "</td><td>" as *u8); _fp(fd, rm_trl(rl))
207 _fp(fd, "</td><td>" as *u8); _fp(fd, rm_axis_label(rm_axis(rl)))
208 if rm_permil_reachable(rl) == 1 { _fp(fd, "</td><td class='nx'>yes</td><td class='nx'>" as *u8) } else { _fp(fd, "</td><td><b>NO</b></td><td class='nx'>" as *u8) }
209 _fp(fd, rm_evidence(rl))
210 _fp(fd, "</td></tr>\n" as *u8)
211 rl = rl + 1
212 }
213 _fp(fd, "</table></div>\n" as *u8)
214 _fp(fd, "<p class='sub'><b>Anti-gaming:</b> no coverage percentage can reach a COMPARATIVE rung. The deriving function is capped at PRODUCTION, and a gate sweeps every input 0-1000 to prove no permil yields level 4 or 5 — those require a named competitor, a stated method and a triangulated verdict, never a number.</p>\n" as *u8)
215
216 _fp(fd, "<h2>Every domain, and the next rung it owes</h2><div class='scroll'><table>\n" as *u8)
217 _fp(fd, "<tr><th>axis</th><th>domain</th><th>now → bar</th><th class='n'>lvl</th><th>progress</th><th>evidence</th><th>next rung</th></tr>\n" as *u8)
218 let nd: i64 = sp_domains(fd, store)
219 _fp(fd, "</table></div>\n" as *u8)
220
221 _fp(fd, "<div class='foot'>generated by nx_sota_page at epoch " as *u8); _fn(fd, now)
222 _fp(fd, " · " as *u8); _fn(fd, nd); _fp(fd, " domain rows emitted\n" as *u8)
223 _fp(fd, "sources: " as *u8); _fp(fd, store); _fp(fd, " (sovereign seg_store) · " as *u8); _fp(fd, ledger); _fp(fd, " (durable ledger)\n" as *u8)
224 _fp(fd, "instruments: nx_ecosystem_maturity_rollup · nx_ecomat_trend (gate 15/15) · nx_ecomat_trend_live (8/8, conservation + triangulation) · nx_ecomat_domledger (7/7, reconciles with this headline)\n" as *u8)
225 _fp(fd, "nothing on this page is hand-written; regenerate any time.</div>\n" as *u8)
226 _fp(fd, "</div></body></html>\n" as *u8)
227 sys_close(fd)
228
229 _p(" wrote " as *u8); _p(outp); _p(" domains=" as *u8); _fn(1, nd)
230 _p(" maturity=" as *u8); _fn(1, roll[0]); _p(" permil advancement=" as *u8); _fn(1, tr[TRO_ADVANCE]); _p("\n" as *u8)
231 // POST-RENDER DRIFT: the table came from a SECOND walk, so evidence logs may have moved between
232 // the tiles and the rows. Re-derive and compare against the pre-flight snapshot -- equal COUNTS
233 // are not enough, the LEVELS must match too. The file exists by now so this cannot un-write it;
234 // it exits non-zero so the separate, deliberate publish step never runs.
235 let post: *i64 = sys_mmap(EDL_SUMS * 8) as *i64
236 let postn: i64 = edl_walk(store, 0 - 1, 0, post)
237 var drift: i64 = 0
238 if postn != pren { drift = 1 }
239 if post[0] != pre[0] { drift = 1 }
240 if post[1] != pre[1] { drift = 1 }
241 if drift == 1 {
242 _p("NX-SOTA-PAGE verdict=RED reason=store-drifted-mid-render -- DO NOT PUBLISH this file\n" as *u8)
243 sys_exit(105)
244 return 105
245 }
246 if nd != roll[2] {
247 _p("NX-SOTA-PAGE verdict=RED reason=domain-count-mismatch (table " as *u8); _fn(1, nd); _p(" vs rollup " as *u8); _fn(1, roll[2]); _p(")\n" as *u8)
248 sys_exit(103)
249 return 103
250 }
251 _p("NX-SOTA-PAGE verdict=GREEN (page regenerated from live instruments)\n" as *u8)
252 sys_exit(0)
253 return 0
254}