worker

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const CASStatus30315 = 30315

Variables

This section is empty.

Functions

func NewPermissionDeniedError

func NewPermissionDeniedError(reason string) error

Types

type AllowlistAuthorizer

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

func NewControllerAllowlist

func NewControllerAllowlist(pubkeys ...string) *AllowlistAuthorizer

func NewPubkeyACL

func NewPubkeyACL(pubkeys ...string) *AllowlistAuthorizer

func (*AllowlistAuthorizer) Authorize

func (a *AllowlistAuthorizer) Authorize(_ context.Context, request Request) (Authorization, error)

func (*AllowlistAuthorizer) Kind

func (a *AllowlistAuthorizer) Kind() AuthKind

type AuditFacets

type AuditFacets struct {
	Actor       string `json:"actor,omitempty"`
	Action      string `json:"action,omitempty"`
	Target      string `json:"target,omitempty"`
	Outcome     string `json:"outcome,omitempty"`
	Correlation string `json:"correlation,omitempty"`
}

type AuthKind

type AuthKind string
const (
	AuthControllerAllowlist AuthKind = "controller-allowlist"
	AuthPubkeyACL           AuthKind = "pubkey-acl"
	AuthCashu               AuthKind = "cashu"
)

type Authorization

type Authorization struct {
	Requester string
}

type Authorizer

type Authorizer interface {
	Kind() AuthKind
	Authorize(ctx context.Context, request Request) (Authorization, error)
}

type BudgetContext

type BudgetContext struct {
	WorkerPubkey string
	Requester    string
	Method       string
	TaskID       string
}

type BudgetEvaluator

type BudgetEvaluator interface {
	Evaluate(ctx context.Context, usage costgovernance.BudgetUsage) (*costgovernance.BudgetDecision, error)
}

type BudgetUsageProvider

type BudgetUsageProvider interface {
	BudgetUsage(ctx context.Context, request BudgetContext) (costgovernance.BudgetUsage, error)
}

type CashuAuthorizer

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

func NewCashuAuthorizer

func NewCashuAuthorizer(pubkeys ...string) *CashuAuthorizer

func (*CashuAuthorizer) Authorize

func (a *CashuAuthorizer) Authorize(ctx context.Context, request Request) (Authorization, error)

func (*CashuAuthorizer) Kind

func (a *CashuAuthorizer) Kind() AuthKind

type Descriptor

type Descriptor struct {
	Profile   ProfileKind          `json:"profile"`
	Runtime   string               `json:"runtime"`
	AdKind    int                  `json:"ad_kind"`
	Methods   []Method             `json:"methods"`
	WorkModel WorkModel            `json:"work_model"`
	Schema    Schemas              `json:"schema"`
	Isolation *IsolationDescriptor `json:"isolation,omitempty"`
}

type Driver

type Driver interface {
	Execute(ctx context.Context, method string, params Params) (Outcome, error)
	Capabilities() Descriptor
}

type IsolationDescriptor

type IsolationDescriptor struct {
	Level     IsolationLevel `json:"level"`
	Mechanism string         `json:"mechanism"`
}

type IsolationLevel

type IsolationLevel string
const (
	IsolationProcess   IsolationLevel = "process"
	IsolationContainer IsolationLevel = "container"
	IsolationVM        IsolationLevel = "vm"
)

type Method

type Method struct {
	Name        string `json:"name"`
	ParamSchema string `json:"param_schema,omitempty"`
	Idempotent  bool   `json:"idempotent,omitempty"`
}

type Outcome

type Outcome struct {
	Result   json.RawMessage `json:"result,omitempty"`
	Status   TermStatus      `json:"status"`
	Audit    AuditFacets     `json:"audit"`
	Progress []StatusUpdate  `json:"progress,omitempty"`
}

type Params

type Params struct {
	Raw  json.RawMessage `json:"raw"`
	Meta RequestMeta     `json:"_meta"`
}

type PermissionDeniedError

type PermissionDeniedError struct {
	Reason string
}

PermissionDeniedError lets drivers reject an authorized controller's method-level request without turning the JSON-RPC response into success.

func (*PermissionDeniedError) Error

func (e *PermissionDeniedError) Error() string

type PreparedRequest

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

func (*PreparedRequest) Method

