Skip to content

Commit fb301cf

Browse files
HumanBean17claude
andcommitted
Migrate graph storage from KuzuDB to LadybugDB
This commit replaces the KuzuDB dependency with LadybugDB, the maintained fork by the same core team. This is a mechanical rename with no logic changes. Changes: - Dependency swap: kuzu>=0.11.3,<0.12 → ladybug>=0.17.1,<0.18 - File rename: kuzu_queries.py → ladybug_queries.py - Class rename: KuzuGraph → LadybugGraph - Function renames: resolve_kuzu_path → resolve_ladybug_path, etc. - CLI arg rename: --kuzu-path → --ladybug-path - Database file extension: code_graph.kuzu → code_graph.lbug - Ontology field rename: kuzu_type → graph_type (engine-agnostic) - Updated all imports, references, and documentation Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent d36ed2f commit fb301cf

50 files changed

Lines changed: 1415 additions & 1416 deletions

Some content is hidden

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

AGENTS.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ when needed.
7474
|------|------|
7575
| `server.py` | MCP stdio server. Every `@mcp.tool` lives here. |
7676
| `search_lancedb.py` | Vector / hybrid / graph-expanded search; ranking. |
77-
| `build_ast_graph.py` | Tree-sitter → Kuzu graph builder (full rebuild). Owns `pass1``pass6` (`pass5` emits `HTTP_CALLS` / `ASYNC_CALLS` caller edges; `pass6_match_edges` resolves cross-service / intra-service / ambiguous / phantom / unresolved match outcomes — ontology 7). |
78-
| `kuzu_queries.py` | Read-only Cypher helpers used by the server. Includes `meta()` decoder for the Kuzu MAP-as-STRING JSON-blob columns. |
77+
| `build_ast_graph.py` | Tree-sitter → LadybugDB graph builder (full rebuild). Owns `pass1``pass6` (`pass5` emits `HTTP_CALLS` / `ASYNC_CALLS` caller edges; `pass6_match_edges` resolves cross-service / intra-service / ambiguous / phantom / unresolved match outcomes — ontology 7). |
78+
| `ladybug_queries.py` | Read-only Cypher helpers used by the server. Includes `meta()` decoder for the LadybugDB MAP-as-STRING JSON-blob columns. |
7979
| `ast_java.py` | Tree-sitter Java parsing, role/capability inference, `_string_value_atoms` helper (shared by route/client/producer extractors), `_collect_outgoing_calls` for caller-side detection. |
8080
| `graph_enrich.py` | `module` / `microservice` resolution, `BrownfieldOverrides` (route + role + capability + http client + async producer), meta-annotation walk, `resolve_routes_for_method` / `resolve_http_client_for_method` / `resolve_async_producer_for_method`. |
8181
| `java_ontology.py` | Source of truth for `VALID_ROLES`, `VALID_CAPABILITIES`, `VALID_CLIENT_KINDS`, `VALID_HTTP_CALL_STRATEGIES`, `VALID_ASYNC_CALL_STRATEGIES`, `VALID_HTTP_CALL_MATCHES`. |
@@ -90,7 +90,7 @@ when needed.
9090

9191
## Test layout
9292

93-
- `tests/conftest.py` — session-scoped Kuzu graph fixture.
93+
- `tests/conftest.py` — session-scoped LadybugDB graph fixture.
9494
- `tests/bank-chat-system/` — deterministic Java corpus (fixture, not production model).
9595
- `tests/fixtures/call_graph_smoke/` — mini Maven tree calibrated against the call-graph resolver.
9696
- `tests/fixtures/brownfield_route_stubs/``@CodebaseRoute` / `@CodebaseRoutes` source stubs (PR-A3).
@@ -188,7 +188,7 @@ template):
188188
`VALID_ASYNC_CALL_STRATEGIES`, `VALID_HTTP_CALL_MATCHES`,
189189
`VALID_ROUTE_FRAMEWORKS`, `VALID_ROUTE_KINDS`, `VALID_PRODUCER_KINDS`,
190190
`VALID_RESOLVE_REASONS`, `VALID_UNRESOLVED_CALL_REASONS`.
191-
- Schema changes that affect the Lance index or Kuzu graph need a
191+
- Schema changes that affect the Lance index or LadybugDB graph need a
192192
matching update to the README "Re-index required" callout. Bump
193193
`ontology_version` when enrichment semantics change (currently **17**).
194194
- Brownfield is a first-class surface: any new auto-detection (route,
@@ -199,10 +199,10 @@ template):
199199
union when any brownfield layer fires on a method (single network packet
200200
→ single edge). See `plans/completed/PLAN-TIER1B-COMPLETION.md` §
201201
"Caller-side composition divergence".
202-
- Kuzu's Python binder rejects `dict` for `MAP` columns. Store all
202+
- LadybugDB's Python binder rejects `dict` for `MAP` columns. Store all
203203
map-shaped graph_meta data (`routes_by_framework`, `routes_by_layer`,
204204
`http_calls_by_strategy`, `async_calls_by_strategy`, etc.) as `STRING`
205-
JSON blobs and decode in `kuzu_queries.meta()`.
205+
JSON blobs and decode in `ladybug_queries.meta()`.
206206
- `server.py` is a stdio MCP server: anything reachable from a tool
207207
handler must not write to **stdout** (that's the JSON-RPC transport).
208208
Diagnostics go to stderr.
@@ -216,10 +216,10 @@ template):
216216
support. `BrownfieldOverrides` already holds route, role, capability,
217217
http client, and async producer dicts — extend it in place.
218218

219-
## Kuzu Cypher pitfalls
219+
## LadybugDB Cypher pitfalls
220220

221-
When adding or editing Cypher run against Kuzu (for example in
222-
`kuzu_queries.py`, `mcp_v2.py`, or any `KuzuGraph._rows` caller):
221+
When adding or editing Cypher run against LadybugDB (for example in
222+
`ladybug_queries.py`, `mcp_v2.py`, or any `LadybugGraph._rows` caller):
223223

224224
- **Do not filter relationship types with** `label(e) IN $list` **or**
225225
`label(e) IN ["A","B"]` **in** `WHERE`. On supported versions this can
@@ -252,7 +252,7 @@ When adding or editing Cypher run against Kuzu (for example in
252252
```bash
253253
rm -rf /tmp/check && .venv/bin/python build_ast_graph.py \
254254
--source-root tests/bank-chat-system \
255-
--kuzu-path /tmp/check/code_graph.kuzu --verbose
255+
--ladybug-path /tmp/check/code_graph.lbug --verbose
256256
```
257257

258258
## Commit and PR
@@ -289,7 +289,7 @@ When adding or editing Cypher run against Kuzu (for example in
289289
## Cursor Cloud specific instructions
290290

291291
This is a self-contained Python project — no external services
292-
(no Postgres, Kafka, Docker) are needed. All storage (Kuzu, LanceDB,
292+
(no Postgres, Kafka, Docker) are needed. All storage (LadybugDB, LanceDB,
293293
CocoIndex state) is embedded/file-based.
294294

295295
### Environment
@@ -317,12 +317,12 @@ first run. They are not required for normal development.
317317

318318
### Hello-world verification
319319

320-
Build the Kuzu graph from the test fixture and inspect it:
320+
Build the LadybugDB graph from the test fixture and inspect it:
321321

322322
```bash
323323
rm -rf /tmp/check && .venv/bin/python build_ast_graph.py \
324324
--source-root tests/bank-chat-system \
325-
--kuzu-path /tmp/check/code_graph.kuzu --verbose
325+
--ladybug-path /tmp/check/code_graph.lbug --verbose
326326
.venv/bin/java-codebase-rag meta \
327327
--source-root tests/bank-chat-system --index-dir /tmp/check
328328
```

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
A graph-native code intelligence layer for Java microservice estates, exposed to LLM agents via the **Model Context Protocol (MCP)**.
44

5-
The system extracts a deterministic property graph from Java source (tree-sitter), stores it in **Kuzu** (graph) alongside a **LanceDB** vector index (chunks), and exposes a deliberately small MCP surface — **five tools**: `search`, `find`, `describe`, `neighbors`, `resolve` — that collapse onto three primitive agent operations: **locate**, **inspect**, **walk**.
5+
The system extracts a deterministic property graph from Java source (tree-sitter), stores it in **LadybugDB** (graph) alongside a **LanceDB** vector index (chunks), and exposes a deliberately small MCP surface — **five tools**: `search`, `find`, `describe`, `neighbors`, `resolve` — that collapse onto three primitive agent operations: **locate**, **inspect**, **walk**.
66

77
> **What this MCP is:** a **GPS for code navigation**, not a reasoning engine.
88
> Agents use a simple loop:
@@ -21,7 +21,7 @@ For the design rationale, the GPS metaphor, and the full ontology, see [`docs/pa
2121

2222
Generic code-search tools (grep, ctags, vector-only RAG) hit a ceiling on real Java microservice estates: they find files but lose the structure that makes a Spring/JAX-RS system navigable. This project is built around five choices that target that gap.
2323

24-
- **Hybrid RAG + GraphRAG, not either-or.** Semantic recall (LanceDB chunk vectors) and structural navigation (Kuzu property graph) are composed in one surface. `search` finds candidate nodes by meaning; `neighbors` walks the exact edge you care about (`CALLS`, `IMPLEMENTS`, `INJECTS`, `DECLARES_ROUTE`, …). The agent picks the right primitive per step instead of being forced into pure-vector or pure-symbol search.
24+
- **Hybrid RAG + GraphRAG, not either-or.** Semantic recall (LanceDB chunk vectors) and structural navigation (LadybugDB property graph) are composed in one surface. `search` finds candidate nodes by meaning; `neighbors` walks the exact edge you care about (`CALLS`, `IMPLEMENTS`, `INJECTS`, `DECLARES_ROUTE`, …). The agent picks the right primitive per step instead of being forced into pure-vector or pure-symbol search.
2525

2626
- **A Java-tuned role model.** Symbols are labelled with stereotypes inferred from Spring and JAX-RS conventions — `CONTROLLER`, `SERVICE`, `REPOSITORY`, `CLIENT`, `PRODUCER`, `MAPPER`, `DTO`. Agents can ask "list controllers" or "who injects this repository" directly, instead of grep-ing for `@RestController` and hoping for the best. Roles drive both filtering (`find` with a `NodeFilter`) and ranking.
2727

@@ -69,7 +69,7 @@ After `pip install --upgrade java-codebase-rag`, run `java-codebase-rag update`
6969

7070
If you prefer manual configuration, see [`docs/JAVA-CODEBASE-RAG-CLI.md`](./docs/JAVA-CODEBASE-RAG-CLI.md) for the full CLI reference.
7171

72-
> **Stability disclaimer.** This package does **not** promise backward compatibility. MCP tool contracts, env vars, Lance/Kuzu schemas, config files, and Python APIs may change without a deprecation period. Track `main` and rebuild indexes when ontology or embedding settings change.
72+
> **Stability disclaimer.** This package does **not** promise backward compatibility. MCP tool contracts, env vars, Lance/LadybugDB schemas, config files, and Python APIs may change without a deprecation period. Track `main` and rebuild indexes when ontology or embedding settings change.
7373
7474
---
7575

@@ -82,7 +82,7 @@ This repo ships a small multi-module Spring fixture under [`tests/bank-chat-syst
8282
git clone https://github.com/HumanBean17/java-codebase-rag
8383
cd java-codebase-rag
8484

85-
# 2. Build the index (Lance vectors + Kuzu graph). First run downloads the
85+
# 2. Build the index (Lance vectors + LadybugDB graph). First run downloads the
8686
# embedding model (~90 MB) and takes ~30-60s on the fixture.
8787
java-codebase-rag init --source-root tests/bank-chat-system --index-dir /tmp/bank-chat-index
8888

@@ -97,7 +97,7 @@ Smoke-test the index with two checks (`search_lancedb` ships with the package):
9797
JAVA_CODEBASE_RAG_INDEX_DIR=/tmp/bank-chat-index \
9898
python -m search_lancedb "chat ingress controller" --table java --limit 3
9999

100-
# Vector + graph expansion — proves Kuzu is wired in
100+
# Vector + graph expansion — proves LadybugDB is wired in
101101
JAVA_CODEBASE_RAG_INDEX_DIR=/tmp/bank-chat-index \
102102
python -m search_lancedb "chat ingress controller" --table java --limit 3 \
103103
--graph-expand --expand-depth 2
@@ -197,8 +197,8 @@ Run `java-codebase-rag --help` to list grouped subcommands. Operator playbook wi
197197
| Setup | `install` | Interactive setup wizard: config, MCP registration, skill/agent deployment, indexing. |
198198
| Setup | `update` | Refresh shipped artifacts (skill, agent, MCP entry) after pip upgrade. |
199199
| Lifecycle | `init` | First-time index. Refuses if artifacts already exist. |
200-
| Lifecycle | `increment` | CocoIndex catch-up + incremental Kuzu update. `--vectors-only` for Lance only. |
201-
| Lifecycle | `reprocess` | Full Lance + Kuzu rebuild. `--vectors-only` / `--graph-only` for a single phase. |
200+
| Lifecycle | `increment` | CocoIndex catch-up + incremental LadybugDB update. `--vectors-only` for Lance only. |
201+
| Lifecycle | `reprocess` | Full Lance + LadybugDB rebuild. `--vectors-only` / `--graph-only` for a single phase. |
202202
| Lifecycle | `erase` | Delete index artifacts. Requires `--yes` or TTY confirm. |
203203
| Introspection | `meta`, `tables`, `diagnose-ignore`, `unresolved-calls` | Health, table listing, ignore-layer diagnostics, receiver-failure call sites. |
204204
| Analysis | `analyze-pr` | Blast-radius / risk from a unified diff. |

0 commit comments

Comments
 (0)