fix(memory): correct ring-hop distance computation in WaterCircles retrieval#6600
Merged
Conversation
…trieval graph_recall_watercircles computed hop_dist by preferring the edge's source-node depth, falling back to target only when source was absent from the depth map. Since BFS discovers edges regardless of traversal direction, source was almost always present but one ring shallower than the edge's true ring, so the dist != hop filter never matched and every edge was dropped for any typical seed-outward graph, regardless of ring_limit. Fixed by computing hop_dist as the max of source and target depth -- the edge's farther endpoint from the seed -- which correctly identifies its ring regardless of discovery orientation. Also fixes a zeph-agent-context test that had pinned the old buggy empty-result behavior as expected, and adds regression coverage for multi-ring (ring_limit > 1) bucketing. Closes #6596
bug-ops
enabled auto-merge (squash)
July 20, 2026 18:23
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
graph_recall_watercirclescomputed each edge'shop_distby preferring the edge's source-node depth, falling back to the target only when source was absent from the depth map. Since BFS discovers edges regardless of traversal direction, the source was almost always present but one ring shallower than the edge's true ring, so thedist != hopfilter never matched — every edge was dropped for any typical seed-outward graph, regardless ofring_limit.Fixed by computing
hop_dist = max(source_depth, target_depth)— the edge's farther endpoint from the seed — which correctly identifies its ring regardless of discovery orientation.Also fixes a
zeph-agent-contexttest that had pinned the old buggy empty-result behavior as the expected outcome, and adds regression coverage assertinghop_distanceacross multiple rings (ring_limit > 1).Closes #6596
Test plan
cargo +nightly fmt --checkcargo clippy --profile ci --workspace --all-targets --features "desktop,ide,server,chat,pdf,scheduler,testing" -- -D warningscargo nextest run --config-file .github/nextest.toml --workspace --features "desktop,ide,server,chat,pdf,scheduler" --lib --bins— 14927 passedRUSTFLAGS="-D warnings" RUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links" cargo doc --no-deps --workspace --features "desktop,ide,server,chat,pdf,scheduler"gitleaks protect --staged --no-banner --redactring_limit > 1)hop_distancebucketing