You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
path: shortest path runs on an undirected view, so results can traverse edges backwards #2487
Because _und is undirected and no weight= is passed, the returned route can walk edges
against their direction. On a real Next.js repo (215 nodes, 379 edges, all EXTRACTED):
Three of the five hops point backwards. The rendering is honest — it draws <-- — but
the result is presented under the label "shortest path", which reads as a dependency chain.
Why it matters
imports_from is directional and the direction carries the meaning. "A depends on B" and
"B depends on A" are different facts, and a route that mixes both answers a different
question: "are these two files connected by some chain?" rather than "how does A reach B?"
For an agent asking "how does the login flow reach the users table" — the example used in
the project's own docs — a mixed-direction chain can support a wrong conclusion about
which module owns what.
Suggested fix
A --directed flag (or making directed the default, with --undirected to opt out) using
the directed graph that is already in memory:
networkx is already a dependency, so this needs no new package.
Related: weighting by confidence
shortest_path is also called without weight=, so every edge costs 1 regardless of how
it was derived. Since edges already carry confidence (EXTRACTED / INFERRED / AMBIGUOUS), an optional --by-confidence mode could map confidence to cost and run
Dijkstra, returning the most reliable route rather than the one with fewest hops. On a
mixed corpus the two answers differ; on a code-only corpus they coincide, so the flag would
be a no-op there and cost nothing.
Happy to send a PR for the --directed part if the direction is welcome.
Fixed in v0.9.34. graphify path and the MCP shortest_path tool now respect edge direction by default, building a digraph from the true _src/_tgt directions, so a returned path no longer traverses edges backwards. Use --undirected (CLI) or undirected=true (MCP) to search ignoring direction; when no directed path exists it says so instead of returning a reversed one. Thanks for the report.
Activity
fix(path): respect edge direction by default in path and shortest_path (
safishamsi commentedon Aug 5, 2026
Fixed in v0.9.34.
graphify pathand the MCPshortest_pathtool now respect edge direction by default, building a digraph from the true_src/_tgtdirections, so a returned path no longer traverses edges backwards. Use--undirected(CLI) orundirected=true(MCP) to search ignoring direction; when no directed path exists it says so instead of returning a reversed one. Thanks for the report.Merge upstream/v8 (0.9.38) into feat/clusters
fix(path): respect edge direction by default in path and shortest_path (
Merge branch 'v8' into saidea