fix: replace N+1 loop in QueryService.findRelatedEndpoints() with batch Cypher query#12
Merged
Merged
Conversation
…her query Added GraphStore.findEndpointNeighborsBatch() that fetches all endpoint neighbors for a list of node IDs in one MATCH ... WHERE n.id IN $nodeIds query, eliminating up to 50 separate findNeighbors() calls per invocation. QueryService.findRelatedEndpoints() now separates the direct-endpoint pass from the neighbor pass, using the new batch method for the latter. Deduplication and connected_via semantics are preserved. Added 3 unit tests covering: batch usage (verifying findNeighbors is never called), direct endpoint matches, and deduplication. Co-Authored-By: Paperclip <noreply@paperclip.ing>
|
aksOps
added a commit
that referenced
this pull request
Apr 3, 2026
Resolves conflicts between backend chain (PRs #12-#16) and detection quality fixes: - TopicLinker: preserved extended SENDS_TO/RECEIVES_FROM/PUBLISHES/LISTENS support from both chains - GraphStore/EnrichCommand: kept search_index (fulltext, keyword analyzer, label_lower/fqn_lower) from backend chain - QueryService: preserved batch endpoint neighbor query from backend chain + stats improvements - NestJSControllerDetectorTest/NestJSGuardsDetectorTest: merged no-match discriminator tests Co-Authored-By: Paperclip <noreply@paperclip.ing>
aksOps
added a commit
that referenced
this pull request
Apr 3, 2026
… fix) The merge of feat/phase5-dashboard-redesign into main introduced a duplicate definition of findEndpointNeighborsBatch(List<String>). Both versions had identical semantics but different implementation style: Kept: the first (from the backend chain PRs #12-16) which uses NodeKind.ENDPOINT.getValue() for type safety and UNWIND/MATCH pattern with $ids parameter. Removed: the second (from phase5) which used string literals ('ENDPOINT', 'WEBSOCKET_ENDPOINT') and IN $nodeIds pattern. Fixes: compilation failure on main (javac error: method already defined). Co-Authored-By: Paperclip <noreply@paperclip.ing>
2 tasks
aksOps
added a commit
that referenced
this pull request
Apr 3, 2026
Two duplicate method definitions were introduced when feat/phase5-dashboard-redesign was merged into main, because both the backend chain (PRs #12-16) and the phase5 branch independently added the same methods: 1. GraphStore.findEndpointNeighborsBatch(List<String>): - Kept: UNWIND/$ids/NodeKind.getValue() version (from backend chain, type-safe) - Removed: IN $nodeIds/string literal version (from phase5) 2. TopicLinkerTest.determinismTest(): - Kept: multi-producer/multi-consumer test with PRODUCES+CONSUMES+PUBLISHES+LISTENS and TOPIC+EVENT nodes (more comprehensive, verifies target ID equality) - Removed: simpler 3-edge test (from backported detection-quality-fixes commit) Fixes: javac compilation failures on main branch. Co-Authored-By: Paperclip <noreply@paperclip.ing>
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
findRelatedEndpoints()was executing up to 50 separatefindNeighbors()Cypher queries in a loop (one per search result)GraphStore.findEndpointNeighborsBatch(List<String> nodeIds)that fetches all endpoint/websocket endpoint neighbors in a singleMATCH ... WHERE n.id IN $nodeIds AND m.kind IN [...]queryQueryService.findRelatedEndpoints()now separates the direct-endpoint check from the neighbor traversal and uses the batch method for the latterconnected_viafield and deduplication semantics are fully preservedTest plan
QueryServiceTest: batch query usage (verifiesfindNeighborsis never called), direct endpoint matches, deduplication🤖 Generated with Claude Code