Skip to content

Commit fa9b74b

Browse files
JuanCS-Devclaude
andcommitted
docs: Update service READMEs with accurate documentation
## metacognitive_reflector/README.md (23 → 175 lines) - Add Tribunal system (3 judges: VERITAS, SOPHIA, DIKĒ) - Document all API endpoints (/reflect, /verdict, /agent/*) - Add Self-Reflection Engine details - Document Memory integration (4-tier) - Add offense levels and punishment system ## episodic_memory/README.md (24 → 229 lines) - Correct database: Qdrant (not ChromaDB) - Document Memory Types (MIRIX: CORE, EPISODIC, SEMANTIC, etc) - Add 4-tier Memory Fortress architecture - Document all endpoints (12 total) - Add Entity Index and decay curve details ## api_gateway/README.md (23 → 141 lines) - Add service routing table (local + Docker) - Document request flow diagram - Add configuration options - Document error responses ## consciousness/README.md - Fix port: 8001 (was 8000) - Add Neuromodulation System (4 modulators) - Add Soul Configuration section - Add Free Will Engine section - Update date to 2025-12-12 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 55c6827 commit fa9b74b

File tree

4 files changed

+540
-37
lines changed

4 files changed

+540
-37
lines changed
Lines changed: 127 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,140 @@
11
# API Gateway Service
22

3-
Minimalist gateway to route external requests to internal services.
3+
**Port:** 8000
4+
**Status:** Production-Ready
5+
**Updated:** 2025-12-12
6+
7+
Reverse proxy gateway that routes external requests to internal NOESIS microservices.
8+
9+
---
10+
11+
## Architecture
12+
13+
```
14+
api_gateway/
15+
├── src/api_gateway/
16+
│ ├── core/
17+
│ │ └── proxy.py # Service routing logic
18+
│ └── main.py # FastAPI application
19+
```
20+
21+
---
22+
23+
## Service Routing
24+
25+
### Local Development Mode
26+
27+
| Route | Service | Port |
28+
|-------|---------|------|
29+
| `/api/consciousness/*` | maximus_core_service | 8001 |
30+
| `/api/memory/*` | episodic_memory | 8102 |
31+
| `/api/reflect/*` | metacognitive_reflector | 8002 |
32+
| `/api/ethics/*` | ethical_audit_service | 8006 |
33+
| `/api/executive/*` | prefrontal_cortex_service | 8005 |
34+
35+
### Docker Mode
36+
37+
In Docker, services use internal DNS names on port 8000:
38+
39+
```python
40+
services = {
41+
"maximus_core_service": "http://maximus_core:8000",
42+
"episodic_memory": "http://episodic_memory:8000",
43+
"metacognitive_reflector": "http://metacognitive_reflector:8000",
44+
"ethical_audit_service": "http://ethical_audit:8000",
45+
"prefrontal_cortex_service": "http://prefrontal_cortex:8000",
46+
}
47+
```
48+
49+
---
50+
51+
## Features
52+
53+
- **Request Forwarding**: Routes to appropriate backend service
54+
- **Connection Pooling**: 20 keep-alive connections
55+
- **Timeout Management**: 30s total, 10s connect
56+
- **Error Handling**: 502 for upstream failures, 404 for unknown services
57+
58+
---
59+
60+
## API Endpoints
61+
62+
```
63+
GET /health → Gateway health check
64+
ANY /api/{service}/* → Forward to service
65+
```
66+
67+
---
468

569
## Quick Start
670

771
```bash
8-
# Run service
9-
python -m backend.services.api_gateway.main
10-
```
72+
# Run gateway
73+
cd backend/services/api_gateway
74+
PYTHONPATH=src python -m uvicorn api_gateway.main:app --port 8000
1175

12-
## Architecture
76+
# Health check
77+
curl http://localhost:8000/health
1378

14-
Acts as a reverse proxy. Handles authentication and rate limiting.
79+
# Forward to consciousness
80+
curl http://localhost:8000/api/consciousness/v1/health
1581

16-
## API
82+
# Forward to memory
83+
curl http://localhost:8000/api/memory/v1/memories/stats
84+
```
1785

18-
- Routes requests to `/api/v1/{service_name}`.
86+
---
1987

2088
## Configuration
2189

22-
- `SERVICES_MAP`: Mapping of service names to internal URLs.
90+
```bash
91+
# Environment Variables
92+
API_GATEWAY_PORT=8000
93+
DOCKER_ENV=false # Set to "true" in Docker
94+
95+
# Timeouts (in proxy.py)
96+
REQUEST_TIMEOUT=30.0 # Total request timeout
97+
CONNECT_TIMEOUT=10.0 # Connection timeout
98+
MAX_KEEPALIVE=20 # Connection pool size
99+
```
100+
101+
---
102+
103+
## Request Flow
104+
105+
```
106+
Client Request
107+
108+
109+
┌─────────────────┐
110+
│ API Gateway │ Port 8000
111+
│ (FastAPI) │
112+
└────────┬────────┘
113+
114+
Route by path
115+
116+
┌────┴────┬──────────┬──────────┐
117+
▼ ▼ ▼ ▼
118+
┌───────┐ ┌───────┐ ┌───────┐ ┌───────┐
119+
│Maximus│ │Memory │ │Reflect│ │Ethics │
120+
│ :8001 │ │ :8102 │ │ :8002 │ │ :8006 │
121+
└───────┘ └───────┘ └───────┘ └───────┘
122+
```
123+
124+
---
125+
126+
## Error Responses
127+
128+
| Code | Meaning |
129+
|------|---------|
130+
| 404 | Service not found in routing table |
131+
| 502 | Upstream service unavailable |
132+
| 500 | Internal gateway error |
133+
134+
---
135+
136+
## Related Documentation
137+
138+
- [Maximus Core](../maximus_core_service/src/maximus_core_service/consciousness/README.md)
139+
- [Episodic Memory](../episodic_memory/README.md)
140+
- [Metacognitive Reflector](../metacognitive_reflector/README.md)
Lines changed: 214 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,228 @@
11
# Episodic Memory Service
22

3-
Stores and retrieves past experiences to provide context for current actions.
3+
**Port:** 8102
4+
**Database:** Qdrant (Vector DB)
5+
**Status:** Production-Ready
6+
**Updated:** 2025-12-12
7+
8+
Persistent memory storage for the NOESIS consciousness system. Implements a **4-tier Memory Fortress** architecture with semantic search capabilities.
9+
10+
---
11+
12+
## Architecture
13+
14+
```
15+
episodic_memory/
16+
├── api/
17+
│ └── routes.py # FastAPI endpoints
18+
├── core/
19+
│ ├── qdrant_client.py # Vector database client
20+
│ ├── entity_index.py # Entity extraction & indexing
21+
│ ├── memory_store.py # Memory CRUD operations
22+
│ ├── persistent_store.py # Disk persistence
23+
│ ├── hierarchy.py # 4-tier cache hierarchy
24+
│ └── context_builder.py # Context assembly for LLM
25+
└── models/
26+
└── memory.py # Memory data models
27+
```
28+
29+
---
30+
31+
## Memory Types (MIRIX)
32+
33+
| Type | Purpose | Persistence | Priority |
34+
|------|---------|-------------|----------|
35+
| **CORE** | Identity, immutable facts | Permanent | 5 (highest) |
36+
| **EPISODIC** | Specific events, experiences | Decayable | 10 |
37+
| **SEMANTIC** | General knowledge, facts | Long-term | 8 |
38+
| **PROCEDURAL** | Skills, how-to knowledge | Long-term | 5 |
39+
| **RESOURCE** | External references | Medium-term | 3 |
40+
| **VAULT** | High-confidence, consolidated | Permanent | 5 |
41+
42+
---
43+
44+
## 4-Tier Memory Fortress
45+
46+
```
47+
┌─────────────────────────────────────────────────────────────┐
48+
│ L1: HOT CACHE (In-Memory LRU) │
49+
│ Latency: <1ms | Max: 1000 entries | TTL: 300s │
50+
│ Contents: CORE + VAULT (critical memories) │
51+
├─────────────────────────────────────────────────────────────┤
52+
│ L2: WARM STORAGE (Redis + AOF) │
53+
│ Latency: <10ms | Persistence: AOF log │
54+
│ Contents: Recent EPISODIC + SEMANTIC │
55+
├─────────────────────────────────────────────────────────────┤
56+
│ L3: COLD STORAGE (Qdrant via HTTP) │
57+
│ Latency: <50ms | Semantic search enabled │
58+
│ Contents: All memory types, vector embeddings │
59+
├─────────────────────────────────────────────────────────────┤
60+
│ L4: VAULT BACKUP (JSON + Checksums) │
61+
│ Sync: Every 5 min | Path: data/vault/ │
62+
│ Contents: Disaster recovery snapshots │
63+
└─────────────────────────────────────────────────────────────┘
64+
```
65+
66+
---
67+
68+
## API Endpoints
69+
70+
### Health
71+
72+
```
73+
GET /health → Service health check
74+
```
75+
76+
### Memory CRUD
77+
78+
```
79+
POST /v1/memories → Store new memory
80+
GET /v1/memories/{id} → Get memory by ID
81+
DELETE /v1/memories/{id} → Delete memory
82+
GET /v1/memories/type/{type} → Get memories by type
83+
GET /v1/memories/stats → Memory statistics
84+
```
85+
86+
### Search & Context
87+
88+
```
89+
POST /v1/memories/search → Semantic search (vector similarity)
90+
POST /v1/memories/context → Build LLM context from memories
91+
```
92+
93+
### Maintenance
94+
95+
```
96+
POST /v1/memories/consolidate → Move old memories to VAULT
97+
POST /v1/memories/decay → Apply forgetting curve
98+
POST /v1/memories/sync → Sync with persistent storage
99+
```
100+
101+
---
102+
103+
## Qdrant Configuration
104+
105+
```python
106+
# Collection: maximus_episodic_memory
107+
# Vector size: 1536 (OpenAI embeddings)
108+
# Distance: Cosine similarity
109+
# Quantization: int8 (99th percentile) → 3x memory reduction
110+
111+
QDRANT_URL = "http://localhost:6333"
112+
COLLECTION_NAME = "maximus_episodic_memory"
113+
VECTOR_SIZE = 1536
114+
```
115+
116+
---
117+
118+
## Entity Index
119+
120+
Automatic entity extraction for fast retrieval:
121+
122+
```python
123+
# Extracts:
124+
# - Proper nouns (capitalized words)
125+
# - Technical terms
126+
# - Quoted strings
127+
# - Keywords
128+
129+
# Creates inverted index:
130+
# entity → [memory_id_1, memory_id_2, ...]
131+
132+
# Storage: data/entity_index.json
133+
```
134+
135+
---
136+
137+
## Memory Decay (Forgetting Curve)
138+
139+
Implements Ebbinghaus forgetting curve:
140+
141+
```python
142+
# Decay formula
143+
retention = e^(-t/S)
144+
145+
# Where:
146+
# t = time since last access
147+
# S = memory strength (based on access count)
148+
149+
# Memories below threshold are candidates for:
150+
# 1. Consolidation to VAULT (if high value)
151+
# 2. Deletion (if low value)
152+
```
153+
154+
---
4155

5156
## Quick Start
6157

7158
```bash
159+
# Start Qdrant
160+
docker run -p 6333:6333 qdrant/qdrant
161+
8162
# Run service
9-
python -m backend.services.episodic_memory.main
10-
```
163+
cd backend/services/episodic_memory
164+
PYTHONPATH=src python -m uvicorn episodic_memory.main:app --port 8102
11165

12-
## Architecture
166+
# Health check
167+
curl http://localhost:8102/health
13168

14-
Uses a vector database (e.g., ChromaDB or Qdrant) to store embeddings of events.
169+
# Store memory
170+
curl -X POST http://localhost:8102/v1/memories \
171+
-H "Content-Type: application/json" \
172+
-d '{
173+
"content": "User prefers dark mode",
174+
"type": "SEMANTIC",
175+
"importance": 0.8
176+
}'
15177

16-
## API
178+
# Search
179+
curl -X POST http://localhost:8102/v1/memories/search \
180+
-H "Content-Type: application/json" \
181+
-d '{"query": "user preferences", "limit": 5}'
182+
```
17183

