Skip to content

Entity Registry

The entity registry gives the people, organizations, projects, places, and concepts your memories mention a single canonical record each. Suppose “Alice Chen”, “Alice”, and “achen” show up across hundreds of memories. The registry resolves all three to one entity. That entity keeps its aliases and the list of memories that mention it, and recall, perspective, and the knowledge base can use it.

The registry is part of core MemoryLayer (0.2.0+). It is off by default.

Terminal window
export MEMORYLAYER_ENTITY_REGISTRY_ENABLED=true
memorylayer serve

While the flag is off, the /v1/entities endpoints that read or modify the registry return 501. The SDKs surface that 501 as EnterpriseRequiredError, even though the registry is a core feature. Turn on the flag to use it.

How Entities Are Built

With the registry enabled, every stored memory goes through accretion:

  1. Entity names are extracted from the content. Core MemoryLayer uses a deterministic extractor: dialogue speakers plus proper-noun spans. MemoryLayer Enterprise can use typed named-entity recognition (GLiNER2) instead.
  2. Each name is resolved: it is normalized, then matched exactly against canonical names, then against aliases. A new entity is created only when nothing matches.
  3. The memory is attached to each entity as a member. The role is self when the entity is the memory’s speaker or observer_id, and mention otherwise. A memory’s observer_id and subject_id fields always accrete as people, so email and documents get perspective anchors even without dialogue prefixes.

Names that the extractor could not type become concept and are promoted to person when the evidence says so. The same normalized name maps to one canonical entity per workspace.

Entity Types

The core types are person, org, project, place, event, and concept (the catch-all). The ontology also defines artifact, work_item, decision, and topic. Add domain types with MEMORYLAYER_ENTITY_TYPES, a comma-separated list of type or type:ner_label entries:

Terminal window
export MEMORYLAYER_ENTITY_TYPES="equipment,chemical:chemical compound,standard"

The Entity Record

FieldDescription
idEntity ID
entity_typeOne of the types above (a string, so domain types round-trip)
canonical_name / normalized_nameDisplay name and match key
aliasesOther surface forms that resolve to this entity
confidenceResolution confidence (default 1.0)
provenanceHow the entity came to exist
representative_memory_idA memory that best represents the entity
statusactive or merged
merged_intoThe surviving entity when status is merged

API

All endpoints are under /v1/entities and accept an optional workspace_id query parameter.

Method & PathDescription
GET /v1/entitiesList entities (status = active or merged, limit default 100, max 1000)
GET /v1/entities/resolve?name=...&entity_type=personResolve a surface name to a canonical entity. Never creates one; returns 404 when nothing matches. The response gives matched_via (exact, alias, and so on) and a score.
GET /v1/entities/{id}Get one entity
POST /v1/entities/mergeMerge source_id into target_id (body: source_id, target_id, reason)
POST /v1/entities/dedupeBatch deduplication (see below)
GET /v1/entities/{id}/provenanceProvenance and lineage
GET /v1/entities/{id}/relatedRelated entities by co-occurrence (limit 10, min_shared 1)
POST /v1/entities/seedSeed a catalog of canonical entities
POST /v1/entities/backfillAccrete entities from existing memories
POST /v1/entities/enrichLink entities to an external knowledge base
POST /v1/entities/{id}/deriveSynthesize inference memories (insights) about an entity
GET /v1/entities/{id}/cardAn LLM-written entity card: reflection, insights, and source memories (cached 300 s)
GET /v1/entities/{id}/insightsList derived insights, optionally filtered by observer_id

The derive, card, and insights endpoints use the configured LLM.

SDK Support

The Python, TypeScript, and Go SDKs wrap list, get, resolve, and merge:

entities = await client.list_entities(limit=50)
resolution = await client.resolve_entity("Alice Chen", entity_type="person")
survivor = await client.merge_entities(dup_id, keep_id, reason="same person")
const { entities } = await client.listEntities({ limit: 50 });
const resolved = await client.resolveEntity("Alice Chen", { entityType: "person" });

Use the REST API for the other endpoints.

Merge and Dedup

Merge moves the source entity’s members and aliases onto the target, carries the source’s names forward as aliases, and marks the source merged with merged_into set. Merges are idempotent: merging an entity into itself, or merging when either side is already merged, is a no-op that returns the surviving entity.

Dedup (POST /v1/entities/dedupe, with optional threshold and limit default 1000) finds near-duplicate entities by name-embedding similarity. It groups them with union-find clustering and merges each cluster into its best-established member: the one with the most members, then the most aliases, then the highest confidence. It returns {clusters, merged}.

Seeding and Backfill

Seed a catalog of known entities before ingestion, so resolution lands on your canonical names:

Terminal window
curl -X POST "$MEMORYLAYER_URL/v1/entities/seed" \
-H "Content-Type: application/json" \
-d '{
"entities": [
{"name": "Acme Corp", "entity_type": "org", "aliases": ["Acme", "ACME Inc."],
"external_ids": {"wikidata": "Q123"}},
{"name": "Project Falcon", "entity_type": "project", "description": "Payments rewrite"}
]
}'

Seeding creates or updates entities. Entries with an entity type the ontology does not know are skipped and listed in skipped_invalid_type.

Backfill accretes entities from memories that were stored before the registry was enabled:

Terminal window
# Accrete from existing memories in batches of 200
curl -X POST "$MEMORYLAYER_URL/v1/entities/backfill?batch_size=200"
# Wipe the workspace's registry first, then rebuild
curl -X POST "$MEMORYLAYER_URL/v1/entities/backfill?reset=true"

The response reports cleared, scanned, and accreted. Backfill always re-runs extraction with the current extractor instead of reusing entity names cached on each memory. Add reset=true after switching extractors, so stale entities from the old extractor are removed first. max_memories caps a run.

Provenance

GET /v1/entities/{id}/provenance returns a PROV-O-flavoured lineage record:

FieldDescription
originseeded, promoted, created, matched, or unknown
activity, agent, descriptionWhat created the entity and who ran it
external_linksExternal knowledge-base links (id, label, description, url, score) keyed by source
source_memory_idsMemories that evidence the entity
generated_atWhen the lineage was recorded

Relatedness

GET /v1/entities/{id}/related ranks other entities by member co-occurrence: how many memories mention both. Each result carries shared_memories and a score. Raise min_shared to require stronger evidence.

External Linking (Wikidata)

POST /v1/entities/enrich (with types default org,person,place, limit default 500, and overwrite default false) links entities to an external knowledge base through the configured linker. The linker is selected with MEMORYLAYER_ENTITY_LINKER_PROVIDER. Core MemoryLayer ships only the default no-op linker. The wikidata linker is part of MemoryLayer Enterprise.

Registry-Backed Recall

Two recall channels use the registry. Both are off by default:

Env varDefaultEffect
MEMORYLAYER_ENTITY_REGISTRY_RECALL_ENABLEDfalseResolves the query’s entities and fuses their mention members into recall. This catches memories that name the entity by an alias.
MEMORYLAYER_ENTITY_REGISTRY_RECALL_POOL200Candidate pool for that channel
MEMORYLAYER_ENTITY_REGISTRY_RECALL_MIN_RELEVANCE0.0Query-relevance floor, which stops large entities from flooding results
MEMORYLAYER_GRAPH_RECALL_ENABLEDfalseThe bounded graph-traversal channel over the entity neighbourhood

Recall never creates entities from a query string.