Documentation
¶
Overview ¶
Package graph provides Neo4j-based code graph operations. Implemented in Phase 05.
Index ¶
- type APIHandlerResult
- type AffectedEndpoint
- type BuildResult
- type Builder
- type CallerResult
- type Client
- type CommunityDetector
- type Edge
- type EntryPoint
- type FileNode
- type FunctionNode
- type ImpactReport
- type PackageNode
- type ProcessDetector
- func (d *ProcessDetector) DetectAll(ctx context.Context, repoID int64) (int, error)
- func (d *ProcessDetector) DetectEntryPoints(ctx context.Context, repoID int64) ([]EntryPoint, error)
- func (d *ProcessDetector) TraceForward(ctx context.Context, entryQName string, maxDepth int) ([]ProcessStepResult, error)
- type ProcessStepResult
- type Querier
- func (q *Querier) AnalyzeImpact(ctx context.Context, symbol string, maxDepth int, repo string) (*ImpactReport, error)
- func (q *Querier) FindCallers(ctx context.Context, functionName string, depth int, minConfidence float64, ...) ([]CallerResult, error)
- func (q *Querier) FormatCallers(functionName string, callers []CallerResult) string
- func (q *Querier) FormatServiceDependencies(service string, deps []string) string
- func (q *Querier) GetAPIHandlers(ctx context.Context, endpointPattern string) ([]APIHandlerResult, error)
- func (q *Querier) GetServiceDependencies(ctx context.Context, service string) ([]string, error)
- type ServiceDependency
- type TypeNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIHandlerResult ¶
APIHandlerResult holds resolved handler info for an endpoint pattern.
type AffectedEndpoint ¶
AffectedEndpoint represents an API endpoint affected by a code change.
type BuildResult ¶
type BuildResult struct {
PackageNodes int
FileNodes int
FunctionNodes int
TypeNodes int
ImportEdges int
ServiceNodes int
ConnectionEdges int
ComponentEdges int
CallEdges int
TypeFlowEdges int
ImplementsEdges int
}
BuildResult holds counts of nodes and edges created.
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder reads the PostgreSQL index and populates the Neo4j knowledge graph.
func NewBuilder ¶
NewBuilder constructs a Builder.
type CallerResult ¶
type CallerResult struct {
Name string
QualifiedName string
File string
Line int
Depth int
Confidence float64
IsNameMatch bool // true when result is a name-match fallback (no CALLS edge in graph)
}
CallerResult holds a function that calls (or references) a target function.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps a Neo4j driver and provides typed helpers for Cypher execution.
type CommunityDetector ¶
type CommunityDetector struct {
// contains filtered or unexported fields
}
CommunityDetector implements Louvain community detection on the call graph.
func NewCommunityDetector ¶
func NewCommunityDetector(pool *pgxpool.Pool, communityRepo domain.CommunityRepository) *CommunityDetector
NewCommunityDetector constructs a CommunityDetector.
func (*CommunityDetector) BuildGraph ¶
func (d *CommunityDetector) BuildGraph(ctx context.Context, repoID int64) ([]string, map[string]string, []Edge, error)
BuildGraph constructs the adjacency list from function_calls table.
func (*CommunityDetector) DetectAll ¶
DetectAll runs Louvain community detection for a repository and persists results.
func (*CommunityDetector) RunLouvain ¶
func (d *CommunityDetector) RunLouvain(nodes []string, edges []Edge) map[string]int
RunLouvain implements the Louvain modularity optimization algorithm.
type EntryPoint ¶
type EntryPoint struct {
QualifiedName string
Name string
FilePath string
Line int
Kind string // "http_handler", "kafka_consumer", "main", "cli"
}
EntryPoint represents a detected entry point in the codebase.
type FunctionNode ¶
FunctionNode represents a function or method in the knowledge graph.
type ImpactReport ¶
type ImpactReport struct {
Callers []CallerResult
AffectedEndpoints []AffectedEndpoint
AffectedComponents []string
}
ImpactReport is the result of a change impact analysis.
type PackageNode ¶
PackageNode represents a Go package/module in the knowledge graph.
type ProcessDetector ¶
type ProcessDetector struct {
// contains filtered or unexported fields
}
ProcessDetector detects entry points and traces execution flows forward.
func NewProcessDetector ¶
func NewProcessDetector(pool *pgxpool.Pool, client *Client, processRepo domain.ProcessRepository) *ProcessDetector
NewProcessDetector constructs a ProcessDetector.
func (*ProcessDetector) DetectAll ¶
DetectAll detects all processes for a repository and persists them.
func (*ProcessDetector) DetectEntryPoints ¶
func (d *ProcessDetector) DetectEntryPoints(ctx context.Context, repoID int64) ([]EntryPoint, error)
DetectEntryPoints finds all entry points in the repository.
func (*ProcessDetector) TraceForward ¶
func (d *ProcessDetector) TraceForward(ctx context.Context, entryQName string, maxDepth int) ([]ProcessStepResult, error)
TraceForward performs a BFS from the entry point through CALLS edges.
type ProcessStepResult ¶
type ProcessStepResult struct {
QualifiedName string
Name string
FilePath string
Line int
Depth int
}
ProcessStepResult holds one step from a forward trace.
type Querier ¶
type Querier struct {
// contains filtered or unexported fields
}
Querier provides higher-level graph query operations over the Neo4j client.
func (*Querier) AnalyzeImpact ¶
func (q *Querier) AnalyzeImpact(ctx context.Context, symbol string, maxDepth int, repo string) (*ImpactReport, error)
AnalyzeImpact performs a transitive impact analysis — finds all callers, affected endpoints, and affected UI components for a given symbol. repo optionally restricts analysis to a single repository (empty = all repos).
func (*Querier) FindCallers ¶
func (q *Querier) FindCallers(ctx context.Context, functionName string, depth int, minConfidence float64, repo string) ([]CallerResult, error)
FindCallers returns functions that call the target function, using recursive CALLS edges in the Neo4j graph (variable-length paths up to depth). minConfidence filters edges below the threshold (0.0 = no filter). repo optionally restricts results to a single repository (empty = all repos).
func (*Querier) FormatCallers ¶
func (q *Querier) FormatCallers(functionName string, callers []CallerResult) string
FormatCallers renders caller results as human-readable text. Graph callers (CALLS edges) and name-match fallbacks are shown in separate sections.
func (*Querier) FormatServiceDependencies ¶
FormatServiceDependencies renders dependency list as human-readable text.
func (*Querier) GetAPIHandlers ¶
func (q *Querier) GetAPIHandlers(ctx context.Context, endpointPattern string) ([]APIHandlerResult, error)
GetAPIHandlers finds functions whose name or qualified name contains the pattern.
type ServiceDependency ¶
ServiceDependency captures a package dependency edge.