fix(context): make ContextGraph.add_edge idempotent by deduping on edge_id - #926
fix(context): make ContextGraph.add_edge idempotent by deduping on edge_id#926pravit-amp wants to merge 1 commit into
Conversation
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
PR Summary by QodoMake ContextGraph.add_edge idempotent by deduping edges on edge_id
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can enable the Remediation agent and Qodo fixes findings in a dedicated fix PR |
Fixes #922
ContextGraph._add_internal_edgeappended every edge unconditionally, so adding the same edge twice stored two copies sharing one content-derivededge_id. This inflatedstats()["edge_count"], pusheddensity()past 1.0, and made re-ingest double the edge set on every run.Changes
edge_id -> ContextEdgeindex (_edge_index), mirroring howself.nodesdedupes by node ID._add_internal_edgenow returnsFalsewhen theedge_idalready exists, before touchingedges,edge_type_index, or_adjacency, and before firing the mutation callback (no phantom ADD_EDGE audit events).loadandclear()) also clear the new index.add_edgeis a no-op, parallel edges with distinct attributes are preserved, re-ingest viabuild_from_entities_and_relationshipsstays at one edge, andclear()resets the dedupe index.Notes
Testing
tests/context/suite passes (484 tests).