Skip to content

refactor(cli): one tool roster for the CLI and MCP server faces (#420, 1/3) - #421

Merged
ajianaz merged 2 commits into
developfrom
refactor/tool-roster
Oct 26, 2026
Merged

ajianaz merged 2 commits into
developfrom
refactor/tool-roster

Conversation

@ajianaz

@ajianaz ajianaz commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

What

Adds tole_cli::tool_roster and moves the CLI faces (run, resume, chat, mission) and the MCP server faces (tole mcp, MCP-over-HTTP) onto it. Part 1 of 3 of #420.

Why

build_registry and build_server_registry were near-copies of the same per-tool rules, and session_host::open_session is a third copy; they had drifted (plan mode applied three ways, two delete_file rules, two binary probes and two GitHub-origin probes). One roster puts each rule in one place. This is the second item of the 2026-10-26 architecture review.

Changes

  • tool_roster.rs (new): build(approver, Roster). Roster carries what differs per face: workspace, shell dir, plan mode, child-agent options, MCP servers, plan emitter. Rules inside: plan mode skips Write-tier registration and ends with retain_read_only (MCP tools are always Write); delete_file only behind an interactive approver (the registry and AllowlistApprover still refuse it on their own); agent tools only for parents outside plan mode; probe-gated uteke / cora / gh / gitea; the cora MCP → cora_search fallback; sibling tracking and the handoff tool for children. binary_available (executable files only) and agent_depth live here.
  • main.rs: build_registry(approver, host, allow) and build_server_registry(workspace, allow, plan_mode) are thin adapters; the four copied cfg-gated call sites collapse to one line each; register_gh, the duplicate binary_available and detect_github_repo are gone (−460 lines).
  • session_host.rs: detect_github_repo takes &Path.
  • The MCP server faces now report a missing uteke / cora binary or GitHub origin on stderr, as the CLI does. Registered tool sets are otherwise unchanged.
  • CHANGELOG entry.

Part 2 moves session_host::open_session (serve, ACP, MCP session tools) onto the roster; part 3 unifies the five todo registrations.

Testing

  • New unit tests in tool_roster: Destructive only behind an interactive approver, plan mode leaves only ReadOnly tools, agent tools only when the face allows children, the binary probe requires an executable.
  • cargo fmt --all, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace (green; one earlier run had two load-related failures in config_sensitive, which passed 4/4 alone and in a full rerun).
  • Bare profiles as in CI: cargo check -p tole-cli --no-default-features, cargo clippy -p tole-cli --no-default-features --features shell-tools -- -D warnings.
  • cora review --staged: deterministic checks clean; the LLM step timed out (504 from the gateway) twice, so the diff was also reviewed with cora 0.19's agent-as-reviewer tools (review_prepare / review_finalize): should_block: false, one minor unwrap inside a unit test.

… 1/3)

Add tole_cli::tool_roster: build(approver, Roster) registers a
session's tools with the per-tool rules in one place (plan mode,
Destructive only behind an interactive approver, child-agent tools,
probe-gated uteke/cora/gh, the cora MCP fallback, sibling tracking).
build_registry (run/resume/chat/mission) and build_server_registry
(tole mcp, MCP-over-HTTP) are thin adapters over it. One binary probe
and one GitHub-origin probe remain.
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

…roster imports (#420)

The pre-roster build_registry registered agent_start/agent_poll in the bare profile too; the roster had put them behind this crate's shell-tools gate (caught by the no-mcp CI job). The binary probe and AllowlistApprover imports are gated to the profiles that use them, so the bare and mcp-only profiles build without warnings.
@ajianaz
ajianaz merged commit bdc0342 into develop Oct 26, 2026
16 checks passed
@ajianaz
ajianaz deleted the refactor/tool-roster branch October 26, 2026 04:55
ajianaz added a commit that referenced this pull request Oct 26, 2026
…ter (#420, 2/3) (#426)

## What

`session_host::open_session` (used by `tole serve`, `tole acp` and the
MCP session tools) now builds its registry with `tool_roster::build`,
the same module the CLI and MCP-server faces use since #421. Part 2 of 3
of #420.

## Why

`open_session` was the third copy of the per-tool registration rules and
had drifted from the CLI: no `verify_package`, a binary probe that
accepted non-executable files, no sibling tracking or handoff tool for
children, and agent-tool registration errors silently ignored.

## Changes

- `session_host.rs`: the ~95-line registration block becomes a `Roster`
(workspace = session cwd for files and shell tools, plan mode, child
agents without worktrees, the ACP plan emitter) passed to
`tool_roster::build`. `tole_cli_binary_available` is removed (the
roster's executable-only probe replaces it). Turn-end hooks, storage and
todo registration are unchanged (todo moves in part 3).
- Server sessions gain `verify_package`; children additionally get
sibling tracking and the handoff tool, as on the CLI. Probe misses
(uteke / cora / GitHub origin) are now reported on stderr.
- `delete_file` still registers only behind an interactive approver
(ACP); plan mode still leaves only ReadOnly tools (`update_plan`,
`systemone_decide`, `web_*` and `job_poll` are ReadOnly, so plan-mode
sessions keep them).
- CHANGELOG.

MCP servers on server faces stay out of scope: those faces refuse
`--mcp-server` today, so attaching MCP there is a separate feature.

## Testing

- New `roster_tests::server_sessions_use_the_shared_roster`
(`open_session` with an allowlist approver): `verify_package` and
`write_file` present, `delete_file` absent; in plan mode only ReadOnly
tools, no `write_file` / `run_command` / `agent_start` / `todo_write`.
- `cargo fmt`, `cargo clippy --workspace --all-targets -- -D warnings`,
bare-profile clippy (none / shell-tools), `cargo test --workspace` (all
green), plus `acp_approval` and `serve_approvals` re-run on the final
code.
- Cora agent-as-reviewer on the exact staged diff (`review_prepare` →
own review → `review_finalize`): 0 findings, `should_block: false`. Two
info `qual-clone` hits from the first pass were fixed (values moved
instead of cloned).

Co-authored-by: ajianaz <[email protected]>
ajianaz added a commit that referenced this pull request Oct 27, 2026
… request count (#429) (#445)

## What

The scripted provider mock in
`crates/tole-cli/tests/config_sensitive.rs` picks its answer from the
conversation instead of from a request counter. Closes #429.

## Why

`on_pretool_from_config_runs_and_can_deny` and
`on_posttool_and_on_turnend_from_config_run` failed intermittently under
machine load (four times on 2026-10-26, once in CI on #421): the `tole
run` child exited 0, but the hook marker was never written. The mock
answered request n with `steps[min(n, last)]`, so a client retry
consumed the next scripted step. The turn then received the final answer
instead of the `write_file` tool call and never ran the tool.

## Changes

- `spawn_mock`: the step is `steps[min(t, last)]`, where t is the number
of `role: tool` messages already in the request's transcript. Every
script in this file is one turn (a final, or a tool call then a final),
so the scripts mean what they meant before; a retried request now gets
the same answer.
- The two hook tests keep the recorded requests and include the request
count and the child's stderr in their failure messages, so a future
failure is diagnosable from the log.
- The now-unused request counter (`AtomicUsize`) is removed.

## Testing

- `cargo test -p tole-cli --test config_sensitive`: 23 passed.
- `cargo fmt --all --check`, `cargo clippy -p tole-cli --tests -- -D
warnings`: clean.
- Cora agent-as-reviewer on the exact staged diff, judged from
`review_finalize`: `should_block: false`, 0 issues.

Co-authored-by: ajianaz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant