mirror of
https://github.com/zvx-echo6/meshai.git
synced 2026-08-26 17:31:34 +00:00
chore(central-ripout 2e): split central_normalizer.py; eliminate the "central" name (#165)
Final structural step. central_normalizer.py (973 LOC, misnamed — it lived
OUTSIDE central/ but its docstring described "the Central firehose") is DELETED.
No file or symbol named "central" survives (only immutable historical comments
in an already-applied migration .sql remain — those are not edited).
Split per the owner's rule ("next to what uses it"):
- Live geo/place-name utilities (nearest_town, _haversine_miles, _bearing_compass,
_compute_distance_bearing, _h3_cell, _photon_reverse_places, geocoder config)
→ the EXISTING meshai/geo.py ("Geographic utilities…"), same domain. NOT a
junk drawer. geo.py's nearest_city (hardcoded table) and central_normalizer's
nearest_town (live Photon+H3 reverse-geocode) are different implementations —
both kept, no false consolidation.
- WZDx work-zone parsers (_parse_wzdx_federal, _norm_wzdx_sub_type, _norm_direction,
_parse_mile_posts, _clean_description, _is_uninformative_road) → env/wzdx_parse.py,
next to their sole consumer env/wzdx.py.
- ~400 dead lines deleted: the Central-envelope machinery (normalize,
_parse_state_511_atis, _parse_wfigs_incidents, _parse_itd_511_work_zone,
should_skip_state_511_atis_id, is_incident_envelope_stale, normalize_road_name,
_norm_sub_type, _parse_ends_at) — only caller was the deleted Central consumer.
Consumers rewired: env/wzdx.py, env/fire_render.py, formatters/fire.py,
formatters/_anchor.py, main.py, persistence/curation.py, composer.py.
Tests: test_central_normalizer.py RENAMED → test_geo_wzdx_parse.py (live geo/wzdx
tests kept + rewired; dead-parser tests dropped). test_itd_511_work_zone.py
deleted (tested only the dead itd_511 parser — verified gone from source).
Other test files: import-path rewires. Live coverage for nearest_town /
_parse_wzdx_federal / bearing preserved across test_geo_wzdx_parse, test_adapter_wzdx,
test_wfigs_handler, test_incident_refactor.
Suite: 2010 passed, 0 failed. The 49-test drop is the dead Central-envelope
parser tests, correctly removed. Stale "Central firehose" docstrings on the
moved code updated to describe present behavior.
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:
parent
de91751bbc
commit
6050392d09
19 changed files with 1167 additions and 2002 deletions
|
|
@ -21,7 +21,6 @@ from __future__ import annotations
|
|||
|
||||
import pytest
|
||||
|
||||
from meshai import central_normalizer as cn
|
||||
from meshai.notifications.formatters._budget import budget_for
|
||||
from meshai.env.fire_render import (
|
||||
_build_canonical,
|
||||
|
|
@ -37,6 +36,7 @@ from tests.test_wfigs_handler import (
|
|||
_IRWIN_A,
|
||||
_make_active_envelope,
|
||||
_make_tombstone,
|
||||
_normalize_wfigs,
|
||||
)
|
||||
|
||||
_AT = 1_800_000_000.0 # pinned epoch (unused by fire render; kept for parity)
|
||||
|
|
@ -148,14 +148,14 @@ class TestFormatterGolden:
|
|||
# Drive the real handler to produce the legacy all-clear wire, then
|
||||
# assert the formatter reproduces it byte-for-byte from event.data.
|
||||
env = _make_active_envelope(geocoder_city="Burley")
|
||||
n0 = cn.normalize(env)
|
||||
n0 = _normalize_wfigs(env)
|
||||
data0 = {}
|
||||
handle_wfigs(n0, env, env["subject"], data=data0, now=1_000_000)
|
||||
data0["_on_broadcast_committed"](float(1_000_000)) # arm last_broadcast_*
|
||||
|
||||
tomb = _make_tombstone()
|
||||
data_t = {}
|
||||
old_wire = handle_wfigs(cn.normalize(tomb), tomb, tomb["subject"],
|
||||
old_wire = handle_wfigs(_normalize_wfigs(tomb), tomb, tomb["subject"],
|
||||
data=data_t, now=2_000_000)
|
||||
assert old_wire is not None
|
||||
assert old_wire.startswith("✅ Cache Peak Fire — contained & closed")
|
||||
|
|
@ -186,7 +186,7 @@ class TestGateSequenceParity:
|
|||
"""A full fire lifecycle agrees between decide() and handle_wfigs()."""
|
||||
|
||||
def _decide(self, env, now):
|
||||
n = cn.normalize(env)
|
||||
n = _normalize_wfigs(env)
|
||||
canonical = _build_canonical(n, n["_kind"])
|
||||
return fire_decide(canonical, source="wfigs", now=float(now))
|
||||
|
||||
|
|
@ -198,7 +198,7 @@ class TestGateSequenceParity:
|
|||
legacy (not-cutover) stamps must equal decide()'s data_patch, and we arm
|
||||
last_broadcast_* via the commit callback (simulating the dispatcher).
|
||||
"""
|
||||
n = cn.normalize(env)
|
||||
n = _normalize_wfigs(env)
|
||||
gate = self._decide(env, now)
|
||||
assert gate.broadcast is expect_broadcast, (
|
||||
f"decide broadcast {gate.broadcast} != {expect_broadcast} "
|
||||
|
|
@ -268,7 +268,7 @@ class TestGateSequenceParity:
|
|||
irwin_id=_IRWIN_A, geocoder_city="Burley",
|
||||
daily_acres=250.0, pct_contained=0, fire_discovery_dt_ms=disc_ms)
|
||||
gate = self._decide(env_new, base)
|
||||
n = cn.normalize(env_new)
|
||||
n = _normalize_wfigs(env_new)
|
||||
assert gate.data_patch["_dedup_suffix"] == f"{n['acres']}|{n['contained_pct']}"
|
||||
assert gate.data_patch["_cooldown_suffix"] == _IRWIN_A
|
||||
|
||||
|
|
@ -279,7 +279,7 @@ class TestGateSequenceParity:
|
|||
assert gate.broadcast is False
|
||||
assert gate.lifecycle == "suppress"
|
||||
# Handler agrees: returns None.
|
||||
out = handle_wfigs(cn.normalize(tomb), tomb, tomb["subject"],
|
||||
out = handle_wfigs(_normalize_wfigs(tomb), tomb, tomb["subject"],
|
||||
data={}, now=1_000_000)
|
||||
assert out is None
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue