Implement a new MCP tool and API that exposes similar dup...#492
Draft
philwinder wants to merge 3 commits intomainfrom
Draft
Implement a new MCP tool and API that exposes similar dup...#492philwinder wants to merge 3 commits intomainfrom
philwinder wants to merge 3 commits intomainfrom
Conversation
Implements POST /api/v1/search/duplicates endpoint and the kodit_find_duplicates MCP tool for finding semantically similar code snippets within a repository. Key changes: - Add FindAll to EmbeddingStore interface (SQLite + VectorChord impls) - Add DuplicateSearch service with normalize-once triangle scan (O(N·D) normalize + N*(N-1)/2 dot products); hard cap at 5000 embeddings - Add POST /api/v1/search/duplicates handler with threshold/limit params - Add kodit_find_duplicates MCP tool (repo_url, threshold, limit) - Wire DuplicateFinder into MCP server and scoped handler - Add E2E tests covering validation, empty results, and pair detection Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Spec-Ref: helix-specs@30382ed
Contributor
Go Test CoverageTotal coverage: 31.3% Full coverage report |
Adds TestSmoke_Duplicates which registers a plain local directory containing two semantically similar Python files, waits for embeddings, then asserts that both the REST API (POST /api/v1/search/duplicates) and the MCP tool (kodit_find_duplicates) return at least one pair with cosine similarity >= 0.50. Also adds postJSON helper for raw HTTP POST calls in smoke tests. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Spec-Ref: helix-specs@30382ed
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Spec-Ref: helix-specs@595b2e8
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.
Implement a new MCP tool and API that exposes similar duplicated chunks for a repository. Accept the repository ID as a query parameter because we might want to compare over multiple repositories in the future. This should be a POST request like the search endpoints. It should probably live with the search APIs.
In terms of actual functionality, it shall compute the similarity of all embeddings against all other embeddings to find snippets that are highly similar. We will then threshold those results so that we only get really similar snippets. Again, that is another optional parameter.
The trickiest part of this whole thing is figuring out a fast way of calculating that comparison of all embeddings against all other embeddings. That's computationally hard, so we need to find a shortcut.
In the end, we should add an end-to-end test to the application service that implements this, and we should also manually test the API. Make dev will be running in the background so you can call localhost:8080.
Use TDD where appropriate. Please test edge cases.
🔗 Open in Helix
🚀 Built with Helix