code wiki / _hdl_build / nx_healthtruth.nx

nx_healthtruth.nx

buildroot/runtime/_hdl_build/nx_healthtruth.nx

10090 B207 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_healthtruth.nx -- THE DETECTOR THE 2026-07-26 INCIDENT DID NOT HAVE. Eats debt 1785048333 (sev 9). THE DEBT, VERBATIM IN SUBSTANCE: nx_health reported {overall:OK, degraded:0, down:0} while nx_resmon measured swap_used_permil=999 with SwapFree=1136 kB of 24252332 kB -- swap 99.995% exhausted -- and the edge :8443 was refusing connections and POST /mcp was intermittently returning the STATIC SITE HOMEPAGE instead of routing to the tools daemon. WHY nx_health COULD NOT SEE IT, CONFIRMED IN SOURCE: nx_mgmt_api.nx ma_health_count() derives `reasons` ENTIRELY from a supervisor process snapshot -- duplicate procs, restart loops, "DOWN" tokens, supervisor duel. Every one of those asks "IS THE PROCESS PRESENT?" ★★★★★A LIVENESS CHECK CANNOT SEE A RESOURCE FAILURE, BECAUSE A PROCESS BEING SWAPPED TO DEATH IS STILL A PROCESS THAT EXISTS. The health endpoint was not lying about what it measured; it was measuring the wrong thing and reporting it as "overall". ⚠STILL TRUE RIGHT NOW, NOT JUST DURING THE INCIDENT. Measured live 2026-08-01 from /proc/meminfo: MemAvailable 20429704 / MemTotal 36921296 -> 553 permil available SwapFree 5710164 / SwapTotal 24252332 -> 764 permil of swap CONSUMED and nx_health simultaneously returned {"overall":"OK","degraded":0,"reasons":[]}. ★WHY THIS IS A SEPARATE ORGAN AND NOT A PATCH TO nx_mgmt_api: rebuilding the management API would ship whatever unbuilt edits other lanes have staged in that file and could take the control plane down -- an OUTAGE, not merely a blast radius, and it would sever the very transport used to observe the result. ★A FIX THAT CAN TAKE DOWN THE THING YOU WOULD USE TO VERIFY THE FIX IS NOT A SAFE FIRST MOVE. This organ makes the blindness CONTINUOUSLY MEASURABLE first; narrowing ma_health_count afterwards is then a small change against a known-good detector. WHAT IT DOES: reads /proc/meminfo (the kernel's own numbers, independent of BOTH instruments), computes pressure in permil, and renders a verdict. Thresholds are DATA, not magic numbers (Rule 11): read from knowledge/healththresh.conf when present, with documented fallbacks. license_tier: ORIGINAL expect_exit: 0

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_healthtruth.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main w sys_write sys_mmap sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close meminfo_kb starts permil nn w ↻ sys_mmap ↻ sys_write ↻ evaluate verdict_name w ↻

structs

none

consts

104const HT_OK: i64 = 0
105const HT_DEGRADED: i64 = 1
106const HT_RED: i64 = 2

functions

32func w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 3: nnverdict_namemain calls 1: sys_write
34func nn(v: i64) -> i64
called by 1: main calls 3: wsys_mmapsys_write
48func starts(b: *u8, n: i64, at: i64, s: *u8) -> i64
called by 1: meminfo_kb
61func meminfo_kb(b: *u8, n: i64, key: *u8) -> i64
called by 1: main calls 1: starts
99func permil(part: i64, whole: i64) -> i64
called by 1: main
108func verdict_name(v: i64) -> i64
called by 1: main calls 1: w
117func evaluate(mem_avail_pm: i64, swap_used_pm: i64,
called by 1: main
134func main() -> i64