compiler

package
v0.0.53 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: Apache-2.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CellRecipeDirectory = ".c2j/recipes"
	DefaultRecipeName   = "default"
	DefaultRecipeRef    = "main"
)
View Source
const RootSourceResolutionTaskType = "recipe_root_source_resolve"
View Source
const WithinRecipeResolutionTaskType = "recipe_within_resolution"

Variables

This section is empty.

Functions

func BuildCellRecipeSelector

func BuildCellRecipeSelector(repositorySource string, recipeName string, ref string) (string, error)

func ExecuteRecipe

func ExecuteRecipe(ctx workflow.Context, r recipe.Recipe, rawRecipeInputs map[string]interface{}, execCtx contextual.JobContext, commitContext contextual.GitCommitContext, opts ...ExecutionOptions) (map[string]interface{}, []jobdb.Artifact, error)

ExecuteRecipe keeps the existing public entry point, delegating to the default executor.

func ExecuteRecipeWithExecutor

func ExecuteRecipeWithExecutor(exec RecipeExecutor, ctx workflow.Context, r recipe.Recipe, rawRecipeInputs map[string]interface{}, execCtx contextual.JobContext, commitContext contextual.GitCommitContext, opts ...ExecutionOptions) (map[string]interface{}, []jobdb.Artifact, error)

ExecuteRecipeWithExecutor allows callers to run with a custom executor (e.g., decorator).

func IsCellRecipeName

func IsCellRecipeName(value string) bool

func IsGitRecipeSelector

func IsGitRecipeSelector(selector string) bool

func IsLocalRecipeFileReference

func IsLocalRecipeFileReference(value string) bool

func NewRecipeWorker

func NewRecipeWorker(dependencies ops.ServiceDependencies2, activityRegistry *workerops.ActivityRegistry, provider ...template.CELOptionsProvider) (*jobworkflow.WorkSet, error)

func NewRecipeWorkerWithOptions

func NewRecipeWorkerWithOptions(dependencies ops.ServiceDependencies2, activityRegistry *workerops.ActivityRegistry, opts RecipeJobWorkerOptions) (*jobworkflow.WorkSet, error)

func NormalizeGitRepositorySource

func NormalizeGitRepositorySource(source string) (string, error)

func RepositoryNameFromSource

func RepositoryNameFromSource(source string) string

func ValidateRecipeSelector

func ValidateRecipeSelector(selector string) error

Types

type CELVariables

type CELVariables struct {
	Outputs map[string]interface{}            `json:"Outputs"`
	State   *StateInfo                        `json:"State"`
	States  map[string]map[string]interface{} `json:"States"`
	Inputs  map[string]interface{}            `json:"ContainerInputs"`
	Context *RecipeContext                    `json:"Context"`
	Steps   map[string]interface{}            `json:"Steps"` // Access to step outputs within current state
}

CELVariables represents the variables available in CEL expressions

type DefaultRecipeExecutor

type DefaultRecipeExecutor struct {
	// contains filtered or unexported fields
}

DefaultRecipeExecutor preserves the existing execution behavior, with optional CEL provider injection.

func NewDefaultRecipeExecutor

func NewDefaultRecipeExecutor(provider template.CELOptionsProvider) DefaultRecipeExecutor

NewDefaultRecipeExecutor builds an executor with a default CEL provider.

func (DefaultRecipeExecutor) ExecuteChildGroup added in v0.0.24

func (DefaultRecipeExecutor) ExecuteNode

func (d DefaultRecipeExecutor) ExecuteNode(ctx workflow.Context, parentResCtx *template.ResolutionContext, n *recipe.Node) error

ExecuteWorkflow implements the WorkflowExecutor interface for unified recipes

func (DefaultRecipeExecutor) ExecuteOp

func (d DefaultRecipeExecutor) ExecuteOp(ctx workflow.Context, parentResolutionContext *template.ResolutionContext, metadata recipe.NodeMetadata, op string) error

func (DefaultRecipeExecutor) ExecuteRecipe

func (d DefaultRecipeExecutor) ExecuteRecipe(ctx workflow.Context, r recipe.Recipe, rawRecipeInputs map[string]interface{}, execCtx contextual.JobContext, commitContext contextual.GitCommitContext, opts ...ExecutionOptions) (map[string]interface{}, []jobdb.Artifact, error)

func (DefaultRecipeExecutor) ExecuteSequence

