Skip to content

fix(graph): stop leaking edges to excluded neighbors#463

Open
davion-knight wants to merge 1 commit into
vouchdev:testfrom
davion-knight:fix/graph-neighbor-edge-leak
Open

fix(graph): stop leaking edges to excluded neighbors#463
davion-knight wants to merge 1 commit into
vouchdev:testfrom
davion-knight:fix/graph-neighbor-edge-leak

Conversation

@davion-knight

Copy link
Copy Markdown
Contributor

summary

find_neighbors() appended an edge to the response before checking whether its other endpoint passed the same retrievability/existence checks that gate node inclusion (_neighbor_ok / _node_kind). superseded, archived, and redacted claims — and missing nodes — were correctly excluded from nodes, but the edge pointing at them still went out. a response could contain an edge whose target referenced a claim id the response itself said didn't exist.

kb.neighbors shares this code path across all three surfaces (mcp, jsonl, cli), so the leak was identical everywhere.

what changed

reordered the loop in src/vouch/graph.py::find_neighbors so an edge is only recorded once its other endpoint has been accepted into visited — either just now, having passed the gate, or already accepted in an earlier iteration.

test plan

extended test_find_neighbors_excludes_superseded_claims in tests/test_graph.py to also assert result["edges"] == [] — fails on the old code (returns the dangling edge to the superseded claim), passes with the fix.

.venv/bin/python -m ruff check src tests
.venv/bin/python -m mypy src
.venv/bin/python -m pytest tests/test_graph.py -q
.venv/bin/python -m pytest tests/ -q --ignore=tests/embeddings

all clean. note: the full suite has 3 pre-existing order-dependent failures (test_fsck_clean_kb_prints_clean_and_exits_zero, test_search_fts5_backend_label, test_deindex_removes_fts_and_prov) that reproduce identically on a clean test checkout with no changes — unrelated to this PR, confirmed by stashing this diff and re-running.

find_neighbors() appended an edge to the response before checking
whether its other endpoint passed the same retrievability/existence
checks gating node inclusion (_neighbor_ok / _node_kind). superseded,
archived, and redacted claims -- and missing nodes -- were correctly
excluded from `nodes`, but the edge pointing at them still went out,
so a response could contain an edge whose target referenced a claim
id the response itself said didn't exist.

kb.neighbors shares this code path across all three surfaces (mcp,
jsonl, cli), so the leak was identical everywhere. reordered the loop
so an edge is only recorded once its other endpoint has been accepted
into `visited` (either just now, having passed the gate, or already
accepted in an earlier iteration).
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@plind-junior, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 57 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 145d8152-354a-489a-a8ed-73c2bcf27759

📥 Commits

Reviewing files that changed from the base of the PR and between 950151f and 8edd2a9.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • src/vouch/graph.py
  • tests/test_graph.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added docs documentation, specs, examples, and repo guidance retrieval context, search, synthesis, and evaluation tests tests and fixtures size: XS less than 50 changed non-doc lines labels Jul 13, 2026
@plind-junior

Copy link
Copy Markdown
Member

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs documentation, specs, examples, and repo guidance retrieval context, search, synthesis, and evaluation size: XS less than 50 changed non-doc lines tests tests and fixtures

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants