code wiki / (root) / nx_enginelab_driver_gate.nx

nx_enginelab_driver_gate.nx source

↩ module page · 403 lines · 23148 B

1// nx_enginelab_driver_gate.nx -- END-TO-END gate for nx_enginelab, THE DRIVER. 2// 3// WHAT THIS PROVES THAT nx_enginelab_gate CANNOT. That gate asserts arithmetic properties of the 4// instrument library on fixtures built in memory, and says so in its own verdict: "fixtures whose 5// answers are known by construction". It therefore passes exactly as well when NOTHING drives the 6// library over a real frame -- which is the state the estate was in until nx_enginelab existed. This 7// gate forks the DEPLOYED driver against the REAL engine and asserts on its published report, so a 8// green here means a real renderer was really measured. 9// 10// EVERY TOOTH BINDS TO A DENOMINATOR. A report block that was never printed parses as -1 here, never 11// as 0, so a tooth cannot pass because a field was missing: the field helpers return -1 for "the tag 12// was not printed" and -1 for "the key was not on that tag's line", and the teeth test for positive 13// values. THE FIXTURE-REACHED-THE-CONDITION TEETH COME FIRST and assert the subprocess actually ran 14// and produced bytes, because a harness failure returns an empty capture that would otherwise make 15// every absence-shaped assertion below vacuously true. 16// 17// PARSING IS TAG-ANCHORED AND LINE-BOUNDED. The driver prints several blocks that share key names 18// (q= appears on SUBJECT and on every JOIN row; draws= appears on JOIN and on the named-absence row), 19// so an unanchored search would read one block's data as another's. gdrv_field finds the TAG, bounds 20// itself to that tag's line, and only then looks for the key -- the same positional discipline 21// gv_last_line uses for verdicts. 22// 23// SCRATCH IS PRIVATE AND UNDER /tmp. A gate that shares scratch with a production beat measures the 24// fixture instead of the code; this one writes only under GDRV_DIR, created at SETUP (a teardown does 25// not run when a run crashes). 26// license_tier: ORIGINAL No hardware writes (Rule 26): forks a read-only measurement organ. 27import "nx_syscalls.nx" 28import "nx_gate_verdict.nx" 29import "nx_tool_run.nx" 30 31// The DEPLOYED driver. _offc is the mirror every runner forks and the path the mutation harness 32// refreshes when it is given `subject nx_enginelab`, so pointing here is what makes this gate 33// substitutable under nx_gate_bite. 34// TWO CANDIDATE PATHS, RESOLVED BY STAT RATHER THAN ASSUMED. Runners fork the _offc mirror and the 35// mutation harness refreshes it there, but a gate launched from a different working directory would 36// find nothing at a relative path and every absence-shaped assertion below would pass vacuously. So 37// the path is RESOLVED, and T1 asserts that the resolution actually landed on a file. 38const GDRV_SUBJ_REL: *u8 = "_offc/nx_enginelab.elf" 39const GDRV_SUBJ_ABS: *u8 = "/volume1/homes/elderwesto/nishihost/_offc/nx_enginelab.elf" 40const GDRV_STATBUF: i64 = 256 41const GDRV_DIR: *u8 = "/tmp/nx_enginelab_driver_gate" 42const GDRV_CAPFILE: *u8 = "/tmp/nx_enginelab_driver_gate/roundtrip.elc" 43// A path whose PARENT does not exist: the capture write must refuse rather than report success. 44const GDRV_BADPATH: *u8 = "/tmp/nx_enginelab_driver_gate/no_such_dir/deep.elc" 45const GDRV_MODE_0755: i64 = 493 46const GDRV_OUTCAP: i64 = 32768 47const GDRV_ARGVMAX: i64 = 16 48// Fixture parameters. q=8 is the engine COARSEST quality and is chosen for RUN COST, not for 49// realism: every tooth below is a structural property of the report, and none of them depends on the 50// resolution. The headline performance numbers are taken by the driver at q=1 and published 51// separately -- a gate that spent ten seconds per tooth would simply not be run. 52const GDRV_Q_FAST: i64 = 8 53const GDRV_Q_MID: i64 = 4 54const GDRV_FRAMES: i64 = 3 55const GDRV_V: i64 = 2 56const GDRV_GRID: i64 = 8 57const GDRV_THRESH: i64 = 4 58// The driver exit codes, restated at their meaning so a tooth reads as an assertion about behaviour 59// rather than about a number. 60const GDRV_EXIT_OK: i64 = 0 61const GDRV_EXIT_FAIL: i64 = 1 62const GDRV_EXIT_USAGE: i64 = 2 63const GDRV_EXIT_UNMEASURABLE: i64 = 3 64const GDRV_ASCII_0: i64 = 48 65const GDRV_ASCII_9: i64 = 57 66const GDRV_NL: i64 = 10 67const GDRV_DEC: i64 = 10 68const GDRV_NOTFOUND: i64 = -1 69const GDRV_MINUS_CH: i64 = 45 70const GDRV_NS_PER_US: i64 = 1000 71const GDRV_PERMIL_FULL: i64 = 1000 72// rays at q=8 over a 1920x1200 native frame; only ever compared, never used as a bar 73const GDRV_MIN_CELLS: i64 = 1 74 75// ---- capture buffers ------------------------------------------------------------------------------ 76func gdrv_exists(p: *u8) -> i64 { 77 let sb: *u8 = sys_mmap(GDRV_STATBUF) 78 let r: i64 = sys_fstatat(p, sb) 79 sys_munmap(sb, GDRV_STATBUF) 80 if r == 0 { return 1 } 81 return 0 82} 83func gdrv_subject() -> *u8 { 84 if gdrv_exists(GDRV_SUBJ_REL) == 1 { return GDRV_SUBJ_REL } 85 return GDRV_SUBJ_ABS 86} 87func gdrv_resolved() -> i64 { 88 if gdrv_exists(GDRV_SUBJ_REL) == 1 { return 1 } 89 if gdrv_exists(GDRV_SUBJ_ABS) == 1 { return 1 } 90 return 0 91} 92 93func gdrv_buf() -> *u8 { return sys_mmap(GDRV_OUTCAP) } 94func gdrv_len() -> *i64 { return sys_mmap(16) as *i64 } 95 96// ---- text helpers. Substring search, line bounds, and a tag-anchored integer field. ----------------- 97func gdrv_lit_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } 98 99// first offset of `lit` in buf[from..n), or -1 100func gdrv_find(buf: *u8, n: i64, from: i64, lit: *u8) -> i64 { 101 let m: i64 = gdrv_lit_len(lit) 102 if m == 0 { return GDRV_NOTFOUND } 103 var i: i64 = from 104 var res: i64 = GDRV_NOTFOUND 105 while i + m <= n { 106 if res < 0 { 107 var j: i64 = 0 108 var ok: i64 = 1 109 while j < m { 110 if buf[i + j] != lit[j] { ok = 0; j = m } else { j = j + 1 } 111 } 112 if ok == 1 { res = i } 113 } 114 i = i + 1 115 } 116 return res 117} 118 119func gdrv_count(buf: *u8, n: i64, lit: *u8) -> i64 { 120 var c: i64 = 0 121 var at: i64 = 0 122 var run: i64 = 1 123 while run == 1 { 124 let f: i64 = gdrv_find(buf, n, at, lit) 125 if f < 0 { run = 0 } else { c = c + 1; at = f + 1 } 126 } 127 return c 128} 129 130// end of the line containing `from` 131func gdrv_eol(buf: *u8, n: i64, from: i64) -> i64 { 132 var i: i64 = from 133 while i < n { 134 if buf[i] == (GDRV_NL as u8) { return i } 135 i = i + 1 136 } 137 return n 138} 139 140func gdrv_int_at(buf: *u8, n: i64, at: i64) -> i64 { 141 var i: i64 = at 142 var v: i64 = 0 143 var got: i64 = 0 144 var neg: i64 = 0 145 if i < n { if buf[i] == (GDRV_MINUS_CH as u8) { neg = 1; i = i + 1 } } 146 while i < n { 147 let c: i64 = buf[i] as i64 148 if c >= GDRV_ASCII_0 { if c <= GDRV_ASCII_9 { v = v*GDRV_DEC + (c - GDRV_ASCII_0); got = 1; i = i + 1 } else { i = n } } else { i = n } 149 } 150 if got == 0 { return GDRV_NOTFOUND } 151 if neg == 1 { return 0 - v } 152 return v 153} 154 155// THE ANCHORED READ. -1 when the tag was never printed, and -1 when the key is absent from that 156// tag's own line. Both are honest absences and neither can be mistaken for a measured zero. 157func gdrv_field(buf: *u8, n: i64, tag: *u8, key: *u8) -> i64 { 158 let t: i64 = gdrv_find(buf, n, 0, tag) 159 if t < 0 { return GDRV_NOTFOUND } 160 let e: i64 = gdrv_eol(buf, n, t) 161 let k: i64 = gdrv_find(buf, e, t, key) 162 if k < 0 { return GDRV_NOTFOUND } 163 return gdrv_int_at(buf, e, k + gdrv_lit_len(key)) 164} 165 166// the same read, but for the Nth occurrence of a tag (the JOIN rows) 167func gdrv_field_nth(buf: *u8, n: i64, tag: *u8, key: *u8, nth: i64) -> i64 { 168 var at: i64 = 0 169 var seen: i64 = 0 170 var t: i64 = GDRV_NOTFOUND 171 var run: i64 = 1 172 while run == 1 { 173 let f: i64 = gdrv_find(buf, n, at, tag) 174 if f < 0 { run = 0 } else { 175 if seen == nth { t = f; run = 0 } else { seen = seen + 1; at = f + 1 } 176 } 177 } 178 if t < 0 { return GDRV_NOTFOUND } 179 let e: i64 = gdrv_eol(buf, n, t) 180 let k: i64 = gdrv_find(buf, e, t, key) 181 if k < 0 { return GDRV_NOTFOUND } 182 return gdrv_int_at(buf, e, k + gdrv_lit_len(key)) 183} 184 185func gdrv_num_str(v: i64) -> *u8 { 186 let b: *u8 = sys_mmap(32) 187 if v == 0 { b[0] = GDRV_ASCII_0 as u8; b[1] = 0 as u8; return b } 188 var m: i64 = v 189 let t: *u8 = sys_mmap(32) 190 var k: i64 = 0 191 while m > 0 { t[k] = (GDRV_ASCII_0 + (m % GDRV_DEC)) as u8; m = m / GDRV_DEC; k = k + 1 } 192 var i: i64 = 0 193 while i < k { b[i] = t[k - 1 - i]; i = i + 1 } 194 b[k] = 0 as u8 195 return b 196} 197 198// Fork the deployed driver with the given argv tail. Returns the child exit code; the capture and 199// its length land in buf/lenp. 200func gdrv_run(a1: *u8, a2: *u8, a3: *u8, a4: *u8, a5: *u8, a6: *u8, a7: *u8, buf: *u8, lenp: *i64) -> i64 { 201 let subj: *u8 = gdrv_subject() 202 let av: *i64 = sys_mmap(GDRV_ARGVMAX * 8) as *i64 203 var k: i64 = 0 204 av[k] = subj as i64; k = k + 1 205 if (a1 as i64) != 0 { av[k] = a1 as i64; k = k + 1 } 206 if (a2 as i64) != 0 { av[k] = a2 as i64; k = k + 1 } 207 if (a3 as i64) != 0 { av[k] = a3 as i64; k = k + 1 } 208 if (a4 as i64) != 0 { av[k] = a4 as i64; k = k + 1 } 209 if (a5 as i64) != 0 { av[k] = a5 as i64; k = k + 1 } 210 if (a6 as i64) != 0 { av[k] = a6 as i64; k = k + 1 } 211 if (a7 as i64) != 0 { av[k] = a7 as i64; k = k + 1 } 212 av[k] = 0 213 return tr_run_capture(subj, av, buf, GDRV_OUTCAP, lenp) 214} 215 216func gdrv_pos(v: i64) -> i64 { if v > 0 { return 1 } return 0 } 217func gdrv_eq(a: i64, b: i64) -> i64 { if a == b { return 1 } return 0 } 218func gdrv_eq2(a: i64, b: i64, c: i64, d: i64) -> i64 { if a == b { if c == d { return 1 } } return 0 } 219func gdrv_eq3(a: i64, b: i64, c: i64, d: i64, e: i64, f: i64) -> i64 { 220 if a == b { if c == d { if e == f { return 1 } } } return 0 221} 222func gdrv_eq4(a: i64, b: i64, c: i64, d: i64, e: i64, f: i64, g: i64, h: i64) -> i64 { 223 if a == b { if c == d { if e == f { if g == h { return 1 } } } } return 0 224} 225func gdrv_has(buf: *u8, n: i64, lit: *u8) -> i64 { 226 if gdrv_find(buf, n, 0, lit) >= 0 { return 1 } 227 return 0 228} 229 230func main() -> i64 { 231 let ctr: *i64 = gv_ctr() 232 gv_head("nx_enginelab_driver_gate -- the DRIVER attached to the REAL engine: a green here means a real renderer was really measured, not that a fixture computed correctly" as *u8) 233 234 sys_mkdir(GDRV_DIR, GDRV_MODE_0755) 235 236 let sv: *u8 = gdrv_num_str(GDRV_V) 237 let ss: *u8 = "20260728" as *u8 238 let sf: *u8 = gdrv_num_str(GDRV_FRAMES) 239 let sq: *u8 = gdrv_num_str(GDRV_Q_FAST) 240 let sqm: *u8 = gdrv_num_str(GDRV_Q_MID) 241 let szero: *u8 = "0" as *u8 242 let sgrid: *u8 = gdrv_num_str(GDRV_GRID) 243 let sthr: *u8 = gdrv_num_str(GDRV_THRESH) 244 245 // ---- the main measurement run --------------------------------------------------------------- 246 let b1: *u8 = gdrv_buf() 247 let l1: *i64 = gdrv_len() 248 let rc1: i64 = gdrv_run("frame" as *u8, sv, ss, sf, sq, 0 as *u8, 0 as *u8, b1, l1) 249 let n1: i64 = l1[0] 250 251 gv_check("T1 FIXTURE REACHED THE CONDITION: the subject binary RESOLVED to a real file, the deployed driver ran, and it produced a report -- without this every absence-shaped tooth below would pass on an empty capture" as *u8, 252 gdrv_eq3(gdrv_resolved(), 1, rc1, GDRV_EXIT_OK, gdrv_pos(n1), 1), ctr) 253 gv_subjects("bytes of driver report captured" as *u8, n1, ctr) 254 255 // ---- the subject really was the engine, at a real resolution --------------------------------- 256 let rays: i64 = gdrv_field(b1, n1, "ENGINELAB-SUBJECT " as *u8, "rays_per_frame=" as *u8) 257 let rw: i64 = gdrv_field(b1, n1, "ENGINELAB-SUBJECT " as *u8, "rw=" as *u8) 258 let rh: i64 = gdrv_field(b1, n1, "ENGINELAB-SUBJECT " as *u8, "rh=" as *u8) 259 gv_check("T2 the report names the real engine and a POSITIVE frame extent -- rays are read from the engine own owner of the written extent, not restated here" as *u8, 260 gdrv_eq4(gdrv_has(b1, n1, "organ=nx_wasm_craft entry=render_impl" as *u8), 1, 261 gdrv_pos(rays), 1, gdrv_pos(rw), 1, gdrv_pos(rh), 1), ctr) 262 gv_check("T3 the announced ray count RECONCILES with the announced extent -- rw x rh, so a report cannot claim a resolution it did not render" as *u8, 263 gdrv_eq(rays, rw * rh), ctr) 264 265 // ---- coverage: the store sizing arithmetic is right for the frames requested ------------------ 266 let ev: i64 = gdrv_field(b1, n1, "ENGINELAB-COVERAGE " as *u8, "events=" as *u8) 267 let dropped: i64 = gdrv_field(b1, n1, "ENGINELAB-COVERAGE " as *u8, "dropped=" as *u8) 268 let complete: i64 = gdrv_field(b1, n1, "ENGINELAB-COVERAGE " as *u8, "complete=" as *u8) 269 let errs: i64 = gdrv_field(b1, n1, "ENGINELAB-COVERAGE " as *u8, "errors=" as *u8) 270 gv_check("T4 NO SILENT CAPS: the derived store capacity held every event of a real run -- dropped=0 complete=1 bound to a POSITIVE event count" as *u8, 271 gdrv_eq4(dropped, 0, complete, 1, errs, 0, gdrv_pos(ev), 1), ctr) 272 273 // ---- pacing: the trailing mark closes the last frame ------------------------------------------ 274 let closed: i64 = gdrv_field(b1, n1, "ENGINELAB-PACING " as *u8, "closed_frames=" as *u8) 275 let openf: i64 = gdrv_field(b1, n1, "ENGINELAB-PACING " as *u8, "open=" as *u8) 276 let median: i64 = gdrv_field(b1, n1, "ENGINELAB-PACING " as *u8, "median_us=" as *u8) 277 let worst: i64 = gdrv_field(b1, n1, "ENGINELAB-PACING " as *u8, "worst_us=" as *u8) 278 gv_check("T5 EVERY REQUESTED FRAME IS CLOSED AND MEASURED: the trailing boundary mark means the last frame is not silently lost as OPEN" as *u8, 279 gdrv_eq2(closed, GDRV_FRAMES, openf, 1), ctr) 280 gv_check("T6 the pacing figures are real times, and worst is never better than median" as *u8, 281 gdrv_eq3(gdrv_pos(median), 1, gdrv_pos(worst), 1, gdrv_pos(worst - median + 1), 1), ctr) 282 283 // ---- the join: one row per frame, each attributing real CPU time to a named zone -------------- 284 let joins: i64 = gdrv_count(b1, n1, "ENGINELAB-JOIN " as *u8) 285 let j0dur: i64 = gdrv_field_nth(b1, n1, "ENGINELAB-JOIN " as *u8, "dur_us=" as *u8, 0) 286 let j0cpu: i64 = gdrv_field_nth(b1, n1, "ENGINELAB-JOIN " as *u8, "cpu_us=" as *u8, 0) 287 let j0rays: i64 = gdrv_field_nth(b1, n1, "ENGINELAB-JOIN " as *u8, "rays=" as *u8, 0) 288 let jlast: i64 = gdrv_field_nth(b1, n1, "ENGINELAB-JOIN " as *u8, "ord=" as *u8, GDRV_FRAMES - 1) 289 gv_check("T7 THE JOIN RESOLVES FOR EVERY FRAME: one row per requested frame and the last row is the last ordinal" as *u8, 290 gdrv_eq2(joins, GDRV_FRAMES, jlast, GDRV_FRAMES - 1), ctr) 291 gv_check("T8 a joined frame carries a real duration, real CPU root time inside it, and the ray count that frame was rendered at" as *u8, 292 gdrv_eq4(gdrv_pos(j0dur), 1, gdrv_pos(j0cpu), 1, gdrv_pos(j0dur - j0cpu + 1), 1, j0rays, rays), ctr) 293 294 // ---- zones: self time is attributed, and the hot zone is the one that did the work ------------ 295 let rendcalls: i64 = gdrv_field(b1, n1, "ENGINELAB-ZONE name=render " as *u8, "calls=" as *u8) 296 let rendself: i64 = gdrv_field(b1, n1, "ENGINELAB-ZONE name=render " as *u8, "self_us=" as *u8) 297 let rendopen: i64 = gdrv_field(b1, n1, "ENGINELAB-ZONE name=render " as *u8, "open=" as *u8) 298 let initself: i64 = gdrv_field(b1, n1, "ENGINELAB-ZONE name=init " as *u8, "self_us=" as *u8) 299 let nsray: i64 = gdrv_field(b1, n1, "ENGINELAB-RAYS " as *u8, "ns_per_ray=" as *u8) 300 gv_check("T9 EVERY ZONE OPENED WAS CLOSED: render ran once per frame with no open scope left behind, and world init is attributed separately from frame cost" as *u8, 301 gdrv_eq4(rendcalls, GDRV_FRAMES, rendopen, 0, gdrv_pos(rendself), 1, gdrv_pos(initself), 1), ctr) 302 gv_check("T10 COST PER UNIT OF WORK IS PUBLISHED: ns_per_ray is positive and derives from the render self time, which is the only figure comparable across resolutions" as *u8, 303 gdrv_eq2(gdrv_pos(nsray), 1, nsray, rendself * GDRV_NS_PER_US / (rays * GDRV_FRAMES)), ctr) 304 305 // ---- THE ABSTENTION. This is the tooth that would be easiest to lose. ------------------------- 306 // The CPU occupancy of these frames is ~999 permil, so a bound verdict that keyed on occupancy 307 // alone would confidently answer CPU-BOUND. It must not: with no GPU evidence in the capture the 308 // only honest answer is UNKNOWN, and the reason must travel with it. 309 gv_check("neg-control-T11 WITH NO GPU EVIDENCE THE BOUND VERDICT ABSTAINS AND NEVER ACQUITS: verdict=UNKNOWN with its reason, and the words CPU-BOUND and GPU-BOUND appear nowhere" as *u8, 310 gdrv_eq4(gdrv_has(b1, n1, "ENGINELAB-BOUND code=3 verdict=UNKNOWN reason=" as *u8), 1, 311 gdrv_has(b1, n1, "verdict=CPU-BOUND" as *u8), 0, 312 gdrv_has(b1, n1, "verdict=GPU-BOUND" as *u8), 0, 313 gdrv_has(b1, n1, "verdict=BOTH" as *u8), 0), ctr) 314 315 // ---- THE NAMED ABSENCE. draws=0 must never be able to read as a frame that issued no work. ---- 316 gv_check("T12 THE UNMEASURABLE CLASS IS DECLARED, NOT LEFT AS A ZERO: draws=0 always ships with its cause and the exact emission site the engine lane owes" as *u8, 317 gdrv_eq3(gdrv_has(b1, n1, "ENGINELAB-UNMEASURABLE draws=0" as *u8), 1, 318 gdrv_has(b1, n1, "reason=the-engine-emits-no-draw-stream" as *u8), 1, 319 gdrv_has(b1, n1, "owner=engine-lane-nx_wasm_craft" as *u8), 1), ctr) 320 321 // ---- memory: the engine arena is a real allocation and is reported as one --------------------- 322 let allocs: i64 = gdrv_field(b1, n1, "ENGINELAB-MEM " as *u8, "allocs=" as *u8) 323 let orphan: i64 = gdrv_field(b1, n1, "ENGINELAB-MEM " as *u8, "orphan_frees=" as *u8) 324 let live: i64 = gdrv_field(b1, n1, "ENGINELAB-MEM " as *u8, "live_bytes=" as *u8) 325 gv_check("T13 the engine arena is accounted, not omitted: a positive live byte count with no orphan frees" as *u8, 326 gdrv_eq3(gdrv_pos(allocs), 1, orphan, 0, gdrv_pos(live), 1), ctr) 327 328 // ---- resolution is a real dial, checked by ARITHMETIC not by timing -------------------------- 329 let b2: *u8 = gdrv_buf() 330 let l2: *i64 = gdrv_len() 331 let rc2: i64 = gdrv_run("frame" as *u8, sv, ss, sf, sqm, 0 as *u8, 0 as *u8, b2, l2) 332 let n2: i64 = l2[0] 333 let rays2: i64 = gdrv_field(b2, n2, "ENGINELAB-SUBJECT " as *u8, "rays_per_frame=" as *u8) 334 let perm1: i64 = gdrv_field(b1, n1, "ENGINELAB-SUBJECT " as *u8, "native_permil=" as *u8) 335 let perm2: i64 = gdrv_field(b2, n2, "ENGINELAB-SUBJECT " as *u8, "native_permil=" as *u8) 336 gv_check("T14 A REDUCED CAPTURE CAN NEVER PASS AS A FULL ONE: a finer quality announces strictly more rays and a strictly larger fraction of native" as *u8, 337 gdrv_eq4(rc2, GDRV_EXIT_OK, gdrv_pos(rays2 - rays), 1, gdrv_pos(perm2 - perm1), 1, gdrv_pos(perm1), 1), ctr) 338 339 // ---- EL1 ON REAL DATA ------------------------------------------------------------------------- 340 let b3: *u8 = gdrv_buf() 341 let l3: *i64 = gdrv_len() 342 let rc3: i64 = gdrv_run("capture" as *u8, GDRV_CAPFILE, sv, ss, sf, sq, 0 as *u8, b3, l3) 343 let n3: i64 = l3[0] 344 let recs: i64 = gdrv_field(b3, n3, "ENGINELAB-CAPTURE " as *u8, "records=" as *u8) 345 let ident: i64 = gdrv_field(b3, n3, "ENGINELAB-CAPTURE " as *u8, "records_identical=" as *u8) 346 let didt: i64 = gdrv_field(b3, n3, "ENGINELAB-CAPTURE " as *u8, "derived_identical=" as *u8) 347 gv_check("T15 A REAL CAPTURE OUTLIVES ITS PROCESS AND REOPENS EXACTLY: every field of every record and every derived pacing figure identical, bound to a POSITIVE record count" as *u8, 348 gdrv_eq4(rc3, GDRV_EXIT_OK, ident, 1, didt, 1, gdrv_pos(recs), 1), ctr) 349 350 // ---- NEGATIVE CONTROLS ------------------------------------------------------------------------ 351 // A capture whose destination cannot be opened must REFUSE. Without this the round-trip tooth 352 // above could be satisfied by a driver that never wrote anything and compared a store with itself. 353 let b4: *u8 = gdrv_buf() 354 let l4: *i64 = gdrv_len() 355 let rc4: i64 = gdrv_run("capture" as *u8, GDRV_BADPATH, sv, ss, sf, sq, 0 as *u8, b4, l4) 356 let n4: i64 = l4[0] 357 gv_check("neg-control-T16 AN UNWRITABLE CAPTURE DESTINATION IS REFUSED BY NAME, never reported as a successful round trip" as *u8, 358 gdrv_eq3(rc4, GDRV_EXIT_FAIL, 359 gdrv_has(b4, n4, "verdict=WRITE-REFUSED" as *u8), 1, 360 gdrv_has(b4, n4, "ROUNDTRIP-IDENTICAL" as *u8), 0), ctr) 361 362 // A run with no frames has NO SUBJECT. The empty-set pass is the defect this whole board exists 363 // to catch, so the driver must refuse rather than publish a healthy-looking zero. 364 let b5: *u8 = gdrv_buf() 365 let l5: *i64 = gdrv_len() 366 let rc5: i64 = gdrv_run("frame" as *u8, sv, ss, szero, sq, 0 as *u8, 0 as *u8, b5, l5) 367 let n5: i64 = l5[0] 368 gv_check("neg-control-T17 A ZERO-FRAME RUN IS UNMEASURABLE AND SAYS SO -- it takes no measurement at all rather than publishing an empty-set pass" as *u8, 369 gdrv_eq4(rc5, GDRV_EXIT_UNMEASURABLE, 370 gdrv_has(b5, n5, "ENGINELAB-REFUSED verdict=UNMEASURABLE" as *u8), 1, 371 gdrv_has(b5, n5, "ENGINELAB-JOIN" as *u8), 0, 372 gdrv_has(b5, n5, "ENGINELAB-PACING" as *u8), 0), ctr) 373 374 // An unknown verb must not silently fall through into a measurement. 375 let b6: *u8 = gdrv_buf() 376 let l6: *i64 = gdrv_len() 377 let rc6: i64 = gdrv_run("profile" as *u8, sv, ss, sf, sq, 0 as *u8, 0 as *u8, b6, l6) 378 let n6: i64 = l6[0] 379 gv_check("neg-control-T18 AN UNRECOGNISED VERB REFUSES WITH USAGE AND MEASURES NOTHING -- it never falls through into the default action" as *u8, 380 gdrv_eq3(rc6, GDRV_EXIT_USAGE, 381 gdrv_has(b6, n6, "usage: nx_enginelab" as *u8), 1, 382 gdrv_has(b6, n6, "ENGINELAB-SUBJECT" as *u8), 0), ctr) 383 384 // ---- GOLDEN: determinism of the real render path, per cell ----------------------------------- 385 let b7: *u8 = gdrv_buf() 386 let l7: *i64 = gdrv_len() 387 let rc7: i64 = gdrv_run("golden" as *u8, sv, ss, sf, sq, sgrid, sthr, b7, l7) 388 let n7: i64 = l7[0] 389 let cells: i64 = gdrv_field(b7, n7, "ENGINELAB-GOLDEN " as *u8, "cells_total=" as *u8) 390 let matched: i64 = gdrv_field(b7, n7, "ENGINELAB-GOLDEN " as *u8, "cells_matched=" as *u8) 391 let gperm: i64 = gdrv_field(b7, n7, "ENGINELAB-GOLDEN " as *u8, "permil=" as *u8) 392 gv_check("T19 THE REAL RENDER PATH IS DETERMINISTIC, MEASURED PER CELL AND BOUND TO ITS DENOMINATOR: two independent arenas on one seed match on every cell of a NON-EMPTY grid" as *u8, 393 gdrv_eq4(rc7, GDRV_EXIT_OK, gperm, GDRV_PERMIL_FULL, matched, cells, 394 gdrv_pos(cells - GDRV_MIN_CELLS + 1), 1), ctr) 395 gv_check("T20 the golden grid really examined the frame it was handed -- its cell count equals the requested grid squared, so a comparison over a window that was never built cannot read as a pass" as *u8, 396 gdrv_eq(cells, GDRV_GRID * GDRV_GRID), ctr) 397 398 let rc: i64 = gv_verdict("ENGINELAB-DRIVER-GATE" as *u8, ctr, 399 "the sovereign engine instrument was driven over real frames of the real renderer: the join resolves per frame, coverage is complete, the bound verdict abstains for want of GPU evidence rather than acquitting on occupancy, the draw class is declared unmeasurable by name, a capture reopens exactly, and two independent runs of one seed agree on every cell" as *u8) 400 gv_journal("nx_enginelab_driver_gate" as *u8, ctr[0], ctr[1], gdrv_eq(rc, 0)) 401 sys_exit(rc) 402 return rc 403}