code wiki / _hdl_build / nx_gpu_sovereignty_gate.nx
nx_gpu_sovereignty_gate.nx source
↩ module page · 90 lines · 4447 B
1// nx_gpu_sovereignty_gate.nx -- ADVERSARIAL proof of the operator's "NO 3rd party" law for the browser-COMPAT
2// GPU page: scans knowledge/gpulab.html and FAILS if it references ANY external host / CDN / 3rd-party engine,
3// while REQUIRING a real self-contained WebGL2 pipeline. (This gate proves the COMPAT tier adds no library --
4// the render is our shaders/geometry running on the host's standard WebGL2; sovereignty of EXECUTION is the
5// T3-on-our-silicon story, tracked in nx_render_tier_census.) license_tier: ORIGINAL expect_exit: 0
6import "nx_syscalls.nx"
7
8func hw(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
9func pn(v: i64) -> i64 {
10 let b: *u8 = sys_mmap(32) as *u8
11 var x: i64 = v
12 var i: i64 = 31
13 if x == 0 { b[i] = 48 as u8; i = i - 1 }
14 while x > 0 { b[i] = (48 + x % 10) as u8; x = x / 10; i = i - 1 }
15 sys_write(1, (b as i64 + i + 1) as *u8, 31 - i)
16 return 0
17}
18func nlen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
19func has(buf: *u8, len: i64, needle: *u8) -> i64 {
20 let nl: i64 = nlen(needle)
21 if nl == 0 { return 0 }
22 var i: i64 = 0
23 while i + nl <= len {
24 var k: i64 = 0
25 var m: i64 = 1
26 while k < nl {
27 let cb: *u8 = (buf as i64 + i + k) as *u8
28 if cb[0] != needle[k] { m = 0; k = nl }
29 k = k + 1
30 }
31 if m == 1 { return 1 }
32 i = i + 1
33 }
34 return 0
35}
36
37func main() -> i64 {
38 var fails: i64 = 0
39 let lenp: *i64 = sys_mmap(16) as *i64
40 let buf: *u8 = sys_read_file("knowledge/gpulab.html" as *u8, lenp)
41 if (buf as i64) == 0 { hw("GATE RED: cannot read knowledge/gpulab.html\n" as *u8); return 1 }
42 let len: i64 = lenp[0]
43 hw("gpulab.html bytes="); pn(len); hw("\n" as *u8)
44
45 // T1 no external fetch (no host reference)
46 var t1: i64 = 1
47 if has(buf, len, "://" as *u8) == 1 { t1 = 0 }
48 if has(buf, len, "script src" as *u8) == 1 { t1 = 0 }
49 if has(buf, len, "stylesheet" as *u8) == 1 { t1 = 0 }
50 if t1 == 1 { hw("T1 PASS no external fetch: no host URL, no <script src>, no external stylesheet\n" as *u8) }
51 else { hw("T1 FAIL external reference present\n" as *u8); fails = fails + 1 }
52
53 // T2 no 3rd-party engine/CDN
54 var t2: i64 = 1
55 if has(buf, len, "three" as *u8) == 1 { t2 = 0 }
56 if has(buf, len, "babylon" as *u8) == 1 { t2 = 0 }
57 if has(buf, len, "playcanvas" as *u8) == 1 { t2 = 0 }
58 if has(buf, len, "cdn" as *u8) == 1 { t2 = 0 }
59 if has(buf, len, "unpkg" as *u8) == 1 { t2 = 0 }
60 if has(buf, len, "jsdelivr" as *u8) == 1 { t2 = 0 }
61 if t2 == 1 { hw("T2 PASS no 3rd-party engine: no three/babylon/playcanvas/cdn/unpkg/jsdelivr -- the renderer is OURS\n" as *u8) }
62 else { hw("T2 FAIL 3rd-party engine/CDN referenced\n" as *u8); fails = fails + 1 }
63
64 // T3 real GPU pipeline present
65 var t3: i64 = 1
66 if has(buf, len, "webgl2" as *u8) == 0 { t3 = 0 }
67 if has(buf, len, "createShader" as *u8) == 0 { t3 = 0 }
68 if has(buf, len, "300 es" as *u8) == 0 { t3 = 0 }
69 if has(buf, len, "drawElements" as *u8) == 0 { t3 = 0 }
70 if t3 == 1 { hw("T3 PASS real GPU pipeline: WebGL2 + our GLSL (300 es) + drawElements -- executes on the GPU\n" as *u8) }
71 else { hw("T3 FAIL GPU pipeline incomplete\n" as *u8); fails = fails + 1 }
72
73 // T4 feature-detect + graceful sovereign fallback
74 var t4: i64 = 1
75 if has(buf, len, "fallback" as *u8) == 0 { t4 = 0 }
76 if has(buf, len, "soft-raster" as *u8) == 0 { t4 = 0 }
77 if t4 == 1 { hw("T4 PASS graceful fallback to the SOVEREIGN soft-raster tier on no-WebGL2 devices (progressive enhancement)\n" as *u8) }
78 else { hw("T4 FAIL no sovereign fallback\n" as *u8); fails = fails + 1 }
79
80 // T5 device-adaptive quality (mobile vs desktop) present
81 var t5: i64 = 1
82 if has(buf, len, "Mobi" as *u8) == 0 { t5 = 0 }
83 if has(buf, len, "devicePixelRatio" as *u8) == 0 { t5 = 0 }
84 if t5 == 1 { hw("T5 PASS device-adaptive: mobile/desktop detection + DPR scaling -- highest quality the device carries\n" as *u8) }
85 else { hw("T5 FAIL no device adaptation\n" as *u8); fails = fails + 1 }
86
87 if fails == 0 { hw("VERDICT GREEN: gpu-sovereignty 5/5 -- COMPAT-tier GPU page proven ZERO-3rd-party, self-contained, device-adaptive, sovereign-fallback (adversarial)\n" as *u8) }
88 else { hw("VERDICT RED fails=" as *u8); pn(fails); hw("\n" as *u8) }
89 return fails
90}