Repository navigation
fix(api-callers): give each client call to its most specific route - #134
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # REQUIREMENTS.md # app/mcp/handlers/route_handlers.py # app/services/graph_traversal.py
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.
Problem
find_api_callerscompares client calls with a route throughmatch_route_and_call. A route parameter matches any segment. Thus a general route also gets the calls of a more specific route.Example (ASP.NET API):
GET api/v{version}/assistants/{id}matched the client callsGET /api/v2/Assistants/details,/drafts, and/system-tool-bundles. These calls belong to the routesapi/v{version}/assistants/details,.../drafts, and.../system-tool-bundles. These routes also exist. ASP.NET and most other frameworks send a call to the most specific route.trace_pathhad the same problem inexternal_callersandexternal_handlers.Fix
app/services/chunking/route_specificity.pyapplies the specificity rule.match_route_and_calldoes not change.details) beats a mixed segment (v{version}). A mixed segment beats a parameter ({id}). Routes of different length (base-relative calls) are compared by their number of literal segments. Equal routes are a tie, and both routes keep the call.find_api_callersfirst resolvespathto its own route in each repository. Then it keeps a call only when that route is also the most specific route for the call. When no known route matchespath, the tool keeps every matching call, as before.trace_pathuses the same rule forexternal_callersandexternal_handlers./{baseUrl}/api/v2/Assistants/{id}) continue to match.docs/mcp-tools-and-resources.mddescribes the rule.Tests
tests/test_route_specificity.py(15 test cases). It covers the rule, base-relative URLs, method and repository separation,find_api_callerson a seeded database, andtrace_path.origin/mainhave the same failures. These failures come from packages that are not installed locally (fastembed, qdrant_client, tree-sitter grammars). The branch adds no new failures.🤖 Generated with Claude Code