engine

package
v0.2.0-beta.5 Latest Latest
Warning

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

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

Documentation

Overview

Package engine owns the deterministic host execution foundation.

Index

Constants

View Source
const (
	ScreenshotDiffThreshold = 0.005

	AnimationTimeout                  = 15 * time.Second
	ElementStabilityTimeout           = 3 * time.Second
	ElementStabilityPollInterval      = 100 * time.Millisecond
	HierarchySettlePollInterval       = 200 * time.Millisecond
	IOSScreenSettleTimeout            = 3 * time.Second
	AndroidWindowUpdateTimeout        = 750 * time.Millisecond
	AndroidIMECommitSettleDelay       = 250 * time.Millisecond
	DriverServerLaunchTimeout         = 15 * time.Second
	LookupTimeout                     = 17 * time.Second
	OptionalLookupTimeout             = 7 * time.Second
	NotVisiblePollInterval            = 500 * time.Millisecond
	WaitUntilVisiblePollInterval      = time.Second
	RepeatDelay                       = 100 * time.Millisecond
	DefaultSwipeDuration              = 400 * time.Millisecond
	MaximumSettleTimeout              = 30 * time.Second
	AndroidReachabilityPollInterval   = 100 * time.Millisecond
	IOSStatusReachabilityPollInterval = 500 * time.Millisecond

	HierarchySettleAttempts  = 10
	WaitUntilVisibleAttempts = 10
	TapAttempts              = 1
	TapAttemptsWithRetry     = 2
	RetryCommandMaxRetries   = 3
)
View Source
const (
	EffectNone effectClass = iota
	EffectObserved
	EffectDeviceMutation
	EffectHostMutation
	EffectComposite
	EffectArtifact
)

Variables

View Source
var ErrCloudAPIKeyNotAvailable = errors.New("cloud API key is not available for AI execution")

ErrCloudAPIKeyNotAvailable marks an AI command reached execution without a configured AIPredictionEngine (missing engine or API key). It is wrapped in a OperationError so the failure stays retryable and, under the AI commands' default optional=true, is warned rather than fatal.

Functions

func CanWarnWhenOptional

func CanWarnWhenOptional(err error) bool

CanWarnWhenOptional reports whether an optional command may convert the failure into a warned outcome.

func IsCommandSkipped

func IsCommandSkipped(err error) bool

IsCommandSkipped reports whether the error represents intentional control flow rather than a failed command.

func IsRetryable

func IsRetryable(err error) bool

IsRetryable reports whether retry command semantics may retry the failure.

func Validate

func Validate(ctx context.Context, program *Program) error

Validate compiles a prepared Program without running it, so a caller can learn what Execute would refuse before anything reaches a device. compileProgram runs "before any runtime or device dependency is constructed", which is what lets a syntax check use it: parse and capability preflight see a command's SHAPE and its support, never its VALUES, so `repeat: -1` and a 100% coordinate pass both and fail on the device instead.

Compilation is interpolation aware -- `${POINT}` compiles and defers to evaluation -- so this refuses literals only and never a value the flow gets from its environment.

Types

type AIPredictionEngine

type AIPredictionEngine interface {
	FindDefects(ctx context.Context, screenshotPNG []byte) (AIResult, error)
	PerformAssertion(ctx context.Context, screenshotPNG []byte, assertion string) (AIResult, error)
	ExtractText(ctx context.Context, screenshotPNG []byte, query string) (AIResult, error)
}

AIPredictionEngine is the injectable, screenshot-based AI boundary declared in specs/01-core-engine.md. Every call receives an uncompressed PNG screenshot of the current screen. A nil engine on Dependencies fails closed with ErrCloudAPIKeyNotAvailable when the provider key is unavailable.

type AIResult

type AIResult struct {
	Pass      bool
	Reasoning string
	Text      string
	Defects   []string
}

AIResult is the owned outcome of one AIPredictionEngine call. Not every field is meaningful for every method: Pass and Reasoning describe an assertion, Defects lists findDefects results, and Text carries extracted text.

type ArtifactSink

type ArtifactSink interface {
	Write(context.Context, ArtifactWriteRequest) (ArtifactWriteResult, error)
}

ArtifactSink owns artifact naming, storage, and finalization.

type ArtifactWriteRequest

type ArtifactWriteRequest struct {
	Owner         string
	Kind          string
	SuggestedName string
	Data          []byte
	Metadata      map[string]string
}

ArtifactWriteRequest describes content whose final path is owned by the injected sink rather than by a command handler.

type ArtifactWriteResult

type ArtifactWriteResult struct {
	Artifact     device.Artifact
	BytesWritten int64
}

ArtifactWriteResult identifies the finalized artifact owned by the sink.

type AssertionError

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

AssertionError identifies a failed product assertion. Assertions share the operation retry and optional-warning classification but remain separately inspectable.

func NewAssertionError

func NewAssertionError(message string, cause error) *AssertionError

func (AssertionError) Error

func (e AssertionError) Error() string

func (AssertionError) Unwrap

func (e AssertionError) Unwrap() error

type Clock

type Clock interface {
	Now() time.Time
	Wait(context.Context, time.Duration) error
}

Clock is the minimal time source required by deterministic engine logic. enginetest.FakeClock and RealClock both satisfy it structurally.

type CommandMetadata

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

CommandMetadata is an immutable snapshot of execution metadata.

func NewCommandMetadata

func NewCommandMetadata(numberOfRuns int, evaluatedCommand *model.Command, logMessages []string, insight string, aiReasoning string) CommandMetadata

func (CommandMetadata) AIReasoning

func (m CommandMetadata) AIReasoning() string

func (CommandMetadata) EvaluatedCommand

func (m CommandMetadata) EvaluatedCommand() (model.Command, bool)

func (CommandMetadata) HasNumberOfRuns

func (m CommandMetadata) HasNumberOfRuns() bool

HasNumberOfRuns reports whether NumberOfRuns was explicitly populated. The zero-value CommandMetadata is absent, while NewCommandMetadata makes every supplied value present, including zero.

func (CommandMetadata) Insight

func (m CommandMetadata) Insight() string

func (CommandMetadata) LogMessages

func (m CommandMetadata) LogMessages() []string

func (CommandMetadata) NumberOfRuns

func (m CommandMetadata) NumberOfRuns() int

type CommandResult

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

CommandResult is an immutable terminal command record.

func (CommandResult) Artifacts

func (r CommandResult) Artifacts() []device.Artifact

func (CommandResult) Command

func (r CommandResult) Command() model.Command

func (CommandResult) Depth

func (r CommandResult) Depth() int

func (CommandResult) Duration

func (r CommandResult) Duration() time.Duration

func (CommandResult) FinishedAt

func (r CommandResult) FinishedAt() time.Time

func (CommandResult) Metadata

func (r CommandResult) Metadata() CommandMetadata

func (CommandResult) Outcome

func (r CommandResult) Outcome() Outcome

func (CommandResult) ProductError

func (r CommandResult) ProductError() error

func (CommandResult) RootRunID

func (r CommandResult) RootRunID() string

func (CommandResult) Sequence

func (r CommandResult) Sequence() uint64

func (CommandResult) StartedAt

func (r CommandResult) StartedAt() time.Time

type CommandSkippedError

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

CommandSkippedError is control flow for a command that intentionally did not execute.

func NewCommandSkippedError

func NewCommandSkippedError(message string, cause error) *CommandSkippedError

func (CommandSkippedError) Error

func (e CommandSkippedError) Error() string

func (CommandSkippedError) Unwrap

func (e CommandSkippedError) Unwrap() error

type CommandSpan

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

CommandSpan is a single-use command timing scope.

func (*CommandSpan) CommandReset

func (s *CommandSpan) CommandReset(previous CommandResult) (Event, error)

CommandReset captures an immutable reset event for a previously executed immediate child. The child's identity is reused and no sequence is allocated.

func (*CommandSpan) Finish

func (s *CommandSpan) Finish(outcome Outcome, productError error, metadata CommandMetadata) (CommandResult, Event, error)

func (*CommandSpan) FinishWithArtifacts

func (s *CommandSpan) FinishWithArtifacts(
	outcome Outcome,
	productError error,
	metadata CommandMetadata,
	artifacts []device.Artifact,
) (CommandResult, Event, error)

FinishWithArtifacts completes the command with finalized host-owned artifacts while preserving immutable result and listener snapshots.

func (*CommandSpan) MetadataUpdated

func (s *CommandSpan) MetadataUpdated(metadata CommandMetadata) (Event, error)

MetadataUpdated captures an immutable metadata event for this active parent without completing the span or allocating another command sequence.

type ConfigurationError

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

ConfigurationError identifies invalid engine input or configuration.

func NewConfigurationError

func NewConfigurationError(message string, cause error) *ConfigurationError

func (ConfigurationError) Error

func (e ConfigurationError) Error() string

func (ConfigurationError) Unwrap

func (e ConfigurationError) Unwrap() error

type Controller

type Controller interface {
	WaitIfPaused(context.Context) error
}

Controller is the pause/resume boundary consulted before command dispatch.

type ControllerFunc

type ControllerFunc func(context.Context) error

func (ControllerFunc) WaitIfPaused

func (f ControllerFunc) WaitIfPaused(ctx context.Context) error

type ControllerResult

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

ControllerResult preserves a pre-existing product error while separately exposing controller failure. Without a product error, controller failure is the effective execution error.

func WaitForController

func WaitForController(ctx context.Context, controller Controller, productError error) ControllerResult

WaitForController safely invokes a controller without allowing a callback panic or error to overwrite an existing product failure.

func (ControllerResult) ControllerFailure

func (r ControllerResult) ControllerFailure() error

func (ControllerResult) EffectiveError

func (r ControllerResult) EffectiveError() error

func (ControllerResult) ProductError

func (r ControllerResult) ProductError() error

type Dependencies

type Dependencies struct {
	// ExecutionID is a caller-owned deterministic identity for one public
	// Execute invocation. Root-run correlation is derived from it.
	ExecutionID string
	// ExternalEnvironment is a caller-owned environment input. Execute takes
	// one sanitized snapshot and applies it only at each selected root scope.
	ExternalEnvironment map[string]string
	// ReservedEnvironment carries the variables only the host may set —
	// FLOWBATON_SHARD_ID, FLOWBATON_SHARD_INDEX, FLOWBATON_DEVICE_UDID. It is a
	// separate field because ExternalEnvironment is sanitized: those names are
	// stripped from the operator's map precisely so they can arrive only here.
	// Every key must carry the FLOWBATON_ prefix, and these win over both a
	// flow's own env and the operator's.
	ReservedEnvironment map[string]string

	// SequencedRoots is how many of the plan's LEADING roots
	// executionOrder.flowsOrder named. Those flows were declared to depend on
	// each other, so a failure among them ends the run unless
	// ContinueOnFailure says otherwise. Every remaining root is parallel-eligible
	// and always runs, as specified by specs/03-cli-tooling.md:30.
	SequencedRoots int
	// ContinueOnFailure carries the ordered sequence past a failed flow.
	ContinueOnFailure bool

	Driver     device.Driver
	Clock      Clock
	JSFactory  js.Factory
	Controller Controller
	// FailureResolver is optional. Nil and invalid resolvers fail closed.
	FailureResolver FailureResolver
	Listeners       []Listener

	ArtifactSink        ArtifactSink
	RecordingController RecordingController
	ResourceReader      ResourceReader
	InputGenerator      InputGenerator
	ImageChecker        ImageChecker
	// AIEngine is optional. A nil engine fails AI commands closed with
	// ErrCloudAPIKeyNotAvailable (specs/01-core-engine.md).
	AIEngine AIPredictionEngine
}

Dependencies contains the required engine core and optional command-family services. Optional services are validated only by the handler that uses them.

type DeviceConnectionError

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

DeviceConnectionError identifies a transport or device-session loss that must propagate rather than be retried or downgraded to an optional warning.

func NewDeviceConnectionError

func NewDeviceConnectionError(message string, cause error) *DeviceConnectionError

func (DeviceConnectionError) Error

func (e DeviceConnectionError) Error() string

func (DeviceConnectionError) Unwrap

func (e DeviceConnectionError) Unwrap() error

type ElementLookup

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

ElementLookup owns host-side hierarchy acquisition and selector lookup. Device information is cached after the first successful read because the viewport is stable for the lifetime of a driver session.

func NewElementLookup

func NewElementLookup(driver device.Driver, clock Clock) *ElementLookup

NewElementLookup constructs deterministic host-side lookup primitives.

func (*ElementLookup) AdjustedTimeout

func (lookup *ElementLookup) AdjustedTimeout(options LookupOptions) time.Duration

AdjustedTimeout returns an explicit timeout unchanged (apart from flooring negatives at zero), or the required/optional default minus elapsed time since the latest interaction. The result is always non-negative.

func (*ElementLookup) Find

func (lookup *ElementLookup) Find(ctx context.Context, selector model.ElementSelector, options LookupOptions) (*hierarchy.Element, error)

Find polls normalized visible hierarchies until the selector matches or the adjusted deadline is reached. Matching delegates to the frozen exact matching package without altering selector semantics.

func (*ElementLookup) ForgetDeviceInfo

func (lookup *ElementLookup) ForgetDeviceInfo()

ForgetDeviceInfo drops the cached device grid so the next read measures the screen as it is now. DeviceInfo is cached because a lookup polls and the iOS runner answers the route by taking a screenshot, but the grid is the one field that changes under a running session, and visibleHierarchy prunes with it: after a rotation an element plainly on a landscape screen falls outside the remembered portrait width and reads as missing.

The engine calls this when IT rotates the device. A rotation the app performs on its own is a known gap: nothing tells the session, and the cached grid stays wrong until the flow rotates or the session ends.

func (*ElementLookup) RecordInteraction

func (lookup *ElementLookup) RecordInteraction(at time.Time)

RecordInteraction records the latest accepted interaction instant. Timestamps before the watermark cannot move it backwards.

func (*ElementLookup) SetActiveApp

func (lookup *ElementLookup) SetActiveApp(appID string) string

SetActiveApp names the app whose hierarchy lookups should read, and returns what was set before so a caller can restore it.

Drivers use the active app ID to scope hierarchy requests. Returning the previous value rather than exposing a stack keeps ownership with the flow scope that already pushes and pops the environment: one place that knows a flow was entered also knows it was left.

func (*ElementLookup) WaitForElementStability

func (lookup *ElementLookup) WaitForElementStability(ctx context.Context, previous *hierarchy.Element) (ElementStabilityResult, error)

WaitForElementStability refreshes the element by attributes (excluding bounds) every 100ms. Transient absence or ambiguity keeps the last-known element; driver and hierarchy failures still propagate.

func (*ElementLookup) WaitForHierarchySettle

func (lookup *ElementLookup) WaitForHierarchySettle(ctx context.Context, request device.SettleRequest) (*device.ViewHierarchy, error)

WaitForHierarchySettle confirms settling only after two equal, non-loading hierarchy samples. Nil samples are inconclusive and never count as settled. An explicit timeout governs deadline polling; an omitted timeout performs exactly ten possible 200ms polls.

func (*ElementLookup) WaitUntilNotVisible

func (lookup *ElementLookup) WaitUntilNotVisible(ctx context.Context, selector model.ElementSelector, timeout time.Duration) error

WaitUntilNotVisible checks immediately, then polls at the exact 500ms condition cadence through the deadline. A still-visible element at the deadline is a retryable OperationError.

func (*ElementLookup) WaitUntilVisible

func (lookup *ElementLookup) WaitUntilVisible(ctx context.Context, selector model.ElementSelector, optional bool) (*hierarchy.Element, error)

WaitUntilVisible performs exactly ten possible one-second waits followed by one hierarchy lookup per attempt. Optional exhaustion is a nil element and nil error; required exhaustion is a retryable OperationError.

type ElementStabilityResult

type ElementStabilityResult struct {
	Element *hierarchy.Element
	Bounds  device.Bounds
	Stable  bool
}

ElementStabilityResult preserves the latest refreshable element and bounds even when the stability deadline expires. Stable is true only when equal consecutive bounds are observed before that deadline.

type Event

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

Event is an immutable listener-facing lifecycle snapshot.

func (Event) Artifacts

func (e Event) Artifacts() []device.Artifact

func (Event) At

func (e Event) At() time.Time

func (Event) Command

func (e Event) Command() (model.Command, bool)

func (Event) Depth

func (e Event) Depth() int

func (Event) FlowPath

func (e Event) FlowPath() string

func (Event) Kind

func (e Event) Kind() EventKind

func (Event) Metadata

func (e Event) Metadata() CommandMetadata

func (Event) Outcome

func (e Event) Outcome() Outcome

func (Event) ProductError

func (e Event) ProductError() error

func (Event) RootRunID

func (e Event) RootRunID() string

func (Event) Sequence

func (e Event) Sequence() uint64

type EventKind

type EventKind string

EventKind identifies an immutable engine lifecycle event.

const (
	EventFlowStarted            EventKind = "FlowStarted"
	EventFlowFinished           EventKind = "FlowFinished"
	EventCommandStarted         EventKind = "CommandStarted"
	EventCommandFinished        EventKind = "CommandFinished"
	EventCommandReset           EventKind = "CommandReset"
	EventCommandMetadataUpdated EventKind = "CommandMetadataUpdated"
)

type FailureDecision

type FailureDecision string

FailureDecision is the stable root-command failure action returned by a FailureResolver. CONTINUE is the only value that permits later root work.

const (
	FailureDecisionFail     FailureDecision = "FAIL"
	FailureDecisionContinue FailureDecision = "CONTINUE"
)

type FailureResolver

type FailureResolver interface {
	ResolveFailure(context.Context, CommandResult) FailureDecision
}

FailureResolver decides whether root-owned execution may continue after a finalized failed command. Child and nested execution never consults it.

type FailureResolverFunc

type FailureResolverFunc func(context.Context, CommandResult) FailureDecision

func (FailureResolverFunc) ResolveFailure

func (resolver FailureResolverFunc) ResolveFailure(ctx context.Context, result CommandResult) FailureDecision

type FlowResult

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

FlowResult is an immutable terminal flow record.

func Execute

func Execute(ctx context.Context, program *Program, dependencies Dependencies) (results []FlowResult, err error)

Execute compiles the complete prepared Program before creating a runtime or touching the driver, then executes selected roots in plan order. Duplicate root selections intentionally produce independent execution sessions.

func (FlowResult) Commands

func (r FlowResult) Commands() []CommandResult

func (FlowResult) Depth

func (r FlowResult) Depth() int

func (FlowResult) Duration

func (r FlowResult) Duration() time.Duration

func (FlowResult) FinishedAt

func (r FlowResult) FinishedAt() time.Time

func (FlowResult) Name

func (r FlowResult) Name() string

Name is the flow's authored `name:`, blank when it has none.

func (FlowResult) Outcome

func (r FlowResult) Outcome() Outcome

func (FlowResult) Path

func (r FlowResult) Path() string

func (FlowResult) ProductError

func (r FlowResult) ProductError() error

func (FlowResult) RootRunID

func (r FlowResult) RootRunID() string

func (FlowResult) StartedAt

func (r FlowResult) StartedAt() time.Time

type FlowSpan

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

FlowSpan is a single-use flow timing scope.

func (*FlowSpan) Finish

func (s *FlowSpan) Finish(outcome Outcome, productError error, commands []CommandResult) (FlowResult, Event, error)

type ImageCheckRequest

type ImageCheckRequest struct {
	Expected []byte
	Actual   []byte
	Crop     *image.Rectangle
}

ImageCheckRequest contains encoded images and an optional shared crop.

type ImageChecker

type ImageChecker interface {
	Check(context.Context, ImageCheckRequest) (imagecheck.Result, error)
}

ImageChecker is the injectable host boundary around imagecheck.Result.

type InputGenerator

type InputGenerator interface {
	Generate(context.Context, InputRequest) (string, error)
}

InputGenerator supplies deterministic host-generated input.

type InputKind

type InputKind string

InputKind is the stable input-generation category used by random-input command handlers.

const (
	InputText        InputKind = "text"
	InputNumber      InputKind = "number"
	InputEmail       InputKind = "email"
	InputPersonName  InputKind = "person-name"
	InputCityName    InputKind = "city-name"
	InputCountryName InputKind = "country-name"
	InputColorName   InputKind = "color-name"
)

type InputRequest

type InputRequest struct {
	Kind   InputKind
	Length int
}

InputRequest asks the injected generator for one typed value.

type Listener

type Listener interface {
	OnEvent(context.Context, Event) error
}

Listener observes immutable engine events. Listener failures are diagnostic only and never replace the product execution error.

type ListenerDispatchResult

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

ListenerDispatchResult keeps product and observer failures in separate channels so observer code cannot change execution semantics.

func DispatchListeners

func DispatchListeners(ctx context.Context, event Event, productError error, listeners ...Listener) ListenerDispatchResult

DispatchListeners invokes every listener in declaration order while isolating returned errors and panics.

func (ListenerDispatchResult) EffectiveError

func (r ListenerDispatchResult) EffectiveError() error

func (ListenerDispatchResult) ListenerFailures

func (r ListenerDispatchResult) ListenerFailures() []ListenerFailure

func (ListenerDispatchResult) ProductError

func (r ListenerDispatchResult) ProductError() error

type ListenerFailure

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

ListenerFailure records one isolated listener error or panic.

func (ListenerFailure) Err

func (f ListenerFailure) Err() error

func (ListenerFailure) Index

func (f ListenerFailure) Index() int

type ListenerFunc

type ListenerFunc func(context.Context, Event) error

func (ListenerFunc) OnEvent

func (f ListenerFunc) OnEvent(ctx context.Context, event Event) error

type LookupOptions

type LookupOptions struct {
	Optional bool
	Timeout  *time.Duration
}

LookupOptions controls a selector lookup. A nil Timeout uses the adjusted required or optional default. Optional absence is represented explicitly as a nil element and nil error; required absence is a OperationError.

type NoopController

type NoopController struct{}

NoopController never pauses or fails.

func (NoopController) WaitIfPaused

func (NoopController) WaitIfPaused(context.Context) error

type OperationError

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

OperationError identifies a product operation failure eligible for command retry and optional-warning handling.

func NewOperationError

func NewOperationError(message string, cause error) *OperationError

func (OperationError) Error

func (e OperationError) Error() string

func (OperationError) Unwrap

func (e OperationError) Unwrap() error

type Outcome

type Outcome string

Outcome is the stable terminal status for a command or flow.

const (
	Completed Outcome = "Completed"
	Skipped   Outcome = "Skipped"
	Warned    Outcome = "Warned"
	Failed    Outcome = "Failed"
	Cancelled Outcome = "Cancelled"
)

func ClassifyOutcome

func ClassifyOutcome(err error, optional bool) Outcome

ClassifyOutcome applies the engine's skipped, cancelled, and optional-warning taxonomy to a product error.

type Program

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

Program is the immutable-by-API set of flows validated by capability preflight.

func Prepare

func Prepare(ctx context.Context, plan model.ExecutionPlan, loader capability.FlowLoader) (*Program, error)

Prepare runs capability preflight through a recording cache and retains the validated parsed flows. Executing a Program never reloads source files.

func PrepareForPlatform

func PrepareForPlatform(
	ctx context.Context,
	plan model.ExecutionPlan,
	loader capability.FlowLoader,
	platform capability.ExecutionPlatform,
) (*Program, error)

PrepareForPlatform performs the same immutable preparation while rejecting features whose registry Platforms do not include the selected driver. It is intended for executable paths before Driver.Open; syntax-only callers may continue to use Prepare.

func (*Program) Flow

func (p *Program) Flow(canonicalPath string) (model.Flow, bool)

Flow returns one prepared flow without consulting the source loader.

func (*Program) FlowPaths

func (p *Program) FlowPaths() []string

FlowPaths returns unique canonical flow paths in preflight load order.

func (*Program) Graph

func (p *Program) Graph() capability.Report

Graph returns the selected-root capability proof retained by the Program.

func (*Program) Roots

func (p *Program) Roots() []string

Roots returns canonical selected roots in execution-plan order, including repeated selections.

type RealClock

type RealClock struct{}

RealClock is the production wall-clock implementation.

func (RealClock) Now

func (RealClock) Now() time.Time

func (RealClock) Wait

func (RealClock) Wait(ctx context.Context, delay time.Duration) error

type RecordingController

type RecordingController interface {
	Start(context.Context, RecordingStartRequest) error
	Stop(context.Context) ([]device.Artifact, error)
}

RecordingController completes the start/stop lifecycle outside frozen device.Driver v0 and returns only finalized artifacts from Stop.

type RecordingStartRequest

type RecordingStartRequest struct {
	Name     string
	Metadata map[string]string
}

RecordingStartRequest describes one host-managed recording session.

type ResourceReadRequest

type ResourceReadRequest struct {
	Path string
}

ResourceReadRequest names one independently resolved host resource.

type ResourceReadResult

type ResourceReadResult struct {
	Data     []byte
	Metadata map[string]string
}

ResourceReadResult is an owned snapshot of resource bytes and metadata.

type ResourceReader

type ResourceReader interface {
	Read(context.Context, ResourceReadRequest) (ResourceReadResult, error)
}

ResourceReader resolves command resources without direct filesystem access in handlers.

type Timeline

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

Timeline is the shared monotonic command-sequence and time source for one execution run.

func NewTimeline

func NewTimeline(clock Clock) (*Timeline, error)

func (*Timeline) BeginCommand

func (t *Timeline) BeginCommand(command model.Command, depth int) (*CommandSpan, Event, error)

BeginCommand allocates the next sequence number and captures an immutable start event.

func (*Timeline) BeginFlow

func (t *Timeline) BeginFlow(path string, name string, depth int) (*FlowSpan, Event, error)

BeginFlow captures a flow start without allocating a command sequence.

name is the flow's authored `name:`, blank when it has none. It is carried because this is the only point where the compiled config and the result being built are both in scope: a consumer holding a FlowResult has just a path, and a path cannot be turned back into an authored name.

func (*Timeline) Checkpoint

func (t *Timeline) Checkpoint() uint64

Checkpoint returns the highest command sequence allocated so far, including commands whose spans have not finished yet.

type Timer

type Timer interface {
	Deadline() time.Time
	Done() <-chan struct{}
	Wait(context.Context) error
	Stop() bool
}

Timer is the independently waitable timer contract implemented by enginetest.FakeTimer.

Jump to

Keyboard shortcuts

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