- Add migration 002: UNIQUE index on status_logs(camera_id, recorded_at)
- Upgrade migration system to version-tracked (schema_version table)
- Prevents race-condition double-inserts that application-level COUNT(*) check cannot guard against
- Complements existing application-level dedup from CUB-230
- Add request validation: Content-Type check, body size limit (64KB)
- Add field length validation (camera_id: 64, friendly_name: 128, mode: 32, resolution: 32)
- Add FPS range validation (0-240)
- Add battery_pct range validation (0-100)
- Replace ad-hoc map[string]string errors with structured APIError {error, code, details}
- Fix isUniqueConstraintErr to catch both camera_id and mac_address constraint violations
- Fix MacAddress model field from string to *string for NULL handling
- Fix splitSQL to strip -- line comments before splitting (was causing migration failures with modernc.org/sqlite)
- Add 30 integration tests covering all endpoints
- All tests pass: ok github.com/cubecraft/remoterig/internal/api
- Add dedup check in handleStatus using (camera_id, recorded_at) uniqueness
- Skip insert if duplicate detected - logs replayed entries
- Go mod: updated version to 1.19
- Added monotonic event ID (Last-Event-ID) for reconnection support
- Events now emit typed: 'event: camera_status' for client-side filtering
- Initial connection event sends 'event: connected' with ID
- Reconnection acknowledgment via Last-Event-ID header
- CORS preflight (OPTIONS) handler
- Access-Control-Allow-Headers: Last-Event-ID
- Initial heartbeat shortened to 15s for faster detect (30s for steady)
Closes CUB-233.
Implements MQTT subscriber (internal/mqtt/subscriber.go) that:
- Connects to Mosquitto broker with auto-reconnect
- Subscribes to remoterig/cameras/+/status, +/heartbeat, +/announce
- Parses and validates incoming messages per MQTT contract
- Inserts status_logs with duplicate prevention
- Auto-detects recording state changes and manages recording_events
- Broadcasts camera status changes via SSE hub
- Camera auto-registration via announce (MAC-based, sequential cam-NNN)
- Heartbeat watchdog marks cameras offline after 120s silence
- Wired into main.go with graceful degradation (warns if broker unreachable)
Dependency: github.com/eclipse/paho.mqtt.golang v1.5.0
Closes CUB-232.