code wiki / _hdl_build / nx_user_console.nx

nx_user_console.nx source

↩ module page · 107 lines · 7487 B

1// nx_user_console.nx -- the END-USER CONSOLE (operator 2026-06-09: "getting capabilities in the 2// hands of the end users"). Generates a browser dashboard FROM THE DURABLE LOGS (real data, never 3// narration): latest site-quality score + per-criterion rows, the proof-ledger verdict, the bench 4// verdicts. Output knowledge/site_console.html -- servable HOT by the live sites daemon (drop into 5// the router's content dir = live next request). DOGFOOD LAW: the console page itself must PASS 6// nx_site_quality_gate -- the team's quality bar applies to the team's own UI. license_tier: ORIGINAL 7import "nx_syscalls.nx" 8import "nx_itoa_lib.nx" // shared MSB-first emitter (zero-alloc) 9const K_MAGIC_1048592: i64 = 1048592 10const K_MAGIC_1048576: i64 = 1048576 11func _p(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 12// MIGRATED to the shared emitter (debt 1785563586). The old body mmapped a scratch buffer 13// per call and never freed it. At PAGE granularity that is 4096B leaked PER CALL -- the 14// defect that took 28.5GB of a 36GB host in nx_ts_lumadiff (2MB input, ~3.66M calls). 15// nxi_* is MSB-first, allocates NOTHING, and emits identical bytes including the sign. 16func _pn(v: i64) -> i64 { nxi_out(v); return 0 } 17func _fp(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 } 18func uc_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } 19func uc_read(path: *u8, buf: *u8, cap: i64) -> i64 { 20 let fd: i64 = sys_openat_rd(path) 21 if fd < 0 { return 0 } 22 var total: i64 = 0 23 var go: i64 = 1 24 while go == 1 { 25 let base: i64 = buf as i64 26 let n: i64 = sys_read(fd, (base + total) as *u8, cap - total) 27 if n <= 0 { go = 0 } else { total = total + n } 28 if total >= cap { go = 0 } 29 } 30 sys_close(fd) 31 return total 32} 33// find the LAST line containing pat; write that line to ofd inside <code> (raw log line = the evidence) 34func uc_last_line(ofd: i64, buf: *u8, n: i64, pat: *u8) -> i64 { 35 let pl: i64 = uc_slen(pat) 36 var best: i64 = 0 - 1 37 var i: i64 = 0 38 while i < n { 39 var le: i64 = i 40 while le < n { if buf[le] == (10 as u8) { break } le = le + 1 } 41 var j: i64 = i 42 var hit: i64 = 0 43 while j + pl <= le { var k: i64 = 0; var h2: i64 = 1; while k < pl { if buf[j+k] != pat[k] { h2 = 0; k = pl } else { k = k + 1 } } if h2 == 1 { hit = 1; j = le } else { j = j + 1 } } 44 if hit == 1 { best = i } 45 i = le + 1 46 } 47 if best < 0 { _fp(ofd, "<code>no record yet</code>" as *u8); return 0 } 48 var le2: i64 = best 49 while le2 < n { if buf[le2] == (10 as u8) { break } le2 = le2 + 1 } 50 _fp(ofd, "<code>" as *u8) 51 sys_write(ofd, ((buf as i64) + best) as *u8, le2 - best) 52 _fp(ofd, "</code>" as *u8) 53 return 1 54} 55func main() -> i64 { 56 _p("=== USER CONSOLE: dashboard generated from the durable logs (dogfooded vs the quality gate) ===\n" as *u8) 57 let lb: *u8 = sys_mmap(K_MAGIC_1048592) 58 let ofd: i64 = sys_openat_wr("knowledge/site_console.html.new" as *u8, 0x1a4) 59 if ofd < 0 { sys_exit(1); return 1 } 60 _fp(ofd, "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><title>Nishi Site Console</title>" as *u8) 61 _fp(ofd, "<style>body{font-family:system-ui;margin:0;background:#f6f7f9;color:#16202a}main{max-width:760px;margin:0 auto;padding:1rem}section{background:#fff;border-radius:8px;padding:1rem;margin:1rem 0;box-shadow:0 1px 3px rgba(0,0,0,.08)}code{display:block;overflow-x:auto;background:#0f172a;color:#d7e3f4;padding:.6rem;border-radius:6px;font-size:.8rem}h1{font-size:1.3rem}h2{font-size:1rem}.skip{position:absolute;left:-999px}</style></head><body>" as *u8) 62 _fp(ofd, "<a class=\"skip\" href=\"#main\">Skip to content</a><header><nav aria-label=\"Primary\"><a href=\"/\">Home</a></nav></header><main id=\"main\"><h1>Nishi Site Console</h1><p>Every number below is read from a durable log written by a gate. Nothing on this page is hand-asserted.</p>" as *u8) 63 // sections from the logs 64 _fp(ofd, "<section><h2>Site quality (latest)</h2>" as *u8) 65 var n: i64 = uc_read("knowledge/status/site_quality.log" as *u8, lb, K_MAGIC_1048576) 66 uc_last_line(ofd, lb, n, "SITEQ-SCORE" as *u8) 67 _fp(ofd, "</section><section><h2>Proof ledger (all claims)</h2>" as *u8) 68 n = uc_read("knowledge/status/proof_ledger.log" as *u8, lb, K_MAGIC_1048576) 69 uc_last_line(ofd, lb, n, "PROOF " as *u8) 70 _fp(ofd, "</section><section><h2>Benchmark verdicts</h2>" as *u8) 71 n = uc_read("knowledge/status/synth_bench.log" as *u8, lb, K_MAGIC_1048576) 72 uc_last_line(ofd, lb, n, "EXCEED" as *u8) 73 _fp(ofd, "</section><section><h2>Security posture</h2>" as *u8) 74 n = uc_read("knowledge/status/security_status.log" as *u8, lb, K_MAGIC_1048576) 75 uc_last_line(ofd, lb, n, "SECSTATUS " as *u8) 76 _fp(ofd, "</section><section><h2>Claude-use trend</h2>" as *u8) 77 n = uc_read("knowledge/status/claude_meter.log" as *u8, lb, K_MAGIC_1048576) 78 uc_last_line(ofd, lb, n, "METER " as *u8) 79 _fp(ofd, "</section><section><h2>Team autonomy (role scorecard totals)</h2>" as *u8) 80 n = uc_read("knowledge/status/role_scorecard.log" as *u8, lb, K_MAGIC_1048576) 81 uc_last_line(ofd, lb, n, "SCORECARD-TOTALS" as *u8) 82 _fp(ofd, "</section><section><h2>Executive sponsor -- marching order and outcomes</h2><p>The Conductor's pick, the Warden's last attempt, and the raised-hand batch (tutor + co-spec fuel).</p>" as *u8) 83 n = uc_read("knowledge/status/assign_next.log" as *u8, lb, K_MAGIC_1048576) 84 uc_last_line(ofd, lb, n, "ASSIGNNEXT " as *u8) 85 uc_last_line(ofd, lb, n, "ASSIGNRESULT " as *u8) 86 uc_last_line(ofd, lb, n, "RAISEDHANDS " as *u8) 87 _fp(ofd, "</section><section><h2>Executive sponsor -- decisions and co-spec queue</h2><p>Read-only evidence: decisions move ONLY via the authenticated intake (X-I3) or the repo decision file; every reason is captured as training signal.</p>" as *u8) 88 n = uc_read("knowledge/status/sponsor_review.log" as *u8, lb, K_MAGIC_1048576) 89 uc_last_line(ofd, lb, n, "SPONSOR applied=" as *u8) 90 uc_last_line(ofd, lb, n, "SPONSOR-SPEC " as *u8) 91 _fp(ofd, "</section><section><h2>Executive callouts</h2>" as *u8) 92 n = uc_read("knowledge/registry/callouts.tsv" as *u8, lb, K_MAGIC_1048576) 93 uc_last_line(ofd, lb, n, "CALLOUT-" as *u8) 94 _fp(ofd, "</section><section><h2>System triage (running / crashed / recoverable)</h2>" as *u8) 95 n = uc_read("knowledge/status/system_triage.log" as *u8, lb, K_MAGIC_1048576) 96 uc_last_line(ofd, lb, n, "TRIAGE " as *u8) 97 _fp(ofd, "</section><section><h2>Conductor heartbeat (self-running loop)</h2>" as *u8) 98 n = uc_read("knowledge/status/pulse_daemon.log" as *u8, lb, K_MAGIC_1048576) 99 uc_last_line(ofd, lb, n, "DAEMON-BEAT " as *u8) 100 _fp(ofd, "</section><section><h2>Re-prove everything</h2><p>One command re-runs every grader: <code>_offc/nx_sov_build_run.elf nx_prove_all</code></p></section>" as *u8) 101 _fp(ofd, "</main><footer><p style=\"text-align:center;color:#5a6b7d\">Nishi team console -- generated from logs, gated by nx_site_quality_gate</p></footer></body></html>" as *u8) 102 sys_close(ofd) 103 sys_renameat("knowledge/site_console.html.new" as *u8, "knowledge/site_console.html" as *u8) 104 _p(" console written: knowledge/site_console.html (atomic)\n" as *u8) 105 sys_exit(0) 106 return 0 107}