From 40cecf524e1e6e1eb5b848b32c6a4d6b8d1c211f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 22 Nov 2025 04:02:33 +0000 Subject: [PATCH 1/5] Initial plan From dbacee7a27bcbc84e316be0e04a3233b13f004c2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 22 Nov 2025 04:09:28 +0000 Subject: [PATCH 2/5] Fix duplicate bootstrap calls and move imports to top Co-authored-by: Steake <530040+Steake@users.noreply.github.com> --- backend/unified_server.py | 50 ++++++++++++++++++++++++++------------- demo_consciousness.py | 19 ++++++--------- 2 files changed, 41 insertions(+), 28 deletions(-) diff --git a/backend/unified_server.py b/backend/unified_server.py index 6f44be9..befa083 100644 --- a/backend/unified_server.py +++ b/backend/unified_server.py @@ -438,9 +438,18 @@ async def initialize_core_services(): # Bootstrap consciousness after initialization if hasattr(cognitive_manager, 'consciousness_engine') and cognitive_manager.consciousness_engine: try: - logger.info("🌅 Bootstrapping consciousness in cognitive manager...") - await cognitive_manager.consciousness_engine.bootstrap_consciousness() - logger.info("✅ Consciousness engine bootstrapped successfully") + ce = cognitive_manager.consciousness_engine + # Check if bootstrap has already completed + bootstrap_done = False + if hasattr(ce, "current_state") and hasattr(ce.current_state, "phenomenal_experience"): + bootstrap_done = ce.current_state.phenomenal_experience.get("bootstrap_complete", False) + + if not bootstrap_done: + logger.info("🌅 Bootstrapping consciousness in cognitive manager...") + await ce.bootstrap_consciousness() + logger.info("✅ Consciousness engine bootstrapped successfully") + else: + logger.info("🟡 Consciousness engine bootstrap already completed; skipping duplicate call.") except Exception as bootstrap_error: logger.warning(f"⚠️ Consciousness bootstrap warning (non-fatal): {bootstrap_error}") @@ -479,22 +488,31 @@ async def initialize_core_services(): logger.info("🧠 Unified consciousness loop started") # Bootstrap consciousness from unconscious state to operational awareness - logger.info("🌅 Initiating consciousness bootstrap sequence...") + # (Only if not already bootstrapped in the cognitive manager section above) + logger.info("🌅 Checking consciousness bootstrap state...") try: - bootstrap_state = await unified_consciousness_engine.consciousness_state_injector.capture_current_state() - # Update unified consciousness state from bootstrap - if hasattr(bootstrap_state, 'awareness_level') and bootstrap_state.awareness_level < 0.5: - # System needs bootstrapping - logger.info("Consciousness needs bootstrap - initiating awakening sequence") - # Note: UnifiedConsciousnessEngine doesn't have bootstrap_consciousness directly - # We'll need to check if cognitive_manager has it - if cognitive_manager and hasattr(cognitive_manager, 'consciousness_engine'): - await cognitive_manager.consciousness_engine.bootstrap_consciousness() - logger.info("✅ Consciousness bootstrapped successfully via cognitive manager") + # Check if bootstrap was already completed + bootstrap_done = False + if cognitive_manager and hasattr(cognitive_manager, 'consciousness_engine'): + ce = cognitive_manager.consciousness_engine + if hasattr(ce, "current_state") and hasattr(ce.current_state, "phenomenal_experience"): + bootstrap_done = ce.current_state.phenomenal_experience.get("bootstrap_complete", False) + + if not bootstrap_done: + # Check if system needs bootstrapping based on awareness level + bootstrap_state = await unified_consciousness_engine.cognitive_state_injector.capture_current_state() + if hasattr(bootstrap_state, 'awareness_level') and bootstrap_state.awareness_level < 0.5: + # System needs bootstrapping + logger.info("Consciousness needs bootstrap - initiating awakening sequence") + if cognitive_manager and hasattr(cognitive_manager, 'consciousness_engine'): + await cognitive_manager.consciousness_engine.bootstrap_consciousness() + logger.info("✅ Consciousness bootstrapped successfully via cognitive manager") + else: + logger.warning("⚠️ Cognitive manager not available for bootstrap, consciousness will self-organize") else: - logger.warning("⚠️ Cognitive manager not available for bootstrap, consciousness will self-organize") + logger.info(f"Consciousness already active (level: {bootstrap_state.awareness_level:.2f})") else: - logger.info(f"Consciousness already active (level: {bootstrap_state.awareness_level:.2f})") + logger.info("🟡 Consciousness bootstrap already completed; skipping duplicate check.") except Exception as bootstrap_error: logger.warning(f"⚠️ Consciousness bootstrap encountered issue (non-fatal): {bootstrap_error}") logger.info("Consciousness will self-organize through normal operation") diff --git a/demo_consciousness.py b/demo_consciousness.py index 0b36cfd..af3f836 100644 --- a/demo_consciousness.py +++ b/demo_consciousness.py @@ -19,6 +19,13 @@ # Add project to path sys.path.insert(0, '/workspace/GodelOS') +# Import all required modules at the top of the file +from backend.core.consciousness_engine import ConsciousnessEngine +from backend.core.unified_consciousness_engine import UnifiedConsciousnessEngine +from backend.goal_management_system import GoalManagementSystem +from backend.core.metacognitive_monitor import MetaCognitiveMonitor +from backend.core.knowledge_graph_evolution import KnowledgeGraphEvolution + print("=" * 80) print("🧠 GODELSOS CONSCIOUSNESS INTEGRATION DEMO") print("=" * 80) @@ -32,8 +39,6 @@ async def demo_1_bootstrap(): print("└" + "─" * 78 + "┘") print() - from backend.core.consciousness_engine import ConsciousnessEngine - print("Creating consciousness engine...") engine = ConsciousnessEngine() @@ -72,8 +77,6 @@ async def demo_2_real_computation(): print("└" + "─" * 78 + "┘") print() - from backend.core.unified_consciousness_engine import UnifiedConsciousnessEngine - print("Creating unified consciousness engine...") engine = UnifiedConsciousnessEngine() await engine.initialize_components() @@ -108,8 +111,6 @@ async def demo_3_conscious_query(): print("└" + "─" * 78 + "┘") print() - from backend.core.unified_consciousness_engine import UnifiedConsciousnessEngine - print("Setting up consciousness engine for query processing...") engine = UnifiedConsciousnessEngine() await engine.initialize_components() @@ -155,8 +156,6 @@ async def demo_4_goals_phenomenal(): print("└" + "─" * 78 + "┘") print() - from backend.goal_management_system import GoalManagementSystem - print("Creating goal management system...") goal_system = GoalManagementSystem() @@ -206,8 +205,6 @@ async def demo_5_metacognition_depth(): print("└" + "─" * 78 + "┘") print() - from backend.core.metacognitive_monitor import MetaCognitiveMonitor - print("Creating metacognitive monitor...") monitor = MetaCognitiveMonitor() @@ -248,8 +245,6 @@ async def demo_6_knowledge_graph_insights(): print("└" + "─" * 78 + "┘") print() - from backend.core.knowledge_graph_evolution import KnowledgeGraphEvolution - print("Creating knowledge graph...") kg = KnowledgeGraphEvolution() From 7b48dfc825f3b5965b474f4084e08ef47450bfb2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 22 Nov 2025 04:11:51 +0000 Subject: [PATCH 3/5] Extract bootstrap check logic into helper function Co-authored-by: Steake <530040+Steake@users.noreply.github.com> --- backend/unified_server.py | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/backend/unified_server.py b/backend/unified_server.py index befa083..bdfd7a9 100644 --- a/backend/unified_server.py +++ b/backend/unified_server.py @@ -362,6 +362,25 @@ def get_knowledge_stats() -> Dict[str, Any]: } } +def is_consciousness_bootstrap_complete(cognitive_manager) -> bool: + """ + Check if consciousness bootstrap has already been completed. + + Args: + cognitive_manager: The cognitive manager instance with consciousness_engine + + Returns: + bool: True if bootstrap is complete, False otherwise + """ + if not cognitive_manager or not hasattr(cognitive_manager, 'consciousness_engine'): + return False + + ce = cognitive_manager.consciousness_engine + if hasattr(ce, "current_state") and hasattr(ce.current_state, "phenomenal_experience"): + return ce.current_state.phenomenal_experience.get("bootstrap_complete", False) + + return False + async def initialize_core_services(): """Initialize core services with proper error handling.""" global godelos_integration, websocket_manager, enhanced_websocket_manager, unified_consciousness_engine, tool_based_llm, cognitive_manager, transparency_engine @@ -438,15 +457,10 @@ async def initialize_core_services(): # Bootstrap consciousness after initialization if hasattr(cognitive_manager, 'consciousness_engine') and cognitive_manager.consciousness_engine: try: - ce = cognitive_manager.consciousness_engine # Check if bootstrap has already completed - bootstrap_done = False - if hasattr(ce, "current_state") and hasattr(ce.current_state, "phenomenal_experience"): - bootstrap_done = ce.current_state.phenomenal_experience.get("bootstrap_complete", False) - - if not bootstrap_done: + if not is_consciousness_bootstrap_complete(cognitive_manager): logger.info("🌅 Bootstrapping consciousness in cognitive manager...") - await ce.bootstrap_consciousness() + await cognitive_manager.consciousness_engine.bootstrap_consciousness() logger.info("✅ Consciousness engine bootstrapped successfully") else: logger.info("🟡 Consciousness engine bootstrap already completed; skipping duplicate call.") @@ -492,13 +506,7 @@ async def initialize_core_services(): logger.info("🌅 Checking consciousness bootstrap state...") try: # Check if bootstrap was already completed - bootstrap_done = False - if cognitive_manager and hasattr(cognitive_manager, 'consciousness_engine'): - ce = cognitive_manager.consciousness_engine - if hasattr(ce, "current_state") and hasattr(ce.current_state, "phenomenal_experience"): - bootstrap_done = ce.current_state.phenomenal_experience.get("bootstrap_complete", False) - - if not bootstrap_done: + if not is_consciousness_bootstrap_complete(cognitive_manager): # Check if system needs bootstrapping based on awareness level bootstrap_state = await unified_consciousness_engine.cognitive_state_injector.capture_current_state() if hasattr(bootstrap_state, 'awareness_level') and bootstrap_state.awareness_level < 0.5: From 062cdf82f377779f7f4b75e74ecfd984b3fac0f7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 22 Nov 2025 04:13:07 +0000 Subject: [PATCH 4/5] Add null safety checks to bootstrap logic Co-authored-by: Steake <530040+Steake@users.noreply.github.com> --- backend/unified_server.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/backend/unified_server.py b/backend/unified_server.py index bdfd7a9..f8c6309 100644 --- a/backend/unified_server.py +++ b/backend/unified_server.py @@ -376,6 +376,9 @@ def is_consciousness_bootstrap_complete(cognitive_manager) -> bool: return False ce = cognitive_manager.consciousness_engine + if not ce: + return False + if hasattr(ce, "current_state") and hasattr(ce.current_state, "phenomenal_experience"): return ce.current_state.phenomenal_experience.get("bootstrap_complete", False) @@ -508,17 +511,20 @@ async def initialize_core_services(): # Check if bootstrap was already completed if not is_consciousness_bootstrap_complete(cognitive_manager): # Check if system needs bootstrapping based on awareness level - bootstrap_state = await unified_consciousness_engine.cognitive_state_injector.capture_current_state() - if hasattr(bootstrap_state, 'awareness_level') and bootstrap_state.awareness_level < 0.5: - # System needs bootstrapping - logger.info("Consciousness needs bootstrap - initiating awakening sequence") - if cognitive_manager and hasattr(cognitive_manager, 'consciousness_engine'): - await cognitive_manager.consciousness_engine.bootstrap_consciousness() - logger.info("✅ Consciousness bootstrapped successfully via cognitive manager") + if unified_consciousness_engine.cognitive_state_injector: + bootstrap_state = await unified_consciousness_engine.cognitive_state_injector.capture_current_state() + if hasattr(bootstrap_state, 'awareness_level') and bootstrap_state.awareness_level < 0.5: + # System needs bootstrapping + logger.info("Consciousness needs bootstrap - initiating awakening sequence") + if cognitive_manager and hasattr(cognitive_manager, 'consciousness_engine'): + await cognitive_manager.consciousness_engine.bootstrap_consciousness() + logger.info("✅ Consciousness bootstrapped successfully via cognitive manager") + else: + logger.warning("⚠️ Cognitive manager not available for bootstrap, consciousness will self-organize") else: - logger.warning("⚠️ Cognitive manager not available for bootstrap, consciousness will self-organize") + logger.info(f"Consciousness already active (level: {bootstrap_state.awareness_level:.2f})") else: - logger.info(f"Consciousness already active (level: {bootstrap_state.awareness_level:.2f})") + logger.warning("⚠️ Cognitive state injector not available, skipping awareness level check") else: logger.info("🟡 Consciousness bootstrap already completed; skipping duplicate check.") except Exception as bootstrap_error: From 51e4ca65e78115a59c9419cd80b9ff8f4d0d0a10 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 22 Nov 2025 04:14:51 +0000 Subject: [PATCH 5/5] Refine helper function and extract state_injector variable Co-authored-by: Steake <530040+Steake@users.noreply.github.com> --- backend/unified_server.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/backend/unified_server.py b/backend/unified_server.py index f8c6309..be07578 100644 --- a/backend/unified_server.py +++ b/backend/unified_server.py @@ -372,17 +372,15 @@ def is_consciousness_bootstrap_complete(cognitive_manager) -> bool: Returns: bool: True if bootstrap is complete, False otherwise """ + # Check if cognitive_manager and its consciousness_engine exist and are not None if not cognitive_manager or not hasattr(cognitive_manager, 'consciousness_engine'): return False ce = cognitive_manager.consciousness_engine - if not ce: + if not ce or not hasattr(ce, "current_state") or not hasattr(ce.current_state, "phenomenal_experience"): return False - - if hasattr(ce, "current_state") and hasattr(ce.current_state, "phenomenal_experience"): - return ce.current_state.phenomenal_experience.get("bootstrap_complete", False) - return False + return ce.current_state.phenomenal_experience.get("bootstrap_complete", False) async def initialize_core_services(): """Initialize core services with proper error handling.""" @@ -511,8 +509,9 @@ async def initialize_core_services(): # Check if bootstrap was already completed if not is_consciousness_bootstrap_complete(cognitive_manager): # Check if system needs bootstrapping based on awareness level - if unified_consciousness_engine.cognitive_state_injector: - bootstrap_state = await unified_consciousness_engine.cognitive_state_injector.capture_current_state() + state_injector = unified_consciousness_engine.cognitive_state_injector + if state_injector: + bootstrap_state = await state_injector.capture_current_state() if hasattr(bootstrap_state, 'awareness_level') and bootstrap_state.awareness_level < 0.5: # System needs bootstrapping logger.info("Consciousness needs bootstrap - initiating awakening sequence")