services

package
v0.4.0-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

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

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

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

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

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

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

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

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

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

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

func (s *PluginService) ListCachedPlugins(ctx context.Context) ([]*entities.Plugin, error)

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.

func (*PluginService) PublishPlugin

func (s *PluginService) PublishPlugin(
	ctx context.Context,
	plugin *entities.Plugin,
	wasm io.Reader,
	shouldSign bool,
) error

PublishPlugin uploads a plugin to a registry.

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 WithLogger

func WithLogger(l *slog.Logger) PluginServiceOption

WithLogger sets the logger.

func WithResolver

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

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

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL