from __future__ import annotations

from dataclasses import asdict, dataclass, field
from typing import Any, Dict, List, Optional


VERDICTS = {"implemented", "partial", "missing", "conflict", "uncertain"}


@dataclass
class RequirementSnapshot:
    requirement_uid: str
    title: str
    description: str
    acceptance_criteria: List[str] = field(default_factory=list)
    requirement_type: Optional[str] = None
    section_title: Optional[str] = None
    interface_name: Optional[str] = None
    interface_type: Optional[str] = None
    data_source: Optional[str] = None
    data_destination: Optional[str] = None

    def to_dict(self) -> Dict[str, Any]:
        return asdict(self)


@dataclass
class ConsistencyResultItem:
    requirement_uid: str
    requirement_title: str
    requirement_type: Optional[str]
    requirement_text: str
    verdict: str
    coverage_score: float
    confidence: float
    matched_functions: List[Dict[str, Any]]
    covered_points: List[str] = field(default_factory=list)
    missing_points: List[str] = field(default_factory=list)
    conflict_points: List[str] = field(default_factory=list)
    call_chain_evidence: List[str] = field(default_factory=list)
    suggestion: str = ""
    raw_judgment: Dict[str, Any] = field(default_factory=dict)

    def to_dict(self) -> Dict[str, Any]:
        return asdict(self)

