"""Schemas for plan generation and rule engine."""
from typing import Optional, Any
from pydantic import BaseModel, Field


class ParameterInfo(BaseModel):
    """Information about a scannable parameter."""
    name: str
    display_name: str
    unit: str
    category: str
    default_start: float
    default_stop: float
    default_step: float
    min_allowed: float
    max_allowed: float
    description: str = ""
    topology_supported: list[str] = Field(default_factory=list)


class ParameterRegistryResponse(BaseModel):
    """Response containing all scannable parameters."""
    total: int
    parameters: list[ParameterInfo]


class RangeRecommendation(BaseModel):
    """Recommended scan range for a parameter."""
    start: float
    stop: float
    step: float
    notes: str = ""


class RangeRecommendRequest(BaseModel):
    """Request for range recommendation."""
    parameter_name: str
    boundary_conditions: dict[str, Any] = Field(default_factory=dict)


class PlanGenerateRequest(BaseModel):
    """Request to generate a plan from boundary conditions."""
    boundary_conditions: dict[str, Any] = Field(default_factory=dict)
    parameter_names: Optional[list[str]] = None
    model_path: str = ""


class PlanGenerateResponse(BaseModel):
    """Response containing a generated plan draft."""
    name: str
    model_path: str
    topology: str
    variables: list[dict[str, Any]]
    cases: list[dict[str, Any]] = Field(default_factory=list)
    estimated_points: int
    estimated_time_min: float
    generation_summary: dict[str, Any] = Field(default_factory=dict)
