"""
Analyzer plugin interface (Alpha Terminal - Diligence).

Each analyzer contributes items to one or more quadrants:
authority | market | risk | value
"""

from __future__ import annotations

from dataclasses import dataclass
from datetime import datetime
from typing import Protocol

from sqlalchemy.ext.asyncio import AsyncSession

from app.schemas.analyze import AnalyzeItem
from app.services.domain_checker import DomainCheckResult


@dataclass(frozen=True)
class AnalyzeContext:
    db: AsyncSession
    domain: str
    computed_at: datetime
    fast: bool
    check: DomainCheckResult
    health: object | None  # DomainHealthReport or None (kept as object to avoid import cycles)


@dataclass(frozen=True)
class AnalyzerContribution:
    quadrant: str  # authority|market|risk|value
    items: list[AnalyzeItem]


class Analyzer(Protocol):
    key: str
    ttl_seconds: int

    async def analyze(self, ctx: AnalyzeContext) -> list[AnalyzerContribution]: ...

