sessiondb

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrReadOnlyRecordEvents reports a rejected event write against a read-only session database.
	ErrReadOnlyRecordEvents = errors.New("store: read-only session database cannot record events")
	// ErrReadOnlyRecordTokenUsage reports a rejected token-usage write against a read-only session database.
	ErrReadOnlyRecordTokenUsage = errors.New("store: read-only session database cannot record token usage")
)

Functions

This section is empty.

Types

type ReadOnlyOpenOption

type ReadOnlyOpenOption func(*readOnlyOpenConfig)

ReadOnlyOpenOption customizes read-only session database opening.

func WithReadOnlyOpenRetry

func WithReadOnlyOpenRetry(
	maxAttempts int,
	minRetryDelay time.Duration,
	maxRetryDelay time.Duration,
) ReadOnlyOpenOption

WithReadOnlyOpenRetry configures retry behavior for read-only session database opens.

type ReadOnlySessionDB

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

ReadOnlySessionDB opens an existing per-session events database for queries without creating, migrating, checkpointing, or otherwise mutating it.

func OpenSessionDBReadOnly

func OpenSessionDBReadOnly(
	ctx context.Context,
	sessionID string,
	path string,
	options ...ReadOnlyOpenOption,
) (*ReadOnlySessionDB, error)

OpenSessionDBReadOnly opens an existing per-session events database in SQLite read-only mode. It intentionally fails for missing paths instead of creating a fresh database during stale transcript/event reads.

func (*ReadOnlySessionDB) Close

func (s *ReadOnlySessionDB) Close(ctx context.Context) error

Close closes the read-only database handle without checkpointing.

func (*ReadOnlySessionDB) History

History returns ordered session events grouped by turn id.

func (*ReadOnlySessionDB) Query

func (s *ReadOnlySessionDB) Query(
	ctx context.Context,
	query store.EventQuery,
) (events []store.SessionEvent, err error)

Query returns events filtered by the supplied options.

func (*ReadOnlySessionDB) Record

func (*ReadOnlySessionDB) RecordTokenUsage

func (s *ReadOnlySessionDB) RecordTokenUsage(context.Context, store.TokenUsage) error

type SessionDB

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

SessionDB owns a per-session SQLite database and its dedicated writer loop.

func OpenSessionDB

func OpenSessionDB(ctx context.Context, sessionID string, path string) (*SessionDB, error)

OpenSessionDB opens or creates the per-session events database at path.

func (*SessionDB) Clear

func (s *SessionDB) Clear(ctx context.Context) error

Clear removes all persisted per-session runtime records while preserving the migrated database schema and the open writer. It is used by session reset flows before the recorder is exposed to any live session goroutine.

func (*SessionDB) Close

func (s *SessionDB) Close(ctx context.Context) error

Close drains queued writes, checkpoints the WAL, and closes the database.

func (*SessionDB) History

func (s *SessionDB) History(ctx context.Context, query store.EventQuery) ([]store.TurnHistory, error)

History returns ordered session events grouped by turn id.

func (*SessionDB) Path

func (s *SessionDB) Path() string

Path reports the on-disk path for the database file.

func (*SessionDB) Query

func (s *SessionDB) Query(ctx context.Context, query store.EventQuery) ([]store.SessionEvent, error)

Query returns events filtered by the supplied options.

func (*SessionDB) QueryHookRuns

func (s *SessionDB) QueryHookRuns(ctx context.Context, query store.HookRunQuery) ([]hookspkg.HookRunRecord, error)

QueryHookRuns returns persisted hook execution records filtered by the supplied options.

func (*SessionDB) Record

func (s *SessionDB) Record(ctx context.Context, event store.SessionEvent) error

Record appends a session event using the dedicated writer goroutine.

func (*SessionDB) RecordHookRun

func (s *SessionDB) RecordHookRun(ctx context.Context, record hookspkg.HookRunRecord) error

RecordHookRun stores one hook execution audit record in the per-session store.

func (*SessionDB) RecordPersisted

func (s *SessionDB) RecordPersisted(ctx context.Context, event store.SessionEvent) (store.SessionEvent, error)

RecordPersisted appends a session event and returns the stored row with sequence metadata.

func (*SessionDB) RecordTokenUsage

func (s *SessionDB) RecordTokenUsage(ctx context.Context, usage store.TokenUsage) error

RecordTokenUsage stores or merges per-turn usage data for the session.

func (*SessionDB) SessionID

func (s *SessionDB) SessionID() string

SessionID reports the owning session identifier for the database.

Jump to

Keyboard shortcuts

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