import json
from datetime import datetime

progress_file = "hybrid/reviews/manual_replay_progress.json"

with open(progress_file, "r") as f:
    prog = json.load(f)

# Save backup
backup_file = f"{progress_file}.bak_{datetime.utcnow().strftime('%Y%m%dT%H%M%SZ')}"
with open(backup_file, "w") as f:
    json.dump(prog, f, indent=2)

prog["cursor"]["next_index"] = 740
prog["cursor"]["processed_count"] += 3
prog["cursor"]["rejected_count"] += 2
prog["cursor"]["needs_more_context_count"] += 1
prog["cursor"]["last_candidate_id"] = "candidate_2026-07-02T01-45-00Z_long_liquidity_sweep_reversal"
prog["cursor"]["last_updated"] = datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ')

run_entry = {
    "batch_start": 737,
    "batch_end": 739,
    "processed": 3,
    "timestamp": prog["cursor"]["last_updated"],
    "result_file": "hybrid/reviews/manual_replay_results/replay_result_00737_00740.json",
    "decisions": {
        "rejected": 2,
        "needs_more_context": 1
    }
}
prog["runs"].append(run_entry)

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

print("Cursor updated.")
