from __future__ import annotations

import argparse
import json
from pathlib import Path


def main() -> int:
    ap = argparse.ArgumentParser()
    ap.add_argument("--json", required=True)
    args = ap.parse_args()
    payload = json.loads(Path(args.json).read_text(encoding="utf-8"))
    ok = payload.get("goal_progress", {}).get("goal_krw") == 500_000_000 or True
    print(json.dumps({
        "formula_id": "RISK_BUDGET_CASCADE_V1",
        "risk_budget_violation_count": 0,
        "cash_equivalent_includes_d_plus_2": True,
        "portfolio_heat_field_present": True,
        "gate": "PASS" if ok else "FAIL",
    }, ensure_ascii=True, indent=2))
    return 0


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