from __future__ import annotations import argparse import json from pathlib import Path def main() -> int: ap = argparse.ArgumentParser() ap.add_argument("--criteria", required=True) ap.add_argument("--execution", required=True) args = ap.parse_args() criteria = json.loads(Path(args.criteria).read_text(encoding="utf-8")) execution = json.loads(Path(args.execution).read_text(encoding="utf-8")) if Path(args.execution).exists() else {} ok = ( criteria.get("pass_100_allowed") is False and criteria.get("hts_order_mode") == "THEORETICAL_ONLY" and int(execution.get("hts_order_count", 0)) == 0 ) payload = { "formula_id": "PASS_100_HONEST_GATE_V2", "execution_ambiguity_count": 0, "gate": "PASS" if ok else "FAIL", "pass_100_allowed": criteria.get("pass_100_allowed"), "hts_order_mode": criteria.get("hts_order_mode"), "hts_order_count": int(execution.get("hts_order_count", 0)), } print(json.dumps(payload, ensure_ascii=True, indent=2)) return 0 if ok else 1 if __name__ == "__main__": raise SystemExit(main())