feat: surface edge counts in graph_search and graph_get#1459
Merged
Conversation
Both Jarvis knowledge-graph tools now return an "edges" map
({EDGE_TYPE: count}) per node so an agent can see how connected a node is
and which relationship types it can traverse next with graph_neighbors.
- graph_search: sends include_edge_counts=true so Jarvis attaches the
edges map inline (one call, no per-node round trips).
- graph_get: fetches the existing /connection-counts endpoint and
collapses its (edge_type, target_type, count) rows into {EDGE_TYPE:
count} via the new exported collapseConnectionCounts helper. Adds an
optional namespace param so the count is scoped correctly. Best effort:
never fails the call if the lookup errors.
Adds unit tests for collapseConnectionCounts and the updated search URL.
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.
What
graph_searchandgraph_get(the Jarvis knowledge-graph tools agents use to traverse the graph) now include anedgesmap per node showing edge type → count:{ "ref_id": "abc-123", "node_type": "File", "name": "main.rs", "edges": { "CONTAINS": 5, "PART_OF": 4 } }Why
Lets an agent see how connected a node is and which relationship types it can hop along next (via
graph_neighbors) directly from search/get results — no separate exploratory call needed to gauge connectivity.How
graph_search: sendsinclude_edge_counts=trueso Jarvis attaches theedgesmap inline. One call, no per-node round trips.graph_searchresults simply carryedges: {}.graph_get: calls the existing/v2/nodes/{ref_id}/connection-countsendpoint and collapses its(edge_type, target_type, count)rows into{EDGE_TYPE: count}via the new exportedcollapseConnectionCountshelper. Works today (endpoint already exists). Adds an optionalnamespaceparam so the count is scoped to the right partition. Best effort — never fails the call if the lookup errors.Tests
collapseConnectionCounts(summing across target types, missing/non-numeric counts, empty input).graph_searchURL-construction tests to assertinclude_edge_counts=true.toolsJarvis.test.tspass;tsc --noEmitclean.