fix: count INHERITS/IMPLEMENTS edges in search_graph degree#572
Merged
DeusData merged 2 commits intoJun 23, 2026
Merged
Conversation
search_graph reported in_degree/out_degree of 0 for Class nodes that
have real INHERITS edges, because the degree computation in both
cbm_store_node_degree (Cypher virtual properties) and cbm_store_search
(result population and min_degree/max_degree filter) only counted CALLS
(and USAGE) edges. A min_degree filter therefore silently excluded
well-connected classes.
Broaden the edge-type predicate in both surfaces to
IN ('CALLS', 'USAGE', 'INHERITS', 'IMPLEMENTS') so search_graph and
Cypher report the same edge-type-agnostic degree and stay consistent.
Add regression tests covering: a parent class with N INHERITS children,
combined CALLS+INHERITS degree without double counting, min_degree now
including inheritance-only classes, and isolated nodes still reporting
zero.
Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
cbm_store_node_degree backs the MCP get_code_snippet callers/callees counts and the Cypher in_degree/out_degree virtual property, which are deliberately CALLS-scoped. Restore it to CALLS-only and scope the INHERITS/IMPLEMENTS broadening to cbm_store_search alone, which is the search_graph surface issue DeusData#558 is about. Adjust the new tests so node_degree assertions expect CALLS-only counts while the search_graph result assertions expect the broadened structural degree. Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
1 task
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 does this PR do?
Fixes #558.
search_graphreportedin_degree: 0/out_degree: 0forClassnodes that have realINHERITSedges (e.g. a parent class with 8 subclasses showedin_degree: 0), so anymin_degreefilter silently excluded well-connected classes.The degree shown by
search_graphis computed on demand incbm_store_search, where thein_deg/out_degsubqueries only countede.type IN ('CALLS', 'USAGE'), omitting structural edges. This PR broadens that predicate toIN ('CALLS', 'USAGE', 'INHERITS', 'IMPLEMENTS')so the surfaced degree and themin_degree/max_degreefilter reflect inheritance edges.cbm_store_node_degreeis left untouched on purpose: it backs theget_code_snippetcallers/calleescounts and the Cypherin_degree/out_degreevirtual property, both of which are deliberately CALLS-scoped. Broadening it there would inflate call counts, so the fix is scoped to thesearch_graphsurface that the issue is about.Tests
Added four regression tests to
tests/test_store_search.c:store_search_degree_counts_inherits— a parentClasswith NINHERITSchildren now reportsin_degree == Nviasearch_graph(the exact bug from the issue).store_search_degree_calls_plus_inherits_no_double_count— a node with both aCALLSand anINHERITSedge reports the combined degree with no double counting.store_search_min_degree_includes_inherits_only— a class connected only byINHERITSis now included by amin_degree = 1filter (previously excluded).store_search_isolated_node_zero_degree— an edgeless node still reports0.The pre-existing
store_node_degreetest (which assertscbm_store_node_degreestays CALLS-only) continues to pass, confirming the caller/callee semantics are unchanged.Checklist
git commit -s) — required, CI rejects unsigned commits (DCO, see CONTRIBUTING.md)make -f Makefile.cbm test) — thestore_searchandstore_nodessuites pass; the new degree tests andstore_node_degreeare greenclang-formatclean