"""recoil.pipeline._lib.exceptions — pipeline-rooted view of canonical exceptions.

The pipeline-local ``BudgetExceededError`` is preserved here for backward
compatibility with ``pipeline/orchestrator/pipeline.py``. The canonical
Phase A.1 / Phase E family (RecoilError, SchemaValidationError,
SidecarFieldError, CrossConfigDriftError, plus all Phase E.2 additions)
is re-exported directly from ``recoil/core/exceptions.py``.

This module exists so that legacy pipeline-rooted callers that still
write a pipeline-rooted ``lib.exceptions`` import resolve to the
canonical class object rather than getting an ImportError. New code
should ``import recoil.core.exceptions`` directly.

DEPRECATED for the Phase A.1 family — callers should be moved to import
from ``recoil.core.exceptions`` directly; the re-export chain here is a
temporary compatibility shim. ``BudgetExceededError`` itself is NOT
slated for canonicalization in Phase E.
"""

from __future__ import annotations


class BudgetExceededError(Exception):
    """Raised when a generation would exceed the episode budget cap."""

    def __init__(self, current_cost: float, estimated_cost: float, budget_cap: float):
        self.current_cost = current_cost
        self.estimated_cost = estimated_cost
        self.budget_cap = budget_cap
        super().__init__(
            f"Budget exceeded: current ${current_cost:.2f} + "
            f"estimated ${estimated_cost:.2f} = ${current_cost + estimated_cost:.2f} "
            f"> cap ${budget_cap:.2f}"
        )


# Re-export the canonical Recoil exception family directly from
# recoil.core.exceptions. The former importlib-proxy mechanism (via the
# now-deleted ``_canonical_proxy.py``) is gone — production code targets
# the recoil.core path directly post-project-paths-refactor-v2.
from recoil.core.exceptions import (  # noqa: E402
    RecoilError,
    SchemaValidationError,
    SidecarFieldError,
    CrossConfigDriftError,
    # Phase C family
    CostMissingError,
    UnknownFailureEscalation,
    PayloadHintsValidationError,
    # Phase E.2 / E.6 family
    RetryExhaustedError,
    SanctionedFallbackError,
    RefDimensionUnknownError,
    MediaProbeError,
    SidecarCorruptError,
    VerdictCorruptError,
    WorkspaceStateCorruptError,
    CastingFragmentCorruptError,
    EditorialConfigCorruptError,
    RecommendationsCorruptError,
    PromptCompilerOverridesCorruptError,
    ConfigParseError,
    PromptValidatorConfigError,
    KeyframeContextLookupError,
    ExecutionStoreUnavailableError,
    VerdictAutofillError,
    ModelProfileLookupError,
)

__all__ = [
    "BudgetExceededError",
    "RecoilError",
    "SchemaValidationError",
    "SidecarFieldError",
    "CrossConfigDriftError",
    # Phase C family
    "CostMissingError",
    "UnknownFailureEscalation",
    "PayloadHintsValidationError",
    # Phase E.2 / E.6 family
    "RetryExhaustedError",
    "SanctionedFallbackError",
    "RefDimensionUnknownError",
    "MediaProbeError",
    "SidecarCorruptError",
    "VerdictCorruptError",
    "WorkspaceStateCorruptError",
    "CastingFragmentCorruptError",
    "EditorialConfigCorruptError",
    "RecommendationsCorruptError",
    "PromptCompilerOverridesCorruptError",
    "ConfigParseError",
    "PromptValidatorConfigError",
    "KeyframeContextLookupError",
    "ExecutionStoreUnavailableError",
    "VerdictAutofillError",
    "ModelProfileLookupError",
]
