workspaces

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package workspaces owns durable Environment filesystem identities. The workspacefs protocol owns adapter configuration and attachment validation.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound      = errors.New("workspace not found")
	ErrConflict      = errors.New("workspace ownership or lifecycle conflict")
	ErrNotConfigured = errors.New("workspace filesystem is not configured")
	// ErrCapacityExhausted refuses a new workspace whose admission would exceed
	// the tenant capacity policy. It is an unavailable outcome, not invalid input.
	ErrCapacityExhausted = fmt.Errorf("%w: tenant workspace capacity exhausted", workspacefs.ErrUnavailable)
)

Functions

This section is empty.

Types

type Controls

Controls constructs the registered adapter for a retained configuration.

type ExecutionOperations

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

ExecutionOperations coordinates filesystem mutations under the execution lease.

func NewExecution

func NewExecution(storage Storage, execution ExecutionStorage, controls Controls, ownership Ownership) *ExecutionOperations

func (*ExecutionOperations) Configure

func (e *ExecutionOperations) Configure(ctx context.Context, input SelectionInput, validate func(workspacefs.Declaration) error) (Selection, error)

Configure qualifies and publishes selection while the caller holds the shared deployment mutation gate. Existing bindings keep their immutable configuration and admitted capacity; the tenant policy applies to new bindings only.

func (*ExecutionOperations) Declaration

func (*ExecutionOperations) DeleteBatch

func (e *ExecutionOperations) DeleteBatch(ctx context.Context, cursor string) (string, error)

DeleteBatch scans explicit deletion intent independently of compute inventory. The store excludes every unreleased allocation and retains terminal identities.

func (*ExecutionOperations) Ensure

func (e *ExecutionOperations) Ensure(ctx context.Context, tenant, environment string, requirements *workspacefs.Requirements, capacity uint32) (*workspacefs.Binding, error)

Ensure persists the binding before creation and retries only filesystem Create, whose protocol requires convergence. Compute reservation follows this operation. capacity is the deployment's request; it is admitted only for a new binding.

func (*ExecutionOperations) GetReady

func (e *ExecutionOperations) GetReady(ctx context.Context, tenant, environment string, requirements *workspacefs.Requirements) (*workspacefs.Binding, error)

GetReady never creates a filesystem or substitutes today's selected adapter.

func (*ExecutionOperations) Selection

func (e *ExecutionOperations) Selection(ctx context.Context) (Selection, error)

Selection reads the single operator-owned selection and tenant capacity policy.

type ExecutionStorage

type ExecutionStorage interface {
	// SelectConfiguration commits the selection and the tenant capacity policy
	// together with administrator audit on the execution lease, retaining
	// immutable previous configurations. Reusing an ID requires the same
	// adapter, parameters and credential.
	SelectConfiguration(context.Context, workspacefs.ConfigurationRecord, uint32) error
	// Bind returns an existing binding unchanged, across configuration and
	// policy changes. Otherwise it admits a new identity with the expected
	// configuration ID and capacity: ErrConflict if another configuration is
	// now selected; under a tenant capacity policy, ErrUnsupported for an
	// unbounded request and ErrCapacityExhausted when the tenant's workspaces
	// that are not yet deleted would exceed it or include an unbounded one.
	Bind(ctx context.Context, tenant, environment, configuration string, capacityMiB uint32) (Record, error)
	MarkReady(context.Context, workspacefs.Reference, workspacefs.Attachment) error
	// BeginDelete requires an explicitly deleted Session and released compute.
	BeginDelete(context.Context, workspacefs.Reference) error
	MarkDeleted(context.Context, workspacefs.Reference) error
}

ExecutionStorage writes only through the existing execution lease. Session locking serializes admission and ready publication against public deletion.

type Ownership

type Ownership interface{ CheckOwnership(context.Context) error }

type Record

type Record struct {
	Reference     workspacefs.Reference
	Configuration workspacefs.ConfigurationRecord
	CapacityMiB   uint32
	State         State
	Attachment    *workspacefs.Attachment
}

Record retains its reference, immutable configuration and admitted capacity after deletion so late creation receipts cannot reintroduce a deleted workspace. Configuration carries the decrypted credential for Control only.

type Selection

type Selection struct {
	workspacefs.Configuration
	TenantCapacityMiB uint32 `json:"tenant_capacity_mib" binding:"required"`
}

Selection is the workspace storage runtime setting: the selected immutable configuration and the tenant capacity policy, written together. Zero TenantCapacityMiB disables tenant admission; a positive value requires a configuration that enforces capacity quotas.

type SelectionInput

type SelectionInput struct {
	Selection
	Credential json.RawMessage
}

SelectionInput adds the write-only adapter credential. Omitting it when re-selecting an existing configuration retains its stored credential.

type State

type State string
const (
	Creating State = "creating"
	Ready    State = "ready"
	Deleting State = "deleting"
	Deleted  State = "deleted"
)

type Storage

type Storage interface {
	ActiveConfiguration(context.Context) (workspacefs.ConfigurationRecord, error)
	// Configuration returns a retained configuration by ID, or ErrNotFound.
	Configuration(context.Context, string) (workspacefs.ConfigurationRecord, error)
	Selection(context.Context) (Selection, error)
	Get(context.Context, string, string) (Record, error)
	// DeletionCandidates includes explicitly deleted Sessions even when no
	// compute allocation was ever made, and resumes committed deletion intent.
	// Unreleased compute ownership excludes a workspace from this list.
	DeletionCandidates(context.Context, string) ([]Record, error)
}

Storage reads configurations and ownership; it grants no execution authority. Records and configurations carry their decrypted credentials; Selection is public.

Jump to

Keyboard shortcuts

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