graphquery

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const MaxEntityQueryBytes = 4 << 20

MaxEntityQueryBytes bounds entity responses and each store result batch.

Variables

View Source
var ErrDiscoveryUnavailable = errors.New("graph discovery projection is unavailable; rebuild the generation")
View Source
var ErrGenerationChanged = errors.New("graph generation changed during the request")

ErrGenerationChanged means the generation a request started on was retired or replaced while the request ran; the same request can succeed on retry.

View Source
var ErrGraphMissing = errors.New("no graph generation is active")

ErrGraphMissing means no generation is active for the repository at the indexed commit the request resolved. Retrying cannot help: a SCIP index for that commit must be uploaded or a graph artifact published first. A repository re-indexed between scope resolution and the query reports the same thing, because its new commit has no generation until the next upload.

View Source
var (
	ErrInvalidRequest = errors.New("invalid graph query")
)
View Source
var ErrQuerySize = errors.New("graph query response exceeds byte limit")

Functions

func AddEntityQueryBytes

func AddEntityQueryBytes(used *int, value any) error

AddEntityQueryBytes lets stores and traversal reject oversized facts before accumulating a result set. Final response encoding also checks JSON overhead.

func DiscoveryDocument

func DiscoveryDocument(value string) string

func DiscoveryGrams

func DiscoveryGrams(value string) []string

Native GIN array containment supplies substring recall without pg_trgm, also for long lexemes. SQL rechecks full normalized fields after the gram probe.

func DiscoveryLexeme

func DiscoveryLexeme(term string) string

Search lexemes stay below PostgreSQL's 2047-byte limit. Long words retain an exact hash term and use the indexed gram path for prefix/substring retrieval.

func DiscoveryPatterns

func DiscoveryPatterns(patterns []string) ([]string, []bool)

DiscoveryPatterns compiles gitignore-style rules to PostgreSQL/Go compatible regular expressions. Matching order and ignored ancestors are handled by SQL.

func DiscoveryTerms

func DiscoveryTerms(value string, projectTerms []string) []string

func FoldName

func FoldName(value string) string

FoldName changes ASCII case only; selectors retain non-ASCII and NUL bytes.

func GeneratedFilename

func GeneratedFilename(path string) bool

func IdentifierSegments

func IdentifierSegments(value string) []string

IdentifierSegments follows the pinned segment vocabulary, without discovery's diacritic folding or suffix stemming. Only twelve useful segments are retained.

func NameGrams

func NameGrams(value string) []string

NameGrams uses hex bytes so GIN keys preserve every literal selector byte.

func NormalizeDiscovery

func NormalizeDiscovery(value string) string

NormalizeDiscovery changes the disposable search projection only. Original protobuf facts and bytea selectors retain all bytes, including NUL.

func NormalizeFilePath

func NormalizeFilePath(value string) (string, error)

NormalizeFilePath accepts repository-relative paths, including ./ and redundant separators. Parent traversal, absolute paths and platform separators are refused.

func PathPatterns

func PathPatterns(patterns []string) ([]string, []bool)

PathPatterns preserves path case and Unicode for indexed-file filtering.

func SegmentWordVariants

func SegmentWordVariants(word string) []string

Types

type AggregateFanQuery

type AggregateFanQuery struct {
	Snapshot QuerySnapshot
	Values   []string
	Incoming bool
}

type AggregateLimitQuery

type AggregateLimitQuery struct {
	Snapshot QuerySnapshot
	Limit    int
}

type AggregateModuleQuery

type AggregateModuleQuery struct {
	Snapshot         QuerySnapshot
	Assignments      []graphprotocol.ModuleAssignment
	Kinds, PairKinds []int16
	MinConfidence    float64
	Limit            int
}

type AggregateModuleRow

type AggregateModuleRow struct {
	Source, Target, Kind, From, To string
	Count, Declared, Uncertain     int
}

type AggregateNamesQuery

type AggregateNamesQuery struct {
	Snapshot  QuerySnapshot
	Values    []string
	Operation string
	Limit     int
}

type AggregateUnresolvedQuery

type AggregateUnresolvedQuery struct {
	Snapshot QuerySnapshot
	Values   []string
	Path     string
	Limit    int
}

type AnalysisEntityQuery

type AnalysisEntityQuery struct {
	Snapshot         QuerySnapshot
	Paths, Kinds     []string
	QualifiedPattern string
	QualifiedLiteral *string
	QualifiedParts   []string
	QualifiedPrefix  string
	QualifiedSuffix  string
	Exported         *bool
	Order            string
	Limit            int
}

type AnalysisEvidenceQuery

type AnalysisEvidenceQuery struct {
	Snapshot    QuerySnapshot
	Occurrences []string
	Limit       int
}

type AnalysisStore

type AnalysisStore interface {
	EntityStore
	QueryAnalysisEntities(context.Context, AnalysisEntityQuery) ([]graphprotocol.Entity, error)
	QueryAnalysisEvidence(context.Context, AnalysisEvidenceQuery) ([]graphprotocol.Evidence, error)
}

type DiscoveryQuery

type DiscoveryQuery struct {
	Text                           string
	Kinds, Languages, Paths, Names []string
}

func ParseDiscoveryQuery

func ParseDiscoveryQuery(raw string) DiscoveryQuery

type DiscoverySearch

type DiscoverySearch struct {
	Snapshots                      []QuerySnapshot
	Query                          DiscoveryQuery
	Terms                          []string
	Groups                         [][]string
	Symbols, Files, Deprioritize   []string
	ExplicitSymbols, ExplicitFiles []string
	Limit                          int
	Fuzzy                          bool
	NoMultiterm                    bool
}

type DiscoveryStore

type DiscoveryStore interface {
	QueryDiscovery(context.Context, DiscoverySearch) ([]graphprotocol.DiscoveryMatch, error)
}

DiscoveryStore accepts the same trusted internal generation scope as EntityStore. Returned facts must be bounded before decoding; the service rechecks generation.

type EntityNeighbor

type EntityNeighbor struct {
	Entity graphprotocol.Entity
	Edge   graphprotocol.Evidence
}

type EntityNeighborQuery

type EntityNeighborQuery struct {
	Snapshot      QuerySnapshot
	Occurrence    string
	Relation      string
	Direction     string
	MinConfidence float64
	Limit         int
	// ProducerOrder returns edges in the producer's original row order
	// instead of by neighbor occurrence.
	ProducerOrder bool
}

type EntityQuery

type EntityQuery struct {
	Snapshots     []QuerySnapshot
	Selector      graphprotocol.EntitySelector
	Offset, Limit int
}

type EntityStore

type EntityStore interface {
	EntityGenerations(context.Context, []QuerySnapshot) ([]graphprotocol.Generation, error)
	QueryEntities(context.Context, EntityQuery) ([]graphprotocol.Entity, error)
	EntityNeighbors(context.Context, EntityNeighborQuery) ([]EntityNeighbor, error)
}

EntityStore is the v2 query path; legacy manifests intentionally exclude v2. Callers supply authorized internal repository snapshots. Stores never expand that scope by resolving equal names or occurrences in other repositories.

type FileClassificationQuery

type FileClassificationQuery struct {
	Snapshots []QuerySnapshot
	Paths     []string
}

type FileClassificationRow

type FileClassificationRow struct {
	RepositoryID       int64
	Path               string
	Present            bool
	PersistedGenerated *bool
	Ambient            bool
}

type FileClassificationStore

type FileClassificationStore interface {
	ClassifyFiles(context.Context, FileClassificationQuery) ([]FileClassificationRow, error)
	CountGeneratedFiles(context.Context, []QuerySnapshot) (generated, total int64, err error)
}

type FileCountStore

type FileCountStore interface {
	CountFiles(context.Context, FileQuery) (int64, error)
}

type FileDependencyPairRow

type FileDependencyPairRow struct {
	RepositoryID int64
	Source       string
	Target       string
	References   int
}

type FileDependencyQuery

type FileDependencyQuery struct {
	Snapshot      QuerySnapshot
	Paths         []string
	Direction     string
	MinConfidence float64
	Limit         int
}

type FileDependencyStore

type FileDependencyStore interface {
	QueryFileDependencyPairs(context.Context, FileDependencyQuery) ([]FileDependencyPairRow, error)
}

type FileQuery

type FileQuery struct {
	Snapshots          []QuerySnapshot
	Path               *string
	Prefix             *string
	Directory, Pattern string
	Offset, Limit      int
	UTF16Pattern       bool
}

type FileStore

type FileStore interface {
	QueryFiles(context.Context, FileQuery) ([]graphprotocol.IndexedFile, error)
}

type HierarchyCount added in v0.6.1

type HierarchyCount struct {
	Subtypes, Implementers int
}

type HierarchyCountQuery added in v0.6.1

type HierarchyCountQuery struct {
	Snapshot   QuerySnapshot
	Occurrence string
}

type HierarchyStore added in v0.6.1

type HierarchyStore interface {
	AnalysisStore
	CountHierarchyChildren(context.Context, HierarchyCountQuery) (HierarchyCount, error)
}

type Limits

type Limits struct {
	MaxDuration                               time.Duration
	PerCategory, DefaultImpactDepth, MaxDepth int
	DefaultTraceDepth, MaxTraceDepth, MaxRows int
	MaxNodes, MaxEdges, MaxFanout             int
}

type MissingGenerationError added in v0.10.0

type MissingGenerationError struct{ Commit string }

MissingGenerationError is ErrGraphMissing with the indexed commit that has no generation, so transports can name it without parsing error text.

func (*MissingGenerationError) Error added in v0.10.0

func (e *MissingGenerationError) Error() string

func (*MissingGenerationError) Is added in v0.10.0

