Repository navigation
fix(registry): recover local graphs after registered data directories disappear - #1080
4 commits merged into
Conversation
code-review-graph reviewOverall risk: 0.55 (MEDIUM) — 45 changed function(s)/class(es), 40 affected flow(s), 1 test gap(s) (0 with no tested caller found, 1 reached only through a caller) Risk-scored changes
Affected execution flows
Reached only through a callerNo test names these directly, but a tested caller reaches them along the call path shown. That is a path in the call graph, not a record of execution -- the caller's tests may never take this branch. Treat it as where to look, not as coverage: these count as gaps and are scored as untested.
Powered by code-review-graph — local-first analysis; no code leaves the CI runner. |
|
Thank you for this PR. I tested the fallback, the repos listing and the CLI commands with a removed data folder. The fallback works well. Before I can merge it, please fix these:
The failing tests are on the branch After you push the fix, I will test it again. |
|
Hi @tirth8205, the review issues have been fixed and pushed, with regression tests covering the reported cases. The repos command now catches OSError when inspecting an unreachable registered data directory and continues listing the other repositories. Your regression tests were added and the relevant xfail marks removed. I rechecked CI today: all 17 checks are passing, with the upgrade-path check intentionally skipped. The branch is also up to date with staging and has no merge conflicts. Could you please retest the updated PR when you have a chance? Thank you! |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block approval of the registered data-directory recovery changes.
No open issues 🎉
What changed in this PR
Addresses #1057 by preserving access to an existing local graph when a registered external data directory disappears, while retaining normal priority for existing directories and fresh relocations.
Changes:
- Falls back to environment/local resolution with a warning for both read-only and write callers.
- Displays registered data directories in
repos, marking missing or inaccessible paths without interrupting the listing. - Adds recovery and entry-point regression tests, plus usage documentation.
| File | Description |
|---|---|
tests/test_swept_data_dir_entry_points.py |
Covers recovery through hooks, context tools, search, and exports. |
tests/test_repos_unreachable_data_dir.py |
Checks listing resilience to permission and mount errors. |
tests/test_registered_data_dir_recovery.py |
Covers resolution edge cases and CLI/MCP integration. |
tests/test_missing_registered_data_dir.py |
Tests fallback, relocation priority, and directory display. |
docs/USAGE.md |
Documents recovery behavior and missing-directory markers. |
code_review_graph/incremental.py |
Avoids recreating missing registrations when a local graph exists. |
code_review_graph/cli.py |
Shows registered data paths and handles inspection errors. |
Review effort: Balanced
0160eb0
Linked issue
Closes #1057.
What & why
When a registered external data directory disappears, get_data_dir can recreate it and strand an existing local graph. If the registered directory is missing and the local graph.db exists, warn and fall through to the normal environment/local resolution for both read-only and write callers. Fresh relocations without local graphs and existing registered directories retain their priority. The repos command now displays registered data directories and marks missing ones. Includes usage documentation.
How it was tested
Following the same staged regression/baseline methodology used in my earlier PRs (#274, #276, #279, #353 and #354), against the current contribution target
stagingat6b12d11625cbec3b6773e076cb3d136464fa90e5.ruff check code_review_graph tests/test_missing_registered_data_dir.py: clean.bandit -r code_review_graph/ -c pyproject.toml: zero findings.mypy code_review_graph/ --ignore-missing-imports --no-strict-optional: the same three existing Windowsfcntl.LOCK_EX/LOCK_NB/flockerrors indaemon.pyas unchanged staging; no new errors.Exact test commands (using a local virtual environment with
.[dev], asuvis not installed):Full local Windows suite completed: 4,151 passed, 110 failed, 819 skipped, 46 deselected, 2 xfailed, 2 xpassed; 86% coverage. Unchanged staging: 4,143 passed, 110 failed, with identical skip/xfail/xpass counts. Failure identities match unchanged staging exactly; no new failures. The Git ceiling isolates temporary test repositories from an unrelated enclosing home-directory Git repository; PATH/PYTHONPATH point to each checkout under test. Browser tests passed in CI; browser and opt-in upgrade suites were excluded locally.