Jorvis Knowledge Graph Engine

Overview

The Knowledge Graph Engine (analytics-platform/src/ai/knowledge/) is the semantic brain of Jorvis. It provides business context, entity relationships, and schema enrichment to the LLM and Graph Engine.

Architecture

The Knowledge Graph is exposed via the Jorvis MCP Server (planned) and is currently used internally by the GraphOrchestratorService.

Components

DirectoryPurpose
glossary/Business Glossary: Defines domain terms (e.g., "MRR", "Churn") to ground LLM reasoning.
metrics/Metric Definitions: Structured definitions of KPI calculations to ensure consistent SQL generation.
graph-linker/Entity Resolution: Links unstructured mentions in text to database entities (e.g., "Apple" -> vendors.id=54).
schema-enrichment/Metadata Layer: Adds semantic descriptions to raw database schemas (e.g., "This table contains unverified leads").
query-examples/Few-Shot Store: Curated list of Question-SQL pairs for in-context learning.

Integration

1. In-Context Learning (RAG)

The PromptManagerService injects relevant knowledge into the LLM context:

  • Glossary Injection: Matches terms in user query against glossary/.
  • Metric Injection: Matches metric names against metrics/.
  • Example Injection: Retrieves similar queries from query-examples/.

2. MCP Exposure (mcp-knowledge-graph)

The system is designed to be exposed as an MCP Resource:

// Proposed MCP Resource Structure
{
  "uri": "jorvis://knowledge/glossary",
  "name": "Business Glossary",
  "mimeType": "application/json"
}

Data Flow

  1. Ingestion: Glossary/Metrics loaded from YAML/JSON configs.
  2. Indexing: Terms indexed for vector/keyword search.
  3. Retrieval: ContextRetrievalService finds relevant context for a query.
  4. Synthesis: LLM uses context to generate accurate SQL/Answers.

Future Roadmap

  • Federation: Link knowledge across tenants.
  • UI Editor: Allow non-technical users to edit Glossary/Metrics via Open WebUI.
  • Auto-Discovery: Automatically populate glossary from DB comments.