func (d DefaultRecipeExecutor) ExecuteSequence(ctx workflow.Context, rCtx *template.ResolutionContext, metadata recipe.NodeMetadata, outputTemplate map[string]interface{}, sequence []recipe.Node) error

func (DefaultRecipeExecutor) ExecuteStateMachine

func (d DefaultRecipeExecutor) ExecuteStateMachine(ctx workflow.Context, parentContext *template.ResolutionContext, metadata recipe.NodeMetadata, outputTemplate map[string]interface{}, stateMap *recipe.StateMap, opts ...ExecutionOptions) error

ExecuteStateMachine runs the state machine with the new StateMap format

func (DefaultRecipeExecutor) WithDelegate

WithDelegate returns a copy of the executor that will dispatch recursive executor calls (ExecuteNode/ExecuteSequence/ExecuteStateMachine/ExecuteOp) to the provided delegate. This allows decorators to wrap the default executor without reimplementing execution logic.

type EnvironmentInfo

type EnvironmentInfo struct {
	Name   string `json:"name"`
	Region string `json:"region"`
}

EnvironmentInfo contains environment context

type ExecutionHandoff added in v0.0.52

type ExecutionHandoff struct {
	Kind       string               `json:"kind"`
	JobKey     jobdb.JobKey         `json:"job"`
	Demand     execution.Demand     `json:"demand"`
	Allocation execution.Allocation `json:"allocation"`
	Mismatches []execution.Mismatch `json:"mismatches,omitempty"`
	Published  bool                 `json:"published"`
}

type ExecutionInfo

type ExecutionInfo struct {
	StartedAt time.Time     `json:"started_at"`
	Timeout   time.Duration `json:"timeout"`
}

ExecutionInfo contains execution context

type ExecutionMode

type ExecutionMode string
const (
	ExecutionModeRun      ExecutionMode = "run"
	ExecutionModeValidate ExecutionMode = "validate"
)

type ExecutionOptions

type ExecutionOptions struct {
	Mode       ExecutionMode
	Validation ValidationOptions
	// Optional CEL options provider to inject extra functions/types.
	CELOptionsProvider  template.CELOptionsProvider
	StateObserver       StateObserver
	DiagnosticsObserver template.DiagnosticsObserver
	// ResolvedSelectors carries internal selector pins for the current recipe run.
	ResolvedSelectors map[string]string
	// ResolvedGitRefs carries internal repo/ref pins for the current recipe run.
	ResolvedGitRefs map[string]string
}

type InlineResolutionOptions added in v0.0.29

type InlineResolutionOptions struct {
	ProjectID  string
	RootFile   string
	WorkingDir string
	Resolver   RecipeSourceResolver
	RootSource *RecipeSourceResolution
}

type InlineResolutionResult added in v0.0.29

type InlineResolutionResult struct {
	Recipe recipe.Recipe
}

func ResolveInlineRecipes added in v0.0.29

func ResolveInlineRecipes(ctx context.Context, rec recipe.Recipe, opts InlineResolutionOptions) (InlineResolutionResult, error)

type NoOpStateObserver

type NoOpStateObserver struct{}

func (NoOpStateObserver) StateEntered

func (NoOpStateObserver) StateEntered(stateName string)

func (NoOpStateObserver) StateExited

func (NoOpStateObserver) StateExited(stateName string)

func (NoOpStateObserver) TransitionEvalauted

func (NoOpStateObserver) TransitionEvalauted(expression string, result bool, nextStateIfExpressionTrue string)

type NormalizedOpInput

type NormalizedOpInput struct {
	Data               map[string]interface{}
	StoredArtifactKeys []jobdb.ArtifactKey
}

func NormalizeOpInput

func NormalizeOpInput(inputType reflect.Type, raw map[string]interface{}) (NormalizedOpInput, error)

type RecipeContext

type RecipeContext struct {
	Recipe      RecipeInfo      `json:"recipe"`
	Environment EnvironmentInfo `json:"environment"`
	Execution   ExecutionInfo   `json:"execution"`
}

RecipeContext contains system-provided context variables

type RecipeExecutor

type RecipeExecutor interface {
	ExecuteRecipe(ctx workflow.Context, r recipe.Recipe, rawRecipeInputs map[string]interface{}, execCtx contextual.JobContext, commitContext contextual.GitCommitContext, opts ...ExecutionOptions) (map[string]interface{}, []jobdb.Artifact, error)
	ExecuteNode(ctx workflow.Context, parentResCtx *template.ResolutionContext, n *recipe.Node) error
	ExecuteStateMachine(ctx workflow.Context, parentContext *template.ResolutionContext, metadata recipe.NodeMetadata, outputTemplate map[string]interface{}, stateMap *recipe.StateMap, opts ...ExecutionOptions) error
	ExecuteOp(ctx workflow.Context, parentResolutionContext *template.ResolutionContext, metadata recipe.NodeMetadata, op string) error
	ExecuteChildGroup(ctx workflow.Context, parent *template.ResolutionContext, metadata recipe.NodeMetadata, group recipe.ChildGroupData) error
	ExecuteSequence(ctx workflow.Context, rCtx *template.ResolutionContext, metadata recipe.NodeMetadata, outputTemplate map[string]interface{}, sequence []recipe.Node) error
}

RecipeExecutor defines the surface area for executing recipes, states, and ops. This enables decorator implementations (e.g., analysis) without changing call sites.

type RecipeInfo

type RecipeInfo struct {
	Name        string `json:"name"`
	Version     string `json:"version"`
	ExecutionID string `json:"execution_id"`
}

RecipeInfo contains information about the current recipe

type RecipeJobWorkerOptions

type RecipeJobWorkerOptions struct {
	Allocation         execution.Allocation
	ReadOnlyReplay     bool
	OnExecutionHandoff func(ExecutionHandoff)
	StageExecution     func(jobdb.JobKey, execution.Demand)
	WrapTaskWorker     func(jobworkflow.TaskWorker) jobworkflow.TaskWorker
	CELOptionsProvider template.CELOptionsProvider

	// Executor overrides recipe execution for instrumentation. When nil, DefaultRecipeExecutor is used.
	Executor RecipeExecutor
	// ExecutorFactory overrides Executor when provided, allowing per-run executors.
	ExecutorFactory func() RecipeExecutor

	// RootSourceResolver resolves non-embedded root recipe selectors at execution time.
	RootSourceResolver RecipeSourceResolver

	// OnRecipeLoaded is called after the recipe artifact has been loaded and parsed.
	OnRecipeLoaded func(recipeName string)
	// OnRecipeSourceResolved is called after the root recipe source has been resolved.
	OnRecipeSourceResolved func(RecipeSourceResolution)
}

type RecipeRefResolver

type RecipeRefResolver interface {
	ResolveRecipeRef(ctx context.Context, projectID string, selector string) (RecipeSourceResolution, error)
	LoadRecipeRef(ctx context.Context, projectID string, selector string) (*recipe.Recipe, error)
}

func NewProviderBackedRecipeRefResolver

func NewProviderBackedRecipeRefResolver(provider func(projectID string, recipeRef string) (*recipe.Recipe, error)) RecipeRefResolver

type RecipeRefYAMLLoader

type RecipeRefYAMLLoader interface {
	LoadRecipeRefYAML(ctx context.Context, projectID string, selector string) ([]byte, error)
}

type RecipeSourceKind

type RecipeSourceKind string
const (
	RecipeSourceKindArtifact  RecipeSourceKind = "artifact"
	RecipeSourceKindServerRef RecipeSourceKind = "serverRef"
	RecipeSourceKindGit       RecipeSourceKind = "git"
)

type RecipeSourceResolution

type RecipeSourceResolution struct {
	SourceKind        RecipeSourceKind `json:"source_kind"`
	SubmittedSelector string           `json:"submitted_selector"`
	ResolvedSelector  string           `json:"resolved_selector,omitempty"`
	ResolvedCommit    string           `json:"resolved_commit,omitempty"`
	ArtifactName      string           `json:"artifact_name,omitempty"`
	WasAlreadyPinned  bool             `json:"was_already_pinned"`
}

func (RecipeSourceResolution) EffectiveSelector

func (r RecipeSourceResolution) EffectiveSelector() string

type RecipeSourceResolver

type RecipeSourceResolver interface {
	Resolve(ctx context.Context, projectID string, selector string) (RecipeSourceResolution, error)
	Load(ctx context.Context, projectID string, resolution RecipeSourceResolution) (recipe.Recipe, error)
}

type RecipeSourceResolverOptions

type RecipeSourceResolverOptions struct {
	// GitRepository is retained for API compatibility. Git selectors are
	// resolved through SelectorCache so extension and recipe sources share one
	// materialization path.
	GitRepository     gitpkg.Repository
	SelectorCache     *selectorcache.Cache
	RecipeRefResolver RecipeRefResolver
}

type RecipeSourceYAMLLoader

type RecipeSourceYAMLLoader interface {
	LoadYAML(ctx context.Context, projectID string, resolution RecipeSourceResolution) ([]byte, error)
}

type ResolvedRecipeSource

type ResolvedRecipeSource struct {
	RecipeSourceResolution
	RecipeYAML string `json:"recipe_yaml,omitempty"`
}

func ParseResolvedRecipeSourceJSON

func ParseResolvedRecipeSourceJSON(raw []byte) (*ResolvedRecipeSource, error)

func ParseResolvedRecipeSourceTaskData

func ParseResolvedRecipeSourceTaskData(td jobdb.TaskData) (*ResolvedRecipeSource, error)

func (ResolvedRecipeSource) LoadRecipe

func (r ResolvedRecipeSource) LoadRecipe() (recipe.Recipe, error)

type ScopedContext

type ScopedContext struct {
	// Parent scope (nil for root)
	Parent *ScopedContext

	// Local step outputs for this scope only
	LocalStepOutputs map[string]interface{}

	// Reference to the global state context
	StateContext *StateContext

	// Scope identifier for debugging
	ScopeID string
}

ScopedContext represents an isolated execution context for nested compositions

func NewScopedContext

func NewScopedContext(parent *ScopedContext, stateCtx *StateContext, scopeID string) *ScopedContext

NewScopedContext creates a new scoped context

func (*ScopedContext) GetCELVariables

func (sc *ScopedContext) GetCELVariables(currentOutputs map[string]interface{}) map[string]interface{}

GetCELVariables prepares variables for CEL evaluation with proper scoping

func (*ScopedContext) GetStepOutput

func (sc *ScopedContext) GetStepOutput(stepID string) (interface{}, bool)

GetStepOutput retrieves a step output from the current scope only

func (*ScopedContext) GetTemplateData

func (sc *ScopedContext) GetTemplateData() map[string]interface{}

GetTemplateData prepares template data with proper scoping

func (*ScopedContext) MergeOutputs

func (sc *ScopedContext) MergeOutputs() map[string]interface{}

MergeOutputs merges the outputs from a nested scope back to parent This is used when a nested composition completes

func (*ScopedContext) SetStepOutput

func (sc *ScopedContext) SetStepOutput(stepID string, output interface{})

SetStepOutput sets a step output in the current scope

type StateContext

type StateContext struct {
	CurrentState  string                            `json:"current_state"`
	Inputs        map[string]interface{}            `json:"inputs"`
	StateOutputs  map[string]map[string]interface{} `json:"state_outputs"`
	Attempts      map[string]int                    `json:"attempts"`
	StateInfo     map[string]*StateInfo             `json:"state_info"`
	RecipeContext *RecipeContext                    `json:"recipe_context,omitempty"`
	StepOutputs   map[string]interface{}            `json:"step_outputs"` // Track step outputs within current state
}

StateContext maintains the runtime context for state machine execution

type StateInfo

type StateInfo struct {
	Name      string    `json:"name"`
	Attempts  int       `json:"attempts"`
	EnteredAt time.Time `json:"entered_at"`
}

StateInfo tracks metadata for each state

type StateObserver

type StateObserver interface {
	StateEntered(stateName string)
	StateExited(stateName string)
	TransitionEvalauted(expression string, result bool, nextStateIfExpressionTrue string)
}

type StepResult

type StepResult struct {
	Outputs map[string]interface{}
}

StepResult stores the result of a workflow step

type TransitionSelectionObserver added in v0.0.11

type TransitionSelectionObserver interface {
	TransitionSelected(fromState string, toState string, payload map[string]interface{})
}

type ValidationMode

type ValidationMode string
const (
	ValidateAll      ValidationMode = "all"
	ValidatePathOnly ValidationMode = "path_only"
)

type ValidationOptions

type ValidationOptions struct {
	Mode       ValidationMode
	CollectAll bool
}

type WithinRecipeResolutionResult

type WithinRecipeResolutionResult struct {
	ResolvedSelectors map[string]string `json:"resolved_selectors,omitempty"`
	ResolvedGitRefs   map[string]string `json:"resolved_git_refs,omitempty"`
}

func ParseWithinRecipeResolutionJSON

func ParseWithinRecipeResolutionJSON(raw []byte) (*WithinRecipeResolutionResult, error)

func ParseWithinRecipeResolutionTaskData

func ParseWithinRecipeResolutionTaskData(td jobdb.TaskData) (*WithinRecipeResolutionResult, error)

Jump to

Keyboard shortcuts

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