diff --git a/work/meshai/central/__init__.py b/work/meshai/central/__init__.py index d4fcda5..e87a682 100644 --- a/work/meshai/central/__init__.py +++ b/work/meshai/central/__init__.py @@ -2,7 +2,7 @@ JetStream firehose and normalized it into meshai pipeline Events. The NATS consumer is retired (Central is gone); this package now only holds the split-file modules still used by the native adapter paths (firms_handler, -wfigs_handler _render, idaho_gauge_sites). The satellite pieces -(satpass_handler, tle_handler, pass_predictor) have moved to -meshai.env.satellite — they're feed-adapter support code, not consumer -leftovers.""" +wfigs_handler _render). The satellite pieces (satpass_handler, tle_handler, +pass_predictor) have moved to meshai.env.satellite, and the gauge-site +lookups have moved to meshai.env.gauge_sites — they're feed-adapter support +code, not consumer leftovers.""" diff --git a/work/meshai/central/idaho_gauge_sites.py b/work/meshai/env/gauge_sites.py similarity index 80% rename from work/meshai/central/idaho_gauge_sites.py rename to work/meshai/env/gauge_sites.py index 392cb8a..cab1f85 100644 --- a/work/meshai/central/idaho_gauge_sites.py +++ b/work/meshai/env/gauge_sites.py @@ -1,4 +1,4 @@ -"""v0.6-4 Idaho gauge-site lookups (now backed by gauge_sites table). +"""v0.6-4 gauge-site lookups (now backed by gauge_sites table). The IDAHO_CURATED_SITES Python dict was migrated to the gauge_sites SQLite table in v8.sql. seed_gauge_sites() (called from init_db on first boot) @@ -6,18 +6,19 @@ populates the table with the original 9 sites. The lookup helpers below read from the table via meshai.persistence.curation. Module exports retained for backward-compat with existing tests: - lookup_site, normalize_site_id, THRESHOLD_RANK, compute_threshold_state. + lookup_site, normalize_site_id, compute_threshold_state. The IDAHO_CURATED_SITES name itself is gone -- new code should call lookup_site() (DB-backed) or the curation accessor directly. + +(Relocated from meshai/central/idaho_gauge_sites.py -- Central is gone; +this is pure hydro/gauge domain code, not a Central handler. The "idaho_" +prefix was dropped on the move: the data is Idaho-scoped but the code +itself is generic gauge/threshold logic. THRESHOLD_RANK, formerly exported +here, was inlined into its sole consumer, meshai.notifications.gating.hydro.) """ from typing import Optional -# Ordered list of threshold names from low to high. Used to compare -# "is current threshold higher than prior" (upward crossing detection). -THRESHOLD_RANK = ["normal", "action", "flood_minor", "flood_moderate", "flood_major"] - - def normalize_site_id(raw: Optional[str]) -> Optional[str]: """Accept 'USGS-13139510', 'USGS:13139510', '13139510', etc. Return the canonical 'USGS-' form so the curation table lookups succeed.""" diff --git a/work/meshai/env/usgs.py b/work/meshai/env/usgs.py index 641853c..dcfd64a 100644 --- a/work/meshai/env/usgs.py +++ b/work/meshai/env/usgs.py @@ -39,11 +39,11 @@ def _cfg_str(config, attr: str, default: str) -> str: # Maps the flood_status strings _fetch() sets (see severity-classification # block above) onto the ranked threshold_state vocabulary the shared hydro -# gating/formatter modules speak (meshai.central.idaho_gauge_sites. -# THRESHOLD_RANK / meshai.notifications.gating.hydro / formatters.hydro). -# Kept local rather than importing from central.idaho_gauge_sites so this -# adapter has no dependency on the (Central-only, reference-only) central -# package -- only the string vocabulary is shared, not the code. +# gating/formatter modules speak (meshai.notifications.gating.hydro. +# THRESHOLD_RANK / formatters.hydro). +# Kept local rather than importing from gating.hydro so this adapter has +# no dependency on the gating package -- only the string vocabulary is +# shared, not the code. _FLOOD_STATUS_TO_THRESHOLD_STATE = { "Action Stage": "action", "Minor Flood": "flood_minor", diff --git a/work/meshai/notifications/gating/hydro.py b/work/meshai/notifications/gating/hydro.py index ccc38ab..d573440 100644 --- a/work/meshai/notifications/gating/hydro.py +++ b/work/meshai/notifications/gating/hydro.py @@ -74,12 +74,17 @@ import logging from typing import Optional from meshai.adapter_config import adapter_config -from meshai.central.idaho_gauge_sites import THRESHOLD_RANK from meshai.notifications.gating.base import GateResult from meshai.persistence import get_db logger = logging.getLogger(__name__) +# Ordered list of threshold names from low to high. Used to compare +# "is current threshold higher than prior" (upward crossing detection). +# Formerly meshai.central.idaho_gauge_sites.THRESHOLD_RANK -- inlined here +# since this decider was its only consumer. +THRESHOLD_RANK = ["normal", "action", "flood_minor", "flood_moderate", "flood_major"] + def _rank(state: Optional[str]) -> int: """THRESHOLD_RANK index for *state*, treating unknown as 0 (normal).""" diff --git a/work/tests/test_hydro_refactor.py b/work/tests/test_hydro_refactor.py index 34556e0..45a01a8 100644 --- a/work/tests/test_hydro_refactor.py +++ b/work/tests/test_hydro_refactor.py @@ -208,8 +208,8 @@ class TestGateSequenceParity: def _canonical(self, fixture): """Build canonical data from a Central-style fixture (as the deleted - handler used to) via the still-live idaho_gauge_sites helpers.""" - from meshai.central.idaho_gauge_sites import ( + handler used to) via the still-live gauge_sites helpers.""" + from meshai.env.gauge_sites import ( compute_threshold_state, lookup_site, normalize_site_id, ) env = fixture["envelope"]