---
type: "Source File"
title: "!/usr/bin/env python3"
description: "#!/usr/bin/env python3 \"\"\"Append source-reviewed model evidence without network access or model calls. The catalogue is a dated editorial snapshot, not an automatic release detector. Use --appendix to merge into the."
resource: "https://capabilities.copecheck.com"
tags: ["copecheck", "capabilities", "source-file", "py"]
timestamp: "2026-10-24T17:25:06Z"
site: "capabilities"
source_path: "copecheck-capabilities/tools/import_reviewed_models.py"
---

# !/usr/bin/env python3

Source path: `copecheck-capabilities/tools/import_reviewed_models.py`  
Index snapshot generated: `2026-11-24T13:27:52Z`  
File modified: `2026-10-24T17:25:06Z`

```py
#!/usr/bin/env python3
"""Append source-reviewed model evidence without network access or model calls.

The catalogue is a dated editorial snapshot, not an automatic release detector.
Use --appendix to merge into the current register rather than deploying an old
local register over a newer production copy.
"""
from __future__ import annotations

import argparse
import datetime as dt
import json
from pathlib import Path

from import_vendor_releases import DEFAULT_APPENDIX, load_appendix, normalise_url, write_appendix

DEFAULT_CATALOG = Path(__file__).resolve().parents[1] / "data" / "reviewed-models-2026-10-24.json"


def merge_catalog(appendix: dict, catalog: dict) -> list[dict]:
    """Validate the entire batch before mutating; preserve every existing item."""
    reviewed = dt.date.fromisoformat(catalog["reviewed_at"])
    if reviewed > dt.datetime.now(dt.timezone.utc).date():
        raise ValueError("Review date is in the future")
    rows = catalog["items"]
    if not isinstance(rows, list):
        raise ValueError("Catalogue items must be a list")
    required = {"slug", "url", "title", "publisher", "claim", "oracle_verdict", "observed_at", "evidence_status", "availability"}
    for row in rows:
        if not required <= row.keys() or any(not row[k] for k in required):
            raise ValueError(f"Incomplete reviewed item: {row.get('slug')}")
        if dt.date.fromisoformat(row["observed_at"]) > reviewed:
            raise ValueError("Evidence date cannot follow review date")
        if not row["url"].startswith("https://"):
            raise ValueError("Evidence requires an HTTPS source")
    existing = appendix.get("items", [])
    urls = {normalise_url(str(row.get("url", ""))) for row in existing}
    slugs = {row.get("slug") for row in existing}
    added = []
    for row in rows:
        aliases = {normalise_url(url) for url in [row["url"], *row.get("url_aliases", [])]}
        if aliases & urls:
            continue
        if row["slug"] in slugs:
            raise ValueError(f"Slug collision: {row['slug']}")
        added.append({**row, "source_family": "reviewed_vendor_model", "reviewed_at": catalog["reviewed_at"]})
        urls.update(aliases)
        slugs.add(row["slug"])
    if added:
        appendix.setdefault("items", []).extend(added)
        appendix["updated_at"] = dt.datetime.now(dt.timezone.utc).replace(microsecond=0).isoformat().replace("+00:00", "Z")
        appendix.setdefault("scanner", {})["reviewed_model_import"] = {
            "reviewed_at": catalog["reviewed_at"], "added": len(added),
            "mode": "reviewed_primary_sources_no_model_call",
            "sources": sorted({row["url"] for row in rows}),
        }
    return added


def main() -> None:
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("--appendix", type=Path, default=DEFAULT_APPENDIX)
    parser.add_argument("--catalog", type=Path, default=DEFAULT_CATALOG)
    parser.add_argument("--dry-run", action="store_true")
    args = parser.parse_args()
    appendix = load_appendix(args.appendix)
    catalog = json.loads(args.catalog.read_text(encoding="utf-8"))
    added = merge_catalog(appendix, catalog)
    print(f"Reviewed sources: {len(catalog['items'])}; new entries: {len(added)}")
    for row in added:
        print(f"- {row['publisher']}: {row['title']}")
    if added and not args.dry_run:
        write_appendix(args.appendix, appendix)


if __name__ == "__main__":
    main()
```
