nx_supp_formula_test.nx source
↩ module page · 225 lines · 13100 B
1// nx_supp_formula_test.nx -- gate for the supplement go-to-market engine.
2// Built around the real target list: a female-libido stack of L-Citrulline,
3// Pycnogenol, Ashwagandha KSM-66, Maca, Tribulus, Panax ginseng and Ginkgo,
4// at the low end of their clinically studied doses.
5//
6// T1-T3 are the ones that decide whether there is a business: the legal gate
7// must REFUSE oxytocin and Kisspeptin-10 by construction and NAME them.
8// T5-T7 are the ones that decide the product: a fully clinically dosed stack
9// does not fit in a capsule, and the arithmetic says so before anyone spends
10// money on a fill run.
11// expect_exit: 0 license_tier: ORIGINAL
12import "nx_syscalls.nx"
13import "nx_supp_ingredient.nx"
14import "nx_supp_formula.nx"
15
16func 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 }
17func 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 }
18
19// The lawful stack, every ingredient at its clinical low-end dose.
20func build_stack() -> *NxSuppFormula {
21 let f: *NxSuppFormula = nx_supp_formula_new()
22 sf_set_clinical(f, SI_L_CITRULLINE)
23 sf_set_clinical(f, SI_PYCNOGENOL)
24 sf_set_clinical(f, SI_ASHWAGANDHA)
25 sf_set_clinical(f, SI_MACA)
26 sf_set_clinical(f, SI_TRIBULUS)
27 sf_set_clinical(f, SI_PANAX_GINSENG)
28 sf_set_clinical(f, SI_GINKGO)
29 return f
30}
31
32func main() -> i64 {
33 var pass: i64 = 0
34 var total: i64 = 0
35
36 let f: *NxSuppFormula = build_stack()
37
38 // --- T1 the lawful stack is marketable ---
39 total = total + 1
40 let v: i64 = sf_regulatory_verdict(f)
41 let block: i64 = sf_first_blocking(f)
42 t_puts("T1 botanical/amino stack verdict=" as *u8); t_putn(v); t_puts(" blocking=" as *u8); t_putn(block); t_puts(" want 1/-1 (MARKETABLE): " as *u8)
43 if v == SF_MARKETABLE { if block == SI_INVALID { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } } else { t_puts("FAIL\n" as *u8) }
44
45 // --- T2 ADDING OXYTOCIN KILLS THE PRODUCT (drug preclusion) ---
46 total = total + 1
47 let ox: *NxSuppFormula = build_stack()
48 sf_set_dose(ox, SI_OXYTOCIN, 10)
49 let v_ox: i64 = sf_regulatory_verdict(ox)
50 let b_ox: i64 = sf_first_blocking(ox)
51 t_puts("T2 + oxytocin: verdict=" as *u8); t_putn(v_ox); t_puts(" blocking ingredient=" as *u8); t_puts(si_name(b_ox)); t_puts(" want 2=REFUSED_DRUG: " as *u8)
52 if v_ox == SF_REFUSED_DRUG { if b_ox == SI_OXYTOCIN { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } } else { t_puts("FAIL\n" as *u8) }
53
54 // --- T3 KISSPEPTIN-10 AND BPC-157 ARE NOT DIETARY INGREDIENTS ---
55 total = total + 1
56 let kp: *NxSuppFormula = build_stack()
57 sf_set_dose(kp, SI_KISSPEPTIN10, 1)
58 let v_kp: i64 = sf_regulatory_verdict(kp)
59 let bpc: *NxSuppFormula = build_stack()
60 sf_set_dose(bpc, SI_BPC157, 500)
61 let v_bpc: i64 = sf_regulatory_verdict(bpc)
62 let brem: *NxSuppFormula = build_stack()
63 sf_set_dose(brem, SI_BREMELANOTIDE, 2)
64 let v_brem: i64 = sf_regulatory_verdict(brem)
65 t_puts("T3 +kisspeptin-10=" as *u8); t_putn(v_kp); t_puts(" +BPC-157=" as *u8); t_putn(v_bpc); t_puts(" +bremelanotide=" as *u8); t_putn(v_brem); t_puts(" want 3/3/2: " as *u8)
66 var ok3: i64 = 1
67 if v_kp != SF_REFUSED_NOT_DIETARY { ok3 = 0 }
68 if v_bpc != SF_REFUSED_NOT_DIETARY { ok3 = 0 }
69 if v_brem != SF_REFUSED_DRUG { ok3 = 0 }
70 if ok3 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) }
71
72 // --- T4 fail-closed: unknown id and empty formula ---
73 total = total + 1
74 let bad: *NxSuppFormula = nx_supp_formula_new()
75 sf_set_dose(bad, 99, 100)
76 let v_bad: i64 = sf_regulatory_verdict(bad)
77 let empty: *NxSuppFormula = nx_supp_formula_new()
78 let v_empty: i64 = sf_regulatory_verdict(empty)
79 t_puts("T4 unknown-ingredient=" as *u8); t_putn(v_bad); t_puts(" empty-formula=" as *u8); t_putn(v_empty); t_puts(" want 4/0 (never MARKETABLE): " as *u8)
80 var ok4: i64 = 1
81 if v_bad != SF_REFUSED_UNKNOWN { ok4 = 0 }
82 if v_empty != SF_REFUSED_EMPTY { ok4 = 0 }
83 if ok4 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) }
84
85 // --- T5 THE PHYSICAL WALL: the clinical stack needs ~11 size-00 caps ---
86 total = total + 1
87 let mass: i64 = sf_total_mass_mg(f)
88 let vol: i64 = sf_total_volume_ul(f)
89 let caps00: i64 = sf_capsules_needed(f, SI_CAP_00)
90 let caps000: i64 = sf_capsules_needed(f, SI_CAP_000)
91 t_puts("T5 serving mass=" as *u8); t_putn(mass); t_puts(" mg volume=" as *u8); t_putn(vol); t_puts(" uL -> size-00 caps=" as *u8); t_putn(caps00); t_puts(" size-000 caps=" as *u8); t_putn(caps000); t_puts(": " as *u8)
92 var ok5: i64 = 1
93 if mass != 6180 { ok5 = 0 }
94 if caps00 < 9 { ok5 = 0 }
95 if caps00 > 13 { ok5 = 0 }
96 if caps000 >= caps00 { ok5 = 0 }
97 if ok5 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) }
98
99 // --- T6 it does NOT fit a saleable capsule count, and the engine says
100 // which ingredient is responsible ---
101 total = total + 1
102 let fits2: i64 = sf_fits_in_capsules(f, SI_CAP_00, 2)
103 let fits4: i64 = sf_fits_in_capsules(f, SI_CAP_00, 4)
104 let bulk: i64 = sf_bulkiest_ingredient(f)
105 t_puts("T6 fits in 2 caps=" as *u8); t_putn(fits2); t_puts(" in 4 caps=" as *u8); t_putn(fits4); t_puts(" bulkiest=" as *u8); t_puts(si_name(bulk)); t_puts(": " as *u8)
106 var ok6: i64 = 1
107 if fits2 != 0 { ok6 = 0 }
108 if fits4 != 0 { ok6 = 0 }
109 if bulk != SI_L_CITRULLINE { ok6 = 0 }
110 if ok6 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) }
111
112 // --- T7 drop the two bulk drivers and a 2-capsule product IS reachable ---
113 total = total + 1
114 let lean: *NxSuppFormula = nx_supp_formula_new()
115 sf_set_clinical(lean, SI_PYCNOGENOL)
116 sf_set_clinical(lean, SI_PANAX_GINSENG)
117 sf_set_clinical(lean, SI_GINKGO)
118 sf_set_dose(lean, SI_ASHWAGANDHA, 300)
119 let lean_caps: i64 = sf_capsules_needed(lean, SI_CAP_00)
120 let lean_ok: i64 = sf_is_marketable(lean)
121 t_puts("T7 lean formula (no citrulline/maca, half ashwagandha) = " as *u8); t_putn(lean_caps); t_puts(" size-00 caps, marketable=" as *u8); t_putn(lean_ok); t_puts(": " as *u8)
122 var ok7: i64 = 1
123 if lean_caps > 2 { ok7 = 0 }
124 if lean_caps < 1 { ok7 = 0 }
125 if lean_ok != 1 { ok7 = 0 }
126 if ok7 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) }
127
128 // --- T8 the fairy-dust boundary, tested on BOTH sides ---
129 // A deliberate HALF dose is a formulation choice, not fairy dust, so the
130 // threshold is exclusive: 500 permil is not flagged. A token 50 mg of an
131 // ingredient trialled at 600 mg is, and that is the case worth catching.
132 total = total + 1
133 let ash_ad: i64 = sf_dose_adequacy_permil(lean, SI_ASHWAGANDHA)
134 let ash_fd: i64 = sf_is_fairy_dusted(lean, SI_ASHWAGANDHA)
135 let token: *NxSuppFormula = nx_supp_formula_new()
136 sf_set_dose(token, SI_ASHWAGANDHA, 50)
137 let tok_ad: i64 = sf_dose_adequacy_permil(token, SI_ASHWAGANDHA)
138 let tok_fd: i64 = sf_is_fairy_dusted(token, SI_ASHWAGANDHA)
139 let full_fd: i64 = sf_count_fairy_dusted(f)
140 let unset_fd: i64 = sf_is_fairy_dusted(f, SI_FENUGREEK)
141 t_puts("T8 half dose adequacy=" as *u8); t_putn(ash_ad); t_puts(" flagged=" as *u8); t_putn(ash_fd); t_puts(" ; token 50mg adequacy=" as *u8); t_putn(tok_ad); t_puts(" flagged=" as *u8); t_putn(tok_fd); t_puts(" ; full stack flagged=" as *u8); t_putn(full_fd); t_puts(" absent ingredient=" as *u8); t_putn(unset_fd); t_puts(": " as *u8)
142 var ok8: i64 = 1
143 if ash_ad != 500 { ok8 = 0 }
144 if ash_fd != 0 { ok8 = 0 }
145 if tok_ad != 83 { ok8 = 0 }
146 if tok_fd != 1 { ok8 = 0 }
147 if full_fd != 0 { ok8 = 0 }
148 if unset_fd != 0 { ok8 = 0 }
149 if ok8 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) }
150
151 // --- T9 COGS: actives per serving, and the capsule penalty ---
152 total = total + 1
153 let act: i64 = sf_actives_cost_cents(f)
154 let cogs_cap: i64 = sf_cogs_per_bottle_cents(f, 30, SF_FORMAT_CAPSULE, SI_CAP_00)
155 let cogs_pow: i64 = sf_cogs_per_bottle_cents(f, 30, SF_FORMAT_POWDER, 0)
156 let penalty: i64 = cogs_cap - cogs_pow
157 t_puts("T9 actives=" as *u8); t_putn(act); t_puts("c/serving; 30-serving bottle COGS capsule=" as *u8); t_putn(cogs_cap); t_puts("c powder=" as *u8); t_putn(cogs_pow); t_puts("c ; capsule penalty=" as *u8); t_putn(penalty); t_puts("c: " as *u8)
158 var ok9: i64 = 1
159 if act < 35 { ok9 = 0 }
160 if act > 50 { ok9 = 0 }
161 if cogs_cap <= cogs_pow { ok9 = 0 }
162 if penalty < 500 { ok9 = 0 }
163 if ok9 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) }
164
165 // --- T10 MARGIN AT $39.99: capsule fails a 70% target, powder nearly hits it ---
166 total = total + 1
167 let retail: i64 = 3999
168 let m_cap: i64 = sf_gross_margin_permil(retail, cogs_cap)
169 let m_pow: i64 = sf_gross_margin_permil(retail, cogs_pow)
170 t_puts("T10 at $39.99 gross margin capsule=" as *u8); t_putn(m_cap); t_puts(" permil powder=" as *u8); t_putn(m_pow); t_puts(" permil (target 700): " as *u8)
171 var ok10: i64 = 1
172 if m_cap >= 700 { ok10 = 0 }
173 if m_pow <= m_cap { ok10 = 0 }
174 if m_pow < 600 { ok10 = 0 }
175 if ok10 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) }
176
177 // --- T11 RUNNING IT BACKWARDS: price + margin -> ingredient budget ---
178 total = total + 1
179 let budget: i64 = sf_cogs_budget_cents(retail, 700)
180 let per_serv: i64 = sf_actives_budget_per_serving_cents(f, retail, 700, 30, SF_FORMAT_POWDER, 0)
181 let per_serv_cap: i64 = sf_actives_budget_per_serving_cents(f, retail, 700, 30, SF_FORMAT_CAPSULE, SI_CAP_00)
182 t_puts("T11 $39.99 at 70% GM -> COGS budget=" as *u8); t_putn(budget); t_puts("c ; actives budget/serving powder=" as *u8); t_putn(per_serv); t_puts("c capsule=" as *u8); t_putn(per_serv_cap); t_puts("c: " as *u8)
183 var ok11: i64 = 1
184 if budget != 1199 { ok11 = 0 }
185 if per_serv <= 0 { ok11 = 0 }
186 if per_serv_cap >= per_serv { ok11 = 0 }
187 if ok11 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) }
188
189 // --- T12 the budget buys the clinical dose of everything here ---
190 total = total + 1
191 let aff_cit: i64 = sf_clinical_dose_affordable(SI_L_CITRULLINE, per_serv)
192 let aff_pyc: i64 = sf_clinical_dose_affordable(SI_PYCNOGENOL, per_serv)
193 let max_pyc: i64 = sf_max_dose_for_budget_mg(SI_PYCNOGENOL, 9)
194 t_puts("T12 at " as *u8); t_putn(per_serv); t_puts("c/serving: citrulline clinical affordable=" as *u8); t_putn(aff_cit); t_puts(" pycnogenol=" as *u8); t_putn(aff_pyc); t_puts(" ; 9c buys " as *u8); t_putn(max_pyc); t_puts("mg pycnogenol: " as *u8)
195 var ok12: i64 = 1
196 if aff_cit != 1 { ok12 = 0 }
197 if aff_pyc != 1 { ok12 = 0 }
198 if max_pyc != 60 { ok12 = 0 }
199 if ok12 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) }
200
201 // --- T13 a price too low returns a NEGATIVE actives budget: the honest
202 // answer that conversion alone already blows the COGS ---
203 total = total + 1
204 let cheap: i64 = sf_actives_budget_per_serving_cents(f, 500, 700, 30, SF_FORMAT_CAPSULE, SI_CAP_00)
205 t_puts("T13 at $5.00 retail / 70% GM the actives budget is " as *u8); t_putn(cheap); t_puts("c per serving (negative = impossible): " as *u8)
206 if cheap < 0 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) }
207
208 // --- T14 capsule fill is VOLUME x DENSITY, not a fixed mg figure ---
209 total = total + 1
210 let fill_dense: i64 = si_capsule_fill_mg(SI_CAP_00, si_density_mg_per_ml(SI_L_CITRULLINE))
211 let fill_fluffy: i64 = si_capsule_fill_mg(SI_CAP_00, si_density_mg_per_ml(SI_GINKGO))
212 t_puts("T14 size-00 holds " as *u8); t_putn(fill_dense); t_puts("mg citrulline but only " as *u8); t_putn(fill_fluffy); t_puts("mg ginkgo: " as *u8)
213 if fill_dense > fill_fluffy { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) }
214
215 // --- T15 costs are flagged indicative, and the DSHEA disclaimer is
216 // not optional ---
217 total = total + 1
218 let ind: i64 = si_cost_is_indicative(SI_PYCNOGENOL)
219 t_puts("T15 costs flagged indicative=" as *u8); t_putn(ind); t_puts(" DSHEA disclaimer required=" as *u8); t_putn(SF_DSHEA_DISCLAIMER_REQUIRED); t_puts(": " as *u8)
220 if ind == 1 { if SF_DSHEA_DISCLAIMER_REQUIRED == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } } else { t_puts("FAIL\n" as *u8) }
221
222 t_puts("SUPP-GTM-GATE passed " as *u8); t_putn(pass); t_puts("/" as *u8); t_putn(total)
223 if pass == total { t_puts(" verdict=GREEN\n" as *u8); sys_exit(0); return 0 }
224 t_puts(" verdict=RED\n" as *u8); sys_exit(1); return 1
225}