"""Contract validation helpers.""" from __future__ import annotations from pvr_eval.core.schema import EvalContract def validate_contract(contract: EvalContract) -> None: if not contract.case_id: raise ValueError("contract.case_id is required") if not contract.atomic_checks: raise ValueError(f"contract {contract.case_id!r} has no atomic checks") seen: set[str] = set() for check in contract.atomic_checks: if check.check_id in seen: raise ValueError(f"duplicate atomic check id {check.check_id!r} in {contract.case_id}") seen.add(check.check_id) if check.weight < 0: raise ValueError(f"atomic check {check.check_id!r} has negative weight") if not check.checker: raise ValueError(f"atomic check {check.check_id!r} has no checker")