sqlite

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package sqlite implements SQLite session persistence and FTS5 indexing (S03), following upstream storage/sqlite-session. session_events stores JSON blobs keyed by (session_id, seq); session_events_fts indexes message and title text for S04 queries. Append and AppendBatch update both tables transactionally. User/assistant Content and session Title supply index text; other events contribute empty text.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Match

type Match struct {
	SessionID string `json:"sessionId"`
	Seq       uint64 `json:"seq"`
	Text      string `json:"text,omitempty"`
}

Match identifies a session, sequence, and matched text; results sort by session ID.

type Store

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

Store persists session events in SQLite with an FTS5 index.

func Open

func Open(path string) (*Store, error)

Open opens or creates the database and initializes tables and FTS5.

func (*Store) Append

func (s *Store) Append(ctx context.Context, sessionID brand.SessionID, ev session.SessionEvent) error

Append inserts an event and its index entry in one transaction.

func (*Store) AppendBatch

func (s *Store) AppendBatch(ctx context.Context, sessionID brand.SessionID, events []session.SessionEvent) error

AppendBatch atomically inserts multiple events in one transaction.

func (*Store) Close

func (s *Store) Close() error

Close closes the database connection.

func (*Store) Count

func (s *Store) Count(ctx context.Context, sessionID brand.SessionID) (int, error)

Count returns the session's event count.

func (*Store) FTSEnabled

func (s *Store) FTSEnabled() bool

FTSEnabled reports FTS5 availability for callers and tests.

func (*Store) FTSUnavailable

func (s *Store) FTSUnavailable() bool

FTSUnavailable indicates the current driver does not support FTS5.

func (*Store) ListSessions

func (s *Store) ListSessions(ctx context.Context) ([]string, error)

ListSessions returns known session IDs in deterministic lexical order for queries.

func (*Store) Load

func (s *Store) Load(ctx context.Context, sessionID brand.SessionID) ([]session.SessionEvent, error)

Load returns session events in ascending sequence order.

func (*Store) Search

func (s *Store) Search(ctx context.Context, query string) ([]Match, error)

Search uses FTS5 and returns matching session/sequence pairs. Trigram queries require at least three runes; shorter queries or unavailable FTS5 fall back to LIKE without an inverted index.

Jump to

Keyboard shortcuts

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