Skip to content

detect_changes loses impacted symbols when the indexed project is a subdirectory of a normal Git repository #1951

Description

@quakquak86

Version

codebase-memory-mcp 0.10.8

Platform

Windows 11 Pro build 26200, x64, NTFS

What happened?

detect_changes finds the changed Git file but resolves zero seed symbols when the Codebase Memory project root is a subdirectory of an otherwise normal standalone Git repository.

This does not require a linked Git worktree. The same repository and same change work correctly when Codebase Memory indexes the Git root itself.

Repository layout:

repo/                 <- normal Git root (.git directory)
  game/               <- Codebase Memory project root
    src/
      math.ts
      use.ts

use.ts imports and calls addOne() from math.ts.
With repo/game indexed as cbm-subdir-repro, changing repo/game/src/math.ts gives:

base: HEAD
changed_files: 1
  game/src/math.ts
seed_symbols: 0
impacted_total: 0

Git reports paths relative to the Git root (game/src/math.ts), while graph paths for the subdirectory project are relative to the project root (src/math.ts). The path coordinate systems therefore do not match when seeding the impact traversal.

Control

Indexing the exact same repository from the Git root instead (repo/ as cbm-root-repro) and running the exact same detect_changes request gives:

base: HEAD
changed_files: 1
  game/src/math.ts
seed_symbols: 1
impacted_total: 1
cbm-root-repro.game.src.use (game/src/use.ts):
  useIt Function 1

So Git diff detection and graph impact traversal both work; only the Git-root -> indexed-subdirectory path normalization loses the seed symbols.

Minimal reproduction

mkdir repo/game/src
cd repo

git init
git config user.email repro@example.com
git config user.name repro
Set-Content game/src/math.ts 'export function addOne(x: number): number { return x + 1; }'
Set-Content game/src/use.ts 'import { addOne } from "./math"; export function useIt(): number { return addOne(4); }'
git add .
git commit -m initial

codebase-memory-mcp cli --json index_repository --repo-path "$PWD/game" --name cbm-subdir-repro --mode fast
Set-Content game/src/math.ts 'export function addOne(x: number): number { return x + 2; }'
codebase-memory-mcp cli --json detect_changes --project cbm-subdir-repro --scope impact --direction inbound --depth 2 --since HEAD

For the control, index $PWD as a second project and repeat detect_changes; it returns the useIt caller as expected.

Expected behavior

detect_changes should translate Git-root-relative changed paths into the indexed project's coordinate system before looking up seed symbols. A subdirectory index should provide the same impact result as a root index for files within that subdirectory.

Related issues

#659 is similar in symptom but specifically concerns linked Git worktrees and was closed after worktree-root handling. This reproduction is a normal standalone repository with a .git directory at the parent root and still reproduces on 0.10.8.

#1357 is a separate default-branch resolution issue.

Confirmations

  • Reproduced with a synthetic two-file repository; no proprietary code is needed.
  • Reproduced on current stable release 0.10.8.
  • Searched existing issues; I did not find this normal subdirectory-index case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    windowsWindows-specific issues

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions