diff

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package diff computes semantic diffs and PR impact analysis between graph snapshots.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DiffSummary

type DiffSummary struct {
	NodesAdded    int `json:"nodes_added"`
	NodesRemoved  int `json:"nodes_removed"`
	NodesModified int `json:"nodes_modified"`
	EdgesAdded    int `json:"edges_added"`
	EdgesRemoved  int `json:"edges_removed"`
}

DiffSummary provides aggregate counts.

type EdgeChange

type EdgeChange struct {
	SourceName string  `json:"source_name"`
	TargetName string  `json:"target_name"`
	EdgeType   string  `json:"edge_type"`
	Confidence float64 `json:"confidence"`
	Provenance string  `json:"provenance,omitempty"`
}

EdgeChange is an edge with enriched source/target metadata.

type ImpactSummary

type ImpactSummary struct {
	TotalSymbolsChanged  int    `json:"total_symbols_changed"`
	TotalCallersAffected int    `json:"total_callers_affected"`
	TotalCalleesAffected int    `json:"total_callees_affected"`
	RiskLevel            string `json:"risk_level"`
}

ImpactSummary provides aggregate impact metrics.

type NodeChange

type NodeChange struct {
	QualifiedName string `json:"qualified_name"`
	Kind          string `json:"kind"`
	File          string `json:"file,omitempty"`
	Line          int    `json:"line,omitempty"`
	Signature     string `json:"signature,omitempty"`
	NodeHash      string `json:"node_hash"`
}

NodeChange is a node with enriched metadata for display.

type NodeModification

type NodeModification struct {
	QualifiedName string       `json:"qualified_name"`
	Kind          string       `json:"kind"`
	EdgesAdded    []EdgeChange `json:"edges_added,omitempty"`
	EdgesRemoved  []EdgeChange `json:"edges_removed,omitempty"`
}

NodeModification represents a node whose edges changed without the node itself being added or removed.

type PRImpactResult

type PRImpactResult struct {
	OldSnapshot    string         `json:"old_snapshot"`
	NewSnapshot    string         `json:"new_snapshot"`
	ChangedSymbols []SymbolImpact `json:"changed_symbols"`
	AffectedEdges  []EdgeChange   `json:"affected_edges"`
	Summary        ImpactSummary  `json:"summary"`
}

PRImpactResult is the blast radius analysis for a PR.

func PRImpact

func PRImpact(ctx context.Context, store types.GraphStore, oldSnapshot, newSnapshot types.Hash) (*PRImpactResult, error)

PRImpact computes blast radius analysis for all symbols that changed between two snapshots. For each added, removed, or modified symbol, it finds callers and callees to assess impact scope.

type SemanticDiffResult

type SemanticDiffResult struct {
	OldSnapshot   string             `json:"old_snapshot"`
	NewSnapshot   string             `json:"new_snapshot"`
	NodesAdded    []NodeChange       `json:"nodes_added"`
	NodesRemoved  []NodeChange       `json:"nodes_removed"`
	NodesModified []NodeModification `json:"nodes_modified,omitempty"`
	EdgesAdded    []EdgeChange       `json:"edges_added"`
	EdgesRemoved  []EdgeChange       `json:"edges_removed"`
	Summary       DiffSummary        `json:"summary"`
}

SemanticDiffResult is the enriched diff between two snapshots.

func SemanticDiff

func SemanticDiff(ctx context.Context, store types.GraphStore, oldSnapshot, newSnapshot types.Hash) (*SemanticDiffResult, error)

SemanticDiff computes an enriched semantic diff between two snapshots. It takes the raw DiffResult from store.SnapshotDiff and enriches it with node metadata (qualified names, signatures) and detects modified nodes (nodes whose edges changed without the node being added/removed).

type SymbolImpact

type SymbolImpact struct {
	Symbol      NodeChange   `json:"symbol"`
	ChangeType  string       `json:"change_type"`
	Callers     []NodeChange `json:"callers,omitempty"`
	Callees     []NodeChange `json:"callees,omitempty"`
	CallerCount int          `json:"caller_count"`
	CalleeCount int          `json:"callee_count"`
}

SymbolImpact describes the blast radius of a single changed symbol.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL