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

retrieval

package
v1.5.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: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DBPath

func DBPath(outDir string) string

DBPath returns the canonical retrieval DB path for an output directory.

func EnsureGraphSync

func EnsureGraphSync(graphPath string, graph *types.Graph) (string, error)

EnsureGraphSync refreshes the retrieval substrate when graph.json is newer or the SQLite DB does not exist yet.

func SetEmbedTextsForTesting

func SetEmbedTextsForTesting(fn func([]string) ([][]float32, error)) func()

SetEmbedTextsForTesting overrides embedding generation inside tests.

func SyncGraph

func SyncGraph(graph *types.Graph, dbPath string) error

SyncGraph materializes the graph into SQLite for lexical retrieval.

Types

type EdgeContext

type EdgeContext struct {
	FromID    string
	FromLabel string
	ToID      string
	ToLabel   string
	Relation  string
	Direction string
	Hop       int
}

EdgeContext is compact support for why a structural result was included.

type EmbeddingRuntime

type EmbeddingRuntime struct {
	Provider               string
	Model                  string
	Endpoint               string
	VectorSearchMode       string
	VectorIndex            string
	RequestedVectorBackend string
	SQLiteVecPath          string
	SQLiteVecEnabled       bool
	SQLiteVecReason        string
}

EmbeddingRuntime captures runtime/provenance for persisted vectors.

func CurrentEmbeddingRuntime

func CurrentEmbeddingRuntime() (EmbeddingRuntime, error)

type Metadata

type Metadata struct {
	EmbeddingProvider      string
	EmbeddingModel         string
	EmbeddingEndpoint      string
	VectorSearchMode       string
	VectorIndex            string
	RequestedVectorBackend string
	SQLiteVecPath          string
	SQLiteVecEnabled       bool
	SQLiteVecReason        string
	EmbeddingDims          int
}

Metadata records retrieval substrate provenance and vector runtime details.

func LoadMetadata

func LoadMetadata(dbPath string) (Metadata, error)

type Result

type Result struct {
	ID           string
	Label        string
	Kind         string
	Path         string
	Description  string
	MetadataText string
	SourceType   string
	SourceName   string
	SourcePath   string
	SourceRemote string
	Score        float64
}

Result is one lexical hit returned from the SQLite substrate.

Source* fields carry the repo-local provenance of the underlying node so that retrieval remains repo-scoped and explainable. Fused results can use them to attribute evidence back to the originating repo without re-reading graph.json.

func SearchLexical

func SearchLexical(dbPath, input string, limit int) ([]Result, int, error)

SearchLexical runs FTS5 over the materialized graph nodes. It is a convenience wrapper that delegates to SearchLexicalWithOptions with default (unscoped) options.

func SearchLexicalWithOptions

func SearchLexicalWithOptions(dbPath, input string, opts SearchOptions) ([]Result, int, error)

SearchLexicalWithOptions runs FTS5 over the materialized graph nodes with an optional repo scope applied at the SQL layer. Repo scoping matches the stored source_name column so that retrieval stays repo-bounded.

func SearchVector

func SearchVector(dbPath, input string, limit int) ([]Result, int, error)

SearchVector runs local vector retrieval over stored node embeddings using default (unscoped) options.

func SearchVectorWithOptions

func SearchVectorWithOptions(dbPath, input string, opts SearchOptions) ([]Result, int, error)

SearchVectorWithOptions runs local vector retrieval with an optional repo scope applied to the stored node vectors. Embeddings are kept locally in SQLite and the repo filter ensures retrieval stays repo-scoped rather than querying a global deep index.

type SearchOptions

type SearchOptions struct {
	// Limit caps the number of returned hits. Zero falls back to a sensible
	// default (5) inside each search function.
	Limit int
	// Repo scopes the query to a single repo by matching the stored
	// source_name column. Empty means no repo filter.
	Repo string
	// SourceType scopes retrieval to one stored source type. Empty means no
	// source-type filter.
	SourceType string
}

SearchOptions narrows a repo-local retrieval query. The zero value runs an unscoped query, which matches the historical behavior of SearchLexical and SearchVector.

type StructuralResult

type StructuralResult struct {
	Result
	Context []EdgeContext
}

StructuralResult is one graph-structural candidate.

func ExpandStructural

func ExpandStructural(dbPath string, seeds []Result, opts TraversalOptions) ([]StructuralResult, int, error)

ExpandStructural walks the persisted graph outward from lexical seeds.

type TraversalOptions

type TraversalOptions struct {
	MaxHops          int
	MaxExpansions    int
	Limit            int
	AllowedRelations []string
}

TraversalOptions bounds structural graph expansion.

Jump to

Keyboard shortcuts

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