Skip to content

Graphorin API reference v0.7.0


Graphorin API reference / @graphorin/memory / / GraphMemoryStoreExt

Interface: GraphMemoryStoreExt

Defined in: packages/memory/src/internal/storage-adapter.ts:820

Optional storage extension for the lightweight in-SQLite relation graph (P2-1). Owns the canonical entities table, the fact_entities mapping, and the append-only entity_merges ledger. The entity resolution policy (lexical + embedding dedup, optional LLM adjudication) lives in @graphorin/memory; this surface is the pure persistence + the recursive-CTE traversal.

Adapters that opt out leave the property undefined; entity resolution on write degrades to a no-op and search({ expandHops }) skips expansion. The default @graphorin/store-sqlite adapter implements it.

Stable

Methods

expandActivation()?

ts
optional expandActivation(
   scope, 
   seedFactIds, 
   opts?): Promise<readonly {
  depth: number;
  fact: Fact;
}[]>;

Defined in: packages/memory/src/internal/storage-adapter.ts:871

PPR-lite graded expansion (D5): like expandOneHop but returns each neighbour with its minimum hop depth from the seeds, so the tier can weight it by damped spreading activation. Optional - stores without it fall back to flat one-hop expansion.

Parameters

ParameterType
scopeSessionScope
seedFactIdsreadonly string[]
opts?ExpandHopsStoreOptions

Returns

Promise<readonly { depth: number; fact: Fact; }[]>


expandOneHop()

ts
expandOneHop(
   scope, 
   seedFactIds, 
opts?): Promise<readonly Fact[]>;

Defined in: packages/memory/src/internal/storage-adapter.ts:860

Expand seed facts to neighbours sharing a canonical entity (one-hop CTE).

Parameters

ParameterType
scopeSessionScope
seedFactIdsreadonly string[]
opts?ExpandHopsStoreOptions

Returns

Promise&lt;readonly Fact[]&gt;


factsForEntityName()?

ts
optional factsForEntityName(
   scope, 
   normalizedName, 
opts?): Promise<readonly Fact[]>;

Defined in: packages/memory/src/internal/storage-adapter.ts:881

Exact entity-match retriever (D5): facts linked to the canonical entity for normalizedName. Optional. Powers a precise "facts about <entity>" candidate leg.

Parameters

ParameterType
scopeSessionScope
normalizedNamestring
opts?ExpandHopsStoreOptions

Returns

Promise&lt;readonly Fact[]&gt;


findEntityByNormalizedName()?

ts
optional findEntityByNormalizedName(scope, normalizedName): Promise<EntityWithEmbedding | null>;

Defined in: packages/memory/src/internal/storage-adapter.ts:837

Uncapped indexed lookup of the canonical root for an exact normalized name. Lets the resolver dedup an exact alias of an arbitrarily-old entity without scanning (and deserializing) the bounded listEntities candidate window (CS-11). Optional: stores without it fall back to the capped lexical scan inside resolveEntityDecision.

Parameters

ParameterType
scopeSessionScope
normalizedNamestring

Returns

Promise&lt;EntityWithEmbedding | null&gt;


getEntity()

ts
getEntity(scope, id): Promise<GraphEntity | null>;

Defined in: packages/memory/src/internal/storage-adapter.ts:842

Lookup one entity by id (any merge state).

Parameters

ParameterType
scopeSessionScope
idstring

Returns

Promise&lt;GraphEntity | null&gt;


linkFactEntity()

ts
linkFactEntity(
   factId, 
   entityId, 
role): Promise<void>;

Defined in: packages/memory/src/internal/storage-adapter.ts:824

Link a fact's subject / object to a canonical entity (idempotent).

Parameters

ParameterType
factIdstring
entityIdstring
roleEntityRole

Returns

Promise&lt;void&gt;


listEntities()

ts
listEntities(scope, opts?): Promise<readonly EntityWithEmbedding[]>;

Defined in: packages/memory/src/internal/storage-adapter.ts:826

Candidate entities for the resolver (roots only unless includeMerged).

Parameters

ParameterType
scopeSessionScope
opts?{ includeMerged?: boolean; limit?: number; }
opts.includeMerged?boolean
opts.limit?number

Returns

Promise&lt;readonly EntityWithEmbedding[]&gt;


listMerges()

ts
listMerges(scope, opts?): Promise<readonly EntityMergeRecord[]>;

Defined in: packages/memory/src/internal/storage-adapter.ts:855

The append-only merge / unmerge ledger, newest first.

Parameters

ParameterType
scopeSessionScope
opts?{ limit?: number; }
opts.limit?number

Returns

Promise&lt;readonly EntityMergeRecord[]&gt;


mergeEntities()

ts
mergeEntities(
   scope, 
   fromId, 
   intoId, 
reason?): Promise<void>;

Defined in: packages/memory/src/internal/storage-adapter.ts:846

Merge fromId into intoId's root; auditable + reversible.

Parameters

ParameterType
scopeSessionScope
fromIdstring
intoIdstring
reason?string

Returns

Promise&lt;void&gt;


resolveCanonical()

ts
resolveCanonical(scope, id): Promise<string>;

Defined in: packages/memory/src/internal/storage-adapter.ts:844

Follow mergedInto to the canonical root id.

Parameters

ParameterType
scopeSessionScope
idstring

Returns

Promise&lt;string&gt;


unmergeEntity()

ts
unmergeEntity(
   scope, 
   id, 
reason?): Promise<void>;

Defined in: packages/memory/src/internal/storage-adapter.ts:853

Reverse a merge: make id a root again + record an audit row.

Parameters

ParameterType
scopeSessionScope
idstring
reason?string

Returns

Promise&lt;void&gt;


upsertEntity()

ts
upsertEntity(scope, input): Promise<string>;

Defined in: packages/memory/src/internal/storage-adapter.ts:822

Find-or-create the canonical (root) entity for the normalized name.

Parameters

ParameterType
scopeSessionScope
inputEntityUpsertInput

Returns

Promise&lt;string&gt;