"""EB1-GNN Preview Server.

This module implements an OpenAI-compatible server for the GNN-based EB1 routing
models: eb1-preview (TieredRouter) and eb1-delta-preview (EB1Conductor).

Architecture:
    The server uses a protocol-first design where embeddings and GNN inference
    are abstracted behind protocols. This enables:
    1. Single-process deployment (current): GNN + embeddings + execution
    2. Microservice deployment (future): Split services for independent scaling

    Key design (Issue #11 fix): EmbeddedRouter wraps TieredRouter and REQUIRES
    an EmbeddingProvider at construction. This makes it impossible to use the
    wrong embeddings (Dean's principle: make wrong thing impossible).

Endpoints:
    POST /v1/chat/completions  - Main inference (route + execute)
    GET  /v1/models            - List available models
    GET  /healthz              - Health check for systemd

Example:
    # Start server
    python -m ember.eb1_gnn.server --port 8082 --registry-path /path/to/gnn

    # Make request
    curl -X POST http://localhost:8082/v1/chat/completions \\
        -H "Content-Type: application/json" \\
        -d '{"model": "eb1-preview", "messages": [{"role": "user", "content": "Hi"}]}'
"""

from ember.eb1_gnn.executor import execute_model, execute_streaming
from ember.eb1_gnn.handlers import handle_eb1_delta_preview, handle_eb1_preview
from ember.eb1_gnn.routing import EmbeddedRouter, EmbeddingProvider
from ember.eb1_gnn.server import (
    MODEL_EB1_DELTA_PREVIEW,
    MODEL_EB1_PREVIEW,
    ServerConfig,
    ServerState,
    create_app,
    run_server,
)

__all__ = [
    # Server
    "create_app",
    "run_server",
    "ServerConfig",
    "ServerState",
    # Routing
    "EmbeddedRouter",
    "EmbeddingProvider",
    # Model IDs
    "MODEL_EB1_PREVIEW",
    "MODEL_EB1_DELTA_PREVIEW",
    # Handlers
    "handle_eb1_preview",
    "handle_eb1_delta_preview",
    # Executor
    "execute_model",
    "execute_streaming",
]
