import json
import os
from datetime import datetime, timezone

progress_path = "/home/aryy/.hermes/profiles/finance/backtests/xauusd_2026/hybrid/reviews/manual_replay_progress.json"

with open(progress_path, 'r') as f:
    progress = json.load(f)

# Update cursor
progress['cursor']['next_index'] = 508
progress['cursor']['processed_count'] = 508
progress['cursor']['rejected_count'] += 2
progress['cursor']['needs_more_context_count'] += 1
progress['cursor']['last_candidate_id'] = "candidate_2026-04-15T04-45-00Z_long_liquidity_sweep_reversal"
progress['cursor']['last_updated'] = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")

# Update run
run = progress['runs'][0]
run['result_files'].append("hybrid/reviews/manual_replay_results/replay_result_00505_00508.json")
run['decision_counts']['rejected'] += 2
run['decision_counts']['needs_more_context'] += 1

# Save atomic backup
import shutil
shutil.copy2(progress_path, progress_path + f".bak_{datetime.now().strftime('%Y%m%dT%H%M%SZ')}")

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

print(f"Updated cursor to 508")
