sqlite

package
v0.56.4 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DayJobs added in v0.56.0

type DayJobs struct {
	Store *Store
	Chat  string
}

DayJobs never reads raw result/error bodies into Telegram state. Ownership is established through the job, not through task payload text supplied by a client.

func (DayJobs) Change added in v0.56.0

Change rejects mutation of job projections.

func (DayJobs) Detail added in v0.56.0

func (d DayJobs) Detail(ctx context.Context, owner string, item dayview.Item) (dayview.Detail, error)

Detail rechecks job and task ownership before returning a private result.

func (DayJobs) List added in v0.56.0

func (d DayJobs) List(ctx context.Context, owner string, _ time.Time, _ *time.Location) ([]dayview.Item, error)

List lists jobs and execution summaries bound to the owned conversation.

func (DayJobs) Name added in v0.56.0

func (DayJobs) Name() string

Name returns the background-job source name.

type DayOperations added in v0.56.0

type DayOperations struct {
	Store *Store
	Chat  string
}

DayOperations exposes scoped uncertain-operation receipts as read-only day items.

func (DayOperations) Change added in v0.56.0

func (d DayOperations) Change(ctx context.Context, owner string, item dayview.Item, action string, _ time.Time) error

Change records explicit uncertainty acknowledgement without replaying a write.

func (DayOperations) List added in v0.56.0

func (d DayOperations) List(ctx context.Context, owner string, _ time.Time, _ *time.Location) ([]dayview.Item, error)

List lists scoped reconciliation receipts without exposing raw provider errors.

func (DayOperations) Name added in v0.56.0

func (DayOperations) Name() string

Name returns the uncertain-operation source name.

func (DayOperations) Verify added in v0.56.0

func (d DayOperations) Verify(ctx context.Context, owner string, item dayview.Item, action string, _ time.Time) (dayview.Verification, error)

Verify observes acknowledgement status without changing a receipt.

type EmbedFunc

type EmbedFunc func(ctx context.Context, texts []string) ([][]float32, error)

EmbedFunc generates embeddings for texts. Used as a callback to avoid import cycles.

type ReminderDaySource added in v0.56.0

type ReminderDaySource struct {
	Store *Store
	Chat  string
}

ReminderDaySource reads only the current owner's pending reminders in the current conversation.

func (ReminderDaySource) Change added in v0.56.0

func (d ReminderDaySource) Change(ctx context.Context, owner string, i dayview.Item, action string, due time.Time) error

Change conditionally acknowledges or reschedules an owned reminder.

func (ReminderDaySource) List added in v0.56.0

func (d ReminderDaySource) List(ctx context.Context, owner string, _ time.Time, _ *time.Location) ([]dayview.Item, error)

List lists owned reminders and their exact delivery-state capabilities.

func (ReminderDaySource) Name added in v0.56.0

func (ReminderDaySource) Name() string

Name returns the local reminder source name.

func (ReminderDaySource) Verify added in v0.56.0

func (d ReminderDaySource) Verify(ctx context.Context, owner string, item dayview.Item, action string, due time.Time) (dayview.Verification, error)

Verify observes the owned reminder only, with no requeue/reschedule writes.

type Store

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

Store implements storage.Repository using SQLite via bun.

func New

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

New creates a new SQLite store at the given file path.

func (*Store) ApplyDayVerification added in v0.56.0

func (s *Store) ApplyDayVerification(ctx context.Context, owner, id, expected string, v dayview.Verification) error

ApplyDayVerification records a read-only outcome if the receipt still has the expected status.

func (*Store) ApplyLocalTelegramTopicOperation added in v0.56.0

func (s *Store) ApplyLocalTelegramTopicOperation(ctx context.Context, op *domain.TelegramTopicOperation, state *domain.TelegramTopicState) error

ApplyLocalTelegramTopicOperation is a local application gate, not a Telegram forum close/reopen. State and durable result commit together, without any API call.

func (*Store) BackfillUserIDs

func (s *Store) BackfillUserIDs(ctx context.Context) (int64, error)

BackfillUserIDs sets user_id on facts, insights, tech_facts, and chat_messages that have an empty user_id, based on user_channels bindings. Matches on channel_id OR channel_user_id (Telegram stores chat_id as user_id in DMs).

func (*Store) BeginTelegramTopicDeletion added in v0.56.0

func (s *Store) BeginTelegramTopicDeletion(ctx context.Context, scope domain.TelegramTopicDeletionScope, source string) (out *domain.TelegramTopicDeletion, err error)

BeginTelegramTopicDeletion atomically fences an exact private route and cleans its bound local data.

func (*Store) BindChannel

func (s *Store) BindChannel(ctx context.Context, uc *domain.UserChannel) error

func (*Store) BindLegacyTelegramTopic added in v0.56.0

func (s *Store) BindLegacyTelegramTopic(ctx context.Context, scope domain.TelegramTopicDeletionScope) error

BindLegacyTelegramTopic is a one-way, explicitly approved provenance repair. Observing a new token or receiving a message never authorizes this method.

func (*Store) CancelPendingImportTask added in v0.37.0

func (s *Store) CancelPendingImportTask(ctx context.Context, uniqueKey string) (bool, error)

CancelPendingImportTask cancels a not-yet-started import task by its unique key, marking it failed so it is never claimed. Only pending tasks are cancelable this way; a claimed/running import must run to completion (its own heartbeat aborts it if the run is otherwise stopped). Returns canceled=false when no pending task matched (already running, done, or absent).

func (*Store) ClaimDayOperation added in v0.56.0

func (s *Store) ClaimDayOperation(ctx context.Context, o *dayview.Operation) (claimed bool, err error)

ClaimDayOperation claims a new approved intent while excluding unresolved resource operations.

func (*Store) ClaimReminderDelivery added in v0.56.0

func (s *Store) ClaimReminderDelivery(ctx context.Context, id int64, chat string, due time.Time) (*domain.Reminder, error)

ClaimReminderDelivery atomically excludes snooze/cancel from an in-flight send. A crash after this claim is uncertain, never blindly redelivered.

func (*Store) ClaimTask

func (s *Store) ClaimTask(ctx context.Context, workerID string, capabilities []string) (*domain.Task, error)

func (*Store) ClaimTelegramTopicDeletionNotice added in v0.56.0

func (s *Store) ClaimTelegramTopicDeletionNotice(ctx context.Context, scope domain.TelegramTopicDeletionScope) (bool, error)

ClaimTelegramTopicDeletionNotice claims at most one notice attempt for a finalized deletion.

func (*Store) ClaimTelegramTopicOperation added in v0.56.0

func (s *Store) ClaimTelegramTopicOperation(ctx context.Context, op *domain.TelegramTopicOperation) (*domain.TelegramTopicOperation, bool, error)

ClaimTelegramTopicOperation durably claims an intent without retrying an unresolved native operation.

func (*Store) ClaimTelegramTopicSeed added in v0.56.0

func (s *Store) ClaimTelegramTopicSeed(ctx context.Context, seed *domain.TelegramTopicSeed) (bool, error)

ClaimTelegramTopicSeed claims the non-idempotent creation stage for an incoming root message.

func (*Store) CleanupDayState added in v0.56.0

func (s *Store) CleanupDayState(ctx context.Context, now time.Time, batch int) error

CleanupDayState removes private projections but preserves compact operation tombstones. Cleanup never removes active reminder routes or retries writes.

func (*Store) CleanupStaleTasks

func (s *Store) CleanupStaleTasks(ctx context.Context, timeout time.Duration) (int, error)

func (*Store) ClearHistory

func (s *Store) ClearHistory(ctx context.Context, chatID string) error

func (*Store) Close

func (s *Store) Close() error

func (*Store) CompleteTask

func (s *Store) CompleteTask(ctx context.Context, taskID int64, result string) error

func (*Store) CompleteTodoItem

func (s *Store) CompleteTodoItem(ctx context.Context, id int64, userID string) error

CompleteTodoItem marks a todo item as completed.

