Documentation
¶
Overview ¶
Package execution manages owned harness processes on SSH execution hosts. Transport reachability never establishes whether a task or process ended.
Index ¶
- Constants
- Variables
- func CoordinatorCall(ctx context.Context, endpoint Endpoint, host, op string, ref Ref, payload any, ...) error
- func Decode(raw []byte, v any) error
- func Digest(b []byte) string
- func GatewayMCP(ctx context.Context, servers map[string]MCPServer, op string, ...) (any, error)
- func GitHubBranch(ref Ref) string
- func GitHubGitVerb(args []string) string
- func GitHubReadRepository(args []string) (string, []string, bool)
- func GitHubRepository(args []string, fallback string) (string, error)
- func GitHubWrite(args []string) (bool, error)
- func GitHubWriteRepository(args []string, fallback string) (string, error)
- func HostPath(s string) bool
- func MCPProxy(ctx context.Context, call MCPCallback) (*mcpserver.MCPServer, error)
- func NewControlKey() (string, error)
- func PublicKey(k ed25519.PrivateKey) string
- func RepositoryIdentity(raw string) string
- func SSHArgv(e Endpoint, connect time.Duration, command string) []string
- func SSHCommand(ctx context.Context, argv []string, stdin []byte) ([]byte, error)
- func Sign(r StartRequest, key ed25519.PrivateKey, now time.Time) string
- func SigningKey(root string) (ed25519.PrivateKey, error)
- func SupportedHarness(h string) bool
- func UnitName(r Ref) string
- func ValidDigest(s string) bool
- func ValidIdentity(s string) bool
- func ValidateGitHubAPIRead(args []string) error
- func ValidateHandle(h Host, r StartRequest, x Handle) error
- func ValidateMCP(servers map[string]MCPServer) error
- func ValidateWorkerPush(args []string, branch string) error
- func Verify(r StartRequest, key string, now time.Time) error
- func VerifyCallback(r CallbackRequest, key string) bool
- func VerifyLease(grant LeaseGrant, request LeaseRequest, ref Ref, coordinator, key string) error
- func WriteMergeAuthorization(root string, grant MergeAuthorization, action string, now time.Time) error
- type Ack
- type ActivationDecision
- type CallbackRequest
- type Capabilities
- type CommandRunner
- type ControlLedger
- type ControlRequest
- type ControlResult
- type ControlSyncer
- type Coordinator
- type Delivery
- type Endpoint
- type Envelope
- type ExecutionID
- type Handle
- type HarnessConfig
- type HarnessReadiness
- type Host
- type HostCommand
- type HostConfig
- type HostID
- type HostUpdate
- type Inspector
- type InventoryReader
- type Journal
- type LeaseGrant
- type LeaseRequest
- type LogPage
- type LogRequest
- type Logger
- type MCPCallRequest
- type MCPCallback
- type MCPServer
- type MergeAudit
- type MergeAuthorization
- type MergeResult
- type MergeUse
- type MessageLedger
- func (l *MessageLedger) Accept(id string) error
- func (l *MessageLedger) Attempt(m Envelope) error
- func (l *MessageLedger) Next() (Envelope, bool)
- func (l *MessageLedger) Resolve(q MessageResolution) (Ack, error)
- func (l MessageLedger) Status() []Delivery
- func (l *MessageLedger) Store(ref Ref, m Envelope) (Ack, error)
- type MessageResolution
- type MessageResolver
- type Messenger
- type Observation
- type Policy
- type PolicyRebind
- type PolicyRebinder
- type Receipt
- type Ref
- type Resources
- type SSHTransport
- func (t SSHTransport) Call(ctx context.Context, op string, ref Ref, payload, result any) error
- func (t SSHTransport) Check(ctx context.Context) (Capabilities, error)
- func (t SSHTransport) Inspect(ctx context.Context, r Ref) (Observation, error)
- func (t SSHTransport) Inventory(ctx context.Context, coordinator string) ([]Ref, error)
- func (t SSHTransport) Logs(ctx context.Context, r Ref, q LogRequest) (LogPage, error)
- func (t SSHTransport) Message(ctx context.Context, r Ref, m Envelope) (Ack, error)
- func (t SSHTransport) Missing(ctx context.Context, ref Ref) (bool, error)
- func (t SSHTransport) RebindPolicy(ctx context.Context, r Ref, q PolicyRebind) (Observation, error)
- func (t SSHTransport) ResolveMessage(ctx context.Context, r Ref, q MessageResolution) (Ack, error)
- func (t SSHTransport) Start(ctx context.Context, r StartRequest) (Handle, error)
- func (t SSHTransport) Stop(ctx context.Context, r Ref, q StopRequest) (Ack, error)
- func (t SSHTransport) SyncControl(ctx context.Context, r Ref) (ControlResult, error)
- func (t SSHTransport) UploadSource(ctx context.Context, ref Ref, data []byte) error
- type Sender
- type Server
- func (s *Server) BusyExecutions(ctx context.Context, own Ref) ([]Ref, error)
- func (s *Server) Caller(id string) (Journal, error)
- func (s *Server) Check(ctx context.Context) (Capabilities, error)
- func (s *Server) GitHubEnvironment(j Journal, env []string) ([]string, error)
- func (s *Server) Inspect(ctx context.Context, r Ref) (Observation, error)
- func (s *Server) InstalledPolicy() (Policy, error)
- func (s *Server) Inventory(ctx context.Context, coordinator string) ([]Ref, error)
- func (s *Server) Logs(_ context.Context, r Ref, q LogRequest) (LogPage, error)
- func (s *Server) Message(ctx context.Context, ref Ref, m Envelope) (ack Ack, err error)
- func (s *Server) Missing(ctx context.Context, ref Ref) (bool, error)
- func (s *Server) Policy() Policy
- func (s *Server) Prepare(p Policy) (string, error)
- func (s *Server) ProvisionTools(ctx context.Context) error
- func (s *Server) Quiesce(ctx context.Context) (busy int, release func(), err error)
- func (s *Server) Read(r Ref) (Journal, error)
- func (s *Server) RebindPolicy(ctx context.Context, r Ref, q PolicyRebind) (Observation, error)
- func (s *Server) ReceiveSource(ctx context.Context, ref Ref, chunk SourceChunk) error
- func (s *Server) ResolveMessage(ctx context.Context, ref Ref, q MessageResolution) (ack Ack, err error)
- func (s *Server) RevokeGitHub(j Journal) error
- func (s *Server) Run(ctx context.Context, ref Ref) (runErr error)
- func (s *Server) SendControl(ctx context.Context, j Journal, op string, data any, id string, ...) (ControlResult, error)
- func (s *Server) Serve(ctx context.Context, input io.Reader, output io.Writer) error
- func (s *Server) Start(ctx context.Context, r StartRequest) (Handle, error)
- func (s *Server) Stop(ctx context.Context, r Ref, q StopRequest) (Ack, error)
- func (s *Server) SyncControl(ctx context.Context, r Ref, run CommandRunner) (ControlResult, error)
- type SourceChunk
- type SourceUploader
- type StartRequest
- type Starter
- type StopRequest
- type Stopper
- type ToolConfig
- type Transport
- type UnreachableError
- type WireRequest
- type WireResponse
Constants ¶
const ( GitHubOrigin = "origin" GitHubGitTool = "git" )
const ( MessageWake = "wake" Stored = "stored" Accepted = "accepted" Uncertain = "uncertain" Resolved = "resolved" )
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" )
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.
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).
const CIRerun = "ci-rerun"
CIRerun requests a coordinator-owned CI rerun without exporting credentials.
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.
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.
const HarnessOmp = "omp"
const LeaseDuration = 90 * time.Second
const LeaseRenewal = 20 * time.Second
const MCPCall = "mcp-call"
const MCPList = "mcp-list"
const MaxSourceBundle = 64 << 20
const MergeSucceeded = "merged"
const OmpVersions = ">= 18.14.2, < 19.0.0"
Pin the protocol and extension API family proven by this adapter.
const SourceChunkSize = 256 << 10
const UpdateTimeout = 5 * time.Minute
UpdateTimeout bounds a host update: the download, its verification, the new release's prepare and a rollback.
Variables ¶
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.
var ErrUnsupported = errors.New("message acceptance is unavailable for this SSH execution or adapter; inspect the original execution before recovery")
Functions ¶
func CoordinatorCall ¶
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 ¶
GitHubBranch is the one upstream branch assigned to this execution.
func GitHubGitVerb ¶
GitHubGitVerb skips git's global options so unauthenticated local commands retain normal semantics. Network operations reject such overrides separately.
func GitHubReadRepository ¶
GitHubReadRepository scopes explicit read transports to their named repository. Clone destinations and fetch refspecs stay client arguments, never authority.
func GitHubRepository ¶
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 ¶
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 ¶
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 MCPProxy ¶
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 PublicKey ¶
func PublicKey(k ed25519.PrivateKey) string
func RepositoryIdentity ¶
RepositoryIdentity accepts the canonical public GitHub transport forms, without passwords, query strings or a caller-selected credential helper.
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
SupportedHarness names the harnesses with a remote adapter. Every other harness starts on the coordinating machine only.
func ValidDigest ¶
func ValidIdentity ¶
func ValidateGitHubAPIRead ¶
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 ValidateWorkerPush ¶
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 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 {
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.
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 ¶
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 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 Delivery ¶
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.
type ExecutionID ¶
type ExecutionID string
type HarnessConfig ¶
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 ¶
AdmitsRepository reports whether this host can prepare the repository.
func (Host) Supports ¶ added in v0.174.0
Supports reports whether the operator lists harness for this host.
func (Host) ValidateCatalog ¶
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 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 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 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 ¶
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 LogRequest ¶
type MCPCallRequest ¶
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 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)
type MergeResult ¶
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 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.
type MessageResolution ¶
type MessageResolver ¶
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"`
}
type PolicyRebind ¶
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 Ref ¶
type Ref struct {
Host HostID `json:"host"`
Execution ExecutionID `json:"execution"`
Generation uint64 `json:"generation"`
}
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"`
}
type SSHTransport ¶
type SSHTransport struct {
Host Host
Run CommandRunner
}
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) Logs ¶
func (t SSHTransport) Logs(ctx context.Context, r Ref, q LogRequest) (LogPage, 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
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 ¶
BusyExecutions names every journal-backed execution that blocks an update.
func (*Server) Caller ¶
Caller verifies process ownership through the service cgroup. Environment variables alone cannot impersonate a different worker on the same host.
func (*Server) GitHubEnvironment ¶
GitHubEnvironment installs only dispatch scripts, never tokens. The helper asks the coordinator on each command; no credential is saved on the host.
func (*Server) InstalledPolicy ¶
func (*Server) Policy ¶
Policy describes precisely what prepare installs. ConfigurationDigest also binds the caller's host-local guard configuration, not just these fields.
func (*Server) ProvisionTools ¶
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 ¶
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) 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 (*Server) ResolveMessage ¶
func (*Server) RevokeGitHub ¶
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 ¶
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 ¶
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) Stop ¶
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 SourceUploader ¶ added in v0.174.0
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 StopRequest ¶
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 UnreachableError ¶
func (*UnreachableError) Error ¶
func (e *UnreachableError) Error() string
func (*UnreachableError) Unwrap ¶
func (e *UnreachableError) Unwrap() error