"""Read and hash three pinned public documents without installing or executing FreeVideo."""

import hashlib
import json
import urllib.request

REVISION = "e92a08df3c1ec9a96fb52a07b19976e1c74eb2be"
DOCUMENTS = ("README.md", "docs/Mac.md", "docs/execution-planning.md")


def audit():
    documents = []
    for name in DOCUMENTS:
        url = f"https://raw.githubusercontent.com/FlashML-org/FreeVideo/{REVISION}/{name}"
        request = urllib.request.Request(url, headers={"User-Agent": "CloutDocumentAudit/1.0"})
        with urllib.request.urlopen(request, timeout=30) as response:
            data = response.read()
        documents.append(
            {"path": name, "bytes": len(data), "sha256": hashlib.sha256(data).hexdigest()}
        )
    return {
        "repository": "FlashML-org/FreeVideo",
        "revision": REVISION,
        "scope": "Public document bytes only with no installation inference or weight validation",
        "documents": documents,
    }


if __name__ == "__main__":
    print(json.dumps(audit(), indent=2))
