Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions core/orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down Expand Up @@ -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)
3 changes: 1 addition & 2 deletions core/tests/test_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading