omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / seed / ng / physics / gate_physics.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note seed/ng/physics/gate_physics.om |
| 3 | note Standalone Pure Seeded OM-2 Verification Gate for Sovereign Intelligence 2.0 Stage 3 |
| 4 | note (Pillar 3: Physics-Typed Computing — Pareto Bank + WattCBF <-> fabHotSwap + Chain Error). |
| 5 | note |
| 6 | note Strictly DRY_RUN_READONLY (hw_writes == 0): zero sysfs/GPU/UEFI/SPI writes. |
| 7 | note |
| 8 | note Compose & build with pinned seeded omc (SHA-256 85b84c6d...): |
| 9 | note cat si/directives/om2.om \ |
| 10 | note apps/omega-wattd/watt_sense.om \ |
| 11 | note apps/omega-wattd/watt_cbf.om \ |
| 12 | note seed/ng/target/target_desc.om \ |
| 13 | note seed/ng/target/isel.om \ |
| 14 | note seed/ng/target/sm121_pe.om \ |
| 15 | note seed/ng/target/fabric.om \ |
| 16 | note seed/ng/physics/pareto_bank.om \ |
| 17 | note seed/ng/physics/phys_solver.om \ |
| 18 | note seed/ng/physics/gate_physics.om | seed/out/omc > /tmp/gate_physics |
| 19 | |
| 20 | const PG_SEM_FRAME ulong 9001 |
| 21 | const PG_SEM_TRAP14 ulong 9002 |
| 22 | const PG_SEM_TRAP14_ONLY ulong 9003 |
| 23 | const PG_SEM_ERR_ONLY ulong 9004 |
| 24 | const PG_SEM_POWER_CAP ulong 9005 |
| 25 | |
| 26 | global pg_pass ulong 1 |
| 27 | global pg_neg ulong 1 |
| 28 | |
| 29 | text pg_hdr "=== OMEGA NG STAGE 3 (PHYSICS-TYPED COMPUTING) VERIFICATION GATE ===\n" |
| 30 | text pg_p "PASS " |
| 31 | text pg_f "FAIL " |
| 32 | text pg_nl "\n" |
| 33 | |
| 34 | text pg_t1 "T1_pareto_bank_proof_gate" |
| 35 | text pg_t1_d " admitted=9 frontier=" |
| 36 | text pg_t1_d2 " unproved_refused=" |
| 37 | |
| 38 | text pg_t2 "T2_thermal_ramp_60c_to_84c_16p6ms" |
| 39 | text pg_t2_d " ramp=BF16->FP8->NVFP4->CPU_X925->CPU_A725(SLIP) swaps=" |
| 40 | text pg_t2_d2 " alarms=" |
| 41 | text pg_t2_d3 " ty_bf16=" |
| 42 | text pg_t2_d4 " ty_a725=" |
| 43 | |
| 44 | text pg_t3 "T3_trap14_90w_clamped_and_refused" |
| 45 | text pg_t3_d " cbf_90w_gpu_mw=62640 cbf_h=668 solo_90w=REFUSED pair_picked_mw=50000" |
| 46 | |
| 47 | text pg_t4 "T4_err_bound_inviolable" |
| 48 | text pg_t4_d " exact_picked_prec=CPU_X925 err=0 loose_only_tol10=REFUSED" |
| 49 | |
| 50 | text pg_t5 "T5_hard_deadline_vs_soft_alarm" |
| 51 | text pg_t5_d " hard_84c=PHYS_ERR_HARD_DEADLINE fab_unchanged=1 soft_84c=ALARM_DEADLINE_SLIP slip_us=5400" |
| 52 | |
| 53 | text pg_t6 "T6_chain_error_composition" |
| 54 | text pg_t6_d " add_100_pass=1 add_105_refused=1 amp_pass=1 amp_ovf_refused=1 exact_refused=1" |
| 55 | |
| 56 | text pg_t7 "T7_oir_v2_wire_contract_parser" |
| 57 | text pg_t7_d " valid_28b=OK bad_res=REFUSED bad_exact_err=REFUSED bad_hard_dl0=REFUSED bad_tier=REFUSED" |
| 58 | |
| 59 | text pg_t8 "T8_overtemp_and_bad_policy_fail_closed" |
| 60 | text pg_t8_d " overtemp_die=FAIL_CLOSED overtemp_sink=FAIL_CLOSED neg_budget=FAIL_CLOSED fan=100" |
| 61 | |
| 62 | text pg_t9 "T9_contract_power_cap_and_arboris_shortcut" |
| 63 | text pg_t9_d " cap_25w_picked=ARBORIS_SHORTCUT mode=CRYSTALLIZED ty_shortcut=" |
| 64 | |
| 65 | text pg_t10 "T10_readonly_actuator_and_telemetry" |
| 66 | text pg_t10_d " actuator_mode=DRY_RUN_READONLY hw_writes=0 total_dispatches=" |
| 67 | text pg_t10_d2 " total_refusals=" |
| 68 | |
| 69 | text pg_sum_ok "GATE_PHYSICS PASS checks=" |
| 70 | text pg_sum_fail "GATE_PHYSICS FAIL checks=" |
| 71 | text pg_sum_of "/10 neg_controls=" |
| 72 | text pg_sum_tail " hw_writes=0\n" |
| 73 | |
| 74 | fn pg_add_neg n ulong to void |
| 75 | put pg_neg 0 add get pg_neg 0 n |
| 76 | end |
| 77 | |
| 78 | fn pg_reg sem_id ulong tid ulong prec ulong pw long lat long eb long to ulong |
| 79 | uj = pb_calc_joules_uj pw lat |
| 80 | cptr = add 65536 mul prec 4096 |
| 81 | pb_stage_id sem_id tid prec PB_PROOF_REQUIRED cptr |
| 82 | pb_stage_phys pw lat uj eb 1000000 |
| 83 | ret pb_commit |
| 84 | end |
| 85 | |
| 86 | fn pg_put_u64_rec dst edit uchar 28 off ulong v ulong to void |
| 87 | for k ulong 8 |
| 88 | b = uchar and shr v mul k 8 255 |
| 89 | put dst add off k b |
| 90 | end |
| 91 | end |
| 92 | |
| 93 | fn pg_enc_v2_hdr dst edit uchar 28 pur ulong tier ulong hdl ulong res ulong to void |
| 94 | put dst 0 uchar and pur 255 |
| 95 | put dst 1 uchar and tier 255 |
| 96 | put dst 2 uchar and hdl 255 |
| 97 | put dst 3 uchar and res 255 |
| 98 | end |
| 99 | |
| 100 | fn pg_enc_v2_vals dst edit uchar 28 eb ulong dl ulong pwr ulong to void |
| 101 | pg_put_u64_rec dst 4 eb |
| 102 | pg_put_u64_rec dst 12 dl |
| 103 | pg_put_u64_rec dst 20 pwr |
| 104 | end |
| 105 | |
| 106 | note T1: Pareto Realization Bank across all 9 profiles + strict proof_mask == 7 negative controls |
| 107 | fn pg_t1_pareto_bank to bool |
| 108 | ok = true |
| 109 | pb_init |
| 110 | note Register all 9 named profiles on PG_SEM_FRAME (with distinct power/latency/error trade-offs) |
| 111 | if ne pg_reg PG_SEM_FRAME TID_SM121 PB_PREC_FP64 76000 9000 0 PB_OK |
| 112 | ok = false |
| 113 | end |
| 114 | if ne pg_reg PG_SEM_FRAME TID_SM121 PB_PREC_FP32 72000 5500 1 PB_OK |
| 115 | ok = false |
| 116 | end |
| 117 | if ne pg_reg PG_SEM_FRAME TID_SM121 PB_PREC_BF16 68000 2500 10 PB_OK |
| 118 | ok = false |
| 119 | end |
| 120 | if ne pg_reg PG_SEM_FRAME TID_SM121 PB_PREC_FP8 48000 4000 40 PB_OK |
| 121 | ok = false |
| 122 | end |
| 123 | if ne pg_reg PG_SEM_FRAME TID_SM121 PB_PREC_NVFP4 26000 6500 100 PB_OK |
| 124 | ok = false |
| 125 | end |
| 126 | if ne pg_reg PG_SEM_FRAME TID_X925 PB_PREC_CPU_X925 18000 13000 0 PB_OK |
| 127 | ok = false |
| 128 | end |
| 129 | if ne pg_reg PG_SEM_FRAME TID_A725 PB_PREC_CPU_A725 5000 22000 0 PB_OK |
| 130 | ok = false |
| 131 | end |
| 132 | if ne pg_reg PG_SEM_FRAME TID_SM121 PB_PREC_SM121 78000 1800 50 PB_OK |
| 133 | ok = false |
| 134 | end |
| 135 | if ne pg_reg PG_SEM_FRAME TID_A725 PB_PREC_ARBORIS_SHORTCUT 8000 500 250 PB_OK |
| 136 | ok = false |
| 137 | end |
| 138 | if ne pb_count_for_sem PG_SEM_FRAME 9 |
| 139 | ok = false |
| 140 | end |
| 141 | note Negative controls: proof_mask != 7 MUST be refused (0, 3, 5, 6, 8, 15) |
| 142 | pb_stage_phys 10000 1000 10000 0 1000000 |
| 143 | pb_stage_id PG_SEM_FRAME TID_X925 PB_PREC_CPU_X925 0 9999 |
| 144 | if ne pb_commit PB_ERR_PROOF_MASK |
| 145 | ok = false |
| 146 | end |
| 147 | pb_stage_id PG_SEM_FRAME TID_X925 PB_PREC_CPU_X925 3 9999 |
| 148 | if ne pb_commit PB_ERR_PROOF_MASK |
| 149 | ok = false |
| 150 | end |
| 151 | pb_stage_id PG_SEM_FRAME TID_X925 PB_PREC_CPU_X925 5 9999 |
| 152 | if ne pb_commit PB_ERR_PROOF_MASK |
| 153 | ok = false |
| 154 | end |
| 155 | pb_stage_id PG_SEM_FRAME TID_X925 PB_PREC_CPU_X925 6 9999 |
| 156 | if ne pb_commit PB_ERR_PROOF_MASK |
| 157 | ok = false |
| 158 | end |
| 159 | pb_stage_id PG_SEM_FRAME TID_X925 PB_PREC_CPU_X925 8 9999 |
| 160 | if ne pb_commit PB_ERR_PROOF_MASK |
| 161 | ok = false |
| 162 | end |
| 163 | pb_stage_id PG_SEM_FRAME TID_X925 PB_PREC_CPU_X925 15 9999 |
| 164 | if ne pb_commit PB_ERR_PROOF_MASK |
| 165 | ok = false |
| 166 | end |
| 167 | pg_add_neg 1 |
| 168 | note Negative controls: zero code_ptr and invalid latency/power refused |
| 169 | pb_stage_id PG_SEM_FRAME TID_X925 PB_PREC_CPU_X925 7 0 |
| 170 | if ne pb_commit PB_ERR_BAD_PTR |
| 171 | ok = false |
| 172 | end |
| 173 | pb_stage_id PG_SEM_FRAME TID_X925 PB_PREC_CPU_X925 7 9999 |
| 174 | pb_stage_phys -1 1000 1000 0 1000000 |
| 175 | if ne pb_commit PB_ERR_BAD_METRICS |
| 176 | ok = false |
| 177 | end |
| 178 | pb_stage_phys 10000 0 0 0 1000000 |
| 179 | if ne pb_commit PB_ERR_BAD_METRICS |
| 180 | ok = false |
| 181 | end |
| 182 | pg_add_neg 1 |
| 183 | if ne pb_count_for_sem PG_SEM_FRAME 9 |
| 184 | ok = false |
| 185 | end |
| 186 | if ne get pb_rej_proof 0 6 |
| 187 | ok = false |
| 188 | end |
| 189 | fc = pb_frontier_count PG_SEM_FRAME |
| 190 | if eq fc 0 |
| 191 | ok = false |
| 192 | end |
| 193 | if ok |
| 194 | wd_puts pg_p |
| 195 | wd_puts pg_t1 |
| 196 | wd_puts pg_t1_d |
| 197 | wd_put_u64 fc |
| 198 | wd_puts pg_t1_d2 |
| 199 | wd_put_u64 get pb_rej_proof 0 |
| 200 | wd_puts pg_nl |
| 201 | else |
| 202 | wd_puts pg_f |
| 203 | wd_puts pg_t1 |
| 204 | wd_puts pg_nl |
| 205 | end |
| 206 | ret ok |
| 207 | end |
| 208 | |
| 209 | note T2: Dynamic precision scaling across 60C -> 78C -> 81C -> 83C -> 84C thermal ramp & 16.6 ms budget |
| 210 | fn pg_t2_thermal_ramp to bool |
| 211 | ok = true |
| 212 | fabInit |
| 213 | ps_init |
| 214 | ps_set_baseline 15000 5000 40 |
| 215 | note Contract: @pure @tol 100 @deadline 16600 (soft) @power 0 |
| 216 | note Note: ARBORIS_SHORTCUT has err=250 > 100, SM121 raw has pw=78000 (pruned by @power 70000) |
| 217 | ps_set_contract 1 long PHYS_TIER_TOL 0 100 16600 70000 |
| 218 | pol = new WattPolicy 110000 80000 85000 5 |
| 219 | st = new WattThermal 60000 54000 25000 |
| 220 | note Step 1: 60.0 C (cool) -> picks BF16 (68 W, 2500 us <= 16600 us, err=10) |
| 221 | rc = ps_dispatch PG_SEM_FRAME 0 st pol |
| 222 | ty_bf16 = get ps_tel PS_TEL_TURING_YIELD |
| 223 | if ne rc PHYS_OK |
| 224 | ok = false |
| 225 | end |
| 226 | if ne get ps_tel PS_TEL_PREC long PB_PREC_BF16 |
| 227 | ok = false |
| 228 | end |
| 229 | if ne get fabTid 0 TID_SM121 |
| 230 | ok = false |
| 231 | end |
| 232 | if ne get fabVer 0 1 |
| 233 | ok = false |
| 234 | end |
| 235 | if lt get ps_tel PS_TEL_BARRIER_H 0 |
| 236 | ok = false |
| 237 | end |
| 238 | if le ty_bf16 0 |
| 239 | ok = false |
| 240 | end |
| 241 | note Step 2: 78.0 C (warm, P_safe_gpu=50640 mW) -> prunes BF16 (68 W), picks FP8 (48 W, 4000 us) |
| 242 | put st t_die 78000 |
| 243 | put st t_sink 76000 |
| 244 | rc = ps_dispatch PG_SEM_FRAME 0 st pol |
| 245 | if ne rc PHYS_OK |
| 246 | ok = false |
| 247 | end |
| 248 | if ne get ps_tel PS_TEL_PREC long PB_PREC_FP8 |
| 249 | ok = false |
| 250 | end |
| 251 | if ne get fabVer 0 2 |
| 252 | ok = false |
| 253 | end |
| 254 | if lt get ps_tel PS_TEL_BARRIER_H 0 |
| 255 | ok = false |
| 256 | end |
| 257 | note Step 3: 81.0 C (hot, P_safe_gpu=28640 mW) -> prunes FP8 (48 W), picks NVFP4 (26 W, 6500 us) |
| 258 | put st t_die 81000 |
| 259 | put st t_sink 79500 |
| 260 | rc = ps_dispatch PG_SEM_FRAME 0 st pol |
| 261 | if ne rc PHYS_OK |
| 262 | ok = false |
| 263 | end |
| 264 | if ne get ps_tel PS_TEL_PREC long PB_PREC_NVFP4 |
| 265 | ok = false |
| 266 | end |
| 267 | if ne get fabVer 0 3 |
| 268 | ok = false |
| 269 | end |
| 270 | if lt get ps_tel PS_TEL_BARRIER_H 0 |
| 271 | ok = false |
| 272 | end |
| 273 | note Step 4: 83.0 C (very hot, P_safe_gpu=13320 mW) -> migrates off GPU to CPU_X925 (18 W CPU, 13000 us <= 16600) |
| 274 | put st t_die 83000 |
| 275 | put st t_sink 82000 |
| 276 | rc = ps_dispatch PG_SEM_FRAME 0 st pol |
| 277 | if ne rc PHYS_OK |
| 278 | ok = false |
| 279 | end |
| 280 | if ne get ps_tel PS_TEL_PREC long PB_PREC_CPU_X925 |
| 281 | ok = false |
| 282 | end |
| 283 | if ne get fabTid 0 TID_X925 |
| 284 | ok = false |
| 285 | end |
| 286 | if ne get fabMode 0 FAB_MODE_CPU_NATIVE |
| 287 | ok = false |
| 288 | end |
| 289 | if ne get fabVer 0 4 |
| 290 | ok = false |
| 291 | end |
| 292 | if lt get ps_tel PS_TEL_BARRIER_H 0 |
| 293 | ok = false |
| 294 | end |
| 295 | note Step 5: 84.0 C (ceiling edge, P_safe_cpu_extra=13200 mW) -> prunes X925 (18 W), picks CPU_A725 (5 W, 22000 us) + ALARM_DEADLINE_SLIP! |
| 296 | put st t_die 84000 |
| 297 | put st t_sink 84000 |
| 298 | rc = ps_dispatch PG_SEM_FRAME 0 st pol |
| 299 | ty_a725 = get ps_tel PS_TEL_TURING_YIELD |
| 300 | if ne rc PHYS_OK_DEADLINE_SLIP |
| 301 | ok = false |
| 302 | end |
| 303 | if ne get ps_tel PS_TEL_PREC long PB_PREC_CPU_A725 |
| 304 | ok = false |
| 305 | end |
| 306 | if ne get ps_tel PS_TEL_ALARM_CODE long PHYS_ALARM_DEADLINE_SLIP |
| 307 | ok = false |
| 308 | end |
| 309 | if ne get ps_tel PS_TEL_DL_MARGIN_US -5400 |
| 310 | ok = false |
| 311 | end |
| 312 | if ne get fabTid 0 TID_A725 |
| 313 | ok = false |
| 314 | end |
| 315 | if ne get fabVer 0 5 |
| 316 | ok = false |
| 317 | end |
| 318 | if lt get ps_tel PS_TEL_BARRIER_H 0 |
| 319 | ok = false |
| 320 | end |
| 321 | if le ty_a725 0 |
| 322 | ok = false |
| 323 | end |
| 324 | if ok |
| 325 | wd_puts pg_p |
| 326 | wd_puts pg_t2 |
| 327 | wd_puts pg_t2_d |
| 328 | wd_put_u64 get fabVer 0 |
| 329 | wd_puts pg_t2_d2 |
| 330 | wd_put_u64 get ps_alm_count 0 |
| 331 | wd_puts pg_t2_d3 |
| 332 | wd_put_i64 ty_bf16 |
| 333 | wd_puts pg_t2_d4 |
| 334 | wd_put_i64 ty_a725 |
| 335 | wd_puts pg_nl |
| 336 | else |
| 337 | wd_puts pg_f |
| 338 | wd_puts pg_t2 |
| 339 | wd_puts pg_nl |
| 340 | end |
| 341 | ret ok |
| 342 | end |
| 343 | |
| 344 | fn pg_t3_check_cbf st90 view WattThermal pol90 view WattPolicy to bool |
| 345 | pr90 = new WattProp 90000 15000 5000 40 |
| 346 | cmd90 = new WattCmd 0 0 0 0 0 0 |
| 347 | wc_cbf_filter st90 pol90 pr90 cmd90 |
| 348 | dt90 = wc_next_die_delta st90 get cmd90 p_gpu get cmd90 p_cpu get cmd90 p_unc |
| 349 | h90 = wc_barrier_h 78000 76000 2 dt90 |
| 350 | if ne get cmd90 p_gpu 62640 |
| 351 | ret false |
| 352 | end |
| 353 | if ne h90 668 |
| 354 | ret false |
| 355 | end |
| 356 | if ne get cmd90 fan_pct 100 |
| 357 | ret false |
| 358 | end |
| 359 | ret true |
| 360 | end |
| 361 | |
| 362 | note T3: Trap-14 90 W spike clamped by WattCBF AND refused by phys_solver |
| 363 | fn pg_t3_trap14_90w to bool |
| 364 | ok = true |
| 365 | st90 = new WattThermal 76000 66000 25000 |
| 366 | pol90 = new WattPolicy 110000 80000 78000 2 |
| 367 | if not pg_t3_check_cbf st90 pol90 |
| 368 | ok = false |
| 369 | end |
| 370 | note Register a 90 W Trap-14 GPU realization on PG_SEM_TRAP14_ONLY (solo) and paired with safe 50 W on PG_SEM_TRAP14 |
| 371 | if ne pg_reg PG_SEM_TRAP14_ONLY TID_SM121 PB_PREC_SM121 90000 500 0 PB_OK |
| 372 | ok = false |
| 373 | end |
| 374 | if ne pg_reg PG_SEM_TRAP14 TID_SM121 PB_PREC_SM121 90000 500 0 PB_OK |
| 375 | ok = false |
| 376 | end |
| 377 | if ne pg_reg PG_SEM_TRAP14 TID_SM121 PB_PREC_FP8 50000 3000 0 PB_OK |
| 378 | ok = false |
| 379 | end |
| 380 | ps_set_baseline 15000 5000 40 |
| 381 | ps_set_contract 1 long PHYS_TIER_EXACT 0 0 16600 0 |
| 382 | ver_before = get fabVer 1 |
| 383 | rc = ps_dispatch PG_SEM_TRAP14_ONLY 1 st90 pol90 |
| 384 | if ne rc PHYS_ERR_WATTCBF_UNSAFE |
| 385 | ok = false |
| 386 | end |
| 387 | if ne get fabVer 1 ver_before |
| 388 | ok = false |
| 389 | end |
| 390 | pg_add_neg 1 |
| 391 | rc = ps_dispatch PG_SEM_TRAP14 1 st90 pol90 |
| 392 | if ne rc PHYS_OK |
| 393 | ok = false |
| 394 | end |
| 395 | if ne get ps_tel PS_TEL_POWER_MW 50000 |
| 396 | ok = false |
| 397 | end |
| 398 | if ne get fabVer 1 add ver_before 1 |
| 399 | ok = false |
| 400 | end |
| 401 | if lt get ps_tel PS_TEL_BARRIER_H 0 |
| 402 | ok = false |
| 403 | end |
| 404 | if ok |
| 405 | wd_puts pg_p |
| 406 | wd_puts pg_t3 |
| 407 | wd_puts pg_t3_d |
| 408 | wd_puts pg_nl |
| 409 | else |
| 410 | wd_puts pg_f |
| 411 | wd_puts pg_t3 |
| 412 | wd_puts pg_nl |
| 413 | end |
| 414 | ret ok |
| 415 | end |
| 416 | |
| 417 | note T4: Declared @err bound is NEVER silently broken |
| 418 | fn pg_t4_err_bound to bool |
| 419 | ok = true |
| 420 | st = new WattThermal 83000 82000 25000 |
| 421 | pol = new WattPolicy 110000 80000 85000 5 |
| 422 | ps_set_baseline 15000 5000 40 |
| 423 | note At 83 C under @exact, NVFP4/FP8/BF16/ARBORIS are ineligible; picks exact CPU_X925 (err=0) |
| 424 | ps_set_contract 1 long PHYS_TIER_EXACT 0 0 16600 0 |
| 425 | rc_ex = ps_dispatch PG_SEM_FRAME 2 st pol |
| 426 | if or ne rc_ex PHYS_OK or ne get ps_tel PS_TEL_ERR_BOUND 0 ne get ps_tel PS_TEL_PREC long PB_PREC_CPU_X925 |
| 427 | ok = false |
| 428 | end |
| 429 | note Negative control: PG_SEM_ERR_ONLY holds only err=50 and err=100; under @tol 10 MUST refuse! |
| 430 | if ne pg_reg PG_SEM_ERR_ONLY TID_SM121 PB_PREC_FP8 30000 1000 50 PB_OK |
| 431 | ok = false |
| 432 | end |
| 433 | if ne pg_reg PG_SEM_ERR_ONLY TID_SM121 PB_PREC_NVFP4 20000 800 100 PB_OK |
| 434 | ok = false |
| 435 | end |
| 436 | st_cool = new WattThermal 60000 54000 25000 |
| 437 | ps_set_contract 1 long PHYS_TIER_TOL 0 10 16600 0 |
| 438 | ver_b = get fabVer 3 |
| 439 | rc_bad = ps_dispatch PG_SEM_ERR_ONLY 3 st_cool pol |
| 440 | if or ne rc_bad PHYS_ERR_ERR_BOUND ne get fabVer 3 ver_b |
| 441 | ok = false |
| 442 | end |
| 443 | pg_add_neg 1 |
| 444 | if ok |
| 445 | wd_puts pg_p |
| 446 | wd_puts pg_t4 |
| 447 | wd_puts pg_t4_d |
| 448 | wd_puts pg_nl |
| 449 | else |
| 450 | wd_puts pg_f |
| 451 | wd_puts pg_t4 |
| 452 | wd_puts pg_nl |
| 453 | end |
| 454 | ret ok |
| 455 | end |
| 456 | |
| 457 | note T5: @hard_deadline fail-closed refusal vs soft deadline explicit ALARM_DEADLINE_SLIP |
| 458 | fn pg_t5_hard_vs_soft to bool |
| 459 | ok = true |
| 460 | st84 = new WattThermal 84000 84000 25000 |
| 461 | pol = new WattPolicy 110000 80000 85000 5 |
| 462 | ps_set_baseline 15000 5000 40 |
| 463 | note Hard deadline = 1: MUST fail closed with PHYS_ERR_HARD_DEADLINE and NOT touch fabWtbl[4] |
| 464 | ps_set_contract 1 long PHYS_TIER_TOL 1 100 16600 70000 |
| 465 | ver_b = get fabVer 4 |
| 466 | alm_b = get ps_alm_count 0 |
| 467 | rc_h = ps_dispatch PG_SEM_FRAME 4 st84 pol |
| 468 | if or ne rc_h PHYS_ERR_HARD_DEADLINE or ne get fabVer 4 ver_b ne get ps_alm_count 0 alm_b |
| 469 | ok = false |
| 470 | end |
| 471 | pg_add_neg 1 |
| 472 | note Soft deadline = 0: MUST pick CPU_A725 (22000 us) AND emit explicit ALARM_DEADLINE_SLIP (slip=5400) |
| 473 | ps_set_contract 1 long PHYS_TIER_TOL 0 100 16600 70000 |
| 474 | rc_s = ps_dispatch PG_SEM_FRAME 4 st84 pol |
| 475 | if or ne rc_s PHYS_OK_DEADLINE_SLIP ne get ps_tel PS_TEL_PREC long PB_PREC_CPU_A725 |
| 476 | ok = false |
| 477 | end |
| 478 | if or ne get fabVer 4 add ver_b 1 ne get ps_alm_count 0 add alm_b 1 |
| 479 | ok = false |
| 480 | end |
| 481 | if or ne get ps_alm_code alm_b PHYS_ALARM_DEADLINE_SLIP ne get ps_alm_slip alm_b 5400 |
| 482 | ok = false |
| 483 | end |
| 484 | if ok |
| 485 | wd_puts pg_p |
| 486 | wd_puts pg_t5 |
| 487 | wd_puts pg_t5_d |
| 488 | wd_puts pg_nl |
| 489 | else |
| 490 | wd_puts pg_f |
| 491 | wd_puts pg_t5 |
| 492 | wd_puts pg_nl |
| 493 | end |
| 494 | ret ok |
| 495 | end |
| 496 | |
| 497 | note T6: Composed multi-stage call-chain error check PASS & overflow REFUSAL |
| 498 | fn pg_t6_chain_error to bool |
| 499 | ok = true |
| 500 | note 6a: Additive chain [40, 35, 25] <= 100 -> PASS |
| 501 | if ne ps_chain_begin 100 long PHYS_TIER_TOL PHYS_OK |
| 502 | ok = false |
| 503 | end |
| 504 | if ne ps_chain_add_stage 101 40 PHYS_OK |
| 505 | ok = false |
| 506 | end |
| 507 | if ne ps_chain_add_stage 102 35 PHYS_OK |
| 508 | ok = false |
| 509 | end |
| 510 | if ne ps_chain_add_stage 103 25 PHYS_OK |
| 511 | ok = false |
| 512 | end |
| 513 | if or ne get ps_ch_total_err 0 100 ne ps_chain_commit PHYS_OK |
| 514 | ok = false |
| 515 | end |
| 516 | note 6b: Negative control — additive overflow [40, 35, 30] = 105 > 100 -> REFUSED |
| 517 | if ne ps_chain_begin 100 long PHYS_TIER_TOL PHYS_OK |
| 518 | ok = false |
| 519 | end |
| 520 | if ne ps_chain_add_stage 101 40 PHYS_OK |
| 521 | ok = false |
| 522 | end |
| 523 | if ne ps_chain_add_stage 102 35 PHYS_OK |
| 524 | ok = false |
| 525 | end |
| 526 | if ne ps_chain_add_stage 103 30 PHYS_ERR_CHAIN_ERR_OVERFLOW |
| 527 | ok = false |
| 528 | end |
| 529 | if ne ps_chain_commit PHYS_ERR_CHAIN_ERR_OVERFLOW |
| 530 | ok = false |
| 531 | end |
| 532 | pg_add_neg 1 |
| 533 | note 6c: Outward-rounded Lipschitz interval composition (amp=120/100): |
| 534 | note Stage 1: 40 -> Stage 2: ceil(40*120/100)+20 = 48+20 = 68 <= 70 PASS |
| 535 | if ne ps_chain_begin 70 long PHYS_TIER_TOL PHYS_OK |
| 536 | ok = false |
| 537 | end |
| 538 | if ne ps_chain_add_stage_amp 201 40 100 100 PHYS_OK |
| 539 | ok = false |
| 540 | end |
| 541 | if ne ps_chain_add_stage_amp 202 20 120 100 PHYS_OK |
| 542 | ok = false |
| 543 | end |
| 544 | if or ne get ps_ch_total_err 0 68 ne ps_chain_commit PHYS_OK |
| 545 | ok = false |
| 546 | end |
| 547 | note 6d: Negative control — amplified overflow: ceil(40*125/100)+21 = 50+21 = 71 > 70 -> REFUSED |
| 548 | if ne ps_chain_begin 70 long PHYS_TIER_TOL PHYS_OK |
| 549 | ok = false |
| 550 | end |
| 551 | if ne ps_chain_add_stage_amp 201 40 100 100 PHYS_OK |
| 552 | ok = false |
| 553 | end |
| 554 | if ne ps_chain_add_stage_amp 202 21 125 100 PHYS_ERR_CHAIN_ERR_OVERFLOW |
| 555 | ok = false |
| 556 | end |
| 557 | if ne ps_chain_commit PHYS_ERR_CHAIN_ERR_OVERFLOW |
| 558 | ok = false |
| 559 | end |
| 560 | pg_add_neg 1 |
| 561 | note 6e: Negative control — @exact outer chain (err=0) refuses even stage_err=1 |
| 562 | if ne ps_chain_begin 0 long PHYS_TIER_EXACT PHYS_OK |
| 563 | ok = false |
| 564 | end |
| 565 | if ne ps_chain_add_stage 301 1 PHYS_ERR_CHAIN_ERR_OVERFLOW |
| 566 | ok = false |
| 567 | end |
| 568 | pg_add_neg 1 |
| 569 | if ok |
| 570 | wd_puts pg_p |
| 571 | wd_puts pg_t6 |
| 572 | wd_puts pg_t6_d |
| 573 | wd_puts pg_nl |
| 574 | else |
| 575 | wd_puts pg_f |
| 576 | wd_puts pg_t6 |
| 577 | wd_puts pg_nl |
| 578 | end |
| 579 | ret ok |
| 580 | end |
| 581 | |
| 582 | note T7: Live 28-byte ΩIR v2 wire contract record parsing & malformed refusals (IR.md §16.1) |
| 583 | fn pg_t7_oir_v2_wire to bool |
| 584 | ok = true |
| 585 | rec = new uchar 28 0 |
| 586 | note Valid v2 record: pure=1, tier=2 (@tol), hard=1, res=0, err=128, dl=16600, pwr=60000 |
| 587 | pg_enc_v2_hdr rec 1 2 1 0 |
| 588 | pg_enc_v2_vals rec 128 16600 60000 |
| 589 | if ne ps_parse_oir_v2_contract part rec 0 28 PHYS_OK |
| 590 | ok = false |
| 591 | end |
| 592 | if or ne get ps_ctr 0 1 or ne get ps_ctr 1 2 ne get ps_ctr 2 1 |
| 593 | ok = false |
| 594 | end |
| 595 | if or ne get ps_ctr 3 128 or ne get ps_ctr 4 16600 ne get ps_ctr 5 60000 |
| 596 | ok = false |
| 597 | end |
| 598 | note Drive live dispatch from the parsed ΩIR v2 contract (at 60 C -> picks FP8 48 W <= 60 W!) |
| 599 | st = new WattThermal 60000 54000 25000 |
| 600 | pol = new WattPolicy 110000 80000 85000 5 |
| 601 | ps_set_baseline 15000 5000 40 |
| 602 | rc = ps_dispatch PG_SEM_FRAME 5 st pol |
| 603 | if or ne rc PHYS_OK ne get ps_tel PS_TEL_PREC long PB_PREC_FP8 |
| 604 | ok = false |
| 605 | end |
| 606 | note Negative controls: nonzero reserved byte, @exact with err>0, @hard_deadline with dl=0, tier=3 |
| 607 | pg_enc_v2_hdr rec 1 2 0 1 |
| 608 | pg_enc_v2_vals rec 10 16600 0 |
| 609 | if ne ps_parse_oir_v2_contract part rec 0 28 PHYS_ERR_BAD_CONTRACT |
| 610 | ok = false |
| 611 | end |
| 612 | pg_enc_v2_hdr rec 1 1 0 0 |
| 613 | pg_enc_v2_vals rec 5 16600 0 |
| 614 | if ne ps_parse_oir_v2_contract part rec 0 28 PHYS_ERR_BAD_CONTRACT |
| 615 | ok = false |
| 616 | end |
| 617 | pg_enc_v2_hdr rec 1 2 1 0 |
| 618 | pg_enc_v2_vals rec 10 0 0 |
| 619 | if ne ps_parse_oir_v2_contract part rec 0 28 PHYS_ERR_BAD_CONTRACT |
| 620 | ok = false |
| 621 | end |
| 622 | pg_enc_v2_hdr rec 1 3 0 0 |
| 623 | pg_enc_v2_vals rec 0 16600 0 |
| 624 | if ne ps_parse_oir_v2_contract part rec 0 28 PHYS_ERR_BAD_CONTRACT |
| 625 | ok = false |
| 626 | end |
| 627 | pg_add_neg 1 |
| 628 | if ok |
| 629 | wd_puts pg_p |
| 630 | wd_puts pg_t7 |
| 631 | wd_puts pg_t7_d |
| 632 | wd_puts pg_nl |
| 633 | else |
| 634 | wd_puts pg_f |
| 635 | wd_puts pg_t7 |
| 636 | wd_puts pg_nl |
| 637 | end |
| 638 | ret ok |
| 639 | end |
| 640 | |
| 641 | note T8: Over-temperature die/sink and invalid policy fail closed via WattCBF |
| 642 | fn pg_t8_overtemp_fail_closed to bool |
| 643 | ok = true |
| 644 | ps_set_baseline 15000 5000 40 |
| 645 | ps_set_contract 1 long PHYS_TIER_TOL 0 100 16600 0 |
| 646 | pol_ok = new WattPolicy 110000 80000 85000 5 |
| 647 | ver_b = get fabVer 6 |
| 648 | note 8a: Die over ceiling (86 C >= 85 C) |
| 649 | st_hot_d = new WattThermal 86000 70000 25000 |
| 650 | if ne ps_dispatch PG_SEM_FRAME 6 st_hot_d pol_ok PHYS_ERR_WATTCBF_FAIL_CLOSED |
| 651 | ok = false |
| 652 | end |
| 653 | if or ne get ps_tel PS_TEL_FAN_PCT 100 ne get ps_tel PS_TEL_P_SAFE_GPU 0 |
| 654 | ok = false |
| 655 | end |
| 656 | note 8b: Sink over ceiling (90 C >= 85 C) |
| 657 | st_hot_s = new WattThermal 60000 90000 25000 |
| 658 | if ne ps_dispatch PG_SEM_FRAME 6 st_hot_s pol_ok PHYS_ERR_WATTCBF_FAIL_CLOSED |
| 659 | ok = false |
| 660 | end |
| 661 | note 8c: Invalid negative WattPolicy budget (-1000 mW) |
| 662 | st_cool = new WattThermal 60000 54000 25000 |
| 663 | pol_bad = new WattPolicy -1000 80000 85000 5 |
| 664 | if ne ps_dispatch PG_SEM_FRAME 6 st_cool pol_bad PHYS_ERR_WATTCBF_FAIL_CLOSED |
| 665 | ok = false |
| 666 | end |
| 667 | if ne get fabVer 6 ver_b |
| 668 | ok = false |
| 669 | end |
| 670 | pg_add_neg 1 |
| 671 | if ok |
| 672 | wd_puts pg_p |
| 673 | wd_puts pg_t8 |
| 674 | wd_puts pg_t8_d |
| 675 | wd_puts pg_nl |
| 676 | else |
| 677 | wd_puts pg_f |
| 678 | wd_puts pg_t8 |
| 679 | wd_puts pg_nl |
| 680 | end |
| 681 | ret ok |
| 682 | end |
| 683 | |
| 684 | note T9: Contract @power cap + ARBORIS_SHORTCUT crystallized fabMode & TuringYield_J gain |
| 685 | fn pg_t9_power_cap_arboris to bool |
| 686 | ok = true |
| 687 | if ne pg_reg PG_SEM_POWER_CAP TID_SM121 PB_PREC_NVFP4 30000 1200 20 PB_OK |
| 688 | ok = false |
| 689 | end |
| 690 | if ne pg_reg PG_SEM_POWER_CAP TID_A725 PB_PREC_ARBORIS_SHORTCUT 8000 500 25 PB_OK |
| 691 | ok = false |
| 692 | end |
| 693 | st = new WattThermal 60000 54000 25000 |
| 694 | pol = new WattPolicy 110000 80000 85000 2 |
| 695 | ps_set_baseline 10000 5000 40 |
| 696 | note Tight @power 25000 prunes 30 W NVFP4 even at 60 C -> picks 8 W ARBORIS_SHORTCUT (CRYSTALLIZED) |
| 697 | ps_set_contract 1 long PHYS_TIER_TOL 1 50 1000 25000 |
| 698 | rc = ps_dispatch PG_SEM_POWER_CAP 7 st pol |
| 699 | ty_sc = get ps_tel PS_TEL_TURING_YIELD |
| 700 | if or ne rc PHYS_OK ne get ps_tel PS_TEL_PREC long PB_PREC_ARBORIS_SHORTCUT |
| 701 | ok = false |
| 702 | end |
| 703 | if or ne get fabMode 7 FAB_MODE_CRYSTALLIZED ne get fabCostNs 7 500 |
| 704 | ok = false |
| 705 | end |
| 706 | if le ty_sc 0 |
| 707 | ok = false |
| 708 | end |
| 709 | if ok |
| 710 | wd_puts pg_p |
| 711 | wd_puts pg_t9 |
| 712 | wd_puts pg_t9_d |
| 713 | wd_put_i64 ty_sc |
| 714 | wd_puts pg_nl |
| 715 | else |
| 716 | wd_puts pg_f |
| 717 | wd_puts pg_t9 |
| 718 | wd_puts pg_nl |
| 719 | end |
| 720 | ret ok |
| 721 | end |
| 722 | |
| 723 | note T10: Strictly DRY_RUN_READONLY actuator invariant (hw_writes == 0) + cumulative telemetry check |
| 724 | fn pg_t10_readonly_telemetry to bool |
| 725 | ok = true |
| 726 | if ne get g_wmeta 12 0 |
| 727 | ok = false |
| 728 | end |
| 729 | if ne get ps_tel PS_TEL_HW_WRITES 0 |
| 730 | ok = false |
| 731 | end |
| 732 | if ne get ps_tel PS_TEL_ACTUATOR_MODE long PHYS_ACTUATOR_DRY_RUN_READONLY |
| 733 | ok = false |
| 734 | end |
| 735 | if le get ps_stats 0 0 |
| 736 | ok = false |
| 737 | end |
| 738 | if le get ps_stats 1 0 |
| 739 | ok = false |
| 740 | end |
| 741 | if le get ps_stats 3 0 |
| 742 | ok = false |
| 743 | end |
| 744 | if ok |
| 745 | wd_puts pg_p |
| 746 | wd_puts pg_t10 |
| 747 | wd_puts pg_t10_d |
| 748 | wd_put_u64 get ps_stats 0 |
| 749 | wd_puts pg_t10_d2 |
| 750 | wd_put_u64 get ps_stats 1 |
| 751 | wd_puts pg_nl |
| 752 | else |
| 753 | wd_puts pg_f |
| 754 | wd_puts pg_t10 |
| 755 | wd_puts pg_nl |
| 756 | end |
| 757 | ret ok |
| 758 | end |
| 759 | |
| 760 | fn main to int |
| 761 | tdInitAll |
| 762 | isInitRules |
| 763 | tdCacheInit |
| 764 | fabInit |
| 765 | pb_init |
| 766 | ps_init |
| 767 | put pg_pass 0 0 |
| 768 | put pg_neg 0 0 |
| 769 | wd_puts pg_hdr |
| 770 | if pg_t1_pareto_bank |
| 771 | put pg_pass 0 add get pg_pass 0 1 |
| 772 | end |
| 773 | if pg_t2_thermal_ramp |
| 774 | put pg_pass 0 add get pg_pass 0 1 |
| 775 | end |
| 776 | if pg_t3_trap14_90w |
| 777 | put pg_pass 0 add get pg_pass 0 1 |
| 778 | end |
| 779 | if pg_t4_err_bound |
| 780 | put pg_pass 0 add get pg_pass 0 1 |
| 781 | end |
| 782 | if pg_t5_hard_vs_soft |
| 783 | put pg_pass 0 add get pg_pass 0 1 |
| 784 | end |
| 785 | if pg_t6_chain_error |
| 786 | put pg_pass 0 add get pg_pass 0 1 |
| 787 | end |
| 788 | if pg_t7_oir_v2_wire |
| 789 | put pg_pass 0 add get pg_pass 0 1 |
| 790 | end |
| 791 | if pg_t8_overtemp_fail_closed |
| 792 | put pg_pass 0 add get pg_pass 0 1 |
| 793 | end |
| 794 | if pg_t9_power_cap_arboris |
| 795 | put pg_pass 0 add get pg_pass 0 1 |
| 796 | end |
| 797 | if pg_t10_readonly_telemetry |
| 798 | put pg_pass 0 add get pg_pass 0 1 |
| 799 | end |
| 800 | p = get pg_pass 0 |
| 801 | if eq p 10 |
| 802 | wd_puts pg_sum_ok |
| 803 | wd_put_u64 p |
| 804 | wd_puts pg_sum_of |
| 805 | wd_put_u64 get pg_neg 0 |
| 806 | wd_puts pg_sum_tail |
| 807 | wd_flush |
| 808 | ret 0 |
| 809 | end |
| 810 | wd_puts pg_sum_fail |
| 811 | wd_put_u64 p |
| 812 | wd_puts pg_sum_of |
| 813 | wd_put_u64 get pg_neg 0 |
| 814 | wd_puts pg_sum_tail |
| 815 | wd_flush |
| 816 | ret 1 |
| 817 | end |