code wiki / (root) / nx_water_design_test.nx

nx_water_design_test.nx source

↩ module page · 61 lines · 4094 B

1// nx_water_design_test.nx -- the end-to-end water DESIGN gate for nx_water_design: the full 2// research-to-design chain. Raw atmospheric condensate is flat AND unsafe; treatment makes it potable 3// but still flat; remineralisation makes it delicious, healthful and safe; and the harvester 4// recommender plus the yield model compose in from nx_water_awg. 5// 6// MIGRATED OFF A HAND-ROLLED VERDICT 2026-08-14 -- reasoning in nx_water_quality_test. The exit code 7// was the failed assertion NUMBER, so no outside judge could read the outcome and the first failure 8// masked every later one. Now inherits nx_gate_verdict; migrated per-tooth by hand because the 9// automated D001 candidate collapses N teeth into a single boolean. 10// 11// THIS GATE IS THE ONE THAT EARNS THE DOMAIN'S CLAIM. It does not merely check that the designed water 12// scores well -- it asserts the STAGES ARE DIFFERENT FROM EACH OTHER: raw is refused, treated is safe 13// but not healthful, designed is both. An implementation that returned the same sample at every stage 14// would fail here and pass a suite that only ever looked at the final number. 15// license_tier: ORIGINAL expect_exit: 0 16 17import "nx_syscalls.nx" 18import "nx_gate_verdict.nx" 19import "nx_water_awg.nx" 20import "nx_water_quality.nx" 21import "nx_water_design.nx" 22 23func main() -> i64 { 24 gv_head("nx_water_design gate -- raw condensate to treated to remineralised, and the harvester chain" as *u8) 25 let ctr: *i64 = gv_ctr() 26 27 // --- raw atmospheric condensate: flat AND unsafe (Legionella risk) --- 28 let raw: *NxWaterSample = wd_raw_condensate() 29 gv_check("raw-condensate-tastes-flat-15" as *u8, wq_taste_score(raw) == 15, ctr) 30 gv_check("neg-control-raw-condensate-is-NOT-potable" as *u8, wq_is_potable(raw) == 0, ctr) 31 gv_check("neg-control-raw-condensate-refused-for-bacteria" as *u8, wq_safety_admit(raw) == WQ_REFUSED_BACTERIA, ctr) 32 33 // --- treatment (UV + filter) makes it potable but still flat --- 34 wd_treat(raw) 35 gv_check("treated-condensate-becomes-potable" as *u8, wq_is_potable(raw) == 1, ctr) 36 // SAFE IS NOT HEALTHFUL AND NOT TASTY. These two teeth are why the middle stage is a real stage 37 // rather than a relabelling of the final one. 38 gv_check("neg-control-treated-is-safe-but-NOT-healthful" as *u8, wq_is_healthful(raw) == 0, ctr) 39 gv_check("neg-control-treated-still-tastes-flat" as *u8, wq_taste_score(raw) == 15, ctr) 40 41 // --- the fully designed water: delicious + healthful + safe --- 42 let best: *NxWaterSample = wd_design_best_water() 43 gv_check("designed-water-scores-100-on-taste" as *u8, wq_taste_score(best) == 100, ctr) 44 gv_check("designed-water-lands-in-the-excellent-TDS-band" as *u8, wq_tds_taste_class(best.tds) == WQ_EXCELLENT, ctr) 45 gv_check("designed-water-is-potable" as *u8, wq_is_potable(best) == 1, ctr) 46 gv_check("designed-water-is-healthful" as *u8, wq_is_healthful(best) == 1, ctr) 47 48 // --- the measured claim: designing BEATS the raw input it started from --- 49 // Stated as a strict inequality against the actual starting sample rather than against a constant, 50 // so the claim cannot be satisfied by a model that simply hardcodes a good final score. 51 gv_check("designed-water-strictly-beats-raw-condensate-on-taste" as *u8, wq_taste_score(best) > wq_taste_score(raw), ctr) 52 53 // --- harvester choice + yield compose from the climate --- 54 gv_check("design-chain-recommends-condensation-when-humid" as *u8, wd_recommend_harvester(30, 70) == WA_CONDENSATION, ctr) 55 gv_check("design-chain-recommends-sorbent-when-desert" as *u8, wd_recommend_harvester(25, 20) == WA_SORBENT, ctr) 56 gv_check("design-chain-recommends-passive-capillary-when-moderate" as *u8, wd_recommend_harvester(20, 35) == WA_PASSIVE_CAP, ctr) 57 gv_check("design-chain-daily-yield-matches-the-awg-model" as *u8, wd_daily_yield_ml(30, 70, 5, 100) == 34560, ctr) 58 59 return gv_verdict("nx_water_design_test" as *u8, ctr, 60 "three distinguishable stages (raw refused, treated safe-not-healthful, designed both) plus the composed harvester and yield chain" as *u8) 61}