v0.1 - Declarative Memory Modeling Language for AI Agents
MemoryML (MML) is a declarative language for defining agent memory schemas, storage mappings, and retrieval strategies. Inspired by LookML's semantic layer approach, MML provides a code-first abstraction over diverse storage backends.
1. DEFINE (Dev Time) 2. COMPILE (Build) 3. RUNTIME (Execution)
types/*.mml --> MML Parser --> Schema Validator
explores/*.mml --> Compiled --> Backend Router
backends/*.yaml --> Schema --> Storage Layer
Traditional memory systems hardcode storage logic:
# Imperative (current engram)
memory.add(text, user_id=user, metadata={"type": "preference"})
MemoryML separates concerns:
# Declarative (MemoryML)
# types/semantic.mml defines WHAT
# backends/production.yaml defines WHERE
# Application just calls: add_memory(text, type="semantic")
memory/
├── memory.yaml # Root project configuration
├── types/ # Memory type definitions
│ ├── episodic.mml
│ ├── semantic.mml
│ └── procedural.mml
├── explores/ # Combined retrieval views
│ └── project_context.mml
├── backends/ # Backend configurations
│ ├── development.yaml
│ └── production.yaml
├── policies/ # Retention and privacy
│ └── retention.yaml
└── tests/ # Schema tests
└── schema_tests.yaml
memory_type: episodic
version: "1.0"
schema:
required:
timestamp:
type: datetime
index: temporal
content:
type: text
embedding: true
session_id:
type: uuid
computed:
recency_score:
expression: "EXP(-(NOW() - timestamp) / 604800)"
storage:
primary_backend: vector
retention:
default: 90d
summarized_after: 30d
memory_type: semantic
version: "1.0"
schema:
required:
subject:
type: text
embedding: true
index: hash
predicate:
type: text
enum: [prefers, knows, uses, dislikes, ...]
object:
type: text
embedding: true
relationships:
- name: related_to
target_type: semantic
cardinality: many_to_many
memory_type: procedural
version: "1.0"
schema:
required:
pattern_name:
type: text
index: hash
trigger_conditions:
type: json
action_sequence:
type: json
effectiveness_score:
type: float
range: [0, 1]
Explores define combined retrieval views across memory types:
explore: project_context
sources:
- type: episodic
filter: "timestamp > NOW() - INTERVAL '7 days'"
- type: semantic
filter: "is_current = true"
- type: procedural
filter: "effectiveness_score > 0.5"
retrieval:
method: hybrid
components:
- type: vector_search
weight: 0.6
- type: graph_traversal
weight: 0.3
- type: recency
weight: 0.1
token_budget: 4000
| Backend | Type | Use Case |
|---|---|---|
| pgvector | vector | Production semantic search |
| redis | graph | Relationship traversal |
| sqlite | relational | Development, lightweight |
| redis | cache | Hot memory caching |
mml validate # Validate all .mml files
mml compile --backend=prod # Generate migrations
mml test # Run schema tests
mml migrate # Apply migrations
mml export --format=jsonld # Export for portability
| Tool | Description |
|---|---|
add_memory |
Store memory with type validation |
search_memories |
Hybrid search via explores |
link_memories |
Create typed relationships |
get_related |
Graph traversal |
analyze_intelligence |
Knowledge graph health report |
View Full SpecificationFor the complete specification including all schema definitions, policy configurations, test formats, and JSON-LD export structure, see the full markdown spec.