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 ¶
- type Option
- type Store
- func (s *Store) Close() error
- func (s *Store) Forget(ctx context.Context, scope agentmemory.Scope, name string) (*agentmemory.Change, error)
- func (s *Store) Get(ctx context.Context, scope agentmemory.Scope, name string) (*agentmemory.Entry, error)
- func (s *Store) Journal(ctx context.Context, after uint64) iter.Seq2[agentmemory.Change, error]
- func (s *Store) List(ctx context.Context, scope agentmemory.Scope) ([]agentmemory.Entry, error)
- func (s *Store) MaxEntryBytes() int
- func (s *Store) Path() string
- func (s *Store) Put(ctx context.Context, e agentmemory.Entry, opts ...agentmemory.PutOption) (*agentmemory.Change, error)
- func (s *Store) Search(ctx context.Context, scopes []agentmemory.Scope, query string, limit int) ([]agentmemory.Entry, error)
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 ¶
WithClock sets the clock that stamps Updated and At, for tests that want a fixed one.
func WithMaxEntryBytes ¶
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 ¶
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) 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) List ¶
func (s *Store) List(ctx context.Context, scope agentmemory.Scope) ([]agentmemory.Entry, error)
List implements agentmemory.Store.
func (*Store) MaxEntryBytes ¶
MaxEntryBytes implements agentmemory.Store.
func (*Store) Put ¶
func (s *Store) Put(ctx context.Context, e agentmemory.Entry, opts ...agentmemory.PutOption) (*agentmemory.Change, error)
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.