Documentation
¶
Index ¶
- Constants
- func AssertCommitted(inspection Inspection, wantVersion string) error
- func AssertManifestPresent(inspection Inspection) error
- func FormatInspection(inspection Inspection) ([]byte, error)
- func RequireInspection(stateRoot, wantVersion string) error
- type Action
- type Engine
- type Inspection
- type OptionalString
- type Phase
- type Request
- type Result
- type Store
- func (store *Store) Complete(transaction Transaction, state updateengine.State, result Result) (Result, error)
- func (store *Store) CurrentResultPath() string
- func (store *Store) LockPath() string
- func (store *Store) ReadAuthoritativeResult() (Result, error)
- func (store *Store) ReadCurrentResult() (Result, error)
- func (store *Store) ReadResult(transactionID string) (Result, error)
- func (store *Store) ReadTransaction() (Transaction, error)
- func (store *Store) ResultPath(transactionID string) string
- func (store *Store) Root() string
- func (store *Store) TransactionPath() string
- func (store *Store) WriteResult(result Result) error
- func (store *Store) WriteTransaction(transaction Transaction) error
- type Transaction
Constants ¶
View Source
const ( // FailureRollbackFailed 是 Engine journal Restore 失败,下一次 install 可以重试 Restore。 FailureRollbackFailed = "rollback_failed" // FailureExternalRollbackFailed 是 OS adapter(Task/Registry/PowerShell 等)回滚失败。 // Engine journal 没有能力修好外部状态,禁止只凭 Restore 成功就放行下一次 install。 FailureExternalRollbackFailed = "external_rollback_failed" FailureTrialInterrupted = "trial-interrupted" FailureUninstallFailed = "uninstall_failed" FailureAbandoned = "abandoned" )
View Source
const SchemaVersion = 1
Variables ¶
This section is empty.
Functions ¶
func AssertCommitted ¶
func AssertCommitted(inspection Inspection, wantVersion string) error
func AssertManifestPresent ¶
func AssertManifestPresent(inspection Inspection) error
func FormatInspection ¶
func FormatInspection(inspection Inspection) ([]byte, error)
func RequireInspection ¶
Types ¶
type Action ¶
type Action string
const ( ActionInstall Action = "install" ActionRepair Action = "repair" ActionUninstall Action = "uninstall" // ActionCommit 把 defer-commit 留下的 trial 写成 committed。 // 只有 OS adapter 确认外部状态已落地之后才能调用;Engine 自己不再抢先 commit。 ActionCommit Action = "commit" // ActionAbandon 只改权威事务状态,不代替真实文件/注册表/服务回滚。 // 调用方必须先完成外部 rollback:成功后写 rolled_back。 // rollback 自身失败则带 RollbackFailed 写 failed/external_rollback_failed, // 这会阻断下一次自动 install;修复 OS adapter 状态后再 abandon 一次(不要带 --rollback-failed)才是恢复入口。 ActionAbandon Action = "abandon" )
type Inspection ¶
type Inspection struct {
StateRoot string `json:"state_root"`
HasTransaction bool `json:"has_transaction"`
HasResult bool `json:"has_result"`
State string `json:"state,omitempty"`
TransactionID string `json:"transaction_id,omitempty"`
Action string `json:"action,omitempty"`
Version string `json:"version,omitempty"`
ActiveVersion string `json:"active_version,omitempty"`
LocalMCPURL string `json:"local_mcp_url,omitempty"`
PublicURL string `json:"public_url,omitempty"`
Healthy bool `json:"healthy"`
ManifestPath string `json:"manifest_path,omitempty"`
HasUnixManifest bool `json:"has_unix_manifest"`
HasWinManifest bool `json:"has_windows_manifest"`
// Windows generation pointer 与 self-update 事务的权威评估。
// Setup/卸载脚本必须消费这些结构化结论,不得自行解析 active-version.json
// 或 update/transaction.json 再解释状态。pointer 缺失时是 missing,
// 存在但读不出来/结构非法时是 invalid,其余透传 pointer 内的 state。
PointerState string `json:"pointer_state,omitempty"`
PointerActiveVersion string `json:"pointer_active_version,omitempty"`
PointerFallbackVersion string `json:"pointer_fallback_version,omitempty"`
PendingUpdateTransaction bool `json:"pending_update_transaction"`
}
Inspection 是 E2E 和脚本共用的安装结果校验视图。 断言逻辑留在 Go 里,Shell/PowerShell 只负责安排环境后调用 inspect。
func Inspect ¶
func Inspect(stateRoot string) (Inspection, error)
type OptionalString ¶
OptionalString 把“未指定”和“空值”分开。 未指定:保留已有凭据,缺失且首次开启公网认证时才生成。 已指定:必须使用该值,空字符串非法。
func Specified ¶
func Specified(value string) OptionalString
type Phase ¶
type Phase string
const ( PhasePrepare Phase = "prepare" PhaseVerify Phase = "verify" PhaseStage Phase = "stage" PhaseActivate Phase = "activate" PhaseStart Phase = "start" PhaseHealth Phase = "health" PhaseSkills Phase = "skills" PhaseTunnel Phase = "tunnel" PhaseCommit Phase = "commit" PhaseRollback Phase = "rollback" )
type Request ¶
type Request struct {
Action Action
InstallRoot string
RuntimeRoot string
RuntimeRootLiteral string
PayloadDir string
BinaryPath string
LiveBinary string
SkillBundle string
Version string
Channel string
Host string
Port int
LogLevel string
TunnelMode string
ServerURL string
TunnelToken string
TunnelTokenFile string
CloudflaredPath string
ServiceName string
ServiceUser string
ServiceGroup string
ServiceManager string
DataDir string
SystemdDir string
OpenRCDir string
LaunchAgentsDir string
AuthToken OptionalString
OAuthPassword OptionalString
OAuthTokenSecret OptionalString
RotateOAuth bool
RegisterService bool
StartService bool
NonInteractive bool
PurgeConfig bool
PurgeData bool
PrivilegeMode string
AgentDockHome string
AgentDockDefaultDir string
TaskName string
StartupValueName string
TrayStartupValueName string
CloudflaredStartupValueName string
SkipHealth bool
SkipSkills bool
SkipServiceUser bool
NoPrivilege bool
// DeferCommit 让 install/repair 在 verify 完成后停在 trial。
// Windows 脚本还要写 HKCU/Task/tray;那些完成之前不能出现 committed。
DeferCommit bool
// MarkHealthy 只给外层 OS adapter 的 commit 使用:adapter 已经完成自己的 health-check,
// Engine 不重复探测,只把这个已验证事实投影到权威 Result。
MarkHealthy bool
// RollbackFailed 只给 abandon 用:外部 rollback 没做完,禁止宣称 rolled_back。
RollbackFailed bool
// TransactionID 绑定 commit/abandon 到明确的 install 事务,不能拿上一笔 result.json 冒充成功。
TransactionID string
}
type Result ¶
type Result struct {
SchemaVersion int `json:"schema_version"`
TransactionID string `json:"transaction_id"`
Platform string `json:"platform"`
Action Action `json:"action"`
State updateengine.State `json:"state"`
Phase Phase `json:"phase"`
Version string `json:"version"`
ActiveVersion string `json:"active_version,omitempty"`
FallbackVersion string `json:"fallback_version,omitempty"`
LocalMCPURL string `json:"local_mcp_url,omitempty"`
PublicURL string `json:"public_url,omitempty"`
Healthy bool `json:"healthy"`
PrivilegeMode string `json:"privilege_mode,omitempty"`
// TaskName 只在 uninstall Result 里返回:engine 解析后的计划任务名是 Windows
// adapter 删除任务的单一来源,脚本不得再自行解析 runtime.json 重复判定。
TaskName string `json:"task_name,omitempty"`
Failure *updateengine.Failure `json:"failure,omitempty"`
Warnings []string `json:"warnings,omitempty"`
StartedAt time.Time `json:"started_at"`
CompletedAt time.Time `json:"completed_at"`
}
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) Complete ¶
func (store *Store) Complete(transaction Transaction, state updateengine.State, result Result) (Result, error)
func (*Store) CurrentResultPath ¶
func (*Store) ReadAuthoritativeResult ¶
ReadAuthoritativeResult 返回当前权威事务对应的结果。terminal transaction 是 durable commit point; 即使进程死在 transaction.json 与 result projection 两次原子写之间,读取也必须收敛到终态。
func (*Store) ReadCurrentResult ¶
func (*Store) ReadTransaction ¶
func (store *Store) ReadTransaction() (Transaction, error)
func (*Store) ResultPath ¶
func (*Store) TransactionPath ¶
func (*Store) WriteResult ¶
func (*Store) WriteTransaction ¶
func (store *Store) WriteTransaction(transaction Transaction) error
type Transaction ¶
type Transaction struct {
SchemaVersion int `json:"schema_version"`
TransactionID string `json:"transaction_id"`
Platform string `json:"platform"`
Action Action `json:"action"`
SourceVersion string `json:"source_version,omitempty"`
TargetVersion string `json:"target_version"`
ActiveVersion string `json:"active_version,omitempty"`
FallbackVersion string `json:"fallback_version,omitempty"`
State updateengine.State `json:"state"`
Phase Phase `json:"phase"`
InstallRoot string `json:"install_root"`
RuntimeRoot string `json:"runtime_root"`
// PurgeConfig / PurgeData 是 uninstall 的事务意图。trial 重入必须逐项匹配,
// 否则同一 transaction 会在第二次请求下执行比首次承诺更强或更弱的清理。
PurgeConfig bool `json:"purge_config,omitempty"`
PurgeData bool `json:"purge_data,omitempty"`
ServiceUser string `json:"service_user,omitempty"`
AgentDockHome string `json:"agentdock_home,omitempty"`
AgentDockDefaultDir string `json:"agentdock_default_dir,omitempty"`
StartedAt time.Time `json:"started_at"`
UpdatedAt time.Time `json:"updated_at"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
Failure *updateengine.Failure `json:"failure,omitempty"`
Warnings []string `json:"warnings,omitempty"`
}
Click to show internal directories.
Click to hide internal directories.