#!/usr/bin/env python3
"""StaffWeight: four new positive keys, two read enhancements, one shared error."""
from pathlib import Path
import subprocess
import sys
import integrate_20261010 as tool

E = tool.AI + 'parallel-ai-store-staff-weight-crud-20261010/'

def verify():
    subprocess.run([sys.executable, str(tool.ROOT / E / 'compare.py')], check=True, capture_output=True)
    subprocess.run([sys.executable, str(tool.ROOT / E / 'test_compare.py')], check=True, capture_output=True)
    cleanup = tool.load(E + 'resource-cleanup.json')
    for lane, port in [('B', 18321), ('C', 18322)]:
        retained = tool.load(E + 'retention-' + lane + '.json')
        assert retained['read_only'] and retained['business_dml'] == 0
        assert retained['ownership_each_original_row_verified'] and retained['all_money_fields_zero']
        assert retained['weight_real_soft_rows'] == retained['weight_read_active_rows'] == 3
        assert retained['current_recommend_rows'] == 1 and retained['history_rows'] == 8
        assert cleanup[lane]['token_absent'] and cleanup[lane]['private_cache_files'] == 0
        assert cleanup[lane][f'port_{port}_listening'] is False
    assert cleanup['large_output_full_table_sha_claimed'] is False
    assert cleanup['real_queue_or_notify_network_called'] is False

def targets():
    out = []
    for action in ['detail', 'add', 'edit', 'delete', 'list', 'echartsList', 'all']:
        target = dict(repo='ai_api', method='POST', path='/store/weight.StaffWeight/' + action,
            module='体重管理及内部推荐计算', terminal='PC端', role='private-synthetic-positive-user-staff-owned-tenant',
            risk='read' if action in ['detail', 'list', 'echartsList', 'all'] else 'weight-write',
            scope='ai-primary-own-weight-staff-recommend-history-real-Serve-job-no-queue-or-network',
            evidence=E + 'REPORT.md', request_type='POST-form-query-id-see-current-PC-contract',
            parity='partial-evidence-21-HTTP-pairs-full-source-verified-types-values-order-owned-ID-and-auto-time-mapped',
            cleanup='retained-owned-user-staff-six-weight-one-current-eight-history-funds-zero-credentials-workers-released')
        if action in ['list', 'echartsList']:
            target['boundary_empty_min_max'] = 'partial-evidence-nonempty-three-consecutive-dates-BETWEEN-inclusive-and-single-bound'
        if action == 'add':
            target['duplicate_retry'] = 'partial-evidence-original-duplicate-add-creates-distinct-generated-string-ID'
            target['boundary_empty_min_max'] = 'partial-evidence-three-decimal-rounding-and-original-forced-current-date-energy-rule'
        if action == 'delete':
            target['duplicate_retry'] = 'partial-evidence-real-soft-delete-latest-fallback-last-zero-and-repeat-refusal'
        if action == 'all':
            target.update(mysql_state='tested-fail-shared-original-missing-name-column',
                dm_state='tested-fail-shared-original-missing-name-column',
                success_case='tested-fail-shared-original-schema-not-positive',
                readback='tested-fail-both-schemas-missing-name-source-select-confirmed',
                mysql_readback='tested-fail-no-positive-result-missing-name-column',
                dm_readback='tested-fail-no-positive-result-missing-name-column',
                parity='tested-fail-shared-original-business-error-not-a-DM-only-difference')
        out.append(target)
    return out

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