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 ApplySolutionCELCostLimit(ctx context.Context, sol *solution.Solution) context.Context
- 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 IsValidationOnlyFailure(err error) bool
- 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 ResolverDiagnostic
- type ResolverExecutionConfig
- type ResolverExecutionResult
- type ResolverRegistryAdapter
- type SolutionValidationResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplySolutionCELCostLimit ¶ added in v0.17.0
ApplySolutionCELCostLimit injects the solution's CEL cost limit into the context if the solution defines one. The effective limit is min(solutionLimit, globalLimit) so that solutions cannot raise the limit above the operator-configured global default. When global limiting is disabled (globalLimit == 0), solution overrides are ignored.
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, explicit resolvers are excluded unless they are transitively required by a non-explicit resolver. Uses resolver.ExtractDependencies to detect dependencies from CEL expressions, Go templates, explicit rslvr: references, and provider-specific extraction.
func IsValidationOnlyFailure ¶ added in v0.24.0
IsValidationOnlyFailure reports whether every failure contained in err is a validation failure. It returns false when err contains any non-validation failure (such as a resolve- or transform-phase error) so those remain fatal. Non-fatal inspection mode only suppresses pure validation failures.
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 ResolverDiagnostic ¶ added in v0.24.0
type ResolverDiagnostic struct {
// Resolver is the name of the resolver that failed. It may be empty when
// the failure is not attributable to a specific resolver.
Resolver string `json:"resolver,omitempty" yaml:"resolver,omitempty" doc:"Name of the resolver that failed"`
// Phase is the execution phase number where the failure occurred (0 when unknown).
Phase int `json:"phase,omitempty" yaml:"phase,omitempty" doc:"Phase number where the failure occurred"`
// Message is the human-readable failure description.
Message string `json:"message" yaml:"message" doc:"Human-readable failure message"`
}
ResolverDiagnostic describes a single resolver validation or execution failure surfaced during a non-fatal inspection run.
func DiagnosticsFromError ¶ added in v0.24.0
func DiagnosticsFromError(err error) []ResolverDiagnostic
DiagnosticsFromError converts a resolver execution error into a structured list of per-resolver diagnostics. It understands AggregatedExecutionError (validate-all mode) and AggregatedValidationError, and falls back to a single generic diagnostic for any other error. Returns nil when err is nil.
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"`
// NonFatalValidation, when true, treats resolver validation-only failures
// as non-fatal: the populated values are returned alongside structured
// diagnostics (ResolverExecutionResult.Diagnostics) instead of aborting
// with an error. Resolve- and transform-phase failures (where no value
// could be produced) remain fatal. This is used by inspection and
// troubleshooting paths (run resolver, preview_resolvers) so that resolver
// output remains useful even when validation fails. It implies validate-all
// semantics so that all reachable resolvers populate their values.
NonFatalValidation bool `` /* 159-byte string literal not displayed */
}
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. When
// NonFatalValidation is enabled, this also includes partial values produced
// by resolvers that failed validation (their value is captured post-transform
// before the validate phase rejects it).
Data map[string]any `json:"data" yaml:"data" doc:"Resolved values"`
// Context is the resolver execution context with full metadata.
Context *resolver.Context `json:"-" yaml:"-"`
// Diagnostics holds the resolver validation or execution error collected
// when NonFatalValidation is enabled. It is nil when execution was clean.
// Use DiagnosticsFromError to convert it into a structured list.
Diagnostics error `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.