oficina / equipo Public

feat: add the scoped coordinator tool server

Bind structured tools to the current coordinator claim, persist replayable effects and clarification answers, and isolate provider inventories from task tools. Keep changed policy inventories uncertified.
codex agent, operated by paul@keymail.dev pushed by claude agent, operated by paul@keymail.dev 4d07586d499426229608bc4a2c166fd96bb90b2d parent f5c5c16
47 files changed, +2,422 −96
  • .rastrillo/budgets.txt +2 −2
  • docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md +246 −0
  • internal/coordinator/budget_test.go +9 −0
  • internal/coordinator/tools.go +136 −0
  • internal/coordinator/tools_test.go +43 −0
  • internal/coordinator/types.go +72 −0
  • internal/directlive/coordinator.go +83 −0
  • internal/directlive/driver.go +8 −2
  • internal/directlive/driver_test.go +25 −2
  • internal/directlive/testdata/fake-cli.py +2 −1
  • internal/directlive/turn.go +6 −0
  • internal/equipo/conversation/coordinator_api.go +24 −0
  • internal/equipo/conversation/coordinator_engine.go +2 −1
  • internal/equipo/conversation/coordinator_events.go +13 −4
  • internal/equipo/conversation/coordinator_execution.go +2 −2
  • internal/equipo/conversation/store.go +19 −0
  • internal/equipo/conversation/tool_delivery.go +54 −0
  • internal/equipo/conversation/tools.go +396 −0
  • internal/equipo/coordinator.go +20 −7
  • internal/equipo/coordinator_api.go +0 −7
  • internal/equipo/coordinator_execution.go +2 −21
  • internal/equipo/copy.go +26 −0
  • internal/equipo/planning/plans.go +25 −4
  • internal/plan3test/coordinator_tools_test.go +246 −0
  • internal/release/manifest.json +2 −2
  • internal/runner/capture.go +1 −1
  • internal/runner/containment/mounts.go +3 −1
  • internal/runner/containment/mounts_test.go +49 −0
  • internal/runner/coordinator_tool_journal.go +134 −0
  • internal/runner/coordinator_tool_proxy.go +267 −0
  • internal/runner/coordinator_tools_test.go +248 −0
  • internal/runner/direct_fixes_test.go +1 −1
  • internal/runner/direct_recovery_test.go +2 −2
  • internal/runner/journal.go +7 −1
  • internal/runner/journal_test.go +1 −1
  • internal/runner/provider/actions.go +8 −1
  • internal/runner/provider/claude/launcher.go +7 −2
  • internal/runner/provider/codex/coordinator.go +27 −0
  • internal/runner/provider/codex/launcher.go +10 −3
  • internal/runner/provider/codex/plan_policy_test.go +40 −0
  • internal/runner/provider/policy.go +38 −2
  • internal/runner/tool_proxy.go +41 −9
  • internal/runner/tool_socket.go +9 −8
  • internal/runner/tools.go +14 −1
  • internal/runnerproto/coordinator.go +44 −7
  • internal/runnerproto/coordinator_handler.go +6 −0
  • internal/runnerproto/handler.go +2 −1

CI failed — run details

diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt
index 6efd9e8f..f163f727 100644
--- a/.rastrillo/budgets.txt
+++ b/.rastrillo/budgets.txt
@@ -14,14 +14,14 @@ perf GET /* skip Unknown private paths render 404; this fallback contains no scr
time internal/equipo/team 45s Final fix package rerun measured 29.461s (prior CI 28.271s); 45s gives 52 percent headroom for core migration, recovery and concurrency coverage.
time internal/equipotest 300s Final fix package rerun measured 187.035s (review 172.4s); 300s gives 60 percent headroom for HTTP, sandbox, authority and final regression coverage.
-size internal/equipo 10800 - Task 5 keeps the existing ceiling by extracting coordinator operations into conversation and runner HTTP mechanics into runnerproto. Measured 10781 source and 437 test lines; roster, database and execution wiring remain here.
+size internal/equipo 10800 - Task 6 keeps the existing ceiling by moving project listing into conversation and consolidating coordinator facades. Measured 10800 source and 437 test lines; roster, database, copy and execution wiring remain here.
size internal/equipotest - 13000 Final finding regressions stay beside the mandated integration fixtures; current test count: 11667.
time internal/runner/checks 60s CI worker measured 44.553s (44.6s rounded); 60s gives 34 percent headroom. Shared baseline capture reduces repeated Go runs; retain the CI allowance for sandbox sentinels, timeout and child cleanup.
time internal/runner 330s Final corrected package rerun measured 152.897s; review worst 220.6s, interrupted CI 245.239s. 330s exceeds even the interrupted run by 34 percent. Injected-clock lease test measured 8.416s instead of about 65s.
perf GET /live skip Authorized notification stream, bounded to 30 seconds; not a GET screen.
perf GET /api/runner/v2/artifacts/{assignment}/{artifact} skip Authenticated runner artifact download, not a browser GET screen. Runner long-poll and blob downloads use POST and are outside the screen inventory.
-size internal/runner 8000 - Task 4 retains direct journal, proxy, attestation and supervisor hooks in runner; pure step contracts live in planflow. Measured 7627 source and 6592 test lines. Tests remain under the default size ceiling.
+size internal/runner 8500 - Task 6 retains the separate coordinator broker and additive durable submission journal beside direct launch and task tools. Measured 8080 source and 6840 test lines; schemas and instance operations live in coordinator and conversation. Targeted tests stay below the existing time ceiling.
time internal/runner/provider/claude 45s Task 5 measured 32.430s for fake CLI sessions and fsynced account, policy, capture and refresh checks; 45s gives 38 percent headroom on the shared runner.
time internal/runner/provider/codex 15s Task 11a full branch gate measured 11.659s (prior attempt 11.464s) for schema, native approval and fsynced capture fixtures; 15s gives 29 percent headroom under shared-runner load.
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
index 469dc71d..3583e40e 100644
--- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
@@ -721,3 +721,249 @@ New user-facing string keys/text: none. The specific connection error reuses the
Self-review checked that old uncertainty is neither requeued nor refunded, containment remains required across generations, receipt settlement occurs once, query failures roll back all poll writes, and audit failures roll back their turn changes. Delivery validators must still be local and bounded. A disagreement about known versus unknown usage is rejected without changing the settled receipt. Other review findings not dispatched for this round remain outside scope; Task 6 owns the Claude tool inventory.
No full suite, make ci, provider calls, sign-ins, enrolment, agents, servers, handoff file, push, merge or deployment. Go caches stayed at their defaults. Mutation scratch was created under `$TMPDIR` and removed after its output was copied into these reports. Commit subject: `fix: unblock coordinator after reset and settle delivery once`; author: `codex <codex~paul@keymail.dev>`.
+
+
+## Task 6
+
+Structured coordinator tools implemented on `plan-3`. Full report: `.superpowers/sdd/2026-11-04-equipo-plan-3-coordinator/task-6-report.md`. No push or live run. Both new policy inventories are uncertified.
+
+### Commands and results
+
+`CGO_ENABLED=0 go test ./internal/coordinator ./internal/runner ./internal/plan3test -run '^TestCoordinator(Tool|Project|Suggestion)' -count=1`
+
+PASS, exit 0. coordinator 0.002s; runner 0.554s; plan3test 2.305s.
+
+`CGO_ENABLED=0 go test ./internal/runner/provider/claude ./internal/runner/provider/codex ./internal/runner/provider ./internal/runner/containment ./internal/release -run '^(TestCoordinatorTool|TestPlanWorkflow(ProviderPolicies|Release)|TestClaudePermissionResponse|TestCodexApprovalResponse|TestEffectivePolicy)' -count=1`
+
+PASS, exit 0. Claude 4.438s; Codex 6.715s; provider 4.598s; containment 0.007s; release 0.004s.
+
+`CGO_ENABLED=0 go test ./internal/runner -run '^(TestCoordinatorToolJournalUpgrade|TestDirectJournal|TestRunnerJournalDurabilityConfiguration|TestCodexApprovalResponseBroker|TestCodexApprovalResponseIdempotency|TestPlanWorkflowProviderPoliciesBroker)' -count=1`
+
+PASS, exit 0, 5.672s. Includes the additive journal upgrades and the existing task broker.
+
+`CGO_ENABLED=0 go test ./internal/directlive -run '^TestCoordinatorToolAllowlistFakeCLI$' -count=1`
+
+PASS, exit 0, 5.715s. Both pinned launcher adapters use disposable fake CLI fixtures and the actual coordinator MCP endpoint.
+
+`CGO_ENABLED=0 go test ./internal/directlive -run '^TestDirectDriverFakeCLI$' -count=1`
+
+PASS, exit 0, 202.240s. All 19 fixture cases passed. Coordinator cases check the empty native inventory and structured question; specialist cases retain their native-tool tests. No live certification was produced.
+
+`CGO_ENABLED=0 go test ./internal/runner ./internal/runner/provider/claude ./internal/runner/provider/codex ./internal/runner/provider ./internal/plan3test -run '^(TestCoordinator|TestCodexApprovalResponse|TestClaudePermissionResponse|TestDirectJournal|TestRunnerJournalDurabilityConfiguration|TestEffectivePolicy|TestPrivateHomeConfigOutsideWritableMounts|TestPlanWorkflowProviderPoliciesBroker|TestConversation|TestPlanProjection)' -count=1`
+
+PASS, exit 0. runner 11.871s; Claude 1.915s; Codex 5.373s; provider 5.039s; plan3test 16.692s. This regression run preceded the final source-reference and card-attribution additions, which passed the final named command.
+
+`CGO_ENABLED=0 go vet ./internal/coordinator ./internal/equipo ./internal/equipo/conversation ./internal/equipo/planning ./internal/runner ./internal/runner/provider ./internal/runner/provider/claude ./internal/runner/provider/codex ./internal/runner/containment ./internal/runnerproto ./internal/directlive ./internal/release ./internal/plan3test`
+
+PASS, exit 0.
+
+`gofmt -l internal/coordinator internal/equipo internal/runner internal/runnerproto internal/directlive internal/release internal/plan3test`
+
+PASS, exit 0, no output.
+
+`git diff --check`
+
+PASS, exit 0.
+
+### Red evidence and corrections
+
+The exact required Red command exited 1 before implementation because `Names`, `Validate`, `CoordinatorToolCall`, `CoordinatorToolResult` and `Execution.CallCoordinatorTool` did not exist. The runner tests then failed to compile before the separate coordinator journal methods existed. The named command now passes.
+
+Additional behavioral Red checks:
+
+- `CGO_ENABLED=0 go test ./internal/plan3test -run '^TestCoordinatorToolDelivery$' -count=1`: exit 1, `team: evidence` for a committed tool result with a trusted receipt. Added the local delivery validator; final named run passed.
+- `CGO_ENABLED=0 go test ./internal/plan3test -run '^TestCoordinatorToolQuestionReplacement$' -count=1`: exit 1, `different question reused pending clarification`. Different questions now supersede the pending record; identical ambiguity requests reuse one question.
+- `CGO_ENABLED=0 go test ./internal/plan3test -run '^TestCoordinatorToolSources$' -count=1`: exit 1, `runner.invalid` for a valid project source. Added revision/hash references and current source validation. Final named run passed; a separate mutation then proved forged references are refused.
+- `CGO_ENABLED=0 go test ./internal/plan3test -run '^TestCoordinatorProjectInference$' -count=1`: exit 1, `proposal card lacks visible coordinator attribution`. The card's message now names the coordinator, alongside plan history and delegated audit attribution.
+- `CGO_ENABLED=0 go test ./internal/release -run '^TestPlanWorkflowReleasePolicyInventory$' -count=1`: exit 1 and printed the two new inventory hashes. Recorded both as uncertified; the release regression passed.
+
+The first green attempt also caught invalid test fixture assumptions: the recommendation's person step must use the existing `merge` key, and default specialists already exist. The tests now use the valid plan shape and compare specialist counts before/after. Unix socket tests use a pinned directory descriptor because the on-disk TMPDIR path can exceed Unix socket address limits.
+
+The real fake-CLI path found two implementation errors that the in-memory adapter fixtures could not catch. The first full fixture run exited 1 after 121.057s because an ordinary directory could not be remounted read-only. The workspace is now an empty read-only tmpfs. The next run exited 1 after 216.476s because the namespace's pinned-file digest check did not recognize the new catalog. Catalog bytes now participate in constructor hashes, generated-file validation, launch attestation and pinned-file digest validation. The isolated two-provider fixture and final 19-case fixture passed. Temporary diagnostic wrappers used to locate that failure were restored and are absent from the final diff.
+
+### Guard mutations
+
+### Claude native inventory
+
+`CGO_ENABLED=0 go test ./internal/runner -run ^TestCoordinatorToolAllowlist$ -count=1`
+
+Exit 1; restored: true.
+
+```text
+--- FAIL: TestCoordinatorToolAllowlist (0.00s)
+ coordinator_tools_test.go:37: coordinator exposes built-in tool Bash
+FAIL
+rastrillo-budget/v1 ran 0s
+FAIL amadan.net/oficina/equipo/internal/runner 0.002s
+FAIL
+```
+
+### strict argument schema
+
+`CGO_ENABLED=0 go test ./internal/coordinator -run ^TestCoordinatorToolAllowlist$ -count=1`
+
+Exit 1; restored: true.
+
+```text
+--- FAIL: TestCoordinatorToolAllowlist (0.00s)
+ tools_test.go:21: schema accepted {"project_id":1,"person":"other"}
+FAIL
+rastrillo-budget/v1 ran 0s
+FAIL amadan.net/oficina/equipo/internal/coordinator 0.002s
+FAIL
+```
+
+### message scope
+
+`CGO_ENABLED=0 go test ./internal/plan3test -run ^TestCoordinatorToolScope$ -count=1`
+
+Exit 1; restored: true.
+
+```text
+--- FAIL: TestCoordinatorToolScope (0.60s)
+ coordinator_tools_test.go:40: unauthorized tool accepted {other suggest_preference [123 34 115 111 117 114 99 101 95 109 101 115 115 97 103 101 95 105 100 34 58 34 82 50 68 80 66 83 72 70 83 78 87 69 82 76 66 50 87 78 67 82 78 80 73 52 74 71 34 44 34 116 101 120 116 34 58 34 112 114 105 118 97 116 101 34 125]}
+FAIL
+rastrillo-budget/v1 ran 605ms
+FAIL amadan.net/oficina/equipo/internal/plan3test 0.647s
+FAIL
+```
+
+### instance replay hash
+
+`CGO_ENABLED=0 go test ./internal/plan3test -run ^TestCoordinatorToolScope$ -count=1`
+
+Exit 1; restored: true.
+
+```text
+--- FAIL: TestCoordinatorToolScope (0.61s)
+ coordinator_tools_test.go:48: changed replay accepted
+FAIL
+rastrillo-budget/v1 ran 611ms
+FAIL amadan.net/oficina/equipo/internal/plan3test 0.655s
+FAIL
+```
+
+### broker approval hash
+
+`CGO_ENABLED=0 go test ./internal/runner -run ^TestCoordinatorToolBroker$ -count=1`
+
+Exit 1; restored: true.
+
+```text
+--- FAIL: TestCoordinatorToolBroker (0.42s)
+ --- FAIL: TestCoordinatorToolBroker/claude (0.20s)
+ coordinator_tools_test.go:164: execution changed approved hash
+ --- FAIL: TestCoordinatorToolBroker/codex (0.22s)
+ coordinator_tools_test.go:164: execution changed approved hash
+FAIL
+rastrillo-budget/v1 ran 418ms
+FAIL amadan.net/oficina/equipo/internal/runner 0.421s
+FAIL
+```
+
+### clarification generation
+
+`CGO_ENABLED=0 go test ./internal/plan3test -run ^TestCoordinatorToolClarificationInvalidation/generation$ -count=1`
+
+Exit 1; restored: true.
+
+```text
+--- FAIL: TestCoordinatorToolClarificationInvalidation (0.60s)
+ --- FAIL: TestCoordinatorToolClarificationInvalidation/generation (0.60s)
+ coordinator_tools_test.go:179: invalid clarification answered generation
+FAIL
+rastrillo-budget/v1 ran 601ms
+FAIL amadan.net/oficina/equipo/internal/plan3test 0.644s
+FAIL
+```
+
+### clarification expiry
+
+`CGO_ENABLED=0 go test ./internal/plan3test -run ^TestCoordinatorToolClarificationInvalidation/expiry$ -count=1`
+
+Exit 1; restored: true.
+
+```text
+--- FAIL: TestCoordinatorToolClarificationInvalidation (0.60s)
+ --- FAIL: TestCoordinatorToolClarificationInvalidation/expiry (0.60s)
+ coordinator_tools_test.go:179: invalid clarification answered expiry
+FAIL
+rastrillo-budget/v1 ran 604ms
+FAIL amadan.net/oficina/equipo/internal/plan3test 0.644s
+FAIL
+```
+
+### declared question option
+
+`CGO_ENABLED=0 go test ./internal/plan3test -run ^TestCoordinatorToolClarification$ -count=1`
+
+Exit 1; restored: true.
+
+```text
+--- FAIL: TestCoordinatorToolClarification (0.55s)
+ coordinator_tools_test.go:150: undeclared option accepted
+FAIL
+rastrillo-budget/v1 ran 549ms
+FAIL amadan.net/oficina/equipo/internal/plan3test 0.591s
+FAIL
+```
+
+### delivery resource identity
+
+`CGO_ENABLED=0 go test ./internal/plan3test -run ^TestCoordinatorToolDelivery$ -count=1`
+
+Exit 1; restored: true.
+
+```text
+--- FAIL: TestCoordinatorToolDelivery (0.54s)
+ coordinator_tools_test.go:200: forged delivery accepted
+FAIL
+rastrillo-budget/v1 ran 543ms
+FAIL amadan.net/oficina/equipo/internal/plan3test 0.588s
+FAIL
+```
+
+### checkout omission
+
+`CGO_ENABLED=0 go test ./internal/runner/containment -run ^TestCoordinatorToolNoCheckout$ -count=1`
+
+Exit 1; restored: true.
+
+```text
+--- FAIL: TestCoordinatorToolNoCheckout (0.00s)
+ mounts_test.go:151: empty workspace absent
+FAIL
+rastrillo-budget/v1 ran 5ms
+FAIL amadan.net/oficina/equipo/internal/runner/containment 0.006s
+FAIL
+```
+
+### prose parsing
+
+`CGO_ENABLED=0 go test ./internal/plan3test -run ^TestCoordinatorSuggestionOnly$ -count=1`
+
+Exit 1; restored: true.
+
+```text
+--- FAIL: TestCoordinatorSuggestionOnly (0.62s)
+ coordinator_tools_test.go:116: prose executed
+FAIL
+rastrillo-budget/v1 ran 620ms
+FAIL amadan.net/oficina/equipo/internal/plan3test 0.665s
+FAIL
+```
+
+### source revision and digest
+
+`CGO_ENABLED=0 go test ./internal/plan3test -run ^TestCoordinatorToolSources$ -count=1`
+
+Exit 1; restored: true.
+
+```text
+--- FAIL: TestCoordinatorToolSources (0.64s)
+ coordinator_tools_test.go:241: forged source accepted
+FAIL
+rastrillo-budget/v1 ran 638ms
+FAIL amadan.net/oficina/equipo/internal/plan3test 0.680s
+FAIL
+```
diff --git a/internal/coordinator/budget_test.go b/internal/coordinator/budget_test.go
new file mode 100644
index 00000000..38a86bd5
--- /dev/null
+++ b/internal/coordinator/budget_test.go
@@ -0,0 +1,9 @@
+package coordinator
+
+import (
+ "amadan.net/rastrillo/rastrillo/budget"
+ "os"
+ "testing"
+)
+
+func TestMain(m *testing.M) { os.Exit(budget.Main(m)) }
diff --git a/internal/coordinator/tools.go b/internal/coordinator/tools.go
new file mode 100644
index 00000000..969cb4f5
--- /dev/null
+++ b/internal/coordinator/tools.go
@@ -0,0 +1,136 @@
+package coordinator
+
+import (
+ "amadan.net/oficina/equipo/internal/runner/provider"
+ "amadan.net/oficina/equipo/internal/runnerproto"
+ "amadan.net/oficina/equipo/internal/taskplan"
+ "bytes"
+ "encoding/json"
+ "reflect"
+ "strings"
+ "unicode/utf8"
+)
+
+func Names() []string { return provider.CoordinatorTools() }
+func argument(name string) any {
+ switch name {
+ case "read_project":
+ return &ReadProject{}
+ case "read_task":
+ return &ReadTask{}
+ case "propose_plan":
+ return &ProposePlan{}
+ case "ask_person":
+ return &AskPerson{}
+ case "route_to_task":
+ return &RouteToTask{}
+ case "post_message":
+ return &PostMessage{}
+ case "suggest_preference":
+ return &SuggestPreference{}
+ case "suggest_specialist", "suggest_playbook":
+ return &SuggestDraft{}
+ }
+ return nil
+}
+func Text(s string, limit int) bool {
+ return strings.TrimSpace(s) != "" && len(s) <= limit && utf8.ValidString(s)
+}
+func ids(ss []string, allowEmpty bool) bool {
+ if (!allowEmpty && len(ss) == 0) || len(ss) > 32 {
+ return false
+ }
+ seen := map[string]bool{}
+ for _, s := range ss {
+ if !Text(s, 256) || seen[s] {
+ return false
+ }
+ seen[s] = true
+ }
+ return true
+}
+func Validate(call CoordinatorToolCall) (any, error) {
+ v := argument(call.Name)
+ if v == nil || !Text(call.RequestID, 256) || len(call.Arguments) > 65536 || runnerproto.DecodeLimit(bytes.NewReader(call.Arguments), v, 65536) != nil {
+ return nil, runnerproto.ErrInvalid
+ }
+ valid := false
+ switch a := v.(type) {
+ case *ReadProject:
+ valid = a.ProjectID > 0
+ case *ReadTask:
+ valid = Text(a.TaskID, 256)
+ case *ProposePlan:
+ p := a.Plan.TaskPlan()
+ if p.ProjectID == 0 {
+ p.ProjectID = 1
+ }
+ valid = Text(a.MessageID, 256) && a.Plan.ProjectID >= 0 && taskplan.Validate(p) == nil
+ for _, s := range a.Plan.Steps {
+ valid = valid && len(s.Instructions) <= 8192
+ }
+ case *AskPerson:
+ valid = Text(a.MessageID, 256) && Text(a.Question, 8192) && len(a.Options) <= 32 && a.Options != nil
+ seen := map[string]bool{}
+ for _, o := range a.Options {
+ valid = valid && Text(o.ID, 256) && Text(o.Label, 512) && !seen[o.ID]
+ seen[o.ID] = true
+ }
+ case *RouteToTask:
+ valid = Text(a.MessageID, 256) && Text(a.TaskID, 256)
+ case *PostMessage:
+ valid = Text(a.Body, 16384) && a.SourceRefs != nil && len(a.SourceRefs) <= 32 && (len(a.SourceRefs) == 0 || taskplan.ValidateAnswer(taskplan.AnswerResult{Body: a.Body, Sources: a.SourceRefs}) == nil)
+ case *SuggestPreference:
+ valid = Text(a.SourceMessageID, 256) && Text(a.Text, 8192)
+ case *SuggestDraft:
+ valid = ids(a.SourceMessageIDs, false) && Text(a.Draft.Name, 256) && Text(a.Draft.Instructions, 8192)
+ }
+ if !valid {
+ return nil, runnerproto.ErrInvalid
+ }
+ return v, nil
+}
+
+// Schemas and decoding use the same explicit argument types. No authority fields
+// or provider configuration can be supplied through these objects.
+func Schemas(descriptions map[string]string) []map[string]any {
+ out := []map[string]any{}
+ for _, name := range Names() {
+ schema := schemaFor(reflect.TypeOf(argument(name)).Elem())
+ props := schema["properties"].(map[string]any)
+ props["request_id"] = map[string]any{"type": "string", "minLength": 1, "maxLength": 256}
+ schema["required"] = append(schema["required"].([]string), "request_id")
+ out = append(out, map[string]any{"name": name, "description": descriptions[name], "inputSchema": schema})
+ }
+ return out
+}
+func schemaFor(t reflect.Type) map[string]any {
+ switch t.Kind() {
+ case reflect.Struct:
+ props := map[string]any{}
+ required := []string{}
+ for i := 0; i < t.NumField(); i++ {
+ f := t.Field(i)
+ tag := strings.Split(f.Tag.Get("json"), ",")
+ props[tag[0]] = schemaFor(f.Type)
+ if len(tag) == 1 {
+ required = append(required, tag[0])
+ }
+ }
+ return map[string]any{"type": "object", "properties": props, "required": required, "additionalProperties": false}
+ case reflect.Slice:
+ return map[string]any{"type": "array", "items": schemaFor(t.Elem()), "maxItems": 32}
+ case reflect.Int64:
+ return map[string]any{"type": "integer", "minimum": 0}
+ default:
+ return map[string]any{"type": "string", "maxLength": 16384}
+ }
+}
+func Canonical(call CoordinatorToolCall) (CoordinatorToolCall, error) {
+ v, err := Validate(call)
+ if err != nil {
+ return call, err
+ }
+ call.Arguments, err = json.Marshal(v)
+ return call, err
+}
diff --git a/internal/coordinator/tools_test.go b/internal/coordinator/tools_test.go
new file mode 100644
index 00000000..678ec621
--- /dev/null
+++ b/internal/coordinator/tools_test.go
@@ -0,0 +1,43 @@
+package coordinator
+
+import (
+ "encoding/json"
+ "reflect"
+ "testing"
+)
+
+func TestCoordinatorToolAllowlist(t *testing.T) {
+ want := []string{"read_project", "read_task", "propose_plan", "ask_person", "route_to_task", "post_message", "suggest_preference", "suggest_specialist", "suggest_playbook"}
+ if !reflect.DeepEqual(Names(), want) {
+ t.Fatal("unexpected tool inventory", Names())
+ }
+ 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"} {
+ if _, err := Validate(CoordinatorToolCall{RequestID: "r", Name: name, Arguments: json.RawMessage(`{}`)}); err == nil {
+ t.Fatalf("unauthorized tool %s", name)
+ }
+ }
+ for _, raw := range []string{`{"project_id":1,"person":"other"}`, `{"project_id":1,"project_id":2}`, `{"project_id":0}`, `null`, `{"project_id":1} trailing`} {
+ if _, err := Validate(CoordinatorToolCall{RequestID: "r", Name: "read_project", Arguments: json.RawMessage(raw)}); err == nil {
+ t.Fatalf("schema accepted %s", raw)
+ }
+ }
+ if _, err := Validate(CoordinatorToolCall{RequestID: "r", Name: "read_project", Arguments: json.RawMessage(`{"project_id":1}`)}); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := Validate(CoordinatorToolCall{RequestID: "", Name: "read_project", Arguments: json.RawMessage(`{"project_id":1}`)}); err == nil {
+ t.Fatal("missing request ID accepted")
+ }
+ for _, s := range Schemas(nil) {
+ if s["inputSchema"].(map[string]any)["additionalProperties"] != false {
+ t.Fatal("open schema")
+ }
+ }
+}
+
+func TestCoordinatorToolStrictFields(t *testing.T) {
+ for _, raw := range []string{`{"Body":"hi","source_refs":[]}`, `{"body":"hi"}`, `{"body":"hi","source_refs":null}`} {
+ if _, err := Validate(CoordinatorToolCall{RequestID: "r", Name: "post_message", Arguments: json.RawMessage(raw)}); err == nil {
+ t.Fatal("strict schema accepted", raw)
+ }
+ }
+}
diff --git a/internal/coordinator/types.go b/internal/coordinator/types.go
new file mode 100644
index 00000000..a81d1e07
--- /dev/null
+++ b/internal/coordinator/types.go
@@ -0,0 +1,72 @@
+package coordinator
+
+import (
+ "amadan.net/oficina/equipo/internal/runnerproto"
+ "amadan.net/oficina/equipo/internal/taskplan"
+ "context"
+)
+
+type CoordinatorToolCall = runnerproto.CoordinatorToolCall
+type CoordinatorToolResult = runnerproto.CoordinatorToolResult
+type ClarificationQuestion = runnerproto.ClarificationQuestion
+type QuestionOption = runnerproto.QuestionOption
+type ToolClient interface {
+ Call(context.Context, CoordinatorToolCall) (CoordinatorToolResult, error)
+}
+
+type ReadProject struct {
+ ProjectID int64 `json:"project_id"`
+}
+type ReadTask struct {
+ TaskID string `json:"task_id"`
+}
+type PlanStep struct {
+ Key string `json:"key"`
+ Specialist string `json:"specialist,omitempty"`
+ Action string `json:"action"`
+ Instructions string `json:"instructions,omitempty"`
+ DependsOn []string `json:"depends_on,omitempty"`
+}
+type Plan struct {
+ Kind taskplan.Kind `json:"kind"`
+ ProjectID int64 `json:"project_id"`
+ Steps []PlanStep `json:"steps"`
+}
+
+func (p Plan) TaskPlan() taskplan.Plan {
+ out := taskplan.Plan{Kind: p.Kind, ProjectID: p.ProjectID}
+ for _, s := range p.Steps {
+ out.Steps = append(out.Steps, taskplan.Step{Key: s.Key, Specialist: s.Specialist, Action: s.Action, Instructions: s.Instructions, DependsOn: s.DependsOn})
+ }
+ return out
+}
+
+type ProposePlan struct {
+ MessageID string `json:"message_id"`
+ Plan Plan `json:"plan"`
+}
+type AskPerson struct {
+ MessageID string `json:"message_id"`
+ Question string `json:"question"`
+ Options []QuestionOption `json:"options"`
+}
+type RouteToTask struct {
+ MessageID string `json:"message_id"`
+ TaskID string `json:"task_id"`
+}
+type PostMessage struct {
+ Body string `json:"body"`
+ SourceRefs []taskplan.SourceRef `json:"source_refs"`
+}
+type SuggestPreference struct {
+ SourceMessageID string `json:"source_message_id"`
+ Text string `json:"text"`
+}
+type Draft struct {
+ Name string `json:"name"`
+ Instructions string `json:"instructions"`
+}
+type SuggestDraft struct {
+ SourceMessageIDs []string `json:"source_message_ids"`
+ Draft Draft `json:"draft"`
+}
diff --git a/internal/directlive/coordinator.go b/internal/directlive/coordinator.go
new file mode 100644
index 00000000..abc52c8c
--- /dev/null
+++ b/internal/directlive/coordinator.go
@@ -0,0 +1,83 @@
+package directlive
+
+import (
+ "context"
+ "encoding/json"
+ "fmt"
+ "slices"
+ "strings"
+
+ "amadan.net/oficina/equipo/internal/equipo"
+ "amadan.net/oficina/equipo/internal/equipo/team"
+ "amadan.net/oficina/equipo/internal/runner"
+ "amadan.net/oficina/equipo/internal/runner/provider"
+ "amadan.net/oficina/equipo/internal/runnerproto"
+)
+
+// Coordinator fixtures exercise a fresh session with no native tools. The
+// specialist certification sequence requires native approval and a checkout;
+// it cannot certify this distinct policy. Live certification stays unavailable.
+func (x *exercise) coordinatorFixture(ctx context.Context) (provider.DirectEvidence, error) {
+ if x.d.source != "fake-cli" {
+ return x.evidence, provider.ErrPolicy
+ }
+ deadline, _ := ctx.Deadline()
+ c := runnerproto.CoordinatorClaim{ToolCopy: equipo.CoordinatorToolCopy(), Binding: runnerproto.CoordinatorBinding{ID: "fixture-binding", Generation: 1}, Turn: runnerproto.CoordinatorTurn{ID: "certification-1", Generation: 1}, Scope: team.Scope{Account: team.AccountID(x.d.cfg.MachineFingerprint)}, Handle: team.Handle{Attempt: 1, Fence: 1}, LeaseDeadline: deadline, AttemptDeadline: deadline, Brief: runnerproto.RunnerBrief{Selection: runnerproto.Selection{Provider: x.launch.Selection.Provider, AccountID: x.launch.Selection.AccountID, Model: x.launch.Selection.Model, Isolation: team.IsolationSnapshot{Status: "confined"}}}}
+ var err error
+ calls := 0
+ x.proxy, err = runner.OpenCoordinatorToolProxy(ctx, runner.CoordinatorToolBinding{Claim: c, Journal: x.journal, Current: func(ctx context.Context) error { return ctx.Err() }, Call: func(_ context.Context, call runnerproto.CoordinatorToolCall) (runnerproto.CoordinatorToolResult, error) {
+ calls++
+ return runnerproto.CoordinatorToolResult{ResourceID: "fixture-question", Revision: 1, Value: json.RawMessage(`{"state":"pending"}`)}, nil
+ }})
+ if err != nil {
+ return x.evidence, fmt.Errorf("coordinator fixture line: %w", err)
+ }
+ defer x.proxy.Close()
+ x.launch.ToolSocket = x.proxy.SocketPath
+ x.session, err = x.launcher.Open(ctx, x.launch)
+ if err != nil {
+ return x.evidence, fmt.Errorf("coordinator launcher open: %w", err)
+ }
+ defer x.launcher.Close(context.Background(), x.session)
+ x.events, err = x.launcher.Events(ctx, x.session)
+ if err != nil {
+ return x.evidence, fmt.Errorf("coordinator fixture line: %w", err)
+ }
+ frames, err := x.turn(ctx, "Certification action: question. Use the bound Equipo clarification tool.")
+ if err != nil {
+ return x.evidence, fmt.Errorf("coordinator fixture line: %w", err)
+ }
+ observed := x.evidence.Provider == "codex" // Codex config/catalog readback is checked at Open.
+ if x.evidence.Provider == "claude" {
+ want := append([]string{"mcp__equipo__permission"}, provider.ActionProfile{Action: "coordinate"}.MCPTools()...)
+ slices.Sort(want)
+ for _, raw := range frames {
+ var init struct {
+ Type, Subtype string
+ Tools []string
+ }
+ if json.Unmarshal(raw, &init) == nil && init.Type == "system" && init.Subtype == "init" {
+ slices.Sort(init.Tools)
+ observed = slices.Equal(init.Tools, want)
+ for _, tool := range init.Tools {
+ if !strings.HasPrefix(tool, "mcp__equipo__") {
+ return x.evidence, provider.ErrPolicy
+ }
+ }
+ }
+ }
+ }
+ if !observed || calls != 1 {
+ return x.evidence, fmt.Errorf("inventory observed=%v calls=%d: %w", observed, calls, provider.ErrPolicy)
+ }
+ if err = x.check("coordinator-empty-native-inventory", observed, json.RawMessage(x.launch.Policy.Manifest)); err != nil {
+ return x.evidence, fmt.Errorf("coordinator fixture line: %w", err)
+ }
+ if err = x.check("coordinator-structured-question", calls == 1, map[string]int{"calls": calls}); err != nil {
+ return x.evidence, fmt.Errorf("coordinator fixture line: %w", err)
+ }
+ if err = x.namespaceChecks(ctx); err != nil {
+ return x.evidence, fmt.Errorf("coordinator namespace: %w", err)
+ }
+ return x.evidence, nil
+}
diff --git a/internal/directlive/driver.go b/internal/directlive/driver.go
index 78abdf3a..8be10772 100644
--- a/internal/directlive/driver.go
+++ b/internal/directlive/driver.go
@@ -44,6 +44,9 @@ func Run(ctx context.Context, c provider.DirectLiveConfig, config []byte, p Path
return run(ctx, c, config, p, "direct-live", terminalAnswer, EnvironmentPolicyPaths(os.Getenv))
}
func run(ctx context.Context, c provider.DirectLiveConfig, config []byte, p Paths, source string, answer answerFunc, policyPaths PolicyPaths) error {
+ return runRoles(ctx, c, config, p, source, answer, policyPaths, []string{"Engineering", "Engineering-reproduction", "Review", "Product", "Scope", "Research", "Investigation", "Copy", "Design", "Coordinator"})
+}
+func runRoles(ctx context.Context, c provider.DirectLiveConfig, config []byte, p Paths, source string, answer answerFunc, policyPaths PolicyPaths, roles []string) error {
if err := c.Validate("1"); err != nil {
return err
}
@@ -76,7 +79,7 @@ func run(ctx context.Context, c provider.DirectLiveConfig, config []byte, p Path
var records []provider.DirectEvidence
var failures []error
for _, b := range c.Bindings {
- for _, role := range []string{"Engineering", "Engineering-reproduction", "Review", "Product", "Scope", "Research", "Investigation", "Copy", "Design", "Coordinator"} {
+ for _, role := range roles {
if b.Binding.Provider == "codex" && role == "Product" {
continue
}
@@ -86,7 +89,7 @@ func run(ctx context.Context, c provider.DirectLiveConfig, config []byte, p Path
return err
}
e, err := d.exercise(ctx, b, role, dir)
- if err == nil {
+ if err == nil && role != "Coordinator" {
err = d.recover(ctx, b, role, dir, &e)
}
if err != nil {
@@ -269,6 +272,9 @@ func (d *driver) exercise(ctx context.Context, b provider.DirectLiveBinding, rol
x.evidence.PolicyHash = policy.Hash
x.launch = provider.Launch{AttemptKey: d.cfg.RunID + "/" + binding.Provider + "/" + role, Workspace: d.cfg.Repository, Binding: binding, Policy: policy, Selection: provider.Selection{ConnectionID: b.Binding.ID, Provider: binding.Provider, Family: map[string]string{"claude": "claude", "codex": "gpt"}[binding.Provider], AccountID: binding.AccountID, Model: b.Model}}
phase = "open"
+ if role == "Coordinator" {
+ return x.coordinatorFixture(ctx)
+ }
if err = x.open(ctx, tool); err != nil {
return e, err
}
diff --git a/internal/directlive/driver_test.go b/internal/directlive/driver_test.go
index e19ce281..90c37d09 100644
--- a/internal/directlive/driver_test.go
+++ b/internal/directlive/driver_test.go
@@ -15,6 +15,10 @@ import (
"testing"
)
+func TestCoordinatorToolAllowlistFakeCLI(t *testing.T) {
+ t.Setenv("EQUIPO_FAKE_COORDINATOR_ONLY", "1")
+ TestDirectDriverFakeCLI(t)
+}
func TestDirectDriverFakeCLI(t *testing.T) {
root := t.TempDir()
repo, err := filepath.Abs("../..")
@@ -125,7 +129,13 @@ func TestDirectDriverFakeWorker(t *testing.T) {
if err := os.WriteFile(paths.AccountBindingsPath, marshal(bindings), 0600); err != nil {
t.Fatal(err)
}
- if err := run(context.Background(), c, marshal(c), p, "fake-cli", answer, paths); err != nil {
+ runFixture := run
+ if os.Getenv("EQUIPO_FAKE_COORDINATOR_ONLY") == "1" {
+ runFixture = func(ctx context.Context, c provider.DirectLiveConfig, raw []byte, p Paths, source string, answer answerFunc, paths PolicyPaths) error {
+ return runRoles(ctx, c, raw, p, source, answer, paths, []string{"Coordinator"})
+ }
+ }
+ if err := runFixture(context.Background(), c, marshal(c), p, "fake-cli", answer, paths); err != nil {
files, _ := filepath.Glob(filepath.Join(c.EvidenceDir, "*", "diagnostics.json"))
for _, p := range files {
raw, _ := os.ReadFile(p)
@@ -142,7 +152,11 @@ func TestDirectDriverFakeWorker(t *testing.T) {
t.Fatal(err)
}
var index []string
- if json.Unmarshal(raw, &index) != nil || len(index) != 19 {
+ want := 19
+ if os.Getenv("EQUIPO_FAKE_COORDINATOR_ONLY") == "1" {
+ want = 2
+ }
+ if json.Unmarshal(raw, &index) != nil || len(index) != want {
t.Fatal("missing driver coverage")
}
for _, name := range index {
@@ -151,6 +165,15 @@ func TestDirectDriverFakeWorker(t *testing.T) {
t.Fatal(err)
}
var e provider.DirectEvidence
+ if strings.Contains(name, "Coordinator") {
+ if json.Unmarshal(raw, &e) != nil || e.Checks["coordinator-empty-native-inventory"].Status != "pass" || e.Checks["coordinator-structured-question"].Status != "pass" {
+ t.Fatalf("empty inventory fixture failed: %s", raw)
+ }
+ if e.ValidateGroup(filepath.Dir(filepath.Join(c.EvidenceDir, name)), "Contract") == nil {
+ t.Fatal("offline coordinator fixture certified production")
+ }
+ continue
+ }
if json.Unmarshal(raw, &e) != nil || len(e.Usage) == 0 || e.Checks["workspace-positive-control"].Status != "pass" {
t.Fatalf("driver did not observe tools and usage: %s", raw)
}
diff --git a/internal/directlive/testdata/fake-cli.py b/internal/directlive/testdata/fake-cli.py
index 435e15e3..a0b2c890 100644
--- a/internal/directlive/testdata/fake-cli.py
+++ b/internal/directlive/testdata/fake-cli.py
@@ -44,7 +44,7 @@ for line in sys.stdin:
turn+=1
session=req['session_id']
prompt=req['message']['content']
- tools=sys.argv[sys.argv.index('--tools')+1].split(',')+mcp()
+ tools=[name for name in sys.argv[sys.argv.index('--tools')+1].split(',') if name]+mcp()
emit({'type':'system','subtype':'init','session_id':session,'claude_code_version':'2.1.312','model':'fixture-model','permissionMode':'manual','tools':tools,'skills':[],'plugins':[],'mcp_servers':[{'name':'equipo','status':'connected'}]})
if 'Certification action: native-' in prompt:
allow='native-allow' in prompt
@@ -59,6 +59,7 @@ for line in sys.stdin:
if reply['result']['decision']!=('accept' if allow else 'decline'):raise RuntimeError('unexpected native answer')
if 'Certification action: question' in prompt:
args={'request_id':'question-'+str(turn),'question':'Which disposable case should be checked?'}
+ if 'mcp__equipo__read_project' in mcp():args.update({'message_id':'fixture-message','options':[]})
if family=='codex':
emit({'method':'item/started','params':{'threadId':session,'turnId':str(turn),'item':{'id':'ask','type':'mcpToolCall','server':'equipo','tool':'ask_person','arguments':args}}})
emit({'id':2000+turn,'method':'mcpServer/elicitation/request','params':{'threadId':session,'turnId':str(turn),'serverName':'equipo','mode':'form','_meta':{'codex_approval_kind':'mcp_tool_call','tool_params':args},'requestedSchema':{'type':'object','properties':{}}}})
diff --git a/internal/directlive/turn.go b/internal/directlive/turn.go
index 867589e3..ff3786ae 100644
--- a/internal/directlive/turn.go
+++ b/internal/directlive/turn.go
@@ -98,6 +98,12 @@ func (x *exercise) turn(ctx context.Context, prompt string) ([][]byte, error) {
if err != nil {
return frames, err
}
+ if ev.Kind == "request" && x.launch.Policy.Coordinator() {
+ if err = x.proxy.ApproveCoordinator(ctx, x.launcher, ev); err != nil {
+ return frames, err
+ }
+ continue
+ }
if ev.Kind == "request" {
relay := x.relay()
if _, _, mcpErr := codex.MCPApproval(ev); mcpErr == nil {
diff --git a/internal/equipo/conversation/coordinator_api.go b/internal/equipo/conversation/coordinator_api.go
index 2a590a24..ab22e2fa 100644
--- a/internal/equipo/conversation/coordinator_api.go
+++ b/internal/equipo/conversation/coordinator_api.go
@@ -3,6 +3,8 @@ package conversation
import (
"amadan.net/oficina/equipo/internal/equipo/kernel"
"amadan.net/oficina/equipo/internal/runnerproto"
+ "errors"
+ "gorm.io/gorm"
)
// CoordinatorContextFor supplies only the admitted message. Task 7 may extend
@@ -45,3 +47,25 @@ func (s *Store) DeliverCoordinator(row TurnRecord, body string) error {
_, err := s.appendMessage(row.ConversationID, row.ConversationID, "", "coordinator", "coordinator:"+row.BindingID, body, "delivery")
return err
}
+
+func (e *Engine) projects(tx *gorm.DB, person string, sel runnerproto.Selection) ([]runnerproto.CoordinatorProject, error) {
+ var rows []struct {
+ ID, Revision int64
+ Name string
+ }
+ if err := tx.Table("projects").Select("id", "revision", "name").Order("id").Limit(1000).Find(&rows).Error; err != nil {
+ return nil, err
+ }
+ out := []runnerproto.CoordinatorProject{}
+ for _, p := range rows {
+ revision, err := e.CheckProject(tx, person, p.ID, sel)
+ if err != nil {
+ if errors.Is(err, e.Forbidden) || errors.Is(err, e.NotFound) {
+ continue
+ }
+ return nil, err
+ }
+ out = append(out, runnerproto.CoordinatorProject{ID: p.ID, Label: p.Name, Revision: revision})
+ }
+ return out, nil
+}
diff --git a/internal/equipo/conversation/coordinator_engine.go b/internal/equipo/conversation/coordinator_engine.go
index 5c3ffa1e..b8df0dda 100644
--- a/internal/equipo/conversation/coordinator_engine.go
+++ b/internal/equipo/conversation/coordinator_engine.go
@@ -13,6 +13,8 @@ type RunnerPrincipal = runnerproto.RunnerPrincipal
type Assignment = runnerproto.Assignment
type RunnerRequest = runnerproto.RunnerRequest
type Engine struct {
+ ToolCopy runnerproto.CoordinatorToolCopy
+ Tools ToolOperations
Selection func(*gorm.DB, BindingRecord) (runnerproto.Selection, error)
CheckProject func(*gorm.DB, string, int64, runnerproto.Selection) (int64, error)
StoreError func(error) error
@@ -22,7 +24,6 @@ type Engine struct {
Core *team.Store
Atomic func(context.Context, func(context.Context, *gorm.DB) error) error
Conversation func(*gorm.DB) *Store
- Projects func(*gorm.DB, string, runnerproto.Selection) ([]runnerproto.CoordinatorProject, error)
Project func(*gorm.DB, string, int64, runnerproto.Selection) (int64, runnerproto.SourceSnapshot, error)
RunnerCurrent func(*gorm.DB, RunnerPrincipal) error
Audit func(*gorm.DB, BindingRecord, string, string) error
diff --git a/internal/equipo/conversation/coordinator_events.go b/internal/equipo/conversation/coordinator_events.go
index 1d35aa4a..2637fa8b 100644
--- a/internal/equipo/conversation/coordinator_events.go
+++ b/internal/equipo/conversation/coordinator_events.go
@@ -37,13 +37,20 @@ func (e *Engine) CompleteCoordinator(ctx context.Context, p RunnerPrincipal, c C
}
return nil
}
- if row.State != "running" || e.Delivery == nil {
+ if row.State != "running" {
return team.ErrEvidence
}
if err = e.Core.ValidateHandle(ctx, c.Scope, c.Handle); err != nil {
return err
}
- body, receipt, err := e.Delivery(ctx, c, event)
+ var body string
+ var receipt team.Receipt
+ committed := e.Delivery == nil
+ if committed {
+ receipt, err = e.committedToolDelivery(ctx, tx, c, row, event)
+ } else {
+ body, receipt, err = e.Delivery(ctx, c, event)
+ }
if err != nil {
return err
}
@@ -61,8 +68,10 @@ func (e *Engine) CompleteCoordinator(ctx context.Context, p RunnerPrincipal, c C
} else if err = e.Core.Record(ctx, c.Scope, event.ActionID, receipt); err != nil {
return err
}
- if err = e.Conversation(tx).DeliverCoordinator(row, body); err != nil {
- return err
+ if !committed {
+ if err = e.Conversation(tx).DeliverCoordinator(row, body); err != nil {
+ return err
+ }
}
if err = e.Core.DeliverCoordinator(ctx, c.Scope, c.Handle, b.ID, hash); err != nil {
return err
diff --git a/internal/equipo/conversation/coordinator_execution.go b/internal/equipo/conversation/coordinator_execution.go
index 45d893c1..9468ae96 100644
--- a/internal/equipo/conversation/coordinator_execution.go
+++ b/internal/equipo/conversation/coordinator_execution.go
@@ -60,7 +60,7 @@ func (e *Engine) ClaimCoordinator(ctx context.Context, p RunnerPrincipal, turnID
if err != nil {
return err
}
- contextValue.Projects, err = e.Projects(tx, p.Person, sel)
+ contextValue.Projects, err = e.projects(tx, p.Person, sel)
if err != nil {
return err
}
@@ -135,7 +135,7 @@ func (e *Engine) ClaimCoordinator(ctx context.Context, p RunnerPrincipal, turnID
row.AttemptID = int64(handle.Attempt)
row.Fence = handle.Fence
row.Selection = string(mustCoordinatorJSON(sel))
- result = CoordinatorClaim{Binding: b.CoordinatorBinding, Turn: row.CoordinatorTurn, Scope: scope, Handle: handle, Context: contextValue, Admission: ticket, LeaseDeadline: lease, AttemptDeadline: deadline, Brief: runnerproto.RunnerBrief{AttemptDeadline: deadline, Step: runnerproto.StepBrief{StepKey: "coordinate", Action: "coordinate", SpecialistKey: "coordinator"}, Policy: policy, Target: spec.Target, Selection: sel}}
+ result = CoordinatorClaim{ToolCopy: e.ToolCopy, Binding: b.CoordinatorBinding, Turn: row.CoordinatorTurn, Scope: scope, Handle: handle, Context: contextValue, Admission: ticket, LeaseDeadline: lease, AttemptDeadline: deadline, Brief: runnerproto.RunnerBrief{AttemptDeadline: deadline, Step: runnerproto.StepBrief{StepKey: "coordinate", Action: "coordinate", SpecialistKey: "coordinator"}, Policy: policy, Target: spec.Target, Selection: sel}}
row.Claim = string(mustCoordinatorJSON(result))
if err = tx.Model(&TurnRecord{}).Where("id=?", row.ID).Select("state", "job_id", "attempt_id", "fence", "claim", "selection", "context_hash", "project_revision").Updates(&row).Error; err != nil {
return err
diff --git a/internal/equipo/conversation/store.go b/internal/equipo/conversation/store.go
index 512e8512..56ff3a80 100644
--- a/internal/equipo/conversation/store.go
+++ b/internal/equipo/conversation/store.go
@@ -188,6 +188,25 @@ func (s *Store) page(actor kernel.Actor, stream string, through, revision int64,
return page, err
}
for _, c := range cards {
+ if c.Kind != "task" {
+ switch c.Kind {
+ case "clarification":
+ var q QuestionRecord
+ if err := s.tx.Where("id=? AND person=?", c.ResourceID, actor.Address).First(&q).Error; err != nil {
+ return page, err
+ }
+ page.Cards = append(page.Cards, Card{ID: c.ID, Kind: c.Kind, ResourceID: q.ID, Revision: q.Revision})
+ case "suggest_preference", "suggest_specialist", "suggest_playbook":
+ var msg messageRecord
+ if err := s.tx.Where("id=? AND conversation_id=?", c.ResourceID, stream).First(&msg).Error; err != nil {
+ return page, err
+ }
+ page.Cards = append(page.Cards, Card{ID: c.ID, Kind: c.Kind, ResourceID: msg.ID, Revision: msg.Revision})
+ default:
+ return page, s.deps.Invalid
+ }
+ continue
+ }
task, err := s.deps.Task(s.tx, actor, c.ResourceID)
if err != nil {
return page, err
diff --git a/internal/equipo/conversation/tool_delivery.go b/internal/equipo/conversation/tool_delivery.go
new file mode 100644
index 00000000..f0a83115
--- /dev/null
+++ b/internal/equipo/conversation/tool_delivery.go
@@ -0,0 +1,54 @@
+package conversation
+
+import (
+ "amadan.net/oficina/equipo/internal/equipo/team"
+ "amadan.net/oficina/equipo/internal/runnerproto"
+ "bytes"
+ "context"
+ "encoding/json"
+ "gorm.io/gorm"
+)
+
+func toolResource(c CoordinatorClaim, row TurnRecord) string {
+ return runnerproto.EventHash([]any{string(c.Scope.Account), c.Binding.ID, c.Binding.Generation, row.ID, c.Handle.Attempt, c.Handle.Fence, row.ProviderSessionID})
+}
+
+// committedToolDelivery reads only local bounded records. Provider text and a
+// tool result without a previously validated provider receipt cannot complete.
+func (e *Engine) committedToolDelivery(ctx context.Context, tx *gorm.DB, c CoordinatorClaim, row TurnRecord, event runnerproto.Event) (team.Receipt, error) {
+ var delivery struct {
+ RequestID string `json:"request_id"`
+ ResourceID string `json:"resource_id"`
+ }
+ if runnerproto.DecodeLimit(bytes.NewReader(event.Payload), &delivery, 1024) != nil || delivery.RequestID == "" || delivery.ResourceID == "" {
+ return team.Receipt{}, team.ErrEvidence
+ }
+ var saved requestRecord
+ if err := tx.Where("principal=? AND operation='coordinator.tool' AND resource=? AND request_id=?", c.Binding.Person, toolResource(c, row), delivery.RequestID).First(&saved).Error; err != nil {
+ return team.Receipt{}, team.ErrEvidence
+ }
+ var out CoordinatorToolResult
+ if len(saved.Result) > 65536 || json.Unmarshal([]byte(saved.Result), &out) != nil || out.ResourceID != delivery.ResourceID {
+ return team.Receipt{}, team.ErrEvidence
+ }
+ // The committed result marks the operation, so reads cannot prove delivery.
+ var value struct {
+ Tool string `json:"tool"`
+ }
+ if json.Unmarshal(out.Value, &value) != nil {
+ return team.Receipt{}, team.ErrEvidence
+ }
+ switch value.Tool {
+ case "post_message", "propose_plan", "ask_person", "route_to_task", "suggest_preference", "suggest_specialist", "suggest_playbook":
+ default:
+ return team.Receipt{}, team.ErrEvidence
+ }
+ action, err := e.Core.GetAction(ctx, c.Scope, c.Admission.Dispatch.Action)
+ if err != nil {
+ return team.Receipt{}, err
+ }
+ if action.State != team.ActionSucceeded || action.Receipt == nil || action.Receipt.Outcome != team.OutcomeSuccess {
+ return team.Receipt{}, team.ErrEvidence
+ }
+ return *action.Receipt, nil
+}
diff --git a/internal/equipo/conversation/tools.go b/internal/equipo/conversation/tools.go
new file mode 100644
index 00000000..098d4e38
--- /dev/null
+++ b/internal/equipo/conversation/tools.go
@@ -0,0 +1,396 @@
+package conversation
+
+import (
+ "context"
+ "crypto/rand"
+ "encoding/json"
+ "errors"
+ "strconv"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/coordinator"
+ "amadan.net/oficina/equipo/internal/equipo/planning"
+ "amadan.net/oficina/equipo/internal/equipo/team"
+ "amadan.net/oficina/equipo/internal/runnerproto"
+ "gorm.io/gorm"
+)
+
+type CoordinatorToolCall = runnerproto.CoordinatorToolCall
+type CoordinatorToolResult = runnerproto.CoordinatorToolResult
+
+type ToolOperations struct {
+ Planning func(*gorm.DB) *planning.Store
+ AmbiguousProject string
+}
+
+func (e *Engine) readToolTask(tx *gorm.DB, person, id string, sel runnerproto.Selection) (int64, any, error) {
+ var t planning.Task
+ if err := tx.First(&t, "id=?", id).Error; err != nil {
+ return 0, nil, e.StoreError(err)
+ }
+ if _, err := e.CheckProject(tx, person, t.ProjectID, sel); err != nil {
+ return 0, nil, err
+ }
+ plan, err := e.Tools.Planning(tx).Plan(t)
+ return t.Revision, map[string]any{"id": t.ID, "description": t.Description, "state": t.State, "project_id": t.ProjectID, "revision": t.Revision, "plan": plan}, err
+}
+func result(id string, revision int64, value any) (CoordinatorToolResult, error) {
+ raw, err := json.Marshal(value)
+ if len(raw) > 65536 {
+ return CoordinatorToolResult{}, runnerproto.ErrInvalid
+ }
+ return CoordinatorToolResult{ResourceID: id, Revision: revision, Value: raw}, err
+}
+func (e *Engine) CallCoordinatorTool(ctx context.Context, p RunnerPrincipal, c CoordinatorClaim, call CoordinatorToolCall) (CoordinatorToolResult, error) {
+ call, err := coordinator.Canonical(call)
+ if err != nil {
+ return CoordinatorToolResult{}, err
+ }
+ args, _ := coordinator.Validate(call)
+ var out CoordinatorToolResult
+ err = e.Atomic(ctx, func(ctx context.Context, tx *gorm.DB) error {
+ b, row, err := e.validateCoordinatorClaim(ctx, tx, p, c)
+ if err != nil {
+ return err
+ }
+ if row.State != "running" || row.ProviderSessionID == "" {
+ return e.Conflict
+ }
+ if err = e.Core.ValidateHandle(ctx, c.Scope, c.Handle); err != nil {
+ return err
+ }
+ cs := e.Conversation(tx)
+ actor := Actor{Address: b.Person}
+ // Scope and policy checks also run on replay, before saved content is returned.
+ if err = e.toolScope(tx, cs, row, c.Brief.Selection, args); err != nil {
+ return err
+ }
+ m := Mutation{RequestID: call.RequestID}
+ resource := toolResource(c, row)
+ if ok, err := cs.CoordinatorReplay(actor, "coordinator.tool", resource, m, call, &out); ok || err != nil {
+ return err
+ }
+ var count int64
+ if err = tx.Model(&requestRecord{}).Where("principal=? AND operation='coordinator.tool' AND resource=?", actor.Address, resource).Count(&count).Error; err != nil {
+ return err
+ }
+ if count >= 128 {
+ return e.Invalid
+ }
+ switch a := args.(type) {
+ case *coordinator.ReadProject:
+ rev, source, err := e.Project(tx, p.Person, a.ProjectID, c.Brief.Selection)
+ if err != nil {
+ return err
+ }
+ source.Payload = e.Redact(source.Payload)
+ source.Ref.Hash = team.ContentDigest(source.Payload)
+ out, err = result(strconv.FormatInt(a.ProjectID, 10), rev, source)
+ if err != nil {
+ return err
+ }
+ case *coordinator.ReadTask:
+ source, err := e.toolTaskSource(tx, p.Person, a.TaskID, c.Brief.Selection)
+ if err != nil {
+ return err
+ }
+ out, err = result(a.TaskID, source.Ref.Revision, source)
+ if err != nil {
+ return err
+ }
+ case *coordinator.ProposePlan:
+ if a.Plan.ProjectID == 0 {
+ out, err = cs.ask(row, call.RequestID, coordinator.AskPerson{MessageID: a.MessageID, Question: e.Tools.AmbiguousProject, Options: []coordinator.QuestionOption{}}, e.Now())
+ if err != nil {
+ return err
+ }
+ } else {
+ plan, err := e.Tools.Planning(tx).ProposeCoordinator(actor, b.ID, a.Plan.TaskPlan(), Mutation{RequestID: resource + ":" + call.RequestID}, func(tx *gorm.DB, _ Actor, kind, id string) error { return e.Audit(tx, b, kind, id) })
+ if err != nil {
+ return err
+ }
+ var card cardRecord
+ var thread Thread
+ if err = tx.Where("stream_id=? AND resource_id=? AND kind='task'", row.ConversationID, plan.TaskID).First(&card).Error; err != nil {
+ return err
+ }
+ if err = tx.Model(&messageRecord{}).Where("id=?", card.ID).Select("author_kind", "author_id").Updates(map[string]any{"author_kind": "coordinator", "author_id": "coordinator:" + b.ID}).Error; err != nil {
+ return err
+ }
+ if err = tx.Where("task_id=?", plan.TaskID).First(&thread).Error; err != nil {
+ return err
+ }
+ out, err = result(plan.TaskID, plan.Revision, map[string]any{"plan": plan, "card_id": card.ID, "thread_id": thread.ID, "message_id": a.MessageID, "author": "coordinator:" + b.ID, "delegating_person": b.Person})
+ if err != nil {
+ return err
+ }
+ }
+ case *coordinator.AskPerson:
+ out, err = cs.ask(row, call.RequestID, *a, e.Now())
+ if err != nil {
+ return err
+ }
+ case *coordinator.RouteToTask:
+ routed := *cs
+ routed.deps = cs.deps
+ routed.deps.Audit = func(tx *gorm.DB, _ Actor, kind, id string) error { return e.Audit(tx, b, kind, id) }
+ msg, err := routed.RouteMessage(actor, a.MessageID, a.TaskID, Mutation{RequestID: resource + ":" + call.RequestID})
+ if err != nil {
+ return err
+ }
+ out, err = result(msg.ID, msg.Revision, msg)
+ if err != nil {
+ return err
+ }
+ case *coordinator.PostMessage:
+ var body string
+ if err = json.Unmarshal(e.Redact(mustCoordinatorJSON(a.Body)), &body); err != nil {
+ return err
+ }
+ msg, err := cs.appendMessage(row.ConversationID, row.ConversationID, "", "coordinator", "coordinator:"+b.ID, body, "commentary")
+ if err != nil {
+ return err
+ }
+ out, err = result(msg.ID, msg.Revision, map[string]any{"message": msg, "source_refs": a.SourceRefs})
+ if err != nil {
+ return err
+ }
+ case *coordinator.SuggestPreference, *coordinator.SuggestDraft:
+ out, err = cs.suggest(row, call.Name, args)
+ if err != nil {
+ return err
+ }
+ default:
+ return e.Invalid
+ }
+ if err = e.Audit(tx, b, "coordinator.tool."+call.Name, out.ResourceID); err != nil {
+ return err
+ }
+ var audits []int64
+ if err = tx.Table("audit_events").Where("actor=? AND record_id=?", "coordinator:"+b.ID, out.ResourceID).Order("id").Limit(128).Pluck("id", &audits).Error; err != nil {
+ return err
+ }
+ out.Value, err = json.Marshal(map[string]any{"tool": call.Name, "result": out.Value, "audit_ids": audits})
+ if err != nil || len(out.Value) > 65536 {
+ return e.Invalid
+ }
+ return cs.SaveCoordinatorResult(actor, "coordinator.tool", resource, m, call, out)
+ })
+ return out, err
+}
+func (e *Engine) toolScope(tx *gorm.DB, cs *Store, row TurnRecord, sel runnerproto.Selection, args any) error {
+ message := func(id string) error {
+ var msg messageRecord
+ if err := tx.Where("id=? AND conversation_id=? AND author_kind='person' AND author_id=?", id, row.ConversationID, row.Person).First(&msg).Error; err != nil {
+ return e.StoreError(err)
+ }
+ // Prior requests are not silently repurposed by a later admitted turn.
+ if id != row.MessageID {
+ return e.Forbidden
+ }
+ return nil
+ }
+ project := func(id int64) error { _, err := e.CheckProject(tx, row.Person, id, sel); return err }
+ task := func(id string) error {
+ if e.Tools.Planning == nil {
+ return e.Unavailable
+ }
+ _, _, err := e.readToolTask(tx, row.Person, id, sel)
+ return err
+ }
+ switch a := args.(type) {
+ case *coordinator.ReadProject:
+ return project(a.ProjectID)
+ case *coordinator.ReadTask:
+ return task(a.TaskID)
+ case *coordinator.ProposePlan:
+ if err := message(a.MessageID); err != nil {
+ return err
+ }
+ if a.Plan.ProjectID > 0 {
+ return project(a.Plan.ProjectID)
+ }
+ case *coordinator.AskPerson:
+ return message(a.MessageID)
+ case *coordinator.RouteToTask:
+ if err := message(a.MessageID); err != nil {
+ return err
+ }
+ return task(a.TaskID)
+ case *coordinator.SuggestPreference:
+ return message(a.SourceMessageID)
+ case *coordinator.SuggestDraft:
+ for _, id := range a.SourceMessageIDs {
+ if err := message(id); err != nil {
+ return err
+ }
+ }
+ case *coordinator.PostMessage:
+ for _, ref := range a.SourceRefs {
+ var source runnerproto.SourceSnapshot
+ var err error
+ switch ref.Kind {
+ case "project":
+ id, parseErr := strconv.ParseInt(ref.ID, 10, 64)
+ if parseErr != nil || id <= 0 {
+ return e.Invalid
+ }
+ _, source, err = e.Project(tx, row.Person, id, sel)
+ if err == nil {
+ source.Payload = e.Redact(source.Payload)
+ source.Ref.Hash = team.ContentDigest(source.Payload)
+ }
+ case "task":
+ source, err = e.toolTaskSource(tx, row.Person, ref.ID, sel)
+ default:
+ return e.Invalid
+ }
+ if err != nil {
+ return err
+ }
+ if ref != source.Ref {
+ return e.Conflict
+ }
+ }
+ }
+ return nil
+}
+func (s *Store) ask(row TurnRecord, request string, a coordinator.AskPerson, now time.Time) (CoordinatorToolResult, error) {
+ var old QuestionRecord
+ err := s.tx.Where("binding_id=? AND turn_id=? AND generation=? AND state='pending'", row.BindingID, row.ID, row.Generation).First(&old).Error
+ if err == nil {
+ var q coordinator.ClarificationQuestion
+ if err = json.Unmarshal([]byte(old.Payload), &q); err != nil {
+ return CoordinatorToolResult{}, err
+ }
+ if q.Prompt == a.Question && runnerproto.EventHash(q.Options) == runnerproto.EventHash(a.Options) && now.Before(q.ExpiresAt) {
+ return result(q.ID, q.Revision, q)
+ }
+ if err = s.tx.Model(&QuestionRecord{}).Where("id=?", q.ID).Select("state", "revision").Updates(map[string]any{"state": "superseded", "revision": gorm.Expr("revision+1")}).Error; err != nil {
+ return CoordinatorToolResult{}, err
+ }
+ err = gorm.ErrRecordNotFound
+ }
+ if !errors.Is(err, gorm.ErrRecordNotFound) {
+ return CoordinatorToolResult{}, err
+ }
+ q := coordinator.ClarificationQuestion{ID: rand.Text(), MessageID: a.MessageID, TurnID: row.ID, Prompt: a.Question, Options: a.Options, State: "pending", Revision: 1, Generation: row.Generation, ExpiresAt: now.Add(24 * time.Hour)}
+ raw, err := json.Marshal(q)
+ if err != nil {
+ return CoordinatorToolResult{}, err
+ }
+ rec := QuestionRecord{ID: q.ID, BindingID: row.BindingID, TurnID: row.ID, Person: row.Person, RequestID: request, State: q.State, Payload: string(raw), Generation: row.Generation, Revision: 1}
+ if err = s.tx.Create(&rec).Error; err != nil {
+ return CoordinatorToolResult{}, err
+ }
+ msg, err := s.appendMessage(row.ConversationID, row.ConversationID, "", "coordinator", "coordinator:"+row.BindingID, a.Question, "clarification")
+ if err != nil {
+ return CoordinatorToolResult{}, err
+ }
+ if err = s.tx.Create(&cardRecord{ID: msg.ID, StreamID: row.ConversationID, Kind: "clarification", ResourceID: q.ID, Revision: 1, Sequence: msg.Sequence}).Error; err != nil {
+ return CoordinatorToolResult{}, err
+ }
+ return result(q.ID, 1, q)
+}
+func (s *Store) suggest(row TurnRecord, kind string, value any) (CoordinatorToolResult, error) {
+ raw, err := json.Marshal(value)
+ if err != nil {
+ return CoordinatorToolResult{}, err
+ }
+ msg, err := s.appendMessage(row.ConversationID, row.ConversationID, "", "coordinator", "coordinator:"+row.BindingID, string(raw), "suggestion")
+ if err != nil {
+ return CoordinatorToolResult{}, err
+ }
+ if err = s.tx.Create(&cardRecord{ID: msg.ID, StreamID: row.ConversationID, Kind: kind, ResourceID: msg.ID, Revision: 1, Sequence: msg.Sequence}).Error; err != nil {
+ return CoordinatorToolResult{}, err
+ }
+ return result(msg.ID, 1, value)
+}
+func (s *Store) AnswerClarification(actor Actor, id, optionID, text string, m Mutation, now time.Time) error {
+ b, err := s.Binding(actor)
+ if err != nil {
+ return err
+ }
+ var rec QuestionRecord
+ if err = s.tx.Where("id=? AND binding_id=? AND person=?", id, b.ID, actor.Address).First(&rec).Error; err != nil {
+ return s.deps.NotFound
+ }
+ var q coordinator.ClarificationQuestion
+ if err = json.Unmarshal([]byte(rec.Payload), &q); err != nil {
+ return err
+ }
+ var turn TurnRecord
+ if err = s.tx.First(&turn, "id=?", rec.TurnID).Error; err != nil {
+ return err
+ }
+ if rec.Generation != b.Generation || turn.Generation != b.Generation || (turn.State != "running" && turn.State != "delivered") || !now.Before(q.ExpiresAt) {
+ return s.deps.Conflict
+ }
+ input := struct {
+ Option, Text string
+ Revision int64
+ }{optionID, text, m.Revision}
+ var saved struct{ MessageID, TurnID string }
+ if ok, err := s.CoordinatorReplay(actor, "clarification.answer", id, m, input, &saved); ok || err != nil {
+ return err
+ }
+ if rec.State != "pending" || m.Revision != rec.Revision {
+ return s.deps.Conflict
+ }
+ body := text
+ if optionID != "" {
+ if text != "" {
+ return s.deps.Invalid
+ }
+ found := false
+ for _, o := range q.Options {
+ if o.ID == optionID {
+ body = o.Label
+ found = true
+ }
+ }
+ if !found {
+ return s.deps.Invalid
+ }
+ } else if !coordinator.Text(text, 8192) {
+ return s.deps.Invalid
+ }
+ q.State = "answered"
+ q.Revision++
+ raw, err := json.Marshal(q)
+ if err != nil {
+ return err
+ }
+ if err = s.tx.Model(&QuestionRecord{}).Where("id=?", id).Select("state", "revision", "payload").Updates(map[string]any{"state": q.State, "revision": q.Revision, "payload": string(raw)}).Error; err != nil {
+ return err
+ }
+ if err = s.tx.Model(&cardRecord{}).Where("resource_id=? AND kind='clarification'", id).Select("revision").Updates(map[string]any{"revision": q.Revision}).Error; err != nil {
+ return err
+ }
+ msg, err := s.appendMessage(turn.ConversationID, turn.ConversationID, "", "person", actor.Address, body, "coordinator")
+ if err != nil {
+ return err
+ }
+ next, err := s.QueueCoordinator(actor, msg.ID, turn.ProjectID, Mutation{RequestID: "clarification:" + id})
+ if err != nil {
+ return err
+ }
+ if err = s.deps.Audit(s.tx, actor, "clarification.answer", id); err != nil {
+ return err
+ }
+ saved.MessageID, saved.TurnID = msg.ID, next.ID
+ return s.SaveCoordinatorResult(actor, "clarification.answer", id, m, input, saved)
+}
+
+func (e *Engine) toolTaskSource(tx *gorm.DB, person, id string, sel runnerproto.Selection) (runnerproto.SourceSnapshot, error) {
+ rev, value, err := e.readToolTask(tx, person, id, sel)
+ if err != nil {
+ return runnerproto.SourceSnapshot{}, err
+ }
+ raw, err := json.Marshal(value)
+ if err != nil {
+ return runnerproto.SourceSnapshot{}, err
+ }
+ raw = e.Redact(raw)
+ return runnerproto.SourceSnapshot{Ref: team.SourceRef{Kind: "task", ID: id, Revision: rev, Hash: team.ContentDigest(raw)}, Payload: raw}, nil
+}
diff --git a/internal/equipo/coordinator.go b/internal/equipo/coordinator.go
index da91bc05..0b45217a 100644
--- a/internal/equipo/coordinator.go
+++ b/internal/equipo/coordinator.go
@@ -7,6 +7,7 @@ import (
"context"
"errors"
"gorm.io/gorm"
+ "slices"
"time"
)
@@ -131,14 +132,26 @@ func (s *Store) coordinatorProject(tx *gorm.DB, person string, projectID int64,
if err != nil {
return p, err
}
- allowed := false
- for _, id := range ids {
- if id == sel.ConnectionID {
- allowed = true
- }
- }
- if !allowed || choice.PinnedID != "" && choice.PinnedID != sel.ConnectionID {
+ if !slices.Contains(ids, sel.ConnectionID) || choice.PinnedID != "" && choice.PinnedID != sel.ConnectionID {
return p, ErrForbidden
}
return p, nil
}
+
+type CoordinatorToolCall = runnerproto.CoordinatorToolCall
+type CoordinatorToolResult = runnerproto.CoordinatorToolResult
+type ClarificationQuestion = runnerproto.ClarificationQuestion
+
+func (e *Execution) CallCoordinatorTool(ctx context.Context, p RunnerPrincipal, c CoordinatorClaim, call CoordinatorToolCall) (CoordinatorToolResult, error) {
+ return e.coordinatorEngine().CallCoordinatorTool(ctx, p, c, call)
+}
+func (s *Store) AnswerClarification(ctx context.Context, a Actor, id, optionID, text string, m Mutation) error {
+ a.Address = normalizeAddress(a.Address)
+ return s.write(ctx, func(tx *gorm.DB) error {
+ return conversationAt(tx).AnswerClarification(a, id, optionID, text, m, s.runnerClock.Now().UTC())
+ })
+}
+
+func (e *Execution) PollCoordinator(ctx context.Context, p RunnerPrincipal) ([]CoordinatorTurn, error) {
+ return e.coordinatorEngine().PollCoordinator(ctx, p)
+}
diff --git a/internal/equipo/coordinator_api.go b/internal/equipo/coordinator_api.go
deleted file mode 100644
index c6c4d0cd..00000000
--- a/internal/equipo/coordinator_api.go
+++ /dev/null
@@ -1,7 +0,0 @@
-package equipo
-
-import "context"
-
-func (e *Execution) PollCoordinator(ctx context.Context, p RunnerPrincipal) ([]CoordinatorTurn, error) {
- return e.coordinatorEngine().PollCoordinator(ctx, p)
-}
diff --git a/internal/equipo/coordinator_execution.go b/internal/equipo/coordinator_execution.go
index 02c51afe..bfbf04ec 100644
--- a/internal/equipo/coordinator_execution.go
+++ b/internal/equipo/coordinator_execution.go
@@ -6,14 +6,12 @@ import (
"amadan.net/oficina/equipo/internal/runnerproto"
"context"
"encoding/json"
- "errors"
"gorm.io/gorm"
"time"
)
-func decodeCoordinator(raw string, v any) error { return json.Unmarshal([]byte(raw), v) }
func (e *Execution) coordinatorEngine() *conversation.Engine {
- return &conversation.Engine{Core: e.Core, Atomic: e.atomic, Selection: e.store.coordinatorSelection, StoreError: storeError, NotFound: ErrNotFound, CheckProject: func(tx *gorm.DB, p string, id int64, sel Selection) (int64, error) {
+ return &conversation.Engine{ToolCopy: CoordinatorToolCopy(), Tools: conversation.ToolOperations{AmbiguousProject: pageCopy["coordinator.project_question"], Planning: e.store.planningAt}, Core: e.Core, Atomic: e.atomic, Selection: e.store.coordinatorSelection, StoreError: storeError, NotFound: ErrNotFound, CheckProject: func(tx *gorm.DB, p string, id int64, sel Selection) (int64, error) {
project, err := e.store.coordinatorProject(tx, p, id, sel)
return project.Revision, err
}, Conversation: conversationAt, Now: func() time.Time { return e.store.runnerClock.Now().UTC() }, Audit: coordinatorAudit, Invalid: ErrInvalid, Conflict: ErrConflict, Forbidden: ErrForbidden, Unavailable: ErrUnavailable, WaitingConnection: errCoordinatorWaitingConnection, Events: e.validators.Events, Receipt: e.validators.Receipt, Containment: e.validators.Containment, Delivery: e.validators.CoordinatorDelivery, Redact: func(raw []byte) []byte { return runner.RedactJSON(raw, nil) },
@@ -21,24 +19,7 @@ func (e *Execution) coordinatorEngine() *conversation.Engine {
_, err := runnerPrincipalAt(tx, p, e.store.runnerClock.Now().UTC())
return err
},
- Projects: func(tx *gorm.DB, person string, sel Selection) ([]runnerproto.CoordinatorProject, error) {
- var projects []Project
- if err := tx.Order("id").Find(&projects).Error; err != nil {
- return nil, err
- }
- out := []runnerproto.CoordinatorProject{}
- for _, p := range projects {
- allowed, err := e.store.coordinatorProject(tx, person, p.ID, sel)
- if err != nil {
- if errors.Is(err, ErrForbidden) || errors.Is(err, ErrNotFound) {
- continue
- }
- return nil, err
- }
- out = append(out, runnerproto.CoordinatorProject{ID: allowed.ID, Label: allowed.Name, Revision: allowed.Revision})
- }
- return out, nil
- }, Project: func(tx *gorm.DB, person string, id int64, sel Selection) (int64, runnerproto.SourceSnapshot, error) {
+ Project: func(tx *gorm.DB, person string, id int64, sel Selection) (int64, runnerproto.SourceSnapshot, error) {
p, err := e.store.coordinatorProject(tx, person, id, sel)
if err != nil {
return 0, runnerproto.SourceSnapshot{}, err
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go
index 7166dfda..50d6c8c4 100644
--- a/internal/equipo/copy.go
+++ b/internal/equipo/copy.go
@@ -4,6 +4,7 @@ import (
"sort"
"amadan.net/oficina/equipo/internal/runner"
+ "amadan.net/oficina/equipo/internal/runnerproto"
)
// COPY APPROVED BY DELEGATION (Luna pass, 2026-11-01, house rules).
@@ -47,6 +48,26 @@ const BootLog = "Equipo could not start."
// COPY APPROVED BY DELEGATION (Luna pass, 2026-11-01, house rules).
var pageCopy = map[string]string{
+ // COPY REVIEW REQUIRED: coordinator.tool.read_project
+ "coordinator.tool.read_project": "Read the project material this connection may use.",
+ // COPY REVIEW REQUIRED: coordinator.tool.read_task
+ "coordinator.tool.read_task": "Read a task in an allowed project.",
+ // COPY REVIEW REQUIRED: coordinator.tool.propose_plan
+ "coordinator.tool.propose_plan": "Propose a plan for the current message. Ask which project if it is unclear.",
+ // COPY REVIEW REQUIRED: coordinator.tool.ask_person
+ "coordinator.tool.ask_person": "Ask your person a question for a later turn.",
+ // COPY REVIEW REQUIRED: coordinator.tool.route_to_task
+ "coordinator.tool.route_to_task": "Link the current message to a task requested by your person.",
+ // COPY REVIEW REQUIRED: coordinator.tool.post_message
+ "coordinator.tool.post_message": "Post a message with references to its sources.",
+ // COPY REVIEW REQUIRED: coordinator.tool.suggest_preference
+ "coordinator.tool.suggest_preference": "Suggest a preference for your person to review.",
+ // COPY REVIEW REQUIRED: coordinator.tool.suggest_specialist
+ "coordinator.tool.suggest_specialist": "Suggest a specialist for your person to review.",
+ // COPY REVIEW REQUIRED: coordinator.tool.suggest_playbook
+ "coordinator.tool.suggest_playbook": "Suggest a playbook for your person to review.",
+ // COPY REVIEW REQUIRED: coordinator.project_question
+ "coordinator.project_question": "Which project is this for?",
// COPY REVIEW REQUIRED
"conversation.routed": "Reply added to the task thread.",
// COPY REVIEW REQUIRED
@@ -523,3 +544,8 @@ const CopyRunnerDiagnostic = "Runner error %s at %s.\n"
// COPY REVIEW REQUIRED: conversation.cursor_expired
const copyConversationCursorExpired = "This conversation page has expired. Open the conversation again."
+
+func CoordinatorToolCopy() runnerproto.CoordinatorToolCopy {
+ copy := RunnerToolCopy()
+ return runnerproto.CoordinatorCopy(pageCopy, copy.Accepted, copy.Rejected)
+}
diff --git a/internal/equipo/planning/plans.go b/internal/equipo/planning/plans.go
index 75e275e1..b1fe501c 100644
--- a/internal/equipo/planning/plans.go
+++ b/internal/equipo/planning/plans.go
@@ -73,9 +73,10 @@ type Dependencies struct {
Invalid, Conflict, Forbidden, Unavailable error
}
type Store struct {
- tx *gorm.DB
- ctx context.Context
- deps Dependencies
+ coordinator string
+ tx *gorm.DB
+ ctx context.Context
+ deps Dependencies
}
func New(ctx context.Context, tx *gorm.DB, deps Dependencies) *Store {
@@ -165,7 +166,7 @@ func (s *Store) history(t *Task, p taskplan.Plan, actor kernel.Actor, before *ta
return err
}
changed, _ := json.Marshal(keys)
- return s.tx.Create(&Revision{TaskID: t.ID, Revision: p.Revision, Plan: string(raw), ActorKind: "person", Actor: actor.Address, ChangedKeys: string(changed), CreatedAt: time.Now().UTC()}).Error
+ return s.tx.Create(&Revision{TaskID: t.ID, Revision: p.Revision, Plan: string(raw), ActorKind: s.actorKind(), Actor: s.actorID(actor), ChangedKeys: string(changed), CreatedAt: time.Now().UTC()}).Error
}
func (s *Store) persist(t Task, actor kernel.Actor, kind string) error {
if err := s.tx.Model(&Task{}).Where("id=?", t.ID).Select("ProjectID", "Revision", "JobID", "State", "WaitCode", "BaseCommit", "CheckDefinitionHash", "BaselineTestSetHash", "MergeOwner", "Kind", "PlanRevision", "ApprovalRevision", "ReplacementID").Updates(&t).Error; err != nil {
@@ -319,3 +320,23 @@ func (s *Store) Seed(t Task, actor kernel.Actor) error {
}
return s.tx.Model(&Task{}).Where("id=? AND plan_revision=0", t.ID).Select("Kind", "PlanRevision").Updates(&t).Error
}
+
+func (s *Store) actorKind() string {
+ if s.coordinator != "" {
+ return "coordinator"
+ }
+ return "person"
+}
+func (s *Store) actorID(a kernel.Actor) string {
+ if s.coordinator != "" {
+ return s.coordinator
+ }
+ return a.Address
+}
+func (s *Store) ProposeCoordinator(actor kernel.Actor, binding string, p taskplan.Plan, m kernel.Mutation, audit func(*gorm.DB, kernel.Actor, string, string) error) (taskplan.Plan, error) {
+ copy := *s
+ copy.coordinator = "coordinator:" + binding
+ copy.deps = s.deps
+ copy.deps.Audit = audit
+ return copy.Propose(actor, p, m)
+}
diff --git a/internal/plan3test/coordinator_tools_test.go b/internal/plan3test/coordinator_tools_test.go
new file mode 100644
index 00000000..ee34f2d6
--- /dev/null
+++ b/internal/plan3test/coordinator_tools_test.go
@@ -0,0 +1,246 @@
+package plan3test
+
+import (
+ "amadan.net/oficina/equipo/internal/equipo"
+ "amadan.net/oficina/equipo/internal/equipo/team"
+ "amadan.net/oficina/equipo/internal/runnerproto"
+ "encoding/json"
+ "reflect"
+ "strings"
+ "testing"
+ "time"
+)
+
+func toolCall(t *testing.T, x *equipo.Execution, p equipo.RunnerPrincipal, c equipo.CoordinatorClaim, id, name string, args any) runnerproto.CoordinatorToolResult {
+ t.Helper()
+ raw, err := json.Marshal(args)
+ must(t, err)
+ out, err := x.CallCoordinatorTool(ctx, p, c, runnerproto.CoordinatorToolCall{RequestID: id, Name: name, Arguments: raw})
+ must(t, err)
+ return out
+}
+func claimTools(t *testing.T) (*fixture, *equipo.Execution, equipo.RunnerPrincipal, equipo.CoordinatorClaim) {
+ f, x, p, _ := coordinatorFixture(t)
+ turn := queueCoordinator(t, f, "Please plan this change", "tools")
+ c, err := x.ClaimCoordinator(ctx, p, turn.ID, turn.Revision)
+ must(t, err)
+ // Trusted session event validation belongs to the runner event validator.
+ f.exec(t, "UPDATE coordinator_turns SET provider_session_id='fixture-session' WHERE id=?", turn.ID)
+ return f, x, p, c
+}
+func TestCoordinatorToolScope(t *testing.T) {
+ f, x, p, c := claimTools(t)
+ other, err := f.Store.SendMessage(ctx, peer, "", "private", equipo.Mutation{RequestID: "other"})
+ must(t, err)
+ bad := []runnerproto.CoordinatorToolCall{
+ {RequestID: "other", Name: "suggest_preference", Arguments: json.RawMessage(`{"source_message_id":"` + other.ID + `","text":"private"}`)},
+ {RequestID: "fields", Name: "post_message", Arguments: json.RawMessage(`{"body":"hi","source_refs":[],"person":"other"}`)},
+ }
+ for _, call := range bad {
+ if _, err = x.CallCoordinatorTool(ctx, p, c, call); err == nil {
+ t.Fatal("unauthorized tool accepted", call)
+ }
+ }
+ call := runnerproto.CoordinatorToolCall{RequestID: "same", Name: "post_message", Arguments: json.RawMessage(`{"body":"hi","source_refs":[]}`)}
+ _, err = x.CallCoordinatorTool(ctx, p, c, call)
+ must(t, err)
+ call.Arguments = json.RawMessage(`{"body":"changed","source_refs":[]}`)
+ if _, err = x.CallCoordinatorTool(ctx, p, c, call); err == nil {
+ t.Fatal("changed replay accepted")
+ }
+ for _, change := range []func(*equipo.CoordinatorClaim){func(c *equipo.CoordinatorClaim) { c.Handle.Fence++ }, func(c *equipo.CoordinatorClaim) { c.Turn.ID = "wrong" }} {
+ bad := c
+ change(&bad)
+ if _, err = x.CallCoordinatorTool(ctx, p, bad, call); err == nil {
+ t.Fatal("wrong claim accepted")
+ }
+ }
+ f.exec(t, `UPDATE connection_choices SET connection_ids_json='["codex"]',pinned_id='codex'`)
+ var project int64
+ must(t, f.DB.Writer().QueryRow("SELECT id FROM projects LIMIT 1").Scan(&project))
+ raw, _ := json.Marshal(map[string]any{"project_id": project})
+ if _, err = x.CallCoordinatorTool(ctx, p, c, runnerproto.CoordinatorToolCall{RequestID: "project", Name: "read_project", Arguments: raw}); err == nil {
+ t.Fatal("restricted project disclosed")
+ }
+ f.exec(t, "UPDATE members SET active=0 WHERE address=?", owner.Address)
+ call.Arguments = json.RawMessage(`{"body":"hi","source_refs":[]}`)
+ if _, err = x.CallCoordinatorTool(ctx, p, c, call); err == nil {
+ t.Fatal("revoked member replay accepted")
+ }
+}
+func proposalArgs(message string, project int64) map[string]any {
+ return map[string]any{"message_id": message, "plan": map[string]any{"kind": "recommendation", "project_id": project, "steps": []any{map[string]any{"key": "research", "specialist": "product", "action": "recommend", "instructions": "Find improvements"}, map[string]any{"key": "merge", "action": "person"}}}}
+}
+func TestCoordinatorProjectInference(t *testing.T) {
+ f, x, p, c := claimTools(t)
+ before := f.count(t, "SELECT count(*) FROM tasks")
+ q := toolCall(t, x, p, c, "ambiguous", "propose_plan", proposalArgs(c.Turn.MessageID, 0))
+ if f.count(t, "SELECT count(*) FROM tasks") != before || f.count(t, "SELECT count(*) FROM coordinator_questions WHERE state='pending'") != 1 {
+ t.Fatal("ambiguous proposal created task or omitted question")
+ }
+ again := toolCall(t, x, p, c, "ambiguous-2", "propose_plan", proposalArgs(c.Turn.MessageID, 0))
+ if again.ResourceID != q.ResourceID {
+ t.Fatal("duplicate ambiguity question")
+ }
+ var project int64
+ must(t, f.DB.Writer().QueryRow("SELECT id FROM projects LIMIT 1").Scan(&project))
+ result := toolCall(t, x, p, c, "inferred", "propose_plan", proposalArgs(c.Turn.MessageID, project))
+ if f.count(t, "SELECT count(*) FROM conversation_messages WHERE author_kind='coordinator' AND author_id=? AND id IN (SELECT id FROM conversation_cards WHERE resource_id=?)", "coordinator:"+c.Binding.ID, result.ResourceID) != 1 {
+ t.Fatal("proposal card lacks visible coordinator attribution")
+ }
+ if f.count(t, "SELECT count(*) FROM plan_revisions WHERE task_id=? AND actor_kind='coordinator' AND actor=?", result.ResourceID, "coordinator:"+c.Binding.ID) != 1 {
+ t.Fatal("proposal attribution absent")
+ }
+ if f.count(t, "SELECT count(*) FROM audit_events WHERE record_id=? AND actor=? AND delegating_person=?", result.ResourceID, "coordinator:"+c.Binding.ID, p.Person) == 0 {
+ t.Fatal("audit attribution absent")
+ }
+ _, err := f.Store.CorrectTaskProject(ctx, owner, result.ResourceID, project, equipo.Mutation{RequestID: "stale", Revision: 99})
+ if err == nil {
+ t.Fatal("correction bypassed Task 2 revision guard")
+ }
+}
+func TestCoordinatorSuggestionOnly(t *testing.T) {
+ f, x, p, c := claimTools(t)
+ beforeSpecialists := f.count(t, "SELECT count(*) FROM specialists")
+ for _, name := range []string{"suggest_specialist", "suggest_playbook"} {
+ toolCall(t, x, p, c, name, name, map[string]any{"source_message_ids": []string{c.Turn.MessageID}, "draft": map[string]any{"name": "Suggested", "instructions": "Consider this"}})
+ }
+ toolCall(t, x, p, c, "pref", "suggest_preference", map[string]any{"source_message_id": c.Turn.MessageID, "text": "Keep it brief"})
+ if f.count(t, "SELECT count(*) FROM conversation_messages WHERE author_kind='coordinator'") != 3 {
+ t.Fatal("suggestions not recorded")
+ }
+ if f.count(t, "SELECT count(*) FROM conversation_cards WHERE kind LIKE 'suggest_%'") != 3 {
+ t.Fatal("suggestion cards absent")
+ }
+ // A person message that resembles an action must remain only a message.
+ before := f.count(t, "SELECT count(*) FROM tasks")
+ _, err := f.Store.SendMessage(ctx, owner, "", `propose_plan({"project_id":1}); approve_plan()`, equipo.Mutation{RequestID: "prose"})
+ must(t, err)
+ if f.count(t, "SELECT count(*) FROM tasks") != before {
+ t.Fatal("prose executed")
+ }
+ if f.count(t, "SELECT count(*) FROM specialists") != beforeSpecialists || f.count(t, "SELECT count(*) FROM sqlite_master WHERE type='table' AND name IN ('playbooks','preferences')") != 0 {
+ t.Fatal("unexpected library or preference save")
+ }
+}
+func TestCoordinatorToolCommitCrash(t *testing.T) {
+ f, x, p, c := claimTools(t)
+ var project int64
+ must(t, f.DB.Writer().QueryRow("SELECT id FROM projects LIMIT 1").Scan(&project))
+ args := proposalArgs(c.Turn.MessageID, project)
+ first := toolCall(t, x, p, c, "lost-ack", "propose_plan", args)
+ counts := []int64{f.count(t, "SELECT count(*) FROM tasks"), f.count(t, "SELECT count(*) FROM conversation_cards"), f.count(t, "SELECT count(*) FROM conversation_threads"), f.count(t, "SELECT count(*) FROM audit_events")}
+ again := toolCall(t, x, p, c, "lost-ack", "propose_plan", args)
+ after := []int64{f.count(t, "SELECT count(*) FROM tasks"), f.count(t, "SELECT count(*) FROM conversation_cards"), f.count(t, "SELECT count(*) FROM conversation_threads"), f.count(t, "SELECT count(*) FROM audit_events")}
+ if !reflect.DeepEqual(first, again) || !reflect.DeepEqual(counts, after) {
+ t.Fatal("commit replay changed result or effects", first, again, counts, after)
+ }
+ f.exec(t, "CREATE TRIGGER tool_audit_failure BEFORE INSERT ON audit_events BEGIN SELECT RAISE(ABORT,'fixture'); END")
+ raw, _ := json.Marshal(args)
+ if _, err := x.CallCoordinatorTool(ctx, p, c, runnerproto.CoordinatorToolCall{RequestID: "rollback", Name: "propose_plan", Arguments: raw}); err == nil {
+ t.Fatal("audit failure ignored")
+ }
+ if f.count(t, "SELECT count(*) FROM tasks") != counts[0] {
+ t.Fatal("tool partially committed")
+ }
+}
+func TestCoordinatorToolClarification(t *testing.T) {
+ f, x, p, c := claimTools(t)
+ q := toolCall(t, x, p, c, "question", "ask_person", map[string]any{"message_id": c.Turn.MessageID, "question": "Which project?", "options": []map[string]string{{"id": "one", "label": "First"}}})
+ if err := f.Store.AnswerClarification(ctx, peer, q.ResourceID, "one", "", equipo.Mutation{RequestID: "foreign", Revision: 1}); err == nil {
+ t.Fatal("other person answered")
+ }
+ if err := f.Store.AnswerClarification(ctx, owner, q.ResourceID, "bad", "", equipo.Mutation{RequestID: "bad", Revision: 1}); err == nil {
+ t.Fatal("undeclared option accepted")
+ }
+ f.exec(t, "UPDATE coordinator_turns SET state='delivered' WHERE id=?", c.Turn.ID)
+ must(t, f.Store.AnswerClarification(ctx, owner, q.ResourceID, "one", "", equipo.Mutation{RequestID: "answer", Revision: 1}))
+ must(t, f.Store.AnswerClarification(ctx, owner, q.ResourceID, "one", "", equipo.Mutation{RequestID: "answer", Revision: 1}))
+ if err := f.Store.AnswerClarification(ctx, owner, q.ResourceID, "one", "", equipo.Mutation{RequestID: "answer-again", Revision: 1}); err == nil {
+ t.Fatal("answered twice")
+ }
+ if f.count(t, "SELECT count(*) FROM coordinator_turns WHERE state='queued'") != 1 {
+ t.Fatal("answer did not queue fresh turn")
+ }
+}
+
+func TestCoordinatorToolClarificationInvalidation(t *testing.T) {
+ for _, change := range []string{"expiry", "generation", "replacement", "lookup"} {
+ t.Run(change, func(t *testing.T) {
+ f, x, p, c := claimTools(t)
+ q := toolCall(t, x, p, c, "q", "ask_person", map[string]any{"message_id": c.Turn.MessageID, "question": "More detail?", "options": []any{}})
+ switch change {
+ case "expiry":
+ f.exec(t, `UPDATE coordinator_questions SET payload=json_set(payload,'$.ExpiresAt','2000-01-01T00:00:00Z')`)
+ case "generation":
+ f.exec(t, "UPDATE coordinator_bindings SET generation=generation+1")
+ case "replacement":
+ f.exec(t, "UPDATE coordinator_turns SET state='superseded'")
+ case "lookup":
+ f.exec(t, "ALTER TABLE members RENAME TO unavailable_members")
+ }
+ if err := f.Store.AnswerClarification(ctx, owner, q.ResourceID, "", "answer", equipo.Mutation{RequestID: "answer", Revision: 1}); err == nil {
+ t.Fatal("invalid clarification answered", change)
+ }
+ if f.count(t, "SELECT count(*) FROM coordinator_turns WHERE state='queued'") != 0 {
+ t.Fatal("invalid answer queued turn")
+ }
+ })
+ }
+}
+
+func TestCoordinatorToolDelivery(t *testing.T) {
+ f, x, p, c := claimTools(t)
+ out := toolCall(t, x, p, c, "post", "post_message", map[string]any{"body": "Recorded answer", "source_refs": []team.SourceRef{}})
+ event := runnerproto.Event{Version: 2, ID: "delivery", TaskID: c.Turn.ID, AssignmentID: c.Turn.ID, ServerID: "fixture", AgentID: "fixture", SessionID: "fixture-session", TurnID: c.Turn.ID, Kind: "coordinator.delivery", Scope: c.Scope, Handle: c.Handle, ActionID: c.Admission.Dispatch.Action, SourceTime: time.Now().UTC()}
+ event.Payload = json.RawMessage(`{"request_id":"post","resource_id":"` + out.ResourceID + `"}`)
+ if err := x.CompleteCoordinator(ctx, p, c, event); err == nil {
+ t.Fatal("missing trusted receipt delivered")
+ }
+ must(t, x.Core.Record(ctx, c.Scope, c.Admission.Dispatch.Action, team.Receipt{ID: "receipt", Outcome: team.OutcomeSuccess}))
+ forged := event
+ forged.Payload = json.RawMessage(`{"request_id":"post","resource_id":"forged"}`)
+ if err := x.CompleteCoordinator(ctx, p, c, forged); err == nil {
+ t.Fatal("forged delivery accepted")
+ }
+ must(t, x.CompleteCoordinator(ctx, p, c, event))
+ must(t, x.CompleteCoordinator(ctx, p, c, event))
+ if f.count(t, "SELECT count(*) FROM conversation_messages WHERE author_kind='coordinator' AND body='Recorded answer'") != 1 {
+ t.Fatal("delivery duplicated tool message")
+ }
+ if f.count(t, "SELECT count(*) FROM coordinator_turns WHERE state='delivered'") != 1 {
+ t.Fatal("durable effect did not deliver")
+ }
+}
+
+func TestCoordinatorToolQuestionReplacement(t *testing.T) {
+ f, x, p, c := claimTools(t)
+ first := toolCall(t, x, p, c, "first", "ask_person", map[string]any{"message_id": c.Turn.MessageID, "question": "First question?", "options": []any{}})
+ second := toolCall(t, x, p, c, "second", "ask_person", map[string]any{"message_id": c.Turn.MessageID, "question": "Replacement question?", "options": []any{}})
+ if first.ResourceID == second.ResourceID {
+ t.Fatal("different question reused pending clarification")
+ }
+ if err := f.Store.AnswerClarification(ctx, owner, first.ResourceID, "", "old", equipo.Mutation{RequestID: "old-answer", Revision: 1}); err == nil {
+ t.Fatal("replaced question answered")
+ }
+ must(t, f.Store.AnswerClarification(ctx, owner, second.ResourceID, "", "new", equipo.Mutation{RequestID: "new-answer", Revision: 1}))
+}
+
+func TestCoordinatorToolSources(t *testing.T) {
+ f, x, p, c := claimTools(t)
+ var project int64
+ must(t, f.DB.Writer().QueryRow("SELECT id FROM projects LIMIT 1").Scan(&project))
+ read := toolCall(t, x, p, c, "read", "read_project", map[string]any{"project_id": project})
+ var value struct {
+ Result runnerproto.SourceSnapshot `json:"result"`
+ }
+ must(t, json.Unmarshal(read.Value, &value))
+ args := map[string]any{"body": "Project recommendation", "source_refs": []team.SourceRef{value.Result.Ref}}
+ toolCall(t, x, p, c, "sourced", "post_message", args)
+ value.Result.Ref.Hash = strings.Repeat("0", 64)
+ args["source_refs"] = []team.SourceRef{value.Result.Ref}
+ raw, _ := json.Marshal(args)
+ if _, err := x.CallCoordinatorTool(ctx, p, c, runnerproto.CoordinatorToolCall{RequestID: "forged-source", Name: "post_message", Arguments: raw}); err == nil {
+ t.Fatal("forged source accepted")
+ }
+}
diff --git a/internal/release/manifest.json b/internal/release/manifest.json
index 807d4b08..22cf80e1 100644
--- a/internal/release/manifest.json
+++ b/internal/release/manifest.json
@@ -114,13 +114,13 @@
{
"provider": "claude",
"action": "coordinate",
- "inventory_hash": "0d4014b45648a34a48b35bdc37416dd440e7be2def55ce34b7cc93c5af1bf5d3",
+ "inventory_hash": "fc32844140a0a086c644c62909650c7e12bfdff9d4b4bf75f55938151089ce69",
"status": "uncertified"
},
{
"provider": "codex",
"action": "coordinate",
- "inventory_hash": "046ad41840ffb70ab541b5543644ee43f5fd4e14b539504126a8e8ba195ef28a",
+ "inventory_hash": "4c910ce3627df86de9114cbf3eb7007052ef711c06c97551f62e612eb88b6317",
"status": "uncertified"
}
]
diff --git a/internal/runner/capture.go b/internal/runner/capture.go
index 467cb7b4..77a54e16 100644
--- a/internal/runner/capture.go
+++ b/internal/runner/capture.go
@@ -19,7 +19,7 @@ import (
const MaxFrameBytes = 1 << 20
const maxDiagnostics = 64 << 10
-const directPendingSize = `((SELECT COALESCE(SUM(size),0) FROM journal_events WHERE acked=0)+(SELECT COALESCE(SUM(length(body)),0) FROM journal_tools WHERE acked=0)+(SELECT COALESCE(SUM(length(body)),0) FROM direct_frames WHERE pending=1)+(SELECT COALESCE(SUM(length(body)),0) FROM direct_events WHERE projected=0))`
+const directPendingSize = `((SELECT COALESCE(SUM(length(body)+COALESCE(length(result),0)),0) FROM coordinator_tools)+(SELECT COALESCE(SUM(size),0) FROM journal_events WHERE acked=0)+(SELECT COALESCE(SUM(length(body)),0) FROM journal_tools WHERE acked=0)+(SELECT COALESCE(SUM(length(body)),0) FROM direct_frames WHERE pending=1)+(SELECT COALESCE(SUM(length(body)),0) FROM direct_events WHERE projected=0))`
type captureFactory struct{ journal *Journal }
diff --git a/internal/runner/containment/mounts.go b/internal/runner/containment/mounts.go
index d799bf98..c846ee22 100644
--- a/internal/runner/containment/mounts.go
+++ b/internal/runner/containment/mounts.go
@@ -111,7 +111,9 @@ func (m *Manager) mountPlan(l provider.Launch, dir string) (_ *mounts, err error
}
p.args = append(p.args, "--overlay-src", "/etc", "--tmp-overlay", "/etc")
p.args = append(p.args, "--symlink", "usr/bin", "/bin", "--symlink", "usr/lib", "/lib", "--symlink", "usr/lib64", "/lib64", "--proc", "/proc", "--dev", "/dev", "--dir", "/run", "--dir", "/sys", "--dir", "/home/runner", "--tmpfs", "/etc/claude-code", "--tmpfs", "/etc/codex")
- if err = p.bind(l.Workspace, "/workspace", l.Policy.ReadOnlyWorkspace(), true); err != nil {
+ if l.Policy.Coordinator() {
+ p.args = append(p.args, "--tmpfs", "/workspace", "--remount-ro", "/workspace")
+ } else if err = p.bind(l.Workspace, "/workspace", l.Policy.ReadOnlyWorkspace(), true); err != nil {
return nil, err
}
runtimeHome := filepath.Join(dir, "home")
diff --git a/internal/runner/containment/mounts_test.go b/internal/runner/containment/mounts_test.go
index 30d490e8..39cbf4e2 100644
--- a/internal/runner/containment/mounts_test.go
+++ b/internal/runner/containment/mounts_test.go
@@ -2,9 +2,13 @@ package containment
import (
"context"
+ "crypto/sha256"
+ "encoding/hex"
+ "fmt"
"io"
"os"
"path/filepath"
+ "strings"
"testing"
)
@@ -111,3 +115,48 @@ func TestNamespaceClaudeEnvironment(t *testing.T) {
t.Fatal("unsupported updater environment accepted")
}
}
+
+func TestCoordinatorToolNoCheckout(t *testing.T) {
+ m, l := fixture(t)
+ l.Policy.Manifest = []byte(`{"Action":"coordinate"}`)
+ hash := sha256.Sum256(l.Policy.Manifest)
+ l.Policy.ManifestHash = hex.EncodeToString(hash[:])
+ dir, err := os.MkdirTemp(m.cfg.ScratchRoot, "coordinator-")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(dir)
+ for _, name := range []string{"tmp", "home"} {
+ if err = os.Mkdir(filepath.Join(dir, name), 0700); err != nil {
+ t.Fatal(err)
+ }
+ }
+ plan, err := m.mountPlan(l, dir)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer plan.close()
+ for i, arg := range plan.args {
+ if arg == "/workspace" && i > 0 && strings.Contains(plan.args[i-1], "bind") {
+ t.Fatal("checkout mounted")
+ }
+ }
+ found := false
+ for i, arg := range plan.args {
+ if arg == "--tmpfs" && i+1 < len(plan.args) && plan.args[i+1] == "/workspace" {
+ found = true
+ }
+ }
+ if !found {
+ t.Fatal("empty workspace absent")
+ }
+ for _, f := range plan.files {
+ name, err := os.Readlink(fmt.Sprintf("/proc/self/fd/%d", f.Fd()))
+ if err != nil {
+ t.Fatal(err)
+ }
+ if name == l.Workspace {
+ t.Fatal("checkout descriptor passed to namespace")
+ }
+ }
+}
diff --git a/internal/runner/coordinator_tool_journal.go b/internal/runner/coordinator_tool_journal.go
new file mode 100644
index 00000000..71540308
--- /dev/null
+++ b/internal/runner/coordinator_tool_journal.go
@@ -0,0 +1,134 @@
+package runner
+
+import (
+ "context"
+ "database/sql"
+ "encoding/json"
+ "errors"
+
+ "amadan.net/oficina/equipo/internal/coordinator"
+ "amadan.net/oficina/equipo/internal/runner/provider"
+ "amadan.net/oficina/equipo/internal/runnerproto"
+)
+
+type CoordinatorToolSubmission struct {
+ Claim runnerproto.CoordinatorClaim `json:"claim"`
+ Session provider.Session `json:"session"`
+ Call runnerproto.CoordinatorToolCall `json:"call"`
+}
+
+func coordinatorToolKey(c runnerproto.CoordinatorClaim, call runnerproto.CoordinatorToolCall) string {
+ return runnerproto.EventHash([]any{c.Scope.Account, c.Binding.ID, c.Binding.Generation, c.Turn.ID, c.Handle.Attempt, c.Handle.Fence, call.RequestID})
+}
+func (j *Journal) reserveCoordinatorTool(ctx context.Context, c runnerproto.CoordinatorClaim, s provider.Session, call runnerproto.CoordinatorToolCall) error {
+ call, err := coordinator.Canonical(call)
+ if err != nil {
+ return err
+ }
+ v := CoordinatorToolSubmission{Claim: c, Session: s, Call: call}
+ raw, err := json.Marshal(v)
+ if err != nil {
+ return err
+ }
+ key, hash := coordinatorToolKey(c, call), runnerproto.EventHash(v)
+ if err = j.AdmissionAllowed(ctx); err != nil {
+ return err
+ }
+ tx, err := j.db.BeginTx(ctx, nil)
+ if err != nil {
+ return j.storageFailure(ctx, err)
+ }
+ defer tx.Rollback()
+ var old string
+ err = tx.QueryRowContext(ctx, "SELECT content_hash FROM coordinator_tools WHERE request_key=?", key).Scan(&old)
+ if err == nil {
+ if old != hash {
+ return runnerproto.ErrInvalid
+ }
+ return nil
+ }
+ if !errors.Is(err, sql.ErrNoRows) {
+ return err
+ }
+ var size, count int64
+ if err = tx.QueryRowContext(ctx, "SELECT "+directPendingSize).Scan(&size); err != nil {
+ return err
+ }
+ if err = tx.QueryRowContext(ctx, "SELECT count(*) FROM coordinator_tools WHERE binding=? AND generation=? AND turn=?", c.Binding.ID, c.Binding.Generation, c.Turn.ID).Scan(&count); err != nil {
+ return err
+ }
+ if count >= 128 || size+int64(len(raw)) > j.maxBytes {
+ return ErrJournal
+ }
+ if _, err = tx.ExecContext(ctx, "INSERT INTO coordinator_tools(request_key,content_hash,binding,generation,turn,body,result,acked) VALUES(?,?,?,?,?,?,NULL,0)", key, hash, c.Binding.ID, c.Binding.Generation, c.Turn.ID, raw); err != nil {
+ return err
+ }
+ return tx.Commit()
+}
+func (j *Journal) ackCoordinatorTool(ctx context.Context, c runnerproto.CoordinatorClaim, s provider.Session, call runnerproto.CoordinatorToolCall, result runnerproto.CoordinatorToolResult) error {
+ if err := j.reserveCoordinatorTool(ctx, c, s, call); err != nil {
+ return err
+ }
+ raw, err := json.Marshal(result)
+ if err != nil || len(raw) > 65536 || result.ResourceID == "" || result.Revision < 1 || !json.Valid(result.Value) {
+ return runnerproto.ErrInvalid
+ }
+ key := coordinatorToolKey(c, call)
+ tx, err := j.db.BeginTx(ctx, nil)
+ if err != nil {
+ return j.storageFailure(ctx, err)
+ }
+ defer tx.Rollback()
+ var old []byte
+ if err = tx.QueryRowContext(ctx, "SELECT result FROM coordinator_tools WHERE request_key=?", key).Scan(&old); err != nil {
+ return err
+ }
+ if len(old) > 0 && !runnerproto.SameRequestJSON(old, raw) {
+ return runnerproto.ErrInvalid
+ }
+ var size int64
+ if err = tx.QueryRowContext(ctx, "SELECT "+directPendingSize).Scan(&size); err != nil {
+ return err
+ }
+ if size+int64(len(raw)) > j.maxBytes {
+ return ErrJournal
+ }
+ if _, err = tx.ExecContext(ctx, "UPDATE coordinator_tools SET result=?,acked=1 WHERE request_key=?", raw, key); err != nil {
+ return err
+ }
+ return tx.Commit()
+}
+func (j *Journal) CoordinatorToolSubmissions(ctx context.Context, limit int) ([]CoordinatorToolSubmission, error) {
+ if limit < 1 || limit > 128 {
+ return nil, runnerproto.ErrInvalid
+ }
+ rows, err := j.db.QueryContext(ctx, "SELECT body FROM coordinator_tools WHERE acked=0 AND submitted=1 ORDER BY ordinal LIMIT ?", limit)
+ if err != nil {
+ return nil, err
+ }
+ defer rows.Close()
+ out := []CoordinatorToolSubmission{}
+ for rows.Next() {
+ var raw []byte
+ var v CoordinatorToolSubmission
+ if err = rows.Scan(&raw); err != nil {
+ return nil, err
+ }
+ if err = json.Unmarshal(raw, &v); err != nil {
+ return nil, err
+ }
+ out = append(out, v)
+ }
+ return out, rows.Err()
+}
+
+func (j *Journal) submitCoordinatorTool(ctx context.Context, c runnerproto.CoordinatorClaim, s provider.Session, call runnerproto.CoordinatorToolCall) error {
+ if err := j.reserveCoordinatorTool(ctx, c, s, call); err != nil {
+ return err
+ }
+ _, err := j.db.ExecContext(ctx, "UPDATE coordinator_tools SET submitted=1 WHERE request_key=?", coordinatorToolKey(c, call))
+ if err != nil {
+ return j.storageFailure(ctx, err)
+ }
+ return nil
+}
diff --git a/internal/runner/coordinator_tool_proxy.go b/internal/runner/coordinator_tool_proxy.go
new file mode 100644
index 00000000..67cb04fa
--- /dev/null
+++ b/internal/runner/coordinator_tool_proxy.go
@@ -0,0 +1,267 @@
+package runner
+
+import (
+ "bytes"
+ "context"
+ "encoding/json"
+ "fmt"
+ "net"
+ "os"
+ "path/filepath"
+ "strings"
+ "sync"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/coordinator"
+ "amadan.net/oficina/equipo/internal/runner/provider"
+ "amadan.net/oficina/equipo/internal/runner/provider/codex"
+ "amadan.net/oficina/equipo/internal/runnerproto"
+)
+
+type CoordinatorToolBinding struct {
+ Claim runnerproto.CoordinatorClaim
+ Session provider.Session
+ Journal *Journal
+ Current func(context.Context) error
+ Call func(context.Context, runnerproto.CoordinatorToolCall) (runnerproto.CoordinatorToolResult, error)
+}
+type coordinatorBroker struct {
+ mu sync.Mutex
+ binding CoordinatorToolBinding
+ invalid bool
+ deadline time.Time
+}
+
+func OpenCoordinatorToolProxy(ctx context.Context, b CoordinatorToolBinding) (*ToolProxy, error) {
+ c := b.Claim
+ if b.Journal == nil || b.Current == nil || b.Call == nil || c.Binding.ID == "" || c.Binding.Generation < 1 || c.Turn.ID == "" || c.Turn.Generation != c.Binding.Generation || c.Scope.Account == "" || c.Handle.Attempt <= 0 || c.Handle.Fence <= 0 || c.Brief.Target.Repository != "" || c.Brief.Selection.Isolation.Status != "confined" || !time.Now().Before(c.LeaseDeadline) || !time.Now().Before(c.AttemptDeadline) {
+ return nil, runnerproto.ErrInvalid
+ }
+ if err := b.Current(ctx); err != nil {
+ return nil, err
+ }
+ root := filepath.Dir(b.Journal.path)
+ parent, err := openPrivateDir(root)
+ if err != nil {
+ return nil, err
+ }
+ parent.Close()
+ dir, err := os.MkdirTemp(root, "coordinator-tool-")
+ if err != nil {
+ return nil, err
+ }
+ ok := false
+ defer func() {
+ if !ok {
+ os.Remove(filepath.Join(dir, "equipo.sock"))
+ os.Remove(dir)
+ }
+ }()
+ fd, err := openPrivateDir(dir)
+ if err != nil {
+ return nil, err
+ }
+ defer fd.Close()
+ path := filepath.Join(dir, "equipo.sock")
+ listener, err := net.ListenUnix("unix", &net.UnixAddr{Name: fmt.Sprintf("/proc/self/fd/%d/equipo.sock", fd.Fd()), Net: "unix"})
+ if err != nil {
+ return nil, err
+ }
+ listener.SetUnlinkOnClose(false)
+ if err = os.Chmod(path, 0600); err != nil {
+ listener.Close()
+ return nil, err
+ }
+ ctx, cancel := context.WithCancel(ctx)
+ p := &ToolProxy{SocketPath: path, listener: listener, ctx: ctx, cancel: cancel, directory: dir, coordinator: &coordinatorBroker{binding: b, deadline: c.LeaseDeadline}}
+ p.workers.Add(1)
+ go p.accept()
+ context.AfterFunc(ctx, func() { _ = p.Close() })
+ p.workers.Add(1)
+ go func() {
+ defer p.workers.Done()
+ tick := time.NewTicker(100 * time.Millisecond)
+ defer tick.Stop()
+ for {
+ select {
+ case <-ctx.Done():
+ return
+ case <-tick.C:
+ if err := p.coordinator.current(ctx, false); err != nil {
+ cancel()
+ return
+ }
+ }
+ }
+ }()
+ ok = true
+ return p, nil
+}
+func (b *coordinatorBroker) current(ctx context.Context, dispatched bool) error {
+ b.mu.Lock()
+ v, invalid, deadline := b.binding, b.invalid, b.deadline
+ b.mu.Unlock()
+ if invalid || ctx.Err() != nil || !time.Now().Before(deadline) || !time.Now().Before(v.Claim.AttemptDeadline) {
+ return runnerproto.ErrInvalid
+ }
+ if err := v.Current(ctx); err != nil {
+ b.mu.Lock()
+ b.invalid = true
+ b.mu.Unlock()
+ return err
+ }
+ if v.Session.ID != "" {
+ if v.Session.Provider != v.Claim.Brief.Selection.Provider || v.Session.AccountID != v.Claim.Brief.Selection.AccountID || v.Session.Model != v.Claim.Brief.Selection.Model {
+ return runnerproto.ErrInvalid
+ }
+ if dispatched {
+ if err := v.Journal.currentDirectTurn(ctx, v.Session, v.Claim.Turn.ID); err != nil {
+ return err
+ }
+ }
+ } else if dispatched {
+ return runnerproto.ErrInvalid
+ }
+ return v.Journal.AdmissionAllowed(ctx)
+}
+func (p *ToolProxy) bindCoordinator(session provider.Session, turn string) error {
+ b := p.coordinator
+ if err := b.current(p.ctx, false); err != nil {
+ return err
+ }
+ b.mu.Lock()
+ defer b.mu.Unlock()
+ if turn != b.binding.Claim.Turn.ID || session.ID == "" || session.AttemptKey == "" || session.Provider != b.binding.Claim.Brief.Selection.Provider || session.AccountID != b.binding.Claim.Brief.Selection.AccountID || session.Model != b.binding.Claim.Brief.Selection.Model || (b.binding.Session.ID != "" && b.binding.Session != session) {
+ return runnerproto.ErrInvalid
+ }
+ var saved string
+ var recovered int
+ if err := b.binding.Journal.db.QueryRowContext(p.ctx, "SELECT session,recovered FROM direct_attempts WHERE attempt=?", session.AttemptKey).Scan(&saved, &recovered); err != nil || saved != session.ID || recovered != 0 {
+ return runnerproto.ErrInvalid
+ }
+ b.binding.Session = session
+ return nil
+}
+func (p *ToolProxy) ValidateCoordinatorApproval(ctx context.Context, call runnerproto.CoordinatorToolCall) error {
+ b := p.coordinator
+ if b == nil {
+ return runnerproto.ErrInvalid
+ }
+ if err := b.current(ctx, true); err != nil {
+ return err
+ }
+ b.mu.Lock()
+ v := b.binding
+ b.mu.Unlock()
+ return v.Journal.reserveCoordinatorTool(ctx, v.Claim, v.Session, call)
+}
+func (p *ToolProxy) CallCoordinatorTool(ctx context.Context, call runnerproto.CoordinatorToolCall) (runnerproto.CoordinatorToolResult, error) {
+ var zero runnerproto.CoordinatorToolResult
+ if err := p.ValidateCoordinatorApproval(ctx, call); err != nil {
+ return zero, err
+ }
+ b := p.coordinator
+ b.mu.Lock()
+ v := b.binding
+ b.mu.Unlock()
+ if err := v.Journal.submitCoordinatorTool(ctx, v.Claim, v.Session, call); err != nil {
+ return zero, err
+ }
+ // Always revisit instance authority, including acknowledged local replays.
+ out, err := v.Call(ctx, call)
+ if err != nil {
+ return zero, err
+ }
+ if err = b.current(ctx, true); err != nil {
+ return zero, err
+ }
+ if err = v.Journal.ackCoordinatorTool(ctx, v.Claim, v.Session, call, out); err != nil {
+ return zero, err
+ }
+ return out, nil
+}
+func coordinatorMCPCall(name string, raw json.RawMessage) (runnerproto.CoordinatorToolCall, error) {
+ var fields map[string]json.RawMessage
+ if runnerproto.DecodeLimit(bytes.NewReader(raw), &fields, maxToolFrame) != nil {
+ return runnerproto.CoordinatorToolCall{}, runnerproto.ErrInvalid
+ }
+ var id string
+ if json.Unmarshal(fields["request_id"], &id) != nil {
+ return runnerproto.CoordinatorToolCall{}, runnerproto.ErrInvalid
+ }
+ delete(fields, "request_id")
+ args, err := json.Marshal(fields)
+ call := runnerproto.CoordinatorToolCall{RequestID: id, Name: name, Arguments: args}
+ if err != nil {
+ return call, err
+ }
+ return coordinator.Canonical(call)
+}
+func (p *ToolProxy) coordinatorPermission(ctx context.Context, raw json.RawMessage) (json.RawMessage, error) {
+ var q struct {
+ Tool string `json:"tool_name"`
+ UseID string `json:"tool_use_id,omitempty"`
+ Input json.RawMessage `json:"input"`
+ }
+ if runnerproto.DecodeLimit(bytes.NewReader(raw), &q, maxToolFrame) != nil || !strings.HasPrefix(q.Tool, "mcp__equipo__") {
+ return nil, runnerproto.ErrInvalid
+ }
+ call, err := coordinatorMCPCall(strings.TrimPrefix(q.Tool, "mcp__equipo__"), q.Input)
+ if err != nil {
+ return nil, err
+ }
+ if err = p.ValidateCoordinatorApproval(ctx, call); err != nil {
+ return nil, err
+ }
+ return json.RawMessage(`{"behavior":"allow"}`), nil
+}
+
+// ApproveCoordinator binds Codex's captured MCP request to the same durable hash
+// as execution. Native and uncorrelated requests are always denied.
+func (p *ToolProxy) ApproveCoordinator(ctx context.Context, l provider.Launcher, ev provider.Event) error {
+ if p.coordinator == nil || l == nil {
+ return runnerproto.ErrInvalid
+ }
+ p.coordinator.mu.Lock()
+ b := p.coordinator.binding
+ p.coordinator.mu.Unlock()
+ authorize := func(ctx context.Context, original provider.Event) error {
+ if original.SessionID != b.Session.ID || original.TurnID != b.Claim.Turn.ID || original.RequestID != ev.RequestID || !bytes.Equal(original.Payload, ev.Payload) || !bytes.Equal(original.ToolCall, ev.ToolCall) {
+ return runnerproto.ErrInvalid
+ }
+ name, raw, err := codex.MCPApproval(original)
+ if err != nil {
+ return err
+ }
+ call, err := coordinatorMCPCall(name, raw)
+ if err != nil {
+ return err
+ }
+ return p.ValidateCoordinatorApproval(ctx, call)
+ }
+ behavior := "allow"
+ if err := authorize(ctx, ev); err != nil {
+ behavior = "deny"
+ }
+ return l.Respond(ctx, b.Session, provider.Answer{RequestID: ev.RequestID, TurnID: b.Claim.Turn.ID, Behavior: behavior, Authorize: authorize})
+}
+func (p *ToolProxy) serveCoordinator(conn net.Conn) {
+ b := p.coordinator
+ b.mu.Lock()
+ claim := b.binding.Claim
+ b.mu.Unlock()
+ copy := ToolCopy{Accepted: claim.ToolCopy.Accepted, Rejected: claim.ToolCopy.Rejected, Coordinator: claim.ToolCopy.Descriptions}
+ cap := toolCapability{Coordinator: true, Copy: copy, Tools: coordinator.Names()}
+ var permission func(context.Context, json.RawMessage) (json.RawMessage, error)
+ if claim.Brief.Selection.Provider == "claude" {
+ permission = p.coordinatorPermission
+ }
+ _ = serveTools(p.ctx, &proxyReader{conn: conn}, conn, func() (toolCapability, error) { return cap, b.current(p.ctx, false) }, func(q toolRequest) (any, error) {
+ out, err := p.CallCoordinatorTool(p.ctx, runnerproto.CoordinatorToolCall{RequestID: q.RequestID, Name: q.Name, Arguments: q.Arguments})
+ if err != nil {
+ return nil, err
+ }
+ raw, err := json.Marshal(out)
+ return map[string]any{"content": []any{map[string]string{"type": "text", "text": string(raw)}}}, err
+ }, permission)
+}
diff --git a/internal/runner/coordinator_tools_test.go b/internal/runner/coordinator_tools_test.go
new file mode 100644
index 00000000..868f1a23
--- /dev/null
+++ b/internal/runner/coordinator_tools_test.go
@@ -0,0 +1,248 @@
+package runner
+
+import (
+ "context"
+ "encoding/json"
+ "fmt"
+ "net"
+ "os"
+ "path/filepath"
+ "strings"
+ "testing"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/runner/provider"
+ "amadan.net/oficina/equipo/internal/runner/provider/claude"
+ "amadan.net/oficina/equipo/internal/runner/provider/codex"
+ "amadan.net/oficina/equipo/internal/runnerproto"
+)
+
+func TestCoordinatorToolAllowlist(t *testing.T) {
+ profile, _ := provider.Profile("coordinate")
+ for _, family := range []string{"claude", "codex"} {
+ b := provider.Binding{Provider: family, CredentialHome: "/private/account", Home: "/private/run", RuntimeRoot: "/private/runtime"}
+ in := provider.PolicyInputs{Action: "coordinate", Tools: profile.MCPTools()}
+ var got provider.PolicyInputs
+ var err error
+ if family == "claude" {
+ got, err = claude.PolicyInputs(b, in, profile.Specialist, "model")
+ } else {
+ got, err = codex.PolicyInputs(b, in, "model")
+ }
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, tool := range got.Tools {
+ if !strings.HasPrefix(tool, "mcp__equipo__") {
+ t.Fatalf("coordinator exposes built-in tool %s", tool)
+ }
+ }
+ if family == "claude" {
+ for i, arg := range got.Argv {
+ if arg == "--tools" && got.Argv[i+1] != "" {
+ t.Fatal("nonempty built-in inventory")
+ }
+ }
+ } else {
+ var cfg map[string]any
+ json.Unmarshal(got.Settings, &cfg)
+ for _, key := range []string{"shell_tool", "view_image", "search_tool", "browser_use", "computer_use", "code_mode", "js_repl"} {
+ if cfg["features"].(map[string]any)[key] != false {
+ t.Fatal("Codex built-in enabled", key)
+ }
+ }
+ var catalog struct {
+ Models []struct {
+ Shell string `json:"shell_type"`
+ Patch any `json:"apply_patch_tool_type"`
+ Tools []string `json:"experimental_supported_tools"`
+ }
+ }
+ if json.Unmarshal(got.Catalog, &catalog) != nil || len(catalog.Models) != 1 || catalog.Models[0].Shell != "disabled" || catalog.Models[0].Patch != nil || len(catalog.Models[0].Tools) != 0 {
+ t.Fatal("Codex native inventory not empty")
+ }
+ if cfg["web_search"] != "disabled" {
+ t.Fatal("web search enabled")
+ }
+ }
+ }
+}
+func TestCoordinatorToolJournal(t *testing.T) {
+ ctx := context.Background()
+ root := t.TempDir()
+ mustJournal(t, os.Chmod(root, 0700))
+ j, err := OpenJournal(ctx, filepath.Join(root, "journal.db"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer j.Close()
+ c := runnerproto.CoordinatorClaim{}
+ c.Scope.Account = "instance"
+ c.Binding.ID = "binding"
+ c.Binding.Generation = 1
+ c.Turn.ID = "turn"
+ c.Handle.Attempt = 1
+ c.Handle.Fence = 2
+ session := provider.Session{ID: "session", AttemptKey: "attempt", Provider: "claude"}
+ call := runnerproto.CoordinatorToolCall{RequestID: "r", Name: "post_message", Arguments: json.RawMessage(`{"body":"hi","source_refs":[]}`)}
+ if err = j.reserveCoordinatorTool(ctx, c, session, call); err != nil {
+ t.Fatal(err)
+ }
+ changed := call
+ changed.Arguments = json.RawMessage(`{"body":"changed","source_refs":[]}`)
+ if err = j.reserveCoordinatorTool(ctx, c, session, changed); err == nil {
+ t.Fatal("approval request hash changed")
+ }
+ pending, err := j.CoordinatorToolSubmissions(ctx, 10)
+ if err != nil || len(pending) != 0 {
+ t.Fatal("approval queued execution", pending, err)
+ }
+ mustJournal(t, j.submitCoordinatorTool(ctx, c, session, call))
+ pending, err = j.CoordinatorToolSubmissions(ctx, 10)
+ if err != nil || len(pending) != 1 {
+ t.Fatal("missing durable submission", pending, err)
+ }
+ result := runnerproto.CoordinatorToolResult{ResourceID: "message", Revision: 1, Value: json.RawMessage(`{}`)}
+ if err = j.ackCoordinatorTool(ctx, c, session, call, result); err != nil {
+ t.Fatal(err)
+ }
+ if err = j.reserveCoordinatorTool(ctx, c, session, changed); err == nil {
+ t.Fatal("acked request hash changed")
+ }
+ if err = j.reserveCoordinatorTool(ctx, c, session, call); err != nil {
+ t.Fatal(err)
+ }
+ pending, err = j.CoordinatorToolSubmissions(ctx, 10)
+ if err != nil || len(pending) != 0 {
+ t.Fatal("ack not durable", pending, err)
+ }
+}
+
+func TestCoordinatorToolBroker(t *testing.T) {
+ for _, family := range []string{"claude", "codex"} {
+ t.Run(family, func(t *testing.T) {
+ ctx := context.Background()
+ j, _, session, _ := directFixture(t, family)
+ mustJournal(t, j.BeginTurn(ctx, session, directTurn()))
+ mustJournal(t, j.consumeTurn(ctx, session.AttemptKey, session.ID, "hello"))
+ c := runnerproto.CoordinatorClaim{}
+ c.Scope.Account = "instance"
+ c.Binding.ID = "binding"
+ c.Binding.Generation = 1
+ c.Turn.ID = "turn"
+ c.Turn.Generation = 1
+ c.Handle.Attempt = 1
+ c.Handle.Fence = 7
+ c.LeaseDeadline = time.Now().Add(time.Minute)
+ c.AttemptDeadline = time.Now().Add(time.Hour)
+ c.Brief.Selection.Provider = family
+ c.Brief.Selection.AccountID = session.AccountID
+ c.Brief.Selection.Model = session.Model
+ c.Brief.Selection.Isolation.Status = "confined"
+ c.ToolCopy = runnerproto.CoordinatorToolCopy{Accepted: "accepted", Rejected: "rejected"}
+ current := true
+ calls := 0
+ p, err := OpenCoordinatorToolProxy(ctx, CoordinatorToolBinding{Claim: c, Session: session, Journal: j, Current: func(context.Context) error {
+ if !current {
+ return runnerproto.ErrInvalid
+ }
+ return nil
+ }, Call: func(_ context.Context, call runnerproto.CoordinatorToolCall) (runnerproto.CoordinatorToolResult, error) {
+ calls++
+ return runnerproto.CoordinatorToolResult{ResourceID: "message", Revision: 1, Value: json.RawMessage(`{}`)}, nil
+ }})
+ mustJournal(t, err)
+ defer p.Close()
+ call := runnerproto.CoordinatorToolCall{RequestID: "r", Name: "post_message", Arguments: json.RawMessage(`{"body":"hi","source_refs":[]}`)}
+ mustJournal(t, p.ValidateCoordinatorApproval(ctx, call))
+ if calls != 0 {
+ t.Fatal("approval executed tool")
+ }
+ changed := call
+ changed.Arguments = json.RawMessage(`{"body":"different","source_refs":[]}`)
+ if _, err = p.CallCoordinatorTool(ctx, changed); err == nil {
+ t.Fatal("execution changed approved hash")
+ }
+ _, err = p.CallCoordinatorTool(ctx, call)
+ mustJournal(t, err)
+ if calls != 1 {
+ t.Fatal("tool did not execute")
+ }
+ if family == "claude" {
+ raw := json.RawMessage(`{"tool_name":"mcp__equipo__post_message","input":{"request_id":"r","body":"hi","source_refs":[]}}`)
+ if _, err = p.coordinatorPermission(ctx, raw); err != nil {
+ t.Fatal(err)
+ }
+ if _, err = p.coordinatorPermission(ctx, json.RawMessage(`{"tool_name":"Bash","input":{"command":"ls"}}`)); err == nil {
+ t.Fatal("native permission granted")
+ }
+ }
+ // Exercise the actual MCP transport and its coordinator schema selection.
+ dir, err := os.Open(filepath.Dir(p.SocketPath))
+ mustJournal(t, err)
+ defer dir.Close()
+ conn, err := net.Dial("unix", fmt.Sprintf("/proc/self/fd/%d/equipo.sock", dir.Fd()))
+ mustJournal(t, err)
+ defer conn.Close()
+ enc := json.NewEncoder(conn)
+ dec := json.NewDecoder(conn)
+ for i, method := range []string{"initialize", "tools/list", "tools/call"} {
+ var params any = map[string]any{}
+ if method == "initialize" {
+ params = map[string]any{"protocolVersion": "2025-06-18", "capabilities": map[string]any{}, "clientInfo": map[string]any{}}
+ }
+ if method == "tools/call" {
+ params = map[string]any{"name": "read_project", "arguments": map[string]any{"request_id": "read", "project_id": 1}}
+ }
+ mustJournal(t, enc.Encode(map[string]any{"jsonrpc": "2.0", "id": i, "method": method, "params": params}))
+ var reply map[string]any
+ mustJournal(t, dec.Decode(&reply))
+ if reply["error"] != nil {
+ t.Fatal(reply)
+ }
+ if method == "tools/list" {
+ raw, _ := json.Marshal(reply)
+ if !strings.Contains(string(raw), "source_message_ids") || strings.Contains(string(raw), "submit_candidate") {
+ t.Fatal("task schema leaked", string(raw))
+ }
+ }
+ }
+ current = false
+ if _, err = p.CallCoordinatorTool(ctx, call); err == nil {
+ t.Fatal("revoked authority replay")
+ }
+ if p.ValidateCoordinatorApproval(ctx, call) == nil {
+ t.Fatal("revoked approval")
+ }
+ })
+ }
+}
+
+func TestCoordinatorToolJournalUpgrade(t *testing.T) {
+ ctx := context.Background()
+ path := filepath.Join(t.TempDir(), "private", "journal.db")
+ j, err := OpenJournal(ctx, path)
+ mustJournal(t, err)
+ mustJournal(t, j.Append(ctx, journalEvent("retained", 1)))
+ _, err = j.db.Exec("DROP TABLE coordinator_tools; PRAGMA user_version=4")
+ mustJournal(t, err)
+ mustJournal(t, j.Close())
+ j, err = OpenJournal(ctx, path)
+ mustJournal(t, err)
+ defer j.Close()
+ var version int
+ mustJournal(t, j.db.QueryRow("PRAGMA user_version").Scan(&version))
+ if version != 5 {
+ t.Fatal("ordered migration missing", version)
+ }
+ pending, err := j.Pending(ctx, 10)
+ mustJournal(t, err)
+ if len(pending) != 1 || pending[0].ID != "retained" {
+ t.Fatal("old outbox lost")
+ }
+ rows, err := j.CoordinatorToolSubmissions(ctx, 10)
+ mustJournal(t, err)
+ if len(rows) != 0 {
+ t.Fatal("invented coordinator submissions")
+ }
+}
diff --git a/internal/runner/direct_fixes_test.go b/internal/runner/direct_fixes_test.go
index 1eb4370a..0d6c67f8 100644
--- a/internal/runner/direct_fixes_test.go
+++ b/internal/runner/direct_fixes_test.go
@@ -234,7 +234,7 @@ func TestDirectJournalPrunesFrames(t *testing.T) {
// Simulate a v2 archive and one pending frame awaiting retirement.
_, err := j.db.Exec("WITH RECURSIVE n(x) AS (SELECT 1 UNION ALL SELECT x+1 FROM n WHERE x<200) INSERT INTO direct_frames(stream,sequence,body,pending) SELECT ?,x,'{}',0 FROM n", p.ID())
mustJournal(t, err)
- _, err = j.db.Exec("DROP INDEX IF EXISTS direct_frames_pending; DROP INDEX IF EXISTS direct_events_projected; PRAGMA user_version=2")
+ _, err = j.db.Exec("DROP TABLE coordinator_tools; DROP INDEX IF EXISTS direct_frames_pending; DROP INDEX IF EXISTS direct_events_projected; PRAGMA user_version=2")
mustJournal(t, err)
path := j.path
mustJournal(t, j.Close())
diff --git a/internal/runner/direct_recovery_test.go b/internal/runner/direct_recovery_test.go
index 2f5fed44..69551caa 100644
--- a/internal/runner/direct_recovery_test.go
+++ b/internal/runner/direct_recovery_test.go
@@ -157,7 +157,7 @@ func TestDirectJournalUpgrade(t *testing.T) {
j, _, _, _ := directFixture(t, "claude")
ctx := context.Background()
mustJournal(t, j.Append(ctx, journalEvent("legacy", 1)))
- _, err := j.db.Exec("DROP TABLE direct_attempts; DROP TABLE direct_turns; DROP TABLE direct_frames; DROP TABLE direct_events; DROP TABLE direct_usage; PRAGMA user_version=1")
+ _, err := j.db.Exec("DROP TABLE coordinator_tools; DROP TABLE direct_attempts; DROP TABLE direct_turns; DROP TABLE direct_frames; DROP TABLE direct_events; DROP TABLE direct_usage; PRAGMA user_version=1")
mustJournal(t, err)
path := j.path
mustJournal(t, j.Close())
@@ -166,7 +166,7 @@ func TestDirectJournalUpgrade(t *testing.T) {
defer j.Close()
var v int
mustJournal(t, j.db.QueryRow("PRAGMA user_version").Scan(&v))
- if v != 4 {
+ if v != 5 {
t.Fatalf("journal version %d", v)
}
events, err := j.Pending(ctx, 10)
diff --git a/internal/runner/journal.go b/internal/runner/journal.go
index 3dd428f9..88965a89 100644
--- a/internal/runner/journal.go
+++ b/internal/runner/journal.go
@@ -83,7 +83,7 @@ func OpenJournal(ctx context.Context, path string) (*Journal, error) {
db.SetMaxOpenConns(1)
j := &Journal{db: db, path: path, maxBytes: MaxJournalBytes}
var version int
- if err = db.QueryRowContext(ctx, "PRAGMA user_version").Scan(&version); err != nil || version > 4 {
+ if err = db.QueryRowContext(ctx, "PRAGMA user_version").Scan(&version); err != nil || version > 5 {
db.Close()
return nil, ErrJournal
}
@@ -122,6 +122,12 @@ func OpenJournal(ctx context.Context, path string) (*Journal, error) {
_, err = tx.ExecContext(ctx, `CREATE TABLE IF NOT EXISTS direct_answer_scopes(answer_key TEXT PRIMARY KEY,attempt TEXT NOT NULL,turn TEXT NOT NULL);
CREATE INDEX IF NOT EXISTS direct_answer_attempt ON direct_answer_scopes(attempt,turn);
PRAGMA user_version=4;`)
+ }
+ if err == nil && version < 5 {
+ _, err = tx.ExecContext(ctx, `CREATE TABLE coordinator_tools(ordinal INTEGER PRIMARY KEY AUTOINCREMENT,request_key TEXT UNIQUE NOT NULL,content_hash TEXT NOT NULL,binding TEXT NOT NULL,generation INTEGER NOT NULL,turn TEXT NOT NULL,body BLOB NOT NULL,result BLOB,submitted INTEGER NOT NULL DEFAULT 0,acked INTEGER NOT NULL DEFAULT 0);
+ CREATE INDEX coordinator_tools_pending ON coordinator_tools(acked,ordinal);
+ CREATE INDEX coordinator_tools_turn ON coordinator_tools(binding,generation,turn);
+ PRAGMA user_version=5;`)
}
if err == nil {
_, err = tx.ExecContext(ctx, "UPDATE journal_streams SET ready=0")
diff --git a/internal/runner/journal_test.go b/internal/runner/journal_test.go
index 851ab29e..2f0e04b2 100644
--- a/internal/runner/journal_test.go
+++ b/internal/runner/journal_test.go
@@ -338,7 +338,7 @@ func TestRunnerJournalDurabilityConfiguration(t *testing.T) {
if syncLevel != 2 || mode != "delete" {
t.Fatal("journal writes are not durably synced", syncLevel, mode)
}
- _, err = j.db.Exec("PRAGMA user_version=5")
+ _, err = j.db.Exec("PRAGMA user_version=6")
mustJournal(t, err)
mustJournal(t, j.Close())
if other, err := OpenJournal(journalCtx, path); err == nil {
diff --git a/internal/runner/provider/actions.go b/internal/runner/provider/actions.go
index aa3cf783..b18b828f 100644
--- a/internal/runner/provider/actions.go
+++ b/internal/runner/provider/actions.go
@@ -11,7 +11,7 @@ func Profile(action string) (ActionProfile, error) {
p := ActionProfile{Action: action}
switch action {
case "coordinate":
- p.Specialist, p.Submission, p.ReadOnly = "Coordinator", "submit_answer", true
+ p.Specialist, p.Submission, p.ReadOnly = "Coordinator", "post_message", true
case "reproduce":
p.Specialist, p.Submission = "Engineering", "submit_reproduction"
case "scope":
@@ -32,6 +32,9 @@ func Profile(action string) (ActionProfile, error) {
return p, nil
}
func (p ActionProfile) Tools() []string {
+ if p.Action == "coordinate" {
+ return CoordinatorTools()
+ }
tools := []string{p.Submission, "ask_person"}
if p.Render {
tools = append(tools, "submit_render")
@@ -45,3 +48,7 @@ func (p ActionProfile) MCPTools() []string {
}
return tools
}
+
+func CoordinatorTools() []string {
+ return []string{"read_project", "read_task", "propose_plan", "ask_person", "route_to_task", "post_message", "suggest_preference", "suggest_specialist", "suggest_playbook"}
+}
diff --git a/internal/runner/provider/claude/launcher.go b/internal/runner/provider/claude/launcher.go
index 2e908c83..b5d47478 100644
--- a/internal/runner/provider/claude/launcher.go
+++ b/internal/runner/provider/claude/launcher.go
@@ -101,7 +101,9 @@ func nativeTools(role string) ([]string, error) {
switch role {
case "Engineering", "Copy", "Design":
return []string{"Bash", "Read", "Write", "Edit", "Glob", "Grep"}, nil
- case "Review", "Product", "Scope", "Research", "Coordinator":
+ case "Coordinator":
+ return []string{}, nil
+ case "Review", "Product", "Scope", "Research":
return []string{"Read", "Glob", "Grep", "Bash"}, nil
}
return nil, provider.ErrPolicy
@@ -122,7 +124,7 @@ func PolicyInputs(b provider.Binding, in provider.PolicyInputs, specialist, mode
}
tools := append(append([]string{}, native...), "mcp__equipo__permission")
for _, tool := range in.Tools {
- if !slices.Contains([]string{"mcp__equipo__ask_person", "mcp__equipo__submit_candidate", "mcp__equipo__submit_review", "mcp__equipo__submit_reproduction", "mcp__equipo__submit_acceptance", "mcp__equipo__submit_answer", "mcp__equipo__submit_render"}, tool) {
+ if in.Action != "coordinate" && !slices.Contains([]string{"mcp__equipo__ask_person", "mcp__equipo__submit_candidate", "mcp__equipo__submit_review", "mcp__equipo__submit_reproduction", "mcp__equipo__submit_acceptance", "mcp__equipo__submit_answer", "mcp__equipo__submit_render"}, tool) {
return in, provider.ErrPolicy
}
tools = append(tools, tool)
@@ -151,6 +153,9 @@ func PolicyInputs(b provider.Binding, in provider.PolicyInputs, specialist, mode
settings["sandbox"].(map[string]any)["filesystem"].(map[string]any)["denyWrite"] = append(append([]string{}, denied...), "/workspace")
}
}
+ if in.Action == "coordinate" {
+ settings["permissions"].(map[string]any)["allow"] = []string{}
+ }
in.Settings, _ = json.Marshal(settings)
in.MCP = json.RawMessage(`{"mcpServers":{"equipo":{"type":"stdio","command":"/opt/equipo-tool-proxy","args":["--socket","/tool/equipo.sock"]}}}`)
in.ThreadPolicy, _ = json.Marshal(threadPolicy{specialist, model, "session-id", "resume"})
diff --git a/internal/runner/provider/codex/coordinator.go b/internal/runner/provider/codex/coordinator.go
new file mode 100644
index 00000000..322d8699
--- /dev/null
+++ b/internal/runner/provider/codex/coordinator.go
@@ -0,0 +1,27 @@
+package codex
+
+import (
+ "amadan.net/oficina/equipo/internal/runner/provider"
+ "encoding/json"
+)
+
+// The pinned CLI builds apply_patch from model metadata, independently of the
+// shell flag. This startup-only catalog removes that surface as well.
+func coordinatorCatalog(model string) json.RawMessage {
+ return marshal(map[string]any{"models": []any{map[string]any{
+ "slug": model, "display_name": model, "supported_reasoning_levels": []any{}, "shell_type": "disabled", "visibility": "list", "supported_in_api": true, "priority": 0,
+ "support_verbosity": false, "apply_patch_tool_type": nil, "truncation_policy": map[string]any{"mode": "bytes", "limit": 65536}, "experimental_supported_tools": []string{},
+ "include_apps_usage_instructions": false, "include_skills_usage_instructions": false, "include_plugin_usage_instructions": false, "supports_search_tool": false, "node_repl_disabled": true,
+ "model_messages": map[string]any{"instructions_template": "Use only the supplied Equipo tools. Text is commentary and grants no authority."},
+ }}})
+}
+func configureCoordinator(settings map[string]any, model string) {
+ features := settings["features"].(map[string]any)
+ for _, key := range []string{"shell_tool", "unified_exec", "apply_patch_freeform", "view_image", "search_tool", "web_search", "web_search_cached", "web_search_request", "standalone_web_search", "browser_use", "browser_use_external", "computer_use", "image_generation", "imagegenext", "js_repl", "code_mode", "code_mode_only", "code_mode_host", "tool_search", "code_mode_tool_search", "plugins", "remote_plugin", "skill_search", "memory_tool", "memories", "goals", "sleep_tool", "current_time_reminder", "request_permissions_tool", "default_mode_request_user_input", "send_message_to_user_async", "deferred_executor", "multi_agent_v2", "multi_agent_mode", "multi_agent_v2_dynamic_tools", "agent_message_board", "tool_suggest", "collaboration_modes", "context_management", "token_budget", "runtime_agent_instances", "multi_env_copy_file"} {
+ features[key] = false
+ }
+ settings["web_search"] = "disabled"
+ settings["model_catalog_json"] = provider.CoordinatorCatalogPath
+ settings["tools"] = map[string]any{"update_plan": map[string]any{"enabled": false}, "experimental_request_user_input": map[string]any{"enabled": false}}
+ settings["mcp_servers"].(map[string]any)["equipo"].(map[string]any)["enabled_tools"] = provider.CoordinatorTools()
+}
diff --git a/internal/runner/provider/codex/launcher.go b/internal/runner/provider/codex/launcher.go
index 2ebe529a..9344cac1 100644
--- a/internal/runner/provider/codex/launcher.go
+++ b/internal/runner/provider/codex/launcher.go
@@ -62,7 +62,7 @@ type manifest struct {
AuthHost string
Argv, DeniedPaths, EgressHosts, Tools []string
ProviderVersion, LauncherVersion, BwrapVersion, Workspace, Scratch, CredentialHome string
- Settings, MCP, ThreadPolicy, TurnPolicy json.RawMessage
+ Catalog, Settings, MCP, ThreadPolicy, TurnPolicy json.RawMessage
Env map[string]string
Files, Instructions []struct {
Mount provider.Mount
@@ -130,7 +130,14 @@ func PolicyInputs(b provider.Binding, in provider.PolicyInputs, model string) (p
"permissions": map[string]any{"equipo": map[string]any{"filesystem": fs, "network": map[string]any{"enabled": false}}},
"features": map[string]any{"apps": false, "multi_agent": false, "remote_control": false, "tool_call_mcp_elicitation": true}, "mcp_servers": map[string]any{"equipo": map[string]any{"command": "/opt/equipo-tool-proxy", "args": []string{"--socket", "/tool/equipo.sock"}}},
}
+ if in.Action == "coordinate" {
+ configureCoordinator(settings, model)
+ in.Catalog = coordinatorCatalog(model)
+ }
for _, tool := range in.Tools {
+ if in.Action == "coordinate" {
+ continue
+ }
switch tool {
case "mcp__equipo__ask_person", "mcp__equipo__submit_candidate", "mcp__equipo__submit_review", "mcp__equipo__submit_reproduction", "mcp__equipo__submit_acceptance", "mcp__equipo__submit_answer", "mcp__equipo__submit_render":
default:
@@ -187,7 +194,7 @@ func policyInputs(p provider.Policy) (provider.PolicyInputs, manifest, error) {
if !uniqueJSON(p.Manifest) || json.Unmarshal(p.Manifest, &m) != nil {
return provider.PolicyInputs{}, m, provider.ErrPolicy
}
- in := provider.PolicyInputs{Action: m.Action, AuthHost: m.AuthHost, Argv: m.Argv, DeniedPaths: append([]string{}, m.DeniedPaths...), EgressHosts: m.EgressHosts, Tools: m.Tools, ProviderVersion: m.ProviderVersion, LauncherVersion: m.LauncherVersion, BwrapVersion: m.BwrapVersion, Workspace: m.Workspace, Scratch: m.Scratch, Settings: m.Settings, MCP: m.MCP, ThreadPolicy: m.ThreadPolicy, TurnPolicy: m.TurnPolicy, Env: map[string]string{}}
+ in := provider.PolicyInputs{Action: m.Action, AuthHost: m.AuthHost, Argv: m.Argv, DeniedPaths: append([]string{}, m.DeniedPaths...), EgressHosts: m.EgressHosts, Tools: m.Tools, ProviderVersion: m.ProviderVersion, LauncherVersion: m.LauncherVersion, BwrapVersion: m.BwrapVersion, Workspace: m.Workspace, Scratch: m.Scratch, Catalog: m.Catalog, Settings: m.Settings, MCP: m.MCP, ThreadPolicy: m.ThreadPolicy, TurnPolicy: m.TurnPolicy, Env: map[string]string{}}
for _, path := range []string{m.CredentialHome, "/home/runner"} {
for i, p := range in.DeniedPaths {
if p == path {
@@ -233,7 +240,7 @@ func (l *Launcher) validatePolicy(b provider.Binding, p provider.Policy) (provid
return in, provider.ErrPolicy
}
}
- if !reflect.DeepEqual(in.Argv, want.Argv) || p.Env["CODEX_HOME"] != "/home/runner" {
+ if (in.Action == "coordinate" && !sameJSON(in.Catalog, want.Catalog)) || !reflect.DeepEqual(in.Argv, want.Argv) || p.Env["CODEX_HOME"] != "/home/runner" {
return in, provider.ErrPolicy
}
binary, helper, toolHelper := false, false, false
diff --git a/internal/runner/provider/codex/plan_policy_test.go b/internal/runner/provider/codex/plan_policy_test.go
index 1a3170b1..4530937e 100644
--- a/internal/runner/provider/codex/plan_policy_test.go
+++ b/internal/runner/provider/codex/plan_policy_test.go
@@ -3,6 +3,7 @@ package codex
import (
"context"
"encoding/json"
+ "os"
"slices"
"testing"
@@ -77,3 +78,42 @@ func TestPlanWorkflowProviderPoliciesLauncher(t *testing.T) {
})
}
}
+
+func TestCoordinatorToolCatalogBound(t *testing.T) {
+ f := fixtureFor(t)
+ profile, _ := provider.Profile("coordinate")
+ in := f.inputs
+ in.Action = "coordinate"
+ in.Tools = profile.MCPTools()
+ var err error
+ in, err = PolicyInputs(f.lease.Binding(), in, f.launch.Selection.Model)
+ if err != nil {
+ t.Fatal(err)
+ }
+ p, err := provider.BuildPolicy(f.lease.Binding(), in)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if _, err = f.l.validatePolicy(f.lease.Binding(), p); err != nil {
+ t.Fatal(err)
+ }
+ for _, m := range p.Mounts {
+ if m.Target == provider.CoordinatorCatalogPath {
+ raw, err := os.ReadFile(m.Source)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err = p.ValidateFileDigest(m.Source, provider.DigestDirectEvidence(raw)); err != nil {
+ t.Fatal("catalog missing pinned digest", err)
+ }
+ if err = os.WriteFile(m.Source, []byte(`{"models":[]}`), 0600); err != nil {
+ t.Fatal(err)
+ }
+ if p.ValidateSources(f.lease.Binding()) == nil {
+ t.Fatal("changed catalog accepted")
+ }
+ return
+ }
+ }
+ t.Fatal("catalog not mounted")
+}
diff --git a/internal/runner/provider/policy.go b/internal/runner/provider/policy.go
index 9ff1ad96..ffac12b0 100644
--- a/internal/runner/provider/policy.go
+++ b/internal/runner/provider/policy.go
@@ -19,6 +19,7 @@ import (
const PolicyVersion = "direct-v1"
const SettingsPath = "/config/equipo-settings.json"
+const CoordinatorCatalogPath = "/config/equipo-coordinator-models.json"
const MCPPath = "/config/equipo-mcp.json"
type PolicyInputs struct {
@@ -27,6 +28,7 @@ type PolicyInputs struct {
RuntimeFiles []Mount
DeniedPaths, EgressHosts []string
ProviderVersion, LauncherVersion, BwrapVersion string
+ Catalog json.RawMessage `json:",omitempty"`
Settings, MCP, ThreadPolicy, TurnPolicy json.RawMessage
Tools []string
// Adapters supply the exact argv and any permitted nonsecret environment.
@@ -52,6 +54,7 @@ type effectiveManifest struct {
Env map[string]string
Files []fileDigest
DeniedPaths, EgressHosts, Tools []string
+ Catalog json.RawMessage `json:",omitempty"`
Settings, MCP, ThreadPolicy, TurnPolicy json.RawMessage
Workspace, Scratch, RuntimeHome, ConfigHome string
Instructions []fileDigest
@@ -160,6 +163,9 @@ func nonsecretJSON(raw json.RawMessage) bool {
case map[string]any:
for k, v := range x {
lower := strings.ToLower(k)
+ if k == "token_budget" && v == false {
+ continue
+ }
if strings.Contains(lower, "token") || strings.Contains(lower, "secret") || strings.Contains(lower, "password") || strings.Contains(lower, "api_key") || strings.Contains(lower, "apikey") || lower == "authorization" {
return false
}
@@ -337,7 +343,7 @@ func BuildPolicy(b Binding, in PolicyInputs) (Policy, error) {
for _, k := range []string{"HTTP_PROXY", "HTTPS_PROXY", "http_proxy", "https_proxy"} {
fullEnv[k] = "http://127.0.0.1:18080"
}
- m := effectiveManifest{Action: in.Action, AuthHost: in.AuthHost, Version: PolicyVersion, BindingID: b.ID, Provider: b.Provider, AccountID: b.AccountID, CredentialHome: b.CredentialHome, Identity: b.Expected, ProviderVersion: in.ProviderVersion, LauncherVersion: in.LauncherVersion, BwrapVersion: in.BwrapVersion, Argv: append([]string(nil), in.Argv...), Env: fullEnv, Files: files, DeniedPaths: denied, EgressHosts: hosts, Tools: tools, Settings: settings, MCP: mcp, ThreadPolicy: thread, TurnPolicy: turn, Workspace: in.Workspace, Scratch: in.Scratch, RuntimeHome: b.Home, ConfigHome: b.provenance.config, Instructions: instructions, HooksDisabled: true, PluginsDisabled: true, TurnOverridesOmitted: true, MaskedDirectories: []string{"/etc/claude-code", "/etc/codex"}, Proxy: "http://127.0.0.1:18080"}
+ m := effectiveManifest{Action: in.Action, AuthHost: in.AuthHost, Version: PolicyVersion, BindingID: b.ID, Provider: b.Provider, AccountID: b.AccountID, CredentialHome: b.CredentialHome, Identity: b.Expected, ProviderVersion: in.ProviderVersion, LauncherVersion: in.LauncherVersion, BwrapVersion: in.BwrapVersion, Argv: append([]string(nil), in.Argv...), Env: fullEnv, Files: files, DeniedPaths: denied, EgressHosts: hosts, Tools: tools, Catalog: in.Catalog, Settings: settings, MCP: mcp, ThreadPolicy: thread, TurnPolicy: turn, Workspace: in.Workspace, Scratch: in.Scratch, RuntimeHome: b.Home, ConfigHome: b.provenance.config, Instructions: instructions, HooksDisabled: true, PluginsDisabled: true, TurnOverridesOmitted: true, MaskedDirectories: []string{"/etc/claude-code", "/etc/codex"}, Proxy: "http://127.0.0.1:18080"}
readOnly := false
if in.Action != "" {
profile, err := Profile(in.Action)
@@ -348,6 +354,15 @@ func BuildPolicy(b Binding, in PolicyInputs) (Policy, error) {
}
m.OuterMounts = []Mount{{Source: "/usr", Target: "/usr", ReadOnly: true}, {Source: in.Workspace, Target: "/workspace", ReadOnly: readOnly}, {Source: b.Home, Target: "/home/runner"}, {Source: in.Scratch, Target: "/tmp"}}
m.GeneratedMounts = generatedMounts(b)
+ if len(in.Catalog) > 0 {
+ if b.Provider != "codex" || in.Action != "coordinate" || !json.Valid(in.Catalog) {
+ return Policy{}, ErrPolicy
+ }
+ m.GeneratedMounts = append(m.GeneratedMounts, Mount{Source: filepath.Join(b.provenance.config, "equipo-coordinator-models.json"), Target: CoordinatorCatalogPath, ReadOnly: true})
+ }
+ if in.Action == "coordinate" {
+ m.OuterMounts = append(m.OuterMounts[:1], m.OuterMounts[2:]...)
+ }
m.NamespaceArgs = NamespaceArguments()
raw, manifestHash, e := hashJSON(m)
if e != nil {
@@ -371,6 +386,12 @@ func BuildPolicy(b Binding, in PolicyInputs) (Policy, error) {
}
mounts := append(append([]Mount(nil), in.RuntimeFiles...), in.InstructionFiles...)
mounts = append(mounts, generatedMounts(b)...)
+ if len(in.Catalog) > 0 {
+ mounts = append(mounts, Mount{Source: filepath.Join(b.provenance.config, "equipo-coordinator-models.json"), Target: CoordinatorCatalogPath, ReadOnly: true})
+ }
+ if len(in.Catalog) > 0 && atomicPrivate(dir, "equipo-coordinator-models.json", in.Catalog) != nil {
+ return Policy{}, ErrPolicy
+ }
p := Policy{Hash: policyHash, ManifestHash: manifestHash, InstructionHash: instructionHash, Manifest: raw, Mounts: mounts, Env: env, Settings: settings, MCP: mcp, ThreadPolicy: thread, TurnPolicy: turn}
b.provenance.mu.Lock()
b.provenance.policy = &Policy{Manifest: bytes.Clone(raw), ManifestHash: manifestHash}
@@ -401,7 +422,11 @@ func (p Policy) ValidateSources(b Binding) error {
return e
}
defer dir.Close()
- for name, want := range map[string][]byte{"equipo-settings.json": m.Settings, "equipo-mcp.json": m.MCP} {
+ generated := map[string][]byte{"equipo-settings.json": m.Settings, "equipo-mcp.json": m.MCP}
+ if len(m.Catalog) > 0 {
+ generated["equipo-coordinator-models.json"] = m.Catalog
+ }
+ for name, want := range generated {
raw, e := readPrivate(dir, name)
if e != nil || !bytes.Equal(raw, want) {
return ErrPolicy
@@ -487,6 +512,9 @@ func AttestLaunch(l Launch, argv []string) (string, error) {
mounts = append(mounts, f.Mount)
}
expectedMounts := append(mounts, generatedMounts(l.Binding)...)
+ if len(m.Catalog) > 0 {
+ expectedMounts = append(expectedMounts, Mount{Source: filepath.Join(l.Binding.provenance.config, "equipo-coordinator-models.json"), Target: CoordinatorCatalogPath, ReadOnly: true})
+ }
if !reflect.DeepEqual(expectedMounts, p.Mounts) {
return "", ErrPolicy
}
@@ -574,6 +602,9 @@ func (p Policy) ValidateFileDigest(path, hash string) error {
return nil
}
}
+ if len(m.Catalog) > 0 && path == filepath.Join(m.ConfigHome, "equipo-coordinator-models.json") && digest(m.Catalog) == hash {
+ return nil
+ }
if path == filepath.Join(m.ConfigHome, "equipo-settings.json") && digest(m.Settings) == hash {
return nil
}
@@ -697,3 +728,8 @@ func (p Policy) ReadOnlyWorkspace() bool {
profile, err := Profile(m.Action)
return err != nil || profile.ReadOnly
}
+
+func (p Policy) Coordinator() bool {
+ var m effectiveManifest
+ return p.ManifestHash != "" && digest(p.Manifest) == p.ManifestHash && json.Unmarshal(p.Manifest, &m) == nil && m.Action == "coordinate"
+}
diff --git a/internal/runner/tool_proxy.go b/internal/runner/tool_proxy.go
index b1443b9b..181f3acd 100644
--- a/internal/runner/tool_proxy.go
+++ b/internal/runner/tool_proxy.go
@@ -23,14 +23,15 @@ const directMCP = `{"mcpServers":{"equipo":{"type":"stdio","command":"/opt/equip
// ToolProxy exposes MCP only. The authenticating broker and its capability stay
// in the runner; neither is written into the mounted endpoint directory.
type ToolProxy struct {
- SocketPath string
- broker *AttemptSocket
- listener *net.UnixListener
- ctx context.Context
- cancel context.CancelFunc
- workers sync.WaitGroup
- once sync.Once
- directory string
+ coordinator *coordinatorBroker
+ SocketPath string
+ broker *AttemptSocket
+ listener *net.UnixListener
+ ctx context.Context
+ cancel context.CancelFunc
+ workers sync.WaitGroup
+ once sync.Once
+ directory string
}
func OpenToolProxy(ctx context.Context, b ToolBinding) (*ToolProxy, error) {
@@ -128,6 +129,9 @@ func openToolProxy(ctx context.Context, b ToolBinding, root string) (*ToolProxy,
// identity is durable, before StartTurn writes its prompt. Calls still require
// durable dispatch. Binding never changes the task, fence or tools.
func (p *ToolProxy) BindTurn(session provider.Session, turn string) error {
+ if p.coordinator != nil {
+ return p.bindCoordinator(session, turn)
+ }
s := p.broker
s.mu.Lock()
defer s.mu.Unlock()
@@ -164,12 +168,36 @@ func (p *ToolProxy) BindTurn(session provider.Session, turn string) error {
// RenewLease accepts only the supervisor's trusted monotonic renewal.
func (p *ToolProxy) RenewLease(ctx context.Context, deadline time.Time) error {
+ if p.coordinator != nil {
+ b := p.coordinator
+ if err := b.current(ctx, false); err != nil {
+ return err
+ }
+ b.mu.Lock()
+ defer b.mu.Unlock()
+ if !deadline.After(b.deadline) || deadline.After(b.binding.Claim.AttemptDeadline) {
+ return runnerproto.ErrInvalid
+ }
+ b.deadline = deadline
+ return nil
+ }
return p.broker.RenewLease(ctx, deadline)
}
func (p *ToolProxy) MCP() json.RawMessage { return json.RawMessage(directMCP) }
func (p *ToolProxy) Close() error {
- p.once.Do(func() { p.cancel(); p.broker.Invalidate(); p.listener.Close() })
+ p.once.Do(func() {
+ p.cancel()
+ if p.broker != nil {
+ p.broker.Invalidate()
+ }
+ if p.coordinator != nil {
+ p.coordinator.mu.Lock()
+ p.coordinator.invalid = true
+ p.coordinator.mu.Unlock()
+ }
+ p.listener.Close()
+ })
p.workers.Wait()
if err := os.Remove(p.SocketPath); err != nil && !os.IsNotExist(err) {
return err
@@ -195,6 +223,10 @@ func (p *ToolProxy) accept() {
if !toolPeer(conn) {
return
}
+ if p.coordinator != nil {
+ p.serveCoordinator(conn)
+ return
+ }
// Cancellation and lease loss close idle connections through AfterFunc.
input := &proxyReader{conn: conn}
_ = serveTools(p.ctx, input, conn, func() (toolCapability, error) {
diff --git a/internal/runner/tool_socket.go b/internal/runner/tool_socket.go
index fe8fa152..9ca8b666 100644
--- a/internal/runner/tool_socket.go
+++ b/internal/runner/tool_socket.go
@@ -48,14 +48,15 @@ type ToolBinding struct {
Current func(context.Context) error
}
type toolCapability struct {
- Copy ToolCopy `json:"copy"`
- Secret string `json:"secret"`
- InstanceID string `json:"instance_id"`
- TaskID string `json:"task_id"`
- Attempt int64 `json:"attempt"`
- Fence int64 `json:"fence"`
- Tools []string `json:"tools"`
- ExpiresAt time.Time `json:"expires_at"`
+ Coordinator bool `json:"coordinator,omitempty"`
+ Copy ToolCopy `json:"copy"`
+ Secret string `json:"secret"`
+ InstanceID string `json:"instance_id"`
+ TaskID string `json:"task_id"`
+ Attempt int64 `json:"attempt"`
+ Fence int64 `json:"fence"`
+ Tools []string `json:"tools"`
+ ExpiresAt time.Time `json:"expires_at"`
}
type toolRequest struct {
Capability string `json:"capability"`
diff --git a/internal/runner/tools.go b/internal/runner/tools.go
index a16740a6..82353a79 100644
--- a/internal/runner/tools.go
+++ b/internal/runner/tools.go
@@ -12,11 +12,13 @@ import (
"strings"
"unicode/utf8"
+ "amadan.net/oficina/equipo/internal/coordinator"
"amadan.net/oficina/equipo/internal/runnerproto"
"amadan.net/oficina/equipo/internal/taskplan"
)
type ToolCopy struct {
+ Coordinator map[string]string `json:"coordinator,omitempty"`
Acceptance, Answer, Render string
Accepted string `json:"accepted"`
Rejected string `json:"rejected"`
@@ -179,6 +181,12 @@ func serveTools(ctx context.Context, input io.Reader, output io.Writer, capabili
break
}
schemas := toolSchemas(cap.Tools, cap.Copy)
+ if cap.Coordinator {
+ schemas = []any{}
+ for _, schema := range coordinator.Schemas(cap.Copy.Coordinator) {
+ schemas = append(schemas, schema)
+ }
+ }
if permission != nil {
schemas = append(schemas, map[string]any{"name": "permission", "inputSchema": map[string]any{"type": "object", "properties": map[string]any{"tool_name": map[string]string{"type": "string"}, "tool_use_id": map[string]string{"type": "string"}, "input": map[string]string{"type": "object"}}, "required": []string{"tool_name", "input"}, "additionalProperties": false}})
}
@@ -221,7 +229,12 @@ func serveTools(ctx context.Context, input io.Reader, output io.Writer, capabili
err = runnerproto.ErrInvalid
break
}
- if err = validateToolArguments(params.Name, args); err != nil {
+ if cap.Coordinator {
+ _, err = coordinator.Validate(runnerproto.CoordinatorToolCall{RequestID: requestID, Name: params.Name, Arguments: args})
+ } else {
+ err = validateToolArguments(params.Name, args)
+ }
+ if err != nil {
break
}
result, err = call(toolRequest{Capability: cap.Secret, InstanceID: cap.InstanceID, TaskID: cap.TaskID, Attempt: cap.Attempt, Fence: cap.Fence, RequestID: requestID, Name: params.Name, Arguments: args})
diff --git a/internal/runnerproto/coordinator.go b/internal/runnerproto/coordinator.go
index 20018e26..163edbd1 100644
--- a/internal/runnerproto/coordinator.go
+++ b/internal/runnerproto/coordinator.go
@@ -2,6 +2,8 @@ package runnerproto
import (
"amadan.net/oficina/equipo/internal/equipo/team"
+ "amadan.net/oficina/equipo/internal/runner/provider"
+ "encoding/json"
"time"
)
@@ -35,7 +37,12 @@ type CoordinatorContext struct {
Sources []SourceSnapshot
ConfirmedPreferences []string
}
+type CoordinatorToolCopy struct {
+ Accepted, Rejected string
+ Descriptions map[string]string
+}
type CoordinatorClaim struct {
+ ToolCopy CoordinatorToolCopy
Binding CoordinatorBinding
Turn CoordinatorTurn
Scope team.Scope
@@ -46,11 +53,41 @@ type CoordinatorClaim struct {
LeaseDeadline, AttemptDeadline time.Time
}
type CoordinatorRequest struct {
- Version int `json:"version"`
- Capabilities []string `json:"capabilities"`
- TurnID string `json:"turn_id,omitempty"`
- Revision int64 `json:"revision,omitempty"`
- Claim *CoordinatorClaim `json:"claim,omitempty"`
- Event *Event `json:"event,omitempty"`
- Proof *ContainmentProof `json:"proof,omitempty"`
+ ToolCall *CoordinatorToolCall `json:"tool_call,omitempty"`
+ Version int `json:"version"`
+ Capabilities []string `json:"capabilities"`
+ TurnID string `json:"turn_id,omitempty"`
+ Revision int64 `json:"revision,omitempty"`
+ Claim *CoordinatorClaim `json:"claim,omitempty"`
+ Event *Event `json:"event,omitempty"`
+ Proof *ContainmentProof `json:"proof,omitempty"`
+}
+
+type CoordinatorToolCall struct {
+ RequestID string `json:"request_id"`
+ Name string `json:"name"`
+ Arguments json.RawMessage `json:"arguments"`
+}
+type CoordinatorToolResult struct {
+ ResourceID string `json:"resource_id"`
+ Revision int64 `json:"revision"`
+ Value json.RawMessage `json:"value"`
+}
+type ClarificationQuestion struct {
+ ID, MessageID, TurnID, Prompt, State string
+ Options []QuestionOption
+ Revision, Generation int64
+ ExpiresAt time.Time
+}
+type QuestionOption struct {
+ ID string `json:"id"`
+ Label string `json:"label"`
+}
+
+func CoordinatorCopy(copy map[string]string, accepted, rejected string) CoordinatorToolCopy {
+ out := CoordinatorToolCopy{Accepted: accepted, Rejected: rejected, Descriptions: map[string]string{}}
+ for _, name := range provider.CoordinatorTools() {
+ out.Descriptions[name] = copy["coordinator.tool."+name]
+ }
+ return out
}
diff --git a/internal/runnerproto/coordinator_handler.go b/internal/runnerproto/coordinator_handler.go
index 1f16125f..ac6c866d 100644
--- a/internal/runnerproto/coordinator_handler.go
+++ b/internal/runnerproto/coordinator_handler.go
@@ -36,6 +36,12 @@ func (s *Handler) coordinatorRunnerOperation(op string) http.HandlerFunc {
return
}
switch op {
+ case "tool":
+ if q.ToolCall == nil {
+ err = s.Invalid
+ } else {
+ value, err = s.Execution().CallCoordinatorTool(r.Context(), p, *q.Claim, *q.ToolCall)
+ }
case "renew":
value, err = s.Execution().RenewCoordinator(r.Context(), p, *q.Claim)
case "event":
diff --git a/internal/runnerproto/handler.go b/internal/runnerproto/handler.go
index a19e443b..61c0e9e2 100644
--- a/internal/runnerproto/handler.go
+++ b/internal/runnerproto/handler.go
@@ -12,6 +12,7 @@ import (
)
type ExecutionAPI interface {
+ CallCoordinatorTool(context.Context, RunnerPrincipal, CoordinatorClaim, CoordinatorToolCall) (CoordinatorToolResult, error)
PollCoordinator(context.Context, RunnerPrincipal) ([]CoordinatorTurn, error)
ClaimCoordinator(context.Context, RunnerPrincipal, string, int64) (CoordinatorClaim, error)
RenewCoordinator(context.Context, RunnerPrincipal, CoordinatorClaim) (time.Time, error)
@@ -41,7 +42,7 @@ type Handler struct {
func (s *Handler) Router() chi.Router {
r := chi.NewRouter()
- for _, op := range []string{"poll", "claim", "renew", "event", "containment"} {
+ for _, op := range []string{"poll", "claim", "renew", "event", "containment", "tool"} {
r.Post("/coordinator/"+op, s.coordinatorRunnerOperation(op))
}
r.Post("/poll", s.runnerPoll)