Subsystem: Application Startup Lifecycle
Detailed breakdown of how M31A initializes from process entry point to execution readiness.
Entry Point: src/main.rs
The startup sequence follows 10 discrete phases:
- Panic Hook Installation (
install_panic_hook): Restores standard terminal modes (disables raw mode, leaves alternate screen, restores cursor) if an unexpected panic occurs. - Channel-Aware
--versionCheck: Intercepts-V/--versionbefore heavy runtime initialization, returning compile-time channel identity. - CLI Parsing: Clap parses arguments into
Cliand extractsCliOverrides. - Storage Layout & Migration:
StorageLayout::newresolves global platform dirs and migrates any legacy project-local databases to the canonical platform path. - Configuration Resolution:
ResolvedConfiguration::builderloads configuration layers. Present-but-invalid configs trigger an immediate exit (exit(1)). - SQLite Initialization:
initialize_database(&db_path)applies all pending SQL migrations idempotently. - Broadcast Event Bus: Creates
BroadcastEventBuswith capacity 2,048. - Startup Crash Recovery:
recover_startup_crashes(&pool)checks for interrupted runs from previous sessions. - Dispatch or Interactive Cockpit:
- If subcommand specified: executes via
CliDispatcher. - If interactive terminal: checks onboarding status and launches
TuiApplication.
- If subcommand specified: executes via
- Async Runtime Assembly: TUI renders an immediate first frame while background async runtime assembly hydrations proceed smoothly.