fix(config): don't anchor project root on a stray ~/.java-codebase-rag/ index (#357)#367
Merged
Conversation
…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>
Owner
Author
|
Addressed a review finding: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
discover_project_rootwalked up to and including$HOME, treating a bare.java-codebase-rag/index dir at$HOMEas a project anchor. If an operator ever created~/.java-codebase-rag/(e.g. a strayinitrun from home), any command run from a$HOMEsubdir that lacks its own marker resolved the project root to$HOMEand silently operated on the home-level index — surprising cross-project index resolution.Fix
The index-dir anchor now applies below
$HOMEonly. At$HOMEitself, 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$HOMEno 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$HOMEstill anchors even beside a stray index dir.All existing
discover_project_roottests still pass (config-at-home boundary, non-empty/empty index dir below home, config-wins-over-index, etc.).Notes
ontology_versionchange — discovery logic only.Closes #357.
🤖 Generated with Claude Code