code wiki / _hdl_build / nx_viz_exceed_gate.nx
nx_viz_exceed_gate.nx source
↩ module page · 56 lines · 2901 B
1// nx_viz_exceed_gate.nx -- REFEREE for the viz census: the count must be ORGAN-COMPUTED + honest (no inflation).
2// T1 known fixture -> HAVE=2 PARTIAL=1 MISSING=1 total=4 (counts the nishi_state column correctly)
3// T2 all-MISSING fixture -> coverage=0 (NO false capability-exceed; the negative control)
4// T3 comments-only fixture -> total=0 (# lines + the header are not miscounted)
5// GREEN iff T1..T3. Sovereign: nx_viz_exceed (shared vc_count) + nx_syscalls. license_tier: ORIGINAL
6import "nx_viz_exceed.nx"
7import "nx_syscalls.nx"
8import "nx_gate_verdict.nx"
9
10func g_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
11func g_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
12func g_row(name: *u8, ok: i64) -> i64 {
13 if ok == 1 { g_w(" PASS " as *u8) }
14 if ok != 1 { g_w(" FAIL " as *u8) }
15 g_w(name); g_w("\n" as *u8)
16 return ok
17}
18
19func main() -> i64 {
20 g_w("viz-exceed census gate (organ-computed count; no self-scoring, no inflation)\n" as *u8)
21 let counts: *i64 = sys_mmap(32) as *i64
22 var pass: i64 = 0
23
24 // ---- T1: known mix ----
25 let fix1: *u8 = "# comment line\nb\tt\tm\tc\tHAVE\te\nc\tt\tm\tc\tHAVE\te\nd\tt\tm\tc\tPARTIAL\te\ne\tt\tm\tc\tMISSING\te\n" as *u8
26 vc_count(fix1, g_len(fix1), counts)
27 var t1: i64 = 0
28 if counts[0] == 2 { if counts[1] == 1 { if counts[2] == 1 { if counts[3] == 4 { t1 = 1 } } } }
29 pass = pass + g_row("T1 HAVE=2 PARTIAL=1 MISSING=1 total=4\x00" as *u8, t1)
30
31 // ---- T2: all-MISSING -> coverage 0 (no false exceed) ----
32 let fix2: *u8 = "a\tt\tm\tc\tMISSING\te\nb\tt\tm\tc\tMISSING\te\nc\tt\tm\tc\tMISSING\te\n" as *u8
33 vc_count(fix2, g_len(fix2), counts)
34 var cov: i64 = 0
35 if counts[3] > 0 { cov = (counts[0] * 1000 + counts[1] * 500) / counts[3] }
36 var t2: i64 = 0
37 if counts[2] == 3 { if counts[3] == 3 { if cov == 0 { t2 = 1 } } }
38 pass = pass + g_row("T2 all-MISSING -> coverage=0 (no false exceed)\x00" as *u8, t2)
39
40 // ---- T3: comments-only -> total 0 ----
41 let fix3: *u8 = "# only a comment\n# another comment\n" as *u8
42 vc_count(fix3, g_len(fix3), counts)
43 var t3: i64 = 0
44 if counts[3] == 0 { t3 = 1 }
45 pass = pass + g_row("T3 comments not counted -> total=0\x00" as *u8, t3)
46
47 // MIGRATED onto nx_gate_verdict by nx_gate_dry_apply (D001, minimal form): every check
48 // row above is untouched, so the PASS/FAIL vector cannot change; only the hand-rolled
49 // verdict emission is replaced by the ONE shared base class. Proven by nx_gate_migrate verify.
50 let ctr__dry: *i64 = gv_ctr()
51 ctr__dry[0] = pass
52 ctr__dry[1] = 3
53 let rc__dry: i64 = gv_verdict("VIZ-EXCEED-GATE" as *u8, ctr__dry, "3/3 (census counts honestly; no inflation, no false exceed)" as *u8)
54 sys_exit(rc__dry)
55 return rc__dry
56}