Skip to content

fix(graph): impact reads a node's edges in one unlimited query again - #3341

Merged
colbymchenry merged 1 commit into
mainfrom
claude/land-3249
Nov 18, 2026
Merged

colbymchenry merged 1 commit into
mainfrom
claude/land-3249

Conversation

@colbymchenry

Copy link
Copy Markdown
Owner

Summary

Lands @inth3shadows's #3249 as theirs: their commit, unchanged, on current main, with them as the author, plus a CHANGELOG bullet. Impact traversal is back to its 1.6.2 speed with the same results.

Root cause (from #3248 / #3249)

#3125 made getImpactRecursive read each visited node's dependents as kind IN (<12 kinds>) … ORDER BY kind, source, line, col LIMIT ?. The kind list searches idx_edges_target_kind once per kind, and the LIMIT under that ORDER BY made each read slower still. The walk runs that read once per visited node, so getImpactRadius took 2–3x as long. That shipped in 1.6.3.

Fix (#3249, unchanged)

getIncomingEdgesExceptContains reads WHERE target = ? AND kind != 'contains' with no LIMIT, through a cached statement. The walk slices it to the edge budget as before, so truncated keeps its meaning. A container's members are read without a LIMIT too.

Review and validation

  • Security: every line read. Queries, traversal and tests only; no network, exec, file writes or dependencies. The cherry-picked diff is identical to the PR diff that was reviewed (+98/−6 in 3 files); the only addition here is the CHANGELOG bullet. The commit message differs only in rewording one line that started with #.

  • Red→green: __tests__/graph.test.ts 44 passed with the fix; with main's queries.ts and traversal.ts, its 2 new tests fail (getIncomingEdgesExceptContains is not a function; a LIMIT reached the read).

  • Timing, codegraph's own source (1,377 files, 32k nodes), getImpactRadius best of 7 per process, median of 7 interleaved rounds:

    arm init getNode
    published 1.6.2 18.5 ms 28.2 ms
    main (1.6.3 source) 45.2 ms 59.6 ms
    this branch 18.0 ms 25.8 ms

    Same subgraph on main and this branch: 827 nodes / 2,708 edges for init, 901 / 4,449 for getNode.

  • Same output: on byte-identical copies of the 1.6.3 index, main and this branch return the same nodes (in order), edges (in order) and truncated for all 30,625 non-file nodes at the default budget and depth, and for 3,000 tight-budget cases (maxNodes 1–40, maxEdges 1–60, depth 1–5; 497 of them truncated).

  • Full suite: see the READY report.

Fixes #3248

@Marcos-199-GitHub's #3285 builds on the same commit and adds a schema bump with a new edges index created on open; that part is left out.

🤖 Generated with Claude Code

@colbymchenry
colbymchenry force-pushed the claude/land-3249 branch 2 times, most recently from 629c73b to 559d0c7 Compare November 17, 2026 23:17
…3248)

PR #3125 gave impact traversal a node and edge budget, and fetched each visited
node's incoming edges as `kind IN (<every kind but contains>) ... LIMIT ?`.
Both halves slowed the read the walk makes once per visited node: the kind
list searches the target index once per kind, and the LIMIT under the
read's ORDER BY made it slower still. getImpactRadius took 2-3x as long for
the same subgraph.

The walk now reads `WHERE target = ? AND kind != 'contains'` with no LIMIT,
through a cached statement, and the slice applies the budget as before. A
container's members are read without a LIMIT too, for the same reason. A
contains edge still never takes a budget slot or marks the result
truncated, and the output is unchanged: the same nodes, edges, order and
truncation as main on 20,000 random graphs and 500 traversals of
codegraph's own index.

Fixes #3248

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Impact traversal is 2–3x slower since #3125: incoming edges are fetched with a 12-kind IN list

2 participants