Skip to content

Data Model

Context Chain stores everything in a Memgraph graph database. Here's the complete data model.

Node Types

CodeEntity

Represents a code element in your repository. Created by Joern CPG analysis.

PropertyTypeDescription
namestringEntity name (function name, file path, etc.)
typeenumservice, file, function, api_endpoint
scopestring[]Module/service tags for filtering
repostringWhich repository this belongs to

DecisionContext

A design decision extracted from an AI coding session, code analysis, or manual input.

PropertyTypeDescription
idstringUnique identifier
contentstringFull natural language description
summarystringShort summary (for progressive disclosure)
keywordsstring[]Extracted concept terms (Slot 2)
scopestring[]Module tags
embeddingfloat[]Semantic vector (Slot 5)
created_atdatetimeWhen created
updated_atdatetimeLast modification
ownerstringWho produced this decision
session_idstringSource AI chat session
commit_hashstringCode version at time of decision
sourceenumai_chat, meeting, manual
confidenceenumowner_confirmed, ai_inferred, auto_generated, refined
stalenessenumactive, stale, archived

AggregatedSummary

Module-level summaries generated by the refinement pipeline. Groups multiple fine-grained decisions into a higher-level overview.

INFO

Not yet implemented. Planned for the refinement pipeline.

Edge Types

Code Structure Edges

Generated by Joern CPG analysis and LLM inference.

EdgeFrom → ToMeaning
CONTAINSCodeEntity → CodeEntityHierarchy: service → file → function
CALLSCodeEntity → CodeEntityFunction calls another function
DEPENDS_ON_APICodeEntity → CodeEntityCross-service API dependency (LLM-inferred)

Decision Anchor Edges

Connect decisions to the code they describe.

EdgeFrom → ToMeaning
ANCHORED_TODecisionContext → CodeEntityPrecise anchor (function-level)
APPROXIMATE_TODecisionContext → CodeEntityFuzzy anchor (file/directory-level, with confidence property)

Decision Relationship Edges

Connect decisions to each other, forming a decision graph.

EdgeFrom → ToMeaning
CAUSED_BYDecision → DecisionA was caused by B
LEADS_TODecision → DecisionA led to B
CONFLICTS_WITHDecision → DecisionTension / trade-off between A and B
SUPERSEDESDecision → DecisionB replaces A
DEPENDS_ONDecision → DecisionA assumes B holds
CO_DECIDEDDecision → DecisionMade together in the same session
SUMMARIZESAggregatedSummary → DecisionContextSummary covers these decisions

Internal Tracking Edges

Used by the pipeline, not exposed to consumers.

EdgeFrom → ToMeaning
PENDING_COMPARISONDecision → DecisionNot yet checked for relationships

TIP

PENDING_COMPARISON edges use an inverted tracking pattern: instead of recording "already compared, no relationship" (which pollutes the graph), the system creates PENDING edges for pairs that haven't been compared yet. As comparisons run, PENDING edges are deleted regardless of result — only meaningful relationship edges remain.

Graph Visualization

Open Memgraph Lab at http://localhost:3000 to browse the graph interactively.

Useful Cypher queries:

cypher
// All decisions anchored to a specific file
MATCH (d:DecisionContext)-[:ANCHORED_TO]->(c:CodeEntity {type: 'file', name: 'auth.ts'})
RETURN d, c

// Decision causal chain
MATCH path = (d1:DecisionContext)-[:CAUSED_BY|LEADS_TO*1..3]-(d2:DecisionContext)
WHERE d1.id = 'some-decision-id'
RETURN path

// Functions with no decisions (coverage gaps)
MATCH (c:CodeEntity {type: 'function'})
WHERE NOT (c)<-[:ANCHORED_TO]-(:DecisionContext)
RETURN c.name, c.repo
ORDER BY c.repo

Released under the Apache 2.0 License.