Documentation
¶
Overview ¶
Package execute provides business logic for validating and executing solutions. This package is the shared domain layer used by CLI, MCP, and future API consumers.
Index ¶
- func BuildExecutionData(resolverCtx *resolver.Context, resolvers []*resolver.Resolver, ...) map[string]any
- func BuildProviderSummary(resolverCtx *resolver.Context, resolvers []*resolver.Resolver) map[string]any
- func CalculateValueSize(value any) int64
- func FilterResolversWithDependencies(resolvers []*resolver.Resolver, targetNames []string, ...) []*resolver.Resolver
- func RenderGraph(w io.Writer, graph GraphRenderer, data any, format string) error
- func ResolverProviderName(r *resolver.Resolver) string
- func ResolversForPreview(ctx context.Context, sol *solution.Solution, params map[string]any, ...) (map[string]any, error)
- type ActionExecutionConfig
- type ActionExecutionResult
- type GraphRenderer
- type ResolverExecutionConfig
- type ResolverExecutionResult
- type ResolverRegistryAdapter
- type SolutionValidationResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildExecutionData ¶
func BuildExecutionData( resolverCtx *resolver.Context, resolvers []*resolver.Resolver, totalElapsed time.Duration, ) map[string]any
BuildExecutionData constructs structured execution metadata from resolver results. The returned map is extensible — new top-level sections can be added without breaking consumers (e.g. "diagrams", "timeline", "warnings").
func BuildProviderSummary ¶
func BuildProviderSummary( resolverCtx *resolver.Context, resolvers []*resolver.Resolver, ) map[string]any
BuildProviderSummary aggregates per-provider usage statistics from resolver execution.
func CalculateValueSize ¶
CalculateValueSize estimates the size of a value in bytes by JSON-marshalling it.
func FilterResolversWithDependencies ¶
func FilterResolversWithDependencies(resolvers []*resolver.Resolver, targetNames []string, lookup resolver.DescriptorLookup) []*resolver.Resolver
FilterResolversWithDependencies returns the specified resolvers and all their dependencies. When targetNames is empty, all resolvers are returned. Uses resolver.ExtractDependencies to detect dependencies from CEL expressions, Go templates, explicit rslvr: references, and provider-specific extraction.
func RenderGraph ¶
RenderGraph renders a graph in the specified format using the GraphRenderer interface.
func ResolverProviderName ¶
ResolverProviderName extracts the primary provider name from a resolver.
func ResolversForPreview ¶ added in v0.6.0
func ResolversForPreview( ctx context.Context, sol *solution.Solution, params map[string]any, reg *provider.Registry, ) (map[string]any, error)
ResolversForPreview is a convenience wrapper over Resolvers that accepts a provider.Registry directly and returns only the resolved data map. It initialises a default registry when reg is nil and reads the execution config from context. This is the shared entry point for preview/render operations in both the MCP server and the CLI.
Types ¶
type ActionExecutionConfig ¶ added in v0.6.0
type ActionExecutionConfig struct {
// DefaultTimeout is the default timeout per action execution.
DefaultTimeout time.Duration `json:"defaultTimeout,omitempty" yaml:"defaultTimeout,omitempty" doc:"Default per-action execution timeout"`
// GracePeriod is the cancellation grace period.
GracePeriod time.Duration `json:"gracePeriod,omitempty" yaml:"gracePeriod,omitempty" doc:"Cancellation grace period"`
// MaxConcurrency limits concurrent action execution (0=unlimited).
MaxConcurrency int `json:"maxConcurrency,omitempty" yaml:"maxConcurrency,omitempty" doc:"Maximum concurrent actions" maximum:"1000"`
// OutputDir is the target directory for action output. When set, providers
// in action mode resolve relative paths against this directory instead of CWD.
// An empty string means actions use CWD (backward-compatible default).
OutputDir string `json:"outputDir,omitempty" yaml:"outputDir,omitempty" doc:"Target directory for action output" maxLength:"4096"`
// Cwd is the original working directory to expose as __cwd in action
// expressions. When empty, the executor captures os.Getwd() at creation time.
// Callers that change the working directory before creating the executor
// (e.g., bundle extraction) should set this explicitly.
Cwd string `json:"-" yaml:"-"`
}
ActionExecutionConfig holds action execution parameters decoupled from CLI types. This allows the MCP server and other consumers to configure action execution without constructing CLI-specific scaffolding (IOStreams, flag sets, etc.).
func ActionExecutionConfigFromContext ¶ added in v0.6.0
func ActionExecutionConfigFromContext(ctx context.Context) ActionExecutionConfig
ActionExecutionConfigFromContext creates an ActionExecutionConfig from the application config stored in context, providing sensible defaults.
type ActionExecutionResult ¶ added in v0.6.0
type ActionExecutionResult struct {
// Result is the underlying action execution result.
Result *action.ExecutionResult `json:"result" yaml:"result" doc:"Action execution result"`
}
ActionExecutionResult wraps the action executor result with additional metadata.
func Actions ¶ added in v0.6.0
func Actions( ctx context.Context, sol *solution.Solution, resolverData map[string]any, reg *provider.Registry, cfg ActionExecutionConfig, ) (*ActionExecutionResult, error)
Actions runs the action execution pipeline on the given solution. It accepts pre-resolved data from a prior resolver execution and a provider registry. When cfg.OutputDir is set, providers executing in action mode resolve relative paths against that directory instead of CWD.
NOTE: This function performs real execution including filesystem changes (e.g. creating OutputDir). For dry-run semantics, callers should use dryrun.Generate instead — it builds the action graph and generates WhatIf descriptions without invoking providers or creating directories.
type GraphRenderer ¶
type GraphRenderer interface {
RenderASCII(w io.Writer) error
RenderDOT(w io.Writer) error
RenderMermaid(w io.Writer) error
}
GraphRenderer defines the interface for types that can render as ASCII, DOT, and Mermaid.
type ResolverExecutionConfig ¶
type ResolverExecutionConfig struct {
// Timeout is the default timeout per resolver.
Timeout time.Duration `json:"timeout,omitempty" yaml:"timeout,omitempty" doc:"Default timeout per resolver"`
// PhaseTimeout is the timeout for each execution phase.
PhaseTimeout time.Duration `json:"phaseTimeout,omitempty" yaml:"phaseTimeout,omitempty" doc:"Timeout for each execution phase"`
// MaxConcurrency limits concurrent resolver execution (0=unlimited).
MaxConcurrency int `json:"maxConcurrency,omitempty" yaml:"maxConcurrency,omitempty" doc:"Maximum concurrent resolvers"`
// WarnValueSize triggers a warning when resolver values exceed this size in bytes.
WarnValueSize int64 `json:"warnValueSize,omitempty" yaml:"warnValueSize,omitempty" doc:"Warn when value exceeds this size"`
// MaxValueSize rejects resolver values exceeding this size in bytes.
MaxValueSize int64 `json:"maxValueSize,omitempty" yaml:"maxValueSize,omitempty" doc:"Reject values exceeding this size"`
// ValidateAll validates all resolvers even if some fail.
ValidateAll bool `json:"validateAll,omitempty" yaml:"validateAll,omitempty" doc:"Validate all resolvers even on failure"`
// SkipValidation skips resolver validation.
SkipValidation bool `json:"skipValidation,omitempty" yaml:"skipValidation,omitempty" doc:"Skip resolver validation"`
// SkipTransform skips resolver transforms.
SkipTransform bool `json:"skipTransform,omitempty" yaml:"skipTransform,omitempty" doc:"Skip resolver transforms"`
}
ResolverExecutionConfig holds resolver execution parameters decoupled from CLI types. This allows the MCP server to configure resolver execution without constructing fake CLI scaffolding (IOStreams, flag sets, etc.).
func ResolverExecutionConfigFromContext ¶
func ResolverExecutionConfigFromContext(ctx context.Context) ResolverExecutionConfig
ResolverExecutionConfigFromContext creates a ResolverExecutionConfig from the application config stored in context, providing sensible defaults.
type ResolverExecutionResult ¶
type ResolverExecutionResult struct {
// Data contains the resolved values keyed by resolver name.
Data map[string]any `json:"data" yaml:"data" doc:"Resolved values"`
// Context is the resolver execution context with full metadata.
// Only available when execution succeeds.
Context *resolver.Context `json:"-" yaml:"-"`
}
ResolverExecutionResult holds the structured output of resolver execution.
func Resolvers ¶
func Resolvers( ctx context.Context, sol *solution.Solution, params map[string]any, reg *provider.Registry, cfg ResolverExecutionConfig, ) (*ResolverExecutionResult, error)
Resolvers runs the resolver execution pipeline on the given solution. This standalone function decouples resolver execution from CLI-specific types (IOStreams, progress bars, output formatting). The MCP server uses this to execute resolvers and return structured results.
type ResolverRegistryAdapter ¶
type ResolverRegistryAdapter struct {
// contains filtered or unexported fields
}
ResolverRegistryAdapter adapts provider.Registry to resolver.RegistryInterface.
func NewResolverRegistryAdapter ¶
func NewResolverRegistryAdapter(registry *provider.Registry) *ResolverRegistryAdapter
NewResolverRegistryAdapter creates a new ResolverRegistryAdapter wrapping the given provider.Registry.
func (*ResolverRegistryAdapter) DescriptorLookup ¶
func (r *ResolverRegistryAdapter) DescriptorLookup() resolver.DescriptorLookup
func (*ResolverRegistryAdapter) Get ¶
func (r *ResolverRegistryAdapter) Get(name string) (provider.Provider, error)
func (*ResolverRegistryAdapter) List ¶
func (r *ResolverRegistryAdapter) List() []provider.Provider
type SolutionValidationResult ¶
type SolutionValidationResult struct {
// Valid is true when the solution passes all validation checks.
Valid bool `json:"valid" yaml:"valid" doc:"Whether the solution is valid"`
// HasResolvers indicates whether the solution defines resolvers.
HasResolvers bool `json:"hasResolvers" yaml:"hasResolvers" doc:"Whether the solution has resolvers"`
// HasWorkflow indicates whether the solution defines an action workflow.
HasWorkflow bool `json:"hasWorkflow" yaml:"hasWorkflow" doc:"Whether the solution has a workflow"`
// Errors contains any validation errors found.
Errors []string `json:"errors,omitempty" yaml:"errors,omitempty" doc:"Validation errors"`
}
SolutionValidationResult holds the structured results of validating a solution.
func ValidateSolution ¶
func ValidateSolution(_ context.Context, sol *solution.Solution, reg *provider.Registry) *SolutionValidationResult
ValidateSolution validates a loaded solution and its workflow against the given provider registry. This standalone function can be called from both the CLI and the MCP server without requiring CLI-specific types.