meshai/meshai
matt+claude c2d5bcfbd1 feat(central): v0.5.4 -- region-aware subscriptions using Central v0.9.20 regional subjects
Pre-v0.5.4 every Central subscription used a bare wildcard (central.wx.>,
central.fire.>, central.traffic.>, central.quake.>, central.hydro.>,
central.space.>), so a Magic Valley operator flipping nws -> central was
in fact subscribing to the all-US firehose and discarding 95% of events
locally. Central v0.9.20 (2026-05-28) added per-region subject suffixes
so the firehose can be filtered server-side. This wires meshai to use them.

Backend (meshai/central/consumer.py):
- New _subjects_for(adapter, region) replaces the static ADAPTER_SUBJECTS
  dict. ADAPTER_SUBJECTS is retained as an alias to _SUBJECTS_BARE for any
  legacy importers; the dispatcher path is unchanged.
- Per-adapter subject patterns (region='us.id' default):
    nws        -> central.wx.alert.us.id.>     (region BEFORE wildcard)
    usgs_quake -> central.quake.event.>.us.id  (region AFTER wildcard)
    firms      -> central.fire.hotspot.>.us.id
    fires      -> central.fire.incident.id.>   (state token at fixed depth)
                  central.fire.perimeter.id.>
    traffic    -> central.traffic.>.id          (bare state, no us. prefix)
    roads511   -> central.traffic.>.id          (shared with traffic, sub-adapter routing)
    usgs       -> central.hydro.>.us.id
                  central.hydro.>.unknown      (workaround until v0.9.20.1)
    swpc       -> central.space.>               (planetary; region ignored)
- Empty/None region falls back to bare wildcards (pre-v0.9.20 behaviour).
- _subject_owned() pulls region from env.central.region and routes through
  _subjects_for; v0.5.3 sub-adapter routing (owned-sources set) still
  applies on shared subjects like central.traffic.>.id.
- start() logs the active region at connect-time for ops visibility.

Config (meshai/config.py):
- CentralConsumerConfig.region: str = "us.id". One region per consumer
  applies to every central-flipped adapter; per-adapter overrides can
  land in v0.6 when there is a real use case.

Frontend (dashboard-frontend/src/pages/Environment.tsx):
- Central Connection panel gets a Region text input next to URL/Durable.
- EnvConfig.central type extended with region: string.
- Static bundle rebuilt; index-DCFmSeOM.js -> index-B24tHcYj.js.

Tests:
- tests/test_central_region_routing.py (new, 9 cases): asserts the exact
  v0.9.20 subject string for each adapter at region='us.id', the SWPC
  global-stays-global rule, the USGS .unknown workaround, the empty-region
  backward-compat fallback for all 8 adapters, and integration through
  CentralConsumer._subject_owned() with the default region.
- tests/test_central_consumer.py + tests/test_central_sub_adapter_routing.py:
  the two tests that asserted bare-wildcard subjects now set
  env.central.region = "" explicitly to preserve their original concern
  (no region semantics — backward-compat path only).

Why swpc stays global: space weather is planetary -- a CME is detected on
the sun, the geomagnetic response is hemispheric. There is no Idaho-only
solar event; subscribing per-region would only drop events we want.

Why hydro has the .unknown workaround: Central v0.9.20 leaves gauges
whose USGS state can't be inferred on central.hydro.>.unknown. Until
v0.9.20.1 backfills the state tag we subscribe to both filters to
avoid silently losing those rows. Idaho downstream-filtering on
data['_enriched']['usgs_site']['state'] is future v0.6 work.

Orthogonal to v0.5.2 dispatcher guards (staleness / cooldown / dedup)
and v0.5.3 sub-adapter routing: the region filter operates at the NATS
subscription layer (server-side), upstream of everything else.

Verified: pytest 327 passed (318 prior + 9 new region-routing tests);
py_compile clean; frontend build clean. Safe-mode preserved -- no toggle
enabled, no master enabled, no central enabled.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-04 02:30:33 +00:00
..
backends fix: Remove hard-coded token limits on LLM responses 2026-05-05 22:06:50 +00:00
central feat(central): v0.5.4 -- region-aware subscriptions using Central v0.9.20 regional subjects 2026-06-04 02:30:33 +00:00
cli feat: Full alert engine — 17 conditions, scaling cooldown, per-condition TUI toggles 2026-05-06 05:39:11 +00:00
commands build: normalize all line endings to LF 2026-05-14 22:43:06 +00:00
dashboard feat(central): v0.5.4 -- region-aware subscriptions using Central v0.9.20 regional subjects 2026-06-04 02:30:33 +00:00
env feat(central): v0.4 C.1 Central connector backend (no-op until adapter source flipped) 2026-05-28 02:28:19 +00:00
notifications fix(notifications): v0.5.2 -- staleness filter, cooldown, dedup, renderer wiring, hydro family 2026-06-04 00:40:28 +00:00
scripts build: normalize all line endings to LF 2026-05-14 22:43:06 +00:00
sources build: normalize all line endings to LF 2026-05-14 22:43:06 +00:00
__init__.py Initial commit: MeshAI - LLM-powered Meshtastic assistant 2025-12-15 11:53:46 -07:00
__main__.py Initial commit: MeshAI - LLM-powered Meshtastic assistant 2025-12-15 11:53:46 -07:00
alert_engine.py refactor: simplify severity to 3 levels (routine/priority/immediate) 2026-05-13 19:05:50 -06:00
chunker.py feat: ACK-based message delivery, markdown stripping, prompt fixes 2026-05-06 04:17:44 +00:00
config.py feat(central): v0.5.4 -- region-aware subscriptions using Central v0.9.20 regional subjects 2026-06-04 02:30:33 +00:00
config_loader.py feat(notifications): v0.5.0 -- Master Toggles UX redesign + Central Connection GUI + grouped categories + region scoping 2026-05-28 07:00:10 +00:00
connector.py fix: node_id int handling in connector + rule stats data path 2026-05-13 19:27:04 -06:00
context.py Add passive mesh context awareness — observe channel traffic, inject into LLM prompts 2026-02-24 22:02:42 +00:00
geo.py build: normalize all line endings to LF 2026-05-14 22:43:06 +00:00
history.py Support unlimited message history when max_messages_per_user is 0 2026-02-24 07:03:15 +00:00
knowledge.py build: normalize all line endings to LF 2026-05-14 22:43:06 +00:00
main.py feat(central): v0.4 C.1 Central connector backend (no-op until adapter source flipped) 2026-05-28 02:28:19 +00:00
memory.py Unify memory implementations: delete AnthropicMemory and GoogleMemory 2026-02-23 20:14:50 +00:00
mesh_data_store.py fix: notification system improvements and threshold corrections 2026-05-14 06:03:51 +00:00
mesh_health.py fix: notification system improvements and threshold corrections 2026-05-14 06:03:51 +00:00
mesh_models.py feat: Feeder-level gateway awareness from /api/packets_seen 2026-05-05 19:55:23 +00:00
mesh_reporter.py fix: notification system improvements and threshold corrections 2026-05-14 06:03:51 +00:00
mesh_sources.py build: normalize all line endings to LF 2026-05-14 22:43:06 +00:00
meshmonitor.py build: normalize all line endings to LF 2026-05-14 22:43:06 +00:00
responder.py fix: Switch to delay-based delivery — wantAck firmware retries cause duplicates 2026-05-07 21:50:09 +00:00
router.py build: normalize all line endings to LF 2026-05-14 22:43:06 +00:00
subscriptions.py build: normalize all line endings to LF 2026-05-14 22:43:06 +00:00