Knowledge Graph Integration
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 (recommended for most repos)
Graphify uses tree-sitter for deterministic AST extraction across 20 languages. No LLM required for the code analysis pass.
pip install graphifyycd your-repographify .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:
# Generate the KG (one-time, or after major refactors)graphify .
# Run review — KG auto-detected, function-level output enabledimpact-gate review --path . --since origin/mainThe 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.goEvidence Levels
| Level | What it provides | Limitation |
|---|---|---|
| File mapping | A changed file belongs to a manifest family | Family membership does not prove test coverage |
| Knowledge graph | Static call and test relationships | Edges do not establish runtime execution or assertion coverage |
| Per-test source map | Explicit source-file links for executed specs | Requires 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
- KG Loading: impact-gate checks for
.graphify/graph.jsonor.understand-anything/knowledge-graph.json - Node Matching: Changed files are matched to KG nodes (functions, classes, components)
- Call Chain Traversal: BFS walks up the call graph to find all callers (up to depth 3)
- Test Coverage Mapping: For each affected function, finds test nodes connected via
testsedges - 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
# Graphify caches by SHA — only reprocesses changed filesgraphify .