Commit Graph

49 Commits

Author SHA1 Message Date
Aaron D. Lee
c3c743ec74 feat(F1): configure syslog audit logging for vigilar.alerts
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 18:36:57 -04:00
Aaron D. Lee
f33b82cc83 feat(F1): integrate Web Push notifications into event processor
Import send_alert into processor.py, store engine as self._engine after
init_db(), extend _execute_action() to accept event_type/severity/source_id
and call send_alert for alert_all and push_and_record actions, and pass
those params from _handle_event().

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 18:01:11 -04:00
Aaron D. Lee
2c79e0c044 feat(F1): notification content mapping and Web Push sender
Add vigilar/alerts/sender.py with _CONTENT_MAP for human-readable push
notification titles/bodies, build_notification(), and send_alert() which
retrieves VAPID key, iterates push subscriptions, calls pywebpush, and
logs results to alert_log with auto-cleanup of expired (410) endpoints.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 18:01:07 -04:00
Aaron D. Lee
602945e99d feat(F2): recording list, download (decrypt), and delete API
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 17:42:35 -04:00
Aaron D. Lee
1b7f77b298 feat(F2): integrate AES-256-CTR encryption into AdaptiveRecorder
After FFmpeg finishes writing, _stop_ffmpeg() now reads VIGILAR_ENCRYPTION_KEY
and encrypts the MP4 to .vge format via encrypt_file(), updating the returned
RecordingSegment to reflect the encrypted file path and size.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 17:41:39 -04:00
Aaron D. Lee
e630c206b2 feat(F4): PIN verification on arm/disarm + reset-pin endpoint
Adds PIN checking to arm/disarm endpoints using verify_pin() against
cfg.security.pin_hash, and a new POST /system/api/reset-pin endpoint
that verifies the recovery passphrase before updating the PIN hash.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 17:40:01 -04:00
Aaron D. Lee
f8d28cf78e feat(F2): AES-256-CTR encryption module for recordings
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 17:39:40 -04:00
Aaron D. Lee
0544f7218a feat(F4): add SecurityConfig model to VigilarConfig 2026-04-03 17:38:10 -04:00
Aaron D. Lee
3f2a59c11e feat(F4): add PIN hashing utilities with PBKDF2-SHA256 2026-04-03 17:37:42 -04:00
Aaron D. Lee
2c72743bec Add visitor recognition design spec (S3)
Local face recognition with visitor profiles, unknown clustering,
household presence integration, and privacy-first opt-in model.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 15:32:12 -04:00
Aaron D. Lee
f530f26530 Add pet lifestyle rules engine design spec (S5)
Per-pet configurable rules with conditions (zone, time, presence)
and actions (push, log, record). Walk tracker, missing pet, on-the-loose
detection via composable rule builder UI.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 15:27:48 -04:00
Aaron D. Lee
93492e33d8 Add daily delight design spec (Q1, Q4, Q6)
Highlight reel video, kiosk ambient mode for magic picture frame,
and on-demand time-lapse generator with scheduling.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 15:20:20 -04:00
Aaron D. Lee
1338f7213d Add detection intelligence design spec (Q2, Q3, Q5)
Activity heatmaps, wildlife journal with weather correlation,
and package detection with sunset-aware reminders.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 15:14:04 -04:00
Aaron D. Lee
c9904648fa Add foundation plumbing design spec (F1-F4)
Notification delivery, recording playback/encryption, HLS.js bundle,
and PIN verification with recovery passphrase.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 14:38:29 -04:00
Aaron D. Lee
6436076c8a Merge feature/pet-aware-security into main
Pet detection (YOLOv8), pet ID classifier (MobileNetV3-Small),
wildlife threat-tiered alerting, pet dashboard, training UI,
and recording labeling overlay.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 13:53:10 -04:00
Aaron D. Lee
042aad08ec Fix unused variable in train_model endpoint
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 13:49:50 -04:00
Aaron D. Lee
0b82105179 Fix minor issues: enum types, backup path, JS URLs, status field, timestamp docs
- CameraConfig.location now uses CameraLocation enum (Pydantic v2 coerces TOML strings)
- Wildlife classifier returns ThreatLevel enum values with correct return type annotation
- Model backup path fixed: pet_id_backup.pt instead of pet_id.backup.pt
- Dashboard submitLabel JS now posts to /pets/<sighting_id>/label matching Flask route
- Pet status API computes status field (safe/unknown) based on last-seen recency
- digest.py comment explains timestamp unit difference between tables

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 13:49:20 -04:00
Aaron D. Lee
9858738e82 Fix web blueprint: security, stubs, dashboard context, upload validation
- Pass pets list to dashboard template (Critical 3)
- Sanitize upload filenames with werkzeug secure_filename (Important 6)
- Validate image extension against allowlist (Important 7)
- 404 check for pet existence in upload and update endpoints (Important 8)
- Save uploads to training/{pet_name}/ not training/{pet_id}/ (Important 11)
- Wire /train to PetTrainer with background thread (Important 12)
- Wire /api/training-status to stored trainer status (Important 13)
- Implement /api/highlights from sightings + wildlife queries (Important 14)
- Cap limit param at 500 on sightings and wildlife endpoints (Important 15)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 13:48:38 -04:00
Aaron D. Lee
6771923585 Wire detection pipeline: throttle YOLO, save crops, insert sightings, route person/vehicle
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 13:46:38 -04:00
Aaron D. Lee
c77f732ac7 Differentiate PET_ESCAPE and UNKNOWN_ANIMAL events by zone and identity
Replace the flat pet/detected handler with context-aware classification:
unknown animals (no pet_id) → UNKNOWN_ANIMAL/WARNING, known pets in
exterior/transition zones → PET_ESCAPE/ALERT, known pets indoors →
PET_DETECTED/INFO. Adds four new unit tests covering all three paths.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 13:45:15 -04:00
Aaron D. Lee
713d16d445 Fix lint issues in pet detection integration
- Import PetsConfig directly instead of forward ref string
- Fix import sorting in worker.py, queries.py, constants.py
- Remove unused imports in profiles.py, trainer.py, processor.py

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 13:32:17 -04:00
Aaron D. Lee
4274d1373f Add pet labeling UI overlay to recording playback
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 13:30:52 -04:00
Aaron D. Lee
32955bc7e4 Add pets dashboard template with Bootstrap 5 dark theme 2026-04-03 13:30:07 -04:00
Aaron D. Lee
94c5184f46 Add pets web blueprint with API endpoints
Implements all /pets/* routes (register, status, sightings, wildlife,
unlabeled crops, label, upload, update, delete, train, training-status,
highlights), registers the blueprint in app.py, adds a placeholder
dashboard template, and covers the API with 11 passing unit tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 13:27:46 -04:00
Aaron D. Lee
2b3a4ba853 Add pet and wildlife counts to daily digest
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 13:24:33 -04:00
Aaron D. Lee
547193fd79 Add ultralytics and torchvision dependencies for pet detection 2026-04-03 13:23:23 -04:00
Aaron D. Lee
45007dcac2 Add crop manager for staging and training image lifecycle
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 13:22:26 -04:00
Aaron D. Lee
4c9ebe029d Integrate YOLOv8 detection and pet ID into camera worker 2026-04-03 13:22:25 -04:00
Aaron D. Lee
d0acf7703c Handle pet and wildlife events in event processor 2026-04-03 13:20:46 -04:00
Aaron D. Lee
53daf58c78 Add camera_location filtering to alert profile matching
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 13:20:37 -04:00
Aaron D. Lee
e48ba305ea Add pet ID model trainer with MobileNetV3-Small transfer learning
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 13:19:12 -04:00
Aaron D. Lee
c7f9304f2a Add pet ID classifier with species-filtered identification
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 13:18:42 -04:00
Aaron D. Lee
13b7c2a219 Add wildlife threat classification with size heuristics
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 13:17:21 -04:00
Aaron D. Lee
131eed73b1 Add YOLOv8 unified detector with class classification
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 13:15:31 -04:00
Aaron D. Lee
d83710b839 Add pet and wildlife database query functions
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 13:13:56 -04:00
Aaron D. Lee
ea092bca10 Add pets, pet_sightings, wildlife_sightings, pet_training_images tables
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 13:11:01 -04:00
Aaron D. Lee
4ca06651b6 Fix import sort order in config.py (ruff I001)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 13:08:59 -04:00
Aaron D. Lee
6e3ef1dcdc Add pet detection, wildlife, and activity config models
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 13:08:40 -04:00
Aaron D. Lee
aae857ec53 Add pet/wildlife enums, event types, and MQTT topics
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 13:07:09 -04:00
Aaron D. Lee
767bbf26ba Add .worktrees/ and .superpowers/ to .gitignore
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 13:02:10 -04:00
Aaron D. Lee
0c0f484cdf Add pet-aware security features implementation plan
18 tasks covering: YOLOv8 detector, pet ID classifier, wildlife threat
classification, crop management, alert integration, web UI, and training.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 13:00:45 -04:00
Aaron D. Lee
4b8da811df Add pet-aware security features design spec
Covers pet detection (YOLOv8), pet ID classifier, wildlife threat
tiers, zone-based alerting, training UI, and pet dashboard.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 12:50:14 -04:00
Aaron D. Lee
11d776faa6 Add smart alert profiles and recording timeline (Tasks 4-5)
Task 4 — Alert Profiles: presence-aware + time-of-day alert routing.
Profiles match household state (EMPTY/KIDS_HOME/ADULTS_HOME/ALL_HOME)
and time windows (sleep hours). Per-detection-type rules control
push/record/quiet behavior with role-based recipients (all vs adults).

Task 5 — Recording Timeline: canvas-based 24h timeline per camera
with color-coded segments (person=red, vehicle=blue, motion=gray).
Click-to-play, date picker, detection type filters, hour markers.
Timeline API endpoint returns segments for a camera+date.

All 5 daily-use feature tasks complete. 140 tests passing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 00:09:08 -04:00
Aaron D. Lee
8314a61815 Add presence detection, person/vehicle AI detection, health monitoring
Task 1 — Presence: ping family phones, derive household state
(EMPTY/KIDS_HOME/ADULTS_HOME/ALL_HOME), configurable departure delay,
per-member roles, auto-arm actions via MQTT.

Task 2 — Detection: MobileNet-SSD v2 via OpenCV DNN for person/vehicle
classification. Vehicle color/size fingerprinting for known car matching.
Zone-based filtering per camera. Model download script.

Task 3 — Health: periodic disk/MQTT/subsystem checks, auto-prune oldest
non-starred recordings on disk pressure, daily digest builder.

126 tests passing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 00:06:45 -04:00
Aaron D. Lee
8a65ac8c69 Add implementation plan for daily use features
5-task plan covering presence detection, person/vehicle AI detection,
smart alert profiles, recording timeline UI, and health monitoring.
Tasks 1-3 parallelizable, 4 depends on 1+2, 5 depends on 2.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 00:01:53 -04:00
Aaron D. Lee
53ae925a70 Add daily use features design spec
Spec covers 5 feature areas for making Vigilar a system a household
relies on daily: multi-person presence detection, MobileNet person +
vehicle detection with driveway fencing, smart alert profiles with
presence/time awareness, recording timeline UI, and health monitoring
with auto-prune and daily digest.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 23:42:29 -04:00
Aaron D. Lee
ebcc49b474 Add kiosk setup and deployment scripts (Phases 5 + 9)
Phase 5 — RPi Kiosk:
- setup_kiosk.sh: full RPi OS Lite setup (X11, Chromium kiosk mode,
  auto-login, DPMS disabled, GPU memory split, screen rotation)
- kiosk.service: systemd unit for reliable auto-start
- update_kiosk.sh: reconfigure URL/rotation/resolution without re-setup
- Handles both Bullseye and Bookworm RPi OS versions

Phase 9 — Hardening + Deployment:
- install.sh: full server setup (apt/pacman, vigilar user, venv,
  directories, permissions, mosquitto config, systemd units)
- gen_cert.sh: TLS cert via mkcert or openssl fallback
- gen_vapid_keys.sh: VAPID keys for Web Push notifications
- setup_nut.sh: NUT configuration with USB UPS auto-detection
- backup.sh: SQLite snapshot + config archive, cron-ready
- uninstall.sh: clean removal with data preservation option
- vigilar.service: hardened systemd unit (ProtectSystem, NoNewPrivileges,
  PrivateTmp, syscall filtering)
- vigilar-mosquitto.conf: localhost-only MQTT broker config

All scripts idempotent, bash -n validated, support Debian + Arch.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 23:25:03 -04:00
Aaron D. Lee
10b0cf4d0e Add events/rules engine, sensor bridge, and UPS monitor (Phases 6-8)
Phase 6 — Events + Rule Engine:
- EventProcessor subprocess: subscribes to all MQTT events, logs to DB,
  evaluates rules, fires alert actions
- ArmStateFSM: DISARMED/ARMED_HOME/ARMED_AWAY with PIN verification
  (HMAC-safe), DB persistence, MQTT state publishing
- RuleEngine: AND/OR logic, 4 condition types (arm_state, sensor_event,
  camera_motion, time_window), per-rule cooldown tracking
- SSE event stream with subscriber queue pattern and keepalive
- Event acknowledge endpoint

Phase 7 — Sensor Bridge:
- SensorBridge subprocess: subscribes to Zigbee2MQTT, normalizes payloads
  (contact, occupancy, temperature, humidity, battery, linkquality)
- GPIOHandler: conditional gpiozero import, callbacks for reed switches
  and PIR sensors
- SensorRegistry: maps Zigbee addresses and names to config sensor IDs
- SensorEvent/SensorState dataclasses
- Web UI now shows real sensor states from DB

Phase 8 — UPS Monitor:
- UPSMonitor subprocess: polls NUT via pynut2 with reconnect backoff
- State transition detection: OL→OB (power_loss), charge/runtime
  thresholds (low_battery, critical), OB→OL (restored)
- ShutdownSequence: ordered shutdown with configurable delay and command
- All conditionally imported (pynut2, gpiozero) for non-target platforms

Fixed test_db fixture to use isolated engines (no global singleton leak).
96 tests passing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 23:17:53 -04:00
Aaron D. Lee
845a85d618 Initial commit: Vigilar DIY home security system
Phase 1 (Foundation): project skeleton, TOML config + Pydantic validation,
MQTT bus wrapper, SQLite schema (9 tables), Click CLI, process supervisor.

Phase 2 (Camera): RTSP capture via OpenCV, MOG2 motion detection with
configurable sensitivity/zones, adaptive FPS recording (2fps idle/30fps
motion) via FFmpeg subprocess, HLS live streaming, pre-motion ring buffer.

Phase 3 (Web UI): Flask + Bootstrap 5 dark theme, 6 blueprints, Jinja2
templates (dashboard, kiosk 2x2 grid, events, sensors, recordings, settings),
PWA with service worker + Web Push, full admin settings UI with config
persistence.

Remote Access: WireGuard tunnel configs, nginx reverse proxy with HLS
caching + rate limiting, bandwidth-optimized remote HLS stream (426x240
@ 500kbps), DO droplet setup script, certbot TLS.

29 tests passing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 23:11:27 -04:00