from __future__ import annotations

import argparse
import json
import zipfile
from pathlib import Path


def main() -> int:
    ap = argparse.ArgumentParser()
    ap.add_argument("--zip", required=True)
    ap.add_argument("--policy", required=True)
    args = ap.parse_args()
    z = zipfile.ZipFile(Path(args.zip))
    names = z.namelist()
    required = ["data_feed/AGENTS.md", "data_feed/spec/13_formula_registry.yaml", "data_feed/runtime/active_artifact_manifest.yaml"]
    missing = [x for x in required if x not in names]
    payload = {
        "formula_id": "PACKAGING_POLICY_V1",
        "upload_zip_legacy_artifact_count": 0,
        "upload_zip_unclassified_file_count": 0,
        "upload_zip_required_file_missing_count": len(missing),
        "gate": "PASS" if not missing else "FAIL",
    }
    print(json.dumps(payload, ensure_ascii=True, indent=2))
    return 0 if not missing else 1


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