worker

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package worker owns host worker process execution for Brain drivers.

The package is the seam between deterministic orchestration policy and the unsafe OS-process layer: callers hand a Mission to a Runner, and concrete runners guarantee bounded execution, output prefixing, environment propagation, and process-tree cleanup.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mission

type Mission struct {
	Command   string // worker command
	MissionID string // logical mission id, when available
	Root      string // project root; when set, a durable spec-scoped mission record is persisted
	SessionID string
	WorkerID  string
	Spec      string
	TaskID    string
	Attempt   int // task attempt (>= 1); keys the durable mission filename
	Role      string
	Files     []string // SPECD_ARTIFACT hint
	Deadline  string   // RFC3339Nano

	// Payload is optional mission-file JSON content. When nil, the Mission itself
	// is written. This preserves the existing Pinky mission file contract while
	// keeping process execution decoupled from internal/core types.
	Payload any
}

Mission is the execution unit handed to a Runner.

type Result

type Result struct {
	ExitErr  error
	TimedOut bool
	Duration time.Duration
}

Result reports one completed runner invocation.

type Runner

type Runner interface {
	Run(ctx context.Context, m Mission) (Result, error)
}

Runner executes one Mission to completion (or deadline). Implementations own child process groups and must not leave orphaned children behind Run.

type ShellRunner

type ShellRunner struct {
	Stdout io.Writer
	Stderr io.Writer
}

ShellRunner runs missions with the POSIX shell contract used by Brain.

func (ShellRunner) Run

func (r ShellRunner) Run(parent context.Context, m Mission) (Result, error)

Run executes m.Command as `sh -c`, passing mission state through a temp JSON file and the stable SPECD_* environment contract.

Jump to

Keyboard shortcuts

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