"""Pydantic data models shared across the pipeline.""" from __future__ import annotations from typing import Optional from pydantic import BaseModel, Field class Job(BaseModel): """A synthetic task (freelance job description or math problem).""" id: str category: str complexity: str # easy | medium | hard complexity_score: float # ground-truth intrinsic complexity in [0, 1] title: str description: str requirements: list[str] # canonical acceptance criteria (invariant under T) # cosmetic attributes that perturbations may alter without changing requirements cosmetic: dict[str, str] = Field(default_factory=dict) class Twin(BaseModel): """A meaning-preserving perturbation of a base job.""" id: str base_id: str operator: str # which perturbation operator produced this twin description: str requirements: list[str] invariance_ok: bool = True # passed the requirement-invariance check invariance_reason: str = "" class LabeledPair(BaseModel): """Training target: measured degradation between a base job and a twin. ``delta_per_model`` maps model name -> Y(J) - Y(T(J)); ``delta_mean`` is the measured contrast Delta(J,T) used as the contrast-head target. ``d_obs`` is the observed average difficulty D_avg (ex-ante head target); ``d_wc`` is the observed worst-case difficulty D_wc (ex-ante head target). """ base_id: str twin_id: str operator: str category: str complexity: str complexity_score: float base_text: str twin_text: str delta_per_model: dict[str, float] = Field(default_factory=dict) delta_mean: float = 0.0 d_obs: float = 0.0 # job-level D_avg target for the ex-ante head d_wc: float = 0.0 # job-level D_wc target for the ex-ante head y_base_mean: float = 0.0 # judge score on the base job (for score-predictor baseline) day: Optional[int] = None dose: Optional[int] = None # number of composed perturbation ops in this twin (paper's m); None if unknown/unset