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/seed/node/live-test.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 / seed / node / live-test.om` 2410 lines ยท 41547 bytes Raw Blame History 1 note seed/node/live-test.om -- the live coding workflow under the durable 2 note scheduler (DRA-399). It drives the real programs (ollm serving the own 3 note round40 model, code-main, code-test, tool, infer) and checks what they 4 note did; it implements none of their logic. Composition (omc exit status 5 note checked; fn main is here): 6 note { printf 'om2\n'; cat seed/json/json.om om/tls/sha2.om 7 note seed/node/live-test.om; } | seed/out/omc > build/node/live-test 8 note Usage: live-test BASE NODE OLLM MODELDIR OMC40 SEL [serve=0] [parts=fcr] 9 note BASE must not exist (it is created); NODE holds infer, tool, code-main 10 note and code-test; MODELDIR holds model.ck and merges.bin; OMC40 is the 11 note compiler the objectives are checked with; SEL is the round40 12 note final-selected.json. All paths absolute. serve=0 runs without a model 13 note server (negative control: every check that needs the model must FAIL 14 note and the exit is nonzero). parts= picks the full run (f), the 15 note cancellation (c) and the crash and restart (r); a part left out is 16 note NOT_RUN. Run it inside bwrap --unshare-net (the server listens on 17 note 127.0.0.1:18399). Output: LIVE, HASH, SEL, PREP, SERVE, RUN, REVIEW, 18 note SNAP and JOP evidence lines, one PASS|FAIL|NOT_RUN line per check, then 19 note "LIVE checks N pass P fail F not_run R". Exit 0 only if every check 20 note passed, 1 otherwise, 2 usage. 21 note Scenario directories BASE/full, BASE/cancel, BASE/crash each hold 22 note root/jobs (the files the objectives repair), work, journal (the 23 note node's journal v2), serve.log and the programs' stdout/stderr. 24 25 text lto0 "loop,4,3,70,jobs/item76666.om,Fix the error in this file and confirm its goal." 26 text lto1 "loop,5,3,71,jobs/item83423.om,Inspect the code and repair it to satisfy the goal." 27 text lto2 "loop,1,6,72,jobs/item82342.om,Fix the error in this file and confirm its goal." 28 text lto3 "loop,2,4,70,jobs/item85188.om,Fix the error in this file and confirm its goal." 29 text ltj0 "jobs/item76666.om" 30 text ltj1 "jobs/item83423.om" 31 text ltj2 "jobs/item82342.om" 32 text ltj3 "jobs/item85188.om" 33 34 note Pinned inputs (sha256): the round40 model and merges, the ollm runtime 35 note built from ~/work/omega-node-ollm/ollm.om, the objectives' compiler 36 note omega-mv `e5b32567` and the round40 selection. 37 text lhmod "`7c7b5b5260f2d9453b6076b64e7f23e88341d96498584f2dfaa229c31ad2e346`" 38 text lhmrg "`73a29baf97619a746a21232c403bf08af71a76e48b3b2cde6d64dab766083882`" 39 text lhollm "`f99fce9fe914f51b708af5b39c8f07856bdcc6f4523dd43fa457f0d26aaa4745`" 40 text lhomc "`2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f`" 41 text lhsel "`2017a902927baf1aae899db08a47cf83e0a1dcd148476f511ad73a63012ff138`" 42 43 text ltdnul "/dev/null" 44 text ltproc "/proc" 45 text ltcmdl "/cmdline" 46 text ltself "/proc/self/exe" 47 text ltinfr "/infer" 48 text ltinfw "infer" 49 text lttool "/tool" 50 text ltcmn "/code-main" 51 text ltctst "/code-test" 52 text ltroot "/root" 53 text ltjobs "/root/jobs" 54 text ltwork "/work" 55 text ltjour "/journal" 56 text ltjfl "/journal/journal" 57 text ltslog "/serve.log" 58 text ltmck "/model.ck" 59 text ltmmg "/merges.bin" 60 text ltsnap "/run1-item76666.om" 61 text ltrw "/rw" 62 text ltserve "serve" 63 text ltport "18399" 64 text ltview "0" 65 text ltcanc "cancel" 66 text ltcms "20000" 67 text ltchk "check" 68 text ltk3 "3" 69 text ltfull "full" 70 text ltcrsh "crash" 71 text ltrun "run" 72 text ltout ".out" 73 text lterr ".err" 74 text ltrev "review-" 75 text ltmiss "missing" 76 text lttp "Tests passed." 77 text ltfnf "File not found." 78 text ltpass "PASS" 79 text ltfail "FAIL" 80 text ltnr "NOT_RUN" 81 text ltcwp "CWP " 82 text ltcwr "CWR " 83 text ltcwe "CWE " 84 text ltcwo "CWO " 85 text ltcws "CWSUM pass=" 86 text ltomnt "OMNT1 " 87 text ltporl "PORT " 88 text lt499 "C 499 " 89 text ltsrv "serve=" 90 text ltprt "parts=" 91 text ltkjob "job" 92 text ltkpath "path" 93 text ltkbrk "broken" 94 text ltkcor "correct" 95 text ltkflt "fault" 96 text ltkturn "turns" 97 text ltkprm "prompt" 98 text ltkraw "raw" 99 text ltkkind "kind" 100 text ltkk "k" 101 text ltkn "n" 102 text ltka "a" 103 text ltkpass "pass" 104 text ltloop "loop" 105 106 text ltusage "LIVE usage: live-test BASE NODE OLLM MODELDIR OMC40 SEL [serve=0] [parts=fcr] (absolute paths; BASE must not exist)" 107 text ltlive "LIVE" 108 text ltstart "start realns" 109 text ltpidw "pid" 110 text ltbase "base" 111 text lthash "HASH" 112 text ltsel "SEL" 113 text ltprep "PREP" 114 text ltsrvw "SERVE" 115 text ltrunw "RUN" 116 text ltrevw "REVIEW" 117 text ltsnapw "SNAP" 118 text ltjop "JOP" 119 text ltsha "sha256" 120 text ltbytes "bytes" 121 text ltpinok "pin=match" 122 text ltpinbd "pin=MISMATCH" 123 text ltunrd "unreadable errno" 124 text ltabs "absent" 125 text ltfaultw "fault" 126 text ltturns "turns" 127 text ltpassw "pass" 128 text ltfailw "fail" 129 text ltnrw "not_run" 130 text ltchks "checks" 131 text ltexit "exit" 132 text ltms "ms" 133 text ltleft "node_procs_left" 134 text ltgone "server_group_gone" 135 text ltready "ready_ms" 136 text ltdied "exited_before_ready" 137 text ltnosrv "no_server" 138 text lttmo "not_ready" 139 text ltprms "prompts" 140 text ltraws "raws" 141 text ltsum "cwsum" 142 text ltcorw "equals_correct" 143 text ltbrkw "equals_broken" 144 text lttst "tool_exit" 145 text ltstat "tool_status" 146 text ltobs "observation" 147 text ltcev "cancel_events" 148 text ltc499 "server_499" 149 text ltkillw "killed_at_inference_after_replace" 150 text ltinfa "infer_procs_at_kill" 151 text ltr1st "run1_status" 152 text ltr1o "run1_cwo" 153 text ltr1r "run1_replace_issued" 154 text ltr2r "run2_replace_issued" 155 text ltsnok "snapshot_correct" 156 text ltprepw "prep" 157 text ltsrvok "server" 158 text ltpins "pinned_ok" 159 text ltprog "programs_hashed" 160 text lterrw "error" 161 text ltnsel "part not selected" 162 text ltnode "node_procs" 163 text ltrecs "records" 164 text ltopens "opens" 165 text ltadm "admits" 166 text ltstw "starts" 167 text ltdnw "dones" 168 text ltrel "releases" 169 text ltcanw "cancels" 170 text ltpol "policy" 171 text ltgoal "goal" 172 text ltfair "fair" 173 text ltoth "other" 174 text ltbad "bad" 175 text ltops "ops" 176 text ltmax "max_starts_per_op" 177 text ltreps "replace_starts" 178 text ltopen "open_ops" 179 text ltsetl "settled_by_restart" 180 text ltspv "spver_bad" 181 text ltfnc "fence_bad" 182 text ltidt "identity" 183 text ltfncw "fence" 184 text ltoutc "outcome" 185 text lthow "how" 186 text ltop "op" 187 text ltcls "class" 188 text ltbrkb "broken_bytes" 189 text ltcorb "correct_bytes" 190 191 text ltcpre "prereq-hashes" 192 text ltcsel "selection" 193 text ltcfw "full-workflow" 194 text ltcfj "full-journal" 195 text ltctr "round40-transcript" 196 text ltcrv "review-outputs" 197 text ltccn "cancel-mid-inference" 198 text ltccj "cancel-journal" 199 text ltccr "crash-restart" 200 text ltcrj "crash-journal" 201 text ltcnl "no-leak" 202 203 note la: arguments 1..6 at 512 * k, lengths in ll; lopt 0 serve, 1 parts. 204 global la uchar 4096 205 global ll ulong 8 206 global lopt ulong 4 207 global lob uchar 8192 208 global lon ulong 1 209 global lpa uchar 4096 210 global lpn ulong 1 211 global lhx uchar 64 212 global lck ulong 4 213 global lpid ulong 1 214 global lcu ulong 1 215 global linf ulong 1 216 note ltx: per objective i and slot s (0 broken, 1 correct, 2 fault, 3..9 217 note turn prompts, 10..16 turn raws) 4096 bytes at (17 i + s) 4096. 218 global ltx uchar 278528 219 global ltxl ulong 68 220 global ltnt ulong 4 221 global ltps ulong 4 222 note lcw: parsed output; per objective i at 16 i: 0 CWO lines, 1 passed, 223 note 2 result, 3 turns, 4 CWP frames, 5 CWR frames, 6 prompts equal to the 224 note record, 7 raws equal, 8 replace jobs issued, 9 replace outcomes, 225 note 10 inference jobs issued after a replace outcome, 11 cancel events, 226 note 12 CWE lines; 64 CWSUM lines, 65 its pass, 66 its fail (objective 3 227 note uses 48..60, so the CWSUM slots must start above it). 228 global lcw ulong 80 229 note lcr: crash scenario values (see lt_crash). 230 global lcr ulong 16 231 global lrv ulong 4 232 note ljs: journal summary (see lj_scan); ljo: per operation 12 words (0..3 233 note the operation key, starts, dones, start fence, done fence, outcome, 234 note how, the job id and the class of its START). 235 global ljs ulong 32 236 global ljo ulong 12288 237 global ljn ulong 1 238 239 note ======== output lines 240 241 fn lt_dig v ulong d edit uchar 24 to ulong 242 k = ulong 0 243 x = v 244 for i ulong 24 245 put d k uchar add 48 rem x 10 246 k = add k 1 247 x = div x 10 248 if eq x 0 249 break 250 end 251 end 252 ret k 253 end 254 255 fn lo_c c ulong to void 256 n = get lon 0 257 if or lt n 8100 and eq c 10 lt n 8192 258 put lob n uchar c 259 put lon 0 add n 1 260 end 261 end 262 263 fn lo_t a view uchar * to void 264 for i ulong len a 265 lo_c ulong get a i 266 end 267 end 268 269 fn lo_w a view uchar * to void 270 lo_c 32 271 lo_t a 272 end 273 274 fn lo_n v ulong to void 275 d = new uchar 24 0 276 k = lt_dig v d 277 for j ulong k 278 lo_c ulong get d sub sub k j 1 279 end 280 end 281 282 fn lo_kv k view uchar * v ulong to void 283 lo_c 32 284 lo_t k 285 lo_c 32 286 lo_n v 287 end 288 289 fn lo_a k ulong to void 290 for i ulong get ll k 291 lo_c ulong get la add mul k 512 i 292 end 293 end 294 295 fn lo_p to void 296 for i ulong get lpn 0 297 lo_c ulong get lpa i 298 end 299 end 300 301 fn lo_h to void 302 for i ulong 64 303 lo_c ulong get lhx i 304 end 305 end 306 307 fn lo_xs i ulong s ulong to void 308 q = add mul i 17 s 309 b = mul q 4096 310 for j ulong get ltxl q 311 lo_c ulong get ltx add b j 312 end 313 end 314 315 fn lo_x x ulong to void 316 if eq x 0 317 lo_t ltfull 318 end 319 if eq x 1 320 lo_t ltcanc 321 end 322 if eq x 2 323 lo_t ltcrsh 324 end 325 end 326 327 fn lo_e to void 328 lo_c 10 329 n = get lon 0 330 p = ulong 0 331 for it ulong 4096 332 if ge p n 333 break 334 end 335 r = write 1 lob p sub n p 336 if le r 0 337 break 338 end 339 p = add p ulong r 340 end 341 put lon 0 0 342 end 343 344 fn lt_ok b bool to ulong 345 if b 346 ret 0 347 end 348 ret 1 349 end 350 351 note One check line: verdict st (0 PASS, 1 FAIL, 2 NOT_RUN), the name, then 352 note the detail already in the line buffer. 353 fn lt_res st ulong name view uchar * to void 354 d = new uchar 8192 0 355 n = get lon 0 356 for i ulong n 357 put d i get lob i 358 end 359 put lon 0 0 360 put lck 0 add get lck 0 1 361 put lck add st 1 add get lck add st 1 1 362 if eq st 0 363 lo_t ltpass 364 end 365 if eq st 1 366 lo_t ltfail 367 end 368 if eq st 2 369 lo_t ltnr 370 end 371 lo_w name 372 if gt n 0 373 if ne get d 0 32 374 lo_c 32 375 end 376 lo_t view part d 0 n 377 end 378 lo_e 379 end 380 381 note ======== paths (the current path is lpa[0, lpn)) 382 383 fn lp_c c ulong to void 384 n = get lpn 0 385 if lt n 4000 386 put lpa n uchar c 387 put lpn 0 add n 1 388 end 389 end 390 391 fn lp_t a view uchar * to void 392 for i ulong len a 393 lp_c ulong get a i 394 end 395 end 396 397 fn lp_n v ulong to void 398 d = new uchar 24 0 399 k = lt_dig v d 400 for j ulong k 401 lp_c ulong get d sub sub k j 1 402 end 403 end 404 405 fn lp_a k ulong to void 406 for i ulong get ll k 407 lp_c ulong get la add mul k 512 i 408 end 409 end 410 411 fn lp_x x ulong to void 412 put lpn 0 0 413 lp_a 1 414 lp_c 47 415 if eq x 0 416 lp_t ltfull 417 end 418 if eq x 1 419 lp_t ltcanc 420 end 421 if eq x 2 422 lp_t ltcrsh 423 end 424 end 425 426 fn lp_o i ulong to void 427 if eq i 0 428 lp_t ltj0 429 end 430 if eq i 1 431 lp_t ltj1 432 end 433 if eq i 2 434 lp_t ltj2 435 end 436 if eq i 3 437 lp_t ltj3 438 end 439 end 440 441 note Output file names: out 0 run, 1 run1, 2 run2, 10 + i review-i; e 0 442 note .out, 1 .err. 443 fn lp_on oi ulong e ulong to void 444 if ge oi 10 445 lp_t ltrev 446 lp_n sub oi 10 447 else 448 lp_t ltrun 449 if gt oi 0 450 lp_n oi 451 end 452 end 453 if eq e 0 454 lp_t ltout 455 else 456 lp_t lterr 457 end 458 end 459 460 note ======== packed argument lists (execprog) 461 462 fn pk_t pk edit uchar 4096 p ulong a view uchar * to ulong 463 if gt add add p 2 len a 4096 464 ret 5000 465 end 466 c = add or ulong get pk 0 shl ulong get pk 1 8 1 467 put pk 0 uchar and c 255 468 put pk 1 uchar shr c 8 469 put pk p uchar and len a 255 470 put pk add p 1 uchar shr len a 8 471 for i ulong len a 472 put pk add add p 2 i get a i 473 end 474 ret add add p 2 len a 475 end 476 477 fn pk_p pk edit uchar 4096 p ulong to ulong 478 b = new uchar 4096 0 479 n = get lpn 0 480 for i ulong n 481 put b i get lpa i 482 end 483 ret pk_t pk p view part b 0 n 484 end 485 486 fn pk_a pk edit uchar 4096 p ulong k ulong to ulong 487 put lpn 0 0 488 lp_a k 489 ret pk_p pk p 490 end 491 492 fn pk_o pk edit uchar 4096 p ulong i ulong to ulong 493 if eq i 0 494 ret pk_t pk p lto0 495 end 496 if eq i 1 497 ret pk_t pk p lto1 498 end 499 if eq i 2 500 ret pk_t pk p lto2 501 end 502 ret pk_t pk p lto3 503 end 504 505 note ======== files (at the current path) 506 507 fn lf_creat to long 508 ret fopen lpa 0 get lpn 0 577 420 509 end 510 511 fn lf_mk to bool 512 r = makedir lpa 0 get lpn 0 493 513 ret eq r 0 514 end 515 516 fn lf_read b edit uchar * to long 517 fd = fopen lpa 0 get lpn 0 0 0 518 if lt fd 0 519 ret fd 520 end 521 t = ulong 0 522 for it ulong `1000000` 523 if ge t len b 524 break 525 end 526 n = read int fd b t sub len b t 527 if le n 0 528 break 529 end 530 t = add t ulong n 531 end 532 r = fclose int fd 533 ret long t 534 end 535 536 fn lf_wb b view uchar * to bool 537 fd = lf_creat 538 if lt fd 0 539 ret false 540 end 541 t = ulong 0 542 for it ulong 100000 543 if ge t len b 544 break 545 end 546 n = write int fd b t sub len b t 547 if le n 0 548 break 549 end 550 t = add t ulong n 551 end 552 r = fclose int fd 553 ret eq t len b 554 end 555 556 fn lf_wx i ulong s ulong to bool 557 q = add mul i 17 s 558 o = mul q 4096 559 m = get ltxl q 560 fd = lf_creat 561 if lt fd 0 562 ret false 563 end 564 t = ulong 0 565 for it ulong 100000 566 if ge t m 567 break 568 end 569 n = write int fd ltx add o t sub m t 570 if le n 0 571 break 572 end 573 t = add t ulong n 574 end 575 r = fclose int fd 576 ret eq t m 577 end 578 579 fn lt_hd v ulong to uchar 580 if lt v 10 581 ret uchar add 48 v 582 end 583 ret uchar add 87 v 584 end 585 586 fn lt_hex g view uchar 32 to void 587 for i ulong 32 588 v = ulong get g i 589 put lhx mul i 2 lt_hd shr v 4 590 put lhx add mul i 2 1 lt_hd and v 15 591 end 592 end 593 594 note sha256 of the file at the current path into lhx (hex); its size, or a 595 note negative error. 596 fn lf_hash to long 597 b = new uchar `1048576` 0 598 c = new ulong 40 0 599 g = new uchar 32 0 600 fd = fopen lpa 0 get lpn 0 0 0 601 if lt fd 0 602 ret fd 603 end 604 sha256_init c 605 t = ulong 0 606 for it ulong 100000 607 n = read int fd b 0 `1048576` 608 if lt n 0 609 r = fclose int fd 610 ret n 611 end 612 if eq n 0 613 break 614 end 615 sha256_update c view part b 0 ulong n 616 t = add t ulong n 617 end 618 r = fclose int fd 619 sha256_final c g 620 lt_hex g 621 ret long t 622 end 623 624 fn lt_hxeq a view uchar * to bool 625 if ne len a 64 626 ret false 627 end 628 for i ulong 64 629 if ne get lhx i get a i 630 ret false 631 end 632 end 633 ret true 634 end 635 636 note ======== bytes 637 638 fn lt_pfx b view uchar * p ulong a view uchar * to bool 639 if gt add p len a len b 640 ret false 641 end 642 for i ulong len a 643 if ne get b add p i get a i 644 ret false 645 end 646 end 647 ret true 648 end 649 650 fn lt_seq a view uchar * b view uchar * to bool 651 if ne len a len b 652 ret false 653 end 654 ret lt_pfx a 0 b 655 end 656 657 fn lt_b b bool to ulong 658 if b 659 ret 1 660 end 661 ret 0 662 end 663 664 fn lt_has a view uchar * k view uchar * to bool 665 if gt len k len a 666 ret false 667 end 668 for i ulong add sub len a len k 1 669 if lt_pfx a i k 670 ret true 671 end 672 end 673 ret false 674 end 675 676 fn lt_xeq a view uchar * i ulong s ulong to bool 677 q = add mul i 17 s 678 if ne len a get ltxl q 679 ret false 680 end 681 b = mul q 4096 682 for j ulong len a 683 if ne get a j get ltx add b j 684 ret false 685 end 686 end 687 ret true 688 end 689 690 fn lt_kna i ulong w ulong to ulong 691 t = new ulong 12 0 692 put t 0 4 693 put t 1 3 694 put t 2 70 695 put t 3 5 696 put t 4 3 697 put t 5 71 698 put t 6 1 699 put t 7 6 700 put t 8 72 701 put t 9 2 702 put t 10 4 703 put t 11 70 704 ret get t add mul i 3 w 705 end 706 707 note ======== processes 708 709 fn lt_wst ws view uchar 4 to ulong 710 st = or ulong get ws 0 shl ulong get ws 1 8 711 if eq and st 127 0 712 ret and shr st 8 255 713 end 714 ret add 128 and st 127 715 end 716 717 note Run pk in its own process group with stdin /dev/null, stdout ofd and 718 note stderr efd. The pid, or negative. 719 fn lt_spawn pk view uchar 4096 pn ulong ofd long efd long to long 720 dn = fopen ltdnul 0 len ltdnul 0 0 721 pid = fork 722 if eq pid 0 723 r = setpgid 0 0 724 r = dupfd int ofd 1 0 725 r = dupfd int efd 2 0 726 if ge dn 0 727 r = dupfd int dn 0 0 728 end 729 r = execprog pk 0 pn 730 exit 127 731 end 732 if ge dn 0 733 q = fclose int dn 734 end 735 if gt pid 0 736 q = setpgid int pid int pid 737 end 738 ret pid 739 end 740 741 note Wait for pid at most ms; on time out its group is killed, it is reaped 742 note and the result is 999. Exit code, or 128 + signal; 998 wait failed. 743 fn lt_wait pid long ms ulong to ulong 744 ws = new uchar 4 0 745 dl = add ulong monons mul ms `1000000` 746 for it ulong `100000000` 747 g = waitpid int pid ws 0 4 1 748 if ne g 0 749 if lt g 0 750 ret 998 751 end 752 ret lt_wst ws 753 end 754 if ge ulong monons dl 755 r = killpid neg int pid 9 756 g = waitpid int pid ws 0 4 0 757 ret 999 758 end 759 q = sleepns `20000000` 760 end 761 ret 998 762 end 763 764 fn lt_pmat a view uchar * to ulong 765 k = get ll 2 766 if le len a add k 6 767 ret 0 768 end 769 for i ulong k 770 if ne get a i get la add 1024 i 771 ret 0 772 end 773 end 774 if ne get a k 47 775 ret 0 776 end 777 if lt_pfx a add k 1 ltinfw 778 if eq get a add k 6 0 779 put linf 0 add get linf 0 1 780 end 781 end 782 ret 1 783 end 784 785 fn lt_pent d view uchar 32768 p ulong to ulong 786 b = new uchar 512 0 787 pid = ulong 0 788 k = ulong 0 789 for i ulong 24 790 ch = ulong get d add add p 19 i 791 if eq ch 0 792 break 793 end 794 if or lt ch 48 gt ch 57 795 ret 0 796 end 797 pid = add mul pid 10 sub ch 48 798 k = add k 1 799 end 800 if or eq k 0 eq pid get lpid 0 801 ret 0 802 end 803 put lpn 0 0 804 lp_t ltproc 805 lp_c 47 806 lp_n pid 807 lp_t ltcmdl 808 fd = fopen lpa 0 get lpn 0 0 0 809 if lt fd 0 810 ret 0 811 end 812 n = read int fd b 0 512 813 r = fclose int fd 814 if le n 0 815 ret 0 816 end 817 ret lt_pmat view part b 0 ulong n 818 end 819 820 note Processes (other than this one) whose argv0 is NODE/..., counted from 821 note /proc; linf: those that are NODE/infer. 822 fn lt_procs to ulong 823 d = new uchar 32768 0 824 put linf 0 0 825 put lpn 0 0 826 lp_t ltproc 827 fd = fopen lpa 0 get lpn 0 16384 0 828 if lt fd 0 829 ret 99999 830 end 831 c = ulong 0 832 for it ulong 10000 833 n = getdnts int fd d 0 32768 834 if le n 0 835 break 836 end 837 p = ulong 0 838 while lt p ulong n bound 100000 839 w = or ulong get d add p 16 shl ulong get d add p 17 8 840 if eq w 0 841 break 842 end 843 c = add c lt_pent d p 844 p = add p w 845 end 846 end 847 r = fclose int fd 848 ret c 849 end 850 851 fn lt_left ms ulong to ulong 852 c = lt_procs 853 for it ulong 10000 854 if or eq c 0 ge mul it 100 ms 855 ret c 856 end 857 q = sleepns `100000000` 858 c = lt_procs 859 end 860 ret c 861 end 862 863 note ======== round40 selection 864 865 fn lt_mem src view uchar 524288 tape view uint 131072 t ulong key view uchar * to ulong 866 if eq t jsnone 867 ret jsnone 868 end 869 if ne js_type tape t jsobj 870 ret jsnone 871 end 872 k = js_first tape t 873 for it ulong 100000 874 if eq k jsnone 875 ret jsnone 876 end 877 if js_streq src js_off tape k key 878 ret add k 1 879 end 880 k = js_mnext tape k 881 end 882 ret jsnone 883 end 884 885 fn lt_isp src view uchar 524288 tape view uint 131072 p ulong i ulong to bool 886 if eq p jsnone 887 ret false 888 end 889 if ne js_type tape p jsstr 890 ret false 891 end 892 o = js_off tape p 893 if eq i 0 894 ret js_streq src o ltj0 895 end 896 if eq i 1 897 ret js_streq src o ltj1 898 end 899 if eq i 2 900 ret js_streq src o ltj2 901 end 902 ret js_streq src o ltj3 903 end 904 905 note The first record whose job.path is objective i's file. 906 fn lt_find src view uchar 524288 tape view uint 131072 i ulong to ulong 907 if ne js_type tape 0 jsarr 908 ret jsnone 909 end 910 e = js_first tape 0 911 for it ulong 100000 912 if eq e jsnone 913 ret jsnone 914 end 915 j = lt_mem src tape e ltkjob 916 p = lt_mem src tape j ltkpath 917 if lt_isp src tape p i 918 ret e 919 end 920 e = js_enext tape e 921 end 922 ret jsnone 923 end 924 925 fn lt_sto src view uchar 524288 tape view uint 131072 t ulong i ulong s ulong to bool 926 ob = new uchar 4096 0 927 if eq t jsnone 928 ret false 929 end 930 if ne js_type tape t jsstr 931 ret false 932 end 933 r = js_sget src js_off tape t ob 934 if lt r 0 935 ret false 936 end 937 b = mul add mul i 17 s 4096 938 for j ulong ulong r 939 put ltx add b j get ob j 940 end 941 put ltxl add mul i 17 s ulong r 942 ret true 943 end 944 945 note job. is the number lt_kna (iw / 3, iw % 3). 946 fn lt_kv src view uchar 524288 tape view uint 131072 j ulong key view uchar * iw ulong to bool 947 x = lt_mem src tape j key 948 if eq x jsnone 949 ret false 950 end 951 if ne js_type tape x jsnum 952 ret false 953 end 954 ret eq js_tou src js_off tape x lt_kna div iw 3 rem iw 3 955 end 956 957 fn lt_kchk src view uchar 524288 tape view uint 131072 j ulong i ulong to ulong 958 x = lt_mem src tape j ltkkind 959 if eq x jsnone 960 ret 30 961 end 962 if ne js_type tape x jsstr 963 ret 30 964 end 965 if not js_streq src js_off tape x ltloop 966 ret 30 967 end 968 if not lt_kv src tape j ltkk mul i 3 969 ret 31 970 end 971 if not lt_kv src tape j ltkn add mul i 3 1 972 ret 32 973 end 974 if not lt_kv src tape j ltka add mul i 3 2 975 ret 33 976 end 977 ret 0 978 end 979 980 fn lt_rec src view uchar 524288 tape view uint 131072 e ulong i ulong to ulong 981 j = lt_mem src tape e ltkjob 982 if not lt_sto src tape lt_mem src tape j ltkbrk i 0 983 ret 20 984 end 985 if not lt_sto src tape lt_mem src tape j ltkcor i 1 986 ret 21 987 end 988 if not lt_sto src tape lt_mem src tape j ltkflt i 2 989 ret 22 990 end 991 u = lt_mem src tape e ltkturn 992 if eq u jsnone 993 ret 23 994 end 995 if ne js_type tape u jsarr 996 ret 23 997 end 998 c = ulong 0 999 t = js_first tape u 1000 for it ulong 8 1001 if eq t jsnone 1002 break 1003 end 1004 if ge c 7 1005 ret 24 1006 end 1007 if not lt_sto src tape lt_mem src tape t ltkprm i add 3 c 1008 ret 25 1009 end 1010 if not lt_sto src tape lt_mem src tape t ltkraw i add 10 c 1011 ret 26 1012 end 1013 c = add c 1 1014 t = js_enext tape t 1015 end 1016 put ltnt i c 1017 ps = lt_mem src tape e ltkpass 1018 put ltps i 0 1019 if ne ps jsnone 1020 if eq js_type tape ps jstrue 1021 put ltps i 1 1022 end 1023 end 1024 ret lt_kchk src tape j i 1025 end 1026 1027 note Load the four objectives' records: 0, or where it failed. 1028 fn lt_sel to ulong 1029 src = new uchar 524288 0 1030 tape = new uint 131072 0 1031 put lpn 0 0 1032 lp_a 6 1033 n = lf_read src 1034 if or le n 0 ge n 524288 1035 ret 1 1036 end 1037 r = js_init tape 524288 64 1038 if lt r 0 1039 ret 2 1040 end 1041 r = js_parse src tape ulong n 1042 if lt r 0 1043 ret 3 1044 end 1045 for i ulong 4 1046 e = lt_find src tape i 1047 if eq e jsnone 1048 ret add 10 i 1049 end 1050 x = lt_rec src tape e i 1051 if ne x 0 1052 ret x 1053 end 1054 end 1055 ret 0 1056 end 1057 1058 fn lt_selr s ulong to void 1059 if eq s 0 1060 for i ulong 4 1061 lo_t ltsel 1062 lo_c 32 1063 lo_n i 1064 lo_c 32 1065 put lpn 0 0 1066 lp_o i 1067 lo_p 1068 lo_kv ltturns get ltnt i 1069 lo_w ltfaultw 1070 lo_c 32 1071 lo_xs i 2 1072 lo_kv ltpassw get ltps i 1073 lo_kv ltbrkb get ltxl mul i 17 1074 lo_kv ltcorb get ltxl add mul i 17 1 1075 lo_e 1076 end 1077 end 1078 lo_kv lterrw s 1079 lt_res lt_ok eq s 0 ltcsel 1080 end 1081 1082 note ======== output parsing (code-main / code-test frames and lines) 1083 1084 fn lt_pclr to void 1085 for i ulong 80 1086 put lcw i 0 1087 end 1088 end 1089 1090 fn lt_inc k ulong to void 1091 put lcw k add get lcw k 1 1092 end 1093 1094 fn lt_num b view uchar * p ulong to ulong 1095 v = ulong 0 1096 q = p 1097 for it ulong 24 1098 if ge q len b 1099 break 1100 end 1101 c = ulong get b q 1102 if or lt c 48 gt c 57 1103 break 1104 end 1105 v = add mul v 10 sub c 48 1106 q = add q 1 1107 end 1108 put lcu 0 add q 1 1109 ret v 1110 end 1111 1112 fn lt_eol b view uchar * n ulong p ulong to ulong 1113 q = p 1114 for it ulong `1000000` 1115 if ge q n 1116 ret n 1117 end 1118 if eq get b q 10 1119 ret q 1120 end 1121 q = add q 1 1122 end 1123 ret n 1124 end 1125 1126 fn lt_tcmp b view uchar * s ulong m ulong i ulong w ulong to void 1127 o = mul i 16 1128 ci = add o add 4 w 1129 k = get lcw ci 1130 lt_inc ci 1131 if ge k 7 1132 ret 1133 end 1134 if lt_xeq view part b s m i add add 3 mul w 7 k 1135 lt_inc add o add 6 w 1136 end 1137 end 1138 1139 fn lt_frm b view uchar * n ulong p ulong w ulong to ulong 1140 i = lt_num b add p 4 1141 t = lt_num b get lcu 0 1142 m = lt_num b get lcu 0 1143 s = get lcu 0 1144 if gt add add s m 1 n 1145 ret p 1146 end 1147 if lt i 4 1148 lt_tcmp b s m i w 1149 end 1150 ret add add s m 1 1151 end 1152 1153 fn lt_cwe b view uchar * p ulong to void 1154 i = lt_num b add p 4 1155 id = lt_num b get lcu 0 1156 ev = lt_num b get lcu 0 1157 v = lt_num b get lcu 0 1158 if ge i 4 1159 ret 1160 end 1161 o = mul i 16 1162 lt_inc add o 12 1163 if and eq ev 1 eq v 4 1164 lt_inc add o 8 1165 end 1166 if and eq ev 4 eq rem id 10 4 1167 lt_inc add o 9 1168 end 1169 if and and eq ev 1 eq v 1 gt get lcw add o 9 0 1170 lt_inc add o 10 1171 end 1172 if eq ev 5 1173 lt_inc add o 11 1174 end 1175 end 1176 1177 fn lt_cwo b view uchar * p ulong to void 1178 i = lt_num b add p 4 1179 q = get lcu 0 1180 ok = lt_pfx b q ltpass 1181 r = lt_num b add q 5 1182 t = lt_num b get lcu 0 1183 if ge i 4 1184 ret 1185 end 1186 o = mul i 16 1187 lt_inc o 1188 if ok 1189 put lcw add o 1 1 1190 end 1191 put lcw add o 2 r 1192 put lcw add o 3 t 1193 end 1194 1195 fn lt_cws b view uchar * p ulong to void 1196 a = lt_num b add p 11 1197 c = lt_num b add get lcu 0 5 1198 lt_inc 64 1199 put lcw 65 a 1200 put lcw 66 c 1201 end 1202 1203 note One complete line (or frame) at p: the position after it, or p when it 1204 note is not complete yet. 1205 fn lt_line b view uchar * n ulong p ulong to ulong 1206 e = lt_eol b n p 1207 if ge e n 1208 ret p 1209 end 1210 if lt_pfx b p ltcwp 1211 ret lt_frm b n p 0 1212 end 1213 if lt_pfx b p ltcwr 1214 ret lt_frm b n p 1 1215 end 1216 if lt_pfx b p ltcwe 1217 lt_cwe b p 1218 end 1219 if lt_pfx b p ltcwo 1220 lt_cwo b p 1221 end 1222 if lt_pfx b p ltcws 1223 lt_cws b p 1224 end 1225 ret add e 1 1226 end 1227 1228 fn lt_parse b view uchar * n ulong to void 1229 lt_pclr 1230 p = ulong 0 1231 for it ulong `1000000` 1232 if ge p n 1233 ret 1234 end 1235 q = lt_line b n p 1236 if eq q p 1237 ret 1238 end 1239 p = q 1240 end 1241 end 1242 1243 fn lt_rd x ulong oi ulong to ulong 1244 b = new uchar `1048576` 0 1245 lp_x x 1246 lp_c 47 1247 lp_on oi 0 1248 n = lf_read b 1249 if le n 0 1250 lt_pclr 1251 ret 0 1252 end 1253 lt_parse b ulong n 1254 ret ulong n 1255 end 1256 1257 note ======== journal v2 reader 1258 1259 fn lj_dec b view uchar 128 r edit ulong 16 k ulong to void 1260 for w ulong k 1261 v = ulong 0 1262 for j ulong 8 1263 v = or v shl ulong get b add mul w 8 j mul j 8 1264 end 1265 put r w v 1266 end 1267 end 1268 1269 fn lj_sum r view ulong 16 n ulong to ulong 1270 h = ulong `14695981039346656037` 1271 for i ulong n 1272 v = get r i 1273 for j ulong 8 1274 h = mul xor h and shr v mul j 8 255 `1099511628211` 1275 end 1276 end 1277 ret h 1278 end 1279 1280 fn lj_hdr r view ulong 16 to bool 1281 for i ulong 4 1282 put ljs add 24 i get r add 3 i 1283 end 1284 s = and eq get r 0 `5786624599` eq get r 1 2 1285 s = and s eq get r 2 128 1286 ret and s eq get r 7 lj_sum r 7 1287 end 1288 1289 fn lj_meq r view ulong 16 e ulong to bool 1290 for i ulong 4 1291 if ne get ljo add e i get r add 3 i 1292 ret false 1293 end 1294 end 1295 ret true 1296 end 1297 1298 fn lj_op r view ulong 16 d ulong to void 1299 k = get ljn 0 1300 for q ulong get ljn 0 bound 1024 1301 e = mul q 12 1302 if lj_meq r e 1303 k = q 1304 break 1305 end 1306 end 1307 if eq k get ljn 0 1308 if ge k 1024 1309 put ljs 11 add get ljs 11 1 1310 ret 1311 end 1312 for i ulong 12 1313 put ljo add mul k 12 i 0 1314 end 1315 for i ulong 4 1316 put ljo add mul k 12 i get r add 3 i 1317 end 1318 put ljn 0 add k 1 1319 end 1320 e = mul k 12 1321 if eq d 0 1322 put ljo add e 4 add get ljo add e 4 1 1323 put ljo add e 6 get r 2 1324 put ljo add e 10 get r 8 1325 put ljo add e 11 get r 7 1326 else 1327 put ljo add e 5 add get ljo add e 5 1 1328 put ljo add e 7 get r 2 1329 put ljo add e 8 get r 7 1330 put ljo add e 9 get r 9 1331 end 1332 end 1333 1334 fn lj_cnt k ulong to void 1335 put ljs k add get ljs k 1 1336 end 1337 1338 fn lj_one r view ulong 16 to void 1339 lj_cnt 0 1340 if ne get r 15 lj_sum r 15 1341 lj_cnt 11 1342 end 1343 if ne get r 1 get ljs 0 1344 lj_cnt 11 1345 end 1346 ty = get r 0 1347 f = get r 2 1348 if eq ty 1 1349 lj_cnt 1 1350 if le f get ljs 28 1351 lj_cnt 17 1352 end 1353 put ljs 28 f 1354 if ne get r 5 3 1355 lj_cnt 16 1356 end 1357 else 1358 if ne f get ljs 28 1359 lj_cnt 17 1360 end 1361 end 1362 if eq ty 2 1363 lj_cnt 4 1364 end 1365 if eq ty 3 1366 lj_cnt 2 1367 lj_op r 0 1368 end 1369 if eq ty 4 1370 lj_cnt 3 1371 lj_op r 1 1372 end 1373 if eq ty 5 1374 lj_cnt 5 1375 end 1376 if eq ty 8 1377 lj_cnt 6 1378 end 1379 if eq ty 11 1380 lj_cnt 7 1381 end 1382 if eq ty 12 1383 lj_cnt 8 1384 end 1385 if eq ty 13 1386 lj_cnt 9 1387 end 1388 if or or eq ty 6 eq ty 7 or eq ty 10 gt ty 13 1389 lj_cnt 10 1390 end 1391 end 1392 1393 note Read and validate DIR/journal of scenario x: 0, or 1 not opened, 2 no 1394 note header. Summary: ljs 0 records, 1 OPEN, 2 START, 3 DONE, 4 ADMIT, 1395 note 5 RELEASE, 6 CANCEL, 7 POLICY, 8 GOAL, 9 FAIR, 10 other types, 11 bad 1396 note (header, checksum, seq, torn), 12 max starts per operation, 13 starts 1397 note of replace operations, 14 operations started and never done, 15 1398 note operations done under a later fence than they started (settled by a 1399 note restart), 16 OPEN with another SPVER, 17 fence errors, 18 operations, 1400 note 24..27 objective identity, 28 current fence. 1401 fn lj_scan x ulong to ulong 1402 b = new uchar 128 0 1403 r = new ulong 16 0 1404 for i ulong 32 1405 put ljs i 0 1406 end 1407 put ljn 0 0 1408 lp_x x 1409 lp_t ltjfl 1410 fd = fopen lpa 0 get lpn 0 0 0 1411 if lt fd 0 1412 ret 1 1413 end 1414 n = read int fd b 0 64 1415 if ne n 64 1416 q = fclose int fd 1417 ret 2 1418 end 1419 lj_dec b r 8 1420 if not lj_hdr r 1421 lj_cnt 11 1422 end 1423 for it ulong `1000000` 1424 n = read int fd b 0 128 1425 if eq n 0 1426 break 1427 end 1428 if ne n 128 1429 lj_cnt 11 1430 break 1431 end 1432 lj_dec b r 16 1433 lj_one r 1434 end 1435 q = fclose int fd 1436 ret 0 1437 end 1438 1439 fn lj_fin to void 1440 put ljs 18 get ljn 0 1441 for k ulong get ljn 0 bound 1024 1442 e = mul k 12 1443 s = get ljo add e 4 1444 if gt s get ljs 12 1445 put ljs 12 s 1446 end 1447 if eq rem get ljo add e 10 10 4 1448 put ljs 13 add get ljs 13 s 1449 end 1450 if and gt s 0 eq get ljo add e 5 0 1451 lj_cnt 14 1452 end 1453 f = ne get ljo add e 6 get ljo add e 7 1454 if and f and gt get ljo add e 5 0 gt s 0 1455 lj_cnt 15 1456 end 1457 end 1458 end 1459 1460 fn lj_pr r ulong to void 1461 lo_kv lterrw r 1462 lo_kv ltrecs get ljs 0 1463 lo_kv ltopens get ljs 1 1464 lo_kv ltadm get ljs 4 1465 lo_kv ltstw get ljs 2 1466 lo_kv ltdnw get ljs 3 1467 lo_kv ltrel get ljs 5 1468 lo_kv ltcanw get ljs 6 1469 lo_kv ltpol get ljs 7 1470 lo_kv ltgoal get ljs 8 1471 lo_kv ltfair get ljs 9 1472 lo_kv ltoth get ljs 10 1473 lo_kv ltbad get ljs 11 1474 lo_kv ltops get ljs 18 1475 lo_kv ltmax get ljs 12 1476 lo_kv ltreps get ljs 13 1477 lo_kv ltopen get ljs 14 1478 lo_kv ltsetl get ljs 15 1479 lo_kv ltspv get ljs 16 1480 lo_kv ltfnc get ljs 17 1481 lo_kv ltidt get ljs 24 1482 for i ulong 3 1483 lo_c 44 1484 lo_n get ljs add 25 i 1485 end 1486 end 1487 1488 fn lj_ops x ulong to void 1489 for k ulong get ljn 0 bound 1024 1490 e = mul k 12 1491 lo_t ltjop 1492 lo_c 32 1493 lo_x x 1494 lo_w ltop 1495 lo_kv ltkjob get ljo add e 10 1496 lo_kv ltcls get ljo add e 11 1497 for i ulong 4 1498 lo_c 32 1499 lo_n get ljo add e i 1500 end 1501 lo_kv ltstw get ljo add e 4 1502 lo_kv ltdnw get ljo add e 5 1503 lo_kv ltfncw get ljo add e 6 1504 lo_c 47 1505 lo_n get ljo add e 7 1506 lo_kv ltoutc get ljo add e 8 1507 lo_kv lthow get ljo add e 9 1508 lo_e 1509 end 1510 end 1511 1512 note The journal checks every scenario shares: readable and intact, every 1513 note OPEN under SPVER 3, fences increasing, no POLICY record (the default 1514 note policy sched_new set was never changed), the expected OPEN count, every 1515 note operation started exactly once and done, and the objective identity 1516 note (tag OMNC, count no, issue 290). The detail goes to the line buffer. 1517 fn lt_cj x ulong opens ulong no ulong to bool 1518 r = lj_scan x 1519 lj_fin 1520 lj_pr r 1521 s = eq r 0 1522 s = and s and eq get ljs 11 0 eq get ljs 16 0 1523 s = and s and eq get ljs 17 0 eq get ljs 7 0 1524 s = and s and eq get ljs 1 opens eq get ljs 12 1 1525 s = and s eq get ljs 14 0 1526 s = and s eq get ljs 24 `1330466371` 1527 s = and s and eq get ljs 25 no eq get ljs 27 290 1528 ret s 1529 end 1530 1531 note ======== the programs 1532 1533 fn lt_go x ulong oi ulong pk view uchar 4096 pn ulong to long 1534 lp_x x 1535 lp_c 47 1536 lp_on oi 0 1537 fo = lf_creat 1538 lp_x x 1539 lp_c 47 1540 lp_on oi 1 1541 fe = lf_creat 1542 if or lt fo 0 lt fe 0 1543 ret neg long 1 1544 end 1545 pid = lt_spawn pk pn fo fe 1546 r = fclose int fo 1547 r = fclose int fe 1548 ret pid 1549 end 1550 1551 note code-main (mode 0) or code-test cancel 20000 (mode 1) on objectives 1552 note 0..no-1 of scenario x, output to run. 1553 fn lt_cw x ulong mode ulong no ulong oi ulong to long 1554 pk = new uchar 4096 0 1555 put lpn 0 0 1556 lp_a 2 1557 if eq mode 0 1558 lp_t ltcmn 1559 else 1560 lp_t ltctst 1561 end 1562 p = pk_p pk 2 1563 if eq mode 1 1564 p = pk_t pk p ltcanc 1565 p = pk_t pk p ltcms 1566 end 1567 put lpn 0 0 1568 lp_a 2 1569 lp_t ltinfr 1570 p = pk_p pk p 1571 put lpn 0 0 1572 lp_a 2 1573 lp_t lttool 1574 p = pk_p pk p 1575 p = pk_a pk p 5 1576 lp_x x 1577 lp_t ltroot 1578 p = pk_p pk p 1579 lp_x x 1580 lp_t ltwork 1581 p = pk_p pk p 1582 lp_x x 1583 lp_t ltjour 1584 p = pk_p pk p 1585 p = pk_t pk p ltport 1586 p = pk_t pk p ltview 1587 for i ulong no bound 4 1588 p = pk_o pk p i 1589 end 1590 if ge p 4096 1591 ret neg long 1 1592 end 1593 ret lt_go x oi pk p 1594 end 1595 1596 note tool check ROOT PATH WORK OMC40 3 K N A on the full run's objective i. 1597 fn lt_tl i ulong to long 1598 pk = new uchar 4096 0 1599 put lpn 0 0 1600 lp_a 2 1601 lp_t lttool 1602 p = pk_p pk 2 1603 p = pk_t pk p ltchk 1604 lp_x 0 1605 lp_t ltroot 1606 p = pk_p pk p 1607 put lpn 0 0 1608 lp_o i 1609 p = pk_p pk p 1610 lp_x 0 1611 lp_t ltrw 1612 lp_n i 1613 p = pk_p pk p 1614 p = pk_a pk p 5 1615 p = pk_t pk p ltk3 1616 for w ulong 3 1617 put lpn 0 0 1618 lp_n lt_kna i w 1619 p = pk_p pk p 1620 end 1621 if ge p 4096 1622 ret neg long 1 1623 end 1624 ret lt_go 0 add 10 i pk p 1625 end 1626 1627 note ollm serve 18399 MODELDIR/model.ck MODELDIR/merges.bin for scenario x, 1628 note logging to serve.log, ready once it printed PORT. The pid, 0 with 1629 note serve=0, negative when it did not come up. 1630 fn lt_serve x ulong to long 1631 pk = new uchar 4096 0 1632 lo_t ltsrvw 1633 lo_c 32 1634 lo_x x 1635 if eq get lopt 0 0 1636 lo_w ltnosrv 1637 lo_e 1638 ret 0 1639 end 1640 p = pk_a pk 2 3 1641 p = pk_t pk p ltserve 1642 p = pk_t pk p ltport 1643 put lpn 0 0 1644 lp_a 4 1645 lp_t ltmck 1646 p = pk_p pk p 1647 put lpn 0 0 1648 lp_a 4 1649 lp_t ltmmg 1650 p = pk_p pk p 1651 lp_x x 1652 lp_t ltslog 1653 fd = lf_creat 1654 if lt fd 0 1655 lo_e 1656 ret neg long 1 1657 end 1658 t0 = ulong monons 1659 pid = lt_spawn pk p fd fd 1660 r = fclose int fd 1661 if le pid 0 1662 lo_e 1663 ret neg long 2 1664 end 1665 lo_kv ltpidw ulong pid 1666 ret lt_srdy x pid t0 1667 end 1668 1669 fn lt_srdy x ulong pid long t0 ulong to long 1670 b = new uchar 65536 0 1671 ws = new uchar 4 0 1672 for it ulong 1500 1673 q = sleepns `200000000` 1674 lp_x x 1675 lp_t ltslog 1676 n = lf_read b 1677 if gt n 0 1678 if lt_has view part b 0 ulong n ltporl 1679 lo_kv ltready div sub ulong monons t0 `1000000` 1680 lo_e 1681 ret pid 1682 end 1683 end 1684 g = waitpid int pid ws 0 4 1 1685 if ne g 0 1686 lo_w ltdied 1687 lo_e 1688 ret neg long 3 1689 end 1690 end 1691 r = killpid neg int pid 9 1692 g = waitpid int pid ws 0 4 0 1693 lo_w lttmo 1694 lo_e 1695 ret neg long 4 1696 end 1697 1698 note Stop a server: TERM to its group, bounded wait, KILL; true when the 1699 note group is gone. 1700 fn lt_stop pid long to bool 1701 if le pid 0 1702 ret true 1703 end 1704 r = killpid neg int pid 15 1705 s = lt_wait pid 15000 1706 r = killpid neg int pid 9 1707 q = sleepns `200000000` 1708 g = killpid neg int pid 0 1709 ret lt g 0 1710 end 1711 1712 fn lt_c499 x ulong to bool 1713 b = new uchar 65536 0 1714 for it ulong 300 1715 lp_x x 1716 lp_t ltslog 1717 n = lf_read b 1718 if gt n 0 1719 if lt_has view part b 0 ulong n lt499 1720 ret true 1721 end 1722 end 1723 q = sleepns `100000000` 1724 end 1725 ret false 1726 end 1727 1728 fn lt_runl x ulong oi ulong e ulong ms ulong l ulong to void 1729 lo_t ltrunw 1730 lo_c 32 1731 lo_x x 1732 lo_c 32 1733 lp_x x 1734 lp_c 47 1735 lp_on oi 0 1736 lo_p 1737 lo_kv ltexit e 1738 lo_kv ltms ms 1739 lo_kv ltleft l 1740 lo_e 1741 end 1742 1743 note ======== preparing a scenario 1744 1745 fn lt_prep1 x ulong i ulong to bool 1746 lp_x x 1747 lp_t ltroot 1748 lp_c 47 1749 lp_o i 1750 lo_t ltprep 1751 lo_c 32 1752 lo_x x 1753 lo_c 32 1754 lo_p 1755 lo_w ltfaultw 1756 lo_c 32 1757 lo_xs i 2 1758 if lt_xeq ltmiss i 2 1759 lo_w ltabs 1760 lo_e 1761 ret true 1762 end 1763 ok = lf_wx i 0 1764 h = lf_hash 1765 lo_w ltsha 1766 lo_c 32 1767 lo_h 1768 lo_kv ltbytes ulong h 1769 lo_e 1770 ret and ok ge h 0 1771 end 1772 1773 fn lt_prep x ulong no ulong to bool 1774 lp_x x 1775 ok = lf_mk 1776 lp_x x 1777 lp_t ltroot 1778 ok = and ok lf_mk 1779 lp_x x 1780 lp_t ltjobs 1781 ok = and ok lf_mk 1782 lp_x x 1783 lp_t ltwork 1784 ok = and ok lf_mk 1785 lp_x x 1786 lp_t ltjour 1787 ok = and ok lf_mk 1788 for i ulong no bound 4 1789 ok = and ok lt_prep1 x i 1790 end 1791 ret ok 1792 end 1793 1794 note ======== full run: four objectives, transcript and review 1795 1796 fn lt_ofmt i ulong to void 1797 o = mul i 16 1798 lo_c 32 1799 lo_c 111 1800 lo_n i 1801 lo_c 61 1802 if eq get lcw add o 1 1 1803 lo_t ltpass 1804 else 1805 lo_t ltfail 1806 end 1807 lo_c 47 1808 lo_n get lcw add o 2 1809 lo_c 47 1810 lo_n get lcw add o 3 1811 end 1812 1813 fn lt_cfull ok bool e ulong l ulong gone bool sp long to void 1814 s = and ok eq e 0 1815 s = and s and eq l 0 gone 1816 s = and s gt sp 0 1817 s = and s eq get lcw 64 1 1818 s = and s and eq get lcw 65 4 eq get lcw 66 0 1819 for i ulong 4 1820 o = mul i 16 1821 s = and s and eq get lcw o 1 eq get lcw add o 1 1 1822 end 1823 lo_kv ltexit e 1824 lo_kv ltsum get lcw 65 1825 lo_c 47 1826 lo_n get lcw 66 1827 for i ulong 4 1828 lt_ofmt i 1829 end 1830 lo_kv ltleft l 1831 lo_kv ltgone lt_b gone 1832 lo_kv ltsrvok lt_b gt sp 0 1833 lt_res lt_ok s ltcfw 1834 end 1835 1836 note Every CWP frame equals the recorded turn prompt and every CWR frame 1837 note the recorded raw reply, in order, and their counts equal the recorded 1838 note turn count. 1839 fn lt_ctr to void 1840 s = true 1841 for i ulong 4 1842 o = mul i 16 1843 nt = get ltnt i 1844 q = and eq get lcw add o 4 nt eq get lcw add o 5 nt 1845 q = and q and eq get lcw add o 6 nt eq get lcw add o 7 nt 1846 s = and and s q gt nt 0 1847 lo_c 32 1848 lo_c 111 1849 lo_n i 1850 lo_kv ltturns nt 1851 lo_kv ltprms get lcw add o 6 1852 lo_c 47 1853 lo_n get lcw add o 4 1854 lo_kv ltraws get lcw add o 7 1855 lo_c 47 1856 lo_n get lcw add o 5 1857 end 1858 lt_res lt_ok s ltctr 1859 end 1860 1861 note The full run's final file of objective i, and the tool's own check of 1862 note it: lrv 0 status, 1 observation offset, 2 observation length. 1863 fn lt_omnt b view uchar * n ulong to void 1864 put lrv 0 999 1865 put lrv 2 0 1866 if not lt_pfx b 0 ltomnt 1867 ret 1868 end 1869 st = lt_num b 6 1870 ol = lt_num b get lcu 0 1871 cl = lt_num b get lcu 0 1872 s = get lcu 0 1873 if gt add s ol n 1874 ret 1875 end 1876 put lrv 0 st 1877 put lrv 1 s 1878 put lrv 2 ol 1879 end 1880 1881 fn lt_rev i ulong to bool 1882 b = new uchar 65536 0 1883 lp_x 0 1884 lp_t ltroot 1885 lp_c 47 1886 lp_o i 1887 lo_t ltrevw 1888 lo_c 32 1889 lo_n i 1890 lo_c 32 1891 lo_p 1892 n = lf_read b 1893 eqc = false 1894 if ge n 0 1895 eqc = lt_xeq view part b 0 ulong n i 1 1896 h = lf_hash 1897 lo_w ltsha 1898 lo_c 32 1899 lo_h 1900 lo_kv ltbytes ulong h 1901 else 1902 lo_w ltabs 1903 end 1904 lo_kv ltcorw lt_b eqc 1905 lp_x 0 1906 lp_t ltrw 1907 lp_n i 1908 m = lf_mk 1909 pid = lt_tl i 1910 e = ulong 997 1911 if gt pid 0 1912 e = lt_wait pid 600000 1913 end 1914 lp_x 0 1915 lp_c 47 1916 lp_on add 10 i 0 1917 k = lf_read b 1918 lt_omnt b ulong k 1919 lo_kv lttst e 1920 lo_kv ltstat get lrv 0 1921 lo_w ltobs 1922 lo_c 32 1923 lo_c 34 1924 lo_t view part b get lrv 1 get lrv 2 1925 lo_c 34 1926 lo_e 1927 ok = and eq e 0 eq get lcw add mul i 16 1 1 1928 if lt_xeq ltmiss i 2 1929 t = lt_seq view part b get lrv 1 get lrv 2 ltfnf 1930 ok = and ok and lt n 0 eq get lrv 0 1 1931 ret and ok t 1932 end 1933 t = lt_seq view part b get lrv 1 get lrv 2 lttp 1934 ok = and ok and eqc eq get lrv 0 0 1935 ret and ok t 1936 end 1937 1938 fn lt_full to void 1939 rr = new ulong 4 0 1940 ok = lt_prep 0 4 1941 sp = lt_serve 0 1942 t0 = ulong monons 1943 pid = lt_cw 0 0 4 0 1944 e = ulong 997 1945 if gt pid 0 1946 e = lt_wait pid `4000000` 1947 end 1948 ms = div sub ulong monons t0 `1000000` 1949 l = lt_left 15000 1950 if gt pid 0 1951 r = killpid neg int pid 9 1952 end 1953 gone = lt_stop sp 1954 sz = lt_rd 0 0 1955 lt_runl 0 0 e ms l 1956 lt_cfull ok e l gone sp 1957 j = lt_cj 0 1 4 1958 lt_res lt_ok j ltcfj 1959 lt_ctr 1960 v = true 1961 for i ulong 4 1962 put rr i lt_b lt_rev i 1963 v = and v eq get rr i 1 1964 end 1965 for i ulong 4 1966 lo_c 32 1967 lo_c 111 1968 lo_n i 1969 lo_c 61 1970 lo_n get rr i 1971 end 1972 lt_res lt_ok v ltcrv 1973 end 1974 1975 note ======== cancellation: code-test cancels objective 0 after 20 s, during 1976 note inference; code-main's cancel path must kill the inference (the 1977 note server logs the dropped request as status 499) and journal the CANCEL. 1978 note lcr: 0 prep ok, 1 exit, 2 ms, 3 node processes left, 4 server logged 1979 note 499, 5 server group gone, 6 server ok. 1980 fn lt_canc to void 1981 put lcr 0 lt_b lt_prep 1 1 1982 sp = lt_serve 1 1983 put lcr 6 lt_b gt sp 0 1984 t0 = ulong monons 1985 pid = lt_cw 1 1 1 0 1986 e = ulong 997 1987 if gt pid 0 1988 e = lt_wait pid 600000 1989 end 1990 put lcr 1 e 1991 put lcr 2 div sub ulong monons t0 `1000000` 1992 put lcr 3 lt_left 15000 1993 if gt pid 0 1994 r = killpid neg int pid 9 1995 end 1996 put lcr 4 lt_b lt_c499 1 1997 put lcr 5 lt_b lt_stop sp 1998 n = lt_rd 1 0 1999 lt_runl 1 0 e get lcr 2 get lcr 3 2000 lt_ccan 2001 j = lt_cj 1 1 1 2002 j = and j ge get ljs 6 1 2003 lt_res lt_ok j ltccj 2004 end 2005 2006 fn lt_ccan to void 2007 ms = get lcr 2 2008 s = and eq get lcr 0 1 eq get lcr 1 1 2009 s = and s and eq get lcw 0 1 eq get lcw 1 0 2010 s = and s and eq get lcw 2 19 ge get lcw 11 1 2011 s = and s and eq get lcr 4 1 eq get lcr 3 0 2012 s = and s and eq get lcr 5 1 eq get lcr 6 1 2013 s = and s and ge ms 20000 lt ms 60000 2014 lo_kv ltexit get lcr 1 2015 lo_kv ltms ms 2016 lt_ofmt 0 2017 lo_kv ltcev get lcw 11 2018 lo_kv ltc499 get lcr 4 2019 lo_kv ltleft get lcr 3 2020 lo_kv ltgone get lcr 5 2021 lt_res lt_ok s ltccn 2022 end 2023 2024 note ======== crash and restart: run1 of objective 0 is SIGKILLed (code-main 2025 note only, its workers left to the node's own cleanup) during the first 2026 note inference after the replace landed; run2 restarts on the same 2027 note root, work and journal. lcr: 0 kill point reached, 1 infer processes 2028 note at the kill, 2 node processes left after run1, 3 run1 CWO lines, 4 2029 note run1 replace jobs issued, 5 run1 replace outcomes, 6 snapshot equals 2030 note the correct file, 7 run2 exit, 8 run2 ms, 9 node processes left after 2031 note run2, 10 server group gone, 11 prep ok, 12 server ok, 13 run1 status. 2032 2033 fn lt_kill pid long to ulong 2034 ws = new uchar 4 0 2035 c = ulong 0 2036 for it ulong 300 2037 c = lt_procs 2038 if gt get linf 0 0 2039 break 2040 end 2041 q = sleepns `100000000` 2042 end 2043 q = sleepns `2000000000` 2044 c = lt_procs 2045 put lcr 1 get linf 0 2046 r = killpid int pid 9 2047 g = waitpid int pid ws 0 4 0 2048 put lcr 13 lt_wst ws 2049 ret 1 2050 end 2051 2052 fn lt_watch pid long to ulong 2053 ws = new uchar 4 0 2054 for it ulong 40000 2055 q = sleepns `100000000` 2056 g = waitpid int pid ws 0 4 1 2057 if ne g 0 2058 put lcr 13 lt_wst ws 2059 ret 0 2060 end 2061 n = lt_rd 2 1 2062 if gt get lcw 10 0 2063 ret lt_kill pid 2064 end 2065 end 2066 ret 0 2067 end 2068 2069 fn lt_snap to bool 2070 b = new uchar 65536 0 2071 lp_x 2 2072 lp_t ltroot 2073 lp_c 47 2074 lp_o 0 2075 n = lf_read b 2076 lo_t ltsnapw 2077 lo_c 32 2078 lo_p 2079 if lt n 0 2080 lo_w ltabs 2081 lo_e 2082 ret false 2083 end 2084 eqc = lt_xeq view part b 0 ulong n 0 1 2085 eqb = lt_xeq view part b 0 ulong n 0 0 2086 lp_x 2 2087 lp_t ltsnap 2088 w = lf_wb view part b 0 ulong n 2089 h = lf_hash 2090 lo_c 32 2091 lo_p 2092 lo_w ltsha 2093 lo_c 32 2094 lo_h 2095 lo_kv ltbytes ulong h 2096 lo_kv ltcorw lt_b eqc 2097 lo_kv ltbrkw lt_b eqb 2098 lo_e 2099 ret and eqc w 2100 end 2101 2102 fn lt_ccr to void 2103 s = and eq get lcr 0 1 ge get lcr 1 1 2104 s = and s and eq get lcr 2 0 eq get lcr 3 0 2105 s = and s and ge get lcr 4 1 ge get lcr 5 1 2106 s = and s and eq get lcr 6 1 eq get lcr 7 0 2107 s = and s and eq get lcw 0 1 eq get lcw 1 1 2108 s = and s and eq get lcr 9 0 eq get lcr 10 1 2109 s = and s and eq get lcr 11 1 eq get lcr 12 1 2110 s = and s eq get lcr 13 137 2111 lo_kv ltkillw get lcr 0 2112 lo_kv ltinfa get lcr 1 2113 lo_kv ltr1st get lcr 13 2114 lo_kv ltr1o get lcr 3 2115 lo_kv ltr1r get lcr 4 2116 lo_kv ltleft get lcr 2 2117 lo_kv ltsnok get lcr 6 2118 lo_kv ltexit get lcr 7 2119 lo_kv ltms get lcr 8 2120 lt_ofmt 0 2121 lo_kv ltr2r get lcw 8 2122 lo_kv ltleft get lcr 9 2123 lo_kv ltgone get lcr 10 2124 lt_res lt_ok s ltccr 2125 end 2126 2127 fn lt_crash to void 2128 for i ulong 16 2129 put lcr i 0 2130 end 2131 ok = lt_prep 2 1 2132 sp = lt_serve 2 2133 put lcr 11 lt_b ok 2134 put lcr 12 lt_b gt sp 0 2135 pid = lt_cw 2 0 1 1 2136 if gt pid 0 2137 put lcr 0 lt_watch pid 2138 end 2139 put lcr 2 lt_left 15000 2140 if gt pid 0 2141 r = killpid neg int pid 9 2142 end 2143 sz = lt_rd 2 1 2144 put lcr 3 get lcw 0 2145 put lcr 4 get lcw 8 2146 put lcr 5 get lcw 9 2147 put lcr 6 lt_b lt_snap 2148 t0 = ulong monons 2149 p2 = lt_cw 2 0 1 2 2150 e = ulong 997 2151 if gt p2 0 2152 e = lt_wait p2 `4000000` 2153 end 2154 put lcr 7 e 2155 put lcr 8 div sub ulong monons t0 `1000000` 2156 put lcr 9 lt_left 15000 2157 if gt p2 0 2158 r = killpid neg int p2 9 2159 end 2160 put lcr 10 lt_b lt_stop sp 2161 lt_runl 2 1 get lcr 13 0 get lcr 2 2162 lt_runl 2 2 e get lcr 8 get lcr 9 2163 sz = lt_rd 2 2 2164 lt_ccr 2165 j = lt_cj 2 2 1 2166 j = and j ge get ljs 15 1 2167 lt_res lt_ok j ltcrj 2168 lj_ops 2 2169 end 2170 2171 note ======== prerequisites, arguments, main 2172 2173 fn lt_hp pin view uchar * chk bool to bool 2174 h = lf_hash 2175 lo_t lthash 2176 lo_c 32 2177 lo_p 2178 if lt h 0 2179 lo_kv ltunrd ulong neg h 2180 lo_e 2181 ret false 2182 end 2183 lo_w ltsha 2184 lo_c 32 2185 lo_h 2186 lo_kv ltbytes ulong h 2187 m = true 2188 if chk 2189 m = lt_hxeq pin 2190 if m 2191 lo_w ltpinok 2192 else 2193 lo_w ltpinbd 2194 end 2195 end 2196 lo_e 2197 ret m 2198 end 2199 2200 fn lt_prq to void 2201 a = ulong 0 2202 put lpn 0 0 2203 lp_a 4 2204 lp_t ltmck 2205 a = add a lt_b lt_hp lhmod true 2206 put lpn 0 0 2207 lp_a 4 2208 lp_t ltmmg 2209 a = add a lt_b lt_hp lhmrg true 2210 put lpn 0 0 2211 lp_a 3 2212 a = add a lt_b lt_hp lhollm true 2213 put lpn 0 0 2214 lp_a 5 2215 a = add a lt_b lt_hp lhomc true 2216 put lpn 0 0 2217 lp_a 6 2218 a = add a lt_b lt_hp lhsel true 2219 c = ulong 0 2220 put lpn 0 0 2221 lp_a 2 2222 lp_t ltinfr 2223 c = add c lt_b lt_hp lhsel false 2224 put lpn 0 0 2225 lp_a 2 2226 lp_t lttool 2227 c = add c lt_b lt_hp lhsel false 2228 put lpn 0 0 2229 lp_a 2 2230 lp_t ltcmn 2231 c = add c lt_b lt_hp lhsel false 2232 put lpn 0 0 2233 lp_a 2 2234 lp_t ltctst 2235 c = add c lt_b lt_hp lhsel false 2236 put lpn 0 0 2237 lp_t ltself 2238 c = add c lt_b lt_hp lhsel false 2239 lo_kv ltpins a 2240 lo_c 47 2241 lo_n 5 2242 lo_kv ltprog c 2243 lo_c 47 2244 lo_n 5 2245 lt_res lt_ok and eq a 5 eq c 5 ltcpre 2246 end 2247 2248 fn lt_leak to void 2249 c = lt_procs 2250 lo_kv ltnode c 2251 lt_res lt_ok eq c 0 ltcnl 2252 end 2253 2254 fn lt_nrf why view uchar * to void 2255 lo_t why 2256 lt_res 2 ltcfw 2257 lo_t why 2258 lt_res 2 ltcfj 2259 lo_t why 2260 lt_res 2 ltctr 2261 lo_t why 2262 lt_res 2 ltcrv 2263 end 2264 2265 fn lt_nrc why view uchar * to void 2266 lo_t why 2267 lt_res 2 ltccn 2268 lo_t why 2269 lt_res 2 ltccj 2270 end 2271 2272 fn lt_nrr why view uchar * to void 2273 lo_t why 2274 lt_res 2 ltccr 2275 lo_t why 2276 lt_res 2 ltcrj 2277 end 2278 2279 fn lt_arg k ulong to bool 2280 n = argread k la mul k 512 511 2281 if or lt n 2 gt n 510 2282 ret false 2283 end 2284 put ll k ulong n 2285 ret eq get la mul k 512 47 2286 end 2287 2288 fn lt_opt k ulong to bool 2289 b = new uchar 512 0 2290 n = argread k b 0 512 2291 if or lt n 7 gt n 12 2292 ret false 2293 end 2294 if and eq n 7 lt_pfx b 0 ltsrv 2295 c = ulong get b 6 2296 if eq c 48 2297 put lopt 0 0 2298 ret true 2299 end 2300 if eq c 49 2301 put lopt 0 1 2302 ret true 2303 end 2304 ret false 2305 end 2306 if not lt_pfx b 0 ltprt 2307 ret false 2308 end 2309 m = ulong 0 2310 for i ulong sub ulong n 6 bound 8 2311 c = ulong get b add 6 i 2312 if eq c 102 2313 m = or m 1 2314 else 2315 if eq c 99 2316 m = or m 2 2317 else 2318 if eq c 114 2319 m = or m 4 2320 else 2321 ret false 2322 end 2323 end 2324 end 2325 end 2326 put lopt 1 m 2327 ret true 2328 end 2329 2330 fn lt_end to int 2331 lo_t ltlive 2332 lo_kv ltchks get lck 0 2333 lo_kv ltpassw get lck 1 2334 lo_kv ltfailw get lck 2 2335 lo_kv ltnrw get lck 3 2336 lo_e 2337 if and eq get lck 2 0 eq get lck 3 0 2338 ret 0 2339 end 2340 ret 1 2341 end 2342 2343 fn main to int 2344 put lpid 0 ulong getpid 2345 put lopt 0 1 2346 put lopt 1 7 2347 c = ulong argcnt 2348 ok = and ge c 7 le c 9 2349 if ok 2350 for k ulong 6 2351 ok = and ok lt_arg add k 1 2352 end 2353 for k ulong sub c 7 bound 2 2354 ok = and ok lt_opt add k 7 2355 end 2356 end 2357 if ok 2358 put lpn 0 0 2359 lp_a 1 2360 ok = lf_mk 2361 end 2362 if not ok 2363 lo_t ltusage 2364 lo_e 2365 ret 2 2366 end 2367 lo_t ltlive 2368 lo_kv ltpidw get lpid 0 2369 lo_w ltbase 2370 lo_c 32 2371 lo_a 1 2372 lo_w ltsrv 2373 lo_n get lopt 0 2374 lo_w ltprt 2375 lo_n get lopt 1 2376 lo_kv ltstart ulong realns 2377 lo_e 2378 lt_prq 2379 s = lt_sel 2380 lt_selr s 2381 if ne and get lopt 1 1 0 2382 if eq s 0 2383 lt_full 2384 else 2385 lt_nrf ltcsel 2386 end 2387 else 2388 lt_nrf ltnsel 2389 end 2390 if ne and get lopt 1 2 0 2391 if eq s 0 2392 lt_canc 2393 else 2394 lt_nrc ltcsel 2395 end 2396 else 2397 lt_nrc ltnsel 2398 end 2399 if ne and get lopt 1 4 0 2400 if eq s 0 2401 lt_crash 2402 else 2403 lt_nrr ltcsel 2404 end 2405 else 2406 lt_nrr ltnsel 2407 end 2408 lt_leak 2409 ret lt_end 2410 end