File size: 44,494 Bytes
1b5c929 37ae1e2 1b5c929 3eafdf4 1b5c929 37ae1e2 1b5c929 ae03c09 3eafdf4 affaa54 1b5c929 37ae1e2 7d74a1f 37ae1e2 7d74a1f 37ae1e2 7d74a1f 37ae1e2 7d74a1f 37ae1e2 409cbb4 37ae1e2 bd82781 9facab1 6647fe7 409cbb4 37ae1e2 7d74a1f 37ae1e2 1b5c929 ae03c09 1b5c929 37ae1e2 1b5c929 37ae1e2 1b5c929 c2a3bcd 1b5c929 3eafdf4 7d6e4e0 37ae1e2 3eafdf4 7d6e4e0 3eafdf4 37ae1e2 7d6e4e0 3eafdf4 37ae1e2 3eafdf4 7d6e4e0 1b5c929 37ae1e2 affaa54 37ae1e2 1b5c929 37ae1e2 1b5c929 3eafdf4 37ae1e2 1b5c929 7d6e4e0 1b5c929 37ae1e2 1b5c929 3eafdf4 1b5c929 37ae1e2 1b5c929 7d6e4e0 37ae1e2 1b5c929 3eafdf4 37ae1e2 1b5c929 37ae1e2 1b5c929 37ae1e2 1b5c929 37ae1e2 c2a3bcd 1b5c929 37ae1e2 1b5c929 37ae1e2 1b5c929 37ae1e2 1b5c929 37ae1e2 1b5c929 ae03c09 1b5c929 37ae1e2 1b5c929 37ae1e2 1b5c929 3eafdf4 37ae1e2 affaa54 37ae1e2 1b5c929 37ae1e2 affaa54 37ae1e2 1b5c929 37ae1e2 1b5c929 37ae1e2 ae03c09 37ae1e2 409cbb4 37ae1e2 affaa54 37ae1e2 affaa54 37ae1e2 1b5c929 ae03c09 1b5c929 ae03c09 409cbb4 ae03c09 1b5c929 37ae1e2 ae03c09 1b5c929 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 | #!/usr/bin/env python3
"""Audit exported resource rows against local files and external source metadata."""
from __future__ import annotations
import argparse
import concurrent.futures as futures
import csv
import html
import json
import re
import ssl
import subprocess
import sys
import time
import urllib.error
import urllib.request
import xml.etree.ElementTree as ET
from datetime import datetime, timezone
from html.parser import HTMLParser
from pathlib import Path
from urllib.parse import urldefrag, urlencode, urlparse
ROOT = Path(__file__).resolve().parents[1]
RESOURCES_CSV = ROOT / "data" / "resources.csv"
AUDIT_CSV = ROOT / "data" / "resource_source_audit.csv"
ARXIV_PUBLICATION_AUDIT = ROOT / "data" / "arxiv_publication_audit.csv"
REPO_BLOB_URL = "https://github.com/ChaoYue0307/awesome-loop-engineering/blob/main"
PROJECT_GITHUB_REPO = "chaoyue0307/awesome-loop-engineering"
ARXIV_RE = re.compile(r"arxiv\.org/(?:abs|pdf)/(?P<id>\d{4}\.\d{4,5})(?:v\d+)?")
YEAR_RE = re.compile(r"(?<!\d)(?P<year>19\d{2}|20\d{2})(?!\d)")
ISO_DATE_RE = re.compile(r"(?P<year>19\d{2}|20\d{2})[-/](?P<month>\d{1,2})[-/](?P<day>\d{1,2})")
ATOM_NS = "{http://www.w3.org/2005/Atom}"
ARXIV_NS = "{http://arxiv.org/schemas/atom}"
PUBLISHER_BY_DOMAIN = {
"adk.dev": "Google Agent Development Kit",
"arxiv.org": "arXiv",
"github.com": "GitHub",
"anthropic.com": "Anthropic",
"claude.com": "Anthropic",
"crewai.com": "CrewAI",
"openai.com": "OpenAI",
"huggingface.co": "Hugging Face",
"langchain.com": "LangChain",
"microsoft.com": "Microsoft",
"google.com": "Google",
"googleblog.com": "Google",
"aws.amazon.com": "Amazon Web Services",
"amazon.com": "Amazon",
"preprints.org": "Preprints.org",
"ainowinstitute.org": "AI Now Institute",
"medium.com": "Medium",
"substack.com": "Substack",
"strandsagents.com": "Strands Agents",
"x.com": "X",
"youtube.com": "YouTube",
"aclanthology.org": "Association for Computational Linguistics",
"iclr.cc": "International Conference on Learning Representations",
"icml.cc": "International Conference on Machine Learning",
"openreview.net": "OpenReview",
"papers.nips.cc": "Neural Information Processing Systems Foundation",
"proceedings.mlr.press": "Proceedings of Machine Learning Research",
"proceedings.neurips.cc": "Neural Information Processing Systems Foundation",
}
PUBLICATION_OVERRIDES = {
"https://www.anthropic.com/engineering/demystifying-evals-for-ai-agents": {
"authors": "Mikaela Grace; Jeremy Hadfield; Rodrigo Olivares; Jiri De Jonghe",
"publication_date": "2026-01-09",
"publication_year": "2026",
"publication_venue": "Anthropic Engineering",
"publisher": "Anthropic",
"publication_note": "Author and date read from the post's own byline and dateline on anthropic.com/engineering; kept in code because automatic resolution falls back to the domain for this host.",
"metadata_source": "publisher-meta",
},
"https://www.anthropic.com/engineering/AI-resistant-technical-evaluations": {
"authors": "Tristan Hume",
"publication_date": "2026-01-21",
"publication_year": "2026",
"publication_venue": "Anthropic Engineering",
"publisher": "Anthropic",
"publication_note": "Author and date read from the post's own byline and dateline on anthropic.com/engineering; kept in code because automatic resolution falls back to the domain for this host.",
"metadata_source": "publisher-meta",
},
"https://www.anthropic.com/engineering/infrastructure-noise": {
"authors": "Gian Segato",
"publication_date": "2026-02-05",
"publication_year": "2026",
"publication_venue": "Anthropic Engineering",
"publisher": "Anthropic",
"publication_note": "Author and date read from the post's own byline and dateline on anthropic.com/engineering; kept in code because automatic resolution falls back to the domain for this host.",
"metadata_source": "publisher-meta",
},
"https://www.anthropic.com/engineering/building-c-compiler": {
"authors": "Nicholas Carlini",
"publication_date": "2026-02-05",
"publication_year": "2026",
"publication_venue": "Anthropic Engineering",
"publisher": "Anthropic",
"publication_note": "Author and date read from the post's own byline and dateline on anthropic.com/engineering; kept in code because automatic resolution falls back to the domain for this host.",
"metadata_source": "publisher-meta",
},
"https://www.anthropic.com/engineering/eval-awareness-browsecomp": {
"authors": "Russell Coleman",
"publication_date": "2026-03-06",
"publication_year": "2026",
"publication_venue": "Anthropic Engineering",
"publisher": "Anthropic",
"publication_note": "Author and date read from the post's own byline and dateline on anthropic.com/engineering; kept in code because automatic resolution falls back to the domain for this host.",
"metadata_source": "publisher-meta",
},
"https://www.anthropic.com/engineering/harness-design-long-running-apps": {
"authors": "Prithvi Rajasekaran",
"publication_date": "2026-03-24",
"publication_year": "2026",
"publication_venue": "Anthropic Engineering",
"publisher": "Anthropic",
"publication_note": "Author and date read from the post's own byline and dateline on anthropic.com/engineering; kept in code because automatic resolution falls back to the domain for this host.",
"metadata_source": "publisher-meta",
},
"https://www.anthropic.com/engineering/claude-code-auto-mode": {
"authors": "John Hughes",
"publication_date": "2026-03-25",
"publication_year": "2026",
"publication_venue": "Anthropic Engineering",
"publisher": "Anthropic",
"publication_note": "Author and date read from the post's own byline and dateline on anthropic.com/engineering; kept in code because automatic resolution falls back to the domain for this host.",
"metadata_source": "publisher-meta",
},
"https://www.anthropic.com/engineering/managed-agents": {
"authors": "Lance Martin; Gabe Cemaj; Michael Cohen",
"publication_date": "2026-04-08",
"publication_year": "2026",
"publication_venue": "Anthropic Engineering",
"publisher": "Anthropic",
"publication_note": "Author and date read from the post's own byline and dateline on anthropic.com/engineering; kept in code because automatic resolution falls back to the domain for this host.",
"metadata_source": "publisher-meta",
},
"https://www.anthropic.com/engineering/april-23-postmortem": {
"authors": "Anthropic",
"publication_date": "2026-04-23",
"publication_year": "2026",
"publication_venue": "Anthropic Engineering",
"publisher": "Anthropic",
"publication_note": "Author and date read from the post's own byline and dateline on anthropic.com/engineering; kept in code because automatic resolution falls back to the domain for this host.",
"metadata_source": "publisher-meta",
},
"https://www.diagrid.io/blog/checkpoints-are-not-durable-execution-why-langgraph-crewai-google-adk-and-others-fall-short-for-production-agent-workflows": {
"authors": "Yaron Schneider",
"publication_date": "2026-02-25",
"publication_year": "2026",
"publisher": "Diagrid",
"publication_note": "Author and date read from the post's own byline on diagrid.io; kept in code because automatic resolution falls back to the domain for this host.",
"metadata_source": "publisher-meta",
},
"https://zenity.io/blog/current-events/ai-agent-database-deletion-pocketos": {
"authors": "Chris Hughes",
"publication_date": "2026-04-28",
"publication_year": "2026",
"publisher": "Zenity",
"publication_note": "Author and date read from the post's own byline on zenity.io; kept in code because automatic resolution falls back to the domain for this host.",
"metadata_source": "publisher-meta",
},
"https://ainowinstitute.org/publications/friendly-fire-exploit-brief": {
"authors": "Boyan Milanov",
"publication_date": "2026-07-08",
"publication_year": "2026",
"publication_venue": "AI Now Institute",
"publisher": "AI Now Institute",
"publication_note": "Author and date read from the publication's own article:published_time and author meta tags; kept in code because automatic resolution falls back to the domain for this host.",
"metadata_source": "publisher-meta",
},
"gallery/loop-graph-reference.md": {
"authors": "Lingjiao Chen; Matei Zaharia; Jack Clark; Christopher Re; Chelsea Finn; Ion Stoica",
"publication_date": "2026",
"publication_year": "2026",
"publication_note": "Author list transcribed from the manuscript screenshot supplied with the gallery reference; kept in code so audit regeneration preserves it.",
"metadata_source": "repository",
},
"https://openreview.net/forum?id=HyzdRiR9Y7": {
"authors": "Mostafa Dehghani; Stephan Gouws; Oriol Vinyals; Jakob Uszkoreit; Łukasz Kaiser",
"publication_date": "2019",
"publication_year": "2019",
"publication_venue": "International Conference on Learning Representations (ICLR)",
"publisher": "OpenReview",
"publication_note": "Published at ICLR 2019; venue and authors verified from the official OpenReview record.",
"metadata_source": "OpenReview",
},
"https://openreview.net/forum?id=HHbRxoDTxE": {
"authors": "Liu Yang; Kangwook Lee; Robert D. Nowak; Dimitris Papailiopoulos",
"publication_date": "2024",
"publication_year": "2024",
"publication_venue": "International Conference on Learning Representations (ICLR)",
"publisher": "OpenReview",
"publication_note": "Published at ICLR 2024; venue and authors verified from the official OpenReview record.",
"metadata_source": "OpenReview",
},
"https://iclr.cc/virtual/2025/poster/28971": {
"authors": "Nikunj Saunshi; Nishanth Dikkala; Zhiyuan Li; Sanjiv Kumar; Sashank J. Reddi",
"publication_date": "2025",
"publication_year": "2025",
"publication_venue": "International Conference on Learning Representations (ICLR)",
"publisher": "International Conference on Learning Representations",
"publication_note": "Published at ICLR 2025; metadata verified from the official conference poster page.",
"metadata_source": "ICLR proceedings",
},
"https://proceedings.neurips.cc/paper_files/paper/2025/hash/3b01972cf31e6fa0fe29e4b8b5c2a0a1-Abstract-Conference.html": {
"authors": "Jonas Geiping; Sean McLeish; Neel Jain; John Kirchenbauer; Siddharth Singh; Brian Bartoldson; Bhavya Kailkhura; Abhinav Bhatele; Tom Goldstein",
"publication_date": "2025",
"publication_year": "2025",
"publication_venue": "Advances in Neural Information Processing Systems 38 (NeurIPS 2025)",
"publisher": "Neural Information Processing Systems Foundation",
"publication_note": "Published at NeurIPS 2025; the proceedings page's later web timestamp is not used as the conference year.",
"metadata_source": "NeurIPS proceedings",
},
"https://papers.nips.cc/paper_files/paper/2025/hash/8b08bbf8b420faa6eeb4020720582ec7-Abstract-Conference.html": {
"authors": "Sangmin Bae; Yujin Kim; Reza Bayat; Sungnyun Kim; Jiyoun Ha; Tal Schuster; Adam Fisch; Hrayr Harutyunyan; Ziwei Ji; Aaron Courville; Se-Young Yun",
"publication_date": "2025",
"publication_year": "2025",
"publication_venue": "Advances in Neural Information Processing Systems 38 (NeurIPS 2025)",
"publisher": "Neural Information Processing Systems Foundation",
"publication_note": "Published at NeurIPS 2025; the proceedings page's later web timestamp is not used as the conference year.",
"metadata_source": "NeurIPS proceedings",
},
"https://iclr.cc/virtual/2026/poster/10009450": {
"authors": "Ahmadreza Jeddi; Marco Ciccone; Babak Taati",
"publication_date": "2026",
"publication_year": "2026",
"publication_venue": "International Conference on Learning Representations (ICLR)",
"publisher": "International Conference on Learning Representations",
"publication_note": "Published at ICLR 2026; metadata verified from the official conference poster page.",
"metadata_source": "ICLR proceedings",
},
"https://iclr.cc/virtual/2026/poster/10011117": {
"authors": "Xiaojing Zhang; Haifeng Wu; Gang He; Jiyang Shen; Bochen Lyu; Zhanxing Zhu",
"publication_date": "2026",
"publication_year": "2026",
"publication_venue": "International Conference on Learning Representations (ICLR)",
"publisher": "International Conference on Learning Representations",
"publication_note": "Published at ICLR 2026; metadata verified from the official conference poster page.",
"metadata_source": "ICLR proceedings",
},
"https://iclr.cc/virtual/2026/poster/10007767": {
"authors": "Yunao Zheng; Xiaojie Wang; Lei Ren; Chen Wei",
"publication_date": "2026",
"publication_year": "2026",
"publication_venue": "International Conference on Learning Representations (ICLR)",
"publisher": "International Conference on Learning Representations",
"publication_note": "Published at ICLR 2026; metadata verified from the official conference poster page.",
"metadata_source": "ICLR proceedings",
},
"https://openreview.net/forum?id=eQaJSRZiGn": {
"authors": "Tianyu Fu; Yichen You; Zekai Chen; Guohao Dai; Huazhong Yang; Yu Wang",
"publication_date": "2026",
"publication_year": "2026",
"publication_venue": "International Conference on Machine Learning (ICML)",
"publisher": "OpenReview",
"publication_note": "Published at ICML 2026; venue and authors verified from the official OpenReview record.",
"metadata_source": "OpenReview",
},
"https://openreview.net/forum?id=ri0LAMdhd9": {
"authors": "Hayden Prairie; Zachary Novack; Taylor Berg-Kirkpatrick; Daniel Y. Fu",
"publication_date": "2026",
"publication_year": "2026",
"publication_venue": "Learning to Iterate Workshop at ICLR 2026",
"publisher": "OpenReview",
"publication_note": "Workshop paper at the Learning to Iterate Workshop at ICLR 2026; not an ICLR main-conference paper.",
"metadata_source": "OpenReview",
},
"https://doi.org/10.1145/3805760.3814895": {
"authors": "Simarjot Khanna",
"publication_date": "2026-07",
"publication_year": "2026",
"publication_venue": "Proceedings of the 3rd ACM International Conference on AI-Powered Software (AIware '26)",
"publisher": "Association for Computing Machinery",
"doi": "10.1145/3805760.3814895",
"publication_note": "Published at AIware 2026; metadata verified from the author-supplied camera-ready paper because the DOI landing page restricted automated access.",
"metadata_source": "ACM DOI and camera-ready paper",
},
"https://www.preprints.org/manuscript/202603.1756": {
"authors": "Chaoyue He; Xin Zhou; Di Wang; Hong Xu; Wei Liu; Chunyan Miao",
"publication_date": "2026-04-23",
"publication_year": "2026",
"publication_venue": "Preprints.org",
"publisher": "Preprints.org",
"doi": "10.20944/preprints202603.1756.v2",
"publication_note": "Version 2; the primary source states that this preprint is not peer-reviewed.",
"metadata_source": "primary-page",
},
"https://resources.anthropic.com/hubfs/Building%20Effective%20AI%20Agents-%20Architecture%20Patterns%20and%20Implementation%20Frameworks.pdf": {
"authors": "Anthropic",
"publication_date": "2025-12-03",
"publication_year": "2025",
"publication_venue": "Anthropic eBook",
"publisher": "Anthropic",
"publication_note": "Date verified from the primary PDF creation metadata.",
"metadata_source": "pdf-metadata",
},
"https://adk.dev/evaluate/": {
"authors": "Google Agent Development Kit",
"publication_venue": "Google Agent Development Kit",
"publisher": "Google",
"metadata_source": "primary-page",
},
"https://adk.dev/sessions/": {
"authors": "Google Agent Development Kit",
"publication_venue": "Google Agent Development Kit",
"publisher": "Google",
"metadata_source": "primary-page",
},
"https://adk.dev/graphs/": {
"authors": "Google Agent Development Kit",
"publication_venue": "Google Agent Development Kit",
"publisher": "Google",
"metadata_source": "primary-page",
},
"https://docs.langchain.com/oss/python/langgraph/persistence": {
"authors": "LangChain",
"publication_venue": "LangGraph",
"publisher": "LangChain",
"metadata_source": "primary-page",
},
"https://learn.microsoft.com/en-us/agent-framework/workflows/checkpoints": {
"authors": "Microsoft",
"publication_venue": "Microsoft Agent Framework",
"publisher": "Microsoft",
"metadata_source": "primary-page",
},
"https://docs.crewai.com/en/concepts/flows": {
"authors": "CrewAI",
"publication_venue": "CrewAI",
"publisher": "CrewAI",
"metadata_source": "primary-page",
},
"https://strandsagents.com/docs/user-guide/concepts/agents/state/": {
"authors": "Strands Agents",
"publication_venue": "Strands Agents",
"publisher": "Strands Agents",
"metadata_source": "primary-page",
},
"https://strandsagents.com/docs/user-guide/concepts/multi-agent/graph/": {
"authors": "Strands Agents",
"publication_venue": "Strands Agents",
"publisher": "Strands Agents",
"metadata_source": "primary-page",
},
}
FIELDS = [
"row_id",
"title",
"url",
"url_kind",
"domain",
"audit_status",
"http_status",
"final_url",
"canonical_url",
"content_type",
"source_title",
"source_description",
"authors",
"publication_date",
"publication_year",
"publication_venue",
"publisher",
"doi",
"publication_note",
"primary_category",
"metadata_source",
"github_repo",
"github_stars",
"github_forks",
"github_open_issues",
"github_description",
"github_license",
"github_created_at",
"github_updated_at",
"arxiv_id",
"error",
"retrieved_at",
]
RESTRICTED_HTTP = {401, 403, 405, 406, 418, 429, 999}
# Hosts that answer 404 to automated clients while serving the page normally in a browser.
# Recorded as access-restricted rather than broken, matching how scripts/verify_urls.py already
# classifies them, so the same source does not flap between broken and ok on every audit.
EDGE_FILTERED_HOSTS = {"ninadpathak.com"}
def clean(value: str | None) -> str:
if not value:
return ""
return " ".join(html.unescape(value).strip().split())
class MetadataParser(HTMLParser):
def __init__(self) -> None:
super().__init__()
self.in_title = False
self.title_parts: list[str] = []
self.description = ""
self.description_priority = 0
self.meta_values: dict[str, list[str]] = {}
@property
def title(self) -> str:
return clean(" ".join(self.title_parts))
def handle_starttag(self, tag: str, attrs: list[tuple[str, str | None]]) -> None:
if tag.lower() == "title":
self.in_title = True
return
if tag.lower() != "meta":
return
attr_map = {key.lower(): value or "" for key, value in attrs}
name = (attr_map.get("name") or attr_map.get("property") or attr_map.get("itemprop") or "").lower()
candidate = clean(attr_map.get("content"))
if name and candidate:
self.meta_values.setdefault(name, []).append(candidate)
priority = {
"description": 1,
"og:description": 1,
"twitter:description": 1,
"dc.description": 2,
"citation_abstract": 3,
}.get(name, 0)
if candidate and priority > self.description_priority:
self.description = candidate
self.description_priority = priority
def handle_endtag(self, tag: str) -> None:
if tag.lower() == "title":
self.in_title = False
def handle_data(self, data: str) -> None:
if self.in_title:
self.title_parts.append(data)
def first(self, *names: str) -> str:
for name in names:
values = self.meta_values.get(name.lower(), [])
if values:
return values[0]
return ""
def all(self, *names: str) -> list[str]:
for name in names:
values = self.meta_values.get(name.lower(), [])
if values:
return list(dict.fromkeys(values))
return []
class RedirectHandler(urllib.request.HTTPRedirectHandler):
"""Teach Python 3.9's urllib opener to follow permanent HTTP 308 moves."""
def http_error_308(self, req, fp, code, msg, headers): # type: ignore[no-untyped-def]
return self.http_error_302(req, fp, code, msg, headers)
def redirect_request(self, req, fp, code, msg, headers, newurl): # type: ignore[no-untyped-def]
if code == 308 and req.get_method() in {"GET", "HEAD"}:
code = 307
return super().redirect_request(req, fp, code, msg, headers, newurl)
def read_rows() -> list[dict[str, str]]:
with RESOURCES_CSV.open(encoding="utf-8", newline="") as handle:
return list(csv.DictReader(handle))
def github_repo_from_url(url: str) -> str:
parsed = urlparse(url)
if parsed.netloc.lower() != "github.com":
return ""
parts = [part for part in parsed.path.strip("/").split("/") if part]
if len(parts) < 2 or parts[0] in {"topics", "marketplace", "features"}:
return ""
return f"{parts[0]}/{parts[1]}"
def arxiv_id_from_url(url: str) -> str:
match = ARXIV_RE.search(url)
return match.group("id") if match else ""
def normalize_date(value: str) -> str:
value = clean(value)
if not value:
return ""
match = ISO_DATE_RE.search(value)
if match:
return f"{match.group('year')}-{int(match.group('month')):02d}-{int(match.group('day')):02d}"
year = YEAR_RE.search(value)
return year.group("year") if year else ""
def year_from_value(value: str) -> str:
match = YEAR_RE.search(value or "")
return match.group("year") if match else ""
def normalize_doi(value: str) -> str:
value = clean(value)
for prefix in ("https://doi.org/", "http://doi.org/", "doi:"):
if value.lower().startswith(prefix):
value = value[len(prefix) :]
break
return value.strip()
def publisher_for_domain(domain: str) -> str:
normalized = domain.lower().removeprefix("www.")
for suffix, publisher in PUBLISHER_BY_DOMAIN.items():
if normalized == suffix or normalized.endswith(f".{suffix}"):
return publisher
return normalized
def project_github_venue(url: str) -> str:
path = urlparse(url).path.lower()
if "/releases" in path:
return "GitHub Releases"
if "/discussions" in path:
return "GitHub Discussions"
return "GitHub"
def html_metadata(body: bytes, content_type: str) -> dict[str, str]:
if "html" not in content_type.lower():
return {}
text = body[:750_000].decode("utf-8", errors="ignore")
parser = MetadataParser()
try:
parser.feed(text)
except Exception: # noqa: BLE001 - source metadata should not fail the URL audit.
return {}
authors = parser.all("citation_author", "dc.creator", "author")
publication_date = normalize_date(
parser.first(
"citation_publication_date",
"citation_date",
"article:published_time",
"datepublished",
"dc.date.issued",
"dc.date",
"date",
)
)
publication_venue = parser.first(
"citation_conference_title",
"citation_journal_title",
"citation_technical_report_institution",
)
publisher = parser.first("citation_publisher", "dc.publisher", "og:site_name", "application-name")
doi = normalize_doi(parser.first("citation_doi", "dc.identifier.doi", "doi"))
has_publication_metadata = any((authors, publication_date, publication_venue, publisher, doi))
return {
"source_title": parser.title,
"source_description": parser.description,
"authors": "; ".join(authors),
"publication_date": publication_date,
"publication_year": year_from_value(publication_date),
"publication_venue": publication_venue,
"publisher": publisher,
"doi": doi,
"metadata_source": "html-meta" if has_publication_metadata else "",
}
def fetch_url(url: str, timeout: float, attempts: int) -> dict[str, str]:
context = ssl._create_unverified_context()
opener = urllib.request.build_opener(
urllib.request.HTTPSHandler(context=context),
RedirectHandler(),
)
last_error = ""
parsed_url = urlparse(url)
request_url = url
for attempt in range(1, attempts + 1):
for method in ("GET", "HEAD"):
request = urllib.request.Request(
request_url,
method=method,
headers={"User-Agent": "awesome-loop-engineering-source-audit"},
)
try:
with opener.open(request, timeout=timeout) as response:
final_url = response.geturl()
final_host = urlparse(final_url).netloc.lower()
if parsed_url.netloc.lower() == "code.claude.com" and final_host not in {
"",
"code.claude.com",
"docs.anthropic.com",
}:
return {
"audit_status": "restricted",
"http_status": str(response.status),
"final_url": request_url,
"content_type": response.headers.get("content-type", ""),
"source_title": "",
"source_description": "",
"error": f"redirected_to_unrelated_host:{final_host}",
}
content_type = response.headers.get("content-type", "")
body = response.read(750_000) if method == "GET" else b""
metadata = html_metadata(body, content_type)
result = {
"audit_status": "ok",
"http_status": str(response.status),
"final_url": final_url,
"content_type": content_type,
"error": "",
}
result.update(metadata)
return result
except urllib.error.HTTPError as error:
if method == "HEAD":
continue
error_host = urlparse(error.geturl()).netloc.lower()
if parsed_url.netloc.lower() == "code.claude.com" and error_host not in {
"",
"code.claude.com",
"docs.anthropic.com",
}:
return {
"audit_status": "restricted",
"http_status": str(error.code),
"final_url": request_url,
"content_type": error.headers.get("content-type", "") if error.headers else "",
"source_title": "",
"source_description": "",
"error": f"redirected_to_unrelated_host:{error_host}",
}
if error.code == 404 and parsed_url.netloc.lower() == "code.claude.com" and attempt < attempts:
last_error = "HTTPError:404"
break
if error.code in RESTRICTED_HTTP or (
error.code == 404 and parsed_url.netloc.lower() in EDGE_FILTERED_HOSTS
):
return {
"audit_status": "restricted",
"http_status": str(error.code),
"final_url": request_url,
"content_type": error.headers.get("content-type", "") if error.headers else "",
"source_title": "",
"source_description": "",
"error": "restricted_or_rate_limited",
}
return {
"audit_status": "broken",
"http_status": str(error.code),
"final_url": request_url,
"content_type": error.headers.get("content-type", "") if error.headers else "",
"source_title": "",
"source_description": "",
"error": f"HTTPError:{error.code}",
}
except Exception as error: # noqa: BLE001 - audit output should capture exact failure class.
last_error = error.__class__.__name__
if method == "HEAD":
continue
if attempt < attempts:
delay = 1.5 * attempt if parsed_url.netloc.lower() == "code.claude.com" else 0.25 * attempt
time.sleep(min(4.0, delay))
return {
"audit_status": "unreachable",
"http_status": "",
"final_url": request_url,
"content_type": "",
"source_title": "",
"source_description": "",
"error": last_error or "unknown",
}
def audit_row(row: dict[str, str], retrieved_at: str, timeout: float, attempts: int) -> dict[str, str]:
base = {
"row_id": row["row_id"],
"title": row["title"],
"url": row["url"],
"url_kind": row["url_kind"],
"domain": row["domain"],
"audit_status": "",
"http_status": "",
"final_url": "",
"canonical_url": "",
"content_type": "",
"source_title": "",
"source_description": "",
"authors": "",
"publication_date": "",
"publication_year": "",
"publication_venue": "",
"publisher": "",
"doi": "",
"publication_note": "",
"primary_category": "",
"metadata_source": "",
"github_repo": github_repo_from_url(row["url"]),
"github_stars": "",
"github_forks": "",
"github_open_issues": "",
"github_description": "",
"github_license": "",
"github_created_at": "",
"github_updated_at": "",
"arxiv_id": arxiv_id_from_url(row["url"]),
"error": "",
"retrieved_at": retrieved_at,
}
if row["url_kind"] == "local_path":
local_target, fragment = urldefrag(row["url"])
path = (ROOT / local_target).resolve()
if path.exists():
base.update(
{
"audit_status": "local_ok",
"final_url": f"{REPO_BLOB_URL}/{local_target}" + (f"#{fragment}" if fragment else ""),
"source_title": row["title"],
"publication_year": "2026",
"publication_venue": "GitHub",
"publisher": "GitHub",
"metadata_source": "repository",
}
)
else:
base.update({"audit_status": "local_missing", "error": "local_path_missing"})
return base
if row["url_kind"] == "local_anchor":
base.update(
{
"audit_status": "local_anchor",
"final_url": row["url"],
"publication_year": "2026",
"publication_venue": "GitHub",
"publisher": "GitHub",
"metadata_source": "repository",
}
)
return base
base.update(fetch_url(row["url"], timeout=timeout, attempts=attempts))
return base
def github_stats_via_gh(repo: str, timeout: float) -> dict[str, str]:
if not repo:
return {}
try:
result = subprocess.run(
["gh", "api", f"repos/{repo}"],
check=False,
capture_output=True,
text=True,
timeout=timeout,
)
except Exception: # noqa: BLE001 - stats are best-effort.
return {}
if result.returncode != 0:
return {}
try:
return github_stats_from_payload(json.loads(result.stdout))
except json.JSONDecodeError:
return {}
def github_stats_from_payload(data: dict[str, object]) -> dict[str, str]:
license_data = data.get("license") or {}
if not isinstance(license_data, dict):
license_data = {}
description = data.get("description") or ""
return {
"github_stars": str(data.get("stargazers_count", "")),
"github_forks": str(data.get("forks_count", "")),
"github_open_issues": str(data.get("open_issues_count", "")),
"github_description": clean(str(description)),
"github_license": clean(str(license_data.get("spdx_id", ""))),
"github_created_at": clean(str(data.get("created_at", ""))),
"github_updated_at": clean(str(data.get("updated_at", ""))),
}
def github_stats(repo: str, timeout: float, use_gh_cli: bool) -> dict[str, str]:
if not repo:
return {}
if use_gh_cli:
stats = github_stats_via_gh(repo, timeout=timeout)
if stats:
return stats
context = ssl._create_unverified_context()
request = urllib.request.Request(
f"https://api.github.com/repos/{repo}",
headers={"User-Agent": "awesome-loop-engineering-source-audit"},
)
try:
with urllib.request.urlopen(request, timeout=timeout, context=context) as response:
data = json.loads(response.read().decode("utf-8"))
except Exception: # noqa: BLE001 - stats are best-effort; URL audit carries primary status.
return {}
return github_stats_from_payload(data)
def enrich_github(rows: list[dict[str, str]], timeout: float, use_gh_cli: bool) -> None:
repos = sorted({row["github_repo"] for row in rows if row["github_repo"]})
stats = {repo: github_stats(repo, timeout=timeout, use_gh_cli=use_gh_cli) for repo in repos}
for row in rows:
row.update(stats.get(row["github_repo"], {}))
def fetch_arxiv_batch(arxiv_ids: list[str], timeout: float, attempts: int) -> dict[str, dict[str, str]]:
query = urlencode({"id_list": ",".join(arxiv_ids), "max_results": str(len(arxiv_ids))})
url = f"https://export.arxiv.org/api/query?{query}"
context = ssl._create_unverified_context()
request = urllib.request.Request(
url,
headers={"User-Agent": "awesome-loop-engineering-publication-audit"},
)
for attempt in range(1, attempts + 1):
try:
with urllib.request.urlopen(request, timeout=timeout, context=context) as response:
root = ET.fromstring(response.read())
break
except Exception: # noqa: BLE001 - fallback metadata remains explicit below.
if attempt == attempts:
return {}
time.sleep(min(3.0, attempt))
records: dict[str, dict[str, str]] = {}
for entry in root.findall(f"{ATOM_NS}entry"):
entry_url = clean(entry.findtext(f"{ATOM_NS}id") or "")
match = ARXIV_RE.search(entry_url)
if not match:
continue
arxiv_id = match.group("id")
authors = [
clean(author.findtext(f"{ATOM_NS}name") or "")
for author in entry.findall(f"{ATOM_NS}author")
]
primary = entry.find(f"{ARXIV_NS}primary_category")
published = normalize_date(entry.findtext(f"{ATOM_NS}published") or "")
journal_reference = clean(entry.findtext(f"{ARXIV_NS}journal_ref") or "")
records[arxiv_id] = {
"authors": "; ".join(author for author in authors if author),
"publication_date": published,
"publication_year": year_from_value(published),
"publication_venue": journal_reference or "arXiv",
"publisher": "arXiv",
"doi": normalize_doi(entry.findtext(f"{ARXIV_NS}doi") or ""),
"publication_note": clean(entry.findtext(f"{ARXIV_NS}comment") or ""),
"primary_category": clean(primary.get("term", "")) if primary is not None else "",
"metadata_source": "arxiv-api",
}
return records
def arxiv_year(arxiv_id: str) -> str:
try:
return str(2000 + int(arxiv_id[:2]))
except (TypeError, ValueError):
return ""
def enrich_arxiv(rows: list[dict[str, str]], timeout: float, attempts: int) -> None:
arxiv_ids = sorted({row["arxiv_id"] for row in rows if row["arxiv_id"]})
records: dict[str, dict[str, str]] = {}
batch_size = 75
for start in range(0, len(arxiv_ids), batch_size):
if start:
time.sleep(3.0)
records.update(fetch_arxiv_batch(arxiv_ids[start : start + batch_size], timeout, attempts))
for row in rows:
arxiv_id = row["arxiv_id"]
if not arxiv_id:
continue
metadata = records.get(arxiv_id)
if metadata:
row.update({key: value for key, value in metadata.items() if value})
else:
row["publisher"] = "arXiv"
row["publication_year"] = row["publication_year"] or arxiv_year(arxiv_id)
row["metadata_source"] = row["metadata_source"] or "arxiv-id"
def load_arxiv_publication_decisions() -> dict[str, dict[str, str]]:
if not ARXIV_PUBLICATION_AUDIT.exists():
return {}
with ARXIV_PUBLICATION_AUDIT.open(encoding="utf-8", newline="") as handle:
return {row["arxiv_id"]: row for row in csv.DictReader(handle)}
def apply_arxiv_publication_overlay(rows: list[dict[str, str]]) -> None:
decisions = load_arxiv_publication_decisions()
for row in rows:
row["canonical_url"] = row.get("canonical_url") or row.get("final_url") or row["url"]
decision = decisions.get(row.get("arxiv_id", ""))
if not decision or decision["status"] not in {"accepted", "published"}:
continue
for field in (
"publication_date",
"publication_year",
"publication_venue",
"publisher",
"doi",
"metadata_source",
):
row[field] = decision[field]
row["canonical_url"] = decision["published_url"] or row["canonical_url"]
if decision["status"] == "accepted":
row["publication_note"] = (
f"Accepted at {decision['publication_venue']}; "
"the linked arXiv record is the available paper version."
)
else:
row["publication_note"] = (
f"Published in {decision['publication_venue']}; "
"the linked arXiv record remains available for open access."
)
def year_from_url(url: str) -> str:
parsed = urlparse(url)
match = re.search(r"/(?:manuscript/)?(?P<year>20\d{2})(?:[/_-]|\d{2}\.)", parsed.path)
if not match:
return ""
year = int(match.group("year"))
return str(year) if year <= datetime.now(timezone.utc).year + 1 else ""
def finalize_publication_metadata(rows: list[dict[str, str]]) -> None:
for row in rows:
override = PUBLICATION_OVERRIDES.get(row["url"], {})
row.update({key: value for key, value in override.items() if value})
if row["arxiv_id"] and row["metadata_source"] == "html-meta":
row["metadata_source"] = "arxiv-html-meta"
if row["github_repo"]:
row["publisher"] = "GitHub"
if row["github_repo"].lower() == PROJECT_GITHUB_REPO:
row["publication_venue"] = project_github_venue(row["url"])
else:
row["publication_venue"] = row["publication_venue"] or row["github_repo"]
if not row["publication_date"] and row["github_created_at"]:
row["publication_date"] = normalize_date(row["github_created_at"])
row["metadata_source"] = "github-api"
if not row["publisher"]:
row["publisher"] = publisher_for_domain(row["domain"]) or "Source not stated"
if not row["publication_year"]:
row["publication_year"] = year_from_value(row["publication_date"])
if not row["publication_year"]:
row["publication_year"] = year_from_url(row["url"])
if row["publication_year"] and not row["metadata_source"]:
row["metadata_source"] = "url-date"
if not row["metadata_source"]:
row["metadata_source"] = "domain-fallback"
row["doi"] = normalize_doi(row["doi"])
def write_audit(rows: list[dict[str, str]], out_path: Path = AUDIT_CSV) -> None:
out_path.parent.mkdir(parents=True, exist_ok=True)
with out_path.open("w", encoding="utf-8", newline="") as handle:
writer = csv.DictWriter(handle, fieldnames=FIELDS, lineterminator="\n")
writer.writeheader()
writer.writerows(rows)
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--timeout", type=float, default=10.0)
parser.add_argument("--workers", type=int, default=12)
parser.add_argument("--attempts", type=int, default=2)
parser.add_argument("--github-cli", action="store_true", help="use authenticated gh api calls for GitHub repo stats")
parser.add_argument("--fail-on-broken", action="store_true")
parser.add_argument(
"--apply-publication-overlay-only",
action="store_true",
help="apply the checked-in arXiv publication decisions to the existing source audit without network access",
)
args = parser.parse_args()
if args.apply_publication_overlay_only:
with AUDIT_CSV.open(encoding="utf-8", newline="") as handle:
audited = list(csv.DictReader(handle))
finalize_publication_metadata(audited)
apply_arxiv_publication_overlay(audited)
write_audit(audited)
resolved = sum(
bool(row.get("arxiv_id")) and row.get("publisher") not in {"", "arXiv"}
for row in audited
)
print(f"Applied {resolved} published or accepted venue records to {AUDIT_CSV.relative_to(ROOT)}")
return 0
retrieved_at = datetime.now(timezone.utc).replace(microsecond=0).isoformat()
rows = read_rows()
with futures.ThreadPoolExecutor(max_workers=args.workers) as executor:
checks = [executor.submit(audit_row, row, retrieved_at, args.timeout, args.attempts) for row in rows]
audited = [check.result() for check in futures.as_completed(checks)]
audited.sort(key=lambda row: row["row_id"])
enrich_github(audited, timeout=args.timeout, use_gh_cli=args.github_cli)
enrich_arxiv(audited, timeout=max(args.timeout, 20.0), attempts=args.attempts)
finalize_publication_metadata(audited)
apply_arxiv_publication_overlay(audited)
write_audit(audited)
broken = [row for row in audited if row["audit_status"] in {"broken", "unreachable", "local_missing"}]
print(f"Wrote {len(audited)} rows to {AUDIT_CSV.relative_to(ROOT)}")
print(f"Broken or unreachable rows: {len(broken)}")
for row in broken[:20]:
print(f"- {row['row_id']} {row['audit_status']} {row['url']} {row['error']}", file=sys.stderr)
if broken and args.fail_on_broken:
return 1
return 0
if __name__ == "__main__":
raise SystemExit(main())
|