#!/usr/bin/env python3
"""Evidence-only CLOB slices, keeping the missing C start-marker boundary."""
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-s2-581-593/verify_review.py')
    assert hashlib.sha256(path.read_bytes()).hexdigest() == 'a7eb7f5e1e6e40b969f038f5e7bb32b7fb8c0db0dab4cf94b1abbfee807f1c50'
    result = json.loads(subprocess.check_output([sys.executable, '-B', str(path)]))
    assert result['offline'] and result['checks'] == 671 and result['original_checks'] == 5820
    assert result['pure_original_pipeline']['checks'] == 125
    assert result['sizes'] == [1024, 32767, 32768, 32769, 65537, 1048577]
    assert result['HTTP'] == 24 and result['real_DML'] == 12 and result['cache_only_GET']
    assert len(result['missing_C_started_raw_artifacts']) == 12 and not result['business_patch']
    subprocess.check_call(['git', '-C', str(tool.source_root('ai_api')), 'merge-base', '--is-ancestor', result['source_commit'], 'develop_dameng'])

if __name__ == '__main__':
    audit = Path(__file__).with_name('integration-20261013-long-json.json')
    assert not audit.exists(), 'Never replay main'
    report = tool.AI + 'parallel-long-json-20261013/ROOT_REVIEW.md'
    rows = [item('ai_api', method, '/terminal/setting/' + action, '', evidence=report, evidence_only=True)
            for method, action in [('POST', 'update'), ('GET', 'detail')]]
    tool.main(rows, audit, verify)
