Help us shape the future of Go! Take the 2026 Go Developer Survey

engine

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0, MIT Imports: 46 Imported by: 0

Documentation

Overview

Package engine orchestrates locked preparation and independent destination reconciliation.

Index

Constants

This section is empty.

Variables

View Source
var ErrPluginsFailed = errors.New("plugins failed")

ErrPluginsFailed reports that a plugin report holds a plugin that did not load or offers operations this Stemma cannot use; the report says which.

Functions

func BuiltinSchema added in v0.3.0

func BuiltinSchema() ([]byte, error)

BuiltinSchema describes built-in operations without loading a project or plugins.

func ProjectSchema added in v0.2.0

func ProjectSchema(ctx context.Context, opts Options) (result []byte, err error)

ProjectSchema describes operations without acquiring software inputs or contacting destinations. Offline requires plugins the cache already holds.

func ReadMember added in v0.11.0

func ReadMember(ctx context.Context, name, member string, w io.Writer) (err error)

ReadMember writes one file inside a local artifact to w, or the names a directory inside it holds.

func Unreported added in v0.4.0

func Unreported(err error) error

Unreported is the part of a run's error that its report does not carry with a resource, or nil. Joined errors are split; a wrapped error keeps its context whole.

func ValidateProject added in v0.2.0

func ValidateProject(ctx context.Context, opts Options, resolved bool) (result config.Project, err error)

ValidateProject checks the catalog as written: declared fields, expressions, operation contracts and the resource and publication graphs. It reads no environment values. Settings, inputs and metadata that hold expressions are checked by schema, and their values when a command uses them. Resolved validation evaluates everything a run would and returns the project with its connection settings evaluated.

Types

type Candidate added in v0.3.0

type Candidate struct {
	// Lock is the reviewed lockfile the catalog was resolved against.
	Lock lockfile.File `json:"lock"`
	// Plugins are the locked plugin entries whose code performed the resolution.
	Plugins   map[string]plugins.Entry     `json:"plugins,omitempty"`
	Resources map[string]CandidateResource `json:"resources"`
}

Candidate is one whole-catalog resolution held in memory. Callers decide which resources become lockfile changes; Resolve never writes the lockfile.

func Resolve added in v0.3.0

func Resolve(ctx context.Context, opts Options) (candidate Candidate, runErr error)

Resolve observes every declared input of the catalog once and reports each resource independently, so one unreachable source cannot hide the others. ResourceDone receives each resource's input changes as it finishes. Plugins load from the lockfile: their code runs before anything is observed.

func (Candidate) Dependents added in v0.3.0

func (c Candidate) Dependents(key string) []string

Dependents returns every resource that transitively consumes key's outputs. Skipped consumers are left out: nothing implicit ever runs them.

type CandidateResource added in v0.3.0

type CandidateResource struct {
	Name      string                  `json:"name"`
	Kind      string                  `json:"kind"`
	Inputs    map[string]source.Entry `json:"inputs,omitempty"`
	Producers []string                `json:"producers,omitempty"`
	// Skipped marks a resource the resolution left out: a suspended one, or a
	// profiled one that nothing it resolved consumes. Its lock entries stay as
	// they are.
	Skipped   bool     `json:"skipped,omitempty"`
	Error     string   `json:"error,omitempty"`
	BlockedBy []string `json:"blocked_by,omitempty"`
}

CandidateResource reports one resource's current inputs, or why they could not be observed, alongside the resources whose outputs it consumes.

type Contracts added in v0.4.0

type Contracts struct {
	Project    string
	Components map[string]map[string]any
	// Destinations name the operation behind each destination connection.
	Destinations map[string]string
	Operations   []plugin.Operation
	// Unavailable explains each plugin that did not load and each operation
	// offered at another interface version.
	Unavailable []string
}

Contracts are what a project can declare: its components and destination connections, and the operations Stemma and its plugins provide.

func ProjectContracts added in v0.4.0

func ProjectContracts(ctx context.Context, opts Options) (result Contracts, err error)

ProjectContracts describes what a project can declare from its project document alone, so resource documents that do not load yet leave it describable. A plugin that does not load is reported beside the operations that did. Plugin discovery executes code.

type DestinationReport

type DestinationReport struct {
	Artifact string            `json:"artifact,omitempty"`
	Name     string            `json:"name"`
	Origins  map[string]string `json:"origins,omitempty"`
	Changes  []plugin.Change   `json:"changes"`
	Applied  bool              `json:"reconciled"`
	Error    string            `json:"error,omitempty"`
}

DestinationReport describes semantic drift independently of cache hits.

func (DestinationReport) MarshalJSON added in v0.10.0

func (r DestinationReport) MarshalJSON() ([]byte, error)

MarshalJSON distinguishes planned drift, successful reconciliation and failure.

type IconOptions added in v0.3.0

type IconOptions struct {
	// Force replaces assets that already exist.
	Force bool
	// Size is the glassy edge in pixels; zero selects icon.Size.
	Size int
	// Presentation styles the artwork; icon.Auto follows the host.
	Presentation icon.Presentation
	// From is a local application, installer or artwork file that supplies one
	// resource's artwork in place of the software the resource prepares.
	From string
}

IconOptions configures the icon method, which extracts the artwork prepared software carries and presents it as the declared asset.

type InputSelection added in v0.9.1

type InputSelection struct {
	Name string
	Path string
}

InputSelection identifies a named input and an optional path within it.

type Inspection added in v0.4.0

type Inspection struct {
	Filename string       `json:"filename"`
	Format   string       `json:"format"`
	Version  string       `json:"version,omitempty"`
	Facts    plugin.Facts `json:"facts"`
}

Inspection describes a local file or directory by its own metadata.

func Inspect

func Inspect(ctx context.Context, name, selection string) (result Inspection, err error)

Inspect inventories a local artifact using the same facts as input expressions.

type LockComparison added in v0.11.0

type LockComparison struct {
	Compared   int
	Unresolved []string
}

LockComparison is what a lock comparison covered: the number of inputs whose entry it compared with their declaration, and each input it could not compare, as Kind/name and the input's name. Those declarations read environment values, which resolved validation and runs evaluate.

type Options

type Options struct {
	ConfigPath, CacheDir string
	// GitHubToken authenticates release lookups of GitHub sources that declare
	// no token.
	GitHubToken string
	Method      string
	Resources   []string
	// Profiles selects the resources declaring any of these profiles, in place
	// of the resources that declare none. A run names profiles or Resources.
	Profiles []string
	// ChangedSince narrows prepare to the resources whose preparation differs
	// from the catalog at this Git revision, after checking the lockfile's
	// shape.
	ChangedSince string
	Lock         lockfile.Options
	Icons        IconOptions
	// Input selects artwork or facts without building the selected resource.
	Input InputSelection
	// Output names the resource output the artifact method materializes;
	// empty selects installer.
	Output string
	// OutputFile exports the selected artifact outside the disposable cache.
	OutputFile string
	// Read names a file inside the selected artifact or input. The artifact
	// and inspect methods write it to ReadTo in place of their own result.
	Read     string
	ReadTo   io.Writer
	Handlers map[string]reconcileHandler
	// ResourceDone receives each final resource result, including failures.
	ResourceDone func(ResourceReport) error
	// Compared, when set, has validation also compare the reviewed lock with
	// every declaration and report what that covered.
	Compared *LockComparison
}

Options configures one finite execution of the CLI.

type PluginOperation added in v0.4.0

type PluginOperation struct {
	Name     string               `json:"name"`
	Kind     string               `json:"kind"`
	Resource *plugin.ResourceKind `json:"resource,omitempty"`
}

PluginOperation identifies an operation a plugin offers.

type PluginReport added in v0.4.0

type PluginReport struct {
	Name  string `json:"name"`
	Image string `json:"image,omitempty"`
	Path  string `json:"path,omitempty"`
	// Digest names the code: the platform index of an image or the content of
	// local files. Locked reports that it comes from the lockfile rather than
	// the declaration.
	Digest string `json:"digest,omitempty"`
	Locked bool   `json:"locked,omitempty"`
	Status string `json:"status,omitempty"`
	// Before is the digest the lockfile held before an update.
	Before      string               `json:"before,omitempty"`
	Version     string               `json:"version,omitempty"`
	Revision    string               `json:"revision,omitempty"`
	Interfaces  map[string]int       `json:"interfaces,omitempty"`
	Platforms   []string             `json:"platforms,omitempty"`
	Operations  []PluginOperation    `json:"operations,omitempty"`
	Unavailable []plugin.Unavailable `json:"unavailable,omitempty"`
	Error       string               `json:"error,omitempty"`
}

PluginReport describes a declared plugin: the code its declaration and lock entry select, what it offers, and what it cannot.

func InspectPlugins added in v0.10.0

func InspectPlugins(ctx context.Context, opts Options, verify bool) ([]PluginReport, error)

InspectPlugins loads every declared plugin from its lock entry, as runs do, and reports each one. With verify, an installed plugin that differs from its pinned files fails to load. It returns ErrPluginsFailed when a report holds a failure.

func ListPlugins added in v0.4.0

func ListPlugins(ctx context.Context, configPath string) ([]PluginReport, error)

ListPlugins reads declarations and recorded pins without acquiring or executing plugin code. A recorded pin does not verify local file contents.

type PluginUpdate added in v0.4.0

type PluginUpdate struct {
	Plugins     []PluginReport `json:"plugins"`
	Removed     []string       `json:"removed,omitempty"`
	LockChanged bool           `json:"lock_changed"`
}

PluginUpdate reports what plugins update locked. Removed names the entries of plugins no longer declared.

func UpdatePlugins added in v0.4.0

func UpdatePlugins(ctx context.Context, opts Options, names []string) (update PluginUpdate, err error)

UpdatePlugins locks the named plugins, or every declared plugin, to what their declarations select now: a tag is resolved again and a local path snapshotted. Each plugin is described first; one that does not load keeps its entry. Entries of plugins no longer declared are removed. It returns ErrPluginsFailed when a report holds a failure.

type Prepared

type Prepared struct {
	InputsHash    string                     `json:"inputs_hash,omitempty"`
	Payload       cas.Ref                    `json:"payload"`
	Filename      string                     `json:"filename"`
	Format        string                     `json:"format"`
	Version       string                     `json:"version,omitempty"`
	ContentRoot   string                     `json:"content_root,omitempty"`
	Tree          bool                       `json:"tree,omitempty"`
	Facts         plugin.Facts               `json:"facts"`
	SuppliedFacts bool                       `json:"supplied_facts,omitempty"`
	Evidence      map[string]json.RawMessage `json:"evidence,omitempty"`
	EntryPoint    string                     `json:"entry_point,omitempty"`
	Mode          uint32                     `json:"mode,omitempty"`
	Cached        bool                       `json:"cached"`
	Path          string                     `json:"-"`
}

Prepared preserves the original source alongside selected payloads and verification evidence.

type Publication added in v0.11.0

type Publication struct {
	Destination string            `json:"destination"`
	Metadata    json.RawMessage   `json:"metadata,omitempty"`
	Origins     map[string]string `json:"origins,omitempty"`
	Deferred    string            `json:"deferred,omitempty"`
}

Publication reports managed metadata without reading destination state. Deferred says why Metadata is absent.

type Report

type Report struct {
	// LockChanged reports whether update wrote the lockfile.
	LockChanged *bool `json:"lock_changed,omitempty"`
	// RemovedInputs are lock entries of resources the catalog no longer declares.
	RemovedInputs []lockfile.InputChange `json:"removed_inputs,omitempty"`
	// Plugins are the plugin lock entries an update changed.
	Plugins   []lockfile.PluginChange `json:"plugins,omitempty"`
	Warnings  []string                `json:"warnings,omitempty"`
	Summary   Summary                 `json:"summary"`
	Error     string                  `json:"error,omitempty"`
	Resources []ResourceReport        `json:"resources"`
	// Artifact is where the artifact method materialized the selected output.
	Artifact string `json:"artifact,omitempty"`
	// Inspection is the static evidence of the selected resource input.
	Inspection *Inspection `json:"inspection,omitempty"`
}

Report distinguishes source, preparation and each destination's work.

func Run

func Run(ctx context.Context, opts Options) (report Report, runErr error)

Run resolves locked resources in dependency order and reconciles destinations independently.

func (*Report) Summarize added in v0.4.0

func (r *Report) Summarize(method string)

Summarize records totals before any presentation filter is applied.

type ResourceError added in v0.4.0

type ResourceError struct {
	Resource string
	Err      error
}

ResourceError identifies a resource failure independently of command-wide failures.

func (ResourceError) Error added in v0.4.0

func (e ResourceError) Error() string

func (ResourceError) Unwrap added in v0.4.0

func (e ResourceError) Unwrap() error

type ResourceReport added in v0.2.0

type ResourceReport struct {
	Notices        []plugin.Notice `json:"notices,omitempty"`
	Name           string          `json:"name"`
	Kind           string          `json:"kind"`
	Key            string          `json:"key"`
	InputCacheHits map[string]bool `json:"input_cache_hits,omitempty"`
	// Inputs are the lock changes this run commits for the resource, or would
	// commit when it ignores input locks.
	Inputs       []lockfile.InputChange `json:"inputs,omitempty"`
	Artifacts    map[string]Prepared    `json:"artifacts,omitempty"`
	Cached       bool                   `json:"cached"`
	Destinations []DestinationReport    `json:"destinations,omitempty"`
	Publications []Publication          `json:"publications,omitempty"`
	// Icon reports what the icon method did for the resource's declared asset.
	Icon     string `json:"icon,omitempty"`
	IconPath string `json:"icon_path,omitempty"`
	Error    string `json:"error,omitempty"`
	// BlockedBy names the resources whose unavailable outputs prevented execution.
	BlockedBy []string `json:"blocked_by,omitempty"`
}

ResourceReport separates immutable outputs from destination reconciliation.

func (ResourceReport) MarshalJSON added in v0.10.0

func (r ResourceReport) MarshalJSON() ([]byte, error)

MarshalJSON keeps preparation cache state out of unrelated command results.

type Summary added in v0.4.0

type Summary struct {
	Resources             int `json:"resources"`
	InputChanges          int `json:"input_changes,omitempty"`
	Changed               int `json:"changed,omitempty"`
	Unchanged             int `json:"unchanged,omitempty"`
	Failed                int `json:"failed,omitempty"`
	Blocked               int `json:"blocked,omitempty"`
	Skipped               int `json:"skipped,omitempty"`
	Destinations          int `json:"destinations,omitempty"`
	DestinationOperations int `json:"destination_operations,omitempty"`
	Applied               int `json:"applied,omitempty"`
	Resolved              int `json:"resolved,omitempty"`
	Prepared              int `json:"prepared,omitempty"`
	Cached                int `json:"cached,omitempty"`
	Created               int `json:"created,omitempty"`
	Derived               int `json:"derived,omitempty"`
	// contains filtered or unexported fields
}

Summary counts the entire run, including resources omitted from its presentation.

func (Summary) MarshalJSON added in v0.10.0

func (s Summary) MarshalJSON() ([]byte, error)

MarshalJSON exposes predictable counters relevant to the command that ran.

Jump to

Keyboard shortcuts

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