# Approvals, rules and cost ceilings

> Publishing and costly generation wait for you. How the approval queue works, how to write a rule, and how to cap what is spent.

Source: https://stuarty.com/docs/guide/approvals/

## You will learn

- what waits in the approval queue, and what you see before you decide;
- how to approve, reject, and write a rule that approves for you;
- how a cost ceiling stops spending, and why an agent can never raise one.

## The idea

An agent, a schedule or you can **prepare** a publication or a request that costs money. It does not run. It becomes an item of the queue, with what will be sent, to which destination, and the estimated cost. You approve or reject it, or a rule you wrote approves it without asking. A job that needs approval is created in the state `waiting_approval`, makes no outbound call and spends nothing until then.

Three rules hold everywhere:

1. **A person decides, an agent never does.** Approving, rejecting, writing a rule and setting a ceiling need a signed-in browser session. The local token of the CLI, an API key and every agent surface are refused with `E_PRIVILEGED_SESSION`. A browser window opened with `stuarty open` is not a person's session either, so there the buttons that need a person (Approve, Reject, save a rule or a ceiling, set a price, keep a note, mark a skill as read) are shown disabled with the reason: do it in the Stuarty desktop app, or sign in with your password when the server runs in network mode.
2. **A ceiling is a hard stop.** A request whose estimate is over a ceiling is refused with a message that says what to do. Approving a request does not lift a ceiling: you raise the ceiling first, on purpose.
3. **Every use of a rule is recorded** in the audit log, with the rule, the request and the time.

## Quick start

1. Open **Approvals** (in the **Publish** group of the sidebar). The page has the queue **Waiting for you** on the left, and on the right the **Cost limit** and the **Rules that approve for you**. The button **Rules** at the top jumps to the rules. A request is also shown in the bell at the top of every page.
2. Each request says what happens, in a sentence such as "Publish this item to your connection", and shows the item, the tool, where it goes, the estimated cost, whether it can be undone, who asked and when. For a publication it shows the post that will be sent, with **Open in Publish**. Choose **Approve**, or **Reject** with an optional reason. Nothing is published or paid before that.
3. The queue is live: new requests appear by themselves, and the page says so when it is not live and you must reload.
4. Or from a terminal, to see what waits (the decision itself is for the browser):

```bash
   stuarty approval:list
   stuarty cost:show
```

   `approval:list` shows the pending requests; `--state all` adds the decided and the expired ones. `cost:show` shows the ceilings and what was spent today and over the last 30 days.

### Rules that approve for you

A rule lets a kind of action through without asking. It can be narrow (one destination, one project) and it can carry a limit per action and per day. On **Approvals**, in **Rules that approve for you**, choose **New rule**, then **Add rule**: pick the kind (for example the publications of one project to one account, or the generations under a small cost), the limits, and save. A rule can be switched off without deleting it. A rule is created only from the browser; an agent that tries gets `E_PRIVILEGED_SESSION`.

### Cost ceilings

A ceiling is the most one action may cost and the most that may be spent in a day, for the whole workspace or for one project. Set it in **Cost limit** on the **Approvals** page, with **Set a ceiling**. A bar shows what was **Spent today** against the ceiling of the day; a day is a UTC day, and leaving both limits empty removes the ceiling of that currency. Before a call to a provider there is an estimate, and after it the real cost is recorded; when either would pass a ceiling the call stops. The numbers are in millionths of the currency, the way providers price them.

## Common mistakes

- Expecting an approval to override a ceiling. It does not. Raise the ceiling, then approve.
- Writing a rule broader than you mean. A rule with no project and no destination covers every project and every destination of that kind; give it a limit.
- Waiting for an agent to approve its own request. It cannot, by design: a prompt injected into a transcript can prepare a post and can never publish it.

## Next steps

- [Your first short video](/docs/guide/first-short-video)
- [The publishing calendar](/docs/guide/publishing-calendar)
- [Approvals from an agent's point of view](/docs/agents/approvals)
- [What leaves your machine](/docs/what-leaves-your-machine)
