#!/usr/bin/env python3
"""Habit/RPE: six first business paths plus two genuinely strengthened old reads."""
from pathlib import Path
import subprocess
import sys
import integrate_20261010 as tool

EVIDENCE = tool.AI + 'parallel-ai-habit-settings-20261010/'

def verify():
    result = subprocess.run([sys.executable, str(tool.ROOT / EVIDENCE / 'compare.py'),
        str(tool.ROOT / EVIDENCE / 'evidence-B.json'), str(tool.ROOT / EVIDENCE / 'evidence-C.json')],
        check=True, capture_output=True)
    subprocess.run([sys.executable, str(tool.ROOT / EVIDENCE / 'test_compare.py')], check=True, capture_output=True)
    for lane in ['B', 'C']:
        r = tool.load(EVIDENCE + 'evidence-' + lane + '.json')
        assert r['case_count'] == 28 and r['error'] is None and not r['real_queue_or_staff_power_executed']
        assert len(r['queue_captures']) == 3 and all(e['owned_parameters_valid'] and not e['real_queue_executed']
                                                    for e in r['queue_captures'])
        assert all(count == 0 for count in r['cleanup']['fresh_pdo_owned_rows'].values())
        assert r['cleanup']['natural_tables_and_enum_unchanged'] and r['cleanup']['tokens_absent']

def targets():
    out = []
    for app, terminal in [('store', 'PC端'), ('terminal', '设备端')]:
        for action in ['detail', 'setHabit', 'detailRpe', 'setRpe']:
            out.append(dict(repo='ai_api', method='POST', path=f'/{app}/store.Habit/{action}',
                module='人员习惯与训练RPE', terminal=terminal, role='isolated-own-staff-tenant-cache-token',
                risk='read' if action.startswith('detail') else 'staff-health-write',
                scope='ai-primary-own-staff-habit-rpe-header-items-Serve-queue-captured-not-executed',
                evidence=EVIDENCE + 'REPORT.md', request_type='application/json-numeric-client-identifiers',
                parity='partial-evidence-28-complete-wire-responses-equal-original-table-readback',
                boundary_empty_min_max='partial-evidence-default-choice-two-future-dates-missing-and-overlap-rejection',
                duplicate_retry='partial-evidence-habit-repeat-and-first-day-RPE-replacement-second-day-unchanged'))
    return out

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