18-
- `POST /remember`: Store a new memory.
19-
- `GET /recall`: Retrieve relevant memories.
184+
---
20185

21186
## Configuration
22187

23-
- `VECTOR_DB_URL`: URL of the vector database.
188+
```bash
189+
# Environment Variables
190+
EPISODIC_MEMORY_PORT=8102
191+
QDRANT_URL=http://localhost:6333
192+
EMBEDDING_MODEL=text-embedding-ada-002
193+
DATA_DIR=./data
194+
```
195+
196+
---
197+
198+
## Guarantees
199+
200+
| Metric | Target |
201+
|--------|--------|
202+
| L1 Latency | <1ms |
203+
| L3 Latency | <50ms |
204+
| Durability | 99.99% |
205+
| Recovery Time | <30s |
206+
| Checksum Pass | 100% |
207+
208+
---
209+
210+
## Integration with Consciousness
211+
212+
```
213+
Consciousness Pipeline:
214+
1. User input received
215+
2. Context built from relevant memories
216+
3. ESGT ignition with memory context
217+
4. LLM generates response
218+
5. New memories stored (insights, facts learned)
219+
6. Memories consolidated periodically
220+
```
221+
222+
---
223+
224+
## Related Documentation
225+
226+
- [Memory Fortress](../../../docs/MEMORY_FORTRESS.md)
227+
- [Metacognitive Reflector](../metacognitive_reflector/README.md)
228+
- [Consciousness System](../maximus_core_service/src/maximus_core_service/consciousness/README.md)

0 commit comments

Comments
 (0)