code wiki / _hdl_build / nx_site_liveness.nx
nx_site_liveness.nx source
↩ module page · 53 lines · 3080 B
1// nx_site_liveness.nx -- the LIVE truth source the maturity engine was missing: probe each public site for REAL
2// (HTTP 200 + body, via the sovereign fetcher) and write a verdict log the rollup reads. Composes the gate-proven
3// health logic (nx_http_health_gate 9/9) but INLINES the verdict (the hh_healthy CALL miscompiles -- a real .nx
4// codegen bug found live). Output: knowledge/status/site_liveness.log lines `... verdict=GREEN|RED`, the last being
5// the consolidated SITES-LIVE-ALL (so the maturity engine's gate-liveness reads the true overall state).
6// license_tier: ORIGINAL
7import "nx_http_health_lib.nx"
8const K_MAGIC_16384: i64 = 16384
9const K_MAGIC_16380: i64 = 16380
10
11// probe url, write a per-site verdict line, return 1 healthy / 0 down. INLINE verdict (no miscompiling call).
12func sl_check(lfd: i64, host: *u8, url: *u8) -> i64 {
13 let args: *i64 = sys_mmap(16) as *i64; args[0] = url as i64
14 dep_run_capture("_offc/nx_research_fetch.elf" as *u8, args, 1, "/tmp/sl_probe.out" as *u8)
15 let buf: *u8 = sys_mmap(K_MAGIC_16384)
16 let n: i64 = dp_read("/tmp/sl_probe.out" as *u8, buf, K_MAGIC_16380)
17 let st: i64 = hh_after(buf, n, "status=" as *u8)
18 let bb: i64 = hh_after(buf, n, "body_bytes=" as *u8)
19 var h: i64 = 1
20 if st != 200 { h = 0 }
21 if bb <= 0 { h = 0 }
22 if lfd >= 0 {
23 dp_w(lfd, "SITE-LIVENESS host=" as *u8); dp_w(lfd, host); dp_w(lfd, " http_status=" as *u8); dp_wn(lfd, st)
24 dp_w(lfd, " body_bytes=" as *u8); dp_wn(lfd, bb); dp_w(lfd, " healthy=" as *u8); dp_wn(lfd, h); dp_w(lfd, " verdict=" as *u8)
25 if h == 1 { dp_w(lfd, "GREEN" as *u8) } else { dp_w(lfd, "RED" as *u8) }
26 dp_w(lfd, "\n" as *u8)
27 }
28 dp_w(1, " " as *u8); dp_w(1, host); dp_w(1, ": http=" as *u8); dp_wn(1, st); dp_w(1, " healthy=" as *u8); dp_wn(1, h); dp_w(1, "\n" as *u8)
29 return h
30}
31
32func main() -> i64 {
33 dp_w(1, "=== NISHI SITE LIVENESS: REAL HTTP probe of the live sites (the truth, not a port-bind proxy) ===\n" as *u8)
34 let lfd: i64 = sys_openat_append("knowledge/status/site_liveness.log" as *u8, 0x1a4)
35 let h1: i64 = sl_check(lfd, "nishifamily" as *u8, "https://nishifamily.com" as *u8)
36 let h2: i64 = sl_check(lfd, "andelinwest" as *u8, "https://andelinwest.com" as *u8)
37 var allok: i64 = 1
38 if h1 == 0 { allok = 0 }
39 if h2 == 0 { allok = 0 }
40 // consolidated line LAST (so el_last_green reads the true overall verdict)
41 if lfd >= 0 {
42 dp_w(lfd, "SITES-LIVE-ALL nishifamily=" as *u8); dp_wn(lfd, h1); dp_w(lfd, " andelinwest=" as *u8); dp_wn(lfd, h2)
43 dp_w(lfd, " verdict=" as *u8)
44 if allok == 1 { dp_w(lfd, "GREEN" as *u8) } else { dp_w(lfd, "RED" as *u8) }
45 dp_w(lfd, " epoch=" as *u8); dp_wn(lfd, sys_now_realtime_sec()); dp_w(lfd, "\n" as *u8)
46 sys_close(lfd)
47 }
48 dp_w(1, "SITES-LIVE-ALL verdict=" as *u8)
49 if allok == 1 { dp_w(1, "GREEN (both pages actually load)\n" as *u8); sys_exit(0); return 0 }
50 dp_w(1, "RED (a page is DOWN -- this is the real signal the proxies missed)\n" as *u8)
51 sys_exit(1)
52 return 1
53}