nx_budget.nx
buildroot/runtime/nx_budget.nx
about
nx_budget.nx -- declared resource ceiling per cell.
Per cardinal: cooperative-resource-arbitration. A cell declares its
hard ceiling at instantiation; allocation-beyond-budget returns
denial, never crashes the host. This is the structural EXCEED-axis
vs Docker / WSL2 / containerd silent OOM-kill: the host OS-level
OOM-killer cannot reach Nishi cells because cells refuse to ask for
more than they declared.
Composes:
nx_attention_class -- foreground class can preempt background
budget on contention via nx_yield
nx_evict_journal -- every denial / forced release is logged
nx_homeostasis -- when used > ceiling * threshold, migration
signal fires (nx_tropism resolves target)
nx_tier -- buffer sizes (NX_BUF_*) inform sane defaults
across NX_TIER_MCU..NX_TIER_HPC
V1 ships five resource kinds; further kinds (GPU compute units,
FPGA cells, peer-link bandwidth) are queued.
Gap list (V1 honest perf verdict):
- no atomic CAS on used counters (single-threaded cell assumption)
- no time-windowed rate limiting (net_bps is current-instant only)
- no nested sub-budgets (one flat ceiling per cell)
- no serialization to disk (in-memory only this phase)
genealogy_id: nishi_cardinal_2026-05-17_cooperative_resource_arbitration
lineage_id: substrate_budget_v1
nx_safety_envelope:
intended_use: "Per-cell resource ceiling enforcement;
prevents host OOM by denying over-budget asks"
sil_target: SIL2
asil_target: QM
dal_target: DAL C
evidence: [denial_before_alloc, no_silent_overshoot,
used_le_max_invariant]
hazard_register: [bug-tape-budget-counter-overflow,
bug-tape-release-without-prior-request]
dependencies 2 imports · 27 importers
diagram shows first 10 each side; +0 more imports, +17 more importers in the complete lists below.
imports: nx_syscalls.nxnx_tier.nx
imported by: nx_budget_alloc.nxnx_budget_alloc_test.nxnx_budget_test.nxnx_cell.nxnx_cell_anatomy_compose_test.nxnx_cell_test.nxnx_ecosystem_compose_test.nxnx_homeostasis.nxnx_homeostasis_test.nxnx_lysis.nxnx_microbiome_test.nxnx_organism.nxnx_organism_test.nxnx_pathway.nxnx_pathway_test.nxnx_pollinate.nxnx_promote.nxnx_reclaim.nxnx_reclaim_test.nxnx_sovereign_compose_test.nxnx_substrate_compose_test.nxnx_symbiote.nxnx_symbiote_test.nxnx_tier3_ecology_compose_test.nxnx_treaty.nxnx_treaty_test.nxnx_xenocell.nx
structs
| 78 | struct NxBudget |
consts
| 51 | const NX_RES_RAM: nx_int = 0 |
| 52 | const NX_RES_VRAM: nx_int = 1 |
| 53 | const NX_RES_CPU: nx_int = 2 // cpu time, microseconds per tick |
| 54 | const NX_RES_DISK: nx_int = 3 // disk bytes written |
| 55 | const NX_RES_NET: nx_int = 4 // network bytes per second |
| 56 | const NX_RES_N_KINDS: nx_int = 5 |
| 66 | const NX_BUDGET_OK: nx_int = 0 |
| 67 | const NX_BUDGET_ERR_BAD_KIND: nx_int = 1 |
| 68 | const NX_BUDGET_ERR_OVER: nx_int = 2 // would exceed ceiling |
| 69 | const NX_BUDGET_ERR_UNDERFLOW: nx_int = 3 // release without request |
functions
| 58 | func nx_res_kind_is_valid(k: nx_int) -> nx_int |
| 94 | func nx_budget_new(cell_id: nx_int, |
| 122 | func nx_budget_request(b: *NxBudget, kind: nx_int, want: nx_size) -> nx_int |
| 158 | func nx_budget_release(b: *NxBudget, kind: nx_int, n: nx_size) -> nx_int |
| 193 | func nx_budget_remaining(b: *NxBudget, kind: nx_int) -> nx_size |
| 207 | func nx_budget_pressure_q10(b: *NxBudget, kind: nx_int) -> nx_int |