Documentation
¶
Overview ¶
Package runner executes CommandSpecs. It is the only package that touches os/exec, so every caller can be tested against a fake.
Agent CLIs spawn children, so cancellation kills the whole process group. Killing only the parent leaks grandchildren that hold the stdout pipe open.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommandSpec ¶
type CommandSpec struct {
Argv []string // Argv[0] is replaced with the resolved CLI path before exec
Dir string // workspace the agent runs in
Env []string // extras appended to os.Environ()
}
CommandSpec describes a runner invocation. Harnesses build specs but never touch os/exec; this package executes them, so callers can fake execution entirely.
type Exec ¶
type Exec struct{}
Exec runs commands for real. Isolation is the pod's concern, not this package's: specs execute unconfined.
func (*Exec) Run ¶
func (e *Exec) Run(ctx context.Context, spec CommandSpec, timeout time.Duration, onLine func(line []byte) (abort bool, reason string)) (Result, error)
Run executes spec with the given timeout, collecting stdout (bounded) into Result.Stdout. When onLine is non-nil it observes every stdout line as it streams; returning abort=true kills the process group and ends the run with Aborted=true and the observer's reason, plus everything collected so far. Neither an abort nor a timed-out run is an error: a timeout returns TimedOut=true with whatever output arrived, so callers can grade or parse partial output. The returned error is non-nil only for unstartable commands or parent-context cancellation (Ctrl-C).
type Result ¶
type Result struct {
Stdout []byte // full stdout (bounded), ANSI-stripped
TimedOut bool // the per-run timeout expired
Aborted bool // the per-line observer ended the run early
AbortReason string // the observer's reason for aborting
ExitCode int // process exit code (-1 when killed)
StderrTail string // last bytes of stderr, for timeout diagnostics
Elapsed time.Duration // wall clock of the agent run
}
Result is the outcome of one agent run.