workspace

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2026 License: Apache-2.0 Imports: 13 Imported by: ? 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 workspace defines owner-pinned workspace and environment contracts. Host implementations perform Git, container, and remote-runtime operations.

Index

Constants

This section is empty.

Variables

View Source
var ErrTerminalRevision = errors.New("terminal ownership revision conflict")

Functions

This section is empty.

Types

type Environment

type Environment struct {
	Version          int               `json:"version"`
	Placement        Placement         `json:"placement"`
	WorkspaceLeaseID string            `json:"workspace_lease_id"`
	ImageDigest      string            `json:"image_digest,omitempty"`
	Repositories     []Repository      `json:"repositories,omitempty"`
	Setup            []string          `json:"setup,omitempty"`
	Runtime          map[string]string `json:"runtime,omitempty"`
	Network          NetworkPolicy     `json:"network"`
	Resources        ResourceLimits    `json:"resources"`
	SecretBindings   []string          `json:"secret_bindings,omitempty"`
	CleanupPolicy    string            `json:"cleanup_policy,omitempty"`
	Digest           string            `json:"digest"`
}

Environment is a reproducible placement description, not a sandbox claim.

func (Environment) Seal

func (e Environment) Seal() (Environment, error)

func (Environment) Validate

func (e Environment) Validate() error

type Lease

type Lease struct {
	ID            string             `json:"id"`
	Workspace     string             `json:"workspace"`
	Root          string             `json:"root"`
	CanonicalRoot string             `json:"canonical_root"`
	Mode          Mode               `json:"mode"`
	Owner         execution.Identity `json:"owner"`
	AcquiredAt    time.Time          `json:"acquired_at"`
	ExpiresAt     time.Time          `json:"expires_at,omitempty"`
	Revision      uint64             `json:"revision"`
}

Lease is the durable workspace authority held by one child or root run.

type ManagedWorktrees

type ManagedWorktrees struct {
	Driver WorktreeDriver
	Store  WorktreeStore
	Leases Manager
}

func (ManagedWorktrees) Cleanup

func (m ManagedWorktrees) Cleanup(ctx context.Context, id string, owner execution.Identity, expected uint64) error

func (ManagedWorktrees) Create

func (m ManagedWorktrees) Create(ctx context.Context, request WorktreeRequest) (Lease, error)

func (ManagedWorktrees) Recover

func (m ManagedWorktrees) Recover(ctx context.Context, owner execution.Identity) ([]Lease, error)

type MemoryManager

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

MemoryManager keys exclusion by canonical filesystem identity, not by the caller's workspace label. It also notices root replacement while leased.

func NewMemoryManager

func NewMemoryManager() *MemoryManager

func (*MemoryManager) Acquire

func (m *MemoryManager) Acquire(ctx context.Context, lease Lease) error

func (*MemoryManager) Get

func (m *MemoryManager) Get(ctx context.Context, id string, owner execution.Identity) (Lease, bool, error)

func (*MemoryManager) List

func (m *MemoryManager) List(ctx context.Context, owner execution.Identity) ([]Lease, error)

func (*MemoryManager) Release

func (m *MemoryManager) Release(ctx context.Context, id string, owner execution.Identity, expected uint64) error

type MemoryTerminalStore

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

func NewMemoryTerminalStore

func NewMemoryTerminalStore() *MemoryTerminalStore

func (*MemoryTerminalStore) CompareAndSwap

func (s *MemoryTerminalStore) CompareAndSwap(ctx context.Context, identity execution.Identity, id string, expected uint64, owner TerminalOwner, rows, columns int) (TerminalLease, error)

func (*MemoryTerminalStore) Create

func (*MemoryTerminalStore) Get

type MemoryWorktreeStore

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

func NewMemoryWorktreeStore

func NewMemoryWorktreeStore() *MemoryWorktreeStore

func (*MemoryWorktreeStore) CompareAndSwap

func (s *MemoryWorktreeStore) CompareAndSwap(ctx context.Context, owner execution.Identity, id string, expected uint64, state WorktreeState, lease Lease, lastError string) (Worktree, error)

func (*MemoryWorktreeStore) Create

func (s *MemoryWorktreeStore) Create(ctx context.Context, item Worktree) (Worktree, error)

func (*MemoryWorktreeStore) Get

func (*MemoryWorktreeStore) List

type Mode

type Mode string
const (
	ModeReadOnly Mode = "read_only"
	ModeMutable  Mode = "mutable"
)

type NetworkPolicy

type NetworkPolicy string
const (
	NetworkNone       NetworkPolicy = "none"
	NetworkRestricted NetworkPolicy = "restricted"
	NetworkHost       NetworkPolicy = "host"
)

type Placement

type Placement string
const (
	PlacementLocal     Placement = "local"
	PlacementContainer Placement = "container"
	PlacementRemote    Placement = "remote"
)

type Repository

type Repository struct {
	URL      string `json:"url"`
	Revision string `json:"revision"`
	Path     string `json:"path"`
}

type ResourceLimits

type ResourceLimits struct {
	CPUMillis    int   `json:"cpu_millis,omitempty"`
	MemoryBytes  int64 `json:"memory_bytes,omitempty"`
	ProcessCount int   `json:"process_count,omitempty"`
}

type SandboxCapabilities

type SandboxCapabilities struct {
	Placements         []Placement     `json:"placements"`
	NetworkPolicies    []NetworkPolicy `json:"network_policies"`
	EnforcesCPU        bool            `json:"enforces_cpu"`
	EnforcesMemory     bool            `json:"enforces_memory"`
	EnforcesProcesses  bool            `json:"enforces_processes"`
	EnforcesFilesystem bool            `json:"enforces_filesystem"`
	EnforcesSecrets    bool            `json:"enforces_secrets"`
}

type SandboxDriver

type SandboxDriver interface {
	Name() string
	Capabilities(context.Context) (SandboxCapabilities, error)
	Start(context.Context, SandboxRequest) (SandboxHandle, error)
	Stop(context.Context, SandboxHandle) error
	Health(context.Context, SandboxHandle) error
}

SandboxDriver is an enforcement backend, not merely a process launcher. Capabilities are checked before Start so unsupported restrictions fail shut.

type SandboxHandle

type SandboxHandle struct {
	ID                string    `json:"id"`
	Driver            string    `json:"driver"`
	EnvironmentDigest string    `json:"environment_digest"`
	StartedAt         time.Time `json:"started_at"`
}

type SandboxRequest

type SandboxRequest struct {
	ID          string             `json:"id"`
	Identity    execution.Identity `json:"identity"`
	Environment Environment        `json:"environment"`
	Executable  string             `json:"executable"`
	Arguments   []string           `json:"arguments,omitempty"`
	WorkingDir  string             `json:"working_dir"`
	Deadline    time.Time          `json:"deadline,omitempty"`
}

type SandboxRuntime

type SandboxRuntime struct{ Driver SandboxDriver }

func (SandboxRuntime) Start

type TerminalController

type TerminalController struct{ Store TerminalStore }

func (TerminalController) Disconnect

func (c TerminalController) Disconnect(ctx context.Context, identity execution.Identity, id string, expected uint64) (TerminalLease, error)

Disconnect hands control back to the host under CAS. Stale agents cannot reclaim input because every ownership change increments the generation.

func (TerminalController) Handoff

func (c TerminalController) Handoff(ctx context.Context, identity execution.Identity, id string, expected uint64, to TerminalOwner) (TerminalLease, error)

func (TerminalController) Resize

func (c TerminalController) Resize(ctx context.Context, identity execution.Identity, id string, expected uint64, actor TerminalOwner, rows, columns int) (TerminalLease, error)

type TerminalLease

type TerminalLease struct {
	ID         string             `json:"id"`
	Identity   execution.Identity `json:"identity"`
	Owner      TerminalOwner      `json:"owner"`
	Generation uint64             `json:"generation"`
	Rows       int                `json:"rows,omitempty"`
	Columns    int                `json:"columns,omitempty"`
	Revision   uint64             `json:"revision"`
	UpdatedAt  time.Time          `json:"updated_at"`
}

type TerminalOwner

type TerminalOwner string
const (
	TerminalHost     TerminalOwner = "host"
	TerminalAgent    TerminalOwner = "agent"
	TerminalApproval TerminalOwner = "approval"
	TerminalUser     TerminalOwner = "user"
)

type Worktree

type Worktree struct {
	Request   WorktreeRequest `json:"request"`
	Lease     Lease           `json:"lease"`
	State     WorktreeState   `json:"state"`
	LastError string          `json:"last_error,omitempty"`
	Revision  uint64          `json:"revision"`
	UpdatedAt time.Time       `json:"updated_at"`
}

type WorktreeDriver

type WorktreeDriver interface {
	Create(context.Context, WorktreeRequest) (string, error)
	Cleanup(context.Context, string) error
}

type WorktreeManager

type WorktreeManager interface {
	Create(context.Context, WorktreeRequest) (Lease, error)
	Recover(context.Context, execution.Identity) ([]Lease, error)
	Cleanup(context.Context, string, execution.Identity, uint64) error
}

type WorktreeRequest

type WorktreeRequest struct {
	ID       string
	Owner    execution.Identity
	Source   string
	Revision string
	Path     string
}

type WorktreeState

type WorktreeState string
const (
	WorktreeCreating WorktreeState = "creating"
	WorktreeReady    WorktreeState = "ready"
	WorktreeCleaning WorktreeState = "cleaning"
	WorktreeRemoved  WorktreeState = "removed"
	WorktreeOrphaned WorktreeState = "orphaned"
)

Jump to

Keyboard shortcuts

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