code wiki / (root) / nx_synth_live_check.nx

nx_synth_live_check.nx source

↩ module page · 82 lines · 4673 B

1// nx_synth_live_check.nx -- sovereign LIVE check of nishifamily.com/synth (the synthetic-humans lab page) via 2// our own TLS client (per-surface autotest pattern, clone of nx_games_url_check). Fetches the page + all three 3// assets, asserts 200 + sane byte counts + the page marker. This is the publish-loop proof: unlisted = not 4// published. license_tier: ORIGINAL expect_exit: 0 5import "nx_syscalls.nx" 6import "nx_x509_trust_store.nx" 7import "nx_trust_store_load_from_certdata.nx" 8import "nx_https_fetch_follow.nx" 9const K_MAGIC_4194304: i64 = 4194304 10const K_MAGIC_6000: i64 = 6000 11const K_MAGIC_200000: i64 = 200000 12const K_MAGIC_50000: i64 = 50000 13const K_MAGIC_30000: i64 = 30000 14const K_MAGIC_500000: i64 = 500000 15const K_MAGIC_700000: i64 = 700000 16 17func lw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 18func ln(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)} let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1} sys_write(1,bb,k); return 0 } 19func lfind(buf: *u8, n: i64, needle: *u8) -> i64 { 20 var nl: i64 = 0 21 while needle[nl] != (0 as u8) { nl = nl + 1 } 22 if nl == 0 { return 0 } 23 var i: i64 = 0 24 while i + nl <= n { 25 var j: i64 = 0 26 var ok: i64 = 1 27 while j < nl { if (buf[i+j]&0xff) != (needle[j]&0xff) { ok = 0; j = nl } else { j = j + 1 } } 28 if ok == 1 { return i } 29 i = i + 1 30 } 31 return 0 - 1 32} 33 34func main() -> i64 { 35 let r: i64 = nx_trust_store_load_from_certdata("data/mozilla_certdata.txt" as *u8, 512, K_MAGIC_4194304) 36 if r <= 0 { lw("SYNTH-CHECK: certdata load failed\n"); sys_exit(1); return 1 } 37 let store: *TrustStore = r as *TrustStore 38 let cap: i64 = K_MAGIC_4194304 39 let out: *u8 = sys_mmap(cap) 40 let status: *i64 = sys_mmap(8) as *i64 41 var fails: i64 = 0 42 43 let n1: i64 = nx_https_fetch_follow("https://nishifamily.com/synth" as *u8, store, out, cap, 6, status) 44 lw("/synth status="); ln(status[0]); lw(" bytes="); ln(n1) 45 var ok1: i64 = 0 46 if status[0] == 200 { if n1 >= K_MAGIC_6000 { if lfind(out, n1, "Synth Lab" as *u8) >= 0 { ok1 = 1 } } } 47 if ok1 == 1 { lw(" OK (page + marker)\n") } else { fails = fails + 1; lw(" FAIL\n") } 48 49 let n2: i64 = nx_https_fetch_follow("https://nishifamily.com/synth/wave.png" as *u8, store, out, cap, 6, status) 50 lw("/synth/wave.png status="); ln(status[0]); lw(" bytes="); ln(n2) 51 var ok2: i64 = 0 52 if status[0] == 200 { if n2 >= K_MAGIC_200000 { if (out[0]&0xff) == 137 { ok2 = 1 } } } 53 if ok2 == 1 { lw(" OK (full APNG)\n") } else { fails = fails + 1; lw(" FAIL\n") } 54 55 let n3: i64 = nx_https_fetch_follow("https://nishifamily.com/synth/wave_photo.png" as *u8, store, out, cap, 6, status) 56 lw("/synth/wave_photo status="); ln(status[0]); lw(" bytes="); ln(n3) 57 var ok3: i64 = 0 58 if status[0] == 200 { if n3 >= K_MAGIC_50000 { if (out[0]&0xff) == 137 { ok3 = 1 } } } 59 if ok3 == 1 { lw(" OK (full APNG)\n") } else { fails = fails + 1; lw(" FAIL\n") } 60 61 let n4: i64 = nx_https_fetch_follow("https://nishifamily.com/synth/variants.png" as *u8, store, out, cap, 6, status) 62 lw("/synth/variants status="); ln(status[0]); lw(" bytes="); ln(n4) 63 var ok4: i64 = 0 64 if status[0] == 200 { if n4 >= K_MAGIC_30000 { if (out[0]&0xff) == 137 { ok4 = 1 } } } 65 if ok4 == 1 { lw(" OK (bestiary sheet)\n") } else { fails = fails + 1; lw(" FAIL\n") } 66 67 let n5: i64 = nx_https_fetch_follow("https://nishifamily.com/synth/wolf.stl" as *u8, store, out, cap, 6, status) 68 lw("/synth/wolf.stl status="); ln(status[0]); lw(" bytes="); ln(n5) 69 var ok5: i64 = 0 70 if status[0] == 200 { if n5 >= K_MAGIC_500000 { if lfind(out, 64, "solid nishi_variant" as *u8) >= 0 { ok5 = 1 } } } 71 if ok5 == 1 { lw(" OK (watertight STL)\n") } else { fails = fails + 1; lw(" FAIL\n") } 72 73 let n6: i64 = nx_https_fetch_follow("https://nishifamily.com/synth/direwolf.stl" as *u8, store, out, cap, 6, status) 74 lw("/synth/direwolf status="); ln(status[0]); lw(" bytes="); ln(n6) 75 var ok6: i64 = 0 76 if status[0] == 200 { if n6 >= K_MAGIC_700000 { if lfind(out, 64, "solid nishi_variant" as *u8) >= 0 { ok6 = 1 } } } 77 if ok6 == 1 { lw(" OK (watertight STL)\n") } else { fails = fails + 1; lw(" FAIL\n") } 78 79 if fails == 0 { lw("SYNTH-LIVE-CHECK 6/6 GREEN -- nishifamily.com/synth is LIVE with clips + bestiary + STL downloads, over our own TLS\n"); sys_exit(0); return 0 } 80 lw("SYNTH-LIVE-CHECK RED fails="); ln(fails); lw("\n") 81 sys_exit(1); return 1 82}