"""Shared types for the metrics provider abstraction."""

from __future__ import annotations

from dataclasses import dataclass
from typing import Protocol


@dataclass(frozen=True)
class MemorySnapshot:
    used_bytes: int
    total_bytes: int
    percent: float


@dataclass(frozen=True)
class ProcessSnapshot:
    cpu_percent: float  # normalized to 0–100% across all cores
    rss_bytes: int


@dataclass(frozen=True)
class ThermalSnapshot:
    """Battery + thermal readings; every field is optional.

    Different platforms expose different subsets of these — desktops
    rarely have a battery temp, headless servers rarely report any
    thermal zone, and stock Android often locks down everything except
    the battery node. ``None`` means "not available", *not* "zero".
    """

    battery_percent: float | None = None
    battery_temp_c: float | None = None
    cpu_temp_c: float | None = None  # max across all thermal zones


class MetricsProvider(Protocol):
    """Read-only host + current-process metrics."""

    available: bool

    def cpu_percent(self) -> float: ...
    def cpu_count(self) -> int: ...
    def virtual_memory(self) -> MemorySnapshot: ...
    def process_snapshot(self) -> ProcessSnapshot: ...
    def thermals(self) -> ThermalSnapshot: ...
