"""Deterministic local verification and manifest generator."""
import hashlib, json, platform, subprocess, sys
from pathlib import Path
ROOT=Path(__file__).resolve().parent
result=subprocess.run([sys.executable,str(ROOT/'verify_sympy.py')],cwd=ROOT,text=True,capture_output=True,timeout=900,check=True)
files=['paper.md','README.md','requirements.txt','verify_sympy.py','verify_sage.py','verify_maple.mpl','certificate_sympy.json','independent_reproduction.md']
hashes={name:hashlib.sha256((ROOT/name).read_bytes()).hexdigest() for name in files}
manifest={'status':'PASS','python':sys.version,'platform':platform.platform(),'command':[sys.executable,'verify_sympy.py'],'stdout':result.stdout,'files_sha256':hashes}
payload=json.dumps(manifest,indent=2,sort_keys=True)
(ROOT/'manifest.json').write_text(payload,encoding='utf-8')
print(json.dumps({'status':'PASS','manifest':'manifest.json','sha256':hashlib.sha256(payload.encode()).hexdigest()},indent=2))
