返回 CodeWhale
TOOL_SURFACE.md
根目录 / docs / TOOL_SURFACE.md
1 # Tool surface
2
3 > 阅读简体中文版:[zh_hans/TOOL_SURFACE.md](zh_hans/TOOL_SURFACE.md)。
4
5 This document describes the current model-facing tool contract. The v0.9.1
6 cutover that produced it is recorded in `docs/RUNTIME_SIMPLIFICATION_DESIGN.md`;
7 read the workspace version from `Cargo.toml`, not from this line. The registry
8 remains larger than the first-turn catalog so
9 saved transcripts can replay and uncommon capabilities can be loaded on demand.
10 The model should learn one canonical name for each common operation.
11
12 Implementation sources:
13
14 - `crates/engine/src/core/engine/tool_catalog.rs` owns the eager/deferred catalog.
15 - `crates/engine/src/tools/registry.rs` registers canonical tools and hidden aliases.
16 - `crates/engine/src/tools/{file,file_tool,shell}.rs` own the small foreground
17 primitive behavior and schemas; the other native tools remain searchable.
18 - `docs/RUNTIME_SIMPLIFICATION_DESIGN.md` records the v0.9.1 cutover and receipt.
19
20 The `speech` tool can synthesize audio on the standard MiniMax route. Set
21 `[features].speech_host = true` to run its option and format preparation in
22 the bundled host. The engine sends the request and writes the audio file.
23
24 ## Default-active contract
25
26 Current `main` starts new turns with twelve eager native names plus one
27 discovery tool: `execute_tools` in code mode (the default, including Plan where
28 every nested call still passes Plan's read-only gates), or synthetic
29 `tool_search` on a surface without an eager `execute_tools` (
30 `code_mode = false`, read-only evidence children, child scopes that leave
31 `execute_tools` out, and workers under an authority envelope). The engine
32 decides this once per turn on the final, narrowed catalog.
33
34 1. `read`
35 2. `write`
36 3. `edit`
37 4. `list_dir`
38 5. `file_search`
39 6. `grep_files`
40 7. `bash`
41 8. `agent`
42 9. `todo_write`
43 10. `create_goal`
44 11. `present`
45 12. `load_skill`
46 13. `execute_tools` (code mode) or `tool_search` (synthetic)
47
48 The twelve native names are `DEFAULT_ACTIVE_NATIVE_TOOLS` in
49 `crates/engine/src/core/engine/tool_catalog.rs`. An authority boundary may
50 remove `agent` at the maximum child depth, and Plan hides shell tools.
51 `get_goal`, `update_goal` and `task_shell_wait`
52 activate on demand once a goal or background shell exists. Route size alone must not
53 change this core vocabulary. `workflow` and `context_archive_search` remain
54 reachable when policy permits (a program calls them, `tools.load` adds
55 `workflow`'s schema, or `tool_search` finds them where it is offered); they are
56 no longer eager names.
57
58 The direct schemas deliberately stay small:
59
60 | Tool | Input | Purpose |
61 |---|---|---|
62 | `read` | `path`, optional `offset`, optional `limit` | Read a bounded file window with explicit continuation or truncation notices. |
63 | `write` | `path`, `content` | Create or replace a file. |
64 | `edit` | `path`, `edits` | Apply one or more unambiguous text replacements against one original snapshot. |
65 | `file_search` | `query`, optional `path`, `limit`, `extensions`, `exclude` | Find files by name, path fragment or glob and return bounded, ranked matches. Respects ignore files; `exclude` replaces default exclusions. |
66 | `bash` | `command`, optional `timeout`, optional `description` | Run one cancellable foreground shell command and return a bounded tail. The optional description is display-only. |
67 | `agent` | delegated task and optional scope/context controls | Start or inspect focused child work. |
68 | `grep_files` | `pattern`, optional search controls | Find matching content in workspace files. |
69 | `todo_write` | complete replacement list of `{content, status}` items | Keep optional, agent-owned progress notes for genuinely multi-step work. |
70 | `create_goal` | objective plus optional budget | Start the session goal the turn works toward. |
71 | `get_goal` | none | Read the active goal and its progress. |
72 | `update_goal` | terminal status | Mark the goal complete or blocked. |
73 | `task_shell_wait` | `task_id`, optional `wait`, `timeout_ms`, `cancel`, `gate` | Poll or stop a background shell task. Completion still arrives as a runtime event, so use it for early output, true barriers, or gate evidence. |
74 | `present` | `files`, optional `note` | Declare 1–32 existing workspace files as final deliverables with a read-only SHA-256 handoff receipt; nothing is copied or moved. |
75 | `load_skill` | optional `name`, `query` | Load a named skill's `SKILL.md` body and companion-file list; omit `name` or use `name="list"` to list eligible skills, or use `query` to search names and descriptions. |
76 | `execute_tools` | `code` | Run a JavaScript program that discovers, loads and calls tools through one gate (code mode). |
77 | `tool_search` | `query`, optional matching controls | Discover policy-allowed deferred tools and add selected schemas to this conversation's toolbox. Offered only where `execute_tools` is not eager. |
78
79 Tools keep their names across modes. Plan omits shell tools such as `bash` from
80 model requests, tool search and `execute_tools` discovery, and refuses shell calls and file mutations.
81 Work routes those calls through approval, sandbox, trusted-path,
82 repository-law, and managed-policy gates. Full Access changes
83 ordinary approval behavior but does not bypass hard safety or repository law.
84
85 `tasks`, `Git`, `Run`, `Web`, `remember`, and other specialized capabilities
86 are searchable rather than first-turn ceremony.
87
88 On the TUI's default (calm) shell card the Bash description is the headline,
89 shown as written apart from stripped terminal escapes, collapsed whitespace and
90 a length bound, and the command sits on its own `$` row directly under it in
91 every state and at every width, including automatic runs. A card without a
92 description leads with the `$` command instead. The labeled card
93 (`show_tool_details = true` with `calm_mode = false`) keeps the command in its
94 header and the description as a muted `note:` row. The description never
95 replaces the command and is excluded from execution, exact approval keys and
96 Auto-Review input. The original description remains in the recorded tool input
97 and exports. Approval prompts, `/jobs`, the activity inspector, ACP and other
98 Runtime clients keep showing the command; this change adds no description row
99 to those surfaces.
100
101 ## Local code execution
102
103 `code_execution` (Python) uses the same
104 permission-aware local launcher as workspace task gates and test runs. Ordinary
105 approval retains the effective session policy. To retry a denied exact call
106 with wider permissions, supply `sandbox_permissions` (`workspace-write` or
107 `danger-full-access`) and a nonempty `justification`; Ask mode requires explicit
108 one-shot user approval. The approved policy affects only that call.
109
110 It reads source from stdin, returns stdout/stderr/return_code, and keeps
111 the existing timeout and process-tree cleanup. It is not a persistent REPL;
112 tracebacks refer to stdin rather than a temporary script path. The persistent
113 Python kernels behind `rlm` start through the same launcher, so they run under
114 the same effective policy.
115
116 Platform/backend limits of the shared launcher still apply: no available local
117 wrapper means workspace-write remains unenforced, while read-only is refused.
118 An external sandbox session cannot use these local interpreter tools and must
119 use its shell execution path. See [sandbox limits](SANDBOX.md).
120
121 ## Deferred and dynamic tools
122
123 `Web` is conditional and deferred. It is discoverable (`tools.search` in a
124 program, or `tool_search`) only when the active policy and runtime backend
125 permit it. Read-only
126 children retain its read-only search/fetch evidence path; read-only authority
127 does not mean "unable to research."
128
129 A search that would go to a third-party search service follows
130 `[search] third_party` (see [Third-party search
131 consent](CONFIGURATION.md#web-search-provider)): with `"ask"` an interactive
132 turn shows the **Third-party web search** card first, and with `"off"` the
133 search returns a short "web search is off" result without contacting the
134 service. That result comes before the call's own approval, so a search that
135 cannot run never asks for one. Fetching a URL is not a search and is not gated
136 by this setting.
137
138 `third_party_search` is a reserved input name. The Engine removes it from every
139 tool call's input, including MCP, extension and nested `execute_tools` calls,
140 before the approval or the tool sees it, so a tool cannot declare an argument
141 with that name.
142
143 The durable `github`, `automation`, and `rlm` action families are also deferred
144 by default. `rlm` owns `open`, `eval`, `configure`, and `close` actions for a
145 persistent local Python session. A ```` ```repl ```` fence in an ordinary reply is
146 text and never runs; only a recursive `rlm` turn executes its fenced code, and
147 only when `code_execution` is on that turn's surface (never in Plan mode) and
148 after `code_execution`'s approval under the session posture. These kernels start
149 through the launcher `code_execution` uses, with the sanitized child
150 environment, so the session's sandbox policy and wrapper apply to them: a
151 read-only policy without an enforcing wrapper refuses to start one, and a
152 session running commands in an external sandbox backend starts no local kernel.
153 The long input reaches the kernel over stdin, never through a file. A kernel is
154 dropped whenever the sandbox policy it started under changes, and an `rlm`
155 context opened under one policy is closed by a call under another. Where the
156 platform has no enforcing wrapper (Linux without bubblewrap, Windows) a
157 workspace-write policy stays unenforced, as for `exec_shell` and
158 `code_execution`. Feature-gated native tools may be added to
159 the active or deferred catalog only when their implementation and host
160 dependencies are available.
161
162 MCP tools are dynamic. Successfully connected servers register names such as
163 `mcp_<server>_<tool>` from `~/.codewhale/mcp.json`; a failed or disabled server
164 must not be presented as available. MCP and plugin tools are normally deferred. When the composition VM is eager and the turn admits exactly one compact named batch schema, `execute_tools` also accepts `{batch:{tool,arguments}}` instead of JavaScript. The VM forwards the data through the same nested gate, bounds and receipts; the server tool stays deferred unless explicitly requested. The current server routes and turn permissions narrow the shortcut’s member names; its nested dispatch checks the offered members after hooks. The server supplies a bounded guide to their arguments. Other tools stay searchable; `[tools].always_load` still makes individual schemas eager.
165
166 For an unstarted configured server, an MCP-focused search (`tools.search` or
167 `tools.list` in a program, or `tool_search`) first performs bounded discovery
168 under the current turn's server/tool ceiling.
169 It searches real server-provided schemas after connection, rather than
170 inventing `mcp_*` definitions. A search inside `execute_tools` describes
171 those schemas without activating them; a direct search uses the existing
172 activation cache. Each conversation targets 16 names and 32 KiB of added tool
173 schemas. Tools used in the current or previous turn stay available. The
174 admission ceiling for pinned tools is twice those targets. Ordinary unrelated
175 searches leave optional servers unstarted. The CLI's standalone MCP inspection
176 commands own a separate pool.
177
178 ### Code mode (`execute_tools`)
179
180 For a known sequence, prefer a tool’s own batch operation. Use `execute_tools` when the next call depends on an intermediate result, and return the verified outcome. Search unknown names and schemas before acting. An unexpected state, refusal, uncertain delivery or direct-only decision ends that sequence.
181
182 `execute_tools` is engine-injected, alongside the synthetic interpreter tools.
183 It runs a JavaScript program whose only host surface is the `tools` object:
184 `await tools.call(name, args)`, `await tools.<namespace>.<op>(args)`, the
185 discovery calls `tools.list`, `tools.search` and `tools.describe`, and
186 `tools.load`. It is the default way to compose several tool calls — MCP and
187 plugin tools included — without round-tripping every intermediate result
188 through the conversation. It is available in Plan mode too (every nested call
189 still takes Plan's read-only gates) and hidden under a worker authority
190 envelope; surfaces without eager `execute_tools` offer `tool_search` instead.
191
192 - **One gate.** In a session turn every nested call is sent back to the turn
193 loop and planned exactly like a direct call: deny/allow lists, preparation
194 (MCP `readOnlyHint`/`destructiveHint`), `tool_call_before` hooks, ask-rules,
195 Auto-Review, repository law, and the Computer Use consent refusal. MCP calls
196 run through the session MCP pool. Approving the program grants nothing, so
197 `execute_tools` itself is auto-approved. If the permission posture changes
198 while a program runs, its remaining nested calls are refused (an approved
199 call survives only an equal or broader posture, as for a direct call) and
200 the model retries them under the new posture.
201 - **Approvals suspend the program.** A nested call that needs approval raises
202 the normal approval card (named `execute_tools program call: ...`) and the
203 program waits; allow resumes it, deny fails only that nested call as an
204 exception the program can catch. Time spent waiting on a decision does not
205 count against the program's run deadline, which is the turn's remaining
206 wall clock.
207 - **Receipts.** The result lists every nested call with its decision (`auto`,
208 `approved`, `denied`, `refused`) and status (`ok`, `failed`, `refused`,
209 `in_flight`). A program that hits its deadline still returns the receipt;
210 `in_flight` calls were cancelled and may have partially run. Each nested
211 result is `{content, metadata, truncated}`; an oversized result keeps that
212 shape, and `truncated` names the original size and the spillover file with
213 the full output.
214 - **Discovery without re-pinning.** Discovery inside a program never activates
215 a tool, so the request's tool array and the session-pinned prefix do not
216 change. `tools.list(namespace?, {limit})` returns an array of names,
217 signatures and summaries, 200 by default and 500 at most; a cut list also
218 carries `total` and `truncated: true`.
219 `tools.search(query, {namespace, limit})` ranks matches.
220 `tools.describe(names)` adds the full description for each name; a name that
221 does not exist comes back as a `missing` entry with `suggestions`. An entry
222 marked `direct_only` exists but cannot be called from a program.
223 - **Explicit loading.** `tools.load(names)` (1 to 8 names) is the one nested
224 call that changes the request: it adds deferred schemas, typically of
225 `direct_only` tools, to the next step through the conversation toolbox
226 cache, under a declared `tool_surface` change. It answers which names
227 loaded, which were already available and which are unavailable (unknown,
228 denied or outside the allow-list) with a reason. Discovery and refused
229 calls never load anything.
230 - **Namespace calls.** `tools.<namespace>.<op>(args)` is resolved once, on the
231 host, to exactly one tool in the current catalog, and then takes the same gate
232 as `tools.call`. A spelling that names no tool, or more than one, is an error
233 and nothing runs.
234 - **Stays direct:** `agent`, `workflow`, `rlm`, `request_user_input`,
235 `show_data`, `present`, `request_plugin_install`, the interpreters, nested
236 `execute_tools`, interactive shells, sandbox escalation, Computer Use
237 consent and scripts, and MCP sign-in (`mcp_<server>_authenticate`). The
238 refusal names `tools.load` for a deferred one.
239
240 Code mode is on by default (`[features] code_mode = true`), which makes
241 `execute_tools` eager from the first request and leaves `tool_search` off the
242 wire; direct tools stay available either way, and a direct `tool_search` call
243 from a resumed session still runs. Set `code_mode = false` (or run with
244 `--disable code_mode`) to defer `execute_tools` and offer `tool_search`
245 instead. The flag is session configuration, so the prompt prefix stays stable
246 within a session.
247
248 Sub-agents get `execute_tools` on the same terms, unless their role is limited
249 to the read-only evidence tools or an explicit tool list leaves it out. A
250 child's nested call is planned by the child's own gate, so its grant and its
251 approval path apply as for its direct calls, and it is admitted at execution
252 against the child's write-scope claim and live peers. A child's program also
253 stops at the child's tool timeout (time waiting on approvals is not counted)
254 or its work deadline, and still returns the receipt. A program in which no
255 nested call ran does not count as progress for the child's permission-denial
256 guard, but the guard does not yet count a refused nested call as a denial
257 either; only the child's step and time budgets end a loop of denied calls
258 retried inside programs. Without an engine turn
259 (a direct unit call), a program keeps the conservative profile: read-only,
260 auto-approved native calls only, no MCP.
261
262 ### Conversation toolbox cache
263
264 A successful search activation is remembered by name for the current
265 conversation. Its soft targets are sixteen deferred names and 32 KiB of added
266 provider-wire schemas, measured after the route's production transformations
267 against the eager-tool baseline. An adapter that cannot measure the wire reports
268 unknown bytes; internal `Tool` serialization is not substituted. To make room it
269 evicts MCP tools before first-party tools, and within each group evicts tools
270 that were never called first (oldest activation first), then the least recently
271 called; a tool called or admitted by a search in the current or previous turn is
272 never evicted, so a later search cannot evict an earlier search's results. When such
273 tools already fill the
274 cache, a search still admits its fresh matches over the soft targets, up to a
275 hard ceiling of twice the targets. Past the ceiling it admits its best match and
276 holds the rest; a later activation restores the targets once those tools go
277 unused. One search's own matches never exceed the soft targets; its overflow is
278 held even when the cache is empty. Every entry is revalidated against the
279 current catalog and policy before it is advertised again. A session sync clears
280 it. The cache cannot resurrect a removed, denied, or newly-eager tool.
281
282 When a search's activation pushes a previously activated tool out of the
283 cache, that search's result lists it under `evicted_tool_references`, so the
284 model is told the tool is no longer callable rather than finding it missing
285 from the next request. A held match is listed under
286 `unavailable_tool_references`. Both carry `tool_search_input`, an exact regex
287 query for that one name that loads it again; a `tools.load` result names
288 `tools.load` instead. Only tools that actually left the
289 active set are listed; a tool that became eager stays callable and is not
290 reported. Each search also returns the current `active_deferred_tools` snapshot
291 and wire-byte measurement in `toolbox`; a new admission explicitly supersedes
292 older eviction or unavailable notices for the same name. Other declared toolbox
293 changes, including revalidation and direct first-use activation, append one
294 current deferred-toolbox snapshot before the next model request. That snapshot
295 supersedes old availability notices without rewriting earlier history.
296
297 Each subagent gets its own policy-filtered deferred catalog, one discovery
298 surface (`execute_tools` when its grant admits it, otherwise `tool_search`
299 unless its tool scope is empty), and bounded activation cache. Forked messages and instructions
300 remain in context, but the child cache starts empty and discovers tools locally;
301 neither forked context nor a cache can become a discovery allowlist. A child can
302 still search every tool its own authority permits, including Web search/fetch
303 for read-only research roles.
304
305 ## Inspect the model-client request tool payload
306
307 Run `/tools` after a model turn to inspect a bounded projection of the exact
308 tool field in the latest prepared model-client request. `/tools json` emits the
309 same evidence as bounded machine-readable JSON. Both formats open in a pager;
310 they are not copied into transcript history. `/tool-studio` remains a human-
311 command compatibility alias; it is not a model tool.
312
313 The snapshot distinguishes an absent tool field from a present empty array. It
314 reports the exact model-client tool JSON byte count and SHA-256 digest only when
315 measurement fits the one-MiB inspection bound; larger payloads stay unavailable.
316 Provider adapters may transform, sanitize, or omit those fields while building
317 a provider-specific wire body, so `/tools` marks provider delivery and the wire
318 payload unavailable. The separate per-request receipt described in [CACHE.md](CACHE.md)
319 measures the production wire schema and joins it with reported provider usage. Capture and rendering are bounded: retained schemas,
320 descriptions, caller lists, catalog rows, turn IDs, and payload measurement all
321 carry explicit truncation, omission, or unavailable receipts. The snapshot stays
322 in memory only for the current session and is replaced on each prepared request.
323
324 Provider, model, approval, registry provenance, and runtime capability metadata
325 are not fields in the request tool schema. `/tools` therefore reports them as
326 unavailable instead of joining against mutable state or inferring values. Use
327 the separate route and permission receipts for those facts.
328
329 ## Modes and permission postures
330
331 Modes and permission postures are separate controls:
332
333 - **Plan** hides shell tools and refuses shell execution and file mutation.
334 - **Work** is ordinary interactive execution.
335 - **Ask**, **Auto-Review**, and **Full Access** control approval behavior within
336 an action-capable mode. They never widen Plan into write or shell access.
337
338 See `docs/MODES.md` for the full mode and posture contract.
339
340 ## Compatibility names
341
342 The model-facing contract is the lowercase core above. The retired `File` and
343 `Bash` hidden action handlers are no longer registered: display, history
344 rendering, reserved-name protection, and saved policy/deny rules still recognize
345 them, while a live `File` call fails as an unknown tool and a live `Bash` call
346 resolves case-insensitively to `bash` (refusing legacy `action`, `persist`,
347 `tty`, or `interact` parameters).
348
349 Protocol clients (MCP server, plugin workspace broker, and extension `core/call`)
350 may still call the hidden single-operation file names `read_file`, `write_file`,
351 and `edit_file` directly. Those names never enter a new model catalog or
352 discovery result. Unknown or retired names fail closed instead of guessing a
353 destination.
354
355 `tts`, `terminal/*`, `agents/*` and the `work_update`, `TodoWrite`, `todo`,
356 `checklist_write` and `checklist_update` spellings of `todo_write` are not
357 registered. Nothing re-executes a saved tool call, so those names keep only
358 their display mappings, their policy alias rows (a saved deny rule on
359 `terminal/*` still matches `terminal_run`) and their place in
360 `RESERVED_TOOL_NAMES`. A live call to one gets the unknown-tool error.
361
362 Specialized native families such as `Git`, `Run`, and `Web` are not aliases for
363 the lowercase core. They remain real, policy-filtered deferred tools, called
364 from a program or loaded on demand (`tools.load`, `tool_search`, or a direct
365 call by name).
366
367 ## Long-running work
368
369 `bash` runs one cancellable foreground command. It does not carry background,
370 TTY, wait, interact, or cancel action fields. Stateful process and terminal
371 control stays out of the shell schema: `task_shell_wait` activates once
372 `bash` starts a background job, while interactive terminal control remains
373 deferred until it is needed; neither enlarges the first-turn shell schema.
374
375 Use `tasks` when the work itself needs a durable lifecycle, structured gates,
376 artifacts, replayable timelines, or a stable task id. Large tool results should
377 remain behind bounded handles or artifacts instead of being copied wholesale
378 into the parent transcript.
379
380 ## Parallel fan-out
381
382 The sub-agent capacity source of truth is
383 `crates/runtime/src/config/subagent_limits.rs`:
384
385 - default configured concurrency: **64**;
386 - maximum configured concurrency: **128**;
387 - maximum admitted running-plus-queued work: **1024**.
388
389 These are capacity ceilings, not advice to dispatch every available slot. A
390 manager should use the smallest useful fan-out, preserve a single owner for
391 fan-in, and verify worker receipts before reporting combined completion.
392
393 RLM child-query batching is a different, cheaper cost class. Its
394 `sub_query_batch` helper accepts 1–16 one-shot children inside a live `rlm`
395 session; it is not a substitute for tool-carrying `agent` workers.
396
397 ## Human inspection: `/tools` (`/tool-studio`)
398
399 `/tools` renders a **read-only, bounded human projection** of the tool field of
400 the request that was prepared for one `(turn, step)`. It is not a second
401 registry and not an execution surface.
402
403 **The seam.** The snapshot is built in `crates/engine/src/core/engine/turn_loop.rs`
404 immediately after `MessageRequest` is constructed, from `request.tools` — the
405 same value the model client is handed. The engine resolves the surrounding
406 per-turn data once in `engine.rs` (`ToolSurfaceContext`: flattened registry
407 facts, the MCP pool's own server attribution, the engine-injected catalog names,
408 and the resolved model client's receipt) and passes it as plain data, so the
409 per-step seam never re-locks the MCP pool or holds a tool object.
410
411 **Turn and step identity.** The tool set can differ between steps of a turn, so
412 each snapshot is stamped with turn id and step and each seam emits its own. The
413 TUI keeps only the latest (`SessionState.last_tool_request_snapshot`). Before
414 the first seam there is no snapshot and `/tools` says so rather than rebuilding
415 a registry in the UI.
416
417 Two kinds of fact are kept apart:
418
419 - **Wire facts** come from the prepared request: name, description, schema,
420 `defer_loading` / `strict` / `allowed_callers` / `cache_control`, byte
421 accounting, and the catalog digest.
422 - **Surface facts** come from the `ToolSurfaceContext`: provenance
423 (`builtin` / `plugin` / `mcp` / `synthetic` / `unknown`), MCP server identity,
424 declared capabilities, declared approval requirement, and model visibility.
425
426 Contract:
427
428 - **One digest.** `active_tool_catalog_sha256`
429 (`crates/engine/src/core/engine/preview.rs`) is the single definition of the
430 active-tool-catalog hash. The request manifest publishes it as
431 `ToolSurfaceFacts::active_tool_catalog_sha256` and `/tools` reports the same
432 value for the same prepared request; neither surface keeps a hash of its own.
433 - **Nothing is guessed.** MCP server identity is shown only when the real pool
434 attributed that exact model tool name. `McpPool::mcp_model_tool_name` is the
435 single definition shared by the model catalog and the human attribution, and
436 an ambiguous name (two servers colliding on one model name) resolves to no
437 server. Synthetic provenance comes from
438 `default_synthetic_catalog_tool_names`, which is asserted against the engine's
439 own `is_synthetic_catalog_tool` predicate. A transmitted tool with no registry
440 entry reports `capabilities: unknown`, never "none".
441 - **Provider availability follows the resolved client.** It comes from
442 `Engine::tool_surface_provider_receipt`, never from "a tool registry exists".
443 With no client the receipt is `unavailable` even when the registry is full.
444 - **Unknown shrinks, it does not vanish.** `unavailable_for_this_request` always
445 contains `provider_wire_payload`: nothing on this path observes what the
446 provider adapter finally transmits. It additionally contains `provider` and
447 `model` without a resolved client, and `provenance` / `capabilities` /
448 `approval` when no surface context was captured.
449 - **Absent stays distinct from empty.** A request with no tools field is not a
450 request with an empty tools array; an unresolved field is `unknown` with a
451 reason, not a default.
452 - **Bounded.** Rendering is capped by tool count (32), name, description, schema
453 bytes, allowed-caller count, and a payload measurement bound, each with an
454 explicit truncation or omission receipt. Registered tools that this request
455 does *not* carry are reported as a bounded name list plus an exact count
456 rather than expanding the projection.
457 - **Inert.** The snapshot lives beside the transcript, never in
458 `session.messages`, so it cannot enter a model request or perturb the
459 provider's prefix cache. It never executes a tool, never reads credentials,
460 never reorders the catalog, and is never registered as a model-callable tool.
461 - **Delivery is never claimed.** The capture happens before connection setup, so
462 `delivery_status` stays `unknown`.
463
464 ## Release verification
465
466 Do not infer the public surface from handler function names. Verify the model
467 catalog and alias visibility at the exact candidate SHA:
468
469 ```bash
470 python3 scripts/measure-runtime-contract.py
471 cargo test -p codewhale-tui --lib --locked core::engine::tests::default_active_contract_keeps_discovery_and_core_tools_eager -- --exact
472 cargo test -p codewhale-tui --lib --locked tools::file_tool::tests::primitive_schemas_are_separate_and_small_contract_shaped -- --exact
473 cargo test -p codewhale-tui --lib --locked tools::shell::tests::lowercase_bash_schema_is_small_contract -- --exact
474 cargo test --locked -p codewhale-tui --lib core::engine::tests::print_mode_tool_catalog_metrics -- --ignored --exact --nocapture
475 ```
476
477 Check the test names against the source before trusting a green run: `cargo test`
478 exits 0 with "0 passed; N filtered out" when a filter matches nothing, so a
479 misspelled filter is indistinguishable from a pass. Each `--exact` command
480 above must report `1 passed` (the ignored metrics test reports `1 passed`
481 only because `--ignored` selects it); `0 passed` means the filter matched
482 nothing and the check did not run.
483
484 The provider-free receipt must report the thirteen default-active names listed
485 above. A separate repository-wide tool count may include deferred, dynamic,
486 feature-gated, and compatibility-only registrations; it is not the number of
487 tools placed in the first-turn model catalog.
488
488 lines MARKDOWN