Skip to content

add CLI + decision engine for incremental Kuzu rebuild (PR-T4)#273

Closed
HumanBean17 wants to merge 11 commits into
masterfrom
feat/tier2-pr4-cli-decision-engine
Closed

add CLI + decision engine for incremental Kuzu rebuild (PR-T4)#273
HumanBean17 wants to merge 11 commits into
masterfrom
feat/tier2-pr4-cli-decision-engine

Conversation

@HumanBean17

Copy link
Copy Markdown
Owner

Summary

  • Decision engine (refresh_decision.py): isolates incremental vs full rebuild logic for both Lance and Kuzu. Detects changes via git diff or explicit changed_paths. Full rebuild triggered on: deletes, renames, config changes, pipeline changes, meta-annotation changes, missing/stale .deps.json, >50% dirty set.
  • CLI integration (java_codebase_rag/cli.py): removes stale Kuzu incremental warning from _cmd_increment. Dispatches to incremental or full Kuzu rebuild based on decision engine. Respects lance_mode for Lance full reprocess when config/pipeline changes.
  • Pipeline wrapper (java_codebase_rag/pipeline.py): adds run_build_ast_graph_incremental — writes changed paths to temp file, calls build_ast_graph.py --changed-paths.
  • MCP tool (server.py): creates refresh_code_index tool that executes Lance + Kuzu rebuild based on decision engine. Backward compatible (confirm=true only still works). Returns decision transparency fields.
  • Tests: 15 tests — 12 decision engine tests (all 9 plan-named tests + 3 additional for missing coverage) + 3 CLI integration tests.

Scope

Implements PR-T4 from plans/active/PLAN-TIER2-INCREMENTAL-REBUILD.md.
Companion proposal: propose/active/INDEX-AUTO-MODE-PROPOSE.md.
Depends on PR-T3 (incremental orchestrator, already merged).

Manual verification

.venv/bin/ruff check .
.venv/bin/python -m pytest tests/test_refresh_decision.py tests/test_cli_increment.py -v

Files changed

File Change
refresh_decision.py New — decision engine with ChangeSet, RefreshDecision, _choose_refresh_mode
java_codebase_rag/cli.py Remove _INCREMENT_WARNING_LINES + _emit_increment_kuzu_warning; update _cmd_increment to dispatch via decision engine
java_codebase_rag/pipeline.py Add run_build_ast_graph_incremental wrapper
server.py Create refresh_code_index MCP tool
tests/test_refresh_decision.py New — 12 decision engine tests
tests/test_cli_increment.py New — 3 CLI integration tests

🤖 Generated with Claude Code

HumanBean17 and others added 4 commits June 6, 2026 21:45
…R-T4)

- Add refresh_decision.py: decision engine that chooses incremental vs full
  rebuild for Lance and Kuzu based on change detection (git diff or explicit
  changed_paths). Full rebuild triggered on deletes, renames, config changes,
  pipeline changes, meta-annotation changes, missing/stale .deps.json, or
  >50% dirty set.
- Update _cmd_increment in CLI: remove stale Kuzu warning, dispatch to
  incremental or full Kuzu rebuild based on decision engine output. Respect
  lance_mode for Lance full reprocess.
- Add run_build_ast_graph_incremental to pipeline.py: writes changed paths
  to temp file, calls build_ast_graph.py --changed-paths.
- Create refresh_code_index MCP tool in server.py: executes Lance + Kuzu
  rebuild based on decision engine, returns decision transparency fields.
- Add 15 tests: 12 decision engine tests + 3 CLI integration tests.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Make refresh_decision import lazy inside _cmd_increment to avoid
  ModuleNotFoundError when running as installed entrypoint
- Update test_registered_tool_surface_is_v2_navigation_only to include
  refresh_code_index in expected tool set
- Fix CLI test mock paths to patch refresh_decision.choose_refresh_mode
  instead of java_codebase_rag.cli.choose_refresh_mode

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ky tests

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The MCP server is a read-only query interface. Building/refreshing the
index belongs in the CLI (java-codebase-rag increment/reprocess), not
as an MCP tool. Remove the tool from server.py, fix test expectations,
and update proposals and plan to remove all MCP integration sections.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@HumanBean17 HumanBean17 force-pushed the feat/tier2-pr4-cli-decision-engine branch from e99248a to bc358b1 Compare June 6, 2026 20:29
HumanBean17 and others added 7 commits June 6, 2026 23:30
… kuzu_graph for meta test

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Commit f512e87 changed CI from pinned requirements.txt to pyproject.toml
ranges, pulling a newer cocoindex that eagerly downloads SentenceTransformer
models during init. CI runners can't reach HuggingFace, causing these tests
to fail with 401/OSError.

Add _heavy_ok() guard that checks both cocoindex binary availability and
RUN_HEAVY env var. CI sets RUN_HEAVY=0, so these integration tests are now
properly skipped.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Previous fix only covered 2 of 11 search tests that call search_v2 without
mocking the SentenceTransformer model loader. Adds the stub to all remaining
tests in test_mcp_v2.py and test_mcp_v2_compose.py.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…e_counts

The test calls _graph_meta_output() which uses the global KuzuGraph
singleton. Other test files reset _instance to None without restoring it,
so by the time this test runs the singleton may be gone, causing
_graph_meta_output() to create a new (empty) instance.

Fix: explicitly re-bind the singleton from the session kuzu_graph fixture
before calling _graph_meta_output().

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…_type_counts

_graph_meta_output() uses KuzuGraph.get() which resolves the DB path from
env vars and may mismatch with the session fixture's tmp_path, causing it
to open an empty DB. Call kuzu_graph.meta() directly instead.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Replace git diff change detection with hash-based diff against .deps.json
  (walk source tree, compare SHA-256 hashes)
- Remove RUN_HEAVY=0 from CI workflow so cocoindex integration tests run
  now that HF_TOKEN is configured
- Update plans/proposals to reflect the new detection strategy

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@HumanBean17 HumanBean17 closed this Jun 6, 2026
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