feat(dispatcher): bypass cooldown for immediate-severity events

Events with severity=immediate skip the per-toggle cooldown check
entirely — they are already rate-controlled by source handler change
detection. Also set cooldown_seconds default to 0 (disabled).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Matt Johnson (via Claude) 2026-06-07 16:57:21 +00:00
commit d305ce65d7
2 changed files with 7 additions and 2 deletions

View file

@ -543,7 +543,7 @@ class NotificationToggle:
severity_channels: dict = field(default_factory=dict) severity_channels: dict = field(default_factory=dict)
# v0.5.2: staleness drop + per-toggle cooldown (Matt's spam fix) # v0.5.2: staleness drop + per-toggle cooldown (Matt's spam fix)
freshness_seconds: int = 600 # drop events older than this at dispatcher entrance freshness_seconds: int = 600 # drop events older than this at dispatcher entrance
cooldown_seconds: int = 300 # per (toggle, category, region) throttle window cooldown_seconds: int = 0 # per (toggle, category, region) throttle window; 0 = disabled
# per-channel delivery config (mirrors NotificationRuleConfig channel fields) # per-channel delivery config (mirrors NotificationRuleConfig channel fields)
broadcast_channel: Optional[int] = None broadcast_channel: Optional[int] = None
node_ids: list = field(default_factory=list) node_ids: list = field(default_factory=list)

View file

@ -358,6 +358,11 @@ class Dispatcher:
return return
# ---------- Section 2 — per-toggle cooldown ---------- # ---------- Section 2 — per-toggle cooldown ----------
# Immediate-severity events bypass cooldown entirely — they are
# already rate-controlled by source handler change detection.
if getattr(event, "severity", None) == "immediate":
cooldown_s = 0
else:
cooldown_s = int(getattr(tog, "cooldown_seconds", 300) or 0) cooldown_s = int(getattr(tog, "cooldown_seconds", 300) or 0)
if cooldown_s > 0: if cooldown_s > 0:
suffix = (event.data or {}).get("_cooldown_suffix", "") suffix = (event.data or {}).get("_cooldown_suffix", "")