Documentation
¶
Overview ¶
Package sqlite provides SQLite-specific implementation for conversation storage. Schema definitions and constants for the conversation database.
Note: Actual schema migrations are defined in pkg/db/migrations/ and shared across all kodelet database components.
Package sqlite provides SQLite-specific implementation for conversation storage. It implements the ConversationStore interface using SQLite database with optimized WAL mode configuration, schema migrations, and efficient querying.
Index ¶
- type JSONField
- type Store
- func (s *Store) BindConversationRunnerAffinity(ctx context.Context, conversationID, runnerID, environmentProfile string) error
- func (s *Store) Close() error
- func (s *Store) ConversationRunnerAffinity(ctx context.Context, conversationID string) (string, string, bool, error)
- func (s *Store) Delete(ctx context.Context, id string) error
- func (s *Store) Load(ctx context.Context, id string) (conversations.ConversationRecord, error)
- func (s *Store) LoadMetadata(ctx context.Context, id string) (map[string]any, error)
- func (s *Store) LoadSearchSource(ctx context.Context, id string) (conversations.ConversationRecord, error)
- func (s *Store) PendingSearchIndex(ctx context.Context, version int) ([]conversations.SearchIndexCandidate, error)
- func (s *Store) PruneSearchIndex(ctx context.Context) (int, error)
- func (s *Store) Query(ctx context.Context, options conversations.QueryOptions) (conversations.QueryResult, error)
- func (s *Store) ReplaceSearchIndex(ctx context.Context, document conversations.SearchDocument) (bool, error)
- func (s *Store) Save(ctx context.Context, record conversations.ConversationRecord) error
- func (s *Store) SaveConversationFork(ctx context.Context, sourceConversationID string, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JSONField ¶
type JSONField[T any] struct { Data T }
JSONField is a generic type for handling JSON marshaling/unmarshaling in database
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store implements ConversationStore using SQLite database
func NewStore ¶
NewStore creates a new SQLite-based conversation store. Note: Migrations should be run via db.RunMigrations() at CLI startup before calling this.
func (*Store) BindConversationRunnerAffinity ¶
func (s *Store) BindConversationRunnerAffinity(ctx context.Context, conversationID, runnerID, environmentProfile string) error
BindConversationRunnerAffinity establishes authoritative affinity without moving an existing binding.
func (*Store) ConversationRunnerAffinity ¶
func (s *Store) ConversationRunnerAffinity(ctx context.Context, conversationID string) (string, string, bool, error)
ConversationRunnerAffinity returns the authoritative runner binding for a conversation.
func (*Store) Load ¶
func (s *Store) Load(ctx context.Context, id string) (conversations.ConversationRecord, error)
Load retrieves a conversation record by ID
func (*Store) LoadMetadata ¶
LoadMetadata retrieves only persisted metadata, without decoding message or tool history.
func (*Store) LoadSearchSource ¶
func (s *Store) LoadSearchSource(ctx context.Context, id string) (conversations.ConversationRecord, error)
LoadSearchSource loads the fields needed to build search entries, skipping usage and structured tool results, which dominate stored conversation size.
func (*Store) PendingSearchIndex ¶
func (s *Store) PendingSearchIndex(ctx context.Context, version int) ([]conversations.SearchIndexCandidate, error)
PendingSearchIndex returns conversations whose search entries are missing, stale, or built by another extraction version, most recently updated first. Dirtiness is derived from the database, so saves by any process are found.
func (*Store) PruneSearchIndex ¶
PruneSearchIndex removes search entries of conversations deleted without going through Store.Delete, such as by another process or an older binary.
func (*Store) Query ¶
func (s *Store) Query(ctx context.Context, options conversations.QueryOptions) (conversations.QueryResult, error)
Query performs advanced queries with filtering, sorting, and pagination. Search sees only indexed conversations; non-searchable terms match nothing.
func (*Store) ReplaceSearchIndex ¶
func (s *Store) ReplaceSearchIndex(ctx context.Context, document conversations.SearchDocument) (bool, error)
ReplaceSearchIndex atomically replaces one conversation's search entries. It reports false without writing when the conversation changed after the document was extracted, leaving it pending for the next pass. Unchanged content only advances the recorded source version.
func (*Store) Save ¶
func (s *Store) Save(ctx context.Context, record conversations.ConversationRecord) error
Save persists a conversation record to the database using UPSERT to preserve created_at timestamps
func (*Store) SaveConversationFork ¶
func (s *Store) SaveConversationFork(ctx context.Context, sourceConversationID string, forked conversations.ConversationRecord) error
SaveConversationFork atomically saves a fork and copies the source runner affinity.