From 79fbd0b1337bfabf3db87fa63e4b16f1036b04b5 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Sun, 27 Sep 2026 05:09:17 +1000 Subject: [PATCH] fix(archied): republish the config snapshot when live settings apply applyWorkflowExecutionSettings swapped the running config with cfgHolder.Set, so the dashboard's published projection kept the previous budgets until the next reload. Route it through publishConfig like every other config change. Fixes #1148 --- internal/app/archied/config_snapshot_test.go | 29 ++++++++++++++++++++ internal/app/archied/control_plane.go | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/internal/app/archied/config_snapshot_test.go b/internal/app/archied/config_snapshot_test.go index f08bf34d7..bc088f2af 100644 --- a/internal/app/archied/config_snapshot_test.go +++ b/internal/app/archied/config_snapshot_test.go @@ -5,8 +5,10 @@ import ( "encoding/json" "log/slog" "testing" + "time" "github.com/samcharles93/archie-core/internal/config" + "github.com/samcharles93/archie-core/internal/domain/workflow" "github.com/samcharles93/archie-core/internal/infrastructure/configuration" "github.com/samcharles93/archie-core/internal/infrastructure/postgres/pgstore" "github.com/samcharles93/archie-core/internal/webui" @@ -136,3 +138,30 @@ func TestPublishConfigSnapshotWithoutConfiguration(t *testing.T) { t.Fatalf("ConfigSnapshot = (found %v, %v), want nothing published", found, err) } } + +// TestLiveSettingsApplyRepublishesTheConfigSnapshot: the dashboard renders the +// published projection, not the daemon's Holder, so a live apply that changes +// the running config must republish it or the page keeps showing the old +// values until the next reload. +func TestLiveSettingsApplyRepublishesTheConfigSnapshot(t *testing.T) { + st := pgstore.Open(t) + t.Cleanup(func() { _ = st.Close() }) + + b, _ := newLiveApplyBoot(t, fileConfig()) + b.stateStore = st + if err := b.applyWorkflowExecutionSettings(t.Context(), workflow.ExecutionSettings{MaxModelToolSteps: 25, MaxRuntime: time.Hour, MaxConsecutiveGateFailures: 4}, 2); err != nil { + t.Fatalf("live update: %v", err) + } + + snapshot, found, err := st.ConfigSnapshot(context.Background()) + if err != nil || !found { + t.Fatalf("ConfigSnapshot = (found %v, %v), want the live apply to publish one", found, err) + } + var view webui.ConfigView + if err := json.Unmarshal(snapshot.Document, &view); err != nil { + t.Fatalf("decode published document: %v", err) + } + if view.Budgets.MaxSteps != 25 || view.Budgets.GateMaxFailures != 4 { + t.Errorf("published budgets = %+v, want the live-applied limits", view.Budgets) + } +} diff --git a/internal/app/archied/control_plane.go b/internal/app/archied/control_plane.go index d182664d1..eab460c99 100644 --- a/internal/app/archied/control_plane.go +++ b/internal/app/archied/control_plane.go @@ -216,7 +216,7 @@ func (b *boot) applyWorkflowExecutionSettings(ctx context.Context, settings work return err } b.executionSettings.Store(&candidate.settings) - b.cfgHolder.Set(candidate.cfg) + b.publishConfig(ctx, candidate.cfg) b.applyStatus.Report(ctx, controlplane.WorkflowExecutionSettingsKind, version, nil) b.log.Info("workflow execution settings applied", "version", version) if limit, uptime := settings.MaxTaskRuntime, candidate.cfg.Containers.MaxUptime.Std(); uptime > 0 && (limit <= 0 || limit > uptime) {