v0.9.20: regional subject routing on quake / fire / hydro / disaster adapters

* v0.9.20: regional subject routing on quake / fire / hydro / disaster adapters

Adds regional subject tokens to four adapters that previously published
without location-based routing:

- usgs_quake: central.quake.event.<tier>.us.<state> (US) or .<country> (intl)
- firms: central.fire.hotspot.<sat>.<conf>.us.<state> or .<country>
- nwis: central.hydro.<param>.<agency>.<site>.us.<state> (always US)
- eonet: central.disaster.eonet.<cat>.<country> (replaces hardcoded .global)

The us.<state> pattern (two tokens for US events) matches the NWS precedent
and resolves the ISO-2 collision between Idaho (id) and Indonesia.

New shared helper module: src/central/adapters/_subject_helpers.py
- US_STATE_NAME_TO_CODE: 50 states + DC + territories
- subject_for_country(): normalized country token
- subject_for_region(): returns us.<state>, <country>, or unknown

gdacs.py refactored to import subject_for_country from shared module.

Fixes: meshai v0.4 Phase C.3 bug (M4.1 Nevada quake routed globally)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* v0.9.20: stale docstring nit on renamed test

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Matt Johnson <mj@k7zvx.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
malice 2026-05-27 23:50:30 -06:00 committed by GitHub
commit 6ea7bd70f1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 383 additions and 38 deletions

View file

@ -503,7 +503,7 @@ class TestSubjectFor:
geo=Geo(centroid=(-116.0, 45.0)),
data={},
)
assert adapter.subject_for(event) == "central.quake.event.minor"
assert adapter.subject_for(event) == "central.quake.event.minor.unknown"
@pytest.mark.asyncio
async def test_subject_light(self, temp_db_path, mock_config_store):
@ -522,7 +522,7 @@ class TestSubjectFor:
geo=Geo(centroid=(-116.0, 45.0)),
data={},
)
assert adapter.subject_for(event) == "central.quake.event.light"
assert adapter.subject_for(event) == "central.quake.event.light.unknown"
@pytest.mark.asyncio
async def test_subject_moderate(self, temp_db_path, mock_config_store):
@ -541,7 +541,7 @@ class TestSubjectFor:
geo=Geo(centroid=(-116.0, 45.0)),
data={},
)
assert adapter.subject_for(event) == "central.quake.event.moderate"
assert adapter.subject_for(event) == "central.quake.event.moderate.unknown"
@pytest.mark.asyncio
async def test_subject_strong(self, temp_db_path, mock_config_store):
@ -560,7 +560,7 @@ class TestSubjectFor:
geo=Geo(centroid=(-116.0, 45.0)),
data={},
)
assert adapter.subject_for(event) == "central.quake.event.strong"
assert adapter.subject_for(event) == "central.quake.event.strong.unknown"
@pytest.mark.asyncio
async def test_subject_major(self, temp_db_path, mock_config_store):
@ -579,7 +579,7 @@ class TestSubjectFor:
geo=Geo(centroid=(-116.0, 45.0)),
data={},
)
assert adapter.subject_for(event) == "central.quake.event.major"
assert adapter.subject_for(event) == "central.quake.event.major.unknown"
@pytest.mark.asyncio
async def test_subject_great(self, temp_db_path, mock_config_store):
@ -598,4 +598,4 @@ class TestSubjectFor:
geo=Geo(centroid=(-116.0, 45.0)),
data={},
)
assert adapter.subject_for(event) == "central.quake.event.great"
assert adapter.subject_for(event) == "central.quake.event.great.unknown"