platform

package
v0.1.1-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const NoKeychainEnv = "DEVSTRAP_NO_KEYCHAIN"

NoKeychainEnv, when set to "1", forces the file-backed key store instead of the OS keychain. This is required for headless/CI runs and hermetic end-to-end tests, where an OS keychain call can block on a GUI unlock prompt.

Variables

View Source
var (
	ErrUnsupported    = errors.New("platform feature unsupported")
	ErrEditorNotFound = errors.New("editor command not found")
	ErrSecretNotFound = errors.New("platform secret not found")
)

Functions

This section is empty.

Types

type EditorAdapter

type EditorAdapter interface {
	Name() string
	Open(ctx context.Context, dir, editor string) error
}

type FSEvent

type FSEvent struct {
	Kind FSEventKind
	Path string
	At   time.Time
}

type FSEventKind

type FSEventKind string
const (
	FSEventUnknown FSEventKind = "unknown"
	FSEventScan    FSEventKind = "scan"
)

type Keychain

type Keychain interface {
	Name() string
	Store(ctx context.Context, service, account string, secret []byte) error
	Load(ctx context.Context, service, account string) ([]byte, error)
	Delete(ctx context.Context, service, account string) error
}

type NativeWatcher

type NativeWatcher struct {
	Debounce   time.Duration
	MaxLatency time.Duration
}

func (NativeWatcher) Name

func (w NativeWatcher) Name() string

func (NativeWatcher) Watch

func (w NativeWatcher) Watch(ctx context.Context, root string, events chan<- FSEvent) error

type PollWatcher

type PollWatcher struct {
	Interval time.Duration
}

func (PollWatcher) Name

func (w PollWatcher) Name() string

func (PollWatcher) Watch

func (w PollWatcher) Watch(ctx context.Context, root string, events chan<- FSEvent) error

type RuntimeInfo

type RuntimeInfo struct {
	OS   string
	Arch string
}

func Runtime

func Runtime() RuntimeInfo

type Sandbox

type Sandbox interface {
	Name() string
	// Available reports whether the sandbox can be used on this host; the
	// returned error explains why not (wrapped in ErrUnsupported).
	Available() error
	// Command returns the argv wrapped in the sandbox launcher plus a cleanup
	// function (always safe to call) that removes any generated profile file.
	Command(ctx context.Context, spec SandboxSpec, argv []string) ([]string, func(), error)
}

Sandbox wraps an agent argv in an OS-enforced confinement (AGEN-03 / P4-GIT-03). Unlike the wrapper-level argv/file policies (which are advisory and interpreter-bypassable), a Sandbox is enforced by the kernel for the child and everything it spawns.

type SandboxSpec

type SandboxSpec struct {
	// WorktreeDir is the agent worktree — the only project location the
	// child may write.
	WorktreeDir string
	// TmpDir is the child's temp directory (writable).
	TmpDir string
	// LogDir is where the generated profile file lives. It is NOT granted to
	// the child: the agent log is written by the parent process, so the child
	// only ever sees inherited pipes — keeping LogDir read-only for the child
	// prevents it from tampering with its own 0600 log or the profile.
	LogDir string
	// UserHome is the REAL user home. The agent child env repoints HOME to
	// the worktree (SECU-02), but the filesystem still contains the user's
	// dotfiles — sensitive-read denies are anchored here.
	UserHome string
	// DevstrapHome is the DevStrap home (~/.devstrap); its keys directory is
	// read-denied.
	DevstrapHome string
	// DenyNetwork blocks all network access for the child.
	DenyNetwork bool
	// DenySensitiveReads blocks reads of credential-bearing paths under
	// UserHome (.ssh, .aws, .gnupg, .config/gh, .kube, .docker) and
	// DevstrapHome/keys.
	DenySensitiveReads bool
}

SandboxSpec describes the confinement an agent child process should run under. Paths must be absolute; implementations resolve symlinks themselves (macOS Seatbelt matches on real paths, and /tmp, TMPDIR, and cloud-drive roots are routinely symlinks).

type ServiceManager

type ServiceManager interface {
	Name() string
	Install(ctx context.Context, spec ServiceSpec) error
	Uninstall(ctx context.Context, label string) error
	Status(ctx context.Context, label string) (ServiceStatus, error)
}

type ServiceSpec

type ServiceSpec struct {
	Label    string
	ExecPath string
	Args     []string
	Env      map[string]string
}

type ServiceStatus

type ServiceStatus struct {
	Installed bool
	Running   bool
	Detail    string
}

type Set

type Set struct {
	OS       string
	Watcher  Watcher
	Service  ServiceManager
	Keychain Keychain
	Editor   EditorAdapter
	Sandbox  Sandbox
}

func Detect

func Detect() Set

type SystemEditor

type SystemEditor struct{}

func (SystemEditor) Name

func (SystemEditor) Name() string

func (SystemEditor) Open

func (SystemEditor) Open(ctx context.Context, dir, editor string) error

type SystemKeychain

type SystemKeychain struct {
	Platform string
	Target   string
}

func (SystemKeychain) Delete

func (k SystemKeychain) Delete(_ context.Context, service, account string) error

func (SystemKeychain) Load

func (k SystemKeychain) Load(_ context.Context, service, account string) ([]byte, error)

func (SystemKeychain) Name

func (k SystemKeychain) Name() string

func (SystemKeychain) Store

func (k SystemKeychain) Store(_ context.Context, service, account string, secret []byte) error

type UnsupportedKeychain

type UnsupportedKeychain struct {
	Platform string
	Target   string
}

func (UnsupportedKeychain) Delete

func (UnsupportedKeychain) Load

func (UnsupportedKeychain) Name

func (k UnsupportedKeychain) Name() string

func (UnsupportedKeychain) Store

type UnsupportedSandbox

type UnsupportedSandbox struct {
	Platform string
}

UnsupportedSandbox is the explicit no-sandbox placeholder for platforms without an implemented adapter (Linux landlock/bubblewrap is a named follow-up slice; see spec/14). Callers treat Available() != nil as "run unconfined and say so".

func (UnsupportedSandbox) Available

func (s UnsupportedSandbox) Available() error

func (UnsupportedSandbox) Command

func (s UnsupportedSandbox) Command(context.Context, SandboxSpec, []string) ([]string, func(), error)

func (UnsupportedSandbox) Name

func (s UnsupportedSandbox) Name() string

type UnsupportedServiceManager

type UnsupportedServiceManager struct {
	Platform string
	Target   string
}

func (UnsupportedServiceManager) Install

func (UnsupportedServiceManager) Name

func (UnsupportedServiceManager) Status

func (UnsupportedServiceManager) Uninstall

type Watcher

type Watcher interface {
	Name() string
	Watch(ctx context.Context, root string, events chan<- FSEvent) error
}

Jump to

Keyboard shortcuts

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