Skip to content

impact --depth N misses dependents within N hops (depth-limited DFS marks nodes visited at the limit) #1974

Closed

Description

@inth3shadows

codegraph impact <symbol> --depth N, and multi-depth callers, leave out dependents that are within N hops.

On main (ba3c21e):

export function t(){}
export function a(){ t(); }
export function b(){ a(); t(); }
export function c(){ b(); }
codegraph impact t --depth 2   → t, a, b        (expected t, a, b, c: c → b → t is 2 hops)
codegraph impact t --depth 3   → t, a, b, c

Cause: getImpactRecursive (src/graph/traversal.ts:543-600) and getCallersRecursive (:270-317) are depth-limited DFS walks with one shared visited set. Here b is first reached through a at depth 2, the limit, so it's marked visited without being expanded. When it's reached again directly from t at depth 1, it's skipped, so c is never found. Which dependents go missing depends on edge order.

The viewer's blast radius uses the same call (src/ui-server/api/node.ts:462, stats.ts:71, depth 3), so it undercounts the same way.

Suggested fix: walk level by level, as traverseBFS in the same file does, or re-expand a node when it's reached at a smaller depth than before. #1089 fixed a related gate in the same function (dropped edges), but not this. The open changes in #1583 / #1352 keep the recursive DFS, so they don't cover it either.

Activity

  1. colbymchenry commented on Sep 27, 2026

    @colbymchenry
    Owner

    Thanks for the detailed report, @inth3shadows, and thanks for using CodeGraph! This is fixed on main by #2000, which builds on @danusha2345's #1991 (thank you!): impact --depth N (and callers/callees at a depth) now finds every dependent within N hops, even when a longer path reaches one of them first. The fix will be in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions