"""Verify final container source bytes without attributing old experiments to a new image.""" import hashlib import json import subprocess from pathlib import Path ids = subprocess.check_output(["docker", "compose", "ps", "-q", "api"], text=True).split() assert ids probe = "import hashlib,json,pathlib; p=pathlib.Path('/app/src/messenger'); print(json.dumps({x.name:hashlib.sha256(x.read_bytes()).hexdigest() for x in sorted(p.glob('*.py'))}))" expected = {p.name: hashlib.sha256(p.read_bytes()).hexdigest() for p in sorted(Path("src/messenger").glob("*.py"))} instances = [] for cid in ids: actual = json.loads(subprocess.check_output(["docker", "exec", cid, "python", "-c", probe], text=True)) assert actual == expected, "Runtime source differs from repository" identity = json.loads(subprocess.check_output(["docker", "inspect", cid], text=True))[0] instances.append({"container_id": cid, "image_id": identity["Image"], "source_matches_repository": True}) result = {"instances": instances, "runtime_source_sha256": expected, "passed": True, "fault_scope": "The repeated 11 fault scenarios and 9 extra invariants ran after worker/jobs/UTF-8/image-validation fixes. Only the shared validate_image wrapper's killpg/output failure guards were tightened afterward. The complete final 179-case suite and 40M image runs used this final image; no full-image identity with the preceding fault run is claimed."} Path("evidence/review-runtime-source.json").write_text(json.dumps(result, indent=2)) print("PASS: both final API containers match repository source")