from dataclasses import dataclass, field
from typing import Dict, Any
import time


@dataclass
class Signal:
    """
    Represents a detected anomaly or rule trigger.

    Signals are generated by rules and statistical detectors when they
    detect noteworthy events in log streams.

    Attributes:
        name: Identifier for the type of signal (e.g., "keyword_match", "log_spike")
        severity: Importance level - "low", "medium", or "high"
        message: Human-readable description of what was detected
        timestamp: Unix timestamp when the signal was generated
        meta: Additional context and data about the detection
    """

    name: str
    severity: str  # low | medium | high
    message: str
    timestamp: float = field(default_factory=lambda: time.time())
    meta: Dict[str, Any] = field(default_factory=dict)
