nx_heavyio_lib.nx
buildroot/runtime/nx_heavyio_lib.nx
about
nx_heavyio_lib.nx -- THE HEAVY-I/O CONCURRENCY BOUND, in the PRIMITIVE layer (runtime/) so every bulk-I/O
producer can reach it (the seq1450 layering rule: primitives may not import the organ layer).
WHY (measured 2026-09-02): the estate's storm ruler nx_ioadmit_lib is an INSTANTANEOUS, PER-CALLER check.
The clock scheduler, nx_compare_regen's fork burst, seg-compact, a daemon restart and a seat-launched job
EACH read "not stormed" at their own instant and all proceed -- and the storm is their SUM, which none of
them individually caused (a TOCTOU / thundering-herd gap). Operator: "this is not sota or best of breed
coordination and discipline for hub spoke resource management". A bound must count what is RUNNING across
every surface, not what was true at one caller's instant.
IT COMPOSES THE TWO INCUMBENTS, NEVER A THIRD RULER: nx_poolgov.pg_width derives K from THIS box (hw budget,
PROPORTIONAL squeeze above the load ceiling, fail-safe to wmin) and pg_count_procs counts the running heavy
class across every surface; nx_ioadmit_lib.ioa_spawn_budget stays as the storm witness, a SECOND conjunct.
Data (rule 11): knowledge/heavyio.conf --
producer <proc-name-needle> one row per heavy-I/O producer (the class this bound governs)
slots_per_cpu <n> floor <n> max_centi <n> wmin <n> wmax <n> size the width (reasoning in the conf)
hio_decide() is PURE and gate-driven; hio_admit() is the thin /proc wrapper. Three states, never a guess:
HIO_ADMIT 1 | HIO_DEFER 0 | HIO_UNOBSERVABLE (-1): conf or /proc unreadable. THE CALLER OWNS THE
UNOBSERVABLE POLICY and must NAME it: a periodic beat announces and proceeds (a missing conf must never
silence the estate's publishers -- the clock's own ioadmit dispatch check still guards the storm); an
interactive spawner may refuse.
license_tier: ORIGINAL Read-only. No hw writes (Rule 26). lib (no main)
dependencies 4 imports · 11 importers
diagram shows first 10 each side; +0 more imports, +1 more importers in the complete lists below.
imports: nx_syscalls.nxnx_poolgov.nxnx_ioadmit_lib.nxnx_lease_lib.nx
imported by: nx_artifactdrift.nxnx_compare_regen.nxnx_compare_regen_scoped.nxnx_compare_regen_t138.nxnx_eco_graph_build.nxnx_heavyio_gate.nxnx_plan_run.nxnx_seg_compact_cli.nxnx_swcompare_evidence.nxnx_web_crawl_step.nxnx_web_shard_compact.nx
structs
| none |
consts
| 28 | const HIO_CONF: *u8 = "knowledge/heavyio.conf" |
| 29 | const HIO_ADMIT: i64 = 1 |
| 30 | const HIO_DEFER: i64 = 0 |
| 31 | const HIO_UNOBSERVABLE: i64 = 0 - 1 |
| 32 | const HIO_MAXP: i64 = 32 // producer rows the conf may carry; the reader announces when it fills |
| 33 | const HIO_NAMEW: i64 = 64 // one producer needle slot (comm names are 15 bytes; cmdline needles longer) |
| 34 | const HIO_CONFCAP: i64 = 65536 |
| 35 | const HIO_SPACE: i64 = 32 |
| 36 | const HIO_NL: i64 = 10 |
| 37 | const HIO_HASH: i64 = 35 |
| 39 | const HIO_C_NPROD: i64 = 0 |
| 40 | const HIO_C_SLOTS: i64 = 1 |
| 41 | const HIO_C_FLOOR: i64 = 2 |
| 42 | const HIO_C_MAXC: i64 = 3 |
| 43 | const HIO_C_WMIN: i64 = 4 |
| 44 | const HIO_C_WMAX: i64 = 5 |
| 45 | const HIO_C_FILLED: i64 = 6 // 1 when HIO_MAXP was reached (rows beyond it were NOT read -- announced) |
| 46 | const HIO_C_TTL: i64 = 7 // slot_ttl <sec>: crash guard for a HUNG-BUT-ALIVE holder (a dead one frees at once) |
| 47 | const HIO_C_SLOTS_N: i64 = 8 |
| 48 | const HIO_C_BYTES: i64 = 64 // HIO_C_SLOTS_N * 8 |
| 51 | const HIO_O_RUNNING: i64 = 0 |
| 52 | const HIO_O_WIDTH: i64 = 1 |
| 53 | const HIO_O_STORM: i64 = 2 |
| 54 | const HIO_O_SLOT: i64 = 3 |
| 55 | const HIO_OUT_BYTES: i64 = 32 |
| 60 | const HIO_ROOT_A: *u8 = "knowledge/" |
| 61 | const HIO_ROOT_B: *u8 = "../knowledge/" |
| 62 | const HIO_CONF_LEAF: *u8 = "heavyio.conf" |
| 63 | const HIO_LEASE_LEAF: *u8 = "lease/" |
| 64 | const HIO_SLOT_PFX: *u8 = "heavyio-slot-" |
| 65 | const HIO_OWNER_PFX: *u8 = "pid" |
| 66 | const HIO_PROC_PFX: *u8 = "/proc/" |
| 67 | const HIO_PROC_LEAF: *u8 = "/stat" |
| 68 | const HIO_PATHCAP: i64 = 256 |
| 69 | const HIO_TTL_DEFAULT: i64 = 900 // used ONLY when the conf carries no slot_ttl row; the conf explains 900 |
| 70 | const HIO_POOL_NONE: i64 = 0 - 1 // every slot held by a LIVE holder -> DEFER |
| 71 | const HIO_POOL_IO: i64 = 0 - 2 // every slot attempt failed with io (lease root unwritable) -> UNOBSERVABLE, never a stall |
functions
| 73 | func hio_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 74 | func hio_cat(d: *u8, o: i64, s: *u8) -> i64 { var i: i64 = 0; var p: i64 = o; while s[i] != (0 as u8) { d[p] = s[i]; p = p + 1; i = i + 1 } return p } |
| 75 | func hio_catn(d: *u8, o: i64, v: i64) -> i64 { let t: *u8 = sys_mmap(28); var m: i64 = v; var p: i64 = o; if m < 0 { d[p] = 45 as u8; p = p + 1; m = 0 - m } var k: i64 = 0; if m == 0 { t[0] = 48 as u8; k = 1 } while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } var i: i64 = 0; while i < k { d[p] = t[k-1-i]; p = p + 1; i = i + 1 } return p } called by 6: hg_fx_pathshg_plant_slot0hio_pid_alivehio_ownerhio_slot_namehio_announce calls 1: sys_mmap |
| 76 | func hio_eol(q: *u8, i: i64, n: i64) -> i64 { var e: i64 = i; var s: i64 = 1; while s == 1 { if e >= n { s = 0 } else { if q[e] == (HIO_NL as u8) { s = 0 } else { e = e + 1 } } } return e } called by 1: hio_conf_read |
| 77 | func hio_keyis(q: *u8, s: i64, e: i64, key: *u8) -> i64 called by 1: hio_conf_read |
| 84 | func hio_atoi(q: *u8, s: i64, e: i64) -> i64 called by 1: hio_conf_read |
| 90 | func hio_slot(names: *u8, i: i64) -> *u8 { return ((names as i64) + i * HIO_NAMEW) as *u8 } |
| 95 | func hio_conf_read(path: *u8, cfg: *i64, names: *u8) -> i64 called by 2: mainhio_admit_conf_root calls 8: sys_openat_rdsys_mmapsys_readsys_closehio_eolhio_keyis+2 |
| 138 | func hio_decide(running: i64, width: i64, storm_budget: i64) -> i64 called by 1: main |
| 148 | func hio_width(cfg: *i64) -> i64 |
| 165 | func hio_running(cfg: *i64, names: *u8) -> i64 |
| 175 | func hio_storm_budget() -> i64 |
| 190 | func hio_pid_alive(pid: i64) -> i64 |
| 203 | func hio_owner_pid(owner: *u8) -> i64 called by 1: hio_pool_acquire |
| 221 | func hio_owner(out: *u8) -> i64 |
| 227 | func hio_slot_name(i: i64, out: *u8) -> i64 |
| 234 | func hio_root(root: *u8) -> i64 |
| 249 | func hio_lease_root(root: *u8, out: *u8) -> i64 |
| 257 | func hio_pool_acquire(lroot: *u8, width: i64, ttl: i64) -> i64 called by 2: mainhio_admit_conf_root calls 10: ls_mkdirsys_openat_rdsys_closesys_mmaphio_ownerhio_slot_name+4 |
| 288 | func hio_pool_release(lroot: *u8, slot: i64) -> i64 |
| 298 | func hio_decide_pool(width: i64, storm_budget: i64, slot: i64) -> i64 |
| 309 | func hio_admit_conf_root(root: *u8, path: *u8, out: *i64) -> i64 called by 3: mainhio_admit_confhio_admit calls 8: sys_mmaphio_conf_readhio_runninghio_widthhio_storm_budgethio_lease_root+2 |
| 327 | func hio_admit_conf(path: *u8, out: *i64) -> i64 { return hio_admit_conf_root(HIO_ROOT_A, path, out) } |
| 328 | func hio_admit(out: *i64) -> i64 |
| 341 | func hio_release(out: *i64) -> i64 |
| 352 | func hio_announce(fd: i64, verdict: i64, out: *i64) -> i64 |
| 370 | func hio_ratchet_next(floor: i64, adopters: i64) -> i64 called by 1: main |