get_data_dir recreates a registered data dir that no longer exists, stranding the real graph

Author: Vex788Created Sep 19, 2026Updated Sep 19, 2026

A repository registered with --data-dir pointing into a temp directory loses its graph when the OS sweeps that directory, and the failure is silent and self-perpetuating.

get_data_dir trusts the registry entry with no existence check. With create=True it does data_dir.mkdir(parents=True, exist_ok=True) on the registered path, so:

  1. The temp directory is swept.
  2. The next read-only tool resolves to the missing path and reports missing_graph / "No graph found ... run build first" — while a perfectly good <repo>/.code-review-graph/graph.db sits there unused.
  3. The next write command recreates the registered directory empty and builds a second graph into it.

_get_store in tools/_common.py calls get_db_path(root) without read_only=True, so even an ordinary query participates in step 3.

Suggested fix: when create=True, the registered directory does not exist, and <repo>/.code-review-graph/graph.db does, log a warning naming both paths and fall through to normal resolution instead of creating the registered path. Relocating a graph-less repository to a fresh directory — the documented use of --data-dir — keeps working because the guard only fires when a local graph already exists.

Related and cheap: code-review-graph repos prints only the repository path, so a relocated data_dir is invisible. Printing it, with a [MISSING] marker when the directory is gone, turns a silent failure into a visible one.

Source: tirth8205/code-review-graph