Skip to main content

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 (collaboration, intelligent caching,
90/// performance monitoring). TODO: atomize this 648-LOC single file into a
91/// directory; for now consumers spell `IPC::AdvancedFeatures::*` directly.
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 (Trace env var).
118/// Must be declared before WindServiceHandlers so the dev_log! macro is
119/// available.
120pub mod DevLog;
121
122/// Central `sky://` emit wrapper that logs under the `sky-emit` DevLog
123/// tag. Optional drop-in for any `ApplicationHandle::emit(channel, …)`
124/// call site; existing emits keep working unchanged.
125pub mod SkyEmit;
126
127/// Shared `UriComponents` emitter. Every handler that returns a URI to the
128/// renderer must route through this module so the `$mid: 1` marshalling
129/// marker is never forgotten (without it VS Code's IPC reviver skips the
130/// field and `uri.with is not a function` cascades through the sidebar).
131pub mod UriComponents;
132
133/// Wind Service Handlers - dispatcher for every `MountainIPCInvoke` Tauri
134/// call from Wind/Output/Sky. The `mod.rs` inside is the central `match`
135/// that routes wire strings to per-domain atoms or handler files. Atoms
136/// live under `WindServiceHandlers/<Domain>/<Atom>.rs` following the
137/// one-export-per-file convention.
138///
139/// The previous `WindServiceHandler` (singular) sibling was merged here
140/// on 2026-04-23: of its 24 files, only 3 functions were live
141/// (extensions install/uninstall, nativeHost showOpenDialog) and those
142/// now live as atoms under `WindServiceHandlers/Extension/` and
143/// `WindServiceHandlers/NativeDialog/`. The remaining 21 files were
144/// dead-code duplicates of plural-side implementations.
145pub mod WindServiceHandlers;
146
147// --- Legacy Subdirectories ---
148
149/// Legacy Enhanced subdirectory.
150pub mod Enhanced;
151
152/// Legacy Permission subdirectory.
153pub mod Permission;
154
155// No `pub use` re-exports - callers spell the full path
156// (`IPC::Connection::Manager::ConnectionManager`, etc.). The legacy single-
157// file modules `TauriIPCServer_Old`, `AdvancedFeatures`, `StatusReporter`,
158// `WindAdvancedSync`, `ConfigurationBridge` remain as roots for the
159// in-progress atomic migration.
160
161// --- Notes on Migration ---
162
163// MIGRATION PATH TO ATOMIC STRUCTURE:
164//
165// Phase 1: ✅ Create Atomic Structure
166// - Created new atomic module directories
167// - Implemented core functionality
168// - Added comprehensive documentation
169//
170// Phase 2: 🔄 Backward Compatibility (Current)
171// - Keeping legacy files for compatibility
172// - Using #[path = "..."] to reference legacy files
173// - Gradually migrating dependent code
174//
175// Phase 3: ⏳ Migration
176// - Update dependent files to use new structure
177// - Test migration incrementally
178// - Monitor for issues
179//
180// Phase 4: ⏳ Cleanup
181// - Remove legacy files
182// - Update all documentation
183// - Final verification
184//
185// The following atomic modules are ready for migration:
186// - IPC/TauriIPCServer/ (Server.rs)
187// - IPC/Message/ (Types.rs)
188// - IPC/Connection/ (Manager.rs, Types.rs, Health.rs)
189// - IPC/Encryption/ (MessageCompressor.rs, SecureChannel.rs)
190// - IPC/Security/ (PermissionManager.rs, Role.rs, Permission.rs)
191// - IPC/AdvancedFeatures/ (Features.rs)
192// - IPC/ConfigurationBridge/ (mod.rs - placeholder)
193// - IPC/StatusReporter/ (mod.rs - placeholder)
194// - IPC/WindAdvancedSync/ (mod.rs - placeholder)