code wiki / _hdl_build / nx_critic_test.nx
nx_critic_test.nx source
↩ module page · 45 lines · 3627 B
1// nx_critic_test.nx -- the Critic evaluates real beliefs the team holds, and MUST catch the one we
2// leaned on without a red-team (PSNR=image-quality, refuted by Blau-Michaeli) -- demoting it while
3// blessing genuinely robust ones, and ALWAYS keeping every verdict provisional. Exit 0 if all hold.
4// license_tier: ORIGINAL
5
6import "nx_critic.nx"
7import "nx_syscalls.nx"
8
9func ct_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
10func ct_num(v: i64) -> i64 { let bb: *u8 = sys_mmap(28); var m: i64=v; if m<0 {m=0-m}; let t: *u8 = sys_mmap(28); var k: i64=0; if m==0 {t[0]=48;k=1}; while m>0 {t[k]=48+(m%10); m=m/10; k=k+1}; var i: i64=0; while i<k {bb[i]=t[k-1-i]; i=i+1}; sys_write(1, bb, k); return 0 }
11func ct_st(s: i64) -> i64 { if s==CRIT_LAW {ct_puts("LAW " as *u8)} if s==CRIT_THEORY {ct_puts("THEORY " as *u8)} if s==CRIT_REFUTED {ct_puts("REFUTED " as *u8)} return 0 }
12
13func main() -> i64 {
14 ct_puts("=== NISHI CRITIC: scientific evaluation -- nothing is gospel ===\n" as *u8)
15 // belief, (reproductions, counters, redteamed)
16 // B0: "PSNR/MSE measures generation quality" -- widely used (3), BUT Blau-Michaeli rate-distortion-
17 // perception is a surviving counter (1), and we have NOW red-teamed it (1) -> REFUTED.
18 let b0: i64 = crit_status(3, 1, 1)
19 // B1: "single-batch decode is memory-bandwidth bound" -- many independent papers (5), no surviving
20 // counter (0), red-teamed (1) -> LAW (still provisional, regime-bound to small batch).
21 let b1: i64 = crit_status(5, 0, 1)
22 // B2: our nx_image_fidelity ASSUMPTION as we shipped it (pre-catch): used (1), never red-teamed (0)
23 // -> THEORY + BLIND SPOT (the mistake the operator caught).
24 let b2: i64 = crit_status(1, 0, 0)
25 // B3: the NEW belief "fidelity needs distortion AND perception" -- reproduced (2), no counter (0),
26 // red-teamed (1) -> LAW (provisional, the current successor to B0).
27 let b3: i64 = crit_status(2, 0, 1)
28
29 ct_puts(" B0 PSNR=quality -> " as *u8); ct_st(b0); ct_puts(" act-conf=" as *u8); ct_num(crit_act_confidence(3,1,1)); ct_puts("\n" as *u8)
30 ct_puts(" B1 decode mem-bound -> " as *u8); ct_st(b1); ct_puts(" act-conf=" as *u8); ct_num(crit_act_confidence(5,0,1)); ct_puts("\n" as *u8)
31 ct_puts(" B2 our fidelity(ship)-> " as *u8); ct_st(b2); ct_puts(" blindspot=" as *u8); ct_num(crit_is_blindspot(1,0)); ct_puts("\n" as *u8)
32 ct_puts(" B3 distortion+percep -> " as *u8); ct_st(b3); ct_puts(" act-conf=" as *u8); ct_num(crit_act_confidence(2,0,1)); ct_puts("\n" as *u8)
33
34 let r: *i64 = sys_mmap(8*8) as *i64
35 r[0] = 0; if b0 == CRIT_REFUTED { r[0] = 1 } // caught the PSNR error
36 r[1] = 0; if b1 == CRIT_LAW { r[1] = 1 } // blessed the robust one
37 r[2] = 0; if b2 == CRIT_THEORY { if crit_is_blindspot(1,0) == 1 { r[2] = 1 } } // flagged the blind spot
38 r[3] = 0; if b3 == CRIT_LAW { r[3] = 1 } // the successor is current-best
39 r[4] = 0; if crit_is_provisional(b1) == 1 { if crit_keeps_successor_slot(b1) == 1 { r[4] = 1 } } // even a LAW is provisional + successor-open
40 var pass: i64 = 0; var i: i64 = 0
41 while i < 5 { pass = pass + r[i]; i = i + 1 }
42 ct_puts("----\n passed " as *u8); ct_num(pass); ct_puts("/5\n" as *u8)
43 if pass == 5 { ct_puts(" CRITIC LIVE: PSNR demoted by counter-theory, robust laws blessed (still provisional), blind spots flagged. No gospel.\n" as *u8); sys_exit(0); return 0 }
44 ct_puts(" FAIL\n" as *u8); sys_exit(1); return 1
45}