meshai/tests
Matt Johnson (via Claude) 31e543ca04 feat(v0.7-fire-tracker-3): spotting detection -- pixels beyond perimeter trigger immediate broadcast
Phase 3 of FIRMS+WFIGS fusion. v15.sql adds perimeter_geojson to
fire_passes + last_spotting_broadcast_at to fires. FIRMS handler
computes convex hull of each pass on pass-boundary close; attributed
pixels >= 1.5 mi (configurable) from previous-pass perimeter emit
wildfire_spotting broadcast. Cooldown 1h between spotting broadcasts
per fire so rapid embers do not spam. wildfire_spotting category at
immediate severity -- spotting is the highest-actionable fire signal
(spread beyond perimeter). All thresholds GUI-editable. Phase 4 (LLM
summaries + on-demand queries) deferred.

Schema (v15.sql):
- fire_passes gains perimeter_geojson TEXT (nullable; populated by
  _close_prev_perimeter at boundary). GeoJSON Polygon, single outer
  ring in (lon, lat) order per RFC 7946, closed (first == last).
- fires gains last_spotting_broadcast_at REAL (per-fire cooldown
  latch). Index (irwin_id, last_spotting_broadcast_at) for the
  cooldown probe.

adapter_config (defaults.py REGISTRY):
- fires.spotting_distance_threshold_mi = 1.5 (float). Matches design
  doc Phase 3 spec; design doc open question #6 lists this as TBD
  pending real spotting observation data.
- fires.spotting_cooldown_seconds = 3600 (int, 1h). Suppresses
  rapid-ember spam from a single satellite pass.

ALERT_CATEGORIES (notifications/categories.py):
- wildfire_spotting: immediate / fire. Highest fire severity --
  spotting represents fire spread BEYOND the existing perimeter, the
  most actionable detection signal.

FIRMS handler (central/firms_handler.py):
- _handle_pass_boundary now closes the prior pass's perimeter (convex
  hull of fire_pixels via Andrew's monotone chain) on the first
  boundary; subsequent in-pass pixels reuse the stored hull.
- _check_spotting runs for every attributed pixel: looks up the most
  recent CLOSED pass (perimeter_geojson NOT NULL AND pass_id !=
  current), point-in-polygon test, vertex-distance approximation
  per design doc Q (sparse pixels make edge projection overkill at
  VIIRS 375 m resolution), per-fire cooldown gate.
- Priority order: spotting (immediate) > growth (priority) > cluster
  (priority) > halt (routine). Spotting preempts growth at the same
  pixel because immediate > priority.
