spaxel/mothership/internal/analytics
jedarden 15c491ffea feat: implement anomaly detection and security mode
Implements comprehensive anomaly detection system that learns normal household
patterns over 7+ days and alerts on deviations. Transforms spaxel into a basic
home security system.

Core features:
- Normal behaviour model: statistical tracking of occupancy patterns per
  (hour_of_week, zone_id) slot with expected occupancy, typical person count,
  and typical BLE devices
- Four anomaly types: unusual hour presence, unknown BLE device, motion during
  away mode, unusual dwell duration
- Security mode: lowered thresholds, immediate alerts, bypasses quiet hours
- Auto-away/disarm: automatic security mode activation based on BLE device
  presence (15min absence, auto-disarm on device return)
- Alert chain: staged notifications (dashboard → push → webhook → escalation)
- WebSocket integration: real-time anomaly broadcasts to dashboard

API endpoints:
- GET/POST /api/mode: system mode control (home/away/sleep)
- GET /api/security/status: current security state

Tests cover all anomaly types, alert chain timing, security mode thresholds,
auto-away/disarm, acknowledgement flow, and cooldown deduplication.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-09 09:48:44 -04:00
..
alert_handler.go test: add comprehensive tests for auto-away/disarm and system mode endpoints 2026-04-09 07:26:34 -04:00
anomaly.go feat: implement anomaly detection and security mode 2026-04-09 09:48:44 -04:00
anomaly_test.go feat: implement 7-day pattern learning algorithm for anomaly detection 2026-04-06 21:27:10 -04:00
flow.go feat: complete anomaly detection & security mode dashboard UI 2026-04-09 05:59:54 -04:00
flow_test.go feat(localization): implement self-improving localization with BLE ground truth 2026-03-29 20:11:22 -04:00
handler.go feat: wire anomaly detection & security mode API endpoints 2026-04-07 14:47:44 -04:00
patterns.go feat: implement 7-day pattern learning algorithm for anomaly detection 2026-04-06 21:27:10 -04:00
patterns_test.go feat: implement 7-day pattern learning algorithm for anomaly detection 2026-04-06 21:27:10 -04:00