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 HostPath(s string) bool
- 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 UnitName(r Ref) string
- func ValidDigest(s string) bool
- func ValidIdentity(s string) bool
- func ValidateHandle(h Host, r StartRequest, x Handle) error
- func Verify(r StartRequest, key string, now time.Time) error
- func VerifyCallback(r CallbackRequest, key string) bool
- type Ack
- type ActivationDecision
- type CallbackRequest
- type Capabilities
- type CommandRunner
- type ControlLedger
- type ControlRequest
- type ControlResult
- type ControlSyncer
- type Coordinator
- type Endpoint
- type Envelope
- type ExecutionID
- type Handle
- type HarnessConfig
- type Host
- type HostCommand
- type HostConfig
- type HostID
- type Inspector
- type Journal
- type LogPage
- type LogRequest
- type Logger
- type Messenger
- type Observation
- type Policy
- 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) 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) 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)
- type Server
- func (s *Server) Caller(id string) (Journal, error)
- func (s *Server) Check(ctx context.Context) (Capabilities, error)
- func (s *Server) Inspect(ctx context.Context, r Ref) (Observation, error)
- func (s *Server) InstalledPolicy() (Policy, error)
- func (s *Server) Logs(_ context.Context, r Ref, q LogRequest) (LogPage, error)
- func (s *Server) Policy() Policy
- func (s *Server) Prepare(p Policy) (string, error)
- func (s *Server) Read(r Ref) (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 StartRequest
- type Starter
- type StopRequest
- type Stopper
- type Transport
- type UnreachableError
- type WireRequest
- type WireResponse
Constants ¶
const ( HarnessClaude = "claude" Preparing = "preparing" Activating = "activating" Applied = "applied" ControlNote = "note" ControlPark = "park" ControlReport = "report" Protocol = 1 EnvID = "BEEKEEPER_EXECUTION_ID" EnvCoordinator = "BEEKEEPER_EXECUTION_COORDINATOR" MaxWire = 1 << 20 MaxLog = 256 << 10 Prepared = "prepared" Running = "running" Exited = "exited" Failed = "failed" Unknown = "unknown" Reachable = "reachable" Unreachable = "unreachable" )
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.
Variables ¶
var ErrUnsupported = errors.New("remote wake acceptance is not implemented; see https://github.com/giantswarm/beekeeper/issues/1714")
Functions ¶
func CoordinatorCall ¶
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 ValidDigest ¶
func ValidIdentity ¶
func ValidateHandle ¶
func ValidateHandle(h Host, r StartRequest, x Handle) error
func VerifyCallback ¶
func VerifyCallback(r CallbackRequest, key string) bool
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 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 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 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"`
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.
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"`
Harnesses map[string]HarnessConfig `yaml:"harnesses" json:"harnesses"`
Coordinators map[string]Coordinator `yaml:"coordinators" json:"coordinators"`
MaxBusy int `yaml:"maxBusy" json:"maxBusy"`
}
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 Journal ¶
type Journal struct {
ActivationAttempted bool `json:"activationAttempted"`
RunnerPID int `json:"runnerPID,omitempty"`
RunnerStarted time.Time `json:"runnerStarted,omitempty"`
Request StartRequest `json:"request"`
Digest string `json:"digest"`
Handle Handle `json:"handle"`
Phase string `json:"phase"`
Ready bool `json:"ready"`
StopRequest *StopRequest `json:"stopRequest,omitempty"`
StopAcknowledged bool `json:"stopAcknowledged"`
LastError string `json:"lastError,omitempty"`
}
type LogRequest ¶
type Observation ¶
type Observation struct {
Handle Handle `json:"handle"`
ProcessState string `json:"processState"`
Reachability string `json:"reachability"`
ObservedAt time.Time `json:"observedAt"`
ReachabilityAt time.Time `json:"reachabilityAt"`
Ready bool `json:"ready"`
StopRequested bool `json:"stopRequested"`
StopAcknowledged bool `json:"stopAcknowledged"`
LastError string `json:"lastError,omitempty"`
}
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.
type Policy ¶
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) 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)
type Server ¶
type Server struct {
Config HostConfig
Root, Executable, ConfigPath, Version, SecurityDigest string
Rules []byte
Launcher platform.Launcher
Command 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) Caller ¶
Caller verifies process ownership through the service cgroup. Environment variables alone cannot impersonate a different worker on the same 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) 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) SyncControl ¶
func (s *Server) SyncControl(ctx context.Context, r Ref, run CommandRunner) (ControlResult, error)
type StartRequest ¶
type StartRequest struct {
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"`
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 UnreachableError ¶
func (*UnreachableError) Error ¶
func (e *UnreachableError) Error() string
func (*UnreachableError) Unwrap ¶
func (e *UnreachableError) Unwrap() error