code wiki / (root) / nx_leak_check.nx

nx_leak_check.nx

buildroot/runtime/nx_leak_check.nx

15434 B274 linesdepth 4pulls 5 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

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

nx_leak_check_lib.nx nx_leak_check.nx

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

main lk_puts lk_seq lk_atoi lk_clamp_n lc_now_ms sys_mmap sys_clock_gettime_mono sys_munmap lc_vsz sys_mmap ↻ lc_itoa sys_mmap ↻ sys_munmap ↻ vw_vmsize_kb_of vw_status_kb_of sys_mmap ↻ vw_read sys_openat_rd sys_read sys_close sys_munmap ↻ vw_status_kb vw_slen sys_mmap ↻ vw_num_at sys_munmap ↻ sys_munmap ↻ osp_cpu_ticks osp_stat_field sys_mmap ↻ osp_ppath osp_itoa sys_mmap ↻ osp_bread sys_openat_rd ↻ sys_read ↻ sys_close ↻ osp_num sys_sleep_ms

structs

none

consts

12const LK_ARG_VERB: i64 = 1
13const LK_ARG_P1: i64 = 2 // series: pid ; fleet: samples
14const LK_ARG_P2: i64 = 3 // series: samples ; fleet: interval_ms
15const LK_ARG_P3: i64 = 4 // series: interval_ms
16const LK_ARGC_FLEET: i64 = 4 // fleet samples interval
17const LK_ARGC_SERIES: i64 = 5 // series pid samples interval
18const LK_RC_USAGE: i64 = 2
19const LK_RC_LEAK: i64 = 1
20const LK_MAX_S: i64 = 32 // max samples per series
21const LK_MAX_ORG: i64 = 256 // max organs in a fleet scan
22const LK_MAX_PROC: i64 = 4096 // /proc pid enumeration cap
23const LK_PAIRS: i64 = 496 // LK_MAX_S*(LK_MAX_S-1)/2 -- Theil-Sen pairwise-slope scratch
24const LK_WORD: i64 = 8
25const LK_MS_PER_S: i64 = 1000
26const LK_SEV_CHURN: i64 = 1 // severity ladder: HEALTHY 0 < CHURN 1 < SPIKE 2 < LEAK 3
27const LK_SEV_SPIKE: i64 = 2
28const LK_SEV_LEAK: i64 = 3
29const LK_SEV_CRIT: i64 = 2 // severity >= this (SPIKE|LEAK) = CRITICAL (fails the fleet exit)
30const LK_MIN_AGE_S: i64 = 120 // a LEAK verdict requires a process OLD ENOUGH to own a baseline: fork-per-

functions

36func 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 }
37func lk_putn(v: i64) -> i64
47func 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
48func lk_atoi(s: *u8) -> i64
called by 1: main
54func lk_clamp_n(n: i64) -> i64
called by 1: main
62func lk_verdict_line(out: *i64) -> i64
called by 1: main calls 2: lk_putslk_putn
74func lk_code_name(code: i64) -> *u8
called by 1: lk_meter
81func lk_sev(code: i64) -> i64
called by 1: main
88func lk_meter(label: *u8, out: *i64) -> i64
called by 1: main calls 3: lk_putslk_code_namelk_putn
99func lk_proc_age_s(pid: i64, hz: i64) -> i64
104func lk_cpu_util(cpu: *i64, coff: i64, ts: *i64, n: i64, util: *i64, utime: *i64, hz: i64) -> i64
called by 1: main
115func main(argc: i64, argv: *i64) -> i64