Mountain/RunTime/Shutdown/
mod.rs

1//! # Shutdown (RunTime)
2//!
3//! ## RESPONSIBILITIES
4//!
5//! Service shutdown and lifecycle management for graceful application
6//! termination. Coordinates cleanup of all application services with error
7//! recovery.
8//!
9//! Provides comprehensive shutdown operations through impl blocks on
10//! ApplicationRunTime:
11//! - Main shutdown orchestration
12//! - Cocoon sidecar shutdown with retry
13//! - Terminal disposal
14//! - Application state persistence
15//! - Pending operation cleanup
16//!
17//! ## ARCHITECTURAL ROLE
18//!
19//! The lifecycle manager in Mountain's architecture that ensures clean
20//! application termination and state persistence.
21//!
22//! ## KEY COMPONENTS
23//!
24//! - **Shutdown**: Core shutdown functions implemented on ApplicationRunTime
25//!
26//! ## ERROR HANDLING
27//!
28//! All shutdown operations use error recovery to continue cleanup even when
29//! individual services fail. Errors are collected and reported without
30//! crashing. Multi-attempt retry for critical operations like Cocoon shutdown.
31//!
32//! ## LOGGING
33//!
34//! Uses log crate with appropriate severity levels:
35//! - `info`: Shutdown initiation and completion
36//! - `debug`: Detailed operation steps
37//! - `warn`: Recoverable errors during shutdown
38//! - `error`: Failed operations (but continues shutdown)
39//!
40//! ## PERFORMANCE CONSIDERATIONS
41//!
42//! - Shutdown operations are optimized to complete quickly
43//! - Parallel cleanup where safe (terminal disposal)
44//! - Minimal blocking during state persistence
45//! - Uses timeout recovery to prevent hanging
46//!
47//! ## TODO
48//!
49//! Medium Priority:
50//! - [ ] Add shutdown progress reporting
51//! - [ ] Implement shutdown timeout per service
52//! - [ ] Add shutdown cancellation support
53//!
54//! Low Priority:
55//! - [ ] Add shutdown metrics collection
56//! - [ ] Implement service dependency ordering
57//! - [ ] Add shutdown rollback for partial failures
58
59// --- Sub-modules ---
60
61/// Shutdown orchestration and service cleanup implemented on
62/// ApplicationRunTime.
63pub mod Shutdown;
64
65// Note: The shutdown functions (Shutdown, ShutdownWithRecovery,
66// ShutdownCocoonWithRetry, DisposeTerminalsSafely, SaveApplicationState,
67// FlushPendingOperations) are now implemented as methods on the
68// ApplicationRunTime struct in Shutdown.rs