Skip to content

CodeGraph Multi-Root Workspace Issue #1033

Description

@kun-yx

CodeGraph Multi-Root Workspace Issue

Problem

CodeGraph does not index code inside Windows Junction directories, which makes it hard to build a single aggregated workspace for a multi-repo / submodule-style project.

Environment

  • OS: Windows
  • Shell: PowerShell
  • CodeGraph: v1.1.1
  • Backend: node:sqlite - built-in (full WAL)
  • Project layout: one root workspace with multiple independent repositories as Git submodules / gitlinks

Example root layout:

repo-root/
  service-a/
  service-b/
  service-c/
  shared-sdk/
  client-app/

The root repository records these module directories as 160000 gitlink entries.

Use Case

I want to use one CodeGraph MCP project to query the whole workspace across modules, instead of creating and switching between separate CodeGraph indexes for each module.

To do this, I created an aggregated workspace:

repo-root/.cg-workspace/
  service-a -> repo-root/service-a
  service-b -> repo-root/service-b
  service-c -> repo-root/service-c
  shared-sdk -> repo-root/shared-sdk
  client-app -> repo-root/client-app
  .codegraph/
repo-root/.codegraph/

On Windows these entries are Junction directories.

The CodeGraph metadata directory is also shared through a Junction:

repo-root/.codegraph -> repo-root/.cg-workspace/.codegraph

So both the repository root and the aggregated workspace point to the same CodeGraph database directory.

Actual Behavior

Running CodeGraph on the aggregated workspace only indexes a few direct files and does not traverse the Junction directories.

Example:

codegraph index .cg-workspace

Result:

Indexing project
  * Scanning files - 3 found
  * Parsing code - done
  * Resolving refs - done

Indexed 3 files
12 nodes, 17 edges

However, the files are reachable through the Junctions:

rg --files .cg-workspace
# 79 files

rg --files -L .cg-workspace
# 10272 files

So the Junctions are valid, but CodeGraph appears not to follow Windows reparse points during scanning.

There is also an intermittent behavior when using the Junction-based workspace with MCP:

  • At the beginning, CodeGraph may appear to work for a short period.
  • After several MCP queries or file operations, the index seems to degrade or become ineffective.
  • Running codegraph status then shows only a very small number of indexed files, even though the linked modules contain many source files.
  • The status still reports [OK] Index is up to date, but the index statistics become unexpectedly small.

Example normal status before degradation:

CodeGraph Status

Project: repo-root\.cg-workspace

Index Statistics:
  Files:     8,798
  Nodes:     179,256
  Edges:     306,904
  DB Size:   403.63 MB
  Backend:   node:sqlite - built-in (full WAL)
  Journal:   wal

Nodes by Kind:
  method          44,968
  import          44,778
  enum_member     17,472
  function        17,116
  type_alias      11,904
  file            8,779
  struct          6,755
  class           6,700
  field           6,669
  constant        5,133
  enum            3,535
  variable        2,611
  namespace       2,517
  interface       319

Files by Language:
  cpp             3,641
  kotlin          2,468
  c               1,935
  xml             673
  java            61
  properties      17
  yaml            2
  python          1

[OK] Index is up to date

Example degraded status:

CodeGraph Status

Project: repo-root\.cg-workspace

Index Statistics:
  Files:     3
  Nodes:     12
  Edges:     17
  DB Size:   403.63 MB
  Backend:   node:sqlite - built-in (full WAL)
  Journal:   wal

Nodes by Kind:
  function        6
  import          5
  file            1

Files by Language:
  yaml            2
  python          1

[OK] Index is up to date

This makes the setup feel unstable: the workspace may look usable initially, but after a few rounds of usage the effective index no longer represents the full workspace.

Expected Behavior

CodeGraph should provide a way to index an aggregated workspace that uses Windows Junctions / symlinks to compose multiple repositories.

Possible solutions:

  • Add an option such as --follow-symlinks / --follow-junctions
  • Detect Windows Junctions and allow traversal when explicitly enabled
  • Add a workspace configuration file that can include multiple roots
  • Add first-class multi-root / monorepo workspace support for MCP

Why This Matters

For multi-repo projects, indexing each module separately makes MCP usage inconvenient:

  • Cross-module search and call-chain exploration is fragmented
  • The MCP client has to choose one projectPath at a time
  • It is hard to ask workspace-level questions across services/modules

A single aggregated CodeGraph project would make MCP usage much more practical.

Additional Notes

Indexing the root repository directly also does not solve this case because the module directories are Git submodule/gitlink entries. CodeGraph indexes only the root repository files and does not expand the submodule contents.

So both current approaches fail for whole-workspace indexing:

  1. Root repository indexing skips gitlink/submodule contents.
  2. Aggregated workspace indexing skips Junction contents.
  3. Junction-based MCP usage may appear to work briefly, then degrade to an incomplete index after several operations.

A supported multi-root or follow-junction mode would solve this.

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