fix(memory): reject dangling relations#4477
Open
jstar0 wants to merge 1 commit into
Open
Conversation
Signed-off-by: King Star <mcxin.y@gmail.com>
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
Fixes #4457.
The memory server now rejects
create_relationsrequests when either endpoint does not name an existing entity. This prevents the knowledge graph from persisting dangling relations that point at nodes that were never created.Changes
createRelationspreviously filtered only duplicate relations before appending new entries to the graph. That allowed a fresh graph to store relations such asGhost_A -> Ghost_Bwhileentitiesremained empty.This change validates every incoming relation endpoint against the current entity set before saving. If a batch contains an invalid endpoint, the call fails before writing any of the batch, matching the fail-fast behavior already used by
add_observationsfor unknown entities.The memory README now documents that
create_relationsfails when the source or target entity does not exist.Risk / Scope
The change is limited to the memory reference server. Existing valid relations and duplicate-relation skipping behavior are unchanged.
The only behavior change is that
create_relationsnow fails instead of silently storing a relation whosefromortoendpoint is missing.Verification