runtimeexec

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package runtimeexec shares invocation ownership across agent and command steps.

Index

Constants

View Source
const ContainerBridge = "/opt/agent-workflow/bridge/bridge.mjs"
View Source
const ContainerGuardian = "/usr/local/bin/agent-workflow-guardian"
View Source
const GuardianProtocol = "1"
View Source
const MountedGuardian = "/engine-guardian/guardian"

Variables

This section is empty.

Functions

func BuildContainer

func BuildContainer(cmd *exec.Cmd, policy Policy, options ContainerOptions, owner containerapi.Owner, lifetimeDir string) ([]string, error)

BuildContainer contains no effects. It is shared by command and agent roles.

func BuildRequest

func BuildRequest(o LaunchOptions, owner containerapi.Owner, lifetime string) (containerapi.CreateRequest, error)

func CheckImage

func CheckImage(ctx context.Context, policy Policy, bridge bool, requiredLabels ...map[string]string) error

func CheckPolicy

func CheckPolicy(ctx context.Context, p Policy) error

func DefaultGuardianDirectory

func DefaultGuardianDirectory() string

func NewID

func NewID() string

func PrepareContainer

func PrepareContainer(ctx context.Context, cmd *exec.Cmd, policy Policy, options ContainerOptions) (func(), error)

func ProbeContext

func ProbeContext(ctx context.Context) (context.Context, context.CancelFunc)

Probe contexts bound runtime prerequisite checks independently of turn length.

func RuntimePath

func RuntimePath(policy Policy) (string, error)

func Supervise

func Supervise(ctx context.Context, cmd *exec.Cmd) (func(), error)

func SupervisePolicy

func SupervisePolicy(ctx context.Context, cmd *exec.Cmd, p Policy) (func(), error)

func WithBinding

func WithBinding(ctx context.Context, b Binding) context.Context

Types

type Binding

type Binding struct {
	Journal                            Journal
	Dir, RunID, Owner, LogicalID, Kind string
	Generation                         int64
}

func BindingFrom

func BindingFrom(ctx context.Context) (Binding, bool)

type ContainerOptions

type ContainerOptions struct {
	Workspace, State, Root string
	Bridge                 bool
	CredentialFile         string
	CredentialEnv          string
	// Environment contains explicit workload assignments, separate from the host runtime environment.
	Environment []string
}

type ContainerSession

type ContainerSession struct {
	Runtime    containerapi.Runtime
	Invocation *Invocation
	Owner      containerapi.Owner
	// contains filtered or unexported fields
}

ContainerSession owns an inert-create/attach/start/wait/remove lifecycle. It is also used by resident job containers. Close verifies absence before returning.

func LaunchContainer

func LaunchContainer(ctx context.Context, o LaunchOptions) (session *ContainerSession, returned error)

func (*ContainerSession) Close

func (s *ContainerSession) Close() error

func (*ContainerSession) Exec

func (s *ContainerSession) Exec(ctx context.Context, q containerapi.ExecRequest, streams containerapi.Streams) (code int, returned error)

Exec journals an identity before starting a command in the resident container. A per-command heartbeat is mounted below the parent's lifetime directory, so cancellation can stop descendants without ending the parent's lifetime.

func (*ContainerSession) Run

func (s *ContainerSession) Run(ctx context.Context, streams containerapi.Streams) (int, error)

func (*ContainerSession) Start

type GuardianAsset

type GuardianAsset struct {
	Path     string `json:"path"`
	SHA256   string `json:"sha256"`
	Platform string `json:"platform"`
}

func GuardianFor

func GuardianFor(directory string, image containerapi.Image) (GuardianAsset, error)

GuardianFor selects the Linux workload binary even when the host is macOS. The manifest is part of the release; no download or build occurs at runtime.

func (GuardianAsset) Verify

func (g GuardianAsset) Verify() error

type Invocation

type Invocation struct {
	Record Record
	// contains filtered or unexported fields
}

func Admit

func Admit(ctx context.Context, kind string) (*Invocation, error)

func (*Invocation) Directory

func (i *Invocation) Directory() string

func (*Invocation) Save

func (i *Invocation) Save(ctx context.Context, state string) error

func (*Invocation) StartHeartbeat

func (i *Invocation) StartHeartbeat() error

func (*Invocation) StopHeartbeat

func (i *Invocation) StopHeartbeat()

func (*Invocation) Supervise

func (i *Invocation) Supervise(ctx context.Context, cmd *exec.Cmd, cleanup []string) (func(), error)

type Journal

type Journal interface {
	AdmitInvocation(context.Context, Record) error
	UpdateInvocation(context.Context, Record) error
}

type LaunchOptions

type LaunchOptions struct {
	Policy                 Policy
	Selection              containerapi.Selection
	Image                  containerapi.Image
	Guardian               GuardianAsset
	Workspace, State, Root string
	Command, Env           []string
	WorkingDir             string
	Actions                string
	EngineState            string
	TaskStateDir           string
}

type Policy

type Policy struct {
	NetworkRuntime string             `yaml:"network-runtime"`
	Network        *network.Reference `yaml:"-" json:",omitempty"`
	NetworkMode    string             `yaml:"network" json:",omitempty"`
	Mode           string             `yaml:"mode"`
	Image          string             `yaml:"image"`
	Runtime        string             `yaml:"runtime"`
	Writable       bool               `yaml:"writable"`
	Cleanup        string             `yaml:"cleanup"`
	UID            *int               `yaml:"uid"`
	GID            *int               `yaml:"gid"`
}

func PinPolicy

func PinPolicy(ctx context.Context, p Policy) (Policy, error)

PinPolicy resolves a selection once at admission. A retained reference is checked, never silently refreshed after runtime replacement or resume.

func (Policy) Validate

func (p Policy) Validate() error

func (Policy) ValidateFor

func (p Policy) ValidateFor(goos string) error

type Record

type Record struct {
	ExecID         string              `json:"exec_id,omitempty"`
	Network        *network.Reference  `json:"network_runtime,omitempty"`
	ID             string              `json:"id"`
	RunID          string              `json:"run_id"`
	Generation     int64               `json:"execution_generation"`
	LogicalID      string              `json:"logical_invocation_id"`
	Owner          string              `json:"-"`
	Kind           string              `json:"kind"`
	State          string              `json:"cleanup_state"`
	Token          string              `json:"token"`
	CompletionPath string              `json:"completion_path"`
	Container      *containerapi.Owner `json:"container,omitempty"`
	StartedAt      time.Time           `json:"started_at"`
	UpdatedAt      time.Time           `json:"updated_at"`
	Error          string              `json:"error,omitempty"`
}

func Reconcile

func Reconcile(ctx context.Context, record Record) (Record, error)

type StorageError

type StorageError struct {
	Err error
}

StorageError identifies a runtime state persistence failure while retaining its diagnostic.

func (*StorageError) Error

func (e *StorageError) Error() string

func (*StorageError) Unwrap

func (e *StorageError) Unwrap() error

Directories

Path Synopsis
Package network implements the explicitly prepared shared network runtime.
Package network implements the explicitly prepared shared network runtime.

Jump to

Keyboard shortcuts

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