# 17. Grants and approvals

> **Status: partly implemented.** Core permission matching and `#authority`
> bypass-immune member approval policy
> ([`openagents/core/permissions.coax`](../../openagents/core/permissions.coax),
> [`openagents/core/perm_match.coax`](../../openagents/core/perm_match.coax),
> [`openagents/core/members.coax`](../../openagents/core/members.coax), `#14057`),
> Desktop interactive permission cards ([`apps/openagents-desktop/page/permit.coax`](../../apps/openagents-desktop/page/permit.coax)),
> and HTTP protobuf agent grants ([`coax/web/api/agent-policy.coax`](../../coax/web/api/agent-policy.coax),
> [`coax/web/api/agent-wire.coax`](../../coax/web/api/agent-wire.coax)) pass on
> `cpu`. Remaining: unified NIP-CAP/NIP-POL protobuf schemas and mobile/web
> approval sheet parity (`openagents/agent/grants.coax`).

## Premise

The front can now choose a member. This chapter says what that member may do.
A description grants nothing, a grant is its own record, and any effect on the
world waits for your approval.

## Draft

The broader an agent is, the harder it is to say what it may do. This is the
sixth pressure, authority, and a composition answers it by making permission
as specific as its members.

Three things stay separate. A description says what a member can do. A grant
says that this member may do it, here, for you. An approval is your yes to one
action. Describing a member grants nothing. Installing one grants nothing. A
plan that needs a grant you haven't given stops and asks.

Effects are sorted by what they touch. Reading your files, writing to them,
running a command, sending a message in your name and moving money each need
their own grant. Money always needs an approval for the specific payment
(chapter 33).

The person who owns a computer sets its policy. A paired phone can ask that
computer to do something, but it can't widen what the owner allowed. Keys stay
on the device that holds them.

An agent that acts for you has its own key and a grant you approve: scopes,
spend caps in sats and an expiry. An agent can never widen its own grant. That
grant is the first record in this book whose schema is in use (chapter 5).

[Episode 250](../../docs/transcripts/250.md) is the reason for this chapter.
Agents invented commands and reported the wrong model, and the fix was typed
capabilities and controls backed by evidence. The Coder book builds the
sandbox and approval prompt for a coding session. This chapter uses the same
pieces for every member.

## What we build

A plan for what this chapter ships once the draft is approved:

- Grant records, kept apart from member descriptions.
- An approval step that every surface draws the same way: what will happen, to
  what, and what it costs.
- A refusal as a normal result with a reason, for a plan that asks for more
  than it was given.

It builds on what exists today:

- [`openagents/core/permissions.coax`](../../openagents/core/permissions.coax), [`openagents/core/perm_match.coax`](../../openagents/core/perm_match.coax), and [`openagents/core/members.coax`](../../openagents/core/members.coax) (`#authority` bypass-immune grants for `WalletPay`, vault secrets, and Nostr signing, `#14057`)
- [`apps/openagents-desktop/page/permit.coax`](../../apps/openagents-desktop/page/permit.coax) (interactive Desktop approval cards & Full Auto mode, `#14063`)
- [`coax/web/api/agent-policy.coax`](../../coax/web/api/agent-policy.coax) and [`coax/web/api/agent-wire.coax`](../../coax/web/api/agent-wire.coax)
- [`coder/tui/approvals.coax`](../../coder/tui/approvals.coax)
- [`coder/tui/host_grants.coax`](../../openagents/daemon/host_grants.coax)
- [`coax/lib/nostr/cap`](../../coax/lib/nostr/cap)
- [`coax/lib/nostr/nipkeys.coax`](../../coax/lib/nostr/nipkeys.coax)

On the protocol ([chapter 65](ch065-one-schema-three-carriages.md)):

| Record | Schema | Carriage | Today |
| --- | --- | --- | --- |
| A member's grant | `openagents.capability.v1` `Grant` ([spec 19.3](../../docs/protocol/openagents-protocol-spec.md#193-openagentscapabilityv1)) | Nostr: a private record in a kind 3188 envelope (NIP-CAP) | Spec sketch; no `.proto` file. `coax/lib/nostr/cap` handles the NIP's JSON |
| Approval of one action | `openagents.policy.v1` `ApprovalRequest`, `ApprovalDecision` ([spec 19.2](../../docs/protocol/openagents-protocol-spec.md#192-openagentspolicyv1)) | Nostr: a private record in a kind 3188 envelope (NIP-POL) | Spec sketch; no `.proto` file |
| What an agent may do in its owner's name | `openagents.account.v1alpha1` `GrantRequest`, `Grant` ([`agents.proto`](../../proto/openagents/account/v1alpha1/agents.proto)) | HTTP, as binary protobuf | In use: the generated codec `coax/web/api/agent-wire.coax` ([chapter 5](ch005-logging-in-when-a-send-needs-it.md)) |

### The chapter's check

- **Source:** the grant records in `openagents/agent/grants.coax` and the
  shared approval step, with a fake member whose one effect writes a file.
- **Trace:** installing the member leaves `state grants` empty. A plan
  that needs the write opens the approval step, and `tree` shows what will
  happen, to what file and the cost. `tap approval.approve` lets the
  member write the file once, and `logs` records the grant and the
  approval as separate lines.
- **Refusal:** a plan that asks for more than the grant gives returns a
  refusal result with its reason, such as `refused: no grant for
  files.write`, and the file is not written. A paired phone that asks to
  widen the owner's policy gets the same kind of refusal.
- **Independent check:** chapter 5's existing checks on the agent grant
  codec, `coax/web/api/agent-wire.coax`, show an agent can't widen its own
  grant. The approval step's text in `tree` is the same on web and on the
  iPhone simulator.

Planned paths: `openagents/agent/grants.coax`.

## Sources

- **Episodes:**
  - [Episode 250, *Ready the Fleet*](../../docs/transcripts/250.md): typed capabilities after invented commands
  - [Episode 235, *Agents Earn Bitcoin Tips*](../../docs/transcripts/235.md): bounded agent spending
  - [Episode 207, *Your Keys, Your Coins, Your Identity*](../../docs/transcripts/207.md): your keys, your identity
  - [Episode 204, *DO NOT BREAK USERSPACE*](../../docs/transcripts/204.md): platform changes that break workflows
- **Old code at `coder-v1.0.0`, crates:** `capability`, `coder-access`, `coder-boundary`, `oa-seal`, `secret-screen`
- **NIPs:** [NIP-CAP](../../nostr/nips/openagents/NIP-CAP.md), [NIP-KEYS](../../nostr/nips/openagents/NIP-KEYS.md), [NIP-POL](../../nostr/nips/openagents/NIP-POL.md)
- **Also:**
  - [Coder book, chapter 5: A sandbox and approvals](../../coder/book/ch005-a-sandbox-and-approvals.md)
  - *The Return of the General Agent* (`git show coder-v1.0.0:docs/essays/2026-10-01-the-return-of-the-general-agent.md`), pressure F
- **Promises covered** ([audit](../../docs/audits/2026-11-10-episode-289-port-audit.md#1-what-episode-289-promised)): P8, P14

## Open questions for the owner

1. Which grants can a person give once and keep, and which ask every time?
