* Introduce project_personas table with foreign keys to projects and agent_personas * Add project_skills table with foreign key to projects and agent_skills * Include override boolean field in agent_persona_skills and project_skills * Update schema and migration files to reflect new tables and fields * Enhance CORS handling to reflect request origin
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package tools
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
ext "git.warky.dev/wdevs/amcs/internal/types"
|
||||
)
|
||||
|
||||
func TestMergeWorldModelSkills(t *testing.T) {
|
||||
project := []ext.AgentSkill{
|
||||
{ID: 1, Name: "go", Content: "project", Tags: []string{}},
|
||||
{ID: 2, Name: "postgres", Content: "database", Tags: []string{}},
|
||||
}
|
||||
persona := &ext.PersonaFull{Skills: []ext.PersonaSkillEntry{
|
||||
{ID: 1, Name: "go", Content: "ignored additive duplicate", Tags: []string{}},
|
||||
{ID: 3, Name: "Postgres", Content: "persona override", Tags: []string{}, Override: true},
|
||||
{ID: 4, Name: "writing", Content: "additive", Tags: []string{}},
|
||||
}}
|
||||
|
||||
got := mergeWorldModelSkills(project, persona)
|
||||
if len(got) != 3 {
|
||||
t.Fatalf("len(skills) = %d, want 3", len(got))
|
||||
}
|
||||
if got[0].Content != "project" || got[0].Source != "project" {
|
||||
t.Fatalf("additive duplicate replaced project skill: %#v", got[0])
|
||||
}
|
||||
if got[1].Content != "persona override" || got[1].Source != "persona" || !got[1].Override {
|
||||
t.Fatalf("override did not replace project skill: %#v", got[1])
|
||||
}
|
||||
if got[2].Name != "writing" || got[2].Source != "persona" {
|
||||
t.Fatalf("new additive persona skill missing: %#v", got[2])
|
||||
}
|
||||
}
|
||||
|
||||
func TestMergeWorldModelGuardrailsKeepsStrictest(t *testing.T) {
|
||||
project := []ext.AgentGuardrail{{ID: 1, Name: "safe", Severity: "high", Content: "project"}}
|
||||
persona := &ext.PersonaFull{Guardrails: []ext.PersonaGuardrailEntry{
|
||||
{ID: 2, Name: "Safe", Severity: "low", Content: "weaker"},
|
||||
{ID: 3, Name: "privacy", Severity: "critical", Content: "new"},
|
||||
}}
|
||||
|
||||
got := mergeWorldModelGuardrails(project, persona)
|
||||
if len(got) != 2 {
|
||||
t.Fatalf("len(guardrails) = %d, want 2", len(got))
|
||||
}
|
||||
if got[0].Severity != "high" || got[0].Content != "project" {
|
||||
t.Fatalf("persona weakened project guardrail: %#v", got[0])
|
||||
}
|
||||
if got[1].Name != "privacy" || got[1].Severity != "critical" {
|
||||
t.Fatalf("new persona guardrail missing: %#v", got[1])
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user