Knowledge Cores as Modular Memory
Understand how Knowledge Cores provide modular, swappable Knowledge Graph storage for AI agents. Learn to organize, version, and manage multiple knowledge bases.
Knowledge Cores as Modular Memory
Knowledge Cores are modular, isolated Knowledge Graph instances that serve as swappable memory units for AI agents and applications. Each Knowledge Core contains a complete, independent graph of entities and relationships, enabling multi-tenancy, version control, and specialized knowledge domains within a single TrustGraph deployment.
What Are Knowledge Cores?
Think of Knowledge Cores as self-contained memory modules for your AI system:
// A Knowledge Core is an isolated graph instance
const knowledgeCore = {
id: "core_production_v1",
name: "Production Knowledge Base",
type: "graph_database",
// Complete graph instance
storage: {
nodes: 1_000_000,
edges: 5_000_000,
properties: 10_000_000
},
// Metadata
version: "1.0.0",
created: "2025-01-01",
lastModified: "2025-12-24",
// Access control
permissions: {
read: ["agent_1", "agent_2"],
write: ["agent_1"],
admin: ["user_123"]
},
// Backend configuration
backend: {
type: "cassandra",
cluster: ["node1:9042", "node2:9042", "node3:9042"],
keyspace: "trustgraph_production"
}
};
Key characteristics:
- Isolated: Each core is completely independent
- Swappable: Switch between cores without downtime
- Versioned: Track changes and roll back if needed
- Specialized: Optimize each core for specific domains
- Scalable: Scale cores independently
Why Use Knowledge Cores?
1. Multi-Tenancy
Isolate data for different customers or organizations:
// Create separate cores for each tenant
await trustgraph.cores.create({
name: "tenant_acme_corp",
type: "cassandra",
isolation: "complete",
config: {
keyspace: "acme_corp_data"
}
});
await trustgraph.cores.create({
name: "tenant_globex_inc",
type: "cassandra",
isolation: "complete",
config: {
keyspace: "globex_inc_data"
}
});
// Agents automatically use the correct core
const agent = await trustgraph.createAgent({
id: "customer_support_agent",
knowledgeCore: "tenant_acme_corp" // Isolated to this tenant
});
2. Domain Specialization
Create specialized cores for different knowledge domains:
// Medical knowledge core
const medicalCore = await trustgraph.cores.create({
name: "medical_knowledge",
type: "neo4j",
schema: {
entityTypes: ["disease", "symptom", "treatment", "drug", "patient"],
relationshipTypes: ["causes", "treats", "prescribed_for", "contraindicated"]
}
});
// Legal knowledge core
const legalCore = await trustgraph.cores.create({
name: "legal_knowledge",
type: "memgraph",
schema: {
entityTypes: ["case", "statute", "regulation", "precedent", "party"],
relationshipTypes: ["cites", "overturns", "applies_to", "governed_by"]
}
});
// Financial knowledge core
const financialCore = await trustgraph.cores.create({
name: "financial_knowledge",
type: "cassandra",
schema: {
entityTypes: ["company", "transaction", "account", "asset", "liability"],
relationshipTypes: ["owns", "trades", "invests_in", "owes"]
}
});
3. Version Control
Version your knowledge graphs like code:
// Production core
const prodCore = await trustgraph.cores.create({
name: "production",
version: "2.1.0"
});
// Create staging core as copy
const stagingCore = await trustgraph.cores.clone({
source: "production",
name: "staging",
version: "2.2.0-beta"
});
// Make changes in staging
await trustgraph.useCore("staging");
await trustgraph.ingest({ source: "new_data.json" });
await trustgraph.updateSchema({ ... });
// Test in staging
const testResults = await runTests(stagingCore);
if (testResults.passed) {
// Promote staging to production
await trustgraph.cores.promote({
source: "staging",
target: "production",
version: "2.2.0"
});
} else {
// Roll back - discard staging changes
await trustgraph.cores.delete("staging");
}
4. Temporal Separation
Separate current vs historical data:
// Current data (frequently updated)
const currentCore = await trustgraph.cores.create({
name: "current_knowledge",
type: "memgraph", // In-memory for speed
config: {
retention: "90_days"
}
});
// Historical archive (read-only)
const archiveCore = await trustgraph.cores.create({
name: "historical_archive",
type: "cassandra", // Distributed for scale
config: {
readonly: true,
compression: "high"
}
});
// Periodically archive old data
await trustgraph.cores.archiveData({
source: "current_knowledge",
target: "historical_archive",
olderThan: "90_days"
});
Creating and Managing Knowledge Cores
Creating a Core
const core = await trustgraph.cores.create({
name: "my_knowledge_core",
// Backend type
type: "cassandra", // or "neo4j", "memgraph", "nebula"
// Backend configuration
config: {
cluster: ["cassandra1:9042", "cassandra2:9042"],
keyspace: "my_core",
replicationFactor: 3
},
// Schema definition
schema: {
entityTypes: ["person", "organization", "document"],
relationshipTypes: ["works_at", "authored", "cites"],
ontology: "schema/ontology.owl"
},
// Metadata
metadata: {
description: "Core knowledge base for main application",
owner: "team_data",
tags: ["production", "primary"]
}
});
Switching Between Cores
// Set active core for current context
await trustgraph.useCore("production");
// All operations now use production core
await trustgraph.query({ query: "..." });
// Switch to different core
await trustgraph.useCore("staging");
// Now using staging core
await trustgraph.query({ query: "..." });
// Or specify core explicitly
await trustgraph.query({
query: "...",
core: "production" // Override active core
});
Listing and Inspecting Cores
// List all cores
const cores = await trustgraph.cores.list();
for (const core of cores) {
console.log(`Core: ${core.name}`);
console.log(` Type: ${core.type}`);
console.log(` Nodes: ${core.stats.nodeCount}`);
console.log(` Edges: ${core.stats.edgeCount}`);
console.log(` Size: ${core.stats.sizeGB} GB`);
console.log(` Status: ${core.status}`);
}
// Get detailed info about specific core
const coreInfo = await trustgraph.cores.inspect("production");
console.log(coreInfo);
// {
// name: "production",
// version: "2.1.0",
// schema: { ... },
// stats: { ... },
// config: { ... },
// health: "healthy"
// }
Deleting a Core
// Delete a core (careful - permanent!)
await trustgraph.cores.delete("old_core", {
confirm: true,
backup: true // Create backup before deletion
});
Multi-Core Architectures
Pattern 1: Read/Write Separation
// Write core - optimized for ingestion
const writeCore = await trustgraph.cores.create({
name: "write_core",
type: "memgraph",
config: {
memoryLimit: "64GB",
writeOptimized: true
}
});
// Read core - optimized for queries
const readCore = await trustgraph.cores.create({
name: "read_core",
type: "cassandra",
config: {
readOptimized: true,
cacheSize: "32GB"
}
});
// Ingest to write core
await trustgraph.useCore("write_core");
await trustgraph.ingest({ source: "data/" });
// Replicate to read core
await trustgraph.cores.replicate({
source: "write_core",
target: "read_core"
});
// Queries use read core
await trustgraph.useCore("read_core");
const results = await trustgraph.query({ query: "..." });
Pattern 2: Hierarchical Knowledge
// General knowledge (large, shared)
const generalCore = await trustgraph.cores.create({
name: "general_knowledge",
type: "cassandra",
shared: true
});
// Domain-specific knowledge (smaller, focused)
const domainCore = await trustgraph.cores.create({
name: "domain_medical",
type: "neo4j",
extends: "general_knowledge" // Inherits general knowledge
});
// Query across both cores
const results = await trustgraph.query({
query: "medical question",
cores: ["domain_medical", "general_knowledge"],
priority: "domain_first" // Check domain core first
});
Pattern 3: Geographic Distribution
// Regional cores for data sovereignty
const usCore = await trustgraph.cores.create({
name: "knowledge_us_east",
type: "cassandra",
config: {
datacenter: "us-east-1",
region: "us"
}
});
const euCore = await trustgraph.cores.create({
name: "knowledge_eu_west",
type: "cassandra",
config: {
datacenter: "eu-west-1",
region: "eu"
}
});
// Route queries to appropriate core based on user location
async function getCore(userLocation: string) {
if (userLocation.startsWith("EU")) {
return "knowledge_eu_west";
} else {
return "knowledge_us_east";
}
}
Knowledge Core Operations
Cloning a Core
// Create exact copy of existing core
const cloned = await trustgraph.cores.clone({
source: "production",
name: "experiment_1",
type: "same", // Use same backend as source
copyData: true
});
// Now experiment without affecting production
await trustgraph.useCore("experiment_1");
await experimentalChanges();
Merging Cores
// Merge two cores
await trustgraph.cores.merge({
source1: "medical_core_v1",
source2: "medical_core_v2",
target: "medical_core_merged",
// Conflict resolution strategy
conflicts: {
entities: "prefer_source2", // Use source2 entities on conflict
relationships: "union" // Keep relationships from both
}
});
Exporting and Importing
// Export core to file
await trustgraph.cores.export({
core: "production",
format: "graphml", // or "json", "cypher", "rdf"
output: "backup/production_2025-12-24.graphml",
compress: true
});
// Import core from file
await trustgraph.cores.import({
file: "backup/production_2025-12-24.graphml",
target: "production_restored",
format: "graphml"
});
Syncing Cores
// Keep two cores synchronized
await trustgraph.cores.sync({
source: "production",
target: "disaster_recovery",
// Sync strategy
mode: "incremental", // Only sync changes
direction: "one-way", // source -> target only
interval: "5m", // Sync every 5 minutes
// Conflict handling
onConflict: "source_wins"
});
Performance Optimization
Core-Specific Optimization
// Optimize core for specific workload
await trustgraph.cores.optimize({
core: "production",
workload: {
readHeavy: true,
writeHeavy: false,
complexTraversals: true,
avgQueryDepth: 3
},
tuning: {
// Cache settings
cache: {
nodeCache: "16GB",
edgeCache: "8GB",
queryCache: "4GB"
},
// Indexing
indexes: {
nodeProperties: ["name", "type", "created"],
edgeTypes: ["relates_to", "connects"]
},
// Compression
compression: {
properties: true,
edges: false // Don't compress for fast traversal
}
}
});
Sharding Large Cores
// Shard large core across multiple backends
await trustgraph.cores.shard({
core: "very_large_core",
// Sharding strategy
strategy: "hash", // or "range", "geographic"
shards: 8,
// Shard key
shardKey: "entity_type",
// Backend for each shard
backends: [
{ shard: 0, cluster: ["shard0-1:9042", "shard0-2:9042"] },
{ shard: 1, cluster: ["shard1-1:9042", "shard1-2:9042"] },
// ... more shards
]
});
Agent Memory with Knowledge Cores
Use Knowledge Cores to provide agents with specialized memory:
// Create agent with dedicated memory core
const agent = await trustgraph.createAgent({
id: "research_agent",
// Personal memory core
memoryCore: await trustgraph.cores.create({
name: "agent_research_memory",
type: "memgraph",
config: {
persistent: true,
size: "small"
}
}),
// Shared knowledge core (read-only)
knowledgeCore: "shared_research_knowledge",
// Core access
coreAccess: {
memory: ["read", "write"],
knowledge: ["read"]
}
});
// Agent can write to its memory core
await agent.remember({
fact: "User prefers detailed explanations",
confidence: 0.9
});
// Agent reads from shared knowledge core
const context = await agent.retrieve({
query: "quantum computing",
core: "knowledge"
});
Best Practices
- Use Cores for Isolation: Separate cores for tenants, environments, domains
- Version Your Cores: Track changes and enable rollback
- Optimize Per Core: Tune each core for its specific workload
- Regular Backups: Export cores regularly for disaster recovery
- Monitor Core Health: Track performance metrics per core
- Clean Up Unused Cores: Delete old experimental or staging cores
- Document Core Purpose: Clear naming and metadata for each core
- Control Access: Use permissions to restrict core access appropriately
Related Concepts
- Agent Memory - Memory systems for AI agents
- Multi-tenant - Multi-tenancy architecture
- Knowledge Graph - Graph structure fundamentals
- Collections - Logical data groupings