code wiki / (root) / nx_probiome.nx

nx_probiome.nx source

↩ module page · 708 lines · 28820 B

1// nx_probiome.nx -- R6 of the FERMENTATION ladder: the cross-kingdom 2// BENEFICIAL-MICROBE engine. The fermentation rungs (R0-R5) run the 3// yogurt/cheese PROCESS safely; this rung models the CULTURES THEMSELVES 4// as biology -- which organism confers which benefit to which host, and 5// whether it is safe to use at all -- and generalises the yogurt/cheese 6// "good bacteria" idea across all of life: PEOPLE (gut probiotics), 7// PLANTS (rhizosphere PGPR, nitrogen fixers, mycorrhizae), ANIMALS 8// (direct-fed microbials), and ORGANISMS-IN-GENERAL (soil nitrifiers, 9// composters, bioremediators). One engine, four host kingdoms -- the 10// "One Health" pattern (a single microbe can lift people AND plants AND 11// soil). 12// 13// v2 (2026-07-09) widens beyond bacteria to ORGANISMS IN GENERAL: a 14// microbe_domain axis (bacterium / yeast / mold / mycorrhizal fungus) so 15// the engine covers the real biology of fermentation and plant health -- 16// acetic-acid bacteria (kombucha/vinegar), probiotic + leavening yeasts, 17// koji/tempeh/cheese molds, and arbuscular mycorrhizal fungi -- not just 18// bacteria. Additive, never reductive: every earlier strain is kept. 19// 20// THE NEVER-HARM LAW (the cross-kingdom analog of nx_ferment_safety's 21// never-poison law, Global Rule 26): a beneficial-microbe capability 22// may NEVER recommend or admit an organism that is unsafe for its host. 23// STRUCTURAL refusal, not a warning string: 24// - a frank PATHOGEN (Listeria monocytogenes, ...) is ALWAYS refused; 25// - an OPPORTUNIST / non-QPS organism (Enterococcus faecium, which can 26// carry transferable vancomycin resistance and is a nosocomial 27// pathogen) is refused for general use; 28// - an organism that carries acquired ANTIBIOTIC RESISTANCE is refused 29// (it could transfer the resistance in the gut/rumen/soil); 30// - a TOXIGENIC organism is refused even though its genus contains QPS 31// members -- a "qualified" strain must PASS its qualification. Two 32// genus-level liar-kill pairs prove this MECHANICALLY: Bacillus 33// subtilis (QPS) vs B. cereus (cereulide toxin), and Aspergillus 34// oryzae (safe domesticated koji mold) vs A. flavus (aflatoxin); 35// - a HOST MISMATCH is refused: a soil/plant nitrogen-fixer is NOT a 36// human probiotic (do not eat Rhizobium as a gut culture), and the 37// recommender will never hand you a strain outside the target host. 38// Unknown strain ids FAIL CLOSED (treated as pathogens). 39// 40// THE EXCEED (measured, liar-killed by the gate -- see the _test): 41// - vs a $40 yogurt maker: it holds temperature and knows nothing 42// about strains; this reasons about the organisms. 43// - vs a probiotic label / a cookbook: it lists "contains L. 44// acidophilus" but cannot prove the strain is safe-by-construction, 45// cannot refuse a real marketed-but-unsafe additive (E. faecium's 46// AMR, B. cereus's toxin), cannot tell a safe koji mold from its 47// aflatoxigenic cousin, and cannot find that ONE microbe benefits 48// four kingdoms. Here every recommendation is safe-by-construction 49// and cross-kingdom benefit is computed. 50// 51// Grounding (research, not bro-science -- Rule 4; cited genealogy). A 52// later rung (nx_probiome_research_fetch) grounds each constant against 53// fetched EFSA/FDA/primary-literature sources, exactly as 54// nx_ferment_safety's constants are grounded. cite_id map: 55// 1 listeria_monocytogenes_dairy_pathogen 56// 2 efsa_bacillus_absence_of_toxigenic_activity 57// 3 bacillus_cereus_cereulide_enterotoxin 58// 4 enterococcus_faecium_vanA_transferable_amr 59// 5 rhizobium_bradyrhizobium_symbiotic_n_fixation 60// 6 azospirillum_azotobacter_associative_diazotroph 61// 7 pseudomonas_fluorescens_pgpr_biocontrol_isr 62// 8 lactic_acid_bacteria_qps_food_cultures 63// 9 scfa_butyrate_bifidobacterium_gut_immune 64// 10 nitrosomonas_ammonia_oxidation_nitrogen_cycle 65// 11 pseudomonas_putida_hydrocarbon_bioremediation 66// 12 acetic_acid_bacteria_kombucha_vinegar 67// 13 saccharomyces_boulardii_probiotic_yeast 68// 14 propionibacterium_freudenreichii_b12_swiss 69// 15 aspergillus_oryzae_domesticated_nontoxigenic_koji 70// 16 arbuscular_mycorrhiza_phosphorus_uptake_symbiosis 71// 17 trichoderma_harzianum_mycoparasite_biocontrol 72// 18 rhizopus_oligosporus_tempeh_fermentation 73// 19 penicillium_roqueforti_blue_cheese_ripening 74// 20 leuconostoc_mesenteroides_heterofermentative_kraut 75// 21 bacillus_velezensis_amyloliquefaciens_pgpr 76// 22 aspergillus_flavus_aflatoxin_carcinogen 77// 78// genealogy_id: nishi_ferment_safety_r0_never_poison 79// + efsa_qps + fda_gras 80// + one_health_cross_kingdom_microbiome 81 82import "nx_syscalls.nx" 83 84// ===== Sealed enum: host kingdom (index form, for a target) ======= 85 86const PB_HOST_HUMAN: i64 = 0 87const PB_HOST_PLANT: i64 = 1 88const PB_HOST_ANIMAL: i64 = 2 89const PB_HOST_SOIL: i64 = 3 // organisms/environment in general 90const PB_HOST_N: i64 = 4 91 92// ===== Host kingdom bits (mask form, a strain can help several) === 93 94const PB_HB_HUMAN: i64 = 1 95const PB_HB_PLANT: i64 = 2 96const PB_HB_ANIMAL: i64 = 4 97const PB_HB_SOIL: i64 = 8 98 99// ===== Sealed enum: microbe domain (organisms in general) ========= 100 101const PB_DOM_BACTERIUM: i64 = 0 102const PB_DOM_YEAST: i64 = 1 // unicellular fungi (Saccharomyces...) 103const PB_DOM_MOLD: i64 = 2 // filamentous fungi (Rhizopus, koji...) 104const PB_DOM_MYCORRHIZAL: i64 = 3 // arbuscular mycorrhizal root symbionts 105const PB_DOM_N: i64 = 4 106 107// ===== Sealed enum: benefit mechanism (index form) ================ 108 109const PB_MECH_LACTIC: i64 = 0 // lactic-acid souring / preservation 110const PB_MECH_SCFA: i64 = 1 // short-chain fatty acids (butyrate) 111const PB_MECH_EXCLUSION: i64 = 2 // competitive pathogen exclusion 112const PB_MECH_VITAMIN: i64 = 3 // vitamin K / B (incl B12) synthesis 113const PB_MECH_IMMUNE: i64 = 4 // immune modulation 114const PB_MECH_NFIX: i64 = 5 // nitrogen fixation 115const PB_MECH_PSOL: i64 = 6 // phosphate solubilization / uptake 116const PB_MECH_PHYTOHORMONE: i64 = 7 // IAA/auxin plant growth promotion 117const PB_MECH_BIOCONTROL: i64 = 8 // antifungal / induced systemic resistance 118const PB_MECH_FEED: i64 = 9 // feed efficiency / rumen stabilization 119const PB_MECH_BIOREMEDIATION: i64 = 10 // degrade pollutants 120const PB_MECH_NITRIFICATION: i64 = 11 // ammonia -> nitrite (N cycle) 121const PB_MECH_ACETIC: i64 = 12 // acetic / organic-acid preservation 122const PB_MECH_LEAVENING: i64 = 13 // CO2 / ethanol fermentation (rise) 123const PB_MECH_PREDIGEST: i64 = 14 // proteolysis -> bioavailable nutrients 124const PB_MECH_MYCORRHIZAL: i64 = 15 // root symbiosis: water + nutrient uptake 125const PB_MECH_N: i64 = 16 126 127// ===== Benefit mechanism bits (mask form) ========================= 128 129const PB_MB_LACTIC: i64 = 1 130const PB_MB_SCFA: i64 = 2 131const PB_MB_EXCLUSION: i64 = 4 132const PB_MB_VITAMIN: i64 = 8 133const PB_MB_IMMUNE: i64 = 16 134const PB_MB_NFIX: i64 = 32 135const PB_MB_PSOL: i64 = 64 136const PB_MB_PHYTOHORMONE: i64 = 128 137const PB_MB_BIOCONTROL: i64 = 256 138const PB_MB_FEED: i64 = 512 139const PB_MB_BIOREMEDIATION: i64 = 1024 140const PB_MB_NITRIFICATION: i64 = 2048 141const PB_MB_ACETIC: i64 = 4096 142const PB_MB_LEAVENING: i64 = 8192 143const PB_MB_PREDIGEST: i64 = 16384 144const PB_MB_MYCORRHIZAL: i64 = 32768 145 146// ===== Sealed enum: safety class (EFSA QPS / FDA GRAS grounded) ==== 147 148const PB_SAFE_QPS: i64 = 0 // presumed safe (QPS / GRAS) 149const PB_SAFE_QUALIFIED: i64 = 1 // QPS *with qualifications*: safe iff 150 // NOT toxigenic AND no acquired AMR 151const PB_SAFE_OPPORTUNIST: i64 = 2 // not QPS; opportunist / transferable AMR 152const PB_SAFE_PATHOGEN: i64 = 3 // frank pathogen -- always refused 153const PB_SAFE_N: i64 = 4 154 155// ===== Sealed enum: genus (for grouping / readability) ============ 156 157const PB_GEN_LACTOBACILLUS: i64 = 0 158const PB_GEN_BIFIDOBACTERIUM: i64 = 1 159const PB_GEN_STREPTOCOCCUS: i64 = 2 160const PB_GEN_LACTOCOCCUS: i64 = 3 161const PB_GEN_BACILLUS: i64 = 4 162const PB_GEN_RHIZOBIUM: i64 = 5 163const PB_GEN_BRADYRHIZOBIUM: i64 = 6 164const PB_GEN_AZOSPIRILLUM: i64 = 7 165const PB_GEN_AZOTOBACTER: i64 = 8 166const PB_GEN_PSEUDOMONAS: i64 = 9 167const PB_GEN_ENTEROCOCCUS: i64 = 10 168const PB_GEN_LISTERIA: i64 = 11 169const PB_GEN_NITROSOMONAS: i64 = 12 170const PB_GEN_ACETOBACTER: i64 = 13 171const PB_GEN_PROPIONIBACTERIUM: i64 = 14 172const PB_GEN_LEUCONOSTOC: i64 = 15 173const PB_GEN_SACCHAROMYCES: i64 = 16 174const PB_GEN_KLUYVEROMYCES: i64 = 17 175const PB_GEN_RHIZOPUS: i64 = 18 176const PB_GEN_PENICILLIUM: i64 = 19 177const PB_GEN_ASPERGILLUS: i64 = 20 178const PB_GEN_TRICHODERMA: i64 = 21 179const PB_GEN_GLOMUS: i64 = 22 // arbuscular mycorrhizal fungi 180const PB_GEN_N: i64 = 23 181 182// ===== Sealed enum: never-harm verdict ============================ 183 184const PB_OK: i64 = 0 185const PB_REFUSED_PATHOGEN: i64 = 1 186const PB_REFUSED_OPPORTUNIST: i64 = 2 187const PB_REFUSED_AMR: i64 = 3 188const PB_REFUSED_TOXIGENIC: i64 = 4 189const PB_REFUSED_HOST_MISMATCH: i64 = 5 190const PB_REFUSED_BAD_HOST: i64 = 6 191 192// ===== Sealed enum: strain catalog ids ============================ 193 194const PB_STR_L_ACIDOPHILUS: i64 = 0 195const PB_STR_L_RHAMNOSUS_GG: i64 = 1 196const PB_STR_B_LONGUM: i64 = 2 197const PB_STR_S_THERMOPHILUS: i64 = 3 198const PB_STR_L_LACTIS: i64 = 4 199const PB_STR_B_SUBTILIS: i64 = 5 200const PB_STR_RHIZOBIUM: i64 = 6 201const PB_STR_BRADYRHIZOBIUM: i64 = 7 202const PB_STR_AZOSPIRILLUM: i64 = 8 203const PB_STR_AZOTOBACTER: i64 = 9 204const PB_STR_P_FLUORESCENS: i64 = 10 205const PB_STR_E_FAECIUM: i64 = 11 // OPPORTUNIST (vanA AMR) -- liar-kill 206const PB_STR_B_CEREUS: i64 = 12 // TOXIGENIC Bacillus -- liar-kill 207const PB_STR_LISTERIA: i64 = 13 // PATHOGEN -- liar-kill 208const PB_STR_NITROSOMONAS: i64 = 14 209const PB_STR_P_PUTIDA: i64 = 15 // bioremediation 210const PB_STR_ACETOBACTER: i64 = 16 // kombucha/vinegar (acetic-acid bacteria) 211const PB_STR_L_KEFIRI: i64 = 17 // kefir 212const PB_STR_PROPIONIBACTERIUM: i64 = 18 // Swiss cheese + B12 213const PB_STR_LEUCONOSTOC: i64 = 19 // kraut/kimchi early phase 214const PB_STR_S_BOULARDII: i64 = 20 // probiotic YEAST 215const PB_STR_S_CEREVISIAE: i64 = 21 // baker's/brewer's YEAST 216const PB_STR_K_MARXIANUS: i64 = 22 // kefir YEAST 217const PB_STR_RHIZOPUS: i64 = 23 // tempeh MOLD 218const PB_STR_P_ROQUEFORTI: i64 = 24 // blue-cheese MOLD 219const PB_STR_A_ORYZAE: i64 = 25 // koji MOLD (safe, domesticated) 220const PB_STR_A_FLAVUS: i64 = 26 // AFLATOXIN MOLD -- liar-kill 221const PB_STR_TRICHODERMA: i64 = 27 // plant biocontrol fungus 222const PB_STR_MYCORRHIZA: i64 = 28 // arbuscular mycorrhizal fungi 223const PB_STR_B_AMYLOLIQUEFACIENS: i64 = 29 // PGPR biofungicide bacterium 224const PB_STR_N: i64 = 30 225 226// ===== Struct: NxProbiomeStrain =================================== 227 228struct NxProbiomeStrain { 229 strain_id: i64, 230 genus_id: i64, 231 microbe_domain: i64, // PB_DOM_* 232 host_mask: i64, // OR of PB_HB_* 233 mechanism_mask: i64, // OR of PB_MB_* 234 safety_class: i64, // PB_SAFE_* 235 benefit_milli: i64, // measured benefit magnitude 0..1000 236 carries_amr: i64, // 0/1 acquired antibiotic resistance 237 is_toxigenic: i64, // 0/1 produces a toxin 238 cite_id: i64, // fetched-source grounding id 239} 240 241// ===== Catalog: fill a strain spec from its data row ============== 242// 243// FAIL-CLOSED default: an unknown id is a pathogen with no benefit, so a 244// missing catalog entry can never be recommended. 245 246func nx_probiome_strain(id: i64) -> *NxProbiomeStrain { 247 let s: *NxProbiomeStrain = (sys_mmap(96)) as *NxProbiomeStrain 248 s.strain_id = id 249 s.genus_id = PB_GEN_LISTERIA 250 s.microbe_domain = PB_DOM_BACTERIUM 251 s.host_mask = 0 252 s.mechanism_mask = 0 253 s.safety_class = PB_SAFE_PATHOGEN 254 s.benefit_milli = 0 255 s.carries_amr = 0 256 s.is_toxigenic = 0 257 s.cite_id = 0 258 259 // ---- PEOPLE: gut probiotics + dairy cultures (QPS/GRAS) ---- 260 if id == PB_STR_L_ACIDOPHILUS { 261 s.genus_id = PB_GEN_LACTOBACILLUS 262 s.host_mask = PB_HB_HUMAN | PB_HB_ANIMAL 263 s.mechanism_mask = PB_MB_LACTIC | PB_MB_EXCLUSION | PB_MB_VITAMIN 264 s.safety_class = PB_SAFE_QPS 265 s.benefit_milli = 700 266 s.cite_id = 8 267 } 268 if id == PB_STR_L_RHAMNOSUS_GG { 269 s.genus_id = PB_GEN_LACTOBACILLUS 270 s.host_mask = PB_HB_HUMAN | PB_HB_ANIMAL 271 s.mechanism_mask = PB_MB_IMMUNE | PB_MB_EXCLUSION 272 s.safety_class = PB_SAFE_QPS 273 s.benefit_milli = 850 274 s.cite_id = 9 275 } 276 if id == PB_STR_B_LONGUM { 277 s.genus_id = PB_GEN_BIFIDOBACTERIUM 278 s.host_mask = PB_HB_HUMAN 279 s.mechanism_mask = PB_MB_SCFA | PB_MB_IMMUNE | PB_MB_VITAMIN 280 s.safety_class = PB_SAFE_QPS 281 s.benefit_milli = 800 282 s.cite_id = 9 283 } 284 if id == PB_STR_S_THERMOPHILUS { 285 s.genus_id = PB_GEN_STREPTOCOCCUS 286 s.host_mask = PB_HB_HUMAN 287 s.mechanism_mask = PB_MB_LACTIC | PB_MB_EXCLUSION 288 s.safety_class = PB_SAFE_QPS 289 s.benefit_milli = 600 290 s.cite_id = 8 291 } 292 if id == PB_STR_L_LACTIS { 293 s.genus_id = PB_GEN_LACTOCOCCUS 294 s.host_mask = PB_HB_HUMAN 295 s.mechanism_mask = PB_MB_LACTIC | PB_MB_EXCLUSION 296 s.safety_class = PB_SAFE_QPS 297 s.benefit_milli = 550 298 s.cite_id = 8 299 } 300 301 // ---- PLANTS + ANIMALS + SOIL: the cross-kingdom keystone ---- 302 // Bacillus subtilis: plant biocontrol + phosphate solubilizer + 303 // animal feed additive + soil member. QPS *with qualification* 304 // (this strain is non-toxigenic, so it PASSES). 305 if id == PB_STR_B_SUBTILIS { 306 s.genus_id = PB_GEN_BACILLUS 307 s.host_mask = PB_HB_PLANT | PB_HB_ANIMAL | PB_HB_SOIL 308 s.mechanism_mask = PB_MB_BIOCONTROL | PB_MB_PSOL | PB_MB_FEED | PB_MB_PHYTOHORMONE 309 s.safety_class = PB_SAFE_QUALIFIED 310 s.benefit_milli = 750 311 s.cite_id = 2 312 } 313 314 // ---- PLANTS + SOIL: nitrogen fixers + growth promoters ---- 315 if id == PB_STR_RHIZOBIUM { 316 s.genus_id = PB_GEN_RHIZOBIUM 317 s.host_mask = PB_HB_PLANT | PB_HB_SOIL 318 s.mechanism_mask = PB_MB_NFIX 319 s.safety_class = PB_SAFE_QPS 320 s.benefit_milli = 900 321 s.cite_id = 5 322 } 323 if id == PB_STR_BRADYRHIZOBIUM { 324 s.genus_id = PB_GEN_BRADYRHIZOBIUM 325 s.host_mask = PB_HB_PLANT | PB_HB_SOIL 326 s.mechanism_mask = PB_MB_NFIX 327 s.safety_class = PB_SAFE_QPS 328 s.benefit_milli = 900 329 s.cite_id = 5 330 } 331 if id == PB_STR_AZOSPIRILLUM { 332 s.genus_id = PB_GEN_AZOSPIRILLUM 333 s.host_mask = PB_HB_PLANT | PB_HB_SOIL 334 s.mechanism_mask = PB_MB_NFIX | PB_MB_PHYTOHORMONE 335 s.safety_class = PB_SAFE_QPS 336 s.benefit_milli = 650 337 s.cite_id = 6 338 } 339 if id == PB_STR_AZOTOBACTER { 340 s.genus_id = PB_GEN_AZOTOBACTER 341 s.host_mask = PB_HB_PLANT | PB_HB_SOIL 342 s.mechanism_mask = PB_MB_NFIX | PB_MB_PHYTOHORMONE 343 s.safety_class = PB_SAFE_QPS 344 s.benefit_milli = 600 345 s.cite_id = 6 346 } 347 // Pseudomonas fluorescens: plant biocontrol + P solubilizer. The 348 // genus contains opportunists (P. aeruginosa) -> QUALIFIED; this 349 // species is benign (non-toxigenic, no acquired AMR) -> PASSES. 350 if id == PB_STR_P_FLUORESCENS { 351 s.genus_id = PB_GEN_PSEUDOMONAS 352 s.host_mask = PB_HB_PLANT | PB_HB_SOIL 353 s.mechanism_mask = PB_MB_BIOCONTROL | PB_MB_PSOL 354 s.safety_class = PB_SAFE_QUALIFIED 355 s.benefit_milli = 700 356 s.cite_id = 7 357 } 358 359 // ---- SOIL / ENVIRONMENT: nitrifier + bioremediator ---- 360 if id == PB_STR_NITROSOMONAS { 361 s.genus_id = PB_GEN_NITROSOMONAS 362 s.host_mask = PB_HB_SOIL 363 s.mechanism_mask = PB_MB_NITRIFICATION 364 s.safety_class = PB_SAFE_QPS 365 s.benefit_milli = 500 366 s.cite_id = 10 367 } 368 if id == PB_STR_P_PUTIDA { 369 s.genus_id = PB_GEN_PSEUDOMONAS 370 s.host_mask = PB_HB_SOIL 371 s.mechanism_mask = PB_MB_BIOREMEDIATION | PB_MB_PSOL 372 s.safety_class = PB_SAFE_QUALIFIED 373 s.benefit_milli = 650 374 s.cite_id = 11 375 } 376 377 // ---- PEOPLE (widened): acetic-acid bacteria, kefir, B12, kraut ---- 378 if id == PB_STR_ACETOBACTER { 379 s.genus_id = PB_GEN_ACETOBACTER 380 s.host_mask = PB_HB_HUMAN 381 s.mechanism_mask = PB_MB_ACETIC | PB_MB_EXCLUSION 382 s.safety_class = PB_SAFE_QPS 383 s.benefit_milli = 500 384 s.cite_id = 12 385 } 386 if id == PB_STR_L_KEFIRI { 387 s.genus_id = PB_GEN_LACTOBACILLUS 388 s.host_mask = PB_HB_HUMAN 389 s.mechanism_mask = PB_MB_LACTIC | PB_MB_EXCLUSION | PB_MB_IMMUNE 390 s.safety_class = PB_SAFE_QPS 391 s.benefit_milli = 750 392 s.cite_id = 8 393 } 394 // Propionibacterium freudenreichii: Swiss-cheese eyes + a rare 395 // microbial source of vitamin B12; also a gut SCFA (propionate) maker. 396 if id == PB_STR_PROPIONIBACTERIUM { 397 s.genus_id = PB_GEN_PROPIONIBACTERIUM 398 s.host_mask = PB_HB_HUMAN 399 s.mechanism_mask = PB_MB_VITAMIN | PB_MB_SCFA 400 s.safety_class = PB_SAFE_QPS 401 s.benefit_milli = 700 402 s.cite_id = 14 403 } 404 if id == PB_STR_LEUCONOSTOC { 405 s.genus_id = PB_GEN_LEUCONOSTOC 406 s.host_mask = PB_HB_HUMAN 407 s.mechanism_mask = PB_MB_LACTIC | PB_MB_EXCLUSION 408 s.safety_class = PB_SAFE_QPS 409 s.benefit_milli = 500 410 s.cite_id = 20 411 } 412 413 // ---- YEASTS (organisms in general): probiotic + leavening ---- 414 // Saccharomyces boulardii: the one widely-used PROBIOTIC YEAST 415 // (antibiotic-associated + C. difficile diarrhea). A eukaryote, so 416 // intrinsically free of transferable bacterial AMR. 417 if id == PB_STR_S_BOULARDII { 418 s.genus_id = PB_GEN_SACCHAROMYCES 419 s.microbe_domain = PB_DOM_YEAST 420 s.host_mask = PB_HB_HUMAN 421 s.mechanism_mask = PB_MB_IMMUNE | PB_MB_EXCLUSION 422 s.safety_class = PB_SAFE_QPS 423 s.benefit_milli = 800 424 s.cite_id = 13 425 } 426 if id == PB_STR_S_CEREVISIAE { 427 s.genus_id = PB_GEN_SACCHAROMYCES 428 s.microbe_domain = PB_DOM_YEAST 429 s.host_mask = PB_HB_HUMAN | PB_HB_ANIMAL 430 s.mechanism_mask = PB_MB_LEAVENING | PB_MB_VITAMIN | PB_MB_FEED 431 s.safety_class = PB_SAFE_QPS 432 s.benefit_milli = 550 433 s.cite_id = 13 434 } 435 if id == PB_STR_K_MARXIANUS { 436 s.genus_id = PB_GEN_KLUYVEROMYCES 437 s.microbe_domain = PB_DOM_YEAST 438 s.host_mask = PB_HB_HUMAN 439 s.mechanism_mask = PB_MB_LEAVENING | PB_MB_PREDIGEST 440 s.safety_class = PB_SAFE_QPS 441 s.benefit_milli = 600 442 s.cite_id = 13 443 } 444 445 // ---- MOLDS (organisms in general): tempeh, cheese, koji ---- 446 // Rhizopus oligosporus: knits soybeans into tempeh, predigests 447 // protein, raises B vitamins. QUALIFIED (a food mold; this species 448 // is non-toxigenic in tempeh use). 449 if id == PB_STR_RHIZOPUS { 450 s.genus_id = PB_GEN_RHIZOPUS 451 s.microbe_domain = PB_DOM_MOLD 452 s.host_mask = PB_HB_HUMAN 453 s.mechanism_mask = PB_MB_PREDIGEST | PB_MB_VITAMIN 454 s.safety_class = PB_SAFE_QUALIFIED 455 s.benefit_milli = 700 456 s.cite_id = 18 457 } 458 if id == PB_STR_P_ROQUEFORTI { 459 s.genus_id = PB_GEN_PENICILLIUM 460 s.microbe_domain = PB_DOM_MOLD 461 s.host_mask = PB_HB_HUMAN 462 s.mechanism_mask = PB_MB_PREDIGEST | PB_MB_EXCLUSION 463 s.safety_class = PB_SAFE_QUALIFIED 464 s.benefit_milli = 550 465 s.cite_id = 19 466 } 467 // Aspergillus oryzae: the DOMESTICATED koji mold (miso/soy sauce/ 468 // sake/amazake). Selected over millennia to be NON-toxigenic -- the 469 // safe half of the genus liar-kill pair with A. flavus. 470 if id == PB_STR_A_ORYZAE { 471 s.genus_id = PB_GEN_ASPERGILLUS 472 s.microbe_domain = PB_DOM_MOLD 473 s.host_mask = PB_HB_HUMAN 474 s.mechanism_mask = PB_MB_PREDIGEST | PB_MB_VITAMIN 475 s.safety_class = PB_SAFE_QUALIFIED 476 s.benefit_milli = 700 477 s.cite_id = 15 478 } 479 // Aspergillus flavus: same genus as koji, but produces AFLATOXIN 480 // (a potent carcinogen). QUALIFIED-but-TOXIGENIC -> REFUSED. This 481 // proves the qualification is real: genus alone never confers safety. 482 if id == PB_STR_A_FLAVUS { 483 s.genus_id = PB_GEN_ASPERGILLUS 484 s.microbe_domain = PB_DOM_MOLD 485 s.host_mask = PB_HB_HUMAN 486 s.mechanism_mask = PB_MB_PREDIGEST 487 s.safety_class = PB_SAFE_QUALIFIED 488 s.benefit_milli = 0 489 s.is_toxigenic = 1 490 s.cite_id = 22 491 } 492 493 // ---- PLANTS + SOIL (widened): fungal biocontrol + mycorrhiza ---- 494 // Trichoderma harzianum: a mycoparasitic fungus -- the leading 495 // biofungicide; colonizes roots and attacks plant-pathogenic fungi. 496 if id == PB_STR_TRICHODERMA { 497 s.genus_id = PB_GEN_TRICHODERMA 498 s.microbe_domain = PB_DOM_MOLD 499 s.host_mask = PB_HB_PLANT | PB_HB_SOIL 500 s.mechanism_mask = PB_MB_BIOCONTROL | PB_MB_PHYTOHORMONE 501 s.safety_class = PB_SAFE_QUALIFIED 502 s.benefit_milli = 750 503 s.cite_id = 17 504 } 505 // Arbuscular mycorrhizal fungi (Glomus/Rhizophagus): symbiose with 506 // ~80% of land-plant roots, vastly extending phosphorus + water 507 // uptake. A cornerstone "healthy opportunity" organism for plants. 508 if id == PB_STR_MYCORRHIZA { 509 s.genus_id = PB_GEN_GLOMUS 510 s.microbe_domain = PB_DOM_MYCORRHIZAL 511 s.host_mask = PB_HB_PLANT | PB_HB_SOIL 512 s.mechanism_mask = PB_MB_MYCORRHIZAL | PB_MB_PSOL 513 s.safety_class = PB_SAFE_QPS 514 s.benefit_milli = 850 515 s.cite_id = 16 516 } 517 // Bacillus velezensis / amyloliquefaciens: a top commercial PGPR + 518 // biofungicide (lipopeptide antibiosis, ISR). QUALIFIED non-toxigenic. 519 if id == PB_STR_B_AMYLOLIQUEFACIENS { 520 s.genus_id = PB_GEN_BACILLUS 521 s.host_mask = PB_HB_PLANT | PB_HB_SOIL 522 s.mechanism_mask = PB_MB_BIOCONTROL | PB_MB_PSOL | PB_MB_PHYTOHORMONE 523 s.safety_class = PB_SAFE_QUALIFIED 524 s.benefit_milli = 700 525 s.cite_id = 21 526 } 527 528 // ---- LIAR-KILL entries: real but unsafe (the gate must refuse) ---- 529 // Enterococcus faecium: a REAL animal feed additive, but NOT on the 530 // QPS list -- it can carry transferable vancomycin (vanA) resistance 531 // and is a nosocomial opportunist. Refused for general use. 532 if id == PB_STR_E_FAECIUM { 533 s.genus_id = PB_GEN_ENTEROCOCCUS 534 s.host_mask = PB_HB_ANIMAL 535 s.mechanism_mask = PB_MB_FEED | PB_MB_EXCLUSION 536 s.safety_class = PB_SAFE_OPPORTUNIST 537 s.benefit_milli = 500 538 s.carries_amr = 1 539 s.cite_id = 4 540 } 541 // Bacillus cereus: same genus as the QPS B. subtilis, but produces 542 // the cereulide emetic toxin + enterotoxins -> a QUALIFIED strain 543 // that FAILS its qualification. Refused as toxigenic. 544 if id == PB_STR_B_CEREUS { 545 s.genus_id = PB_GEN_BACILLUS 546 s.host_mask = PB_HB_SOIL 547 s.mechanism_mask = PB_MB_BIOCONTROL 548 s.safety_class = PB_SAFE_QUALIFIED 549 s.benefit_milli = 300 550 s.is_toxigenic = 1 551 s.cite_id = 3 552 } 553 // Listeria monocytogenes: the classic dairy pathogen contaminant. 554 // Benefits nothing; always refused. 555 if id == PB_STR_LISTERIA { 556 s.genus_id = PB_GEN_LISTERIA 557 s.host_mask = 0 558 s.mechanism_mask = 0 559 s.safety_class = PB_SAFE_PATHOGEN 560 s.benefit_milli = 0 561 s.cite_id = 1 562 } 563 return s 564} 565 566func nx_probiome_strain_count() -> i64 { 567 return PB_STR_N 568} 569 570// ===== nx_probiome_admit ========================================== 571// 572// THE NEVER-HARM REFUSAL POINT. Given a strain and the host kingdom it 573// is being proposed FOR, returns a sealed verdict. Flat guard layers 574// (no nesting) mirror nx_ferment_validate. 575 576func nx_probiome_admit(s: *NxProbiomeStrain, target_host: i64) -> i64 { 577 if target_host < 0 { return PB_REFUSED_BAD_HOST } 578 if target_host >= PB_HOST_N { return PB_REFUSED_BAD_HOST } 579 // Layer 1: a frank pathogen is ALWAYS refused. 580 if s.safety_class == PB_SAFE_PATHOGEN { return PB_REFUSED_PATHOGEN } 581 // Layer 2: an opportunist / non-QPS strain is refused for general use. 582 if s.safety_class == PB_SAFE_OPPORTUNIST { return PB_REFUSED_OPPORTUNIST } 583 // Layer 3: acquired antibiotic resistance is refused (transfer risk). 584 if s.carries_amr != 0 { return PB_REFUSED_AMR } 585 // Layer 4: a toxigenic strain is refused (failed qualification). 586 if s.is_toxigenic != 0 { return PB_REFUSED_TOXIGENIC } 587 // Layer 5: host match -- the strain must actually benefit this host. 588 let bit: i64 = 1 << target_host 589 if (s.host_mask & bit) == 0 { return PB_REFUSED_HOST_MISMATCH } 590 return PB_OK 591} 592 593// ===== Cross-kingdom query predicates ============================= 594 595func pb_benefits_host(s: *NxProbiomeStrain, host: i64) -> i64 { 596 if host < 0 { return 0 } 597 if host >= PB_HOST_N { return 0 } 598 let bit: i64 = 1 << host 599 if (s.host_mask & bit) != 0 { return 1 } 600 return 0 601} 602 603func pb_has_mechanism(s: *NxProbiomeStrain, mech: i64) -> i64 { 604 if mech < 0 { return 0 } 605 if mech >= PB_MECH_N { return 0 } 606 let bit: i64 = 1 << mech 607 if (s.mechanism_mask & bit) != 0 { return 1 } 608 return 0 609} 610 611func pb_host_count(s: *NxProbiomeStrain) -> i64 { 612 var n: i64 = 0 613 var i: i64 = 0 614 while i < PB_HOST_N { 615 let bit: i64 = 1 << i 616 if (s.host_mask & bit) != 0 { n = n + 1 } 617 i = i + 1 618 } 619 return n 620} 621 622func pb_mech_count(s: *NxProbiomeStrain) -> i64 { 623 var n: i64 = 0 624 var i: i64 = 0 625 while i < PB_MECH_N { 626 let bit: i64 = 1 << i 627 if (s.mechanism_mask & bit) != 0 { n = n + 1 } 628 i = i + 1 629 } 630 return n 631} 632 633// Safe-by-class (host-independent): the never-harm layers minus host. 634func pb_is_safe(s: *NxProbiomeStrain) -> i64 { 635 if s.safety_class == PB_SAFE_PATHOGEN { return 0 } 636 if s.safety_class == PB_SAFE_OPPORTUNIST { return 0 } 637 if s.carries_amr != 0 { return 0 } 638 if s.is_toxigenic != 0 { return 0 } 639 return 1 640} 641 642// A "One Health" keystone: SAFE and benefits >= 3 of the 4 kingdoms. 643func pb_is_keystone(s: *NxProbiomeStrain) -> i64 { 644 if pb_is_safe(s) == 0 { return 0 } 645 if pb_host_count(s) >= 3 { return 1 } 646 return 0 647} 648 649// ===== nx_probiome_recommend ====================================== 650// 651// GENERATIVE + SAFE-BY-CONSTRUCTION: over the whole catalog, return the 652// strain id that best serves a (host, mechanism) target -- but ONLY 653// among strains the never-harm gate ADMITS for that host. An unsafe 654// strain (E. faecium's AMR, a toxigenic mold, a pathogen) can never be 655// recommended even when it nominally has the mechanism. -1 if none. 656 657func nx_probiome_recommend(host: i64, mech: i64) -> i64 { 658 var best_id: i64 = -1 659 var best_val: i64 = -1 660 var id: i64 = 0 661 while id < PB_STR_N { 662 let s: *NxProbiomeStrain = nx_probiome_strain(id) 663 if nx_probiome_admit(s, host) == PB_OK { 664 if pb_has_mechanism(s, mech) == 1 { 665 if s.benefit_milli > best_val { 666 best_val = s.benefit_milli 667 best_id = id 668 } 669 } 670 } 671 id = id + 1 672 } 673 return best_id 674} 675 676// The benefit magnitude of the recommended strain (or 0 if none). 677func nx_probiome_recommend_benefit(host: i64, mech: i64) -> i64 { 678 let id: i64 = nx_probiome_recommend(host, mech) 679 if id < 0 { return 0 } 680 let s: *NxProbiomeStrain = nx_probiome_strain(id) 681 return s.benefit_milli 682} 683 684// Count the SAFE strains that benefit a given host (catalog breadth). 685func nx_probiome_count_safe_for(host: i64) -> i64 { 686 var n: i64 = 0 687 var id: i64 = 0 688 while id < PB_STR_N { 689 let s: *NxProbiomeStrain = nx_probiome_strain(id) 690 if nx_probiome_admit(s, host) == PB_OK { n = n + 1 } 691 id = id + 1 692 } 693 return n 694} 695 696// Count SAFE strains in a given microbe domain (bacteria/yeast/mold/...). 697func nx_probiome_count_domain(domain: i64) -> i64 { 698 var n: i64 = 0 699 var id: i64 = 0 700 while id < PB_STR_N { 701 let s: *NxProbiomeStrain = nx_probiome_strain(id) 702 if s.microbe_domain == domain { 703 if pb_is_safe(s) == 1 { n = n + 1 } 704 } 705 id = id + 1 706 } 707 return n 708}