from __future__ import annotations

from dataclasses import dataclass
from pathlib import Path

import yaml


@dataclass(slots=True, frozen=True)
class DocsGoldenCase:
    case_id: str
    query: str
    expected_intent: str
    expected_sub_intent: str
    expected_layers: tuple[str, ...]
    rows: tuple[dict, ...]


def load_cases(path: Path) -> list[DocsGoldenCase]:
    payload = yaml.safe_load(path.read_text(encoding="utf-8")) or {}
    items = payload.get("cases") or []
    return [
        DocsGoldenCase(
            case_id=str(item["id"]),
            query=str(item["query"]),
            expected_intent=str(item["expected_intent"]),
            expected_sub_intent=str(item["expected_sub_intent"]),
            expected_layers=tuple(item.get("expected_layers") or ()),
            rows=tuple(item.get("rows") or ()),
        )
        for item in items
    ]
