adapter

package
v0.63.2 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTargetNotFound = errors.New("adapter target not found")
	// ErrTargetDegraded means an adapter could not safely establish physical
	// ownership. Supervisors must retry without mutating durable registry
	// bookkeeping because the uncertainty may be transient.
	ErrTargetDegraded = errors.New("adapter target ownership degraded")
)

Functions

func CmuxDegradedOwnershipKey added in v0.59.1

func CmuxDegradedOwnershipKey(inventory TargetInventory, err error) (string, bool)

CmuxDegradedOwnershipKey returns a physical key only when the error came from the same concrete cmux inventory type used for the candidate lookup. This prevents generic or third-party TargetInventory implementations from turning ErrTargetDegraded into permission to skip an uncertain owner.

Types

type Adapter

type Adapter interface {
	Name() string
	Probe(ctx context.Context, target string) error
	Inject(ctx context.Context, target string, payload string) error
}

type Cmux

type Cmux struct {
	Runner       CommandRunner
	Path         string
	Getenv       func(string) string
	LookPath     func(string) (string, error)
	UserHomeDir  func() (string, error)
	IsExecutable func(string) bool
	Sleep        func(context.Context, time.Duration) error
	SettleDelay  time.Duration
	// LiveTTYOwnerCount reports how many live (non-zombie) processes hold the
	// device at devPath as their controlling terminal. Defaults to the darwin
	// sysctl implementation; tests inject a fake so they never run a real
	// sysctl against fixture tty names.
	LiveTTYOwnerCount func(devPath string) (int, error)
	// Logf receives non-fatal diagnostics (evictions, degraded fail-closed
	// ttys). Nil is a no-op.
	Logf func(format string, args ...any)
	// contains filtered or unexported fields
}

func (Cmux) Discover

func (c Cmux) Discover(_ context.Context) (string, error)

func (Cmux) Inject

func (c Cmux) Inject(ctx context.Context, target string, payload string) error

func (Cmux) Inventory

func (c Cmux) Inventory(ctx context.Context, _ OwnershipContext) (TargetInventory, error)

func (Cmux) Name

func (Cmux) Name() string

func (Cmux) NormalizeTarget

func (Cmux) NormalizeTarget(target string) (string, error)

func (Cmux) Probe

func (c Cmux) Probe(ctx context.Context, target string) error

type CommandRunner

type CommandRunner interface {
	Run(ctx context.Context, name string, args ...string) ([]byte, error)
}

type Discoverer

type Discoverer interface {
	Discover(ctx context.Context) (string, error)
}

type ExecRunner

type ExecRunner struct{}

func (ExecRunner) Run

func (ExecRunner) Run(ctx context.Context, name string, args ...string) ([]byte, error)

type File

type File struct{}

func (File) Inject

func (File) Inject(ctx context.Context, target string, payload string) error

func (File) Name

func (File) Name() string

func (File) NormalizeTarget

func (File) NormalizeTarget(target string) (string, error)

NormalizeTarget resolves a file target to its stable absolute pathname. Registration persists this value, so a later launchd invocation cannot reinterpret a relative target from a different working directory. Resolving existing symlinks also keeps lexical and symlink aliases from claiming the same destination independently.

func (File) Probe

func (File) Probe(ctx context.Context, target string) error

type Ghostty

type Ghostty struct {
	Runner CommandRunner
}

func (Ghostty) Discover

func (g Ghostty) Discover(ctx context.Context) (string, error)

func (Ghostty) Inject

func (g Ghostty) Inject(ctx context.Context, target string, payload string) error

func (Ghostty) Name

func (Ghostty) Name() string

func (Ghostty) NormalizeTarget

func (Ghostty) NormalizeTarget(target string) (string, error)

func (Ghostty) Probe

func (g Ghostty) Probe(ctx context.Context, target string) error

type InventoryProvider

type InventoryProvider interface {
	Inventory(ctx context.Context, own OwnershipContext) (TargetInventory, error)
}

InventoryProvider lets the supervisor inventory an adapter once per pass instead of spawning one probe process for every registry entry. The OwnershipContext lets the registration preflight pass a trusted-live candidate; other callers pass the zero value.

type OwnershipContext

type OwnershipContext struct {
	// TrustedTarget is the adapter-native target string (e.g. a cmux surface
	// target) the caller has proven live. Empty means no trusted candidate.
	TrustedTarget string
}

OwnershipContext carries optional trust the caller has already established about a candidate target. Only the registration preflight may populate it: the target it is registering was discovered from the live local surface, so it is live by construction and can break an otherwise-ambiguous physical ownership tie. Supervisor and inject passes pass the zero value, which trusts nothing.

type Registry

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

func DefaultRegistry

func DefaultRegistry() Registry

func DefaultRegistryWithLogf

func DefaultRegistryWithLogf(logf func(format string, args ...any)) Registry

DefaultRegistryWithLogf returns the production adapter set with non-fatal adapter diagnostics wired to logf. Callers that do not own a diagnostic stream can continue using DefaultRegistry.

func NewRegistry

func NewRegistry(adapters ...Adapter) Registry

func (Registry) Get

func (r Registry) Get(name string) (Adapter, error)

type TargetInventory

type TargetInventory interface {
	Probe(target string) error
	OwnershipKey(target string) (string, error)
}

TargetInventory is a point-in-time existence snapshot. Implementations must return ErrTargetNotFound only when absence is proven by the snapshot; parse, transport, and permission failures remain ambiguous errors. When ownership is degraded, callers remain fail-closed unless a concrete adapter-specific capability proves that the same immutable inventory also established a different physical identity. The generic interface deliberately exposes no constructor for such a capability.

type TargetNormalizer

type TargetNormalizer interface {
	NormalizeTarget(target string) (string, error)
}

Jump to

Keyboard shortcuts

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