2026-07-05 17:24:17 +02:00
|
|
|
"""Method Registry — built-in steering methods."""
|
2026-07-05 17:09:20 +02:00
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
from dataclasses import dataclass
|
|
|
|
|
|
|
|
|
|
_METHODS: dict[str, "MethodDefinition"] = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
|
|
|
class MethodDefinition:
|
|
|
|
|
key: str
|
|
|
|
|
version: str
|
2026-07-05 17:24:17 +02:00
|
|
|
label: str
|
2026-07-05 17:09:20 +02:00
|
|
|
description: str
|
|
|
|
|
default_lifecycle_steps: tuple[str, ...]
|
2026-07-05 17:24:17 +02:00
|
|
|
next_action_strategy_key: str = "default"
|
2026-07-05 17:09:20 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def register_method(defn: MethodDefinition) -> None:
|
|
|
|
|
if defn.key in _METHODS:
|
|
|
|
|
raise ValueError(f"Method already registered: {defn.key}")
|
|
|
|
|
_METHODS[defn.key] = defn
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_method(key: str) -> MethodDefinition | None:
|
|
|
|
|
return _METHODS.get(key)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def list_methods() -> tuple[MethodDefinition, ...]:
|
|
|
|
|
return tuple(_METHODS.values())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def clear_methods_for_tests() -> None:
|
|
|
|
|
_METHODS.clear()
|