Fix source_file path lookup for explain and affected#1503
Closed
behavio1 wants to merge 1 commit into
Closed
Conversation
safishamsi
pushed a commit
that referenced
this pull request
Jun 27, 2026
…e nodes (#1503) A path query like `explain "app/api/route.ts"` tokenized to terms that matched no node, so explain/affected returned "No node matching". Source-file paths are now part of the search index and matched exactly (serve._find_node gains a leading source-exact tier; affected.resolve_seed gains a source-file match). When several nodes share a source_file (e.g. a file-level node plus a function node), the lookup prefers the file-level node — the L1 node whose label basename matches the queried filename, falling back to the unique L1 or unique basename match, else None. Ported from PR #1503 by @behavio1. Maintainer fixes on top: aligned trailing- separator handling between resolve_seed and _find_node (affected previously returned None for a trailing-slash path that explain resolved), corrected the stale "three-tier" _find_node docstring, and added regression tests for the trailing-slash parity and the ambiguous-no-file-node -> None case. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Collaborator
|
Thanks @behavio1 — real bug, cleanly fixed, and the multi-node-per-source-file regression tests are exactly the right coverage. The file-node preference (L1 + basename match, with safe fallbacks) is sensible. Landed on |
safishamsi
added a commit
that referenced
this pull request
Jun 28, 2026
Dates the 0.8.51 CHANGELOG and bumps the version. Highlights: Obsidian export no longer overwrites user notes / .obsidian config in an existing vault (#1506); cross-file node-ID cluster fixes — C# resolver (#1466), Go sourceless stubs (#1500), import-stub disambiguation (#1462); Java enum/annotation type nodes (#1512) + generic parents (#1510); explain/affected source-file path lookup (#1503); claude-cli Windows GBK fix (#1505); macOS install docs (#1471) and the global-add docs fix (#1489). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.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.
Summary
This PR fixes full
source_filepath lookup for:graphify explain "<source-file-path>"graphify affected "<source-file-path>"It also adds regression coverage for the case where a graph contains multiple
nodes from the same source file, such as a file-level node plus function nodes.
Root cause
Graphs can contain several nodes with the same
source_file. For example, aroute file can have a file-level
route.tsnode and aGET()handler node fromthe same path.
Before this change:
explaincould miss full path queries because_find_node()tokenizes thequery, while the trigram prefilter only indexed the raw
source_file.affectedcould fail to resolve a full path because exactsource_filelookup returned multiple candidate nodes and no preferred seed.
What changed
source_filetext in theserve.pytrigram search index._find_node()match exact tokenizedsource_filepaths.the same file.
affected.resolve_seed().explain,affected, and_find_node().Validation
Full test result with provider env vars unset: