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/protocol/synapse/pulse/src/10pulse.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 / protocol / synapse / pulse / src / 10pulse.om` 1926 lines ยท 36688 bytes Raw Blame History 1 note synapse-pulse 10pulse.om: reconcile the claims ledger with GitHub and live omp sessions. 2 global gop ulong 16 3 global gopl ulong 16 4 global gfl ulong 8 5 global gnow ulong 2 6 global gco ulong 16384 7 global gcl ulong 16384 8 global gca uchar 1024 9 global gkd uchar 1024 10 global gcn ulong 1 11 global gtk uint 24576 12 global gtn ulong 1024 13 global grpo ulong 128 14 global grpl ulong 128 15 global grp uchar 128 16 global grn ulong 1 17 global gprr ulong 8192 18 global gprn ulong 8192 19 global gprs uchar 8192 20 global gprm uchar 8192 21 global gprho ulong 8192 22 global gprhl ulong 8192 23 global gprc ulong 1 24 global gcnt ulong 32 25 global gout uchar `4194304` 26 global gon ulong 1 27 global gfp ulong 8 28 global gstop uint 32 29 global garr ulong 16 30 global gstopn ulong 1 31 global gmo ulong 1 32 global gss ulong 4 33 global ghs ulong 16 34 global ghit uchar 1024 35 36 text tusage "usage: synapse-pulse [--home DIR] run [--alert] [--alert-dir DIR] [--gh PATH] [--sessions DIR] [--claims-bin PATH] [--offline FIXTUREDIR] [--now YYYY-MM-DDTHH:MM:SSZ]" 37 text trun "run" 38 text thome "--home" 39 text talert "--alert" 40 text tadir "--alert-dir" 41 text tgh "--gh" 42 text tsess "--sessions" 43 text tcbin "--claims-bin" 44 text toff "--offline" 45 text tnow "--now" 46 text tenvh "AIEN_COORD_HOME=" 47 text tenvhm "HOME=" 48 text tdhome "/.local/state/aien-coord" 49 text tenvpath "PATH=" 50 text tdadir "/.local/state/aienos/watch" 51 text tdgh "/.local/bin/gh" 52 text tdsess "/.omp/agent/sessions" 53 text tdpath "/usr/bin:/bin" 54 text tnohome "synapse-pulse: no --home, AIEN_COORD_HOME or HOME" 55 text tbadenvh "synapse-pulse: HOME must be an absolute path" 56 text tnohadir "synapse-pulse: HOME is not set: pass --alert-dir DIR or set HOME" 57 text tnohgh "synapse-pulse: HOME is not set: pass --gh PATH or set HOME" 58 text tnohsess "synapse-pulse: HOME is not set: pass --sessions DIR or set HOME" 59 text tnohkid "synapse-pulse: HOME is not set: the gh child needs HOME (set HOME, or use --offline)" 60 text tnocbin "synapse-pulse: --claims-bin PATH is required (absolute path to synapse-claims)" 61 text tbadnow "synapse-pulse: --now must be YYYY-MM-DDTHH:MM:SSZ" 62 text tlist "list" 63 text tall "--all" 64 text tconf "conflicts" 65 text texpire "expire" 66 text tagent "--agent" 67 text tpulse "pulse" 68 text tslpu "/pulse" 69 text tsletag "/pulse/etags" 70 text tslfind "/pulse/findings.jsonl" 71 text tslreq "/pulse/requests.log" 72 text tsl "/" 73 text tetag ".etag" 74 text tbody ".body" 75 text thttp ".http" 76 text tenv "/usr/bin/env" 77 text tapi "api" 78 text tdi "-i" 79 text tdh "-H" 80 text tinm "If-None-Match: " 81 text tclfail "synapse-pulse: synapse-claims failed: " 82 text tclbad "synapse-pulse: malformed synapse-claims output line" 83 text tkid "id" 84 text tkagent "agent" 85 text tksess "session" 86 text tkkind "kind" 87 text tktarg "target" 88 text tkmode "mode" 89 text tkstate "state" 90 text tkint "intent" 91 text tkexp "expires" 92 text tkact "active" 93 text tksince "since" 94 text tka "a" 95 text tkb "b" 96 text tkreas "reason" 97 text tkop "op" 98 text tknum "number" 99 text tkmerg "merged_at" 100 text tkhead "head" 101 text tkref "ref" 102 text tkfile "filename" 103 text topen "open" 104 text tclosed "closed" 105 text tprepo "repo:" 106 text tpbr "branch:" 107 text tppath "path:" 108 text tppr "pr:" 109 text tpext "ext:" 110 text tmerged "MERGED" 111 text tdeploy "DEPLOYED" 112 text tjsonl ".jsonl" 113 text tpulls "/pulls?state=all&per_page=50" 114 text tfiles "/files?per_page=100" 115 text trepos "repos/" 116 text tpullsl "/pulls/" 117 text tqk "{\"kind\":\"" 118 text tqsev "\",\"severity\":\"" 119 text tqrepo "\",\"repo\":" 120 text tqtarg ",\"target\":" 121 text tqid ",\"id\":" 122 text tqagent ",\"agent\":" 123 text tqsess ",\"session\":" 124 text tqpr ",\"pr\":" 125 text tqpath ",\"path\":" 126 text tqoid ",\"other_id\":" 127 text tqoag ",\"other_agent\":" 128 text tqdet ",\"detail\":" 129 text tqend "}\n" 130 text tsevw "warn" 131 text tsevi "info" 132 text tseve "error" 133 text fexp "expired_lease" 134 text fdead "dead_session" 135 text funk "unknown_session" 136 text funcl "unclaimed_pr" 137 text fstcon "status_contradicted" 138 text fdup "duplicate_work" 139 text fconf "conflict" 140 text tstops "with from into this that them they were been have will also make should would could than then when what which there their about after before over under only just more most some such each other being does done must need" 141 text tcap "synapse-pulse: GitHub request cap (40 per run) reached; skipped: " 142 text tghfail "synapse-pulse: GitHub read failed: " 143 text tbig "synapse-pulse: response over 983040 bytes, skipped: " 144 text tnofix "synapse-pulse: offline fixture missing: " 145 text tsp " " 146 text tinmeq " inm=" 147 text tstateq " status=" 148 text tbyteq " bytes=" 149 text tsrceq " source=" 150 text tsgh "gh" 151 text tsoff "offline" 152 text tscache "cache" 153 text tdash "-" 154 text texpok "synapse-pulse: exec synapse-claims expire --agent pulse exit=" 155 text tevents " events=" 156 text tkalert "COORD-DRIFT" 157 text tslalert "/ALERT" 158 text tslalog "/alerts.log" 159 text tsince " (since " 160 text tdetails "; details " 161 text tclear "/alerts.log; clear with: aien-watch clear COORD-DRIFT)\n" 162 text tresolv " RESOLVED COORD-DRIFT " 163 text tcolsp ": " 164 text tkalcol "COORD-DRIFT:" 165 166 fn pu_ob c uchar to void 167 n = get gon 0 168 if ge n len gout 169 put gfl 7 1 170 ret 171 end 172 put gout n c 173 put gon 0 add n 1 174 end 175 176 fn pu_ot t view uchar * to void 177 for i ulong len t 178 pu_ob get t i 179 end 180 end 181 182 fn pu_od v ulong to void 183 m = syn_mark 184 syn_pd v 185 for i ulong syn_len m 186 pu_ob get gsp add m i 187 end 188 syn_rew m 189 end 190 191 fn pu_hex v ulong to uchar 192 if lt v 10 193 ret uchar add 48 v 194 end 195 ret uchar add 87 v 196 end 197 198 note pu_oq: write pool string (o,n) as a JSON string; control bytes are escaped 199 fn pu_oq o ulong n ulong to void 200 pu_ob 34 201 for i ulong n 202 c = get gsp add o i 203 if or eq c 34 eq c 92 204 pu_ob 92 205 pu_ob c 206 else 207 if lt c 32 208 pu_ob 92 209 if eq c 10 210 pu_ob 110 211 else 212 if eq c 9 213 pu_ob 116 214 else 215 if eq c 13 216 pu_ob 114 217 else 218 pu_ob 117 219 pu_ob 48 220 pu_ob 48 221 pu_ob pu_hex ulong shr c 4 222 pu_ob pu_hex ulong and c 15 223 end 224 end 225 end 226 else 227 pu_ob c 228 end 229 end 230 end 231 pu_ob 34 232 end 233 234 fn pu_cf c ulong f ulong to ulong 235 ret get gco add mul c 16 f 236 end 237 238 fn pu_cl c ulong f ulong to ulong 239 ret get gcl add mul c 16 f 240 end 241 242 fn pu_oqf c ulong f ulong to void 243 if ge c get gcn 0 244 pu_ob 34 245 pu_ob 34 246 ret 247 end 248 pu_oq pu_cf c f pu_cl c f 249 end 250 251 note pu_fnd: one finding line with the fixed 12 keys; gfp 0 pr, 1/2 path, 3/4 detail 252 note sev 0 info, 1 warn, 2 error; c and oc are claim rows (oc `4294967295` = none) 253 fn pu_fnd kind view uchar * sev ulong c ulong oc ulong to void 254 if and gt sev 0 eq get gcnt 8 0 255 put gcnt 8 1 256 put gcnt 9 get gfp 3 257 put gcnt 10 get gfp 4 258 end 259 pu_ot tqk 260 pu_ot kind 261 pu_ot tqsev 262 if eq sev 0 263 pu_ot tsevi 264 put gcnt 1 add get gcnt 1 1 265 else 266 if eq sev 1 267 pu_ot tsevw 268 else 269 pu_ot tseve 270 end 271 put gcnt 0 add get gcnt 0 1 272 end 273 pu_ot tqrepo 274 pu_oqf c 9 275 pu_ot tqtarg 276 pu_oqf c 4 277 pu_ot tqid 278 pu_oqf c 0 279 pu_ot tqagent 280 pu_oqf c 1 281 pu_ot tqsess 282 pu_oqf c 2 283 pu_ot tqpr 284 pu_od get gfp 0 285 pu_ot tqpath 286 pu_oq get gfp 1 get gfp 2 287 pu_ot tqoid 288 pu_oqf oc 0 289 pu_ot tqoag 290 pu_oqf oc 1 291 pu_ot tqdet 292 pu_oq get gfp 3 get gfp 4 293 pu_ot tqend 294 put gfp 0 0 295 put gfp 1 0 296 put gfp 2 0 297 put gfp 3 0 298 put gfp 4 0 299 end 300 301 note pu_det: mark the detail text that starts at pool offset m 302 fn pu_det m ulong to void 303 put gfp 3 m 304 put gfp 4 syn_len m 305 end 306 307 fn pu_opt i ulong to bool 308 ret ne get gopl i 0 309 end 310 311 note pu_popt: append option i (a pool string) to the pool 312 fn pu_popt i ulong to void 313 syn_ps get gop i get gopl i 314 end 315 316 fn pu_pathi i ulong t view uchar * to ulong 317 m = syn_mark 318 pu_popt i 319 syn_pt t 320 ret m 321 end 322 323 fn pu_cargv to void 324 syn_ainit 325 syn_ap get gop 4 get gopl 4 326 syn_at thome 327 syn_ap get gop 0 get gopl 0 328 if eq get gfl 2 1 329 syn_at tnow 330 syn_ap get gop 6 get gopl 6 331 end 332 end 333 334 fn pu_errout pre view uchar * to void 335 w = write 2 pre 0 len pre 336 c = get gxs 0 337 m = syn_mark 338 syn_pd ulong c 339 w = write 2 gsp m syn_len m 340 syn_rew m 341 w = write 2 tsp 0 1 342 w = write 2 gerrb 0 get gerrn 0 343 w = write 2 tnl 0 1 344 end 345 346 note pu_key: field number of member key token at src off; 20 for active, 99 otherwise 347 fn pu_key src view uchar * off ulong to ulong 348 if js_streq src off tkid 349 ret 0 350 end 351 if js_streq src off tkagent 352 ret 1 353 end 354 if js_streq src off tksess 355 ret 2 356 end 357 if js_streq src off tkkind 358 ret 3 359 end 360 if js_streq src off tktarg 361 ret 4 362 end 363 if js_streq src off tkmode 364 ret 5 365 end 366 if js_streq src off tkstate 367 ret 6 368 end 369 if js_streq src off tkint 370 ret 7 371 end 372 if js_streq src off tkexp 373 ret 8 374 end 375 if js_streq src off tksince 376 ret 11 377 end 378 if js_streq src off tkact 379 ret 20 380 end 381 ret 99 382 end 383 384 note pu_soff: source offset of token v when it is a string, else jsnone (string offsets are below 983040) 385 fn pu_soff tape view uint * v ulong to ulong 386 if ne js_type tape v jsstr 387 ret jsnone 388 end 389 ret js_off tape v 390 end 391 392 note pu_sval: decode the string at source offset off (pu_soff) into the pool; offset returned, gxs 2 = 393 note length (0 if off is jsnone). Takes the offset, not the token, to stay within six parameter slots. 394 fn pu_sval src view uchar * off ulong tmp edit uchar * to ulong 395 m = syn_mark 396 put gxs 2 0 397 if eq off jsnone 398 ret m 399 end 400 n = js_sget src off tmp 401 if lt n 0 402 ret m 403 end 404 syn_pa tmp 0 ulong n 405 put gxs 2 n 406 ret m 407 end 408 409 note pu_memb: value token of member key in object token get gmo 0, or jsnone. The object token comes 410 note in gmo because src, tape and key (two slots each) already fill the six parameter slots. 411 fn pu_memb src view uchar * tape view uint * key view uchar * to ulong 412 o = get gmo 0 413 if ne js_type tape o jsobj 414 ret jsnone 415 end 416 k = js_first tape o 417 while ne k jsnone bound 999999 418 if js_streq src js_off tape k key 419 ret add k 1 420 end 421 k = js_mnext tape k 422 end 423 ret jsnone 424 end 425 426 note pu_derive: kind code, repo (field 9) and rest (field 10) from the target string 427 fn pu_derive c ulong to void 428 o = pu_cf c 4 429 n = pu_cl c 4 430 b = mul c 16 431 k = uchar 0 432 p = ulong 0 433 sep = uchar 0 434 if syn_pre o n tprepo 435 k = 1 436 p = len tprepo 437 end 438 if syn_pre o n tpbr 439 k = 2 440 p = len tpbr 441 sep = 35 442 end 443 if syn_pre o n tppath 444 k = 3 445 p = len tppath 446 sep = 58 447 end 448 if syn_pre o n tppr 449 k = 4 450 p = len tppr 451 sep = 35 452 end 453 if syn_pre o n tpext 454 k = 5 455 end 456 put gkd c k 457 if or eq k 0 eq k 5 458 ret 459 end 460 e = n 461 if ne sep 0 462 e = syn_find o n p sep 463 end 464 put gco add b 9 add o p 465 put gcl add b 9 sub e p 466 if lt e n 467 put gco add b 10 add add o e 1 468 put gcl add b 10 sub sub n e 1 469 end 470 end 471 472 text tmany "synapse-pulse: over 1024 claims" 473 text texpbad "synapse-pulse: claim expires is not YYYY-MM-DDTHH:MM:SSZ" 474 note pu_setcf: claim row c field f is pool string o, length as pu_sval left it in gxs 2 475 fn pu_setcf c ulong f ulong o ulong to void 476 x = add mul c 16 f 477 put gco x o 478 put gcl x ulong get gxs 2 479 end 480 481 fn pu_ldrow src view uchar * tape edit uint * tmp edit uchar * to long 482 if lt js_parse src tape len src 0 483 ret neg long 65 484 end 485 if ne js_type tape 0 jsobj 486 ret neg long 65 487 end 488 c = get gcn 0 489 if ge c 1024 490 syn_die tmany 70 491 end 492 for f ulong 16 493 put gco add mul c 16 f 0 494 put gcl add mul c 16 f 0 495 end 496 put gca c 0 497 k = js_first tape 0 498 while ne k jsnone bound 999999 499 f = pu_key src js_off tape k 500 if lt f 12 501 pu_setcf c f pu_sval src pu_soff tape add k 1 tmp 502 end 503 if eq f 20 504 if eq js_type tape add k 1 jstrue 505 put gca c 1 506 end 507 end 508 k = js_mnext tape k 509 end 510 if eq pu_cl c 0 0 511 ret neg long 65 512 end 513 if ne pu_cl c 8 0 514 t = syn_tsp pu_cf c 8 pu_cl c 8 515 if eq get gxs 2 0 516 w = write 2 texpbad 0 len texpbad 517 w = write 2 tnl 0 1 518 ret neg long 65 519 end 520 end 521 put gcn 0 add c 1 522 pu_derive c 523 ret 0 524 end 525 526 note pu_eol: offset i ends a line of raw[0..n): i is n or raw[i] is a newline 527 fn pu_eol raw view uchar * i ulong n ulong to bool 528 if eq i n 529 ret true 530 end 531 ret eq get raw syn_min i sub len raw 1 10 532 end 533 534 note pu_lines: kind 0 list rows, 1 conflicts, 2 expire events; returns rows or negative 535 fn pu_lines raw view uchar * n ulong kind ulong to long 536 tape = new uint 65536 0 537 tmp = new uchar 65536 0 538 rows = js_init tape 65536 64 539 rows = 0 540 s = ulong 0 541 for i ulong add n 1 542 if pu_eol raw i n 543 if gt i s 544 q = long 0 545 if eq kind 0 546 q = pu_ldrow part raw s sub i s tape tmp 547 end 548 if eq kind 1 549 q = pu_cfrow part raw s sub i s tape tmp 550 end 551 if eq kind 2 552 q = pu_exrow part raw s sub i s tape tmp 553 end 554 if lt q 0 555 w = write 2 tclbad 0 len tclbad 556 w = write 2 tnl 0 1 557 ret q 558 end 559 rows = add rows 1 560 end 561 s = add i 1 562 end 563 end 564 ret rows 565 end 566 567 note pu_byid: claim row with id (o,n), or `4294967295` 568 fn pu_byid o ulong n ulong to ulong 569 for c ulong get gcn 0 570 if syn_peq pu_cf c 0 pu_cl c 0 o n 571 ret c 572 end 573 end 574 ret `4294967295` 575 end 576 577 text tdconf "ledger conflict " 578 text tvs " vs " 579 fn pu_cfrow src view uchar * tape edit uint * tmp edit uchar * to long 580 if lt js_parse src tape len src 0 581 ret neg long 65 582 end 583 put gmo 0 0 584 a = pu_memb src tape tka 585 b = pu_memb src tape tkb 586 if or eq a jsnone eq b jsnone 587 ret neg long 65 588 end 589 put gmo 0 a 590 a = pu_memb src tape tkid 591 put gmo 0 b 592 b = pu_memb src tape tkid 593 if or eq a jsnone eq b jsnone 594 ret neg long 65 595 end 596 m = syn_mark 597 o = pu_sval src pu_soff tape a tmp 598 a = pu_byid o ulong get gxs 2 599 o = pu_sval src pu_soff tape b tmp 600 b = pu_byid o ulong get gxs 2 601 syn_rew m 602 put gmo 0 0 603 rs = pu_memb src tape tkreas 604 m = syn_mark 605 syn_pt tdconf 606 if ne rs jsnone 607 o = pu_sval src pu_soff tape rs tmp 608 end 609 syn_pb 58 610 syn_pb 32 611 if lt a get gcn 0 612 syn_ps pu_cf a 4 pu_cl a 4 613 end 614 syn_pt tvs 615 if lt b get gcn 0 616 syn_ps pu_cf b 4 pu_cl b 4 617 end 618 pu_det m 619 pu_fnd fconf 2 a b 620 ret 0 621 end 622 623 text tdexp "lease expired at " 624 text tdexp2 "; pulse appended the expire event" 625 fn pu_exrow src view uchar * tape edit uint * tmp edit uchar * to long 626 r = js_parse src tape len src 627 if lt r 0 628 ret neg long 65 629 end 630 put gmo 0 0 631 ix = pu_memb src tape tkid 632 if eq ix jsnone 633 ret neg long 65 634 end 635 m = syn_mark 636 o = pu_sval src pu_soff tape ix tmp 637 c = pu_byid o ulong get gxs 2 638 syn_rew m 639 if ge c get gcn 0 640 ret 0 641 end 642 m = syn_mark 643 syn_pt tdexp 644 syn_ps pu_cf c 8 pu_cl c 8 645 syn_pt tdexp2 646 pu_det m 647 pu_fnd fexp 1 c `4294967295` 648 ret 0 649 end 650 651 text tclbig "synapse-pulse: synapse-claims list output over 3 MiB" 652 fn pu_ldclaims to long 653 raw = new uchar `3145728` 0 654 pu_cargv 655 syn_at tlist 656 syn_at tall 657 n = syn_run raw `120000000000` 658 if ne get gxs 0 0 659 pu_errout tclfail 660 ret neg long 70 661 end 662 if gt get gxs 1 long len raw 663 syn_die tclbig 70 664 end 665 r = pu_lines raw n 0 666 ret r 667 end 668 669 fn pu_ldconf to long 670 raw = new uchar `1048576` 0 671 pu_cargv 672 syn_at tconf 673 n = syn_run raw `120000000000` 674 if gt get gxs 0 1 675 pu_errout tclfail 676 ret neg long 70 677 end 678 r = pu_lines raw n 1 679 ret r 680 end 681 682 fn pu_expire to long 683 need = ulong 0 684 for c ulong get gcn 0 685 if and eq get gca c 0 ne pu_cl c 8 0 686 t = syn_tsp pu_cf c 8 pu_cl c 8 687 if and eq get gxs 2 1 le t get gnow 0 688 need = 1 689 end 690 end 691 end 692 if eq need 0 693 ret 0 694 end 695 raw = new uchar `1048576` 0 696 pu_cargv 697 syn_at texpire 698 syn_at tagent 699 syn_at tpulse 700 n = syn_run raw `120000000000` 701 w = write 2 texpok 0 len texpok 702 m = syn_mark 703 syn_pd ulong get gxs 0 704 w = write 2 gsp m syn_len m 705 syn_rew m 706 if ne get gxs 0 0 707 w = write 2 tnl 0 1 708 pu_errout tclfail 709 ret neg long 70 710 end 711 r = pu_lines raw n 2 712 w = write 2 tevents 0 len tevents 713 m = syn_mark 714 syn_pd ulong r 715 w = write 2 gsp m syn_len m 716 syn_rew m 717 w = write 2 tnl 0 1 718 ret r 719 end 720 721 note sessions: claim session is an absolute .jsonl path, a top-level session uuid or a dotted omp agent id 722 fn pu_mtime po ulong pn ulong to long 723 st = new uchar 128 0 724 r = stat gsp po pn st 0 128 725 if lt r 0 726 ret neg long 1 727 end 728 v = ulong 0 729 for i ulong 8 730 v = or v shl ulong get st add 88 i mul i 8 731 end 732 ret long v 733 end 734 735 fn pu_isuuid o ulong n ulong to bool 736 if ne n 36 737 ret false 738 end 739 for i ulong 36 740 c = get gsp add o i 741 if or or eq i 8 eq i 13 or eq i 18 eq i 23 742 if ne c 45 743 ret false 744 end 745 else 746 if not or and ge c 48 le c 57 and ge c 97 le c 102 747 ret false 748 end 749 end 750 end 751 ret true 752 end 753 754 note pu_agpath: append the subagent file path for agent id (so,sn) under the session dir prefix already in the pool 755 fn pu_agpath so ulong sn ulong to void 756 for i ulong sn 757 if eq get gsp add so i 46 758 syn_ps so i 759 syn_pb 47 760 end 761 end 762 syn_ps so sn 763 syn_pt tjsonl 764 end 765 766 note pu_u16: little-endian 16-bit value at db[p] 767 fn pu_u16 db view uchar * p ulong to ulong 768 ret or ulong get db p shl ulong get db add p 1 8 769 end 770 771 note pu_dend: first offset from e that holds a zero byte or reaches lim (end of a dirent name) 772 fn pu_dend db view uchar * e ulong lim ulong to ulong 773 x = e 774 while and lt x lim ne get db x 0 bound 4096 775 x = add x 1 776 end 777 ret x 778 end 779 780 note pu_sfx: db[a..a+l) equals pool bytes gsp[q..q+l) 781 fn pu_sfx db view uchar * a ulong q ulong l ulong to bool 782 for j ulong l 783 if ne get db add a j get gsp add q j 784 ret false 785 end 786 end 787 ret true 788 end 789 790 note session lookup state in gss: 0-1 session string (so,sn) of the claim, 2 mode (1 uuid, 2 agent id) 791 note pu_scone: mtime of slug dir (po,pn) entry db[nm..e) when it belongs to the session, else -1 792 fn pu_scone db view uchar * nm ulong e ulong po ulong pn ulong to long 793 t = neg long 1 794 m = syn_mark 795 syn_ps po pn 796 syn_pb 47 797 syn_pa db nm sub e nm 798 if eq get gss 2 1 799 q = syn_mark 800 syn_pb 95 801 syn_ps get gss 0 get gss 1 802 syn_pt tjsonl 803 l = syn_len q 804 syn_rew q 805 ok = false 806 if ge sub e nm l 807 ok = pu_sfx db sub e l q l 808 end 809 if not ok 810 syn_rew m 811 end 812 end 813 if eq get gss 2 2 814 syn_pb 47 815 pu_agpath get gss 0 get gss 1 816 end 817 if gt syn_len m 0 818 t = pu_mtime m syn_len m 819 end 820 syn_rew m 821 ret t 822 end 823 824 note pu_scan2: entries of one slug dir (po,pn); best mtime for the session in gss 825 fn pu_scan2 po ulong pn ulong to long 826 best = neg long 1 827 fd = fopen gsp po pn 524288 0 828 if lt fd 0 829 ret best 830 end 831 db = new uchar 32768 0 832 while true bound 100000 833 k = getdnts int fd db 0 len db 834 if le k 0 835 break 836 end 837 p = ulong 0 838 while lt p ulong k bound 100000 839 rl = pu_u16 db add p 16 840 nm = add p 19 841 e = pu_dend db nm add p rl 842 if gt sub e nm 2 843 t = pu_scone db nm e po pn 844 if gt t best 845 best = t 846 end 847 end 848 if eq rl 0 849 break 850 end 851 p = add p rl 852 end 853 end 854 c = fclose int fd 855 ret best 856 end 857 858 note pu_slugs: best mtime for the session in gss over every slug dir under --sessions 859 fn pu_slugs to long 860 best = neg long 1 861 fd = fopen gsp get gop 3 get gopl 3 524288 0 862 if lt fd 0 863 ret best 864 end 865 db = new uchar 32768 0 866 while true bound 100000 867 k = getdnts int fd db 0 len db 868 if le k 0 869 break 870 end 871 p = ulong 0 872 while lt p ulong k bound 100000 873 rl = pu_u16 db add p 16 874 nm = add p 19 875 e = pu_dend db nm add p rl 876 if and gt sub e nm 0 ne get db nm 46 877 m = syn_mark 878 pu_popt 3 879 syn_pb 47 880 syn_pa db nm sub e nm 881 t = pu_scan2 m syn_len m 882 if gt t best 883 best = t 884 end 885 syn_rew m 886 end 887 if eq rl 0 888 break 889 end 890 p = add p rl 891 end 892 end 893 r = fclose int fd 894 ret best 895 end 896 897 fn pu_sessmt c ulong to long 898 so = pu_cf c 2 899 sn = pu_cl c 2 900 if eq sn 0 901 ret neg long 1 902 end 903 if eq get gsp so 47 904 ret pu_mtime so sn 905 end 906 put gss 0 so 907 put gss 1 sn 908 put gss 2 2 909 if pu_isuuid so sn 910 put gss 2 1 911 end 912 ret pu_slugs 913 end 914 915 text tdunk "session not found under --sessions (accepted: omp agent id, session uuid, absolute .jsonl path)" 916 text tddead "active lease but session file last written " 917 text tddead2 " (over 2h ago)" 918 fn pu_sessions to void 919 for c ulong get gcn 0 920 if eq get gca c 1 921 t = pu_sessmt c 922 if lt t 0 923 m = syn_mark 924 syn_pt tdunk 925 pu_det m 926 pu_fnd funk 0 c `4294967295` 927 else 928 if gt get gnow 0 add ulong t 7200 929 m = syn_mark 930 syn_pt tddead 931 syn_tsw ulong t 932 syn_pt tddead2 933 pu_det m 934 pu_fnd fdead 1 c `4294967295` 935 end 936 end 937 end 938 end 939 end 940 941 note intent tokens: lower-case alphanumeric runs of 4+ bytes, FNV-1a 32, stop words dropped 942 fn pu_lc c uchar to uchar 943 if and ge c 65 le c 90 944 ret uchar add c 32 945 end 946 ret c 947 end 948 949 fn pu_isan c uchar to bool 950 ret or or and ge c 48 le c 57 and ge c 97 le c 122 and ge c 65 le c 90 951 end 952 953 fn pu_isstop h uint to bool 954 for i ulong get gstopn 0 955 if eq get gstop i h 956 ret true 957 end 958 end 959 ret false 960 end 961 962 note pu_tkdup: hash h is a stop word or already among the first cnt tokens of claim row c 963 fn pu_tkdup c ulong cnt ulong h uint to bool 964 if pu_isstop h 965 ret true 966 end 967 for j ulong cnt 968 if eq get gtk add mul c 24 j h 969 ret true 970 end 971 end 972 ret false 973 end 974 975 note pu_toks: hash the tokens of (o,n); mode 0 fills the stop list, mode 1 fills claim row c 976 fn pu_toks o ulong n ulong mode ulong c ulong to void 977 h = uint `2166136261` 978 k = ulong 0 979 cnt = ulong 0 980 for i ulong add n 1 981 ch = uchar 32 982 if lt i n 983 ch = get gsp add o i 984 end 985 if pu_isan ch 986 h = mul xor h uint pu_lc ch `16777619` 987 k = add k 1 988 else 989 if ge k 4 990 if eq mode 0 991 if lt get gstopn 0 32 992 put gstop get gstopn 0 h 993 put gstopn 0 add get gstopn 0 1 994 end 995 else 996 if lt cnt 24 997 if not pu_tkdup c cnt h 998 put gtk add mul c 24 cnt h 999 cnt = add cnt 1 1000 end 1001 end 1002 end 1003 end 1004 h = `2166136261` 1005 k = 0 1006 end 1007 end 1008 if eq mode 1 1009 put gtn c cnt 1010 end 1011 end 1012 1013 text tddup "intents share " 1014 text tddup2 " of " 1015 text tddup3 " tokens: " 1016 text tddup4 " || " 1017 note pu_tkcnt: tokens of claim row b equal to x 1018 fn pu_tkcnt b ulong x uint to ulong 1019 k = ulong 0 1020 for j ulong get gtn b 1021 if eq get gtk add mul b 24 j x 1022 k = add k 1 1023 end 1024 end 1025 ret k 1026 end 1027 1028 note pu_shared: token pairs equal between claim rows a and b 1029 fn pu_shared a ulong b ulong to ulong 1030 sh = ulong 0 1031 for i ulong get gtn a 1032 x = get gtk add mul a 24 i 1033 sh = add sh pu_tkcnt b x 1034 end 1035 ret sh 1036 end 1037 1038 fn pu_dup to void 1039 for c ulong get gcn 0 1040 put gtn c 0 1041 if eq get gca c 1 1042 pu_toks pu_cf c 7 pu_cl c 7 1 c 1043 end 1044 end 1045 n = get gcn 0 1046 for a ulong n 1047 for b ulong n 1048 if and and lt a b eq get gca a 1 eq get gca b 1 1049 if not syn_peq pu_cf a 1 pu_cl a 1 pu_cf b 1 pu_cl b 1 1050 sh = pu_shared a b 1051 mn = syn_min get gtn a get gtn b 1052 if and ge sh 3 ge mul sh 2 mn 1053 m = syn_mark 1054 syn_pt tddup 1055 syn_pd sh 1056 syn_pt tddup2 1057 syn_pd mn 1058 syn_pt tddup3 1059 syn_ps pu_cf a 7 pu_cl a 7 1060 syn_pt tddup4 1061 syn_ps pu_cf b 7 pu_cl b 7 1062 pu_det m 1063 pu_fnd fdup 1 a b 1064 end 1065 end 1066 end 1067 end 1068 end 1069 end 1070 1071 note repos with active claims; grp marks repos holding an active path claim 1072 fn pu_repos to void 1073 put grn 0 0 1074 for c ulong get gcn 0 1075 rl = pu_cl c 9 1076 if and eq get gca c 1 ne rl 0 1077 ro = pu_cf c 9 1078 f = get grn 0 1079 for r ulong get grn 0 1080 if syn_peq get grpo r get grpl r ro rl 1081 f = r 1082 end 1083 end 1084 if and eq f get grn 0 lt f 128 1085 put grpo f ro 1086 put grpl f rl 1087 put grp f 0 1088 put grn 0 add f 1 1089 end 1090 if and lt f get grn 0 eq get gkd c 3 1091 put grp f 1 1092 end 1093 end 1094 end 1095 end 1096 1097 note pu_segst: pool offset t starts a path segment of the string that begins at s 1098 fn pu_segst s ulong t ulong to bool 1099 if eq t s 1100 ret true 1101 end 1102 ret eq get gsp sub t 1 47 1103 end 1104 1105 note glob: * matches inside one path segment, ** any depth (including none) 1106 fn pu_glob p ulong pe ulong s ulong se ulong to bool 1107 if eq p pe 1108 ret eq s se 1109 end 1110 c = get gsp p 1111 if eq c 42 1112 if and lt add p 1 pe eq get gsp add p 1 42 1113 q = add p 2 1114 if and lt q pe eq get gsp q 47 1115 for i ulong add sub se s 1 1116 if pu_segst s add s i 1117 if pu_glob add q 1 pe add s i se 1118 ret true 1119 end 1120 end 1121 end 1122 ret false 1123 end 1124 for i ulong add sub se s 1 1125 if pu_glob q pe add s i se 1126 ret true 1127 end 1128 end 1129 ret false 1130 end 1131 for i ulong add sub se s 1 1132 if pu_glob add p 1 pe add s i se 1133 ret true 1134 end 1135 if lt add s i se 1136 if eq get gsp add s i 47 1137 ret false 1138 end 1139 end 1140 end 1141 ret false 1142 end 1143 if eq s se 1144 ret false 1145 end 1146 if ne c get gsp s 1147 ret false 1148 end 1149 ret pu_glob add p 1 pe add s 1 se 1150 end 1151 1152 note GitHub: cache key is the request path with / replaced by , 1153 fn pu_key2 po ulong pn ulong to ulong 1154 m = syn_mark 1155 for i ulong pn 1156 c = get gsp add po i 1157 if eq c 47 1158 c = 44 1159 end 1160 syn_pb c 1161 end 1162 ret m 1163 end 1164 1165 fn pu_lognum t view uchar * v ulong to void 1166 syn_pt t 1167 syn_pd v 1168 end 1169 1170 fn pu_reqlog po ulong pn ulong eo ulong en ulong st ulong bl ulong to void 1171 m = syn_mark 1172 syn_tsw div ulong realns `1000000000` 1173 syn_pb 32 1174 syn_ps po pn 1175 syn_pt tinmeq 1176 if eq en 0 1177 syn_pt tdash 1178 else 1179 syn_ps eo en 1180 end 1181 pu_lognum tstateq st 1182 pu_lognum tbyteq bl 1183 syn_pt tsrceq 1184 if eq st 304 1185 syn_pt tscache 1186 else 1187 if eq get gfl 1 1 1188 syn_pt tsoff 1189 else 1190 syn_pt tsgh 1191 end 1192 end 1193 syn_pb 10 1194 l = syn_len m 1195 p = pu_pathi 0 tslreq 1196 fd = fopen gsp p syn_len p 525377 420 1197 if ge fd 0 1198 w = write int fd gsp m l 1199 c = fclose int fd 1200 end 1201 syn_rew m 1202 end 1203 1204 text tetagh "etag:" 1205 note pu_lower: ASCII lower-case of byte 1206 fn pu_hdr a view uchar * s ulong e ulong to bool 1207 if lt sub e s 5 1208 ret false 1209 end 1210 for i ulong 5 1211 if ne pu_lc get a add s i get tetagh i 1212 ret false 1213 end 1214 end 1215 ret true 1216 end 1217 1218 note pu_gh request state in ghs: 0 pool base, 1-2 cache key, 3-4 etag file path, 5-6 stored etag, 1219 note 7-8 etag of the response 1220 note pu_ghetag: cache key and etag file path of (po,pn) into the pool; the stored etag after them 1221 fn pu_ghetag po ulong pn ulong to void 1222 ko = pu_key2 po pn 1223 put ghs 1 ko 1224 put ghs 2 syn_len ko 1225 ep = pu_pathi 0 tsletag 1226 syn_pb 47 1227 syn_ps ko get ghs 2 1228 syn_pt tetag 1229 put ghs 3 ep 1230 put ghs 4 syn_len ep 1231 eb = new uchar 1024 0 1232 el = syn_rfile ep get ghs 4 eb 1233 put ghs 5 syn_mark 1234 en = ulong 0 1235 if gt el 0 1236 for i ulong ulong el 1237 c = get eb i 1238 if and ne c 10 ne c 13 1239 syn_pb c 1240 en = add en 1 1241 end 1242 end 1243 end 1244 put ghs 6 en 1245 end 1246 1247 note pu_ghget: raw response of (po,pn) into obf (fixture or gh api -i); its length, or -2 after cleanup 1248 fn pu_ghget obf edit uchar * po ulong pn ulong to long 1249 if eq get gfl 1 1 1250 fp = pu_pathi 5 tsl 1251 syn_ps get ghs 1 get ghs 2 1252 syn_pt thttp 1253 r = syn_rfile fp syn_len fp obf 1254 if lt r 0 1255 w = write 2 tnofix 0 len tnofix 1256 w = write 2 gsp fp syn_len fp 1257 w = write 2 tnl 0 1 1258 syn_rew get ghs 0 1259 put gcnt 3 add get gcnt 3 1 1260 ret neg long 2 1261 end 1262 ret r 1263 end 1264 syn_ainit 1265 syn_at tenv 1266 syn_ap get gop 9 get gopl 9 1267 syn_ap get gop 10 get gopl 10 1268 syn_ap get gop 2 get gopl 2 1269 syn_at tapi 1270 syn_at tdi 1271 if gt get ghs 6 0 1272 syn_at tdh 1273 h = syn_mark 1274 syn_pt tinm 1275 syn_ps get ghs 5 get ghs 6 1276 syn_ap h syn_len h 1277 end 1278 syn_ap po pn 1279 n = syn_run obf `60000000000` 1280 if gt get gxs 0 1 1281 w = write 2 tghfail 0 len tghfail 1282 w = write 2 gsp po pn 1283 pu_errout tsp 1284 syn_rew get ghs 0 1285 put gcnt 3 add get gcnt 3 1 1286 ret neg long 2 1287 end 1288 ret long n 1289 end 1290 1291 note pu_ghst: HTTP status from the first line of the response obf[0..n) 1292 fn pu_ghst obf view uchar * n ulong to ulong 1293 st = ulong 0 1294 if and gt n 12 eq get obf 0 72 1295 sp = ulong 0 1296 while and lt sp n ne get obf sp 32 bound 64 1297 sp = add sp 1 1298 end 1299 for i ulong 3 1300 c = ulong get obf syn_min add add sp 1 i sub n 1 1301 st = add mul st 10 sub c 48 1302 end 1303 end 1304 ret st 1305 end 1306 1307 note pu_skipsp: first offset from v below e that is not a space 1308 fn pu_skipsp a view uchar * v ulong e ulong to ulong 1309 x = v 1310 while and lt x e eq get a x 32 bound 4096 1311 x = add x 1 1312 end 1313 ret x 1314 end 1315 1316 note pu_ghhdr: body offset of the response obf[0..n); appends its etag to the pool (ghs 7-8) 1317 fn pu_ghhdr obf view uchar * n ulong to ulong 1318 ls = ulong 0 1319 bo = n 1320 put ghs 7 syn_mark 1321 nen = ulong 0 1322 ln = ulong 0 1323 for i ulong n 1324 if eq get obf i 10 1325 e = i 1326 if gt e ls 1327 if eq get obf sub e 1 13 1328 e = sub e 1 1329 end 1330 end 1331 if and gt ln 0 eq e ls 1332 bo = add i 1 1333 break 1334 end 1335 if and gt ln 0 pu_hdr obf ls e 1336 v = pu_skipsp obf add ls 5 e 1337 syn_pa obf v sub e v 1338 nen = sub e v 1339 end 1340 ln = add ln 1 1341 ls = add i 1 1342 end 1343 end 1344 put ghs 8 nen 1345 ret bo 1346 end 1347 1348 note pu_gh200: move the body (bo,bl) to obf[0..), cache body and etag, log; returns bl 1349 fn pu_gh200 obf edit uchar * po ulong pn ulong bo ulong bl ulong to long 1350 for i ulong bl 1351 put obf i get obf add bo i 1352 end 1353 bp = pu_pathi 0 tsletag 1354 syn_pb 47 1355 syn_ps get ghs 1 get ghs 2 1356 syn_pt tbody 1357 fd = syn_wbeg bp syn_len bp 1358 if ge fd 0 1359 w = write int fd obf 0 bl 1360 r = syn_wend fd bp syn_len bp 1361 end 1362 if gt get ghs 8 0 1363 ep2 = syn_mark 1364 syn_ps get ghs 3 get ghs 4 1365 fd = syn_wbeg ep2 get ghs 4 1366 if ge fd 0 1367 w = write int fd gsp get ghs 7 get ghs 8 1368 r = syn_wend fd ep2 get ghs 4 1369 end 1370 end 1371 pu_reqlog po pn get ghs 5 get ghs 6 200 bl 1372 syn_rew get ghs 0 1373 put gcnt 4 add get gcnt 4 1 1374 ret long bl 1375 end 1376 1377 note pu_gh304: cached body into obf[0..); its length, or -2 (etag dropped) when the cache is gone 1378 fn pu_gh304 obf edit uchar * po ulong pn ulong to long 1379 bp = pu_pathi 0 tsletag 1380 syn_pb 47 1381 syn_ps get ghs 1 get ghs 2 1382 syn_pt tbody 1383 r = syn_rfile bp syn_len bp obf 1384 if lt r 0 1385 q = unlink gsp get ghs 3 get ghs 4 1386 w = write 2 tghfail 0 len tghfail 1387 w = write 2 gsp po pn 1388 w = write 2 tnl 0 1 1389 syn_rew get ghs 0 1390 put gcnt 3 add get gcnt 3 1 1391 ret neg long 2 1392 end 1393 pu_reqlog po pn get ghs 5 get ghs 6 304 ulong r 1394 syn_rew get ghs 0 1395 put gcnt 4 add get gcnt 4 1 1396 ret r 1397 end 1398 1399 note pu_gh: GET path (po,pn); body moved to out[0..); returns body length, -1 cap, -2 failure, -3 too large 1400 fn pu_gh obf edit uchar * po ulong pn ulong to long 1401 if ge get gcnt 2 40 1402 w = write 2 tcap 0 len tcap 1403 w = write 2 gsp po pn 1404 w = write 2 tnl 0 1 1405 put gcnt 5 add get gcnt 5 1 1406 ret neg long 1 1407 end 1408 put gcnt 2 add get gcnt 2 1 1409 put ghs 0 syn_mark 1410 pu_ghetag po pn 1411 r = pu_ghget obf po pn 1412 if lt r 0 1413 ret r 1414 end 1415 n = ulong r 1416 if gt get gxs 1 long len obf 1417 w = write 2 tbig 0 len tbig 1418 w = write 2 gsp po pn 1419 w = write 2 tnl 0 1 1420 syn_rew get ghs 0 1421 ret neg long 3 1422 end 1423 st = pu_ghst obf n 1424 bo = pu_ghhdr obf n 1425 bl = sub n syn_min bo n 1426 if eq st 200 1427 ret pu_gh200 obf po pn bo bl 1428 end 1429 if eq st 304 1430 ret pu_gh304 obf po pn 1431 end 1432 pu_reqlog po pn get ghs 5 get ghs 6 st bl 1433 w = write 2 tghfail 0 len tghfail 1434 w = write 2 gsp po pn 1435 w = write 2 tnl 0 1 1436 syn_rew get ghs 0 1437 put gcnt 3 add get gcnt 3 1 1438 ret neg long 2 1439 end 1440 1441 text tbadpr "synapse-pulse: PR list did not parse" 1442 note pu_pulls: tape lives in this frame and the response buffer in pu_pullt's, so neither frame passes 1443 note omc's 4 MiB per-function stack cap (error 23); the chain stays inside the 8 MiB program stack 1444 fn pu_pulls r ulong to void 1445 tape = new uint 786432 0 1446 pu_pullt r tape 1447 end 1448 1449 note pu_prel: PR object in gmo into row gprc (number, state, merged, head ref); false without a number 1450 fn pu_prel obf view uchar * tape view uint * tmp edit uchar * to bool 1451 v = pu_memb obf tape tknum 1452 if eq v jsnone 1453 ret false 1454 end 1455 i = get gprc 0 1456 put gprn i js_tou obf js_off tape v 1457 put gprs i 2 1458 v = pu_memb obf tape tkstate 1459 if ne v jsnone 1460 if js_streq obf js_off tape v topen 1461 put gprs i 1 1462 end 1463 end 1464 put gprm i 0 1465 v = pu_memb obf tape tkmerg 1466 if ne v jsnone 1467 if eq js_type tape v jsstr 1468 put gprm i 1 1469 end 1470 end 1471 put gprho i 0 1472 put gprhl i 0 1473 v = pu_memb obf tape tkhead 1474 if ne v jsnone 1475 put gmo 0 v 1476 v = pu_memb obf tape tkref 1477 if ne v jsnone 1478 o = pu_sval obf pu_soff tape v tmp 1479 put gprho i o 1480 put gprhl i ulong get gxs 2 1481 end 1482 end 1483 ret true 1484 end 1485 1486 fn pu_pullt r ulong tape edit uint * to void 1487 obf = new uchar `1114112` 0 1488 tmp = new uchar 8192 0 1489 m = syn_mark 1490 syn_pt trepos 1491 syn_ps get grpo r get grpl r 1492 syn_pt tpulls 1493 n = pu_gh obf m syn_len m 1494 syn_rew m 1495 if lt n 0 1496 ret 1497 end 1498 if gt n 983040 1499 w = write 2 tbig 0 len tbig 1500 w = write 2 tnl 0 1 1501 ret 1502 end 1503 q = js_init tape 983040 64 1504 q = js_parse obf tape ulong n 1505 if or lt q 0 ne js_type tape 0 jsarr 1506 w = write 2 tbadpr 0 len tbadpr 1507 w = write 2 tnl 0 1 1508 ret 1509 end 1510 e = js_first tape 0 1511 while ne e jsnone bound 100000 1512 put gmo 0 e 1513 i = get gprc 0 1514 if lt i 8192 1515 if pu_prel obf tape tmp 1516 put gprr i r 1517 put gprc 0 add i 1 1518 end 1519 end 1520 e = js_enext tape e 1521 end 1522 end 1523 1524 note pu_prclaimed: an active pr: or branch: claim covers PR row i 1525 fn pu_prclaim i ulong to bool 1526 r = get gprr i 1527 for c ulong get gcn 0 1528 if and eq get gca c 1 syn_peq pu_cf c 9 pu_cl c 9 get grpo r get grpl r 1529 k = get gkd c 1530 if eq k 4 1531 v = syn_pdec pu_cf c 10 pu_cl c 10 1532 if and eq get gxs 2 1 eq v get gprn i 1533 ret true 1534 end 1535 end 1536 if and eq k 2 ne get gprhl i 0 1537 if syn_peq pu_cf c 10 pu_cl c 10 get gprho i get gprhl i 1538 ret true 1539 end 1540 end 1541 end 1542 end 1543 ret false 1544 end 1545 1546 text tdunc1 "open PR #" 1547 text tdunc2 " (head " 1548 text tdunc3 ") changes a path held by " 1549 text tdunc4 " and no pr: or branch: claim covers it" 1550 note pu_files: tape here, response buffer in pu_filet (same 4 MiB per-frame split as pu_pulls) 1551 fn pu_files i ulong to void 1552 tape = new uint 786432 0 1553 pu_filet i tape 1554 end 1555 1556 note pu_fhit: claim c is an active path claim on repo row r, not yet reported (ghit), whose glob 1557 note matches the changed file (fo,fl) 1558 fn pu_fhit c ulong r ulong fo ulong fl ulong to bool 1559 if ne get gca c 1 1560 ret false 1561 end 1562 if ne get gkd c 3 1563 ret false 1564 end 1565 if ne get ghit c 0 1566 ret false 1567 end 1568 if not syn_peq pu_cf c 9 pu_cl c 9 get grpo r get grpl r 1569 ret false 1570 end 1571 po = pu_cf c 10 1572 pe = add po pu_cl c 10 1573 ret pu_glob po pe fo add fo fl 1574 end 1575 1576 note pu_fmatch: changed file (fo,fl) of PR row i against active path claims not yet reported (ghit) 1577 fn pu_fmatch i ulong fo ulong fl ulong to void 1578 r = get gprr i 1579 for c ulong get gcn 0 1580 if pu_fhit c r fo fl 1581 put ghit c 1 1582 m = syn_mark 1583 syn_pt tdunc1 1584 syn_pd get gprn i 1585 syn_pt tdunc2 1586 syn_ps get gprho i get gprhl i 1587 syn_pt tdunc3 1588 syn_ps pu_cf c 1 pu_cl c 1 1589 syn_pt tdunc4 1590 pu_det m 1591 put gfp 0 get gprn i 1592 put gfp 1 fo 1593 put gfp 2 fl 1594 pu_fnd funcl 1 c `4294967295` 1595 end 1596 end 1597 end 1598 1599 fn pu_filet i ulong tape edit uint * to void 1600 obf = new uchar `1114112` 0 1601 tmp = new uchar 8192 0 1602 for c ulong 1024 1603 put ghit c 0 1604 end 1605 r = get gprr i 1606 m = syn_mark 1607 syn_pt trepos 1608 syn_ps get grpo r get grpl r 1609 syn_pt tpullsl 1610 syn_pd get gprn i 1611 syn_pt tfiles 1612 n = pu_gh obf m syn_len m 1613 syn_rew m 1614 if or lt n 0 gt n 983040 1615 ret 1616 end 1617 q = js_init tape 983040 64 1618 q = js_parse obf tape ulong n 1619 if or lt q 0 ne js_type tape 0 jsarr 1620 ret 1621 end 1622 e = js_first tape 0 1623 while ne e jsnone bound 100000 1624 put gmo 0 e 1625 fv = pu_memb obf tape tkfile 1626 if ne fv jsnone 1627 fo = pu_sval obf pu_soff tape fv tmp 1628 pu_fmatch i fo ulong get gxs 2 1629 end 1630 e = js_enext tape e 1631 end 1632 end 1633 1634 fn pu_prrow r ulong num ulong to ulong 1635 for i ulong get gprc 0 1636 if and eq get gprr i r eq get gprn i num 1637 ret i 1638 end 1639 end 1640 ret `4294967295` 1641 end 1642 1643 fn pu_ridx o ulong n ulong to ulong 1644 for r ulong get grn 0 1645 if syn_peq get grpo r get grpl r o n 1646 ret r 1647 end 1648 end 1649 ret `4294967295` 1650 end 1651 1652 text tdst1 "claim state " 1653 text tdst2 " but GitHub PR is not merged (state " 1654 text tdst3 "GitHub PR is closed (" 1655 text tunm "not merged" 1656 text tdst4 ") but the claim is still active" 1657 text tdst5 "claim state " 1658 text tdst6 " but no GitHub PR from this branch is merged" 1659 note pu_stpr: pr: claim c on repo row r; mg when the claim state is merged or deployed 1660 fn pu_stpr c ulong r ulong mg bool to void 1661 v = syn_pdec pu_cf c 10 pu_cl c 10 1662 i = pu_prrow r v 1663 if ge i get gprc 0 1664 ret 1665 end 1666 put gfp 0 v 1667 if and mg eq get gprm i 0 1668 m = syn_mark 1669 syn_pt tdst1 1670 syn_ps pu_cf c 6 pu_cl c 6 1671 syn_pt tdst2 1672 if eq get gprs i 1 1673 syn_pt topen 1674 else 1675 syn_pt tclosed 1676 end 1677 syn_pb 41 1678 pu_det m 1679 pu_fnd fstcon 1 c `4294967295` 1680 else 1681 if and eq get gca c 1 eq get gprs i 2 1682 m = syn_mark 1683 syn_pt tdst3 1684 if eq get gprm i 1 1685 syn_pt tmerged 1686 else 1687 syn_pt tunm 1688 end 1689 syn_pt tdst4 1690 pu_det m 1691 pu_fnd fstcon 1 c `4294967295` 1692 end 1693 end 1694 put gfp 0 0 1695 end 1696 1697 note pu_stbr: merged or deployed branch: claim c on repo row r with PRs from it but none merged 1698 fn pu_stbr c ulong r ulong to void 1699 seen = ulong 0 1700 any = ulong 0 1701 co = pu_cf c 10 1702 cl = pu_cl c 10 1703 for i ulong get gprc 0 1704 if eq get gprr i r 1705 if syn_peq get gprho i get gprhl i co cl 1706 seen = add seen 1 1707 any = or any ulong get gprm i 1708 end 1709 end 1710 end 1711 if and gt seen 0 eq any 0 1712 m = syn_mark 1713 syn_pt tdst5 1714 syn_ps pu_cf c 6 pu_cl c 6 1715 syn_pt tdst6 1716 pu_det m 1717 pu_fnd fstcon 1 c `4294967295` 1718 end 1719 end 1720 1721 fn pu_status to void 1722 for c ulong get gcn 0 1723 k = get gkd c 1724 r = pu_ridx pu_cf c 9 pu_cl c 9 1725 if lt r get grn 0 1726 mg = or syn_seq pu_cf c 6 pu_cl c 6 tmerged syn_seq pu_cf c 6 pu_cl c 6 tdeploy 1727 if eq k 4 1728 pu_stpr c r mg 1729 end 1730 if and eq k 2 mg 1731 pu_stbr c r 1732 end 1733 end 1734 end 1735 end 1736 1737 fn pu_github to void 1738 for r ulong get grn 0 1739 pu_pulls r 1740 end 1741 for i ulong get gprc 0 1742 if and eq get gprs i 1 eq get grp get gprr i 1 1743 if not pu_prclaim i 1744 pu_files i 1745 end 1746 end 1747 end 1748 pu_status 1749 end 1750 1751 note alert in exactly the aien-watch format; kind COORD-DRIFT 1752 note pu_alch: byte allowed in an alert KIND (A-Z, 0-9, -) 1753 fn pu_alch c uchar to bool 1754 if and ge c 65 le c 90 1755 ret true 1756 end 1757 if and ge c 48 le c 57 1758 ret true 1759 end 1760 ret eq c 45 1761 end 1762 1763 fn pu_alkeep a view uchar * s ulong e ulong to bool 1764 if pu_isdrift a s e 1765 ret false 1766 end 1767 if ge s e 1768 ret false 1769 end 1770 c = get a s 1771 if or lt c 65 gt c 90 1772 ret false 1773 end 1774 i = add s 1 1775 while lt i e bound 4096 1776 c = get a i 1777 if eq c 58 1778 ret and lt add i 1 e eq get a add i 1 32 1779 end 1780 if not pu_alch c 1781 ret false 1782 end 1783 i = add i 1 1784 end 1785 ret false 1786 end 1787 1788 fn pu_isdrift a view uchar * s ulong e ulong to bool 1789 if lt sub e s len tkalcol 1790 ret false 1791 end 1792 for i ulong len tkalcol 1793 if ne get a add s i get tkalcol i 1794 ret false 1795 end 1796 end 1797 ret true 1798 end 1799 1800 fn pu_alog m ulong to void 1801 p = pu_pathi 1 tslalog 1802 fd = fopen gsp p syn_len p 525377 420 1803 syn_rew p 1804 if ge fd 0 1805 w = write int fd gsp m syn_len m 1806 c = fclose int fd 1807 end 1808 end 1809 1810 note pu_alsel: sel 0 appends the COORD-DRIFT lines (each cut to 400 bytes, joined by newline) and 1811 note returns their count; sel 1 appends every other well-formed KIND line with its newline 1812 fn pu_alsel buf view uchar * nn ulong sel ulong to ulong 1813 ls = ulong 0 1814 cnt = ulong 0 1815 for i ulong add nn 1 1816 if or eq i nn eq get buf syn_min i sub len buf 1 10 1817 if gt i ls 1818 if eq sel 0 1819 if pu_isdrift buf ls i 1820 if gt cnt 0 1821 syn_pb 10 1822 end 1823 syn_pa buf ls syn_min sub i ls 400 1824 cnt = add cnt 1 1825 end 1826 else 1827 if pu_alkeep buf ls i 1828 syn_pa buf ls sub i ls 1829 syn_pb 10 1830 cnt = add cnt 1 1831 end 1832 end 1833 end 1834 ls = add i 1 1835 end 1836 end 1837 ret cnt 1838 end 1839 1840 note pu_flat: aien-watch text rule: newline, tab, CR to space; squeeze spaces; first 600 bytes 1841 fn pu_flat xo ulong tn ulong to void 1842 sp = false 1843 k = ulong 0 1844 for i ulong tn 1845 c = get gsp add xo i 1846 if or or eq c 10 eq c 9 eq c 13 1847 c = 32 1848 end 1849 if not and sp eq c 32 1850 if lt k 600 1851 syn_pb c 1852 k = add k 1 1853 end 1854 end 1855 sp = eq c 32 1856 end 1857 end 1858 1859 note pu_alwr: replace the alert file (ap,apl) with the pool text from kp, or remove it when empty 1860 fn pu_alwr ap ulong apl ulong kp ulong to void 1861 kl = syn_len kp 1862 if gt kl 0 1863 fd = syn_wbeg ap apl 1864 if ge fd 0 1865 w = write int fd gsp kp kl 1866 r = syn_wend fd ap apl 1867 end 1868 else 1869 r = unlink gsp ap apl 1870 end 1871 end 1872 1873 note pu_alert: mode 1 raise with text (xo,tn), mode 0 resolve; garr holds the pool pieces 1874 fn pu_alert mode ulong xo ulong tn ulong to void 1875 buf = new uchar 262144 0 1876 base = syn_mark 1877 syn_tsw div ulong realns `1000000000` 1878 put garr 0 base 1879 put garr 1 syn_len base 1880 ap = pu_pathi 1 tslalert 1881 apl = syn_len ap 1882 n = syn_rfile ap apl buf 1883 nn = ulong 0 1884 if gt n 0 1885 nn = ulong n 1886 end 1887 put garr 2 syn_mark 1888 nd = pu_alsel buf nn 0 1889 put garr 3 syn_len get garr 2 1890 if and eq mode 0 eq nd 0 1891 syn_rew base 1892 ret 1893 end 1894 put garr 4 syn_mark 1895 if eq mode 1 1896 pu_flat xo tn 1897 end 1898 put garr 5 syn_len get garr 4 1899 kp = syn_mark 1900 nd = pu_alsel buf nn 1 1901 if eq mode 1 1902 syn_pt tkalcol 1903 syn_pb 32 1904 syn_ps get garr 4 get garr 5 1905 syn_pt tsince 1906 syn_ps get garr 0 get garr 1 1907 syn_pt tdetails 1908 pu_popt 1 1909 syn_pt tclear 1910 end 1911 pu_alwr ap apl kp 1912 lm = syn_mark 1913 syn_ps get garr 0 get garr 1 1914 if eq mode 1 1915 syn_pb 32 1916 syn_pt tkalert 1917 syn_pb 32 1918 syn_ps get garr 4 get garr 5 1919 else 1920 syn_pt tresolv 1921 syn_ps get garr 2 get garr 3 1922 end 1923 syn_pb 10 1924 pu_alog lm 1925 syn_rew base 1926 end