code wiki / (root) / nx_allergen.nx

nx_allergen.nx

buildroot/runtime/nx_allergen.nx

5384 B138 linesdepth 2pulls 2 transitivereach 1 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_allergen.nx -- FOOD-SCIENCE SUITE / ALLERGEN MANAGEMENT rung. Tracks the FDA "big 9" allergens (FASTER Act 2021) as a bitmask, rolls a recipe's ingredients up into its full allergen profile (catching HIDDEN allergens a naive list misses -- traditional soy sauce carries BOTH soy AND wheat), checks a recipe against a person's avoid-profile, flags shared-equipment CROSS-CONTACT ("may contain"), and suggests a substitution that NEVER reintroduces an avoided allergen. THE exceed: allergen safety is computed by ROLLUP + personalization + cross-contact + safe-substitution, not a static "contains nuts" line; and a substitute is validated against the SAME avoid-profile so it can't swap one allergen for another (the classic milk->soy-milk mistake for a soy-allergic person). Grounded: fda_faster_act_2021_big9_allergens + fda_food_allergen_labeling genealogy_id: fda_big9_allergens + nishi_food_science_suite

dependencies 1 imports · 1 importers

nx_syscalls.nx nx_allergen.nx nx_allergen_test.nx

imports: nx_syscalls.nx

imported by: nx_allergen_test.nx

structs

none

consts

22const AL_MILK: i64 = 1
23const AL_EGG: i64 = 2
24const AL_FISH: i64 = 4
25const AL_SHELLFISH: i64 = 8
26const AL_TREENUT: i64 = 16
27const AL_PEANUT: i64 = 32
28const AL_WHEAT: i64 = 64
29const AL_SOY: i64 = 128
30const AL_SESAME: i64 = 256
31const AL_N: i64 = 9 // number of allergen bits
35const ING_MILK: i64 = 0
36const ING_CHEESE: i64 = 1
37const ING_YOGURT: i64 = 2
38const ING_EGG: i64 = 3
39const ING_WHEAT_FLOUR: i64 = 4
40const ING_BREAD: i64 = 5
41const ING_SOY_SAUCE: i64 = 6
42const ING_TOFU: i64 = 7
43const ING_PEANUT: i64 = 8
44const ING_ALMOND: i64 = 9
45const ING_SHRIMP: i64 = 10
46const ING_SALMON: i64 = 11
47const ING_SESAME_OIL: i64 = 12
48const ING_TAHINI: i64 = 13
49const ING_RICE: i64 = 14
50const ING_CHICKEN: i64 = 15
51const ING_OLIVE_OIL: i64 = 16
53const ING_OAT_MILK: i64 = 17
54const ING_RICE_FLOUR: i64 = 18
55const ING_COCONUT_AMINOS: i64 = 19
56const ING_FLAX_EGG: i64 = 20
57const ING_SUNFLOWER_BUTTER: i64 = 21
58const ING_N: i64 = 22

functions

61func nx_ingredient_allergens(id: i64) -> i64
82func al_mask_add(mask: i64, ing_id: i64) -> i64
called by 1: main calls 1: nx_ingredient_allergens
86func al_contains(recipe_mask: i64, allergen_bit: i64) -> i64
called by 1: main
92func al_safe_for(recipe_mask: i64, avoid_mask: i64) -> i64
called by 1: main
98func al_count(recipe_mask: i64) -> i64
called by 1: main
111func al_cross_contact_risk(facility_mask: i64, avoid_mask: i64) -> i64
called by 1: main
121func al_substitute(ing_id: i64, avoid_mask: i64) -> i64
called by 1: main calls 1: nx_ingredient_allergens