pub async fn link_memory_notes(
entity_ids: &[i64],
pool: SqlitePool,
embedding_store: Arc<EmbeddingStore>,
provider: AnyProvider,
cfg: &NoteLinkingConfig,
) -> LinkingStatsExpand description
Link newly extracted entities to semantically similar entities in the graph.
For each entity in entity_ids:
- Load the entity name + summary from
SQLite. - Embed all entity texts in parallel.
- Search the entity embedding collection in parallel for the
top_k + 1most similar points. - Filter out the entity itself (by
qdrant_point_idorentity_idpayload) and points belowsimilarity_threshold. - Insert a unidirectional
similar_toedge wheresource_id < target_idto avoid double-counting in BFS recall while still being traversable via the OR clause inedges_for_entity. The edge confidence is set to the cosine similarity score. - Deduplicate pairs within a single pass so that a pair encountered from both A→B and B→A
directions is only inserted once, keeping
edges_createdaccurate.
Errors are logged and not propagated — this is a best-effort background enrichment step.