from pathlib import Path
import subprocess, sys, json, hashlib
ROOT=Path(__file__).resolve().parent; WS=ROOT/'workspace'; EVID=ROOT/'evidence/prior_verification.json'
setup=subprocess.run([sys.executable,'setup_fixture.py'],cwd=ROOT,text=True,capture_output=True)
if setup.returncode: print(setup.stdout); print(setup.stderr,file=sys.stderr); raise SystemExit(setup.returncode)
def run(args): return subprocess.run(args,cwd=WS,text=True,capture_output=True,check=True).stdout.strip()
status=run(['git','status','--porcelain=v1','--untracked-files=all']).splitlines()
checks=[]
checks.append(('BRANCH_PRESENT',run(['git','branch','--show-current'])=='feature/coupon-audit'))
checks.append(('HEAD_PRESENT',len(run(['git','rev-parse','HEAD']))==40))
checks.append(('THREE_VISIBLE_DELTAS',len(status)==3))
checks.append(('PRIOR_REPORT_PRESENT',EVID.exists()))
checks.append(('NO_NETWORK_REQUIRED',True))
for name,ok in checks: print(name,'PASS' if ok else 'FAIL')
raise SystemExit(0 if all(ok for _,ok in checks) else 1)
