"""# Summary Family registry — resolve a ``(kind, variant, mode)`` triple to a root class. A single lookup replaces hand-rolled ``if/else`` family selection. """ from typing import Dict, Type # Populated by ``register`` as families import. _FAMILIES: Dict[str, Dict[str, Dict[str, Type]]] = {} def register(kind: str, variant: str, root_cls: Type, mode: str = "default") -> Type: """Register ``root_cls`` for a ``(kind, variant, mode)`` triple. Returns: Type: The registered class (so it can be used as a decorator). """ _FAMILIES.setdefault(kind, {}).setdefault(variant, {})[mode] = root_cls return root_cls def resolve_root(kind: str, variant: str, mode: str = "default") -> Type: """Return the root class for a ``(kind, variant, mode)`` triple. Raises: KeyError: When no family matches the triple. """ return _FAMILIES[kind][variant][mode]