workflow

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package workflow builds native xyOps workflows: a validated graph (NewXyopsWorkflow) and the plan -> changes? -> approval -> deploy pipeline (NewPipeline). xyOps owns orchestration, Resume authorization and audit.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Approval

type Approval struct {
	// ReviewInput is an optional top-level input.data key containing a safe,
	// human-readable plan. Show it in the native Resume dialog, not in logs
	// or notification text. This field is for display, never deploy authority.
	ReviewInput string
	// WebHook is fired when the run reaches approval (optional).
	WebHook string
	// Text is shown with the suspension and sent with the notification.
	Text string
}

Approval configures an approval step.

type EntryProps

type EntryProps struct {
	Category, Executor    string
	Trigger               xyops.Trigger
	WorkflowDeploy, Body  xyops.EventRef
	TimeoutSeconds, Queue int
	AlertWebHook          string
}

EntryProps declares the admission-facing graph, not an extra step in Body. Install in an independently bootstrapped stack. WorkflowDeploy must check a trusted receipt and reconcile ONLY the admitted owner's definition bundle. A manual trigger needed for sub-workflow invocation is not an auth policy: OIDC-only handlers must also verify authoritative upstream job linkage.

type Pipeline

type Pipeline struct {
	Workflow *XyopsWorkflow
	// Steps maps step ID to the event it runs (owned or referenced).
	Steps map[string]xyops.EventRef
	// Owned maps step ID to events this pipeline created (tasks, approvals).
	Owned map[string]*xyops.Event
}

Pipeline is a native workflow and the events its steps run.

func NewEntry

func NewEntry(s *core.Stack, id string, p EntryProps) (*Pipeline, error)

NewEntry installs one visible success-only sequence at the trigger boundary. Child workflows used inside Body do not get recursively wrapped. Keep credentials on scoped workers, not on the entry or its caller. References are stable IDs: do not cross-link Terraform resources in different states.

func NewEntryWithParams

func NewEntryWithParams(s *core.Stack, id string, p EntryProps, inputs map[string]map[string]string) (*Pipeline, error)

NewEntryWithParams sets reviewed node parameters on the same admission graph as NewEntry. Only the definitions and release edges accept parameters.

func NewPipeline

func NewPipeline(stack *core.Stack, name string, p PipelineProps) (*Pipeline, error)

NewPipeline creates the workflow and the events its owned steps run. The workflow ID and every owned event ID are claimed app-wide: a collision with another event, workflow or pipeline in the app fails synthesis, and a refusal leaves no partial resources.

func NewPipelineWithParams

func NewPipelineWithParams(stack *core.Stack, name string, p PipelineProps, inputs map[string]map[string]string) (*Pipeline, error)

NewPipelineWithParams is NewPipeline with literal, platform-authored input parameters on referenced event nodes. These are not an authorization channel. The separate map preserves the original Step and PipelineProps API/layout.

func NewScopedEntry

func NewScopedEntry(s *core.Stack, id string, p EntryProps, handler string) (*Pipeline, error)

NewScopedEntry bootstraps an entry with its own definitions worker. There is one lease: the entry holds its slot across both the worker and the body, including suspended approvals. There is no global workflow-deploy queue. The handler must accept only authenticated scheduler evidence. Do not grant the worker any of the global definition installer's credentials.

type PipelineProps

type PipelineProps struct {
	// ID names the workflow; owned steps are ID_<step>. Every title is
	// "<stack>-<id>" (xyops.Title).
	ID, Category string
	// Executor runs every owned step.
	Executor string
	Enabled  bool
	Trigger  xyops.Trigger
	Fields   []xyops.Field
	// Steps run in order. At least one; a gate may not be first or last.
	Steps           []Step
	MaxRuns         int
	StepConcurrency int
	// Queue holds up to this many further runs (FIFO, native xyOps queue) while
	// MaxRuns are in progress, for up to TimeoutSeconds. 0 = refuse them.
	// A queued run starts nothing (no step, no credentials) until it starts.
	Queue          int
	TimeoutSeconds int
	AlertWebHook   string
}

PipelineProps defines native xyOps orchestration, not an independent approval service: xyOps permissions authorize Resume and its audit log records it. Handlers must enforce pinned intent, expiry, replay protection and disruption guards themselves; a graph is not that policy.

Concurrency has separate controls:

  • MaxRuns / Queue: concurrent and waiting runs of the workflow. A run holds its slot until it finishes, including while an approval is suspended.
  • StepConcurrency: job limit on events this pipeline owns (default MaxRuns). Referenced events keep the limits their owner declared.
  • Target locking (two runs mutating the same infrastructure) belongs to the handlers: the graph cannot know which runs touch the same targets.

type ScopedReleaseProps

type ScopedReleaseProps struct {
	ServiceReleaseProps
	Reconcile                string
	EntryTimeout, EntryQueue int
}

ScopedReleaseProps is the single-stack first-install path. Existing entries in a separate bootstrap state use NewScopedEntry to retain their addresses.

type ServiceRelease

type ServiceRelease struct {
	*Pipeline
	Entry   *Pipeline // populated by NewScopedRelease only
	Intake  *xyops.Event
	Workers []*xyops.Event // excludes intake and approval
	State   *xyops.Secret  // dedicated state identity; provisioned out of band
}

func NewScopedRelease

func NewScopedRelease(s *core.Stack, p ScopedReleaseProps) (*ServiceRelease, error)

NewScopedRelease creates body and owned workers first, then the stable entry, then the intake whose success action references that entry. All are managed in this stack, with explicit provider dependencies; no pre-existing body or externally created intake target is assumed.

func NewServiceRelease

func NewServiceRelease(s *core.Stack, p ServiceReleaseProps) (*ServiceRelease, error)

type ServiceReleaseProps

type ServiceReleaseProps struct {
	Body, Entry, Category, Executor string
	StateVault, StateNotes          string
	Steps                           []Step
	Queue, Timeout                  int
	AlertHook                       string

	Intake xyops.EventProps
	Vaults []string // dedicated site-owned vault IDs; values are enrolled out of band
}

ServiceReleaseProps is trusted installation policy, never execution data from a caller. Ordered steps are trusted implementations; application manifests cannot grant state or weaken approval policy. A per-pipeline state vault is mandatory.

type Step

type Step struct {
	// ID names the node; owned events are "<pipeline ID>_<ID>".
	ID string
	// Exactly one of Script (Task), Event (Run), Approval or Gate.
	Script         string
	TimeoutSeconds int
	Event          *xyops.EventRef
	Approval       *Approval
	Gate           string
	// Label shown on the node; defaults to ID ("<ID>?" for gates).
	Label string
}

A pipeline is an ordered list of steps run in series on one native xyOps workflow. Each step is wired to the next on success; a Gate ends the run when its condition is false. Steps:

  • Task: an event the pipeline owns, "<pipeline ID>_<step>", running a reviewed script on the pipeline's Executor.
  • Run: an existing event or workflow (event.Ref(), XyopsWorkflow.Ref() or xyops.ExternalEvent). A workflow runs as a sub-workflow: the run waits for it and keeps its slot. The pipeline never creates or changes it.
  • Approval: an owned no-op event that, at start, notifies a web hook and suspends until an authorized user resumes it (Abort declines). Insert it only where a human must decide.
  • Gate: a decision on the previous step's output data (xyOps expression, e.g. "data.changes == true"). False ends the run.

Starting a workflow that must run independently (its own queue and approvals) is not a step: use xyops.EventProps.OnSuccess on the launching event.

func ApprovalStep

func ApprovalStep(id, webHook string) Step

ApprovalStep is a human decision point: notify, then suspend until Resume.

func Gate

func Gate(id, expression string) Step

Gate continues only when expression holds on the previous step's output.

func Run

func Run(id string, ref xyops.EventRef) Step

Run is a step running an existing event, or a workflow as a sub-workflow.

func Task

func Task(id, script string, timeoutSeconds int) Step

Task is an owned step running script (a reviewed control-plane handler).

type XyopsConnection

type XyopsConnection struct {
	ID        string `json:"id"`
	Source    string `json:"source"`
	Dest      string `json:"dest"`
	Condition string `json:"condition,omitempty"`
}

XyopsConnection preserves native routing conditions.

type XyopsNode

type XyopsNode struct {
	ID   string         `json:"id"`
	Type string         `json:"type"`
	X    int            `json:"x"`
	Y    int            `json:"y"`
	Data map[string]any `json:"data,omitempty"`
}

XyopsNode is a native xyOps node. Data is backend-owned JSON, not a CDK deployment vocabulary. Action/limit nodes attach to jobs, not sequential steps.

type XyopsWorkflow

type XyopsWorkflow struct {
	Resource *core.Resource
	// contains filtered or unexported fields
}

XyopsWorkflow is a provider-backed workflow definition, installed when its containing stack is applied (including bootstrap). Construction never runs it.

func NewXyopsWorkflow

func NewXyopsWorkflow(stack *core.Stack, name string, p XyopsWorkflowProps) (*XyopsWorkflow, error)

NewXyopsWorkflow validates and synthesizes a native workflow resource using attributes available since provider 0.1.2-dev.8. Require xyops.Provider on stack. Native loops are allowed. Use an explicit join controller for all-of fan-in.

func (*XyopsWorkflow) Ref

func (w *XyopsWorkflow) Ref() xyops.EventRef

Ref returns a reference for launching this workflow (for example from an event's OnSuccess). The workflow resource is a dependency of the launcher.

type XyopsWorkflowProps

type XyopsWorkflowProps struct {
	ID          string
	Title       string
	Category    string
	Enabled     bool
	Nodes       []XyopsNode
	Connections []XyopsConnection
	Triggers    []map[string]any
	Actions     []map[string]any
	Limits      []map[string]any
	Tags        []string
	Import      bool
	Params      map[string]any
	Fields      []map[string]any
	Notes       *string
	Icon        *string
}

XyopsWorkflowProps maps the existing xyops_workflow provider resource. No runtime approval or deployment-safety guarantee is inferred from a graph. Optional metadata and runtime input fields require provider 0.1.2-dev.8 or later.

Jump to

Keyboard shortcuts

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