Relationship Types Reference
MemoryLayer provides 63 typed relationships organized into 11 categories for connecting memories in a knowledge graph.
Hierarchical Relationships
Define parent-child and containment structures.
| Relationship | Direction | Description | Example |
|---|---|---|---|
parent_of | A -> B | A is parent of B | “Module is parent of function” |
child_of | A -> B | A is child of B | “Function is child of module” |
part_of | A -> B | A is part of B | “Auth middleware is part of API gateway” |
has_part | A -> B | A contains B as a part | “API gateway has part auth middleware” |
instance_of | A -> B | A is instance of B | “This error is instance of TimeoutError” |
type_of | A -> B | A is the type/class of B | “TimeoutError is type of this error” |
Causal Relationships
Track cause-and-effect chains.
| Relationship | Direction | Description | Example |
|---|---|---|---|
causes | A -> B | A directly causes B | “Memory leak causes OOM crash” |
caused_by | A -> B | A is caused by B | “OOM crash caused by memory leak” |
enables | A -> B | A makes B possible | “Auth service enables user management” |
enabled_by | A -> B | A is made possible by B | “User management enabled by auth service” |
triggers | A -> B | A triggers B to happen | “Config change triggers restart” |
triggered_by | A -> B | A is triggered by B | “Restart triggered by config change” |
leads_to | A -> B | A eventually leads to B | “Tech debt leads to refactoring” |
led_to_by | A -> B | A is led to by B | “Refactoring led to by tech debt” |
prevents | A -> B | A prevents B from occurring | “Rate limiting prevents DDoS” |
prevented_by | A -> B | A is prevented by B | “DDoS prevented by rate limiting” |
Temporal Relationships
Track time-based ordering.
| Relationship | Direction | Description | Example |
|---|---|---|---|
before | A -> B | A occurs before B in time | “Design before implementation” |
after | A -> B | A occurs after B in time | “Testing after implementation” |
during | A -> B | A occurs during the timespan of B | “Bug discovered during code review” |
Similarity Relationships
Connect related content.
| Relationship | Direction | Description | Example |
|---|---|---|---|
similar_to | A <-> B | A is similar to B | “Auth bug is similar to previous auth issue” |
duplicate_of | A <-> B | A is an exact or near duplicate of B | “This report duplicates the earlier finding” |
related_to | A <-> B | A is generally related to B | “Caching is related to performance” |
variant_of | A <-> B | A is a variant/version of B | “Retry with backoff is variant of simple retry” |
Learning Relationships
Track how knowledge evolves over time.
| Relationship | Direction | Description | Example |
|---|---|---|---|
builds_on | A -> B | A builds on knowledge in B | “V2 API builds on V1 patterns” |
built_upon_by | A -> B | A is built upon by B | “V1 patterns built upon by V2 API” |
contradicts | A <-> B | A contradicts B | “New benchmark contradicts old results” |
confirms | A <-> B | A confirms/validates B | “Load test confirms performance fix” |
supports | A -> B | A provides evidence for B | “Metrics data supports scaling decision” |
supported_by | A -> B | A has evidence provided by B | “Scaling decision supported by metrics data” |
supersedes | A -> B | A replaces B (B is outdated) | “JWT auth supersedes session cookies” |
superseded_by | A -> B | A is replaced by B (A is outdated) | “Session cookies superseded by JWT auth” |
Refinement Relationships
Track how knowledge is refined and replaced.
| Relationship | Direction | Description | Example |
|---|---|---|---|
refines | A -> B | A refines/elaborates on B | “V2 config refines V1 approach” |
refined_by | A -> B | A is refined by B | “V1 approach refined by V2 config” |
replaces | A -> B | A supersedes or replaces B | “New API replaces legacy endpoint” |
replaced_by | A -> B | A is replaced by B | “Legacy endpoint replaced by new API” |
Reference Relationships
Track citations and references.
| Relationship | Direction | Description | Example |
|---|---|---|---|
references | A -> B | A references B | “Bug report references stack trace” |
referenced_by | A -> B | A is referenced by B | “API docs referenced by integration guide” |
Solution Relationships
Connect problems to their solutions.
| Relationship | Direction | Description | Example |
|---|---|---|---|
solves | A -> B | A is a solution for B | “Circuit breaker solves cascade failure” |
solved_by | A -> B | A is solved by B | “Cascade failure solved by circuit breaker” |
addresses | A -> B | A partially addresses B | “Retry logic addresses transient errors” |
addressed_by | A -> B | A is partially addressed by B | “Transient errors addressed by retry logic” |
alternative_to | A <-> B | A is an alternative to B | “Redis is alternative to Memcached” |
improves | A -> B | A is an improvement on B | “Connection pooling improves raw connections” |
improved_by | A -> B | A is improved by B | “Raw connections improved by connection pooling” |
Context Relationships
Describe where and when things apply.
| Relationship | Direction | Description | Example |
|---|---|---|---|
occurs_in | A -> B | A happens in context B | “Timeout occurs in payment service” |
contains_occurrence | A -> B | A contains occurrence of B | “Payment service contains occurrence of timeout” |
applies_to | A -> B | A is relevant to B | “CORS config applies to API gateway” |
has_applicable | A -> B | A has applicable rule B | “API gateway has applicable CORS config” |
works_with | A <-> B | A works together with B | “FastAPI works with SQLAlchemy” |
requires | A -> B | A requires B | “Deployment requires Docker” |
required_by | A -> B | A is required by B | “Docker required by deployment” |
Workflow Relationships
Define sequences and dependencies.
| Relationship | Direction | Description | Example |
|---|---|---|---|
follows | A -> B | A comes after B in sequence | “Deploy follows testing” |
followed_by | A -> B | A is followed by B in sequence | “Testing followed by deploy” |
depends_on | A -> B | A depends on B | “API depends on database migration” |
depended_on_by | A -> B | A is depended on by B | “Database migration depended on by API” |
blocks | A -> B | A blocks/prevents B | “Broken CI blocks deployment” |
blocked_by | A -> B | A is blocked by B | “Deployment blocked by broken CI” |
Quality Relationships
Express preferences and deprecations.
| Relationship | Direction | Description | Example |
|---|---|---|---|
effective_for | A -> B | A is effective for B | “Caching is effective for read-heavy loads” |
has_effective | A -> B | A has effective solution B | “Read-heavy loads has effective caching” |
preferred_over | A -> B | A is preferred over B | “TypeScript preferred over JavaScript” |
less_preferred_than | A -> B | A is less preferred than B | “JavaScript less preferred than TypeScript” |
deprecated_by | A -> B | A is deprecated in favor of B | “REST deprecated by GraphQL (for this use case)” |
deprecates | A -> B | A deprecates B | “GraphQL deprecates REST (for this use case)” |
Relationship Properties
Each relationship type in the ontology has the following properties:
| Property | Description |
|---|---|
| symmetric | Whether A->B implies B->A (e.g., similar_to is symmetric, causes is not) |
| transitive | Whether A->B and B->C implies A->C (e.g., causes is transitive) |
| inverse | The inverse relationship type (e.g., causes / caused_by) |
| category | The high-level category this relationship belongs to |
Symmetric relationships (like similar_to, contradicts, works_with) apply in both directions automatically. Directed relationships (like causes, solves, follows) have an explicit inverse type.
Usage
Python
from memorylayer import RelationshipType
await client.associate( source_id="mem_123", target_id="mem_456", relationship=RelationshipType.SOLVES, strength=0.9)TypeScript
import { RelationshipType } from "@scitrera/memorylayer-sdk";
await client.associate( "mem-123", "mem-456", RelationshipType.SOLVES, 0.9);MCP
{ "source_id": "mem_123", "target_id": "mem_456", "relationship": "solves", "strength": 0.9}Using Raw Strings
You can also use raw snake_case strings instead of the SDK enum values:
await client.associate( source_id="mem_123", target_id="mem_456", relationship="solves", strength=0.9)Strength
Association strength is a float between 0.0 and 1.0:
| Range | Meaning |
|---|---|
| 0.8 — 1.0 | Strong, verified relationship |
| 0.5 — 0.7 | Moderate confidence |
| 0.1 — 0.4 | Weak or speculative |
Strength affects how associations are scored during graph-enhanced recall. Higher-strength edges propagate more of the parent memory’s relevance score to discovered memories.
Filtering by Category
You can filter graph traversals by high-level category instead of listing individual types:
const result = await client.traverseGraph("mem-123", { relationshipCategories: ["causal", "solution"], maxDepth: 3,});Available categories: hierarchical, causal, temporal, similarity, learning, refinement, reference, solution, context, workflow, quality.