#!/usr/bin/env python3
"""Real Store owner resolution; camel aliases do not create extra entries."""
import json
from pathlib import Path
import subprocess
import sys
import integrate_20261010 as tool

EVIDENCE = tool.STORE + 'parallel-store-mobile-readonly3-20261010/'

def verify():
    result = subprocess.run([sys.executable, str(tool.ROOT / EVIDENCE / 'compare.py')],
        check=True, capture_output=True, text=True)
    summary = json.loads(result.stdout)
    assert summary['unique_method_keys'] == 6 and summary['partial_compatible_keys'] == 5
    assert summary['explicit_contract_failure_keys'] == 1 and summary['open_schema_field'] == 'bank_user_name'
    assert summary['mysql_same_path_wire_bodies_unchanged'] == 8
    assert not summary['aliases_counted_as_extra_interfaces'] and not summary['cross_database_full_values_equal_claimed']
    cleanup = tool.load(EVIDENCE + 'cleanup.json')
    assert cleanup['cross_phase_B_full_source_digest_equal'] is False
    assert cleanup['cross_phase_B_digest_difference_pending'] is True
    lanes = {row['lane']: row for row in cleanup['lanes']}
    assert set(lanes) == {'B', 'C'}
    for row in lanes.values():
        assert row['worker_stopped'] and row['port_not_listening']
        assert row['private_cache_files_remaining'] == 0 and row['selected_source_unchanged']

def targets():
    out = []
    common = dict(repo='store', terminal='PC-or-mobile-see-report', role='isolated-approved-natural-readonly-auth',
        risk='read', scope='store-primary-readonly-source-projection-no-money-or-device-mutation',
        evidence=EVIDENCE + 'REPORT.md', from_repo='unreviewed', from_source='apifox-2026-05-08')
    for action in ['list', 'detail']:
        extra = dict(parity='partial-evidence-source-values-and-selected-full-wire-types-equal-decimal-red-green')
        if action == 'detail':
            extra.update(dm_state='tested-fail-schema-contract-missing-bank-user-name',
                parity='tested-fail-one-wire-key-bank-user-name-missing-after-decimal-repair',
                boundary_empty_min_max='partial-evidence-missing-order-error-camel-source-path-tested')
        out.append(dict(common, method='GET', path='/api/order/' + action, module='移动订单读取',
            request_type='GET-query', **extra))
    for action in ['restaurantList', 'restaurantDetail', 'restaurantOptions', 'stallOptions']:
        out.append(dict(common, method='POST', path='/api/dining_config/' + action, module='餐厅档口读取',
            request_type='application/json',
            parity='partial-evidence-source-verified-full-wire-types-and-per-engine-tree-values-equal'))
    return out

if __name__ == '__main__':
    tool.main(targets(), Path(__file__).with_name('integration-20261010-batch4.json'), verify)
