neuralmind.uk / NeuralMind v4.17.0 — an answer from a stale index says so, and package code in __init__.py stays in the graph Edit this page on GitHub ↗

NeuralMind v4.17.0 — an answer from a stale index says so, and package code in __init__.py stays in the graph

Type: Minor release Theme: context the agent can trust. When the index is behind the code, every place the agent reads it from carries one line saying so; and an edit to a package’s __init__.py reaches the graph instead of disappearing from it

A hands-on audit of 12 repositories on v4.12.0 (#640) found two ways the index could fall behind the code without anyone being told:


What changed

A stale index says so, wherever the agent reads it

neuralmind query, the MCP neuralmind_query, neuralmind_search and neuralmind_wakeup tools, and the related-files block each prompt gets (Claude Code’s UserPromptSubmit hook, and the Hermes plugin’s pre_llm_call hook) carry one line when the index can’t vouch for its answer. neuralmind search prints the same line on stderr, so --json output stays parseable.

The line names the first of these that applies:

Condition The line
The index is only in the legacy graphify-out/ layout Index is in the legacy graphify-out/ layout, which NeuralMind no longer reads, so semantic search finds nothing: run neuralmind build <project>.
The git hook’s background rebuild failed after the last successful build Index may be stale: the last background rebuild failed (log: .neuralmind/hook-build.log); run neuralmind build <project>.
Commits since the build started changed files in the project Index is stale: 2 files changed in commits since the last build (src/auth.py, src/session.py); run neuralmind build <project>.
The same, while the hook’s background rebuild is running Index is catching up: 2 files changed in commits since the last build (src/auth.py, src/session.py); a background rebuild is running.

A current index gets no line, so nothing changes in the common case.

How “commits since the build” is decided. The build now records when it started and the commit HEAD pointed at. A query compares the modification time of git’s logs/HEAD with that start time. The reflog is the right clock because a pull checks out commits dated before the build, so commit dates would miss it. Only when HEAD moved does the query run one git diff --name-only <build commit> HEAD -- .. Then a commit elsewhere in a larger repository, or a branch switch that changes nothing in the project, adds no line. If the build’s commit is gone (after a rebase), the line says HEAD moved to commits the index was not built from.

Cost. In the common case the check is a few stat calls and a read of .neuralmind/build_status.json; the git diff runs only after HEAD moved. It never raises: a failed check adds no line rather than breaking the answer.

Where else it shows:

The git hook records a failed rebuild. The post-commit, post-merge, post-checkout and post-rewrite hooks from neuralmind init-hook used to discard the background build’s exit status. Now a failed build leaves .neuralmind/.hook-build.failed and a successful one removes it. A failure older than the last successful build (a manual neuralmind build since) doesn’t count. Re-run neuralmind init-hook . to get the new hooks.

Also: package code in __init__.py stays in the graph

The graph builder parses __init__.py like any other module; the incremental path lost it, two ways:

An index already in that state heals on its next build; doctor’s “files on disk not in graph” line goes away.

What the agent actually sees

When the index is current: nothing new.

When it isn’t, one line, in the place the agent already reads:

## NeuralMind associative recall

Code matching this prompt:
- src/auth.py: login() (L12)

Index is stale: 1 file changed in commits since the last build (src/auth.py); run neuralmind build /home/me/project.

The agent can act on it: rebuild, read the named files directly, or treat the recalled context as possibly out of date.

After the __init__.py fix, code in a package’s __init__.py appears in query and search results and in the prompt’s related files like any other module’s.

Per-agent expectations

Agent What changes
Claude Code (hooks + MCP) The prompt’s related-files block ends with the line when stale; MCP query/wakeup put it above the context and in freshness, search on the first result
Cursor / Cline / Continue (MCP) MCP query/wakeup/search as above; no prompt hook
Hermes-Agent plugin Same prompt block as Claude Code (it runs the same hook action)
Generic MCP client Same as Cursor

Every agent sees __init__.py code it couldn’t see before, once its project is rebuilt.

Upgrading

Not in this release

Reproduce

pytest tests/test_query_freshness.py -v                      # every notice, the hook marker, query + MCP + prompt block
pytest tests/test_g4_incremental.py -k package_init -v      # the scan sees __init__.py edits
pytest tests/test_incremental_wiring.py -k PackageInit -v   # edits reach the graph; a missing file is restored
pytest tests/test_doctor.py -k returns_all_checks -v

# In a built project with the git hooks installed:
echo "# touch" >> some_module.py && git commit -qam "change"
neuralmind query . "how does X work"   # first line: Index is catching up … / Index is stale …
neuralmind doctor .                    # Query freshness line