> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tai42.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Extensions (tai42_contract.extensions)

> The ExtensionKind taxonomy and extension base surface.

Extension contracts.

`ExtensionKind` is the enum of tool-extension kinds (Wrapper / Transformer /
Backend). Each kind carries its distinguishing rules as explicit properties —
`multiple` (cardinality), `preserves_schema` and `declares_schema` (the
input-schema rule), `preserves_output_shape` (whether a minted branch may
inherit the base tool's output schema), and `relocates_execution` (whether the
kind moves the tool body to another process) — so generic machinery keys off a
property, never off `kind is WRAPPER`. The per-kind extension shape is in
`tai42_contract.extensions.kinds`.

## ExtensionKind

`tai42_contract.extensions.ExtensionKind`

```python theme={null}
class ExtensionKind(StrEnum)
```

The three tool-extension kinds and their per-kind properties.

Every kind branches by rename: an extension mints a NEW-named variant tool
bound alongside the original, and a stacked combo (`[a, b]`) binds one
variant per prefix (`tool`, `tool_a`, `tool_a_b`). No kind replaces a
tool in place.

* `WRAPPER` — presents the wrapped tool's input schema unchanged (minus its
  own declared `reserved_params`); stackable.
* `TRANSFORMER` — presents its OWN composed input schema (a concrete
  makefun-presented signature, never bare `*args/**kwargs`); stackable.
* `BACKEND` — one execution-backend strategy per tool (`multiple=False`);
  no input-schema rule; relocates the tool body's execution to a worker
  process (`relocates_execution`).

**Attributes**

| Attribute     | Type |
| ------------- | ---- |
| `WRAPPER`     | —    |
| `TRANSFORMER` | —    |
| `BACKEND`     | —    |

### Members

#### multiple

`tai42_contract.extensions.ExtensionKind.multiple`

```python theme={null}
multiple: bool
```

Whether a single tool may carry more than one extension of this kind.

#### preserves\_schema

`tai42_contract.extensions.ExtensionKind.preserves_schema`

```python theme={null}
preserves_schema: bool
```

Whether an extension of this kind must present the extended tool's
input schema unchanged (parameter names/types identical; the tool NAME
always changes — every extension branches to a new-named tool).

#### declares\_schema

`tai42_contract.extensions.ExtensionKind.declares_schema`

```python theme={null}
declares_schema: bool
```

Whether an extension of this kind must present its OWN concrete input
schema (a real makefun-presented signature, never bare
`*args/**kwargs`).

#### relocates\_execution

`tai42_contract.extensions.ExtensionKind.relocates_execution`

```python theme={null}
relocates_execution: bool
```

Whether an extension of this kind moves the tool body's execution to
another process. A BACKEND swaps the execution strategy for a worker (the
wrapped callable is submitted and runs there, not in the process that
received the call); a WRAPPER and a TRANSFORMER execute the body
in-process, inside their own frame.

This drives the stacking-order rule the apply site enforces: an
extension that `requires_body_locality` (its wrapper only works in the
process running the tool body, e.g. a proxy layer routing egress through
a task-scoped contextvar) must bind INSIDE any relocating extension, so
its wrapper travels with the body to the worker. Bound outside, the
relocating layer ships only the inner callable and the locality-requiring
wrapper stays behind in the submitting process, silently not applying.

#### preserves\_output\_shape

`tai42_contract.extensions.ExtensionKind.preserves_output_shape`

```python theme={null}
preserves_output_shape: bool
```

Whether an extension of this kind returns the extended tool's result
shape unchanged, so a branch it mints may inherit the base tool's
OUTPUT schema. This is an OUTPUT-schema concern, distinct from
`preserves_schema` (which is about the INPUT schema): a WRAPPER returns
the wrapped tool's result unchanged and a BACKEND swaps the execution
strategy but returns the same output shape (both preserve), while a
TRANSFORMER reshapes the result (does not preserve).
