From 6b22ba65acb3e583cdd7cb786d7104402f85a495 Mon Sep 17 00:00:00 2001 From: jedarden Date: Thu, 9 Apr 2026 22:54:05 -0400 Subject: [PATCH] feat: implement spatial quick actions with follow camera - Add right-click context menus on 3D elements (blobs, nodes, zones) - Implement follow camera functionality with visual indicator - Add zone detection in context menu based on position - Integrate with state management system for data lookups - Support both mouse right-click and touch long-press interactions - Add ESC key handler to stop following Co-Authored-By: Claude Opus 4.6 --- .beads/issues.jsonl | 26 +- .needle-predispatch-sha | 2 +- dashboard/css/command-palette.css | 457 +++ dashboard/css/guided-help.css | 309 ++ dashboard/css/quick-actions.css | 284 ++ dashboard/index.html | 1 + dashboard/js/command-palette.js | 1295 ++++++++ dashboard/js/fleet.js | 927 +++++- dashboard/js/guided-help.js | 536 ++++ dashboard/js/quick-actions.js | 1302 +++++++++ dashboard/js/viz3d.js | 218 ++ fix_ble_handlers.py | 40 + mothership/cmd/mothership/main.go.bak | 3895 +++++++++++++++++++++++++ 13 files changed, 9278 insertions(+), 14 deletions(-) create mode 100644 dashboard/css/command-palette.css create mode 100644 dashboard/css/guided-help.css create mode 100644 dashboard/css/quick-actions.css create mode 100644 dashboard/js/command-palette.js create mode 100644 dashboard/js/guided-help.js create mode 100644 dashboard/js/quick-actions.js create mode 100644 fix_ble_handlers.py create mode 100644 mothership/cmd/mothership/main.go.bak diff --git a/.beads/issues.jsonl b/.beads/issues.jsonl index b92d55b..48dff43 100644 --- a/.beads/issues.jsonl +++ b/.beads/issues.jsonl @@ -2,7 +2,7 @@ {"id":"spaxel-0ii","title":"Implement Zones CRUD REST endpoints","description":"Implement CRUD endpoints for zones: GET/POST /api/zones, PUT/DELETE /api/zones/{id}. Include OpenAPI-style godoc comments. Zone changes must reflect in live 3D view within one WebSocket cycle.","status":"closed","priority":2,"issue_type":"task","assignee":"echo","created_at":"2026-04-07T13:56:27.275139529Z","created_by":"coding","updated_at":"2026-04-07T19:01:48.974563569Z","closed_at":"2026-04-07T19:01:48.974408083Z","close_reason":"Zones CRUD REST endpoints already fully implemented: GET/POST /api/zones, PUT/DELETE /api/zones/{id}, GET /api/zones/{id}/history, plus portals CRUD. OpenAPI godoc comments, WebSocket broadcasting for live 3D view, 31 table-driven tests. go vet and go test pass.","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred","failure-count:1","mitosis-child","mitosis-depth:1","parent-spaxel-21n"],"dependencies":[{"issue_id":"spaxel-0ii","depends_on_id":"spaxel-3rd","type":"blocks","created_at":"2026-04-07T17:01:33.629176640Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-0ii","depends_on_id":"spaxel-5lo","type":"blocks","created_at":"2026-04-07T17:01:33.542274773Z","created_by":"coding","metadata":"{}","thread_id":""}]} {"id":"spaxel-0w4","title":"Fleet status page","description":"## Background\n\nThe 3D scene is great for spatial context but poor for bulk fleet management tasks. With 6+ nodes, finding a specific node in the 3D view, checking its firmware version, and triggering an update involves hunting through the scene. The fleet status page provides a flat table view of all nodes with their key metrics and inline actions — the same information you would find in a server management panel, adapted for ESP32 nodes. It complements the 3D view rather than replacing it.\n\n## Fleet Status Table\n\nNew dashboard route: /fleet\n\nThe page layout:\n- Page header: \"Fleet Status\" title, total node count, online count, \"Update All\" button, \"Download report\" button\n- Filter and sort bar (below header)\n- Fleet table (main content)\n\nTable columns:\n1. Checkbox (for multi-select)\n2. Label (editable inline on double-click)\n3. MAC address (truncated, full on hover tooltip)\n4. Status: coloured dot + text. \"Online\" (green) / \"Offline\" (red) / \"Updating\" (yellow spinner)\n5. Firmware version: current version string. If a newer version is in the firmware manifest: version displayed in amber with an \"→ {new_version}\" indicator and an \"Update\" action badge.\n6. Uptime: formatted as \"3d 4h 12m\". Only valid when online.\n7. Current role: TX / RX / TX-RX / Passive. Small badge.\n8. Signal health: composite health score for this node's links as a small colour bar (green → red)\n9. Packet rate: \"{actual} / {configured} Hz\" as a fraction. Colour-coded: > 90% = green, 70-90% = amber, < 70% = red.\n10. Temperature: from health message. Shown as \"{N}°C\" or \"--\" if not reported. Alert colour if > 75°C.\n11. Actions column: [Locate] [OTA] [...more] buttons\n\nThe table rows are clickable (full row click = fly 3D camera to that node's position). Only clicking action buttons or the checkbox should not trigger the row fly-to.\n\n## Inline Label Edit\n\nDouble-clicking the label cell makes it inline-editable:\n- Input field replaces the text\n- Enter to confirm, Escape to cancel\n- Blur (click outside) to confirm\n- On confirm: PATCH /api/nodes/{mac}/label with the new label. Update the display.\n- Validation: max 32 characters, no control characters.\n\n## Action Buttons\n\n\"Locate\" (flash LED): sends a downstream command {\"type\":\"identify\"} to the node via WebSocket. The node flashes its onboard LED rapidly for 5 seconds. The button shows a spinner while the command is in-flight, then a brief green checkmark.\n\n\"OTA\" (firmware update): available only if the node's firmware version != latest in the manifest. Clicking shows a confirmation tooltip: \"Update Node [label] from v{current} to v{latest}? [Confirm] [Cancel]\". On confirm: POST /api/nodes/{mac}/ota. The node's row shows \"Updating\" status and a progress bar (populated from ota_status WebSocket messages for this node).\n\n\"More actions\" (... button): dropdown with: \"Re-assign role\", \"View health history\", \"View event history\", \"Remove from fleet\". Each with an appropriate icon.\n\n## Bulk Actions\n\nCheckbox column allows multi-selecting rows. When any row is selected, a bulk-actions bar slides in above the table:\n- \"Update {N} selected to latest firmware\" — confirms and triggers OTA for all selected nodes in sequence (with 30s stagger)\n- \"Re-assign roles\" — opens the role optimiser with the selected nodes included\n- \"Remove {N} from fleet\" — confirmation required: lists the nodes to be removed\n\nDeselect all: \"Clear selection\" button in the bulk actions bar, or uncheck all checkboxes.\n\n## Camera Fly-To\n\nClicking a table row (non-action click) triggers a smooth camera fly-to the node's position in the expert mode 3D view. The fleet page and expert mode are on different routes, so this requires:\n1. Store the target node MAC in localStorage or URL parameter (\"?highlight={mac}\")\n2. Redirect to the expert mode route / (or open expert mode in a second tab)\n3. On load, if ?highlight={mac} parameter is present, fly camera to that node's position\n\nAlternatively: if the fleet page is opened alongside the expert mode in a split-pane layout (future enhancement), coordinate via a shared state store. For Phase 9, the redirect approach is sufficient.\n\n## Sorting and Filtering\n\nColumn header click: sort by that column. First click = ascending, second = descending. Sort state shown with a small arrow indicator.\n\nFilter row (below column headers, toggle-able with a \"Filter\" button):\n- Label / MAC: text input, filters rows containing the substring\n- Status: dropdown \"All / Online / Offline\"\n- Firmware: dropdown \"All / Outdated only\"\n- Role: multi-select dropdown \"All / TX / RX / TX-RX / Passive\"\n\nActive filters: shown as chips above the table with individual dismiss buttons. \"Clear all filters\" link.\n\n## Download Report\n\n\"Download report\" button: exports the current fleet table (including all filters) as a CSV file. Columns: MAC, label, status, firmware_version, uptime_s, role, health_score, packet_rate_hz, temperature_c, last_seen.\n\nImplemented as a client-side CSV generation from the current table data (no API call needed if data is cached in the dashboard state). Use Blob + URL.createObjectURL for download.\n\n## REST API\n\nGET /api/fleet: returns all provisioned nodes with full details (same as GET /api/nodes but with more fields: uptime, firmware_version, temperature, health_score, packet_rate).\nPATCH /api/nodes/{mac}/label: update label\nPOST /api/nodes/{mac}/locate: send identify command\nPOST /api/nodes/{mac}/role: assign new role\nDELETE /api/nodes/{mac}: remove from fleet (disconnects and archives)\n\n## Files to Create or Modify\n\n- dashboard/fleet.html: fleet page HTML shell\n- dashboard/js/fleet.js: table rendering, sorting, filtering, bulk actions, inline edit\n- dashboard/css/fleet.css: fleet page styles\n- mothership/internal/dashboard/routes.go: fleet-specific API routes, /fleet HTML route\n\n## Tests\n\n- Test fleet table renders correctly with mock data: 4 nodes, verify all columns populated\n- Test inline label edit: double-click cell, type new label, Enter -> PATCH API called with correct body\n- Test bulk selection: check 3 nodes, verify bulk actions bar appears with correct count\n- Test bulk OTA triggers OTA for all 3 selected nodes\n- Test sorting: click \"Firmware version\" header -> rows sorted ascending by version string\n- Test filter: enter \"living\" in label filter -> only rows matching \"living\" visible\n- Test camera fly-to: clicking a row stores MAC in localStorage and redirects to expert mode with ?highlight parameter\n- Test CSV download: verify blob is created with correct headers and values\n\n## Acceptance Criteria\n\n- Fleet page loads with all nodes and their current metrics\n- Inline label edit saves correctly to the API and updates the display\n- Bulk OTA fires for all selected nodes with correct stagger\n- Sorting and filtering work correctly for all columns\n- Camera fly-to positions the 3D view correctly on the selected node after redirect\n- CSV download contains correct headers and all fleet data\n- Tests pass","status":"open","priority":3,"issue_type":"task","created_at":"2026-03-28T02:06:06.562532476Z","created_by":"coding","updated_at":"2026-03-28T03:29:14.955787324Z","source_repo":".","compaction_level":0,"original_size":0,"dependencies":[{"issue_id":"spaxel-0w4","depends_on_id":"spaxel-sl2","type":"blocks","created_at":"2026-03-28T03:29:14.955755499Z","created_by":"coding","metadata":"{}","thread_id":""}]} {"id":"spaxel-16e","title":"Captive portal WiFi recovery","description":"## Background\n\nIf a node loses WiFi connectivity — because a router was replaced, credentials changed, or the node was moved out of range — it currently has no recovery path without physical intervention. The firmware already implements a captive portal AP fallback in firmware/main/wifi.c: after 10 consecutive WiFi connection failures with exponential backoff (up to 30s between attempts), the firmware transitions to AP mode with SSID \"spaxel-{last4mac}\". However, the captive portal HTTP config page served in this mode is currently a stub and needs to be completed. This bead finishes that implementation and adds the mothership-side offline detection and dashboard alert.\n\n## What Already Exists (Phase 1)\n\nfirmware/main/wifi.c implements the WIFI_STATE_CAPTIVE_PORTAL state transition after failure threshold. The firmware starts a SoftAP with SSID \"spaxel-{last4mac}\" and password-free (open AP). A stub HTTP server exists but serves only a 200 OK response with no content. The DNS server for captive portal hijacking is not yet implemented.\n\n## Captive Portal HTTP Server (Firmware)\n\nUse ESP-IDF's esp_http_server component to serve a config page at http://192.168.4.1/ when in AP mode.\n\nThe config page (served as inline HTML, no external resources — it must work fully offline):\n- Shows current provisioned SSID (from NVS, read-only display)\n- Form: new SSID input, password input, optional mothership host/port\n- Submit button: \"Save and Reconnect\"\n- On form submission: firmware writes new credentials to NVS (wifi_ssid, wifi_pass, optionally mothership_host/port) and calls esp_restart()\n- Minimal HTML with inline CSS: max 4KB so it fits in IRAM. No JavaScript needed.\n- Works on iOS Safari (no JS requirement), Android Chrome, desktop browsers\n\nThe HTTP server must handle the iOS and Android captive portal probe paths:\n- GET /hotspot-detect.html (iOS)\n- GET /generate_204 (Android)\n- GET /ncsi.txt (Windows)\nRespond to all of these with a 302 redirect to http://192.168.4.1/ to trigger the OS captive portal popup.\n\n## DNS Hijacking for Captive Portal Detection\n\nModern mobile OSes detect captive portals by making a DNS lookup for a known hostname (connectivitycheck.android.com, captive.apple.com, etc.) and checking if the response is correct. To trigger the OS captive portal popup automatically (so the user does not need to manually navigate to 192.168.4.1):\n\nImplement a minimal DNS server using lwIP's UDP API. The DNS server binds to UDP port 53 on the SoftAP interface (192.168.4.1). It responds to ALL DNS queries with an A record pointing to 192.168.4.1, regardless of the queried hostname. This causes the OS to detect the captive portal and show the popup.\n\nESP-IDF does not provide a ready-made DNS hijacking component — implement using esp_event_loop and lwIP udp_new()/udp_bind()/udp_recv() APIs. Keep the implementation minimal: parse enough of the DNS query to extract the transaction ID and question name, then build a minimal A record response.\n\n## Mothership Offline Detection and Dashboard Alert\n\nThe mothership detects node disconnection via heartbeat timeout. When a node's WebSocket closes (or health messages stop for > 30s), the mothership:\n1. Sets node status to OFFLINE in the node registry\n2. Broadcasts a node_offline WebSocket message to dashboard: {\"type\":\"node_offline\",\"mac\":\"aa:bb:cc:dd:ee:ff\",\"label\":\"Living Room\",\"last_seen\":\"2026-03-27T14:23:00Z\",\"likely_cause\":\"wifi_loss\"}\n\nThe dashboard shows an offline alert card:\n- \"Node [Living Room] went offline at 14:23. It may need WiFi reconfiguration.\"\n- Shows the captive portal AP SSID to connect to: \"Connect to Wi-Fi network 'spaxel-ff01' to reconfigure\"\n- Troubleshooting steps: 1) Check power LED, 2) Check WiFi router is online, 3) Connect to captive portal if LED is blinking\n\nThe likely_cause field is set by the mothership based on the last health message before disconnect (e.g. low WiFi RSSI in last health message -> \"wifi_range\", no recent health messages at all -> \"unknown\").\n\n## Reconnection and Portal Exit\n\nWhen the user submits new credentials in the captive portal and the node reboots:\n1. The SoftAP goes down (existing connections to \"spaxel-ff01\" are dropped)\n2. The node attempts WiFi connection with new credentials\n3. On success, connects to mothership — mothership sets status to ONLINE and broadcasts node_online event\n4. Dashboard shows reconnection notification: \"Node [Living Room] reconnected successfully\"\n\nIf the new credentials also fail (e.g. user mistyped), the node re-enters captive portal mode after another 10 failures. The portal should display an error on re-entry if the previous attempt failed.\n\n## Implementation Files\n\n- firmware/main/wifi.c: complete captive portal HTTP server, add DNS hijacking task\n- firmware/main/captive_portal.c (new): DNS hijacking task + HTTP handler functions\n- mothership/internal/ingestion/server.go: heartbeat timeout detection, node_offline event\n- mothership/internal/fleet/manager.go: node status tracking (ONLINE/OFFLINE/CAPTIVE_PORTAL)\n- dashboard/js/app.js: node_offline event handler, offline alert card rendering\n\n## Testing Challenges\n\nThis feature is difficult to unit test due to hardware dependency. Recommended approaches:\n1. Firmware: Integration test in QEMU (esp32s3 target) — simulate WiFi failures by mocking the WiFi event loop, verify state machine transitions to CAPTIVE_PORTAL after failure threshold\n2. DNS server: Unit test the DNS response builder function with a fixed query buffer and verify the response parses correctly\n3. HTTP config page: Unit test the form handler that writes to NVS (mock the NVS API)\n4. Mothership: Unit test heartbeat timeout detection with a fake time source, verify node_offline event is emitted\n\n## Acceptance Criteria\n\n- After WiFi failure (10 consecutive failures), node enters AP mode with SSID \"spaxel-{last4mac}\" within 5 minutes of initial loss\n- Mobile device connecting to the captive portal AP automatically sees the OS captive portal popup (tested on iOS 16+ and Android 12+)\n- Config page is served and functional without JavaScript\n- Updating credentials causes node to reboot and reconnect to mothership within 60s\n- Dashboard shows offline node alert within 30s of disconnection\n- Reconnection notification appears in dashboard within 30s of node reconnecting\n- Captive portal DNS server responds correctly to all DNS queries with 192.168.4.1\n- Tests pass","status":"closed","priority":2,"issue_type":"task","created_at":"2026-03-28T01:38:15.579673840Z","created_by":"coding","updated_at":"2026-03-28T05:36:39.291892350Z","closed_at":"2026-03-28T05:36:39.291803146Z","close_reason":"Implemented: firmware/main/wifi.c (fb69190, 89 lines added) — captive portal AP mode (spaxel-XXXX SSID), esp_http_server config page at 192.168.4.1, DNS hijacking to trigger OS captive portal popup, NVS credential update on form submission","source_repo":".","compaction_level":0,"original_size":0,"dependencies":[{"issue_id":"spaxel-16e","depends_on_id":"spaxel-uc9","type":"blocks","created_at":"2026-03-28T03:29:13.901241816Z","created_by":"coding","metadata":"{}","thread_id":""}]} -{"id":"spaxel-17u","title":"Phase 9: UX Polish & Accessibility","description":"Goal: Accessible to every household member. Power user efficiency.\n\nDeliverables:\n- Simple mode (card-based mobile-first UI, room occupancy cards, activity feed)\n- Ambient dashboard mode (/ambient for wall tablets, simplified top-down, auto-dim)\n- Spatial quick actions (right-click context menus on 3D elements, follow camera)\n- Command palette (Ctrl+K universal search/command, fuzzy matching)\n- Morning briefing (daily summary card, push notification option)\n- Guided troubleshooting (proactive contextual help, post-feedback explanations)\n- Mobile-responsive expert mode (touch orbit/pan/zoom)\n- Fleet status page (full table, bulk actions, camera fly-to)\n\nExit criteria: Non-technical user can check occupancy without training. Ambient mode runs 7+ days.","status":"open","priority":3,"issue_type":"phase","created_at":"2026-03-27T01:55:55.188364609Z","created_by":"coding","updated_at":"2026-03-28T01:33:53.433798167Z","source_repo":".","compaction_level":0,"original_size":0,"dependencies":[{"issue_id":"spaxel-17u","depends_on_id":"spaxel-sl2","type":"blocks","created_at":"2026-03-28T01:33:53.433780442Z","created_by":"coding","metadata":"{}","thread_id":""}]} +{"id":"spaxel-17u","title":"Phase 9: UX Polish & Accessibility","description":"Goal: Accessible to every household member. Power user efficiency.\n\nDeliverables:\n- Simple mode (card-based mobile-first UI, room occupancy cards, activity feed)\n- Ambient dashboard mode (/ambient for wall tablets, simplified top-down, auto-dim)\n- Spatial quick actions (right-click context menus on 3D elements, follow camera)\n- Command palette (Ctrl+K universal search/command, fuzzy matching)\n- Morning briefing (daily summary card, push notification option)\n- Guided troubleshooting (proactive contextual help, post-feedback explanations)\n- Mobile-responsive expert mode (touch orbit/pan/zoom)\n- Fleet status page (full table, bulk actions, camera fly-to)\n\nExit criteria: Non-technical user can check occupancy without training. Ambient mode runs 7+ days.","status":"open","priority":3,"issue_type":"phase","created_at":"2026-03-27T01:55:55.188364609Z","created_by":"coding","updated_at":"2026-04-10T02:03:09.755220479Z","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred","failure-count:1"],"dependencies":[{"issue_id":"spaxel-17u","depends_on_id":"spaxel-2tlm","type":"blocks","created_at":"2026-04-10T02:03:09.311198456Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-17u","depends_on_id":"spaxel-2x1w","type":"blocks","created_at":"2026-04-10T02:03:09.525865595Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-17u","depends_on_id":"spaxel-7b3g","type":"blocks","created_at":"2026-04-10T02:03:09.377986112Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-17u","depends_on_id":"spaxel-bsek","type":"blocks","created_at":"2026-04-10T02:03:09.442882165Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-17u","depends_on_id":"spaxel-duvd","type":"blocks","created_at":"2026-04-10T02:03:09.577884728Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-17u","depends_on_id":"spaxel-eelr","type":"blocks","created_at":"2026-04-10T02:03:09.654765280Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-17u","depends_on_id":"spaxel-jxru","type":"blocks","created_at":"2026-04-10T02:03:09.755196510Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-17u","depends_on_id":"spaxel-sl2","type":"blocks","created_at":"2026-03-28T01:33:53.433780442Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-17u","depends_on_id":"spaxel-trsm","type":"blocks","created_at":"2026-04-10T02:03:09.707647462Z","created_by":"coding","metadata":"{}","thread_id":""}]} {"id":"spaxel-19h","title":"fix: localization/spatial_weights.go unused variable linkID","description":"## Problem\n`internal/localization/spatial_weights.go:601` declares `linkID` but never uses it, causing build failure.\n\n## Fix\nFind line 601 in `mothership/internal/localization/spatial_weights.go` and either:\n- Remove the `linkID` variable assignment, or\n- Use the value (pass it somewhere meaningful), or\n- Replace with blank identifier: `linkID` → `_`\n\n## Verify\n```bash\ncd /home/coding/spaxel/mothership && PATH=$PATH:/home/coding/go/bin go build ./internal/localization/\n```\nMust compile with no errors.","status":"closed","priority":1,"issue_type":"task","assignee":"bravo","created_at":"2026-04-06T22:29:51.085342479Z","created_by":"coding","updated_at":"2026-04-06T22:35:21.502259769Z","closed_at":"2026-04-06T22:35:21.502022402Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0} {"id":"spaxel-1l2j","title":"Implement GET /api/events/{id} detail endpoint","description":"Implement GET /api/events/{id} for single event detail. Acceptance Criteria: Returns 404 for non-existent event IDs; Returns full event details for valid IDs.","status":"closed","priority":2,"issue_type":"task","assignee":"hotel","created_at":"2026-04-09T18:14:45.476239078Z","created_by":"coding","updated_at":"2026-04-09T19:09:34.130476972Z","closed_at":"2026-04-09T19:09:34.130355809Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["mitosis-child","mitosis-depth:1","parent-spaxel-yeh"]} {"id":"spaxel-1xt","title":"events: REST API GET /api/events with FTS5 search and cursor pagination","description":"## Overview\nImplement the HTTP handler for the events REST API (part 3 of spaxel-2ap split).\n\n## Endpoint\n`GET /api/events`\n\nQuery params:\n- `limit` (default 50, max 500)\n- `before` (cursor: timestamp_ms as string — keyset pagination, NOT OFFSET)\n- `after` (ISO8601 datetime)\n- `type` (filter by event type)\n- `zone` (filter by zone name)\n- `person` (filter by person label)\n- `q` (FTS5 query — prefix matching, e.g. `q=motion*`)\n\nResponse:\n```json\n{\"events\": [...], \"cursor\": \"1744000000000\", \"has_more\": true, \"total_filtered\": 42}\n```\n\n## Implementation\n- Register at `/api/events` in the existing chi router (requires spaxel-6ha is wired, but can be added independently)\n- FTS5 query via: `SELECT e.* FROM fts_events ft JOIN events e ON e.id = ft.rowid WHERE fts_events MATCH ? ORDER BY e.timestamp_ms DESC LIMIT ?`\n- Keyset: add `AND timestamp_ms < ?` when `before` cursor is provided\n- total_filtered: COUNT from same query without LIMIT\n\n## Verify\n```bash\ncd /home/coding/spaxel/mothership && PATH=$PATH:/home/coding/go/bin go build ./...\n# Run mothership and curl:\n# curl 'http://localhost:8080/api/events?limit=10&q=detection*'\n```\n\nRequires: spaxel-4u6 (schema must exist first)","status":"closed","priority":2,"issue_type":"task","assignee":"echo","created_at":"2026-04-06T22:31:17.453879797Z","created_by":"coding","updated_at":"2026-04-07T17:27:48.091794931Z","closed_at":"2026-04-07T17:27:48.091693315Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred"],"dependencies":[{"issue_id":"spaxel-1xt","depends_on_id":"spaxel-4u6","type":"blocks","created_at":"2026-04-06T22:31:24.454688305Z","created_by":"coding","metadata":"{}","thread_id":""}]} @@ -12,7 +12,9 @@ {"id":"spaxel-28k","title":"Add event messages to WebSocket feed","description":"Add 'event' message type to /ws/dashboard for presence transitions, zone entries/exits, and portal crossings. Broadcast: { type: 'event', event: { id, ts, kind, zone, blob_id, person_name } }. Handle in app.js onmessage. Events appear within 1s of zone transition.","status":"closed","priority":2,"issue_type":"task","assignee":"delta","created_at":"2026-04-06T14:18:27.377328251Z","created_by":"coding","updated_at":"2026-04-07T15:14:57.597424097Z","closed_at":"2026-04-07T15:14:57.597088117Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred","failure-count:23","mitosis-child","mitosis-depth:1","parent-spaxel-9eg"]} {"id":"spaxel-2ap","title":"Activity timeline backend: events API, FTS5 search, cursor pagination","description":"## Overview\nBackend for the unified activity timeline — event ingestion, storage, full-text search, and REST API with cursor pagination. Feeds the timeline dashboard UI (spaxel-65k).\n\n## SQLite schema\n- events table: id INTEGER PK, type TEXT, timestamp_ms INTEGER, zone TEXT, person TEXT, blob_id TEXT, detail_json TEXT, severity TEXT\n- FTS5 virtual table fts_events: content='events', content_rowid='id' — indexed on type, zone, person, detail_json\n- events_archive: same schema, auto-migrated from events when timestamp_ms < now - 90 days (nightly at 02:00 local)\n- Indexes: idx_events_ts (timestamp_ms DESC), idx_events_type, idx_events_zone, idx_events_person\n\n## Event types to ingest\ndetection, zone_entry, zone_exit, portal_crossing, trigger_fired, fall_alert, anomaly, security_alert, node_online, node_offline, ota_update, baseline_changed, system, learning_milestone\n\n## REST API\n- GET /api/events — query params: limit (default 50, max 500), before (cursor), after (ISO8601), type, zone, person, q (FTS5 query)\n- Response: {events: [...], cursor: '', has_more: bool, total_filtered: int}\n- Keyset pagination using timestamp_ms as cursor (no OFFSET)\n- FTS5 query via fts_events MATCH q; fuzzy: prefix matching via q*\n\n## Event publishing\n- All event types published to dashboard WS feed as 'event' messages (requires spaxel-9eg)\n- Event bus in Go: internal publish/subscribe so any package can emit events without direct dependency on dashboard\n\n## Acceptance\n- 1000 events query <50ms with FTS5 search\n- Cursor pagination returns consistent results across pages\n- Archive job runs at 02:00 and moves events >90 days\n- FTS5 search matches partial words (prefix mode)\n- Requires: spaxel-6ha (REST API wiring), spaxel-9eg (WS event feed)","status":"closed","priority":2,"issue_type":"task","assignee":"delta","created_at":"2026-04-06T13:02:26.845982082Z","created_by":"coding","updated_at":"2026-04-07T19:32:10.083144442Z","closed_at":"2026-04-07T19:32:10.082803006Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["blocked","deferred"],"dependencies":[{"issue_id":"spaxel-2ap","depends_on_id":"spaxel-1xt","type":"blocks","created_at":"2026-04-06T22:31:24.411971684Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-2ap","depends_on_id":"spaxel-4u6","type":"blocks","created_at":"2026-04-06T22:31:24.308501610Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-2ap","depends_on_id":"spaxel-6n9","type":"blocks","created_at":"2026-04-06T22:31:24.359488476Z","created_by":"coding","metadata":"{}","thread_id":""}]} {"id":"spaxel-2ea","title":"Add alert messages to WebSocket feed","description":"Add 'alert' message type to /ws/dashboard for anomaly detections and security mode triggers. Broadcast: { type: 'alert', alert: { id, ts, severity, description, acknowledged } }. Handle in app.js onmessage.","status":"closed","priority":2,"issue_type":"task","assignee":"bravo","created_at":"2026-04-06T14:18:27.455727878Z","created_by":"coding","updated_at":"2026-04-07T11:04:25.716894375Z","closed_at":"2026-04-07T11:04:25.716743770Z","close_reason":"Alert message type already fully implemented: BroadcastAlert() in hub.go broadcasts {type:'alert', alert:{id,ts,severity,description,acknowledged}} to /ws/dashboard clients. Called from anomaly detection, security mode changes, and trigger-disabled alerts. Frontend handleAlertMessage() in app.js routes the alert type, shows toast notifications, logs to timeline, and triggers alert banner. Table-driven tests pass (4 cases). go vet clean.","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred","mitosis-child","mitosis-depth:1","parent-spaxel-9eg"]} +{"id":"spaxel-2tlm","title":"Implement simple mode UI","description":"Card-based mobile-first UI with room occupancy cards and activity feed. Non-technical users should be able to check occupancy without training.","status":"closed","priority":2,"issue_type":"task","assignee":"golf","created_at":"2026-04-10T02:03:09.271050009Z","created_by":"coding","updated_at":"2026-04-10T02:08:15.912199673Z","closed_at":"2026-04-10T02:08:15.912102801Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["mitosis-child","mitosis-depth:1","parent-spaxel-17u"]} {"id":"spaxel-2wg","title":"BLE device registry and labelling","description":"## Background\n\nThe firmware scans BLE advertisements every 5 seconds and relays them to the mothership via the bidirectional protocol (spaxel-o4l, Phase 3). Each BLE relay message contains a list of {mac, name, rssi, manufacturer_data} tuples for all devices heard by that node in the last 5 seconds. Phase 6 turns this raw stream into a structured \"People and Devices\" registry where users can label their devices and associate them with named people. This is the identity layer that transforms anonymous CSI blobs into \"Alice\" and \"Bob\".\n\n## BLE Device Auto-Detection\n\nThe mothership can identify device types from manufacturer data embedded in BLE advertisement packets. The Bluetooth SIG assigns Company IDs to manufacturers; the first 2 bytes of manufacturer_data encode the company ID (little-endian).\n\nCompany IDs to detect:\n- 0x004C (Apple): likely iPhone, iPad, AirPods, or Apple Watch. Sub-type from manufacturer data length and flags.\n- 0x0006 (Microsoft): Windows devices\n- 0x0075 (Samsung): Samsung phones/tablets\n- 0x009E (Fitbit): Fitness trackers\n- 0x0157 (Garmin): GPS watches / fitness devices\n- 0x0059 (Nordic): Tile trackers (Nordic Semiconductor is used by many Tile-like devices)\n- 0x0499 (Ruuvi): Ruuvi temperature/humidity sensors\n- 0x00E0 (Google): Android devices (Nearby Share beacons)\nClassify all others as \"Unknown\". The device name field (if present in the advertisement) provides additional signal.\n\nWearable heuristic: RSSI typically -55 to -75 dBm across multiple nodes with relatively consistent signal (worn close to body). Static devices (speakers, tablets) show higher variance. Flags this heuristic as \"possibly wearable\" (not definitive).\n\n## BLERegistry\n\nNew package: mothership/internal/identity/ble.go\n\nBLERegistry struct: backed by SQLite table ble_devices.\n\nSQLite schema:\nCREATE TABLE ble_devices (\n mac TEXT PRIMARY KEY,\n name TEXT,\n manufacturer TEXT,\n device_type TEXT, -- apple_phone, apple_earbuds, fitbit, garmin, tile, samsung, unknown\n label TEXT, -- user-assigned label\n person_id TEXT, -- FK to people.id\n rssi_min INTEGER,\n rssi_max INTEGER,\n rssi_avg INTEGER,\n first_seen DATETIME,\n last_seen DATETIME,\n is_archived BOOLEAN DEFAULT FALSE,\n last_seen_node_mac TEXT\n);\n\nCREATE TABLE people (\n id TEXT PRIMARY KEY, -- uuid\n name TEXT NOT NULL,\n color TEXT, -- hex colour for dashboard rendering\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP\n);\n\nCREATE TABLE person_devices (\n person_id TEXT,\n device_mac TEXT,\n PRIMARY KEY (person_id, device_mac)\n);\n\nBLERegistry methods:\n- ProcessRelayMessage(nodeMac string, devices []BLEDevice): upsert all devices, update last_seen, update RSSI stats\n- GetDevices(includeArchived bool) []BLEDeviceRecord\n- UpdateLabel(mac, label string) error\n- AssignToPerson(mac, personID string) error\n- CreatePerson(name, color string) (Person, error)\n- GetPeople() []Person\n- ArchiveStale(olderThan time.Duration): set is_archived=true for devices not seen for > olderThan\n\n## BLE MAC Randomisation Handling\n\nModern iPhones and Android phones randomise their BLE MAC address periodically (every 10-15 minutes for iPhones, similar for Android). This is a fundamental privacy feature. The implications for spaxel:\n\n1. The same physical phone appears as multiple different MAC addresses in the registry. The BLERegistry will create new entries for each rotated address.\n2. Long-term tracking of phones by MAC is unreliable. The registry will accumulate many entries for a single phone over time.\n3. Workarounds: (a) Apple uses Resolvable Private Addresses (RPA) that can be resolved with the Identity Resolving Key (IRK) — requires pairing, not available without user action. (b) Device name is sometimes consistent across rotations. (c) Wearable devices (Fitbit, Garmin, AirTag) typically do NOT rotate their MACs — they provide reliable long-term tracking.\n\nThe dashboard must clearly explain this limitation in the \"People and Devices\" panel:\n\"Your phone's Bluetooth address changes regularly for privacy reasons. For reliable person tracking, use a Fitbit, Garmin watch, or AirTag, which have stable addresses.\"\n\nGrouping heuristic: if two devices have the same manufacturer data prefix (first 6 bytes) and name, and were never seen simultaneously at high RSSI from the same node, they are likely the same device with a rotated MAC. Surface this as a \"possible duplicate\" suggestion in the UI: \"These may be the same device: [mac1] and [mac2]. Merge?\"\n\n## REST API\n\nGET /api/ble/devices: returns list of BLEDeviceRecord, optionally filtered by ?archived=true\nGET /api/ble/devices/{mac}: returns single device with full history\nPUT /api/ble/devices/{mac}: update label, device_type, or person assignment. Body: {\"label\":\"Alice's Phone\",\"device_type\":\"apple_phone\",\"person_id\":\"uuid-123\"}\nDELETE /api/ble/devices/{mac}: archive (not hard delete)\n\nGET /api/people: returns list of People with their associated devices\nPOST /api/people: create person. Body: {\"name\":\"Alice\",\"color\":\"#3b82f6\"}\nPUT /api/people/{id}: update name or color\nDELETE /api/people/{id}: soft-delete (retain historical data)\n\n## Dashboard Panel\n\n\"People and Devices\" sidebar panel showing:\n- People section: list of defined people with avatar (initials in circle with their color), device count, last seen time\n - Per person: click to expand, shows associated devices\n - \"Add person\" button opens inline form\n- All devices section (below people): list of devices not yet assigned to a person\n - Per device: device type icon (Apple logo, Fitbit icon, etc.), last seen node (abbreviated), last seen timestamp, RSSI bar\n - Inline label edit on double-click\n - Drag-and-drop to assign to a person card\n - Archive button (hides from active list, accessible via \"Show archived\" toggle)\n- Privacy notice: \"Phones may appear multiple times due to address rotation. Wearables and AirTags have stable addresses.\"\n\n## Tests\n\n- Test device auto-detection: Apple company ID 0x004C -> device_type \"apple_phone\", Fitbit 0x009E -> \"fitbit\"\n- Test that ProcessRelayMessage correctly upserts devices and updates last_seen and RSSI stats\n- Test ArchiveStale marks devices not seen for > 7 days as archived\n- Test person creation and device-to-person assignment API calls\n- Test MAC randomisation handling: two devices with same name and no simultaneous sighting are flagged as possible duplicates\n- Test that archived devices are excluded from GetDevices(false) but included in GetDevices(true)\n\n## Acceptance Criteria\n\n- Discovered BLE devices appear in the dashboard \"People and Devices\" panel within 30 seconds of first observation\n- Device type is auto-detected correctly for Apple, Fitbit, Garmin, and Samsung devices\n- User can assign labels and associate devices with named people via the dashboard UI\n- Drag-and-drop device-to-person assignment works in the UI\n- Devices not seen for > 7 days are automatically archived and hidden from the active list\n- Privacy limitation is clearly documented in the panel UI\n- Possible duplicate MAC-rotated devices are surfaced as merge suggestions\n- Tests pass","status":"closed","priority":3,"issue_type":"task","assignee":"juliet","created_at":"2026-03-28T01:44:02.204633291Z","created_by":"coding","updated_at":"2026-03-29T18:07:39.656772405Z","closed_at":"2026-03-29T18:07:39.656662663Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred"],"dependencies":[{"issue_id":"spaxel-2wg","depends_on_id":"spaxel-c0q","type":"blocks","created_at":"2026-03-28T03:29:14.172209347Z","created_by":"coding","metadata":"{}","thread_id":""}]} +{"id":"spaxel-2x1w","title":"Implement command palette","description":"Ctrl+K universal search/command with fuzzy matching for power user efficiency.","status":"open","priority":2,"issue_type":"task","created_at":"2026-04-10T02:03:09.482985749Z","created_by":"coding","updated_at":"2026-04-10T02:03:09.482985749Z","source_repo":".","compaction_level":0,"original_size":0,"labels":["mitosis-child","mitosis-depth:1","parent-spaxel-17u"]} {"id":"spaxel-32o","title":"Link weather diagnostics and repositioning advice","description":"## Background\n\nEven with good hardware and correct placement, some links will chronically underperform. A user who placed a node on a metal shelf, behind a TV, or in a corner will see consistently poor detection without understanding why. Telling users \"your detection quality is low\" is useless without telling them what to do about it. Link weather diagnostics provide root-cause analysis and specific, actionable repositioning advice — including 3D visualisation of why a link is performing poorly and where to move a node to fix it.\n\nThe name \"link weather\" is deliberate: just as weather forecasts present complex atmospheric state in human terms (\"partly cloudy with 60% chance of rain\"), link weather presents complex RF state as: \"Node A to Node B: interference detected. Likely cause: microwave oven or 2.4GHz congestion. Try moving Node B 1.5 metres to the right.\"\n\n## DiagnosticEngine\n\nNew module: mothership/internal/diagnostics/linkweather.go\n\nDiagnosticEngine runs as a background goroutine, consuming link health history from SQLite and emitting Diagnosis structs. It runs a full diagnostic pass every 15 minutes.\n\nA Diagnosis struct contains:\n- LinkID string\n- RuleID string (identifies which rule fired)\n- Severity: INFO, WARNING, ACTIONABLE\n- Title string (human-readable headline)\n- Detail string (explanation of the diagnosis in plain language)\n- Advice string (specific actionable steps)\n- RepositioningTarget *Vec3 (3D position to move the node to, or nil if repositioning is not the solution)\n- RepositioningNodeMAC string (which node to move)\n- ConfidenceScore float64 (how confident the diagnostic engine is in this diagnosis)\n\n## Diagnostic Rules\n\nRule 1: Environmental Change\nTrigger: High baseline drift (>5% per hour) correlated across multiple links simultaneously (>50% of active links).\nTitle: \"Environmental change detected\"\nDetail: \"Multiple sensing links are showing simultaneous baseline shifts. This typically indicates a temperature change, or a large object was moved in the space. The system is adapting automatically.\"\nAdvice: \"No action needed. The baseline will re-stabilise within 30 minutes.\"\nRepositioningTarget: nil\nConfidence: 0.85 if drift is correlated across >50% of links\n\nRule 2: WiFi Congestion or Distance\nTrigger: Packet rate health < 0.8 for more than 10 minutes on a single link.\nTitle: \"Node B has low signal rate\"\nDetail: \"Node [B] is only delivering [N]% of the expected [M] packets per second. The most common causes are distance from the WiFi router or congestion from nearby networks.\"\nAdvice: \"1. Move Node [B] within 10 metres of your WiFi router. 2. If already close, check if the 2.4GHz channel is congested (3+ networks on overlapping channels). 3. ESP32-S3 supports both 2.4GHz and 5GHz — if your router supports 5GHz, update Node B's WiFi config to use the 5GHz SSID.\"\nRepositioningTarget: nil (advice is router proximity, not specific coordinates)\n\nRule 3: Near-Field Metal Interference\nTrigger: Low phase stability (< 0.4) sustained for > 30 minutes during known-quiet periods.\nTitle: \"Metal interference near Node [A]\"\nDetail: \"The sensing link [A to B] has unstable phase measurements even when no one is moving. This is typically caused by metal objects in the near field of the node's antenna (within 10cm): metal shelves, radiators, TV backs, or large appliances.\"\nAdvice: \"Check for metal objects within 10cm of Node [A]. If Node [A] is on a metal surface or shelf, mount it on a non-metal bracket or wall. Try repositioning it 20-30cm away from metal surfaces.\"\nRepositioningTarget: nil (advice is clearance from metal, not a specific position)\n\nRule 4: Fresnel Zone Blockage (Half-Room Dead Zone)\nTrigger: Consistent miss rate (>30% of test walks that should be detected are missed) in a specific area of the room, AND the missing area correlates geometrically with an obstacle in the link's Fresnel zone.\nThis rule requires the feedback loop data (Phase 7, spaxel-i28) — specifically the user-submitted false negatives with position information. If no feedback data is available, this rule can trigger heuristically when one side of the room consistently shows lower blob confidence scores.\nTitle: \"Coverage gap detected — possible obstruction\"\nDetail: \"The area near [zone description] shows lower detection coverage. An obstacle may be blocking the path between Node [A] and Node [B], interrupting their sensing zone.\"\nAdvice: \"Move Node [B] [direction] by approximately [distance] to restore coverage. The target position is marked in green in the 3D view.\"\nRepositioningTarget: computed_optimal_position (see below)\n\nRule 5: Periodic Interference Spikes\nTrigger: Periodic spikes in deltaRMS variance (3-10 events per hour, each lasting 1-3 minutes) not correlated with occupancy data (no people detected moving).\nTitle: \"Periodic interference detected\"\nDetail: \"Node [A] to Node [B] is experiencing regular interference bursts [N] times per hour. This pattern is consistent with a microwave oven, a cordless phone, or a pulsed 2.4GHz source.\"\nAdvice: \"Consider the following: 1. Is Node [A] or Node [B] near a kitchen? Microwave ovens cause strong 2.4GHz interference. 2. A cordless DECT phone or baby monitor near one of the nodes may be the source. 3. Try moving the affected node at least 2 metres from any 2.4GHz appliances.\"\nRepositioningTarget: nil (interference is appliance-specific)\n\n## Repositioning Advice in 3D\n\nFor Rule 4 (Fresnel zone blockage), compute the optimal repositioning target:\n1. Use the GDOP-based coverage optimiser from Phase 5 self-healing fleet (spaxel-jc4) to compute the position that maximises GDOP for the blocked zone while keeping all other nodes fixed.\n2. The optimal position is the computed_optimal_position Vec3.\n3. In the 3D dashboard, render a \"ghost\" node at this position: translucent version of the node mesh, with a dashed line from the current position to the ghost position.\n4. Show expected GDOP improvement: \"Moving Node B here would improve detection in the east corner from [N]% to [M]%.\"\n\n## Weekly Reliability Trends\n\nStore daily health score averages in SQLite: link_health_daily (link_id TEXT, date DATE, avg_health REAL, min_health REAL, max_health REAL, PRIMARY KEY (link_id, date)).\n\nA background job runs daily at midnight and writes the day's health averages from the link health log (link_health_log table: link_id, timestamp, composite_score).\n\nDashboard shows for each link: 7-day sparkline of daily average health score. \"Best day\" annotation (highest average) and \"worst day\" annotation (lowest average). This gives users a sense of long-term reliability.\n\n## Files to Create or Modify\n\n- mothership/internal/diagnostics/linkweather.go: DiagnosticEngine and all 5 rules\n- mothership/internal/diagnostics/reposition.go: repositioning target computation\n- mothership/internal/health/linkhealth.go: add link_health_log table writes\n- dashboard/js/linkhealth.js: link health panel, diagnostics display, ghost node rendering\n- mothership/internal/dashboard/routes.go: GET /api/links/{id}/diagnostics, GET /api/links/{id}/health-history\n\n## Tests\n\n- Test Rule 1 (environmental change): inject simultaneous high-drift events across 60% of links, verify diagnosis fires with Severity=INFO\n- Test Rule 2 (WiFi congestion): inject packet_rate=0.7 for 15 minutes, verify diagnosis fires with appropriate advice text\n- Test Rule 3 (metal interference): inject phase_stability=0.3 for 35 minutes during a quiet window, verify diagnosis fires\n- Test Rule 4 (Fresnel blockage): requires feedback data — inject synthetic false-negative feedback events clustered in one spatial zone, verify diagnosis fires and RepositioningTarget is non-nil\n- Test Rule 5 (periodic interference): inject 5 deltaRMS variance spikes per hour for 2 hours, verify diagnosis fires with correct periodicity estimate\n- Test weekly trend aggregation: inject 7 days of health scores, verify daily averages are correctly computed and stored\n- Test that repositioning target is within room bounds and improves GDOP\n\n## Acceptance Criteria\n\n- All 5 diagnostic rules fire correctly on synthetic test data that matches their trigger conditions\n- Repositioning advice for Rule 4 appears as a ghost node in the 3D dashboard view\n- Expected GDOP improvement shown alongside repositioning ghost node\n- Weekly 7-day sparkline visible in link health panel for each link\n- Diagnostics accessible via API and displayed in Link Health panel on link click\n- Tests pass","status":"closed","priority":3,"issue_type":"task","assignee":"juliet","created_at":"2026-03-28T01:43:13.596164634Z","created_by":"coding","updated_at":"2026-03-29T18:07:39.683230580Z","closed_at":"2026-03-29T18:07:39.683089345Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred"],"dependencies":[{"issue_id":"spaxel-32o","depends_on_id":"spaxel-axa","type":"blocks","created_at":"2026-03-28T03:29:14.023730499Z","created_by":"coding","metadata":"{}","thread_id":""}]} {"id":"spaxel-3ca","title":"Add time-travel debugging","description":"Implement:\n- Pause live mode\n- Timeline scrubbing\n- Replay 3D from recorded CSI data\n\nAcceptance: Can replay 24 hours of historical data with full 3D visualization.","status":"closed","priority":2,"issue_type":"task","assignee":"golf","created_at":"2026-04-09T14:54:38.737598265Z","created_by":"coding","updated_at":"2026-04-09T17:41:51.707526513Z","closed_at":"2026-04-09T17:41:51.707468066Z","close_reason":"Time-travel debugging implementation complete. All acceptance criteria met:\n- Pause live mode: Implemented in dashboard/js/replay.js with Pause Live button\n- Timeline scrubbing: Full scrubber UI with seek functionality \n- Replay 3D from recorded CSI: Viz3D integration with enterReplayMode/exitReplayMode/updateReplayBlobs\n- 24-hour replay: Recording buffer supports 48-hour retention (exceeds requirement)\n\nBackend (mothership/internal/api/replay.go, replay/worker.go):\n- REST API for session management (start, stop, seek, tune, set-speed, set-state)\n- Separate signal processing pipeline for replay\n- Blob broadcasting to dashboard\n\nFrontend (dashboard/js/replay.js):\n- Complete replay controls UI\n- Parameter tuning panel with instant preview\n- Timeline loop polling session state\n\n3D Visualization (dashboard/js/viz3d.js):\n- Stores/restores live blob states during replay transitions\n- Full 3D blob rendering from replay data\n\nVerification: Comprehensive test suite exists (replay_test.go) covering session lifecycle, multiple sessions, parameter tuning, and timestamp parsing.","source_repo":".","compaction_level":0,"original_size":0,"labels":["failure-count:20","mitosis-child","mitosis-depth:1","parent-spaxel-sl2"]} {"id":"spaxel-3ps","title":"Detection feedback loop and accuracy tracking","description":"## Background\n\nEvery detection algorithm produces errors. False positives (detected presence when no one is there) are annoying and erode trust. False negatives (missed detection of a real person) are dangerous for safety applications. The feedback loop gives users a direct mechanism to correct errors and the system learns from those corrections. Showing users measurable improvement over time (\"You've provided 47 corrections. Accuracy improved 12% this week\") creates a virtuous engagement loop and transforms users into active participants in improving the system.\n\n## Feedback UI Elements\n\nEvery detection event exposed to the user should have feedback affordances. Three contexts:\n\n1. Dashboard 3D view: Each active track has a small thumbs-up/down icon that appears on hover/focus. Clicking thumbs-down opens a quick inline form.\n\n2. Activity timeline (Phase 8): Every detection event entry has thumbs-up/thumbs-down at the end of the row. Space-efficient: 2 icon buttons.\n\n3. Push notifications: Fall and anomaly notifications include a quick-reply option (via ntfy actions or Pushover callbacks): \"False alarm — clear this.\"\n\n4. \"I was here and wasn't detected\" button: On the timeline panel, a button \"Report missed detection\" opens a form: \"When? [time picker, default: now]\", \"Where? [zone picker]\", \"Who? [person picker, optional]\". Submits as a FALSE_NEGATIVE feedback event with the user-provided position.\n\nFeedback form for thumbs-down:\n- \"What was wrong?\" (radio buttons):\n - \"No one was there (false alarm)\"\n - \"Someone was missed at this location\"\n - \"Wrong person identified\"\n - \"Wrong zone/location\"\n- Optional free-text \"Notes\" field\n- Submit / Cancel\n\n## Feedback Storage\n\nSQLite schema:\nCREATE TABLE detection_feedback (\n id TEXT PRIMARY KEY,\n event_id TEXT, -- references events table (activity timeline)\n event_type TEXT, -- \"blob_detection\", \"zone_transition\", \"fall_alert\", \"anomaly\"\n feedback_type TEXT, -- \"TRUE_POSITIVE\", \"FALSE_POSITIVE\", \"FALSE_NEGATIVE\", \"WRONG_IDENTITY\", \"WRONG_ZONE\"\n details_json TEXT, -- {\"zone_id\":\"...\", \"person_id\":\"...\", \"notes\":\"...\"}\n timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,\n applied BOOLEAN DEFAULT FALSE, -- set to TRUE after weight refinement processes it\n processed_at DATETIME\n);\n\nThe applied flag enables incremental processing: the weight learner (Phase 7 self-improving localisation) queries WHERE applied = FALSE, processes batches, and marks them TRUE.\n\n## Accuracy Metrics\n\nCompute precision/recall/F1 per link, per zone, and per person weekly. This requires knowing the true positives, false positives, and false negatives.\n\nGround truth sources:\n- User thumbs-up -> TRUE_POSITIVE for the corresponding detection event\n- User thumbs-down (false alarm) -> FALSE_POSITIVE for the detection event\n- User \"missed detection\" report -> FALSE_NEGATIVE for the reported time/zone\n\nNote: ground truth is sparse — users will not feedback every event. We use the feedback we have as a sample. Assume events without feedback are TRUE_POSITIVE for the purpose of precision estimates (conservative: this means precision is an upper bound, not exact).\n\nMetrics computed weekly:\n- precision = TP / (TP + FP) — of all detections, what fraction were correct\n- recall = TP / (TP + FN) — of all true presence events, what fraction were detected\n- F1 = 2 * precision * recall / (precision + recall)\n- Per-link metrics: which links have the most false positives (worst precision)\n- Per-zone metrics: which zones are most often missed (worst recall)\n\nStorage: detection_accuracy (week TEXT, scope_type TEXT, scope_id TEXT, precision REAL, recall REAL, f1 REAL, tp_count INT, fp_count INT, fn_count INT, computed_at DATETIME). Scope types: \"system\", \"link\", \"zone\", \"person\".\n\n## Accuracy Trend Display\n\nDashboard \"Accuracy\" panel (in expert mode):\n- Overall accuracy gauge: composite F1 score as a circular gauge (0-100%)\n- Week-over-week trend graph: sparkline of weekly F1 over the last 8 weeks\n- \"You've provided N corrections. Your accuracy improved X% this week.\" — motivational counter\n- Per-zone breakdown: bar chart of precision/recall per zone (click a zone bar to jump to it in 3D view)\n- Per-link breakdown: link health vs. feedback score correlation (are high-health links also high-accuracy?)\n- Feedback count: total corrections given, open corrections (not yet processed), processed corrections\n\nThe accuracy trend display intentionally shows the improvement trajectory, not just the absolute value, to reinforce that feedback has an effect.\n\n## Feedback Application\n\nProcessing happens in a background goroutine (mothership/internal/learning/feedback_processor.go) that runs every 6 hours or when triggered manually.\n\nFor FALSE_POSITIVE events with associated CSI data (in the recording buffer from Phase 2):\n- Retrieve the CSI data from the recording buffer at the event timestamp for all links\n- Add the CSI frame data to a \"known false positive\" set in SQLite: false_positive_frames (link_id, timestamp, delta_rms, context_json)\n- The weight learner (self-improving localisation bead) uses this set as negative examples\n\nFor FALSE_NEGATIVE events with user-reported position:\n- Add to \"known false negative\" set: false_negative_frames (link_id, timestamp, expected_position_xyz, context_json)\n- The weight learner uses this as a positive example at the specified position\n\nAfter processing, mark feedback.applied = TRUE.\n\n## Files to Create or Modify\n\n- mothership/internal/learning/feedback_processor.go: feedback processing pipeline\n- mothership/internal/analytics/accuracy.go: weekly metric computation\n- dashboard/js/feedback.js: thumbs-up/down UI components (reusable across 3D view and timeline)\n- dashboard/js/accuracy.js: Accuracy panel rendering\n- mothership/internal/dashboard/routes.go: POST /api/feedback, GET /api/accuracy\n\n## Tests\n\n- Test feedback storage: POST /api/feedback with each feedback_type, verify SQLite record created\n- Test accuracy metric computation with synthetic TP/FP/FN data: 8 TP, 2 FP, 1 FN -> precision=0.8, recall=0.888\n- Test weekly rollup: 7 days of daily feedback -> correctly aggregated weekly metric\n- Test that applied=false events are found and marked as applied after processor run\n- Test \"improvements\" counter: feedback_count increases on each POST /api/feedback call\n\n## Acceptance Criteria\n\n- Thumbs-up/down buttons appear on active tracks in 3D view and on all timeline events\n- \"Missed detection\" button and form available in timeline panel\n- Feedback stored in SQLite with correct feedback_type and details\n- Accuracy metrics computed weekly and stored in detection_accuracy table\n- Accuracy panel shows week-over-week trend (requires at least 2 weeks of data)\n- Feedback improvement counter shows correct counts\n- Applied flag correctly set after processor run\n- Tests pass","status":"closed","priority":3,"issue_type":"task","assignee":"sp4","created_at":"2026-03-28T01:49:50.419277632Z","created_by":"coding","updated_at":"2026-03-29T22:08:03.778130122Z","closed_at":"2026-03-29T22:08:03.778000167Z","close_reason":"Implementation complete: feedback storage (SQLite), accuracy computation (precision/recall/F1 weekly), feedback processor (6h interval), API endpoints (/api/learning/*), frontend feedback UI (thumbs up/down, missed detection form), accuracy panel (F1 gauge, sparkline, per-zone breakdown). All 12 tests pass.","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred","failure-count:1"],"dependencies":[{"issue_id":"spaxel-3ps","depends_on_id":"spaxel-zvs","type":"blocks","created_at":"2026-03-28T03:29:14.442377218Z","created_by":"coding","metadata":"{}","thread_id":""}]} @@ -34,6 +36,7 @@ {"id":"spaxel-70i","title":"Develop CSI simulator CLI","description":"Create Go CLI tool for:\n- Virtual node generation\n- Synthetic CSI binary frame output\n- Developer testing workflow\n\nAcceptance: CLI generates valid CSI binary frames for testing without hardware.","status":"closed","priority":2,"issue_type":"task","assignee":"hotel","created_at":"2026-04-09T14:54:38.869607224Z","created_by":"coding","updated_at":"2026-04-09T16:31:52.344734554Z","closed_at":"2026-04-09T16:31:52.344617250Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["failure-count:2","mitosis-child","mitosis-depth:1","parent-spaxel-sl2"]} {"id":"spaxel-72t","title":"Provisioning payload and NVS write","description":"## Background\n\nWhen a new node is provisioned, it needs WiFi credentials (SSID + password) and a unique node ID (for use in the hello message and as a persistent identifier). The provisioning payload is assembled by the mothership and sent to the firmware over serial during onboarding, or can also be sent over the WebSocket after reconnect. Getting this right is foundational to the security and identity model of the entire system.\n\n## Why Mothership-Generated Node IDs?\n\nRather than generating a random ID on device, having the mothership assign node IDs allows it to: track provisioned-but-never-connected nodes for inventory management, support re-provisioning with ID continuity (same physical device gets same ID after factory reset), prevent ID collisions in multi-node deployments, and maintain a token-based security model where only provisioned nodes can connect.\n\n## NVS Schema\n\nThe firmware NVS schema is defined in firmware/main/spaxel.h (schema version 1). Keys and types:\n- wifi_ssid (string, max 32 chars)\n- wifi_pass (string, max 64 chars)\n- node_id (uint16, assigned by mothership)\n- node_token (string, 12-char hex, assigned by mothership)\n- mothership_host (string, empty = use mDNS)\n- mothership_port (uint16, default 8080)\n- role (uint8, 0=rx, 1=tx, 2=tx-rx, 3=passive)\n- sample_rate (uint16, default 20 Hz)\n- schema_ver (uint8, current = 1)\n\n## Mothership API\n\nPOST /api/provision\nRequest body: {\"ssid\": \"MyWifi\", \"password\": \"secret\", \"label\": \"Living Room Node\"}\nResponse: {\"node_id\": 42, \"provision_token\": \"a3f7b2c1d8e9\", \"config_blob\": \"{...json...}\"}\n\nThe config_blob is a JSON string encoding all NVS keys listed above. It is passed verbatim to the firmware over serial or WebSocket. The firmware parses it, writes each key to NVS, and reboots.\n\nExample config_blob:\n{\"wifi_ssid\":\"MyWifi\",\"wifi_pass\":\"secret\",\"node_id\":42,\"node_token\":\"a3f7b2c1d8e9\",\"mothership_host\":\"\",\"mothership_port\":8080,\"role\":0,\"sample_rate\":20,\"schema_ver\":1}\n\n## Firmware Provisioning Handling\n\nTwo provisioning paths:\n\n1. Serial provisioning (onboarding wizard path): Before WiFi is connected, the firmware listens on UART0 (115200 baud) for a JSON line starting with {\"provision\":. On receipt, write to NVS and reboot. This path works even before WiFi credentials are configured.\n\n2. WebSocket provisioning (re-provisioning path): A new downstream command type \"provision\" alongside existing role/config/ota/reboot in firmware/main/websocket.c. Allows the mothership to update credentials or reset a node over the air. This is useful for credential rotation without physical access.\n\n## Security Model\n\nThe provision_token is used as a bearer token in the WebSocket Authorization header (Authorization: Bearer ) for all subsequent connections. The mothership validates the token on every connection attempt against the provisioned_nodes SQLite table. Nodes without a valid token receive a {type:\"reject\"} downstream message and the connection is closed.\n\nToken format: 12 lowercase hex characters (48 bits of entropy). Generated server-side using crypto/rand. Not derivable from node_id or MAC address.\n\n## SQLite Storage\n\nAdd a provisioned_nodes table to the mothership SQLite database:\nCREATE TABLE provisioned_nodes (\n node_id INTEGER PRIMARY KEY,\n mac TEXT,\n token TEXT NOT NULL,\n label TEXT,\n provisioned_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n first_seen DATETIME,\n last_seen DATETIME,\n firmware_version TEXT,\n current_role INTEGER DEFAULT 0\n);\n\nThe mac field is populated when the node first connects and sends its hello message. Before first connection, mac is NULL (node is provisioned but not yet seen).\n\n## Implementation Location\n\n- mothership/internal/provision/handler.go: POST /api/provision handler\n- mothership/internal/provision/store.go: SQLite CRUD for provisioned_nodes\n- mothership/internal/ingestion/auth.go: WebSocket token validation on connection\n- firmware/main/websocket.c: add \"provision\" downstream command type\n- firmware/main/wifi.c: add serial JSON provisioning path on UART0 (pre-WiFi)\n\n## Re-provisioning\n\nIf a node already exists in provisioned_nodes (matched by mac), the mothership can re-provision it with a new token. The old token is invalidated immediately. The new config_blob is sent via the existing WebSocket connection (if online) or over serial (if physically accessible). This handles: WiFi password changes, mothership IP changes, node relabelling.\n\n## Tests\n\n- Test that POST /api/provision returns valid config_blob containing all required NVS keys\n- Test that node_id is unique and increments correctly\n- Test that token validation rejects connections with unknown tokens\n- Test that token validation rejects connections with expired/rotated tokens\n- Test NVS serialisation round-trip: parse config_blob back to NVS key-value map and verify all values\n- Test that a second provision for the same MAC updates rather than duplicates the record\n\n## Acceptance Criteria\n\n- Provisioned node connects to mothership successfully with the assigned node_id and token\n- Token validation correctly rejects unprovisioned connection attempts with {type:\"reject\"}\n- Node label stored and returned via GET /api/nodes in the node list\n- Re-provisioning updates token and invalidates old token within one round-trip\n- config_blob contains all required NVS keys with correct types\n- Tests pass","status":"closed","priority":2,"issue_type":"task","created_at":"2026-03-28T01:36:54.067220841Z","created_by":"coding","updated_at":"2026-03-28T05:36:39.268631627Z","closed_at":"2026-03-28T05:36:39.268468107Z","close_reason":"Implemented: provisioning/server.go (fb69190) + firmware/main/provision.c/h (fb69190) — POST /api/provision generates node_id+token+config_blob, UART serial provisioning window on ESP32, NVS write, provisioned_nodes SQLite table with token validation","source_repo":".","compaction_level":0,"original_size":0,"dependencies":[{"issue_id":"spaxel-72t","depends_on_id":"spaxel-uc9","type":"blocks","created_at":"2026-03-28T03:29:13.844135515Z","created_by":"coding","metadata":"{}","thread_id":""}]} {"id":"spaxel-783","title":"Add Identify button to fleet status page","description":"Add 'Identify' button per row in the fleet status page that POSTs to /api/nodes/{mac}/identify.\n\n**Acceptance:**\n- Fleet status page has 'Identify' button per row","status":"closed","priority":2,"issue_type":"task","assignee":"hotel","created_at":"2026-04-09T11:11:49.991341754Z","created_by":"coding","updated_at":"2026-04-09T11:18:10.966551629Z","closed_at":"2026-04-09T11:18:10.966448973Z","close_reason":"Added Identify button (⚡) per row in the fleet status page that POSTs to /api/nodes/{mac}/identify. Button only shows for online nodes and sends a 5-second LED blink command with toast feedback.","source_repo":".","compaction_level":0,"original_size":0,"labels":["mitosis-child","mitosis-depth:1","parent-spaxel-h58"]} +{"id":"spaxel-7b3g","title":"Build ambient dashboard mode","description":"Create /ambient route for wall tablets with simplified top-down view and auto-dim functionality. Should run 7+ days continuously.","status":"closed","priority":2,"issue_type":"task","assignee":"golf","created_at":"2026-04-10T02:03:09.350486770Z","created_by":"coding","updated_at":"2026-04-10T02:27:09.159574173Z","closed_at":"2026-04-10T02:27:09.159337207Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["failure-count:3","mitosis-child","mitosis-depth:1","parent-spaxel-17u"]} {"id":"spaxel-7nk","title":"fix: sleep/handler.go cannot index interface{} map value","description":"## Problem\n`internal/sleep/handler.go` lines 229 and 232 fail with: `cannot index result[\"metrics\"] (map index expression of type interface{})`\n\nThe `result` map is of type `map[string]interface{}`, so `result[\"metrics\"]` returns `interface{}`, which cannot be directly indexed.\n\n## Fix\nAdd a type assertion before indexing. Around lines 229-232 in `internal/sleep/handler.go`:\n```go\n// Before the two if-blocks, get a typed reference:\nif metricsMap, ok := result[\"metrics\"].(map[string]interface{}); ok {\n if !metrics.SleepStartTime.IsZero() {\n metricsMap[\"sleep_start_time\"] = metrics.SleepStartTime.Format(\"15:04\")\n }\n if !metrics.SleepEndTime.IsZero() {\n metricsMap[\"sleep_end_time\"] = metrics.SleepEndTime.Format(\"15:04\")\n }\n}\n```\n\n## Verify\n```bash\ncd /home/coding/spaxel/mothership && PATH=$PATH:/home/coding/go/bin go build ./internal/sleep/\n```","status":"closed","priority":1,"issue_type":"task","assignee":"delta","created_at":"2026-04-06T22:30:05.128489582Z","created_by":"coding","updated_at":"2026-04-06T22:40:47.430043249Z","closed_at":"2026-04-06T22:40:47.429779459Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0} {"id":"spaxel-7qo","title":"Dashboard: WebSocket reconnection with exponential backoff and state management","description":"## Overview\nImplement robust client-side WebSocket reconnection with exponential backoff, jitter, and visual state transitions during disconnects.\n\n## Reconnection logic (dashboard/js/websocket.js or app.js)\n- Backoff sequence: 1s, 2s, 4s, 8s, max 10s; ±500ms random jitter on each attempt\n- Track disconnect_duration_ms from first disconnect event\n\n## Visual state transitions:\nDisconnect < 5s: silent (no UI change); blob positions extrapolated from last velocity\nDisconnect 5-30s: 3D scene dims to 50% opacity; 'Reconnecting...' spinner in status bar; user interaction disabled\nDisconnect > 30s: non-blocking modal: 'Connection lost — [Reload Page]'; allow viewing stale scene\n\n## Blob position extrapolation (<5s):\n- On disconnect: record last_position and last_velocity per blob\n- Each animation frame: position = last_position + last_velocity × elapsed_s (capped at 2s extrapolation)\n\n## On successful reconnect:\n- Clear all blob trails (path history lines)\n- Apply snapshot from first WebSocket message (spaxel-fll)\n- Restore scene opacity to 100%\n- Dismiss spinner and modal\n- Log 'Reconnected after Xs' to console\n\n## Acceptance\n- Disconnect for 3s: no visual change; blobs continue moving smoothly\n- Disconnect for 10s: scene dims, spinner shown\n- Disconnect for 35s: modal appears; scene still visible\n- Reconnect: modal dismissed, trails cleared, scene snaps to current state within 200ms\n- Requires: spaxel-fll (snapshot protocol), spaxel-896 (panel framework)","status":"closed","priority":2,"issue_type":"task","assignee":"echo","created_at":"2026-04-06T16:44:33.446200584Z","created_by":"coding","updated_at":"2026-04-07T16:45:31.143915724Z","closed_at":"2026-04-07T16:45:31.143823228Z","close_reason":"WebSocket reconnection with exponential backoff and visual state management was already fully implemented in commit ff3428f. All acceptance criteria met: backoff 1s-10s with ±500ms jitter, <5s silent extrapolation, 5-30s dimming with spinner, >30s modal with reload button, reconnect clears trails and restores scene from snapshot.","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred"]} {"id":"spaxel-7x2","title":"Wire anomaly detection & security mode API endpoints","description":"## Backend\n\n- Confirm AnomalyDetector is initialized and running in main()\n- Anomaly events must be pushed to the dashboard WS feed as 'alert' messages\n- GET /api/anomalies?since=24h — list recent anomaly events\n- POST /api/security/arm + /api/security/disarm — arm/disarm security mode\n- GET /api/security/status — { armed, learning_until, anomaly_count_24h }\n\n## Acceptance\n- Endpoints return correct JSON structure\n- Anomaly events push to WS feed as 'alert' messages\n- Arm/disarm state persists across server restarts","status":"closed","priority":2,"issue_type":"task","assignee":"bravo","created_at":"2026-04-06T16:09:35.812256758Z","created_by":"coding","updated_at":"2026-04-07T19:17:55.756354374Z","closed_at":"2026-04-07T19:17:55.756259632Z","close_reason":"All acceptance criteria verified and already committed in b1c2218. AnomalyDetector initialized in main() with 6h periodic updates. Anomaly events broadcast to dashboard WS as alert messages. GET /api/anomalies?since=24h, POST /api/security/arm, POST /api/security/disarm, GET /api/security/status all wired and tested. Arm/disarm state persisted to learning_state table and restored on restart. All 14 related tests passing.","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred","failure-count:2","mitosis-child","mitosis-depth:1","parent-spaxel-a55"]} @@ -51,7 +54,8 @@ {"id":"spaxel-axa.1","title":"Interactive onboarding wizard","description":"## Background\n\nPhase 4's central goal is that a non-technical user can go from an unboxed ESP32-S3 to streaming CSI in under 5 minutes. The onboarding wizard is the centrepiece of this experience. It uses the Web Serial API (available in Chrome/Edge) to communicate with the ESP32 over USB — no driver installation needed, no CLI, no app download. The wizard is embedded in the existing mothership dashboard, accessible at /onboard.\n\n## Why Web Serial?\n\nThe alternative approaches — a dedicated mobile app, a WiFi provisioning AP, or a CLI tool — all have significant UX friction. Web Serial lets us flash firmware, provision WiFi credentials, and guide the user through calibration all in one browser session. The dashboard already knows the mothership IP/port. Chrome and Edge (95%+ of desktop browser market) support Web Serial natively since 2021. The only caveat is that Web Serial is not available in Firefox or Safari — this must be documented prominently at the start of the wizard.\n\n## Wizard Steps\n\n1. **Browser check**: Detect navigator.serial availability. If missing, show: 'Please use Google Chrome or Microsoft Edge to use the setup wizard. Firefox and Safari do not support USB device access.'\n\n2. **Connect device**: Call navigator.serial.requestPort(). Guide the user to hold BOOT button while plugging in if the device does not appear. Show a GIF or SVG illustration of the ESP32-S3 board with the BOOT button highlighted.\n\n3. **Flash firmware** (if not already spaxel firmware): Use esp-web-tools (espressif/esp-web-tools, CDN: https://unpkg.com/esp-web-tools@10/dist/web/install-button.js). This open-source library handles the full ESP32 flashing pipeline via Web Serial, including ROM bootloader protocol, chip detection, and progress reporting. It needs a firmware manifest.json at GET /api/firmware/manifest describing binary addresses and offsets. Show a progress bar during flashing. Estimated time: 45-90 seconds.\n\n4. **Provision WiFi**: Show a form for SSID and password. Optional: mothership host/port override (for non-mDNS setups). Assemble the provisioning payload and send to the ESP32 over serial as JSON (see Provisioning Payload bead for format). If using esp-web-tools, the provisioning can be injected via custom serial commands after flashing.\n\n5. **Detect mothership**: Once provisioned and rebooted, the ESP32 boots and discovers the mothership via mDNS (spaxel-mothership.local) or the configured host. Poll GET /api/nodes every 3s for up to 120s waiting for the new node to appear. Show animated 'Connecting...' indicator. On timeout: show WiFi troubleshooting guidance (5GHz check, SSID typo check, distance check).\n\n6. **Guided calibration**: Show the CSI waveform for the new node's links as they come online. Steps:\n a. 'Walk around your space for 30 seconds' — CSI amplitude should show activity. If flat: check node orientation.\n b. 'Stand still at the far end of the room' — capture baseline. Show countdown. Green check when baseline is captured.\n c. 'Walk through the centre of the room' — Fresnel zone lights up in 3D view, blob appears. 'The sensor can see you!'\n d. 'Sit down and stay still for 30 seconds' — test stationary detection (if Phase 5 available). Otherwise skip.\n\n7. **Node placement guidance**: Transition to the coverage painting UI (spaxel-qq6) for optimal node positioning. Show GDOP overlay for the current node placement. Suggest additional node positions if coverage is poor.\n\n## Files to Create/Modify\n\n- dashboard/js/onboard.js: wizard state machine, Web Serial API calls, step rendering\n- dashboard/index.html: add /onboard route and wizard container div, import esp-web-tools\n- mothership/internal/dashboard/routes.go (or similar): add GET /api/firmware/manifest route\n- mothership/internal/dashboard/hub.go: no changes needed (wizard uses REST polling, not WebSocket for this flow)\n\n## esp-web-tools Integration\n\n\n\nManifest served at GET /api/firmware/manifest:\n\n\n## Wizard State Machine\n\nStates: BROWSER_CHECK → CONNECT_DEVICE → FLASH_FIRMWARE → PROVISION_WIFI → DETECT_NODE → CALIBRATE → PLACEMENT → COMPLETE\n\nEach state has: render() function, onEnter() side effects, onNext() transition, onBack() for revert, onError() for failure handling.\n\nPersisted in sessionStorage so a page refresh during onboarding resumes from the last step (critical for the reboot-then-detect step).\n\n## Error Handling\n\nMap every known failure to a human-friendly message:\n- 'NotFoundError: No port selected' → 'No device detected. Make sure the USB cable is connected and hold the BOOT button while plugging in.'\n- 'NetworkError' during flash → 'The connection was interrupted. Check the USB cable is not loose and try again.'\n- Node not appearing after 120s → 'Your node connected to WiFi but cannot reach the mothership. Check: 1) Your router blocks device-to-device communication (AP isolation). 2) The mothership address is correct. 3) Your network uses a VLAN that separates devices.'\n- Wrong SSID/password → Node will fall into captive portal mode after 10 failures, triggering a 'Captive portal detected' guidance flow.\n\nNever show stack traces, WebSocket error codes, or Go error strings to the user.\n\n## Tests\n\n- Mock navigator.serial API in Jest (using jest-serial-port or a hand-written mock) to test wizard state transitions without real hardware\n- Test that provisioning payload is correctly assembled and sent over the mocked serial port\n- Test that polling GET /api/nodes correctly detects node appearance and transitions to DETECT_NODE → CALIBRATE\n- Test that BROWSER_CHECK step correctly detects missing serial API and shows the correct error\n- Test that sessionStorage correctly restores wizard state on page refresh at each step\n\n## Acceptance Criteria\n\n- Wizard completes in under 5 minutes on a fresh ESP32-S3 with a working WiFi network\n- User sees live CSI waveform during calibration step\n- Node appears in dashboard after wizard completion, with correct label\n- All known error conditions show human-friendly guidance, not technical errors\n- All existing dashboard tests pass\n- Wizard state is resumable after page refresh","status":"tombstone","priority":2,"issue_type":"task","created_at":"2026-03-28T01:34:58.168170967Z","created_by":"coding","updated_at":"2026-03-28T01:35:25.110026775Z","closed_at":"2026-03-28T01:35:25.110026775Z","source_repo":".","deleted_at":"2026-03-28T01:35:25.110008642Z","deleted_by":"coding","delete_reason":"delete","original_type":"task","compaction_level":0,"original_size":0} {"id":"spaxel-b6a","title":"Implement calibration POST endpoint","description":"## Task\nImplement POST /api/floorplan/calibrate endpoint.\n\n## Specification\n- Accept {ax,ay,bx,by,distance_m,rotation_deg}: two pixel coordinates and their real-world distance\n- Compute and persist pixel-to-meter transform to SQLite floorplan table\n\n## Acceptance\n- Calibration data persists to SQLite floorplan table","status":"closed","priority":2,"issue_type":"task","assignee":"charlie","created_at":"2026-04-07T17:55:52.516620827Z","created_by":"coding","updated_at":"2026-04-07T18:53:06.721066Z","closed_at":"2026-04-07T18:53:06.720893263Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["mitosis-child","mitosis-depth:1","parent-spaxel-klk"]} {"id":"spaxel-bf5","title":"Build crowd flow visualization","description":"Create visualization tools for occupancy patterns and movement.\n\nDeliverables:\n- Trajectory accumulation over time\n- Directional flow map rendering\n- Dwell time hotspot visualization\n\nAcceptance: Dashboard shows accumulated movement patterns and hotspots.","status":"closed","priority":2,"issue_type":"task","assignee":"sp3","created_at":"2026-03-29T19:25:04.155117811Z","created_by":"coding","updated_at":"2026-03-29T19:39:12.378329742Z","closed_at":"2026-03-29T19:39:12.378228906Z","close_reason":"Implemented crowd flow visualization with three components:\n\nBackend (Go):\n- FlowAccumulator records trajectory segments and dwell time in SQLite\n- REST endpoints for flow map, dwell heatmap, and detected corridors\n- Bresenham rasterization, angular variance analysis, connected component labeling\n\nFrontend (JavaScript):\n- Pattern controls in dashboard sidebar (flows, dwell, corridors toggles)\n- Time filter dropdown (7d, 30d, all time)\n- 3D visualization with ArrowHelper, PlaneGeometry, pulsating animations\n\nFiles: dashboard/index.html, dashboard/js/app.js, mothership/internal/analytics/","source_repo":".","compaction_level":0,"original_size":0,"labels":["mitosis-child","mitosis-depth:1","parent-spaxel-i28"]} -{"id":"spaxel-btj","title":"Pre-deployment simulator","description":"## Background\n\nA person considering buying 4+ ESP32-S3 nodes wants to know: will this work in my house? Where should I put the nodes? How accurate will it be with 4 nodes vs 6? The pre-deployment simulator lets users model their space, place virtual nodes, and run synthetic walkers to get an expected accuracy estimate — all before spending any money or touching hardware. It is also a powerful teaching tool for understanding how WiFi CSI sensing works.\n\n## Simulator Mode\n\nNew dashboard route /simulate. A separate UI state that reuses the 3D scene infrastructure but replaces all live data with simulated data.\n\nThe simulator does NOT connect to any hardware or the mothership's live pipeline. It runs entirely in the browser with synthetic CSI generation via a WebAssembly module or JavaScript implementation of the physics model.\n\n(Alternative: run the simulation on the mothership server side, with a separate \"simulation session\" API endpoint. This is more complex but allows reusing the Go signal processing code directly. Recommend the server-side approach for accuracy.)\n\n## Space Editor\n\nReuses the 3D editor from the node placement UI (spaxel-qq6). Additional tools for the simulator:\n- Wall tool: draw lines on the floor plane that represent walls. Walls are stored as line segments and affect the path loss model (each wall crossing reduces RSSI by ~3-6 dB, configurable).\n- Furniture tool: place box-shaped obstacle volumes. Obstacles block direct path and affect Fresnel zone intersection.\n- Room dimensions tool: define the room boundaries (already in node placement UI).\n\n## Virtual Node Placement\n\nSame node placement UI as the real dashboard. Virtual nodes have the same placement interface but no hardware connection. Node icons are greyed out to indicate virtual.\n\nThe placement UI renders the GDOP overlay (from Phase 3, spaxel-qq6) using the virtual node positions. This is the same GDOP computation as the real system.\n\n## Synthetic Walkers\n\n1-4 animated figures that move through the virtual space. Walker types:\n- Random walk: starts at a random position, takes random steps of 0.3-0.8m every 500ms, bounces off walls.\n- Path walk: user draws a polyline path in the 3D view. Walker follows the path and loops.\n- Zone walk: user selects a set of zones. Walker randomly transitions between zones using the zone transition portal geometry.\n\nWalker animation: rendered as the same humanoid mesh used for real blobs in the 3D view but with a distinctive \"ghost\" colour (semi-transparent white) to distinguish from real detections.\n\n## Simulated CSI Generation\n\nFor each virtual walker position at each 100ms timestep, compute the expected CSI frame for each virtual node pair:\n\n1. Path loss: RSSI = RSSI_at_1m - 20*log10(d) - n_walls * wall_attenuation_db\n where d = direct path distance, n_walls = number of walls crossed, wall_attenuation_db = 4 dB default.\n\n2. Fresnel zone contribution: for the walker at position P, compute the Fresnel zone overlap fraction for each link (TX, RX). This uses the same geometry as the FusionEngine (spaxel-m9a).\n\n3. deltaRMS simulation: expected_delta_rms = fresnel_overlap * signal_amplitude + gaussian_noise(sigma)\n signal_amplitude = 0.05 * exp(-distance_from_fresnel_centre / sigma_fresnel) where sigma_fresnel = 0.3m.\n gaussian_noise sigma is calibrated from real-world measurements (see docs/research/ for empirical noise floor).\n\n4. Generate binary CSI frame in the same format as real hardware (24-byte header + I/Q payload). Feed through the actual mothership signal processing pipeline via a simulation API endpoint.\n\n## Pipeline Integration\n\nThe mothership exposes a simulation API: POST /api/simulate/session creates a simulation session. Within a session:\n- Virtual nodes are registered as if they had connected via WebSocket\n- Synthetic frames are injected via POST /api/simulate/session/{id}/frames\n- The standard processing pipeline runs on the injected frames\n- Blob positions are returned in the response\n\nThe dashboard simulator mode polls this API to get blob positions for each simulation timestep.\n\n## Accuracy Estimation\n\nAfter running the simulation with N walkers for 30 seconds:\n- Collect all blob positions from the mothership pipeline\n- Compare to walker ground truth positions (known from the simulation)\n- Compute median position error: median(|blob_position - walker_position|) for matched pairs\n- Compute false positive rate: blob detections when no walker is in that area\n- Compute recall: fraction of walker positions that had a matched blob within 1m\n\nReport: \"With this layout, expected accuracy is ±{N}m median error, {M}% detection rate.\"\n\n## Recommendations Engine\n\nBased on the simulation results, generate actionable layout recommendations:\n- \"Adding a node near the hallway would reduce the east-side dead zone by ~30% GDOP improvement.\"\n- \"Node A and Node B are nearly collinear. Moving Node B 1.5m to the left would improve coverage.\"\n- \"With 4 nodes, you can achieve ±0.8m accuracy. Adding a 5th node would improve to ±0.5m.\"\n\nThese recommendations are generated by:\n1. Running the GDOP computation for the current layout\n2. Identifying zones with GDOP > 2.5 (poor coverage) — dead zone detection\n3. Trying a set of candidate additional-node positions and computing GDOP improvement\n\n## Shopping List\n\nBased on the virtual node count in the simulation:\n\"For this layout you need: {N} × ESP32-S3 Development Board, {N} × USB-C Power Supply (5V 1A), {N} × Adhesive Cable Clips for routing.\"\nInclude a pre-filled Amazon search URL template (not an affiliate link, just a query).\n\n## Files to Create or Modify\n\n- mothership/internal/simulator/session.go: SimulationSession, synthetic frame injection API\n- mothership/internal/simulator/physics.go: path loss model, Fresnel zone CSI generation\n- mothership/internal/simulator/accuracy.go: accuracy estimation, recommendation engine\n- dashboard/js/simulate.js: simulator UI, walker rendering, recommendations display\n- mothership/internal/dashboard/routes.go: POST/GET /api/simulate/ endpoints\n\n## Tests\n\n- Test Fresnel zone CSI simulation: walker at the midpoint of a TX-RX link should produce delta_rms > 0.03; walker at 2m off-axis should produce delta_rms < 0.01\n- Test path loss model: d=1m, n_walls=0 -> RSSI = RSSI_at_1m; d=2m, n_walls=1 -> RSSI = RSSI_at_1m - 6 - 4 = -10 dB relative\n- Test accuracy estimation: 1 walker at known position, simulation produces 1 blob within 0.5m -> accuracy report shows ≤ 0.5m error\n- Test recommendations engine: GDOP > 2.5 in east corner -> recommendation to add node near east corner\n\n## Acceptance Criteria\n\n- Simulator runs without any hardware (all computation in mothership API + browser)\n- GDOP overlay renders correctly for virtual node placements\n- Synthetic walkers produce blob detections via the real mothership pipeline\n- Accuracy estimate is produced after 30-second simulation run\n- Recommendation engine suggests at least one improvement for any layout with a dead zone\n- Shopping list rendered with correct node count\n- Tests pass","status":"open","priority":3,"issue_type":"task","created_at":"2026-03-28T01:56:54.736166126Z","created_by":"coding","updated_at":"2026-03-28T03:29:14.783877908Z","source_repo":".","compaction_level":0,"original_size":0,"dependencies":[{"issue_id":"spaxel-btj","depends_on_id":"spaxel-i28","type":"blocks","created_at":"2026-03-28T03:29:14.783856424Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-btj","depends_on_id":"spaxel-o0e","type":"blocks","created_at":"2026-03-28T01:58:40.668968235Z","created_by":"coding","metadata":"{}","thread_id":""}]} +{"id":"spaxel-bsek","title":"Add spatial quick actions","description":"Right-click context menus on 3D elements with follow camera functionality.","status":"in_progress","priority":2,"issue_type":"task","assignee":"golf","created_at":"2026-04-10T02:03:09.410752186Z","created_by":"coding","updated_at":"2026-04-10T02:44:30.791579191Z","source_repo":".","compaction_level":0,"original_size":0,"labels":["failure-count:2","mitosis-child","mitosis-depth:1","parent-spaxel-17u"]} +{"id":"spaxel-btj","title":"Pre-deployment simulator","description":"## Background\n\nA person considering buying 4+ ESP32-S3 nodes wants to know: will this work in my house? Where should I put the nodes? How accurate will it be with 4 nodes vs 6? The pre-deployment simulator lets users model their space, place virtual nodes, and run synthetic walkers to get an expected accuracy estimate — all before spending any money or touching hardware. It is also a powerful teaching tool for understanding how WiFi CSI sensing works.\n\n## Simulator Mode\n\nNew dashboard route /simulate. A separate UI state that reuses the 3D scene infrastructure but replaces all live data with simulated data.\n\nThe simulator does NOT connect to any hardware or the mothership's live pipeline. It runs entirely in the browser with synthetic CSI generation via a WebAssembly module or JavaScript implementation of the physics model.\n\n(Alternative: run the simulation on the mothership server side, with a separate \"simulation session\" API endpoint. This is more complex but allows reusing the Go signal processing code directly. Recommend the server-side approach for accuracy.)\n\n## Space Editor\n\nReuses the 3D editor from the node placement UI (spaxel-qq6). Additional tools for the simulator:\n- Wall tool: draw lines on the floor plane that represent walls. Walls are stored as line segments and affect the path loss model (each wall crossing reduces RSSI by ~3-6 dB, configurable).\n- Furniture tool: place box-shaped obstacle volumes. Obstacles block direct path and affect Fresnel zone intersection.\n- Room dimensions tool: define the room boundaries (already in node placement UI).\n\n## Virtual Node Placement\n\nSame node placement UI as the real dashboard. Virtual nodes have the same placement interface but no hardware connection. Node icons are greyed out to indicate virtual.\n\nThe placement UI renders the GDOP overlay (from Phase 3, spaxel-qq6) using the virtual node positions. This is the same GDOP computation as the real system.\n\n## Synthetic Walkers\n\n1-4 animated figures that move through the virtual space. Walker types:\n- Random walk: starts at a random position, takes random steps of 0.3-0.8m every 500ms, bounces off walls.\n- Path walk: user draws a polyline path in the 3D view. Walker follows the path and loops.\n- Zone walk: user selects a set of zones. Walker randomly transitions between zones using the zone transition portal geometry.\n\nWalker animation: rendered as the same humanoid mesh used for real blobs in the 3D view but with a distinctive \"ghost\" colour (semi-transparent white) to distinguish from real detections.\n\n## Simulated CSI Generation\n\nFor each virtual walker position at each 100ms timestep, compute the expected CSI frame for each virtual node pair:\n\n1. Path loss: RSSI = RSSI_at_1m - 20*log10(d) - n_walls * wall_attenuation_db\n where d = direct path distance, n_walls = number of walls crossed, wall_attenuation_db = 4 dB default.\n\n2. Fresnel zone contribution: for the walker at position P, compute the Fresnel zone overlap fraction for each link (TX, RX). This uses the same geometry as the FusionEngine (spaxel-m9a).\n\n3. deltaRMS simulation: expected_delta_rms = fresnel_overlap * signal_amplitude + gaussian_noise(sigma)\n signal_amplitude = 0.05 * exp(-distance_from_fresnel_centre / sigma_fresnel) where sigma_fresnel = 0.3m.\n gaussian_noise sigma is calibrated from real-world measurements (see docs/research/ for empirical noise floor).\n\n4. Generate binary CSI frame in the same format as real hardware (24-byte header + I/Q payload). Feed through the actual mothership signal processing pipeline via a simulation API endpoint.\n\n## Pipeline Integration\n\nThe mothership exposes a simulation API: POST /api/simulate/session creates a simulation session. Within a session:\n- Virtual nodes are registered as if they had connected via WebSocket\n- Synthetic frames are injected via POST /api/simulate/session/{id}/frames\n- The standard processing pipeline runs on the injected frames\n- Blob positions are returned in the response\n\nThe dashboard simulator mode polls this API to get blob positions for each simulation timestep.\n\n## Accuracy Estimation\n\nAfter running the simulation with N walkers for 30 seconds:\n- Collect all blob positions from the mothership pipeline\n- Compare to walker ground truth positions (known from the simulation)\n- Compute median position error: median(|blob_position - walker_position|) for matched pairs\n- Compute false positive rate: blob detections when no walker is in that area\n- Compute recall: fraction of walker positions that had a matched blob within 1m\n\nReport: \"With this layout, expected accuracy is ±{N}m median error, {M}% detection rate.\"\n\n## Recommendations Engine\n\nBased on the simulation results, generate actionable layout recommendations:\n- \"Adding a node near the hallway would reduce the east-side dead zone by ~30% GDOP improvement.\"\n- \"Node A and Node B are nearly collinear. Moving Node B 1.5m to the left would improve coverage.\"\n- \"With 4 nodes, you can achieve ±0.8m accuracy. Adding a 5th node would improve to ±0.5m.\"\n\nThese recommendations are generated by:\n1. Running the GDOP computation for the current layout\n2. Identifying zones with GDOP > 2.5 (poor coverage) — dead zone detection\n3. Trying a set of candidate additional-node positions and computing GDOP improvement\n\n## Shopping List\n\nBased on the virtual node count in the simulation:\n\"For this layout you need: {N} × ESP32-S3 Development Board, {N} × USB-C Power Supply (5V 1A), {N} × Adhesive Cable Clips for routing.\"\nInclude a pre-filled Amazon search URL template (not an affiliate link, just a query).\n\n## Files to Create or Modify\n\n- mothership/internal/simulator/session.go: SimulationSession, synthetic frame injection API\n- mothership/internal/simulator/physics.go: path loss model, Fresnel zone CSI generation\n- mothership/internal/simulator/accuracy.go: accuracy estimation, recommendation engine\n- dashboard/js/simulate.js: simulator UI, walker rendering, recommendations display\n- mothership/internal/dashboard/routes.go: POST/GET /api/simulate/ endpoints\n\n## Tests\n\n- Test Fresnel zone CSI simulation: walker at the midpoint of a TX-RX link should produce delta_rms > 0.03; walker at 2m off-axis should produce delta_rms < 0.01\n- Test path loss model: d=1m, n_walls=0 -> RSSI = RSSI_at_1m; d=2m, n_walls=1 -> RSSI = RSSI_at_1m - 6 - 4 = -10 dB relative\n- Test accuracy estimation: 1 walker at known position, simulation produces 1 blob within 0.5m -> accuracy report shows ≤ 0.5m error\n- Test recommendations engine: GDOP > 2.5 in east corner -> recommendation to add node near east corner\n\n## Acceptance Criteria\n\n- Simulator runs without any hardware (all computation in mothership API + browser)\n- GDOP overlay renders correctly for virtual node placements\n- Synthetic walkers produce blob detections via the real mothership pipeline\n- Accuracy estimate is produced after 30-second simulation run\n- Recommendation engine suggests at least one improvement for any layout with a dead zone\n- Shopping list rendered with correct node count\n- Tests pass","status":"open","priority":3,"issue_type":"task","created_at":"2026-03-28T01:56:54.736166126Z","created_by":"coding","updated_at":"2026-04-09T23:28:13.602020044Z","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred"],"dependencies":[{"issue_id":"spaxel-btj","depends_on_id":"spaxel-i28","type":"blocks","created_at":"2026-03-28T03:29:14.783856424Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-btj","depends_on_id":"spaxel-o0e","type":"blocks","created_at":"2026-03-28T01:58:40.668968235Z","created_by":"coding","metadata":"{}","thread_id":""}]} {"id":"spaxel-c02","title":"Mothership: comprehensive /healthz endpoint","description":"## Overview\nExpand the /healthz endpoint from the current minimal response to the full spec required for Docker HEALTHCHECK and Traefik health routing.\n\n## Current state\nGET /healthz returns: {status:'ok', version:'...'} — missing required fields\n\n## Required response (plan lines 3507-3510):\nHealthy: HTTP 200 — {status:'ok', uptime_s:N, version:'...', nodes_online:N, db:'ok', load_level:0-3}\nDegraded: HTTP 503 — {status:'degraded', reason:'...', uptime_s:N, nodes_online:N, db:'ok'|'failing', load_level:0-3}\n\n## Implementation\n- Track start_time at mothership boot; compute uptime_s = int(time.Since(start).Seconds())\n- nodes_online: query ingestion server's connected node count (atomic counter)\n- db health: run 'SELECT 1' against SQLite with 100ms timeout; 'ok' or 'failing'\n- load_level: read from load shedding state (spaxel-zvb)\n- Degraded conditions: db='failing', or load_level=3 for >60s, or nodes_online=0 after 5min uptime\n- reason field: human-readable explanation of degradation\n\n## Docker integration\nUpdate Dockerfile HEALTHCHECK:\nHEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 CMD wget -qO- http://localhost:8080/healthz | grep -q '\"status\":\"ok\"' || exit 1\n\n## Acceptance\n- GET /healthz returns all required fields with correct types\n- HTTP 503 returned when SQLite unreachable (test by renaming DB file)\n- uptime_s increments correctly across multiple calls\n- Docker HEALTHCHECK transitions to 'healthy' within start-period","status":"closed","priority":2,"issue_type":"task","assignee":"alpha","created_at":"2026-04-06T16:43:31.728532118Z","created_by":"coding","updated_at":"2026-04-07T15:14:36.243697798Z","closed_at":"2026-04-07T15:14:36.243595147Z","close_reason":"Comprehensive /healthz endpoint already implemented in commit e44dd34. All required fields present: status, uptime_s, version, nodes_online, db, load_level, reason. Degraded conditions: DB failing, load_level=3 >60s, no nodes after 5min. HTTP 200/503 codes. Docker HEALTHCHECK configured.","source_repo":".","compaction_level":0,"original_size":0,"labels":["failure-count:3"]} {"id":"spaxel-c0q","title":"Phase 5: Reliability & Intelligence","description":"Goal: Production-quality detection for daily home use.\n\nDeliverables:\n- Diurnal adaptive baseline (24-slot hourly vectors, 7-day learning, crossfade, confidence indicator)\n- Stationary person detection (breathing band 0.1-0.5 Hz, long-dwell logic)\n- Ambient confidence score (per-link health: SNR, phase stability, packet rate, drift; composite gauge)\n- Self-healing fleet (auto role re-optimization on node loss/recovery, coverage comparison)\n- Link weather diagnostics (root-cause suggestions, weekly trends, repositioning advice)\n\nExit criteria: System runs unattended 7+ days with <5% false positive rate.","status":"closed","priority":3,"issue_type":"phase","assignee":"delta","created_at":"2026-03-27T01:55:24.131799292Z","created_by":"coding","updated_at":"2026-03-29T16:17:57.940335180Z","closed_at":"2026-03-29T16:17:57.940275703Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred"],"dependencies":[{"issue_id":"spaxel-c0q","depends_on_id":"spaxel-axa","type":"blocks","created_at":"2026-03-28T01:33:43.508871095Z","created_by":"coding","metadata":"{}","thread_id":""}]} {"id":"spaxel-c1c","title":"Fall detection","description":"## Background\n\nFall detection is one of the highest-value safety features for homes with elderly residents or people with medical conditions. Approximately 1 in 4 adults over 65 fall each year, and a fall without prompt help can be fatal. A system that detects falls without requiring the person to press a button (wearable panic buttons are often not worn consistently) can be life-saving.\n\nA CSI-based fall detector works by analysing the track's Z-position history from the biomechanical blob tracker (spaxel-n9n). A fall is characterised by: rapid Z-axis descent (person goes from standing height ~1.7m to floor level ~0.2m in less than 1 second) followed by sustained stillness (no motion for > 30 seconds at floor level). False positives — sitting down quickly, a child lying on the floor, someone doing yoga — must be minimised through careful gating and the post-fall confirmation step.\n\n## Fall Detection Algorithm\n\nImplemented in mothership/internal/tracker/fall.go or as a method on TrackManager.\n\nState machine per track:\n- NORMAL: no fall detected\n- DESCENT_DETECTED: Z velocity trigger fired, monitoring for confirmation\n- FALL_CONFIRMED: post-fall stillness confirmed, alert active\n- ALERT_ACKNOWLEDGED: user acknowledged, monitoring continues\n\nStep 1 — Descent trigger:\nMonitor Z position history over a 200ms rolling window. Compute Z velocity (dZ/dt in m/s).\nTrigger condition: Z velocity < -1.5 m/s AND total Z drop in last 1s > 0.8m.\nOn trigger: transition to DESCENT_DETECTED, record trigger_time.\n\nStep 2 — Post-fall confirmation (the critical false-positive reduction step):\nAfter the descent trigger fires:\na. Check that current Z position is < 0.4m (person is at floor level, not just crouching)\nb. Check that motion (deltaRMS from the contributing links) is < 0.01 for > 30 consecutive seconds\nIf both conditions are met: transition to FALL_CONFIRMED, fire alert chain.\nIf Z rises above 0.4m within the 30-second window (person got up): cancel, return to NORMAL.\n\nStep 3 — False positive suppression:\nApply a higher threshold (drop > 1.2m instead of 0.8m) if the track has a \"sitting\" or \"lying\" posture classification in the last 10 minutes (from posture hints in spaxel-n9n). This reduces false alarms for people who sit down quickly or lie down intentionally.\nApply no fall detection in user-defined \"children's zones\" (zones with the is_children_zone flag) where floor-level activity is normal.\n\n## Alert Chain\n\n1. T+0s: FALL_CONFIRMED transition fires.\n Dashboard: full-width banner with high urgency styling. \"Possible fall detected — [person name] in [zone name]. Are you OK? [Acknowledge] [Call for help]\"\n Browser notification API (if permission granted): \"Spaxel: Possible fall detected — Alice in Hallway\"\n\n2. T+2 minutes (without user acknowledgement):\n Webhook/MQTT alert fires (via AutomationEngine with trigger type \"fall_detected\").\n Push notification via configured channel (ntfy/Pushover).\n\n3. T+5 minutes (without acknowledgement):\n Escalation: second webhook fires to any configured escalation URL (separate from primary webhook). Push notification with \"URGENT\" prefix. Dashboard banner pulses red.\n\nAcknowledgement: the [Acknowledge] button on the dashboard banner:\n- Transitions state to ALERT_ACKNOWLEDGED\n- Cancels the T+2min and T+5min timers\n- Logs the acknowledgement in the activity timeline with timestamp\n- Shows a brief form: \"How is [person name]?\" — [Fine, just fell] / [Needed help] / [False alarm]\n- Feedback stored for accuracy tracking (Phase 7)\n\n## Person Identification in Alerts\n\nIf the track has a confirmed BLE identity:\n- Alert: \"Possible fall detected — Alice in Hallway\"\n- Notification: includes person name and zone\n\nIf the track is anonymous:\n- Alert: \"Possible fall detected — unknown person in Hallway\"\n- Fall event still fires and escalates on the same timeline\n\n## Children's Zones\n\nAdd is_children_zone boolean flag to the zones table (see portals bead). A zone marked as children's zone suppresses fall detection for all tracks within it. Set via zone editor in the dashboard. Rationale: young children spend significant time at floor level (crawling, playing), and false fall alerts in a nursery or playroom are highly counterproductive.\n\n## Z Position Accuracy Dependency\n\nFall detection quality is directly tied to the accuracy of 3D position estimates from the tracker (spaxel-n9n). The UKF state includes Z position, but Z is the hardest axis to localise with WiFi CSI — the nodes are typically all at similar heights (wall-mounted or tabletop), so the vertical Fresnel zone geometry is poor. In practice:\n- Z accuracy is typically ±0.3m for direct LoS links\n- Fall detection requires a Z drop of > 0.8m, which should be detectable even with ±0.3m Z error\n- The 30-second stillness confirmation is the primary false-positive filter — it tolerates poor Z accuracy\n\nDocument this in the dashboard: \"Fall detection works best with nodes at different heights (e.g. one high, one low). Single-level node deployment may miss smaller Z changes.\"\n\n## Integration with Existing Systems\n\nFallDetector subscribes to TrackManager updates (the same 10 Hz update loop as identity matching). It receives the full TrackState including position history and posture hints.\n\nFallDetector emits FallEvent to the internal event bus on FALL_CONFIRMED. The event bus (Phase 8 activity timeline bead) logs it to the timeline. The AutomationEngine processes it for automation triggers. The spatial context notifications module (Phase 6) sends the push notification.\n\n## Files to Create or Modify\n\n- mothership/internal/tracker/fall.go: FallDetector struct, state machine, descent/stillness detection\n- mothership/internal/tracker/manager.go: integrate FallDetector in update loop\n- mothership/internal/events/events.go: FallEvent type\n- dashboard/js/fall.js: fall alert banner, acknowledgement handler, escalation countdown\n- mothership/internal/dashboard/routes.go: POST /api/fall/{event_id}/acknowledge\n\n## Tests\n\n- Test descent trigger: inject synthetic track with Z velocity = -2.0 m/s over 500ms and drop from 1.7m to 0.2m. Verify DESCENT_DETECTED transition.\n- Test post-fall confirmation: after descent trigger, inject 30 seconds of deltaRMS < 0.005 at Z = 0.2m. Verify FALL_CONFIRMED transition.\n- Test that a quick sit-down (Z drops from 1.7m to 0.5m at -1.0 m/s — below speed threshold) does NOT trigger DESCENT_DETECTED.\n- Test false positive suppression: track has \"sitting\" posture history, then fall of 0.9m fires — verify higher threshold (1.2m) is applied and no trigger for 0.9m drop.\n- Test alert chain timing: verify T+2min and T+5min timers fire without acknowledgement.\n- Test that acknowledgement cancels pending timers.\n- Test that children's zone flag suppresses fall detection.\n\n## Acceptance Criteria\n\n- Fall detector transitions to FALL_CONFIRMED on a simulated fall trajectory (2.0 m/s descent, 1.5m drop, 30s floor stillness)\n- Post-fall stillness confirmation fires after 30 consecutive seconds of stillness at Z < 0.4m\n- False positive suppression reduces alerts for quick sit-down actions (drop < 0.8m or speed < 1.5 m/s)\n- Alert chain fires at T+0, T+2min, T+5min without acknowledgement\n- Acknowledgement correctly cancels pending escalation timers\n- Person name included in alert when BLE identity is confirmed\n- Children's zone flag suppresses all fall detection for tracks within that zone\n- Tests pass","status":"closed","priority":3,"issue_type":"task","assignee":"juliet","created_at":"2026-03-28T01:47:29.093424440Z","created_by":"coding","updated_at":"2026-03-29T18:07:39.730764084Z","closed_at":"2026-03-29T18:07:39.730401434Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"dependencies":[{"issue_id":"spaxel-c1c","depends_on_id":"spaxel-c0q","type":"blocks","created_at":"2026-03-28T03:29:14.322493912Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-c1c","depends_on_id":"spaxel-n9n","type":"blocks","created_at":"2026-03-28T01:47:33.774431809Z","created_by":"coding","metadata":"{}","thread_id":""}]} @@ -61,8 +65,10 @@ {"id":"spaxel-csj","title":"Spatial quick actions context menu","description":"## Background\n\nThe 3D scene contains many interactive elements: humanoid track blobs, node spheres, zone cuboids, portal planes, trigger volumes, and empty space. Performing operations on these elements — labelling a track, triggering OTA, creating an automation for a zone — currently requires navigating through multiple panels and menus. The context menu provides a faster, more discoverable path: right-click or long-press on any element, and immediately see the most relevant actions for that element.\n\nThis is a UI polish bead, but one with significant usability impact for power users who frequently interact with the 3D scene.\n\n## Raycasting and Element Detection\n\nWhen a right-click (or 300ms long-press on touch) event fires on the Three.js canvas:\n1. Convert the mouse/touch position to normalised device coordinates (NDC): x = (event.clientX / canvas.width) * 2 - 1, y = -(event.clientY / canvas.height) * 2 + 1\n2. Create a THREE.Raycaster and call raycaster.setFromCamera(ndcCoords, camera)\n3. Cast the ray against the following scene object groups (in priority order, check outermost first):\n a. Track blobs and humanoid meshes (highest priority — users click on people most often)\n b. Node spheres/cylinders\n c. Zone cuboids (bounding box meshes)\n d. Portal plane meshes\n e. Trigger volume bounding boxes\n f. Ground plane (for empty space context menu — always intersects last)\n4. Take the closest intersection with a ray distance check (ignore intersections behind the camera)\n5. Identify the element type from the mesh's userData.type field (set at mesh creation time: \"track\", \"node\", \"zone\", \"portal\", \"trigger_volume\", \"ground\")\n\n## Context Menu Rendering\n\nThe context menu is an HTML div overlay (not a Three.js object) positioned at the mouse/touch coordinates. It must:\n- Appear instantly (no animation delay)\n- Stay within viewport bounds (reposition if near edges)\n- Dismiss on: Escape key, click anywhere outside, second right-click, Tab\n- Not interfere with OrbitControls (prevent camera orbit while menu is open: set controls.enabled = false while menu is visible, restore on dismiss)\n\nContext menu HTML: a `div.context-menu` with `ul.context-menu-list` containing `li.context-menu-item` elements. Each item has an icon (SVG inline) and a label. Dividers are `li.context-menu-divider`.\n\nCSS: box-shadow, border-radius, background #1e293b (dark), 14px font, 36px min item height, hover state highlight.\n\n## Menu Items Per Element Type\n\nTrack/blob:\n- \"Who is this? Assign label\" — opens the People & Devices panel filtered to this track\n- \"Follow (camera)\" — enables follow-camera mode for this track\n- \"View history\" — jumps activity timeline to this track's events (filter by track_id)\n- \"Mark as false positive\" — shortcut to the feedback form with FALSE_POSITIVE pre-selected\n- \"Explain detection\" — triggers explain mode (spaxel-ez4 explainability overlay)\n- divider\n- \"Set as unknown (anonymous)\" — removes identity assignment from this track\n\nNode:\n- \"Edit label\" — opens an inline edit field directly on the node's label in the 3D scene\n- \"View health details\" — opens the link health panel focused on this node's links\n- \"Trigger OTA update\" — triggers OTA for this specific node (with confirmation dialog if node is the last online)\n- \"Locate node (blink LED)\" — sends a blink/identify command via WebSocket to the node\n- \"Re-assign role\" — opens a role picker (TX/RX/TX-RX/passive) inline\n- divider\n- \"Remove from fleet\" — opens confirmation: \"This will disconnect Node [label] and remove its data.\"\n\nEmpty space:\n- \"Add virtual node here\" — places a new virtual node at the clicked ground position (for placement simulation)\n- \"Create zone here\" — starts zone creation mode with the clicked position as one corner\n- \"Set as home point\" — sets the coordinate origin to this position (recentres the floor plan)\n- \"Place portal here\" — starts portal creation mode centred at this position\n\nZone:\n- \"Edit zone bounds\" — enters zone edit mode (drag handles to resize)\n- \"Rename zone\" — inline rename in the zone label\n- \"View occupancy history\" — opens timeline filtered to this zone's transition events\n- \"Create automation for this zone\" — opens the automation builder with this zone pre-selected as trigger target\n- divider\n- \"Delete zone\" — with confirmation\n\nPortal:\n- \"Edit portal\" — enters portal edit mode (move/resize)\n- \"View crossing history\" — opens timeline filtered to portal crossing events for this portal\n- divider\n- \"Delete portal\" — with confirmation\n\nTrigger volume:\n- \"Edit trigger\" — opens the automation associated with this volume in the automation builder\n- \"Test fire\" — fires the automation with test_mode=true flag\n- \"Enable / Disable\" — toggles the automation's enabled flag\n- divider\n- \"Delete trigger volume\" — deletes the volume and its associated automation trigger\n\n## Follow Camera Mode\n\nWhen \"Follow (camera)\" is selected from a track's context menu:\n1. Camera enters follow mode: every render frame, camera.position and camera.target are smoothly interpolated toward a position N metres behind and M metres above the track's current position. N=3m, M=2m default (third-person camera).\n2. A \"Following: Alice\" chip appears in the top-left corner of the 3D canvas.\n3. Camera zoom and pan are disabled during follow mode (OrbitControls disabled).\n4. \"Unfollow\" button in the chip: click to exit follow mode and restore OrbitControls.\n5. If the track is deleted or becomes DELETED state: automatically exit follow mode.\n\nThe interpolation uses Three.js VectorLerp and QuaternionSlerp (or equivalent). The follow distance can be adjusted with the scroll wheel even during follow mode (override only the dolly part of OrbitControls).\n\n## Files to Create or Modify\n\n- dashboard/js/contextmenu.js: ContextMenuManager, raycasting, menu rendering, action dispatch\n- dashboard/js/camera.js (or app.js): follow camera mode logic\n- dashboard/js/contextmenu.css: context menu styles\n- dashboard/js/app.js: register right-click and long-press listeners, integrate ContextMenuManager\n\n## Tests\n\n- Test raycasting correctly identifies element type: mock scene with a \"track\" mesh and a \"node\" mesh; raycast at the track's screen position -> returns element type \"track\"\n- Test that correct menu items appear for each element type: mock scene with one of each type, right-click each, verify menu item labels match the specification\n- Test that \"Follow\" camera mode activates: verify controls.enabled = false and camera follow interpolation fires on each render frame\n- Test dismiss on Escape key, click outside, and second right-click\n- Test that menu stays within viewport: when context menu would extend beyond right edge, it repositions to left of cursor\n- Test \"Trigger OTA\" opens confirmation dialog when node is last online\n- Test \"Mark as false positive\" dispatches correct feedback event\n\n## Acceptance Criteria\n\n- Context menu appears on right-click for all element types in under 50ms\n- Correct action set shown for each element type (no irrelevant actions)\n- \"Follow\" camera mode smoothly tracks the selected track with correct camera offset\n- \"Unfollow\" exits follow mode and restores normal OrbitControls\n- All menu actions execute correctly (dispatching to the correct handler)\n- Menu repositions to stay within viewport bounds\n- Menu dismisses on Escape, click outside, and second right-click\n- Tests pass","status":"open","priority":3,"issue_type":"task","created_at":"2026-03-28T02:01:33.863869938Z","created_by":"coding","updated_at":"2026-03-28T03:29:14.918513652Z","source_repo":".","compaction_level":0,"original_size":0,"dependencies":[{"issue_id":"spaxel-csj","depends_on_id":"spaxel-sl2","type":"blocks","created_at":"2026-03-28T03:29:14.918462075Z","created_by":"coding","metadata":"{}","thread_id":""}]} {"id":"spaxel-cxm","title":"Phase 2: Signal Processing & Detection","description":"Goal: Detect presence on a single link.\n\n3 of 6 items complete (phase sanitisation, baseline system, motion detection).\n\nRemaining:\n- Dashboard presence indicator — per-link motion detected/clear display with amplitude time series\n- CSI recording buffer — disk-backed circular buffer (48h default) for time-travel replay\n- Adaptive sensing rate — mothership-controlled rate changes (idle 2Hz ↔ active 50Hz), on-device amplitude variance check\n\nExit criteria: Dashboard reliably shows motion detected/clear for a single link. Idle links auto-drop to 2 Hz.","status":"closed","priority":2,"issue_type":"phase","assignee":"spaxel-alpha","created_at":"2026-03-27T01:55:01.708603531Z","created_by":"coding","updated_at":"2026-03-28T05:36:26.109167705Z","closed_at":"2026-03-28T05:36:26.109107331Z","close_reason":"Phase 2 complete. All 6 deliverables implemented: phase sanitisation, baseline system, motion detection (973b0a0), dashboard presence indicator (75edd83 + spaxel-26o), CSI recording buffer (0816a5c + spaxel-hey), adaptive sensing rate (bcfd1e3 + spaxel-tim). go test ./... passes.","source_repo":".","compaction_level":0,"original_size":0} {"id":"spaxel-d04","title":"Implement security mode dashboard UI","description":"## Dashboard UI (dashboard/js/security-panel.js)\n\n### Security mode card (always visible in header or sidebar)\n- Arm / Disarm toggle button with confirmation dialog\n- Status badge: DISARMED / LEARNING (N days remaining) / ARMED / ALERT\n- Learning period progress bar: '5 of 7 days complete'\n- Last anomaly: '2 hours ago — kitchen motion at 3:14am'\n\n### Alert banner\n- Full-width red banner when anomaly triggered while armed\n- Description, timestamp, affected zone\n- Acknowledge button (POST /api/anomalies/{id}/acknowledge)\n\n### Anomaly timeline tab\n- List of recent anomaly events with severity, zone, timestamp\n- Links to timeline view for full context\n\n## Acceptance\n- Learning period progress updates on page refresh\n- Anomaly alert banner appears within 2s of detection\n- Acknowledged alerts disappear from the banner (not from history)","status":"closed","priority":2,"issue_type":"task","assignee":"alpha","created_at":"2026-04-06T16:09:35.859782007Z","created_by":"coding","updated_at":"2026-04-07T14:22:13.362922232Z","closed_at":"2026-04-07T14:22:13.362861907Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred","failure-count:1","mitosis-child","mitosis-depth:1","parent-spaxel-a55"]} -{"id":"spaxel-d41","title":"Create pre-deployment simulator","description":"Build simulator with:\n- Virtual space definition\n- Virtual nodes\n- Synthetic walkers\n- GDOP overlay\n\nAcceptance: Simulator produces realistic synthetic data matching real-world conditions.","status":"open","priority":2,"issue_type":"task","created_at":"2026-04-09T14:54:38.804838310Z","created_by":"coding","updated_at":"2026-04-09T14:54:38.804838310Z","source_repo":".","compaction_level":0,"original_size":0,"labels":["mitosis-child","mitosis-depth:1","parent-spaxel-sl2"]} +{"id":"spaxel-d41","title":"Create pre-deployment simulator","description":"Build simulator with:\n- Virtual space definition\n- Virtual nodes\n- Synthetic walkers\n- GDOP overlay\n\nAcceptance: Simulator produces realistic synthetic data matching real-world conditions.","status":"closed","priority":2,"issue_type":"task","assignee":"golf","created_at":"2026-04-09T14:54:38.804838310Z","created_by":"coding","updated_at":"2026-04-10T01:31:26.261658691Z","closed_at":"2026-04-10T01:31:26.261329135Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred","failure-count:14","mitosis-child","mitosis-depth:1","parent-spaxel-sl2"],"dependencies":[{"issue_id":"spaxel-d41","depends_on_id":"spaxel-cha","type":"blocks","created_at":"2026-04-09T16:11:25.448768498Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-d41","depends_on_id":"spaxel-esn","type":"blocks","created_at":"2026-04-09T16:11:25.532279654Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-d41","depends_on_id":"spaxel-q9d","type":"blocks","created_at":"2026-04-09T16:11:25.573588703Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-d41","depends_on_id":"spaxel-z43","type":"blocks","created_at":"2026-04-09T16:11:25.492872540Z","created_by":"coding","metadata":"{}","thread_id":""}]} {"id":"spaxel-dbd","title":"Add floor plan dashboard UI","description":"## Dashboard (dashboard/js/floorplan-setup.js)\n- Setup panel section: 'Floor Plan' with upload button\n- On image select: POST to /api/floorplan/image; display uploaded image on ground plane in 3D scene\n- Calibration UI: click point A on image → click point B → enter real-world distance in meters → Save\n- Compute pixel-to-meter scale factor: scale = distance_m / pixel_distance(A,B)\n- Apply scale and rotation to Three.js ground plane texture on load\n\n## Acceptance\n- Uploaded image displayed as ground plane texture in 3D view\n- Calibrated coordinate system maps pixel positions to correct meter positions\n- Image persists across server restart","status":"closed","priority":2,"issue_type":"task","assignee":"golf","created_at":"2026-04-07T14:46:37.333473683Z","created_by":"coding","updated_at":"2026-04-09T12:37:44.104723182Z","closed_at":"2026-04-09T12:37:44.104601579Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred","mitosis-child","mitosis-depth:1","parent-spaxel-6hd"]} +{"id":"spaxel-duvd","title":"Create morning briefing feature","description":"Daily summary card with push notification option.","status":"open","priority":2,"issue_type":"task","created_at":"2026-04-10T02:03:09.550342367Z","created_by":"coding","updated_at":"2026-04-10T02:03:09.550342367Z","source_repo":".","compaction_level":0,"original_size":0,"labels":["mitosis-child","mitosis-depth:1","parent-spaxel-17u"]} +{"id":"spaxel-eelr","title":"Build guided troubleshooting","description":"Proactive contextual help and post-feedback explanations.","status":"open","priority":2,"issue_type":"task","created_at":"2026-04-10T02:03:09.614829621Z","created_by":"coding","updated_at":"2026-04-10T02:03:09.614829621Z","source_repo":".","compaction_level":0,"original_size":0,"labels":["mitosis-child","mitosis-depth:1","parent-spaxel-17u"]} {"id":"spaxel-esn","title":"Create synthetic walkers","description":"Implement synthetic walkers that move through the virtual space between nodes.\n\nAcceptance:\n- Walkers can traverse between virtual nodes\n- Movement patterns produce realistic synthetic data","status":"closed","priority":2,"issue_type":"task","assignee":"hotel","created_at":"2026-04-09T16:11:25.513037845Z","created_by":"coding","updated_at":"2026-04-09T17:15:23.000870233Z","closed_at":"2026-04-09T17:15:23.000764431Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["failure-count:1","mitosis-child","mitosis-depth:1","parent-spaxel-d41"]} {"id":"spaxel-ez4","title":"Detection explainability overlay","description":"## Background\n\nWhen a blob appears in an unexpected position, or an alert fires that seems wrong, the first question is \"why?\" The explainability overlay answers this question visually in the 3D scene, without requiring the user to understand deltaRMS, Fresnel zones, or UKF — though the data is available for those who want it. This transforms a \"magic box\" into a comprehensible physical system.\n\nThis is also the most important debugging tool for a developer tuning the system: seeing which links contributed most to a blob position, and by how much, is the fastest path to understanding localisation errors.\n\n## ExplainabilitySnapshot\n\nThe FusionEngine (spaxel-m9a) is extended to emit an ExplainabilitySnapshot alongside each BlobUpdate. This snapshot contains all the data needed to explain why a specific blob appeared at a specific position.\n\nExplainabilitySnapshot struct (mothership/internal/fusion/explain.go):\n- blob_id: the ID of the blob being explained\n- blob_position: Vec3 — final estimated position\n- per_link_contributions: []LinkContribution\n - link_id, tx_mac, rx_mac\n - weight float64 — the geometric Fresnel weight for this blob position\n - learned_weight float64 — the learned spatial weight (from weight learner, Phase 7)\n - combined_weight float64 = weight * learned_weight\n - delta_rms float64 — the current deltaRMS for this link\n - contribution_pct float64 — percentage of total fusion score contributed by this link\n - fresnel_intersection_volume float64 — volume of Fresnel zone ellipsoid that overlaps the blob's voxel (proxy for \"how much does this link see this position\")\n- ble_match: optional — if identity is matched: {device_mac, person_id, person_label, ble_distance_m, triangulation_confidence}\n- fusion_score float64 — total occupancy grid score at blob position\n- timestamp of snapshot\n\nThe snapshot is broadcast via WebSocket as \"blob_explain\" message type, alongside the regular \"blob_update\". The frontend requests a snapshot by sending {\"type\":\"request_explain\",\"blob_id\":\"...\"} — the server then enriches the next blob update with the explain data.\n\n## 3D Explain Mode UI\n\nRight-click (desktop) or long-press (mobile, 300ms) on any blob/track in the Three.js scene triggers explain mode.\n\nScene transformation in explain mode:\n1. All link lines dim to 20% opacity (using THREE.MeshBasicMaterial.opacity)\n2. Contributing links — those with contribution_pct > 2% — increase to 100% opacity and glow with colour intensity mapped to contribution_pct (low contribution = pale blue, high contribution = bright yellow)\n3. First Fresnel zone ellipsoids rendered for each contributing link: THREE.Mesh with SphereGeometry scaled by (a, b, b) and rotated to the link axis, translucent wireframe + fill (opacity 0.1). The ellipsoid colour matches the link line colour.\n4. A \"blob explanation panel\" (sidebar overlay, not a Three.js object) shows the breakdown:\n - Blob position in metres: \"Detected at (3.2m, 1.8m, 1.0m)\"\n - Fusion score: \"Detection confidence: [N]%\"\n - Contributing links table: link name, contribution %, deltaRMS, health score — sorted by contribution descending\n - Motion sparkline: small 30-second deltaRMS chart per link (uses the recording buffer data if available, otherwise the in-memory history)\n - BLE match details: \"Identity: Alice (BLE triangulation, confidence 82%, 0.4m from blob)\"\n - If no BLE match: \"Identity: Unknown (no BLE device match)\"\n\nExit explain mode: click anywhere outside the blob, or press Escape. Scene returns to normal opacity levels.\n\n## Fresnel Ellipsoid Geometry\n\nThe first Fresnel zone ellipsoid geometry for a link:\n- TX position P1, RX position P2\n- Link distance d = |P1 - P2|\n- WiFi wavelength lambda = 0.06m (5 GHz) or 0.125m (2.4 GHz) — use the channel from the node's hello message\n- Semi-major axis: a = (d + lambda/2) / 2\n- Semi-minor axis: b = sqrt(a^2 - (d/2)^2)\n- Centre: midpoint(P1, P2)\n- Orientation: the major axis is along the P1->P2 unit vector\n\nIn Three.js: SphereGeometry with radius=1, then scale (a, b, b) with the correct rotation matrix (use THREE.Quaternion.setFromUnitVectors to align with P1->P2 direction).\n\n## Motion Sparkline\n\nFor each contributing link in the explanation panel, show a 30-second history of deltaRMS as a small canvas sparkline (using the existing amplitude history if available from the dashboard WebSocket connection, or fetching from GET /api/recordings/{link_id}/recent?seconds=30 if the recording buffer is available).\n\nThe sparkline shows the moment of detection as a vertical line at the right edge. A horizontal dashed line shows the current motion threshold. Visually conveying \"the signal crossed the threshold at this moment.\"\n\n## Files to Create or Modify\n\n- mothership/internal/fusion/explain.go: ExplainabilitySnapshot, emission logic in FusionEngine\n- mothership/internal/fusion/engine.go: extend to emit ExplainabilitySnapshot alongside BlobUpdate\n- dashboard/js/explain.js: explain mode 3D scene transforms, sidebar panel\n- dashboard/js/fresnel.js: Fresnel ellipsoid geometry helper (reused by Fresnel debug overlay bead)\n- mothership/internal/dashboard/hub.go: blob_explain WebSocket message type\n\n## Tests\n\n- Test ExplainabilitySnapshot generation: with 3 known links and a blob at a known position, verify per_link_contributions are computed correctly\n- Test contribution_pct sums to approximately 100% across all links with non-zero weight\n- Test Fresnel ellipsoid geometry: for TX at (0,0,0) and RX at (4,0,0) with lambda=0.06: a ≈ 2.015, b ≈ 0.345. Verify these values from the geometry computation.\n- Test that explain mode correctly dims/highlights links in the Three.js scene (test via scene state inspection, not visual rendering)\n- Test that WebSocket \"request_explain\" message triggers snapshot emission in the next update cycle\n- Test sidebar panel rendering with mock ExplainabilitySnapshot data\n\n## Acceptance Criteria\n\n- Right-click on any blob triggers explain mode with correct contributing link highlighting\n- Fresnel ellipsoids render at correct positions and sizes for all contributing links\n- Confidence breakdown panel shows per-link contributions that sum to 100%\n- Non-contributing links visually dimmed in explain mode\n- Motion sparklines show 30-second history for each contributing link\n- BLE match details shown when identity is available\n- Escaping explain mode restores all link opacities to normal\n- Tests pass","status":"open","priority":3,"issue_type":"task","created_at":"2026-03-28T01:55:18.006377304Z","created_by":"coding","updated_at":"2026-03-28T03:29:14.817464555Z","source_repo":".","compaction_level":0,"original_size":0,"dependencies":[{"issue_id":"spaxel-ez4","depends_on_id":"spaxel-i28","type":"blocks","created_at":"2026-03-28T03:29:14.817442776Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-ez4","depends_on_id":"spaxel-s70","type":"blocks","created_at":"2026-03-28T01:55:20.955603637Z","created_by":"coding","metadata":"{}","thread_id":""}]} {"id":"spaxel-fi6","title":"Implement Portals CRUD REST endpoints","description":"Implement CRUD endpoints for portals: GET/POST /api/portals, PUT/DELETE /api/portals/{id}. Include OpenAPI-style godoc comments. Portal changes must reflect in live 3D view within one WebSocket cycle.","status":"closed","priority":2,"issue_type":"task","assignee":"foxtrot","created_at":"2026-04-07T13:56:27.334232115Z","created_by":"coding","updated_at":"2026-04-07T17:56:13.860592476Z","closed_at":"2026-04-07T17:56:13.860493596Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred","failure-count:2","mitosis-child","mitosis-depth:1","parent-spaxel-21n"]} @@ -85,7 +91,8 @@ {"id":"spaxel-jcc","title":"Reintegrate phase 6+ packages into default build","description":"## Problem\n\nmain_phase6.go uses a 'phase6' build tag which excludes all Phase 6+ code from the default binary. All backend work from Phase 6 onward is dead code that never runs.\n\n## What needs to change\n\n- Remove the 'phase6' build tag gating from main_phase6.go (or merge into cmd/mothership/main.go)\n- Ensure all packages under: automation/, events/, notify/, replay/, prediction/, learning/, analytics/, sleep/, tracker/, zones/, mqtt/ are wired into the server at startup\n- Run 'go build ./...' to confirm all packages compile cleanly\n- Run 'go test ./...' — all tests must pass\n\n## Files to check\n\n- mothership/cmd/mothership/main.go\n- mothership/cmd/mothership/main_phase6.go (if it exists)\n- Any file with '//go:build phase6'\n\n## Acceptance\n\n'go build -o /dev/null ./...' succeeds with no build tags. All routes, goroutines, and managers from phase 6 packages are initialized in main().","status":"closed","priority":1,"issue_type":"task","assignee":"alpha","created_at":"2026-04-06T12:55:18.201589244Z","created_by":"coding","updated_at":"2026-04-07T06:29:44.917129307Z","closed_at":"2026-04-07T06:29:44.917067598Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["blocked","failure-count:82"],"dependencies":[{"issue_id":"spaxel-jcc","depends_on_id":"spaxel-19h","type":"blocks","created_at":"2026-04-06T22:30:41.001290765Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-jcc","depends_on_id":"spaxel-7nk","type":"blocks","created_at":"2026-04-06T22:30:41.103813566Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-jcc","depends_on_id":"spaxel-9nj","type":"blocks","created_at":"2026-04-06T22:30:40.971412241Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-jcc","depends_on_id":"spaxel-glq","type":"blocks","created_at":"2026-04-06T22:30:40.945729745Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-jcc","depends_on_id":"spaxel-she","type":"blocks","created_at":"2026-04-06T22:30:41.126328414Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-jcc","depends_on_id":"spaxel-uln","type":"blocks","created_at":"2026-04-06T22:30:41.045136934Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-jcc","depends_on_id":"spaxel-x59","type":"blocks","created_at":"2026-04-06T22:30:41.167499700Z","created_by":"coding","metadata":"{}","thread_id":""}]} {"id":"spaxel-jk0","title":"Simple mode with progressive disclosure","description":"## Background\n\nThe 3D expert interface is powerful but overwhelming for casual household members who just want to know \"is anyone home?\" or \"is the baby still asleep?\". Simple mode is a card-based, mobile-first UI that surfaces the most important information without any 3D scene. It should be usable by anyone who can read a smartphone screen, including elderly family members and non-technical partners who did not install the system.\n\nProgressive disclosure means: start with the simplest possible view, and let users reach more complexity when they want it — without being exposed to complexity they don't need.\n\n## Auto-Detection of Simple Mode\n\nSimple mode is automatically selected as the default view based on:\n1. Screen width < 768px (phones, small tablets in portrait)\n2. User-agent contains \"Mobile\" (additional phone detection signal)\n3. User has previously selected simple mode (localStorage \"spaxel_mode\" = \"simple\")\n\nExpert mode is the default for desktop browsers. A user can override the auto-detection and save their preference.\n\n## Room Occupancy Cards\n\nThe main view is a card grid (CSS Grid, 1 column on phones, 2 columns on small tablets). One card per defined zone.\n\nEach occupancy card shows:\n- Zone name (large, readable typography, min 20px font size)\n- Zone colour as a left border accent\n- Occupant count: large number\n- Named occupants: first names in a row (e.g. \"Alice, Bob\"). Anonymous tracks: \"1 person\"\n- Status icon: person silhouette if occupied, empty room icon if vacant\n- \"Last activity\" time: \"3 minutes ago\" (time since last zone transition event in this zone)\n\nAuto-update: cards update in real-time via WebSocket. When occupancy changes, the card animates briefly (a gentle pulse or highlight) to draw attention to the change.\n\nEmpty state (no zones defined): show a \"Get started\" prompt: \"Set up your rooms to see who's home. [Go to setup]\"\n\n## Activity Feed\n\nScrollable list below the zone cards (or as a separate tab). Shows the last 20 person-relevant events, filtered to exclude system noise (no node_connected, no weight_update events — only ZoneTransition, FallDetected, AnomalyDetected).\n\nEvent items: icon + one-line description + timestamp. Examples:\n- \"Alice walked into the Kitchen — 2 minutes ago\"\n- \"Bob left the house — 14 minutes ago\"\n- \"No one home since 8:32am\"\n- \"Possible fall: Alice in Hallway — 3 minutes ago [View] [Acknowledge]\"\n\nPlain English descriptions — no jargon. \"Possible fall\" not \"FallDetected event in zone_hallway_01.\"\n\nTap any event: shows a brief detail popup (not a full detail view). For zone transitions: \"Alice (via Living Room door) at 14:23\". For falls: the fall alert card with acknowledge button.\n\n## Alert Banner\n\nWhen an active unacknowledged alert exists (fall, anomaly, node offline), show a full-width banner at the top of the simple mode view:\n- Fall alert: red background, \"Possible fall — Alice in Hallway. [Acknowledge]\"\n- Anomaly (away mode): orange background, \"Movement detected while away. [View details]\"\n- Node offline: yellow background, \"Node Living Room went offline. [Help]\"\n\nAlerts are ordered by severity (fall > anomaly > node offline) if multiple are active. The [Help] button links to the troubleshooting flow (spaxel-r0l Phase 4 bead).\n\n## Sleep Summary Card\n\nA morning-only card, shown only between 6am and 11am on the day after a sleep session:\n- Position: above zone cards (highest priority in morning)\n- Content: \"Alice slept 7h 23m last night. 2 brief wake-ups. [View details]\"\n- If multiple people: stacked cards or a compact multi-person summary\n- Dismiss button: card hidden for today (localStorage flag \"spaxel_sleep_summary_{date}_shown\")\n- \"View details\" navigates to the Sleep panel in expert mode\n\n## Navigation\n\nBottom navigation bar (mobile-standard pattern): five tabs with icons + labels:\n1. Home (house icon) — occupancy cards (default tab)\n2. Activity (clock icon) — activity feed\n3. (empty centre spot for potential quick-action FAB in future)\n4. Alerts (bell icon) — active alerts and history. Badge with alert count.\n5. Settings (gear icon) — simplified settings: notification channel, person names, mode toggle\n\nThe Settings tab in simple mode shows only: display name for each person (from BLE registry), notification channel status (green = configured, grey = not set), and \"Switch to expert mode\" at the bottom.\n\n## Expert Mode Toggle\n\nA clearly labelled button: \"Expert Mode\" in the settings tab and as a persistent bottom-nav item. Tapping it:\n- If a PIN is configured (expert mode lock, settable in expert mode settings): shows PIN entry pad\n- If no PIN: immediately switches to expert mode\n- Saves preference to localStorage\n\nThe mode toggle is intentionally in settings/bottom-nav rather than prominently on the home screen — to reduce accidental switches for non-technical users.\n\n## Night Mode (OLED Dark)\n\nAuto-active during configured quiet hours (e.g. 10pm-7am). Uses CSS media query prefers-color-scheme: dark plus a manual override. OLED optimised: true black background (#000000), not just dark grey. This saves battery on OLED screens and reduces light disruption in bedrooms.\n\nAll card backgrounds in night mode: #0a0a0a (near-black). Text: #ffffff. Zone colour accents remain colourful.\n\n## Design System\n\nSimple mode uses a separate CSS file (dashboard/css/simple.css) that does NOT import from the expert mode styles. No Three.js canvas, no OrbitControls, no shader materials. Pure HTML + CSS + vanilla JS.\n\nFont size hierarchy: 14px minimum for secondary text, 16px for primary, 24px+ for zone names and counts. All interactive targets: minimum 44px height for WCAG AA touch target compliance.\n\n## Files to Create or Modify\n\n- dashboard/simple.html: simple mode HTML shell with bottom nav\n- dashboard/js/simple.js: card rendering, WebSocket updates, event feed\n- dashboard/js/simplemode.js: mode detection, localStorage mode preference\n- dashboard/css/simple.css: simple mode styles, night mode\n- mothership/internal/dashboard/routes.go: ensure /simple route is served\n\n## Tests\n\n- Test that room occupancy cards correctly reflect current zone state from WebSocket messages\n- Test activity feed filtering: inject a node_connected event and a zone_transition event; only the zone_transition should appear in simple mode feed\n- Test alert banner appears and dismisses correctly on acknowledge\n- Test mode toggle correctly switches between simple and expert mode routes\n- Test sleep summary card appears only between 6am-11am on the morning after a session\n- Test that occupancy card updates show the animated pulse on change\n- Test night mode activates based on quiet hours configuration\n\n## Acceptance Criteria\n\n- Simple mode loads correctly on a 320px wide screen (iPhone SE) without horizontal scrolling\n- Occupancy cards update in real-time as people move between zones\n- Activity feed shows only person-relevant events in plain English\n- Alert banner appears prominently and dismisses on acknowledge\n- Sleep summary card shown between 6am-11am after sleep session, dismissed when tapped\n- Mode toggle to expert mode works and saves preference\n- Night mode activates during configured quiet hours\n- All tap targets are at least 44px in height\n- Tests pass","status":"open","priority":3,"issue_type":"task","created_at":"2026-03-28T01:59:32.690434334Z","created_by":"coding","updated_at":"2026-03-28T03:29:14.851752276Z","source_repo":".","compaction_level":0,"original_size":0,"dependencies":[{"issue_id":"spaxel-jk0","depends_on_id":"spaxel-sl2","type":"blocks","created_at":"2026-03-28T03:29:14.851714754Z","created_by":"coding","metadata":"{}","thread_id":""}]} {"id":"spaxel-jkw","title":"Add Identify context menu to 3D view","description":"Add 'Identify (blink LED)' option to the right-click context menu in the 3D view that POSTs to /api/nodes/{mac}/identify.\n\n**Acceptance:**\n- 3D view right-click menu has 'Identify (blink LED)' option","status":"closed","priority":2,"issue_type":"task","assignee":"golf","created_at":"2026-04-09T11:11:50.047388206Z","created_by":"coding","updated_at":"2026-04-09T11:32:19.559003892Z","closed_at":"2026-04-09T11:32:19.558903935Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["failure-count:1","mitosis-child","mitosis-depth:1","parent-spaxel-h58"]} -{"id":"spaxel-jy4","title":"Crowd flow visualisation","description":"## Background\n\nOver days and weeks, the movement patterns of household members accumulate into meaningful flows: the main corridor between bedroom and bathroom, the typical path from the front door to the kitchen, habitual dwell spots (the favourite chair, the home office desk, the kitchen counter). Visualising these as directional flow maps and dwell hotspot heatmaps provides useful insight into how the space is actually used — and can inform furniture placement, automation placement, and even architectural decisions. It's also a compelling visual that demonstrates the system's accumulated knowledge.\n\n## FlowAccumulator\n\nNew package: mothership/internal/analytics/flow.go\n\nFlowAccumulator subscribes to TrackManager updates (10 Hz) and accumulates trajectory data.\n\nTrajectory sampling: for each track update, if the track has moved > 0.2m since the last recorded waypoint (for that track), record the movement:\n- from_xyz: last waypoint position\n- to_xyz: current position\n- speed: metres per second at this step\n- person_id: if identity is known\n- timestamp\n\nThis 0.2m threshold prevents accumulating thousands of micro-samples for stationary people.\n\nSQLite table: trajectory_segments (id TEXT PRIMARY KEY, person_id TEXT, from_x REAL, from_y REAL, from_z REAL, to_x REAL, to_y REAL, to_z REAL, speed REAL, timestamp DATETIME). Only store ground plane (from_z and to_z floor-projected: set to 0 for the flow map, since we render on the ground plane).\n\nTable growth management: the table accumulates indefinitely. Prune segments older than 90 days (configurable) with a daily background job. With 4 people at typical home movement rates, 90 days generates approximately 50,000 segments — manageable for SQLite.\n\n## Flow Map Computation\n\nQuery: for each 0.25m grid cell (same resolution as OccupancyGrid in FusionEngine), average the movement vectors of all trajectory segments that pass through that cell.\n\nSQL approach: for each segment, determine which grid cells it passes through (Bresenham's line algorithm on the grid). Accumulate vector components (to_x - from_x, to_y - from_y) into per-cell accumulators.\n\nIn practice: compute on demand when requested (not continuously). Cache the result for up to 5 minutes (or until a \"flow dirty\" flag is set by new trajectory data).\n\nOutput: FlowMap struct with per-cell vectors (x_component, y_component) and a cell count. Serialised to JSON for the dashboard.\n\n## Dwell Hotspot Heatmap\n\nQuery: for each track update where speed < 0.1 m/s (stationary or near-stationary), increment the dwell counter for the corresponding 0.25m grid cell.\n\nSQLite table: dwell_accumulator (grid_x INT, grid_y INT, person_id TEXT, count INT, last_updated DATETIME, PRIMARY KEY (grid_x, grid_y, person_id)). Aggregated at the person+cell level for person-filtered views.\n\nOutput: DwellHeatmap struct mapping (grid_x, grid_y) to count. Normalised to [0, 1] by dividing by the max count across all cells.\n\n## Corridor Detection\n\nIdentify grid cells with consistently high flow volume AND low angular variance in their flow vectors. These are likely corridors or pathways.\n\nAlgorithm:\n1. For each cell, compute the circular variance of the flow vector angles across all segments that contributed. Low variance = directional consistency = corridor.\n2. Threshold: cells with segment_count > 10 AND circular_variance < 0.3 are candidate corridor cells.\n3. Connected component analysis: group adjacent corridor cells into corridor regions.\n4. Each corridor region is represented by its dominant direction and a bounding box.\n\nCorridor regions are stored in SQLite: detected_corridors (id, centroid_xyz, dominant_direction_xy, length_m, width_m, cell_count, last_computed). Recomputed weekly.\n\n## Time and Person Filters\n\nThe dashboard allows filtering flow data by:\n- Time range: \"Today\", \"This week\", \"This month\", custom date range. Implemented as SQL WHERE timestamp >= ? filters on the trajectory_segments table.\n- Person: filter to show only trajectories attributed to a specific person_id (or \"All people\").\n\nFiltered queries are run on-demand with SQL indices on (timestamp, person_id).\n\n## Dashboard Visualisation\n\nAdd two toggle-able layers to the 3D scene (in addition to existing layers):\n\n1. \"Flow\" layer: render flow vectors as animated arrows on the ground plane. Each arrow is positioned at the cell centre, oriented in the cell's average flow direction, and sized proportional to the flow volume (segment count). Use Three.js ArrowHelper for rendering. Animate: cycle the arrow colour from 0% to 100% opacity (flowing effect) on a 2-second loop. Only render cells with > 5 segments.\n\n2. \"Dwell Hotspot\" layer: render a heatmap on the ground plane as coloured rectangle patches (Three.js PlaneGeometry with MeshBasicMaterial, colour mapped from blue (low dwell) through green to red (high dwell)). Opacity 0.4. Only render cells with > 10 dwell samples.\n\n3. Corridor highlighting: detected corridors rendered as slightly raised platform geometry (extruded rectangle, height 0.01m) with a pathway colour (warm grey, opacity 0.3). Toggle-able as sub-option of the \"Flow\" layer.\n\nLayer controls: new \"Patterns\" section in the 3D layer control panel. Three checkboxes: \"Movement flows\", \"Dwell hotspots\", \"Corridors\". Time filter dropdown: \"All time / Last 7 days / Last 30 days\". Person filter dropdown.\n\n## REST API\n\nGET /api/analytics/flow?person_id=&since=&until= — returns FlowMap JSON\nGET /api/analytics/dwell?person_id=&since=&until= — returns DwellHeatmap JSON\nGET /api/analytics/corridors — returns list of DetectedCorridor\n\n## Tests\n\n- Test trajectory sampling: track moves 0.25m -> segment recorded; track moves 0.05m -> no segment\n- Test flow vector averaging: 5 segments all pointing East -> cell vector = (1, 0); 5 East + 5 North -> cell vector ~= (0.5, 0.5)\n- Test dwell accumulation: 100 track updates at speed=0 in cell (5, 7) -> dwell_accumulator[5][7] count = 100\n- Test corridor detection: 20 aligned segments in adjacent cells with angular_variance < 0.3 -> corridor detected\n- Test time-range filtering: insert segments at T-1day and T-8days; query since T-7days -> only T-1day segment returned\n- Test 90-day pruning job removes old segments\n\n## Acceptance Criteria\n\n- Flow layer renders correctly in 3D view with animated arrows for rooms with > 7 days of data\n- Dwell hotspot heatmap visible and renders high-use spots (favourite chair, kitchen counter) correctly\n- Corridor overlay visible with detected high-traffic pathways\n- Time and person filter controls update the rendered layers\n- Layer toggles show/hide each layer cleanly without scene rebuild\n- Tests pass","status":"in_progress","priority":3,"issue_type":"task","assignee":"echo","created_at":"2026-03-28T01:52:55.852672681Z","created_by":"coding","updated_at":"2026-04-09T08:50:53.910236304Z","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred","failure-count:325"]} +{"id":"spaxel-jxru","title":"Build fleet status page","description":"Full table view with bulk actions and camera fly-to functionality.","status":"open","priority":2,"issue_type":"task","created_at":"2026-04-10T02:03:09.725489218Z","created_by":"coding","updated_at":"2026-04-10T02:03:09.725489218Z","source_repo":".","compaction_level":0,"original_size":0,"labels":["mitosis-child","mitosis-depth:1","parent-spaxel-17u"]} +{"id":"spaxel-jy4","title":"Crowd flow visualisation","description":"## Background\n\nOver days and weeks, the movement patterns of household members accumulate into meaningful flows: the main corridor between bedroom and bathroom, the typical path from the front door to the kitchen, habitual dwell spots (the favourite chair, the home office desk, the kitchen counter). Visualising these as directional flow maps and dwell hotspot heatmaps provides useful insight into how the space is actually used — and can inform furniture placement, automation placement, and even architectural decisions. It's also a compelling visual that demonstrates the system's accumulated knowledge.\n\n## FlowAccumulator\n\nNew package: mothership/internal/analytics/flow.go\n\nFlowAccumulator subscribes to TrackManager updates (10 Hz) and accumulates trajectory data.\n\nTrajectory sampling: for each track update, if the track has moved > 0.2m since the last recorded waypoint (for that track), record the movement:\n- from_xyz: last waypoint position\n- to_xyz: current position\n- speed: metres per second at this step\n- person_id: if identity is known\n- timestamp\n\nThis 0.2m threshold prevents accumulating thousands of micro-samples for stationary people.\n\nSQLite table: trajectory_segments (id TEXT PRIMARY KEY, person_id TEXT, from_x REAL, from_y REAL, from_z REAL, to_x REAL, to_y REAL, to_z REAL, speed REAL, timestamp DATETIME). Only store ground plane (from_z and to_z floor-projected: set to 0 for the flow map, since we render on the ground plane).\n\nTable growth management: the table accumulates indefinitely. Prune segments older than 90 days (configurable) with a daily background job. With 4 people at typical home movement rates, 90 days generates approximately 50,000 segments — manageable for SQLite.\n\n## Flow Map Computation\n\nQuery: for each 0.25m grid cell (same resolution as OccupancyGrid in FusionEngine), average the movement vectors of all trajectory segments that pass through that cell.\n\nSQL approach: for each segment, determine which grid cells it passes through (Bresenham's line algorithm on the grid). Accumulate vector components (to_x - from_x, to_y - from_y) into per-cell accumulators.\n\nIn practice: compute on demand when requested (not continuously). Cache the result for up to 5 minutes (or until a \"flow dirty\" flag is set by new trajectory data).\n\nOutput: FlowMap struct with per-cell vectors (x_component, y_component) and a cell count. Serialised to JSON for the dashboard.\n\n## Dwell Hotspot Heatmap\n\nQuery: for each track update where speed < 0.1 m/s (stationary or near-stationary), increment the dwell counter for the corresponding 0.25m grid cell.\n\nSQLite table: dwell_accumulator (grid_x INT, grid_y INT, person_id TEXT, count INT, last_updated DATETIME, PRIMARY KEY (grid_x, grid_y, person_id)). Aggregated at the person+cell level for person-filtered views.\n\nOutput: DwellHeatmap struct mapping (grid_x, grid_y) to count. Normalised to [0, 1] by dividing by the max count across all cells.\n\n## Corridor Detection\n\nIdentify grid cells with consistently high flow volume AND low angular variance in their flow vectors. These are likely corridors or pathways.\n\nAlgorithm:\n1. For each cell, compute the circular variance of the flow vector angles across all segments that contributed. Low variance = directional consistency = corridor.\n2. Threshold: cells with segment_count > 10 AND circular_variance < 0.3 are candidate corridor cells.\n3. Connected component analysis: group adjacent corridor cells into corridor regions.\n4. Each corridor region is represented by its dominant direction and a bounding box.\n\nCorridor regions are stored in SQLite: detected_corridors (id, centroid_xyz, dominant_direction_xy, length_m, width_m, cell_count, last_computed). Recomputed weekly.\n\n## Time and Person Filters\n\nThe dashboard allows filtering flow data by:\n- Time range: \"Today\", \"This week\", \"This month\", custom date range. Implemented as SQL WHERE timestamp >= ? filters on the trajectory_segments table.\n- Person: filter to show only trajectories attributed to a specific person_id (or \"All people\").\n\nFiltered queries are run on-demand with SQL indices on (timestamp, person_id).\n\n## Dashboard Visualisation\n\nAdd two toggle-able layers to the 3D scene (in addition to existing layers):\n\n1. \"Flow\" layer: render flow vectors as animated arrows on the ground plane. Each arrow is positioned at the cell centre, oriented in the cell's average flow direction, and sized proportional to the flow volume (segment count). Use Three.js ArrowHelper for rendering. Animate: cycle the arrow colour from 0% to 100% opacity (flowing effect) on a 2-second loop. Only render cells with > 5 segments.\n\n2. \"Dwell Hotspot\" layer: render a heatmap on the ground plane as coloured rectangle patches (Three.js PlaneGeometry with MeshBasicMaterial, colour mapped from blue (low dwell) through green to red (high dwell)). Opacity 0.4. Only render cells with > 10 dwell samples.\n\n3. Corridor highlighting: detected corridors rendered as slightly raised platform geometry (extruded rectangle, height 0.01m) with a pathway colour (warm grey, opacity 0.3). Toggle-able as sub-option of the \"Flow\" layer.\n\nLayer controls: new \"Patterns\" section in the 3D layer control panel. Three checkboxes: \"Movement flows\", \"Dwell hotspots\", \"Corridors\". Time filter dropdown: \"All time / Last 7 days / Last 30 days\". Person filter dropdown.\n\n## REST API\n\nGET /api/analytics/flow?person_id=&since=&until= — returns FlowMap JSON\nGET /api/analytics/dwell?person_id=&since=&until= — returns DwellHeatmap JSON\nGET /api/analytics/corridors — returns list of DetectedCorridor\n\n## Tests\n\n- Test trajectory sampling: track moves 0.25m -> segment recorded; track moves 0.05m -> no segment\n- Test flow vector averaging: 5 segments all pointing East -> cell vector = (1, 0); 5 East + 5 North -> cell vector ~= (0.5, 0.5)\n- Test dwell accumulation: 100 track updates at speed=0 in cell (5, 7) -> dwell_accumulator[5][7] count = 100\n- Test corridor detection: 20 aligned segments in adjacent cells with angular_variance < 0.3 -> corridor detected\n- Test time-range filtering: insert segments at T-1day and T-8days; query since T-7days -> only T-1day segment returned\n- Test 90-day pruning job removes old segments\n\n## Acceptance Criteria\n\n- Flow layer renders correctly in 3D view with animated arrows for rooms with > 7 days of data\n- Dwell hotspot heatmap visible and renders high-use spots (favourite chair, kitchen counter) correctly\n- Corridor overlay visible with detected high-traffic pathways\n- Time and person filter controls update the rendered layers\n- Layer toggles show/hide each layer cleanly without scene rebuild\n- Tests pass","status":"open","priority":3,"issue_type":"task","created_at":"2026-03-28T01:52:55.852672681Z","created_by":"coding","updated_at":"2026-04-09T23:28:13.618819456Z","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred","failure-count:325"]} {"id":"spaxel-jza","title":"Dashboard: PIN change flow","description":"## Overview\nAllow authenticated users to change their dashboard PIN after first setup.\n\n## Backend\n- POST /api/auth/change-pin — requires valid session; body: {old_pin:'...', new_pin:'...'}\n- Verify old_pin against current bcrypt hash; return HTTP 403 if mismatch\n- Hash new_pin with bcrypt cost=12; update auth.pin_bcrypt\n- Existing sessions remain valid after PIN change (session tokens are independent of PIN)\n- Return {ok:true} on success\n\n## Dashboard\n- Settings panel: 'Security' section with 'Change PIN' button\n- Modal form: old PIN → new PIN → confirm new PIN → Submit\n- On 403: show 'Incorrect current PIN' error inline\n- On success: show 'PIN changed successfully' toast; close modal\n\n## Acceptance\n- Old PIN still works immediately after change attempt fails (403)\n- New PIN works on next login after successful change\n- Active session cookie remains valid after PIN change\n- Requires: spaxel-nk6 (PIN auth)","status":"closed","priority":3,"issue_type":"task","assignee":"golf","created_at":"2026-04-06T16:43:09.899017181Z","created_by":"coding","updated_at":"2026-04-09T12:10:28.896292868Z","closed_at":"2026-04-09T12:10:28.896154010Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred"]} {"id":"spaxel-klf","title":"Build self-improving localization","description":"Implement localization that learns from ground truth data.\n\nDeliverables:\n- BLE integration as ground truth source\n- Fresnel zone weight refinement algorithm\n- Continuous weight adjustment based on feedback\n\nAcceptance: Localization accuracy improves automatically as BLE ground truth data accumulates.","notes":"Implementation COMPLETE. Components:\n\n- BLEGroundTruthProvider: RSSI trilateration with Gauss-Newton iteration\n- WeightLearner: Gradient-based Fresnel zone weight refinement \n- SpatialWeightLearner: Per-zone spatial weights with SGD\n- WeightStore: SQLite persistence (link_weights table)\n- Engine fusion.go: Applies learned weights during localization\n- REST API: /api/localization/* endpoints for all features\n\nAcceptance met: Accuracy improves automatically as BLE data accumulates.\n\nPhase 7 (Learning & Analytics) marked COMPLETE in PROGRESS.md.","status":"closed","priority":2,"issue_type":"task","assignee":"golf","created_at":"2026-03-29T19:25:03.995110604Z","created_by":"coding","updated_at":"2026-04-09T14:34:11.347506328Z","closed_at":"2026-04-09T14:34:11.347172223Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred","failure-count:927","mitosis-child","mitosis-depth:1","parent-spaxel-i28"]} {"id":"spaxel-klk","title":"Add floor plan backend API and storage","description":"## Backend (mothership/internal/floorplan.go)\n- POST /api/floorplan/image — multipart form; accept PNG/JPG max 10 MB; save to /data/floorplan/image.png\n- GET /api/floorplan/image — serve the stored image (200 or 404 if none)\n- POST /api/floorplan/calibrate — accept {ax,ay,bx,by,distance_m,rotation_deg}: two pixel coordinates and their real-world distance; compute and persist pixel-to-meter transform\n- GET /api/floorplan/calibrate — return current calibration or 404 if none\n- SQLite floorplan table: image_path TEXT, cal_ax,cal_ay,cal_bx,cal_by REAL, distance_m REAL, rotation_deg REAL, updated_at INT\n\n## Acceptance\n- Image upload saves file to /data/floorplan/image.png\n- Calibration data persists to SQLite\n- > 10 MB upload rejected with 413 error","status":"closed","priority":2,"issue_type":"task","assignee":"charlie","created_at":"2026-04-07T14:46:37.281038019Z","created_by":"coding","updated_at":"2026-04-07T19:03:01.027553189Z","closed_at":"2026-04-07T19:03:01.027363382Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["failure-count:1","mitosis-child","mitosis-depth:1","parent-spaxel-6hd"],"dependencies":[{"issue_id":"spaxel-klk","depends_on_id":"spaxel-05a","type":"blocks","created_at":"2026-04-07T17:55:53.393074362Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-klk","depends_on_id":"spaxel-b6a","type":"blocks","created_at":"2026-04-07T17:55:52.719854848Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-klk","depends_on_id":"spaxel-itf","type":"blocks","created_at":"2026-04-07T17:55:52.239848449Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-klk","depends_on_id":"spaxel-ts2","type":"blocks","created_at":"2026-04-07T17:55:50.722857752Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-klk","depends_on_id":"spaxel-xlo","type":"blocks","created_at":"2026-04-07T17:55:49.889540315Z","created_by":"coding","metadata":"{}","thread_id":""}]} @@ -104,7 +111,7 @@ {"id":"spaxel-ncw","title":"Add system health messages to WebSocket feed","description":"Add 'system_health' message type to /ws/dashboard for periodic system stats every 60s. Broadcast: { type: 'system_health', health: { uptime_s, node_count, bead_count, go_routines, mem_mb } }. Handle in app.js onmessage.","status":"closed","priority":2,"issue_type":"task","assignee":"bravo","created_at":"2026-04-06T14:18:27.674751078Z","created_by":"coding","updated_at":"2026-04-07T12:53:38.767877850Z","closed_at":"2026-04-07T12:53:38.767672942Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred","mitosis-child","mitosis-depth:1","parent-spaxel-9eg"]} {"id":"spaxel-nhl","title":"Build detection explainability system","description":"Create X-ray overlay showing:\n- Contributing links to detections\n- Confidence breakdown\n\nAcceptance: Users can see exactly why a detection was triggered with visual overlays and confidence metrics.","status":"in_progress","priority":2,"issue_type":"task","assignee":"hotel","created_at":"2026-04-09T14:54:38.671332846Z","created_by":"coding","updated_at":"2026-04-09T15:42:40.598403686Z","source_repo":".","compaction_level":0,"original_size":0,"labels":["failure-count:6","mitosis-child","mitosis-depth:1","parent-spaxel-sl2"]} {"id":"spaxel-nk6","title":"Dashboard: PIN setup, login, and session cookie authentication","description":"## Overview\nProtect the dashboard with a PIN that is set on first run and verified on every subsequent visit via session cookies.\n\n## Backend (mothership/internal/auth/)\n- SQLite auth table: pin_bcrypt TEXT, install_secret TEXT (singleton row)\n- GET /api/auth/status — return {pin_configured: bool} — no auth required\n- POST /api/auth/setup — body: {pin:'1234'} — only works if pin not yet configured; bcrypt cost=12; store hash\n- POST /api/auth/login — body: {pin:'1234'} — verify bcrypt; on success issue session cookie:\n Name: spaxel_session, HttpOnly, SameSite=Strict (if TLS), Path=/, Max-Age=604800\n Store session_id → expires_at in SQLite sessions table\n- POST /api/auth/logout — clear session cookie; delete session from SQLite\n- Session middleware: all /api/* and /ws/* require valid session cookie; return 401 if missing/expired\n- Rolling window: on each authenticated request, if within 24h of expiry, extend by 7 days\n\n## Dashboard (dashboard/js/auth.js)\n- On load: GET /api/auth/status; if pin_configured=false → show first-run PIN setup page (full-screen, blocks dashboard)\n- First-run page: enter PIN + confirm PIN → POST /api/auth/setup → reload\n- Login page: shown on 401; PIN entry form → POST /api/auth/login → reload on success\n- Logout button in settings panel → POST /api/auth/logout → redirect to login\n\n## Acceptance\n- Fresh install: setup page shown before any dashboard content\n- After PIN set: login required on next visit\n- Session cookie survives page refresh; expires after 7 days of inactivity\n- 401 returned immediately for any /api/ call without valid cookie","status":"closed","priority":1,"issue_type":"task","assignee":"alpha","created_at":"2026-04-06T16:43:02.833541561Z","created_by":"coding","updated_at":"2026-04-06T17:17:02.044261204Z","closed_at":"2026-04-06T17:17:02.044047110Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["failure-count:2"]} -{"id":"spaxel-nqh","title":"BLE-to-blob identity matching","description":"## Background\n\nThe BLE device registry (spaxel-2wg) tells us which labelled devices are present in the home and their per-node RSSI. The CSI fusion engine (spaxel-m9a) and blob tracker (spaxel-n9n) tell us where anonymous humanoid figures are located in 3D space. Identity matching bridges these two systems: given named BLE devices with per-node RSSI observations, and anonymous CSI blobs with estimated 3D positions, assign device identities to blobs.\n\nWhen a match is confident, the humanoid figure in the 3D view gains a name label and person colour. \"Alice is in the Kitchen\" becomes a real-time fact rather than an approximation.\n\n## RSSI Triangulation Algorithm\n\nFor each BLE device with observations from multiple nodes in the current scan cycle (last 5 seconds):\n\nStep 1: Convert RSSI to distance for each observing node.\nDistance model: d = d0 * 10^((RSSI_ref - RSSI) / (10 * n))\nParameters: d0 = 1.0m (reference distance), RSSI_ref = -65 dBm (RSSI at 1m in typical indoor environment), n = 2.5 (indoor path loss exponent — typical range 2.0-3.5; 2.5 is a reasonable default for residential spaces).\n\nStep 2: With 2+ nodes, perform weighted least squares triangulation.\nPosition estimate: argmin_P { sum_i w_i * (|P - node_i| - d_i)^2 }\nwhere w_i = 1/sigma_i^2, sigma_i = d_i * ln(10) / (10 * n) * RSSI_noise_sigma (typically 5 dBm).\nSolve with 3-5 iterations of gradient descent or Gauss-Newton (the system is nonlinear).\nWith 1 node: only an approximate range estimate; triangulation confidence = 0.2.\nWith 2 nodes: 2D position estimate on a circle/arc; confidence = 0.5.\nWith 3+ nodes: full 2D position estimate with residual as quality indicator; confidence = min(1.0, 0.7 + 0.1 * (n-3)) where n is node count.\n\nStep 3: Assign to nearest CSI blob.\nFor each triangulated BLE position, find the nearest active CSI blob (from TrackManager) within a 2-metre search radius. The assignment uses Euclidean distance in the horizontal plane (ignore Z for BLE since antenna height is variable).\n\nIf multiple BLE devices map to the same blob (e.g. Alice has a phone AND a Fitbit), use the device with the highest triangulation confidence.\n\nIf a BLE device position is triangulated but no CSI blob is within 2 metres: create a \"BLE-only\" placeholder track at the BLE position. BLE-only tracks are shown as a different visual (outlined circle rather than filled, lower opacity) to indicate lower confidence.\n\n## Match Confidence Score\n\nFor each BLE-to-blob assignment, compute a match confidence:\nconfidence = f_observations * f_node_count * f_residual * f_distance\n\nwhere:\n- f_observations: 1.0 if device seen in last 5s, 0.5 if last 15s, 0.0 if older\n- f_node_count: 0.2 (1 node), 0.5 (2 nodes), 0.8+ (3+ nodes)\n- f_residual: 1.0 - min(1.0, triangulation_residual_metres / 2.0) — penalise poor triangulation fit\n- f_distance: 1.0 if blob distance < 0.5m, linear decay to 0 at 2.0m\n\nOnly assign identity if confidence > 0.6. Below this threshold: keep the blob anonymous (\"Unknown\").\n\n## Identity Persistence\n\nOnce a BLE-blob match is made, the identity persists for 5 minutes even if:\n- The BLE device rotates its MAC (new MAC will match same person via the person record)\n- The BLE device briefly falls below RSSI threshold of all nodes (indoor dead zone)\n- The CSI blob briefly disappears (tracker coasted state, per spaxel-n9n)\n\nAfter 5 minutes of no BLE observation and no high-confidence re-match: revert to anonymous.\n\nThis 5-minute persistence prevents flickering identity labels when people walk through areas with inconsistent BLE coverage.\n\n## TrackManager Integration\n\nExtend the TrackState struct in mothership/internal/tracker/ (spaxel-n9n):\n- PersonID string (from BLE registry people table)\n- PersonLabel string\n- PersonColor string\n- IdentityConfidence float64\n- IdentitySource string (\"ble_triangulation\" or \"ble_only\" or \"\")\n\nTrackManager.UpdateIdentities(blePositions map[deviceMAC]Vec3, registry BLERegistry) method: runs the matching algorithm and updates track identity fields.\n\nCalled at the same frequency as FusionEngine (10 Hz), but BLE positions only update at 5s intervals — cache the last BLE positions and re-use them between BLE updates.\n\n## API\n\nGET /api/tracks enriches the existing track list with person_id, person_label, person_color, and identity_confidence fields.\n\nExample response:\n[{\n \"id\": \"track-1\",\n \"position\": {\"x\": 3.2, \"y\": 1.8, \"z\": 1.0},\n \"velocity\": {\"x\": 0.1, \"y\": -0.2, \"z\": 0.0},\n \"confidence\": 0.87,\n \"posture_hint\": \"standing\",\n \"person_id\": \"uuid-alice\",\n \"person_label\": \"Alice\",\n \"person_color\": \"#3b82f6\",\n \"identity_confidence\": 0.82\n}]\n\n## Dashboard Integration\n\nIn the 3D view (Three.js scene): tracks with confirmed identity display a floating text label (person name) above the humanoid figure mesh, rendered using THREE.Sprite with a canvas texture containing the name in the person's colour.\n\nIn the \"People and Devices\" panel: each person row shows \"Currently: Kitchen\" (current zone from room transition portals, Phase 6) and \"In 3D view: [jump to track]\" link.\n\n## Tests\n\n- Test RSSI-to-distance conversion with known values: RSSI=-65 -> d=1.0m, RSSI=-75 -> d=2.5m (with default params)\n- Test triangulation with 3 nodes at known positions and known distances: verify position error < 0.5m\n- Test nearest-blob assignment: 2 blobs at (2,2) and (5,5), BLE device triangulated at (2.3,1.9) -> assigns to first blob\n- Test confidence gate: confidence=0.55 -> no assignment; confidence=0.65 -> assignment made\n- Test BLE-only placeholder track creation when no blob within 2m\n- Test identity persistence: after BLE device disappears, track retains identity for 5 minutes then reverts\n- Test identity handoff when BLE device MAC rotates: same person assignment maintained via person record\n\n## Acceptance Criteria\n\n- Named identity labels appear on 3D blobs when person carries a labelled BLE device with confidence > 0.6\n- Identity is maintained through brief BLE dead zones (up to 5 minutes)\n- Two people in the same room get correct distinct identities when their BLE devices are distinguishable\n- Confidence gate prevents wrong assignments (no identity label when confidence < 0.6)\n- BLE-only placeholder tracks appear for people whose BLE device is heard but no CSI blob is nearby\n- Tests pass","status":"in_progress","priority":3,"issue_type":"task","assignee":"echo","created_at":"2026-03-28T01:44:50.795871765Z","created_by":"coding","updated_at":"2026-04-07T20:36:11.407019373Z","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred","failure-count:52"]} +{"id":"spaxel-nqh","title":"BLE-to-blob identity matching","description":"## Background\n\nThe BLE device registry (spaxel-2wg) tells us which labelled devices are present in the home and their per-node RSSI. The CSI fusion engine (spaxel-m9a) and blob tracker (spaxel-n9n) tell us where anonymous humanoid figures are located in 3D space. Identity matching bridges these two systems: given named BLE devices with per-node RSSI observations, and anonymous CSI blobs with estimated 3D positions, assign device identities to blobs.\n\nWhen a match is confident, the humanoid figure in the 3D view gains a name label and person colour. \"Alice is in the Kitchen\" becomes a real-time fact rather than an approximation.\n\n## RSSI Triangulation Algorithm\n\nFor each BLE device with observations from multiple nodes in the current scan cycle (last 5 seconds):\n\nStep 1: Convert RSSI to distance for each observing node.\nDistance model: d = d0 * 10^((RSSI_ref - RSSI) / (10 * n))\nParameters: d0 = 1.0m (reference distance), RSSI_ref = -65 dBm (RSSI at 1m in typical indoor environment), n = 2.5 (indoor path loss exponent — typical range 2.0-3.5; 2.5 is a reasonable default for residential spaces).\n\nStep 2: With 2+ nodes, perform weighted least squares triangulation.\nPosition estimate: argmin_P { sum_i w_i * (|P - node_i| - d_i)^2 }\nwhere w_i = 1/sigma_i^2, sigma_i = d_i * ln(10) / (10 * n) * RSSI_noise_sigma (typically 5 dBm).\nSolve with 3-5 iterations of gradient descent or Gauss-Newton (the system is nonlinear).\nWith 1 node: only an approximate range estimate; triangulation confidence = 0.2.\nWith 2 nodes: 2D position estimate on a circle/arc; confidence = 0.5.\nWith 3+ nodes: full 2D position estimate with residual as quality indicator; confidence = min(1.0, 0.7 + 0.1 * (n-3)) where n is node count.\n\nStep 3: Assign to nearest CSI blob.\nFor each triangulated BLE position, find the nearest active CSI blob (from TrackManager) within a 2-metre search radius. The assignment uses Euclidean distance in the horizontal plane (ignore Z for BLE since antenna height is variable).\n\nIf multiple BLE devices map to the same blob (e.g. Alice has a phone AND a Fitbit), use the device with the highest triangulation confidence.\n\nIf a BLE device position is triangulated but no CSI blob is within 2 metres: create a \"BLE-only\" placeholder track at the BLE position. BLE-only tracks are shown as a different visual (outlined circle rather than filled, lower opacity) to indicate lower confidence.\n\n## Match Confidence Score\n\nFor each BLE-to-blob assignment, compute a match confidence:\nconfidence = f_observations * f_node_count * f_residual * f_distance\n\nwhere:\n- f_observations: 1.0 if device seen in last 5s, 0.5 if last 15s, 0.0 if older\n- f_node_count: 0.2 (1 node), 0.5 (2 nodes), 0.8+ (3+ nodes)\n- f_residual: 1.0 - min(1.0, triangulation_residual_metres / 2.0) — penalise poor triangulation fit\n- f_distance: 1.0 if blob distance < 0.5m, linear decay to 0 at 2.0m\n\nOnly assign identity if confidence > 0.6. Below this threshold: keep the blob anonymous (\"Unknown\").\n\n## Identity Persistence\n\nOnce a BLE-blob match is made, the identity persists for 5 minutes even if:\n- The BLE device rotates its MAC (new MAC will match same person via the person record)\n- The BLE device briefly falls below RSSI threshold of all nodes (indoor dead zone)\n- The CSI blob briefly disappears (tracker coasted state, per spaxel-n9n)\n\nAfter 5 minutes of no BLE observation and no high-confidence re-match: revert to anonymous.\n\nThis 5-minute persistence prevents flickering identity labels when people walk through areas with inconsistent BLE coverage.\n\n## TrackManager Integration\n\nExtend the TrackState struct in mothership/internal/tracker/ (spaxel-n9n):\n- PersonID string (from BLE registry people table)\n- PersonLabel string\n- PersonColor string\n- IdentityConfidence float64\n- IdentitySource string (\"ble_triangulation\" or \"ble_only\" or \"\")\n\nTrackManager.UpdateIdentities(blePositions map[deviceMAC]Vec3, registry BLERegistry) method: runs the matching algorithm and updates track identity fields.\n\nCalled at the same frequency as FusionEngine (10 Hz), but BLE positions only update at 5s intervals — cache the last BLE positions and re-use them between BLE updates.\n\n## API\n\nGET /api/tracks enriches the existing track list with person_id, person_label, person_color, and identity_confidence fields.\n\nExample response:\n[{\n \"id\": \"track-1\",\n \"position\": {\"x\": 3.2, \"y\": 1.8, \"z\": 1.0},\n \"velocity\": {\"x\": 0.1, \"y\": -0.2, \"z\": 0.0},\n \"confidence\": 0.87,\n \"posture_hint\": \"standing\",\n \"person_id\": \"uuid-alice\",\n \"person_label\": \"Alice\",\n \"person_color\": \"#3b82f6\",\n \"identity_confidence\": 0.82\n}]\n\n## Dashboard Integration\n\nIn the 3D view (Three.js scene): tracks with confirmed identity display a floating text label (person name) above the humanoid figure mesh, rendered using THREE.Sprite with a canvas texture containing the name in the person's colour.\n\nIn the \"People and Devices\" panel: each person row shows \"Currently: Kitchen\" (current zone from room transition portals, Phase 6) and \"In 3D view: [jump to track]\" link.\n\n## Tests\n\n- Test RSSI-to-distance conversion with known values: RSSI=-65 -> d=1.0m, RSSI=-75 -> d=2.5m (with default params)\n- Test triangulation with 3 nodes at known positions and known distances: verify position error < 0.5m\n- Test nearest-blob assignment: 2 blobs at (2,2) and (5,5), BLE device triangulated at (2.3,1.9) -> assigns to first blob\n- Test confidence gate: confidence=0.55 -> no assignment; confidence=0.65 -> assignment made\n- Test BLE-only placeholder track creation when no blob within 2m\n- Test identity persistence: after BLE device disappears, track retains identity for 5 minutes then reverts\n- Test identity handoff when BLE device MAC rotates: same person assignment maintained via person record\n\n## Acceptance Criteria\n\n- Named identity labels appear on 3D blobs when person carries a labelled BLE device with confidence > 0.6\n- Identity is maintained through brief BLE dead zones (up to 5 minutes)\n- Two people in the same room get correct distinct identities when their BLE devices are distinguishable\n- Confidence gate prevents wrong assignments (no identity label when confidence < 0.6)\n- BLE-only placeholder tracks appear for people whose BLE device is heard but no CSI blob is nearby\n- Tests pass","status":"open","priority":3,"issue_type":"task","created_at":"2026-03-28T01:44:50.795871765Z","created_by":"coding","updated_at":"2026-04-09T23:28:13.640321106Z","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred","failure-count:52"]} {"id":"spaxel-o0e","title":"Fresnel zone debug overlay","description":"## Background\n\nThe Fresnel zone geometry is at the heart of the fusion algorithm (spaxel-m9a). Every link's contribution to the 3D occupancy grid is weighted by how much of the candidate voxel falls within the first Fresnel zone ellipsoid. When debugging why localisation is placing a blob in the wrong position, being able to see the actual Fresnel ellipsoids for each active link — overlaid on the 3D scene — instantly reveals whether the zones are covering the right area.\n\nThis is a pure debug/developer tool. It is toggle-able (off by default) and intended for system tuners and developers, not end users. The explainability overlay (spaxel-ez4) already shows Fresnel ellipsoids for a specific selected blob. The Fresnel zone debug overlay shows them persistently for all active links simultaneously.\n\n## Ellipsoid Geometry (Recap)\n\nFor each active link with TX at position P1 and RX at position P2:\n- Link distance d = |P1 - P2|\n- WiFi channel wavelength lambda: 5 GHz -> lambda = 0.06m, 2.4 GHz -> lambda = 0.125m. Use the channel reported in the node's hello message (or the channel from the link's last received CSI frame header).\n- Semi-major axis: a = (d + lambda/2) / 2\n- Semi-minor axis: b = sqrt(a^2 - (d/2)^2)\n- Ellipsoid centre: midpoint(P1, P2)\n- Ellipsoid orientation: major axis along the P1->P2 unit vector\n\nThe first Fresnel zone ellipsoid represents the region where a point reflector would shorten the signal path by at most half a wavelength relative to the direct path. Motion within this region has maximum impact on CSI.\n\n## Three.js Rendering\n\nEllipsoid mesh construction:\n1. Start with THREE.SphereGeometry(1, 32, 16) — a unit sphere\n2. Apply non-uniform scaling: new THREE.Vector3(a, b, b) via mesh.scale.set(a, b, b)\n3. Rotate to align with the link axis: compute the quaternion that maps (1,0,0) to the P1->P2 unit vector using THREE.Quaternion.setFromUnitVectors(new THREE.Vector3(1,0,0), linkAxis)\n4. Apply the quaternion to mesh.quaternion\n\nMaterial: TWO materials:\n- Wireframe: THREE.LineSegments with EdgesGeometry for crisp wireframe edges, line color matching the link line colour, opacity 0.6\n- Fill: THREE.MeshBasicMaterial with transparent=true, opacity 0.08, colour matching the link, depthWrite=false (so the fill doesn't obscure other geometry)\n\nLayer toggle: add \"Fresnel Zones\" checkbox to the 3D layer control panel (in the \"Debug\" section, only visible when expert mode is active). Default: off. When toggled on, add all ellipsoid meshes to the scene. When toggled off, remove them.\n\n## Per-Link Controls\n\nWhen a user hovers over a Fresnel ellipsoid in the 3D scene (using Three.js raycasting):\n- The corresponding link line highlights (brightness increase)\n- A tooltip appears (HTML overlay, positioned at screen coordinates of the hover point):\n \"Link: [tx_label] to [rx_label]\n Fresnel zone radius at midpoint: {b:.2f}m\n Link distance: {d:.2f}m\n Wavelength: {lambda:.3f}m (channel {ch})\n Link health: {health_score:.0%}\"\n\nClicking an ellipsoid:\n- Selects the corresponding link in the link panel (sidebar)\n- Highlights the link entry in the link list\n\n## Performance Considerations\n\nWith 6 active links, we render 6 pairs of meshes (wireframe + fill = 12 Three.js objects). This is negligible for any modern GPU. However, the wireframe geometry uses EdgesGeometry which creates one Line for each edge — for a sphere with 32 horizontal and 16 vertical segments, that's approximately 1000 line segments per ellipsoid. At 6 links, 6000 line segments total. This should render at 60 fps on any modern device, but if performance is an issue on mobile, reduce the sphere segment count to 16x8 when the debug overlay is active on mobile viewports.\n\nPre-compute at link addition time: when a new link is registered (node hello + peer MAC), compute the ellipsoid geometry and add it to the scene (hidden if the layer is off). Update on node position change. Remove when link becomes inactive (no frames for > 30s).\n\n## Relationship to Explainability Overlay\n\nThe Fresnel zone debug overlay (this bead) and the detection explainability overlay (spaxel-ez4) both render Fresnel ellipsoids. They share the same geometry computation code (dashboard/js/fresnel.js — the ellipsoid helper function). The difference:\n- This overlay: shows all active link ellipsoids simultaneously, toggle-able layer\n- Explainability overlay: shows only contributing link ellipsoids for a specific selected blob, in explain mode\n\nBoth import from fresnel.js. The helper function FresnelEllipsoid(P1, P2, lambda) returns a Three.js Mesh ready for scene insertion.\n\n## Files to Create or Modify\n\n- dashboard/js/fresnel.js: FresnelEllipsoid helper function (shared with explainability)\n- dashboard/js/layers.js: add \"Fresnel Zones\" toggle in the debug layer section\n- dashboard/js/app.js: integrate Fresnel overlay management — create/update/remove ellipsoids on link events\n\n## Tests\n\n- Test ellipsoid geometry computation with known TX/RX positions: TX at (0,0,0), RX at (4,0,0), lambda=0.06m -> a ~= 2.015, b ~= 0.345. Verify to 3 decimal places.\n- Test semi-minor axis for edge case: very short link d=0.1m -> b should be very small but positive\n- Test for diagonal link: TX at (0,0,0), RX at (3,4,0) (distance=5m) -> verify a and b are computed correctly\n- Test that toggling the layer on/off adds/removes the correct number of mesh objects from the scene (mock Three.js scene)\n- Test hover tooltip shows correct data (link health from mock, link endpoints from mock)\n- Test that ellipsoids update when node position changes\n\n## Acceptance Criteria\n\n- Fresnel zone ellipsoids render correctly for all active links when the debug layer is toggled on\n- Ellipsoid semi-major and semi-minor axes match theoretical first Fresnel zone values for the link distance and frequency\n- Toggle shows/hides all ellipsoids cleanly without leaving orphan objects in the scene\n- Hovering an ellipsoid shows the correct tooltip with link details and health score\n- Clicking an ellipsoid selects the corresponding link in the link panel\n- Geometry computation is shared with the explainability overlay via fresnel.js\n- Tests pass","status":"open","priority":3,"issue_type":"task","created_at":"2026-03-28T01:58:33.424914116Z","created_by":"coding","updated_at":"2026-03-28T03:29:14.736776003Z","source_repo":".","compaction_level":0,"original_size":0,"dependencies":[{"issue_id":"spaxel-o0e","depends_on_id":"spaxel-i28","type":"blocks","created_at":"2026-03-28T03:29:14.736620594Z","created_by":"coding","metadata":"{}","thread_id":""}]} {"id":"spaxel-o4l","title":"Bidirectional node protocol","description":"Implement full bidirectional protocol over the existing WebSocket connection.\n\n## Deliverables\n- Registration (hello message with capabilities)\n- Health reporting (heap, WiFi RSSI, uptime, temperature every 10s)\n- BLE scan relay (device list JSON)\n- Role/config push from mothership (TX/RX/passive mode, packet rate)\n- OTA command messages (trigger update, progress tracking)\n- All messages over the existing single WebSocket per node\n\n## Acceptance Criteria\n- Nodes register on connect with full capability advertisement\n- Mothership can push role changes and config updates\n- Health metrics flow reliably at 10s intervals\n- Protocol is backward-compatible with Phase 1 implementation\n\n## References\n- Current protocol: mothership/internal/ingestion/message.go\n- Firmware WebSocket: firmware/main/websocket.c","status":"closed","priority":2,"issue_type":"task","assignee":"spaxel-alpha","created_at":"2026-03-27T01:56:31.632551776Z","created_by":"coding","updated_at":"2026-03-28T01:34:05.644219477Z","closed_at":"2026-03-27T03:14:43.201850105Z","close_reason":"Implemented full bidirectional node protocol. Firmware: motion hints wired to websocket_send_motion_hint() with rate-limiting, csi_set_rate() fixed, all message types active (hello/health/ble/motion_hint/ota_status). Mothership: OnMotionHint() ramps adjacent nodes via topology callback, idle timeout 30s, variance threshold adaptive, added SendRoleToMAC() and SendOTAToMAC() for dynamic downstream pushes, OTA status logging. Binary CSI frames remain backward-compatible with Phase 1.","source_repo":".","compaction_level":0,"original_size":0,"dependencies":[{"issue_id":"spaxel-o4l","depends_on_id":"spaxel-uc9","type":"blocks","created_at":"2026-03-28T01:34:05.644181123Z","created_by":"coding","metadata":"{}","thread_id":""}]} {"id":"spaxel-ofa","title":"End-to-end integration test harness (simulator + mothership assertions)","description":"## Overview\nBuild an automated integration test that starts the mothership, runs the CSI simulator against it, and asserts on observable behavior — providing a production-realism gate for CI.\n\n## Test harness (tests/e2e/run.sh or Go test)\n\n### Setup:\n1. Start mothership container (or binary): docker run -d -p 8080:8080 ronaldraygun/spaxel:latest\n2. Wait for /healthz to return {status:'ok'} with 15s timeout (poll every 500ms)\n3. If PIN auth enabled: POST /api/auth/setup with test PIN; POST /api/auth/login\n\n### Run simulator:\n4. Start: sim --mothership http://localhost:8080 --nodes 4 --walkers 2 --duration 30s --rate 20 --ble --seed 42\n5. Simulator exits non-zero if it receives {type:'reject'} message; test fails immediately\n\n### Assert during run (poll every 1s for 30s):\n6. GET /api/blobs (or WebSocket) → assert blob_count > 0 within first 15s\n7. GET /api/nodes → assert nodes_online == 4 within first 5s\n8. GET /healthz → assert status=='ok' throughout entire run\n\n### Assert after run:\n9. GET /api/events?type=detection → assert at least 1 detection event recorded\n10. Simulator printed per-second frame counts to stdout; verify no frame-rate drop >20% from target\n\n## CI integration\n- GitHub Actions workflow: .github/workflows/e2e.yml (but only triggers from Argo Workflows via spaxel-ci)\n- Build image → run test harness → post result as bead comment\n\n## Acceptance\n- Test passes on fresh container with seed 42 configuration\n- Test fails clearly when mothership rejects frames (wrong protocol)\n- Test runs in <90s total (15s startup + 30s sim + 45s buffer)","status":"closed","priority":2,"issue_type":"task","assignee":"alpha","created_at":"2026-04-06T16:44:47.443177386Z","created_by":"coding","updated_at":"2026-04-07T20:01:09.701396700Z","closed_at":"2026-04-07T20:01:09.701265832Z","close_reason":"Implemented end-to-end integration test harness for Spaxel:\n\n1. Argo WorkflowTemplate spaxel-e2e-workflowtemplate.yml added to declarative-config for CI/CD integration\n\n2. Existing test infrastructure already in place:\n - Bash script harness: tests/e2e/run.sh\n - Go test harness: mothership/tests/e2e/e2e_test.go\n - CSI simulator: mothership/cmd/sim/main.go\n - GitHub Actions workflow: .github/workflows/e2e.yml\n\n3. Test harness behavior:\n - Starts mothership container (or local binary)\n - Waits for /healthz to return ok (15s timeout, 500ms poll)\n - Handles PIN auth setup if enabled\n - Runs simulator with configurable nodes/walkers/duration/rate\n - Asserts during run: health ok, nodes online, blobs detected\n - Asserts after run: detection events, frame rate\n - Runs in under 90s total\n\n4. CI integration via Argo Workflows spaxel-e2e template","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred","failure-count:19"]} @@ -115,10 +122,10 @@ {"id":"spaxel-pgu","title":"Implement detection feedback loop","description":"Build the detection feedback system that enables user-driven improvement.\n\nDeliverables:\n- Thumbs up/down UI for detection events\n- Missed-detection marking capability\n- Accuracy trend tracking and visualization\n\nAcceptance: Users can provide feedback on detections; system tracks accuracy metrics over time.","status":"closed","priority":2,"issue_type":"task","assignee":"sp1","created_at":"2026-03-29T19:25:03.930370782Z","created_by":"coding","updated_at":"2026-03-29T22:11:29.477805625Z","closed_at":"2026-03-29T22:11:29.477539090Z","close_reason":"Detection feedback loop fully implemented. Thumbs up/down UI, missed-detection marking, and accuracy trend tracking all complete.","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred","mitosis-child","mitosis-depth:1","parent-spaxel-i28"]} {"id":"spaxel-pnd","title":"Add Mothership REST API endpoint for identify","description":"Implement POST /api/nodes/{mac}/identify endpoint with body {duration_ms: 5000}. Forward as downstream WebSocket message to the target node. Return 404 if node not connected; 200 on success.\n\n**Acceptance:**\n- REST endpoint returns 404 for disconnected nodes\n- REST endpoint returns 200 on success and forwards identify message to node","status":"closed","priority":2,"issue_type":"task","assignee":"golf","created_at":"2026-04-09T10:58:29.743814123Z","created_by":"coding","updated_at":"2026-04-09T11:15:59.159650646Z","closed_at":"2026-04-09T11:15:59.159513170Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["failure-count:1","mitosis-child","mitosis-depth:1","parent-spaxel-lve"]} {"id":"spaxel-pv5","title":"Backup: SQLite Online Backup API streaming endpoint","description":"## Overview\nImplement GET /api/backup using SQLite's Online Backup API for consistent hot backups without downtime or temp files.\n\n## Implementation (mothership/internal/ — new backup.go)\n\n### Why Online Backup API:\n- Simple file copy misses in-flight WAL pages and produces inconsistent backups\n- sqlite3_backup_* copies page-by-page; readers/writers continue uninterrupted\n- No temp file needed: stream directly to HTTP response\n\n### Go implementation using go-sqlite3 (CGO) or modernc.org/sqlite:\nfunc StreamBackup(w http.ResponseWriter, src *sql.DB):\n 1. Open in-memory destination DB: sqlite3_open(':memory:', &pDest)\n 2. Init backup: pBackup = sqlite3_backup_init(pDest, 'main', pSrc, 'main')\n 3. Loop: sqlite3_backup_step(pBackup, 100) until SQLITE_DONE\n 4. sqlite3_backup_finish(pBackup)\n 5. Read all bytes from pDest and write to http.ResponseWriter\n\n### Response format:\n- Content-Type: application/zip\n- Content-Disposition: attachment; filename='spaxel-backup-.zip'\n- Zip contents:\n - spaxel.db (from backup)\n - floor_plan/ directory (if exists)\n - VERSION file\n\n### Endpoint:\nGET /api/backup — requires session auth; streams zip directly; no temp files written\n\n## Acceptance\n- Backup completes while mothership is actively processing CSI frames\n- Downloaded .db file opens cleanly in sqlite3 CLI: PRAGMA integrity_check returns 'ok'\n- Backup size reasonable (not 0 bytes, not gigabytes for fresh install)\n- Simultaneous write during backup does not produce corrupt backup (verify with PRAGMA integrity_check)","status":"closed","priority":2,"issue_type":"task","assignee":"bravo","created_at":"2026-04-06T13:10:29.966455717Z","created_by":"coding","updated_at":"2026-04-07T10:17:12.858443123Z","closed_at":"2026-04-07T10:17:12.858299524Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred","failure-count:10"]} -{"id":"spaxel-pvz","title":"Time-travel debugging and CSI replay","description":"## Background\n\nThe CSI recording buffer (Phase 2, spaxel-tqj) stores 48 hours of raw CSI frames on disk. Time-travel debugging lets you pause the live 3D view, scrub a timeline to any point in that 48-hour window, and replay the 3D scene exactly as it was at that moment. This is the most powerful debugging tool in spaxel: if a false alert fired at 3am, you can replay those 10 minutes and see exactly which links fired, what the blob positions were, and why the alert triggered. Parameter tuning without hardware becomes possible: change the motion threshold slider and immediately see how different the replay result would have been.\n\n## ReplayEngine\n\nNew package: mothership/internal/replay/engine.go\n\nReplayEngine manages the replay lifecycle:\n- state: LIVE, PAUSED, REPLAYING, SEEKING\n- replay_position: current replay timestamp\n- replay_speed: float64 (1.0 = real-time, 5.0 = 5x speed, 0.0 = paused)\n- linked_session_id: the WebSocket session ID of the client requesting replay (each dashboard session has its own replay state)\n\nReplayEngine.Seek(t time.Time): reads the recording buffer to the specified timestamp. Uses the segment file structure from spaxel-tqj: finds the correct segment file for time t, scans forward to the exact frame at t. Target: seek time < 1 second.\n\nReplayEngine.Play(speed float64): starts reading frames from the buffer at the specified speed and feeding them through the signal processing pipeline.\n\n## Replay Processing Pipeline\n\nThe replay pipeline is a copy of the live processing pipeline but with all outputs redirected to \"replay\" namespaced WebSocket messages:\n- \"replay_blob_update\" instead of \"blob_update\"\n- \"replay_track_update\" instead of \"track_update\"\n- \"replay_link_health\" instead of \"link_health\"\n\nThe replay pipeline uses a separate instance of:\n- SignalProcessor (with possibly modified parameters from the tuning sliders)\n- FusionEngine\n- TrackManager\n\nThese are cloned from the live instances at replay start so they inherit the current configuration, then modified by slider values.\n\nThe replay pipeline is self-contained: it does not affect the live pipeline in any way. Live detection continues while replay is active.\n\n## Parameter Tuning During Replay\n\nWhile in replay mode, the dashboard shows a \"Tuning\" panel with sliders for key signal processing parameters:\n- Motion threshold: deltaRMS threshold for motion detection (default from config, range 0.001 to 0.1)\n- Baseline tau: EMA time constant in seconds (default 30s, range 5s to 300s)\n- Fresnel weight sigma: Gaussian sigma for Fresnel zone contribution (default 0.1m, range 0.01m to 0.5m)\n- Minimum confidence for detection: composite minimum confidence before blob is reported (default 0.3)\n\nChanging any slider: the replay engine discards the current replay pipeline state and re-processes from the current replay_position with the new parameters. This takes at most 1-2 seconds for a typical segment (the CSI frames are already on disk; it's fast CPU processing).\n\n\"Apply to Live\" button: copies the currently-active replay parameters to the live configuration and persists them to the mothership config file. The live pipeline picks up the new values within one processing cycle. Requires confirmation modal: \"This will change the live detection configuration. Continue?\"\n\n## Dashboard Controls\n\nEntering replay mode: clicking the \"Pause\" button (or pressing Space) on the live dashboard:\n1. Pauses the live 3D view (3D scene stops updating)\n2. Shows the timeline scrubber: a horizontal bar spanning the 48-hour recording window\n3. Event markers appear on the scrubber at the timestamps of activity timeline events (zone transitions, alerts, etc.)\n4. \"Live\" chip in the dashboard header changes to \"Replay\" chip\n\nTimeline scrubber:\n- Click to seek to any position in the 48-hour window\n- Drag for continuous scrubbing\n- Event markers: small coloured ticks on the scrubber. Clicking a marker seeks to that event and jumps the activity timeline selection to that event row.\n- The current replay position is shown as a draggable thumb with a timestamp tooltip (\"2026-03-27 03:14:22\")\n\nPlayback controls:\n- Play/Pause button (Space key shortcut)\n- Speed selector: 1x, 5x, 10x\n- Step-forward button: advances replay by 1 second\n- \"Back to Live\" button: exits replay mode and resumes live updates\n\nThe 3D scene in replay mode: shows a \"REPLAY\" watermark badge in the top-left corner (so it's clear the view is not live). All live blob and track updates are suppressed while in replay mode (only replay_ prefixed messages update the scene).\n\n## Seek Performance\n\nThe recording buffer (spaxel-tqj) uses 1-hour segment files. To seek to timestamp T:\n1. Identify the correct segment file: {linkID}-{year}-{month}-{day}-{hour}.csi\n2. Binary search within the file: CSI frames are variable-length but each has a 24-byte header with timestamp_us. Scan forward from start of file to the frame nearest T. O(n) but files are ≤ 1 hour = at most 180,000 frames at 50 Hz. At 64-byte average header read, this is < 10MB scan and typically completes in < 200ms.\n3. Buffer a few seconds of frames ahead of T for smooth playback start.\n\nFor all active links: seek all link segment files in parallel (goroutines). Total seek time < 1s.\n\n## Files to Create or Modify\n\n- mothership/internal/replay/engine.go: ReplayEngine, state machine, seek, play, parameter injection\n- mothership/internal/replay/pipeline.go: replay signal processing pipeline (cloned from live)\n- mothership/internal/recording/ (spaxel-tqj): add SeekToTimestamp(t time.Time) method\n- mothership/internal/dashboard/hub.go: replay_ namespaced WebSocket message routing\n- dashboard/js/replay.js: timeline scrubber UI, playback controls, tuning panel\n- mothership/internal/dashboard/routes.go: WebSocket commands for replay control (type: \"replay_seek\", \"replay_play\", \"replay_pause\", \"replay_set_params\")\n\n## Tests\n\n- Test seek: create a mock recording buffer with known frames at known timestamps. Seek to an arbitrary timestamp, verify the returned frame is the closest one to the target.\n- Test that replay pipeline processes frames identically to live pipeline for the same input (regression test with saved CSI data and known expected output blobs)\n- Test parameter slider: change motion_threshold via replay command, verify the replay pipeline uses the new threshold on subsequent frames\n- Test \"Apply to Live\" correctly writes parameter changes to the live config\n- Test that live pipeline output is unaffected while replay is active (isolation test)\n- Test seek performance: 1-hour segment file with 180,000 frames, seek to timestamp in the middle, complete in < 500ms\n\n## Acceptance Criteria\n\n- Seek to any point in 48-hour window completes in < 1 second for all active links\n- Replay produces identical blob positions to original live processing for the same CSI input\n- Parameter sliders re-process the current replay position in < 3 seconds\n- \"Apply to Live\" copies parameters correctly and live detection immediately uses new values\n- Timeline scrubber event markers correctly align with activity timeline events\n- \"Back to Live\" correctly resumes live detection without any stale state\n- Tests pass","status":"open","priority":3,"issue_type":"task","created_at":"2026-03-28T01:56:04.674847447Z","created_by":"coding","updated_at":"2026-03-28T03:29:14.698778779Z","source_repo":".","compaction_level":0,"original_size":0,"dependencies":[{"issue_id":"spaxel-pvz","depends_on_id":"spaxel-i28","type":"blocks","created_at":"2026-03-28T03:29:14.698749622Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-pvz","depends_on_id":"spaxel-tqj","type":"blocks","created_at":"2026-03-28T01:56:07.776160379Z","created_by":"coding","metadata":"{}","thread_id":""}]} +{"id":"spaxel-pvz","title":"Time-travel debugging and CSI replay","description":"## Background\n\nThe CSI recording buffer (Phase 2, spaxel-tqj) stores 48 hours of raw CSI frames on disk. Time-travel debugging lets you pause the live 3D view, scrub a timeline to any point in that 48-hour window, and replay the 3D scene exactly as it was at that moment. This is the most powerful debugging tool in spaxel: if a false alert fired at 3am, you can replay those 10 minutes and see exactly which links fired, what the blob positions were, and why the alert triggered. Parameter tuning without hardware becomes possible: change the motion threshold slider and immediately see how different the replay result would have been.\n\n## ReplayEngine\n\nNew package: mothership/internal/replay/engine.go\n\nReplayEngine manages the replay lifecycle:\n- state: LIVE, PAUSED, REPLAYING, SEEKING\n- replay_position: current replay timestamp\n- replay_speed: float64 (1.0 = real-time, 5.0 = 5x speed, 0.0 = paused)\n- linked_session_id: the WebSocket session ID of the client requesting replay (each dashboard session has its own replay state)\n\nReplayEngine.Seek(t time.Time): reads the recording buffer to the specified timestamp. Uses the segment file structure from spaxel-tqj: finds the correct segment file for time t, scans forward to the exact frame at t. Target: seek time < 1 second.\n\nReplayEngine.Play(speed float64): starts reading frames from the buffer at the specified speed and feeding them through the signal processing pipeline.\n\n## Replay Processing Pipeline\n\nThe replay pipeline is a copy of the live processing pipeline but with all outputs redirected to \"replay\" namespaced WebSocket messages:\n- \"replay_blob_update\" instead of \"blob_update\"\n- \"replay_track_update\" instead of \"track_update\"\n- \"replay_link_health\" instead of \"link_health\"\n\nThe replay pipeline uses a separate instance of:\n- SignalProcessor (with possibly modified parameters from the tuning sliders)\n- FusionEngine\n- TrackManager\n\nThese are cloned from the live instances at replay start so they inherit the current configuration, then modified by slider values.\n\nThe replay pipeline is self-contained: it does not affect the live pipeline in any way. Live detection continues while replay is active.\n\n## Parameter Tuning During Replay\n\nWhile in replay mode, the dashboard shows a \"Tuning\" panel with sliders for key signal processing parameters:\n- Motion threshold: deltaRMS threshold for motion detection (default from config, range 0.001 to 0.1)\n- Baseline tau: EMA time constant in seconds (default 30s, range 5s to 300s)\n- Fresnel weight sigma: Gaussian sigma for Fresnel zone contribution (default 0.1m, range 0.01m to 0.5m)\n- Minimum confidence for detection: composite minimum confidence before blob is reported (default 0.3)\n\nChanging any slider: the replay engine discards the current replay pipeline state and re-processes from the current replay_position with the new parameters. This takes at most 1-2 seconds for a typical segment (the CSI frames are already on disk; it's fast CPU processing).\n\n\"Apply to Live\" button: copies the currently-active replay parameters to the live configuration and persists them to the mothership config file. The live pipeline picks up the new values within one processing cycle. Requires confirmation modal: \"This will change the live detection configuration. Continue?\"\n\n## Dashboard Controls\n\nEntering replay mode: clicking the \"Pause\" button (or pressing Space) on the live dashboard:\n1. Pauses the live 3D view (3D scene stops updating)\n2. Shows the timeline scrubber: a horizontal bar spanning the 48-hour recording window\n3. Event markers appear on the scrubber at the timestamps of activity timeline events (zone transitions, alerts, etc.)\n4. \"Live\" chip in the dashboard header changes to \"Replay\" chip\n\nTimeline scrubber:\n- Click to seek to any position in the 48-hour window\n- Drag for continuous scrubbing\n- Event markers: small coloured ticks on the scrubber. Clicking a marker seeks to that event and jumps the activity timeline selection to that event row.\n- The current replay position is shown as a draggable thumb with a timestamp tooltip (\"2026-03-27 03:14:22\")\n\nPlayback controls:\n- Play/Pause button (Space key shortcut)\n- Speed selector: 1x, 5x, 10x\n- Step-forward button: advances replay by 1 second\n- \"Back to Live\" button: exits replay mode and resumes live updates\n\nThe 3D scene in replay mode: shows a \"REPLAY\" watermark badge in the top-left corner (so it's clear the view is not live). All live blob and track updates are suppressed while in replay mode (only replay_ prefixed messages update the scene).\n\n## Seek Performance\n\nThe recording buffer (spaxel-tqj) uses 1-hour segment files. To seek to timestamp T:\n1. Identify the correct segment file: {linkID}-{year}-{month}-{day}-{hour}.csi\n2. Binary search within the file: CSI frames are variable-length but each has a 24-byte header with timestamp_us. Scan forward from start of file to the frame nearest T. O(n) but files are ≤ 1 hour = at most 180,000 frames at 50 Hz. At 64-byte average header read, this is < 10MB scan and typically completes in < 200ms.\n3. Buffer a few seconds of frames ahead of T for smooth playback start.\n\nFor all active links: seek all link segment files in parallel (goroutines). Total seek time < 1s.\n\n## Files to Create or Modify\n\n- mothership/internal/replay/engine.go: ReplayEngine, state machine, seek, play, parameter injection\n- mothership/internal/replay/pipeline.go: replay signal processing pipeline (cloned from live)\n- mothership/internal/recording/ (spaxel-tqj): add SeekToTimestamp(t time.Time) method\n- mothership/internal/dashboard/hub.go: replay_ namespaced WebSocket message routing\n- dashboard/js/replay.js: timeline scrubber UI, playback controls, tuning panel\n- mothership/internal/dashboard/routes.go: WebSocket commands for replay control (type: \"replay_seek\", \"replay_play\", \"replay_pause\", \"replay_set_params\")\n\n## Tests\n\n- Test seek: create a mock recording buffer with known frames at known timestamps. Seek to an arbitrary timestamp, verify the returned frame is the closest one to the target.\n- Test that replay pipeline processes frames identically to live pipeline for the same input (regression test with saved CSI data and known expected output blobs)\n- Test parameter slider: change motion_threshold via replay command, verify the replay pipeline uses the new threshold on subsequent frames\n- Test \"Apply to Live\" correctly writes parameter changes to the live config\n- Test that live pipeline output is unaffected while replay is active (isolation test)\n- Test seek performance: 1-hour segment file with 180,000 frames, seek to timestamp in the middle, complete in < 500ms\n\n## Acceptance Criteria\n\n- Seek to any point in 48-hour window completes in < 1 second for all active links\n- Replay produces identical blob positions to original live processing for the same CSI input\n- Parameter sliders re-process the current replay position in < 3 seconds\n- \"Apply to Live\" copies parameters correctly and live detection immediately uses new values\n- Timeline scrubber event markers correctly align with activity timeline events\n- \"Back to Live\" correctly resumes live detection without any stale state\n- Tests pass","status":"closed","priority":3,"issue_type":"task","assignee":"golf","created_at":"2026-03-28T01:56:04.674847447Z","created_by":"coding","updated_at":"2026-04-09T23:28:05.470539345Z","closed_at":"2026-04-09T23:28:05.470414181Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred","failure-count:28"],"dependencies":[{"issue_id":"spaxel-pvz","depends_on_id":"spaxel-i28","type":"blocks","created_at":"2026-03-28T03:29:14.698749622Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-pvz","depends_on_id":"spaxel-tqj","type":"blocks","created_at":"2026-03-28T01:56:07.776160379Z","created_by":"coding","metadata":"{}","thread_id":""}]} {"id":"spaxel-pwf","title":"Self-improving localisation with BLE ground truth","description":"## Background\n\nThe Fresnel zone fusion engine (spaxel-m9a) computes localisation by weighting each link's deltaRMS contribution according to the geometric intersection of candidate voxels with the Fresnel zone ellipsoid. These weights are currently uniform and based purely on geometry. In practice, some links are better at detecting motion in specific parts of the room than others — due to reflection geometry, multipath, furniture layout, and antenna orientation. By using BLE RSSI positions as continuous ground truth (when a person's labelled phone or wearable is visible), we can refine the per-link, per-zone weights to match observed physical reality.\n\n## Self-Improving Mechanism\n\nNew package: mothership/internal/learning/weights.go\n\nWeightLearner runs as a background goroutine. It operates on ground truth samples collected during normal operation.\n\nA ground truth sample is collected when BOTH:\n1. A confident BLE triangulated position is available for a known person (confidence > 0.7 from identity matching bead spaxel-nqh)\n2. A CSI blob position is within 0.5m of the BLE position (confirming the blob corresponds to that person)\n\nSample structure: {timestamp, person_id, ble_position Vec3, blob_position Vec3, per_link_delta_rms map[linkID]float64, per_link_health map[linkID]float64}\n\nThese samples are stored in SQLite: ground_truth_samples (id, timestamp, person_id, position_xyz, per_link_deltas_json, per_link_health_json). The table is capped at 10,000 samples per person (oldest first out) to prevent unbounded growth.\n\n## Online Weight Learning\n\nAfter accumulating 100+ samples for a given spatial zone (the room is divided into zones of 0.5m x 0.5m grid cells for this purpose), run incremental linear regression:\n\nPrediction model: position_estimate = sum_i (w_i * delta_rms_i) / sum_i w_i, where w_i are the learnable per-link weights.\n\nThe objective is to minimise the mean squared error between the position estimate from the weighted fusion and the ground truth BLE positions, over all samples in the zone.\n\nUpdate rule (stochastic gradient descent, online):\nFor each new ground truth sample:\n- Compute current position estimate using current weights\n- Compute error = ground_truth_position - estimated_position\n- For each link i: w_i += learning_rate * error * delta_rms_i / |delta_rms_vector|\n- learning_rate = 0.001 (small to prevent overfitting to transient environmental changes)\n- Apply L2 regularisation: w_i *= (1 - regularisation * learning_rate) where regularisation = 0.01\n\nClip weights to [0, 5] to prevent divergence. Normalise weight vector to unit sum after each update.\n\n## Validation Gate\n\nTo prevent the learned weights from degrading accuracy (overfitting, transient environmental changes, sensor noise):\n\nHold out 20% of samples as a validation set (random selection). After each batch of 50 weight updates, compute the mean position error on the validation set using the updated weights vs. the original (geometric) weights.\n\nOnly persist the updated weights if: validation_error_new < validation_error_original * 0.95 (at least 5% improvement on the validation set).\n\nIf the validation check fails, discard the weight update and log: \"Weight update rejected: no improvement on validation set. Keeping current weights.\"\n\nThis is a conservative gate. The threshold is configurable (fleet.weight_improvement_threshold, default 0.05).\n\n## Weight Storage\n\nSQLite table: link_weights (link_id TEXT, zone_grid_x INT, zone_grid_y INT, weight REAL, sample_count INT, last_updated DATETIME, validation_improvement REAL, PRIMARY KEY (link_id, zone_grid_x, zone_grid_y)).\n\nZone grid: floor is divided into 0.5m cells. zone_grid_x = floor(x / 0.5), zone_grid_y = floor(y / 0.5). This allows position-dependent weights — a link might be excellent for localisation in one area and poor in another.\n\nOn FusionEngine update: instead of using geometric Fresnel zone weights alone, multiply by the learned spatial weight for the voxel being evaluated (bilinear interpolation between grid cells for smooth transitions).\n\nFallback: if no learned weight exists for a grid cell (insufficient samples), use the geometric weight (learned weight = 1.0). This ensures correctness during the learning period.\n\n## Accuracy Trend in Dashboard\n\nThe accuracy improvement from learning should be visible to users. In the \"Accuracy\" dashboard panel (Phase 7 feedback loop bead):\n\nAdd \"Position accuracy\" subsection:\n- Median position error (m): computed weekly from ground truth samples. median(|ble_position - blob_position|) over all weekly samples.\n- Week-over-week trend: sparkline of weekly median position error. Arrow indicating direction (improving/degrading).\n- Sample count: \"Based on N position measurements from M people this week\"\n- \"Accuracy improving\" badge when position error has decreased by > 10% vs previous week.\n\n## Files to Create or Modify\n\n- mothership/internal/learning/weights.go: WeightLearner, SGD update, validation gate\n- mothership/internal/learning/samples.go: ground truth sample collection, SQLite storage\n- mothership/internal/fusion/engine.go (spaxel-m9a): integrate learned weights in FusionEngine\n- mothership/internal/dashboard/routes.go: GET /api/accuracy/weights (debug endpoint showing current weight map)\n- dashboard/js/accuracy.js: position accuracy trend chart\n\n## Tests\n\n- Test ground truth sample collection gates correctly: confidence > 0.7 AND BLE-blob distance < 0.5m -> sample collected; confidence = 0.6 -> no sample\n- Test SGD weight update: after 100 samples with known ground truth, verify weights move in the direction that reduces error\n- Test validation gate: inject a batch of adversarial samples that would degrade accuracy, verify gate rejects the update\n- Test bilinear interpolation between adjacent grid cells produces smooth weight values\n- Test weight fallback: FusionEngine correctly uses geometric weight=1.0 when no learned weight exists for a grid cell\n- Test SQLite cap: inserting 10,001 samples removes the oldest one, maintaining the 10,000 cap\n\n## Acceptance Criteria\n\n- Position error decreases measurably over 2+ weeks of operation with BLE ground truth data (target: from initial ~1.2m to < 0.8m median error)\n- Validation gate prevents weight regressions (mock adversarial samples do not degrade fusion accuracy)\n- Weight updates persist across mothership restarts\n- Position accuracy trend visible in dashboard Accuracy panel\n- Sample collection rate visible (samples per day per person) in dashboard\n- Tests pass","status":"closed","priority":3,"issue_type":"task","assignee":"bravo","created_at":"2026-03-28T01:50:34.214065492Z","created_by":"coding","updated_at":"2026-03-30T00:12:00.715207673Z","closed_at":"2026-03-30T00:12:00.715088959Z","close_reason":"Implemented self-improving localization with BLE ground truth. Created spatial weight learner with SGD, validation gate, bilinear interpolation. Added position accuracy visualization to dashboard. All tests implemented.","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred"],"dependencies":[{"issue_id":"spaxel-pwf","depends_on_id":"spaxel-3ps","type":"blocks","created_at":"2026-03-28T01:50:36.699492024Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-pwf","depends_on_id":"spaxel-zvs","type":"blocks","created_at":"2026-03-28T03:29:14.574878149Z","created_by":"coding","metadata":"{}","thread_id":""}]} {"id":"spaxel-q99z","title":"Add Tap-to-Jump Time-Travel","description":"Implement tap-to-jump coordination with time-travel replay module. When timeline event is clicked (expert mode), emit jump_to_time command with event timestamp. The time-travel player pauses live playback, seeks CSI recording buffer to timestamp, and begins replay. Highlight selected event and show Now replaying chip in timeline header.\n\nAcceptance Criteria:\n- Clicking event emits correct timestamp to time-travel player\n- 3D scene seeks to correct timestamp\n- Selected event highlights in timeline\n- Now replaying chip appears in timeline header\n- Tests pass","status":"open","priority":2,"issue_type":"task","created_at":"2026-04-09T17:50:35.191487107Z","created_by":"coding","updated_at":"2026-04-09T17:50:35.191487107Z","source_repo":".","compaction_level":0,"original_size":0,"labels":["mitosis-child","mitosis-depth:1","parent-spaxel-s70"]} -{"id":"spaxel-q9d","title":"Add GDOP overlay","description":"Implement GDOP (Geometric Dilution of Precision) overlay for the simulator.\n\nAcceptance:\n- GDOP overlay visualizes accuracy metrics across the virtual space\n- Simulator produces realistic synthetic data matching real-world conditions","status":"in_progress","priority":2,"issue_type":"task","assignee":"hotel","created_at":"2026-04-09T16:11:25.552156606Z","created_by":"coding","updated_at":"2026-04-09T17:32:58.464028526Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["failure-count:2","mitosis-child","mitosis-depth:1","parent-spaxel-d41"]} +{"id":"spaxel-q9d","title":"Add GDOP overlay","description":"Implement GDOP (Geometric Dilution of Precision) overlay for the simulator.\n\nAcceptance:\n- GDOP overlay visualizes accuracy metrics across the virtual space\n- Simulator produces realistic synthetic data matching real-world conditions","status":"closed","priority":2,"issue_type":"task","assignee":"golf","created_at":"2026-04-09T16:11:25.552156606Z","created_by":"coding","updated_at":"2026-04-10T00:30:03.856931576Z","closed_at":"2026-04-10T00:30:03.856827566Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["failure-count:14","mitosis-child","mitosis-depth:1","parent-spaxel-d41"]} {"id":"spaxel-qfp","title":"Sleep quality monitoring","description":"## Background\n\nThe breathing analysis feature (Phase 5, spaxel-r37) detects the micro-motion of breathing in stationary people. Run continuously in bedroom zones overnight, it can compute sleep quality metrics without any wearable device. Chest displacement during breathing at 15 breaths/minute produces a detectable 0.25 Hz signal in CSI. By tracking this overnight, combined with motion events (wake episodes) and the timing of presence in the bedroom zone, we can produce a sleep summary that rivals basic commercial sleep trackers — without the user wearing anything.\n\n## Sleep Session Detection\n\nSleepMonitor in mothership/internal/sleep/monitor.go.\n\nSession onset detection (all conditions must hold):\n1. Person is in a bedroom zone (zone with is_bedroom flag = true, set in zone editor)\n2. Stationary detection fires (STATIONARY_DETECTED state from breathing analysis bead)\n3. BLE device shows reduced activity (optional enhancement: phone advertising rate drops when screen is off; this is a bonus signal, not required)\nTentative onset: all conditions met. Confirmed onset: conditions hold for 15 consecutive minutes.\n\nSession end detection:\n1. Person leaves bedroom zone (zone transition event fires)\n2. OR: motion detection fires for > 2 minutes (sustained motion = getting up)\n3. OR: stationary detection drops and does not return for > 30 minutes (person left room without portal crossing — reconciliation path)\n\nSession record stored in SQLite:\nCREATE TABLE sleep_sessions (\n id TEXT PRIMARY KEY,\n person_id TEXT NOT NULL,\n zone_id TEXT NOT NULL, -- bedroom zone\n session_date DATE NOT NULL, -- the date this sleep night belongs to (typically today-1 for morning reports)\n sleep_onset DATETIME, -- time tentative detection was confirmed\n wake_time DATETIME,\n time_in_bed_minutes REAL,\n sleep_latency_minutes REAL, -- time from entering bedroom to sleep onset\n wake_episode_count INTEGER DEFAULT 0,\n wake_after_sleep_onset_minutes REAL, -- total time awake after first sleep onset\n breathing_rate_mean REAL,\n breathing_rate_stddev REAL,\n breathing_anomaly_count INTEGER DEFAULT 0, -- breathing < 8 or > 25 per minute\n sleep_efficiency REAL -- (time_in_bed - waso) / time_in_bed * 100\n);\n\nCREATE TABLE sleep_wake_episodes (\n id TEXT PRIMARY KEY,\n session_id TEXT,\n episode_start DATETIME,\n episode_end DATETIME,\n duration_seconds REAL\n);\n\n## Sleep Metrics Computation\n\nDuring the sleep session, SleepMonitor subscribes to:\n- Breathing data: periodic sample of breathing_freq_hz from BreathingDetector (spaxel-r37). Store in a rolling buffer.\n- Motion events: MOTION_DETECTED state transitions from LinkProcessor. Each motion event during a confirmed sleep session is a potential wake episode.\n\nWake episode classification:\n- If deltaRMS > threshold for > 3 seconds: wake episode starts\n- If deltaRMS returns below threshold and breathing signal resumes: wake episode ends\n- Store episode start/end in sleep_wake_episodes\n\nBreathing analysis during sleep:\n- Mean breathing rate (bpm): mean(breathing_freq_hz * 60) over all samples in session\n- Breathing rate standard deviation: indicates sleep stage variability (higher variance may indicate REM activity)\n- Breathing anomaly: if breathing_freq_hz * 60 < 8 or > 25 for > 3 consecutive minutes: log anomaly. This is a proxy for potential sleep apnoea or hyperventilation.\n\nSleep efficiency: (time_in_bed_minutes - wake_after_sleep_onset_minutes) / time_in_bed_minutes * 100. A value above 85% is considered good sleep efficiency.\n\n## Morning Summary Card\n\nOn first WebSocket connection from the dashboard after 6am AND after a sleep session has ended (wake_time is set):\n- Mothership pushes a \"morning_summary\" WebSocket message with the completed session data\n- Dashboard renders a dismissible card in simple mode (full width at top) and as a floating panel in expert mode\n\nCard content:\n- \"Last night: [sleep_duration] h [mm] min\"\n- Colored efficiency indicator: green (>85%), amber (70-85%), red (<70%)\n- Wake episodes: \"2 wake episodes, [total waso] min awake after sleep onset\"\n- Breathing: \"Average breathing: [N] breaths/min\"\n- Anomaly note (if applicable): \"Unusual breathing detected at [time]. [View details]\"\n- \"View full sleep report\" link (opens detailed timeline view in expert mode)\n\n## Weekly Trends\n\nDashboard \"Sleep\" panel:\n- 7-day sparkline of sleep duration per night\n- 7-day sparkline of sleep efficiency per night\n- Average breathing rate over the week\n- Week-over-week comparison: \"This week you slept 6h 48m on average (vs. 7h 12m last week)\"\n\n## Per-Person Tracking\n\nSleep monitoring is person-specific and requires BLE identity (so the system knows whose bedroom this is). Multiple people sharing a bedroom: each person has their own sleep session if their BLE devices can be distinguished. If both people are in bed simultaneously, the breathing detector may pick up a blend of two breathing rates — acknowledge this limitation in documentation.\n\nFor anonymous tracks (no BLE identity): detect in-bedroom stationary presence only (no per-person sleep report). Log \"Unidentified person in bedroom zone\" for 8+ hour periods.\n\n## Zone Configuration\n\nThe zone editor (portals bead, spaxel-qlh) is extended with a zone type selector:\n- Normal zone (default)\n- Bedroom (enables sleep monitoring)\n- Kitchen (no special behavior)\n- Children's zone (suppresses fall detection)\n\nThis is stored as zone_type in the zones table.\n\n## Files to Create or Modify\n\n- mothership/internal/sleep/monitor.go: SleepMonitor, session detection, metric computation\n- mothership/internal/sleep/report.go: morning summary generation, weekly trend aggregation\n- mothership/internal/signal/breathing.go (spaxel-r37): add tick-based sample reporting for sleep monitor\n- dashboard/js/sleep.js: morning summary card, Sleep panel\n- mothership/internal/events/events.go: SleepSessionStartEvent, SleepSessionEndEvent\n\n## Tests\n\n- Test sleep session onset: stationary detection fires, person in bedroom, 15 minutes -> session confirmed\n- Test that stationary detection < 15 minutes does not create a session (avoids brief naps misclassified)\n- Test wake episode counting: 3 MOTION_DETECTED events > 3s each during a session -> wake_episode_count = 3\n- Test wake after sleep onset calculation: 3 episodes of 5 minutes each -> waso = 15 minutes\n- Test sleep efficiency calculation: 480 minutes in bed, 45 minutes waso -> efficiency = 90.6%\n- Test breathing anomaly detection: inject 4 minutes of breathing_freq_hz = 0.1 (6 bpm) -> anomaly logged\n- Test morning summary trigger fires only on first connection after 6am AND after session end\n\n## Acceptance Criteria\n\n- Sleep session detected within 15 minutes of confirmed onset (stationary in bedroom zone)\n- Wake episodes counted correctly (tested with synthetic motion event injection)\n- Morning summary card appears on first dashboard open after wake time (6am by default, configurable)\n- Weekly trends sparkline shows 7 nights of data after 7 days\n- Sleep session data persists in SQLite across mothership restarts\n- Breathing anomaly flag fires correctly for rate < 8 or > 25 bpm\n- Tests pass","status":"in_progress","priority":3,"issue_type":"task","assignee":"hotel","created_at":"2026-03-28T01:52:06.457208929Z","created_by":"coding","updated_at":"2026-04-09T17:45:50.699344621Z","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred","failure-count:81"]} {"id":"spaxel-qgj","title":"Implement NTP client in ESP32 firmware","description":"Add NTP synchronization to firmware/main/wifi.c or ntp.c:\n- Call esp_sntp_setservername(0, ntp_server) before esp_sntp_init() on boot\n- ntp_server read from NVS 'ntp_server' key (default: 'pool.ntp.org')\n- Attempt sync for up to 10 seconds after WiFi connect; log WARN if sync fails\n- On sync failure: proceed without stagger (rely on CSMA/CA)\n- Resync every 10 minutes via esp_timer periodic callback\n- Include ntp_synced status in health JSON message\n\nAcceptance: Node health messages show ntp_synced: true when pool is reachable; ntp_synced: false when NTP blocked — node still operates normally; resync occurs every ~600s (verified via UART logs)","status":"closed","priority":2,"issue_type":"task","assignee":"alpha","created_at":"2026-04-07T14:37:00.302557793Z","created_by":"coding","updated_at":"2026-04-07T17:32:57.896842167Z","closed_at":"2026-04-07T17:32:57.896693758Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["failure-count:1","mitosis-child","mitosis-depth:1","parent-spaxel-u7y"]} {"id":"spaxel-qlh","title":"Room transition portals and zone occupancy","description":"## Background\n\nKnowing a blob is at coordinates (3.2m, 1.8m, 1.0m) is useful to the algorithm, but \"Alice is in the Kitchen\" is useful to a person. Room transition portals define doorway planes between named zones. When a track's trajectory intersects a portal plane, the zone occupancy counts update and a transition event fires. This is the foundation for natural language presence display (\"Alice is in the Kitchen\"), automation triggers (\"when Alice enters the bedroom\"), and the activity timeline (\"Alice moved from Living Room to Kitchen at 14:23\").\n\n## Zone Definitions\n\nZones are named 3D volumes represented as axis-aligned bounding boxes (AABB) for simplicity. Each zone has: id (uuid), name (\"Kitchen\"), bounds_min (Vec3), bounds_max (Vec3), color (hex string for 3D overlay), created_at.\n\nSQLite schema:\nCREATE TABLE zones (\n id TEXT PRIMARY KEY,\n name TEXT NOT NULL,\n bounds_min_x REAL, bounds_min_y REAL, bounds_min_z REAL,\n bounds_max_x REAL, bounds_max_y REAL, bounds_max_z REAL,\n color TEXT DEFAULT '#3b82f6',\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP\n);\n\nContainment test: a position P is in zone Z if bounds_min_x <= P.x <= bounds_max_x AND bounds_min_y <= P.y <= bounds_max_y. The Z bounds are typically 0 to ceiling height (usually 2.5m) since we track floor-plane position.\n\n## Portal Definitions\n\nA portal is a vertical plane segment spanning a doorway. It divides two zones and detects crossings.\n\nPortal schema:\nCREATE TABLE portals (\n id TEXT PRIMARY KEY,\n name TEXT, -- e.g. \"Kitchen Door\"\n zone_a_id TEXT, -- zone on one side\n zone_b_id TEXT, -- zone on other side\n plane_point Vec3, -- a point on the portal plane (e.g. centre of doorway)\n plane_normal Vec3, -- unit normal vector of the portal plane\n width REAL, -- width of the doorway in metres\n height REAL, -- height of the doorway (default: 2.1m)\n created_at DATETIME\n);\n\nA portal normal points from zone_a toward zone_b. A crossing from zone_a to zone_b has dot(velocity, normal) > 0. A crossing from zone_b to zone_a has dot(velocity, normal) < 0.\n\n## Portal Editor (3D Dashboard)\n\nExtend the node placement UI (spaxel-qq6) with portal editing:\n1. User clicks \"Add Portal\" button\n2. A vertical plane appears in the 3D scene at the camera's focal point\n3. User drags the plane using TransformControls (from Three.js addons) to position it across a doorway\n4. User adjusts width and assigns zone names on each side (dropdown of existing zones or \"Create new zone\")\n5. User clicks \"Save\" — portal is stored in SQLite and rendered as a semi-transparent divider plane in the 3D scene\n\nPortal rendering: thin coloured plane (opacity 0.3, colour #a855f7 purple) with a label at the top edge showing the portal name. When a track crosses the portal, the plane briefly flashes brighter (animated opacity increase then decay back to 0.3).\n\nZone rendering: semi-transparent coloured cuboid volumes (opacity 0.1, colour from zone.color). Zone name displayed as a floating text label at the zone centroid (using THREE.Sprite). A \"Zones\" layer toggle in the 3D view hides/shows all zones simultaneously.\n\n## Crossing Detection\n\nCrossingDetector runs as part of the TrackManager update loop (10 Hz). For each track update:\n\n1. For each active portal, test if the track crossed the portal plane in the last update step:\n - Previous position P_prev, current position P_curr\n - Check if the line segment P_prev -> P_curr intersects the portal plane within the portal's rectangular bounds (width x height centered on plane_point)\n - Intersection test: t = dot(plane_point - P_prev, normal) / dot(P_curr - P_prev, normal). If 0 <= t <= 1, compute intersection point P_int = P_prev + t*(P_curr - P_prev), then check if P_int is within the doorway rectangle.\n - Crossing direction: if dot(P_curr - P_prev, normal) > 0, direction is A_to_B; otherwise B_to_A.\n\n2. On crossing detected: update occupancy counts, emit ZoneCrossingEvent.\n\nZoneCrossingEvent: {portal_id, track_id, person_id, person_label, from_zone_id, from_zone_name, to_zone_id, to_zone_name, direction, timestamp}.\n\nThis event is:\n- Published to the internal event bus\n- Broadcast via WebSocket to dashboard as type \"zone_transition\"\n- Appended to activity timeline (Phase 8)\n- Processed by automation engine (Phase 6)\n\n## Occupancy Counter\n\nOccupancyManager maintains a per-zone current occupant list (map[zoneID][]TrackID).\n\nUpdates from two sources:\n1. CrossingDetector portal events: when a track crosses from zone A to B, move its entry in the occupancy map from A to B.\n2. Direct containment check: run every 30 seconds as a reconciliation pass. For each active track, check if it is within any zone's bounding box. If the track is in zone C but the occupancy map says it is in zone A (e.g. track was created inside a zone without crossing a portal), update accordingly.\nThe containment check prevents \"teleportation\" inconsistencies when tracks are created or resume from coasting state.\n\n## WebSocket Broadcast\n\nOn each zone occupancy change, the mothership broadcasts:\n{\"type\":\"zone_occupancy\",\"zones\":[{\"id\":\"zone-kitchen\",\"name\":\"Kitchen\",\"occupants\":[{\"track_id\":\"track-1\",\"person_id\":\"uuid-alice\",\"person_label\":\"Alice\"}]},{\"id\":\"zone-living\",\"name\":\"Living Room\",\"occupants\":[]}]}\n\nAnd specifically on crossings:\n{\"type\":\"zone_transition\",\"portal_id\":\"...\",\"person_label\":\"Alice\",\"from_zone\":\"Kitchen\",\"to_zone\":\"Living Room\",\"timestamp\":\"2026-03-27T14:23:00Z\"}\n\n## REST API\n\nGET /api/zones: list all zones with current occupancy\nPOST /api/zones: create zone\nPUT /api/zones/{id}: update zone bounds/name/color\nDELETE /api/zones/{id}: delete zone (removes from all occupancy tracking)\n\nGET /api/portals: list all portals\nPOST /api/portals: create portal\nPUT /api/portals/{id}: update portal\nDELETE /api/portals/{id}: delete portal\n\nGET /api/zones/{id}/history?since=2026-03-27T00:00:00Z: get crossing history for zone (list of ZoneCrossingEvent)\n\n## Tests\n\n- Test portal crossing detection with a track path that passes through the portal plane: verify crossing event fires with correct direction\n- Test that a track path that runs parallel to a portal plane but within 0.1m does not fire a false crossing\n- Test that a track path outside the portal's width bounds does not fire a crossing\n- Test occupancy count updates: zone Kitchen starts with 1 occupant, track crosses portal to Living Room, Kitchen count = 0, Living Room count = 1\n- Test the 30-second reconciliation pass: track that appears inside a zone without crossing a portal is correctly assigned to that zone\n- Test zone containment with a position exactly on the bounds_min edge (inclusive boundary)\n- Test that zone_transition WebSocket message is broadcast with correct from_zone and to_zone names\n\n## Acceptance Criteria\n\n- Portal editor allows placing vertical plane portals across doorways in the 3D scene\n- Zone bounding boxes are editable and render as semi-transparent volumes in 3D view\n- Zone labels update in real-time as people move between zones (\"Kitchen: Alice, Bob\")\n- Zone transition events fire within one track update cycle (100ms) of the crossing occurring\n- Reconciliation pass correctly handles tracks that appear inside zones without portal crossings\n- Zone and portal data persists across mothership restarts via SQLite\n- WebSocket broadcasts zone_occupancy after every occupancy change\n- Tests pass","status":"open","priority":3,"issue_type":"task","created_at":"2026-03-28T01:45:41.668543362Z","created_by":"coding","updated_at":"2026-03-28T03:29:14.268105795Z","source_repo":".","compaction_level":0,"original_size":0,"dependencies":[{"issue_id":"spaxel-qlh","depends_on_id":"spaxel-c0q","type":"blocks","created_at":"2026-03-28T03:29:14.268078719Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-qlh","depends_on_id":"spaxel-nqh","type":"blocks","created_at":"2026-03-28T01:45:44.642770328Z","created_by":"coding","metadata":"{}","thread_id":""}]} @@ -134,13 +141,14 @@ {"id":"spaxel-sbi","title":"Ambient confidence score and link health","description":"## Background\n\nNot all sensing links are equal. A link where a wall bisects the Fresnel zone produces consistently noisy detections. A link experiencing WiFi congestion from neighbour networks drops packets and has unreliable amplitude measurements. A link near a microwave oven sees periodic interference bursts. Without a quality metric, the fusion engine treats all links equally, and poor-quality links introduce noise that degrades overall localisation accuracy.\n\nThe ambient confidence score is a per-link quality metric that: (1) gates and weights detection algorithms so poor links contribute less, (2) surfaces actionable quality information to the user, and (3) powers the link weather diagnostics feature. A composite system-wide Detection Quality gauge summarises overall system health.\n\n## Per-Link Health Metrics\n\nNew module: mothership/internal/health/linkhealth.go\n\nLinkHealthScorer computes five sub-metrics per link, each in [0, 1]:\n\n1. SNR Estimate (weight 40%)\n Ratio of motion-period delta to quiet-period delta, expressed as a quality score.\n During known-quiet periods (determined by extended absence of motion, minimum 60s), record the ambient deltaRMS variance (sigma_quiet). During motion-active periods, record deltaRMS peaks (signal level). SNR_ratio = signal_level / sigma_quiet. Map to [0,1] via: score = min(1.0, log10(SNR_ratio) / log10(100)) where SNR=100:1 -> score=1.0, SNR=10:1 -> score=0.5.\n\n2. Phase Stability (weight 30%)\n During known-quiet periods, compute the variance of the phase offset across subcarriers. Low variance indicates stable hardware clock synchronisation between TX and RX, which is a prerequisite for reliable phase-based detection. High variance (>0.5 radians) suggests temperature drift or near-field metal interference.\n score = max(0, 1 - phase_variance / 0.5)\n\n3. Packet Rate Health (weight 20%)\n actual_pps / configured_rate. If configured at 50 Hz and receiving 40 Hz: score = 0.8.\n Rolling average over 10-second window.\n\n4. Baseline Drift (weight 10%)\n Rate of change of the EMA baseline over a 1-hour sliding window. High drift indicates an unstable environment (e.g. gradual temperature change, something blocking or unblocking the Fresnel zone). Computed as: drift_rate = |B_t - B_{t-1h}| / |B_{t-1h}| (normalised L2 change per hour).\n score = max(0, 1 - drift_rate / 0.1) where 10% per hour -> score=0.0.\n\n5. Composite Score\n composite = 0.4 * snr + 0.3 * phase_stability + 0.2 * packet_rate + 0.1 * (1 - baseline_drift_normalized)\n Clamped to [0, 1]. Updated every 10 seconds.\n\n## Dashboard Visualisation\n\nPer-link health is surfaced in multiple places:\n\nIn the 3D view (Phase 3 node placement UI, spaxel-qq6):\n- Link line thickness: 2px (health > 0.7), 1px (health 0.4-0.7), 0.5px (health < 0.4)\n- Link line colour: green (#22c55e at health=1.0) through yellow (#eab308 at health=0.5) through red (#ef4444 at health=0)\n\nIn the Link Health panel (sidebar, shown on link click):\n- Per-metric breakdown: four sub-score gauges (SNR, Phase Stability, Packet Rate, Baseline Drift) with label, value, and interpretation\n- Sparkline chart: composite health score over last 24 hours\n- \"Why is this low?\" contextual hint based on which sub-metric is lowest\n\nSystem-wide Detection Quality gauge (dashboard header):\n- Single number: weighted average of all active link composite scores\n- Rendered as a circular gauge (0-100%) with colour gradient\n- Tooltip: \"Based on N active links. Weakest link: [link name] at [score%]\"\n\n## API\n\nGET /api/links returns:\n[{\n \"link_id\": \"aabbccddee:ff:00:11:22:33\",\n \"tx_mac\": \"aa:bb:cc:dd:ee:ff\",\n \"rx_mac\": \"00:11:22:33:44:55\",\n \"health_score\": 0.83,\n \"health_details\": {\n \"snr\": 0.91,\n \"phase_stability\": 0.78,\n \"packet_rate\": 0.97,\n \"baseline_drift\": 0.62\n },\n \"last_updated\": \"2026-03-27T14:23:45Z\"\n}]\n\n## Gating Effects\n\nThe health score gates and weights two downstream systems:\n1. BreathingDetector (stationary person detection, spaxel-r37): disabled when composite health_score < 0.7\n2. FusionEngine (spaxel-m9a): each link's contribution to the 3D occupancy grid is multiplied by its health_score. A link with score=0.3 contributes only 30% as much as a link with score=1.0. This prevents degraded links from producing noisy phantom blobs.\n\nThe gating thresholds (0.7 for breathing, any value for weighted fusion) are configurable via mothership config.\n\n## Integration with Existing Code\n\nLinkHealthScorer is instantiated in mothership/internal/ingestion/server.go alongside the existing signal processors. It receives:\n- Packet arrival timestamps (to compute actual PPS vs configured)\n- deltaRMS values from the signal processor (for SNR computation)\n- Phase values from the signal processor (for phase stability)\n- Baseline vectors from BaselineManager (for drift computation)\n\nThe health scores are updated in background via a goroutine that fires every 10 seconds. Results are published on the internal event bus as LinkHealthUpdate events, which the dashboard hub broadcasts as \"link_health\" WebSocket messages.\n\n## Tests\n\n- Test composite score computation with mock inputs: all 1.0 -> 1.0, packet_rate=0.5 others 1.0 -> weighted result\n- Test SNR sub-score mapping: SNR_ratio=1 -> score=0, SNR_ratio=10 -> score=0.5, SNR_ratio=100 -> score=1.0\n- Test phase stability: variance=0 -> score=1.0, variance=0.5 -> score=0.0, variance=0.25 -> score=0.5\n- Test that breathing detection gating fires correctly when score drops below 0.7\n- Test FusionEngine link weight reflects health score (inspect internal state after injection)\n- Test API response format matches documented schema\n- Test that health score updates are published to the event bus\n\n## Acceptance Criteria\n\n- Per-link health scores computed and visible in dashboard for all active links\n- 3D link line thickness and colour reflect health score in real-time\n- Detection Quality gauge shows system-wide average health, updates every 10 seconds\n- BreathingDetector correctly gated off when link health < 0.7\n- FusionEngine link weights reflect health scores (verified via test)\n- Per-metric breakdown visible in Link Health panel on link click\n- Tests pass","status":"closed","priority":3,"issue_type":"task","assignee":"delta","created_at":"2026-03-28T01:41:30.452621121Z","created_by":"coding","updated_at":"2026-03-29T18:07:39.806481028Z","closed_at":"2026-03-29T18:07:39.806256783Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred"],"dependencies":[{"issue_id":"spaxel-sbi","depends_on_id":"spaxel-axa","type":"blocks","created_at":"2026-03-28T03:29:13.992381357Z","created_by":"coding","metadata":"{}","thread_id":""}]} {"id":"spaxel-sdu9","title":"Build Dashboard Timeline Panel","description":"Create sidebar panel showing events in reverse-chronological order. Implement event-specific visual rendering with icons and descriptions per event type. Add thumbs-up/down buttons on each event delegating to feedback module. Use virtualized rendering with IntersectionObserver for 1000+ events.\n\nAcceptance Criteria:\n- All event types render with correct icons and descriptions\n- Event descriptions use plain English templates\n- Feedback buttons appear on each event and invoke feedback module correctly\n- Timeline handles 10,000+ events without UI slowdown via virtualized rendering\n- Tests pass","status":"open","priority":2,"issue_type":"task","created_at":"2026-04-09T17:50:35.030370233Z","created_by":"coding","updated_at":"2026-04-09T17:50:35.030370233Z","source_repo":".","compaction_level":0,"original_size":0,"labels":["mitosis-child","mitosis-depth:1","parent-spaxel-s70"]} {"id":"spaxel-she","title":"fix: mqtt/client.go API mismatches for paho v1.5.0","description":"## Problem\n`internal/mqtt/client.go` uses methods that don't exist in paho.mqtt.golang v1.5.0 (the version in go.mod):\n\n1. **Line 120**: `opts.SetCleanOnConnect(true)` — method doesn't exist. In paho v1.5.0 the method is `opts.SetCleanSession(true)`\n2. **Line 147**: `opts.OnDisconnect = func(...)` — field doesn't exist. In paho v1.5.0 the callback is set via `opts.SetConnectionLostHandler(func(...))`\n3. **Lines 402, 404**: Redundant type assertions inside a type switch:\n - `case string: data = []byte(v.(string))` — `v` is already typed as `string` in this case branch; change to `data = []byte(v)`\n - `case []byte: data = v.([]byte)` — `v` is already `[]byte`; change to `data = v`\n\n## Fixes\n1. Line 120: `opts.SetCleanOnConnect(true)` → `opts.SetCleanSession(true)`\n2. Lines 147-160 (OnDisconnect assignment block): Replace with `opts.SetConnectionLostHandler(func(client mqtt.Client, err error) { ... })`\n3. Lines 402, 404: Remove the redundant type assertions\n\n## Verify\n```bash\ncd /home/coding/spaxel/mothership && PATH=$PATH:/home/coding/go/bin go build ./internal/mqtt/\n```","status":"closed","priority":1,"issue_type":"task","assignee":"delta","created_at":"2026-04-06T22:30:21.813369312Z","created_by":"coding","updated_at":"2026-04-06T22:47:51.175731416Z","closed_at":"2026-04-06T22:47:51.175482589Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["failure-count:1"]} -{"id":"spaxel-sl2","title":"Phase 8: Analysis & Developer Tools","description":"Goal: Deep debugging, system tuning, detection explainability.\n\nDeliverables:\n- Activity timeline (universal event stream, tap-to-jump, inline feedback)\n- Detection explainability (X-ray overlay, contributing links, confidence breakdown)\n- Time-travel debugging (pause live, scrub timeline, replay 3D from recorded CSI)\n- Pre-deployment simulator (virtual space + nodes + synthetic walkers, GDOP overlay)\n- CSI simulator Go CLI (virtual nodes, synthetic CSI binary frames, for dev/testing)\n- Fresnel zone debug overlay (wireframe ellipsoids between active links)\n\nExit criteria: Time-travel replays 24h of data. Simulator produces realistic synthetic data.","status":"open","priority":3,"issue_type":"phase","created_at":"2026-03-27T01:55:47.111916358Z","created_by":"coding","updated_at":"2026-04-09T14:54:38.947171222Z","source_repo":".","compaction_level":0,"original_size":0,"labels":["failure-count:1"],"dependencies":[{"issue_id":"spaxel-sl2","depends_on_id":"spaxel-3ca","type":"blocks","created_at":"2026-04-09T14:54:38.771420677Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-sl2","depends_on_id":"spaxel-5a3","type":"blocks","created_at":"2026-04-09T14:54:38.947095956Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-sl2","depends_on_id":"spaxel-70i","type":"blocks","created_at":"2026-04-09T14:54:38.897281189Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-sl2","depends_on_id":"spaxel-8ke","type":"blocks","created_at":"2026-04-09T14:54:38.637243667Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-sl2","depends_on_id":"spaxel-d41","type":"blocks","created_at":"2026-04-09T14:54:38.841330220Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-sl2","depends_on_id":"spaxel-i28","type":"blocks","created_at":"2026-03-28T01:33:51.145107801Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-sl2","depends_on_id":"spaxel-nhl","type":"blocks","created_at":"2026-04-09T14:54:38.714247271Z","created_by":"coding","metadata":"{}","thread_id":""}]} +{"id":"spaxel-sl2","title":"Phase 8: Analysis & Developer Tools","description":"Goal: Deep debugging, system tuning, detection explainability.\n\nDeliverables:\n- Activity timeline (universal event stream, tap-to-jump, inline feedback)\n- Detection explainability (X-ray overlay, contributing links, confidence breakdown)\n- Time-travel debugging (pause live, scrub timeline, replay 3D from recorded CSI)\n- Pre-deployment simulator (virtual space + nodes + synthetic walkers, GDOP overlay)\n- CSI simulator Go CLI (virtual nodes, synthetic CSI binary frames, for dev/testing)\n- Fresnel zone debug overlay (wireframe ellipsoids between active links)\n\nExit criteria: Time-travel replays 24h of data. Simulator produces realistic synthetic data.","status":"closed","priority":3,"issue_type":"phase","assignee":"golf","created_at":"2026-03-27T01:55:47.111916358Z","created_by":"coding","updated_at":"2026-04-10T01:37:01.689881858Z","closed_at":"2026-04-10T01:37:01.689692542Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["failure-count:1"],"dependencies":[{"issue_id":"spaxel-sl2","depends_on_id":"spaxel-3ca","type":"blocks","created_at":"2026-04-09T14:54:38.771420677Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-sl2","depends_on_id":"spaxel-5a3","type":"blocks","created_at":"2026-04-09T14:54:38.947095956Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-sl2","depends_on_id":"spaxel-70i","type":"blocks","created_at":"2026-04-09T14:54:38.897281189Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-sl2","depends_on_id":"spaxel-8ke","type":"blocks","created_at":"2026-04-09T14:54:38.637243667Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-sl2","depends_on_id":"spaxel-d41","type":"blocks","created_at":"2026-04-09T14:54:38.841330220Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-sl2","depends_on_id":"spaxel-i28","type":"blocks","created_at":"2026-03-28T01:33:51.145107801Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-sl2","depends_on_id":"spaxel-nhl","type":"blocks","created_at":"2026-04-09T14:54:38.714247271Z","created_by":"coding","metadata":"{}","thread_id":""}]} {"id":"spaxel-sty","title":"CSI simulator Go CLI","description":"## Background\n\nThe pre-deployment simulator (spaxel-btj) provides a browser-based spatial planning tool. The CSI simulator CLI is a complementary developer tool: a standalone Go command-line program that opens WebSocket connections to a running mothership as virtual nodes and injects synthetic CSI binary frames. This enables automated integration testing, performance benchmarking, and algorithm development entirely without ESP32 hardware.\n\nThe critical difference: the pre-deployment simulator generates CSI on the server side (using the simulation API). The CLI simulator generates CSI externally and connects via the standard node WebSocket interface — testing the full network stack and protocol, not just the signal processing.\n\n## CLI Implementation\n\nNew Go command: mothership/cmd/sim/main.go\n\nUsage examples:\n sim --mothership localhost:8080 --nodes 4 --walkers 2 --rate 20 --duration 60\n sim --mothership localhost:8080 --token abc123def456 --nodes 2 --walkers 1 --seed 42\n sim --space \"6x4x2.5\" --nodes 4 --walkers 3 --rate 50 --duration 120 --ble\n sim --verify --mothership localhost:8080 --nodes 2 --walkers 1 --duration 10\n\nCLI Flags:\n- --mothership: URL of the mothership (default: ws://localhost:8080/ws)\n- --token: provision token. If not specified, automatically provisions via POST /api/provision with synthetic credentials.\n- --nodes: number of virtual nodes (default 2). Each node opens a separate WebSocket connection.\n- --walkers: number of synthetic walkers (default 1).\n- --rate: CSI transmission rate in Hz per node pair (default 20).\n- --duration: total run time in seconds (default 60). \"0\" means run until Ctrl+C.\n- --seed: random seed for reproducible walker paths (default: random seed, logged at startup).\n- --space: room dimensions in \"WxDxH\" format (default \"5x5x2.5\").\n- --ble: include synthetic BLE advertisements (one BLE device per walker, with stable random MAC).\n- --verify: after --duration seconds, verify that the mothership produced the expected number of blobs. Exit 0 on success, 1 on failure.\n- --noise-sigma: Gaussian noise standard deviation for I/Q generation (default 0.005).\n- --wall: add a wall as \"x1,y1,x2,y2\" (can be repeated). Walls affect the path loss model.\n- --output-csv: write synthetic ground truth (walker positions + link deltaRMS) to a CSV file for offline analysis.\n\n## Synthetic CSI Frame Generation\n\nFor each virtual node pair (TX, RX) and each walker at each timestep:\n\n1. Compute RSSI from path loss model (same as simulator physics, mothership/internal/simulator/physics.go — reuse this package).\n\n2. Compute deltaRMS from Fresnel zone overlap (same physics model).\n\n3. Generate binary CSI frame matching the Phase 1 protocol format:\n Header (24 bytes):\n - Magic: 0xABCDEF01 (4 bytes)\n - Version: 1 (1 byte)\n - Node MAC: 6 bytes (synthetic, consistent per virtual node)\n - Peer MAC: 6 bytes (TX node's MAC for RX-side frames)\n - Channel: 6 (2.4GHz ch 6) or 36 (5GHz) — configurable\n - RSSI: 1 byte (signed, from path loss calculation)\n - Num subcarriers: 64 (1 byte)\n - Timestamp_us: 8 bytes (current Unix microseconds)\n\n Payload (128 bytes = 64 subcarriers * 2 bytes each):\n - For each subcarrier i: I = amplitude * cos(phase_i) + noise, Q = amplitude * sin(phase_i) + noise\n - amplitude: from Fresnel zone deltaRMS model\n - phase_i: phase_base + i * phase_step + phase_noise (simulate subcarrier phase variation)\n - noise: gaussian(sigma=--noise-sigma)\n - Values are int8 (clamped to [-127, 127])\n\nThe frame format is validated against the actual firmware output by comparing to real recorded frames in docs/research/reference_frames.bin (if available).\n\n## Connection Protocol\n\nEach virtual node:\n1. Opens WebSocket to ws://{mothership}/ws\n2. Sends hello message: {\"type\":\"hello\",\"mac\":\"{virtual_mac}\",\"firmware_version\":\"sim-1.0.0\",\"capabilities\":{\"can_tx\":true,\"can_rx\":true},\"free_heap\":200000,\"wifi_rssi\":-45,\"ip_addr\":\"127.0.0.{n}\"}\n3. Waits for role push from mothership (expects {\"type\":\"role\",\"role\":N})\n4. If receives {\"type\":\"reject\"}: logs error and exits with code 2\n5. Begins sending CSI frames at the configured rate using the binary WebSocket message format (not JSON)\n6. Also sends health messages every 10s: {\"type\":\"health\",\"heap\":200000,\"rssi\":-45,\"uptime_s\":N}\n7. If --ble: sends BLE relay messages every 5s: {\"type\":\"ble\",\"devices\":[{\"mac\":\"...\",\"name\":\"sim-person-1\",\"rssi\":-60}]}\n\n## Verification Mode (--verify)\n\nAfter --duration seconds:\n1. Stop sending CSI frames\n2. Wait 2 seconds for pipeline to settle\n3. GET {mothership}/api/blobs — gets current list of active blobs\n4. Assert: blob_count == walker_count (within ±1 tolerance)\n5. If all walkers are within the room bounds: assert all walkers have a blob within 2m distance\n6. Print: \"PASS: {blob_count} blobs detected for {walker_count} walkers\" or \"FAIL: expected N blobs, got M\"\n7. Exit 0 (PASS) or 1 (FAIL)\n\nThis is the CI smoke test that verifies the full pipeline end-to-end without hardware.\n\n## CI Integration\n\nAdd a CI step to the mothership GitHub Actions workflow (if one exists, or document the command):\n1. Start mothership with test config (in-memory SQLite, no recording)\n2. Run: sim --verify --nodes 2 --walkers 1 --duration 10 --seed 42\n3. Assert exit code 0\n\nThis becomes the primary end-to-end integration test. If the sim fails to produce blobs, something in the pipeline is broken.\n\n## Performance Testing\n\nThe simulator supports high-throughput testing:\n- sim --nodes 16 --walkers 4 --rate 50 --duration 60: measures mothership throughput at 16 nodes * 50 Hz = 800 frames/second\n- The simulator prints throughput statistics at the end: frames sent, frames per second, CPU time\n- Use for benchmarking and profiling the mothership processing pipeline\n\n## Files to Create\n\n- mothership/cmd/sim/main.go: CLI entry point with all flags\n- mothership/cmd/sim/generator.go: synthetic CSI frame generator\n- mothership/cmd/sim/walker.go: synthetic walker movement simulation\n- mothership/cmd/sim/verify.go: blob count verification logic\n- mothership/internal/simulator/physics.go: reuse from pre-deployment simulator (shared package)\n\n## Tests\n\n- Test that generated frames have the correct binary header format (magic, version bytes in correct positions)\n- Test that RSSI value is within plausible range for the given walker distance (e.g. walker at 2m, wall_attenuation=0 -> RSSI in [-50, -70])\n- Test that generated I/Q values are clamped to int8 range [-127, 127]\n- Test hello message format matches what the mothership ingestion server expects (parsed successfully)\n- Test that --verify correctly detects missing blobs (inject 1 walker, mock mothership returns 0 blobs -> FAIL)\n- Test --seed 42 produces identical walker paths across two runs (reproducibility)\n- Test --output-csv generates a CSV with correct headers and ground truth positions\n\n## Acceptance Criteria\n\n- CLI connects and streams synthetic CSI to a running mothership\n- Mothership blob count equals walker count (within ±1) when --verify is used\n- CLI exits cleanly after --duration seconds\n- --verify returns exit code 0 when blobs match, exit code 1 when they don't\n- Works correctly in a CI environment without hardware\n- High-throughput test (16 nodes, 50 Hz) completes without mothership errors or OOM\n- Tests pass","status":"open","priority":3,"issue_type":"task","created_at":"2026-03-28T01:57:48.145516684Z","created_by":"coding","updated_at":"2026-03-28T03:29:14.669157389Z","source_repo":".","compaction_level":0,"original_size":0,"dependencies":[{"issue_id":"spaxel-sty","depends_on_id":"spaxel-i28","type":"blocks","created_at":"2026-03-28T03:29:14.669138899Z","created_by":"coding","metadata":"{}","thread_id":""}]} {"id":"spaxel-tgj","title":"Home automation integration (MQTT and webhooks)","description":"## Background\n\nMany home automation systems — Home Assistant, OpenHAB, Node-RED, Domoticz — use MQTT as their primary integration backbone. By publishing spaxel state as MQTT topics with Home Assistant auto-discovery payloads, spaxel becomes a first-class presence sensor in any HA setup. No custom integration code is needed: the entities appear automatically in Home Assistant's entity registry simply by being powered on and having MQTT configured. This makes spaxel accessible to millions of home automation users who already have HA running.\n\n## MQTT Client\n\nOptional MQTT client in mothership/internal/mqtt/client.go.\n\nThe client is optional — if MQTT is not configured, the module is a no-op. Configuration via dashboard Settings or mothership config file:\n- broker_url: e.g. \"tcp://homeassistant.local:1883\" or \"mqtt://192.168.1.100:1883\"\n- username, password (optional)\n- tls: true/false\n- client_id: \"spaxel-{mothership_id}\" (unique per mothership instance)\n- retain: true (retained messages for presence and occupancy topics)\n\nUse the github.com/eclipse/paho.mqtt.golang library (the de-facto standard Go MQTT client).\n\nReconnect policy: exponential backoff from 5s to 120s, indefinite retry. Log reconnect attempts.\n\n## MQTT Topic Structure\n\nAll topics are prefixed with \"spaxel/{mothership_id}/\" where mothership_id is the unique ID from the mothership config.\n\nPerson presence:\n- Topic: spaxel/{mothership_id}/person/{person_id}/presence\n- Payload: \"home\" or \"not_home\" (plain string, retained)\n- Updated when: a person's first labelled BLE device is seen (home) or all their BLE devices have been absent for > 15 minutes (not_home)\n\nZone occupancy:\n- Topic: spaxel/{mothership_id}/zone/{zone_id}/occupancy\n- Payload: integer count (plain string, retained, e.g. \"2\")\n- Topic: spaxel/{mothership_id}/zone/{zone_id}/occupants\n- Payload: JSON array of person names (retained, e.g. [\"Alice\",\"Bob\"])\n- Updated on every zone occupancy change\n\nFall detection:\n- Topic: spaxel/{mothership_id}/fall_detected\n- Payload: JSON {\"person_id\":\"...\",\"person_label\":\"Alice\",\"zone_id\":\"...\",\"zone_name\":\"Hallway\",\"timestamp\":\"2026-03-27T14:23:00Z\"}\n- Not retained (event topic)\n\nSystem health:\n- Topic: spaxel/{mothership_id}/system/health\n- Payload: JSON {\"node_count\":4,\"online_count\":4,\"detection_quality\":0.87,\"mode\":\"home\"}\n- Retained, updated every 60s\n\n## Home Assistant Auto-Discovery\n\nOn initial MQTT connection (and on reconnect), publish HA auto-discovery payloads to the homeassistant/ prefix topics. HA processes these automatically and adds the entities to its registry.\n\nPer person: binary_sensor (presence)\nDiscovery topic: homeassistant/binary_sensor/spaxel_{mothership_id}_{person_id}/config\nPayload (JSON, retained):\n{\n \"name\": \"Alice Presence\",\n \"unique_id\": \"spaxel_{mothership_id}_{person_id}_presence\",\n \"state_topic\": \"spaxel/{mothership_id}/person/{person_id}/presence\",\n \"payload_on\": \"home\",\n \"payload_off\": \"not_home\",\n \"device_class\": \"presence\",\n \"device\": {\n \"identifiers\": [\"spaxel_{mothership_id}\"],\n \"name\": \"Spaxel\",\n \"model\": \"Spaxel Presence System\",\n \"manufacturer\": \"Spaxel\"\n }\n}\n\nPer zone: sensor (occupancy count) + binary_sensor (zone occupied)\nDiscovery topic: homeassistant/sensor/spaxel_{mothership_id}_{zone_id}_occupancy/config\nPayload: {name, unique_id, state_topic, unit_of_measurement: \"people\", device_class: null, device: ...}\n\nFall detection: binary_sensor with device_class: \"safety\"\nDiscovery topic: homeassistant/binary_sensor/spaxel_{mothership_id}_fall/config\n\nSystem mode: select (home/away/sleep) or input_select via MQTT\nDiscovery + command topics so HA can set system mode.\n\nWhen a person or zone is deleted, publish an empty payload to the corresponding discovery topic (HA treats this as \"remove entity\").\n\n## Event Publishing\n\nThe MQTT client subscribes to the internal event bus and publishes:\n- ZoneCrossingEvent -> update zone occupancy topics\n- PersonPresenceChangeEvent -> update person presence topic\n- FallEvent -> publish to fall_detected topic\n- SystemHealthEvent -> publish to system health topic (60s interval)\n\n## Generic Webhook Integration\n\nA complementary feature: a system-level webhook that delivers ALL spaxel events to a single user-configured URL, not just user-configured automations. This is for integrations that want to receive the full event stream (e.g. a custom backend, a logging service, or a complex HA automation that can't be expressed in the automation builder).\n\nPOST /api/settings/system-webhook: set URL\nAll internal events are serialised as JSON and POST'd to this URL with event type in the X-Spaxel-Event header.\nSame retry policy as automation webhooks (one retry after 30s on 5xx).\n\n## Dashboard Settings\n\nSettings panel -> \"Integrations\" tab:\n- MQTT section: broker URL, username, password (masked), TLS toggle, \"Test Connection\" button, \"Publish discovery payloads now\" button\n- System webhook section: URL input, \"Test\" button, recent delivery log (last 10 events with status)\n- Status indicator: green dot if MQTT connected, red if disconnected with last error message\n\n## Tests\n\n- Test MQTT connection to a local broker (use go-mqtt-broker test dependency or a Docker Eclipse Mosquitto in CI)\n- Test auto-discovery payload format against HA MQTT auto-discovery spec (compare JSON structure)\n- Test retained messages: verify that on reconnect, retained messages are not re-published if unchanged\n- Test that fall_detected topic is published on FallEvent\n- Test that zone occupancy topics update correctly on ZoneCrossingEvent\n- Test auto-discovery cleanup: deleting a person sends empty payload to discovery topic\n- Test system webhook delivers all event types to a mock HTTP server\n- Test reconnect policy: simulate broker disconnect, verify client reconnects with backoff\n\n## Acceptance Criteria\n\n- Spaxel entities appear automatically in Home Assistant entity list after MQTT config without any HA config editing\n- Person presence binary_sensor in HA updates within 30 seconds of BLE presence change\n- Zone occupancy sensor in HA reflects correct integer count\n- Fall detection binary_sensor fires and resets correctly\n- System mode select allows bidirectional control from HA (HA can set spaxel mode via MQTT)\n- System webhook receives all event types\n- Tests pass","status":"open","priority":3,"issue_type":"task","created_at":"2026-03-28T01:49:02.414667027Z","created_by":"coding","updated_at":"2026-03-28T03:29:14.412561189Z","source_repo":".","compaction_level":0,"original_size":0,"dependencies":[{"issue_id":"spaxel-tgj","depends_on_id":"spaxel-c0q","type":"blocks","created_at":"2026-03-28T03:29:14.412533268Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-tgj","depends_on_id":"spaxel-c1c","type":"blocks","created_at":"2026-03-28T01:49:05.719934686Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-tgj","depends_on_id":"spaxel-nqh","type":"blocks","created_at":"2026-03-28T01:49:05.665936722Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-tgj","depends_on_id":"spaxel-qlh","type":"blocks","created_at":"2026-03-28T01:49:05.694421101Z","created_by":"coding","metadata":"{}","thread_id":""}]} {"id":"spaxel-tig","title":"Guided troubleshooting (enhanced for production)","description":"## Background\n\nThe Phase 4 guided troubleshooting bead (spaxel-r0l) covers onboarding failures and basic node offline recovery. This Phase 9 bead extends it with production-quality proactive assistance that emerges from the system's own understanding of its state: detection quality degradation warnings with root-cause analysis, post-feedback explanations that close the loop for curious users, feature discovery notifications that teach users about new capabilities as they become available, and a searchable help system for self-service support.\n\nThe philosophy: the system should feel like a knowledgeable, helpful companion that notices problems before you do and explains them in terms you understand.\n\n## 1. Proactive Quality Prompts\n\nTrigger: when ambient confidence score (Phase 5, spaxel-sbi) drops below 0.6 on any link for more than 5 consecutive minutes.\n\nAction: show a non-blocking, dismissible prompt card in the dashboard:\n\"Detection quality has dropped on [Node A] to [Node B]. This link is at [N]% reliability.\"\n\nThe card includes:\n- A \"Diagnose\" button that runs the link weather diagnostics (Phase 5, spaxel-32o) and shows the results in a slide-out panel.\n- \"Dismiss for today\" option (hides until tomorrow or until quality recovers and drops again)\n- The 3D link line is highlighted (pulsing amber) while the prompt is active\n\nThe link weather diagnostic result is shown in plain English:\n- \"Possible cause: new furniture may be blocking the sensing zone. [See where to move the node]\"\n- \"Possible cause: WiFi congestion from neighbouring networks. [What to do about this]\"\n- \"Cause unknown — system is adapting. [No action needed]\"\n\nDo NOT show this prompt if the quality drop is temporary (< 5 minutes). Many quality drops are transient (microwave oven use, brief WiFi congestion) and showing a prompt for every one would train the user to ignore them.\n\n## 2. Repeated-Setting Change Detection\n\nTrigger: if a user changes the same configuration setting (motion threshold, baseline tau, etc.) more than 3 times within a 24-hour period.\n\nThis is a signal that the user is struggling to find the right value. The system should proactively offer help rather than silently watch the user thrash.\n\nAction: show a non-intrusive prompt: \"Looks like you're fine-tuning the motion threshold. Would you like help finding the right value for your space?\"\n\nThe \"Help me tune this\" button opens a guided calibration flow:\n1. \"Set threshold too low?\" -> walk around room, system shows how many false positives at the current setting\n2. \"Set threshold too high?\" -> sit still, system shows if motion is being missed\n3. Suggests optimal value based on the diurnal baseline SNR and link health\n4. \"Apply suggested value: [N]\" button\n\nTrack repeated changes in localStorage: {setting_name: {count, last_change_timestamp}} for the last 24h.\n\n## 3. Post-Feedback Explanations\n\nWhen a user marks a detection event as a false positive (FALSE_POSITIVE feedback from spaxel-3ps), show an explanation:\n\n\"The system detected motion here because: [link A to link B]'s signal (deltaRMS) exceeded the motion threshold by [N]x at [time]. This could be caused by: [root cause from diagnostic rules, if any match, or 'ambient RF interference' as default]. We've noted this and will apply a correction.\"\n\nThe explanation uses the ExplainabilitySnapshot for the event (spaxel-ez4) to identify the contributing link, and runs a quick diagnostic check (spaxel-32o rule engine) on the link's health history at the event timestamp.\n\nShow as an expandable section (\"Why did this happen?\") on the feedback confirmation card, not as a separate notification.\n\n## 4. Feature Discovery Notifications\n\nWhen a feature becomes available for the first time (requires a one-time condition to be met), fire a single non-blocking notification:\n\nEvents and their messages:\n- DiurnalBaselineActivated (after 7 days of data, Phase 5): \"Your system has learned your home's daily patterns. Detection accuracy should improve starting today.\"\n- FirstSleepSessionComplete (first sleep monitored, Phase 7): \"Your first sleep session was tracked overnight. Tap to see your sleep summary.\"\n- WeightUpdateApproved (first self-improving weight update, Phase 7): \"Localisation accuracy improved based on your BLE device positions. Median position error decreased.\"\n- AutomationFirstFired (first automation triggered, Phase 6): \"Your first automation just ran! [View in automations log]\"\n- PredictionModelReady (7 days per person, Phase 7): \"Presence predictions are now available for [person name]. [View predictions]\"\n\nEach notification:\n- Keyed by a unique event ID stored in SQLite: feature_notifications (event_id TEXT PRIMARY KEY, fired_at DATETIME, acknowledged_at DATETIME)\n- Never fires twice (primary key ensures uniqueness)\n- Dismissed by tapping (marks acknowledged_at)\n- Does not fire during quiet hours (uses notification manager quiet hours logic)\n\n## 5. Contextual Help System\n\nA \"?\" button in the expert mode header opens a searchable help overlay. The overlay contains:\n- A search input (same fuzzy search as command palette, Phase 9 spaxel-tvq)\n- A list of help articles (approximately 30 covering all major features)\n- Each article: title, 1-3 sentence plain-English explanation, link to a relevant dashboard section or action\n\nSample articles:\n- \"What is a sensing link?\" — \"A sensing link is the path between two spaxel nodes (one transmitting, one receiving). Motion in the space between them changes the signal, which spaxel detects.\"\n- \"Why is my detection quality low?\" — \"Low quality usually means interference from other WiFi devices, an obstacle in the sensing zone, or the node is too far from your router. Click 'Diagnose' on the link to find the specific cause.\"\n- \"How does presence prediction work?\" — \"After 7 days, spaxel learns when people are typically in each room and predicts where they'll be next. Predictions appear in the Predictions panel.\"\n- \"What is the Fresnel zone?\" — \"The Fresnel zone is the region in space where motion has the most impact on the signal between two nodes. Spaxel uses this geometry to estimate where in the room a person is.\"\n\nArticles are stored as a static JSON file (dashboard/help_articles.json, 30-50 articles). No server round-trip needed for help.\n\n## Implementation Structure\n\n- mothership/internal/help/notifier.go: feature discovery notification manager, persistence\n- dashboard/js/proactive.js: quality prompt, repeated-setting detector, post-feedback explanation\n- dashboard/js/help.js: help overlay, fuzzy search on articles, article rendering\n- dashboard/help_articles.json: all help article content\n- mothership/internal/diagnostics/linkweather.go: add GetDiagnosticFor(linkID, timestamp) method for post-feedback use\n\n## Tests\n\n- Test quality prompt trigger: mock confidence score = 0.55 for 6 minutes, verify prompt appears; confidence = 0.55 for 3 minutes, verify no prompt\n- Test repeated-setting detection: mock 4 threshold changes in 20h, verify help prompt fires\n- Test post-feedback explanation: inject FALSE_POSITIVE feedback on an event with a known ExplainabilitySnapshot, verify explanation text contains the contributing link name\n- Test feature discovery: inject DiurnalBaselineActivated event, verify notification fires once; inject again, verify no second notification\n- Test help search: query \"fresnel\" -> \"What is the Fresnel zone?\" appears in results\n- Test dismissed prompts don't re-appear (localStorage + SQLite persistence)\n\n## Acceptance Criteria\n\n- Quality prompt appears within 5 minutes of confidence score dropping below 0.6 threshold\n- Prompt does NOT appear for transient drops shorter than 5 minutes\n- \"Diagnose\" in quality prompt shows root cause in plain language\n- Repeated-setting detection fires after 3+ changes in 24h\n- Post-feedback explanation shown after any FALSE_POSITIVE feedback submission\n- Feature discovery notifications fire exactly once per feature, in plain language\n- Help overlay opens with \"?\" button, search finds relevant articles\n- Dismissed prompts never re-appear (unless condition reoccurs after recovery)\n- Tests pass","status":"open","priority":3,"issue_type":"task","created_at":"2026-03-28T02:04:15.981731936Z","created_by":"coding","updated_at":"2026-03-28T03:29:15.089323032Z","source_repo":".","compaction_level":0,"original_size":0,"dependencies":[{"issue_id":"spaxel-tig","depends_on_id":"spaxel-32o","type":"blocks","created_at":"2026-03-28T02:04:22.625685956Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-tig","depends_on_id":"spaxel-sbi","type":"blocks","created_at":"2026-03-28T02:04:22.592483085Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-tig","depends_on_id":"spaxel-sl2","type":"blocks","created_at":"2026-03-28T03:29:15.089304486Z","created_by":"coding","metadata":"{}","thread_id":""}]} {"id":"spaxel-tim","title":"Adaptive sensing rate","description":"Implement mothership-controlled sensing rate with on-device burst detection.\n\n## Deliverables\n- Mothership rate control: send rate change commands (2Hz idle ↔ 50Hz active) per link via WebSocket\n- Rate decision logic: drop to 2Hz when no motion for 30s, burst to 50Hz on motion\n- On-device amplitude variance check at low rate (2Hz) — if variance exceeds threshold, burst to full rate and notify mothership\n- Motion hints from ESP32 to preemptively ramp adjacent links\n- Firmware changes: firmware/main/csi.c to support dynamic rate changes\n\n## Acceptance Criteria\n- Idle links automatically drop to 2Hz packet rate\n- Motion triggers burst to configured active rate\n- ESP32 can locally detect motion onset and self-burst before mothership commands\n- Adjacent links ramp up on motion hints from nearby nodes\n- Tests for rate decision logic in mothership\n\n## References\n- Plan: docs/plan/plan.md item 12\n- CSI capture: firmware/main/csi.c\n- Signal pipeline: mothership/internal/signal/processor.go","status":"closed","priority":2,"issue_type":"task","assignee":"spaxel-alpha","created_at":"2026-03-27T01:56:21.876231481Z","created_by":"coding","updated_at":"2026-03-28T05:36:02.592406514Z","closed_at":"2026-03-28T05:36:02.592346365Z","close_reason":"Implemented: ratecontrol.go (bcfd1e3, fb69190) — mothership-controlled 2Hz↔50Hz rate changes, firmware csi.c/websocket.c dynamic rate config, on-device amplitude variance burst detection","source_repo":".","compaction_level":0,"original_size":0} {"id":"spaxel-tqj","title":"CSI recording buffer","description":"Implement disk-backed circular buffer for CSI frame recording.\n\n## Deliverables\n- New package: mothership/internal/recording/\n- Append incoming CSI frames to disk-backed circular buffer (48h default retention)\n- Binary format for efficient storage (same frame format as WebSocket)\n- Configurable retention period via environment variable\n- Foundation for time-travel replay feature (Phase 8)\n\n## Acceptance Criteria\n- CSI frames are persisted to disk as they arrive\n- Buffer auto-prunes frames older than retention period\n- Can read back frames for a given time range\n- Storage is bounded (auto-prune prevents disk exhaustion)\n- Tests cover write, read-back, and pruning\n\n## References\n- Frame format: mothership/internal/ingestion/frame.go (24-byte header + payload)\n- Ring buffer: mothership/internal/ingestion/ring.go (in-memory reference)","status":"closed","priority":2,"issue_type":"task","assignee":"spaxel-alpha","created_at":"2026-03-27T01:56:09.947974130Z","created_by":"coding","updated_at":"2026-03-28T01:34:05.658150061Z","closed_at":"2026-03-27T03:02:15.596740568Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"dependencies":[{"issue_id":"spaxel-tqj","depends_on_id":"spaxel-cxm","type":"blocks","created_at":"2026-03-28T01:34:05.658124716Z","created_by":"coding","metadata":"{}","thread_id":""}]} {"id":"spaxel-tr7","title":"3D spatial visualization","description":"Full Three.js 3D scene with humanoid figures, room bounds, and node meshes.\n\n## Deliverables\n- Room bounds visualization (walls, floor, ceiling from configured dimensions)\n- Floor plan texture support (uploaded image mapped to ground plane)\n- Humanoid figures using SkinnedMesh + AnimationMixer (standing/walking/seated/lying)\n- Vertical pillar anchors and footprint trails for tracked blobs\n- Node meshes at configured 3D positions with link lines between pairs\n- View presets (top-down, perspective, first-person follow)\n- WebSocket integration to receive blob positions from mothership\n\n## Acceptance Criteria\n- Humanoid figures animate smoothly between postures\n- User can orbit, pan, zoom with OrbitControls\n- Node positions and link lines update in real-time\n- Works with existing dashboard skeleton (dashboard/js/app.js)\n\n## References\n- Plan: docs/plan/plan.md item 17\n- Dashboard: dashboard/index.html, dashboard/js/app.js","status":"closed","priority":2,"issue_type":"task","assignee":"spaxel-alpha","created_at":"2026-03-27T01:57:04.504533558Z","created_by":"coding","updated_at":"2026-03-28T05:36:26.148595152Z","closed_at":"2026-03-28T05:36:26.148493523Z","close_reason":"Implemented: dashboard/js/viz3d.js 566 lines (bcd19ad) — room bounds, humanoid SkinnedMesh 13-bone skeleton 4 postures, footprint trails, node meshes, link lines, 3 view presets","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred"],"dependencies":[{"issue_id":"spaxel-tr7","depends_on_id":"spaxel-cxm","type":"blocks","created_at":"2026-03-28T03:29:13.740185994Z","created_by":"coding","metadata":"{}","thread_id":""}]} +{"id":"spaxel-trsm","title":"Make expert mode mobile-responsive","description":"Touch orbit/pan/zoom functionality for mobile devices.","status":"open","priority":2,"issue_type":"task","created_at":"2026-04-10T02:03:09.684731821Z","created_by":"coding","updated_at":"2026-04-10T02:03:09.684731821Z","source_repo":".","compaction_level":0,"original_size":0,"labels":["mitosis-child","mitosis-depth:1","parent-spaxel-17u"]} {"id":"spaxel-ts2","title":"Implement image upload endpoint","description":"## Task\nImplement POST /api/floorplan/image endpoint.\n\n## Specification\n- Multipart form handling\n- Accept PNG/JPG max 10 MB\n- Save to /data/floorplan/image.png\n- Reject > 10 MB upload with 413 error\n\n## Acceptance\n- Image upload saves file to /data/floorplan/image.png\n- > 10 MB upload rejected with 413 error","status":"closed","priority":2,"issue_type":"task","assignee":"charlie","created_at":"2026-04-07T17:55:50.419717078Z","created_by":"coding","updated_at":"2026-04-07T18:43:14.895237433Z","closed_at":"2026-04-07T18:43:14.895178829Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["failure-count:2","mitosis-child","mitosis-depth:1","parent-spaxel-klk"]} {"id":"spaxel-tvq","title":"Command palette","description":"## Background\n\nExpert users — system installers, power users, home automation enthusiasts — want to operate the dashboard entirely from the keyboard. Reaching for the mouse to navigate between nodes, zones, and features breaks focus. The command palette (Ctrl+K / Cmd+K) provides a keyboard-driven interface to every feature: navigate to any person, zone, or node by typing their name, execute commands like \"Start OTA\" or \"Toggle Fresnel overlay\", and even jump the 3D scene to specific timestamps using a time syntax.\n\n## Trigger and Appearance\n\nKeyboard shortcut: Ctrl+K (Windows/Linux) or Cmd+K (macOS). Also triggerable via a small search icon button in the dashboard header bar.\n\nAvailable in: expert mode only. Not available in simple mode or ambient mode (those are for non-technical users who don't benefit from a command palette).\n\nThe palette appears as a centred modal overlay:\n- Semi-transparent dark backdrop (opacity 0.5, backdrop-filter: blur(4px))\n- Centred container: max-width 600px, border-radius 12px, background #1e293b\n- Top: search input (auto-focused, placeholder \"Search people, zones, nodes, commands...\")\n- Below: results list (max 8 visible, scrollable)\n\nClose on: Escape key, click on backdrop, second Ctrl+K/Cmd+K.\n\n## Search Scope\n\nAll entities are cached client-side in the dashboard's state store (already maintained from WebSocket updates). No server round-trips for search — purely client-side matching.\n\nSearch categories (in priority order in results):\n1. People: names from the people registry. Icon: person silhouette. Action: jump 3D camera to person's current blob.\n2. Zones: zone names. Icon: location pin. Action: jump 3D camera to zone centroid, select zone.\n3. Nodes: node labels or MAC addresses. Icon: radio antenna. Action: jump 3D camera to node position, select node.\n4. Recent events: last 20 timeline events (titles). Icon: clock. Action: open event detail in timeline.\n5. Commands: static list of dashboard commands (see Commands below). Icon: lightning bolt. Action: execute command.\n6. Time navigation: if query starts with \"@\", attempt time parsing (see below). Icon: clock. Action: seek replay to that time.\n\n## Fuzzy Matching\n\nClient-side fuzzy matching for all categories. Use a simple Jaro-Winkler or Levenshtein-distance based scorer:\n- Exact prefix match: highest score. \"Kit\" -> \"Kitchen\" gets top score.\n- Subsequence match: \"kitch rm\" -> \"Kitchen\" matches (not adjacent characters but in order).\n- Typo tolerance: 1 character substitution tolerated for strings > 4 characters.\n\nImplementation: a custom 30-line fuzzy match function in JavaScript. No dependencies needed. The function returns a score in [0, 1]; results with score < 0.3 are excluded.\n\nSort: primary by category priority (commands highest if starting with \"/\"), secondary by match score.\n\n## Commands\n\nStatic list of commands accessible from the palette:\n\nNavigation commands:\n- \"Open settings\" -> navigate to /settings\n- \"Open fleet page\" -> navigate to /fleet\n- \"Open automations\" -> navigate to /automations\n- \"Open simulator\" -> navigate to /simulate\n\nView commands:\n- \"Toggle Fresnel overlay\" -> toggle the Fresnel zone debug layer\n- \"Toggle flow map\" -> toggle the flow map layer\n- \"Toggle dwell heatmap\" -> toggle the dwell heatmap layer\n- \"Toggle zone volumes\" -> toggle zone cuboid visibility\n- \"Reset camera\" -> fly camera back to default top-down position\n\nSystem commands:\n- \"Enter away mode\" -> POST /api/mode {\"mode\":\"away\"}\n- \"Enter home mode\" -> POST /api/mode {\"mode\":\"home\"}\n- \"Enter sleep mode\" -> POST /api/mode {\"mode\":\"sleep\"}\n- \"Trigger fleet OTA\" -> opens the fleet OTA dialog\n- \"Add a person\" -> opens the Add Person form in the People & Devices panel\n- \"Add a zone\" -> starts zone creation mode in the 3D view\n- \"Add a portal\" -> starts portal creation mode\n\nDebug commands (shown at bottom, lower priority):\n- \"Export all events CSV\" -> GET /api/events?format=csv and download\n- \"Show link health table\" -> opens the link health panel\n- \"Run diagnostics\" -> triggers a diagnostics pass and shows results\n- \"Check firmware updates\" -> fetches latest firmware version and compares to all nodes\n\n## Time Navigation\n\nIf the query starts with \"@\": attempt to parse as a time expression and offer a \"Jump to time\" result.\n\nSupported formats:\n- \"@3am\" -> today at 03:00\n- \"@3:15am\" -> today at 03:15\n- \"@yesterday 11pm\" -> yesterday at 23:00\n- \"@2026-03-27 14:23\" -> specific datetime\n- \"@-30min\" -> 30 minutes ago from now\n- \"@-2h\" -> 2 hours ago\n\nOn selection: triggers time-travel replay to the parsed timestamp (same as clicking a timeline event's tap-to-jump).\n\nShow parsing preview in the result item: \"Jump to 2026-03-27 03:00:00\" with a clock icon.\n\n## Result Item Rendering\n\nEach result item in the list:\n- Left: icon (category-appropriate SVG, 16px)\n- Centre-left: primary text (entity name or command label, 14px)\n- Centre-right: secondary text (grey, 12px): for zones: \"[N] people currently\", for nodes: \"[online/offline]\", for commands: keyboard shortcut hint if any\n- Right: arrow icon (shows the item is actionable)\n\nSelected item (keyboard navigation): blue #3b82f6 background highlight.\n\n## Keyboard Navigation\n\n- Arrow up/down: move selection through results\n- Enter: execute selected item\n- Tab: same as Enter (for keyboard-first users who use Tab to confirm)\n- Escape: close palette\n- Character keys: type to refine search (selection resets to first result on each keystroke)\n\n## Recent History\n\nWhen the palette opens with an empty query: show \"Recent\" header with the last 5 palette actions (stored in localStorage \"spaxel_palette_history\"). Format: same as search results but without scores. \"Recent\" category shown before search results.\n\nRecent history excludes time navigation entries (those are ephemeral).\n\n## Files to Create or Modify\n\n- dashboard/js/commandpalette.js: CommandPaletteManager, fuzzy match, time parsing, result rendering\n- dashboard/js/commandpalette.css: modal overlay, input, result list styles\n- dashboard/js/app.js: keyboard shortcut listener (Ctrl+K / Cmd+K), integrate CommandPaletteManager\n\n## Tests\n\n- Test fuzzy matching: \"kit\" -> \"Kitchen\" score > 0.7; \"livig rm\" -> \"Living Room\" score > 0.5; \"xyz\" -> \"Kitchen\" score < 0.3 (excluded)\n- Test time navigation parsing: \"@3am\" parses to today at 03:00; \"@-30min\" parses to 30 minutes ago; \"@2026-03-27 14:23\" parses correctly\n- Test that commands list is complete (all documented commands present in the registry)\n- Test keyboard navigation: arrow down moves selection, Enter executes, Escape closes\n- Test recent history: execute 5 actions, open palette with empty query -> 5 recent items shown\n- Test that palette does not activate in simple mode or ambient mode (keyboard listener absent)\n- Test that viewport reposition correctly positions the palette centred on the screen\n\n## Acceptance Criteria\n\n- Command palette opens with Ctrl+K (or Cmd+K on macOS) in < 50ms\n- Fuzzy search returns \"Kitchen\" for query \"kitch\", \"kit\", \"ktchn\"\n- Time navigation \"@3am\" correctly seeks replay to 03:00 today\n- All documented commands are accessible and execute correctly\n- Arrow key navigation works correctly through results\n- Recent history shows last 5 palette actions on empty query\n- Palette unavailable in simple and ambient modes\n- All features accessible in 3 keystrokes or fewer from palette open\n- Tests pass","status":"open","priority":3,"issue_type":"task","created_at":"2026-03-28T02:02:28.058307267Z","created_by":"coding","updated_at":"2026-03-28T03:29:15.028133142Z","source_repo":".","compaction_level":0,"original_size":0,"dependencies":[{"issue_id":"spaxel-tvq","depends_on_id":"spaxel-s70","type":"blocks","created_at":"2026-03-28T02:02:31.595593278Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-tvq","depends_on_id":"spaxel-sl2","type":"blocks","created_at":"2026-03-28T03:29:15.028093011Z","created_by":"coding","metadata":"{}","thread_id":""}]} {"id":"spaxel-u7y","title":"Firmware: NTP clock sync for TX stagger accuracy","description":"## Overview\nImplement NTP synchronization on ESP32-S3 so all nodes share a common clock, enabling accurate TX stagger scheduling to avoid CSI collisions.\n\n## Firmware (firmware/main/wifi.c or ntp.c)\n- Call esp_sntp_setservername(0, ntp_server) before esp_sntp_init() on boot\n- ntp_server read from NVS 'ntp_server' key (default: 'pool.ntp.org')\n- Attempt sync for up to 10 seconds after WiFi connect; log WARN to UART if sync fails\n- On sync failure: proceed without stagger (rely on CSMA/CA for collision avoidance)\n- Resync every 10 minutes via esp_timer periodic callback\n- Include NTP sync status in health JSON message: {type:'health', ..., ntp_synced: true/false}\n\n## Mothership (provisioning payload)\n- Read SPAXEL_NTP_SERVER env var (default: pool.ntp.org)\n- Embed ntp_server field in provisioning payload JSON\n- Support config downstream message field ntp_server to push updated server to nodes\n\n## Acceptance\n- Node health messages show ntp_synced: true when pool is reachable\n- ntp_synced: false when NTP blocked — node still operates normally\n- Resync occurs every ~600s (verified via UART logs)","status":"closed","priority":2,"issue_type":"task","assignee":"alpha","created_at":"2026-04-06T16:42:26.894640218Z","created_by":"coding","updated_at":"2026-04-07T17:46:19.521425117Z","closed_at":"2026-04-07T17:46:19.521245004Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["failure-count:1"],"dependencies":[{"issue_id":"spaxel-u7y","depends_on_id":"spaxel-288","type":"blocks","created_at":"2026-04-07T14:37:00.359263571Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-u7y","depends_on_id":"spaxel-qgj","type":"blocks","created_at":"2026-04-07T14:37:00.321904383Z","created_by":"coding","metadata":"{}","thread_id":""}]} @@ -153,7 +161,7 @@ {"id":"spaxel-ux6","title":"Mothership: startup phase sequencing with timeout enforcement","description":"## Overview\nImplement explicit startup phase logging and a 30-second total timeout so the mothership fails fast and clearly on misconfiguration.\n\n## Phases (plan lines 3450-3475):\nPhase 1/7 — Data directory: create /data, acquire flock() lock (prevents dual-instance)\nPhase 2/7 — SQLite: open database, enable WAL mode, set busy_timeout=5000\nPhase 3/7 — Schema migrations: apply pending migrations (spaxel-9z3)\nPhase 4/7 — Config & secrets: validate env vars (spaxel-env-validation), load/generate install secret\nPhase 5/7 — Subsystems: start all managers (fleet, ingestion, signal, fusion, etc.) with 5s per-subsystem timeout\nPhase 6/7 — HTTP + mDNS: bind HTTP server, advertise _spaxel._tcp.local\nPhase 7/7 — Health: run initial health check; log [READY]\n\n## Implementation\n- context.WithTimeout(30s) wraps all 7 phases\n- Each phase: log '[PHASE N/7 — Description]' on start; '[PHASE N/7 OK] (Xms)' on completion\n- Phase 5 subsystem timeout: each manager.Start() called with 5s context; if any fails, abort startup\n- On 30s deadline exceeded: log fatal '[STARTUP TIMEOUT] Failed to reach ready state in 30s'; exit(1)\n- Write /tmp/spaxel.ready on Phase 7 success (optional, for Docker --health-cmd alternative)\n\n## Acceptance\n- Startup log shows all 7 phases with timing\n- Missing data directory: fails at Phase 1 with clear error\n- DB corruption: fails at Phase 2 with clear error\n- Subsystem timeout (e.g., SQLite locked): fails at Phase 5 within 5s\n- Total startup within 5s under normal conditions (logged timing confirms)","status":"closed","priority":2,"issue_type":"task","assignee":"foxtrot","created_at":"2026-04-06T16:43:56.570408149Z","created_by":"coding","updated_at":"2026-04-07T17:11:16.918324384Z","closed_at":"2026-04-07T17:11:16.918218979Z","close_reason":"Startup phase sequencing with 30s timeout enforcement already implemented in commit 76ac271. Package mothership/internal/startup provides: 7 sequential phases, 30s total timeout, 5s per-subsystem timeout, phase logging with timing, ready marker file. All 15 tests pass.","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred","failure-count:2"]} {"id":"spaxel-v5p2","title":"Add Search and Filter to Timeline","description":"Implement filter bar with checkboxes for event categories (Presence, Zones, Alerts, System, Learning). Add person dropdown, zone dropdown, date range selector (Today/Last 7 days/Last 30 days/Custom), and text search for fuzzy matching on descriptions. Client-side filtering for loaded events; server-side for date-range queries.\n\nAcceptance Criteria:\n- Type filter checkboxes correctly filter by category\n- Person and zone dropdowns filter to correct subsets\n- Date range queries return correct results\n- Text search performs fuzzy matching on descriptions\n- Load more pagination works for 500+ results","status":"open","priority":2,"issue_type":"task","created_at":"2026-04-09T17:50:35.099347841Z","created_by":"coding","updated_at":"2026-04-09T17:50:35.099347841Z","source_repo":".","compaction_level":0,"original_size":0,"labels":["mitosis-child","mitosis-depth:1","parent-spaxel-s70"]} {"id":"spaxel-v9z","title":"Diurnal adaptive baseline","description":"## Background\n\nThe EMA (Exponential Moving Average) baseline implemented in Phase 2 adapts to ambient conditions on a roughly 30-second timescale. This handles rapid environmental changes well, but misses systematic daily patterns: more WiFi interference in evenings due to neighbour activity, temperature changes affecting the ESP32's hardware oscillator characteristics, different background activity patterns at different times of day (e.g. higher ambient motion from TV or household activity in the evenings). A diurnal (24-hour) baseline learns these patterns and crossfades to the appropriate hourly baseline, dramatically reducing false positives at different times of day.\n\n## What is a Diurnal Baseline?\n\nInstead of a single EMA that tracks the most recent state, we maintain 24 separate baseline vectors — one per hour of the day. Each hour-slot baseline is an array of float64 values, one per CSI subcarrier (matching the existing baseline format). The hour-slot is updated only by readings that arrive during that hour, using a very slow EMA (tau = 7 days, so alpha ≈ 0.00017 per sample at 2 Hz). This means each hour-slot slowly learns the characteristic ambient CSI for that time of day, averaged over many days.\n\n## 7-Day Learning Period\n\nA freshly deployed system has no diurnal data. For the first 7 days, the system continues to use the standard Phase 2 EMA baseline for all detection decisions. During this period, all received readings are silently updating the diurnal slots, but those slots are not used for detection. The dashboard shows: \"Learning your home's daily patterns: {N} days remaining.\"\n\nAfter 7 days of data (where \"data\" means at least 100 readings in each hour-slot — this threshold prevents partial-data slots from being used), the diurnal baseline activates automatically. A one-time notification is shown: \"Your system has learned your daily patterns. Accuracy should improve this week.\"\n\n## Crossfade Algorithm\n\nA naive implementation would jump discontinuously at each hour boundary, causing false detections at e.g. exactly 14:00 when the baseline switches from the 13:xx slot to the 14:xx slot. The fix is a smooth crossfade:\n\nLet h = current_hour (0-23), frac = current_minute / 60.\nEffective baseline B_eff = (1 - frac) * B_slot[h] + frac * B_slot[(h+1) % 24]\n\nThis is a linear interpolation between the current-hour and next-hour baselines. At 13:00, B_eff = B_slot[13]. At 13:30, B_eff = 0.5*B_slot[13] + 0.5*B_slot[14]. At 13:59, B_eff is nearly B_slot[14]. A cosine crossfade (frac_smooth = (1 - cos(pi * frac)) / 2) can be used instead of linear for a perceptually smoother transition.\n\nThe crossfade is applied per-subcarrier to the full baseline vector before comparing to incoming CSI readings.\n\n## Confidence Indicator\n\nThe confidence score is a per-link float in [0, 1] that summarises the reliability of detection on that link. It is broadcast as part of the \"link_health\" WebSocket message and rendered in the dashboard as a colour-coded indicator per link (green > 0.7, amber 0.4-0.7, red < 0.4).\n\nConfidence inputs:\n1. Baseline age: time since the diurnal slot for the current hour was last updated. Staleness reduces confidence. If a slot has not been updated for > 3 days, its confidence contribution is 0.\n2. Diurnal learning progress: 0.0 before 7 days, interpolates to 1.0 at 14 days. This ramps in the diurnal component gradually as more data accumulates.\n3. Packet rate health: actual received packets per second divided by the configured sample rate. If packet rate drops to 80% of configured, confidence = 0.8. At 50%, confidence = 0.5.\n4. Composite: weighted_avg(baseline_age: 0.3, diurnal_progress: 0.3, packet_rate: 0.4).\n\n## SQLite Persistence\n\nThe diurnal baseline must survive mothership restarts. Extend the existing BaselineManager.Snapshot() / RestoreBaseline() methods to include diurnal data.\n\nAdd SQLite table: diurnal_baselines (link_id TEXT, hour_slot INTEGER, subcarrier_idx INTEGER, value REAL, sample_count INTEGER, last_updated DATETIME, PRIMARY KEY (link_id, hour_slot, subcarrier_idx)).\n\nOn startup, RestoreBaseline() loads diurnal slots from SQLite. On shutdown (or every 5 minutes as a background snapshot), Snapshot() writes updated diurnal slots to SQLite. The snapshot is incremental: only write slots that have been updated since the last snapshot.\n\nFile: mothership/internal/signal/baseline.go — extend existing BaselineManager struct.\n\n## Implementation Structure\n\nNew struct DiurnalBaseline within baseline.go:\n- slots [24][]float64: per-hour baseline vectors (len = num_subcarriers)\n- sampleCounts [24]int: readings accumulated per slot\n- lastUpdated [24]time.Time: timestamp of last slot update\n- alpha float64: slow EMA coefficient (default: 1/(7*24*3600*2) per sample at 2Hz)\n\nDiurnalBaseline.Update(hour int, values []float64) method: applies slow EMA to the appropriate hour slot.\nDiurnalBaseline.EffectiveBaseline(t time.Time) []float64: returns the crossfaded baseline for the given timestamp.\nDiurnalBaseline.IsReady() bool: returns true if 7+ days have elapsed since first update AND all 24 slots have >= 100 samples.\nDiurnalBaseline.Confidence(t time.Time, packetRateRatio float64) float64: returns composite confidence score.\n\n## Tests\n\n- Test that hour-slot selection is correct for timestamps at boundaries (23:59:59 -> slot 23, 00:00:00 -> slot 0)\n- Test that crossfade at half-hour produces the correct blend of two adjacent slots\n- Test cosine crossfade is smooth (no discontinuity at integer hours in the smooth version)\n- Test that the 7-day learning gate correctly returns IsReady() = false before 7 days and true after\n- Test that confidence score is 0 when packet_rate_ratio = 0\n- Test SQLite snapshot round-trip: snapshot diurnal data, clear in-memory state, restore, verify values match\n- Test that baseline staleness correctly reduces confidence for a slot not updated in > 3 days\n\n## Acceptance Criteria\n\n- Diurnal baseline automatically activates after 7 days of data collection per link\n- Hour-boundary crossfade is smooth (no visible discontinuities in false positive rate)\n- Confidence indicator visible per link in dashboard, updates in real-time\n- Diurnal baseline data persists across mothership restarts via SQLite snapshot\n- Detection accuracy measurably improves (target: <5% false positive rate after 7-day learning vs >10% with standard EMA baseline in homes with consistent daily patterns)\n- One-time \"patterns learned\" notification fires exactly once after 7 days\n- Tests pass","status":"closed","priority":3,"issue_type":"task","assignee":"india","created_at":"2026-03-28T01:39:55.414445302Z","created_by":"coding","updated_at":"2026-03-29T18:07:39.839347486Z","closed_at":"2026-03-29T18:07:39.838982115Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred"],"dependencies":[{"issue_id":"spaxel-v9z","depends_on_id":"spaxel-axa","type":"blocks","created_at":"2026-03-28T03:29:13.961565954Z","created_by":"coding","metadata":"{}","thread_id":""}]} -{"id":"spaxel-vuw","title":"Spatial automation: trigger volume geometry builder","description":"## Overview\n3D trigger volume editor and point-in-volume evaluation engine for the spatial automation system.\n\n## Backend (mothership/automation/ or zones/)\n- Geometry types: box {type, x, y, z, w, d, h} and cylinder {type, cx, cy, z, r, h} stored as shape_json\n- Point-in-volume tests: axis-aligned box test and cylinder test functions\n- Trigger state machine per (trigger_id, blob_id) pair: track inside/outside state and transition edges (enter, leave, dwell, vacant, count)\n- Dwell timer: fire dwell action after N continuous seconds inside volume\n- SQLite triggers table: id, name, shape_json, condition TEXT, condition_params JSON, actions_json, enabled BOOL, last_fired_ms\n- REST CRUD at /api/triggers (requires spaxel-6ha)\n\n## Dashboard (dashboard/js/automation-builder.js)\n- Automation panel via panel framework (spaxel-896)\n- Draw box volume: click + drag to define base footprint, height slider\n- Draw cylinder volume: click center, drag radius, height slider\n- THREE.js TransformControls for translate/scale/rotate after placement\n- Volume visualization: translucent colored box/cylinder; pulse animation when condition fires\n- Condition picker: enter zone / leave zone / dwell N seconds / zone vacant / count >= N\n- Action list: webhook URL, MQTT topic/payload, internal (arm security, rebaseline, notify)\n- Trigger log: last 10 firings with timestamp and matched blob\n\n## Acceptance\n- Box and cylinder volumes render correctly in 3D view\n- Point-in-volume evaluated on each fusion tick (target <1ms per trigger)\n- Dwell trigger fires at correct time ±1s\n- Trigger state persists across server restart\n- Requires: spaxel-896, spaxel-6ha, spaxel-9eg","status":"open","priority":2,"issue_type":"task","created_at":"2026-04-06T13:01:42.971994626Z","created_by":"coding","updated_at":"2026-04-06T22:37:47.261863838Z","source_repo":".","compaction_level":0,"original_size":0,"labels":["blocked","deferred","failure-count:20"],"dependencies":[{"issue_id":"spaxel-vuw","depends_on_id":"spaxel-6ha","type":"blocks","created_at":"2026-04-06T22:30:46.177551897Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-vuw","depends_on_id":"spaxel-9eg","type":"blocks","created_at":"2026-04-06T22:30:46.211344140Z","created_by":"coding","metadata":"{}","thread_id":""}]} +{"id":"spaxel-vuw","title":"Spatial automation: trigger volume geometry builder","description":"## Overview\n3D trigger volume editor and point-in-volume evaluation engine for the spatial automation system.\n\n## Backend (mothership/automation/ or zones/)\n- Geometry types: box {type, x, y, z, w, d, h} and cylinder {type, cx, cy, z, r, h} stored as shape_json\n- Point-in-volume tests: axis-aligned box test and cylinder test functions\n- Trigger state machine per (trigger_id, blob_id) pair: track inside/outside state and transition edges (enter, leave, dwell, vacant, count)\n- Dwell timer: fire dwell action after N continuous seconds inside volume\n- SQLite triggers table: id, name, shape_json, condition TEXT, condition_params JSON, actions_json, enabled BOOL, last_fired_ms\n- REST CRUD at /api/triggers (requires spaxel-6ha)\n\n## Dashboard (dashboard/js/automation-builder.js)\n- Automation panel via panel framework (spaxel-896)\n- Draw box volume: click + drag to define base footprint, height slider\n- Draw cylinder volume: click center, drag radius, height slider\n- THREE.js TransformControls for translate/scale/rotate after placement\n- Volume visualization: translucent colored box/cylinder; pulse animation when condition fires\n- Condition picker: enter zone / leave zone / dwell N seconds / zone vacant / count >= N\n- Action list: webhook URL, MQTT topic/payload, internal (arm security, rebaseline, notify)\n- Trigger log: last 10 firings with timestamp and matched blob\n\n## Acceptance\n- Box and cylinder volumes render correctly in 3D view\n- Point-in-volume evaluated on each fusion tick (target <1ms per trigger)\n- Dwell trigger fires at correct time ±1s\n- Trigger state persists across server restart\n- Requires: spaxel-896, spaxel-6ha, spaxel-9eg","status":"closed","priority":2,"issue_type":"task","assignee":"hotel","created_at":"2026-04-06T13:01:42.971994626Z","created_by":"coding","updated_at":"2026-04-09T22:32:45.945424590Z","closed_at":"2026-04-09T22:32:45.945363460Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["blocked","deferred","failure-count:21"],"dependencies":[{"issue_id":"spaxel-vuw","depends_on_id":"spaxel-6ha","type":"blocks","created_at":"2026-04-06T22:30:46.177551897Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-vuw","depends_on_id":"spaxel-9eg","type":"blocks","created_at":"2026-04-06T22:30:46.211344140Z","created_by":"coding","metadata":"{}","thread_id":""}]} {"id":"spaxel-w40","title":"Passive radar: auto-detect router AP as virtual TX node","description":"## Overview\nAutomatically detect the home router as a passive radar TX source, eliminating need for a dedicated active TX node.\n\n## Firmware changes\n- During hello message, include ap_bssid and ap_channel from esp_wifi_sta_get_ap_info()\n\n## Mothership (mothership/fleet/ or ingestion/)\n- On hello: extract ap_bssid; if >=80% of nodes report same BSSID create virtual node entry with virtual=1, position unset\n- OUI lookup: embed IEEE OUI registry as Go map compiled via go:embed; display router brand\n- Detect AP BSSID change (router reboot/replacement) and emit system alert\n- SQLite nodes table: add virtual BOOL, node_type TEXT, ap_bssid TEXT, ap_channel INT columns\n\n## Dashboard\n- After AP auto-detected: 'I detected your router (ASUS). Place it on the floor plan to improve accuracy.'\n- Drag-to-place virtual node (distinct router icon) in 3D editor\n- Confirmation dialog with 'Use as signal source' toggle\n\n## Acceptance\n- Virtual node appears in /api/nodes with virtual=true\n- 3D view renders virtual node with distinct icon\n- AP change detection fires a system event within 30s of BSSID change","status":"closed","priority":2,"issue_type":"task","assignee":"alpha","created_at":"2026-04-06T13:01:07.745215170Z","created_by":"coding","updated_at":"2026-04-06T18:04:45.975811136Z","closed_at":"2026-04-06T18:04:45.975562593Z","close_reason":"Implemented passive radar auto-detection of router AP\n\nFirmware: Added ap_bssid/ap_channel to hello message using esp_wifi_sta_get_ap_info()\n\nMothership: Created apdetector package for >=80% BSSID agreement detection, OUI lookup for router manufacturer, AP change detection system events\n\nDashboard: AP detection notification, distinct router icon in 3D (box+4antennas), drag-to-place positioning\n\nVirtual nodes appear in /api/nodes with virtual=true, node_type=ap","source_repo":".","compaction_level":0,"original_size":0,"labels":["failure-count:3"]} {"id":"spaxel-x59","title":"merge: remove phase6 build tag and unify main.go","description":"## Problem\n`cmd/mothership/main_phase6.go` is gated behind `//go:build phase6` which excludes all Phase 6+ code from default builds. The directory has both `main.go` (Phase 5) and `main_phase6.go` (Phase 6) — both define `package main` with `func main()`, so removing the build tag would cause a duplicate symbol error.\n\n## Prerequisites\nAll Phase 6 package compile errors must be fixed first (spaxel-glq, spaxel-9nj, spaxel-19h, spaxel-uln, spaxel-7nk, spaxel-she).\n\n## Steps\n1. Confirm all Phase 6+ packages compile cleanly:\n ```bash\n cd /home/coding/spaxel/mothership\n PATH=$PATH:/home/coding/go/bin go build ./internal/...\n ```\n2. Delete `cmd/mothership/main.go.bak` (stale backup)\n3. Delete `cmd/mothership/main.go` (Phase 5 entrypoint, superseded)\n4. Remove the `//go:build phase6` line and the blank line after it from `cmd/mothership/main_phase6.go`\n5. Build and verify:\n ```bash\n PATH=$PATH:/home/coding/go/bin go build ./...\n PATH=$PATH:/home/coding/go/bin go test ./...\n ```\n\n## Acceptance\n- `go build ./...` passes with no errors\n- Binary is built from the Phase 6 entrypoint\n- No `phase6` build tag exists anywhere in the codebase\n\nDependents:\n <- spaxel-jcc","status":"closed","priority":1,"issue_type":"task","assignee":"delta","created_at":"2026-04-06T22:30:32.363205812Z","created_by":"coding","updated_at":"2026-04-07T05:33:07.064388207Z","closed_at":"2026-04-07T05:33:07.064285866Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["deferred","failure-count:19"],"dependencies":[{"issue_id":"spaxel-x59","depends_on_id":"spaxel-19h","type":"blocks","created_at":"2026-04-06T22:30:41.292760872Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-x59","depends_on_id":"spaxel-7nk","type":"blocks","created_at":"2026-04-06T22:30:41.351817968Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-x59","depends_on_id":"spaxel-9nj","type":"blocks","created_at":"2026-04-06T22:30:41.255304103Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-x59","depends_on_id":"spaxel-glq","type":"blocks","created_at":"2026-04-06T22:30:41.209121103Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-x59","depends_on_id":"spaxel-she","type":"blocks","created_at":"2026-04-06T22:30:41.390256545Z","created_by":"coding","metadata":"{}","thread_id":""},{"issue_id":"spaxel-x59","depends_on_id":"spaxel-uln","type":"blocks","created_at":"2026-04-06T22:30:41.322389944Z","created_by":"coding","metadata":"{}","thread_id":""}]} {"id":"spaxel-xlo","title":"Create SQLite floorplan table and storage directory","description":"## Task\nCreate the floorplan table in SQLite and ensure /data/floorplan directory exists.\n\n## Schema\nSQLite floorplan table: image_path TEXT, cal_ax,cal_ay,cal_bx,cal_by REAL, distance_m REAL, rotation_deg REAL, updated_at INT\n\n## Acceptance\n- /data/floorplan directory exists\n- floorplan table created in SQLite with correct schema","status":"closed","priority":2,"issue_type":"task","assignee":"charlie","created_at":"2026-04-07T17:55:49.108738491Z","created_by":"coding","updated_at":"2026-04-07T18:21:09.020450667Z","closed_at":"2026-04-07T18:21:09.020390325Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["mitosis-child","mitosis-depth:1","parent-spaxel-klk"]} diff --git a/.needle-predispatch-sha b/.needle-predispatch-sha index ffb65f8..8631f61 100644 --- a/.needle-predispatch-sha +++ b/.needle-predispatch-sha @@ -1 +1 @@ -a48fc8134ba7c42ebedc5ef0d3840215b754fa0f +6d30c6341441df56c3d7d2cea37f4d31144eda47 diff --git a/dashboard/css/command-palette.css b/dashboard/css/command-palette.css new file mode 100644 index 0000000..c3fd006 --- /dev/null +++ b/dashboard/css/command-palette.css @@ -0,0 +1,457 @@ +/** + * Spaxel Dashboard - Command Palette Styles + * + * Ctrl+K / Cmd+K universal search and command interface. + */ + +/* ===== Command Palette Container ===== */ +.command-palette { + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + z-index: 1000; + display: none; +} + +.command-palette.visible { + display: block; +} + +.command-backdrop { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + background: rgba(0, 0, 0, 0.6); + backdrop-filter: blur(4px); + -webkit-backdrop-filter: blur(4px); + animation: fadeIn 0.2s ease-out; +} + +@keyframes fadeIn { + from { opacity: 0; } + to { opacity: 1; } +} + +/* ===== Command Container ===== */ +.command-container { + position: absolute; + top: 15%; + left: 50%; + transform: translateX(-50%); + width: 90%; + max-width: 600px; + max-height: 70vh; + background: var(--command-bg, #1e1e1e); + border-radius: 12px; + box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5); + border: 1px solid var(--command-border, rgba(255, 255, 255, 0.1)); + display: flex; + flex-direction: column; + overflow: hidden; + animation: slideUp 0.2s ease-out; +} + +@keyframes slideUp { + from { + opacity: 0; + transform: translate(-50%, 20px); + } + to { + opacity: 1; + transform: translate(-50%, 0); + } +} + +/* ===== Command Header ===== */ +.command-header { + display: flex; + align-items: center; + gap: 12px; + padding: 16px; + border-bottom: 1px solid var(--command-border, rgba(255, 255, 255, 0.1)); +} + +.command-icon { + font-size: 20px; + flex-shrink: 0; +} + +.command-input { + flex: 1; + background: transparent; + border: none; + color: var(--command-text, #eee); + font-size: 16px; + font-family: inherit; + outline: none; +} + +.command-input::placeholder { + color: var(--command-placeholder, #666); +} + +.command-hint { + font-size: 11px; + color: var(--command-hint, #666); + white-space: nowrap; +} + +/* ===== Command Body ===== */ +.command-body { + flex: 1; + overflow-y: auto; + overflow-x: hidden; + min-height: 200px; +} + +.command-body::-webkit-scrollbar { + width: 8px; +} + +.command-body::-webkit-scrollbar-track { + background: transparent; +} + +.command-body::-webkit-scrollbar-thumb { + background: rgba(255, 255, 255, 0.2); + border-radius: 4px; +} + +.command-body::-webkit-scrollbar-thumb:hover { + background: rgba(255, 255, 255, 0.3); +} + +/* ===== Command Results ===== */ +.command-results { + padding: 8px 0; +} + +/* Category Headers */ +.command-header { + padding: 8px 16px; + font-size: 11px; + font-weight: 600; + text-transform: uppercase; + letter-spacing: 1px; + color: var(--command-header, #666); + position: sticky; + top: 0; + background: var(--command-bg, #1e1e1e); + z-index: 1; +} + +/* Command Items */ +.command-item { + display: flex; + align-items: center; + gap: 12px; + padding: 10px 16px; + cursor: pointer; + transition: background 0.15s ease; + border-left: 2px solid transparent; +} + +.command-item:hover { + background: var(--command-hover, rgba(255, 255, 255, 0.05)); +} + +.command-item.selected { + background: var(--command-selected, rgba(79, 195, 247, 0.15)); + border-left-color: var(--command-accent, #4fc3f7); +} + +.command-item-icon { + font-size: 18px; + flex-shrink: 0; + width: 24px; + text-align: center; +} + +.command-item-content { + flex: 1; + min-width: 0; +} + +.command-item-title { + font-size: 14px; + font-weight: 500; + color: var(--command-text, #eee); + margin-bottom: 2px; +} + +.command-item-description { + font-size: 12px; + color: var(--command-description, #888); + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.command-item-shortcut { + font-size: 11px; + font-family: monospace; + color: var(--command-shortcut, #666); + background: var(--command-shortcut-bg, rgba(255, 255, 255, 0.1)); + padding: 2px 6px; + border-radius: 4px; + flex-shrink: 0; +} + +/* Highlight matches in search results */ +.command-item-title mark, +.command-item-description mark { + background: var(--command-mark-bg, rgba(79, 195, 247, 0.3)); + color: var(--command-mark-text, #4fc3f7); + padding: 0 2px; + border-radius: 2px; +} + +/* ===== Empty State ===== */ +.command-empty { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + padding: 60px 20px; + color: var(--command-empty, #666); +} + +.empty-icon { + font-size: 48px; + margin-bottom: 16px; + opacity: 0.5; +} + +.empty-text { + font-size: 16px; + font-weight: 500; + margin-bottom: 4px; +} + +.empty-hint { + font-size: 13px; + opacity: 0.7; +} + +/* ===== Command Footer ===== */ +.command-footer { + padding: 12px 16px; + border-top: 1px solid var(--command-border, rgba(255, 255, 255, 0.1)); + background: var(--command-footer-bg, rgba(0, 0, 0, 0.3)); +} + +.footer-hints { + display: flex; + gap: 16px; + font-size: 11px; + color: var(--command-hint, #666); +} + +.hint-item { + display: flex; + align-items: center; + gap: 4px; +} + +.hint-item kbd { + background: var(--command-kbd-bg, rgba(255, 255, 255, 0.1)); + border: 1px solid var(--command-kbd-border, rgba(255, 255, 255, 0.2)); + border-radius: 4px; + padding: 2px 6px; + font-family: monospace; + font-size: 10px; + color: var(--command-kbd, #999); +} + +/* ===== Help Modal ===== */ +.command-help-modal { + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + z-index: 1001; + display: none; +} + +.command-help-modal.visible { + display: block; +} + +.help-backdrop { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + background: rgba(0, 0, 0, 0.7); + backdrop-filter: blur(4px); + -webkit-backdrop-filter: blur(4px); +} + +.help-container { + position: relative; + background: var(--command-bg, #1e1e1e); + border-radius: 12px; + max-width: 600px; + max-height: 80vh; + margin: 10vh auto; + border: 1px solid var(--command-border, rgba(255, 255, 255, 0.1)); + box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5); + display: flex; + flex-direction: column; + overflow: hidden; +} + +.help-header { + display: flex; + justify-content: space-between; + align-items: center; + padding: 16px 20px; + border-bottom: 1px solid var(--command-border, rgba(255, 255, 255, 0.1)); +} + +.help-header h3 { + font-size: 18px; + font-weight: 600; + color: var(--command-text, #eee); + margin: 0; +} + +.help-close { + background: transparent; + border: none; + color: var(--command-close, #888); + font-size: 24px; + cursor: pointer; + padding: 0; + line-height: 1; + transition: color 0.2s; +} + +.help-close:hover { + color: var(--command-text, #eee); +} + +.help-content { + padding: 20px; + overflow-y: auto; + max-height: calc(80vh - 80px); +} + +.help-content h3 { + font-size: 16px; + font-weight: 600; + color: var(--command-text, #eee); + margin-top: 20px; + margin-bottom: 12px; +} + +.help-content h3:first-child { + margin-top: 0; +} + +.help-content p { + font-size: 14px; + color: var(--command-description, #aaa); + line-height: 1.6; + margin-bottom: 12px; +} + +.help-content ul { + margin: 0 0 12px 20px; + padding: 0; +} + +.help-content li { + font-size: 14px; + color: var(--command-description, #aaa); + line-height: 1.6; + margin-bottom: 6px; +} + +.help-content strong { + color: var(--command-text, #eee); +} + +.help-content kbd { + background: var(--command-kbd-bg, rgba(255, 255, 255, 0.1)); + border: 1px solid var(--command-kbd-border, rgba(255, 255, 255, 0.2)); + border-radius: 4px; + padding: 2px 6px; + font-family: monospace; + font-size: 12px; + color: var(--command-kbd, #999); +} + +/* ===== Responsive Design ===== */ +@media (max-width: 600px) { + .command-container { + width: 95%; + top: 10%; + max-height: 75vh; + } + + .command-item { + padding: 12px 16px; + } + + .footer-hints { + flex-wrap: wrap; + gap: 12px; + } + + .help-container { + margin: 5vh auto; + max-height: 85vh; + } +} + +/* ===== Accessibility ===== */ +.command-item:focus-visible { + outline: 2px solid var(--command-accent, #4fc3f7); + outline-offset: -2px; +} + +.command-input:focus-visible { + outline: none; +} + +/* ===== Reduced Motion ===== */ +@media (prefers-reduced-motion: reduce) { + .command-palette * { + animation-duration: 0.01ms !important; + animation-iteration-count: 1 !important; + transition-duration: 0.01ms !important; + } +} + +/* ===== Dark/Light Mode Support ===== */ +@media (prefers-color-scheme: light) { + .command-palette { + --command-bg: #ffffff; + --command-text: #1d1d1f; + --command-border: rgba(0, 0, 0, 0.1); + --command-hover: rgba(0, 0, 0, 0.05); + --command-selected: rgba(0, 122, 255, 0.1); + --command-accent: #007aff; + --command-placeholder: #999; + --command-description: #666; + --command-header: #999; + --command-hint: #666; + --command-empty: #999; + --command-shortcut: #666; + --command-shortcut-bg: rgba(0, 0, 0, 0.05); + --command-kbd-bg: rgba(0, 0, 0, 0.05); + --command-kbd-border: rgba(0, 0, 0, 0.1); + --command-kbd: #666; + --command-mark-bg: rgba(0, 122, 255, 0.2); + --command-mark-text: #007aff; + --command-footer-bg: rgba(0, 0, 0, 0.03); + --command-close: #999; + } +} diff --git a/dashboard/css/guided-help.css b/dashboard/css/guided-help.css new file mode 100644 index 0000000..9c2e889 --- /dev/null +++ b/dashboard/css/guided-help.css @@ -0,0 +1,309 @@ +/** + * Spaxel Dashboard - Guided Troubleshooting Styles + * + * Proactive contextual help panel with step-by-step guidance. + */ + +/* ===== Guided Help Container ===== */ +.guided-help-container { + position: fixed; + bottom: 20px; + left: 20px; + z-index: 200; + pointer-events: none; + opacity: 0; + transform: translateY(20px); + transition: opacity 0.3s ease, transform 0.3s ease; +} + +.guided-help-container.visible { + opacity: 1; + transform: translateY(0); + pointer-events: auto; +} + +/* ===== Help Panel ===== */ +.guided-help-panel { + background: rgba(30, 30, 58, 0.98); + border: 1px solid rgba(79, 195, 247, 0.3); + border-radius: 12px; + box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(79, 195, 247, 0.1); + width: 380px; + max-width: calc(100vw - 40px); + overflow: hidden; +} + +/* ===== Header ===== */ +.help-header { + display: flex; + justify-content: space-between; + align-items: center; + padding: 16px 20px; + background: linear-gradient(135deg, rgba(79, 195, 247, 0.15), rgba(41, 182, 246, 0.1)); + border-bottom: 1px solid rgba(79, 195, 247, 0.2); +} + +.help-title { + display: flex; + align-items: center; + gap: 10px; +} + +.help-icon { + font-size: 24px; + line-height: 1; +} + +.help-title h3 { + font-size: 16px; + font-weight: 600; + color: #eee; + margin: 0; +} + +.help-close-btn { + background: none; + border: none; + color: #888; + font-size: 24px; + cursor: pointer; + padding: 0; + line-height: 1; + width: 28px; + height: 28px; + display: flex; + align-items: center; + justify-content: center; + border-radius: 4px; + transition: background 0.2s, color 0.2s; +} + +.help-close-btn:hover { + background: rgba(255, 255, 255, 0.1); + color: #ccc; +} + +/* ===== Content ===== */ +.help-content { + padding: 20px; +} + +/* Progress Dots */ +.help-progress { + display: flex; + align-items: center; + gap: 8px; + margin-bottom: 20px; +} + +.help-progress-dot { + width: 8px; + height: 8px; + border-radius: 50%; + background: rgba(255, 255, 255, 0.15); + transition: all 0.3s ease; +} + +.help-progress-dot.active { + background: #4fc3f7; + box-shadow: 0 0 8px rgba(79, 195, 247, 0.6); + transform: scale(1.3); +} + +.help-progress-dot.completed { + background: #66bb6a; +} + +/* Step Content */ +.help-step { + margin-bottom: 16px; +} + +.step-title { + font-size: 15px; + font-weight: 600; + color: #4fc3f7; + margin: 0 0 8px 0; +} + +.step-content { + font-size: 14px; + color: #ccc; + line-height: 1.5; + margin: 0; +} + +/* Dismiss Hint */ +.help-dismiss-hint { + margin-top: 16px; + padding-top: 12px; + border-top: 1px solid rgba(255, 255, 255, 0.1); +} + +.help-dismiss-checkbox { + display: flex; + align-items: center; + gap: 8px; + font-size: 12px; + color: #888; + cursor: pointer; + user-select: none; +} + +.help-dismiss-checkbox input[type="checkbox"] { + width: 14px; + height: 14px; + accent-color: #4fc3f7; + cursor: pointer; +} + +.help-dismiss-checkbox span { + line-height: 1; +} + +/* ===== Actions ===== */ +.help-actions { + display: flex; + gap: 8px; + padding: 16px 20px; + background: rgba(0, 0, 0, 0.3); + border-top: 1px solid rgba(255, 255, 255, 0.1); +} + +.help-btn { + padding: 8px 16px; + border-radius: 6px; + font-size: 13px; + font-weight: 500; + cursor: pointer; + border: none; + transition: background 0.2s, transform 0.1s; +} + +.help-btn:hover { + transform: translateY(-1px); +} + +.help-btn:active { + transform: translateY(0); +} + +.help-btn-primary { + background: #4fc3f7; + color: #1a1a2e; + margin-left: auto; +} + +.help-btn-primary:hover { + background: #29b6f6; +} + +.help-btn-secondary { + background: rgba(255, 255, 255, 0.1); + color: #ccc; + border: 1px solid rgba(255, 255, 255, 0.15); +} + +.help-btn-secondary:hover { + background: rgba(255, 255, 255, 0.15); +} + +.help-btn-action { + background: rgba(76, 175, 80, 0.2); + color: #66bb6a; + border: 1px solid rgba(76, 175, 80, 0.4); +} + +.help-btn-action:hover { + background: rgba(76, 175, 80, 0.3); +} + +/* ===== Context Help Button ===== */ +.context-help-btn { + width: 20px; + height: 20px; + border-radius: 50%; + background: rgba(79, 195, 247, 0.2); + border: 1px solid rgba(79, 195, 247, 0.4); + color: #4fc3f7; + font-size: 12px; + font-weight: 600; + cursor: pointer; + display: inline-flex; + align-items: center; + justify-content: center; + transition: all 0.2s; + margin-left: 6px; +} + +.context-help-btn:hover { + background: rgba(79, 195, 247, 0.3); + border-color: rgba(79, 195, 247, 0.6); +} + +/* ===== Animation ===== */ +@keyframes helpSlideIn { + from { + opacity: 0; + transform: translateY(20px); + } + to { + opacity: 1; + transform: translateY(0); + } +} + +@keyframes helpPulse { + 0%, 100% { + box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(79, 195, 247, 0.1); + } + 50% { + box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 2px rgba(79, 195, 247, 0.3); + } +} + +.guided-help-container.visible .guided-help-panel { + animation: helpSlideIn 0.3s ease-out; +} + +/* ===== Responsive Design ===== */ +@media (max-width: 480px) { + .guided-help-container { + bottom: 10px; + left: 10px; + right: 10px; + } + + .guided-help-panel { + width: 100%; + max-width: none; + } + + .help-actions { + flex-wrap: wrap; + } + + .help-btn { + flex: 1; + min-width: calc(50% - 4px); + } +} + +/* ===== Accessibility ===== */ +.help-btn:focus-visible, +.help-close-btn:focus-visible, +.context-help-btn:focus-visible { + outline: 2px solid #4fc3f7; + outline-offset: 2px; +} + +/* ===== Reduced Motion ===== */ +@media (prefers-reduced-motion: reduce) { + .guided-help-container, + .guided-help-panel, + .help-progress-dot, + .help-btn { + animation: none !important; + transition-duration: 0.01ms !important; + } +} diff --git a/dashboard/css/quick-actions.css b/dashboard/css/quick-actions.css new file mode 100644 index 0000000..6126354 --- /dev/null +++ b/dashboard/css/quick-actions.css @@ -0,0 +1,284 @@ +/** + * Spaxel Dashboard - Spatial Quick Actions Styles + * + * Right-click (desktop) or long-press (mobile) context menus + * on 3D elements for context-sensitive actions. + */ + +/* ===== Context Menu Container ===== */ +.context-menu { + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + z-index: 1000; + display: none; +} + +.context-menu.visible { + display: block; +} + +.context-backdrop { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + background: rgba(0, 0, 0, 0.4); + backdrop-filter: blur(2px); + -webkit-backdrop-filter: blur(2px); + animation: fadeIn 0.15s ease-out; +} + +@keyframes fadeIn { + from { opacity: 0; } + to { opacity: 1; } +} + +/* ===== Context Container ===== */ +.context-container { + position: absolute; + min-width: 280px; + max-width: 340px; + background: var(--context-bg, #1e1e1e); + border-radius: 12px; + box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5); + border: 1px solid var(--context-border, rgba(255, 255, 255, 0.1)); + display: flex; + flex-direction: column; + overflow: hidden; + animation: scaleIn 0.15s ease-out; +} + +@keyframes scaleIn { + from { + opacity: 0; + transform: scale(0.95); + } + to { + opacity: 1; + transform: scale(1); + } +} + +/* ===== Context Header ===== */ +.context-header { + display: flex; + align-items: center; + gap: 12px; + padding: 14px 16px; + border-bottom: 1px solid var(--context-border, rgba(255, 255, 255, 0.1)); + background: var(--context-header-bg, rgba(255, 255, 255, 0.03)); +} + +.context-icon { + font-size: 22px; + flex-shrink: 0; + width: 32px; + height: 32px; + display: flex; + align-items: center; + justify-content: center; + background: var(--context-icon-bg, rgba(79, 195, 247, 0.15)); + border-radius: 8px; +} + +.context-title { + flex: 1; + font-size: 15px; + font-weight: 600; + color: var(--context-text, #eee); + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +/* ===== Context Body ===== */ +.context-body { + max-height: 400px; + overflow-y: auto; + overflow-x: hidden; +} + +.context-body::-webkit-scrollbar { + width: 6px; +} + +.context-body::-webkit-scrollbar-track { + background: transparent; +} + +.context-body::-webkit-scrollbar-thumb { + background: rgba(255, 255, 255, 0.2); + border-radius: 3px; +} + +.context-body::-webkit-scrollbar-thumb:hover { + background: rgba(255, 255, 255, 0.3); +} + +/* ===== Context Items ===== */ +.context-item { + display: flex; + align-items: flex-start; + gap: 12px; + padding: 12px 16px; + cursor: pointer; + transition: background 0.15s ease; + border-left: 3px solid transparent; +} + +.context-item:hover { + background: var(--context-hover, rgba(255, 255, 255, 0.05)); +} + +.context-item:active { + background: var(--context-active, rgba(255, 255, 255, 0.08)); +} + +.item-icon { + font-size: 18px; + flex-shrink: 0; + width: 24px; + text-align: center; + padding-top: 2px; +} + +.item-content { + flex: 1; + min-width: 0; +} + +.item-label { + font-size: 14px; + font-weight: 500; + color: var(--context-text, #eee); + margin-bottom: 2px; +} + +.item-description { + font-size: 12px; + color: var(--context-description, #888); + line-height: 1.3; +} + +/* ===== Target-Specific Styling ===== */ + +/* Blob/Person context */ +.context-menu[data-target="blob"] .context-icon { + background: rgba(79, 195, 247, 0.15); + color: #4fc3f7; +} + +/* Node context */ +.context-menu[data-target="node"] .context-icon { + background: rgba(76, 175, 80, 0.15); + color: #4caf50; +} + +/* Zone context */ +.context-menu[data-target="zone"] .context-icon { + background: rgba(255, 152, 0, 0.15); + color: #ff9800; +} + +/* Empty space context */ +.context-menu[data-target="empty"] .context-icon { + background: rgba(158, 158, 158, 0.15); + color: #9e9e9e; +} + +/* Portal context */ +.context-menu[data-target="portal"] .context-icon { + background: rgba(156, 39, 176, 0.15); + color: #9c27b0; +} + +/* Trigger context */ +.context-menu[data-target="trigger"] .context-icon { + background: rgba(244, 67, 54, 0.15); + color: #f44336; +} + +/* ===== Follow Mode Indicator ===== */ +.follow-mode-indicator { + position: fixed; + bottom: 80px; + left: 50%; + transform: translateX(-50%); + background: rgba(79, 195, 247, 0.9); + color: white; + padding: 10px 20px; + border-radius: 20px; + font-size: 14px; + font-weight: 500; + display: flex; + align-items: center; + gap: 8px; + z-index: 999; + animation: slideUp 0.2s ease-out; + pointer-events: none; +} + +.follow-mode-indicator::before { + content: '🎯'; +} + +@keyframes slideUp { + from { + opacity: 0; + transform: translate(-50%, 20px); + } + to { + opacity: 1; + transform: translate(-50%, 0); + } +} + +/* ===== Responsive Design ===== */ +@media (max-width: 600px) { + .context-container { + min-width: 260px; + max-width: 90vw; + } + + .context-item { + padding: 14px 16px; + } + + .follow-mode-indicator { + bottom: 100px; + padding: 12px 24px; + font-size: 15px; + } +} + +/* ===== Accessibility ===== */ +.context-item:focus-visible { + outline: 2px solid var(--context-accent, #4fc3f7); + outline-offset: -2px; +} + +/* ===== Reduced Motion ===== */ +@media (prefers-reduced-motion: reduce) { + .context-menu * { + animation-duration: 0.01ms !important; + animation-iteration-count: 1 !important; + transition-duration: 0.01ms !important; + } +} + +/* ===== Dark/Light Mode Support ===== */ +@media (prefers-color-scheme: light) { + .context-menu { + --context-bg: #ffffff; + --context-text: #1d1d1f; + --context-border: rgba(0, 0, 0, 0.1); + --context-hover: rgba(0, 0, 0, 0.05); + --context-active: rgba(0, 0, 0, 0.08); + --context-description: #666; + --context-header-bg: rgba(0, 0, 0, 0.02); + } +} diff --git a/dashboard/index.html b/dashboard/index.html index bf8f8bb..7f9b50b 100644 --- a/dashboard/index.html +++ b/dashboard/index.html @@ -19,6 +19,7 @@ +