# Verity Edge: verify the continuity test pack hash. Python 3, standard library only.
# Usage: python verify_pack.py continuity_events_snapshot_2026-10-06.json   (saved copy)
#        python verify_pack.py                                                  (live public record)
import sys, json, hashlib, urllib.request
URL = "https://api.verityedge.eu/api/v1/public/continuity-events?limit=50"
IDS = ["3547cfa1-231d-423a-a039-86210fc2954a",  # kill-mid-drain, 30 Sep
       "5a272fea-5a84-404d-bf4b-da3d93752bc3",  # 60 min, 29 Sep
       "ae278b52-095e-473e-918e-0945b65643fc",  # 120 min, 29 Sep
       "de8c2310"]                              # 30 min, 29 Sep (matched by prefix)
EXPECTED = "9992a52cabd21084f932af8f7228157c64f3221a5c618da815c9429d81696578"
data = json.load(open(sys.argv[1])) if len(sys.argv) > 1 else json.load(urllib.request.urlopen(URL))
ev = [e for e in data["events"] if any(e["id"].startswith(i) for i in IDS)]
ev.sort(key=lambda e: e["id"])
canon = json.dumps(ev, sort_keys=True, separators=(",", ":"), ensure_ascii=False)
h = hashlib.sha256(canon.encode("utf-8")).hexdigest()
print("events found:", len(ev), "(expected 4)")
print("computed:", h)
print("expected:", EXPECTED)
print("MATCH" if h == EXPECTED and len(ev) == 4 else "NO MATCH")
