#!/usr/bin/env python3
"""Intake one observed GET's empty and owned metadata results, no image fetch."""
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/review-expert1541/verify_independent.py'
    assert hashlib.sha256(p.read_bytes()).hexdigest() == 'f4f58e96242229ef8ecc5ab30e4eac53c8bbb7c7036a138772ec3cb7b7ca90f1'
    r = json.loads(subprocess.check_output([sys.executable, '-B', str(p)]))
    assert r['passed'] and r['checks'] == 7234 and r['sealed_assets'] == 155
    assert r['new_SQL_HTTP_business_CLI'] == r['image_downloads'] == r['health_HTTP'] == 0
    assert r['metadata_I_each_side'] == 1

if __name__ == '__main__':
    audit = Path(__file__).with_name('integration-20261014-expert1541.json')
    assert not audit.exists(), 'Never replay main'
    report = 'work/2026-09-28-smart-canteen-dm8-poc/matrix-integration/ROOT_EXPERT1541_ACCEPTANCE_20261014.md'
    tool.main([item('ai_api', 'GET', '/api/expert.qrcode/get', '', evidence=report,
        scope='original-default-dispatch-bound-owned-Store-empty-and-one-Qrcode-metadata-row',
        success_case='partial-evidence-owned-nonempty-original-GET-URL-metadata-only',
        boundary_empty_min_max='partial-evidence-original-empty-then-one-owned-row-no-multiple-sort-proof',
        readback='tested-pass-full-Qrcode3-native-types-Store18-unchanged-four-empty-associations',
        parity='partial-evidence-full-raw-identical-except-trace-Chinese-URL-escaping-preserved',
        cleanup='one-owned-metadata-row-retained-no-URL-fetch-old-Store-unchanged-worker-stopped')], audit, verify)
