Commit graph

2 commits

Author SHA1 Message Date
dcb53ae30c test: update stale assertions post feature/mesh-intelligence merge
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-10 03:43:06 +00:00
Matt Johnson
7f8633aed5 fix(avalanche): v0.5.7-avalanche -- Central avalanche check + categories audit
Seventh family of the v0.5.7 NATS-and-categories campaign. Smaller scope than prior families (consumer.py unchanged): the Central side is verifiably empty, and the registry-audit gap is a single-entry add.

FIX 1 -- Central avalanche adapter check: VERIFIED ABSENT in Central v0.10.0. Searched the consumer integration guide (docs/CONSUMER-INTEGRATION.md at v0.10.0-itd-511) -- zero `avalanche` / `NWAC` / `CAIC` references. Searched the producer source tree (src/central/adapters/) -- no avalanche-named adapter files. meshai already accounts for this:

  - meshai/central/consumer.py _SUBJECTS_BARE has no `avalanche` key, so
    _subjects_for("avalanche", *) returns [] regardless of region.
  - CENTRAL_ADAPTER_TO_SOURCE has no avalanche entry on either side.
  - _subject_owned() (consumer.py line 334-) explicitly logs a warning
    if someone flips avalanche.feed_source=central, then skips
    subscribing.

No code change needed for FIX 1. Tests now pin these invariants so a future refactor that introduces an unexpected avalanche Central wire breaks loudly here.

FIX 2 -- ALERT_CATEGORIES avalanche-family audit. Native meshai/env/avalanche.py emits two categories from the NWAC/CAIC danger-level tier:

    danger_level >= 4 (High, Extreme)  -> avalanche_warning
    danger_level == 3 (Considerable)   -> avalanche_watch
    danger_level <= 2 (Low, Moderate)  -> silently dropped (not actionable)

Pre-v0.5.7-avalanche registry had avalanche_warning + avalanche_considerable. avalanche_warning matched the native emit. avalanche_considerable was a LEGACY name for the Considerable-danger tier -- the native code already emits avalanche_watch for that same semantic (verified at meshai/env/avalanche.py:266; tests/test_adapter_avalanche.py:90 asserts the mapping).

So avalanche_watch was MISSING from the registry, leaving the rule editor unable to target danger-level=3 emissions even though they were correctly routed to toggle="avalanche" via the `("avalanche", "avalanche")` prefix fallback.

Added avalanche_watch under toggle="avalanche", default_severity="routine", with a description that points at the Considerable-tier semantics and an example_message matching the live NWAC product phrasing. composer._CATEGORY_EMOJI and _CATEGORY_LABEL gained matching entries so live LoRa rendering shows the right glyph (⛷, label "AVY").

Legacy entry kept: avalanche_considerable remains in the registry as a forward-compat target even though no current code path emits it. Reasoning matches the v0.5.7-rf precedent:
  - router.py source-attribution tables (lines 317, 429) reference it
  - composer.py emoji + label tables reference it
  - A future phase might re-emit avalanche_considerable as a finer-grained
    distinction from the generic Watch label; removing the registry entry
    would break any user rule currently targeting it.

If avalanche_considerable remains un-emitted by v0.6, file a follow-up cleanup phase to remove it together with the rf-family hf_blackout / tropospheric_ducting legacy entries. test_alert_categories_avalanche_complete uses a SUBSET assertion (native emit ⊆ registry) so the legacy entry is allowed.

Audit table after v0.5.7-avalanche:
  Registry avalanche (3):
    avalanche_warning      (native danger_level >= 4)
    avalanche_watch        [v0.5.7-avalanche NEW] (native danger_level == 3)
    avalanche_considerable (legacy, no current emitter)
  Native emit: {avalanche_warning, avalanche_watch} ⊆ Registry  -- parity for everything emitted.

Tests
-----
PYTHONPATH=. pytest -q: 442 passed (was 431; +11 net).
  - tests/test_avalanche_v057.py (new): _subjects_for("avalanche", *) returns [] for every region input; avalanche absent from _SUBJECTS_BARE and CENTRAL_ADAPTER_TO_SOURCE; flipping avalanche.feed_source=central produces zero subscriptions; avalanche_watch present under toggle="avalanche" with required fields; avalanche_warning + avalanche_considerable still registry-present; native emit set equals {avalanche_warning, avalanche_watch} and is a subset of the registry.

Safe-mode preserved (master off, all family toggles off, all adapters native, central disabled). No live toggle flipped. Not tagging yet -- v0.5.7 tag waits until all families ship.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-04 06:55:27 +00:00