nx_health_probe.nx
buildroot/runtime/nx_health_probe.nx
about
nx_health_probe.nx -- SERVING health probe (closes hosting_research gap #5 "health-probe-not-liveness",
3/0 CONFIRMED: a service running-but-not-serving is worse than crashed; nx_hostctl only /proc-name-scans).
Black-box probe: connect + send a request + bounded recv. Distinguishes the 4 real states a supervisor
must act on differently -- crucially HUNG (process up + port bound but NOT responding), which PID-liveness
(systemd) and even a LISTEN check (nx_port_audit) both MISS. No daemon cooperation needed (unlike systemd
sd_notify WATCHDOG); same black-box idea as a k8s liveness probe but sovereign + composes with the
restart-guard + reap + listen audits into one supervision-health story.
module: nishi-core.supervision.health_probe capability: DAEMON_ROBUSTNESS
dependencies 2 imports · 8 importers
imports: nx_syscalls.nxnx_connect.nx
imported by: nx_daemon_supervisor.nxnx_health_probe_gate.nxnx_hostctl.nxnx_ready_census.nxnx_runsv.nxnx_site_monitor.nxnx_status_page.nxnx_tenancy_gate.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 12 | const HP_MAGIC_4096: i64 = 4096 |
| 13 | const HP_MAGIC_4095: i64 = 4095 |
| 14 | const HP_MAGIC_8443: i64 = 8443 |
| 15 | const HP_MAGIC_7443: i64 = 7443 |
| 16 | const HP_MAGIC_18096: i64 = 18096 |
| 17 | const HP_MAGIC_18090: i64 = 18090 |
| 18 | const HP_MAGIC_18190: i64 = 18190 |
| 19 | const HP_MAGIC_11434: i64 = 11434 |
| 20 | const HP_MAGIC_18691: i64 = 18691 |
| 21 | const HP_MAGIC_18098: i64 = 18098 |
| 22 | const HP_MAGIC_18099: i64 = 18099 |
| 23 | const HP_MAGIC_8445: i64 = 8445 |
| 25 | const HP_SERVING: i64 = 1 // got an HTTP response -> the daemon is alive AND serving |
| 26 | const HP_REFUSED: i64 = 2 // connect failed -> down / not listening (crashed or never bound) |
| 27 | const HP_HUNG: i64 = 3 // connected but NO response within the timeout -> hung (the case PID/LISTEN miss) |
| 28 | const HP_BADRESP: i64 = 4 // responded, but not a valid HTTP reply -> wrong/garbage process on the port |
| 80 | const HP_CONFIRM_GAP_MS: i64 = 500 |
| 82 | const HP_CONNECT_TIMEOUT_S: i64 = 2 |
functions
| 30 | func hp_name(v: i64) -> *u8 |
| 37 | func hp_sockaddr(buf: *u8, port: i64, a: i64, b: i64, c: i64, d: i64) -> i64 |
| 47 | func hp_probe(port: i64, timeout_sec: i64) -> i64 |
| 89 | func hp_listening(port: i64) -> i64 called by 3: hp_socket_deadmainmain calls 7: sys_socketsys_set_socket_timeoutsys_mmaphp_sockaddrnx_connect_boundedsys_close+1 |
| 105 | func hp_socket_dead(port: i64) -> i64 |
| 121 | func hp_hexv(c: i64) -> i64 { if c >= 97 { return c - 87 } return c - 48 } called by 1: hp_build_ch |
| 124 | func hp_build_ch(out: *u8) -> i64 |
| 140 | func hp_probe_tls(port: i64, timeout_sec: i64) -> i64 called by 2: mainhp_one_tls calls 10: sys_socketsys_set_socket_timeoutsys_mmaphp_sockaddrnx_connect_boundedhp_build_ch+4 |
| 171 | func hp_probe_ws(port: i64, timeout_sec: i64) -> i64 called by 2: mainhp_one_ws calls 9: sys_socketsys_set_socket_timeoutsys_mmaphp_sockaddrnx_connect_boundedsys_write+3 |
| 193 | func hp_p(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 194 | func hp_n(v: i64) -> i64 { let t: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m} 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} let b: *u8=sys_mmap(28); var i: i64=0; while i<k{b[i]=t[k-1-i];i=i+1} sys_write(1,b,k); return 0 } |
| 195 | func hp_one(port: i64, name: *u8) -> i64 |
| 200 | func hp_one_tls(port: i64, name: *u8) -> i64 |
| 205 | func hp_one_ws(port: i64, name: *u8) -> i64 |
| 213 | func main() -> i64 |