Documentation
¶
Overview ¶
Package services contains application use cases.
Package services contains application use cases.
Package services contains application use cases.
Package services contains application use cases.
Index ¶
- type CachedPluginResolver
- type CapabilityGatekeeper
- type CapabilityOrchestrator
- func (o *CapabilityOrchestrator) CollectCapabilities(ctx context.Context, profile entities.ProfileReader, pluginDir string) (map[string][]capabilities.Capability, ports.PluginRuntime, error)
- func (o *CapabilityOrchestrator) CollectRequiredCapabilities(ctx context.Context, profile entities.ProfileReader, ...) (map[string][]capabilities.Capability, error)
- func (o *CapabilityOrchestrator) GrantCapabilities(required map[string][]capabilities.Capability, trustAll bool) (map[string][]capabilities.Capability, error)
- type CapabilityOrchestratorOption
- func WithAnalyzer(a ports.CapabilityAnalyzer) CapabilityOrchestratorOption
- func WithCapabilityRegistry(r *capabilities.Registry) CapabilityOrchestratorOption
- func WithGatekeeper(g ports.CapabilityGatekeeperPort) CapabilityOrchestratorOption
- func WithSecurityConfig(configPath, securityLevel string) CapabilityOrchestratorOption
- func WithTrustAll(trust bool) CapabilityOrchestratorOption
- type CheckProfileUseCase
- type CheckProfileUseCaseOption
- func WithCapabilityOrchestrator(o *CapabilityOrchestrator) CheckProfileUseCaseOption
- func WithEngineFactory(f ports.EngineFactory) CheckProfileUseCaseOption
- func WithLockfileService(s *LockfileService) CheckProfileUseCaseOption
- func WithPluginResolver(r ports.PluginDirectoryResolver) CheckProfileUseCaseOption
- func WithPluginService(s *PluginService) CheckProfileUseCaseOption
- func WithProfileValidator(v ports.ProfileValidator) CheckProfileUseCaseOption
- func WithSystemConfig(c ports.SystemConfigProvider) CheckProfileUseCaseOption
- func WithUseCaseLogger(l *slog.Logger) CheckProfileUseCaseOption
- type EmbeddedPluginResolver
- type LockfileService
- type PlanProfileUseCase
- type PlanProfileUseCaseOption
- type PluginService
- func (s *PluginService) ListCachedPlugins(ctx context.Context) ([]*entities.Plugin, error)
- func (s *PluginService) LoadPlugin(ctx context.Context, spec *dto.PluginSpecDTO) (string, error)
- func (s *PluginService) PruneCache(ctx context.Context, keepVersions int) error
- func (s *PluginService) PublishPlugin(ctx context.Context, plugin *entities.Plugin, wasm io.Reader, shouldSign bool) error
- type PluginServiceOption
- type RegistryPluginResolver
- type ValidateProfileUseCase
- type ValidateProfileUseCaseOption
- func WithValidateDependencyResolver(r *domainservices.DependencyResolver) ValidateProfileUseCaseOption
- func WithValidateExpectValidator(v *domainservices.ExpectValidator) ValidateProfileUseCaseOption
- func WithValidateLogger(l *slog.Logger) ValidateProfileUseCaseOption
- func WithValidateProfileValidator(v ports.ProfileValidator) ValidateProfileUseCaseOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CachedPluginResolver ¶
type CachedPluginResolver struct {
services.BaseResolver
// contains filtered or unexported fields
}
CachedPluginResolver checks local cache for plugins.
func NewCachedPluginResolver ¶
func NewCachedPluginResolver(repository ports.PluginRepository) *CachedPluginResolver
NewCachedPluginResolver creates a cached plugin resolver.
func (*CachedPluginResolver) Resolve ¶
func (r *CachedPluginResolver) Resolve(ctx context.Context, ref values.PluginReference) (*entities.Plugin, error)
Resolve checks cache, otherwise delegates to next.
type CapabilityGatekeeper ¶
type CapabilityGatekeeper struct {
// contains filtered or unexported fields
}
CapabilityGatekeeper handles capability granting decisions, user interaction, and persistence. This is an application service responsible for the security boundary between required and granted capabilities.
func NewCapabilityGatekeeper ¶
func NewCapabilityGatekeeper(configPath string, securityLevel string) *CapabilityGatekeeper
NewCapabilityGatekeeper creates a new capability gatekeeper.
func (*CapabilityGatekeeper) GrantCapabilities ¶
func (g *CapabilityGatekeeper) GrantCapabilities( required capabilities.Grant, capabilityInfo map[string]ports.CapabilityInfo, trustAll bool, ) (capabilities.Grant, error)
GrantCapabilities determines which capabilities to grant based on security policy, user input, and saved grants. It handles the complete granting workflow: check saved grants, apply security policy, prompt if needed, persist decisions.
Parameters:
- required: capabilities requested by plugins
- capabilityInfo: metadata about each capability (is it broad, profile-specific alternative, etc.)
- trustAll: if true, auto-grant all capabilities without prompting
Returns:
- granted capabilities
- error if user denies or security policy blocks
type CapabilityOrchestrator ¶
type CapabilityOrchestrator struct {
// contains filtered or unexported fields
}
CapabilityOrchestrator coordinates capability collection and granting. It delegates to specialized services: - CapabilityAnalyzer for extraction (domain logic) - CapabilityGatekeeper for granting (security boundary)
func NewCapabilityOrchestrator ¶
func NewCapabilityOrchestrator( runtimeFactory ports.PluginRuntimeFactory, opts ...CapabilityOrchestratorOption, ) *CapabilityOrchestrator
NewCapabilityOrchestrator creates a capability orchestrator with the given options. RuntimeFactory is required for creating plugin runtimes.
func (*CapabilityOrchestrator) CollectCapabilities ¶
func (o *CapabilityOrchestrator) CollectCapabilities(ctx context.Context, profile entities.ProfileReader, pluginDir string) (map[string][]capabilities.Capability, ports.PluginRuntime, error)
CollectCapabilities creates a temporary runtime and collects required capabilities. Returns the required capabilities and the temporary runtime (caller must close it).
func (*CapabilityOrchestrator) CollectRequiredCapabilities ¶
func (o *CapabilityOrchestrator) CollectRequiredCapabilities(ctx context.Context, profile entities.ProfileReader, runtime ports.PluginRuntime, pluginDir string) (map[string][]capabilities.Capability, error)
CollectRequiredCapabilities loads plugins and identifies requirements. It prioritizes specific capabilities extracted from profile configs over plugin metadata.
func (*CapabilityOrchestrator) GrantCapabilities ¶
func (o *CapabilityOrchestrator) GrantCapabilities(required map[string][]capabilities.Capability, trustAll bool) (map[string][]capabilities.Capability, error)
GrantCapabilities resolves permissions via the gatekeeper. Delegates the complete granting workflow to CapabilityGatekeeper.
type CapabilityOrchestratorOption ¶
type CapabilityOrchestratorOption func(*CapabilityOrchestrator)
CapabilityOrchestratorOption configures a CapabilityOrchestrator.
func WithAnalyzer ¶
func WithAnalyzer(a ports.CapabilityAnalyzer) CapabilityOrchestratorOption
WithAnalyzer sets a custom capability analyzer.
func WithCapabilityRegistry ¶
func WithCapabilityRegistry(r *capabilities.Registry) CapabilityOrchestratorOption
WithCapabilityRegistry sets a capability registry to use for the analyzer.
func WithGatekeeper ¶
func WithGatekeeper(g ports.CapabilityGatekeeperPort) CapabilityOrchestratorOption
WithGatekeeper sets a custom capability gatekeeper.
func WithSecurityConfig ¶
func WithSecurityConfig(configPath, securityLevel string) CapabilityOrchestratorOption
WithSecurityConfig sets the config path and security level for the gatekeeper.
func WithTrustAll ¶
func WithTrustAll(trust bool) CapabilityOrchestratorOption
WithTrustAll sets the trust-all flag for capability granting.
type CheckProfileUseCase ¶
type CheckProfileUseCase struct {
// contains filtered or unexported fields
}
CheckProfileUseCase orchestrates the complete profile check workflow. This is a pure application layer component that depends only on ports.
func NewCheckProfileUseCase ¶
func NewCheckProfileUseCase( profileLoader ports.ProfileLoader, profileCompiler *services.ProfileCompiler, opts ...CheckProfileUseCaseOption, ) *CheckProfileUseCase
NewCheckProfileUseCase creates a new check profile use case. ProfileLoader and ProfileCompiler are required dependencies.
func (*CheckProfileUseCase) CheckFailed ¶
func (uc *CheckProfileUseCase) CheckFailed(result *execution.ExecutionResult) bool
CheckFailed returns true if the execution result indicates failures.
func (*CheckProfileUseCase) Execute ¶
func (uc *CheckProfileUseCase) Execute(ctx context.Context, req dto.CheckProfileRequest) (*dto.CheckProfileResponse, error)
Execute runs the complete check profile workflow.
type CheckProfileUseCaseOption ¶
type CheckProfileUseCaseOption func(*CheckProfileUseCase)
CheckProfileUseCaseOption configures a CheckProfileUseCase.
func WithCapabilityOrchestrator ¶
func WithCapabilityOrchestrator(o *CapabilityOrchestrator) CheckProfileUseCaseOption
WithCapabilityOrchestrator sets the capability orchestrator.
func WithEngineFactory ¶
func WithEngineFactory(f ports.EngineFactory) CheckProfileUseCaseOption
WithEngineFactory sets the engine factory.
func WithLockfileService ¶
func WithLockfileService(s *LockfileService) CheckProfileUseCaseOption
WithLockfileService sets the lockfile service.
func WithPluginResolver ¶
func WithPluginResolver(r ports.PluginDirectoryResolver) CheckProfileUseCaseOption
WithPluginResolver sets the plugin directory resolver.
func WithPluginService ¶
func WithPluginService(s *PluginService) CheckProfileUseCaseOption
WithPluginService sets the plugin service.
func WithProfileValidator ¶
func WithProfileValidator(v ports.ProfileValidator) CheckProfileUseCaseOption
WithProfileValidator sets the profile validator.
func WithSystemConfig ¶
func WithSystemConfig(c ports.SystemConfigProvider) CheckProfileUseCaseOption
WithSystemConfig sets the system config provider.
func WithUseCaseLogger ¶
func WithUseCaseLogger(l *slog.Logger) CheckProfileUseCaseOption
WithUseCaseLogger sets the logger.
type EmbeddedPluginResolver ¶
type EmbeddedPluginResolver struct {
services.BaseResolver
// contains filtered or unexported fields
}
EmbeddedPluginResolver checks for built-in plugins.
func NewEmbeddedPluginResolver ¶
func NewEmbeddedPluginResolver(source ports.EmbeddedPluginSource) *EmbeddedPluginResolver
NewEmbeddedPluginResolver creates an embedded plugin resolver.
func (*EmbeddedPluginResolver) Resolve ¶
func (r *EmbeddedPluginResolver) Resolve(ctx context.Context, ref values.PluginReference) (*entities.Plugin, error)
Resolve checks if plugin is embedded, otherwise delegates to next.
type LockfileService ¶
type LockfileService struct {
// contains filtered or unexported fields
}
LockfileService orchestrates plugin version resolution and locking.
func NewLockfileService ¶
func NewLockfileService( repo ports.LockfileRepository, resolver ports.VersionResolver, digester ports.PluginDigester, ) *LockfileService
NewLockfileService creates a new LockfileService.
func (*LockfileService) ResolvePlugins ¶
func (s *LockfileService) ResolvePlugins( ctx context.Context, profile *entities.Profile, lockfilePath string, ) (*entities.Lockfile, error)
ResolvePlugins resolves plugin versions using the lockfile if available, or falls back to resolving constraints and updating the lockfile.
type PlanProfileUseCase ¶
type PlanProfileUseCase struct {
// contains filtered or unexported fields
}
PlanProfileUseCase generates an execution plan without running controls. This provides a dry-run view showing what would execute and in what order.
func NewPlanProfileUseCase ¶
func NewPlanProfileUseCase( profileLoader ports.ProfileLoader, profileCompiler *services.ProfileCompiler, opts ...PlanProfileUseCaseOption, ) *PlanProfileUseCase
NewPlanProfileUseCase creates a new plan profile use case. ProfileLoader and ProfileCompiler are required dependencies.
func (*PlanProfileUseCase) Execute ¶
func (uc *PlanProfileUseCase) Execute( ctx context.Context, req dto.PlanProfileRequest, ) (*dto.PlanProfileResponse, error)
Execute generates the execution plan.
type PlanProfileUseCaseOption ¶
type PlanProfileUseCaseOption func(*PlanProfileUseCase)
PlanProfileUseCaseOption configures a PlanProfileUseCase.
func WithPlanDependencyResolver ¶
func WithPlanDependencyResolver(r *services.DependencyResolver) PlanProfileUseCaseOption
WithPlanDependencyResolver sets a custom dependency resolver.
func WithPlanLogger ¶
func WithPlanLogger(l *slog.Logger) PlanProfileUseCaseOption
WithPlanLogger sets the logger.
type PluginService ¶
type PluginService struct {
// contains filtered or unexported fields
}
PluginService orchestrates plugin management use cases. Coordinates domain services and infrastructure adapters.
func NewPluginService ¶
func NewPluginService( repository ports.PluginRepository, registry ports.PluginRegistry, opts ...PluginServiceOption, ) *PluginService
NewPluginService creates a plugin service with the given options. Repository and registry are required dependencies.
func (*PluginService) ListCachedPlugins ¶
ListCachedPlugins returns all plugins in local cache.
func (*PluginService) LoadPlugin ¶
func (s *PluginService) LoadPlugin(ctx context.Context, spec *dto.PluginSpecDTO) (string, error)
LoadPlugin is the main use case for loading a plugin. Returns the file path to the WASM binary.
func (*PluginService) PruneCache ¶
func (s *PluginService) PruneCache(ctx context.Context, keepVersions int) error
PruneCache removes old plugin versions.
type PluginServiceOption ¶
type PluginServiceOption func(*PluginService)
PluginServiceOption configures a PluginService.
func WithIntegrityService ¶
func WithIntegrityService(is *services.IntegrityService) PluginServiceOption
WithIntegrityService sets the integrity service.
func WithIntegrityVerifier ¶
func WithIntegrityVerifier(iv ports.IntegrityVerifier) PluginServiceOption
WithIntegrityVerifier sets the integrity verifier.
func WithResolver ¶
func WithResolver(r services.PluginResolutionStrategy) PluginServiceOption
WithResolver sets the plugin resolution strategy.
type RegistryPluginResolver ¶
type RegistryPluginResolver struct {
services.BaseResolver
// contains filtered or unexported fields
}
RegistryPluginResolver pulls plugins from OCI registries.
func NewRegistryPluginResolver ¶
func NewRegistryPluginResolver( registry ports.PluginRegistry, repository ports.PluginRepository, logger *slog.Logger, ) *RegistryPluginResolver
NewRegistryPluginResolver creates a registry resolver.
func (*RegistryPluginResolver) Resolve ¶
func (r *RegistryPluginResolver) Resolve(ctx context.Context, ref values.PluginReference) (*entities.Plugin, error)
Resolve pulls from registry and caches.
type ValidateProfileUseCase ¶
type ValidateProfileUseCase struct {
// contains filtered or unexported fields
}
ValidateProfileUseCase validates profile structure without execution. This provides fast feedback during profile development by checking: - Profile metadata (name, version) - Control definitions (ID, name, observations) - Dependency graph (cycle detection) - Expect expression syntax (expr-lang)
func NewValidateProfileUseCase ¶
func NewValidateProfileUseCase( profileLoader ports.ProfileLoader, profileCompiler *domainservices.ProfileCompiler, opts ...ValidateProfileUseCaseOption, ) *ValidateProfileUseCase
NewValidateProfileUseCase creates a new validate profile use case. ProfileLoader and ProfileCompiler are required dependencies.
func (*ValidateProfileUseCase) Execute ¶
func (uc *ValidateProfileUseCase) Execute( ctx context.Context, req dto.ValidateProfileRequest, ) (*dto.ValidateProfileResponse, error)
Execute validates the profile and returns validation results.
type ValidateProfileUseCaseOption ¶
type ValidateProfileUseCaseOption func(*ValidateProfileUseCase)
ValidateProfileUseCaseOption configures a ValidateProfileUseCase.
func WithValidateDependencyResolver ¶
func WithValidateDependencyResolver(r *domainservices.DependencyResolver) ValidateProfileUseCaseOption
WithValidateDependencyResolver sets a custom dependency resolver.
func WithValidateExpectValidator ¶
func WithValidateExpectValidator(v *domainservices.ExpectValidator) ValidateProfileUseCaseOption
WithValidateExpectValidator sets a custom expect validator.
func WithValidateLogger ¶
func WithValidateLogger(l *slog.Logger) ValidateProfileUseCaseOption
WithValidateLogger sets the logger.
func WithValidateProfileValidator ¶
func WithValidateProfileValidator(v ports.ProfileValidator) ValidateProfileUseCaseOption
WithValidateProfileValidator sets the profile validator.