Repository navigation
Stop get_related_nodes 'both' fan-out double-counting reverse names - #2947
Conversation
…loses #2823) A reverse relationship name resolves to one traversal regardless of the requested direction, so the 'both' fan-out ran the identical query twice and reported every related node twice. Stop after the first call when the name was rewritten to its forward form. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Pragmatic Code Review — PR #2947Review Type: Initial Review Requirements Check
Verification of the stop signal (
|
malibio
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review: APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.
- Stop the 'both' fan-out when the traversal ran in a different direction than requested; a reverseName equal to its forward name comes back un-rewritten, so the name check still double-counted it - Test the same-name reverse spelling, the built-in child_of inverse, and the per-hit direction/relationship labels Skipped: a typed resolved-as-reverse flag on GetRelatedOutput would change the core rel_ops API, out of scope for this agent-lane fix. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Address-review summary (406e8df)✅ #1 🟡 same-name reverseName still double-counted: fixed. The fan-out now stops when the traversal ran in a different direction than the one requested ( Tests: all 4 in Re-review decision: NO RE-REVIEW NEEDED. The logic change is the reviewer's own suggested line, and a test was shown failing before it and passing after; the rest are test additions. |
Closes #2823
Problem
The local agent's
get_related_nodestool implementsdirection: "both"(its default) as tworel_ops::get_related_nodescalls,outthenin, concatenated. Since #2822, a reverse relationship name (declaredreverseName, or a built-in inverse likechild_of) resolves to one traversal regardless of direction, so both calls returned the identical set and every node was reported twice with a doubled count.Fix
After each call, if
rel_opsrewrote the name to its forward form (the signal that it resolved as a reverse name and ignored the requested direction), stop the fan-out. This skips the redundant query instead of running it and deduplicating. Forward and built-in names still fan out to both directions as before.Tests
New
packages/agent/tests/get_related_nodes_both_direction.rsdrives the realGraphToolExecutor::executeagainst a realSqliteStore:directionomitted orbothreturns each of 2 invoices once. Without the fix this fails with count 4.mentions) withbothstill returns the union of outbound and inbound hits.Pre-push gate passed.
🤖 Generated with Claude Code