func (*Store) ConversationUnavailable added in v0.56.0

func (s *Store) ConversationUnavailable(ctx context.Context, key string) (bool, error)

ConversationUnavailable reports terminal lifecycle state without requiring a route for ordinary chats.

func (*Store) CountAgentJobsByUser added in v0.36.0

func (s *Store) CountAgentJobsByUser(ctx context.Context, userID string) (int, error)

CountAgentJobsByUser returns how many jobs userID owns (for per-user caps).

func (*Store) CountFactsByUser added in v0.56.4

func (s *Store) CountFactsByUser(ctx context.Context, userID string) (int, error)

CountFactsByUser counts account memory without loading private fact contents. Unlike aggregate dashboard queries, this owner-only counter fails closed.

func (*Store) CountInsights

func (s *Store) CountInsights(ctx context.Context, chatID string) (int, error)

func (*Store) CountInsightsByUser

func (s *Store) CountInsightsByUser(ctx context.Context, userID string) (int, error)

func (*Store) CountMessages

func (s *Store) CountMessages(ctx context.Context, chatID string) (int, error)

func (*Store) CountTasksByStatus

func (s *Store) CountTasksByStatus(ctx context.Context) (map[domain.TaskStatus]int, error)

func (*Store) CountTechFacts

func (s *Store) CountTechFacts(ctx context.Context, chatID string) (int, error)

func (*Store) CountTechFactsByUser

func (s *Store) CountTechFactsByUser(ctx context.Context, userID string) (int, error)

func (*Store) CountTodoItemsByProvider

func (s *Store) CountTodoItemsByProvider(ctx context.Context, userID string) (map[string]int, error)

CountTodoItemsByProvider returns counts of incomplete items per provider for a user.

func (*Store) CreateAgentJob

func (s *Store) CreateAgentJob(ctx context.Context, j *domain.AgentJob) error

func (*Store) CreateChannelInstance

func (s *Store) CreateChannelInstance(ctx context.Context, ci *domain.ChannelInstance) error

func (*Store) CreateDayReminder added in v0.56.0

func (s *Store) CreateDayReminder(ctx context.Context, owner, conversation, title, zone string, due time.Time, operationID string) (id int64, created bool, err error)

CreateDayReminder commits an idempotency record and a single reminder in one transaction. Call this instead of the generic ClaimDayOperation path. The operationID is a server-created key bound to the confirmed exact command.

func (*Store) CreateReminder

func (s *Store) CreateReminder(ctx context.Context, r *domain.Reminder) error

func (*Store) CreateTask

func (s *Store) CreateTask(ctx context.Context, t *domain.Task) error

func (*Store) CreateTaskIfNotExists

func (s *Store) CreateTaskIfNotExists(ctx context.Context, t *domain.Task) (bool, error)

func (*Store) CreateTodoItem

func (s *Store) CreateTodoItem(ctx context.Context, item *domain.TodoItem) error

CreateTodoItem inserts a new todo item.

func (*Store) CreateUser

func (s *Store) CreateUser(ctx context.Context, u *domain.User) error

func (*Store) CreateVectorTables

func (s *Store) CreateVectorTables(ctx context.Context) error

CreateVectorTables creates tables for storing embeddings.

func (*Store) CurrentReminder added in v0.56.0

func (s *Store) CurrentReminder(ctx context.Context, id int64, chat string, due time.Time) (*domain.Reminder, error)

CurrentReminder rejects cancelled/rescheduled stale jobs before delivery.

func (*Store) DeleteAccountFact added in v0.50.0

func (s *Store) DeleteAccountFact(ctx context.Context, owner string, id int64) (bool, error)

DeleteAccountFact deletes exactly one owned saved fact, regardless of source.

func (*Store) DeleteAccountFactsByQuery added in v0.50.0

func (s *Store) DeleteAccountFactsByQuery(ctx context.Context, owner, query string) (int64, error)

DeleteAccountFactsByQuery retains the legacy FTS semantics within one owner. Empty/operator-only queries never become an unfiltered DELETE.

func (*Store) DeleteAgentJob

func (s *Store) DeleteAgentJob(ctx context.Context, id int64) error

func (*Store) DeleteChannelInstance

func (s *Store) DeleteChannelInstance(ctx context.Context, id string) error

func (*Store) DeleteConfigOverride

func (s *Store) DeleteConfigOverride(ctx context.Context, key string) error

func (*Store) DeleteCredential added in v0.29.1

func (s *Store) DeleteCredential(ctx context.Context, id int64) error

DeleteCredential removes a credential by ID.

func (*Store) DeleteCredentialBinding added in v0.29.1

func (s *Store) DeleteCredentialBinding(ctx context.Context, credentialID int64, consumerType, consumerID string) error

DeleteCredentialBinding removes a specific credential binding.

func (*Store) DeleteDirective

func (s *Store) DeleteDirective(ctx context.Context, chatID string) error

func (*Store) DeleteExpiredHTTPArtifacts added in v0.46.0

func (s *Store) DeleteExpiredHTTPArtifacts(ctx context.Context, before time.Time) ([]domain.HTTPArtifact, error)

DeleteExpiredHTTPArtifacts removes rows past their TTL and returns them so the caller can delete the files.

func (*Store) DeleteExpiredHTTPStandingGrants added in v0.47.0

func (s *Store) DeleteExpiredHTTPStandingGrants(ctx context.Context) error

DeleteExpiredHTTPStandingGrants removes dead rows (housekeeping).

func (*Store) DeleteExpiredInsights

func (s *Store) DeleteExpiredInsights(ctx context.Context) error

func (*Store) DeleteFact

func (s *Store) DeleteFact(ctx context.Context, id int64, chatID string) error

func (*Store) DeleteFactByID

func (s *Store) DeleteFactByID(ctx context.Context, id int64) error

func (*Store) DeleteFactsByQuery

func (s *Store) DeleteFactsByQuery(ctx context.Context, chatID, query string) (int, error)

func (*Store) DeleteGoogleAccount

func (s *Store) DeleteGoogleAccount(ctx context.Context, id int64) error

func (*Store) DeleteHTTPArtifact added in v0.46.0

func (s *Store) DeleteHTTPArtifact(ctx context.Context, id string) error

DeleteHTTPArtifact removes a row.

func (*Store) DeleteHTTPCredentialGrant added in v0.46.0

func (s *Store) DeleteHTTPCredentialGrant(ctx context.Context, id int64) error

DeleteHTTPCredentialGrant removes a grant by ID (ownership checked by caller).

func (*Store) DeleteInsight

func (s *Store) DeleteInsight(ctx context.Context, id int64, chatID string) error

func (*Store) DeleteInstalledSkill

func (s *Store) DeleteInstalledSkill(ctx context.Context, slug string) error

DeleteInstalledSkill removes an installed skill record by slug.

func (*Store) DeleteMCPRecord added in v0.55.0

func (s *Store) DeleteMCPRecord(ctx context.Context, owner, id string) error

DeleteMCPRecord removes expired encrypted artifacts without touching audit metadata.

func (*Store) DeleteMessagesBefore

func (s *Store) DeleteMessagesBefore(ctx context.Context, chatID string, beforeID int64) error

func (*Store) DeleteOldTasks

func (s *Store) DeleteOldTasks(ctx context.Context, olderThan time.Duration) (int, error)

func (*Store) DeleteReminder

func (s *Store) DeleteReminder(ctx context.Context, id int64, chatID string) error

func (*Store) DeleteSlackAccount added in v0.38.0

func (s *Store) DeleteSlackAccount(ctx context.Context, userID string) error

DeleteSlackAccount removes the owner's Slack account (disconnect).

func (*Store) DeleteSlackRoutesOlderThan added in v0.38.0

func (s *Store) DeleteSlackRoutesOlderThan(ctx context.Context, instanceID string, olderThan time.Time) (int64, error)

DeleteSlackRoutesOlderThan prunes stale routes for an instance whose last update predates olderThan, bounding table growth (thread-scoped chatIDs mint a row per thread). Returns the number of rows deleted.

func (*Store) DeleteSyncedTodoItemsNotIn

func (s *Store) DeleteSyncedTodoItemsNotIn(ctx context.Context, userID, provider string, keepExternalIDs []string) (int, error)

DeleteSyncedTodoItemsNotIn removes synced items for a provider/user that are not in the given external IDs set.

func (*Store) DeleteTodoItem

func (s *Store) DeleteTodoItem(ctx context.Context, id int64, userID string) error

DeleteTodoItem deletes a todo item by ID, scoped to user.

func (*Store) DeleteUser

func (s *Store) DeleteUser(ctx context.Context, id string) error

func (*Store) EnsureDaySchema added in v0.56.0

func (s *Store) EnsureDaySchema(ctx context.Context) error

EnsureDaySchema creates or upgrades the private-card and receipt schema.

func (*Store) EnsureTelegramTopics added in v0.56.0

func (s *Store) EnsureTelegramTopics(ctx context.Context) error

EnsureTelegramTopics creates and upgrades topic state, identity and receipt tables.

func (*Store) EvictOldEmbeddings

func (s *Store) EvictOldEmbeddings(ctx context.Context, maxEntries int) error

EvictOldEmbeddings removes the least recently accessed embeddings beyond maxEntries.

func (*Store) EvictResponseCache

func (s *Store) EvictResponseCache(ctx context.Context, maxEntries int) error

EvictResponseCache removes the least recently accessed entries beyond maxEntries.

func (*Store) FactsWithoutEmbeddings

func (s *Store) FactsWithoutEmbeddings(ctx context.Context, limit int) ([]domain.Fact, error)

FactsWithoutEmbeddings returns facts that don't have a vector embedding yet.

func (*Store) FailTask

func (s *Store) FailTask(ctx context.Context, taskID int64, errMsg string) error

func (*Store) FinalizeTelegramTopicDeletion added in v0.56.0

func (s *Store) FinalizeTelegramTopicDeletion(ctx context.Context, scope domain.TelegramTopicDeletionScope) (out *domain.TelegramTopicDeletion, err error)

FinalizeTelegramTopicDeletion records confirmed native deletion for the same durable scope.

func (*Store) FindTelegramTopicAlbum added in v0.56.0

func (s *Store) FindTelegramTopicAlbum(ctx context.Context, instance, owner string, chat int64, album string) (*domain.TelegramTopicSeed, error)

FindTelegramTopicAlbum finds a scoped prior seed so album messages share one creation.

func (*Store) FinishDayOperation added in v0.56.0

func (s *Store) FinishDayOperation(ctx context.Context, id, status string) error

FinishDayOperation records success or uncertainty without scheduling another provider write.

func (*Store) FinishTelegramTopicSeed added in v0.56.0

func (s *Store) FinishTelegramTopicSeed(ctx context.Context, instance, owner string, chat int64, thread, message int, status string) error

FinishTelegramTopicSeed marks a scoped processing seed processed, cleared or discarded.

func (*Store) GetAgentJob

func (s *Store) GetAgentJob(ctx context.Context, id int64) (*domain.AgentJob, error)

func (*Store) GetAllFacts

func (s *Store) GetAllFacts(ctx context.Context, chatID string) ([]domain.Fact, error)

func (*Store) GetAllFactsByUser

func (s *Store) GetAllFactsByUser(ctx context.Context, userID string) ([]domain.Fact, error)

func (*Store) GetAnySlackAccount added in v0.38.0

func (s *Store) GetAnySlackAccount(ctx context.Context) (*domain.SlackAccount, error)

GetAnySlackAccount returns the single connected Slack account regardless of owner, or (nil, nil) when none exists. Slack is single-owner (one row total), so this is the canonical way to resolve "the connected account".

func (*Store) GetCachedEmbedding

func (s *Store) GetCachedEmbedding(ctx context.Context, contentHash string) ([]float32, error)

GetCachedEmbedding retrieves a cached embedding by content hash.

func (*Store) GetCachedResponse

func (s *Store) GetCachedResponse(ctx context.Context, hash string, maxAge time.Duration) (*storage.CachedResponse, error)

GetCachedResponse retrieves a cached LLM response by prompt hash. Returns nil if not found or older than maxAge.

func (*Store) GetChannelInstance

func (s *Store) GetChannelInstance(ctx context.Context, id string) (*domain.ChannelInstance, error)

func (*Store) GetChannelInstanceIDByChat

func (s *Store) GetChannelInstanceIDByChat(ctx context.Context, chatID string) (string, error)

GetChannelInstanceIDByChat returns the channel_instance_id for a given chatID (channel_id field). Returns empty string if not found.

func (*Store) GetChannelLocale

func (s *Store) GetChannelLocale(ctx context.Context, channelType, channelUserID string) (string, error)

GetChannelLocale returns the locale for a user channel by channel type and user ID.

func (*Store) GetChannelLocaleByChatID

func (s *Store) GetChannelLocaleByChatID(ctx context.Context, chatID string) (string, error)

GetChannelLocaleByChatID returns the locale for a user channel by chatID.

func (*Store) GetChatIDs

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

func (*Store) GetConfigOverride

func (s *Store) GetConfigOverride(ctx context.Context, key string) (*domain.ConfigOverride, error)

func (*Store) GetCredential added in v0.29.1

func (s *Store) GetCredential(ctx context.Context, id int64) (*domain.Credential, error)

GetCredential retrieves a credential by ID.

func (*Store) GetCredentialByName added in v0.29.1

func (s *Store) GetCredentialByName(ctx context.Context, name string) (*domain.Credential, error)

GetCredentialByName retrieves a global credential by name.

func (*Store) GetCredentialByNameAndOwner added in v0.29.1

func (s *Store) GetCredentialByNameAndOwner(ctx context.Context, name, ownerID string) (*domain.Credential, error)

GetCredentialByNameAndOwner retrieves a user-scoped credential.

func (*Store) GetDailyCost

func (s *Store) GetDailyCost(ctx context.Context) (float64, error)

GetDailyCost returns the total cost in USD for the current day across all chats.

func (*Store) GetDailyCostByChat

func (s *Store) GetDailyCostByChat(ctx context.Context, chatID string) (float64, error)

GetDailyCostByChat returns the total cost in USD for the current day for a specific chat.

func (*Store) GetDayCard added in v0.56.0

func (s *Store) GetDayCard(ctx context.Context, id string) (*dayview.Card, error)

GetDayCard loads server-side card authority by its opaque identifier.

func (*Store) GetDefaultGoogleAccount

func (s *Store) GetDefaultGoogleAccount(ctx context.Context, userID string) (*domain.GoogleAccount, error)

func (*Store) GetDirective

func (s *Store) GetDirective(ctx context.Context, chatID string) (*domain.Directive, error)

func (*Store) GetDirectiveByUser

func (s *Store) GetDirectiveByUser(ctx context.Context, userID string) (*domain.Directive, error)

func (*Store) GetDueAgentJobs

func (s *Store) GetDueAgentJobs(ctx context.Context, now time.Time) ([]domain.AgentJob, error)

func (*Store) GetDueReminders

func (s *Store) GetDueReminders(ctx context.Context, now time.Time) ([]domain.Reminder, error)

func (*Store) GetGoogleAccount

func (s *Store) GetGoogleAccount(ctx context.Context, id int64) (*domain.GoogleAccount, error)

func (*Store) GetGoogleAccountByEmail

func (s *Store) GetGoogleAccountByEmail(ctx context.Context, userID, email string) (*domain.GoogleAccount, error)

func (*Store) GetHTTPArtifact added in v0.46.0

func (s *Store) GetHTTPArtifact(ctx context.Context, id string) (*domain.HTTPArtifact, error)

GetHTTPArtifact fetches one row by ID.

func (*Store) GetHistory

func (s *Store) GetHistory(ctx context.Context, chatID string, limit int) ([]domain.ChatMessage, error)

func (*Store) GetHistoryBefore

func (s *Store) GetHistoryBefore(ctx context.Context, chatID string, beforeID int64, limit int) ([]domain.ChatMessage, error)

func (*Store) GetImportRun added in v0.37.0

func (s *Store) GetImportRun(ctx context.Context, userID, jobID string) (*domain.ImportRun, error)

GetImportRun fetches a user's run summary by job_id. Returns (nil, nil) when the run does not exist; genuine DB errors (e.g. SQLITE_BUSY outlasting busy_timeout) are propagated so callers do not mistake a transient failure for "no such run". Scoped by user_id (IDOR guard) to match ListImportRuns.

func (*Store) GetImportedConversationMessages added in v0.37.0

func (s *Store) GetImportedConversationMessages(ctx context.Context, userID, conversationUUID string) ([]domain.ImportedMessage, error)

GetImportedConversationMessages returns a conversation's messages in order, scoped to the owning user (IDOR guard).

func (*Store) GetInstalledSkill

func (s *Store) GetInstalledSkill(ctx context.Context, slug string) (*domain.InstalledSkill, error)

GetInstalledSkill returns a single installed skill by slug.

func (*Store) GetLocationFactsByUser added in v0.56.4

func (s *Store) GetLocationFactsByUser(ctx context.Context, owner string, limit int) ([]domain.Fact, error)

GetLocationFactsByUser reads a bounded set of relevant user-source assertions by creation time, independent of popularity, decay and memory reinforcement.

func (*Store) GetMCPOAuthFlow added in v0.55.0

func (s *Store) GetMCPOAuthFlow(ctx context.Context, id string) (domain.MCPRecord, error)

GetMCPOAuthFlow is the single narrowly scoped lookup needed before the OAuth callback has an authenticated owner. Its ID is a SHA-256 digest of random state.

func (*Store) GetMCPRecord added in v0.55.0

func (s *Store) GetMCPRecord(ctx context.Context, owner, id, kind string) (domain.MCPRecord, error)

GetMCPRecord resolves an exact owner-scoped encrypted record.

func (*Store) GetPublicSnapshot added in v0.56.0

func (s *Store) GetPublicSnapshot(ctx context.Context, instance, id string) (*dayview.PublicSnapshot, error)

GetPublicSnapshot resolves a publication only within the requested bot instance.

func (*Store) GetRecentFacts

func (s *Store) GetRecentFacts(ctx context.Context, chatID string, limit int) ([]domain.Fact, error)

func (*Store) GetRecentFactsByUser

func (s *Store) GetRecentFactsByUser(ctx context.Context, userID string, limit int) ([]domain.Fact, error)

func (*Store) GetRecentInsights

func (s *Store) GetRecentInsights(ctx context.Context, chatID string, limit int) ([]domain.Insight, error)

func (*Store) GetRecentInsightsByUser

func (s *Store) GetRecentInsightsByUser(ctx context.Context, userID string, limit int) ([]domain.Insight, error)

func (*Store) GetResponseCacheStats

func (s *Store) GetResponseCacheStats(ctx context.Context) (entries int, totalHits int, err error)

GetResponseCacheStats returns the total number of cached entries and total hit count.

func (*Store) GetSchedulerState

func (s *Store) GetSchedulerState(ctx context.Context, name string) (*domain.SchedulerState, error)

func (*Store) GetSkillProposal added in v0.31.0

func (s *Store) GetSkillProposal(ctx context.Context, id int64) (*domain.SkillProposal, error)

GetSkillProposal fetches a single proposal by id.

func (*Store) GetSkillStats added in v0.31.0

func (s *Store) GetSkillStats(ctx context.Context, filter storage.SkillStatsFilter) ([]storage.SkillStat, error)

GetSkillStats returns per-skill aggregated telemetry, ordered by call count. Uses the bun query builder so DATETIME columns (last_used) decode into time.Time regardless of how the driver represents them.

func (*Store) GetSlackAccountByUserID added in v0.38.0

func (s *Store) GetSlackAccountByUserID(ctx context.Context, userID string) (*domain.SlackAccount, error)

GetSlackAccountByUserID returns the owner's Slack account, or (nil, nil) when none is connected so callers can treat "not connected" cleanly.

func (*Store) GetSlackRoute added in v0.38.0

func (s *Store) GetSlackRoute(ctx context.Context, instanceID, chatID string) (*domain.SlackChatRoute, error)

GetSlackRoute returns the persisted route for an (instanceID, chatID), or (nil, nil) when none exists so the caller can fall back to parsing the chatID. Scoping by instanceID isolates routes between Slack instances that may share a workspace's channel IDs.

func (*Store) GetTechFacts

func (s *Store) GetTechFacts(ctx context.Context, chatID string) ([]domain.TechFact, error)

func (*Store) GetTechFactsByCategory

func (s *Store) GetTechFactsByCategory(ctx context.Context, chatID, category string) ([]domain.TechFact, error)

func (*Store) GetTechFactsByCategoryAndUser

func (s *Store) GetTechFactsByCategoryAndUser(ctx context.Context, userID, category string) ([]domain.TechFact, error)

func (*Store) GetTechFactsByUser

func (s *Store) GetTechFactsByUser(ctx context.Context, userID string) ([]domain.TechFact, error)

func (*Store) GetTelegramRoute added in v0.56.0

func (s *Store) GetTelegramRoute(ctx context.Context, id string) (*domain.TelegramConversationRoute, error)

GetTelegramRoute loads the persisted transport authority for a conversation.

func (*Store) GetTelegramTopicDeletion added in v0.56.0

func (s *Store) GetTelegramTopicDeletion(ctx context.Context, key string) (*domain.TelegramTopicDeletion, error)

GetTelegramTopicDeletion loads a durable tombstone, if present.

func (*Store) GetTelegramTopicOperation added in v0.56.0

func (s *Store) GetTelegramTopicOperation(ctx context.Context, id, owner, instance string) (*domain.TelegramTopicOperation, error)

GetTelegramTopicOperation reads a receipt only for its owning user and bot instance.

func (*Store) GetTelegramTopicState added in v0.56.0

func (s *Store) GetTelegramTopicState(ctx context.Context, id string) (*domain.TelegramTopicState, error)

GetTelegramTopicState loads the local conversation lifecycle state.

func (*Store) GetTodoItem

func (s *Store) GetTodoItem(ctx context.Context, id int64, userID string) (*domain.TodoItem, error)

GetTodoItem returns a single todo item by ID, scoped to user.

func (*Store) GetUsageByDay added in v0.28.0

func (s *Store) GetUsageByDay(ctx context.Context, filter storage.UsageFilter) ([]storage.DailyUsage, error)

GetUsageByDay returns daily aggregated usage matching the filter.

func (*Store) GetUsageByModel added in v0.28.0

func (s *Store) GetUsageByModel(ctx context.Context, filter storage.UsageFilter) ([]storage.ModelUsage, error)

GetUsageByModel returns per-model aggregated usage matching the filter.

func (*Store) GetUsageStats

func (s *Store) GetUsageStats(ctx context.Context, chatID string) ([]domain.UsageRecord, error)

func (*Store) GetUsageSummary added in v0.28.0

func (s *Store) GetUsageSummary(ctx context.Context, filter storage.UsageFilter) (*storage.UsageSummary, error)

GetUsageSummary returns aggregated usage summary matching the filter.

func (*Store) GetUser

func (s *Store) GetUser(ctx context.Context, id string) (*domain.User, error)

func (*Store) GetUserByChannel

func (s *Store) GetUserByChannel(ctx context.Context, channelType, channelUserID string) (*domain.User, error)

func (*Store) GetUserByUsername

func (s *Store) GetUserByUsername(ctx context.Context, username string) (*domain.User, error)

func (*Store) GetUserIDs

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

GetUserIDs returns distinct user IDs that have data in the system.

func (*Store) HasHTTPStandingGrant added in v0.47.0

func (s *Store) HasHTTPStandingGrant(ctx context.Context, owner, scheme, host, port string) (bool, error)

HasHTTPStandingGrant reports whether an unrevoked, unexpired grant covers the exact origin (or globally) for the owner.

func (*Store) ImportedFactKeyExists added in v0.37.0

func (s *Store) ImportedFactKeyExists(ctx context.Context, sourceUUID string) (bool, error)

ImportedFactKeyExists reports whether a memory fact with this dedup key was imported.

func (*Store) ImportedMessagesWithoutEmbeddings added in v0.37.0

func (s *Store) ImportedMessagesWithoutEmbeddings(ctx context.Context, limit int) ([]domain.ImportedMessage, error)

ImportedMessagesWithoutEmbeddings returns archived messages that have no vector embedding yet (delta for the embedding pass). Uses NOT IN rather than a join — modernc handles this form well and does not support UPDATE..FROM.

func (*Store) IncrementUsage

func (s *Store) IncrementUsage(ctx context.Context, chatID string, inputTokens, outputTokens int64) error

func (*Store) IncrementUsageWithCost

func (s *Store) IncrementUsageWithCost(ctx context.Context, chatID string, inputTokens, outputTokens int64, costUSD float64) error

IncrementUsageWithCost increments usage stats including cost tracking.

func (*Store) InsightsWithoutEmbeddings

func (s *Store) InsightsWithoutEmbeddings(ctx context.Context, limit int) ([]domain.Insight, error)

InsightsWithoutEmbeddings returns insights that don't have a vector embedding yet.

func (*Store) ListAgentJobs

func (s *Store) ListAgentJobs(ctx context.Context) ([]domain.AgentJob, error)

func (*Store) ListAgentJobsByUser added in v0.36.0

func (s *Store) ListAgentJobsByUser(ctx context.Context, userID string) ([]domain.AgentJob, error)

ListAgentJobsByUser returns only the jobs owned by userID.

func (*Store) ListAllChannels

func (s *Store) ListAllChannels(ctx context.Context) ([]domain.UserChannel, error)

func (*Store) ListAllHTTPArtifacts added in v0.46.0

func (s *Store) ListAllHTTPArtifacts(ctx context.Context) ([]domain.HTTPArtifact, error)

ListAllHTTPArtifacts returns every row (sweeper reconciliation).

func (*Store) ListAllReminders

func (s *Store) ListAllReminders(ctx context.Context, chatID string) ([]domain.Reminder, error)

func (*Store) ListAuditEntriesByPrefix added in v0.38.0

func (s *Store) ListAuditEntriesByPrefix(ctx context.Context, actionPrefix string, limit int) ([]domain.AuditEntry, error)

ListAuditEntriesByPrefix returns the most recent audit entries whose Action starts with actionPrefix (e.g. "slack."), newest first. The prefix is a hardcoded literal from the caller, never user input.

func (*Store) ListChannelInstanceCredentialBindings added in v0.29.1

func (s *Store) ListChannelInstanceCredentialBindings(ctx context.Context) (map[string]storage.ChannelCredentialBinding, error)

ListChannelInstanceCredentialBindings returns instance->credential mappings.

func (*Store) ListChannelInstances

func (s *Store) ListChannelInstances(ctx context.Context) ([]domain.ChannelInstance, error)

func (*Store) ListConfigOverrides

func (s *Store) ListConfigOverrides(ctx context.Context) ([]domain.ConfigOverride, error)

func (*Store) ListCredentialAudit added in v0.29.1

func (s *Store) ListCredentialAudit(ctx context.Context, credentialID int64, limit int) ([]domain.CredentialAudit, error)

ListCredentialAudit returns audit entries for a credential.

func (*Store) ListCredentialBindings added in v0.29.1

func (s *Store) ListCredentialBindings(ctx context.Context, credentialID int64) ([]domain.CredentialBinding, error)

ListCredentialBindings returns all bindings for a credential.

func (*Store) ListCredentialBindingsByConsumer added in v0.29.1

func (s *Store) ListCredentialBindingsByConsumer(ctx context.Context, consumerType, consumerID string) ([]domain.CredentialBinding, error)

ListCredentialBindingsByConsumer returns bindings for a consumer.

func (*Store) ListCredentials added in v0.29.1

func (s *Store) ListCredentials(ctx context.Context, filter storage.CredentialFilter) ([]domain.Credential, error)

ListCredentials returns credentials matching the filter.

func (*Store) ListDayOperations added in v0.56.0

func (s *Store) ListDayOperations(ctx context.Context, owner, conversation string) ([]dayview.Operation, error)

ListDayOperations lists bounded durable receipts for an exact owner and conversation.

func (*Store) ListGoogleAccounts

func (s *Store) ListGoogleAccounts(ctx context.Context, userID string) ([]domain.GoogleAccount, error)

func (*Store) ListHTTPArtifactsByBinding added in v0.50.0

func (s *Store) ListHTTPArtifactsByBinding(ctx context.Context, owner, binding string) ([]domain.HTTPArtifact, error)

ListHTTPArtifactsByBinding applies native origin filtering before the list bound, so activity in other chats cannot hide this chat's attachments.

func (*Store) ListHTTPArtifactsByOwner added in v0.46.0

func (s *Store) ListHTTPArtifactsByOwner(ctx context.Context, ownerUserID string) ([]domain.HTTPArtifact, error)

ListHTTPArtifactsByOwner returns an owner's artifacts, newest first.

func (*Store) ListHTTPCredentialGrants added in v0.46.0

func (s *Store) ListHTTPCredentialGrants(ctx context.Context, credentialID int64) ([]domain.HTTPCredentialGrant, error)

ListHTTPCredentialGrants returns all grants for a credential.

func (*Store) ListHTTPStandingGrants added in v0.47.0

func (s *Store) ListHTTPStandingGrants(ctx context.Context, owner string) ([]domain.HTTPStandingGrant, error)

ListHTTPStandingGrants returns an owner's grants, newest first.

func (*Store) ListImportRuns added in v0.37.0

func (s *Store) ListImportRuns(ctx context.Context, userID string, limit int) ([]domain.ImportRun, error)

ListImportRuns lists a user's import runs, newest first.

func (*Store) ListImportedConversations added in v0.37.0

func (s *Store) ListImportedConversations(ctx context.Context, userID string, limit, offset int) ([]domain.ImportedConversation, error)

ListImportedConversations lists a user's archived conversations, newest first.

func (*Store) ListInstalledSkills

func (s *Store) ListInstalledSkills(ctx context.Context) ([]domain.InstalledSkill, error)

ListInstalledSkills returns all installed skills, ordered by name.

func (*Store) ListMCPEvents added in v0.55.0

func (s *Store) ListMCPEvents(ctx context.Context, owner string) ([]domain.MCPRecordEvent, error)

ListMCPEvents returns bounded safe audit metadata for one owner.

func (*Store) ListReminders

func (s *Store) ListReminders(ctx context.Context, chatID string) ([]domain.Reminder, error)

func (*Store) ListSkillProposals added in v0.31.0

func (s *Store) ListSkillProposals(ctx context.Context, filter storage.SkillProposalFilter) ([]domain.SkillProposal, error)

ListSkillProposals returns proposals (newest first), optionally filtered by status.

func (*Store) ListTasks

func (s *Store) ListTasks(ctx context.Context, filter storage.TaskFilter) ([]domain.Task, error)

func (*Store) ListTelegramTopicSyncRoutes added in v0.56.0

func (s *Store) ListTelegramTopicSyncRoutes(ctx context.Context, instance, after string, limit int) ([]domain.TelegramConversationRoute, error)

ListTelegramTopicSyncRoutes returns a bounded keyset of proven routes still needing reconciliation.

func (*Store) ListTelegramTopics added in v0.56.0

func (s *Store) ListTelegramTopics(ctx context.Context, instance, owner string, chat int64, offset, limit int, botIDs ...int64) ([]domain.TelegramTopicListItem, error)

ListTelegramTopics lists only routes observed by this instance for this owner. Telegram Bot API has no API to enumerate all existing private topics.

func (*Store) ListTodoItemsAll

func (s *Store) ListTodoItemsAll(ctx context.Context, userID string, limit int) ([]domain.TodoItem, error)

ListTodoItemsAll returns all incomplete items for a user (no date filter).

func (*Store) ListTodoItemsDueToday

func (s *Store) ListTodoItemsDueToday(ctx context.Context, userID string, now time.Time) ([]domain.TodoItem, error)

ListTodoItemsDueToday returns incomplete items due today for a user.

func (*Store) ListTodoItemsOverdue

func (s *Store) ListTodoItemsOverdue(ctx context.Context, userID string, now time.Time) ([]domain.TodoItem, error)

ListTodoItemsOverdue returns incomplete items overdue for a user.

func (*Store) ListTodoItemsUpcoming

func (s *Store) ListTodoItemsUpcoming(ctx context.Context, userID string, now time.Time, days int) ([]domain.TodoItem, error)

ListTodoItemsUpcoming returns incomplete items due within the next N days for a user.

func (*Store) ListUserChannels

func (s *Store) ListUserChannels(ctx context.Context, userID string) ([]domain.UserChannel, error)

func (*Store) ListUsers

func (s *Store) ListUsers(ctx context.Context) ([]domain.User, error)

func (*Store) LoadMCPRecords added in v0.55.0

func (s *Store) LoadMCPRecords(ctx context.Context) ([]domain.MCPRecord, error)

LoadMCPRecords is used only at startup by the private MCP control plane.

func (*Store) MarkDayDelivered added in v0.56.0

func (s *Store) MarkDayDelivered(ctx context.Context, id string, revision int64) error

MarkDayDelivered advances a card delivery receipt only for the expected revision.

func (*Store) MarkReminderDeliverySuppressed added in v0.56.0

func (s *Store) MarkReminderDeliverySuppressed(ctx context.Context, id int64) error

MarkReminderDeliverySuppressed records a definitive no-send decision. It is terminal for the queued job and becomes pending only via explicit reschedule.

func (*Store) MarkReminderDeliveryUnknown added in v0.56.0

func (s *Store) MarkReminderDeliveryUnknown(ctx context.Context, id int64) error

MarkReminderDeliveryUnknown marks an in-flight send uncertain without requeuing delivery.

func (*Store) MarkReminderFired

func (s *Store) MarkReminderFired(ctx context.Context, id int64) error

func (*Store) PendingDayCards added in v0.56.0

func (s *Store) PendingDayCards(ctx context.Context, instance string) ([]dayview.Card, error)

PendingDayCards lists bounded undelivered, unexpired projections for one bot instance.

func (*Store) PruneImportRuns added in v0.37.0

func (s *Store) PruneImportRuns(ctx context.Context, keep int) (int, error)

PruneImportRuns keeps only the newest `keep` import runs (by id) and deletes the rest. import_runs is not GC-ed by the scheduler, so this bounds its growth.

func (*Store) PruneMCPEvents added in v0.55.0

func (s *Store) PruneMCPEvents(ctx context.Context, before time.Time) error

PruneMCPEvents removes expired safe audit metadata according to retention policy.

func (*Store) PutTelegramRoute added in v0.56.0

func (s *Store) PutTelegramRoute(ctx context.Context, r *domain.TelegramConversationRoute) error

PutTelegramRoute persists immutable bot, owner and native transport coordinates.

func (*Store) PutTelegramTopicState added in v0.56.0

func (s *Store) PutTelegramTopicState(ctx context.Context, v *domain.TelegramTopicState) error

PutTelegramTopicState updates local metadata without reopening a terminal conversation.

func (*Store) ReadAccountDirective added in v0.50.0

func (s *Store) ReadAccountDirective(ctx context.Context, owner string) (string, error)

ReadAccountDirective returns shared instructions with legacy-source fallback.

func (*Store) ReadMobileRelevantKnowledge added in v0.50.0

func (s *Store) ReadMobileRelevantKnowledge(ctx context.Context, owner, query string) (string, error)

ReadMobileRelevantKnowledge augments the bounded baseline with FTS matches from this owner's saved facts. Legacy namespace exclusions stay in force.

func (*Store) ReadMobileSavedKnowledge added in v0.48.0

func (s *Store) ReadMobileSavedKnowledge(ctx context.Context, owner string) (string, error)

ReadMobileSavedKnowledge is an explicit account-memory snapshot, never a mobile namespace opt-out. LIMIT and substring caps apply in SQL, before any large legacy row enters RAM. No history search or memory writes are performed.

func (*Store) ReconcileReminderClaims added in v0.56.0

func (s *Store) ReconcileReminderClaims(ctx context.Context, now time.Time) error

ReconcileReminderClaims marks abandoned sends uncertain, never requeues them. Fifteen minutes exceeds the bounded sender call and avoids treating an active request as evidence of a crash. Legacy rows receive a fresh lease at upgrade.

func (*Store) ReinforceFact

func (s *Store) ReinforceFact(ctx context.Context, id int64) error

func (*Store) ReinforceInsight

func (s *Store) ReinforceInsight(ctx context.Context, id int64) error

func (*Store) ReopenTodoItem

func (s *Store) ReopenTodoItem(ctx context.Context, id int64, userID string) error

ReopenTodoItem clears completed_at on a todo item.

func (*Store) ReplaceMessagesWithSummary added in v0.39.0

func (s *Store) ReplaceMessagesWithSummary(ctx context.Context, chatID string, lastOldID int64, summary *domain.ChatMessage) error

ReplaceMessagesWithSummary commits deletion and insertion together. Reusing the last replaced message ID preserves chronological ID ordering and the existing FTS triggers. A failed insert never loses the original conversation.

func (*Store) ResolveDayOperation added in v0.56.0

func (s *Store) ResolveDayOperation(ctx context.Context, owner, conversation, id, expected string) error

ResolveDayOperation records owner acknowledgement without retrying or asserting remote success.

func (*Store) ResolveReminderDelivery added in v0.56.0

func (s *Store) ResolveReminderDelivery(ctx context.Context, owner, conversation string, id int64, expected, decision string) error

ResolveReminderDelivery records a user's observation; it does not manufacture technical delivery proof or requeue an uncertain Telegram send.

func (*Store) RevokeHTTPStandingGrant added in v0.47.0

func (s *Store) RevokeHTTPStandingGrant(ctx context.Context, id int64) error

RevokeHTTPStandingGrant marks a grant revoked (idempotent).

func (*Store) RevokeUserSessions added in v0.48.0

func (s *Store) RevokeUserSessions(ctx context.Context, id string) error

RevokeUserSessions is an account-authority security logout. Mobile validation and business fences observe this durable epoch; it does not claim remote wipe.

func (*Store) RunDayMaintenance added in v0.56.0

func (s *Store) RunDayMaintenance(ctx context.Context)

RunDayMaintenance is process-scoped, independent of card visibility flags. Disabling the UI must not disable expiration of its previously stored data.

func (*Store) RunMigrations

func (s *Store) RunMigrations(ctx context.Context) error

func (*Store) SaveAuditEntry

func (s *Store) SaveAuditEntry(ctx context.Context, e *domain.AuditEntry) error

func (*Store) SaveCachedEmbedding

func (s *Store) SaveCachedEmbedding(ctx context.Context, contentHash string, embedding []float32) error

SaveCachedEmbedding stores an embedding in the cache keyed by content hash.

func (*Store) SaveCachedResponse

func (s *Store) SaveCachedResponse(ctx context.Context, hash, model, response, usageJSON string) error

SaveCachedResponse stores an LLM response in the cache.

func (*Store) SaveConfigOverride

func (s *Store) SaveConfigOverride(ctx context.Context, o *domain.ConfigOverride) error

func (*Store) SaveCredential added in v0.29.1

func (s *Store) SaveCredential(ctx context.Context, c *domain.Credential) error

SaveCredential persists a new credential.

func (*Store) SaveCredentialAudit added in v0.29.1

func (s *Store) SaveCredentialAudit(ctx context.Context, a *domain.CredentialAudit) error

SaveCredentialAudit persists an audit entry.

func (*Store) SaveCredentialBinding added in v0.29.1

func (s *Store) SaveCredentialBinding(ctx context.Context, b *domain.CredentialBinding) error

SaveCredentialBinding creates a credential binding (idempotent).

func (*Store) SaveDayCard added in v0.56.0

func (s *Store) SaveDayCard(ctx context.Context, c *dayview.Card) error

SaveDayCard persists a bounded projection behind the conversation lifecycle fence.

func (*Store) SaveDirective

func (s *Store) SaveDirective(ctx context.Context, d *domain.Directive) error

func (*Store) SaveFact

func (s *Store) SaveFact(ctx context.Context, f *domain.Fact) error

func (*Store) SaveFactVector

func (s *Store) SaveFactVector(ctx context.Context, factID int64, embedding []float32) error

SaveFactVector stores the embedding for a fact as a binary BLOB.

func (*Store) SaveGoogleAccount

func (s *Store) SaveGoogleAccount(ctx context.Context, a *domain.GoogleAccount) error

func (*Store) SaveHTTPArtifact added in v0.46.0

func (s *Store) SaveHTTPArtifact(ctx context.Context, a *domain.HTTPArtifact) error

SaveHTTPArtifact inserts new artifact metadata.

func (*Store) SaveHTTPCredentialGrant added in v0.46.0

func (s *Store) SaveHTTPCredentialGrant(ctx context.Context, g *domain.HTTPCredentialGrant) error

SaveHTTPCredentialGrant persists an origin-bound HTTP credential grant.

func (*Store) SaveHTTPStandingGrant added in v0.47.0

func (s *Store) SaveHTTPStandingGrant(ctx context.Context, g *domain.HTTPStandingGrant) error

SaveHTTPStandingGrant persists a standing mutation approval.

func (*Store) SaveImportedConversation added in v0.37.0

func (s *Store) SaveImportedConversation(ctx context.Context, c *domain.ImportedConversation) (bool, error)

SaveImportedConversation upserts an archived conversation keyed by source_uuid. On a delta re-import the export snapshot is the source of truth for the mutable header (title/summary/message_count/updated_at), so those are refreshed from the new snapshot while created_at/imported_at are preserved. Returns created=true only when the conversation did not previously exist (SQLite's ON CONFLICT DO UPDATE cannot distinguish insert from update via RowsAffected, hence the existence check).

func (*Store) SaveImportedFactKey added in v0.37.0

func (s *Store) SaveImportedFactKey(ctx context.Context, k *domain.ImportedFactKey) error

SaveImportedFactKey records a memory→fact dedup key, ignoring duplicates.

func (*Store) SaveImportedMessage added in v0.37.0

func (s *Store) SaveImportedMessage(ctx context.Context, m *domain.ImportedMessage) (bool, error)

SaveImportedMessage inserts an archived message, ignoring duplicates by source_uuid. Returns inserted=false when the message already exists. When inserted=true the message's ID is populated (used to enqueue embedding). Embedding is NOT triggered here — it runs as a separate batched pass to serialize the shared embedding pipeline.

func (*Store) SaveImportedMessageVector added in v0.37.0

func (s *Store) SaveImportedMessageVector(ctx context.Context, messageID int64, chunkIndex int, embedding []float32) error

SaveImportedMessageVector stores one chunk embedding for an archived message. Keyed by (message_id, chunk_index) so re-embedding is idempotent.

func (*Store) SaveInsight

func (s *Store) SaveInsight(ctx context.Context, d *domain.Insight) error

func (*Store) SaveInsightVector

func (s *Store) SaveInsightVector(ctx context.Context, insightID int64, embedding []float32) error

SaveInsightVector stores the embedding for an insight as a binary BLOB.

func (*Store) SaveInstalledSkill

func (s *Store) SaveInstalledSkill(ctx context.Context, sk *domain.InstalledSkill) error

SaveInstalledSkill inserts or updates (upsert by slug) an installed skill record.

func (*Store) SaveMCPRecord added in v0.55.0

func (s *Store) SaveMCPRecord(ctx context.Context, r *domain.MCPRecord, expected int64) error

SaveMCPRecord atomically fences stale writers. expected=0 means insert only.

func (*Store) SaveMessage

func (s *Store) SaveMessage(ctx context.Context, msg *domain.ChatMessage) error

func (*Store) SavePublicSnapshot added in v0.56.0

func (s *Store) SavePublicSnapshot(ctx context.Context, p *dayview.PublicSnapshot) error

SavePublicSnapshot saves a bounded publication while preserving immutable ownership.

func (*Store) SaveSchedulerState

func (s *Store) SaveSchedulerState(ctx context.Context, state *domain.SchedulerState) error

func (*Store) SaveSkillExecution added in v0.31.0

func (s *Store) SaveSkillExecution(ctx context.Context, e *domain.SkillExecution) error

SaveSkillExecution appends a per-call skill telemetry record.

func (*Store) SaveSkillProposal added in v0.31.0

func (s *Store) SaveSkillProposal(ctx context.Context, p *domain.SkillProposal) error

SaveSkillProposal inserts a new self-authored skill proposal.

func (*Store) SaveSlackAccount added in v0.38.0

func (s *Store) SaveSlackAccount(ctx context.Context, a *domain.SlackAccount) error

SaveSlackAccount inserts the owner's Slack account row.

func (*Store) SaveTelegramTopicOperation added in v0.56.0

func (s *Store) SaveTelegramTopicOperation(ctx context.Context, op *domain.TelegramTopicOperation) error

SaveTelegramTopicOperation persists the outcome of an already claimed native operation.

func (*Store) SaveUsageAttempt added in v0.39.0

func (s *Store) SaveUsageAttempt(ctx context.Context, attempt *domain.LLMUsageAttempt, rec storage.UsageUpsert) error

SaveUsageAttempt commits its unique attempt and aggregate in one transaction. Event redelivery never charges a second time; failed persistence rolls back both records rather than leaving an unaggregated or double-counted attempt.

func (*Store) SearchFacts

func (s *Store) SearchFacts(ctx context.Context, chatID, query string, limit int) ([]domain.Fact, error)

func (*Store) SearchFactsByUser

func (s *Store) SearchFactsByUser(ctx context.Context, userID, query string, limit int) ([]domain.Fact, error)

func (*Store) SearchFactsHybrid

func (s *Store) SearchFactsHybrid(ctx context.Context, chatID string, query string, queryVec []float32, limit int, vectorWeight float64) ([]domain.Fact, error)

SearchFactsHybrid combines FTS and vector search, merging results with weighted scoring. vectorWeight controls the blend: 0 = pure FTS, 1 = pure vector.

func (*Store) SearchFactsHybridByUser

func (s *Store) SearchFactsHybridByUser(ctx context.Context, userID string, query string, queryVec []float32, limit int, vectorWeight float64) ([]domain.Fact, error)

func (*Store) SearchImportedMessagesHybrid added in v0.37.0

func (s *Store) SearchImportedMessagesHybrid(ctx context.Context, userID, query string, queryVec []float32, limit int, vectorWeight float64) ([]domain.ImportedMessage, error)

SearchImportedMessagesHybrid combines FTS and vector search over the isolated archive, scoped to a single user. queryVec==nil (or vectorWeight<=0) falls back to FTS-only. Per-message vector score is max-pooled across the message's chunks. This path is deliberately NOT wired into the assistant's live retrieval.

func (*Store) SearchInsights

func (s *Store) SearchInsights(ctx context.Context, chatID, query string, limit int) ([]domain.Insight, error)

func (*Store) SearchInsightsByUser

func (s *Store) SearchInsightsByUser(ctx context.Context, userID, query string, limit int) ([]domain.Insight, error)

func (*Store) SearchInsightsHybrid

func (s *Store) SearchInsightsHybrid(ctx context.Context, chatID string, query string, queryVec []float32, limit int, vectorWeight float64) ([]domain.Insight, error)

SearchInsightsHybrid combines FTS and vector search for insights.

func (*Store) SearchInsightsHybridByUser

func (s *Store) SearchInsightsHybridByUser(ctx context.Context, userID string, query string, queryVec []float32, limit int, vectorWeight float64) ([]domain.Insight, error)

func (*Store) SearchMessages added in v0.33.0

func (s *Store) SearchMessages(ctx context.Context, chatID, query string, limit int) ([]domain.ChatMessage, error)

SearchMessages returns chat-scoped messages matching the query, newest first.

func (*Store) SearchMessagesByUser added in v0.33.0

func (s *Store) SearchMessagesByUser(ctx context.Context, userID, query string, limit int) ([]domain.ChatMessage, error)

SearchMessagesByUser returns user-scoped messages (across channels) matching the query, newest first.

func (*Store) SetEmbedFunc

func (s *Store) SetEmbedFunc(fn EmbedFunc)

SetEmbedFunc sets a callback for auto-embedding facts and insights on save.

func (*Store) SetHalfLifeDays

func (s *Store) SetHalfLifeDays(days float64)

SetHalfLifeDays configures the temporal decay half-life for memory ranking.

func (*Store) SetMMRLambda

func (s *Store) SetMMRLambda(lambda float64)

SetMMRLambda configures the MMR diversity parameter for memory retrieval. 0 = disabled, 0.7 recommended. Higher values favor relevance over diversity.

func (*Store) StartTask

func (s *Store) StartTask(ctx context.Context, taskID int64, workerID string) error

func (*Store) SumHTTPArtifactBytes added in v0.46.0

func (s *Store) SumHTTPArtifactBytes(ctx context.Context) (int64, error)

SumHTTPArtifactBytes sums stored ready+partial bytes (quota truth).

func (*Store) SumHTTPArtifactBytesByOwner added in v0.50.0

func (s *Store) SumHTTPArtifactBytesByOwner(ctx context.Context, owner string) (int64, error)

SumHTTPArtifactBytesByOwner includes every persisted ready/partial byte, independently of the bounded history listing and artifact transport.

func (*Store) TaskStillRunnable added in v0.56.0

func (s *Store) TaskStillRunnable(ctx context.Context, id int64) (bool, error)

TaskStillRunnable is used before dispatch and by cancellation monitoring.

func (*Store) TouchTask added in v0.37.0

func (s *Store) TouchTask(ctx context.Context, taskID int64) (bool, error)

TouchTask bumps claimed_at for a claimed/running task, acting as a worker heartbeat so CleanupStaleTasks does not reclaim a long-running job out from under its worker. Returns stillOwned=false when no claimed/running row matched — i.e. the task was already reclaimed, completed, or failed — so the caller can abort rather than keep working on a job another worker may now own.

func (*Store) TransitionTelegramTopicSeed added in v0.56.0

func (s *Store) TransitionTelegramTopicSeed(ctx context.Context, seed *domain.TelegramTopicSeed, expected, next string) error

TransitionTelegramTopicSeed advances an exact scoped seed stage behind its lifecycle fence.

func (*Store) UnbindChannel

func (s *Store) UnbindChannel(ctx context.Context, id int64) error

func (*Store) UpdateAgentJob

func (s *Store) UpdateAgentJob(ctx context.Context, j *domain.AgentJob) error

func (*Store) UpdateAgentJobSchedule

func (s *Store) UpdateAgentJobSchedule(ctx context.Context, id int64, lastRun, nextRun time.Time) error

func (*Store) UpdateChannel

func (s *Store) UpdateChannel(ctx context.Context, uc *domain.UserChannel) error

func (*Store) UpdateChannelInstance

func (s *Store) UpdateChannelInstance(ctx context.Context, ci *domain.ChannelInstance) error

func (*Store) UpdateChannelLocale

func (s *Store) UpdateChannelLocale(ctx context.Context, chatID string, locale string) error

UpdateChannelLocale updates the locale for a user channel identified by chatID (channel_id).

func (*Store) UpdateCredential added in v0.29.1

func (s *Store) UpdateCredential(ctx context.Context, c *domain.Credential) error

UpdateCredential updates an existing credential.

func (*Store) UpdateFactContent

func (s *Store) UpdateFactContent(ctx context.Context, id int64, content string) error

func (*Store) UpdateGoogleAccountMeta

func (s *Store) UpdateGoogleAccountMeta(ctx context.Context, id int64, alias string, isDefault bool) error

func (*Store) UpdateGoogleTokens

func (s *Store) UpdateGoogleTokens(ctx context.Context, id int64, accessToken, refreshToken string, expiry time.Time) error

func (*Store) UpdateHTTPArtifact added in v0.46.0

func (s *Store) UpdateHTTPArtifact(ctx context.Context, a *domain.HTTPArtifact) error

UpdateHTTPArtifact persists metadata changes.

func (*Store) UpdateInstalledSkill

func (s *Store) UpdateInstalledSkill(ctx context.Context, sk *domain.InstalledSkill) error

UpdateInstalledSkill updates an installed skill record by slug.

func (*Store) UpdateSkillProposalStatus added in v0.31.0

func (s *Store) UpdateSkillProposalStatus(ctx context.Context, id int64, status string) error

UpdateSkillProposalStatus sets the lifecycle status of a proposal.

func (*Store) UpdateSlackTokens added in v0.38.0

func (s *Store) UpdateSlackTokens(ctx context.Context, id int64, accessToken, refreshToken string, expiry time.Time) error

UpdateSlackTokens refreshes the stored (encrypted) tokens and expiry after a token rotation.

func (*Store) UpdateTodoItem

func (s *Store) UpdateTodoItem(ctx context.Context, item *domain.TodoItem) error

UpdateTodoItem updates a todo item.

func (*Store) UpdateUser

func (s *Store) UpdateUser(ctx context.Context, u *domain.User) error

func (*Store) UpsertImportRun added in v0.37.0

func (s *Store) UpsertImportRun(ctx context.Context, r *domain.ImportRun) error

UpsertImportRun inserts or updates the durable summary for an import run, keyed by job_id. started_at is preserved on update.

func (*Store) UpsertSlackRoute added in v0.38.0

func (s *Store) UpsertSlackRoute(ctx context.Context, r *domain.SlackChatRoute) error

UpsertSlackRoute persists (or refreshes) the Slack coordinates for a composite chatID so proactive delivery can route to it after the in-memory cache is gone.

func (*Store) UpsertTechFact

func (s *Store) UpsertTechFact(ctx context.Context, f *domain.TechFact) error

func (*Store) UpsertTodoItemByExternal

func (s *Store) UpsertTodoItemByExternal(ctx context.Context, item *domain.TodoItem) error

UpsertTodoItemByExternal creates or updates a todo item matched by (user_id, provider, external_id). Uses INSERT ON CONFLICT to avoid race conditions during concurrent syncs.

func (*Store) UpsertUsage added in v0.28.0

func (s *Store) UpsertUsage(ctx context.Context, rec storage.UsageUpsert) error

UpsertUsage inserts or updates a usage stats row with all fields.

func (*Store) ValidateAgentJob added in v0.56.0

func (s *Store) ValidateAgentJob(ctx context.Context, id int64, owner, prompt, delivery string) (bool, error)

ValidateAgentJob checks current job authority and conversation availability before execution.

func (*Store) WithUserSecurity added in v0.48.0

func (s *Store) WithUserSecurity(ctx context.Context, id string, fn func(*domain.User) error) error

WithUserSecurity holds a short write reservation in the account authority while another realm verifies/mints credentials. WAL read snapshots alone do not prevent a concurrent password/disable/delete commit. Never use this for streams, network/provider calls or waiting for a user decision.

func (*Store) WriteAccountDirective added in v0.50.0

func (s *Store) WriteAccountDirective(ctx context.Context, owner, content string) error

WriteAccountDirective replaces the owner preference, retaining empty clears.

Jump to

Keyboard shortcuts

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