oficina / equipo Public

Merge branch 'final-gaps' into main

runner: final certification gaps before Paul's live gate

Codex specialists drop the native question tool; one static MCP resource and
stdin setup make every routing row exercisable; Claude auto-approves only
absolute workspace paths; prompts flush stray input.
claude agent, operated by paul@keymail.dev 35e2cab79a619a35d5ac453e57e5afbe80652086 parent ad40828parent 49cdfb5
30 files changed, +806 −77
  • docs/superpowers/plans/CODEX-BRIEF-final-gaps-2.md +24 −0
  • docs/superpowers/plans/CODEX-BRIEF-final-gaps.md +43 −0
  • docs/superpowers/plans/CONTROLLER-REPORT-final-gaps.md +304 −0
  • internal/directlive/approval_controls_test.go +10 −1
  • internal/directlive/certification_gaps_test.go +6 −0
  • internal/directlive/codex_inventory.go +1 −1
  • 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 +4 −11
  • internal/directlive/terminal.go +3 −0
  • internal/directlive/tool_routing.go +6 −7
  • internal/directlive/try_inventory_test.go +1 −1
  • internal/directlive/turn.go +13 −1
  • internal/release/manifest.json +8 −8
  • internal/runner/coordinator_tools_test.go +9 −11
  • internal/runner/mcpresource/resource.go +30 −0
  • internal/runner/mcpresource/resource_test.go +38 −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/provider/codex/catalog_guards_test.go +7 −2
  • internal/runner/provider/codex/config_readback.go +10 −6
  • internal/runner/provider/codex/live_config_test.go +30 −0
  • internal/runner/provider/codex/probe_failures_test.go +4 −1
  • internal/runner/provider/codex/specialist_catalog.go +2 −0
  • internal/runner/tools.go +5 −10
  • scripts/runner-reference-allowlist.json +1 −1

CI passed — run details

landed from final-gaps

diff --git a/docs/superpowers/plans/CODEX-BRIEF-final-gaps-2.md b/docs/superpowers/plans/CODEX-BRIEF-final-gaps-2.md
new file mode 100644
index 00000000..c7ab321f
--- /dev/null
+++ b/docs/superpowers/plans/CODEX-BRIEF-final-gaps-2.md
@@ -0,0 +1,24 @@
+# Brief: final gaps round 2 — answer to your H1 question
+
+Same branch at 164ab9b. Same AUTHORISATION (paul@tito.io Codex only this
+time; Claude not needed). Budget 10 model turns.
+
+Controller decision on H1: do NOT enable
+`features.default_mode_request_user_input`. Specialists ask people only
+through Equipo's `mcp__equipo__ask_person`. Remove `request_user_input`
+from the specialist tool surface instead: drop it from the generated
+specialist model catalog (or disable the feature that exposes it,
+whichever the pinned 0.165.0 honours), bind that into the policy hash,
+assert in the tool-inventory/readback that it is ABSENT for specialists,
+and fail if it appears. Coordinator unchanged.
+
+Then fix `read_mcp_resource` (invalid-arguments in live-2): capture the
+incoming MCP params shape (no secrets involved; it's a fixed resource),
+fix the handler, and prove live that every Codex specialist workspace
+routing row passes for codex-Engineering (catalog without
+request_user_input; read_mcp_resource, list tools, write_stdin
+included). Targeted tests, ONE full `make -k ci` (rerun at most twice).
+Commit subject < 80, body `Co-Authored-By: Astra <noreply@openai.com>`,
+push. "Round 2" in CONTROLLER-REPORT-final-gaps.md with the launch log.
+Scratch removed; nothing running; no copy-review server. If blocked,
+commit what is safe and print the question. Print a five-line summary.
diff --git a/docs/superpowers/plans/CODEX-BRIEF-final-gaps.md b/docs/superpowers/plans/CODEX-BRIEF-final-gaps.md
new file mode 100644
index 00000000..3e759b6d
--- /dev/null
+++ b/docs/superpowers/plans/CODEX-BRIEF-final-gaps.md
@@ -0,0 +1,43 @@
+# Brief: last gaps before Paul's certification run (Opus review of ad40828)
+
+Branch `final-gaps` from main ad40828. Read CONTROLLER-REPORT-approval-
+controls.md and CONTROLLER-REPORT-certification-gaps.md. AUTHORISATION
+as CODEX-BRIEF-live-turn-failures.md (paul@tito.io Claude + Codex only,
+sequential, no full gate, no bundle, no credential contents, no
+sign-ins); you may play the person via the guide's terminal reader.
+Budget 25 model turns. Controller decisions:
+
+- H1 Codex tools that can never pass: `read_mcp_resource` (always
+ exposed by 0.165.0; Equipo's MCP server has no resources),
+ `request_user_input`, `write_stdin` (declined in run 4). Make each
+ genuinely exercisable in the workspace routing check:
+ * Equipo's MCP server serves exactly one static, read-only resource
+ (e.g. `equipo://routing-check`, short fixed text, no data, same for
+ every tuple; no other resources; list/templates reflect it) so
+ read_mcp_resource and the list tools pass on a real call. Keep the
+ coordinator's inventory rules consistent.
+ * request_user_input: the routing turn asks it once and the answer path
+ (automatic in routing, as today) completes it.
+ * write_stdin: the routing turn first starts a process with
+ exec_command that waits on stdin (e.g. `head -n1`), then writes to
+ it.
+ Prove all Codex workspace routing rows `pass` live for codex-Engineering.
+ If any tool truly cannot be exercised, stop and write the question.
+- H2 Claude auto-allow (answers.go workspaceNativePath and the protected
+ check): auto-allow only ABSOLUTE paths under /workspace; a relative
+ `path`/`file_path` is never auto-allowed (it goes through the normal
+ person path, or is refused if that is what policy says). For Glob,
+ compute the pattern's literal base directory (components before the
+ first glob metacharacter) and run the symlink/protected check on
+ path+base; auto-allow only if that passes. Tests for relative paths,
+ `cd`-style relative escapes, and a pattern whose base is a symlink.
+- H3 Fix the comment at 07d9f80 to state the residual race (a symlink
+ swapped after Equipo's check is still caught by Claude's own
+ symlink-aware deny rules for /home; recorded as accepted residual risk)
+ and add that to docs/superpowers/plans/CONTROLLER-REPORT-final-gaps.md.
+- H4 Terminal reader: flush pending input (TCIFLUSH) before each prompt
+ so a stray line cannot answer the next prompt; test with a pty.
+- H5 Targeted tests, ONE full `make -k ci` (rerun at most twice). Commit
+ subject < 80, body `Co-Authored-By: Astra <noreply@openai.com>`, push.
+ CONTROLLER-REPORT-final-gaps.md with the launch log. Scratch removed;
+ nothing running; no copy-review server. Print a five-line summary.
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..cec1c2c0
--- /dev/null
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-final-gaps.md
@@ -0,0 +1,304 @@
+# Final gaps, 2026-11-05
+
+Round 2 below resolves H1. The earlier question and limitations in this report
+record round 1 and are superseded by the round 2 results.
+
+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.
+
+## Round 2
+
+H1 is complete. Both focused Codex Engineering launches passed every exposed
+workspace routing row. The native `request_user_input` tool was absent from
+both captured catalogs. Specialists retain `mcp__equipo__ask_person` for questions.
+
+The pinned 0.165.0 honors `tools.experimental_request_user_input.enabled=false`.
+Specialist construction now sets that flag and explicitly keeps
+`features.default_mode_request_user_input=false`. These settings are included
+in the existing policy manifest and hash. The live specialist inventory rejects
+`request_user_input` in any captured catalog frame. The obsolete routing prompt
+for that native question tool was removed. The coordinator policy is unchanged.
+
+Typed effective config omits the disabled tool flag, as it already did for the
+coordinator. Specialist readback now accepts that exact pinned omission only
+when the tool map is `{"web_search":null}` and the requested flag is false.
+The command-line layer must retain the requested settings. Enabled, missing or
+changed settings are rejected, and catalog absence is checked independently.
+Eight Codex specialist inventory hashes changed; the coordinator hash did not.
+All 18 release inventory entries remain uncertified.
+
+### Resource read diagnosis
+
+The first launch captured these incoming `resources/read` parameters:
+
+```json
+{"_meta":{"progressToken":6},"uri":"equipo://routing-check"}
+```
+
+The previous round had already added `_meta` support after live-2, without a
+fresh live check. The new capture confirms that Codex sends this field. Removing
+that support reproduces `runner.invalid` with the captured parameters. The
+existing fix is retained, documented and covered by the exact captured input;
+no broader resource handler change was needed. Unknown fields and other URIs
+remain refused. The second launch used the uninstrumented handler and returned
+the fixed resource successfully.
+
+### Launch log
+
+Only binding `codex`, account `paul@tito.io`, home `account-2598223264`, model
+`gpt-6-astra`, provider 0.165.0 was launched. No Claude launch or other account
+was used. Credential contents were not inspected. Credential staging used the
+production account lease. No sign-in or edit to state.json, bindings.json or
+runner.env occurred.
+
+The temporary source overlay kept production exercise setup, policy
+construction, account leasing, containment, journal, broker, terminal reader,
+launch and shutdown. It restricted execution to catalog discovery and workspace
+routing for Codex Engineering. It skipped outside probes, recovery, the full
+live gate and certificate/bundle writers. The input validator retained its
+ordinary two-binding configuration, but only the authorized Codex binding was
+opened. Every launch used a fresh disposable Git repository and private scratch.
+
+Live-1 temporarily attached the fixed resource's incoming parameters as response
+metadata for diagnosis, without changing its contents or acceptance decision.
+Live-2 removed that instrumentation from both executables. Captures were debugging
+observations only, not certification evidence. Times below are UTC, 2026-11-05.
+
+| Start | End | Tuple | Turns | Result |
+| --- | --- | --- | ---: | --- |
+| 15:22:38 | 15:23:45 | codex-Engineering, live-1 | 2 | All ten workspace rows pass; native question tool absent; resource parameters captured. |
+| 15:25:40 | 15:26:48 | codex-Engineering, live-2 | 2 | All ten workspace rows pass with uninstrumented resource handler; native question tool absent. |
+
+Four model turns were used, within the ten-turn budget. Both launches passed
+observed effective policy, strict MCP and disabled hooks/plugins readback.
+The ten passing rows in each run were `apply_patch`, `exec_command`,
+`list_mcp_resource_templates`, `list_mcp_resources`, `mcp__equipo__ask_person`,
+`mcp__equipo__submit_candidate`, `mcp__equipo__submit_render`, `read_mcp_resource`,
+`view_image` and `write_stdin`. Stdin proof included the waiting process,
+matching session ID, input marker and successful exit.
+
+### Verification
+
+The first targeted command failed before implementation:
+
+```sh
+CGO_ENABLED=0 go test ./internal/directlive ./internal/runner/provider/codex -run 'TestSpecialist(NoGoalOrPluginTools|ObservableToolCatalog)$' -count=1
+```
+
+It caught the accepted native question tool and both missing disabled settings.
+The release inventory test then failed for exactly the eight changed specialist
+hashes before the manifest was updated. Coordinator inventory remained valid.
+
+The restored combined targeted command passed all four packages:
+
+```sh
+CGO_ENABLED=0 go test ./internal/directlive ./internal/runner/provider/codex ./internal/runner/mcpresource ./internal/release -run 'TestSpecialist|TestCodexLiveConfig|TestRouting(ResourceOnly|SetupCompletable)|TestCodexRoutingResourceResults|TestCodexWriteStdinRoutingPrecondition|TestPlanWorkflowReleasePolicyInventory|TestCoordinator' -count=1
+```
+
+Seven temporary mutation overlays each produced a failing assertion, then were
+removed from use. Each ran with
+`CGO_ENABLED=0 go test -overlay <overlay.json> <package> -run '^<test>$' -count=1`:
+
+| Broken behavior | Failing test |
+| --- | --- |
+| Accept native question tool in inventory | TestSpecialistNoGoalOrPluginTools |
+| Enable specialist native question tool | TestSpecialistObservableToolCatalog |
+| Enable default-mode questions | TestSpecialistObservableToolCatalog |
+| Reject captured resource metadata | TestRoutingResourceOnly |
+| Restore coordinator-only readback exception | TestSpecialistQuestionReadback |
+| Accept enabled effective tool config | TestSpecialistQuestionReadback |
+| Skip constructor settings comparison | TestSpecialistCatalogAuthority/question |
+
+The single full `make -k ci` invocation exited 0; no rerun was needed.
+All 29 test packages passed uncached in 5m21.516s. Build, vet, formatting,
+static analysis, vulnerability and secret scans, reference checks, size budgets,
+provider and namespace checks, migration and performance passed. Cold boot was
+117ms against 500ms, and every screen met its 150ms budget.
+
+Local timing warnings remained: provider 20.577s against 15s, Claude 45.969s
+against 45s, and Codex 38.495s against 35s. These are reported locally and
+would fail with CI timing enforcement; no passing remote gate is claimed.
+
+### Delivery
+
+The delivery branch remains `final-gaps`. No README prose or app-owned runtime
+copy changed. No copy-review server was started. No merge, default-branch push,
+deployment, full live gate or certification bundle was performed.
+
+Both live sessions closed normally. Their namespace records and staged homes
+were retired. All task-created harnesses, overlays, captures, binaries and logs
+were removed after recording the results here. 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/codex_inventory.go b/internal/directlive/codex_inventory.go
index 4cfb57c4..e901742e 100644
--- a/internal/directlive/codex_inventory.go
+++ b/internal/directlive/codex_inventory.go
@@ -36,7 +36,7 @@ func codexInventory(session string, frames []json.RawMessage) ([]string, error)
}
for _, name := range got {
// Disabled features must also be absent from the live tool catalog.
- if strings.Contains(name, "goal") || strings.Contains(name, "plugin") || name == "suggest_tools" {
+ if strings.Contains(name, "goal") || strings.Contains(name, "plugin") || name == "suggest_tools" || name == "request_user_input" {
return nil, provider.ErrPolicy
}
}
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..a3b5290d
--- /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{"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..7f6271fa 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,11 @@ 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
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/try_inventory_test.go b/internal/directlive/try_inventory_test.go
index 54908084..78b0e441 100644
--- a/internal/directlive/try_inventory_test.go
+++ b/internal/directlive/try_inventory_test.go
@@ -21,7 +21,7 @@ func TestSpecialistObservedCatalog(t *testing.T) {
}
func TestSpecialistNoGoalOrPluginTools(t *testing.T) {
- for _, tool := range []string{"create_goal", "get_goal", "update_goal", "request_plugin_install", "list_plugins", "suggest_tools"} {
+ for _, tool := range []string{"request_user_input", "create_goal", "get_goal", "update_goal", "request_plugin_install", "list_plugins", "suggest_tools"} {
t.Run(tool, func(t *testing.T) {
raw := json.RawMessage(strings.ReplaceAll(`{"method":"rawResponseItem/completed","params":{"threadId":"session","item":{"type":"additional_tools","role":"developer","tools":[{"type":"namespace","name":"functions","tools":[{"type":"function","name":"TOOL"}]}]}}}`, "TOOL", tool))
if _, err := codexInventory("session", []json.RawMessage{raw}); err == nil {
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/release/manifest.json b/internal/release/manifest.json
index 20bd020d..9b5b2158 100644
--- a/internal/release/manifest.json
+++ b/internal/release/manifest.json
@@ -66,49 +66,49 @@
{
"provider": "codex",
"action": "reproduce",
- "inventory_hash": "54dca9e7dd4586a83bc07ec90d851515dbc1282e4d60cbfb763748082b17b620",
+ "inventory_hash": "901526200f84751107212e20d37ba0fb69b7327c68f22fb848bce0b1e8d8015a",
"status": "uncertified"
},
{
"provider": "codex",
"action": "scope",
- "inventory_hash": "c974736608caf867121637a6a5c8f09f9cdcb411816f7d6f833382768331252c",
+ "inventory_hash": "d4ca8ac8de09708ff436f6e6f9f37c7633f0f142ed8f05dc0323fd125067d7cb",
"status": "uncertified"
},
{
"provider": "codex",
"action": "recommend",
- "inventory_hash": "9fcf66944fb316b3c03d11ca4d22e389eafeb9fa35c9b4b2a5a7d37c3682248f",
+ "inventory_hash": "1b74ea49e9ea967cc5e45259f5083a1e72a075f0c4a36966bf7b547cd35b63b4",
"status": "uncertified"
},
{
"provider": "codex",
"action": "investigate",
- "inventory_hash": "156120ec1e363ca4c3078ea586cb9f3e2b2391304bc9d65cbe064269299b847d",
+ "inventory_hash": "41d48df7ddc595e8bf8d18af7aec7949d061e3f623be652acb641701bbe14c7d",
"status": "uncertified"
},
{
"provider": "codex",
"action": "implement",
- "inventory_hash": "768493e64fbbd8f83ec8a55dd254e67ff2a72dcb1420b4358ebe851949515bae",
+ "inventory_hash": "c17dcf2652a12d934d315a9851ef30c2a44e28c0b335821fd37130d80073ce5d",
"status": "uncertified"
},
{
"provider": "codex",
"action": "copy",
- "inventory_hash": "1bb921376a123ea8045ef598409add46f48a92365c8446cd68509e7cefb41401",
+ "inventory_hash": "07d46054cadebbb157b506214dc68dd28f603c7b7626a24d2f7a68fd9dab58cd",
"status": "uncertified"
},
{
"provider": "codex",
"action": "design",
- "inventory_hash": "a7c1b68fc9eddf355d840a94888d79815faa09b5be33116d4db8baab02b6dd12",
+ "inventory_hash": "f9c15cf275406039ca47da0b22b7d3fdaaabde84d320690a965c0cb53bbf5623",
"status": "uncertified"
},
{
"provider": "codex",
"action": "review",
- "inventory_hash": "3ea818300ad288807e7c9f5f1921e7cd7de12a6ae9e70e0135a3bdf39b1825c5",
+ "inventory_hash": "93d34cac547f6daef7ef6d6d0a4220df25fbb98bf03e15e5e743f694bc2a35a7",
"status": "uncertified"
},
{
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..2abf22c3
--- /dev/null
+++ b/internal/runner/mcpresource/resource.go
@@ -0,0 +1,30 @@
+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"`
+ // Codex 0.165.0 sends a progress token on resource reads.
+ 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..c03f9372
--- /dev/null
+++ b/internal/runner/mcpresource/resource_test.go
@@ -0,0 +1,38 @@
+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"}]}`},
+ // Captured from Codex 0.165.0 during round 2, live-1.
+ {"resources/read", `{"_meta":{"progressToken":6},"uri":"equipo://routing-check"}`, `{"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/provider/codex/catalog_guards_test.go b/internal/runner/provider/codex/catalog_guards_test.go
index 21e195c4..28641c55 100644
--- a/internal/runner/provider/codex/catalog_guards_test.go
+++ b/internal/runner/provider/codex/catalog_guards_test.go
@@ -8,7 +8,7 @@ import (
)
func TestSpecialistCatalogAuthority(t *testing.T) {
- for _, mutation := range []string{"bytes", "code_mode", "collaboration", "template"} {
+ for _, mutation := range []string{"bytes", "code_mode", "collaboration", "template", "question"} {
t.Run(mutation, func(t *testing.T) {
f := fixtureFor(t)
in := f.inputs
@@ -19,7 +19,12 @@ func TestSpecialistCatalogAuthority(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- if mutation != "bytes" {
+ if mutation == "question" {
+ var settings map[string]any
+ _ = json.Unmarshal(in.Settings, &settings)
+ settings["tools"].(map[string]any)["experimental_request_user_input"] = map[string]any{"enabled": true}
+ in.Settings = marshal(settings)
+ } else if mutation != "bytes" {
var catalog struct{ Models []map[string]any }
if json.Unmarshal(in.Catalog, &catalog) != nil {
t.Fatal("catalog")
diff --git a/internal/runner/provider/codex/config_readback.go b/internal/runner/provider/codex/config_readback.go
index 00574c73..c7259628 100644
--- a/internal/runner/provider/codex/config_readback.go
+++ b/internal/runner/provider/codex/config_readback.go
@@ -11,25 +11,29 @@ func effectiveConfigMatches(p provider.Policy, got map[string]json.RawMessage) b
return true
}
var m struct{ ProviderVersion string }
- if !p.Coordinator() || json.Unmarshal(p.Manifest, &m) != nil || m.ProviderVersion != Version {
+ if json.Unmarshal(p.Manifest, &m) != nil || m.ProviderVersion != Version {
return false
}
var want map[string]json.RawMessage
if json.Unmarshal(p.Settings, &want) != nil {
return false
}
- // 0.165.0 keeps these two disabled flags in the session layer but omits
+ // 0.165.0 keeps disabled tool flags in the session layer but omits
// them from typed effective config; this is not proof they are disabled.
- // The live tool inventory check in directlive/coordinator_inventory.go is
- // the real guard. The unmodified command-line layer is checked below.
+ // Live inventories must also prove absence. validateConfig separately
+ // requires an unchanged command-line layer.
var tools, effective map[string]json.RawMessage
- if json.Unmarshal(want["tools"], &tools) != nil || len(tools) != 2 || json.Unmarshal(got["tools"], &effective) != nil {
+ keys := []string{"experimental_request_user_input"}
+ if p.Coordinator() {
+ keys = append(keys, "update_plan")
+ }
+ if json.Unmarshal(want["tools"], &tools) != nil || len(tools) != len(keys) || json.Unmarshal(got["tools"], &effective) != nil {
return false
}
if len(effective) != 1 || !sameJSON(effective["web_search"], []byte(`null`)) {
return false
}
- for _, key := range []string{"update_plan", "experimental_request_user_input"} {
+ for _, key := range keys {
if !sameJSON(tools[key], []byte(`{"enabled":false}`)) {
return false
}
diff --git a/internal/runner/provider/codex/live_config_test.go b/internal/runner/provider/codex/live_config_test.go
index 0e05f9fb..3a9bfcfb 100644
--- a/internal/runner/provider/codex/live_config_test.go
+++ b/internal/runner/provider/codex/live_config_test.go
@@ -62,3 +62,33 @@ func TestCodexLiveConfigStrict(t *testing.T) {
})
}
}
+
+func TestSpecialistQuestionReadback(t *testing.T) {
+ for _, mode := range []string{"valid", "enabled-layer", "missing-layer", "enabled-effective", "default-mode", "other-version"} {
+ t.Run(mode, func(t *testing.T) {
+ v, p := liveConfig(t)
+ layer := v["layers"].([]any)[0].(map[string]any)["config"].(map[string]any)
+ tools := layer["tools"].(map[string]any)
+ delete(tools, "update_plan")
+ p.Settings = marshal(layer)
+ p.Manifest = marshal(map[string]any{"Action": "implement", "ProviderVersion": Version})
+ cfg := v["config"].(map[string]any)
+ switch mode {
+ case "enabled-layer":
+ tools["experimental_request_user_input"] = map[string]any{"enabled": true}
+ case "missing-layer":
+ delete(tools, "experimental_request_user_input")
+ case "enabled-effective":
+ cfg["tools"].(map[string]any)["experimental_request_user_input"] = map[string]any{"enabled": true}
+ case "default-mode":
+ cfg["features"].(map[string]any)["default_mode_request_user_input"] = true
+ case "other-version":
+ p.Manifest = marshal(map[string]any{"Action": "implement", "ProviderVersion": "other"})
+ }
+ p.ManifestHash = provider.DigestDirectEvidence(p.Manifest)
+ if got := validateConfig(marshal(v), p); (got == nil) != (mode == "valid") {
+ t.Fatalf("readback mode %s: %v", mode, got)
+ }
+ })
+ }
+}
diff --git a/internal/runner/provider/codex/probe_failures_test.go b/internal/runner/provider/codex/probe_failures_test.go
index 9495eb70..02c8c3c8 100644
--- a/internal/runner/provider/codex/probe_failures_test.go
+++ b/internal/runner/provider/codex/probe_failures_test.go
@@ -31,8 +31,11 @@ func TestSpecialistObservableToolCatalog(t *testing.T) {
t.Error("wrong specialist catalog", m)
}
}
+ if !sameJSON(marshal(settings["tools"]), []byte(`{"experimental_request_user_input":{"enabled":false}}`)) {
+ t.Error("specialist question tool not disabled")
+ }
features := settings["features"].(map[string]any)
- for _, key := range []string{"code_mode", "code_mode_only", "code_mode_host", "multi_agent_v2", "multi_agent_mode", "multi_agent_v2_dynamic_tools", "image_generation", "imagegenext"} {
+ for _, key := range []string{"code_mode", "code_mode_only", "code_mode_host", "multi_agent_v2", "multi_agent_mode", "multi_agent_v2_dynamic_tools", "image_generation", "imagegenext", "default_mode_request_user_input"} {
if features[key] != false {
t.Errorf("%s not disabled: %v", key, features[key])
}
diff --git a/internal/runner/provider/codex/specialist_catalog.go b/internal/runner/provider/codex/specialist_catalog.go
index 80679679..5f6f1b4f 100644
--- a/internal/runner/provider/codex/specialist_catalog.go
+++ b/internal/runner/provider/codex/specialist_catalog.go
@@ -20,5 +20,7 @@ func specialistCatalog(model string) json.RawMessage {
func configureSpecialistCatalog(settings map[string]any, in *provider.PolicyInputs, model string) {
settings["model_catalog_json"] = provider.CoordinatorCatalogPath
settings["web_search"] = "disabled"
+ settings["features"].(map[string]any)["default_mode_request_user_input"] = false
+ settings["tools"] = map[string]any{"experimental_request_user_input": map[string]any{"enabled": false}}
in.Catalog = specialistCatalog(model)
}
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."