code wiki / (root) / nx_crispr.nx

nx_crispr.nx

buildroot/runtime/nx_crispr.nx

8134 B223 linesdepth 3pulls 3 transitivereach 3 importersview sourcekind library
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_tier.nx nx_pamp.nx nx_crispr.nx nx_crispr_test.nx nx_mimicry_compose_test.nx nx_tier1_immune_compose_test.nx

imports: nx_syscalls.nxnx_tier.nxnx_pamp.nx

imported by: nx_crispr_test.nxnx_mimicry_compose_test.nxnx_tier1_immune_compose_test.nx

structs

68struct NxCrisprSpacer
82struct NxCrisprArray

consts

55const NX_CRISPR_OK: nx_int = 0
56const NX_CRISPR_ERR_FULL: nx_int = 1
57const NX_CRISPR_HIT: nx_int = 2 // signature matched
58const NX_CRISPR_MISS: nx_int = 3 // signature not in DB
89const NX_CRISPR_SPACER_BYTES: nx_size = 40
90const NX_CRISPR_DEFAULT_CAPACITY: nx_size = 256

functions

94func nx_crispr_new(capacity: nx_size) -> *NxCrisprArray
called by 3: mainmainmain calls 1: sys_mmap
106func _crispr_at(a: *NxCrisprArray, idx: nx_size) -> *NxCrisprSpacer
117func nx_crispr_match(a: *NxCrisprArray,
144func nx_crispr_remember(a: *NxCrisprArray,
180func nx_crispr_touch(a: *NxCrisprArray, idx: nx_size, now_us: nx_size) -> nx_int
called by 2: mainmain calls 1: _crispr_at
194func nx_crispr_count_kind(a: *NxCrisprArray, kind: nx_int) -> nx_int
called by 3: mainmainmain calls 1: _crispr_at
212func nx_crispr_total_hits(a: *NxCrisprArray) -> nx_int
called by 2: mainmain calls 1: _crispr_at