From 20c5799a8db083a8a78d8ca44f3f9442ac6eb8d5 Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sun, 27 Sep 2026 11:32:09 -0400 Subject: [PATCH] correlator: a radio code is not a location MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A 09-22 replay stop was titled "Traffic Stop at 96 times 5" — a disposition code read aloud, extracted as the location (server-26#170). clean_location now rejects "N times N", ten-codes, "signal N", "code N", "condition N". c2-core: 476 pass. Co-Authored-By: Claude Opus 5.5 --- drb-c2-core/app/internal/incident_correlator.py | 12 ++++++++++++ drb-c2-core/tests/test_clearance_tracking.py | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/drb-c2-core/app/internal/incident_correlator.py b/drb-c2-core/app/internal/incident_correlator.py index a04cd2c..2233517 100644 --- a/drb-c2-core/app/internal/incident_correlator.py +++ b/drb-c2-core/app/internal/incident_correlator.py @@ -343,9 +343,21 @@ def clean_location(value) -> Optional[str]: s = str(value).strip() if not s or not _LOCATION_WORD_RE.search(s): return None + if _RADIO_CODE_RE.match(s): + return None return s +# Status/disposition codes the extractor sometimes returns as a location: +# "96 times 5" (a disposition code read aloud) titled a 09-22 replay stop +# "Traffic Stop at 96 times 5" (server-26#170); "10-8", "signal 99", "code 4" +# are the same shape. +_RADIO_CODE_RE = re.compile( + r"^\s*(?:\d{1,3}\s*(?:times|x)\s*\d{1,3}|10[\s-]?\d{1,3}|(?:signal|code|condition)\s+\d{1,3})\s*$", + re.IGNORECASE, +) + + def location_is_unit(location, units) -> bool: """ True when a location label is really one of the incident's own unit diff --git a/drb-c2-core/tests/test_clearance_tracking.py b/drb-c2-core/tests/test_clearance_tracking.py index 0f20328..318d07e 100644 --- a/drb-c2-core/tests/test_clearance_tracking.py +++ b/drb-c2-core/tests/test_clearance_tracking.py @@ -154,3 +154,10 @@ def test_plate_read_on_a_patrol_channel_is_a_stop(): # not on rail/bridge channels, and not without digits assert b("Frank David Boy 4514", [], None, "routine", "MTA Bridges and Tunnels - Whitestone") == ([], None, "routine") assert b("Charlie, David, go ahead.", [], None, "routine", ch) == ([], None, "routine") + + +def test_radio_codes_are_not_locations(): + for junk in ("96 times 5", "96 x 1", "10-8", "Signal 99", "code 4"): + assert ic.clean_location(junk) is None, junk + for place in ("West Main Street", "Route 9", "96 Main Street", "Exit 17 southbound"): + assert ic.clean_location(place) == place, place -- 2.54.0