"""Pin: PUBLIC_API.json MUST match the generator's output (DOC-08 / REL-03)."""

from __future__ import annotations

import json
from pathlib import Path

from tools.generate_public_api_json import build_payload  # type: ignore[import-not-found]

_JSON = Path(__file__).resolve().parents[2] / "PUBLIC_API.json"


def test_public_api_json_exists() -> None:
    assert _JSON.exists(), "PUBLIC_API.json missing — run tools/generate_public_api_json.py"


def test_public_api_json_matches_generator() -> None:
    assert json.loads(_JSON.read_text(encoding="utf-8")) == build_payload(), (
        "PUBLIC_API.json out of sync with __all__ — regenerate + commit."
    )
