Skip to content

The codegraph index FM-Agent analyses is not the one it builds #200

Description

@Dshuishui

Summary

try_codegraph_init(force=True) rebuilds the index by removing .codegraph/
with shutil.rmtree and then running codegraph init. In the default install
this never takes effect, yet the run still prints codegraph index built.

oh-my-openagent makes .codegraph a symlink into
~/.omo/codegraph/projects/, and shutil.rmtree refuses to remove a symlink —
the OSError is swallowed by ignore_errors=True. codegraph init then sees an
index already there and no-ops. Both steps do nothing.

Measured

Two projects, both def alpha(), each indexed once. Change the source to
def beta(), then call try_codegraph_init(force=True):

.codegraph is a real directory   index = ['beta']     -> rebuilt
.codegraph is a symlink          index = ['alpha']    -> not rebuilt

A real incremental run (edit source → commit → --incremental) produced correct
output, but what corrected the index was not the rebuild — it was the codegraph
daemon: [CodeGraph MCP] Auto-synced 1 file(s). The index FM-Agent analyses is
not the one it builds.

The path is reached whenever an index already exists and force=True: full runs
from the second onwards, incremental mode, entry-func mode. Separately, the
rmtree runs unconditionally, so a rebuild that does not happen leaves nothing
behind and nothing rolls it back.

Proposal

Replace rmtree + init with codegraph index — the command codegraph provides
for exactly this ("Rebuild the full index from scratch, same result as a fresh
init"), with no manual deletion. Measured on the same setup: a symlinked, stale
['alpha'] index becomes ['beta'].

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions