from __future__ import annotations

import json
import os
import subprocess
import sys
from pathlib import Path


def main() -> None:
    root = Path(__file__).resolve().parent.parent
    out_path = root / "results" / "row19_results.json"
    out_path.parent.mkdir(parents=True, exist_ok=True)

    # Run the existing Row 19 script
    subprocess.check_call(
        [sys.executable, "-m", "tools.row19.run_row19"],
        cwd=str(root),
    )

    # Basic sanity check
    if not out_path.exists():
        raise FileNotFoundError(f"Expected Row 19 output not found: {out_path}")

    with open(out_path, "r", encoding="utf-8") as f:
        obj = json.load(f)

    print(obj.get("verdict", "UNKNOWN"))


if __name__ == "__main__":
    main()