Skip to content

feat(status): show graph backend (kuzu / duckdb) in cgh status#25

Merged
joy-software merged 1 commit into
developfrom
feature/status-show-backend
Jun 2, 2026
Merged

feat(status): show graph backend (kuzu / duckdb) in cgh status#25
joy-software merged 1 commit into
developfrom
feature/status-show-backend

Conversation

@joy-software
Copy link
Copy Markdown
Contributor

Summary

Adds a Backend row to `cgh status` right under Version, plus a structured `backend` field in the JSON payload. Tells you which backend cgh is using for the repo without poking around `.codegraph/`.

Display

```
codegraph status

Version 0.4.0
Backend kuzu (graph.db, 68.1 MB)
Owner running pid=15350 ...
...
```

Four cases:

Scenario Row
Only Kuzu on disk, no env var `kuzu (graph.db, 68.1 MB)`
Only DuckDB on disk `duckdb (graph.duckdb, 2.8 MB)`
Kuzu on disk + `CGH_DB=duckdb` set `kuzu (...) CGH_DB='duckdb' mismatch — next index would create a duckdb DB`
Neither on disk yet `none on disk (would create graph.db)`

The mismatch warning catches the gotcha: you set the env var but the repo was last indexed with the other backend. Without the warning, the next `cgh index` would silently create a second graph file.

JSON shape

```json
"backend": {
"on_disk": ["kuzu"],
"active": "kuzu",
"env_var": "duckdb",
"env_implies": "duckdb",
"mismatch": true
}
```

Verification

Tested across all four cases on wb-backend (Kuzu) + a scratch DuckDB repo. Detection mirrors `federation.py`'s `_detect_backend_file` so the table and federation agree on what's active.

  • `uvx ruff check .` clean
  • 298 / 298 tests still pass
  • CI green

A new Backend row right under Version. Tells you at a glance which
backend cgh is using for this repo without poking around .codegraph/.

Display covers the four meaningful cases:

  Backend  kuzu (graph.db, 68.1 MB)
  Backend  duckdb (graph.duckdb, 2.8 MB)
  Backend  kuzu (graph.db, 68.1 MB)  CGH_DB='duckdb' mismatch — next
                                     index would create a duckdb DB
  Backend  none on disk  (would create graph.db)

The mismatch warning is the important one — it catches the case
where you set CGH_DB=duckdb but the repo was last indexed with
Kuzu. Without the warning, the next `cgh index` silently creates a
second graph file and the two backends drift.

JSON payload (`cgh status --json`) gains a structured `backend`
field with on_disk[], active, env_var, env_implies, mismatch.
Lets scripts answer "is this repo on duckdb yet?" without parsing
text.

The detection mirrors federation.py's _detect_backend_file:
graph.duckdb wins when both are present (half-migrated repo).
@joy-software joy-software merged commit a0cc719 into develop Jun 2, 2026
1 check passed
@joy-software joy-software deleted the feature/status-show-backend branch June 2, 2026 06:47
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