nx_promote.nx
buildroot/runtime/nx_promote.nx
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
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
| 91 | struct NxFailoverContract |
consts
| 65 | const NX_PR_TRG_NONE: nx_int = 0 |
| 66 | const NX_PR_TRG_RANSOMWARE: nx_int = 1 |
| 67 | const NX_PR_TRG_IMMUNE_COMPROMISED: nx_int = 2 |
| 68 | const NX_PR_TRG_PRIMARY_CRASHED: nx_int = 3 |
| 69 | const NX_PR_TRG_OPERATOR_DRILL: nx_int = 4 |
| 70 | const NX_PR_TRG_RESOURCE_OOM: nx_int = 5 |
| 71 | const NX_PR_TRG_HEALTH_CHECK_FAIL: nx_int = 6 |
| 72 | const NX_PR_TRG_N_TRIGGERS: nx_int = 7 |
| 76 | const NX_PROMOTE_OK: nx_int = 0 |
| 77 | const NX_PROMOTE_ERR_NO_CHROMATIN: nx_int = 1 |
| 78 | const NX_PROMOTE_ERR_BAD_TRIGGER: nx_int = 2 |
| 79 | const NX_PROMOTE_ERR_BACKUP_STALE: nx_int = 3 |
| 80 | const NX_PROMOTE_ERR_PRIMARY_HEALTHY: nx_int = 4 // operator-drill safety |
| 81 | const NX_PROMOTE_ERR_BAD_MARK: nx_int = 5 |
functions
| 103 | func nx_pr_trigger_is_valid(t: nx_int) -> nx_int |
| 111 | func nx_failover_contract_new(service_id: nx_int, |
| 132 | func nx_promote_update_chromatin(c: *NxFailoverContract, |
| 161 | func nx_promote_execute(c: *NxFailoverContract, |
| 197 | func nx_promote_is_primary(c: *NxFailoverContract, cell_id: nx_int) -> nx_int |
| 209 | func nx_promote_flap_count(c: *NxFailoverContract) -> nx_int |