runtimeclient

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RuntimeLeaseSignatureSchemaVersion = "redevplugin.runtime_execution_lease.v1"
	RuntimeLeaseTokenKind              = "runtime_execution_lease"
	RuntimeLeaseSignatureAlgorithm     = "ed25519"
)

Variables

View Source
var (
	ErrRuntimeLeaseInvalid = errors.New("runtime execution lease is invalid")
	ErrRuntimeLeaseReplay  = errors.New("runtime execution lease has already been consumed")
)
View Source
var (
	ErrRuntimeLeaseSignatureKeyringRequired = errors.New("runtime lease signing keyring is required")
	ErrRuntimeLeaseSigningKeyNotFound       = errors.New("runtime lease signing key not found")
	ErrRuntimeLeaseSigningKeyRevoked        = errors.New("runtime lease signing key is revoked")
	ErrRuntimeLeasePublicKeyInvalid         = errors.New("runtime lease signing public key is invalid")
	ErrRuntimeLeaseSignatureRequired        = errors.New("runtime execution lease signature is required")
	ErrRuntimeLeaseSignatureInvalid         = errors.New("runtime execution lease signature is invalid")
)
View Source
var (
	ErrRuntimePathRequired   = errors.New("runtime path is required")
	ErrRuntimeNotReady       = errors.New("runtime is not ready")
	ErrRuntimeIPCUnavailable = errors.New("runtime ipc transport is unavailable")
	ErrRuntimeHandshake      = errors.New("runtime ipc handshake failed")
	ErrRuntimeRequestFailed  = errors.New("runtime ipc request failed")
)

Functions

func CanonicalRuntimeLeaseSignaturePayload

func CanonicalRuntimeLeaseSignaturePayload(lease Lease, method string) ([]byte, error)

Types

type ArtifactProvider

type ArtifactProvider interface {
	ReadArtifact(ctx context.Context, req ArtifactRequest) (ArtifactResult, error)
}

type ArtifactRequest

type ArtifactRequest struct {
	PackageHash    string `json:"package_hash"`
	Artifact       string `json:"artifact"`
	ArtifactSHA256 string `json:"artifact_sha256"`
}

type ArtifactResult

type ArtifactResult struct {
	Content []byte `json:"-"`
	SHA256  string `json:"sha256"`
}

type Ed25519RuntimeLeaseVerifier

type Ed25519RuntimeLeaseVerifier struct {
	Keyring RuntimeLeaseSigningKeyring
	Now     func() time.Time
}

func (Ed25519RuntimeLeaseVerifier) VerifyRuntimeLease

type HandleGrantValidationRequest

type HandleGrantValidationRequest struct {
	HandleGrantToken    string `json:"handle_grant_token"`
	PluginInstanceID    string `json:"plugin_instance_id"`
	ActiveFingerprint   string `json:"active_fingerprint"`
	RuntimeInstanceID   string `json:"runtime_instance_id,omitempty"`
	RuntimeGenerationID string `json:"runtime_generation_id"`
	RuntimeShardID      string `json:"runtime_shard_id,omitempty"`
	HandleID            string `json:"handle_id"`
	Method              string `json:"method"`
	PolicyRevision      uint64 `json:"policy_revision"`
	ManagementRevision  uint64 `json:"management_revision"`
	RevokeEpoch         uint64 `json:"revoke_epoch"`
}

type HandleGrantValidationResult

type HandleGrantValidationResult struct {
	HandleGrantID       string `json:"handle_grant_id"`
	HandleID            string `json:"handle_id"`
	Method              string `json:"method"`
	RuntimeGenerationID string `json:"runtime_generation_id"`
	MaxBytesPerSecond   int64  `json:"max_bytes_per_second,omitempty"`
	MaxTotalBytes       int64  `json:"max_total_bytes,omitempty"`
}

type HandleGrantValidator

type HandleGrantValidator interface {
	ValidateHandleGrant(ctx context.Context, req HandleGrantValidationRequest) (HandleGrantValidationResult, error)
}

type Health

type Health struct {
	RuntimeInstanceID   string `json:"runtime_instance_id"`
	RuntimeGenerationID string `json:"runtime_generation_id"`
	IPCChannelID        string `json:"ipc_channel_id,omitempty"`
	ConnectionNonce     string `json:"connection_nonce,omitempty"`
	RuntimeVersion      string `json:"runtime_version,omitempty"`
	RustIPCVersion      string `json:"rust_ipc_version,omitempty"`
	WASMABIVersion      string `json:"wasm_abi_version,omitempty"`
	Ready               bool   `json:"ready"`
}

