Skip to content

feat: add cross-language edge contexts and context-aware queries#573

Open
TheFedaikin wants to merge 1 commit intosafishamsi:v5from
TheFedaikin:v5
Open

feat: add cross-language edge contexts and context-aware queries#573
TheFedaikin wants to merge 1 commit intosafishamsi:v5from
TheFedaikin:v5

Conversation

@TheFedaikin
Copy link
Copy Markdown

Make graph queries context-aware across languages

What we want

We want graphify queries to distinguish between edge kinds that are currently traversed together.

Examples:

  • calls vs type/declaration references
  • imports vs executable relationships
  • field references vs other symbol mentions

A query like who calls X? should prefer call-heavy results instead of mixing calls, imports, and declaration-style references.

Why

This improves query precision in larger or noisier graphs and makes edge disambiguation a graph-level, cross-language capability.

Model boundary:

  • relation = semantic edge type
  • context = syntactic disambiguation where needed

Proposal

Add a cross-language context layer for edges where it improves query quality, and use it during query traversal.

Initial contexts:

  • call
  • import
  • field

Queries should support:

  • explicit filtering
  • small heuristic inference when the query clearly implies a context

Examples:

  • graphify query "extract" --context call
  • who calls extract -> infer call when no explicit filter is provided

Scope

  • add/standardize edge context where supported
  • support context-aware filtering in:
    • CLI graphify query
    • MCP query_graph
  • show active context filtering in query output

Non-goals

  • do not move inherits / implements into context
  • do not replace relation with context
  • do not build broad NLP intent parsing
  • do not treat this as a fix for general explain / path disambiguation

References #569

This is related to #569, but narrower in scope.

  • #569 is mainly about resolving the right node or candidate set in large, noisy graphs
  • this issue is about traversing the right edge kinds once the node is found

In short:

  • #569 = node resolution / disambiguation
  • this issue = edge-context-aware traversal

Done when

  • queries can explicitly filter by context
  • obvious query phrasing can infer context when no filter is passed
  • output makes the active context visible
  • extraction/tests cover the touched languages

› can you now give me the updated PR description?

• # Add cross-language edge contexts and context-aware queries

Summary

This PR makes edge context a first-class cross-language query feature.

It:

  • expands edge context support across touched extractors
  • adds repeatable --context filtering to CLI graphify query
  • adds context_filter to MCP query_graph
  • adds small heuristic context inference when no explicit filter is provided
  • shows the active context filter in query output

Model boundary:

  • relation = semantic meaning
  • context = syntactic disambiguation

Why

Testing

uv run --with pytest pytest tests/test_extract.py tests/test_multilang.py tests/test_languages.py tests/test_serve.py tests/test_query_cli.py -q

Passed:

  • 181 passed

Also ran:

uv run graphify update .

Queries like who calls X? should not traverse the same way as what imports X? or where is X used as a field?.

This improves query precision and gives graphify a cleaner cross-language story for edge disambiguation.

References

Closes #572.
Related to #569.

This PR improves traversal precision via edge-context filtering, but does not address explain / path candidate resolution or broader node-disambiguation behavior.

Examples

graphify query "extract" --context call
graphify query "who calls extract"

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.

Feature request: make graph queries context-aware across languages

1 participant