| 1 | package codex |
| 2 | |
| 3 | import ( |
| 4 | "amadan.net/oficina/equipo/internal/runner/provider" |
| 5 | "encoding/json" |
| 6 | "testing" |
| 7 | ) |
| 8 | |
| 9 | func TestSpecialistObservableToolCatalog(t *testing.T) { |
| 10 | for _, action := range []string{"implement", "review"} { |
| 11 | f := fixtureFor(t) |
| 12 | in := f.inputs |
| 13 | in.Action = action |
| 14 | p, _ := provider.Profile(action) |
| 15 | in.Tools = p.MCPTools() |
| 16 | in, err := PolicyInputs(f.lease.Binding(), in, "gpt-6-astra") |
| 17 | if err != nil { |
| 18 | t.Fatal(err) |
| 19 | } |
| 20 | var settings map[string]any |
| 21 | json.Unmarshal(in.Settings, &settings) |
| 22 | if len(in.Catalog) == 0 { |
| 23 | t.Error("model metadata still overrides disabled features") |
| 24 | } |
| 25 | var catalog struct{ Models []map[string]any } |
| 26 | if json.Unmarshal(in.Catalog, &catalog) != nil || len(catalog.Models) != 1 { |
| 27 | t.Error("missing pinned specialist catalog") |
| 28 | } else { |
| 29 | m := catalog.Models[0] |
| 30 | if m["tool_mode"] != nil || m["multi_agent_version"] != nil || m["shell_type"] != "shell_command" || m["apply_patch_tool_type"] != "freeform" { |
| 31 | t.Error("wrong specialist catalog", m) |
| 32 | } |
| 33 | } |
| 34 | if !sameJSON(marshal(settings["tools"]), []byte(`{"experimental_request_user_input":{"enabled":false}}`)) { |
| 35 | t.Error("specialist question tool not disabled") |
| 36 | } |
| 37 | features := settings["features"].(map[string]any) |
| 38 | for _, key := range []string{"code_mode", "code_mode_only", "code_mode_host", "multi_agent_v2", "multi_agent_mode", "multi_agent_v2_dynamic_tools", "image_generation", "imagegenext", "default_mode_request_user_input"} { |
| 39 | if features[key] != false { |
| 40 | t.Errorf("%s not disabled: %v", key, features[key]) |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | func TestExplicitUntrustedWorkspace(t *testing.T) { |
| 47 | f := fixtureFor(t) |
| 48 | var settings map[string]json.RawMessage |
| 49 | if json.Unmarshal(f.inputs.Settings, &settings) != nil { |
| 50 | t.Fatal("settings") |
| 51 | } |
| 52 | if !sameJSON(settings["projects"], []byte(`{"/workspace":{"trust_level":"untrusted"}}`)) { |
| 53 | t.Fatal("workspace trust left to provider persistence") |
| 54 | } |
| 55 | } |
| 56 | |