code wiki / _hdl_build / nx_res_census.nx

nx_res_census.nx

buildroot/runtime/_hdl_build/nx_res_census.nx

14867 B277 linesdepth 6pulls 7 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_res_census.nx -- THE RUNTIME RESOURCE WITNESS (per-daemon + system, trend-logged). 2026-07-05 OOM arc + operator: "efficiency in our resource use across ALL the nishi ecosystems ... live resources and storage and all the other axes" + "measured every poll, not discovered at OOM". WHY THIS ORGAN EXISTS (no-tool-proliferation: consolidation-check DONE, justified NEW): nx_explore for VmRSS / proc_status / resource_census / diskspace = 0 files -- NOTHING reads per-process memory anywhere in the ecosystem; the 26GiB health_eval leak + the 2.5TB clock commit were discovered AT OOM, and the leak diagnosis lived only in a memory note. This is the RUNTIME half of the two-witness law: the static half (nx_antipattern_catalog leaksweep) catches the DIRECT mmap-in-loop shape but proved BLIND to the helper-indirection tier (nx_seed_announce_all: 199MB grown, ZERO static sites) -- only a per-daemon RSS/VmSize GROWTH TREND catches that class. Single responsibility (Cardinal 9): MEASURE + LOG + show DELTA. It is a WITNESS, not a judge -- no thresholds baked in (Cardinal 11); the judge tier composes later (nx_metric_ledger BETTER/WORSE, mgmt_snapshot surface, clock-registry cadence = OWNER wiring on the NAS; hardware-up honesty: this run proves the mechanism on the dev substrate, the target wiring is hostctl/clock). SIGNATURE TABLE (banked by the OOM workstream): huge VmSize = commit-leak / fork-wedge class; huge anon-RSS = the OOM-killer class. Both columns logged so the trend separates them. MMAP DISCIPLINE: every buffer HOISTED once in main -- this organ must scan CLEAN under the leaksweep it complements (practice the law). license_tier: ORIGINAL lineage_id: nishi_res_census_v1 expect_exit: 0

dependencies 3 imports · 0 importers

nx_sovjson_lib.nx nx_syscalls.nx nx_dir.nx nx_res_census.nx

imports: nx_sovjson_lib.nxnx_syscalls.nxnx_dir.nx

imported by: nobody (leaf or entry point)

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

main sys_mmap rc_w sys_write rc_slen sj_vlen rc_readf sys_openat_rd sys_read sys_close sys_now_realtime_sec sys_mmap ↻ sys_clock_gettime_real rc_openat_append rc_cat sj_cat rc_kb rc_find rc_slen ↻ rc_num_after rc_slen ↻ rc_catn sys_write ↻ nx_dir_list nx_openat nx_dirent_read nx_dirent_iter nx_dir_is_dotlike nx_dir_name_strlen nx_dir_arena_copy_name rc_all_digits rc_find ↻ rc_prev rc_slen ↻ rc_find ↻ rc_num_after ↻ rc_wn sys_write ↻ sys_close ↻ sys_exit

structs

none

consts

25const RC_LOG: *u8 = "knowledge/status/res_census.log\x00"
26const RC_PIDCAP: i64 = 8192 // /proc numeric entries enumerated (dir rows)
27const RC_FBUF: i64 = 65536 // one proc-file read buffer (status/cmdline/meminfo), reused
28const RC_LOGBUF: i64 = 4194304 // prior trend-log window for delta lookup (TRUNC honestly noted)

functions

30func rc_slen(s: *u8) -> i64 { return sj_vlen(s) }
called by 4: rc_wrc_findrc_kbrc_prev calls 1: sj_vlen
31func rc_w(fd: i64, s: *u8) -> i64 { sys_write(fd, s, rc_slen(s)); return 0 }
called by 1: main calls 2: sys_writerc_slen
33func rc_wn(fd: i64, v: i64, scr: *u8) -> i64
called by 1: main calls 1: sys_write
44func rc_cat(dst: *u8, o: i64, s: *u8) -> i64 { return sj_cat(dst, o, s) }
called by 1: main calls 1: sj_cat
45func rc_catn(dst: *u8, o: i64, v: i64, scr: *u8) -> i64
called by 1: main
56func rc_find(buf: *u8, n: i64, needle: *u8) -> i64
called by 3: rc_kbrc_prevmain calls 1: rc_slen
69func rc_num_after(buf: *u8, n: i64, i0: i64) -> i64
called by 2: rc_kbrc_prev
78func rc_kb(buf: *u8, n: i64, label: *u8) -> i64
called by 1: main calls 3: rc_findrc_num_afterrc_slen
83func rc_all_digits(nm: *u8, len: i64) -> i64
called by 1: main
90func rc_readf(path: *u8, buf: *u8, cap: i64) -> i64
called by 1: main calls 3: sys_openat_rdsys_readsys_close
101func rc_openat_append(path: *u8) -> i64 { return __syscall(257, AT_FDCWD, path, 0x441, 0x1a4, 0, 0) } // O_WRONLY|O_CREAT|O_APPEND 0644 (same idiom as nx_tools_api revocation list)
called by 1: main
106func rc_prev(logbuf: *u8, ln: i64, name: *u8, tag: *u8) -> i64
called by 1: main calls 3: rc_slenrc_findrc_num_after
141func main(argc: i64, argv: *i64) -> i64