nx_worldvis_gate.nx source
↩ module page · 190 lines · 11408 B
1// nx_worldvis_gate.nx -- THE VISIBLE-EXPERIENCE RULER (donors-into-world rung, 2026-08-23).
2// The operator's complaint was exact: boards improved while the served worlds stood still.
3// This gate measures the SERVED pages (the docroot files a visitor receives), never a board:
4// - each world page carries the visiting-cast roster, loader, authored-surface mode and the
5// footer declaration -- and the ROSTER COUNT ON THE PAGE equals the conf's row count
6// (count bound IN the condition; an empty conf cannot vacuously pass: rows>0 is a tooth);
7// - every declared donor asset is SERVED and carries TEXC+TEXM (a clay visitor cannot pass);
8// - neg-control-banked-predonor-page-fires: the banked pre-donor page must LACK the roster
9// marker, proving the marker teeth are capable of failing (a green that never had a
10// corresponding red is unverified).
11// Pixel-level GPU sampling proof is browser territory, declared here and witnessed by the
12// operator-facing headless captures (worldcap); this gate is the structural, always-runnable
13// half. license_tier: ORIGINAL expect_exit: 0
14import "nx_syscalls.nx"
15import "nx_gate_verdict.nx"
16
17func wv_find(hay: *u8, n: i64, needle: *u8) -> i64 {
18 var nl: i64 = 0
19 while needle[nl] != (0 as u8) { nl = nl + 1 }
20 if nl == 0 { return 1 }
21 var i: i64 = 0
22 while i + nl <= n {
23 var j: i64 = 0
24 var hit: i64 = 1
25 while j < nl { if hay[i + j] != needle[j] { hit = 0; j = nl } else { j = j + 1 } }
26 if hit == 1 { return 1 }
27 i = i + 1
28 }
29 return 0
30}
31func wv_count(hay: *u8, n: i64, needle: *u8) -> i64 {
32 var nl: i64 = 0
33 while needle[nl] != (0 as u8) { nl = nl + 1 }
34 if nl == 0 { return 0 }
35 var c: i64 = 0
36 var i: i64 = 0
37 while i + nl <= n {
38 var j: i64 = 0
39 var hit: i64 = 1
40 while j < nl { if hay[i + j] != needle[j] { hit = 0; j = nl } else { j = j + 1 } }
41 if hit == 1 { c = c + 1; i = i + nl } else { i = i + 1 }
42 }
43 return c
44}
45func wv_rd64(b: *u8, off: i64) -> i64 { var v: i64 = 0; var k: i64 = 7; while k >= 0 { v = v*256 + (b[off+k] as i64); k = k - 1 } return v }
46func wv_tag4(b: *u8, off: i64, t: *u8) -> i64 { if b[off] == t[0] { if b[off+1] == t[1] { if b[off+2] == t[2] { if b[off+3] == t[3] { return 1 } } } } return 0 }
47
48// count conf rows (non-comment, 4-field). Returns row count; asset paths checked inline in main.
49func wv_conf_rows(buf: *u8, n: i64) -> i64 {
50 var rows: i64 = 0
51 var i: i64 = 0
52 while i < n {
53 let ls: i64 = i
54 var le: i64 = ls
55 var scan: i64 = 1
56 while scan == 1 { if le >= n { scan = 0 } else { if buf[le] == (10 as u8) { scan = 0 } else { le = le + 1 } } }
57 if le >= n { return 0 - 1 }
58 i = le + 1
59 if le > ls { if buf[ls] != (35 as u8) { rows = rows + 1 } }
60 }
61 return rows
62}
63
64func wv_page(ctr: *i64, path: *u8, label_pre: *u8, want: i64) -> i64 {
65 let bx: *i64 = sys_mmap(16) as *i64
66 let pg: *u8 = sys_read_file(path, bx)
67 let n: i64 = bx[0]
68 var ok_read: i64 = 0
69 if (pg as i64) != 0 { if n > 0 { ok_read = 1 } }
70 gv_puts(" [" as *u8); gv_puts(label_pre); gv_puts("] bytes=" as *u8); gv_num(n); gv_puts("\n" as *u8)
71 gv_check("page-readable" as *u8, ok_read, ctr)
72 if ok_read == 0 { return 1 }
73 let cast: i64 = wv_count(pg, n, "{n:\"" as *u8)
74 gv_puts(" cast_on_page=" as *u8); gv_num(cast); gv_puts(" conf_rows=" as *u8); gv_num(want); gv_puts("\n" as *u8)
75 var t: i64 = 0
76 if cast == want { if want > 0 { t = 1 } }
77 gv_check("cast-count-on-page-equals-conf-rows (bound in condition, empty set cannot pass)" as *u8, t, ctr)
78 gv_check("page-carries-roster-marker" as *u8, wv_find(pg, n, "NXNPCS=[" as *u8), ctr)
79 gv_check("page-carries-loadDonors" as *u8, wv_find(pg, n, "loadDonors" as *u8), ctr)
80 gv_check("page-carries-authored-surface-mode" as *u8, wv_find(pg, n, "uAuth" as *u8), ctr)
81 gv_check("page-carries-drawDonors" as *u8, wv_find(pg, n, "drawDonors" as *u8), ctr)
82 gv_check("page-declares-visiting-cast-in-footer" as *u8, wv_find(pg, n, "Visiting characters" as *u8), ctr)
83 // THE PRODUCT-RULE TOOTH (2026-08-23, operator-caught 'super buggy and broken'): the cast
84 // must NOT load on the default page while its render is broken. A VISIBLY BROKEN FEATURE ON
85 // THE FRONT DOOR IS WORSE THAN AN ABSENT ONE, so the gating is the invariant -- this tooth
86 // fires the moment someone un-gates it, which is the exact regression that shipped today.
87 gv_check("default-page-does-not-autoload-the-cast (loadDonors is CAST9-gated)" as *u8, wv_find(pg, n, "if(CAST9)loadDonors" as *u8), ctr)
88 gv_check("opt-in-lever-declared-on-the-page (?cast=1)" as *u8, wv_find(pg, n, "cast=1" as *u8), ctr)
89 // WEBGPU TIER HONESTY (2026-08-23): the ?gpu=1 tier draws the WORLD ONLY -- the resident cast
90 // AND the visiting cast both render through the GL character programs (MVS/MFS), so a visitor
91 // who forces that tier sees an empty world. A tier that cannot draw something must SAY SO;
92 // silence there is indistinguishable from a world with nobody in it. This tooth fires if the
93 // declaration is ever dropped from the emitted page.
94 gv_check("webgpu-tier-declares-its-character-abstention" as *u8, wv_find(pg, n, "characters-not-drawn-on-this-tier" as *u8), ctr)
95 return 0
96}
97
98func main() -> i64 {
99 let ctr: *i64 = gv_ctr()
100 // the conf is the cast's single owner
101 let cb: *i64 = sys_mmap(16) as *i64
102 let conf: *u8 = sys_read_file("knowledge/world_npcs.conf" as *u8, cb)
103 var rows: i64 = 0
104 if (conf as i64) != 0 { rows = wv_conf_rows(conf, cb[0]) }
105 gv_puts(" conf rows=" as *u8); gv_num(rows); gv_puts("\n" as *u8)
106 gv_check("conf-declares-a-cast (rows>0; the gate must not pass on an empty roster)" as *u8, rows > 0, ctr)
107 // every declared donor asset is served and textured (walk the conf again inline)
108 if (conf as i64) != 0 { if rows > 0 {
109 let n: i64 = cb[0]
110 var i: i64 = 0
111 var served: i64 = 0
112 var textured: i64 = 0
113 while i < n {
114 let ls: i64 = i
115 var le: i64 = ls
116 var scan: i64 = 1
117 while scan == 1 { if le >= n { scan = 0 } else { if conf[le] == (10 as u8) { scan = 0 } else { le = le + 1 } } }
118 if le >= n { i = n } else {
119 i = le + 1
120 if le > ls { if conf[ls] != (35 as u8) {
121 conf[le] = 0 as u8
122 var q: i64 = ls
123 var asx: i64 = 0
124 var nf: i64 = 0
125 while q < le { if conf[q] == (9 as u8) { conf[q] = 0 as u8; nf = nf + 1; if nf == 1 { asx = q + 1 } } q = q + 1 }
126 if asx > 0 {
127 let pth: *u8 = sys_mmap(256)
128 var w: i64 = 0
129 let pre: *u8 = "sites/nishifamily/world/" as *u8
130 while pre[w] != (0 as u8) { pth[w] = pre[w]; w = w + 1 }
131 var a2: i64 = asx
132 while conf[a2] != (0 as u8) { pth[w] = conf[a2]; w = w + 1; a2 = a2 + 1 }
133 let sfx: *u8 = ".nxa" as *u8
134 var s2: i64 = 0
135 while sfx[s2] != (0 as u8) { pth[w] = sfx[s2]; w = w + 1; s2 = s2 + 1 }
136 pth[w] = 0 as u8
137 let ax: *i64 = sys_mmap(16) as *i64
138 let ab: *u8 = sys_read_file(pth, ax)
139 if (ab as i64) != 0 {
140 served = served + 1
141 let ns9: i64 = wv_rd64(ab, 16)
142 var texc: i64 = 0
143 var texm: i64 = 0
144 var s9: i64 = 0
145 while s9 < ns9 {
146 let e9: i64 = 32 + s9*32
147 if wv_tag4(ab, e9, "TEXC" as *u8) == 1 { texc = 1 }
148 if wv_tag4(ab, e9, "TEXM" as *u8) == 1 { texm = 1 }
149 s9 = s9 + 1
150 }
151 if texc == 1 { if texm == 1 { textured = textured + 1 } }
152 }
153 }
154 } }
155 }
156 }
157 gv_puts(" donors served=" as *u8); gv_num(served); gv_puts(" textured=" as *u8); gv_num(textured); gv_puts(" of rows=" as *u8); gv_num(rows); gv_puts("\n" as *u8)
158 gv_check("every-declared-donor-asset-served (served==rows)" as *u8, served == rows, ctr)
159 gv_check("every-served-donor-carries-TEXC-and-TEXM (a clay visitor cannot pass)" as *u8, textured == rows, ctr)
160 } }
161 // the two operator-named worlds, measured as SERVED bytes
162 wv_page(ctr, "sites/nishifamily/world/craft.html" as *u8, "craft" as *u8, rows)
163 wv_page(ctr, "sites/nishifamily/world/beach.html" as *u8, "beach" as *u8, rows)
164 // neg-control: the banked pre-donor page must LACK the roster marker -- the marker teeth
165 // are thereby proven ABLE to fail (fires on bad, silent on good)
166 let nx2: *i64 = sys_mmap(16) as *i64
167 let old: *u8 = sys_read_file("knowledge/bank/craft.html.predonor-20260823" as *u8, nx2)
168 if gv_need("knowledge/bank/craft.html.predonor-20260823" as *u8, (old as i64) != 0, ctr) == 1 {
169 gv_check("neg-control-banked-predonor-page-lacks-roster-marker" as *u8, wv_find(old, nx2[0], "NXNPCS=[" as *u8) == 0, ctr)
170 // the SAME banked page predates the WebGPU declaration, so it proves THAT tooth can fail
171 // too -- a marker tooth whose string nothing has ever lacked is decoration, not evidence.
172 gv_check("neg-control-banked-predonor-page-lacks-the-webgpu-abstention" as *u8, wv_find(old, nx2[0], "characters-not-drawn-on-this-tier" as *u8) == 0, ctr)
173 }
174 // ⛔THE SCOPE OF THIS GATE, STATED SO IT CANNOT BE MISREAD AGAIN. Every tooth above measures
175 // the SERVED MARKUP and the ASSET BYTES. NOT ONE measures a RENDERED FRAME -- and on
176 // 2026-08-23 this gate read 18/18 GREEN while the operator saw a broken cast: only 1 of 4
177 // donors arriving, a ~30px dark blob at the horizon, ground contact unverified. ★★★★★★A GATE
178 // WHOSE SUBJECT IS THE MARKUP CANNOT SPEAK FOR THE PIXELS, AND ITS GREEN IS EVIDENCE OF
179 // NOTHING ABOUT WHAT A VISITOR SEES. The render half is OWED and NAMED, not silently absent:
180 // nx_worldcast_render_gate -- compose nx_pageshot at a COMPUTED camera (the golden-angle ring
181 // is derivable), then assert: arrival count reaches the roster count inside a budget DERIVED
182 // from the measured per-donor parse cost; donor pixel footprint inside bounds derived from its
183 // own scale + the camera geometry (never a picked number); silhouette upright per the asset's
184 // own stature axis; textured-not-flat by atlas ON/OFF differencing (the harness already exists
185 // in nx_npc_atlas_gate); cross-donor consistency. Neg-control: a deliberately mis-rotated,
186 // mis-scaled, untextured donor must FAIL those teeth.
187 let rcv: i64 = gv_verdict("NX-WORLDVIS" as *u8, ctr, "MARKUP+ASSET SCOPE ONLY: the cast's code is on the served pages and is opt-in-gated, its assets are served and textured in-asset, and the pre-donor bank proves the teeth can fail -- this gate says NOTHING about how a donor RENDERS (see nx_worldcast_render_gate, owed)" as *u8)
188 sys_exit(rcv)
189 return rcv
190}