| 1 | package claude |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "amadan.net/oficina/equipo/internal/runner/provider" |
| 7 | ) |
| 8 | |
| 9 | // The coordinator's launch accepts exactly its tool set: every tool the |
| 10 | // conversation offers (add_report since slice 4c) builds a policy, and |
| 11 | // one it does not offer is refused. The launcher's own list once lagged |
| 12 | // the action's, and every coordinator start failed policy_rejected. |
| 13 | func TestConversePolicyCoversEveryTool(t *testing.T) { |
| 14 | profile, err := provider.Profile("converse") |
| 15 | if err != nil { |
| 16 | t.Fatal(err) |
| 17 | } |
| 18 | b := provider.Binding{Provider: "claude", CredentialHome: "/private/account", Home: "/private/run", RuntimeRoot: "/private/runtime"} |
| 19 | in := provider.PolicyInputs{Action: "converse", Tools: profile.MCPTools()} |
| 20 | if _, err := PolicyInputs(b, in, profile.Specialist, "model"); err != nil { |
| 21 | t.Fatalf("converse tools %v: %v", profile.MCPTools(), err) |
| 22 | } |
| 23 | in.Tools = append(profile.MCPTools(), "mcp__equipo__merge_now") |
| 24 | if _, err := PolicyInputs(b, in, profile.Specialist, "model"); err == nil { |
| 25 | t.Fatal("a tool the conversation does not offer was accepted") |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | func TestAccessLegacyPolicy(t *testing.T) { |
| 30 | p, _ := provider.Profile("converse") |
| 31 | tools := p.MCPTools()[1:] |
| 32 | b := provider.Binding{Provider: "claude", CredentialHome: "/private/account", Home: "/private/run", RuntimeRoot: "/private/runtime"} |
| 33 | if _, err := PolicyInputs(b, provider.PolicyInputs{Action: "converse", Tools: tools}, p.Specialist, "model"); err != nil { |
| 34 | t.Fatal("legacy tool set refused", err) |
| 35 | } |
| 36 | tools = append(tools, "mcp__equipo__merge_now") |
| 37 | if _, err := PolicyInputs(b, provider.PolicyInputs{Action: "converse", Tools: tools}, p.Specialist, "model"); err == nil { |
| 38 | t.Fatal("unexpected extra tool allowed") |
| 39 | } |
| 40 | } |
| 41 | |