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.
| Property | Type | Description |
|---|---|---|
name | string | Entity name (function name, file path, etc.) |
type | enum | service, file, function, api_endpoint |
scope | string[] | Module/service tags for filtering |
repo | string | Which repository this belongs to |
DecisionContext
A design decision extracted from an AI coding session, code analysis, or manual input.
| Property | Type | Description |
|---|---|---|
id | string | Unique identifier |
content | string | Full natural language description |
summary | string | Short summary (for progressive disclosure) |
keywords | string[] | Extracted concept terms (Slot 2) |
scope | string[] | Module tags |
embedding | float[] | Semantic vector (Slot 5) |
created_at | datetime | When created |
updated_at | datetime | Last modification |
owner | string | Who produced this decision |
session_id | string | Source AI chat session |
commit_hash | string | Code version at time of decision |
source | enum | ai_chat, meeting, manual |
confidence | enum | owner_confirmed, ai_inferred, auto_generated, refined |
staleness | enum | active, 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.
| Edge | From → To | Meaning |
|---|---|---|
CONTAINS | CodeEntity → CodeEntity | Hierarchy: service → file → function |
CALLS | CodeEntity → CodeEntity | Function calls another function |
DEPENDS_ON_API | CodeEntity → CodeEntity | Cross-service API dependency (LLM-inferred) |
Decision Anchor Edges
Connect decisions to the code they describe.
| Edge | From → To | Meaning |
|---|---|---|
ANCHORED_TO | DecisionContext → CodeEntity | Precise anchor (function-level) |
APPROXIMATE_TO | DecisionContext → CodeEntity | Fuzzy anchor (file/directory-level, with confidence property) |
Decision Relationship Edges
Connect decisions to each other, forming a decision graph.
| Edge | From → To | Meaning |
|---|---|---|
CAUSED_BY | Decision → Decision | A was caused by B |
LEADS_TO | Decision → Decision | A led to B |
CONFLICTS_WITH | Decision → Decision | Tension / trade-off between A and B |
SUPERSEDES | Decision → Decision | B replaces A |
DEPENDS_ON | Decision → Decision | A assumes B holds |
CO_DECIDED | Decision → Decision | Made together in the same session |
SUMMARIZES | AggregatedSummary → DecisionContext | Summary covers these decisions |
Internal Tracking Edges
Used by the pipeline, not exposed to consumers.
| Edge | From → To | Meaning |
|---|---|---|
PENDING_COMPARISON | Decision → Decision | Not 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:
// 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