fix(graph): stop leaking edges to excluded neighbors#463
Open
davion-knight wants to merge 1 commit into
Open
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).
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.