"""Pluggable discovery module contracts and result containers."""

from __future__ import annotations

from dataclasses import dataclass, field
from pathlib import Path
from threading import Lock
from typing import Protocol

from sentra.discovery.session import ScanCache
from sentra.models import DiscoveryProviderRecord, PassiveObservation, ServiceEvidence


@dataclass(frozen=True)
class DiscoveryModuleContext:
    host: str
    ports: list[int]
    timeout: float
    cache: ScanCache
    cache_lock: Lock | None = None
    workspace: Path | None = None


@dataclass(frozen=True)
class HostDiscoveryResult:
    services: list[ServiceEvidence] = field(default_factory=list)
    cache_hits: int = 0
    providers: list[DiscoveryProviderRecord] = field(default_factory=list)
    passive_observations: list[PassiveObservation] = field(default_factory=list)


class DiscoveryModule(Protocol):
    name: str

    def scan_host(self, context: DiscoveryModuleContext) -> HostDiscoveryResult:
        """Return deterministic discovery results for a single host."""

