"""AP-10 / AP-11 — PUBLIC_API.md MUST list every public ``__all__`` name."""

from __future__ import annotations

import importlib
from pathlib import Path

_MODS = (
    "mgf.fastapi",
    "mgf.fastapi.exceptions",
    "mgf.fastapi.webhooks",
    "mgf.fastapi.security",
    "mgf.fastapi.db",
    "mgf.fastapi.testing",
    "mgf.fastapi.logs",
)


def test_public_api_md_lists_every_all_name() -> None:
    md = (Path(__file__).resolve().parents[2] / "PUBLIC_API.md").read_text(encoding="utf-8")
    missing = []
    for m in _MODS:
        for n in getattr(importlib.import_module(m), "__all__", []):
            if n == "__version__":
                continue
            if n not in md:
                missing.append(f"{m}.{n}")
    assert not missing, f"PUBLIC_API.md missing public names (AP-10): {missing}"