func (e *MissingGenerationError) Is(target error) bool

type Neighbor

type Neighbor struct {
	Symbol graphprotocol.Symbol
	Parent SymbolRef
	Edge   graphprotocol.Relationship
}

type NeighborQuery

type NeighborQuery struct {
	Snapshots     []QuerySnapshot
	Frontier      []SymbolRef
	Relation      string
	Direction     string
	MinConfidence float64
	Offset, Limit int
}

type QuerySnapshot

type QuerySnapshot struct {
	RepositoryID int64
	UploadID     int64
	Commit       string
}

type SegmentSearch

type SegmentSearch struct {
	Snapshots       []QuerySnapshot
	Variants, Words []string
	Limit           int
}

type SegmentStore

type SegmentStore interface {
	QuerySegments(context.Context, SegmentSearch) ([]graphprotocol.SegmentMatch, error)
}

type Service

type Service struct {
	Store  Store
	Limits Limits
}

func (*Service) AffectedTests

func (*Service) AmbiguousReferencedNames

func (service *Service) AmbiguousReferencedNames(ctx context.Context, request graphprotocol.AggregateValuesRequest) (graphprotocol.AggregateNamesResponse, error)

func (*Service) CallGraph

func (*Service) CircularDependencies

func (*Service) Context

func (*Service) Discover

func (*Service) Entities

func (*Service) ExportedSymbols

func (service *Service) ExportedSymbols(ctx context.Context, request graphprotocol.FileEntityRequest) (graphprotocol.EntitiesResponse, error)

func (*Service) FileDependencies

func (*Service) FileDependencyPairs

func (*Service) FileDependentCounts

func (*Service) FileDependents

func (*Service) FileNodes

func (*Service) FileReachCounts

func (*Service) FilteredSubgraph

func (*Service) FindByQualifiedName

func (service *Service) FindByQualifiedName(ctx context.Context, request graphprotocol.QualifiedNameRequest) (graphprotocol.EntitiesResponse, error)

func (*Service) GraphStats

func (service *Service) GraphStats(ctx context.Context, scope graphprotocol.Scope) (graphprotocol.GraphStatsResponse, error)

func (*Service) Health

func (service *Service) Health(ctx context.Context) error

func (*Service) Impact

func (*Service) ImpactRadius

func (*Service) IndexedFiles

func (*Service) LanguagesWithExports

func (*Service) ModuleStructure

func (service *Service) ModuleStructure(ctx context.Context, request graphprotocol.ScopeRequest) (graphprotocol.ModuleStructureResponse, error)

func (*Service) NodeMetrics

func (*Service) RelevantContext

RelevantContext composes bounded discovery and traversal in one immutable generation. It preserves edge occurrences even when their triples repeat.

func (*Service) SegmentMatches

func (*Service) SymbolCalls added in v0.7.0

SymbolCalls lists the callers (incoming) or callees (outgoing) of every definition of a name, one section per distinct definition. Each neighbor appears once, with the first edge that reached it; limit bounds each section (default 20, 1-100) and Truncated reports that more exist.

func (*Service) SymbolImpact added in v0.7.0

SymbolImpact merges each distinct definition's impact radius (default depth 2, 1-10): entities in first-reached order, edges once per source, target and kind.

func (*Service) TopCallingFiles

func (*Service) TopDependedOn

func (*Service) Trace

func (*Service) Traverse

Traverse visits entities once while retaining every bounded edge occurrence, including parallel edges, self edges and edges back into an already seen cycle. Edge endpoints always preserve the producer's original direction.

func (*Service) TypeHierarchy added in v0.6.1

func (*Service) TypeRelations added in v0.6.1

func (*Service) UnresolvedNamesAmong

func (*Service) Usages

func (*Service) ValidateContextSnapshots

func (service *Service) ValidateContextSnapshots(ctx context.Context, snapshots []graphprotocol.ContextSnapshot) error

ValidateContextSnapshots checks the actual legacy uploads captured before the Context query, including a replacement at the same indexed commit.

func (*Service) ValidateGenerations

func (service *Service) ValidateGenerations(ctx context.Context, scope graphprotocol.Scope, expected []graphprotocol.Generation) error

ValidateGenerations closes a composition after source I/O. The scope must still be authorized by the caller; generation IDs are public GitHub repository IDs.

type Store

type Store interface {
	Health(context.Context) error
	Manifests(context.Context) (map[int64]graphartifact.Manifest, error)
	Symbols(context.Context, SymbolQuery) ([]graphprotocol.Symbol, error)
	Neighbors(context.Context, NeighborQuery) ([]Neighbor, error)
}

type SymbolQuery

type SymbolQuery struct {
	Snapshots      []QuerySnapshot
	UID, Name      string
	FilePath, Kind string
	Limit          int
}

type SymbolRef

type SymbolRef struct {
	RepositoryID int64
	UID          string
}

Jump to

Keyboard shortcuts

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