nx_crispr.nx
buildroot/runtime/nx_crispr.nx
about
nx_crispr.nx -- adaptive signature memory (Tier-1 immune).
Biology: CRISPR-Cas is the bacterial adaptive immune system. When
a virus infects, bacteria capture a fragment of viral DNA as a
"spacer" in their CRISPR array; on next encounter, Cas enzymes
match the spacer and cleave the virus. Substrate equivalent: when
nx_pamp detects a hit, nx_crispr remembers its content-addressed
signature; on next encounter the lookup is O(1) and the response
can fire WITHOUT re-running pamp's expensive scanners.
THIS COMPLETES THE LEARN-FROM-EXPERIENCE LOOP. nx_pamp is the
pattern recognition; nx_crispr is the memory. Together they
implement adaptive innate immunity. Per [[feedback-unified-immune-
architecture-three-tier]] the signature DB grows across encounters
and (V2) shares via peer mesh so every Nishi cell benefits from
every Nishi cell's incident history.
Composes:
nx_pamp -- supplier of new signatures to remember
nx_xenocell -- the source of confirmed-hostile events
nx_decoy -- decoy hits become CRISPR entries since they prove
someone read the decoy
nx_evict_journal -- pre-existing forensic substrate; CRISPR
complements (pamp_journal is event log,
crispr is THE SIGNATURE INDEX)
V1 ships a fixed-capacity ring of spacer entries. V2 makes it
peer-sharable (content-addressed merkle tree) so the community
shares intrusion intelligence without leaking specifics.
Gap list (V1 honest perf verdict):
- linear-scan lookup; V2 builds hash index for O(1)
- no automatic expiration of stale spacers
- no peer-mesh federation
- no signature-class grouping (every spacer treated independently)
genealogy_id: cardinal_2026-05-19_tier_1_innate_immune_microbial +
biology_CRISPR_Cas_adaptive_immunity
lineage_id: substrate_crispr_v1
dependencies 3 imports · 3 importers
imports: nx_syscalls.nxnx_tier.nxnx_pamp.nx
imported by: nx_crispr_test.nxnx_mimicry_compose_test.nxnx_tier1_immune_compose_test.nx
structs
| 68 | struct NxCrisprSpacer |
| 82 | struct NxCrisprArray |
consts
| 55 | const NX_CRISPR_OK: nx_int = 0 |
| 56 | const NX_CRISPR_ERR_FULL: nx_int = 1 |
| 57 | const NX_CRISPR_HIT: nx_int = 2 // signature matched |
| 58 | const NX_CRISPR_MISS: nx_int = 3 // signature not in DB |
| 89 | const NX_CRISPR_SPACER_BYTES: nx_size = 40 |
| 90 | const NX_CRISPR_DEFAULT_CAPACITY: nx_size = 256 |
functions
| 94 | func nx_crispr_new(capacity: nx_size) -> *NxCrisprArray |
| 106 | func _crispr_at(a: *NxCrisprArray, idx: nx_size) -> *NxCrisprSpacer |
| 117 | func nx_crispr_match(a: *NxCrisprArray, |
| 144 | func nx_crispr_remember(a: *NxCrisprArray, |
| 180 | func nx_crispr_touch(a: *NxCrisprArray, idx: nx_size, now_us: nx_size) -> nx_int |
| 194 | func nx_crispr_count_kind(a: *NxCrisprArray, kind: nx_int) -> nx_int |
| 212 | func nx_crispr_total_hits(a: *NxCrisprArray) -> nx_int |