Skip to content

fix(config): don't anchor project root on a stray ~/.java-codebase-rag/ index (#357)#367

Merged
HumanBean17 merged 2 commits into
masterfrom
fix/config-project-root
Jul 4, 2026
Merged

fix(config): don't anchor project root on a stray ~/.java-codebase-rag/ index (#357)#367
HumanBean17 merged 2 commits into
masterfrom
fix/config-project-root

Conversation

@HumanBean17

Copy link
Copy Markdown
Owner

What

discover_project_root walked up to and including $HOME, treating a bare .java-codebase-rag/ index dir at $HOME as a project anchor. If an operator ever created ~/.java-codebase-rag/ (e.g. a stray init run from home), any command run from a $HOME subdir that lacks its own marker resolved the project root to $HOME and silently operated on the home-level index — surprising cross-project index resolution.

Fix

The index-dir anchor now applies below $HOME only. At $HOME itself, only a config file (.java-codebase-rag.yml / .yaml) anchors — a deliberate home-level config is intentional and preserved. A bare stray index dir at $HOME no longer hijacks resolution.

This matches the issue's suggested fix ("only anchor on a config file at $HOME, not a bare index dir").

Test

Two new tests in TestDiscoverProjectRoot (TDD: the stray-index test failed first, then passed):

  • test_discover_project_root_ignores_stray_index_dir_at_home — stray ~/.java-codebase-rag/ no longer anchors.
  • test_discover_project_root_config_at_home_still_anchors — a config file at $HOME still anchors even beside a stray index dir.

All existing discover_project_root tests still pass (config-at-home boundary, non-empty/empty index dir below home, config-wins-over-index, etc.).

.venv/bin/python -m pytest tests/test_config.py -q
# 33 passed

Notes

  • No re-index, env-var, or ontology_version change — discovery logic only.

Closes #357.

🤖 Generated with Claude Code

HumanBean17 and others added 2 commits July 3, 2026 23:33
…g/ index (#357)

discover_project_root treated a bare .java-codebase-rag/ index dir at $HOME as
a project anchor, so a stray home-level index (e.g. an accidental `init` from
home) hijacked resolution for any command run from a $HOME subdir without its
own marker — silently reading/writing the home-level index. Demote the index-dir
anchor below $HOME only; a config file at $HOME still anchors (a deliberate
~/.java-codebase-rag.yml is intentional).

Co-Authored-By: Claude <noreply@anthropic.com>
test_discover_project_root_config_at_home_still_anchors created an EMPTY
stray ~/.java-codebase-rag/ dir, but _has_index_dir requires non-empty
(any(idx.iterdir())), so the index-anchor check never saw it -- the test
passed regardless of whether a stray index was actually present and did
not represent its own documented "stray index dir beside it" scenario.
Write a code_graph.lbug into the stray dir (mirroring the companion
ignores_stray_index_dir test) so the fixture is faithful.

Co-Authored-By: Claude <noreply@anthropic.com>
@HumanBean17

Copy link
Copy Markdown
Owner Author

Addressed a review finding: test_discover_project_root_config_at_home_still_anchors created an EMPTY stray ~/.java-codebase-rag/ dir, which _has_index_dir (requires non-empty) couldn't see — so the test passed regardless of whether a stray index was present and didn't represent its own "stray index dir beside it" docstring. Now writes a code_graph.lbug into the stray dir (mirroring the companion test).

@HumanBean17 HumanBean17 merged commit 8725f03 into master Jul 4, 2026
1 check passed
@HumanBean17 HumanBean17 deleted the fix/config-project-root branch July 4, 2026 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

config: discover_project_root walks up to $HOME → risk of cross-project index resolution

1 participant