Skip to content

detect_changes silently defaults to base main on repos whose default branch isn't main, reporting changed_files: 0 with no warning #1357

Description

@artaommahe

Version

codebase-memory-mcp 0.9.1-rc.1

Platform

macOS (Apple Silicon)

Install channel

GitHub release archive / install.sh / install.ps1

Binary variant

standard

What happened, and what did you expect?

Called without base_branch, detect_changes reports base: main even when the repository has no main branch at all, and returns changed_files: 0 with no warning or error. On a clean working tree the result is indistinguishable from a correct "nothing has changed" answer.

This is the quiet-failure case that matters: an agent asking "what does my branch change, and what does it impact?" gets a confident empty answer. Repositories whose default branch is master, trunk, develop, or anything else silently get no impact analysis at all.

Expected: resolve the base from the repository's actual default branch / upstream (git symbolic-ref refs/remotes/origin/HEAD, or the branch's tracking ref), and if the chosen base cannot be resolved, say so — an error or an explicit base_resolved: false / warning field — rather than reporting a base that doesn't exist and an empty diff.

With an explicit --base-branch trunk the tool works correctly: on the same private monorepo it returned 17 changed files exactly matching git diff --name-only trunk...HEAD, 61 seed symbols and 33 impacted symbols. The engine is fine; only base resolution is wrong.

Reproduction

Public repro repo: https://github.com/artaommahe/codebase-memory-mcp-rc-repros — see Case D. Its default branch is trunk and it deliberately has no main branch.

git clone https://github.com/artaommahe/codebase-memory-mcp-rc-repros
cd codebase-memory-mcp-rc-repros

git rev-parse --abbrev-ref HEAD     # trunk
git rev-parse --verify main         # fatal: Needed a single revision  (no such branch)
git status --porcelain | wc -l      # 0   (clean tree)

codebase-memory-mcp cli index_repository --repo-path "$PWD" --mode full --name cbm-rc-repros
codebase-memory-mcp cli detect_changes --project cbm-rc-repros

Observed:

base: main
direction: inbound
changed_files: 0
seed_symbols: 0
impacted_total: 0
impacted_shown: 0
impacted: 0  (rows: name label hop; qn = group prefix + "." + name; nearest hops first)

No warning that main does not exist. --base-branch trunk behaves correctly on the same repo.

Confirmations

  • I searched existing issues and this is not a duplicate.
  • My reproduction uses shareable code (a dummy snippet or a public OSS repository), not proprietary code.

Posted by Claude Code on behalf of @artaommahe

Metadata

Metadata

Assignees

No one assigned

    Labels

    editor/integrationEditor compatibility and CLI integrationwindowsWindows-specific issues

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions