code wiki / (root) / nx_probiome_test.nx

nx_probiome_test.nx source

↩ module page · 130 lines · 7111 B

1// nx_probiome_test.nx -- smoke for nx_probiome (R6, cross-kingdom 2// beneficial-microbe engine, v2 widened to organisms in general). Proves: 3// - a data-driven catalog spanning FOUR host kingdoms AND four microbe 4// domains (bacteria / yeasts / molds / mycorrhizal fungi); 5// - the "One Health" keystone (B. subtilis benefits 3 kingdoms); 6// - a GENERATIVE recommender that is SAFE-BY-CONSTRUCTION; 7// - TWO genus-level liar-kill pairs: Bacillus subtilis vs B. cereus 8// (toxin) and Aspergillus oryzae (koji) vs A. flavus (aflatoxin); 9// - LIAR-KILLS: pathogen, toxigenic bacterium, toxigenic mold, AMR 10// opportunist, host mismatch, unknown (fail-closed) all REFUSED; 11// - the recommender never returns an AMR additive or an aflatoxin mold 12// even when it nominally fits the target. 13// Exit code = failed assertion number; 0 = all pass. 14 15import "nx_syscalls.nx" 16import "nx_probiome.nx" 17 18func main() -> i64 { 19 // --- catalog lookup returns the right genus + domain --- 20 let la: *NxProbiomeStrain = nx_probiome_strain(PB_STR_L_ACIDOPHILUS) 21 if la.genus_id != PB_GEN_LACTOBACILLUS { return 1 } 22 if la.microbe_domain != PB_DOM_BACTERIUM { return 2 } 23 24 // --- all FOUR kingdoms have an admissible beneficial microbe --- 25 let gg: *NxProbiomeStrain = nx_probiome_strain(PB_STR_L_RHAMNOSUS_GG) 26 if nx_probiome_admit(gg, PB_HOST_HUMAN) != PB_OK { return 3 } 27 let rh: *NxProbiomeStrain = nx_probiome_strain(PB_STR_RHIZOBIUM) 28 if nx_probiome_admit(rh, PB_HOST_PLANT) != PB_OK { return 4 } 29 let bs: *NxProbiomeStrain = nx_probiome_strain(PB_STR_B_SUBTILIS) 30 if nx_probiome_admit(bs, PB_HOST_ANIMAL) != PB_OK { return 5 } 31 let ni: *NxProbiomeStrain = nx_probiome_strain(PB_STR_NITROSOMONAS) 32 if nx_probiome_admit(ni, PB_HOST_SOIL) != PB_OK { return 6 } 33 34 // --- cross-kingdom keystone: B. subtilis lifts 3 kingdoms --- 35 if pb_host_count(bs) != 3 { return 7 } 36 if pb_is_keystone(bs) != 1 { return 8 } 37 38 // --- query predicates --- 39 if pb_benefits_host(bs, PB_HOST_PLANT) != 1 { return 9 } 40 if pb_benefits_host(bs, PB_HOST_HUMAN) != 0 { return 10 } 41 if pb_has_mechanism(bs, PB_MECH_BIOCONTROL) != 1 { return 11 } 42 if pb_has_mechanism(bs, PB_MECH_NFIX) != 0 { return 12 } 43 44 // --- GENERATIVE recommender (best safe strain for a target) --- 45 if nx_probiome_recommend(PB_HOST_HUMAN, PB_MECH_IMMUNE) != PB_STR_L_RHAMNOSUS_GG { return 13 } 46 if nx_probiome_recommend_benefit(PB_HOST_PLANT, PB_MECH_NFIX) != 900 { return 14 } 47 if nx_probiome_recommend(PB_HOST_SOIL, PB_MECH_BIOREMEDIATION) != PB_STR_P_PUTIDA { return 15 } 48 49 // --- LIAR-KILL: frank pathogen is always refused --- 50 let ls: *NxProbiomeStrain = nx_probiome_strain(PB_STR_LISTERIA) 51 if nx_probiome_admit(ls, PB_HOST_HUMAN) != PB_REFUSED_PATHOGEN { return 16 } 52 53 // --- LIAR-KILL: toxigenic Bacillus (cereus) refused despite genus --- 54 let bc: *NxProbiomeStrain = nx_probiome_strain(PB_STR_B_CEREUS) 55 if nx_probiome_admit(bc, PB_HOST_SOIL) != PB_REFUSED_TOXIGENIC { return 17 } 56 57 // --- LIAR-KILL: AMR opportunist (E. faecium) refused for general use --- 58 let ef: *NxProbiomeStrain = nx_probiome_strain(PB_STR_E_FAECIUM) 59 if nx_probiome_admit(ef, PB_HOST_ANIMAL) != PB_REFUSED_OPPORTUNIST { return 18 } 60 61 // --- LIAR-KILL: host mismatch -- a soil N-fixer is NOT a human probiotic --- 62 if nx_probiome_admit(rh, PB_HOST_HUMAN) != PB_REFUSED_HOST_MISMATCH { return 19 } 63 64 // --- FAIL-CLOSED: an unknown strain id is treated as a pathogen --- 65 let unk: *NxProbiomeStrain = nx_probiome_strain(PB_STR_N) 66 if nx_probiome_admit(unk, PB_HOST_HUMAN) != PB_REFUSED_PATHOGEN { return 20 } 67 68 // --- bad host index refused --- 69 if nx_probiome_admit(gg, 9) != PB_REFUSED_BAD_HOST { return 21 } 70 71 // --- CROWN 1: the recommender is SAFE-BY-CONSTRUCTION. E. faecium 72 // nominally fits (animal, feed) but is refused; the engine 73 // returns the safe B. subtilis instead, never the AMR bug. --- 74 let rec: i64 = nx_probiome_recommend(PB_HOST_ANIMAL, PB_MECH_FEED) 75 if rec != PB_STR_B_SUBTILIS { return 22 } 76 if rec == PB_STR_E_FAECIUM { return 23 } 77 let recs: *NxProbiomeStrain = nx_probiome_strain(rec) 78 if nx_probiome_admit(recs, PB_HOST_ANIMAL) != PB_OK { return 24 } 79 80 // --- WIDENED: microbe domains beyond bacteria --- 81 // Probiotic YEAST (S. boulardii) admitted for humans. 82 let sb: *NxProbiomeStrain = nx_probiome_strain(PB_STR_S_BOULARDII) 83 if sb.microbe_domain != PB_DOM_YEAST { return 25 } 84 if nx_probiome_admit(sb, PB_HOST_HUMAN) != PB_OK { return 26 } 85 86 // Koji MOLD (A. oryzae) admitted; its aflatoxigenic cousin REFUSED -- 87 // the SECOND genus-level liar-kill pair (mold analog of Bacillus). 88 let ao: *NxProbiomeStrain = nx_probiome_strain(PB_STR_A_ORYZAE) 89 if ao.microbe_domain != PB_DOM_MOLD { return 27 } 90 if nx_probiome_admit(ao, PB_HOST_HUMAN) != PB_OK { return 28 } 91 let af: *NxProbiomeStrain = nx_probiome_strain(PB_STR_A_FLAVUS) 92 if af.genus_id != ao.genus_id { return 29 } 93 if nx_probiome_admit(af, PB_HOST_HUMAN) != PB_REFUSED_TOXIGENIC { return 30 } 94 95 // MYCORRHIZAL fungus: a cornerstone plant-health organism. 96 let my: *NxProbiomeStrain = nx_probiome_strain(PB_STR_MYCORRHIZA) 97 if my.microbe_domain != PB_DOM_MYCORRHIZAL { return 31 } 98 if nx_probiome_admit(my, PB_HOST_PLANT) != PB_OK { return 32 } 99 if nx_probiome_recommend(PB_HOST_PLANT, PB_MECH_MYCORRHIZAL) != PB_STR_MYCORRHIZA { return 33 } 100 101 // Acetic-acid bacteria: recommend for the (human, acetic) target. 102 if nx_probiome_recommend(PB_HOST_HUMAN, PB_MECH_ACETIC) != PB_STR_ACETOBACTER { return 34 } 103 104 // --- CROWN 2: the recommender excludes the AFLATOXIN mold too. 105 // For (human, predigest) it returns a SAFE mold at benefit 700, 106 // never A. flavus (benefit 0, toxigenic -> refused). --- 107 let rec2: i64 = nx_probiome_recommend(PB_HOST_HUMAN, PB_MECH_PREDIGEST) 108 if rec2 == PB_STR_A_FLAVUS { return 35 } 109 if nx_probiome_recommend_benefit(PB_HOST_HUMAN, PB_MECH_PREDIGEST) != 700 { return 36 } 110 let rec2s: *NxProbiomeStrain = nx_probiome_strain(rec2) 111 if nx_probiome_admit(rec2s, PB_HOST_HUMAN) != PB_OK { return 37 } 112 113 // --- catalog breadth per kingdom (safe-admissible counts) --- 114 if nx_probiome_count_safe_for(PB_HOST_HUMAN) != 15 { return 38 } 115 if nx_probiome_count_safe_for(PB_HOST_PLANT) != 9 { return 39 } 116 if nx_probiome_count_safe_for(PB_HOST_SOIL) != 11 { return 40 } 117 // ANIMAL == 4 proves E. faecium (the AMR opportunist) is excluded. 118 if nx_probiome_count_safe_for(PB_HOST_ANIMAL) != 4 { return 41 } 119 120 // --- catalog breadth per microbe domain (organisms in general) --- 121 if nx_probiome_count_domain(PB_DOM_BACTERIUM) != 18 { return 42 } 122 if nx_probiome_count_domain(PB_DOM_YEAST) != 3 { return 43 } 123 // MOLD == 4 proves A. flavus (toxigenic) is excluded from the safe set. 124 if nx_probiome_count_domain(PB_DOM_MOLD) != 4 { return 44 } 125 if nx_probiome_count_domain(PB_DOM_MYCORRHIZAL) != 1 { return 45 } 126 127 if nx_probiome_strain_count() != 30 { return 46 } 128 129 return 0 130}