from __future__ import annotations

from datetime import datetime, timedelta, timezone

DEFAULT_TIER_PROBE_TTL_HOURS = 24.0


def probe_is_fresh_at(
    last_probe_at: str | None,
    *,
    ttl_hours: float = DEFAULT_TIER_PROBE_TTL_HOURS,
) -> bool:
    if not last_probe_at or ttl_hours <= 0:
        return False
    try:
        at = datetime.fromisoformat(str(last_probe_at).replace("Z", "+00:00"))
    except ValueError:
        return False
    return at >= datetime.now(timezone.utc) - timedelta(hours=ttl_hours)
