MnemosyneEcto.Backend (mnemosyne_ecto v0.2.0)

Copy Markdown View Source

Database-agnostic Ecto implementation of Mnemosyne.GraphBackend.

Persists knowledge graph nodes in a single polymorphic nodes table with JSON data, vector embeddings, and JSON link maps. Metadata and durable ingestion receipts are stored in separate tables.

get_ingestion/2 returns the scoped durable record or nil without changing backend state. commit_ingestion/3 atomically arbitrates a scoped source record and its graph changes. New sources return :inserted; equal digest and fingerprint retries return :existing with the original durable receipt and do not apply the supplied graph. Conflicting retries return IngestionError, while database or graph persistence failures return StorageError.

The concrete database engine is resolved automatically from the configured repository's Ecto adapter:

See MnemosyneEcto.Adapter for the per-engine seam.

Telemetry

See MnemosyneEcto.Telemetry for the full list of events and their metadata.

Error handling

Callbacks whose behaviour spec includes {:error, ...} returns (apply_changeset, get_ingestion, commit_ingestion, delete_nodes, find_candidates, get_nodes_by_type) catch exceptions and return {:error, StorageError.t()}. commit_ingestion returns IngestionError for a durable source conflict instead. Callbacks that only define {:ok, ...} returns (get_node, get_linked_nodes, get_metadata, update_metadata, delete_metadata) let exceptions propagate, as the caller is expected to handle crashes via supervision.