"""Translate service evidence into normalized protocol labels."""

from __future__ import annotations

from sentra.models.artifacts import ServiceEvidence


def infer_protocols(services: list[ServiceEvidence]) -> list[str]:
    detected: set[str] = set()
    for service in services:
        normalized = service.service.lower()
        if normalized in {"http", "https"}:
            detected.add("web")
        elif normalized in {"mqtt", "coap", "modbus", "rtsp", "ssh", "telnet"}:
            detected.add(normalized)
        else:
            detected.add(service.protocol.lower())
    return sorted(detected)

