"""Typed structures and constants for SWE-bench ingestion."""

from __future__ import annotations

from dataclasses import dataclass
from typing import Optional

PASS_FAIL_METRIC = "pass_fail"


@dataclass(frozen=True, slots=True)
class SWEbenchExample:
    """Represents a SWE-bench instance with enough fields to build prompts."""

    task_id: str
    problem_statement: str
    hints_text: Optional[str] = None
    repo: str = ""
    instance_id: str = ""
    base_commit: str = ""
    fail_to_pass: Optional[str] = None
    pass_to_pass: Optional[str] = None

    @property
    def task_description(self) -> str:
        """Short task description used for embeddings."""
        parts: list[str] = []
        if self.repo:
            parts.append(self.repo.strip())
        if self.problem_statement:
            parts.append(self.problem_statement.strip())
        if self.hints_text:
            parts.append(f"Hints: {self.hints_text.strip()}")
        return " | ".join(parts)


@dataclass(frozen=True, slots=True)
class SWEbenchResult:
    """Captures one model's attempt on a SWE-bench example."""

    example: SWEbenchExample
    llm_name: str
    prompt: str
    response: str
    pass_rate: float
    latency_seconds: float = 0.0
    cost_usd: float = 0.0
