Skip to content
quarry Artifact [c9c41c0f22]
Login

Artifact [c9c41c0f22]

Artifact c9c41c0f22d56fa316c17ba95d6e3835c465871b070098728b3963844c684031:


- Feature Name: `the-quarry-client` (one small static program, served
  by the forge, that logs a machine in once, hands the login to zit and
  fossil, does the forge workflow in a few verbs, and prints the next
  command at every refusal)
- Start Date: 2026-11-20
- Status: Accepted, 2026-11-20. Every decision is made (see
  [Decisions](#decisions)); there are no open questions. Not built.
  Built in the order under [Build order](#build-order).
- Depends on: RFC 0030 (the setup start and pickup); RFC 0031 (`next`,
  `waiting`, the client's first five verbs, guides proven by code);
  RFC 0032 (a machine logs in as its person, bots, hard stops)
- Amends: RFC 0031 [decision 6](0031-one-goal-one-consent.md#decisions)
  (the client's verbs: the five stay, and `auth`, `repo` and `doctor`
  are added; `login` and `whoami` become aliases)
- Tracks: danmestas/zit#357 (a generic `credential-command` setting in
  zit); tickets #398 and #434 in part, #460, #461.

Examples use a placeholder person `alex`, a repository `alex/website`,
a machine `mac-mini` and a bot `website-release`. Code is cited as it
stands at trunk `7e6fd70be13f`.

## Summary

Ship one small static program, `quarry`, that a person or a coding
agent installs with one line from the forge itself. It logs a machine
in as its person with one approval (the flow RFC 0032 step 1 shipped),
keeps the token in the OS keychain, hands that token to zit and fossil
so nobody pastes a password, and does the forge workflow in a few
verbs. Every refusal prints the next command. `quarry doctor` names
what is wrong on this machine and prints the fix.

The design in one paragraph: a CLI and nothing else; the pickup login
kept and made resumable; opaque tokens that lapse after 90 days unused,
with no refresh; a client-only build of about 8 MB served from the
forge, verified by checksum and a minisign signature; all wording and
all permission judgments on the server (`next`, `waiting`, `me` and one
new op, `me.check`), so the client holds credentials and runs zit, and
nothing else.

## Goals

1. **One approval, then no auth questions.** After `quarry auth login`
   a person or agent on that machine clones, pushes, opens and lands
   landings, reads CI and calls the API with no further credential
   step.
2. **The tool teaches.** A user who cannot ask an expert gets the next
   command from every refusal, and a full diagnosis from `quarry
   doctor`.
3. **Fossil compatibility is absolute.** No new card, artifact, pragma
   or sync behaviour. A machine token is the password a stock fossil
   client sends under the person's own login (RFC 0032, Migration). The
   client works beside stock `fossil` as it works beside zit.
4. **Small enough to finish.** One problem: be a person's or a bot's
   hands on one forge from a terminal. Shaped like `gh` (`auth login`,
   `auth status`, `repo clone`, `api`), because people and coding
   agents already know it. Standard library plus at most one small
   dependency. `--json`, stable exit codes and `quarry api` so it
   composes. A fixed verb list: a new verb needs a journey that fails
   without it (RFC 0031's rule, kept).
5. **No second source of truth.** What a token may do, what a landing
   waits on and what to do next are composed by the forge and printed
   by the client byte for byte (RFC 0031 principle 8). The client holds
   no permission table and no copy of the hard stops.
6. **Shippable.** A download that is not the 135 MB server, a one-line
   install, verification and an update path, on five platforms.

## Non-goals

- No approving from the terminal. RFC 0032's hard stops stay in a
  browser; the client opens the exact page, waits and reports.
- No OAuth authorization server and no third-party app registrations.
- No MCP server, SDK, TUI or dashboard
  ([Alternatives](#alternatives) says when that could change).
- No forge call, token store or pickup inside zit. zit gains one
  generic hook, [`credential-command`](#zit-and-fossil-credentials).
- No mirror of the API as verbs. `quarry api` reaches every other op.
- No second documentation site. `/llms.txt` shrinks to point at the
  client.

## Where today is wrong

Each row is in the tree today. The build order says which step fixes
it.

| # | What is wrong | Where |
|---|---|---|
| a | `quarry login` exists only inside the 135 MB server binary; nobody without a forge build can run it | `cmd/quarry/main.go:121`, `cmd/quarry/pickup.go` |
| b | One login per host: a second login silently replaces the first, so "as me or as a bot" is impossible on one machine | `internal/pickupclient/login.go:55` |
| c | The keychain exists only on macOS; Linux and Windows always get a plain 0600 file | `login.go:210-222` |
| d | The default label is `HOSTNAME, DIRECTORY`, so a token used from every directory is audited under one directory's name forever | `login.go:336-340` |
| e | The revoke link is printed as `/me#push` and composed by the client; RFC 0032 says `/me#machines` | `login.go:472,491,577` |
| f | The forge's address defaults to a compiled-in constant; another forge's users get the wrong host | `login.go:30` |
| g | A login cannot be resumed: if the person is away for ten minutes the command exits 3 and the agent starts over | `login.go:432-434` |
| h | `next` has two shapes: an object (`Next`, `internal/api/router.go:1096`) and a bare string (`hardstops.go:99`, `pickup.go:312`) | as cited |
| i | The hard-stop table in code has eight rows; RFC 0032's has five, and its invariant 4 says the two are identical | `internal/api/hardstops.go:44-63` |
| j | `/llms.txt` is 465 lines and still opens "An agent is its own account"; it teaches the two-credential setup RFC 0032 retired | `internal/web/web.go:7419` |
| k | The runner download carries the pickup client under the name `quarry-runner`, with a checksum list and no signature | `internal/runnerdist/runnerdist.go`, `scripts/build-linux.sh:272-292` |
| l | There is no exit status for "not logged in", so an agent cannot tell it from any other refusal | `login.go:303` |
| m | A token cannot end itself, so a `logout` could only forget the token locally and leave it live | hard stop 1 |

## Auth

### Logging a machine in

The login is the pickup flow as shipped (`POST /api/v1/setup/start`
kind `login`, `POST /api/v1/pickups/collect`; RFC 0030, RFC 0032 step
1). The client makes 32 random bytes, sends only their SHA-256 with the
start, shows a short typed code and a link, and polls with the key.

It is kept because it is RFC 8628's device grant [S1] in shape, with
one improvement: the collecting secret is made on the device and the
server holds only its hash. It works over SSH, in a container and from
an agent's tool call, where a loopback redirect (RFC 8252 [S4]) needs a
browser on the same machine. Renaming the endpoints to OAuth's would
buy interoperability with clients that do not exist.

Device-code phishing is answered as RFC 8628 section 5.4 asks, and the
four guards already built stay: the code is typed and never carried in
a link, the approval page shows the address the start came from, a
start from another network requires typing the machine's label, and a
new login is announced by email (RFC 0032 decision 14). No
`verification_uri_complete` and no QR code: that convenience is the
phishing aid.

Changes to the flow:

- **`interval`** in the start answer, so the client never guesses the
  poll rate. A 429 keeps `Retry-After`.
- **A closed set of poll states**, documented: `waiting`, `pending`,
  `denied`, `expired`, `lapsed`, `collected`. A known key is never
  answered 404.
- **Resumable.** Before printing the code, the client writes the pickup
  key and the start's expiry to `STATE/pending-<host>.json` (0600).
  `quarry auth login` run again finds it: still valid, it prints the
  same code and keeps waiting; approved meanwhile, it collects at once;
  expired, it starts a fresh code. "Run it again" is always right. An
  approved login stays collectable for 24 hours (`docs/agents.md`), and
  today the client throws the key away at exit.
- **Auto-renew while waiting.** On a terminal, when a code lapses
  unclaimed the client starts and prints the next, for up to `--wait`
  (default 30 minutes), within the start limits.
- **`--no-wait`** for agents: print the link and code, save the pending
  state, exit 3. The agent tells its person and later runs the same
  command, which collects. No tool call blocks for ten minutes.
- **The label is the hostname alone**; `--label` overrides.
- **Everything printed after "Logged in" comes from `GET /api/v1/me`**,
  the revoke address included.

### Where the token is kept

Highest first, the order `gh` uses [S8]:

1. **`QUARRY_TOKEN` in the environment**, for CI and for people who
   keep secrets elsewhere. A forge CI job already receives
   `QUARRY_USER` and `QUARRY_TOKEN` (`docs/agents.md` section 8), so
   `quarry` works inside a forge job with no setup. It is sent to
   exactly one host: `QUARRY_HOST` if set, else the host of the
   checkout's saved remote, else nowhere, with a refusal that says so.
2. **The OS keychain**, one item per host and account: service
   `quarry:HOST`, account `ACCOUNT`. macOS Keychain through `security
   -i` with the value on standard input, as `login.go:179-200` does
   today; Secret Service over D-Bus on Linux; Credential Manager on
   Windows.
3. **A private file** where there is no keychain (a server, a
   container, WSL without a desktop):
   `$XDG_CONFIG_HOME/quarry/<hex host>.json`, 0600 in a 0700
   directory, as `dirStore` does today. `--insecure-storage` forces
   it.

`auth status` says which of the three is in use, every time.

`zalando/go-keyring` [S11] goes behind the existing `Keychain`
interface for Linux and Windows; the hand-written macOS path stays. It
is pure Go, has `MockInit()` for tests, and is what `gh` uses [S12].

A non-secret record per host stays in the config directory: the
accounts known, which is the default, and where each token is kept.
Never the value.

The token is never on a command line, in a URL, in a file in a
checkout, or printed by any verb but `auth token`.

### zit and fossil credentials

Fossil's sync login does not send a password. The client signs each
request with `SHA1(project-code/login/password)` [S14], and the forge
keeps exactly that per token and per repository (`sync_secret`,
`internal/oltp/synctoken.go:30`). The first round of a clone cannot be
signed, so zit and fossil both fall back to HTTP Basic with the token
as the password. After one good sync, zit saves the derived secret in
the checkout (0600, tied to the saved remote) and fossil saves the
password, obscured, in the repository's config table. Fossil has no
credential-helper protocol [S19].

**Priming, which works with zit as it is.** `quarry` runs `zit clone`
or `zit pull --user ACCOUNT` with `ZIT_PASSWORD` set in the child's
environment only; zit saves the derived secret, and bare `zit push`
works from then on. This is what `pickup collect --clone` already does
(`pickupclient.go:373`). It is per checkout.

**`credential-command`, the end state (danmestas/zit#357).** One
generic global setting in zit. When zit needs a login for a URL and has
none saved and no `ZIT_PASSWORD`, it runs the command with git's
credential-helper protocol [S15] on standard input and output and uses
the answer. `quarry auth setup-zit` sets it to `quarry auth
credential`, as `gh auth setup-git` does for git [S16]. Every checkout,
old and new, then authenticates with no step and survives a token
change. The hook names no forge, so RFC 0031's rule that zit carries no
forge call, token store or pickup still holds; it is the same idea as
`$ZIT_QUARRY`.

`quarry auth setup-zit` does whichever the installed zit supports: it
sets `credential-command` once, globally, or else primes the checkout
it is run in. `quarry repo clone` always primes. zit never reads
quarry's token store.

**Stock fossil.** `quarry repo clone --fossil`, and `auth setup-zit` in
a fossil checkout, do the same for fossil. There are two forms, and
step 5's test picks between them:

- *Preferred:* set the remote as `https://ACCOUNT@HOST/r/OWNER/REPO`
  and store the password with `fossil sql` reading standard input,
  using fossil's own `obscure()` SQL function. The token never reaches
  argv. This writes a row fossil owns, so it ships only if stock fossil
  2.28 and 2.29 then authenticate on bare `pull`, `push`, `sync` and
  autosync in `scripts/wire-check.sh`.
- *Fallback:* `fossil clone --save-http-password
  https://ACCOUNT:TOKEN@HOST/...`, the form `docs/agents.md` section 9
  documents today, with the token on a command line for the life of
  that one process.

Because the saved zit secret and the saved fossil password are both
derived from the token, changing the token breaks every checkout's
saved login. [Token lifetime](#token-lifetime) follows from that.

### Accounts and hosts

- **Host.** Everything is keyed by the normalised host (`hostKey`,
  `login.go:70`). A command's host is, in order: `--host`,
  `QUARRY_HOST`, the saved remote of the checkout it runs in (zit's or
  fossil's), the default host, the one host logged in, else a refusal
  naming `quarry auth login https://HOST`. The compiled-in default
  goes; the installer records the forge it was fetched from as the
  default host.
- **Account.** A host holds the person's login and any number of bots'.
  The default is the person. `--as NAME`, or `QUARRY_AS`, picks a bot
  for one command; `quarry auth setup-zit --as NAME` pins a checkout to
  a bot. No flag is you; `--as website-release` is the bot.
- **No `auth switch`.** A global switch is state an agent cannot see,
  and the root of "which account did that run as". A flag and a
  per-checkout pin cover the need with nothing hidden.
- **`auth status`** lists all of it, and says which login a command in
  the current directory would use and why.

### Token lifetime

Tokens stay as they are: opaque, lapsing after 90 days unused
(`TokenIdleLife`, `internal/oltp/token.go:84`). There are no refresh
tokens and no short-lived access tokens. The usual advice points the
other way, so the reasons are recorded here. Anyone proposing to change
this must answer the first.

1. **Fossil makes rotation expensive.** Every saved zit and fossil
   login is derived from the token. An hourly token would break every
   checkout hourly unless a helper ran on every sync, and fossil has no
   helper. While Fossil compatibility is absolute, this alone decides
   it.
2. **Short life buys little here.** The token is opaque and looked up
   on every call, so a revoke ends it at once. Short-lived tokens earn
   their keep where a token is self-contained and cannot be recalled.
3. **Refresh is itself a source of auth failures.** It is a second
   credential to store, rotate and replay-detect [S24]. Two agents
   refreshing at once is the kind of failure this RFC exists to remove.
4. **Reach is bounded by rules, not by time:** the hard stops, the
   green-landing rule, the Machines list and the email on a new login
   (RFC 0032).

What is added instead: `auth status` prints the day the token lapses if
unused; `doctor` warns inside 14 days; a lapsed or revoked token is
answered with a `next` naming `quarry auth login`. Where short life is
right it already exists: a CI run's token ends with the run (RFC 0021),
and a bot's token may be minted with `--days`.

### Bots and CI

- **A forge CI job** has `QUARRY_USER` and `QUARRY_TOKEN` in its
  environment, and `quarry` uses them. Nothing to configure.
- **A bot** (RFC 0032): `quarry auth login --bot website-release --repo
  alex/website --role publisher`, run on the machine that will hold it
  and approved once by an admin of the repository. It is stored beside
  the person's login and used with `--as`.
- **A bot in another system's CI** needs its token in that system's
  secret store. That is the one job of `quarry auth token`, which
  writes to a pipe and never to a terminal.
- **A machine with no login** gets, from any verb, exit status 4 and on
  stderr:

  ```
  quarry: this machine is not logged in to zeitforge.app.
    run    quarry auth login --no-wait
    then   show your person the link and the code it prints; they approve once
    then   run the same command again
  ```

  With `--json`:
  `{"ok":false,"code":"no_login","next":{"say":"...","cmd":"quarry auth login --no-wait"}}`.
  The server's 401 already carries `Link: </llms.txt>; rel="help"`, and
  `/llms.txt` opens with the same lines, so an agent using curl is sent
  to the client.

### Logout

`gh auth logout` removes the local copy and leaves the token live
[S25]. That is wrong for a full-rights token and is not copied.

- `quarry auth logout` ends the token on the forge, then removes the
  keychain item and the record, then lists the checkouts that still
  hold a saved login made with it.
- It needs one new op: a token may end *itself*, the presenting token
  and no other. It is safe for the reason `--repo` is (RFC 0032
  decision 12): it can only take reach away. It is an exception to hard
  stop 1, whose sentence becomes "manage your sign-in and credentials,
  except to end this token". The step that adds the op edits row 1 of
  RFC 0032's table in the same landing, so that RFC's invariant 4 holds.
- Offline, it removes the local copy and says the token is still live
  and where to revoke it. It never reports a revoke it did not see
  succeed.
- Revoking another machine, or all of them, stays in the browser on the
  Machines list (RFC 0032 step 4). There is no `logout --all`.

### Browser-only acts

The list is the server's (`hardStops`), printed by `auth status` from
`me.token.mayNot`. The client holds no copy. When a call meets one, the
server answers 403 `browser_only` with a `next`, and the client:

1. **Opens the exact page.** It prints `next.say` and `next.open`.
   `--open` opens it; never when stdout is not a terminal.
2. **Waits.** With `--wait` it follows the repository's event stream
   (`GET /api/v1/r/{repo}/events/stream`) and retries the refused call
   when a settings or landing event arrives.
3. **Reports** what took effect, from the retried call's own answer.

For this, `next` is one shape everywhere:
`{say, cmd, call, open, ask, help}`. `open` is added to `api.Next`, and
the two string forms are retired.

## Verbs

| Verb | Step |
|---|---|
| `quarry auth login` (alias `quarry login`) | 1, 3 |
| `quarry auth status` (alias `quarry whoami`) | 1 |
| `quarry auth logout` | 2 |
| `quarry doctor` | 4, 10 |
| `quarry auth setup-zit`, `quarry repo clone` | 5 |
| `quarry api` | 7 |
| `quarry status` | 8 |
| `quarry land` | 9 |
| `quarry repo create`, `quarry repo import` | 11 |
| `quarry upgrade`, `quarry version` | 12 |
| `quarry auth token` | 13 |

`login`, `whoami`, `land`, `status` and `api` are RFC 0031's five,
unchanged in meaning. The journey that fails without each addition:
`auth logout`, a person cannot end a machine's token from that machine;
`auth setup-zit` and `repo clone`, nobody knew how to clone; `repo
import`, nobody knew how to bring Git history; `doctor`, there is no
expert to ask; `auth token`, a bot's token cannot otherwise reach
another system's secret store except by a person copying it.

### Conventions

- **`--json`**: exactly one JSON object on stdout and nothing else. It
  always has `ok`; a refusal adds `code`, `error` and `next`. `-F json`
  is accepted as the same thing, for people coming from zit.

  ```json
  {"ok": false, "code": "browser_only",
   "error": "a token does not change branch protection",
   "next": {"say": "Change it signed in at a browser.",
            "open": "https://zeitforge.app/r/alex/website/settings",
            "cmd": "", "call": "", "ask": false,
            "help": "/llms.txt#browser-only"}}
  ```

- **Exit status**: 0 done; 1 refused; 2 usage; 3 still waiting; 4 not
  logged in. 0 to 3 are `pickupclient`'s today; `gh` also uses 4 for
  "needs authentication" [S26].
- **No prompts.** There is nothing to prompt for: approvals are in the
  browser. So there is no `--no-input`, and no hang in an agent's
  shell.
- `NO_COLOR` is honoured, and there is no colour when stdout is not a
  terminal [S27].
- Server strings are printed through `show()` (`login.go:596`), so a
  forge cannot write escape sequences to a terminal.
- `--help` on each verb fits one screen and ends with an example.

### `auth`

```
$ quarry auth login
Open https://zeitforge.app/setup and type   KQ4T-9XWM   (10 minutes)
Waiting for your approval ...
Logged in to zeitforge.app as alex, from mac-mini.
  can      everything you can do on the forge
  cannot   manage your sign-in and credentials; change branch
           protection; override a failing check; delete a repository
           or hand it on; act as a site admin
  token    in the login keychain; ends after 90 days unused
  revoke   https://zeitforge.app/me#machines
Next: quarry repo clone OWNER/NAME
```

Usage: `quarry auth login [URL] [--label NAME] [--repo OWNER/NAME]...
[--bot NAME --role ROLE] [--no-wait] [--wait DURATION]
[--insecure-storage]`.

An agent, with its person away:

```
$ quarry auth login --no-wait --json
{"ok":false,"code":"waiting","link":"https://zeitforge.app/setup",
 "user_code":"KQ4T-9XWM","expires":"2026-11-20T21:40:00Z",
 "next":{"say":"Show your person the link and the code. They approve once. Then run this again.",
         "cmd":"quarry auth login --no-wait"}}
$ echo $?
3

  ... forty minutes later, the code long expired, the person back ...

$ quarry auth login --no-wait
That code expired unused. A new one:
Open https://zeitforge.app/setup and type   R7HC-2MPD   (10 minutes)
$ quarry auth login --no-wait
Logged in to zeitforge.app as alex, from mac-mini.
  ...
```

```
$ quarry auth status
zeitforge.app
  alex              you, via "mac-mini"          default
    token           login keychain; ends 2027-02-18 if unused
    reaches         every repository you do
    cannot          manage your sign-in and credentials; change branch
                    protection; override a failing check; delete a
                    repository or hand it on; act as a site admin
    revoke          https://zeitforge.app/me#machines
  website-release   a bot of alex/website (publisher)     use: --as website-release
    token           login keychain; ends 2027-02-18 if unused
    reaches         alex/website
In this directory: alex/website on zeitforge.app, as alex.
  zit               syncs as alex (saved login works)
```

Usage: `quarry auth status [--host HOST] [--json]`. Exit 0 if the login
this directory would use works, 1 if the forge refuses it, 4 if there
is none. Every line under an account is the server's: `GET /api/v1/me`
gains the token's kind, scopes, lapse day and revoke address beside
`may` and `mayNot`.

```
$ quarry auth logout
Ended the token "mac-mini" on zeitforge.app and removed it from the login keychain.
These checkouts held a saved login made with it, which no longer works:
  ~/src/website        run: quarry auth setup-zit   (after you log in again)
```

Usage: `quarry auth logout [--host HOST] [--as NAME]`.

```
$ quarry auth setup-zit
zit 0.15.0 will now ask quarry for a login whenever a forge needs one.
  set   credential-command = quarry auth credential   (zit settings --global)
Try it: zit pull
```

With a zit that has no such setting, inside a checkout:

```
$ quarry auth setup-zit
~/src/website now syncs with zeitforge.app as alex.
  zit pull, zit push and autosync work here with no password.
  Other checkouts: run this in each, or clone with quarry repo clone.
```

Usage: `quarry auth setup-zit [--as NAME] [--undo]`. In a fossil
checkout it does the same for fossil and says so. `quarry auth
credential` is the helper zit calls; it speaks git's helper protocol
and is not for people.

```
$ quarry auth token
quarry: a token is not printed to a terminal.
  pipe it   quarry auth token --as website-release | gh secret set QUARRY_TOKEN
  or run    quarry api ...        (the token is used, never shown)
```

Usage: `quarry auth token [--as NAME]`. It writes the token and a
newline to stdout only when stdout is not a terminal. Its help steers
to `quarry api` first.

### `repo`

```
$ quarry repo clone alex/website
Cloned alex/website into ./website (412 check-ins) as alex.
  zit pull and zit push work here with no password.
Next: zit commit --branch NAME, then quarry land
```

Usage: `quarry repo clone OWNER/NAME [DIR] [--fossil] [--as NAME]`,
plus whatever follows `--`, passed to `zit clone` (`--horizon`,
`--cone`). A public repository clones anonymously with no login, and
the output says how to log in before pushing.

```
$ quarry repo create notes --private
Created alex/notes (private) on zeitforge.app.
Cloned it into ./notes. It is empty: the first push gives it its history.
Next: add files, zit commit, zit push
```

Usage: `quarry repo create NAME [--private] [--team TEAM] [--no-clone]`.
`POST /api/v1/repos {"name","create":true}`; the name check is the
server's (`GET /api/v1/repos/name`).

```
$ quarry repo import ~/src/oldproject --name oldproject
Importing Git history with zit import-git ... 3,804 commits, 41 tags, 6 branches.
Created alex/oldproject on zeitforge.app and pushed the history to it.
Cloned it into ./oldproject.
  The Git repository at ~/src/oldproject was read and not changed.
Next: cd oldproject; quarry status

$ quarry repo import https://github.com/example/tool
The forge is importing https://github.com/example/tool as alex/tool ...
  1,240 of 9,871 commits
Imported. It follows the Git repository from now on (a mirror: read-only here).
  To make this forge the home of the code: https://zeitforge.app/r/alex/tool/settings
Next: quarry repo clone alex/tool
```

Usage: `quarry repo import PATH|GIT-URL [--name NAME] [--private]
[--no-mirror]`. A local path is `zit import-git` and then the first
push (an empty repository takes the project of its first push,
`docs/agents.md` section 5). A URL is the forge's own import
(`POST /api/v1/repos {"clone":URL,"git":true}`), followed on the event
stream. Breaking out of a mirror changes what the repository is and
stays a browser act; the client prints the page.

### `land`

```
$ quarry land
Pushed parse-fix to alex/website.
Opened !41  parse-fix -> trunk
Armed. It lands itself when build and test are green.
Follow it: quarry status --watch
```

```
$ quarry land --stack --watch
Pushed 3 branches to alex/website.
  !41  parse-fix     -> trunk   opened
  !42  parse-tests   -> !41     opened
  !43  parse-docs    -> !42     opened
Armed. Each rung lands when it and the rungs beneath it are green.
  !41  landed as you via mac-mini (2b9496a3a1)
  !42  landed as you via mac-mini (7e6fd70be1)
  !43  not landing: check "test" failed in step "go test ./..."
       next: quarry status !43 --log
$ echo $?
1
```

Usage: `quarry land [BRANCH|!N] [--to TARGET] [--stack] [--watch]
[-m MESSAGE] [--no-arm]`. It pushes if the forge lacks the tip, opens a
landing if none is open (so a landing opened locally and never pushed
cannot happen, danmestas/zit#356), arms it with `{"on":true}` always
(#463), and prints the server's answer (`armed`, `changed`, `say`).

It refuses to be confused with the local path:

```
$ zit landing accept 41
$ quarry land
quarry: parse-fix was merged into trunk in this checkout by zit landing accept.
  That merge is local: the forge's checks and branch rules were not consulted,
  and trunk here only accepts green landings, so a push of it is refused.
  undo it   zit undo
  then      quarry land
```

### `status`

```
$ quarry status
alex/website on zeitforge.app, as alex (mac-mini)
  !41  parse-fix   -> trunk   armed; check "test" is running, 2m
  !38  typo        -> trunk   landed 14:02 as you via mac-mini
Nothing waits on you.
```

```
$ quarry status !43
!43  parse-docs -> !42   open, not landing
  blocked   conflicts with trunk in internal/web/web.go, docs/api.md
  next      zit merge trunk, resolve, zit commit, quarry land
```

```
$ quarry status !43 --log
!43  parse-docs -> !42   check "test" failed (run 9153, 3m12s)
  step "go test ./..." exited 1; last 20 lines:
    --- FAIL: TestParseDocs (0.02s)
        parse_test.go:88: got 3 sections, want 4
    FAIL    example.org/website/internal/parse  0.412s
  whole log   quarry api GET /r/{repo}/ci/runs/9153/log
  next        fix, zit commit, and it is tested again; nothing to re-arm
```

Usage: `quarry status [!N|BRANCH] [--watch] [--log] [--json]`. Every
sentence is `waiting.say` and `next` from the forge (RFC 0031 stage B).
`--watch` follows the event stream and exits 0 when it lands, 1 when it
stops. `--log` uses each check's `runId` (#460).

### `api`

```
$ quarry api GET /r/{repo}/landing?state=open --json | jq '.landings[].title'
"parse-fix"

$ quarry api POST /r/{repo}/ci/trigger -d '{"landing":"41"}'
{"run":"9160","say":"started test for !41"}

$ quarry api POST /r/{repo}/branch/protection -d @rule.json
quarry: branch.protection.set is for you signed in at a browser: a token does not
change branch protection.
  open   https://zeitforge.app/r/alex/website/settings
  then   quarry api ... --wait    (retries once the setting changes)
$ echo $?
1
```

Usage: `quarry api METHOD PATH [-d JSON|@FILE|-] [--as NAME] [--wait]`.
`{repo}` is filled from the checkout. The path is under `/api/v1`. The
token goes in a header from the store; it is in no argument and no
environment variable of the process. `quarry api GET /` is the op
index, so an agent can discover the rest. There is no built-in `--jq`:
it would be the largest dependency in the program. Pipe to `jq`.

### `doctor`

`doctor` is the server's judgment plus a few local facts. One new
read-only op, `me.check` (`GET /api/v1/me/check?repo=R&branch=B`),
answers a list of findings, each `{id, ok, say, next}`, composed where
the rules live: the token's kind, scopes and reach; the caller's role
on R; whether B is protected, who owns it, whether it carries the
green-landing rule and has required checks; what each open landing of
the caller's waits on; whether the address or account is under a
sign-in hold.

The client adds what only it can see: whether there is a token and
where; whether `QUARRY_TOKEN` shadows a stored login; zit's version;
the checkout's saved remote and whether its saved login works; a
pending or expired login start; the client's version against the
forge's.

```
$ quarry doctor
quarry 0.42.0 (client) on mac-mini; forge zeitforge.app 0.42.0
  ok    logged in as alex, token "mac-mini" in the login keychain
  ok    the token calls the API and pushes (scopes api, sync)
  ok    it reaches alex/website; your role there is admin
  ok    trunk only accepts green landings (build, test); you are an owner
  ok    zit 0.14.14 found; this checkout syncs as alex
  ok    !41 is armed; it waits on check "test", running 2m
Nothing to fix. Next: quarry status --watch
```

On a machine with the failures of the [trail](#the-auth-trail):

```
$ quarry doctor
quarry 0.42.0 (client) on build-box; forge zeitforge.app 0.42.0
  FIX   QUARRY_TOKEN is set in this shell and hides your stored login.
        It is a push credential of the agent website-push: it syncs, and
        cannot call the API.
        next: unset QUARRY_TOKEN        (then quarry doctor)
  FIX   A login was started here 14 minutes ago and its code expired unused.
        next: quarry auth login
  FIX   The stored token is limited to alexx/website, and no repository
        has that address from here; this checkout is alex/website.
        next: quarry auth login --repo alex/website
  FIX   !43 was approved to change auto-land and is not armed: the request
        carried no "on", which disarmed it.
        next: quarry land !43
  FIX   This checkout merged parse-fix into trunk locally (zit landing
        accept). The forge was not asked and will refuse the push.
        next: zit undo; quarry land
  note  This address is held for failed sign-ins until 14:31:10; a correct
        token is refused until then. Do not retry before it.
  note  Three things are yours in a browser, never a token's:
        change branch protection, override a failing check, delete a
        repository or hand it on. quarry prints the page when you meet one.
5 to fix. Start with the first.
$ echo $?
1
```

Usage: `quarry doctor [--json] [--fix]`. `--fix` runs the `next` of
each finding that is local and cannot lose anything (re-prime a
checkout, discard an expired login start). It never logs in, lands or
changes the forge.

### `quarry` with no arguments

```
$ quarry
quarry: work on a quarry forge from a terminal.

  quarry auth login      log this machine in as you (one approval, in a browser)
  quarry repo clone O/N  copy a repository here; zit then syncs with no password
  quarry land            push this branch, open its landing, land it when CI is green

Then:    quarry status   what is my work waiting on?
Stuck:   quarry doctor   what is wrong here, and the command that fixes it
More:    quarry help     every command      quarry help --json   the same, for a program
```

## Teaching built in

1. **Every refusal prints the next command.** Server refusals carry
   `next` (RFC 0031 principle 1). The client prints `next.say`, then
   `next.cmd` if present, else `next.open`, else `next.call` rewritten
   as `quarry api ...`. Once a verb exists the server may fill `cmd`
   with it (RFC 0031 decision 9).
2. **Local refusals are a closed table** in one file,
   `internal/forgeclient/local.go`: no login, no zit on the path, not a
   checkout, no keychain. Each has a stable `code` and a `next`. This
   is the one place the client owns words. RFC 0031 principle 8's build
   check is narrowed to match: the client may hold sentences about the
   *machine*, never about what an account, token or branch permits. A
   test fails if a client string names a capability letter, a role or a
   hard stop.
3. **Help leads with three commands.** `quarry help VERB` fits a screen
   and ends in an example.
4. **`quarry help --json`** lists every verb, its flags and its exit
   codes from the same table that prints the help, so help cannot drift
   from the parser and an agent reads the surface in one call.
5. **`/llms.txt` points at the client** (RFC 0031 decision 8). Its
   first screen becomes:

   ```
   # https://zeitforge.app: a quarry forge

   Install the client, then three commands do the common work:

       curl -fsSL https://zeitforge.app/install.sh | sh
       quarry auth login       # one approval by your person, in a browser
       quarry repo clone OWNER/NAME
       quarry land             # push, open the landing, land on green

   Every refusal prints the next command. If stuck: quarry doctor.
   To land, use quarry land. zit landing accept merges locally and
   does not consult this forge's checks.
   Anything else: quarry api METHOD PATH; the index is quarry api GET /.
   Without the client: /llms.txt#wire (the same steps as HTTP calls).
   ```

   The wire format moves under `#wire`, generated and tested as
   `docs/api.md` is. The lines that teach the retired `push` and `read`
   setups and `Quarry-Ask` leave (RFC 0032 Migration). Every command in
   the file is extracted and run against a test forge (RFC 0031
   principle 9).
6. **The repository page teaches too.** The clone box shows `quarry
   repo clone alex/website` first: one short line with no credential in
   it. The zit and fossil forms stay beneath it.

## Distribution

### The client-only build

Measured: a build holding only `login` and `whoami`
(`internal/pickupclient`), `CGO_ENABLED=0 -trimpath -ldflags "-s -w"`,
is 6.7 MB on darwin/arm64, 7.1 MB on linux/amd64 and 7.3 MB on
windows/amd64. The full client should be near 8 MB. The server build is
135 MB and needs cgo.

`cmd/quarry-runner` already is the small static build with the pickup
client in it. It becomes the client: built once per platform as
`quarry-OS-ARCH`, with `quarry-runner-OS-ARCH` kept as the same bytes
and behaving as the runner when started under that name, the way
`isRunnerCopy()` does in `cmd/quarry/main.go`. The server build keeps
every client verb, so on a forge's own box `quarry` is one program.

The server is kept out by test:

- `TestClientImportsNoServer`: `go list -deps` of the client's main
  package includes none of `internal/web`, `internal/api`,
  `internal/oltp`, `internal/xfer`, nor anything needing cgo.
- The build script fails if any client build exceeds 12 MB.
- `quarry version` prints `quarry 0.42.0 (client)` or `(forge)`.

`zit ui` runs `quarry ui` from the path. The client-only build answers
that with a sentence and where to get the full build, not "unknown
command".

Platforms: linux/amd64, linux/arm64, darwin/arm64, darwin/amd64 and
windows/amd64, which are `runnerdist.Platforms`, already cross-built by
`scripts/build-linux.sh:281-290`. Another is added when someone asks.

### Served from the forge

The client is served by the forge at `/cli/`, beside `/runner/` and by
the same handler (`internal/runnerdist`), with `/install.sh` at the
root. The client then always matches the forge it talks to, and a
self-hosted forge serves its own client with no third party.

A release carries the same files (`scripts/release.sh` already
publishes the runner downloads under `releases/X.Y.Z/` with
`SHA256SUMS`). A forge serves the release-built, release-signed client
unchanged; nothing is signed on the forge's box.

### Install and verification

```
$ curl -fsSL https://zeitforge.app/install.sh | sh
quarry installer for zeitforge.app
  platform    darwin/arm64
  download    https://zeitforge.app/cli/quarry-darwin-arm64  (8.1 MB)
  checksum    sha256 matches SHA256SUMS
  signature   SHA256SUMS is signed by the quarry release key (RWQ...k3)
  installed   ~/.local/bin/quarry   0.42.0 (client)
  default     zeitforge.app
Next: quarry auth login
```

The script is about 80 lines of POSIX sh. It:

- is one `main()` called on its last line, so a cut-off download runs
  nothing [S29][S30];
- uses `curl --proto '=https' --tlsv1.2 --fail`;
- downloads the binary and `SHA256SUMS`, checks the hash with
  `sha256sum` or `shasum -a 256`, and stops on a mismatch;
- runs the downloaded binary's own `quarry upgrade --verify FILE`,
  which checks the signature on `SHA256SUMS` with the public key
  compiled into it, so no `minisign` program is needed on the machine;
- installs to `~/.local/bin` (or `$QUARRY_INSTALL_DIR`), never with
  sudo, changes no shell profile, and says so if the directory is not
  on the path;
- records the forge it came from as the default host;
- prints each thing it does.

**What this proves.** On a first install the script, the binary and the
checksum come from one origin over TLS, so the checksum guards against
corruption and not against a compromised forge. First install trusts
TLS to the forge, as every `curl | sh` does. The signature earns its
place afterwards: an installed client carries the release key, so
`quarry upgrade` refuses a build the key did not sign even if the
forge's web tier is later compromised. Anyone who wants more on day one
can check `SHA256SUMS.minisig` with stock `minisign` against a key
published elsewhere.

**Signing is minisign** [S34]: Ed25519, one small signature file, a
stock verifier, and verification that is `crypto/ed25519` plus a few
dozen lines of parsing. The private key is held off the forge, on the
owner's machine, and used when a release is cut.

**macOS.** A file fetched by `curl` is not quarantined, and Go's linker
ad-hoc signs arm64 binaries, so the install line needs no Apple account
(step 1's test confirms this with `xattr -l` on a clean Mac). A binary
downloaded in a browser is quarantined, and Gatekeeper refuses it
unsigned [S36]. So the settings page shows the install line for macOS,
not a download link. There is no Apple notarisation yet.

**Windows.** `install.ps1` with the same steps comes with step 12.
Until then the page gives the download link and the checksum command it
gives for the runner.

**Not goreleaser.** Its release step assumes GitHub, GitLab or Gitea
hosting [S37], and `scripts/build-linux.sh` and `scripts/release.sh`
already cross-build five targets, write `SHA256SUMS` and publish. It is
revisited if deb or rpm packages are wanted. A Homebrew tap waits until
someone asks for it.

### Updates

- **The version check rides on calls already made.** Every API answer
  gains two headers: `Quarry-Version` (the forge's) and
  `Quarry-Client-Min` (the oldest client it still speaks to). There is
  no separate phone-home.
  - Client older than `Quarry-Client-Min`: the command is refused
    before it does anything, with `next: quarry upgrade`.
  - Client older than the forge: one line on stderr, at most once a
    day, only on a terminal, never with `--json`; off with
    `QUARRY_NO_UPDATE_NOTIFIER`.
  - Client newer than the forge (two forges, one machine): nothing. The
    client works against any forge at or above its own minimum.
- **`quarry upgrade`** downloads this platform's build from the forge
  it is logged in to, verifies checksum and signature, and swaps the
  file by rename (write beside, rename over; on Windows the running
  file is moved aside first) [S40]. It refuses, with the right command,
  when the binary is not the user's to write or sits in a package
  manager's tree. It never runs unasked.

## Alternatives

| | For | Against |
|---|---|---|
| **A. CLI only** | Every coding agent drives a CLI through a shell and learns it from `--help`; no protocol and nothing to keep running; `--json` and exit codes serve programs; one person can finish it [S42] | An agent with no shell cannot use it; each verb is hand-written |
| B. CLI plus a generated UTCP manual [S45] | Nearly free once `GET /api/v1` and `quarry help --json` exist; no server | Young; no mainstream agent reads one natively; one more published surface to keep true |
| C. An MCP server | The one way into agents with no shell; typed tools | Remote MCP authorization is OAuth 2.1 with client registration [S46], the server this RFC declines to build; a local one is a second front end over the same verbs; RFC 0031 already excludes it |
| D. Everything in zit | One program to install | zit is Zig and the forge is Go, so wording and rules would exist twice; a stock fossil user must land without zit; `zit landing accept` mistaken for the forge's accept is the bug this would deepen. RFC 0031 decision 1 settled it |
| E. Browser only | Nothing to install | An agent cannot use it; nothing for clone, push or CI |

**Recommendation, adopted: A.** Two things built here keep B and C
cheap later: the server composes every sentence, and `quarry help
--json` describes the client. B would then be a generated file, and C
could be `quarry mcp` over stdio reusing the token store. Neither is in
the build order.

Within the design, the choices not taken, one line each:

- **A loopback-redirect login** (RFC 8252): needs a browser on the same
  machine, and the people this serves are agents in terminals without
  one.
- **Short-lived tokens with refresh**: see
  [Token lifetime](#token-lifetime).
- **zit reads quarry's token store**: two programs would know one
  format, and RFC 0031 forbids a token store in zit.
- **`99designs/keyring`** [S13]: more backends than are needed, and
  larger.
- **Cosign, GPG or SSH signatures**: online services and an outside
  identity, heavy tooling for one key, or no verifier a user is sure to
  have.
- **Serving the client from the zit release site**: it would tie the
  client's version to zit's, and a forge could not serve its own.

## Build order

Each step is one landing and lands alone. "Sign-off" marks a step that
changes something a person sees: the owner approves the real output on
real data before it lands. "Needs" lists earlier steps here, or steps
of RFC 0031 and RFC 0032, which are cited and not repeated. "Fixes"
names rows of [Where today is wrong](#where-today-is-wrong).

**Stage 1. Something to download**

1. **The client build and its front door.** Sign-off.
   `cmd/quarry-runner` builds as `quarry-OS-ARCH`, with
   `quarry-runner-OS-ARCH` kept as the same bytes; `/cli/{file}` and
   `/install.sh` served by `internal/runnerdist`; `quarry` with no
   arguments prints the three commands; `auth login` and `auth status`
   name the shipped `login` and `whoami`, which stay as aliases; the
   label defaults to the hostname; the revoke address comes from `me`;
   the default host is what the installer recorded. Checksum only; the
   signature is step 12. Test: `TestClientImportsNoServer`; no client
   build over 12 MB; `install.sh` in a clean container ends with
   `quarry version` equal to the forge's, and a corrupted download
   aborts with nothing installed; on a clean Mac the installed file
   carries no quarantine attribute. Tickets: #398 item 1 and #434 A.1,
   in part. Fixes a, d, e, f, k. Needs: none.
2. **Not logged in, and logout.** Exit status 4 and the `no_login`
   refusal with its `next`; the `--json` envelope on `auth login` and
   `auth status`; the op by which a token ends itself, with row 1 of
   RFC 0032's hard-stop table edited to match; `auth logout`. Test: a
   verb with no stored token exits 4 and its JSON carries `next.cmd`;
   after `logout` the token is refused by the forge with a `next` and
   is in neither keychain nor file; a token cannot end another token;
   offline, `logout` reports the token as still live. Fixes l, m.
   Needs: 1.
3. **A login that survives an absent person.** `interval` in the start
   answer; the pending state file; resume; auto-renew; `--no-wait`;
   keychains on Linux and Windows behind `Keychain`. Test: a start left
   for 11 minutes, then `auth login` again, ends logged in with one
   approval; an approval given while no client waited is collected by
   the next run; on Linux with no Secret Service the file store is used
   and `auth status` says so. Fixes c, g. Needs: 1.
4. **`doctor`, first cut.** Sign-off. The local findings, and
   `me.check` with the token findings: kind, scopes, reach, lapse,
   sign-in hold. Test: one fixture each for trail items 1, 2, 4, 5 and
   6, each producing its finding with a `next` that clears it when run;
   the build check that the client holds no capability letter, role
   name or hard-stop sentence. Needs: 2.

**Stage 2. Code without a password**

5. **`repo clone` and `auth setup-zit`, by priming.** Sign-off, for the
   repository page's clone box, which leads with the `quarry` line.
   Test: against a test forge with a private repository, `repo clone`
   then bare `zit pull`, `zit push` and an autosync commit all
   authenticate, and the token is in no process's arguments; the same
   with stock fossil 2.28 and 2.29 (`--fossil`), which decides between
   the two fossil forms; a public repository clones with no login.
   Needs: 2.
6. **One `next`, with `open`.** `api.Next` gains `open`; the string
   forms in `hardstops.go` and `pickup.go` become the object; the
   code's hard-stop table and RFC 0032's are reconciled (RFC 0032 step
   2); the client's refusal printer and `--open`. Test: the registry
   walk of RFC 0031 principle 1 also rejects a `next` that is not an
   object; each hard stop refuses a login token with `next.open` set to
   a page that answers 200 to a signed-in session. Fixes h, i. Needs:
   RFC 0032 step 2.
7. **`api`.** RFC 0031 step 17, plus `{repo}` and `--wait` on a
   `browser_only`. Test: the token never appears in the process list or
   environment; a `browser_only` call with `--wait` succeeds after the
   setting is changed in a browser session in the test. Needs: 6.

**Stage 3. Landing**

8. **`status`.** RFC 0031 step 18. Test: as there, plus `--log` prints
   the failed step for each check by its `runId`. Tickets: with RFC
   0031 step 6, closes #460. Needs: RFC 0031 steps 5, 6 and 7.
9. **`land`, and the local-accept refusal.** RFC 0031 step 19. Test: as
   there; a checkout holding a local `zit landing accept` is refused
   with `zit undo` as its `next`; arming always sends `"on":true` and
   prints the server's `say`. Tickets: with RFC 0032 step 8, closes
   #461. Needs: 8, and RFC 0032 step 8 for a landing to land as the
   person.
10. **`doctor`, complete.** Sign-off. `me.check` gains the repository
    and branch findings (role, protection, owners, the green rule,
    required checks) and the landing findings (armed or not, what it
    waits on). Test: fixtures for trail items 2, 3, 7, 8 and 9; over
    the landing-state matrix of RFC 0031 step 5, `doctor` never prints
    a finding without a `next`. Needs: 9.

**Stage 4. The rest of the surface**

11. **`repo create` and `repo import`.** Test: a local Git repository
    with tags and two branches is imported, pushed and re-cloned, and
    the check-in count matches `zit import-git`'s; a Git URL is
    imported by the forge and `repo clone` of it works; the source
    repository is byte-identical afterwards. Tickets: #398 item 2, and
    #434 in part. Needs: 5.
12. **Signature and `upgrade`.** Sign-off, for the installer's output.
    `SHA256SUMS.minisig` made at release with the key held off the
    forge; the public key compiled in; `quarry upgrade` and `upgrade
    --verify`; `Quarry-Version` and `Quarry-Client-Min` on API answers;
    `install.ps1`. Test: a build whose signature is wrong or missing is
    refused and the installed file is unchanged; a client below the
    minimum is refused with `next: quarry upgrade`; a copy under a
    package manager's prefix refuses to replace itself. Needs: 1.
13. **`--as`, bots, and `auth token`.** Several accounts per host;
    `--bot` on login (RFC 0032 step 9); `auth token`. Test: with a
    person and a bot stored, a command without `--as` is recorded as
    the person and with it as the bot; `auth token` writes nothing to a
    terminal and writes the token to a pipe. Fixes b. Needs: RFC 0032
    step 9.
14. **The guides lead with the client.** Sign-off. `/llms.txt` and
    `docs/agents.md` as under [Teaching built in](#teaching-built-in)
    (RFC 0031 step 22). Test: every command in both is extracted and
    run against a test forge; `/llms.txt` is under 120 lines. Fixes j.
    Needs: 9, 11.
15. **The journeys, in CI.** RFC 0031 step 20 with RFC 0032's changes:
    a cold agent given only the forge's address installs the client,
    logs in with one approval, clones, lands a branch on green, meets a
    hard stop and prints its page. Test: approvals are counted, and the
    count is one. This is #398's own test. Needs: 14.

**In zit's repository** (tracked there, not here)

16. **`credential-command`.** danmestas/zit#357. When it ships, `auth
    setup-zit` sets it; until then priming covers the common path, so
    nothing here waits on it. Needs: none.
17. **RFC 0031 steps 23 to 25**, unchanged: `landing open` pushes or
    says it has not; `landing accept` with a saved remote says it
    merged locally; `zit login`, `land` and `status` pass through to
    `quarry`.

Steps needing sign-off: 1, 4, 5, 10, 12, 14.

### The auth trail

The ten failures of 2026-11-19 and 2026-11-20 that this RFC answers,
and the step that ends each. "Shipped" is work already on trunk.

| # | What happened | Ended by | Step |
|---|---|---|---|
| 1 | A push token at the API: a bare 401, then a lockout | A login token has both scopes, so there is no wrong door (RFC 0032 step 1). A legacy sync-only credential gets `wrong_scope` with `next` (#458), and `doctor` names it and says when a hold lifts | shipped; 4 |
| 2 | Kind `read` could not open or arm; a landing-capable agent took two credentials, a grant and an owner seat across five pages | `quarry auth login`: the machine is the person, who already holds the role and the owner seat. `doctor` on an old agent token says it is an agent's token, with that `next` | shipped; 4, 10 |
| 3 | A tap per arm or accept; "approved" not checkable; three silent disarms | No approvals after login (RFC 0032). `land` always sends `on:true` and prints the server's `armed`, `changed` and `say`; `status` shows what took effect; `doctor` reads the armed state back | 8, 9, 10 |
| 4 | A token minted for `OWNER/NAME` reached nothing | A login has no repository list by default. `--repo` addresses are resolved by the server at approval and shown resolved (RFC 0032 step 5); `auth status` prints reach from the server; `doctor` flags a reach that excludes the current checkout | 4 |
| 5 | A repository-limited token could not read its own sign-off | The client waits on pickup, which needs no token, and after login there are no sign-offs to read. Fixed on the server besides | shipped |
| 6 | Collect answered 404 then 429 before the claim; codes expired while the person was away | The 404 is fixed (#471). Login is resumable, renews its code, and `--no-wait` lets an agent return later; an approval made while nobody waited is collected by the next run | 3 |
| 7 | Agents did not know that `zit landing accept` skips the gates, how to clone, or how to import Git history | `quarry land` is the way to land and refuses a local accept with `zit undo`; `/llms.txt` says so on its first screen; `quarry repo clone`, with the clone box leading with it; `quarry repo import` | 5, 9, 11, 14 |
| 8 | Too many named agents; "as me, or as itself, like gh" | Two identities and one flag: no flag is you, `--as NAME` is a bot. `auth status` lists exactly those. Personal agents retire (RFC 0032 step 10) | 13 |
| 9 | A machine token cannot approve, mint, change protection or override | By design: the refusal is `browser_only` with the exact page; the client prints it, can open it, waits, and reports what changed. `auth status` and `doctor` print the server's "cannot" list before anyone meets it | 6, 7 |
| 10 | No expert to ask | Every refusal carries `next`; `quarry` with no arguments shows three commands; `quarry doctor`; `/llms.txt` in one screen, each command run by a test | 2, 4, 10, 14 |

## Decisions

Settled by the owner on 2026-11-20 ("as recommended on all"):

1. The minisign release key is held off the forge, on the owner's
   machine, and used when a release is cut. Forge deploys serve
   release-signed client builds and sign nothing on the box. No Apple
   notarisation yet; it is revisited when a browser download for macOS
   matters. Reason: a published key is hard to take back, and a key on
   the forge would fall with the forge.
2. `quarry auth token` exists. It writes only to a pipe, never to a
   terminal. Reason: without it a bot's token reaches another system's
   secret store only by a person copying it, which is worse.
3. Tokens lapse after 90 days unused, with no refresh and no
   short-lived access tokens. Reason: Fossil's sync login is derived
   from the token, so rotation breaks every checkout's saved login, and
   a revoke already ends an opaque token at once. The four reasons are
   under [Token lifetime](#token-lifetime); a change to this must
   answer them.
4. zit gains a generic `credential-command` setting (danmestas/zit#357).
   Reason: it names no forge, it is how git solves this, and it is the
   difference between every checkout working and `setup-zit` run in
   each one.

Decided here, reversible:

5. The verbs are grouped as `auth` and `repo`, with `login` and
   `whoami` kept as aliases. This amends RFC 0031 decision 6. Reason:
   it is `gh`'s grammar, which people and coding agents already know,
   and each added verb has a journey that fails without it.
6. `--json` is the flag, and `-F json` is accepted. Reason: `--json` is
   what a newcomer guesses; `-F json` is what a zit user types.
7. The client is served from the forge. Reason: it always matches the
   forge it talks to, and it is the only choice that works for other
   people's forges.
8. No goreleaser. Reason: it would replace thirty lines of shell that
   already cross-build, checksum and publish.
9. No `auth switch`. Reason: a global switch is state an agent cannot
   see; `--as` and a per-checkout pin hide nothing.
10. The host default is recorded by the installer, not compiled in.
    Reason: a client fetched from a forge should talk to that forge.
11. The login stays the pickup flow. Reason: it is the device grant
    with a client-held key, and it works where there is no browser.
12. `logout` ends the token on the forge, through an op by which a
    token ends only itself. Reason: a logout that leaves a full-rights
    token live is not a logout.

## Sources

Fetched 2026-11-20. The numbers are those of the research notes this
RFC was condensed from; a gap is a source that argued for a choice now
decided and is not cited above.

- [S1] RFC 8628, OAuth 2.0 Device Authorization Grant: https://www.rfc-editor.org/rfc/rfc8628.txt
- [S4] RFC 8252, OAuth 2.0 for Native Apps (sections 7.3, 8.3): https://www.rfc-editor.org/rfc/rfc8252.txt
- [S8] `gh help environment` (token precedence, host, the update notifier): https://cli.github.com/manual/gh_help_environment
- [S11] zalando/go-keyring README: https://raw.githubusercontent.com/zalando/go-keyring/master/README.md
- [S12] cli/cli go.mod (go-keyring v0.2.8): https://raw.githubusercontent.com/cli/cli/trunk/go.mod
- [S13] 99designs/keyring: https://github.com/99designs/keyring
- [S14] Fossil, password management and the sync login card: https://fossil-scm.org/home/doc/trunk/www/password.wiki
- [S15] git credential helpers: https://git-scm.com/docs/gitcredentials , https://git-scm.com/docs/git-credential
- [S16] `gh auth setup-git`: https://cli.github.com/manual/gh_auth_setup-git
- [S19] Fossil `clone`, `sync` and `remote` help (URL credentials, `--save-http-password`, `--once`, `remote scrub`): https://fossil-scm.org/home/help?cmd=clone , https://fossil-scm.org/home/help?cmd=sync , https://fossil-scm.org/home/help?cmd=remote ; `obscure()` from `fossil help sql`, fossil 2.29, run locally
- [S24] RFC 9700, OAuth 2.0 Security Best Current Practice: https://www.rfc-editor.org/rfc/rfc9700.txt
- [S25] `gh auth logout` (local only): https://cli.github.com/manual/gh_auth_logout
- [S26] `gh help exit-codes`: https://cli.github.com/manual/gh_help_exit-codes
- [S27] Command Line Interface Guidelines: https://clig.dev/
- [S29] rustup installer: https://sh.rustup.rs
- [S30] Tailscale installer: https://tailscale.com/install.sh
- [S34] minisign: https://github.com/jedisct1/minisign
- [S36] Apple developer forums, ad-hoc signed Go binaries and quarantine: https://developer.apple.com/forums/thread/857202
- [S37] goreleaser release and publishers: https://goreleaser.com/customization/release/ , https://goreleaser.com/customization/publishers/
- [S40] minio/selfupdate (the rename technique, Windows): https://pkg.go.dev/github.com/minio/selfupdate
- [S42] Armin Ronacher, "Tools: Code Is All You Need": https://lucumr.pocoo.org/2025/7/3/tools/
- [S45] UTCP: https://www.utcp.io/
- [S46] MCP authorization, revision 2025-11-25: https://modelcontextprotocol.io/specification/2025-11-25/basic/authorization

In this repository: `docs/rfcs/0030-setup-by-approval.md`,
`docs/rfcs/0031-one-goal-one-consent.md`,
`docs/rfcs/0032-you-bots-and-branch-rules.md`, `docs/agents.md`,
`internal/web/web.go` (`agentGuide`), `internal/pickupclient/login.go`,
`internal/pickupclient/pickupclient.go`, `cmd/quarry/main.go`,
`cmd/quarry/pickup.go`, `cmd/quarry-runner/main.go`,
`internal/runnerdist/runnerdist.go`, `internal/api/hardstops.go`,
`internal/api/router.go`, `internal/api/eventstream.go`,
`internal/oltp/token.go`, `internal/oltp/synctoken.go`,
`scripts/build-linux.sh`, `scripts/release.sh`,
`scripts/wire-check.sh`. Tickets read: #398, #434, #455, #458 to #471.