code wiki / (root) / nx_supp_channel_test.nx

nx_supp_channel_test.nx source

↩ module page · 171 lines · 9618 B

1// nx_supp_channel_test.nx -- gate for the commercial-channel rung. 2// T3/T4 carry the answer: oxytocin HAS a lawful US route (503A compounding, 3// via the approved-drug-substance prong) while kisspeptin-10 has none and 4// BPC-157 was affirmatively excluded. Same channel, opposite outcomes, by a 5// rule on the record. 6// expect_exit: 0 license_tier: ORIGINAL 7import "nx_syscalls.nx" 8import "nx_supp_ingredient.nx" 9import "nx_supp_channel.nx" 10 11func t_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 12func t_putn(v: i64) -> i64 { let bb: *u8 = sys_mmap(28); var m: i64 = v; if m < 0 { m = 0 - m; sys_write(1, "-" as *u8, 1) } let t: *u8 = sys_mmap(28); var k: i64 = 0; if m == 0 { t[0] = 48 as u8; k = 1 } while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } var i: i64 = 0; while i < k { bb[i] = t[k - 1 - i]; i = i + 1 } sys_write(1, bb, k); return 0 } 13 14func main() -> i64 { 15 var pass: i64 = 0 16 var total: i64 = 0 17 18 // --- T1 a botanical's best channel is plain retail, no prescriber --- 19 total = total + 1 20 let b_ash: i64 = ch_best(SI_ASHWAGANDHA) 21 let rx_ash: i64 = ch_requires_prescriber(b_ash) 22 let n_ash: i64 = ch_count_open(SI_ASHWAGANDHA) 23 t_puts("T1 ashwagandha best channel = " as *u8); t_puts(ch_name(b_ash)); t_puts(" prescriber=" as *u8); t_putn(rx_ash); t_puts(" channels open=" as *u8); t_putn(n_ash); t_puts(": " as *u8) 24 var ok1: i64 = 1 25 if b_ash != CH_SUPPLEMENT { ok1 = 0 } 26 if rx_ash != 0 { ok1 = 0 } 27 if n_ash != 1 { ok1 = 0 } 28 if ok1 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } 29 30 // --- T2 a peptide has NO supplement channel, in any framing --- 31 total = total + 1 32 let s_kp: i64 = ch_open(SI_KISSPEPTIN10, CH_SUPPLEMENT) 33 let s_ox: i64 = ch_open(SI_OXYTOCIN, CH_SUPPLEMENT) 34 let s_bpc: i64 = ch_open(SI_BPC157, CH_SUPPLEMENT) 35 t_puts("T2 supplement channel: kisspeptin=" as *u8); t_putn(s_kp); t_puts(" oxytocin=" as *u8); t_putn(s_ox); t_puts(" BPC-157=" as *u8); t_putn(s_bpc); t_puts(" want all 0: " as *u8) 36 var ok2: i64 = 1 37 if s_kp != 0 { ok2 = 0 } 38 if s_ox != 0 { ok2 = 0 } 39 if s_bpc != 0 { ok2 = 0 } 40 if ok2 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } 41 42 // --- T3 OXYTOCIN DOES HAVE A LAWFUL US ROUTE: 503A compounding, 43 // via the approved-drug-substance prong --- 44 total = total + 1 45 let p1: i64 = ch_is_approved_drug_substance(SI_OXYTOCIN) 46 let p2: i64 = ch_has_usp_monograph(SI_OXYTOCIN) 47 let prongs: i64 = ch_prongs_passed(SI_OXYTOCIN) 48 let comp: i64 = ch_compoundable(SI_OXYTOCIN) 49 let best_ox: i64 = ch_best(SI_OXYTOCIN) 50 t_puts("T3 oxytocin prong1(approved)=" as *u8); t_putn(p1); t_puts(" prong2(USP)=" as *u8); t_putn(p2); t_puts(" total prongs=" as *u8); t_putn(prongs); t_puts(" compoundable=" as *u8); t_putn(comp); t_puts(" best=" as *u8); t_puts(ch_name(best_ox)); t_puts(": " as *u8) 51 var ok3: i64 = 1 52 if p1 != 1 { ok3 = 0 } 53 if p2 != 1 { ok3 = 0 } 54 if prongs != 2 { ok3 = 0 } 55 if comp != 1 { ok3 = 0 } 56 if best_ox != CH_RX_COMPOUNDED { ok3 = 0 } 57 if ok3 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } 58 59 // --- T4 KISSPEPTIN-10 PASSES NO PRONG; BPC-157 WAS EXCLUDED --- 60 // Being reviewed and rejected is a stronger no than never examined. 61 total = total + 1 62 let kp_prongs: i64 = ch_prongs_passed(SI_KISSPEPTIN10) 63 let kp_comp: i64 = ch_compoundable(SI_KISSPEPTIN10) 64 let kp_route: i64 = ch_has_any_route(SI_KISSPEPTIN10) 65 let bpc_cat2: i64 = ch_is_503a_category2(SI_BPC157) 66 let bpc_comp: i64 = ch_compoundable(SI_BPC157) 67 let bpc_route: i64 = ch_has_any_route(SI_BPC157) 68 t_puts("T4 kisspeptin prongs=" as *u8); t_putn(kp_prongs); t_puts(" compoundable=" as *u8); t_putn(kp_comp); t_puts(" any route=" as *u8); t_putn(kp_route); t_puts(" ; BPC-157 category2=" as *u8); t_putn(bpc_cat2); t_puts(" compoundable=" as *u8); t_putn(bpc_comp); t_puts(" any route=" as *u8); t_putn(bpc_route); t_puts(": " as *u8) 69 var ok4: i64 = 1 70 if kp_prongs != 0 { ok4 = 0 } 71 if kp_comp != 0 { ok4 = 0 } 72 if kp_route != 0 { ok4 = 0 } 73 if bpc_cat2 != 1 { ok4 = 0 } 74 if bpc_comp != 0 { ok4 = 0 } 75 if bpc_route != 0 { ok4 = 0 } 76 if ok4 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } 77 78 // --- T5 BPC-157 is closed off by BOTH mechanisms independently --- 79 // HONEST LIMITATION: this does NOT prove that the category-2 exclusion 80 // takes precedence over a passing prong, because BPC-157 passes zero 81 // prongs -- the assertion would hold even if the precedence were wrong. 82 // No catalog entry currently has both properties, so that ordering is 83 // UNTESTED BY CONSTRUCTION. It becomes testable the moment a substance is 84 // added that is both listed and excluded; until then this test only 85 // establishes that BPC-157 has no compounding route by either route. 86 total = total + 1 87 let bpc_p: i64 = ch_prongs_passed(SI_BPC157) 88 let bpc_c: i64 = ch_compoundable(SI_BPC157) 89 let bpc_x: i64 = ch_is_503a_category2(SI_BPC157) 90 t_puts("T5 BPC-157 prongs=" as *u8); t_putn(bpc_p); t_puts(" excluded=" as *u8); t_putn(bpc_x); t_puts(" compoundable=" as *u8); t_putn(bpc_c); t_puts(" (precedence itself UNTESTED - no dual-property entry): " as *u8) 91 var ok5: i64 = 1 92 if bpc_p != 0 { ok5 = 0 } 93 if bpc_x != 1 { ok5 = 0 } 94 if bpc_c != 0 { ok5 = 0 } 95 if ok5 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } 96 97 // --- T6 bremelanotide: approved drug, so the approved route is open 98 // and compounding follows from prong 1 --- 99 total = total + 1 100 let br_app: i64 = ch_open(SI_BREMELANOTIDE, CH_APPROVED_DRUG) 101 let br_best: i64 = ch_best(SI_BREMELANOTIDE) 102 let br_rx: i64 = ch_requires_prescriber(br_best) 103 t_puts("T6 bremelanotide approved-drug channel=" as *u8); t_putn(br_app); t_puts(" best=" as *u8); t_puts(ch_name(br_best)); t_puts(" prescriber=" as *u8); t_putn(br_rx); t_puts(": " as *u8) 104 var ok6: i64 = 1 105 if br_app != 1 { ok6 = 0 } 106 if br_rx != 1 { ok6 = 0 } 107 if ok6 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } 108 109 // --- T7 every prescription channel is flagged as needing a prescriber, 110 // and retail/OTC are not --- 111 total = total + 1 112 let r_sup: i64 = ch_requires_prescriber(CH_SUPPLEMENT) 113 let r_otc: i64 = ch_requires_prescriber(CH_OTC_MONOGRAPH) 114 let r_503a: i64 = ch_requires_prescriber(CH_RX_COMPOUNDED) 115 let r_503b: i64 = ch_requires_prescriber(CH_RX_OUTSOURCING) 116 let r_nda: i64 = ch_requires_prescriber(CH_APPROVED_DRUG) 117 t_puts("T7 prescriber needed supplement/OTC/503A/503B/NDA = " as *u8); t_putn(r_sup); t_puts("/" as *u8); t_putn(r_otc); t_puts("/" as *u8); t_putn(r_503a); t_puts("/" as *u8); t_putn(r_503b); t_puts("/" as *u8); t_putn(r_nda); t_puts(" want 0/0/1/1/1: " as *u8) 118 var ok7: i64 = 1 119 if r_sup != 0 { ok7 = 0 } 120 if r_otc != 0 { ok7 = 0 } 121 if r_503a != 1 { ok7 = 0 } 122 if r_503b != 1 { ok7 = 0 } 123 if r_nda != 1 { ok7 = 0 } 124 if ok7 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } 125 126 // --- T8 OFFSHORE DOES NOT OPEN A US ROUTE --- 127 // Encoded as functions so a downstream planner cannot route around it. 128 total = total + 1 129 let off: i64 = ch_offshore_manufacture_opens_us_retail() 130 let fa: i64 = ch_foreign_approval_covers_us_sale() 131 t_puts("T8 offshore manufacture opens US retail=" as *u8); t_putn(off); t_puts(" foreign approval covers US sale=" as *u8); t_putn(fa); t_puts(" want 0/0: " as *u8) 132 if off == 0 { if fa == 0 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } } else { t_puts("FAIL\n" as *u8) } 133 134 // --- T9 fail-closed on an unknown substance --- 135 total = total + 1 136 let u_route: i64 = ch_has_any_route(99) 137 let u_comp: i64 = ch_compoundable(99) 138 let u_open: i64 = ch_open(99, CH_SUPPLEMENT) 139 t_puts("T9 unknown substance: any route=" as *u8); t_putn(u_route); t_puts(" compoundable=" as *u8); t_putn(u_comp); t_puts(" supplement=" as *u8); t_putn(u_open); t_puts(" want all 0: " as *u8) 140 var ok9: i64 = 1 141 if u_route != 0 { ok9 = 0 } 142 if u_comp != 0 { ok9 = 0 } 143 if u_open != 0 { ok9 = 0 } 144 if ok9 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } 145 146 // --- T10 the whole catalog, summarised: how many substances have any 147 // lawful route at all --- 148 total = total + 1 149 var i10: i64 = 0 150 var routed: i64 = 0 151 var rx_only: i64 = 0 152 while i10 < SI_N { 153 let r: i64 = ch_has_any_route(i10) 154 routed = routed + r 155 if r == 1 { 156 let b: i64 = ch_best(i10) 157 let need: i64 = ch_requires_prescriber(b) 158 rx_only = rx_only + need 159 } 160 i10 = i10 + 1 161 } 162 t_puts("T10 catalog of " as *u8); t_putn(SI_N); t_puts(": " as *u8); t_putn(routed); t_puts(" have a lawful route, of which " as *u8); t_putn(rx_only); t_puts(" are prescription-only: " as *u8) 163 var ok10: i64 = 1 164 if routed != 11 { ok10 = 0 } 165 if rx_only != 2 { ok10 = 0 } 166 if ok10 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } 167 168 t_puts("SUPP-CHANNEL-GATE passed " as *u8); t_putn(pass); t_puts("/" as *u8); t_putn(total) 169 if pass == total { t_puts(" verdict=GREEN\n" as *u8); sys_exit(0); return 0 } 170 t_puts(" verdict=RED\n" as *u8); sys_exit(1); return 1 171}