Files
codebase-memory-mcp/src/graph_buffer
Andrew Studnicky d08fccd912 fix(graph_buffer): merge duplicate-edge properties commutatively
confidence, strategy and via are not part of the edge dedup key
(source:target:type), and the same logical edge is legitimately minted by more
than one strategy carrying different values — pass_calls emits CALLS edges from
both LSP resolution and registry-textual matching. cbm_gbuf_insert_edge
replaced the stored blob unconditionally, and per-worker edge buffers merge in
worker-slot order, so which strategy's attributes survived was a function of
thread scheduling: the edge set stayed stable while its attributes flickered
run to run.

Replace the overwrite with a total order over the two candidates, which makes
the result commutative and associative and therefore independent of arrival
order:

  1. higher "confidence" wins, which also enforces the intended precedence
     that an LSP-resolved call outranks a textual match;
  2. on equal confidence, the lexicographically greater blob wins, giving a
     deterministic choice between otherwise equal candidates.

An empty or absent incoming blob still never displaces stored properties.

Adds three tests: order independence for the same pair of blobs inserted both
ways, the higher-confidence winner regardless of arrival, and the existing
empty-blob guard. The first two fail before this change.

Signed-off-by: Andrew Studnicky <a.j.studnicky@gmail.com>
2026-08-06 08:26:45 -04:00
..