/ run_mission_control.py
run_mission_control.py
1 #!/usr/bin/env python3 2 """ 3 Run Mission Control - Sovereign OS Cross-Thread Synthesis 4 5 Usage: 6 python run_mission_control.py 7 8 # Or with custom sessions dir: 9 python run_mission_control.py --sessions /path/to/sessions 10 11 # With debug logging: 12 python run_mission_control.py --debug 13 14 Mission Control will: 15 1. Watch all LIVE-COMPRESSION-*.md files 16 2. Detect resonance across threads 17 3. Write RESONANCE-ALERTS when patterns detected 18 4. Produce DAILY-SYNTHESIS.md every 5 FO checkpoints 19 5. Update LIVE-GRAPH.md in real-time 20 """ 21 22 import sys 23 import os 24 import argparse 25 import logging 26 from pathlib import Path 27 28 # Ensure user site-packages is in path (for watchdog) 29 user_site = Path.home() / "Library/Python/3.9/lib/python/site-packages" 30 if user_site.exists() and str(user_site) not in sys.path: 31 sys.path.insert(0, str(user_site)) 32 33 # Add core to path 34 sys.path.insert(0, str(Path(__file__).parent)) 35 36 from core.metacog.mission_control import MissionControl, MissionControlConfig 37 from core.graph.live_render import LiveGraphRenderer 38 from core.graph.edge_drawer import EdgeDrawer 39 40 41 def setup_logging(debug: bool = False) -> None: 42 """Configure logging.""" 43 level = logging.DEBUG if debug else logging.INFO 44 45 logging.basicConfig( 46 level=level, 47 format="%(asctime)s [%(levelname)s] %(name)s: %(message)s", 48 datefmt="%H:%M:%S" 49 ) 50 51 52 def print_banner() -> None: 53 """Print startup banner.""" 54 print(""" 55 ╔══════════════════════════════════════════════════════════════════════════╗ 56 ║ ║ 57 ║ ███╗ ███╗██╗███████╗███████╗██╗ ██████╗ ███╗ ██╗ ║ 58 ║ ████╗ ████║██║██╔════╝██╔════╝██║██╔═══██╗████╗ ██║ ║ 59 ║ ██╔████╔██║██║███████╗███████╗██║██║ ██║██╔██╗ ██║ ║ 60 ║ ██║╚██╔╝██║██║╚════██║╚════██║██║██║ ██║██║╚██╗██║ ║ 61 ║ ██║ ╚═╝ ██║██║███████║███████║██║╚██████╔╝██║ ╚████║ ║ 62 ║ ╚═╝ ╚═╝╚═╝╚══════╝╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ║ 63 ║ ║ 64 ║ ██████╗ ██████╗ ███╗ ██╗████████╗██████╗ ██████╗ ██╗ ║ 65 ║ ██╔════╝██╔═══██╗████╗ ██║╚══██╔══╝██╔══██╗██╔═══██╗██║ ║ 66 ║ ██║ ██║ ██║██╔██╗ ██║ ██║ ██████╔╝██║ ██║██║ ║ 67 ║ ██║ ██║ ██║██║╚██╗██║ ██║ ██╔══██╗██║ ██║██║ ║ 68 ║ ╚██████╗╚██████╔╝██║ ╚████║ ██║ ██║ ██║╚██████╔╝███████╗ ║ 69 ║ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝ ║ 70 ║ ║ 71 ║ SOVEREIGN OS - Cross-Thread Synthesis ║ 72 ║ ║ 73 ╚══════════════════════════════════════════════════════════════════════════╝ 74 """) 75 76 77 def main(): 78 parser = argparse.ArgumentParser( 79 description="Mission Control - Sovereign OS Cross-Thread Synthesis" 80 ) 81 parser.add_argument( 82 "--sessions", 83 type=Path, 84 default=Path(__file__).parent / "sessions", 85 help="Path to sessions directory (default: ./sessions)" 86 ) 87 parser.add_argument( 88 "--interval", 89 type=int, 90 default=5, 91 help="FO checkpoints between synthesis (default: 5)" 92 ) 93 parser.add_argument( 94 "--debug", 95 action="store_true", 96 help="Enable debug logging" 97 ) 98 parser.add_argument( 99 "--no-banner", 100 action="store_true", 101 help="Skip startup banner" 102 ) 103 104 args = parser.parse_args() 105 106 # Setup 107 setup_logging(args.debug) 108 109 if not args.no_banner: 110 print_banner() 111 112 # Validate sessions dir 113 if not args.sessions.exists(): 114 print(f"Error: Sessions directory not found: {args.sessions}") 115 print("Create it or specify a different path with --sessions") 116 sys.exit(1) 117 118 # Create config 119 config = MissionControlConfig( 120 sessions_dir=args.sessions, 121 synthesis_interval_checkpoints=args.interval 122 ) 123 124 print(f"Sessions directory: {config.sessions_dir}") 125 print(f"Synthesis interval: every {config.synthesis_interval_checkpoints} FO checkpoints") 126 print(f"Daily synthesis at: {config.daily_synthesis_time}") 127 print() 128 print("Watching for LIVE-COMPRESSION-*.md changes...") 129 print("Press Ctrl+C to stop") 130 print() 131 132 # Run Mission Control 133 mc = MissionControl(config) 134 135 try: 136 mc.run_forever() 137 except KeyboardInterrupt: 138 print("\nShutting down Mission Control...") 139 except Exception as e: 140 logging.error(f"Mission Control error: {e}") 141 raise 142 143 144 if __name__ == "__main__": 145 main()