Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

fix(endpoint): keep updater reconciliation aligned with mode

shukieshahf4a61b9fb21b
diff --git a/cli/beacon/cmd/endpoint_update_service.go b/cli/beacon/cmd/endpoint_update_service.go
index 5a935b3b..76ba5cf8 100644
--- a/cli/beacon/cmd/endpoint_update_service.go
+++ b/cli/beacon/cmd/endpoint_update_service.go
@@ -228,6 +228,20 @@ func runScheduledUpdate(parent context.Context) error {
return nil
}
sleepJitter()
+ mode = selfupdate.ResolveMode(configAutoUpdateMode())
+ if mode == selfupdate.ModeOff {
+ current := version.GetVersion()
+ res := selfupdate.CheckResult{Mode: mode}
+ _ = selfupdate.EmitCheckEvent(selfupdate.CheckEventOptions{
+ Result: res,
+ Action: selfupdate.EventUnsupported,
+ Reason: "mode_off_after_jitter",
+ LogPath: endpointSystemLogPath(),
+ AgentVersion: current,
+ })
+ fmt.Println("Update checks were disabled during jitter; nothing to do.")
+ return nil
+ }
current := version.GetVersion()
if mode == selfupdate.ModeAuto {
diff --git a/cli/beacon/internal/endpoint/lifecycle/lifecycle.go b/cli/beacon/internal/endpoint/lifecycle/lifecycle.go
index 3690f19d..c162c5e4 100644
--- a/cli/beacon/internal/endpoint/lifecycle/lifecycle.go
+++ b/cli/beacon/internal/endpoint/lifecycle/lifecycle.go
@@ -295,10 +295,9 @@ func Repair(opts InstallOptions) (InstallResult, error) {
}
func reconcileUpdaterFromConfig(logPath string) error {
- cfg := loadOrDefault(false, logPath)
localMode := ""
- if cfg.AutoUpdate != nil {
- localMode = cfg.AutoUpdate.Mode
+ if mode, err := autoUpdateModeFromConfigFile(endpointconfig.ConfigPath(false)); err == nil {
+ localMode = mode
}
mode := selfupdate.ResolveMode(localMode)
mgr := service.UpdaterManager{}
@@ -313,6 +312,23 @@ func reconcileUpdaterFromConfig(logPath string) error {
return mgr.Load()
}
+func autoUpdateModeFromConfigFile(path string) (string, error) {
+ data, err := os.ReadFile(path)
+ if err != nil {
+ return "", err
+ }
+ var partial struct {
+ AutoUpdate *endpointconfig.AutoUpdate `json:"auto_update"`
+ }
+ if err := json.Unmarshal(data, &partial); err != nil {
+ return "", err
+ }
+ if partial.AutoUpdate == nil {
+ return "", nil
+ }
+ return partial.AutoUpdate.Mode, nil
+}
+
func GetStatus(userMode bool, logPath string) Status {
cfg := loadOrDefault(userMode, logPath)
runtimeLog := ResolveRuntimeLog(userMode, logPath)
diff --git a/cli/beacon/internal/endpoint/lifecycle/lifecycle_test.go b/cli/beacon/internal/endpoint/lifecycle/lifecycle_test.go
index d62b9c77..fc4371f6 100644
--- a/cli/beacon/internal/endpoint/lifecycle/lifecycle_test.go
+++ b/cli/beacon/internal/endpoint/lifecycle/lifecycle_test.go
@@ -299,6 +299,27 @@ func TestWriteReadManifestRoundTrip(t *testing.T) {
}
}
+func TestAutoUpdateModeFromConfigFileIgnoresDestinationValidation(t *testing.T) {
+ path := filepath.Join(t.TempDir(), "config.json")
+ if err := os.WriteFile(path, []byte(`{
+ "user_mode": false,
+ "log_path": "/var/log/beacon-agent/runtime.jsonl",
+ "collector": {"grpc_port":4317,"http_port":4318},
+ "harnesses": ["claude"],
+ "destinations": {"splunk_hec": {"endpoint": "https://splunk.example"}},
+ "auto_update": {"mode": "auto"}
+}`), 0o600); err != nil {
+ t.Fatal(err)
+ }
+ mode, err := autoUpdateModeFromConfigFile(path)
+ if err != nil {
+ t.Fatalf("autoUpdateModeFromConfigFile: %v", err)
+ }
+ if mode != "auto" {
+ t.Fatalf("mode = %q, want auto", mode)
+ }
+}
+
func TestDiscoverAndRestoreBackups(t *testing.T) {
dir := t.TempDir()
target := filepath.Join(dir, "settings.json")