Skip to content

[Bug] KuzuDB 0.11.3 backend: systemic query incompatibilities break call-graph, deps, and resolution phase #769

Closed

Description

@tucaman

Summary

The KuzuDB backend in CGC 0.3.1 has three distinct query compatibility failures with KuzuDB 0.11.3 that collectively break call-graph edges, dependency analysis, and the resolution phase of indexing. These appear to be the root cause behind several existing open issues (#727, #756, #757, #683, #684).

Environment

  • CGC: 0.3.1
  • KuzuDB: 0.11.3 (kuzu Python package)
  • Python: 3.13.5
  • OS: Windows 11
  • Config: INDEX_SOURCE=false, INDEX_VARIABLES=false, DEFAULT_DATABASE=kuzudb

Three Distinct Failures

1. Resolution phase: "Casting between NODE and NODE is not implemented"

During the resolution phase (after parsing completes at 100%), every single call-graph edge insertion fails:

ERROR - Kuzu Query failed:
    OPTIONAL MATCH (caller:Function {name: $caller_name, path: $caller_file_path})
    ... Error: Runtime exception: Casting between NODE and NODE is not implemented.

Impact: Zero call-graph edges are stored. The resolution phase burns CPU for ~45+ minutes on a 1312-file repo producing no useful output. analyze callers and analyze calls return empty or near-empty results.

Related issues: #756, #683

2. Dependency queries: "Variable file is not in scope"

analyze deps (module dependencies) fails with a Binder exception:

MATCH (file:File)-[imp:IMPORTS]->(module:Module {name: $module_name})
WHERE 1=1 {repo_filter}
OPTIONAL MATCH (repo:Repository)-[:CONTAINS]->(file)
... Error: Binder exception: Variable file is not in scope.

The file variable from the first MATCH clause is not visible in the subsequent OPTIONAL MATCH in KuzuDB's query planner.

Related issues: #757, #684

3. Fulltext index creation: Parser exception on CALL db.idx.fulltext.createNodeIndex

On every cgc command (list, find, etc.), two errors appear:

ERROR - Kuzu Query failed: CALL db.idx.fulltext.createNodeIndex('Function', 'name', 'source', 'docstring')
... Error: Parser exception: Invalid input <CALL db.>: expected rule oC_Statement

Impact: Full-text search (find content) is broken. Node lookup (find name) still works because it uses exact match, not fulltext.

What Works vs What's Broken

Feature Status Notes
find name (exact node lookup) ✅ Works Simple node query
find pattern (substring) ✅ Works Simple node query
analyze tree (inheritance) ✅ Works INHERITS edges stored during parse phase
analyze callers (call graph) ❌ Broken "Casting NODE/NODE" kills edge creation
analyze calls (callees) ❌ Broken Same casting error
analyze chain (call chain) ❌ Broken Depends on call edges
analyze deps (imports) ❌ Broken "Variable not in scope"
find content (fulltext) ❌ Broken Fulltext index creation fails

Reproduction

# 1. Install CGC with KuzuDB
pip install codegraphcontext kuzu

# 2. Configure
cgc config set DEFAULT_DATABASE kuzudb
cgc config set INDEX_SOURCE false
cgc config set INDEX_VARIABLES false

# 3. Index any Python repo with >50 files
cgc index /path/to/repo --force
# Observe: progress bar reaches 100%, then resolution phase spews
# "Casting between NODE and NODE" errors for 30-60+ minutes

# 4. Test queries
cgc analyze callers "any_function"  # empty or near-empty
cgc analyze deps "any_module"       # crashes with "Variable not in scope"
cgc find content "any_string"       # fails silently (no fulltext index)

Root Cause Hypothesis

CGC's Cypher queries were likely developed/tested against an older KuzuDB version (possibly 0.8.x-0.10.x). KuzuDB 0.11.x appears to have introduced:

  • Stricter type casting rules for node variables across OPTIONAL MATCH chains
  • Changes to variable scoping in multi-clause queries
  • Different syntax for fulltext index creation (CALL db.idx... vs whatever the new API is)

Suggested Fix

The database_kuzu.py translation layer needs to be updated for KuzuDB 0.11.x query semantics. The three failures are in different query patterns but share a common cause: the Neo4j-to-Kuzu query translator produces queries that 0.11.x rejects.

Additionally, the resolution phase should fail fast rather than retrying the same broken query pattern thousands of times. A single failed OPTIONAL MATCH pattern should disable that query type for the rest of the run, not repeat the error for every call in every file.

Workaround

For users who only need symbol lookup (find name, find pattern, analyze tree), CGC with KuzuDB still works. The parsing phase correctly stores nodes and inheritance edges. Call-graph and dependency features require either:

  • Downgrading kuzu to a compatible version (untested — which version works?)
  • Using Neo4j or FalkorDB backend instead

Activity

  1. github-actions commented on Mar 29, 2026

    @github-actions
    Contributor

    Hi! 👋 Join our CodeGraphContext Discord channel to collaborate: https://discord.gg/dR4QY32uYQ

  2. Shashankss1205 commented on Mar 29, 2026

    @Shashankss1205
    Collaborator

    Hey @tucaman I am working on the exact same bug, there's a bug in kuzudb indexing logic and hence I need some time figuring this out

  3. Shashankss1205 commented on Mar 29, 2026

    @Shashankss1205
    Collaborator

    Hey @tucaman can you check if the kuzudb indexing works now??

  4. tucaman commented on Mar 29, 2026

    @tucaman
    Author

    Hey @tucaman can you check if the kuzudb indexing works now??

    Did you make any progress already? Or do you want me to create a fix?

  5. Shashankss1205 commented on Mar 29, 2026

    @Shashankss1205
    Collaborator
  6. tucaman commented on Mar 29, 2026

    @tucaman
    Author
  7. Shashankss1205 commented on Mar 29, 2026

    @Shashankss1205
    Collaborator

    Hey @tucaman can you check if the kuzudb indexing works now??

    Did you make any progress already? Or do you want me to create a fix?

    Fixed it in the latest PR, need some testing

  8. tucaman commented on Mar 29, 2026

    @tucaman
    Author

    @Shashankss1205 Thanks for the quick response!

    We upgraded from 0.3.1 → 0.3.4 (via uv pip install --upgrade codegraphcontext) and re-tested. Same three failures persist on 0.3.4:

    1. Fulltext index: CALL db.idx.fulltext.createNodeIndex still fails with parser exception on every command
    2. Deps query: analyze deps still crashes with "Variable file is not in scope"
    3. Call-graph edges: analyze callers "transform" returns only 1 caller (should be dozens) — resolution phase still logs "Casting between NODE and NODE" for every edge

    We also tried installing 0.3.5 but it can't resolve — it depends on inquirerpy>=0.3.5 which doesn't exist on PyPI yet:

    Because only inquirerpy<=0.3.4 is available and codegraphcontext==0.3.5
    depends on inquirerpy>=0.3.5, we can conclude that codegraphcontext==0.3.5
    cannot be used.
    

    Happy to test a fix if you point us to a branch or pre-release. Our setup:

    • KuzuDB 0.11.3, Python 3.13.5, Windows 11
    • ~1312 Python files indexed
    • Config: INDEX_SOURCE=false, INDEX_VARIABLES=false
  9. Shashankss1205 commented on Mar 29, 2026

    @Shashankss1205
    Collaborator

    Hey, please test 0.3.5 and beyond versions.

    https://pypi.org/project/codegraphcontext/0.3.5/

  10. tucaman commented on Mar 29, 2026

    @tucaman
    Author

    Hi, would love to, but cannot sync:

    x No solution found when resolving dependencies for split (python_full_version >= '3.14' and sys_platform != 'win32'):
    `-> Because only inquirerpy<=0.3.4 is available and codegraphcontext==0.3.5 depends on inquirerpy>=0.3.5, we can conclude that codegraphcontext==0.3.5 cannot be used.
    And because only codegraphcontext<=0.3.5 is available and your project depends on codegraphcontext>=0.3.5, we can conclude that your project's requirements are unsatisfiable.

      hint: While the active Python version is 3.13, the resolution failed for other Python versions supported by your project. Consider limiting your project's supported Python
      versions using `requires-python`.
    
  11. added a commit that references this issue on Mar 29, 2026
  12. Shashankss1205 commented on Mar 29, 2026

    @Shashankss1205
    Collaborator

    Umm, Another version-
    https://pypi.org/project/codegraphcontext/0.3.7/

    Let me know if this works, or I will have to recheck each dependency again with 100% perfect way out

  13. tucaman commented on Apr 6, 2026

    @tucaman
    Author

    CGC 0.3.9 Upgrade Report — adAPPter_uv (Windows 11)

    Environment

    • OS: Windows 11 (10.0.26100)
    • Python: 3.13.5 (uv venv)
    • KuzuDB: 0.11.3
    • CGC: 0.3.7 → 0.3.9
    • Repo: ~1,312 Python files, 11 workspace packages

    Indexing Results

    Metric 0.3.7 (old) 0.3.9 (new)
    CALLS edges 0 (hung 30-60 min) 42,298 in 11.7s
    Inheritance links 58 58 in 0.2s
    Total index time hung/Ctrl+C 482 seconds
    Post-processing broken 11.9 seconds total

    PR #796 is a massive improvement. The UNWIND batching fix completely resolves the CALLS edge creation failure. Breakdown: fn→fn=34,178, fn→cls=905, cls→fn=6,006, file→fn=1,182, file→cls=27.

    Feature Test Results

    Feature Status Notes
    find name ✅ PASS Found symbols at correct file:line
    analyze callers ✅ PASS 4 callers for transform — works!
    analyze tree ✅ PASS Inheritance hierarchy + 47 methods
    analyze deps ❌ FAIL Same Binder exception: Variable file is not in scope (#757)
    find content ❌ FAIL Fulltext index creation still fails (CALL db.idx.fulltext.createNodeIndex parser error)

    Summary

    3/5 features now working (up from 2/5 on 0.3.7). The CALLS engine rewrite is the key fix — call graph analysis is now functional and fast.

    Still broken:

    Minor issues:

    • .ruff_cache and .pentagon directories generate thousands of "No parser found" warnings — should be added to IGNORE_DIRS or .cgcignore
    • Fulltext index errors fire on every CGC startup (cosmetic but noisy)
  14. moved this from Backlog to In progress in CGC Progress Boardon Apr 29, 2026
  15. Shashankss1205 commented on Apr 30, 2026

    @Shashankss1205
    Collaborator

    Hey @sonxy-cn thanks for bringing this to notice. I will try to shift from kuzudb to ladybug db, because of better maintainability.

  16. moved this from In progress to Done in CGC Progress Boardon May 7, 2026
  17. added a commit that references this issue on Jun 21, 2026
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

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions