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/train/omega-llm/tools/wpatch/wpbuild.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 / train / omega-llm / tools / wpatch / wpbuild.om` 800 lines ยท 15248 bytes Raw Blame History 1 note SPDX-License-Identifier: AGPL-3.0-only 2 note wpbuild: the Omega build driver for ollm, wpatch and its test driver wpcheck. CPU only. 3 note Usage: wpbuild REPO OUT OMC OMEGA_MV CORE (all five required; CORE is a taskset core number). 4 note Steps, in order (any failure prints one WPBUILD FAIL line and exits nonzero): 5 note 1. Compiler pin: the sha256 of OMC (read from sha256sum) must equal OMCPIN. 6 note 2. SHA-256: git show of om/sha256/sha256-om2.om at omega-mv pin `e5b32567` into OUT/sha256-source.om; 7 note its sha256 (read from sha256sum) must equal SHASRC. 8 note 3. Vendoring, done here in Omega: the layout block (from the line `layout shactx 104` through the 9 note next line `end`) goes to OUT/sha256-layout.om. Every other line except `om2` goes to 10 note OUT/sha256-functions.om, with a leading `export fn ` made `fn `, and on lines that do not start 11 note with `note` each whole word ([A-Za-z0-9_] run) in OLDW renamed to the word at the same position 12 note in NEWW. OUT/sha256-vendored.om is `om2`, layout, functions; OUT/sha256.diff is diff -u of the 13 note source against it (a review record, not an input). 14 note 4. wpcheck: OUT/wpcheck-all.om is `om2`, layout, functions, wpcheck.om; compiled to OUT/wpcheck. 15 note 5. Net pins: `OUT/wpcheck sum` (the vendored Omega SHA-256) of native/omegallm/net/http.om, 16 note json.om and jsonw.om must equal NPHTTP, NPJSON and NPJSONW (the pins of the aarch64 ollm build). 17 note 6. ollm: OUT/ollm.om is the line `om2`, then native/omegallm/ net/http.om net/json.om 18 note net/jsonw.om math.om data.om lpool.om model.om adam.om ckpt.om bpe.om cli.om lio.om serve.om 19 note nogpu.om, plain concatenation in that order (the aarch64 ollm source); compiled to OUT/ollm. 20 note 7. wpatch: OUT/wpatch-all.om is `om2`, layout, OUT/ollm.om without its `om2` line and with 21 note `fn main to int` (exactly one such line) renamed `fn wpollm to int`, functions, wpatch.om; 22 note compiled to OUT/wpatch. 23 note Each compile runs taskset -c CORE nice -n 19 OMC into a .new file, which is made executable and 24 note renamed over the target. A compile error removes the .new file and exits with omc's status. 25 note Finally sha256sum prints OMC, the SHA source, ollm.om, ollm, both compositions and both binaries. 26 note Exit codes: 2 usage, 3 a pinned digest differs (compiler, SHA source or net source), 4 main 27 note count, 5 I/O or capacity, 6 a tool failed (its status is printed), otherwise omc's own status. 28 om2 29 30 global sb uchar 65536 31 global sl ulong 128 32 global pb uchar 4096 33 global pn ulong 1 34 global av uchar 4096 35 global ap ulong 2 36 global stb uchar 4 37 global inb uchar `8388608` 38 global bn ulong 1 39 global ob uchar `8388608` 40 global obn ulong 1 41 global lay uchar 4096 42 global lan ulong 1 43 global fns uchar 65536 44 global fnn ulong 1 45 global cap uchar 4096 46 global capn ulong 1 47 global dig uchar 32 48 text PIN "`e5b32567a7aff3ce594e3254a622a846a6cd190b`:om/sha256/sha256-om2.om" 49 text SHASRC "`dbf002dd6aa36585632b9d01d98ac3f0bd2fa0f0475082940de53638847994bb`" 50 text OMCPIN "`2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f`" 51 text NPHTTP "`aff258ecd3858454056811a5e6fe1f660f9d650a7207d6c41885105110e046a7`" 52 text NPJSON "`456254fc754ea35103ced480407b24fc1a3896d094b90ae0e9623e7b6594e2d2`" 53 text NPJSONW "`464f649e8207495f5d67fe8795d31e42ea3ccebd9ed547274dab802d4f7c5f21`" 54 text SHTTP "/train/omega-llm/native/net/http.om" 55 text SJSON "/train/omega-llm/native/net/json.om" 56 text SJSONW "/train/omega-llm/native/net/jsonw.om" 57 text SMATH "/train/omega-llm/native/math.om" 58 text SDATA "/train/omega-llm/native/data.om" 59 text SLPOOL "/train/omega-llm/native/lpool.om" 60 text SMODEL "/train/omega-llm/native/model.om" 61 text SADAM "/train/omega-llm/native/adam.om" 62 text SCKPT "/train/omega-llm/native/ckpt.om" 63 text SBPE "/train/omega-llm/native/bpe.om" 64 text SSPEC "/train/omega-llm/native/spec.om" 65 text SCLI "/train/omega-llm/native/cli.om" 66 text SLIO "/train/omega-llm/native/lio.om" 67 text SSERVE "/train/omega-llm/native/serve.om" 68 text SNOGPU "/train/omega-llm/native/nogpu.om" 69 text CSUM "sum" 70 text OLDW "kinit iv sched rounds compress run blocks finish tobuf absorb " 71 text NEWW "wskinit wsiv wssched wsround wscomp wsrun wsblks wsfin wstobuf wsabsb " 72 text GIT "/usr/bin/git" 73 text GC "-C" 74 text GSHOW "show" 75 text SUM "/usr/bin/sha256sum" 76 text DIFF "/usr/bin/diff" 77 text DU "-u" 78 text TSET "/usr/bin/taskset" 79 text TC "-c" 80 text NICE "/usr/bin/nice" 81 text NN "-n" 82 text N19 "19" 83 text OM2 "om2" 84 text LSTART "layout shactx 104" 85 text LEND "end" 86 text EXPFN "export fn " 87 text NOTE "note" 88 text MAINL "fn main to int" 89 text WPOLLM "fn wpollm to int\n" 90 text OM2NL "om2\n" 91 text FSRC "/sha256-source.om" 92 text FLAY "/sha256-layout.om" 93 text FFNS "/sha256-functions.om" 94 text FVEN "/sha256-vendored.om" 95 text FDIF "/sha256.diff" 96 text FOLLM "/ollm.om" 97 text FONEW "/ollm.new" 98 text FOL "/ollm" 99 text FWPS "/train/omega-llm/tools/wpatch/wpatch.om" 100 text FCKS "/train/omega-llm/tools/wpatch/wpcheck.om" 101 text FWALL "/wpatch-all.om" 102 text FCALL "/wpcheck-all.om" 103 text FWNEW "/wpatch.new" 104 text FCNEW "/wpcheck.new" 105 text FWP "/wpatch" 106 text FCK "/wpcheck" 107 text MUSAGE "WPBUILD FAIL usage: wpbuild REPO OUT OMC OMEGA_MV CORE\n" 108 text MIO "WPBUILD FAIL I/O or capacity: " 109 text MTOOL "WPBUILD FAIL tool exit " 110 text MSHA "WPBUILD FAIL SHA-256 source digest differs from the pin\n" 111 text MOMCP "WPBUILD FAIL omc digest differs from the pin\n" 112 text MNET "WPBUILD FAIL net source digest differs from the pin: " 113 text MMAIN "WPBUILD FAIL ollm.om must hold exactly one line `fn main to int`, found " 114 text MOMC "WPBUILD FAIL omc exit " 115 text MOK "WPBUILD PASS\n" 116 text NL "\n" 117 118 note ---- output, slots and argument packets -------------------------------------------------- 119 fn say s view uchar * to void 120 r = write 1 s 0 len s 121 end 122 fn saynum v ulong to void 123 x = v 124 n = ulong 0 125 while ge x 10 126 put dig n uchar add 48 rem x 10 127 x = div x 10 128 n = add n 1 129 end 130 put dig n uchar add 48 x 131 for i ulong add n 1 132 r = write 1 dig sub n i 1 133 end 134 end 135 fn saypb to void 136 r = write 1 pb 0 get pn 0 137 end 138 fn die c ulong m view uchar * to void 139 say m 140 exit int c 141 end 142 fn dieio to void 143 say MIO 144 saypb 145 say NL 146 exit 5 147 end 148 fn pclear to void 149 put pn 0 0 150 end 151 fn pbyte b uchar to void 152 n = get pn 0 153 if ge n 4095 154 dieio 155 end 156 put pb n b 157 put pn 0 add n 1 158 end 159 fn ptext s view uchar * to void 160 for i ulong len s 161 pbyte get s i 162 end 163 end 164 note Slot k is 512 bytes of sb at k * 512, its length in sl. 165 fn pslot k ulong to void 166 o = mul k 512 167 for i ulong get sl k 168 pbyte get sb add o i 169 end 170 end 171 fn keepat k ulong to void 172 n = get pn 0 173 if gt n 512 174 dieio 175 end 176 o = mul k 512 177 for i ulong n 178 put sb add o i get pb i 179 end 180 put sl k n 181 end 182 fn argslot i ulong k ulong to void 183 r = argread i pb 0 512 184 if le r 0 185 die 2 MUSAGE 186 end 187 put pn 0 ulong r 188 keepat k 189 end 190 note slot k = slot base followed by text s 191 fn under k ulong base ulong s view uchar * to void 192 pclear 193 pslot base 194 ptext s 195 keepat k 196 end 197 fn aclear to void 198 put ap 0 2 199 put ap 1 0 200 end 201 fn apb to void 202 p = get ap 0 203 n = get pn 0 204 if or gt add add p n 2 len av ge get ap 1 64 205 dieio 206 end 207 put av p uchar and n 255 208 put av add p 1 uchar shr n 8 209 for i ulong n 210 put av add add p 2 i get pb i 211 end 212 put ap 0 add add p 2 n 213 put ap 1 add get ap 1 1 214 end 215 fn atext s view uchar * to void 216 pclear 217 ptext s 218 apb 219 end 220 fn aslot k ulong to void 221 pclear 222 pslot k 223 apb 224 end 225 fn popen k ulong fl int to int 226 pclear 227 pslot k 228 r = fopen pb 0 get pn 0 fl 420 229 if lt r 0 230 dieio 231 end 232 ret int r 233 end 234 fn redir s int d int to void 235 if ne s d 236 if ne dupfd s d 0 long d 237 exit 127 238 end 239 end 240 end 241 note Run the packet in av with stdin fi and stdout fo (-1 inherits); return the exit status, or 242 note 256 + the signal number when the child was killed. 243 fn spawn fi int fo int to ulong 244 put av 0 uchar and get ap 1 255 245 put av 1 uchar shr get ap 1 8 246 pid = fork 247 if lt pid 0 248 dieio 249 end 250 if eq pid 0 251 if ge fi 0 252 redir fi 0 253 end 254 if ge fo 0 255 redir fo 1 256 end 257 r = execprog av 0 get ap 0 258 exit 127 259 end 260 if ge fi 0 261 r = fclose fi 262 end 263 if ge fo 0 264 r = fclose fo 265 end 266 w = waitpid int pid stb 0 4 0 267 if ne w long pid 268 dieio 269 end 270 if ne get stb 0 0 271 ret add 256 ulong and get stb 0 127 272 end 273 ret ulong get stb 1 274 end 275 fn tool fi int fo int to void 276 x = spawn fi fo 277 if ne x 0 278 say MTOOL 279 saynum x 280 say NL 281 exit 6 282 end 283 end 284 fn waitok pid long to void 285 w = waitpid int pid stb 0 4 0 286 bad = or ne get stb 0 0 ne get stb 1 0 287 if or ne w pid bad 288 say MTOOL 289 saynum ulong get stb 1 290 say NL 291 exit 6 292 end 293 end 294 note Run the packet with stdout read back through a pipe into cap (at most 4096 bytes). 295 fn capture to void 296 put av 0 uchar and get ap 1 255 297 put av 1 uchar shr get ap 1 8 298 pf = new uchar 8 0 299 if ne pipefds pf 0 8 0 0 300 dieio 301 end 302 rd = int or ulong get pf 0 shl ulong get pf 1 8 303 wr = int or ulong get pf 4 shl ulong get pf 5 8 304 pid = fork 305 if lt pid 0 306 dieio 307 end 308 if eq pid 0 309 r = fclose rd 310 redir wr 1 311 r = execprog av 0 get ap 0 312 exit 127 313 end 314 r = fclose wr 315 n = ulong 0 316 k = long 1 317 while gt k 0 318 k = read rd cap n sub len cap n 319 if gt k 0 320 n = add n ulong k 321 end 322 end 323 r = fclose rd 324 put capn 0 n 325 waitok pid 326 end 327 328 note ---- whole files --------------------------------------------------------------------------- 329 fn slurp k ulong to void 330 fd = popen k 0 331 n = ulong 0 332 k2 = long 1 333 while gt k2 0 334 if eq n len inb 335 dieio 336 end 337 k2 = read fd inb n sub len inb n 338 if lt k2 0 339 dieio 340 end 341 n = add n ulong k2 342 end 343 r = fclose fd 344 put bn 0 n 345 end 346 fn obyte b uchar to void 347 n = get obn 0 348 if ge n len ob 349 dieio 350 end 351 put ob n b 352 put obn 0 add n 1 353 end 354 fn otext s view uchar * to void 355 for i ulong len s 356 obyte get s i 357 end 358 end 359 fn obig o ulong n ulong to void 360 for i ulong n 361 obyte get inb add o i 362 end 363 end 364 fn olay to void 365 for i ulong get lan 0 366 obyte get lay i 367 end 368 end 369 fn ofns to void 370 for i ulong get fnn 0 371 obyte get fns i 372 end 373 end 374 note Write ob to slot k, created or truncated. 375 fn spill k ulong to void 376 fd = popen k 577 377 n = get obn 0 378 p = ulong 0 379 while lt p n 380 r = write fd ob p sub n p 381 if le r 0 382 dieio 383 end 384 p = add p ulong r 385 end 386 if ne fclose fd 0 387 dieio 388 end 389 put obn 0 0 390 end 391 392 note ---- line tests on inb ----------------------------------------------------------------------- 393 note end of the line starting at o (index of its LF, or bn) 394 fn eol o ulong to ulong 395 n = get bn 0 396 e = o 397 while lt e n 398 if eq get inb e 10 399 ret e 400 end 401 e = add e 1 402 end 403 ret n 404 end 405 fn lineis o ulong e ulong s view uchar * to bool 406 if ne sub e o len s 407 ret false 408 end 409 for i ulong len s 410 if ne get inb add o i get s i 411 ret false 412 end 413 end 414 ret true 415 end 416 fn starts o ulong e ulong s view uchar * to bool 417 if lt sub e o len s 418 ret false 419 end 420 for i ulong len s 421 if ne get inb add o i get s i 422 ret false 423 end 424 end 425 ret true 426 end 427 fn wordch c ulong to bool 428 a = and ge c 48 le c 57 429 b = and ge c 65 le c 90 430 d = and ge c 97 le c 122 431 ret or or a b or d eq c 95 432 end 433 note position (0..9) of inb[o..e) among the words of OLDW, or 10 434 fn oldword o ulong e ulong to ulong 435 w = ulong 0 436 s = ulong 0 437 for i ulong len OLDW 438 if eq get OLDW i 32 439 if eq sub i s sub e o 440 same = true 441 for j ulong sub i s 442 if ne get OLDW add s j get inb add o j 443 same = false 444 end 445 end 446 if same 447 ret w 448 end 449 end 450 w = add w 1 451 s = add i 1 452 end 453 end 454 ret 10 455 end 456 fn fbyte b uchar to void 457 n = get fnn 0 458 if ge n len fns 459 dieio 460 end 461 put fns n b 462 put fnn 0 add n 1 463 end 464 fn newword w ulong to void 465 k = ulong 0 466 for i ulong len NEWW 467 c = get NEWW i 468 if eq c 32 469 k = add k 1 470 else 471 if eq k w 472 fbyte c 473 end 474 end 475 end 476 end 477 note one functions line inb[o..e) plus its LF (when e < bn) 478 fn fnline o ulong e ulong to void 479 p = o 480 if starts o e EXPFN 481 p = add o 7 482 end 483 if starts o e NOTE 484 for i ulong sub e p 485 fbyte get inb add p i 486 end 487 else 488 while lt p e 489 if wordch ulong get inb p 490 q = p 491 while and lt q e wordch ulong get inb q 492 q = add q 1 493 end 494 w = oldword p q 495 if lt w 10 496 newword w 497 else 498 for i ulong sub q p 499 fbyte get inb add p i 500 end 501 end 502 p = q 503 else 504 fbyte get inb p 505 p = add p 1 506 end 507 end 508 end 509 if lt e get bn 0 510 fbyte 10 511 end 512 end 513 fn lbyte b uchar to void 514 n = get lan 0 515 if ge n len lay 516 dieio 517 end 518 put lay n b 519 put lan 0 add n 1 520 end 521 note Split the SHA source in inb into lay and fns (step 3). 522 fn split to void 523 n = get bn 0 524 put lan 0 0 525 put fnn 0 0 526 o = ulong 0 527 inl = false 528 while lt o n 529 e = eol o 530 if inl 531 for i ulong sub e o 532 lbyte get inb add o i 533 end 534 lbyte 10 535 if lineis o e LEND 536 inl = false 537 end 538 else 539 if lineis o e LSTART 540 inl = true 541 for i ulong sub e o 542 lbyte get inb add o i 543 end 544 lbyte 10 545 else 546 if not lineis o e OM2 547 fnline o e 548 end 549 end 550 end 551 o = add e 1 552 end 553 end 554 note Append ollm.om (in inb) to ob without `om2` and with main renamed; return the main count. 555 fn oollm to ulong 556 n = get bn 0 557 c = ulong 0 558 o = ulong 0 559 while lt o n 560 e = eol o 561 if lineis o e MAINL 562 otext WPOLLM 563 c = add c 1 564 else 565 if not lineis o e OM2 566 obig o sub e o 567 if lt e n 568 obyte 10 569 end 570 end 571 end 572 o = add e 1 573 end 574 ret c 575 end 576 577 note ---- steps ----------------------------------------------------------------------------------- 578 note slots: 0 REPO, 1 OUT, 2 OMC, 3 OMEGA_MV, 4 CORE, 5 scratch, 6 source, 7 vendored, 8 all, 9 new 579 note true when the captured output starts with the 64 hex digits s 580 fn capis s view uchar * to bool 581 if lt get capn 0 64 582 ret false 583 end 584 for i ulong 64 585 if ne get cap i get s i 586 ret false 587 end 588 end 589 ret true 590 end 591 fn stepomc to void 592 aclear 593 atext SUM 594 aslot 2 595 capture 596 if not capis OMCPIN 597 die 3 MOMCP 598 end 599 end 600 fn stepsrc to void 601 under 6 1 FSRC 602 aclear 603 atext GIT 604 atext GC 605 aslot 3 606 atext GSHOW 607 atext PIN 608 tool -1 popen 6 577 609 aclear 610 atext SUM 611 aslot 6 612 capture 613 if not capis SHASRC 614 die 3 MSHA 615 end 616 end 617 note `OUT/wpcheck sum REPO s` (vendored Omega SHA-256) must print the pin p. 618 fn netpin s view uchar * p view uchar * to void 619 under 5 1 FCK 620 aclear 621 aslot 5 622 atext CSUM 623 under 5 0 s 624 aslot 5 625 capture 626 if not capis p 627 say MNET 628 pclear 629 pslot 5 630 saypb 631 say NL 632 exit 3 633 end 634 end 635 note append the whole file REPO s to ob 636 fn ofile s view uchar * to void 637 under 5 0 s 638 slurp 5 639 obig 0 get bn 0 640 end 641 fn stepollm to void 642 netpin SHTTP NPHTTP 643 netpin SJSON NPJSON 644 netpin SJSONW NPJSONW 645 otext OM2NL 646 ofile SHTTP 647 ofile SJSON 648 ofile SJSONW 649 ofile SMATH 650 ofile SDATA 651 ofile SLPOOL 652 ofile SMODEL 653 ofile SADAM 654 ofile SCKPT 655 ofile SBPE 656 ofile SSPEC 657 ofile SCLI 658 ofile SLIO 659 ofile SSERVE 660 ofile SNOGPU 661 under 8 1 FOLLM 662 spill 8 663 under 9 1 FONEW 664 compile FOL 665 end 666 fn stepvend to void 667 slurp 6 668 split 669 under 5 1 FLAY 670 olay 671 spill 5 672 under 5 1 FFNS 673 ofns 674 spill 5 675 under 7 1 FVEN 676 otext OM2NL 677 olay 678 ofns 679 spill 7 680 under 5 1 FDIF 681 aclear 682 atext DIFF 683 atext DU 684 aslot 6 685 aslot 7 686 x = spawn -1 popen 5 577 687 if ne x 1 688 say MTOOL 689 saynum x 690 say NL 691 exit 6 692 end 693 end 694 fn compose to void 695 under 5 1 FOLLM 696 slurp 5 697 otext OM2NL 698 olay 699 c = oollm 700 if ne c 1 701 say MMAIN 702 saynum c 703 say NL 704 exit 4 705 end 706 ofns 707 under 5 0 FWPS 708 slurp 5 709 obig 0 get bn 0 710 under 8 1 FWALL 711 spill 8 712 end 713 fn composeck to void 714 otext OM2NL 715 olay 716 ofns 717 under 5 0 FCKS 718 slurp 5 719 obig 0 get bn 0 720 under 8 1 FCALL 721 spill 8 722 end 723 note Compile slot 8 into slot 9 (the .new file), then rename it to dst (a text under OUT). 724 fn compile dst view uchar * to void 725 aclear 726 atext TSET 727 atext TC 728 aslot 4 729 atext NICE 730 atext NN 731 atext N19 732 aslot 2 733 x = spawn popen 8 0 popen 9 577 734 if ne x 0 735 pclear 736 pslot 9 737 r = unlink pb 0 get pn 0 738 say MOMC 739 saynum x 740 say NL 741 exit int x 742 end 743 pclear 744 pslot 9 745 if ne chmod pb 0 get pn 0 493 0 746 dieio 747 end 748 under 5 1 dst 749 aclear 750 aslot 9 751 aslot 5 752 put av 0 2 753 put av 1 0 754 if ne renames av 0 get ap 0 0 0 755 dieio 756 end 757 end 758 fn main to int 759 if ne argcnt 6 760 die 2 MUSAGE 761 end 762 for i ulong 5 763 argslot add i 1 i 764 end 765 pclear 766 pslot 1 767 r = makedir pb 0 get pn 0 493 768 if and lt r 0 ne r -17 769 dieio 770 end 771 stepomc 772 stepsrc 773 stepvend 774 composeck 775 under 9 1 FCNEW 776 compile FCK 777 stepollm 778 compose 779 under 9 1 FWNEW 780 compile FWP 781 aclear 782 atext SUM 783 aslot 2 784 aslot 6 785 under 5 1 FOLLM 786 aslot 5 787 under 5 1 FOL 788 aslot 5 789 under 5 1 FCALL 790 aslot 5 791 under 5 1 FCK 792 aslot 5 793 under 5 1 FWALL 794 aslot 5 795 under 5 1 FWP 796 aslot 5 797 tool -1 -1 798 say MOK 799 ret 0 800 end