Knowledge Graph
Mayros maintains a persistent knowledge graph in Cortex, storing knowledge as RDF triples (subject → predicate → object). This graph powers code understanding, project memory, and cross-session recall.
Architecture
mermaidgraph TB A[Code Indexer] -->|structural triples| C[Cortex KG] B[CompactionExtractor] -->|conventions & findings| C D[ProjectMemory] -->|decisions & patterns| C C -->|before_prompt_build| E[Cross-Session Recall] C -->|mayros kg| F[CLI Queries]
Three knowledge layers
1. Code Index
The Code Indexer scans project files and extracts structural knowledge: functions, classes, imports, and exports. This gives agents an understanding of the codebase without reading every file.
2. Project Memory
Project Memory captures conventions, architectural decisions, and findings discovered during work. Knowledge is stored automatically via the agent_end hook and the CompactionExtractor, or manually via CLI and tools.
3. Cross-Session Recall
At before_prompt_build, Mayros queries the knowledge graph for relevant conventions and findings, injecting them into the agent's context. This means knowledge learned in one session is available in future sessions without manual repetition.
Namespace isolation
All triples are scoped with a namespace prefix (default: mayros). This enforces strict isolation:
- Each project's knowledge stays separate
- Agent-scoped data uses
{ns}:agent:{agentId}prefixes - No cross-namespace queries are possible
Querying
- CLI:
mayros kg search "query"for natural language search - Tools:
cortex_project_memory_queryandcortex_project_memory_storefor programmatic access - Direct:
mayros kg explore "subject"to traverse connected triples
Configuration
json5{ plugins: { entries: { "memory-semantic": { config: { codeIndexer: { enabled: true, include: ["src/**/*"], exclude: ["node_modules/**"], }, projectMemory: { enabled: true, autoExtract: true, maxConventions: 100, }, }, }, }, }, }
Related
- Code Indexer — automatic code scanning
- Project Memory — conventions, decisions, findings
- Compaction — smart compaction with knowledge extraction
- kg CLI — command reference
- Cortex (AIngle) — the underlying triple store