Help us shape the future of Go! Take the 2026 Go Developer Survey

query

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteMetricsSnapshot added in v1.4.0

func WriteMetricsSnapshot(metrics SearchMetrics) (string, error)

WriteMetricsSnapshot persists one retrieval comparison under ~/.vela/retrieval-history.

Types

type ComparisonMetrics added in v1.4.0

type ComparisonMetrics struct {
	OverlapAtK       int            `json:"overlap_at_k"`
	OverlapRatio     float64        `json:"overlap_ratio"`
	AddedByFederated int            `json:"added_by_federated"`
	AddedBySource    map[string]int `json:"added_by_source"`
	AncoraLatencyGap int64          `json:"ancora_latency_gap_ms"`
	GraphLatencyMs   int64          `json:"graph_latency_ms"`
}

ComparisonMetrics highlights what federated retrieval changed vs the Ancora baseline.

type Engine

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

Engine wraps a loaded graph and answers queries against it.

func LoadFromFile

func LoadFromFile(graphPath string) (*Engine, error)

LoadFromFile reads graph.json and constructs a query Engine.

func (*Engine) Bindings added in v1.4.0

func (e *Engine) Bindings(label string) string

Bindings returns queryable memory reference binder state for the given node.

func (*Engine) Explain

func (e *Engine) Explain(label string) string

Explain returns all edges where the given node is source or target.

func (*Engine) FindNode added in v1.5.0

func (e *Engine) FindNode(term string) (types.Node, bool)

FindNode resolves a node by ID, exact label, or fuzzy label match.

func (*Engine) Graph

func (e *Engine) Graph() *types.Graph

Graph returns the underlying types.Graph (read-only reference).

func (*Engine) Neighbors added in v1.5.0

func (e *Engine) Neighbors(label string) ([]Neighbor, error)

Neighbors returns all incoming and outgoing edges for the given node.

func (*Engine) NodeByID

func (e *Engine) NodeByID(id string) (types.Node, bool)

NodeByID returns the node with the given ID string, if it exists.

func (*Engine) Path

func (e *Engine) Path(fromLabel, toLabel string) string

Path finds the shortest directed path from nodeA to nodeB. Returns a human-readable string.

func (*Engine) Query

func (e *Engine) Query(input string) string

Query is a freeform dispatcher: parses "path A B", "explain X", etc.

func (*Engine) Route added in v1.4.0

func (e *Engine) Route(input string) string

Route reports workspace-layer repo routing for a query.

func (*Engine) Search added in v1.5.0

func (e *Engine) Search(term string, limit int) []types.Node

Search performs a small lexical ranking over node fields.

func (*Engine) Stats added in v1.5.0

func (e *Engine) Stats() GraphStats

Stats returns a structured graph summary.

type GraphStats added in v1.5.0

type GraphStats struct {
	NodeCount       int
	EdgeCount       int
	CommunityCount  int
	NodeTypes       map[string]int
	ConfidenceTypes map[string]int
}

GraphStats summarizes the graph contents for diagnostics and MCP output.

type Neighbor added in v1.5.0

type Neighbor struct {
	Node      types.Node
	Edge      types.Edge
	Direction string
}

Neighbor describes a directly connected node and the edge relating it.

type SearchHit added in v1.4.0

type SearchHit struct {
	ID                 string             `json:"id"`
	CanonicalID        string             `json:"canonical_id,omitempty"`
	Label              string             `json:"label"`
	Kind               string             `json:"kind,omitempty"`
	Path               string             `json:"path,omitempty"`
	Snippet            string             `json:"snippet,omitempty"`
	Support            []string           `json:"support,omitempty"`
	SupportGraph       *SupportGraph      `json:"support_graph,omitempty"`
	Score              float64            `json:"score"`
	PrimarySource      string             `json:"primary_source"`
	PrimaryLayer       string             `json:"primary_layer,omitempty"`
	Sources            []string           `json:"sources"`
	Layers             []string           `json:"layers,omitempty"`
	Contributions      map[string]float64 `json:"contributions,omitempty"`
	Signals            map[string]float64 `json:"signals,omitempty"`
	LayerContributions map[string]float64 `json:"layer_contributions,omitempty"`
	Provenance         []SearchProvenance `json:"provenance,omitempty"`
}

SearchHit is a ranked retrieval result.

type SearchMetrics added in v1.4.0

type SearchMetrics struct {
	GeneratedAt   string            `json:"generated_at"`
	Query         string            `json:"query"`
	Limit         int               `json:"limit"`
	AncoraOnly    StrategyMetrics   `json:"ancora_only"`
	Federated     StrategyMetrics   `json:"federated"`
	Comparison    ComparisonMetrics `json:"comparison"`
	VectorRuntime *VectorRuntime    `json:"vector_runtime,omitempty"`
}

SearchMetrics records the baseline and federated retrieval comparison for one query.

type SearchProfile added in v1.4.0

type SearchProfile string

SearchProfile selects which retrieval stack to run.

