"""Data models for agentreflect."""

from dataclasses import dataclass, field
from typing import Optional


@dataclass
class FailureRecord:
    """A normalized failure record extracted from any input source."""

    type: str  # e.g. "AttributeError", "TimeoutError", "git-fix", "note"
    message: str
    context: str = ""
    source_file: str = ""
    line: Optional[int] = None
    raw: str = ""


@dataclass
class RuleSuggestion:
    """A suggested rule for AGENTS.md."""

    category: str  # e.g. "error-handling", "imports", "null-checks"
    text: str  # The actual rule text
    confidence: float = 0.8  # 0.0 - 1.0
    source: str = ""  # Which failure record(s) generated this

    def as_markdown_item(self) -> str:
        return f"- [ ] {self.text}"
