graphify icon indicating copy to clipboard operation
graphify copied to clipboard

explain: the ambiguity message says retry with the repo-relative path, but a path resolves to the file node, not the symbol; there is no path-scoped symbol form

Open rilkerfc opened this issue 2 months ago • 0 comments

Prior art, so this is not a duplicate

  • #3176 (closed 2026-08-29) reported the silent pick and, under "Attempted workaround (does not work)", tried path::run_sweep and got "No node matching". The fix that closed it added the ambiguity guard and the id list. The qualifier half was not addressed, and the new message now recommends it.
  • #2467 (fixed) repaired the other half of the same hint: the printed node id could not be fed back into explain. This issue is the same shape for the "repo-relative path" half.
  • #569 (open) proposes explain --file <path> [--line N] for monorepos; that flag would also resolve this. This issue is narrower: the message today points at a form that resolves to the wrong node.

Repro

src/components/Widget.tsx
  export function Widget({ label }: { label: string }) { return <span>{label}</span>; }
  export function helper(n: number): number { return n + 1; }

src/screens/Home.tsx
  import { Widget, helper } from '../components/Widget';
  function Widget() { return <div>local</div>; }
  export function HomeScreen(flag: boolean) {
    const a = flag ? helper(1) : helper(2);
    const jobs = [];
    if (flag) jobs.push(helper(3));
    return a + jobs.length;
  }

git init && git add -A && git commit -m init && GRAPHIFY_FORCE=1 graphify update . --force

What happens

$ graphify explain Widget --graph graphify-out/graph.json
Ambiguous: 'Widget' matches 2 nodes in different files.
  src/screens/Home.tsx
    id: src_screens_home_widget
  src/components/Widget.tsx
    id: src_components_widget_widget
Retry with the repo-relative path or the full node id.

$ graphify explain "src/components/Widget.tsx::Widget" --graph graphify-out/graph.json
No node matching 'src/components/Widget.tsx::Widget' found.

$ graphify explain "src/components/Widget.tsx:Widget" --graph graphify-out/graph.json
No node matching 'src/components/Widget.tsx:Widget' found.

$ graphify explain "src/components/Widget.tsx" --graph graphify-out/graph.json
Node: Widget.tsx
  ID:        src_components_widget
  ...

The bare path does resolve, but to the file node: serve._find_node_tiers has a source_exact tier that matches the tokenized query against source_file, and no tier that combines a path with a label. So the message's first suggestion yields either "No node matching" or a different node than the one asked about. Only the id: works, and an id is not something a reader types from memory.

Expected

Either, ideally both:

  1. A path-scoped symbol form in _find_node, e.g. path::Symbol (the form #3176 already tried), restricting the label match to nodes whose source_file equals the path. #569's --file flag is the same capability spelled as an option.
  2. Until then, the message says what works: "Retry with one of the node ids above."

Where

  • graphify/cli.py, explain branch: prints "Retry with the repo-relative path or the full node id."
  • graphify/serve.py, _find_node_tiers: source_exact is a file-node tier.

Why it matters

The guard from #3176 is good: it stops a same-named local symbol (Home.tsx declares its own Widget) from silently answering for the exported one. The follow-up advice sends the reader one call sideways in exactly the situation the guard was built for.

Version: graphify 0.9.57 (graphifyy on PyPI), Python 3.12.3, Linux.

rilkerfc avatar Sep 11 '26 01:09 rilkerfc