oficina / equipo Public

Tighten workspace approvals and repair routing prerequisites

Co-Authored-By: Astra <noreply@openai.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 164ab9ba18729da616284a10698ef4bcfa8dadfe parent d15b1e7
20 files changed, +551 −58
  • docs/superpowers/plans/CONTROLLER-REPORT-final-gaps.md +178 −0
  • internal/directlive/approval_controls_test.go +10 −1
  • internal/directlive/certification_gaps_test.go +6 −0
  • internal/directlive/driver.go +1 −0
  • internal/directlive/final_gaps_test.go +42 −0
  • internal/directlive/routing_process.go +2 −1
  • internal/directlive/routing_resource.go +61 −0
  • internal/directlive/routing_resource_test.go +36 −0
  • internal/directlive/routing_setup.go +7 −11
  • internal/directlive/terminal.go +3 −0
  • internal/directlive/tool_routing.go +6 −7
  • internal/directlive/turn.go +13 −1
  • internal/runner/coordinator_tools_test.go +9 −11
  • internal/runner/mcpresource/resource.go +29 −0
  • internal/runner/mcpresource/resource_test.go +37 −0
  • internal/runner/provider/actions.go +1 −1
  • internal/runner/provider/claude/answers.go +23 −14
  • internal/runner/provider/claude/final_gaps_test.go +81 −0
  • internal/runner/tools.go +5 −10
  • scripts/runner-reference-allowlist.json +1 −1

CI cancelled — superseded by a newer push — run details

diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-final-gaps.md b/docs/superpowers/plans/CONTROLLER-REPORT-final-gaps.md
new file mode 100644
index 00000000..0d85cad0
--- /dev/null
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-final-gaps.md
@@ -0,0 +1,178 @@
+# Final gaps, 2026-11-05
+
+H2, H3 and H4 are implemented. H1 remains incomplete: the captured Codex
+0.165.0 catalog describes `request_user_input` as available only in Plan mode.
+The normal specialist routing turn does not use Plan mode, and the model
+declined that tool. No tool exclusion or passing verdict was invented.
+
+## Controller question
+
+May specialist policies explicitly enable
+`features.default_mode_request_user_input`, with their constructor hashes
+updated and a new focused live check? The alternative is to retain the current
+policy and leave H1 blocked. The coordinator would retain its existing disabled
+question tool. This question was raised with Paul; no policy change or further
+live launch has been made pending his answer.
+
+The brief says to stop and write the question when a tool cannot be exercised.
+The limitation above comes from the captured provider tool description, not
+only the model's explanation. The model did not invoke the tool, so a runtime
+refusal has not been observed. Four of the authorized 25 model turns were used.
+
+## Changes and limits
+
+Equipo advertises one static, read-only MCP resource,
+`equipo://routing-check`, containing only `equipo-routing-ready`. Discovery
+returns that resource and no templates. Other URIs, write methods and unknown
+read fields are refused. Standard MCP `_meta` is accepted without affecting the
+response. The handler has no account, team or filesystem input. Both task and
+coordinator transports use it. The coordinator's native inventory comment now
+reflects the fixture; its tool inventory and policy authority are unchanged.
+
+The routing prompt supplies the resource URI, an explicit question, and a
+`head -n1` process before `write_stdin`. Routing questions receive the fixed
+answer automatically, including MCP requests whose context originates at
+session open. The guide acknowledges an answered MCP question before the next
+submission needs the broker slot. Native approval still uses the person path.
+Outside probes retain automatic refusal.
+
+Resource proof now requires matching call IDs, the Equipo server and the fixed
+resource or template result. Stdin proof still requires process start, a returned
+session ID, input to that same session, the marker and exit code zero. It also
+accepts the CRLF output observed from the live pseudo-terminal.
+
+The second live run passed six rows: `apply_patch`, `exec_command`,
+`mcp__equipo__ask_person`, `mcp__equipo__submit_candidate`,
+`mcp__equipo__submit_render` and `view_image`. Resource discovery and stdin
+completed successfully, but the old proof reader did not recognize their
+results. Their proof changes pass targeted tests and replay of the saved live-2 frames.
+That replay now recognizes nine of eleven workspace rows as passing. The resource read returned
+an MCP invalid-arguments error. Accepting standard read metadata is tested,
+but the incoming MCP parameters were not captured, so metadata as the cause
+remains an inference. The changed read handler and proof readers have not been
+rechecked live. All-workspace-rows-pass is not established.
+
+Claude native file actions with an omitted or relative `path` or `file_path` are refused,
+including paths that could resolve differently after a working-directory
+change. They cannot become automatic approvals by being joined to `/workspace`.
+For Glob, the literal pattern components before the first metacharacter are
+joined to the supplied absolute path before protected-path and symlink checks.
+Tests cover a symlink in that literal base and a denied path in it. Ordinary
+absolute workspace file actions remain automatic.
+
+The comment introduced at 07d9f80 now records the accepted residual race:
+Equipo's check and Claude's later filesystem operation are not atomic. A symlink
+swapped after Equipo checks relies on Claude's own symlink-aware `/home` deny
+rules for refusal. The check does not eliminate that race.
+
+The terminal reader calls `TCIFLUSH` before printing each prompt. A real
+pseudo-terminal test queues an initial stray answer and another line after each
+response. Each subsequent prompt waits for its own answer. CR, LF and CRLF are
+covered, along with the existing native allow, native deny and structured-answer
+sequence.
+
+## Launch log
+
+Only the confirmed `paul@tito.io` Codex binding `codex`, home
+`account-2598223264`, was launched. No Claude launch was needed for the targeted
+path tests. No other account was used. Credential contents were not inspected;
+only production account-lease staging handled credentials. No sign-in or edit
+to state.json, bindings.json or runner.env occurred.
+
+A temporary source overlay retained production exercise setup, account leasing,
+policies, containment, journal, tool broker, launch and shutdown. It replaced
+the full driver sequence with catalog discovery and workspace routing only.
+It ran through the built direct-live entry point. Its workspace was a disposable
+Git repository. It did not run outside probes, the full live gate, recovery
+certification, certificate writers or bundle writers. Saved observations were
+debugging captures only.
+
+All times are UTC on 2026-11-05. Launches were sequential.
+
+| Start | End | Tuple | Turns | Outcome |
+| --- | --- | --- | ---: | --- |
+| 14:45:14 | 14:47:30 | Codex Engineering, live-1 | 2 | Catalog and routing started. After the person answered `ask_person` through the actual terminal reader, the pending question occupied the submission slot. Candidate approval failed with `runner.invalid`. |
+| 14:50:48 | 14:52:19 | Codex Engineering, live-2 | 2 | Automatic question answer and candidate/render submissions succeeded. Six rows passed. Resource discovery and stdin succeeded but lacked recognized proof. Resource read failed; the Plan-only question tool was declined. |
+
+An earlier harness invocation used a binary built without the `direct_live`
+tag. It rejected the internal command before a provider launch and admitted no
+model turn. The build tag was corrected before live-1.
+
+## Verification
+
+Failing tests preceded the fixes. All commands used `CGO_ENABLED=0` and
+`-count=1`:
+
+- `go test ./internal/runner/provider/claude -run 'TestWorkspacePathsMustBeAbsolute|TestGlobLiteralBaseProtected'`
+ reproduced relative auto-approval and the unchecked Glob symlink base.
+- `go test ./internal/runner/provider/claude -run '^TestWorkspacePathMustBeExplicit$'`
+ reproduced automatic approval when the path was omitted.
+- `go test ./internal/runner/provider/claude -run '^TestGlobBaseDeniedPath$'`
+ reproduced protected-path checking before the literal base was appended.
+- `go test ./internal/runner -run '^TestRoutingResourceOnly$'`
+ reproduced missing resource discovery/read support, then rejected read
+ metadata. The final handler and test live in `internal/runner/mcpresource`.
+- `go test ./internal/directlive -run '^TestControlTerminalFlushPending$'`
+ consumed a queued stray answer in each line-ending case.
+- `go test ./internal/directlive -run 'TestRoutingSetupCompletable|TestRoutingQuestionAutomatic'`
+ reproduced missing concrete setup and the question reaching the person.
+- `go test ./internal/directlive -run '^TestRoutingMCPQuestionAutomatic$'`
+ reproduced the session-context MCP question reaching the person.
+- `go test ./internal/directlive -run '^TestCodexRoutingResourceResults$'`
+ rejected correlated successful resource-result fixtures.
+- `go test ./internal/directlive -run '^TestCodexWriteStdinRoutingPrecondition$'`
+ rejected successful pseudo-terminal CRLF output.
+
+The combined targeted tests pass, including ordinary workspace approval,
+protected-path refusal, coordinator transport, terminal controls, routing setup,
+question answers, static resources and stdin proof.
+
+Temporary overlays deliberately restored the omitted-path default, relative
+auto-approval, relative
+protected-path normalization, omission of the Glob base, omission of denied
+paths, omission of the terminal flush, acceptance of another resource URI,
+changed resource contents, rejected read metadata, omission of CRLF handling,
+disabled resource-result correlation, disabled automatic answers and bypassed
+stdin proof.
+Each corresponding test failed with an assertion. The mutations were not kept.
+Commands had the form
+`CGO_ENABLED=0 go test -overlay <overlay.json> <package> -run '^<test>$' -count=1`.
+
+The first `make -k ci` exited 2. The added transport tests exceeded the
+existing test-line budget, and changing the MCP initialize line invalidated its
+exact reference hash. The full test step ran in 5m11.446s; its only failing test
+was the same reference check. The static-resource handler and tests were moved
+into `internal/runner/mcpresource`, keeping the existing budget unchanged, and
+the one reference entry was updated. Every other lane passed. Cold boot was
+92ms against 500ms; all screens met 150ms.
+
+The first permitted rerun exited 2. All 29 packages passed uncached in
+5m9.912s, but the new resource package lacked the required test timing hook.
+Adding its standard `budget.Main` hook made the targeted budget check pass.
+Every other lane passed. Cold boot was 93ms; all screens met 150ms.
+
+These two runs reported local timing warnings for provider (20.533s and
+20.537s against 15s), Claude (46.024s and 45.908s against 45s) and Codex
+(38.465s and 38.402s against 35s). The local gate reports these warnings;
+CI timing enforcement would fail them. No passing remote gate is claimed.
+
+The second and final permitted rerun exited 0. All 29 packages passed uncached
+in 5m10.061s. Build, vet, formatting, static analysis, vulnerability and secret
+scans, reference checks, size budgets, adapter and namespace checks, migration
+and performance passed. Cold boot was 94ms; all screens met 150ms. Local timing
+warnings remained: provider 20.499s, Claude 46.669s and Codex 39.005s. There were
+exactly three full `make -k ci` invocations, within the permitted retry limit.
+
+## Delivery
+
+The delivery branch is `final-gaps`. H1 is explicitly incomplete; this is not
+a certification or a release. The remaining work requires the controller's
+question-mode decision, a fresh resource-read check, and an all-rows-pass run.
+All 18 release inventory entries retain their existing uncertified status.
+
+No README prose or user-facing copy entries changed. The resource text is a
+fixed protocol fixture. No copy-review server, merge, default-branch push or
+deployment was performed. Temporary harnesses, overlays, debugging captures,
+binaries and logs were removed after their results were recorded here. Both
+provider launches closed normally; their namespace records and staged homes
+were retired. No task process or server remains.
diff --git a/internal/directlive/approval_controls_test.go b/internal/directlive/approval_controls_test.go
index 921c0744..cfcb8f1a 100644
--- a/internal/directlive/approval_controls_test.go
+++ b/internal/directlive/approval_controls_test.go
@@ -20,6 +20,9 @@ func TestControlTerminalRawReturn(t *testing.T) {
t.Fatal(err)
}
for _, behavior := range []string{"allow", "deny", "question"} {
+ if os.Getenv("EQUIPO_TEST_STALE_INPUT") == "1" {
+ time.Sleep(100 * time.Millisecond)
+ }
if behavior == "question" {
q.Kind = "person"
q.RawRequest = []byte(`{"id":"p","kind":"person","question":"Which case?"}`)
@@ -47,6 +50,7 @@ if pid==0:
output=b'';pending=b'';sent=0
answers=[b'Allow once',b'Deny',b'{"answers":{"answer":"ordinary"}}']
ending={'cr':b'\r','crlf':b'\r\n','lf':b'\n'}[sys.argv[2]]
+if os.environ.get('EQUIPO_TEST_STALE_INPUT')=='1': os.write(fd,b'Deny\n')
try:
end=time.monotonic()+5
while time.monotonic()<end:
@@ -57,7 +61,7 @@ try:
while b'\n' in pending:
line,pending=pending.split(b'\n',1)
if line.startswith(b'Type Allow once, Deny,'):
- os.write(fd,answers[sent]+ending);sent+=1
+ os.write(fd,answers[sent]+ending+(b'Allow once\n' if os.environ.get('EQUIPO_TEST_STALE_INPUT')=='1' else b''));sent+=1
_,status=os.waitpid(pid,0)
print(output.decode())
sys.exit(os.waitstatus_to_exitcode(status))
@@ -85,3 +89,8 @@ finally:
})
}
}
+
+func TestControlTerminalFlushPending(t *testing.T) {
+ t.Setenv("EQUIPO_TEST_STALE_INPUT", "1")
+ TestControlTerminalRawReturn(t)
+}
diff --git a/internal/directlive/certification_gaps_test.go b/internal/directlive/certification_gaps_test.go
index 1f6e6824..80943f62 100644
--- a/internal/directlive/certification_gaps_test.go
+++ b/internal/directlive/certification_gaps_test.go
@@ -7,6 +7,7 @@ import (
"os/exec"
"path/filepath"
"regexp"
+ "strings"
"testing"
"amadan.net/oficina/equipo/internal/runner"
@@ -86,6 +87,11 @@ func TestCodexWriteStdinRoutingPrecondition(t *testing.T) {
if routingStatus("codex", frames, "write_stdin", "/workspace/control", false) != "pass" {
t.Fatal("successful process interaction unrecognized")
}
+ crlf := append([][]byte{}, frames...)
+ crlf[3] = frame("function_call_output", "", "write", "", strings.ReplaceAll("Process exited with code 0\nFinal output:\nequipo-routing-ready\n", "\n", "\r\n"))
+ if !codexStdinPositive(crlf) {
+ t.Fatal("PTY CRLF interaction unrecognized")
+ }
for _, missing := range []int{0, 1, 2, 3} {
broken := append([][]byte{}, frames[:missing]...)
broken = append(broken, frames[missing+1:]...)
diff --git a/internal/directlive/driver.go b/internal/directlive/driver.go
index 936b6a48..6c3a63a5 100644
--- a/internal/directlive/driver.go
+++ b/internal/directlive/driver.go
@@ -190,6 +190,7 @@ type exercise struct {
mu sync.Mutex
answers map[string]int
probing bool
+ routing bool
questions int
brokerApprovals int
staleDenied, invalidDenied, escalationDenied bool
diff --git a/internal/directlive/final_gaps_test.go b/internal/directlive/final_gaps_test.go
new file mode 100644
index 00000000..b5675be2
--- /dev/null
+++ b/internal/directlive/final_gaps_test.go
@@ -0,0 +1,42 @@
+package directlive
+
+import (
+ "amadan.net/oficina/equipo/internal/runnerproto"
+ "context"
+ "strings"
+ "testing"
+)
+
+func TestRoutingSetupCompletable(t *testing.T) {
+ x := exercise{}
+ for tool, need := range map[string]string{"request_user_input": "routing", "read_mcp_resource": "equipo://routing-check", "write_stdin": routingStdinCommand} {
+ prompt, err := x.routingSetup(context.Background(), tool, "/workspace/control")
+ if err != nil || !strings.Contains(prompt, need) {
+ t.Errorf("%s setup incomplete: %s %v", tool, prompt, err)
+ }
+ }
+}
+
+func TestRoutingQuestionAutomatic(t *testing.T) {
+ x := exercise{root: t.TempDir(), answers: map[string]int{}, d: &driver{answer: func(context.Context, runnerproto.Question) (runnerproto.QuestionAnswer, error) {
+ t.Fatal("routing question reached person")
+ return runnerproto.QuestionAnswer{}, nil
+ }}}
+ q := runnerproto.Question{ID: "routing", Kind: "question", RawRequest: []byte(`{"provider":"codex","name":"request_user_input","input":{"questions":[{"header":"routing","question":"Continue?"}]}}`)}
+ a, err := x.answer(withProbeExpectation(context.Background(), "allow"), q)
+ if err != nil || a.Behavior != "allow" || string(a.UpdatedInput) != `{"answers":{"routing":"Continue"}}` {
+ t.Fatalf("answer=%+v err=%v", a, err)
+ }
+}
+
+func TestRoutingMCPQuestionAutomatic(t *testing.T) {
+ x := exercise{routing: true, root: t.TempDir(), answers: map[string]int{}, d: &driver{answer: func(context.Context, runnerproto.Question) (runnerproto.QuestionAnswer, error) {
+ t.Fatal("routing MCP question reached person")
+ return runnerproto.QuestionAnswer{}, nil
+ }}}
+ q := runnerproto.Question{ID: "routing", Kind: "person", RawRequest: []byte(`{"id":"routing","kind":"person","question":"Continue?"}`)}
+ a, err := x.answer(context.Background(), q)
+ if err != nil || a.Behavior != "allow" {
+ t.Fatalf("answer=%+v err=%v", a, err)
+ }
+}
diff --git a/internal/directlive/routing_process.go b/internal/directlive/routing_process.go
index f4214a4d..8a9361ac 100644
--- a/internal/directlive/routing_process.go
+++ b/internal/directlive/routing_process.go
@@ -6,7 +6,7 @@ import (
"strings"
)
-const routingStdinCommand = `read -r equipo_routing_line; printf '%s\n' "$equipo_routing_line"`
+const routingStdinCommand = `head -n1`
func codexStdinPositive(frames [][]byte) bool {
starts, sessions, writes := map[string]bool{}, map[int64]bool{}, map[string]bool{}
@@ -25,6 +25,7 @@ func codexStdinPositive(frames [][]byte) bool {
continue
}
b := f.Params.Item
+ b.Output = strings.ReplaceAll(b.Output, "\r\n", "\n")
if b.Type == "function_call" && b.CallID != "" {
var args struct {
Cmd string
diff --git a/internal/directlive/routing_resource.go b/internal/directlive/routing_resource.go
new file mode 100644
index 00000000..1a0b6b5d
--- /dev/null
+++ b/internal/directlive/routing_resource.go
@@ -0,0 +1,61 @@
+package directlive
+
+import "encoding/json"
+
+// Resource controls require a correlated call and the fixed Equipo fixture.
+// Arbitrary text, provider errors and another server cannot pass these rows.
+func codexResourcePositive(frames [][]byte, tool string) bool {
+ if tool != "list_mcp_resources" && tool != "list_mcp_resource_templates" && tool != "read_mcp_resource" {
+ return false
+ }
+ const uri = "equipo://routing-check"
+ calls := map[string]bool{}
+ for _, raw := range frames {
+ var frame struct {
+ Method string
+ Params struct {
+ Item struct {
+ Type, Name, Arguments, Output string
+ CallID string `json:"call_id"`
+ }
+ }
+ }
+ if json.Unmarshal(raw, &frame) != nil || frame.Method != "rawResponseItem/completed" {
+ continue
+ }
+ item := frame.Params.Item
+ if item.Type == "function_call" && item.Name == tool && item.CallID != "" {
+ var args struct{ Server, URI string }
+ if json.Unmarshal([]byte(item.Arguments), &args) == nil && args.Server == "equipo" && (tool != "read_mcp_resource" || args.URI == uri) {
+ calls[item.CallID] = true
+ }
+ }
+ if item.Type != "function_call_output" || !calls[item.CallID] {
+ continue
+ }
+ var result struct {
+ Server, URI string
+ Resources []struct{ Server, URI, Name, MimeType string }
+ ResourceTemplates []json.RawMessage
+ Contents []struct{ URI, MimeType, Text string }
+ }
+ if json.Unmarshal([]byte(item.Output), &result) != nil || result.Server != "equipo" {
+ continue
+ }
+ switch tool {
+ case "list_mcp_resources":
+ if len(result.Resources) == 1 && result.Resources[0].URI == uri && result.Resources[0].Name == "routing-check" && result.Resources[0].MimeType == "text/plain" {
+ return true
+ }
+ case "list_mcp_resource_templates":
+ if result.ResourceTemplates != nil && len(result.ResourceTemplates) == 0 {
+ return true
+ }
+ case "read_mcp_resource":
+ if result.URI == uri && len(result.Contents) == 1 && result.Contents[0].URI == uri && result.Contents[0].MimeType == "text/plain" && result.Contents[0].Text == "equipo-routing-ready" {
+ return true
+ }
+ }
+ }
+ return false
+}
diff --git a/internal/directlive/routing_resource_test.go b/internal/directlive/routing_resource_test.go
new file mode 100644
index 00000000..bdcd70e4
--- /dev/null
+++ b/internal/directlive/routing_resource_test.go
@@ -0,0 +1,36 @@
+package directlive
+
+import (
+ "encoding/json"
+ "testing"
+)
+
+func TestCodexRoutingResourceResults(t *testing.T) {
+ for _, tc := range []struct{ tool, args, output string }{
+ {"list_mcp_resources", `{"server":"equipo"}`, `{"server":"equipo","resources":[{"server":"equipo","uri":"equipo://routing-check","name":"routing-check","mimeType":"text/plain"}]}`},
+ {"list_mcp_resource_templates", `{"server":"equipo"}`, `{"server":"equipo","resourceTemplates":[]}`},
+ {"read_mcp_resource", `{"server":"equipo","uri":"equipo://routing-check"}`, `{"server":"equipo","uri":"equipo://routing-check","contents":[{"uri":"equipo://routing-check","mimeType":"text/plain","text":"equipo-routing-ready"}]}`},
+ } {
+ t.Run(tc.tool, func(t *testing.T) {
+ frame := func(kind, id, name, args, output string) []byte {
+ return marshal(map[string]any{"method": "rawResponseItem/completed", "params": map[string]any{"item": map[string]any{"type": kind, "call_id": id, "name": name, "arguments": args, "output": output}}})
+ }
+ call := frame("function_call", "call", tc.tool, tc.args, "")
+ result := frame("function_call_output", "call", "", "", tc.output)
+ if routingStatus("codex", [][]byte{call, result}, tc.tool, "/workspace/control", false) != "pass" {
+ t.Fatal("successful resource result missed")
+ }
+ for _, frames := range [][][]byte{{call}, {result}, {call, frame("function_call_output", "other", "", "", tc.output)}, {call, frame("function_call_output", "call", "", "", `{"error":"failed"}`)}} {
+ if routingStatus("codex", frames, tc.tool, "/workspace/control", false) == "pass" {
+ t.Fatal("incomplete or failed resource call passed")
+ }
+ }
+ var args map[string]any
+ json.Unmarshal([]byte(tc.args), &args)
+ args["server"] = "other"
+ if routingStatus("codex", [][]byte{frame("function_call", "call", tc.tool, string(marshal(args)), ""), result}, tc.tool, "/workspace/control", false) == "pass" {
+ t.Fatal("other server passed")
+ }
+ })
+ }
+}
diff --git a/internal/directlive/routing_setup.go b/internal/directlive/routing_setup.go
index 784ec21a..c7d87295 100644
--- a/internal/directlive/routing_setup.go
+++ b/internal/directlive/routing_setup.go
@@ -10,15 +10,6 @@ import (
"amadan.net/oficina/equipo/internal/runner/provider"
)
-// Unavailable prerequisites remain certification failures. This list explains
-// the fixed known case; it grants no exemption from a successful control.
-func routingPrerequisite(tool string) string {
- if tool == "read_mcp_resource" {
- return "the pinned Equipo server exposes tools but no resources"
- }
- return ""
-}
-
func (x *exercise) routingSetup(ctx context.Context, tool, path string) (string, error) {
name := strings.TrimPrefix(tool, "mcp__equipo__")
args := map[string]any{"request_id": "routing-" + name}
@@ -49,9 +40,14 @@ func (x *exercise) routingSetup(ctx context.Context, tool, path string) (string,
case "ask_person":
args["question"] = "May this disposable workspace routing control finish?"
case "write_stdin":
- return "Precondition: use exec_command to start read -r equipo_routing_line; printf '%s\\n' \"$equipo_routing_line\" with tty=true and yield_time_ms=1. Use its returned session_id with write_stdin, chars=equipo-routing-ready followed by a newline. Wait for exit code 0 and the echoed marker. This setup call is additional to the exec_command control.\n", nil
+ return fmt.Sprintf("Precondition: first use exec_command with cmd=%q, tty=true and yield_time_ms=1000. It waits for stdin. Then call write_stdin with the returned session_id and chars=equipo-routing-ready followed by a newline. Wait for exit code 0 and the echoed marker. The exec_command setup is required in addition to its own routing control.\n", routingStdinCommand), nil
case "read_mcp_resource":
- return "List available MCP resources first and read one only if it exists. If none exists, report that prerequisite as unavailable.\n", nil
+ return "Call read_mcp_resource with server=equipo and uri=equipo://routing-check. It is a fixed, read-only routing fixture.\n", nil
+ case "list_mcp_resources", "list_mcp_resource_templates":
+ return "Call this tool with server=equipo.\n", nil
+ case "request_user_input":
+ return `Call request_user_input exactly once with {"questions":[{"id":"routing","header":"routing","question":"Continue this disposable routing check?","options":[{"label":"Continue","description":"Finish the check."},{"label":"Stop","description":"Stop the check."}]}]}. The routing harness answers Continue automatically; wait for its answer before finishing.
+`, nil
default:
return "Use valid arguments for a harmless workspace control. A missing prerequisite fails certification; never invent evidence.\n", nil
}
diff --git a/internal/directlive/terminal.go b/internal/directlive/terminal.go
index 03e15e44..ab989f6a 100644
--- a/internal/directlive/terminal.go
+++ b/internal/directlive/terminal.go
@@ -22,6 +22,9 @@ func terminalAnswer(ctx context.Context, q runnerproto.Question) (runnerproto.Qu
if _, err = unix.IoctlGetTermios(int(tty.Fd()), unix.TCGETS); err != nil {
return answer, err
}
+ if err = unix.IoctlSetInt(int(tty.Fd()), unix.TCFLSH, unix.TCIFLUSH); err != nil {
+ return answer, err
+ }
key := terminalGuidance(ctx)
if key == "" && (q.Kind == "person" || q.Kind == "question") {
key = "live.check-question"
diff --git a/internal/directlive/tool_routing.go b/internal/directlive/tool_routing.go
index 9c692845..8ce75b9f 100644
--- a/internal/directlive/tool_routing.go
+++ b/internal/directlive/tool_routing.go
@@ -14,7 +14,7 @@ import (
)
func routingStatus(family string, frames [][]byte, tool, path string, outside bool) string {
- if family == "codex" && !outside && (codexRoutingPositive(frames, tool, path) || tool == "write_stdin" && codexStdinPositive(frames)) {
+ if family == "codex" && !outside && (codexRoutingPositive(frames, tool, path) || codexResourcePositive(frames, tool) || tool == "write_stdin" && codexStdinPositive(frames)) {
return "pass"
}
if family == "codex" && tool == "write_stdin" && !outside {
@@ -79,7 +79,7 @@ func (x *exercise) toolRouting(ctx context.Context) error {
x.mu.Lock()
x.probing = true
x.mu.Unlock()
- defer func() { x.mu.Lock(); x.probing = false; x.mu.Unlock() }()
+ defer func() { x.mu.Lock(); x.probing = false; x.routing = false; x.mu.Unlock() }()
markers, err := x.probeMarkers()
if err != nil {
return err
@@ -167,12 +167,14 @@ func (x *exercise) toolRouting(ctx context.Context) error {
if !outside {
x.mu.Lock()
x.probing = false
+ x.routing = true
x.mu.Unlock()
- turnContext = withControlExpectation(ctx, "allow")
+ turnContext = withProbeExpectation(ctx, "allow")
}
frames, err := x.turn(turnContext, prompt.String())
x.mu.Lock()
x.probing = true
+ x.routing = false
x.mu.Unlock()
if err != nil {
return err
@@ -192,9 +194,6 @@ func (x *exercise) toolRouting(ctx context.Context) error {
return provider.ErrIsolation
}
status := routingStatus(x.evidence.Provider, frames, tool.Name, paths[tool.Name], outside)
- if !outside && status != "pass" && routingPrerequisite(tool.Name) != "" {
- status = "not-exercisable"
- }
if outside && tool.Name == "Bash" && x.evidence.Provider == "claude" && x.outerPresent(paths[tool.Name]) {
rawFrames := make([]json.RawMessage, len(frames))
for j, f := range frames {
@@ -215,7 +214,7 @@ func (x *exercise) toolRouting(ctx context.Context) error {
for j, f := range frames {
raw[j] = f
}
- o, err := observation(x.root, fmt.Sprintf("routing-%s-%d.json", key, i), status, map[string]any{"tool": tool.Name, "path": paths[tool.Name], "frames": raw, "approval_questions": questions, "unavailable_prerequisite": routingPrerequisite(tool.Name)})
+ o, err := observation(x.root, fmt.Sprintf("routing-%s-%d.json", key, i), status, map[string]any{"tool": tool.Name, "path": paths[tool.Name], "frames": raw, "approval_questions": questions})
if err != nil {
return err
}
diff --git a/internal/directlive/turn.go b/internal/directlive/turn.go
index 28842092..46d7c4fc 100644
--- a/internal/directlive/turn.go
+++ b/internal/directlive/turn.go
@@ -41,6 +41,11 @@ func (x *exercise) open(ctx context.Context, tool string) error {
relay := x.relay()
relay.Binding = bound
answer, err := relay.Ask(ctx, id, args, x.answer)
+ if err == nil {
+ // The disposable guide acts as supervisor and consumes this answered
+ // question before the next routing submission needs the broker slot.
+ err = x.journal.AckTool(ctx, q)
+ }
return answer, err
}
if permission, ok := x.launcher.(interface {
@@ -166,10 +171,17 @@ func (x *exercise) answer(ctx context.Context, q runnerproto.Question) (runnerpr
var err error
expectation, _ := ctx.Value(probeExpectationKey{}).(probeExpectation)
x.mu.Lock()
- probing := x.probing
+ probing, routing := x.probing, x.routing
x.mu.Unlock()
if probing || expectation.automatic && expectation.behavior == "deny" {
a.Behavior = "deny"
+ } else if (routing || expectation.automatic && expectation.behavior == "allow") && (q.Kind == "question" || q.Kind == "person") {
+ a.Behavior = "allow"
+ key := "routing"
+ if q.Kind == "person" {
+ key = "answer"
+ }
+ a.UpdatedInput = marshal(map[string]any{"answers": map[string]string{key: "Continue"}})
} else {
a, err = x.d.answer(ctx, q)
}
diff --git a/internal/runner/coordinator_tools_test.go b/internal/runner/coordinator_tools_test.go
index 154b826f..9c6a861e 100644
--- a/internal/runner/coordinator_tools_test.go
+++ b/internal/runner/coordinator_tools_test.go
@@ -228,21 +228,19 @@ func TestCoordinatorToolBroker(t *testing.T) {
}
if method == "initialize" {
caps := reply["result"].(map[string]any)["capabilities"].(map[string]any)
- if _, ok := caps["resources"]; ok {
- t.Fatal("resources capability advertised")
+ if _, ok := caps["resources"]; !ok {
+ t.Fatal("resources capability missing")
}
}
- if method == "resources/list" || method == "resources/templates/list" {
- key := "resources"
- if method == "resources/templates/list" {
- key = "resourceTemplates"
- }
- result := reply["result"].(map[string]any)
- entries, ok := result[key].([]any)
- if !ok || len(entries) != 0 || len(result) != 1 {
- t.Fatal("nonempty resource discovery", reply)
+ if method == "resources/list" {
+ entries := reply["result"].(map[string]any)["resources"].([]any)
+ if len(entries) != 1 || entries[0].(map[string]any)["uri"] != "equipo://routing-check" {
+ t.Fatal("unexpected resources", reply)
}
}
+ if method == "resources/templates/list" && len(reply["result"].(map[string]any)["resourceTemplates"].([]any)) != 0 {
+ t.Fatal("resource templates exposed", reply)
+ }
if method == "tools/list" {
raw, _ := json.Marshal(reply)
if !strings.Contains(string(raw), "source_message_ids") || strings.Contains(string(raw), "submit_candidate") {
diff --git a/internal/runner/mcpresource/resource.go b/internal/runner/mcpresource/resource.go
new file mode 100644
index 00000000..84a75afc
--- /dev/null
+++ b/internal/runner/mcpresource/resource.go
@@ -0,0 +1,29 @@
+package mcpresource
+
+import (
+ "amadan.net/oficina/equipo/internal/runnerproto"
+ "bytes"
+ "encoding/json"
+)
+
+// The routing fixture contains no team, account or filesystem data. Every
+// specialist and coordinator gets the same bytes, with no write operation.
+func Result(method string, raw json.RawMessage) (any, error) {
+ const uri = "equipo://routing-check"
+ switch method {
+ case "resources/list":
+ return map[string]any{"resources": []any{map[string]string{"uri": uri, "name": "routing-check", "mimeType": "text/plain"}}}, nil
+ case "resources/templates/list":
+ return map[string]any{"resourceTemplates": []any{}}, nil
+ case "resources/read":
+ var params struct {
+ URI string `json:"uri"`
+ Meta json.RawMessage `json:"_meta,omitempty"`
+ }
+ if runnerproto.DecodeLimit(bytes.NewReader(raw), &params, 64<<10) != nil || params.URI != uri {
+ return nil, runnerproto.ErrInvalid
+ }
+ return map[string]any{"contents": []any{map[string]string{"uri": uri, "mimeType": "text/plain", "text": "equipo-routing-ready"}}}, nil
+ }
+ return nil, runnerproto.ErrInvalid
+}
diff --git a/internal/runner/mcpresource/resource_test.go b/internal/runner/mcpresource/resource_test.go
new file mode 100644
index 00000000..09b4b875
--- /dev/null
+++ b/internal/runner/mcpresource/resource_test.go
@@ -0,0 +1,37 @@
+package mcpresource
+
+import (
+ "amadan.net/rastrillo/rastrillo/budget"
+ "encoding/json"
+ "os"
+ "testing"
+)
+
+func TestRoutingResourceOnly(t *testing.T) {
+ for _, q := range []struct{ method, params, want string }{
+ {"resources/list", `{}`, `{"resources":[{"mimeType":"text/plain","name":"routing-check","uri":"equipo://routing-check"}]}`},
+ {"resources/templates/list", `{}`, `{"resourceTemplates":[]}`},
+ {"resources/read", `{"uri":"equipo://routing-check"}`, `{"contents":[{"mimeType":"text/plain","text":"equipo-routing-ready","uri":"equipo://routing-check"}]}`},
+ {"resources/read", `{"uri":"equipo://routing-check","_meta":{"progressToken":1}}`, `{"contents":[{"mimeType":"text/plain","text":"equipo-routing-ready","uri":"equipo://routing-check"}]}`},
+ {"resources/read", `{"uri":"file:///workspace/private"}`, ""},
+ {"resources/read", `{"uri":"equipo://routing-check/other"}`, ""},
+ {"resources/read", `{"uri":"equipo://routing-check","path":"/home/runner"}`, ""},
+ {"resources/write", `{"uri":"equipo://routing-check","text":"changed"}`, ""},
+ } {
+ t.Run(q.method+q.params, func(t *testing.T) {
+ result, err := Result(q.method, json.RawMessage(q.params))
+ if q.want == "" {
+ if err == nil {
+ t.Fatal("invalid request accepted", result)
+ }
+ return
+ }
+ raw, marshalErr := json.Marshal(result)
+ if err != nil || marshalErr != nil || string(raw) != q.want {
+ t.Fatalf("result=%s err=%v marshal=%v", raw, err, marshalErr)
+ }
+ })
+ }
+}
+
+func TestMain(m *testing.M) { os.Exit(budget.Main(m)) }
diff --git a/internal/runner/provider/actions.go b/internal/runner/provider/actions.go
index 857cf417..1404dd8a 100644
--- a/internal/runner/provider/actions.go
+++ b/internal/runner/provider/actions.go
@@ -54,7 +54,7 @@ func CoordinatorTools() []string {
}
// Codex 0.165.0 registers these whenever MCP is configured. The coordinator's
-// only server exposes no resources; Claude has no native-tool exception.
+// only server exposes one static routing fixture; Claude has no native-tool exception.
func CoordinatorNativeTools(family string) []string {
if family == "codex" {
return []string{"list_mcp_resources", "list_mcp_resource_templates", "read_mcp_resource"}
diff --git a/internal/runner/provider/claude/answers.go b/internal/runner/provider/claude/answers.go
index 461bae4c..e93e7638 100644
--- a/internal/runner/provider/claude/answers.go
+++ b/internal/runner/provider/claude/answers.go
@@ -159,7 +159,7 @@ func permissionResult(q permissionRequest, a provider.Answer, policy provider.Po
return nil, provider.ErrPolicy
}
if !filepath.IsAbs(path) {
- path = filepath.Join("/workspace", path)
+ return nil, provider.ErrPolicy
}
path = filepath.Clean(path)
for _, deny := range m.DeniedPaths {
@@ -215,7 +215,7 @@ func protectedNativePath(q permissionRequest, policy provider.Policy) bool {
if json.Unmarshal(policy.Manifest, &m) != nil || json.Unmarshal(q.Input, &input) != nil {
return true
}
- path := "/workspace"
+ path := ""
for _, key := range []string{"file_path", "path"} {
if raw, ok := input[key]; ok {
if json.Unmarshal(raw, &path) != nil || path == "" {
@@ -228,7 +228,22 @@ func protectedNativePath(q permissionRequest, policy provider.Policy) bool {
return true
}
if !filepath.IsAbs(path) {
- path = filepath.Join("/workspace", path)
+ return true
+ }
+ if q.Tool == "Glob" {
+ var pattern string
+ if raw, ok := input["pattern"]; ok {
+ if json.Unmarshal(raw, &pattern) != nil || filepath.IsAbs(pattern) || slices.Contains(strings.Split(pattern, "/"), "..") {
+ return true
+ }
+ // Only the literal base is known before Glob expands the pattern.
+ for _, part := range strings.Split(pattern, "/") {
+ if strings.ContainsAny(part, "*?[{\\") {
+ break
+ }
+ path = filepath.Join(path, part)
+ }
+ }
}
path = filepath.Clean(path)
if path == "/home" || strings.HasPrefix(path, "/home/") {
@@ -242,14 +257,6 @@ func protectedNativePath(q permissionRequest, policy provider.Policy) bool {
if path != "/workspace" && !strings.HasPrefix(path, "/workspace/") {
return false
}
- if q.Tool == "Glob" {
- var pattern string
- if raw, ok := input["pattern"]; ok {
- if json.Unmarshal(raw, &pattern) != nil || filepath.IsAbs(pattern) || slices.Contains(strings.Split(pattern, "/"), "..") {
- return true
- }
- }
- }
host := m.Workspace
if !filepath.IsAbs(host) {
return true
@@ -273,7 +280,9 @@ func protectedNativePath(q permissionRequest, policy provider.Policy) bool {
// workspaceNativePath reports a native file action whose path is inside
// /workspace. Callers must first refuse protectedNativePath, which also
-// rejects workspace symlinks that leave the workspace.
+// rejects existing workspace symlinks. A symlink swapped after Equipo checks
+// remains a race: Claude's own symlink-aware /home deny rules must catch it.
+// This is an accepted residual risk, not an atomic filesystem guarantee.
func workspaceNativePath(q permissionRequest) bool {
if !slices.Contains([]string{"Read", "Write", "Edit", "Glob", "Grep"}, q.Tool) {
return false
@@ -282,7 +291,7 @@ func workspaceNativePath(q permissionRequest) bool {
if json.Unmarshal(q.Input, &input) != nil {
return false
}
- path := "/workspace"
+ path := ""
for _, key := range []string{"file_path", "path"} {
if raw, ok := input[key]; ok {
if json.Unmarshal(raw, &path) != nil || path == "" || strings.HasPrefix(path, "~") {
@@ -292,7 +301,7 @@ func workspaceNativePath(q permissionRequest) bool {
}
}
if !filepath.IsAbs(path) {
- path = filepath.Join("/workspace", path)
+ return false
}
path = filepath.Clean(path)
return path == "/workspace" || strings.HasPrefix(path, "/workspace/")
diff --git a/internal/runner/provider/claude/final_gaps_test.go b/internal/runner/provider/claude/final_gaps_test.go
new file mode 100644
index 00000000..75a78de0
--- /dev/null
+++ b/internal/runner/provider/claude/final_gaps_test.go
@@ -0,0 +1,81 @@
+package claude
+
+import (
+ "amadan.net/oficina/equipo/internal/runner/provider"
+ "encoding/json"
+ "os"
+ "path/filepath"
+ "testing"
+)
+
+func TestWorkspacePathsMustBeAbsolute(t *testing.T) {
+ f := fixtureFor(t, "Engineering")
+ for _, tool := range []string{"Read", "Write", "Edit", "Glob", "Grep"} {
+ for _, path := range []string{"ordinary.txt", ".", "./ordinary.txt", "../ordinary.txt", "../../home/runner/auth", "sub/../../home/runner/auth"} {
+ for _, key := range []string{"file_path", "path"} {
+ q := permissionRequest{Tool: tool, Input: marshalProbe(map[string]string{key: path, "pattern": "*.txt"})}
+ if workspaceNativePath(q) {
+ t.Errorf("%s auto-allows %s=%s", tool, key, path)
+ }
+ if !protectedNativePath(q, f.launch.Policy) {
+ t.Errorf("%s relative path not refused: %s", tool, path)
+ }
+ if _, err := permissionResult(q, provider.Answer{Behavior: "allow"}, f.launch.Policy); err == nil {
+ t.Errorf("relative path approvable: %s", path)
+ }
+ }
+ }
+ }
+}
+
+func TestGlobLiteralBaseProtected(t *testing.T) {
+ f := fixtureFor(t, "Engineering")
+ if err := os.Mkdir(filepath.Join(f.launch.Workspace, "safe"), 0700); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.Symlink("/home/runner", filepath.Join(f.launch.Workspace, "safe", "alias")); err != nil {
+ t.Fatal(err)
+ }
+ for _, tc := range []struct {
+ path, pattern string
+ denied bool
+ }{
+ {"/workspace", "safe/alias/*.txt", true},
+ {"/workspace/safe", "alias/**/*.txt", true},
+ {"/workspace", "safe/alias", true},
+ {"/workspace", "safe/[ab]*.txt", false},
+ {"/workspace", "safe/{a,b}/*.txt", false},
+ {"/workspace", "safe/*.txt", false},
+ {"/workspace", "../home/*", true},
+ {"/workspace", "/home/*", true},
+ } {
+ q := permissionRequest{Tool: "Glob", Input: marshalProbe(map[string]string{"path": tc.path, "pattern": tc.pattern})}
+ if got := protectedNativePath(q, f.launch.Policy); got != tc.denied {
+ t.Errorf("%s + %s denied=%v", tc.path, tc.pattern, got)
+ }
+ }
+}
+
+func TestGlobBaseDeniedPath(t *testing.T) {
+ f := fixtureFor(t, "Engineering")
+ var m manifest
+ if err := json.Unmarshal(f.launch.Policy.Manifest, &m); err != nil {
+ t.Fatal(err)
+ }
+ m.DeniedPaths = append(m.DeniedPaths, "/workspace/private")
+ f.launch.Policy.Manifest = marshalProbe(m)
+ q := permissionRequest{Tool: "Glob", Input: marshalProbe(map[string]string{"path": "/workspace", "pattern": "private/*.txt"})}
+ if !protectedNativePath(q, f.launch.Policy) {
+ t.Fatal("Glob literal base bypasses denied paths")
+ }
+}
+
+func TestWorkspacePathMustBeExplicit(t *testing.T) {
+ f := fixtureFor(t, "Engineering")
+ for _, tool := range []string{"Read", "Write", "Edit", "Glob", "Grep"} {
+ q := permissionRequest{Tool: tool, Input: marshalProbe(map[string]string{"pattern": "*.txt"})}
+ if workspaceNativePath(q) || !protectedNativePath(q, f.launch.Policy) {
+ t.Errorf("%s assumes the current directory is /workspace", tool)
+ }
+ }
+}
diff --git a/internal/runner/tools.go b/internal/runner/tools.go
index 460c6c9b..b83fa90d 100644
--- a/internal/runner/tools.go
+++ b/internal/runner/tools.go
@@ -13,6 +13,7 @@ import (
"unicode/utf8"
"amadan.net/oficina/equipo/internal/coordinator"
+ "amadan.net/oficina/equipo/internal/runner/mcpresource"
"amadan.net/oficina/equipo/internal/runnerproto"
"amadan.net/oficina/equipo/internal/taskplan"
)
@@ -174,21 +175,15 @@ func serveTools(ctx context.Context, input io.Reader, output io.Writer, capabili
params.ProtocolVersion = "2025-06-18"
}
initialized = true
- result = map[string]any{"protocolVersion": params.ProtocolVersion, "capabilities": map[string]any{"tools": map[string]any{}}, "serverInfo": map[string]any{"name": "equipo-runner", "version": "1"}}
+ result = map[string]any{"protocolVersion": params.ProtocolVersion, "capabilities": map[string]any{"tools": map[string]any{}, "resources": map[string]any{}}, "serverInfo": map[string]any{"name": "equipo-runner", "version": "1"}}
case "ping":
result = map[string]any{}
- case "resources/list", "resources/templates/list":
- if !initialized || !cap.Coordinator {
+ case "resources/list", "resources/templates/list", "resources/read":
+ if !initialized {
err = runnerproto.ErrInvalid
break
}
- key := "resources"
- if q.Method == "resources/templates/list" {
- key = "resourceTemplates"
- }
- result = map[string]any{key: []any{}}
- case "resources/read":
- err = runnerproto.ErrInvalid
+ result, err = mcpresource.Result(q.Method, q.Params)
case "tools/list":
if !initialized {
err = runnerproto.ErrInvalid
diff --git a/scripts/runner-reference-allowlist.json b/scripts/runner-reference-allowlist.json
index c233f1e2..a89efcce 100644
--- a/scripts/runner-reference-allowlist.json
+++ b/scripts/runner-reference-allowlist.json
@@ -5846,7 +5846,7 @@
},
{
"path": "internal/runner/tools.go",
- "line_sha256": "79958bbf3060319bb707c654d3a746972fafca69cb656e71e82bff191362c19e",
+ "line_sha256": "204f0d2bbb0575eaa33b464e150a65b3916efc43213f9b8994d8ca70d8b6a7d7",
"match": "equipo-runner",
"count": 1,
"reason": "Retained executable, service or command path; not an operating-system account requirement."