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/aien-train/blob/main/native/omegese45/hive/hive.om # aien-train AIEN training programme: language-model history, GB10 constraints and the route to training on the project engine. Plans and runnable checks are distinguished. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-train / native / omegese45 / hive / hive.om` 1380 lines ยท 21701 bytes Raw Blame History 1 note SPDX-License-Identifier: AGPL-3.0-only 2 note OE45 hive driver (aien-train #45, demo lane). One bounded episode: 3 note validated goal G -> core decode -> act A -> Aienet-0 microjob -> R -> rep P. 4 note Build: cat native/omegese45/vocab.om native/omegese45/msg.om 5 note native/omegese45/mjr1.om native/omegese45/hive/hive.om | omc 6 note Usage: hive CONF, run with the case directory as the current directory. 7 note CONF holds 15 lines, one value each, in this order: 8 note 0 RUN 1 SERVE 2 KEYS 3 PINS 4 WKEYS 5 WPINS 6 WSTATE 7 RECOMP 9 note 8 RECSHA 9 ADDR 10 CORE 11 CKPT 12 MODE (U|G) 13 VERIFIER hex 10 note 14 ACCEPT timeout seconds. 11 note Case directory: goal.oe45 (one G line) in; episode.oe45 (append-only 12 note journal, oe45 v1), dispatch.log, hive.log, facts.tsv, disp/, out/, logs/. 13 note The journal holds profile lines only. An A job line is the intent and is 14 note synced before its dispatch; its R line is synced after. A restart rescans 15 note the journal; an A job without R is reconciled with --retry, so the worker 16 note returns its cached receipt instead of executing a second time. 17 note Exits: 0 episode complete (P journaled, facts.tsv written); 61 usage or 18 note config; 62 binding refused before dispatch; 63 decode failed after one 19 note guided repair, or checkpoint refused; 64 journal, goal or policy guard; 20 note 65 driver I/O or spawn failure; 66 unmapped aienet0-run exit or an 21 note inconsistent VERIFIED/MJR1; 69 bundle payload differs from the lowered A. 22 23 const ohnw ulong 89 24 const ohncf ulong 15 25 text ohw "run bundle --listen --keys --pins --out --recompute --recompute-sha256 --resend --accept-timeout --m --k --n --seed --connect --state --connect-timeout --retry decode episode.oe45 facts.tsv dispatch.log hive.log /dev/null disp out logs goal.oe45 intent outcome res ok refused fail end transport replay budget worker receipt recomp verdict io .an0b .mjr1 .fact .out .err serve bind - VERIFIED REFUSED WORKER AN0_REPLAY AN0_OVER_BUDGET MJB_OVER_BUDGET dag_id= reconcile repair G oe45 v1 job attempt m k n seed exit class code dag_id mjr1_sha256 mjr1_outcome verifier 30 done rc= hive: decoded dispatch retry new lower HIVE_DONE journal torn refuse" 26 27 const ohxrun ulong 0 28 const ohxbund ulong 1 29 const ohxlist ulong 2 30 const ohxkeys ulong 3 31 const ohxpins ulong 4 32 const ohxout ulong 5 33 const ohxrec ulong 6 34 const ohxrecs ulong 7 35 const ohxresnd ulong 8 36 const ohxacct ulong 9 37 const ohxm ulong 10 38 const ohxconn ulong 14 39 const ohxstate ulong 15 40 const ohxcto ulong 16 41 const ohxretry ulong 17 42 const ohxdec ulong 18 43 const ohxep ulong 19 44 const ohxfacts ulong 20 45 const ohxdlog ulong 21 46 const ohxhlog ulong 22 47 const ohxnull ulong 23 48 const ohxdisp ulong 24 49 const ohxodir ulong 25 50 const ohxlogs ulong 26 51 const ohxgoal ulong 27 52 const ohxint ulong 28 53 const ohxoutc ulong 29 54 const ohxres ulong 30 55 const ohxok ulong 31 56 const ohxrefd ulong 32 57 const ohxfail ulong 33 58 const ohxend ulong 34 59 const ohxtrans ulong 35 60 const ohxrepl ulong 36 61 const ohxbudg ulong 37 62 const ohxwork ulong 38 63 const ohxrcpt ulong 39 64 const ohxrcmp ulong 40 65 const ohxverd ulong 41 66 const ohxio ulong 42 67 const ohxan0b ulong 43 68 const ohxmjr1 ulong 44 69 const ohxfact ulong 45 70 const ohxsout ulong 46 71 const ohxserr ulong 47 72 const ohxserve ulong 48 73 const ohxbind ulong 49 74 const ohxdash ulong 50 75 const ohxverif ulong 51 76 const ohxworkr ulong 53 77 const ohxa0rep ulong 54 78 const ohxa0bud ulong 55 79 const ohxmjbud ulong 56 80 const ohxdagid ulong 57 81 const ohxrecon ulong 58 82 const ohxrepr ulong 59 83 const ohxg ulong 60 84 const ohxhdr ulong 63 85 const ohxcto30 ulong 76 86 const ohxdone ulong 77 87 const ohxrceq ulong 78 88 const ohxhive ulong 79 89 const ohxdecd ulong 80 90 const ohxdsp ulong 81 91 const ohxnew ulong 83 92 const ohxlower ulong 84 93 const ohxhdone ulong 85 94 const ohxjour ulong 86 95 const ohxtorn ulong 87 96 const ohxrefu ulong 88 97 98 note Configuration slots. 99 const ohcrun ulong 0 100 const ohcserve ulong 1 101 const ohckeys ulong 2 102 const ohcpins ulong 3 103 const ohcwkeys ulong 4 104 const ohcwpins ulong 5 105 const ohcwst ulong 6 106 const ohcrec ulong 7 107 const ohcrecs ulong 8 108 const ohcaddr ulong 9 109 const ohccore ulong 10 110 const ohcckpt ulong 11 111 const ohcmode ulong 12 112 const ohcverif ulong 13 113 const ohcacct ulong 14 114 115 note Driver state slots in ohv. 116 const ohspid ulong 0 117 const ohsseq ulong 1 118 const ohslast ulong 2 119 const ohsjob ulong 3 120 const ohsatt ulong 4 121 const ohstr ulong 5 122 const ohsnmod ulong 6 123 const ohsnal ulong 7 124 const ohsnf ulong 8 125 const ohsdag ulong 9 126 const ohssha ulong 10 127 const ohsjobs ulong 11 128 const ohsout ulong 12 129 const ohsdecs ulong 13 130 const ohscls ulong 14 131 const ohscode ulong 15 132 133 note Last journal kinds kept in ohv[ohslast]. 134 const ohkg ulong 1 135 const ohkajob ulong 2 136 const ohkr ulong 3 137 const ohkp ulong 4 138 const ohkaref ulong 5 139 140 global ohwo ulong 96 141 global ohwl ulong 96 142 global ohcf uchar 8192 143 global ohco ulong 16 144 global ohcl ulong 16 145 global ohb uchar 65536 146 global ohbn ulong 1 147 global oht uchar 4096 148 global ohtn ulong 1 149 global ohd uchar 4096 150 global ohdn ulong 1 151 global ohpk uchar 4096 152 global ohpv ulong 2 153 global oho uchar 512 154 global ohe uchar 512 155 global ohio ulong 2 156 global ohst uchar 8 157 global ohsb uchar 128 158 global ohal uchar 512 159 global ohv ulong 32 160 global ohfj ulong 16 161 global ohdag uchar 64 162 global ohsha uchar 64 163 164 note Split ohw into word offsets and lengths. 165 fn ohwinit to void 166 p = ulong 0 167 for i ulong ohnw 168 put ohwo i p 169 s = p 170 while lt p len ohw bound 4096 171 if eq get ohw p 32 172 break 173 end 174 p = add p 1 175 end 176 put ohwl i sub p s 177 p = add p 1 178 end 179 end 180 181 fn ohtclr to void 182 put ohtn 0 0 183 end 184 185 fn ohtc c uchar to void 186 n = get ohtn 0 187 if ge n len oht 188 exit 65 189 end 190 put oht n c 191 put ohtn 0 add n 1 192 end 193 194 fn ohtw w ulong to void 195 o = get ohwo w 196 for j ulong get ohwl w 197 ohtc get ohw add o j 198 end 199 end 200 201 fn ohtk i ulong to void 202 o = get ohco i 203 for j ulong get ohcl i 204 ohtc get ohcf add o j 205 end 206 end 207 208 fn ohtd v ulong to void 209 dg = new uchar 20 0 210 x = v 211 c = ulong 0 212 while true bound 21 213 put dg c uchar rem x 10 214 c = add c 1 215 x = div x 10 216 if eq x 0 217 break 218 end 219 end 220 for j ulong c 221 ohtc add 48 get dg sub sub c 1 j 222 end 223 end 224 225 note Append ohb[o..o+n). 226 fn ohtb o ulong n ulong to void 227 for j ulong n 228 ohtc get ohb add o j 229 end 230 end 231 232 fn ohtdag to void 233 if eq get ohv ohsdag 1 234 for j ulong 64 235 ohtc get ohdag j 236 end 237 else 238 ohtw ohxdash 239 end 240 end 241 242 fn ohtsha to void 243 if eq get ohv ohssha 1 244 for j ulong 64 245 ohtc get ohsha j 246 end 247 else 248 ohtw ohxdash 249 end 250 end 251 252 note Copy the builder into the data, stdout-path, stderr-path or ocin buffers. 253 fn ohtod to void 254 n = get ohtn 0 255 for j ulong n 256 put ohd j get oht j 257 end 258 put ohdn 0 n 259 end 260 261 fn ohtoo to void 262 n = get ohtn 0 263 if gt n len oho 264 exit 65 265 end 266 for j ulong n 267 put oho j get oht j 268 end 269 put ohio 0 n 270 end 271 272 fn ohtoe to void 273 n = get ohtn 0 274 if gt n len ohe 275 exit 65 276 end 277 for j ulong n 278 put ohe j get oht j 279 end 280 put ohio 1 n 281 end 282 283 fn ohtoin to ulong 284 n = get ohtn 0 285 for j ulong n 286 put ocin j get oht j 287 end 288 ret n 289 end 290 291 fn ohotot to void 292 ohtclr 293 for j ulong get ohio 0 294 ohtc get oho j 295 end 296 end 297 298 fn ohetot to void 299 ohtclr 300 for j ulong get ohio 1 301 ohtc get ohe j 302 end 303 end 304 305 note Packed argument list for execprog: u16 count, then u16 length + bytes. 306 fn ohpkclr to void 307 put ohpv 0 0 308 put ohpv 1 2 309 end 310 311 fn ohpkt to void 312 c = get ohpv 0 313 p = get ohpv 1 314 n = get ohtn 0 315 if or ge c 64 gt add add p 2 n len ohpk 316 exit 65 317 end 318 put ohpk p uchar and n 255 319 put ohpk add p 1 uchar shr n 8 320 for j ulong n 321 put ohpk add add p 2 j get oht j 322 end 323 put ohpv 0 add c 1 324 put ohpv 1 add add p 2 n 325 end 326 327 fn ohpkfin to ulong 328 c = get ohpv 0 329 put ohpk 0 uchar and c 255 330 put ohpk 1 uchar shr c 8 331 ret get ohpv 1 332 end 333 334 fn ohpw w ulong to void 335 ohtclr 336 ohtw w 337 ohpkt 338 end 339 340 fn ohpkk i ulong to void 341 ohtclr 342 ohtk i 343 ohpkt 344 end 345 346 fn ohpd v ulong to void 347 ohtclr 348 ohtd v 349 ohpkt 350 end 351 352 note Read the file named by the builder into ohb. Returns bytes or -errno. 353 fn ohrdf to long 354 fd = fopen oht 0 get ohtn 0 0 0 355 if lt fd 0 356 ret fd 357 end 358 t = ulong 0 359 fin = false 360 while and lt t len ohb not fin bound 70000 361 r = read int fd ohb t sub len ohb t 362 if lt r 0 363 c = fclose int fd 364 ret r 365 end 366 if eq r 0 367 fin = true 368 end 369 t = add t ulong r 370 end 371 c = fclose int fd 372 put ohbn 0 t 373 if not fin 374 ret neg long 27 375 end 376 ret long t 377 end 378 379 note Write ohd to the file named by the builder with open flags fl, then fsync. 380 fn ohwrd fl int to void 381 fd = fopen oht 0 get ohtn 0 fl 420 382 if lt fd 0 383 exit 65 384 end 385 n = get ohdn 0 386 t = ulong 0 387 while lt t n bound 5000 388 w = write int fd ohd t sub n t 389 if le w 0 390 exit 65 391 end 392 t = add t ulong w 393 end 394 s = fsync int fd 395 if lt s 0 396 exit 65 397 end 398 c = fclose int fd 399 end 400 401 note Copy ohb[0..n) into ohd. 402 fn ohbtod n ulong to void 403 if gt n len ohd 404 exit 65 405 end 406 for j ulong n 407 put ohd j get ohb j 408 end 409 put ohdn 0 n 410 end 411 412 note Builder holds a line without LF: append it to stdout and hive.log. 413 fn ohlog to void 414 ohtc 10 415 ohtod 416 n = get ohdn 0 417 t = ulong 0 418 while lt t n bound 5000 419 w = write 1 ohd t sub n t 420 if le w 0 421 exit 65 422 end 423 t = add t ulong w 424 end 425 ohtclr 426 ohtw ohxhlog 427 ohwrd 1089 428 end 429 430 note Builder holds a line without LF: append it to the named log file w. 431 fn ohappw w ulong to void 432 ohtc 10 433 ohtod 434 ohtclr 435 ohtw w 436 ohwrd 1089 437 end 438 439 fn ohhead w ulong to void 440 ohtclr 441 ohtw ohxhive 442 ohtc 32 443 ohtw w 444 end 445 446 note Per-spawn stdout and stderr files: logs/--.out|.err 447 fn ohsetio tag ulong to void 448 q = get ohv ohsseq 449 put ohv ohsseq add q 1 450 ohtclr 451 ohtw ohxlogs 452 ohtc 47 453 ohtd get ohv ohspid 454 ohtc 45 455 ohtd q 456 ohtc 45 457 ohtw tag 458 b = get ohtn 0 459 ohtw ohxsout 460 ohtoo 461 put ohtn 0 b 462 ohtw ohxserr 463 ohtoe 464 end 465 466 note Fork and exec the packed list with an empty environment; stdin from 467 note /dev/null, stdout and stderr into the ohsetio files. Returns the pid. 468 fn ohspawn to long 469 pn = ohpkfin 470 pid = fork 471 if lt pid 0 472 exit 65 473 end 474 if eq pid 0 475 ohtclr 476 ohtw ohxnull 477 f0 = fopen oht 0 get ohtn 0 0 0 478 f1 = fopen oho 0 get ohio 0 577 420 479 f2 = fopen ohe 0 get ohio 1 577 420 480 if or or lt f0 0 lt f1 0 lt f2 0 481 exit 65 482 end 483 d0 = dupfd int f0 0 0 484 d1 = dupfd int f1 1 0 485 d2 = dupfd int f2 2 0 486 c0 = fclose int f0 487 c1 = fclose int f1 488 c2 = fclose int f2 489 e = execprog ohpk 0 pn 490 exit 65 491 end 492 ret pid 493 end 494 495 note Wait for pid; exit code, or 128 + signal. 496 fn ohwait pid long to long 497 r = waitpid int pid ohst 0 4 0 498 while eq r neg long 4 bound 1000 499 r = waitpid int pid ohst 0 4 0 500 end 501 if lt r 0 502 exit 65 503 end 504 s = uint get ohst 0 505 s = or s shl uint get ohst 1 8 506 s = or s shl uint get ohst 2 16 507 s = or s shl uint get ohst 3 24 508 if eq and s 127 0 509 ret long and shr s 8 255 510 end 511 ret add long and s 127 128 512 end 513 514 fn ohconf to void 515 if ne argcnt 2 516 exit 61 517 end 518 r = argread 1 oht 0 4096 519 if lt r 1 520 exit 61 521 end 522 put ohtn 0 ulong r 523 k = ohrdf 524 if or lt k 1 gt k 8192 525 exit 61 526 end 527 n = ulong k 528 i = ulong 0 529 s = ulong 0 530 for p ulong n 531 c = get ohb p 532 put ohcf p c 533 if eq c 10 534 if or ge i ohncf eq p s 535 exit 61 536 end 537 put ohco i s 538 put ohcl i sub p s 539 i = add i 1 540 s = add p 1 541 end 542 end 543 if or ne i ohncf ne s n 544 exit 61 545 end 546 end 547 548 fn ohmkdir w ulong to void 549 ohtclr 550 ohtw w 551 r = makedir oht 0 get ohtn 0 493 552 if and lt r 0 ne r neg long 17 553 exit 65 554 end 555 end 556 557 note Sync the case directory so a new journal name survives a crash. 558 fn ohsyncd to void 559 ohtclr 560 ohtc 46 561 fd = fopen oht 0 1 0 0 562 if lt fd 0 563 exit 65 564 end 565 s = fsync int fd 566 c = fclose int fd 567 if lt s 0 568 exit 65 569 end 570 end 571 572 note Create episode.oe45 = "oe45 v1" + G from goal.oe45 if it does not exist. 573 fn ohinitj to void 574 ohtclr 575 ohtw ohxep 576 s = stat oht 0 get ohtn 0 ohsb 0 128 577 if ge s 0 578 ret 579 end 580 ohtclr 581 ohtw ohxgoal 582 k = ohrdf 583 if lt k 2 584 exit 64 585 end 586 n = ulong k 587 for p ulong sub n 1 588 if eq get ohb p 10 589 exit 64 590 end 591 end 592 if ne get ohb sub n 1 10 593 exit 64 594 end 595 ohtclr 596 ohtb 0 sub n 1 597 g = ohtoin 598 r = ocsetgl g 599 if lt r 0 600 exit 64 601 end 602 ohtclr 603 ohtw 61 604 ohtc 32 605 ohtw 62 606 ohtc 10 607 ohtb 0 n 608 ohtod 609 ohtclr 610 ohtw ohxep 611 ohwrd 193 612 ohsyncd 613 end 614 615 note v1.3 episode shape, checked both while replaying and before journaling/dispatch. 616 note Refuse is the first and only A; its P must be refused bound. P needs an A. 617 fn ohorder k ulong to void 618 last = get ohv ohslast 619 if eq k 2 620 if and ne last ohkg ne last ohkr 621 exit 64 622 end 623 if and eq get ocids 1 9 ne last ohkg 624 exit 64 625 end 626 end 627 if eq k 4 628 if and ne last ohkr ne last ohkaref 629 exit 64 630 end 631 if eq last ohkaref 632 if or ne get ocids 1 11 ne get ocids 2 13 633 exit 64 634 end 635 end 636 end 637 end 638 639 note Classify one journal line held in ocin[0..l) and update the state. 640 fn ohline l ulong to void 641 last = get ohv ohslast 642 if eq last 0 643 r = ocsetgl l 644 if lt r 0 645 exit 64 646 end 647 put ohv ohsjobs 1 648 if eq get ocgv 0 7 649 put ohv ohsjobs 2 650 end 651 put ohv ohslast ohkg 652 ret 653 end 654 k = ocvline l 0 655 if or lt k 0 eq k 1 656 exit 64 657 end 658 ohorder ulong k 659 if eq k 2 660 put ohv ohsnmod add get ohv ohsnmod 1 661 if eq get ocids 1 9 662 put ohv ohslast ohkaref 663 ret 664 end 665 a = add get ohv ohsatt 1 666 put ohv ohsatt a 667 f = get ohv ohsnf 668 if ge f 8 669 exit 64 670 end 671 put ohfj mul f 2 get ohv ohsjob 672 put ohfj add mul f 2 1 a 673 put ohv ohsnf add f 1 674 if gt l len ohal 675 exit 64 676 end 677 for j ulong l 678 put ohal j get ocin j 679 end 680 put ohv ohsnal l 681 put ohv ohslast ohkajob 682 ret 683 end 684 if eq k 3 685 if ne last ohkajob 686 exit 64 687 end 688 put ohv ohslast ohkr 689 put ohv ohstr 0 690 if eq get ocids 1 10 691 put ohv ohsjob add get ohv ohsjob 1 692 put ohv ohsatt 0 693 ret 694 end 695 if eq get ocids 2 17 696 put ohv ohstr 1 697 end 698 ret 699 end 700 put ohv ohsnmod add get ohv ohsnmod 1 701 put ohv ohslast ohkp 702 end 703 704 note Drop a torn (unterminated) journal tail; keep everything up to the last LF. 705 fn ohtorn n ulong to ulong 706 q = n 707 while gt q 0 bound 70000 708 if eq get ohb sub q 1 10 709 break 710 end 711 q = sub q 1 712 end 713 ohtclr 714 ohtw ohxep 715 fd = fopen oht 0 get ohtn 0 1 0 716 if lt fd 0 717 exit 65 718 end 719 r = ftrunc int fd long q 720 s = fsync int fd 721 c = fclose int fd 722 if or lt r 0 lt s 0 723 exit 65 724 end 725 ohhead ohxtorn 726 ohtc 32 727 ohtd sub n q 728 ohlog 729 ret q 730 end 731 732 note Rebuild the episode state from the journal. 733 fn ohscan to void 734 ohtclr 735 ohtw ohxep 736 k = ohrdf 737 if lt k 8 738 exit 64 739 end 740 n = ulong k 741 if ne get ohb sub n 1 10 742 n = ohtorn n 743 end 744 ohtclr 745 ohtw 61 746 ohtc 32 747 ohtw 62 748 for j ulong 7 749 if ne get ohb j get oht j 750 exit 64 751 end 752 end 753 if ne get ohb 7 10 754 exit 64 755 end 756 put ohv ohslast 0 757 put ohv ohsjob 1 758 put ohv ohsatt 0 759 put ohv ohstr 0 760 put ohv ohsnmod 0 761 put ohv ohsnf 0 762 p = ulong 8 763 while lt p n bound 256 764 e = p 765 while ne get ohb e 10 bound 4096 766 e = add e 1 767 end 768 l = sub e p 769 if gt l len ocin 770 exit 64 771 end 772 for j ulong l 773 put ocin j get ohb add p j 774 end 775 ohline l 776 p = add e 1 777 end 778 if eq get ohv ohslast 0 779 exit 64 780 end 781 end 782 783 note Run the core once; returns the validated model line length in ocin, or 0. 784 fn ohdec1 g bool to ulong 785 put ohv ohsdecs add get ohv ohsdecs 1 786 if gt get ohv ohsdecs 16 787 exit 64 788 end 789 ohpkclr 790 ohpkk ohccore 791 ohpw ohxdec 792 ohpkk ohcckpt 793 if g 794 ohpw ohxg 795 else 796 ohpkk ohcmode 797 end 798 ohpw ohxep 799 ohsetio ohxdec 800 pid = ohspawn 801 e = ohwait pid 802 ohhead ohxdecd 803 ohtc 32 804 ohtw ohxrceq 805 ohtd ulong e 806 ohlog 807 if or eq e 51 eq e 52 808 exit 63 809 end 810 if ne e 0 811 ret 0 812 end 813 ohotot 814 k = ohrdf 815 if lt k 2 816 ret 0 817 end 818 n = ulong k 819 for p ulong sub n 1 820 if eq get ohb p 10 821 ret 0 822 end 823 end 824 if ne get ohb sub n 1 10 825 ret 0 826 end 827 ohtclr 828 ohtb 0 sub n 1 829 m = ohtoin 830 v = ocvline m 5 831 if lt v 0 832 ret 0 833 end 834 ret m 835 end 836 837 note Decode in the configured mode; on an invalid line or rc, one guided repair 838 note in mode G. The repair is logged in hive.log, never in the journal. 839 fn ohdecode to ulong 840 m = ohdec1 false 841 if gt m 0 842 ret m 843 end 844 ohhead ohxrepr 845 ohlog 846 m = ohdec1 true 847 if gt m 0 848 ret m 849 end 850 exit 63 851 end 852 853 fn ohbpath j ulong to void 854 ohtclr 855 ohtw ohxdisp 856 ohtc 47 857 ohtc 106 858 ohtd j 859 ohtw ohxan0b 860 end 861 862 fn ohbe b ulong n ulong to ulong 863 v = ulong 0 864 for i ulong n 865 v = add shl v 8 ulong get ohb add b i 866 end 867 ret v 868 end 869 870 note Ensure disp/j.an0b exists and its payload equals the lowered A (oclv). 871 fn ohbund j ulong to void 872 ohbpath j 873 s = stat oht 0 get ohtn 0 ohsb 0 128 874 if lt s 0 875 ohpkclr 876 ohpkk ohcrun 877 ohpw ohxbund 878 ohpw ohxkeys 879 ohpkk ohckeys 880 ohpw ohxout 881 ohbpath j 882 ohpkt 883 for i ulong 4 884 ohpw add ohxm i 885 ohpd get oclv i 886 end 887 ohsetio ohxbund 888 pid = ohspawn 889 e = ohwait pid 890 if ne e 0 891 ohhead ohxbund 892 ohtc 32 893 ohtw ohxrceq 894 ohtd ulong e 895 ohlog 896 exit 65 897 end 898 ohhead ohxnew 899 ohtc 32 900 ohbpath j 901 ohlog 902 end 903 ohbpath j 904 k = ohrdf 905 if lt k 124 906 exit 69 907 end 908 ok = and eq get ohb 6 0 eq get ohb 7 15 909 ok = and ok eq get ohb 109 1 910 ok = and ok eq ohbe 110 2 get oclv 0 911 ok = and ok eq ohbe 112 2 get oclv 1 912 ok = and ok eq ohbe 114 2 get oclv 2 913 ok = and ok eq ohbe 116 8 get oclv 3 914 if not ok 915 ohhead ohxlower 916 ohlog 917 exit 69 918 end 919 end 920 921 fn ohishex p ulong to bool 922 if gt add p 64 get ohbn 0 923 ret false 924 end 925 for j ulong 64 926 c = get ohb add p j 927 if not or and ge c 48 le c 57 and ge c 97 le c 102 928 ret false 929 end 930 end 931 ret true 932 end 933 934 note Does ohb[p..] start with word w? 935 fn ohat p ulong w ulong to bool 936 o = get ohwo w 937 l = get ohwl w 938 if gt add p l get ohbn 0 939 ret false 940 end 941 for j ulong l 942 x = get ohb add p j 943 if ne x get ohw add o j 944 ret false 945 end 946 end 947 ret true 948 end 949 950 note Position just after the first word w in ohb[0..ohbn), or -1. 951 fn ohfind w ulong to long 952 n = get ohbn 0 953 for p ulong n 954 if ohat p w 955 ret long add p get ohwl w 956 end 957 end 958 ret neg long 1 959 end 960 961 note Is ohb[p..] exactly word w, followed by space, LF or the end? 962 fn ohmatch p ulong w ulong to bool 963 if not ohat p w 964 ret false 965 end 966 l = get ohwl w 967 n = get ohbn 0 968 if eq add p l n 969 ret true 970 end 971 c = get ohb add p l 972 ret or eq c 32 eq c 10 973 end 974 975 note dag_id from the aienet0-run stderr file. 976 fn ohgdag to void 977 put ohv ohsdag 0 978 ohetot 979 k = ohrdf 980 if lt k 0 981 exit 65 982 end 983 q = ohfind ohxdagid 984 if lt q 0 985 ret 986 end 987 p = ulong q 988 if not ohishex p 989 ret 990 end 991 for j ulong 64 992 put ohdag j get ohb add p j 993 end 994 put ohv ohsdag 1 995 end 996 997 note Exit 0: VERIFIED must name the same dag; MJR1 outcome 1. 998 fn ohgver to void 999 ohotot 1000 k = ohrdf 1001 if lt k 0 1002 exit 65 1003 end 1004 q = ohfind ohxverif 1005 if or lt q 0 ne get ohv ohsdag 1 1006 exit 66 1007 end 1008 p = add ulong q 1 1009 if or not ohishex p not ohishex add p 65 1010 exit 66 1011 end 1012 for j ulong 64 1013 if ne get ohb add p j get ohdag j 1014 exit 66 1015 end 1016 put ohsha j get ohb add add p 65 j 1017 end 1018 put ohv ohssha 1 1019 ohtclr 1020 ohtw ohxodir 1021 ohtc 47 1022 ohtdag 1023 ohtw ohxmjr1 1024 n = get ohtn 0 1025 for j ulong n 1026 put ocpath j get oht j 1027 end 1028 r = ocmjrf n 1029 if ne r 1 1030 exit 66 1031 end 1032 put ohv ohsout 1 1033 end 1034 1035 note Exit 11: the refusal tag is the word after "REFUSED WORKER " on stdout. 1036 fn ohgtag to ulong 1037 ohotot 1038 k = ohrdf 1039 if lt k 0 1040 exit 65 1041 end 1042 q = ohfind ohxworkr 1043 if lt q 0 1044 ret ohxwork 1045 end 1046 p = add ulong q 1 1047 if ohmatch p ohxa0rep 1048 ret ohxrepl 1049 end 1050 if or ohmatch p ohxa0bud ohmatch p ohxmjbud 1051 ret ohxbudg 1052 end 1053 ret ohxwork 1054 end 1055 1056 note aienet0-run exit -> R class and code words. 1057 fn ohmap e long to void 1058 put ohv ohscode ohxdash 1059 put ohv ohscls ohxfail 1060 if eq e 0 1061 ohgver 1062 put ohv ohscls ohxok 1063 ret 1064 end 1065 if eq e 11 1066 put ohv ohscls ohxrefd 1067 put ohv ohscode ohgtag 1068 ret 1069 end 1070 if eq e 10 1071 put ohv ohscode ohxtrans 1072 ret 1073 end 1074 if eq e 12 1075 put ohv ohscode ohxrcpt 1076 ret 1077 end 1078 if eq e 13 1079 put ohv ohscode ohxrcmp 1080 ret 1081 end 1082 if eq e 14 1083 put ohv ohscode ohxverd 1084 ret 1085 end 1086 if eq e 15 1087 put ohv ohscode ohxio 1088 ret 1089 end 1090 ohhead ohxrceq 1091 ohtd ulong e 1092 ohlog 1093 exit 66 1094 end 1095 1096 note disp/ja.fact: one facts.tsv row for this dispatch. 1097 fn ohfact j ulong a ulong e long to void 1098 ohtclr 1099 ohtd j 1100 ohtc 9 1101 ohtd a 1102 for i ulong 4 1103 ohtc 9 1104 ohtd get oclv i 1105 end 1106 ohtc 9 1107 ohtd ulong e 1108 ohtc 9 1109 ohtw get ohv ohscls 1110 ohtc 9 1111 ohtw get ohv ohscode 1112 ohtc 9 1113 ohtdag 1114 ohtc 9 1115 ohtsha 1116 ohtc 9 1117 if eq e 0 1118 ohtd get ohv ohsout 1119 ohtc 9 1120 ohtk ohcverif 1121 else 1122 ohtw ohxdash 1123 ohtc 9 1124 ohtw ohxdash 1125 end 1126 ohtc 10 1127 ohtod 1128 ohtclr 1129 ohtw ohxdisp 1130 ohtc 47 1131 ohtc 106 1132 ohtd j 1133 ohtc 97 1134 ohtd a 1135 ohtw ohxfact 1136 ohwrd 577 1137 end 1138 1139 note Journal R after self-validating it against the R grammar. 1140 fn ohjres to void 1141 ohtclr 1142 ohtw ohxres 1143 ohtc 32 1144 ohtw get ohv ohscls 1145 if ne get ohv ohscode ohxdash 1146 ohtc 32 1147 ohtw get ohv ohscode 1148 end 1149 ohtc 32 1150 ohtw ohxend 1151 m = ohtoin 1152 v = ocvline m 3 1153 if ne v 3 1154 exit 64 1155 end 1156 ohappw ohxep 1157 end 1158 1159 fn ohspsrv rt ulong to long 1160 ohpkclr 1161 ohpkk ohcserve 1162 ohpw ohxconn 1163 ohpkk ohcaddr 1164 ohpw ohxkeys 1165 ohpkk ohcwkeys 1166 ohpw ohxpins 1167 ohpkk ohcwpins 1168 ohpw ohxstate 1169 ohpkk ohcwst 1170 ohpw ohxcto 1171 ohpw ohxcto30 1172 if eq rt 1 1173 ohpw ohxretry 1174 end 1175 ohsetio ohxserve 1176 ret ohspawn 1177 end 1178 1179 fn ohsprun j ulong to long 1180 ohpkclr 1181 ohpkk ohcrun 1182 ohpw ohxrun 1183 ohpw ohxlist 1184 ohpkk ohcaddr 1185 ohpw ohxkeys 1186 ohpkk ohckeys 1187 ohpw ohxpins 1188 ohpkk ohcpins 1189 ohpw ohxout 1190 ohpw ohxodir 1191 ohpw ohxrec 1192 ohpkk ohcrec 1193 ohpw ohxrecs 1194 ohpkk ohcrecs 1195 ohpw ohxresnd 1196 ohbpath j 1197 ohpkt 1198 ohpw ohxacct 1199 ohpkk ohcacct 1200 ohsetio ohxrun 1201 ret ohspawn 1202 end 1203 1204 note One dispatch of job j, attempt a (oclv holds the lowered A). 1205 fn ohdisp j ulong a ulong rt ulong to void 1206 ohbund j 1207 ohtclr 1208 ohtw ohxint 1209 ohtc 32 1210 ohtd j 1211 ohtc 32 1212 ohtd a 1213 ohtc 32 1214 ohtw ohxretry 1215 ohtc 61 1216 ohtd rt 1217 ohtc 32 1218 ohtw ohxdisp 1219 ohtc 47 1220 ohtc 106 1221 ohtd j 1222 ohtw ohxan0b 1223 put ohv ohsdag 0 1224 ohappw ohxdlog 1225 wp = ohspsrv rt 1226 rp = ohsprun j 1227 e = ohwait rp 1228 we = ohwait wp 1229 put ohv ohssha 0 1230 put ohv ohsout 0 1231 ohgdag 1232 ohmap e 1233 ohfact j a e 1234 ohjres 1235 ohtclr 1236 ohtw ohxoutc 1237 ohtc 32 1238 ohtd j 1239 ohtc 32 1240 ohtd a 1241 ohtc 32 1242 ohtd ulong e 1243 ohtc 32 1244 ohtdag 1245 ohtc 32 1246 ohtw ohxserve 1247 ohtc 61 1248 ohtd ulong we 1249 ohappw ohxdlog 1250 end 1251 1252 note Reconcile an A job journaled without its R (interrupted dispatch). 1253 fn ohrecon to void 1254 n = get ohv ohsnal 1255 for j ulong n 1256 put ocin j get ohal j 1257 end 1258 r = oclowerl n 1259 if ne r 0 1260 exit 64 1261 end 1262 ohhead ohxrecon 1263 ohtc 32 1264 ohtd get ohv ohsjob 1265 ohtc 32 1266 ohtd get ohv ohsatt 1267 ohlog 1268 ohdisp get ohv ohsjob get ohv ohsatt 1 1269 end 1270 1271 note A validated model line is in ocin[0..n): journal it, dispatching an A job. 1272 fn ohstep n ulong to void 1273 ohorder get ocids 0 1274 if eq get ocids 0 2 1275 if eq get ocids 1 8 1276 j = get ohv ohsjob 1277 a = get ohv ohsatt 1278 if or ge a 2 and gt a 0 eq get ohv ohstr 0 1279 ohhead ohxrefu 1280 ohlog 1281 exit 64 1282 end 1283 b = ocbindl n j 1284 if or eq b 41 eq b 42 1285 ohhead ohxbind 1286 ohtc 32 1287 ohtd ulong b 1288 ohlog 1289 exit 62 1290 end 1291 if ne b 0 1292 exit 64 1293 end 1294 r = oclowerl n 1295 if ne r 0 1296 exit 64 1297 end 1298 rt = get ohv ohstr 1299 ohtclr 1300 for i ulong n 1301 ohtc get ocin i 1302 end 1303 ohappw ohxep 1304 ohdisp j add a 1 rt 1305 ret 1306 end 1307 end 1308 ohtclr 1309 for i ulong n 1310 ohtc get ocin i 1311 end 1312 ohappw ohxep 1313 end 1314 1315 fn ohfacts to void 1316 ohtclr 1317 for i ulong 13 1318 if gt i 0 1319 ohtc 9 1320 end 1321 ohtw add ohxhdr i 1322 end 1323 ohtc 10 1324 ohtod 1325 ohtclr 1326 ohtw ohxfacts 1327 ohwrd 577 1328 for f ulong get ohv ohsnf 1329 j = get ohfj mul f 2 1330 a = get ohfj add mul f 2 1 1331 ohtclr 1332 ohtw ohxdisp 1333 ohtc 47 1334 ohtc 106 1335 ohtd j 1336 ohtc 97 1337 ohtd a 1338 ohtw ohxfact 1339 k = ohrdf 1340 if lt k 1 1341 exit 65 1342 end 1343 ohbtod ulong k 1344 ohtclr 1345 ohtw ohxfacts 1346 ohwrd 1089 1347 end 1348 end 1349 1350 fn main to int 1351 ohwinit 1352 put ohv ohspid ulong getpid 1353 ohconf 1354 ohmkdir ohxdisp 1355 ohmkdir ohxodir 1356 ohmkdir ohxlogs 1357 ohinitj 1358 for it ulong 40 1359 ohscan 1360 last = get ohv ohslast 1361 if eq last ohkp 1362 ohfacts 1363 ohhead ohxhdone 1364 ohtc 32 1365 ohtd get ohv ohsnf 1366 ohlog 1367 ret 0 1368 end 1369 if eq last ohkajob 1370 ohrecon 1371 else 1372 if ge get ohv ohsnmod 10 1373 exit 64 1374 end 1375 n = ohdecode 1376 ohstep n 1377 end 1378 end 1379 exit 64 1380 end