"""
Base grower — abstract interface for dynamic architecture expansion.
"""

from __future__ import annotations

from abc import ABC, abstractmethod
from typing import Any

from model_osmosis.core.config import OsmosisConfig
from model_osmosis.knowledge.representation import UniversalKnowledge


class BaseGrower(ABC):
    """Abstract base class for model architecture growers.

    Growers dynamically expand a model's architecture to accommodate
    incoming knowledge from another model.
    """

    @abstractmethod
    def can_handle(self, model: Any) -> bool:
        """Return True if this grower can expand the given model type."""

    @abstractmethod
    def grow(
        self,
        model: Any,
        knowledge: UniversalKnowledge,
        config: OsmosisConfig,
    ) -> Any:
        """Expand the model's architecture to accommodate the incoming knowledge.

        The growth must be **function-preserving**: the grown model should
        produce the same outputs as the original model before growth.

        Args:
            model: The model to expand.
            knowledge: The knowledge that needs to be absorbed (used to
                determine how much growth is needed).
            config: Pipeline configuration.

        Returns:
            The grown model (may be a new instance or modified in-place).
        """
