Skip to content

context_filter can never select inheritance edges for C#, Java and Python (heritage edges carry no context; TypeScript's carry "type"), and a filter that matches no edge is silent #5178

Closed

Description

@janmaticka

Pre-flight checks

  • I searched existing issues and PRs for context_filter + inheritance; nothing found

What happened?

query_graph's context_filter keeps only edges whose context attribute is in the filter (serve.py _filter_graph_by_context, data.get("context") in filters). Heritage edges (inherits / implements) get a context only from the TypeScript extractor (type). The C#, Java and Python extractors emit them without one: extractors/engine.py add_edge() sets context only when it is passed, and e.g. the C# base_list branch calls add_edge(class_nid, base_nid, relation, line, metadata=metadata).

As a result, no context_filter value can select inheritance in C#, Java or Python: ["type"] works for TypeScript only, and ["inherits"] matches nothing in any language (_CONTEXT_FILTER_ALIASES has no entry for it).

The failure is silent. The traversal returns the seed node(s) and no edges, with no hint that the filter matched zero edges. On our C# graph, OneTimeAsyncStartable is the base class of ~550 types (get_neighbors(relation_filter="inherits") lists them all), yet query_graph comes back with 1 nodes found for both context_filter=["inherits"] and ["type"].

Expected: heritage edges are selectable by context the same way in every language, and an explicit filter that matches no edge in the graph is reported instead of producing an empty-looking answer.

Steps to reproduce

Same hierarchy in four languages, graphify extract . --code-only --no-viz:

src/Shapes.cs    namespace Demo { public interface IShape { double Area(); } public class Base { } public class Square : Base, IShape { public double Area() => 1; } }
src/shapes.ts    export interface IShape { area(): number }  export class Base {}  export class Square extends Base implements IShape { area() { return 1 } }
src/Shapes.java  interface IShape { double area(); }  class Base {}  class Square extends Base implements IShape { public double area() { return 1; } }
src/shapes.py    class Base: pass / class Square(Base): def area(self): return 1

Error output or graph output

Heritage edges in the resulting graph.json:

src/shapes.ts    implements  context='type'   square -> ishape
src/shapes.ts    inherits    context='type'   square -> base
src/Shapes.cs    inherits    context=None     square -> base
src/Shapes.cs    implements  context=None     square -> ishape
src/Shapes.java  implements  context=None     square -> ishape
src/Shapes.java  inherits    context=None     square -> base
src/shapes.py    inherits    context=None     square -> base

On a real C# graph:

query_graph(question="OneTimeAsyncStartable subclasses", context_filter=["inherits"])
Graph: ... (91973 nodes) | Traversal: BFS depth=3 | Start: ['OneTimeAsyncStartable'] | Context: inherits (explicit) | 1 nodes found
NODE OneTimeAsyncStartable [src=src/Common/.../OneTimeAsyncStartable.cs loc=L15 ...]

The same result for context_filter=["type"]. The ~550 incoming inherits edges are in the graph: get_neighbors(label="OneTimeAsyncStartable", relation_filter="inherits") returns them.

Suggested fix

  • Give heritage edges one consistent context in every extractor (TypeScript already uses type), or let context_filter fall back to the edge relation for structural relations (inherits, implements, extends, e.g. via _CONTEXT_FILTER_ALIASES plus a relation match in _filter_graph_by_context).
  • When an explicit context_filter matches no edge in the graph, say so in the header, e.g. Context: inherits (explicit, matched 0 edges), so an empty traversal is not mistaken for "no relationships".

Graphify version

0.9.107

Operating System

Linux x86_64 (openSUSE Leap 16)

Python Version

3.13.13

Installation Method

uv tool install "graphifyy[openai,mcp]==0.9.107"

Additional Environment Details

Code-only extraction, no provider involved.

Activity

  1. github-actions commented on Nov 12, 2026

    @github-actions

    Thanks for opening this issue, @janmaticka. A maintainer will take a look soon.

    If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.

    To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.

  2. safishamsi commented on Nov 12, 2026

    @safishamsi
    Member

    Fixed by #5179 (9762d8b), released in graphify 0.9.108. Thanks @janmaticka for the report and @sunhouy for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions