execution

package
v0.175.0-rc.443 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 49 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 execution manages owned harness processes on SSH execution hosts. Transport reachability never establishes whether a task or process ended.

Index

Constants

View Source
const (
	GitHubOrigin  = "origin"
	GitHubGitTool = "git"
)
View Source
const (
	MessageWake = "wake"

	Stored    = "stored"
	Accepted  = "accepted"
	Uncertain = "uncertain"
	Resolved  = "resolved"
)
View Source
const (

	// RetireRequested, RetirePreserved and RetireRetired are the stages of the
	// one retirement every terminal path enters. A stage is durable before the
	// next begins, and each step is safe to repeat. RetireNoJournal answers a
	// retirement of an execution its host holds no journal of: nothing
	// journal-backed is left, which is not a claim about unowned files.
	RetireRequested = "requested"
	RetirePreserved = "preserved"
	RetireRetired   = "retired"
	RetireNoJournal = "no-journal"

	// The triggers that enter a retirement. They differ in why, never in how.
	RetireTriggerReport      = "report"
	RetireTriggerStop        = "stop"
	RetireTriggerFailedStart = "failed-start"
	RetireTriggerCrash       = "crash"

	// The resource kinds of an execution's inventory.
	ResourceExecutionRoot  = "execution-root"
	ResourceWorktree       = "worktree"
	ResourceRepository     = "repository"
	ResourceBranch         = "branch"
	ResourceUpstreamBranch = "upstream-branch"
	ResourceScratch        = "scratch"
	ResourceTemporary      = "temporary"
	ResourceCache          = "cache"
	ResourceToolchain      = "toolchain"
	ResourceSourceBundle   = "source-bundle"
	ResourceCredential     = "credential-handle" //nolint:gosec // a resource kind, not a credential
	ResourceMCPHome        = "mcp-home"

	// DefaultRetention is how long moved-aside resources are kept when the host
	// configures no retention, the same week the desk gives its aside entries.
	DefaultRetention = 7 * 24 * time.Hour
)
View Source
const (
	HarnessClaude = "claude"
	HarnessCodex  = "codex"
	HarnessAgy    = "agy"
	Preparing     = "preparing"
	Activating    = "activating"
	Applied       = "applied"
	ControlNote   = "note"
	ControlPark   = "park"
	ControlResume = "resume"
	ControlReport = "report"

	Protocol       = 1
	EnvID          = "BEEKEEPER_EXECUTION_ID"
	EnvCoordinator = "BEEKEEPER_EXECUTION_COORDINATOR"
	EnvHome        = "BEEKEEPER_EXECUTION_HOME"
	MaxWire        = 1 << 20
	MaxLog         = 256 << 10
	Prepared       = "prepared"
	Running        = "running"
	Exited         = "exited"
	Failed         = "failed"
	Unknown        = "unknown"
	Reachable      = "reachable"
	Unreachable    = "unreachable"
)
View Source
const (
	ToolGo          = "go"
	ToolGitHub      = "gh"
	PinnedToolsFile = "tools.json"
)

ToolGo and ToolGitHub are the worker toolchain a host provisions next to its harness: Go for the repositories whose source checkout has a go.mod, and the GitHub CLI on every host.

View Source
const (
	GitHubLoggedIn  = "logged-in"
	GitHubLoggedOut = "logged-out"
)

GitHubLoggedIn and GitHubLoggedOut are the host's own gh login.

View Source
const (
	WorkerGitName  = "beekeeper"
	WorkerGitEmail = "beekeeper@execution.invalid"
)

WorkerGitName and WorkerGitEmail are the commit identity of a prepared workspace whose execution user has none of their own.

View Source
const AgyVersions = ">= 1.4.7, < 2.0.0"

The agy adapter relies on `--input-format stream-json --output-format stream-json`, `--conversation` resume, and PreToolUse hooks from `~/.gemini/config/hooks.json` under the project name key (agy >= 1.4.7).

View Source
const BundleSchema = 1
View Source
const CIRerun = "ci-rerun"

CIRerun requests a coordinator-owned CI rerun without exporting credentials.

View Source
const ClaudeVersions = ">= 2.1.268, < 3.0.0"

The adapter relies on restricted settings and auth status's configDirectory contract. Pin an exact installed version inside this supported CLI family.

View Source
const CodexVersions = ">= 0.165.0, < 1.0.0"

The codex adapter relies on `exec --json` thread events, `exec resume`, PreToolUse hooks from CODEX_HOME and --dangerously-bypass-hook-trust.

View Source
const HarnessOmp = "omp"
View Source
const LeaseDuration = 90 * time.Second
View Source
const LeaseRenewal = 20 * time.Second
View Source
const LogRetention = 30 * 24 * time.Hour
View Source
const MCPCall = "mcp-call"
View Source
const MCPList = "mcp-list"
View Source
const MaxSourceBasis = 256

MaxSourceBasis bounds the commits one basis reply names.

View Source
const MaxSourceBundle = 64 << 20
View Source
const MergeSucceeded = "merged"
View Source
const OmpVersions = ">= 18.14.2, < 19.0.0"

Pin the protocol and extension API family proven by this adapter.

View Source
const SourceBasisOperation = "source-basis"

SourceBasisOperation asks a host which commits of a repository a new workspace there already holds, so the coordinator bundles only the rest.

View Source
const SourceChunkSize = 256 << 10
View Source
const UpdateTimeout = 5 * time.Minute

UpdateTimeout bounds a host update: the download, its verification, the new release's prepare and a rollback.

Variables

View Source
var ErrCoordinatorBusy = errors.New("coordinator lease state commit busy")

ErrCoordinatorBusy crosses the callback boundary as a fixed diagnostic; host journals never retain arbitrary coordinator errors or SSH output.

View Source
var ErrNotFound = errors.New("execution journal not found")

ErrNotFound means an inspected execution has no host journal. Other inspection failures never authorize creating or changing a preparation.

View Source
var ErrUnfinished = errors.New("execution is unfinished: its owned unit is not confirmed ended")

ErrUnfinished refuses the retirement of an execution that may still run or resume. A parked worker between turns is one: it keeps its worktree and thread.

View Source
var ErrUnsupported = errors.New("message acceptance is unavailable for this SSH execution or adapter; inspect the original execution before recovery")

Functions

func CanContinue

func CanContinue(harness string) bool

CanContinue says harness can take a conversation up again in a new process. omp's runner starts a fresh session and has no way back into an old one.

func CheckTools

func CheckTools(have, need map[string]string) error

CheckTools verifies that the reported host tools satisfy the minimum versions required by the served repositories.

func CoordinatorCall

func CoordinatorCall(ctx context.Context, endpoint Endpoint, host, op string, ref Ref, payload any, key string, result any, run CommandRunner) error

func Decode

func Decode(raw []byte, v any) error

func Digest

func Digest(b []byte) string

func GatewayMCP

func GatewayMCP(ctx context.Context, servers map[string]MCPServer, op string, request MCPCallRequest) (any, error)

GatewayMCP enforces the current coordinator allowlist for discovery AND calls. An unexposed call is refused before any upstream connection or side effect.

func GitHubBranch

func GitHubBranch(ref Ref) string

GitHubBranch is the one upstream branch assigned to this execution.

func GitHubGitVerb

func GitHubGitVerb(args []string) string

GitHubGitVerb skips git's global options so unauthenticated local commands retain normal semantics. Network operations reject such overrides separately.

func GitHubReadRepository

func GitHubReadRepository(args []string) (string, []string, bool)

GitHubReadRepository scopes explicit read transports to their named repository. Clone destinations and fetch refspecs stay client arguments, never authority.

func GitHubRepository

func GitHubRepository(args []string, fallback string) (string, error)

GitHubRepository determines the scope of one gh invocation. Cross-owner calls must name their repository explicitly; global auth/search commands have no safely bounded repository scope.

func GitHubWrite

func GitHubWrite(args []string) (bool, error)

GitHubWrite classifies one gh subcommand. The token behind a read is as write-capable as any other, so a subcommand named in neither table, a later gh release's included, is refused rather than dispatched as a read.

func GitHubWriteRepository

func GitHubWriteRepository(args []string, fallback string) (string, error)

GitHubWriteRepository is the single repository a write acts on. gh prefers a URL target over --repo, so GitHubRepository's last-match reading could vouch for one owner while gh writes to another: every target must agree. Text that starts with a GitHub URL of another repository goes through --body-file.

func HostPath

func HostPath(s string) bool

func MCPProxy

func MCPProxy(ctx context.Context, call MCPCallback) (*mcpserver.MCPServer, error)

MCPProxy is the worker's stdio gateway. Every tool use returns to the coordinator so cached discovery never grants authority after revocation.

func NewControlKey

func NewControlKey() (string, error)

func PublicKey

func PublicKey(k ed25519.PrivateKey) string

func ReportOrphans

func ReportOrphans(rows []ResourceFinding, coordinator string, registered []Ref)

ReportOrphans joins the host's resources with a desk's registered execution inventory. Other coordinators' resources are accounted for, never adopted. An orphan remains in its observed active/parked/terminal/unknown state.

func RepositoriesTools

func RepositoriesTools(repositories map[string]string) (map[string]string, error)

RepositoriesTools names each tool a worker needs for repositories and the lowest version that serves it: gh everywhere, Go at the highest toolchain (or go line) any repository's go.mod names.

func RepositoryIdentity

func RepositoryIdentity(raw string) string

RepositoryIdentity accepts the canonical public GitHub transport forms, without passwords, query strings or a caller-selected credential helper.

func SSHArgv

func SSHArgv(e Endpoint, connect time.Duration, command string) []string

func SSHCommand

func SSHCommand(ctx context.Context, argv []string, stdin []byte) ([]byte, error)

func Sign

func Sign(r StartRequest, key ed25519.PrivateKey, now time.Time) string

func SigningKey

func SigningKey(root string) (ed25519.PrivateKey, error)

SigningKey creates a coordinator key once. Only its public half is ever returned to an operator; provision that half on the host independently.

func SupportedHarness added in v0.174.0

func SupportedHarness(h string) bool

SupportedHarness names the harnesses with a remote adapter. Every other harness starts on the coordinating machine only.

func SyncCurrentBundle

func SyncCurrentBundle(ctx context.Context, c BundleSyncer, b CoordinatorBundle) (string, error)

SyncCurrentBundle makes b available on the host and returns the digest a start binds. It transfers only what the host lacks; any failure starts no worker.

func UnitName

func UnitName(r Ref) string

func ValidDigest

func ValidDigest(s string) bool

func ValidIdentity

func ValidIdentity(s string) bool

func ValidateGitHubAPIRead

func ValidateGitHubAPIRead(args []string) error

ValidateGitHubAPIRead parses the arguments after `gh api` the way gh does, so that only GET and HEAD reach the shared token. A field makes gh default to POST and stays a query parameter only under an explicit read method; a flag not listed here, --input and --hostname among them, is refused. GraphQL's POST passes only as a read that is literal in full (github.GraphQLRead).

func ValidateHandle

func ValidateHandle(h Host, r StartRequest, x Handle) error

func ValidateMCP

func ValidateMCP(servers map[string]MCPServer) error

func ValidateWorkerPush

func ValidateWorkerPush(args []string, branch string) error

func Verify

func Verify(r StartRequest, key string, now time.Time) error

func VerifyCallback

func VerifyCallback(r CallbackRequest, key string) bool

func VerifyLease

func VerifyLease(grant LeaseGrant, request LeaseRequest, ref Ref, coordinator, key string) error

func WriteMergeAuthorization

func WriteMergeAuthorization(root string, grant MergeAuthorization, action string, now time.Time) error

The caller serializes this durable ledger with the coordinating state lock. It records consumption before invoking GitHub, so a crash can never replay a merge. Reconciliation may read GitHub but never repeats a consumed attempt.

Types

type Ack

type Ack struct {
	ID       string `json:"id"`
	Sequence uint64 `json:"sequence"`
	Stage    string `json:"stage"`
}

type ActivationDecision

type ActivationDecision struct {
	Allowed bool `json:"allowed"`
}

ActivationDecision is a fresh coordinator answer, never a cached grant.

type BundleArtifact

type BundleArtifact struct {
	BundleSource
	Digest  string `json:"digest"`
	Content []byte `json:"content"`
}

type BundleCapability

type BundleCapability struct {
	Name     string `yaml:"name" json:"name"`
	Required bool   `yaml:"required" json:"required"`
}

BundleCapability declares a dependency, never connector configuration or credentials.

type BundleReport

type BundleReport struct {
	Expected  string   `json:"expected"`
	Installed string   `json:"installed,omitempty"`
	Current   bool     `json:"current"`
	Differs   []string `json:"differs,omitempty"`
	Problem   string   `json:"problem,omitempty"`
}

BundleReport is the coordinator's comparison in hosts check. Differs names the artifacts of the expected bundle the host's newest one lacks or holds otherwise.

type BundleSource

type BundleSource struct {
	Source   string `yaml:"source" json:"source"`
	Artifact string `yaml:"artifact" json:"artifact"`
}

BundleSource explicitly approves one file. Directories are never harvested. Rules use rules/<name>/AGENTS.md or CLAUDE.md; skills use skills/<name>/... ; plugins use plugins/<name>/skills/<skill>/... and plugins/<name>/commands/<file>.md.

type BundleStatus

type BundleStatus struct {
	Digest    string            `json:"digest"`
	Installed bool              `json:"installed"`
	Problem   string            `json:"problem,omitempty"`
	Latest    string            `json:"latest,omitempty"`
	Artifacts map[string]string `json:"artifacts,omitempty"`
}

BundleStatus is the host's answer about one bundle digest. Installed says that digest is whole and unchanged; Problem says why one that exists cannot be used. Latest is the newest whole bundle, and Artifacts its path to content digest: metadata only, so a coordinator can name what differs.

type BundleSyncer

type BundleSyncer interface {
	BundleStatus(context.Context, string) (BundleStatus, error)
	SyncBundle(context.Context, CoordinatorBundle) (string, error)
}

BundleSyncer is the optional host operation behind a start's synchronization.

type CallbackRequest

type CallbackRequest struct {
	WireRequest
	Proof string `json:"proof"`
}

type Capabilities

type Capabilities struct {
	ResourceAudit []ResourceFinding `json:"resourceAudit,omitempty"`
	// PolicyBundle compares the coordinator's current bundle with what the host
	// holds. hosts check fills it; the host's own check leaves it empty.
	PolicyBundle *BundleReport `json:"policyBundle,omitempty"`
	// Sources compares each mapped host source with its default branch.
	// hosts check fills it; the host's own check leaves it empty.
	Sources []SourceReport `json:"sources,omitempty"`
	CIWait  bool           `json:"ciWait"`
	// SourcePreparation promises source-chunk upload and typed not-found
	// responses when inspecting an execution whose journal does not exist.
	SourcePreparation bool `json:"sourcePreparation"`
	// GitHub says a worker here can read GitHub. The host only promises the
	// protocol; the coordinator's check settles it against GitHubLogin and its
	// worker App.
	GitHub bool `json:"github,omitempty"`
	// GitHubLogin is the host's own gh login, empty from an older host.
	GitHubLogin  string            `json:"githubLogin,omitempty"`
	Publication  bool              `json:"publication"`
	Protocol     int               `json:"protocol"`
	Identity     HostID            `json:"identity"`
	Version      string            `json:"version"`
	PolicyDigest string            `json:"policyDigest"`
	Harnesses    map[string]string `json:"harnesses"`
	// Unavailable names each configured harness that failed its version,
	// login or guard probe. The host advertises only the passing ones.
	Unavailable map[string]string           `json:"unavailable,omitempty"`
	Readiness   map[string]HarnessReadiness `json:"readiness,omitempty"`
	// Tools names each provisioned worker tool and its pinned version.
	Tools     map[string]string `json:"tools,omitempty"`
	Resources Resources         `json:"resources"`
}

type CommandRunner

type CommandRunner func(context.Context, []string, []byte) ([]byte, error)

CommandRunner is replaced by tests; production uses SSHCommand.

type ContinueRequest

type ContinueRequest struct {
	Receipt string `json:"receipt"`
}

ContinueRequest asks a host to run an exited execution again. Receipt is a fresh coordinator signature over the execution's own start request: a registration receipt lives a minute, a parked worker much longer.

type Continuer

type Continuer interface {
	Continue(context.Context, Ref, ContinueRequest) (Handle, error)
}

Continuer is a transport that can run an exited execution again.

type ControlLedger

type ControlLedger struct {
	Sequence uint64                   `json:"sequence"`
	Results  map[string]ControlResult `json:"results,omitempty"`
}

ControlLedger belongs to one registered execution on the coordinator. Persist it in the same transaction as the mutation apply performs.

func (*ControlLedger) Apply

func (l *ControlLedger) Apply(expected Ref, request ControlRequest, apply func() (string, error)) (ControlResult, error)

Apply returns the original receipt for an exact replay, including an application refusal. Protocol conflicts and gaps call apply zero times. The callback must validate before mutation: a refusal is acknowledged and persisted, so its domain state must remain unchanged on an error.

type ControlRequest

type ControlRequest struct {
	Ref       Ref             `json:"ref"`
	ID        string          `json:"id"`
	Sequence  uint64          `json:"sequence"`
	Operation string          `json:"operation"`
	Data      json.RawMessage `json:"data"`
}

ControlRequest is a host-to-coordinator mutation. Its sequence and receipt survive both processes; it cannot grant authority or select a caller.

func (ControlRequest) ContentDigest

func (r ControlRequest) ContentDigest() string

type ControlResult

type ControlResult struct {
	ID       string `json:"id"`
	Sequence uint64 `json:"sequence"`
	Digest   string `json:"digest"`
	Output   string `json:"output"`
	Error    string `json:"error,omitempty"`
}

type ControlSyncer

type ControlSyncer interface {
	SyncControl(context.Context, Ref) (ControlResult, error)
}

ControlSyncer is the optional host outbox reconciliation operation. It does not implement worker wake acceptance, which remains unsupported.

type Coordinator

type Coordinator struct {
	PublicKey string   `yaml:"publicKey" json:"publicKey"`
	Callback  Endpoint `yaml:"callback" json:"callback"`
}

type CoordinatorBundle

type CoordinatorBundle struct {
	Schema       int                `json:"schema"`
	Artifacts    []BundleArtifact   `json:"artifacts"`
	Settings     map[string]string  `json:"settings,omitempty"`
	Capabilities []BundleCapability `json:"capabilities,omitempty"`
}

func BuildCoordinatorBundle

func BuildCoordinatorBundle(root string, sources []BundleSource, settings map[string]string, capabilities []BundleCapability, secretFiles []string) (CoordinatorBundle, error)

BuildCoordinatorBundle captures only explicitly approved files below root. secretFiles supplies the coordinator's configured secret-store exclusions.

func (CoordinatorBundle) Compare

Compare reports expected against the host's status. A host behind is not a fault: the next start transfers the bundle.

func (CoordinatorBundle) Digest

func (b CoordinatorBundle) Digest() string

func (CoordinatorBundle) Validate

func (b CoordinatorBundle) Validate() error

type Delivery

type Delivery struct {
	Resolution string   `json:"resolution,omitempty"`
	Envelope   Envelope `json:"envelope"`
	Digest     string   `json:"digest"`
	Stage      string   `json:"stage"`
}

func (Delivery) Ack

func (d Delivery) Ack() Ack

type Endpoint

type Endpoint struct {
	SSH        string `yaml:"ssh" json:"ssh"`
	Executable string `yaml:"executable" json:"executable"`
	Config     string `yaml:"config" json:"config"`
}

Endpoint names an operator-provisioned SSH route, never shell source.

func (Endpoint) Validate

func (e Endpoint) Validate() error

type Envelope

type Envelope struct {
	Sender   Sender `json:"sender"`
	ID       string `json:"id"`
	Sequence uint64 `json:"sequence"`
	From     Ref    `json:"from"`
	To       Ref    `json:"to"`
	Kind     string `json:"kind"`
	Text     string `json:"text"`
}

type ExecutionID

type ExecutionID string

type Handle

type Handle struct {
	Ref            Ref    `json:"ref"`
	Repository     string `json:"repository"`
	Commit         string `json:"commit"`
	Workspace      string `json:"workspace"`
	Unit           string `json:"unit"`
	ConversationID string `json:"conversationID"`
}

type HarnessConfig

type HarnessConfig struct {
	Executable string `yaml:"executable" json:"executable"`
	Version    string `yaml:"version" json:"version"`
	ConfigDir  string `yaml:"configDir,omitempty" json:"configDir,omitempty"`
}

type HarnessReadiness

type HarnessReadiness struct {
	Version      string `json:"version"`
	VersionCheck string `json:"versionCheck"`
	Login        string `json:"login"`
	Guard        string `json:"guard"`
}

HarnessReadiness reports only probe outcomes and the pinned version, never authentication output. A skipped check must not be mistaken for a pass.

type Host

type Host struct {
	Endpoint      `yaml:",inline"`
	Identity      HostID            `yaml:"identity" json:"identity"`
	WorkspaceRoot string            `yaml:"workspaceRoot" json:"workspaceRoot"`
	Repositories  map[string]string `yaml:"repositories" json:"repositories"`
	// RepositoryOrgs admits coordinator-bundled repositories without a source mapping.
	RepositoryOrgs   []string `yaml:"repositoryOrgs,omitempty" json:"repositoryOrgs,omitempty"`
	Harnesses        []string `yaml:"harnesses" json:"harnesses"`
	PolicyDigest     string   `yaml:"policyDigest" json:"policyDigest"`
	MaxBusy          int      `yaml:"maxBusy" json:"maxBusy"`
	ConnectTimeout   string   `yaml:"connectTimeout,omitempty" json:"connectTimeout,omitempty"`
	OperationTimeout string   `yaml:"operationTimeout,omitempty" json:"operationTimeout,omitempty"`
}

Host is the coordinator's agents.hosts entry. Timeouts are seconds so the execution contract has no dependency on the configuration package. PolicyDigest is the digest every start on the host is pinned to: the one beekeeper recorded when it last updated the host (agents hosts update), or, for a host it never updated, the entry's own deprecated value.

func (Host) AdmitsRepository

func (h Host) AdmitsRepository(repo string) bool

AdmitsRepository reports whether this host can prepare the repository.

func (Host) Supports added in v0.174.0

func (h Host) Supports(harness string) bool

Supports reports whether the operator lists harness for this host.

func (Host) Validate

func (h Host) Validate() error

func (Host) ValidateCatalog

func (h Host) ValidateCatalog() error

ValidateCatalog validates the entry as agents.hosts names it: the policy digest is beekeeper's own state, so the entry may leave it out, and one it still names must be a digest.

type HostCommand

type HostCommand func(context.Context, string, []string, string, ...string) ([]byte, error)

type HostConfig

type HostConfig struct {
	RulesFile     string            `yaml:"rulesFile" json:"rulesFile"`
	Identity      HostID            `yaml:"identity" json:"identity"`
	WorkspaceRoot string            `yaml:"workspaceRoot" json:"workspaceRoot"`
	Repositories  map[string]string `yaml:"repositories" json:"repositories"`
	// RepositoryOrgs admits coordinator-bundled repositories without a source mapping.
	RepositoryOrgs []string                 `yaml:"repositoryOrgs,omitempty" json:"repositoryOrgs,omitempty"`
	Harnesses      map[string]HarnessConfig `yaml:"harnesses" json:"harnesses"`
	Coordinators   map[string]Coordinator   `yaml:"coordinators" json:"coordinators"`
	MaxBusy        int                      `yaml:"maxBusy" json:"maxBusy"`
	// Tools pins the worker toolchain (go, gh) a worker calls by bare name.
	// Omitted, it leaves the configuration digest of a host without it as is.
	Tools map[string]ToolConfig `yaml:"tools,omitempty" json:"tools,omitempty"`
	// Retention is how long a retired execution's moved-aside resources are
	// kept, a Go duration. Omitted, it is DefaultRetention and leaves the
	// configuration digest of a host without it as is.
	Retention string `yaml:"retention,omitempty" json:"retention,omitempty"`
	// SharedHome keeps workers on the account's HOME instead of one in their
	// execution root. Omitted, it leaves the configuration digest as it is.
	SharedHome bool `yaml:"sharedHome,omitempty" json:"sharedHome,omitempty"`
}

HostConfig is operator-owned configuration on the execution host. It is never replaced by a request, a brief or the coordinator's filesystem paths.

func (HostConfig) Validate

func (c HostConfig) Validate() error

type HostID

type HostID string

type HostUpdate

type HostUpdate struct {
	Protocol     int    `json:"protocol"`
	Identity     HostID `json:"identity,omitempty"`
	Version      string `json:"version,omitempty"`
	PolicyDigest string `json:"policyDigest,omitempty"`
	Busy         int    `json:"busy,omitempty"`
	Executions   []Ref  `json:"executions,omitempty"`
	Error        string `json:"error,omitempty"`
}

HostUpdate is the answer of an execution host's `agents hosts self-update`: the release it runs and the digest of the policy it prepared for it. Busy counts the executions that still run there, when it changed nothing for them; Error is why the update failed, the host left on its old release.

func UpdateHost

func UpdateHost(ctx context.Context, h Host, version string, release []byte, run CommandRunner) (HostUpdate, error)

UpdateHost has host h install release version, verified, and prepare the policy of it (agents hosts self-update over the host's SSH route). The answer is checked against the host's identity: a busy host, or one that answers the release and a digest, is an answer; anything else an error. release is the coordinator's lookup of version, sent on the command's standard input so that the host does not ask GitHub's API itself; a host on a release that does not read it looks the release up on its own.

type Inspector

type Inspector interface {
	Inspect(context.Context, Ref) (Observation, error)
}

type InventoryReader

type InventoryReader interface {
	Inventory(context.Context, string) ([]Ref, error)
	Missing(context.Context, Ref) (bool, error)
}

InventoryReader lists only journal-backed executions of one coordinator. Missing confirms both journal absence and an inactive owned unit; a missing journal alone never proves that a process ended.

type Journal

type Journal struct {
	RetainedAt          time.Time            `json:"retainedAt,omitzero"`
	RevocationFailed    bool                 `json:"revocationFailed,omitempty"`
	Lease               *LeaseGrant          `json:"lease,omitempty"`
	LeaseFailure        *LeaseRenewalFailure `json:"leaseFailure,omitempty"`
	LeasePending        *LeaseRequest        `json:"leasePending,omitempty"`
	Completed           bool                 `json:"completed,omitempty"`
	Messages            MessageLedger        `json:"messages,omitempty"`
	ActivationAttempted bool                 `json:"activationAttempted"`
	RunnerPID           int                  `json:"runnerPID,omitempty"`
	RunnerStarted       time.Time            `json:"runnerStarted,omitempty"`
	LastActive          time.Time            `json:"lastActive,omitzero"`
	Request             StartRequest         `json:"request"`
	Digest              string               `json:"digest"`
	Handle              Handle               `json:"handle"`
	Phase               string               `json:"phase"`
	Ready               bool                 `json:"ready"`
	InTurn              bool                 `json:"inTurn,omitempty"`
	StopRequest         *StopRequest         `json:"stopRequest,omitempty"`
	StopAcknowledged    bool                 `json:"stopAcknowledged"`
	LastError           string               `json:"lastError,omitempty"`
	// Thread is the codex thread the first turn created; every later turn
	// resumes it and the codex guard binds tool calls to it. Claude's
	// conversation is the request's own identity and leaves it empty.
	Thread string `json:"thread,omitempty"`
	// Policy is the host policy a coordinator-approved rebind moved this
	// execution onto; empty, it is the signed request's own policy.
	Policy string `json:"policy,omitempty"`
	// Resources is the inventory of what this execution owns on its host,
	// durable before any of it is created; Retirement is the one retirement
	// that ends them, nil until a terminal path enters it.
	Resources  []Resource  `json:"resources,omitempty"`
	Retirement *Retirement `json:"retirement,omitempty"`
	// Disposable says preservation proved there was nothing to keep: no recovery
	// and no ignored files. Only then does a purge remove what moved aside, so a
	// journal retired without it stays. PurgedAt is when it did. Both stay on the
	// host: a coordinator refuses a Retirement with fields it does not know.
	Disposable bool      `json:"disposable,omitempty"`
	PurgedAt   time.Time `json:"purgedAt,omitzero"`
}

func (Journal) BoundPolicy

func (j Journal) BoundPolicy() string

BoundPolicy is the policy digest the execution's host-side commands require the host's prepared policy to match.

type LeaseGrant

type LeaseGrant struct {
	Ref         Ref       `json:"ref"`
	Coordinator string    `json:"coordinator"`
	Sequence    uint64    `json:"sequence"`
	Nonce       string    `json:"nonce"`
	IssuedAt    time.Time `json:"issuedAt"`
	ExpiresAt   time.Time `json:"expiresAt"`
	Signature   string    `json:"signature"`
}

func IssueLease

func IssueLease(ref Ref, coordinator string, previous *LeaseGrant, request LeaseRequest, key ed25519.PrivateKey, now time.Time) (LeaseGrant, error)

IssueLease is called inside the coordinator's stop/renewal transaction. A repeated request returns its original deadline, never another lease interval.

type LeaseRenewalFailure

type LeaseRenewalFailure struct {
	At       time.Time     `json:"at"`
	Duration time.Duration `json:"duration"`
	Stage    string        `json:"stage"`
	Kind     string        `json:"kind"`
	Sequence uint64        `json:"sequence"`
	Count    uint64        `json:"count"`
}

renewLease persists the challenge before calling the coordinator, and stores its signed response before granting runtime. The caller measures deadlines from BEFORE the request with a monotonic clock; host wall-clock skew never extends authority. An uncertain retry keeps the original challenge and time. LeaseRenewalFailure retains only bounded metadata, never callback stderr, control keys, signatures, transcripts or host routes.

type LeaseRequest

type LeaseRequest struct {
	Previous uint64 `json:"previous"`
	Nonce    string `json:"nonce"`
}

type LogPage

type LogPage struct {
	Data      []byte `json:"data"`
	Next      string `json:"next"`
	Truncated bool   `json:"truncated"`
}

type LogRequest

type LogRequest struct {
	After string `json:"after"`
	Limit int    `json:"limit"`
}

type Logger

type Logger interface {
	Logs(context.Context, Ref, LogRequest) (LogPage, error)
}

type MCPCallRequest

type MCPCallRequest struct {
	Name      string         `json:"name"`
	Arguments map[string]any `json:"arguments,omitempty"`
}

type MCPCallback

type MCPCallback func(context.Context, string, any, any) error

type MCPServer

type MCPServer struct {
	URL     string   `yaml:"url,omitempty"`
	Command string   `yaml:"command,omitempty"`
	Args    []string `yaml:"args,omitempty"`
	Tools   []string `yaml:"tools"`
}

MCPServer is coordinator-only configuration. Credentials and local commands never travel to a worker. Empty Tools exposes nothing; wildcards are not used.

type MergeAudit

type MergeAudit struct {
	At     time.Time `json:"at"`
	Action string    `json:"action"`
}

type MergeAuthorization

type MergeAuthorization struct {
	ReviewDigest string       `json:"reviewDigest"`
	DeskReviewID string       `json:"deskReviewID"`
	ReviewID     string       `json:"reviewID"`
	ID           string       `json:"id"`
	Ref          Ref          `json:"ref"`
	Repository   string       `json:"repository"`
	PR           int          `json:"pr"`
	Head         string       `json:"head"`
	Issuer       string       `json:"issuer"`
	IssuedAt     time.Time    `json:"issuedAt"`
	ExpiresAt    time.Time    `json:"expiresAt"`
	Revoked      bool         `json:"revoked"`
	Consumed     bool         `json:"consumed"`
	Outcome      string       `json:"outcome,omitempty"`
	Audit        []MergeAudit `json:"audit"`
}

MergeAuthorization is coordinator-owned. It is never a bearer credential: every use also authenticates the exact owned execution with the live service.

func ReadMergeAuthorization

func ReadMergeAuthorization(root, id string) (MergeAuthorization, error)

func (MergeAuthorization) Admits

func (g MergeAuthorization) Admits(use MergeUse, now time.Time) error

type MergeResult

type MergeResult struct {
	ID      string `json:"id"`
	Outcome string `json:"outcome"`
}

func UseMerge

func UseMerge(ctx context.Context, root string, use MergeUse, now time.Time, live func(context.Context) error, merge func(context.Context) error) (MergeResult, error)

UseMerge performs one synchronous attempt under the caller's coordinating state transaction. Stop, holds and revocation therefore cannot commit between the live check and command execution. No detached child is permitted.

type MergeUse

type MergeUse struct {
	ID         string `json:"id"`
	Ref        Ref    `json:"ref"`
	Repository string `json:"repository"`
	PR         int    `json:"pr"`
	Head       string `json:"head"`
}

type MessageLedger

type MessageLedger struct {
	Sequence uint64              `json:"sequence"`
	Entries  map[string]Delivery `json:"entries,omitempty"`
}

MessageLedger keeps receipts for the execution's lifetime. Sequence only advances on acceptance; gaps stay stored and an uncertain send blocks replay.

func (*MessageLedger) Accept

func (l *MessageLedger) Accept(id string) error

func (*MessageLedger) Attempt

func (l *MessageLedger) Attempt(m Envelope) error

func (*MessageLedger) Next

func (l *MessageLedger) Next() (Envelope, bool)

func (*MessageLedger) Resolve

func (l *MessageLedger) Resolve(q MessageResolution) (Ack, error)

Resolve explicitly skips a blocked receipt. It records operator intent, not harness acceptance, and never retries an uncertain write.

func (MessageLedger) Status

func (l MessageLedger) Status() []Delivery

Status excludes message text but retains identity and evidence for operators.

func (*MessageLedger) Store

func (l *MessageLedger) Store(ref Ref, m Envelope) (Ack, error)

type MessageResolution

type MessageResolution struct {
	ID     string `json:"id"`
	Reason string `json:"reason"`
}

type MessageResolver

type MessageResolver interface {
	ResolveMessage(context.Context, Ref, MessageResolution) (Ack, error)
}

type Messenger

type Messenger interface {
	Message(context.Context, Ref, Envelope) (Ack, error)
}

type Observation

type Observation struct {
	Lease            *LeaseGrant `json:"lease,omitempty"`
	Messages         []Delivery  `json:"messages,omitempty"`
	MessageSequence  uint64      `json:"messageSequence,omitempty"`
	Handle           Handle      `json:"handle"`
	ProcessState     string      `json:"processState"`
	Reachability     string      `json:"reachability"`
	ObservedAt       time.Time   `json:"observedAt"`
	ReachabilityAt   time.Time   `json:"reachabilityAt"`
	LastActive       time.Time   `json:"lastActive,omitzero"`
	Ready            bool        `json:"ready"`
	InTurn           bool        `json:"inTurn,omitempty"`
	StopRequested    bool        `json:"stopRequested"`
	StopAcknowledged bool        `json:"stopAcknowledged"`
	LastError        string      `json:"lastError,omitempty"`
	// PolicyDigest is the policy the execution's host-side commands are bound
	// to; HostPolicyDigest is the host's prepared policy, empty when it is
	// unprepared or stale. A difference leaves the unit running while its
	// publication, merge and capped runs refuse until a policy rebind.
	PolicyDigest     string `json:"policyDigest,omitempty"`
	HostPolicyDigest string `json:"hostPolicyDigest,omitempty"`
}

func (Observation) BetweenTurns

func (o Observation) BetweenTurns() bool

BetweenTurns says the observed execution runs, accepted its first task and waits for a wake: no turn runs, none is stored to begin and no delivery is uncertain. A host update goes ahead under it (Quiesce).

func (Observation) FailedContact

func (o Observation) FailedContact(err error, now time.Time) Observation

FailedContact preserves the last process evidence. A transport failure never establishes completion, releases capacity or changes a worker's task.

func (Observation) PolicyAvailable

func (o Observation) PolicyAvailable() bool

PolicyAvailable reports whether the execution's host-side commands accept the host's prepared policy. Hosts that predate the fields report neither.

type Policy

type Policy struct {
	Protocol            int    `json:"protocol"`
	Version             string `json:"version"`
	ConfigurationDigest string `json:"configurationDigest"`
	RulesDigest         string `json:"rulesDigest"`
	SettingsDigest      string `json:"settingsDigest"`
	// CodexDigest binds the managed CODEX_HOME's config, hooks and rules. It
	// is empty on a host that runs no codex, leaving its policy unchanged.
	CodexDigest string `json:"codexDigest,omitempty"`
	OmpDigest   string `json:"ompDigest,omitempty"`
	// AgyDigest binds the managed agy home's config, hooks and rules. It is
	// empty on a host that runs no agy, leaving its policy unchanged.
	AgyDigest string `json:"agyDigest,omitempty"`
}

func (Policy) Digest

func (p Policy) Digest() string

type PolicyRebind

type PolicyRebind struct {
	From string `json:"from"`
	To   string `json:"to"`
}

PolicyRebind moves a running execution from the policy it is bound to onto the host's prepared policy, once the coordinator approved that policy.

type PolicyRebinder

type PolicyRebinder interface {
	RebindPolicy(context.Context, Ref, PolicyRebind) (Observation, error)
}

PolicyRebinder is the optional host operation behind agents recover after an approved host-policy update.

type Receipt

type Receipt struct {
	Ref         Ref       `json:"ref"`
	Coordinator string    `json:"coordinator"`
	Digest      string    `json:"digest"`
	ExpiresAt   time.Time `json:"expiresAt"`
	Signature   string    `json:"signature"`
}

type Recovery

type Recovery struct {
	Ref          string `json:"ref"`
	Commit       string `json:"commit"`
	Base         string `json:"base"`
	Head         string `json:"head"`
	Branch       string `json:"branch,omitempty"`
	Dirty        bool   `json:"dirty,omitempty"`
	Bundle       string `json:"bundle"`
	BundleDigest string `json:"bundleDigest"`
	Repository   string `json:"repository"`
}

Recovery is the durable reference to work a retirement preserved. Commit is one commit reaching the worker's head, its branch, what only its reflogs still reach and a snapshot of its dirty and untracked files. Bundle holds it past Base; Repository is the moved-aside repository, which also keeps Ref and every other ref of the worker.

type Ref

type Ref struct {
	Host       HostID      `json:"host"`
	Execution  ExecutionID `json:"execution"`
	Generation uint64      `json:"generation"`
}

func (Ref) Key

func (r Ref) Key() string

func (Ref) Validate

func (r Ref) Validate() error

type Resource

type Resource struct {
	Owner Ref    `json:"owner"`
	Kind  string `json:"kind"`
	Path  string `json:"path,omitempty"`
	Ref   string `json:"ref,omitempty"`
	Aside string `json:"aside,omitempty"`
}

Resource is one thing an execution owns on its host, recorded against the execution before it exists. Aside is where retirement moves it; a resource without one travels with its execution root or, for an upstream branch, stays as publication evidence. Journals, logs and control receipts are evidence, not resources: they stay until the host's retention says otherwise.

type ResourceFinding

type ResourceFinding struct {
	Orphan      bool      `json:"orphan,omitempty"`
	Ref         Ref       `json:"ref"`
	Coordinator string    `json:"coordinator,omitempty"`
	Path        string    `json:"path"`
	State       string    `json:"state"`
	Reason      string    `json:"reason"`
	Retry       string    `json:"retry"`
	RetainedAt  time.Time `json:"retainedAt,omitzero"`
	EligibleAt  time.Time `json:"eligibleAt,omitzero"`
}

ResourceFinding contains metadata only, never journal secrets or file contents.

type Resources

type Resources struct {
	Blocks        []string  `json:"blocks,omitempty"`
	BuildBlocks   []string  `json:"buildBlocks,omitempty"`
	AvailableMiB  int       `json:"availableMiB"`
	Load1         float64   `json:"load1"`
	DiskFreeGiB   float64   `json:"diskFreeGiB"`
	SwapGrowthMiB int       `json:"swapGrowthMiB"`
	BuildBusy     bool      `json:"buildBusy"`
	ObservedAt    time.Time `json:"observedAt"`
}

func (Resources) Validate

func (r Resources) Validate(now time.Time) error

type RetireRequest

type RetireRequest struct {
	ID      string `json:"id"`
	Trigger string `json:"trigger"`
	Reason  string `json:"reason"`
}

RetireRequest asks the host to retire a terminal execution. Repeating it, under any ID or trigger, resumes the retirement already recorded.

type Retirement

type Retirement struct {
	Ref         Ref       `json:"ref"`
	ID          string    `json:"id"`
	Trigger     string    `json:"trigger"`
	Reason      string    `json:"reason"`
	Stage       string    `json:"stage"`
	Recovery    *Recovery `json:"recovery,omitempty"`
	RequestedAt time.Time `json:"requestedAt"`
	RetiredAt   time.Time `json:"retiredAt,omitzero"`
	RetainUntil time.Time `json:"retainUntil,omitzero"`
	LastError   string    `json:"lastError,omitempty"`
}

Retirement is the host's durable state of one retirement.

func (Retirement) Finished

func (r Retirement) Finished() bool

Finished says the host holds nothing further to retire for this execution.

type Retirer

type Retirer interface {
	Retire(context.Context, Ref, RetireRequest) (Retirement, error)
}

Retirer is the optional host operation behind a coordinator's retirement.

type SSHTransport

type SSHTransport struct {
	Host Host
	Run  CommandRunner
}

func (SSHTransport) BundleStatus

func (t SSHTransport) BundleStatus(ctx context.Context, digest string) (BundleStatus, error)

func (SSHTransport) Call

func (t SSHTransport) Call(ctx context.Context, op string, ref Ref, payload, result any) error

func (SSHTransport) Check

func (t SSHTransport) Check(ctx context.Context) (Capabilities, error)

func (SSHTransport) Continue

func (t SSHTransport) Continue(ctx context.Context, r Ref, q ContinueRequest) (Handle, error)

func (SSHTransport) Inspect

func (t SSHTransport) Inspect(ctx context.Context, r Ref) (Observation, error)

func (SSHTransport) Inventory

func (t SSHTransport) Inventory(ctx context.Context, coordinator string) ([]Ref, error)

func (SSHTransport) Logs

func (t SSHTransport) Logs(ctx context.Context, r Ref, q LogRequest) (LogPage, error)

func (SSHTransport) Message

func (t SSHTransport) Message(ctx context.Context, r Ref, m Envelope) (Ack, error)

func (SSHTransport) Missing

func (t SSHTransport) Missing(ctx context.Context, ref Ref) (bool, error)

func (SSHTransport) RebindPolicy

func (t SSHTransport) RebindPolicy(ctx context.Context, r Ref, q PolicyRebind) (Observation, error)

func (SSHTransport) ResolveMessage

func (t SSHTransport) ResolveMessage(ctx context.Context, r Ref, q MessageResolution) (Ack, error)

func (SSHTransport) Retire

func (t SSHTransport) Retire(ctx context.Context, r Ref, q RetireRequest) (Retirement, error)

func (SSHTransport) SourceBasis

func (t SSHTransport) SourceBasis(ctx context.Context, ref Ref, repository string) (SourceBasis, error)

func (SSHTransport) Start

func (t SSHTransport) Start(ctx context.Context, r StartRequest) (Handle, error)

func (SSHTransport) Stop

func (t SSHTransport) Stop(ctx context.Context, r Ref, q StopRequest) (Ack, error)

func (SSHTransport) SyncBundle

func (t SSHTransport) SyncBundle(ctx context.Context, b CoordinatorBundle) (string, error)

func (SSHTransport) SyncControl

func (t SSHTransport) SyncControl(ctx context.Context, r Ref) (ControlResult, error)

func (SSHTransport) UploadSource added in v0.174.0

func (t SSHTransport) UploadSource(ctx context.Context, ref Ref, data []byte) error

type Sender

type Sender struct {
	Session string `json:"session"`
	Name    string `json:"name"`
	Host    string `json:"host"`
}

Sender is the coordinating caller, retained across SSH and login shells. From and To bind delivery to the owned execution and process generation.

type Server

type Server struct {
	Config                                                HostConfig
	Root, Executable, ConfigPath, Version, SecurityDigest string
	GuardsDisabled                                        bool
	Rules                                                 []byte
	Launcher                                              platform.Launcher
	Command                                               HostCommand
	Combined                                              HostCommand
	Resources                                             func(context.Context) (Resources, error)
	GuardProbe                                            func() error
	Authorize                                             func(context.Context, StartRequest) error
	Callback                                              CommandRunner
	Now                                                   func() time.Time
	OwnUnit                                               func() string
	// contains filtered or unexported fields
}

Server operates only on journals it created. It never discovers or adopts another conversation, process or unit by name.

func (*Server) AuditResources

func (s *Server) AuditResources(ctx context.Context) ([]ResourceFinding, error)

AuditResources does not call Inspect (which can acknowledge a stop), create directories, or read credentials. Unknown ownership always blocks mutation.

func (*Server) BundleStatus

func (s *Server) BundleStatus(digest string) (BundleStatus, error)

BundleStatus never repairs: a changed bundle stays a Problem until an operator looks, since an execution may be bound to it.

func (*Server) BusyExecutions

func (s *Server) BusyExecutions(ctx context.Context, own Ref) ([]Ref, error)

BusyExecutions names every journal-backed execution that blocks an update.

func (*Server) Caller

func (s *Server) Caller(id string) (Journal, error)

Caller verifies process ownership through the service cgroup. Environment variables alone cannot impersonate a different worker on the same host.

func (*Server) Check

func (s *Server) Check(ctx context.Context) (Capabilities, error)

func (*Server) Continue

func (s *Server) Continue(ctx context.Context, r Ref, q ContinueRequest) (Handle, error)

Continue launches the same unit on the same journal, workspace and conversation; it never creates another execution. The runner takes the conversation up again and its first turn is the next stored message. What a stop ended stays ended, and a retirement already moved the workspace.

func (*Server) GitHubEnvironment

func (s *Server) GitHubEnvironment(j Journal, env []string) ([]string, error)

GitHubEnvironment installs only dispatch scripts, never tokens. The helper asks the coordinator on each command; no credential is saved on the host.

func (*Server) Inspect

func (s *Server) Inspect(ctx context.Context, r Ref) (Observation, error)

func (*Server) InstallBundle

func (s *Server) InstallBundle(ctx context.Context, b CoordinatorBundle) (string, error)

InstallBundle publishes a bundle under its digest with one rename, so a start or a concurrent sync sees all of it or none. Repeating it finds it installed. It holds the host's admission and only ever adds: what an execution is bound to stays as it was.

func (*Server) InstalledPolicy

func (s *Server) InstalledPolicy() (Policy, error)

func (*Server) Inventory

func (s *Server) Inventory(ctx context.Context, coordinator string) ([]Ref, error)

func (*Server) LoadPinnedTools

func (s *Server) LoadPinnedTools() error

LoadPinnedTools applies a raised Go pin recorded in the host's managed execution root when it is newer than the static configuration's pin.

func (*Server) Logs

func (s *Server) Logs(_ context.Context, r Ref, q LogRequest) (LogPage, error)

func (*Server) Message

func (s *Server) Message(ctx context.Context, ref Ref, m Envelope) (ack Ack, err error)

func (*Server) Missing

func (s *Server) Missing(ctx context.Context, ref Ref) (bool, error)

func (*Server) Policy

func (s *Server) Policy() Policy

Policy describes precisely what prepare installs. ConfigurationDigest also binds the caller's host-local guard configuration, not just these fields. A coordinator bundle is no part of it: a rule change must not move the host's pin, and each execution's request binds the bundle it runs under instead.

func (*Server) Prepare

func (s *Server) Prepare(p Policy) (string, error)

func (*Server) ProvisionTools

func (s *Server) ProvisionTools(ctx context.Context) error

ProvisionTools installs missing pinned tools, raising the Go pin when the served repositories require a newer release and never overwriting an existing installation. Call only while admission is quiesced. Installed tools are shared host state, not worker scratch.

func (*Server) ProvisionToolsFor

func (s *Server) ProvisionToolsFor(ctx context.Context, required map[string]string) error

ProvisionToolsFor installs missing pinned tools and raises the Go pin to the highest version named by the host's served repositories or required.

func (*Server) Quiesce

func (s *Server) Quiesce(ctx context.Context) (busy int, release func(), err error)

Quiesce holds the host's admission, so that no execution starts and no turn begins until release, and counts the executions that are in a turn or may begin one on their own. An update replaces the binary and the policy every running execution is pinned to: it goes ahead only at zero, before release. An execution between turns (a parked worker waiting for its wake) does not hold it back: its next turn begins only after release, on the updated host, once the coordinator rebinds it to the prepared policy.

func (*Server) Read

func (s *Server) Read(r Ref) (Journal, error)

func (*Server) RebindPolicy

func (s *Server) RebindPolicy(ctx context.Context, r Ref, q PolicyRebind) (Observation, error)

RebindPolicy binds a running execution to the host's prepared policy. The coordinator sends it only for the policy pinned in its host catalog; the host still requires a launched execution whose owned unit is active, that exact prepared policy and the bound one it replaces, so a stale request, an exited execution or an unprepared host fails closed.

func (*Server) ReceiveSource added in v0.174.0

func (s *Server) ReceiveSource(ctx context.Context, ref Ref, chunk SourceChunk) error

func (*Server) ReconcileResource

func (s *Server) ReconcileResource(ctx context.Context, ref Ref, releaseEvidence bool) error

ReconcileResource is intentionally one execution per call. The execution lock serializes with starts. It enters the one retirement every terminal path uses, so unpublished work is preserved before anything moves aside, then removes what earlier retirements proved disposable. ReleaseEvidence is an explicit desk attestation that this log is no longer needed for publication review or recovery.

func (*Server) ResolveMessage

func (s *Server) ResolveMessage(ctx context.Context, ref Ref, q MessageResolution) (ack Ack, err error)

func (*Server) Retire

func (s *Server) Retire(ctx context.Context, r Ref, q RetireRequest) (Retirement, error)

Retire takes a terminal execution through its one retirement: work is preserved durably, then its owned resources move aside. Report, stop, failed start and crash all arrive here; a retry resumes at the recorded stage, so an interrupted retirement never starts over or is skipped. An error always leaves the retirement unfinished. Once this one holds, the coordinator's call also removes what earlier retirements proved disposable and kept past retention: nothing else on a host ever deletes a retired resource.

func (*Server) RevokeGitHub

func (s *Server) RevokeGitHub(j Journal) error

RevokeGitHub runs on normal exit and termination, independently of the runner's cancelled context. Coordinator stop/inspection also revoke, so losing the host cannot keep a worker's credentials alive.

func (*Server) Run

func (s *Server) Run(ctx context.Context, ref Ref) (runErr error)

Run owns one headless turn and its first-task acceptance evidence. Only the execution-run service calls it; caller verification is done by the command.

func (*Server) SendControl

func (s *Server) SendControl(ctx context.Context, j Journal, op string, data any, id string, run CommandRunner) (ControlResult, error)

SendControl stores a mutation before contacting the coordinator. A caller that retries identical data receives the original receipt, including a note number. Different work cannot overtake an unacknowledged mutation.

func (*Server) Serve

func (s *Server) Serve(ctx context.Context, input io.Reader, output io.Writer) error

Serve handles one bounded request. EOF and malformed data return a protocol refusal, never an empty successful reply. Diagnostics are not sent as data.

func (*Server) SourceBasis

func (s *Server) SourceBasis(ctx context.Context, repository string) (SourceBasis, error)

SourceBasis reads only the host's own mapped checkout; it changes nothing.

func (*Server) Start

func (s *Server) Start(ctx context.Context, r StartRequest) (Handle, error)

func (*Server) Stop

func (s *Server) Stop(ctx context.Context, r Ref, q StopRequest) (Ack, error)

Stop terminates only the owned process. Its workspace and source artifacts remain at the journal's recorded paths: even a clean tree can contain unpublished commits, and an acknowledged stop is not proof of task completion. Only Retire, once the coordinator asks for it, moves them.

func (*Server) SyncControl

func (s *Server) SyncControl(ctx context.Context, r Ref, run CommandRunner) (ControlResult, error)

type SourceBasis

type SourceBasis struct {
	Commits []string `json:"commits"`
}

SourceBasis lists the commits a workspace clone of repository starts with. The clone copies the mapped checkout's branches, so their tips (newest first, HEAD's commit leading) are commits whose objects the host holds. An unmapped repository is cloned from the bundle alone and has no basis.

type SourceBasisReader

type SourceBasisReader interface {
	SourceBasis(context.Context, Ref, string) (SourceBasis, error)
}

SourceBasisReader is a transport that can ask a host for its source basis.

type SourceChunk added in v0.174.0

type SourceChunk struct {
	Offset int64  `json:"offset"`
	Total  int64  `json:"total"`
	Data   []byte `json:"data"`
}

type SourceReport

type SourceReport struct {
	Repository string `json:"repository"`
	Head       string `json:"head,omitempty"`
	Branch     string `json:"branch,omitempty"`
	// Missing counts the default branch's commits the host source lacks.
	Missing int    `json:"missingCommits"`
	Problem string `json:"problem,omitempty"`
}

SourceReport is hosts check's comparison of one mapped host source with its repository's default branch on GitHub.

type SourceUploader added in v0.174.0

type SourceUploader interface {
	UploadSource(context.Context, Ref, []byte) error
}

SourceUploader transfers coordinator-fetched objects before preparation. The digest and exact commit are bound into the durable start request.

type StartRequest

type StartRequest struct {
	// BundleDigest is the coordinator policy bundle this execution runs under
	// for its whole life; empty, it runs on the host's prepared policy alone.
	BundleDigest   string `json:"bundleDigest,omitempty"`
	Effort         string `json:"effort,omitempty"`
	GitHub         bool   `json:"github,omitempty"`
	MCP            bool   `json:"mcp,omitempty"`
	LeaseRequired  bool   `json:"leaseRequired,omitempty"`
	Messaging      bool   `json:"messaging,omitempty"`
	Builds         bool   `json:"builds"`
	Ref            Ref    `json:"ref"`
	RequestID      string `json:"requestID"`
	Coordinator    string `json:"coordinator"`
	Name           string `json:"name"`
	Task           string `json:"task"`
	Repository     string `json:"repository"`
	GitRef         string `json:"gitRef"`
	SourceDigest   string `json:"sourceDigest,omitempty"`
	Harness        string `json:"harness"`
	Model          string `json:"model"`
	Prompt         string `json:"prompt"`
	PolicyDigest   string `json:"policyDigest"`
	ConversationID string `json:"conversationID"`
	// ControlKey authenticates component callbacks, never provider requests.
	// It travels only in the protected SSH request and owned journals.
	ControlKey          string `json:"controlKey"`
	RegistrationReceipt string `json:"registrationReceipt,omitempty"`
}

func (StartRequest) Digest

func (r StartRequest) Digest() string

func (StartRequest) Validate

func (r StartRequest) Validate() error

type Starter

type Starter interface {
	Start(context.Context, StartRequest) (Handle, error)
}

type StopRequest

type StopRequest struct {
	ID     string `json:"id"`
	Reason string `json:"reason"`
}

type Stopper

type Stopper interface {
	Stop(context.Context, Ref, StopRequest) (Ack, error)
}

type ToolConfig

type ToolConfig struct {
	Executable string `yaml:"executable" json:"executable"`
	Version    string `yaml:"version" json:"version"`
}

ToolConfig pins one operator-installed tool a worker calls by bare name.

func RaiseGoTool

func RaiseGoTool(base ToolConfig, version string) (ToolConfig, error)

RaiseGoTool returns a ToolConfig for version under the same parent tools directory as base, or base unchanged when version is not newer.

type Transport

type Transport interface {
	Starter
	Inspector
	Messenger
	Stopper
	Logger
}

type UnreachableError

type UnreachableError struct {
	Operation string
	Cause     error
}

func (*UnreachableError) Error

func (e *UnreachableError) Error() string

func (*UnreachableError) Unwrap

func (e *UnreachableError) Unwrap() error

type WireRequest

type WireRequest struct {
	Protocol  int             `json:"protocol"`
	RequestID string          `json:"requestID"`
	Operation string          `json:"operation"`
	Ref       Ref             `json:"ref"`
	Payload   json.RawMessage `json:"payload,omitempty"`
}

type WireResponse

type WireResponse struct {
	Protocol  int             `json:"protocol"`
	RequestID string          `json:"requestID"`
	Ref       Ref             `json:"ref"`
	Payload   json.RawMessage `json:"payload,omitempty"`
	Error     string          `json:"error,omitempty"`
	Code      string          `json:"code,omitempty"`
}

Jump to

Keyboard shortcuts

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