const (
	SearchProfileFederated   SearchProfile = "federated"
	SearchProfileAncora      SearchProfile = "ancora"
	SearchProfileGraph       SearchProfile = "graph"
	SearchProfileGraphHybrid SearchProfile = "graph-hybrid"
	SearchProfileLexical     SearchProfile = "lexical"
	SearchProfileStructural  SearchProfile = "structural"
	SearchProfileVector      SearchProfile = "vector"
)

type SearchProvenance added in v1.4.0

type SearchProvenance struct {
	Layer   string   `json:"layer"`
	Source  string   `json:"source,omitempty"`
	Signal  string   `json:"signal,omitempty"`
	Repo    string   `json:"repo,omitempty"`
	Reasons []string `json:"reasons,omitempty"`
}

type SearchResponse added in v1.4.0

type SearchResponse struct {
	Query   string        `json:"query"`
	Hits    []SearchHit   `json:"hits"`
	Routing SearchRouting `json:"routing,omitempty"`
	Metrics SearchMetrics `json:"metrics"`
}

SearchResponse is the federated result set plus comparison metrics.

type SearchRoute added in v1.4.0

type SearchRoute struct {
	Repo    string   `json:"repo"`
	Score   float64  `json:"score"`
	Reasons []string `json:"reasons,omitempty"`
}

type SearchRouting added in v1.4.0

type SearchRouting struct {
	Tokens      []string      `json:"tokens,omitempty"`
	RoutedRepos []SearchRoute `json:"routed_repos,omitempty"`
	Fallback    bool          `json:"fallback"`
}

type SearchRun added in v1.4.0

type SearchRun struct {
	Profile SearchProfile   `json:"profile"`
	Query   string          `json:"query"`
	Hits    []SearchHit     `json:"hits"`
	Metrics StrategyMetrics `json:"metrics"`
}

SearchRun is one retrieval execution for a selected profile.

type Searcher added in v1.4.0

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

Searcher runs Ancora-only and federated retrieval against the current graph.

func NewSearcher added in v1.4.0

func NewSearcher(engine *Engine, ancoraDBPath string) *Searcher

NewSearcher wires a graph engine with an optional Ancora DB path.

func (*Searcher) RunProfile added in v1.4.0

func (s *Searcher) RunProfile(input string, limit int, profile SearchProfile) (SearchRun, error)

RunProfile runs one selected retrieval stack for evaluation/benchmarking.

func (*Searcher) Search added in v1.4.0

func (s *Searcher) Search(input string, limit int) (SearchResponse, error)

Search returns federated results and baseline comparison metrics.

func (*Searcher) WithTraversal added in v1.4.0

func (s *Searcher) WithTraversal(opts retrieval.TraversalOptions) *Searcher

WithTraversal updates graph traversal controls for graph-side search.

type StrategyMetrics added in v1.4.0

type StrategyMetrics struct {
	LatencyMs          int64          `json:"latency_ms"`
	Candidates         int            `json:"candidates"`
	Returned           int            `json:"returned"`
	SourceContribution map[string]int `json:"source_contribution"`
	SignalContribution map[string]int `json:"signal_contribution,omitempty"`
	RankingComposition []string       `json:"ranking_composition"`
	DistinctKinds      int            `json:"distinct_kinds"`
	HybridResults      int            `json:"hybrid_results,omitempty"`
}

StrategyMetrics captures signals that matter when comparing retrieval modes.

type SupportEdge added in v1.4.0

type SupportEdge struct {
	FromID         string `json:"from_id"`
	ToID           string `json:"to_id"`
	Relation       string `json:"relation"`
	Direction      string `json:"direction,omitempty"`
	Hop            int    `json:"hop,omitempty"`
	EvidenceType   string `json:"evidence_type,omitempty"`
	SourceArtifact string `json:"source_artifact,omitempty"`
	Confidence     string `json:"confidence,omitempty"`
	Verification   string `json:"verification,omitempty"`
}

SupportEdge is one supporting edge in a result subgraph.

type SupportGraph added in v1.4.0

type SupportGraph struct {
	Nodes []SupportNode `json:"nodes,omitempty"`
	Edges []SupportEdge `json:"edges,omitempty"`
}

SupportGraph is a compact structured subgraph attached to a hit.

type SupportNode added in v1.4.0

type SupportNode struct {
	ID    string `json:"id"`
	Label string `json:"label"`
	Kind  string `json:"kind,omitempty"`
	Path  string `json:"path,omitempty"`
}

SupportNode is one supporting node in a result subgraph.

type VectorRuntime added in v1.4.0

type VectorRuntime struct {
	Provider         string `json:"provider,omitempty"`
	Model            string `json:"model,omitempty"`
	SearchMode       string `json:"search_mode,omitempty"`
	IndexBackend     string `json:"index_backend,omitempty"`
	RequestedBackend string `json:"requested_backend,omitempty"`
	SQLiteVecEnabled bool   `json:"sqlite_vec_enabled,omitempty"`
	SQLiteVecReason  string `json:"sqlite_vec_reason,omitempty"`
	EmbeddingDims    int    `json:"embedding_dims,omitempty"`
}

Jump to

Keyboard shortcuts

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