Skip to content

Commit b8c349b

Browse files
HumanBean17claude
andauthored
fix(update): run incremental graph rebuild, drop stale "not implemented" warning (#310)
`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 <noreply@anthropic.com>
1 parent c26b94f commit b8c349b

5 files changed

Lines changed: 38 additions & 14 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ java-codebase-rag install
6363
java-codebase-rag install --non-interactive --agent claude-code
6464
```
6565

66-
After `pip install --upgrade java-codebase-rag`, run `java-codebase-rag update` to refresh shipped artifacts.
66+
After `pip install --upgrade java-codebase-rag`, run `java-codebase-rag update` to refresh shipped artifacts and catch up the index (Lance + graph).
6767

6868
### Manual registration
6969

@@ -195,7 +195,7 @@ Run `java-codebase-rag --help` to list grouped subcommands. Operator playbook wi
195195
| Group | Subcommand | What it does |
196196
|---|---|---|
197197
| Setup | `install` | Interactive setup wizard: config, MCP registration, skill/agent deployment, indexing. |
198-
| Setup | `update` | Refresh shipped artifacts (skill, agent, MCP entry) after pip upgrade. |
198+
| Setup | `update` | Refresh shipped artifacts (skill, agent, MCP entry) + incremental Lance/graph catch-up after pip upgrade. |
199199
| Lifecycle | `init` | First-time index. Refuses if artifacts already exist. |
200200
| Lifecycle | `increment` | CocoIndex catch-up + incremental Kuzu update. `--vectors-only` for Lance only. |
201201
| Lifecycle | `reprocess` | Full Lance + Kuzu rebuild. `--vectors-only` / `--graph-only` for a single phase. |

docs/JAVA-CODEBASE-RAG-CLI.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ java-codebase-rag install --scope user
6161

6262
### `update`
6363

64-
Post-upgrade refresh: overwrites skill and agent files with the latest shipped versions and updates the MCP command path. Requires a prior `install` run.
64+
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.
6565

6666
```bash
6767
# Refresh after pip upgrade
@@ -83,7 +83,7 @@ java-codebase-rag update --force
8383
- Detects previously configured agent hosts (scans both project-level and user-level config files).
8484
- Refreshes skill and agent files (versioned assets from the package).
8585
- Updates MCP entrypoint path if `java-codebase-rag-mcp` has moved.
86-
- Runs `increment` on the index if it exists (LanceDB catch-up). Prints graph staleness warning.
86+
- Runs an incremental index update (Lance + graph) if an index exists — same as `java-codebase-rag increment`.
8787
- Skips MCP config if the entry already exists and is correct.
8888

8989
**Exit codes:**

java_codebase_rag/cli.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -775,8 +775,9 @@ def build_parser() -> argparse.ArgumentParser:
775775
help="Refresh shipped artifacts (skill, agent, MCP entry) after pip upgrade.",
776776
description=(
777777
"Post-upgrade refresh: overwrites skill and agent files with the latest "
778-
"shipped versions and updates the MCP command path. Use --dry-run to "
779-
"preview changes without writing. Requires a prior `install` run."
778+
"shipped versions and updates the MCP command path. If an index exists, "
779+
"also runs an incremental Lance + graph catch-up (same as `increment`). "
780+
"Use --dry-run to preview changes without writing. Requires a prior `install` run."
780781
),
781782
)
782783
update.add_argument(

java_codebase_rag/installer.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,7 @@ def run_update(
11821182
index_dir_has_existing_artifacts,
11831183
resolve_operator_config,
11841184
)
1185-
from java_codebase_rag.pipeline import run_cocoindex_update
1185+
from java_codebase_rag.pipeline import run_cocoindex_update, run_incremental_graph
11861186

11871187
project_root = discover_project_root(cwd)
11881188
if project_root is None:
@@ -1207,22 +1207,37 @@ def run_update(
12071207
print("Run `java-codebase-rag install` to create one.")
12081208
return EXIT_PARTIAL if has_artifact_failures else EXIT_SUCCESS
12091209

1210-
# Run increment (LanceDB catch-up)
1210+
# Run increment: LanceDB catch-up + incremental graph rebuild.
1211+
# Mirrors `java-codebase-rag increment` so both index layers stay current.
1212+
# The "graph not implemented" warning belongs only on the vectors-only path
1213+
# (increment --vectors-only), where the graph step is deliberately skipped.
12111214
if not dry_run:
1212-
print("\nUpdating index (incremental LanceDB update)...")
1215+
print("\nUpdating index (Lance + graph)...")
12131216
cfg.apply_to_os_environ()
12141217
env = cfg.subprocess_env()
12151218

12161219
coco = run_cocoindex_update(env, full_reprocess=False, quiet=True)
12171220
if coco.returncode != 0:
1218-
print(f"Error: Index update failed with code {coco.returncode}")
1221+
print(f"Error: Lance index update failed with code {coco.returncode}")
12191222
return 1
12201223

1221-
# Print graph staleness warning
1222-
from java_codebase_rag.cli import _INCREMENT_WARNING_LINES
1223-
print("\n" + "\n".join(_INCREMENT_WARNING_LINES))
1224+
g = run_incremental_graph(
1225+
source_root=cfg.source_root,
1226+
ladybug_path=cfg.ladybug_path,
1227+
verbose=False,
1228+
quiet=True,
1229+
env=env,
1230+
)
1231+
if g.returncode != 0:
1232+
# Artifacts above already refreshed; the graph catch-up is best-effort
1233+
# here. Surface a truthful, actionable message instead of leaving the
1234+
# graph silently stale or claiming the feature is unimplemented.
1235+
print(
1236+
f"\nWarning: incremental graph update failed (exit {g.returncode}). "
1237+
"Run `java-codebase-rag reprocess` for a full rebuild."
1238+
)
12241239
else:
1225-
print("\nWould run incremental index update.")
1240+
print("\nWould run incremental index update (Lance + graph).")
12261241

12271242
# Print summary
12281243
print("\nUpdate complete.")

tests/test_installer.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,6 +1106,10 @@ def mock_run_build_ast_graph(*args, **kwargs):
11061106
from subprocess import CompletedProcess
11071107
return CompletedProcess(["build_ast_graph"], 0)
11081108

1109+
def mock_run_incremental_graph(*args, **kwargs):
1110+
from subprocess import CompletedProcess
1111+
return CompletedProcess(["build_ast_graph", "--incremental"], 0)
1112+
11091113
monkeypatch.setattr(
11101114
"java_codebase_rag.pipeline.run_cocoindex_update",
11111115
mock_run_cocoindex_update,
@@ -1114,6 +1118,10 @@ def mock_run_build_ast_graph(*args, **kwargs):
11141118
"java_codebase_rag.pipeline.run_build_ast_graph",
11151119
mock_run_build_ast_graph,
11161120
)
1121+
monkeypatch.setattr(
1122+
"java_codebase_rag.pipeline.run_incremental_graph",
1123+
mock_run_incremental_graph,
1124+
)
11171125

11181126
# Change to fixture directory
11191127
monkeypatch.setattr(Path, "cwd", lambda: cwd)

0 commit comments

Comments
 (0)