func (p *PreparedRequest) Method() string

type ProfileKind

type ProfileKind string
const (
	ProfileAgentLifecycle ProfileKind = "agent-lifecycle"
	ProfileCompute        ProfileKind = "compute"
	ProfileCI             ProfileKind = "ci"
	ProfileDocs           ProfileKind = "docs"
	ProfileMaintenance    ProfileKind = "maintenance"
)

type Publisher

type Publisher interface {
	Publish(ctx context.Context, event casnostr.Event) error
}

type RelayPublisher

type RelayPublisher struct{ RelayURLs []string }

func (RelayPublisher) Publish

func (p RelayPublisher) Publish(ctx context.Context, event casnostr.Event) error

type Request

type Request struct {
	Event  *casnostr.Event
	Method string
	Params json.RawMessage
}

type RequestMeta

type RequestMeta struct {
	ProgressToken string `json:"progressToken,omitempty"`
	CorrelationID string `json:"correlation_id,omitempty"`
	Requester     string `json:"requester,omitempty"`
}

type Runtime

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

func NewRuntime

func NewRuntime(cfg RuntimeConfig) (*Runtime, error)

func (*Runtime) Advertise

func (r *Runtime) Advertise(ctx context.Context) (*casnostr.Event, error)

func (*Runtime) ExecutePrepared

func (r *Runtime) ExecutePrepared(ctx context.Context, prepared *PreparedRequest) (contextvm.Response, error)

func (*Runtime) HandleGiftWrap

func (r *Runtime) HandleGiftWrap(ctx context.Context, outer *casnostr.Event) (contextvm.Response, error)

func (*Runtime) HandleIntent

func (r *Runtime) HandleIntent(ctx context.Context, event *casnostr.Event) (contextvm.Response, error)

func (*Runtime) PrepareGiftWrap

func (r *Runtime) PrepareGiftWrap(ctx context.Context, outer *casnostr.Event) (*PreparedRequest, contextvm.Response, error)

func (*Runtime) PrepareIntent

func (r *Runtime) PrepareIntent(ctx context.Context, event *casnostr.Event) (*PreparedRequest, contextvm.Response, error)

func (*Runtime) Profile

func (r *Runtime) Profile() ProfileKind

func (*Runtime) RejectPrepared

func (r *Runtime) RejectPrepared(ctx context.Context, prepared *PreparedRequest, err error) (contextvm.Response, error)

type RuntimeConfig

type RuntimeConfig struct {
	Driver              Driver
	Authorizer          Authorizer
	Signer              casnostr.Signer
	Publisher           Publisher
	RelayURLs           []string
	BudgetEvaluator     BudgetEvaluator
	BudgetUsageProvider BudgetUsageProvider
}

type Schemas

type Schemas struct {
	Control    string `json:"control,omitempty"`
	Capability string `json:"capability,omitempty"`
}

type StatusUpdate

type StatusUpdate struct {
	Status  string `json:"status"`
	Message string `json:"message,omitempty"`
}

type TermStatus

type TermStatus string
const (
	StatusOK       TermStatus = "ok"
	StatusFailed   TermStatus = "failed"
	StatusRejected TermStatus = "rejected"
)

type WorkModel

type WorkModel string
const (
	WorkModelDurableStateful    WorkModel = "durable-stateful"
	WorkModelEphemeralStateless WorkModel = "ephemeral-stateless"
)

Directories

Path Synopsis
drivers
ci
maintenance
Package maintenance implements the per-host fleet hygiene driver ("Swabbie"): scan → classify → quarantine → purge, plus system-pressure metrics.
Package maintenance implements the per-host fleet hygiene driver ("Swabbie"): scan → classify → quarantine → purge, plus system-pressure metrics.
Package vmexec defines the provider-neutral contract for running one job in an isolated virtual machine.
Package vmexec defines the provider-neutral contract for running one job in an isolated virtual machine.
fake
Package fake provides a scriptable vmexec engine for adapter and driver tests.
Package fake provides a scriptable vmexec engine for adapter and driver tests.
protocol
Package protocol implements the versioned NDJSON protocol shared by VM hosts and the cascadia guest agent.
Package protocol implements the versioned NDJSON protocol shared by VM hosts and the cascadia guest agent.

Jump to

Keyboard shortcuts

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