#!/usr/bin/env python3
"""Article and Spec business evidence; Store reads added only after independent review."""
from pathlib import Path
import subprocess
import sys
import integrate_20261010 as tool

AI = tool.AI

def verify():
    article = AI + 'parallel-ai-article-owned-20261010/'
    subprocess.run([sys.executable, str(tool.ROOT / article / 'compare.py'),
        str(tool.ROOT / article / 'evidence-B.json'), str(tool.ROOT / article / 'evidence-C.json')],
        check=True, capture_output=True)
    subprocess.run([sys.executable, str(tool.ROOT / article / 'test_compare.py')], check=True, capture_output=True)
    spec = tool.load(AI + 'parallel-ai-spec-owned-20261010/results.json')
    assert spec['scenario_pairs'] == spec['strict_equal_pairs'] == spec['wire_shape_equal_pairs'] == 10
    assert spec['nonempty_positive_pairs'] == 4 and spec['exact_get_paths'] == 2
    assert all(c['source_projection_equal_both'] and c['strict_differences'] == c['wire_shape_differences'] == 0
               for c in spec['cases'])
    for audit in spec['audit'].values():
        assert audit['natural_unchanged'] and audit['token_cleaned'] and audit['http_dml_observed'] == 0
        assert all(v == 0 for v in audit['independent_remaining'].values())
        assert audit['fixture_proof'] == {'groups': 2, 'values': 5, 'relations': 7, 'goods_rows': 0, 'store_rows': 0}

def targets():
    out = []
    for app, terminal in [('store', 'PC端'), ('terminal', '设备端')]:
        common = dict(repo='ai_api', terminal=terminal, role='isolated-owned-tenant-cache-token')
        out.append(dict(common, method='GET', path=f'/{app}/goods.Spec/list', module='商品规格关系读取', risk='read',
            scope='ai-primary-own-spec-spec-value-rel-only-no-Goods-or-Store-record',
            evidence=AI + 'parallel-ai-spec-owned-20261010/REPORT.md',
            parity='partial-evidence-ten-complete-wire-responses-equal-generated-IDs-source-verified',
            boundary_empty_min_max='partial-evidence-zero-id-and-owned-relations-cleaned-empty',
            request_type='GET-query'))
        for action in ['list', 'detail', 'add', 'edit', 'delete']:
            method = 'GET' if action in ['list', 'detail'] else 'POST'
            out.append(dict(common, method=method, path=f'/{app}/content.Article/{action}', module='文章内容',
                risk='read' if method == 'GET' else 'content-write', scope='ai-primary-own-article-category-local-file-metadata-no-file-IO',
                evidence=AI + 'parallel-ai-article-owned-20261010/REPORT.md',
                parity='partial-evidence-46-complete-wire-responses-equal-counter-not-normalized',
                boundary_empty_min_max='partial-evidence-36440-byte-content-quote-filter-empty-content-and-cover-rejection',
                duplicate_retry='partial-evidence-detail-repeat-counter-unchanged-and-repeat-soft-delete',
                request_type='GET-query' if method == 'GET' else 'JSON-or-form-see-evidence'))
    return out

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