type HeartbeatResult

type HeartbeatResult struct {
	RuntimeGenerationID  string `json:"runtime_generation_id"`
	RuntimeUnixNano      int64  `json:"runtime_unix_nano"`
	MaxStalenessMillis   int64  `json:"max_staleness_ms"`
	HostSentUnixNanoEcho int64  `json:"host_sent_unix_nano"`
}

type Lease

type Lease struct {
	LeaseID                string      `json:"lease_id"`
	TokenID                string      `json:"token_id,omitempty"`
	LeaseToken             string      `json:"lease_token"`
	LeaseNonce             string      `json:"lease_nonce"`
	PluginID               string      `json:"plugin_id,omitempty"`
	PluginVersion          string      `json:"plugin_version,omitempty"`
	ActiveFingerprint      string      `json:"active_fingerprint,omitempty"`
	SurfaceInstanceID      string      `json:"surface_instance_id,omitempty"`
	OwnerSessionHash       string      `json:"owner_session_hash,omitempty"`
	OwnerUserHash          string      `json:"owner_user_hash,omitempty"`
	SessionChannelIDHash   string      `json:"session_channel_id_hash,omitempty"`
	BridgeChannelID        string      `json:"bridge_channel_id,omitempty"`
	RuntimeGenerationID    string      `json:"runtime_generation_id"`
	PluginInstanceID       string      `json:"plugin_instance_id"`
	Method                 string      `json:"method,omitempty"`
	Effect                 string      `json:"effect,omitempty"`
	Execution              string      `json:"execution,omitempty"`
	OperationID            string      `json:"operation_id,omitempty"`
	StreamID               string      `json:"stream_id,omitempty"`
	AuditCorrelationID     string      `json:"audit_correlation_id,omitempty"`
	TargetDescriptorHashes []string    `json:"target_descriptor_hashes,omitempty"`
	Limits                 LeaseLimits `json:"limits,omitempty"`
	PolicyRevision         uint64      `json:"policy_revision"`
	ManagementRevision     uint64      `json:"management_revision"`
	RevokeEpoch            uint64      `json:"revoke_epoch"`
	RuntimeShardID         string      `json:"runtime_shard_id,omitempty"`
	RuntimeInstanceID      string      `json:"runtime_instance_id,omitempty"`
	IPCChannelID           string      `json:"ipc_channel_id,omitempty"`
	ConnectionNonce        string      `json:"connection_nonce,omitempty"`
	KeyID                  string      `json:"key_id,omitempty"`
	Signature              string      `json:"signature,omitempty"`
	IssuedAt               time.Time   `json:"issued_at,omitempty"`
	IssuedAtUnixMillis     int64       `json:"issued_at_unix_ms,omitempty"`
	ExpiresAt              time.Time   `json:"expires_at"`
}

func SignRuntimeLease

func SignRuntimeLease(lease Lease, method string, keyID string, privateKey ed25519.PrivateKey) (Lease, error)

type LeaseLimits

type LeaseLimits struct {
	TimeoutMillis           int64 `json:"timeout_ms,omitempty"`
	MemoryBytes             int64 `json:"memory_bytes,omitempty"`
	MaxPayloadBytes         int64 `json:"max_payload_bytes,omitempty"`
	MaxStreamBytesPerSecond int64 `json:"max_stream_bytes_per_sec,omitempty"`
}

type MemoryRuntimeLeaseReplayStore

type MemoryRuntimeLeaseReplayStore struct {
	// contains filtered or unexported fields
}

func NewMemoryRuntimeLeaseReplayStore

func NewMemoryRuntimeLeaseReplayStore() *MemoryRuntimeLeaseReplayStore

func (*MemoryRuntimeLeaseReplayStore) ConsumeRuntimeLease

func (*MemoryRuntimeLeaseReplayStore) ListRuntimeLeaseReplays

type ProcessSupervisor

type ProcessSupervisor struct {
	// contains filtered or unexported fields
}

func NewProcessSupervisor

func NewProcessSupervisor(options ProcessSupervisorOptions) (*ProcessSupervisor, error)

func (*ProcessSupervisor) Health

func (*ProcessSupervisor) Heartbeat

func (s *ProcessSupervisor) Heartbeat(ctx context.Context) (HeartbeatResult, error)

func (*ProcessSupervisor) InvokeWorker

func (s *ProcessSupervisor) InvokeWorker(ctx context.Context, lease Lease, method string, payload []byte) ([]byte, error)

func (*ProcessSupervisor) Revoke

func (s *ProcessSupervisor) Revoke(ctx context.Context, pluginInstanceID string, revokeEpoch uint64) (RevokeResult, error)

func (*ProcessSupervisor) Start

func (s *ProcessSupervisor) Start(ctx context.Context, target Target) error

func (*ProcessSupervisor) Stop

func (s *ProcessSupervisor) Stop(ctx context.Context) error

type ProcessSupervisorOptions

type ProcessSupervisorOptions struct {
	RuntimePath           string
	Args                  []string
	Env                   []string
	Dir                   string
	Diagnostics           observability.DiagnosticsSink
	Artifacts             ArtifactProvider
	HandleGrants          HandleGrantValidator
	RuntimeLeaseReplays   RuntimeLeaseReplayStore
	StorageFiles          storage.FilesBroker
	StorageKV             storage.KVBroker
	StorageSQLite         storage.SQLiteBroker
	Connectivity          connectivity.Broker
	NetworkExecutor       connectivity.NetworkExecutor
	StreamSink            RuntimeStreamSink
	Now                   func() time.Time
	HandshakeTimeout      time.Duration
	HeartbeatInterval     time.Duration
	MaxHeartbeatStaleness time.Duration
}

type RevokeResult

type RevokeResult struct {
	PluginInstanceID         string `json:"plugin_instance_id"`
	RevokeEpoch              uint64 `json:"revoke_epoch"`
	ClosedSocketCount        int    `json:"closed_socket_count"`
	ClosedStreamCount        int    `json:"closed_stream_count"`
	ClosedStorageHandleCount int    `json:"closed_storage_handle_count"`
}

type RuntimeLeasePublicKey

type RuntimeLeasePublicKey struct {
	Algorithm       string `json:"algorithm"`
	KeyID           string `json:"key_id"`
	PublicKeyBase64 string `json:"public_key_base64"`
}

func NormalizeRuntimeLeasePublicKeys

func NormalizeRuntimeLeasePublicKeys(keys []RuntimeLeasePublicKey) ([]RuntimeLeasePublicKey, error)

func RuntimeLeasePublicKeyFromEd25519

func RuntimeLeasePublicKeyFromEd25519(keyID string, publicKey ed25519.PublicKey) (RuntimeLeasePublicKey, error)

type RuntimeLeaseReplayConsumeRequest

type RuntimeLeaseReplayConsumeRequest struct {
	Lease  Lease     `json:"lease"`
	Method string    `json:"method"`
	Now    time.Time `json:"now,omitempty"`
}

type RuntimeLeaseReplayListRequest

type RuntimeLeaseReplayListRequest struct {
	PluginInstanceID string `json:"plugin_instance_id,omitempty"`
}

type RuntimeLeaseReplayLister

type RuntimeLeaseReplayLister interface {
	ListRuntimeLeaseReplays(ctx context.Context, req RuntimeLeaseReplayListRequest) ([]RuntimeLeaseReplayRecord, error)
}

type RuntimeLeaseReplayRecord

type RuntimeLeaseReplayRecord struct {
	LeaseID             string    `json:"lease_id"`
	LeaseNonceHash      string    `json:"lease_nonce_hash"`
	PluginInstanceID    string    `json:"plugin_instance_id"`
	RuntimeGenerationID string    `json:"runtime_generation_id"`
	Method              string    `json:"method"`
	PolicyRevision      uint64    `json:"policy_revision"`
	ManagementRevision  uint64    `json:"management_revision"`
	RevokeEpoch         uint64    `json:"revoke_epoch"`
	ConsumedAt          time.Time `json:"consumed_at"`
	ExpiresAt           time.Time `json:"expires_at"`
}

type RuntimeLeaseReplayStore

type RuntimeLeaseReplayStore interface {
	ConsumeRuntimeLease(ctx context.Context, req RuntimeLeaseReplayConsumeRequest) (RuntimeLeaseReplayRecord, error)
}

type RuntimeLeaseSigningKey

