Documentation
¶
Overview ¶
Package index stores embeddings for source-code chunks and answers nearest-neighbor queries via cosine similarity. The implementation is intentionally minimal (in-memory + gob on disk) to avoid pulling in a vector-DB dependency for what is currently an opt-in feature.
Index ¶
- func BuildFingerprints(root string, files []string) (map[string]string, error)
- func DiffFingerprints(prev, curr map[string]string) (added, modified, deleted []string)
- func LoadFingerprints(path string) (map[string]string, error)
- func SaveFingerprints(path string, fp map[string]string) error
- func SaveMeta(path string, m EmbedMeta) error
- type EmbedMeta
- type FileFingerprint
- type Hit
- type Index
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildFingerprints ¶
BuildFingerprints returns a path → sha256 map for the given repo-relative files. Files unreadable from root are skipped silently.
func DiffFingerprints ¶
DiffFingerprints classifies paths between two snapshots.
func LoadFingerprints ¶
LoadFingerprints reads a snapshot from path. A missing file returns an empty map without error so first-run callers can treat it uniformly.
func SaveFingerprints ¶
SaveFingerprints persists a snapshot to path (creating parent dirs as needed).
Types ¶
type EmbedMeta ¶
EmbedMeta identifies the embedding model that produced a persisted index. Vectors from different models (or dimensions) are not comparable.
func LoadMeta ¶
LoadMeta reads the metadata at path. ok is false when the file is missing or unreadable, meaning the originating model is unknown.
func MetaFor ¶
MetaFor describes emb. Embedders without a Name method are recorded as "unknown" and distinguished by dimension only.
func (EmbedMeta) Compatible ¶
Compatible reports whether vectors saved under m can be compared with vectors produced under cur. An unknown (zero) dimension on either side is not treated as a mismatch.
type FileFingerprint ¶
FileFingerprint is a single (path, sha256) entry. The SHA-256 is computed over the file's verbatim bytes.
type Index ¶
type Index interface {
Add(ctx context.Context, chunks []chunker.Chunk, paths []string) error
Remove(paths []string)
Search(ctx context.Context, query string, k int) ([]Hit, error)
Persist(path string) error
Load(path string) error
}
Index stores chunk embeddings and answers similarity queries.