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
46 lines
1.9 KiB
Go
46 lines
1.9 KiB
Go
package settings
|
|
|
|
import (
|
|
core "agent-system-core"
|
|
"testing"
|
|
)
|
|
|
|
func TestPluginSettingScopesAndReservedModelNamespace(t *testing.T) {
|
|
s := NewService(nil)
|
|
s.SetExtraSchema([]core.SettingDesc{
|
|
{Key: "plugins.example.shared", Type: core.SettingString, Scope: ProjectSettingScope},
|
|
{Key: "plugins.example.personal", Type: core.SettingString},
|
|
{Key: "plugins.example.system", Type: core.SettingString, Scope: core.SettingScopeSystem},
|
|
{Key: "models.custom.apiKey", Type: core.SettingSecret},
|
|
{Key: "models.chat.model", Type: core.SettingString},
|
|
})
|
|
if err := s.ValidateWrite(map[string]any{"plugins.example.shared": "team"}, ProjectSettingScope); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, scope := range []core.SettingScope{UserSettingScope, PersonalProjectScope} {
|
|
if err := s.ValidateWrite(map[string]any{"plugins.example.shared": "team"}, scope); err == nil {
|
|
t.Fatal("shared plugin accepted personal override")
|
|
}
|
|
if err := s.ValidateWrite(map[string]any{"plugins.example.personal": "mine"}, scope); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := s.ValidateWrite(map[string]any{"models.custom.apiKey": "personal"}, scope); err == nil {
|
|
t.Fatal("plugin opened the reserved managed model namespace")
|
|
}
|
|
if err := s.ValidateWrite(map[string]any{"models.chat.model": "personal"}, scope); err == nil {
|
|
t.Fatal("plugin replaced builtin authority")
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestPluginCannotPublishPrivateRuntimePolicySetting(t *testing.T) {
|
|
s := NewService(nil)
|
|
s.SetExtraSchema([]core.SettingDesc{{Key: "_policy.managedModels", Type: core.SettingBool, Scope: core.SettingScopeSystem}})
|
|
if err := s.ValidateWrite(map[string]any{"_policy.managedModels": false}, core.SettingScopeSystem); err == nil {
|
|
t.Fatal("private runtime policy became editable through plugin descriptor")
|
|
}
|
|
if err := s.validateUnset(map[string]any{}, []string{"_policy.managedModels"}, core.SettingScopeSystem); err == nil {
|
|
t.Fatal("private runtime policy accepted unset")
|
|
}
|
|
}
|