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
This commit is contained in:
sam committed 2026-09-27 05:09:24 +10:00
1 parent 69ba1f19bc
commit 8d6c3e3c99
2 files changed
+30 -1

No files matched your search

@@ -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)
}
}
+1 -1
View File
@@ -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) {