oficina / equipo Public

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

Plain git — no account needed to clone.

Download

Download this file

1package coordinator
2
3import (
4 "encoding/json"
5 "reflect"
6 "testing"
7)
8
9func TestCoordinatorToolAllowlist(t *testing.T) {
10 want := []string{"equipo_status", "read_project", "read_task", "propose_project", "propose_plan", "ask_person", "route_to_task", "post_message", "suggest_preference", "suggest_specialist", "suggest_playbook"}
11 if !reflect.DeepEqual(Names(), want) {
12 t.Fatal("unexpected tool inventory", Names())
13 }
14 for _, name := range []string{"shell", "Bash", "Read", "Glob", "Grep", "exec_command", "read_file", "web", "fetch", "create_specialist", "create_playbook", "publish", "approve_plan", "select_account", "settle", "submit_answer"} {
15 if _, err := Validate(CoordinatorToolCall{RequestID: "r", Name: name, Arguments: json.RawMessage(`{}`)}); err == nil {
16 t.Fatalf("unauthorized tool %s", name)
17 }
18 }
19 for _, raw := range []string{`{"project_id":1,"person":"other"}`, `{"project_id":1,"project_id":2}`, `{"project_id":0}`, `null`, `{"project_id":1} trailing`} {
20 if _, err := Validate(CoordinatorToolCall{RequestID: "r", Name: "read_project", Arguments: json.RawMessage(raw)}); err == nil {
21 t.Fatalf("schema accepted %s", raw)
22 }
23 }
24 if _, err := Validate(CoordinatorToolCall{RequestID: "r", Name: "read_project", Arguments: json.RawMessage(`{"project_id":1}`)}); err != nil {
25 t.Fatal(err)
26 }
27 if _, err := Validate(CoordinatorToolCall{RequestID: "", Name: "read_project", Arguments: json.RawMessage(`{"project_id":1}`)}); err == nil {
28 t.Fatal("missing request ID accepted")
29 }
30 for _, s := range Schemas(nil) {
31 if s["inputSchema"].(map[string]any)["additionalProperties"] != false {
32 t.Fatal("open schema")
33 }
34 }
35}
36
37func TestCoordinatorToolStrictFields(t *testing.T) {
38 for _, raw := range []string{`{"Body":"hi","source_refs":[]}`, `{"body":"hi"}`, `{"body":"hi","source_refs":null}`} {
39 if _, err := Validate(CoordinatorToolCall{RequestID: "r", Name: "post_message", Arguments: json.RawMessage(raw)}); err == nil {
40 t.Fatal("strict schema accepted", raw)
41 }
42 }
43}
44
45func TestProposeProjectSchema(t *testing.T) {
46 for _, raw := range []string{`{"repository":"amadan.net/oficina/new-app","why":"Fix this app."}`, `{"repository":"amadan.net/oficina/new-app","why":"Fix this app.","person":"other"}`} {
47 _, err := Validate(CoordinatorToolCall{RequestID: "project", Name: "propose_project", Arguments: json.RawMessage(raw)})
48 if (err == nil) != (raw == `{"repository":"amadan.net/oficina/new-app","why":"Fix this app."}`) {
49 t.Fatal("wrong project schema result", err)
50 }
51 }
52}
53