code wiki / (root) / nx_health_probe.nx

nx_health_probe.nx

buildroot/runtime/nx_health_probe.nx

13144 B234 linesdepth 5pulls 5 transitivereach 13 importersview sourcekind probetopic health
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_connect.nx nx_health_probe.nx nx_daemon_supervisor.nx nx_health_probe_gate.nx nx_hostctl.nx nx_ready_census.nx nx_runsv.nx nx_site_monitor.nx nx_status_page.nx nx_tenancy_gate.nx

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

main hp_p sys_write hp_one_tls hp_probe_tls sys_socket sys_set_socket_timeout sys_mmap sys_setsockopt sys_munmap sys_mmap ↻ hp_sockaddr nx_connect_bounded nx_fcntl sys_connect sys_mmap ↻ sys_poll hp_build_ch hp_hexv sys_write ↻ sys_read sys_munmap ↻ sys_close hp_p ↻ hp_n sys_mmap ↻ sys_write ↻ hp_name hp_one hp_probe sys_socket ↻ sys_set_socket_timeout ↻ sys_mmap ↻ hp_sockaddr ↻ nx_connect_bounded ↻ sys_write ↻ sys_read ↻ sys_munmap ↻ sys_close ↻ hp_p ↻

structs

none

consts

12const HP_MAGIC_4096: i64 = 4096
13const HP_MAGIC_4095: i64 = 4095
14const HP_MAGIC_8443: i64 = 8443
15const HP_MAGIC_7443: i64 = 7443
16const HP_MAGIC_18096: i64 = 18096
17const HP_MAGIC_18090: i64 = 18090
18const HP_MAGIC_18190: i64 = 18190
19const HP_MAGIC_11434: i64 = 11434
20const HP_MAGIC_18691: i64 = 18691
21const HP_MAGIC_18098: i64 = 18098
22const HP_MAGIC_18099: i64 = 18099
23const HP_MAGIC_8445: i64 = 8445
25const HP_SERVING: i64 = 1 // got an HTTP response -> the daemon is alive AND serving
26const HP_REFUSED: i64 = 2 // connect failed -> down / not listening (crashed or never bound)
27const HP_HUNG: i64 = 3 // connected but NO response within the timeout -> hung (the case PID/LISTEN miss)
28const HP_BADRESP: i64 = 4 // responded, but not a valid HTTP reply -> wrong/garbage process on the port
80const HP_CONFIRM_GAP_MS: i64 = 500
82const HP_CONNECT_TIMEOUT_S: i64 = 2

functions

30func hp_name(v: i64) -> *u8
37func hp_sockaddr(buf: *u8, port: i64, a: i64, b: i64, c: i64, d: i64) -> i64
47func hp_probe(port: i64, timeout_sec: i64) -> i64
89func hp_listening(port: i64) -> i64
105func hp_socket_dead(port: i64) -> i64
called by 2: mainmain calls 2: hp_listeningsys_sleep_ms
121func hp_hexv(c: i64) -> i64 { if c >= 97 { return c - 87 } return c - 48 }
called by 1: hp_build_ch
124func hp_build_ch(out: *u8) -> i64
called by 1: hp_probe_tls calls 1: hp_hexv
140func hp_probe_tls(port: i64, timeout_sec: i64) -> i64
171func hp_probe_ws(port: i64, timeout_sec: i64) -> i64
193func 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 }
194func 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 }
195func hp_one(port: i64, name: *u8) -> i64
called by 1: main calls 4: hp_probehp_php_nhp_name
200func hp_one_tls(port: i64, name: *u8) -> i64
called by 1: main calls 4: hp_probe_tlshp_php_nhp_name
205func hp_one_ws(port: i64, name: *u8) -> i64
called by 1: main calls 4: hp_probe_wshp_php_nhp_name
213func main() -> i64