fix(mcp): report duplicate kg_add reuse - #2286
Open
MichaelWave369 wants to merge 1 commit into
Open
Conversation
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.
Closes #2268.
tool_kg_addpreviously returned the same success shape for a fresh insert and an existing open triple reused byKnowledgeGraph.add_triple(). That meant a caller could not tell whether this call created the fact or reused an existing row whose provenance remained unchanged.This patch keeps deduplication and storage semantics untouched and makes the MCP response truthful:
reason"reason": "already_exists"This deliberately does not modify
KnowledgeGraph.add_triple(), so it is orthogonal to #1139's NULL-metadata backfill work.Regression coverage pins three cases:
already_exists, returns the same triple id, and leaves the original stored provenance intact;Validation against current
develop(639c69a):python -m pytest -q tests/test_kg_add_duplicate_reason.pypython -m pytest -q tests/test_mcp_server.py -k 'kg_add or kg_query'ruff check mempalace/mcp_server.py tests/test_kg_add_duplicate_reason.pyruff format --check mempalace/mcp_server.py tests/test_kg_add_duplicate_reason.pypython -m compileall -q mempalace/mcp_server.py tests/test_kg_add_duplicate_reason.pyAll passed locally in the fork's GitHub Actions validation run.