Skip to content

Commit 8c0dcde

Browse files
authored
Merge pull request #47 from Steake/copilot/sub-pr-44-another-one
Fix duplicate consciousness bootstrap and import organization
2 parents fb6316b + 58f622f commit 8c0dcde

File tree

2 files changed

+24
-36
lines changed

2 files changed

+24
-36
lines changed

backend/unified_server.py

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -438,9 +438,20 @@ async def initialize_core_services():
438438
# Bootstrap consciousness after initialization
439439
if hasattr(cognitive_manager, 'consciousness_engine') and cognitive_manager.consciousness_engine:
440440
try:
441-
logger.info("🌅 Bootstrapping consciousness in cognitive manager...")
442-
await cognitive_manager.consciousness_engine.bootstrap_consciousness()
443-
logger.info("✅ Consciousness engine bootstrapped successfully")
441+
ce = cognitive_manager.consciousness_engine
442+
# Check if bootstrap already completed to avoid duplicate calls
443+
bootstrap_done = False
444+
if (hasattr(ce, 'current_state') and
445+
hasattr(ce.current_state, 'phenomenal_experience') and
446+
ce.current_state.phenomenal_experience):
447+
bootstrap_done = ce.current_state.phenomenal_experience.get('bootstrap_complete', False)
448+
449+
if not bootstrap_done:
450+
logger.info("🌅 Bootstrapping consciousness in cognitive manager...")
451+
await ce.bootstrap_consciousness()
452+
logger.info("✅ Consciousness engine bootstrapped successfully")
453+
else:
454+
logger.info("🟡 Consciousness engine bootstrap already completed; skipping duplicate call.")
444455
except Exception as bootstrap_error:
445456
logger.warning(f"⚠️ Consciousness bootstrap warning (non-fatal): {bootstrap_error}")
446457

@@ -477,27 +488,9 @@ async def initialize_core_services():
477488
# Start the consciousness loop
478489
await unified_consciousness_engine.start_consciousness_loop()
479490
logger.info("🧠 Unified consciousness loop started")
480-
481-
# Bootstrap consciousness from unconscious state to operational awareness
482-
logger.info("🌅 Initiating consciousness bootstrap sequence...")
483-
try:
484-
bootstrap_state = await unified_consciousness_engine.consciousness_state_injector.capture_current_state()
485-
# Update unified consciousness state from bootstrap
486-
if hasattr(bootstrap_state, 'awareness_level') and bootstrap_state.awareness_level < 0.5:
487-
# System needs bootstrapping
488-
logger.info("Consciousness needs bootstrap - initiating awakening sequence")
489-
# Note: UnifiedConsciousnessEngine doesn't have bootstrap_consciousness directly
490-
# We'll need to check if cognitive_manager has it
491-
if cognitive_manager and hasattr(cognitive_manager, 'consciousness_engine'):
492-
await cognitive_manager.consciousness_engine.bootstrap_consciousness()
493-
logger.info("✅ Consciousness bootstrapped successfully via cognitive manager")
494-
else:
495-
logger.warning("⚠️ Cognitive manager not available for bootstrap, consciousness will self-organize")
496-
else:
497-
logger.info(f"Consciousness already active (level: {bootstrap_state.awareness_level:.2f})")
498-
except Exception as bootstrap_error:
499-
logger.warning(f"⚠️ Consciousness bootstrap encountered issue (non-fatal): {bootstrap_error}")
500-
logger.info("Consciousness will self-organize through normal operation")
491+
492+
# Note: Consciousness bootstrap is handled in cognitive_manager initialization above
493+
# to avoid duplicate bootstrap calls
501494

502495
except Exception as e:
503496
logger.error(f"❌ Failed to initialize unified consciousness engine: {e}")

demo_consciousness.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
import time
1717
from datetime import datetime
1818

19+
# Backend imports - moved to top for better organization
20+
from backend.core.consciousness_engine import ConsciousnessEngine
21+
from backend.core.unified_consciousness_engine import UnifiedConsciousnessEngine
22+
from backend.goal_management_system import GoalManagementSystem
23+
from backend.core.metacognitive_monitor import MetaCognitiveMonitor
24+
from backend.core.knowledge_graph_evolution import KnowledgeGraphEvolution
25+
1926
# Add project to path
2027
sys.path.insert(0, '/workspace/GodelOS')
2128

@@ -32,8 +39,6 @@ async def demo_1_bootstrap():
3239
print("└" + "─" * 78 + "┘")
3340
print()
3441

35-
from backend.core.consciousness_engine import ConsciousnessEngine
36-
3742
print("Creating consciousness engine...")
3843
engine = ConsciousnessEngine()
3944

@@ -72,8 +77,6 @@ async def demo_2_real_computation():
7277
print("└" + "─" * 78 + "┘")
7378
print()
7479

75-
from backend.core.unified_consciousness_engine import UnifiedConsciousnessEngine
76-
7780
print("Creating unified consciousness engine...")
7881
engine = UnifiedConsciousnessEngine()
7982
await engine.initialize_components()
@@ -108,8 +111,6 @@ async def demo_3_conscious_query():
108111
print("└" + "─" * 78 + "┘")
109112
print()
110113

111-
from backend.core.unified_consciousness_engine import UnifiedConsciousnessEngine
112-
113114
print("Setting up consciousness engine for query processing...")
114115
engine = UnifiedConsciousnessEngine()
115116
await engine.initialize_components()
@@ -155,8 +156,6 @@ async def demo_4_goals_phenomenal():
155156
print("└" + "─" * 78 + "┘")
156157
print()
157158

158-
from backend.goal_management_system import GoalManagementSystem
159-
160159
print("Creating goal management system...")
161160
goal_system = GoalManagementSystem()
162161

@@ -206,8 +205,6 @@ async def demo_5_metacognition_depth():
206205
print("└" + "─" * 78 + "┘")
207206
print()
208207

209-
from backend.core.metacognitive_monitor import MetaCognitiveMonitor
210-
211208
print("Creating metacognitive monitor...")
212209
monitor = MetaCognitiveMonitor()
213210

@@ -248,8 +245,6 @@ async def demo_6_knowledge_graph_insights():
248245
print("└" + "─" * 78 + "┘")
249246
print()
250247

251-
from backend.core.knowledge_graph_evolution import KnowledgeGraphEvolution
252-
253248
print("Creating knowledge graph...")
254249
kg = KnowledgeGraphEvolution()
255250

0 commit comments

Comments
 (0)