feat: detect channel moves on startup, migrate messages and permissions#2433
feat: detect channel moves on startup, migrate messages and permissions#2433
Conversation
When channels are rearranged externally (e.g., via the official Meshtastic app), MeshMonitor now detects the changes on config sync and automatically: 1. Migrates messages to follow channel content to new slots 2. Migrates user permissions to match new channel assignments 3. Logs new/unknown channels (default: no permissions for non-admins) 4. Audit logs all detected changes Detection works by snapshotting channel PSKs before config sync starts, then comparing after configComplete. Also wired permission migration into the drag-and-drop reorder endpoint. Closes #2425 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
PSK-only matching could produce false positives when multiple channels share the same key. Now both PSK and channel name must match to confirm a channel has moved between slots. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Claude finished @Yeraze's task —— View job Code Review Complete ✅Reviewing PR #2433 for code quality, potential issues, and best practices:
🟢 StrengthsCode Quality & Design:
Security & Safety:
🟡 Areas for ImprovementTest Coverage - Critical Gap: // ❌ Missing: No tests for the new migration methods
await databaseService.auth.migratePermissionsForChannelMoves(moves);
await databaseService.messages.migrateMessagesForChannelMoves(moves);Recommendation: Add unit tests for Error Handling:
Code Organization:
🟠 Potential Edge Cases
🔵 Performance ConsiderationsDatabase Operations:
Memory Usage:
🔒 Security Assessment✅ No major security concerns identified
📊 RecommendationsHigh Priority:
Medium Priority: Low Priority: Overall Assessment: 🟢 APPROVE with Test RequirementsThis is a well-designed feature that addresses a real user need. The code quality is high with proper error handling and follows existing patterns. The main blocker is the lack of test coverage for critical migration logic. Once tests are added, this should be safe to merge. Migration detection logic is sound, database operations are safe, and security practices are followed. The implementation correctly handles the complex cases of channel swaps and moves. |
9 tests for migrateMessagesForChannelMoves: - Empty moves, simple moves, swaps, mixed moves - Zero affected rows, one-sided swaps, channel DB isolation 7 tests for migratePermissionsForChannelMoves: - Empty moves, simple moves, swaps, mixed moves - Multi-user swaps, non-channel permission isolation Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Claude finished @Yeraze's task —— View job Code Review Complete ✅Reviewing PR #2433 for code quality, potential issues, and best practices:
🟢 Major Improvement: Test CoverageExcellent response to previous feedback - The missing test coverage has been thoroughly addressed:
Both test suites are comprehensive and test edge cases like empty moves, swaps with missing data, and complex multi-channel scenarios. 🟢 StrengthsCode Quality & Design:
Security & Safety:
🟡 Areas for ImprovementTransaction Consistency Gap: // ❌ Messages have transaction safety, permissions do not
await databaseService.messages.migrateMessagesForChannelMoves(moves); // Has BEGIN/COMMIT/ROLLBACK
await databaseService.auth.migratePermissionsForChannelMoves(moves); // No transaction wrapperImpact: Permission migration could partially fail, leaving inconsistent state Error Handling:
Empty String Edge Case:
🔵 Performance ConsiderationsDatabase Operations:
Memory Usage:
🟠 Potential Edge Cases
🔒 Security Assessment✅ No security concerns identified
📊 Test Coverage Assessment✅ Excellent test coverage (major improvement from previous review)
Final RecommendationsHigh Priority:
Medium Priority: Low Priority: Overall Assessment: 🟢 APPROVEThis is a significant improvement over the previous version. The comprehensive test coverage addresses the main blocker identified in the earlier review. The code quality is high, follows established patterns, and implements the requested feature correctly. Key improvements:
The remaining recommendations are enhancements rather than blockers. The permission transaction consistency issue is the only moderate concern, but doesn't prevent merging since permission operations are typically small and atomic. This PR successfully implements channel migration with proper safety mechanisms and is ready for merge. |
Summary
When channels are rearranged externally (e.g., via the official Meshtastic app), MeshMonitor now detects the changes on config sync and automatically migrates messages and permissions.
Closes #2425
What happens on startup
Also included
Changes
Test plan