The shared SqliteBrain connection for this agent.
The knowledge_nodes and knowledge_edges tables must already exist
(SqliteBrain creates them in its constructor).
Add a memory node to the graph.
The node is persisted to knowledge_nodes (type = 'memory_graph') with
the metadata serialised into the properties JSON column. If a node with
the same memoryId already exists it is silently replaced (upsert).
Unique identifier for the memory trace this node represents.
Structural metadata describing the memory.
Add a directed edge between two memory nodes.
If an edge with the same (sourceId, targetId) pair already exists it is
replaced (upsert by composite key). The underlying SQLite row is identified
by a deterministic UUID derived from the source/target pair so that
repeated upserts land on the same row.
Edge descriptor including type, weight, and timestamp.
Retrieve all edges incident to a memory node.
Returns edges where memoryId appears as either source or target.
Optionally filters by edge type.
O(E) scan over the in-memory edge map — acceptable for typical graph sizes (< 10k edges).
Node ID to query.
Optional type: MemoryEdgeTypeOptional edge type filter.
Array of matching MemoryEdge objects.
Run spreading activation from a set of seed nodes.
Implements Anderson's ACT-R spreading activation model using BFS:
parentActivation * (1 - decayPerHop) * edgeWeight.activationThreshold are not expanded further.maxDepth.Seed nodes are excluded from the returned list (they are the query, not the result).
IDs of the memory nodes that trigger the activation.
Optional config: SpreadingActivationConfigOptional tuning parameters.
Activated nodes sorted by activation descending, capped at maxResults.
Record that a set of memories were activated together (Hebbian learning).
For every unordered pair (A, B) in memoryIds, a CO_ACTIVATED edge is
upserted:
weight = learningRate.learningRate
and capped at 1.0.This implements the Hebbian rule "neurons that fire together wire together" at the memory graph level, gradually strengthening associations between memories that are frequently retrieved in the same context.
IDs of co-activated memories.
Weight increment per co-activation event.
0.1
Return all CONTRADICTS edges incident to a given memory node.
A CONTRADICTS edge signals that two memories express mutually incompatible beliefs or facts. The consolidation engine uses this to trigger conflict-resolution passes.
The memory node to check for contradictions.
Array of CONTRADICTS edges (may be empty).
Detect connected components (clusters) in the memory graph.
Uses path-compressed Union-Find over all edges. Components are filtered
to those with at least minSize members.
The centroidId of each cluster is the member with the highest total
incident edge weight (most central node). If the cluster has only one
member, centroidId equals that member.
The density of a cluster is computed as:
actualEdges / maxPossibleEdges where maxPossibleEdges = n*(n-1).
For single-member clusters, density = 0.
Minimum component size to include.
Array of MemoryCluster objects.
2
SQLite-backed implementation of IMemoryGraph.
Thread safety: inherits the underlying adapter's concurrency model. Writes serialise automatically through WAL when using SQLite-backed adapters.
Usage: