import hashlib,json,shutil
from pathlib import Path
import analysis,build_paper_content,build_pdf
root=Path(__file__).resolve().parent; workspace=root.parents[1]; temp_root=workspace/'tmp-research-039'/'reproduction'
assert workspace in temp_root.parents and temp_root.name=='reproduction'
if temp_root.exists(): shutil.rmtree(temp_root)
temp_root.mkdir(parents=True)
try:
    analysis.run(temp_root)
    rebuilt=temp_root/'paper.pdf'; build_pdf.build(rebuilt,temp_root)
    actual=hashlib.sha256((root/'paper.pdf').read_bytes()).hexdigest(); reproduced=hashlib.sha256(rebuilt.read_bytes()).hexdigest(); assert actual==reproduced,(actual,reproduced)
    print(json.dumps({'status':'PASSED','reportNumber':'SHWRP-2026-039','version':'1.0','actualSha256':actual,'reproducedSha256':reproduced,'bitwiseMatch':True}))
finally:
    if temp_root.exists(): shutil.rmtree(temp_root)
