from __future__ import annotations

from jarvis_gateway.adapters.base import BaseAdapter
from jarvis_gateway.contracts import ModuleId
from jarvis_gateway.services.overview_service import OverviewService


class ExplodingHealthAdapter(BaseAdapter):
    module_id = ModuleId.HEALTH
    title = "HealthManager"

    def get_snapshot(self):  # type: ignore[no-untyped-def]
        raise RuntimeError("/home/agent/synthetic/health_data.db diagnosis labor")


def test_overview_stays_stable_when_health_probe_throws() -> None:
    overview = OverviewService([ExplodingHealthAdapter()]).build_overview()
    assert overview.status in {"attention", "offline", "ok"}
    assert overview.modules[0].module_id == "health"
    assert overview.modules[0].status == "degraded"
    text = overview.model_dump_json().lower()
    assert "health_data.db" not in text
    assert "/home/agent" not in text
    assert "diagnosis" not in text
    assert "labor" not in text
