"""Validated training sample type. A TrainingSample that exists is valid — all invariants are checked at construction time. Downstream code can serialize without re-checking. """ from __future__ import annotations import json import os from dataclasses import dataclass from typing import Any from evals.prompts import GENERAL_DIMS from evals.physics_criteria import ALL_LAWS ALLOWED_KEYS: frozenset[str] = frozenset(GENERAL_DIMS) | frozenset(ALL_LAWS) def _resolve_path(video_path: str, base_dir: str | None) -> str: if base_dir and not os.path.isabs(video_path): video_path = os.path.join(base_dir, video_path) return os.path.normpath(video_path) @dataclass(frozen=True) class TrainingSample: system: str user: str assistant: str video_path: str def __post_init__(self) -> None: errors: list[str] = [] if not self.system: errors.append("empty system prompt") if not self.user: errors.append("empty user prompt") if not self.assistant: errors.append("empty assistant response") video_count = self.user.count("