Skip to content

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.

RelationshipDirectionDescriptionExample
parent_ofA -> BA is parent of B“Module is parent of function”
child_ofA -> BA is child of B“Function is child of module”
part_ofA -> BA is part of B“Auth middleware is part of API gateway”
has_partA -> BA contains B as a part“API gateway has part auth middleware”
instance_ofA -> BA is instance of B“This error is instance of TimeoutError”
type_ofA -> BA is the type/class of B“TimeoutError is type of this error”

Causal Relationships

Track cause-and-effect chains.

RelationshipDirectionDescriptionExample
causesA -> BA directly causes B“Memory leak causes OOM crash”
caused_byA -> BA is caused by B“OOM crash caused by memory leak”
enablesA -> BA makes B possible“Auth service enables user management”
enabled_byA -> BA is made possible by B“User management enabled by auth service”
triggersA -> BA triggers B to happen“Config change triggers restart”
triggered_byA -> BA is triggered by B“Restart triggered by config change”
leads_toA -> BA eventually leads to B“Tech debt leads to refactoring”
led_to_byA -> BA is led to by B“Refactoring led to by tech debt”
preventsA -> BA prevents B from occurring“Rate limiting prevents DDoS”
prevented_byA -> BA is prevented by B“DDoS prevented by rate limiting”

Temporal Relationships

Track time-based ordering.

RelationshipDirectionDescriptionExample
beforeA -> BA occurs before B in time“Design before implementation”
afterA -> BA occurs after B in time“Testing after implementation”
duringA -> BA occurs during the timespan of B“Bug discovered during code review”

Similarity Relationships

Connect related content.

RelationshipDirectionDescriptionExample
similar_toA <-> BA is similar to B“Auth bug is similar to previous auth issue”
duplicate_ofA <-> BA is an exact or near duplicate of B“This report duplicates the earlier finding”
related_toA <-> BA is generally related to B“Caching is related to performance”
variant_ofA <-> BA is a variant/version of B“Retry with backoff is variant of simple retry”

Learning Relationships

Track how knowledge evolves over time.

RelationshipDirectionDescriptionExample
builds_onA -> BA builds on knowledge in B“V2 API builds on V1 patterns”
built_upon_byA -> BA is built upon by B“V1 patterns built upon by V2 API”
contradictsA <-> BA contradicts B“New benchmark contradicts old results”
confirmsA <-> BA confirms/validates B“Load test confirms performance fix”
supportsA -> BA provides evidence for B“Metrics data supports scaling decision”
supported_byA -> BA has evidence provided by B“Scaling decision supported by metrics data”
supersedesA -> BA replaces B (B is outdated)“JWT auth supersedes session cookies”
superseded_byA -> BA is replaced by B (A is outdated)“Session cookies superseded by JWT auth”

Refinement Relationships

Track how knowledge is refined and replaced.

RelationshipDirectionDescriptionExample
refinesA -> BA refines/elaborates on B“V2 config refines V1 approach”
refined_byA -> BA is refined by B“V1 approach refined by V2 config”
replacesA -> BA supersedes or replaces B“New API replaces legacy endpoint”
replaced_byA -> BA is replaced by B“Legacy endpoint replaced by new API”

Reference Relationships

Track citations and references.

RelationshipDirectionDescriptionExample
referencesA -> BA references B“Bug report references stack trace”
referenced_byA -> BA is referenced by B“API docs referenced by integration guide”

Solution Relationships

Connect problems to their solutions.

RelationshipDirectionDescriptionExample
solvesA -> BA is a solution for B“Circuit breaker solves cascade failure”
solved_byA -> BA is solved by B“Cascade failure solved by circuit breaker”
addressesA -> BA partially addresses B“Retry logic addresses transient errors”
addressed_byA -> BA is partially addressed by B“Transient errors addressed by retry logic”
alternative_toA <-> BA is an alternative to B“Redis is alternative to Memcached”
improvesA -> BA is an improvement on B“Connection pooling improves raw connections”
improved_byA -> BA is improved by B“Raw connections improved by connection pooling”

Context Relationships

Describe where and when things apply.

RelationshipDirectionDescriptionExample
occurs_inA -> BA happens in context B“Timeout occurs in payment service”
contains_occurrenceA -> BA contains occurrence of B“Payment service contains occurrence of timeout”
applies_toA -> BA is relevant to B“CORS config applies to API gateway”
has_applicableA -> BA has applicable rule B“API gateway has applicable CORS config”
works_withA <-> BA works together with B“FastAPI works with SQLAlchemy”
requiresA -> BA requires B“Deployment requires Docker”
required_byA -> BA is required by B“Docker required by deployment”

Workflow Relationships

Define sequences and dependencies.

RelationshipDirectionDescriptionExample
followsA -> BA comes after B in sequence“Deploy follows testing”
followed_byA -> BA is followed by B in sequence“Testing followed by deploy”
depends_onA -> BA depends on B“API depends on database migration”
depended_on_byA -> BA is depended on by B“Database migration depended on by API”
blocksA -> BA blocks/prevents B“Broken CI blocks deployment”
blocked_byA -> BA is blocked by B“Deployment blocked by broken CI”

Quality Relationships

Express preferences and deprecations.

RelationshipDirectionDescriptionExample
effective_forA -> BA is effective for B“Caching is effective for read-heavy loads”
has_effectiveA -> BA has effective solution B“Read-heavy loads has effective caching”
preferred_overA -> BA is preferred over B“TypeScript preferred over JavaScript”
less_preferred_thanA -> BA is less preferred than B“JavaScript less preferred than TypeScript”
deprecated_byA -> BA is deprecated in favor of B“REST deprecated by GraphQL (for this use case)”
deprecatesA -> BA deprecates B“GraphQL deprecates REST (for this use case)”

Relationship Properties

Each relationship type in the ontology has the following properties:

PropertyDescription
symmetricWhether A->B implies B->A (e.g., similar_to is symmetric, causes is not)
transitiveWhether A->B and B->C implies A->C (e.g., causes is transitive)
inverseThe inverse relationship type (e.g., causes / caused_by)
categoryThe 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:

RangeMeaning
0.8 — 1.0Strong, verified relationship
0.5 — 0.7Moderate confidence
0.1 — 0.4Weak 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.