code wiki / _hdl_build / nx_connect_live_verify.nx
nx_connect_live_verify.nx source
↩ module page · 270 lines · 15722 B
1// nx_connect_live_verify.nx -- SOVEREIGN live verification of the PUBLIC CONNECT app, every rung OURS
2// on OUR hardware: DNS -> TCP -> our TLS 1.3 handshake (X.509 chain-validated vs the Mozilla trust
3// store) -> HTTP GET/POST -> our HTTP parser -> our dechunk -> byte assertions. This REPLACES WebFetch
4// (operator 2026-07-10: "i dont want webfetch in the mix i want native nishi os and nishi browser our
5// hardware from each rung up"). Same bits-up stack as nx_browser_own_site_live_test, extended to POST
6// so the INTERACTIVE path is proven sovereignly too.
7// GET https://nishifamily.com/connect -> 200 + app markers (title, Vera, ru+en MT, receipts)
8// POST https://nishifamily.com/connect/say -> the reply renders "thanks friend" (real MT over TLS)
9// Exit 0 = the live public app served + rendered through our own browser stack. license_tier: ORIGINAL
10import "nx_syscalls.nx"
11import "nx_x509_trust_store.nx"
12import "nx_trust_store_load_from_certdata.nx"
13import "nx_tls13_client_validate_certificate.nx"
14import "nx_tls13_client_session_run.nx"
15import "nx_https_url_for_fetch.nx"
16import "nx_https_url_connect.nx"
17import "nx_https_get_complete.nx"
18import "nx_https_post_complete.nx"
19import "nx_http_response_parse.nx"
20const K_MAGIC_262144: i64 = 262144
21const K_MAGIC_16384: i64 = 16384
22const K_MAGIC_4194304: i64 = 4194304
23
24func lv_w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
25func lv_n(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)} 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} var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1} sys_write(1,bb,k); return 0 }
26func lv_check(pass: i64, label: *u8, fails: *i64) -> i64 {
27 lv_w(" " as *u8); lv_w(label); lv_w(": " as *u8)
28 if pass==1 { lv_w("PASS\n" as *u8) } else { lv_w("FAIL\n" as *u8); fails[0]=fails[0]+1 }
29 return 0
30}
31func lv_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
32func lv_cat(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){dst[off+i]=s[i]; i=i+1} return off+i }
33func lv_catb(dst: *u8, off: i64, src: *u8, n: i64) -> i64 { var i: i64=0; while i<n { dst[off+i]=src[i]; i=i+1 } return off+n }
34func lv_catnum(dst: *u8, off: i64, v: i64) -> i64 {
35 var o: i64=off
36 var m: i64=v
37 let t: *u8=sys_mmap(28)
38 var k: i64=0
39 if m<=0 { dst[o]=48 as u8; return o+1 }
40 while m>0 { t[k]=(48+(m%10)) as u8; m=m/10; k=k+1 }
41 var i: i64=0
42 while i<k { dst[o+i]=t[k-1-i]; i=i+1 }
43 return o+k
44}
45func lv_has(buf: *u8, n: i64, needle: *u8) -> i64 {
46 let m: i64 = lv_slen(needle)
47 if m==0 { return 0 }
48 var i: i64=0
49 while i+m<=n {
50 var k: i64=0
51 var hit: i64=1
52 while k<m { if buf[i+k]!=needle[k] { hit=0; k=m } else { k=k+1 } }
53 if hit==1 { return 1 }
54 i=i+1
55 }
56 return 0
57}
58
59// one bits-up request to nishifamily.com. is_post=1 -> POST body; else GET. body region (dechunked)
60// lands in html[0..return); status returned via st[0]. return<0 names the failing stage.
61func lv_fetch(store: *TrustStore, is_post: i64, path: *u8, plen: i64, body: *u8, blen: i64,
62 html: *u8, cap: i64, st: *i64) -> i64 {
63 let url: *u8 = "https://nishifamily.com/\x00"
64 let url_p: *NxUrl = nx_url_new()
65 let target_raw: *u8 = sys_mmap(32)
66 let target: *NxHttpsTarget = target_raw as *NxHttpsTarget
67 target.url = url_p
68 target.port = 0
69 if nx_https_url_for_fetch(url, target) != NX_HTTPS_URL_OK { return 0-41 }
70 let host: *u8 = url + target.url.host_off
71 let hlen: i64 = target.url.host_len
72 let fd_p: *i64 = sys_mmap(16) as *i64
73 if nx_https_url_connect(target, url, sys_now_realtime_sec(), fd_p) != NX_HTTPS_CONNECT_OK { return 0-42 }
74 let fd: i64 = *fd_p
75 sys_set_socket_timeout(fd, 12)
76 let vc_raw: *u8 = sys_mmap(64)
77 let vc: *TlsValidationContext = vc_raw as *TlsValidationContext
78 vc.store = store
79 vc.sni_host = host
80 vc.sni_host_len = hlen
81 vc.now_epoch = sys_now_realtime_sec()
82 let cr: *u8 = sys_mmap(32)
83 let priv: *u8 = sys_mmap(32)
84 var i: i64=0
85 while i<32 { cr[i]=(0xC0+i) as u8; priv[i]=(0xA0+i) as u8; i=i+1 }
86 let sr: i64 = nx_tls13_client_session_run(fd, host, hlen, cr, priv, vc)
87 if sr<=0 { sys_close(fd); return 0-(200+(0-sr)) }
88 let session: *Tls13ClientSession = sr as *Tls13ClientSession
89 let buf: *u8 = sys_mmap(K_MAGIC_262144)
90 var gc: i64 = 0
91 if is_post==1 {
92 // Build the POST request bytes ourselves + send via the Content-Length-AWARE req_complete
93 // (the same read core GET uses, cl-stop) -- post_complete reads-until-close, which hangs on
94 // the edge's keep-alive. Connection: close makes the edge finish cleanly too.
95 let req: *u8 = sys_mmap(K_MAGIC_16384)
96 var ro: i64 = 0
97 ro = lv_cat(req, ro, "POST " as *u8)
98 ro = lv_catb(req, ro, path, plen)
99 ro = lv_cat(req, ro, " HTTP/1.1\r\nHost: " as *u8)
100 ro = lv_catb(req, ro, host, hlen)
101 ro = lv_cat(req, ro, "\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: " as *u8)
102 ro = lv_catnum(req, ro, blen)
103 ro = lv_cat(req, ro, "\r\nConnection: close\r\n\r\n" as *u8)
104 ro = lv_catb(req, ro, body, blen)
105 gc = nx_https_req_complete(session, fd, req, ro, buf, K_MAGIC_262144)
106 } else {
107 gc = nx_https_get_complete(session, fd, path, plen, host, hlen, buf, K_MAGIC_262144)
108 }
109 sys_close(fd)
110 if gc<0 { return 0-(100+(0-gc)) }
111 let resp: *i64 = sys_mmap(128) as *i64
112 if nx_http_response_parse(buf, gc, resp)!=0 { return 0-50 }
113 st[0] = resp[1]
114 let body_off: i64 = resp[6]
115 let body_kind: i64 = resp[8]
116 var hl: i64 = 0
117 if body_kind==2 { hl = nx_http_dechunk(buf+body_off, gc-body_off, html, cap) }
118 else { hl = gc-body_off; var ci: i64=0; while ci<hl { if ci<cap { html[ci]=buf[body_off+ci] } ci=ci+1 } }
119 return hl
120}
121
122func main() -> i64 {
123 let fails: *i64 = sys_mmap(16) as *i64
124 fails[0]=0
125 lv_w("=== nx_connect_live_verify -- SOVEREIGN verify of nishifamily.com/connect (our TLS, our parser, our hardware) ===\n" as *u8)
126
127 // trust store (nxc2-relative real Mozilla bundle)
128 let r: i64 = nx_trust_store_load_from_certdata("data/mozilla_certdata.txt\x00" as *u8, 300, K_MAGIC_4194304)
129 if r<=0 { lv_w("TRUST LOAD FAIL (run from nxc2)\n" as *u8); return 1 }
130 let store: *TrustStore = r as *TrustStore
131 lv_w(" CA roots=" as *u8); lv_n(trust_store_count(store)); lv_w("\n" as *u8)
132
133 let html: *u8 = sys_mmap(K_MAGIC_262144)
134 let st: *i64 = sys_mmap(16) as *i64
135
136 // ---- GET /connect over our stack ----
137 let g: i64 = lv_fetch(store, 0, "/connect\x00" as *u8, 8, 0 as *u8, 0, html, K_MAGIC_262144, st)
138 if g<0 { lv_w(" GET stage FAIL code=" as *u8); lv_n(g); lv_w("\n" as *u8); fails[0]=fails[0]+1 }
139 else {
140 lv_w(" GET /connect -> HTTP " as *u8); lv_n(st[0]); lv_w(" body=" as *u8); lv_n(g); lv_w(" bytes (over our TLS 1.3)\n" as *u8)
141 var t1: i64=0
142 if st[0]==200 { t1=1 }
143 lv_check(t1, "T1 GET /connect returns 200 through the sovereign edge" as *u8, fails)
144 var t2: i64=1
145 if lv_has(html, g, "aria-current=\"page\"" as *u8)==0 { t2=0 }
146 if lv_has(html, g, "/connect/reconnect" as *u8)==0 { t2=0 }
147 if lv_has(html, g, "/connect/partners" as *u8)==0 { t2=0 }
148 if lv_has(html, g, "--accent:#7aa2ff" as *u8)==0 { t2=0 }
149 if lv_has(html, g, "compare/connect" as *u8)==0 { t2=0 }
150 lv_check(t2, "T2 multi-page shell renders (nav + aria-current + nishi_ds tokens + receipts link)" as *u8, fails)
151 }
152
153 // ---- GET /connect/chat: the Cyrillic + live-MT surface ----
154 let gc2: i64 = lv_fetch(store, 0, "/connect/chat\x00" as *u8, 13, 0 as *u8, 0, html, K_MAGIC_262144, st)
155 if gc2<0 { lv_w(" GET /chat stage FAIL code=" as *u8); lv_n(gc2); lv_w("\n" as *u8); fails[0]=fails[0]+1 }
156 else {
157 var t3: i64=1
158 if lv_has(html, gc2, "привет друг" as *u8)==0 { t3=0 }
159 if lv_has(html, gc2, "hello friend" as *u8)==0 { t3=0 }
160 lv_check(t3, "T3 Cyrillic + its live translation survive DNS->TLS->parse->dechunk intact" as *u8, fails)
161 }
162
163 // ---- POST /connect/say over our stack: real MT round-trip ----
164 let bodyv: *u8 = "text=%D1%81%D0%BF%D0%B0%D1%81%D0%B8%D0%B1%D0%BE+%D0%B4%D1%80%D1%83%D0%B3&speaker=vera\x00" as *u8
165 let p: i64 = lv_fetch(store, 1, "/connect/say\x00" as *u8, 12, bodyv, lv_slen(bodyv), html, K_MAGIC_262144, st)
166 if p<0 { lv_w(" POST stage FAIL code=" as *u8); lv_n(p); lv_w("\n" as *u8); fails[0]=fails[0]+1 }
167 else {
168 lv_w(" POST /connect/say -> HTTP " as *u8); lv_n(st[0]); lv_w(" body=" as *u8); lv_n(p); lv_w(" bytes\n" as *u8)
169 var t4: i64=0
170 if st[0]==200 { if lv_has(html, p, "thanks friend" as *u8)==1 { t4=1 } }
171 lv_check(t4, "T4 POST renders live MT 'thanks friend' (interactive path, sovereign, over our TLS)" as *u8, fails)
172 }
173
174 // ---- POST /connect/consent over our stack: the LDS reconnection capability, live on the public edge ----
175 // A fresh session starts with discovery OFF, so this single request proves BOTH halves of the gate:
176 // the opt-in is honoured, and the roster it unlocks is the real consent-gated overlap computation.
177 let cbody: *u8 = "set=on\x00" as *u8
178 let c: i64 = lv_fetch(store, 1, "/connect/consent\x00" as *u8, 16, cbody, lv_slen(cbody), html, K_MAGIC_262144, st)
179 if c<0 { lv_w(" POST /consent stage FAIL code=" as *u8); lv_n(c); lv_w("\n" as *u8); fails[0]=fails[0]+1 }
180 else {
181 lv_w(" POST /connect/consent -> HTTP " as *u8); lv_n(st[0]); lv_w(" body=" as *u8); lv_n(c); lv_w(" bytes\n" as *u8)
182 var t5: i64=1
183 if st[0]!=200 { t5=0 }
184 if lv_has(html, c, "Sister Cortez" as *u8)==0 { t5=0 } // strong, mutually-confirmed overlap
185 if lv_has(html, c, "strong match" as *u8)==0 { t5=0 }
186 if lv_has(html, c, "after you left" as *u8)==0 { t5=0 } // time necessity, explained in the UI
187 if lv_has(html, c, "has not turned on reconnection discovery" as *u8)==0 { t5=0 } // peer consent wins
188 lv_check(t5, "T5 LDS reconnection LIVE on the public edge: opt-in unlocks the consent-gated overlap roster" as *u8, fails)
189 }
190
191 // ---- NEG-CONTROL: without the opt-in, a fresh visitor is shown NOBODY ----
192 let d: i64 = lv_fetch(store, 0, "/connect/reconnect\x00" as *u8, 18, 0 as *u8, 0, html, K_MAGIC_262144, st)
193 if d<0 { lv_w(" GET /reconnect stage FAIL code=" as *u8); lv_n(d); lv_w("\n" as *u8); fails[0]=fails[0]+1 }
194 else {
195 var t6: i64=1
196 if lv_has(html, d, "Sister Cortez" as *u8)==1 { t6=0 }
197 if lv_has(html, d, "Brother Reyes" as *u8)==1 { t6=0 }
198 if lv_has(html, d, "discovery is <b>off</b>" as *u8)==0 { t6=0 }
199 lv_check(t6, "T6 NEG-CONTROL: a fresh visitor with no opt-in is shown ZERO people, live" as *u8, fails)
200 }
201
202 // ---- T7: every published route answers 200 on the live edge (no dead tab in the nav) ----
203 var t7: i64 = 1
204 var t8: i64 = 1
205 let r1: i64 = lv_fetch(store, 0, "/connect/partners\x00" as *u8, 17, 0 as *u8, 0, html, K_MAGIC_262144, st)
206 if r1<0 { t7=0; t8=0 } else {
207 if st[0]!=200 { t7=0 }
208 // the ranks must be ENGINE OUTPUT computed live, not page copy: 55 / 45 / exactly 0
209 if lv_has(html, r1, "rank 55" as *u8)==0 { t8=0 }
210 if lv_has(html, r1, "rank 45" as *u8)==0 { t8=0 }
211 if lv_has(html, r1, "rank 0" as *u8)==0 { t8=0 }
212 if lv_has(html, r1, "excluded" as *u8)==0 { t8=0 } // minor x romance lane, non-numeric
213 if lv_has(html, r1, "match 92" as *u8)==1 { t8=0 } // the old fabricated number must be gone
214 }
215 let r2: i64 = lv_fetch(store, 0, "/connect/community\x00" as *u8, 18, 0 as *u8, 0, html, K_MAGIC_262144, st)
216 if r2<0 { t7=0; t8=0 } else {
217 if st[0]!=200 { t7=0 }
218 if lv_has(html, r2, "community group" as *u8)==0 { t7=0 }
219 // the community-only boundary must be a LIVE registry measurement, not page copy
220 if lv_has(html, r2, "would need: <b>0</b>" as *u8)==0 { t8=0 }
221 if lv_has(html, r2, "reports <b>3</b>" as *u8)==0 { t8=0 }
222 if lv_has(html, r2, "Faith consent" as *u8)==0 { t8=0 }
223 if lv_has(html, r2, "Who may do what here" as *u8)==0 { t8=0 } // group permission engine, live
224 if lv_has(html, r2, "removes a fellow admin" as *u8)==0 { t8=0 }
225 }
226 let r3: i64 = lv_fetch(store, 0, "/connect/events\x00" as *u8, 15, 0 as *u8, 0, html, K_MAGIC_262144, st)
227 if r3<0 { t7=0; t8=0 } else {
228 if st[0]!=200 { t7=0 }
229 if lv_has(html, r3, "two-deep" as *u8)==0 { t7=0 }
230 if lv_has(html, r3, "Who can reach whom" as *u8)==0 { t8=0 } // the wall, rendered live
231 if lv_has(html, r3, "private one-to-one" as *u8)==0 { t8=0 }
232 if lv_has(html, r3, "seats" as *u8)==0 { t8=0 } // capacity, from the events engine
233 }
234 // T9: the INTENT LANE is live and refuses unilateral escalation, over the public edge
235 let lbody: *u8 = "mine=3&theirs=0\x00" as *u8
236 let r4: i64 = lv_fetch(store, 1, "/connect/lane\x00" as *u8, 13, lbody, lv_slen(lbody), html, K_MAGIC_262144, st)
237 var t9: i64 = 1
238 if r4<0 { t9=0 } else {
239 if st[0]!=200 { t9=0 }
240 // asked for Dating while she stays on Language -> must remain Language exchange
241 if lv_has(html, r4, "relationship is <b>Language exchange</b>" as *u8)==0 { t9=0 }
242 }
243 lv_w(" route bytes: partners=" as *u8); lv_n(r1); lv_w(" community=" as *u8); lv_n(r2); lv_w(" events=" as *u8); lv_n(r3); lv_w(" lane=" as *u8); lv_n(r4); lv_w("\n" as *u8)
244 lv_check(t9, "T9 intent lane LIVE: a unilateral request for Dating does NOT move the relationship" as *u8, fails)
245 lv_check(t7, "T7 every nav route answers 200 live with its own capability rendered (no dead tab)" as *u8, fails)
246 lv_check(t8, "T8 shared ENGINES drive the live pages: match ranks computed (55/45/0 + excluded), wall rendered" as *u8, fails)
247
248 // T10: the PRODUCT LANDING page must advertise what actually shipped. It previously described an older
249 // app and never mentioned reconnection at all -- a visitor could not learn the signature capability
250 // exists. This tooth fails the moment the landing page drifts behind the live app again.
251 let l: i64 = lv_fetch(store, 0, "/synth/connect\x00" as *u8, 14, 0 as *u8, 0, html, K_MAGIC_262144, st)
252 var t10: i64 = 1
253 if l<0 { t10=0 } else {
254 if st[0]!=200 { t10=0 }
255 if lv_has(html, l, "Find the people you already knew" as *u8)==0 { t10=0 } // reconnection, surfaced
256 if lv_has(html, l, "/connect/reconnect" as *u8)==0 { t10=0 } // and reachable
257 if lv_has(html, l, "never church administration" as *u8)==0 { t10=0 } // the community boundary
258 // NB: pick a phrase with NO inline markup inside it -- the card renders "<i>both</i> agreed to",
259 // so the literal "both agreed to" never matches.
260 if lv_has(html, l, "open the same door" as *u8)==0 { t10=0 } // consented intent lanes
261 }
262 lv_w(" landing bytes=" as *u8); lv_n(l); lv_w("\n" as *u8)
263 lv_check(t10, "T10 landing page advertises what SHIPPED (reconnection + lanes + community boundary, linked)" as *u8, fails)
264
265 lv_w(" fails=" as *u8); lv_n(fails[0]); lv_w("\n" as *u8)
266 if fails[0]==0 { lv_w("VERDICT: GREEN (nishifamily.com/connect live + interactive, verified bits-up through OUR stack -- no WebFetch)\n" as *u8); sys_exit(0) }
267 lv_w("VERDICT: RED\n" as *u8)
268 sys_exit(1)
269 return 1
270}