fix(query): prevent generic symbol query flooding via multiplicity penalty and seed deduplication#1832
Open
devcool20 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.
Description
This PR resolves Issue #1766, which causes query results to be flooded when codebases contain multiple generic/homonymous names (such as Next.js route handlers named
GETorPOST, or framework entrypoints likeindexorhandler).Previously, when a query matched a generic word (e.g.,
"get"), multiple distinct nodes sharing the same generic label (e.g.,GET()) would receive the full_EXACT_MATCH_BONUSand get selected as query seeds. Running a BFS traversal from multiple generic nodes ended up pulling in massive portions of unrelated code, burying the actual specific target.Proposed Changes
Label Multiplicity Penalty (
graphify/serve.py):_label_counts_cache) on the graphG.score /= multiplicity), ensuring generic framework convention names cannot easily overpower specific identifiers.Seed Label Deduplication (
graphify/serve.py):seen_labelstracking set in_pick_seedsto filter out duplicate labels, guaranteeing that only a single representative node gets seeded for any given homonymous label.Validation & Testing
"get users"seededusers_model,api_users_GET, andapi_analytics_GET(flooding the BFS traversal). After the fix, the query correctly seeds onlyusers_modeland a single representativeGETnode (api_analytics_GET).pytest tests/test_serve.py). All 80 unit tests passed successfully with 0 regressions.