"""Explicit ScopeWrit failure classes."""


class ScopeWritError(Exception):
    """Base class for expected product errors."""


class ManifestError(ScopeWritError):
    """A scope manifest is invalid or not trusted."""


class SignatureError(ScopeWritError):
    """A signature or signed token is invalid."""


class ReplayError(ScopeWritError):
    """A run, approval, or action ticket was replayed."""


class StateError(ScopeWritError):
    """Durable run state violates an invariant."""


class ResourceError(ScopeWritError):
    """A resource identifier is ambiguous or unsafe."""


class LedgerError(ScopeWritError):
    """The flight recorder is malformed or tampered with."""


class GatewayError(ScopeWritError):
    """An execution adapter could not complete a guarded action."""

    def __init__(self, message: str, *, decision: object | None = None):
        super().__init__(message)
        self.decision = decision
