code wiki / (root) / nx_haccp_test.nx

nx_haccp_test.nx source

↩ module page · 51 lines · 2288 B

1// nx_haccp_test.nx -- smoke for nx_haccp. Proves hazard analysis, CCP 2// determination, grounded critical limits, monitoring, the never-poison 3// HALT on a breached CCP, and composition with nx_preservation's 12-D cook. 4// Exit code = failed assertion number; 0 = all pass. 5 6import "nx_syscalls.nx" 7import "nx_preservation.nx" 8import "nx_haccp.nx" 9 10func main() -> i64 { 11 // --- CCP determination (control points vs prerequisites) --- 12 if haccp_is_ccp(HC_COOK) != HC_CCP_YES { return 1 } 13 if haccp_is_ccp(HC_CAN) != HC_CCP_YES { return 2 } 14 if haccp_is_ccp(HC_ACIDIFY) != HC_CCP_YES { return 3 } 15 if haccp_is_ccp(HC_RECEIVE) != HC_CCP_NO { return 4 } // prerequisite 16 if haccp_is_ccp(HC_SERVE) != HC_CCP_NO { return 5 } 17 18 // --- hazard analysis --- 19 if haccp_primary_hazard(HC_COOK) != HC_HAZ_BIO { return 6 } 20 if haccp_primary_hazard(HC_PREP) != HC_HAZ_PHYS { return 7 } 21 22 // --- cook critical limits --- 23 if haccp_cook_limit(HC_FOOD_POULTRY) != 74 { return 8 } 24 if haccp_cook_limit(HC_FOOD_WHOLE) != 63 { return 9 } 25 26 // --- COOK CCP monitoring + never-poison HALT --- 27 if haccp_cook_admit(75, HC_FOOD_POULTRY) != HC_OK { return 10 } 28 if haccp_cook_admit(70, HC_FOOD_POULTRY) != HC_HALT { return 11 } // undercooked poultry HALTS 29 if haccp_cook_admit(65, HC_FOOD_WHOLE) != HC_OK { return 12 } 30 31 // --- COOL CCP: two-stage cooling --- 32 if haccp_cool_admit(2, 4) != HC_OK { return 13 } 33 if haccp_cool_admit(3, 4) != HC_HALT { return 14 } // stage 1 too slow HALTS 34 if haccp_cool_admit(2, 5) != HC_HALT { return 15 } // stage 2 too slow HALTS 35 36 // --- HOLD CCPs --- 37 if haccp_hot_hold_admit(60) != HC_OK { return 16 } 38 if haccp_hot_hold_admit(50) != HC_HALT { return 17 } 39 if haccp_cold_hold_admit(4) != HC_OK { return 18 } 40 if haccp_cold_hold_admit(8) != HC_HALT { return 19 } 41 42 // --- CAN CCP composes preservation's 12-D botulinum cook --- 43 if haccp_can_admit(2520, 210) != HC_OK { return 20 } 44 if haccp_can_admit(2310, 210) != HC_HALT { return 21 } // short of 12-D HALTS 45 46 // --- ACIDIFY CCP composes the ferment never-poison line --- 47 if haccp_acidify_admit(4200) != HC_OK { return 22 } 48 if haccp_acidify_admit(5000) != HC_HALT { return 23 } // above pH 4.6 HALTS 49 50 return 0 51}