"""Domain status -> UI state name. Lives here rather than in yksa-web-kit because it is a property of the data, not of the presentation: a model exposes ``ui_state`` and the template renders it. The visual vocabulary — which icon and word each state gets — is the web kit's half, in ``yksa_web.states``. """ from __future__ import annotations #: Every service's RunStatus-like TextChoices overlaps by value, so one table #: covers them all. _HEALTH = { "ok": "ok", "success": "ok", "partial": "warning", "warning": "warning", "failed": "failed", "error": "failed", "running": "running", "pending": "running", "queued": "running", "skipped": "skipped", } def health_state(value: str | None) -> str: """A value absent from the table renders as ``unknown`` rather than blank — a status the reader can see beats one that silently disappears.""" return _HEALTH.get((value or "").lower(), "unknown")