impact

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

@index Application BFS blast-radius analysis with depth and node-count bounds.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Analyzer

type Analyzer struct {
	// contains filtered or unexported fields
}

Analyzer computes impact radius over the graph. @intent estimate which nodes may be affected by a change

func New

func New(store EdgeReader) *Analyzer

New creates an impact analyzer. @intent construct a blast-radius analyzer around a graph reader

func (*Analyzer) ImpactRadius

func (a *Analyzer) ImpactRadius(ctx context.Context, nodeID uint, depth int) ([]graph.Node, error)

ImpactRadius performs BFS traversal to find all nodes within the given depth. Used by MCP get_impact_radius tool and pre-merge check prompt.

@param nodeID the starting node for blast-radius analysis @param depth BFS traversal depth limit @return all nodes reachable within depth hops @intent identify blast radius of code changes for risk assessment @domainRule traverses both outgoing and incoming edges bidirectionally @see changes.Service.AnalyzePage

func (*Analyzer) ImpactRadiusBounded

func (a *Analyzer) ImpactRadiusBounded(ctx context.Context, nodeID uint, depth int, opts RadiusOptions) (*RadiusResult, error)

ImpactRadiusBounded performs the bidirectional BFS that backs ImpactRadius with explicit caps. @intent expose a limit-aware blast radius traversal for cost-sensitive callers @param nodeID starting node for the BFS @param depth maximum BFS hop count (further capped by opts.MaxDepth) @param opts traversal limits applied during BFS @return RadiusResult with visited nodes and truncation metadata @domainRule traverses outgoing and incoming edges in lock step at each depth @ensures Truncated is true when MaxNodes stopped traversal before adding another node

type EdgeReader

type EdgeReader interface {
	GetEdgesFrom(ctx context.Context, nodeID uint) ([]graph.Edge, error)
	GetEdgesFromNodes(ctx context.Context, nodeIDs []uint) ([]graph.Edge, error)
	GetEdgesTo(ctx context.Context, nodeID uint) ([]graph.Edge, error)
	GetEdgesToNodes(ctx context.Context, nodeIDs []uint) ([]graph.Edge, error)
	GetNodeByID(ctx context.Context, id uint) (*graph.Node, error)
	GetNodesByIDs(ctx context.Context, ids []uint) ([]graph.Node, error)
}

EdgeReader exposes graph queries required for impact analysis. @intent abstract bidirectional edge and node lookups for blast-radius traversal

type RadiusOptions

type RadiusOptions struct {
	MaxDepth int
	MaxNodes int
}

RadiusOptions caps how far ImpactRadiusBounded is allowed to expand. @intent let callers limit BFS depth and visited node count for safety

type RadiusResult

type RadiusResult struct {
	Nodes         []graph.Node
	Truncated     bool
	MaxDepth      int
	MaxNodes      int
	ReturnedNodes int
}

RadiusResult reports the resolved nodes and whether limits truncated traversal. @intent surface the visited node set together with truncation metadata

Jump to

Keyboard shortcuts

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