| 1 | package provider |
| 2 | |
| 3 | import ( |
| 4 | "errors" |
| 5 | "reflect" |
| 6 | "slices" |
| 7 | "testing" |
| 8 | |
| 9 | "amadan.net/oficina/equipo/internal/specialist" |
| 10 | ) |
| 11 | |
| 12 | // TestDesignActionProfile: the Design step's action profile (design-v1's |
| 13 | // Policy.Action) has exactly render_page, submit_candidate and |
| 14 | // ask_person, design-v1's tools in its order, and never the old |
| 15 | // submit_render; it is the Design role's, writes its workspace, and is |
| 16 | // the only action that may read /render. |
| 17 | func TestDesignActionProfile(t *testing.T) { |
| 18 | menu, ok := specialist.Lookup(specialist.ProfileDesign) |
| 19 | if !ok || menu.Policy.Action != DesignStepAction { |
| 20 | t.Fatalf("design-v1's action is %q, the runner's %q", menu.Policy.Action, DesignStepAction) |
| 21 | } |
| 22 | p, err := Profile(DesignStepAction) |
| 23 | if err != nil { |
| 24 | t.Fatal(err) |
| 25 | } |
| 26 | want := ActionProfile{Action: "design_step", Specialist: "Design", Submission: "submit_candidate"} |
| 27 | if p != want { |
| 28 | t.Fatalf("profile %+v, want %+v", p, want) |
| 29 | } |
| 30 | if got := p.Tools(); !slices.Equal(got, []string{"render_page", "submit_candidate", "ask_person"}) || !slices.Equal(got, menu.Tools) { |
| 31 | t.Fatalf("tools %v, design-v1 %v", got, menu.Tools) |
| 32 | } |
| 33 | if got := p.MCPTools(); !slices.Equal(got, []string{"mcp__equipo__render_page", "mcp__equipo__submit_candidate", "mcp__equipo__ask_person"}) { |
| 34 | t.Fatalf("MCP tools %v", got) |
| 35 | } |
| 36 | if !p.AcceptsTools(DesignMCPTools()) { |
| 37 | t.Fatal("its own tools refused") |
| 38 | } |
| 39 | for name, tools := range map[string][]string{ |
| 40 | "the old submit_render": append(p.MCPTools(), "mcp__equipo__submit_render"), |
| 41 | "no render_page": {"mcp__equipo__submit_candidate", "mcp__equipo__ask_person"}, |
| 42 | "Engineering's": {"mcp__equipo__submit_candidate", "mcp__equipo__ask_person", "mcp__equipo__submit_render"}, |
| 43 | "research's": {"mcp__equipo__submit_findings", "mcp__equipo__keep_image"}, |
| 44 | "none": {}, |
| 45 | } { |
| 46 | if p.AcceptsTools(tools) { |
| 47 | t.Errorf("%s accepted", name) |
| 48 | } |
| 49 | } |
| 50 | // Only the Design step reads /render; nothing else, Engineering |
| 51 | // above all, and not the plan workflow's legacy design action. |
| 52 | for _, action := range []string{"implement", "design", "copy", "inspect", "review", "answer", "converse", "assist", "coordinate", ResearchStepAction, GlanceAction, ""} { |
| 53 | if RenderReaderAction(action) { |
| 54 | t.Errorf("%q reads /render", action) |
| 55 | } |
| 56 | } |
| 57 | if !RenderReaderAction(DesignStepAction) || !DesignAction(DesignStepAction) || DesignAction("design") || ResearchReaderAction(DesignStepAction) { |
| 58 | t.Fatal("the design step's reads") |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | // TestEngineeringActionUnchanged: Engineering's action profile and tool |
| 63 | // list, as they were before Design (byte for byte), and the plan |
| 64 | // workflow's legacy design action left as it was. |
| 65 | func TestEngineeringActionUnchanged(t *testing.T) { |
| 66 | for action, want := range map[string]struct { |
| 67 | profile ActionProfile |
| 68 | tools []string |
| 69 | }{ |
| 70 | "implement": {ActionProfile{Action: "implement", Specialist: "Engineering", Submission: "submit_candidate", Render: true}, []string{"submit_candidate", "ask_person", "submit_render"}}, |
| 71 | "design": {ActionProfile{Action: "design", Specialist: "Design", Submission: "submit_candidate", Render: true}, []string{"submit_candidate", "ask_person", "submit_render"}}, |
| 72 | } { |
| 73 | p, err := Profile(action) |
| 74 | if err != nil || p != want.profile || !reflect.DeepEqual(p.Tools(), want.tools) { |
| 75 | t.Fatalf("%s: %+v %v %v", action, p, p.Tools(), err) |
| 76 | } |
| 77 | } |
| 78 | if _, err := Profile("design-v1"); !errors.Is(err, ErrPolicy) { |
| 79 | t.Fatal("a profile id is not an action") |
| 80 | } |
| 81 | } |
| 82 | |