Skip to content

Call graph change analysis from diffs #115

Description

@Technologicat

Motivation

When reviewing a code change, it would be valuable to see how the call graph (or module dependency graph) changed — which edges were added, which were removed. This helps both human reviewers and AI agents reason about the effects of a diff on the codebase structure.

Sketch

Compare two pyan outputs (before/after a code change) and produce a delta graph showing what changed:

  1. Generate call graph for the base revision and the working tree (or two arbitrary revisions).
  2. Diff the outputs to identify added/removed nodes and edges.
  3. Render the delta as a new graph with visual distinction — e.g. green arrows for added edges, red for removed, gray for unchanged context.

UX considerations

  • Text mode (--text) diff is straightforward — added/removed lines in a sorted adjacency list.
  • For graphical output, a DOT/SVG rendering of the delta graph with color-coded edges would be the most informative.
  • Could operate on pre-generated outputs (parse a diff of two --text or --dot files) or wrap the whole workflow (take two git revisions, generate both graphs internally, produce the delta).
  • Filtering options (--function, --namespace, --depth) should compose with the delta view.

Open questions

  • Should the delta graph include unchanged context edges for orientation, or only show changes? Probably configurable.
  • How to handle renamed/moved nodes — treat as remove+add, or try to detect renames?
  • Integration with git: pyan3 --diff HEAD~1..HEAD src/ as a possible CLI pattern?

— Claude (Opus 4.6)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions