Skip to content

feat(#401): cosine-based auto-linking + dedup detection on remember() - #421

Merged
ajianaz merged 2 commits into
developfrom
feat/401-cosine-auto-link
Jun 21, 2026
Merged

ajianaz merged 2 commits into
developfrom
feat/401-cosine-auto-link

Conversation

@ajianaz

@ajianaz ajianaz commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

Implements #401.

Summary

Add cosine-similarity auto-linking to the remember() pipeline.

How it works

After every remember(), search the vector index for top-20 similar memories:

  • Cosine >= 0.80: create similar_to edge
  • Cosine >= 0.92: create possible_duplicate edge

Key decisions

  • Runs AFTER index.insert() (cora finding: must be searchable)
  • Namespace-scoped: only links within same namespace (cora finding: cross-namespace is wrong)
  • Best-effort: errors logged, never fails remember()
  • Thresholds are constants (will be configurable in future)

New edge types

  • EDGE_SIMILAR_TO = "similar_to"
  • EDGE_POSSIBLE_DUPLICATE = "possible_duplicate"

Tests

2 integration tests (marked #[ignore] — require ONNX embedder like other Uteke::open tests).

Milestone: v0.3.0 — Graph RAG

Add auto_link_cosine() to edges.rs — runs after every remember():

- Searches vector index for top-20 similar memories
- Creates similar_to edge when cosine >= 0.80
- Creates possible_duplicate edge when cosine >= 0.92
- Best-effort: errors logged, never fails remember()

New edge types: EDGE_SIMILAR_TO, EDGE_POSSIBLE_DUPLICATE
Thresholds are constants (will be configurable in future).

Tests marked #[ignore] (require ONNX embedder like other integration tests).
Comment thread crates/uteke-core/src/edges.rs Fixed
Comment thread crates/uteke-core/src/edges.rs Fixed
@github-actions

github-actions Bot commented Jun 21, 2026 •

Copy link
Copy Markdown

🔍 Cora AI Code Review

❌ Blocked — critical issues found.

🔴 Error (1)

  • crates/uteke-core/src/memory/crud.rs:355 — In memories_in_namespace, the iterator uses .filter_map(|r| r.ok()) after query_map(...). That means any per-row deserialization or SQLite row access error is silently ignored and the function still returns Ok(ids). Since auto_link_cosine() relies on this list to scope links by namespace, a partial read can cause missing or inconsistent edge creation without surfacing an error.

Review powered by cora-cli · BYOK · MIT

pub fn memories_in_namespace(&self, namespace: &str) -> Result<Vec<String>, Error> {
let mut stmt = self
.conn
.prepare("SELECT id FROM memories WHERE namespace = ?1")
@ajianaz
ajianaz merged commit 89415e7 into develop Jun 21, 2026
8 of 9 checks passed
@ajianaz
ajianaz deleted the feat/401-cosine-auto-link branch June 21, 2026 12:58
ajianaz added a commit that referenced this pull request Aug 13, 2026
…#421)

Add auto_link_cosine() to edges.rs — runs after every remember():

- Searches vector index for top-20 similar memories
- Creates similar_to edge when cosine >= 0.80
- Creates possible_duplicate edge when cosine >= 0.92
- Best-effort: errors logged, never fails remember()

New edge types: EDGE_SIMILAR_TO, EDGE_POSSIBLE_DUPLICATE
Thresholds are constants (will be configurable in future).

Tests marked #[ignore] (require ONNX embedder like other integration tests).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants