Documentation
¶
Overview ¶
Package observability 实现 XOps v2 实时可观测性投影、远端指标/日志流与 POSIX 强校验 GUI 自动化/会话用例服务 (ADR-007 / ADR-008 / ADR-009 / ADR-010 / Plan P3-T4)。
核心交付范围与安全不变量:
- TUI 指标 / 日志流聚合投影(Projection):受 core/conc.Nursery 监督消费 events.SystemBus 与多条隔离 OperationStream(0 裸 go、0 time.Sleep),穷尽覆盖全部 12 类封闭 Event 变体,提供有界无锁竞态快照、 单调锁存 GateHalted/OutcomeUnknown 标志、DropAndCount 丢弃计数与事件驱动 WaitUpdate;
- 远端指标与日志流(StreamMetrics / StreamLogs):强制 POSIX Bourne 启动方言(INV-E4),日志文件路径在非 DirectOperator 配置档下经 Round-2 规范化防软链逃逸,Docker 容器名严格白名单正则防注入;
- POSIX 强校验 GUI 自动化与受管隧道会话(ExecuteGUI / OpenGUISession / InspectGUISession / CloseGUISession): 严格校验 X11/Wayland Display、键位和弦、归一化坐标与端口范围;纯 Go 零 CGO 截图防解压炸弹与等比压缩; 全程 0 OperatorReadFS 依赖(仅经可选 ScopedRootFS 落盘产物),供 P3-T5 MCP gui 工具直接安全复用。
Index ¶
- Constants
- Variables
- func BuildGUIScript(spec GUIActionSpec) (string, error)
- func ValidateGUIAction(spec GUIActionSpec) error
- func ValidateGUIKeySpec(raw string) error
- func ValidateWaylandDisplay(raw string) error
- func ValidateX11Display(raw string) error
- type DiagnosticRecord
- type DiskMetric
- type GUIActionKind
- type GUIActionSpec
- type GUIArtifactDest
- type GUIExecRequest
- type GUIExecResult
- func (r GUIExecResult) Action() GUIActionKind
- func (r GUIExecResult) Artifact() algebraic.Option[pathalg.LocalRootedDest]
- func (r GUIExecResult) Duration() algebraic.Duration
- func (r GUIExecResult) IsValid() bool
- func (r GUIExecResult) IsZero() bool
- func (r GUIExecResult) Outcome() execution.ExecutionOutcome
- func (r GUIExecResult) Screenshot() algebraic.Option[ProcessedScreenshot]
- func (r GUIExecResult) Stderr() string
- func (r GUIExecResult) Stdout() string
- type GUISessionInfo
- func (i GUISessionInfo) BoundAddr() string
- func (i GUISessionInfo) DisplayNum() int
- func (i GUISessionInfo) Handle() plan.ManagedHandle[plan.KindTunnel]
- func (i GUISessionInfo) IsValid() bool
- func (i GUISessionInfo) IsZero() bool
- func (i GUISessionInfo) Kind() GUISessionKind
- func (i GUISessionInfo) RemoteTarget() string
- type GUISessionKind
- type GUISessionSpec
- type GUISessionStatus
- func (s GUISessionStatus) Active() bool
- func (s GUISessionStatus) BoundAddr() string
- func (s GUISessionStatus) DisplayNum() int
- func (s GUISessionStatus) Err() error
- func (s GUISessionStatus) HandleStatus() pool.HandleStatus
- func (s GUISessionStatus) IsValid() bool
- func (s GUISessionStatus) IsZero() bool
- func (s GUISessionStatus) Kind() GUISessionKind
- func (s GUISessionStatus) RemoteTarget() string
- type HostMetricsFrame
- type LogEntry
- type LogStreamRequest
- type LogStreamResult
- type LogTarget
- type LogTargetKind
- type MetricPoint
- type MetricsStreamRequest
- type MetricsStreamResult
- type OpenGUISessionRequest
- type OperationView
- type PoolRecord
- type ProcessMetric
- type ProcessSortBy
- type ProcessedScreenshot
- type Projection
- func (p *Projection) ApplyEvent(ev events.Event) error
- func (p *Projection) AttachOperationStream(stream *events.OperationStream) error
- func (p *Projection) Close() error
- func (p *Projection) Snapshot() ProjectionSnapshot
- func (p *Projection) WaitUpdate(ctx context.Context, sinceVersion uint64) (ProjectionSnapshot, error)
- type ProjectionConfig
- type ProjectionSnapshot
- func (s ProjectionSnapshot) ActiveStreams() int
- func (s ProjectionSnapshot) CanonicalJSON() ([]byte, error)
- func (s ProjectionSnapshot) Diagnostics() []DiagnosticRecord
- func (s ProjectionSnapshot) DroppedEvents() uint64
- func (s ProjectionSnapshot) GateHalted() bool
- func (s ProjectionSnapshot) HasUnknownOutcome() bool
- func (s ProjectionSnapshot) IsValid() bool
- func (s ProjectionSnapshot) IsZero() bool
- func (s ProjectionSnapshot) Logs() []LogEntry
- func (s ProjectionSnapshot) MarshalJSONTo(enc *jsontext.Encoder) error
- func (s ProjectionSnapshot) Metrics() []MetricPoint
- func (s ProjectionSnapshot) Operations() []OperationView
- func (s ProjectionSnapshot) PoolEvents() []PoolRecord
- func (s ProjectionSnapshot) TotalEvents() uint64
- func (s ProjectionSnapshot) Version() uint64
- type ScrollDirection
- type Service
- func (s *Service) CloseGUISession(ctx context.Context, handle plan.ManagedHandle[plan.KindTunnel]) error
- func (s *Service) ExecuteGUI(ctx context.Context, req GUIExecRequest) (GUIExecResult, error)
- func (s *Service) InspectGUISession(ctx context.Context, handle plan.ManagedHandle[plan.KindTunnel]) (GUISessionStatus, error)
- func (s *Service) OpenGUISession(ctx context.Context, req OpenGUISessionRequest) (GUISessionInfo, error)
- func (s *Service) StreamLogs(ctx context.Context, req LogStreamRequest) (LogStreamResult, error)
- func (s *Service) StreamMetrics(ctx context.Context, req MetricsStreamRequest) (MetricsStreamResult, error)
- type ServiceConfig
Constants ¶
const ( LogTargetInvalid LogTargetKind = iota LogTargetFile LogTargetDocker ProcessSortInvalid ProcessSortBy = 0 ProcessSortCPU ProcessSortBy = 1 ProcessSortMem ProcessSortBy = 2 GUIActionInvalid GUIActionKind = 0 GUIActionScreenshot GUIActionKind = 1 GUIActionClick GUIActionKind = 2 GUIActionDoubleClick GUIActionKind = 3 GUIActionRightClick GUIActionKind = 4 GUIActionMove GUIActionKind = 5 GUIActionDrag GUIActionKind = 6 GUIActionScroll GUIActionKind = 7 GUIActionType GUIActionKind = 8 GUIActionKey GUIActionKind = 9 ScrollDirectionInvalid ScrollDirection = 0 ScrollUp ScrollDirection = 1 ScrollDown ScrollDirection = 2 ScrollLeft ScrollDirection = 3 ScrollRight ScrollDirection = 4 GUISessionInvalid GUISessionKind = 0 GUISessionX11 GUISessionKind = 1 GUISessionVNC GUISessionKind = 2 )
Variables ¶
var ( ErrNilContext = errors.New("usecase/observability: context 不能为 nil") ErrInvalidConfig = errors.New("usecase/observability: 无效的 ServiceConfig 或 ProjectionConfig 配置") ErrServiceNotInitialized = errors.New("usecase/observability: Service 未初始化") ErrInvalidRequest = errors.New("usecase/observability: 无效的可观测性或 GUI 请求") ErrPOSIXShellRequired = errors.New("usecase/observability: 目标节点必须使用 POSIX Bourne 兼容 Shell(sh/bash/zsh)") ErrInvalidLogTarget = errors.New("usecase/observability: 无效的远端日志目标或非法容器名称") ErrInvalidGUIInput = errors.New("usecase/observability: 无效或包含注入风险的 GUI 输入参数") ErrScreenshotInvalid = errors.New("usecase/observability: 远端截图载荷缺失、格式不受支持或触发解压炸弹防护") ErrProjectionClosed = errors.New("usecase/observability: Projection 未初始化或已关闭") ErrUncertainOutcome = errors.New("usecase/observability: 远端操作结果未知(OutcomeUnknown),严禁重试") ErrSymlinkPolicyDenied = errors.New("usecase/observability: 远端软链展开超限或被策略拒绝") )
本包导出的不可变哨兵错误,供 core/engine、entry/tui、mcpruntime 与测试经 errors.Is 精确区分故障类别。
Functions ¶
func BuildGUIScript ¶
func BuildGUIScript(spec GUIActionSpec) (string, error)
BuildGUIScript 为校验通过的 GUIActionSpec 生成硬化 POSIX Bourne 脚本: mktemp -d 0700 + trap、分辨率感知归一化坐标换算 [0,1000]->像素、Wayland(ydotool)/X11(xdotool) 双分支与全量 QuotePOSIX。
func ValidateGUIAction ¶
func ValidateGUIAction(spec GUIActionSpec) error
ValidateGUIAction 对 GUIActionSpec 执行全量失败关闭校验(归一化坐标 [0,1000]、Display、键位、滚轮与文本边界)。
func ValidateGUIKeySpec ¶
ValidateGUIKeySpec 严格校验按键或组合和弦名称(如 "Return"、"ctrl+c"),拒绝前导 "-"、空白与 Shell 元字符。
func ValidateWaylandDisplay ¶
ValidateWaylandDisplay 严格校验 WAYLAND_DISPLAY 格式(仅允许 "wayland-N")。
func ValidateX11Display ¶
ValidateX11Display 严格校验 X11 DISPLAY 格式(仅允许 ":N" 或 ":N.S"),阻断环境变量与命令注入。
Types ¶
type DiagnosticRecord ¶
type DiagnosticRecord struct {
Scope events.DiagnosticScope `json:"scope"`
Severity events.Severity `json:"severity"`
Code string `json:"code"`
Message string `json:"message"`
Attrs map[string]string `json:"attrs,omitzero"`
OccurredAt time.Time `json:"occurred_at"`
}
ProjectionConfig 与不可变投影视图 DTO(零裸 time.Duration,供 Phase 5 entry/tui 直接消费)。
type DiskMetric ¶
type DiskMetric struct {
Mount string `json:"mount"`
UsedBytes uint64 `json:"used_bytes"`
TotalBytes uint64 `json:"total_bytes"`
UsedPercent float64 `json:"used_percent"`
}
DiskMetric、ProcessMetric、HostMetricsFrame、MetricsStreamRequest 与 MetricsStreamResult(零裸 time.Duration)。
type GUIActionKind ¶
type GUIActionKind uint8
func ParseGUIActionKind ¶
func ParseGUIActionKind(raw string) (GUIActionKind, error)
func (GUIActionKind) AppendText ¶
func (k GUIActionKind) AppendText(b []byte) ([]byte, error)
func (GUIActionKind) IsValid ¶
func (k GUIActionKind) IsValid() bool
func (GUIActionKind) IsZero ¶
func (k GUIActionKind) IsZero() bool
func (GUIActionKind) MarshalText ¶
func (k GUIActionKind) MarshalText() ([]byte, error)
func (GUIActionKind) String ¶
func (k GUIActionKind) String() string
func (*GUIActionKind) UnmarshalText ¶
func (k *GUIActionKind) UnmarshalText(t []byte) error
type GUIActionSpec ¶
type GUIActionSpec struct {
Action GUIActionKind
Display, WaylandDisplay string
X, Y, StartX, StartY int
EndX, EndY, Clicks int
Direction ScrollDirection
Text, Key string
IncludeShot bool
}
GUIActionSpec、GUIArtifactDest、GUIExecRequest、ProcessedScreenshot、GUIExecResult 与 GUI 会话类型。
type GUIArtifactDest ¶
type GUIArtifactDest struct {
RootDir pathalg.LocalDir
File pathalg.LocalRootedDest
}
GUIActionSpec、GUIArtifactDest、GUIExecRequest、ProcessedScreenshot、GUIExecResult 与 GUI 会话类型。
type GUIExecRequest ¶
type GUIExecRequest struct {
Plan plan.SealedConnectionPlan
NodeID string
Profile algebraic.Option[execution.LaunchProfile]
Spec GUIActionSpec
Artifact algebraic.Option[GUIArtifactDest]
Timeout algebraic.Option[algebraic.Duration]
Risk algebraic.Option[security.RiskLevel]
Approval algebraic.Option[gate.ApprovalSubmission]
OperationStream *events.OperationStream
}
GUIActionSpec、GUIArtifactDest、GUIExecRequest、ProcessedScreenshot、GUIExecResult 与 GUI 会话类型。
type GUIExecResult ¶
type GUIExecResult struct {
// contains filtered or unexported fields
}
func (GUIExecResult) Action ¶
func (r GUIExecResult) Action() GUIActionKind
func (GUIExecResult) Artifact ¶
func (r GUIExecResult) Artifact() algebraic.Option[pathalg.LocalRootedDest]
func (GUIExecResult) Duration ¶
func (r GUIExecResult) Duration() algebraic.Duration
func (GUIExecResult) IsValid ¶
func (r GUIExecResult) IsValid() bool
func (GUIExecResult) IsZero ¶
func (r GUIExecResult) IsZero() bool
func (GUIExecResult) Outcome ¶
func (r GUIExecResult) Outcome() execution.ExecutionOutcome
func (GUIExecResult) Screenshot ¶
func (r GUIExecResult) Screenshot() algebraic.Option[ProcessedScreenshot]
func (GUIExecResult) Stderr ¶
func (r GUIExecResult) Stderr() string
func (GUIExecResult) Stdout ¶
func (r GUIExecResult) Stdout() string
type GUISessionInfo ¶
type GUISessionInfo struct {
// contains filtered or unexported fields
}
func (GUISessionInfo) BoundAddr ¶
func (i GUISessionInfo) BoundAddr() string
func (GUISessionInfo) DisplayNum ¶
func (i GUISessionInfo) DisplayNum() int
func (GUISessionInfo) Handle ¶
func (i GUISessionInfo) Handle() plan.ManagedHandle[plan.KindTunnel]
func (GUISessionInfo) IsValid ¶
func (i GUISessionInfo) IsValid() bool
func (GUISessionInfo) IsZero ¶
func (i GUISessionInfo) IsZero() bool
func (GUISessionInfo) Kind ¶
func (i GUISessionInfo) Kind() GUISessionKind
func (GUISessionInfo) RemoteTarget ¶
func (i GUISessionInfo) RemoteTarget() string
type GUISessionKind ¶
type GUISessionKind uint8
func ParseGUISessionKind ¶
func ParseGUISessionKind(raw string) (GUISessionKind, error)
func (GUISessionKind) AppendText ¶
func (k GUISessionKind) AppendText(b []byte) ([]byte, error)
func (GUISessionKind) IsValid ¶
func (k GUISessionKind) IsValid() bool
func (GUISessionKind) IsZero ¶
func (k GUISessionKind) IsZero() bool
func (GUISessionKind) MarshalText ¶
func (k GUISessionKind) MarshalText() ([]byte, error)
func (GUISessionKind) String ¶
func (k GUISessionKind) String() string
func (*GUISessionKind) UnmarshalText ¶
func (k *GUISessionKind) UnmarshalText(t []byte) error
type GUISessionSpec ¶
type GUISessionSpec struct {
Kind GUISessionKind
DisplayNum int
UseUnixSocket, AllowNonLoopbackBind bool
LocalBindHost string
LocalBindPort uint16
}
GUIActionSpec、GUIArtifactDest、GUIExecRequest、ProcessedScreenshot、GUIExecResult 与 GUI 会话类型。
type GUISessionStatus ¶
type GUISessionStatus struct {
// contains filtered or unexported fields
}
func (GUISessionStatus) Active ¶
func (s GUISessionStatus) Active() bool
func (GUISessionStatus) BoundAddr ¶
func (s GUISessionStatus) BoundAddr() string
func (GUISessionStatus) DisplayNum ¶
func (s GUISessionStatus) DisplayNum() int
func (GUISessionStatus) Err ¶
func (s GUISessionStatus) Err() error
func (GUISessionStatus) HandleStatus ¶
func (s GUISessionStatus) HandleStatus() pool.HandleStatus
func (GUISessionStatus) IsValid ¶
func (s GUISessionStatus) IsValid() bool
func (GUISessionStatus) IsZero ¶
func (s GUISessionStatus) IsZero() bool
func (GUISessionStatus) Kind ¶
func (s GUISessionStatus) Kind() GUISessionKind
func (GUISessionStatus) RemoteTarget ¶
func (s GUISessionStatus) RemoteTarget() string
type HostMetricsFrame ¶
type HostMetricsFrame struct {
NodeID string `json:"node_id"`
SampledAt time.Time `json:"sampled_at"`
Hostname string `json:"hostname,omitzero"`
CPUPercent float64 `json:"cpu_percent"`
Load1 float64 `json:"load_1"`
Load5 float64 `json:"load_5"`
Load15 float64 `json:"load_15"`
MemUsed uint64 `json:"mem_used_bytes"`
MemTotal uint64 `json:"mem_total_bytes"`
MemPercent float64 `json:"mem_percent"`
Uptime algebraic.Duration `json:"uptime"`
Disks []DiskMetric `json:"disks,omitzero"`
Processes []ProcessMetric `json:"processes,omitzero"`
}
DiskMetric、ProcessMetric、HostMetricsFrame、MetricsStreamRequest 与 MetricsStreamResult(零裸 time.Duration)。
type LogEntry ¶
type LogEntry struct {
TraceID string `json:"trace_id"`
OperationID string `json:"operation_id,omitzero"`
NodeID string `json:"node_id,omitzero"`
Stream events.OutputStreamKind `json:"stream"`
ChunkIndex uint64 `json:"chunk_index"`
Data string `json:"data"`
Truncated bool `json:"truncated,omitzero"`
OccurredAt time.Time `json:"occurred_at"`
}
ProjectionConfig 与不可变投影视图 DTO(零裸 time.Duration,供 Phase 5 entry/tui 直接消费)。
type LogStreamRequest ¶
type LogStreamRequest struct {
Plan plan.SealedConnectionPlan
NodeID string
Profile algebraic.Option[execution.LaunchProfile]
Target LogTarget
TailLines int
Follow bool
MaxBytes uint64
Timeout algebraic.Option[algebraic.Duration]
Output io.Writer
Risk algebraic.Option[security.RiskLevel]
Approval algebraic.Option[gate.ApprovalSubmission]
OperationStream *events.OperationStream
}
LogStreamRequest 与 LogStreamResult 描述远端日志采集输入与不可变结果快照。
type LogStreamResult ¶
type LogStreamResult struct {
// contains filtered or unexported fields
}
func (LogStreamResult) Data ¶
func (r LogStreamResult) Data() []byte
func (LogStreamResult) Duration ¶
func (r LogStreamResult) Duration() algebraic.Duration
func (LogStreamResult) IsValid ¶
func (r LogStreamResult) IsValid() bool
func (LogStreamResult) IsZero ¶
func (r LogStreamResult) IsZero() bool
func (LogStreamResult) Outcome ¶
func (r LogStreamResult) Outcome() execution.ExecutionOutcome
func (LogStreamResult) Truncated ¶
func (r LogStreamResult) Truncated() bool
type LogTarget ¶
type LogTarget struct {
// contains filtered or unexported fields
}
LogTarget 表示经校验的远端日志采集目标(常规文件路径或安全白名单 Docker 容器名);零值恒无效。
func NewDockerLogTarget ¶
func NewFileLogTarget ¶
func NewFileLogTarget(p pathalg.RemotePath) (LogTarget, error)
NewFileLogTarget 与 NewDockerLogTarget 构造校验后的远端日志目标。
func (LogTarget) FilePath ¶
func (t LogTarget) FilePath() pathalg.RemotePath
func (LogTarget) Kind ¶
func (t LogTarget) Kind() LogTargetKind
type LogTargetKind ¶
type LogTargetKind uint8
func ParseLogTargetKind ¶
func ParseLogTargetKind(raw string) (LogTargetKind, error)
ParseLogTargetKind / ParseProcessSortBy / ParseGUIActionKind / ParseScrollDirection / ParseGUISessionKind。
func (LogTargetKind) AppendText ¶
func (k LogTargetKind) AppendText(b []byte) ([]byte, error)
func (LogTargetKind) IsValid ¶
func (k LogTargetKind) IsValid() bool
func (LogTargetKind) IsZero ¶
func (k LogTargetKind) IsZero() bool
func (LogTargetKind) MarshalText ¶
func (k LogTargetKind) MarshalText() ([]byte, error)
func (LogTargetKind) String ¶
func (k LogTargetKind) String() string
func (*LogTargetKind) UnmarshalText ¶
func (k *LogTargetKind) UnmarshalText(t []byte) error
type MetricPoint ¶
type MetricPoint struct {
Key string `json:"key"`
NodeID string `json:"node_id,omitzero"`
Name string `json:"name"`
Unit string `json:"unit,omitzero"`
Value float64 `json:"value"`
Interval algebraic.Duration `json:"interval"`
Labels map[string]string `json:"labels,omitzero"`
OccurredAt time.Time `json:"occurred_at"`
}
ProjectionConfig 与不可变投影视图 DTO(零裸 time.Duration,供 Phase 5 entry/tui 直接消费)。
type MetricsStreamRequest ¶
type MetricsStreamRequest struct {
Plan plan.SealedConnectionPlan
NodeID string
Profile algebraic.Option[execution.LaunchProfile]
Interval algebraic.Option[algebraic.Duration]
MaxSamples, TopProcesses int
SortBy algebraic.Option[ProcessSortBy]
Timeout algebraic.Option[algebraic.Duration]
OnFrame func(HostMetricsFrame)
Risk algebraic.Option[security.RiskLevel]
Approval algebraic.Option[gate.ApprovalSubmission]
OperationStream *events.OperationStream
}
DiskMetric、ProcessMetric、HostMetricsFrame、MetricsStreamRequest 与 MetricsStreamResult(零裸 time.Duration)。
type MetricsStreamResult ¶
type MetricsStreamResult struct {
// contains filtered or unexported fields
}
func (MetricsStreamResult) Duration ¶
func (r MetricsStreamResult) Duration() algebraic.Duration
func (MetricsStreamResult) Frames ¶
func (r MetricsStreamResult) Frames() []HostMetricsFrame
func (MetricsStreamResult) IsValid ¶
func (r MetricsStreamResult) IsValid() bool
func (MetricsStreamResult) IsZero ¶
func (r MetricsStreamResult) IsZero() bool
func (MetricsStreamResult) Outcome ¶
func (r MetricsStreamResult) Outcome() execution.ExecutionOutcome
type OpenGUISessionRequest ¶
type OpenGUISessionRequest struct {
Plan plan.SealedConnectionPlan
NodeID string
Spec GUISessionSpec
Risk algebraic.Option[security.RiskLevel]
Approval algebraic.Option[gate.ApprovalSubmission]
OperationStream *events.OperationStream
}
GUIActionSpec、GUIArtifactDest、GUIExecRequest、ProcessedScreenshot、GUIExecResult 与 GUI 会话类型。
type OperationView ¶
type OperationView struct {
OperationID string `json:"operation_id"`
TraceID string `json:"trace_id"`
NodeID string `json:"node_id,omitzero"`
Tool string `json:"tool,omitzero"`
Action string `json:"action,omitzero"`
Summary string `json:"summary,omitzero"`
Completed bool `json:"completed"`
Succeeded bool `json:"succeeded"`
Unknown bool `json:"unknown,omitzero"`
LastCode string `json:"last_code,omitzero"`
LastMessage string `json:"last_message,omitzero"`
LastStepID string `json:"last_step_id,omitzero"`
LastStepStat string `json:"last_step_status,omitzero"`
Duration algebraic.Duration `json:"duration"`
UpdatedAt time.Time `json:"updated_at"`
}
ProjectionConfig 与不可变投影视图 DTO(零裸 time.Duration,供 Phase 5 entry/tui 直接消费)。
type PoolRecord ¶
type PoolRecord struct {
Action events.PoolEventAction `json:"action"`
Endpoint string `json:"endpoint,omitzero"`
ActiveLeases uint32 `json:"active_leases"`
Latency algebraic.Duration `json:"latency"`
Detail string `json:"detail,omitzero"`
OccurredAt time.Time `json:"occurred_at"`
}
ProjectionConfig 与不可变投影视图 DTO(零裸 time.Duration,供 Phase 5 entry/tui 直接消费)。
type ProcessMetric ¶
type ProcessMetric struct {
PID int32 `json:"pid"`
User string `json:"user"`
CPUPercent float64 `json:"cpu_percent"`
MemPercent float64 `json:"mem_percent"`
Command string `json:"command"`
}
DiskMetric、ProcessMetric、HostMetricsFrame、MetricsStreamRequest 与 MetricsStreamResult(零裸 time.Duration)。
type ProcessSortBy ¶
type ProcessSortBy uint8
func ParseProcessSortBy ¶
func ParseProcessSortBy(raw string) (ProcessSortBy, error)
func (ProcessSortBy) AppendText ¶
func (s ProcessSortBy) AppendText(b []byte) ([]byte, error)
func (ProcessSortBy) IsValid ¶
func (s ProcessSortBy) IsValid() bool
func (ProcessSortBy) IsZero ¶
func (s ProcessSortBy) IsZero() bool
func (ProcessSortBy) MarshalText ¶
func (s ProcessSortBy) MarshalText() ([]byte, error)
func (ProcessSortBy) String ¶
func (s ProcessSortBy) String() string
func (*ProcessSortBy) UnmarshalText ¶
func (s *ProcessSortBy) UnmarshalText(t []byte) error
type ProcessedScreenshot ¶
type ProcessedScreenshot struct {
MIMEType string `json:"mime_type"`
Width int `json:"width"`
Height int `json:"height"`
OrigWidth int `json:"orig_width"`
OrigHeight int `json:"orig_height"`
Data []byte `json:"-"`
}
GUIActionSpec、GUIArtifactDest、GUIExecRequest、ProcessedScreenshot、GUIExecResult 与 GUI 会话类型。
func ExtractAndProcessScreenshot ¶
func ExtractAndProcessScreenshot(rawStdout []byte) (ProcessedScreenshot, error)
ExtractAndProcessScreenshot 从远端 GUI 捕获输出中提取显式标记包裹的 Base64 图像载荷, 在解码像素前严格实施魔数分派(PNG/JPEG/WebP 零空导入)与解压炸弹尺寸守卫,并按最长边 1280px 等比双线性压缩为 JPEG。
func ProcessScreenshotBytes ¶
func ProcessScreenshotBytes(raw []byte) (ProcessedScreenshot, error)
ProcessScreenshotBytes 对原始图像字节执行纯 Go 零 CGO 魔数校验、防解压炸弹校验与最长边 1280px 等比 JPEG 压缩; 合法 WebP 在完整校验 RIFF/VP8/VP8L/VP8X 尺寸头后有界透传,不支持或受损图像严格失败关闭返回 ErrScreenshotInvalid。
type Projection ¶
type Projection struct {
// contains filtered or unexported fields
}
Projection 是面向 Phase 5 entry/tui 与诊断面板的实时状态投影聚合器(ADR-010 / Plan P3-T4):
- 受 core/conc.Nursery 全程监督消费 SystemBus 与多条 OperationStream(0 裸 go、0 goroutine 泄漏);
- 穷尽消费全部 12 类封闭 events.Event 变体,单调锁存 GateHalted / OutcomeUnknown 告警位;
- 提供无锁竞态不可变 Snapshot() 与纯事件驱动 WaitUpdate()(0 轮询、0 time.Sleep)。
func NewProjection ¶
func NewProjection(ctx context.Context, cfg ProjectionConfig) (*Projection, error)
NewProjection 校验缓冲配置并在 core/conc.Nursery 监督下启动 SystemBus 消费投影。
func (*Projection) ApplyEvent ¶
func (p *Projection) ApplyEvent(ev events.Event) error
ApplyEvent 将单条有效封闭 events.Event 同步投影至内部有界视图,穷尽覆盖全部 12 类事件并 fail-closed 拒绝未知变体。
func (*Projection) AttachOperationStream ¶
func (p *Projection) AttachOperationStream(stream *events.OperationStream) error
AttachOperationStream 将单次用例调用的隔离 OperationStream 挂载至本 Projection 异步排空消费。
func (*Projection) Close ¶
func (p *Projection) Close() error
Close 幂等关闭订阅与 Nursery,确定性排空全部后台消费协程并唤醒所有 WaitUpdate 等待者(不伪造版本自增,0 goroutine 泄漏)。
func (*Projection) Snapshot ¶
func (p *Projection) Snapshot() ProjectionSnapshot
Snapshot 返回当前聚合投影的无锁竞态、确定性排序不可变快照;未初始化零值失败关闭。
func (*Projection) WaitUpdate ¶
func (p *Projection) WaitUpdate(ctx context.Context, sinceVersion uint64) (ProjectionSnapshot, error)
WaitUpdate 以纯事件驱动阻塞等待投影版本号严格大于 sinceVersion,或 ctx 取消 / Projection 关闭(0 轮询)。
type ProjectionConfig ¶
type ProjectionConfig struct {
SystemBus *events.SystemBus
BusBuffer, MaxLogEntries, MaxDiagnostics, MaxPoolEvents, MaxOperations, MaxMetrics int
}
ProjectionConfig 与不可变投影视图 DTO(零裸 time.Duration,供 Phase 5 entry/tui 直接消费)。
type ProjectionSnapshot ¶
type ProjectionSnapshot struct {
// contains filtered or unexported fields
}
ProjectionSnapshot 是 Projection 的并发安全不可变投影快照;零值恒无效。
func (ProjectionSnapshot) ActiveStreams ¶
func (s ProjectionSnapshot) ActiveStreams() int
func (ProjectionSnapshot) CanonicalJSON ¶
func (s ProjectionSnapshot) CanonicalJSON() ([]byte, error)
func (ProjectionSnapshot) Diagnostics ¶
func (s ProjectionSnapshot) Diagnostics() []DiagnosticRecord
func (ProjectionSnapshot) DroppedEvents ¶
func (s ProjectionSnapshot) DroppedEvents() uint64
func (ProjectionSnapshot) GateHalted ¶
func (s ProjectionSnapshot) GateHalted() bool
func (ProjectionSnapshot) HasUnknownOutcome ¶
func (s ProjectionSnapshot) HasUnknownOutcome() bool
func (ProjectionSnapshot) IsValid ¶
func (s ProjectionSnapshot) IsValid() bool
func (ProjectionSnapshot) IsZero ¶
func (s ProjectionSnapshot) IsZero() bool
func (ProjectionSnapshot) Logs ¶
func (s ProjectionSnapshot) Logs() []LogEntry
func (ProjectionSnapshot) MarshalJSONTo ¶
func (s ProjectionSnapshot) MarshalJSONTo(enc *jsontext.Encoder) error
MarshalJSONTo 与 CanonicalJSON 实现 ProjectionSnapshot 的 Go 1.27 encoding/json/v2 确定性编码。
func (ProjectionSnapshot) Metrics ¶
func (s ProjectionSnapshot) Metrics() []MetricPoint
func (ProjectionSnapshot) Operations ¶
func (s ProjectionSnapshot) Operations() []OperationView
func (ProjectionSnapshot) PoolEvents ¶
func (s ProjectionSnapshot) PoolEvents() []PoolRecord
func (ProjectionSnapshot) TotalEvents ¶
func (s ProjectionSnapshot) TotalEvents() uint64
func (ProjectionSnapshot) Version ¶
func (s ProjectionSnapshot) Version() uint64
type ScrollDirection ¶
type ScrollDirection uint8
func ParseScrollDirection ¶
func ParseScrollDirection(raw string) (ScrollDirection, error)
func (ScrollDirection) AppendText ¶
func (d ScrollDirection) AppendText(b []byte) ([]byte, error)
func (ScrollDirection) IsValid ¶
func (d ScrollDirection) IsValid() bool
func (ScrollDirection) IsZero ¶
func (d ScrollDirection) IsZero() bool
func (ScrollDirection) MarshalText ¶
func (d ScrollDirection) MarshalText() ([]byte, error)
func (ScrollDirection) String ¶
func (d ScrollDirection) String() string
func (*ScrollDirection) UnmarshalText ¶
func (d *ScrollDirection) UnmarshalText(t []byte) error
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service 是 XOps v2 可观测性(日志/指标流)与 POSIX 强校验 GUI 自动化/隧道会话用例服务; 物理不依赖 OperatorReadFS,零值恒未初始化并严格失败关闭。
func NewService ¶
func NewService(cfg ServiceConfig) (*Service, error)
NewService 校验必填出站依赖并构造不可绕过能力门控的 observability.Service。
func (*Service) CloseGUISession ¶
func (s *Service) CloseGUISession(ctx context.Context, handle plan.ManagedHandle[plan.KindTunnel]) error
CloseGUISession 显式释放受管 GUI 会话句柄并有界关闭底层转发与守护协程。
func (*Service) ExecuteGUI ¶
func (s *Service) ExecuteGUI(ctx context.Context, req GUIExecRequest) (GUIExecResult, error)
ExecuteGUI 执行经强 POSIX 校验与能力门控(CapExecute)的远端 GUI 动作, 支持纯 Go 截图压缩与可选 ScopedRootFS 产物落盘(物理 0 OperatorReadFS 依赖,供 MCP gui 安全复用)。
func (*Service) InspectGUISession ¶
func (s *Service) InspectGUISession(ctx context.Context, handle plan.ManagedHandle[plan.KindTunnel]) (GUISessionStatus, error)
InspectGUISession 查询受管 GUI 会话句柄的不可变状态快照;Gate Halted 态立即拒绝。
func (*Service) OpenGUISession ¶
func (s *Service) OpenGUISession(ctx context.Context, req OpenGUISessionRequest) (GUISessionInfo, error)
func (*Service) StreamLogs ¶
func (s *Service) StreamLogs(ctx context.Context, req LogStreamRequest) (LogStreamResult, error)
func (*Service) StreamMetrics ¶
func (s *Service) StreamMetrics(ctx context.Context, req MetricsStreamRequest) (MetricsStreamResult, error)
StreamMetrics 在严格 POSIX Bourne 校验与 CapInspect 门控下流式采集远端 /proc NDJSON 主机指标, 逐行实时解析并盖采样时钟、计算 CPU 增量利用率、确定性排序 Top-N 进程并推送至 OperationStream 与 OnFrame。
type ServiceConfig ¶
type ServiceConfig struct {
Gate gate.Authorizer // 必填:能力门控授权器(ADR-008)
Pool *pool.Pool // 必填:双通道纯内存 Actor 连接池(ADR-009)
Clock ports.Clock // 必填:确定性时钟端口
Entropy ports.Entropy // 必填:显式熵源端口
Env ports.EnvPort // 可选:SendEnv 环境变量过滤端口
ScopedFS ports.ScopedRootFS // 可选:沙箱本地文件系统(仅用于 GUI 截图产物原子落盘)
Forwarder ports.ForwarderPort // 可选:SSH 端口/Unix 隧道转发端口(GUI X11/VNC 会话)
ShellProbe ports.ShellProbePort // 可选:两阶段远端 Shell 方言探测端口
SystemBus *events.SystemBus // 可选:非阻塞诊断总线
}
ServiceConfig 定义可观测性与 GUI 用例服务 Service 的显式出站依赖配置; 物理不接受 OperatorReadFS,确保 MCP 运行时(P3-T5)复用本服务时 100% 满足沙箱边界隔离。