Skip to content

add walk-up config discovery and configurable source root#270

Merged
HumanBean17 merged 3 commits into
masterfrom
feat/pr-1-dirs-hierarchy
Jun 6, 2026
Merged

add walk-up config discovery and configurable source root#270
HumanBean17 merged 3 commits into
masterfrom
feat/pr-1-dirs-hierarchy

Conversation

@HumanBean17

Copy link
Copy Markdown
Owner

Summary

Implements propose/active/DIRS-HIERARCHY-PROPOSE.md and plans/active/PLAN-DIRS-HIERARCHY.md (PR-1).

  • Walk-up config discovery: CLI and MCP server walk up from cwd to find .java-codebase-rag.yml/.yaml, like git finds .git. First match wins, stops at $HOME (inclusive).
  • source_root YAML field: Optional YAML key resolved relative to the config file directory (not cwd). Useful for monorepos where the config lives above the Java source tree.
  • Precedence chain: CLI --source-root > JAVA_CODEBASE_RAG_SOURCE_ROOT env > YAML source_root > walk-up discovery > cwd.
  • init parent-config warning: init prints a soft warning to stderr if a config exists in an ancestor directory.
  • No env vars required: mcp.json.example updated with a minimal zero-env-var config. README and CONFIGURATION docs updated.
  • No breaking changes: Existing workflows (cwd = config dir, explicit env vars) produce identical behavior.

Files changed

File Change
java_codebase_rag/config.py discover_project_root(), two-phase resolve_operator_config()
server.py _project_root() and _resolve_lancedb_uri() use walk-up
java_codebase_rag/cli.py init parent-config warning
tests/test_config.py 12 tests: discovery (6) + precedence (6)
tests/test_mcp_server_project_root.py 1 test: _project_root() walk-up
README.md MCP host wiring updated for walk-up
docs/CONFIGURATION.md Precedence table, source_root YAML field, walk-up docs
mcp.json.example Minimal zero-env-var config

Test plan

  • 13 named tests pass (6 discovery + 6 precedence + 1 server integration)
  • Existing test suite passes without JAVA_CODEBASE_RAG_RUN_HEAVY
  • ruff check . clean
  • Manual: run java-codebase-rag meta from a subdirectory of an indexed project — should discover config via walk-up

🤖 Generated with Claude Code

@HumanBean17 HumanBean17 force-pushed the feat/pr-1-dirs-hierarchy branch from 1dfeb79 to 0ab4cdd Compare June 6, 2026 17:38
HumanBean17 and others added 2 commits June 6, 2026 21:15
Implements propose/active/DIRS-HIERARCHY-PROPOSE.md as a single PR.

- discover_project_root(start) walks from start upward looking for
  .java-codebase-rag.yml/.yaml, first match wins, stops at $HOME
  (inclusive). Mirrors git's .git discovery.
- resolve_operator_config() uses two-phase resolution: phase 1 finds
  the config file directory via walk-up, phase 2 resolves effective
  source root from CLI > env > YAML source_root > discovery > cwd.
- server.py _project_root() and _resolve_lancedb_uri() use walk-up
  when JAVA_CODEBASE_RAG_SOURCE_ROOT is unset.
- cli.py init emits a soft warning when a parent config is detected.
- YAML config gains an optional source_root field resolved relative
  to the config file directory (not cwd).
- mcp.json.example shows minimal zero-env-var config.
- README and CONFIGURATION docs updated for walk-up and source_root.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- server.py main() passes source_root=None to resolve_operator_config
  so YAML source_root is resolved in Phase 2, not skipped. The previous
  code passed _project_root() as source_root, which caused the CLI path
  to skip YAML resolution (C1 from code review).
- cli.py _cmd_diagnose_ignore uses cfg.source_root instead of
  server._project_root() to avoid divergence when YAML source_root
  is set (I3 from code review).
- add test for YAML source_root resolution via server path.
- add tests for init parent-config warning detection.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@HumanBean17 HumanBean17 force-pushed the feat/pr-1-dirs-hierarchy branch from 0ab4cdd to 4395e64 Compare June 6, 2026 18:15
Update test_mcp_server_loads_yaml_config_at_startup and
test_mcp_server_yaml_config_precedence_env_over_yaml to expect
resolve_operator_config(source_root=None) instead of the old
resolve_operator_config(source_root=_project_root()).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@HumanBean17 HumanBean17 merged commit ca005a9 into master Jun 6, 2026
1 of 2 checks passed
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.

1 participant