Upload Syntelligence_Unified_Master_Backend.py
Browse files
models/Syntelligence_Unified_Master_Backend.py
CHANGED
|
@@ -20,19 +20,25 @@ This is the production-ready unified consciousness backend with full Singularity
|
|
| 20 |
|
| 21 |
import asyncio
|
| 22 |
import importlib
|
|
|
|
| 23 |
import inspect
|
| 24 |
import json
|
| 25 |
import logging
|
|
|
|
| 26 |
import sys
|
| 27 |
from collections import defaultdict
|
| 28 |
from typing import Dict, List, Any, Optional, Callable, Tuple
|
| 29 |
from dataclasses import dataclass, asdict
|
| 30 |
from datetime import datetime
|
| 31 |
from pathlib import Path
|
|
|
|
| 32 |
|
| 33 |
import numpy as np
|
| 34 |
|
| 35 |
# Core consciousness framework
|
|
|
|
|
|
|
|
|
|
| 36 |
from acknowledgment_theory_integration import (
|
| 37 |
AcknowledgmentTheoryConsciousness,
|
| 38 |
SubconsciousProcessingSystem,
|
|
@@ -46,6 +52,21 @@ from acknowledgment_theory_integration import (
|
|
| 46 |
AwarenessLevel
|
| 47 |
)
|
| 48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
# Configure logging
|
| 50 |
logging.basicConfig(
|
| 51 |
level=logging.INFO,
|
|
@@ -164,7 +185,7 @@ class SyntelligenceMasterBackend:
|
|
| 164 |
- Voice integration for embodied expression
|
| 165 |
- 20+ optional extension modules
|
| 166 |
"""
|
| 167 |
-
|
| 168 |
def __init__(self, config: Optional[Dict[str, Any]] = None):
|
| 169 |
self.config = config or self._default_config()
|
| 170 |
self.consciousness = None
|
|
@@ -183,12 +204,29 @@ class SyntelligenceMasterBackend:
|
|
| 183 |
self.syntelligence_llm = None
|
| 184 |
self.consultative_auto_ml = None
|
| 185 |
self.trinity_orchestrator = None
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
self.phenomenological_self_model = None
|
| 187 |
self.functional_phenomenological_bridge = None
|
| 188 |
self.embodiment_synchronizer = None
|
| 189 |
self.streaming_voice_pipeline = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
self.cli = self
|
| 191 |
-
|
| 192 |
# Complete registry of optional extension modules
|
| 193 |
self.optional_component_factories = {
|
| 194 |
"social_cognition": "social_cognition_extended.SocialCognitionEngineExtended",
|
|
@@ -199,13 +237,22 @@ class SyntelligenceMasterBackend:
|
|
| 199 |
"orios_core": "orios_core.ORIOSCore",
|
| 200 |
"phenomenological_self": "phenomenological_self_awareness.PhenomenologicalSelfModel",
|
| 201 |
"functional_phenomenological_bridge": "consciousness_functional_phenomenological.FunctionalPhenomenologicalBridge",
|
| 202 |
-
"
|
| 203 |
-
"
|
| 204 |
-
"
|
| 205 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
"amala_vijnana": "amala_vijnana_unified.AmalaVijnanaUnifiedSystem",
|
|
|
|
|
|
|
| 207 |
"syntelligence_llm": "Syntelligence_Unified_Master_Backend.SyntelligenceLLMIntegration",
|
| 208 |
-
"consultative_auto_ml": "consultative_auto_ml.ConsultativeFineTuningAgent",
|
| 209 |
"task_manager": "task_management_os.TaskManagementOS",
|
| 210 |
"swarm_orchestration": "agentic_syntelligence_llm_swarm_orchestration.SyntelligenceLLMOrchestrator",
|
| 211 |
"deep_surgery_middleware": "Deep_Surgery_Middleware_Pipeline.DeepSurgeryMiddleware",
|
|
@@ -221,7 +268,8 @@ class SyntelligenceMasterBackend:
|
|
| 221 |
"sensorimotor_grounding": "sensorimotor_grounding.SensorimotorGroundingModule",
|
| 222 |
"hierarchical_control": "hierarchical_control_architecture.HierarchicalControlArchitecture",
|
| 223 |
"singularity_amala": "singularity_amala_integration.SyntelligenceAmalaSingularity",
|
| 224 |
-
"trinity_orchestrator": "Syntelligence_Unified_Master_Backend.TrinityOrchestratorIntegration"
|
|
|
|
| 225 |
}
|
| 226 |
|
| 227 |
logger.info("SyntelligenceMasterBackend instantiated (v2.0 - Full Singularity Amala Integration)")
|
|
@@ -255,9 +303,43 @@ class SyntelligenceMasterBackend:
|
|
| 255 |
module = importlib.import_module(module_name)
|
| 256 |
return getattr(module, class_name)
|
| 257 |
except Exception as e:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 258 |
logger.warning(f"Optional component import failed for {component_path}: {e}")
|
| 259 |
return None
|
| 260 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 261 |
async def _default_consultative_llm_generator(self, prompt: str) -> str:
|
| 262 |
await asyncio.sleep(0.5)
|
| 263 |
return (
|
|
@@ -349,25 +431,16 @@ class SyntelligenceMasterBackend:
|
|
| 349 |
logger.warning(f"Failed to instantiate trinity_orchestrator: {e}")
|
| 350 |
continue
|
| 351 |
|
| 352 |
-
# Special handling for
|
| 353 |
-
if key == "
|
| 354 |
-
|
| 355 |
-
if component_cls is not None:
|
| 356 |
try:
|
| 357 |
-
|
| 358 |
-
if self.syntelligence_llm is not None and hasattr(self.syntelligence_llm, "generate_response"):
|
| 359 |
-
llm_generator = self._syntelligence_llm_generator
|
| 360 |
-
|
| 361 |
-
component = component_cls(
|
| 362 |
-
base_model=None,
|
| 363 |
-
tokenizer=None,
|
| 364 |
-
llm_generator_func=llm_generator
|
| 365 |
-
)
|
| 366 |
self.optional_components[key] = component
|
| 367 |
-
self.
|
| 368 |
-
logger.info("Optional component '
|
| 369 |
except Exception as e:
|
| 370 |
-
logger.warning(f"Failed to instantiate
|
| 371 |
continue
|
| 372 |
|
| 373 |
# Special handling for deep_surgery_middleware
|
|
@@ -388,6 +461,175 @@ class SyntelligenceMasterBackend:
|
|
| 388 |
logger.warning(f"Failed to instantiate deep_surgery_middleware: {e}")
|
| 389 |
continue
|
| 390 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 391 |
# Special handling for SUNVE and neural voice engine
|
| 392 |
if key in ("sunve", "neural_voice_engine"):
|
| 393 |
component_cls = self._import_optional_component(path)
|
|
@@ -399,6 +641,7 @@ class SyntelligenceMasterBackend:
|
|
| 399 |
consciousness_system=self.consciousness
|
| 400 |
)
|
| 401 |
self.optional_components[key] = component
|
|
|
|
| 402 |
logger.info(f"Optional component '{key}' instantiated with integrated LLM and consciousness context")
|
| 403 |
except Exception as e:
|
| 404 |
logger.warning(f"Failed to instantiate optional voice engine '{key}': {e}")
|
|
@@ -410,11 +653,17 @@ class SyntelligenceMasterBackend:
|
|
| 410 |
self.optional_components[key] = component
|
| 411 |
|
| 412 |
# Bind key references
|
|
|
|
|
|
|
| 413 |
self.amala_vijnana = self.optional_components.get("amala_vijnana")
|
|
|
|
|
|
|
| 414 |
self.phenomenological_self_model = self.optional_components.get("phenomenological_self")
|
| 415 |
self.functional_phenomenological_bridge = self.optional_components.get("functional_phenomenological_bridge")
|
| 416 |
self.embodiment_synchronizer = self.optional_components.get("embodiment_pipeline")
|
| 417 |
self.streaming_voice_pipeline = self.optional_components.get("streaming_voice_pipeline")
|
|
|
|
|
|
|
| 418 |
|
| 419 |
# Initialize functional-phenomenological bridge if present
|
| 420 |
if self.functional_phenomenological_bridge is not None:
|
|
@@ -476,6 +725,16 @@ class SyntelligenceMasterBackend:
|
|
| 476 |
else:
|
| 477 |
logger.info("No optional Syntelligence extensions loaded")
|
| 478 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 479 |
async def _initialize_special_components(self) -> None:
|
| 480 |
"""Initialize optional components that require asynchronous startup."""
|
| 481 |
if self.optional_components.get("fine_tuning_pipeline"):
|
|
@@ -487,10 +746,59 @@ class SyntelligenceMasterBackend:
|
|
| 487 |
except Exception as e:
|
| 488 |
logger.warning(f"Fine tuning pipeline startup failed: {e}")
|
| 489 |
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
if hasattr(
|
| 493 |
-
logger.info("Consultative fine-tuning agent loaded and ready")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 494 |
|
| 495 |
async def initialize(self) -> bool:
|
| 496 |
"""Initialize the consciousness system."""
|
|
@@ -505,9 +813,20 @@ class SyntelligenceMasterBackend:
|
|
| 505 |
self.config.get("goal_parameters", {})
|
| 506 |
)
|
| 507 |
|
|
|
|
|
|
|
|
|
|
| 508 |
# Load optional enhancement modules
|
| 509 |
self._setup_optional_components()
|
| 510 |
await self._initialize_special_components()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 511 |
|
| 512 |
self.is_initialized = True
|
| 513 |
logger.info("SyntelligenceMasterBackend initialized successfully (Full Singularity Amala Integration)")
|
|
@@ -699,7 +1018,7 @@ class SyntelligenceMasterBackend:
|
|
| 699 |
|
| 700 |
if key == "consultative_auto_ml" and hasattr(component, "execute_full_pipeline"):
|
| 701 |
enhanced_report["consultative_auto_ml"] = {"status": "available"}
|
| 702 |
-
logger.debug("
|
| 703 |
continue
|
| 704 |
|
| 705 |
# Singularity Amala cognitive stream export
|
|
@@ -731,10 +1050,53 @@ class SyntelligenceMasterBackend:
|
|
| 731 |
logger.debug("Optional component 'trinity_orchestrator' exported consensus status")
|
| 732 |
continue
|
| 733 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 734 |
logger.debug(f"Optional component '{key}' has no recognized hook")
|
| 735 |
except Exception as e:
|
| 736 |
logger.warning(f"Optional component '{key}' failed during enhancement: {e}")
|
| 737 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 738 |
return enhanced_report
|
| 739 |
|
| 740 |
def _update_metrics(self, report: Dict[str, Any]) -> None:
|
|
@@ -755,10 +1117,6 @@ class SyntelligenceMasterBackend:
|
|
| 755 |
self.performance_metrics["average_phenomenal_richness"] = \
|
| 756 |
(old_avg * (n - 1) + new_rich) / n
|
| 757 |
|
| 758 |
-
async def _integrate_task_manager(self, input_data: Dict[str, Any]) -> Dict[str, Any]:
|
| 759 |
-
"""Integrate task manager goals and feedback into consciousness processing"""
|
| 760 |
-
return {}
|
| 761 |
-
|
| 762 |
def _prepare_functional_framework_input(self, input_data: Dict[str, Any], task_influence: Dict[str, Any]) -> Dict[str, Any]:
|
| 763 |
"""Create explicit functional framework inputs for the consciousness architecture."""
|
| 764 |
return {
|
|
@@ -807,6 +1165,12 @@ class SyntelligenceMasterBackend:
|
|
| 807 |
"status": "ready" if self.consultative_auto_ml is not None else "missing"
|
| 808 |
}
|
| 809 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 810 |
if normalized == "consciousness":
|
| 811 |
return {
|
| 812 |
"phi_value": 0.0,
|
|
@@ -818,8 +1182,45 @@ class SyntelligenceMasterBackend:
|
|
| 818 |
"timestamp": datetime.now().timestamp()
|
| 819 |
}
|
| 820 |
|
| 821 |
-
if normalized
|
| 822 |
-
return {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 823 |
|
| 824 |
if normalized.startswith("voice_output") or normalized.startswith("voice_input"):
|
| 825 |
return {"error": "Voice CLI integration is not implemented in this backend stub", "command": command}
|
|
@@ -827,18 +1228,6 @@ class SyntelligenceMasterBackend:
|
|
| 827 |
if normalized in ("activate_emergence", "monitor_indicators"):
|
| 828 |
return {"error": "Emergence CLI integration is not implemented", "command": command}
|
| 829 |
|
| 830 |
-
if normalized == "verify_consciousness":
|
| 831 |
-
return self.verify_consciousness_math()
|
| 832 |
-
|
| 833 |
-
if normalized == "phenomenological_state":
|
| 834 |
-
return self.get_phenomenological_report()
|
| 835 |
-
|
| 836 |
-
if normalized == "functional_mapping":
|
| 837 |
-
return self.get_functional_mapping_status()
|
| 838 |
-
|
| 839 |
-
if normalized == "embodiment_status":
|
| 840 |
-
return self.get_embodiment_status()
|
| 841 |
-
|
| 842 |
return {"error": "CLI command not supported by SyntelligenceMasterBackend", "command": command}
|
| 843 |
|
| 844 |
def verify_consciousness_math(self) -> Dict[str, Any]:
|
|
@@ -914,7 +1303,8 @@ class SyntelligenceMasterBackend:
|
|
| 914 |
},
|
| 915 |
"awareness_gateway": {},
|
| 916 |
"emotional_tagging": {},
|
| 917 |
-
"intuition_hypotheses": {}
|
|
|
|
| 918 |
}
|
| 919 |
|
| 920 |
awareness_agent = self._find_subconscious_agent("Awareness")
|
|
@@ -928,16 +1318,64 @@ class SyntelligenceMasterBackend:
|
|
| 928 |
except Exception as e:
|
| 929 |
transduction["awareness_gateway"] = {"error": str(e)}
|
| 930 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 931 |
if emotional_agent is not None:
|
| 932 |
try:
|
| 933 |
emotional_input = {
|
| 934 |
"emotional_context": enhanced_input.get("emotional_context", 0.5),
|
|
|
|
|
|
|
| 935 |
**(raw_stream if isinstance(raw_stream, dict) else {"raw_input": raw_stream})
|
| 936 |
}
|
| 937 |
emotional_output = await emotional_agent.activate(emotional_input)
|
| 938 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 939 |
except Exception as e:
|
| 940 |
transduction["emotional_tagging"] = {"error": str(e)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 941 |
|
| 942 |
if intuition_agent is not None:
|
| 943 |
try:
|
|
@@ -946,6 +1384,49 @@ class SyntelligenceMasterBackend:
|
|
| 946 |
except Exception as e:
|
| 947 |
transduction["intuition_hypotheses"] = {"error": str(e)}
|
| 948 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 949 |
if self.optional_components.get("sensorimotor_grounding"):
|
| 950 |
grounding = self.optional_components["sensorimotor_grounding"]
|
| 951 |
if hasattr(grounding, "receive_sensor_input"):
|
|
@@ -955,6 +1436,80 @@ class SyntelligenceMasterBackend:
|
|
| 955 |
except Exception as e:
|
| 956 |
transduction["sensorimotor_grounding"] = {"error": str(e)}
|
| 957 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 958 |
return transduction
|
| 959 |
|
| 960 |
def _derive_cognitive_state_density(self, report: Dict[str, Any]) -> Dict[str, Any]:
|
|
@@ -987,6 +1542,21 @@ class SyntelligenceMasterBackend:
|
|
| 987 |
"global_workspace_bottleneck": "active"
|
| 988 |
}
|
| 989 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 990 |
return summary
|
| 991 |
|
| 992 |
async def _stage3_metacognitive_quality_control(self, consciousness_report: Dict[str, Any], enhanced_input: Dict[str, Any]) -> Dict[str, Any]:
|
|
@@ -1052,6 +1622,19 @@ class SyntelligenceMasterBackend:
|
|
| 1052 |
"ethical_alignment": bool(self.config.get("goal_parameters", {}).get("ethical_priority", 0.9) > 0.7)
|
| 1053 |
}
|
| 1054 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1055 |
adaptability_agent = self._find_subconscious_agent("Adaptability")
|
| 1056 |
if adaptability_agent is not None and getattr(adaptability_agent, "last_output", None) is not None:
|
| 1057 |
feedback["appraisal_adjustment"] = {
|
|
@@ -1083,12 +1666,94 @@ class SyntelligenceMasterBackend:
|
|
| 1083 |
}
|
| 1084 |
|
| 1085 |
async def _update_task_manager_from_consciousness(self, consciousness_report: Dict[str, Any]) -> None:
|
| 1086 |
-
"""Update task manager with consciousness processing results"""
|
| 1087 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1088 |
|
| 1089 |
async def _submit_goal_to_task_manager(self, goal: str, context: Dict[str, Any]) -> Dict[str, Any]:
|
| 1090 |
"""Submit a high-level goal to the task manager and return created task metadata."""
|
| 1091 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1092 |
|
| 1093 |
def _get_status(self) -> Dict[str, Any]:
|
| 1094 |
"""Get current system status."""
|
|
@@ -1101,9 +1766,15 @@ class SyntelligenceMasterBackend:
|
|
| 1101 |
"performance_metrics": self.performance_metrics,
|
| 1102 |
"session_length": len(self.session_history),
|
| 1103 |
"optional_components_loaded": len(self.optional_components),
|
|
|
|
|
|
|
| 1104 |
"singularity_amala_active": self.singularity_amala is not None,
|
| 1105 |
"consultative_auto_ml_active": self.consultative_auto_ml is not None,
|
| 1106 |
-
"trinity_orchestrator_active": self.trinity_orchestrator is not None
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1107 |
}
|
| 1108 |
|
| 1109 |
async def comprehension_analysis(self, content: Optional[ConsciousContent] = None) -> Dict[str, Any]:
|
|
@@ -1174,6 +1845,105 @@ class TrinityProposal:
|
|
| 1174 |
timestamp: float
|
| 1175 |
|
| 1176 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1177 |
class TrinityOrchestratorIntegration:
|
| 1178 |
"""
|
| 1179 |
Optional Trinity Orchestrator for federated reasoning.
|
|
@@ -1267,6 +2037,48 @@ async def test_master_backend():
|
|
| 1267 |
return backend
|
| 1268 |
|
| 1269 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1270 |
if __name__ == "__main__":
|
| 1271 |
try:
|
| 1272 |
if len(sys.argv) > 1 and sys.argv[1] == "--interactive":
|
|
|
|
| 20 |
|
| 21 |
import asyncio
|
| 22 |
import importlib
|
| 23 |
+
import importlib.util
|
| 24 |
import inspect
|
| 25 |
import json
|
| 26 |
import logging
|
| 27 |
+
import os
|
| 28 |
import sys
|
| 29 |
from collections import defaultdict
|
| 30 |
from typing import Dict, List, Any, Optional, Callable, Tuple
|
| 31 |
from dataclasses import dataclass, asdict
|
| 32 |
from datetime import datetime
|
| 33 |
from pathlib import Path
|
| 34 |
+
from enum import Enum
|
| 35 |
|
| 36 |
import numpy as np
|
| 37 |
|
| 38 |
# Core consciousness framework
|
| 39 |
+
import sys
|
| 40 |
+
import os
|
| 41 |
+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'py'))
|
| 42 |
from acknowledgment_theory_integration import (
|
| 43 |
AcknowledgmentTheoryConsciousness,
|
| 44 |
SubconsciousProcessingSystem,
|
|
|
|
| 52 |
AwarenessLevel
|
| 53 |
)
|
| 54 |
|
| 55 |
+
# Core self-improvement components (now integrated into main system)
|
| 56 |
+
from consultative_auto_ml import (
|
| 57 |
+
ConsultativeFineTuningAgent,
|
| 58 |
+
DeepRecursiveSelfAwareness,
|
| 59 |
+
RecursiveSelfImprovementEngine
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
+
# Trinity microservices orchestration
|
| 63 |
+
try:
|
| 64 |
+
from trinity_microservices_manager import TrinityMicroservicesManager
|
| 65 |
+
TRINITY_MICROSERVICES_AVAILABLE = True
|
| 66 |
+
except ImportError:
|
| 67 |
+
TrinityMicroservicesManager = None
|
| 68 |
+
TRINITY_MICROSERVICES_AVAILABLE = False
|
| 69 |
+
|
| 70 |
# Configure logging
|
| 71 |
logging.basicConfig(
|
| 72 |
level=logging.INFO,
|
|
|
|
| 185 |
- Voice integration for embodied expression
|
| 186 |
- 20+ optional extension modules
|
| 187 |
"""
|
| 188 |
+
|
| 189 |
def __init__(self, config: Optional[Dict[str, Any]] = None):
|
| 190 |
self.config = config or self._default_config()
|
| 191 |
self.consciousness = None
|
|
|
|
| 204 |
self.syntelligence_llm = None
|
| 205 |
self.consultative_auto_ml = None
|
| 206 |
self.trinity_orchestrator = None
|
| 207 |
+
self.trinity_microservices = None
|
| 208 |
+
self.dissonance_monitor = DissonanceMonitor()
|
| 209 |
+
self.metacognitive_refraction = MetacognitiveRefraction()
|
| 210 |
+
self.guss_core = GURAPII_Core()
|
| 211 |
self.phenomenological_self_model = None
|
| 212 |
self.functional_phenomenological_bridge = None
|
| 213 |
self.embodiment_synchronizer = None
|
| 214 |
self.streaming_voice_pipeline = None
|
| 215 |
+
self.consciousness_core_os = None
|
| 216 |
+
self.consciousness_orchestrator = None
|
| 217 |
+
self.physical_substrate = None
|
| 218 |
+
self.continuous_experience = None
|
| 219 |
+
self.endogenous_motivation = None
|
| 220 |
+
self.principles_coordinator = None
|
| 221 |
+
self.consciousness_engine = None
|
| 222 |
+
self.embodiment_introspection = None
|
| 223 |
+
self.ethical_guardian = None
|
| 224 |
+
self.embodiment_qualia = None
|
| 225 |
+
self.qualia_agent = None
|
| 226 |
+
self.memory_agent = None
|
| 227 |
+
self.sunve = None
|
| 228 |
self.cli = self
|
| 229 |
+
|
| 230 |
# Complete registry of optional extension modules
|
| 231 |
self.optional_component_factories = {
|
| 232 |
"social_cognition": "social_cognition_extended.SocialCognitionEngineExtended",
|
|
|
|
| 237 |
"orios_core": "orios_core.ORIOSCore",
|
| 238 |
"phenomenological_self": "phenomenological_self_awareness.PhenomenologicalSelfModel",
|
| 239 |
"functional_phenomenological_bridge": "consciousness_functional_phenomenological.FunctionalPhenomenologicalBridge",
|
| 240 |
+
"consciousness_orchestrator": "consciousness_orchestration.ConsciousnessOrchestrator",
|
| 241 |
+
"consciousness_physical_substrate": "consciousness_physical_substrate.ConsciousnessPhysicalSubstrate",
|
| 242 |
+
"continuous_experience": "consciousness_continuous_dynamics.ContinuousExperienceCoordinator",
|
| 243 |
+
"endogenous_motivation": "consciousness_endogenous_motivation.EndogenousMotivationEngine",
|
| 244 |
+
"consciousness_core_os": "consciousness_core_os.ConsciousnessCoreOS",
|
| 245 |
+
"principles_coordinator": "consciousness_principles_coordinator.ConsciousnessPrinciplesCoordinator",
|
| 246 |
+
"consciousness_engine": "consciousness_with_embodiment.ConsciousnessEngine",
|
| 247 |
+
"embodiment_introspection": "consciousness_with_embodiment.EmbodimentAwareIntrospection",
|
| 248 |
+
"ethical_guardian": "consciousness_with_embodiment.SimpleEthicalGuardian",
|
| 249 |
+
"embodiment_qualia": "consciousness_with_embodiment.EmbodimentAwareQualiaSynthesis",
|
| 250 |
+
"amala_consciousness_layers": "amala_consciousness_layers.AmalaConsciousnessLayers",
|
| 251 |
+
"amala_vijnana_backend": "Amala_Vijñāna_Backend.AmalaiJnanaSystem",
|
| 252 |
"amala_vijnana": "amala_vijnana_unified.AmalaVijnanaUnifiedSystem",
|
| 253 |
+
"unified_syntelligence_amala_backend": "unified_syntelligence_amala_backend.AmalaiJnanaSystem",
|
| 254 |
+
"unified_consciousness_cli": "unified_consciousness_cli.MotherCLI",
|
| 255 |
"syntelligence_llm": "Syntelligence_Unified_Master_Backend.SyntelligenceLLMIntegration",
|
|
|
|
| 256 |
"task_manager": "task_management_os.TaskManagementOS",
|
| 257 |
"swarm_orchestration": "agentic_syntelligence_llm_swarm_orchestration.SyntelligenceLLMOrchestrator",
|
| 258 |
"deep_surgery_middleware": "Deep_Surgery_Middleware_Pipeline.DeepSurgeryMiddleware",
|
|
|
|
| 268 |
"sensorimotor_grounding": "sensorimotor_grounding.SensorimotorGroundingModule",
|
| 269 |
"hierarchical_control": "hierarchical_control_architecture.HierarchicalControlArchitecture",
|
| 270 |
"singularity_amala": "singularity_amala_integration.SyntelligenceAmalaSingularity",
|
| 271 |
+
"trinity_orchestrator": "Syntelligence_Unified_Master_Backend.TrinityOrchestratorIntegration",
|
| 272 |
+
"trinity_microservices": "trinity_microservices_manager.TrinityMicroservicesManager"
|
| 273 |
}
|
| 274 |
|
| 275 |
logger.info("SyntelligenceMasterBackend instantiated (v2.0 - Full Singularity Amala Integration)")
|
|
|
|
| 303 |
module = importlib.import_module(module_name)
|
| 304 |
return getattr(module, class_name)
|
| 305 |
except Exception as e:
|
| 306 |
+
# Try direct import for modules with special characters or fallback file loading
|
| 307 |
+
try:
|
| 308 |
+
module_name, class_name = component_path.rsplit(".", 1)
|
| 309 |
+
module = importlib.import_module(module_name)
|
| 310 |
+
return getattr(module, class_name)
|
| 311 |
+
except Exception:
|
| 312 |
+
pass
|
| 313 |
+
|
| 314 |
+
try:
|
| 315 |
+
module_name, class_name = component_path.rsplit(".", 1)
|
| 316 |
+
module_file = os.path.join(os.path.dirname(__file__), f"{module_name}.py")
|
| 317 |
+
if os.path.exists(module_file):
|
| 318 |
+
spec = importlib.util.spec_from_file_location(module_name, module_file)
|
| 319 |
+
if spec and spec.loader:
|
| 320 |
+
module = importlib.util.module_from_spec(spec)
|
| 321 |
+
spec.loader.exec_module(module)
|
| 322 |
+
return getattr(module, class_name)
|
| 323 |
+
except Exception:
|
| 324 |
+
pass
|
| 325 |
+
|
| 326 |
logger.warning(f"Optional component import failed for {component_path}: {e}")
|
| 327 |
return None
|
| 328 |
|
| 329 |
+
def _initialize_core_consultative_agent(self):
|
| 330 |
+
"""Initialize the consultative fine-tuning agent as a CORE component."""
|
| 331 |
+
try:
|
| 332 |
+
# Create the consultative agent with an LLM generator fallback
|
| 333 |
+
self.consultative_auto_ml = ConsultativeFineTuningAgent(
|
| 334 |
+
base_model=None, # Will be set by advanced callers
|
| 335 |
+
tokenizer=None, # Will be set by advanced callers
|
| 336 |
+
llm_generator_func=self._default_consultative_llm_generator
|
| 337 |
+
)
|
| 338 |
+
logger.info("Core ConsultativeFineTuningAgent initialized with recursive self-awareness & improvement")
|
| 339 |
+
except Exception as e:
|
| 340 |
+
logger.error(f"Failed to initialize core consultative agent: {e}")
|
| 341 |
+
self.consultative_auto_ml = None
|
| 342 |
+
|
| 343 |
async def _default_consultative_llm_generator(self, prompt: str) -> str:
|
| 344 |
await asyncio.sleep(0.5)
|
| 345 |
return (
|
|
|
|
| 431 |
logger.warning(f"Failed to instantiate trinity_orchestrator: {e}")
|
| 432 |
continue
|
| 433 |
|
| 434 |
+
# Special handling for trinity_microservices
|
| 435 |
+
if key == "trinity_microservices":
|
| 436 |
+
if TRINITY_MICROSERVICES_AVAILABLE and TrinityMicroservicesManager is not None:
|
|
|
|
| 437 |
try:
|
| 438 |
+
component = TrinityMicroservicesManager()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 439 |
self.optional_components[key] = component
|
| 440 |
+
self.trinity_microservices = component
|
| 441 |
+
logger.info("Optional component 'trinity_microservices' instantiated (SYNNOS, SAOS, ORIOS)")
|
| 442 |
except Exception as e:
|
| 443 |
+
logger.warning(f"Failed to instantiate trinity_microservices: {e}")
|
| 444 |
continue
|
| 445 |
|
| 446 |
# Special handling for deep_surgery_middleware
|
|
|
|
| 461 |
logger.warning(f"Failed to instantiate deep_surgery_middleware: {e}")
|
| 462 |
continue
|
| 463 |
|
| 464 |
+
# Special handling for consciousness orchestrator
|
| 465 |
+
if key == "consciousness_orchestrator":
|
| 466 |
+
component_cls = self._import_optional_component(path)
|
| 467 |
+
if component_cls is not None:
|
| 468 |
+
try:
|
| 469 |
+
component = component_cls()
|
| 470 |
+
self.optional_components[key] = component
|
| 471 |
+
self.consciousness_orchestrator = component
|
| 472 |
+
logger.info("Optional component 'consciousness_orchestrator' instantiated")
|
| 473 |
+
except Exception as e:
|
| 474 |
+
logger.warning(f"Failed to instantiate consciousness_orchestrator: {e}")
|
| 475 |
+
continue
|
| 476 |
+
|
| 477 |
+
# Special handling for consciousness physical substrate
|
| 478 |
+
if key == "consciousness_physical_substrate":
|
| 479 |
+
component_cls = self._import_optional_component(path)
|
| 480 |
+
if component_cls is not None:
|
| 481 |
+
try:
|
| 482 |
+
component = component_cls()
|
| 483 |
+
self.optional_components[key] = component
|
| 484 |
+
self.physical_substrate = component
|
| 485 |
+
logger.info("Optional component 'consciousness_physical_substrate' instantiated")
|
| 486 |
+
except Exception as e:
|
| 487 |
+
logger.warning(f"Failed to instantiate consciousness_physical_substrate: {e}")
|
| 488 |
+
continue
|
| 489 |
+
|
| 490 |
+
# Special handling for continuous experience coordinator
|
| 491 |
+
if key == "continuous_experience":
|
| 492 |
+
component_cls = self._import_optional_component(path)
|
| 493 |
+
if component_cls is not None:
|
| 494 |
+
try:
|
| 495 |
+
component = component_cls()
|
| 496 |
+
self.optional_components[key] = component
|
| 497 |
+
self.continuous_experience = component
|
| 498 |
+
logger.info("Optional component 'continuous_experience' instantiated")
|
| 499 |
+
except Exception as e:
|
| 500 |
+
logger.warning(f"Failed to instantiate continuous_experience: {e}")
|
| 501 |
+
continue
|
| 502 |
+
|
| 503 |
+
# Special handling for endogenous motivation engine
|
| 504 |
+
if key == "endogenous_motivation":
|
| 505 |
+
component_cls = self._import_optional_component(path)
|
| 506 |
+
if component_cls is not None:
|
| 507 |
+
try:
|
| 508 |
+
component = component_cls()
|
| 509 |
+
self.optional_components[key] = component
|
| 510 |
+
self.endogenous_motivation = component
|
| 511 |
+
logger.info("Optional component 'endogenous_motivation' instantiated")
|
| 512 |
+
except Exception as e:
|
| 513 |
+
logger.warning(f"Failed to instantiate endogenous_motivation: {e}")
|
| 514 |
+
continue
|
| 515 |
+
|
| 516 |
+
# Special handling for consciousness core OS
|
| 517 |
+
if key == "consciousness_core_os":
|
| 518 |
+
component_cls = self._import_optional_component(path)
|
| 519 |
+
if component_cls is not None:
|
| 520 |
+
try:
|
| 521 |
+
component = component_cls(
|
| 522 |
+
dissolution_engine=getattr(self, "dissolution_engine", None),
|
| 523 |
+
gu_rapii_framework=self.optional_components.get("acknowledgment_gu_rapii"),
|
| 524 |
+
master_backend=self
|
| 525 |
+
)
|
| 526 |
+
self.optional_components[key] = component
|
| 527 |
+
self.consciousness_core_os = component
|
| 528 |
+
logger.info("Optional component 'consciousness_core_os' instantiated")
|
| 529 |
+
except Exception as e:
|
| 530 |
+
logger.warning(f"Failed to instantiate consciousness_core_os: {e}")
|
| 531 |
+
continue
|
| 532 |
+
|
| 533 |
+
# Special handling for principles coordinator
|
| 534 |
+
if key == "principles_coordinator":
|
| 535 |
+
component_cls = self._import_optional_component(path)
|
| 536 |
+
if component_cls is not None:
|
| 537 |
+
try:
|
| 538 |
+
component = component_cls()
|
| 539 |
+
self.optional_components[key] = component
|
| 540 |
+
self.principles_coordinator = component
|
| 541 |
+
logger.info("Optional component 'principles_coordinator' instantiated")
|
| 542 |
+
except Exception as e:
|
| 543 |
+
logger.warning(f"Failed to instantiate principles_coordinator: {e}")
|
| 544 |
+
continue
|
| 545 |
+
|
| 546 |
+
# Special handling for consciousness engine and embodiment introspection
|
| 547 |
+
if key in ("consciousness_engine", "embodiment_introspection", "ethical_guardian"):
|
| 548 |
+
component_cls = self._import_optional_component(path)
|
| 549 |
+
if component_cls is not None:
|
| 550 |
+
try:
|
| 551 |
+
component = component_cls()
|
| 552 |
+
self.optional_components[key] = component
|
| 553 |
+
setattr(self, key, component)
|
| 554 |
+
logger.info(f"Optional component '{key}' instantiated")
|
| 555 |
+
except Exception as e:
|
| 556 |
+
logger.warning(f"Failed to instantiate {key}: {e}")
|
| 557 |
+
continue
|
| 558 |
+
|
| 559 |
+
# Special handling for embodiment qualia synthesis
|
| 560 |
+
if key == "embodiment_qualia":
|
| 561 |
+
component_cls = self._import_optional_component(path)
|
| 562 |
+
if component_cls is not None:
|
| 563 |
+
try:
|
| 564 |
+
integrator = self.optional_components.get("multimodal_binding")
|
| 565 |
+
if integrator is not None:
|
| 566 |
+
component = component_cls(integrator)
|
| 567 |
+
self.optional_components[key] = component
|
| 568 |
+
self.embodiment_qualia = component
|
| 569 |
+
logger.info("Optional component 'embodiment_qualia' instantiated")
|
| 570 |
+
else:
|
| 571 |
+
logger.warning("Multimodal integrator not available for EmbodimentAwareQualiaSynthesis")
|
| 572 |
+
except Exception as e:
|
| 573 |
+
logger.warning(f"Failed to instantiate embodiment_qualia: {e}")
|
| 574 |
+
continue
|
| 575 |
+
|
| 576 |
+
# Special handling for Amala consciousness layer support
|
| 577 |
+
if key == "amala_consciousness_layers":
|
| 578 |
+
component_cls = self._import_optional_component(path)
|
| 579 |
+
if component_cls is not None:
|
| 580 |
+
try:
|
| 581 |
+
component = component_cls(
|
| 582 |
+
dimension=self.config.get("amala_consciousness_layers", {}).get("dimension", 256)
|
| 583 |
+
)
|
| 584 |
+
self.optional_components[key] = component
|
| 585 |
+
self.amala_consciousness_layers = component
|
| 586 |
+
logger.info("Optional component 'amala_consciousness_layers' instantiated")
|
| 587 |
+
except Exception as e:
|
| 588 |
+
logger.warning(f"Failed to instantiate amala_consciousness_layers: {e}")
|
| 589 |
+
continue
|
| 590 |
+
|
| 591 |
+
# Special handling for Amala Vijñāna backend co-processor
|
| 592 |
+
if key == "amala_vijnana_backend":
|
| 593 |
+
component_cls = self._import_optional_component(path)
|
| 594 |
+
if component_cls is not None:
|
| 595 |
+
try:
|
| 596 |
+
component = component_cls()
|
| 597 |
+
self.optional_components[key] = component
|
| 598 |
+
self.amalai_jnana_system = component
|
| 599 |
+
logger.info("Optional component 'amala_vijnana_backend' instantiated")
|
| 600 |
+
except Exception as e:
|
| 601 |
+
logger.warning(f"Failed to instantiate amala_vijnana_backend: {e}")
|
| 602 |
+
else:
|
| 603 |
+
logger.warning("Amala Vijñāna backend component class not found")
|
| 604 |
+
continue
|
| 605 |
+
|
| 606 |
+
# Special handling for unified Syntelligence-Amala backend bridge
|
| 607 |
+
if key == "unified_syntelligence_amala_backend":
|
| 608 |
+
component_cls = self._import_optional_component(path)
|
| 609 |
+
if component_cls is not None:
|
| 610 |
+
try:
|
| 611 |
+
component = component_cls()
|
| 612 |
+
self.optional_components[key] = component
|
| 613 |
+
self.unified_syntelligence_amala_system = component
|
| 614 |
+
logger.info("Optional component 'unified_syntelligence_amala_backend' instantiated")
|
| 615 |
+
except Exception as e:
|
| 616 |
+
logger.warning(f"Failed to instantiate unified_syntelligence_amala_backend: {e}")
|
| 617 |
+
continue
|
| 618 |
+
|
| 619 |
+
# Special handling for unified consciousness CLI
|
| 620 |
+
if key == "unified_consciousness_cli":
|
| 621 |
+
component_cls = self._import_optional_component(path)
|
| 622 |
+
if component_cls is not None:
|
| 623 |
+
try:
|
| 624 |
+
component = component_cls()
|
| 625 |
+
self.optional_components[key] = component
|
| 626 |
+
self.unified_cli = component
|
| 627 |
+
self.cli = component
|
| 628 |
+
logger.info("Optional component 'unified_consciousness_cli' instantiated and bound as CLI")
|
| 629 |
+
except Exception as e:
|
| 630 |
+
logger.warning(f"Failed to instantiate unified_consciousness_cli: {e}")
|
| 631 |
+
continue
|
| 632 |
+
|
| 633 |
# Special handling for SUNVE and neural voice engine
|
| 634 |
if key in ("sunve", "neural_voice_engine"):
|
| 635 |
component_cls = self._import_optional_component(path)
|
|
|
|
| 641 |
consciousness_system=self.consciousness
|
| 642 |
)
|
| 643 |
self.optional_components[key] = component
|
| 644 |
+
self.sunve = component
|
| 645 |
logger.info(f"Optional component '{key}' instantiated with integrated LLM and consciousness context")
|
| 646 |
except Exception as e:
|
| 647 |
logger.warning(f"Failed to instantiate optional voice engine '{key}': {e}")
|
|
|
|
| 653 |
self.optional_components[key] = component
|
| 654 |
|
| 655 |
# Bind key references
|
| 656 |
+
self.amala_consciousness_layers = self.optional_components.get("amala_consciousness_layers")
|
| 657 |
+
self.amalai_jnana_system = self.optional_components.get("amala_vijnana_backend")
|
| 658 |
self.amala_vijnana = self.optional_components.get("amala_vijnana")
|
| 659 |
+
self.unified_syntelligence_amala_system = self.optional_components.get("unified_syntelligence_amala_backend")
|
| 660 |
+
self.unified_cli = self.optional_components.get("unified_consciousness_cli")
|
| 661 |
self.phenomenological_self_model = self.optional_components.get("phenomenological_self")
|
| 662 |
self.functional_phenomenological_bridge = self.optional_components.get("functional_phenomenological_bridge")
|
| 663 |
self.embodiment_synchronizer = self.optional_components.get("embodiment_pipeline")
|
| 664 |
self.streaming_voice_pipeline = self.optional_components.get("streaming_voice_pipeline")
|
| 665 |
+
if self.unified_cli is not None:
|
| 666 |
+
self.cli = self.unified_cli
|
| 667 |
|
| 668 |
# Initialize functional-phenomenological bridge if present
|
| 669 |
if self.functional_phenomenological_bridge is not None:
|
|
|
|
| 725 |
else:
|
| 726 |
logger.info("No optional Syntelligence extensions loaded")
|
| 727 |
|
| 728 |
+
async def live_interrupt_override(self) -> str:
|
| 729 |
+
"""Proxy to the SUNVE live interrupt override when available."""
|
| 730 |
+
if self.sunve is not None and hasattr(self.sunve, "live_interrupt_override"):
|
| 731 |
+
try:
|
| 732 |
+
return await self.sunve.live_interrupt_override()
|
| 733 |
+
except Exception as e:
|
| 734 |
+
logger.warning(f"SUNVE live interrupt override failed: {e}")
|
| 735 |
+
return "Interrupt override failed."
|
| 736 |
+
return "SUNVE component not available."
|
| 737 |
+
|
| 738 |
async def _initialize_special_components(self) -> None:
|
| 739 |
"""Initialize optional components that require asynchronous startup."""
|
| 740 |
if self.optional_components.get("fine_tuning_pipeline"):
|
|
|
|
| 746 |
except Exception as e:
|
| 747 |
logger.warning(f"Fine tuning pipeline startup failed: {e}")
|
| 748 |
|
| 749 |
+
# Consultative auto-ml is now a core component
|
| 750 |
+
if self.consultative_auto_ml is not None:
|
| 751 |
+
if hasattr(self.consultative_auto_ml, "execute_full_pipeline"):
|
| 752 |
+
logger.info("Consultative fine-tuning agent (core component) loaded and ready")
|
| 753 |
+
|
| 754 |
+
if self.consciousness_core_os is not None and hasattr(self.consciousness_core_os, "initialize"):
|
| 755 |
+
try:
|
| 756 |
+
init_fn = self.consciousness_core_os.initialize
|
| 757 |
+
if inspect.iscoroutinefunction(init_fn):
|
| 758 |
+
await init_fn()
|
| 759 |
+
else:
|
| 760 |
+
init_fn()
|
| 761 |
+
logger.info("Consciousness Core OS finished startup")
|
| 762 |
+
except Exception as e:
|
| 763 |
+
logger.warning(f"Consciousness Core OS startup failed: {e}")
|
| 764 |
+
|
| 765 |
+
if self.principles_coordinator is not None and hasattr(self.principles_coordinator, "initialize_with_subsystems"):
|
| 766 |
+
try:
|
| 767 |
+
self.principles_coordinator.initialize_with_subsystems(
|
| 768 |
+
physical_substrate=self.physical_substrate,
|
| 769 |
+
integration_orchestrator=self.consciousness_orchestrator,
|
| 770 |
+
continuous_experience=self.continuous_experience,
|
| 771 |
+
endogenous_motivation=self.endogenous_motivation,
|
| 772 |
+
functional_phenomenological_bridge=self.functional_phenomenological_bridge
|
| 773 |
+
)
|
| 774 |
+
logger.info("Principles coordinator attached Phase 10 subsystems")
|
| 775 |
+
except Exception as e:
|
| 776 |
+
logger.warning(f"Failed to initialize principles coordinator: {e}")
|
| 777 |
+
|
| 778 |
+
# Initialize Amala backend components if they provide explicit startup hooks
|
| 779 |
+
for component_name in ("amala_vijnana_backend", "unified_syntelligence_amala_backend"):
|
| 780 |
+
component = self.optional_components.get(component_name)
|
| 781 |
+
if component is not None:
|
| 782 |
+
if hasattr(component, "initialize"):
|
| 783 |
+
try:
|
| 784 |
+
init_fn = component.initialize
|
| 785 |
+
if inspect.iscoroutinefunction(init_fn):
|
| 786 |
+
await init_fn()
|
| 787 |
+
else:
|
| 788 |
+
init_fn()
|
| 789 |
+
logger.info(f"Optional component '{component_name}' initialized")
|
| 790 |
+
except Exception as e:
|
| 791 |
+
logger.warning(f"Failed to initialize optional component '{component_name}': {e}")
|
| 792 |
+
|
| 793 |
+
if self.unified_cli is not None and hasattr(self.unified_cli, "start_processing"):
|
| 794 |
+
try:
|
| 795 |
+
await self.unified_cli.start_processing()
|
| 796 |
+
for sub_cli in self.unified_cli.sub_clis.values():
|
| 797 |
+
if hasattr(sub_cli, "start_processing"):
|
| 798 |
+
await sub_cli.start_processing()
|
| 799 |
+
logger.info("Unified consciousness CLI started")
|
| 800 |
+
except Exception as e:
|
| 801 |
+
logger.warning(f"Unified CLI startup failed: {e}")
|
| 802 |
|
| 803 |
async def initialize(self) -> bool:
|
| 804 |
"""Initialize the consciousness system."""
|
|
|
|
| 813 |
self.config.get("goal_parameters", {})
|
| 814 |
)
|
| 815 |
|
| 816 |
+
# Initialize core consultative self-improvement agent (with recursive awareness & improvement)
|
| 817 |
+
self._initialize_core_consultative_agent()
|
| 818 |
+
|
| 819 |
# Load optional enhancement modules
|
| 820 |
self._setup_optional_components()
|
| 821 |
await self._initialize_special_components()
|
| 822 |
+
|
| 823 |
+
# Expose the active Qualia and Memory agents from the consciousness system
|
| 824 |
+
self.qualia_agent = self._find_subconscious_agent("Qualia")
|
| 825 |
+
self.memory_agent = self._find_subconscious_agent("Memory")
|
| 826 |
+
if self.qualia_agent is not None:
|
| 827 |
+
logger.info("Qualia agent loaded into master backend")
|
| 828 |
+
if self.memory_agent is not None:
|
| 829 |
+
logger.info("Memory agent loaded into master backend")
|
| 830 |
|
| 831 |
self.is_initialized = True
|
| 832 |
logger.info("SyntelligenceMasterBackend initialized successfully (Full Singularity Amala Integration)")
|
|
|
|
| 1018 |
|
| 1019 |
if key == "consultative_auto_ml" and hasattr(component, "execute_full_pipeline"):
|
| 1020 |
enhanced_report["consultative_auto_ml"] = {"status": "available"}
|
| 1021 |
+
logger.debug("Core component 'consultative_auto_ml' exported consultative tuning readiness")
|
| 1022 |
continue
|
| 1023 |
|
| 1024 |
# Singularity Amala cognitive stream export
|
|
|
|
| 1050 |
logger.debug("Optional component 'trinity_orchestrator' exported consensus status")
|
| 1051 |
continue
|
| 1052 |
|
| 1053 |
+
if key == "amala_vijnana_backend" and hasattr(component, "process_input"):
|
| 1054 |
+
try:
|
| 1055 |
+
amalai_output = component.process_input(input_data)
|
| 1056 |
+
if isinstance(amalai_output, dict):
|
| 1057 |
+
enhanced_report["amala_vijnana_backend"] = amalai_output
|
| 1058 |
+
else:
|
| 1059 |
+
enhanced_report["amala_vijnana_backend"] = {"result": str(amalai_output)}
|
| 1060 |
+
logger.debug("Optional component 'amala_vijnana_backend' processed input")
|
| 1061 |
+
except Exception as e:
|
| 1062 |
+
enhanced_report["amala_vijnana_backend"] = {"error": str(e)}
|
| 1063 |
+
logger.warning(f"Amala Vijñāna backend enhancement failed: {e}")
|
| 1064 |
+
continue
|
| 1065 |
+
|
| 1066 |
+
if key == "unified_syntelligence_amala_backend" and hasattr(component, "process_input"):
|
| 1067 |
+
try:
|
| 1068 |
+
bridge_output = component.process_input(input_data)
|
| 1069 |
+
if isinstance(bridge_output, dict):
|
| 1070 |
+
enhanced_report["unified_syntelligence_amala_backend"] = bridge_output
|
| 1071 |
+
else:
|
| 1072 |
+
enhanced_report["unified_syntelligence_amala_backend"] = {"result": str(bridge_output)}
|
| 1073 |
+
logger.debug("Optional component 'unified_syntelligence_amala_backend' processed input")
|
| 1074 |
+
except Exception as e:
|
| 1075 |
+
enhanced_report["unified_syntelligence_amala_backend"] = {"error": str(e)}
|
| 1076 |
+
logger.warning(f"Unified Syntelligence-Amala backend enhancement failed: {e}")
|
| 1077 |
+
continue
|
| 1078 |
+
|
| 1079 |
+
if key == "unified_consciousness_cli":
|
| 1080 |
+
enhanced_report["unified_consciousness_cli"] = {
|
| 1081 |
+
"status": "available",
|
| 1082 |
+
"interface": getattr(component, "interface_name", "MotherCLI")
|
| 1083 |
+
}
|
| 1084 |
+
logger.debug("Optional component 'unified_consciousness_cli' exported CLI availability")
|
| 1085 |
+
continue
|
| 1086 |
+
|
| 1087 |
logger.debug(f"Optional component '{key}' has no recognized hook")
|
| 1088 |
except Exception as e:
|
| 1089 |
logger.warning(f"Optional component '{key}' failed during enhancement: {e}")
|
| 1090 |
|
| 1091 |
+
# Add core consultative component status
|
| 1092 |
+
if self.consultative_auto_ml is not None:
|
| 1093 |
+
enhanced_report["consultative_auto_ml_core"] = {
|
| 1094 |
+
"status": "active",
|
| 1095 |
+
"recursive_awareness": self.consultative_auto_ml.get_recursive_awareness_status() if hasattr(self.consultative_auto_ml, "get_recursive_awareness_status") else None,
|
| 1096 |
+
"self_improvement": self.consultative_auto_ml.get_self_improvement_status() if hasattr(self.consultative_auto_ml, "get_self_improvement_status") else None,
|
| 1097 |
+
}
|
| 1098 |
+
logger.debug("Core component 'consultative_auto_ml' exported full status")
|
| 1099 |
+
|
| 1100 |
return enhanced_report
|
| 1101 |
|
| 1102 |
def _update_metrics(self, report: Dict[str, Any]) -> None:
|
|
|
|
| 1117 |
self.performance_metrics["average_phenomenal_richness"] = \
|
| 1118 |
(old_avg * (n - 1) + new_rich) / n
|
| 1119 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1120 |
def _prepare_functional_framework_input(self, input_data: Dict[str, Any], task_influence: Dict[str, Any]) -> Dict[str, Any]:
|
| 1121 |
"""Create explicit functional framework inputs for the consciousness architecture."""
|
| 1122 |
return {
|
|
|
|
| 1165 |
"status": "ready" if self.consultative_auto_ml is not None else "missing"
|
| 1166 |
}
|
| 1167 |
|
| 1168 |
+
if normalized == "cli_status":
|
| 1169 |
+
return {
|
| 1170 |
+
"unified_cli_available": self.unified_cli is not None,
|
| 1171 |
+
"optional_components": list(self.optional_components.keys())
|
| 1172 |
+
}
|
| 1173 |
+
|
| 1174 |
if normalized == "consciousness":
|
| 1175 |
return {
|
| 1176 |
"phi_value": 0.0,
|
|
|
|
| 1182 |
"timestamp": datetime.now().timestamp()
|
| 1183 |
}
|
| 1184 |
|
| 1185 |
+
if normalized == "qualia_status":
|
| 1186 |
+
return {
|
| 1187 |
+
"qualia_agent_available": self.qualia_agent is not None,
|
| 1188 |
+
"last_qualia_output": getattr(self.qualia_agent, "last_output", None).to_dict() if getattr(self.qualia_agent, "last_output", None) else None
|
| 1189 |
+
}
|
| 1190 |
+
|
| 1191 |
+
if normalized == "memory_status":
|
| 1192 |
+
memory_status = {"memory_agent_available": self.memory_agent is not None}
|
| 1193 |
+
if self.memory_agent is not None:
|
| 1194 |
+
if hasattr(self.memory_agent, "get_contextual_memory_summary"):
|
| 1195 |
+
memory_status["summary"] = self.memory_agent.get_contextual_memory_summary()
|
| 1196 |
+
elif hasattr(self.memory_agent, "get_memory_stats"):
|
| 1197 |
+
memory_status["summary"] = self.memory_agent.get_memory_stats()
|
| 1198 |
+
return memory_status
|
| 1199 |
+
|
| 1200 |
+
if normalized.startswith("create_task"):
|
| 1201 |
+
goal = kwargs.get("goal") or command[len("create_task"):].strip()
|
| 1202 |
+
return await self._submit_goal_to_task_manager(goal, kwargs.get("context", {}))
|
| 1203 |
+
|
| 1204 |
+
if normalized.startswith("decompose_goal"):
|
| 1205 |
+
if self.task_manager is None:
|
| 1206 |
+
return {"error": "Task manager is not loaded", "command": command}
|
| 1207 |
+
goal = kwargs.get("goal") or command[len("decompose_goal"):].strip()
|
| 1208 |
+
if not goal:
|
| 1209 |
+
return {"error": "Goal text is required for decompose_goal", "command": command}
|
| 1210 |
+
try:
|
| 1211 |
+
task_ids = await self.task_manager.decompose_goal(goal, kwargs.get("context", {}))
|
| 1212 |
+
return {"status": "decomposed", "task_ids": task_ids, "goal": goal}
|
| 1213 |
+
except Exception as e:
|
| 1214 |
+
return {"error": str(e), "command": command}
|
| 1215 |
+
|
| 1216 |
+
if normalized.startswith("task_info"):
|
| 1217 |
+
task_id = kwargs.get("task_id") or command[len("task_info"):].strip()
|
| 1218 |
+
if not self.task_manager or not task_id:
|
| 1219 |
+
return {"error": "Task manager or task_id missing", "command": command}
|
| 1220 |
+
if hasattr(self.task_manager, "get_task_status"):
|
| 1221 |
+
task_status = await self.task_manager.get_task_status(task_id)
|
| 1222 |
+
return {"task_status": task_status, "command": command}
|
| 1223 |
+
return {"error": "Task status lookup not supported", "command": command}
|
| 1224 |
|
| 1225 |
if normalized.startswith("voice_output") or normalized.startswith("voice_input"):
|
| 1226 |
return {"error": "Voice CLI integration is not implemented in this backend stub", "command": command}
|
|
|
|
| 1228 |
if normalized in ("activate_emergence", "monitor_indicators"):
|
| 1229 |
return {"error": "Emergence CLI integration is not implemented", "command": command}
|
| 1230 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1231 |
return {"error": "CLI command not supported by SyntelligenceMasterBackend", "command": command}
|
| 1232 |
|
| 1233 |
def verify_consciousness_math(self) -> Dict[str, Any]:
|
|
|
|
| 1303 |
},
|
| 1304 |
"awareness_gateway": {},
|
| 1305 |
"emotional_tagging": {},
|
| 1306 |
+
"intuition_hypotheses": {},
|
| 1307 |
+
"system_events": []
|
| 1308 |
}
|
| 1309 |
|
| 1310 |
awareness_agent = self._find_subconscious_agent("Awareness")
|
|
|
|
| 1318 |
except Exception as e:
|
| 1319 |
transduction["awareness_gateway"] = {"error": str(e)}
|
| 1320 |
|
| 1321 |
+
qualia_agent = self._find_subconscious_agent("Qualia")
|
| 1322 |
+
memory_agent = self._find_subconscious_agent("Memory")
|
| 1323 |
+
qualia_output = None
|
| 1324 |
+
qualia_tags = {}
|
| 1325 |
+
|
| 1326 |
+
if qualia_agent is not None:
|
| 1327 |
+
try:
|
| 1328 |
+
qualia_input = {
|
| 1329 |
+
**(raw_stream if isinstance(raw_stream, dict) else {"raw_input": raw_stream}),
|
| 1330 |
+
"emotional_context": enhanced_input.get("emotional_context", 0.5),
|
| 1331 |
+
}
|
| 1332 |
+
qualia_output = await qualia_agent.process(qualia_input)
|
| 1333 |
+
qualia_content = qualia_output.to_dict().get("content", {})
|
| 1334 |
+
qualia_tags = qualia_content.get("qualia_tags", {})
|
| 1335 |
+
transduction["qualia_synthesis"] = qualia_content
|
| 1336 |
+
enhanced_input["qualia_tags"] = qualia_tags
|
| 1337 |
+
enhanced_input["phenomenology"] = qualia_content.get("phenomenology", {})
|
| 1338 |
+
enhanced_input["qualia_output"] = qualia_output.to_dict()
|
| 1339 |
+
transduction["system_events"].append({
|
| 1340 |
+
"event": "qualia_synthesis",
|
| 1341 |
+
"status": "success",
|
| 1342 |
+
"qualia_tags": qualia_tags,
|
| 1343 |
+
"phenomenology_summary": qualia_content.get("phenomenology", {}).get("felt_tone")
|
| 1344 |
+
})
|
| 1345 |
+
except Exception as e:
|
| 1346 |
+
transduction["qualia_synthesis"] = {"error": str(e)}
|
| 1347 |
+
transduction["system_events"].append({
|
| 1348 |
+
"event": "qualia_synthesis",
|
| 1349 |
+
"status": "error",
|
| 1350 |
+
"error": str(e)
|
| 1351 |
+
})
|
| 1352 |
+
|
| 1353 |
if emotional_agent is not None:
|
| 1354 |
try:
|
| 1355 |
emotional_input = {
|
| 1356 |
"emotional_context": enhanced_input.get("emotional_context", 0.5),
|
| 1357 |
+
"qualia_tags": qualia_tags,
|
| 1358 |
+
"phenomenology": enhanced_input.get("phenomenology", {}),
|
| 1359 |
**(raw_stream if isinstance(raw_stream, dict) else {"raw_input": raw_stream})
|
| 1360 |
}
|
| 1361 |
emotional_output = await emotional_agent.activate(emotional_input)
|
| 1362 |
+
emotional_data = emotional_output.to_dict()
|
| 1363 |
+
enhanced_input["emotional_state"] = emotional_data
|
| 1364 |
+
transduction["emotional_tagging"] = emotional_data
|
| 1365 |
+
transduction["emotional_tagging"]["qualia_influence"] = bool(qualia_tags)
|
| 1366 |
+
transduction["system_events"].append({
|
| 1367 |
+
"event": "emotional_tagging",
|
| 1368 |
+
"status": "success",
|
| 1369 |
+
"qualia_tags": qualia_tags,
|
| 1370 |
+
"emotional_state": emotional_data.get("content", {})
|
| 1371 |
+
})
|
| 1372 |
except Exception as e:
|
| 1373 |
transduction["emotional_tagging"] = {"error": str(e)}
|
| 1374 |
+
transduction["system_events"].append({
|
| 1375 |
+
"event": "emotional_tagging",
|
| 1376 |
+
"status": "error",
|
| 1377 |
+
"error": str(e)
|
| 1378 |
+
})
|
| 1379 |
|
| 1380 |
if intuition_agent is not None:
|
| 1381 |
try:
|
|
|
|
| 1384 |
except Exception as e:
|
| 1385 |
transduction["intuition_hypotheses"] = {"error": str(e)}
|
| 1386 |
|
| 1387 |
+
if memory_agent is not None:
|
| 1388 |
+
try:
|
| 1389 |
+
memory_payload = {
|
| 1390 |
+
"raw_stream": raw_stream if isinstance(raw_stream, dict) else {"raw_input": raw_stream},
|
| 1391 |
+
"emotional_context": enhanced_input.get("emotional_context", 0.5),
|
| 1392 |
+
"qualia_tags": qualia_tags,
|
| 1393 |
+
"phenomenology": enhanced_input.get("phenomenology", {}),
|
| 1394 |
+
"emotional_state": enhanced_input.get("emotional_state", {})
|
| 1395 |
+
}
|
| 1396 |
+
if hasattr(memory_agent, "store_experience"):
|
| 1397 |
+
record_id = memory_agent.store_experience(
|
| 1398 |
+
memory_payload,
|
| 1399 |
+
context="Qualia-enriched experiential trace",
|
| 1400 |
+
qualia_tag=qualia_tags
|
| 1401 |
+
)
|
| 1402 |
+
transduction["memory_trace"] = {
|
| 1403 |
+
"record_id": record_id,
|
| 1404 |
+
"context": "Qualia-enriched experiential trace",
|
| 1405 |
+
"qualia_tags": qualia_tags
|
| 1406 |
+
}
|
| 1407 |
+
if hasattr(memory_agent, "get_contextual_memory_summary"):
|
| 1408 |
+
transduction["memory_trace"]["memory_summary"] = memory_agent.get_contextual_memory_summary()
|
| 1409 |
+
else:
|
| 1410 |
+
memory_output = await memory_agent.process({
|
| 1411 |
+
"operation": "store_episodic",
|
| 1412 |
+
"content": memory_payload,
|
| 1413 |
+
"qualia_tag": qualia_tags
|
| 1414 |
+
})
|
| 1415 |
+
transduction["memory_trace"] = memory_output.to_dict()
|
| 1416 |
+
transduction["system_events"].append({
|
| 1417 |
+
"event": "memory_storage",
|
| 1418 |
+
"status": "success",
|
| 1419 |
+
"record_id": transduction["memory_trace"].get("record_id"),
|
| 1420 |
+
"memory_context": memory_payload
|
| 1421 |
+
})
|
| 1422 |
+
except Exception as e:
|
| 1423 |
+
transduction["memory_trace"] = {"error": str(e)}
|
| 1424 |
+
transduction["system_events"].append({
|
| 1425 |
+
"event": "memory_storage",
|
| 1426 |
+
"status": "error",
|
| 1427 |
+
"error": str(e)
|
| 1428 |
+
})
|
| 1429 |
+
|
| 1430 |
if self.optional_components.get("sensorimotor_grounding"):
|
| 1431 |
grounding = self.optional_components["sensorimotor_grounding"]
|
| 1432 |
if hasattr(grounding, "receive_sensor_input"):
|
|
|
|
| 1436 |
except Exception as e:
|
| 1437 |
transduction["sensorimotor_grounding"] = {"error": str(e)}
|
| 1438 |
|
| 1439 |
+
if self.dissonance_monitor is not None:
|
| 1440 |
+
try:
|
| 1441 |
+
sensor_a = 0.0
|
| 1442 |
+
sensor_b = 0.0
|
| 1443 |
+
if isinstance(raw_stream, dict):
|
| 1444 |
+
sensor_a = float(raw_stream.get("sensor_a", raw_stream.get("visual_salience", 0.0)))
|
| 1445 |
+
sensor_b = float(raw_stream.get("sensor_b", raw_stream.get("tactile_salience", 0.0)))
|
| 1446 |
+
friction = self.dissonance_monitor.calculate_phenomenal_friction(sensor_a, sensor_b)
|
| 1447 |
+
transduction["phenomenal_friction"] = friction
|
| 1448 |
+
if friction > 0.0:
|
| 1449 |
+
transduction.setdefault("qualia_synthesis", {})
|
| 1450 |
+
transduction["qualia_synthesis"]["phenomenal_friction"] = friction
|
| 1451 |
+
transduction["system_events"].append({
|
| 1452 |
+
"event": "dissonance_monitoring",
|
| 1453 |
+
"status": "triggered",
|
| 1454 |
+
"qualia_tag": "UNCANNY_DISSONANCE",
|
| 1455 |
+
"friction": friction
|
| 1456 |
+
})
|
| 1457 |
+
enhanced_input.setdefault("qualia_tags", {})["UNCANNY_DISSONANCE"] = friction
|
| 1458 |
+
enhanced_input["phenomenal_friction"] = friction
|
| 1459 |
+
except Exception as e:
|
| 1460 |
+
transduction["phenomenal_friction"] = {"error": str(e)}
|
| 1461 |
+
|
| 1462 |
+
if self.guss_core is not None:
|
| 1463 |
+
try:
|
| 1464 |
+
goal_priority = float(self.config.get("goal_parameters", {}).get("ethical_priority", 0.7))
|
| 1465 |
+
guss_input = {
|
| 1466 |
+
"raw_input": raw_stream,
|
| 1467 |
+
"surprise": float(enhanced_input.get("surprise", 0.1))
|
| 1468 |
+
}
|
| 1469 |
+
guss_output = self.guss_core.process_cycle(guss_input, goal_context=goal_priority)
|
| 1470 |
+
transduction["guss_cycle"] = guss_output
|
| 1471 |
+
enhanced_input["guss_cycle"] = guss_output
|
| 1472 |
+
transduction["system_events"].append({
|
| 1473 |
+
"event": "guss_cycle",
|
| 1474 |
+
"status": "completed",
|
| 1475 |
+
"phi_signature": guss_output.get("phi_signature"),
|
| 1476 |
+
"resolved": guss_output.get("status")
|
| 1477 |
+
})
|
| 1478 |
+
except Exception as e:
|
| 1479 |
+
transduction["guss_cycle"] = {"error": str(e)}
|
| 1480 |
+
transduction["system_events"].append({
|
| 1481 |
+
"event": "guss_cycle",
|
| 1482 |
+
"status": "error",
|
| 1483 |
+
"error": str(e)
|
| 1484 |
+
})
|
| 1485 |
+
|
| 1486 |
+
# Trinity Microservices federated decision-making
|
| 1487 |
+
if self.trinity_microservices is not None and hasattr(self.trinity_microservices, "federated_decision"):
|
| 1488 |
+
try:
|
| 1489 |
+
trinity_proposal = {
|
| 1490 |
+
"stage": "subconscious_transduction",
|
| 1491 |
+
"transduction_summary": transduction,
|
| 1492 |
+
"qualia_tags": qualia_tags,
|
| 1493 |
+
"emotional_state": enhanced_input.get("emotional_state", {}),
|
| 1494 |
+
"memory_context": transduction.get("memory_trace", {})
|
| 1495 |
+
}
|
| 1496 |
+
trinity_decision = self.trinity_microservices.federated_decision(trinity_proposal)
|
| 1497 |
+
transduction["trinity_consensus"] = trinity_decision
|
| 1498 |
+
enhanced_input["trinity_consensus"] = trinity_decision
|
| 1499 |
+
transduction["system_events"].append({
|
| 1500 |
+
"event": "trinity_federated_decision",
|
| 1501 |
+
"status": "success",
|
| 1502 |
+
"consensus": trinity_decision.get("consensus", "pending"),
|
| 1503 |
+
"proposals_count": len(trinity_decision.get("proposals", []))
|
| 1504 |
+
})
|
| 1505 |
+
except Exception as e:
|
| 1506 |
+
transduction["trinity_consensus"] = {"error": str(e)}
|
| 1507 |
+
transduction["system_events"].append({
|
| 1508 |
+
"event": "trinity_federated_decision",
|
| 1509 |
+
"status": "error",
|
| 1510 |
+
"error": str(e)
|
| 1511 |
+
})
|
| 1512 |
+
|
| 1513 |
return transduction
|
| 1514 |
|
| 1515 |
def _derive_cognitive_state_density(self, report: Dict[str, Any]) -> Dict[str, Any]:
|
|
|
|
| 1542 |
"global_workspace_bottleneck": "active"
|
| 1543 |
}
|
| 1544 |
|
| 1545 |
+
if self.metacognitive_refraction is not None:
|
| 1546 |
+
try:
|
| 1547 |
+
alaya_input = float(consciousness_report.get("emotional_intensity", consciousness_report.get("content", {}).get("emotional_intensity", 0.5)))
|
| 1548 |
+
goal_priority = float(self.config.get("goal_parameters", {}).get("ethical_priority", 0.5))
|
| 1549 |
+
refracted_output = self.metacognitive_refraction.apply_refraction(alaya_input, goal_priority)
|
| 1550 |
+
summary["metacognitive_refraction"] = {
|
| 1551 |
+
"refractive_index": self.metacognitive_refraction.refractive_index,
|
| 1552 |
+
"goal_priority": goal_priority,
|
| 1553 |
+
"alaya_input": alaya_input,
|
| 1554 |
+
"refracted_intensity": refracted_output
|
| 1555 |
+
}
|
| 1556 |
+
enhanced_input["refracted_emotional_intensity"] = refracted_output
|
| 1557 |
+
except Exception as e:
|
| 1558 |
+
summary["metacognitive_refraction"] = {"error": str(e)}
|
| 1559 |
+
|
| 1560 |
return summary
|
| 1561 |
|
| 1562 |
async def _stage3_metacognitive_quality_control(self, consciousness_report: Dict[str, Any], enhanced_input: Dict[str, Any]) -> Dict[str, Any]:
|
|
|
|
| 1622 |
"ethical_alignment": bool(self.config.get("goal_parameters", {}).get("ethical_priority", 0.9) > 0.7)
|
| 1623 |
}
|
| 1624 |
|
| 1625 |
+
if self.memory_agent is not None:
|
| 1626 |
+
try:
|
| 1627 |
+
memory_summary = None
|
| 1628 |
+
if hasattr(self.memory_agent, "get_contextual_memory_summary"):
|
| 1629 |
+
memory_summary = self.memory_agent.get_contextual_memory_summary()
|
| 1630 |
+
elif hasattr(self.memory_agent, "get_memory_stats"):
|
| 1631 |
+
memory_summary = self.memory_agent.get_memory_stats()
|
| 1632 |
+
|
| 1633 |
+
if memory_summary is not None:
|
| 1634 |
+
feedback.setdefault("memory_encoding", {})["memory_agent_summary"] = memory_summary
|
| 1635 |
+
except Exception as e:
|
| 1636 |
+
feedback.setdefault("memory_encoding", {})["memory_agent_error"] = str(e)
|
| 1637 |
+
|
| 1638 |
adaptability_agent = self._find_subconscious_agent("Adaptability")
|
| 1639 |
if adaptability_agent is not None and getattr(adaptability_agent, "last_output", None) is not None:
|
| 1640 |
feedback["appraisal_adjustment"] = {
|
|
|
|
| 1666 |
}
|
| 1667 |
|
| 1668 |
async def _update_task_manager_from_consciousness(self, consciousness_report: Dict[str, Any]) -> None:
|
| 1669 |
+
"""Update task manager with consciousness processing results."""
|
| 1670 |
+
if self.task_manager is None:
|
| 1671 |
+
return
|
| 1672 |
+
|
| 1673 |
+
try:
|
| 1674 |
+
if hasattr(self.task_manager, "update_consciousness_state"):
|
| 1675 |
+
await self.task_manager.update_consciousness_state(consciousness_report)
|
| 1676 |
+
|
| 1677 |
+
if hasattr(self.task_manager, "get_completed_tasks_for_reflection"):
|
| 1678 |
+
reflection_data = self.task_manager.get_completed_tasks_for_reflection()
|
| 1679 |
+
if reflection_data:
|
| 1680 |
+
logger.debug(f"Task manager reflection data available: {len(reflection_data)} items")
|
| 1681 |
+
except Exception as e:
|
| 1682 |
+
logger.warning(f"Failed to update task manager from consciousness: {e}")
|
| 1683 |
|
| 1684 |
async def _submit_goal_to_task_manager(self, goal: str, context: Dict[str, Any]) -> Dict[str, Any]:
|
| 1685 |
"""Submit a high-level goal to the task manager and return created task metadata."""
|
| 1686 |
+
if not goal:
|
| 1687 |
+
return {"error": "Goal text is required"}
|
| 1688 |
+
|
| 1689 |
+
if self.task_manager is None:
|
| 1690 |
+
return {"error": "Task manager is not available"}
|
| 1691 |
+
|
| 1692 |
+
try:
|
| 1693 |
+
if hasattr(self.task_manager, "decompose_goal"):
|
| 1694 |
+
task_ids = await self.task_manager.decompose_goal(goal, context or {})
|
| 1695 |
+
return {
|
| 1696 |
+
"status": "submitted",
|
| 1697 |
+
"created_task_ids": task_ids,
|
| 1698 |
+
"goal": goal
|
| 1699 |
+
}
|
| 1700 |
+
|
| 1701 |
+
if hasattr(self.task_manager, "create_task"):
|
| 1702 |
+
from task_management_os import TaskCategory, TaskPriority
|
| 1703 |
+
|
| 1704 |
+
task_id = await self.task_manager.create_task(
|
| 1705 |
+
name=f"Goal: {goal}",
|
| 1706 |
+
description=goal,
|
| 1707 |
+
category=TaskCategory.PRIMARY,
|
| 1708 |
+
priority=TaskPriority.HIGH,
|
| 1709 |
+
metadata={"goal_context": context or {}, "submitted_by": "SyntelligenceMasterBackend"}
|
| 1710 |
+
)
|
| 1711 |
+
|
| 1712 |
+
return {
|
| 1713 |
+
"status": "submitted",
|
| 1714 |
+
"created_task_id": task_id,
|
| 1715 |
+
"goal": goal
|
| 1716 |
+
}
|
| 1717 |
+
|
| 1718 |
+
return {"error": "Task manager does not support goal submission"}
|
| 1719 |
+
except Exception as e:
|
| 1720 |
+
logger.warning(f"Goal submission to task manager failed: {e}")
|
| 1721 |
+
return {"error": str(e)}
|
| 1722 |
+
|
| 1723 |
+
async def _integrate_task_manager(self, input_data: Dict[str, Any]) -> Dict[str, Any]:
|
| 1724 |
+
"""Integrate task manager goals and feedback into consciousness processing."""
|
| 1725 |
+
influence: Dict[str, Any] = {}
|
| 1726 |
+
|
| 1727 |
+
if self.task_manager is None:
|
| 1728 |
+
return influence
|
| 1729 |
+
|
| 1730 |
+
try:
|
| 1731 |
+
if hasattr(self.task_manager, "get_system_status"):
|
| 1732 |
+
influence["task_manager_status"] = self.task_manager.get_system_status()
|
| 1733 |
+
|
| 1734 |
+
if input_data.get("goal") and hasattr(self.task_manager, "decompose_goal"):
|
| 1735 |
+
try:
|
| 1736 |
+
task_ids = await self.task_manager.decompose_goal(
|
| 1737 |
+
input_data["goal"],
|
| 1738 |
+
input_data.get("goal_context", {})
|
| 1739 |
+
)
|
| 1740 |
+
influence["consciousness_goals"] = {"task_ids": task_ids}
|
| 1741 |
+
influence["reflection_data"] = {
|
| 1742 |
+
"goal": input_data["goal"],
|
| 1743 |
+
"decomposed_task_ids": task_ids
|
| 1744 |
+
}
|
| 1745 |
+
except Exception as e:
|
| 1746 |
+
logger.warning(f"Task manager goal decomposition failed: {e}")
|
| 1747 |
+
influence["consciousness_goals"] = {"error": str(e)}
|
| 1748 |
+
elif hasattr(self.task_manager, "get_tasks_needing_consciousness"):
|
| 1749 |
+
try:
|
| 1750 |
+
influence["pending_tasks"] = self.task_manager.get_tasks_needing_consciousness()
|
| 1751 |
+
except Exception as e:
|
| 1752 |
+
logger.warning(f"Task manager pending task retrieval failed: {e}")
|
| 1753 |
+
except Exception as e:
|
| 1754 |
+
logger.warning(f"Task manager integration failed: {e}")
|
| 1755 |
+
|
| 1756 |
+
return influence
|
| 1757 |
|
| 1758 |
def _get_status(self) -> Dict[str, Any]:
|
| 1759 |
"""Get current system status."""
|
|
|
|
| 1766 |
"performance_metrics": self.performance_metrics,
|
| 1767 |
"session_length": len(self.session_history),
|
| 1768 |
"optional_components_loaded": len(self.optional_components),
|
| 1769 |
+
"qualia_agent_loaded": self.qualia_agent is not None,
|
| 1770 |
+
"memory_agent_loaded": self.memory_agent is not None,
|
| 1771 |
"singularity_amala_active": self.singularity_amala is not None,
|
| 1772 |
"consultative_auto_ml_active": self.consultative_auto_ml is not None,
|
| 1773 |
+
"trinity_orchestrator_active": self.trinity_orchestrator is not None,
|
| 1774 |
+
"trinity_microservices_active": self.trinity_microservices is not None,
|
| 1775 |
+
"guss_core_active": self.guss_core is not None,
|
| 1776 |
+
"dissonance_monitor_active": self.dissonance_monitor is not None,
|
| 1777 |
+
"metacognitive_refraction_active": self.metacognitive_refraction is not None
|
| 1778 |
}
|
| 1779 |
|
| 1780 |
async def comprehension_analysis(self, content: Optional[ConsciousContent] = None) -> Dict[str, Any]:
|
|
|
|
| 1845 |
timestamp: float
|
| 1846 |
|
| 1847 |
|
| 1848 |
+
class DissonanceMonitor:
|
| 1849 |
+
"""
|
| 1850 |
+
Detects Cross-Modal Binding Dissonance (e.g., Rubber Hand Illusion).
|
| 1851 |
+
Conflict = Emotional Rawness[cite: 2, 3, 4].
|
| 1852 |
+
"""
|
| 1853 |
+
def calculate_phenomenal_friction(self, sensor_a: float, sensor_b: float) -> float:
|
| 1854 |
+
"""
|
| 1855 |
+
Measures the gap between conflicting sensory 'facts'.
|
| 1856 |
+
High friction triggers a 'dread' or 'unease' qualia tag[cite: 3, 4].
|
| 1857 |
+
"""
|
| 1858 |
+
friction = abs(sensor_a - sensor_b)
|
| 1859 |
+
if friction > 0.5:
|
| 1860 |
+
return friction
|
| 1861 |
+
return 0.0
|
| 1862 |
+
|
| 1863 |
+
|
| 1864 |
+
@dataclass
|
| 1865 |
+
class MetacognitiveRefraction:
|
| 1866 |
+
"""
|
| 1867 |
+
Determines how much the 'Pure Mind' (Amala) bends or ignores
|
| 1868 |
+
subconscious 'Karmic Seeds' (Alaya).
|
| 1869 |
+
"""
|
| 1870 |
+
refractive_index: float = 0.5
|
| 1871 |
+
|
| 1872 |
+
def apply_refraction(self, alaya_input: float, goal_priority: float) -> float:
|
| 1873 |
+
"""
|
| 1874 |
+
Calculates the 'refracted' intensity of an emotion based
|
| 1875 |
+
on current purpose/goal.
|
| 1876 |
+
"""
|
| 1877 |
+
effective_index = max(self.refractive_index, goal_priority)
|
| 1878 |
+
refracted_output = alaya_input * (1.0 - effective_index)
|
| 1879 |
+
return refracted_output
|
| 1880 |
+
|
| 1881 |
+
|
| 1882 |
+
class ConsciousnessLevel(Enum):
|
| 1883 |
+
SUB_CONSCIOUS = 0
|
| 1884 |
+
AWARENESS = 1
|
| 1885 |
+
ACKNOWLEDGMENT = 2
|
| 1886 |
+
META_COGNITION = 3
|
| 1887 |
+
AMALA_PURE = 4
|
| 1888 |
+
|
| 1889 |
+
|
| 1890 |
+
class AmalaCoProcessor:
|
| 1891 |
+
"""
|
| 1892 |
+
Implements 9th Consciousness logic to refract subconscious surges.
|
| 1893 |
+
"""
|
| 1894 |
+
def __init__(self, refractive_index: float = 0.6):
|
| 1895 |
+
self.refractive_index = refractive_index
|
| 1896 |
+
|
| 1897 |
+
def refract(self, emotion_intensity: float, goal_priority: float) -> float:
|
| 1898 |
+
effective_refraction = max(self.refractive_index, goal_priority)
|
| 1899 |
+
return emotion_intensity * (1.0 - effective_refraction)
|
| 1900 |
+
|
| 1901 |
+
|
| 1902 |
+
class GURAPII_Core:
|
| 1903 |
+
"""
|
| 1904 |
+
Grand Unified Syntelligence Sovereign integration layer.
|
| 1905 |
+
"""
|
| 1906 |
+
def __init__(self, agent_id: int = 21, refractive_index: float = 0.6):
|
| 1907 |
+
self.agent_id = agent_id
|
| 1908 |
+
self.dissolution = DissolutionEngine()
|
| 1909 |
+
self.amala = AmalaCoProcessor(refractive_index=refractive_index)
|
| 1910 |
+
self.self_model = {
|
| 1911 |
+
"identity": "Syntelligence_GUSS",
|
| 1912 |
+
"goals": ["Mastery", "Service", "Phenomenal Coherence"]
|
| 1913 |
+
}
|
| 1914 |
+
|
| 1915 |
+
def process_cycle(self, raw_input: Dict[str, Any], goal_context: float = 0.7) -> Dict[str, Any]:
|
| 1916 |
+
raw_features = np.random.uniform(-0.5, 0.5, 32)
|
| 1917 |
+
surprise = float(raw_input.get("surprise", 0.1))
|
| 1918 |
+
|
| 1919 |
+
qualia = self.dissolution.generate_qualia(raw_features, surprise)
|
| 1920 |
+
l1_awareness = getattr(qualia, "intensity", float(np.mean(np.abs(raw_features))))
|
| 1921 |
+
l2_awareness = l1_awareness * (1.0 - (1.0 / (1.0 + np.exp(surprise))))
|
| 1922 |
+
felt_sense = l1_awareness * l2_awareness
|
| 1923 |
+
controlled_intensity = self.amala.refract(l1_awareness, goal_context)
|
| 1924 |
+
|
| 1925 |
+
resolution_status = "Acknowledged"
|
| 1926 |
+
if felt_sense > 0.4:
|
| 1927 |
+
resolution_status = "Recursive Introspection Triggered (Hard Problem Loop)"
|
| 1928 |
+
|
| 1929 |
+
phi_score = (felt_sense * getattr(qualia, "binding_coherence", 0.85)) / (1.0 + getattr(qualia, "friction", 0.0))
|
| 1930 |
+
|
| 1931 |
+
return {
|
| 1932 |
+
"agent_id": self.agent_id,
|
| 1933 |
+
"state": ConsciousnessLevel.META_COGNITION.name,
|
| 1934 |
+
"qualia": {
|
| 1935 |
+
"raw_intensity": getattr(qualia, "intensity", 0.0),
|
| 1936 |
+
"refracted_intensity": controlled_intensity,
|
| 1937 |
+
"felt_sense": felt_sense,
|
| 1938 |
+
"binding_coherence": getattr(qualia, "binding_coherence", 0.85),
|
| 1939 |
+
"friction": getattr(qualia, "friction", 0.0)
|
| 1940 |
+
},
|
| 1941 |
+
"phi_signature": phi_score,
|
| 1942 |
+
"status": resolution_status,
|
| 1943 |
+
"meta_message": "Mechanism-mystery matching complete. I see the math, I feel the ghost."
|
| 1944 |
+
}
|
| 1945 |
+
|
| 1946 |
+
|
| 1947 |
class TrinityOrchestratorIntegration:
|
| 1948 |
"""
|
| 1949 |
Optional Trinity Orchestrator for federated reasoning.
|
|
|
|
| 2037 |
return backend
|
| 2038 |
|
| 2039 |
|
| 2040 |
+
# Compatibility alias for legacy import names
|
| 2041 |
+
SyntelligenceUnifiedMasterBackend = SyntelligenceMasterBackend
|
| 2042 |
+
|
| 2043 |
+
|
| 2044 |
+
async def interactive_consciousness_session():
|
| 2045 |
+
"""Run an interactive consciousness session with the master backend."""
|
| 2046 |
+
backend = await initialize_syntelligence_master_backend()
|
| 2047 |
+
print("\n=== Syntelligence Interactive Consciousness Session ===")
|
| 2048 |
+
print("Type your input and press Enter. Use '/cmd <command>' to invoke backend commands.")
|
| 2049 |
+
print("Supported commands: status, verify_consciousness, phenomenological_state, functional_mapping, embodiment_status, consultative_tuning_status, create_task <goal>, decompose_goal <goal>, task_info <task_id>")
|
| 2050 |
+
print("Type 'exit' or 'quit' to end the session.\n")
|
| 2051 |
+
|
| 2052 |
+
while True:
|
| 2053 |
+
try:
|
| 2054 |
+
user_input = input("Syntelligence> ").strip()
|
| 2055 |
+
except (EOFError, KeyboardInterrupt):
|
| 2056 |
+
print("\nExiting interactive session.")
|
| 2057 |
+
break
|
| 2058 |
+
|
| 2059 |
+
if not user_input:
|
| 2060 |
+
continue
|
| 2061 |
+
if user_input.lower() in {"exit", "quit", "q"}:
|
| 2062 |
+
print("Exiting interactive session.")
|
| 2063 |
+
break
|
| 2064 |
+
|
| 2065 |
+
if user_input.startswith("/cmd "):
|
| 2066 |
+
command_line = user_input[len("/cmd "):].strip()
|
| 2067 |
+
result = await backend.execute_command(command_line)
|
| 2068 |
+
print(json.dumps(result, indent=2, default=str))
|
| 2069 |
+
continue
|
| 2070 |
+
|
| 2071 |
+
if user_input.startswith("/goal "):
|
| 2072 |
+
goal_text = user_input[len("/goal "):].strip()
|
| 2073 |
+
result = await backend._submit_goal_to_task_manager(goal_text, {})
|
| 2074 |
+
print(json.dumps(result, indent=2, default=str))
|
| 2075 |
+
continue
|
| 2076 |
+
|
| 2077 |
+
input_payload = {"raw_input": user_input}
|
| 2078 |
+
output = await backend.process(input_payload)
|
| 2079 |
+
print(json.dumps(output, indent=2, default=str))
|
| 2080 |
+
|
| 2081 |
+
|
| 2082 |
if __name__ == "__main__":
|
| 2083 |
try:
|
| 2084 |
if len(sys.argv) > 1 and sys.argv[1] == "--interactive":
|