claude-configs/skills/_archive/memorygraph/SCHEMA.md
Cal Corum 807c6978e5 Archive legacy memorygraph skill
- Move skills/memorygraph/ to skills/_archive/memorygraph/
- Saves ~67 tokens per session from skill loading

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 08:13:11 -06:00

198 lines
4.9 KiB
Markdown

# MemoryGraph SQLite Schema
**Database Location**: `~/.memorygraph/memory.db`
## Tables
### nodes
Stores all memory entries.
| Column | Type | Description |
|--------|------|-------------|
| id | TEXT PRIMARY KEY | UUID identifier |
| label | TEXT NOT NULL | Always "Memory" for memory nodes |
| properties | TEXT NOT NULL | JSON blob containing all memory fields |
| created_at | TIMESTAMP | Auto-set on creation |
| updated_at | TIMESTAMP | Auto-set on update |
**Indexes**:
- `idx_nodes_label` - Label lookup
- `idx_nodes_created` - Chronological queries
- `idx_nodes_memory` - Memory-specific queries (WHERE label = 'Memory')
### relationships
Stores typed connections between memories.
| Column | Type | Description |
|--------|------|-------------|
| id | TEXT PRIMARY KEY | UUID identifier |
| from_id | TEXT NOT NULL | Source memory ID (FK to nodes) |
| to_id | TEXT NOT NULL | Target memory ID (FK to nodes) |
| rel_type | TEXT NOT NULL | Relationship type (SOLVES, CAUSES, etc.) |
| properties | TEXT NOT NULL | JSON blob with strength, confidence, context |
| created_at | TIMESTAMP | Auto-set on creation |
**Indexes**:
- `idx_rel_from` - Outgoing relationships
- `idx_rel_to` - Incoming relationships
- `idx_rel_type` - Relationship type queries
### nodes_fts
FTS5 virtual table for full-text search.
| Column | Type | Description |
|--------|------|-------------|
| id | TEXT | Memory ID |
| title | TEXT | Memory title |
| content | TEXT | Memory content |
| summary | TEXT | Memory summary |
---
## Memory Properties (JSON in nodes.properties)
```json
{
"id": "uuid",
"type": "solution|problem|error|fix|...",
"title": "Short descriptive title",
"content": "Detailed content",
"summary": "Optional brief summary",
"tags": ["tag1", "tag2"],
"importance": 0.5,
"confidence": 0.8,
"usage_count": 0,
"created_at": "ISO timestamp",
"updated_at": "ISO timestamp"
}
```
### Memory Types
| Type | Description |
|------|-------------|
| `solution` | Fix or solution to a problem |
| `problem` | Issue or challenge encountered |
| `error` | Specific error message or condition |
| `fix` | Code-level fix or patch |
| `code_pattern` | Reusable code pattern |
| `decision` | Architectural or design decision |
| `configuration` | Configuration that worked |
| `workflow` | Process or workflow pattern |
| `task` | Task or todo item |
| `project` | Project context |
| `technology` | Technology notes |
| `command` | Useful command |
| `file_context` | File-specific context |
| `general` | General memory |
---
## Relationship Properties (JSON in relationships.properties)
```json
{
"id": "uuid",
"strength": 0.5,
"confidence": 0.8,
"context": "{\"text\": \"...\", \"components\": [...]}",
"evidence_count": 1,
"success_rate": null,
"created_at": "ISO timestamp",
"last_validated": "ISO timestamp",
"validation_count": 0,
"counter_evidence_count": 0
}
```
### Relationship Types
**Causal**
- `CAUSES` - A causes B
- `TRIGGERS` - A triggers B
- `LEADS_TO` - A leads to B
- `PREVENTS` - A prevents B
- `BREAKS` - A breaks B
**Solution**
- `SOLVES` - A solves B (most common)
- `ADDRESSES` - A addresses B
- `ALTERNATIVE_TO` - A is alternative to B
- `IMPROVES` - A improves B
- `REPLACES` - A replaces B
**Context**
- `OCCURS_IN` - A occurs in B
- `APPLIES_TO` - A applies to B
- `WORKS_WITH` - A works with B
- `REQUIRES` - A requires B
- `USED_IN` - A used in B
**Learning**
- `BUILDS_ON` - A builds on B
- `CONTRADICTS` - A contradicts B
- `CONFIRMS` - A confirms B
- `GENERALIZES` - A generalizes B
- `SPECIALIZES` - A specializes B
**Similarity**
- `SIMILAR_TO` - A similar to B
- `VARIANT_OF` - A variant of B
- `RELATED_TO` - A related to B (general)
- `ANALOGY_TO` - A analogy to B
- `OPPOSITE_OF` - A opposite of B
**Workflow**
- `FOLLOWS` - A follows B
- `DEPENDS_ON` - A depends on B
- `ENABLES` - A enables B
- `BLOCKS` - A blocks B
- `PARALLEL_TO` - A parallel to B
**Quality**
- `EFFECTIVE_FOR` - A effective for B
- `INEFFECTIVE_FOR` - A ineffective for B
- `PREFERRED_OVER` - A preferred over B
- `DEPRECATED_BY` - A deprecated by B
- `VALIDATED_BY` - A validated by B
---
## Common Queries
### Get all memories
```sql
SELECT id, properties FROM nodes WHERE label = 'Memory';
```
### Search by title/content (FTS)
```sql
SELECT n.id, n.properties
FROM nodes n
JOIN nodes_fts fts ON n.id = fts.id
WHERE nodes_fts MATCH 'search term';
```
### Get memory with relationships
```sql
SELECT n.properties,
r.rel_type,
r.properties as rel_props,
n2.properties as related_memory
FROM nodes n
LEFT JOIN relationships r ON n.id = r.from_id OR n.id = r.to_id
LEFT JOIN nodes n2 ON (r.from_id = n2.id OR r.to_id = n2.id) AND n2.id != n.id
WHERE n.id = 'memory-uuid';
```
### Find solutions for a problem
```sql
SELECT n.properties
FROM nodes n
JOIN relationships r ON n.id = r.from_id
WHERE r.to_id = 'problem-uuid' AND r.rel_type = 'SOLVES';
```
---
*Generated: 2025-12-07*