#!/usr/bin/env python3 """Validate release paths and sizes without reading field values.""" from __future__ import annotations import argparse import json from pathlib import Path def main() -> int: parser = argparse.ArgumentParser() parser.add_argument("release_root", type=Path, nargs="?", default=Path.cwd()) args = parser.parse_args() root = args.release_root.resolve() manifest = root / "metadata" / "cases.jsonl" rows = [json.loads(line) for line in manifest.read_text().splitlines() if line] missing = [] size_mismatches = [] for row in rows: file_path = root / row["release_path"] if not file_path.is_file(): missing.append(row["release_path"]) continue actual = file_path.stat().st_size if actual != row["file_bytes"]: size_mismatches.append( {"file": row["release_path"], "expected": row["file_bytes"], "actual": actual} ) report = { "root": str(root), "manifest_rows": len(rows), "missing": missing, "size_mismatches": size_mismatches, "valid": not missing and not size_mismatches, } print(json.dumps(report, indent=2, sort_keys=True)) return 0 if report["valid"] else 1 if __name__ == "__main__": raise SystemExit(main())