"""
Base absorber — abstract interface for injecting knowledge into target models.
"""

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 BaseAbsorber(ABC):
    """Abstract base class for knowledge absorbers.

    Absorbers take extracted UniversalKnowledge and inject it into a target
    model, optionally training the target to replicate the source's behavior.
    """

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

    @abstractmethod
    def absorb(
        self,
        target_model: Any,
        knowledge: UniversalKnowledge,
        config: OsmosisConfig,
    ) -> Any:
        """Inject knowledge into the target model.

        Args:
            target_model: The model to inject knowledge into.
            knowledge: The extracted universal knowledge bundle.
            config: Pipeline configuration.

        Returns:
            The target model with absorbed knowledge (may be modified in-place
            or a new instance).
        """
