sqlite

package module
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package sqlite is an agentmemory.Store over one SQLite database file with full-text search. It is a nested module so the driver (modernc.org/sqlite, pure Go) stays out of the root module's dependency graph. Entries are rows of memory_entries, the journal is memory_journal, whose line column holds the same JSON record filestore's journal.jsonl would, so a database can be dumped to that file without conversion, and Search runs over memory_entries_fts, an FTS5 index of each entry's name, meta and content, ranked by relevance. Every table is prefixed memory_, so the file can be shared with other stores, such as agentsession's.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Store)

Option configures Open.

func WithClock

func WithClock(now func() time.Time) Option

WithClock sets the clock that stamps Updated and At, for tests that want a fixed one.

func WithMaxEntryBytes

func WithMaxEntryBytes(n int) Option

WithMaxEntryBytes sets the content bound; the default is agentmemory.DefaultMaxEntryBytes.

type Store

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

Store is a SQLite-backed agentmemory.Store. It is safe for concurrent use within one process, and several processes may share the file: every write is one immediate transaction, so writers queue on the database's own lock.

func Open

func Open(path string, opts ...Option) (*Store, error)

Open opens or creates the database at path and applies the schema. Every connection runs in WAL mode with a busy timeout, and writes go through a single-connection pool so writers queue instead of failing.

func (*Store) Close

func (s *Store) Close() error

Close runs PRAGMA optimize and closes both pools.

func (*Store) Forget

func (s *Store) Forget(ctx context.Context, scope agentmemory.Scope, name string) (*agentmemory.Change, error)

Forget implements agentmemory.Store.

func (*Store) Get

func (s *Store) Get(ctx context.Context, scope agentmemory.Scope, name string) (*agentmemory.Entry, error)

Get implements agentmemory.Store.

func (*Store) Journal

func (s *Store) Journal(ctx context.Context, after uint64) iter.Seq2[agentmemory.Change, error]

Journal implements agentmemory.Store.

func (*Store) List

func (s *Store) List(ctx context.Context, scope agentmemory.Scope) ([]agentmemory.Entry, error)

List implements agentmemory.Store.

func (*Store) MaxEntryBytes

func (s *Store) MaxEntryBytes() int

MaxEntryBytes implements agentmemory.Store.

func (*Store) Path

func (s *Store) Path() string

Path returns the database file.

func (*Store) Put

Put implements agentmemory.Store: one immediate transaction reads the stored entry, checks the bound and the precondition against it, writes the row, refreshes the search index and appends the journal record with the next sequence number.

func (*Store) Search

func (s *Store) Search(ctx context.Context, scopes []agentmemory.Scope, query string, limit int) ([]agentmemory.Entry, error)

Search implements agentmemory.Store over the FTS5 index: every word of the query must match a token of the entry's name, meta or content, as a prefix and ignoring case, and results come in relevance order. An empty query lists the scopes' entries in scope order then name.

Jump to

Keyboard shortcuts

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