nx_probiome_garden.nx source
↩ module page · 94 lines · 4174 B
1// nx_probiome_garden.nx -- R6c: the PLANT-KINGDOM payoff. Matches a crop
2// to the beneficial soil/root microbe that helps it grow -- real agronomy
3// (Rhizobium inoculant for legumes, Azospirillum for cereals, arbuscular
4// mycorrhizae for root crops, Bacillus biocontrol for disease-prone
5// fruiting crops) -- and VALIDATES every recommendation through the R6
6// never-HARM gate for the PLANT host. So the garden gets "healthy
7// opportunities" from the same beneficial-microbe engine that runs the
8// cheese/yogurt cultures, and can never be handed an unsafe organism.
9//
10// Separation of concerns (Rule 9): nx_probiome knows WHICH microbes are
11// safe and WHAT they do; this rung adds the crop<->microbe agronomy and
12// leans on the probiome gate to prove the pick is safe + plant-beneficial.
13//
14// Biology note: Rhizobium fixes nitrogen only in SYMBIOSIS with legume
15// root nodules (host-specific), so it is matched to legumes; cereals and
16// leafy crops get the ASSOCIATIVE / free-living diazotrophs (Azospirillum,
17// Azotobacter) that work in any rhizosphere.
18//
19// genealogy_id: nishi_probiome_r6 + legume_rhizobium_inoculation_agronomy
20
21import "nx_syscalls.nx"
22import "nx_probiome.nx"
23
24// ===== Sealed enum: crop archetype (by microbial partnership) =====
25
26const PG_CROP_LEGUME: i64 = 0 // beans/peas/lentils -> symbiotic N-fixer
27const PG_CROP_CEREAL: i64 = 1 // corn/wheat/rice (grasses) -> associative N
28const PG_CROP_LEAFY: i64 = 2 // lettuce/brassica (heavy N) -> free-living N
29const PG_CROP_FRUITING: i64 = 3 // tomato/pepper/squash -> biocontrol + P
30const PG_CROP_ROOT: i64 = 4 // carrot/potato/onion -> mycorrhizal P uptake
31const PG_CROP_TREE: i64 = 5 // fruit trees/perennials -> mycorrhiza
32const PG_CROP_N: i64 = 6
33
34// Primary microbial NEED (a probiome mechanism) per crop archetype.
35func pg_crop_mechanism(crop: i64) -> i64 {
36 if crop == PG_CROP_LEGUME { return PB_MECH_NFIX }
37 if crop == PG_CROP_CEREAL { return PB_MECH_NFIX }
38 if crop == PG_CROP_LEAFY { return PB_MECH_NFIX }
39 if crop == PG_CROP_FRUITING { return PB_MECH_BIOCONTROL }
40 if crop == PG_CROP_ROOT { return PB_MECH_MYCORRHIZAL }
41 if crop == PG_CROP_TREE { return PB_MECH_MYCORRHIZAL }
42 return -1
43}
44
45// The recommended inoculant strain (agronomy-grounded, host-specific).
46func pg_inoculant(crop: i64) -> i64 {
47 if crop == PG_CROP_LEGUME { return PB_STR_RHIZOBIUM }
48 if crop == PG_CROP_CEREAL { return PB_STR_AZOSPIRILLUM }
49 if crop == PG_CROP_LEAFY { return PB_STR_AZOTOBACTER }
50 if crop == PG_CROP_FRUITING { return PB_STR_B_SUBTILIS }
51 if crop == PG_CROP_ROOT { return PB_STR_MYCORRHIZA }
52 if crop == PG_CROP_TREE { return PB_STR_MYCORRHIZA }
53 return -1
54}
55
56// Validate the recommended inoculant through the R6 never-HARM gate for
57// the PLANT host. Returns the sealed probiome verdict (PB_OK if safe);
58// an unknown crop is a host mismatch (nothing recommended).
59func pg_inoculant_admit(crop: i64) -> i64 {
60 let sid: i64 = pg_inoculant(crop)
61 if sid < 0 { return PB_REFUSED_HOST_MISMATCH }
62 let s: *NxProbiomeStrain = nx_probiome_strain(sid)
63 return nx_probiome_admit(s, PB_HOST_PLANT)
64}
65
66// The benefit magnitude of the recommended inoculant (0 if none).
67func pg_inoculant_benefit(crop: i64) -> i64 {
68 let sid: i64 = pg_inoculant(crop)
69 if sid < 0 { return 0 }
70 let s: *NxProbiomeStrain = nx_probiome_strain(sid)
71 return s.benefit_milli
72}
73
74// Does the recommended inoculant actually deliver the crop's needed
75// mechanism? (Consistency check between the agronomy map and the biology.)
76func pg_inoculant_delivers_need(crop: i64) -> i64 {
77 let sid: i64 = pg_inoculant(crop)
78 if sid < 0 { return 0 }
79 let need: i64 = pg_crop_mechanism(crop)
80 let s: *NxProbiomeStrain = nx_probiome_strain(sid)
81 return pb_has_mechanism(s, need)
82}
83
84// Count crop archetypes whose recommended inoculant is safe + plant-
85// beneficial (should be all of them -- safe by construction).
86func pg_count_served() -> i64 {
87 var n: i64 = 0
88 var crop: i64 = 0
89 while crop < PG_CROP_N {
90 if pg_inoculant_admit(crop) == PB_OK { n = n + 1 }
91 crop = crop + 1
92 }
93 return n
94}