Semantic Graph
A semantic graph connects entities (functions, classes, agents, concepts) with typed relationships. It powers retrieval-augmented generation (RAG), GraphRAG, and cross-reference navigation.
Use Cases
- Code understanding: link functions to callers, classes to dependencies, tests to source files.
- Agent memory: persist facts, decisions, and blockers across sessions.
- RAG/GraphRAG: retrieve relevant subgraphs instead of flat document chunks.
Entity Types
| Node | Relationships |
|---|---|
Function |
CALLS, IMPORTS, TESTED_BY |
Class |
INHERITS_FROM, IMPLEMENTS, USES |
Agent |
OWNS, BLOCKED_BY, DECIDED |
Concept |
RELATES_TO, DEPENDS_ON |
Session |
PRODUCED, HANDS_OFF_TO |
Spec and Trace Enrichment
The orchestrata-ultimate semantic graph is enriched with specifications and code @traces annotations. This creates a requirement-aware layer:
Spec→HAS_STORY→StoryStory→HAS_REQUIREMENT→RequirementCodeElement→IMPLEMENTS→Requirement
Run the enrichment:
python scripts/enrich_semantic_graph_specs.py
Current scale:
| Node/Edge | Count |
|---|---|
| Spec | 61 |
| Story | 333 |
| Requirement | 4,924 |
| CodeElement | 5,129 |
| IMPLEMENTS | ~13,000 |
Example query:
MATCH (c:CodeElement)-[:IMPLEMENTS]->(r:Requirement {req_id: 'REQ-004-US-001-001'})
RETURN c.label, c.file_path, c.line_number
Backends
- Memgraph (orchgraph fork,
memgraphdatabase) — Cypher-compatible graph database used by the knowledge wiki indexer and RAG graph expansion; also holds theSpec/Story/Requirement/CodeElementenrichment described above (as:Entitynodes with alabelsproperty, written byupsert_entities). - Neo4j — retired 2026-07-27 (migration plan Step 5.1). The operational knowledge graph moved off Neo4j onto the same orchgraph cluster as the
orchkgdatabase; theneo4j-db/neo4j-node-*containers were destroyed andscripts/sync_ast_to_neo4j.pywas replaced byscripts/sync_ast_to_graph.py.KG_ROUTING_URI(the direct replacement for the retiredNEO4J_URI) now points at orchgraph (neo4j://10.53.1.160:7691).