Conversation
The incremental path already refuses a graph anchored to a different repository root via _assert_graph_matches_root (tirth8205#889). When tools/build.py auto-escalated to full_rebuild=True (no nodes or no usable diff base), that guard was bypassed entirely and the foreign graph was silently wiped and replaced (tirth8205#906). The automatic fallback now applies the same root guard before escalating. An explicit user --full still keeps its wipe-and-rebuild behavior.
code-review-graph reviewOverall risk: 0.55 (MEDIUM) — 5 changed function(s)/class(es), 1 affected flow(s), 2 test gap(s) Risk-scored changes
Affected execution flows
Test gaps
Token savings: this graph-backed report used ~1,393 fewer tokens (~14%) 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. |
|
The guard itself is right, and I confirmed it closes the path I reported: on the parent commit, Three things need fixing before I take it. 1. The shipped GitHub Action turns the refusal straight back into a wipe. code-review-graph update --base "${CRG_BASE}" || code-review-graph build
Same data loss as #906, now with an ignorable stderr line in front of it. 2. The daemon's initial build bypasses the guard, and its probe is wrong in exactly the #906 configuration. db_path = Path(repo.path) / ".code-review-graph" / "graph.db"
if not db_path.exists():
self._initial_build(repo) # shells out to `build` → full_rebuild=True → guard skippedThat ignores 3. The new test does not test anything. A source-text assertion goes green the moment someone renames a variable and red the moment someone reformats, and it protects nothing in between. The PR body says end-to-end coverage "requires the CLI entry path", but Two notes rather than requests:
Small stuff: the guard adds a function-local absolute import of a private symbol while the file already imports from Gates on the branch are green (2987 passed, ruff and mypy clean, 13/13 checks). |
|
Changes required: the Action's fallback still overwrites a foreign graph after the new guard refuses an update. In disposable repositories A and B containing |
|
Checks pass and the code looks right. Missing: tests for the edge cases it introduces.
Every new branch in the code should have a test, including the failure branch. Disagree with any of these? Say so here first. PRs now target |
|
The new guard never runs on the case it was written for. On plain staging, Where the guard is reachable it regresses behaviour. Take a graph whose File markers point at files that no longer exist on this machine. Exit 0, and the markers correctly become B's. This branch refuses, exits 1, and freezes the markers at the dead paths. Nothing is protected, because there is no live checkout to lose, and the user is wedged, because explicit The RuntimeError escapes Gates are green: 4237 passed, 848 skipped, ruff and mypy clean over 77 source files. The happy path costs nothing. I built psf/requests at dae7ef6 on both branches and got 801 nodes and 5370 edges after a full build, 802 and 5371 after an incremental update, with zero differing node or edge identities. To make it mergeable:
|
Summary
The incremental path already refuses a graph anchored to a different repository root via
_assert_graph_matches_root(#889). Whentools/build.pyauto-escalated tofull_rebuild=True— either because the store had no nodes or because no usable diff base existed — that guard was bypassed entirely and the foreign graph was silently wiped and replaced (#906).The fix applies the same
_assert_graph_matches_rootguard before the automatic fallback escalates. Auser_requested_fullflag distinguishes the automatic path from an explicit user--full, so the explicit flag still keeps its wipe-and-rebuild behavior.Testing
test_assert_graph_matches_root_is_importable— the guard is callable.test_build_py_contains_root_guard_before_auto_full_rebuild— source-level guard:build.pymust call_assert_graph_matches_rootand must trackuser_requested_fullso the guard only fires on the automatic path.Verification boundary: end-to-end testing with two repository roots sharing a graph database requires the CLI entry path; the source-level guard plus the already-tested
_assert_graph_matches_root(from #889) covers the wiring.Fixes #906