code wiki / _hdl_build / nx_comms_hwup_census.nx
nx_comms_hwup_census.nx source
↩ module page · 122 lines · 7397 B
1// nx_comms_hwup_census.nx -- the HARDWARE-UP RUNG LADDER for the comms stack (operator 2026-07-02:
2// "get the hardware foundational rung each rung up through software etc to full s class exceed").
3// Every rung carries REAL evidence (a measured/gate log via the last-verdict rule) -- nothing asserted:
4// R0 HARDWARE codec compute on THIS CPU (nx_lpc_speed_bench: 77x/241x realtime-48k measured).
5// Honest boundary: camera/mic + NIC ride the browser/OS -- named, not claimed.
6// R1 CODEC CORE the shipped wasm core is complete + faithful (sovereign VM diff, 4/4).
7// R2 LOSS ENGINE RS-FEC relay organ proven (k=8,m=2, 4/4 KATs).
8// R3 INTL TRANSPORT measured on the international profiles vs the rival classes (nx_intl_h2h):
9// live-TCP BEHIND, FEC-target matches rival-UDP + beats rival-TCP-fallback.
10// R4 QOE GOVERNOR MOS model + anti-liar (ROOMQOEGATE).
11// R5 LAST MILE the JS surface ratchet (may only shrink toward the core).
12// R6 LIVE OPS fresh funcheck video PASS (a dead room fails this census).
13// THE GAP ROW: the FEC engine is NOT wired into the live daemon -- detected mechanically (self-flips
14// when wired). That wiring is the named s-class-exceed move for international interactions.
15// expect_exit: 0 license_tier: ORIGINAL
16import "nx_syscalls.nx"
17import "nx_gate_green.nx"
18const K_MAGIC_8192: i64 = 8192
19const K_MAGIC_86400: i64 = 86400
20
21func slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
22func pw(s: *u8) -> i64 { sys_write(1,s,slen(s)); return 0 }
23func pn(v: i64) -> i64 {
24 let b: *u8=sys_mmap(28); var m: i64=v; if m<0{sys_write(1,"-" as *u8,1);m=0-m}
25 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}
26 var i: i64=0; while i<k{b[i]=t[k-1-i];i=i+1} sys_write(1,b,k); return 0 }
27func contains(hay: *u8, n: i64, needle: *u8) -> i64 {
28 let nl: i64=slen(needle); if nl==0 {return 1}
29 var i: i64=0
30 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 }
31 return 0 }
32func filehas(path: *u8, pat: *u8) -> i64 {
33 let box: *i64 = sys_mmap(16) as *i64; box[0]=0
34 let b: *u8 = sys_read_file(path, box)
35 if (b as i64)==0 { return 0 }
36 return contains(b, box[0], pat) }
37func cr_find_eol(b: *u8, n: i64, st: i64) -> i64 { var i: i64=st; while i<n { if (b[i] as i64)==10 {return i} i=i+1 } return n }
38func cr_live2(logpath: *u8, maxage_s: i64) -> i64 {
39 let box: *i64 = sys_mmap(16) as *i64; box[0]=0
40 let b: *u8 = sys_read_file(logpath, box)
41 if (b as i64)==0 { return 0 }
42 let n: i64 = box[0]
43 var ls: i64 = 0 - 1
44 var linestart: i64 = 0
45 var i: i64 = 0
46 while i <= n {
47 var eol: i64 = 0
48 if i==n { eol=1 } else { if (b[i] as i64)==10 { eol=1 } }
49 if eol==1 {
50 if i>linestart { if (b[linestart] as i64)==70 { if (b[linestart+1] as i64)==85 { ls=linestart } } }
51 linestart = i+1
52 }
53 i = i + 1
54 }
55 if ls<0 { return 0 }
56 let le: i64 = cr_find_eol(b, n, ls)
57 let ln: *u8 = sys_mmap(K_MAGIC_8192)
58 var k: i64 = 0
59 while ls+k<le { ln[k]=b[ls+k]; k=k+1 }
60 ln[k]=0 as u8
61 var ep: i64 = 0
62 var p: i64 = 0
63 var found: i64 = 0
64 while p+6<k {
65 if ln[p]==(101 as u8) { if ln[p+1]==(112 as u8) { if ln[p+2]==(111 as u8) { if ln[p+3]==(99 as u8) { if ln[p+4]==(104 as u8) { if ln[p+5]==(61 as u8) {
66 found=1
67 var q: i64 = p+6
68 while q<k { let c: i64 = ln[q] as i64; if c>=48 { if c<=57 { ep=ep*10+(c-48); q=q+1 } else { q=k } } else { q=k } }
69 p = k
70 } } } } } }
71 if p<k { p=p+1 }
72 }
73 if found==0 { return 0 }
74 let now: i64 = sys_now_realtime_sec()
75 var age: i64 = now - ep
76 if age<0 { age = 0 - age }
77 if age > maxage_s { return 0 }
78 if contains(ln, k, "video_room=PASS" as *u8)==0 { return 0 }
79 if contains(ln, k, "video_appjs=PASS" as *u8)==0 { return 0 }
80 return 1 }
81
82func rung(name: *u8, log: *u8, anchor: *u8, failp: *i64) -> i64 {
83 let g: i64 = gg_gate_green(log, anchor, "verdict=GREEN" as *u8)
84 pw(" " as *u8)
85 if g==1 { pw("[GREEN] " as *u8) } else { pw("[RED ] " as *u8); failp[0]=failp[0]+1 }
86 pw(name); pw("\n" as *u8)
87 return g }
88
89func main() -> i64 {
90 pw("=== nx_comms_hwup_census: the comms stack, hardware rung UP (every rung = real evidence) ===\n" as *u8)
91 let failp: *i64 = sys_mmap(16) as *i64
92 failp[0] = 0
93
94 rung("R0 HARDWARE codec compute measured on this CPU (LPCBENCH 77x enc / 241x dec realtime-48k)" as *u8, "knowledge/status/lpc_speed.log" as *u8, "LPCBENCH" as *u8, failp)
95 pw(" (honest boundary: camera/mic + NIC ride the browser/OS -- named, not claimed sovereign)\n" as *u8)
96 rung("R1 CODEC CORE shipped wasm complete + faithful (sovereign VM diff 4/4, incl new ladder) " as *u8, "knowledge/status/vc_wasm_vm.log" as *u8, "VC-WASM-VM" as *u8, failp)
97 rung("R2 LOSS ENGINE RS-FEC relay organ k=8 m=2 (built, KATs 4/4) " as *u8, "knowledge/status/room_fec_relay.log" as *u8, "ROOMFECRELAY" as *u8, failp)
98 rung("R3 INTL TRANSPORT measured vs rival classes on 4 intl profiles (nx_intl_h2h) " as *u8, "knowledge/status/intl_h2h.log" as *u8, "INTLH2H" as *u8, failp)
99 rung("R4 QOE GOVERNOR MOS model + anti-liar " as *u8, "knowledge/status/room_qoe.log" as *u8, "ROOMQOEGATE" as *u8, failp)
100 rung("R5 LAST MILE JS ratchet (surface may only shrink toward the core) " as *u8, "knowledge/status/lastmile_ratchet.log" as *u8, "LASTMILE" as *u8, failp)
101 let live: i64 = cr_live2("knowledge/status/funcheck.log" as *u8, K_MAGIC_86400)
102 pw(" " as *u8)
103 if live==1 { pw("[GREEN] " as *u8) } else { pw("[RED ] " as *u8); failp[0]=failp[0]+1 }
104 pw("R6 LIVE OPS fresh funcheck video PASS (dead room fails this census) \n" as *u8)
105
106 // THE GAP ROW (self-flips): is the FEC relay wired into the live daemon?
107 let wired: i64 = filehas("runtime/_hdl_build/nx_sites_daemon_v2.nx" as *u8, "fec_relay" as *u8)
108 pw(" " as *u8)
109 if wired==1 { pw("[WIRED ] " as *u8) } else { pw("[GAP ] " as *u8) }
110 pw("FEC engine wired into the LIVE daemon -- THE s-class-exceed move for international calls\n" as *u8)
111
112 // controls
113 var fail: i64 = failp[0]
114 if gg_gate_green("knowledge/status/lpc_speed.log" as *u8, "LPCBENCH" as *u8, "verdict=GREEN" as *u8)==1 { pw("POS-control: GREEN\n" as *u8) } else { pw("POS-control FAILED -> RED\n" as *u8); fail=fail+1 }
115 if gg_gate_green("knowledge/status/lpc_speed.log" as *u8, "LPCBENCH" as *u8, "verdict=ZZBOGUS" as *u8)==0 { pw("NEG-control bogus-pattern: GREEN\n" as *u8) } else { pw("NEG-control FAILED -> RED\n" as *u8); fail=fail+1 }
116 if gg_gate_green("knowledge/status/no_such.log" as *u8, "X" as *u8, "verdict=GREEN" as *u8)==0 { pw("NEG-control missing-log: GREEN\n" as *u8) } else { pw("NEG-control FAILED -> RED\n" as *u8); fail=fail+1 }
117
118 pw("COMMS-HWUP-CENSUS rungs=7 live=" as *u8); pn(live); pw(" fec_wired=" as *u8); pn(wired); pw(" fail=" as *u8); pn(fail)
119 if fail==0 { pw(" verdict=GREEN -- every rung evidenced hardware-up; the GAP row names the exceed move\n" as *u8); return 0 }
120 pw(" verdict=RED\n" as *u8)
121 return 1
122}