Skip to content

Branch.head_sha stale after re-indexing an existing project (freezes at creation-time HEAD) #1213

Description

@HorusScale

Summary

Branch.head_sha in the graph does not update when re-indexing an already-existing project. It stays frozen at whatever commit was HEAD when the project was first created, even though the graph content itself (nodes/edges) updates correctly on re-index.

Environment

  • cbm v0.9.0, linux-amd64 release, SHA-256 verified against checksums.txt
  • Invoked directly via cli (no MCP server auto-install), isolated CBM_CACHE_DIR/CBM_ALLOWED_ROOT against a throwaway git repo

Repro (~5 commands)

  1. Fresh index at commit A:
    cli index_repository --repo-path <repo> --name smoketest
    MATCH (b:Branch) RETURN b.head_sha = A. Correct.

  2. Advance HEAD to commit B (real commit, e.g. adding a function). Re-index the same project (default mode):
    cli index_repository --repo-path <repo> --name smoketest
    → graph content updates correctly (node/edge counts increase, new function present in the graph).
    Branch.head_sha still reads A — unchanged.

  3. Advance HEAD to commit C. Re-index explicitly with --mode full:
    → graph content updates again correctly.
    Branch.head_sha now reads B — one commit behind the re-index that caused it, not C.

  4. Control: delete_project then fresh index_repository (no prior project) at current HEAD:
    Branch.head_sha correctly matches current HEAD immediately.

So the bug is specific to re-indexing an existing project — both default and --mode full — not to indexing itself.

Why this matters

Branch.head_sha (and index_status, which we separately confirmed reads live git HEAD rather than indexed-state — always "fresh," not useful either) are the two natural surfaces for a caller to answer "is the index actually caught up with the repo?" Neither gives a trustworthy answer in the normal long-lived-project + incremental-watcher-reindex scenario. A caller trusting Branch.head_sha as a freshness signal would see staleness silently understated forever after the first index, even while the watcher is correctly doing its job content-wise.

Suggested area to look

Whatever code path updates the Branch node's head_sha property likely only runs on project creation, not on the re-index/update path that touches node/edge content.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority/highNeeds near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker.stability/performanceServer crashes, OOM, hangs, high CPU/memoryux/behaviorDisplay bugs, docs, adoption UX

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions