package codex import ( "encoding/json" "os" "strings" "testing" "amadan.net/oficina/equipo/internal/runner/provider" ) func TestCodexRuntimeSettings(t *testing.T) { for _, action := range []string{"implement", "coordinate"} { t.Run(action, func(t *testing.T) { f := fixtureFor(t) in := f.inputs in.Action = action profile, _ := provider.Profile(action) in.Tools = profile.MCPTools() in, err := PolicyInputs(f.lease.Binding(), in, f.launch.Selection.Model) if err != nil { t.Fatal(err) } if !configSubset([]byte(`{"skills":{"bundled":{"enabled":false}},"features":{"memories":false,"goals":false,"plugins":false,"remote_plugin":false,"tool_suggest":false}}`), in.Settings) { t.Fatal("skills or memories not disabled") } if !strings.Contains(strings.Join(in.Argv, " "), `skills={"bundled"={"enabled"=false}}`) { t.Fatal("skills missing from argv") } p, err := provider.BuildPolicy(f.lease.Binding(), in) if err != nil { t.Fatal(err) } for _, key := range []string{"skills", "memories", "goals", "plugins", "remote_plugin", "tool_suggest"} { t.Run(key, func(t *testing.T) { var got map[string]any json.Unmarshal(in.Settings, &got) if key == "skills" { got[key].(map[string]any)["bundled"].(map[string]any)["enabled"] = true } else { got["features"].(map[string]any)[key] = true } readback := marshal(map[string]any{"config": got, "origins": map[string]any{}, "layers": []any{map[string]any{"name": map[string]any{"type": "sessionFlags"}, "version": "fixture", "config": json.RawMessage(in.Settings)}}}) if validateConfig(readback, p) == nil { t.Fatal("enabled capability accepted") } }) } }) } } func TestCodexRecordedDisabledRuntime(t *testing.T) { raw, err := os.ReadFile("testdata/disabled-skills-0.165.0.json") if err != nil { t.Fatal(err) } var frames []struct { ID int Result json.RawMessage } if err = json.Unmarshal(raw, &frames); err != nil { t.Fatal(err) } if len(frames) != 4 { t.Fatal("incomplete recording") } if !configSubset([]byte(`{"account":null,"requiresOpenaiAuth":true}`), frames[1].Result) { t.Fatal("recording is not unauthenticated") } if !configSubset([]byte(`{"config":{"skills":{"bundled":{"enabled":false}},"features":{"memories":false}}}`), frames[2].Result) { t.Fatal("disabled config not recorded") } if !sameJSON(frames[3].Result, []byte(`{"data":[{"cwd":"/workspace","skills":[],"errors":[]}]}`)) { t.Fatal("skills exposed") } }