"""Bootstrap healthcheck callable.

Used by both `companion-tier1` and `operator-tooling` Dockerfiles via
`HEALTHCHECK CMD python -m gps_denied_onboard.healthcheck`. Returns a non-zero exit
code on any failure so Docker's healthcheck loop marks the container unhealthy.

AC-6 (Bootstrap / AZ-263): this module must be importable and runnable.
"""

from __future__ import annotations

import sys


def check() -> int:
    """Quick liveness check: all foundation packages must be importable.

    Returns 0 on success, non-zero exit code on failure.
    """
    try:
        import gps_denied_onboard  # noqa: F401
        from gps_denied_onboard import _types  # noqa: F401
        from gps_denied_onboard._types import (  # noqa: F401
            calibration,
            emitted,
            inference,
            manifests,
            matching,
            nav,
            pose,
            tile,
            vpr,
        )
        from gps_denied_onboard.logging import get_logger  # noqa: F401
    except ImportError as exc:
        print(f"healthcheck: ImportError: {exc}", file=sys.stderr)
        return 1
    return 0


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