code wiki / _hdl_build / nx_page_verify_gate.nx
nx_page_verify_gate.nx source
↩ module page · 92 lines · 5198 B
1// nx_page_verify_gate.nx -- proves the browser-grade page verifier END-TO-END on the REAL edge: the fixed
2// /render3d page must be GREEN (exit 0), and the PERMANENT negctl fixture (sites/nishifamily/render3d/negctl.html:
3// a .png that answers HTML + a relative ref) must be RED with EXACTLY 2 broken -- the two classes that caused the
4// 2026-07-16 "the pngs are broken" incident. If the negctl leg ever passes, the verifier lost its teeth.
5// license_tier: ORIGINAL expect_exit: 0
6import "nx_syscalls.nx"
7
8func hw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
9func pn(v: i64) -> i64 { let t: *u8=sys_mmap(24); var m: i64=v; if m<0{sys_write(1,"-" as *u8,1);m=0-m} var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} let b: *u8=sys_mmap(24); var j: i64=0; while j<k{b[j]=t[k-1-j];j=j+1} sys_write(1,b,k); return 0 }
10
11func run1(elf: *u8, a1: *u8) -> i64 {
12 let pid: i64 = sys_fork()
13 if pid == 0 {
14 let argv: *i64 = sys_mmap(32) as *i64
15 argv[0]=elf as i64; argv[1]=a1 as i64; argv[2]=0
16 let envp: *i64 = sys_mmap(16) as *i64
17 envp[0]=0
18 // quiet: the gate judges EXIT CODES; the CLI's own runs remain the verbose surface
19 sys_execve(elf, argv, envp)
20 sys_exit(127)
21 }
22 let st: *i64 = sys_mmap(16) as *i64
23 sys_wait4(pid, st, 0)
24 let sig: i64 = st[0] & 0x7f
25 if sig != 0 { return 128 + sig }
26 return (st[0] >> 8) & 0xff
27}
28
29func run2(elf: *u8, a1: *u8, a2: *u8) -> i64 {
30 let pid: i64 = sys_fork()
31 if pid == 0 {
32 let argv: *i64 = sys_mmap(32) as *i64
33 argv[0]=elf as i64; argv[1]=a1 as i64; argv[2]=a2 as i64; argv[3]=0
34 let envp: *i64 = sys_mmap(16) as *i64
35 envp[0]=0
36 sys_execve(elf, argv, envp)
37 sys_exit(127)
38 }
39 let st: *i64 = sys_mmap(16) as *i64
40 sys_wait4(pid, st, 0)
41 let sig: i64 = st[0] & 0x7f
42 if sig != 0 { return 128 + sig }
43 return (st[0] >> 8) & 0xff
44}
45
46func main() -> i64 {
47 hw("=== nx_page_verify_gate -- the verifier's teeth, proven on the live edge ===\n" as *u8)
48 var fails: i64 = 0
49 let elf: *u8 = "/tmp/nx_page_verify.sov.elf" as *u8
50
51 let rc1: i64 = run1(elf, "https://nishifamily.com/render3d" as *u8)
52 hw(" /render3d exit=" as *u8); pn(rc1); hw("\n" as *u8)
53 var t1: i64 = 0
54 if rc1 == 0 { t1 = 1 }
55 if t1 == 1 { hw("T1 PASS the fixed page is GREEN (all assets fetch + decode)\n" as *u8) } else { fails=fails+1; hw("T1 FAIL page broken or verifier RED\n" as *u8) }
56
57 let rc2: i64 = run1(elf, "https://nishifamily.com/render3d/negctl.html" as *u8)
58 hw(" negctl exit=" as *u8); pn(rc2); hw("\n" as *u8)
59 var t2: i64 = 0
60 if rc2 == 2 { t2 = 1 }
61 if t2 == 1 { hw("T2 PASS neg-control: BOTH broken classes detected (png-answers-HTML + relative-ref law) -- the verifier has teeth\n" as *u8) } else { fails=fails+1; hw("T2 FAIL negctl did not report exactly 2 broken\n" as *u8) }
62
63 // ---- seq911: THE ROOT-FALLBACK BLIND SPOT, now a permanent neg-control ----------------
64 // The edge answers 200 with the site ROOT for any unknown path. Every asset on it fetches
65 // and decodes, so the asset-only verdict said GREEN while the page you published had
66 // landed nowhere. Measured 2026-07-25 on /research/rt004.html (835-byte root served, a
67 // 10201-byte page published nowhere). These three legs pin the fix permanently.
68 let ghost: *u8 = "https://nishifamily.com/definitely-not-a-page-seq911.html" as *u8
69 let want: *u8 = "expect=Five Rejected Hypotheses" as *u8
70
71 let rc3: i64 = run1(elf, ghost)
72 hw(" ghost-path (no assertion) exit=" as *u8); pn(rc3); hw("\n" as *u8)
73 var t3: i64 = 0
74 if rc3 == 0 { t3 = 1 }
75 if t3 == 1 { hw("T3 PASS the OLD blindness is real+reproducible: a nonexistent path is GREEN with no content assertion\n" as *u8) } else { fails=fails+1; hw("T3 FAIL ghost path did not return GREEN -- the neg-control is no longer meaningful, re-derive it\n" as *u8) }
76
77 let rc4: i64 = run2(elf, ghost, want)
78 hw(" ghost-path (expect=) exit=" as *u8); pn(rc4); hw("\n" as *u8)
79 var t4: i64 = 0
80 if rc4 == 1 { t4 = 1 }
81 if t4 == 1 { hw("T4 PASS NEG-CONTROL: the SAME 200 is now RED because the expected content is absent -- a 200 is not your page\n" as *u8) } else { fails=fails+1; hw("T4 FAIL the fallback page still passes a content assertion\n" as *u8) }
82
83 let rc5: i64 = run2(elf, "https://nishifamily.com/rt004.html" as *u8, want)
84 hw(" real page (expect=) exit=" as *u8); pn(rc5); hw("\n" as *u8)
85 var t5: i64 = 0
86 if rc5 == 0 { t5 = 1 }
87 if t5 == 1 { hw("T5 PASS NON-VACUITY: the REAL page passes the SAME assertion, so expect= is not a blanket refusal\n" as *u8) } else { fails=fails+1; hw("T5 FAIL the real page failed its own content assertion\n" as *u8) }
88
89 if fails == 0 { hw("NX-PAGE-VERIFY verdict=GREEN -- browser-grade live verification is load-bearing (status-200 alone can NEVER pass a broken page again, and a 200 for the WRONG page can never pass a content assertion)\n" as *u8); sys_exit(0); return 0 }
90 hw("NX-PAGE-VERIFY verdict=RED fails=" as *u8); pn(fails); hw("\n" as *u8)
91 sys_exit(1); return 1
92}