{"modulePath":"github.com/GoCodeAlone/workflow","version":"v0.87.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package interfaces\n\nPackage interfaces defines shared interface types used across the workflow engine, handlers, and module packages. Placing these interfaces here breaks the direct handler→module concrete-type dependency and enables each package to be tested in isolation with mocks.\n\n## Constants\n\n```go\nconst (\n\tKeyName             = \"name\"\n\tKeyRegion           = \"region\"\n\tKeyImage            = \"image\"\n\tKeyHTTPPort         = \"http_port\"\n\tKeyInternalPorts    = \"internal_ports\"\n\tKeyProtocol         = \"protocol\"\n\tKeyInstanceCount    = \"instance_count\"\n\tKeySize             = \"size\"\n\tKeyEnvVars          = \"env_vars\"\n\tKeyEnvVarsSecret    = \"env_vars_secret\" //nolint:gosec // G101 false positive: this is a config key name, not a credential\n\tKeyVPCRef           = \"vpc_ref\"\n\tKeyAutoscaling      = \"autoscaling\"\n\tKeyRoutes           = \"routes\"\n\tKeyCORS             = \"cors\"\n\tKeyDomains          = \"domains\"\n\tKeyHealthCheck      = \"health_check\"\n\tKeyLivenessCheck    = \"liveness_check\"\n\tKeyIngress          = \"ingress\"\n\tKeyEgress           = \"egress\"\n\tKeyAlerts           = \"alerts\"\n\tKeyLogDestinations  = \"log_destinations\"\n\tKeyTermination      = \"termination\"\n\tKeyMaintenance      = \"maintenance\"\n\tKeyJobs             = \"jobs\"\n\tKeyWorkers          = \"workers\"\n\tKeyStaticSites      = \"static_sites\"\n\tKeySidecars         = \"sidecars\"\n\tKeyBuildCommand     = \"build_command\"\n\tKeyRunCommand       = \"run_command\"\n\tKeyDockerfilePath   = \"dockerfile_path\"\n\tKeySourceDir        = \"source_dir\"\n\tKeyProviderSpecific = \"provider_specific\"\n)\n```\nCanonical IaC config key constants. These are the standard field names used across all IaC providers to describe application resource configuration.\n\n```go\nconst (\n\tJobKindPreDeploy    = \"PRE_DEPLOY\"\n\tJobKindPostDeploy   = \"POST_DEPLOY\"\n\tJobKindFailedDeploy = \"FAILED_DEPLOY\"\n\tJobKindScheduled    = \"SCHEDULED\"\n\tJobKindEphemeral    = \"EPHEMERAL\"\n)\n```\n\n```go\nconst (\n\tMigrationRepairConfirmation = \"FORCE_MIGRATION_METADATA\"\n\n\tMigrationRepairStatusSucceeded        = \"succeeded\"\n\tMigrationRepairStatusFailed           = \"failed\"\n\tMigrationRepairStatusApprovalRequired = \"approval_required\"\n\tMigrationRepairStatusUnsupported      = \"unsupported\"\n)\n```\n\n```go\nconst MaxProviderJobTimeoutSeconds = 3600\n```\nMaxProviderJobTimeoutSeconds bounds one-off provider job execution to one hour.\n\n## Variables\n\n```go\nvar (\n\tErrResourceNotFound      = errors.New(\"iac: resource not found\")      // 404/410\n\tErrResourceAlreadyExists = errors.New(\"iac: resource already exists\") // 409 Conflict\n\tErrRateLimited           = errors.New(\"iac: rate limited\")            // 429\n\tErrTransient             = errors.New(\"iac: transient error\")         // 502/503/504\n\tErrUnauthorized          = errors.New(\"iac: unauthorized\")            // 401\n\tErrForbidden             = errors.New(\"iac: forbidden\")               // 403\n\tErrValidation            = errors.New(\"iac: validation error\")        // 400/422\n\t// ErrImageNotInRegistry indicates that an image tag or digest referenced\n\t// by a desired ResourceSpec is not present in the registry. Drivers\n\t// SHOULD return this (wrapped) from Diff, Create, and Update when an\n\t// image-presence pre-flight fails. Callers can use errors.Is for typed\n\t// identification, but gRPC-bound callers should ALSO match the message\n\t// string \"iac: image tag or digest not found in registry\" for\n\t// cross-process robustness — structpb does not preserve sentinel\n\t// identity across the gRPC plugin boundary. The message string is\n\t// load-bearing; do not change it.\n\tErrImageNotInRegistry = errors.New(\"iac: image tag or digest not found in registry\")\n\t// ErrProviderMethodUnimplemented indicates that a remote IaC provider\n\t// plugin does not implement the optional method that was just dispatched.\n\t// Used by the wfctl gRPC proxy *remoteIaCProvider to translate\n\t// gRPC codes.Unimplemented (and equivalent string-matched plugin errors)\n\t// into a stable sentinel that dispatch sites can errors.Is on.\n\t//\n\t// Why this exists\n\t// ───────────────\n\t// v0.27.0 added optional sub-interfaces (EnumeratorAll, Enumerator, etc.)\n\t// to interfaces.IaCProvider. Dispatch sites (infra_audit_keys.go,\n\t// infra_cleanup.go, infra_prune.go) iterate providers and use a\n\t// type-assertion `p.(interfaces.X)` as the \"does this provider support X?\"\n\t// gate. v0.27.1 bridged these methods on remoteIaCProvider so audit-keys\n\t// could reach plugins that DO implement them, but as a side effect every\n\t// gRPC-loaded provider now satisfies the optional interface — even ones\n\t// whose plugin process does not implement the underlying method.\n\t//\n\t// To preserve the iterate-and-skip semantics, dispatch sites now call the\n\t// method and check for ErrProviderMethodUnimplemented via errors.Is. A\n\t// match is treated identically to the pre-v0.27.1 negative type-assert:\n\t// log \"skipped \u003cprovider\u003e: does not implement \u003cInterface\u003e\" and continue\n\t// iterating to the next provider.\n\t//\n\t// Plugins SHOULD return status.Error(codes.Unimplemented, \"...\") from\n\t// their InvokeMethod / InvokeMethodContext dispatcher when an optional\n\t// method is not supported. The proxy translates this to\n\t// ErrProviderMethodUnimplemented for callers.\n\tErrProviderMethodUnimplemented = errors.New(\"iac: provider method unimplemented\")\n)\n```\nSentinel errors for common IaC resource operation response categories. Use errors.Is to identify them after wrapping.\n\n```go\nvar SizingMap = map[Size]SizingDefaults{\n\tSizeXS: {CPU: \"0.25\", Memory: \"512Mi\", DBStorage: \"10Gi\", CacheMemory: \"256Mi\"},\n\tSizeS:  {CPU: \"1\", Memory: \"2Gi\", DBStorage: \"50Gi\", CacheMemory: \"1Gi\"},\n\tSizeM:  {CPU: \"2\", Memory: \"4Gi\", DBStorage: \"100Gi\", CacheMemory: \"4Gi\"},\n\tSizeL:  {CPU: \"4\", Memory: \"16Gi\", DBStorage: \"500Gi\", CacheMemory: \"16Gi\"},\n\tSizeXL: {CPU: \"8\", Memory: \"32Gi\", DBStorage: \"1Ti\", CacheMemory: \"64Gi\"},\n}\n```\nSizingMap defines the default resource allocations per size tier.\n\n## Functions\n\n```go\nfunc CanonicalKeys() []string\n```\nCanonicalKeys returns the full list of canonical IaC config key strings.\n\n```go\nfunc IaCCanonicalSchemaJSON() []byte\n```\nIaCCanonicalSchemaJSON returns the raw JSON Schema bytes.\n\n```go\nfunc IsCanonicalKey(key string) bool\n```\nIsCanonicalKey returns true if key is a recognized canonical IaC config key.\n\n```go\nfunc IsErrResourceNotFound(err error) bool\n```\nIsErrResourceNotFound reports whether err is or wraps ErrResourceNotFound, including the case where the sentinel was stringified across a gRPC plugin boundary (where errors.Is fails because structpb does not preserve sentinel identity). Matches the ErrImageNotInRegistry precedent above. The message string of ErrResourceNotFound is load-bearing for this match; do not change it without updating TestErrResourceNotFound\\_MessageStringStable.\n\nFor non-gRPC callers (e.g., SQL-backed tenant lookups in module/), errors.Is fires and strings.Contains is never reached.\n\n```go\nfunc IsValidHookEvent(s string) bool\n```\nIsValidHookEvent returns true if s matches a known HookEvent constant.\n\n```go\nfunc IsValidationError(err error) bool\n```\nIsValidationError reports whether err (or any error in its chain) is a \\*ValidationError.\n\n```go\nfunc ValidateProviderID(s string, format ProviderIDFormat) bool\n```\nValidateProviderID returns true when s is a valid provider ID for the given format. Unknown and unrecognized formats always return true (forward compat). Freeform requires a non-empty string. Specific formats delegate to their dedicated validators.\n\n```go\nfunc ValidateUpdatePriorState(ref ResourceRef, spec ResourceSpec, prior *ResourceState) error\n```\nValidateUpdatePriorState binds an update to the same resource incarnation. Diagnostics intentionally omit config, outputs, and provider identifiers.\n\n```go\nfunc ValidationErrorStatus(err error) int\n```\nValidationErrorStatus returns the HTTP status code from a ValidationError in the error chain. Returns 400 if the error has no status or is not a ValidationError.\n\n## Types\n\n```go\ntype ActionError struct {\n\tResource string `json:\"resource\"`\n\tAction   string `json:\"action\"`\n\tError    string `json:\"error\"`\n}\n```\nActionError captures a resource-level error during apply or destroy.\n\n```go\ntype ActionOutcome struct {\n\tActionIndex uint32       `json:\"action_index\"`\n\tStatus      ActionStatus `json:\"status\"`\n\tError       string       `json:\"error,omitempty\"`\n}\n```\nActionOutcome is the wfctl-side per-action surfacing for v2 hook dispatch. Engine populates one entry per PlanAction in ApplyResult.Actions; wfctl dispatches v2 hooks (Created / Deleted) by matching ActionIndex back to the planned action slice. Per workflow#699 the proto-side pb.ActionResult mirror was deleted — ActionOutcome is now the sole representation of per-action outcome.\n\n```go\ntype ActionStatus uint8\n```\nActionStatus categorizes per-action outcomes for wfctl-side hook dispatch. Mirrors pb.ActionStatus (plugin/external/proto/iac.proto) for type-safe Go boundary use; constant tags 0-6 MUST stay in lockstep with the proto. Per workflow#640 Phase 2 + workflow#698 Phase 2.3 + ADR 0040 invariants 1-2.\n\nPhase 2.3 reclassification: the engine now distinguishes pre-dispatch (Skipped), dispatch (Error/DeleteFailed), and post-hook (CompensationFailed) failures. Consumers that previously checked ActionStatusError alone for \"action did not produce desired end-state\" should now check {Error, DeleteFailed, CompensationFailed, Skipped}.\n\n```go\nconst (\n\t// ActionStatusUnspecified is the zero-value. Engine-side population\n\t// in wfctlhelpers.ApplyPlanWithHooks must replace this before\n\t// returning; wfctl rejects ActionOutcome entries left at\n\t// Unspecified per ADR 0040 invariant 2. Per workflow#699 the\n\t// proto-side decode path (formerly applyResultFromPB) is gone —\n\t// the only producer is now the engine's per-action populate.\n\tActionStatusUnspecified ActionStatus = iota\n\tActionStatusSuccess\n\tActionStatusError\n\tActionStatusDeleteFailed\n\t// Phase 2.3 (workflow#698):\n\tActionStatusCompensated        // reserved-for-future-emission; engine v0.56.0 does NOT emit (no auto-compensation); plugins may emit if they implement own compensation\n\tActionStatusCompensationFailed // post-driver-success hook failed; cloud-side work IS done; operator must verify state; manual compensation may be required\n\tActionStatusSkipped            // action never attempted at driver (ctx-cancel pre-dispatch, JIT-substitution-fail, driver-resolve-fail); cloud-side state unchanged\n)\n```\n\n```go\ntype AlertSpec struct {\n\tRule     string  `json:\"rule\" yaml:\"rule\"`\n\tOperator string  `json:\"operator\" yaml:\"operator\"` // GREATER_THAN | LESS_THAN\n\tValue    float64 `json:\"value\" yaml:\"value\"`\n\tWindow   string  `json:\"window\" yaml:\"window\"` // e.g. \"10m\"\n\tDisabled bool    `json:\"disabled\" yaml:\"disabled\"`\n}\n```\nAlertSpec defines an observable metric threshold alert.\n\n```go\ntype ApplyResult struct {\n\tPlanID    string           `json:\"plan_id\"`\n\tResources []ResourceOutput `json:\"resources\"`\n\tErrors    []ActionError    `json:\"errors,omitempty\"`\n\n\t// InitialInputSnapshot captures env-var fingerprints at the start of apply.\n\t// Populated by wfctlhelpers.ApplyPlan (T3.1) at apply entry by snapshotting\n\t// every name listed in plan.InputSnapshot through inputsnapshot.OSEnvProvider.\n\t// Used by the deferred postcondition (T3.1.5) to compute the drift report\n\t// against the apply-time snapshot.\n\tInitialInputSnapshot map[string]string `json:\"initial_input_snapshot,omitempty\"`\n\n\t// InputDriftReport names env-vars whose fingerprint changed between plan\n\t// and apply. Populated by the deferred postcondition in\n\t// wfctlhelpers.ApplyPlan (T3.1.5) regardless of whether the apply\n\t// itself succeeded or errored. Empty (or nil) means no drift detected.\n\t// Entries are sorted by Name for deterministic comparison and stable\n\t// diagnostic output; the sort guarantee is enforced by\n\t// inputsnapshot.ComputeDrift (covered by\n\t// TestComputeDrift_ResultIsSortedByName in\n\t// iac/inputsnapshot/compute_drift_test.go).\n\tInputDriftReport []DriftEntry `json:\"input_drift_report,omitempty\"`\n\n\t// ReplaceIDMap propagates new ProviderIDs from Replace actions to\n\t// dependent resources whose Apply runs later in the same plan.\n\t// Populated by doReplace (T3.4); consumed by JIT substitution in W-5\n\t// (T5.2/T5.3).\n\t//\n\t// Keyed by the *replaced* resource's Name (i.e., action.Resource.Name\n\t// from the Replace PlanAction — the resource whose Delete-then-Create\n\t// just produced a fresh ProviderID). The value is the new ProviderID\n\t// returned from the post-Delete Create. Dependent resources reference\n\t// the replaced resource by name in their config, so JIT substitution\n\t// in W-5 translates \"name → new ProviderID\" via this map.\n\tReplaceIDMap map[string]string `json:\"replace_id_map,omitempty\"`\n\n\t// Actions surfaces per-PlanAction outcomes for v2 hook dispatch in\n\t// wfctl. Always populated (one entry per IaCPlan.Actions index) when\n\t// an IaC plugin declares ComputePlanVersion=\"v2\" in\n\t// CapabilitiesResponse. Per ADR 0024 + ADR 0040, plugins NOT\n\t// declaring v2 are permanently incompatible with workflow v0.54.0+;\n\t// there is no compat shim. Per workflow#640 Phase 2 + ADR 0040\n\t// invariants 1-2.\n\tActions []ActionOutcome `json:\"actions,omitempty\"`\n}\n```\nApplyResult summarises the outcome of applying a plan.\n\n```go\ntype ArtifactEntry struct {\n\tPath string `json:\"path\"`\n\tURL  string `json:\"url\"`\n}\n```\nArtifactEntry is a single published artifact with its URL.\n\n```go\ntype AutoscalingSpec struct {\n\tMin           int `json:\"min\" yaml:\"min\"`\n\tMax           int `json:\"max\" yaml:\"max\"`\n\tCPUPercent    int `json:\"cpu_percent\" yaml:\"cpu_percent\"`\n\tMemoryPercent int `json:\"memory_percent\" yaml:\"memory_percent\"`\n}\n```\nAutoscalingSpec controls horizontal-pod / instance autoscaling.\n\n```go\ntype BootstrapResult struct {\n\t// Bucket is the name of the created or confirmed state bucket/container.\n\tBucket string `json:\"bucket,omitempty\"`\n\t// Region is the region where the bucket resides.\n\tRegion string `json:\"region,omitempty\"`\n\t// Endpoint is the S3-compatible API endpoint URL (if applicable).\n\tEndpoint string `json:\"endpoint,omitempty\"`\n\t// EnvVars is a map of environment variable names to values that should be\n\t// exported for CI capture (e.g. WFCTL_STATE_BUCKET, SPACES_BUCKET).\n\tEnvVars map[string]string `json:\"env_vars,omitempty\"`\n}\n```\nBootstrapResult contains metadata returned by a successful BootstrapStateBackend call.\n\n```go\ntype CORSSpec struct {\n\tAllowOrigins     []string `json:\"allow_origins,omitempty\" yaml:\"allow_origins,omitempty\"`\n\tAllowMethods     []string `json:\"allow_methods,omitempty\" yaml:\"allow_methods,omitempty\"`\n\tAllowHeaders     []string `json:\"allow_headers,omitempty\" yaml:\"allow_headers,omitempty\"`\n\tExposeHeaders    []string `json:\"expose_headers,omitempty\" yaml:\"expose_headers,omitempty\"`\n\tAllowCredentials bool     `json:\"allow_credentials\" yaml:\"allow_credentials\"`\n\tMaxAge           string   `json:\"max_age,omitempty\" yaml:\"max_age,omitempty\"`\n}\n```\nCORSSpec configures Cross-Origin Resource Sharing headers.\n\n```go\ntype DestroyResult struct {\n\tDestroyed []string      `json:\"destroyed\"`\n\tErrors    []ActionError `json:\"errors,omitempty\"`\n}\n```\nDestroyResult summarises the outcome of a destroy operation.\n\n```go\ntype Diagnostic struct {\n\tID     string    `json:\"id\"`               // provider-side identifier (e.g. deployment ID)\n\tPhase  string    `json:\"phase\"`            // terminal or current phase\n\tCause  string    `json:\"cause\"`            // human-readable root cause or error summary\n\tAt     time.Time `json:\"at\"`               // when the event was created or last updated\n\tDetail string    `json:\"detail,omitempty\"` // optional verbose tail (log excerpt, stack)\n}\n```\nDiagnostic is a single troubleshooting finding returned by a Troubleshooter. It describes a recent provider-side event (deployment, job run, etc.) with enough context to understand why a health check failed without visiting the provider's console.\n\n```go\ntype DiffResult struct {\n\tNeedsUpdate  bool          `json:\"needs_update\"`\n\tNeedsReplace bool          `json:\"needs_replace\"`\n\tChanges      []FieldChange `json:\"changes\"`\n}\n```\nDiffResult summarises the differences between desired and actual resource state.\n\n```go\ntype DomainSpec struct {\n\tName     string `json:\"name\" yaml:\"name\"`\n\tZone     string `json:\"zone,omitempty\" yaml:\"zone,omitempty\"`\n\tType     string `json:\"type\" yaml:\"type\"` // PRIMARY | ALIAS\n\tWildcard bool   `json:\"wildcard\" yaml:\"wildcard\"`\n}\n```\nDomainSpec describes a custom domain attached to a service.\n\n```go\ntype DriftClass string\n```\nDriftClass classifies the type of drift detected between IaC state and actual cloud state. Used by wfctl infra drift output and wfctl infra apply --refresh recovery semantics.\n\n```go\nconst (\n\t// DriftClassUnknown is the zero value; preserved for backwards compat\n\t// with consumers serialized before the Class field existed.\n\tDriftClassUnknown DriftClass = \"\"\n\t// DriftClassInSync — state and cloud agree.\n\tDriftClassInSync DriftClass = \"in-sync\"\n\t// DriftClassGhost — state has the resource; cloud Read returned\n\t// ErrResourceNotFound. Caller can prune via wfctl infra apply --refresh.\n\tDriftClassGhost DriftClass = \"ghost\"\n\t// DriftClassConfig — state and cloud both have the resource but configs\n\t// differ. Caller reconciles via wfctl infra apply (normal plan path).\n\tDriftClassConfig DriftClass = \"config\"\n)\n```\n\n```go\ntype DriftConfigDetector interface {\n\tDetectDriftWithSpecs(ctx context.Context, resources []ResourceRef, specs map[string]ResourceSpec) ([]DriftResult, error)\n}\n```\nDriftConfigDetector is an OPTIONAL interface a provider MAY implement to surface config-drift in addition to the existence-only Ghost / InSync / Unknown classifications produced by DetectDrift.\n\nspecs is the per-ref applied-config map sourced from state. Callers build it from ResourceState.AppliedConfig (wrapped into ResourceSpec); missing or empty entries instruct the provider to fall back to existence-only behavior for that ref. The map key is ref.Name (matches ResourceState.Name).\n\nCallers MUST type-assert against this interface and fall back to IaCProvider.DetectDrift(refs) on the negative case. Providers that do not implement DriftConfigDetector continue to work unchanged.\n\nProviders SHOULD only return DriftClassConfig when they have high confidence the applied entry represents user-supplied config (not adoption-shaped Outputs reflow); see ResourceState.AppliedConfigSource (iac\\_state.go) for the canonical discriminator.\n\n```go\ntype DriftEntry struct {\n\tName             string `json:\"name\"`\n\tPlanFingerprint  string `json:\"plan_fingerprint\"`\n\tApplyFingerprint string `json:\"apply_fingerprint\"`\n}\n```\nDriftEntry names a single env-var whose fingerprint changed between plan-time and apply-time. Used by both the persisted-\\`--plan\\` path (cmd/wfctl/infra.go, wired in T1.5) and the in-process apply path (wfctlhelpers.ApplyPlan, wired in T3.1.5 — both via inputsnapshot.FormatStaleError).\n\n```go\ntype DriftResult struct {\n\tName     string         `json:\"name\"`\n\tType     string         `json:\"type\"`\n\tDrifted  bool           `json:\"drifted\"`\n\tClass    DriftClass     `json:\"class,omitempty\"` // additive; omitted when Unknown\n\tExpected map[string]any `json:\"expected,omitempty\"`\n\tActual   map[string]any `json:\"actual,omitempty\"`\n\tFields   []string       `json:\"fields,omitempty\"` // which fields drifted\n}\n```\nDriftResult captures detected drift between declared and actual resource state.\n\n```go\ntype EgressRule struct {\n\tDestination string `json:\"destination\" yaml:\"destination\"`\n\tProtocol    string `json:\"protocol\" yaml:\"protocol\"`\n\tAllow       bool   `json:\"allow\" yaml:\"allow\"`\n}\n```\nEgressRule is a single outbound allow/deny entry.\n\n```go\ntype EgressSpec struct {\n\tBandwidth string       `json:\"bandwidth,omitempty\" yaml:\"bandwidth,omitempty\"` // informational budget, e.g. \"1Gbps\"\n\tRules     []EgressRule `json:\"rules,omitempty\" yaml:\"rules,omitempty\"`\n}\n```\nEgressSpec controls outbound traffic policy.\n\n```go\ntype Enumerator interface {\n\tEnumerateByTag(ctx context.Context, tag string) ([]ResourceRef, error)\n}\n```\nEnumerator is an OPTIONAL interface for providers that can list resources by tag across the cloud account. Used by \\`wfctl infra cleanup --tag \\\u003cname\u003e\\`. Providers without a tag-query API simply do not implement it; the cleanup subcommand skips them with a structured stdout log line so operators see the explicit skip rather than silent under-cleanup.\n\nThe contract is intentionally narrow: implementations MUST return refs that the same provider's ResourceDriver(type).Delete can act on. ProviderID is recommended (the cleanup command may use it for log correlation), but Name + Type are the load-bearing identifiers Delete needs.\n\nCallers MUST type-assert against this interface and treat the negative case as a skip — providers may or may not implement Enumerator depending on whether their cloud API exposes a tag-query primitive. The implementation status of individual provider plugins is documented in docs/WFCTL.md \\`#### infra cleanup\\`, not here, so the API comment does not go stale every time a new plugin gains tag-query support.\n\n```go\ntype EnumeratorAll interface {\n\tEnumerateAll(ctx context.Context, resourceType string) ([]*ResourceOutput, error)\n}\n```\nEnumeratorAll is an OPTIONAL provider interface for resource types that don't support tagging (e.g. DO Spaces keys). Returns ALL resources of resourceType in the account regardless of tag, with full metadata (Outputs map populated) so callers can filter without re-reading.\n\nReturns \\[]\\*ResourceOutput rather than \\[]ResourceRef because filtering (drift detection, prune) needs the metadata. Implementations should paginate transparently. Returning \\*ResourceOutput keeps the contract consistent with ResourceDriver.Read which also returns this shape.\n\nPer ADR 0016. Used by \\`wfctl infra audit-keys\\` + \\`wfctl infra prune\\`.\n\n```go\ntype EventEmitter interface {\n\tEmitWorkflowStarted(ctx context.Context, workflowType, action string, data map[string]any)\n\tEmitWorkflowCompleted(ctx context.Context, workflowType, action string, duration time.Duration, results map[string]any)\n\tEmitWorkflowFailed(ctx context.Context, workflowType, action string, duration time.Duration, err error)\n}\n```\nEventEmitter publishes workflow lifecycle events. \\*module.WorkflowEventEmitter satisfies this interface. All methods must be safe to call when no event bus is configured (no-ops).\n\n```go\ntype EventRecorder interface {\n\tRecordEvent(ctx context.Context, executionID string, eventType string, data map[string]any) error\n}\n```\nEventRecorder records pipeline execution events for observability. \\*store.EventRecorderAdapter and any compatible recorder satisfy this interface.\n\n```go\ntype FieldChange struct {\n\tPath     string `json:\"path\"`\n\tOld      any    `json:\"old\"`\n\tNew      any    `json:\"new\"`\n\tForceNew bool   `json:\"force_new\"` // change requires resource replacement\n}\n```\nFieldChange describes a single field-level difference.\n\n```go\ntype GeneratorMetadata struct {\n\tWfctlVersion string              `json:\"wfctl_version\"`\n\tPlugins      []PluginVersionInfo `json:\"plugins,omitempty\"`\n}\n```\nGeneratorMetadata records the wfctl version and installed IaC plugin versions that were present when an IaC plan or state operation was produced. Storing this information makes it possible to reason about compatibility between recorded state and the current toolchain, and to identify upgrades that may be required when behavior has changed between versions.\n\nNote: Plugins lists all IaC provider plugins installed in WFCTL\\_PLUGIN\\_DIR at generation time. In single-run invocations this is equivalent to the loaded set, but operators should be aware that extra installed-but-not-used plugins may appear.\n\n```go\ntype HealthCheckSpec struct {\n\tHTTPPath            string `json:\"http_path,omitempty\" yaml:\"http_path,omitempty\"`\n\tTCPPort             int    `json:\"tcp_port,omitempty\" yaml:\"tcp_port,omitempty\"`\n\tPort                int    `json:\"port,omitempty\" yaml:\"port,omitempty\"`\n\tInitialDelaySeconds int    `json:\"initial_delay_seconds\" yaml:\"initial_delay_seconds\"`\n\tPeriodSeconds       int    `json:\"period_seconds\" yaml:\"period_seconds\"`\n\tTimeoutSeconds      int    `json:\"timeout_seconds\" yaml:\"timeout_seconds\"`\n\tSuccessThreshold    int    `json:\"success_threshold\" yaml:\"success_threshold\"`\n\tFailureThreshold    int    `json:\"failure_threshold\" yaml:\"failure_threshold\"`\n}\n```\nHealthCheckSpec describes an HTTP or TCP health probe.\n\n```go\ntype HealthResult struct {\n\tHealthy bool   `json:\"healthy\"`\n\tMessage string `json:\"message,omitempty\"`\n}\n```\nHealthResult is the outcome of a health check for a resource.\n\n```go\ntype HookEvent string\n```\nHookEvent is the string identifier for a build-pipeline hook event.\n\n```go\nconst (\n\t// Build lifecycle events emitted by wfctl build.\n\tHookEventPreBuild             HookEvent = \"pre_build\"\n\tHookEventPreTargetBuild       HookEvent = \"pre_target_build\"\n\tHookEventPostTargetBuild      HookEvent = \"post_target_build\"\n\tHookEventPreContainerBuild    HookEvent = \"pre_container_build\"\n\tHookEventPostContainerBuild   HookEvent = \"post_container_build\"\n\tHookEventPreContainerPush     HookEvent = \"pre_container_push\"\n\tHookEventPostContainerPush    HookEvent = \"post_container_push\"\n\tHookEventPreArtifactsPublish  HookEvent = \"pre_artifacts_publish\"\n\tHookEventPostArtifactsPublish HookEvent = \"post_artifacts_publish\"\n\tHookEventPreBuildFail         HookEvent = \"pre_build_fail\"\n\tHookEventPostBuild            HookEvent = \"post_build\"\n\n\t// HookEventInstallVerify is emitted by wfctl plugin install after tarball\n\t// download and before extraction. The supply-chain plugin registers a handler\n\t// that verifies cosign signatures, SBOM presence, and OSV vulnerability policy.\n\tHookEventInstallVerify HookEvent = \"install_verify\"\n)\n```\n\n```go\nfunc AllHookEvents() []HookEvent\n```\nAllHookEvents returns all defined hook event constants.\n\n```go\ntype HookPayload struct {\n\tEvent     HookEvent      `json:\"event\"`\n\tPlugin    string         `json:\"plugin\"`\n\tBuildID   string         `json:\"build_id\"`\n\tTimestamp int64          `json:\"timestamp\"`\n\tData      map[string]any `json:\"data,omitempty\"`\n}\n```\nHookPayload is the JSON envelope passed to a plugin hook handler on stdin. Plugins decode this and then further decode Data into the event-specific struct.\n\n```go\ntype IaCCapabilityDeclaration struct {\n\tResourceType string   `json:\"resource_type\"` // infra.database, infra.vpc, etc.\n\tTier         int      `json:\"tier\"`          // 1=infra, 2=shared, 3=app\n\tOperations   []string `json:\"operations\"`    // create, read, update, delete, scale\n}\n```\nIaCCapabilityDeclaration describes a resource type supported by a provider.\n\n```go\ntype IaCLockHandle interface {\n\tUnlock(ctx context.Context) error\n}\n```\nIaCLockHandle is returned by IaCStateStore.Lock and is used to release the lock.\n\n```go\ntype IaCPlan struct {\n\tID        string       `json:\"id\"`\n\tActions   []PlanAction `json:\"actions\"`\n\tCreatedAt time.Time    `json:\"created_at\"`\n\t// DesiredHash is a SHA-256 hex digest of the canonical desired-state inputs\n\t// (sorted ResourceSpecs) at the time the plan was generated. wfctl infra apply\n\t// --plan compares this against the current config to detect stale plans.\n\tDesiredHash string `json:\"plan_hash,omitempty\"`\n\n\t// Include records the sorted resource names passed through\n\t// `wfctl infra plan --include`. Empty means the plan covered the full\n\t// desired set. wfctl infra apply --plan uses this to recompute DesiredHash\n\t// against the same scope without requiring --include at apply time.\n\tInclude []string `json:\"include,omitempty\"`\n\n\t// SchemaVersion is bumped when on-disk plan format changes (W-5 sets to 2 when JIT is required).\n\tSchemaVersion int `json:\"schema_version,omitempty\"`\n\n\t// InputSnapshot records env var names read during ${VAR} substitution at\n\t// plan time, fingerprinting only those that were SET (16-hex-char sha256\n\t// prefix of the value). Unset vars are omitted from the map; their absence\n\t// at apply time is therefore not flagged as drift. Apply re-computes inputs\n\t// and prints diagnostic on mismatch.\n\t//\n\t// Completeness caveat: the cmd/wfctl scanner that populates this map\n\t// (cmd/wfctl/infra_inputsnapshot.go::collectInfraEnvVarRefs) currently\n\t// walks each module's own Config but does not apply top-level\n\t// environments[env].envVars defaults. Vars that originate solely from a\n\t// top-level envVars default may therefore be absent from the snapshot;\n\t// closing this gap is tracked as a follow-up to W-1.\n\tInputSnapshot map[string]string `json:\"input_snapshot,omitempty\"`\n\n\t// GeneratorMetadata records the wfctl version and installed IaC plugin\n\t// versions present when this plan was produced. Populated when the plan\n\t// is serialised to disk (wfctl infra plan -o). Consumers can inspect\n\t// this to assess whether upgrades are needed before re-applying a stored\n\t// plan.\n\tGeneratorMetadata *GeneratorMetadata `json:\"generator_metadata,omitempty\"`\n}\n```\nIaCPlan is the complete execution plan for a set of infrastructure changes.\n\n```go\ntype IaCProvider interface {\n\tName() string\n\tVersion() string\n\tInitialize(ctx context.Context, config map[string]any) error\n\n\t// Capabilities returns what resource types this provider supports.\n\tCapabilities() []IaCCapabilityDeclaration\n\n\t// Lifecycle\n\tPlan(ctx context.Context, desired []ResourceSpec, current []ResourceState) (*IaCPlan, error)\n\t// Apply was removed per workflow#699 (2026-05-17). v2 dispatch\n\t// routes through wfctlhelpers.ApplyPlanWithHooks (ResourceDriver\n\t// per-action + IaCProviderFinalizer.FinalizeApply post-loop). The\n\t// load-time Capabilities-RPC gate in cmd/wfctl/deploy_providers.go\n\t// rejects plugins whose CapabilitiesResponse.compute_plan_version\n\t// is not \"v2\".\n\tDestroy(ctx context.Context, resources []ResourceRef) (*DestroyResult, error)\n\n\t// Observability\n\tStatus(ctx context.Context, resources []ResourceRef) ([]ResourceStatus, error)\n\tDetectDrift(ctx context.Context, resources []ResourceRef) ([]DriftResult, error)\n\n\t// Migration\n\tImport(ctx context.Context, cloudID string, resourceType string) (*ResourceState, error)\n\n\t// Sizing\n\tResolveSizing(resourceType string, size Size, hints *ResourceHints) (*ProviderSizing, error)\n\n\t// Resource drivers for fine-grained CRUD\n\tResourceDriver(resourceType string) (ResourceDriver, error)\n\n\t// SupportedCanonicalKeys returns the subset of canonical IaC config keys\n\t// that this provider understands. Providers may return a subset; callers\n\t// use this to warn on unrecognised fields before applying a plan.\n\t// Built-in and stub providers return the full canonical key set.\n\tSupportedCanonicalKeys() []string\n\n\t// BootstrapStateBackend ensures the state backend resource (bucket/container)\n\t// exists on this provider. It is idempotent: if the resource already exists,\n\t// it returns the current metadata without error. cfg is the expanded\n\t// iac.state module config (backend, bucket, region, credentials, etc.).\n\t//\n\t// Providers that do not manage a state backend should return (nil, nil).\n\t// The caller prints each entry in result.EnvVars as `export KEY=VALUE` for\n\t// CI capture and writes result.Bucket back to the on-disk config.\n\tBootstrapStateBackend(ctx context.Context, cfg map[string]any) (*BootstrapResult, error)\n\n\tClose() error\n}\n```\nIaCProvider is the main interface that cloud provider plugins implement. Each provider (AWS, GCP, Azure, DO) implements this as a gRPC plugin.\n\n```go\ntype IaCProviderJobCanceler interface {\n\tCancelJob(ctx context.Context, handle JobHandle) error\n}\n```\nIaCProviderJobCanceler is a separate OPTIONAL capability, preserving existing IaCProviderRunner implementations. Cancellation applies only to the exact provider-owned job identified by the handle, including its ownership metadata. Providers own terminal cleanup and return ErrProviderMethodUnimplemented when cancellation is unsupported. Callers must discover this capability separately.\n\n```go\ntype IaCProviderRegionLister interface {\n\tListRegions(ctx context.Context, env string) ([]string, error)\n}\n```\nIaCProviderRegionLister is an OPTIONAL interface that an IaCProvider implementation MAY also satisfy to expose provider-sourced region lists. Callers MUST type-assert against this interface and treat the negative case as a skip (static-catalog fallback) — providers that do not implement it continue to work unchanged. Mirrors the Enumerator/DriftDetector/ ProviderValidator optional-interface pattern.\n\nListRegions returns the region identifiers available in the provider for the given environment name (used to scope region lists by env when providers expose env-scoped credentials). An empty env is treated as \"all regions\". Implementations SHOULD sort the returned slice; callers that need a stable order MUST sort themselves.\n\n```go\ntype IaCProviderRunner interface {\n\tRunJob(ctx context.Context, spec JobSpec) (*JobHandle, error)\n\tJobStatus(ctx context.Context, handle JobHandle) (*JobStatusReply, error)\n\tJobLogs(ctx context.Context, handle JobHandle, sink LogCaptureSink) error\n}\n```\nIaCProviderRunner is an OPTIONAL provider interface for launching and observing one-off cloud-native jobs, such as ECS RunTask, Cloud Run Jobs, Azure Container Instances, or DigitalOcean App jobs. Providers that do not implement this continue to work unchanged; callers must discover it through provider-specific accessors or type assertions and treat absence as unsupported.\n\nEnvVarsSecret entries in JobSpec are references for provider-side resolution. The engine must not resolve them to plaintext before crossing this boundary.\n\n```go\ntype IaCStateStore interface {\n\tSaveResource(ctx context.Context, state ResourceState) error\n\tGetResource(ctx context.Context, name string) (*ResourceState, error)\n\tListResources(ctx context.Context) ([]ResourceState, error)\n\tDeleteResource(ctx context.Context, name string) error\n\n\tSavePlan(ctx context.Context, plan IaCPlan) error\n\tGetPlan(ctx context.Context, id string) (*IaCPlan, error)\n\n\tLock(ctx context.Context, resource string, ttl time.Duration) (IaCLockHandle, error)\n\n\tClose() error\n}\n```\nIaCStateStore provides persistent state tracking for managed resources.\n\n```go\ntype IngressRule struct {\n\tMatch     string `json:\"match\" yaml:\"match\"`         // path prefix or header expression\n\tComponent string `json:\"component\" yaml:\"component\"` // target service/worker name\n}\n```\nIngressRule maps an HTTP match to a backend component.\n\n```go\ntype IngressSpec struct {\n\tLoadBalancer string        `json:\"load_balancer,omitempty\" yaml:\"load_balancer,omitempty\"` // e.g. round_robin | least_connections\n\tRules        []IngressRule `json:\"rules,omitempty\" yaml:\"rules,omitempty\"`\n}\n```\nIngressSpec controls inbound traffic routing.\n\n```go\ntype InstallVerifyPayload struct {\n\tTarballPath               string `json:\"tarball_path\"`\n\tExpectedSignatureIdentity string `json:\"expected_signature_identity,omitempty\"`\n\tExpectedSBOMHash          string `json:\"expected_sbom_hash,omitempty\"`\n\tVulnPolicy                string `json:\"vuln_policy,omitempty\"` // block-critical | warn | off\n}\n```\nInstallVerifyPayload is the Data payload for HookEventInstallVerify. The supply-chain plugin handler verifies the tarball's cosign signature, SBOM presence, and OSV vulnerability scan per the declared policy.\n\n```go\ntype JobHandle struct {\n\tID       string            `json:\"id\"`\n\tName     string            `json:\"name,omitempty\"`\n\tProvider string            `json:\"provider,omitempty\"`\n\tMetadata map[string]string `json:\"metadata,omitempty\"`\n}\n```\nJobHandle identifies a provider-created one-off job. Metadata is provider-owned and may include region, task ARN, job URL, or similar correlation fields.\n\n```go\ntype JobSpec struct {\n\tName string `json:\"name\" yaml:\"name\"`\n\tKind string `json:\"kind\" yaml:\"kind\"`\n\t// Target identifies the exact existing parent. Providers validate ownership\n\t// and supported resource types; core never guesses a provider-specific type.\n\tTarget *ResourceRef `json:\"target,omitempty\" yaml:\"target,omitempty\"`\n\t// TimeoutSeconds is 1..MaxProviderJobTimeoutSeconds for targeted jobs.\n\t// Zero is accepted only for untargeted legacy callers, including\n\t// module/provider_ephemeral_runner.go, retaining provider-default behavior.\n\tTimeoutSeconds  int                  `json:\"timeout_seconds,omitempty\" yaml:\"timeout_seconds,omitempty\"`\n\tImage           string               `json:\"image,omitempty\" yaml:\"image,omitempty\"`\n\tRunCommand      string               `json:\"run_command\" yaml:\"run_command\"`\n\tEnvVars         map[string]string    `json:\"env_vars,omitempty\" yaml:\"env_vars,omitempty\"`\n\tEnvVarsSecret   map[string]string    `json:\"env_vars_secret,omitempty\" yaml:\"env_vars_secret,omitempty\"`\n\tCron            string               `json:\"cron,omitempty\" yaml:\"cron,omitempty\"` // non-empty for SCHEDULED kind\n\tTermination     *TerminationSpec     `json:\"termination,omitempty\" yaml:\"termination,omitempty\"`\n\tAlerts          []AlertSpec          `json:\"alerts,omitempty\" yaml:\"alerts,omitempty\"`\n\tLogDestinations []LogDestinationSpec `json:\"log_destinations,omitempty\" yaml:\"log_destinations,omitempty\"`\n}\n```\nJobSpec describes a one-off or scheduled job workload. Kind is one of: PRE\\_DEPLOY, POST\\_DEPLOY, FAILED\\_DEPLOY, SCHEDULED, EPHEMERAL.\n\n```go\nfunc (s JobSpec) Validate() error\n```\nValidate checks provider-neutral target identity and timeout before dispatch. Providers remain responsible for enforcing the execution timeout and cleanup.\n\n```go\ntype JobState string\n```\nJobState is the provider-neutral lifecycle state for a one-off provider job.\n\n```go\nconst (\n\tJobStateUnknown   JobState = \"unknown\"\n\tJobStatePending   JobState = \"pending\"\n\tJobStateRunning   JobState = \"running\"\n\tJobStateSucceeded JobState = \"succeeded\"\n\tJobStateFailed    JobState = \"failed\"\n\tJobStateCancelled JobState = \"cancelled\"\n)\n```\n\n```go\ntype JobStatusReply struct {\n\tHandle   JobHandle `json:\"handle\"`\n\tState    JobState  `json:\"state\"`\n\tExitCode int       `json:\"exit_code\"`\n\tMessage  string    `json:\"message,omitempty\"`\n}\n```\nJobStatusReply is the latest provider-reported state for a JobHandle.\n\n```go\ntype LogCaptureProvider interface {\n\tCaptureLogs(ctx context.Context, req LogCaptureRequest, sink LogCaptureSink) error\n}\n```\nLogCaptureProvider is an OPTIONAL provider interface for ad-hoc operational log capture. \\`wfctl logs capture\\` discovers it through the typed optional IaCProviderLogCapture service.\n\n```go\ntype LogCaptureRequest struct {\n\tResourceName    string\n\tResourceType    string\n\tProviderID      string\n\tComponentName   string\n\tLogType         string\n\tTailLines       int\n\tFollow          bool\n\tDurationSeconds int64\n\tDeploymentID    string\n}\n```\nLogCaptureRequest describes a bounded provider log capture. Providers may support only a subset of fields; unsupported values should return a clear error instead of silently changing scope.\n\n```go\ntype LogCaptureSink interface {\n\tWriteLogChunk(LogChunk) error\n}\n```\nLogCaptureSink receives log chunks from a provider.\n\n```go\ntype LogChunk struct {\n\tData   []byte\n\tSource string\n\tEOF    bool\n}\n```\nLogChunk is one provider-emitted log payload. Data is already formatted for the caller's output stream; Source is optional metadata such as \"historic\" or \"live\".\n\n```go\ntype LogDestinationSpec struct {\n\tName     string            `json:\"name\" yaml:\"name\"`\n\tEndpoint string            `json:\"endpoint\" yaml:\"endpoint\"`\n\tHeaders  map[string]string `json:\"headers,omitempty\" yaml:\"headers,omitempty\"`\n\tTLS      bool              `json:\"tls\" yaml:\"tls\"`\n}\n```\nLogDestinationSpec forwards logs to an external system.\n\n```go\ntype MaintenanceSpec struct {\n\tWindow  string `json:\"window\" yaml:\"window\"` // e.g. \"Sun 03:00-05:00 UTC\"\n\tEnabled bool   `json:\"enabled\" yaml:\"enabled\"`\n}\n```\nMaintenanceSpec defines a recurring maintenance window.\n\n```go\ntype MetricsRecorder interface {\n\tRecordWorkflowExecution(workflowType, action, status string)\n\tRecordWorkflowDuration(workflowType, action string, duration time.Duration)\n}\n```\nMetricsRecorder records workflow execution metrics. \\*module.MetricsCollector satisfies this interface. All methods must be safe to call when no metrics backend is configured (no-ops).\n\n```go\ntype MigrationDriver interface {\n\tName() string\n\tUp(ctx context.Context, req MigrationRequest) (MigrationResult, error)\n\tDown(ctx context.Context, req MigrationRequest) (MigrationResult, error)\n\tStatus(ctx context.Context, req MigrationRequest) (MigrationStatus, error)\n\tGoto(ctx context.Context, req MigrationRequest, target string) (MigrationResult, error)\n}\n```\nMigrationDriver is the interface that migration backend plugins implement. Implementations live in workflow-plugin-migrations (golang-migrate, goose, atlas).\n\n```go\ntype MigrationOptions struct {\n\tSteps   int\n\tDryRun  bool\n\tTimeout time.Duration\n\tVersion string\n}\n```\nMigrationOptions controls migration behaviour.\n\n```go\ntype MigrationProvider interface {\n\t// ProvidesMigrations returns an fs.FS rooted at the migrations directory.\n\t// The FS must contain SQL files named in the golang-migrate convention:\n\t// \u003cversion\u003e_\u003cdescription\u003e.up.sql and \u003cversion\u003e_\u003cdescription\u003e.down.sql.\n\tProvidesMigrations() (fs.FS, error)\n\n\t// MigrationsDependencies returns the names of other MigrationProvider\n\t// modules whose migrations must be applied before this module's.\n\t// For example, the authz module might return [\"workflow.tenants\"].\n\t// Returning nil or an empty slice means no dependencies.\n\tMigrationsDependencies() []string\n}\n```\nMigrationProvider is optionally implemented by modules that embed their own SQL migration files (e.g., the tenants module, authz module).\n\nThe workflow-plugin-migrations runner walks all registered modules in the modular service registry, calls ProvidesMigrations on those that implement this interface, collects the returned filesystems, orders them by declared dependency, and applies them before the application's own migrations.\n\n```go\ntype MigrationRepairRequest struct {\n\tAppResourceName      string            `json:\"app_resource_name\"`\n\tDatabaseResourceName string            `json:\"database_resource_name\"`\n\tJobImage             string            `json:\"job_image\"`\n\tSourceDir            string            `json:\"source_dir\"`\n\tExpectedDirtyVersion string            `json:\"expected_dirty_version\"`\n\tForceVersion         string            `json:\"force_version\"`\n\tThenUp               bool              `json:\"then_up\"`\n\tUpIfClean            bool              `json:\"up_if_clean\"`\n\tConfirmForce         string            `json:\"confirm_force\"`\n\tEnv                  map[string]string `json:\"env,omitempty\"`\n\tTimeoutSeconds       int               `json:\"timeout_seconds,omitempty\"`\n}\n```\n\n```go\nfunc (r MigrationRepairRequest) Validate() error\n```\n\n```go\ntype MigrationRepairResult struct {\n\tProviderJobID string       `json:\"provider_job_id,omitempty\"`\n\tStatus        string       `json:\"status\"`\n\tApplied       []string     `json:\"applied,omitempty\"`\n\tLogs          string       `json:\"logs,omitempty\"`\n\tDiagnostics   []Diagnostic `json:\"diagnostics,omitempty\"`\n}\n```\n\n```go\ntype MigrationRequest struct {\n\tDSN     string\n\tSource  MigrationSource\n\tOptions MigrationOptions\n}\n```\nMigrationRequest holds all parameters needed to run a migration operation.\n\n```go\nfunc (r MigrationRequest) Validate() error\n```\nValidate returns ErrValidation if required fields are missing.\n\n```go\ntype MigrationResult struct {\n\tApplied    []string\n\tSkipped    []string\n\tDurationMs int64\n}\n```\nMigrationResult is returned after a successful migration operation.\n\n```go\ntype MigrationSource struct {\n\tDir        string\n\tFiles      []string\n\tSchemaName string\n}\n```\nMigrationSource describes where migration files come from.\n\n```go\ntype MigrationStatus struct {\n\tCurrent string\n\tPending []string\n\tDirty   bool\n}\n```\nMigrationStatus describes the current migration state of a database.\n\n```go\ntype OwnerFilter struct {\n\tOwner        string `json:\"owner,omitempty\"`\n\tResourceType string `json:\"resource_type,omitempty\"`\n}\n```\nOwnerFilter narrows ownership enumeration. An empty Owner asks the provider to use its default scope; an empty ResourceType means all supported types the provider can safely enumerate.\n\n```go\ntype OwnershipProvider interface {\n\tGetOwner(ctx context.Context, ref ResourceRef) (*ResourceOwner, error)\n\tSetOwner(ctx context.Context, ref ResourceRef, owner string) error\n\tListOwners(ctx context.Context, filter OwnerFilter) ([]ResourceOwner, error)\n}\n```\nOwnershipProvider is an OPTIONAL interface for providers that can read, set, and enumerate cloud-side ownership metadata. Used by \\`wfctl infra apply --owner \\\u003cname\u003e\\` and \\`wfctl infra owners\\`.\n\nImplementations map this provider-neutral contract to native tags, labels, or other safe metadata. \\`GetOwner\\` returns Owner=\"\" when the resource is unowned. \\`SetOwner\\` must be idempotent for the same owner. DNS ownership is intentionally out of scope because the DNS orchestration plugin owns DNS TXT policy.\n\n```go\ntype PipelineContext struct {\n\t// TriggerData is the original data from the trigger (immutable after creation).\n\tTriggerData map[string]any\n\n\t// StepOutputs maps step-name -\u003e output from each completed step.\n\tStepOutputs map[string]map[string]any\n\n\t// Current is the merged state: trigger data + all step outputs.\n\t// Steps read from Current and their output is merged back into it.\n\tCurrent map[string]any\n\n\t// Metadata holds execution metadata (pipeline name, trace ID, etc.)\n\tMetadata map[string]any\n\n\t// StrictTemplates causes template execution to return an error instead of\n\t// the zero value when a template expression references a missing map key.\n\t// When false (the default), missing keys resolve to the zero value with a\n\t// warning logged via Logger. Enable via pipeline config: strict_templates: true.\n\tStrictTemplates bool\n\n\t// Logger is used to emit warnings when a template expression resolves a\n\t// missing key to the zero value (non-strict mode). When nil, slog.Default()\n\t// is used.\n\tLogger *slog.Logger\n}\n```\nPipelineContext carries data through a pipeline execution.\n\n```go\nfunc NewPipelineContext(triggerData map[string]any, metadata map[string]any) *PipelineContext\n```\nNewPipelineContext creates a PipelineContext initialized with trigger data.\n\n```go\nfunc (pc *PipelineContext) MergeStepOutput(stepName string, output map[string]any)\n```\nMergeStepOutput records a step's output and merges it into Current.\n\n```go\ntype PipelineExecutor interface {\n\t// ExecutePipeline runs a named pipeline synchronously and returns its\n\t// structured output. Returns _pipeline_output if set by\n\t// step.pipeline_output, otherwise the pipeline's merged Current state.\n\tExecutePipeline(ctx context.Context, name string, data map[string]any) (map[string]any, error)\n}\n```\nPipelineExecutor provides direct pipeline invocation for Go callers (gRPC servers, tests, etc.) without HTTP serialization overhead. \\*workflow.StdEngine satisfies this interface.\n\n```go\ntype PipelineRunner interface {\n\t// Run executes the pipeline with the given trigger data and returns the\n\t// merged result map (equivalent to PipelineContext.Current).\n\tRun(ctx context.Context, data map[string]any) (map[string]any, error)\n\n\t// SetLogger sets the logger used for pipeline execution.\n\t// Implementations should be idempotent: if a logger is already set,\n\t// a subsequent call should be a no-op.\n\tSetLogger(logger *slog.Logger)\n\n\t// SetEventRecorder sets the recorder used for pipeline execution events.\n\t// Implementations should be idempotent: if a recorder is already set,\n\t// a subsequent call should be a no-op.\n\tSetEventRecorder(recorder EventRecorder)\n}\n```\nPipelineRunner is the interface satisfied by \\*module.Pipeline. It allows workflow handlers to execute pipelines without importing the concrete module types, enabling handler unit tests with mocks.\n\n```go\ntype PipelineStep interface {\n\t// Name returns the step's unique name within the pipeline.\n\tName() string\n\n\t// Execute runs the step with the pipeline context.\n\tExecute(ctx context.Context, pc *PipelineContext) (*StepResult, error)\n}\n```\nPipelineStep is a single composable unit of work in a pipeline.\n\n```go\ntype PlanAction struct {\n\tAction   string         `json:\"action\"` // create, update, replace, delete\n\tResource ResourceSpec   `json:\"resource\"`\n\tCurrent  *ResourceState `json:\"current,omitempty\"`\n\tChanges  []FieldChange  `json:\"changes,omitempty\"`\n\t// CreationOwned is populated only for post-apply hooks by the engine's\n\t// actual dispatch outcome. Upsert updates are false; saved plans cannot\n\t// assert ownership. Nil preserves legacy direct hook callers.\n\tCreationOwned *bool `json:\"-\"`\n\n\t// ResolvedConfigHash is the SHA-256 of the action's Resource.Config,\n\t// computed via platform.ConfigHash. wfctl preserves declarative references\n\t// here; runtime-resolved driver copies are never hashed into persisted plans.\n\t// The legacy field/wire name is retained for compatibility. Lower-case hex (no\n\t// \"sha256:\" prefix); empty string when the config map is empty\n\t// (platform.ConfigHash short-circuit). The field uses `omitempty`, so the\n\t// empty-string case is ABSENT from plan.json — consumers should treat\n\t// \"key missing\" and \"value == empty string\" as the same condition.\n\t//\n\t// Currently populated by ComputePlan and persisted in plan.json so apply\n\t// has the per-action hash available; the apply-time consumer that surfaces\n\t// a per-resource diagnostic on mismatch is wired in a follow-up PR (W-3a/\n\t// T3.1.5). Until then the field is observable via plan.json inspection but\n\t// not yet enforced at apply.\n\tResolvedConfigHash string `json:\"resolved_config_hash,omitempty\"`\n}\n```\nPlanAction is a single planned change within an IaCPlan.\n\n```go\ntype PlanDiagnostic struct {\n\t// Severity is Error|Warning|Info; see PlanDiagnosticSeverity.\n\tSeverity PlanDiagnosticSeverity `json:\"severity\"`\n\t// Resource is the offending resource name; empty for plan-level findings.\n\tResource string `json:\"resource,omitempty\"`\n\t// Field is a dotted/bracketed field path within Resource (e.g. \"vpc_ref\"\n\t// or \"tags[0].key\"); empty for resource-level findings.\n\tField string `json:\"field,omitempty\"`\n\t// Message is a human-readable description of the finding.\n\tMessage string `json:\"message\"`\n}\n```\nPlanDiagnostic is a single finding emitted by a ProviderValidator implementation against an IaCPlan. PlanDiagnostics surface cross-resource constraints (e.g. a database referencing an unknown VPC) at plan time rather than at the provider's API call.\n\n```go\ntype PlanDiagnosticSeverity int\n```\nPlanDiagnosticSeverity classifies the severity of a plan-validation PlanDiagnostic returned by a provider that implements ProviderValidator. Exit-code mapping for \\`wfctl infra align\\`:\n\n  - PlanDiagnosticError → always fails the run (regardless of --strict).\n  - PlanDiagnosticWarning → advisory by default; fails the run under --strict.\n  - PlanDiagnosticInfo → never affects the exit code (even under --strict).\n\nNote: distinct from the unrelated Troubleshooter Diagnostic type (iac\\_resource\\_driver.go), which describes runtime/deploy events. The plan spec for T4.1 originally proposed \\`Diagnostic\\` for the plan-validation type; renamed to PlanDiagnostic to remain purely additive (W-4 contract) without disturbing existing Troubleshooter consumers.\n\n```go\nconst (\n\t// PlanDiagnosticInfo is purely informational — surfaced to the user but\n\t// never fails an align run.\n\tPlanDiagnosticInfo PlanDiagnosticSeverity = iota\n\t// PlanDiagnosticWarning flags a likely-misconfiguration that does not\n\t// block apply but should be reviewed (advisory under --strict).\n\tPlanDiagnosticWarning\n\t// PlanDiagnosticError indicates a constraint violation that the provider\n\t// would reject at apply time. Fails an align run under --strict.\n\tPlanDiagnosticError\n)\n```\n\n```go\ntype PluginVersionInfo struct {\n\tName    string `json:\"name\"`\n\tVersion string `json:\"version,omitempty\"`\n}\n```\nPluginVersionInfo captures the name and version of an installed IaC provider plugin found in the plugin directory at the time an IaC plan or apply was run.\n\n```go\ntype PortSpec struct {\n\tName     string `json:\"name\" yaml:\"name\"`\n\tPort     int    `json:\"port\" yaml:\"port\"`\n\tProtocol string `json:\"protocol\" yaml:\"protocol\"` // http | tcp | udp\n\tPublic   bool   `json:\"public\" yaml:\"public\"`\n}\n```\nPortSpec describes a named port exposed by a service or sidecar.\n\n```go\ntype PostArtifactsPublishPayload struct {\n\tAssets     []ArtifactEntry `json:\"assets\"`\n\tDurationMs int64           `json:\"duration_ms\"`\n}\n```\n\n```go\ntype PostBuildPayload struct {\n\tTargets    []string `json:\"targets\"`\n\tSuccess    bool     `json:\"success\"`\n\tDurationMs int64    `json:\"duration_ms\"`\n}\n```\nPostBuildPayload is the final build summary.\n\n```go\ntype PostContainerBuildPayload struct {\n\tTarget     string `json:\"target\"`\n\tImageRef   string `json:\"image_ref\"`\n\tDigest     string `json:\"digest\"`\n\tDurationMs int64  `json:\"duration_ms\"`\n}\n```\nPostContainerBuildPayload carries the built image digest.\n\n```go\ntype PostContainerPushPayload struct {\n\tImageRef   string   `json:\"image_ref\"`\n\tDigest     string   `json:\"digest\"`\n\tRegistries []string `json:\"registries\"`\n\tDurationMs int64    `json:\"duration_ms\"`\n}\n```\n\n```go\ntype PostTargetBuildPayload struct {\n\tTarget     string   `json:\"target\"`\n\tType       string   `json:\"type\"`\n\tOutputs    []string `json:\"outputs,omitempty\"`\n\tDurationMs int64    `json:\"duration_ms\"`\n}\n```\n\n```go\ntype PreArtifactsPublishPayload struct {\n\tAssets []string `json:\"assets\"`\n}\n```\nPreArtifactsPublishPayload / PostArtifactsPublishPayload describe asset publishing.\n\n```go\ntype PreBuildFailPayload struct {\n\tError  string `json:\"error\"`\n\tTarget string `json:\"target,omitempty\"`\n}\n```\nPreBuildFailPayload carries the error that caused the build to fail.\n\n```go\ntype PreBuildPayload struct {\n\tConfigPath string   `json:\"config_path\"`\n\tTargets    []string `json:\"targets\"`\n}\n```\nPreBuildPayload is the Data payload for HookEventPreBuild.\n\n```go\ntype PreContainerBuildPayload struct {\n\tTarget         string   `json:\"target\"`\n\tDockerfilePath string   `json:\"dockerfile_path\"`\n\tContextPath    string   `json:\"context_path\"`\n\tTags           []string `json:\"tags\"`\n}\n```\nPreContainerBuildPayload carries Dockerfile + context for a container build start.\n\n```go\ntype PreContainerPushPayload struct {\n\tImageRef   string   `json:\"image_ref\"`\n\tRegistries []string `json:\"registries\"`\n}\n```\nPreContainerPushPayload / PostContainerPushPayload describe registry push.\n\n```go\ntype PreTargetBuildPayload struct {\n\tTarget string `json:\"target\"`\n\tType   string `json:\"type\"`\n}\n```\nPreTargetBuildPayload / PostTargetBuildPayload carry per-target context.\n\n```go\ntype ProviderCredentialRevoker interface {\n\tRevokeProviderCredential(ctx context.Context, source string, credentialID string) error\n}\n```\nProviderCredentialRevoker is an OPTIONAL interface a provider MAY implement to support revoking previously-issued provider\\_credential credentials. Used by \\`wfctl infra bootstrap --force-rotate \\\u003cname\u003e\\` to invalidate the OLD credential at the upstream provider AFTER the new one has been minted and stored (mint-new-then-revoke-old ordering; see ADR 0012).\n\nsource is the provider\\_credential source string (e.g. \"digitalocean.spaces\"). credentialID is the provider-specific identifier of the OLD credential (e.g. the access\\_key for DO Spaces — stored as \\\u003cname\u003e\\_access\\_key).\n\nCallers MUST type-assert before calling and treat the negative case as a \"log warning, not implemented\" path — providers that do not implement this interface are valid; revocation just does not happen automatically.\n\nError contract:\n\n  - nil → successfully revoked (or credential was already absent)\n  - non-nil → revocation failed; caller logs warning + emits telemetry but MUST NOT roll back the newly-stored credential (the new key is valid)\n\n```go\ntype ProviderIDFormat int\n```\nProviderIDFormat identifies the shape of provider-specific resource identifiers so wfctl can validate them at the driver boundary without knowing provider-specific semantics.\n\nThe zero value IDFormatUnknown disables validation for backward compatibility — drivers that don't opt in get today's behavior.\n\n```go\nconst (\n\t// IDFormatUnknown disables validation (zero value).\n\tIDFormatUnknown ProviderIDFormat = iota\n\t// IDFormatUUID is the canonical 36-character hyphenated UUID shape.\n\tIDFormatUUID\n\t// IDFormatDomainName is an RFC 1035 domain name.\n\tIDFormatDomainName\n\t// IDFormatARN is an AWS-style colon-separated ARN.\n\tIDFormatARN\n\t// IDFormatFreeform allows any non-empty string.\n\tIDFormatFreeform\n)\n```\n\n```go\nfunc (f ProviderIDFormat) String() string\n```\nString returns a stable identifier for logs and error messages.\n\n```go\ntype ProviderIDValidator interface {\n\tProviderIDFormat() ProviderIDFormat\n}\n```\nProviderIDValidator is an optional interface ResourceDriver implementations may provide to declare the shape of their ProviderIDs. wfctl uses the declaration to validate ProviderIDs at two boundaries:\n\n  - Input: before Update/Delete, probe ref.ProviderID against the declared format. On mismatch, wfctl logs a warning but still calls the driver so its own heal logic (if any) can run.\n  - Output: after Apply, probe r.ProviderID before persisting to state. Mismatch for non-Unknown formats is a HARD failure — the driver has a bug and state must not be corrupted. Freeform accepts any non-empty ProviderID; Unknown disables output validation.\n\nDrivers that do not implement this interface receive today's behavior: no validation, no warning, no failure.\n\n```go\ntype ProviderMigrationRepairer interface {\n\tRepairDirtyMigration(ctx context.Context, req MigrationRepairRequest) (*MigrationRepairResult, error)\n}\n```\n\n```go\ntype ProviderPlanner interface {\n\tPlanV2(ctx context.Context, desired []ResourceSpec, current []ResourceState) (IaCPlan, error)\n}\n```\nProviderPlanner is an optional interface for v2 plugins that need custom plan logic (replacing platform.ComputePlan's default driver.Diff dispatch).\n\nReserved as an extension hook for Tofu/Pulumi-style adapter plugins. Core wfctl's platform.ComputePlan + wfctlhelpers.ApplyPlan do NOT type-assert against this interface in v0.21.0 — adapter PRs that wish to use it will add the type-assertion at the dispatch site in their own design discussion.\n\nPlugins implementing this interface are accepted by the loader; the implementation is not yet exercised by core code.\n\n```go\ntype ProviderSizing struct {\n\tInstanceType string         `json:\"instance_type\"`\n\tSpecs        map[string]any `json:\"specs\"`\n}\n```\nProviderSizing is the concrete sizing resolved by a provider for a resource type.\n\n```go\ntype ProviderValidator interface {\n\tValidatePlan(plan *IaCPlan) []PlanDiagnostic\n}\n```\nProviderValidator is an OPTIONAL interface that an IaCProvider implementation MAY also satisfy to expose provider-side cross-resource constraint validation at plan time. Consumers (e.g. R-A10 in cmd/wfctl/infra\\_align\\*.go) use a type-assertion to discover whether a given provider implements ValidatePlan; providers that do not implement it continue to work unchanged.\n\nValidatePlan is read-only: it MUST NOT mutate plan and MUST NOT make remote calls. The returned slice may be nil (no diagnostics).\n\n```go\ntype Reconfigurable interface {\n\t// Reconfigure applies new configuration to a running module.\n\t// The module should:\n\t//   1. Validate the new config\n\t//   2. Gracefully drain in-flight work\n\t//   3. Apply the new configuration\n\t//   4. Resume accepting new work\n\t// Returns an error if the new config is invalid or cannot be applied.\n\tReconfigure(ctx context.Context, newConfig map[string]any) error\n}\n```\nReconfigurable is optionally implemented by modules that support runtime reconfiguration without requiring a full engine restart. When a config change affects only modules implementing this interface, the engine can perform a surgical update instead of a full stop/rebuild/start.\n\n```go\ntype ResourceAdoptionLocator interface {\n\tAdoptionRef(spec ResourceSpec) (ResourceRef, bool, error)\n}\n```\nResourceAdoptionLocator is an optional interface ResourceDriver implementations may provide when a desired ResourceSpec can be resolved to a live provider resource before local state exists. wfctl infra apply uses this to adopt existing resources into state and then computes an update/delete plan from real current state instead of blindly creating duplicates.\n\n```go\ntype ResourceDriver interface {\n\tCreate(ctx context.Context, spec ResourceSpec) (*ResourceOutput, error)\n\tRead(ctx context.Context, ref ResourceRef) (*ResourceOutput, error)\n\tUpdate(ctx context.Context, ref ResourceRef, spec ResourceSpec) (*ResourceOutput, error)\n\tDelete(ctx context.Context, ref ResourceRef) error\n\tDiff(ctx context.Context, desired ResourceSpec, current *ResourceOutput) (*DiffResult, error)\n\tHealthCheck(ctx context.Context, ref ResourceRef) (*HealthResult, error)\n\tScale(ctx context.Context, ref ResourceRef, replicas int) (*ResourceOutput, error)\n\t// SensitiveKeys returns output keys whose values should be masked in logs and plan output.\n\t// Sensitive Config inputs use the optional ResourceSensitiveInputDeclarer.\n\tSensitiveKeys() []string\n}\n```\nResourceDriver handles CRUD for a single resource type within a provider.\n\n```go\ntype ResourceHints struct {\n\tCPU     string `json:\"cpu,omitempty\" yaml:\"cpu,omitempty\"`\n\tMemory  string `json:\"memory,omitempty\" yaml:\"memory,omitempty\"`\n\tStorage string `json:\"storage,omitempty\" yaml:\"storage,omitempty\"`\n}\n```\nResourceHints are optional fine-grained overrides on top of the Size tier.\n\n```go\ntype ResourceLifecycle struct {\n\tGeneration string        `json:\"generation\"`\n\tPhase      ResourcePhase `json:\"phase\"`\n\t// RoutingCreated permits rollback only of an interrupted owned creation.\n\t// Its absent/false legacy value never authorizes deleting adopted resources.\n\tRoutingCreated bool                    `json:\"routing_created,omitempty\"`\n\tSecrets        []RoutedSecretReference `json:\"secrets,omitempty\"`\n}\n```\nResourceLifecycle contains only identifiers and completion evidence, never credential values. Generation fences retries against a different incarnation.\n\n```go\ntype ResourceOutput struct {\n\tName       string          `json:\"name\"`\n\tType       string          `json:\"type\"`\n\tProviderID string          `json:\"provider_id\"`\n\tOutputs    map[string]any  `json:\"outputs\"`             // IPs, endpoints, connection strings\n\tSensitive  map[string]bool `json:\"sensitive,omitempty\"` // keys whose values are sensitive\n\tStatus     string          `json:\"status\"`\n}\n```\nResourceOutput is the concrete output of a provisioned or read resource.\n\n```go\ntype ResourceOwner struct {\n\tRef    ResourceRef `json:\"ref\"`\n\tOwner  string      `json:\"owner,omitempty\"`\n\tSource string      `json:\"source,omitempty\"`\n}\n```\nResourceOwner captures cloud-side resource ownership metadata returned by providers that implement OwnershipProvider. Owner is the portable identity; Source describes the provider-specific mechanism (for example \"tag:managed-by\" or \"label:managed-by\").\n\n```go\ntype ResourcePhase string\n```\nResourcePhase records recovery debt independently of provider outputs.\n\n```go\nconst (\n\tResourcePhaseActive                           ResourcePhase = \"active\"\n\tResourcePhaseSecretRoutingPending             ResourcePhase = \"secret_routing_pending\" //nolint:gosec // Lifecycle label, not a credential.\n\tResourcePhaseCloudDeletePending               ResourcePhase = \"cloud_delete_pending\"\n\tResourcePhaseCloudDeletedSecretCleanupPending ResourcePhase = \"cloud_deleted_secret_cleanup_pending\" //nolint:gosec // Lifecycle label, not a credential.\n)\n```\n\n```go\ntype ResourceRef struct {\n\tName       string `json:\"name\"`\n\tType       string `json:\"type\"`\n\tProviderID string `json:\"provider_id,omitempty\"`\n}\n```\nResourceRef is a lightweight reference to an existing resource.\n\n```go\ntype ResourceReplacer interface {\n\tReplace(ctx context.Context, oldRef ResourceRef, spec ResourceSpec) (*ResourceOutput, error)\n}\n```\nResourceReplacer is an optional interface ResourceDriver implementations may provide when a resource's Replace transition needs more than naive Delete-then-Create — typically because the resource owns single-attach dependents (e.g., a DO Droplet with Block Storage Volumes, an AWS EC2 instance with EBS Volumes, a GCP VM with persistent disks) that the cloud refuses to associate with a new parent until the old parent releases them.\n\nwfctlhelpers.doReplace probes for this interface; on opt-in, the driver receives the OLD ref and the NEW spec and is responsible for the full transition. On non-opt-in, doReplace calls wfctlhelpers.DefaultReplace (the existing Delete-then-Create logic, exported for direct dispatch).\n\nDrivers SHOULD NOT implement this interface unless the resource has orchestration needs the engine cannot satisfy generically — naive Delete-then-Create is correct for the majority of cloud resources and is the default for a reason (atomicity, error attribution).\n\nA driver that opts in but wants engine-default behavior for a particular spec calls wfctlhelpers.DefaultReplace directly. The engine never inspects the returned error to decide between paths, so there is no sentinel-error round-trip.\n\nError attribution: drivers MUST wrap their sub-step errors with a recognizable prefix (e.g., \"\\\u003cresource-type\u003e replace %q: detach volume %q: %w\"). Non-conforming returns are wrapped by the engine with \"replace: driver: \" at the dispatch boundary so operator attribution is preserved at runtime regardless of per-plugin discipline.\n\n```go\ntype ResourceSensitiveInputDeclarer interface {\n\tSensitiveInputPaths(ctx context.Context) ([]string, error)\n}\n```\nResourceSensitiveInputDeclarer is an optional driver capability declaring sensitive Config leaves as canonical RFC 6901 pointers. A whole \"\\*\" segment matches one map key or list index. Declarations contain no secret values. The engine validates present leaves as references before runtime resolution. Remote drivers return ErrProviderMethodUnimplemented when the capability is absent; other errors must stop dispatch rather than omit input validation.\n\n```go\ntype ResourceSpec struct {\n\tName      string         `json:\"name\"`\n\tType      string         `json:\"type\"`\n\tConfig    map[string]any `json:\"config\"`\n\tSize      Size           `json:\"size,omitempty\"`\n\tHints     *ResourceHints `json:\"hints,omitempty\"`\n\tDependsOn []string       `json:\"depends_on,omitempty\"`\n}\n```\nResourceSpec is the desired state declaration for a single resource.\n\n```go\ntype ResourceState struct {\n\tID            string         `json:\"id\"`\n\tName          string         `json:\"name\"`\n\tType          string         `json:\"type\"`\n\tProvider      string         `json:\"provider\"`\n\tProviderRef   string         `json:\"provider_ref,omitempty\"`\n\tProviderID    string         `json:\"provider_id\"`\n\tConfigHash    string         `json:\"config_hash\"`\n\tAppliedConfig map[string]any `json:\"applied_config\"`\n\t// AppliedConfigSource records the provenance of AppliedConfig:\n\t//   - \"apply\": AppliedConfig came from a user-supplied ResourceSpec.Config\n\t//     (set by applyWithProviderAndStore / applyPrecomputedPlanWithStore).\n\t//   - \"adoption\": AppliedConfig was reflowed from live cloud Outputs\n\t//     (set by adoptExistingResources). Comparing such entries against\n\t//     a fresh Read produces false-positive config-drift; consumers MUST\n\t//     refuse to compute config-drift on adoption-shaped entries.\n\t//   - \"\" (empty): legacy state written before this field existed.\n\t//     Consumers MUST treat as \"adoption\" (conservative default).\n\tAppliedConfigSource string             `json:\"applied_config_source,omitempty\"`\n\tOutputs             map[string]any     `json:\"outputs\"`\n\tDependencies        []string           `json:\"dependencies\"`\n\tCreatedAt           time.Time          `json:\"created_at\"`\n\tUpdatedAt           time.Time          `json:\"updated_at\"`\n\tLastDriftCheck      time.Time          `json:\"last_drift_check,omitempty\"`\n\tLifecycle           *ResourceLifecycle `json:\"lifecycle,omitempty\"`\n}\n```\nResourceState is the persisted state record for a single managed resource.\n\n```go\ntype ResourceStateUpdater interface {\n\tUpdateWithState(ctx context.Context, ref ResourceRef, spec ResourceSpec, prior *ResourceState) (*ResourceOutput, error)\n}\n```\nResourceStateUpdater optionally receives authoritative persisted state on the update call. Callers must load it at dispatch time, not from a saved plan or an earlier Diff. Drivers requiring it must reject legacy Update calls before mutation; ResourceDriver remains unchanged for existing implementations. A typed provider bridge may receive nil prior state from a legacy RPC. It must reject state-dependent updates before mutation, but may delegate updates that do not require state to their existing implementation.\n\n```go\ntype ResourceStatus struct {\n\tName       string         `json:\"name\"`\n\tType       string         `json:\"type\"`\n\tProviderID string         `json:\"provider_id\"`\n\tStatus     string         `json:\"status\"` // running, stopped, degraded, unknown\n\tOutputs    map[string]any `json:\"outputs\"`\n}\n```\nResourceStatus is the live status of a provisioned resource.\n\n```go\ntype RouteSpec struct {\n\tPath               string `json:\"path\" yaml:\"path\"`\n\tPreservePathPrefix bool   `json:\"preserve_path_prefix\" yaml:\"preserve_path_prefix\"`\n}\n```\nRouteSpec maps an HTTP path prefix to this service.\n\n```go\ntype RoutedSecretReference struct {\n\tKey            string `json:\"key\"`\n\tStore          string `json:\"store,omitempty\"`\n\tProvider       string `json:\"provider\"`\n\tScope          string `json:\"scope\"`\n\tSubject        string `json:\"subject\"`\n\tVerifiedAbsent bool   `json:\"verified_absent,omitempty\"`\n}\n```\nRoutedSecretReference identifies the concrete secret namespace used at write time. Store selects a configured named store; empty means the routing default.\n\n```go\ntype SchemaRegistrar interface {\n\t// Name returns the module name (used for logging).\n\tName() string\n\n\t// RegisterAdminSchemas registers all admin API request/response schemas\n\t// onto this generator. Equivalent to calling module.RegisterAdminSchemas(gen).\n\tRegisterAdminSchemas()\n\n\t// ApplySchemas applies all previously registered component schemas and\n\t// operation schema overrides to the current OpenAPI spec.\n\tApplySchemas()\n}\n```\nSchemaRegistrar is implemented by any service that can register admin schemas into an OpenAPI specification and apply them. Using this interface in cmd/server allows the server to enrich the OpenAPI spec without holding a concrete \\*module.OpenAPIGenerator pointer.\n\n\\*module.OpenAPIGenerator satisfies this interface.\n\n```go\ntype Selector interface {\n\tMatch(r *http.Request) (key string, matched bool, err error)\n}\n```\nSelector extracts a tenant lookup key from an HTTP request. Match returns the key, whether the selector matched, and any error.\n\n```go\ntype SidecarSpec struct {\n\tName              string                `json:\"name\" yaml:\"name\"`\n\tImage             string                `json:\"image,omitempty\" yaml:\"image,omitempty\"`\n\tRunCommand        string                `json:\"run_command\" yaml:\"run_command\"`\n\tEnvVars           map[string]string     `json:\"env_vars,omitempty\" yaml:\"env_vars,omitempty\"`\n\tEnvVarsSecret     map[string]string     `json:\"env_vars_secret,omitempty\" yaml:\"env_vars_secret,omitempty\"`\n\tPorts             []PortSpec            `json:\"ports,omitempty\" yaml:\"ports,omitempty\"`\n\tResources         *WorkloadResourceSpec `json:\"resources,omitempty\" yaml:\"resources,omitempty\"`\n\tHealthCheck       *HealthCheckSpec      `json:\"health_check,omitempty\" yaml:\"health_check,omitempty\"`\n\tSharesNetworkWith string                `json:\"shares_network_with,omitempty\" yaml:\"shares_network_with,omitempty\"` // name of the service this sidecar attaches to\n}\n```\nSidecarSpec describes a companion container that shares the network with the main service (e.g. Tailscale, Envoy).\n\n```go\ntype Size string\n```\nSize is the abstract sizing tier for a resource.\n\n```go\nconst (\n\tSizeXS Size = \"xs\"\n\tSizeS  Size = \"s\"\n\tSizeM  Size = \"m\"\n\tSizeL  Size = \"l\"\n\tSizeXL Size = \"xl\"\n)\n```\n\n```go\ntype SizingDefaults struct {\n\tCPU         string `json:\"cpu\"`\n\tMemory      string `json:\"memory\"`\n\tDBStorage   string `json:\"db_storage\"`\n\tCacheMemory string `json:\"cache_memory\"`\n}\n```\nSizingDefaults holds the concrete resource values for a given size tier.\n\n```go\ntype StaticSiteSpec struct {\n\tName         string            `json:\"name\" yaml:\"name\"`\n\tBuildCommand string            `json:\"build_command\" yaml:\"build_command\"`\n\tOutputDir    string            `json:\"output_dir\" yaml:\"output_dir\"`\n\tEnvVars      map[string]string `json:\"env_vars,omitempty\" yaml:\"env_vars,omitempty\"`\n\tRoutes       []RouteSpec       `json:\"routes,omitempty\" yaml:\"routes,omitempty\"`\n\tCORS         *CORSSpec         `json:\"cors,omitempty\" yaml:\"cors,omitempty\"`\n\tDomains      []DomainSpec      `json:\"domains,omitempty\" yaml:\"domains,omitempty\"`\n\tAlerts       []AlertSpec       `json:\"alerts,omitempty\" yaml:\"alerts,omitempty\"`\n}\n```\nStaticSiteSpec describes a statically-built web front-end.\n\n```go\ntype StepRegistrar interface {\n\tStepRegistryProvider\n\t// Create instantiates a PipelineStep of the given type.\n\t// app must be a modular.Application; it is typed as any to avoid\n\t// coupling this interfaces package to the modular dependency.\n\tCreate(stepType, name string, config map[string]any, app any) (PipelineStep, error)\n}\n```\nStepRegistrar manages step type registration and creation. It embeds StepRegistryProvider for type enumeration and adds a Create method for instantiating steps. Register is intentionally omitted from this interface because factory signatures use modular.Application (a concrete type) which cannot be expressed here without creating an import cycle.\n\n```go\ntype StepRegistryProvider interface {\n\t// Types returns all registered step type names.\n\tTypes() []string\n}\n```\nStepRegistryProvider exposes the step types registered in a step registry. \\*module.StepRegistry satisfies this interface.\n\n```go\ntype StepResult struct {\n\t// Output is the data produced by this step.\n\tOutput map[string]any\n\n\t// NextStep overrides the default next step (for conditional routing).\n\t// Empty string means continue to the next step in sequence.\n\tNextStep string\n\n\t// Stop indicates the pipeline should stop after this step (success).\n\tStop bool\n\n\t// Skipped indicates the step was bypassed by a guard (skip_if or if).\n\t// When true, the pipeline executor will not record this step in StepOutputs.\n\tSkipped bool\n}\n```\nStepResult is the output of a single pipeline step execution.\n\n```go\ntype Tenant struct {\n\tID       string         `json:\"id\"`\n\tName     string         `json:\"name\"`\n\tSlug     string         `json:\"slug\"`\n\tDomains  []string       `json:\"domains,omitempty\"`\n\tMetadata map[string]any `json:\"metadata,omitempty\"`\n\tIsActive bool           `json:\"is_active\"`\n}\n```\nTenant represents an identified tenant in a multi-tenant system.\n\n```go\nfunc (t Tenant) IsZero() bool\n```\nIsZero reports whether t is the zero value (no ID set).\n\n```go\ntype TenantFilter struct {\n\tActiveOnly bool   `json:\"active_only,omitempty\"`\n\tDomain     string `json:\"domain,omitempty\"`\n\tSlug       string `json:\"slug,omitempty\"`\n\tLimit      int    `json:\"limit,omitempty\"`\n\tOffset     int    `json:\"offset,omitempty\"`\n}\n```\nTenantFilter constrains the results of TenantRegistry.List. All zero-value fields are treated as \"no constraint\".\n\n```go\ntype TenantPatch struct {\n\tName     *string        `json:\"name,omitempty\"`\n\tDomains  []string       `json:\"domains,omitempty\"`\n\tMetadata map[string]any `json:\"metadata,omitempty\"`\n\tIsActive *bool          `json:\"is_active,omitempty\"`\n}\n```\nTenantPatch is a partial update payload; nil pointer fields are left unchanged.\n\n```go\ntype TenantRegistry interface {\n\t// Ensure creates the tenant if it does not exist, or returns the existing one.\n\tEnsure(spec TenantSpec) (Tenant, error)\n\n\t// GetByID looks up a tenant by its opaque ID.\n\tGetByID(id string) (Tenant, error)\n\n\t// GetByDomain looks up a tenant by one of its associated domains.\n\tGetByDomain(domain string) (Tenant, error)\n\n\t// GetBySlug looks up a tenant by its unique URL slug.\n\tGetBySlug(slug string) (Tenant, error)\n\n\t// List returns tenants matching the filter (all tenants if filter is zero).\n\tList(filter TenantFilter) ([]Tenant, error)\n\n\t// Update applies a partial patch to an existing tenant.\n\tUpdate(id string, patch TenantPatch) (Tenant, error)\n\n\t// Disable soft-deletes a tenant (sets IsActive=false).\n\tDisable(id string) error\n}\n```\nTenantRegistry persists and retrieves Tenant records.\n\n```go\ntype TenantResolver interface {\n\t// Resolve returns the Tenant associated with the request.\n\t// Returns the zero Tenant and no error when no tenant is found.\n\tResolve(ctx context.Context, r *http.Request) (Tenant, error)\n}\n```\nTenantResolver resolves the tenant for an inbound request. Implementations combine one or more Selectors with a lookup strategy.\n\n```go\ntype TenantSpec struct {\n\tName     string         `json:\"name\"`\n\tSlug     string         `json:\"slug\"`\n\tDomains  []string       `json:\"domains,omitempty\"`\n\tMetadata map[string]any `json:\"metadata,omitempty\"`\n}\n```\nTenantSpec is the creation payload for a Tenant.\n\n```go\nfunc (s TenantSpec) Validate() error\n```\nValidate checks that TenantSpec has the required fields and that the slug is well-formed. Slug must be non-empty and all-lowercase; mixed-case slugs are rejected to ensure consistent URL routing and cache key derivation.\n\n```go\ntype TerminationSpec struct {\n\tDrainSeconds       int `json:\"drain_seconds\" yaml:\"drain_seconds\"`\n\tGracePeriodSeconds int `json:\"grace_period_seconds\" yaml:\"grace_period_seconds\"`\n}\n```\nTerminationSpec controls drain / graceful-shutdown behaviour.\n\n```go\ntype Trigger interface {\n\tmodular.Module\n\tmodular.Startable\n\tmodular.Stoppable\n\n\t// Configure sets up the trigger from configuration.\n\tConfigure(app modular.Application, triggerConfig any) error\n}\n```\nTrigger defines what can start a workflow execution. Moving this interface here breaks the engine→module import dependency while preserving backward compatibility via the type alias in the module package.\n\n\\*module.HTTPTrigger, \\*module.ScheduleTrigger, and other concrete trigger implementations all satisfy this interface.\n\n```go\ntype TriggerRegistrar interface {\n\t// RegisterTrigger adds a trigger to the registry.\n\tRegisterTrigger(trigger Trigger)\n}\n```\nTriggerRegistrar manages registered triggers. \\*module.TriggerRegistry satisfies this interface.\n\n```go\ntype Troubleshooter interface {\n\tTroubleshoot(ctx context.Context, ref ResourceRef, failureMsg string) ([]Diagnostic, error)\n}\n```\nTroubleshooter is an optional interface that ResourceDrivers may implement. wfctl calls Troubleshoot automatically when a health-check poll times out or a deploy operation returns a generic error, surfacing provider-side context that would otherwise require visiting the provider's web console.\n\nImplementations should return the N most recent relevant events (deployments, job runs, etc.) in reverse-chronological order.  Returning an error is non-fatal — wfctl logs it and continues with the original failure message.\n\n```go\ntype UpsertSupporter interface {\n\tSupportsUpsert() bool\n}\n```\nUpsertSupporter is an optional interface implemented by ResourceDrivers that support locating an existing resource by name alone (empty ProviderID) in their Read method. wfctlhelpers.ApplyPlan uses this hook to recover from Create that returns ErrResourceAlreadyExists: when the driver opts in via SupportsUpsert()==true, ApplyPlan calls Read with a name-only ResourceRef to obtain the existing ProviderID, then calls Update to bring the resource to the desired state — net effect of an idempotent upsert without requiring drivers to implement upsert natively.\n\nDrivers that do not implement this interface (or return false) yield the original ErrResourceAlreadyExists unchanged — ApplyPlan does NOT silently swallow the conflict. Implementations should return true only when their Read can locate a resource by Name + Type without a ProviderID; returning true while requiring a non-empty ProviderID in Read defeats the recovery path.\n\n```go\ntype ValidationError struct {\n\tMessage string\n\tStatus  int    // HTTP status code to use (e.g., 400, 422)\n\tField   string // optional: which field was invalid\n\tCode    string // optional: machine-readable error code for clients\n}\n```\nValidationError indicates a step failed due to invalid user input, not an infrastructure error. HTTP handlers map this to a 4xx status code instead of the default 500 Internal Server Error.\n\n```go\nfunc NewValidationError(msg string, status int) *ValidationError\n```\nNewValidationError creates a ValidationError with the given message and HTTP status code. Use status 400 for bad input, 422 for unprocessable entity, etc.\n\n```go\nfunc (e *ValidationError) Error() string\n```\n\n```go\ntype WorkerSpec struct {\n\tName            string                `json:\"name\" yaml:\"name\"`\n\tImage           string                `json:\"image,omitempty\" yaml:\"image,omitempty\"`\n\tRunCommand      string                `json:\"run_command\" yaml:\"run_command\"`\n\tEnvVars         map[string]string     `json:\"env_vars,omitempty\" yaml:\"env_vars,omitempty\"`\n\tEnvVarsSecret   map[string]string     `json:\"env_vars_secret,omitempty\" yaml:\"env_vars_secret,omitempty\"`\n\tInstanceCount   int                   `json:\"instance_count\" yaml:\"instance_count\"`\n\tSize            string                `json:\"size,omitempty\" yaml:\"size,omitempty\"`\n\tAutoscaling     *AutoscalingSpec      `json:\"autoscaling,omitempty\" yaml:\"autoscaling,omitempty\"`\n\tHealthCheck     *HealthCheckSpec      `json:\"health_check,omitempty\" yaml:\"health_check,omitempty\"`\n\tResources       *WorkloadResourceSpec `json:\"resources,omitempty\" yaml:\"resources,omitempty\"`\n\tTermination     *TerminationSpec      `json:\"termination,omitempty\" yaml:\"termination,omitempty\"`\n\tAlerts          []AlertSpec           `json:\"alerts,omitempty\" yaml:\"alerts,omitempty\"`\n\tLogDestinations []LogDestinationSpec  `json:\"log_destinations,omitempty\" yaml:\"log_destinations,omitempty\"`\n}\n```\nWorkerSpec describes a long-running background worker workload.\n\n```go\ntype WorkflowStoreProvider interface {\n\t// Name returns the module name (used for logging).\n\tName() string\n\n\t// WorkflowStore returns the underlying workflow data store as an opaque\n\t// value. The caller is responsible for asserting the concrete type\n\t// (typically *module.V1Store) when further operations are required.\n\tWorkflowStore() any\n}\n```\nWorkflowStoreProvider is implemented by any service that exposes a workflow data store. Using this interface in cmd/server decouples the server startup code from the concrete \\*module.WorkflowRegistry type.\n\n\\*module.WorkflowRegistry satisfies this interface.\n\n```go\ntype WorkloadResourceSpec struct {\n\tCPUMillis   int `json:\"cpu_millis\" yaml:\"cpu_millis\"` // 1000 = 1 vCPU\n\tMemoryMiB   int `json:\"memory_mib\" yaml:\"memory_mib\"`\n\tCPULimit    int `json:\"cpu_limit\" yaml:\"cpu_limit\"`\n\tMemoryLimit int `json:\"memory_limit\" yaml:\"memory_limit\"`\n}\n```\nWorkloadResourceSpec declares CPU and memory resource requests/limits for a workload. Named distinctly from interfaces.ResourceSpec which is used for IaC infrastructure resources.\n\n","path":"github.com/GoCodeAlone/workflow/interfaces","name":"interfaces","synopsis":"Package interfaces defines shared interface types used across the workflow engine, handlers, and module packages.","isRedistributable":true}
