"""Repeat every deterministic audit and compare reviewed resource/package byte identities.""" from __future__ import annotations import hashlib import json import subprocess import sys from build_definition import OUT, REPO, canonical from rebuild import RESOURCE, build_all def main(): a, overview = build_all() b, again = build_all() assert a == b and overview == again assert a == json.loads((REPO / RESOURCE).read_bytes()) names = [ "audit-summary.json", "review-delta.json", "import-protection.json", "boundaries.json", "package-check.json", "source-check.json", "source-graph.json", ] subprocess.run([sys.executable, str(OUT / "recompute.py")], cwd=REPO, check=True) before = {p: hashlib.sha256((OUT / p).read_bytes()).hexdigest() for p in names} subprocess.run([sys.executable, str(OUT / "recompute.py")], cwd=REPO, check=True) assert before == {p: hashlib.sha256((OUT / p).read_bytes()).hexdigest() for p in names} (OUT / "repeatability.json").write_text( json.dumps( dict( definitions=18, repeated_build_equal=True, repeated_audits_equal=True, resource_sha256=hashlib.sha256(canonical(a)).hexdigest(), artifacts=before, ), ensure_ascii=False, indent=2, ) + "\n" ) print("PASS repeated 18 definitions and upgrade/audit/package recomputation: zero difference") if __name__ == "__main__": main()