Skip to content

fix: count INHERITS/IMPLEMENTS edges in search_graph degree#572

Open
mvanhorn wants to merge 2 commits into
DeusData:mainfrom
mvanhorn:fix/558-search-graph-degree-inherits-edges
Open

fix: count INHERITS/IMPLEMENTS edges in search_graph degree#572
mvanhorn wants to merge 2 commits into
DeusData:mainfrom
mvanhorn:fix/558-search-graph-degree-inherits-edges

Conversation

@mvanhorn

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #558. search_graph reported in_degree: 0 / out_degree: 0 for Class nodes that have real INHERITS edges (e.g. a parent class with 8 subclasses showed in_degree: 0), so any min_degree filter silently excluded well-connected classes.

The degree shown by search_graph is computed on demand in cbm_store_search, where the in_deg/out_deg subqueries only counted e.type IN ('CALLS', 'USAGE'), omitting structural edges. This PR broadens that predicate to IN ('CALLS', 'USAGE', 'INHERITS', 'IMPLEMENTS') so the surfaced degree and the min_degree/max_degree filter reflect inheritance edges.

cbm_store_node_degree is left untouched on purpose: it backs the get_code_snippet callers/callees counts and the Cypher in_degree/out_degree virtual property, both of which are deliberately CALLS-scoped. Broadening it there would inflate call counts, so the fix is scoped to the search_graph surface that the issue is about.

Tests

Added four regression tests to tests/test_store_search.c:

  • store_search_degree_counts_inherits — a parent Class with N INHERITS children now reports in_degree == N via search_graph (the exact bug from the issue).
  • store_search_degree_calls_plus_inherits_no_double_count — a node with both a CALLS and an INHERITS edge reports the combined degree with no double counting.
  • store_search_min_degree_includes_inherits_only — a class connected only by INHERITS is now included by a min_degree = 1 filter (previously excluded).
  • store_search_isolated_node_zero_degree — an edgeless node still reports 0.

The pre-existing store_node_degree test (which asserts cbm_store_node_degree stays CALLS-only) continues to pass, confirming the caller/callee semantics are unchanged.

Checklist

  • Every commit is signed off (git commit -s) — required, CI rejects unsigned commits (DCO, see CONTRIBUTING.md)
  • Tests pass locally (make -f Makefile.cbm test) — the store_search and store_nodes suites pass; the new degree tests and store_node_degree are green
  • Lint passes — touched files are clang-format clean
  • New behavior is covered by a test (reproduce-first for bug fixes)

mvanhorn added 2 commits June 23, 2026 04:08
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Class nodes always have in_degree/out_degree = 0 despite real INHERITS edges existing

1 participant