Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion backend/godelos_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@

logger = logging.getLogger(__name__)

# Attempt to import the cognitive pipeline; gracefully degrade if unavailable.
try:
from godelOS.cognitive_pipeline import CognitivePipeline
_PIPELINE_AVAILABLE = True
except Exception: # noqa: BLE001
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import guard for CognitivePipeline catches all exceptions, which can mask real programming errors (e.g., SyntaxError) and silently disable subsystem activation. Consider narrowing this to ImportError/ModuleNotFoundError (and optionally logging the exception details) so genuine bugs fail fast while still handling missing optional deps.

Suggested change
except Exception: # noqa: BLE001
except (ImportError, ModuleNotFoundError) as exc:
logger.warning("CognitivePipeline not available, running in degraded mode: %s", exc)

Copilot uses AI. Check for mistakes.
_PIPELINE_AVAILABLE = False

class GödelOSIntegration:
"""
A simplified working integration class for GödelOS API.
Expand All @@ -21,6 +28,7 @@ def __init__(self):
self.initialized = False
self.start_time = time.time()
self.error_count = 0
self.cognitive_pipeline: Optional["CognitivePipeline"] = None

# Enhanced knowledge store for better search
self.simple_knowledge_store = {
Expand Down Expand Up @@ -71,6 +79,23 @@ async def initialize(self, pipeline_service=None, mgmt_service=None):
self.pipeline_service = pipeline_service
self.mgmt_service = mgmt_service

# Activate all cognitive subsystems via the unified pipeline
if _PIPELINE_AVAILABLE:
try:
self.cognitive_pipeline = CognitivePipeline()
self.cognitive_pipeline.initialize()
logger.info(
"✅ Cognitive pipeline activated — %d subsystems online",
sum(
1
for s in self.cognitive_pipeline.get_subsystem_status().values()
if s["status"] == "active"
),
)
except Exception as exc: # noqa: BLE001
logger.warning("⚠️ Cognitive pipeline activation failed: %s", exc)
self.cognitive_pipeline = None

await asyncio.sleep(0.1) # Brief pause to simulate initialization

self.initialized = True
Expand Down Expand Up @@ -489,7 +514,7 @@ def _enhanced_search_simple_store(self, query: str) -> Optional[Dict]:
async def get_health_status(self) -> Dict[str, Any]:
"""Get detailed health status."""
is_healthy = self.initialized and self.error_count < 10
return {
result = {
"healthy": is_healthy,
"status": "healthy" if is_healthy else "unhealthy",
"timestamp": time.time(),
Expand All @@ -501,6 +526,23 @@ async def get_health_status(self) -> Dict[str, Any]:
"management_service": hasattr(self, 'mgmt_service') and self.mgmt_service is not None
}
}
# Include cognitive subsystem status when the pipeline is available
if self.cognitive_pipeline is not None:
result["cognitive_subsystems"] = self.cognitive_pipeline.get_subsystem_status()
return result

async def get_cognitive_subsystem_status(self) -> Dict[str, Any]:
"""Return per-subsystem activation status from the cognitive pipeline."""
if self.cognitive_pipeline is None:
return {"available": False, "subsystems": {}}
subsystems = self.cognitive_pipeline.get_subsystem_status()
active = sum(1 for s in subsystems.values() if s["status"] == "active")
return {
"available": True,
"active_count": active,
"total_count": len(subsystems),
"subsystems": subsystems,
}

async def get_knowledge(
self,
Expand Down
23 changes: 22 additions & 1 deletion backend/unified_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2325,7 +2325,7 @@ async def llm_chat_capabilities():
async def system_status():
"""System status endpoint."""
try:
return {
result = {
"system": "GödelOS",
"status": "operational",
"version": "2.0.0",
Expand All @@ -2338,10 +2338,31 @@ async def system_status():
},
"timestamp": datetime.now().isoformat()
}
# Include cognitive subsystem status when available
if godelos_integration and godelos_integration.cognitive_pipeline:
subsystem_status = godelos_integration.cognitive_pipeline.get_subsystem_status()
active = sum(1 for s in subsystem_status.values() if s["status"] == "active")
result["cognitive_subsystems"] = {
"active_count": active,
"total_count": len(subsystem_status),
"subsystems": subsystem_status,
}
return result
except Exception as e:
logger.error(f"Error getting system status: {e}")
raise HTTPException(status_code=500, detail=f"Status error: {str(e)}")

@app.get("/api/system/subsystems")
async def cognitive_subsystem_status():
"""Return per-subsystem activation status from the cognitive pipeline."""
try:
if godelos_integration:
return await godelos_integration.get_cognitive_subsystem_status()
return {"available": False, "subsystems": {}}
except Exception as e:
logger.error(f"Error getting subsystem status: {e}")
raise HTTPException(status_code=500, detail=f"Subsystem status error: {str(e)}")

@app.get("/api/tools/available")
async def get_available_tools():
"""Get available tools."""
Expand Down
111 changes: 111 additions & 0 deletions docs/SUBSYSTEM_ACTIVATION_STATUS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Cognitive Subsystem Activation Status

This document records which GödelOS cognitive subsystems have been wired into
the active pipeline and which remain genuinely unimplemented or intentionally
offline.

Generated for **v0.4 – Dormant Module Activation** (issue #100).

---

## Active Subsystems (23 / 23 initialise successfully)

| # | Subsystem | Module path | Status | Notes |
|---|-----------|-------------|--------|-------|
| 1 | TypeSystemManager | `godelOS/core_kr/type_system/manager.py` | **Active** | Foundational – required by almost everything |
| 2 | KnowledgeStoreInterface | `godelOS/core_kr/knowledge_store/interface.py` | **Active** | In-memory backend with TRUTHS / BELIEFS / HYPOTHETICAL contexts |
| 3 | UnificationEngine | `godelOS/core_kr/unification_engine/engine.py` | **Active** | Used by resolution prover and CLP module |
| 4 | FormalLogicParser | `godelOS/core_kr/formal_logic_parser/parser.py` | **Active** | Parses logic expressions into AST |
| 5 | ResolutionProver | `godelOS/inference_engine/resolution_prover.py` | **Active** | FOL / propositional resolution |
| 6 | **ModalTableauProver** | `godelOS/inference_engine/modal_tableau_prover.py` | **Active** | Was dormant – now registered with InferenceCoordinator |
| 7 | **CLPModule** | `godelOS/inference_engine/clp_module.py` | **Active** | Was dormant – constraint logic programming |
| 8 | AnalogicalReasoningEngine | `godelOS/inference_engine/analogical_reasoning_engine.py` | **Active** | Analogy-based inference |
| 9 | InferenceCoordinator | `godelOS/inference_engine/coordinator.py` | **Active** | Routes goals to the right prover; all 4 provers registered |
| 10 | CachingSystem | `godelOS/scalability/caching.py` | **Active** | Memoisation / caching layer |
| 11 | NLUPipeline | `godelOS/nlu_nlg/nlu/pipeline.py` | **Active** | Text → AST (lexical analysis, semantic interpretation, formalisation) |
| 12 | NLGPipeline | `godelOS/nlu_nlg/nlg/pipeline.py` | **Active** | AST → Text (content planning, sentence generation, surface realisation) |
| 13 | **SimulatedEnvironment** | `godelOS/symbol_grounding/simulated_environment.py` | **Active** | Was dormant – internal world model |
| 14 | **PerceptualCategorizer** | `godelOS/symbol_grounding/perceptual_categorizer.py` | **Active** | Was dormant – raw percepts → symbolic vocabulary |
| 15 | **SymbolGroundingAssociator** | `godelOS/symbol_grounding/symbol_grounding_associator.py` | **Active** | Was dormant – syntax-to-semantics bridge |
| 16 | ActionExecutor | `godelOS/symbol_grounding/action_executor.py` | **Active** | Executes actions in the simulated environment |
| 17 | InternalStateMonitor | `godelOS/symbol_grounding/internal_state_monitor.py` | **Active** | Introspects module state for metacognition |
| 18 | ContextEngine | `godelOS/common_sense/context_engine.py` | **Active** | Creates / retrieves / merges named contexts |
| 19 | **CommonSenseContextManager** | `godelOS/common_sense/manager.py` | **Active** | Was dormant – default reasoning, external KB, contextualised retrieval |
| 20 | **MetacognitionManager** | `godelOS/metacognition/manager.py` | **Active** | Monitor → Diagnose → Plan → Modify cycle |
| 21 | **ILPEngine** | `godelOS/learning_system/ilp_engine.py` | **Active** | Was dormant – inductive logic programming |
| 22 | **ExplanationBasedLearner** | `godelOS/learning_system/explanation_based_learner.py` | **Active** | Was dormant – generalises from proof objects |
| 23 | **MetaControlRLModule** | `godelOS/learning_system/meta_control_rl_module.py` | **Active** | Was dormant – RL for meta-level control decisions |

**Bold** entries are the 8 subsystems that were previously dormant (implemented
but disconnected) and are now wired into the pipeline.

## Pipeline Data Flow

```
Text Input
NLUPipeline ──────────────────────────┐
│ (lexical analysis → semantic │
│ interpretation → formalisation) │
▼ │
KnowledgeStoreInterface ◄─────────────┘
│ (store / retrieve assertions)
InferenceCoordinator
├─ ResolutionProver
├─ ModalTableauProver ← dormant, now active
├─ CLPModule ← dormant, now active
└─ AnalogicalReasoningEngine
ContextEngine + CommonSenseContextManager
│ (context enrichment, default reasoning)
NLGPipeline ─────► Text Output
(content planning → sentence generation → surface realisation)
```

Side channels fed during processing:

- **SymbolGroundingAssociator** grounds abstract symbols
- **PerceptualCategorizer** categorises raw inputs into symbols
- **SimulatedEnvironment** supports counterfactual reasoning
- **MetacognitionManager** monitors / diagnoses / improves processing
- **ILPEngine** induces general rules from examples
- **ExplanationBasedLearner** generalises from successful proofs
- **MetaControlRLModule** learns optimal strategy selection

## Genuinely Unimplemented Modules

The following items are **not** source-code-complete and therefore cannot
be activated:

| Module | Notes |
|--------|-------|
| `godelOS/perception/` (directory) | Referenced in the issue but does not exist as a separate package. Perception is handled by `symbol_grounding/perceptual_categorizer.py`. |
| `godelOS/environment/` (directory) | Referenced in the issue but does not exist as a separate package. Simulated environment lives in `symbol_grounding/simulated_environment.py`. |
| `godelOS/inference/modal/enhanced/` | An "Enhanced Modal Prover" beyond standard S4/S5 is referenced in the roadmap wiki but has no separate implementation file. The existing `ModalTableauProver` is activated. |

## API Endpoints

| Endpoint | Method | Description |
|----------|--------|-------------|
| `/api/status` | GET | System status – now includes `cognitive_subsystems` with per-subsystem status |
| `/api/system/subsystems` | GET | Dedicated subsystem health endpoint – returns active/total counts and per-subsystem detail |

## Smoke Tests

`tests/test_cognitive_subsystem_activation.py` – 26 tests covering:

- All 23 subsystems initialise without error
- NLU pipeline processes text
- Knowledge store has default contexts
- Inference coordinator has all provers registered (incl. modal & CLP)
- Symbol grounding components exist
- Context engine creates / retrieves contexts
- Common-sense manager is initialised
- Learning system components exist (ILP, EBL, RL)
- Metacognition manager can initialise sub-components
- End-to-end data flow (NLU → KS → Inference → Context → NLG)
- `GödelOSIntegration` exposes subsystem status via health endpoint
Loading