code wiki / _hdl_build / nx_video_ui_core_gate.nx
nx_video_ui_core_gate.nx source
↩ module page · 66 lines · 3665 B
1// nx_video_ui_core_gate.nx -- SOVEREIGN verification of the call-UI logic (operator 2026-07-04: "build for
2// NishiOS + the Nishi browser without third parties"). Drives INTENTS over the state machine and asserts
3// state + derived layout -- NO DOM, NO addEventListener, NO WebSocket, NO browser. Because it tests the
4// sovereign core (not an adapter), this exact gate proves the "2-person = remote full + self PiP" law and
5// the mic/cam/roster logic on the browser TODAY and on NishiOS TOMORROW, unchanged. This is the
6// verification that survives the sovereign transition. 0=GREEN / 1=RED.
7import "nx_syscalls.nx"
8import "nx_video_ui_core.nx"
9
10func g_p(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
11func g_n(v: i64) -> i64 {
12 var m: i64=v; if m<0{g_p("-\x00" as *u8);m=0-m}
13 let t: *u8=sys_mmap(24); var k: i64=0; if m==0{t[0]=48 as u8;k=1} else {while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1}}
14 let o: *u8=sys_mmap(24); var j: i64=0; while j<k{o[j]=t[k-1-j];j=j+1} sys_write(1,o,k); return 0 }
15func chk(cond: i64, name: *u8, pp: *i64, tp: *i64) -> i64 {
16 tp[0]=tp[0]+1; g_p(name)
17 if cond==1 { pp[0]=pp[0]+1; g_p(" ok\n\x00" as *u8) } else { g_p(" FAIL\n\x00" as *u8) }
18 return 0 }
19
20func main() -> i64 {
21 g_p("=== nx_video_ui_core_gate: SOVEREIGN intent-driven UI verify (no DOM, NishiOS-ready) ===\n\x00" as *u8)
22 let pp: *i64 = sys_mmap(8) as *i64; pp[0]=0
23 let tp: *i64 = sys_mmap(8) as *i64; tp[0]=0
24 let s: *i64 = sys_mmap(64) as *i64
25 uic_init(s)
26
27 // start alone -> SOLO, mic+cam on
28 chk(uic_layout(s)==LAYOUT_SOLO, "init -> SOLO layout\x00" as *u8, pp, tp)
29 chk(uic_mic(s)==1, "init mic on\x00" as *u8, pp, tp)
30
31 // NEG: swap while SOLO is meaningless -> stays 0 (core decides, not the adapter)
32 uic_intent(s, UI_SWAP_VIEW)
33 chk(uic_swapped(s)==0, "NEG swap in SOLO -> no-op\x00" as *u8, pp, tp)
34
35 // a 2ND PERSON JOINS -> DUO. THIS is the operator's requirement: remote full-screen + self in corner.
36 uic_intent(s, UI_PEER_JOIN)
37 chk(uic_layout(s)==LAYOUT_DUO, "peer joins -> DUO (remote FULL + self PiP)\x00" as *u8, pp, tp)
38
39 // tap-to-swap works in DUO
40 uic_intent(s, UI_SWAP_VIEW)
41 chk(uic_swapped(s)==1, "swap in DUO -> self becomes full\x00" as *u8, pp, tp)
42
43 // mute + cam off toggle state (the buttons, as intents)
44 uic_intent(s, UI_TOGGLE_MIC); chk(uic_mic(s)==0, "toggle mic -> off\x00" as *u8, pp, tp)
45 uic_intent(s, UI_TOGGLE_CAM); chk(uic_cam(s)==0, "toggle cam -> off\x00" as *u8, pp, tp)
46 uic_intent(s, UI_TOGGLE_MIC); chk(uic_mic(s)==1, "toggle mic again -> on\x00" as *u8, pp, tp)
47
48 // a 3RD PERSON -> GRID; swap no longer meaningful
49 uic_intent(s, UI_PEER_JOIN)
50 chk(uic_layout(s)==LAYOUT_GRID, "3rd peer -> GRID\x00" as *u8, pp, tp)
51 chk(uic_swapped(s)==0, "swap ignored outside DUO\x00" as *u8, pp, tp)
52
53 // people leave -> back down through DUO -> SOLO
54 uic_intent(s, UI_PEER_LEAVE)
55 chk(uic_layout(s)==LAYOUT_DUO, "one leaves -> DUO again\x00" as *u8, pp, tp)
56 uic_intent(s, UI_PEER_LEAVE)
57 chk(uic_layout(s)==LAYOUT_SOLO, "last leaves -> SOLO\x00" as *u8, pp, tp)
58
59 // NEG: an unknown intent is an HONEST error, never a silent no-op
60 chk(uic_intent(s, 99)==1, "NEG unknown intent -> error (teeth)\x00" as *u8, pp, tp)
61
62 g_p(" SCORE: \x00" as *u8); g_n(pp[0]); g_p("/\x00" as *u8); g_n(tp[0]); g_p("\n\x00" as *u8)
63 if pp[0]==tp[0] { g_p("UI-CORE-GATE verdict=GREEN -- call-UI logic is SOVEREIGN (intents over state), verified with NO browser -> runs identical on NishiOS\n\x00" as *u8); return 0 }
64 g_p("UI-CORE-GATE verdict=RED\n\x00" as *u8)
65 return 1
66}