Skip to content

Commit fa542b1

Browse files
author
Your Name
committed
fix tests and README.md
1 parent eba8a3f commit fa542b1

File tree

5 files changed

+2343
-752
lines changed

5 files changed

+2343
-752
lines changed

README.md

Lines changed: 163 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,26 @@ This system provides a comprehensive memory management solution for AGI applicat
4848
- Context applicability
4949
- Success metrics
5050

51+
### Advanced Features
52+
53+
**Memory Clustering:**
54+
- Automatic thematic grouping of related memories
55+
- Emotional signature tracking
56+
- Cross-cluster relationship mapping
57+
- Activation pattern analysis
58+
59+
**Worldview Integration:**
60+
- Belief system modeling with confidence scores
61+
- Memory filtering based on worldview alignment
62+
- Identity-core memory cluster identification
63+
- Adaptive memory importance based on beliefs
64+
65+
**Graph Relationships:**
66+
- Apache AGE integration for complex memory networks
67+
- Multi-hop relationship traversal
68+
- Pattern detection across memory types
69+
- Causal relationship modeling
70+
5171
### Key Features
5272

5373
- **Vector Embeddings**: Uses pgvector for similarity-based memory retrieval
@@ -65,9 +85,45 @@ This system provides a comprehensive memory management solution for AGI applicat
6585
- pg_trgm
6686
- cube
6787

68-
## Setup
88+
## Dependencies
89+
90+
### Python Requirements
91+
- asyncpg>=0.29.0 (PostgreSQL async driver)
92+
- pytest>=7.4.3 (testing framework)
93+
- numpy>=1.24.0 (numerical operations)
94+
- fastapi>=0.104.0 (web framework)
95+
- pydantic>=2.4.2 (data validation)
96+
97+
### Node.js Requirements
98+
- @modelcontextprotocol/sdk (MCP framework)
99+
- pg (PostgreSQL driver)
100+
101+
### Database Extensions
102+
- pgvector (vector similarity)
103+
- AGE (graph database)
104+
- pg_trgm (text search)
105+
- btree_gist (indexing)
106+
- cube (multidimensional indexing)
107+
108+
## Environment Configuration
109+
110+
Copy `.env.local` to `.env` and configure:
69111

112+
```bash
113+
POSTGRES_DB=agi_db # Database name
114+
POSTGRES_USER=agi_user # Database user
115+
POSTGRES_PASSWORD=agi_password # Database password
70116
```
117+
118+
For MCP server, also set:
119+
```bash
120+
POSTGRES_HOST=localhost # Database host
121+
POSTGRES_PORT=5432 # Database port
122+
```
123+
124+
## Setup
125+
126+
```bash
71127
cp .env.local .env # modify the .env file with your own values
72128
docker compose up -d
73129
```
@@ -81,7 +137,61 @@ This will:
81137

82138
Run the test suite with:
83139

84-
`pytest test.py -v`
140+
```bash
141+
pytest test.py -v
142+
```
143+
144+
## API Reference (MCP Tools)
145+
146+
### Memory Operations
147+
- `create_memory(type, content, embedding, importance, metadata)` - Create new memories
148+
- `get_memory(memory_id)` - Retrieve and access specific memory
149+
- `search_memories_similarity(embedding, limit, threshold)` - Vector similarity search
150+
- `search_memories_text(query, limit)` - Full-text search
151+
152+
### Cluster Operations
153+
- `get_memory_clusters(limit)` - List memory clusters by importance
154+
- `activate_cluster(cluster_id, context)` - Activate cluster and get memories
155+
- `create_memory_cluster(name, type, description, keywords)` - Create new cluster
156+
157+
### System Introspection
158+
- `get_identity_core()` - Retrieve identity model and core clusters
159+
- `get_worldview()` - Get worldview primitives and beliefs
160+
- `get_memory_health()` - System health statistics
161+
- `get_active_themes(days)` - Recently activated themes
162+
163+
## Usage Examples
164+
165+
### Creating Memories
166+
```python
167+
# Via MCP tools
168+
memory = await create_memory(
169+
type="episodic",
170+
content="User expressed interest in machine learning",
171+
embedding=embedding_vector,
172+
importance=0.8,
173+
metadata={
174+
"emotional_valence": 0.6,
175+
"context": {"topic": "AI", "user_mood": "curious"}
176+
}
177+
)
178+
```
179+
180+
### Searching Memories
181+
```python
182+
# Similarity search
183+
similar = await search_memories_similarity(
184+
embedding=query_vector,
185+
limit=10,
186+
threshold=0.7
187+
)
188+
189+
# Text search
190+
results = await search_memories_text(
191+
query="machine learning concepts",
192+
limit=5
193+
)
194+
```
85195

