#!/usr/bin/env python3
"""Real refund-application/rejection state changes, not a payment acceptance claim."""
from pathlib import Path
import subprocess
import sys
import integrate_20261010 as tool
E = tool.STORE + 'parallel-store-refund-reject-state-20261010/'

def verify():
    subprocess.run([sys.executable, str(tool.ROOT / E / 'compare.py')], check=True, capture_output=True)
    for lane in ['B', 'C']:
        r = tool.load(E + 'result-' + lane + '.json')
        assert len(r['cases']) == 6 and len(r['wallet_source_before']) == 10
        a = tool.load(E + 'independent-audit-' + lane + '.json')
        assert a['all_passed'] and a['independent_new_connections'] and a['database_writes'] == 0
        assert all(n == 0 for n in a['remaining_owned_rows'].values())
        assert all(x['same_before'] for x in a['wallet_sources'].values())
    for r in tool.load(E + 'cleanup.json').values():
        assert r['worker_stopped'] and r['port_not_listening'] and r['private_lease_released']
        assert r['private_cache_files_remaining'] == r['private_runtime_files_remaining'] == 0

def targets():
    out = []
    for action in ['refund', 'refundReject']:
        item = dict(repo='store', method='POST', path='/p/mealOrder/' + action,
            module='订单申请退款与驳回', terminal='PC端', role='private-admin-owned-paid-state-fixture',
            risk='refund-state-write', scope='store-primary-own-order-refund-audit-stall-both-business-wallets-readonly',
            evidence=E + 'REPORT.md', request_type='application/x-www-form-urlencoded',
            parity='partial-evidence-six-real-write-chain-plus-positive-absent-ID-read-full-wire-equal',
            duplicate_retry='partial-evidence-real-private-File-repeat-guard-and-status-refusal-after-own-key-clear',
            boundary_empty_min_max='partial-evidence-owned-0.01-paid-state-fixture-not-real-payment-or-refund-credit')
        if action == 'refundReject':
            item.update(from_repo='unreviewed', from_source='apifox-2026-05-08')
        out.append(item)
    return out

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