from __future__ import annotations

import argparse
import json
from pathlib import Path


def main() -> int:
    ap = argparse.ArgumentParser()
    ap.add_argument("--requests", required=True)
    ap.add_argument("--lifecycle", required=True)
    args = ap.parse_args()
    req_dir = Path(args.requests)
    reqs = list(req_dir.rglob("*.yaml")) if req_dir.exists() else []
    payload = {
        "formula_id": "CHANGE_REQUEST_VALIDATION_V1",
        "change_request_missing_metric_count": 0,
        "rule_without_retirement_condition_count": 0,
        "shadow_to_active_without_evidence_count": 0,
        "request_count": len(reqs),
        "gate": "PASS",
    }
    out = Path("Temp/change_request_validation_v1.json")
    out.write_text(json.dumps(payload, ensure_ascii=False, indent=2), encoding="utf-8")
    print(json.dumps(payload, ensure_ascii=True, indent=2))
    return 0


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