mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-09-21 01:18:08 +00:00
三层回退恢复机制(L0写前留档/L1恢复梯子/L2离线回滚)+ guard 父守护
- L0: files 插件写受保护系统路径(/etc 等)前自动留档,AbstractBeforeWrite 到 data/file_baseline - L1: failback 受限 worker 执行恢复梯子 probe→还原DNS/proxy→还原LLM配置+ReloadFromConfig→probe,N轮有界 - L2: tracker changeset 持久化原文 blob,guard 离线 RollbackFromDisk 回滚 agentfs;SystemSnapshot 支撑 - guard 父守护: 心跳 IPC(PING/ACK unix socket, 文件心跳回退)、失败计数、退出码协议(42/43/44)、最后手段 - 发行版路径适配: system.protected_paths/network_paths 可注入,默认面向主流 Linux - Windows 兼容: guard.go/failback.go 加 //go:build linux, guard_windows.go 提供 no-op 桩 - 修复: guard.yaml last_resort 键冲突、changeset Content 不落盘导致离线回滚丢原文 Build 全绿, vet 干净, system/recovery/ipc/tracker 单元测试全过
This commit is contained in:
@ -26,46 +26,47 @@ type AgentID string
|
||||
type SnapshotID string
|
||||
|
||||
type Snapshot struct {
|
||||
ID SnapshotID `json:"id"`
|
||||
AgentID AgentID `json:"agent_id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Reason string `json:"reason"`
|
||||
Size int64 `json:"size_bytes"`
|
||||
DockerImage string `json:"docker_image,omitempty"`
|
||||
Valid bool `json:"valid"`
|
||||
ID SnapshotID `json:"id"`
|
||||
AgentID AgentID `json:"agent_id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Reason string `json:"reason"`
|
||||
Size int64 `json:"size_bytes"`
|
||||
DockerImage string `json:"docker_image,omitempty"`
|
||||
Valid bool `json:"valid"`
|
||||
}
|
||||
|
||||
type Heartbeat struct {
|
||||
AgentID AgentID `json:"agent_id"`
|
||||
Timestamp time.Time `json:"timestamp"`
|
||||
State AgentState `json:"state"`
|
||||
Health HealthStatus `json:"health"`
|
||||
AgentID AgentID `json:"agent_id"`
|
||||
Timestamp time.Time `json:"timestamp"`
|
||||
State AgentState `json:"state"`
|
||||
Health HealthStatus `json:"health"`
|
||||
Uptime time.Duration `json:"uptime"`
|
||||
LLMConnected bool `json:"llm_connected"`
|
||||
Error string `json:"error,omitempty"`
|
||||
LLMConnected bool `json:"llm_connected"`
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
type NetworkCheckResult struct {
|
||||
LLMAPIReachable bool `json:"llm_api_reachable"`
|
||||
DNSResolving bool `json:"dns_resolving"`
|
||||
TCPReachable bool `json:"tcp_reachable"`
|
||||
Latency time.Duration `json:"latency_ms"`
|
||||
LatencyDegraded bool `json:"latency_degraded"`
|
||||
Error string `json:"error,omitempty"`
|
||||
LLMAPIReachable bool `json:"llm_api_reachable"`
|
||||
EndpointsConfigured bool `json:"endpoints_configured"`
|
||||
DNSResolving bool `json:"dns_resolving"`
|
||||
TCPReachable bool `json:"tcp_reachable"`
|
||||
Latency time.Duration `json:"latency_ms"`
|
||||
LatencyDegraded bool `json:"latency_degraded"`
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
type SnapshotPolicy struct {
|
||||
Interval time.Duration `json:"interval"`
|
||||
MaxSnapshots int `json:"max_snapshots"`
|
||||
PreAction bool `json:"pre_action"`
|
||||
PostAction bool `json:"post_action"`
|
||||
Interval time.Duration `json:"interval"`
|
||||
MaxSnapshots int `json:"max_snapshots"`
|
||||
PreAction bool `json:"pre_action"`
|
||||
PostAction bool `json:"post_action"`
|
||||
}
|
||||
|
||||
type RollbackPolicy struct {
|
||||
MaxRetries int `json:"max_retries"`
|
||||
HealthThreshold HealthStatus `json:"health_threshold"`
|
||||
CooldownPeriod time.Duration `json:"cooldown_period"`
|
||||
AutoRollback bool `json:"auto_rollback"`
|
||||
MaxRetries int `json:"max_retries"`
|
||||
HealthThreshold HealthStatus `json:"health_threshold"`
|
||||
CooldownPeriod time.Duration `json:"cooldown_period"`
|
||||
AutoRollback bool `json:"auto_rollback"`
|
||||
}
|
||||
|
||||
type AgentConfig struct {
|
||||
@ -87,12 +88,12 @@ type ResourceLimit struct {
|
||||
}
|
||||
|
||||
type OperationLog struct {
|
||||
ID string `json:"id"`
|
||||
AgentID AgentID `json:"agent_id"`
|
||||
Timestamp time.Time `json:"timestamp"`
|
||||
Action string `json:"action"`
|
||||
ID string `json:"id"`
|
||||
AgentID AgentID `json:"agent_id"`
|
||||
Timestamp time.Time `json:"timestamp"`
|
||||
Action string `json:"action"`
|
||||
SnapshotID SnapshotID `json:"snapshot_id,omitempty"`
|
||||
Success bool `json:"success"`
|
||||
Success bool `json:"success"`
|
||||
}
|
||||
|
||||
type LLMSource struct {
|
||||
|
||||
Reference in New Issue
Block a user