nx_immune.nx
buildroot/runtime/nx_immune.nx
about
nx_immune.nx -- Tier-2 colony-level adaptive immune coordinator.
Per [[feedback-unified-immune-architecture-three-tier]] Tier 2:
"ADAPTIVE / MULTICELLULAR -- specialized cells + learning + memory;
existing nx_thymus (substrate audit) + nx_immune (runtime defense)."
nx_antibody is the per-cell defense-generation primitive (Tier 1+);
nx_immune is the COLONY-LEVEL orchestrator that:
1. Tracks which cells in the host are currently HEALTHY/ALERTED/
RESPONDING/COMPROMISED
2. Propagates antibody discoveries (clonal-expansion analog):
when one cell's antibody matures to MEMORY state, immune
distributes a copy to every other cell so the same threat
is detected colony-wide on first encounter
3. Coordinates lysis-response: when any cell calls for lysis on
a foreign entity touching multiple cells, immune issues a
colony-wide enforcement (vs each cell deciding alone)
4. Surfaces a COLONY STATUS to the operator (HEALTHY when all
cells healthy; ALERTED when any cell sees a hit; RESPONDING
when active lysis ongoing; COMPROMISED when any cell entered
the abortive-terminal state)
Per [[feedback-captain-moroni-doctrine]]: defensive-only. Colony
response is to PROTECT remaining cells, never to attack.
Composes:
nx_antibody -- per-cell antibodies clone-expand via immune
nx_lysis -- colony-wide enforcement decision
nx_xenocell -- intrusions observed across cells aggregate here
nx_abortive -- cell-state-machine; immune watches transitions
nx_evict_journal -- colony events logged
nx_pollinate (queued) -- cross-host community distribution
V1 ships:
- struct NxImmune holding cell registry + antibody clone-store
- cell-state tracking
- antibody clonal-expansion broadcast
- colony status aggregation
Gap list (V1 honest perf verdict):
dependencies 5 imports · 2 importers
imports: nx_syscalls.nxnx_tier.nxnx_evict_journal.nxnx_antibody.nxnx_lysis.nx
imported by: nx_immune_test.nxnx_tier2_immune_compose_test.nx
structs
| 89 | struct NxImmuneCellRow |
| 103 | struct NxImmune |
consts
| 69 | const NX_COL_HEALTHY: nx_int = 0 |
| 70 | const NX_COL_ALERTED: nx_int = 1 // at least one cell saw a hit |
| 71 | const NX_COL_RESPONDING: nx_int = 2 // active lysis ongoing |
| 72 | const NX_COL_COMPROMISED: nx_int = 3 // at least one cell terminal |
| 73 | const NX_COL_N_STATUSES: nx_int = 4 |
| 77 | const NX_IM_OK: nx_int = 0 |
| 78 | const NX_IM_ERR_FULL: nx_int = 1 |
| 79 | const NX_IM_ERR_BAD_CELL: nx_int = 2 |
| 80 | const NX_IM_ERR_BAD_STATUS: nx_int = 3 |
| 111 | const NX_IM_CELL_BYTES: nx_size = 40 |
functions
| 115 | func nx_col_status_is_valid(s: nx_int) -> nx_int |
| 123 | func nx_immune_new(cell_capacity: nx_size, journal: *NxEvictJournal) -> *NxImmune |
| 136 | func _immune_at(i: *NxImmune, idx: nx_size) -> *NxImmuneCellRow |
| 142 | func _immune_find_cell(i: *NxImmune, cell_id: nx_int) -> nx_int |
| 158 | func nx_immune_register_cell(i: *NxImmune, |
| 175 | func nx_immune_set_cell_status(i: *NxImmune, |
| 196 | func nx_immune_global_status(i: *NxImmune) -> nx_int |
| 220 | func nx_immune_clonal_expand(i: *NxImmune, |
| 251 | func nx_immune_alert_count(i: *NxImmune, cell_id: nx_int) -> nx_int |
| 260 | func nx_immune_count_cells_in_status(i: *NxImmune, status: nx_int) -> nx_size |
| 278 | func nx_immune_should_quarantine_host(i: *NxImmune) -> nx_int |