Documentation
¶
Overview ¶
Package execution delivers durable Turns through the existing daemon protocol.
Index ¶
- Constants
- Variables
- func LocalWorkspaceConfiguration(configuration json.RawMessage) bool
- type Credentials
- type Dispatcher
- type EnvironmentRun
- type Owner
- type Ownership
- type Policy
- type PreparedRuntimeDeployment
- type Result
- type RuntimeDeploymentPreparer
- type RuntimeProvider
- type RuntimeSuspensionPolicy
- type Snapshot
- type Worker
- func (w *Worker) CancelSandboxReset(ctx context.Context, generation uint64) (deployment.View, error)
- func (w *Worker) CheckOwnership(ctx context.Context) error
- func (w *Worker) Configure(ctx context.Context, input workspaces.SelectionInput) (workspaces.Selection, error)
- func (w *Worker) CreateSession(ctx context.Context, tenant string, input sessions.CreateSession) (sessions.Creation, error)
- func (w *Worker) InitializeSandboxDeployment(ctx context.Context, input sandbox.Selection) (deployment.View, error)
- func (w *Worker) MetricsSnapshot() WorkerMetrics
- func (w *Worker) ProvisionEnvironment(ctx context.Context, tenant, environment, providerKey string) (deployment.Allocation, error)
- func (w *Worker) ReadEnvironmentDirectory(ctx context.Context, environment sessions.Environment, path string) (proto.WorkspaceDirectoryResult, error)
- func (w *Worker) ReconcileManagedRuntimes(ctx context.Context) error
- func (w *Worker) Run(ctx context.Context) (runErr error)
- func (w *Worker) Selection(ctx context.Context) (workspaces.Selection, error)
- func (w *Worker) StartSandboxReset(ctx context.Context, input deployment.ResetRequest) (deployment.View, error)
- func (w *Worker) SubmitInputs(ctx context.Context, tenant, session, key string, inputs []sessions.Input) ([]sessions.InputReceipt, error)
- func (w *Worker) UpdateSandboxDeployment(ctx context.Context, input sandbox.Selection) (deployment.View, error)
- func (w *Worker) WriteEnvironmentFile(ctx context.Context, environment sessions.Environment, path string, ...) (int64, error)
- type WorkerJobMetrics
- type WorkerMetrics
Constants ¶
const DefaultExecutionConcurrency = 4
Variables ¶
var ( ErrEnvironmentInputExpired = errors.New("environment input expired before admission") ErrEnvironmentInputCancelled = errors.New("environment input cancelled before admission") )
var ( ErrEnvironmentFileDirectory = fmt.Errorf("%w: environment file destination is a directory", sessions.ErrInvalidInput) ErrEnvironmentFileUnsafe = fmt.Errorf("%w: environment file destination exists or traverses a link", sessions.ErrInvalidInput) )
Known Files.create destination refusals reported by the Runtime installer. They wrap sessions.ErrInvalidInput; the rejected write installed nothing.
var ErrWhitespaceOnlyText = errors.New("whitespace-only message text is not supported by this harness")
ErrWhitespaceOnlyText is a declared native limitation reported before any write, reservation or promotion.
Functions ¶
func LocalWorkspaceConfiguration ¶
func LocalWorkspaceConfiguration(configuration json.RawMessage) bool
LocalWorkspaceConfiguration recognizes a stored V1 profile. It does not provision a Runtime, validate live authority, or admit hosted creation.
Types ¶
type Credentials ¶
type Credentials interface {
MCPBearerToken(context.Context, vaults.MCPBearerToken) (string, error)
}
Credentials opens the bearer token of a Session's frozen MCP credential binding.
type Dispatcher ¶
type Dispatcher struct {
Policy
Registry *runtimegateway.Registry
// Credentials opens the bearer tokens of authenticated MCP servers.
Credentials Credentials
// Observer records which deployment default model configurations committed
// root Turns used. It is required.
Observer modelconfiguration.Observer
// Deployment reads the sandbox deployment and prepares a selection's setup.
// It is required; deployment changes go through Owner.Deployment.
Deployment *deployment.Service
// DeploymentReader reads the deployment's pooled records, such as the
// Sessions a reset still has to archive. It is required.
DeploymentReader deployment.Reader
// Sessions runs the pooled Session use cases, such as staging a Turn's
// Artifacts. It is required.
Sessions *sessions.Service
// SessionsReader serves the plain Session reads. It is required.
SessionsReader sessions.Reader
// ManagedRuntimes provisions hosted Environments on the sandbox deployment.
// It is required.
ManagedRuntimes *RuntimeProvider
// MaxConcurrentExecutions bounds work admitted by this Core execution owner.
// Zero uses DefaultExecutionConcurrency. It is independent of sandbox capacity.
MaxConcurrentExecutions int
// contains filtered or unexported fields
}
func (*Dispatcher) Bind ¶
func (d *Dispatcher) Bind(owner Owner) (*Dispatcher, error)
Bind returns a copy of d bound to owner's execution operations. StartWorker binds through it; a Dispatcher that runs Turns outside a Worker binds the same way.
func (*Dispatcher) Run ¶
func (d *Dispatcher) Run(ctx context.Context, tenantID, sessionID, turnID string) (sessions.Turn, error)
Run claims once before subscribing or sending. Uncertain deliveries are not replayed.
func (*Dispatcher) RunEnvironmentInput ¶
func (d *Dispatcher) RunEnvironmentInput(ctx context.Context, lease Ownership, tenantID, sessionID, reservationID string) (run EnvironmentRun, err error)
RunEnvironmentInput reserves a Turn on the Session-owned Runtime Executor. It checks lease, the lease the Dispatcher's execution operations hold, before any Runtime preparation.
type EnvironmentRun ¶
type EnvironmentRun struct {
Reservation sessions.EnvironmentInputReservation
Turn sessions.Turn
}
type Owner ¶
type Owner struct {
Workspaces *workspaces.ExecutionOperations
Lease Ownership
Deployment *deployment.ExecutionOperations // sandbox deployment changes on the lease-bound deploymentpg storage
Sessions *sessions.ExecutionOperations // Session execution operations on the lease-bound sessionpg storage
}
Owner is everything bound to one execution lease: one field per domain's execution operations.
type Ownership ¶
type Ownership interface {
CheckOwnership(context.Context) error
CancelOperations(context.Context, context.CancelFunc) error
Close(context.Context) error
}
Ownership is the execution lease as the Worker uses it. *pgunit.Lease implements it.
type Policy ¶
type Policy struct {
Declarations harnessconfig.Registry
}
Policy supplies the Harness declarations that admission and dispatch read. The zero value uses the built-in Harnesses. Custom composition must supply the same policy to the HTTP handler and Dispatcher; Runtime claims never add declarations.
func (Policy) Harnesses ¶ added in v0.0.12
func (p Policy) Harnesses() harnessconfig.Registry
Harnesses returns the declarations this policy admits against.
func (Policy) ValidateSessionConfiguration ¶
func (p Policy) ValidateSessionConfiguration(engine string, configuration json.RawMessage) error
ValidateSessionConfiguration checks engine placement and configuration before persistence.
type PreparedRuntimeDeployment ¶
type PreparedRuntimeDeployment struct {
Config *RuntimeProvider
Publish func(*RuntimeProvider)
Selection *sandbox.Selection
VerifyCredential func(context.Context) error
FenceCredential func(context.Context) (func(), error)
}
PreparedRuntimeDeployment has completed provider validation without publishing a selection. Publish must only update in-memory state and must not fail. Selection is the resolved typed configuration returned by preparation.
type Result ¶
type Result struct {
EngineErrorCode string `json:"engine_error_code,omitempty"`
EngineHTTPStatus *int `json:"engine_http_status,omitempty"`
Done proto.DonePayload `json:"done"`
ErrorCode string `json:"error_code,omitempty"`
Error string `json:"error,omitempty"`
AppliedThrough int64 `json:"applied_through"`
}
type RuntimeDeploymentPreparer ¶
type RuntimeDeploymentPreparer func(context.Context, deployment.Setup) (PreparedRuntimeDeployment, error)
type RuntimeProvider ¶
type RuntimeProvider struct {
// PublishUnconfigured updates the shared observation cache after reset commit.
PublishUnconfigured func(uint64)
Generation uint64
Mode string
ProviderKind string
CoreURL string
InstallationID string
BackendFingerprint string
Provider sandbox.SandboxProvider
Suspension *RuntimeSuspensionPolicy
Resources sandbox.Resources
WorkspaceRequirements *workspacefs.Requirements
Workspace *workspacefs.Declaration
// contains filtered or unexported fields
}
RuntimeProvider binds one deployment to one sandbox installation. BackendFingerprint identifies its namespace independently of mutable sizing.
func NewDeferredRuntimeProvider ¶
func NewDeferredRuntimeProvider(installationID string, load func(context.Context) (*RuntimeProvider, error), prepare RuntimeDeploymentPreparer) *RuntimeProvider
NewDeferredRuntimeProvider enables Web setup for one fixed installation. The loader returns nil until selection, then the committed immutable generation; prepare validates each new selection before it is stored. Replacement is serialized by the deployment mutation gate and drain flow.
type RuntimeSuspensionPolicy ¶
RuntimeSuspensionPolicy supplies snapshot retention for a provider that suspends sandboxes. Deployment storage owns the mutable idle timeout.
type Snapshot ¶
type Snapshot struct {
ModelProviderConfigured bool `json:"model_provider_configured,omitempty"`
Agent v1.Agent `json:"agent"`
Environment v1.Environment `json:"environment"`
VaultIDs []string `json:"vault_ids,omitempty"`
MCPCredentials []vaults.MCPCredentialBinding `json:"mcp_credentials,omitempty"`
}
Snapshot is the Session configuration frozen at creation.
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker owns queued work; the database lease excludes a second execution service.
func StartWorker ¶
StartWorker takes over owner.Lease from the moment it is called: a failed start closes the lease before returning, and a started Worker closes it after Run drains.
func (*Worker) CancelSandboxReset ¶
func (*Worker) CheckOwnership ¶
CheckOwnership checks the same database lease used for execution writes.
func (*Worker) Configure ¶ added in v0.0.10
func (w *Worker) Configure(ctx context.Context, input workspaces.SelectionInput) (workspaces.Selection, error)
func (*Worker) CreateSession ¶
func (w *Worker) CreateSession(ctx context.Context, tenant string, input sessions.CreateSession) (sessions.Creation, error)
CreateSession validates execution support before the pooled Session creation reserves or admits initial work, and wakes the scheduler once that creation commits.
func (*Worker) InitializeSandboxDeployment ¶
func (*Worker) MetricsSnapshot ¶
func (w *Worker) MetricsSnapshot() WorkerMetrics
MetricsSnapshot copies bounded in-process observations without querying storage.
func (*Worker) ProvisionEnvironment ¶
func (w *Worker) ProvisionEnvironment(ctx context.Context, tenant, environment, providerKey string) (deployment.Allocation, error)
ProvisionEnvironment is an internal bootstrap operation for an already authorized hosted Environment. It does not enable public hosted admission.
func (*Worker) ReadEnvironmentDirectory ¶
func (w *Worker) ReadEnvironmentDirectory(ctx context.Context, environment sessions.Environment, path string) (proto.WorkspaceDirectoryResult, error)
ReadEnvironmentDirectory observes a Worker-owned read without admitting model input.
func (*Worker) ReconcileManagedRuntimes ¶
ReconcileManagedRuntimes is also callable before serving admission. One scan observes existing allocations and bootstraps committed resources without an allocation. It never retries an existing Create or native work.
func (*Worker) StartSandboxReset ¶
func (w *Worker) StartSandboxReset(ctx context.Context, input deployment.ResetRequest) (deployment.View, error)
func (*Worker) SubmitInputs ¶
func (*Worker) UpdateSandboxDeployment ¶
func (*Worker) WriteEnvironmentFile ¶
func (w *Worker) WriteEnvironmentFile(ctx context.Context, environment sessions.Environment, path string, data []byte) (int64, error)
WriteEnvironmentFile observes a Worker-owned mutation. Caller detachment never clears the durable write intent or starts a replacement operation.
type WorkerJobMetrics ¶
type WorkerJobMetrics struct {
Status coremetrics.JobStatus
LastRunAt *time.Time
Processed *int64
Failed *int64
}
WorkerJobMetrics describes the last completed scheduling poll. Failed counts failed polls, not failed Turns; Processed is unknown when a poll fails.
type WorkerMetrics ¶
type WorkerMetrics struct {
SlotsInUse int64
SlotsTotal int64
ExecutionOwner *bool
Scheduler WorkerJobMetrics
}
WorkerMetrics contains only observations from this worker's existing operations. A nil ExecutionOwner means the last ownership check failed.
Source Files
¶
- artifacts.go
- controls.go
- delivery.go
- deployment_provider_observations.go
- device_authority.go
- directory_preparation.go
- dispatcher.go
- environment.go
- environment_admission.go
- environment_directory.go
- environment_file_write.go
- environment_placement.go
- executor_observation.go
- executor_preparation.go
- finish.go
- functions.go
- harness_admission.go
- journal.go
- mcp.go
- mcp_credentials.go
- mcp_support.go
- message_input.go
- message_support.go
- model_execution.go
- notifications.go
- owner.go
- policy.go
- preparation.go
- prepared_dispatch.go
- request.go
- runtime_cancellation.go
- runtime_compute.go
- runtime_compute_wake.go
- runtime_connections.go
- runtime_initialization.go
- runtime_lifecycle.go
- runtime_manager.go
- runtime_observation.go
- runtime_pending.go
- runtime_preparation_cache.go
- runtime_setup.go
- runtime_wake_hint.go
- runtime_workspace.go
- sandbox_deployment_setup.go
- sandbox_deployment_switch.go
- sandbox_reset.go
- support.go
- worker.go
- worker_device.go
- worker_metrics.go
- worker_schedule.go
- worker_wakeup.go