fix(mcp): preserve distinct block search results by relationship ID - #2414
Draft
carlomarmo wants to merge 1 commit into
Draft
carlomarmo wants to merge 1 commit into
carlomarmo wants to merge 1 commit into
Conversation
This branch has not been deployed
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
MCP block search results are deduplicated by document, label and truncated preview text. Two distinct relationships in the same document can share that preview, so one result disappears even when their full text differs.
Expose
relationship_idon block hits and deduplicate by that stable identity. Repeated hits for the same relationship still retain the first ranked result; distinct relationships and hits without an identity remain separate.Changes
annotation_id.tools.py, retaining its existing import path for callers.Test plan
python -m unittest opencontractserver.mcp.tests.test_search_results -v: all five tests pass against the production formatter/helper.The same tests with the unchanged baseline deduplication helper fail in three expected cases: identical truncated previews, identical full text on distinct relationships, and missing IDs.
Covers repeated-relationship collapse, retention of the first ranked hit, passage identity and ordering.
Database-backed MCP tests and the full backend suite were not run locally: this workspace has no Docker or PostgreSQL services. These remain for repository CI.
Changed-file pre-commit hooks pass: whitespace, EOF, changelog, pyupgrade, Black, isort and flake8.
Full-project mypy checks 1,642 files and reports the same two errors reproduced on unchanged base
1e859dc(1,641 files):opencontractserver/tests/test_coverage_core_scalars.py:45:ListValueNode.valuesexpects a tuple.config/graphql/automation.py:151:CollectedFieldshas novaluesattribute.Both runs also log the same optional
pdfredactimport warning. No new mypy errors.git diff --checkand changelog validation pass.Checklist
Draft pending integration CI and resolution of the existing type-check baseline.