from __future__ import annotations

import argparse
import json
from pathlib import Path


def main() -> int:
    parser = argparse.ArgumentParser()
    parser.add_argument("--strict", action="store_true")
    args = parser.parse_args()
    packet = json.loads(Path("Temp/final_decision_packet_active.json").read_text(encoding="utf-8"))
    errors: list[str] = []
    if packet.get("formula_id") != "FINAL_DECISION_PACKET_V4":
        errors.append("formula_id mismatch")
    if "shadow_ledger" not in packet:
        errors.append("shadow_ledger missing")
    if packet.get("provenance_summary", {}).get("ungrounded_number_count") != 0:
        errors.append("ungrounded numbers present")
    if errors:
        print("FAIL")
        for e in errors:
            print(e)
        return 1
    print("FINAL_DECISION_PACKET_OK")
    return 0


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