nx_leak_check.nx
buildroot/runtime/nx_leak_check.nx
about
nx_leak_check.nx -- FLEET LEAK-HEALTH CERTIFIER, CLI. Non-invasive (reads only /proc). Grounds every
verdict in a real time series + Mann-Kendall trend + Theil-Sen rate -- and PRINTS the numbers, so it is
never a bare assertion. Handles VARIABLE leaks (the sign-based trend test doesn't need a clean line).
series <pid> <samples> <interval_ms> deep single-process analysis; prints the raw series + tau + rate
fleet <samples> <interval_ms> [crit_sev] certify EVERY running sovereign organ (.elf); per-organ verdict.
crit_sev: 1=CHURN+ 2=SPIKE|LEAK (default, deep-dive) 3=LEAK-only (the STANDING-sweep invariant --
transient SPIKEs on bursty workers are printed evidence, not a standing failure). Organs that exit
mid-window are GONE-skipped (sample-validity guard), never convicted on poisoned series.
exit 0 = healthy / all-healthy, 1 = LEAK / some-leak. license_tier: ORIGINAL
dependencies 1 imports · 0 importers
imports: nx_leak_check_lib.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 12 | const LK_ARG_VERB: i64 = 1 |
| 13 | const LK_ARG_P1: i64 = 2 // series: pid ; fleet: samples |
| 14 | const LK_ARG_P2: i64 = 3 // series: samples ; fleet: interval_ms |
| 15 | const LK_ARG_P3: i64 = 4 // series: interval_ms |
| 16 | const LK_ARGC_FLEET: i64 = 4 // fleet samples interval |
| 17 | const LK_ARGC_SERIES: i64 = 5 // series pid samples interval |
| 18 | const LK_RC_USAGE: i64 = 2 |
| 19 | const LK_RC_LEAK: i64 = 1 |
| 20 | const LK_MAX_S: i64 = 32 // max samples per series |
| 21 | const LK_MAX_ORG: i64 = 256 // max organs in a fleet scan |
| 22 | const LK_MAX_PROC: i64 = 4096 // /proc pid enumeration cap |
| 23 | const LK_PAIRS: i64 = 496 // LK_MAX_S*(LK_MAX_S-1)/2 -- Theil-Sen pairwise-slope scratch |
| 24 | const LK_WORD: i64 = 8 |
| 25 | const LK_MS_PER_S: i64 = 1000 |
| 26 | const LK_SEV_CHURN: i64 = 1 // severity ladder: HEALTHY 0 < CHURN 1 < SPIKE 2 < LEAK 3 |
| 27 | const LK_SEV_SPIKE: i64 = 2 |
| 28 | const LK_SEV_LEAK: i64 = 3 |
| 29 | const LK_SEV_CRIT: i64 = 2 // severity >= this (SPIKE|LEAK) = CRITICAL (fails the fleet exit) |
| 30 | const LK_MIN_AGE_S: i64 = 120 // a LEAK verdict requires a process OLD ENOUGH to own a baseline: fork-per- |
functions
| 36 | func lk_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } |
| 37 | func lk_putn(v: i64) -> i64 |
| 47 | func lk_seq(a: *u8, b: *u8) -> i64 { var i: i64 = 0; while a[i] != (0 as u8) { if a[i] != b[i] { return 0 } i = i + 1 } if b[i] != (0 as u8) { return 0 } return 1 } called by 1: main |
| 48 | func lk_atoi(s: *u8) -> i64 called by 1: main |
| 54 | func lk_clamp_n(n: i64) -> i64 called by 1: main |
| 62 | func lk_verdict_line(out: *i64) -> i64 |
| 74 | func lk_code_name(code: i64) -> *u8 called by 1: lk_meter |
| 81 | func lk_sev(code: i64) -> i64 called by 1: main |
| 88 | func lk_meter(label: *u8, out: *i64) -> i64 |
| 99 | func lk_proc_age_s(pid: i64, hz: i64) -> i64 |
| 104 | func lk_cpu_util(cpu: *i64, coff: i64, ts: *i64, n: i64, util: *i64, utime: *i64, hz: i64) -> i64 called by 1: main |
| 115 | func main(argc: i64, argv: *i64) -> i64 |