import json
from datetime import datetime, timezone

prog_path = '/home/aryy/.hermes/profiles/finance/backtests/xauusd_2026/hybrid/reviews/manual_replay_progress.json'
with open(prog_path) as f:
    prog = json.load(f)

with open('/home/aryy/.hermes/profiles/finance/backtests/xauusd_2026/hybrid/reviews/manual_replay_results/replay_result_00792_00795.json') as f:
    results = json.load(f)

for r in results:
    prog['cursor']['processed_count'] += 1
    prog['cursor']['next_index'] += 1
    prog['cursor']['last_candidate_id'] = r['candidate_id']
    dec = r['decision']
    if dec == 'accepted':
        prog['cursor']['accepted_count'] += 1
    elif dec == 'rejected':
        prog['cursor']['rejected_count'] += 1
    elif dec == 'shadow':
        prog['cursor']['shadow_count'] += 1
    elif dec == 'needs_more_context':
        prog['cursor']['needs_more_context_count'] += 1

prog['cursor']['last_updated'] = datetime.now(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')

with open(prog_path, 'w') as f:
    json.dump(prog, f, indent=2)

print("Cursor updated.")
