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 / build / gate.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note seed/build/gate.om: OMEGA-BUILD-COORD, the pure seeded-Omega self-qualification gate for all |
| 3 | note pure-Omega build, release, and automation coordinators (birth, units, tlsbuild, sparkefi, gpucoord, release). |
| 4 | note Compiles every coordinator twice with seed/out/omc (proving deterministic bit-identical builds), |
| 5 | note runs end-to-end positive checks AND planted negative controls for every coordinator. |
| 6 | note Zero shell, zero Python. |
| 7 | note Build: cat seed/build/common.om seed/build/gate.om | seed/out/omc > build/om-build-gate |
| 8 | note Usage: om-build-gate SCRATCH_DIR |
| 9 | |
| 10 | text gt_usage "usage: om-build-gate SCRATCH_DIR\n" |
| 11 | text gt_omc "seed/out/omc" |
| 12 | text gt_com "seed/build/common.om" |
| 13 | text gt_s_bir "seed/build/birth.om" |
| 14 | text gt_s_uni "seed/build/units.om" |
| 15 | text gt_s_tls "seed/build/tlsbuild.om" |
| 16 | text gt_s_efi "seed/build/sparkefi.om" |
| 17 | text gt_s_gpu "seed/build/gpucoord.om" |
| 18 | text gt_s_rel "seed/build/release.om" |
| 19 | text gt_s_p0 "seed/build/phase0.om" |
| 20 | text gt_n_bir "om-birth" |
| 21 | text gt_n_uni "om-units" |
| 22 | text gt_n_tls "om-tlsbuild" |
| 23 | text gt_n_efi "om-sparkefi" |
| 24 | text gt_n_gpu "om-gpucoord" |
| 25 | text gt_n_rel "om-release" |
| 26 | text gt_n_p0 "om-phase0" |
| 27 | text gt_ok "ok " |
| 28 | text gt_fail "FAIL " |
| 29 | text gt_sum1 "OMEGA-BUILD-COORD " |
| 30 | text gt_pass "PASS" |
| 31 | text gt_fl "FAIL" |
| 32 | text gt_sum2 " checks=" |
| 33 | text gt_sum3 " controls=" |
| 34 | text gt_sum4 " caught=" |
| 35 | text gt_sum5 " hardware=NOT_RUN\n" |
| 36 | text gt_m_det "deterministic-2x " |
| 37 | text gt_m_bir "birth-verify" |
| 38 | text gt_m_tls "tlsbuild-fips" |
| 39 | text gt_m_efi "sparkefi-qemu-pe32" |
| 40 | text gt_m_gpu1 "gpucoord-spirv-check" |
| 41 | text gt_m_gpu2 "gpucoord-intel-gate" |
| 42 | text gt_m_gpu3 "gpucoord-build-spec" |
| 43 | text gt_m_gpu4 "gpucoord-build-q36" |
| 44 | text gt_m_rel1 "release-check-locks" |
| 45 | text gt_m_rel2 "release-check-paths" |
| 46 | text gt_m_rel3 "release-uxl" |
| 47 | text gt_m_rel4 "release-package-verify" |
| 48 | text gt_c_uni "ctrl-units-missing-env-exit3" |
| 49 | text gt_c_efi "ctrl-sparkefi-qemu-refuses-SPARK.EFI" |
| 50 | text gt_c_gpu "ctrl-gpucoord-bad-kernel-refused" |
| 51 | text gt_c_rel1 "ctrl-release-verify-catches-tamper" |
| 52 | text gt_c_rel2 "ctrl-release-paths-catches-CON.txt" |
| 53 | text gt_c_rel3 "ctrl-release-locks-catches-bad-lock" |
| 54 | text gt_f_verify "--verify" |
| 55 | text gt_f_check "--check" |
| 56 | text gt_c_locks "check-locks" |
| 57 | text gt_c_paths "check-paths" |
| 58 | text gt_c_uxl "uxl" |
| 59 | text gt_c_pkg "package" |
| 60 | text gt_c_ver "verify" |
| 61 | text gt_c_srun "spirv-run" |
| 62 | text gt_c_schk "spirv-check" |
| 63 | text gt_c_xe "intel-gate" |
| 64 | text gt_c_spec "build-spec" |
| 65 | text gt_c_q36 "build-q36" |
| 66 | text gt_badk "notakernel" |
| 67 | text gt_cl "cl" |
| 68 | text gt_ver "1.0.0-rc1" |
| 69 | text gt_e_plat_q "PLAT=qemu" |
| 70 | text gt_tlsp_src "fn main to int\nr = fips_check 0\nret int r\nend\n" |
| 71 | text gt_b_s1 "/.1" |
| 72 | text gt_b_s2 "/.2" |
| 73 | text gt_b_src "/.src.om" |
| 74 | text gt_d_bir "/birth-w" |
| 75 | text gt_d_tls "/tls-prog.om" |
| 76 | text gt_d_tlso "/tls-prog" |
| 77 | text gt_d_efi "/qemu.efi" |
| 78 | text gt_d_efibad "/SPARK.EFI" |
| 79 | text gt_d_spec "/spec-out" |
| 80 | text gt_d_q36 "/q36-out" |
| 81 | text gt_d_uxl "/uxl-w" |
| 82 | text gt_d_pkg "/pkg-out" |
| 83 | text gt_d_pkgbin "/pkg-out/bin/om-birth" |
| 84 | text gt_d_badwin "/bad-win" |
| 85 | text gt_d_con "/bad-win/CON.txt" |
| 86 | text gt_d_badlk "/bad-locks" |
| 87 | text gt_d_bl_s "/bad-locks/seed/out" |
| 88 | text gt_d_bl_p "/bad-locks/physics.lock" |
| 89 | text gt_bad_hex "not-a-40-hex-commit\n" |
| 90 | text gt_hi "hi\n" |
| 91 | |
| 92 | global gt_scr uchar 4096 |
| 93 | global gt_scrl ulong 1 |
| 94 | global gt_passc ulong 1 |
| 95 | global gt_failc ulong 1 |
| 96 | global gt_ctlc ulong 1 |
| 97 | global gt_caughtc ulong 1 |
| 98 | |
| 99 | fn gt_sp suf view uchar * to void |
| 100 | cb_pa_clr |
| 101 | for i ulong get gt_scrl 0 bound 4096 |
| 102 | cb_pa_ch get gt_scr i |
| 103 | end |
| 104 | cb_pa_tx suf |
| 105 | end |
| 106 | |
| 107 | fn gt_spb suf view uchar * to void |
| 108 | cb_pb_clr |
| 109 | for i ulong get gt_scrl 0 bound 4096 |
| 110 | cb_pb_ch get gt_scr i |
| 111 | end |
| 112 | cb_pb_tx suf |
| 113 | end |
| 114 | |
| 115 | fn gt_bin_pa name view uchar * to void |
| 116 | cb_pa_clr |
| 117 | for i ulong get gt_scrl 0 bound 4096 |
| 118 | cb_pa_ch get gt_scr i |
| 119 | end |
| 120 | cb_pa_ch 47 |
| 121 | cb_pa_tx name |
| 122 | end |
| 123 | |
| 124 | fn gt_rec_ok name view uchar * to void |
| 125 | cb_out gt_ok |
| 126 | cb_out name |
| 127 | cb_out cb_nl |
| 128 | put gt_passc 0 add get gt_passc 0 1 |
| 129 | end |
| 130 | |
| 131 | fn gt_rec_fail name view uchar * to void |
| 132 | cb_out gt_fail |
| 133 | cb_out name |
| 134 | cb_out cb_nl |
| 135 | put gt_failc 0 add get gt_failc 0 1 |
| 136 | end |
| 137 | |
| 138 | fn gt_rec_ctl ok bool name view uchar * to void |
| 139 | put gt_ctlc 0 add get gt_ctlc 0 1 |
| 140 | if ok |
| 141 | cb_out gt_ok |
| 142 | cb_out name |
| 143 | cb_out cb_nl |
| 144 | put gt_caughtc 0 add get gt_caughtc 0 1 |
| 145 | else |
| 146 | cb_out gt_fail |
| 147 | cb_out name |
| 148 | cb_out cb_nl |
| 149 | put gt_failc 0 add get gt_failc 0 1 |
| 150 | end |
| 151 | end |
| 152 | |
| 153 | note Compile common.om + src twice, check byte identity, install as SCRATCH/name |
| 154 | fn gt_build_det src view uchar * name view uchar * to bool |
| 155 | cb_wb_clr |
| 156 | cb_pa_set gt_com |
| 157 | if not cb_append_pa_to_wb |
| 158 | gt_rec_fail name |
| 159 | ret false |
| 160 | end |
| 161 | cb_pa_set src |
| 162 | if not cb_append_pa_to_wb |
| 163 | gt_rec_fail name |
| 164 | ret false |
| 165 | end |
| 166 | gt_sp gt_b_src |
| 167 | if not cb_write_wb_pa 420 |
| 168 | gt_rec_fail name |
| 169 | ret false |
| 170 | end |
| 171 | for i ulong len gt_omc bound 4096 |
| 172 | put cb_pc i get gt_omc i |
| 173 | end |
| 174 | gt_spb gt_b_s1 |
| 175 | if ne cb_run_omc len gt_omc 493 -1 0 |
| 176 | gt_rec_fail name |
| 177 | ret false |
| 178 | end |
| 179 | gt_spb gt_b_s2 |
| 180 | if ne cb_run_omc len gt_omc 493 -1 0 |
| 181 | gt_rec_fail name |
| 182 | ret false |
| 183 | end |
| 184 | gt_sp gt_b_s1 |
| 185 | gt_spb gt_b_s2 |
| 186 | if not cb_cmp_pa_pb |
| 187 | gt_rec_fail name |
| 188 | ret false |
| 189 | end |
| 190 | gt_sp gt_b_s1 |
| 191 | cb_pb_clr |
| 192 | for i ulong get gt_scrl 0 bound 4096 |
| 193 | cb_pb_ch get gt_scr i |
| 194 | end |
| 195 | cb_pb_ch 47 |
| 196 | cb_pb_tx name |
| 197 | if not cb_copy_pa_to_pb 493 |
| 198 | gt_rec_fail name |
| 199 | ret false |
| 200 | end |
| 201 | cb_out gt_ok |
| 202 | cb_out gt_m_det |
| 203 | cb_out name |
| 204 | cb_out cb_nl |
| 205 | put gt_passc 0 add get gt_passc 0 1 |
| 206 | ret true |
| 207 | end |
| 208 | |
| 209 | fn gt_run_quiet use_ev bool to ulong |
| 210 | fo = fopen cb_devnull 0 len cb_devnull 524289 0 |
| 211 | fe = fopen cb_devnull 0 len cb_devnull 524289 0 |
| 212 | ret cb_spawn_fds -1 int fo int fe use_ev |
| 213 | end |
| 214 | |
| 215 | fn main to int |
| 216 | if ne argcnt 2 |
| 217 | cb_err gt_usage |
| 218 | ret 2 |
| 219 | end |
| 220 | if not cb_pa_arg 1 |
| 221 | cb_err gt_usage |
| 222 | ret 2 |
| 223 | end |
| 224 | for i ulong get cb_n 3 bound 4096 |
| 225 | put gt_scr i get cb_pa i |
| 226 | end |
| 227 | put gt_scrl 0 get cb_n 3 |
| 228 | if not cb_mkdir_p_pa |
| 229 | ret 2 |
| 230 | end |
| 231 | |
| 232 | note 1. Build all 6 coordinators deterministically (2x compile + byte compare) |
| 233 | if not gt_build_det gt_s_bir gt_n_bir |
| 234 | ret 1 |
| 235 | end |
| 236 | if not gt_build_det gt_s_uni gt_n_uni |
| 237 | ret 1 |
| 238 | end |
| 239 | if not gt_build_det gt_s_tls gt_n_tls |
| 240 | ret 1 |
| 241 | end |
| 242 | if not gt_build_det gt_s_efi gt_n_efi |
| 243 | ret 1 |
| 244 | end |
| 245 | if not gt_build_det gt_s_gpu gt_n_gpu |
| 246 | ret 1 |
| 247 | end |
| 248 | if not gt_build_det gt_s_rel gt_n_rel |
| 249 | ret 1 |
| 250 | end |
| 251 | if not gt_build_det gt_s_p0 gt_n_p0 |
| 252 | ret 1 |
| 253 | end |
| 254 | |
| 255 | note 2. Positive check: om-birth --verify (full rung0..omc fixpoint + diaggen + 8 size-record + 4 probes) |
| 256 | cb_av_clr |
| 257 | gt_bin_pa gt_n_bir |
| 258 | cb_av_push_pa |
| 259 | cb_av_push_tx gt_f_verify |
| 260 | gt_sp gt_d_bir |
| 261 | cb_av_push_pa |
| 262 | if eq gt_run_quiet false 0 |
| 263 | gt_rec_ok gt_m_bir |
| 264 | else |
| 265 | gt_rec_fail gt_m_bir |
| 266 | end |
| 267 | |
| 268 | note 3. Positive check: om-tlsbuild builds & FIPS-stamps a real TLS program |
| 269 | cb_wb_clr |
| 270 | cb_wb_tx gt_tlsp_src |
| 271 | gt_sp gt_d_tls |
| 272 | z0 = cb_write_wb_pa 420 |
| 273 | cb_av_clr |
| 274 | gt_bin_pa gt_n_tls |
| 275 | cb_av_push_pa |
| 276 | cb_av_push_tx gt_omc |
| 277 | gt_sp gt_d_tls |
| 278 | cb_av_push_pa |
| 279 | gt_sp gt_d_tlso |
| 280 | cb_av_push_pa |
| 281 | if eq gt_run_quiet false 0 |
| 282 | note also run the FIPS-stamped TLS binary! |
| 283 | cb_av_clr |
| 284 | gt_sp gt_d_tlso |
| 285 | cb_av_push_pa |
| 286 | if eq gt_run_quiet false 0 |
| 287 | gt_rec_ok gt_m_tls |
| 288 | else |
| 289 | gt_rec_fail gt_m_tls |
| 290 | end |
| 291 | else |
| 292 | gt_rec_fail gt_m_tls |
| 293 | end |
| 294 | |
| 295 | note 4. Positive check: om-sparkefi with PLAT=qemu builds & verifies PE32+ image |
| 296 | cb_av_clr |
| 297 | gt_bin_pa gt_n_efi |
| 298 | cb_av_push_pa |
| 299 | gt_sp gt_d_efi |
| 300 | cb_av_push_pa |
| 301 | cb_ev_clr |
| 302 | cb_pa_set gt_e_plat_q |
| 303 | cb_ev_push_env_pa |
| 304 | if eq gt_run_quiet true 0 |
| 305 | gt_rec_ok gt_m_efi |
| 306 | else |
| 307 | gt_rec_fail gt_m_efi |
| 308 | end |
| 309 | |
| 310 | note 5. Negative control: om-sparkefi with PLAT=qemu refuses to write SPARK.EFI |
| 311 | cb_av_clr |
| 312 | gt_bin_pa gt_n_efi |
| 313 | cb_av_push_pa |
| 314 | gt_sp gt_d_efibad |
| 315 | cb_av_push_pa |
| 316 | cb_ev_clr |
| 317 | cb_pa_set gt_e_plat_q |
| 318 | cb_ev_push_env_pa |
| 319 | gt_rec_ctl ne gt_run_quiet true 0 gt_c_efi |
| 320 | |
| 321 | note 6. Positive checks: om-gpucoord spirv-check, intel-gate, build-spec |
| 322 | cb_av_clr |
| 323 | gt_bin_pa gt_n_gpu |
| 324 | cb_av_push_pa |
| 325 | cb_av_push_tx gt_c_schk |
| 326 | if eq gt_run_quiet false 0 |
| 327 | gt_rec_ok gt_m_gpu1 |
| 328 | else |
| 329 | gt_rec_fail gt_m_gpu1 |
| 330 | end |
| 331 | |
| 332 | cb_av_clr |
| 333 | gt_bin_pa gt_n_gpu |
| 334 | cb_av_push_pa |
| 335 | cb_av_push_tx gt_c_xe |
| 336 | if eq gt_run_quiet false 0 |
| 337 | gt_rec_ok gt_m_gpu2 |
| 338 | else |
| 339 | gt_rec_fail gt_m_gpu2 |
| 340 | end |
| 341 | |
| 342 | cb_av_clr |
| 343 | gt_bin_pa gt_n_gpu |
| 344 | cb_av_push_pa |
| 345 | cb_av_push_tx gt_c_spec |
| 346 | gt_sp gt_d_spec |
| 347 | cb_av_push_pa |
| 348 | if eq gt_run_quiet false 0 |
| 349 | gt_rec_ok gt_m_gpu3 |
| 350 | else |
| 351 | gt_rec_fail gt_m_gpu3 |
| 352 | end |
| 353 | |
| 354 | cb_av_clr |
| 355 | gt_bin_pa gt_n_gpu |
| 356 | cb_av_push_pa |
| 357 | cb_av_push_tx gt_c_q36 |
| 358 | gt_sp gt_d_q36 |
| 359 | cb_av_push_pa |
| 360 | if eq gt_run_quiet false 0 |
| 361 | gt_rec_ok gt_m_gpu4 |
| 362 | else |
| 363 | gt_rec_fail gt_m_gpu4 |
| 364 | end |
| 365 | |
| 366 | note 7. Negative control: om-gpucoord refuses bad kernel |
| 367 | cb_av_clr |
| 368 | gt_bin_pa gt_n_gpu |
| 369 | cb_av_push_pa |
| 370 | cb_av_push_tx gt_c_srun |
| 371 | cb_av_push_tx gt_badk |
| 372 | cb_av_push_tx gt_cl |
| 373 | gt_rec_ctl ne gt_run_quiet false 0 gt_c_gpu |
| 374 | |
| 375 | note 8. Negative control: om-units without OMEGA_OMC/OMEGA_BRIDGE exits 3 (NOT_RUN) |
| 376 | cb_av_clr |
| 377 | gt_bin_pa gt_n_uni |
| 378 | cb_av_push_pa |
| 379 | cb_av_push_tx gt_f_check |
| 380 | gt_rec_ctl eq gt_run_quiet false 3 gt_c_uni |
| 381 | |
| 382 | note 9. Positive checks: om-release check-locks, check-paths, uxl, package + verify |
| 383 | cb_av_clr |
| 384 | gt_bin_pa gt_n_rel |
| 385 | cb_av_push_pa |
| 386 | cb_av_push_tx gt_c_locks |
| 387 | if eq gt_run_quiet false 0 |
| 388 | gt_rec_ok gt_m_rel1 |
| 389 | else |
| 390 | gt_rec_fail gt_m_rel1 |
| 391 | end |
| 392 | |
| 393 | cb_av_clr |
| 394 | gt_bin_pa gt_n_rel |
| 395 | cb_av_push_pa |
| 396 | cb_av_push_tx gt_c_paths |
| 397 | if eq gt_run_quiet false 0 |
| 398 | gt_rec_ok gt_m_rel2 |
| 399 | else |
| 400 | gt_rec_fail gt_m_rel2 |
| 401 | end |
| 402 | |
| 403 | cb_av_clr |
| 404 | gt_bin_pa gt_n_rel |
| 405 | cb_av_push_pa |
| 406 | cb_av_push_tx gt_c_uxl |
| 407 | gt_sp gt_d_uxl |
| 408 | cb_av_push_pa |
| 409 | if eq gt_run_quiet false 0 |
| 410 | gt_rec_ok gt_m_rel3 |
| 411 | else |
| 412 | gt_rec_fail gt_m_rel3 |
| 413 | end |
| 414 | |
| 415 | cb_av_clr |
| 416 | gt_bin_pa gt_n_rel |
| 417 | cb_av_push_pa |
| 418 | cb_av_push_tx gt_c_pkg |
| 419 | gt_sp gt_d_pkg |
| 420 | cb_av_push_pa |
| 421 | cb_av_push_tx gt_ver |
| 422 | pkg_rc = gt_run_quiet false |
| 423 | ver_rc = ulong 1 |
| 424 | if eq pkg_rc 0 |
| 425 | cb_av_clr |
| 426 | gt_bin_pa gt_n_rel |
| 427 | cb_av_push_pa |
| 428 | cb_av_push_tx gt_c_ver |
| 429 | gt_sp gt_d_pkg |
| 430 | cb_av_push_pa |
| 431 | ver_rc = gt_run_quiet false |
| 432 | end |
| 433 | if and eq pkg_rc 0 eq ver_rc 0 |
| 434 | gt_rec_ok gt_m_rel4 |
| 435 | else |
| 436 | gt_rec_fail gt_m_rel4 |
| 437 | end |
| 438 | |
| 439 | note 10. Negative control: flip 1 byte in packaged bin/om-birth -> verify MUST fail! |
| 440 | gt_sp gt_d_pkgbin |
| 441 | if cb_read_pa |
| 442 | bn = get cb_n 0 |
| 443 | if gt bn 0 |
| 444 | put cb_rb sub bn 1 xor get cb_rb sub bn 1 1 |
| 445 | z1 = cb_write_rb_pa 493 |
| 446 | end |
| 447 | end |
| 448 | cb_av_clr |
| 449 | gt_bin_pa gt_n_rel |
| 450 | cb_av_push_pa |
| 451 | cb_av_push_tx gt_c_ver |
| 452 | gt_sp gt_d_pkg |
| 453 | cb_av_push_pa |
| 454 | gt_rec_ctl ne gt_run_quiet false 0 gt_c_rel1 |
| 455 | |
| 456 | note 11. Negative control: Windows reserved filename CON.txt -> check-paths MUST fail! |
| 457 | gt_sp gt_d_badwin |
| 458 | z2 = cb_mkdir_p_pa |
| 459 | cb_wb_clr |
| 460 | cb_wb_tx gt_hi |
| 461 | gt_sp gt_d_con |
| 462 | z3 = cb_write_wb_pa 420 |
| 463 | cb_av_clr |
| 464 | gt_bin_pa gt_n_rel |
| 465 | cb_av_push_pa |
| 466 | cb_av_push_tx gt_c_paths |
| 467 | gt_sp gt_d_badwin |
| 468 | cb_av_push_pa |
| 469 | gt_rec_ctl ne gt_run_quiet false 0 gt_c_rel2 |
| 470 | |
| 471 | note 12. Negative control: malformed physics.lock -> check-locks MUST fail! |
| 472 | gt_sp gt_d_bl_s |
| 473 | z4 = cb_mkdir_p_pa |
| 474 | cb_wb_clr |
| 475 | cb_wb_tx gt_bad_hex |
| 476 | gt_sp gt_d_bl_p |
| 477 | z5 = cb_write_wb_pa 420 |
| 478 | cb_av_clr |
| 479 | gt_bin_pa gt_n_rel |
| 480 | cb_av_push_pa |
| 481 | cb_av_push_tx gt_c_locks |
| 482 | gt_sp gt_d_badlk |
| 483 | cb_av_push_pa |
| 484 | gt_rec_ctl ne gt_run_quiet false 0 gt_c_rel3 |
| 485 | |
| 486 | note Summary |
| 487 | cb_out gt_sum1 |
| 488 | if eq get gt_failc 0 0 |
| 489 | cb_out gt_pass |
| 490 | else |
| 491 | cb_out gt_fl |
| 492 | end |
| 493 | cb_out gt_sum2 |
| 494 | cb_wnum 1 get gt_passc 0 |
| 495 | cb_out gt_sum3 |
| 496 | cb_wnum 1 get gt_ctlc 0 |
| 497 | cb_out gt_sum4 |
| 498 | cb_wnum 1 get gt_caughtc 0 |
| 499 | cb_out gt_sum5 |
| 500 | if ne get gt_failc 0 0 |
| 501 | ret 1 |
| 502 | end |
| 503 | if ne get gt_ctlc 0 get gt_caughtc 0 |
| 504 | ret 1 |
| 505 | end |
| 506 | ret 0 |
| 507 | end |