from concurrent.futures import ThreadPoolExecutor from pathlib import Path import hashlib import json import sys from urllib.request import Request, urlopen root=Path(__file__).parent pins=["adc7f1241b42e322a6451854ab7e4b4c146bf78a","1581d4cbdd69a0faf34b2089614fe2a814316a6a"] if len(sys.argv) > 1: pins[1] = sys.argv[1] output_name = "comparator-commit-comparison.json" else: output_name = "commit-comparison.json" names=[m.replace(".","/") + ".lean" for m in (root/"project-modules.txt").read_text().splitlines()] names += ["ComparatorChallenges/CycleDecomposition.lean","ComparatorChallenges/CycleDecomposition.json","lean-toolchain"] def read(pin,name): url=f"https://raw.githubusercontent.com/openai/math/{pin}/lean/{name}" request=Request(url,headers={"User-Agent":"Codex Lean commit comparison"}) with urlopen(request,timeout=35) as r: return r.read() def compare(name): local=root/"source"/name before=local.read_bytes() if local.exists() else read(pins[0],name) after=read(pins[1],name) return {"path":name,"desk_sha256":hashlib.sha256(before).hexdigest(), "replay_sha256":hashlib.sha256(after).hexdigest(),"byte_identical":before==after} with ThreadPoolExecutor(max_workers=8) as pool: report=list(pool.map(compare,names)) (root/output_name).write_text(json.dumps({"commits":pins,"files":report},indent=2)+"\n") print(sum(x["byte_identical"] for x in report),"of",len(report),"paths match byte for byte") print("Changed:",[x["path"] for x in report if not x["byte_identical"]]) pinned=(root/"published-lake-manifest.json").read_bytes() for label,content in (("desk",pinned),("external replay",read(pins[1],"lake-manifest.json"))): packages=json.loads(content)["packages"] pkg=next(x for x in packages if x["name"]=="mathlib") print(label,"Mathlib",pkg["rev"])