diff-analyzer module takes a list of changed file paths (e.g. from a git diff) and maps them to the knowledge graph to identify directly changed components, downstream affected components, impacted layers, and cross-cutting relationships. It also generates a risk assessment.
DiffContext
The data structure returned bybuildDiffContext.
Name of the analyzed project, taken from
graph.project.name.The original list of changed file paths passed to
buildDiffContext.Nodes whose
filePath matches one of the changed files, plus any nodes contained within those nodes via "contains" edges.1-hop neighbors of
changedNodes that are not themselves changed — the downstream blast radius.All edges where at least one endpoint is a changed node.
Layers that contain at least one changed or affected node.
Changed files that could not be matched to any node in the knowledge graph (e.g. new files or deleted files not yet re-analyzed).
buildDiffContext
Maps a list of changed file paths to knowledge graph nodes and identifies the ripple effect (affected nodes, layers, edges).The full knowledge graph produced by the analysis pipeline.
File paths that have changed, as returned by
git diff --name-only or similar. Paths should match the filePath values stored on graph nodes.How it works
- File mapping — Each path in
changedFilesis matched againstnode.filePathon every node. Unmatched paths go intounmappedFiles. - Children expansion — For any matched node, edges of type
"contains"are followed to include contained child nodes in the changed set. - 1-hop neighbor detection — All edges touching a changed node are collected as
impactedEdges. The non-changed endpoint of each edge becomes anaffectedNode. - Layer collection — Any layer with a node ID in the union of changed and affected sets is included in
affectedLayers.
formatDiffAnalysis
Formats aDiffContext as structured markdown for LLM or human consumption.
A
DiffContext produced by buildDiffContext.Output structure
The returned string contains the following sections:| Section | Content |
|---|---|
## Changed Components | Name, type, summary, file path, and complexity for each changed node |
## Affected Components | Downstream neighbors that may need attention |
## Affected Layers | Layers touched by the change |
## Impacted Relationships | source --[type]--> target for every impacted edge |
## Unmapped Files | Changed files not found in the knowledge graph |
## Risk Assessment | Automatically computed risk signals |
Risk assessment logic
The risk section is computed automatically from the context:- High complexity — emitted when any changed node has
complexity === "complex" - Cross-layer impact — emitted when affected layers span more than one layer
- Wide blast radius — emitted when more than 5 nodes are affected downstream
- New/unmapped files — emitted when
unmappedFilesis non-empty - Low risk — emitted only when none of the above conditions are met