You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(map): transactional safety, protocol detection, and E2E tests
Add critical production safety features to map editor:
- Pre-sync backup creation before any destructive operations
- Automatic rollback on execution failure or exception
- Dynamic protocol detection (V1/B01/A01) based on device info
- Robust trait discovery for different device types
- Exception handling with guaranteed rollback
Add E2E test suite:
- tests/e2e/test_map_editor_mqtt.py validates full flow
- Tests backup → execute → rollback sequence
- Mocks CommandTrait and MapContentTrait for safe testing
Update documentation:
- Add testing strategy & guardrails (no live destructive testing)
- Revised implementation roadmap
This addresses critical production blockers identified in review:
- P0: Pre-sync backup & auto-rollback
- P1: Protocol detection instead of hardcoded V1
- P2: E2E test coverage
Entire-Checkpoint: b9f6e9a209aa
Copy file name to clipboardExpand all lines: docs/plans/local-map-editor.md
+16-4Lines changed: 16 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -102,8 +102,20 @@ The primary engineering hurdle is translating natural language ("the kitchen") i
102
102
103
103
---
104
104
105
-
## Next Steps for Implementation
105
+
## Testing Strategy & Guardrails (CRITICAL)
106
106
107
-
1.**[PRIORITY] Parser Exploration Script:** Write a targeted script (`roborock/map/explore_parser.py`) to pull a live map and inspect the `MapData` object for raw mathematical coordinates. This validates the feasibility of Phase 1.
108
-
2.**Scaffold the Local State Machine:** Create `roborock/map/editor.py` with the `VirtualState` and `EditObject` base classes.
109
-
3.**Polymorphic Translation Design:** Define the internal schema for V1 vs. A01/B01 map editing payloads.
107
+
Because the map editor is inherently destructive (operations like splitting rooms and saving walls overwrite the robot's state), **destructive commands MUST NOT be executed on physical robots during automated or ad-hoc testing** (unless explicitly part of a signed-off, manual risk-assessment scenario).
108
+
109
+
1.**No Live Destructive Testing:** All translation layers and CLI execution paths must be tested against a Mock MQTT Broker or simulated local devices.
110
+
2.**Transactional Integrity Verification:** Tests must explicitly verify that `create_map_backup` is called before execution, and `restore_map_backup` is invoked immediately upon any failure in the Two/Three-Stage Sync batch.
111
+
3.**Payload Parity Validation:** Mock E2E tests must capture the outbound RPC payloads emitted by `TranslationLayer` and assert they mathematically match the expected constraints (e.g., coordinates are properly transformed integers, `map_flag` is injected, V1 additive batches include original state).
112
+
4.**Dynamic Protocol Fallback:** Tests must ensure the CLI dynamically chooses the V1 or A01/B01 translator based on `device_info.yaml` (via `code_mappings`), rather than hardcoding.
113
+
114
+
---
115
+
116
+
## Next Steps for Implementation (Revised)
117
+
118
+
1.**Fix Transactional Integrity:** Update `roborock/cli.py` (`_execute_edit`) to wrap the `translation.execute_edits` call in a `create_map_backup()` / `restore_map_backup()` try/except block.
119
+
2.**Implement Dynamic Protocol Selection:** Update the CLI to resolve the correct protocol version using `RoborockProductNickname` and `ProductInfo` instead of hardcoding `"v1"`.
120
+
3.**Safe E2E MQTT Tests:** Build an end-to-end integration test (`tests/e2e/test_map_editor_mqtt.py`) that feeds a real map JSON payload (e.g., `home_data_device_a245.json`) into the `MapParser`, runs the full CLI edit flow (VirtualState -> Editor -> TranslationLayer), and traps the outbound MQTT messages to assert correctness without physical side-effects.
121
+
4.**Natural Language Semantic Engine:** Enhance the CLI input parsing to support conversational commands (e.g., "Split the Kitchen in half") vs raw coordinate/room ID injections.
0 commit comments