local

package
v0.2.63 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MPL-2.0 Imports: 23 Imported by: 1 module, 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 local is the dev/self-host workspace provider: a workspace is a directory under --workspace-local-root, and exec runs the command as the chassis's own uid with that directory as HOME and cwd.

There is NO isolation beyond a scrubbed environment — the command can read anything the chassis uid can, and `cwd` may name any directory on the machine. That is why the chassis refuses this provider unless --workspace-allow-local is set explicitly, never implied by --env, and logs a WARN pair at boot.

With TXCO_WORKSPACE_LOCAL_EXEC set, a command is not run here at all: it is handed to that prefix program, which runs it on another machine (via.go).

import _ "github.com/loremlabs/thanks-computer/chassis/workspace/local"

Index

Constants

View Source
const (
	EnvAttachRoot  = "TXCO_ATTACH_ROOT"
	EnvAttachState = "TXCO_ATTACH_STATE"
)

Environment variables every owner-mode command is given, set last.

View Source
const EnvExec = "TXCO_WORKSPACE_LOCAL_EXEC"

EnvExec names the one setting this provider reads for itself: a command prefix every workspace command is handed to, instead of being run here.

TXCO_WORKSPACE_LOCAL_EXEC="sprite exec -s dev-{name} --"
TXCO_WORKSPACE_LOCAL_EXEC="docker exec -i pony-{name}"

It is how a chassis on a laptop drives a real machine without another provider: the workspace is still a directory here (its bookkeeping, its lease, its name), but a command runs wherever the prefix program puts it. The prefix is whitespace-separated words, no quoting; `{tenant}`, `{stack}` and `{name}` are replaced in each word (a `/` in a name becomes `-`). `txco dev --workspace-local-exec` sets it.

What changes when it is set, and why:

  • The command is run as `<prefix…> /bin/sh -c <script>`. The script is the request's command with its variables written in front of it as `export` lines: a process environment does not cross to another machine, so the variables travel inside the command. That includes a run grant's token, which is therefore in the prefix program's argv on this machine. This is the dev posture, as the provider already is.
  • The prefix program itself runs with the CHASSIS's environment, not the scrubbed one: it is the operator's own program and needs its login and its configuration (`sprite`, `docker`). Nothing of that environment reaches the command unless the program sends it.
  • `cwd` beneath the workspace becomes a `cd` relative to wherever the other machine starts a command (its home); an absolute path outside the workspace is used as given, there.
  • The other machine is not made or removed by Create and Destroy, has no stack trees ($TXCO_STACK_DIR), and cannot be dialled (the connect verb) or held open (sessions, a terminal): the provider says so rather than quietly doing those things on this machine.
  • Its commands do not reach this chassis's grant socket, so a grant is handed over as a provider elsewhere gets it: the token and the run's name, not the socket.
  • A timeout kills the prefix program. What it had started on the other machine may run on; that is the program's to end.
View Source
const OwnerName = "owner"

OwnerName is the owner provider's name (--workspace-provider).

View Source
const OwnerTenant = workspace.AttachTenant

OwnerTenant is the one tenant the owner provider serves.

Variables

This section is empty.

Functions

func SetOwnerEnv added in v0.2.63

func SetOwnerEnv(env []string)

SetOwnerEnv records the environment owner-mode commands start from. `txco attach` calls it with its own environment as it was started, before it clears the chassis's settings from the process.

Types

type Owner added in v0.2.63

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

Owner is the owner provider.

func NewOwner added in v0.2.63

func NewOwner(h home.Home, wrapper []string) (*Owner, error)

NewOwner builds the provider over an attach folder. wrapper is the argv that runs a detached job's wrapper; nil is this binary's own.

func (*Owner) Capabilities added in v0.2.63

func (o *Owner) Capabilities() []string

func (*Owner) Create added in v0.2.63

func (o *Owner) Create(_ context.Context, spec workspace.Spec) (workspace.Handle, error)

Create names an existing credential: nothing is made.

func (*Owner) Destroy added in v0.2.63

func (o *Owner) Destroy(context.Context, workspace.Handle) error

Destroy removes nothing. The folder is its owner's.

func (*Owner) Jobs added in v0.2.63

func (o *Owner) Jobs() *detach.Store

Jobs is the store of this machine's detached jobs.

func (*Owner) Name added in v0.2.63

func (o *Owner) Name() string

func (*Owner) ReachesGrants added in v0.2.63

func (o *Owner) ReachesGrants() bool

ReachesGrants: the commands run on this machine, but the run they belong to is another chassis's. Its grant arrives in the request's environment.

func (*Owner) ServesTenant added in v0.2.63

func (o *Owner) ServesTenant(slug string) bool

ServesTenant implements workspace.TenantGate.

func (*Owner) Sleep added in v0.2.63

func (*Owner) Status added in v0.2.63

func (*Owner) Wake added in v0.2.63

Wake hands back a computer bound to the credential's root. The root is read from the credential's file each time: it is the one place it lives.

type Provider

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

Provider keeps every workspace under root. via, when set, is the command prefix every command is handed to instead of being run here (via.go).

func New

func New(root string) (*Provider, error)

New creates (if needed) and resolves the root directory. Symlinks in the root are resolved once here so the cwd guard compares real paths.

func NewVia added in v0.2.41

func NewVia(root, prefix string) (*Provider, error)

NewVia is New with a command prefix (see EnvExec); "" runs commands here.

func (*Provider) Capabilities

func (p *Provider) Capabilities() []string

func (*Provider) Create

func (p *Provider) Create(_ context.Context, spec workspace.Spec) (workspace.Handle, error)

Create makes the directory (idempotent).

func (*Provider) Destroy

func (p *Provider) Destroy(_ context.Context, h workspace.Handle) error

Destroy removes the directory. Guarded to the root so a forged handle cannot remove anything else.

func (*Provider) Jobs added in v0.2.63

func (p *Provider) Jobs() (*detach.Store, error)

Jobs is the store of this provider's detached jobs, made on first use.

func (*Provider) Name

func (p *Provider) Name() string

func (*Provider) ReachesGrants added in v0.2.31

func (p *Provider) ReachesGrants() bool

ReachesGrants: a local workspace's commands run on this machine, as this user, so they reach the chassis's grant socket and its mounted files — unless a prefix hands them to another machine, which gets the token and the run's name and not the socket.

func (*Provider) Root

func (p *Provider) Root() string

Root is the resolved root directory.

func (*Provider) Sleep

Sleep is a no-op: nothing to park.

func (*Provider) Status

Status is "running" while the directory exists (LastUsed = its mtime), "destroyed" otherwise.

func (*Provider) Wake

Wake checks the directory still exists and hands back a Computer bound to it. Bookkeeping only — a directory is never asleep.

Jump to

Keyboard shortcuts

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