"""Quality gate interface and result model."""

from typing import Any, Protocol

from pydantic import BaseModel, Field


class GateResult(BaseModel):
    """Result of a quality gate check.

    Attributes:
        passed: Whether the gate check passed
        message: Human-readable message describing the result
        details: Optional additional details about the result (e.g., errors, warnings)
    """

    passed: bool = Field(..., description="Whether the gate check passed")
    message: str = Field(..., description="Human-readable result message")
    details: dict[str, Any] = Field(
        default_factory=dict, description="Additional details about the result"
    )


class QualityGate(Protocol):
    """Protocol for quality gate implementations.

    All quality gates must implement this protocol to ensure consistent interface.
    """

    def check(self) -> GateResult:
        """Execute the quality gate check.

        Returns:
            GateResult: Result of the gate check with pass/fail status and details
        """
        ...
