Skip to content

fix(cli): detect-changes/visualize/wiki/watch no longer create empty graph.db - #809

Open
arimu1 wants to merge 1 commit into
tirth8205:mainfrom
arimu1:fix/803-readonly-db-empty-graph
Open

fix(cli): detect-changes/visualize/wiki/watch no longer create empty graph.db#809
arimu1 wants to merge 1 commit into
tirth8205:mainfrom
arimu1:fix/803-readonly-db-empty-graph

Conversation

@arimu1

@arimu1 arimu1 commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #777 / #782: status already resolved the DB path read-only when the graph was missing, but detect-changes, visualize, wiki, and watch still called get_db_path() (create) + GraphStore() and could materialize an empty schema graph.db. Later incremental updates then only re-parsed changed files, leaving the graph incomplete.

Changes

  • Treat those commands like status: resolve DB path with read_only=True (or explicit --data-dir without registry/mkdir side effects).
  • Exit with No graph found … Run code-review-graph build first. when the DB is missing (same message as status / dead-code / forget).
  • Keep the default-path legacy .code-review-graph.db migration for these commands.
  • visualize / wiki still write exports next to an explicit --data-dir when a graph is present, without forcing a registry write when the graph is absent.
  • Document recovery for already-poisoned graphs: full code-review-graph build (see docs/TROUBLESHOOTING.md). Auto-heal heuristics for incomplete non-empty graphs left out of scope (issue gap 2).

Test plan

  • uv run pytest tests/test_cli_reconciliation.py tests/test_cli.py::test_visualize_json_uses_local_export tests/test_cli.py::TestWatchInteraction -k "detect_changes or missing_graph or read_only" -q
  • Parametrized tests: missing graph for status/detect-changes/visualize/wiki/watch does not create data dir or empty graph.db
  • Explicit --data-dir for visualize/wiki/watch/status is read-only when missing
  • Existing status / visualize / watch regressions still green
  • ruff check on touched Python files

Fixes #803

detect-changes, visualize, wiki, and watch now resolve the DB path
read-only like status: no data dir, registry entry, or empty schema
when the graph is missing. Document recovery via full `build` for
graphs poisoned by earlier releases.

Fixes tirth8205#803
@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown

code-review-graph review

Overall risk: 0.35 (LOW) — 4 changed function(s)/class(es), 0 affected flow(s), 1 test gap(s)

Risk-scored changes

Risk Level Symbol Location Tested
0.35 low code_review_graph/cli.py::main code_review_graph/cli.py:603 no
0.30 low tests/test_cli.py::test_visualize_json_uses_local_export tests/test_cli.py:105 (test)
0.30 low tests/test_cli_reconciliation.py::test_read_only_commands_missing_graph_do_not_create_empty_db tests/test_cli_reconciliation.py:157 (test)
0.30 low tests/test_cli_reconciliation.py::test_read_only_commands_data_dir_option_is_read_only tests/test_cli_reconciliation.py:196 (test)

Test gaps

  • code_review_graph/cli.py::main (code_review_graph/cli.py:603)

Token savings: this graph-backed report used ~33,819 fewer tokens (~97%) than reading every changed file in full (estimated, chars/4 approximation).


Powered by code-review-graph — local-first analysis; no code leaves the CI runner.

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.

Remaining commands still create an empty graph.db on first run; released-version poisoned graphs are not auto-healed (follow-up to #777 / #782)

1 participant