nx_wiki_dashboard.nx source
↩ module page · 219 lines · 14213 B
1// nx_wiki_dashboard.nx -- /wiki/dashboard living-doc view.
2// Per operator cardinal cluster 2026-05-27 + NISHI_PRODUCT_OPS_PLATFORM
3// charter: "capability matrix + bench timeline + silicon-feedback live
4// + capability-to-product map + sovereignty score + eternal-growth
5// runway". V1 ships the matrix + sovereignty score + arc-readiness
6// view; deeper timelines + silicon-feedback live queued V2.
7//
8// COMPOSES:
9// wiki/nx_wiki_index_builder (NxWikiDocStore for indexed doc count)
10// wiki/nx_wiki_doc_render (NxWikiDocCtx writer pattern reused)
11// hub/nx_nishi_page_emit (V1 page format conformance via
12// nx_wiki_doc_write_header_v1)
13//
14// COMPOSED BY:
15// wiki/nx_wiki_routes (closes /wiki/admin/dashboard 501)
16//
17// V1 SCOPE per NISHI_PRODUCT_OPS_PLATFORM ยง3:
18// - Capability matrix (hardcoded list of arc-complete primitives
19// with WINNER tier per NISHIBENCH_WINNER_STANDARD)
20// - Indexed doc count (live from NxWikiDocStore)
21// - Sovereignty score (no external deps audit; V1 manual = 100/100)
22// - Pending V2/V3 queue (next arcs)
23// - Operator-readable HTML; clickable links to /wiki/<each-charter>
24//
25// V2 SCOPE (TODO):
26// - Bench timeline (read from nx_telemetry rolling buffer)
27// - Silicon-feedback live (hot-PC stats from nishi-silicon sim)
28// - Capability-to-product map (config-driven)
29// - Eternal-growth runway (revenue forecast UI; needs revenue data)
30// - JSON API endpoint /wiki/dashboard.json
31//
32// Status: V1. 2026-05-27.
33
34import "nx_syscalls.nx"
35import "wiki/nx_wiki_index_builder.nx"
36import "wiki/nx_wiki_doc_render.nx"
37
38// ===== Sealed verdict surface (codes 2800-2809) =================================================
39const NX_WDB_OK: i64 = 0
40const NX_WDB_BAD_INPUT: i64 = 2800
41const NX_WDB_RENDER_FAILED: i64 = 2801
42const NX_WDB_RESP_OVERFLOW: i64 = 2802
43
44// ===== Named constants (M7) =================================================
45const NX_WDB_RESP_BUF_CAP: i64 = 524288 // 512 KB
46const NX_WDB_SCRATCH_CAP: i64 = 65536 // 64 KB
47const NX_WDB_RENDER_BODY_CAP: i64 = 262144 // 256 KB rendered HTML body
48const NX_WDB_INT_BUF_CAP: i64 = 32
49
50const NX_WDB_DEFAULT_CANONICAL: *u8 = "https://nishifamily.com/wiki/dashboard" as *u8
51const NX_WDB_DEFAULT_CANONICAL_N: i64 = 38
52const NX_WDB_DEFAULT_SUMMARY: *u8 = "Living dashboard for the Nishi sovereign ecosystem. Capability matrix; sovereignty score; arc-readiness queue." as *u8
53const NX_WDB_DEFAULT_SUMMARY_N: i64 = 115
54const NX_WDB_DEFAULT_TAGS: *u8 = "wiki,dashboard,product-ops,sovereignty" as *u8
55const NX_WDB_DEFAULT_TAGS_N: i64 = 38
56const NX_WDB_DEFAULT_LICENSE: *u8 = "nishi-substrate-public" as *u8
57const NX_WDB_DEFAULT_LICENSE_N: i64 = 22
58const NX_WDB_DEFAULT_AUTHOR: *u8 = "elderwesto" as *u8
59const NX_WDB_DEFAULT_AUTHOR_N: i64 = 10
60const NX_WDB_DEFAULT_LAST_MOD: *u8 = "2026-05-27T00:00:00Z" as *u8
61const NX_WDB_DEFAULT_LAST_MOD_N: i64 = 20
62
63// ===== Decimal int helper =================================================
64
65func nx_wdb_int_to_dec(v: i64, out: *u8, cap: i64) -> i64 {
66 if cap < 2 { return 0 }
67 if v == 0 { out[0] = 0x30 as u8; return 1 }
68 var n: i64 = v
69 var neg: i64 = 0
70 if n < 0 { neg = 1; n = 0 - n }
71 let tmp: *u8 = sys_mmap(NX_WDB_INT_BUF_CAP)
72 var k: i64 = 0
73 while n > 0 {
74 if k >= NX_WDB_INT_BUF_CAP - 2 { return 0 }
75 tmp[k] = (0x30 + (n % 10)) as u8
76 n = n / 10; k = k + 1
77 }
78 var off: i64 = 0
79 if neg == 1 { out[off] = 0x2D as u8; off = off + 1 }
80 var j: i64 = k - 1
81 while j >= 0 { out[off] = tmp[j]; off = off + 1; j = j - 1 }
82 return off
83}
84
85// ===== Dashboard body emit =================================================
86//
87// Hand-crafted markdown-equivalent HTML. Bypasses markdown_block since
88// we want clean tables that the spec defines but markdown doesn't render
89// at GFM-table fidelity yet. V2 ships nx_wiki_dashboard via the same
90// markdown path once nx_md_table_gfm primitive is in.
91
92func nx_wdb_emit_body(ctx: *NxWikiDocCtx, store: *NxWikiDocStore) -> i64 {
93 let rc1: i64 = nx_wiki_doc_write_z(ctx, "<h1>Nishi Product-Ops Dashboard V1</h1>\n" as *u8)
94 if rc1 != NX_WIKI_DOC_OK { return rc1 }
95 let rc2: i64 = nx_wiki_doc_write_z(ctx,
96 "<p class=\"informative\">Per <a href=\"/wiki/nishi-product-ops-platform\">NISHI_PRODUCT_OPS_PLATFORM</a> charter. Living doc; updates each daemon restart.</p>\n" as *u8)
97 if rc2 != NX_WIKI_DOC_OK { return rc2 }
98
99 // ----- INDEXED CORPUS -----
100 let rc3: i64 = nx_wiki_doc_write_z(ctx, "<h2>Indexed Corpus</h2>\n<ul>\n" as *u8)
101 if rc3 != NX_WIKI_DOC_OK { return rc3 }
102 let rc4: i64 = nx_wiki_doc_write_z(ctx, "<li>Indexed documents: <b>" as *u8)
103 if rc4 != NX_WIKI_DOC_OK { return rc4 }
104 let count: i64 = nx_wiki_doc_store_count(store)
105 let buf: *u8 = sys_mmap(NX_WDB_INT_BUF_CAP)
106 let bn: i64 = nx_wdb_int_to_dec(count, buf, NX_WDB_INT_BUF_CAP)
107 let rc5: i64 = nx_wiki_doc_write_bytes(ctx, buf, bn)
108 if rc5 != NX_WIKI_DOC_OK { return rc5 }
109 let rc6: i64 = nx_wiki_doc_write_z(ctx,
110 "</b></li>\n<li>Index backend: <code>nx_search_inverted</code> (FNV-1a 64; lowercase + 2..64 char tokens)</li>\n<li>Search engine: <code>nx_search_onsite_engine</code> (V1 TF/AND; V2 BM25F queued)</li>\n<li>Page format: <a href=\"/wiki/nishi-page-format-v1\">NISHI_PAGE_FORMAT_V1</a></li>\n</ul>\n" as *u8)
111 if rc6 != NX_WIKI_DOC_OK { return rc6 }
112
113 // ----- CAPABILITY MATRIX (V1 arc-complete primitives) -----
114 let rc7: i64 = nx_wiki_doc_write_z(ctx, "<h2>Capability Matrix (V1 arc-complete)</h2>\n" as *u8)
115 if rc7 != NX_WIKI_DOC_OK { return rc7 }
116 let rc8: i64 = nx_wiki_doc_write_z(ctx,
117 "<table>\n<thead><tr><th>Capability</th><th>WINNER tier</th><th>Status</th></tr></thead>\n<tbody>\n" as *u8)
118 if rc8 != NX_WIKI_DOC_OK { return rc8 }
119 let rows: *u8 =
120 "<tr><td>Sovereign substrate language (NishiLang)</td><td>WINNER-S</td><td>Self-hosting; off-c arc proven</td></tr>\n<tr><td>Inverted index search</td><td>BASELINE-C</td><td>LIVE via /wiki/search</td></tr>\n<tr><td>Page format spec + validator + emitter</td><td>WINNER-A</td><td>Trinity shipped; cross-validated</td></tr>\n<tr><td>HTTP server stack</td><td>BASELINE-C</td><td>Audit-server pattern; nokeep-close ships</td></tr>\n<tr><td>Admin login auth</td><td>BASELINE-C</td><td>nx_basic_auth + sessions; admin hash file</td></tr>\n<tr><td>Wiki doc render (V1 page format)</td><td>BASELINE-C</td><td>LIVE; click-through from search works</td></tr>\n<tr><td>Markdown block renderer</td><td>BASELINE-C</td><td>Wirth-style block parser; GFM tables queued</td></tr>\n<tr><td>HUB + thin per-site wiring pattern</td><td>WINNER-A</td><td>Search arc proves reusability</td></tr>\n<tr><td>FNV-1a 64 hash</td><td>WINNER-S</td><td>Substrate-wide; sub-ns/byte</td></tr>\n<tr><td>nx_jpeg decoder</td><td>BASELINE-C</td><td>JPEG/T-81 baseline DCT decoder green</td></tr>\n<tr><td>nx_dom_query</td><td>BASELINE-C</td><td>16/16 KAT</td></tr>\n<tr><td>nx_kv_store</td><td>BASELINE-C</td><td>Used by admin sessions + future indexer</td></tr>\n<tr><td>Silicon target (RV64IM-min)</td><td>BASELINE-C</td><td>Simulator + per-PC cycle attribution</td></tr>\n<tr><td>OBD-II shim</td><td>BASELINE-C</td><td>ISO 15765 + Mode 01/03 + 14 PIDs</td></tr>\n<tr><td>Modbus + MQTT shims</td><td>BASELINE-C</td><td>RTU + TCP; MQTT 3.1.1</td></tr>\n</tbody></table>\n" as *u8
121 let rc9: i64 = nx_wiki_doc_write_z(ctx, rows)
122 if rc9 != NX_WIKI_DOC_OK { return rc9 }
123
124 // ----- SOVEREIGNTY SCORE -----
125 let rc10: i64 = nx_wiki_doc_write_z(ctx, "<h2>Sovereignty Score</h2>\n" as *u8)
126 if rc10 != NX_WIKI_DOC_OK { return rc10 }
127 let rc11: i64 = nx_wiki_doc_write_z(ctx,
128 "<p>Per <a href=\"/wiki/nishi-search-charter\">SEARCH_CHARTER</a> + SILICON_SOVEREIGNTY_AUDIT discipline (open-source licensed code is still third-party).</p>\n<table>\n<thead><tr><th>Component</th><th>External deps</th><th>Score</th></tr></thead>\n<tbody>\n<tr><td>nx_search_inverted</td><td>0</td><td>100/100</td></tr>\n<tr><td>nx_search_onsite_engine</td><td>0</td><td>100/100</td></tr>\n<tr><td>hub/nx_search_query_parser</td><td>0</td><td>100/100</td></tr>\n<tr><td>hub/nx_search_render_html</td><td>0</td><td>100/100</td></tr>\n<tr><td>hub/nx_search_handler_flow</td><td>0</td><td>100/100</td></tr>\n<tr><td>hub/nx_nishi_page_validator</td><td>0</td><td>100/100</td></tr>\n<tr><td>hub/nx_nishi_page_emit</td><td>0</td><td>100/100</td></tr>\n<tr><td>hub/nx_html_to_nishi_page</td><td>0</td><td>100/100</td></tr>\n<tr><td>wiki/nx_wiki_index_builder</td><td>0</td><td>100/100</td></tr>\n<tr><td>wiki/nx_wiki_doc_handler</td><td>0</td><td>100/100</td></tr>\n<tr><td>wiki/nx_wiki_dashboard (this doc)</td><td>0</td><td>100/100</td></tr>\n<tr><th>SEARCH ARC TOTAL</th><th>0</th><th>100/100</th></tr>\n</tbody></table>\n" as *u8)
129 if rc11 != NX_WIKI_DOC_OK { return rc11 }
130
131 // ----- PENDING ARCS -----
132 let rc12: i64 = nx_wiki_doc_write_z(ctx, "<h2>Pending Arcs (V2/V3 queue)</h2>\n<ul>\n" as *u8)
133 if rc12 != NX_WIKI_DOC_OK { return rc12 }
134 let rc13: i64 = nx_wiki_doc_write_z(ctx,
135 "<li>V2 BM25F multi-field ranker (exploits nishi-* meta tags)</li>\n<li>V2 boolean operators in query parser (AND/OR/NOT/phrase)</li>\n<li>V2 positional postings in nx_search_inverted (prereq for BM25F)</li>\n<li>V2 sys_getdents directory auto-discover for wiki index</li>\n<li>V2 nx_nishi_page_validator integration in index builder (skip non-conformant)</li>\n<li>V3 offsite engine + crawler (~1150 lines per charter)</li>\n<li>V3 hybrid federated merge (onsite+offsite)</li>\n<li>V4 third-party hosting + ACL</li>\n<li>Archive subsystem (5 modules per <a href=\"/wiki/nishi-archive-integration-charter\">ARCHIVE_INTEGRATION_CHARTER</a>)</li>\n<li>Silicon: gate emitters (5) + nishi-pnr + nishi-bitstream + ULX3S bring-up</li>\n<li>Future: nishi-git sovereign git server (replaces gitea dependency)</li>\n</ul>\n" as *u8)
136 if rc13 != NX_WIKI_DOC_OK { return rc13 }
137
138 // ----- LIVE CARDINALS -----
139 let rc14: i64 = nx_wiki_doc_write_z(ctx, "<h2>Operator Cardinals in Force</h2>\n<ul>\n" as *u8)
140 if rc14 != NX_WIKI_DOC_OK { return rc14 }
141 let rc15: i64 = nx_wiki_doc_write_z(ctx,
142 "<li>NishiLang must EXCEED Rust/C/Python/Java/C++/Elm</li>\n<li>10 hygiene bug classes M1..M10 (no null/magic/overflow/loops/stubs/...)</li>\n<li>HUB primitive + thin per-site wiring (object-oriented reusability cardinal)</li>\n<li>Open-source licensed code IS still third-party (sovereignty)</li>\n<li>Bits up exceed never match</li>\n<li>No link rot as hygiene (archive cardinal)</li>\n<li>S-class docs above IEEE + WINNER-tier capabilities with named incumbents</li>\n<li>Small sharp composable + avoid duplicate primitives</li>\n<li>Defensive at boundaries, trusting internally (Cardinal 12)</li>\n<li>Build intelligence, never strip features (Cardinal 25)</li>\n</ul>\n" as *u8)
143 if rc15 != NX_WIKI_DOC_OK { return rc15 }
144
145 return NX_WDB_OK
146}
147
148// ===== Top-level handler =================================================
149
150func nx_wiki_dashboard_handle(store: *NxWikiDocStore,
151 resp_buf: *u8, resp_cap: i64,
152 out_resp_n: *i64) -> i64 {
153 if (resp_buf as i64) == 0 { return 0 - NX_WDB_BAD_INPUT }
154 if (out_resp_n as i64) == 0 { return 0 - NX_WDB_BAD_INPUT }
155 out_resp_n[0] = 0
156
157 // Allocate render scratch.
158 let render_buf: *u8 = sys_mmap(NX_WDB_RENDER_BODY_CAP)
159 let scratch: *u8 = sys_mmap(NX_WDB_SCRATCH_CAP)
160 let doc_names: *u8 = sys_mmap(4096)
161
162 // Use the daemon's source-bytes as the "doc content" so the V1
163 // header's content-hash is stable across rebuilds with same code.
164 let pseudo_src: *u8 = "nishi-product-ops-dashboard-v1" as *u8
165 let pseudo_src_n: i64 = 30
166
167 let ctx: *NxWikiDocCtx = (sys_mmap(512)) as *NxWikiDocCtx
168 let rc_ci: i64 = nx_wiki_doc_ctx_init(ctx,
169 render_buf, NX_WDB_RENDER_BODY_CAP,
170 pseudo_src, pseudo_src_n,
171 doc_names, 4096, 0,
172 scratch, NX_WDB_SCRATCH_CAP)
173 if rc_ci != NX_WIKI_DOC_OK { return 0 - NX_WDB_RENDER_FAILED }
174
175 let rc_sm: i64 = nx_wiki_doc_ctx_set_meta(ctx,
176 NX_WDB_DEFAULT_CANONICAL, NX_WDB_DEFAULT_CANONICAL_N,
177 NX_WDB_DEFAULT_SUMMARY, NX_WDB_DEFAULT_SUMMARY_N,
178 NX_WDB_DEFAULT_TAGS, NX_WDB_DEFAULT_TAGS_N,
179 NX_WDB_DEFAULT_LICENSE, NX_WDB_DEFAULT_LICENSE_N,
180 NX_WDB_DEFAULT_AUTHOR, NX_WDB_DEFAULT_AUTHOR_N,
181 NX_WDB_DEFAULT_LAST_MOD, NX_WDB_DEFAULT_LAST_MOD_N)
182 if rc_sm != NX_WIKI_DOC_OK { return 0 - NX_WDB_RENDER_FAILED }
183
184 let title: *u8 = "Nishi Product-Ops Dashboard" as *u8
185 let rc_h: i64 = nx_wiki_doc_write_header_v1(ctx, title, 27)
186 if rc_h != NX_WIKI_DOC_OK { return 0 - NX_WDB_RENDER_FAILED }
187
188 let rc_body: i64 = nx_wdb_emit_body(ctx, store)
189 if rc_body != NX_WDB_OK { return rc_body }
190
191 let rc_f: i64 = nx_wiki_doc_write_footer(ctx)
192 if rc_f != NX_WIKI_DOC_OK { return 0 - NX_WDB_RENDER_FAILED }
193
194 let body_len: i64 = ctx.out_off
195
196 // HTTP wrap (same pattern as nx_wiki_doc_handler).
197 let hdr: *u8 = "HTTP/1.1 200 OK\r\nContent-Type: text/html; charset=utf-8\r\nContent-Length: " as *u8
198 let hdr_n: i64 = 71
199 let crlf2: *u8 = "\r\n\r\n" as *u8
200 let len_buf: *u8 = sys_mmap(NX_WDB_INT_BUF_CAP)
201 let ld: i64 = nx_wdb_int_to_dec(body_len, len_buf, NX_WDB_INT_BUF_CAP)
202 let need: i64 = hdr_n + ld + 4 + body_len
203 if need > resp_cap { return 0 - NX_WDB_RESP_OVERFLOW }
204 var off: i64 = 0
205 var i: i64 = 0
206 while i < hdr_n { resp_buf[off + i] = hdr[i]; i = i + 1 }
207 off = off + hdr_n
208 i = 0
209 while i < ld { resp_buf[off + i] = len_buf[i]; i = i + 1 }
210 off = off + ld
211 i = 0
212 while i < 4 { resp_buf[off + i] = crlf2[i]; i = i + 1 }
213 off = off + 4
214 i = 0
215 while i < body_len { resp_buf[off + i] = ctx.out_buf[i]; i = i + 1 }
216 off = off + body_len
217 out_resp_n[0] = off
218 return NX_WDB_OK
219}