Files
Agent-System-Backend/internal/runtime/managed_model_test.go
T
weichen f965c5877f Enforce settings ownership and versioned shared configuration
Why: Personal project rows and credentials could override system policy and split shared business configuration by actor.

Evidence: SELF receipts /tmp/project-settings-backend-full-20261014-973d52c1.json and /tmp/rdm-settings-backend-final-green-20261014-03.json preserve full commands, object snapshots and output. PostgreSQL and current-head CI remain NOT_RUN.

Impact: Add scope-aware APIs, a fail-closed optional project configuration authorizer, CAS updates and explicit atomic migration. Preserve legacy rows and private preferences; protected secrets and runtime model routes obey system ownership.

Refs: P1/P2/P8, docs/records/2026-10-14-rdm-settings-completion-contract.md
2026-10-14 02:28:41 +00:00

34 lines
1.2 KiB
Go

package runtime
import (
"path/filepath"
"testing"
"agent-system-backend/internal/settings"
"agent-system-backend/internal/store"
core "agent-system-core"
)
func TestManagedModelsIgnorePersistedProfileRoutes(t *testing.T) {
st, err := store.OpenSQLite(filepath.Join(t.TempDir(), "models.db"))
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() { st.Close() })
svc := settings.NewService(st)
if err := svc.MergeSystem(map[string]any{"models": map[string]any{
"chat": map[string]any{"model": "system-chat", "baseUrl": "https://system.example", "apiKey": "system-key"},
"lightweight": map[string]any{"model": "system-lite", "baseUrl": "https://lite.example", "apiKey": "lite-key"},
}}); err != nil {
t.Fatal(err)
}
prof := core.AgentProfile{Owner: "alice", Model: core.ModelRoute{Chat: "old-personal-chat", Lightweight: "old-personal-lite"}}
eff := svc.Effective("alice", "project")
if got := ResolveChatModel(prof, eff); got.Model != "system-chat" || got.Key != "system-key" {
t.Fatalf("personal chat route still effective: %+v", got)
}
if got := ResolveLightweightModel(prof, eff); got.Model != "system-lite" || got.Key != "lite-key" {
t.Fatalf("personal lightweight route still effective: %+v", got)
}
}