Skip to content

fix(memory): correct ring-hop distance computation in WaterCircles retrieval#6600

Merged
bug-ops merged 1 commit into
mainfrom
fix/6596-watercircles-ring-hop
Jul 20, 2026
Merged

fix(memory): correct ring-hop distance computation in WaterCircles retrieval#6600
bug-ops merged 1 commit into
mainfrom
fix/6596-watercircles-ring-hop

Conversation

@bug-ops

@bug-ops bug-ops commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Summary

graph_recall_watercircles computed each edge's hop_dist by 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 the dist != hop filter never matched — every edge was dropped for any typical seed-outward graph, regardless of ring_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-context test that had pinned the old buggy empty-result behavior as the expected outcome, and adds regression coverage asserting hop_distance across multiple rings (ring_limit > 1).

Closes #6596

Test plan

  • cargo +nightly fmt --check
  • cargo clippy --profile ci --workspace --all-targets --features "desktop,ide,server,chat,pdf,scheduler,testing" -- -D warnings
  • cargo nextest run --config-file .github/nextest.toml --workspace --features "desktop,ide,server,chat,pdf,scheduler" --lib --bins — 14927 passed
  • RUSTFLAGS="-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 --redact
  • Added regression test for multi-ring (ring_limit > 1) hop_distance bucketing
  • Verified the strengthened tests fail against the pre-fix source-depth-first logic

…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
@github-actions github-actions Bot added documentation Improvements or additions to documentation memory zeph-memory crate (SQLite) rust Rust code changes bug Something isn't working size/M Medium PR (51-200 lines) labels Jul 20, 2026
@bug-ops
bug-ops enabled auto-merge (squash) July 20, 2026 18:23
@bug-ops
bug-ops merged commit 8df9009 into main Jul 20, 2026
43 checks passed
@bug-ops
bug-ops deleted the fix/6596-watercircles-ring-hop branch July 20, 2026 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation memory zeph-memory crate (SQLite) rust Rust code changes size/M Medium PR (51-200 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

graph_recall_watercircles ring-hop filter drops every edge, returns empty results

1 participant