code wiki / _hdl_build / nx_vsbench_gate.nx

nx_vsbench_gate.nx source

↩ module page · 161 lines · 8914 B

1// nx_vsbench_gate.nx -- certifies the head-to-head VS-board (F1148, eats seq1004's second half: 2// the live board NAMED this gate for weeks while it existed nowhere -- a gate that is prose is not a gate). 3// 4// TEETH (each one earned by a defect this lane actually hit): 5// T1 ANTI-FABRICATION: every Tier-3 EXT cell's OURS and THEIRS artifacts exist on disk with REAL 6// bytes (>= a floor; the nx_bunny decoy law -- existence alone is foolable by a blank). 7// T2 HONESTY-CANNOT-ROT: the board source still carries the contract strings (EXT-only headline, 8// UNGROUNDED-on-zero, HYPOTHESIS-NOT-CLAIM) -- the strings that keep declarations from scoring. 9// T3 DERIVED-NOT-FROZEN: the per-title emit must NOT contain the hardcoded "cells_ext":0 literal -- 10// the exact regression that shipped: headline said ext=2 while Breeders' row said NOT-RUN. 11// T4 TIER DISCIPLINE: every cell declaration carries an explicit ctier assignment on its line. 12// T5 NEG-CONTROL: a fabricated evidence path must be ABSENT (T1 is a check, not a rubber stamp). 13// license_tier: ORIGINAL expect_exit: 0 14import "nx_syscalls.nx" 15import "nx_gate_verdict.nx" 16const VG_MAGIC_2026: i64 = 2026 17 18const VG_ART_FLOOR: i64 = 500000 // NXFH1 400x240 is 576254B; half-uploaded evidence must fail 19 20func pw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 21func pn(v: i64) -> i64 { 22 if v==0 { sys_write(1,"0" as *u8,1); return 0 } 23 var m: i64=v; if m<0 { sys_write(1,"-" as *u8,1); m=0-m } 24 let t: *u8=sys_mmap(32); var k: i64=0 25 while m>0 { t[k]=(48+(m%10)) as u8; m=m/10; k=k+1 } 26 let o: *u8=sys_mmap(32); var q: i64=k-1; var i: i64=0 27 while q>=0 { o[i]=t[q]; i=i+1; q=q-1 } 28 sys_write(1,o,i); return 0 29} 30func line_g(nm: *u8) -> i64 { pw(" " as *u8); pw(nm as *u8); pw(" GREEN\n" as *u8); return 0 } 31func line_r(nm: *u8) -> i64 { pw(" " as *u8); pw(nm as *u8); pw(" RED\n" as *u8); return 0 } 32 33func fsize(p: *u8) -> i64 { 34 let lenp: *i64 = sys_mmap(8) as *i64 35 lenp[0]=0 36 let b: *u8 = sys_read_file(p, lenp) 37 if (b as i64)==0 { return 0-1 } 38 return lenp[0] 39} 40 41// does needle occur in hay[0..n)? 42func has(hay: *u8, n: i64, needle: *u8) -> i64 { 43 var nl: i64=0 44 while needle[nl]!=(0 as u8) { nl=nl+1 } 45 if nl==0 { return 1 } 46 var i: i64=0 47 while i+nl<=n { 48 var k: i64=0 49 var ok: i64=1 50 while k<nl { if hay[i+k]!=needle[k] { ok=0; k=nl } else { k=k+1 } } 51 if ok==1 { return 1 } 52 i=i+1 53 } 54 return 0 55} 56// count occurrences of needle in hay[0..n) 57func cnt(hay: *u8, n: i64, needle: *u8) -> i64 { 58 var nl: i64=0 59 while needle[nl]!=(0 as u8) { nl=nl+1 } 60 var c: i64=0 61 var i: i64=0 62 while i+nl<=n { 63 var k: i64=0 64 var ok: i64=1 65 while k<nl { if hay[i+k]!=needle[k] { ok=0; k=nl } else { k=k+1 } } 66 if ok==1 { c=c+1 } 67 i=i+1 68 } 69 return c 70} 71 72func main() -> i64 { 73 pw("=== nx_vsbench_gate: is the head-to-head board REAL, or self-flattery? ===\n\n" as *u8) 74 var pass: i64 = 0 75 76 // ---- T1 anti-fabrication: EXT evidence on disk with real bytes ---- 77 let a1: i64 = fsize("knowledge/ours_m1.nxfh" as *u8) 78 let a2: i64 = fsize("knowledge/breeders1.nxfh" as *u8) 79 let a3: i64 = fsize("knowledge/veloren1.nxfh" as *u8) 80 let a4: i64 = fsize("knowledge/nx_m2d_frame.nxfh" as *u8) // the EXCEED cell's OURS 81 // F1147 sweep artifacts: every BEHIND cell's evidence is floored too -- losses must be as 82 // regression-proof as wins, or the board can be flattered by quietly dropping bad cells. 83 let a5: i64 = fsize("knowledge/ref_madisland.nxfh" as *u8) 84 let a6: i64 = fsize("knowledge/ref_carnal.nxfh" as *u8) 85 let a7: i64 = fsize("knowledge/ref_dik.nxfh" as *u8) 86 let a8: i64 = fsize("knowledge/ref_vrhot.nxfh" as *u8) 87 // F1147 completion 2026-08-09: the last four refs, floored the day their cells landed. 88 let a9: i64 = fsize("knowledge/mgi1.nxfh" as *u8) 89 let a10: i64 = fsize("knowledge/oplc1.nxfh" as *u8) 90 let a11: i64 = fsize("knowledge/cm3d21.nxfh" as *u8) 91 let a12: i64 = fsize("knowledge/vam1.nxfh" as *u8) 92 // 2026-08-09 re-pair: the OURS artifact is the live NISHI CRAFT frame -- floored like all the rest. 93 let a13: i64 = fsize("knowledge/craft1.nxfh" as *u8) 94 var t1: i64 = 0 95 if a1 >= VG_ART_FLOOR { if a2 >= VG_ART_FLOOR { if a3 >= VG_ART_FLOOR { if a4 >= VG_ART_FLOOR { 96 if a5 >= VG_ART_FLOOR { if a6 >= VG_ART_FLOOR { if a7 >= VG_ART_FLOOR { if a8 >= VG_ART_FLOOR { 97 if a9 >= VG_ART_FLOOR { if a10 >= VG_ART_FLOOR { if a11 >= VG_ART_FLOOR { if a12 >= VG_ART_FLOOR { 98 if a13 >= VG_ART_FLOOR { 99 t1=1 } } } } } } } } } } } } } 100 if t1==1 { pass=pass+1; line_g("T1 anti-fabrication: all EXT-cell artifacts on disk with real bytes" as *u8) } 101 if t1==0 { line_r("T1 anti-fabrication: all EXT-cell artifacts on disk with real bytes" as *u8) } 102 pw(" ours_m1=" as *u8); pn(a1); pw(" breeders1=" as *u8); pn(a2) 103 pw(" veloren1=" as *u8); pn(a3); pw(" m2d_frame=" as *u8); pn(a4) 104 pw(" floor=" as *u8); pn(VG_ART_FLOOR); pw("\n" as *u8) 105 pw(" mgi1=" as *u8); pn(a9); pw(" oplc1=" as *u8); pn(a10) 106 pw(" cm3d21=" as *u8); pn(a11); pw(" vam1=" as *u8); pn(a12) 107 pw(" craft1=" as *u8); pn(a13); pw("\n" as *u8) 108 109 // ---- source-text teeth (the board's declarations are the SSOT under test) ---- 110 let lenp: *i64 = sys_mmap(8) as *i64 111 lenp[0]=0 112 var src: *u8 = sys_read_file("buildroot/runtime/_hdl_build/nx_vsbench.nx" as *u8, lenp) 113 if (src as i64)==0 { src = sys_read_file("runtime/_hdl_build/nx_vsbench.nx" as *u8, lenp) } 114 let n: i64 = lenp[0] 115 var t2: i64 = 0 116 var t3: i64 = 0 117 var t4: i64 = 0 118 if (src as i64)!=0 { 119 // T2 the honesty contract strings must survive every refactor 120 if has(src,n,"TIER-3 EXT cells ONLY" as *u8)==1 { 121 if has(src,n,"UNGROUNDED" as *u8)==1 { 122 if has(src,n,"HYPOTHESIS-NOT-CLAIM" as *u8)==1 { t2=1 } } } 123 // T3 the frozen-row regression can never ship again 124 if has(src,n,"\x22cells_ext\x22:0,\x22headtohead\x22" as *u8)==0 { t3=1 } 125 // T4 tier discipline: every cell DECLARATION line ends "ctier[i]=VS_TIER_x; ncell=k" -- so the 126 // count of "; ncell=" bumps must equal the count of "]=VS_TIER_" assignments. (First version 127 // counted raw "ctier[" refs and matched tally-loop READS too -- a tooth premise the gate's own 128 // RED corrected. Counting the declaration idiom, not the identifier.) 129 let ndecl: i64 = cnt(src,n,"; ncell=" as *u8) 130 let ntier: i64 = cnt(src,n,"]=VS_TIER_" as *u8) 131 if ndecl == ntier { if ndecl >= 2 { t4=1 } } // >=2 live cells = non-vacuous 132 pw(" src=" as *u8); pn(n); pw("B cell-decls=" as *u8); pn(ndecl) 133 pw(" tier-assigns=" as *u8); pn(ntier); pw("\n" as *u8) 134 } 135 if t2==1 { pass=pass+1; line_g("T2 honesty-cannot-rot: EXT-only + UNGROUNDED + HYPOTHESIS-NOT-CLAIM intact" as *u8) } 136 if t2==0 { line_r("T2 honesty-cannot-rot: EXT-only + UNGROUNDED + HYPOTHESIS-NOT-CLAIM intact" as *u8) } 137 if t3==1 { pass=pass+1; line_g("T3 derived-not-frozen: the hardcoded per-title row literal is GONE" as *u8) } 138 if t3==0 { line_r("T3 derived-not-frozen: the hardcoded per-title row literal is GONE" as *u8) } 139 if t4==1 { pass=pass+1; line_g("T4 tier discipline: every cell declaration carries a tier assignment" as *u8) } 140 if t4==0 { line_r("T4 tier discipline: every cell declaration carries a tier assignment" as *u8) } 141 142 // ---- T5 neg-control: a fabricated evidence file must be ABSENT ---- 143 // < 1 not < 0: nx_fs_write cannot delete, so a de-planted control is a 0-byte husk -- and an 144 // empty file carries no fabricated evidence. Content is what the tooth guards against. 145 let ng: i64 = fsize("knowledge/vsbench_fabricated_negcontrol.nxfh" as *u8) 146 var t5: i64 = 0 147 if ng < 1 { t5=1 } 148 if t5==1 { pass=pass+1; line_g("T5 neg-control: the fabricated-evidence path is absent (T1 has teeth)" as *u8) } 149 if t5==0 { line_r("T5 neg-control: the fabricated-evidence path is absent (T1 has teeth)" as *u8) } 150 151 pw("\n=== nx_vsbench_gate " as *u8); pn(pass); pw("/5 " as *u8) 152 // MIGRATED onto nx_gate_verdict by nx_gate_dry_apply (D001, minimal form): every check 153 // row above is untouched, so the PASS/FAIL vector cannot change; only the hand-rolled 154 // verdict emission is replaced by the ONE shared base class. Proven by nx_gate_migrate verify. 155 let ctr__dry: *i64 = gv_ctr() 156 ctr__dry[0] = pass 157 ctr__dry[1] = 5 158 let rc__dry: i64 = gv_verdict("VSBENCH-GATE" as *u8, ctr__dry, "teeth unchanged; verdict emission migrated onto the shared base class" as *u8) 159 sys_exit(rc__dry) 160 return rc__dry 161}