#!/usr/bin/env python3
"""Verify an isolated challenger-versus-Leo runtime report."""

from __future__ import annotations

import argparse
import json
from pathlib import Path

try:
    from leo_agent_challenger_protocol import verify_file
except ImportError:  # pragma: no cover - imported as scripts.* in tests
    from scripts.leo_agent_challenger_protocol import verify_file


def main() -> int:
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("--report", required=True, type=Path)
    parser.add_argument("--output", required=True, type=Path)
    args = parser.parse_args()
    receipt = verify_file(args.report)
    args.output.parent.mkdir(parents=True, exist_ok=True)
    args.output.write_text(json.dumps(receipt, indent=2, sort_keys=True) + "\n", encoding="utf-8")
    print(json.dumps({"output": str(args.output), "status": receipt["status"]}, sort_keys=True))
    return 0 if receipt["status"] == "pass" else 1


if __name__ == "__main__":
    raise SystemExit(main())
