mirror of
https://github.com/zvx-echo6/meshai.git
synced 2026-06-11 01:14:45 +02:00
fix(tracking): v0.5.7-tracking -- Central tracking check + categories audit
EIGHTH and FINAL family of the v0.5.7 NATS-and-categories campaign. Smallest scope of the entire campaign: zero source code changes, regression-tests only. The tracking family is a Phase 7 PLACEHOLDER -- everywhere we looked it is intentionally empty.
FIX 1 -- Central tracking adapter check: VERIFIED ABSENT in Central v0.10.0. Searched the consumer integration guide (docs/CONSUMER-INTEGRATION.md at v0.10.0-itd-511): 22 per-adapter sections in §6, none tracking-related (no APRS / ADS-B / OpenSky / aircraft / satellite). Subject prefixes in use: central.{disaster,fire,fires,hydro,meta,models,quake,space,traffic,traffic_cameras,traffic_flow,wx}.> -- no central.tracking.* / central.aprs.* / central.adsb.*. Producer source tree src/central/adapters/ has 24 adapter files; none tracking-named.
meshai already accounts for this -- _SUBJECTS_BARE has no `tracking` / `aprs` / `adsb` key; CENTRAL_ADAPTER_TO_SOURCE has no tracking entries on either side; _subjects_for("tracking", *) returns [] for any region (no key in the table). No code change needed.
FIX 2 -- ALERT_CATEGORIES tracking-family audit: VERIFIED EMPTY-BY-DESIGN. The tracking family is documented at meshai/notifications/categories.py:19 as "tracking - ADS-B, AIS, satellite passes (Phase 7)" -- a reserved-but-unimplemented family. State as of v0.5.7-tracking:
- "tracking" in VALID_TOGGLES (the toggle name is reserved)
- ZERO ALERT_CATEGORIES entries with toggle="tracking"
- ZERO native adapter files in meshai/env/ (no aprs.py, adsb.py, etc.)
- ZERO entries in _TOGGLE_PREFIX_FALLBACK routing to "tracking"
- dashboard-frontend/src/pages/Environment.tsx FAMILIES list has the
placeholder { key: "tracking", label: "Tracking", icon: Satellite,
adapters: [] } -- empty adapter list
No native emissions to audit against. Every emitted = selectable is trivially satisfied: zero emissions, zero registry entries, zero gap. No code change needed.
Regression guards (the whole commit)
------------------------------------
The risk this commit guards against is: a future Phase 7 implementer adds an APRS or ADS-B adapter (or wires a tracking Central subject) without doing the family-audit shape (registry entries with required fields, composer emoji/labels, paired test refresh). That would create orphan emissions -- the exact failure mode v0.5.7 spent eight phases eliminating across the other families.
tests/test_tracking_v057.py pins ALL of the above placeholder invariants as regression guards:
- No Central tracking-style subject prefixes anywhere in _SUBJECTS_BARE
(sweeps every adapter sub for "tracking" / "aprs" / "adsb" / "opensky").
- No tracking-style entries in CENTRAL_ADAPTER_TO_SOURCE on either side.
- _subjects_for("tracking" / "aprs" / "adsb", *) returns [] for every region.
- "tracking" reserved in VALID_TOGGLES.
- Zero ALERT_CATEGORIES entries with toggle="tracking".
- Zero env adapter files matching tracking-related needles.
- Environment.tsx FAMILIES tracking entry has adapters=[] (regex-pinned).
- No _TOGGLE_PREFIX_FALLBACK rule silently routes to tracking.
Each failure message points the future implementer at the paired changes required -- new registry entries, new composer glyphs, new env adapter file, paired test update. Phase 7 cannot ship partial.
Same outcome shape as v0.5.7-avalanche (Central has no counterpart; meshai handles it correctly already; regression-test-only commit).
Tests
-----
PYTHONPATH=. pytest -q: 450 passed (was 442; +8 net).
- tests/test_tracking_v057.py (new): eight regression guards covering Central absence, meshai-side placeholder state, frontend placeholder, and the no-silent-routing safety.
Campaign-wide test count progression across the eight v0.5.7 families:
v0.5.7-weather 345 (baseline 328 + 17)
v0.5.7-traffic 366 (+21)
v0.5.7-fire 380 (+14)
v0.5.7-seismic 400 (+20)
v0.5.7-water 413 (+13)
v0.5.7-rf 431 (+18)
v0.5.7-avalanche 442 (+11)
v0.5.7-tracking 450 (+8)
Safe-mode preserved (master off, all family toggles off, all adapters native, central disabled). No live toggle flipped. v0.5.7 tag deferred -- waiting on explicit instruction after Matt reviews the campaign-wide summary.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7f8633aed5
commit
7502663f21
1 changed files with 165 additions and 0 deletions
165
tests/test_tracking_v057.py
Normal file
165
tests/test_tracking_v057.py
Normal file
|
|
@ -0,0 +1,165 @@
|
||||||
|
"""v0.5.7-tracking: Central tracking adapter check + categories audit.
|
||||||
|
|
||||||
|
The tracking family is a PLACEHOLDER for Phase 7 (per
|
||||||
|
meshai/notifications/categories.py:19 header comment: "tracking - ADS-B,
|
||||||
|
AIS, satellite passes (Phase 7)"). As of v0.5.7-tracking it has:
|
||||||
|
|
||||||
|
- "tracking" in VALID_TOGGLES (reserved toggle name)
|
||||||
|
- dashboard-frontend/src/pages/Environment.tsx FAMILIES list entry with
|
||||||
|
label="Tracking", icon=Satellite, adapters=[] (empty placeholder)
|
||||||
|
- ZERO native adapter files in meshai/env/
|
||||||
|
- ZERO ALERT_CATEGORIES entries with toggle="tracking"
|
||||||
|
- ZERO Central wires (no central.tracking.* / central.aprs.* / etc.;
|
||||||
|
no entries in _SUBJECTS_BARE; no entries in CENTRAL_ADAPTER_TO_SOURCE)
|
||||||
|
|
||||||
|
This file pins all of those invariants as regression guards. The intent
|
||||||
|
is that a future Phase 7 commit that flips any of these (e.g. adds an
|
||||||
|
APRS adapter, wires a Central tracking subject) will fail these tests
|
||||||
|
and FORCE the implementer to come back and complete the family-audit
|
||||||
|
shape (registry entries with required fields, composer emoji/labels,
|
||||||
|
test file refresh) the same way every other family in v0.5.7 was done.
|
||||||
|
|
||||||
|
Central v0.10.0 cross-check
|
||||||
|
---------------------------
|
||||||
|
The Central v0.10.0 guide (docs/CONSUMER-INTEGRATION.md at v0.10.0-itd-511)
|
||||||
|
documents 22 per-adapter sections covering wx / fire / quake / space /
|
||||||
|
disaster / traffic / hydro -- NONE are tracking-related. The producer
|
||||||
|
source tree src/central/adapters/ contains 24 adapter files; NONE are
|
||||||
|
named for any tracking concept (aprs / adsb / opensky / satellite /
|
||||||
|
position). Subject prefixes used: central.{disaster,fire,fires,hydro,
|
||||||
|
meta,models,quake,space,traffic,traffic_cameras,traffic_flow,wx}.> --
|
||||||
|
no central.tracking.* / central.aprs.*.
|
||||||
|
|
||||||
|
Same shape as v0.5.7-avalanche: no Central counterpart, native-only
|
||||||
|
(currently native-empty).
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from meshai.central.consumer import (
|
||||||
|
CENTRAL_ADAPTER_TO_SOURCE,
|
||||||
|
CentralConsumer,
|
||||||
|
_SUBJECTS_BARE,
|
||||||
|
_subjects_for,
|
||||||
|
)
|
||||||
|
from meshai.config import EnvironmentalConfig
|
||||||
|
from meshai.notifications.categories import ALERT_CATEGORIES, VALID_TOGGLES
|
||||||
|
|
||||||
|
|
||||||
|
# ---------- FIX 1: Central has no tracking adapter -----------------------
|
||||||
|
|
||||||
|
|
||||||
|
def test_central_has_no_tracking_subject_prefix():
|
||||||
|
"""No Central stream/subject namespace uses a tracking-style prefix."""
|
||||||
|
for adapter, subs in _SUBJECTS_BARE.items():
|
||||||
|
for s in subs:
|
||||||
|
assert "tracking" not in s.lower(), \
|
||||||
|
f"unexpected tracking subject for adapter {adapter}: {s!r}"
|
||||||
|
for needle in ("aprs", "adsb", "opensky", "ads_b"):
|
||||||
|
assert needle not in s.lower(), \
|
||||||
|
f"unexpected {needle!r} subject for adapter {adapter}: {s!r}"
|
||||||
|
|
||||||
|
|
||||||
|
def test_central_adapter_remap_has_no_tracking_entries():
|
||||||
|
"""No Central adapter name remaps to a tracking source on either side."""
|
||||||
|
for src_name, mesh_name in CENTRAL_ADAPTER_TO_SOURCE.items():
|
||||||
|
for needle in ("tracking", "aprs", "adsb", "opensky"):
|
||||||
|
assert needle not in src_name.lower(), \
|
||||||
|
f"unexpected Central adapter name: {src_name}"
|
||||||
|
assert needle not in mesh_name.lower(), \
|
||||||
|
f"unexpected meshai source name: {mesh_name}"
|
||||||
|
|
||||||
|
|
||||||
|
def test_tracking_source_is_unknown_to_subjects_for():
|
||||||
|
"""Asking the consumer for tracking-source subjects returns empty for
|
||||||
|
every region -- the source isn't in the table at all."""
|
||||||
|
for region in ("us.id", "us.mt", "", None):
|
||||||
|
assert _subjects_for("tracking", region) == [], \
|
||||||
|
f"_subjects_for('tracking', {region!r}) should be []"
|
||||||
|
assert _subjects_for("aprs", region) == []
|
||||||
|
assert _subjects_for("adsb", region) == []
|
||||||
|
|
||||||
|
|
||||||
|
# ---------- meshai-side placeholder invariants ---------------------------
|
||||||
|
|
||||||
|
|
||||||
|
def test_tracking_toggle_is_reserved_in_valid_toggles():
|
||||||
|
"""The toggle name 'tracking' is reserved (placeholder for Phase 7)
|
||||||
|
even though no categories use it yet."""
|
||||||
|
assert "tracking" in VALID_TOGGLES
|
||||||
|
|
||||||
|
|
||||||
|
def test_alert_categories_has_zero_tracking_entries():
|
||||||
|
"""v0.5.7-tracking placeholder check: registry has no toggle='tracking'
|
||||||
|
entries. If Phase 7 lands, this test should be updated alongside the
|
||||||
|
new entries -- not silently deleted."""
|
||||||
|
tracking_entries = [
|
||||||
|
cid for cid, info in ALERT_CATEGORIES.items()
|
||||||
|
if info.get("toggle") == "tracking"
|
||||||
|
]
|
||||||
|
assert tracking_entries == [], \
|
||||||
|
f"unexpected tracking-family entries: {tracking_entries}"
|
||||||
|
|
||||||
|
|
||||||
|
def test_no_native_tracking_adapter_files():
|
||||||
|
"""meshai/env/ has no tracking-related adapter files. Phase 7 will
|
||||||
|
add at least one (likely aprs.py / adsb.py / opensky.py); when it
|
||||||
|
does, this test should be updated to point at the new adapter."""
|
||||||
|
env_dir = Path("meshai/env")
|
||||||
|
if not env_dir.is_dir():
|
||||||
|
pytest.skip("meshai/env not present in this working tree")
|
||||||
|
files = {p.name for p in env_dir.iterdir() if p.suffix == ".py"}
|
||||||
|
for needle in ("aprs", "adsb", "ads_b", "opensky", "tracking", "satellite"):
|
||||||
|
for fname in files:
|
||||||
|
assert needle not in fname.lower(), \
|
||||||
|
f"unexpected env adapter file {fname!r} hints at a tracking adapter"
|
||||||
|
|
||||||
|
|
||||||
|
# ---------- frontend placeholder invariant -------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
def test_environment_tsx_tracking_family_has_empty_adapter_list():
|
||||||
|
"""Environment.tsx FAMILIES entry for 'tracking' must currently have
|
||||||
|
adapters=[]. Phase 7 will populate this list; that change should be
|
||||||
|
paired with new ALERT_CATEGORIES entries + adapter files + a test
|
||||||
|
refresh here."""
|
||||||
|
tsx = Path("dashboard-frontend/src/pages/Environment.tsx")
|
||||||
|
if not tsx.is_file():
|
||||||
|
pytest.skip("Environment.tsx not present in this working tree")
|
||||||
|
text = tsx.read_text()
|
||||||
|
# Look for the FAMILIES line for tracking; the adapter list must be empty.
|
||||||
|
assert "key: 'tracking'" in text or 'key: "tracking"' in text, \
|
||||||
|
"Environment.tsx FAMILIES is missing the tracking placeholder entry"
|
||||||
|
# Pattern: `key: 'tracking', label: 'Tracking', icon: Satellite, adapters: []`
|
||||||
|
# Accept any quote style + minor formatting tolerance.
|
||||||
|
import re
|
||||||
|
m = re.search(
|
||||||
|
r"""key:\s*['"]tracking['"]\s*,\s*"""
|
||||||
|
r"""label:\s*['"]Tracking['"]\s*,\s*"""
|
||||||
|
r"""icon:\s*\w+\s*,\s*"""
|
||||||
|
r"""adapters:\s*\[\s*\]""",
|
||||||
|
text, re.DOTALL,
|
||||||
|
)
|
||||||
|
assert m, (
|
||||||
|
"Environment.tsx tracking-family adapter list is no longer empty. "
|
||||||
|
"If you're landing Phase 7, update this test together with the "
|
||||||
|
"new ALERT_CATEGORIES entries + adapter files + composer glyphs."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# ---------- safety: no orphan routing into tracking ----------------------
|
||||||
|
|
||||||
|
|
||||||
|
def test_no_prefix_fallback_routes_to_tracking():
|
||||||
|
"""The _TOGGLE_PREFIX_FALLBACK chain in categories.py has no rule that
|
||||||
|
silently routes unknown categories to toggle='tracking'. Adding such
|
||||||
|
a rule without paired registry entries would create orphan tracking
|
||||||
|
events -- the v0.5.7 audit purity rule (every emitted = selectable)
|
||||||
|
forbids this."""
|
||||||
|
from meshai.notifications.categories import _TOGGLE_PREFIX_FALLBACK
|
||||||
|
for prefix, toggle in _TOGGLE_PREFIX_FALLBACK:
|
||||||
|
assert toggle != "tracking", \
|
||||||
|
f"prefix-fallback {prefix!r} -> tracking without registry entries"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue