observation

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: MIT Imports: 7 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 observation defines shared ledger observations and host-selection contracts.

Package observation owns the ledger's wire records. These records contain no OS mechanisms.

Index

Constants

View Source
const Namespace = "ext.system"

Variables

This section is empty.

Functions

func SafeOrigin

func SafeOrigin(raw string) (scheme, host string, ok bool)

SafeOrigin parses a navigation URL and returns only scheme and

Types

type AccessibilityElement

type AccessibilityElement struct {
	ID             string         `json:"id"`
	ParentID       string         `json:"parent_id,omitempty"`
	PID            int            `json:"pid"`
	ProcessStartID string         `json:"process_start_id"`
	Role           string         `json:"role"`
	Identifier     string         `json:"identifier,omitempty"`
	Label          string         `json:"label,omitempty"`
	Value          string         `json:"value,omitempty"`
	Bounds         *SurfaceBounds `json:"bounds,omitempty"`
	Actions        []string       `json:"actions,omitempty"`
	Enabled        *bool          `json:"enabled,omitempty"`
	Focused        *bool          `json:"focused,omitempty"`
}

type AccessibilitySnapshot

type AccessibilitySnapshot struct {
	Platform   string                 `json:"platform"`
	ObservedAt time.Time              `json:"observed_at"`
	Status     CollectionStatus       `json:"status"`
	Elements   []AccessibilityElement `json:"elements"`
}

type AdapterObservation

type AdapterObservation struct {
	Name, Runtime, Selector                          string
	DiscoveryStatus                                  string
	Surfaces, Capabilities, Supports                 []string
	Engine, Role                                     []string
	BrowserShare                                     []string
	Trusted, ListSupported, ObserveSupported, Listed bool
	Contexts                                         []ContextObservation
	// Programs are the executables the consumer found for the commands this adapter
	// declares. They are machine facts: the graph holds one vertex per file, however
	// many adapters were given it.
	Programs  []ProgramCandidate
	Resources []ResourceObservation
	Relations []RelationObservation
}

AdapterObservation describes an installed adapter and any contexts it listed. Listed means its discovery operation completed; it does not prove each configured remote endpoint is running or authorize its use.

type AliasObservation

type AliasObservation struct {
	Space, Name, Adapter, Selection string
	Metadata                        map[string]string
}

AliasObservation is a local user declaration that names one adapter context.

type ApplicationInfo

type ApplicationInfo struct {
	Name string `json:"name"`
	Path string `json:"path"`
}

type CollectionStatus

type CollectionStatus struct {
	State      string     `json:"state"`
	Reason     string     `json:"reason,omitempty"`
	Detail     string     `json:"detail,omitempty"`
	ObservedAt *time.Time `json:"observed_at,omitempty"`
}

type ContainerInfo

type ContainerInfo struct {
	Detected bool     `json:"detected"`
	State    string   `json:"state"`
	Evidence []string `json:"evidence"`
}

type ContextCandidate

type ContextCandidate struct {
	Adapter           string            `json:"adapter"`
	Runtime           string            `json:"runtime"`
	Selection         string            `json:"selection"`
	SelectionDigest   string            `json:"selection_digest"`
	SelectionRedacted bool              `json:"selection_redacted,omitempty"`
	Capabilities      []string          `json:"capabilities"`
	Supports          []string          `json:"supports,omitempty"`
	Engine            []string          `json:"engine,omitempty"`
	Role              []string          `json:"role,omitempty"`
	BrowserShare      map[string]string `json:"browser_share,omitempty"`
	Program           *ContextProgram   `json:"program,omitempty"`
	// Default marks the adapter the user prefers for the kind a resolve asked for.
	// It filters nothing; a caller that wants one adapter asks for a pick.
	Default    bool      `json:"default,omitempty"`
	ObservedAt time.Time `json:"observed_at"`
}

ContextCandidate is a graph observation, not authorization to run an adapter. Callers must still check trust and validate the native selection.

type ContextObservation

type ContextObservation struct {
	Selection    string            `json:"selection"`
	Capabilities []string          `json:"capabilities,omitempty"`
	Supports     []string          `json:"supports,omitempty"`
	BrowserShare map[string]string `json:"browser_share,omitempty"`
	Attributes   map[string]any    `json:"attributes,omitempty"`
}

ContextObservation is a native adapter selection with optional narrower capabilities and resource support, plus ordinary non-secret metadata.

type ContextProgram

type ContextProgram struct {
	Path       string   `json:"path"`
	RealPath   string   `json:"realpath"`
	Version    string   `json:"version,omitempty"`
	OnPath     bool     `json:"on_path,omitempty"`
	Installers []string `json:"installers,omitempty"`
	// Suggested names installers the adapter that runs the file guessed from its
	// location. It is not a fact; see "installers".
	Suggested []string `json:"suggested_installers,omitempty"`
}

ContextProgram is the executable a context runs, as observed. Installers names the installer adapters that reported the file; it is empty when the file was found on PATH alone. The file may have been replaced since the scan.

type DesktopEndpoint

type DesktopEndpoint struct {
	Available bool   `json:"available"`
	Reason    string `json:"reason,omitempty"`
}

type DesktopInfo

type DesktopInfo struct {
	Platform      string          `json:"platform"`
	Interactive   bool            `json:"interactive"`
	Containerized bool            `json:"containerized"`
	Capabilities  []string        `json:"capabilities,omitempty"`
	X11           DesktopEndpoint `json:"x11"`
	Wayland       DesktopEndpoint `json:"wayland"`
	Recording     RecordingInfo   `json:"recording"`
	Reason        string          `json:"reason,omitempty"`
	ObservedAt    time.Time       `json:"observed_at"`
}

type DisplayInfo

type DisplayInfo struct {
	ID      string        `json:"id"`
	Bounds  SurfaceBounds `json:"bounds"`
	Scale   float64       `json:"scale,omitempty"`
	Primary bool          `json:"primary"`
}

type FilesystemInfo

type FilesystemInfo struct {
	MountPoint  string           `json:"mount_point"`
	Source      string           `json:"source"`
	Type        string           `json:"type"`
	ReadOnly    bool             `json:"read_only"`
	Space       *FilesystemSpace `json:"space,omitempty"`
	Label       string           `json:"label,omitempty"`
	DriveKind   string           `json:"drive_kind,omitempty"`
	DetailError string           `json:"detail_error,omitempty"`
}

type FilesystemRequirement

type FilesystemRequirement struct {
	Select                string   `json:"select,omitempty"` // Mount point.
	Path                  string   `json:"path,omitempty"`   // Existing file/directory or a future output path.
	Types                 []string `json:"types,omitempty"`
	Writable              bool     `json:"writable,omitempty"`
	MinimumAvailableBytes uint64   `json:"minimum_available_bytes,omitempty"`
}

type FilesystemSpace

type FilesystemSpace struct {
	TotalBytes     uint64 `json:"total_bytes"`
	FreeBytes      uint64 `json:"free_bytes"`
	AvailableBytes uint64 `json:"available_bytes"`
}

type HostCandidates

type HostCandidates struct {
	Operation   string               `json:"operation"`
	Shells      []ShellInfo          `json:"shells,omitempty"`
	Filesystems []FilesystemInfo     `json:"filesystems,omitempty"`
	Webviews    []WebviewInfo        `json:"webviews,omitempty"`
	ObservedAt  map[string]time.Time `json:"observed_at"`
}

type HostInventory

type HostInventory struct {
	Shells          []ShellInfo            `json:"shells"`
	Filesystems     []FilesystemInfo       `json:"filesystems"`
	Webviews        []WebviewInfo          `json:"webviews"`
	Desktop         *DesktopInfo           `json:"desktop,omitempty"`
	Surfaces        *SurfaceSnapshot       `json:"surfaces,omitempty"`
	Accessibility   *AccessibilitySnapshot `json:"accessibility,omitempty"`
	Permissions     *PermissionSnapshot    `json:"permissions,omitempty"`
	Resources       *ResourceInfo          `json:"resources,omitempty"`
	ShellSearchPath *string                `json:"-"`
}

HostInventory is discovered directly by the graph library, independently of adapters. Nil slices and pointers in ObserveHost preserve the corresponding inventory; non-nil empty slices remove previously observed entries of that kind.

type HostRequirementError

type HostRequirementError struct {
	Operation string
	Kind      string
	Reason    string
	Cause     error
}

HostRequirementError identifies a failed operation requirement. Cause, when present, preserves OS, context, and backend errors for errors.Is/errors.As.

func (*HostRequirementError) Error

func (err *HostRequirementError) Error() string

func (*HostRequirementError) Unwrap

func (err *HostRequirementError) Unwrap() error

type HostSnapshot

type HostSnapshot struct {
	HostInventory
	ObservedAt  map[string]time.Time `json:"observed_at"`
	Environment map[string]string    `json:"-"`
}

HostSnapshot is the typed graph view with separate freshness per category.

type InstallerObservation

type InstallerObservation struct {
	Name, Source string
}

InstallerObservation declares an installer that is not an adapter, such as one the user described in their own configuration. Installers that are adapters (role "installer") need no entry here.

type Inventory

type Inventory struct {
	ObservedAt time.Time          `json:"observed_at"`
	Contexts   []ContextCandidate `json:"contexts"`
}

