refactor(phase2): migrate nws + incident/roads to formatter+decider (tier-a) (#30)

Behavior-preserving relocation (byte-identical goldens), behind the staged-
cutover gate.

- formatters/nws.py + gating/nws.py: move _render + all CAP parsing (HTML-strip,
  _parse_nws_description, motion/hail/wind, county scoping, short-expiry) and the
  gating (3h re-alert window, Update/Cancel/Expire tombstone, first-sighting,
  warning->immediate severity). Native env/nws.py stops truncating description +
  carries parameters/eventCode/certainty/msgType/references/geocoder. Registers
  weather_warning + weather_statement.
- formatters/incident.py + gating/incident.py: absorb the incident _render AND
  the work_zone renderer, reconciling the two sub_type vocabularies; traffic_events
  change-detection gating. Native env/{traffic,roads511}.py emit canonical data.
  Registers work_zone/road_incident/road_closure/traffic_congestion.
- formatters/_anchor.py: shared town/distance/bearing resolver (consolidates WFIGS
  _location_anchor + incident nearest_town; WFIGS fire reuses in Phase 3).
- Fixtures captured: nws x37, traffic x46.

Tier-a byte-identical goldens for all fixtures. Tests: +~150; 0 new failures
(34 baseline, 1539 passed).

Co-authored-by: Matt Johnson <mj@k7zvx.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
malice 2026-07-04 18:16:34 -06:00 committed by GitHub
commit bdc42aa341
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
99 changed files with 15848 additions and 28 deletions

View file

@ -15,16 +15,15 @@ from meshai.notifications.renderers.composer import compose_mesh_message
# ── (a) empty registry returns None for known categories ──────────────────────
@pytest.mark.parametrize("category", [
"weather_warning",
# earthquake_event removed: Phase-1 registers formatters.quake for it.
# weather_warning/weather_statement removed: Phase-2 registers formatters.nws.
# road_closure/work_zone/road_incident/traffic_congestion removed: Phase-2 registers formatters.incident.
"wildfire_incident",
"road_closure",
"battery_critical",
])
def test_get_formatter_returns_none_while_registry_empty(category):
"""Un-migrated categories must still return None from get_formatter."""
# earthquake_event is now migrated (Phase 1); the remaining categories
# here have no formatter yet and must still fall through to Mode-B.
# Only categories not yet migrated to the formatter+gater architecture.
assert category not in FORMATTERS, (
f"Category {category!r} should not be in FORMATTERS yet (not migrated)"
)