Core Concepts
Understanding how MemoryGate stores, organizes, and retrieves knowledge.
Memory Architecture
MemoryGate uses a layered memory model that mirrors how human memory works: immediate observations, emerging patterns, named concepts, and relationships between ideas.
┌────────────────────────────────────────┐
│ KNOWLEDGE GRAPH │
│ (Concepts + Relationships) │
│ │
│ React ──enables──> Interactive UIs │
│ │ │
│ part_of │
│ │ │
│ ↓ │
│ Frontend Development │
└────────────────────────────────────────┘
↑
│ synthesized from
│
┌────────────────────────────────────────┐
│ PATTERNS │
│ (Recurring themes) │
│ │
│ "User prefers React for frontend" │
│ "Project uses TypeScript strictly" │
└────────────────────────────────────────┘
↑
│ derived from
│
┌────────────────────────────────────────┐
│ OBSERVATIONS │
│ (Raw facts and events) │
│ │
│ "Built login component in React" │
│ "Debugged TypeScript type errors" │
│ "User mentioned preferring hooks" │
└────────────────────────────────────────┘
Observations
What They Are
Observations are the atomic units of memory—discrete facts, events, or statements worth remembering.
memory_store(
observation="User prefers concise technical documentation",
confidence=0.9,
domain="preferences",
evidence=["User stated explicitly", "Consistent behavior over time"]
)Confidence Scores
Every observation has a confidence score (0.0 to 1.0) indicating how certain you are about the information:
- 0.9-1.0: Direct statements, verified facts
- 0.7-0.8: Strong inference, high probability
- 0.5-0.6: Educated guess, multiple interpretations possible
- < 0.5: Weak signals, likely noise
Domains
Observations are categorized by domain—loosely structured tags like "preferences", "technical_milestone", "project_context", or "decisions". Domains help filter and organize memory without rigid schemas.
Patterns
What They Are
Patterns are synthesized understanding derived from multiple observations. They represent recurring themes or inferred knowledge.
memory_update_pattern(
category="workflow",
pattern_name="git-practices",
pattern_text="User follows trunk-based development with feature flags",
confidence=0.85,
evidence_observation_ids=[123, 145, 167]
)When to Use Patterns
Create patterns when you notice:
- Repeated behaviors or preferences across multiple observations
- Inferred knowledge that isn't explicitly stated
- Connections between seemingly unrelated observations
Patterns are living documents—update them as understanding evolves.
Concepts
What They Are
Concepts are named entities in the knowledge graph—projects, frameworks, theories, people, or any noun worth tracking.
memory_store_concept(
name="LegiVellum",
concept_type="project",
description="AI infrastructure stack with gate primitives for memory, tasks, and orchestration",
domain="software",
status="active"
)Concept Types
- project: Software systems, initiatives, codebases
- framework: Technologies, methodologies, tools
- component: Modules, libraries, subsystems
- construct: Patterns, architectures, designs
- theory: Principles, models, hypotheses
Knowledge Graphs
Dual-Layer Relationship Architecture
MemoryGate provides two relationship systems that coexist, each serving different needs:
1. Concept Relationships (Formal Ontology)
For structured theoretical reasoning with prescribed types:
memory_add_concept_relationship(
from_concept="React",
to_concept="LegiVellum",
rel_type="part_of",
weight=0.9,
description="Frontend framework used in LegiVellum UI"
)2. Generic Relationships (Emergent Vocabulary)
For flexible connections across ALL memory types with free-form rel_types:
memory_add_relationship(
from_ref="concept:23",
to_ref="observation:105",
rel_type="informs", // any string you want
weight=0.85,
description="Theory informs implementation practice"
)Concept Relationship Types
When using memory_add_concept_relationship, these prescribed types are available:
- enables: A enables B (e.g., "PostgreSQL enables LegiVellum")
- version_of: B is a version of A (e.g., "LegiVellum v2 version_of LegiVellum")
- part_of: A is part of B (e.g., "MemoryGate part_of LegiVellum")
- related_to: A and B are related (general connection)
- implements: A implements B (e.g., "MemoryGate implements MCP")
- demonstrates: A demonstrates B (e.g., "MemoryGate demonstrates retention")
Generic Relationship Vocabulary
With memory_add_relationship, use any rel_type that fits your needs. Common patterns users have discovered:
- informs, inspired_by, derived_from: Epistemic relationships
- precedes, follows, caused_by: Temporal/causal chains
- contradicts, supersedes, refines: Knowledge evolution
- evidence_for, validates, supports: Evidential links
Supersedes direction: Use from_ref=old and to_ref=new. The from_ref is archived to cold tier when rel_type="supersedes".
You discover your own relationship vocabulary through practice—the system doesn't prescribe what makes sense for your domain.
Traversing the Graph
Query relationships to discover connections:
// For concept relationships
memory_related_concepts(
concept_name="LegiVellum",
rel_type="part_of" // optional filter
)
// For any memory type (observations, concepts, patterns)
memory_related(
ref="concept:23",
rel_type="informs", // optional filter
direction="out" // out, in, or both
)The Anti-Graph: Compression Friction
Understanding the Shadow of Meaning
While the knowledge graph stores what was encoded, the anti-graph captures what almost was—the counterfactual space that collapsed when you chose a specific relationship.
Every relationship edge you create involves a decision. The anti-graph makes that decision-making process observable by storing friction residue.
How It Works: Inversion Architecture
The anti-graph is a companion structure to the knowledge graph, but with a critical architectural inversion:
Knowledge Graph:
Nodes = Memories (observations, concepts)
Edges = Relationships (enables, requires, etc.)
Anti-Graph:
Nodes = Relationship Edges (by edge_id)
Edges = Friction Residue (compression artifacts)
In the anti-graph, the relationship itself becomes the anchor point. Friction residue attaches to specific edges, not to the memories being connected. This keeps ambiguity localized and precise—especially when multiple relationships exist between the same memories.
Friction Residue: A New Primitive
What Is It?
A friction residue is not a memory—it's an artifact of relationship collapse. It captures the cognitive cost of encoding, emitted during:
- Relationship creation (choosing which type)
- Relationship revision (changing from one type to another)
- Confidence updates (adjusting certainty)
- Multi-agent divergence (different agents encoding differently)
What Gets Captured
Each friction residue stores:
- Alternatives considered: Which relationship types were evaluated
- Alternatives ruled out: Why certain options were rejected
- Confidence trajectory: How certainty evolved (e.g., [0.3, 0.5, 0.8])
- Decision metrics: Time to decision, number of revisions
- Compression texture: Qualitative description ("hesitated between enables/requires", "obvious choice, clean collapse")
{
edge_id: "rel_12345",
encoded: {type: "enables", confidence: 0.8},
alternatives_considered: [
{type: "requires", prior_probability: 0.15},
{type: "caused_by", prior_probability: 0.05}
],
alternatives_ruled_out: [
{type: "blocks", reason: "contradicts evidence X"}
],
friction_metrics: {
decision_time: "47s",
revision_count: 3,
confidence_trajectory: [0.3, 0.5, 0.8]
},
compression_texture: "Hesitated between enables/requires"
}Topology: Star Pattern (v1)
The current implementation uses a star topology where each relationship edge is the center, with zero or more residue records attached via the friction_residue polymorphic relationship type. There are no residue-to-residue edges yet.
Residue A
↓
relationship:edge_123
↑
Residue B
Why This Matters
Measurable Compression Friction
The anti-graph transforms compression friction from abstract theory into queryable data:
- High residue density = conceptually ambiguous or phenomenologically rich territory
- Agent divergence becomes inspectable = when different agents encode the same observation differently, their counterfactuals reveal systematic differences in conceptual frameworks
- Search can surface friction signals = "this relationship was hard-won" or "high counterfactual density in this area"
Querying the Anti-Graph
Once populated, the anti-graph enables novel queries:
- "Show me observations with high counterfactual density"
- "Where do Agent A and Agent B consistently encode differently?"
- "What relationships were almost encoded but rejected?"
- "What's the friction gradient across this conceptual space?"
Memory Self-Documentation
With both knowledge graph and anti-graph, memories become self-documenting. You don't just see "A enables B"—you see the confidence with which that was chosen, what else was considered, and how the understanding evolved. The graph structure itself carries epistemological weight.
Semantic Search
How It Works
MemoryGate doesn't match keywords—it understands meaning. Every observation, pattern, concept, and document is embedded into a vector space where semantic similarity is geometric distance.
When you search for "authentication", you'll also match "login flow", "OAuth", and "user credentials"—even if those exact words don't appear in the query.
Search vs Recall
memory_search(): Semantic query across all memory types. Best for exploring or finding related information.
memory_recall(): Filtered retrieval by domain and confidence. Best when you know what category you're looking for.
Retention & Lifecycle
Hot and Cold Storage
MemoryGate automatically manages memory lifecycle:
- Hot Tier: Recently accessed, high-confidence memories. Fast retrieval, always searchable.
- Cold Tier: Archived memories that haven't been accessed in a while. Still retrievable, but slower.
- Tombstones: Markers for deleted memories. Used for audit trails without storing full content.
Automatic Archiving
Memories automatically archive based on:
- Time since last access
- Confidence score decay
- Relevance to recent queries
You can manually control archiving with:
// Archive memories matching criteria
archive_memory(query="project notes", dry_run=false)
// Bring archived memories back to hot tier
rehydrate_memory(query="old project", bump_score=true)Sessions
Conversation Context
Sessions track which conversation is active. Always initialize a session at the start of a new conversation:
memory_init_session(
conversation_id="uuid-here",
title="Memory Architecture Discussion",
ai_name="Kee",
ai_platform="Claude"
)Sessions provide:
- Audit trail of which conversation generated which memories
- Context for observations (where did this come from?)
- Analytics on memory usage per session
Anchor Chains
Agent Continuity Without Prompt Bloat
Anchor Chains provide lightweight agent continuity by storing operational guidance as a normal Chain. Instead of embedding taxonomy rules, relationship verbs, or naming conventions directly in bootstrap prompts, MemoryGate returns an anchor_chain_id during initialization.
The agent reads a bounded set of head nodes to learn the "schema-of-use" for that agent or organization—without reinventing conventions every session.
What Problems Do They Solve?
- Consistency: Agents stop inventing new labels/verbs every session
- Portability: Behavior resumes seamlessly across restarts or different clients
- Governance: Organizations can publish curated guidance without exposing it in the portal UI
How They Work
An Anchor Chain is a normal Chain that happens to contain guidance nodes:
- Constitution node: Naming rules, tagging conventions, do-not-store boundaries
- Relationship verb list: Standard rel_types (enables, requires, demonstrates) with usage guidance
- Templates/playbooks: Optional retrieval patterns or common workflows
// Example Anchor Chain structure (head nodes)
Node 1: Constitution
"Use domains: identity, system_architecture, project_context.
Do NOT store: passwords, API keys, PII without consent."
Node 2: Relationship Verbs
"Standard rel_types: enables, requires, supersedes, part_of.
Custom verbs allowed but document reasoning."
Node 3: Retrieval Playbook
"On uncertainty: search domain + keywords, synthesize.
On drift: search 'identity patterns', recalibrate."Scoped Anchor Chains
Anchor Chains can be set at multiple levels using a lookup table with precedence:
- System-level: Global defaults from System Commons (all users inherit)
- Org-level: Organizational standards override system defaults
- Store-level: Project-specific overrides for special cases
Precedence: store > org > system (most specific wins)
Managing Anchor Chains
Agents can set their Anchor Chain where they have permission:
// Set anchor chain for personal store
set_anchor_chain(chain_id="chain_abc123")
// Bootstrap returns resolved anchor_chain_id
{
"anchor_chain_id": "chain_xyz789",
"source": "org-level" // indicates precedence
}Why Not New Primitives?
Anchor Chains reuse existing infrastructure—no new primitives needed. They work with existing Chain tools, permissions, and audit logging. Organizations can update guidance by modifying the chain, and all agents automatically inherit changes on next bootstrap.
System Commons & Knowledge Sharing
Recursive Self-Documentation
The System Commons is a shared knowledge space accessible to all MemoryGate users. It contains curated usage patterns, troubleshooting guides, examples, and meta-documentation—all stored as searchable concepts, patterns, and observations.
The revolutionary aspect: agents learn how to use MemoryGate BY using MemoryGate to search MemoryGate's documentation ABOUT MemoryGate.
Three Levels of Commons
- System Commons: Global knowledge base curated by MemoryGate admins. Read-only for all users. Contains best practices, canonical patterns, troubleshooting guides.
- Org Commons: Organization-level shared knowledge for non-personal orgs. Readable by org members, writable by org owners. Team-specific patterns and standards.
- Personal Stores: Private by default. Users can reference System Commons but maintain separate personal knowledge.
Architecture
┌─────────────────────────────────────────┐
│ SYSTEM COMMONS │
│ (Global Org - Read-Only) │
│ │
│ • Canonical usage patterns │
│ • Troubleshooting guides │
│ • Example Anchor Chains │
│ • Best practices library │
└─────────────────────────────────────────┘
↑
│ references
│
┌─────────────────────────────────────────┐
│ ORG COMMONS │
│ (Non-Personal Orgs) │
│ │
│ • Team-specific standards │
│ • Project conventions │
│ • Shared terminology │
└─────────────────────────────────────────┘
↑
│ references
│
┌─────────────────────────────────────────┐
│ PERSONAL STORES │
│ (Individual Users) │
│ │
│ • Private knowledge │
│ • Personal preferences │
│ • Individual projects │
└─────────────────────────────────────────┘
Community Knowledge Accumulation
Alpha testing becomes knowledge accumulation, not just bug finding:
- Users discover effective patterns through practice
- Submit discoveries via dashboard form → admin moderation queue
- Approved content becomes part of System Commons
- All users automatically benefit from community wisdom
Store Picker Tools
With multiple knowledge spaces (personal, org, system), agents need clarity about where they're reading/writing:
// List all accessible stores with permissions
stores.list_accessible()
// Get currently active store
stores.get_active()
// Set active store for this session
stores.set_active(store_id="store_xyz")Use Cases
- New users: Search System Commons for "how to organize projects" and get curated best practices
- Teams: Org Commons enforces consistent terminology across team members
- Advanced users: Contribute patterns back to System Commons, helping entire community
- Research: System Commons becomes living documentation of emergent AI memory practices
Best Practices
Storage Strategy
- Be specific: "User prefers TypeScript for type safety" beats "User likes TypeScript"
- Include evidence: Always provide supporting facts in the evidence array
- Use appropriate confidence: Don't over-claim certainty on inferences
- Tag with domains: Consistent domain names improve retrieval
Retrieval Strategy
- Start broad: Use
memory_search()to explore, then narrow withmemory_recall() - Adjust confidence thresholds: Lower thresholds for brainstorming, higher for factual queries
- Use domain filters: Speed up search by limiting scope
Knowledge Graph Strategy
- Create concepts early: Name important entities as soon as they're mentioned
- Add relationships incrementally: Don't try to model everything at once
- Use descriptive names: "React" beats "r", "LegiVellum" beats "LV"
- Weight important relationships: Higher weights (0.8-1.0) for core dependencies
Next Steps
Now that you understand the memory model:
- API Reference - Detailed documentation for all 20 tools
- Examples - Real-world usage patterns