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 IsolationResult ¶ added in v0.10.0
type IsolationResult struct {
File string `json:"file"`
Score float64 `json:"score"`
InboundEdges int `json:"inbound_edges"`
OutboundEdges int `json:"outbound_edges"`
HookExecuted bool `json:"hook_executed"`
ReadsEnv []string `json:"reads_env,omitempty"`
ExecutesProc []string `json:"executes_process,omitempty"`
}
IsolationResult represents the isolation score for a single changed file. Higher scores indicate more isolated files with dangerous outbound edges, which are more suspicious in a supply-chain context.
func ComputeIsolation ¶ added in v0.10.0
func ComputeIsolation(ctx context.Context, store types.GraphStore, changedFiles []types.Hash) ([]IsolationResult, error)
ComputeIsolation computes the isolation score for each changed file. The score captures how "isolated" a file is (few inbound edges from unchanged files) combined with how "dangerous" its outbound edges are (reads_env, executes_process). Files that are isolated AND have dangerous outbound edges score higher, indicating potential supply-chain risk.
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.