Documentation
¶
Overview ¶
Package store provides PostgreSQL-backed data access for Creel.
Index ¶
- func EnsureSchema(ctx context.Context, baseURL, schema string) error
- func NewPool(ctx context.Context, postgresURL string) (*pgxpool.Pool, error)
- func RunMigrations(postgresURL, migrationsPath string) error
- type APIKeyConfig
- type APIKeyConfigStore
- func (s *APIKeyConfigStore) Create(ctx context.Context, name, provider string, apiKey []byte, isDefault bool) (*APIKeyConfig, error)
- func (s *APIKeyConfigStore) Delete(ctx context.Context, id string) error
- func (s *APIKeyConfigStore) Get(ctx context.Context, id string) (*APIKeyConfig, error)
- func (s *APIKeyConfigStore) GetDecrypted(ctx context.Context, id string) ([]byte, error)
- func (s *APIKeyConfigStore) List(ctx context.Context) ([]APIKeyConfig, error)
- func (s *APIKeyConfigStore) SetDefault(ctx context.Context, id string) (*APIKeyConfig, error)
- func (s *APIKeyConfigStore) Update(ctx context.Context, id, name, provider string, apiKey []byte) (*APIKeyConfig, error)
- type Chunk
- type ChunkStore
- func (s *ChunkStore) ChunkIDsByTopics(ctx context.Context, topicIDs []string, excludeDocIDs []string) ([]string, error)
- func (s *ChunkStore) Create(ctx context.Context, documentID, content string, sequence int, ...) (*Chunk, error)
- func (s *ChunkStore) Delete(ctx context.Context, id string) error
- func (s *ChunkStore) DocumentTopicID(ctx context.Context, documentID string) (string, error)
- func (s *ChunkStore) DocumentTopicIDs(ctx context.Context, docIDs []string) (map[string]string, error)
- func (s *ChunkStore) Get(ctx context.Context, id string) (*Chunk, error)
- func (s *ChunkStore) GetEmbeddingModels(ctx context.Context, chunkIDs []string) (map[string]string, error)
- func (s *ChunkStore) GetMultiple(ctx context.Context, ids []string) (map[string]*Chunk, error)
- func (s *ChunkStore) ListByDocument(ctx context.Context, documentID string, lastN int, since time.Time) ([]*Chunk, error)
- func (s *ChunkStore) MarkCompacted(ctx context.Context, chunkIDs []string, summaryChunkID string) error
- func (s *ChunkStore) NextSequence(ctx context.Context, documentID string) (int, error)
- func (s *ChunkStore) RestoreCompacted(ctx context.Context, summaryChunkID string) ([]string, error)
- func (s *ChunkStore) SetEmbeddingID(ctx context.Context, chunkID, embeddingID string) error
- type ChunkingStrategy
- type CompactionRecord
- type CompactionStore
- func (s *CompactionStore) Create(ctx context.Context, summaryChunkID string, sourceChunkIDs []string, ...) (*CompactionRecord, error)
- func (s *CompactionStore) Delete(ctx context.Context, id string) error
- func (s *CompactionStore) GetBySummaryChunkID(ctx context.Context, summaryChunkID string) (*CompactionRecord, error)
- func (s *CompactionStore) ListByDocument(ctx context.Context, documentID string) ([]*CompactionRecord, error)
- type DBTX
- type Document
- type DocumentContent
- type DocumentStore
- func (s *DocumentStore) Create(ctx context.Context, topicID, slug, name, docType string, ...) (*Document, error)
- func (s *DocumentStore) CreateWithStatus(ctx context.Context, topicID, slug, name, docType, docStatus string, ...) (*Document, error)
- func (s *DocumentStore) Delete(ctx context.Context, id string) error
- func (s *DocumentStore) Get(ctx context.Context, id string) (*Document, error)
- func (s *DocumentStore) GetContent(ctx context.Context, docID string) (*DocumentContent, error)
- func (s *DocumentStore) GetMultiple(ctx context.Context, ids []string) (map[string]*Document, error)
- func (s *DocumentStore) ListByTopic(ctx context.Context, topicID string) ([]Document, error)
- func (s *DocumentStore) SaveContent(ctx context.Context, docID string, rawContent []byte, contentType string) error
- func (s *DocumentStore) SaveExtractedText(ctx context.Context, docID, text string) error
- func (s *DocumentStore) TopicIDForDocument(ctx context.Context, docID string) (string, error)
- func (s *DocumentStore) Update(ctx context.Context, id, name, docType string, metadata map[string]any, ...) (*Document, error)
- func (s *DocumentStore) UpdateStatus(ctx context.Context, id, status string) error
- type EmbeddingConfig
- type EmbeddingConfigStore
- func (s *EmbeddingConfigStore) Create(ctx context.Context, name, provider, model string, dimensions int, ...) (*EmbeddingConfig, error)
- func (s *EmbeddingConfigStore) Delete(ctx context.Context, id string) error
- func (s *EmbeddingConfigStore) Get(ctx context.Context, id string) (*EmbeddingConfig, error)
- func (s *EmbeddingConfigStore) GetDefault(ctx context.Context) (*EmbeddingConfig, error)
- func (s *EmbeddingConfigStore) List(ctx context.Context) ([]EmbeddingConfig, error)
- func (s *EmbeddingConfigStore) SetDefault(ctx context.Context, id string) (*EmbeddingConfig, error)
- func (s *EmbeddingConfigStore) Update(ctx context.Context, id, name, apiKeyConfigID string) (*EmbeddingConfig, error)
- type EntityStats
- type ExtractionPromptConfig
- type ExtractionPromptConfigStore
- func (s *ExtractionPromptConfigStore) Create(ctx context.Context, name, prompt, description string, isDefault bool) (*ExtractionPromptConfig, error)
- func (s *ExtractionPromptConfigStore) Delete(ctx context.Context, id string) error
- func (s *ExtractionPromptConfigStore) Get(ctx context.Context, id string) (*ExtractionPromptConfig, error)
- func (s *ExtractionPromptConfigStore) GetDefault(ctx context.Context) (*ExtractionPromptConfig, error)
- func (s *ExtractionPromptConfigStore) List(ctx context.Context) ([]ExtractionPromptConfig, error)
- func (s *ExtractionPromptConfigStore) SetDefault(ctx context.Context, id string) (*ExtractionPromptConfig, error)
- func (s *ExtractionPromptConfigStore) Update(ctx context.Context, id, name, prompt, description string) (*ExtractionPromptConfig, error)
- type GrantStore
- type JobStore
- func (s *JobStore) ClaimNext(ctx context.Context, jobType string) (*ProcessingJob, error)
- func (s *JobStore) Create(ctx context.Context, documentID, jobType string) (*ProcessingJob, error)
- func (s *JobStore) CreateDocless(ctx context.Context, jobType string, progress map[string]any) (*ProcessingJob, error)
- func (s *JobStore) CreateWithProgress(ctx context.Context, documentID, jobType string, progress map[string]any) (*ProcessingJob, error)
- func (s *JobStore) Get(ctx context.Context, id string) (*ProcessingJob, error)
- func (s *JobStore) List(ctx context.Context, opts ListJobsOptions) ([]*ProcessingJob, error)
- func (s *JobStore) ListByTopicID(ctx context.Context, topicID string, opts ListJobsOptions) ([]*ProcessingJob, error)
- func (s *JobStore) UpdateStatus(ctx context.Context, id, status string, errorMsg *string) error
- type LLMConfig
- type LLMConfigStore
- func (s *LLMConfigStore) Create(ctx context.Context, name, provider, model string, params map[string]string, ...) (*LLMConfig, error)
- func (s *LLMConfigStore) Delete(ctx context.Context, id string) error
- func (s *LLMConfigStore) Get(ctx context.Context, id string) (*LLMConfig, error)
- func (s *LLMConfigStore) GetDefault(ctx context.Context) (*LLMConfig, error)
- func (s *LLMConfigStore) List(ctx context.Context) ([]LLMConfig, error)
- func (s *LLMConfigStore) SetDefault(ctx context.Context, id string) (*LLMConfig, error)
- func (s *LLMConfigStore) Update(ctx context.Context, id, name, provider, model string, ...) (*LLMConfig, error)
- type Link
- type LinkStore
- func (s *LinkStore) Create(ctx context.Context, sourceChunkID, targetChunkID, linkType, createdBy string, ...) (*Link, error)
- func (s *LinkStore) Delete(ctx context.Context, id string) error
- func (s *LinkStore) DeleteByChunk(ctx context.Context, chunkID string) error
- func (s *LinkStore) Get(ctx context.Context, id string) (*Link, error)
- func (s *LinkStore) ListByChunk(ctx context.Context, chunkID string, includeBacklinks bool) ([]*Link, error)
- func (s *LinkStore) ListByChunks(ctx context.Context, chunkIDs []string) ([]*Link, error)
- func (s *LinkStore) TransferLinks(ctx context.Context, oldChunkID, newChunkID string) (int64, error)
- type ListJobsOptions
- type Memory
- type MemoryStore
- func (s *MemoryStore) Create(ctx context.Context, m *Memory) (*Memory, error)
- func (s *MemoryStore) Get(ctx context.Context, id string) (*Memory, error)
- func (s *MemoryStore) GetByScope(ctx context.Context, principal, scope string) ([]*Memory, error)
- func (s *MemoryStore) GetByScopes(ctx context.Context, principal string, scopes []string) ([]*Memory, error)
- func (s *MemoryStore) GetMultiple(ctx context.Context, ids []string) (map[string]*Memory, error)
- func (s *MemoryStore) Invalidate(ctx context.Context, id string) error
- func (s *MemoryStore) ListByScope(ctx context.Context, principal, scope string, includeInvalidated bool) ([]*Memory, error)
- func (s *MemoryStore) ListScopes(ctx context.Context, principal string) ([]string, error)
- func (s *MemoryStore) Update(ctx context.Context, id string, content string, metadata map[string]any) (*Memory, error)
- type ProcessingJob
- type StatsStore
- type SystemAccount
- type SystemAccountKey
- type SystemAccountStore
- func (s *SystemAccountStore) Create(ctx context.Context, name, description string) (*SystemAccount, string, error)
- func (s *SystemAccountStore) Delete(ctx context.Context, id string) error
- func (s *SystemAccountStore) List(ctx context.Context) ([]SystemAccount, error)
- func (s *SystemAccountStore) LookupKeyHash(ctx context.Context, hash string) (*auth.Principal, error)
- func (s *SystemAccountStore) RevokeKey(ctx context.Context, accountID string) error
- func (s *SystemAccountStore) RotateKey(ctx context.Context, accountID string, gracePeriod time.Duration) (string, error)
- type Topic
- type TopicGrant
- type TopicStore
- func (s *TopicStore) Create(ctx context.Context, slug, name, description, owner string, ...) (*Topic, error)
- func (s *TopicStore) Delete(ctx context.Context, id string) error
- func (s *TopicStore) Get(ctx context.Context, id string) (*Topic, error)
- func (s *TopicStore) Grant(ctx context.Context, topicID, principal, permission, grantedBy string) (*TopicGrant, error)
- func (s *TopicStore) ListForPrincipals(ctx context.Context, principals []string) ([]Topic, error)
- func (s *TopicStore) ListGrants(ctx context.Context, topicID string) ([]TopicGrant, error)
- func (s *TopicStore) Revoke(ctx context.Context, topicID, principal string) error
- func (s *TopicStore) Update(ctx context.Context, id, name, description string, ...) (*Topic, error)
- type VectorBackendConfig
- type VectorBackendConfigStore
- func (s *VectorBackendConfigStore) Create(ctx context.Context, name, backend string, config map[string]any, ...) (*VectorBackendConfig, error)
- func (s *VectorBackendConfigStore) Delete(ctx context.Context, id string) error
- func (s *VectorBackendConfigStore) Get(ctx context.Context, id string) (*VectorBackendConfig, error)
- func (s *VectorBackendConfigStore) GetDefault(ctx context.Context) (*VectorBackendConfig, error)
- func (s *VectorBackendConfigStore) List(ctx context.Context) ([]VectorBackendConfig, error)
- func (s *VectorBackendConfigStore) SetDefault(ctx context.Context, id string) (*VectorBackendConfig, error)
- func (s *VectorBackendConfigStore) Update(ctx context.Context, id, name string, config map[string]any) (*VectorBackendConfig, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureSchema ¶ added in v0.1.4
EnsureSchema creates the given schema if it does not already exist. It opens a one-shot connection to baseURL (which should not include search_path), validates the schema name, runs CREATE SCHEMA IF NOT EXISTS, and closes the connection.
func RunMigrations ¶
RunMigrations applies all pending database migrations.
Types ¶
type APIKeyConfig ¶ added in v0.1.5
type APIKeyConfig struct {
ID string
Name string
Provider string
IsDefault bool
CreatedAt time.Time
UpdatedAt time.Time
}
APIKeyConfig represents a stored API key configuration.
type APIKeyConfigStore ¶ added in v0.1.5
type APIKeyConfigStore struct {
// contains filtered or unexported fields
}
APIKeyConfigStore handles API key configuration persistence.
func NewAPIKeyConfigStore ¶ added in v0.1.5
func NewAPIKeyConfigStore(pool DBTX, encryptor *crypto.Encryptor) *APIKeyConfigStore
NewAPIKeyConfigStore creates a new API key config store.
func (*APIKeyConfigStore) Create ¶ added in v0.1.5
func (s *APIKeyConfigStore) Create(ctx context.Context, name, provider string, apiKey []byte, isDefault bool) (*APIKeyConfig, error)
Create inserts a new API key config with the key encrypted at rest.
func (*APIKeyConfigStore) Delete ¶ added in v0.1.5
func (s *APIKeyConfigStore) Delete(ctx context.Context, id string) error
Delete removes an API key config by ID.
func (*APIKeyConfigStore) Get ¶ added in v0.1.5
func (s *APIKeyConfigStore) Get(ctx context.Context, id string) (*APIKeyConfig, error)
Get retrieves an API key config by ID (without the decrypted key).
func (*APIKeyConfigStore) GetDecrypted ¶ added in v0.1.5
GetDecrypted retrieves the decrypted API key for server-side use.
func (*APIKeyConfigStore) List ¶ added in v0.1.5
func (s *APIKeyConfigStore) List(ctx context.Context) ([]APIKeyConfig, error)
List returns all API key configs (without decrypted keys).
func (*APIKeyConfigStore) SetDefault ¶ added in v0.1.5
func (s *APIKeyConfigStore) SetDefault(ctx context.Context, id string) (*APIKeyConfig, error)
SetDefault marks the given config as the default, clearing any previous default.
func (*APIKeyConfigStore) Update ¶ added in v0.1.5
func (s *APIKeyConfigStore) Update(ctx context.Context, id, name, provider string, apiKey []byte) (*APIKeyConfig, error)
Update modifies an API key config. If apiKey is non-nil, the key is re-encrypted.
type Chunk ¶
type Chunk struct {
ID string
DocumentID string
Sequence int
Content string
EmbeddingID *string
Status string
CompactedBy *string
Metadata map[string]any
CreatedAt time.Time
EmbeddingModel string // from chunk_embeddings.metadata; not stored in chunks table
}
Chunk represents a stored chunk.
type ChunkStore ¶
type ChunkStore struct {
// contains filtered or unexported fields
}
ChunkStore handles chunk persistence.
func NewChunkStore ¶
func NewChunkStore(pool DBTX) *ChunkStore
NewChunkStore creates a new chunk store.
func (*ChunkStore) ChunkIDsByTopics ¶
func (s *ChunkStore) ChunkIDsByTopics(ctx context.Context, topicIDs []string, excludeDocIDs []string) ([]string, error)
ChunkIDsByTopics returns all active chunk IDs belonging to the given topics.
func (*ChunkStore) Create ¶
func (s *ChunkStore) Create(ctx context.Context, documentID, content string, sequence int, metadata map[string]any) (*Chunk, error)
Create inserts a new chunk and returns it.
func (*ChunkStore) Delete ¶
func (s *ChunkStore) Delete(ctx context.Context, id string) error
Delete removes a chunk.
func (*ChunkStore) DocumentTopicID ¶
DocumentTopicID returns the topic ID for a chunk's document.
func (*ChunkStore) DocumentTopicIDs ¶
func (s *ChunkStore) DocumentTopicIDs(ctx context.Context, docIDs []string) (map[string]string, error)
DocumentTopicIDs returns a mapping of document ID to topic ID for the given documents.
func (*ChunkStore) GetEmbeddingModels ¶ added in v0.7.1
func (s *ChunkStore) GetEmbeddingModels(ctx context.Context, chunkIDs []string) (map[string]string, error)
GetEmbeddingModels returns a map of chunk ID to embedding model name by reading the embedding_model key from chunk_embeddings.metadata.
func (*ChunkStore) GetMultiple ¶
GetMultiple retrieves multiple chunks by ID in a single query.
func (*ChunkStore) ListByDocument ¶ added in v0.1.4
func (s *ChunkStore) ListByDocument(ctx context.Context, documentID string, lastN int, since time.Time) ([]*Chunk, error)
ListByDocument returns active chunks for a document in sequence order. If lastN > 0, returns only the last N chunks (ordered ascending by sequence). If since is non-zero, only returns chunks created at or after that time.
func (*ChunkStore) MarkCompacted ¶ added in v0.5.0
func (s *ChunkStore) MarkCompacted(ctx context.Context, chunkIDs []string, summaryChunkID string) error
MarkCompacted sets chunks to compacted status, recording which summary chunk replaced them.
func (*ChunkStore) NextSequence ¶ added in v0.5.0
NextSequence returns the next available sequence number for a document's chunks.
func (*ChunkStore) RestoreCompacted ¶ added in v0.5.0
RestoreCompacted reactivates chunks that were compacted by the given summary chunk. Returns the IDs of the restored chunks.
func (*ChunkStore) SetEmbeddingID ¶
func (s *ChunkStore) SetEmbeddingID(ctx context.Context, chunkID, embeddingID string) error
SetEmbeddingID updates the embedding_id for a chunk.
type ChunkingStrategy ¶ added in v0.2.0
type ChunkingStrategy struct {
Type string `json:"type,omitempty"`
ChunkSize int `json:"chunk_size"`
ChunkOverlap int `json:"chunk_overlap"`
}
ChunkingStrategy configures how documents in a topic are chunked. Type can be "fixed" (default) or "semantic". When "semantic", the chunking worker uses an LLM to identify natural split points in the text.
type CompactionRecord ¶ added in v0.5.0
type CompactionRecord struct {
ID string
SummaryChunkID string
SourceChunkIDs []string
DocumentID string
CreatedBy string
CreatedAt time.Time
}
CompactionRecord tracks which source chunks were compacted into a summary chunk.
type CompactionStore ¶ added in v0.5.0
type CompactionStore struct {
// contains filtered or unexported fields
}
CompactionStore handles compaction record persistence.
func NewCompactionStore ¶ added in v0.5.0
func NewCompactionStore(pool DBTX) *CompactionStore
NewCompactionStore creates a new compaction store.
func (*CompactionStore) Create ¶ added in v0.5.0
func (s *CompactionStore) Create(ctx context.Context, summaryChunkID string, sourceChunkIDs []string, documentID, createdBy string) (*CompactionRecord, error)
Create inserts a compaction record.
func (*CompactionStore) Delete ¶ added in v0.5.0
func (s *CompactionStore) Delete(ctx context.Context, id string) error
Delete removes a compaction record.
func (*CompactionStore) GetBySummaryChunkID ¶ added in v0.5.0
func (s *CompactionStore) GetBySummaryChunkID(ctx context.Context, summaryChunkID string) (*CompactionRecord, error)
GetBySummaryChunkID retrieves a compaction record by the summary chunk it produced.
func (*CompactionStore) ListByDocument ¶ added in v0.5.0
func (s *CompactionStore) ListByDocument(ctx context.Context, documentID string) ([]*CompactionRecord, error)
ListByDocument returns all compaction records for a document.
type DBTX ¶
type DBTX interface {
Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)
Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
Begin(ctx context.Context) (pgx.Tx, error)
}
DBTX is the interface satisfied by *pgxpool.Pool and *pgx.Tx. All stores accept this instead of a concrete pool so that a QueryCounter (or transaction) can be substituted in tests.
type Document ¶
type Document struct {
ID string
TopicID string
Slug string
Name string
DocType string
Status string
Metadata map[string]any
CreatedAt time.Time
UpdatedAt time.Time
URL *string
Author *string
PublishedAt *time.Time
}
Document represents a stored document.
type DocumentContent ¶ added in v0.2.0
type DocumentContent struct {
DocumentID string
RawContent []byte
ContentType string
ExtractedText string
CreatedAt time.Time
UpdatedAt time.Time
}
DocumentContent holds raw uploaded content and extracted text for a document.
type DocumentStore ¶
type DocumentStore struct {
// contains filtered or unexported fields
}
DocumentStore handles document persistence.
func NewDocumentStore ¶
func NewDocumentStore(pool DBTX) *DocumentStore
NewDocumentStore creates a new document store.
func (*DocumentStore) Create ¶
func (s *DocumentStore) Create(ctx context.Context, topicID, slug, name, docType string, metadata map[string]any, url, author *string, publishedAt *time.Time) (*Document, error)
Create inserts a new document.
func (*DocumentStore) CreateWithStatus ¶ added in v0.2.0
func (s *DocumentStore) CreateWithStatus(ctx context.Context, topicID, slug, name, docType, docStatus string, metadata map[string]any, url, author *string, publishedAt *time.Time) (*Document, error)
CreateWithStatus inserts a new document with an explicit status.
func (*DocumentStore) Delete ¶
func (s *DocumentStore) Delete(ctx context.Context, id string) error
Delete removes a document and cascades to chunks.
func (*DocumentStore) GetContent ¶ added in v0.2.0
func (s *DocumentStore) GetContent(ctx context.Context, docID string) (*DocumentContent, error)
GetContent retrieves raw content for a document.
func (*DocumentStore) GetMultiple ¶ added in v0.2.0
func (s *DocumentStore) GetMultiple(ctx context.Context, ids []string) (map[string]*Document, error)
GetMultiple retrieves multiple documents by ID in a single query.
func (*DocumentStore) ListByTopic ¶
ListByTopic returns documents in a topic.
func (*DocumentStore) SaveContent ¶ added in v0.2.0
func (s *DocumentStore) SaveContent(ctx context.Context, docID string, rawContent []byte, contentType string) error
SaveContent stores raw content and content type for a document.
func (*DocumentStore) SaveExtractedText ¶ added in v0.2.0
func (s *DocumentStore) SaveExtractedText(ctx context.Context, docID, text string) error
SaveExtractedText stores extracted text for a document.
func (*DocumentStore) TopicIDForDocument ¶
TopicIDForDocument returns the topic ID that owns the given document.
func (*DocumentStore) Update ¶
func (s *DocumentStore) Update(ctx context.Context, id, name, docType string, metadata map[string]any, url, author *string, publishedAt *time.Time) (*Document, error)
Update modifies a document's mutable fields.
func (*DocumentStore) UpdateStatus ¶ added in v0.2.0
func (s *DocumentStore) UpdateStatus(ctx context.Context, id, status string) error
UpdateStatus sets the status of a document.
type EmbeddingConfig ¶ added in v0.1.5
type EmbeddingConfig struct {
ID string
Name string
Provider string
Model string
Dimensions int
APIKeyConfigID string
IsDefault bool
CreatedAt time.Time
UpdatedAt time.Time
}
EmbeddingConfig represents a stored embedding configuration.
type EmbeddingConfigStore ¶ added in v0.1.5
type EmbeddingConfigStore struct {
// contains filtered or unexported fields
}
EmbeddingConfigStore handles embedding configuration persistence.
func NewEmbeddingConfigStore ¶ added in v0.1.5
func NewEmbeddingConfigStore(pool DBTX) *EmbeddingConfigStore
NewEmbeddingConfigStore creates a new embedding config store.
func (*EmbeddingConfigStore) Create ¶ added in v0.1.5
func (s *EmbeddingConfigStore) Create(ctx context.Context, name, provider, model string, dimensions int, apiKeyConfigID string, isDefault bool) (*EmbeddingConfig, error)
Create inserts a new embedding config.
func (*EmbeddingConfigStore) Delete ¶ added in v0.1.5
func (s *EmbeddingConfigStore) Delete(ctx context.Context, id string) error
Delete removes an embedding config by ID.
func (*EmbeddingConfigStore) Get ¶ added in v0.1.5
func (s *EmbeddingConfigStore) Get(ctx context.Context, id string) (*EmbeddingConfig, error)
Get retrieves an embedding config by ID.
func (*EmbeddingConfigStore) GetDefault ¶ added in v0.1.5
func (s *EmbeddingConfigStore) GetDefault(ctx context.Context) (*EmbeddingConfig, error)
GetDefault returns the default embedding config, or nil if none is set.
func (*EmbeddingConfigStore) List ¶ added in v0.1.5
func (s *EmbeddingConfigStore) List(ctx context.Context) ([]EmbeddingConfig, error)
List returns all embedding configs.
func (*EmbeddingConfigStore) SetDefault ¶ added in v0.1.5
func (s *EmbeddingConfigStore) SetDefault(ctx context.Context, id string) (*EmbeddingConfig, error)
SetDefault marks the given config as the default, clearing any previous default.
func (*EmbeddingConfigStore) Update ¶ added in v0.1.5
func (s *EmbeddingConfigStore) Update(ctx context.Context, id, name, apiKeyConfigID string) (*EmbeddingConfig, error)
Update modifies an embedding config. Only name and api_key_config_id can be changed.
type EntityStats ¶ added in v0.7.1
type EntityStats struct {
APIKeyConfigs int64
LLMConfigs int64
EmbeddingConfigs int64
ExtractionPromptConfigs int64
Topics int64
SystemAccounts int64
Documents int64
Chunks int64
Memories int64
}
EntityStats holds row counts for all major entity tables.
type ExtractionPromptConfig ¶ added in v0.1.5
type ExtractionPromptConfig struct {
ID string
Name string
Prompt string
Description string
IsDefault bool
CreatedAt time.Time
UpdatedAt time.Time
}
ExtractionPromptConfig represents a stored extraction prompt configuration.
type ExtractionPromptConfigStore ¶ added in v0.1.5
type ExtractionPromptConfigStore struct {
// contains filtered or unexported fields
}
ExtractionPromptConfigStore handles extraction prompt configuration persistence.
func NewExtractionPromptConfigStore ¶ added in v0.1.5
func NewExtractionPromptConfigStore(pool DBTX) *ExtractionPromptConfigStore
NewExtractionPromptConfigStore creates a new extraction prompt config store.
func (*ExtractionPromptConfigStore) Create ¶ added in v0.1.5
func (s *ExtractionPromptConfigStore) Create(ctx context.Context, name, prompt, description string, isDefault bool) (*ExtractionPromptConfig, error)
Create inserts a new extraction prompt config.
func (*ExtractionPromptConfigStore) Delete ¶ added in v0.1.5
func (s *ExtractionPromptConfigStore) Delete(ctx context.Context, id string) error
Delete removes an extraction prompt config by ID.
func (*ExtractionPromptConfigStore) Get ¶ added in v0.1.5
func (s *ExtractionPromptConfigStore) Get(ctx context.Context, id string) (*ExtractionPromptConfig, error)
Get retrieves an extraction prompt config by ID.
func (*ExtractionPromptConfigStore) GetDefault ¶ added in v0.1.5
func (s *ExtractionPromptConfigStore) GetDefault(ctx context.Context) (*ExtractionPromptConfig, error)
GetDefault returns the default extraction prompt config, or nil if none is set.
func (*ExtractionPromptConfigStore) List ¶ added in v0.1.5
func (s *ExtractionPromptConfigStore) List(ctx context.Context) ([]ExtractionPromptConfig, error)
List returns all extraction prompt configs.
func (*ExtractionPromptConfigStore) SetDefault ¶ added in v0.1.5
func (s *ExtractionPromptConfigStore) SetDefault(ctx context.Context, id string) (*ExtractionPromptConfig, error)
SetDefault marks the given config as the default, clearing any previous default.
func (*ExtractionPromptConfigStore) Update ¶ added in v0.1.5
func (s *ExtractionPromptConfigStore) Update(ctx context.Context, id, name, prompt, description string) (*ExtractionPromptConfig, error)
Update modifies an extraction prompt config.
type GrantStore ¶
type GrantStore struct {
// contains filtered or unexported fields
}
GrantStore provides access to topic grants and ownership from PostgreSQL.
func NewGrantStore ¶
func NewGrantStore(pool DBTX) *GrantStore
NewGrantStore creates a new grant store.
func (*GrantStore) GrantsForPrincipal ¶
func (s *GrantStore) GrantsForPrincipal(ctx context.Context, principals []string) ([]auth.Grant, error)
GrantsForPrincipal returns all grants matching any of the given principals.
func (*GrantStore) TopicIDsByOwner ¶ added in v0.2.1
TopicIDsByOwner returns the IDs of all topics owned by the given principal.
func (*GrantStore) TopicOwner ¶
TopicOwner returns the owner of the given topic.
type JobStore ¶ added in v0.2.0
type JobStore struct {
// contains filtered or unexported fields
}
JobStore handles processing job persistence.
func NewJobStore ¶ added in v0.2.0
NewJobStore creates a new job store.
func (*JobStore) ClaimNext ¶ added in v0.2.0
ClaimNext atomically finds and claims the next queued job of the given type. Uses FOR UPDATE SKIP LOCKED for safe concurrent polling. Returns nil, nil when no jobs are available.
func (*JobStore) CreateDocless ¶ added in v0.8.0
func (s *JobStore) CreateDocless(ctx context.Context, jobType string, progress map[string]any) (*ProcessingJob, error)
CreateDocless inserts a new queued job without a document (document_id = NULL). Used for jobs that are not tied to a specific document, such as memory maintenance triggered by direct AddMemory calls.
func (*JobStore) CreateWithProgress ¶ added in v0.2.0
func (s *JobStore) CreateWithProgress(ctx context.Context, documentID, jobType string, progress map[string]any) (*ProcessingJob, error)
CreateWithProgress inserts a new queued processing job with initial progress data.
func (*JobStore) List ¶ added in v0.2.0
func (s *JobStore) List(ctx context.Context, opts ListJobsOptions) ([]*ProcessingJob, error)
List returns processing jobs matching the given filters.
func (*JobStore) ListByTopicID ¶ added in v0.2.0
func (s *JobStore) ListByTopicID(ctx context.Context, topicID string, opts ListJobsOptions) ([]*ProcessingJob, error)
ListByTopicID returns processing jobs for documents in the given topic.
func (*JobStore) UpdateStatus ¶ added in v0.2.0
UpdateStatus sets the status of a job. When transitioning to "running", started_at is set. When transitioning to "completed" or "failed", completed_at is set. If errorMsg is non-nil, the error field is set.
type LLMConfig ¶ added in v0.1.5
type LLMConfig struct {
ID string
Name string
Provider string
Model string
Parameters map[string]string
APIKeyConfigID string
IsDefault bool
CreatedAt time.Time
UpdatedAt time.Time
}
LLMConfig represents a stored LLM configuration.
type LLMConfigStore ¶ added in v0.1.5
type LLMConfigStore struct {
// contains filtered or unexported fields
}
LLMConfigStore handles LLM configuration persistence.
func NewLLMConfigStore ¶ added in v0.1.5
func NewLLMConfigStore(pool DBTX) *LLMConfigStore
NewLLMConfigStore creates a new LLM config store.
func (*LLMConfigStore) Create ¶ added in v0.1.5
func (s *LLMConfigStore) Create(ctx context.Context, name, provider, model string, params map[string]string, apiKeyConfigID string, isDefault bool) (*LLMConfig, error)
Create inserts a new LLM config.
func (*LLMConfigStore) Delete ¶ added in v0.1.5
func (s *LLMConfigStore) Delete(ctx context.Context, id string) error
Delete removes an LLM config by ID.
func (*LLMConfigStore) GetDefault ¶ added in v0.1.5
func (s *LLMConfigStore) GetDefault(ctx context.Context) (*LLMConfig, error)
GetDefault returns the default LLM config, or nil if none is set.
func (*LLMConfigStore) List ¶ added in v0.1.5
func (s *LLMConfigStore) List(ctx context.Context) ([]LLMConfig, error)
List returns all LLM configs.
func (*LLMConfigStore) SetDefault ¶ added in v0.1.5
SetDefault marks the given config as the default, clearing any previous default.
type Link ¶ added in v0.4.0
type Link struct {
ID string
SourceChunkID string
TargetChunkID string
LinkType string
CreatedBy string
Metadata map[string]any
CreatedAt time.Time
}
Link represents a stored link between two chunks.
type LinkStore ¶ added in v0.4.0
type LinkStore struct {
// contains filtered or unexported fields
}
LinkStore handles link persistence.
func NewLinkStore ¶ added in v0.4.0
NewLinkStore creates a new link store.
func (*LinkStore) Create ¶ added in v0.4.0
func (s *LinkStore) Create(ctx context.Context, sourceChunkID, targetChunkID, linkType, createdBy string, metadata map[string]any) (*Link, error)
Create inserts a new link and returns it.
func (*LinkStore) DeleteByChunk ¶ added in v0.4.0
DeleteByChunk removes all links where the given chunk is source or target.
func (*LinkStore) ListByChunk ¶ added in v0.4.0
func (s *LinkStore) ListByChunk(ctx context.Context, chunkID string, includeBacklinks bool) ([]*Link, error)
ListByChunk returns links where the given chunk is the source. If includeBacklinks is true, also returns links where the chunk is the target.
func (*LinkStore) ListByChunks ¶ added in v0.4.0
ListByChunks returns all links where any of the given chunk IDs is a source or target. Used for batch link retrieval during search result hydration.
type ListJobsOptions ¶ added in v0.2.0
type ListJobsOptions struct {
DocumentID string
Status string
PageSize int
PageToken string // job ID for keyset pagination
}
ListJobsOptions controls filtering and pagination for job listing.
type Memory ¶ added in v0.2.0
type Memory struct {
ID string
Principal string
Scope string
Content string
EmbeddingID *string
Subject *string
Predicate *string
Object *string
SourceChunkID *string
Status string
InvalidatedAt *time.Time
Metadata map[string]any
CreatedAt time.Time
UpdatedAt time.Time
}
Memory represents a stored memory.
type MemoryStore ¶ added in v0.2.0
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore handles memory persistence.
func NewMemoryStore ¶ added in v0.2.0
func NewMemoryStore(pool DBTX) *MemoryStore
NewMemoryStore creates a new memory store.
func (*MemoryStore) GetByScope ¶ added in v0.2.0
GetByScope returns all active memories for a principal in a scope.
func (*MemoryStore) GetByScopes ¶ added in v0.8.0
func (s *MemoryStore) GetByScopes(ctx context.Context, principal string, scopes []string) ([]*Memory, error)
GetByScopes returns all active memories for a principal, optionally filtered by scopes. When scopes is nil or empty, returns all active memories across all scopes.
func (*MemoryStore) GetMultiple ¶ added in v0.2.0
GetMultiple retrieves multiple memories by ID in a single query.
func (*MemoryStore) Invalidate ¶ added in v0.2.0
func (s *MemoryStore) Invalidate(ctx context.Context, id string) error
Invalidate soft-deletes a memory by setting status to invalidated.
func (*MemoryStore) ListByScope ¶ added in v0.2.0
func (s *MemoryStore) ListByScope(ctx context.Context, principal, scope string, includeInvalidated bool) ([]*Memory, error)
ListByScope returns memories for a principal in a scope, optionally including invalidated ones.
func (*MemoryStore) ListScopes ¶ added in v0.2.0
ListScopes returns distinct scopes for a principal.
type ProcessingJob ¶ added in v0.2.0
type ProcessingJob struct {
ID string
DocumentID string
JobType string
Status string
Progress map[string]any
Error *string
StartedAt *time.Time
CompletedAt *time.Time
CreatedAt time.Time
}
ProcessingJob represents a background processing job.
type StatsStore ¶ added in v0.7.1
type StatsStore struct {
// contains filtered or unexported fields
}
StatsStore provides aggregate statistics from the database.
func NewStatsStore ¶ added in v0.7.1
func NewStatsStore(pool DBTX) *StatsStore
NewStatsStore creates a new StatsStore.
func (*StatsStore) GetStats ¶ added in v0.7.1
func (s *StatsStore) GetStats(ctx context.Context) (*EntityStats, error)
GetStats returns row counts for all major entity tables in a single query.
type SystemAccount ¶
type SystemAccount struct {
ID string
Name string
Description string
Principal string
CreatedAt time.Time
}
SystemAccount represents a stored system account.
type SystemAccountKey ¶
type SystemAccountKey struct {
ID string
AccountID string
KeyHash string
KeyPrefix string
Status string // "active", "grace_period", "revoked"
GraceExpiresAt *time.Time
CreatedAt time.Time
RevokedAt *time.Time
}
SystemAccountKey represents a stored API key.
type SystemAccountStore ¶
type SystemAccountStore struct {
// contains filtered or unexported fields
}
SystemAccountStore handles system account and key persistence.
func NewSystemAccountStore ¶
func NewSystemAccountStore(pool DBTX) *SystemAccountStore
NewSystemAccountStore creates a new store backed by the given pool.
func (*SystemAccountStore) Create ¶
func (s *SystemAccountStore) Create(ctx context.Context, name, description string) (*SystemAccount, string, error)
Create inserts a new system account and its initial key. Returns the account and the raw API key (shown once).
func (*SystemAccountStore) Delete ¶
func (s *SystemAccountStore) Delete(ctx context.Context, id string) error
Delete removes a system account and cascades to its keys.
func (*SystemAccountStore) List ¶
func (s *SystemAccountStore) List(ctx context.Context) ([]SystemAccount, error)
List returns all system accounts.
func (*SystemAccountStore) LookupKeyHash ¶
func (s *SystemAccountStore) LookupKeyHash(ctx context.Context, hash string) (*auth.Principal, error)
LookupKeyHash implements auth.KeyLookup. It resolves a key hash to a principal by checking active and grace-period keys.
func (*SystemAccountStore) RevokeKey ¶
func (s *SystemAccountStore) RevokeKey(ctx context.Context, accountID string) error
RevokeKey immediately revokes all active keys for the account.
func (*SystemAccountStore) RotateKey ¶
func (s *SystemAccountStore) RotateKey(ctx context.Context, accountID string, gracePeriod time.Duration) (string, error)
RotateKey generates a new key for the account. If gracePeriod > 0, old active keys enter grace period; otherwise they are revoked immediately.
type Topic ¶
type Topic struct {
ID string
Slug string
Name string
Description string
Owner string
CreatedAt time.Time
UpdatedAt time.Time
LLMConfigID *string
EmbeddingConfigID *string
ExtractionPromptConfigID *string
ChunkingStrategy *ChunkingStrategy
VectorBackendConfigID *string
}
Topic represents a stored topic.
type TopicGrant ¶
type TopicGrant struct {
ID string
TopicID string
Principal string
Permission string
GrantedBy string
CreatedAt time.Time
}
TopicGrant represents a stored topic grant.
type TopicStore ¶
type TopicStore struct {
// contains filtered or unexported fields
}
TopicStore handles topic and grant persistence.
func NewTopicStore ¶
func NewTopicStore(pool DBTX) *TopicStore
NewTopicStore creates a new topic store.
func (*TopicStore) Create ¶
func (s *TopicStore) Create(ctx context.Context, slug, name, description, owner string, llmConfigID, embeddingConfigID, extractionPromptConfigID *string, vectorBackendConfigID *string) (*Topic, error)
Create inserts a new topic with optional config IDs.
func (*TopicStore) Delete ¶
func (s *TopicStore) Delete(ctx context.Context, id string) error
Delete removes a topic and cascades to grants, documents, chunks.
func (*TopicStore) Grant ¶
func (s *TopicStore) Grant(ctx context.Context, topicID, principal, permission, grantedBy string) (*TopicGrant, error)
Grant creates or updates a topic grant.
func (*TopicStore) ListForPrincipals ¶
ListForPrincipals returns topics accessible to the given principal identities. If principals is nil, returns all topics (for system accounts).
func (*TopicStore) ListGrants ¶
func (s *TopicStore) ListGrants(ctx context.Context, topicID string) ([]TopicGrant, error)
ListGrants returns all grants for a topic.
type VectorBackendConfig ¶ added in v0.7.0
type VectorBackendConfig struct {
ID string
Name string
Backend string
Config map[string]any
IsDefault bool
CreatedAt time.Time
UpdatedAt time.Time
}
VectorBackendConfig represents a stored vector backend configuration.
type VectorBackendConfigStore ¶ added in v0.7.0
type VectorBackendConfigStore struct {
// contains filtered or unexported fields
}
VectorBackendConfigStore handles vector backend configuration persistence.
func NewVectorBackendConfigStore ¶ added in v0.7.0
func NewVectorBackendConfigStore(pool DBTX) *VectorBackendConfigStore
NewVectorBackendConfigStore creates a new vector backend config store.
func (*VectorBackendConfigStore) Create ¶ added in v0.7.0
func (s *VectorBackendConfigStore) Create(ctx context.Context, name, backend string, config map[string]any, isDefault bool) (*VectorBackendConfig, error)
Create inserts a new vector backend config.
func (*VectorBackendConfigStore) Delete ¶ added in v0.7.0
func (s *VectorBackendConfigStore) Delete(ctx context.Context, id string) error
Delete removes a vector backend config by ID.
func (*VectorBackendConfigStore) Get ¶ added in v0.7.0
func (s *VectorBackendConfigStore) Get(ctx context.Context, id string) (*VectorBackendConfig, error)
Get retrieves a vector backend config by ID.
func (*VectorBackendConfigStore) GetDefault ¶ added in v0.7.0
func (s *VectorBackendConfigStore) GetDefault(ctx context.Context) (*VectorBackendConfig, error)
GetDefault returns the default vector backend config, or nil if none is set. coverage:ignore - tested via integration
func (*VectorBackendConfigStore) List ¶ added in v0.7.0
func (s *VectorBackendConfigStore) List(ctx context.Context) ([]VectorBackendConfig, error)
List returns all vector backend configs.
func (*VectorBackendConfigStore) SetDefault ¶ added in v0.7.0
func (s *VectorBackendConfigStore) SetDefault(ctx context.Context, id string) (*VectorBackendConfig, error)
coverage:ignore - tested via integration SetDefault marks the given config as the default, clearing any previous default.
func (*VectorBackendConfigStore) Update ¶ added in v0.7.0
func (s *VectorBackendConfigStore) Update(ctx context.Context, id, name string, config map[string]any) (*VectorBackendConfig, error)
Update modifies a vector backend config. Only name and config can be changed; the backend type cannot be changed post-creation. coverage:ignore - tested via integration