Skip to content

Relationship Types Reference

MemoryLayer’s base ontology defines 85 typed relationships in 12 categories for connecting memories in a knowledge graph. Directed types come in inverse pairs (causes / caused_by), so most categories list both directions.

Plugins can contribute more types at startup. Installing the Repository Planning Graph plugin (memorylayer-server-rpg) adds a 13th category, code_structure, with 12 more types (see below). To see the exact set a workspace accepts, call GET /v1/workspaces/{workspace_id}/schema.

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 (no inverse type)“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)”

Knowledge-Work Relationships

Connect people, teams, and work artifacts: who owns, authored, reviewed, or decided something. Ingestion connectors that carry knowledge-work metadata (see Document Ingestion) emit these types.

RelationshipDirectionDescriptionExample
ownsA -> BAgent owns or is accountable for a work resource“Alice owns the billing service”
owned_byA -> BWork resource is owned by an agent“Billing service owned by Alice”
responsible_forA -> BAgent is assigned or responsible for a work resource“Bob responsible for the Q3 migration”
assigned_toA -> BWork resource is assigned to a responsible agent“Q3 migration assigned to Bob”
authoredA -> BAgent created or authored an artifact“Carol authored the design doc”
authored_byA -> BArtifact was created or authored by an agent“Design doc authored by Carol”
contributed_toA -> BAgent contributed to a work resource“Dan contributed to the RFC”
has_contributorA -> BWork resource has a contributing agent“RFC has contributor Dan”
reviewedA -> BAgent reviewed a work resource“Erin reviewed PR 142”
reviewed_byA -> BWork resource was reviewed by an agent“PR 142 reviewed by Erin”
approvedA -> BAgent approved a work resource or decision“CTO approved the vendor choice”
approved_byA -> BWork resource or decision was approved by an agent“Vendor choice approved by CTO”
decidedA -> BAgent made or authorized a decision“Platform team decided on Postgres”
decided_byA -> BDecision was made or authorized by an agent“Postgres decision decided by platform team”
based_onA -> BDecision or artifact is based on source evidence“Decision based on the load-test report”
basis_forA -> BEvidence provides the basis for another resource“Load-test report is basis for the decision”
affectsA -> BDecision, event, or work item affects another resource“Schema change affects the reporting job”
affected_byA -> BResource is affected by a decision, event, or work item“Reporting job affected by schema change”
aboutA -> BArtifact or work resource is primarily about a topic“Postmortem is about the March outage”
subject_ofA -> BTopic is the subject of an artifact or work resource“March outage is subject of the postmortem”
member_ofA -> BAgent is a member of an organization or team“Alice is member of the payments team”
has_memberA -> BOrganization or team has an agent as a member“Payments team has member Alice”

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.

Code-Structure Relationships (RPG plugin)

These 12 types exist only when the memorylayer-server-rpg plugin is installed. It is included in the official server Docker image. RPG uses them for repository-graph edges.

RelationshipInverseDescription
containscontained_byDirectory contains file, file contains class, and so on
inheritsinherited_byClass inheritance
invokesinvoked_byFunction or method call
importsimported_byModule or package import
composescomposed_byComposition or aggregation
data_flowdata_flow_fromData flows from A to B

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.

Categories

The 12 base categories are hierarchical, causal, temporal, similarity, learning, refinement, knowledge_work, reference, solution, context, workflow, and quality. The RPG plugin adds code_structure.

To restrict a graph traversal, list individual relationship types. The POST /v1/memories/{memory_id}/traverse endpoint filters on relationship_types only:

const result = await client.traverseGraph("mem-123", {
relationshipTypes: ["causes", "caused_by", "solves", "solved_by"],
maxDepth: 3,
});