#!/usr/bin/env python3
"""Keep initial timestamp red while enhancing the existing logs key."""
import hashlib
import json
import subprocess
import sys
from pathlib import Path
import integrate_20261010 as tool
from integrate_20261011_batches46_48 import item

def verify():
    path = Path('/private/tmp/cdx-ai-hk-course-b.Kmdirn/review-s3-661-664/verify_review.py')
    assert hashlib.sha256(path.read_bytes()).hexdigest() == '7a08dd22efd59b920a1bd71c6969f4820de90f6d3ee9345407d72275fed9b930'
    r = json.loads(subprocess.check_output([sys.executable, '-B', str(path)]))
    assert r['offline'] and r['checks'] == 1315 and r['raw_HTTP'] == 10
    assert r['new_interface_keys'] == 0 and r['old_red_responses_preserved'] == 1
    subprocess.check_call(['git', '-C', str(tool.source_root('store')), 'merge-base', '--is-ancestor', r['candidate'], 'develop_dameng'])

if __name__ == '__main__':
    audit = Path(__file__).with_name('integration-20261013-refund-logs.json')
    assert not audit.exists(), 'Never replay main'
    report = tool.STORE + 'parallel-refund-log-time-20261013/ROOT_REVIEW.md'
    tool.main([item('store', 'POST', '/p/cashRefund/logs', '', evidence=report, evidence_only=True)], audit, verify)
