"""Stub file for deploy directory."""
from typing import Any, Callable

from .contracts import ModelBundle, RouteRegistry, RuntimeRoute
from .runtime_resolver import normalize_runtime, resolve_runtime_framework
from .server import start_deploy_server
from .status_handler import DeployStatusReporter, safe_log_error

# Constants
RouteRegistry: Any = ...  # From contracts
RuntimeLoader: Any = ...  # From contracts
RuntimePredictor: Any = ...  # From contracts

# Functions
# From bootstrap
def build_cli_main() -> Callable[[str, int], None]:
    """
    Create a `main(action_id, port)` function for project deploy scripts.
    """
    ...

# From bootstrap
def default_action_tracker_factory(action_id: str) -> Any:
    """
    Create ActionTracker lazily to avoid hard dependency at import time.
    """
    ...

# From bootstrap
def run_deploy() -> Any:
    """
    Run common deploy bootstrap and start server.
    """
    ...

# From bootstrap
def run_main_and_exit() -> None:
    """
    Entry-point helper mirroring existing deploy script behavior.
    """
    ...

# From bootstrap
def run_main_from_argv(argv: list[str]) -> None:
    """
    Standard CLI argument parsing for deploy scripts.
    """
    ...

# From framework_router
def build_router_functions(router: Any) -> tuple[Callable[[Any], Any], Callable[[Any, Any], Any]]:
    """
    Build `(load_model, predict)` callables compatible with deploy servers.
    
        The returned callables can be passed directly to `MatriceDeploy`.
    """
    ...

# From framework_router
def make_routes(route_map: Any[str, tuple[Callable[[Any], Any], Callable[[Any, Any], Any]]]) -> dict[str, Any]:
    """
    Convenience helper to build `RuntimeRoute` objects from tuple map.
    """
    ...

# From runtime_resolver
def normalize_runtime(runtime_framework: str | None) -> str:
    """
    Normalize runtime labels to canonical route keys.
    """
    ...

# From runtime_resolver
def resolve_runtime_framework(action_tracker: Any) -> str:
    """
    Resolve runtime from multiple ActionTracker-compatible locations.
    """
    ...

# From server
def create_deploy_server() -> Any:
    """
    Create deploy server instance from backend type or custom factory.
    """
    ...

# From server
def start_deploy_server() -> Any:
    """
    Create and start deploy server using either `.start_server()` or `.start()`.
    """
    ...

# From status_handler
def safe_log_error(action_tracker: Any, file_path: str, location: str, message: str) -> None:
    """
    Best-effort tracker error logging.
    """
    ...

# From status_handler
def safe_update_status(action_tracker: Any, step_code: str, status: str, description: str) -> None:
    """
    Best-effort status update that never raises to caller.
    """
    ...

# Classes
# From bootstrap
class DeployBootstrapConfig:
    # Configuration for deploy bootstrap behavior.

    ...

# From contracts
class ActionTrackerProtocol:
    # Minimal ActionTracker surface consumed by deploy helpers.

    def log_error(self: Any, file_path: str, module: str, message: str) -> None:
        """
        Record an error event in the platform tracker.
        """
        ...

    def update_status(self: Any, step_code: str, status: str, description: str) -> None:
        """
        Publish a lifecycle status update to the platform tracker.
        """
        ...


# From contracts
class ModelBundle:
    # Loaded model bundle passed between deploy load/predict phases.

    ...

# From contracts
class RuntimeRoute:
    # Runtime-specific load and predict handlers.

    ...

# From framework_router
class FrameworkRouter:
    # Router that dispatches load/predict handlers by runtime key.

    def __init__(self: Any, routes: Any) -> None:
        """
        Initialize the router with runtime handlers and fallback behavior.
        """
        ...

    def load_model(self: Any, action_tracker: Any, runtime_framework: str | None = None) -> Any:
        """
        Load model using runtime route with optional fallback on load failure.
        """
        ...

    def predict(self: Any, bundle: Any, input_bytes: Any) -> Any:
        """
        Run runtime-specific predict handler for a loaded bundle.
        """
        ...

    def supported_runtimes(self: Any) -> tuple[str, ...]:
        """
        Return registered runtime keys.
        """
        ...


# From status_handler
class DeployStatusCodes:
    # Canonical deployment status step codes.

    ...

# From status_handler
class DeployStatusReporter:
    # Semantic status reporter for deploy lifecycle transitions.

    def __init__(self: Any, action_tracker: Any, codes: Any | None = None) -> None:
        """
        Create a reporter backed by an ActionTracker-like object.
        """
        ...

    def acknowledged(self: Any, msg: str = 'Model Deployment has been acknowledged') -> None:
        """
        Emit deployment-acknowledged status.
        """
        ...

    def failed(self: Any, msg: str) -> None:
        """
        Emit deployment-failed status with error context.
        """
        ...

    def model_ready(self: Any, msg: str = 'Model loaded for deployment') -> None:
        """
        Emit model-ready status after loading succeeds.
        """
        ...

    def started(self: Any, msg: str = 'Model deployment started') -> None:
        """
        Emit deployment-started status after server boot.
        """
        ...


from . import bootstrap, contracts, framework_router, runtime_resolver, server, status_handler