Documentation
¶
Index ¶
- func NewAdminService(taskQueue driven.TaskQueue, schedulerStore driven.SchedulerStore, ...) driving.AdminService
- func NewAuthService(userStore driven.UserStore, sessionStore driven.SessionStore, ...) driving.AuthService
- func NewBuiltinAvailabilityResolver(cfg driven.ConfigProvider) domain.AvailabilityResolver
- func NewCapabilitiesService(configProvider driven.ConfigProvider, store driven.CapabilityStore, ...) driving.CapabilitiesService
- func NewConnectionService(cfg ConnectionServiceConfig) driving.ConnectionService
- func NewContentFilterService() driven.ContentFilter
- func NewDocumentService(documentStore driven.DocumentStore, searchEngine driven.SearchEngine) driving.DocumentService
- func NewOAuthServerService(cfg OAuthServerServiceConfig) driving.OAuthServerService
- func NewOAuthService(cfg OAuthServiceConfig) driving.OAuthService
- func NewProviderService(configProvider driven.ConfigProvider) driving.ProviderService
- func NewSearchService(searchEngine driven.SearchEngine, documentStore driven.DocumentStore, ...) driving.SearchService
- func NewSettingsService(settingsStore driven.SettingsStore, aiFactory driven.AIServiceFactory, ...) driving.SettingsService
- func NewSetupService(userStore driven.UserStore, sourceStore driven.SourceStore, teamID string) driving.SetupService
- func NewSourceService(cfg SourceServiceConfig) driving.SourceService
- func NewUserService(cfg UserServiceConfig) driving.UserService
- func RegisterBuiltinCapabilities(registry domain.CapabilityRegistry) error
- func SyncTriggerFromContext(ctx context.Context) domain.TaskTrigger
- func WithSyncTrigger(ctx context.Context, trigger domain.TaskTrigger) context.Context
- type ConnectionServiceConfig
- type EntityRegisterCleanupObserver
- type OAuthServerServiceConfig
- type OAuthServiceConfig
- type Scheduler
- func (s *Scheduler) CreateScheduledTask(ctx context.Context, scheduled *domain.ScheduledTask) error
- func (s *Scheduler) DeleteScheduledTask(ctx context.Context, id string) error
- func (s *Scheduler) DisableScheduledTask(ctx context.Context, id string) error
- func (s *Scheduler) EnableScheduledTask(ctx context.Context, id string) error
- func (s *Scheduler) GetScheduledTask(ctx context.Context, id string) (*domain.ScheduledTask, error)
- func (s *Scheduler) ListScheduledTasks(ctx context.Context, teamID string) ([]*domain.ScheduledTask, error)
- func (s *Scheduler) Start(ctx context.Context) error
- func (s *Scheduler) Stop()
- func (s *Scheduler) TriggerNow(ctx context.Context, id string) (*domain.Task, error)
- func (s *Scheduler) UpdateScheduledTask(ctx context.Context, scheduled *domain.ScheduledTask) error
- type SchedulerConfig
- type SourceServiceConfig
- type SyncOrchestrator
- func (o *SyncOrchestrator) CancelSync(ctx context.Context, sourceID string) error
- func (o *SyncOrchestrator) GetSyncState(ctx context.Context, sourceID string) (*domain.SyncState, error)
- func (o *SyncOrchestrator) ListFailedDocuments(ctx context.Context, sourceID string, limit int) ([]domain.SyncFailedDoc, error)
- func (o *SyncOrchestrator) ListSyncStates(ctx context.Context) ([]*domain.SyncState, error)
- func (o *SyncOrchestrator) SyncAll(ctx context.Context) ([]*domain.SyncResult, error)
- func (o *SyncOrchestrator) SyncContainer(ctx context.Context, sourceID, containerID string) (*domain.SyncResult, error)
- func (o *SyncOrchestrator) SyncSource(ctx context.Context, sourceID string) (*domain.SyncResult, error)
- func (o *SyncOrchestrator) WaitForObservers(ctx context.Context) error
- type SyncOrchestratorConfig
- type UserServiceConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAdminService ¶
func NewAdminService( taskQueue driven.TaskQueue, schedulerStore driven.SchedulerStore, searchQueryRepository driven.SearchQueryRepository, sourceStore driven.SourceStore, ) driving.AdminService
NewAdminService creates a new AdminService
func NewAuthService ¶
func NewAuthService( userStore driven.UserStore, sessionStore driven.SessionStore, authAdapter driven.AuthAdapter, ) driving.AuthService
NewAuthService creates a new AuthService
func NewBuiltinAvailabilityResolver ¶ added in v0.4.0
func NewBuiltinAvailabilityResolver(cfg driven.ConfigProvider) domain.AvailabilityResolver
NewBuiltinAvailabilityResolver builds an AvailabilityResolver that answers for the seven Core built-in capabilities, using the supplied ConfigProvider as the backend-status source.
Returns false for any capability type it doesn't know about; compose with add-on resolvers via domain.NewCompositeAvailabilityResolver to extend coverage.
func NewCapabilitiesService ¶
func NewCapabilitiesService( configProvider driven.ConfigProvider, store driven.CapabilityStore, registry domain.CapabilityRegistry, resolver domain.AvailabilityResolver, ) driving.CapabilitiesService
NewCapabilitiesService wires the dependencies. The registry must already have descriptors registered by the time this service handles requests.
func NewConnectionService ¶
func NewConnectionService(cfg ConnectionServiceConfig) driving.ConnectionService
NewConnectionService creates a new connection service.
func NewContentFilterService ¶ added in v0.2.1
func NewContentFilterService() driven.ContentFilter
NewContentFilterService creates a new ContentFilter service. This service is stateless and can be shared across components.
func NewDocumentService ¶
func NewDocumentService( documentStore driven.DocumentStore, searchEngine driven.SearchEngine, ) driving.DocumentService
NewDocumentService creates a new DocumentService
func NewOAuthServerService ¶ added in v0.2.1
func NewOAuthServerService(cfg OAuthServerServiceConfig) driving.OAuthServerService
NewOAuthServerService creates a new OAuth Server service
func NewOAuthService ¶
func NewOAuthService(cfg OAuthServiceConfig) driving.OAuthService
NewOAuthService creates a new OAuth service.
func NewProviderService ¶
func NewProviderService(configProvider driven.ConfigProvider) driving.ProviderService
NewProviderService creates a new ProviderService.
func NewSearchService ¶
func NewSearchService( searchEngine driven.SearchEngine, documentStore driven.DocumentStore, services *runtime.Services, searchExecutor pipelineport.SearchExecutor, capabilityStore driven.CapabilityStore, settingsStore driven.SettingsStore, teamID string, ) driving.SearchService
NewSearchService creates a new SearchService AI services (embedding, LLM) are accessed dynamically via runtime.Services
func NewSettingsService ¶
func NewSettingsService( settingsStore driven.SettingsStore, aiFactory driven.AIServiceFactory, configProvider driven.ConfigProvider, services *runtime.Services, teamID string, ) driving.SettingsService
NewSettingsService creates a new SettingsService
func NewSetupService ¶
func NewSetupService( userStore driven.UserStore, sourceStore driven.SourceStore, teamID string, ) driving.SetupService
NewSetupService creates a new SetupService
func NewSourceService ¶
func NewSourceService(cfg SourceServiceConfig) driving.SourceService
NewSourceService creates a new SourceService.
func NewUserService ¶
func NewUserService(cfg UserServiceConfig) driving.UserService
NewUserService creates a new UserService.
func RegisterBuiltinCapabilities ¶ added in v0.4.0
func RegisterBuiltinCapabilities(registry domain.CapabilityRegistry) error
RegisterBuiltinCapabilities populates the registry with the seven capabilities Core ships out of the box. Callers (Core's main, or any add-on that builds on Core) MUST call this before constructing the CapabilitiesService — the service iterates the registry and won't see capabilities registered later.
Add-ons that need extra capabilities call registry.Register directly after this function returns. Registration order does not matter; the resolver walks dependencies generically.
Returns an error if any descriptor fails to register (typically because it was already registered — duplicate registration is a programmer error, see the registry's Register contract).
func SyncTriggerFromContext ¶ added in v0.4.0
func SyncTriggerFromContext(ctx context.Context) domain.TaskTrigger
SyncTriggerFromContext returns the trigger attached via WithSyncTrigger. When no trigger has been attached the helper returns TaskTriggerScheduled — matches the historical default so rows logged from non-orchestrator code paths (e.g. backfills, tests) get a sensible label rather than empty string.
func WithSyncTrigger ¶ added in v0.4.0
WithSyncTrigger returns a child context carrying the supplied trigger. Used by the worker after dequeuing a task: it reads the trigger off the task payload (Task.Trigger()) and threads it onto the orchestrator call's context so the rest of the pipeline can see it.
Types ¶
type ConnectionServiceConfig ¶
type ConnectionServiceConfig struct {
// ConnectionStore manages connection persistence.
ConnectionStore driven.ConnectionStore
// SourceStore manages source persistence (for checking usage).
SourceStore driven.SourceStore
// ContainerListerFactory creates container listers for providers.
ContainerListerFactory driven.ContainerListerFactory
// TokenProviderFactory creates token providers for testing connections.
TokenProviderFactory driven.TokenProviderFactory
}
ConnectionServiceConfig holds configuration for the connection service.
type EntityRegisterCleanupObserver ¶ added in v0.4.0
type EntityRegisterCleanupObserver struct {
// contains filtered or unexported fields
}
EntityRegisterCleanupObserver implements DocumentDeleteObserver to keep the entity_register cache aligned with the document store. When a document is deleted (per-doc or via source cascade) the observer removes every entity_register row keyed on that document_id.
Without this observer, cache rows accumulate across re-syncs as documents change ID — hundreds of orphaned rows in a typical deployment. The cache is keyed on (document_id, content_sha256, analyzer_version) so orphans never serve stale data, but they consume storage and pollute audits.
Observer failures are logged-and-ignored by the caller per Core's observer contract. This implementation logs internally too so a repeated cache-cleanup failure is visible without grepping the orchestrator's log line.
func NewEntityRegisterCleanupObserver ¶ added in v0.4.0
func NewEntityRegisterCleanupObserver(register driven.EntityRegister, logger *slog.Logger) *EntityRegisterCleanupObserver
NewEntityRegisterCleanupObserver wires the observer. register must be non-nil; the observer takes no action on a nil register (the field is checked at call time so a misconfigured wiring fails open with a log message rather than a nil-pointer panic).
func (*EntityRegisterCleanupObserver) OnDocumentDeleted ¶ added in v0.4.0
func (o *EntityRegisterCleanupObserver) OnDocumentDeleted(ctx context.Context, source *domain.Source, doc *domain.Document) error
OnDocumentDeleted removes all entity_register rows for the deleted document. Errors propagate upward so the orchestrator can log them alongside other observer outcomes.
func (*EntityRegisterCleanupObserver) OnSourceDeleted ¶ added in v0.4.0
func (o *EntityRegisterCleanupObserver) OnSourceDeleted(ctx context.Context, source *domain.Source) error
OnSourceDeleted is a no-op. Per Core's contract, OnDocumentDeleted fires for every document in a source before OnSourceDeleted fires — so per-doc cleanup has already run by the time we get here. Reserved as an extension point if a future shape needs source-level entity_register state.
type OAuthServerServiceConfig ¶ added in v0.2.1
type OAuthServerServiceConfig struct {
ClientStore driven.OAuthClientStore
CodeStore driven.AuthorizationCodeStore
TokenStore driven.OAuthTokenStore
JWTSecret string // For signing access tokens
MCPServerURL string // For audience validation
}
OAuthServerServiceConfig holds configuration for the OAuth Server service
type OAuthServiceConfig ¶
type OAuthServiceConfig struct {
// ConfigProvider retrieves OAuth app credentials from environment variables.
ConfigProvider driven.ConfigProvider
// OAuthStateStore manages OAuth flow state.
OAuthStateStore driven.OAuthStateStore
// ConnectionStore persists connector installations.
ConnectionStore driven.ConnectionStore
// OAuthHandlerFactory provides OAuth handlers per provider.
// Port interface - abstracts connector factory.
OAuthHandlerFactory driven.OAuthHandlerFactory
}
OAuthServiceConfig holds configuration for the OAuth service.
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler manages periodic task scheduling. It runs on worker nodes and enqueues tasks based on schedules.
For multi-worker deployments, configure a DistributedLock to prevent duplicate task enqueuing across instances.
func NewScheduler ¶
func NewScheduler(cfg SchedulerConfig) *Scheduler
NewScheduler creates a new scheduler.
func (*Scheduler) CreateScheduledTask ¶
CreateScheduledTask creates a new scheduled task.
func (*Scheduler) DeleteScheduledTask ¶
DeleteScheduledTask deletes a scheduled task.
func (*Scheduler) DisableScheduledTask ¶
DisableScheduledTask disables a scheduled task.
func (*Scheduler) EnableScheduledTask ¶
EnableScheduledTask enables a scheduled task.
func (*Scheduler) GetScheduledTask ¶
GetScheduledTask retrieves a scheduled task by ID.
func (*Scheduler) ListScheduledTasks ¶
func (s *Scheduler) ListScheduledTasks(ctx context.Context, teamID string) ([]*domain.ScheduledTask, error)
ListScheduledTasks lists all scheduled tasks for a team.
func (*Scheduler) Start ¶
Start begins the scheduler loop. It runs until Stop is called or context is cancelled.
func (*Scheduler) TriggerNow ¶
TriggerNow immediately enqueues a scheduled task (ignoring schedule).
func (*Scheduler) UpdateScheduledTask ¶
UpdateScheduledTask updates a scheduled task.
type SchedulerConfig ¶
type SchedulerConfig struct {
Store driven.SchedulerStore
TaskQueue driven.TaskQueue
Lock driven.DistributedLock // Optional: distributed lock for multi-instance coordination
Logger *slog.Logger
PollInterval time.Duration // How often to check for due tasks (default: 30s)
LockTTL time.Duration // TTL for the distributed lock (default: 60s)
LockRequired bool // If true, skip scheduling when lock cannot be acquired (default: true)
}
SchedulerConfig holds configuration for the scheduler.
type SourceServiceConfig ¶ added in v0.3.0
type SourceServiceConfig struct {
SourceStore driven.SourceStore
DocumentStore driven.DocumentStore
SyncStore driven.SyncStateStore
SearchEngine driven.SearchEngine
VectorIndex driven.VectorIndex
TaskQueue driven.TaskQueue
TeamID string
Logger *slog.Logger
DocumentDeleteObserver driven.DocumentDeleteObserver // Optional; nil means no observer.
}
SourceServiceConfig holds dependencies for SourceService.
type SyncOrchestrator ¶
type SyncOrchestrator struct {
// contains filtered or unexported fields
}
SyncOrchestrator coordinates the document sync pipeline. It implements the 7-step sync flow:
- Get source config
- Create connector
- Validate connector
- Get sync state (cursor for incremental sync)
- Fetch documents
- Process each document (normalise → chunk → embed → store → index)
- Update sync cursor
func NewSyncOrchestrator ¶
func NewSyncOrchestrator(cfg SyncOrchestratorConfig) *SyncOrchestrator
NewSyncOrchestrator creates a new sync orchestrator.
func (*SyncOrchestrator) CancelSync ¶
func (o *SyncOrchestrator) CancelSync(ctx context.Context, sourceID string) error
CancelSync cancels an ongoing sync for a source. Note: This is a placeholder - actual cancellation requires context propagation.
func (*SyncOrchestrator) GetSyncState ¶
func (o *SyncOrchestrator) GetSyncState(ctx context.Context, sourceID string) (*domain.SyncState, error)
GetSyncState retrieves the sync state for a source.
func (*SyncOrchestrator) ListFailedDocuments ¶ added in v0.4.0
func (o *SyncOrchestrator) ListFailedDocuments(ctx context.Context, sourceID string, limit int) ([]domain.SyncFailedDoc, error)
ListFailedDocuments returns the per-doc skip-list rows for a source. Empty slice when no failed-doc store is wired (legacy mode); the store's own ListBySource handles pagination ordering and limits.
func (*SyncOrchestrator) ListSyncStates ¶
ListSyncStates retrieves sync states for all sources.
func (*SyncOrchestrator) SyncAll ¶
func (o *SyncOrchestrator) SyncAll(ctx context.Context) ([]*domain.SyncResult, error)
SyncAll synchronizes all enabled sources for a team.
func (*SyncOrchestrator) SyncContainer ¶ added in v0.2.1
func (o *SyncOrchestrator) SyncContainer(ctx context.Context, sourceID, containerID string) (*domain.SyncResult, error)
SyncContainer synchronizes a single container within a source. This is used for incremental updates when containers are added.
func (*SyncOrchestrator) SyncSource ¶
func (o *SyncOrchestrator) SyncSource(ctx context.Context, sourceID string) (*domain.SyncResult, error)
SyncSource synchronizes a single source. This is the main entry point for the sync pipeline. For sources with container selection, it syncs each selected container.
func (*SyncOrchestrator) WaitForObservers ¶ added in v0.3.0
func (o *SyncOrchestrator) WaitForObservers(ctx context.Context) error
WaitForObservers blocks until every dispatched DocumentIngestObserver goroutine has returned, or until ctx is cancelled. Useful for tests that need to assert on observer side-effects after a sync completes, and for graceful shutdown paths that want to drain in-flight callbacks before tearing down dependencies (database connections, etc.).
Returns nil on clean drain, ctx.Err() on cancel/timeout. Observer errors are still logged-and-swallowed by the dispatch goroutine; this method only reports caller-side cancellation.
type SyncOrchestratorConfig ¶
type SyncOrchestratorConfig struct {
SourceStore driven.SourceStore
DocumentStore driven.DocumentStore
SyncStore driven.SyncStateStore
SearchEngine driven.SearchEngine
VectorIndex driven.VectorIndex
ConnectorFactory driven.ConnectorFactory
NormaliserReg driven.NormaliserRegistry
Services *runtime.Services
Logger *slog.Logger
IndexingExecutor pipelineport.IndexingExecutor // Required pipeline executor
CapabilitySet *pipeline.CapabilitySet // Capabilities for pipeline
CapabilityStore driven.CapabilityStore // For fetching capability preferences
SettingsStore driven.SettingsStore // For loading team settings
SyncEventRepo driven.SyncEventRepository // For audit logging of sync events
TeamID string // Team ID for settings lookup
DocumentIngestObserver driven.DocumentIngestObserver // Optional; nil means no observer.
DocumentDeleteObserver driven.DocumentDeleteObserver // Optional; nil means no observer.
Lock driven.DistributedLock // Optional. When set, SyncSource/SyncContainer acquire "sync:source:<id>" before running so concurrent invocations no-op (Skipped=true) instead of racing.
LockTTL time.Duration // Optional. Defaults to 1h. Ignored by PG advisory locks (which release on connection close).
Concurrency int // Optional. Per-container doc-level worker count. Defaults to defaultDocConcurrency (1) when zero.
OnDocumentIngestedTimeout time.Duration // Optional. Per-call timeout for the async DocumentIngestObserver. Defaults to 30s when zero.
ObserverQueueDepth int // Optional. Bounded goroutine pool depth for the async DocumentIngestObserver. Defaults to 32 when zero.
// FailedDocStore enables the per-document skip-list / retry ledger.
// When non-nil the orchestrator records per-doc failures here and
// always advances the cursor on a fresh delta batch (failures are
// retried independently). When nil the legacy "stall cursor on any
// error" behaviour is retained — kept for test wiring and any
// embedder that prefers the older semantics.
FailedDocStore driven.SyncFailedDocStore
// FailedDocBackoff overrides the default exponential schedule used
// when recording new failures. Optional — defaults to a sensible
// (5min base, 24h cap, 10 attempts) policy when the zero value is
// passed.
FailedDocBackoff driven.RetryBackoff
// RetryBatchPerSync caps how many previously-failing docs the
// pre-pass attempts per sync run. Defaults to 50 when zero.
RetryBatchPerSync int
}
SyncOrchestratorConfig holds dependencies for SyncOrchestrator.
type UserServiceConfig ¶ added in v0.3.0
type UserServiceConfig struct {
UserStore driven.UserStore
SessionStore driven.SessionStore
AuthAdapter driven.AuthAdapter
TeamID string
Logger *slog.Logger
UserCreateObserver driven.UserCreateObserver // Optional; nil means no observer.
UserDeleteObserver driven.UserDeleteObserver // Optional; nil means no observer.
}
UserServiceConfig holds dependencies for UserService.