Documentation
¶
Overview ¶
Package persistence provides database storage implementations.
Index ¶
- Constants
- Variables
- func AutoMigrate(db database.Database) error
- func CosineSimilarity(a, b []float64) float64
- func PreMigrate(db database.Database) error
- func ValidateSchema(db database.Database) error
- type AssociationMapper
- type AssociationStore
- type BranchMapper
- type BranchModel
- type BranchStore
- type CommitMapper
- type CommitModel
- type CommitStore
- type EmbeddingModel
- type EnrichmentAssociationModel
- type EnrichmentMapper
- type EnrichmentModel
- type EnrichmentStore
- func (s EnrichmentStore) Count(ctx context.Context, options ...repository.Option) (int64, error)
- func (s EnrichmentStore) Delete(ctx context.Context, e enrichment.Enrichment) error
- func (s EnrichmentStore) Find(ctx context.Context, options ...repository.Option) ([]enrichment.Enrichment, error)
- func (s EnrichmentStore) Save(ctx context.Context, e enrichment.Enrichment) (enrichment.Enrichment, error)
- type FileMapper
- type FileModel
- type FileStore
- type Filter
- type FilterOperator
- type Float64Slice
- type OrderBy
- type PgEmbeddingModel
- type PipelineMapper
- type PipelineStepMapper
- type PipelineStepStore
- type PipelineStore
- type Query
- func (q Query) Apply(db *gorm.DB) *gorm.DB
- func (q Query) Equal(field string, value any) Query
- func (q Query) Filters() []Filter
- func (q Query) GreaterThan(field string, value any) Query
- func (q Query) GreaterThanOrEqual(field string, value any) Query
- func (q Query) ILike(field string, pattern string) Query
- func (q Query) In(field string, values any) Query
- func (q Query) IsNotNull(field string) Query
- func (q Query) IsNull(field string) Query
- func (q Query) LessThan(field string, value any) Query
- func (q Query) LessThanOrEqual(field string, value any) Query
- func (q Query) Like(field string, pattern string) Query
- func (q Query) Limit(limit int) Query
- func (q Query) LimitValue() int
- func (q Query) NotEqual(field string, value any) Query
- func (q Query) NotIn(field string, values any) Query
- func (q Query) Offset(offset int) Query
- func (q Query) OffsetValue() int
- func (q Query) Order(field string, direction SortDirection) Query
- func (q Query) OrderAsc(field string) Query
- func (q Query) OrderDesc(field string) Query
- func (q Query) Orders() []OrderBy
- func (q Query) Paginate(page, pageSize int) Query
- func (q Query) Where(field string, operator FilterOperator, value any) Query
- func (q Query) WhereBetween(field string, low, high any) Query
- type RepositoryMapper
- type RepositoryModel
- type RepositoryStore
- type SQLiteBM25Store
- type SQLiteEmbeddingModel
- type SQLiteEmbeddingStore
- type SimilarityMatch
- type SortDirection
- type SourceLocationMapper
- type SourceLocationModel
- type SourceLocationStore
- type StatusStore
- type StepDependencyMapper
- type StepDependencyStore
- type StepMapper
- type StepStore
- type StoredVector
- type TagMapper
- type TagModel
- type TagStore
- type TaskMapper
- type TaskModel
- type TaskName
- type TaskStatusMapper
- type TaskStatusModel
- type TaskStore
- func (s TaskStore) Delete(ctx context.Context, t task.Task) error
- func (s TaskStore) Dequeue(ctx context.Context) (task.Task, bool, error)
- func (s TaskStore) DequeueByOperation(ctx context.Context, operation task.Operation) (task.Task, bool, error)
- func (s TaskStore) Save(ctx context.Context, t task.Task) (task.Task, error)
- type VectorChordBM25Store
- func (s *VectorChordBM25Store) DeleteBy(ctx context.Context, options ...repository.Option) error
- func (s *VectorChordBM25Store) Find(ctx context.Context, options ...repository.Option) ([]search.Result, error)
- func (s *VectorChordBM25Store) Index(ctx context.Context, request search.IndexRequest) error
- type VectorChordEmbeddingStore
Constants ¶
const ( TrackingTypeBranch = "branch" TrackingTypeTag = "tag" TrackingTypeCommit = "commit" )
Tracking type constants.
Variables ¶
var ( TaskNameCode = TaskName("code") TaskNameText = TaskName("text") TaskNameVision = TaskName("vision") )
TaskName values.
var ErrBM25InitializationFailed = errors.New("failed to initialize VectorChord BM25 repository")
ErrBM25InitializationFailed indicates VectorChord BM25 initialization failed.
var ErrSQLiteBM25InitializationFailed = errors.New("failed to initialize SQLite FTS5 BM25 store")
ErrSQLiteBM25InitializationFailed indicates SQLite FTS5 initialization failed.
var ErrVectorInitializationFailed = errors.New("failed to initialize VectorChord vector repository")
ErrVectorInitializationFailed indicates VectorChord vector initialization failed.
Functions ¶
func AutoMigrate ¶
AutoMigrate runs GORM auto migration for all models.
func CosineSimilarity ¶
CosineSimilarity computes the cosine similarity between two vectors. Returns a value between -1 (opposite) and 1 (identical). Returns 0 if either vector has zero magnitude.
func PreMigrate ¶
PreMigrate handles one-time schema conversions from the Python-era database. It converts PostgreSQL enum columns to text so GORM AutoMigrate can manage them. Safe to run repeatedly — it checks whether the enum types still exist before acting.
func ValidateSchema ¶
ValidateSchema verifies every GORM model field has a corresponding column in the database. Returns an error listing any missing columns.
Types ¶
type AssociationMapper ¶
type AssociationMapper struct{}
AssociationMapper maps between domain Association and persistence EnrichmentAssociationModel.
func (AssociationMapper) ToDomain ¶
func (m AssociationMapper) ToDomain(e EnrichmentAssociationModel) enrichment.Association
ToDomain converts an EnrichmentAssociationModel to a domain Association.
func (AssociationMapper) ToModel ¶
func (m AssociationMapper) ToModel(a enrichment.Association) EnrichmentAssociationModel
ToModel converts a domain Association to an EnrichmentAssociationModel.
type AssociationStore ¶
type AssociationStore struct {
database.Repository[enrichment.Association, EnrichmentAssociationModel]
}
AssociationStore implements enrichment.AssociationStore using GORM.
func NewAssociationStore ¶
func NewAssociationStore(db database.Database) AssociationStore
NewAssociationStore creates a new AssociationStore.
func (AssociationStore) Delete ¶
func (s AssociationStore) Delete(ctx context.Context, assoc enrichment.Association) error
Delete removes an association.
func (AssociationStore) Save ¶
func (s AssociationStore) Save(ctx context.Context, assoc enrichment.Association) (enrichment.Association, error)
Save creates or updates an association.
type BranchMapper ¶
type BranchMapper struct{}
BranchMapper maps between domain Branch and persistence BranchModel.
func (BranchMapper) ToDomain ¶
func (m BranchMapper) ToDomain(e BranchModel) repository.Branch
ToDomain converts a BranchModel to a domain Branch.
func (BranchMapper) ToModel ¶
func (m BranchMapper) ToModel(b repository.Branch) BranchModel
ToModel converts a domain Branch to a BranchModel.
type BranchModel ¶
type BranchModel struct {
RepoID int64 `gorm:"column:repo_id;primaryKey;index"`
Repo RepositoryModel `gorm:"foreignKey:RepoID;references:ID;constraint:OnDelete:CASCADE"`
Name string `gorm:"column:name;primaryKey;index;size:255"`
HeadCommitSHA string `gorm:"column:head_commit_sha;index;size:64"`
IsDefault bool `gorm:"column:is_default;default:false"`
CreatedAt time.Time `gorm:"column:created_at"`
UpdatedAt time.Time `gorm:"column:updated_at"`
}
BranchModel represents a Git branch in the database.
func (BranchModel) TableName ¶
func (BranchModel) TableName() string
TableName returns the table name.
type BranchStore ¶
type BranchStore struct {
database.Repository[repository.Branch, BranchModel]
}
BranchStore implements repository.BranchStore using GORM.
func NewBranchStore ¶
func NewBranchStore(db database.Database) BranchStore
NewBranchStore creates a new BranchStore.
func (BranchStore) Delete ¶
func (s BranchStore) Delete(ctx context.Context, branch repository.Branch) error
Delete removes a branch.
func (BranchStore) Save ¶
func (s BranchStore) Save(ctx context.Context, branch repository.Branch) (repository.Branch, error)
Save creates or updates a branch.
func (BranchStore) SaveAll ¶
func (s BranchStore) SaveAll(ctx context.Context, branches []repository.Branch) ([]repository.Branch, error)
SaveAll creates or updates multiple branches.
type CommitMapper ¶
type CommitMapper struct{}
CommitMapper maps between domain Commit and persistence CommitModel.
func (CommitMapper) ToDomain ¶
func (m CommitMapper) ToDomain(e CommitModel) repository.Commit
ToDomain converts a CommitModel to a domain Commit.
func (CommitMapper) ToModel ¶
func (m CommitMapper) ToModel(c repository.Commit) CommitModel
ToModel converts a domain Commit to a CommitModel.
type CommitModel ¶
type CommitModel struct {
CommitSHA string `gorm:"column:commit_sha;primaryKey;size:64"`
RepoID int64 `gorm:"column:repo_id;index"`
Repo RepositoryModel `gorm:"foreignKey:RepoID;references:ID;constraint:OnDelete:CASCADE"`
Date time.Time `gorm:"column:date"`
Message string `gorm:"column:message;type:text"`
ParentCommitSHA *string `gorm:"column:parent_commit_sha;index;size:64"`
Author string `gorm:"column:author;index;size:255"`
CreatedAt time.Time `gorm:"column:created_at"`
UpdatedAt time.Time `gorm:"column:updated_at"`
}
CommitModel represents a Git commit in the database.
func (CommitModel) TableName ¶
func (CommitModel) TableName() string
TableName returns the table name.
type CommitStore ¶
type CommitStore struct {
database.Repository[repository.Commit, CommitModel]
}
CommitStore implements repository.CommitStore using GORM.
func NewCommitStore ¶
func NewCommitStore(db database.Database) CommitStore
NewCommitStore creates a new CommitStore.
func (CommitStore) Delete ¶
func (s CommitStore) Delete(ctx context.Context, commit repository.Commit) error
Delete removes a commit.
func (CommitStore) Save ¶
func (s CommitStore) Save(ctx context.Context, commit repository.Commit) (repository.Commit, error)
Save creates or updates a commit.
func (CommitStore) SaveAll ¶
func (s CommitStore) SaveAll(ctx context.Context, commits []repository.Commit) ([]repository.Commit, error)
SaveAll creates or updates multiple commits.
type EmbeddingModel ¶
type EmbeddingModel struct {
ID int64 `gorm:"column:id;primaryKey;autoIncrement"`
SnippetID string `gorm:"column:snippet_id;index"`
Type string `gorm:"column:type;index"`
Embedding []float64 `gorm:"column:embedding;type:json"`
CreatedAt time.Time `gorm:"column:created_at;not null"`
UpdatedAt time.Time `gorm:"column:updated_at;not null"`
}
EmbeddingModel represents a vector embedding in the database.
func (EmbeddingModel) TableName ¶
func (EmbeddingModel) TableName() string
TableName returns the table name.
type EnrichmentAssociationModel ¶
type EnrichmentAssociationModel struct {
ID int64 `gorm:"column:id;primaryKey;autoIncrement"`
EnrichmentID int64 `gorm:"column:enrichment_id;not null;index;uniqueIndex:idx_enrichment_assoc"`
Enrichment EnrichmentModel `gorm:"foreignKey:EnrichmentID;references:ID;constraint:OnDelete:CASCADE"`
EntityType string `gorm:"column:entity_type;size:50;not null;index:idx_enrichment_entity;uniqueIndex:idx_enrichment_assoc"`
EntityID string `gorm:"column:entity_id;size:255;not null;index:idx_enrichment_entity;uniqueIndex:idx_enrichment_assoc"`
CreatedAt time.Time `gorm:"column:created_at;not null"`
UpdatedAt time.Time `gorm:"column:updated_at;not null"`
}
EnrichmentAssociationModel links enrichments to entities.
func (EnrichmentAssociationModel) TableName ¶
func (EnrichmentAssociationModel) TableName() string
TableName returns the table name.
type EnrichmentMapper ¶
type EnrichmentMapper struct{}
EnrichmentMapper maps between domain Enrichment and persistence EnrichmentModel.
func (EnrichmentMapper) ToDomain ¶
func (m EnrichmentMapper) ToDomain(e EnrichmentModel) enrichment.Enrichment
ToDomain converts an EnrichmentModel to a domain Enrichment.
func (EnrichmentMapper) ToModel ¶
func (m EnrichmentMapper) ToModel(e enrichment.Enrichment) EnrichmentModel
ToModel converts a domain Enrichment to an EnrichmentModel.
type EnrichmentModel ¶
type EnrichmentModel struct {
ID int64 `gorm:"column:id;primaryKey;autoIncrement"`
Type string `gorm:"column:type;not null;index"`
Subtype string `gorm:"column:subtype;not null;index"`
Content string `gorm:"column:content;type:text;not null"`
Language string `gorm:"column:language;size:50"`
CreatedAt time.Time `gorm:"column:created_at;not null"`
UpdatedAt time.Time `gorm:"column:updated_at;not null"`
}
EnrichmentModel represents an enrichment in the database.
func (EnrichmentModel) TableName ¶
func (EnrichmentModel) TableName() string
TableName returns the table name.
type EnrichmentStore ¶
type EnrichmentStore struct {
database.Repository[enrichment.Enrichment, EnrichmentModel]
}
EnrichmentStore implements enrichment.EnrichmentStore using GORM.
func NewEnrichmentStore ¶
func NewEnrichmentStore(db database.Database) EnrichmentStore
NewEnrichmentStore creates a new EnrichmentStore.
func (EnrichmentStore) Count ¶
func (s EnrichmentStore) Count(ctx context.Context, options ...repository.Option) (int64, error)
Count returns the number of enrichments matching the given options.
func (EnrichmentStore) Delete ¶
func (s EnrichmentStore) Delete(ctx context.Context, e enrichment.Enrichment) error
Delete removes an enrichment.
func (EnrichmentStore) Find ¶
func (s EnrichmentStore) Find(ctx context.Context, options ...repository.Option) ([]enrichment.Enrichment, error)
Find retrieves enrichments matching the given options. Supports commit SHA filtering via enrichment.WithCommitSHA / WithCommitSHAs options, which join through enrichment_associations.
func (EnrichmentStore) Save ¶
func (s EnrichmentStore) Save(ctx context.Context, e enrichment.Enrichment) (enrichment.Enrichment, error)
Save creates or updates an enrichment.
type FileMapper ¶
type FileMapper struct{}
FileMapper maps between domain File and persistence FileModel.
func (FileMapper) ToDomain ¶
func (m FileMapper) ToDomain(e FileModel) repository.File
ToDomain converts a FileModel to a domain File.
func (FileMapper) ToModel ¶
func (m FileMapper) ToModel(f repository.File) FileModel
ToModel converts a domain File to a FileModel.
type FileModel ¶
type FileModel struct {
ID int64 `gorm:"column:id;autoIncrement"`
CommitSHA string `gorm:"column:commit_sha;primaryKey;uniqueIndex:idx_commit_path;size:64"`
Commit CommitModel `gorm:"foreignKey:CommitSHA;references:CommitSHA;constraint:-"`
Path string `gorm:"column:path;primaryKey;uniqueIndex:idx_commit_path;size:1024"`
BlobSHA string `gorm:"column:blob_sha;index;size:64"`
MimeType string `gorm:"column:mime_type;index;size:255"`
Extension string `gorm:"column:extension;index;size:255"`
Size int64 `gorm:"column:size"`
CreatedAt time.Time `gorm:"column:created_at"`
}
FileModel represents a Git file in the database.
type FileStore ¶
type FileStore struct {
database.Repository[repository.File, FileModel]
}
FileStore implements repository.FileStore using GORM.
func NewFileStore ¶
NewFileStore creates a new FileStore.
func (FileStore) Save ¶
func (s FileStore) Save(ctx context.Context, file repository.File) (repository.File, error)
Save creates or updates a file.
func (FileStore) SaveAll ¶
func (s FileStore) SaveAll(ctx context.Context, files []repository.File) ([]repository.File, error)
SaveAll creates or updates multiple files.
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter represents a single query filter condition.
func NewBetweenFilter ¶
NewBetweenFilter creates a new BETWEEN Filter.
func NewFilter ¶
func NewFilter(field string, operator FilterOperator, value any) Filter
NewFilter creates a new Filter.
func (Filter) Operator ¶
func (f Filter) Operator() FilterOperator
Operator returns the filter operator.
type FilterOperator ¶
type FilterOperator int
FilterOperator represents SQL comparison operators.
const ( OpEqual FilterOperator = iota OpNotEqual OpGreaterThan OpGreaterThanOrEqual OpLessThan OpLessThanOrEqual OpLike OpILike OpIn OpNotIn OpIsNull OpIsNotNull OpBetween )
FilterOperator values.
func (FilterOperator) String ¶
func (o FilterOperator) String() string
String returns the SQL representation of the operator.
type Float64Slice ¶
type Float64Slice []float64
Float64Slice is a custom type for JSON serialization of []float64 in SQLite.
func (*Float64Slice) Scan ¶
func (f *Float64Slice) Scan(value any) error
Scan implements sql.Scanner for reading JSON from SQLite.
type OrderBy ¶
type OrderBy struct {
// contains filtered or unexported fields
}
OrderBy represents a sort specification.
func NewOrderBy ¶
func NewOrderBy(field string, direction SortDirection) OrderBy
NewOrderBy creates a new OrderBy.
func (OrderBy) Direction ¶
func (o OrderBy) Direction() SortDirection
Direction returns the sort direction.
type PgEmbeddingModel ¶
type PgEmbeddingModel struct {
ID int64 `gorm:"column:id;primaryKey;autoIncrement"`
SnippetID string `gorm:"column:snippet_id;uniqueIndex"`
Embedding database.PgVector `gorm:"column:embedding;type:vector"`
}
PgEmbeddingModel is a GORM model for PostgreSQL vector embedding tables.
type PipelineMapper ¶ added in v1.2.4
type PipelineMapper struct{}
PipelineMapper maps between domain Pipeline and persistence models.
func (PipelineMapper) ToDomain ¶ added in v1.2.4
func (m PipelineMapper) ToDomain(e models.Pipeline) repository.Pipeline
ToDomain converts a models.Pipeline to a domain Pipeline.
func (PipelineMapper) ToModel ¶ added in v1.2.4
func (m PipelineMapper) ToModel(p repository.Pipeline) models.Pipeline
ToModel converts a domain Pipeline to a models.Pipeline.
type PipelineStepMapper ¶ added in v1.2.4
type PipelineStepMapper struct{}
PipelineStepMapper maps between domain PipelineStep and persistence models.
func (PipelineStepMapper) ToDomain ¶ added in v1.2.4
func (m PipelineStepMapper) ToDomain(e models.PipelineStep) repository.PipelineStep
ToDomain converts a models.PipelineStep to a domain PipelineStep.
func (PipelineStepMapper) ToModel ¶ added in v1.2.4
func (m PipelineStepMapper) ToModel(ps repository.PipelineStep) models.PipelineStep
ToModel converts a domain PipelineStep to a models.PipelineStep.
type PipelineStepStore ¶ added in v1.2.4
type PipelineStepStore struct {
database.Repository[repository.PipelineStep, models.PipelineStep]
}
PipelineStepStore implements repository.PipelineStepStore using GORM.
func NewPipelineStepStore ¶ added in v1.2.4
func NewPipelineStepStore(db database.Database) PipelineStepStore
NewPipelineStepStore creates a new PipelineStepStore.
type PipelineStore ¶ added in v1.2.4
type PipelineStore struct {
database.Repository[repository.Pipeline, models.Pipeline]
}
PipelineStore implements repository.PipelineStore using GORM.
func NewPipelineStore ¶ added in v1.2.4
func NewPipelineStore(db database.Database) PipelineStore
NewPipelineStore creates a new PipelineStore.
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
Query represents a database query with filters, ordering, and pagination.
func (Query) GreaterThan ¶
GreaterThan adds a greater-than filter.
func (Query) GreaterThanOrEqual ¶
GreaterThanOrEqual adds a greater-than-or-equal filter.
func (Query) LessThanOrEqual ¶
LessThanOrEqual adds a less-than-or-equal filter.
func (Query) LimitValue ¶
LimitValue returns the limit value (0 means no limit).
func (Query) Order ¶
func (q Query) Order(field string, direction SortDirection) Query
Order adds an ordering specification.
type RepositoryMapper ¶
type RepositoryMapper struct{}
RepositoryMapper maps between domain Repository and persistence RepositoryModel.
func (RepositoryMapper) ToDomain ¶
func (m RepositoryMapper) ToDomain(e RepositoryModel) repository.Repository
ToDomain converts a RepositoryModel to a domain Repository.
func (RepositoryMapper) ToModel ¶
func (m RepositoryMapper) ToModel(r repository.Repository) RepositoryModel
ToModel converts a domain Repository to a RepositoryModel.
type RepositoryModel ¶
type RepositoryModel struct {
ID int64 `gorm:"primaryKey;autoIncrement"`
PipelineID *int64 `gorm:"column:pipeline_id;index"`
Pipeline models.Pipeline `gorm:"foreignKey:PipelineID;constraint:OnDelete:SET NULL"`
SanitizedRemoteURI string `gorm:"column:sanitized_remote_uri;index;uniqueIndex;size:1024"`
RemoteURI string `gorm:"column:remote_uri;size:1024"`
UpstreamURL *string `gorm:"column:upstream_url;index;size:1024"`
ClonedPath *string `gorm:"column:cloned_path;size:1024"`
LastScannedAt *time.Time `gorm:"column:last_scanned_at"`
NumCommits int `gorm:"column:num_commits;default:0"`
NumBranches int `gorm:"column:num_branches;default:0"`
NumTags int `gorm:"column:num_tags;default:0"`
TrackingType string `gorm:"column:tracking_type;index;size:255"`
TrackingName string `gorm:"column:tracking_name;index;size:255"`
ChunkSize int `gorm:"column:chunk_size"`
ChunkOverlap int `gorm:"column:chunk_overlap"`
MinChunkSize int `gorm:"column:min_chunk_size"`
CreatedAt time.Time `gorm:"column:created_at"`
UpdatedAt time.Time `gorm:"column:updated_at"`
}
RepositoryModel represents a Git repository in the database.
func (RepositoryModel) TableName ¶
func (RepositoryModel) TableName() string
TableName returns the table name.
type RepositoryStore ¶
type RepositoryStore struct {
database.Repository[repository.Repository, RepositoryModel]
}
RepositoryStore implements repository.RepositoryStore using GORM.
func NewRepositoryStore ¶
func NewRepositoryStore(db database.Database) RepositoryStore
NewRepositoryStore creates a new RepositoryStore.
func (RepositoryStore) Delete ¶
func (s RepositoryStore) Delete(ctx context.Context, repo repository.Repository) error
Delete removes a repository.
func (RepositoryStore) Save ¶
func (s RepositoryStore) Save(ctx context.Context, repo repository.Repository) (repository.Repository, error)
Save creates or updates a repository.
type SQLiteBM25Store ¶
type SQLiteBM25Store struct {
// contains filtered or unexported fields
}
SQLiteBM25Store implements search.BM25Store using SQLite FTS5.
func NewSQLiteBM25Store ¶
NewSQLiteBM25Store creates a new SQLiteBM25Store, eagerly initializing the FTS5 table and row ID counter.
func (*SQLiteBM25Store) DeleteBy ¶
func (s *SQLiteBM25Store) DeleteBy(ctx context.Context, options ...repository.Option) error
DeleteBy removes documents matching the given options.
func (*SQLiteBM25Store) Find ¶
func (s *SQLiteBM25Store) Find(ctx context.Context, options ...repository.Option) ([]search.Result, error)
Find performs BM25 keyword search using options.
func (*SQLiteBM25Store) Index ¶
func (s *SQLiteBM25Store) Index(ctx context.Context, request search.IndexRequest) error
Index adds documents to the BM25 index.
type SQLiteEmbeddingModel ¶
type SQLiteEmbeddingModel struct {
ID int64 `gorm:"column:id;primaryKey;autoIncrement"`
SnippetID string `gorm:"column:snippet_id;uniqueIndex"`
Embedding Float64Slice `gorm:"column:embedding;type:json"`
}
SQLiteEmbeddingModel represents a vector embedding in SQLite.
type SQLiteEmbeddingStore ¶
type SQLiteEmbeddingStore struct {
database.Repository[search.Embedding, SQLiteEmbeddingModel]
// contains filtered or unexported fields
}
SQLiteEmbeddingStore implements search.EmbeddingStore for SQLite. Stores embeddings as JSON and performs cosine similarity search in-memory.
func NewSQLiteEmbeddingStore ¶
func NewSQLiteEmbeddingStore(db database.Database, taskName TaskName, logger zerolog.Logger) (*SQLiteEmbeddingStore, error)
NewSQLiteEmbeddingStore creates a new SQLiteEmbeddingStore.
func (*SQLiteEmbeddingStore) SaveAll ¶
SaveAll persists pre-computed embeddings using batched upsert.
func (*SQLiteEmbeddingStore) Search ¶
func (s *SQLiteEmbeddingStore) Search(ctx context.Context, options ...repository.Option) ([]search.Result, error)
Search performs vector similarity search using pre-computed embedding from options.
type SimilarityMatch ¶
type SimilarityMatch struct {
// contains filtered or unexported fields
}
SimilarityMatch holds a snippet ID and its similarity score.
func NewSimilarityMatch ¶
func NewSimilarityMatch(snippetID string, similarity float64) SimilarityMatch
NewSimilarityMatch creates a new SimilarityMatch.
func TopKSimilar ¶
func TopKSimilar(query []float64, vectors []StoredVector, k int) []SimilarityMatch
TopKSimilar finds the top-k most similar vectors to the query. Returns results sorted by similarity in descending order (highest similarity first).
func TopKSimilarFiltered ¶
func TopKSimilarFiltered(query []float64, vectors []StoredVector, k int, allowedIDs map[string]struct{}) []SimilarityMatch
TopKSimilarFiltered finds the top-k most similar vectors, filtering by allowed snippet IDs.
func (SimilarityMatch) Similarity ¶
func (m SimilarityMatch) Similarity() float64
Similarity returns the similarity score.
func (SimilarityMatch) SnippetID ¶
func (m SimilarityMatch) SnippetID() string
SnippetID returns the snippet identifier.
type SortDirection ¶
type SortDirection int
SortDirection represents sort direction.
const ( SortAsc SortDirection = iota SortDesc )
SortDirection values.
func (SortDirection) String ¶
func (s SortDirection) String() string
String returns the SQL representation.
type SourceLocationMapper ¶ added in v1.3.0
type SourceLocationMapper struct{}
SourceLocationMapper maps between domain SourceLocation and persistence SourceLocationModel.
func (SourceLocationMapper) ToDomain ¶ added in v1.3.0
func (m SourceLocationMapper) ToDomain(e SourceLocationModel) sourcelocation.SourceLocation
ToDomain converts a SourceLocationModel to a domain SourceLocation.
func (SourceLocationMapper) ToModel ¶ added in v1.3.0
func (m SourceLocationMapper) ToModel(s sourcelocation.SourceLocation) SourceLocationModel
ToModel converts a domain SourceLocation to a SourceLocationModel.
type SourceLocationModel ¶ added in v1.3.0
type SourceLocationModel struct {
ID int64 `gorm:"column:id;primaryKey;autoIncrement"`
EnrichmentID int64 `gorm:"column:enrichment_id;not null;uniqueIndex"`
Enrichment EnrichmentModel `gorm:"foreignKey:EnrichmentID;references:ID;constraint:OnDelete:CASCADE"`
Page int `gorm:"column:page;not null;default:0"`
StartLine int `gorm:"column:start_line;not null"`
EndLine int `gorm:"column:end_line;not null"`
}
SourceLocationModel records where an enrichment's content originates within its source file. For text chunks this is a line range; for page images this is a page number.
func (SourceLocationModel) TableName ¶ added in v1.3.0
func (SourceLocationModel) TableName() string
TableName returns the table name.
type SourceLocationStore ¶ added in v1.3.0
type SourceLocationStore struct {
database.Repository[sourcelocation.SourceLocation, SourceLocationModel]
}
SourceLocationStore implements sourcelocation.Store using GORM.
func NewSourceLocationStore ¶ added in v1.3.0
func NewSourceLocationStore(db database.Database) SourceLocationStore
NewSourceLocationStore creates a new SourceLocationStore.
type StatusStore ¶
type StatusStore struct {
database.Repository[task.Status, TaskStatusModel]
}
StatusStore implements task.StatusStore using GORM.
func NewStatusStore ¶
func NewStatusStore(db database.Database) StatusStore
NewStatusStore creates a new StatusStore.
func (StatusStore) LoadWithHierarchy ¶
func (s StatusStore) LoadWithHierarchy(ctx context.Context, trackableType task.TrackableType, trackableID int64) ([]task.Status, error)
LoadWithHierarchy loads all task statuses for a trackable entity with their parent-child relationships reconstructed.
type StepDependencyMapper ¶ added in v1.2.4
type StepDependencyMapper struct{}
StepDependencyMapper maps between domain StepDependency and persistence models.
func (StepDependencyMapper) ToDomain ¶ added in v1.2.4
func (m StepDependencyMapper) ToDomain(e models.StepDependency) repository.StepDependency
ToDomain converts a models.StepDependency to a domain StepDependency.
func (StepDependencyMapper) ToModel ¶ added in v1.2.4
func (m StepDependencyMapper) ToModel(d repository.StepDependency) models.StepDependency
ToModel converts a domain StepDependency to a models.StepDependency.
type StepDependencyStore ¶ added in v1.2.4
type StepDependencyStore struct {
database.Repository[repository.StepDependency, models.StepDependency]
}
StepDependencyStore implements repository.StepDependencyStore using GORM.
func NewStepDependencyStore ¶ added in v1.2.4
func NewStepDependencyStore(db database.Database) StepDependencyStore
NewStepDependencyStore creates a new StepDependencyStore.
type StepMapper ¶ added in v1.2.4
type StepMapper struct{}
StepMapper maps between domain Step and persistence models.
func (StepMapper) ToDomain ¶ added in v1.2.4
func (m StepMapper) ToDomain(e models.Step) repository.Step
ToDomain converts a models.Step to a domain Step.
func (StepMapper) ToModel ¶ added in v1.2.4
func (m StepMapper) ToModel(s repository.Step) models.Step
ToModel converts a domain Step to a models.Step.
type StepStore ¶ added in v1.2.4
type StepStore struct {
database.Repository[repository.Step, models.Step]
}
StepStore implements repository.StepStore using GORM.
func NewStepStore ¶ added in v1.2.4
NewStepStore creates a new StepStore.
type StoredVector ¶
type StoredVector struct {
// contains filtered or unexported fields
}
StoredVector holds an embedding vector with its snippet ID.
func NewStoredVector ¶
func NewStoredVector(snippetID string, embedding []float64) StoredVector
NewStoredVector creates a new StoredVector.
func (StoredVector) Embedding ¶
func (v StoredVector) Embedding() []float64
Embedding returns the embedding vector (copy).
func (StoredVector) SnippetID ¶
func (v StoredVector) SnippetID() string
SnippetID returns the snippet identifier.
type TagMapper ¶
type TagMapper struct{}
TagMapper maps between domain Tag and persistence TagModel.
type TagModel ¶
type TagModel struct {
RepoID int64 `gorm:"column:repo_id;primaryKey;index"`
Repo RepositoryModel `gorm:"foreignKey:RepoID;references:ID;constraint:OnDelete:CASCADE"`
Name string `gorm:"column:name;primaryKey;index;size:255"`
TargetCommitSHA string `gorm:"column:target_commit_sha;index;size:64"`
Message *string `gorm:"column:message;type:text"`
TaggerName *string `gorm:"column:tagger_name;size:255"`
TaggerEmail *string `gorm:"column:tagger_email;size:255"`
TaggedAt *time.Time `gorm:"column:tagged_at"`
CreatedAt time.Time `gorm:"column:created_at"`
UpdatedAt time.Time `gorm:"column:updated_at"`
}
TagModel represents a Git tag in the database.
type TagStore ¶
type TagStore struct {
database.Repository[repository.Tag, TagModel]
}
TagStore implements repository.TagStore using GORM.
func NewTagStore ¶
NewTagStore creates a new TagStore.
func (TagStore) Save ¶
func (s TagStore) Save(ctx context.Context, tag repository.Tag) (repository.Tag, error)
Save creates or updates a tag.
func (TagStore) SaveAll ¶
func (s TagStore) SaveAll(ctx context.Context, tags []repository.Tag) ([]repository.Tag, error)
SaveAll creates or updates multiple tags.
type TaskMapper ¶
type TaskMapper struct{}
TaskMapper maps between domain Task and persistence TaskModel.
type TaskModel ¶
type TaskModel struct {
ID int64 `gorm:"column:id;primaryKey;autoIncrement"`
DedupKey string `gorm:"column:dedup_key;type:varchar(255);uniqueIndex;not null"`
Type string `gorm:"column:type;type:varchar(255);index;not null"`
Payload json.RawMessage `gorm:"column:payload;type:jsonb"`
Priority int `gorm:"column:priority;not null"`
CreatedAt time.Time `gorm:"column:created_at;autoCreateTime"`
UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime"`
}
TaskModel represents a task in the database.
type TaskStatusMapper ¶
type TaskStatusMapper struct{}
TaskStatusMapper maps between domain Status and persistence TaskStatusModel.
func (TaskStatusMapper) ToDomain ¶
func (m TaskStatusMapper) ToDomain(e TaskStatusModel) task.Status
ToDomain converts a TaskStatusModel to a domain Status.
func (TaskStatusMapper) ToModel ¶
func (m TaskStatusMapper) ToModel(s task.Status) TaskStatusModel
ToModel converts a domain Status to a TaskStatusModel.
type TaskStatusModel ¶
type TaskStatusModel struct {
ID string `gorm:"column:id;type:varchar(255);primaryKey;index;not null"`
CreatedAt time.Time `gorm:"column:created_at;not null"`
UpdatedAt time.Time `gorm:"column:updated_at;not null"`
Operation string `gorm:"column:operation;type:varchar(255);index;not null"`
TrackableID *int64 `gorm:"column:trackable_id;index:idx_trackable"`
TrackableType *string `gorm:"column:trackable_type;type:varchar(255);index:idx_trackable"`
ParentID *string `gorm:"column:parent;type:varchar(255);index"`
Message string `gorm:"column:message;type:text;default:''"`
State string `gorm:"column:state;type:varchar(255);default:''"`
Error string `gorm:"column:error;type:text;default:''"`
Total int `gorm:"column:total;default:0"`
Current int `gorm:"column:current;default:0"`
}
TaskStatusModel represents task status in the database.
func (TaskStatusModel) TableName ¶
func (TaskStatusModel) TableName() string
TableName returns the table name.
type TaskStore ¶
type TaskStore struct {
database.Repository[task.Task, TaskModel]
}
TaskStore implements task.TaskStore using GORM.
func NewTaskStore ¶
NewTaskStore creates a new TaskStore.
type VectorChordBM25Store ¶
type VectorChordBM25Store struct {
// contains filtered or unexported fields
}
VectorChordBM25Store implements search.BM25Store using VectorChord PostgreSQL extension.
func NewVectorChordBM25Store ¶
func NewVectorChordBM25Store(db database.Database, logger zerolog.Logger) (*VectorChordBM25Store, error)
NewVectorChordBM25Store creates a new VectorChordBM25Store, eagerly initializing extensions, tokenizer, and tables.
func (*VectorChordBM25Store) DeleteBy ¶
func (s *VectorChordBM25Store) DeleteBy(ctx context.Context, options ...repository.Option) error
DeleteBy removes documents matching the given options.
func (*VectorChordBM25Store) Find ¶
func (s *VectorChordBM25Store) Find(ctx context.Context, options ...repository.Option) ([]search.Result, error)
Find performs BM25 keyword search using options.
func (*VectorChordBM25Store) Index ¶
func (s *VectorChordBM25Store) Index(ctx context.Context, request search.IndexRequest) error
Index adds documents to the BM25 index.
type VectorChordEmbeddingStore ¶
type VectorChordEmbeddingStore struct {
database.Repository[search.Embedding, PgEmbeddingModel]
// contains filtered or unexported fields
}
VectorChordEmbeddingStore implements search.EmbeddingStore using VectorChord PostgreSQL extension. Table creation is deferred to the first SaveAll call, using the actual embedding dimension. Read methods work against whatever table state exists; if no data has been written yet they return empty results.
func NewVectorChordEmbeddingStore ¶
func NewVectorChordEmbeddingStore(db database.Database, taskName TaskName, onRebuilt func(context.Context), logger zerolog.Logger) *VectorChordEmbeddingStore
NewVectorChordEmbeddingStore creates a new VectorChordEmbeddingStore. Construction is side-effect-free; the VectorChord extension and table are created lazily on the first SaveAll call using the actual embedding dimension.
onRebuilt is called (at most once) if an existing table had to be dropped and recreated due to a dimension mismatch; pass nil if no action is needed.
func (*VectorChordEmbeddingStore) SaveAll ¶
func (s *VectorChordEmbeddingStore) SaveAll(ctx context.Context, embeddings []search.Embedding) error
SaveAll persists pre-computed embeddings using batched upsert, then ensures the vchordrq index exists (it requires data for K-means clustering).
func (*VectorChordEmbeddingStore) Search ¶
func (s *VectorChordEmbeddingStore) Search(ctx context.Context, options ...repository.Option) ([]search.Result, error)
Search performs vector similarity search within a transaction so that the vchordrq.probes session variable is visible to the query.
Source Files
¶
- bm25_store_sqlite.go
- bm25_store_vectorchord.go
- branch_store.go
- commit_store.go
- db.go
- embedding_store.go
- embedding_store_sqlite.go
- embedding_store_vectorchord.go
- enrichment_store.go
- file_store.go
- mappers.go
- models.go
- pipline_store.go
- query.go
- repository_store.go
- source_location_store.go
- status_store.go
- tag_store.go
- task_store.go