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

# protect

> Bind a function to an action name: every call becomes a decided, recorded Action.

`ctrlrun.protect` — function, defined at `src/ctrlrun/control.py:1967`

```python theme={null}
from ctrlrun import protect
```

```python theme={null}
def protect(name: str, *, effect: str | None = None, resource: str | None = None, wait: bool = False, lease: timedelta | None = None, reconcile: Callable[[str], ReconcileOutcome] | None = None, reconcile_eagerly: bool = False, control: Control | None = None) -> Callable[[Callable[P, R]], Callable[P, R]]
```

Bind a function to an action name: every call becomes a decided, recorded Action.

The wrapped function is the executor (SPEC-v0.1 §5.5), and it is invoked with the
action's canonical arguments, never with the caller's own objects (§2.2).

`effect` and `resource` are templates over the call's arguments (§5.1). Their syntax is
checked here, at decoration time, so a typo fails at import rather than mid-agent-run.

`lease` is how long this action's reservation is held (§5.3 E3), for work that takes
longer than the Control's default; it overrides that default and nothing else. Expiry
means what it always meant: past the lease the effect is `AMBIGUOUS`, never released.

`reconcile` asks the remote what happened to an effect whose outcome is unknown
(SPEC-v0.2 §2). With `reconcile_eagerly`, it also runs immediately after this call
produces an `AMBIGUOUS` outcome, rather than only when one blocks a later attempt.

## Next

* [Python API index](/reference/api/index).
* [Get started](/get-started/quickstart) · [Why](/why).


## Related topics

- [Protect a function](/guides/protect-a-function.md)
- [Protect an existing MCP server in five minutes](/cookbook/protect-an-mcp-server.md)
- [ctrlrun verify](/verify.md)
- [CTRLRun and framework human-in-the-loop](/compare/framework-hitl.md)
- [Reconcile automatically](/guides/reconcile-automatically.md)
