Task: BrainRegistry
Parent epic: #4 (M1 — Robot Connection)
Depends on: #14 (vector-go-sdk in go.mod)
What to do
Create internal/brain/registry.go — a registry that holds one ConnectionManager per robot ESN. The Go HTTP handlers get/create robot connections through this registry.
// Package brain manages persistent SDK connections to Vector robots.
// One ConnectionManager per ESN, created on first event and held for the process lifetime.
package brain
type Registry struct { ... }
func NewRegistry(cfg *config.Config) *Registry
func (r *Registry) Get(esn string) (*ConnectionManager, bool)
func (r *Registry) GetOrCreate(esn string) *ConnectionManager
func (r *Registry) All() []*ConnectionManager
func (r *Registry) Shutdown(ctx context.Context) error
Integration
Registry is created in main.go and passed to buildRouter
/health reads registry.All() to report connection status
/api/v1/robots reads registry.All() for the robot list
/api/v1/robots/{esn}/state reads registry.Get(esn) for state
Notes
- One registry, held for process lifetime. Thread-safe (multiple HTTP handlers read it concurrently).
- The registry does not create connections proactively —
ConnectionManager does that lazily on first use or immediately if configured.
Definition of done
Registry compiles. /health returns "connected" or "disconnected" per ESN (not "configured").
Task: BrainRegistry
Parent epic: #4 (M1 — Robot Connection)
Depends on: #14 (vector-go-sdk in go.mod)
What to do
Create
internal/brain/registry.go— a registry that holds oneConnectionManagerper robot ESN. The Go HTTP handlers get/create robot connections through this registry.Integration
Registryis created inmain.goand passed tobuildRouter/healthreadsregistry.All()to report connection status/api/v1/robotsreadsregistry.All()for the robot list/api/v1/robots/{esn}/statereadsregistry.Get(esn)for stateNotes
ConnectionManagerdoes that lazily on first use or immediately if configured.Definition of done
Registry compiles.
/healthreturns"connected"or"disconnected"per ESN (not"configured").