File size: 4,283 Bytes
ba4b555
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
"""Master Automated Verification Suite Runner for Privacy-Preserving Cross-Bank Fraud Detection Platform.

Discovers and executes reference verifications, Hypothesis property tests,
adversarial robustness tests, and scalability benchmarks across all 21 verified subsystems.
"""

from __future__ import annotations

import logging
import subprocess
import sys
import time
from pathlib import Path

logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(message)s")
logger = logging.getLogger(__name__)

REPO_ROOT = Path(__file__).resolve().parent.parent
VERIFICATION_DIR = REPO_ROOT / "verification"


def run_all_verifications() -> bool:
    subsystems = sorted([
        d for d in VERIFICATION_DIR.iterdir()
        if d.is_dir() and not d.name.startswith((".", "__")) and ((d / "tests").is_dir() or any(d.glob("test_*.py")))
    ])
    total_dirs = len([d for d in VERIFICATION_DIR.iterdir() if d.is_dir() and not d.name.startswith((".", "__"))])

    logger.info("==========================================================================")
    logger.info("STARTING MASTER SCIENTIFIC VERIFICATION SUITE ACROSS %d VERIFIED SUBSYSTEMS", len(subsystems))
    logger.info("==========================================================================")
    logger.info(
        "Discovered %d verified subsystem directories (out of %d total entries in verification/).",
        len(subsystems),
        total_dirs,
    )

    start_time = time.perf_counter()
    overall_success = True

    # Step 1: Run reference verification runners
    logger.info("\n--- Phase 1: Running Reference Verification Scripts ---")
    ref_scripts = sorted(list(VERIFICATION_DIR.glob("**/tests/*_reference_verification.py")))
    logger.info("Discovered %d reference verification scripts.", len(ref_scripts))
    for script in ref_scripts:
        logger.info("Executing reference script: %s", script.name)
        res = subprocess.run([sys.executable, str(script)], cwd=REPO_ROOT, capture_output=True, text=True)
        if res.returncode != 0:
            logger.error("FAILED reference script %s:\nSTDOUT:\n%s\nSTDERR:\n%s", script.name, res.stdout, res.stderr)
            overall_success = False

    # Step 2: Run benchmark scripts
    logger.info("\n--- Phase 2: Running Scalability Benchmark Scripts ---")
    bench_scripts = sorted(list(VERIFICATION_DIR.glob("**/tests/*_benchmark_scalability.py")))
    logger.info("Discovered %d benchmark scalability scripts.", len(bench_scripts))
    for script in bench_scripts:
        logger.info("Executing benchmark script: %s", script.name)
        res = subprocess.run([sys.executable, str(script)], cwd=REPO_ROOT, capture_output=True, text=True)
        if res.returncode != 0:
            logger.error("FAILED benchmark script %s:\nSTDOUT:\n%s\nSTDERR:\n%s", script.name, res.stdout, res.stderr)
            overall_success = False

    # Step 3: Run full pytest suite across verification/
    logger.info("\n--- Phase 3: Executing Pytest Verification Suite ---")
    pytest_res = subprocess.run([sys.executable, "-m", "pytest", "verification/", "-v"], cwd=REPO_ROOT, capture_output=True, text=True)
    logger.info("Pytest Suite Output Summary:\n%s", pytest_res.stdout.splitlines()[-1] if pytest_res.stdout else "")

    if pytest_res.returncode != 0:
        logger.error("Pytest suite reported failures:\n%s", pytest_res.stdout)
        if pytest_res.stderr:
            logger.error("Pytest stderr:\n%s", pytest_res.stderr)
        overall_success = False

    elapsed = time.perf_counter() - start_time
    logger.info("\n==========================================================================")
    if overall_success:
        logger.info("✅ ALL %d SUBSYSTEM VERIFICATION SUITES PASSED IN %.2f SECONDS!", len(subsystems), elapsed)
    else:
        logger.error("❌ VERIFICATION SUITE ENCOUNTERED FAILURES.")
    logger.info("==========================================================================")

    return overall_success


if __name__ == "__main__":
    import argparse

    parser = argparse.ArgumentParser(
        description="Master Automated Verification Suite Runner across verified subsystems."
    )
    parser.parse_args()
    success = run_all_verifications()
    sys.exit(0 if success else 1)