Skip to content

Commit 33da915

Browse files
HumanBean17claude
andauthored
Fix LadybugDB migration issues and JSON parsing (#303)
- Fix test file references from kuzu to ladybug (kuzu_db_path_cross_service_smoke → ladybug_db_path_cross_service_smoke) - Fix stale ontology tests to use ladybug.Connection instead of kuzu.Connection - Fix database file extension (.kuzu → .lbug) - Fix helper functions in _builders.py (build_kuzu_to → build_ladybug_to) - Add _parse_ladybug_json helper to handle LadybugDB's non-standard JSON format (unquoted keys) - Update meta() method to use _parse_ladybug_json for all JSON fields - Update error messages and CLI arguments from kuzu to ladybug - Fix test assertions to use ladybug_path instead of lbug_path - Fix test constant references (KUZU_INCREMENTAL_TRACKING_ISSUE_URL → LADYBUG_INCREMENTAL_TRACKING_ISSUE_URL) - Fix test assertions for LadybugDB warning messages - Add _parse_ladybug_json helper to test_ast_graph_build.py Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
1 parent d36ed2f commit 33da915

43 files changed

Lines changed: 1383 additions & 1361 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ast_java.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ class RouteDecl:
325325
filename: str
326326
start_line: int
327327
end_line: int
328-
# brownfield / B2a composition (graph_enrich.resolve_routes_for_method); not a Kuzu column.
328+
# brownfield / B2a composition (graph_enrich.resolve_routes_for_method); not a graph column.
329329
route_source_layer: str = "builtin"
330330

331331

build_ast_graph.py

Lines changed: 66 additions & 66 deletions
Large diffs are not rendered by default.

graph_enrich.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def collect_annotation_meta_chain(
334334
) -> dict[str, frozenset[str]]:
335335
"""Map annotation simple name → built-in simple names reachable via meta-annotations.
336336
337-
Single source of truth for Layer A: both the Kuzu writer and Lance chunk
337+
Single source of truth for Layer A: both the LadybugDB writer and Lance chunk
338338
enrichment must use this; they must not derive `meta_chain` from separate
339339
filesystem walks. See ``PLAN-BROWNFIELD-ROLE-OVERRIDES`` §
340340
*Single source of truth (REQUIRED — read before implementation)*.
@@ -350,7 +350,7 @@ def annotation_meta_decls_from_graph_tables(
350350
"""From `build_ast_graph.GraphTables.types`, map @interface simple name -> meta anns.
351351
352352
Used for diagnostics; Layer A in production uses `collect_annotation_meta_chain`
353-
(disk) so Kuzu and Lance share one index.
353+
(disk) so LadybugDB and Lance share one index.
354354
"""
355355
decls: dict[str, tuple[str, ...]] = {}
356356
first_fqn: dict[str, str] = {}
@@ -1702,7 +1702,7 @@ def enrich_chunk(
17021702

17031703

17041704
def symbol_id(kind: str, fqn: str, file_path: str = "", start_byte: int = 0) -> str:
1705-
"""Deterministic SHA1-based id for Kuzu Symbol nodes."""
1705+
"""Deterministic SHA1-based id for LadybugDB Symbol nodes."""
17061706
key = f"{kind}|{fqn}|{file_path}|{start_byte}".encode("utf-8")
17071707
return hashlib.sha1(key).hexdigest()
17081708

java_codebase_rag/cli.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
from java_codebase_rag.pipeline import clip, run_build_ast_graph, run_cocoindex_drop, run_cocoindex_update, run_incremental_graph
2525
from java_ontology import VALID_UNRESOLVED_CALL_REASONS
2626

27-
KUZU_INCREMENTAL_TRACKING_ISSUE_URL = "https://github.com/HumanBean17/java-codebase-rag/issues/73"
27+
LADYBUG_INCREMENTAL_TRACKING_ISSUE_URL = "https://github.com/HumanBean17/java-codebase-rag/issues/73"
2828

2929
_INCREMENT_WARNING_LINES = (
30-
"WARNING: AST graph (Kuzu) incremental rebuild is not yet implemented.",
30+
"WARNING: AST graph (LadybugDB) incremental rebuild is not yet implemented.",
3131
"The graph reflects the index state from the last `init` or `reprocess`,",
3232
"which means `find`, `neighbors`, and `describe` may return stale results",
3333
"for files changed since then.",
@@ -37,8 +37,8 @@
3737
"For an up-to-date graph, run:",
3838
" java-codebase-rag reprocess",
3939
"",
40-
"Track progress on Kuzu incremental rebuild:",
41-
f" {KUZU_INCREMENTAL_TRACKING_ISSUE_URL}",
40+
"Track progress on LadybugDB incremental rebuild:",
41+
f" {LADYBUG_INCREMENTAL_TRACKING_ISSUE_URL}",
4242
)
4343

4444
_REFRESH_DEPRECATION = (
@@ -47,7 +47,7 @@
4747
)
4848

4949
_REPROCESS_DRIFT_VECTORS_ONLY = (
50-
"java-codebase-rag reprocess: rebuilt vectors only; graph (code_graph.kuzu) was NOT rebuilt "
50+
"java-codebase-rag reprocess: rebuilt vectors only; graph (code_graph.lbug) was NOT rebuilt "
5151
"and may now reflect a stale source snapshot."
5252
)
5353

@@ -178,7 +178,7 @@ def _emit(value: Any) -> None:
178178
print(json.dumps(payload, default=_jsonable, sort_keys=True, indent=None))
179179

180180

181-
def _emit_increment_kuzu_warning() -> None:
181+
def _emit_increment_ladybug_warning() -> None:
182182
for line in _INCREMENT_WARNING_LINES:
183183
print(line, file=sys.stderr)
184184

@@ -289,7 +289,7 @@ def work() -> int:
289289
print(file=sys.stderr, flush=True)
290290
g = run_build_ast_graph(
291291
source_root=cfg.source_root,
292-
kuzu_path=cfg.kuzu_path,
292+
ladybug_path=cfg.ladybug_path,
293293
verbose=verbose,
294294
quiet=bool(args.quiet),
295295
env=env,
@@ -319,7 +319,7 @@ def _cmd_increment(args: argparse.Namespace) -> int:
319319
# Check for --vectors-only flag
320320
vectors_only = bool(getattr(args, "vectors_only", False))
321321
if vectors_only:
322-
_emit_increment_kuzu_warning()
322+
_emit_increment_ladybug_warning()
323323

324324
def work() -> int:
325325
env = cfg.subprocess_env()
@@ -350,7 +350,7 @@ def work() -> int:
350350
# Run incremental graph update
351351
g = run_incremental_graph(
352352
source_root=cfg.source_root,
353-
kuzu_path=cfg.kuzu_path,
353+
ladybug_path=cfg.ladybug_path,
354354
verbose=bool(args.verbose),
355355
quiet=bool(args.quiet),
356356
env=env,
@@ -437,7 +437,7 @@ def work() -> int:
437437
if graph_only:
438438
g = run_build_ast_graph(
439439
source_root=cfg.source_root,
440-
kuzu_path=cfg.kuzu_path,
440+
ladybug_path=cfg.ladybug_path,
441441
verbose=verbose,
442442
quiet=bool(args.quiet),
443443
env=env,
@@ -509,7 +509,7 @@ def _cmd_erase(args: argparse.Namespace) -> int:
509509
cfg = _resolved_from_ns(args)
510510
_startup_hints(cfg)
511511
cfg.apply_to_os_environ()
512-
to_describe: list[Path] = [cfg.kuzu_path, cfg.cocoindex_db]
512+
to_describe: list[Path] = [cfg.ladybug_path, cfg.cocoindex_db]
513513
if cfg.index_dir.is_dir():
514514
try:
515515
import lancedb
@@ -546,8 +546,8 @@ def work() -> int:
546546
)
547547
elif drop.returncode != 0:
548548
print(clip(drop.stderr, 4000), file=sys.stderr)
549-
if cfg.kuzu_path.exists():
550-
shutil.rmtree(cfg.kuzu_path, ignore_errors=True)
549+
if cfg.ladybug_path.exists():
550+
shutil.rmtree(cfg.ladybug_path, ignore_errors=True)
551551
if cfg.cocoindex_db.exists():
552552
try:
553553
cfg.cocoindex_db.unlink()
@@ -577,17 +577,17 @@ def _cmd_meta(args: argparse.Namespace) -> int:
577577
cfg = _resolved_from_ns(args)
578578
_startup_hints(cfg)
579579
cfg.apply_to_os_environ()
580-
from kuzu_queries import KuzuGraph # lazy
580+
from ladybug_queries import LadybugGraph # lazy
581581

582-
KuzuGraph._instance = None
583-
KuzuGraph._instance_path = None
582+
LadybugGraph._instance = None
583+
LadybugGraph._instance_path = None
584584
payload = server._graph_meta_output().model_dump()
585585
payload["embedding_model"] = cfg.embedding_model
586586
payload["embedding_device"] = cfg.embedding_device
587587
payload["embedding_model_source"] = cfg.embedding_model_source
588588
payload["embedding_device_source"] = cfg.embedding_device_source
589589
payload["index_dir"] = str(cfg.index_dir.resolve())
590-
payload["kuzu_path"] = str(cfg.kuzu_path.resolve())
590+
payload["ladybug_path"] = str(cfg.ladybug_path.resolve())
591591
payload["index_dir_source"] = cfg.index_dir_source
592592
payload["hints_enabled"] = cfg.hints_enabled
593593
payload["hints_enabled_source"] = cfg.hints_enabled_source
@@ -637,12 +637,12 @@ def _cmd_unresolved_calls_list(args: argparse.Namespace) -> int:
637637
cfg = _resolved_from_ns(args)
638638
_startup_hints(cfg)
639639
cfg.apply_to_os_environ()
640-
from kuzu_queries import KuzuGraph # lazy
640+
from ladybug_queries import LadybugGraph # lazy
641641

642-
if not KuzuGraph.exists():
642+
if not LadybugGraph.exists():
643643
_emit({"success": False, "message": "Kuzu graph not found"})
644644
return 1
645-
graph = KuzuGraph.get()
645+
graph = LadybugGraph.get()
646646
rows = graph.list_unresolved_call_sites(
647647
method_id=args.method_id,
648648
reason=args.reason,
@@ -658,12 +658,12 @@ def _cmd_unresolved_calls_stats(args: argparse.Namespace) -> int:
658658
cfg = _resolved_from_ns(args)
659659
_startup_hints(cfg)
660660
cfg.apply_to_os_environ()
661-
from kuzu_queries import KuzuGraph # lazy
661+
from ladybug_queries import LadybugGraph # lazy
662662

663-
if not KuzuGraph.exists():
663+
if not LadybugGraph.exists():
664664
_emit({"success": False, "message": "Kuzu graph not found"})
665665
return 1
666-
graph = KuzuGraph.get()
666+
graph = LadybugGraph.get()
667667
buckets = graph.stats_unresolved_call_sites(by=args.by)
668668
total = sum(int(r.get("n") or 0) for r in buckets)
669669
_emit({"success": True, "total": total, "by": args.by, "buckets": buckets})
@@ -683,12 +683,12 @@ def _cmd_analyze_pr(args: argparse.Namespace) -> int:
683683
_emit({"success": False, "message": "Diff is empty"})
684684
return 1
685685
import pr_analysis # lazy
686-
from kuzu_queries import KuzuGraph # lazy
686+
from ladybug_queries import LadybugGraph # lazy
687687

688-
if not KuzuGraph.exists():
688+
if not LadybugGraph.exists():
689689
_emit({"success": False, "message": "Kuzu graph not found"})
690690
return 1
691-
graph = KuzuGraph.get()
691+
graph = LadybugGraph.get()
692692
report = pr_analysis.analyze_pr_pipeline(graph, diff_text)
693693
_emit(pr_analysis.pr_report_to_dict(report))
694694
return 0

java_codebase_rag/config.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,9 @@ def resolved_sbert_model_for_process_env(import_time_default: str) -> str:
6767
# Legacy env keys: never honored; detection-only hints name the replacement (if any).
6868
_LEGACY_ENV_HINTS: tuple[tuple[str, str], ...] = (
6969
("LANCEDB_URI", "JAVA_CODEBASE_RAG_INDEX_DIR"),
70-
("KUZU_DB_PATH", "JAVA_CODEBASE_RAG_INDEX_DIR (Kuzu lives at <index_dir>/code_graph.kuzu)"),
7170
("LANCEDB_MCP_PROJECT_ROOT", "cwd or --source-root (no env replacement)"),
7271
("LANCEDB_MCP_ALLOW_REFRESH", "(removed; use init / increment / reprocess / erase)"),
73-
("LANCEDB_MCP_GRAPH_ENABLED", "(removed; graph is used when code_graph.kuzu exists)"),
72+
("LANCEDB_MCP_GRAPH_ENABLED", "(removed; graph is used when code_graph.lbug exists)"),
7473
("LANCEDB_MCP_MICROSERVICE_ROOTS", "microservice_roots: in .java-codebase-rag.yml"),
7574
("LANCEDB_MCP_DEBUG_CONTEXT", ENV_DEBUG_CONTEXT),
7675
("LANCEDB_MCP_RUN_HEAVY", ENV_RUN_HEAVY),
@@ -182,7 +181,7 @@ def load_yaml_mapping(source_root: Path) -> dict[str, Any]:
182181
class ResolvedOperatorConfig:
183182
source_root: Path
184183
index_dir: Path
185-
kuzu_path: Path
184+
ladybug_path: Path
186185
cocoindex_db: Path
187186
embedding_model: str
188187
embedding_device: str | None
@@ -193,7 +192,7 @@ class ResolvedOperatorConfig:
193192
hints_enabled_source: SettingSource
194193

195194
def apply_to_os_environ(self) -> None:
196-
"""Make downstream modules (server, kuzu_queries, flows) see a consistent environment.
195+
"""Make downstream modules (server, ladybug_queries, flows) see a consistent environment.
197196
198197
When ``embedding_device`` is unset, ``SBERT_DEVICE`` is not removed from ``os.environ`` so
199198
a long-lived host process is not mutated for unrelated callers; subprocesses still use
@@ -369,12 +368,12 @@ def resolve_operator_config(
369368
yaml_path=("hints", "enabled"),
370369
default=True,
371370
)
372-
ku = index_dir / "code_graph.kuzu"
371+
ku = index_dir / "code_graph.lbug"
373372
coco = index_dir / "cocoindex.db"
374373
return ResolvedOperatorConfig(
375374
source_root=root,
376375
index_dir=index_dir,
377-
kuzu_path=ku,
376+
ladybug_path=ku,
378377
cocoindex_db=coco,
379378
embedding_model=model,
380379
embedding_device=device,
@@ -387,9 +386,9 @@ def resolve_operator_config(
387386

388387

389388
def index_dir_has_existing_artifacts(index_dir: Path) -> tuple[bool, list[str]]:
390-
"""True if Kuzu graph dir or any Lance table already exists under index_dir."""
389+
"""True if graph dir or any Lance table already exists under index_dir."""
391390
paths: list[str] = []
392-
ku = index_dir / "code_graph.kuzu"
391+
ku = index_dir / "code_graph.lbug"
393392
if ku.exists():
394393
paths.append(str(ku.resolve()))
395394
if index_dir.is_dir():

java_codebase_rag/installer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ def run_init_if_needed(
791791
# Run AST graph build
792792
g = run_build_ast_graph(
793793
source_root=cfg.source_root,
794-
kuzu_path=cfg.kuzu_path,
794+
ladybug_path=cfg.ladybug_path,
795795
verbose=not quiet,
796796
quiet=quiet,
797797
env=env,

java_codebase_rag/pipeline.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def run_cocoindex_drop(env: dict[str, str], *, quiet: bool) -> subprocess.Comple
201201
def run_build_ast_graph(
202202
*,
203203
source_root: Path,
204-
kuzu_path: Path,
204+
ladybug_path: Path,
205205
verbose: bool,
206206
quiet: bool = False,
207207
env: dict[str, str] | None = None,
@@ -219,8 +219,8 @@ def run_build_ast_graph(
219219
str(builder),
220220
"--source-root",
221221
str(source_root),
222-
"--kuzu-path",
223-
str(kuzu_path),
222+
"--ladybug-path",
223+
str(ladybug_path),
224224
]
225225
# Three-tier: --quiet (silent) / default (filtered progress) / --verbose (raw).
226226
# Default passes --verbose so the builder emits per-pass progress lines,
@@ -254,7 +254,7 @@ def run_build_ast_graph(
254254
def run_incremental_graph(
255255
*,
256256
source_root: Path,
257-
kuzu_path: Path,
257+
ladybug_path: Path,
258258
verbose: bool,
259259
quiet: bool = False,
260260
env: dict[str, str] | None = None,
@@ -273,8 +273,8 @@ def run_incremental_graph(
273273
str(builder),
274274
"--source-root",
275275
str(source_root),
276-
"--kuzu-path",
277-
str(kuzu_path),
276+
"--ladybug-path",
277+
str(ladybug_path),
278278
"--incremental",
279279
]
280280
# Three-tier: --quiet (silent) / default (filtered progress) / --verbose (raw).

java_index_flow_lancedb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
LanceDB requires a single primary key per table; each chunk gets a UUID `id`.
55
66
Environment:
7-
JAVA_CODEBASE_RAG_INDEX_DIR — Lance tables + Kuzu + cocoindex state (default: ./.java-codebase-rag)
7+
JAVA_CODEBASE_RAG_INDEX_DIR — Lance tables + LadybugDB + cocoindex state (default: ./.java-codebase-rag)
88
JAVA_CODEBASE_RAG_SOURCE_ROOT — Java repo root for indexing (optional; else cocoindex cwd)
99
SBERT_MODEL / SBERT_DEVICE — embedding (optional; YAML also supported via java-codebase-rag CLI)
1010

java_ontology.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
@dataclass(frozen=True)
142142
class EdgeAttr:
143143
name: str
144-
kuzu_type: str
144+
graph_type: str
145145
purpose: str
146146

147147

0 commit comments

Comments
 (0)