---
title: "12.9 Recap and reference"
url: https://una-lang.org/en/learn/capabilities/recap-and-reference/
release: v0.4.0
edition: "0.2"
---

# 12.9 Recap and reference

## 12.9.1 For agents

:::agents
`una --json check .` reports the capability diagnostics of this chapter, the U3xxx codes, in the domain `authority`. For [forgetting to hand over a binding](https://una-lang.org/en/learn/capabilities/common-mistakes/#forgetting-to-hand-over-a-binding-u3001):

```json include="mistakes/1/expected/commands/json.txt#L2"
{"schema":"una.diagnostics/1","diagnostics":[{"schema":"una.diagnostic/1","code":"U3001","severity":"error","domain":"authority","message":"`dispatch` needs `@log: Console[print]`, which is not in scope here","primary":{"file":"src/notices.una","start":{"line":106,"col":3},"end":{"line":106,"col":20}},"related":[],"repairs":[{"rank":1,"escape_cost":0,"widens":{"kind":"authority","cost":"the function then holds this authority, and every caller must hold it too: check that the operation belongs to this function's job"},"description":"declare `uses @log: Console[print]` in the header","edit":{"file":"src/notices.una","start":{"line":102,"col":32},"end":{"line":102,"col":32},"replacement":"\n  uses @log: Console[print]"}}],"explain":"una explain U3001"}],"fixable":0}
```

A repair that gives a function more authority carries `widens`, with its kind (`authority`, or `grant` for U3012) and its cost, and ranks after the repairs that keep authority. `una fix` skips the repairs that widen:

```text include="mistakes/1/expected/commands/fix.txt"
$ una fix --dry-run .
skipped src/notices.una:102:32 U3001 declare `uses @log: Console[print]` in the header: widens authority
```

The compact rule: *every effect is `@binding.op(...)` on a binding of the header's `uses`; bindings pass by name or through `with`; a handler implements every operation of its capability and keeps its contract; `main` gets only the granted host capabilities.*
:::

## 12.9.2 Recap

:::recap
- A function's `uses` list everything it may do outside the program; a `pub` function without `uses` is pure.
- List the operations a function needs; a callee holds only those its header lists.
- Bindings pass by name, or through `with` for one statement; a capability is never a value.
- Host capabilities reach `main` only as `[run] grants` and `--grant` allow; grant the least that works.
- Declare each outside service as a `capability`, with a handler for each way to provide it; every handler implements every operation.
- A clause such as `if error use` on an operation's call keeps a function working when a service fails.
- A function argument with effects needs `uses of` and `fails of` (edition `0.2`).
- Edition `0.3` adds conditions on operations ([section 13.1](https://una-lang.org/en/learn/authority/conditions-on-operations-edition-0-3/#s13-1)), ceilings for modules ([section 13.2](https://una-lang.org/en/learn/authority/a-ceiling-for-a-module-boundaries/#s13-2)), narrowed rebindings `with @x = @y[ops]` ([Granting less at the call](https://una-lang.org/en/learn/authority/a-ceiling-for-a-module-boundaries/#granting-less-at-the-call-with-x-yops)) and locked contracts ([section 13.3](https://una-lang.org/en/learn/authority/locking-a-contract-contracts/#s13-3)).
:::

## 12.9.3 Reference

:::reference
- Construct pages: [`capability` and `op`](https://una-lang.org/en/docs/language/capabilities/capability/), [`uses`](https://una-lang.org/en/docs/language/capabilities/uses/), [`with`](https://una-lang.org/en/docs/language/capabilities/with/), [`handler`](https://una-lang.org/en/docs/language/capabilities/handler/), [host capabilities and grants](https://una-lang.org/en/docs/language/capabilities/host/)
- Configuration: [`[run] grants`](https://una-lang.org/en/docs/configure/run/grants/)
- Standard library: [the prelude and the host capabilities](https://una-lang.org/en/docs/std/)
- Diagnostics: [U1001](https://una-lang.org/en/docs/errors/U1001/), [U3001](https://una-lang.org/en/docs/errors/U3001/), [U3002](https://una-lang.org/en/docs/errors/U3002/), [U3004](https://una-lang.org/en/docs/errors/U3004/), [U3005](https://una-lang.org/en/docs/errors/U3005/), [U3010](https://una-lang.org/en/docs/errors/U3010/), [U3011](https://una-lang.org/en/docs/errors/U3011/), [U3012](https://una-lang.org/en/docs/errors/U3012/), [U5001](https://una-lang.org/en/docs/errors/U5001/)
- Specification: [capabilities and effects](https://una-lang.org/en/docs/spec/05-capabilities-and-effects/), [standard library](https://una-lang.org/en/docs/spec/14-standard-library/), [diagnostics and ABI](https://una-lang.org/en/docs/spec/13-diagnostics-and-abi/)
- Editions: [editions](https://una-lang.org/en/docs/editions/)
:::
