code wiki / _hdl_build / nx_comms_rival_census.nx
nx_comms_rival_census.nx source
↩ module page · 188 lines · 13302 B
1// nx_comms_rival_census.nx -- MEASURED rival-benchmark census: the nishifamily.com/video comms stack
2// vs JITSI / ZOOM / TELEGRAM / DISCORD (operator 2026-07-02: "benchmarked against the best ... have all
3// of their features like texting and contacts"). Mirrors nx_video_exceed_census_gate honesty + EXTENDS it:
4// (1) GROUNDED: refuses to run unless the banked rival research (knowledge/fetched/rival_*.raw, 17
5// sources fetched by nx_comms_rival_fetch) is on disk -- no assumed rival facts (Rule 4).
6// (2) LIVE AXIS: reads the LAST persisted FUNCHECK line (knowledge/status/funcheck.log) and requires
7// video_room=PASS AND video_appjs=PASS AND age<24h -- a DEAD room can NEVER score GREEN here
8// (closes the false-GREEN the organ-on-disk census admits to).
9// (3) PER-RIVAL PARITY: each feature row carries which rivals have it; rollup = permille of each
10// rival's features we ALSO have, + the honest BEHIND build-list.
11// Evidence kinds: 1=organ-on-disk 2=file-contains(pattern) 3=declared ABSENT (build target; rivals have).
12// Controls: POS(known organ), NEG(bogus path), NEG(bogus pattern), NEG(bogus funcheck log -> UNKNOWN).
13// expect_exit: 0 license_tier: ORIGINAL
14import "nx_syscalls.nx"
15const K_MAGIC_8192: i64 = 8192
16const K_MAGIC_86400: i64 = 86400
17
18func slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
19func pw(s: *u8) -> i64 { sys_write(1,s,slen(s)); return 0 }
20func pn(v: i64) -> i64 {
21 let b: *u8=sys_mmap(28); var m: i64=v; if m<0{sys_write(1,"-" as *u8,1);m=0-m}
22 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}
23 var i: i64=0; while i<k{b[i]=t[k-1-i];i=i+1} sys_write(1,b,k); return 0 }
24func have(path: *u8) -> i64 { let fd: i64=sys_openat_rd(path); if fd<0 {return 0} sys_close(fd); return 1 }
25func contains(hay: *u8, n: i64, needle: *u8) -> i64 {
26 let nl: i64=slen(needle); if nl==0 {return 1}
27 var i: i64=0
28 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 }
29 return 0 }
30func filehas(path: *u8, pat: *u8) -> i64 {
31 let box: *i64 = sys_mmap(16) as *i64; box[0]=0
32 let b: *u8 = sys_read_file(path, box)
33 if (b as i64)==0 { return 0 }
34 return contains(b, box[0], pat) }
35
36// one feature row. st layout: [0]=J_tot [1]=J_have [2]=Z_tot [3]=Z_have [4]=T_tot [5]=T_have
37// [6]=D_tot [7]=D_have [8]=we_total [9]=we_have [10]=behind_count. Returns we(0/1).
38func cr_row(st: *i64, name: *u8, kind: i64, path: *u8, pat: *u8, jm: i64, zm: i64, tm: i64, dm: i64, note: *u8) -> i64 {
39 var we: i64 = 0
40 if kind==1 { we = have(path) }
41 if kind==2 { we = filehas(path, pat) }
42 st[8]=st[8]+1; if we==1 { st[9]=st[9]+1 }
43 if jm==1 { st[0]=st[0]+1; if we==1 {st[1]=st[1]+1} }
44 if zm==1 { st[2]=st[2]+1; if we==1 {st[3]=st[3]+1} }
45 if tm==1 { st[4]=st[4]+1; if we==1 {st[5]=st[5]+1} }
46 if dm==1 { st[6]=st[6]+1; if we==1 {st[7]=st[7]+1} }
47 pw(" [" as *u8)
48 if we==1 { pw("OURS " as *u8) } else { pw(" -- " as *u8) }
49 pw("] " as *u8); pw(name); pw(" rivals=" as *u8)
50 if jm==1 {pw("J" as *u8)} if zm==1 {pw("Z" as *u8)} if tm==1 {pw("T" as *u8)} if dm==1 {pw("D" as *u8)}
51 if jm+zm+tm+dm==0 { pw("none" as *u8) }
52 pw(" " as *u8); pw(note); pw("\n" as *u8)
53 if we==0 { if jm+zm+tm+dm>0 { st[10]=st[10]+1 } }
54 return we }
55
56func 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 }
57
58// LIVE axis: parse the LAST "FUNCHECK epoch=..." line of logpath; return 1 iff it has both
59// video_room=PASS and video_appjs=PASS AND epoch is within maxage_s of now. 0 = dead/stale/missing.
60
61func cr_live2(logpath: *u8, maxage_s: i64) -> i64 {
62 let box: *i64 = sys_mmap(16) as *i64; box[0]=0
63 let b: *u8 = sys_read_file(logpath, box)
64 if (b as i64)==0 { return 0 }
65 let n: i64 = box[0]
66 var ls: i64 = 0 - 1
67 var linestart: i64 = 0
68 var i: i64 = 0
69 while i <= n {
70 var eol: i64 = 0
71 if i==n { eol=1 } else { if (b[i] as i64)==10 { eol=1 } }
72 if eol==1 {
73 if i>linestart { if (b[linestart] as i64)==70 { if (b[linestart+1] as i64)==85 { ls=linestart } } }
74 linestart = i+1
75 }
76 i = i + 1
77 }
78 if ls<0 { return 0 }
79 let le: i64 = cr_find_eol(b, n, ls)
80 // copy the line to a zero-terminated buffer
81 let ln: *u8 = sys_mmap(K_MAGIC_8192)
82 var k: i64 = 0
83 while ls+k<le { ln[k]=b[ls+k]; k=k+1 }
84 ln[k]=0 as u8
85 // parse epoch=
86 var ep: i64 = 0
87 var p: i64 = 0
88 var found: i64 = 0
89 while p+6<k {
90 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) {
91 found=1
92 var q: i64 = p+6
93 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 } }
94 p = k
95 } } } } } }
96 if p<k { p=p+1 }
97 }
98 if found==0 { return 0 }
99 let now: i64 = sys_now_realtime_sec()
100 var age: i64 = now - ep
101 if age<0 { age = 0 - age }
102 if age > maxage_s { pw(" LIVE: stale funcheck record (age_s=" as *u8); pn(age); pw(") -> NOT live\n" as *u8); return 0 }
103 if contains(ln, k, "video_room=PASS" as *u8)==0 { return 0 }
104 if contains(ln, k, "video_appjs=PASS" as *u8)==0 { return 0 }
105 return 1 }
106
107func main() -> i64 {
108 pw("=== nx_comms_rival_census: MEASURED benchmark vs JITSI/ZOOM/TELEGRAM/DISCORD (grounded + live-guarded) ===\n" as *u8)
109 var fail: i64 = 0
110
111 // ---- (1) GROUNDING: the banked rival research must be on disk (nx_comms_rival_fetch, 17 sources) ----
112 var g: i64 = 0
113 g = g + have("knowledge/fetched/rival_jitsi.raw" as *u8)
114 g = g + have("knowledge/fetched/rival_zoom.raw" as *u8)
115 g = g + have("knowledge/fetched/rival_telegram.raw" as *u8)
116 g = g + have("knowledge/fetched/rival_discord.raw" as *u8)
117 g = g + have("knowledge/fetched/rival_mtproto.raw" as *u8)
118 g = g + have("knowledge/fetched/rival_signal_protocol.raw" as *u8)
119 g = g + have("knowledge/fetched/rival_matrix.raw" as *u8)
120 g = g + have("knowledge/fetched/rival_whatsapp.raw" as *u8)
121 g = g + have("knowledge/fetched/rival_jitsi_videobridge.raw" as *u8)
122 g = g + have("knowledge/fetched/rival_mediasoup.raw" as *u8)
123 g = g + have("knowledge/fetched/rival_janus.raw" as *u8)
124 g = g + have("knowledge/fetched/rival_bigbluebutton.raw" as *u8)
125 g = g + have("knowledge/fetched/rival_zoom_e2e.raw" as *u8)
126 g = g + have("knowledge/fetched/rival_instant_messaging.raw" as *u8)
127 g = g + have("knowledge/fetched/rival_presence.raw" as *u8)
128 g = g + have("knowledge/fetched/rival_contact_list.raw" as *u8)
129 g = g + have("knowledge/fetched/rival_im_comparison.raw" as *u8)
130 pw("GROUNDING: rival sources banked = " as *u8); pn(g); pw("/17" as *u8)
131 if g>=13 { pw(" OK\n" as *u8) } else { pw(" UNGROUNDED -> RED (run nx_comms_rival_fetch)\n" as *u8); fail=fail+1 }
132
133 // ---- (2) LIVE AXIS: the room must be ENTERABLE per the last persisted funcheck (fresh <24h) ----
134 let live: i64 = cr_live2("knowledge/status/funcheck.log" as *u8, K_MAGIC_86400)
135 pw("LIVE AXIS: video_room+video_appjs fresh-PASS = " as *u8)
136 if live==1 { pw("LIVE\n" as *u8) } else { pw("NOT-LIVE (dead/stale/missing) -> census cannot be GREEN\n" as *u8); fail=fail+1 }
137
138 // ---- (3) FEATURE ROWS vs the four rivals ----
139 let st: *i64 = sys_mmap(96) as *i64
140 var i: i64=0; while i<12 {st[i]=0; i=i+1}
141 pw("--- CORE CALL ---\n" as *u8)
142 cr_row(st, "multiparty-call-n8 " as *u8, 1, "runtime/_hdl_build/nx_signaling_v2.nx" as *u8, "-" as *u8, 1,1,1,1, "(8/room relay; rivals scale higher via SFU)" as *u8)
143 cr_row(st, "video-call " as *u8, 2, "sites/nishifamily/video/app.js" as *u8, "getUserMedia" as *u8, 1,1,1,1, "-" as *u8)
144 cr_row(st, "audio-call-compressed " as *u8, 2, "runtime/nx_video_client_wasm.nx" as *u8, "vc_lpc_encode" as *u8, 1,1,1,1, "(sovereign LPC; opus-class quality = separate row)" as *u8)
145 cr_row(st, "screenshare " as *u8, 2, "sites/nishifamily/video/app.js" as *u8, "getDisplayMedia" as *u8, 1,1,1,1, "-" as *u8)
146 cr_row(st, "invite-link " as *u8, 2, "sites/nishifamily/video/app.js" as *u8, "join=1" as *u8, 1,1,1,1, "-" as *u8)
147 cr_row(st, "adaptive-bitrate " as *u8, 2, "runtime/nx_video_client_wasm.nx" as *u8, "vc_ladder_step" as *u8, 1,1,1,1, "(client RTT ladder)" as *u8)
148 cr_row(st, "mobile-web " as *u8, 2, "sites/nishifamily/video/index.html" as *u8, "viewport" as *u8, 1,1,1,1, "-" as *u8)
149 cr_row(st, "text-chat-in-call " as *u8, 2, "sites/nishifamily/video/app.js" as *u8, "nishi_chat_" as *u8, 1,1,1,1, "(R3 SHIPPED 2026-07-02; gate 9/9 + funcheck video_chat)" as *u8)
150 pw("--- DIFFERENTIATORS ---\n" as *u8)
151 cr_row(st, "async-video-circles " as *u8, 2, "runtime/_hdl_build/nx_sites_daemon_v2.nx" as *u8, "/video/circle" as *u8, 0,0,1,0, "(Telegram video-messages analogue; J/Z/D lack)" as *u8)
152 cr_row(st, "live-caption-translate " as *u8, 1, "runtime/_hdl_build/nx_mt_multi.nx" as *u8, "-" as *u8, 0,1,0,0, "(EN/RU/BE/UK/PL; Zoom = paid tier)" as *u8)
153 cr_row(st, "e2ee-primitives " as *u8, 1, "runtime/nx_e2e.nx" as *u8, "-" as *u8, 1,1,1,1, "(rivals: opt-in tiers; live-wire = build)" as *u8)
154 cr_row(st, "ring-notify-callsig " as *u8, 1, "runtime/nx_callsig.nx" as *u8, "-" as *u8, 0,1,1,1, "-" as *u8)
155 cr_row(st, "noise-suppress-classical " as *u8, 1, "runtime/nx_vad.nx" as *u8, "-" as *u8, 0,1,0,1, "(classical VAD vs rival neural = quality gap)" as *u8)
156 cr_row(st, "sovereign-zero-dep FLOOR " as *u8, 1, "runtime/nx_video_client_wasm.nx" as *u8, "-" as *u8, 0,0,0,0, "(no rival is; floor not exceed)" as *u8)
157 pw("--- HONEST BEHIND (rivals have, we lack = the build backlog) ---\n" as *u8)
158 cr_row(st, "persistent-chat-history " as *u8, 3, "-" as *u8, "-" as *u8, 0,1,1,1, "-> R4 profile store" as *u8)
159 cr_row(st, "contacts-roster " as *u8, 3, "-" as *u8, "-" as *u8, 0,1,1,1, "-> R4 profile store" as *u8)
160 cr_row(st, "presence-status " as *u8, 3, "-" as *u8, "-" as *u8, 0,1,1,1, "-> R4/R6" as *u8)
161 cr_row(st, "reactions " as *u8, 3, "-" as *u8, "-" as *u8, 1,1,1,1, "-> chat kind exists in nx_chat_ring" as *u8)
162 cr_row(st, "file-send " as *u8, 3, "-" as *u8, "-" as *u8, 0,1,1,1, "-" as *u8)
163 cr_row(st, "sfu-selective-forward " as *u8, 3, "-" as *u8, "-" as *u8, 1,1,0,1, "long-pole V-SFU-1 (naive broadcast today)" as *u8)
164 cr_row(st, "asr-speech2text " as *u8, 3, "-" as *u8, "-" as *u8, 0,1,0,0, "long-pole V-ASR-1 (frontend gated)" as *u8)
165 cr_row(st, "av1-vp9-decode " as *u8, 3, "-" as *u8, "-" as *u8, 1,1,1,1, "long-pole" as *u8)
166 cr_row(st, "opus-class-audio " as *u8, 3, "-" as *u8, "-" as *u8, 1,1,1,1, "long-pole (LPC is not opus-class)" as *u8)
167 cr_row(st, "call-recording " as *u8, 3, "-" as *u8, "-" as *u8, 0,1,0,1, "(circles are self-cam only)" as *u8)
168
169 // ---- (4) ROLLUP ----
170 pw("--- MEASURED ROLLUP (parity permille = of the features that rival has, how many we ALSO have) ---\n" as *u8)
171 pw(" vs JITSI : " as *u8); pn(st[1]); pw("/" as *u8); pn(st[0]); pw(" = " as *u8); if st[0]>0 {pn(st[1]*1000/st[0])} pw(" permille\n" as *u8)
172 pw(" vs ZOOM : " as *u8); pn(st[3]); pw("/" as *u8); pn(st[2]); pw(" = " as *u8); if st[2]>0 {pn(st[3]*1000/st[2])} pw(" permille\n" as *u8)
173 pw(" vs TELEGRAM : " as *u8); pn(st[5]); pw("/" as *u8); pn(st[4]); pw(" = " as *u8); if st[4]>0 {pn(st[5]*1000/st[4])} pw(" permille\n" as *u8)
174 pw(" vs DISCORD : " as *u8); pn(st[7]); pw("/" as *u8); pn(st[6]); pw(" = " as *u8); if st[6]>0 {pn(st[7]*1000/st[6])} pw(" permille\n" as *u8)
175 pw(" our coverage: " as *u8); pn(st[9]); pw("/" as *u8); pn(st[8]); pw(" BEHIND rows = " as *u8); pn(st[10]); pw("\n" as *u8)
176
177 // ---- (5) CONTROLS (liar-kill) ----
178 if have("runtime/_hdl_build/nx_signaling_v2.nx" as *u8)==1 { pw("POS-control organ EXISTS: GREEN\n" as *u8) } else { pw("POS-control FAILED -> RED\n" as *u8); fail=fail+1 }
179 if have("runtime/nx_does_not_exist_xyz.nx" as *u8)==0 { pw("NEG-control bogus-path ABSENT: GREEN\n" as *u8) } else { pw("NEG-control FAILED (fabricated) -> RED\n" as *u8); fail=fail+1 }
180 if filehas("sites/nishifamily/video/app.js" as *u8, "zz_bogus_pattern_qq" as *u8)==0 { pw("NEG-control bogus-pattern ABSENT: GREEN\n" as *u8) } else { pw("NEG-control pattern FAILED -> RED\n" as *u8); fail=fail+1 }
181 if cr_live2("knowledge/status/no_such_funcheck.log" as *u8, K_MAGIC_86400)==0 { pw("NEG-control bogus-live-log NOT-LIVE: GREEN\n" as *u8) } else { pw("NEG-control live FAILED (fabricated liveness) -> RED\n" as *u8); fail=fail+1 }
182
183 pw("COMMS-RIVAL-CENSUS grounded=" as *u8); pn(g); pw("/17 live=" as *u8); pn(live)
184 pw(" behind=" as *u8); pn(st[10]); pw(" fail=" as *u8); pn(fail)
185 if fail==0 { pw(" verdict=GREEN -- measured vs the 4 rivals; BEHIND list is the honest backlog; a dead room cannot GREEN this census\n" as *u8); return 0 }
186 pw(" verdict=RED\n" as *u8)
187 return 1
188}