Documentation
¶
Overview ¶
Package service provides domain service interfaces.
Index ¶
- Variables
- type BM25
- type Cloner
- type Embedding
- type EmbeddingService
- func (s *EmbeddingService) Exists(ctx context.Context, options ...repository.Option) (bool, error)
- func (s *EmbeddingService) Find(ctx context.Context, query string, options ...repository.Option) ([]search.Result, error)
- func (s *EmbeddingService) Index(ctx context.Context, request search.IndexRequest, opts ...search.IndexOption) error
- type EnrichConfig
- type EnrichOption
- type EnrichProgress
- type Enricher
- type EnrichmentRequest
- type EnrichmentResponse
- type RequestError
- type ScanCommitResult
- type Scanner
Constants ¶
This section is empty.
Variables ¶
var ErrEmptyQuery = errors.New("search query cannot be empty")
ErrEmptyQuery indicates an empty search query.
var ErrInvalidTopK = errors.New("top-k must be positive")
ErrInvalidTopK indicates an invalid top-k value.
Functions ¶
This section is empty.
Types ¶
type BM25 ¶
type BM25 struct {
// contains filtered or unexported fields
}
BM25 provides domain logic for BM25 operations.
type Cloner ¶
type Cloner interface {
// ClonePathFromURI returns the local clone path for a given repository URI.
ClonePathFromURI(uri string) string
// Clone clones a repository and returns the local path.
Clone(ctx context.Context, remoteURI string) (string, error)
// CloneToPath clones a repository to a specific path.
CloneToPath(ctx context.Context, remoteURI string, clonePath string) error
// Update updates a repository based on its tracking configuration.
// Returns the actual clone path used, which may differ from the stored
// path if the repository was relocated (e.g. after migration).
Update(ctx context.Context, repo repository.Repository) (string, error)
// Ensure clones the repository if it doesn't exist, otherwise pulls latest changes.
Ensure(ctx context.Context, remoteURI string) (string, error)
}
Cloner handles repository cloning and updating operations.
type Embedding ¶
type Embedding interface {
// Index indexes documents using domain business rules.
Index(ctx context.Context, request search.IndexRequest, opts ...search.IndexOption) error
// Find embeds the query text and performs vector similarity search.
Find(ctx context.Context, query string, options ...repository.Option) ([]search.Result, error)
// Exists checks whether any row matches the given options.
Exists(ctx context.Context, options ...repository.Option) (bool, error)
}
Embedding provides domain logic for embedding operations.
type EmbeddingService ¶
type EmbeddingService struct {
// contains filtered or unexported fields
}
EmbeddingService implements domain logic for embedding operations.
func NewEmbedding ¶
func NewEmbedding(store search.EmbeddingStore, embedder search.Embedder, budget search.TokenBudget, parallelism int) (*EmbeddingService, error)
NewEmbedding creates a new embedding service. The budget controls text truncation and adaptive batching. Parallelism controls how many batches are dispatched concurrently; values <= 0 are clamped to 1.
func (*EmbeddingService) Exists ¶
func (s *EmbeddingService) Exists(ctx context.Context, options ...repository.Option) (bool, error)
Exists checks whether any row matches the given options.
func (*EmbeddingService) Find ¶
func (s *EmbeddingService) Find(ctx context.Context, query string, options ...repository.Option) ([]search.Result, error)
Find embeds the query text and performs vector similarity search.
func (*EmbeddingService) Index ¶
func (s *EmbeddingService) Index(ctx context.Context, request search.IndexRequest, opts ...search.IndexOption) error
Index indexes documents using domain business rules: validate → deduplicate against store → batch embed → batch save.
type EnrichConfig ¶
type EnrichConfig struct {
// contains filtered or unexported fields
}
EnrichConfig holds the resolved configuration for an Enrich call.
func NewEnrichConfig ¶
func NewEnrichConfig(opts ...EnrichOption) EnrichConfig
NewEnrichConfig applies all options and returns the resolved config.
func (EnrichConfig) MaxFailureRate ¶
func (c EnrichConfig) MaxFailureRate() float64
MaxFailureRate returns the maximum fraction of requests that may fail before the Enrich call returns an error. Default is 0.05 (5%).
func (EnrichConfig) Progress ¶
func (c EnrichConfig) Progress() EnrichProgress
Progress returns the progress callback, or nil if none was set.
func (EnrichConfig) RequestError ¶
func (c EnrichConfig) RequestError() RequestError
RequestError returns the request error callback, or nil if none was set.
type EnrichOption ¶
type EnrichOption func(*EnrichConfig)
EnrichOption configures the behaviour of an Enrich call.
func WithEnrichProgress ¶
func WithEnrichProgress(fn EnrichProgress) EnrichOption
WithEnrichProgress registers a callback that is invoked after each enrichment request completes successfully.
func WithMaxFailureRate ¶
func WithMaxFailureRate(rate float64) EnrichOption
WithMaxFailureRate sets the maximum fraction of requests that may fail before the Enrich call returns an error. The rate is clamped to [0, 1]. A rate of 0 means any single request failure is fatal.
func WithRequestError ¶
func WithRequestError(fn RequestError) EnrichOption
WithRequestError registers a callback that is invoked when an individual request fails during enrichment. This allows callers to log each upstream error as it occurs.
type EnrichProgress ¶
type EnrichProgress func(completed, total int)
EnrichProgress is called after each request completes during enrichment. completed is the running total of requests processed so far; total is the overall number of requests to enrich.
type Enricher ¶
type Enricher interface {
// Enrich processes requests and returns responses for each.
Enrich(ctx context.Context, requests []EnrichmentRequest, opts ...EnrichOption) ([]EnrichmentResponse, error)
}
Enricher generates enrichments using an AI provider.
type EnrichmentRequest ¶
type EnrichmentRequest struct {
// contains filtered or unexported fields
}
EnrichmentRequest represents an enrichment request with a custom system prompt.
func NewEnrichmentRequest ¶
func NewEnrichmentRequest(id, text, systemPrompt string) EnrichmentRequest
NewEnrichmentRequest creates a new enrichment request.
func (EnrichmentRequest) ID ¶
func (r EnrichmentRequest) ID() string
ID returns the request identifier.
func (EnrichmentRequest) SystemPrompt ¶
func (r EnrichmentRequest) SystemPrompt() string
SystemPrompt returns the custom system prompt.
func (EnrichmentRequest) Text ¶
func (r EnrichmentRequest) Text() string
Text returns the text to be enriched.
type EnrichmentResponse ¶
type EnrichmentResponse struct {
// contains filtered or unexported fields
}
EnrichmentResponse represents an enrichment response.
func NewEnrichmentResponse ¶
func NewEnrichmentResponse(id, text string) EnrichmentResponse
NewEnrichmentResponse creates a new enrichment response.
func (EnrichmentResponse) ID ¶
func (r EnrichmentResponse) ID() string
ID returns the response identifier (matches the request ID).
func (EnrichmentResponse) Text ¶
func (r EnrichmentResponse) Text() string
Text returns the enriched text.
type RequestError ¶
RequestError is called when an individual request fails during enrichment. requestID is the identifier of the failed request; err is the upstream error.
type ScanCommitResult ¶
type ScanCommitResult struct {
// contains filtered or unexported fields
}
ScanCommitResult holds the result of scanning a single commit.
func NewScanCommitResult ¶
func NewScanCommitResult(commit repository.Commit, files []repository.File) ScanCommitResult
NewScanCommitResult creates a new ScanCommitResult.
func (ScanCommitResult) Commit ¶
func (r ScanCommitResult) Commit() repository.Commit
Commit returns the scanned commit.
func (ScanCommitResult) Files ¶
func (r ScanCommitResult) Files() []repository.File
Files returns the scanned files.
type Scanner ¶
type Scanner interface {
// ScanCommit scans a specific commit and returns commit with its files.
ScanCommit(ctx context.Context, clonedPath string, commitSHA string, repoID int64) (ScanCommitResult, error)
// ScanBranch scans all commits on a branch.
ScanBranch(ctx context.Context, clonedPath string, branchName string, repoID int64) ([]repository.Commit, error)
// ScanAllBranches scans metadata for all branches.
ScanAllBranches(ctx context.Context, clonedPath string, repoID int64) ([]repository.Branch, error)
// ScanAllTags scans metadata for all tags.
ScanAllTags(ctx context.Context, clonedPath string, repoID int64) ([]repository.Tag, error)
// FilesForCommitsBatch processes files for a batch of commits.
FilesForCommitsBatch(ctx context.Context, clonedPath string, commitSHAs []string) ([]repository.File, error)
}
Scanner extracts data from Git repositories without mutation.