MATIH Platform is in active MVP development. Documentation reflects current implementation status.
12. AI Service
Context Graph
Context Graph Overview

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

PageDescription
Semantic SearchUnified, semantic, structural, precedent, and discovery search
Graph TraversalPath finding, cycle detection, pattern matching
Search AnalyticsSearch usage analytics, entity suggestions
Agent Thinking TracesAgent reasoning capture, replay, and analysis
Ontology ManagementOWL/SHACL ontology parsing, registry, watcher
Causal InferenceCausal analysis via graph relationships
Action GraphAction tracking and graph construction
Semantic SQLOntology-driven SQL generation