Documentation
¶
Index ¶
- Constants
- Variables
- func FilterReviewableFiles(files []services.PRFileInfo) []services.PRFileInfo
- func GetToolDefinitions() []anthropic.ToolUnionParam
- func NewAnthropicReviewer(apiKey string, model string, maxTokens int, maxTurns int, ...) services.Reviewer
- func NewEmbedderService(cfg config.OpenAIConfig, logger *zap.Logger) (services.EmbedderService, error)
- func NewEmbedderWithSemaphore(inner services.EmbedderService, logger *zap.Logger, ...) services.EmbedderService
- func NewGraphRetriever(graph repositories.GraphRepository, graphName string, ...) services.RetrieverService
- func NewGrepRetriever(provider services.SourceProvider, root string) services.RetrieverService
- func NewHybridRetriever(vector, graph services.RetrieverService, alpha float32) services.RetrieverService
- func NewIndexRetrievalService(openAICfg config.OpenAIConfig, indexerCfg config.IndexerConfig, ...) services.IndexRetrievalService
- func NewIndexerRouter(cfg config.IndexerConfig, logger *zap.Logger) services.IndexerService
- func NewKeywordRetriever(textRepo repositories.TextSearchRepository, collection string) services.RetrieverService
- func NewLocalSourceProvider(cfg config.IndexerConfig) services.SourceProvider
- func NewLocalSourceProviderWithRoot(root string) services.SourceProvider
- func NewMerkleService(cfg config.IndexerConfig, envCfg *coreconfig.EnvConfig, logger *zap.Logger) (services.MerkleService, error)
- func NewMultiRetriever(vector, keyword services.RetrieverService, graph repositories.GraphRepository, ...) services.RetrieverService
- func NewOpenAIReviewer(apiKey string, model string, maxTokens int, maxTurns int, ...) services.Reviewer
- func NewOutboxDispatcher(logger *zap.Logger, db *gorm.DB, dsn services.PostgresDSN, ...) services.OutboxDispatcher
- func NewRetriever(strategy string, emb services.EmbedderService, ...) services.RetrieverService
- func NewS3SourceProvider(cfg config.IndexerConfig, logger *zap.Logger) (services.SourceProvider, error)
- func NewS3SourceProviderWithParams(bucket, prefix, region, endpoint string, logger *zap.Logger) (services.SourceProvider, error)
- func NewSmartChunker(cfg config.IndexerConfig) *smartChunker
- func NewSyncSessionService(logger *zap.Logger, db *gorm.DB, openAICfg config.OpenAIConfig, ...) services.SyncSessionService
- func NewTreeSitterIndexer(cfg config.IndexerConfig, logger *zap.Logger) services.IndexerService
- func NewVectorRetriever(emb services.EmbedderService, store repositories.VectorRepository, ...) services.RetrieverService
- type AnthropicReviewer
- type CalleeRef
- type ContractDiff
- type DiffIndex
- type GraphContext
- type IndexRetrievalServiceImpl
- func (s *IndexRetrievalServiceImpl) DeleteIndex(ctx context.Context, req *dto.IndexDeleteRequest) (*dto.IndexDeleteResponse, error)
- func (s *IndexRetrievalServiceImpl) GetContext(ctx context.Context, req *dto.ContextRequest) (*dto.ContextResponse, error)
- func (s *IndexRetrievalServiceImpl) GetIndexStatus(ctx context.Context, repoPath, userID string, workspaceID uint64, ...) (*dto.IndexStatusResponse, error)
- func (s *IndexRetrievalServiceImpl) GraphQuery(ctx context.Context, req *dto.GraphQueryRequest) (*dto.GraphQueryResponse, error)
- func (s *IndexRetrievalServiceImpl) Search(ctx context.Context, req *dto.SearchRequest) (*dto.SearchResponse, error)
- func (s *IndexRetrievalServiceImpl) TriggerIndex(ctx context.Context, req *dto.IndexRequest) (string, error)
- type OpenAIReviewer
- type PRClassification
- type Pipeline
- func (p *Pipeline) Analyze(ctx context.Context, repoPath string, indexReq *dto.IndexRequest) (*services.ReviewOutput, *services.ReviewMetrics, error)
- func (p *Pipeline) Index(ctx context.Context, req *dto.IndexRequest) error
- func (p *Pipeline) IndexChangedFiles(ctx context.Context, collectionName string, indexRoot string, ...) (*services.IndexStats, error)
- func (p *Pipeline) IsCollectionPopulated(ctx context.Context, req *dto.IndexRequest) bool
- func (p *Pipeline) Review(ctx context.Context, req *dto.ReviewRequest) (*services.ReviewOutput, *services.ReviewMetrics, error)
- type PromptProvider
- type RiskAssessment
- type ShardBootstrap
- type ToolExecutor
Constants ¶
const ( LangGo = "go" LangRuby = "ruby" LangJavaScript = "javascript" LangTypeScript = "typescript" LangTSX = "tsx" LangPython = "python" LangJava = "java" LangRust = "rust" LangC = "c" LangCPP = "cpp" LangCSharp = "csharp" LangStarlark = "starlark" LangProtobuf = "protobuf" LangSQL = "sql" LangYAML = "yaml" LangMarkdown = "markdown" )
Language name constants.
Variables ¶
var DefaultSkipDirs = map[string]bool{ ".git": true, ".venv": true, ".env": true, "node_modules": true, "vendor": true, "__pycache__": true, "target": true, "build": true, "dist": true, }
DefaultSkipDirs lists directories that should be skipped during traversal.
var ExtensionToLanguage = map[string]string{ ".go": LangGo, ".rb": LangRuby, ".js": LangJavaScript, ".jsx": LangJavaScript, ".ts": LangTypeScript, ".tsx": LangTSX, ".py": LangPython, ".java": LangJava, ".rs": LangRust, ".c": LangC, ".h": LangC, ".cpp": LangCPP, ".cc": LangCPP, ".cxx": LangCPP, ".hpp": LangCPP, ".cs": LangCSharp, ".bzl": LangStarlark, ".bazel": LangStarlark, ".proto": LangProtobuf, ".sql": LangSQL, ".yaml": LangYAML, ".yml": LangYAML, ".md": LangMarkdown, }
ExtensionToLanguage maps file extensions to language names.
Functions ¶
func FilterReviewableFiles ¶
func FilterReviewableFiles(files []services.PRFileInfo) []services.PRFileInfo
FilterReviewableFiles returns only the files that need AI review, excluding docs, lockfiles, images, and generated code.
func GetToolDefinitions ¶
func GetToolDefinitions() []anthropic.ToolUnionParam
func NewAnthropicReviewer ¶
func NewAnthropicReviewer( apiKey string, model string, maxTokens int, maxTurns int, executor *ToolExecutor, promptProvider *PromptProvider, logger *zap.Logger, ) services.Reviewer
func NewEmbedderService ¶
func NewEmbedderService(cfg config.OpenAIConfig, logger *zap.Logger) (services.EmbedderService, error)
func NewEmbedderWithSemaphore ¶
func NewEmbedderWithSemaphore(inner services.EmbedderService, logger *zap.Logger, indexerCfg config.IndexerConfig) services.EmbedderService
NewEmbedderWithSemaphore returns an EmbedderService that caps concurrent Embed / EmbedSingle calls at indexerCfg.EmbeddingConcurrency() and wraps OpenAI 4xx errors as services.Terminal("openai_embed", ...). Registered as a dig decorator so dig.Provide(NewEmbedderService) is unchanged; the decorator replaces the resolved EmbedderService after construction. The config dependency resolves automatically via the container since IndexerConfig is already provided.
func NewGraphRetriever ¶
func NewGraphRetriever(graph repositories.GraphRepository, graphName string, openAICfg config.OpenAIConfig, logger *zap.Logger) services.RetrieverService
func NewGrepRetriever ¶
func NewGrepRetriever(provider services.SourceProvider, root string) services.RetrieverService
NewGrepRetriever creates a retriever that does regex/literal pattern matching on raw files.
func NewHybridRetriever ¶
func NewHybridRetriever(vector, graph services.RetrieverService, alpha float32) services.RetrieverService
func NewIndexRetrievalService ¶
func NewIndexRetrievalService( openAICfg config.OpenAIConfig, indexerCfg config.IndexerConfig, store repositories.VectorRepository, graph repositories.GraphRepository, textRepo repositories.TextSearchRepository, repoRepo repositories.RepoRepository, shardRepo repositories.ShardRepository, embedder services.EmbedderService, indexer services.IndexerService, merkle services.MerkleService, indexProd *producers.IndexProducer, logger *zap.Logger, ) services.IndexRetrievalService
func NewIndexerRouter ¶
func NewIndexerRouter(cfg config.IndexerConfig, logger *zap.Logger) services.IndexerService
func NewKeywordRetriever ¶
func NewKeywordRetriever(textRepo repositories.TextSearchRepository, collection string) services.RetrieverService
NewKeywordRetriever creates a BM25-based keyword retriever.
func NewLocalSourceProvider ¶
func NewLocalSourceProvider(cfg config.IndexerConfig) services.SourceProvider
NewLocalSourceProvider creates a SourceProvider backed by the local filesystem.
func NewLocalSourceProviderWithRoot ¶
func NewLocalSourceProviderWithRoot(root string) services.SourceProvider
NewLocalSourceProviderWithRoot creates a SourceProvider with an explicit allowed root.
func NewMerkleService ¶
func NewMerkleService(cfg config.IndexerConfig, envCfg *coreconfig.EnvConfig, logger *zap.Logger) (services.MerkleService, error)
NewMerkleService creates a MerkleService that persists trees to local disk in development, or to S3 in non-development environments.
func NewMultiRetriever ¶
func NewMultiRetriever( vector, keyword services.RetrieverService, graph repositories.GraphRepository, graphName string, logger *zap.Logger, ) services.RetrieverService
func NewOpenAIReviewer ¶
func NewOpenAIReviewer( apiKey string, model string, maxTokens int, maxTurns int, executor *ToolExecutor, promptProvider *PromptProvider, logger *zap.Logger, ) services.Reviewer
func NewOutboxDispatcher ¶
func NewOutboxDispatcher( logger *zap.Logger, db *gorm.DB, dsn services.PostgresDSN, outboxRepo repositories.SyncOutboxRepository, asynqClient *asynq.Client, ) services.OutboxDispatcher
NewOutboxDispatcher is the dig provider. Production callers receive a dispatcher backed by a real *asynq.Client and pq.NewListener.
func NewRetriever ¶
func NewRetriever( strategy string, emb services.EmbedderService, store repositories.VectorRepository, graph repositories.GraphRepository, textRepo repositories.TextSearchRepository, provider services.SourceProvider, collection string, repoRoot string, alpha float32, openAICfg config.OpenAIConfig, logger *zap.Logger, ) services.RetrieverService
NewRetriever builds the appropriate RetrieverService based on the strategy name.
func NewS3SourceProvider ¶
func NewS3SourceProvider(cfg config.IndexerConfig, logger *zap.Logger) (services.SourceProvider, error)
NewS3SourceProvider creates a SourceProvider backed by an S3 bucket using global config.
func NewS3SourceProviderWithParams ¶
func NewS3SourceProviderWithParams(bucket, prefix, region, endpoint string, logger *zap.Logger) (services.SourceProvider, error)
NewS3SourceProviderWithParams creates a SourceProvider backed by an S3 bucket using explicit parameters instead of config. This allows per-request S3 routing. endpoint can be empty for real AWS S3, or a URL like "http://minio:9000" for S3-compatible stores.
func NewSmartChunker ¶
func NewSmartChunker(cfg config.IndexerConfig) *smartChunker
func NewSyncSessionService ¶
func NewSyncSessionService( logger *zap.Logger, db *gorm.DB, openAICfg config.OpenAIConfig, merkle services.MerkleService, store repositories.VectorRepository, textRepo repositories.TextSearchRepository, repoRepo repositories.RepoRepository, shardRepo repositories.ShardRepository, sessionRepo repositories.SyncSessionRepository, batchRepo repositories.SyncBatchRepository, outboxRepo repositories.SyncOutboxRepository, streamRedis *services.StreamContentRedisClient, ) services.SyncSessionService
NewSyncSessionService wires the dependencies registered in injection/server_container.go. MerkleService is already provided on the server container alongside the indexer providers, and WS4 added dig providers for the SyncBatch/SyncOutbox repos and the typed StreamContentRedisClient.
func NewTreeSitterIndexer ¶
func NewTreeSitterIndexer(cfg config.IndexerConfig, logger *zap.Logger) services.IndexerService
func NewVectorRetriever ¶
func NewVectorRetriever(emb services.EmbedderService, store repositories.VectorRepository, collection string) services.RetrieverService
Types ¶
type AnthropicReviewer ¶
type AnthropicReviewer struct {
// contains filtered or unexported fields
}
AnthropicReviewer implements services.Reviewer using the Anthropic Claude API.
func (*AnthropicReviewer) GetMetrics ¶
func (r *AnthropicReviewer) GetMetrics() *services.ReviewMetrics
func (*AnthropicReviewer) Review ¶
func (r *AnthropicReviewer) Review(ctx context.Context, input services.ReviewInput) (*services.ReviewOutput, error)
type CalleeRef ¶
type CalleeRef struct {
CallerFile string
CallerName string
Name string
FilePath string
StartLine int
EndLine int
}
CalleeRef points the body-fetcher at a first-hop callee with line range.
type ContractDiff ¶
type ContractDiff struct {
FilePath string
Function string
OldSignature string
NewSignature string
Changes []string // "params", "return_type", "modifiers"
}
ContractDiff captures a same-named function's signature change. Body-only edits never appear here.
type DiffIndex ¶
type DiffIndex struct {
// contains filtered or unexported fields
}
DiffIndex summarizes a unified diff as per-file maps from new-side line numbers to line content. Only commentable lines (added `+` and context ` ` on the new side) are indexed; deleted lines are excluded.
func (*DiffIndex) Content ¶
Content returns the content of the commentable line, stripped of the unified-diff prefix. Returns "" if the line is not indexed.
func (*DiffIndex) IsValidLine ¶
IsValidLine reports whether line is a commentable new-side line for file.
type GraphContext ¶
type GraphContext struct {
CallerMap map[string][]string
CalleeRefs []CalleeRef
Importers []string
Formatted string
FunctionsAnalyzed int
CallersFound int
CalleesFound int
}
GraphContext holds pre-assembled callers, callees, and importer paths for changed code.
func AssembleGraphContext ¶
func AssembleGraphContext( ctx context.Context, graph repositories.GraphRepository, collectionName string, files []services.PRFileInfo, contractDiffs []ContractDiff, filter services.SearchFilter, logger *zap.Logger, ) *GraphContext
AssembleGraphContext renders a dense, risk-sorted prompt block of callers and contract changes.
type IndexRetrievalServiceImpl ¶
type IndexRetrievalServiceImpl struct {
// contains filtered or unexported fields
}
func (*IndexRetrievalServiceImpl) DeleteIndex ¶
func (s *IndexRetrievalServiceImpl) DeleteIndex(ctx context.Context, req *dto.IndexDeleteRequest) (*dto.IndexDeleteResponse, error)
func (*IndexRetrievalServiceImpl) GetContext ¶
func (s *IndexRetrievalServiceImpl) GetContext(ctx context.Context, req *dto.ContextRequest) (*dto.ContextResponse, error)
func (*IndexRetrievalServiceImpl) GetIndexStatus ¶
func (s *IndexRetrievalServiceImpl) GetIndexStatus(ctx context.Context, repoPath, userID string, workspaceID uint64, machineID string) (*dto.IndexStatusResponse, error)
func (*IndexRetrievalServiceImpl) GraphQuery ¶
func (s *IndexRetrievalServiceImpl) GraphQuery(ctx context.Context, req *dto.GraphQueryRequest) (*dto.GraphQueryResponse, error)
func (*IndexRetrievalServiceImpl) Search ¶
func (s *IndexRetrievalServiceImpl) Search(ctx context.Context, req *dto.SearchRequest) (*dto.SearchResponse, error)
func (*IndexRetrievalServiceImpl) TriggerIndex ¶
func (s *IndexRetrievalServiceImpl) TriggerIndex(ctx context.Context, req *dto.IndexRequest) (string, error)
type OpenAIReviewer ¶
type OpenAIReviewer struct {
// contains filtered or unexported fields
}
OpenAIReviewer implements services.Reviewer using the OpenAI Responses API.
func (*OpenAIReviewer) GetMetrics ¶
func (r *OpenAIReviewer) GetMetrics() *services.ReviewMetrics
func (*OpenAIReviewer) Review ¶
func (r *OpenAIReviewer) Review(ctx context.Context, input services.ReviewInput) (*services.ReviewOutput, error)
type PRClassification ¶
type PRClassification int
PRClassification determines how a PR should be reviewed.
const ( // PRSkip means no AI review needed (docs, lockfiles, CI config). PRSkip PRClassification = iota // PRTrivial means a cheap fast review (config, test-only, small changes). PRTrivial // PRStandard means a normal review with graph context. PRStandard )
func ClassifyPR ¶
func ClassifyPR(files []services.PRFileInfo) (PRClassification, string)
ClassifyPR determines the review classification for a PR based on its files. This is the gatekeeper — it runs before any LLM call.
func (PRClassification) String ¶
func (c PRClassification) String() string
type Pipeline ¶
type Pipeline struct {
// contains filtered or unexported fields
}
func NewPipeline ¶
func NewPipeline( anthropicCfg config.AnthropicConfig, reviewerCfg config.ReviewerConfig, openAICfg config.OpenAIConfig, indexerCfg config.IndexerConfig, store repositories.VectorRepository, graph repositories.GraphRepository, textRepo repositories.TextSearchRepository, repoRepo repositories.RepoRepository, shardRepo repositories.ShardRepository, embedder services.EmbedderService, indexer services.IndexerService, merkle services.MerkleService, prompts *PromptProvider, logger *zap.Logger, ) *Pipeline
func (*Pipeline) Analyze ¶
func (p *Pipeline) Analyze(ctx context.Context, repoPath string, indexReq *dto.IndexRequest) (*services.ReviewOutput, *services.ReviewMetrics, error)
func (*Pipeline) Index ¶
Index is the legacy repo-level entry point used by /index/trigger and codereview. It resolves the collection, builds a fresh Merkle tree from the source provider, diffs it against the stored tree, and delegates the actual indexing work to IndexChangedFiles. The Merkle tree is saved only when the delegate reports zero per-file failures (Delta A in the WS2 plan) so any failed files are automatically retried on the next Index call.
func (*Pipeline) IndexChangedFiles ¶
func (p *Pipeline) IndexChangedFiles( ctx context.Context, collectionName string, indexRoot string, identity services.IndexIdentity, provider services.SourceProvider, changedFiles []string, deletedFiles []string, ) (*services.IndexStats, error)
IndexChangedFiles indexes exactly the specified files and removes the specified paths from Qdrant, FalkorDB, and the text store. It does NOT touch the Merkle tree, resolve the collection name, or decide which files are "changed" — all of that is the caller's responsibility.
Contract (see services/pipeline_identity.go for the full description):
return (stats, nil) → batch reached a commit-worthy state; streaming
workers call markBatchProcessed(stats).
return (nil, err) → whole-batch failure. TerminalError wraps errors
that must not be retried (markBatchTerminallyFailed
via the durable manifest); ordinary errors bubble
up for Asynq retry.
never (stats, err) → forbidden; would double-account.
Callers supplying an InMemorySourceProvider MUST pass indexRoot="". The legacy Pipeline.Index wrapper passes req.RepoPath (or "" for S3) to match the pre-refactor behavior.
func (*Pipeline) IsCollectionPopulated ¶
IsCollectionPopulated reports whether the repo's vector collection has any points. Errors are treated as cold so the caller falls into the sync-index path rather than running a review without context.
func (*Pipeline) Review ¶
func (p *Pipeline) Review(ctx context.Context, req *dto.ReviewRequest) (*services.ReviewOutput, *services.ReviewMetrics, error)
type PromptProvider ¶
type PromptProvider struct {
// contains filtered or unexported fields
}
PromptProvider provides prompt templates via compile-time embedded text files.
func NewPromptProvider ¶
func NewPromptProvider() *PromptProvider
func (*PromptProvider) Audit ¶
func (p *PromptProvider) Audit() string
func (*PromptProvider) MaxTurns ¶
func (p *PromptProvider) MaxTurns() string
func (*PromptProvider) SystemReview ¶
func (p *PromptProvider) SystemReview() string
type RiskAssessment ¶
type RiskAssessment struct {
Level string
Score float64
Reason string
Factors []services.RiskFactor
}
RiskAssessment is the deterministic structural-risk output.
type ShardBootstrap ¶
type ShardBootstrap struct {
// contains filtered or unexported fields
}
func NewShardBootstrap ¶
func NewShardBootstrap( shardCfg config.ShardConfig, openAICfg config.OpenAIConfig, store repositories.VectorRepository, logger *zap.Logger, ) *ShardBootstrap
type ToolExecutor ¶
type ToolExecutor struct {
// contains filtered or unexported fields
}
func NewToolExecutor ¶
func NewToolExecutor( ret services.RetrieverService, graph repositories.GraphRepository, repoPath string, collectionName string, filter services.SearchFilter, logger *zap.Logger, ) *ToolExecutor
func (*ToolExecutor) HasBackend ¶
func (e *ToolExecutor) HasBackend() bool
func (*ToolExecutor) SetMetrics ¶
func (e *ToolExecutor) SetMetrics(m *services.ReviewMetrics)
Source Files
¶
- batch_id.go
- codereview_helpers.go
- context_assembler.go
- contract_diff.go
- diff_anchor.go
- embedder_semaphore.go
- embedder_service_impl.go
- errors.go
- gatekeeper.go
- hld_synthesis.go
- index_retrieval_service_impl.go
- indexer_constants.go
- indexer_router.go
- indexer_treesitter.go
- indexer_treesitter_extractor.go
- indexer_treesitter_languages.go
- merkle_service_impl.go
- openai_reviewer.go
- outbox_dispatcher_impl.go
- pipeline.go
- prompt_provider.go
- resty_client.go
- retriever_factory.go
- retriever_graph.go
- retriever_grep.go
- retriever_hybrid.go
- retriever_keyword.go
- retriever_multi.go
- retriever_vector.go
- reviewer.go
- risk_score.go
- shard_bootstrap.go
- smart_chunker.go
- source_local.go
- source_s3.go
- sync_session_diff_helpers.go
- sync_session_service_impl.go
- sync_session_service_ingest.go
- tool_executor.go