Documentation
¶
Overview ¶
Package system projects CTX machine inventory, shell, and browser observations onto the public generic graph API. It owns the ext.system vocabulary; the base graph package remains product-neutral.
Index ¶
- Constants
- func SafeOrigin(raw string) (scheme, host string, ok bool)
- type AdapterObservation
- type AliasObservation
- type ApplicationInfo
- type CollectionStatus
- type ContextCandidate
- type ContextObservation
- type FilesystemInfo
- type FilesystemRequirement
- type FilesystemSpace
- type Graph
- func (g *Graph) Close() error
- func (g *Graph) ObserveHost(ctx context.Context, inventory HostInventory) error
- func (g *Graph) ObserveInventory(ctx context.Context, adapters []AdapterObservation, aliases []AliasObservation) error
- func (g *Graph) ObserveProcesses(ctx context.Context, observation ProcessSnapshot) error
- func (g *Graph) ObserveShell(ctx context.Context, cwd, profile string, selections map[string]string) error
- func (g *Graph) ObserveWeb(ctx context.Context, provider, profile, scheme, host string) error
- func (g *Graph) PrepareHost(ctx context.Context, requirements OperationRequirements, ...) (PreparedHost, error)
- func (g *Graph) ReadHost(ctx context.Context) (HostSnapshot, error)
- func (g *Graph) ResolveHost(ctx context.Context, requirements OperationRequirements) (HostCandidates, error)
- func (g *Graph) ResolveInventory(ctx context.Context, runtimeName string) (Inventory, error)
- func (g *Graph) ScanHost(ctx context.Context) (HostInventory, error)
- func (g *Graph) ScanProcesses(ctx context.Context, options ProcessOptions) (ProcessSnapshot, error)
- type HostCandidates
- type HostInventory
- type HostRequirementError
- type HostSnapshot
- type Inventory
- type OperationRequirements
- type PreparedHost
- type ProcessInfo
- type ProcessOptions
- type ProcessResource
- type ProcessSnapshot
- type ProcessUsage
- type RelationObservation
- type ResourceObservation
- type ShellInfo
- type ShellRequirement
- type WebviewInfo
- type WebviewRequirement
- type WebviewValidator
Constants ¶
const Namespace = "ext.system"
Variables ¶
This section is empty.
Functions ¶
func SafeOrigin ¶
SafeOrigin parses a navigation URL and returns only scheme and host.
Types ¶
type AdapterObservation ¶
type AdapterObservation struct {
Name, Runtime, Selector string
DiscoveryStatus string
Surfaces, Capabilities, Supports []string
Trusted, ListSupported, ObserveSupported, Listed bool
Contexts []ContextObservation
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 ¶
AliasObservation is a local user declaration that names one adapter context.
type ApplicationInfo ¶
ApplicationInfo identifies an application through OS packaging conventions. It does not assign product capabilities or infer an engine from a name.
type CollectionStatus ¶
type CollectionStatus struct {
State string `json:"state"`
Detail string `json:"detail,omitempty"`
ObservedAt *time.Time `json:"observed_at,omitempty"`
}
CollectionStatus distinguishes an empty observation from inaccessible data. State is complete, partial, permission-denied, unsupported, exited, or unavailable. Detail is a diagnostic, never process arguments or environment contents.
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"`
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"`
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 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"`
}
FilesystemInfo describes a mounted filesystem visible to this process. Space is nil when the OS cannot provide it. This is not a list of unmounted disks or a filesystem-driver catalog. Source never includes URL credentials.
func DiscoverFilesystems ¶
func DiscoverFilesystems(ctx context.Context) ([]FilesystemInfo, error)
DiscoverFilesystems reads the native mount inventory and available space. It observes the caller's mount namespace and permissions, including when CTX itself runs inside a container. It does not traverse filesystem contents.
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"`
}
FilesystemSpace is a point-in-time capacity observation, in bytes. Available space is what the calling user can allocate; it can differ from free space. On Windows, total space is also limited by any quota on the calling user.
type Graph ¶
func New ¶
New registers the CTX system vocabulary on any graph.Store. Other services may keep their own namespaces in the same store.
func (*Graph) ObserveHost ¶
func (g *Graph) ObserveHost(ctx context.Context, inventory HostInventory) error
ObserveHost reconciles host-owned records and their machine relationships. Adapter inventory, shell sessions, and other namespaces are preserved.
func (*Graph) ObserveInventory ¶
func (g *Graph) ObserveInventory(ctx context.Context, adapters []AdapterObservation, aliases []AliasObservation) error
ObserveInventory replaces CTX's adapter inventory projection while leaving shell and web observations intact. It records only ordinary metadata and redacts context names that resemble paths, URLs, or opaque values.
func (*Graph) ObserveProcesses ¶
func (g *Graph) ObserveProcesses(ctx context.Context, observation ProcessSnapshot) error
ObserveProcesses projects generic OS evidence. Complete enumeration removes missing process instances. Partial inventories retain unseen instances. A targeted observation only replaces that PID and its inspected resource kinds. Resource nodes retain their own timestamps across later identity-only scans.
func (*Graph) ObserveShell ¶
func (g *Graph) ObserveShell(ctx context.Context, cwd, profile string, selections map[string]string) error
ObserveShell records the current shell session and its active directory. It never reads arbitrary environment values or shell history.
func (*Graph) ObserveWeb ¶
ObserveWeb records the current web origin after ctx open succeeds. URL paths, queries, fragments, and credentials are intentionally not persisted.
func (*Graph) PrepareHost ¶
func (g *Graph) PrepareHost(ctx context.Context, requirements OperationRequirements, validateWebview WebviewValidator) (PreparedHost, error)
PrepareHost discovers current candidates, selects one for each requirement, and performs live checks. Ambiguous choices require an explicit selection. Webview preparation requires a validator from the consuming backend.
func (*Graph) ReadHost ¶
func (g *Graph) ReadHost(ctx context.Context) (HostSnapshot, error)
ReadHost reads host observations without refreshing or probing the OS.
func (*Graph) ResolveHost ¶
func (g *Graph) ResolveHost(ctx context.Context, requirements OperationRequirements) (HostCandidates, error)
ResolveHost refreshes stale requested categories and returns matching candidates. Webview candidates are installation evidence, not usable backends.
func (*Graph) ResolveInventory ¶
ResolveInventory reads the CTX projection from the public graph. A blank runtime returns every context. Redacted selections remain in the graph for inspection but cannot be used as executable candidates.
func (*Graph) ScanHost ¶
func (g *Graph) ScanHost(ctx context.Context) (HostInventory, error)
ScanHost refreshes all host inventories in the graph and returns the facts.
func (*Graph) ScanProcesses ¶
func (g *Graph) ScanProcesses(ctx context.Context, options ProcessOptions) (ProcessSnapshot, error)
ScanProcesses discovers and reconciles the caller-visible process inventory.
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"`
// contains filtered or unexported fields
}
HostInventory is discovered directly by the graph library, independently of adapters. Nil slices in ObserveHost preserve the corresponding inventory; non-nil empty slices remove previously observed entries of that kind.
func DiscoverHost ¶
func DiscoverHost(ctx context.Context) (HostInventory, error)
DiscoverHost returns local host inventory without opening a graph store.
type HostRequirementError ¶
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"`
// contains filtered or unexported fields
}
HostSnapshot is the typed graph view with separate freshness per category.
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.
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 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"`
// contains filtered or unexported fields
}
ProcessInfo identifies a process instance using PID and an OS start identity. StartID is opaque and platform-specific. Empty StartID means identity could not be established; such entries are returned but never projected as stable nodes.
type ProcessOptions ¶
ProcessOptions bounds returned records and collection time. Zero values select 4096 processes, 1024 resources per category, and a ten-second deadline. Detailed resource inspection is opt-in through InspectProcess.
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"`
}
ProcessResource is OS evidence. A socket does not imply an automation API. Endpoint preserves an OS-rendered address when its roles cannot be established. Descriptors are process-local observations, not reusable handles.
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"`
}
ProcessSnapshot is a non-atomic, point-in-time OS observation. Scope is all or process; only complete all-process enumeration permits removing absent PIDs. HostID includes the boot/namespace identity so records cannot cross reboots.
func DiscoverProcesses ¶
func DiscoverProcesses(ctx context.Context, options ProcessOptions) (ProcessSnapshot, error)
DiscoverProcesses collects identities without scanning every process's files. Processes hidden by the OS are outside this caller-visible inventory.
func InspectProcess ¶
func InspectProcess(ctx context.Context, pid int, options ProcessOptions) (ProcessSnapshot, error)
InspectProcess inspects one process and checks its identity again afterwards. Resources collected during exit or PID reuse are discarded, never reassigned.
type ProcessUsage ¶
type RelationObservation ¶
type RelationObservation struct{ From, To, Kind string }
RelationObservation connects two resources reported by the same adapter.
type ResourceObservation ¶
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"`
}
ShellInfo describes an executable available to this host user. Discovery checks paths and permissions without launching the executable. The configured default is an environment declaration, not proof of the current process.
func DiscoverShells ¶
DiscoverShells finds registered shells, standard shell executable names on PATH, platform shell locations, and a configured SHELL/ComSpec executable. Registered and configured paths can identify shells with arbitrary names.
type ShellRequirement ¶
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"`
}
WebviewInfo describes evidence of a shared web rendering runtime. Discovery does not load the runtime or establish that a particular app can use it. Location is a framework/library path or a Windows registry location. Version is the runtime version; ABIVersion is a library API/ABI generation, not the underlying WebKit or Chromium version.
func DiscoverWebviews ¶
func DiscoverWebviews(ctx context.Context) ([]WebviewInfo, error)
DiscoverWebviews inventories host webview runtimes without launching a browser, reading app profiles, or depending on installed CTX adapters.
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.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
consumer-shaped
command
This consumer-owned example uses consumer-shaped names to demonstrate that CTX accepts arbitrary namespaces and leaves semantic validation to the consumer.
|
This consumer-owned example uses consumer-shaped names to demonstrate that CTX accepts arbitrary namespaces and leaves semantic validation to the consumer. |
|
Package graph provides a generic, namespaced, directed graph store.
|
Package graph provides a generic, namespaced, directed graph store. |
|
service
|
|
|
network/linux/guest
module
|
|
|
Package supervisor runs generic local component processes and projects their observed lifecycle into a graph.
|
Package supervisor runs generic local component processes and projects their observed lifecycle into a graph. |