fix(graph): stop leaking edges to excluded neighbors#463
Conversation
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).
|
Warning Review limit reached
Next review available in: 57 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
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 fromnodes, but the edge pointing at them still went out. a response could contain an edge whosetargetreferenced a claim id the response itself said didn't exist.kb.neighborsshares 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_neighborsso an edge is only recorded once its other endpoint has been accepted intovisited— either just now, having passed the gate, or already accepted in an earlier iteration.test plan
extended
test_find_neighbors_excludes_superseded_claimsintests/test_graph.pyto also assertresult["edges"] == []— fails on the old code (returns the dangling edge to the superseded claim), passes with the fix.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 cleantestcheckout with no changes — unrelated to this PR, confirmed by stashing this diff and re-running.