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
codegraph_get_repository_stats reports an inflated function count for repositories that contain classes with methods. The count includes duplicates because class methods are reachable via two CONTAINS paths.
Steps to Reproduce
pip install codegraphcontext==0.3.1
cgc index /path/to/go/project # Go project with 31 structs and their methods
Then via MCP:
# Per-repo stats reports inflated count:
codegraph_get_repository_stats(repo_path="/path/to/project")
# → functions: 325
# But actual unique functions in the graph:
codegraph_execute_cypher_query("MATCH (f:Function) WHERE f.path STARTS WITH '/path/to/project' RETURN count(f)")
# → 226
# The root cause — CONTAINS* traversal double-counts:
codegraph_execute_cypher_query("MATCH (r:Repository {path: '/path/to/project'})-[:CONTAINS*]->(f:Function) RETURN count(f) AS with_dupes, count(DISTINCT f) AS no_dupes")
# → with_dupes: 325, no_dupes: 226
Root Cause
Class methods are reachable via two paths in the graph:
Repository → File → Function (direct)
Repository → File → Class → Function (via class)
The stats query uses count(f) on CONTAINS* traversal, which counts each method twice. The difference (325 - 226 = 99) exactly matches the number of class methods:
MATCH (c:Class)-[:CONTAINS]->(f:Function) WHEREc.pathSTARTSWITH'/path/to/project'RETURNcount(f)
-- → 99
Fix
Change count(f) to count(DISTINCT f) in the repository stats query.
Environment
codegraphcontext: 0.3.1
Database backend: KùzuDB (default)
Python: 3.12.3
OS: Linux (Ubuntu)
Test repo: Go project with 21 files, 31 structs, 226 unique functions
Hi, I’d like to work on this under GSSoC’26. I’ll keep the fix focused, follow the repo guidelines, and open a clean PR with testing. Could you please assign this to me?
Activity
github-actions commentedon Mar 28, 2026
Hi! 👋 Join our CodeGraphContext Discord channel to collaborate: https://discord.gg/dR4QY32uYQ
mittalsonal commentedon May 29, 2026
Hi, I’d like to work on this under GSSoC’26. I’ll keep the fix focused, follow the repo guidelines, and open a clean PR with testing. Could you please assign this to me?