run

package
v1.0.0-alpha.13 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 31 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package run launches an agent under a budget and turns its usage into rows.

Index

Constants

This section is empty.

Variables

Agents are the names --agent takes: the two agents, and a program that runs each through its SDK.

Functions

func AgentErrorFix

func AgentErrorFix(class adapter.AgentError) string

AgentErrorFix says what to do about an agent error of the class given, empty for a class outside the closed list.

func AgentErrorLine

func AgentErrorLine(class adapter.AgentError) string

AgentErrorLine is an agent error's class and its fix, in one line.

func AgentFor

func AgentFor(argv []string) (adapter.Agent, error)

AgentFor picks the adapter by the command's name.

func AgentNamed

func AgentNamed(name string) (adapter.Agent, error)

AgentNamed picks the adapter by its name, whatever the command is.

func ReaderLine

func ReaderLine(text string) string

ReaderLine is the first line of a reader's error, as a result object and a comment carry it. The error can quote the agent's stream, so every character outside readerLineCharacters becomes ?, and the line is cut at maxReaderLine bytes.

Types

type MissingAgentError

type MissingAgentError struct {
	Name string
	Err  error
}

MissingAgentError is an agent command that is not on PATH.

func (*MissingAgentError) Error

func (e *MissingAgentError) Error() string

func (*MissingAgentError) Unwrap

func (e *MissingAgentError) Unwrap() error

type Options

type Options struct {
	// Agent names the adapter, one of Agents. Empty picks it by the command's
	// name.
	Agent  string
	Argv   []string
	Budget decimal.Decimal
	// BillingAccount fills BillingAccountId. Empty reads unknown.
	BillingAccount string
	// Credential fills SubAccountId. Empty reads null.
	Credential string
	// CI is what the CI system says about the run. Its tags are claims: the
	// rows stay unverified and unattributed until a server checks them.
	CI      cicontext.Context
	Rows    io.Writer
	Stdin   io.Reader
	Stdout  io.Writer
	Stderr  io.Writer
	Catalog *catalog.Catalog
	// Now is the clock. Nil means time.Now.
	Now func() time.Time
	// Grace is how long a stopped agent has before SIGKILL.
	Grace time.Duration
	// Gateway is the run's own key on a gateway. Nil runs without one.
	Gateway *gateway.Session
}

Options describes one run.

type ReaderError

type ReaderError struct {
	Err error
}

ReaderError is a reader that refused the agent's stream or its execution file. No usage was read, so no rows were written.

func (*ReaderError) Error

func (e *ReaderError) Error() string

func (*ReaderError) Unwrap

func (e *ReaderError) Unwrap() error

type Reason

type Reason string

Reason says why a run wrote no rows. Its values are a closed list, each with one sentence, so a reader of an empty rows file can name the cause.

const (
	// ReasonNoUsage is a run whose agent ended and reported no usage.
	ReasonNoUsage Reason = "no_usage"
	// ReasonConcurrentRun is a run refused before its agent started, because
	// another run held the agent's state directory.
	ReasonConcurrentRun Reason = "concurrent_run"
	// ReasonReaderRefused is a run whose reader refused the agent's stream or
	// its execution file, so no usage was read.
	ReasonReaderRefused Reason = "reader_refused"
	// ReasonAgentError is a run whose agent ended in an error before it
	// reported any usage. The run's result names the error's class.
	ReasonAgentError Reason = "agent_error"
)

The reasons a run writes no rows.

func (Reason) Sentence

func (r Reason) Sentence() string

Sentence is the reason in words.

type RefusedError

type RefusedError struct {
	Reason Reason
	Err    error
}

RefusedError is a run that never started its agent, and why.

func (*RefusedError) Error

func (e *RefusedError) Error() string

func (*RefusedError) Unwrap

func (e *RefusedError) Unwrap() error

type Result

type Result struct {
	Agent       string
	AgentExit   int
	Stopped     bool
	Enforcement adapter.Enforcement
	Report      adapter.Report
	Rows        int
	ListTotal   decimal.Decimal
	// Reason is set when the run wrote no rows.
	Reason Reason
	// AgentError is the class of error the agent ended in, empty when it
	// ended in none. It can sit beside rows: an agent can fail after it has
	// made requests.
	AgentError adapter.AgentError
	// RowsSHA256 is the SHA-256 of the rows' x_CostroidRowId values, sorted,
	// each followed by a line feed, in lower-case hex. Empty when the run wrote
	// no rows.
	RowsSHA256 string
	// RowsFileSHA256 is the SHA-256 of every byte the run wrote to Rows, in
	// lower-case hex. A rows file that reads otherwise was written after the
	// run.
	RowsFileSHA256 string
}

Result is what the run came to.

func Record

func Record(opts Options, agent string, report adapter.Report) (Result, error)

Record writes the rows of a run that has already ended. The report's own grade stands, because no process was watched.

func Run

func Run(ctx context.Context, opts Options) (Result, error)

Run starts the agent, reads its stream, stops it at the cap when the plan watches the run, and writes the rows at the grade the run earned.

Jump to

Keyboard shortcuts

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