A unit call-sign is not a place
"Post 1-2" reached the geocoder, resolved against its talkgroup anchor and produced a confident pin in the right town for an event with no known location — while sitting in the same incident's `units` list the whole time. A plausible wrong pin is worse than no pin: nothing downstream can tell it is wrong. Extraction returns `location` and `units` from one pass, so a string in both is a misclassification, not two facts. Drop it before the geocoder sees it. Closes server-26#52. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
964343c819
commit
cc038e6326
@@ -28,7 +28,7 @@ from unittest.mock import AsyncMock, patch
|
||||
|
||||
from app.internal.incident_correlator import (
|
||||
_build_context, _create_incident, _update_incident,
|
||||
_resolve_location_pair, _verified_pin, clean_location,
|
||||
_resolve_location_pair, _verified_pin, clean_location, location_is_unit,
|
||||
)
|
||||
|
||||
NOW = datetime(2026, 8, 20, 7, 25, 0, tzinfo=timezone.utc)
|
||||
@@ -340,3 +340,35 @@ async def test_a_legacy_incidents_title_is_not_claimed_by_the_next_call():
|
||||
incident_type="police", severity="routine")
|
||||
assert "title" not in updates
|
||||
assert updates["location"] == "80 Grasslands Road"
|
||||
|
||||
|
||||
# ── server-26#52: a unit call-sign must never become a map pin ────────────────
|
||||
#
|
||||
# "Post 1-2" passed clean_location (it has a word in it), geocoded against the
|
||||
# Ossining anchor and produced a confident pin in the right town for an event
|
||||
# with no known location. It was in the same incident's `units` all along.
|
||||
|
||||
@pytest.mark.parametrize("location,units", [
|
||||
("Post 1-2", ["1-2", "Lincoln", "Post 1-2"]), # the dump's actual incident
|
||||
("post 1-2", ["Post 1-2"]), # case-blind
|
||||
("Post 1-2.", ["Post 1-2"]), # punctuation-blind
|
||||
("Engine 4", ["Engine 4", "Ladder 1"]),
|
||||
])
|
||||
def test_location_matching_a_unit_is_rejected(location, units):
|
||||
assert location_is_unit(location, units) is True
|
||||
|
||||
|
||||
@pytest.mark.parametrize("location,units", [
|
||||
("Water Street", ["1-2", "Post 1-2"]), # a real place, same incident
|
||||
("South High", []), # no units extracted
|
||||
("Riverdale Station", ["Lincoln"]),
|
||||
("", ["Post 1-2"]), # nothing to compare
|
||||
(None, ["Post 1-2"]),
|
||||
])
|
||||
def test_real_places_survive_the_unit_check(location, units):
|
||||
assert location_is_unit(location, units) is False
|
||||
|
||||
|
||||
def test_unit_check_does_not_match_on_substrings():
|
||||
"""`1-2` is a unit; "1-2 Main Street" is an address that contains it."""
|
||||
assert location_is_unit("1-2 Main Street", ["1-2"]) is False
|
||||
|
||||
Reference in New Issue
Block a user