---
title: "Lesson 6: Approvals"
description: "Ask a person to approve a change before it lands, see why a change waits, and learn which approvals count."
---

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

# Lesson 6: Approvals

**Time:** 20 minutes. **Track:** [developer](https://docs.forge.workreef.dev/learn/#developer). **Before this:** [lesson 1](https://docs.forge.workreef.dev/learn/developer/first-landing/).

By the end of this lesson you will be able to:

- ask for a person's approval before a change lands;
- read what a change waits for;
- say which approvals count, and when your own does.

## Why a change waits

A change lands as soon as it meets its landing requirements: on a forge with runners, its checks pass against exactly the commit that lands, and on every forge the landing scan finds nothing. Sometimes a person should look first. Anyone can ask for that with `af require`: an agent unsure of what it wrote, or an approver who wants to see a change before it lands.

Start a forge and a change:

```console server
$ af-server --dev
...
```

```console check
$ source ~/af-dev/dev/env
$ af workspace add ~/review
Workspace at /home/you/review
Paths: **
main has no landing yet
$ cd ~/review
$ af new -m "Raise the retry limit"
Working on change qzukntwylltpqokkvwtyvolvkonxsvtu at commit 3a34bf0bb49c8af1c0748a1aae86c672e59eeb6cf63b3f897533a878b61c076c
$ printf 'retries = 10\n' > limits.toml
```

## Ask for a person

`af require` takes the change, `@` for your workspace's, and a reason, which is kept with the requirement:

```console check
$ af require @ --reason "the on-call team owns this limit"
change qzukntwylltpqokkvwtyvolvkonxsvtu now waits for that approval
```

`af require` snapshotted your edit first, as every command on `@` does, so there is nothing new to snapshot when you submit. Submit it. It does not land; `af change` says why:

```console check
$ af submit
Submitted commit e4f7792e5a7ddf474d59359e003031234b99edc391aea1671117abb4e0ba9432, 0 edits in its last snapshot
```

```console eventually
$ af change @
state:     Submitted
latest:    e4f7792e5a7ddf474d59359e003031234b99edc391aea1671117abb4e0ba9432
submitted: e4f7792e5a7ddf474d59359e003031234b99edc391aea1671117abb4e0ba9432
may land:  no
waits for: approver
```

It stays submitted, its place kept, while it waits. When the approval comes, the forge tries the landing again on its own.

## Whose approval counts

An approval is a signed statement by one person about one commit, kept for good in the forge's record. Two rules give it meaning:

- **It is about one commit.** If the change moves on, with a new edit or a rebase, it waits again, for an approval of the new commit. What lands is what was approved.
- **Its own line may approve it**: its author, or the person at the root of the agents that wrote it, unless the forge requires another person (`af-server --two-administrators`). Every compliance report lists each approval from a change's own line as an exception, for an auditor to account for.

Try to approve your change yourself:

```console check
$ af approve-change @
Error: PermissionDenied: only a person who holds approver approves a change
[1]
```

Only a person with the approver role approves a change, and the first administrator of a forge does not hold it. Grant it to yourself. As an administrator, the grant takes effect at once, unless the forge requires a second administrator to approve it first:

```console check
$ af grant dev@localhost approver --reason "lesson six"
done: it took effect at once, on your word as an administrator
$ af approve-change @
approved commit e4f7792e5a7ddf474d59359e003031234b99edc391aea1671117abb4e0ba9432 of change qzukntwylltpqokkvwtyvolvkonxsvtu
```

The forge tries the landing again on its own, and the change lands:

```console eventually
$ af status
Change qzukntwylltpqokkvwtyvolvkonxsvtu (landed) at commit e4f7792e5a7ddf474d59359e003031234b99edc391aea1671117abb4e0ba9432
```

Your approval counted: on this forge your own is enough, and the record keeps it as an approval from the change's own line, which the period's compliance report lists as an exception. A forge started with `--two-administrators` requires another person: there your approval is refused, and the change waits for an approver outside its line.

## Changes to the tests wait on their own

A change to anything under `.forge/`, where the tests that gate landing are configured, waits for a person without being asked, so the script that judges changes is never edited without a person's approval. That guards the script, not the verdict: a change's own code runs in its check, so a pass shows it broke nothing the tests catch by mistake, not that it did not cheat on purpose. The approval is a person's, and on a forge that requires another person, someone's outside the change's line:

```console check
$ af new -m "Add a test program"
Working on change sosvztlpyqotptolypuulsxkwkpkutkl at commit 1e83068e0867094ff97bff0a6c61220025303707633b8961a8d6f669970ea90a
$ mkdir -p .forge
$ cat > .forge/test <<'EOF'
> #!/bin/sh
> mkdir -p "$FORGE_OUT/tests"
> printf 'none tap\nend\n' > "$FORGE_OUT/tests/inventory"
> echo 1..0 > "$FORGE_OUT/tests/none.tap"
> EOF
$ af submit
Submitted commit a5009845aeeeea7f606bd981ae2c1f1324e4410206c76169ebf32f08cdaf4b1c, 1 edit in its last snapshot
```

```console eventually
$ af change @
state:     Submitted
latest:    a5009845aeeeea7f606bd981ae2c1f1324e4410206c76169ebf32f08cdaf4b1c
submitted: a5009845aeeeea7f606bd981ae2c1f1324e4410206c76169ebf32f08cdaf4b1c
may land:  no
waits for: approver
```

## Exercises

1. Start a change, ask for approval, and look at it with `af change` before you submit: what state is it in, and what does it wait for?

   ```console check
   $ af abandon
   Abandoned change sosvztlpyqotptolypuulsxkwkpkutkl
   $ af new -m "Lower the timeout"
   Working on change yqskvypwyzyksztpxxxuzqnllrlvqkmk at commit f5fb15ebfbf75990526b62b74281e67bee13427b7890d92bd67ce1cbb7dd597f
   $ printf 'timeout = 10\n' > limits.toml
   $ af require @ --reason "check with the database team"
   change yqskvypwyzyksztpxxxuzqnllrlvqkmk now waits for that approval
   $ af change @
   state:     Open
   latest:    7d3b9e1f5a2c4e6b8d0f2a4c6e8b1d3f5a7c9e02b68d44417640467efbbc4af4
   may land:  no
   waits for: approver
   waits for: scan
   ```

## Check your understanding

<details>
<summary>An approver approved your change, and then you fixed a typo in it. Does it still land?</summary>

Not yet. The approval was of the commit the change was at; the fix made a new commit, so the change waits for an approval of that one. What lands is exactly what was approved.

</details>

<details>
<summary>You hold the approver role. When is your approval of your own change refused?</summary>

On a forge that requires another person, started with `af-server --two-administrators`: there no approval counts from the change's own line, so an approval means someone else looked. On a forge without it, yours counts, and every compliance report lists it as an exception.

</details>

<details>
<summary>Why can an agent you started not approve your change?</summary>

An approval is a person's, made through their own sign-in: no agent approves anything. And where the forge requires another person, an agent you started is in the change's own line too, with the same root as your work, so nobody approves their own work through an agent.

</details>

## Next

[Lesson 7: Take it back](https://docs.forge.workreef.dev/learn/developer/take-it-back/) undoes an operation, restores files, and reverts a landing.

Source: https://docs.forge.workreef.dev/learn/developer/approvals/index.mdx
