Skip to content

fix(diagnose): respect the repo filter and rank candidates from the matched route - #132

Merged
spelech merged 1 commit into
mainfrom
fix/diagnose-issue-repo-filter
Nov 12, 2026
Merged

spelech merged 1 commit into
mainfrom
fix/diagnose-issue-repo-filter

Conversation

@spelech

@spelech spelech commented Nov 12, 2026

Copy link
Copy Markdown
Owner

Problem

diagnose_issue did not obey the repo argument in all result sections.

  • matched_routes[].external_callers showed callers from all repos. A call with repo: "hub-prefix" returned callers from assistant-hub.
  • A stack frame that did not match a file in the requested repo fell back to a file in a different repo.
  • Semantic hits were not checked against repo.

The semantic candidates were also noise. For an exception message with a matched route (POST /api/v2/Tools/{id}/publish), the candidates were SystemToolId, a Python main, and other unrelated symbols. The tool did not show the route handler or the code that the handler calls.

Fix

  • match_routes_and_callers filters api_client_calls by repo when repo is set. Without repo, cross-repo callers stay.
  • _find_matching_indexed_file does not fall back to other repos when repo is set.
  • New module app/services/diagnostic_route_path.py:
    • collect_route_path_symbols gets the matched route handlers and their callees from trace_symbol_path (callees, depth 3). It keeps only calls that resolve to an indexed definition in the repo. Library calls (for example ExecuteReader) are skipped.
    • keep_semantic_hit drops search hits from other repos and from test files. When a route matched, it also drops hits in a different language than the route handler.
  • find_semantic_candidates puts the route call path first, nearest first. Search hits fill the remaining slots. If the call path fills limit, the tool does not run the search.
  • Each candidate has two new fields: source (route_handler, route_callee, or semantic) and depth. Route-path candidates have score: null.
  • Path handling did not change.
  • The docs (docs/mcp-tools-and-resources.md and docs/reference/mcp-tools.md) describe the new behavior. REQUIREMENTS.md is regenerated.

Tests

  • New file tests/test_diagnose_repo_filter_route_candidates.py (SQLite fixture, search is mocked). It copies the reported case: two repos with the same controller, service, and repository chain, and the same route.
  • 5 of the new tests fail on main and pass on this branch.
  • Full local suite: the same failures and errors as main (missing optional packages). The 12 new test cases pass.

🤖 Generated with Claude Code

@spelech
spelech merged commit 79aecc8 into main Nov 12, 2026
15 checks passed
@spelech
spelech deleted the fix/diagnose-issue-repo-filter branch November 12, 2026 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant