code wiki / _hdl_build / nx_ui_live_verify.nx

nx_ui_live_verify.nx source

↩ module page · 58 lines · 3924 B

1// nx_ui_live_verify.nx -- TOP-DOWN UI verifier (operator 2026-07-04: "redundancy in seeing things -- 2// an api with the same capabilities as a front-end testing system ... top-down user/front-end validation"). 3// The REDUNDANT twin of nx_ui_wiring_census: that eye reads LOCAL SOURCE; THIS eye fetches the LIVE SERVED 4// bytes the user actually receives (nx_https_get over the real edge, own TLS-1.3 trust store, no browser, 5// no shell) and runs the SAME shared checks (nx_ui_checks). Disagreement between the two eyes = DEPLOY 6// DRIFT (stale / truncated / edge-mangled deploy) -- a break the source-only eye cannot see. This is the 7// user's perspective: what actually shipped, not what we meant to ship. 8// HONEST SCOPE: static wiring on served bytes, not click-execution (full execution = task #35 engine arc). 9// expect_exit: 0 when the LIVE page is wired + init crash-safe. license_tier: ORIGINAL 10import "nx_ui_checks.nx" 11import "nx_https_get.nx" 12import "nx_trust_store_load_from_certdata.nx" 13const K_MAGIC_4194304: i64 = 4194304 14const K_MAGIC_262144: i64 = 262144 15 16func lv_fetch(url: *u8, store: *TrustStore, out: *u8, cap: i64, nout: *i64) -> i64 { 17 let cr: *u8 = sys_mmap(32); var i: i64=0; while i<32 { cr[i]=(0x41 + i) as u8; i=i+1 } 18 let pk: *u8 = sys_mmap(32); i=0; while i<32 { pk[i]=(0x81 + i) as u8; i=i+1 } 19 let n: i64 = nx_https_get(url, cr, pk, store, sys_now_realtime_sec(), out, cap) 20 nout[0] = n 21 if n <= 0 { return 0 } 22 return 1 } 23 24func main() -> i64 { 25 uc_w("=== nx_ui_live_verify: TOP-DOWN UI verifier (LIVE served bytes the user receives) ===\n" as *u8) 26 let r: i64 = nx_trust_store_load_from_certdata("data/mozilla_certdata.txt\x00" as *u8, 512, K_MAGIC_4194304) 27 if r <= 0 { uc_w("trust store fail\n" as *u8); return 1 } 28 let store: *TrustStore = r as *TrustStore 29 30 let hbuf: *u8 = sys_mmap(K_MAGIC_262144); let hbox: *i64 = sys_mmap(16) as *i64 31 let jbuf: *u8 = sys_mmap(K_MAGIC_262144); let jbox: *i64 = sys_mmap(16) as *i64 32 uc_w(" fetching https://nishifamily.com/video + /video/app.v2.js ...\n" as *u8) 33 if lv_fetch("https://nishifamily.com/video\x00" as *u8, store, hbuf, K_MAGIC_262144, hbox)==0 { uc_w(" !! /video FETCH FAILED (the user cannot load the room)\n" as *u8); return 1 } 34 if lv_fetch("https://nishifamily.com/video/app.v2.js\x00" as *u8, store, jbuf, K_MAGIC_262144, jbox)==0 { uc_w(" !! app.v2.js FETCH FAILED\n" as *u8); return 1 } 35 let hn: i64 = hbox[0]; let jn: i64 = jbox[0] 36 uc_w(" served: index=" as *u8); uc_n(hn); uc_w("B app.v2.js=" as *u8); uc_n(jn); uc_w("B\n" as *u8) 37 38 uc_w(" BUTTON WIRING on SERVED bytes:\n" as *u8) 39 let tally: *i64 = sys_mmap(32) as *i64; tally[0]=0; tally[1]=0 40 uc_check_buttons(hbuf, hn, jbuf, jn, tally) 41 let dead: i64 = tally[1] 42 uc_w(" INIT-CRASH SAFETY on SERVED bytes:\n" as *u8) 43 let init_bad: i64 = uc_check_init(jbuf, jn) 44 45 // served app.v2.js must not be TRUNCATED: the last top-level thing (the IIFE close) must be present. 46 var trunc: i64 = 0 47 if uc_has(jbuf, jn, "})();" as *u8)==0 { trunc=1; uc_w(" !! app.v2.js TRUNCATED (no IIFE close -> syntax error -> dead page)\n" as *u8) } else { uc_w(" app.v2.js tail intact (IIFE closes)\n" as *u8) } 48 49 uc_w(" SCORE(live): " as *u8); uc_n(tally[0]-dead); uc_w("/" as *u8); uc_n(tally[0]); uc_w(" wired dead=" as *u8); uc_n(dead); uc_w(" init_risk=" as *u8); uc_n(init_bad); uc_w(" trunc=" as *u8); uc_n(trunc); uc_w("\n" as *u8) 50 var green: i64 = 1 51 if dead != 0 { green = 0 } 52 if init_bad != 0 { green = 0 } 53 if trunc != 0 { green = 0 } 54 if tally[0] <= 0 { green = 0 } 55 if green==1 { uc_w("UI-LIVE-VERIFY verdict=GREEN -- the LIVE page the user gets is wired + init crash-safe + intact (top-down eye)\n" as *u8); return 0 } 56 uc_w("UI-LIVE-VERIFY verdict=RED -- what SHIPPED to the user is broken (deploy drift / dead button) -- caught top-down\n" as *u8) 57 return 1 58}