Skip to content

Knowledge Graph Integration

Function-level accuracy

Generate a code knowledge graph to upgrade impact-gate from file-level to function-level analysis. Trace changed functions to their callers, identify which specific functions lack test coverage, and get precise impact reports.

Why Use a Knowledge Graph

Without a knowledge graph, impact-gate works at file level: “post.go changed” maps to the “post” family. With a knowledge graph, it works at function level:

SetChannelManagedCategory (channel_category.go:288)
→ called by: patchChannel (channel.go:455)
→ tested by: managed_categories.spec.ts
ClearChannelManagedCategory (channel_category.go:319)
→ called by: patchChannel (channel.go:468)
→ tested by: (none) ← coverage gap!

These graph edges help locate candidate tests. They do not prove a test executes a function or asserts its changed behavior, and they cannot eliminate false positives or missed impacts. Treat the displayed “tested” labels as graph relationships requiring review.

Supported Tools

impact-gate auto-detects knowledge graphs from two tools:

Graphify uses tree-sitter for deterministic AST extraction across 20 languages. No LLM required for the code analysis pass.

Terminal window
pip install graphifyy
cd your-repo
graphify .

Output: .graphify/graph.json — auto-detected by impact-gate.

Languages: TypeScript, JavaScript, Go, Python, Rust, Java, C, C++, Ruby, C#, Kotlin, Scala, PHP, Swift, and more.

Understand-Anything (for Claude Code users)

Understand-Anything generates a knowledge graph using AI agents. Requires a Claude Code or similar AI runtime.

Output: .understand-anything/knowledge-graph.json — auto-detected by impact-gate.

Using KG with impact-gate

Once you have a knowledge graph, impact-gate automatically uses it:

Terminal window
# Generate the KG (one-time, or after major refactors)
graphify .
# Run review — KG auto-detected, function-level output enabled
impact-gate review --path . --since origin/main

The review output will include:

Untested Functions (need coverage):
❌ ClearChannelManagedCategory (channel_category.go) -- called by: patchChannel
❌ handleManagedCategoryWebSocket (websocket_actions.ts)
Tested Functions:
✅ SetChannelManagedCategory -- tested by: managed_categories.spec.ts
✅ patchChannel -- tested by: channel_test.go

Evidence Levels

LevelWhat it providesLimitation
File mappingA changed file belongs to a manifest familyFamily membership does not prove test coverage
Knowledge graphStatic call and test relationshipsEdges do not establish runtime execution or assertion coverage
Per-test source mapExplicit source-file links for executed specsRequires real coverage data; a report or Git diff alone supplies no links

No fixed accuracy percentage is established for these levels. The Mattermost advisory caller keeps declared mapping evidence separate and does not ingest measured per-test coverage.

How It Works

  1. KG Loading: impact-gate checks for .graphify/graph.json or .understand-anything/knowledge-graph.json
  2. Node Matching: Changed files are matched to KG nodes (functions, classes, components)
  3. Call Chain Traversal: BFS walks up the call graph to find all callers (up to depth 3)
  4. Test Coverage Mapping: For each affected function, finds test nodes connected via tests edges
  5. Gap Detection: Functions with no test coverage are flagged in the review output

Regenerating the KG

Regenerate after:

  • Major refactors that change function signatures or call chains
  • Adding new modules or entry points
  • Before a release review
Terminal window
# Graphify caches by SHA — only reprocesses changed files
graphify .