"""Verify trusted source identity and exact test count before reporting a reproduction."""
from pathlib import Path
import hashlib,json,sys,unittest
R=Path(__file__).resolve().parent
EXPECTED={'bounded_arithmetic.py': 'd0ef0f53bfefe1fa0c05284a4dec03de7e246a2d5e7307861328d1e4d625c8d5', 'test_bounded_arithmetic.py': '61e631aeb8b3735f4eaf011749a7ac3abaa0e435107133275fd68f78fea5f34e'}
for name,digest in EXPECTED.items():
 if hashlib.sha256((R/name).read_bytes()).hexdigest()!=digest:raise SystemExit('SOURCE_MISMATCH:'+name)
manifest=json.loads((R/'MANIFEST.json').read_text())
for name,record in manifest['files'].items():
 path=(R/name).resolve()
 if not path.is_relative_to(R):raise SystemExit('UNSAFE_MANIFEST_PATH')
 if hashlib.sha256(path.read_bytes()).hexdigest()!=record['sha256']:raise SystemExit('ARTIFACT_MISMATCH:'+name)
sys.path.insert(0,str(R))
suite=unittest.defaultTestLoader.loadTestsFromName('test_bounded_arithmetic')
if suite.countTestCases()!=20:raise SystemExit('TEST_COUNT_MISMATCH')
result=unittest.TextTestRunner(verbosity=2).run(suite)
if not result.wasSuccessful() or result.testsRun!=20:raise SystemExit(1)
print('PASS: 20 actual calculator test methods; manifest verified. Browser subset: node test_calculator.mjs')
