code wiki / (root) / nx_homeostasis.nx

nx_homeostasis.nx

buildroot/runtime/nx_homeostasis.nx

6411 B144 linesdepth 3pulls 6 transitivereach 12 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_homeostasis.nx -- steady-state monitor that triggers migration. Biological analogue: homeostasis is the body's set-point control -- when blood glucose / pH / temperature drift past tolerance bands, counter-regulatory signals fire. Nishi homeostasis watches each cell's budget pressure, eviction history, and metabolism heat; when any drifts past its set-point, it emits a migration signal that nx_tropism resolves into a concrete relocation target. This is the structural EXCEED-axis vs the kernel OOM-killer: the kernel waits until the host is OUT of memory and then kills the biggest offender after the fact. Homeostasis fires PROACTIVELY at 90% pressure (Q10 921), giving the substrate slack to relocate the cell cleanly before any user-visible disruption. Composes: nx_budget -- pressure_q10 per resource nx_evict_journal -- count_for_cell to spot eviction storms nx_metabolism -- hot sites are migration candidates nx_attention_class -- foreground cells prefer local migration; idle cells are offload-OK to peer/cloud nx_tropism -- consumes the migration signal to pick target V1 ships per-cell snapshot polling. Continuous monitoring (an integrator that fires on sustained pressure rather than instantaneous) is queued; today the caller drives polling at its preferred cadence (a 100ms tick is the canonical default). Gap list (V1 honest perf verdict): - no integrator / leaky-bucket dampening (transient spikes can fire migration signals) - no cross-cell pressure (only per-cell, not host-aggregate) - no de-bounce on repeated MIGRATE signals from same cell - no return-to-set-point hysteresis (cell re-evaluated each tick) genealogy_id: nishi_cardinal_2026-05-17_cooperative_resource_arbitration + cardinal-21 lineage_id: substrate_homeostasis_v1 nx_safety_envelope: intended_use: "Proactive migration trigger before host OOM;

dependencies 6 imports · 5 importers

nx_syscalls.nx nx_tier.nx nx_budget.nx nx_evict_journal.nx nx_metabolism.nx nx_attention_class.nx nx_homeostasis.nx nx_ecosystem_compose_test.nx nx_homeostasis_test.nx nx_substrate_compose_test.nx nx_tropism.nx nx_tropism_test.nx

imports: nx_syscalls.nxnx_tier.nxnx_budget.nxnx_evict_journal.nxnx_metabolism.nxnx_attention_class.nx

imported by: nx_ecosystem_compose_test.nxnx_homeostasis_test.nxnx_substrate_compose_test.nxnx_tropism.nxnx_tropism_test.nx

structs

none

consts

58const NX_HOMEO_STEADY: nx_int = 0 // within bands, no action
59const NX_HOMEO_MIGRATE_RAM: nx_int = 1 // RAM pressure -> move
60const NX_HOMEO_MIGRATE_VRAM: nx_int = 2 // VRAM pressure -> move
61const NX_HOMEO_MIGRATE_DISK: nx_int = 3 // disk pressure -> archive
62const NX_HOMEO_MIGRATE_THERMAL: nx_int = 4 // CPU pressure -> offload
63const NX_HOMEO_DEMOTE_TIER: nx_int = 5 // metabolism says step down
64const NX_HOMEO_PROMOTE_TIER: nx_int = 6 // metabolism says step up
65const NX_HOMEO_EVICTION_STORM: nx_int = 7 // displaced too often
66const NX_HOMEO_N_SIGNALS: nx_int = 8
74const NX_HOMEO_MIGRATE_PRESSURE_Q10: nx_int = 921
75const NX_HOMEO_DEMOTE_PRESSURE_Q10: nx_int = 972
76const NX_HOMEO_EVICTION_STORM_AT: nx_int = 5

functions

89func nx_homeo_check(b: *NxBudget,
130func nx_homeo_signal_is_migration(sig: nx_int) -> nx_int
called by 1: main
140func nx_homeo_signal_is_valid(sig: nx_int) -> nx_int
called by 1: main