#1897·graphiti

node_distance edge search misaligns scores when facts share a source

Author: Shy7777Created Sep 18, 2026Updated Sep 30, 2026

What happened

With EdgeReranker.node_distance, edge_search() can return more edges than scores when multiple facts have the same source node. A consumer pairing the two lists can assign a neighbor's score to a center-node fact and omit later facts.

Reproduction

On main (de8eb5b896c05ed1b5b329d4cb52015446d65e21), supply four candidates: two edges whose source is the center node, one whose source is adjacent to the center, and one whose source is unconnected. Use the node-distance reranker with the default minimum score of zero and a limit of four.

  • Returned edges: both center-node edges, then the adjacent-node edge, then the unconnected edge.
  • Actual scores: [10.0, 1.0, 0.0].
  • Expected scores: [10.0, 10.0, 1.0, 0.0].

With a limit of two, the lengths happen to match, but the second center-node edge still receives 1.0 instead of 10.0.

Cause and proposed fix

edge_search() expands each reranked source UUID into its edge UUIDs, while retaining the per-source score list. Expand the score at the same time so every edge inherits its source's distance score. This needs no change to the distance calculation, filtering, or final limit.

I have a focused fix and three deterministic regression cases using the real distance reranker, with retrieval and database calls mocked. No database or model API is needed to reproduce this. This is separate from #1609, which concerns sorting edge-score pairs in the episode_mentions branch.

Regression test: test_edge_node_distance_scores.py.