from __future__ import annotations

import argparse
from pathlib import Path

import yaml


EXPECTED = [
    "data_quality",
    "portfolio_health",
    "cash",
    "heat",
    "stop_tp",
    "anti_chase",
    "regime",
    "sector_beta",
    "style",
    "sizing",
    "execution",
]


def main() -> int:
    parser = argparse.ArgumentParser()
    parser.add_argument("--graph", required=True)
    parser.add_argument("--strict", action="store_true")
    args = parser.parse_args()
    graph = yaml.safe_load(Path(args.graph).read_text(encoding="utf-8"))
    nodes = [n["id"] for n in graph.get("nodes", [])]
    errors: list[str] = []
    if nodes != EXPECTED:
        errors.append("node order mismatch")
    if len(graph.get("edges", [])) != len(EXPECTED) - 1:
        errors.append("edge count mismatch")
    if errors:
        print("FAIL")
        for e in errors:
            print(e)
        return 1
    print("DECISION_GRAPH_OK")
    return 0


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

