code wiki / _hdl_build / nx_viz_exceed.nx
nx_viz_exceed.nx source
↩ module page · 98 lines · 5881 B
1// nx_viz_exceed.nx -- the MEASURED census for the Nishi Visualization Suite vs d3 (the named incumbent), the
2// no-overclaim discipline applied to viz (like nx_wiki_exceed vs MediaWiki). Reads viz_capability_target.tsv
3// (axes = d3's modules, sourced from d3js.org/api), counts HAVE/PARTIAL/MISSING per axis -- ORGAN-COMPUTED,
4// never self-scored -- and prints the HONEST verdict: capability coverage (BEHIND d3 = the worklist), plus the
5// honest EXCEED axes where Nishi wins by construction (sovereignty / self-contained / privacy). The count
6// function vc_count is shared with the gate so the census is reproducibly correct.
7// usage: nx_viz_exceed [target.tsv] (default knowledge/registry/viz_capability_target.tsv)
8// license_tier: ORIGINAL
9import "nx_syscalls.nx"
10import "nx_itoa_lib.nx" // shared MSB-first emitter (zero-alloc)
11
12func vc_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
13// MIGRATED to the shared emitter (debt 1785563586). The old body mmapped a scratch buffer
14// per call and never freed it. At PAGE granularity that is 4096B leaked PER CALL -- the
15// defect that took 28.5GB of a 36GB host in nx_ts_lumadiff (2MB input, ~3.66M calls).
16// nxi_* is MSB-first, allocates NOTHING, and emits identical bytes including the sign.
17func vc_wn(v: i64) -> i64 { nxi_out(v); return 0 }
18func vc_eqn(s: *u8, lit: *u8, slen: i64, litlen: i64) -> i64 {
19 if slen != litlen { return 0 }
20 var i: i64 = 0
21 while i < slen { if (s[i] as i64) != (lit[i] as i64) { return 0 } i = i + 1 }
22 return 1
23}
24// count nishi_state (field 4, 0-based) over the TSV -> counts[0]=HAVE [1]=PARTIAL [2]=MISSING [3]=total.
25func vc_count(buf: *u8, n: i64, counts: *i64) -> i64 {
26 counts[0] = 0; counts[1] = 0; counts[2] = 0; counts[3] = 0
27 var i: i64 = 0
28 while i < n {
29 let start: i64 = i
30 var le: i64 = i; var f: i64 = 1
31 while f == 1 { if le >= n { f = 0 } else { if (buf[le] as i64) == 10 { f = 0 } else { le = le + 1 } } }
32 let end: i64 = le
33 i = end + 1
34 if end > start {
35 if (buf[start] as i64) != 35 {
36 var col: i64 = 0; var fstart: i64 = start; var q: i64 = start
37 var ss: i64 = 0 - 1; var se: i64 = 0 - 1
38 while q <= end {
39 if q == end {
40 if col == 4 { ss = fstart; se = end }
41 q = end + 1
42 } else {
43 if (buf[q] as i64) == 9 {
44 if col == 4 { ss = fstart; se = q }
45 col = col + 1; fstart = q + 1
46 }
47 q = q + 1
48 }
49 }
50 if ss >= 0 {
51 let st: *u8 = ((buf as i64) + ss) as *u8
52 let sl: i64 = se - ss
53 if vc_eqn(st, "HAVE" as *u8, sl, 4) == 1 { counts[0] = counts[0] + 1; counts[3] = counts[3] + 1 }
54 else { if vc_eqn(st, "PARTIAL" as *u8, sl, 7) == 1 { counts[1] = counts[1] + 1; counts[3] = counts[3] + 1 }
55 else { if vc_eqn(st, "MISSING" as *u8, sl, 7) == 1 { counts[2] = counts[2] + 1; counts[3] = counts[3] + 1 } } }
56 }
57 }
58 }
59 }
60 return 0
61}
62
63func main(argc: i64, argv: *i64) -> i64 {
64 var tsv: *u8 = "knowledge/registry/viz_capability_target.tsv" as *u8
65 if argc >= 2 { tsv = argv[1] as *u8 }
66 let lenbox: *i64 = sys_mmap(16) as *i64; lenbox[0] = 0
67 let buf: *u8 = sys_read_file(tsv, lenbox)
68 if (buf as i64) == 0 { sys_write(2, "nx_viz_exceed: cannot read target\n" as *u8, 34); return 1 }
69 let counts: *i64 = sys_mmap(32) as *i64
70 vc_count(buf, lenbox[0], counts)
71 let have: i64 = counts[0]; let part: i64 = counts[1]; let miss: i64 = counts[2]; let tot: i64 = counts[3]
72 var cov: i64 = 0
73 if tot > 0 { cov = (have * 1000 + part * 500) / tot }
74
75 vc_w("=== NISHI VIZ-SUITE EXCEED CENSUS (vs d3, sourced d3js.org/api) ===\n" as *u8)
76 vc_w("axes=" as *u8); vc_wn(tot); vc_w(" HAVE=" as *u8); vc_wn(have); vc_w(" PARTIAL=" as *u8); vc_wn(part); vc_w(" MISSING=" as *u8); vc_wn(miss)
77 vc_w(" coverage=" as *u8); vc_wn(cov); vc_w("permil\n" as *u8)
78 var full: i64 = 0
79 if miss == 0 { if part == 0 { full = 1 } }
80 if full == 0 {
81 vc_w("CAPABILITY VERDICT: BEHIND d3 (honest -- d3 is vastly more capable; coverage is the WORKLIST, build each layer sovereign).\n" as *u8)
82 }
83 if full == 1 {
84 vc_w("CAPABILITY VERDICT: FULL SOVEREIGN AXIS-COVERAGE -- all " as *u8); vc_wn(tot); vc_w(" d3 capability axes now have a KAT-gated, bits-up implementation. HONEST: this is BREADTH (every axis built + gated), NOT depth-parity -- d3 stays DEEPER within axes; this is NOT a claim that Nishi beats d3.\n" as *u8)
85 }
86 vc_w("HONEST EXCEED AXES (Nishi wins BY CONSTRUCTION): sovereignty (bits-up, no 3rd-party JS/d3.js) + self-contained (no CDN/no link-rot) + privacy (no external calls). 3/3.\n" as *u8)
87 if full == 0 {
88 vc_w("WORKLIST (build these layers, measured): " as *u8); vc_wn(miss); vc_w(" MISSING + " as *u8); vc_wn(part); vc_w(" PARTIAL. NOT S-class on capability yet -- and this census SAYS SO.\n" as *u8)
89 }
90 if full == 1 {
91 vc_w("DEPTH REFINEMENTS still open (per-axis, see the evidence column): vector Delaunay (vs raster Voronoi), LAB/LCH colour (vs HSL), object-interpolation, live in-browser WASM harnesses for the interaction axes. Breadth is complete; DEPTH is the ongoing arc. The census still refuses to call this 'beats d3'.\n" as *u8)
92 }
93
94 // integrity self-check: counted states must sum to total
95 if have + part + miss == tot { vc_w("census-integrity OK (HAVE+PARTIAL+MISSING == total)\n" as *u8) }
96 if have + part + miss != tot { vc_w("census-integrity FAIL\n" as *u8); return 2 }
97 return 0
98}