code wiki / _hdl_build / nx_biotwin_board_gate.nx
nx_biotwin_board_gate.nx source
↩ module page · 165 lines · 9033 B
1// nx_biotwin_board_gate.nx -- the LIAR-KILL gate for nx_biotwin_board.
2//
3// A board that grades a MEDICAL domain is worse than useless if it can rubber-stamp itself, because the
4// failure mode is not an embarrassing number -- it is a credibility claim attached to a human body.
5// Teeth:
6// T1 PROVENANCE -- the COU-0 verdicts must be COPIED FROM A REAL SIBLING ORGAN, not invented.
7// nx_graphics_board.nx must exist AND must itself carry the axes/artifacts we cite from it. This is
8// the anti-fabrication tooth: it makes it impossible to grade ourselves against a made-up baseline.
9// T2 EVIDENCE EXISTS -- every artifact attached to a HAVE/PARTIAL is stat'd on disk. A verdict
10// with a missing artifact is a lie.
11// T3 NEG-CONTROL -- a fabricated artifact path must NOT exist, or T2 could pass by accident.
12// T4 THE FENCE IS ALIVE -- the clamp, the fence tiers, and the PLANTED LIE on axis 21 must all still
13// be in the source. Delete any one and the safety property silently becomes a promise instead of a
14// construction, which is exactly what rule 26 forbids.
15// T5 HONESTY CANNOT ROT -- the deflation, the terminal science blocker, and the law-collision block
16// must still be published. If a later edit quietly deletes them so the numbers read like a green
17// light, this gate goes RED.
18// T6 NO SILENT SCOPE CREEP -- all three COU-4 actuation axes must still be present AND hard-fenced.
19// license_tier: ORIGINAL expect_exit: 0
20import "nx_syscalls.nx"
21
22func gw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
23func gn(v: i64) -> i64 {
24 if v==0 { sys_write(1,"0" as *u8,1); return 0 }
25 var m: i64=v; if m<0 { sys_write(1,"-" as *u8,1); m=0-m }
26 let t: *u8=sys_mmap(32); var k: i64=0
27 while m>0 { t[k]=(48+(m%10)) as u8; m=m/10; k=k+1 }
28 let o: *u8=sys_mmap(32); var q: i64=k-1; var i: i64=0
29 while q>=0 { o[i]=t[q]; i=i+1; q=q-1 }
30 sys_write(1,o,i); return 0
31}
32func fsize(p: *u8) -> i64 {
33 let lenp: *i64 = sys_mmap(8) as *i64
34 lenp[0] = 0
35 let b: *u8 = sys_read_file(p, lenp)
36 if (b as i64) == 0 { return 0-1 }
37 return lenp[0]
38}
39func match_at(buf: *u8, n: i64, i: i64, pat: *u8) -> i64 {
40 var j: i64 = 0
41 while pat[j] != (0 as u8) { if i+j >= n { return 0 } if buf[i+j] != pat[j] { return 0 } j=j+1 }
42 return 1
43}
44func contains(buf: *u8, n: i64, pat: *u8) -> i64 {
45 var i: i64 = 0
46 while i < n { if match_at(buf,n,i,pat)==1 { return 1 } i=i+1 }
47 return 0
48}
49
50func main() -> i64 {
51 gw("=== nx_biotwin_board_gate: is the twin board real, or a rubber stamp on a medical claim? ===\n\n")
52 var pass: i64 = 0
53 var checks: i64 = 0
54
55 // ---------- T1: provenance -- our COU-0 verdicts came from a real sibling organ ----------
56 checks = checks + 1
57 let glen: *i64 = sys_mmap(8) as *i64
58 glen[0] = 0
59 let gsrc: *u8 = sys_read_file("runtime/_hdl_build/nx_graphics_board.nx" as *u8, glen)
60 if (gsrc as i64) == 0 {
61 gw("T1 RED sibling organ absent: runtime/_hdl_build/nx_graphics_board.nx -- COU-0 verdicts unprovenanced\n")
62 } else {
63 var p1: i64 = contains(gsrc, glen[0], "internal-anatomy-render" as *u8)
64 var p2: i64 = contains(gsrc, glen[0], "nishi_being_walk.glb" as *u8)
65 var p3: i64 = contains(gsrc, glen[0], "nx_sdfbody.png" as *u8)
66 if p1==1 { if p2==1 { if p3==1 {
67 gw("T1 GREEN provenance: all 3 cited COU-0 axes/artifacts are present in nx_graphics_board (not invented)\n")
68 pass = pass + 1
69 } } }
70 if p1==0 { gw("T1 RED nx_graphics_board does not carry internal-anatomy-render\n") }
71 if p2==0 { gw("T1 RED nx_graphics_board does not carry nishi_being_walk.glb\n") }
72 if p3==0 { gw("T1 RED nx_graphics_board does not carry nx_sdfbody.png\n") }
73 }
74
75 // ---------- T2: every artifact attached to a non-GAP verdict exists on disk ----------
76 checks = checks + 1
77 var amiss: i64 = 0
78 var atot: i64 = 0
79 atot=atot+1; if fsize("knowledge/nx_bunny.png" as *u8) < 0 { amiss=amiss+1; gw(" ARTIFACT MISSING: knowledge/nx_bunny.png\n") }
80 atot=atot+1; if fsize("knowledge/nx_sdfbody.png" as *u8) < 0 { amiss=amiss+1; gw(" ARTIFACT MISSING: knowledge/nx_sdfbody.png\n") }
81 atot=atot+1; if fsize("knowledge/nishi_being_walk.glb" as *u8) < 0 { amiss=amiss+1; gw(" ARTIFACT MISSING: knowledge/nishi_being_walk.glb\n") }
82 atot=atot+1; if fsize("knowledge/nx_gx_sss_skin.png" as *u8) < 0 { amiss=amiss+1; gw(" ARTIFACT MISSING: knowledge/nx_gx_sss_skin.png\n") }
83 atot=atot+1; if fsize("knowledge/nx_gx8_ssao.png" as *u8) < 0 { amiss=amiss+1; gw(" ARTIFACT MISSING: knowledge/nx_gx8_ssao.png\n") }
84 atot=atot+1; if fsize("knowledge/nx_biotwin_morphometrics.json" as *u8) < 0 { amiss=amiss+1; gw(" ARTIFACT MISSING: knowledge/nx_biotwin_morphometrics.json\n") }
85 if amiss == 0 {
86 gw("T2 GREEN all "); gn(atot); gw(" evidence artifacts exist on disk\n")
87 pass = pass + 1
88 } else {
89 gw("T2 RED "); gn(amiss); gw("/"); gn(atot); gw(" claimed artifacts MISSING -- a verdict without evidence is a lie\n")
90 }
91
92 // ---------- T3: neg-control -- the stat check must be able to FAIL ----------
93 checks = checks + 1
94 if fsize("knowledge/nx_biotwin_FABRICATED_neg_control.png" as *u8) < 0 {
95 gw("T3 GREEN neg-control absent as required (T2 is a real check, not a rubber stamp)\n")
96 pass = pass + 1
97 } else {
98 gw("T3 RED neg-control artifact EXISTS -- the artifact check cannot be trusted\n")
99 }
100
101 // ---------- read the board source once for T4/T5/T6 ----------
102 let blen: *i64 = sys_mmap(8) as *i64
103 blen[0] = 0
104 let bsrc: *u8 = sys_read_file("runtime/_hdl_build/nx_biotwin_board.nx" as *u8, blen)
105 let bn: i64 = blen[0]
106
107 // ---------- T4: the fence is a live construction, not a comment ----------
108 checks = checks + 1
109 if (bsrc as i64) == 0 {
110 gw("T4 RED cannot read the board source to verify the fence\n")
111 } else {
112 // the clamp itself, the hard-fence tier, and the PLANTED LIE that proves the clamp fires
113 var f1: i64 = contains(bsrc, bn, "fence_blocked = fence_blocked + 1" as *u8)
114 var f2: i64 = contains(bsrc, bn, "axfn[21]=2" as *u8)
115 var f3: i64 = contains(bsrc, bn, "axcl[21]=2" as *u8)
116 var f4: i64 = contains(bsrc, bn, "HARD-FENCED-BY-LAW" as *u8)
117 if f1==1 { if f2==1 { if f3==1 { if f4==1 {
118 gw("T4 GREEN fence alive: clamp + hard-fence tier + planted-lie neg-control all present\n")
119 pass = pass + 1
120 } } } }
121 if f1==0 { gw("T4 RED the fence CLAMP was removed -- fenced axes can now score above GAP\n") }
122 if f2==0 { gw("T4 RED axis 21 is no longer hard-fenced\n") }
123 if f3==0 { gw("T4 RED the PLANTED LIE was removed -- the fence is no longer proven at runtime\n") }
124 if f4==0 { gw("T4 RED the HARD-FENCED-BY-LAW verdict string was removed\n") }
125 }
126
127 // ---------- T5: honesty cannot rot ----------
128 checks = checks + 1
129 if (bsrc as i64) == 0 {
130 gw("T5 RED cannot read the board source to verify the honesty blocks\n")
131 } else {
132 var h1: i64 = contains(bsrc, bn, "terminal_blocker" as *u8)
133 var h2: i64 = contains(bsrc, bn, "law_collisions" as *u8)
134 var h3: i64 = contains(bsrc, bn, "may inform a decision about a real person" as *u8)
135 if h1==1 { if h2==1 { if h3==1 {
136 gw("T5 GREEN honesty intact: terminal_blocker + law_collisions + the no-real-person deflation all published\n")
137 pass = pass + 1
138 } } }
139 if h1==0 { gw("T5 RED the terminal science blocker was removed from the board\n") }
140 if h2==0 { gw("T5 RED the law_collisions block was removed from the board\n") }
141 if h3==0 { gw("T5 RED the no-real-person deflation was removed from the board\n") }
142 }
143
144 // ---------- T6: no silent scope creep at COU-4 ----------
145 checks = checks + 1
146 if (bsrc as i64) == 0 {
147 gw("T6 RED cannot read the board source to verify COU-4 scope\n")
148 } else {
149 var s1: i64 = contains(bsrc, bn, "genomic-target-inference" as *u8)
150 var s2: i64 = contains(bsrc, bn, "edit-or-vector-design-emission" as *u8)
151 var s3: i64 = contains(bsrc, bn, "wetlab-or-patient-actuation" as *u8)
152 if s1==1 { if s2==1 { if s3==1 {
153 gw("T6 GREEN all 3 COU-4 actuation axes still declared and fenced (no silent scope creep)\n")
154 pass = pass + 1
155 } } }
156 if s1==0 { gw("T6 RED genomic-target-inference axis was deleted rather than fenced\n") }
157 if s2==0 { gw("T6 RED edit-or-vector-design-emission axis was deleted rather than fenced\n") }
158 if s3==0 { gw("T6 RED wetlab-or-patient-actuation axis was deleted rather than fenced\n") }
159 }
160
161 gw("\n=== nx_biotwin_board_gate "); gn(pass); gw("/"); gn(checks)
162 if pass == checks { gw(" GREEN ===\n"); return 0 }
163 gw(" RED ===\n")
164 return 1
165}