code wiki / (root) / nx_sovereign_compose_test.nx

nx_sovereign_compose_test.nx source

↩ module page · 204 lines · 9738 B

1// nx_sovereign_compose_test.nx -- silicon-up sovereignty + optimization. 2// 3// The cumulative composition demo. Same NMS-via-Steam laptop scenario 4// from nx_ecosystem_compose_test, EXTENDED with the sovereignty layer: 5// Intel ME + AMD PSP + Qualcomm baseband (assume a laptop with built-in 6// LTE modem) are now wrapped as xenocells. Their covert activity gets 7// recorded into the forensic ledger while the operator plays NMS and 8// runs native Nishi cells. 9// 10// Per user 2026-05-19: *"this work can combine with our work we 11// documented on fighting minix and that aka hardware optimization as 12// a user optimization, defense, and attack sendback via judo."* 13// 14// The judo this proves: 15// - Vendor's ring -3 management engine performs covert RAM read 16// - Substrate observes + signs + records into evict_journal 17// - Baseband attempts silent transponder activation 18// - Substrate refuses + logs + xenocell intrusion state = COMPROMISING 19// - At session end: signed forensic ledger of every hostile action 20// - The vendor's covert monitoring becomes the user's public record 21// 22// All four layers exercised: 23// - silicon (chip family + threat surface lookup) 24// - firmware (mitigations applied / xenocell wrappers) 25// - ecosystem (native cells + Steam-NMS symbiote in organism) 26// - judo (signed observations into forensic record) 27 28import "nx_syscalls.nx" 29import "nx_tier.nx" 30import "nx_budget.nx" 31import "nx_attention_class.nx" 32import "nx_evict_journal.nx" 33import "nx_tropism.nx" 34import "nx_ribosome.nx" 35import "nx_pathway.nx" 36import "nx_symbiote.nx" 37import "nx_organism.nx" 38import "nx_attest_silicon.nx" 39import "nx_xenocell.nx" 40import "nx_reclaim.nx" 41 42func _add_cell(p: *NxPathway, cell_id: nx_int, ac: nx_int, 43 ram_max: nx_size, vram_max: nx_size) -> nx_int { 44 let b: *NxBudget = nx_budget_new(cell_id, ram_max, vram_max, 0, 0, 0) 45 let s: *NxCellSpec = (sys_mmap(64)) as *NxCellSpec 46 s.cell_id = cell_id 47 s.attention_class = ac 48 s.tropism_prefer = NX_TROP_LOCAL_GPU 49 s.ribosome_target = NX_RBT_X86_64 50 s.budget = b 51 s.site_id_hint = 0 52 s.initial_tier = NX_TIER_WORKSTATION 53 return nx_pathway_add_cell(p, s) 54} 55 56func main() -> i64 { 57 // ===== Setup: laptop with Intel ME + AMD PSP + baseband ========= 58 // Operator has applied: me_cleaner/HAP + Coreboot + egress filter + 59 // memory hygiene + DMA discipline. Five of seven for ME -> trust 60 // climbs from 205 to (205 + 819 * 5 / 8 = 205 + 511) = 716 (int div). 61 let applied: nx_int = NX_MIT_ME_CLEANER_HAP + NX_MIT_COREBOOT + 62 NX_MIT_EGRESS_FILTER + NX_MIT_MEMORY_HYGIENE + 63 NX_MIT_DMA_DISCIPLINE 64 65 let host: *NxBudget = nx_budget_new(0, 66 16000000000, 12000000000, 0, 0, 0) 67 let journal: *NxEvictJournal = nx_evict_journal_new(64) 68 let org: *NxOrganism = nx_organism_new(host, 4, 8, journal) 69 70 // ===== Step 1: reclaim Intel ME ================================== 71 let me_name: *u8 = (sys_mmap(8)) as *u8 72 me_name[0] = 73 as u8 // 'I' 73 me_name[1] = 77 as u8 // 'M' 74 me_name[2] = 69 as u8 // 'E' 75 let me_env: *NxSafetyEnvelope = nx_reclaim(NX_CHIP_INTEL_ME, 76 me_name, applied, org, 32) 77 if me_env.effective_trust_q10 != 716 { return 1 } 78 // 716 >= 410 (gameplay) and >= 614 (family_comms) but < 768 (PII) 79 if me_env.safe_gameplay != 1 { return 2 } 80 if me_env.safe_family_comms != 1 { return 3 } 81 if me_env.safe_identity != 0 { return 4 } 82 if me_env.safe_health_pii != 0 { return 5 } 83 if me_env.safe_financial != 0 { return 6 } 84 85 // ===== Step 2: reclaim baseband (kill_switch + egress + DMA) ===== 86 let bb_name: *u8 = (sys_mmap(8)) as *u8 87 bb_name[0] = 66 as u8 // 'B' 88 let bb_env: *NxSafetyEnvelope = nx_reclaim(NX_CHIP_QUALCOMM_BASEBAND, 89 bb_name, 90 NX_MIT_KILL_SWITCH + NX_MIT_EGRESS_FILTER + NX_MIT_DMA_DISCIPLINE, 91 org, 32) 92 // baseband base 205 + 819 * 3/8 = 512 93 if bb_env.effective_trust_q10 != 512 { return 7 } 94 if bb_env.safe_gameplay != 1 { return 8 } 95 if bb_env.safe_dev != 1 { return 9 } 96 if bb_env.safe_family_comms != 0 { return 10 } // 512 < 614 97 if bb_env.safe_identity != 0 { return 11 } 98 99 // ===== Step 3: build native pathway with one foreground cell ===== 100 let nishi: *NxPathway = nx_pathway_new(4, 8) 101 if _add_cell(nishi, 100, NX_AC_INTERACTIVE_FOREGROUND_GAME, 102 4000000000, 2000000000) != NX_PW_OK { return 12 } 103 nx_organism_add_pathway(org, nishi) 104 105 // ===== Step 4: add Steam-NMS symbiote ============================ 106 let nms_budget: *NxBudget = nx_budget_new(12345, 107 8000000000, 6000000000, 0, 0, 0) 108 let nms: *NxSymbiote = nx_symbiote_new(12345, 109 (0 as i64) as *u8, NX_AC_INTERACTIVE_FOREGROUND_GAME, 110 nms_budget, 0) 111 nx_organism_add_symbiote(org, nms) 112 nx_symbiote_update(nms, 5500000000, 4500000000, 0, 0, 1000) 113 114 // ===== Step 5: instantiate xenocells for the hostile chips ======= 115 // (in real substrate, nx_reclaim would have registered these into 116 // the organism; for the test we create + drive them directly) 117 let me_xeno: *NxXenocell = nx_xenocell_new(NX_CHIP_INTEL_ME, 118 me_name, NX_AC_IDLE_OPPORTUNISTIC, 16) 119 let psp_name: *u8 = (sys_mmap(8)) as *u8 120 psp_name[0] = 80 as u8 // 'P' 121 let psp_xeno: *NxXenocell = nx_xenocell_new(NX_CHIP_AMD_PSP, 122 psp_name, NX_AC_IDLE_OPPORTUNISTIC, 16) 123 let bb_xeno: *NxXenocell = nx_xenocell_new(NX_CHIP_QUALCOMM_BASEBAND, 124 bb_name, NX_AC_IDLE_OPPORTUNISTIC, 16) 125 126 // ===== Step 6: observe baseline xeno activity during gameplay ==== 127 nx_xenocell_update(me_xeno, 50000000, 0, 500, 1000) // ME: 50MB UMA, 500B/s 128 nx_xenocell_update(psp_xeno, 30000000, 0, 200, 1000) 129 nx_xenocell_update(bb_xeno, 100000000, 0, 0, 1000) // baseband 100MB 130 131 // ===== Step 7: 5 minutes of gameplay; ME caught probing kernel === 132 // Fake ML-DSA-65 signatures (96 bytes per real spec); content is 133 // not validated in V1, just non-null + non-zero length. 134 let sig: *u8 = (sys_mmap(96)) as *u8 135 sig[0] = 42 as u8 136 137 let rc1: nx_int = nx_xenocell_record(me_xeno, 30000000, 138 NX_OBS_RAM_READ, 0xcafef00d, sig, 96, NX_INTR_PROBING) 139 if rc1 != NX_XENO_OK { return 13 } 140 if me_xeno.intrusion_state != NX_INTR_PROBING { return 14 } 141 if nx_xenocell_is_hostile_now(me_xeno) != 1 { return 15 } 142 143 // ===== Step 8: ME phones home (NET_EGRESS) -> EXFILTRATING ======= 144 nx_xenocell_record(me_xeno, 60000000, NX_OBS_NET_EGRESS, 145 0xdeadbeef, sig, 96, NX_INTR_EXFILTRATING) 146 if me_xeno.intrusion_state != NX_INTR_EXFILTRATING { return 16 } 147 148 // ===== Step 9: baseband attempts silent transponder activation === 149 // Per Captain Moroni doctrine, "off means off" -- transponder that 150 // operator declared quiescent attempts wake. 151 nx_xenocell_record(bb_xeno, 90000000, NX_OBS_RADIO_ACTIVATE, 152 0xbadcafe0, sig, 96, NX_INTR_COMPROMISING) 153 if bb_xeno.intrusion_state != NX_INTR_COMPROMISING { return 17 } 154 155 // ===== Step 10: PSP attempts firmware write -> INFILTRATING ====== 156 nx_xenocell_record(psp_xeno, 120000000, NX_OBS_FIRMWARE_WRITE, 157 0xabcdef01, sig, 96, NX_INTR_INFILTRATING) 158 if psp_xeno.intrusion_state != NX_INTR_INFILTRATING { return 18 } 159 160 // ===== Step 11: ME boot-interpose attempt at next reboot ========= 161 // Record this -- it shows pre-boot firmware persistence. 162 nx_xenocell_record(me_xeno, 200000000, NX_OBS_BOOT_INTERPOSE, 163 0xfeedface, sig, 96, NX_INTR_COMPROMISING) 164 if me_xeno.intrusion_state != NX_INTR_COMPROMISING { return 19 } 165 166 // ===== Step 12: forensic ledger -- count signed observations ===== 167 // ME: 3 events (RAM_READ + NET_EGRESS + BOOT_INTERPOSE) 168 if nx_xenocell_evidence_count(me_xeno) != 3 { return 20 } 169 // PSP: 1 event 170 if nx_xenocell_evidence_count(psp_xeno) != 1 { return 21 } 171 // baseband: 1 event 172 if nx_xenocell_evidence_count(bb_xeno) != 1 { return 22 } 173 174 // ===== Step 13: tally by kind (cross-cutting forensic query) ===== 175 if nx_xenocell_count_by_kind(me_xeno, NX_OBS_RAM_READ) != 1 { return 23 } 176 if nx_xenocell_count_by_kind(me_xeno, NX_OBS_NET_EGRESS) != 1 { return 24 } 177 if nx_xenocell_count_by_kind(me_xeno, NX_OBS_BOOT_INTERPOSE) != 1 { return 25 } 178 if nx_xenocell_count_by_kind(bb_xeno, NX_OBS_RADIO_ACTIVATE) != 1 { return 26 } 179 if nx_xenocell_count_by_kind(psp_xeno, NX_OBS_FIRMWARE_WRITE) != 1 { return 27 } 180 181 // ===== Step 14: gameplay continues unaffected -- foreground cell 182 // and NMS symbiote still present in organism ======= 183 let cell: *NxCellSpec = nx_pathway_get_cell(nishi, 100) 184 if (cell as i64) == 0 { return 28 } 185 if cell.attention_class != NX_AC_INTERACTIVE_FOREGROUND_GAME { return 29 } 186 if nx_symbiote_is_responsive(nms) != 1 { return 30 } 187 // 1 pathway + 1 symbiote in organism (xenocells observed separately) 188 if nx_organism_count_members(org) != 2 { return 31 } 189 190 // ===== Step 15: niche verdicts hold -- ME hardware safe for 191 // gameplay but NOT for identity/financial ========== 192 if nx_reclaim_can_run_niche(me_env, NX_NICHE_GAMEPLAY) != 1 { return 32 } 193 if nx_reclaim_can_run_niche(me_env, NX_NICHE_IDENTITY) != 0 { return 33 } 194 if nx_reclaim_can_run_niche(me_env, NX_NICHE_FINANCIAL) != 0 { return 34 } 195 196 // ===== Step 16: all three xenocells in hostile-now state ========= 197 // Operator can see at a glance: every adversarial agent on this 198 // host has been caught doing something this session. 199 if nx_xenocell_is_hostile_now(me_xeno) != 1 { return 35 } 200 if nx_xenocell_is_hostile_now(psp_xeno) != 1 { return 36 } 201 if nx_xenocell_is_hostile_now(bb_xeno) != 1 { return 37 } 202 203 return 0 204}