"""Debug attempt domain model."""

from datetime import datetime

from pydantic import BaseModel, ConfigDict, Field


class DebugAttempt(BaseModel):
    """Domain model for a debug attempt.

    Represents a single attempt to fix a build error using the AutoDebugAgent.
    """

    model_config = ConfigDict(from_attributes=True, arbitrary_types_allowed=True)

    id: int | None = Field(None, description="Unique identifier")
    plan_id: int = Field(..., description="Plan being debugged")
    error_message: str = Field(..., description="Error message that triggered debug")
    attempted_fix: str | None = Field(None, description="Fix that was attempted")
    success: bool = Field(False, description="Whether the fix was successful")
    attempt_number: int = Field(..., description="Attempt number (1-based)")
    created_at: datetime = Field(
        default_factory=datetime.now, description="When attempt was made"
    )
