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

store

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KindFunction  = "function"
	KindMethod    = "method"
	KindClass     = "class"
	KindInterface = "interface"
	KindType      = "type"
	KindConst     = "const"
	KindVar       = "var"

	EdgeCalls   = "calls"
	EdgeImports = "imports"
)
View Source
const CurrentIndexContentVersion = 3

Variables

View Source
var ErrNotFound = errors.New("store: not found")
View Source
var ErrReindexRequired = errors.New("store: reindex required")

Functions

This section is empty.

Types

type ChunkEmbedding

type ChunkEmbedding struct {
	ChunkID int64
	Vector  []float32
}

type Edge

type Edge struct {
	Src    int64
	Dst    int64
	Kind   string
	Weight float64
	// CallLine is the first AST-observed call site for calls edges. Other edge
	// kinds leave it zero.
	CallLine int
}

type Embedding

type Embedding struct {
	SymbolID int64
	Vector   []float32
}

type File

type File struct {
	ID       int64
	Path     string
	Language string
	Hash     string
	Mtime    int64
	Size     int64
}

type ScoredSymbol

type ScoredSymbol struct {
	Symbol
	Score float32
}

type Store

type Store interface {
	SaveFile(ctx context.Context, f *File) (int64, error)
	GetFileByPath(ctx context.Context, path string) (*File, error)
	DeleteFile(ctx context.Context, id int64) error
	ListFiles(ctx context.Context) ([]File, error)

	SaveSymbol(ctx context.Context, s *Symbol) (int64, error)
	SaveSymbolBatch(ctx context.Context, symbols []Symbol) ([]int64, error)
	DeleteSymbolsByFile(ctx context.Context, fileID int64) error
	ListSymbolsByFile(ctx context.Context, fileID int64) ([]Symbol, error)
	ListSymbolsByLanguage(ctx context.Context, language string) ([]Symbol, error)

	SaveEdge(ctx context.Context, e Edge) error
	SaveEdgeBatch(ctx context.Context, edges []Edge) error

	UpsertEmbedding(ctx context.Context, symbolID int64, vec []float32) error
	UpsertEmbeddingBatch(ctx context.Context, embeddings []Embedding) error
	SaveSymbolChunks(ctx context.Context, chunks []SymbolChunk) ([]int64, error)
	UpsertChunkEmbeddingBatch(ctx context.Context, embeddings []ChunkEmbedding) error
	GetEmbedding(ctx context.Context, symbolID int64) ([]float32, bool, error)

	SearchByVector(ctx context.Context, embedding []float32, topK int) ([]Symbol, error)
	GetEdges(ctx context.Context, symbolID int64) ([]Edge, error)

	SearchByVectorScored(ctx context.Context, vec []float32, k int) ([]ScoredSymbol, error)
	SearchByText(ctx context.Context, query string, k int) ([]ScoredSymbol, error)
	GetSymbolsByIDs(ctx context.Context, ids []int64) ([]Symbol, error)
	GetFilesByIDs(ctx context.Context, ids []int64) (map[int64]string, error)
	ListAllEdges(ctx context.Context) ([]Edge, error)
	ListAllSymbolIDs(ctx context.Context) ([]int64, error)
	ListSymbolMeta(ctx context.Context) ([]Symbol, error)
	GetEmbeddingsByIDs(ctx context.Context, ids []int64) (map[int64][]float32, error)
	GetCallerEdges(ctx context.Context, dstIDs []int64, limitPerSymbol int) (map[int64][]int64, error)
	GetCalleeEdges(ctx context.Context, srcIDs []int64, limitPerSymbol int) (map[int64][]int64, error)

	Close() error
}

type Symbol

type Symbol struct {
	ID            int64
	FileID        int64
	Name          string
	Kind          string
	QualifiedName string
	StartLine     int
	EndLine       int
	Signature     string
	Docstring     string
	BodyExcerpt   string
	// FullBody is populated only while indexing when BodyExcerpt is lossy.
	// SQLite stores it in a separate lazy table so retrieval never hydrates
	// large bodies unless expand_context explicitly requests one.
	FullBody string
}

type SymbolBody

type SymbolBody struct {
	SymbolID int64
	Body     string
	SHA256   string
}

type SymbolChunk

type SymbolChunk struct {
	ID       int64
	SymbolID int64
	// StartLine is the chunk's first line in the file, so a hit can point at
	// the code that matched rather than at the symbol's head.
	StartLine int
	Text      string
}

SymbolChunk is one embeddable window of a symbol whose stored excerpt is lossy. Only capped symbols get chunks: everything else is already fully represented by its own vector.

type SymbolToEmbed

type SymbolToEmbed struct {
	Symbol
	Path     string
	Language string
}

SymbolToEmbed is a symbol that has no stored embedding yet, joined with the file fields EmbeddingText needs. Produced by --fast (structure-only) indexing; consumed by the embedding backfill.

Directories

Path Synopsis
DECISION: using modernc.org/sqlite (pure-Go, no CGo) + modernc.org/sqlite/vec subpackage.
DECISION: using modernc.org/sqlite (pure-Go, no CGo) + modernc.org/sqlite/vec subpackage.

Jump to

Keyboard shortcuts

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