Files
HomeAgent/cmd/homed/guard_windows.go
root bc9ef15eb0 三层回退恢复机制(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 单元测试全过
2026-08-05 16:00:08 +08:00

33 lines
1.2 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//go:build !linux
// L0/L1/L2 三层回退恢复机制为 Linux 专属(依赖 /etc 网络基线、overlayfs、
// syscall.Reboot、unix socket IPC、systemctl。在 Windows 等非 Linux 平台
// 本文件提供 no-op 桩guard/failback 角色不执行恢复,其余主 agent 功能照常。
package main
import (
"log"
"os"
agentAPI "gitcode.com/JianFeeeee/HomeAgent/internal/agent/api"
internalConfig "gitcode.com/JianFeeeee/HomeAgent/internal/config"
luaVM "gitcode.com/JianFeeeee/HomeAgent/internal/lua"
)
// runGuard 桩guard 父守护模式仅支持 Linux其余平台打印提示并退出。
func runGuard(dataDir string) {
log.Printf("[guard] guard mode is Linux-only (data=%s), exiting", dataDir)
os.Exit(0)
}
// runFailbackRecovery 桩failback 恢复为 Linux 专属,其余平台直接退出。
func runFailbackRecovery(dataDir string, cfgReg *internalConfig.ConfigRegistry, lua *luaVM.VM, providerMgr *agentAPI.ProviderManager, baseAPIKey string) {
log.Printf("[failback] recovery is Linux-only (data=%s), exiting", dataDir)
os.Exit(exitRecoveryFailed)
}
// lastDiagSummary 桩:无 recovery_result 时返回空自诊断。
func lastDiagSummary(dataDir string) string {
return ""
}