"""Pydantic schemas for session handoffs."""
from __future__ import annotations
from typing import Any
from uuid import UUID
from datetime import datetime
from pydantic import BaseModel, Field


class HandoffCreateRequest(BaseModel):
    intent: str = Field(..., pattern="^(park|escalate)$")
    engineer_notes: str | None = None
    priority: str = Field("normal", pattern="^(normal|elevated)$")


class HandoffResponse(BaseModel):
    id: UUID
    session_id: UUID
    handed_off_by: UUID
    intent: str
    source_branch_id: UUID | None
    snapshot: dict[str, Any]
    ai_assessment: str | None
    ai_assessment_data: dict[str, Any] | None
    artifacts: list[dict[str, Any]] | None
    engineer_notes: str | None
    priority: str
    claimed_by: UUID | None
    claimed_at: datetime | None
    psa_note_pushed: bool
    notification_sent: bool
    created_at: datetime
    model_config = {"from_attributes": True}


class HandoffClaimRequest(BaseModel):
    pass


class HandoffBriefingResponse(BaseModel):
    briefing: str
    handoff: HandoffResponse


class QueueItemResponse(BaseModel):
    handoff_id: UUID
    session_id: UUID
    intent: str
    problem_summary: str | None
    problem_domain: str | None
    priority: str
    handed_off_by_name: str | None
    engineer_notes: str | None
    branch_count: int = 0
    created_at: datetime
    claimed_by: UUID | None
    claimed_at: datetime | None
    model_config = {"from_attributes": True}
