diff --git a/logsight/enterprise.py b/logsight/enterprise.py index ceab760..a3adc8f 100644 --- a/logsight/enterprise.py +++ b/logsight/enterprise.py @@ -110,7 +110,9 @@ class AnomalyScore: def score_event(event: EnrichedLog, recent: list[EnrichedLog]) -> AnomalyScore: """Combine frequency and structural signals into a deterministic score.""" template = event.template or extract_template(event.message) - same = sum(1 for item in recent if (item.template or extract_template(item.message)) == template) + same = sum( + 1 for item in recent if (item.template or extract_template(item.message)) == template + ) error_rate = sum(item.level in {"ERROR", "CRITICAL"} for item in recent) / max(len(recent), 1) rarity = 1.0 / (same + 1) severity = 1.0 if event.level in {"ERROR", "CRITICAL"} else 0.0 diff --git a/logsight/storage.py b/logsight/storage.py index a22329e..5c1ca5b 100644 --- a/logsight/storage.py +++ b/logsight/storage.py @@ -36,7 +36,9 @@ def insert_events(self, events: list[dict[str, Any]]) -> None: class QdrantStore: - def __init__(self, base_url: str = "http://localhost:6333", collection: str = "logsight") -> None: + def __init__( + self, base_url: str = "http://localhost:6333", collection: str = "logsight" + ) -> None: self.base_url = base_url.rstrip("/") self.collection = collection diff --git a/tests/test_enterprise.py b/tests/test_enterprise.py index 0b65d71..0305840 100644 --- a/tests/test_enterprise.py +++ b/tests/test_enterprise.py @@ -1,6 +1,12 @@ """Tests for enterprise observability primitives.""" -from logsight.enterprise import WebhookNotifier, enrich, extract_template, score_event, semantic_features +from logsight.enterprise import ( + WebhookNotifier, + enrich, + extract_template, + score_event, + semantic_features, +) from logsight.parser import parse_line