code wiki / _hdl_build / nx_video_lanes_gate.nx
nx_video_lanes_gate.nx source
↩ module page · 54 lines · 3491 B
1// nx_video_lanes_gate.nx -- source gate for the STAGED TIER-2 client (app.v2.js): striped shard-lanes
2// + core FEC + core-packed 0x43 chat. Source-truth only (the file is STAGED, not live -- flip =
3// point index.html at it after a browser smoke; the live room stays on the proven app.js).
4// T1 lane rooms (room, room#1, room#2) T2 TX = core vc_fecs_pack -> 10 shards striped (0x46)
5// T3 RX = core vc_fecrx_add collector T4 chat TX = core vc_chat_pack (0x43)
6// T5 chat RX = core vc_chat_parse T6 tier surfaced in the UI (skilled-fallback visibility)
7// T7 NEG: JSON chat is GONE from the v2 wire (type:"chat" absent) T8 NEG: bogus pattern absent
8// T9 the LIVE app.js is UNTOUCHED by this staging (still carries its chat build = ratchet-safe)
9// expect_exit: 0 license_tier: ORIGINAL
10import "nx_syscalls.nx"
11
12func slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
13func pw(s: *u8) -> i64 { sys_write(1,s,slen(s)); return 0 }
14func pn(v: i64) -> i64 {
15 let b: *u8=sys_mmap(28); var m: i64=v; if m<0{sys_write(1,"-" as *u8,1);m=0-m}
16 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}
17 var i: i64=0; while i<k{b[i]=t[k-1-i];i=i+1} sys_write(1,b,k); return 0 }
18func contains(hay: *u8, n: i64, needle: *u8) -> i64 {
19 let nl: i64=slen(needle); if nl==0 {return 1}
20 var i: i64=0
21 while i+nl<=n { var j: i64=0; var ok: i64=1; while j<nl { if hay[i+j]!=needle[j]{ok=0;j=nl} else {j=j+1} } if ok==1{return 1} i=i+1 }
22 return 0 }
23func filehas(path: *u8, pat: *u8) -> i64 {
24 let box: *i64 = sys_mmap(16) as *i64; box[0]=0
25 let b: *u8 = sys_read_file(path, box)
26 if (b as i64)==0 { return 0 }
27 return contains(b, box[0], pat) }
28func check(name: *u8, path: *u8, pat: *u8, want: i64, pass: *i64) -> i64 {
29 let got: i64 = filehas(path, pat)
30 pw(" " as *u8)
31 if got==want { pw("PASS " as *u8); pass[0]=pass[0]+1 } else { pw("FAIL " as *u8) }
32 pw(name); pw("\n" as *u8)
33 return 0 }
34
35func main() -> i64 {
36 pw("=== nx_video_lanes_gate: STAGED tier-2 client wiring (source-truth) ===\n" as *u8)
37 let pass: *i64 = sys_mmap(16) as *i64
38 pass[0]=0
39 let V2: *u8 = "sites/nishifamily/video/app.v2.js"
40 let V1: *u8 = "sites/nishifamily/video/app.js"
41 check("T1 shard-lane rooms (room + #l suffix) " as *u8, V2, "room + (l ? \"#\" + l : \"\")" as *u8, 1, pass)
42 check("T2 TX: core vc_fecs_pack striped as kind 0x46 " as *u8, V2, "vc_fecs_pack" as *u8, 1, pass)
43 check("T3 RX: core vc_fecrx_add collector " as *u8, V2, "vc_fecrx_add" as *u8, 1, pass)
44 check("T4 chat TX: core vc_chat_pack (0x43) " as *u8, V2, "vc_chat_pack" as *u8, 1, pass)
45 check("T5 chat RX: core vc_chat_parse " as *u8, V2, "vc_chat_parse" as *u8, 1, pass)
46 check("T6 tier surfaced in UI (tierNow) " as *u8, V2, "tierNow" as *u8, 1, pass)
47 check("T7 NEG: JSON chat GONE from the v2 wire " as *u8, V2, "type: \"chat\"" as *u8, 0, pass)
48 check("T8 NEG: bogus pattern absent " as *u8, V2, "zz_bogus_lanes_qq" as *u8, 0, pass)
49 check("T9 LIVE app.js untouched (still the chat build) " as *u8, V1, "type: \"chat\"" as *u8, 1, pass)
50 pw("VIDEO-LANES-GATE pass=" as *u8); pn(pass[0]); pw("/9" as *u8)
51 if pass[0]==9 { pw(" verdict=GREEN -- v2 wiring staged; flip after browser smoke\n" as *u8); return 0 }
52 pw(" verdict=RED\n" as *u8)
53 return 1
54}