invval

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: MIT Imports: 14 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 invval 提供 core/domain/inventory 拆分的不可变资产标识、持久化提权策略、复用模板 Profile、 同步来源元数据 SyncSource、临时主机规则 AdHocRule 与叶子导入值对象公开子包。

本包为公开只读叶包(归属 LayerCoreDomain),严格遵守 core/domain/** 纯数学零副作用铁律 (零 os/net/context/sync/reflect),零反向导入父包 core/domain/inventory 且严禁导入 core/domain/dns。 迁移自父包与共享领域值对象的导出类型、常量、哨兵错误与构造器均由父包 core/domain/inventory 在 invval_aliases.go 中通过精确 Go 类型别名、单行转发函数与只读哨兵重导出对外保持 100% 源码与二进制兼容; 无错误布尔派生辅助函数 TryParse* 仅保留于本包,不向父包重导出; //xops:opaque、//xops:failclosed 与 //xops:canonicalhash 契约唯一归属本包原始定义处。

Index

Constants

View Source
const (
	// MaxAdHocRules 表示顶层 adhoc_rules 允许配置的最大规则条目数。
	MaxAdHocRules = invgraph.MaxAdHocRules
	// MaxAdHocRuleCIDRs 表示单条 AdHocRule 允许声明的最大 CIDR 前缀数量。
	MaxAdHocRuleCIDRs = invgraph.MaxAdHocRuleCIDRs
	// MaxAdHocRuleDomains 表示单条 AdHocRule 允许声明的最大域名后缀数量。
	MaxAdHocRuleDomains = invgraph.MaxAdHocRuleDomains
)
View Source
const MaxNodeProfiles = invgraph.MaxNodeProfiles

MaxNodeProfiles 表示单节点允许绑定的最大复用模板 Profile 数量(有序去重)。

View Source
const (
	// MaxPrivilegePromptPatternBytes 表示持久化提权策略自定义口令提示正则的最大字节长度(256B)。
	MaxPrivilegePromptPatternBytes = invgraph.MaxPrivilegePromptPatternBytes
)

Variables

View Source
var (
	// ErrInvalidID 表示资产标识符、别名、标签或目标名称不符合字符集或 INV-ID1 约束。
	ErrInvalidID = domi18n.Sentinel(domi18n.KeyInventoryInvalidID)
	// ErrInvalidKeySpec 表示私钥/证书路径、公钥指纹或口令指纹绑定无效。
	ErrInvalidKeySpec = domi18n.Sentinel(domi18n.KeyInventoryInvalidKeySpec)
	// ErrInvalidChallengeRule 表示质询应答规则类别或字段非法。
	ErrInvalidChallengeRule = domi18n.Sentinel(domi18n.KeyInventoryInvalidChallengeRule)
	// ErrInvalidAuthMethod 表示认证方式或 Agent 规格文本非法。
	ErrInvalidAuthMethod = domi18n.Sentinel(domi18n.KeyInventoryInvalidAuthMethod)
	// ErrInvalidNode 表示节点或持久化提权策略字段及组合约束非法。
	ErrInvalidNode = domi18n.Sentinel(domi18n.KeyInventoryInvalidNode)
	// ErrInvalidProfile 表示复用模板 Profile 字段、选项或提权约束非法。
	ErrInvalidProfile = domi18n.Sentinel(domi18n.KeyInventoryInvalidProfile)
	// ErrInvalidSyncSource 表示同步来源元数据 SyncSource 或同步作用域 SyncScope 非法。
	ErrInvalidSyncSource = domi18n.Sentinel(domi18n.KeyInventoryInvalidSyncSource)
	// ErrInvalidAdHocRule 表示临时主机匹配规则 AdHocRule 或规则集 AdHocRuleSet 非法。
	ErrInvalidAdHocRule = domi18n.Sentinel(domi18n.KeyInventoryInvalidAdHocRule)
	// ErrInvalidGraph 表示资产配置图、引用位置或代理图规格非法。
	ErrInvalidGraph = domi18n.Sentinel(domi18n.KeyInventoryInvalidGraph)
	// ErrInvalidImportBundle 表示导入包、导入告警、同步模式或导入决策枚举值非法。
	ErrInvalidImportBundle = domi18n.Sentinel(domi18n.KeyInventoryInvalidImportBundle)
	// ErrNilWriter 表示规范二进制摘要写入目标 io.Writer 为 nil。
	ErrNilWriter = domi18n.Sentinel(domi18n.KeyInventoryNilWriter)
	// ErrNilReceiver 表示反序列化目标指针接收者为 nil。
	ErrNilReceiver = domi18n.Sentinel(domi18n.KeyInventoryNilReceiver)
)

本包与父包 core/domain/inventory 共享的规范不可变哨兵错误(父包同源重导出,保证 errors.Is 指针同一性)。

Functions

func DetectNodeIDEndpointMismatch

func DetectNodeIDEndpointMismatch(id NodeID, user option.Username, ep netaddr.Endpoint) (string, bool)

DetectNodeIDEndpointMismatch 检测 NodeID 中是否包含与当前 (user, endpoint) 不符的过期 IPv4、过期端口后缀或过期用户名前缀。

func IsBareIPLiteral

func IsBareIPLiteral(raw string) bool

IsBareIPLiteral 报告原始文本是否为裸 IPv4/IPv6 或点分纯数字/十六进制伪 IPv4 字面量(INV-ID1 唯一判定源)。

func ProfilePrivSecretRefs

func ProfilePrivSecretRefs(p Profile) []secret.Ref

ProfilePrivSecretRefs 返回 Profile 可选提权口令凭据引用切片;无效或未设置返回 nil。

Types

type AdHocRule

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

AdHocRule 表示仅对 CLI 末跳 OriginAdHoc 生效的纯数学 CIDR / 标签边界域名后缀匹配规则;零值恒无效并失败关闭。

关键安全不变量(ADR-021 R-B1 / R-B3 / R-M2):

  • 不含 AllowMCP 字段,MCP 沙箱物理不可触发;
  • 不导入 core/domain/dns,域名后缀以纯字符串 RFC 1123 规范化与标签边界校验实现;
  • CIDR 仅匹配字面 IP(严格 IPv4/IPv6 地址族隔离,绝不 Unmap),域名仅匹配输入主机名(零隐式 DNS 反查)。

func NewAdHocRule

func NewAdHocRule(spec AdHocRuleSpec) (AdHocRule, error)

NewAdHocRule 校验规则名(严禁首尾空白与控制字符)、关联 ProfileID 及非空 CIDR/域名后缀列表并构造不可变 AdHocRule。

func (AdHocRule) CIDRs

func (r AdHocRule) CIDRs() []netaddr.IPPrefix

func (AdHocRule) Domains

func (r AdHocRule) Domains() []string

func (AdHocRule) Equal

func (r AdHocRule) Equal(o AdHocRule) bool

Equal 执行值语义等价判定;任一无效恒返回 false。

func (AdHocRule) IsValid

func (r AdHocRule) IsValid() bool

func (AdHocRule) IsZero

func (r AdHocRule) IsZero() bool

func (AdHocRule) MarshalJSONTo

func (r AdHocRule) MarshalJSONTo(e *jsontext.Encoder) error

MarshalJSONTo 与 UnmarshalJSONFrom 为 AdHocRule 提供 Go 1.27 JSON/v2 严格编解码(拒绝未知字段如 allow_mcp)。

func (AdHocRule) Name

func (r AdHocRule) Name() string

func (AdHocRule) Profile

func (r AdHocRule) Profile() ProfileID

func (*AdHocRule) UnmarshalJSONFrom

func (r *AdHocRule) UnmarshalJSONFrom(d *jsontext.Decoder) error

type AdHocRuleSet

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

AdHocRuleSet 表示保留声明顺序的不可变顶层只读 adhoc_rules 规则集;零值恒无效并失败关闭(须经 EmptyAdHocRuleSet 或 NewAdHocRuleSet 构造)。

func EmptyAdHocRuleSet

func EmptyAdHocRuleSet() AdHocRuleSet

EmptyAdHocRuleSet 返回合法的空临时主机规则集。

func NewAdHocRuleSet

func NewAdHocRuleSet(rules []AdHocRule) (AdHocRuleSet, error)

NewAdHocRuleSet 校验全部规则合法性、上限与规则名唯一性,按原始声明顺序构造不可变 AdHocRuleSet(平局时先声明者胜出)。

func (AdHocRuleSet) Equal

func (s AdHocRuleSet) Equal(o AdHocRuleSet) bool

Equal 执行值语义等价判定(顺序敏感,因平局裁决依赖声明顺序);任一无效恒返回 false。

func (AdHocRuleSet) IsValid

func (s AdHocRuleSet) IsValid() bool

func (AdHocRuleSet) IsZero

func (s AdHocRuleSet) IsZero() bool

func (AdHocRuleSet) Len

func (s AdHocRuleSet) Len() int

func (AdHocRuleSet) MarshalJSONTo

func (s AdHocRuleSet) MarshalJSONTo(e *jsontext.Encoder) error

MarshalJSONTo 与 UnmarshalJSONFrom 为 AdHocRuleSet 提供 Go 1.27 JSON/v2 确定性数组编解码(零值与 null 失败关闭)。

func (AdHocRuleSet) Match

func (s AdHocRuleSet) Match(host netaddr.CanonicalHost) (AdHocRule, bool)

Match 对规范主机 host 执行 100% 纯内存确定性匹配(ADR-021 §5.3(4)):

  • host.IsIP():在所有规则 CIDR 中选择 ContainsHost(host) 为真且 Bits() 最大者(严格地址族隔离,平局取声明序首条);
  • host.IsDNS():在所有规则域名后缀中选择标签边界匹配且后缀最长者(平局取声明序首条);
  • 无效规则集、无效主机或无匹配均失败关闭返回 (AdHocRule{}, false)。

func (AdHocRuleSet) ReferencesProfile

func (s AdHocRuleSet) ReferencesProfile(id ProfileID) []string

ReferencesProfile 返回引用指定 ProfileID 的全部规则名称列表(保留声明顺序);无效规则集或无效 ID 返回 nil。

func (AdHocRuleSet) Rules

func (s AdHocRuleSet) Rules() []AdHocRule

func (*AdHocRuleSet) UnmarshalJSONFrom

func (s *AdHocRuleSet) UnmarshalJSONFrom(d *jsontext.Decoder) error

type AdHocRuleSpec

type AdHocRuleSpec struct {
	Name    string
	CIDRs   []netaddr.IPPrefix
	Domains []string
	Profile ProfileID
}

AdHocRuleSpec 是构造不可变顶层只读临时主机匹配规则 AdHocRule 的显式入参规格。 严格遵守 ADR-021 R-B3:严禁包含 AllowMCP 字段(MCP 路径物理恒禁用 AdHocRules)。

type AgentSpec

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

func ParseAgentSpec

func ParseAgentSpec(raw string) (AgentSpec, error)

func (AgentSpec) AppendText

func (a AgentSpec) AppendText(b []byte) ([]byte, error)

func (AgentSpec) Equal

func (a AgentSpec) Equal(o AgentSpec) bool

func (AgentSpec) IsValid

func (a AgentSpec) IsValid() bool

func (AgentSpec) IsZero

func (a AgentSpec) IsZero() bool

func (AgentSpec) MarshalText

func (a AgentSpec) MarshalText() ([]byte, error)

func (AgentSpec) String

func (a AgentSpec) String() string

func (*AgentSpec) UnmarshalText

func (a *AgentSpec) UnmarshalText(b []byte) error

type Alias

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

func ParseAlias

func ParseAlias(raw string) (Alias, error)

func (Alias) AppendText

func (t Alias) AppendText(b []byte) ([]byte, error)

func (Alias) Compare

func (a Alias) Compare(o Alias) int

func (Alias) Equal

func (a Alias) Equal(o Alias) bool

func (Alias) IsValid

func (t Alias) IsValid() bool

func (Alias) IsZero

func (t Alias) IsZero() bool

func (Alias) MarshalText

func (t Alias) MarshalText() ([]byte, error)

func (Alias) String

func (t Alias) String() string

func (*Alias) UnmarshalText

func (a *Alias) UnmarshalText(b []byte) error

type AssetRefLocation

type AssetRefLocation uint8

AssetRefLocation 与 SecretRefLocation 分别标识资产图引用与 6 位置凭据引用类别(零值失败关闭)。

const (
	AssetRefLocationInvalid      AssetRefLocation = iota // 无效资产引用位置(零值失败关闭)
	AssetRefNodeHost                                     // Node.HostRef -> Host
	AssetRefNodeIdentity                                 // Node.IdentityRef -> Identity
	AssetRefNodeProxyJump                                // Node.ProxyJump -> Node/Alias
	AssetRefNodeParent                                   // OriginAdHoc.ParentNode -> Node
	AssetRefGlobalProxyJump                              // 顶层全局 options.proxy -> Node/Alias
	AssetRefNodeProfile                                  // Node.Profiles -> Profile
	AssetRefProfileIdentity                              // Profile.IdentityRef -> Identity
	AssetRefProfileProxyJump                             // Profile.ProxyJump -> Node/Alias
	AssetRefGraphDefaultIdentity                         // Graph.DefaultIdentity -> Identity
	AssetRefAdHocRuleProfile                             // 顶层只读 adhoc_rules[].profile -> Profile
)

func ParseAssetRefLocation

func ParseAssetRefLocation(raw string) (AssetRefLocation, error)

ParseAssetRefLocation 与 ParseSecretRefLocation 严格解析规范小写引用位置文本。

func (AssetRefLocation) AppendText

func (l AssetRefLocation) AppendText(b []byte) ([]byte, error)

func (AssetRefLocation) IsValid

func (l AssetRefLocation) IsValid() bool

func (AssetRefLocation) IsZero

func (l AssetRefLocation) IsZero() bool

func (AssetRefLocation) MarshalText

func (l AssetRefLocation) MarshalText() ([]byte, error)

func (AssetRefLocation) String

func (l AssetRefLocation) String() string

func (*AssetRefLocation) UnmarshalText

func (l *AssetRefLocation) UnmarshalText(b []byte) error

type AssetReference

type AssetReference struct {
	Location     AssetRefLocation `json:"location"`
	FromNode     NodeID           `json:"from_node,omitzero"`
	FromProfile  ProfileID        `json:"from_profile,omitzero"`
	FromExternal string           `json:"from_external,omitzero"`
	Target       string           `json:"target"`
	ViaAlias     string           `json:"via_alias,omitzero"`
}

AssetReference、SecretReference 与 PendingSecretRef 描述资产反向引用与 6 位置凭据引用模型。

type AuthMethodKind

type AuthMethodKind uint8

AuthMethodKind 标识 SSH 认证方式判别类别;零值 AuthMethodKindInvalid 失败关闭。

const (
	AuthMethodKindInvalid             AuthMethodKind = iota // 无效认证方式(零值失败关闭)
	AuthMethodKindPassword                                  // 密码凭据引用认证
	AuthMethodKindPrivateKey                                // 私钥与可选证书/绑定口令认证
	AuthMethodKindAgent                                     // SSH Agent 认证
	AuthMethodKindKeyboardInteractive                       // RFC 4256 质询应答认证
	AuthMethodKindComposite                                 // 多因素或有序组合认证
)

func ParseAuthMethodKind

func ParseAuthMethodKind(raw string) (AuthMethodKind, error)

ParseAuthMethodKind 严格解析认证方式类别文本。

func (AuthMethodKind) AppendText

func (k AuthMethodKind) AppendText(b []byte) ([]byte, error)

func (AuthMethodKind) IsValid

func (k AuthMethodKind) IsValid() bool

func (AuthMethodKind) IsZero

func (k AuthMethodKind) IsZero() bool

func (AuthMethodKind) MarshalText

func (k AuthMethodKind) MarshalText() ([]byte, error)

func (AuthMethodKind) String

func (k AuthMethodKind) String() string

func (*AuthMethodKind) UnmarshalText

func (k *AuthMethodKind) UnmarshalText(text []byte) error

type CertPathSpec

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

func ParseCertPathSpec

func ParseCertPathSpec(raw string) (CertPathSpec, error)

func (CertPathSpec) AppendText

func (t CertPathSpec) AppendText(b []byte) ([]byte, error)

func (CertPathSpec) Compare

func (c CertPathSpec) Compare(o CertPathSpec) int

func (CertPathSpec) Equal

func (c CertPathSpec) Equal(o CertPathSpec) bool

func (CertPathSpec) IsValid

func (t CertPathSpec) IsValid() bool

func (CertPathSpec) IsZero

func (t CertPathSpec) IsZero() bool

func (CertPathSpec) MarshalText

func (t CertPathSpec) MarshalText() ([]byte, error)

func (CertPathSpec) String

func (t CertPathSpec) String() string

func (*CertPathSpec) UnmarshalText

func (c *CertPathSpec) UnmarshalText(b []byte) error

type ChallengeRuleKind

type ChallengeRuleKind uint8

ChallengeRuleKind 标识 keyboard-interactive 质询应答规则类别;零值 ChallengeRuleKindInvalid 失败关闭。

const (
	ChallengeRuleKindInvalid       ChallengeRuleKind = iota // 无效规则类别(零值失败关闭)
	ChallengeRuleKindTOTP                                   // 托管 TOTP 种子引用规则
	ChallengeRuleKindSecretRef                              // 静态机密凭据引用规则
	ChallengeRuleKindCommand                                // 外部可执行命令提供者规则
	ChallengeRuleKindLoginPassword                          // 复用身份登录密码规则
)

func ParseChallengeRuleKind

func ParseChallengeRuleKind(raw string) (ChallengeRuleKind, error)

ParseChallengeRuleKind 严格解析质询规则类别文本(totp/secret_ref/command/login_password)。

func (ChallengeRuleKind) AppendText

func (k ChallengeRuleKind) AppendText(b []byte) ([]byte, error)

func (ChallengeRuleKind) IsValid

func (k ChallengeRuleKind) IsValid() bool

func (ChallengeRuleKind) IsZero

func (k ChallengeRuleKind) IsZero() bool

func (ChallengeRuleKind) MarshalText

func (k ChallengeRuleKind) MarshalText() ([]byte, error)

func (ChallengeRuleKind) String

func (k ChallengeRuleKind) String() string

func (*ChallengeRuleKind) UnmarshalText

func (k *ChallengeRuleKind) UnmarshalText(b []byte) error

type DAGCycle

type DAGCycle struct {
	Nodes []TargetKey `json:"nodes"`
}

DAGCycle 与 DAGReport 分别表示 Tarjan SCC 检测到的强连通环路与 ProxyJump 校验报告。

type DAGReport

type DAGReport struct {
	MaxObservedDepth int         `json:"max_observed_depth"`
	TopoOrder        []TargetKey `json:"topo_order,omitzero"`
	Cycles           []DAGCycle  `json:"cycles,omitzero"`
}

DAGCycle 与 DAGReport 分别表示 Tarjan SCC 检测到的强连通环路与 ProxyJump 校验报告。

type HostID

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

HostID、IdentityID、NodeID、ProfileID、Alias、Tag、KeyPathSpec、CertPathSpec 与 AgentSpec 为强类型不透明值对象(零值失败关闭)。

func DeriveSyncedHostID

func DeriveSyncedHostID(current HostID, oldNodeID, newNodeID NodeID, oldEP, newEP netaddr.Endpoint) (HostID, bool)

DeriveSyncedHostID 在独占 HostID 精确匹配旧 NodeID 或旧端点派生模板时,返回同步后的新 HostID。

func ParseHostID

func ParseHostID(raw string) (HostID, error)

ParseHostID..ParseAgentSpec 校验并构造强类型资产标识与凭据路径规格(失败返回零值)。

func TryParseHostID

func TryParseHostID(raw string) (HostID, bool)

TryParseHostID、TryParseIdentityID、TryParseNodeID 与 TryParseProfileID 以纯布尔方式校验并构造资产标识(供无错误派生路径使用,仅留本包)。

func (HostID) AppendText

func (t HostID) AppendText(b []byte) ([]byte, error)

func (HostID) Compare

func (id HostID) Compare(o HostID) int

func (HostID) Equal

func (id HostID) Equal(o HostID) bool

强类型标识与路径规格的等价比较、全序与文本反序列化方法。

func (HostID) IsValid

func (t HostID) IsValid() bool

func (HostID) IsZero

func (t HostID) IsZero() bool

func (HostID) MarshalText

func (t HostID) MarshalText() ([]byte, error)

func (HostID) String

func (t HostID) String() string

func (*HostID) UnmarshalText

func (id *HostID) UnmarshalText(b []byte) error

type IdentityID

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

func DeriveSyncedIdentityID

func DeriveSyncedIdentityID(current IdentityID, oldNodeID, newNodeID NodeID, oldUser option.Username, oldEP netaddr.Endpoint, newUser option.Username, newEP netaddr.Endpoint) (IdentityID, bool)

DeriveSyncedIdentityID 在独占 IdentityID 精确匹配旧 NodeID 或旧 (user, endpoint) 派生模板时,返回同步后的新 IdentityID。

func ParseIdentityID

func ParseIdentityID(raw string) (IdentityID, error)

func TryParseIdentityID

func TryParseIdentityID(raw string) (IdentityID, bool)

func (IdentityID) AppendText

func (t IdentityID) AppendText(b []byte) ([]byte, error)

func (IdentityID) Compare

func (id IdentityID) Compare(o IdentityID) int

func (IdentityID) Equal

func (id IdentityID) Equal(o IdentityID) bool

func (IdentityID) IsValid

func (t IdentityID) IsValid() bool

func (IdentityID) IsZero

func (t IdentityID) IsZero() bool

func (IdentityID) MarshalText

func (t IdentityID) MarshalText() ([]byte, error)

func (IdentityID) String

func (t IdentityID) String() string

func (*IdentityID) UnmarshalText

func (id *IdentityID) UnmarshalText(b []byte) error

type ImportActionKind

type ImportActionKind uint8

ImportActionKind 标识导入预检对单条资产的分类决策;零值 ImportActionInvalid 失败关闭。

const (
	ImportActionInvalid   ImportActionKind = ImportActionKind(invgraph.ActionInvalid)   // 无效决策(零值失败关闭)
	ImportActionAdd       ImportActionKind = ImportActionKind(invgraph.ActionAdd)       // 新增资产
	ImportActionUnchanged ImportActionKind = ImportActionKind(invgraph.ActionUnchanged) // 与现有资产完全一致(幂等跳过)
	ImportActionConflict  ImportActionKind = ImportActionKind(invgraph.ActionConflict)  // 存在标识/别名/引用、人工实体、凭据保护或合并环路冲突
	ImportActionUpdate    ImportActionKind = ImportActionKind(invgraph.ActionUpdate)    // 更新已存在的同源托管资产
	ImportActionPrune     ImportActionKind = ImportActionKind(invgraph.ActionPrune)     // 两阶段安全裁剪源中已消失的同源托管资产
)

func ParseImportActionKind

func ParseImportActionKind(raw string) (ImportActionKind, error)

ParseImportActionKind 严格解析规范小写导入预检决策("add"、"unchanged"、"conflict"、"update"、"prune")。

func (ImportActionKind) AppendText

func (k ImportActionKind) AppendText(b []byte) ([]byte, error)

func (ImportActionKind) IsValid

func (k ImportActionKind) IsValid() bool

func (ImportActionKind) IsZero

func (k ImportActionKind) IsZero() bool

func (ImportActionKind) MarshalText

func (k ImportActionKind) MarshalText() ([]byte, error)

func (ImportActionKind) String

func (k ImportActionKind) String() string

func (*ImportActionKind) UnmarshalText

func (k *ImportActionKind) UnmarshalText(b []byte) error

type ImportEntry

type ImportEntry struct {
	AssetKind string           `json:"asset_kind"`
	AssetID   string           `json:"asset_id"`
	Action    ImportActionKind `json:"action"`
	Reason    string           `json:"reason,omitzero"`
}

ImportEntry 与 ImportReport 描述 PlanImport / PlanImportWithOptions 产出的不可变确定性冲突与同步分析报告。

type ImportMergePolicy

type ImportMergePolicy uint8

ImportMergePolicy 控制声明式同步更新同源实体时的格式感知合并策略;零值 ImportMergeInvalid 失败关闭。

const (
	ImportMergeInvalid            ImportMergePolicy = iota // 无效合并策略(零值失败关闭)
	ImportMergePreserveManual                              // 无条件保留人工维护字段(OpenSSH 默认策略)
	ImportMergeSyncNativeMetadata                          // 允许源覆盖原生 tags/aliases/description 列(CSV 默认策略)
)

func ParseImportMergePolicy

func ParseImportMergePolicy(raw string) (ImportMergePolicy, error)

ParseImportMergePolicy 严格解析规范小写合并策略文本("preserve_manual"、"sync_native_metadata")。

func (ImportMergePolicy) AppendText

func (p ImportMergePolicy) AppendText(b []byte) ([]byte, error)

func (ImportMergePolicy) IsValid

func (p ImportMergePolicy) IsValid() bool

func (ImportMergePolicy) IsZero

func (p ImportMergePolicy) IsZero() bool

func (ImportMergePolicy) MarshalText

func (p ImportMergePolicy) MarshalText() ([]byte, error)

func (ImportMergePolicy) String

func (p ImportMergePolicy) String() string

func (*ImportMergePolicy) UnmarshalText

func (p *ImportMergePolicy) UnmarshalText(b []byte) error

type ImportReport

type ImportReport struct {
	SourceFormat   string          `json:"source_format"`
	AddCount       int             `json:"add_count"`
	UpdateCount    int             `json:"update_count"`
	PruneCount     int             `json:"prune_count"`
	UnchangedCount int             `json:"unchanged_count"`
	ConflictCount  int             `json:"conflict_count"`
	Entries        []ImportEntry   `json:"entries,omitzero"`
	Warnings       []ImportWarning `json:"warnings,omitzero"`
}

ImportEntry 与 ImportReport 描述 PlanImport / PlanImportWithOptions 产出的不可变确定性冲突与同步分析报告。

func (ImportReport) HasChanges

func (r ImportReport) HasChanges() bool

HasChanges 报告导入合并计划是否存在任意新增、更新或裁剪变更。

func (ImportReport) HasConflicts

func (r ImportReport) HasConflicts() bool

HasConflicts 报告导入合并计划是否存在任意冲突项。

type ImportSyncMode

type ImportSyncMode uint8

ImportSyncMode 标识声明式资产导入/同步模式;零值 ImportSyncInvalid 失败关闭(R-M3)。

const (
	ImportSyncInvalid ImportSyncMode = iota // 无效同步模式(零值失败关闭)
	ImportSyncAddOnly                       // 仅新增不修改已有资产(默认只增模式)
	ImportSyncUpsert                        // 新增并更新匹配同源的托管资产(不裁剪)
	ImportSyncPrune                         // 新增、更新并两阶段安全裁剪消失的同源资产
)

func ParseImportSyncMode

func ParseImportSyncMode(raw string) (ImportSyncMode, error)

ParseImportSyncMode 严格解析规范小写同步模式文本("add_only"、"upsert"、"prune")。

func (ImportSyncMode) AppendText

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

func (ImportSyncMode) IsValid

func (m ImportSyncMode) IsValid() bool

func (ImportSyncMode) IsZero

func (m ImportSyncMode) IsZero() bool

func (ImportSyncMode) MarshalText

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

func (ImportSyncMode) String

func (m ImportSyncMode) String() string

func (*ImportSyncMode) UnmarshalText

func (m *ImportSyncMode) UnmarshalText(b []byte) error

type ImportWarning

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

ImportWarning 描述格式导入过程中产生的非致命诊断告警(已校验单行纯文本); 可选携带延迟渲染的结构化本地化消息(仅内存使用,不参与 JSON 线协议编解码与规范相等性比对)。

func NewImportWarning

func NewImportWarning(code, subject, message string) (ImportWarning, error)

NewImportWarning 校验告警码、主题与消息并构造不可变 ImportWarning。

func NewLocalizedImportWarning

func NewLocalizedImportWarning(code, subject string, msg domi18n.Message) (ImportWarning, error)

NewLocalizedImportWarning 校验告警码、主题与结构化本地化消息并构造不可变 ImportWarning, 自动以 msg.Canonical() 填充规范英文 message 字段,并保留 msg 供人类可读终端按语种渲染。

func (ImportWarning) Code

func (w ImportWarning) Code() string

func (ImportWarning) Equal

func (w ImportWarning) Equal(o ImportWarning) bool

func (ImportWarning) IsValid

func (w ImportWarning) IsValid() bool

func (ImportWarning) LocalizedMessage

func (w ImportWarning) LocalizedMessage() algebraic.Option[domi18n.Message]

LocalizedMessage 返回告警可选的延迟本地化结构化消息;零值、无效或经 JSON 反序列化后的告警返回 None。

func (ImportWarning) MarshalJSONTo

func (w ImportWarning) MarshalJSONTo(e *jsontext.Encoder) error

MarshalJSONTo 与 UnmarshalJSONFrom 为 ImportWarning 提供 Go 1.27 JSON/v2 确定性编解码(不序列化内存态 localized)。

func (ImportWarning) Message

func (w ImportWarning) Message() string

func (ImportWarning) Subject

func (w ImportWarning) Subject() string

func (*ImportWarning) UnmarshalJSONFrom

func (w *ImportWarning) UnmarshalJSONFrom(d *jsontext.Decoder) error

type KeyFingerprint

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

KeyFingerprint 表示经严格校验的 OpenSSH SHA-256 公钥指纹("SHA256:<43位无填充Base64>");零值恒无效。

func KeyFingerprintFromSHA256

func KeyFingerprintFromSHA256(sum [sha256.Size]byte) KeyFingerprint

KeyFingerprintFromSHA256 与 ParseKeyFingerprint 构造或解析规范 OpenSSH 公钥指纹。

func ParseKeyFingerprint

func ParseKeyFingerprint(raw string) (KeyFingerprint, error)

func (KeyFingerprint) AppendText

func (f KeyFingerprint) AppendText(b []byte) ([]byte, error)

func (KeyFingerprint) Equal

func (f KeyFingerprint) Equal(o KeyFingerprint) bool

func (KeyFingerprint) IsValid

func (f KeyFingerprint) IsValid() bool

func (KeyFingerprint) IsZero

func (f KeyFingerprint) IsZero() bool

func (KeyFingerprint) MarshalText

func (f KeyFingerprint) MarshalText() ([]byte, error)

func (KeyFingerprint) String

func (f KeyFingerprint) String() string

func (*KeyFingerprint) UnmarshalText

func (f *KeyFingerprint) UnmarshalText(b []byte) error

type KeyPassphraseBinding

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

KeyPassphraseBinding 在类型级结构化强制 INV-F1 / RFC §3.6 不变量:私钥口令凭据引用必绑已校验公钥指纹。

func NewKeyPassphraseBinding

func NewKeyPassphraseBinding(ref secret.Ref, fp KeyFingerprint) (KeyPassphraseBinding, error)

NewKeyPassphraseBinding 校验口令凭据引用与公钥指纹均有效后构造不可变 KeyPassphraseBinding。

func (KeyPassphraseBinding) Equal

func (KeyPassphraseBinding) IsValid

func (b KeyPassphraseBinding) IsValid() bool

func (KeyPassphraseBinding) IsZero

func (b KeyPassphraseBinding) IsZero() bool

func (KeyPassphraseBinding) KeyFingerprint

func (b KeyPassphraseBinding) KeyFingerprint() KeyFingerprint

func (KeyPassphraseBinding) MarshalJSONTo

func (b KeyPassphraseBinding) MarshalJSONTo(enc *jsontext.Encoder) error

MarshalJSONTo 与 UnmarshalJSONFrom 为 KeyPassphraseBinding 提供 Go 1.27 JSON/v2 确定性编解码(零值失败关闭)。

func (KeyPassphraseBinding) PassphraseRef

func (b KeyPassphraseBinding) PassphraseRef() secret.Ref

func (*KeyPassphraseBinding) UnmarshalJSONFrom

func (b *KeyPassphraseBinding) UnmarshalJSONFrom(dec *jsontext.Decoder) error

type KeyPathSpec

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

func ParseKeyPathSpec

func ParseKeyPathSpec(raw string) (KeyPathSpec, error)

func (KeyPathSpec) AppendText

func (t KeyPathSpec) AppendText(b []byte) ([]byte, error)

func (KeyPathSpec) Compare

func (k KeyPathSpec) Compare(o KeyPathSpec) int

func (KeyPathSpec) Equal

func (k KeyPathSpec) Equal(o KeyPathSpec) bool

func (KeyPathSpec) IsValid

func (t KeyPathSpec) IsValid() bool

func (KeyPathSpec) IsZero

func (t KeyPathSpec) IsZero() bool

func (KeyPathSpec) MarshalText

func (t KeyPathSpec) MarshalText() ([]byte, error)

func (KeyPathSpec) String

func (t KeyPathSpec) String() string

func (*KeyPathSpec) UnmarshalText

func (k *KeyPathSpec) UnmarshalText(b []byte) error

type NamespaceKind

type NamespaceKind uint8

NamespaceKind 标识代理图中的命名空间类别(ADR-021 收敛为纯托管命名空间);零值 NamespaceInvalid 失败关闭。

const (
	NamespaceInvalid NamespaceKind = NamespaceKind(invgraph.NSInvalid) // 无效命名空间(零值失败关闭)
	NamespaceManaged NamespaceKind = NamespaceKind(invgraph.NSManaged) // XOps 托管配置节点命名空间
)

func ParseNamespaceKind

func ParseNamespaceKind(raw string) (NamespaceKind, error)

ParseNamespaceKind 严格解析命名空间文本(仅 "managed")。

func (NamespaceKind) AppendText

func (k NamespaceKind) AppendText(b []byte) ([]byte, error)

func (NamespaceKind) IsValid

func (k NamespaceKind) IsValid() bool

func (NamespaceKind) IsZero

func (k NamespaceKind) IsZero() bool

func (NamespaceKind) MarshalText

func (k NamespaceKind) MarshalText() ([]byte, error)

func (NamespaceKind) String

func (k NamespaceKind) String() string

func (*NamespaceKind) UnmarshalText

func (k *NamespaceKind) UnmarshalText(text []byte) error

type NodeID

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

func DeriveNodeIDFromTemplate

func DeriveNodeIDFromTemplate(current NodeID, oldUser option.Username, oldEP netaddr.Endpoint, newUser option.Username, newEP netaddr.Endpoint) (NodeID, bool)

DeriveNodeIDFromTemplate 检测当前 NodeID 是否精确匹配旧 (user, endpoint) 派生模板, 命中时生成新候选 NodeID(即使与 current 相同也返回 true,供 TUI 表单实时预览回退);非派生语义名返回 (_, false)。

func DeriveSyncedNodeID

func DeriveSyncedNodeID(current NodeID, oldUser option.Username, oldEP netaddr.Endpoint, newUser option.Username, newEP netaddr.Endpoint) (NodeID, bool)

DeriveSyncedNodeID 在当前 NodeID 精确匹配旧 (user, endpoint) 派生模板且结果变化时,生成对应新 (user, endpoint) 的合法 NodeID; 业务语义名(如 prod-vm39)与无位置 ID(如 node-7a3c9e1b)一律返回 (_, false) 绝不误改。

func ParseNodeID

func ParseNodeID(raw string) (NodeID, error)

func TryParseNodeID

func TryParseNodeID(raw string) (NodeID, bool)

func (NodeID) AppendText

func (t NodeID) AppendText(b []byte) ([]byte, error)

func (NodeID) Compare

func (id NodeID) Compare(o NodeID) int

func (NodeID) Equal

func (id NodeID) Equal(o NodeID) bool

func (NodeID) IsValid

func (t NodeID) IsValid() bool

func (NodeID) IsZero

func (t NodeID) IsZero() bool

func (NodeID) MarshalText

func (t NodeID) MarshalText() ([]byte, error)

func (NodeID) String

func (t NodeID) String() string

func (*NodeID) UnmarshalText

func (id *NodeID) UnmarshalText(b []byte) error

type PendingSecretRef

type PendingSecretRef struct {
	OwnerID string     `json:"owner_id"`
	Ref     secret.Ref `json:"ref"`
}

AssetReference、SecretReference 与 PendingSecretRef 描述资产反向引用与 6 位置凭据引用模型。

type PrivilegePolicy

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

PrivilegePolicy 表示不可变持久化提权策略值对象(零值失败关闭,经 //xops:canonicalhash 校验全字段覆盖)。

构造期强制约束:

  • 仅 su/doas 允许配置非空 PromptPattern(须为合法 Go RE2 正则且长度 <= 256B);
  • none/sudo/auto 配置 PromptPattern 一律失败关闭;
  • method=none 与 non_interactive=true 互斥并失败关闭。

func NewPrivilegePolicy

func NewPrivilegePolicy(spec PrivilegePolicySpec) (PrivilegePolicy, error)

NewPrivilegePolicy 校验提权方式、非交互标记与可选自定义提示正则并构造不可变 PrivilegePolicy。

func (PrivilegePolicy) Equal

func (PrivilegePolicy) IsValid

func (p PrivilegePolicy) IsValid() bool

IsValid 报告 PrivilegePolicy 是否满足全部结构化不变量;零值恒返回 false。

func (PrivilegePolicy) IsZero

func (p PrivilegePolicy) IsZero() bool

func (PrivilegePolicy) MarshalJSONTo

func (p PrivilegePolicy) MarshalJSONTo(enc *jsontext.Encoder) error

MarshalJSONTo 为 PrivilegePolicy 提供值接收者 Go 1.27 JSON/v2 确定性编码;零值失败关闭。

func (PrivilegePolicy) Method

func (PrivilegePolicy) NonInteractive

func (p PrivilegePolicy) NonInteractive() bool

func (PrivilegePolicy) PromptPattern

func (p PrivilegePolicy) PromptPattern() algebraic.Option[string]

func (*PrivilegePolicy) UnmarshalJSONFrom

func (p *PrivilegePolicy) UnmarshalJSONFrom(dec *jsontext.Decoder) error

UnmarshalJSONFrom 为 PrivilegePolicy 提供严格失败关闭 JSON/v2 解码,拒绝 null、未知字段与非法策略组合。

func (PrivilegePolicy) WriteCanonical

func (p PrivilegePolicy) WriteCanonical(w io.Writer) error

WriteCanonical 以零反射、长度前缀与域分离方式写入 PrivilegePolicy 全字段规范字节流(受 digestcover 校验)。

type PrivilegePolicyKind

type PrivilegePolicyKind uint8

PrivilegePolicyKind 标识节点与 Playbook 的持久化提权策略方法;零值 PrivilegePolicyInvalid 失败关闭。

const (
	PrivilegePolicyInvalid PrivilegePolicyKind = iota // 无效提权方式(零值失败关闭)
	PrivilegePolicyNone                               // 显式关闭提权(none)
	PrivilegePolicySudo                               // POSIX sudo 提权(采用随机 -p 封套,禁止自定义提示正则)
	PrivilegePolicySu                                 // POSIX su 提权(允许可选自定义口令提示正则)
	PrivilegePolicyDoas                               // OpenBSD/Linux doas 提权(允许可选自定义口令提示正则)
	PrivilegePolicyAuto                               // 运行期自动探测可用提权工具(禁止自定义提示正则)
)

func ParsePrivilegePolicyKind

func ParsePrivilegePolicyKind(raw string) (PrivilegePolicyKind, error)

ParsePrivilegePolicyKind 严格解析规范小写提权策略文本(none/sudo/su/doas/auto)。

func (PrivilegePolicyKind) AllowsPromptPattern

func (k PrivilegePolicyKind) AllowsPromptPattern() bool

AllowsPromptPattern 报告该提权方式是否允许声明自定义口令提示正则表达式(仅 su 与 doas 允许)。

func (PrivilegePolicyKind) AppendText

func (k PrivilegePolicyKind) AppendText(b []byte) ([]byte, error)

func (PrivilegePolicyKind) IsValid

func (k PrivilegePolicyKind) IsValid() bool

func (PrivilegePolicyKind) IsZero

func (k PrivilegePolicyKind) IsZero() bool

func (PrivilegePolicyKind) MarshalText

func (k PrivilegePolicyKind) MarshalText() ([]byte, error)

func (PrivilegePolicyKind) String

func (k PrivilegePolicyKind) String() string

func (*PrivilegePolicyKind) UnmarshalText

func (k *PrivilegePolicyKind) UnmarshalText(text []byte) error

type PrivilegePolicySpec

type PrivilegePolicySpec struct {
	Method         PrivilegePolicyKind
	NonInteractive bool
	PromptPattern  algebraic.Option[string]
}

PrivilegePolicySpec 是构造不可变 PrivilegePolicy 的显式入参规格。

type Profile

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

Profile 表示可被节点有序复用或被顶层只读 adhoc_rules 引用的不可变连接配置模板;零值恒无效并失败关闭。

构造期强制约束(ADR-021 R-M1):

  • Profile 间严禁嵌套继承,从结构上物理杜绝模板环路;
  • Options 严禁设置 hostname/port/user/proxy(4 项实体独占字段);
  • 严禁配置孤立的 PrivilegePasswordRef(未声明 Privilege 时不得携带密码引用);
  • 严禁将 PrivilegePolicyNone 与 PrivilegePasswordRef.IsSome() 同设。

func NewProfile

func NewProfile(spec ProfileSpec) (Profile, error)

NewProfile 校验模板标识、可选身份引用、代理路由、选项层、执行配置、提权策略组合约束、描述与标签,构造不可变 Profile。

func (Profile) Description

func (p Profile) Description() string

func (Profile) Equal

func (p Profile) Equal(o Profile) bool

Equal 执行值语义等价判定;任一无效恒返回 false。

func (Profile) Execution

func (Profile) ID

func (p Profile) ID() ProfileID

func (Profile) IdentityRef

func (p Profile) IdentityRef() algebraic.Option[IdentityID]

func (Profile) IsValid

func (p Profile) IsValid() bool

IsValid 报告 Profile 是否经过合法构造并满足全部结构化不变量;零值恒返回 false。

func (Profile) IsZero

func (p Profile) IsZero() bool

func (Profile) MarshalJSONTo

func (p Profile) MarshalJSONTo(e *jsontext.Encoder) error

MarshalJSONTo 为 Profile 提供值接收者 Go 1.27 JSON/v2 确定性编码;零值失败关闭。

func (Profile) Options

func (p Profile) Options() option.OptionLayer

func (Profile) Privilege

func (p Profile) Privilege() algebraic.Option[PrivilegePolicy]

func (Profile) PrivilegePasswordRef

func (p Profile) PrivilegePasswordRef() algebraic.Option[secret.Ref]

func (Profile) Proxy

func (p Profile) Proxy() option.ProxyRoute

func (Profile) Tags

func (p Profile) Tags() []Tag

func (*Profile) UnmarshalJSONFrom

func (p *Profile) UnmarshalJSONFrom(d *jsontext.Decoder) error

UnmarshalJSONFrom 为 Profile 提供严格失败关闭 JSON/v2 解码,拒绝 null、未知字段与非法约束组合。

type ProfileID

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

func ParseProfileID

func ParseProfileID(raw string) (ProfileID, error)

func TryParseProfileID

func TryParseProfileID(raw string) (ProfileID, bool)

func (ProfileID) AppendText

func (t ProfileID) AppendText(b []byte) ([]byte, error)

func (ProfileID) Compare

func (id ProfileID) Compare(o ProfileID) int

func (ProfileID) Equal

func (id ProfileID) Equal(o ProfileID) bool

func (ProfileID) IsValid

func (t ProfileID) IsValid() bool

func (ProfileID) IsZero

func (t ProfileID) IsZero() bool

func (ProfileID) MarshalText

func (t ProfileID) MarshalText() ([]byte, error)

func (ProfileID) String

func (t ProfileID) String() string

func (*ProfileID) UnmarshalText

func (id *ProfileID) UnmarshalText(b []byte) error

type ProfileSpec

type ProfileSpec struct {
	ID                   ProfileID
	IdentityRef          algebraic.Option[IdentityID]
	Proxy                option.ProxyRoute
	Options              option.OptionLayer
	Execution            algebraic.Option[execution.LaunchProfile]
	Privilege            algebraic.Option[PrivilegePolicy]
	PrivilegePasswordRef algebraic.Option[secret.Ref]
	Tags                 []Tag
	Description          string
}

ProfileSpec 是构造不可变复用模板 Profile 的显式入参规格。

type SecretRefLocation

type SecretRefLocation uint8
const (
	SecretLocInvalid              SecretRefLocation = iota // 无效凭据引用位置(零值失败关闭)
	SecretLocAuthPassword                                  // 位置 1:Identity.Auth -> AuthPassword
	SecretLocPrivateKeyPassphrase                          // 位置 2:Identity.Auth -> AuthPrivateKey.PassphraseBinding
	SecretLocChallengeTOTP                                 // 位置 3:Identity.Auth -> KeyboardInteractive -> RuleTOTP
	SecretLocChallengeSecret                               // 位置 4:Identity.Auth -> KeyboardInteractive -> RuleSecretRef
	SecretLocNodePrivilege                                 // 位置 5:Node.PrivilegePasswordRef
	SecretLocProfilePrivilege                              // 位置 6:Profile.PrivilegePasswordRef(排在 NodePrivilege 之后,严守 AuthPassword..ChallengeSecret 连续区间)
	SecretLocPending                                       // 扩展位置:待确认会话 / 运行期覆盖引用
)

func ParseSecretRefLocation

func ParseSecretRefLocation(raw string) (SecretRefLocation, error)

func (SecretRefLocation) AppendText

func (l SecretRefLocation) AppendText(b []byte) ([]byte, error)

func (SecretRefLocation) IsValid

func (l SecretRefLocation) IsValid() bool

func (SecretRefLocation) IsZero

func (l SecretRefLocation) IsZero() bool

func (SecretRefLocation) MarshalText

func (l SecretRefLocation) MarshalText() ([]byte, error)

func (SecretRefLocation) String

func (l SecretRefLocation) String() string

func (*SecretRefLocation) UnmarshalText

func (l *SecretRefLocation) UnmarshalText(b []byte) error

type SecretReference

type SecretReference struct {
	Location SecretRefLocation `json:"location"`
	OwnerID  string            `json:"owner_id"`
	RuleName string            `json:"rule_name,omitzero"`
	Ref      secret.Ref        `json:"ref"`
}

AssetReference、SecretReference 与 PendingSecretRef 描述资产反向引用与 6 位置凭据引用模型。

type SyncScope

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

SyncScope 表示声明式导入同步的规范根作用域 (Format, SourceKey);零值恒无效并失败关闭。

func NewSyncScope

func NewSyncScope(format, sourceKey string) (SyncScope, error)

NewSyncScope 校验并规范化格式名与根同步作用域键,构造不可变 SyncScope。

func (SyncScope) Equal

func (s SyncScope) Equal(o SyncScope) bool

Equal 严格比对两个 SyncScope 是否均有效且 (Format, SourceKey) 完全相等。

func (SyncScope) Format

func (s SyncScope) Format() string

func (SyncScope) IsValid

func (s SyncScope) IsValid() bool

func (SyncScope) IsZero

func (s SyncScope) IsZero() bool

func (SyncScope) MarshalJSONTo

func (s SyncScope) MarshalJSONTo(e *jsontext.Encoder) error

MarshalJSONTo 与 UnmarshalJSONFrom 为 SyncScope 提供 Go 1.27 JSON/v2 严格编解码(零值失败关闭)。

func (SyncScope) Matches

func (s SyncScope) Matches(src SyncSource) bool

Matches 报告 SyncSource 是否归属当前规范根同步作用域 (Format, SourceKey)。

func (SyncScope) SourceKey

func (s SyncScope) SourceKey() string

func (*SyncScope) UnmarshalJSONFrom

func (s *SyncScope) UnmarshalJSONFrom(d *jsontext.Decoder) error

type SyncSource

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

SyncSource 表示挂载于托管资产上的纯元数据声明式同步来源(运行期零触盘,ADR-021 R-B8);零值恒无效并失败关闭。

同源身份由三元组 (Format, SourceKey, ExternalID) 唯一确定;OriginFile 仅为展示与溯源辅助字段, 变更 Include 子文件路径时不影响 SameOrigin 稳定性与 --prune 作用域判定。

func NewSyncSource

func NewSyncSource(spec SyncSourceSpec) (SyncSource, error)

NewSyncSource 校验并规范化四元组字段,构造不可变 SyncSource。

func (SyncSource) Equal

func (s SyncSource) Equal(o SyncSource) bool

Equal 严格按值比对两个 SyncSource 的全部字段(含 OriginFile);任一无效恒返回 false。

func (SyncSource) ExternalID

func (s SyncSource) ExternalID() string

func (SyncSource) Format

func (s SyncSource) Format() string

func (SyncSource) InScope

func (s SyncSource) InScope(scope SyncScope) bool

InScope 报告 SyncSource 是否归属强类型根同步作用域 scope。

func (SyncSource) IsValid

func (s SyncSource) IsValid() bool

func (SyncSource) IsZero

func (s SyncSource) IsZero() bool

func (SyncSource) MarshalJSONTo

func (s SyncSource) MarshalJSONTo(e *jsontext.Encoder) error

MarshalJSONTo 与 UnmarshalJSONFrom 为 SyncSource 提供 Go 1.27 JSON/v2 严格编解码(零值失败关闭)。

func (SyncSource) MatchesScope

func (s SyncSource) MatchesScope(format, sourceKey string) bool

MatchesScope 报告 SyncSource 是否归属给定的 (format, sourceKey) 根同步作用域(先拦截控制字符,再规范化 format 与首尾空格)。

func (SyncSource) OriginFile

func (s SyncSource) OriginFile() string

func (SyncSource) SameOrigin

func (s SyncSource) SameOrigin(o SyncSource) bool

SameOrigin 按同源三元组 (Format, SourceKey, ExternalID) 比对两个 SyncSource 是否指向同一外部实体(忽略展示字段 OriginFile)。

func (SyncSource) Scope

func (s SyncSource) Scope() SyncScope

Scope 提取当前 SyncSource 对应的规范根同步作用域 (Format, SourceKey)。

func (SyncSource) SourceKey

func (s SyncSource) SourceKey() string

func (*SyncSource) UnmarshalJSONFrom

func (s *SyncSource) UnmarshalJSONFrom(d *jsontext.Decoder) error

type SyncSourceSpec

type SyncSourceSpec struct {
	Format     string // 来源格式名(如 "openssh"、"csv")
	SourceKey  string // 规范根同步作用域键(如规范根路径或显式 --sync-source 标识)
	ExternalID string // 外部源内稳定主键标识(如 OpenSSH Host 原始别名或 CSV 行主键)
	OriginFile string // 可选展示字段:实际来源子文件路径(不参与同源身份判等)
}

SyncSourceSpec 是构造不可变同步来源元数据 SyncSource 的显式入参规格(ADR-021 R-B8)。

type Tag

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

func ParseTag

func ParseTag(raw string) (Tag, error)

func (Tag) AppendText

func (t Tag) AppendText(b []byte) ([]byte, error)

func (Tag) Compare

func (t Tag) Compare(o Tag) int

func (Tag) Equal

func (t Tag) Equal(o Tag) bool

func (Tag) IsValid

func (t Tag) IsValid() bool

func (Tag) IsZero

func (t Tag) IsZero() bool

func (Tag) MarshalText

func (t Tag) MarshalText() ([]byte, error)

func (Tag) String

func (t Tag) String() string

func (*Tag) UnmarshalText

func (t *Tag) UnmarshalText(b []byte) error

type TargetKey

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

TargetKey 是代理图中的强类型托管节点顶点键。

func NewTargetKey

func NewTargetKey(ns NamespaceKind, name string) (TargetKey, error)

NewTargetKey 校验命名空间与目标名称并构造不可变 TargetKey。

func ParseTargetKey

func ParseTargetKey(raw string) (TargetKey, error)

ParseTargetKey 解析规范文本 "managed:<name>" 为 TargetKey。

func (TargetKey) AppendText

func (k TargetKey) AppendText(b []byte) ([]byte, error)

func (TargetKey) Compare

func (k TargetKey) Compare(o TargetKey) int

func (TargetKey) Equal

func (k TargetKey) Equal(o TargetKey) bool

func (TargetKey) IsValid

func (k TargetKey) IsValid() bool

func (TargetKey) IsZero

func (k TargetKey) IsZero() bool

func (TargetKey) MarshalText

func (k TargetKey) MarshalText() ([]byte, error)

func (TargetKey) Name

func (k TargetKey) Name() string

func (TargetKey) Namespace

func (k TargetKey) Namespace() NamespaceKind

func (TargetKey) String

func (k TargetKey) String() string

func (*TargetKey) UnmarshalText

func (k *TargetKey) UnmarshalText(text []byte) error

Jump to

Keyboard shortcuts

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