nx_disk_budget.nx
buildroot/runtime/nx_disk_budget.nx
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
imports: nx_syscalls.nxnx_tier.nx
imported by: nx_disk_budget_test.nxnx_ingest_runner.nxnx_ingest_runner_test.nxnx_primitive_synth.nx
structs
| 44 | struct NxDiskBudget |
consts
| 38 | const NX_DISK_BUDGET_OK: nx_int = 0 |
| 39 | const NX_DISK_BUDGET_EXCEEDED: nx_int = -1 |
| 40 | const NX_DISK_BUDGET_WRITE_FAIL: nx_int = -2 |
functions
| 53 | func nx_disk_budget_new(ceiling_bytes: nx_size) -> *NxDiskBudget |
| 65 | func nx_disk_budget_can_write(b: *NxDiskBudget, extra_bytes: nx_size) -> nx_int |
| 73 | func nx_disk_budget_account(b: *NxDiskBudget, n: nx_size) -> nx_size called by 1: nx_ingest_run_offer |
| 80 | func nx_disk_budget_write(b: *NxDiskBudget, fd: nx_fd, buf: *nx_byte, n: nx_size) -> nx_int |
| 96 | func nx_disk_budget_used(b: *NxDiskBudget) -> nx_size |
| 100 | func nx_disk_budget_remaining(b: *NxDiskBudget) -> nx_size called by 1: main |
| 105 | func nx_disk_budget_n_writes_ok(b: *NxDiskBudget) -> nx_int called by 1: main |
| 109 | func nx_disk_budget_n_refused(b: *NxDiskBudget) -> nx_int called by 1: main |
| 115 | func nx_disk_budget_pct_used(b: *NxDiskBudget) -> nx_int |