Inventory is the latest reconciled adapter view. ObservedAt is refreshed on every scan, even when the set of contexts is unchanged.

func (Inventory) Find

func (inventory Inventory) Find(adapter, selection string, capabilities ...string) (ContextCandidate, error)

Find returns a currently observed context with the requested capabilities.

func (Inventory) FreshWithin

func (inventory Inventory) FreshWithin(maxAge time.Duration) bool

type OperationRequirements

type OperationRequirements struct {
	Operation  string                 `json:"operation"`
	Shell      *ShellRequirement      `json:"shell,omitempty"`
	Filesystem *FilesystemRequirement `json:"filesystem,omitempty"`
	Webview    *WebviewRequirement    `json:"webview,omitempty"`
	MaxAge     time.Duration          `json:"-"`
}

OperationRequirements describes host resources needed by a caller. Non-nil requirements are conjunctive. Select pins a resource: failure never causes a different resource to be substituted. MaxAge defaults to five seconds; a negative value forces discovery. No adapter or backend is chosen by name.

type PermissionInfo

type PermissionInfo struct {
	State  string `json:"state"`
	Reason string `json:"reason,omitempty"`
	Scope  string `json:"scope,omitempty"`
	Detail string `json:"detail,omitempty"`
}

type PermissionSnapshot

type PermissionSnapshot struct {
	Platform        string         `json:"platform"`
	ObservedAt      time.Time      `json:"observed_at"`
	Accessibility   PermissionInfo `json:"accessibility"`
	ScreenRecording PermissionInfo `json:"screen_recording"`
}

type PowerInfo

type PowerInfo struct {
	State                string `json:"state"`
	Percentage           int    `json:"percentage"`
	TimeRemainingSeconds int64  `json:"time_remaining_seconds,omitempty"`
}

type PreparedHost

type PreparedHost struct {
	Operation   string          `json:"operation"`
	Shell       *ShellInfo      `json:"shell,omitempty"`
	Filesystem  *FilesystemInfo `json:"filesystem,omitempty"`
	Webview     *WebviewInfo    `json:"webview,omitempty"`
	ValidatedAt time.Time       `json:"validated_at"`
}

PreparedHost contains one validated resource per requirement. This does not authorize execution, reserve capacity, or eliminate races with OS changes.

type ProcessInfo

type ProcessInfo struct {
	PID         int                         `json:"pid"`
	ParentPID   int                         `json:"parent_pid"`
	Name        string                      `json:"name"`
	StartID     string                      `json:"start_id,omitempty"`
	Executable  string                      `json:"executable,omitempty"`
	Owner       string                      `json:"owner,omitempty"`
	Application *ApplicationInfo            `json:"application,omitempty"`
	Usage       *ProcessUsage               `json:"usage,omitempty"`
	Coverage    map[string]CollectionStatus `json:"coverage"`
	Resources   []ProcessResource           `json:"resources,omitempty"`
}

type ProcessOptions

type ProcessOptions struct {
	MaxProcesses int
	MaxResources int
	Timeout      time.Duration
}

type ProcessResource

type ProcessResource struct {
	Kind          string `json:"kind"`
	Path          string `json:"path,omitempty"`
	Descriptor    string `json:"descriptor,omitempty"`
	Protocol      string `json:"protocol,omitempty"`
	LocalAddress  string `json:"local_address,omitempty"`
	RemoteAddress string `json:"remote_address,omitempty"`
	Endpoint      string `json:"endpoint,omitempty"`
	State         string `json:"state,omitempty"`
}

type ProcessSnapshot

type ProcessSnapshot struct {
	HostID      string           `json:"host_id"`
	Scope       string           `json:"scope"`
	ObservedAt  time.Time        `json:"observed_at"`
	Enumeration CollectionStatus `json:"enumeration"`
	Processes   []ProcessInfo    `json:"processes"`
}

type ProcessUsage

type ProcessUsage struct {
	ResidentBytes *uint64  `json:"resident_bytes,omitempty"`
	VirtualBytes  *uint64  `json:"virtual_bytes,omitempty"`
	CPUSeconds    *float64 `json:"cpu_seconds,omitempty"`
	Threads       *uint32  `json:"threads,omitempty"`
}

type ProgramCandidate

type ProgramCandidate struct {
	Name       string         `json:"name"`
	Path       string         `json:"path"`
	RealPath   string         `json:"realpath"`
	Version    string         `json:"version,omitempty"`
	Source     string         `json:"source"`
	OnPath     bool           `json:"on_path,omitempty"`
	Installers []string       `json:"installers,omitempty"`
	Attributes map[string]any `json:"attributes,omitempty"`
}

type RecordingInfo

