feat(infrastructure): implement SQLite repository for relay labels

Add complete SQLite implementation of RelayLabelRepository trait with
all CRUD operations (get_label, save_label, delete_label, get_all_labels).

Key changes:
- Create infrastructure entities module with RelayLabelRecord struct
- Implement TryFrom traits for converting between database records and domain types
- Add From<sqlx::Error> and From<RelayLabelError> for RepositoryError
- Write comprehensive functional tests covering all repository operations
- Verify proper handling of edge cases (empty results, overwrites, max length)

TDD phase: GREEN - All repository trait tests now passing with SQLite implementation

Ref: T036 (specs/001-modbus-relay-control/tasks.md)
This commit is contained in:
2026-01-22 00:03:48 +01:00
parent ce186095fa
commit f726f4185a
9 changed files with 661 additions and 8 deletions

View File

@@ -27,7 +27,7 @@
--------------
* Development phases [0/0]
* TODO Development phases [4/9]
** DONE Phase 1: Setup & Foundation (0.5 days) [8/8]
*Purpose*: Initialize project dependencies and directory structure
@@ -291,7 +291,7 @@
--------------
** TODO Phase 3: Infrastructure Layer (2 days) [5/5]
** DONE Phase 3: Infrastructure Layer (2 days) [1/1]
*Purpose*: Implement Modbus client, mocks, and persistence
- [X] *T028* [P] [US1] [TDD] Write tests for =MockRelayController=
@@ -331,7 +331,9 @@
--------------
*** STARTED T025: ModbusRelayController Implementation (DECOMPOSED) [12/13]
*** DONE T025: ModbusRelayController Implementation (DECOMPOSED) [13/13]
CLOSED: [2026-01-22 jeu. 00:02]
- State "DONE" from "STARTED" [2026-01-22 jeu. 00:02]
- Complexity :: High → Broken into 6 sub-tasks
- Uncertainty :: High
- Rationale :: Nested Result handling, =Arc<Mutex>= synchronization, timeout wrapping
@@ -557,7 +559,7 @@
- Test: =delete_label(RelayId(1)) → Result<(), RepositoryError>=
- *File*: =src/infrastructure/persistence/label_repository.rs=
- *Complexity*: Low | *Uncertainty*: Low
- [ ] *T036* [P] [US4] [TDD] Implement SQLite =RelayLabelRepository=
- [X] *T036* [P] [US4] [TDD] Implement SQLite =RelayLabelRepository=
- Implement =get_label()=, =set_label()=, =delete_label()= using SQLx
- Use =sqlx::query!= macros for compile-time SQL verification
- *File*: =src/infrastructure/persistence/sqlite_label_repository.rs=