#!/usr/bin/env python3
"""One main-row positive and one missing-record limited result, no full approval claim."""
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-workflow1561/verify_independent.py'
    assert hashlib.sha256(p.read_bytes()).hexdigest() == 'd630d307500c63edf11cef9bd8fd42d48a84bea54875b5c35685fa867ea280c0'
    r = json.loads(subprocess.check_output([sys.executable, '-B', str(p)]))
    assert r['passed'] and r['independent_checks'] == 4457 and r['author_checks_executed'] == 2392
    assert r['sealed_assets'] == 528 and r['new_SQL_HTTP_remote_PHP'] == r['author_writes'] == 0

if __name__ == '__main__':
    audit = Path(__file__).with_name('integration-20261014-workflow1561.json')
    assert not audit.exists(), 'Never replay main'
    report = 'work/2026-09-28-smart-canteen-dm8-poc/matrix-integration/ROOT_WORKFLOW1561_ACCEPTANCE_20261014.md'
    specs = []
    for action in ('getWorkFlow', 'info'):
        limited = action == 'info'
        specs.append(item('store', 'POST', '/m/WorkFlow/' + action, '', evidence=report,
            from_repo='unreviewed', from_source='apifox-2026-05-08',
            scope='own-disabled-workflow-main-row-empty-nodes-and-exact-missing-form-only',
            mysql_state='partial-evidence-missing-record-only' if limited else 'tested-pass',
            dm_state='partial-evidence-missing-record-only' if limited else 'tested-pass',
            success_case='not-tested-nonempty-detail-only-missing-return' if limited else 'partial-evidence-real-main-row-empty-node-original-POST',
            readback='tested-pass-workflow7-actor6-config6x2-identity-enum-and-empty-reference-counts-unchanged',
            parity='partial-evidence-complete-original-DTO-typed-ID-trace-only-mapping-no-approval-flow',
            cleanup='one-disabled-preparation-row-retained-own-worker-stopped-no-replay'))
    tool.main(specs, audit, verify)
