code wiki / _hdl_build / nx_video_parity_census.nx

nx_video_parity_census.nx source

↩ module page · 87 lines · 6230 B

1// nx_video_parity_census.nx -- MECHANICAL carry-over guard (operator 2026-07-04: "make sure we arent 2// building into html and js but that we emit so wherever we embed or use it all functionality is carried 3// over"). The /video ROOM (app.v2.js) and the <nishi-video> EMBED (nishi-video.js bundle) are two shims 4// over the SAME sovereign wasm core; features must be present in BOTH or the embed silently lags the room 5// (the divergence that let the duo-PiP layout ship to the room but not the embed). This census checks each 6// shared FEATURE MARKER in both surfaces: PARITY (both) / ROOM-ONLY / EMBED-ONLY / NEITHER. Any non-PARITY 7// row = a carry-over break to fix. NEG-CONTROL: an impossible marker must be NEITHER (checker has teeth). 8// This is monitoring APPLIED to carry-over -- it runs in the keep-up loop so drift is CAUGHT, not prayed. 9// expect_exit: 0 = all shared features at parity + neg-control fired. license_tier: ORIGINAL 10import "nx_syscalls.nx" 11 12func cw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 13func cn(v: i64) -> i64 { 14 let b: *u8=sys_mmap(28); var m: i64=v; if m<0{sys_write(1,"-" as *u8,1);m=0-m} 15 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} 16 var i: i64=0; while i<k{b[i]=t[k-1-i];i=i+1} sys_write(1,b,k); return 0 } 17func has(hay: *u8, n: i64, needle: *u8) -> i64 { 18 var nl: i64=0; while needle[nl]!=(0 as u8){nl=nl+1} 19 var i: i64=0 20 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 } 21 return 0 } 22 23// prow: feature must be in BOTH surfaces. The ROOM surface = index.html + app.v2.js (CSS lives in the 24// HTML, JS logic in the script) -> present if EITHER room file has it. The EMBED = one self-contained 25// bundle. tally[0]=parity tally[1]=total tally[2]=breaks 26func prow2(name: *u8, rjs: *u8, rjn: i64, rhtml: *u8, rhn: i64, emb: *u8, en: i64, marker: *u8, tally: *i64) -> i64 { 27 var r: i64 = has(rjs, rjn, marker) 28 if r == 0 { r = has(rhtml, rhn, marker) } 29 let e: i64 = has(emb, en, marker) 30 cw(" " as *u8); cw(name) 31 tally[1] = tally[1] + 1 32 if r == 1 { if e == 1 { cw(" PARITY\n" as *u8); tally[0] = tally[0] + 1; return 0 } } 33 if r == 1 { if e == 0 { cw(" !! ROOM-ONLY (embed lags)\n" as *u8); tally[2] = tally[2] + 1; return 0 } } 34 if r == 0 { if e == 1 { cw(" !! EMBED-ONLY (room lags)\n" as *u8); tally[2] = tally[2] + 1; return 0 } } 35 cw(" !! NEITHER\n" as *u8); tally[2] = tally[2] + 1 36 return 0 } 37 38func main() -> i64 { 39 cw("=== nx_video_parity_census: room (app.v2.js) vs embed (nishi-video.js) feature carry-over ===\n" as *u8) 40 let rbox: *i64 = sys_mmap(16) as *i64 41 let room: *u8 = sys_read_file("sites/nishifamily/video/app.v2.js" as *u8, rbox) 42 if (room as i64)==0 { cw("no app.v2.js\n" as *u8); return 1 } 43 let rn: i64 = rbox[0] 44 let hbox: *i64 = sys_mmap(16) as *i64 45 let rhtml: *u8 = sys_read_file("sites/nishifamily/video/index.html" as *u8, hbox) 46 if (rhtml as i64)==0 { cw("no index.html\n" as *u8); return 1 } 47 let rhn: i64 = hbox[0] 48 let ebox: *i64 = sys_mmap(16) as *i64 49 let emb: *u8 = sys_read_file("web_assets/nishi-video.js" as *u8, ebox) 50 if (emb as i64)==0 { cw("no nishi-video.js (run nx_video_embed_bundle)\n" as *u8); return 1 } 51 let en: i64 = ebox[0] 52 let t: *i64 = sys_mmap(32) as *i64 53 t[0]=0; t[1]=0; t[2]=0 54 55 cw(" SHARED SHIM FEATURES (must be in BOTH surfaces; room = index.html+app.v2.js):\n" as *u8) 56 prow2("2-person duo-PiP layout (callLayout)" as *u8, room, rn, rhtml, rhn, emb, en, "callLayout" as *u8, t) 57 prow2("resource-intelligence plan (mb_plan)" as *u8, room, rn, rhtml, rhn, emb, en, "mb_plan" as *u8, t) 58 prow2("device budget sensors (deviceBudget/replan)" as *u8, room, rn, rhtml, rhn, emb, en, "replan" as *u8, t) 59 prow2("audio-only scale-down (planVideoOn)" as *u8, room, rn, rhtml, rhn, emb, en, "planVideoOn" as *u8, t) 60 prow2("core wire framing (vc_wire_pack)" as *u8, room, rn, rhtml, rhn, emb, en, "vc_wire_pack" as *u8, t) 61 prow2("FEC shard reassembly (vc_fecrx_add)" as *u8, room, rn, rhtml, rhn, emb, en, "vc_fecrx_add" as *u8, t) 62 prow2("FEC shard pack (vc_fecs_pack)" as *u8, room, rn, rhtml, rhn, emb, en, "vc_fecs_pack" as *u8, t) 63 prow2("LPC audio encode (vc_lpc_encode)" as *u8, room, rn, rhtml, rhn, emb, en, "vc_lpc_encode" as *u8, t) 64 prow2("self-view mirror (scaleX(-1))" as *u8, room, rn, rhtml, rhn, emb, en, "scaleX(-1)" as *u8, t) 65 prow2("adaptive ladder (vc_ladder_step)" as *u8, room, rn, rhtml, rhn, emb, en, "vc_ladder_step" as *u8, t) 66 prow2("SOVEREIGN codec TX 0x57 (txVvFrame)" as *u8, room, rn, rhtml, rhn, emb, en, "txVvFrame" as *u8, t) 67 prow2("SOVEREIGN codec RX chain (vvWaitKey)" as *u8, room, rn, rhtml, rhn, emb, en, "vvWaitKey" as *u8, t) 68 prow2("codec capability handshake (vcAll)" as *u8, room, rn, rhtml, rhn, emb, en, "vcAll" as *u8, t) 69 prow2("lane failover (bestLane)" as *u8, room, rn, rhtml, rhn, emb, en, "bestLane" as *u8, t) 70 71 // NEG-CONTROL: impossible marker -> NEITHER (a break), proving the checker isn't blind-passing 72 let negt: *i64 = sys_mmap(32) as *i64 73 negt[0]=0; negt[1]=0; negt[2]=0 74 prow2("NEG-CONTROL (impossible; MUST be NEITHER)" as *u8, room, rn, rhtml, rhn, emb, en, "zz_no_such_feature_7x9q" as *u8, negt) 75 var neg_ok: i64 = 0 76 if negt[2] == 1 { neg_ok = 1 } // it MUST have registered as a break 77 78 let permille: i64 = t[0] * 1000 / t[1] 79 cw(" PARITY: " as *u8); cn(t[0]); cw("/" as *u8); cn(t[1]); cw(" = " as *u8); cn(permille); cw("permille carry-over breaks=" as *u8); cn(t[2]); cw("\n" as *u8) 80 var green: i64 = 1 81 if t[2] != 0 { green = 0 } 82 if neg_ok != 1 { green = 0 } 83 if green == 1 { cw("VIDEO-PARITY-CENSUS verdict=GREEN -- every shared feature carries to BOTH the room AND the embed\n" as *u8); return 0 } 84 if neg_ok != 1 { cw("VIDEO-PARITY-CENSUS verdict=RED -- neg-control did not fire (checker blind)\n" as *u8); return 1 } 85 cw("VIDEO-PARITY-CENSUS verdict=RED -- " as *u8); cn(t[2]); cw(" feature(s) do NOT carry over (fix the lagging surface)\n" as *u8) 86 return 1 87}