From 61499009171664499a4d40ebddc462c7f9e36df8 Mon Sep 17 00:00:00 2001 From: "Matt Johnson (via Claude)" Date: Mon, 8 Jun 2026 03:53:02 +0000 Subject: [PATCH] feat(incident): config-driven TomTom min_magnitude filter Add tomtom_incidents.min_magnitude setting (default 4 = severe) to adapter_config registry. Replace the hardcoded magnitude==0 drop check with a config-driven floor that silently drops any TomTom event below the configured threshold. Co-Authored-By: Claude Opus 4.6 --- meshai/adapter_config/defaults.py | 5 +++++ meshai/central/incident_handler.py | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/meshai/adapter_config/defaults.py b/meshai/adapter_config/defaults.py index 32678db..0947d0b 100644 --- a/meshai/adapter_config/defaults.py +++ b/meshai/adapter_config/defaults.py @@ -180,6 +180,11 @@ REGISTRY: dict[tuple[str, str], dict[str, Any]] = { "type": "bool", "description": "Drop envelopes whose time_validity != 'present'.", }, + ("tomtom_incidents", "min_magnitude"): { + "default": 4, + "type": "int", + "description": "Minimum TomTom magnitude_of_delay to broadcast (1=minor, 2=moderate, 3=major, 4=severe). Anything below this is silently dropped.", + }, # ================================================================= # STATE_511_ATIS -- 1 setting (states to skip in favor of itd_511) diff --git a/meshai/central/incident_handler.py b/meshai/central/incident_handler.py index d24d8f9..4e57928 100644 --- a/meshai/central/incident_handler.py +++ b/meshai/central/incident_handler.py @@ -272,10 +272,10 @@ def _parse_tomtom_incident(envelope: dict, now: int) -> Optional[dict]: inner = envelope.get("data") or {} d = inner.get("data") or {} - # FILTER §6: magnitude_of_delay == 0 -> drop at handler entrance. - # v0.6-3b: gated by adapter_config.tomtom_incidents.drop_zero_magnitude. + # Drop events below configured minimum magnitude. magnitude = d.get("magnitude_of_delay") - if magnitude == 0 and bool(adapter_config.tomtom_incidents.drop_zero_magnitude): + min_mag = int(adapter_config.tomtom_incidents.min_magnitude or 4) + if magnitude is not None and magnitude < min_mag: return None # FILTER §4: time_validity != 'present' -> drop past/future.