"""Architect error hierarchy."""

from __future__ import annotations


class ArchitectError(Exception):
    """Base exception for all architect errors."""


class PlanningError(ArchitectError):
    """Architect planning phase failed to produce a valid phase DAG."""


class PhaseExecutionError(ArchitectError):
    """A phase failed during execution."""

    def __init__(self, phase_id: str, message: str | None = None) -> None:
        self.phase_id = phase_id
        super().__init__(message or f"Phase '{phase_id}' failed during execution")


class BudgetExhaustedError(ArchitectError):
    """Total architect budget has been exhausted."""

    def __init__(self, spent: float, limit: float, message: str | None = None) -> None:
        self.spent = spent
        self.limit = limit
        super().__init__(message or f"Budget exhausted: ${spent:.2f} spent, limit ${limit:.2f}")


class CircuitBreakerError(ArchitectError):
    """Too many consecutive phase failures."""

    def __init__(self, failures: int, threshold: int) -> None:
        self.failures = failures
        self.threshold = threshold
        super().__init__(
            f"Circuit breaker tripped: {failures} consecutive failures (threshold: {threshold})"
        )
