# #region HealthSchemas [C:3] [TYPE Module] [SEMANTICS pydantic, health, schema, dashboard, dashboard-health-item]
# @BRIEF Pydantic schemas for dashboard health summary — includes v2 LLM validation fields.
# @LAYER Domain
# @RELATION DEPENDS_ON -> [EXT:Library:pydantic]

from datetime import datetime
from typing import Any

from pydantic import BaseModel, Field


# #region DashboardHealthItem [TYPE Class]
# @BRIEF Represents the latest health status of a single dashboard, with v2 LLM validation data.
class DashboardHealthItem(BaseModel):
    record_id: str | None = None
    dashboard_id: str
    dashboard_slug: str | None = None
    dashboard_title: str | None = None
    environment_id: str
    status: str = Field(..., pattern="^(PASS|WARN|FAIL|UNKNOWN)$")
    last_check: datetime
    task_id: str | None = None
    run_id: str | None = None
    policy_id: str | None = None
    summary: str | None = None
    # v2 LLM validation fields
    execution_path: str | None = None  # "screenshot" or "text_only"
    issues_count: int = 0
    timings: dict[str, Any] | None = None
    token_usage: dict[str, Any] | None = None
    screenshot_paths: list[str] | None = None
    chunk_count: int | None = None
    dashboard_name: str | None = None  # human-readable alias for dashboard_title


# #endregion DashboardHealthItem


# #region HealthSummaryResponse [TYPE Class]
# @BRIEF Aggregated health summary for all dashboards.
class HealthSummaryResponse(BaseModel):
    items: list[DashboardHealthItem]
    pass_count: int
    warn_count: int
    fail_count: int
    unknown_count: int


# #endregion HealthSummaryResponse

# #endregion HealthSchemas
