#!/usr/bin/env python3 """Freeze a locally verified candidate. This script has no upload capability.""" import argparse import json from pathlib import Path from hf_release_common import VERSION, file_digest, read_json, write_json def freeze(dataset): required = [ "dataset-validation.json", "replay-validation.json", "gqa-reconstruction-validation.json", ] for name in required: if read_json(dataset / "validation" / name).get("status") != "passed": raise ValueError("Missing successful release check: " + name) files = {} for path in sorted(dataset.rglob("*")): if path.is_symlink(): raise ValueError("Symlink in upload candidate") if not path.is_file() or path.name == "MANIFEST.json": continue relative = str(path.relative_to(dataset)) if ( any(part in {".git", ".cache", ".venv", "__pycache__"} for part in path.parts) or path.suffix in {".pyc", ".log"} or path.name.startswith(".env") ): raise ValueError("Unintended local file in upload candidate: " + relative) files[relative] = {"bytes": path.stat().st_size, "sha256": file_digest(path)} manifest = { "version": VERSION, "purpose": "Release integrity and provenance, separate from semantic/pixel witness evidence", "files": files, "total_bytes": sum(row["bytes"] for row in files.values()), "publication_performed": False, } write_json(dataset / "MANIFEST.json", manifest) return { "status": "frozen_not_uploaded", "files": len(files), "bytes": manifest["total_bytes"], "manifest_sha256": file_digest(dataset / "MANIFEST.json"), } if __name__ == "__main__": parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--dataset", type=Path, required=True) args = parser.parse_args() print(json.dumps(freeze(args.dataset)))