workload

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package workload defines the bounded task specification understood by admission and placement. Unknown fields remain available to later stages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Budget

type Budget struct {
	Tokens       int64          `json:"tokens"`
	CostMicroUSD money.MicroUSD `json:"costUsd"`
	ToolCalls    int64          `json:"toolCalls"`
	WallSeconds  int64          `json:"wallSeconds"`
}

func (Budget) Zero

func (b Budget) Zero() bool

Zero reports whether every dimension is unset, meaning the task carries no budget ceiling and its usage is not enforced.

type Image

type Image struct {
	// Ref is the image reference the provider must run, e.g.
	// "example.com/agent@sha256:...". The worker verifies it against the
	// runtime's own configuration before starting anything.
	Ref string `json:"ref"`
	// Digest pins the image content ("sha256:<64 hex>"); empty allows a
	// mutable reference in dev, but production admission requires it for
	// container runtime classes.
	Digest string `json:"digest,omitempty"`
}

Image is the digest-pinned container reference of a workload.

func (Image) Canonical

func (i Image) Canonical() string

Canonical returns the pin the worker and admission compare: ref@digest when pinned, ref otherwise.

func (Image) Equal

func (i Image) Equal(other Image) bool

Equal reports whether two pins denote the same image.

func (Image) Pinned

func (i Image) Pinned() bool

Pinned reports whether the reference is content-addressed.

func (Image) Validate

func (i Image) Validate() error

Validate checks the pin shape: a non-empty reference and, when set, a canonical sha256 digest.

type ModelCallScript

type ModelCallScript struct {
	ModelRef       string `json:"modelRef"`
	InputTokens    int64  `json:"inputTokens,omitempty"`
	OutputTokens   int64  `json:"outputTokens,omitempty"`
	IdempotencyKey string `json:"idempotencyKey"`
}

ModelCallScript is one deterministic model invocation with pre-declared usage, metered and hard-stopped by the Model Gateway.

type Placement

type Placement struct {
	RuntimeClasses []string `json:"runtimeClasses"`
	PreferredClass string   `json:"preferredClass,omitempty"`
	Region         string   `json:"region"`
	DataResidency  string   `json:"dataResidency,omitempty"`
	ArtifactRegion string   `json:"artifactRegion,omitempty"`
	// AvoidFailureDomains prevents retry placement into a known failed zone,
	// rack, node, or other provider-defined domain.
	AvoidFailureDomains []string `json:"avoidFailureDomains,omitempty"`
	CPU                 int64    `json:"cpuMillis"`
	Memory              int64    `json:"memoryMiB"`
	// WorkspaceBytes is the sandbox workspace size (tmpfs) container-class
	// workloads must declare; Admission rejects container classes with a
	// zero workspace (ADR-010 hardening checklist).
	WorkspaceBytes int64 `json:"workspaceBytes"`
	LLMConcurrency int   `json:"llmConcurrency"`
}

type RetryPolicy

type RetryPolicy struct {
	MaxAttempts int `json:"maxAttempts,omitempty"`
}

func (RetryPolicy) EffectiveMaxAttempts

func (p RetryPolicy) EffectiveMaxAttempts() int

type Runtime

type Runtime struct {
	ComponentPath string   `json:"componentPath,omitempty"`
	Command       []string `json:"command,omitempty"`
}

Runtime describes the provider-specific entry point selected by the task. ComponentPath is consumed by the Wasmtime provider; Command is consumed by OCI-compatible providers.

func (Runtime) ValidateCommand

func (r Runtime) ValidateCommand() error

ValidateCommand bounds the argv passed to a container runtime. Empty means use the image's configured Entrypoint/Cmd.

type Spec

type Spec struct {
	Priority    int         `json:"priority"`
	Deadline    *time.Time  `json:"deadline,omitempty"`
	Budget      Budget      `json:"budget"`
	Placement   Placement   `json:"placement"`
	RetryPolicy RetryPolicy `json:"retryPolicy,omitempty"`
	// Image pins the OCI image this workload must run in (ADR-010). Runtime
	// providers for container classes (oci/microvm) must run exactly this
	// reference; digest-only references are the production contract.
	Image *Image `json:"image,omitempty"`
	// Runtime carries provider-specific launch metadata. Command is an argv
	// array, never a shell fragment, so OCI providers can override an image's
	// default command without introducing shell interpolation.
	Runtime *Runtime `json:"runtime,omitempty"`
	// ToolCalls is the deterministic tool script the reference provider
	// executes through the Tool Gateway before completing. Other providers
	// ignore it; the gateway enforces policy and budget regardless of caller.
	ToolCalls []ToolCall `json:"tools,omitempty"`
	// ModelCalls is the deterministic model script the reference provider
	// executes through the Model Gateway (Begin/Settle/Finish) after tools.
	ModelCalls []ModelCallScript `json:"modelCalls,omitempty"`
}

func Decode

func Decode(raw json.RawMessage) (Spec, error)

type ToolCall

type ToolCall struct {
	ToolName       string          `json:"name"`
	ToolVersion    string          `json:"version,omitempty"`
	Action         string          `json:"action"`
	Resource       string          `json:"resource"`
	Args           json.RawMessage `json:"args,omitempty"`
	IdempotencyKey string          `json:"idempotencyKey"`
}

ToolCall is one deterministic gateway invocation the reference provider performs on behalf of the Attempt. IdempotencyKeys must be unique within a task so replays converge on the stored receipts.

Jump to

Keyboard shortcuts

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