code wiki / _hdl_build / nx_ac_monitor_census.nx

nx_ac_monitor_census.nx source

↩ module page · 318 lines · 14553 B

1// nx_ac_monitor_census.nx -- EVIDENCE-BACKED SOTA gap map for the sovereign 2// AC/HVAC monitoring product ("Flume for AC", data-center-grade, hubless, 3// browser-first). The "census" leg of the operator's research/census/critic/ 4// adversary product. 5// 6// DISCIPLINE (per project-nishi-sensor-gap-census + feedback-census-evidence- 7// backed-not-symbol-presence): a capability is credited HAVE only with 8// EVIDENCE. This census goes beyond symbol-presence -- for the organs built in 9// this workstream it EXECUTES a live witness (runs the organ, checks a known 10// output); crediting a capability whose witness fails turns the census RED. 11// Existing-stack capabilities proven by a sibling gate are HAVE-CITED (named 12// gate, not re-run here). Unbuilt capabilities are GAP with their SOTA source. 13// It is ITSELF liar-killed: a negative-control witness (an asserted-false 14// output) MUST fail -- if the witness harness "passes" a false claim, RED. 15// 16// Prints the honest map + coverage permille + a verdict every run. GREEN = 17// the witness harness is trustworthy (all HAVE witnesses pass, neg-control 18// fails, coverage floor held) -- NOT "coverage is complete"; the GAP rows ARE 19// the remaining work. 20// 21// Sovereign nx_cc->nxasm (no gcc). CWD = nxc2 root. expect_exit: 0 22// license_tier: ORIGINAL 23// genealogy_id: project-hvac-efficiency-sclass-2026-06-23 24// + project-nishi-sensor-gap-census-2026-07-14 (census discipline) 25 26import "syscalls.nx" 27import "runtime.nx" 28import "nx_axioms.nx" 29import "nx_psychrometrics.nx" 30import "nx_ac_enthalpy_metrics.nx" 31import "nx_ac_sensor_verify.nx" 32import "nx_ac_fdd.nx" 33const K_MAGIC_25000: i64 = 25000 34const K_MAGIC_3170: i64 = 3170 35const K_MAGIC_20000: i64 = 20000 36const K_MAGIC_2339: i64 = 2339 37const K_MAGIC_55460: i64 = 55460 38const K_MAGIC_10800: i64 = 10800 39const K_MAGIC_3000: i64 = 3000 40const K_MAGIC_24000: i64 = 24000 41const K_MAGIC_35000: i64 = 35000 42const K_MAGIC_2701: i64 = 2701 43const K_MAGIC_1228: i64 = 1228 44const K_MAGIC_12000: i64 = 12000 45const K_MAGIC_1200: i64 = 1200 46const K_MAGIC_1500: i64 = 1500 47const K_MAGIC_27000: i64 = 27000 48const K_MAGIC_8333: i64 = 8333 49const K_MAGIC_2778: i64 = 2778 50const K_MAGIC_5556: i64 = 5556 51const K_MAGIC_13889: i64 = 13889 52const K_MAGIC_17000: i64 = 17000 53const K_MAGIC_5000: i64 = 5000 54const K_MAGIC_11000: i64 = 11000 55const K_MAGIC_15000: i64 = 15000 56const K_MAGIC_6000: i64 = 6000 57const K_MAGIC_2000: i64 = 2000 58const K_MAGIC_9999: i64 = 9999 59 60// ---- live witnesses (execute the organ, check a known output) ------ 61 62// physics floor: saturation pressure + enthalpy match NIST/ASHRAE exactly 63func w_psychro() -> i64 { 64 if nx_psy_psat_pa(K_MAGIC_25000) != K_MAGIC_3170 { return 0 } 65 if nx_psy_psat_pa(K_MAGIC_20000) != K_MAGIC_2339 { return 0 } 66 if nx_psy_enthalpy_from_rh(K_MAGIC_25000, 600, NX_PSY_P_ATM_PA) != K_MAGIC_55460 { return 0 } 67 return 1 68} 69 70// performance crown: COP / Carnot ceiling 71func w_metrics() -> i64 { 72 if nx_ac_cop_x100(K_MAGIC_10800, K_MAGIC_3000) != 360 { return 0 } 73 if nx_ac_carnot_cop_x100(K_MAGIC_24000, K_MAGIC_35000) != K_MAGIC_2701 { return 0 } 74 if nx_ac_eer_x100(360) != K_MAGIC_1228 { return 0 } 75 return 1 76} 77 78// efficiency drift vs baseline (the Flume bill-hook) 79func w_drift() -> i64 { 80 if nx_ac_efficiency_drift_permille(328, 400) != 180 { return 0 } 81 return 1 82} 83 84// reading-level liar-killer: healthy -> PLAUSIBLE, impossible -> IMPLAUSIBLE 85func w_liarkill() -> i64 { 86 let r: *AcReading = sys_mmap(256) as *AcReading 87 let o: *AcVerify = sys_mmap(128) as *AcVerify 88 r.mode = NX_HVAC_MODE_COOL 89 r.t_supply_mC = K_MAGIC_12000 90 r.rh_supply_pm = 900 91 r.t_return_mC = K_MAGIC_24000 92 r.rh_return_pm = 500 93 r.airflow_cfm = K_MAGIC_1200 94 r.rho_gm3 = K_MAGIC_1200 95 r.t_suction_mC = NX_ACV_ABSENT 96 r.t_sat_evap_mC = NX_ACV_ABSENT 97 r.t_liquid_mC = NX_ACV_ABSENT 98 r.t_sat_cond_mC = NX_ACV_ABSENT 99 r.t_outdoor_mC = NX_ACV_ABSENT 100 r.p_elec_w = K_MAGIC_3000 101 r.t_return_b_mC = NX_ACV_ABSENT 102 r.return_a_src = 1 103 r.return_b_src = 0 104 r.return_tol_mC = 500 105 nx_acv_verify(r, o) 106 if o.verdict != NX_ACV_PLAUSIBLE { return 0 } 107 r.rh_return_pm = K_MAGIC_1500 108 nx_acv_verify(r, o) 109 if o.verdict != NX_ACV_IMPLAUSIBLE_PHYSICS { return 0 } 110 return 1 111} 112 113// cross-sensor independence: a disagreeing SAME-SOURCE echo is NOT a conflict 114func w_independence() -> i64 { 115 let r: *AcReading = sys_mmap(256) as *AcReading 116 let o: *AcVerify = sys_mmap(128) as *AcVerify 117 r.mode = NX_HVAC_MODE_COOL 118 r.t_supply_mC = K_MAGIC_12000 119 r.rh_supply_pm = 900 120 r.t_return_mC = K_MAGIC_24000 121 r.rh_return_pm = 500 122 r.airflow_cfm = K_MAGIC_1200 123 r.rho_gm3 = K_MAGIC_1200 124 r.t_suction_mC = NX_ACV_ABSENT 125 r.t_sat_evap_mC = NX_ACV_ABSENT 126 r.t_liquid_mC = NX_ACV_ABSENT 127 r.t_sat_cond_mC = NX_ACV_ABSENT 128 r.t_outdoor_mC = NX_ACV_ABSENT 129 r.p_elec_w = K_MAGIC_3000 130 r.t_return_b_mC = K_MAGIC_27000 131 r.return_a_src = 1 132 r.return_b_src = 1 133 r.return_tol_mC = 500 134 nx_acv_verify(r, o) 135 if o.verdict != NX_ACV_PLAUSIBLE { return 0 } 136 if o.corroborated != -2 { return 0 } 137 return 1 138} 139 140// FDD: charge / condenser / airflow / freeze faults classify correctly 141func w_fdd() -> i64 { 142 let rd: *FddInput = sys_mmap(128) as *FddInput 143 let th: *FddThresh = sys_mmap(128) as *FddThresh 144 let o: *FddOut = sys_mmap(64) as *FddOut 145 th.target_superheat_mC = K_MAGIC_8333 146 th.superheat_band_mC = K_MAGIC_2778 147 th.target_subcool_mC = K_MAGIC_5556 148 th.subcool_band_mC = K_MAGIC_2778 149 th.split_ceiling_mC = K_MAGIC_13889 150 th.cond_over_ambient_ceiling_mC = K_MAGIC_25000 151 th.cfm_per_ton_floor = 350 152 th.max_cph_x10 = 35 153 th.freeze_suction_sat_mC = 0 154 155 rd.superheat_mC = K_MAGIC_17000 156 rd.subcool_mC = K_MAGIC_1500 157 rd.suction_sat_mC = K_MAGIC_5000 158 rd.evap_split_mC = K_MAGIC_11000 159 rd.cond_over_ambient_mC = K_MAGIC_15000 160 rd.cfm_per_ton = 400 161 rd.cph_x10 = 20 162 nx_ac_fdd_analyze(rd, th, o) 163 if o.verdict != NX_FDD_UNDERCHARGE { return 0 } 164 165 rd.superheat_mC = K_MAGIC_6000 166 rd.subcool_mC = K_MAGIC_12000 167 nx_ac_fdd_analyze(rd, th, o) 168 if o.verdict != NX_FDD_OVERCHARGE { return 0 } 169 170 rd.superheat_mC = K_MAGIC_8333 171 rd.subcool_mC = K_MAGIC_5556 172 rd.suction_sat_mC = -K_MAGIC_2000 173 nx_ac_fdd_analyze(rd, th, o) 174 if o.verdict != NX_FDD_FROZEN_COIL { return 0 } 175 return 1 176} 177 178// negative control: an asserted-FALSE output must NOT pass (proves the 179// witness harness discriminates -- can't rubber-stamp a false HAVE). 180func w_negctl() -> i64 { 181 if nx_psy_psat_pa(K_MAGIC_25000) == K_MAGIC_9999 { return 1 } 182 return 0 183} 184 185// ---- row emitter --------------------------------------------------- 186func row(status: *u8, cap: *u8, ev: *u8) -> i64 { 187 print(status) 188 print(" " as *u8) 189 print(cap) 190 print("\n " as *u8) 191 print(ev) 192 print("\n" as *u8) 193 return 0 194} 195 196func main() -> i64 { 197 let wpsy: i64 = w_psychro() 198 let wmet: i64 = w_metrics() 199 let wdri: i64 = w_drift() 200 let wliar: i64 = w_liarkill() 201 let wind: i64 = w_independence() 202 let wfdd: i64 = w_fdd() 203 let wneg: i64 = w_negctl() 204 205 print("=============================================================\n" as *u8) 206 print(" SOVEREIGN AC/HVAC MONITOR -- SOTA CAPABILITY CENSUS\n" as *u8) 207 print(" [HAVE]=executed-witness-here [CITE]=sibling-gate [PART]=partial [GAP]=named-SOTA-frontier\n" as *u8) 208 print("=============================================================\n" as *u8) 209 210 var have: i64 = 0 211 var cite: i64 = 0 212 var part: i64 = 0 213 var gap: i64 = 0 214 215 print("\n-- PHYSICS FLOOR ------------------------------------------\n" as *u8) 216 if wpsy == 1 { have = have + 1 217 row("[HAVE]" as *u8, "Psychrometrics (Psat/W/enthalpy/dewpoint), no-float" as *u8, "nx_psychrometrics: psat(25C)=3170Pa, h(25C/60%)=55460 J/kg == NIST/ASHRAE" as *u8) 218 } else { gap = gap + 1 219 row("[GAP ]" as *u8, "Psychrometrics" as *u8, "witness FAILED" as *u8) } 220 if wmet == 1 { have = have + 1 221 row("[HAVE]" as *u8, "Delivered capacity / COP / EER (air-side enthalpy method)" as *u8, "nx_ac_enthalpy_metrics: COP=3.60, EER=12.28, DC-grade dT*airflow*dh" as *u8) 222 } else { gap = gap + 1 223 row("[GAP ]" as *u8, "Delivered capacity / COP" as *u8, "witness FAILED" as *u8) } 224 if wmet == 1 { have = have + 1 225 row("[HAVE]" as *u8, "Carnot COP ceiling (hard physical bound)" as *u8, "nx_ac_carnot_cop_x100(24C,35C)=27.01 -- caps any claimed COP" as *u8) 226 } else { gap = gap + 1 227 row("[GAP ]" as *u8, "Carnot ceiling" as *u8, "witness FAILED" as *u8) } 228 229 print("\n-- TRUST / VERIFICATION (the differentiator) --------------\n" as *u8) 230 if wliar == 1 { have = have + 1 231 row("[HAVE]" as *u8, "Reading-level LIAR-KILLER (physics-invariant rejection)" as *u8, "nx_ac_sensor_verify: impossible reading -> IMPLAUSIBLE, never trusted" as *u8) 232 } else { gap = gap + 1 233 row("[GAP ]" as *u8, "Reading-level liar-killer" as *u8, "witness FAILED" as *u8) } 234 if wind == 1 { have = have + 1 235 row("[HAVE]" as *u8, "Cross-sensor independence (echo != corroboration)" as *u8, "nx_ac_sensor_verify: same-source echo -> not corroborated (crossval discipline)" as *u8) 236 } else { gap = gap + 1 237 row("[GAP ]" as *u8, "Cross-sensor independence" as *u8, "witness FAILED" as *u8) } 238 if wdri == 1 { have = have + 1 239 row("[HAVE]" as *u8, "Efficiency drift vs own baseline (the bill-hook)" as *u8, "nx_ac_enthalpy_metrics: drift(3.28 vs 4.00)=180 permille (18% degraded)" as *u8) 240 } else { gap = gap + 1 241 row("[GAP ]" as *u8, "Efficiency drift" as *u8, "witness FAILED" as *u8) } 242 part = part + 1 243 row("[PART]" as *u8, "External-comp: NIST/ASHRAE-grounded thresholds" as *u8, "KATs match NIST WebBook + Title 24; nx_research_verify evidence-ledger pending" as *u8) 244 245 print("\n-- FAULT DETECTION & DIAGNOSIS (NIST/APAR-grounded) -------\n" as *u8) 246 if wfdd == 1 { have = have + 1 247 row("[HAVE]" as *u8, "Refrigerant charge: undercharge / overcharge / liquid restriction" as *u8, "nx_ac_fdd: superheat+subcool rules (NISTIR 7350), Title 24 thresholds" as *u8) 248 } else { gap = gap + 1 249 row("[GAP ]" as *u8, "Refrigerant charge FDD" as *u8, "witness FAILED" as *u8) } 250 if wfdd == 1 { have = have + 1 251 row("[HAVE]" as *u8, "Fouled condenser / low airflow / frozen coil" as *u8, "nx_ac_fdd: condensing-over-ambient, evap split, suction-sat<0 (freeze)" as *u8) 252 } else { gap = gap + 1 253 row("[GAP ]" as *u8, "Coil/airflow FDD" as *u8, "witness FAILED" as *u8) } 254 cite = cite + 1 255 row("[CITE]" as *u8, "Short-cycling / degraded-capacity / poor-tracking" as *u8, "nx_hvac_efficiency (gate nx_hvac_efficiency_test GREEN)" as *u8) 256 gap = gap + 1 257 row("[GAP ]" as *u8, "Capacitor/compressor EOL from inrush-current trend" as *u8, "SOTA: #1 residential AC repair; needs start-current trend organ" as *u8) 258 gap = gap + 1 259 row("[GAP ]" as *u8, "Condensate drain clog detection" as *u8, "SOTA gap: today only a $15 float switch; needs pan-moisture/flow organ" as *u8) 260 gap = gap + 1 261 row("[GAP ]" as *u8, "Benchmark FDD vs labeled fault dataset" as *u8, "datasets identified (NIST HP/AC, LBNL 10.25984/1881324, RP-1043); harness TODO" as *u8) 262 263 print("\n-- SENSING / INGEST ---------------------------------------\n" as *u8) 264 cite = cite + 1 265 row("[CITE]" as *u8, "Device discovery / classify / anchor (multi-vendor)" as *u8, "nx_iot_discover (gate nx_iot_discover_test GREEN)" as *u8) 266 part = part + 1 267 row("[PART]" as *u8, "Electrical CT power/current ingest (Emporia/Sense-class)" as *u8, "architecture defined (HVAC R3); adapter model-specific, not built" as *u8) 268 gap = gap + 1 269 row("[GAP ]" as *u8, "Energy disaggregation (recognize AC in whole-home power)" as *u8, "SOTA-hard (Sense misses ACs); NILM organ TODO" as *u8) 270 271 print("\n-- ALERTING / UX / FLEET ----------------------------------\n" as *u8) 272 part = part + 1 273 row("[PART]" as *u8, "Hubless browser monitor UI (mobile + desktop)" as *u8, "building this session; zero/last-mile-JS, no mandatory hub" as *u8) 274 part = part + 1 275 row("[PART]" as *u8, "Plain-language alerts + bill impact" as *u8, "drift number present; phrasing + $ estimate UX pending" as *u8) 276 cite = cite + 1 277 row("[CITE]" as *u8, "Zero-JS control/monitor page (cross-browser)" as *u8, "nx_iot_control_page / nx_iot_dashboard (gates GREEN)" as *u8) 278 cite = cite + 1 279 row("[CITE]" as *u8, "Watchdog / self-heal reconnect (kills the blink)" as *u8, "nx_iot_watchdog (gate nx_iot_watchdog_test GREEN)" as *u8) 280 cite = cite + 1 281 row("[CITE]" as *u8, "Multi-tenant per-house (HR realms) + hubless LAN-resilient" as *u8, "nx_iot_hub_tenant (gate nx_iot_hub_tenant_gate GREEN); no cloud at runtime" as *u8) 282 283 // ---- coverage summary ---------------------------------------- 284 let total: i64 = have + cite + part + gap 285 let covered: i64 = have + cite 286 print("\n=============================================================\n" as *u8) 287 print(" HAVE(executed) " as *u8); print_i64(have) 288 print(" CITE(gate) " as *u8); print_i64(cite) 289 print(" PART " as *u8); print_i64(part) 290 print(" GAP " as *u8); print_i64(gap) 291 print(" / " as *u8); print_i64(total) 292 print("\n coverage(have+cite) = " as *u8) 293 if total > 0 { print_i64((covered * 1000) / total) } else { print_i64(0) } 294 print(" permille\n" as *u8) 295 296 // ---- verdict: is the census's witness harness TRUSTWORTHY? ---- 297 // GREEN iff all executed-HAVE witnesses passed, the neg-control FAILED, 298 // and coverage did not fall below the floor. RED means a claimed HAVE 299 // could not be reproduced here (never a fabricated green). 300 var trust: i64 = 1 301 if wpsy != 1 { trust = 0 } 302 if wmet != 1 { trust = 0 } 303 if wdri != 1 { trust = 0 } 304 if wliar != 1 { trust = 0 } 305 if wind != 1 { trust = 0 } 306 if wfdd != 1 { trust = 0 } 307 if wneg != 0 { trust = 0 } // neg-control MUST fail 308 if have < 8 { trust = 0 } // no-backslide floor on executed HAVEs 309 310 if trust == 1 { 311 print(" VERDICT: GREEN -- witness harness trustworthy; GAP rows = the work.\n" as *u8) 312 print("=============================================================\n" as *u8) 313 return 0 314 } 315 print(" VERDICT: RED -- a HAVE witness failed or neg-control passed.\n" as *u8) 316 print("=============================================================\n" as *u8) 317 return 1 318}