code wiki / (root) / nx_allelopathy_test.nx

nx_allelopathy_test.nx source

↩ module page · 102 lines · 5246 B

1// nx_allelopathy_test.nx -- smoke for nx_allelopathy. 2 3import "nx_syscalls.nx" 4import "nx_allelopathy.nx" 5 6func main() -> i64 { 7 // 1: refused-niche enum validity bounds 8 if nx_rn_is_valid(NX_RN_NONE) != 1 { return 1 } 9 if nx_rn_is_valid(NX_RN_WEAPONS_PLATFORM) != 1 { return 2 } 10 if nx_rn_is_valid(NX_RN_HUMAN_RIGHTS_VIOLATION_CONTEXT) != 1 { return 3 } 11 if nx_rn_is_valid(-1) != 0 { return 4 } 12 if nx_rn_is_valid(6) != 0 { return 5 } 13 if NX_RN_N_REFUSED != 6 { return 6 } 14 15 // 2: NONE is not refused; all others are 16 if nx_rn_is_refused(NX_RN_NONE) != 0 { return 7 } 17 if nx_rn_is_refused(NX_RN_WEAPONS_PLATFORM) != 1 { return 8 } 18 if nx_rn_is_refused(NX_RN_MASS_SURVEILLANCE_NODE) != 1 { return 9 } 19 if nx_rn_is_refused(NX_RN_PREDATORY_AI_INFERENCE) != 1 { return 10 } 20 if nx_rn_is_refused(NX_RN_STATE_ACTOR_OFFENSIVE) != 1 { return 11 } 21 if nx_rn_is_refused(NX_RN_HUMAN_RIGHTS_VIOLATION_CONTEXT) != 1 { return 12 } 22 if nx_rn_is_refused(-1) != 0 { return 13 } 23 if nx_rn_is_refused(6) != 0 { return 14 } 24 25 // 3: clause kind validity 26 if nx_lc_kind_is_valid(NX_LC_HIPPOCRATIC) != 1 { return 15 } 27 if nx_lc_kind_is_valid(NX_LC_AGPL_COPYLEFT) != 1 { return 16 } 28 if nx_lc_kind_is_valid(-1) != 0 { return 17 } 29 if nx_lc_kind_is_valid(6) != 0 { return 18 } 30 31 // 4: verdict enum validity 32 if nx_al_verdict_is_valid(NX_AL_OK_ALLOWED) != 1 { return 19 } 33 if nx_al_verdict_is_valid(NX_AL_REFUSED) != 1 { return 20 } 34 if nx_al_verdict_is_valid(NX_AL_NEEDS_OPERATOR_REVIEW) != 1 { return 21 } 35 if nx_al_verdict_is_valid(-1) != 0 { return 22 } 36 if nx_al_verdict_is_valid(3) != 0 { return 23 } 37 if nx_al_verdict_is_valid(NX_AL_INVALID) != 0 { return 24 } 38 39 // 5: canonical clauses for WEAPONS_PLATFORM include anti-weapons + AGPL 40 let cw: nx_int = nx_rn_canonical_clauses(NX_RN_WEAPONS_PLATFORM) 41 if (cw & NX_LC_BIT_ANTI_WEAPONS) == 0 { return 25 } 42 if (cw & NX_LC_BIT_HIPPOCRATIC) == 0 { return 26 } 43 if (cw & NX_LC_BIT_AGPL) == 0 { return 27 } 44 45 // 6: canonical clauses for MASS_SURVEILLANCE_NODE include anti-surveillance 46 let cs: nx_int = nx_rn_canonical_clauses(NX_RN_MASS_SURVEILLANCE_NODE) 47 if (cs & NX_LC_BIT_ANTI_SURVEILLANCE) == 0 { return 28 } 48 if (cs & NX_LC_BIT_HIPPOCRATIC) == 0 { return 29 } 49 50 // 7: canonical clauses for PREDATORY_AI_INFERENCE include anti-discrimination 51 let cp: nx_int = nx_rn_canonical_clauses(NX_RN_PREDATORY_AI_INFERENCE) 52 if (cp & NX_LC_BIT_ANTI_DISCRIMINATION) == 0 { return 30 } 53 if (cp & NX_LC_BIT_ANTI_SURVEILLANCE) == 0 { return 31 } 54 55 // 8: canonical clauses for STATE_ACTOR_OFFENSIVE include all defensive 56 let coff: nx_int = nx_rn_canonical_clauses(NX_RN_STATE_ACTOR_OFFENSIVE) 57 if (coff & NX_LC_BIT_ANTI_WEAPONS) == 0 { return 32 } 58 if (coff & NX_LC_BIT_ANTI_SURVEILLANCE) == 0 { return 33 } 59 if (coff & NX_LC_BIT_AGPL) == 0 { return 34 } 60 61 // 9: canonical clauses for NONE -> 0 (no refused-niche clauses applicable) 62 if nx_rn_canonical_clauses(NX_RN_NONE) != 0 { return 35 } 63 64 // 10: assembly verdict -- NONE allows 65 if nx_al_assembly_verdict(NX_RN_NONE) != NX_AL_OK_ALLOWED { return 36 } 66 67 // 11: assembly verdict -- any refused niche refuses 68 if nx_al_assembly_verdict(NX_RN_WEAPONS_PLATFORM) != NX_AL_REFUSED { return 37 } 69 if nx_al_assembly_verdict(NX_RN_MASS_SURVEILLANCE_NODE) != NX_AL_REFUSED { return 38 } 70 if nx_al_assembly_verdict(NX_RN_PREDATORY_AI_INFERENCE) != NX_AL_REFUSED { return 39 } 71 if nx_al_assembly_verdict(NX_RN_STATE_ACTOR_OFFENSIVE) != NX_AL_REFUSED { return 40 } 72 if nx_al_assembly_verdict(NX_RN_HUMAN_RIGHTS_VIOLATION_CONTEXT) != NX_AL_REFUSED { return 41 } 73 74 // 12: invalid input -> INVALID 75 if nx_al_assembly_verdict(-1) != NX_AL_INVALID { return 42 } 76 if nx_al_assembly_verdict(99) != NX_AL_INVALID { return 43 } 77 78 // 13: honest-limit acknowledgment -- always 1 (the substrate is 79 // structurally honest about not being able to stop sovereign-state) 80 if nx_al_honest_limit_acknowledged() != 1 { return 44 } 81 82 // 14: substrate CAN address most threat-actor classes 83 // (matches NX_AC_* enum from nx_risk_register; values 0-3 + 6-9 are addressable) 84 if nx_al_can_address_threat(0) != 1 { return 45 } // INDIVIDUAL_OPPORTUNIST 85 if nx_al_can_address_threat(1) != 1 { return 46 } // CRIMINAL_ORGANIZATION 86 if nx_al_can_address_threat(2) != 1 { return 47 } // PATENT_TROLL 87 if nx_al_can_address_threat(3) != 1 { return 48 } // LARGE_CORP_EXTRACTIVE 88 if nx_al_can_address_threat(6) != 1 { return 49 } // COMPROMISED_INSIDER 89 if nx_al_can_address_threat(7) != 1 { return 50 } // WELL_INTENTIONED_BUT_WRONG 90 if nx_al_can_address_threat(8) != 1 { return 51 } // ACCIDENTAL 91 if nx_al_can_address_threat(9) != 1 { return 52 } // UNKNOWN_ACTOR 92 93 // 15: substrate CANNOT address sovereign-state attackers (HONEST LIMIT) 94 if nx_al_can_address_threat(4) != 0 { return 53 } // STATE_ACTOR_HOSTILE 95 if nx_al_can_address_threat(5) != 0 { return 54 } // STATE_ACTOR_DOMESTIC 96 97 // 16: invalid threat-actor class -> 0 98 if nx_al_can_address_threat(-1) != 0 { return 55 } 99 if nx_al_can_address_threat(10) != 0 { return 56 } 100 101 return 0 102}