code wiki / (root) / nx_supp_formula.nx

nx_supp_formula.nx

buildroot/runtime/nx_supp_formula.nx

12982 B350 linesdepth 3pulls 3 transitivereach 3 importersview sourcekind librarytopic supp
docsdependenciesstructsconstsfunctions

about

nx_supp_formula.nx -- SUPPLEMENT GTM SUITE / FORMULATION + FEASIBILITY rung. Takes a product concept and runs it all the way to a go/no-go: is it legal, does it physically fit a dosage form, what does it cost to make, and does it clear a margin at the price you want to sell it for. Then it runs the same arithmetic BACKWARDS -- from a retail price and a target margin to the ingredient budget you actually have to spend. THREE GATES, IN THE ORDER THAT ACTUALLY KILLS PRODUCTS. 1. LEGAL. One precluded ingredient and there is no product, regardless of how good the formula is. sf_regulatory_verdict NAMES the blocking ingredient rather than returning a bare no -- the same discipline as the hurdle model naming which barrier holds, because "rejected" without "why" gets argued with instead of fixed. 2. PHYSICAL. A dose is a VOLUME before it is a number on a label. Run the clinically studied doses of a full botanical + amino stack and it comes to roughly ten and a half millilitres -- ELEVEN size-00 capsules per serving. Nobody takes eleven capsules. This is the arithmetic behind why so much of the category is under-dosed: the label dose was chosen to fit the capsule, not to match the trial. The honest response is to change the FORMAT, not to quietly cut the dose, and sf_capsules_needed makes that choice explicit instead of accidental. 3. ECONOMIC. At eleven capsules a serving the shells and the encapsulation labour cost about as much as the actives do, so the format decision is also the margin decision -- chemistry and cost point the same way. FAIRY-DUSTING IS DETECTED, NOT ACCOMMODATED. sf_dose_adequacy_permil compares each dose against the low end of the clinically studied range, so a formula carrying a token 50 mg of something trialled at 600 mg is flagged as what it is. Threshold in a named constant, not buried in a branch. COSTS ARE INDICATIVE (see nx_supp_ingredient). Conversion figures are typical contract-manufacturer rates and move with run size; treat every number here as a model to be replaced by quotes, not as a budget. Units: mg, microlitres, CENTS. Margins and adequacy in per-mil. Grounding (cited; researcher-groundable):

dependencies 2 imports · 2 importers

nx_syscalls.nx nx_supp_ingredient.nx nx_supp_formula.nx nx_gtm_svc.nx nx_prodready.nx

imports: nx_syscalls.nxnx_supp_ingredient.nx

imported by: nx_gtm_svc.nxnx_prodready.nx

structs

79struct NxSuppFormula

consts

49const SF_MAGIC_1000000: i64 = 1000000
53const SF_REFUSED_EMPTY: i64 = 0
54const SF_MARKETABLE: i64 = 1
55const SF_REFUSED_DRUG: i64 = 2
56const SF_REFUSED_NOT_DIETARY: i64 = 3
57const SF_REFUSED_UNKNOWN: i64 = 4
61const SF_FORMAT_CAPSULE: i64 = 1
62const SF_FORMAT_POWDER: i64 = 2
65const SF_SHELL_COST_CENTS: i64 = 1 // per capsule shell
66const SF_ENCAP_COST_CENTS: i64 = 2 // per capsule filled (rounded up)
67const SF_BOTTLE_COST_CENTS: i64 = 50
68const SF_LABEL_COST_CENTS: i64 = 15
69const SF_POWDER_SCOOP_CENTS: i64 = 10
72const SF_FAIRY_DUST_PERMIL: i64 = 500
75const SF_DSHEA_DISCLAIMER_REQUIRED: i64 = 1

functions

85func nx_supp_formula_new() -> *NxSuppFormula
95func sf_set_dose(f: *NxSuppFormula, id: i64, dose_mg: i64) -> i64
called by 1: sf_set_clinical calls 1: si_valid_id
108func sf_set_clinical(f: *NxSuppFormula, id: i64) -> i64
113func sf_dose_of(f: *NxSuppFormula, id: i64) -> i64
122func sf_first_blocking(f: *NxSuppFormula) -> i64
138func sf_regulatory_verdict(f: *NxSuppFormula) -> i64
149func sf_is_marketable(f: *NxSuppFormula) -> i64
157func sf_total_mass_mg(f: *NxSuppFormula) -> i64
called by 1: gtm_formula_assess calls 1: sf_dose_of
170func sf_total_volume_ul(f: *NxSuppFormula) -> i64
189func sf_capsules_needed(f: *NxSuppFormula, shell_ul: i64) -> i64
201func sf_fits_in_capsules(f: *NxSuppFormula, shell_ul: i64, max_caps: i64) -> i64
called by 1: pr_format_ok calls 1: sf_capsules_needed
211func sf_bulkiest_ingredient(f: *NxSuppFormula) -> i64
233func sf_dose_adequacy_permil(f: *NxSuppFormula, id: i64) -> i64
240func sf_is_fairy_dusted(f: *NxSuppFormula, id: i64) -> i64
249func sf_count_fairy_dusted(f: *NxSuppFormula) -> i64
262func sf_actives_cost_cents(f: *NxSuppFormula) -> i64
278func sf_conversion_cost_cents(f: *NxSuppFormula, servings: i64, format: i64, shell_ul: i64) -> i64
289func sf_cogs_per_bottle_cents(f: *NxSuppFormula, servings: i64, format: i64, shell_ul: i64) -> i64
298func sf_gross_margin_permil(retail_cents: i64, cogs_cents: i64) -> i64
313func sf_cogs_budget_cents(retail_cents: i64, target_margin_permil: i64) -> i64
324func sf_actives_budget_per_serving_cents(f: *NxSuppFormula, retail_cents: i64, target_margin_permil: i64, servings: i64, format: i64, shell_ul: i64) -> i64
335func sf_max_dose_for_budget_mg(id: i64, budget_cents: i64) -> i64
344func sf_clinical_dose_affordable(id: i64, budget_cents: i64) -> i64