chore: excise the dead Central NATS consumer path (-11,328 LOC) (#144)

* chore: excise the dead Central NATS consumer path

Central was retired and its database dropped 2026-07-15; its NATS broker no
longer exists. Verified against the live CT108 deployment: all 12 adapters
run feed_source=native, zero on central, and central.enabled is False
(default, never overridden). The consumer and its handlers were unreachable.

Removed:
- central/consumer.py and 6 dead handlers (nws, quake, swpc, nwis, avy,
  incident) -- their handle_* entrypoints were reachable only from the
  consumer's dispatch
- the Central wiring in main.py (init, guarded start, retry loop, stop path)
- the dead config surface: CentralConsumerConfig, EnvironmentalConfig.central,
  adapter_config ("central","severity_thresholds") and its display block
- the nats-py dependency (consumer.py was its only importer)
- 19 test files that exercised only the dead path

KEPT -- these live under central/ but are imported directly by native
adapters, and deleting them would break production:
- wfigs_handler.py: firms_handler._handle_pass_boundary() calls its _render()
  on the live FIRMS growth-fire path (env/firms.py -> ingest_hotspot_pixel)
- firms_handler, satpass_handler, tle_handler: split files whose handle_*
  entrypoints are dead but whose engines are live. Left intact; splitting
  them is separate work.
- pass_predictor, budget, idaho_gauge_sites: fully live.

The usgs_quake keys global_mag_floor / regional_mag_floor / regional_centroid
/ regional_radius_mi / broadcast_pager_alerts are NOT removed despite comments
labelling them "CENTRAL-PATH ONLY" -- notifications/gating/quake.py reads them
unconditionally in the native path. Those comments are corrected separately.

Test-count note: the suite drops ~425 tests. Most were migration PARITY tests
whose sole purpose was proving the native rewrite byte-matched the Central
handler (golden byte-parity, cross-source identity, gate-sequence replay).
With the handler deleted there is nothing left to compare against, so they
cannot exist. Native-only tests were kept and reworked where a test reached
for a central symbol incidentally. This is a real coverage loss, accepted
deliberately: the parity harness proved the refactor faithful, and git
history preserves the originals.

Suite: 1984 passed, 6 failed -- the same 6 pre-existing failures as main
(stale SCHEMA_VERSION x3, expired TLE fixtures x2, one order-dependent),
all being fixed on fix/green-test-suite. No new failures.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* test(nws): restore native-only golden coverage for the wire formatter

Commit ca751fb5 deleted the Central nws_handler parity harness along with
the handler itself, which took the ONLY tests that pinned formatters.nws
.format()'s literal wire output. Gate-sequence and schema-conformance
tests already survived natively; the formatter's actual rendered text did
not have any native-only regression net.

Add TestFormatterGolden to test_nws_refactor.py: 3 real-fixture cases plus
6 hand-built pathological cases mined from the deleted test_nws_handler.py
(SVR path-sampling, the "no dangling separator" regression, TOR on-ground
vs radar-indicated, FFW flood-cause detection). Every literal was verified
by temporarily restoring the pre-excision central.nws_handler._render()
from git history (ca751fb5^) in a throwaway, uncommitted script, confirming
byte-identical output against the current native format() for all 37 real
fixtures (nws/ + nws_last/) and all 9 pathological cases, then pinning the
confirmed-matching string as the literal -- not a blind snapshot of
current behavior.

quake/swpc/avalanche/hydro/incident/fire were checked and already carry
equivalent native-only golden coverage (added directly in ca751fb5), so no
changes were needed there.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

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-17 14:03:40 -06:00 committed by GitHub
commit 9f06930a0d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
50 changed files with 643 additions and 11275 deletions

View file

@ -450,83 +450,3 @@ class TestClusterBelowThreshold:
assert out is None
assert data == {}
# ─────────────────────────────────────────────────────────────────────────────
# 6. issue #121 — cutover severity must reach the Event (regression guard)
# ─────────────────────────────────────────────────────────────────────────────
# Spotting and halt used to stamp a plain "severity" key in data_patch.
# central/consumer.py only ever promotes data["_severity_override"] onto
# Event.severity (see consumer.py's issue #118 comment) -- the plain key was
# a silent no-op, the same class of bug fixed for firms_handler.py's own
# inline stamps in PR #120. These drive the REAL cutover path end-to-end
# through CentralConsumer._normalize (the actual production entry point,
# adapter=="firms" dispatch) and assert the emitted Event's severity, so a
# regression back to a plain "severity" key fails loudly instead of silently.
class TestCutoverSeverityReachesEvent:
def _consumer(self):
from unittest.mock import MagicMock
from meshai.config import Config
from meshai.central.consumer import CentralConsumer
cfg = Config()
cfg.notifications.cold_start_grace_seconds = 0
return CentralConsumer(cfg.environmental, MagicMock())
def test_spotting_cutover_event_severity_is_immediate(self, monkeypatch):
_cutover(monkeypatch, "wildfire_spotting")
try:
_seed_pass_a_hex_then_close("ID-SEV-S", 43.0, -115.0)
sp_lat, sp_lon = _offset_mi(43.0, -115.0,
north_mi=2.0 / math.sqrt(2),
east_mi=2.0 / math.sqrt(2))
env = _envelope(lat=sp_lat, lon=sp_lon, acq_time="1800")
env["id"] = "spot-sev-test"
env["data"]["id"] = "spot-sev-test"
env["data"]["geo"] = {"centroid": [sp_lon, sp_lat]}
event = self._consumer()._normalize(_SUBJECT, env)
assert event is not None, "expected a broadcast Event, got None"
assert event.severity == "immediate", (
f"issue #121 regression: expected 'immediate', got "
f"{event.severity!r} -- gating.firms.decide's spotting "
f"data_patch must use _severity_override, not the plain "
f"'severity' key"
)
finally:
from meshai.notifications.cutover import _clear_cache
_clear_cache()
def test_halt_cutover_event_severity_is_routine(self, monkeypatch):
_cutover(monkeypatch, "wildfire_halted")
try:
from meshai.central import firms_handler as _fh
fixed_now = 1780768800
monkeypatch.setattr(_fh.time, "time", lambda: float(fixed_now))
_seed_stale_fire("ID-SEV-H", now_epoch=fixed_now, idle_hours=14)
# Any unrelated pixel arrival opportunistically triggers the halt
# scan (_maybe_emit_halt runs on every pixel as a fallback); use
# one far away so it isn't attributed to (and doesn't grow) the
# stale fire instead.
env = _envelope(lat=10.0, lon=10.0, acq_time="1800")
env["id"] = "halt-sev-test"
env["data"]["id"] = "halt-sev-test"
env["data"]["geo"] = {"centroid": [10.0, 10.0]}
# Raw envelope severity maps to "immediate" (>= immediate_min=3),
# deliberately NOT "routine" -- so the assertion below can only
# pass if the halt data_patch's _severity_override actually
# overrides it down to "routine". A plain "severity" key (the
# bug) would silently leave this at "immediate" instead.
env["data"]["severity"] = 3
event = self._consumer()._normalize(_SUBJECT, env)
assert event is not None, "expected a broadcast Event, got None"
assert event.severity == "routine", (
f"issue #121 regression: expected 'routine', got "
f"{event.severity!r} -- gating.firms.decide's halt "
f"data_patch must use _severity_override, not the plain "
f"'severity' key"
)
finally:
from meshai.notifications.cutover import _clear_cache
_clear_cache()