fix(jrag): honor JAVA_CODEBASE_RAG_SOURCE_ROOT over a stray ancestor marker#387
Merged
Conversation
…marker jrag._resolve_cfg passed source_root=discover_project_root(cwd) into resolve_operator_config, which only honors JAVA_CODEBASE_RAG_SOURCE_ROOT when source_root is None. So any ancestor .java-codebase-rag marker silently overrode the env var that pipeline.subprocess_env sets for the cocoindex child (and that operators/tests rely on), making `jrag imports/outline <rel-file>` resolve against the wrong root → "file not found", exit 2. Pass source_root=None instead, mirroring cli._resolved_from_ns: resolution is now env var → YAML source_root → discover_project_root(cwd). Interactive use (discovery fallback) is unchanged; the #383 config_source pointer is preserved. Regression test creates a non-empty ancestor marker + sets the env var and asserts the env var wins (fails on pre-fix code, passes with the fix). Co-Authored-By: Claude <noreply@anthropic.com>
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.
Summary
Fixes the 3
test_jrag_traversal_compose.pyfailures (test_outline_lists_file_symbols,test_imports_resolves_graph_nodes,test_imports_text_mode_marks_unresolved) by makingjraghonorJAVA_CODEBASE_RAG_SOURCE_ROOTover a stray ancestor.java-codebase-ragmarker — matchingresolve_operator_config's intended precedence (env var > YAML > discovery) and thejava-codebase-ragCLI.Root cause
jrag._resolve_cfgpassedsource_root=discover_project_root(Path.cwd())intoresolve_operator_config. That function only honorsJAVA_CODEBASE_RAG_SOURCE_ROOTwhensource_rootisNone(config.py: the env-var branch is theelseofif source_root is not None). So whenever any ancestor ofcwdhad a.java-codebase-rag/marker, the discovered root was passed explicitly and the env var was silently ignored — even thoughpipeline.subprocess_envsets exactly that env var for the cocoindex child and the operator/test contract relies on it.Symptom:
jrag imports <rel-file>resolved<file>against the wrong source root and returnedfile not found ... (looked at <source_root>/...), exit 2.This is the same class of hijack issue #357 addressed for
$HOME, generalized: any ancestor marker beats an explicit env var. CI stayed green only because a clean checkout has no stray marker; the failures reproduced anywhere a.java-codebase-rag/index existed up-tree from the run dir.Fix (
java_codebase_rag/jrag.py)_resolve_cfgnow passessource_root=None, mirroringcli._resolved_from_ns(which passesNoneunless--source-rootis given).resolve_operator_configthen resolves: env var → YAMLsource_root→discover_project_root(cwd). Interactive use (no env var) is unchanged — discovery still runs as the fallback. Theconfig_sourcepointer behavior from #383 is preserved (it's part ofresolve_operator_config's index-dir path, which still runs).Test (
tests/test_jrag_status.py)test_resolve_cfg_honors_source_root_env_over_stray_marker— creates a non-empty.java-codebase-rag/marker in an ancestor of cwd, setsJAVA_CODEBASE_RAG_SOURCE_ROOTto a different dir, and asserts_resolve_cfgresolves to the env-var root. Verified to fail on the pre-fix code and pass with the fix, so CI catches future regressions (the traversal tests only caught it when a marker happened to exist locally).Verification
🤖 Generated with Claude Code