Documentation
¶
Overview ¶
Package workspace defines owner-pinned workspace and environment contracts. Host implementations perform Git, container, and remote-runtime operations.
Index ¶
- Variables
- type Environment
- type Lease
- type ManagedWorktrees
- func (m ManagedWorktrees) Cleanup(ctx context.Context, id string, owner execution.Identity, expected uint64) error
- func (m ManagedWorktrees) Create(ctx context.Context, request WorktreeRequest) (Lease, error)
- func (m ManagedWorktrees) Recover(ctx context.Context, owner execution.Identity) ([]Lease, error)
- type Manager
- type MemoryManager
- func (m *MemoryManager) Acquire(ctx context.Context, lease Lease) error
- func (m *MemoryManager) Get(ctx context.Context, id string, owner execution.Identity) (Lease, bool, error)
- func (m *MemoryManager) List(ctx context.Context, owner execution.Identity) ([]Lease, error)
- func (m *MemoryManager) Release(ctx context.Context, id string, owner execution.Identity, expected uint64) error
- type MemoryTerminalStore
- func (s *MemoryTerminalStore) CompareAndSwap(ctx context.Context, identity execution.Identity, id string, expected uint64, ...) (TerminalLease, error)
- func (s *MemoryTerminalStore) Create(ctx context.Context, lease TerminalLease) (TerminalLease, error)
- func (s *MemoryTerminalStore) Get(ctx context.Context, identity execution.Identity, id string) (TerminalLease, bool, error)
- type MemoryWorktreeStore
- func (s *MemoryWorktreeStore) CompareAndSwap(ctx context.Context, owner execution.Identity, id string, expected uint64, ...) (Worktree, error)
- func (s *MemoryWorktreeStore) Create(ctx context.Context, item Worktree) (Worktree, error)
- func (s *MemoryWorktreeStore) Get(ctx context.Context, owner execution.Identity, id string) (Worktree, bool, error)
- func (s *MemoryWorktreeStore) List(ctx context.Context, owner execution.Identity) ([]Worktree, error)
- type Mode
- type NetworkPolicy
- type Placement
- type Repository
- type ResourceLimits
- type SandboxCapabilities
- type SandboxDriver
- type SandboxHandle
- type SandboxRequest
- type SandboxRuntime
- type TerminalController
- func (c TerminalController) Disconnect(ctx context.Context, identity execution.Identity, id string, expected uint64) (TerminalLease, error)
- func (c TerminalController) Handoff(ctx context.Context, identity execution.Identity, id string, expected uint64, ...) (TerminalLease, error)
- func (c TerminalController) Resize(ctx context.Context, identity execution.Identity, id string, expected uint64, ...) (TerminalLease, error)
- type TerminalLease
- type TerminalOwner
- type TerminalStore
- type Worktree
- type WorktreeDriver
- type WorktreeManager
- type WorktreeRequest
- type WorktreeState
- type WorktreeStore
Constants ¶
This section is empty.
Variables ¶
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) Create ¶
func (m ManagedWorktrees) Create(ctx context.Context, request WorktreeRequest) (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
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 (s *MemoryTerminalStore) Create(ctx context.Context, lease TerminalLease) (TerminalLease, error)
type MemoryWorktreeStore ¶
type MemoryWorktreeStore struct {
// contains filtered or unexported fields
}
func NewMemoryWorktreeStore ¶
func NewMemoryWorktreeStore() *MemoryWorktreeStore
func (*MemoryWorktreeStore) CompareAndSwap ¶
type NetworkPolicy ¶
type NetworkPolicy string
const ( NetworkNone NetworkPolicy = "none" NetworkRestricted NetworkPolicy = "restricted" NetworkHost NetworkPolicy = "host" )
type Repository ¶
type ResourceLimits ¶
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 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 ¶
func (r SandboxRuntime) Start(ctx context.Context, request SandboxRequest) (SandboxHandle, error)
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 TerminalStore ¶
type TerminalStore interface {
Create(context.Context, TerminalLease) (TerminalLease, error)
CompareAndSwap(context.Context, execution.Identity, string, uint64, TerminalOwner, int, int) (TerminalLease, error)
Get(context.Context, execution.Identity, string) (TerminalLease, bool, error)
}
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 WorktreeManager ¶
type WorktreeRequest ¶
type WorktreeState ¶
type WorktreeState string
const ( WorktreeCreating WorktreeState = "creating" WorktreeReady WorktreeState = "ready" WorktreeCleaning WorktreeState = "cleaning" WorktreeRemoved WorktreeState = "removed" WorktreeOrphaned WorktreeState = "orphaned" )
type WorktreeStore ¶
type WorktreeStore interface {
Create(context.Context, Worktree) (Worktree, error)
CompareAndSwap(context.Context, execution.Identity, string, uint64, WorktreeState, Lease, string) (Worktree, error)
Get(context.Context, execution.Identity, string) (Worktree, bool, error)
List(context.Context, execution.Identity) ([]Worktree, error)
}