Mountain/IPC/mod.rs
1//! # IPC Module
2//!
3//! ## RESPONSIBILITIES
4
5#![allow(unused_imports, unused_variables)]
6//! Inter-process communication (IPC) for the Mountain application, handling
7//! communication between the Tauri frontend and the Rust backend through
8//! various protocols including Tauri commands, WebSocket, and custom message
9//! formats.
10//!
11//! ### Core Functions:
12//! - **Message Routing**: Route IPC messages to appropriate handlers
13//! - **Connection Management**: Manage IPC connections with health monitoring
14//! - **Security**: Implement permission system for IPC access control
15//! - **Encryption**: Provide secure message channels and compression
16//! - **Status Reporting**: Report IPC system status and metrics
17//! - **Configuration Bridge**: Bridge configuration across IPC boundaries
18//! - **Wind Sync**: Advanced synchronization with Wind UI framework
19//! - **Advanced Features**: Experimental/advanced IPC features
20//!
21//! ## Architectural Role
22//!
23//! The IPC module is the **communication layer** in Mountain's architecture:
24//!
25//! ```text
26//! Sky (Frontend) ──► IPC (Communication) ──► Track (Dispatch) ──► Services
27//! Wind (UI) ───────────────────────────────────────────────────────────────┘
28//! Cocoon (Sidecar) ──► Vine (gRPC) ────────────────────────────┘
29//! ```
30//!
31//! ### Design Principles:
32//! 1. **Protocol Agnostic**: Support multiple IPC protocols
33//! 2. **Security First**: All communications are secured and permission-gated
34//! 3. **High Performance**: Optimized for low-latency communication
35//! 4. **Observable**: Comprehensive logging and metrics
36//!
37//! ## Key Components
38//!
39//! - **TauriIPCServer**: Main IPC server orchestrator
40//! - **Message**: Message types and routing
41//! - **Connection**: Connection management and health
42//! - **Encryption**: Message compression and secure channels
43//! - **Security**: Permission system
44//! - **ConfigurationBridge**: Configuration synchronization
45//! - **StatusReporter**: Status and metrics reporting
46//! - **WindAdvancedSync**: Wind framework integration
47//! - **AdvancedFeatures**: Advanced/experimental features
48//!
49//! ## TODOs
50//! High Priority:
51//! - [ ] Add comprehensive unit tests for all modules
52//! - [ ] Implement connection pooling optimizations
53//! - [ ] Add connection timeout handling
54//!
55//! Medium Priority:
56//! - [ ] Add message batching for efficiency
57//! - [ ] Implement keep-alive packets
58//! - [ ] Add connection retry logic
59//!
60//! Low Priority:
61//! - [ ] Add message persistence for offline mode
62//! - [ ] Implement message compression ratio optimization
63//! - [ ] Add connection encryption rotation
64
65// --- Main Sub-modules ---
66
67/// Common shared types and abstractions for IPC layer.
68pub mod Common;
69
70/// Main Tauri IPC server orchestrator.
71// Legacy TauriIPCServer.rs for backward compatibility
72#[path = "TauriIPCServer.rs"]
73pub mod TauriIPCServer_Old;
74
75/// Message types and routing.
76pub mod Message;
77
78/// Connection management and health monitoring.
79pub mod Connection;
80
81/// Message compression and secure channels.
82pub mod Encryption;
83
84/// Permission system for IPC access control.
85pub mod Security;
86
87// --- Feature Sub-modules ---
88
89/// Advanced experimental features.
90// Legacy AdvancedFeatures.rs for backward compatibility
91#[path = "AdvancedFeatures.rs"]
92pub mod AdvancedFeatures;
93
94/// Configuration synchronization bridge.
95// Legacy ConfigurationBridge.rs for backward compatibility
96#[path = "ConfigurationBridge.rs"]
97pub mod ConfigurationBridge;
98
99/// Status and metrics reporting.
100// Legacy StatusReporter.rs for backward compatibility
101#[path = "StatusReporter.rs"]
102pub mod StatusReporter;
103
104/// Wind UI framework synchronization.
105// Legacy WindAdvancedSync.rs for backward compatibility
106#[path = "WindAdvancedSync.rs"]
107pub mod WindAdvancedSync;
108
109// --- Legacy Sub-modules ---
110
111/// Legacy Wind Air Commands.
112pub mod WindAirCommands;
113
114/// Legacy Wind Service Adapters.
115pub mod WindServiceAdapters;
116
117/// Tag-filtered development logging (LAND_DEV_LOG env var).
118/// Must be declared before WindServiceHandlers so the dev_log! macro is
119/// available.
120pub mod DevLog;
121
122/// Legacy Wind Service Handlers.
123pub mod WindServiceHandlers;
124
125/// Wind Service Handler - atomic domain modules split from WindServiceHandlers.
126pub mod WindServiceHandler;
127
128// --- Legacy Subdirectories ---
129
130/// Legacy Enhanced subdirectory.
131pub mod Enhanced;
132
133/// Legacy Permission subdirectory.
134pub mod Permission;
135
136// --- Re-exports for backward compatibility ---
137
138pub use Common::{ConnectionStatus, HealthStatus, MessageType, PerformanceMetrics, ServiceInfo};
139pub use Message::{ListenerCallback, SimpleConnectionStatus, TauriIPCMessage};
140pub use TauriIPCServer_Old as TauriIPCServer;
141pub use Connection::{ConnectionHandle, ConnectionManager, ConnectionStats, HealthChecker};
142pub use Encryption::{
143 MessageCompressor::MessageCompressor,
144 SecureChannel::{EncryptedMessage, SecureMessageChannel},
145};
146pub use Security::{
147 PermissionManager::{PermissionManager, SecurityContext, SecurityEvent, SecurityEventType},
148 Role::Role,
149};
150pub use AdvancedFeatures::{
151 AdvancedFeatures as AdvancedFeatures_New,
152 CachedMessage,
153 CollaborationPermissions,
154 CollaborationSession,
155 MessageCache,
156 PerformanceStats,
157 initialize_advanced_features,
158};
159pub use ConfigurationBridge as ConfigurationBridge_New;
160pub use StatusReporter as StatusReporter_New;
161pub use WindAdvancedSync as WindAdvancedSync_New;
162// --- Legacy compatibility function re-exports ---
163
164// Note: initialize_advanced_features is already exported above
165pub use StatusReporter::initialize_status_reporter;
166pub use WindAdvancedSync::initialize_wind_advanced_sync;
167
168// --- Notes on Migration ---
169
170// MIGRATION PATH TO ATOMIC STRUCTURE:
171//
172// Phase 1: ✅ Create Atomic Structure
173// - Created new atomic module directories
174// - Implemented core functionality
175// - Added comprehensive documentation
176//
177// Phase 2: 🔄 Backward Compatibility (Current)
178// - Keeping legacy files for compatibility
179// - Using #[path = "..."] to reference legacy files
180// - Gradually migrating dependent code
181//
182// Phase 3: ⏳ Migration
183// - Update dependent files to use new structure
184// - Test migration incrementally
185// - Monitor for issues
186//
187// Phase 4: ⏳ Cleanup
188// - Remove legacy files
189// - Update all documentation
190// - Final verification
191//
192// The following atomic modules are ready for migration:
193// - IPC/TauriIPCServer/ (Server.rs)
194// - IPC/Message/ (Types.rs)
195// - IPC/Connection/ (Manager.rs, Types.rs, Health.rs)
196// - IPC/Encryption/ (MessageCompressor.rs, SecureChannel.rs)
197// - IPC/Security/ (PermissionManager.rs, Role.rs, Permission.rs)
198// - IPC/AdvancedFeatures/ (Features.rs)
199// - IPC/ConfigurationBridge/ (mod.rs - placeholder)
200// - IPC/StatusReporter/ (mod.rs - placeholder)
201// - IPC/WindAdvancedSync/ (mod.rs - placeholder)