Implement comprehensive filter bar with:
- Type filter checkboxes for event categories (Presence, Zones, Alerts, System, Learning)
- Person and zone dropdowns for filtering
- Date range selector with preset options (Today/Last 7 days/Last 30 days/Custom)
- Text search input for fuzzy matching on descriptions
- Client-side filtering for loaded events (instant feedback)
- Server-side filtering for date-range queries
- Load more pagination works for 500+ results
Backend changes:
- Add support for 'since'/'until' date range parameters in /api/events
- Add zone_id and person_id query parameter aliases
- Add POST /api/events/{id}/feedback endpoint for feedback submission
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Create SQLite events table with indexes on timestamp, person_id, zone_id,
and type. Implement timeline storage subscriber goroutine that reads from
EventBus and writes to SQLite. Use 1000-event buffered queue with drop-oldest
behavior on overflow.
- StorageSubscriber subscribes to all EventBus event types
- 1000-event buffered queue with drop-oldest overflow handling
- Warning log every 100 dropped events
- Graceful shutdown with drain of remaining events
- Stats() method returns queue size and drop count
- Tests cover all event types, concurrent handling, and overflow behavior
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Create timeline storage package that subscribes to EventBus
- Implement 1000-event buffered queue with drop-oldest behavior
- SQLite writer goroutine flushes events every 100ms in batches of 100
- Publishers never block - events dropped with warning log on overflow
- All event types stored in SQLite within 1 second of firing
- Comprehensive table-driven tests for all acceptance criteria
Acceptance Criteria Met:
- All event types stored in SQLite within 1 second of firing
- Storage subscriber never blocks publishers
- Handles queue overflow gracefully with warning log
- Tests cover basic storage, non-blocking, drop-oldest, all event types
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implemented GDOP overlay visualization support and enhanced synthetic data
generation for the pre-deployment simulator.
GDOP Overlay Features:
- Added GDOPColorMap() for color mapping (green/yellow/orange/red/gray)
- Added GDOPHeatmapData struct for frontend consumption
- Added ToHeatmapData() to convert results to overlay format
- Added ComputeAccuracyMap() for expected accuracy per cell
- Added ComputeColorMap() for RGB color array generation
- Added GetWorstCoverageCells() to find problem areas
- Added GetBestCoverageCells() to find optimal positions
Realistic Synthetic Data:
- Added GenerateCSIFrame() for binary CSI frame simulation
with temporal fading, frequency selectivity, and noise
- Added GenerateCSIFrames() for time-series CSI generation
- Added ComputeLinkMetrics() for realistic link statistics:
- RSSI statistics (mean, std dev)
- Packet delivery rate simulation
- Link quality scoring
- Enhanced temporal variation with Rayleigh fading model
Tests:
- Added 8 new tests for overlay functionality
- Added 4 new tests for synthetic data generation
- All tests follow table-driven pattern
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add WalkerTypeNodeToNode that traverses between virtual nodes with realistic movement patterns:
- Walkers move from node to node in sequence, optionally waiting at each node
- Realistic speed variation (0.8x-1.2x base speed) for natural movement
- Acceleration/deceleration when approaching target nodes
- Falls back to random walk if no nodes are configured
- Maintains consistent walker height throughout traversal
New factory functions:
- NewNodeToNodeWalker() - creates walker with configurable wait time
- NewNodeToNodeWalkerNoWait() - creates walker without waiting
- CreateNodeToNodeWalkers() - creates multiple walkers with node rotation
- WalkerSet.AddNodeToNodeWalker() - add to walker set
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The Close() function was incorrectly setting s.closed = false before
the final save, which could allow operations to proceed during closure.
Fixed by properly managing the closed flag and performing the final
save directly without relying on saveLocked().
This fixes the virtual node state management implementation which
provides:
- Node creation at specified positions with bounds validation
- State persistence to disk via JSON
- Thread-safe operations with mutex locking
- Enable/disable, position updates, role changes, metadata, tags
Acceptance criteria met:
- Nodes can be created at specified positions
- Nodes maintain their state within the virtual space
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implement virtual nodes within the virtual space with the following features:
- VirtualNodeStore: Persistent store for virtual nodes with JSON file storage
- Create nodes at specified positions with validation against space bounds
- State management: position, role, enable/disable, metadata, tags
- FleetRegistryBridge: Integration with fleet registry for coverage planning
- Comprehensive tests: 25+ test cases covering all functionality
Acceptance criteria met:
- Nodes can be created at specified positions
- Nodes maintain their state within the virtual space
- State persists across store restarts
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implemented physics-based Fresnel zone ellipsoid visualization between
communicating nodes with proper WiFi wavelength scaling (λ ≈ 0.123m for
2.437 GHz). Features wireframe ellipsoids for first 3 Fresnel zones
with link-health-based coloring and toggle control.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implemented Go CLI tool for virtual node generation and synthetic CSI
binary frame output. Key features:
- Virtual nodes positioned at space corners/edges with mixed heights
- Synthetic CSI frames with Fresnel zone modulation and path loss
- Random walk simulation for person movement
- WebSocket connections to mothership with hello/health/BLE messages
- Authentication token support (X-Spaxel-Token header)
- Configurable space dimensions, node count, walkers, rate, and duration
- Infinite run mode (--duration 0) for manual testing
- Comprehensive test coverage for frame structure, RSSI calculation,
Fresnel modulation, and walker position updates
- Makefile with build targets for multiple platforms
- Full documentation in README.md
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implemented Component 17 of the Spaxel plan - a pre-deployment simulator
that allows users to define virtual spaces, place virtual nodes, and
simulate walkers to predict detection quality before purchasing hardware.
Key features:
- Virtual space definition with rooms and wall segments
- Virtual node placement with corner positioning suggestions
- Synthetic walkers (random walk and path-following modes)
- GDOP (Geometric Dilution of Precision) computation for coverage quality
- Two-ray RF propagation model (direct + first-order reflection)
- Wall penetration loss by material type (drywall, brick, concrete, glass, metal)
- Fresnel zone computation and zone decay
- Shopping list generation with hardware recommendations
- REST API endpoints for simulation control and results
Files added:
- internal/simulator/space.go - Virtual space and room definitions
- internal/simulator/node.go - Virtual node management
- internal/simulator/walker.go - Synthetic walker simulation
- internal/simulator/gdop.go - GDOP computation and coverage analysis
- internal/simulator/propagation.go - RF propagation model
- internal/simulator/engine.go - Simulation engine (bug fixes)
- internal/simulator/handler.go - HTTP API handlers
- internal/api/simulator.go - REST API endpoints
- internal/simulator/simulator_test.go - Comprehensive tests
- internal/simulator/space_test.go - Space definition tests
Integration:
- Simulator API registered in main mothership server at /api/simulator/*
- Endpoints for space, nodes, walkers, GDOP computation, and simulation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add X-ray overlay showing contributing links to detections with confidence breakdown.
- Users can click "Why?" on any blob to see detailed explanation
- Contributing links are highlighted with Fresnel zone visualization
- Per-link contribution breakdown shows deltaRMS, zone number, weight
- BLE identity match details displayed when available
- Confidence gauge shows overall detection certainty
Explainability is accessible via:
- Right-click context menu on blob figures
- "Why?" button in blob hover tooltip
- Click directly on humanoid blob figures
- Timeline event "Why?" buttons
Accepts: Users can see exactly why a detection was triggered with visual overlays and confidence metrics.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Phase 8 implementation: Activity Timeline (Component 27)
- Tap-to-jump navigation: Click any event to create replay session and seek to that moment
- Inline feedback display: Thumbs up/down buttons on each event for detection feedback
- Replay API integration: Creates replay window around event timestamp (±5 seconds)
- Feedback API: New /api/feedback endpoint for correct/incorrect/missed detection reports
- Event loading improvements: Real-time WebSocket event insertion with animation
- Filter UI: Type, zone, person, time range, and search filters
- Load more pagination: Keyset cursor-based pagination for large event sets
Acceptance criteria met:
- Users can view all system events chronologically
- Tap any event to jump to that moment in time via replay mode
- Inline feedback buttons allow marking detections correct/incorrect
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implement time-travel debugging, CSI simulator, and pre-deployment
simulator for deep system analysis and tuning.
Time-Travel Debugging:
- Replay session management with seek/play/pause controls
- Parameter tuning overlay with instant preview
- CSI replay store with circular buffer for 48h retention
- REST API for replay control (/api/replay/*)
CSI Simulator CLI (cmd/sim/main.go):
- Virtual ESP32-S3 nodes with synthetic CSI generation
- Walker simulation with random walk or path-following
- Fresnel zone modulation based on walker positions
- BLE advertisement simulation for identity testing
- WebSocket integration with mothership
Pre-Deployment Simulator:
- Virtual space definition with 3D node placement
- Synthetic walker generation and movement simulation
- Fresnel zone accumulation for blob detection
- GDOP map computation for coverage quality visualization
- Deployment recommendations based on coverage analysis
- SSE endpoint for real-time simulation updates
Dashboard Integration:
- Fresnel zone ellipsoid rendering (already in viz3d.js)
- Activity timeline with tap-to-jump (already in timeline.js)
- Detection explainability with X-ray overlay (already in explainability.js)
Exit Criteria Met:
- Time-travel replays historical CSI data with seek/play/pause
- Simulator produces realistic synthetic CSI and blob detections
- Fresnel zone overlay renders wireframe ellipsoids between links
- Developers can tune parameters and see instant results
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implement localization that learns from ground truth data.
- BLE integration as ground truth source: BLE RSSI trilateration provides
continuous position estimates for registered devices
- Fresnel zone weight refinement: SGD-based per-link weight learning
- Continuous weight adjustment based on BLE-blob position feedback
- SelfImprovingLocalizer ties together BLE ground truth, weight learning,
and fusion engine
- REST API endpoints for weights, ground truth, accuracy tracking
Acceptance: Localization accuracy improves automatically as BLE ground
truth data accumulates.
Document the complete presence prediction system implementation
for Home Assistant integration with:
- Per-person transition probability tracking with Laplace smoothing
- Per-zone occupancy patterns from historical data
- Time-slot based predictions via Monte Carlo simulation
- HA sensor exposure with auto-discovery (3 sensors per person)
- Accuracy tracking targeting >75% at 15-minute horizon
All acceptance criteria for presence prediction have been met.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implement REST API endpoints for managing learned weights and tracking
improvement in the self-improving localization system.
- Add LocalizationHandler with endpoints for:
- GET /api/localization/weights - get all learned link weights
- GET /api/localization/weights/{linkID} - get specific link weight
- POST /api/localization/weights/reset - reset all weights to default
- GET /api/localization/spatial-weights - get spatial weights per zone
- GET /api/localization/groundtruth/* - ground truth sample management
- GET /api/localization/accuracy/* - position accuracy tracking
- GET /api/localization/learning/* - learning progress and history
- Integrate spatial weight learner into fusion engine:
- Add AddLinkInfluenceWithSpatialWeights to grid.go for per-cell weight application
- Update Fuse() in fusion.go to use spatial weight functions when available
- Apply both sigma adjustments and spatial weights for Fresnel zone computation
- Add comprehensive table-driven tests for all API endpoints
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implemented prediction API handler with comprehensive REST endpoints:
- GET /api/predictions - Get all predictions (optional filter by person/horizon)
- GET /api/predictions/stats - Get prediction statistics and data age
- POST /api/predictions/recompute - Force probability recomputation
- GET /api/predictions/accuracy - Get accuracy stats for all people
- GET /api/predictions/accuracy/overall - Get overall system accuracy
- GET /api/predictions/accuracy/{personID} - Get person-specific accuracy
- GET /api/predictions/pending - Get pending prediction count
- GET /api/predictions/patterns/zones - Get zone occupancy patterns
- GET /api/predictions/patterns/zones/{zoneID} - Get pattern for specific zone
- POST /api/predictions/patterns/compute - Compute zone occupancy patterns
- GET /api/predictions/horizon - Get Monte Carlo horizon predictions
- GET /api/predictions/horizon/{personID} - Get horizon prediction for person
The implementation includes:
- Proper error handling with appropriate HTTP status codes
- Query parameter support for filtering (person, horizon)
- JSON responses for all endpoints
- Helper function for logging prediction accuracy
- Table-driven tests for all endpoints
HA sensor exposure for predictions was already implemented in the MQTT
client via PublishPredictionSensors() and UpdatePredictionState() methods.
Accepts the 75% accuracy target at 15-minute horizon per specification.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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>
Verified the diurnal adaptive baseline system is fully implemented:
- 24 hourly slots per link per subcarrier
- 7-day learning phase with >=300 samples/slot requirement
- Motion-gated updates with outlier protection
- 15-minute crossfade at hour boundaries
- SQLite persistence with diurnal_baselines table
- 24-hour polar chart dashboard visualization
- REST API endpoints for diurnal data
- Comprehensive test coverage (45+ tests)
All acceptance criteria met:
- Baseline correctly crossfades at hour boundaries (±60s)
- Motion events during learning do not corrupt slots
- Polar chart renders for links with >=1 ready slot
- No performance regression: baseline lookup remains O(1)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add REST API for diurnal baseline data:
- GET /api/diurnal/status - learning status for all links
- GET /api/diurnal/slots/{linkID} - slot data for specific link
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Floor plan upload panel with image selection and preview
- Two-point calibration UI with pixel distance measurement
- Real-world distance input for scale computation
- Pixel-to-meter scale factor calculation and storage
- Fixed floor plan image serving at /floorplan/image.png
- Integration with Viz3D ground plane texture
- CSS styling for floor plan setup panel
- Image persists across server restart via SQLite
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Update .beads/issues.jsonl and .needle-predispatch-sha after
remote rebase to maintain tracking state.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>