oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package codex
2
3import (
4 "encoding/json"
5 "slices"
6 "strings"
7 "testing"
8
9 "amadan.net/oficina/equipo/internal/runner/provider"
10)
11
12// TestThinActionPolicies: the thin runner's coordinator (converse), Review
13// (inspect) and ask-the-implementer (answer) profiles render a Codex
14// policy, and the deny profile holds for each: network off, credential
15// and runner paths denied, the workspace read-only, the coordinator with
16// no shell, no patch and exactly its Equipo tools enabled.
17func TestThinActionPolicies(t *testing.T) {
18 b := provider.Binding{Provider: "codex", CredentialHome: "/private/account", Home: "/private/run", RuntimeRoot: "/private/runtime"}
19 for _, action := range []string{"converse", "inspect", "answer"} {
20 t.Run(action, func(t *testing.T) {
21 profile, _ := provider.Profile(action)
22 in := provider.PolicyInputs{Action: action, Tools: profile.MCPTools(), DeniedPaths: []string{"/private/state"}}
23 got, err := PolicyInputs(b, in, "gpt-6-astra")
24 if err != nil {
25 t.Fatalf("%s refused: %v", action, err)
26 }
27 var settings map[string]any
28 if json.Unmarshal(got.Settings, &settings) != nil {
29 t.Fatal("invalid settings")
30 }
31 perm := settings["permissions"].(map[string]any)["equipo"].(map[string]any)
32 fs := perm["filesystem"].(map[string]any)
33 if fs["/workspace"] != "read" {
34 t.Fatalf("%s: workspace %v", action, fs["/workspace"])
35 }
36 for _, denied := range []string{"/private/account", "/private/run", "/private/state", "/home/runner", "/tool", "/egress", "/config", "/proc"} {
37 if fs[denied] != "deny" {
38 t.Fatalf("%s: %s not denied", action, denied)
39 }
40 }
41 if perm["network"].(map[string]any)["enabled"] != false {
42 t.Fatalf("%s: network on", action)
43 }
44 features := settings["features"].(map[string]any)
45 for _, off := range []string{"apps", "multi_agent", "remote_control", "memories", "plugins", "code_mode"} {
46 if features[off] != false {
47 t.Fatalf("%s: feature %s not off", action, off)
48 }
49 }
50 server := settings["mcp_servers"].(map[string]any)["equipo"].(map[string]any)
51 if action == "converse" {
52 for _, off := range []string{"shell_tool", "unified_exec", "apply_patch_freeform", "web_search", "js_repl", "view_image"} {
53 if features[off] != false {
54 t.Fatalf("coordinator feature %s not off", off)
55 }
56 }
57 var enabled []string
58 raw, _ := json.Marshal(server["enabled_tools"])
59 json.Unmarshal(raw, &enabled)
60 if !slices.Equal(enabled, provider.ConverseTools()) {
61 t.Fatalf("coordinator tools %v", enabled)
62 }
63 if !strings.Contains(string(got.Catalog), `"shell_type":"disabled"`) || !strings.Contains(string(got.Catalog), `"apply_patch_tool_type":null`) {
64 t.Fatalf("coordinator catalog %s", got.Catalog)
65 }
66 }
67 // The inventory is exactly the profile's: one more tool, or one
68 // from another profile, is refused.
69 for _, extra := range []string{"mcp__equipo__submit_candidate", "mcp__equipo__start_task", "mcp__equipo__git_show"} {
70 more := in
71 more.Tools = append(append([]string{}, in.Tools...), extra)
72 if _, err := PolicyInputs(b, more, "gpt-6-astra"); err == nil {
73 t.Fatalf("%s accepted %s", action, extra)
74 }
75 }
76 })
77 }
78}
79