"""Utility models for coverage system."""

from datetime import datetime
from typing import Any

from pydantic import BaseModel, Field

from ..enums import OverallStatus


class PolicyError(Exception):
    """Policy loading or validation error"""

    pass


class ValidationResult(BaseModel):
    """Policy validation result"""

    ok: bool
    errors: list[str] = Field(default_factory=list)
    warnings: list[str] = Field(default_factory=list)


class PolicyVersion(BaseModel):
    """Policy version record"""

    id: int | None = None
    version: str
    jurisdiction: str
    tax_year: str
    tenant_id: str | None = None
    source_files: list[str] = Field(default_factory=list)
    compiled_at: datetime
    hash: str


class CoverageAudit(BaseModel):
    """Coverage audit record"""

    id: int | None = None
    taxpayer_id: str
    tax_year: str
    policy_version: str
    overall_status: OverallStatus
    blocking_items: list[dict[str, Any]] = Field(default_factory=list)
    created_at: datetime = Field(default_factory=datetime.utcnow)
    trace_id: str | None = None
