mirror of
https://github.com/zvx-echo6/meshai.git
synced 2026-08-26 17:31:34 +00:00
fix(config): warn on unknown config keys; delete 7 phantom keys from the example (#146)
* fix(config): warn on unknown config keys instead of silently dropping them
_dict_to_dataclass() silently continue'd past any key not in the target
dataclass's field set -- an operator could set a config key, restart, and
have it vanish with zero feedback (config.example.yaml's phantom
mesh_intelligence keys are exactly this bug, fixed separately).
Now logs a WARNING naming the key and the dataclass, hinting at a typo or
a renamed/removed field, via the module's existing _config_logger.
Traced every dynamic/free-form config path to rule out false positives:
notifications.toggles, notifications.destinations, generic_sources,
mesh_sources, and notifications.rules all route through explicit
dict-of-dataclass or verbatim-passthrough handling and never spuriously
warn. Two legitimate legacy shapes DO hit the strict field-check path with
keys that were never (and will never be) dataclass fields:
- notifications.channels (pre-v0.5 channel list), consumed directly from
the raw dict by _migrate_legacy_channels
- notifications.region_routes.enabled (pre mt/mc-split master switch),
read directly by the explicit region_routes handler
Both are allowlisted in _KNOWN_LEGACY_DROP_KEYS so users mid-migration
don't get spurious noise on every load.
Added tests/test_config_loader.py coverage: unknown key warns and does
not raise, both legacy shapes stay silent, and the free-form/dynamic
sections never warn for keys valid on their real target shape.
* fix(config): remove phantom config.example.yaml keys, add missing live ones
The new unknown-key warning (previous commit) caught config.example.yaml
loading with SEVEN warnings, all real drift -- none were false positives
of the warning itself:
mesh_intelligence block shipped three keys with no MeshIntelligenceConfig
field and no implementation anywhere (git log -S confirms they were never
built, not leftovers from a removal):
- region_radius_miles, infra_overrides, region_labels
These only made sense under an older auto-clustering design; what
actually exists is explicit region anchors (regions: list[RegionAnchor]).
Deleted from both the live block and the commented-out example above it,
and added the four fields that DO exist and are live but were missing
from the example: regions, critical_nodes, alert_channel, alert_rules.
Also fixed the now-misleading comment at
dashboard/api/mesh_routes.py:281, which referenced region_labels --
comment only, no code change.
notifications block shipped a whole quiet-hours subsystem that was
deliberately ripped out (commit b948ed77, "silent is better than ugly")
and never implemented as override_quiet -- confirmed by zero readers and
zero dataclass fields anywhere in meshai/:
- quiet_hours_enabled, quiet_hours_start, quiet_hours_end
- override_quiet (on 4 rule entries, including "Emergency Broadcast",
which falsely implied emergency alerts bypass quiet hours)
Deleted; no quiet-hours feature implemented (out of scope -- product
decision for the owner).
config.example.yaml now loads with exactly zero warnings: the loader and
the example finally agree.
---------
Co-authored-by: Matt Johnson <mj@k7zvx.com>
This commit is contained in:
parent
b0d1a76e70
commit
2543dfa8d1
4 changed files with 139 additions and 18 deletions
|
|
@ -114,22 +114,31 @@ mesh_sources: []
|
|||
#
|
||||
# mesh_intelligence:
|
||||
# enabled: true
|
||||
# region_radius_miles: 40.0 # Radius for region clustering
|
||||
# locality_radius_miles: 8.0 # Radius for locality clustering
|
||||
# offline_threshold_hours: 2 # Hours before node considered offline
|
||||
# packet_threshold: 500 # Non-text packets per 24h to flag
|
||||
# battery_warning_percent: 30 # Battery level for warnings
|
||||
# infra_overrides: [] # Node IDs to exclude from infrastructure
|
||||
# region_labels: {} # Override auto-names: {"Twin Falls": "Magic Valley"}
|
||||
# regions: # Fixed region anchors (explicit, not auto-clustered)
|
||||
# - name: "magic_valley"
|
||||
# lat: 42.56
|
||||
# lon: -114.47
|
||||
# local_name: "Magic Valley"
|
||||
# description: "Twin Falls, Burley, Jerome along I-84/US-93"
|
||||
# aliases: ["southern Idaho"]
|
||||
# cities: ["Twin Falls", "Burley", "Jerome"]
|
||||
# locality_radius_miles: 8.0 # Radius for locality clustering within regions
|
||||
# offline_threshold_hours: 2 # Hours before node considered offline
|
||||
# packet_threshold: 500 # Non-text packets per 24h to flag
|
||||
# battery_warning_percent: 30 # Battery level for warnings
|
||||
# critical_nodes: [] # Short names of critical nodes (e.g., ["MHR", "HPR"])
|
||||
# alert_channel: -1 # Channel to broadcast alerts on. -1 = disabled, 0+ = channel index
|
||||
# alert_rules: {} # Per-condition alert toggles/thresholds (see AlertRulesConfig)
|
||||
mesh_intelligence:
|
||||
enabled: false
|
||||
region_radius_miles: 40.0
|
||||
regions: []
|
||||
locality_radius_miles: 8.0
|
||||
offline_threshold_hours: 2
|
||||
packet_threshold: 500
|
||||
battery_warning_percent: 30
|
||||
infra_overrides: []
|
||||
region_labels: {}
|
||||
critical_nodes: []
|
||||
alert_channel: -1
|
||||
alert_rules: {}
|
||||
|
||||
# === ENVIRONMENTAL FEEDS ===
|
||||
# Live situational awareness from NWS, NOAA Space Weather, and Open-Meteo.
|
||||
|
|
@ -223,9 +232,6 @@ environmental:
|
|||
# Categories match alert types from alert_engine.py.
|
||||
notifications:
|
||||
enabled: false
|
||||
quiet_hours_enabled: true # Master toggle for quiet hours feature
|
||||
quiet_hours_start: "22:00" # Suppress non-emergency alerts during quiet hours
|
||||
quiet_hours_end: "06:00"
|
||||
|
||||
# Digest scheduler settings
|
||||
# The digest collects priority/routine events and delivers a summary
|
||||
|
|
@ -250,7 +256,6 @@ notifications:
|
|||
delivery_type: mesh_broadcast
|
||||
broadcast_channel: 0
|
||||
cooldown_minutes: 5
|
||||
override_quiet: true # Send even during quiet hours
|
||||
|
||||
# Infrastructure Down - critical node and infrastructure offline alerts
|
||||
- name: "Infrastructure Down"
|
||||
|
|
@ -261,7 +266,6 @@ notifications:
|
|||
delivery_type: mesh_broadcast
|
||||
broadcast_channel: 0
|
||||
cooldown_minutes: 30
|
||||
override_quiet: false
|
||||
|
||||
# Fire Alert - wildfire proximity and new ignition
|
||||
- name: "Fire Alert"
|
||||
|
|
@ -272,7 +276,6 @@ notifications:
|
|||
delivery_type: mesh_broadcast
|
||||
broadcast_channel: 0
|
||||
cooldown_minutes: 60
|
||||
override_quiet: false
|
||||
|
||||
# Severe Weather - weather warnings
|
||||
- name: "Severe Weather"
|
||||
|
|
@ -283,7 +286,6 @@ notifications:
|
|||
delivery_type: mesh_broadcast
|
||||
broadcast_channel: 0
|
||||
cooldown_minutes: 30
|
||||
override_quiet: false
|
||||
|
||||
# Example: Morning Digest -> mesh broadcast
|
||||
# Delivers the accumulated digest at the configured schedule time
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue