execution

package
v0.175.0-rc.109 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 44 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 (
	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"
)

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 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 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 MCPCall = "mcp-call"
View Source
const MCPList = "mcp-list"
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 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 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 ErrUnsupported = errors.New("message acceptance is unavailable for this SSH execution or adapter; inspect the original execution before recovery")

Functions

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 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 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.

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 CallbackRequest

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

type Capabilities

type Capabilities struct {
	// SourcePreparation promises source-chunk upload and typed not-found
	// responses when inspecting an execution whose journal does not exist.
	SourcePreparation bool              `json:"sourcePreparation"`
	GitHub            bool              `json:"github,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 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 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"`
}

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 {
	Lease               *LeaseGrant   `json:"lease,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"`
}

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 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 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 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 SSHTransport

type SSHTransport struct {
	Host Host
	Run  CommandRunner
}

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) 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) 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) 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
	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
}

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

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) 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) InstalledPolicy

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

func (*Server) Inventory

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

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.

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, never changing a configured version or overwriting an existing installation. Call only while admission is quiesced. Installed tools are shared host state, not worker scratch.

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) ResolveMessage

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

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) 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.

func (*Server) SyncControl

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

type SourceChunk added in v0.174.0

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

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 {
	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.

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