Context Graph Overview
Production - Knowledge graph, ontology, semantic SQL, SHACL validation, agent thinking traces
The Context Graph module provides a knowledge graph layer for the AI Service. It manages entity relationships, ontology definitions, semantic SQL generation, SHACL validation, and agent thinking trace capture. Built on Dgraph for graph storage and Qdrant for vector embeddings.
12.5.1Architecture
API Layer
Context Graph RESTGraphQLOntology APISHACL APISemantic SQL APIThinking APIAnalytics API
Services
OntologyParserOntologyRegistrySHACLGeneratorSHACLValidatorSemanticSQLGeneratorAgentThinkingCapture
Integration
OrchestratorHooksKafkaProducerKafkaConsumerMetricsBridgeThinkingEmbeddings
Security
ContextGraphAuthorizerRBACTenantIsolation
Storage
DgraphContextStoreBitemporalStoreEmbeddingStorePostgresStores
Feature Flags
The Context Graph uses a sophisticated feature flag system for phased rollout:
class SemanticFeature(str, Enum):
SEMANTIC_SQL = "semantic_sql"
SHACL_VALIDATION = "shacl_validation"
ONTOLOGY_WATCHER = "ontology_watcher"
CONCEPT_EXTRACTION = "concept_extraction"
CONTEXT_GRAPH_THINKING = "context_graph_thinking"
CONTEXT_GRAPH_KAFKA = "context_graph_kafka"
CONTEXT_GRAPH_EMBEDDINGS = "context_graph_embeddings"
CONTEXT_GRAPH_RBAC = "context_graph_rbac"Resolution order: Tenant override -> Environment variable -> Canary rollout -> Default
12.5.2Section Pages
| Page | Description |
|---|---|
| Semantic Search | Unified, semantic, structural, precedent, and discovery search |
| Graph Traversal | Path finding, cycle detection, pattern matching |
| Search Analytics | Search usage analytics, entity suggestions |
| Agent Thinking Traces | Agent reasoning capture, replay, and analysis |
| Ontology Management | OWL/SHACL ontology parsing, registry, watcher |
| Causal Inference | Causal analysis via graph relationships |
| Action Graph | Action tracking and graph construction |
| Semantic SQL | Ontology-driven SQL generation |