Behaviour for unified graph persistence and querying backends.
Implementations handle storing, retrieving, and querying knowledge graph nodes through a single interface, replacing the separate Storage and in-memory Graph modules with a database-agnostic contract.
Callbacks
init/1- Initialize the backend with configuration options.apply_changeset/2- Persist a batch of node additions and links.delete_nodes/2- Remove nodes by their IDs.find_candidates/6- Query for nodes matching type/embedding/tag criteria.get_node/2- Fetch a single node by ID.get_linked_nodes/3- Fetch linked nodes, optionally filtered by edge type.
Read callbacks (find_candidates, get_node, get_linked_nodes) return state
for interface uniformity but must not rely on state mutation — callers may
discard the returned state in read-only contexts.
Summary
Types
Callbacks
@callback apply_changeset(Mnemosyne.Graph.Changeset.t(), state()) :: {:ok, state()} | {:error, Mnemosyne.Errors.error()}
@callback delete_nodes([String.t()], state()) :: {:ok, state()} | {:error, Mnemosyne.Errors.error()}
@callback get_linked_nodes([String.t()], Mnemosyne.Graph.Edge.edge_type() | nil, state()) :: {:ok, [struct()], state()}
@callback get_nodes_by_type(node_types :: [atom()], state()) :: {:ok, [struct()], state()} | {:error, Mnemosyne.Errors.error()}
@callback init(opts :: keyword()) :: {:ok, state()} | {:error, Mnemosyne.Errors.error()}