fix(mcp): prefer definitions and report ambiguity in name resolution#466
Open
KerseyFabrications wants to merge 1 commit into
Open
fix(mcp): prefer definitions and report ambiguity in name resolution#466KerseyFabrications wants to merge 1 commit into
KerseyFabrications wants to merge 1 commit into
Conversation
trace_path resolved a function_name from the first row of an unordered name query with no ambiguity check, so a same-named entity (e.g. a shell script's main()) could silently shadow the intended C main(). get_code_snippet reported "ambiguous" for a short name even when one match was the obvious definition (the .c body vs a .h declaration). Fix: add a deterministic resolution ranking — a callable label outranks a module, then the larger definition by line span wins, preferring a real definition without hardcoding file extensions — and a picker that flags a genuine tie. trace_path now traces the preferred node and returns the existing ambiguous-suggestions response on a true tie instead of silently taking nodes[0]; get_code_snippet resolves directly to the preferred match, reporting ambiguity only for real ties. Adds regression tests tool_trace_call_path_ambiguous and tool_trace_call_path_prefers_definition. Signed-off-by: Kris Kersey <kris@kerseyfabrications.com>
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.
trace_path resolved a function_name from the first row of an unordered name
query with no ambiguity check, so a same-named entity (e.g. a shell script's
main()) could silently shadow the intended C main(). get_code_snippet
reported "ambiguous" for a short name even when one match was the obvious
definition (the .c body vs a .h declaration).
Fix: add a deterministic resolution ranking — a callable label outranks a
module, then the larger definition by line span wins, preferring a real
definition without hardcoding file extensions — and a picker that flags a
genuine tie. trace_path now traces the preferred node and returns the
existing ambiguous-suggestions response on a true tie instead of silently
taking nodes[0]; get_code_snippet resolves directly to the preferred match,
reporting ambiguity only for real ties. Adds regression tests
tool_trace_call_path_ambiguous and tool_trace_call_path_prefers_definition.
Signed-off-by: Kris Kersey kris@kerseyfabrications.com