#!/usr/bin/env python3
"""Evidence-only enhancement of two existing menu keys; no new API counts."""
import hashlib
import json
import subprocess
import sys
from pathlib import Path
import integrate_20261010 as tool
from integrate_20261011_batches46_48 import item

HERE = Path(__file__).resolve().parent
REVIEW = Path('/private/tmp/cdx-ai-hk-course-b.Kmdirn/review-s1-324-329/verify_review.py')
REV = '9fde7a6212686be96eb698b433afbe52d98efbc5'
REPORT = tool.STORE + 'parallel-menu-fractions-20261013/ROOT_REVIEW.md'


def verify():
    assert hashlib.sha256(REVIEW.read_bytes()).hexdigest() == 'ced72440f56500c0342d63908dfb81766468adcada8ce1ed1f0b2e6820f39204'
    result = json.loads(subprocess.check_output([sys.executable, '-B', str(REVIEW)]))
    assert result['verified_bounded_evidence'] and result['checks'] == 1828
    assert result['original_verifier']['checks'] == 2917 and result['actual_final_helper']['checks'] == 233
    assert result['original_business_HTTP_artifacts'] == 37
    for path, digest in result['final_source_pins'].items():
        data = subprocess.check_output(['git', '-C', str(tool.source_root('store')), 'show', REV + ':' + path])
        assert hashlib.sha256(data).hexdigest() == digest
    subprocess.check_call(['git', '-C', str(tool.source_root('store')), 'merge-base', '--is-ancestor', REV, 'develop_dameng'])


if __name__ == '__main__':
    audit = HERE / 'integration-20261013-menu-fractions.json'
    assert not audit.exists(), 'Never replay main'
    tool.main([item('store', 'POST', '/p/datemenu/' + action, '', evidence=REPORT, evidence_only=True)
               for action in ['editMenu', 'getMenuInfo']], audit, verify)
