"""Audit actual recorded local simulation outcomes; never grants live clearance."""
from data_paths import default_db_path
import argparse
import json
from ledger_reporting import read_snapshot, performance, Rejected

class WeekendOneQuantAuditor:
    def __init__(self,db_filepath=str(default_db_path('foresixa_day1_v2_fixture.db'))):
        self.db_filepath=db_filepath
    def compile_weekend_performance_metrics(self):
        snapshot=read_snapshot(self.db_filepath)
        rows=snapshot['dispositions']
        tags=sorted({r['execution_tag'] for r in rows}|{'Phase1-Crypto-Sandbox','Phase1-Futures-Sandbox'})
        return {'status':'REVIEW_REQUIRED_LIVE_DISABLED','observed_at':snapshot['observed_at'],
            'data_origin':snapshot['data_origin'],'metrics':performance(rows),
            'workers':{tag:performance([r for r in rows if r['execution_tag']==tag]) for tag in tags},
            'details':rows,'equity':snapshot['equity'],'cash':snapshot['cash'],
            'open_market_value':snapshot['open_market_value'],'trial_started':False,
            'verified_trial_days':0,'go_live_approved':False,
            'limitations':['Synthetic tests are not a verified market trial','No futures execution adapter','Economic PnL is separate from tax adjustments']}
    def close(self):pass

def main():
    parser=argparse.ArgumentParser(description=__doc__)
    parser.add_argument('--db-path',default=str(default_db_path('foresixa_day1_v2_fixture.db')));args=parser.parse_args()
    try:
        print(json.dumps(WeekendOneQuantAuditor(args.db_path).compile_weekend_performance_metrics(),indent=2));return 0
    except Rejected as exc:
        print(json.dumps({'status':'AUDIT_BLOCKED','reason':str(exc)}));return 1
if __name__=='__main__':raise SystemExit(main())
