# -*- coding: utf-8 -*-
"""Reproducibility manifest: SHA-256 of every artifact + environment pins."""
import hashlib, json, os, sys, platform
import sympy

DIR = 'post-jc-program'
files = sorted(f for f in os.listdir(DIR) if f.endswith(('.py', '.json', '.txt')))
manifest = {
    "program": "post-jc-program — machine-verified corollary mining of the Jacobian Conjecture collapse",
    "date": "2026-07-21",
    "environment": {
        "python": sys.version.split()[0],
        "sympy": sympy.__version__,
        "platform": platform.platform(),
        "seeds": {"construction": 20260721, "independent_verify": 987654321},
    },
    "run_order": [
        "python phase1_dixmier_witness.py",
        "python phase2_normalize.py",
        "python phase3_reduce_to_degree3.py",
        "python phase4_independent_verify.py",
        "python phase5b_chain_det_proof.py",
        "python make_manifest.py",
    ],
    "artifacts": {},
}
for f in files:
    if f == 'manifest.json':
        continue
    p = os.path.join(DIR, f)
    h = hashlib.sha256(open(p, 'rb').read()).hexdigest()
    manifest["artifacts"][f] = {"sha256": h, "bytes": os.path.getsize(p)}
    print(f"{h}  {f}")
json.dump(manifest, open(os.path.join(DIR, 'manifest.json'), 'w', encoding='utf-8'), indent=2)
print("\nmanifest.json written")
