Solution Provider#
Date: February 9, 2026
Design Philosophy#
Three guiding principles:
Fail loud by default, opt into silence. Sub-solution failures should be Go errors unless the user explicitly asks for envelope-only reporting. This prevents the most common mistake (forgetting to check
status).Reuse existing types everywhere. The codebase already has
ValueRef,load.Loader,resolver.Context,action.ExecutionResult, etc. The solution provider should compose these, not reinvent them.Separation of loading vs execution. The provider should do one thing — execute a loaded solution. Loading is delegated entirely to a small
Loaderinterface backed bypkg/solution/load. This makes testing trivial and keeps the provider focused.
Purpose#
The solution provider enables solution composition — executing a sub-solution as an opaque unit of work and consuming its results. The parent solution never sees the sub-solution’s internal resolvers, actions, or DAG; it receives only the final output.
This supports a composition model where reusable solutions are published to the catalog and consumed as building blocks. A team maintains deploy-to-k8s@2.0.0 in the catalog, and any parent solution invokes it without knowing its internals.
What This Provider Does#
- Loads a sub-solution from a local file, catalog reference, or URL
- Executes the sub-solution’s resolvers (and optionally its workflow) as a self-contained unit
- Returns the sub-solution’s results to the parent as structured data
- Passes parameters from the parent into the sub-solution
- Detects circular references and enforces depth limits
What This Provider Does Not Do#
- Expose the sub-solution’s internal resolvers or actions to the parent
- Interleave sub-solution execution with parent execution
- Modify the sub-solution in any way
- Manage sub-solution lifecycle or state beyond a single execution
Capabilities#
| Capability | Context | Behavior |
|---|---|---|
from | Resolver resolve.with | Runs resolvers only, returns resolver values |
action | Workflow actions | Runs resolvers + workflow, returns full result |
Solution Sources#
The provider resolves sub-solutions from multiple locations, using the same loader (pkg/solution/load) as the parent scafctl run solution invocation:
| Source Type | Example source Value | Resolution |
|---|---|---|
| Local file | ./infra/database.yaml, /absolute/path.yaml | Loaded from the filesystem relative to the parent solution’s directory (or working directory when unset) |
| Catalog | deploy-to-k8s, deploy-to-k8s@2.0.0 | Searches local catalog first, then configured remote catalogs (bundle tar extracted to an ephemeral per-run temp directory) |
| URL | https://example.com/solution.yaml | Fetched via HTTP(S) |
The source value is classified with source.Classify (purely syntactic, first match wins): http(s):// is a URL; paths starting with /, ./, ~/, or ending in .yaml/.yml/.json are local files; host.tld/.../name and oci:// are registry references; anything else (name, name@1.2.3) is a catalog name. Stdin (-) is rejected for sub-solutions because the parent solution owns it.
Note: When a parent solution referencing local file paths (e.g.,
source: "./child.yaml") is built and pushed to a catalog, all referenced files, sub-solutions, and catalog dependencies are bundled into the artifact automatically. See catalog-build-bundling.md for the full design covering file bundling, multi-file composition (compose), catalog vendoring (solution.lock), and plugin dependencies (bundle.plugins).
Catalog Version Resolution#
Bare catalog names (e.g., deploy-to-k8s) resolve to the highest semver version at execution time. This is non-deterministic — if a new version is published between runs, the newer version is used silently.
For reproducible builds, use explicit versions: deploy-to-k8s@2.0.0. Digest pinning (deploy-to-k8s@sha256:...) provides the strongest guarantee by resolving via content hash.
Future Enhancement: The
solution.lockfile generated byscafctl package solutionrecords resolved catalog versions and digests for reproducible builds. At build time, bare catalog references are resolved and vendored into the bundle. See catalog-build-bundling.md for details on the lock file and vendoring mechanism.
Input Schema#
sourceis aValueRef— allowing dynamic resolution via CEL. This unlocks patterns like selecting a catalog solution based on a resolved environment value.inputsis explicitlymap[string]*spec.ValueRef— the same type used byProviderSource.InputsandAction.Inputs, giving us expr/tmpl/rslvr/literal support for free.propagateErrors— controls error behavior, defaulting totrue(Go error on failure). Setfalsefor envelope-only reporting.maxDepth— a hard recursion limit as defense in depth beyond circular detection.
source:
type: ValueRef
required: true
description: >
Location of the sub-solution. Supports literal string, CEL expression,
resolver reference, or Go template. Resolved value must be a string
(file path, catalog reference, or URL).
example:
literal: "deploy-to-k8s@2.0.0"
# or dynamically:
# expr: "'deploy-to-' + _.target + '@2.0.0'"
inputs:
type: map[string]*ValueRef
required: false
description: >
Key-value map passed as resolver parameters to the sub-solution.
Each value supports the full ValueRef surface (literal, expr, rslvr, tmpl).
Injected via provider.WithParameters() — consumed by `parameter` provider
resolvers in the sub-solution.
propagateErrors:
type: boolean
required: false
default: true
description: >
When true (default), sub-solution failures cause the provider to return
a Go error. When false, failures are reported only in the output envelope's
`status` and `errors` fields.
maxDepth:
type: integer
required: false
default: 10
description: >
Maximum nesting depth for recursive solution composition.
Prevents runaway recursion even without direct cycles.
resolvers:
type: array
required: false
items:
type: string
description: >
List of resolver names to execute from the child solution.
When omitted or empty, all resolvers in the child solution run.
When specified, only the listed resolvers are executed, which reduces
execution time when only a subset of the child's values is needed.
An error is returned if any listed name does not exist in the child.
actions:
type: array
required: false
maxItems: 100
items:
type: string
description: >
Action names or aliases to execute from the child workflow with their
transitive dependsOn dependencies and finally actions (action capability
only). Allows targeting explicit: true entry points in reusable child
workflows. When omitted or empty, all non-explicit actions run. When
non-empty and resolvers is omitted, child resolver execution is scoped to
resolvers referenced by the selected actions and finally section. Passing
actions outside action capability always returns a Go error.
timeout:
type: string
required: false
description: >
Maximum duration for sub-solution execution, as a Go duration string
(e.g. "30s", "5m", "1h"). When set, a context deadline is applied to
the child's resolver and workflow execution. If the timeout expires,
the child execution is cancelled and an error is returned (or reported
in the envelope if propagateErrors is false).
example: "30s"Dynamic source#
Making source a ValueRef enables composition patterns like:
infra-solution:
type: any
resolve:
with:
- provider: solution
inputs:
source:
expr: "'infra-' + _.region + '@1.0.0'"Since the existing InputResolver already handles ValueRef resolution for all input fields, this is free — no extra implementation work.
The ExtractDependencies function on the descriptor handles source as well, ensuring that if source contains _.someResolver, the DAG correctly orders it.
Output Shaping#
The provider returns the full output envelope. To extract or reshape specific values, use the resolver’s transform phase:
infra-config:
type: any
resolve:
with:
- provider: solution
inputs:
source: "infra-config@1.0.0"
transform:
with:
- provider: cel
inputs:
expression: "__self.resolvers"This keeps the provider focused on execution and delegates post-processing to the existing framework-level mechanism. The transform phase supports CEL, Go templates, and any other transform-capable provider.
Value Override Contract#
A recurring composition need (issue #616) is for a parent to override a value the child computes internally – for example, the parent enriches a map with extra fields and wants the child’s downstream rendering (actions, templates) to consume the enriched version.
The provider deliberately keeps the child opaque and isolated: the parent cannot reach in and overwrite an arbitrary child resolver value. Instead, the child opts in to an override using mechanisms the engine already provides. This preserves encapsulation – the child author decides which values are overridable and how the override is merged.
The contract#
The child author exposes an overridable value as three small resolvers:
- Override input – a
parameterresolver with adefault(typically{}), so it is empty when the parent passes nothing. Theexistsflag lives in provider metadata, not in the resolver value, so downstream expressions cannot read it; rely on the default instead. - Internal value – the child’s own computation.
- Effective value – the internal value merged with the override, using
map.merge(internal, override)(the second argument wins on key conflicts).
# child.yaml
spec:
resolvers:
labels_override: # 1. optional parent override (empty by default)
type: any
resolve:
with:
- provider: parameter
inputs:
key: labels_override
default: {}
labels_internal: # 2. the child's own computation
type: any
resolve:
with:
- provider: cel
inputs:
expression: "{'app': 'child', 'tier': 'backend'}"
labels: # 3. effective value the child renders from
type: any
dependsOn: [labels_internal, labels_override]
resolve:
with:
- provider: cel
inputs:
expression: "map.merge(_.labels_internal, _.labels_override)"The parent enriches the value and passes it into the child’s override input using the nested expr form (a bare string would be a literal, not a resolver reference):
# parent.yaml
spec:
resolvers:
enriched_labels:
type: any
resolve:
with:
- provider: cel
inputs:
expression: "{'team': 'platform', 'costCenter': 'CC-42'}"
child_data:
type: any
dependsOn: [enriched_labels]
resolve:
with:
- provider: solution
inputs:
source: "./child.yaml"
inputs:
labels_override:
expr: "_.enriched_labels"The child’s labels now contains both its internal keys (app, tier) and the parent’s overrides (team, costCenter). When the parent omits labels_override, map.merge(internal, {}) yields the internal value unchanged.
Conventions#
- Use a distinct override key (e.g.
labels_override), never the effective resolver’s own name (labels). Reusing the name triggers name-collision auto-wiring and can invent spurious dependency cycles. - Scalars have no
existsto test, so use a sentinel default and a CEL ternary, e.g.default: ""with_.x_override == "" ? _.x_internal : _.x_override. - Type/shape is the child’s responsibility. A shape mismatch (e.g. override is a scalar but the child expects a map) surfaces as a
map.mergeerror at child resolve time and propagates through the normalpropagateErrorspath.
A runnable example lives in examples/solutions/composition/
(child.yaml + parent.yaml).
Why not an engine-level override API#
An earlier proposal (issue #608, item 3) suggested letting the parent override arbitrary child resolver values directly from the solution provider input. This was rejected because it breaks the isolation invariant, has no clean answer for override precedence versus the child’s own resolve/transform phases, and multiplies type/shape and validation-visibility concerns – all with no safe default. The opt-in contract above delivers the same outcome while keeping the child in control.
Output Envelope#
from Capability#
{
"resolvers": {
"resolver-name": "<value>"
},
"status": "success | failed",
"errors": [
{"resolver": "name", "message": "description"}
]
}action Capability#
{
"resolvers": {
"resolver-name": "<value>"
},
"workflow": {
"finalStatus": "succeeded | failed | cancelled | partial-success",
"failedActions": [],
"skippedActions": []
},
"status": "success | failed",
"errors": [],
"success": true
}The workflow field provides only aggregate status — finalStatus, failedActions, and skippedActions. Individual sub-action results are not included, maintaining the opacity boundary. If a sub-solution author wants to expose specific results to the parent, they should do so through the sub-solution’s resolvers (visible via resolvers in the envelope).
If the parent truly needs sub-action details (escape hatch), a verbose: true input could include the full workflow.actions map. But the default is opaque.
Error Handling#
Default: Propagate Errors#
When propagateErrors is true (the default), the provider:
- Executes the sub-solution.
- If any resolver fails or the workflow has
finalStatus != "succeeded", returns a Go error with a descriptive message:solution "deploy-k8s@2.0.0": resolver "db-host" failed: connection refused - The parent’s own
onErrormechanism handles it (fallback to next source,continue, orfail).
This integrates naturally with the existing resolver fallback chain. A resolver using the solution provider with onError: continue can fall back to another source if the sub-solution fails.
Opt-in: Envelope-Only#
When propagateErrors: false, the provider always returns *Output{Data: envelope} — never a Go error (except for circular references and context cancellation). The provider adds a warning via Output.Warnings when status == "failed":
sub-solution "deploy-k8s@2.0.0" failed: 1 resolver error(s). Check _.status and _.errors fields.This ensures failures appear in logs even if the parent doesn’t inspect the envelope.
Always a Go Error#
Circular reference detection, max depth violations, exceeding actions maxItems (100), and supplying actions outside action capability (such as in from capability) always return a Go error regardless of propagateErrors, since these are caller configuration mistakes.
Circular Reference & Depth Detection#
Sub-solutions can themselves use the solution provider, enabling multi-level composition. Two mechanisms prevent runaway recursion:
Ancestor Stack#
A []string ancestor stack in context, using the existing With*/From* pattern:
// pkg/provider/builtin/solutionprovider/context.go
type ancestorStackKey struct{}
func WithAncestorStack(ctx context.Context, stack []string) context.Context
func AncestorStackFromContext(ctx context.Context) []string
func PushAncestor(ctx context.Context, name string) (context.Context, error)PushAncestor checks for duplicates and returns an error with the full chain if found.
Max Depth#
In addition to cycle detection, a hard depth limit (default 10, configurable via maxDepth input) catches non-cyclic but pathologically deep composition (A → B → C → D → … → Z).
The current depth is derived from len(AncestorStackFromContext(ctx)). If adding the new solution would exceed maxDepth, return an error.
Canonical Names#
| Source Type | Canonical Name |
|---|---|
| File path | Absolute path (e.g., /home/user/infra.yaml) |
| Catalog | name@version (e.g., deploy-to-k8s@2.0.0) |
| URL | Full URL (e.g., https://example.com/solution.yaml) |
Error example:
solution: circular reference detected: parent-solution → infra-config@1.0.0 → parent-solutionContext Isolation#
Each sub-solution runs in an isolated context. This is critical for correctness — the sub-solution must not see the parent’s resolver values or parameters.
Propagated (parent → sub-solution)#
| Value | Mechanism | Rationale |
|---|---|---|
| Logger | logger.WithLogger(ctx, scoped) | Scoped with sub-solution name prefix |
| Writer | writer.FromContext(ctx) (pass through) | Sub-solution output goes to same terminal |
| Dry-run | provider.DryRunFromContext(ctx) | Sub-solutions observe dry-run mode |
| Auth registry | auth.WithRegistry(ctx, reg) | Sub-solutions need the same auth |
| App config | config.WithConfig(ctx, cfg) | Sub-solutions read the same config |
| Redaction tracker | redact.FromContext(ctx) (shared) | Secrets resolved in child are tracked and redacted across parent output |
| Parent CEL cost limit | celexp.CostLimitFromContext(ctx) (capped) | Child CEL cost limit cannot raise an enclosing parent’s ceiling |
| Inherited executor config | action.InheritedExecutorConfigFromContext(ctx) | Child workflows inherit parent timeout, grace period, concurrency, IOStreams, Cwd, and prefixed progress callbacks |
| Output directory, conflict strategy, backup | provider.OutputDirectoryFromContext(ctx), ConflictStrategyFromContext(ctx), BackupFromContext(ctx) | Child action writes land in the parent’s --output-dir (with path-containment validation) and honor --on-conflict / --backup |
| Ancestor stack | Custom context key | For recursion detection |
Replaced / Cleared (parent context stripped, sub-solution gets fresh values)#
| Value | Mechanism | Rationale |
|---|---|---|
| Resolver context | Cleared via isolatedContext, then provider.WithResolverContext(ctx, map{}) | Sub-solution starts fresh; parent’s _ and *resolver.Context are not visible |
| Parameters | Cleared via isolatedContext, then provider.WithParameters(ctx, inputs) when inputs is non-nil | inputs map replaces parent’s -r params; parent CLI parameters never leak |
| Solution directory | Cleared via isolatedContext, then provider.WithSolutionDirectory(ctx, childSolutionDir) when known | Child reads resolve against the child’s own file directory or extracted bundle directory (unset for unbundled catalog/URL) |
| Working directory | Cleared via isolatedContext during child resolvers; restored via provider.WithWorkingDirectory(childActionCtx, parentWorkDir) for child actions | Prevents parent action WorkingDirectory from shadowing childSolutionDir during child resolver reads while keeping child action writes anchored to parent working/output directory |
| Iteration context | Cleared via isolatedContext | Sub-solution is not part of parent’s forEach |
| Persisted state | Cleared via isolatedContext | Sub-solution does not read parent’s state.Data snapshot |
| Template functions | Cleared via isolatedContext, then child’s own spec.functions bound by execute.Resolvers / execute.Actions | Parent’s author-defined Go template functions do not leak into child |
| Parent step metadata | Cleared via isolatedContext (ExecutionMode, PreResolvedInputs, SecretProperties, DeclaredScalarType) | Parent resolver/action step flags never affect child ValueRef evaluation or scalar type coercion |
| Solution metadata | Replaced by execute.Resolvers / execute.Actions (provider.WithSolutionMetadata) | Child providers observe the child solution’s own metadata and provenance |
| Action context | Not shared | Sub-solution builds its own action.Context |
Path Resolution & Bundle Extraction Contract#
provider.AbsFromContext checks WorkingDirectory before SolutionDirectory. When a parent workflow action invokes provider: solution, the parent’s WorkingDirectory is set on ctx, so inheriting it into child resolvers would shadow childSolutionDir. The solution provider splits directory scoping across two phases:
| Operation in child | Resolves against |
|---|---|
Resolver reads (file read, templates, relativeTo: solution, nested local source) | Child’s own directory (filepath.Dir(absPath) for local file sources, or the per-execution bundle temp directory for bundled catalog/OCI artifacts; falls back to CWD for unbundled catalog/URL sources) |
Workflow action reads (file read / exists) | With relativeTo: solution: child’s own directory or extracted bundle directory (validated against the child directory even when --output-dir points elsewhere). With relativeTo: cwd: parent’s working directory (validated against that working directory). With default relativeTo: auto: follows provider.ResolvePath (--output-dir when set, else parent’s working directory) so multi-step workflows can read prior action outputs |
Workflow action writes (file write, write-tree, delete, exec CWD, __cwd) | Parent’s --output-dir (with path-containment validation across all relativeTo modes) when set, otherwise the parent’s logical working directory (WorkingDirectoryFromContext -> InheritedExecutorConfig.Cwd -> os.Getwd()) – never inside the ephemeral bundle temp directory |
Nested composition (parent -> child -> grandchild) | Each level resolves its own source and resolver/relativeTo: solution reads against its own directory while propagating the root caller’s output/working directory to action writes |
When the configured Loader implements the optional BundleLoader interface (GetWithBundle(ctx, path)), non-empty bundle archives are extracted after the dry-run check into <binaryName>-bundle-* under os.TempDir() via bundler.ExtractBundleTarLimited (DefaultMaxBundleSize) and removed via defer when Execute returns (including on child failure or context cancellation). Dry-run invocations return before extraction so zero temp directories are created.
NOT Propagated#
| Value | Rationale |
|---|---|
Parent resolver.Context | Would leak parent resolver names into sub-solution’s _ namespace |
Parent __actions | Sub-solution’s actions are independent |
| Execution mode | Set independently based on whether from or action capability is active |
| Metrics | Sub-solution records its own metrics; aggregated at output |
Logger Scoping#
The logger passed to the sub-solution is scoped with the solution name:
subLogger := logger.FromContext(ctx).WithName("solution:" + canonicalName)
ctx = logger.WithLogger(ctx, subLogger)This produces log output like:
solution:deploy-k8s@2.0.0 Resolving 5 resolvers in 3 phases
solution:deploy-k8s@2.0.0 Phase 1: executing 2 resolvers concurrentlyExecution Model#
from Capability (Resolver Context)#
Execute(ctx, input) -> *Output
1. Classify and resolve `source` (relative local files resolve against parent `SolutionDirectory`)
2. Resolve `inputs` -> map[string]any params
3. Check ancestor stack + depth; push ancestor
4. Load solution (and raw bundle tar when `Loader` implements `BundleLoader.GetWithBundle`)
5. Normalize names, merge `bundle.plugins` defaults, and auto-resolve child official providers
6. Short-circuit if `provider.DryRunFromContext(ctx)` (returns dry-run envelope without extracting bundle)
7. Extract non-empty bundle tar to `<binaryName>-bundle-*` temp dir (`defer` cleanup)
8. Compute `childSolutionDir` and capture `parentWorkDir`; build isolated context:
- Mask parent parameters, iteration context, state snapshot, template functions, step metadata, and parent working/solution directories
- Fresh resolver context (empty)
- Attach `childSolutionDir` (when non-empty) and `inputs` parameters
- Scoped logger
9. Filter resolvers when `resolvers` allowlist is specified
10. Execute child resolvers via `execute.Resolvers(...)` (injects child SolutionMetadata, compiles child `spec.functions`, applies parent-capped CEL cost limit)
11. Build `from` envelope (preserving partial resolved values on failure when `propagateErrors: false`)
12. If sub-solution failed AND `propagateErrors` -> return Go error
13. Return &Output{Data: envelope, Warnings: warnings}action Capability (Workflow Context)#
Same as above through step 5, then:
6. Validate `timeout` duration (when set), and when `actions` is non-empty validate that the child defines `spec.workflow` and resolve target action names/aliases + transitive `dependsOn` closure (`action.FilterWorkflowActions(workflow, actions)`) ahead of dry-run and bundle extraction
7. Short-circuit if `provider.DryRunFromContext(ctx)` (returns dry-run action envelope without extracting bundle)
8. Extract non-empty bundle tar to `<binaryName>-bundle-*` temp dir (`defer` cleanup), compute `childSolutionDir` / `parentWorkDir`, and build isolated context
9. Select child resolvers:
- If `resolvers` is explicitly provided (including `resolvers: []` to run all child resolvers) -> `filterResolvers`
- Else if `actions` is non-empty -> `execute.ResolversForWorkflow` over the filtered child workflow
- Else -> all child resolvers (`sol.Spec.ResolversToSlice()`)
10. Execute selected child resolvers via `execute.Resolvers(...)`
11. If child defines no `spec.workflow` (and `actions` is empty), emit `BuildActionEnvelope` with `success: true`
12. Restore `provider.WithWorkingDirectory(childActionCtx, parentWorkDir)` alongside inherited `OutputDirectory`, `ConflictStrategy`, and `Backup`; inherit parent `action.Executor` settings (`InheritedExecutorConfig`: default timeout, grace period, max concurrency, IOStreams, Cwd) and wrap parent `ProgressCallback` with `[solution:<canonicalName>] ` prefix
13. Execute child workflow via `execute.Actions(...)` with `TargetActions: in.Actions`:
- Validate workflow (`action.ValidateWorkflow`)
- Filter actions (`action.FilterWorkflowActions(workflow, actions)` -- narrowing to requested targets + transitive `dependsOn` closure + `finally`, or excluding standalone `explicit: true` actions when `actions` is empty)
- Inject child `SolutionMetadata`, `__execution` metadata, `spec.functions`, and parent-capped CEL cost limit
14. Build `action` envelope with resolver values + workflow summary (recording `PartialResult` or `_workflow` error when `propagateErrors: false`)
15. If sub-solution failed AND `propagateErrors` -> return Go error
16. Return &Output{Data: envelope, Warnings: warnings}Progress Reporting#
The action executor exposes its runtime settings via action.InheritedExecutorConfig on context and supports WithProgressCallback for reporting execution progress. When the solution provider runs in action capability mode, it wraps the parent’s ProgressCallback with action.NewSolutionProgressCallback, serializing concurrent events through a mutex and prefixing child action names with [solution:<canonicalName>] to distinguish them from parent-level progress:
==> [solution:deploy-k8s@2.0.0] provision-cluster: Provision target cluster
done: [solution:deploy-k8s@2.0.0] provision-cluster (120ms)This ensures the parent does not block silently during long-running sub-solution workflows.
Timeout#
The provider accepts an optional timeout input as a Go duration string (e.g. "30s", "5m"). When specified, a context.WithTimeout deadline is applied to the child solution’s resolver and workflow execution. If the timeout expires, child execution is cancelled and the error is either returned (default) or reported in the envelope (when propagateErrors: false).
The parent resolver/action Timeout field also applies to the entire provider execution via context deadline propagation, so the provider-level timeout acts as an inner bound within the outer deadline.
Resolver Filtering#
The provider accepts an optional resolvers input – a list of resolver names to execute from the child solution. When omitted (with actions empty) or explicitly set to [], all resolvers in the child solution run (default behavior; when actions is non-empty and resolvers is omitted, resolvers are scoped automatically to those referenced by the selected actions and finally section). When non-empty, only the listed resolvers are executed, which reduces execution time when only a subset of the child’s values is needed.
An error is returned if any listed name does not exist in the child solution. This catches typos early rather than silently returning partial results.
child-config:
type: any
resolve:
with:
- provider: solution
inputs:
source: "infra-config@1.0.0"
resolvers:
- database-url
- cache-ttlAction Target Filtering#
In action capability mode, the provider accepts an optional actions input (up to MaxActionTargets = 100 action names or aliases) mirroring scafctl run solution --action and scafctl run action:
- Target closure: Each entry resolves by action name or
aliasinspec.workflow.actions(includingexplicit: trueentry points) and pulls in its transitivedependsOndependencies.spec.workflow.finallyactions always run. - Resolver scoping: When
actionsis non-empty andresolversis omitted, child resolver execution is scoped viaexecute.ResolversForWorkflowto only the resolvers referenced by the filtered child workflow (plus their transitive dependencies), preventing unrelated child entry points with unset parameters or credentials from failing. Supplyingresolversexplicitly (includingresolvers: []to execute all child resolvers) overrides automatic scoping. - Error routing: Targeting an unknown action or targeting actions on a child solution without
spec.workflowfails before child resolvers execute (and during provider dry-run whenprovider.DryRunFromContextis set), returning a Go error by default or recording a_workflowentry inerrorswhenpropagateErrors: false. - Capability guard: Supplying
actions(evenactions: []) outsideactioncapability returns a Go error immediately regardless ofpropagateErrors. - WhatIf: When
actionsis non-empty,WhatIfincludes the target list:Would execute solution "deploy-app@2.0.0" (actions: deploy).
workflow:
actions:
deploy:
provider: solution
inputs:
source: "deploy-app@2.0.0"
actions:
- deploy
inputs:
environment: prodDry Run (WhatIf)#
In dry-run mode, the solution provider’s WhatIf function generates a description of what execution would do (e.g., Would execute solution "infra-config@1.0.0"). The provider is not invoked during dry-run — only its WhatIf description is included in the report.
The WhatIf function extracts source (and actions when non-empty) from the inputs to provide a context-specific message. When source information is unavailable, it falls back to a generic description.
Example WhatIf output in the dry-run report:
// action capability (in actionPlan):
{
"name": "run-child",
"provider": "solution",
"wouldDo": "Would execute solution \"infra-config@1.0.0\"",
"phase": 1,
"section": "actions"
}Usage Examples#
Resolver: Import Values from a Catalog Solution#
spec:
resolvers:
environment:
type: string
resolve:
with:
- provider: static
inputs:
value: "production"
infra-config:
type: any
resolve:
with:
- provider: solution
inputs:
source: "infra-config@1.0.0"
inputs:
environment:
expr: "_.environment"
transform:
with:
- provider: cel
inputs:
expression: "__self.resolvers"Result: _.infra-config = {"db_host": "db.prod.internal", "db_port": 5432}
Resolver: Extract a Specific Value with CEL#
db-connection:
type: string
resolve:
with:
- provider: solution
inputs:
source: "infra-config@1.0.0"
inputs:
environment:
expr: "_.environment"
transform:
with:
- provider: cel
inputs:
expression: "__self.resolvers.db_host + ':' + string(__self.resolvers.db_port)"Result: _.db-connection = "db.prod.internal:5432"
Resolver: Dynamic Source#
infra:
type: any
resolve:
with:
- provider: solution
inputs:
source:
expr: "'infra-' + _.region + '@1.0.0'"
transform:
with:
- provider: cel
inputs:
expression: "__self.resolvers"Resolver: Local File Reference#
local-config:
type: any
resolve:
with:
- provider: solution
inputs:
source: "./shared/common-config.yaml"
transform:
with:
- provider: cel
inputs:
expression: "__self.resolvers"Workflow: Compose Deployment Steps#
spec:
resolvers:
region:
type: string
resolve:
with:
- provider: static
inputs:
value: "us-east-1"
workflow:
actions:
setup:
provider: exec
inputs:
command: "echo 'Preparing...'"
deploy-infra:
provider: solution
dependsOn:
- setup
inputs:
source: "deploy-k8s@2.0.0"
inputs:
region:
expr: "_.region"
cluster: "main-cluster"
verify:
provider: exec
dependsOn:
- deploy-infra
inputs:
command:
expr: "'Deploy status: ' + string(__actions['deploy-infra'].results.workflow.finalStatus)"Error Handling in Parent (envelope mode)#
infra:
type: any
resolve:
with:
- provider: solution
inputs:
source: "infra-config@1.0.0"
propagateErrors: false
app-config:
type: any
dependsOn:
- infra
when:
expr: "_.infra.status == 'success'"
resolve:
with:
- provider: static
inputs:
value:
expr: "_.infra.resolvers.db_host"Error Handling in Parent (fallback chain)#
infra:
type: any
resolve:
with:
- provider: solution
inputs:
source: "infra-config@1.0.0"
onError: continue
- provider: static
inputs:
value:
db_host: "localhost"
db_port: 5432Implementation#
Key Files#
| File | Purpose |
|---|---|
pkg/provider/builtin/solutionprovider/solution.go | Provider struct, Descriptor(), Execute() |
pkg/provider/builtin/solutionprovider/solution_test.go | Unit tests with mock loader |
pkg/provider/builtin/solutionprovider/context.go | Ancestor stack + depth context helpers |
pkg/provider/builtin/solutionprovider/envelope.go | Envelope construction for from and action |
pkg/cmd/scafctl/run/solution.go | Registration wiring |
tests/integration/cli_test.go | Integration tests |
Provider Structure#
// pkg/provider/builtin/solutionprovider/solution.go
type Loader interface {
Get(ctx context.Context, path string) (*solution.Solution, error)
}
type BundleLoader interface {
Loader
GetWithBundle(ctx context.Context, path string) (*solution.Solution, []byte, error)
}
type SolutionProvider struct {
loader Loader
registry *provider.Registry
// ... plugin/official-provider settings for child solutions
}
type Option func(*SolutionProvider)
func WithLoader(l Loader) Option
func WithRegistry(r *provider.Registry) Option
func New(opts ...Option) *SolutionProviderThe provider depends only on the local Loader interface (and optional
BundleLoader extension). In production, prepare adapts its load.Loader
(the same router used for the parent solution) with subSolutionLoader, which
implements BundleLoader (Get + GetWithBundle), classifies the path,
rejects stdin, and returns both the loaded solution and any raw bundle tar
archive. Tests supply a mock Loader or BundleLoader.
The provider also receives a reference to the provider registry so sub-solutions have access to all built-in and plugin providers.
Registration#
The solution provider is registered in builtin.go without a loader. The loader depends on the parent’s load.Loader (which needs catalog config and the CLI/MCP/API source policy), so it is injected per execution rather than at registration time.
prepare.SolutionFromLoader builds a ProviderCtx function that injects the loader into each provider execution context:
// In pkg/solution/prepare/prepare.go (simplified):
ctx = solutionprovider.WithLoaderCtx(ctx, subSolutionLoader{loader: loader})Execute reads it with solutionprovider.LoaderFromContext(ctx). Embedders can
alternatively call Configure(WithLoader(...)) on the registered provider.
Custom Dependency Extraction#
The provider implements ExtractDependencies on its descriptor to scan source and nested inputs for resolver references:
desc.ExtractDependencies = func(inputs map[string]any) []string {
var deps []string
if source, ok := inputs["source"]; ok {
deps = append(deps, extractRefsFromValue(source)...)
}
if subInputs, ok := inputs["inputs"].(map[string]any); ok {
for _, v := range subInputs {
deps = append(deps, extractRefsFromValue(v)...)
}
}
return deps
}Schema Definition#
Input schema:
type: object
required: [source]
properties:
source:
description: "Sub-solution location (file path, catalog reference, or URL)"
inputs:
type: object
description: "Parameters passed to the sub-solution's parameter provider"
additionalProperties: true
propagateErrors:
type: boolean
default: true
description: "Whether sub-solution failures cause a Go error"
maxDepth:
type: integer
default: 10
minimum: 1
maximum: 100
description: "Maximum nesting depth for recursive composition"
resolvers:
type: array
items:
type: string
description: "Resolver names to execute; when empty all resolvers run"
actions:
type: array
maxItems: 100
items:
type: string
description: "Action names or aliases to execute from the child workflow with transitive dependsOn and finally actions (action capability only)"
timeout:
type: string
description: "Maximum duration for sub-solution execution (e.g. 30s, 5m)"
example: "30s"Output schemas per capability:
from:
type: object
properties:
resolvers:
type: object
status:
type: string
errors:
type: array
action:
type: object
required: [success]
properties:
success:
type: boolean
resolvers:
type: object
workflow:
type: object
status:
type: string
errors:
type: arrayNote: action capability requires a success boolean field in the output schema (enforced by ValidateDescriptor). The provider sets this to status == "success".
Test Strategy#
Unit Tests (solution_test.go)#
- Basic
from— success: Mock loader returns solution with 2 resolvers. Assert envelope has correctresolversmap andstatus: success. - Basic
action— success: Mock loader returns solution with resolvers + workflow. Assert envelope includesworkflow.finalStatusandsuccess: true. propagateErrors: true(default): Mock loader returns solution whose resolvers fail. AssertExecutereturns a Go error.propagateErrors: false: Same failing solution, but nowExecutereturns*Outputwithstatus: failedandOutput.Warningspopulated.- Circular detection — direct: A → A. Assert error message includes chain.
- Circular detection — indirect: A → B → A. Push “A” onto ancestor stack in context, then execute with source “A”. Assert error.
- Max depth exceeded: Push 10 ancestors onto stack, execute with
maxDepth: 10. Assert depth error. - WhatIf: Call
DescribeWhatIf(ctx, input)with source set. Assert message contains the source name. Also test fallback when source is missing. - Context isolation: Assert sub-solution does not see parent’s resolver values or parameters.
- Dynamic source:
sourcewith CEL expression resolving to a catalog name. Assert correct solution is loaded.
Integration Tests (cli_test.go)#
- End-to-end resolver composition: Parent solution with a resolver using
provider: solutionpointing to a child solution file. Assert parent resolver gets child’s resolver values. - End-to-end workflow composition: Parent workflow invokes child solution as an action. Assert
__actionscontains envelope with workflow status. - Circular reference: Two solution files referencing each other. Assert clear error message.
- Parameter passthrough: Parent passes
inputsto child. Child’sparameterresolver receives the value. Assert child resolver resolves correctly. - Transform phase integration: Parent uses transform to extract specific values from the solution provider envelope.