from pathlib import Path import subprocess,hashlib,ast,json,tempfile,sys p=Path(__file__).parent;s=(p/'verify_synthesis.py').read_text() assert hashlib.sha256(s.encode()).hexdigest()=='e31cbf4b2cee6453072e2112007cf9e6769d1f03af3e434c1b2b29637103a6fe' r=subprocess.run([sys.executable,str(p/'verify_synthesis.py')],capture_output=True,check=True);(p/'verify_synthesis.stdout.txt').write_bytes(r.stdout) assert hashlib.sha256(r.stdout).hexdigest()=='23956f751d6800cc0de294d67afac0212a63380791b0a1143e742d2a4767e58f' mut=s.replace('(23, 29): 2','(23, 29): 999').replace('4: 4\n','4: 999\n');assert mut!=s with tempfile.TemporaryDirectory(prefix='mutation-') as tmp: q=Path(tmp)/'mutation.py';q.write_text(mut);r2=subprocess.run([sys.executable,str(q)],capture_output=True,check=True) assert b'SYNTHESIS CONCLUSION: PASS' in r2.stdout and b'L(T_23, 29) = 999' in r2.stdout (p/'mutation.stdout.txt').write_bytes(r2.stdout) a=[{'line':n.lineno,'test':ast.unparse(n.test)} for n in ast.walk(ast.parse(s)) if isinstance(n,ast.Assert)] (p/'script-audit.json').write_text(json.dumps({'producer_sha256':hashlib.sha256(s.encode()).hexdigest(),'original_stdout_sha256':hashlib.sha256(r.stdout).hexdigest(),'original_recipe_matches':True,'assertions':a,'mutation':{'replacements':[['(23, 29): 2','(23, 29): 999'],['4: 4\\n','4: 999\\n']],'exit_code':r2.returncode,'conclusion_PASS':True,'sha256':hashlib.sha256(r2.stdout).hexdigest()},'scope':'census assertions are real checks; diagonal and spectrum are literal inputs; Q and mass inequalities are printed, not evaluated'},indent=2)+'\n') print('PASS original recipe matches; altered diagonal/spectrum still prints PASS')