ADR 003 — Buttons placeholder
Status
Accepted
Context
The system should support Bitfocus Buttons as a first-class adapter. However:
- The full Buttons protocol is not yet finalised
- We need to define the adapter interface now
- Development and testing should proceed without waiting for full Buttons implementation
- Contract tests should be ready for when implementation happens
Decision
We implement Buttons integration as a placeholder with:
What IS Implemented
- Type definitions: Complete type system for devices, keys, encoders, events
- Adapter interface: Full
ButtonsAdapterinterface contract - Transport abstraction: Generic transport layer (WebSocket, OSC, MQTT, etc.)
- Protocol codec abstraction: Encode/decode layer for protocol messages
- Placeholder adapter: Working implementation using in-memory transport
- Simulator: Full simulator for testing scenarios
- Contract tests: Test suite that validates the interface contract
What is NOT Implemented
- Actual Buttons protocol wire format
- Real transport connections to Buttons devices
- Device discovery over network
- Production-ready error handling for real hardware
Interface Contract
Any future implementation MUST:
interface ButtonsAdapter { readonly namespace: string; connect(router: MessageRouter): Promise<void>; disconnect(): Promise<void>; isConnected(): boolean; getDevices(): ButtonsDevice[]; getDevice(deviceId: string): ButtonsDevice | undefined; getKeyState(deviceId: string, keyIndex: number): ButtonsKeyState | undefined; setKeyImage(deviceId: string, keyIndex: number, image: string): Promise<void>; setKeyText(deviceId: string, keyIndex: number, text: string): Promise<void>; setKeyColour(deviceId: string, keyIndex: number, colour: string): Promise<void>; clearKey(deviceId: string, keyIndex: number): Promise<void>; setBrightness(deviceId: string, level: number): Promise<void>; getState(): ButtonsAdapterState; getMetrics(): ButtonsAdapterMetrics; onEvent(handler: ButtonsAdapterEventHandler): void; offEvent(handler: ButtonsAdapterEventHandler): void;}Consequences
Positive
- Development can proceed with simulated Buttons
- Interface is defined and documented
- Contract tests ensure future implementations are compatible
- No breaking changes when real implementation arrives
Negative
- Placeholder cannot connect to real Buttons devices
- Some real-world edge cases may not be covered
- Interface may need adjustment based on actual protocol
Migration Path
When full implementation is ready:
- Implement real transport (WebSocket, etc.)
- Implement real codec (protocol wire format)
- Pass placeholder adapter to new implementation
- Ensure all contract tests pass
- Remove placeholder, keep simulator for testing