"""
ProofVerdict: Common verdict type for all verifiers.
"""

from __future__ import annotations

from dataclasses import dataclass
from enum import Enum
from typing import Optional


class VerdictStatus(str, Enum):
    """Verification result status."""
    OK = "ok"
    FAIL = "fail"
    SKIPPED = "skipped"


@dataclass(frozen=True)
class ProofVerdict:
    """
    Result of verifying a single proof.

    Attributes:
        status: ok, fail, or skipped
        kind: The proof kind that was verified
        reason: Explanation (especially for failures)
        details: Optional additional context
    """
    status: VerdictStatus
    kind: str
    reason: Optional[str] = None
    details: Optional[dict] = None

    @classmethod
    def ok(cls, kind: str, reason: Optional[str] = None) -> "ProofVerdict":
        """Create a successful verdict."""
        return cls(status=VerdictStatus.OK, kind=kind, reason=reason)

    @classmethod
    def fail(cls, kind: str, reason: str, details: Optional[dict] = None) -> "ProofVerdict":
        """Create a failed verdict."""
        return cls(status=VerdictStatus.FAIL, kind=kind, reason=reason, details=details)

    @classmethod
    def skipped(cls, kind: str, reason: str) -> "ProofVerdict":
        """Create a skipped verdict."""
        return cls(status=VerdictStatus.SKIPPED, kind=kind, reason=reason)

    @property
    def is_ok(self) -> bool:
        return self.status == VerdictStatus.OK

    @property
    def is_fail(self) -> bool:
        return self.status == VerdictStatus.FAIL

    def to_dict(self) -> dict:
        """Convert to dictionary for JSON output."""
        result = {
            "status": self.status.value,
            "kind": self.kind,
        }
        if self.reason:
            result["reason"] = self.reason
        if self.details:
            result["details"] = self.details
        return result
