Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/si/harvester/harvester.om # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / si / harvester / harvester.om` 1011 lines ยท 18461 bytes Raw Blame History 1 om2 2 note si/harvester/harvester.om: Zero-telemetry documentation & reasoning harvester in pure OM-2. 3 note Faithful conversion of harvester (extractor.rs, filter.rs, export.rs) + markdown doc extraction: 4 note - Reads markdown/text on stdin (zero network, zero disk secrets, zero telemetry) 5 note - Extracts # / ## / ### headings outside fenced code blocks 6 note - Counts fenced code blocks (``` fences) 7 note - Extracts [text](url) markdown links, rejects telemetry/tracking domains & unsafe schemes, 8 note strips tracking query parameters (utm_*, fbclid, gclid, mc_eid), deduplicates links via SHA-256 9 note - Extracts key metadata lines (title, author, license, pin, source, date, version, provider, model) 10 note - Extracts ... and ... reasoning blocks with quality scoring 11 note - Emits deterministic JSONL records on stdout with RFC 8259 string escaping. 12 13 global inbuf uchar 32768 14 global rdbuf uchar 4096 15 global outbuf uchar 32768 16 global urlbuf uchar 512 17 global cleanurl uchar 512 18 global decbuf uchar 32 19 global stats ulong 16 20 global shastate uint 8 21 global shak uint 64 22 global shaw uint 64 23 global shablk uchar 64 24 global shadig uchar 32 25 global shahex uchar 64 26 global seenfp uchar 4096 27 28 note stats indices 29 const st_inlen ulong 0 30 const st_outlen ulong 1 31 const st_heads ulong 2 32 const st_blocks ulong 3 33 const st_links ulong 4 34 const st_telrej ulong 5 35 const st_strip ulong 6 36 const st_meta ulong 7 37 const st_reas ulong 8 38 const st_qual ulong 9 39 const st_clen ulong 10 40 const st_seencnt ulong 11 41 const st_dedup ulong 12 42 43 text khex "`0123456789abcdef`" 44 text j_head1 "{\"type\":\"heading\",\"level\":" 45 text j_text ",\"text\":\"" 46 text j_link1 "{\"type\":\"link\",\"text\":\"" 47 text j_url "\",\"url\":\"" 48 text j_meta1 "{\"type\":\"meta\",\"key\":\"" 49 text j_val "\",\"value\":\"" 50 text j_reas1 "{\"type\":\"reasoning\",\"tokens\":" 51 text j_qm ",\"quality_milli\":" 52 text j_sum1 "{\"type\":\"summary\",\"headings\":" 53 text j_sum2 ",\"code_blocks\":" 54 text j_sum3 ",\"links\":" 55 text j_sum4 ",\"telemetry_rejected\":" 56 text j_sum5 ",\"tracking_stripped\":" 57 text j_sum6 ",\"meta\":" 58 text j_sum7 ",\"reasoning\":" 59 text j_sum8 ",\"quality_milli\":" 60 text j_sum9 ",\"sha256\":\"" 61 text j_end "\"}\n" 62 63 text t_fence "```" 64 text t_think_o "" 65 text t_think_c "" 66 text t_thought_o "" 67 text t_thought_c "" 68 text t_kw_step "step" 69 text t_kw_ver "verify" 70 text t_kw_bigo "O(" 71 72 note Metadata keys 73 text mk_title "title:" 74 text mk_author "author:" 75 text mk_lic "license:" 76 text mk_pin "pin:" 77 text mk_src "source:" 78 text mk_date "date:" 79 text mk_ver "version:" 80 text mk_prov "provider:" 81 text mk_mod "model:" 82 83 note Telemetry/tracking domain patterns and unsafe schemes 84 text td_ga "google-analytics.com" 85 text td_gtm "googletagmanager.com" 86 text td_dc "doubleclick.net" 87 text td_mp "mixpanel.com" 88 text td_sg1 "segment.io" 89 text td_sg2 "segment.com" 90 text td_amp "amplitude.com" 91 text td_hj "hotjar.com" 92 text td_fb "facebook.com/tr" 93 text td_tel "telemetry." 94 text td_ana "analytics." 95 text td_pix "pixel." 96 text td_bea "beacon." 97 text td_js "javascript:" 98 text td_dat "data:" 99 100 note Tracking query param prefixes 101 text qp_utm "utm_" 102 text qp_fb "fbclid=" 103 text qp_gc "gclid=" 104 text qp_mc "mc_eid=" 105 106 text e_io "harvester: failed to read stdin\n" 107 108 fn write_all fd int src view uchar * off ulong n ulong to void 109 p = ulong 0 110 while lt p n bound 32768 111 k = write fd src add off p sub n p 112 if le k 0 113 exit 2 114 end 115 p = add p ulong k 116 end 117 end 118 119 fn wstr fd int s view uchar * to void 120 write_all fd s 0 len s 121 end 122 123 fn to_lower c uchar to uchar 124 if and ge c 65 le c 90 125 ret add c 32 126 end 127 ret c 128 end 129 130 fn out_push_ch c uchar to void 131 p = get stats st_outlen 132 if lt p 32768 133 put outbuf p c 134 put stats st_outlen add p 1 135 end 136 end 137 138 fn out_push_lit s view uchar * to void 139 sl = len s 140 i = ulong 0 141 while lt i sl bound 1024 142 out_push_ch get s i 143 i = add i 1 144 end 145 end 146 147 fn out_push_dec v ulong to void 148 i = ulong 32 149 n = v 150 while true bound 24 151 i = sub i 1 152 put decbuf i uchar add rem n 10 48 153 n = div n 10 154 if eq n 0 155 break 156 end 157 end 158 p = i 159 while lt p 32 bound 32 160 out_push_ch get decbuf p 161 p = add p 1 162 end 163 end 164 165 fn out_push_json_ch c uchar to void 166 if eq c 34 167 out_push_ch 92 168 out_push_ch 34 169 ret 170 end 171 if eq c 92 172 out_push_ch 92 173 out_push_ch 92 174 ret 175 end 176 if eq c 10 177 out_push_ch 92 178 out_push_ch 110 179 ret 180 end 181 if eq c 13 182 out_push_ch 92 183 out_push_ch 114 184 ret 185 end 186 if eq c 9 187 out_push_ch 92 188 out_push_ch 116 189 ret 190 end 191 if ge c 32 192 out_push_ch c 193 end 194 end 195 196 fn out_push_in_json off ulong n ulong to void 197 i = ulong 0 198 while lt i n bound 32768 199 if lt add off i 32768 200 out_push_json_ch get inbuf add off i 201 end 202 i = add i 1 203 end 204 end 205 206 fn out_push_cleanurl_json to void 207 n = get stats st_clen 208 i = ulong 0 209 while lt i n bound 512 210 out_push_json_ch get cleanurl i 211 i = add i 1 212 end 213 end 214 215 fn out_push_shahex to void 216 for i ulong 64 217 out_push_ch get shahex i 218 end 219 end 220 221 note FIPS 180-4 SHA-256 222 fn sha_kinit to void 223 put shak 0 0x428a2f98 224 put shak 1 0x71374491 225 put shak 2 0xb5c0fbcf 226 put shak 3 0xe9b5dba5 227 put shak 4 0x3956c25b 228 put shak 5 0x59f111f1 229 put shak 6 0x923f82a4 230 put shak 7 0xab1c5ed5 231 put shak 8 0xd807aa98 232 put shak 9 0x12835b01 233 put shak 10 0x243185be 234 put shak 11 0x550c7dc3 235 put shak 12 0x72be5d74 236 put shak 13 0x80deb1fe 237 put shak 14 0x9bdc06a7 238 put shak 15 0xc19bf174 239 put shak 16 0xe49b69c1 240 put shak 17 0xefbe4786 241 put shak 18 0x0fc19dc6 242 put shak 19 0x240ca1cc 243 put shak 20 0x2de92c6f 244 put shak 21 0x4a7484aa 245 put shak 22 0x5cb0a9dc 246 put shak 23 0x76f988da 247 put shak 24 0x983e5152 248 put shak 25 0xa831c66d 249 put shak 26 0xb00327c8 250 put shak 27 0xbf597fc7 251 put shak 28 0xc6e00bf3 252 put shak 29 0xd5a79147 253 put shak 30 0x06ca6351 254 put shak 31 0x14292967 255 put shak 32 0x27b70a85 256 put shak 33 0x2e1b2138 257 put shak 34 0x4d2c6dfc 258 put shak 35 0x53380d13 259 put shak 36 0x650a7354 260 put shak 37 0x766a0abb 261 put shak 38 0x81c2c92e 262 put shak 39 0x92722c85 263 put shak 40 0xa2bfe8a1 264 put shak 41 0xa81a664b 265 put shak 42 0xc24b8b70 266 put shak 43 0xc76c51a3 267 put shak 44 0xd192e819 268 put shak 45 0xd6990624 269 put shak 46 0xf40e3585 270 put shak 47 0x106aa070 271 put shak 48 0x19a4c116 272 put shak 49 0x1e376c08 273 put shak 50 0x2748774c 274 put shak 51 0x34b0bcb5 275 put shak 52 0x391c0cb3 276 put shak 53 0x4ed8aa4a 277 put shak 54 0x5b9cca4f 278 put shak 55 0x682e6ff3 279 put shak 56 0x748f82ee 280 put shak 57 0x78a5636f 281 put shak 58 0x84c87814 282 put shak 59 0x8cc70208 283 put shak 60 0x90befffa 284 put shak 61 0xa4506ceb 285 put shak 62 0xbef9a3f7 286 put shak 63 0xc67178f2 287 end 288 289 fn sha_iv to void 290 put shastate 0 0x6a09e667 291 put shastate 1 0xbb67ae85 292 put shastate 2 0x3c6ef372 293 put shastate 3 0xa54ff53a 294 put shastate 4 0x510e527f 295 put shastate 5 0x9b05688c 296 put shastate 6 0x1f83d9ab 297 put shastate 7 0x5be0cd19 298 end 299 300 fn sha_sched to void 301 for i ulong 16 302 q = mul i 4 303 x = uint get shablk q 304 x = or shl x 8 uint get shablk add q 1 305 x = or shl x 8 uint get shablk add q 2 306 put shaw i or shl x 8 uint get shablk add q 3 307 end 308 for i ulong 48 309 x = get shaw add i 1 310 y = get shaw add i 14 311 s0 = xor xor rotr x 7 rotr x 18 shr x 3 312 s1 = xor xor rotr y 17 rotr y 19 shr y 10 313 put shaw add i 16 add add get shaw i get shaw add i 9 add s0 s1 314 end 315 end 316 317 fn sha_compress to void 318 sha_sched 319 a = get shastate 0 320 b = get shastate 1 321 c = get shastate 2 322 d = get shastate 3 323 e = get shastate 4 324 f = get shastate 5 325 g = get shastate 6 326 h = get shastate 7 327 t = uint 0 328 for i ulong 64 329 h = add h get shak i 330 h = add h get shaw i 331 t = xor rotr e 6 rotr e 11 332 t = xor t rotr e 25 333 h = add h t 334 h = add h xor g and e xor f g 335 d = add d h 336 t = xor rotr a 2 rotr a 13 337 t = xor t rotr a 22 338 h = add h t 339 h = add h or and a b and c or a b 340 t = h 341 h = g 342 g = f 343 f = e 344 e = d 345 d = c 346 c = b 347 b = a 348 a = t 349 end 350 put shastate 0 add get shastate 0 a 351 put shastate 1 add get shastate 1 b 352 put shastate 2 add get shastate 2 c 353 put shastate 3 add get shastate 3 d 354 put shastate 4 add get shastate 4 e 355 put shastate 5 add get shastate 5 f 356 put shastate 6 add get shastate 6 g 357 put shastate 7 add get shastate 7 h 358 end 359 360 fn sha_finalize_hex to void 361 for i ulong 8 362 w = get shastate i 363 q = mul i 4 364 put shadig q uchar and shr w 24 255 365 put shadig add q 1 uchar and shr w 16 255 366 put shadig add q 2 uchar and shr w 8 255 367 put shadig add q 3 uchar and w 255 368 end 369 for i ulong 32 370 bv = ulong get shadig i 371 put shahex mul i 2 get khex shr bv 4 372 put shahex add mul i 2 1 get khex and bv 15 373 end 374 end 375 376 fn sha256_inbuf to void 377 dlen = get stats st_inlen 378 sha_kinit 379 sha_iv 380 off = ulong 0 381 while ge sub dlen off 64 bound 1024 382 for j ulong 64 383 put shablk j get inbuf add off j 384 end 385 sha_compress 386 off = add off 64 387 end 388 remn = sub dlen off 389 for j ulong 64 390 if lt j remn 391 put shablk j get inbuf add off j 392 else 393 put shablk j 0 394 end 395 end 396 put shablk remn 0x80 397 if gt remn 55 398 sha_compress 399 for j ulong 64 400 put shablk j 0 401 end 402 end 403 bits = mul dlen 8 404 put shablk 56 uchar and shr bits 56 255 405 put shablk 57 uchar and shr bits 48 255 406 put shablk 58 uchar and shr bits 40 255 407 put shablk 59 uchar and shr bits 32 255 408 put shablk 60 uchar and shr bits 24 255 409 put shablk 61 uchar and shr bits 16 255 410 put shablk 62 uchar and shr bits 8 255 411 put shablk 63 uchar and bits 255 412 sha_compress 413 sha_finalize_hex 414 end 415 416 fn sha256_cleanurl to void 417 dlen = get stats st_clen 418 sha_kinit 419 sha_iv 420 off = ulong 0 421 while ge sub dlen off 64 bound 16 422 for j ulong 64 423 put shablk j to_lower get cleanurl add off j 424 end 425 sha_compress 426 off = add off 64 427 end 428 remn = sub dlen off 429 for j ulong 64 430 if lt j remn 431 put shablk j to_lower get cleanurl add off j 432 else 433 put shablk j 0 434 end 435 end 436 put shablk remn 0x80 437 if gt remn 55 438 sha_compress 439 for j ulong 64 440 put shablk j 0 441 end 442 end 443 bits = mul dlen 8 444 put shablk 56 uchar and shr bits 56 255 445 put shablk 57 uchar and shr bits 48 255 446 put shablk 58 uchar and shr bits 40 255 447 put shablk 59 uchar and shr bits 32 255 448 put shablk 60 uchar and shr bits 24 255 449 put shablk 61 uchar and shr bits 16 255 450 put shablk 62 uchar and shr bits 8 255 451 put shablk 63 uchar and bits 255 452 sha_compress 453 sha_finalize_hex 454 end 455 456 note Deduplication check against seenfp (up to 64 unique 64-byte hex fingerprints) 457 fn dedup_insert_cleanurl to bool 458 sha256_cleanurl 459 cnt = get stats st_seencnt 460 k = ulong 0 461 while lt k cnt bound 64 462 base = mul k 64 463 same = true 464 for i ulong 64 465 if ne get seenfp add base i get shahex i 466 same = false 467 end 468 end 469 if same 470 put stats st_dedup add get stats st_dedup 1 471 ret false 472 end 473 k = add k 1 474 end 475 if lt cnt 64 476 base2 = mul cnt 64 477 for i ulong 64 478 put seenfp add base2 i get shahex i 479 end 480 put stats st_seencnt add cnt 1 481 end 482 ret true 483 end 484 485 note String matching helpers on inbuf and urlbuf 486 fn in_starts_ci off ulong lim ulong pat view uchar * to bool 487 pl = len pat 488 if gt add off pl lim 489 ret false 490 end 491 i = ulong 0 492 while lt i pl bound 64 493 if ne to_lower get inbuf add off i to_lower get pat i 494 ret false 495 end 496 i = add i 1 497 end 498 ret true 499 end 500 501 fn in_contains_ci off ulong lim ulong pat view uchar * to bool 502 pl = len pat 503 if lt sub lim off pl 504 ret false 505 end 506 endp = add sub lim pl 1 507 p = off 508 while lt p endp bound 32768 509 if in_starts_ci p lim pat 510 ret true 511 end 512 p = add p 1 513 end 514 ret false 515 end 516 517 fn url_starts_ci pos ulong ulen ulong pat view uchar * to bool 518 pl = len pat 519 if gt add pos pl ulen 520 ret false 521 end 522 i = ulong 0 523 while lt i pl bound 64 524 if ne to_lower get urlbuf add pos i to_lower get pat i 525 ret false 526 end 527 i = add i 1 528 end 529 ret true 530 end 531 532 fn url_contains_ci ulen ulong pat view uchar * to bool 533 pl = len pat 534 if gt pl ulen 535 ret false 536 end 537 lim = add sub ulen pl 1 538 i = ulong 0 539 while lt i lim bound 512 540 if url_starts_ci i ulen pat 541 ret true 542 end 543 i = add i 1 544 end 545 ret false 546 end 547 548 fn is_telemetry_url ulen ulong to bool 549 if url_starts_ci 0 ulen td_js 550 ret true 551 end 552 if url_starts_ci 0 ulen td_dat 553 ret true 554 end 555 if url_contains_ci ulen td_ga 556 ret true 557 end 558 if url_contains_ci ulen td_gtm 559 ret true 560 end 561 if url_contains_ci ulen td_dc 562 ret true 563 end 564 if url_contains_ci ulen td_mp 565 ret true 566 end 567 if url_contains_ci ulen td_sg1 568 ret true 569 end 570 if url_contains_ci ulen td_sg2 571 ret true 572 end 573 if url_contains_ci ulen td_amp 574 ret true 575 end 576 if url_contains_ci ulen td_hj 577 ret true 578 end 579 if url_contains_ci ulen td_fb 580 ret true 581 end 582 if url_contains_ci ulen td_tel 583 ret true 584 end 585 if url_contains_ci ulen td_ana 586 ret true 587 end 588 if url_contains_ci ulen td_pix 589 ret true 590 end 591 ret url_contains_ci ulen td_bea 592 end 593 594 fn is_tracking_param pos ulong lim ulong to bool 595 if url_starts_ci pos lim qp_utm 596 ret true 597 end 598 if url_starts_ci pos lim qp_fb 599 ret true 600 end 601 if url_starts_ci pos lim qp_gc 602 ret true 603 end 604 ret url_starts_ci pos lim qp_mc 605 end 606 607 note Strip tracking query params from urlbuf[0..ulen) into cleanurl[0..st_clen) 608 fn strip_tracking_params ulen ulong to void 609 qpos = ulen 610 i = ulong 0 611 while lt i ulen bound 512 612 if eq get urlbuf i 63 613 qpos = i 614 break 615 end 616 i = add i 1 617 end 618 cl = ulong 0 619 j = ulong 0 620 while lt j qpos bound 512 621 put cleanurl cl get urlbuf j 622 cl = add cl 1 623 j = add j 1 624 end 625 if eq qpos ulen 626 put stats st_clen cl 627 ret 628 end 629 first_q = true 630 pos = add qpos 1 631 while lt pos ulen bound 512 632 ps = pos 633 while lt pos ulen bound 512 634 if eq get urlbuf pos 38 635 break 636 end 637 pos = add pos 1 638 end 639 if is_tracking_param ps pos 640 put stats st_strip add get stats st_strip 1 641 else 642 if gt pos ps 643 if first_q 644 put cleanurl cl 63 645 cl = add cl 1 646 first_q = false 647 else 648 put cleanurl cl 38 649 cl = add cl 1 650 end 651 k = ps 652 while lt k pos bound 512 653 if lt cl 512 654 put cleanurl cl get urlbuf k 655 cl = add cl 1 656 end 657 k = add k 1 658 end 659 end 660 end 661 if lt pos ulen 662 pos = add pos 1 663 end 664 end 665 put stats st_clen cl 666 end 667 668 fn extract_links_on_line ls ulong le_pos ulong to void 669 p = ls 670 while lt p le_pos bound 32768 671 if eq get inbuf p 91 672 ts = add p 1 673 te = ts 674 while lt te le_pos bound 32768 675 if eq get inbuf te 93 676 break 677 end 678 te = add te 1 679 end 680 if and lt add te 2 le_pos eq get inbuf add te 1 40 681 us = add te 2 682 ue = us 683 while lt ue le_pos bound 32768 684 if eq get inbuf ue 41 685 break 686 end 687 ue = add ue 1 688 end 689 if and lt ue le_pos gt ue us 690 ul = sub ue us 691 if gt ul 511 692 ul = ulong 511 693 end 694 k = ulong 0 695 while lt k ul bound 512 696 put urlbuf k get inbuf add us k 697 k = add k 1 698 end 699 if is_telemetry_url ul 700 put stats st_telrej add get stats st_telrej 1 701 else 702 strip_tracking_params ul 703 if dedup_insert_cleanurl 704 put stats st_links add get stats st_links 1 705 out_push_lit j_link1 706 out_push_in_json ts sub te ts 707 out_push_lit j_url 708 out_push_cleanurl_json 709 out_push_lit j_end 710 end 711 end 712 p = ue 713 end 714 end 715 end 716 p = add p 1 717 end 718 end 719 720 fn try_meta_key ls ulong le_pos ulong key view uchar * to bool 721 kl = len key 722 if not in_starts_ci ls le_pos key 723 ret false 724 end 725 vs = add ls kl 726 while lt vs le_pos bound 32768 727 if ne get inbuf vs 32 728 break 729 end 730 vs = add vs 1 731 end 732 ve = le_pos 733 while gt ve vs bound 32768 734 if ne get inbuf sub ve 1 32 735 break 736 end 737 ve = sub ve 1 738 end 739 if eq ve vs 740 ret false 741 end 742 put stats st_meta add get stats st_meta 1 743 out_push_lit j_meta1 744 out_push_in_json ls sub kl 1 745 out_push_lit j_val 746 out_push_in_json vs sub ve vs 747 out_push_lit j_end 748 ret true 749 end 750 751 fn check_meta_line ls ulong le_pos ulong to bool 752 if try_meta_key ls le_pos mk_title 753 ret true 754 end 755 if try_meta_key ls le_pos mk_author 756 ret true 757 end 758 if try_meta_key ls le_pos mk_lic 759 ret true 760 end 761 if try_meta_key ls le_pos mk_pin 762 ret true 763 end 764 if try_meta_key ls le_pos mk_src 765 ret true 766 end 767 if try_meta_key ls le_pos mk_date 768 ret true 769 end 770 if try_meta_key ls le_pos mk_ver 771 ret true 772 end 773 if try_meta_key ls le_pos mk_prov 774 ret true 775 end 776 ret try_meta_key ls le_pos mk_mod 777 end 778 779 fn check_heading_line ls ulong le_pos ulong to bool 780 ll = sub le_pos ls 781 if lt ll 3 782 ret false 783 end 784 if ne get inbuf ls 35 785 ret false 786 end 787 lvl = ulong 0 788 while and lt lvl 3 lt add ls lvl le_pos bound 4 789 if ne get inbuf add ls lvl 35 790 break 791 end 792 lvl = add lvl 1 793 end 794 if eq lvl 0 795 ret false 796 end 797 if ge add ls lvl le_pos 798 ret false 799 end 800 if ne get inbuf add ls lvl 32 801 ret false 802 end 803 ts = add add ls lvl 1 804 while lt ts le_pos bound 32768 805 if ne get inbuf ts 32 806 break 807 end 808 ts = add ts 1 809 end 810 ve = le_pos 811 while gt ve ts bound 32768 812 if ne get inbuf sub ve 1 32 813 break 814 end 815 ve = sub ve 1 816 end 817 put stats st_heads add get stats st_heads 1 818 out_push_lit j_head1 819 out_push_dec lvl 820 out_push_lit j_text 821 out_push_in_json ts sub ve ts 822 out_push_lit j_end 823 ret true 824 end 825 826 note Extract ... or ... reasoning blocks (upstream extractor.rs) 827 fn extract_reasoning_blocks to void 828 tot = get stats st_inlen 829 has_code = gt get stats st_blocks 0 830 base_q = ulong 500 831 if has_code 832 base_q = add base_q 100 833 end 834 put stats st_qual base_q 835 pos = ulong 0 836 while lt pos tot bound 32768 837 rs = ulong 0 838 re = ulong 0 839 found = false 840 if in_starts_ci pos tot t_think_o 841 rs = add pos 7 842 q = rs 843 while lt q tot bound 32768 844 if in_starts_ci q tot t_think_c 845 re = q 846 found = true 847 pos = add q 8 848 break 849 end 850 q = add q 1 851 end 852 else 853 if in_starts_ci pos tot t_thought_o 854 rs = add pos 9 855 q = rs 856 while lt q tot bound 32768 857 if in_starts_ci q tot t_thought_c 858 re = q 859 found = true 860 pos = add q 10 861 break 862 end 863 q = add q 1 864 end 865 end 866 end 867 if found 868 rlen = sub re rs 869 qm = ulong 500 870 if gt rlen 0 871 qm = add qm 200 872 end 873 if gt rlen 50 874 qm = add qm 100 875 end 876 if or in_contains_ci rs re t_kw_step or in_contains_ci rs re t_kw_ver in_contains_ci rs re t_kw_bigo 877 qm = add qm 100 878 end 879 if has_code 880 qm = add qm 100 881 end 882 if gt qm 1000 883 qm = ulong 1000 884 end 885 if gt qm get stats st_qual 886 put stats st_qual qm 887 end 888 put stats st_reas add get stats st_reas 1 889 out_push_lit j_reas1 890 out_push_dec div tot 4 891 out_push_lit j_qm 892 out_push_dec qm 893 out_push_lit j_text 894 out_push_in_json rs rlen 895 out_push_lit j_end 896 else 897 pos = add pos 1 898 end 899 end 900 end 901 902 fn harvest_loaded to void 903 tot = get stats st_inlen 904 for i ulong 13 905 if ne i st_inlen 906 put stats i 0 907 end 908 end 909 in_fence = false 910 pos = ulong 0 911 while lt pos tot bound 32768 912 ls = pos 913 while lt pos tot bound 32768 914 if eq get inbuf pos 10 915 break 916 end 917 pos = add pos 1 918 end 919 if in_starts_ci ls pos t_fence 920 if not in_fence 921 in_fence = true 922 put stats st_blocks add get stats st_blocks 1 923 else 924 in_fence = false 925 end 926 else 927 if not in_fence 928 if not check_heading_line ls pos 929 is_m = check_meta_line ls pos 930 if not is_m 931 extract_links_on_line ls pos 932 end 933 end 934 end 935 end 936 if lt pos tot 937 pos = add pos 1 938 end 939 end 940 extract_reasoning_blocks 941 sha256_inbuf 942 out_push_lit j_sum1 943 out_push_dec get stats st_heads 944 out_push_lit j_sum2 945 out_push_dec get stats st_blocks 946 out_push_lit j_sum3 947 out_push_dec get stats st_links 948 out_push_lit j_sum4 949 out_push_dec get stats st_telrej 950 out_push_lit j_sum5 951 out_push_dec get stats st_strip 952 out_push_lit j_sum6 953 out_push_dec get stats st_meta 954 out_push_lit j_sum7 955 out_push_dec get stats st_reas 956 out_push_lit j_sum8 957 out_push_dec get stats st_qual 958 out_push_lit j_sum9 959 out_push_shahex 960 out_push_lit j_end 961 end 962 963 fn read_stdin to bool 964 tot = ulong 0 965 while true bound 32768 966 k = read 0 rdbuf 0 4096 967 if lt k 0 968 ret false 969 end 970 if eq k 0 971 break 972 end 973 kn = ulong k 974 i = ulong 0 975 while lt i kn bound 4096 976 c = get rdbuf i 977 if ne c 13 978 if ge tot 32768 979 ret false 980 end 981 put inbuf tot c 982 tot = add tot 1 983 end 984 i = add i 1 985 end 986 end 987 put stats st_inlen tot 988 ret true 989 end 990 991 fn flush_out to void 992 n = get stats st_outlen 993 p = ulong 0 994 while lt p n bound 32768 995 k = write 1 outbuf p sub n p 996 if le k 0 997 exit 2 998 end 999 p = add p ulong k 1000 end 1001 end 1002 1003 fn main to int 1004 if not read_stdin 1005 wstr 2 e_io 1006 ret 2 1007 end 1008 harvest_loaded 1009 flush_out 1010 ret 0 1011 end