86196
## Database Schema
87197

@@ -91,7 +201,7 @@ Run the test suite with:
91201
- Vector embeddings for similarity search
92202
- Priority scoring for attention mechanisms
93203

94-
2. **long_term_memory**
204+
2. **memories**
95205
- Permanent storage for consolidated memories
96206
- Links to specific memory type tables
97207
- Metadata tracking (creation, modification, access)
@@ -103,10 +213,22 @@ Run the test suite with:
103213

104214
### Memory Type Tables
105215
Each specialized memory type has its own table with type-specific fields:
106-
- episodic_memory
107-
- semantic_memory
108-
- procedural_memory
109-
- strategic_memory
216+
- episodic_memories
217+
- semantic_memories
218+
- procedural_memories
219+
- strategic_memories
220+
221+
### Clustering Tables
222+
- memory_clusters
223+
- memory_cluster_members
224+
- cluster_relationships
225+
- cluster_activation_history
226+
227+
### Identity and Worldview Tables
228+
- identity_model
229+
- worldview_primitives
230+
- worldview_memory_influences
231+
- identity_memory_resonance
110232

111233
### Indexes and Constraints
112234
- Vector indexes for similarity search
@@ -118,7 +240,7 @@ Each specialized memory type has its own table with type-specific fields:
118240
### Memory Retrieval
119241
```sql
120242
-- Find similar memories using vector similarity
121-
SELECT * FROM long_term_memory
243+
SELECT * FROM memories
122244
WHERE embedding <-> query_embedding < threshold
123245
ORDER BY embedding <-> query_embedding
124246
LIMIT 10;
@@ -131,6 +253,18 @@ SELECT * FROM ag_catalog.cypher('memory_graph', $$
131253
$$) as (related agtype);
132254
```
133255

256+
## Performance Characteristics
257+
258+
- **Vector Search**: Sub-second similarity queries on 10K+ memories
259+
- **Memory Storage**: Supports millions of memories with proper indexing
260+
- **Cluster Operations**: Efficient graph traversal for relationship queries
261+
- **Maintenance**: Requires periodic consolidation and pruning
262+
263+
### Scaling Considerations
264+
- Memory consolidation recommended every 4-6 hours
265+
- Database optimization during off-peak hours
266+
- Monitor vector index performance with large datasets
267+
134268
## System Maintenance
135269

136270
The memory system requires three key maintenance processes to function effectively:
@@ -161,6 +295,25 @@ These maintenance tasks can be implemented using:
161295

162296
Choose the scheduling method that best fits your infrastructure and monitoring capabilities. Ensure proper logging and error handling for all maintenance operations.
163297

298+
## Troubleshooting
299+
300+
### Common Issues
301+
302+
**Database Connection Errors:**
303+
- Ensure PostgreSQL is running: `docker compose ps`
304+
- Check logs: `docker compose logs db`
305+
- Verify extensions: Run test suite with `pytest test.py -v`
306+
307+
**Memory Search Performance:**
308+
- Rebuild vector indexes if queries are slow
309+
- Check memory_health view for system statistics
310+
- Consider memory pruning if dataset is very large
311+
312+
**MCP Server Issues:**
313+
- Verify Node.js dependencies: `npm install`
314+
- Check database connectivity from MCP server
315+
- Ensure environment variables are set correctly
316+
164317
## Usage Guide
165318

166319
### Memory Interaction Flow
@@ -212,7 +365,7 @@ graph TD
212365

213366
### Key Integration Points
214367

215-
- Use the API for all memory operations
368+
- Use the MCP API for all memory operations
216369
- Implement proper error handling for failed operations
217370
- Monitor memory usage and system performance
218371
- Regular backup of critical memories
@@ -234,4 +387,4 @@ This database schema is designed for a single AGI instance. Supporting multiple
234387
- Separate working memory spaces per AGI
235388
- Additional access controls and memory ownership
236389

237-
If you need multi-AGI support, consider refactoring the schema to include tenant isolation patterns before implementation.
390+
If you need multi-AGI support, consider refactoring the schema to include tenant isolation patterns before implementation.

0 commit comments

Comments
 (0)