fix(memory): reject self-loop edges in graph extractor#2221
Merged
Conversation
Three-layer defense against source_entity_id == target_entity_id edges: - extract_and_store: skip self-loops after entity ID resolution (debug log) - insert_edge_typed: return InvalidInput error for self-loops - migration 044: delete existing self-loops + BEFORE INSERT trigger Adds MemoryError::InvalidInput(String) variant.
0bb6b5b to
0f959d7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
source_entity_id == target_entity_idedges in the knowledge graphextract_and_storeinsemantic/graph.rs: skip self-loops after entity ID resolution with debug loginsert_edge_typedingraph/store/mod.rs: returnMemoryError::InvalidInputfor self-loops044: DELETE existing self-loops + BEFORE INSERT trigger (SQLite lacks ALTER TABLE CHECK)MemoryError::InvalidInput(String)variant following existing thiserror patternsTest plan
zeph-memory::semantic::graph::tests::extract_and_store_skips_self_loop_edges— mock returns self-loop, asserts 0 edges insertedzeph-memory::graph::store::tests::insert_edge_typed_rejects_self_loop— asserts InvalidInput errorcargo nextest run --workspace --features full --lib --bins— 6638 passedCloses #2215