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