code wiki / _hdl_build / nx_gamebench_gate.nx

nx_gamebench_gate.nx source

↩ module page · 364 lines · 22489 B

1import "nx_gate_gn.nx" 2import "nx_gate_base.nx" 3// nx_gamebench_gate.nx -- the LIAR-KILL gate for nx_gamebench. A benchmark that grades us is worthless 4// unless something can prove it is not a rubber stamp. Teeth: 5// T1 the RULER IS REAL -- the ingested corpus file exists and carries >=100 catalogued rows. 6// T2 the TITLES ARE FROM THE RULER -- every reference repo we benchmark is literally present in the 7// ingested catalog. This is the anti-fabrication tooth: it makes it impossible to benchmark against 8// an invented game, which is the whole failure mode of a self-authored ruler. 9// T3 EVERY CLAIMED ARTIFACT EXISTS -- each evidence artifact the board attaches to a HAVE is stat'd on 10// disk. A verdict with a missing artifact is a lie and fails the gate. 11// T4 NEG-CONTROL -- a fabricated artifact path must NOT exist. Without this, T3 could pass by 12// accident (e.g. if the stat helper always returned success) and the gate would be a rubber stamp. 13// T5 HONESTY CANNOT ROT -- the board source must still carry the SELF-GRADED/SUSPECT deflation. If a 14// later edit quietly deletes the caveat so the numbers read like parity, this gate goes RED. 15// T6 WIRED MASKS ARE MEASURED, NOT ASSERTED -- for every WIRED-PARTS-LOOP title the wiring artifact 16// must exist, parse as NXSV, carry payload[0] == the mask this gate expects, be a strict SUBSET of 17// the title's required-capability vector (you cannot "exercise" a capability the title does not 18// require), and the board source must declare EXACTLY that mask. Board, gate and artifact are three 19// independent copies -- inflating any one of them goes RED. 20// T7 WIRED NEG-CONTROL -- an UNWIRED title must have NO wiring artifact on disk. Wiring a new title 21// without flipping the board (or fabricating an artifact) fails loud until both move together. 22// license_tier: ORIGINAL expect_exit: 0 23import "nx_syscalls.nx" 24const GB_MAGIC_5000: i64 = 5000 25 26// expected wired masks (bit = capability index in nx_gamebench.nx): 27// NetHack bits 3,7,6,9,11,15,18 = 297672 28// Diablo II bits 0,3,10,9,6,16,15,18 = 362057 29// EndlessSky bits 0,21,12,19,9,16,15,18 = 2986497 (was FULLY WIRED before bit 25 joined its req vector) 30// REQ vectors updated 2026-07-29 (seq304/354/359): every title now ALSO requires bit 25 31// asset-pipeline-import (the 10-slot mk() truncation squeezed it out of every vector). Each REQ below 32// = the board's mka(mk(...),25) value; exercised masks are UNCHANGED (no wiring claimed for bit 25), 33// so wired titles honestly drop -- required-but-unexercised scores at most PARTIAL. 34// minimum bytes for a render artifact to count as real content (seq813 decoy law: existence alone is 35// foolable by a failing producer writing a blank) 36const GB_ART_MIN_RENDER: i64 = 50000 37const GB_NH_MASK: i64 = 297672 38const GB_NH_REQ: i64 = 33868488 39const GB_D2_MASK: i64 = 362057 40const GB_D2_REQ: i64 = 34047689 41const GB_ES_MASK: i64 = 2986497 42const GB_ES_REQ: i64 = 36540929 43 44// seq789 FIX: the board source sits under buildroot/ when the gate runs from ~/nishihost and under 45// runtime/ when it runs from the source tree, so a single relative path can never resolve from both. 46// Try every root -> the gate is CWD-independent. 47func read_board(lenp: *i64) -> *u8 { 48 lenp[0] = 0 49 var b: *u8 = sys_read_file("runtime/_hdl_build/nx_gamebench.nx" as *u8, lenp) 50 if (b as i64) != 0 { return b } 51 lenp[0] = 0 52 b = sys_read_file("buildroot/runtime/_hdl_build/nx_gamebench.nx" as *u8, lenp) 53 if (b as i64) != 0 { return b } 54 lenp[0] = 0 55 b = sys_read_file("_hdl_build/nx_gamebench.nx" as *u8, lenp) 56 if (b as i64) != 0 { return b } 57 lenp[0] = 0 58 return sys_read_file("/volume1/homes/elderwesto/nishihost/buildroot/runtime/_hdl_build/nx_gamebench.nx" as *u8, lenp) 59} 60func grow(name: *u8, ok: i64) -> i64 { if ok==1 { gw(" PASS " as *u8) } else { gw(" FAIL " as *u8) } gw(name); gw(" 61" as *u8); return ok } 62// does a file exist (and how many bytes)? -1 = absent 63func fsize(p: *u8) -> i64 { 64 let lenp: *i64 = sys_mmap(8) as *i64 65 lenp[0] = 0 66 let b: *u8 = sys_read_file(p, lenp) 67 if (b as i64) == 0 { return 0-1 } 68 return lenp[0] 69} 70func match_at(buf: *u8, n: i64, i: i64, pat: *u8) -> i64 { 71 var j: i64 = 0 72 while pat[j] != (0 as u8) { if i+j >= n { return 0 } if buf[i+j] != pat[j] { return 0 } j=j+1 } 73 return 1 74} 75func contains(buf: *u8, n: i64, pat: *u8) -> i64 { 76 var i: i64 = 0 77 while i < n { if match_at(buf,n,i,pat)==1 { return 1 } i=i+1 } 78 return 0 79} 80func countlines(buf: *u8, n: i64) -> i64 { 81 var i: i64=0; var c: i64=0 82 while i<n { if buf[i]==(10 as u8) { c=c+1 } i=i+1 } 83 return c 84} 85func rd64(b: *u8, off: i64) -> i64 { 86 var v: i64=0; var i: i64=7 87 while i>=0 { v = (v*256) + (b[off+i] as i64); i=i-1 } 88 return v 89} 90// verify ONE wired title: artifact exists + NXSV magic + payload[0]==want + want subset-of req. 91// returns 1 good, else prints why and returns 0. 92func wired_ok(path: *u8, want: i64, req: i64) -> i64 { 93 let lenp: *i64 = sys_mmap(8) as *i64 94 lenp[0]=0 95 let b: *u8 = sys_read_file(path, lenp) 96 if (b as i64)==0 { gw(" WIRED-ARTIFACT MISSING: "); gw(path); gw("\n"); return 0 } 97 if lenp[0] < 56 { gw(" WIRED-ARTIFACT TOO SHORT: "); gw(path); gw("\n"); return 0 } 98 var magic: i64=0 99 if b[0]==(78 as u8) { if b[1]==(88 as u8) { if b[2]==(83 as u8) { if b[3]==(86 as u8) { magic=1 } } } } 100 if magic==0 { gw(" WIRED-ARTIFACT BAD MAGIC: "); gw(path); gw("\n"); return 0 } 101 let got: i64 = rd64(b, 48) 102 if got != want { 103 gw(" WIRED-MASK MISMATCH "); gw(path); gw(": artifact="); gn(got) 104 gw(" gate-expects="); gn(want); gw("\n") 105 return 0 106 } 107 if (want & req) != want { 108 gw(" WIRED-MASK NOT A SUBSET of the required vector: "); gw(path); gw("\n") 109 return 0 110 } 111 return 1 112} 113 114func main() -> i64 { 115 gw("=== nx_gamebench_gate: is the game benchmark REAL, or a rubber stamp? ===\n\n") 116 var pass: i64 = 0 117 var checks: i64 = 0 118 119 // ---------- T1: the ruler is a real ingested corpus ---------- 120 checks = checks + 1 121 let rulerp: *u8 = "knowledge/store/nx_game_catalog.reg" as *u8 122 let lenp: *i64 = sys_mmap(8) as *i64 123 lenp[0] = 0 124 let rbuf: *u8 = sys_read_file(rulerp, lenp) 125 var rrows: i64 = 0 126 if (rbuf as i64) == 0 { 127 gw("T1 RED ruler absent: knowledge/store/nx_game_catalog.reg (run nx_game_ingest + nx_game_catalog)\n") 128 } else { 129 rrows = countlines(rbuf, lenp[0]) 130 if rrows >= 100 { 131 gw("T1 GREEN ruler REAL: nx_game_catalog.reg rows="); gn(rrows); gw(" bytes="); gn(lenp[0]); gw("\n") 132 pass = pass + 1 133 } else { 134 gw("T1 RED ruler too small rows="); gn(rrows); gw(" (expected >=100)\n") 135 } 136 } 137 138 // ---------- T2: every benchmarked title is literally in the ingested catalog ---------- 139 // (anti-fabrication: we cannot benchmark against a game we did not ingest) 140 checks = checks + 1 141 var found: i64 = 0 142 var wanted: i64 = 5 143 if (rbuf as i64) != 0 { 144 let rn: i64 = lenp[0] 145 if contains(rbuf, rn, "id-Software/DOOM" as *u8)==1 { found=found+1 } else { gw(" MISSING in corpus: id-Software/DOOM\n") } 146 if contains(rbuf, rn, "OpenXcom/OpenXcom" as *u8)==1 { found=found+1 } else { gw(" MISSING in corpus: OpenXcom/OpenXcom\n") } 147 if contains(rbuf, rn, "OpenDiablo2/OpenDiablo2" as *u8)==1 { found=found+1 } else { gw(" MISSING in corpus: OpenDiablo2/OpenDiablo2\n") } 148 if contains(rbuf, rn, "CleverRaven/Cataclysm-DDA" as *u8)==1 { found=found+1 } else { gw(" MISSING in corpus: CleverRaven/Cataclysm-DDA\n") } 149 if contains(rbuf, rn, "veloren/veloren" as *u8)==1 { found=found+1 } else { gw(" MISSING in corpus: veloren/veloren\n") } 150 } 151 if found == wanted { 152 gw("T2 GREEN all "); gn(wanted); gw(" benchmarked reference repos are present in the ingested corpus (not invented)\n") 153 pass = pass + 1 154 } else { 155 gw("T2 RED only "); gn(found); gw("/"); gn(wanted); gw(" benchmarked repos found in the corpus\n") 156 } 157 158 // ---------- T3: every artifact attached to a HAVE verdict exists on disk ---------- 159 checks = checks + 1 160 var amiss: i64 = 0 161 var atot: i64 = 0 162 atot=atot+1; if fsize("knowledge/nx_game_shmup.png" as *u8) < 1 { amiss=amiss+1; gw(" ARTIFACT MISSING: knowledge/nx_game_shmup.png\n") } 163 // 2026-07-29 (seq788 residue): gx4_walk_t0/t3 are gone from the hub; render-3d evidence follows the 164 // board to gx31_ctl.png with a non-vacuity floor (seq813 decoy law); the t3 input row is dropped 165 // because input-realtime is demoted to PARTIAL on the board until a real artifact is re-banked. 166 atot=atot+1; if fsize("knowledge/gx31_ctl.png" as *u8) < GB_ART_MIN_RENDER { amiss=amiss+1; gw(" ARTIFACT MISSING/DECOY: knowledge/gx31_ctl.png (need real render bytes >= GB_ART_MIN_RENDER)\n") } 167 // 2026-07-30 render-fps-camera flip: native first-person DDA frame, held to the render floor 168 atot=atot+1; if fsize("knowledge/nx_wasm_craft_start.png" as *u8) < GB_ART_MIN_RENDER { amiss=amiss+1; gw(" ARTIFACT MISSING/DECOY: knowledge/nx_wasm_craft_start.png (run nx_wasm_craft_gate; need a real fps frame)\n") } 169 // 2026-07-26: path follows the BOARD (procgen evidence = nx_worldpipe.png, emitted by the GREEN 170 // nx_worldpipe_gate T8 -- the retired nx_procgen_terrain.png had NO producer in the tree). And the 171 // tooth is now NON-VACUOUS per the seq813 decoy law: existence alone is foolable by a failing 172 // producer writing a blank; require real content bytes. 173 atot=atot+1; if fsize("knowledge/nx_worldpipe.png" as *u8) < GB_ART_MIN_RENDER { amiss=amiss+1; gw(" ARTIFACT MISSING/DECOY: knowledge/nx_worldpipe.png (need real render bytes >= GB_ART_MIN_RENDER)\n") } 174 atot=atot+1; if fsize("knowledge/nx_game_td.png" as *u8) < 1 { amiss=amiss+1; gw(" ARTIFACT MISSING: knowledge/nx_game_td.png\n") } 175 atot=atot+1; if fsize("knowledge/nx_game_tbs.png" as *u8) < 1 { amiss=amiss+1; gw(" ARTIFACT MISSING: knowledge/nx_game_tbs.png\n") } 176 atot=atot+1; if fsize("knowledge/nx_game_city.png" as *u8) < 1 { amiss=amiss+1; gw(" ARTIFACT MISSING: knowledge/nx_game_city.png\n") } 177 atot=atot+1; if fsize("knowledge/nx_game_adventure.png" as *u8) < 1 { amiss=amiss+1; gw(" ARTIFACT MISSING: knowledge/nx_game_adventure.png\n") } 178 atot=atot+1; if fsize("knowledge/nx_game_tycoon.png" as *u8) < 1 { amiss=amiss+1; gw(" ARTIFACT MISSING: knowledge/nx_game_tycoon.png\n") } 179 atot=atot+1; if fsize("knowledge/nx_game_sandbox.png" as *u8) < 1 { amiss=amiss+1; gw(" ARTIFACT MISSING: knowledge/nx_game_sandbox.png\n") } 180 // seq813: bunny was the original decoy case -- hold it to the render floor forever. 181 atot=atot+1; if fsize("knowledge/nx_bunny.png" as *u8) < GB_ART_MIN_RENDER { amiss=amiss+1; gw(" ARTIFACT MISSING/DECOY: knowledge/nx_bunny.png (need real render bytes >= GB_ART_MIN_RENDER)\n") } 182 atot=atot+1; if fsize("knowledge/nx_collide2d_traj.sav" as *u8) < 56 { amiss=amiss+1; gw(" ARTIFACT MISSING: knowledge/nx_collide2d_traj.sav (run nx_collide2d_gate)\n") } 183 // seq813 law: a composed VN scene must carry real content bytes, not a bare-gradient decoy 184 atot=atot+1; if fsize("knowledge/nx_vnsprite_scene.png" as *u8) < GB_MAGIC_5000 { amiss=amiss+1; gw(" ARTIFACT MISSING/DECOY: knowledge/nx_vnsprite_scene.png (run nx_vnsprite_gate; need a real composed scene)\n") } 185 // input-realtime receipt = the FULL 9/9 output of the certified input gate, not a stub 186 atot=atot+1; if fsize("knowledge/nx_input_gate_receipt.txt" as *u8) < 200 { amiss=amiss+1; gw(" ARTIFACT MISSING/DECOY: knowledge/nx_input_gate_receipt.txt (re-run nx_input_abstract_gate GREEN)\n") } 187 atot=atot+1; if fsize("knowledge/nx_gamesave_t.sav" as *u8) < 1 { amiss=amiss+1; gw(" ARTIFACT MISSING: knowledge/nx_gamesave_t.sav (run nx_gamesave_gate)\n") } 188 atot=atot+1; if fsize("knowledge/nx_rpgstats_char.sav" as *u8) < 1 { amiss=amiss+1; gw(" ARTIFACT MISSING: knowledge/nx_rpgstats_char.sav (run nx_rpgstats_gate)\n") } 189 atot=atot+1; if fsize("knowledge/nx_entity_world.sav" as *u8) < 1 { amiss=amiss+1; gw(" ARTIFACT MISSING: knowledge/nx_entity_world.sav (run nx_entity_store_gate)\n") } 190 atot=atot+1; if fsize("knowledge/nx_gamemusic.wav" as *u8) < 1 { amiss=amiss+1; gw(" ARTIFACT MISSING: knowledge/nx_gamemusic.wav (run nx_gamemusic_gate)\n") } 191 atot=atot+1; if fsize("knowledge/sfx_demo.wav" as *u8) < 1 { amiss=amiss+1; gw(" ARTIFACT MISSING: knowledge/sfx_demo.wav (run nx_game_audio_gate)\n") } 192 atot=atot+1; if fsize("knowledge/nx_worldsim_world.sav" as *u8) < 1 { amiss=amiss+1; gw(" ARTIFACT MISSING: knowledge/nx_worldsim_world.sav (run nx_worldsim_gate)\n") } 193 atot=atot+1; if fsize("knowledge/nx_plotgen_story.sav" as *u8) < 1 { amiss=amiss+1; gw(" ARTIFACT MISSING: knowledge/nx_plotgen_story.sav (run nx_plotgen_gate)\n") } 194 atot=atot+1; if fsize("knowledge/nx_loottable_item.sav" as *u8) < 1 { amiss=amiss+1; gw(" ARTIFACT MISSING: knowledge/nx_loottable_item.sav (run nx_loottable_gate)\n") } 195 // 2026-07-30 networking-multiplayer flip: netcode session save (NXSV, >=56B header+payload floor) 196 atot=atot+1; if fsize("knowledge/nx_netsync_session.sav" as *u8) < 56 { amiss=amiss+1; gw(" ARTIFACT MISSING: knowledge/nx_netsync_session.sav (run nx_netsync_gate)\n") } 197 // 2026-07-30 voxel-world-chunked flip: whole chunked-world session save (NXSV, >=56B floor) 198 atot=atot+1; if fsize("knowledge/nx_voxchunk_world.sav" as *u8) < 56 { amiss=amiss+1; gw(" ARTIFACT MISSING: knowledge/nx_voxchunk_world.sav (run nx_voxchunk_gate)\n") } 199 atot=atot+1; if fsize("knowledge/nx_wardrobe_state.sav" as *u8) < 1 { amiss=amiss+1; gw(" ARTIFACT MISSING: knowledge/nx_wardrobe_state.sav (run nx_wardrobe_state_gate)\n") } 200 atot=atot+1; if fsize("knowledge/nx_wardrobe_adultgate.txt" as *u8) < 1 { amiss=amiss+1; gw(" ARTIFACT MISSING: knowledge/nx_wardrobe_adultgate.txt (run nx_wardrobe_state_gate)\n") } 201 if amiss == 0 { 202 gw("T3 GREEN all "); gn(atot); gw(" HAVE-evidence artifacts exist on disk\n") 203 pass = pass + 1 204 } else { 205 gw("T3 RED "); gn(amiss); gw("/"); gn(atot); gw(" claimed evidence artifacts are MISSING -- a HAVE without evidence is a lie\n") 206 } 207 208 // ---------- T4: neg-control -- the stat check must be able to FAIL ---------- 209 checks = checks + 1 210 let negp: *u8 = "knowledge/nx_gamebench_FABRICATED_neg_control.png" as *u8 211 if fsize(negp) < 0 { 212 gw("T4 GREEN neg-control absent as required (T3 is a real check, not a rubber stamp)\n") 213 pass = pass + 1 214 } else { 215 gw("T4 RED neg-control artifact EXISTS -- the artifact check cannot be trusted\n") 216 } 217 218 // ---------- T5: the honesty caveat cannot rot out of the board ---------- 219 checks = checks + 1 220 let blen: *i64 = sys_mmap(8) as *i64 221 blen[0] = 0 222 let bsrc: *u8 = read_board(blen) 223 if (bsrc as i64) == 0 { 224 gw("T5 RED cannot read the board source to verify the honesty caveat\n") 225 } else { 226 var h1: i64 = contains(bsrc, blen[0], "SELF-GRADED" as *u8) 227 var h2: i64 = contains(bsrc, blen[0], "SUSPECT" as *u8) 228 var h3: i64 = contains(bsrc, blen[0], "ruler_gaps" as *u8) 229 if h1==1 { if h2==1 { if h3==1 { 230 gw("T5 GREEN honesty intact: SELF-GRADED + SUSPECT + ruler_gaps all still published\n") 231 pass = pass + 1 232 } } } 233 if pass < checks { 234 if h1==0 { gw("T5 RED the SELF-GRADED deflation was removed from the board\n") } 235 if h2==0 { if h1==1 { gw("T5 RED the SUSPECT deflation was removed from the board\n") } } 236 if h3==0 { if h1==1 { if h2==1 { gw("T5 RED ruler_gaps (the honest ruler-incompleteness block) was removed\n") } } } 237 } 238 } 239 240 // ---------- T6: wired masks are measured (artifact == gate == board source), subsets of required ---------- 241 checks = checks + 1 242 var t6: i64=0 243 let w1: i64 = wired_ok("knowledge/nx_wire_nethack.sav" as *u8, GB_NH_MASK, GB_NH_REQ) 244 let w2: i64 = wired_ok("knowledge/nx_wire_diablo2.sav" as *u8, GB_D2_MASK, GB_D2_REQ) 245 let w3: i64 = wired_ok("knowledge/nx_wire_endlesssky.sav" as *u8, GB_ES_MASK, GB_ES_REQ) 246 var bsync: i64=0 247 if (bsrc as i64) != 0 { 248 // seq789 FIX: a no-magic-numbers refactor hoisted these masks into K_MAGIC_* consts, which 249 // silently DISARMED this cross-check (it only knew the literal form). Accept either spelling -- 250 // but for the const form ALSO require the const declaration to bind the exact value, so the 251 // three-way pin (artifact == gate == board) is restored, not loosened. 252 var s1: i64 = contains(bsrc, blen[0], "ttwm[7]=297672" as *u8) 253 if s1==0 { if contains(bsrc, blen[0], "ttwm[7]=K_MAGIC_297672" as *u8)==1 { s1=1 } } 254 var s2: i64 = contains(bsrc, blen[0], "ttwm[2]=362057" as *u8) 255 if s2==0 { if contains(bsrc, blen[0], "ttwm[2]=K_MAGIC_362057" as *u8)==1 { s2=1 } } 256 var s3: i64 = contains(bsrc, blen[0], "ttwm[9]=2986497" as *u8) 257 if s3==0 { if contains(bsrc, blen[0], "ttwm[9]=K_MAGIC_2986497" as *u8)==1 { s3=1 } } 258 if s1==1 { if s2==1 { if s3==1 { bsync=1 } } } 259 } 260 if w1==1 { if w2==1 { if w3==1 { if bsync==1 { 261 gw("T6 GREEN wired masks MEASURED: 3 wiring artifacts parse, masks match the gate AND the board\n") 262 gw(" source declarations AND are subsets of each title's required vector (297672/362057/2986497)\n") 263 t6=1; pass = pass + 1 264 } } } } 265 if t6==0 { 266 gw("T6 RED wired-mask verification failed: art-ok="); gn(w1); gn(w2); gn(w3) 267 gw(" board-sync="); gn(bsync); gw(" -- a wired grade without a matching measured mask is a lie\n") 268 } 269 270 // ---------- T7: wired neg-control -- an unwired title must have NO wiring artifact ---------- 271 checks = checks + 1 272 if fsize("knowledge/nx_wire_doom.sav" as *u8) < 0 { 273 gw("T7 GREEN wired neg-control absent (Doom is not wired and carries no wiring artifact)\n") 274 pass = pass + 1 275 } else { 276 gw("T7 RED knowledge/nx_wire_doom.sav EXISTS but the board does not declare Doom wired --\n") 277 gw(" either a fabricated artifact or an undeclared wiring; board+gate must move together\n") 278 } 279 280 // ---------- T8: AUTO-DISCOVERY -- every HAVE row in the BOARD SOURCE must name an artifact that exists ---------- 281 // (2026-07-30, seq1307: T3 above is a hand-maintained list, so a board flip whose author forgets the 282 // matching gate edit silently escapes the liar-killer -- proven twice in one day. This tooth parses the 283 // board source itself: every capv[i]=2 assignment must be followed by a capev[i]="<path>" whose file 284 // exists on disk; a HAVE with capev=0 is RED. Anti-vacuity: the parser must find >=20 HAVE rows or the 285 // tooth FAILS rather than passing on an empty parse. T3's hand rows remain as the FLOOR checks.) 286 checks = checks + 1 287 var arows: i64 = 0 288 var amiss8: i64 = 0 289 var anoev: i64 = 0 290 let pbuf: *u8 = sys_mmap(160) 291 if (bsrc as i64) != 0 { 292 let bn8: i64 = blen[0] 293 var p: i64 = 0 294 while p < bn8 - 8 { 295 if match_at(bsrc, bn8, p, "capv[" as *u8) == 1 { 296 var q: i64 = p + 5 297 var nd: i64 = 0 298 var dq: i64 = 1 299 while dq == 1 { 300 let c: i64 = bsrc[q] as i64 301 var dig: i64 = 0 302 if c >= 48 { if c <= 57 { dig = 1 } } 303 if dig == 1 { nd = nd + 1; q = q + 1 } 304 if dig == 0 { dq = 0 } 305 } 306 if nd > 0 { if bsrc[q]==(93 as u8) { if bsrc[q+1]==(61 as u8) { 307 let v: i64 = (bsrc[q+2] as i64) - 48 308 if v == 2 { 309 var fnd: i64 = 0 310 var r: i64 = q + 3 311 while r < q + 60 { 312 if fnd == 0 { if match_at(bsrc, bn8, r, "capev[" as *u8) == 1 { fnd = r } } 313 r = r + 1 314 } 315 if fnd == 0 { anoev = anoev + 1 } 316 if fnd > 0 { 317 var s: i64 = fnd + 6 318 var g1: i64 = 1 319 while g1 == 1 { 320 if s >= bn8 { g1 = 0 } 321 if g1 == 1 { if bsrc[s] == (61 as u8) { g1 = 0 } } 322 if g1 == 1 { if s > fnd + 20 { g1 = 0 } } 323 if g1 == 1 { s = s + 1 } 324 } 325 s = s + 1 326 if bsrc[s] == (34 as u8) { 327 s = s + 1 328 var k8: i64 = 0 329 var g2: i64 = 1 330 while g2 == 1 { 331 if s >= bn8 { g2 = 0 } 332 if g2 == 1 { if bsrc[s] == (34 as u8) { g2 = 0 } } 333 if g2 == 1 { if k8 < 150 { pbuf[k8] = bsrc[s]; k8 = k8 + 1 } s = s + 1 } 334 } 335 pbuf[k8] = 0 as u8 336 arows = arows + 1 337 if fsize(pbuf) < 1 { 338 amiss8 = amiss8 + 1 339 gw(" BOARD-HAVE ARTIFACT MISSING (auto-scan): "); gw(pbuf); gw("\n") 340 } 341 } else { anoev = anoev + 1 } 342 } 343 } 344 } } } 345 } 346 p = p + 1 347 } 348 } 349 var t8g: i64 = 0 350 if arows >= 20 { if amiss8 == 0 { if anoev == 0 { t8g = 1 } } } 351 if t8g==1 { 352 gw("T8 GREEN auto-discovery: all "); gn(arows) 353 gw(" HAVE rows parsed FROM THE BOARD SOURCE name artifacts that exist -- a flip can no longer escape the liar-killer by skipping the gate edit\n") 354 pass = pass + 1 355 } else { 356 gw("T8 RED auto-scan: have-rows="); gn(arows); gw(" missing="); gn(amiss8) 357 gw(" have-without-artifact="); gn(anoev); gw(" (floor >=20 rows)\n") 358 } 359 360 gw("\n=== nx_gamebench_gate "); gn(pass); gw("/"); gn(checks) 361 if pass == checks { gw(" GREEN ===\n"); return 0 } 362 gw(" RED ===\n") 363 return 1 364}