type RuntimeLeaseSigningKey struct {
	KeyID               string            `json:"key_id"`
	PublicKey           ed25519.PublicKey `json:"-"`
	RuntimeShardID      string            `json:"runtime_shard_id,omitempty"`
	RuntimeInstanceID   string            `json:"runtime_instance_id,omitempty"`
	RuntimeGenerationID string            `json:"runtime_generation_id,omitempty"`
	IPCChannelID        string            `json:"ipc_channel_id,omitempty"`
	ConnectionNonce     string            `json:"connection_nonce,omitempty"`
	Revoked             bool              `json:"revoked,omitempty"`
	Metadata            map[string]string `json:"metadata,omitempty"`
}

type RuntimeLeaseSigningKeyLookupRequest

type RuntimeLeaseSigningKeyLookupRequest struct {
	KeyID               string `json:"key_id"`
	RuntimeShardID      string `json:"runtime_shard_id,omitempty"`
	RuntimeInstanceID   string `json:"runtime_instance_id,omitempty"`
	RuntimeGenerationID string `json:"runtime_generation_id"`
	IPCChannelID        string `json:"ipc_channel_id,omitempty"`
	ConnectionNonce     string `json:"connection_nonce,omitempty"`
	PluginInstanceID    string `json:"plugin_instance_id,omitempty"`
	Method              string `json:"method,omitempty"`
}

type RuntimeLeaseSigningKeyring

type RuntimeLeaseSigningKeyring interface {
	LookupRuntimeLeaseSigningKey(ctx context.Context, req RuntimeLeaseSigningKeyLookupRequest) (RuntimeLeaseSigningKey, error)
}

type RuntimeLeaseVerificationRequest

type RuntimeLeaseVerificationRequest struct {
	Lease  Lease     `json:"lease"`
	Method string    `json:"method"`
	Now    time.Time `json:"now,omitempty"`
}

type RuntimeLeaseVerifier

type RuntimeLeaseVerifier interface {
	VerifyRuntimeLease(ctx context.Context, req RuntimeLeaseVerificationRequest) error
}

type RuntimeStreamSink added in v0.3.0

type RuntimeStreamSink interface {
	AppendRuntimeStream(ctx context.Context, streamID, kind string, data []byte) error
	CloseRuntimeStream(ctx context.Context, streamID string) error
	FailRuntimeStream(ctx context.Context, streamID, reason string) error
}

type SQLiteRuntimeLeaseReplayStore

type SQLiteRuntimeLeaseReplayStore struct {
	// contains filtered or unexported fields
}

func NewSQLiteRuntimeLeaseReplayStore

func NewSQLiteRuntimeLeaseReplayStore(ctx context.Context, path string) (*SQLiteRuntimeLeaseReplayStore, error)

func (*SQLiteRuntimeLeaseReplayStore) Close

func (*SQLiteRuntimeLeaseReplayStore) ConsumeRuntimeLease

func (*SQLiteRuntimeLeaseReplayStore) ListRuntimeLeaseReplays

type StaticRuntimeLeaseSigningKeyring

type StaticRuntimeLeaseSigningKeyring struct {
	Keys []RuntimeLeaseSigningKey
}

func (StaticRuntimeLeaseSigningKeyring) LookupRuntimeLeaseSigningKey

type Supervisor

type Supervisor interface {
	Start(ctx context.Context, target Target) error
	Stop(ctx context.Context) error
	Health(ctx context.Context) (Health, error)
	Heartbeat(ctx context.Context) (HeartbeatResult, error)
	InvokeWorker(ctx context.Context, lease Lease, method string, payload []byte) ([]byte, error)
	Revoke(ctx context.Context, pluginInstanceID string, revokeEpoch uint64) (RevokeResult, error)
}

type Target

type Target struct {
	OS   string `json:"os"`
	Arch string `json:"arch"`
}

type WorkerErrorOrigin added in v0.4.0

type WorkerErrorOrigin string
const (
	WorkerErrorOriginRuntime  WorkerErrorOrigin = "runtime"
	WorkerErrorOriginHostcall WorkerErrorOrigin = "hostcall"
	WorkerErrorOriginPlugin   WorkerErrorOrigin = "plugin"
)

type WorkerExecutionError added in v0.4.0

type WorkerExecutionError struct {
	Code    string
	Message string
	Origin  WorkerErrorOrigin
}

func (*WorkerExecutionError) Error added in v0.4.0

func (e *WorkerExecutionError) Error() string

func (*WorkerExecutionError) Unwrap added in v0.4.0

func (e *WorkerExecutionError) Unwrap() error

Jump to

Keyboard shortcuts

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