code wiki / (root) / nx_disk_budget.nx

nx_disk_budget.nx

buildroot/runtime/nx_disk_budget.nx

3899 B118 linesdepth 2pulls 2 transitivereach 21 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_disk_budget.nx -- sovereign hard-ceiling on bytes written to disk. Per user directive 2026-05-14: "your design created massive hard drive wastes of 70 gbs and more in minutes ... nishi lang must be autonomous and timely so that it can do at least a million [algorithms] in a timely manner without massive issues like this". Root-cause class: runaway disk consumption when an ingester writes without an upper bound. This primitive declares the bound at the call site (substrate-additive-not-restrictive cardinal) and traps fail-fast when the ceiling is hit (runaway-execution-substrate cardinal). Usage pattern: let b: *NxDiskBudget = nx_disk_budget_new(5 * 1024 * 1024 * 1024) // ... inside the per-record loop: let rc: nx_int = nx_disk_budget_write(b, fd, line, line_len) if rc == NX_DISK_BUDGET_EXCEEDED { ... emit checkpoint, halt cleanly ... } This is a COUNTER-based budget: it tracks what THIS process writes through the wrapped API. It does not see writes by other processes. genealogy_id: hard_disk_quota lineage_id: function

dependencies 2 imports · 4 importers

nx_syscalls.nx nx_tier.nx nx_disk_budget.nx nx_disk_budget_test.nx nx_ingest_runner.nx nx_ingest_runner_test.nx nx_primitive_synth.nx

imports: nx_syscalls.nxnx_tier.nx

imported by: nx_disk_budget_test.nxnx_ingest_runner.nxnx_ingest_runner_test.nxnx_primitive_synth.nx

structs

44struct NxDiskBudget

consts

38const NX_DISK_BUDGET_OK: nx_int = 0
39const NX_DISK_BUDGET_EXCEEDED: nx_int = -1
40const NX_DISK_BUDGET_WRITE_FAIL: nx_int = -2

functions

53func nx_disk_budget_new(ceiling_bytes: nx_size) -> *NxDiskBudget
called by 3: mainnx_ingest_run_newmain calls 1: sys_mmap
65func nx_disk_budget_can_write(b: *NxDiskBudget, extra_bytes: nx_size) -> nx_int
73func nx_disk_budget_account(b: *NxDiskBudget, n: nx_size) -> nx_size
called by 1: nx_ingest_run_offer
80func nx_disk_budget_write(b: *NxDiskBudget, fd: nx_fd, buf: *nx_byte, n: nx_size) -> nx_int
96func nx_disk_budget_used(b: *NxDiskBudget) -> nx_size
100func nx_disk_budget_remaining(b: *NxDiskBudget) -> nx_size
called by 1: main
105func nx_disk_budget_n_writes_ok(b: *NxDiskBudget) -> nx_int
called by 1: main
109func nx_disk_budget_n_refused(b: *NxDiskBudget) -> nx_int
called by 1: main
115func nx_disk_budget_pct_used(b: *NxDiskBudget) -> nx_int