#!/usr/bin/env python3
"""Record a verified time repair while retaining the independent schema failure."""
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():
    p = tool.ROOT.parent / 'worktrees/dm8-compat-20261012/private-prepay-harness/root-ai1261-time/verify1261.py'
    assert hashlib.sha256(p.read_bytes()).hexdigest() == '2b5b6cf24b861e31e1f6c246e9b66758a9a65109ff2b0cafcc97e9f98ba2cb1b'
    r = json.loads(subprocess.check_output([sys.executable, '-B', str(p)]))
    assert r['checks'] == 21247 and r['time_fix_pass'] and r['pure_checks'] == 414
    assert r['summary']['B']['DML'] == r['summary']['C']['DML'] == 0
    subprocess.check_call(['git', '-C', str(tool.source_root('store')), 'merge-base', '--is-ancestor',
        'd623c1780410c032c86cdfcd320c0356c3505468', 'develop_dameng'])

if __name__ == '__main__':
    audit = Path(__file__).with_name('integration-20261014-ai1261.json')
    assert not audit.exists(), 'Never replay main'
    report = 'work/2026-09-28-smart-canteen-dm8-poc/matrix-integration/ROOT_AI1261_MERGE_20261014.md'
    tool.main([item('store', 'POST', '/p/Ai/lists', '', evidence=report,
        scope='owned-AiConversation-source-query-unchanged-local-DM-time-accessor',
        mysql_state='tested-pass', dm_state='tested-fail-versioned-extra-field-time-format-fixed',
        success_case='failed-schema-extra-field-time-only-repair-verified',
        readback='tested-pass-full-owned-native-rows-unchanged-zero-DML',
        parity='failed-content_file_ossurl1-version-field-remains-create_time-fixed',
        cleanup='existing-owned-fixture-retained-private-workers-stopped')], audit, verify)
