Documentation
¶
Overview ¶
Package graphx defines the cooperation interfaces between the ephemeral callgraph (internal/callgraph) and the persistent AGE graph (internal/codegraph). Both packages may implement these interfaces without either importing the other.
Consumers receive an Analytics and/or CrossRefs value through analyze.Deps. When no persistent graph is available, Noop{} is used as the fallback — all methods return zero/empty results and never error.
Index ¶
- type Analytics
- type CrossRefs
- type Noop
- func (Noop) FetchedBy(_ context.Context, _ string, _ Route) ([]SymbolRef, error)
- func (Noop) HandlesRoute(_ context.Context, _, _, _ string) (Route, bool, error)
- func (Noop) Symbol(_ context.Context, _, _, _ string) (Signals, error)
- func (Noop) TestedBy(_ context.Context, _, _, _ string) ([]SymbolRef, error)
- func (Noop) TopPageRank(_ context.Context, _ string, _ int) ([]Signal, error)
- type Route
- type Signal
- type Signals
- type SymbolRef
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Analytics ¶
type Analytics interface {
// Symbol returns the pagerank, community, and surprise signals for a
// single symbol in the given repo.
Symbol(ctx context.Context, repoKey, symbolName, file string) (Signals, error)
// TopPageRank returns the k symbols with the highest pagerank in the repo,
// ordered descending. Returns an empty slice (not an error) when the graph
// has no snapshot.
TopPageRank(ctx context.Context, repoKey string, k int) ([]Signal, error)
}
Analytics returns persistent-graph-computed scalar signals for symbols. Implementations MUST tolerate repos with no snapshot and return Signals{Found: false} rather than an error.
type CrossRefs ¶
type CrossRefs interface {
// HandlesRoute returns the HTTP Route served by a handler symbol, and
// whether such a binding was found. Returns Route{}, false, nil when absent.
HandlesRoute(ctx context.Context, repoKey, symbolName, file string) (Route, bool, error)
// FetchedBy returns the frontend (or upstream) symbols that issue HTTP
// requests to the given route. Returns nil, nil when none are found.
FetchedBy(ctx context.Context, repoKey string, route Route) ([]SymbolRef, error)
// TestedBy returns test functions that directly cover the given production
// symbol. Returns nil, nil when no test edges are recorded.
TestedBy(ctx context.Context, repoKey, symbolName, file string) ([]SymbolRef, error)
}
CrossRefs surfaces graph edges that the ephemeral callgraph does not carry: HTTP route bindings, cross-language FETCHES, and test coverage edges. Implementations MUST tolerate missing snapshots and return empty results.
type Noop ¶
type Noop struct{}
Noop is the zero-cost fallback implementation used when no persistent graph is available (e.g. DATABASE_URL is empty or AGE is not ready). Every method returns an empty/zero result and never errors.
func (Noop) HandlesRoute ¶
HandlesRoute implements CrossRefs. Always returns Route{}, false, nil.
type Route ¶
type Route struct {
// Method is the HTTP method (e.g. "GET", "POST"). Empty means any.
Method string
// Path is the route path pattern (e.g. "/api/users/:id").
Path string
}
Route identifies an HTTP route by method and path pattern. An empty Method means "any method".
type Signal ¶
Signal pairs a symbol reference with its analytics signals. Used as an element type by Analytics.TopPageRank.
type Signals ¶
type Signals struct {
// PageRank is the normalized PageRank score (0..1).
PageRank float64
// Community is the Louvain community identifier. Empty when unassigned.
Community string
// Surprise is the structural surprise score (higher = less expected).
Surprise float64
// Found is false when the graph has no snapshot for this repo/symbol.
// Zero values for PageRank/Community/Surprise are meaningless when Found is false.
Found bool
}
Signals holds scalar analytics for a single symbol computed by the persistent graph. When Found is false the graph is cold or the symbol was not indexed; callers MUST skip enrichment in that case.