code wiki / (root) / nx_promote.nx

nx_promote.nx

buildroot/runtime/nx_promote.nx

8574 B211 linesdepth 4pulls 7 transitivereach 2 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_promote.nx -- failover manifest-pointer swap. Per [[feedback-cell-immune-system-ransomware-judo-ddos-by-bit]]: "failover = manifest pointer flip = sub-second. Attacker's win requires PERSISTENCE; ephemeral content-addressed cells deny persistence by design." THE OPERATION: at any moment, a logical service is served by PRIMARY cell A. A backup cell B holds a chromatin replica of A's state. When A is compromised / freezes / OOMs, nx_promote: 1. Pauses A (substrate-level mark; integration layer enforces) 2. Restores B from its chromatin (if not already running) 3. Updates the service manifest pointer: PRIMARY = B 4. Logs the failover event with the trigger reason Caller drives WHEN (immune anomaly, operator request, scheduled drill). Substrate provides WHAT (the manifest-swap primitive). Composes: nx_chromatin -- B's state replica nx_immune -- A's COMPROMISED status triggers automatic promote nx_abortive -- A enters terminal state; B promotes alongside nx_xenocell -- the foreign agent that triggered failover is recorded as displaced_by in the journal entry nx_evict_journal -- failover event logged with reason nx_provenance_chain -- the swap is a transform; chain-logged V1 ships: - struct NxFailoverContract (primary cell_id + backup cell_id + trigger reason + ts of last swap) - swap operation atomic at this layer (caller's integration layer must ensure no in-flight ops at swap point) - is_primary predicate for downstream readers Gap list (V1 honest perf verdict): - sub-second SLA depends on chromatin freshness (V2 measures) - no automatic split-brain detection (two cells both claiming primary) -- caller's coordination layer responsibility - no rollback after failed promote (V2 adds health check post-promote with auto-rollback)

dependencies 6 imports · 2 importers

nx_syscalls.nx nx_tier.nx nx_budget.nx nx_attention_class.nx nx_evict_journal.nx nx_chromatin.nx nx_promote.nx nx_failover_compose_test.nx nx_promote_test.nx

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

imported by: nx_failover_compose_test.nxnx_promote_test.nx

structs

91struct NxFailoverContract

consts

65const NX_PR_TRG_NONE: nx_int = 0
66const NX_PR_TRG_RANSOMWARE: nx_int = 1
67const NX_PR_TRG_IMMUNE_COMPROMISED: nx_int = 2
68const NX_PR_TRG_PRIMARY_CRASHED: nx_int = 3
69const NX_PR_TRG_OPERATOR_DRILL: nx_int = 4
70const NX_PR_TRG_RESOURCE_OOM: nx_int = 5
71const NX_PR_TRG_HEALTH_CHECK_FAIL: nx_int = 6
72const NX_PR_TRG_N_TRIGGERS: nx_int = 7
76const NX_PROMOTE_OK: nx_int = 0
77const NX_PROMOTE_ERR_NO_CHROMATIN: nx_int = 1
78const NX_PROMOTE_ERR_BAD_TRIGGER: nx_int = 2
79const NX_PROMOTE_ERR_BACKUP_STALE: nx_int = 3
80const NX_PROMOTE_ERR_PRIMARY_HEALTHY: nx_int = 4 // operator-drill safety
81const NX_PROMOTE_ERR_BAD_MARK: nx_int = 5

functions

103func nx_pr_trigger_is_valid(t: nx_int) -> nx_int
111func nx_failover_contract_new(service_id: nx_int,
called by 2: mainmain calls 1: sys_mmap
132func nx_promote_update_chromatin(c: *NxFailoverContract,
called by 2: mainmain calls 1: nx_chromatin_is_fresher
161func nx_promote_execute(c: *NxFailoverContract,
197func nx_promote_is_primary(c: *NxFailoverContract, cell_id: nx_int) -> nx_int
called by 2: mainmain
209func nx_promote_flap_count(c: *NxFailoverContract) -> nx_int
called by 2: mainmain