"""Simulation result schemas."""
from datetime import datetime
from typing import Any
from pydantic import BaseModel, Field


class ResultCreate(BaseModel):
    run_index: int = 0
    status: str = "OK"
    solve_time_s: float = 0.0
    params: dict[str, Any] = Field(default_factory=dict)
    metrics: dict[str, Any] = Field(default_factory=dict)
    error_message: str = ""


class ResultBatchCreate(BaseModel):
    """Batch upload results from scan_results.csv."""
    results: list[ResultCreate]


class ResultResponse(BaseModel):
    id: int
    plan_id: int
    run_index: int
    status: str
    solve_time_s: float
    params: dict[str, Any]
    metrics: dict[str, Any]
    error_message: str
    created_at: datetime

    class Config:
        from_attributes = True


class ResultListResponse(BaseModel):
    total: int
    items: list[ResultResponse]
