Kairo-Jinkendo/backend/steering/strategies/next_action/registry.py

36 lines
841 B
Python
Raw Normal View History

"""NextAction strategy registry — AP1.1."""
from __future__ import annotations
from typing import Any, Protocol
from tenant_context import TenantContext
_STRATEGIES: dict[str, "NextActionStrategy"] = {}
class NextActionStrategy(Protocol):
key: str
def evaluate(
self,
ctx: TenantContext,
*,
initiative_id: str | None = None,
limit: int = 10,
) -> list[dict[str, Any]]: ...
def register_next_action_strategy(strategy: NextActionStrategy) -> None:
if strategy.key in _STRATEGIES:
raise ValueError(f"NextAction strategy already registered: {strategy.key}")
_STRATEGIES[strategy.key] = strategy
def get_next_action_strategy(key: str) -> NextActionStrategy | None:
return _STRATEGIES.get(key)
def clear_strategies_for_tests() -> None:
_STRATEGIES.clear()