From a3846b64ae24103f80274ed70a0f66ab6c7f72e4 Mon Sep 17 00:00:00 2001 From: Dmitry Teryaev Date: Sat, 13 Jun 2026 18:42:46 +0300 Subject: [PATCH] fix(update): run incremental graph rebuild, drop stale "not implemented" warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `java-codebase-rag update` did a Lance-only catch-up then unconditionally printed "AST graph (LadybugDB) incremental rebuild is not yet implemented", even though incremental graph shipped (67a76de) and `increment` already calls run_incremental_graph. The two commands share the word "update" but use different code paths; only the `increment` path (cli.py) was rewired — the installer's run_update index step was never updated. Now run_update mirrors `increment`: after run_cocoindex_update it calls run_incremental_graph, so both index layers stay current. The stale warning is removed entirely; on graph-step failure it prints a truthful, actionable message instead of claiming the feature is missing. The warning constant stays in cli.py for the legitimate `increment --vectors-only` opt-out path. Docs/help (cli --help, README, JAVA-CODEBASE-RAG-CLI.md) updated to describe update as artifact refresh + incremental Lance/graph catch-up, and to drop the false "prints graph staleness warning" line. Co-Authored-By: Claude --- README.md | 4 ++-- docs/JAVA-CODEBASE-RAG-CLI.md | 4 ++-- java_codebase_rag/cli.py | 5 +++-- java_codebase_rag/installer.py | 31 +++++++++++++++++++++++-------- tests/test_installer.py | 8 ++++++++ 5 files changed, 38 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 35cf8a55..37076963 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ java-codebase-rag install java-codebase-rag install --non-interactive --agent claude-code ``` -After `pip install --upgrade java-codebase-rag`, run `java-codebase-rag update` to refresh shipped artifacts. +After `pip install --upgrade java-codebase-rag`, run `java-codebase-rag update` to refresh shipped artifacts and catch up the index (Lance + graph). ### Manual registration @@ -195,7 +195,7 @@ Run `java-codebase-rag --help` to list grouped subcommands. Operator playbook wi | Group | Subcommand | What it does | |---|---|---| | Setup | `install` | Interactive setup wizard: config, MCP registration, skill/agent deployment, indexing. | -| Setup | `update` | Refresh shipped artifacts (skill, agent, MCP entry) after pip upgrade. | +| Setup | `update` | Refresh shipped artifacts (skill, agent, MCP entry) + incremental Lance/graph catch-up after pip upgrade. | | Lifecycle | `init` | First-time index. Refuses if artifacts already exist. | | Lifecycle | `increment` | CocoIndex catch-up + incremental Kuzu update. `--vectors-only` for Lance only. | | Lifecycle | `reprocess` | Full Lance + Kuzu rebuild. `--vectors-only` / `--graph-only` for a single phase. | diff --git a/docs/JAVA-CODEBASE-RAG-CLI.md b/docs/JAVA-CODEBASE-RAG-CLI.md index 7df7c3fc..c761adc0 100644 --- a/docs/JAVA-CODEBASE-RAG-CLI.md +++ b/docs/JAVA-CODEBASE-RAG-CLI.md @@ -61,7 +61,7 @@ java-codebase-rag install --scope user ### `update` -Post-upgrade refresh: overwrites skill and agent files with the latest shipped versions and updates the MCP command path. Requires a prior `install` run. +Post-upgrade refresh: overwrites skill and agent files with the latest shipped versions and updates the MCP command path. If an index exists, also runs an incremental Lance + graph catch-up (same as `increment`). Requires a prior `install` run. ```bash # Refresh after pip upgrade @@ -83,7 +83,7 @@ java-codebase-rag update --force - Detects previously configured agent hosts (scans both project-level and user-level config files). - Refreshes skill and agent files (versioned assets from the package). - Updates MCP entrypoint path if `java-codebase-rag-mcp` has moved. -- Runs `increment` on the index if it exists (LanceDB catch-up). Prints graph staleness warning. +- Runs an incremental index update (Lance + graph) if an index exists — same as `java-codebase-rag increment`. - Skips MCP config if the entry already exists and is correct. **Exit codes:** diff --git a/java_codebase_rag/cli.py b/java_codebase_rag/cli.py index 2a15aa07..1a991d42 100644 --- a/java_codebase_rag/cli.py +++ b/java_codebase_rag/cli.py @@ -775,8 +775,9 @@ def build_parser() -> argparse.ArgumentParser: help="Refresh shipped artifacts (skill, agent, MCP entry) after pip upgrade.", description=( "Post-upgrade refresh: overwrites skill and agent files with the latest " - "shipped versions and updates the MCP command path. Use --dry-run to " - "preview changes without writing. Requires a prior `install` run." + "shipped versions and updates the MCP command path. If an index exists, " + "also runs an incremental Lance + graph catch-up (same as `increment`). " + "Use --dry-run to preview changes without writing. Requires a prior `install` run." ), ) update.add_argument( diff --git a/java_codebase_rag/installer.py b/java_codebase_rag/installer.py index 2dcfc649..ba413931 100644 --- a/java_codebase_rag/installer.py +++ b/java_codebase_rag/installer.py @@ -1182,7 +1182,7 @@ def run_update( index_dir_has_existing_artifacts, resolve_operator_config, ) - from java_codebase_rag.pipeline import run_cocoindex_update + from java_codebase_rag.pipeline import run_cocoindex_update, run_incremental_graph project_root = discover_project_root(cwd) if project_root is None: @@ -1207,22 +1207,37 @@ def run_update( print("Run `java-codebase-rag install` to create one.") return EXIT_PARTIAL if has_artifact_failures else EXIT_SUCCESS - # Run increment (LanceDB catch-up) + # Run increment: LanceDB catch-up + incremental graph rebuild. + # Mirrors `java-codebase-rag increment` so both index layers stay current. + # The "graph not implemented" warning belongs only on the vectors-only path + # (increment --vectors-only), where the graph step is deliberately skipped. if not dry_run: - print("\nUpdating index (incremental LanceDB update)...") + print("\nUpdating index (Lance + graph)...") cfg.apply_to_os_environ() env = cfg.subprocess_env() coco = run_cocoindex_update(env, full_reprocess=False, quiet=True) if coco.returncode != 0: - print(f"Error: Index update failed with code {coco.returncode}") + print(f"Error: Lance index update failed with code {coco.returncode}") return 1 - # Print graph staleness warning - from java_codebase_rag.cli import _INCREMENT_WARNING_LINES - print("\n" + "\n".join(_INCREMENT_WARNING_LINES)) + g = run_incremental_graph( + source_root=cfg.source_root, + ladybug_path=cfg.ladybug_path, + verbose=False, + quiet=True, + env=env, + ) + if g.returncode != 0: + # Artifacts above already refreshed; the graph catch-up is best-effort + # here. Surface a truthful, actionable message instead of leaving the + # graph silently stale or claiming the feature is unimplemented. + print( + f"\nWarning: incremental graph update failed (exit {g.returncode}). " + "Run `java-codebase-rag reprocess` for a full rebuild." + ) else: - print("\nWould run incremental index update.") + print("\nWould run incremental index update (Lance + graph).") # Print summary print("\nUpdate complete.") diff --git a/tests/test_installer.py b/tests/test_installer.py index 9d6dc090..ffcdac5c 100644 --- a/tests/test_installer.py +++ b/tests/test_installer.py @@ -1106,6 +1106,10 @@ def mock_run_build_ast_graph(*args, **kwargs): from subprocess import CompletedProcess return CompletedProcess(["build_ast_graph"], 0) + def mock_run_incremental_graph(*args, **kwargs): + from subprocess import CompletedProcess + return CompletedProcess(["build_ast_graph", "--incremental"], 0) + monkeypatch.setattr( "java_codebase_rag.pipeline.run_cocoindex_update", mock_run_cocoindex_update, @@ -1114,6 +1118,10 @@ def mock_run_build_ast_graph(*args, **kwargs): "java_codebase_rag.pipeline.run_build_ast_graph", mock_run_build_ast_graph, ) + monkeypatch.setattr( + "java_codebase_rag.pipeline.run_incremental_graph", + mock_run_incremental_graph, + ) # Change to fixture directory monkeypatch.setattr(Path, "cwd", lambda: cwd)