diff --git a/core/orchestrator.py b/core/orchestrator.py index e0429cf..5fdec1b 100644 --- a/core/orchestrator.py +++ b/core/orchestrator.py @@ -12,8 +12,8 @@ # Move to Postgres/Redis if you run multiple workers or need durability. _DEDUP_WINDOW_S = float(os.getenv("SENTINEL_DEDUP_WINDOW_S", "300")) _DEDUP_THRESHOLD = int(os.getenv("SENTINEL_DEDUP_THRESHOLD", "1")) # Nth hit in window fires -_recent_alerts: dict[str, list[float]] = defaultdict(list) # signature -> hit times -_open_signatures: dict[str, str] = {} # signature -> live incident_id +_recent_alerts: dict[str, list[float]] = defaultdict(list) # signature -> hit times +_open_signatures: dict[str, str] = {} # signature -> live incident_id def _dedup_gate(signature: str) -> tuple[str, str | None]: @@ -132,7 +132,9 @@ def resolve_incident(incident_id: str) -> dict: ) print(f"[orchestrator] {incident_id} -- postmortem LLM unavailable, degrading: {e}") db.update_postmortem(incident_id, draft) - _clear_signature((incident.get("trigger_data") or {}).get("error_signature", "")) # resolved: reopen to new alerts + _clear_signature( + (incident.get("trigger_data") or {}).get("error_signature", "") + ) # resolved: reopen to new alerts print(f"[orchestrator] {incident_id} -> resolved, postmortem generated") print(f"[metrics] {incident_id} resolve_to_postmortem_s={time.monotonic() - t0:.1f}") return db.get_incident(incident_id) diff --git a/core/tests/test_orchestrator.py b/core/tests/test_orchestrator.py index 646fb07..2f16d97 100644 --- a/core/tests/test_orchestrator.py +++ b/core/tests/test_orchestrator.py @@ -49,8 +49,7 @@ def test_dedup_folds_repeat_alerts(): def test_dedup_threshold_suppresses_below_burst(): """With a threshold >1, alerts below the burst count are suppressed, not opened.""" _reset_dedup() - with patch.object(orch, "_DEDUP_THRESHOLD", 3), \ - patch("core.orchestrator.db.save_incident") as mock_save: + with patch.object(orch, "_DEDUP_THRESHOLD", 3), patch("core.orchestrator.db.save_incident") as mock_save: r1 = handle_alert(_ALERT) r2 = handle_alert(_ALERT) r3 = handle_alert(_ALERT)