store

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package store defines the persistence interface for mneme facts and ships a pure-Go SQLite implementation (store/sqlite). The interface is deliberately small so a future sqlite-vec or pgvector backend can drop in without touching the pipeline.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("mneme: fact not found")

ErrNotFound is returned by Get when no record has the requested id.

Functions

func Cosine

func Cosine(a, b []float32) float32

Cosine returns the cosine similarity of two equal-length float32 vectors. It returns 0 when either vector is zero-length, has a zero magnitude, or the lengths differ — callers treat 0 as "no similarity" rather than an error.

Types

type Store

type Store interface {
	// Insert writes records. It is the caller's job to have deduped first.
	Insert(ctx context.Context, recs []types.Record) error

	// Search returns up to k records in the given scope ranked by cosine
	// similarity to vec, highest first.
	Search(ctx context.Context, scope types.Scope, vec []float32, k int) ([]types.Hit, error)

	// Get returns one record by id.
	Get(ctx context.Context, id string) (types.Record, error)

	// Delete removes one record by id. Deleting a missing id is not an error.
	Delete(ctx context.Context, id string) error

	// ExistingHashes returns the set of fact hashes already stored in scope,
	// used by the pipeline to dedup before insert.
	ExistingHashes(ctx context.Context, scope types.Scope) (map[string]struct{}, error)

	// Close releases resources (e.g. the DB handle).
	Close() error
}

Store persists facts and answers scoped vector searches.

Directories

Path Synopsis
Package sqlite is the pure-Go (modernc.org/sqlite, no cgo) default Store for mneme.
Package sqlite is the pure-Go (modernc.org/sqlite, no cgo) default Store for mneme.

Jump to

Keyboard shortcuts

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