"""Run the lab's independent checks sequentially and stop on a failure."""
from pathlib import Path
import subprocess
import sys

root = Path(__file__).resolve().parent
checks = ["check_stdio.py", "inspect_contract.py", "check_validation.py", "check_context.py", "check_transport.py"]
for filename in checks:
    result = subprocess.run([sys.executable, str(root / filename)], cwd=root, capture_output=True, text=True, encoding="utf-8", timeout=30)
    if result.returncode:
        print("FAIL:", filename)
        print(result.stdout)
        print(result.stderr, file=sys.stderr)
        raise SystemExit(result.returncode)
    print("PASS:", filename)
print("PASS: all five lab checks")
