Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/si/architecture/tools/zero-legacy/gate.om # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / si / architecture / tools / zero-legacy / gate.om` 590 lines ยท 9882 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note gate: the ARCH-ZERO-LEGACY-CLOSURE gate runner (#316), seeded native Omega. 3 note usage: gate OMC (run from tools/zero-legacy; writes under build/) 4 note Builds closure.om, expect.om and sha256.om with OMC, hashes OMC with the native sha256 and 5 note compares it to omega.pin, runs the hostile and clean fixtures in release mode, judges the 6 note reports with expect, builds elfclose.om and fixtures/elfgen.om, generates the synthetic ELF 7 note fixtures, runs elfclose over them and over fixtures/proc and judges both reports (#316 8 note item 2), prints AIEN-OBS lines. Exit 0 only when every expectation holds; 9 note 3 when OMC is missing or does not match the pin (NOT_RUN); 1 otherwise. 10 note gate.sh authenticates the compiler independently before compiling this native fixture gate. 11 12 text tbl "closure.om\nexpect.om\nsha256.om\nbuild/closure\nbuild/expect\nbuild/sha256\nfixtures/tree\nrelease\nfixtures/manifest.txt\nfixtures/clean\nfixtures/clean-manifest.txt\nfixtures/tree.expected\nfixtures/clean.expected\nbuild/tree.out\nbuild/clean.out\nbuild/clean2.out\nbuild/omc.sha\nbuild/closure.sha\nomega.pin\nbuild\nfixtures/io-build.om\nbuild/io-build\nbuild/io-errors.om\nbuild/io-errors\nfixtures/clean/src\nread-error\ndirectory-error\nbuild/read-error.out\nbuild/directory-error.out\nelfclose.om\nbuild/elfclose\nfixtures/elfgen.om\nbuild/elfgen\nbuild/elf\nelf\nproc\nfixtures/proc\nbuild/elf.out\nbuild/proc.out\nfixtures/elf.expected\nfixtures/proc.expected\nbuild/elf/dyn-gcc\nbuild/elf/dyn-nomark\nbuild/elf/badneed\nbuild/elf/need-nostr\nbuild/elf/strtab-unmapped\nbuild/elf/bad-shstrndx\nbuild/elf/static-rust\nbuild/elf/clang-lld\nbuild/elf/static-pie-go\nbuild/elf/bare\nbuild/elf/gnu-phdr\nbuild/elf/trunc\nbuild/elf/badph\nbuild/elf/elf32\nbuild/elf/bigend\nbuild/elf/notelf\nbuild/elf/absent\nbuild/elf/need-inject\nbuild/elf/need-comma\nbuild/elf/interp-tab\nbuild/elf/interp-del\nbuild/elf/load-wrap\nbuild/elf/esc\tname\\x\n" 13 text tobs "AIEN-OBS " 14 text tcls "closure_sha256 \"" 15 text tq "\"\n" 16 text ttre "tree_release_exit " 17 text tcle "clean_release_exit " 18 text tcl2 "clean_undeclared_exit " 19 text tex1 "expect_tree_exit " 20 text tex2 "expect_clean_exit " 21 text trerr "read_error_exit " 22 text tderr "directory_error_exit " 23 text tegen "elfgen_exit " 24 text telfs "elf_scan_exit " 25 text tprcs "proc_scan_exit " 26 text texel "expect_elf_exit " 27 text texpr "expect_proc_exit " 28 text txcr "cross_expect_refused " 29 text tnl "\n" 30 text tuse "usage: gate OMC\n" 31 text tnot "gate: OMC missing or not the pinned compiler (NOT_RUN)\n" 32 text tcf "gate: compile failed\n" 33 text tkey "omc_sha256: " 34 35 global omcp uchar 4096 36 global omcl ulong 1 37 global pk uchar 4096 38 global pkn ulong 1 39 global pkc ulong 1 40 global arg uchar 256 41 global argl ulong 1 42 global fin uchar 256 43 global finl ulong 1 44 global fout uchar 256 45 global foutl ulong 1 46 global status uchar 4 47 global pin uchar 4096 48 global pinl ulong 1 49 global sha uchar 128 50 global nb uchar 24 51 52 note ---- text table ---- 53 54 fn pick i ulong to void 55 s = ulong 0 56 k = ulong 0 57 while lt k i bound 4096 58 if eq get tbl s 10 59 k = add k 1 60 end 61 s = add s 1 62 end 63 n = ulong 0 64 while ne get tbl add s n 10 bound 256 65 put arg n get tbl add s n 66 n = add n 1 67 end 68 put argl 0 n 69 end 70 71 note ---- packets for execprog ---- 72 73 fn pk0 to void 74 put pkn 0 2 75 put pkc 0 0 76 end 77 78 fn pka to void 79 n = get pkn 0 80 m = get argl 0 81 put pk n uchar rem m 256 82 put pk add n 1 uchar div m 256 83 for i ulong m 84 put pk add n add 2 i get arg i 85 end 86 put pkn 0 add n add 2 m 87 c = add get pkc 0 1 88 put pkc 0 c 89 put pk 0 uchar rem c 256 90 put pk 1 uchar div c 256 91 end 92 93 fn pkt i ulong to void 94 pick i 95 pka 96 end 97 98 fn pkomc to void 99 for i ulong get omcl 0 100 put arg i get omcp i 101 end 102 put argl 0 get omcl 0 103 pka 104 end 105 106 fn setin i ulong to void 107 pick i 108 for j ulong get argl 0 109 put fin j get arg j 110 end 111 put finl 0 get argl 0 112 end 113 114 fn setout i ulong to void 115 pick i 116 for j ulong get argl 0 117 put fout j get arg j 118 end 119 put foutl 0 get argl 0 120 end 121 122 fn noio to void 123 put finl 0 0 124 put foutl 0 0 125 end 126 127 note ---- run the packet; stdin/stdout redirected when set; returns exit code or -1 ---- 128 129 fn child to void 130 if gt get finl 0 0 131 fd = fopen fin 0 get finl 0 0 0 132 if lt fd 0 133 exit 126 134 end 135 r = dupfd int fd 0 0 136 end 137 if gt get foutl 0 0 138 fd = fopen fout 0 get foutl 0 577 420 139 if lt fd 0 140 exit 126 141 end 142 r = dupfd int fd 1 0 143 end 144 r = execprog pk 0 get pkn 0 145 exit 127 146 end 147 148 fn run to long 149 pid = fork 150 if lt pid 0 151 ret -1 152 end 153 if eq pid 0 154 child 155 end 156 r = waitpid int pid status 0 4 0 157 if ne r pid 158 ret -1 159 end 160 if ne get status 0 0 161 ret -1 162 end 163 ret long get status 1 164 end 165 166 note ---- steps ---- 167 168 fn compile src ulong dst ulong to bool 169 pk0 170 pkomc 171 setin src 172 setout dst 173 r = run 174 if ne r 0 175 ret false 176 end 177 pick dst 178 r = chmod arg 0 get argl 0 493 179 ret eq r 0 180 end 181 182 note hash the file named by table entry f into table entry out; read 64 hex into sha 183 fn hashto f ulong out ulong to bool 184 pk0 185 pkt 5 186 pkt f 187 put finl 0 0 188 setout out 189 r = run 190 if ne r 0 191 ret false 192 end 193 ret readsha out 194 end 195 196 fn hashomc to bool 197 pk0 198 pkt 5 199 pkomc 200 put finl 0 0 201 setout 16 202 r = run 203 if ne r 0 204 ret false 205 end 206 ret readsha 16 207 end 208 209 fn readsha out ulong to bool 210 pick out 211 fd = fopen arg 0 get argl 0 0 0 212 if lt fd 0 213 ret false 214 end 215 r = read int fd sha 0 128 216 c = fclose int fd 217 ret ge r 64 218 end 219 220 fn loadpin to bool 221 pick 18 222 fd = fopen arg 0 get argl 0 0 0 223 if lt fd 0 224 ret false 225 end 226 r = read int fd pin 0 4096 227 c = fclose int fd 228 if le r 0 229 ret false 230 end 231 put pinl 0 ulong r 232 ret true 233 end 234 235 note does sha[0..64) equal the 64 bytes after "omc_sha256: " in the pin 236 fn pinok to bool 237 n = get pinl 0 238 m = len tkey 239 if lt n add m 64 240 ret false 241 end 242 e = sub n add m 64 243 i = ulong 0 244 while le i e bound 4096 245 j = ulong 0 246 while lt j m bound 16 247 if ne get pin add i j get tkey j 248 break 249 end 250 j = add j 1 251 end 252 if eq j m 253 ret same add i m 254 end 255 i = add i 1 256 end 257 ret false 258 end 259 260 fn same p ulong to bool 261 for j ulong 64 262 if ne get pin add p j get sha j 263 ret false 264 end 265 end 266 ret true 267 end 268 269 fn tree to long 270 pk0 271 pkt 3 272 pkt 6 273 pkt 7 274 pkt 8 275 put finl 0 0 276 setout 13 277 ret run 278 end 279 280 fn clean to long 281 pk0 282 pkt 3 283 pkt 9 284 pkt 7 285 pkt 10 286 put finl 0 0 287 setout 14 288 ret run 289 end 290 291 fn clean2 to long 292 pk0 293 pkt 3 294 pkt 9 295 pkt 7 296 put finl 0 0 297 setout 15 298 ret run 299 end 300 301 fn judge out ulong exp ulong to long 302 pk0 303 pkt 4 304 pkt out 305 pkt exp 306 noio 307 ret run 308 end 309 310 note Build the test copy natively; no shell transformation or production fault switch. 311 fn buildio to bool 312 if not compile 20 21 313 ret false 314 end 315 pk0 316 pkt 21 317 put finl 0 0 318 setout 22 319 r = run 320 if ne r 0 321 ret false 322 end 323 ret compile 22 23 324 end 325 326 fn iotest mode ulong out ulong to long 327 pk0 328 pkt 23 329 pkt 24 330 pkt mode 331 put finl 0 0 332 setout out 333 ret run 334 end 335 336 note ---- ELF and process closure (#316 item 2) ---- 337 338 fn elfgen to long 339 pk0 340 pkt 32 341 pkt 33 342 noio 343 ret run 344 end 345 346 note elfclose elf over the 16 base fixtures, build/closure (real omc output), a missing path, the 6 347 note hostile-string fixtures (control bytes, a comma, a wrapping PT_LOAD, a tab in the file name) 348 note and the directory build/elf (not a regular file: UNREADABLE) 349 fn elfscan to long 350 pk0 351 pkt 30 352 pkt 34 353 for i ulong 16 354 pkt add 41 i 355 end 356 pkt 3 357 pkt 57 358 for j ulong 6 359 pkt add 58 j 360 end 361 pkt 33 362 put finl 0 0 363 setout 37 364 ret run 365 end 366 367 fn procscan to long 368 pk0 369 pkt 30 370 pkt 35 371 pkt 36 372 put finl 0 0 373 setout 38 374 ret run 375 end 376 377 note run the ELF/process stage, print its observations; true when every expectation holds. 378 note The cross judgment (process report against the ELF expectations) must be refused, so a 379 note judge that accepts anything cannot pass this stage. 380 fn elfstage to bool 381 h = elfgen 382 i = elfscan 383 j = procscan 384 k = judge 37 39 385 l = judge 38 40 386 m = judge 38 39 387 x = long 0 388 if ne m 0 389 x = 1 390 end 391 obsn 7 h 392 obsn 8 i 393 obsn 9 j 394 obsn 10 k 395 obsn 11 l 396 obsn 12 x 397 ok = true 398 if ne h 0 399 ok = false 400 end 401 if ne i 0 402 ok = false 403 end 404 if ne j 0 405 ok = false 406 end 407 if ne k 0 408 ok = false 409 end 410 if ne l 0 411 ok = false 412 end 413 if ne x 1 414 ok = false 415 end 416 ret ok 417 end 418 419 note ---- output ---- 420 421 fn wnum v long to void 422 if lt v 0 423 put nb 22 45 424 put nb 23 49 425 r = write 1 nb 22 2 426 ret 427 end 428 x = ulong v 429 n = ulong 0 430 if eq x 0 431 put nb 23 48 432 n = 1 433 end 434 while gt x 0 bound 20 435 put nb sub 23 n uchar add 48 rem x 10 436 x = div x 10 437 n = add n 1 438 end 439 r = write 1 nb sub 24 n n 440 end 441 442 fn obs1 to void 443 r = write 1 tobs 0 len tobs 444 r = write 1 tcls 0 len tcls 445 r = write 1 sha 0 64 446 r = write 1 tq 0 len tq 447 end 448 449 fn obsn k ulong v long to void 450 r = write 1 tobs 0 len tobs 451 if eq k 0 452 r = write 1 ttre 0 len ttre 453 end 454 if eq k 1 455 r = write 1 tcle 0 len tcle 456 end 457 if eq k 2 458 r = write 1 tcl2 0 len tcl2 459 end 460 if eq k 3 461 r = write 1 tex1 0 len tex1 462 end 463 if eq k 4 464 r = write 1 tex2 0 len tex2 465 end 466 if eq k 5 467 r = write 1 trerr 0 len trerr 468 end 469 if eq k 6 470 r = write 1 tderr 0 len tderr 471 end 472 if eq k 7 473 r = write 1 tegen 0 len tegen 474 end 475 if eq k 8 476 r = write 1 telfs 0 len telfs 477 end 478 if eq k 9 479 r = write 1 tprcs 0 len tprcs 480 end 481 if eq k 10 482 r = write 1 texel 0 len texel 483 end 484 if eq k 11 485 r = write 1 texpr 0 len texpr 486 end 487 if eq k 12 488 r = write 1 txcr 0 len txcr 489 end 490 wnum v 491 r = write 1 tnl 0 1 492 end 493 494 fn main to int 495 if lt argcnt 2 496 r = write 2 tuse 0 len tuse 497 ret 64 498 end 499 n = argread 1 omcp 0 4095 500 if lt n 1 501 r = write 2 tuse 0 len tuse 502 ret 64 503 end 504 put omcl 0 ulong n 505 pick 19 506 r = makedir arg 0 get argl 0 493 507 if not compile 2 5 508 r = write 2 tnot 0 len tnot 509 ret 3 510 end 511 if not loadpin 512 r = write 2 tnot 0 len tnot 513 ret 3 514 end 515 if not hashomc 516 r = write 2 tnot 0 len tnot 517 ret 3 518 end 519 if not pinok 520 r = write 2 tnot 0 len tnot 521 ret 3 522 end 523 if not compile 0 3 524 r = write 2 tcf 0 len tcf 525 ret 1 526 end 527 if not compile 1 4 528 r = write 2 tcf 0 len tcf 529 ret 1 530 end 531 if not hashto 3 17 532 r = write 2 tcf 0 len tcf 533 ret 1 534 end 535 if not buildio 536 r = write 2 tcf 0 len tcf 537 ret 1 538 end 539 if not compile 29 30 540 r = write 2 tcf 0 len tcf 541 ret 1 542 end 543 if not compile 31 32 544 r = write 2 tcf 0 len tcf 545 ret 1 546 end 547 pick 33 548 r = makedir arg 0 get argl 0 493 549 obs1 550 a = tree 551 b = clean 552 c = clean2 553 d = judge 13 11 554 e = judge 14 12 555 f = iotest 25 27 556 g = iotest 26 28 557 obsn 0 a 558 obsn 1 b 559 obsn 2 c 560 obsn 3 d 561 obsn 4 e 562 obsn 5 f 563 obsn 6 g 564 y = elfstage 565 if not y 566 ret 1 567 end 568 if ne a 1 569 ret 1 570 end 571 if ne b 0 572 ret 1 573 end 574 if ne c 1 575 ret 1 576 end 577 if ne d 0 578 ret 1 579 end 580 if ne e 0 581 ret 1 582 end 583 if ne f 0 584 ret 1 585 end 586 if ne g 0 587 ret 1 588 end 589 ret 0 590 end