"""Pydantic schema for an eval suite (``evals.json``). A suite is ``{"evals": [ ... ]}`` where each case is independently run twice (``with_skill`` / ``without_skill``) and graded against its ``assertions``. """ import json from pathlib import Path from pydantic import BaseModel, Field class EvalCase(BaseModel): """A single eval case: one prompt, its fixtures, and its graded assertions.""" name: str id: str | None = None target: str = "" prompt: str expected_output: str = "" files: list[str] = Field(default_factory=list) assertions: list[str] = Field(default_factory=list) def case_id(self) -> str: """Return the stable identifier for this case (``id`` if set, else ``name``).""" return self.id or self.name def dir_name(self) -> str: """Return the workspace subdirectory name for this case's outputs.""" cid = self.case_id() return f"eval-{cid}-{self.target}" if self.target else f"eval-{cid}" class EvalSuite(BaseModel): """The full set of eval cases loaded from ``evals.json``.""" evals: list[EvalCase] def load_suite(path: Path) -> EvalSuite: """Load and validate an eval suite from ``evals.json`` at ``path``.""" return EvalSuite.model_validate(json.loads(path.read_text()))