package codex import ( "amadan.net/oficina/equipo/internal/runner/provider" "encoding/json" "os" "testing" ) func TestSpecialistCatalogAuthority(t *testing.T) { for _, mutation := range []string{"bytes", "code_mode", "collaboration", "template", "question"} { t.Run(mutation, func(t *testing.T) { f := fixtureFor(t) in := f.inputs in.Action = "implement" profile, _ := provider.Profile(in.Action) in.Tools = profile.MCPTools() in, err := PolicyInputs(f.lease.Binding(), in, "gpt-6-astra") if err != nil { t.Fatal(err) } if mutation == "question" { var settings map[string]any _ = json.Unmarshal(in.Settings, &settings) settings["tools"].(map[string]any)["experimental_request_user_input"] = map[string]any{"enabled": true} in.Settings = marshal(settings) } else if mutation != "bytes" { var catalog struct{ Models []map[string]any } if json.Unmarshal(in.Catalog, &catalog) != nil { t.Fatal("catalog") } switch mutation { case "code_mode": catalog.Models[0]["tool_mode"] = "code_mode_only" case "collaboration": catalog.Models[0]["multi_agent_version"] = "v2" case "template": catalog.Models[0]["model_messages"] = map[string]string{"instructions_template": "changed"} } in.Catalog = marshal(catalog) } p, err := provider.BuildPolicy(f.lease.Binding(), in) if err != nil { t.Fatal(err) } if mutation == "bytes" { if _, err = f.l.validatePolicy(f.lease.Binding(), p); err != nil { t.Fatal(err) } for _, mount := range p.Mounts { if mount.Target == provider.CoordinatorCatalogPath { if err = os.WriteFile(mount.Source, []byte(`{"models":[]}`), 0600); err != nil { t.Fatal(err) } } } if p.ValidateSources(f.lease.Binding()) == nil { t.Fatal("changed mounted bytes accepted") } } else if _, err = f.l.validatePolicy(f.lease.Binding(), p); err == nil { t.Fatal("changed constructor catalog accepted") } }) } }