engineutil

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: MIT Imports: 31 Imported by: 0 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 engineutil 提供 core/engine 使用的 100% 无状态纯辅助函数与公开请求规格: 涵盖公开哨兵错误与分组映射、枚举文本编解码、RequestTTYMode、跨用例请求 DTO、配置字段归一化与事件流辅助。

本包属 LayerCoreEngine 无环内部叶包(0 sshnet/*、0 sync、0 net、0 状态), 构造期协议端口与服务装配归属 core/engine/internal/assembly,生产代码严禁导入 tck 与 sim。

Index

Constants

View Source
const (
	DefaultSystemBusBuffer       = 64
	DefaultOperationStreamBuffer = 64
)

Engine 事件流与诊断总线默认缓冲区大小。

Variables

View Source
var (
	ErrNilContext               = domi18n.Sentinel(domi18n.KeyEngineNilContext)
	ErrInvalidConfig            = domi18n.Sentinel(domi18n.KeyEngineInvalidConfig)
	ErrEngineNotInitialized     = domi18n.Sentinel(domi18n.KeyEngineNotInitialized)
	ErrEngineClosed             = domi18n.Sentinel(domi18n.KeyEngineClosed)
	ErrEngineHalted             = domi18n.Sentinel(domi18n.KeyEngineHalted)
	ErrInvalidRequest           = domi18n.Sentinel(domi18n.KeyEngineInvalidRequest)
	ErrInvalidProfile           = domi18n.Sentinel(domi18n.KeyEngineInvalidProfile)
	ErrInvalidFallback          = domi18n.Sentinel(domi18n.KeyEngineInvalidFallback)
	ErrInvalidRequestTTY        = domi18n.Sentinel(domi18n.KeyEngineInvalidReqTTY)
	ErrReconcilerUnavailable    = domi18n.Sentinel(domi18n.KeyEngineReconcilerUnav)
	ErrVaultUnavailable         = domi18n.Sentinel(domi18n.KeyEngineVaultUnavail)
	ErrMCPServerNotInitialized  = domi18n.Sentinel(domi18n.KeyEngineMCPNotInit)
	ErrProjectionNotInitialized = domi18n.Sentinel(domi18n.KeyEngineProjNotInit)
	ErrApprovalRequired         = domi18n.Sentinel(domi18n.KeyEngineApprovalReq)
	ErrApprovalRejected         = domi18n.Sentinel(domi18n.KeyEngineApprovalReject)
	ErrAuthorizationDenied      = domi18n.Sentinel(domi18n.KeyEngineAuthDenied)
	ErrScopeEscalated           = domi18n.Sentinel(domi18n.KeyEngineScopeEscalated)
	ErrNotFound                 = domi18n.Sentinel(domi18n.KeyEngineNotFound)
	ErrAlreadyExists            = domi18n.Sentinel(domi18n.KeyEngineAlreadyExists)
	ErrRevisionConflict         = domi18n.Sentinel(domi18n.KeyEngineRevisionConf)
	ErrStillReferenced          = domi18n.Sentinel(domi18n.KeyEngineStillReferenced)
	ErrImportConflict           = domi18n.Sentinel(domi18n.KeyEngineImportConflict)
	ErrUncertainDurability      = domi18n.Sentinel(domi18n.KeyEngineUncertainDur)
	ErrOutcomeUnknown           = domi18n.Sentinel(domi18n.KeyEngineOutcomeUnknown)
	ErrVaultLocked              = domi18n.Sentinel(domi18n.KeyEngineVaultLocked)
	ErrSecretNotFound           = domi18n.Sentinel(domi18n.KeyEngineSecretNotFound)
	ErrAuthFailed               = domi18n.Sentinel(domi18n.KeyEngineAuthFailed)
	ErrHostKeyUnknown           = domi18n.Sentinel(domi18n.KeyEngineHostKeyUnknown)
	ErrHostKeyMismatch          = domi18n.Sentinel(domi18n.KeyEngineHostKeyMismatch)
	ErrHostKeyRevoked           = domi18n.Sentinel(domi18n.KeyEngineHostKeyRevoked)
	ErrDialFailed               = domi18n.Sentinel(domi18n.KeyEngineDialFailed)
	ErrControlMasterDisabled    = domi18n.Sentinel(domi18n.KeyEngineMuxDisabled)
	ErrMuxUnavailable           = domi18n.Sentinel(domi18n.KeyEngineMuxUnavailable)
	ErrHandleNotFound           = domi18n.Sentinel(domi18n.KeyEngineHandleNotFound)
	ErrHandleRevoked            = domi18n.Sentinel(domi18n.KeyEngineHandleRevoked)
	ErrInteractionUnavailable   = domi18n.Sentinel(domi18n.KeyEngineInteractUnav)
	ErrInteractionCanceled      = domi18n.Sentinel(domi18n.KeyEngineInteractCancel)
	ErrRemoteAnchorMismatch     = domi18n.Sentinel(domi18n.KeyEngineAnchorMismatch)
	ErrRemoteIsDir              = domi18n.Sentinel(domi18n.KeyEngineRemoteIsDir)
	ErrNotRegularFile           = domi18n.Sentinel(domi18n.KeyEngineNotRegularFile)
	ErrPatchConflict            = domi18n.Sentinel(domi18n.KeyEnginePatchConflict)
	ErrDigestMismatch           = domi18n.Sentinel(domi18n.KeyEngineDigestMismatch)
	ErrSymlinkRejected          = domi18n.Sentinel(domi18n.KeyEngineSymlinkReject)
	ErrCorruptData              = domi18n.Sentinel(domi18n.KeyEngineCorruptData)
	ErrLimitExceeded            = domi18n.Sentinel(domi18n.KeyEngineLimitExceeded)
	ErrUnsupported              = domi18n.Sentinel(domi18n.KeyEngineUnsupported)
	ErrCanonicalizeFailed       = ucinv.ErrCanonicalizeFailed
	ErrEscapeDisconnected       = ucsess.ErrEscapeDisconnected
)

不可变公开规范哨兵错误,由父包 core/engine 只读重导出以保持指针同一性。

Functions

func AppendValidEnumText

func AppendValidEnumText(b []byte, valid bool, name string, baseErr error, raw uint8) ([]byte, error)

AppendValidEnumText 在枚举有效时向字节缓冲追加其名称,否则返回结构化错误。

func BuildPoolConfig

func BuildPoolConfig(in PoolConfigInput) (pool.PoolConfig, error)

BuildPoolConfig 校验可选连接池时长参数并构造 pool.PoolConfig。

func ChallengeReasonParam

func ChallengeReasonParam(valid bool, reasonMsg algebraic.Option[domi18n.Message], reason, key string) domi18n.Param

ChallengeReasonParam 将审批挑战原因投影为结构化 domi18n.Param(无效零值失败关闭至默认审批原因)。

func CloseOpStreams

func CloseOpStreams(main *events.OperationStream, extras map[inventory.NodeID]*events.OperationStream)

CloseOpStreams 闭合主事件流与全部节点子事件流。

func CloseStreamIfNonNil

func CloseStreamIfNonNil(s *events.OperationStream)

CloseStreamIfNonNil 在事件流非空时关闭以保证确定性 EOF。

func CompileExecCommandPlan

func CompileExecCommandPlan(planOpt algebraic.Option[execution.CommandPlan], rawCmd string, args []string, timeout algebraic.Option[algebraic.Duration]) (execution.CommandPlan, error)

CompileExecCommandPlan 校验互斥三选一命令来源(CommandPlan / Command / CommandArgs)并编译不可变 CommandPlan。

func CompileGuardrailPolicy

func CompileGuardrailPolicy(in GuardrailInput) (gate.GuardrailPolicy, error)

CompileGuardrailPolicy 解析受保护路径模式与 UTF-8 Glob 命令黑名单并编译不可变 gate.GuardrailPolicy。

func CompileOptionalExecCommandPlan

func CompileOptionalExecCommandPlan(planOpt algebraic.Option[execution.CommandPlan], rawCmd string, args []string, timeout algebraic.Option[algebraic.Duration]) (algebraic.Option[execution.CommandPlan], error)

CompileOptionalExecCommandPlan 校验可选互斥命令来源(0 或 1 项):全部未提供时返回 None,提供 1 项时编译不可变 CommandPlan。

func ForwardBindOptionsFromPolicy

func ForwardBindOptionsFromPolicy(pol option.EffectivePolicy) (ports.ForwardBindOptions, error)

ForwardBindOptionsFromPolicy 将已折叠四层 OpenSSH 策略投影为不可变 ports.ForwardBindOptions。

func InheritTransferPrivilege added in v1.4.0

func InheritTransferPrivilege(priv uctrans.PrivilegeOptions, target ucinv.ResolvedTarget) uctrans.PrivilegeOptions

InheritTransferPrivilege 为远端直转/批量 SCP 继承节点级提权策略与密码引用(ADR-020 v1.2 §2.2.2): 仅当调用方未显式设置 Policy 且无冲突子字段时继承节点 Policy(显式 PrivilegePolicyNone 仍可退出); 当生效提权且未指定 PasswordRef/PromptPassword 时继承节点 PrivilegePasswordRef。

func LookupEnumName

func LookupEnumName(idx uint8, fallback string, names ...string) string

LookupEnumName 按索引查找枚举规范名称,越界回退 fallback。

func MapEngineError

func MapEngineError(err error) error

MapEngineError 按目标门面哨兵分组收集全部命中的底层源哨兵(保首次命中序), 并逆序经 domi18n.WrapSentinel 封装以完整保留错误链与结构化无损折叠渲染。

func MapEnum

func MapEnum[F ~uint8, T any](v F, ok bool, baseErr error, table ...T) (T, error)

MapEnum 将底层为 uint8 的枚举按查表投影为目标类型,越界或无效时返回结构化错误。

func MapMCPError

func MapMCPError(err error) error

MapMCPError 将 mcpruntime 配置错误叠加至 ErrInvalidConfig 哨兵链,并执行统一门面哨兵映射。

func MapRes

func MapRes[T any](v T, err error) (T, error)

MapRes 对 (T, error) 返回值执行门面语义哨兵映射。

func MirrorForwardAgentIntoCLI

func MirrorForwardAgentIntoCLI(
	hasPreResolved bool,
	cliOpts option.OptionLayer,
	reqFA algebraic.Option[option.ForwardAgentSpec],
) option.OptionLayer

MirrorForwardAgentIntoCLI 在未提供预解析目标且 CLIOptions 未显式设置 ForwardAgent 时, 将请求级显式 ForwardAgent 镜像写入 CLIOptions,使密封跳板 hop.Transport().ForwardAgent() 与 dial.Dialer 纵深护栏保持一致(ADR-019 v2.2 S3-Q2)。

func NewApprovalSubmission

func NewApprovalSubmission(verdict security.Verdict, envelopeDigest security.Digest, envelope algebraic.Option[security.ApprovalEnvelope], comment string) (gate.ApprovalSubmission, error)

NewApprovalSubmission 校验用户审批判定、信封 SHA-256 摘要与可选完整信封,构造 gate.ApprovalSubmission。

func NewOperationStream

func NewOperationStream(entropy ports.Entropy, buffer int) (*events.OperationStream, error)

NewOperationStream 从显式熵源生成 TraceID/OperationID 并构造单次操作隔离事件流。

func NormalizeMuxSocketKey

func NormalizeMuxSocketKey(raw string) string

NormalizeMuxSocketKey 规范化跨平台 ControlMaster 套接字路径键(剥离 \\?\、统一斜杠、去前导 ./ 与小写 Windows 盘符)。

func NotStartedOutcome

func NotStartedOutcome(phase execution.StartPhase, code string, err error) execution.ExecutionOutcome

NotStartedOutcome 构造启动前失败的不可变 OutcomeNotStarted。

func OptPosStdDuration

func OptPosStdDuration(opt algebraic.Option[algebraic.Duration], name string) (time.Duration, error)

OptPosStdDuration 校验可选正时长配置并转换为标准 time.Duration。

func ParseEnumPairs

func ParseEnumPairs[T any](raw string, zero T, baseErr error, pairs ...EnumPair[T]) (T, error)

ParseEnumPairs 按大小写无关且裁剪空白的方式匹配枚举键列表,未命中返回绑定值的结构化错误。

func RequestTTYToSession added in v1.4.0

func RequestTTYToSession(m RequestTTYMode) (ucsess.RequestTTYMode, error)

RequestTTYToSession 将公开 RequestTTYMode 投影为会话用例层伪终端策略(越界失败关闭)。

func ResolveHostTrustDirs

func ResolveHostTrustDirs(homeDir, khDirOpt algebraic.Option[pathalg.LocalDir], env ports.EnvPort) (homeOpt algebraic.Option[pathalg.LocalDir], khDir pathalg.LocalDir, err error)

ResolveHostTrustDirs 解析 KnownHostsDB 所需的 HomeDir 与默认 known_hosts 目录(~/.ssh)。

func ResolveSessionAgentOverrides

ResolveSessionAgentOverrides 当会话请求未显式覆写 ForwardAgent/IdentityAgent 时, 从已解析 EffectivePolicy 透传真实四态 ForwardAgentSpec(含自定义套接字路径)与 IdentityAgentSpec, 避免仅靠布尔跳板位回退为 "default" 导致自定义代理路径丢失(ADR-019 v2.2 P1-1)。

func ResolveSystemBus

func ResolveSystemBus(existing *events.SystemBus, buf int) (*events.SystemBus, bool, error)

ResolveSystemBus 在调用方未注入 SystemBus 时按默认缓冲区容量创建自有总线。

func RollbackNew

func RollbackNew(opCancel context.CancelCauseFunc, p *pool.Pool, ownsBus bool, bus *events.SystemBus, cause error)

RollbackNew 在 Engine.New 装配失败时同步回滚已建上下文、连接池与自有诊断总线。

func TakeMapKeys

func TakeMapKeys[K comparable](m map[K]struct{}) []K

TakeMapKeys 抽取映射全部键切片并清空原映射。

func ToAutoTargetNodes

func ToAutoTargetNodes(targets []ucinv.ResolvedTarget) ([]ucauto.TargetNode, error)

ToAutoTargetNodes 将公开 ResolvedTarget 切片直接转换为 automation.TargetNode: 托管及 OpenSSH 派生目标直接消费解析期快照的不可变 Tags、NodeExecution(不含 Global 兜底,避免反向遮蔽 PlaybookSettings)、 Privilege 与 PrivilegePasswordRef,严禁隐式二次 ListNodes 门控与幽灵审计。

func ToBatchSCPTargets added in v1.4.0

func ToBatchSCPTargets(targets []BatchSCPTarget, defaultPriv uctrans.PrivilegeOptions) ([]uctrans.BatchSCPTarget, error)

ToBatchSCPTargets 将公开 BatchSCPTarget 切片转换为 transfer.BatchSCPTarget(使用确定性 SynthesizeTargetNodeID, 并按节点级默认继承 PrivilegePolicy 与 PrivilegePasswordRef,顶层 defaultPriv 优先于节点默认 Policy)。

func UnmarshalEnumText

func UnmarshalEnumText[T any](dst *T, zero T, text []byte, nilErr error, parse func(string) (T, error)) error

UnmarshalEnumText 统一实现公开枚举类型的 TextUnmarshaler 逻辑。

func ValidOrZero

func ValidOrZero[T any](valid bool, v T) T

ValidOrZero 在 valid 为 true 时返回 v,否则返回类型 T 的零值。

func ValidateBaseDeps

func ValidateBaseDeps(clk ports.Clock, ent ports.Entropy, audit ports.AuditSink, bus *events.SystemBus, busBuf int) error

ValidateBaseDeps 校验 Engine 必填基础设施端口与 SystemBus 合法性。

func WrapCfgFieldErr

func WrapCfgFieldErr(field string, err error) error

WrapCfgFieldErr 将配置字段校验错误包裹至 ErrInvalidConfig 哨兵链。

func WrapInitErr

func WrapInitErr(component string, err error) error

WrapInitErr 将组件装配期底层错误包裹至 ErrInvalidConfig 哨兵链。

func ZeroVal

func ZeroVal[T any]() (z T)

ZeroVal 返回任意类型 T 的零值。

Types

type ActivateSSHForwardsRequest added in v1.4.0

type ActivateSSHForwardsRequest struct {
	RemoteCall
	ExplicitCLI bool
	Policy      algebraic.Option[option.EffectivePolicy]
}

ActivateSSHForwardsRequest 描述显式 CLI ssh 边界持久化转发与 TUN 激活请求。

type BatchExecRequest added in v1.4.0

type BatchExecRequest struct {
	CallOptions
	Targets                 []ucinv.ResolvedTarget
	Selector                algebraic.Option[playbook.TargetSelector]
	CLIOptions              option.OptionLayer
	AllowDNSResolve         bool // 可选:允许经 CanonicalResolverPort 执行主机名规范化(零值 false)
	AllowFullAdHocTier4     bool // 可选:允许非 IP AdHoc 受 OpenSSH 全量 Tier-4 升级(零值 false)
	ExcludeNodes            []inventory.NodeID
	ExcludeTags             []inventory.Tag
	Command                 execution.CommandPlan
	ExecutionOverride       algebraic.Option[execution.LaunchProfile]
	Privilege               algebraic.Option[inventory.PrivilegePolicy]
	PrivilegeTargetUser     algebraic.Option[option.Username]
	PrivilegePasswordRef    algebraic.Option[secret.Ref]
	PromptPrivilegePassword bool
	Concurrency             int
	MaxOutputBytes          uint64
	OutputDir               algebraic.Option[pathalg.LocalDir]
	FailFast                bool
	NodeStreams             map[inventory.NodeID]*events.OperationStream
	NodeStreamFactory       ucauto.NodeStreamFactory
}

BatchExecRequest 描述多节点批量命令执行请求。

type BatchSCPTarget added in v1.4.0

type BatchSCPTarget struct {
	Target    ucinv.ResolvedTarget
	Privilege uctrans.PrivilegeOptions
}

BatchSCPTarget 描述多目标批量 SCP 上传的单目标解析结果与可选提权覆写(ADR-020)。

type BatchSCPUploadRequest added in v1.4.0

type BatchSCPUploadRequest struct {
	CallOptions
	Targets                                                                  []BatchSCPTarget
	Source                                                                   uctrans.LocalUploadSource
	RemoteDest                                                               pathalg.RemotePath
	Recursive, ExpandIntoDir, NoClobber, Resume, PreserveMode, PreserveTimes bool
	SymlinkPolicy                                                            pathalg.SymlinkPolicy
	Perm                                                                     algebraic.Option[fs.FileMode]
	ModTime                                                                  algebraic.Option[time.Time]
	ChunkSize                                                                int64
	Concurrency, NodeConcurrency, MaxFiles                                   int
	MaxTotalBytes                                                            uint64
	ExpectedDigest                                                           algebraic.Option[security.Digest]
	FailFast                                                                 bool
	Privilege                                                                uctrans.PrivilegeOptions
	NodeStreams                                                              map[inventory.NodeID]*events.OperationStream
}

BatchSCPUploadRequest 描述多目标批量 SCP 上传请求(ADR-020)。

type CallOptions added in v1.4.0

type CallOptions struct {
	Risk            algebraic.Option[security.RiskLevel]
	Approval        algebraic.Option[gate.ApprovalSubmission]
	OperationStream *events.OperationStream
}

CallOptions 描述风险声明、审批提交与单次操作事件流等通用调用选项。

type ControlMasterRequest added in v1.4.0

type ControlMasterRequest struct {
	RemoteCall
	Policy               algebraic.Option[option.EffectivePolicy]
	ForwardAgent         algebraic.Option[option.ForwardAgentSpec]
	IdentityAgent        algebraic.Option[option.IdentityAgentSpec]
	ExplicitForwardAgent bool
	ForwardBindOptions   algebraic.Option[ports.ForwardBindOptions]
}

ControlMasterRequest 描述 ControlMaster 复用主连接启动请求。

type CopyRemoteFileRequest added in v1.4.0

type CopyRemoteFileRequest struct {
	RemoteCall
	Privilege      uctrans.PrivilegeOptions
	SrcPath        pathalg.RemotePath
	DstPath        pathalg.RemotePath
	NoClobber      bool
	PreserveMode   bool
	PreserveTimes  bool
	ChunkSize      int64
	ExpectedAnchor algebraic.Option[ports.RemoteFileAnchor]
}

CopyRemoteFileRequest 描述同主机远端到远端原子文件拷贝请求(ADR-020)。

type DeleteAssetRequest added in v1.4.0

type DeleteAssetRequest struct {
	CallOptions
	ID, ScopeSummary                                string
	ExpectedRevision                                algebraic.Option[ports.Revision]
	DeleteUnusedSecrets, RequireSecretsUnreferenced bool
	ExtraPending                                    []inventory.PendingSecretRef
}

DeleteAssetRequest 描述资产删除请求(含引用凭据清理与额外 Pending 占用声明)。

type EnumPair

type EnumPair[T any] struct {
	Key string
	Val T
}

EnumPair 表示枚举解析器的文本键值映射项。

type ExecRequest added in v1.4.0

type ExecRequest struct {
	Target                    ucinv.ResolvedTarget
	TargetSpec, Command, Term string
	CLIOptions                option.OptionLayer
	AllowDNSResolve           bool // 可选:允许经 CanonicalResolverPort 执行主机名规范化(零值 false,ADR-019 E1)
	AllowFullAdHocTier4       bool // 可选:允许非 IP AdHoc 受 OpenSSH 全量 Tier-4 升级(零值 false,ADR-019 E2)
	ExplicitOrigin            algebraic.Option[option.OriginKind]
	ExplicitAuth              inventory.AuthMethod
	CommandPlan               algebraic.Option[execution.CommandPlan]
	CommandArgs               []string
	CommandTimeout            algebraic.Option[algebraic.Duration]
	NodeExecution             algebraic.Option[execution.LaunchProfile]
	ExecutionOverride         algebraic.Option[execution.LaunchProfile]
	Stdin                     io.Reader
	Stdout, Stderr            io.Writer
	RequestTTY                RequestTTYMode
	ForwardAgent              algebraic.Option[option.ForwardAgentSpec]
	IdentityAgent             algebraic.Option[option.IdentityAgentSpec]
	ExplicitForwardAgent      bool
	Risk                      algebraic.Option[security.RiskLevel]
	Approval                  algebraic.Option[gate.ApprovalSubmission]
	OperationStream           *events.OperationStream
}

ExecRequest 描述单条远端 SSH 命令执行请求(父包 RunSSHRequest 与其同构零拷贝)。

type ExplicitSSHSessionRequest added in v1.4.0

type ExplicitSSHSessionRequest struct {
	ExplicitCLI                 bool
	Target                      ucinv.ResolvedTarget
	TargetSpec, Command, Term   string
	Subsystem                   string
	CLIOptions                  option.OptionLayer
	AllowDNSResolve             bool // 可选:允许经 CanonicalResolverPort 执行主机名规范化(零值 false,ADR-019 E1)
	AllowFullAdHocTier4         bool // 可选:允许非 IP AdHoc 受 OpenSSH 全量 Tier-4 升级(零值 false,ADR-019 E2)
	ExplicitOrigin              algebraic.Option[option.OriginKind]
	ExplicitAuth                inventory.AuthMethod
	Policy                      algebraic.Option[option.EffectivePolicy]
	ExplicitCommand             algebraic.Option[execution.CommandPlan]
	CommandArgs                 []string
	CommandTimeout              algebraic.Option[algebraic.Duration]
	NodeExecution               algebraic.Option[execution.LaunchProfile]
	ExecutionOverride           algebraic.Option[execution.LaunchProfile]
	Stdin                       io.Reader
	Stdout, Stderr              io.Writer
	RequestTTY                  RequestTTYMode
	EscapeHelpText              string
	ExplicitForwardAgent        bool
	ExecutePostAuthLocalCommand bool         // 可选:在 SSH 认证与建连成功后、打开会话通道/OnStarted 前受控执行 LocalCommand
	OnStarted                   func() error // 可选:远端通道与命令启动成功后、阻塞等待退出前回调(用于跨进程后台脱离等时序编排)
	PrivilegePolicy             algebraic.Option[inventory.PrivilegePolicy]
	PrivilegeTargetUser         algebraic.Option[option.Username]
	PasswordRef                 algebraic.Option[secret.Ref]
	PromptPassword              bool
	PrivilegeTimeout            algebraic.Option[algebraic.Duration]
	Risk                        algebraic.Option[security.RiskLevel]
	Approval                    algebraic.Option[gate.ApprovalSubmission]
	OperationStream             *events.OperationStream
}

ExplicitSSHSessionRequest 描述显式 CLI ssh 边界下结合 EffectivePolicy 执行命令、子系统(-s)、持久化 remote_command 或交互式 Shell 的请求。 必须显式设置 ExplicitCLI=true(零值严格失败关闭),确保非 CLI 路径绝不隐式触发持久化 remote_command。

type GUIExecRequest added in v1.4.0

GUIExecRequest 描述远端 GUI 单步动作执行请求。

type GuardrailInput

type GuardrailInput struct {
	ApprovalThreshold    security.RiskLevel
	NoElicitFallback     gate.NoElicitFallback
	NodeOverrides        algebraic.Option[security.NodeOverrides]
	BlockedCommands      algebraic.Option[security.BlockedCommandMatcher]
	BlockedPatterns      []string
	ProtectedRules       []pathalg.ProtectedRule
	ProtectedPatterns    []string
	ProtectedPathRisk    algebraic.Option[security.RiskLevel]
	ApprovalTTL          algebraic.Option[algebraic.Duration]
	MaxPendingChallenges int
	MaxReplayHistory     int
}

GuardrailInput 描述编译 gate.GuardrailPolicy 所需的归一化输入参数。

type ImportRequest added in v1.4.0

type ImportRequest struct {
	CallOptions
	Format, SourceName, ScopeSummary string
	Reader                           io.Reader
	Bundle                           algebraic.Option[inventory.ImportBundle]
	ExpectedRevision                 algebraic.Option[ports.Revision]
	DryRun                           bool
}

ImportRequest 描述外部格式资产导入请求(Reader 与预解析 Bundle 二选一)。

type InspectTransferRequest added in v1.4.0

type InspectTransferRequest struct {
	RemoteCall
	Privilege  uctrans.PrivilegeOptions
	TransferID security.OperationID
	Handle     algebraic.Option[plan.ManagedHandle[plan.KindTransfer]]
}

InspectTransferRequest 描述传输状态快照查询请求。

type InteractiveSSHRequest added in v1.4.0

type InteractiveSSHRequest struct {
	Target               ucinv.ResolvedTarget
	TargetSpec, Term     string
	CLIOptions           option.OptionLayer
	AllowDNSResolve      bool // 可选:允许经 CanonicalResolverPort 执行主机名规范化(零值 false,ADR-019 E1)
	AllowFullAdHocTier4  bool // 可选:允许非 IP AdHoc 受 OpenSSH 全量 Tier-4 升级(零值 false,ADR-019 E2)
	ExplicitOrigin       algebraic.Option[option.OriginKind]
	ExplicitAuth         inventory.AuthMethod
	Stdin                io.Reader
	Stdout, Stderr       io.Writer
	RequestTTY           RequestTTYMode
	EscapeChar           algebraic.Option[option.EscapeCharSpec]
	EscapeHelpText       string
	ForwardAgent         algebraic.Option[option.ForwardAgentSpec]
	IdentityAgent        algebraic.Option[option.IdentityAgentSpec]
	ExplicitForwardAgent bool
	PrivilegePolicy      algebraic.Option[inventory.PrivilegePolicy]
	PrivilegeTargetUser  algebraic.Option[option.Username]
	PasswordRef          algebraic.Option[secret.Ref]
	PromptPassword       bool
	PrivilegeTimeout     algebraic.Option[algebraic.Duration]
	Risk                 algebraic.Option[security.RiskLevel]
	Approval             algebraic.Option[gate.ApprovalSubmission]
	OperationStream      *events.OperationStream
}

InteractiveSSHRequest 描述交互式远端 SSH Shell 会话请求。

type ListDockerContainersRequest added in v1.4.0

type ListDockerContainersRequest struct {
	RemoteCall
	IncludeStopped bool
	MaxContainers  int
	Profile        algebraic.Option[execution.LaunchProfile]
	Timeout        algebraic.Option[algebraic.Duration]
}

ListDockerContainersRequest 描述只读列举远端 Docker 容器列表请求(ADR-020)。

type LocalCommandRequest added in v1.4.0

type LocalCommandRequest struct {
	RemoteCall
	ExplicitCLI     bool
	Policy          algebraic.Option[option.EffectivePolicy]
	TunnelDevice    string
	OnAuthorized    func(authCtx context.Context) (string, error)
	ResolveExecPath func(name string) (string, error)
	Timeout         algebraic.Option[algebraic.Duration]
	MaxOutputBytes  algebraic.Option[uint64]
}

LocalCommandRequest 描述显式 CLI ssh 受控零 Shell 执行 LocalCommand 请求(ADR-019 C2)。

type LogStreamRequest added in v1.4.0

type LogStreamRequest struct {
	RemoteCall
	Profile   algebraic.Option[execution.LaunchProfile]
	Target    ucobs.LogTarget
	TailLines int
	Follow    bool
	MaxBytes  uint64
	Timeout   algebraic.Option[algebraic.Duration]
	Output    io.Writer
}

LogStreamRequest 描述远端日志流读取请求。

type MetricsStreamRequest added in v1.4.0

type MetricsStreamRequest struct {
	RemoteCall
	Profile                  algebraic.Option[execution.LaunchProfile]
	Interval, Timeout        algebraic.Option[algebraic.Duration]
	MaxSamples, TopProcesses int
	SortBy                   algebraic.Option[ucobs.ProcessSortBy]
	OnFrame                  func(ucobs.HostMetricsFrame)
}

MetricsStreamRequest 描述远端主机指标流采集请求。

type MuxControlRequest added in v1.4.0

type MuxControlRequest struct {
	RemoteCall
	SocketPath           algebraic.Option[pathalg.LocalSourcePath]
	Action               ports.MuxControlAction
	Forward              algebraic.Option[ports.ForwardSpec]
	Forwards             []ports.ForwardSpec
	ExitOnForwardFailure bool
}

MuxControlRequest 描述 ControlMaster 控制面(-O)请求。

type OpenGUISessionRequest added in v1.4.0

type OpenGUISessionRequest struct {
	RemoteCall
	Spec ucobs.GUISessionSpec
}

OpenGUISessionRequest 描述远端 GUI 会话打开请求。

type OpenPTYRequest added in v1.4.0

type OpenPTYRequest struct {
	RemoteCall
	Term           string
	Size           algebraic.Option[ports.TerminalSize]
	MaxBufferBytes int
}

OpenPTYRequest 描述远端托管 PTY 会话打开请求。

type PlaybookRequest added in v1.4.0

type PlaybookRequest struct {
	CallOptions
	Playbook                playbook.Playbook
	Targets                 []ucinv.ResolvedTarget
	CLIOptions              option.OptionLayer
	AllowDNSResolve         bool // 可选:允许经 CanonicalResolverPort 执行主机名规范化(零值 false)
	AllowFullAdHocTier4     bool // 可选:允许非 IP AdHoc 受 OpenSSH 全量 Tier-4 升级(零值 false)
	DefaultProfile          algebraic.Option[execution.LaunchProfile]
	Privilege               algebraic.Option[inventory.PrivilegePolicy]
	PrivilegePasswordRef    algebraic.Option[secret.Ref]
	PrivilegeTargetUser     algebraic.Option[option.Username]
	PromptPrivilegePassword bool
	ScopedSourceRoot        algebraic.Option[pathalg.LocalDir]
	Concurrency             int
	Timeout                 algebraic.Option[algebraic.Duration]
	ExtraVars               map[string]string
	NodeStreams             map[inventory.NodeID]*events.OperationStream
	NodeStreamFactory       ucauto.NodeStreamFactory
}

PlaybookRequest 描述 Playbook 多节点编排执行请求。

type PoolConfigInput

type PoolConfigInput struct {
	Dialer            ports.DialerPort
	Clock             ports.Clock
	Entropy           ports.Entropy
	Bus               *events.SystemBus
	AcquireBuffer     int
	MaxConns          int
	MaxHandles        int
	TeardownGrace     algebraic.Option[algebraic.Duration]
	IdleTTL           algebraic.Option[algebraic.Duration]
	KeepaliveInterval algebraic.Option[algebraic.Duration]
}

PoolConfigInput 描述构造 pool.PoolConfig 所需的全部归一化入参。

type PrivilegeExecRequest added in v1.4.0

type PrivilegeExecRequest struct {
	RemoteCall
	Privilege             ports.PrivilegeRequest
	Policy                algebraic.Option[inventory.PrivilegePolicy]
	Command               algebraic.Option[execution.CommandPlan]
	TargetUser            algebraic.Option[option.Username]
	Timeout               algebraic.Option[algebraic.Duration]
	NodeExecution         algebraic.Option[execution.LaunchProfile]
	ExecutionOverride     algebraic.Option[execution.LaunchProfile]
	PasswordRef           algebraic.Option[secret.Ref]
	PromptPassword        bool
	Paths, RecursivePaths []string
	Stdin                 io.Reader
	Stdout, Stderr        io.Writer
	RequestTTY            RequestTTYMode
	Term                  string
}

PrivilegeExecRequest 描述远端提权命令执行请求。

type ProbePendingEnrollmentRequest added in v1.4.0

type ProbePendingEnrollmentRequest struct {
	CallOptions
	CLIOptions option.OptionLayer
}

ProbePendingEnrollmentRequest 描述首连暂存目标真实握手探测请求。

type ProbeShellRequest added in v1.4.0

type ProbeShellRequest struct {
	RemoteCall
	Timeout algebraic.Option[algebraic.Duration]
}

ProbeShellRequest 描述远端 Shell / 提权工具探测请求。

type PullTransferChunkRequest added in v1.4.0

type PullTransferChunkRequest struct {
	RemoteCall
	Privilege     uctrans.PrivilegeOptions
	Handle        plan.ManagedHandle[plan.KindTransfer]
	MaxChunkBytes uint64
}

PullTransferChunkRequest 描述下载分片拉取请求。

type RecoverTransferRequest added in v1.4.0

type RecoverTransferRequest struct {
	RemoteCall
	Privilege         uctrans.PrivilegeOptions
	TransferID        security.OperationID
	PruneSuperseded   bool
	LocalRootForClean algebraic.Option[pathalg.LocalDir]
}

RecoverTransferRequest 描述单条传输日志恢复请求。

type RefConflictData

type RefConflictData struct {
	AssetKind  string
	Subject    string
	AssetRefs  []inventory.AssetReference
	SecretRefs []inventory.SecretReference
}

RefConflictData 封装从错误链中提取的资产或凭据引用冲突纯数据载荷。

func ExtractRefConflictData

func ExtractRefConflictData(err error) (RefConflictData, bool)

ExtractRefConflictData 从错误链提取资产反向引用或凭据引用冲突数据。

type RelayRemoteTransferRequest added in v1.4.0

type RelayRemoteTransferRequest struct {
	CallOptions
	SrcTarget      TargetInput
	SrcPath        pathalg.RemotePath
	SrcPrivilege   uctrans.PrivilegeOptions
	DstTarget      TargetInput
	DstPath        pathalg.RemotePath
	DstPrivilege   uctrans.PrivilegeOptions
	Recursive      bool
	ExpandIntoDir  bool
	NoClobber      bool
	PreserveMode   bool
	PreserveTimes  bool
	SymlinkPolicy  pathalg.SymlinkPolicy
	ChunkSize      int64
	MaxFiles       int
	MaxTotalBytes  uint64
	ExpectedDigest algebraic.Option[security.Digest]
}

RelayRemoteTransferRequest 描述远端到远端零临时文件纯内存流式直转请求(ADR-020)。

type RemoteCall added in v1.4.0

type RemoteCall struct {
	TargetInput
	CallOptions
}

RemoteCall 组合远端目标输入与通用调用选项,供远端操作请求嵌入。

type RemoteFilePatchRequest added in v1.4.0

type RemoteFilePatchRequest struct {
	RemoteCall
	Privilege      uctrans.PrivilegeOptions
	Path           pathalg.RemotePath
	Edits          []uctrans.TextEdit
	ExpectedAnchor algebraic.Option[ports.RemoteFileAnchor]
	ExpectedDigest algebraic.Option[security.Digest]
	MaxBytes       int64
}

RemoteFilePatchRequest 描述远端文本文件补丁请求。

type RemoteFileReadRequest added in v1.4.0

type RemoteFileReadRequest struct {
	RemoteCall
	Privilege uctrans.PrivilegeOptions
	Path      pathalg.RemotePath
	MaxBytes  int64
}

RemoteFileReadRequest 描述远端文件有界读取请求。

type RemoteFileWriteRequest added in v1.4.0

type RemoteFileWriteRequest struct {
	RemoteCall
	Privilege                uctrans.PrivilegeOptions
	Path                     pathalg.RemotePath
	Content                  []byte
	Perm                     algebraic.Option[fs.FileMode]
	NoClobber, CreateParents bool
	ExpectedAnchor           algebraic.Option[ports.RemoteFileAnchor]
}

RemoteFileWriteRequest 描述远端文件原子写入请求。

type RemotePathOpRequest added in v1.4.0

type RemotePathOpRequest struct {
	RemoteCall
	Privilege    uctrans.PrivilegeOptions
	Path         pathalg.RemotePath
	Perm         algebraic.Option[fs.FileMode]
	Atime, Mtime time.Time
}

RemotePathOpRequest 描述单路径远端文件系统操作请求(列目录/建目录/删除/改权限/改时间等)。

type RemoteRenameRequest added in v1.4.0

type RemoteRenameRequest struct {
	RemoteCall
	Privilege        uctrans.PrivilegeOptions
	OldPath, NewPath pathalg.RemotePath
	NoClobber        bool
	ExpectedAnchor   algebraic.Option[ports.RemoteFileAnchor]
}

RemoteRenameRequest 描述远端文件原子重命名请求。

type RemoteStatRequest added in v1.4.0

type RemoteStatRequest struct {
	RemoteCall
	Privilege      uctrans.PrivilegeOptions
	Path           pathalg.RemotePath
	FollowSymlinks bool
}

RemoteStatRequest 描述远端文件元数据查询请求。

type RemoteStatTreeRequest added in v1.4.0

type RemoteStatTreeRequest struct {
	RemoteCall
	Privilege      uctrans.PrivilegeOptions
	Path           pathalg.RemotePath
	FollowSymlinks bool
	TreeDepth      int
	MaxEntries     int
	IgnorePatterns []string
}

RemoteStatTreeRequest 描述单租约有界过滤目录树遍历请求(ADR-020)。

type RequestTTYMode added in v1.4.0

type RequestTTYMode uint8

RequestTTYMode 标识 SSH 会话的伪终端分配策略(auto/yes/no/force,对应 -t/-tt/-T);零值按操作类型取确定性默认。 由父包 core/engine 以类型别名零拷贝重导出。

const (
	RequestTTYUnset RequestTTYMode = iota // 未显式设置(零值)
	RequestTTYAuto                        // 自动模式:仅交互 Shell 且本机为交互终端时分配 PTY
	RequestTTYYes                         // 本机为交互终端时分配 PTY(-t)
	RequestTTYNo                          // 禁止分配 PTY(-T)
	RequestTTYForce                       // 强制分配远端 PTY(-tt)
)

func ParseRequestTTYMode added in v1.4.0

func ParseRequestTTYMode(raw string) (RequestTTYMode, error)

ParseRequestTTYMode 严格解析公开 RequestTTYMode 枚举文本(零堆分配)。

func RequestTTYFromSession added in v1.4.0

func RequestTTYFromSession(m ucsess.RequestTTYMode) RequestTTYMode

RequestTTYFromSession 将会话用例层伪终端策略投影为公开 RequestTTYMode(越界回退 RequestTTYUnset)。

func (RequestTTYMode) AppendText added in v1.4.0

func (m RequestTTYMode) AppendText(b []byte) ([]byte, error)

func (RequestTTYMode) IsValid added in v1.4.0

func (m RequestTTYMode) IsValid() bool

RequestTTYMode 只读校验与文本序列化方法。

func (RequestTTYMode) IsZero added in v1.4.0

func (m RequestTTYMode) IsZero() bool

func (RequestTTYMode) MarshalText added in v1.4.0

func (m RequestTTYMode) MarshalText() ([]byte, error)

func (RequestTTYMode) String added in v1.4.0

func (m RequestTTYMode) String() string

func (*RequestTTYMode) UnmarshalText added in v1.4.0

func (m *RequestTTYMode) UnmarshalText(t []byte) error

type ResumeTransferRequest added in v1.4.0

type ResumeTransferRequest struct {
	RemoteCall
	Privilege uctrans.PrivilegeOptions
	uctrans.TransferSessionOptions
	TransferID   security.OperationID
	StartNextGen bool
}

ResumeTransferRequest 描述可恢复传输续传请求。

type SCPDownloadRequest added in v1.4.0

type SCPDownloadRequest struct {
	RemoteCall
	Privilege                                   uctrans.PrivilegeOptions
	RemoteSource                                pathalg.RemotePath
	LocalRoot                                   pathalg.LocalDir
	LocalDest                                   pathalg.LocalRootedDest
	Recursive, NoClobber, Resume, PreserveTimes bool
	SymlinkPolicy                               pathalg.SymlinkPolicy
	ChunkSize                                   int64
	Concurrency, MaxFiles                       int
	MaxTotalBytes                               uint64
	ExpectedDigest                              algebraic.Option[security.Digest]
}

SCPDownloadRequest 描述并行分片 SCP 下载请求(ScopedRootFS 隔离本地目标)。

type SCPUploadRequest added in v1.4.0

type SCPUploadRequest struct {
	RemoteCall
	Privilege                                                                uctrans.PrivilegeOptions
	Source                                                                   uctrans.LocalUploadSource
	RemoteDest                                                               pathalg.RemotePath
	Recursive, ExpandIntoDir, NoClobber, Resume, PreserveMode, PreserveTimes bool
	SymlinkPolicy                                                            pathalg.SymlinkPolicy
	Perm                                                                     algebraic.Option[fs.FileMode]
	ModTime                                                                  algebraic.Option[time.Time]
	ChunkSize                                                                int64
	Concurrency, MaxFiles                                                    int
	MaxTotalBytes                                                            uint64
	ExpectedDigest                                                           algebraic.Option[security.Digest]
}

SCPUploadRequest 描述并行分片 SCP 上传请求(显式双模态本地源)。

type StartForwardRequest added in v1.4.0

type StartForwardRequest struct {
	RemoteCall
	Spec        ports.ForwardSpec
	BindOptions algebraic.Option[ports.ForwardBindOptions]
}

StartForwardRequest 描述单条端口转发启动请求。

type StartTransferRequest added in v1.4.0

type StartTransferRequest struct {
	RemoteCall
	Privilege uctrans.PrivilegeOptions
	uctrans.TransferSessionOptions
	TransferID     algebraic.Option[security.OperationID]
	Dest           fsm.TransferDest
	TotalBytes     uint64
	ExpectedDigest algebraic.Option[security.Digest]
}

StartTransferRequest 描述可恢复分片传输启动请求。

type StdioForwardRequest added in v1.4.0

type StdioForwardRequest struct {
	RemoteCall
	TargetTemplate string
	Stdin          io.Reader
	Stdout         io.Writer
}

StdioForwardRequest 描述 `-W host:port` 标准输入输出转发请求(ADR-019 A3)。

type SubsystemRequest added in v1.4.0

type SubsystemRequest struct {
	RemoteCall
	Subsystem            string
	Term                 string
	ExtraEnv             map[string]string
	Stdin                io.Reader
	Stdout, Stderr       io.Writer
	RequestTTY           RequestTTYMode
	EscapeChar           algebraic.Option[option.EscapeCharSpec]
	EscapeHelpText       string
	ForwardAgent         algebraic.Option[option.ForwardAgentSpec]
	IdentityAgent        algebraic.Option[option.IdentityAgentSpec]
	ExplicitForwardAgent bool
}

SubsystemRequest 描述 `-s subsystem` 远端 SSH 子系统请求(ADR-019 C1)。

type TargetInput added in v1.4.0

type TargetInput struct {
	Target              ucinv.ResolvedTarget
	TargetSpec          string
	CLIOptions          option.OptionLayer
	AllowDNSResolve     bool // 可选:允许经 CanonicalResolverPort 执行主机名规范化(零值 false,ADR-019 E1)
	AllowFullAdHocTier4 bool // 可选:允许非 IP AdHoc 受 OpenSSH 全量 Tier-4 升级(零值 false,ADR-019 E2)
}

TargetInput 描述远端目标(预解析 Target 与 TargetSpec 须二选一)及目标解析选项。

type TransferHandleOpRequest added in v1.4.0

type TransferHandleOpRequest struct {
	RemoteCall
	Privilege uctrans.PrivilegeOptions
	Handle    plan.ManagedHandle[plan.KindTransfer]
	Reason    string
}

TransferHandleOpRequest 描述基于传输句柄的提交/中止请求。

type WriteTransferChunkRequest added in v1.4.0

type WriteTransferChunkRequest struct {
	RemoteCall
	Privilege uctrans.PrivilegeOptions
	Handle    plan.ManagedHandle[plan.KindTransfer]
	Offset    uint64
	Data      []byte
}

WriteTransferChunkRequest 描述上传分片写入请求。

Jump to

Keyboard shortcuts

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