#!/usr/bin/env python3 """Unattended evidence-capture dispatcher for WBV2-P1424-001. It emits concrete commands from the behavior contracts. Execution is opt-in via --execute; default mode only writes a reproducible handoff manifest. """ import argparse, json, pathlib, subprocess, sys, shutil, os TASK='WBV2-P1424-001'; ROOT=pathlib.Path(__file__).resolve().parents[2] CONTRACT=ROOT/'tests/golden'/TASK/'behavior-contracts.json'; OUT=ROOT/'tests/golden'/TASK/'evidence-capture-handoff.json' def main(): p=argparse.ArgumentParser(); p.add_argument('--execute',action='store_true'); a=p.parse_args() chrome = os.environ.get('CHROME_PATH') or shutil.which('google-chrome') or shutil.which('google-chrome-stable') cs=json.loads(CONTRACT.read_text())['contracts']; steps=[] for c in cs: steps.append({'module':c['module'],'commands':[c['positive']['command'],c['negative']['command']],'runner':'Chromium + native WebEngine/WASM','status':'NOT_RUN'}) hand={'schemaVersion':1,'task':TASK,'status':'READY_FOR_EXECUTION' if chrome else 'BLOCKED_CHROMIUM_MISSING','execute':a.execute,'runner':{'browser':'Chromium','executablePath':chrome,'config':'web/playwright.config.ts'},'steps':steps} if a.execute and not chrome: hand['error']='No Chromium executable found; install or expose CHROME_PATH.' OUT.write_text(json.dumps(hand,indent=2,ensure_ascii=False)+'\n') return 0 if __name__=='__main__': sys.exit(main())