# app/src/trading/market_intelligence/coordinator/service.py

from __future__ import annotations

from src.trading.market_intelligence.common.models import (
    CoordinatorResult,
    RuntimeResult,
)
from src.trading.market_intelligence.coordinator.protocol import CoordinatorProtocol
from src.trading.market_intelligence.coordinator.rules import CoordinatorRules
from src.trading.market_intelligence.coordinator.validation import (
    CoordinatorValidation,
)


class CoordinatorService(CoordinatorProtocol):
    """Единая публичная точка входа Coordinator Layer."""

    def __init__(self) -> None:
        """Создать Coordinator Service."""
        self._validation = CoordinatorValidation()
        self._rules = CoordinatorRules()

    async def coordinate(
        self,
        runtime_result: RuntimeResult,
    ) -> CoordinatorResult:
        """Согласовать результаты Runtime."""
        self._validation.validate(runtime_result)

        return self._rules.coordinate(runtime_result)