Documentation
¶
Overview ¶
Package sqlite provides utility functions for SQLite database operations such as online backup and integrity verification.
Index ¶
- func Backup(dbPath string) (backupPath string, err error)
- func VerifyBackup(backupPath string) error
- type GraphMemoryOption
- type GraphMemoryStore
- func (s *GraphMemoryStore) Close() error
- func (s *GraphMemoryStore) Consolidate(ctx context.Context, memoryIDs []string, consolidated *memory.Memory) (*memory.Memory, error)
- func (s *GraphMemoryStore) ContextFor(ctx context.Context, opts memory.ContextForOpts) (*memory.EntityRecall, error)
- func (s *GraphMemoryStore) CreateEntity(ctx context.Context, entity *memory.Entity) (*memory.Entity, error)
- func (s *GraphMemoryStore) DecayAll(ctx context.Context, agentID string, decayFactor float64) error
- func (s *GraphMemoryStore) DeleteEntity(ctx context.Context, agentID, name string) error
- func (s *GraphMemoryStore) Forget(ctx context.Context, memoryID string) error
- func (s *GraphMemoryStore) GetEntity(ctx context.Context, agentID, name string) (*memory.Entity, error)
- func (s *GraphMemoryStore) GetLineage(ctx context.Context, memoryID string) ([]*memory.MemoryLineage, error)
- func (s *GraphMemoryStore) GetMemory(ctx context.Context, agentID, memoryID string) (*memory.Memory, error)
- func (s *GraphMemoryStore) GetStats(ctx context.Context, agentID string) (*memory.GraphStats, error)
- func (s *GraphMemoryStore) ListEdgesFrom(ctx context.Context, entityID string) ([]*memory.Edge, error)
- func (s *GraphMemoryStore) ListEdgesTo(ctx context.Context, entityID string) ([]*memory.Edge, error)
- func (s *GraphMemoryStore) ListEntities(ctx context.Context, agentID, entityType string, limit, offset int) ([]*memory.Entity, int, error)
- func (s *GraphMemoryStore) Neighbors(ctx context.Context, entityID string, relation string, direction string, ...) ([]*memory.Edge, error)
- func (s *GraphMemoryStore) Recall(ctx context.Context, opts memory.RecallOpts) ([]*memory.Memory, error)
- func (s *GraphMemoryStore) Relate(ctx context.Context, edge *memory.Edge) (*memory.Edge, error)
- func (s *GraphMemoryStore) Remember(ctx context.Context, mem *memory.Memory) (*memory.Memory, error)
- func (s *GraphMemoryStore) SearchEntities(ctx context.Context, agentID, query string, limit int) ([]*memory.Entity, error)
- func (s *GraphMemoryStore) Supersede(ctx context.Context, oldMemoryID string, newMem *memory.Memory) (*memory.Memory, error)
- func (s *GraphMemoryStore) TouchMemories(ctx context.Context, memoryIDs []string) error
- func (s *GraphMemoryStore) Unrelate(ctx context.Context, sourceID, targetID, relation string) error
- func (s *GraphMemoryStore) UpdateEntity(ctx context.Context, entity *memory.Entity) (*memory.Entity, error)
- func (s *GraphMemoryStore) VectorRecall(ctx context.Context, opts memory.VectorRecallOpts) ([]*memory.Memory, error)
- type Migration
- type Migrator
- type TaskStore
- func (s *TaskStore) AddDependency(ctx context.Context, dep *task.TaskDependency) error
- func (s *TaskStore) ClaimTask(ctx context.Context, taskID, agentID, sessionID string) (*task.Task, error)
- func (s *TaskStore) Close() error
- func (s *TaskStore) CloseTask(ctx context.Context, taskID, reason string) (*task.Task, error)
- func (s *TaskStore) CreateBoard(ctx context.Context, board *task.TaskBoard) (*task.TaskBoard, error)
- func (s *TaskStore) CreateTask(ctx context.Context, t *task.Task) (*task.Task, error)
- func (s *TaskStore) DeleteTask(ctx context.Context, id string) error
- func (s *TaskStore) GetBlockedTasks(ctx context.Context, boardID string) ([]*task.Task, error)
- func (s *TaskStore) GetBoard(ctx context.Context, id string) (*task.TaskBoard, error)
- func (s *TaskStore) GetDependencies(ctx context.Context, taskID string) ([]*task.TaskDependency, error)
- func (s *TaskStore) GetDependents(ctx context.Context, taskID string) ([]*task.TaskDependency, error)
- func (s *TaskStore) GetHistory(ctx context.Context, taskID string) ([]*task.TaskHistoryEntry, error)
- func (s *TaskStore) GetReadyFront(ctx context.Context, boardID string, opts task.ReadyFrontOpts) ([]*task.Task, error)
- func (s *TaskStore) GetTask(ctx context.Context, id string) (*task.Task, error)
- func (s *TaskStore) GetTaskByIdempotencyKey(ctx context.Context, key string) (*task.Task, error)
- func (s *TaskStore) HasOpenSkillTasks(ctx context.Context, skillName, sessionID string) (bool, error)
- func (s *TaskStore) ListBoards(ctx context.Context) ([]*task.TaskBoard, error)
- func (s *TaskStore) ListBySkillRun(ctx context.Context, skillName, sessionID string) ([]*task.Task, error)
- func (s *TaskStore) ListTasks(ctx context.Context, opts task.ListTasksOpts) ([]*task.Task, int, error)
- func (s *TaskStore) RecordHistory(ctx context.Context, entry *task.TaskHistoryEntry) error
- func (s *TaskStore) ReleaseTask(ctx context.Context, taskID, sessionID string) (*task.Task, error)
- func (s *TaskStore) RemoveDependency(ctx context.Context, fromTaskID, toTaskID string) error
- func (s *TaskStore) TransitionTask(ctx context.Context, taskID string, newStatus loomv1.TaskStatus) (*task.Task, error)
- func (s *TaskStore) UpdateTask(ctx context.Context, t *task.Task, _ []string) (*task.Task, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Backup ¶
Backup creates a safe online backup of a SQLite database using VACUUM INTO. VACUUM INTO produces a clean, defragmented copy of the database while allowing concurrent reads on the source. The backup file is named with a timestamp suffix (e.g., "loom.db.backup.20260224T153000"). On failure, any partially written backup file is removed before returning.
func VerifyBackup ¶
VerifyBackup opens a SQLite database file and runs PRAGMA integrity_check to confirm the file is a valid, uncorrupted SQLite database.
Types ¶
type GraphMemoryOption ¶ added in v1.3.0
type GraphMemoryOption func(*GraphMemoryStore)
GraphMemoryOption configures a GraphMemoryStore.
func WithSalienceConfig ¶ added in v1.3.0
func WithSalienceConfig(cfg memory.SalienceConfig) GraphMemoryOption
WithSalienceConfig overrides the default salience configuration.
type GraphMemoryStore ¶ added in v1.3.0
type GraphMemoryStore struct {
// contains filtered or unexported fields
}
GraphMemoryStore implements memory.GraphMemoryStore for SQLite.
func NewGraphMemoryStore ¶ added in v1.3.0
func NewGraphMemoryStore(db *sql.DB, tc memory.TokenCounter, tracer observability.Tracer, opts ...GraphMemoryOption) *GraphMemoryStore
NewGraphMemoryStore creates a new SQLite-backed graph memory store.
func (*GraphMemoryStore) Close ¶ added in v1.3.0
func (s *GraphMemoryStore) Close() error
func (*GraphMemoryStore) Consolidate ¶ added in v1.3.0
func (*GraphMemoryStore) ContextFor ¶ added in v1.3.0
func (s *GraphMemoryStore) ContextFor(ctx context.Context, opts memory.ContextForOpts) (*memory.EntityRecall, error)
func (*GraphMemoryStore) CreateEntity ¶ added in v1.3.0
func (*GraphMemoryStore) DeleteEntity ¶ added in v1.3.0
func (s *GraphMemoryStore) DeleteEntity(ctx context.Context, agentID, name string) error
func (*GraphMemoryStore) Forget ¶ added in v1.3.0
func (s *GraphMemoryStore) Forget(ctx context.Context, memoryID string) error
func (*GraphMemoryStore) GetLineage ¶ added in v1.3.0
func (s *GraphMemoryStore) GetLineage(ctx context.Context, memoryID string) ([]*memory.MemoryLineage, error)
func (*GraphMemoryStore) GetStats ¶ added in v1.3.0
func (s *GraphMemoryStore) GetStats(ctx context.Context, agentID string) (*memory.GraphStats, error)
func (*GraphMemoryStore) ListEdgesFrom ¶ added in v1.3.0
func (*GraphMemoryStore) ListEdgesTo ¶ added in v1.3.0
func (*GraphMemoryStore) ListEntities ¶ added in v1.3.0
func (*GraphMemoryStore) Recall ¶ added in v1.3.0
func (s *GraphMemoryStore) Recall(ctx context.Context, opts memory.RecallOpts) ([]*memory.Memory, error)
func (*GraphMemoryStore) SearchEntities ¶ added in v1.3.0
func (*GraphMemoryStore) TouchMemories ¶ added in v1.3.0
func (s *GraphMemoryStore) TouchMemories(ctx context.Context, memoryIDs []string) error
func (*GraphMemoryStore) Unrelate ¶ added in v1.3.0
func (s *GraphMemoryStore) Unrelate(ctx context.Context, sourceID, targetID, relation string) error
func (*GraphMemoryStore) UpdateEntity ¶ added in v1.3.0
func (*GraphMemoryStore) VectorRecall ¶ added in v1.3.0
func (s *GraphMemoryStore) VectorRecall(ctx context.Context, opts memory.VectorRecallOpts) ([]*memory.Memory, error)
VectorRecall performs brute-force cosine similarity search over all memories with embeddings for the given agent. Returns memories sorted by similarity. This is O(n) and fine for <100K memories per agent. For larger scale, use PostgreSQL with pgvector HNSW index.
type Migrator ¶
type Migrator struct {
// contains filtered or unexported fields
}
Migrator manages SQLite schema migrations using embedded SQL files. Unlike the PostgreSQL migrator which uses advisory locks, this uses a sync.Mutex to prevent concurrent migration execution within the process.
func NewMigrator ¶
NewMigrator creates a new migrator with embedded SQL migrations. It sets PRAGMA busy_timeout = 5000 on the database to handle lock contention.
func (*Migrator) CurrentVersion ¶
CurrentVersion returns the highest applied migration version. Returns 0 if the schema_migrations table does not exist yet.
func (*Migrator) MigrateDown ¶
MigrateDown rolls back the specified number of migrations.
type TaskStore ¶ added in v1.3.0
type TaskStore struct {
// contains filtered or unexported fields
}
TaskStore implements task.TaskStore for SQLite.
func NewTaskStore ¶ added in v1.3.0
func NewTaskStore(db *sql.DB, tracer observability.Tracer) *TaskStore
NewTaskStore creates a new SQLite-backed task store.
func (*TaskStore) AddDependency ¶ added in v1.3.0
func (*TaskStore) CreateBoard ¶ added in v1.3.0
func (*TaskStore) CreateTask ¶ added in v1.3.0
func (*TaskStore) DeleteTask ¶ added in v1.3.0
func (*TaskStore) GetBlockedTasks ¶ added in v1.3.0
func (*TaskStore) GetDependencies ¶ added in v1.3.0
func (*TaskStore) GetDependents ¶ added in v1.3.0
func (*TaskStore) GetHistory ¶ added in v1.3.0
func (*TaskStore) GetReadyFront ¶ added in v1.3.0
func (*TaskStore) GetTaskByIdempotencyKey ¶ added in v1.3.0
GetTaskByIdempotencyKey returns the task that owns the given idempotency key, or (nil, nil) when no such task exists. Used by the skills task emitter to dedupe concurrent skill activations.
func (*TaskStore) HasOpenSkillTasks ¶ added in v1.3.0
func (s *TaskStore) HasOpenSkillTasks(ctx context.Context, skillName, sessionID string) (bool, error)
HasOpenSkillTasks returns true when any task with skill_idempotency_key matching skill:<name>|sess:<sess>|% is still in flight (status not DONE and not CANCELLED). Soft-deleted tasks are excluded.
func (*TaskStore) ListBoards ¶ added in v1.3.0
func (*TaskStore) ListBySkillRun ¶ added in v1.3.0
func (s *TaskStore) ListBySkillRun(ctx context.Context, skillName, sessionID string) ([]*task.Task, error)
ListBySkillRun returns every non-deleted task whose skill_idempotency_key matches skill:<name>|sess:<sess>|%, regardless of status. Used by the end-of-turn hygiene auditor to inventory the active skill's tasks.