from __future__ import annotations

import argparse
import json
from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]


def main() -> int:
    ap = argparse.ArgumentParser()
    ap.add_argument("--out", default="Temp/pass_100_criteria_v4.json")
    args = ap.parse_args()
    src = ROOT / "Temp" / "pass_100_criteria_v3.json"
    payload = json.loads(src.read_text(encoding="utf-8")) if src.exists() else {}
    if not isinstance(payload, dict):
        payload = {}
    payload["formula_id"] = "PASS_100_CRITERIA_V4"
    payload["pass_100_allowed"] = False
    payload["hts_order_mode"] = "THEORETICAL_ONLY"
    payload["execution_ambiguity_count"] = 0
    out = ROOT / args.out
    out.parent.mkdir(parents=True, exist_ok=True)
    out.write_text(json.dumps(payload, ensure_ascii=False, indent=2), encoding="utf-8")
    print(json.dumps({"formula_id": payload["formula_id"], "pass_100_allowed": payload["pass_100_allowed"]}, ensure_ascii=True))
    return 0


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