code wiki / _hdl_build / nx_res_census.nx
nx_res_census.nx
buildroot/runtime/_hdl_build/nx_res_census.nx
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
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
structs
| none |
consts
| 25 | const RC_LOG: *u8 = "knowledge/status/res_census.log\x00" |
| 26 | const RC_PIDCAP: i64 = 8192 // /proc numeric entries enumerated (dir rows) |
| 27 | const RC_FBUF: i64 = 65536 // one proc-file read buffer (status/cmdline/meminfo), reused |
| 28 | const RC_LOGBUF: i64 = 4194304 // prior trend-log window for delta lookup (TRUNC honestly noted) |
functions
| 30 | func rc_slen(s: *u8) -> i64 { return sj_vlen(s) } |
| 31 | func rc_w(fd: i64, s: *u8) -> i64 { sys_write(fd, s, rc_slen(s)); return 0 } |
| 33 | func rc_wn(fd: i64, v: i64, scr: *u8) -> i64 |
| 44 | func rc_cat(dst: *u8, o: i64, s: *u8) -> i64 { return sj_cat(dst, o, s) } |
| 45 | func rc_catn(dst: *u8, o: i64, v: i64, scr: *u8) -> i64 called by 1: main |
| 56 | func rc_find(buf: *u8, n: i64, needle: *u8) -> i64 |
| 69 | func rc_num_after(buf: *u8, n: i64, i0: i64) -> i64 |
| 78 | func rc_kb(buf: *u8, n: i64, label: *u8) -> i64 |
| 83 | func rc_all_digits(nm: *u8, len: i64) -> i64 called by 1: main |
| 90 | func rc_readf(path: *u8, buf: *u8, cap: i64) -> i64 |
| 101 | func 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 |
| 106 | func rc_prev(logbuf: *u8, ln: i64, name: *u8, tag: *u8) -> i64 |
| 141 | func main(argc: i64, argv: *i64) -> i64 |