#!/usr/bin/env python3
"""Device/menu read-only evidence; keep all global/representative gates open."""
import hashlib
import json
from pathlib import Path
import subprocess
import sys
import integrate_20261010 as tool

BASE=tool.STORE+'parallel-store-device-menu-next6-20261010/'
PRIVATE=['/tmp/cdx-next6-final.zxbV9E/B','/tmp/cdx-next6-final.zxbV9E/C/private-runtime']

def verify():
    r=subprocess.run([sys.executable,str(tool.ROOT/BASE/'verify_next6.py'),*PRIVATE],check=True,capture_output=True,text=True)
    r=json.loads(r.stdout)
    assert r['status']=='pass' and r['method_candidates']==6 and r['main_contract_cases_per_engine']==10
    assert r['business_dml']==r['ddl']==r['native_h7_added_method_count']==0
    assert r['dining_representative_selection_unresolved'] and not r['sql_fingerprint_gate_closed']
    subprocess.run([sys.executable,str(tool.ROOT/BASE/'test_verify_next6.py'),*PRIVATE],check=True,capture_output=True)
    for line in (tool.ROOT/BASE/'SOURCE_SHA256.txt').read_text().splitlines():
        sha,path=line.split(None,1)
        assert hashlib.sha256((tool.ROOT.parent/'zhctproject/store'/path).read_bytes()).hexdigest()==sha

def specs():
    out=[]
    for path in ['/p/equipment/read','/p/equipment/pushList','/p/equipment/getcode',
            '/api/weigh/dishes','/m/Dishes/recipe','/p/dateMenu/getStaffDiningLists']:
        item=dict(repo='store',from_repo='unreviewed',from_source='apifox-2026-05-08',method='POST',path=path,module='设备菜谱只读有界验收',terminal='PC-or-device-or-mobile-see-report',
            role='approved-private-normal-auth-context',risk='readonly-no-device-send',
            scope='store-primary-original-consumed-rows-readonly-no-new-fixtures-or-DML',evidence=BASE+'REPORT.md',
            request_type='current-controller-form',
            parity='partial-evidence-complete-per-engine-original-DTO-values-types-order-no-natural-cross-value-mapping',
            cleanup='zero-new-DML-DDL-owned-seven-rows-retained-meal4-consumed-window-stable-workers-token-cache-released',
            boundary_empty_min_max='partial-evidence-nonempty-paging-and-owned-recipe-empty-date-source-TINYINT-overflow-see-report')
        if path.endswith('getStaffDiningLists'):
            item.update(parity='partial-evidence-source-definite-fields-and-real-group-timestamp-member-TIMESTAMP0-format-only',
                boundary_empty_min_max='partial-evidence-small-department-nonempty-ALL-empty-meal1-representative-selection-undefined-open')
        out.append(item)
    for path in ['/p/date_menu/hardwareInfo','/p/dateMenu/checkMenuList']:
        out.append(dict(repo='store',method='POST',path=path,module='电子餐牌校正原生CLI增强',terminal='PC-or-device',
            role='approved-private-normal-auth-context',risk='readonly-owned-retained-chain',scope='retained-own-seven-rows-readonly',
            evidence=BASE+'REPORT.md',evidence_only=True))
    return out

if __name__=='__main__':
    audit=Path(__file__).with_name('integration-20261010-batch33.json')
    assert not audit.exists(),'Preserve original transition audit'
    tool.main(specs(),audit,verify)