type RecordingInfo struct {
	Status           string    `json:"status"`
	EncoderAvailable bool      `json:"encoder_available"`
	CaptureAvailable bool      `json:"capture_available"`
	Permission       string    `json:"permission"`
	Formats          []string  `json:"formats,omitempty"`
	Message          string    `json:"message,omitempty"`
	CheckedAt        time.Time `json:"checked_at"`
}

type RelationObservation

type RelationObservation struct{ From, To, Kind string }

RelationObservation connects two resources reported by the same adapter.

type ResourceInfo

type ResourceInfo struct {
	OS                  string           `json:"os"`
	Architecture        string           `json:"architecture"`
	ObservedAt          time.Time        `json:"observed_at"`
	LogicalCPUs         int              `json:"logical_cpus"`
	CPUCapacity         float64          `json:"cpu_capacity"`
	CPUStatus           CollectionStatus `json:"cpu_status"`
	MemoryBytes         uint64           `json:"memory_bytes"`
	MemoryCapacityBytes uint64           `json:"memory_capacity_bytes"`
	MemoryStatus        CollectionStatus `json:"memory_status"`
	Storage             []StorageInfo    `json:"storage,omitempty"`
	Power               *PowerInfo       `json:"power,omitempty"`
	Container           ContainerInfo    `json:"container"`
	UptimeSeconds       *float64         `json:"uptime_seconds,omitempty"`
	BootTime            *time.Time       `json:"boot_time,omitempty"`
	UptimeStatus        CollectionStatus `json:"uptime_status"`
}

type ResourceObservation

type ResourceObservation struct {
	ID, Kind, Context string
	Attributes        map[string]any
}

ResourceObservation identifies a resource in one observed context. ID is adapter-local; the graph stores a digest rather than the raw identifier.

type ShellInfo

type ShellInfo struct {
	Name              string   `json:"name"`
	Path              string   `json:"path"`
	ResolvedPath      string   `json:"resolved_path"`
	ConfiguredDefault bool     `json:"configured_default"`
	Sources           []string `json:"sources"`
}

type ShellRequirement

type ShellRequirement struct {
	Name       string  `json:"name,omitempty"`
	Select     string  `json:"select,omitempty"` // Executable name or path.
	SearchPath *string `json:"-"`                // Optional effective PATH, without changing the process environment.
}

type StorageInfo

type StorageInfo struct {
	Device         string `json:"device"`
	MountPoint     string `json:"mount_point"`
	TotalBytes     uint64 `json:"total_bytes"`
	AvailableBytes uint64 `json:"available_bytes"`
	Type           string `json:"type,omitempty"`
	ReadOnly       bool   `json:"read_only,omitempty"`
}

type SurfaceBounds

type SurfaceBounds struct {
	X      int `json:"x"`
	Y      int `json:"y"`
	Width  int `json:"width"`
	Height int `json:"height"`
}

type SurfaceSnapshot

type SurfaceSnapshot struct {
	Platform        string           `json:"platform"`
	CoordinateSpace string           `json:"coordinate_space"`
	ObservedAt      time.Time        `json:"observed_at"`
	Displays        []DisplayInfo    `json:"displays"`
	Windows         []WindowInfo     `json:"windows"`
	DisplayStatus   CollectionStatus `json:"display_status"`
	WindowStatus    CollectionStatus `json:"window_status"`
}

type WebviewInfo

type WebviewInfo struct {
	Name         string `json:"name"`
	Engine       string `json:"engine"`
	API          string `json:"api"`
	Version      string `json:"version,omitempty"`
	ABIVersion   string `json:"abi_version,omitempty"`
	Architecture string `json:"architecture,omitempty"`
	Location     string `json:"location"`
	ResolvedPath string `json:"resolved_path,omitempty"`
	Scope        string `json:"scope"`
	Source       string `json:"source"`
	DetailError  string `json:"detail_error,omitempty"`
}

type WebviewRequirement

type WebviewRequirement struct {
	Select       string `json:"select,omitempty"` // Discovery location.
	Engine       string `json:"engine,omitempty"`
	API          string `json:"api,omitempty"`
	ABIVersion   string `json:"abi_version,omitempty"`
	Version      string `json:"version,omitempty"` // Exact runtime version, when known.
	Architecture string `json:"architecture,omitempty"`
}

type WebviewValidator

type WebviewValidator func(context.Context, WebviewInfo) error

WebviewValidator belongs to the embedding backend. It must establish that this backend can use the selected runtime, including its ABI and dependencies.

type WindowInfo

type WindowInfo struct {
	ID             string        `json:"id"`
	PID            int           `json:"pid"`
	ProcessStartID string        `json:"process_start_id"`
	Bounds         SurfaceBounds `json:"bounds"`
	OnScreen       bool          `json:"on_screen"`
}

Jump to

Keyboard shortcuts

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