oficina / equipo Public

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

Plain git — no account needed to clone.

Download

Download this file

1package provider
2
3import (
4 "encoding/json"
5 "slices"
6 "testing"
7)
8
9// The Research step's launch profile (spec §4): its own action and
10// specialist, exactly the research-v1 tools, and nothing of the legacy
11// "research" action (which reads a workspace with native tools).
12func TestResearchStepProfile(t *testing.T) {
13 p, err := Profile(ResearchStepAction)
14 if err != nil {
15 t.Fatal(err)
16 }
17 if ResearchStepAction != "research_step" || p.Specialist != ResearchSpecialist || p.Specialist == "Research" || p.Render || p.ReadOnly {
18 t.Fatalf("profile %+v", p)
19 }
20 if got := p.Tools(); !slices.Equal(got, []string{"submit_findings", "keep_image"}) {
21 t.Fatalf("tools %v", got)
22 }
23 if got := p.MCPTools(); !slices.Equal(got, []string{"mcp__equipo__submit_findings", "mcp__equipo__keep_image"}) {
24 t.Fatalf("MCP tools %v", got)
25 }
26 legacy, err := Profile("research")
27 if err != nil || legacy.Specialist != "Research" || !slices.Equal(legacy.Tools(), []string{"submit_answer", "ask_person"}) {
28 t.Fatalf("legacy research changed: %+v %v", legacy, err)
29 }
30 if !ResearchAction(ResearchStepAction) || ResearchAction("research") || CoordinatorAction(ResearchStepAction) {
31 t.Fatal("research action predicates")
32 }
33}
34
35func manifestPolicy(action string) Policy {
36 raw, _ := json.Marshal(map[string]any{"Action": action})
37 return Policy{Manifest: raw, ManifestHash: ManifestDigest(raw)}
38}
39
40// Policy.Research and Policy.ResearchReader read the manifest's action,
41// integrity-checked as Converse and Coordinator are: a manifest that
42// does not match its hash is neither.
43func TestPolicyResearchPredicates(t *testing.T) {
44 for _, c := range []struct {
45 action string
46 research, reader bool
47 }{
48 {ResearchStepAction, true, false},
49 {"implement", false, true},
50 {"inspect", false, true},
51 {"research", false, false},
52 {"converse", false, false},
53 {"coordinate", false, false},
54 {"answer", false, false},
55 {"", false, false},
56 } {
57 p := manifestPolicy(c.action)
58 if p.Research() != c.research || p.ResearchReader() != c.reader {
59 t.Fatalf("%q: research=%v reader=%v", c.action, p.Research(), p.ResearchReader())
60 }
61 if c.action == ResearchStepAction && (p.Coordinator() || p.Converse()) {
62 t.Fatal("research step is not a coordinator")
63 }
64 tampered := p
65 tampered.ManifestHash = ManifestDigest([]byte(`{}`))
66 if tampered.Research() || tampered.ResearchReader() {
67 t.Fatalf("%q: tampered manifest trusted", c.action)
68 }
69 }
70}
71
72// BuildPolicy pins a Research launch's native tools as it does the
73// coordinator's: none beyond what the provider registers for MCP.
74func TestResearchStepNativeToolsPinned(t *testing.T) {
75 b, in := policyFixture(t)
76 in.Action = ResearchStepAction
77 profile, _ := Profile(in.Action)
78 in.Tools = profile.MCPTools()
79 if _, err := BuildPolicy(b, in); err == nil {
80 t.Fatal("research launch without its pinned native tools accepted")
81 }
82 in.NativeTools = CoordinatorNativeTools("codex")
83 if _, err := BuildPolicy(b, in); err != nil {
84 t.Fatalf("pinned research native tools refused: %v", err)
85 }
86 in.NativeTools = append(in.NativeTools, "shell")
87 if _, err := BuildPolicy(b, in); err == nil {
88 t.Fatal("research launch with a shell accepted")
89 }
90}
91