feat(dispatcher): per-fire cooldown independence via _cooldown_suffix

Each WFIGS fire event now carries its irwin_id as _cooldown_suffix in
event.data. The dispatcher incorporates this suffix into the cooldown
key region field, giving each fire its own independent cooldown slot
instead of sharing one per (toggle, category, region).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Matt Johnson (via Claude) 2026-06-07 16:11:49 +00:00
commit 34e2e3f040
2 changed files with 6 additions and 1 deletions

View file

@ -274,6 +274,7 @@ def _attach_commit_handles(data: Optional[dict], *, irwin_id: str,
data["_on_broadcast_committed"] = _on_commit
data["_broadcast_audit"] = {"table": "fires", "pk": irwin_id}
data["_cooldown_suffix"] = irwin_id
# ---------- helpers -------------------------------------------------------

View file

@ -360,10 +360,14 @@ class Dispatcher:
# ---------- Section 2 — per-toggle cooldown ----------
cooldown_s = int(getattr(tog, "cooldown_seconds", 300) or 0)
if cooldown_s > 0:
suffix = (event.data or {}).get("_cooldown_suffix", "")
region_key = event.region or "*"
if suffix:
region_key = f"{region_key}|{suffix}"
ck = (
getattr(tog, "name", "") or fam,
event.category,
event.region or "*",
region_key,
)
now = time.time()
last_fired = self._toggle_cooldown.get(ck)