Commit Graph

77 Commits

Author SHA1 Message Date
Aaron D. Lee
4873d36194 fix: wire package/visitor events, bbox payloads, reel/timelapse scheduling
- Add `requests` to pyproject.toml dependencies (used by detection/weather.py)
- Wire PACKAGE_DELIVERED/REMINDER/COLLECTED and KNOWN/UNKNOWN_VISITOR event
  types in EventProcessor._classify_event
- Add normalized bbox to all detection payloads in camera worker
  (domestic_animal, wildlife, person, vehicle)
- Integrate highlight reel and timelapse scheduling in HealthMonitor.run()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 19:18:38 -04:00
Aaron D. Lee
3289f874ab fix: critical review findings — constant-time PIN compare, redact security config, sunset sign
- Use hmac.compare_digest() in verify_pin() to prevent timing-based PIN oracle attacks
- Redact entire [security] section (pin_hash, recovery_passphrase_hash) from /api/config response
- Sunset sign fix was skipped: existing longitude - ha formula is correct per NOAA equations and verified by test_sunset_equator; longitude + ha produces sunrise, not sunset

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 19:18:14 -04:00
Aaron D. Lee
bdfadbb829 feat(Q6): timelapse generator, schedules, and web routes
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 19:08:29 -04:00
Aaron D. Lee
622af22642 feat(Q1): highlight reel event scoring and FFmpeg clip assembly
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 19:07:12 -04:00
Aaron D. Lee
b4dbb41624 feat(Q4): kiosk ambient mode with camera rotation, alert takeover, dimming
Add GET /kiosk/ambient route and standalone fullscreen template with
rotating camera snapshots (crossfade), top bar clock/date, pet status
bottom bar, SSE-driven alert takeover with HLS playback, configurable
screen dimming, and 6-hour auto-refresh.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 19:06:57 -04:00
Aaron D. Lee
d69bf6d6af feat(Q1,Q4): add HighlightsConfig, KioskConfig, HIGHLIGHT/TIMELAPSE triggers
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 19:06:08 -04:00
Aaron D. Lee
23d5bf062a feat(S3): visitors blueprint with profiles, visits, labeling, privacy controls
Add /visitors/ blueprint with REST API endpoints for listing profiles and
visits, labeling (with consent gate), household linking, ignore/unignore,
and cascading forget. Register blueprint in app.py. Add dashboard and profile
detail templates (Bootstrap 5 dark, tab navigation, fetch-based JS). All six
API tests pass (339 total).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 19:01:33 -04:00
Aaron D. Lee
a5ddc53cf0 feat(S3): FaceRecognizer with in-memory embedding matching
Add FaceRecognizer class that loads face encodings from the database,
supports runtime add_encoding(), and matches new encodings by L2 distance.
face_recognition import is deferred so the class works without dlib installed.
FaceResult dataclass carries profile_id, name, confidence, crop, and bbox.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 18:59:07 -04:00
Aaron D. Lee
5a438fdb32 feat(S3): face profile, embedding, and visit CRUD queries
Add create/get/update/delete_cascade for face_profiles, insert/get for
face_embeddings, and insert/get/get_active for visits. All seven query
functions covered by unit tests (327 passing).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 18:58:19 -04:00
Aaron D. Lee
37beb92467 feat(S3): face_profiles, face_embeddings, visits tables
Add three new SQLAlchemy Core tables to schema.py for visitor recognition:
face_profiles (identity store), face_embeddings (per-profile encodings),
and visits (arrival/departure log). Indexes on profile_id and arrived_at.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 18:57:29 -04:00
Aaron D. Lee
6b7adc1cb6 feat(S3): visitor event types, VisitorsConfig, face_recognition dependency
Add KNOWN_VISITOR, UNKNOWN_VISITOR, VISITOR_DEPARTED to EventType enum.
Add VisitorsConfig model to config.py and wire into VigilarConfig.
Add face_recognition>=1.3.0 under [face] optional-dependencies in pyproject.toml.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 18:56:55 -04:00
Aaron D. Lee
a44187d0f1 feat(S5): pet rule CRUD routes with validation and templates 2026-04-03 18:53:50 -04:00
Aaron D. Lee
931b453ba9 feat(S5): pet rule engine with condition evaluation and cooldown 2026-04-03 18:52:38 -04:00
Aaron D. Lee
fac51a7c8a feat(S5): pet rule CRUD query functions 2026-04-03 18:51:47 -04:00
Aaron D. Lee
533ed078f4 feat(S5): add pet_rules table schema 2026-04-03 18:51:04 -04:00
Aaron D. Lee
e91744ec84 feat(S5): add PET_RULE_TRIGGERED event type and rule config fields 2026-04-03 18:50:40 -04:00
Aaron D. Lee
cdc13e05f6 feat(Q5): package event queries and tracker state machine
Add insert/get/update queries for package_events table, and
notification content for PACKAGE_DELIVERED and PACKAGE_REMINDER events.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 18:47:40 -04:00
Aaron D. Lee
31757f410a feat(Q5): package delivery state machine with sunset-aware reminders
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 18:46:59 -04:00
Aaron D. Lee
8bf7900324 feat(Q3): wildlife journal blueprint with API routes and template
Add wildlife_bp with sightings, stats, frequency, and CSV export
endpoints; Bootstrap 5 dark journal template with live-updating
summary cards, species bars, time-of-day frequency chart, and
paginated/filterable sightings table.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 18:46:32 -04:00
Aaron D. Lee
afc15a92fe feat(Q2): add heatmap route to cameras blueprint
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 18:46:27 -04:00
Aaron D. Lee
8c2a8ea1c5 feat(Q3): wildlife journal query functions
Add get_wildlife_sightings_paginated, get_wildlife_stats, and
get_wildlife_frequency to queries.py with full test coverage.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 18:46:25 -04:00
Aaron D. Lee
66a53f0cd8 feat(Q2): heatmap generation with bbox accumulation and colormap
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 18:46:00 -04:00
Aaron D. Lee
7ccd818a93 feat(Q3): Open-Meteo weather fetcher with hourly caching 2026-04-03 18:42:52 -04:00
Aaron D. Lee
e75a9a9d71 feat(Q5): NOAA sunset calculator (stdlib only) 2026-04-03 18:42:26 -04:00
Aaron D. Lee
a5dd15d0a1 feat(Q5): add package event types and package_events table 2026-04-03 18:41:31 -04:00
Aaron D. Lee
38ff219364 feat(Q3): add temperature, conditions, bbox columns to wildlife_sightings 2026-04-03 18:40:55 -04:00
Aaron D. Lee
4097ee9dd3 feat(Q3): add LocationConfig for latitude/longitude 2026-04-03 18:40:36 -04:00
Aaron D. Lee
7cec13e70e feat(F3): add hls.js v1.5.17 library
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 18:36:58 -04:00
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