- Helpers: _convex_hull (Andrew's monotone chain), _hull_to_geojson
  (RFC 7946 Polygon), _point_in_polygon (ray casting),
  _close_prev_perimeter, _check_spotting, _prev_has_perimeter.

Wire string:
- wildfire_spotting: "🔥 Possible spotting <dist:.1f> mi <dir> of
  <incident_name> perimeter" -- direction is 8-way bearing from the
  previous pass's centroid to the spotting pixel.

Tests (tests/test_fire_tracker_phase3.py, 11 cases all green):
- Pass close stamps perimeter_geojson as a closed Polygon (6 hex
  vertices -> 7-entry closed ring).
- Pixel 2 mi NE of perimeter fires spotting with distance in the
  1.0..2.5 mi band (vertex-distance approximation) and direction NE.
- Pixel inside perimeter -> NO spotting wire.
- Second spotting candidate within 1h cooldown -> suppressed.
- Past-cooldown spotting fires again.
- Convex hull / point-in-polygon / GeoJSON round-trip helper tests.
- adapter_config seed for both new fires.* keys.
- wildfire_spotting category registered with immediate severity.
- 49 tests green across phase1/phase2/phase3/or-arch/include-roundtrip.

Live verification on CT108 after rebuild:
- v15 migration applied (schema_meta=15, no Traceback in 3 min).
- Container healthy.

Synthetic 25-pixel probe (PROBE-V07P3-*, cleaned up after):
- Pass A: 20 pixels in a ~0.3 mi circle. Perimeter stored on boundary.
- Pass B: 5 pixels at distances 0.5/1.0/2.0/5.0/7.0 mi from center.
  Observed wires:
    "🔥 Possible spotting 1.7 mi NE of Probe Spotting Fire perimeter"
    "🔥 Possible spotting 4.7 mi NW of Probe Spotting Fire perimeter"
  (Plus a Phase 2 growth wire on the first pass B pixel -- documented
  side effect: single-pixel pass B centroid shows 0.5 mi drift from
  pass A.)
- 7.0 mi E pixel: outside 5 mi spread, no broadcast (cluster check
  found no co-located unattributed pixels). Cleanup confirmed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-06 06:43:22 +00:00
..
fixtures/central_envelopes feat(content): v0.5.8-state_511_atis -- central_normalizer with Photon nearest_town + composer bypass + SB->S route normalization 2026-06-04 21:38:40 +00:00
conftest.py feat(v0.6-3a): adapter_config foundation -- migration + defaults registry + typed accessor 2026-06-05 17:06:51 +00:00
test_adapter_avalanche.py feat(notifications): Phase 2.10 avalanche adapter pipeline integration 2026-05-27 23:08:24 +00:00
test_adapter_config_api.py feat(v0.6-tail): close 5 v0.6-phase1-complete.md follow-ups 2026-06-05 21:37:05 +00:00
test_adapter_config_foundation.py feat(v0.6-tail): close 5 v0.6-phase1-complete.md follow-ups 2026-06-05 21:37:05 +00:00
test_adapter_ducting.py feat(notifications): Phase 2.13 ducting adapter threshold-crossing emission (severity-tiered, Option C) 2026-05-28 00:01:40 +00:00
test_adapter_fires.py feat(notifications): Phase 2.11 NIFC fires adapter pipeline integration 2026-05-27 23:33:48 +00:00
test_adapter_firms.py fix(fire): v0.5.7-fire -- FIRMS NATS pattern + WFIGS tombstone dedup + remove fire_proximity + categories audit 2026-06-04 06:25:42 +00:00
test_adapter_nws.py feat(notifications): Phase 2.6 NWS adapter pipeline integration 2026-05-15 04:47:31 +00:00
test_adapter_roads511.py feat(notifications): Phase 2.8 roads511 adapter pipeline integration 2026-05-27 21:18:21 +00:00
test_adapter_swpc.py feat(notifications): Phase 2.12 SWPC space weather adapter + dedup fix 2026-05-27 23:41:30 +00:00
test_adapter_traffic.py feat(notifications): Phase 2.7 traffic adapter pipeline integration 2026-05-27 19:17:27 +00:00
test_adapter_usgs.py feat(notifications): Phase 2.9 usgs water adapter pipeline integration 2026-05-27 21:58:13 +00:00
test_adapter_usgs_quake.py feat(notifications): Phase 2.14 USGS earthquake adapter (new) -- closes Rule 16 Seismic standalone path 2026-05-28 00:10:39 +00:00
test_avalanche_v057.py fix(avalanche): v0.5.7-avalanche -- Central avalanche check + categories audit 2026-06-04 06:55:27 +00:00
test_band_conditions.py feat(v0.5.11): band conditions scheduled broadcaster (3x/day HF propagation) 2026-06-05 07:38:51 +00:00
test_central_consumer.py feat(v0.5.13): default-deny dispatcher -- consumer honors handler None returns, kill v0.5.7 regression at the root 2026-06-05 14:17:41 +00:00
test_central_envelope_to_wire_v057.py feat(v0.5.13): default-deny dispatcher -- consumer honors handler None returns, kill v0.5.7 regression at the root 2026-06-05 14:17:41 +00:00
test_central_normalizer.py feat(v0.5.9): unified incident pipeline + state_511_atis Idaho cutover + two-sided freshness gate 2026-06-05 06:41:21 +00:00
test_central_region_routing.py fix(water): v0.5.7-water -- USGS NWIS hydro NATS pattern + categories audit 2026-06-04 06:42:06 +00:00
test_central_sub_adapter_routing.py feat(v0.5.13): default-deny dispatcher -- consumer honors handler None returns, kill v0.5.7 regression at the root 2026-06-05 14:17:41 +00:00
test_channel_rendering.py feat(notifications): Phase 2.5b per-channel-type renderers 2026-05-15 04:25:44 +00:00
test_cold_start_grace.py feat(v0.5.8b): persistence foundation + WFIGS handler + universal cold-start grace 2026-06-05 03:54:04 +00:00
test_config_loader.py fix(notifications): Phase 2.16.1 unblock pipeline -- grouper flush + rules coercion + toggle warning 2026-05-28 00:36:13 +00:00
test_config_source_field.py feat(central): v0.4 C.1 Central connector backend (no-op until adapter source flipped) 2026-05-28 02:28:19 +00:00
test_consumer_default_deny.py feat(v0.6-1): FIRMS handler -- storage-only, closes silent-drop on central.fire.hotspot.> 2026-06-05 15:50:33 +00:00
test_curation.py feat(v0.6-4): gauge_sites + town_anchors curation tables + GUI CRUD 2026-06-05 20:19:13 +00:00
test_dashboard_config_save.py fix(dashboard): v0.4 C.2.1 -- route PUT /config to multi-file save_section (Rule 17 persistence unblocked) 2026-05-28 03:17:30 +00:00
test_dispatcher_persistence.py feat(v0.6-2): dispatcher state persistence -- cold-start, cooldowns, dedup LRU to SQLite 2026-06-05 16:35:40 +00:00
test_env_reporter.py feat(v0.6-5): env_reporter + router wiring + include_in_llm_context per-adapter toggle -- LLM gains read access to every adapter table via the existing mesh_reporter pre-rendered prompt-injection pattern 2026-06-05 20:11:40 +00:00
test_fire_tracker_phase1.py feat(v0.7-fire-tracker-2): movement analysis -- growth + halt detection 2026-06-06 06:12:36 +00:00
test_fire_tracker_phase2.py feat(v0.7-fire-tracker-2): movement analysis -- growth + halt detection 2026-06-06 06:12:36 +00:00
test_fire_tracker_phase3.py feat(v0.7-fire-tracker-3): spotting detection -- pixels beyond perimeter trigger immediate broadcast 2026-06-06 06:43:22 +00:00
test_fire_v057.py feat(v0.5.13): default-deny dispatcher -- consumer honors handler None returns, kill v0.5.7 regression at the root 2026-06-05 14:17:41 +00:00
test_firms_handler.py feat(v0.6-1): FIRMS handler -- storage-only, closes silent-drop on central.fire.hotspot.> 2026-06-05 15:50:33 +00:00
test_incident_handler.py feat(v0.6-tail): close 5 v0.6-phase1-complete.md follow-ups 2026-06-05 21:37:05 +00:00
test_include_roundtrip.py fix(v0.6-tail-4): register !include YAML tag constructor in config loader -- closes prod PUT 500 2026-06-06 04:37:24 +00:00
test_itd_511_work_zone.py feat(v0.5.9): unified incident pipeline + state_511_atis Idaho cutover + two-sided freshness gate 2026-06-05 06:41:21 +00:00
test_notification_toggles.py feat(v0.6-phase2): rip out quiet hours entirely -- dashboard toggle, config schema, pipeline checks. Per Matt's repeated feedback (saved as feedback-quiet-hours-trash.md): silent is better than ugly, mesh users who need a fire alert at 3 AM need it at 3 AM. No replacement. 2026-06-05 20:39:36 +00:00
test_nwis_handler.py feat(v0.6-4): gauge_sites + town_anchors curation tables + GUI CRUD 2026-06-05 20:19:13 +00:00
test_nws_dedup_relaxation.py feat(v0.6-phase3): reminder system + schema split + NWS dedup relaxation 2026-06-05 21:11:32 +00:00
test_nws_handler.py feat(v0.5.10): nws + usgs_quake + swpc handlers 2026-06-05 07:27:01 +00:00
test_or_arch_continuous.py feat(v0.6-tail-3): enforce OR-not-AND continuously -- close USGS direct-lookup leak + flag environmental config changes as restart-required 2026-06-06 03:51:10 +00:00
test_persistence.py feat(v0.5.8b): persistence foundation + WFIGS handler + universal cold-start grace 2026-06-05 03:54:04 +00:00
test_pipeline_digest.py fix(fire): v0.5.7-fire -- FIRMS NATS pattern + WFIGS tombstone dedup + remove fire_proximity + categories audit 2026-06-04 06:25:42 +00:00
test_pipeline_grouper.py fix(notifications): Phase 2.16.1 unblock pipeline -- grouper flush + rules coercion + toggle warning 2026-05-28 00:36:13 +00:00
test_pipeline_inhibitor_grouper.py fix(notifications): Phase 2.16.1 unblock pipeline -- grouper flush + rules coercion + toggle warning 2026-05-28 00:36:13 +00:00
test_pipeline_persistence.py feat(v0.6-6): inhibit_state + grouper_held persistence + ToggleFilter live-reload + Inhibitor/Grouper config knobs 2026-06-05 20:23:34 +00:00
test_pipeline_scheduler.py feat(notifications): Phase 2.5a channel interface unification 2026-05-15 03:45:27 +00:00
test_pipeline_skeleton.py chore(meshai): v0.5.5 -- cleanup bundle (gitignore env anchor, ducting health event_count, mesh_sources secret stripping, delete unused SeverityRouter) 2026-06-04 02:50:45 +00:00
test_pipeline_toggle_filter.py fix(fire): v0.5.7-fire -- FIRMS NATS pattern + WFIGS tombstone dedup + remove fire_proximity + categories audit 2026-06-04 06:25:42 +00:00
test_quake_handler.py feat(v0.5.10): nws + usgs_quake + swpc handlers 2026-06-05 07:27:01 +00:00
test_reminders.py feat(v0.6-phase3): reminder system + schema split + NWS dedup relaxation 2026-06-05 21:11:32 +00:00
test_renderers.py fix(notifications): v0.5.7-regression -- consumer title fallback uses registry name, mesh renderer drops [Family] prefix 2026-06-04 16:06:47 +00:00
test_rf_v057.py feat(v0.5.13): default-deny dispatcher -- consumer honors handler None returns, kill v0.5.7 regression at the root 2026-06-05 14:17:41 +00:00
test_router_env_scope.py feat(v0.6-5): env_reporter + router wiring + include_in_llm_context per-adapter toggle -- LLM gains read access to every adapter table via the existing mesh_reporter pre-rendered prompt-injection pattern 2026-06-05 20:11:40 +00:00
test_save_section_secret_preserve.py chore(meshai): v0.5.5 -- cleanup bundle (gitignore env anchor, ducting health event_count, mesh_sources secret stripping, delete unused SeverityRouter) 2026-06-04 02:50:45 +00:00
test_seismic_v057.py fix(seismic): v0.5.7-seismic -- USGS quake NATS pattern + severity=5 great-quake clamp + categories audit 2026-06-04 06:33:31 +00:00
test_swpc_handler.py feat(v0.5.10): nws + usgs_quake + swpc handlers 2026-06-05 07:27:01 +00:00
test_tail_followups.py feat(v0.6-tail): close 5 v0.6-phase1-complete.md follow-ups 2026-06-05 21:37:05 +00:00
test_tracking_v057.py fix(tracking): v0.5.7-tracking -- Central tracking check + categories audit 2026-06-04 07:00:22 +00:00
test_traffic_v057.py fix(traffic): v0.5.7-traffic -- NATS pattern fix + itd_511 sub-adapter routing + categories audit 2026-06-04 06:10:12 +00:00
test_v052_dispatcher.py feat(v0.5.8b): persistence foundation + WFIGS handler + universal cold-start grace 2026-06-05 03:54:04 +00:00
test_water_v057.py fix(water): v0.5.7-water -- USGS NWIS hydro NATS pattern + categories audit 2026-06-04 06:42:06 +00:00
test_weather_v057.py fix(weather): v0.5.7-weather -- NWS HTML strip + ALERT_CATEGORIES audit (NATS pattern already valid) 2026-06-04 06:00:10 +00:00
test_wfigs_handler.py feat(v0.5.8b): persistence foundation + WFIGS handler + universal cold-start grace 2026-06-05 03:54:04 +00:00
test_work_zone_renderer.py feat(content): v0.5.8-state_511_atis -- central_normalizer with Photon nearest_town + composer bypass + SB->S route normalization 2026-06-04 21:38:40 +00:00