code wiki / _hdl_build / nx_site_liveness.nx
nx_site_liveness.nx source
↩ module page · 80 lines · 4980 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// ★VANTAGE IS PART OF THE QUESTION (fixed 2026-08-08, measured). The old probe asked only "did
12// SOMETHING answer 200?" -- and :443 is CONTENDED (DSM nginx co-squats it). MEASURED that day: a
13// NAS-side fetch of https://nishifamily.com returned status=200 body_bytes=3354, title
14// "Nishi Family . Nishi Family", nav Video/Voxels/About/Story -- while the SOVEREIGN EDGE pinned at
15// 127.0.0.1:8443 returned 16437 bytes, title "Nishi Family -- the sovereign ecosystem". TWO DIFFERENT
16// SITES. An any-200 test reports the estate HEALTHY while measuring a foreign backend -- which is the
17// exact false-green class this organ's own header says it exists to remove ("those proxies
18// false-greened while the site was DOWN"), rebuilt one layer down in its successor.
19// ★A LIVENESS PROBE THAT CANNOT NAME WHO ANSWERED IS NOT MEASURING YOUR SERVICE, IT IS MEASURING A
20// PORT. So: probe through the PINNED vantage (connect-override straight to the sovereign edge; SNI and
21// Host stay the URL host, exactly as nx_page_verify already does) and REQUIRE our own X-Served-By.
22// ★NOT A PER-HOST GUESS: verified live 2026-08-08 that BOTH nishifamily.com AND andelinwest.com answer
23// with this header through the override, so one marker covers every host and cannot rot per-site.
24// ⚠Both conditions are asserted SEPARATELY and both values are printed -- a compound assertion that
25// will not name its failing conjunct is a false-alarm generator.
26const SL_EDGE_ENDPOINT: *u8 = "127.0.0.1:8443"
27const SL_EDGE_MARKER: *u8 = "X-Served-By: nishi-substrate-v2"
28const SL_STATUS_OK: *u8 = "HTTP/1.1 200"
29
30// probe url, write a per-site verdict line, return 1 healthy / 0 down. INLINE verdict (no miscompiling call).
31func sl_check(lfd: i64, host: *u8, url: *u8) -> i64 {
32 let args: *i64 = sys_mmap(16) as *i64
33 args[0] = url as i64
34 args[1] = SL_EDGE_ENDPOINT as i64
35 dep_run_capture("_offc/nx_https_get_cli.elf" as *u8, args, 2, "/tmp/sl_probe.out" as *u8)
36 let buf: *u8 = sys_mmap(K_MAGIC_16384)
37 let n: i64 = dp_read("/tmp/sl_probe.out" as *u8, buf, K_MAGIC_16380)
38 let ok200: i64 = dp_contains(buf, n, SL_STATUS_OK)
39 let mine: i64 = dp_contains(buf, n, SL_EDGE_MARKER)
40 var h: i64 = 1
41 if ok200 == 0 { h = 0 }
42 if mine == 0 { h = 0 }
43 if lfd >= 0 {
44 dp_w(lfd, "SITE-LIVENESS host=" as *u8); dp_w(lfd, host)
45 dp_w(lfd, " vantage=PINNED status_200=" as *u8); dp_wn(lfd, ok200)
46 dp_w(lfd, " served_by_edge=" as *u8); dp_wn(lfd, mine)
47 dp_w(lfd, " bytes=" as *u8); dp_wn(lfd, n)
48 dp_w(lfd, " healthy=" as *u8); dp_wn(lfd, h); dp_w(lfd, " verdict=" as *u8)
49 if h == 1 { dp_w(lfd, "GREEN" as *u8) } else { dp_w(lfd, "RED" as *u8) }
50 dp_w(lfd, "\n" as *u8)
51 }
52 dp_w(1, " " as *u8); dp_w(1, host); dp_w(1, ": status_200=" as *u8); dp_wn(1, ok200)
53 dp_w(1, " served_by_edge=" as *u8); dp_wn(1, mine)
54 dp_w(1, " healthy=" as *u8); dp_wn(1, h); dp_w(1, "\n" as *u8)
55 return h
56}
57
58func main() -> i64 {
59 dp_w(1, "=== NISHI SITE LIVENESS: REAL HTTP probe of the live sites (the truth, not a port-bind proxy) ===\n" as *u8)
60 let lfd: i64 = sys_openat_append("knowledge/status/site_liveness.log" as *u8, 0x1a4)
61 // Trailing slash = the exact URL form verified live through the pinned override on 2026-08-08.
62 let h1: i64 = sl_check(lfd, "nishifamily" as *u8, "https://nishifamily.com/" as *u8)
63 let h2: i64 = sl_check(lfd, "andelinwest" as *u8, "https://andelinwest.com/" as *u8)
64 var allok: i64 = 1
65 if h1 == 0 { allok = 0 }
66 if h2 == 0 { allok = 0 }
67 // consolidated line LAST (so el_last_green reads the true overall verdict)
68 if lfd >= 0 {
69 dp_w(lfd, "SITES-LIVE-ALL nishifamily=" as *u8); dp_wn(lfd, h1); dp_w(lfd, " andelinwest=" as *u8); dp_wn(lfd, h2)
70 dp_w(lfd, " verdict=" as *u8)
71 if allok == 1 { dp_w(lfd, "GREEN" as *u8) } else { dp_w(lfd, "RED" as *u8) }
72 dp_w(lfd, " epoch=" as *u8); dp_wn(lfd, sys_now_realtime_sec()); dp_w(lfd, "\n" as *u8)
73 sys_close(lfd)
74 }
75 dp_w(1, "SITES-LIVE-ALL verdict=" as *u8)
76 if allok == 1 { dp_w(1, "GREEN (both pages actually load)\n" as *u8); sys_exit(0); return 0 }
77 dp_w(1, "RED (a page is DOWN -- this is the real signal the proxies missed)\n" as *u8)
78 sys_exit(1)
79 return 1
80}