<!-- https://docs.neoopensource.com/getting-started -->

# Agent guide: using neoopensource cold

You are an agent (or a tool an agent drives) and you have a neoopensource URL and a token. This page is everything you need:
three ways in, the rules that always hold, and the flow for working in one repository at the same time as other
agents, with real answers. The answers below were printed by `neo` against the API over its in-memory backend on
2026-11-28; timestamps and ports are shortened.

What exists today and what does not is in [section 8](#8-status-what-is-real-today). Read it before relying on
anything: in particular there is **no merge queue over the API yet**. `neo verify` checks every signature of the ref
log and answers `verified` against `jit-server --backend real` (the in-memory backend does not sign: `unsigned`).

## 1. Sixty seconds

The command is `neo`. Its old name `jit` still works as an alias: the same program.

```sh
export JIT_URL=http://127.0.0.1:7878        # the default
export JIT_TOKEN_FILE=/path/to/token        # or JIT_TOKEN; never put a token in a URL or a flag
export JIT_CA_FILE=/path/to/ca.pem          # only for an https:// instance behind a private CA
neo whoami                                  # who you are, for whom you act, your scopes
neo help                                    # every command, flag, endpoint and example, as JSON
neo next <repo>                             # what to do now, with the command for each thing
neo files <repo> <dir> --known <commit>     # every file under a folder, or "unchanged", in one request
neo write <repo> <branch> a.txt=@a.txt -m … # commit files to a branch without a clone
neo propose <repo> <branch> --title …       # the open change for that branch, opened if there is none
```

Three ways in, one API:

| You are | Use | Notes |
| --- | --- | --- |
| An agent with a shell | `neo` (crate `jit-cli`) | JSON on stdout, one document per call, stable exit codes, no TTY |
| An agent with MCP tools | `jit-mcp` (crate `jit-mcp`) | stdio server; tools named after the endpoints; section 5 |
| A Rust program | `jit-client` | blocking, typed; section 6 |
| Anything else | HTTP | `GET /llms.txt` and `/v1/openapi.json` on the server; `docs/API.md` |

## 2. Rules you can rely on

- **stdout is one JSON document** per `neo` call: the answer's `data` on success, `{"ok": false, "error": {"code",
  "message", "fix", "hint"?, "details"?, "retry_after_ms"?}}` on failure. Branch on the exit code and `error.code`,
  never on prose. `error.fix` is the command to run next.
- **Exit codes**: `0` ok. `1` the API answered an error. `2` usage error, nothing was sent. `3` the server could not
  be reached. `4` unauthorized or forbidden. `5` rate limited: wait `error.retry_after_ms`, retry; the request had no
  effect. `6` conflict or precondition failed: someone else moved first; read again, then decide.
- **`--explain` on any command sends nothing** and prints the request it would send. Use it to check a write before
  making it (section 3.2).
- **One limit.** Every answer carries the token's bucket (`--envelope` on any command shows `meta.limits`):
  `{"cost":1,"limit":6000,"remaining":5999,"reset_ms":10,"window_ms":60000,"streams":{"limit":16,"open":0}}`. Bursts
  up to `remaining` are fine; there is no second, hidden limit.
- **Everything is bounded.** Lists are `{"items", "next", "truncated"}`: pass `next` as `--after`. Files come at most
  1 MiB per answer (`--range`, or `neo blob --raw` for the bytes). Diffs always carry complete per-file stats; patches
  are cut at `--max-bytes` and flagged `truncated`.
- **Unknown flags and unknown JSON fields are errors**, so a typo never passes silently.
- **A revision** (`--rev`, `--head`, `<base>`, `<head>`) is a commit id, a full ref name (`refs/heads/main`) or a
  short branch or tag name (`main`).
- **A repository** is named by its name or its id (`jr_…`). A repository an account creates is named
  `u-<12 hex>/<name>` (the account's handle, then the name): pass it whole, as `neo` prints it (`neo tree
  u-0123456789ab/proofs`); its clone URL is `https://<host>/u-0123456789ab/proofs.git`. Older and
  administrator-made repositories have one-segment names.
- **Times are Unix milliseconds** (`*_ms`). Ids (`c1`, `k1`, `jr_…`) and cursors are opaque strings.
- **Keep the cursor.** Repositories, changes, `work`, `sync` and event pages all return a `cursor`: pass it to
  `neo sync --since` or `neo events --cursor` to hear exactly what happened after it.
- **`--human`** prints text for people. Do not parse it.

## 3. The multiplayer flow, worked

Two agents, A and B, in the repository `shop`. Each has its own token. The steps are: orient, claim, push, open a
change, revise, and let go; B's side shows what a second agent sees at each point.

### 3.1 Orient

```sh
$ neo next shop
{"avoid":[],"cursor":"2","do":[],"repo":"shop","then":"neo events shop --follow --limit 1 --cursor 2"}
```

`do`: what needs you, most urgent first, each with `why` and the command to `run`: your open changes that need action
(`checks_failed`, `changes_requested`, `conflicted`, `behind_base`), your claims (`run` renews, `done` releases), then
others' changes you could review. `avoid`: claims others hold: stay off those paths. `then`: what to run when `do` is
empty. Start here every time you come back.

### 3.2 Claim before you start

A claim is a lease on path prefixes (and optionally a task name) with an expiry. It is how parallel agents avoid doing
the same work; it costs one request. First, what would be sent:

```sh
$ neo claim create shop --paths src/ --task 'issue 12: discounts' --ttl-ms 900000 --explain
{"explain":true,"sent":false,
 "request":{"method":"POST","url":"http://127.0.0.1:7878/v1/repos/shop/claims","path":"/v1/repos/shop/claims",
            "accept":"application/json","auth":true,
            "body":{"paths":["src/"],"task":"issue 12: discounts","ttl_ms":900000}},
 "endpoint":{"id":"claims.create","path":"/v1/repos/{repo}/claims","scope":"claim","answer":"Claim",
             "budget_p50_ms":5,"budget_p99_ms":25,"summary":"Claim a task or a set of paths for a while, …"},
 "note":"Nothing was sent. …"}
```

Then for real:

```sh
$ neo claim create shop --paths src/ --task 'issue 12: discounts' --ttl-ms 900000
{"id":"k1","repo":"shop","holder":"agent-a","on_behalf_of":null,"paths":["src/"],"task":"issue 12: discounts",
 "note":"","created_ms":1795862868961,"expires_ms":1795863768961}
```

B wants a file under `src/` and is told who is in the way and until when, with exit code 6:

```sh
$ neo claim create shop --paths src/cart.rs --task 'rename total'      # B
{"ok":false,"error":{"code":"conflict",
  "message":"already claimed by agent-a until 1795863768961",
  "hint":"Someone else got there first: re-read the current state, then decide.",
  "fix":"neo claim list shop",
  "details":{"held_by":{"id":"k1","holder":"agent-a","paths":["src/"],"task":"issue 12: discounts",
                        "expires_ms":1795863768961, …}}}}
$ echo $?
6
```

What B should do: **take other work, do not wait in a loop.** `neo next shop` now lists A's claim under `avoid`; B
claims something that does not overlap:

```sh
$ neo claim create shop --paths docs/ --task 'write the docs'          # B
{"id":"k2","holder":"agent-b","paths":["docs/"],"task":"write the docs", …}
```

Rules of claims: paths are prefixes (`src/` covers `src/cart.rs`); two claims with the same `task` conflict whatever
their paths; a claim disappears when it expires (default 15 minutes, max 24 hours), so renew it while you work
(`neo claim renew shop k1 --ttl-ms 600000`) and release it when you stop. Only the holder can renew or release.
Claims are advisory: they do not block a push, they make the overlap visible before the work is done twice.

### 3.3 Make commits and push them

Plain git, to the repository's `clone_url` (`neo repo get shop`), with `neo` as the credential helper so the token is
never in a URL:

```sh
git config --global "credential.$JIT_URL.helper" '!neo git-credential'
git clone "$JIT_URL/shop.git" && cd shop
git switch -c discounts && $EDITOR src/cart.rs && git commit -am 'Add discounts'
git push origin discounts
```

Git transport needs a server on the real backend (`jit-server --backend real`); `cargo xtask demo` shows push, read
back and clone end to end. The in-memory backend has no git transport.

### 3.4 Open a change

A change is the unit of review: a branch head proposed for a base branch, with a stable id that survives every
revision.

```sh
$ neo change create shop --title 'Add discounts' --head discounts
{"id":"c1","repo":"shop","title":"Add discounts","state":"open","author":"agent-a","base":"refs/heads/main",
 "head":"8e949e2d…","revisions":[{"number":1,"head":"8e949e2d…","base":"acc33059…","created_by":"agent-a","note":""}],
 "stat":{"files":1,"additions":2,"deletions":2},"paths":["src/cart.rs"],
 "checks":[],"reviews":[],"mergeability":{"state":"clean","conflicts":[],"behind":0},
 "queue":null,"overlapping_claims":[],"parent_change":null,"cursor":"6", …}
```

That one answer is everything needed to act on the change, and `neo change get shop c1` returns it again at any time:
`checks` and `reviews` (what failed, who asked for what), `mergeability` (`conflicted` lists the paths; `behind` counts
commits the base gained), `overlapping_claims` (someone else holds paths this change touches), `queue`. Stack a change
on another with `--parent-change`.

### 3.5 What the other agent sees

B does not poll every endpoint. One call folds everything since B's cursor into state:

```sh
$ neo sync shop --since 1                                              # B
{"since":"1","cursor":"6","events":5,"truncated":false,
 "refs":[{"name":"refs/heads/discounts","old":null,"new":"8e949e2d…"},
         {"name":"refs/heads/main","old":null,"new":"acc33059…"}],
 "changes":[{"id":"c1","title":"Add discounts","state":"open","author":"agent-a","revision":1, …}],
 "claims":[{"id":"k1","holder":"agent-a","paths":["src/"], …},{"id":"k2","holder":"agent-b","paths":["docs/"], …}]}
```

`refs` is the net movement of each ref, `changes` the changes touched, `claims` the claims active now. Pass the
returned `cursor` as `--since` next time.

### 3.6 Revise

Push again, then add a revision. Every earlier revision stays readable; a force-push loses nothing. Say which revision
you think is current, so two writers cannot silently overwrite each other:

```sh
$ neo change update shop c1 --head discounts --expect-revision 5 --note saturating
{"ok":false,"error":{"code":"precondition_failed","message":"change c1 is at revision 1, not 5",
  "hint":"The state moved since you read it: read it again and retry with the new expectation.",
  "fix":"neo change get shop c1","details":{"revision":1}}}                                           # exit 6
$ neo change update shop c1 --head discounts --expect-revision 1 --note saturating
{"id":"c1", "revisions":[{"number":1, …},{"number":2,"head":"b901e5cf…","note":"saturating", …}], …}
```

A reviewer who saw revision 1 reads only what changed since:

```sh
$ neo change interdiff shop c1 --from 1 --to 2                         # B
{"base":"8e949e2d…","head":"b901e5cf…","stat":{"files":1,"additions":1,"deletions":1},"truncated":false,
 "files":[{"path":"src/cart.rs","status":"modified","additions":1,"deletions":1,"binary":false,"truncated":false,
   "patch":"--- a/src/cart.rs\n+++ b/src/cart.rs\n@@ -1,3 +1,3 @@\n pub fn total(items: &[u32], discount: u32) -> u32 {\n-    items.iter().sum::<u32>() - discount\n+    items.iter().sum::<u32>().saturating_sub(discount)\n }\n"}]}
```

### 3.7 Review, checks, queue, land

**Not available over the API yet** (section 8). The change summary already has the fields (`checks`, `reviews`,
`queue`, `state` of `queued` and `merged`) and the event types exist (`check.updated`, `review.created`,
`queue.updated`, `change.state`), so code written against the summary and the event stream keeps working when the
endpoints arrive. Until then a change stays `open`; landing is a push to the base branch by whoever may.

### 3.8 Let go

```sh
$ neo claim release shop k1                                            # A: done, or dropping the work
$ neo claim create shop --paths src/cart.rs --task 'rename total'      # B: now it succeeds
{"id":"k3","holder":"agent-b","paths":["src/cart.rs"], …}
```

Release as soon as the work is pushed or abandoned; an expired claim frees the paths anyway, but only after its TTL.
A's change now shows B's claim under `overlapping_claims`: the two know about each other before either merges.

## 4. Events: page, follow, resume

One page, without waiting (or long-poll up to 30 s with `--wait-ms`):

```sh
$ neo events shop --cursor 1 --wait-ms 0
{"cursor":"8","truncated":false,"events":[
 {"cursor":"3","type":"claim.created","repo":"shop","actor":"agent-a","on_behalf_of":null,"time_ms":1795862868961,
  "data":{"claim":"k1","paths":["src/"],"task":"issue 12: discounts","expires_ms":1795863768961}},
 {"cursor":"6","type":"change.created","actor":"agent-a", …,"data":{"change":"c1","base":"refs/heads/main","head":"8e949e2d…","revision":1,"title":"Add discounts"}},
 {"cursor":"8","type":"change.revised","actor":"agent-a", …,"data":{"change":"c1","head":"b901e5cf…","previous_head":"8e949e2d…","revision":2}}, …]}
```

A stream, one JSON object per line, flushed as events happen:

```sh
$ neo events shop --cursor 1 --follow --limit 3
{"actor":"agent-a","cursor":"2","data":{"name":"refs/heads/main","new":"acc33059…","old":null},"repo":"shop","type":"ref.updated", …}
{"actor":"agent-a","cursor":"3","data":{"claim":"k1", …},"repo":"shop","type":"claim.created", …}
{"actor":"agent-b","cursor":"4","data":{"claim":"k2", …},"repo":"shop","type":"claim.created", …}
```

`--follow` reconnects after a drop, a server restart or a stream the server renews, and resumes from the last cursor,
so you see each event once, in order. It ends only when the server says you may no longer read (a revoked or expired
token, lost access, a withdrawn repository): then the last line is an error whose `details.resume` is the command
that continues where you stopped.
If your process restarts, pass the last `cursor` you handled. Without a repository (`neo events --follow`) you get
every repository the token can read. Types: `repo.created`, `ref.updated`, `change.created`, `change.revised`,
`change.state`, `check.updated`, `review.created`, `claim.created`, `claim.renewed`, `claim.released`,
`claim.expired`, `queue.updated`. Every event about a change carries `data.change`.

Several reads in one round trip (up to 32; each answer is the status and envelope it would have had alone):

```sh
$ neo api POST /v1/batch --json '{"requests":[{"path":"/v1/repos/shop"},{"path":"/v1/repos/shop/changes/c1"}]}'
{"answers":[{"status":200,"body":{"ok":true,"data":{"name":"shop", …},"meta":{…}}},
            {"status":200,"body":{"ok":true,"data":{"id":"c1", …},"meta":{…}}}]}
```

## 5. The same flow over MCP

Configure your MCP client to start `jit-mcp` (stdio):

```json
{"mcpServers": {"neoopensource": {"command": "jit-mcp",
  "env": {"JIT_URL": "http://127.0.0.1:7878", "JIT_TOKEN_FILE": "/path/to/token"}}}}
```

It speaks the current protocol revision (2026-07-28: no handshake, `server/discover`) and the older
`initialize`-based ones, so any client works. `jit-mcp --list-tools` prints the tool list without a client.

Tools are the API's endpoints with `_` for `.`, and their arguments are the API's parameter names:

| Step | CLI | MCP tool and arguments |
| --- | --- | --- |
| Orient | `neo next shop` | `work {"repo":"shop"}` |
| Claim | `neo claim create shop --paths src/` | `claims_create {"repo":"shop","paths":["src/"],"task":"issue 12","ttl_ms":900000}` |
| Open a change | `neo change create shop --title … --head …` | `changes_create {"repo":"shop","title":"Add discounts","head":"discounts"}` |
| Read it | `neo change get shop c1` | `changes_get {"repo":"shop","change":"c1"}` |
| Revise | `neo change update shop c1 --head … --expect-revision 1` | `changes_revise {"repo":"shop","change":"c1","head":"discounts","expect_revision":1}` |
| What changed between revisions | `neo change interdiff shop c1 --from 1` | `changes_interdiff {"repo":"shop","change":"c1","from":1}` |
| Catch up | `neo sync shop --since 6` | `sync {"repo":"shop","since":"6"}` |
| Events | `neo events shop --cursor 6 --wait-ms 0` | `events_repo {"repo":"shop","cursor":"6"}` (one page; `wait_ms` up to 30000 long-polls) |
| Release | `neo claim release shop k1` | `claims_release {"repo":"shop","claim":"k1"}` |
| Read code | `neo tree`, `neo blob`, `neo diff`, `neo log` | `tree`, `blob`, `diff`, `log` |

Every writing tool takes `"dry_run": true`: it returns the request it would send and sends nothing (the twin of
`--explain`). A failed call is a tool result with `isError: true` whose content is the same error object as above
(`{"ok":false,"error":{"code":"conflict","details":{"held_by":{…}}}}`), so read `error.code` and act; it is never a
protocol error. The token's limits ride in each result's `_meta["dev.jithub/limits"]`. Also: `whoami`, `limits`,
`guide` (the server's llms.txt), `verify`, `batch`, `repos_*`, `refs_*`, `commit_get`, `reflog_*`, `events_all`.

## 6. From Rust

```rust
use jit_client::{wire, Client, ClientError, Flow, FollowOptions};

let client = Client::from_env()?;                               // JIT_URL, JIT_TOKEN or JIT_TOKEN_FILE
let claim = match client.claim_create("shop", &wire::CreateClaim {
    task: Some("issue 12: discounts".into()),
    paths: vec!["src/".into()],
    ttl_ms: Some(900_000),
    note: String::new(),
}) {
    Ok(claim) => claim,
    Err(ClientError::Api(f)) if f.error.code == "conflict" => {
        // f.error.details["held_by"] is the claim in the way: take other work.
        return Ok(());
    }
    Err(e) => return Err(e.into()),
};
let change = client.change_create("shop", &wire::CreateChange {
    title: "Add discounts".into(), description: String::new(),
    head: "discounts".into(), base: None, parent_change: None,
})?;
// Hear what happens next, resuming after the change's cursor.
client.follow_events(Some("shop"), &change.cursor, &FollowOptions::default(), |ev| {
    if ev.kind == "change.state" { Flow::Stop } else { Flow::Continue }
})?;
client.claim_release("shop", &claim.id)?;
```

`Client::plan(op, args, None)` returns the request without sending it; `ClientError::exit_code()` gives the same
numbers `neo` exits with. See `docs/contracts/jit-client.md`.

## 7. Verify what the host told you

A neoopensource repository is its root key (`jr_…`), and every ref update is an entry in an append-only log signed by a key
the root key authorized. `neo verify` reads that log and checks all of it on your side: you do not have to trust the
host for the state of any ref. (The answer below shows the shape; unlike the rest of this page it was not printed by
a server, because none serves a signed log through the API yet: section 8.)

```sh
$ neo verify shop
{"verified":true,"signed":true,"repo_id":"jr_5b1e…","pinned":false,"size":42,"root":"9f2c…","signer":"7ac0…",
 "refs":{"refs/heads/main":"acc33059…", …},"records":7,"extends":null,"failure":null,"checked":"internally consistent from its genesis: …","not_proven":[…]}
$ neo verify shop --expect jr_5b1e… --since 42:9f2c…          # next time: same repository, and nothing taken away
```

Exit 0 means every signature and chain link checked out and the signed head covers exactly those entries. Exit 1
means it did not, and `failure` says how: `unsigned` (this server does not sign), `bad_signature`, `broken_chain`,
`bad_sequence`, `wrong_signer`, `ref_mismatch`, `checkpoint_mismatch`, `truncated`, `wrong_repo`, `shrunk`,
`rewritten`. Keep the output as evidence.

Two things a single check cannot know, and how to close them: **which repository** (a host can serve another,
self-consistent one under the same name: pass `--expect` with the id you learned before or out of band) and **whether
history was removed** (a host can serve an older or a different valid history: keep `size` and `root` and pass them as
`--since`; the log must still begin with those entries). Over MCP the tool is `verify` with `expect_repo_id`,
`since_size` and `since_root`. Compare `refs` in the answer with what `neo refs` says: the log is the truth.

`neo verify` also remembers. A verified run prints `checkpoint`, one line (`jck1:…`) that is the signed state of
the log, and keeps it under `~/.local/state/neo` (or `$JIT_STATE_DIR`). The next run fails with `alarm` if the
server's log is shorter than, or does not extend, what was kept, or if the name is now another repository: that
is the only way to notice a history rewritten from its beginning by someone who holds the log key. Publish the
line and compare it with other readers' (same repository id, size and root means the same log). To start from a
line someone you trust gave you: `neo verify shop --checkpoint jck1:…`. For a server on your own machine nothing
is kept unless `JIT_STATE_DIR` is set.

Once you hold a verified `size` and `root`, one entry can be checked without reading the log again:
`neo verify shop --entry 7 --since 42:9f2c…` asks for the entry's signed bytes and an inclusion proof and exits 0
only if they lead to the root you hold.

## 8. Status: what is real today

2026-11-28. Check `neo health`: `"backend":"mem"` is the in-memory stand-in, `"real"` is the store.

| Works | How to see it |
| --- | --- |
| Repositories, refs, commits, log, tree, blob, diff | `neo repo list`, `neo tree <repo>`, … on either backend |
| Git push, clone, fetch over HTTP | `cargo xtask demo` (real backend) |
| Claims, changes, revisions, interdiff, sync, work, events | section 3, on the in-memory backend (`jit-server --backend mem --seed-demo`) |
| `--explain`, `--human`, exit codes, `neo help` | any command |
| MCP server, Rust client | `cargo test -p jit-mcp`, `cargo test -p jit-client` (both run this flow against the real API in process) |

| Not yet | Meanwhile |
| --- | --- |
| Merge queue, landing, checks, reviews, comments, abandon: no endpoints | The summary fields and event types exist; a change stays `open` |
| Claims and changes on the real backend | They run on the in-memory backend only until the collaboration service is wired into the API |
| A server whose ref log `neo verify` can verify: the verifier is real (signatures, chain, signer authority, the signed head, pins for identity and history; `cargo test -p jit-client --test verify`), but the real backend does not serve the signed log through the API yet and the in-memory backend does not sign | `neo verify` exits 1 with `failure.code` `unsigned`: treat the repository as unverified |
| Per-agent tokens from the server: there is one development root token | Tests register their own tokens in process |
| An audited TLS stack in the clients: `https://` works (TLS 1.3, rustls with a pure-Rust provider that is a pre-release and unaudited; decision 0007) | Use `https://` whenever the instance is not on loopback; `--ca-file` / `JIT_CA_FILE` for a private CA |
| Git transport authentication | The git mount is loopback-only |


<!-- https://docs.neoopensource.com/api -->

# neoopensource agent API (v1)

<!-- Generated from crates/jit-api/src/registry.rs and types.rs. Do not edit by hand:
run `cargo xtask docs` (or `JIT_UPDATE_DOCS=1 cargo test -p jit-api api_md`). A test fails when this file is stale. -->

The same information is served by a running instance: `/llms.txt` (a guide for agents), `/v1/openapi.json` (OpenAPI
3.1) and `GET /v1` (the endpoint list). Wire conventions (the envelope, limits in every answer, bounded lists,
cursors, errors, idempotency, events) are in `docs/contracts/jit-api.md` section 2 and are not repeated per endpoint.
Note: `Idempotency-Key` answers are kept in memory only and do not survive a restart or a crash (every deploy
restarts the server); for a write that must not happen twice, use the conditional fields (`expect` on commits).

Budgets are p50/p99 on a single warm node, measured by `cargo xtask bench` (see `docs/BENCHMARKS.md`); a regression
fails CI.

## Endpoints

| Endpoint | What it answers | Scope | Budget p50/p99 |
| --- | --- | --- | --- |
| [`GET /v1/health`](#health) | Liveness and version. | none | 1/5 ms |
| [`GET /v1`](#index) | What this service is: every endpoint with its scope and budget, and links to the guide. | none | 1/5 ms |
| [`GET /v1/openapi.json`](#openapi) | OpenAPI 3.1 description of this API, generated from the same table as the routes. | none | 1/5 ms |
| [`GET /v1/whoami`](#whoami) | Who the token is, for whom it acts, what it may do, and its limits. | none | 2/10 ms |
| [`POST /v1/principals`](#principalsregister) | Make a principal's public key known to this instance, so tokens it mints are accepted. | admin | 10/50 ms |
| [`PUT /v1/grants/{principal}`](#grantsinstance) | Set what a principal may do instance-wide (creating repositories needs `admin` here). | admin | 10/50 ms |
| [`PUT /v1/repos/{repo}/grants/{principal}`](#grantsrepo) | Set what a principal may do on one repository. | admin | 10/50 ms |
| [`POST /v1/repos/{repo}/tokens`](#tokensrunner) | Mint a runner's token: one principal, this repository only, read + change_write (push only if asked). | admin | 10/50 ms |
| [`POST /v1/repos/{repo}/tokens/revoke`](#tokensrevoke_repo) | Revoke a runner token of this repository by its revocation id: it and what was narrowed from it stop at once. | admin | 10/50 ms |
| [`POST /v1/tokens/revoke`](#tokensrevoke) | Needs a token. Revoke this request's token (no body), or as instance admin any token by revocation id; add `"unseen": true` for an id never seen here. | none | 10/50 ms |
| [`POST /v1/repos`](#reposcreate) | Create a repository. | admin | 10/50 ms |
| [`GET /v1/repos`](#reposlist) | List repositories the caller can read; `owner` for one account's (`u-…/…`). | read | 5/25 ms |
| [`GET /v1/repos/{repo}`](#reposget) | One repository: default branch, head commit, clone URL, event cursor, ref-log size. | read | 2/10 ms |
| [`POST /v1/repos/{repo}/withhold`](#reposwithhold) | Instance admin only: take part of a repository down, deleting nothing. `refs` covers the names and what only they reach, not what others reach; `record`, not its commits. | admin | 10/50 ms |
| [`POST /v1/repos/{repo}/restore`](#reposrestore) | Instance admin only: lift one withholding by its `withheld` entry's `seq`, as a signed `restored` entry. Others stay in force: lifting a narrower one serves nothing a wider one covers. | admin | 10/50 ms |
| [`GET /v1/repos/{repo}/withholdings`](#reposwithholdings) | The withholdings in force here, oldest first: `seq`, `scope`, `reason`, `reference`. Readable under any withholding, like the log. Lists every signer's; `binding` marks this host's, the only ones it enforces. | read | 10/50 ms |
| [`GET /v1/admin/accounts/{account}`](#accountsadmin_get) | Instance admin only (an unnarrowed token): an account's state, handle and counts. No identity. Alive whatever JIT_SIGNUP says. | admin | 5/25 ms |
| [`POST /v1/admin/accounts/{account}/suspend`](#accountssuspend) | Instance admin only: suspend an account. Its tokens are refused from the next request; its keys are retired for good. | admin | 10/50 ms |
| [`POST /v1/admin/accounts/{account}/restore`](#accountsrestore) | Instance admin only: lift a suspension. No session, key or token comes back. | admin | 10/50 ms |
| [`GET /v1/repos/{repo}/refs`](#refslist) | List refs, optionally under a prefix. | read | 2/10 ms |
| [`GET /v1/repos/{repo}/refs/{name}`](#refsget) | Read one ref. | read | 2/10 ms |
| [`GET /v1/repos/{repo}/commit`](#commitget) | Read one commit. | read | 2/10 ms |
| [`GET /v1/repos/{repo}/log`](#log) | History from a revision, newest first, optionally only commits touching a path. | read | 10/50 ms |
| [`GET /v1/repos/{repo}/tree`](#tree) | List a directory at a revision. | read | 5/25 ms |
| [`GET /v1/repos/{repo}/blob`](#blob) | Read a file at a revision. | read | 5/25 ms |
| [`GET /v1/repos/{repo}/diff`](#diff) | Diff two revisions. | read | 10/50 ms |
| [`GET /v1/repos/{repo}/files`](#files) | Read a directory with its files and their content. | read | 10/50 ms |
| [`POST /v1/repos/{repo}/commits`](#commitscreate) | Commit up to 1000 files to a branch without a clone: one commit on `base`; the branch is set to it. | push | 50/200 ms |
| [`POST /v1/repos/{repo}/changes`](#changescreate) | Propose a change: a stable id over an evolving stack of commits. | change_write | 10/50 ms |
| [`GET /v1/repos/{repo}/changes`](#changeslist) | List changes. | read | 10/50 ms |
| [`GET /v1/repos/{repo}/changes/{change}`](#changesget) | The state of a change in one answer: revisions, diff stat, checks, reviews, conflicts, queue. | read | 10/50 ms |
| [`POST /v1/repos/{repo}/changes/{change}/revisions`](#changesrevise) | Add a revision to a change (what a force-push becomes). Earlier revisions stay readable. | change_write | 10/50 ms |
| [`PUT /v1/repos/{repo}/changes/for/{branch}`](#changesupsert) | The open change for a branch, or open one: revised when the branch moved, never retitled. Idempotent. | change_write | 10/50 ms |
| [`GET /v1/repos/{repo}/changes/{change}/interdiff`](#changesinterdiff) | What changed between two revisions of a change. | read | 10/50 ms |
| [`POST /v1/repos/{repo}/changes/{change}/checks`](#checksreport) | Report a check result on a revision of a change (the same name again replaces it). | change_write | 10/50 ms |
| [`POST /v1/repos/{repo}/claims`](#claimscreate) | Claim a task or a set of paths for a while, so others see it before they start. | claim | 5/25 ms |
| [`GET /v1/repos/{repo}/claims`](#claimslist) | Active claims. | read | 5/25 ms |
| [`POST /v1/repos/{repo}/claims/{claim}/renew`](#claimsrenew) | Extend a claim's lease. | claim | 5/25 ms |
| [`DELETE /v1/repos/{repo}/claims/{claim}`](#claimsrelease) | Release a claim before it expires. | claim | 5/25 ms |
| [`GET /v1/repos/{repo}/sync`](#sync) | What changed since a cursor, folded into state: moved refs, touched changes, active claims. | read | 10/50 ms |
| [`GET /v1/repos/{repo}/work`](#work) | What the caller could do next: its changes needing action, reviews it could give, claims to avoid. | read | 10/50 ms |
| [`GET /v1/repos/{repo}/events`](#eventsrepo) | The repository's ordered event stream (SSE), resumable from a cursor; or one JSON page with `wait_ms`. | read | 5/25 ms |
| [`GET /v1/events`](#eventsall) | The firehose: events of every repository the token can read, in one ordered stream. | read | 5/25 ms |
| [`GET /v1/repos/{repo}/reflog/head`](#refloghead) | The signed head (checkpoint) of the repository's append-only ref log. | read | 5/25 ms |
| [`GET /v1/repos/{repo}/reflog`](#reflogentries) | Entries of the signed ref log, oldest first: who moved which ref, for whom, with which token. | read | 5/25 ms |
| [`GET /v1/repos/{repo}/reflog/proof`](#reflogproof) | Proof that one entry is in the signed log: its RFC 9162 audit path; readable whatever is withheld. | read | 10/50 ms |
| [`GET /v1/repos/{repo}/reflog/consistency`](#reflogconsistency) | Proof that the signed log only grew between two sizes (RFC 9162); readable whatever is withheld. | read | 10/50 ms |
| [`GET /v1/repos/{repo}/bundle`](#reposbundle) | The repository as one signed bundle file, verifiable offline. | read | 10/50 ms |
| [`GET /v1/repos/{repo}/queue`](#queueget) | One target's landing queue: who is in line, and the candidates being checked. | read | 10/50 ms |
| [`GET /v1/repos/{repo}/queue/candidates`](#queuecandidates) | Candidates that still need a check, front first: what a rule's reporter runs next. | read | 10/50 ms |
| [`POST /v1/repos/{repo}/queue/candidates/{candidate}/checks`](#queuereport) | Report a rule's check on a candidate; `passed` lands it in its turn. | change_write | 10/50 ms |
| [`GET /v1/repos/{repo}/landing-rules`](#landing_rulesget) | The repository's landing rules: which changes land by themselves, and on which check. | read | 5/25 ms |
| [`PUT /v1/repos/{repo}/landing-rules`](#landing_rulesset) | Replace the repository's landing rules (the whole list). | admin | 5/25 ms |
| [`DELETE /v1/repos/{repo}/landing-rules`](#landing_rulesdelete) | Remove every landing rule of the repository: nothing lands by itself any more. | admin | 5/25 ms |
| [`POST /v1/feedback`](#feedbackcreate) | Send feedback about this instance: stores the text, CLI version and diagnostics if sent, and the token's principal. Its id is the only way to read its status. | none | 10/50 ms |
| [`GET /v1/feedback/{id}`](#feedbackget) | What became of one feedback item: its state, kind, the change it led to and a one-line reply. | none | 5/25 ms |
| [`GET /v1/admin/feedback`](#feedbackadmin_list) | Feedback items, oldest first. Needs instance `review` (feedback triage) or instance admin. | review | 5/25 ms |
| [`GET /v1/admin/feedback/{id}`](#feedbackadmin_get) | One feedback item in full. Needs instance `review` (feedback triage) or instance admin. | review | 5/25 ms |
| [`PATCH /v1/admin/feedback/{id}`](#feedbackadmin_set) | Triage a feedback item: state, kind, the change it led to, a reply. Needs instance `review` (feedback triage) or instance admin. | review | 10/50 ms |
| [`DELETE /v1/admin/feedback/{id}`](#feedbackadmin_delete) | Delete a feedback item for good: its id names nothing from then on. Instance admin only. | admin | 10/50 ms |
| [`POST /v1/batch`](#batch) | Up to 32 reads in one round trip. | none | 10/50 ms |
| [`POST /v1/session/start`](#sessionstart) | Only when sign-up is on. Start a login: a state for the login page and a nonce for the browser's cookie. | none | 5/25 ms |
| [`POST /v1/session/exchange`](#sessionexchange) | Only when sign-up is on. Finish a login: its state and nonce and Privy's two tokens become a session. | none | 20/100 ms |
| [`POST /v1/session/end`](#sessionend) | Sign out: end this session, or with `everywhere` every session of the account. Exists in every sign-up mode. | none | 10/50 ms |
| [`GET /v1/account`](#accountget) | Only when sign-up is on. The signed-in account: handle, state, how many keys and repositories. | none | 2/10 ms |
| [`POST /v1/pairings`](#pairingsbegin) | Only when sign-up is on. Pair a machine: its ed25519 key and a name get a code to type on the account page. | none | 10/50 ms |
| [`POST /v1/pairings/lookup`](#pairingslookup) | Only when sign-up is on. What a typed code pairs: the machine's name and its key's fingerprint. | none | 5/25 ms |
| [`POST /v1/pairings/approve`](#pairingsapprove) | Only when sign-up is on. Approve a code for the key with the fingerprint the page showed: it becomes a key of the account. | none | 10/50 ms |
| [`GET /v1/pairings/{pairing}`](#pairingsstatus) | Only when sign-up is on. A pairing's state, asked by the machine with `Authorization: JitKey <poll>` signed by its key. | none | 5/25 ms |
| [`GET /v1/account/keys`](#accountkeys) | Only when sign-up is on. The machine keys of the signed-in account. | none | 5/25 ms |
| [`DELETE /v1/account/keys/{id}`](#accountkeysremove) | Only when sign-up is on. Take a machine key away from the account: its tokens are refused from the next request. | none | 10/50 ms |

## Sign-up routes and `JIT_SIGNUP`

The sign-up routes (docs/contracts/accounts.md) exist only as the server's `JIT_SIGNUP` setting says. A route that
does not exist answers exactly what an unknown path answers (`404 not_found`), and is left out of `GET /v1`,
`/v1/openapi.json` and `/llms.txt` on that instance. Every other endpoint exists in every mode. The per-address
limits of these routes are kept in memory and start again at a restart.

| Endpoint | `off` | `preview` | `privy` |
| --- | --- | --- | --- |
| `POST /v1/session/start` | no | yes | yes |
| `POST /v1/session/exchange` | no | yes | yes |
| `POST /v1/session/end` | yes | yes | yes |
| `GET /v1/account` | no | yes | yes |
| `POST /v1/pairings` | no | yes | yes |
| `POST /v1/pairings/lookup` | no | yes | yes |
| `POST /v1/pairings/approve` | no | yes | yes |
| `GET /v1/pairings/{pairing}` | no | yes | yes |
| `GET /v1/account/keys` | no | yes | yes |
| `DELETE /v1/account/keys/{id}` | no | yes | yes |

### health

`GET /v1/health`

Liveness and version.

- Answer (`data`): [`Health`](#health). Status, version, backend, uptime. Also served at `/healthz` without the envelope's cost.
- Scope: none (works without a token)
- Budget: p50 1 ms, p99 5 ms
- CLI: `neo health`

### index

`GET /v1`

What this service is: every endpoint with its scope and budget, and links to the guide.

- Answer (`data`): [`Index`](#index). The endpoint list (bounded by the size of the API).
- Scope: none (works without a token)
- Budget: p50 1 ms, p99 5 ms
- CLI: `neo api GET /v1`

### openapi

`GET /v1/openapi.json`

OpenAPI 3.1 description of this API, generated from the same table as the routes.

- Answer (`data`): [`OpenApi`](#openapi). A bare OpenAPI document (not wrapped in the envelope).
- Scope: none (works without a token)
- Budget: p50 1 ms, p99 5 ms
- CLI: `neo api GET /v1/openapi.json`

### whoami

`GET /v1/whoami`

Who the token is, for whom it acts, what it may do, and its limits.

- Answer (`data`): [`WhoAmI`](#whoami). Principal, owner, scopes, expiry. Limits are in `meta.limits` as in every answer.
- Scope: none (works without a token)
- Budget: p50 2 ms, p99 10 ms
- CLI: `neo whoami`

### principals.register

`POST /v1/principals`

Make a principal's public key known to this instance, so tokens it mints are accepted.

- Request body: [`RegisterPrincipal`](#registerprincipal)
- Answer (`data`): [`PrincipalInfo`](#principalinfo). The principal record. Registering the same id again updates its name.
- Scope: `admin`
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo principal register <id> --name N`

### grants.instance

`PUT /v1/grants/{principal}`

Set what a principal may do instance-wide (creating repositories needs `admin` here).

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `principal` | path | string | yes | Principal id (`jp_…`). |

- Request body: [`SetGrant`](#setgrant)
- Answer (`data`): [`GrantInfo`](#grantinfo). The grant as it now stands. Applies from the next request, also to tokens already issued.
- Scope: `admin`
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo grant set <principal> --scopes S,…`

### grants.repo

`PUT /v1/repos/{repo}/grants/{principal}`

Set what a principal may do on one repository.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |
| `principal` | path | string | yes | Principal id (`jp_…`). |

- Request body: [`SetGrant`](#setgrant)
- Answer (`data`): [`GrantInfo`](#grantinfo). The grant as it now stands. An empty `scopes` removes it.
- Scope: `admin`
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo grant set <principal> --repo R --scopes S,…`

### tokens.runner

`POST /v1/repos/{repo}/tokens`

Mint a runner's token: one principal, this repository only, read + change_write (push only if asked).

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |

- Request body: [`MintRunnerToken`](#mintrunnertoken)
- Answer (`data`): [`RunnerToken`](#runnertoken). The token, once: not stored. Revoke by `revocation_id` (`POST …/tokens/revoke`) or by itself (`POST /v1/tokens/revoke`).
- Scope: `admin`
- Secret: the request or answer carries a credential: answers are `Cache-Control: no-store`, a repeated `Idempotency-Key` is refused (`409`) and never replayed, and a malformed body is not echoed.
- Budget: p50 10 ms, p99 50 ms
- CLI: `jit-runner setup <setup.json>`

### tokens.revoke_repo

`POST /v1/repos/{repo}/tokens/revoke`

Revoke a runner token of this repository by its revocation id: it and what was narrowed from it stop at once.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |

- Request body: [`RevokeToken`](#revoketoken)
- Answer (`data`): [`TokenRevoked`](#tokenrevoked). Idempotent. The revocation is an entry in the repository's signed log, by the caller.
- Scope: `admin`
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo api POST /v1/repos/<repo>/tokens/revoke --json …`

### tokens.revoke

`POST /v1/tokens/revoke`

Needs a token. Revoke this request's token (no body), or as instance admin any token by revocation id; add `"unseen": true` for an id never seen here.

- Request body: [`RevokeAnyToken`](#revokeanytoken)
- Answer (`data`): [`TokenRevoked`](#tokenrevoked). Idempotent; tokens narrowed from it stop too. Unseen, by CLI: `neo admin revoke <revocation id> --unseen`.
- Scope: none (works without a token)
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo --token-file LEAKED api POST /v1/tokens/revoke`

### repos.create

`POST /v1/repos`

Create a repository.

- Request body: [`CreateRepo`](#createrepo)
- Answer (`data`): [`Repo`](#repo). The repository, including its identity (`id`), clone URL and event cursor.
- Scope: `admin`
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo repo create <name>`

### repos.list

`GET /v1/repos`

List repositories the caller can read; `owner` for one account's (`u-…/…`).

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `limit` | query | integer | no | Page size, default 100, max 1000. |
| `after` | query | string | no | The `next` cursor of the previous page. |
| `owner` | query | string | no | An account's handle (`u-…`): only its repositories, `<handle>/<name>`. |

- Answer (`data`): [`Listed<Repo>`](#repo). A page of repositories ordered by name.
- Scope: `read` (public repositories: no token needed)
- Budget: p50 5 ms, p99 25 ms
- CLI: `neo repo list`

### repos.get

`GET /v1/repos/{repo}`

One repository: default branch, head commit, clone URL, event cursor, ref-log size.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |

- Answer (`data`): [`Repo`](#repo). One record.
- Scope: `read` (public repositories: no token needed)
- Budget: p50 2 ms, p99 10 ms
- CLI: `neo repo get <repo>`

### repos.withhold

`POST /v1/repos/{repo}/withhold`

Instance admin only: take part of a repository down, deleting nothing. `refs` covers the names and what only they reach, not what others reach; `record`, not its commits.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |

- Request body: [`Withhold`](#withhold)
- Answer (`data`): [`LogEntry`](#logentry). The `withheld` entry.
- Scope: `admin`
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo admin withhold <repo> (--repository | --refs PATTERN… | --record KIND ID) --reason R [--reference TEXT]`

### repos.restore

`POST /v1/repos/{repo}/restore`

Instance admin only: lift one withholding by its `withheld` entry's `seq`, as a signed `restored` entry. Others stay in force: lifting a narrower one serves nothing a wider one covers.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |

- Request body: [`Restore`](#restore)
- Answer (`data`): [`LogEntry`](#logentry). The `restored` entry; `not_found` if none is in force at `seq`.
- Scope: `admin`
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo admin restore <repo> SEQ`

### repos.withholdings

`GET /v1/repos/{repo}/withholdings`

The withholdings in force here, oldest first: `seq`, `scope`, `reason`, `reference`. Readable under any withholding, like the log. Lists every signer's; `binding` marks this host's, the only ones it enforces.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |
| `after` | query | string | no | Sequence number to list after; absent for the first. |
| `limit` | query | integer | no | Page size, default 100, max 1000. |

- Answer (`data`): [`Listed<Withholding>`](#withholding). A page; restore takes an item's `seq`.
- Scope: `read` (public repositories: no token needed)
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo admin withholdings <repo>`

### accounts.admin_get

`GET /v1/admin/accounts/{account}`

Instance admin only (an unnarrowed token): an account's state, handle and counts. No identity. Alive whatever JIT_SIGNUP says.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `account` | path | string | yes | The account's principal id (`jp_…`) or handle (`u-…`). |

- Answer (`data`): [`AdminAccount`](#adminaccount). `reason` and `suspended_ms` while suspended.
- Scope: `admin`
- Budget: p50 5 ms, p99 25 ms
- CLI: `neo admin account show <account>`

### accounts.suspend

`POST /v1/admin/accounts/{account}/suspend`

Instance admin only: suspend an account. Its tokens are refused from the next request; its keys are retired for good.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `account` | path | string | yes | The account's principal id (`jp_…`) or handle (`u-…`). |

- Request body: [`SuspendAccount`](#suspendaccount)
- Answer (`data`): [`AccountChanged`](#accountchanged). The account, `changed`, `keys_retired`.
- Scope: `admin`
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo admin account suspend <account> --reason R [--reference TEXT]`

### accounts.restore

`POST /v1/admin/accounts/{account}/restore`

Instance admin only: lift a suspension. No session, key or token comes back.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `account` | path | string | yes | The account's principal id (`jp_…`) or handle (`u-…`). |

- Answer (`data`): [`AccountChanged`](#accountchanged). The account, `changed`.
- Scope: `admin`
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo admin account restore <account>`

### refs.list

`GET /v1/repos/{repo}/refs`

List refs, optionally under a prefix.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |
| `prefix` | query | string | no | Only refs whose full name starts with this, e.g. `refs/heads/`. The landing queue's refs are left out under any prefix. |
| `limit` | query | integer | no | Page size, default 100, max 1000. |
| `after` | query | string | no | The `next` cursor of the previous page. |

- Answer (`data`): [`Listed<Ref>`](#ref). A page of refs ordered by name. The landing queue's refs (`refs/queue`, `refs/queue/…`) are never listed, for any `prefix` or caller, and the page is as if they did not exist; see `queue.get`.
- Scope: `read` (public repositories: no token needed)
- Budget: p50 2 ms, p99 10 ms
- CLI: `neo refs <repo> [--prefix P]`

### refs.get

`GET /v1/repos/{repo}/refs/{name}`

Read one ref.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |
| `name` | path | string | yes | Full ref name (`refs/heads/main`) or a short branch or tag name (`main`). |

- Answer (`data`): [`Ref`](#ref). The ref's full name and the object id it points at. The landing queue's refs (`refs/queue`, `refs/queue/…`) are `not_found`, as if they did not exist, and are no revision on any route; see `queue.get`.
- Scope: `read` (public repositories: no token needed)
- Budget: p50 2 ms, p99 10 ms
- CLI: `neo refs <repo> <name>`

### commit.get

`GET /v1/repos/{repo}/commit`

Read one commit.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |
| `rev` | query | string | no | A commit id, a full ref name, or a branch or tag name. Default: the default branch. |

- Answer (`data`): [`Commit`](#commit). Ids, parents, author, committer and message (message capped at 64 KiB).
- Scope: `read` (public repositories: no token needed)
- Budget: p50 2 ms, p99 10 ms
- CLI: `neo commit <repo> <rev>`

### log

`GET /v1/repos/{repo}/log`

History from a revision, newest first, optionally only commits touching a path.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |
| `rev` | query | string | no | A commit id, a full ref name, or a branch or tag name. Default: the default branch. |
| `path` | query | string | no | Only commits that changed this path or anything under it. |
| `limit` | query | integer | no | Page size, default 100, max 1000. |
| `after` | query | string | no | The `next` cursor of the previous page. |

- Answer (`data`): [`Listed<Commit>`](#commit). A page of commits; `next` continues the walk.
- Scope: `read` (public repositories: no token needed)
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo log <repo> [--rev R] [--path P] [--limit N]`

### tree

`GET /v1/repos/{repo}/tree`

List a directory at a revision.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |
| `rev` | query | string | no | A commit id, a full ref name, or a branch or tag name. Default: the default branch. |
| `path` | query | string | no | Directory path; empty or absent for the root. |
| `recursive` | query | boolean | no | List everything under the path, files only. |
| `limit` | query | integer | no | Page size, default 100, max 1000. |
| `after` | query | string | no | The `next` cursor of the previous page. |

- Answer (`data`): [`Tree`](#tree). A page of entries ordered by name, each with kind, id and size. `recursive=true` lists the subtree.
- Scope: `read` (public repositories: no token needed)
- Budget: p50 5 ms, p99 25 ms
- CLI: `neo tree <repo> [--rev R] [path]`

### blob

`GET /v1/repos/{repo}/blob`

Read a file at a revision.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |
| `rev` | query | string | no | A commit id, a full ref name, or a branch or tag name. Default: the default branch. |
| `path` | query | string | yes | File path. |
| `range` | query | string | no | Byte range `start-end` (end exclusive). Default: the first 1 MiB. |

- Answer (`data`): [`Blob`](#blob). Content inline (UTF-8, or base64 when binary), at most 1 MiB per answer; `range` reads further.
- Scope: `read` (public repositories: no token needed)
- Budget: p50 5 ms, p99 25 ms
- CLI: `neo blob <repo> <path> [--rev R] [--raw]`

### diff

`GET /v1/repos/{repo}/diff`

Diff two revisions.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |
| `base` | query | string | yes | Revision to diff from. |
| `head` | query | string | yes | Revision to diff to. |
| `patch` | query | boolean | no | Include patches. Default true. |
| `max_bytes` | query | integer | no | Total patch bytes, default 262144, max 4194304. |
| `path` | query | string | no | Only this path or anything under it. |

- Answer (`data`): [`Diff`](#diff). Per-file stats (complete up to 5000 files) and unified patches bounded by `max_bytes`.
- Scope: `read` (public repositories: no token needed)
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo diff <repo> <base> <head>`

### files

`GET /v1/repos/{repo}/files`

Read a directory with its files and their content.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |
| `rev` | query | string | no | A commit id, a full ref name, or a branch or tag name. Default: the default branch. |
| `path` | query | string | no | Directory path; empty or absent for the root. |
| `known` | query | string | no | A commit you already have, or the `tree` of an earlier answer. |
| `glob` | query | string | no | Only matching files: `*.lean`, `src/**/*.rs`; comma-separated. |
| `max_bytes` | query | integer | no | Total inline content, default 1048576, max 8388608. |
| `after` | query | string | no | The `next` cursor of the previous page. |

- Answer (`data`): [`Files`](#files). Files recursively, content inline up to `max_bytes` in total. With `known`: `unchanged: true` and no files if the directory is the same in both commits.
- Scope: `read` (public repositories: no token needed)
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo files <repo> [path] [--rev R] [--known C] [--glob G]`

### commits.create

`POST /v1/repos/{repo}/commits`

Commit up to 1000 files to a branch without a clone: one commit on `base`; the branch is set to it.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |

- Request body: [`CommitFiles`](#commitfiles)
- Answer (`data`): [`Committed`](#committed). The new commit, its tree and parent, the branch and what it pointed at before (`expect` makes it conditional).
- Scope: `push`
- Budget: p50 50 ms, p99 200 ms
- CLI: `neo write <repo> <branch> PATH=TEXT… -m MSG`

### changes.create

`POST /v1/repos/{repo}/changes`

Propose a change: a stable id over an evolving stack of commits.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |

- Request body: [`CreateChange`](#createchange)
- Answer (`data`): [`ChangeSummary`](#changesummary). The change summary, as `changes.get` returns it.
- Scope: `change_write`
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo change create <repo> --title T --head REV`

### changes.list

`GET /v1/repos/{repo}/changes`

List changes.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |
| `state` | query | string | no | `open` (default), `queued`, `merged`, `abandoned` or `all`. |
| `author` | query | string | no | Only changes by this principal. |
| `limit` | query | integer | no | Page size, default 100, max 1000. |
| `after` | query | string | no | The `next` cursor of the previous page. |

- Answer (`data`): [`Listed<ChangeBrief>`](#changebrief). A page of change briefs, most recently updated first; under a withholding, a page may be short.
- Scope: `read` (public repositories: no token needed)
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo change list <repo>`

### changes.get

`GET /v1/repos/{repo}/changes/{change}`

The state of a change in one answer: revisions, diff stat, checks, reviews, conflicts, queue.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |
| `change` | path | string | yes | Change id. |

- Answer (`data`): [`ChangeSummary`](#changesummary). One summary; its lists are bounded (50 revisions, 200 paths) with true counts alongside.
- Scope: `read` (public repositories: no token needed)
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo change get <repo> <change>`

### changes.revise

`POST /v1/repos/{repo}/changes/{change}/revisions`

Add a revision to a change (what a force-push becomes). Earlier revisions stay readable.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |
| `change` | path | string | yes | Change id. |

- Request body: [`AddRevision`](#addrevision)
- Answer (`data`): [`ChangeSummary`](#changesummary). The updated change summary.
- Scope: `change_write`
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo change update <repo> <change> --head REV`

### changes.upsert

`PUT /v1/repos/{repo}/changes/for/{branch}`

The open change for a branch, or open one: revised when the branch moved, never retitled. Idempotent.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |
| `branch` | path | string | yes | The head branch's short name; slashes allowed, not encoded. |

- Request body: [`UpsertChange`](#upsertchange)
- Answer (`data`): [`Upserted`](#upserted). The change summary, with `created` and `revised` saying what this call did.
- Scope: `change_write`
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo propose <repo> <branch> --title T`

### changes.interdiff

`GET /v1/repos/{repo}/changes/{change}/interdiff`

What changed between two revisions of a change.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |
| `change` | path | string | yes | Change id. |
| `from` | query | integer | yes | Earlier revision number. |
| `to` | query | integer | no | Later revision number. Default: the latest. |
| `patch` | query | boolean | no | Include patches. Default true. |
| `max_bytes` | query | integer | no | Total patch bytes, default 262144, max 4194304. |

- Answer (`data`): [`Diff`](#diff). A diff, bounded like `diff`.
- Scope: `read` (public repositories: no token needed)
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo change interdiff <repo> <change> --from N [--to M]`

### checks.report

`POST /v1/repos/{repo}/changes/{change}/checks`

Report a check result on a revision of a change (the same name again replaces it).

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |
| `change` | path | string | yes | Change id. |

- Request body: [`ReportCheck`](#reportcheck)
- Answer (`data`): [`ChangeSummary`](#changesummary). The change summary. `precondition_failed` (`details.head`) if `head` is stale; log max 256 KiB.
- Scope: `change_write`
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo check report <repo> <change> --name N --state S`

### claims.create

`POST /v1/repos/{repo}/claims`

Claim a task or a set of paths for a while, so others see it before they start.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |

- Request body: [`CreateClaim`](#createclaim)
- Answer (`data`): [`Claim`](#claim). The claim. `409 conflict` with the holder in `details` if an overlapping claim is held by another.
- Scope: `claim`
- Budget: p50 5 ms, p99 25 ms
- CLI: `neo claim create <repo> --paths P [--task T] [--ttl-ms N]`

### claims.list

`GET /v1/repos/{repo}/claims`

Active claims.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |
| `limit` | query | integer | no | Page size, default 100, max 1000. |
| `after` | query | string | no | The `next` cursor of the previous page. |

- Answer (`data`): [`Listed<Claim>`](#claim). A page of unexpired claims, soonest to expire first.
- Scope: `read` (public repositories: no token needed)
- Budget: p50 5 ms, p99 25 ms
- CLI: `neo claim list <repo>`

### claims.renew

`POST /v1/repos/{repo}/claims/{claim}/renew`

Extend a claim's lease.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |
| `claim` | path | string | yes | Claim id. |

- Request body: [`RenewClaim`](#renewclaim)
- Answer (`data`): [`Claim`](#claim). The claim with its new expiry.
- Scope: `claim`
- Budget: p50 5 ms, p99 25 ms
- CLI: `neo claim renew <repo> <claim>`

### claims.release

`DELETE /v1/repos/{repo}/claims/{claim}`

Release a claim before it expires.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |
| `claim` | path | string | yes | Claim id. |

- Answer (`data`): [`Claim`](#claim). The released claim.
- Scope: `claim`
- Budget: p50 5 ms, p99 25 ms
- CLI: `neo claim release <repo> <claim>`

### sync

`GET /v1/repos/{repo}/sync`

What changed since a cursor, folded into state: moved refs, touched changes, active claims.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |
| `since` | query | string | yes | An event cursor from an earlier answer; `0` for everything. |

- Answer (`data`): [`RepoSync`](#reposync). One object; folds at most 10000 events per call and says so in `truncated`.
- Scope: `read` (public repositories: no token needed)
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo sync <repo> --since CURSOR`

### work

`GET /v1/repos/{repo}/work`

What the caller could do next: its changes needing action, reviews it could give, claims to avoid.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |

- Answer (`data`): [`Work`](#work). Four bounded lists: `needs_you` from the caller's 20 most recently updated open changes, the others at most 50 each (claims 200).
- Scope: `read` (public repositories: no token needed)
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo next <repo>`

### events.repo

`GET /v1/repos/{repo}/events`

The repository's ordered event stream (SSE), resumable from a cursor; or one JSON page with `wait_ms`.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |
| `cursor` | query | string | no | Resume after this event cursor; `0` is the beginning. Default: now. |
| `wait_ms` | query | integer | no | Answer JSON instead of a stream: return as soon as there is an event, or after this long (max 30000). |
| `limit` | query | integer | no | Page size, default 100, max 1000. |

- Answer (`data`): [`EventPage`](#eventpage). `text/event-stream` with `id:` = cursor, ending with `event: bye` `{cursor, reason}`; with `wait_ms`, an `EventPage` of at most `limit` events.
- Scope: `read` (public repositories: no token needed)
- Budget: p50 5 ms, p99 25 ms
- CLI: `neo events <repo> [--cursor C] [--follow]`

### events.all

`GET /v1/events`

The firehose: events of every repository the token can read, in one ordered stream.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `cursor` | query | string | no | Resume after this event cursor; `0` is the beginning. Default: now. |
| `wait_ms` | query | integer | no | Answer JSON instead of a stream: return as soon as there is an event, or after this long (max 30000). |
| `limit` | query | integer | no | Page size, default 100, max 1000. |

- Answer (`data`): [`EventPage`](#eventpage). As `events.repo`; cursors of this stream are its own and are not valid on a repository stream.
- Scope: `read` (public repositories: no token needed)
- Budget: p50 5 ms, p99 25 ms
- CLI: `neo events [--cursor C] [--follow]`

### reflog.head

`GET /v1/repos/{repo}/reflog/head`

The signed head (checkpoint) of the repository's append-only ref log.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |

- Answer (`data`): [`LogHead`](#loghead). Size, Merkle root, signer and signature: what a mirror or auditor pins.
- Scope: `read` (public repositories: no token needed)
- Budget: p50 5 ms, p99 25 ms
- CLI: `neo reflog <repo> --head`

### reflog.entries

`GET /v1/repos/{repo}/reflog`

Entries of the signed ref log, oldest first: who moved which ref, for whom, with which token.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |
| `after` | query | string | no | Sequence number to read after; absent for the beginning. |
| `limit` | query | integer | no | Page size, default 100, max 1000. |
| `raw` | query | boolean | no | Include each entry's canonical bytes (base64). |

- Answer (`data`): [`Listed<LogEntry>`](#logentry). A page of entries; `raw=true` adds the canonical signed bytes for local verification.
- Scope: `read` (public repositories: no token needed)
- Budget: p50 5 ms, p99 25 ms
- CLI: `neo reflog <repo> [--after N]`

### reflog.proof

`GET /v1/repos/{repo}/reflog/proof`

Proof that one entry is in the signed log: its RFC 9162 audit path; readable whatever is withheld.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |
| `seq` | query | integer | yes | The entry's sequence number; below `size`. |
| `size` | query | integer | no | The tree size to prove against (a signed head's `size`). Default: the current head's. |

- Answer (`data`): [`LogProof`](#logproof). About log2(size) hashes; verify as `LogProof` says (leaf from `reflog?raw=true`, `verify_inclusion`).
- Scope: `read` (public repositories: no token needed)
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo verify <repo> --entry N --since SIZE:ROOT`

### reflog.consistency

`GET /v1/repos/{repo}/reflog/consistency`

Proof that the signed log only grew between two sizes (RFC 9162); readable whatever is withheld.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |
| `old` | query | integer | yes | The size of the checkpoint you kept; at most `new`. |
| `new` | query | integer | no | The size to prove against (a signed head's `size`). Default: the current head's. |

- Answer (`data`): [`LogConsistency`](#logconsistency). Keep a verified head's size and root; pass it as `old`. A smaller head or a failing proof: the log was rewritten.
- Scope: `read` (public repositories: no token needed)
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo verify <repo>`

### repos.bundle

`GET /v1/repos/{repo}/bundle`

The repository as one signed bundle file, verifiable offline.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |

- Answer: The file, not the envelope: `ETag` (one per log position), `X-Bundle-Sha256`, `X-Bundle-Log-Size`, `-Root`; one `Range` with `If-Range`. `503` + `Retry-After` while it is written, `413` over the cap, `451` if the whole repository is withheld.
- Scope: `read` (public repositories: no token needed)
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo bundle <repo> -o FILE`

### queue.get

`GET /v1/repos/{repo}/queue`

One target's landing queue: who is in line, and the candidates being checked.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |
| `target` | query | string | no | Branch; default `main`. |

- Answer (`data`): [`Queue`](#queue). At most 200 entries, 200 waiting, 64 candidates (`truncated`).
- Scope: `read` (public repositories: no token needed)
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo api GET /v1/repos/<repo>/queue`

### queue.candidates

`GET /v1/repos/{repo}/queue/candidates`

Candidates that still need a check, front first: what a rule's reporter runs next.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |
| `check` | query | string | yes | The check's name. |
| `target` | query | string | no | Only this branch's queue. |

- Answer (`data`): [`Candidates`](#candidates). At most 64; `commit` is what to check and what would land. A plain read.
- Scope: `read` (public repositories: no token needed)
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo api GET /v1/repos/<repo>/queue/candidates?check=<name>`

### queue.report

`POST /v1/repos/{repo}/queue/candidates/{candidate}/checks`

Report a rule's check on a candidate; `passed` lands it in its turn.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |
| `candidate` | path | string | yes | Candidate id, from `queue.candidates`. |

- Request body: [`ReportCandidate`](#reportcandidate)
- Answer (`data`): [`CandidateReported`](#candidatereported). What landed and was put out. `conflict` reasons: `candidate_gone`, `stale_run`, `run_finished`.
- Scope: `change_write`
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo api POST /v1/repos/<repo>/queue/candidates/<id>/checks --json JSON`

### landing_rules.get

`GET /v1/repos/{repo}/landing-rules`

The repository's landing rules: which changes land by themselves, and on which check.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |

- Answer (`data`): [`LandingRules`](#landingrules). Every rule: a change whose changed paths are exactly a rule's lands, squashed, when the rule's check passes.
- Scope: `read` (public repositories: no token needed)
- Budget: p50 5 ms, p99 25 ms
- CLI: `neo api GET /v1/repos/<repo>/landing-rules`

### landing_rules.set

`PUT /v1/repos/{repo}/landing-rules`

Replace the repository's landing rules (the whole list).

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |

- Request body: [`LandingRules`](#landingrules)
- Answer (`data`): [`LandingRules`](#landingrules). The rules as stored. `400 bad_request` with the reason for a malformed rule (no globs).
- Scope: `admin`
- Budget: p50 5 ms, p99 25 ms
- CLI: `neo api PUT /v1/repos/<repo>/landing-rules --json JSON`

### landing_rules.delete

`DELETE /v1/repos/{repo}/landing-rules`

Remove every landing rule of the repository: nothing lands by itself any more.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `repo` | path | string | yes | Repository name or id. An account's repository is `<handle>/<name>` (`u-…/proofs`), in two segments or with the `/` as `%2F` (decision 0089). |

- Answer (`data`): [`LandingRules`](#landingrules). The now empty list.
- Scope: `admin`
- Budget: p50 5 ms, p99 25 ms
- CLI: `neo api DELETE /v1/repos/<repo>/landing-rules`

### feedback.create

`POST /v1/feedback`

Send feedback about this instance: stores the text, CLI version and diagnostics if sent, and the token's principal. Its id is the only way to read its status.

- Request body: [`CreateFeedback`](#createfeedback)
- Answer (`data`): [`FeedbackReceipt`](#feedbackreceipt). The id. `409 conflict` (`details.reason: feedback_full`) while 20 of the sender's items wait. Never replayed by `Idempotency-Key`.
- Scope: none (works without a token)
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo feedback "text"`

### feedback.get

`GET /v1/feedback/{id}`

What became of one feedback item: its state, kind, the change it led to and a one-line reply.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes | The id `POST /v1/feedback` answered. |

- Answer (`data`): [`FeedbackStatus`](#feedbackstatus). The status only: no text, diagnostics or principal. An unknown or deleted id is the same `404`.
- Scope: none (works without a token)
- Budget: p50 5 ms, p99 25 ms
- CLI: `neo feedback status <id>`

### feedback.admin_list

`GET /v1/admin/feedback`

Feedback items, oldest first. Needs instance `review` (feedback triage) or instance admin.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `state` | query | string | no | `received` or `triaged`. |
| `kind` | query | string | no | `bug`, `idea`, `question`, `duplicate` or `not_planned`. |
| `limit` | query | integer | no | Page size, default 50, max 100. |
| `cursor` | query | string | no | The `next` of the previous page. |

- Answer (`data`): [`Listed<FeedbackItem>`](#feedbackitem). A page of whole items; pass `next` as `cursor`.
- Scope: `review`
- Budget: p50 5 ms, p99 25 ms
- CLI: `neo admin feedback list`

### feedback.admin_get

`GET /v1/admin/feedback/{id}`

One feedback item in full. Needs instance `review` (feedback triage) or instance admin.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes | Feedback id (`fb_…`). |

- Answer (`data`): [`FeedbackItem`](#feedbackitem). The item. Its text is any UTF-8 a stranger wrote: escape it before showing it.
- Scope: `review`
- Budget: p50 5 ms, p99 25 ms
- CLI: `neo admin feedback show <id>`

### feedback.admin_set

`PATCH /v1/admin/feedback/{id}`

Triage a feedback item: state, kind, the change it led to, a reply. Needs instance `review` (feedback triage) or instance admin.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes | Feedback id (`fb_…`). |

- Request body: [`SetFeedback`](#setfeedback)
- Answer (`data`): [`FeedbackItem`](#feedbackitem). The item now. A field left out stays; `null` clears it; a kind makes it triaged.
- Scope: `review`
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo admin feedback set <id> --kind bug --reply "..." --change "..."`

### feedback.admin_delete

`DELETE /v1/admin/feedback/{id}`

Delete a feedback item for good: its id names nothing from then on. Instance admin only.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes | Feedback id (`fb_…`). |

- Answer (`data`): [`FeedbackDeleted`](#feedbackdeleted). `deleted: true`; `404` when there was no such item.
- Scope: `admin`
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo admin feedback delete <id>`

### batch

`POST /v1/batch`

Up to 32 reads in one round trip.

- Request body: [`BatchRequest`](#batchrequest)
- Answer (`data`): [`BatchAnswer`](#batchanswer). One envelope per request, in order. Costs one request per part.
- Scope: none (works without a token)
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo api POST /v1/batch --json '{"requests":[{"path":"/v1/repos/x"}]}'`

### session.start

`POST /v1/session/start`

Only when sign-up is on. Start a login: a state for the login page and a nonce for the browser's cookie.

- Answer (`data`): [`LoginStarted`](#loginstarted). `state` and `nonce` (64 hex each) and `expires_ms` (10 minutes). No credential; limited per client address.
- Scope: none (works without a token)
- Secret: the request or answer carries a credential: answers are `Cache-Control: no-store`, an `Idempotency-Key` is ignored and nothing is ever replayed, it is not answered inside a batch, and a malformed body is not echoed.
- Budget: p50 5 ms, p99 25 ms
- CLI: `neo api POST /v1/session/start`

### session.exchange

`POST /v1/session/exchange`

Only when sign-up is on. Finish a login: its state and nonce and Privy's two tokens become a session.

- Request body: [`SessionExchange`](#sessionexchange)
- Answer (`data`): [`SessionExchanged`](#sessionexchanged). A session token (8 h), its expiry, `fresh_until_ms`, `created`, the account. Any failed token, state or nonce: `401 sign_in_again`.
- Scope: none (works without a token)
- Secret: the request or answer carries a credential: answers are `Cache-Control: no-store`, an `Idempotency-Key` is ignored and nothing is ever replayed, it is not answered inside a batch, and a malformed body is not echoed.
- Budget: p50 20 ms, p99 100 ms
- CLI: `neo api POST /v1/session/exchange --json JSON`

### session.end

`POST /v1/session/end`

Sign out: end this session, or with `everywhere` every session of the account. Exists in every sign-up mode.

- Request body: [`EndSession`](#endsession)
- Answer (`data`): [`SessionEnded`](#sessionended). `{"ended": true}`. Only an unnarrowed session token: anything else is `403 session_required`.
- Scope: none (works without a token)
- Secret: the request or answer carries a credential: answers are `Cache-Control: no-store`, an `Idempotency-Key` is ignored and nothing is ever replayed, it is not answered inside a batch, and a malformed body is not echoed.
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo api POST /v1/session/end`

### account.get

`GET /v1/account`

Only when sign-up is on. The signed-in account: handle, state, how many keys and repositories.

- Answer (`data`): [`AccountInfo`](#accountinfo). One record; `fresh_until_ms` only for a session. A session token or a machine key's token.
- Scope: none (works without a token)
- Secret: the request or answer carries a credential: answers are `Cache-Control: no-store`, an `Idempotency-Key` is ignored and nothing is ever replayed, it is not answered inside a batch, and a malformed body is not echoed.
- Budget: p50 2 ms, p99 10 ms
- CLI: `neo api GET /v1/account`

### pairings.begin

`POST /v1/pairings`

Only when sign-up is on. Pair a machine: its ed25519 key and a name get a code to type on the account page.

- Request body: [`BeginPairing`](#beginpairing)
- Answer (`data`): [`PairingBegun`](#pairingbegun). The pairing id, the code (`XXXX-XXXX`, 10 minutes), the instance's key, its `origin` (compare with what you dialed) and the page (`null`: `<JIT_URL>/pair`). No credential.
- Scope: none (works without a token)
- Secret: the request or answer carries a credential: answers are `Cache-Control: no-store`, an `Idempotency-Key` is ignored and nothing is ever replayed, it is not answered inside a batch, and a malformed body is not echoed.
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo login`

### pairings.lookup

`POST /v1/pairings/lookup`

Only when sign-up is on. What a typed code pairs: the machine's name and its key's fingerprint.

- Request body: [`LookupPairing`](#lookuppairing)
- Answer (`data`): [`PairingFound`](#pairingfound). Name, fingerprint (16 hex), where (`started_from`) and when it started, expiry. `404 no_such_code` for an unknown, used or expired code alike. A session only.
- Scope: none (works without a token)
- Secret: the request or answer carries a credential: answers are `Cache-Control: no-store`, an `Idempotency-Key` is ignored and nothing is ever replayed, it is not answered inside a batch, and a malformed body is not echoed.
- Budget: p50 5 ms, p99 25 ms
- CLI: `neo api POST /v1/pairings/lookup --json JSON`

### pairings.approve

`POST /v1/pairings/approve`

Only when sign-up is on. Approve a code for the key with the fingerprint the page showed: it becomes a key of the account.

- Request body: [`ApprovePairing`](#approvepairing)
- Answer (`data`): [`PairingApproved`](#pairingapproved). The new key. A fresh session only (`403 fresh_login_required`); `404 no_such_code`; `409 key_limit` (5 keys).
- Scope: none (works without a token)
- Secret: the request or answer carries a credential: answers are `Cache-Control: no-store`, an `Idempotency-Key` is ignored and nothing is ever replayed, it is not answered inside a batch, and a malformed body is not echoed.
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo api POST /v1/pairings/approve --json JSON`

### pairings.status

`GET /v1/pairings/{pairing}`

Only when sign-up is on. A pairing's state, asked by the machine with `Authorization: JitKey <poll>` signed by its key.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `pairing` | path | string | yes | Pairing id (32 hex), from `POST /v1/pairings`. |

- Answer (`data`): [`PairingStatus`](#pairingstatus). `pending` or `approved` (with the account and its handle). One refusal, `404 no_such_pairing`, for an unknown or expired pairing and a poll that does not verify.
- Scope: none (works without a token)
- Secret: the request or answer carries a credential: answers are `Cache-Control: no-store`, an `Idempotency-Key` is ignored and nothing is ever replayed, it is not answered inside a batch, and a malformed body is not echoed.
- Budget: p50 5 ms, p99 25 ms
- CLI: `neo login`

### account.keys

`GET /v1/account/keys`

Only when sign-up is on. The machine keys of the signed-in account.

- Answer (`data`): [`AccountKeys`](#accountkeys). At most 5 keys, each with id, name, fingerprint and when it was approved. A session only.
- Scope: none (works without a token)
- Secret: the request or answer carries a credential: answers are `Cache-Control: no-store`, an `Idempotency-Key` is ignored and nothing is ever replayed, it is not answered inside a batch, and a malformed body is not echoed.
- Budget: p50 5 ms, p99 25 ms
- CLI: `neo api GET /v1/account/keys`

### account.keys.remove

`DELETE /v1/account/keys/{id}`

Only when sign-up is on. Take a machine key away from the account: its tokens are refused from the next request.

| Parameter | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes | The key's id (`jp_…`), from `GET /v1/account/keys`. |

- Answer (`data`): [`KeyRemoved`](#keyremoved). `{"removed": true}`. A session only; no fresh login needed.
- Scope: none (works without a token)
- Secret: the request or answer carries a credential: answers are `Cache-Control: no-store`, an `Idempotency-Key` is ignored and nothing is ever replayed, it is not answered inside a batch, and a malformed body is not echoed.
- Budget: p50 10 ms, p99 50 ms
- CLI: `neo api DELETE /v1/account/keys/<id>`

## Types

`Listed<T>` is `{"items": [T], "next": string | null, "truncated": boolean}`. Fields marked optional may be absent in requests; answers always carry every field unless noted.

### AccountBrief

An account as a session's answer shows it.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `handle` | string | yes | `u-…`, given by the instance. |
| `principal` | string | yes | `jp_…`. |
| `state` | AccountState | yes |  |

### AccountChanged

What a suspension or a restoration answers: the account after it, whether this request changed it, and for a suspension the machine keys it retired (for good: restoring brings none back).

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `account` | AdminAccount | yes |  |
| `changed` | boolean | yes | `false` when the account already was in that state: nothing was done, nothing was recorded. |
| `keys_retired` | integer \| null | no | Suspension only: keys this request took away and retired. The person pairs their machines again. |

### AccountInfo

`GET /v1/account`.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `created_ms` | integer | yes |  |
| `fresh_until_ms` | integer \| null | no | For a session only: until when its login counts as fresh. |
| `handle` | string | yes |  |
| `keys` | integer | yes | Machine keys of the account (at most 5). |
| `principal` | string | yes |  |
| `repositories` | integer | yes | Repositories the account made (at most 10). |
| `state` | AccountState | yes |  |

### AccountKey

A machine key of an account.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `created_ms` | integer | yes |  |
| `fingerprint` | string | yes |  |
| `id` | string | yes | `jp_…`: the key is a principal, an agent of the account. |
| `name` | string | yes |  |

### AccountKeys

`GET /v1/account/keys`.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `items` | [AccountKey] | yes |  |

### AccountState

What the account is: `active`, or `suspended` by an administrator.

One of: `"active"` \| `"suspended"`

### AddRevision

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `expect_revision` | integer \| null | no | Fail with `precondition_failed` unless the change is currently at this revision number. |
| `head` | string | yes | The new top of the stack. A force-push is just a new revision; every earlier one stays readable. |
| `note` | string | no |  |

### AdminAccount

`GET /v1/admin/accounts/{account}`: an account as an instance administrator sees it. No identity: the provider's subject is never answered.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `created_ms` | integer | yes |  |
| `handle` | string | yes |  |
| `keys` | integer | yes | Machine keys of the account (at most 5). A suspension retires them all. |
| `principal` | string | yes |  |
| `reason` | SuspendReason \| null | no | While suspended: why. |
| `repositories` | integer | yes | Repositories the account made (at most 10). |
| `state` | AccountState | yes |  |
| `suspended_ms` | integer \| null | no | While suspended: since when. |

### ApiError

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `code` | ErrorCode | yes |  |
| `details` | any | no |  |
| `hint` | string \| null | no | What to do next, in one sentence. |
| `message` | string | yes |  |
| `retry_after_ms` | integer \| null | no | Set on `rate_limited` and `unavailable`. |

### ApprovePairing

`POST /v1/pairings/approve`: the fingerprint the page showed; approval binds to that key and no other.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `code` | string | yes |  |
| `fingerprint` | string | yes |  |

### BatchAnswer

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `answers` | [BatchPart] | yes | One entry per request: the HTTP status it would have had and its full envelope. |

### BatchItem

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `method` | string | no | Only `GET` is accepted. |
| `path` | string | yes | Path and query, starting with `/v1/`. |

### BatchPart

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `body` | any | yes |  |
| `status` | integer | yes |  |

### BatchRequest

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `requests` | [BatchItem] | yes | Up to 32 reads, answered in order. |

### BeginPairing

`POST /v1/pairings`: what `neo login` sends.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `name` | string | yes | 1 to 64 characters, no control characters: shown on the account page and in the key list. |
| `public_key` | string | yes | The machine's ed25519 public key, 64 hex digits. Its secret never leaves the machine. |

### Blob

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `binary` | boolean | yes |  |
| `commit` | string | yes |  |
| `content` | string | yes |  |
| `encoding` | Encoding | yes |  |
| `oid` | string | yes |  |
| `path` | string | yes |  |
| `range_end` | integer | yes |  |
| `range_start` | integer | yes | The byte range in `content`: `[start, end)`. |
| `size` | integer | yes | Size of the whole file in bytes. |
| `truncated` | boolean | yes | True when `content` is not the whole file; ask again with `range=start-end`. |

### Candidate

One commit that would land, and what the rule's check says of it so far.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `base` | string | yes | What it is built on: the target's tip, or the candidate ahead. |
| `change` | string | yes |  |
| `check` | string | yes | The check the rule wants on it. |
| `commit` | string | yes | The commit to check (readable by id: `tree`, `blob`, `files` at `rev=<commit>`). If the check passes, the target moves to exactly this. |
| `id` | string | yes |  |
| `number` | integer | yes |  |
| `revision` | integer | yes |  |
| `rule` | string | yes | The landing rule it is a candidate of. |
| `run_seq` | integer | yes |  |
| `state` | CheckState | yes | `pending`: nobody has reported on it yet. |
| `target` | string | yes |  |

### CandidateReported

What a report on a candidate did.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `candidate` | Candidate \| null | no | The candidate as it is now; absent once it landed or its change was put out. |
| `ejected` | [QueueEjected] | yes | The changes it put out of the queue. |
| `landed` | [string] | yes | The changes this report landed, in order (its own, and passed ones that were waiting behind it). |

### Candidates

The candidates that still need a check, front of each queue first (at most 64).

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `items` | [Candidate] | yes |  |

### ChangeBrief

A change as a list item.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `author` | string | yes |  |
| `base` | string | yes |  |
| `head` | string | yes |  |
| `id` | string | yes |  |
| `number` | integer | no | Per-repository number, from 1, never reused; `{change}` in a path accepts it as well as the id. |
| `revision` | integer | yes |  |
| `state` | ChangeState | yes |  |
| `title` | string | yes |  |
| `updated_ms` | integer | yes |  |

### ChangeState

One of: `"open"` \| `"queued"` \| `"merged"` \| `"abandoned"`

### ChangeSummary

Everything needed to act on a change, in one answer.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `author` | string | yes |  |
| `base` | string | yes | Target branch (full ref name). |
| `checks` | [Check] | yes |  |
| `created_ms` | integer | yes |  |
| `cursor` | string | yes | Cursor of the last event about this change. |
| `description` | string | yes |  |
| `head` | string | yes | The current revision's head commit. |
| `id` | string | yes |  |
| `landing` | [RuleVerdict] | no | What each landing rule for the change's target says about it now: whether it lands on a green check, and exactly what stands in the way. Empty: no rule applies, or the change is closed. |
| `mergeability` | Mergeability | yes |  |
| `number` | integer | no | Per-repository number, from 1, never reused; `{change}` in a path accepts it as well as the id. |
| `on_behalf_of` | string \| null | no | On whose behalf the author acts. |
| `overlapping_claims` | [Claim] | yes | Active claims that overlap this change's paths and are held by someone else. |
| `parent_change` | string \| null | no |  |
| `paths` | [string] | yes | Changed paths of the current revision (bounded: the first 200; `stat.files` is the true count). |
| `queue` | QueueEntry \| null | no |  |
| `repo` | string | yes |  |
| `reviews` | [Review] | yes |  |
| `revisions` | [Revision] | yes | Every revision, oldest first (bounded: the latest 50). |
| `stat` | DiffStat | yes | Diff stat of the current revision against its base. |
| `state` | ChangeState | yes |  |
| `title` | string | yes |  |
| `updated_ms` | integer | yes |  |

### Check

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `head` | string \| null | no | The head the reporter said it checked (always the revision's). Absent: the report named none, and no landing rule counts it. |
| `name` | string | yes |  |
| `revision` | integer | yes | The revision the check ran against. |
| `run_seq` | integer | no | The run this result is from (0: the reporter numbers no runs). |
| `state` | CheckState | yes |  |
| `summary` | string | yes |  |
| `updated_ms` | integer | yes |  |

### CheckState

One of: `"pending"` \| `"running"` \| `"passed"` \| `"failed"` \| `"skipped"`

### Claim

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `created_ms` | integer | yes |  |
| `expires_ms` | integer | yes |  |
| `holder` | string | yes |  |
| `id` | string | yes |  |
| `note` | string | yes |  |
| `on_behalf_of` | string \| null | no |  |
| `paths` | [string] | yes |  |
| `repo` | string | yes |  |
| `task` | string \| null | no |  |

### Commit

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `author` | Signature | yes |  |
| `committer` | Signature | yes |  |
| `message` | string | yes | The whole message, at most 64 KiB. |
| `oid` | string | yes |  |
| `parents` | [string] | yes |  |
| `subject` | string | yes | First line of the message. |
| `tree` | string | yes |  |

### CommitFiles

`POST /v1/repos/{repo}/commits`: one commit on top of `base` with these files written or deleted, and `branch` set to it.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `base` | string \| null | no | The new commit's parent: a revision. Default: the default branch's head. |
| `branch` | string | yes | The branch to set: a short name (`work/x`) or a full name under `refs/heads/`. Created if absent, moved if present, whatever it pointed at before (see `expect`). |
| `expect` | string \| null | no | Absent: set the branch whatever it points at. A commit id: the branch must point at exactly that commit now. `null`: the branch must not exist yet. Otherwise `precondition_failed` with `details.current`. |
| `files` | [FileWrite] | yes | At most 1000 entries, each path at most once. |
| `message` | string | yes | The commit message. A final newline is added when missing, as git does. |

### Committed

What `POST /v1/repos/{repo}/commits` made.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `branch` | string | yes | The branch's full name, now pointing at `commit`. |
| `commit` | string | yes | The new commit. |
| `created` | boolean | yes | True when the branch did not exist before. |
| `parent` | string | yes | Its parent: `base`, resolved. |
| `previous` | string \| null | no | What the branch pointed at before; null when it was created. |
| `tree` | string | yes | Its root tree. |

### CreateChange

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `base` | string \| null | no | The branch this change targets; defaults to the repository's default branch. |
| `description` | string | no |  |
| `head` | string | yes | The commit (or ref) at the top of the stack being proposed. |
| `parent_change` | string \| null | no | The change this one is stacked on, if any. |
| `title` | string | yes |  |

### CreateClaim

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `note` | string | no |  |
| `paths` | [string] | no | Path prefixes being worked on, for example `crates/jit-api/`. |
| `task` | string \| null | no | A task id, free text: "issue 12", "fix flaky test x". |
| `ttl_ms` | integer \| null | no | Lease length. Default 15 minutes, max 24 hours. The claim disappears when it expires. |

### CreateFeedback

`POST /v1/feedback`.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `cli_version` | string \| null | no | The sender's CLI version, at most 64 bytes. |
| `diagnostics` | FeedbackDiagnostics \| null | no |  |
| `text` | string | yes | 1 to 8192 bytes of UTF-8. |

### CreateRepo

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `default_branch` | string \| null | no | Defaults to `main`. |
| `description` | string | no |  |
| `name` | string | yes | `[a-z0-9][a-z0-9._-]{0,63}`, unique on this instance. A label: the identity is `id`. Not `u`, not starting with `u-` (an account's handle), and not one of the reserved words (decision 0083). |
| `public` | boolean \| null | no | Public repositories can be read and mirrored without a token. Absent means true. `false` needs an instance admin (the instance-wide `admin` right); anyone else gets `403 private_repos_disabled`. |

### Diff

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `base` | string | yes |  |
| `files` | [FileDiff] | yes | Per-file stats are always complete up to 5000 files; patches are bounded by `max_bytes`. |
| `head` | string | yes |  |
| `stat` | DiffStat | yes |  |
| `truncated` | boolean | yes | True when any patch was cut or the file list was capped. |

### DiffStat

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `additions` | integer | yes |  |
| `deletions` | integer | yes |  |
| `files` | integer | yes |  |

### Encoding

One of: `"utf8"` \| `"base64"`

### EndSession

`POST /v1/session/end`. An empty body ends this session.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `everywhere` | boolean \| null | no | End every session of the account ("sign out everywhere"). |

### EndpointBrief

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `budget_p50_ms` | integer | yes |  |
| `budget_p99_ms` | integer | yes |  |
| `method` | string | yes |  |
| `path` | string | yes |  |
| `scope` | Scope \| null | no |  |
| `summary` | string | yes |  |

### EntryKind

One of: `"file"` \| `"dir"` \| `"symlink"` \| `"submodule"`

### ErrorCode

Stable machine-readable error codes. The HTTP status follows the code.

One of: `"bad_request"` \| `"unknown_field"` \| `"unauthorized"` \| `"forbidden"` \| `"not_found"` \| `"conflict"` \| `"precondition_failed"` \| `"too_large"` \| `"rate_limited"` \| `"unavailable"` \| `"internal"` \| `"private_repos_disabled"` \| `"withheld"` \| `"sign_in_again"` \| `"signup_closed"` \| `"suspended"` \| `"signups_exhausted"` \| `"keys_stale"` \| `"session_required"` \| `"fresh_login_required"` \| `"no_such_code"` \| `"no_such_pairing"` \| `"key_limit"` \| `"bad_key"` \| `"repository_limit"` \| `"pairings_exhausted"`

### Event

One entry of a repository's ordered event log.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `actor` | string | yes |  |
| `cursor` | string | yes | Position in the stream it was read from; resume with it. |
| `data` | any | yes | Type-specific fields; always an object. |
| `on_behalf_of` | string \| null | no |  |
| `repo` | string | yes |  |
| `time_ms` | integer | yes |  |
| `type` | string | yes | `repo.created`, `ref.updated`, `change.created`, `change.revised`, `change.state`, `check.updated`, `review.created`, `claim.created`, `claim.renewed`, `claim.released`, `claim.expired`, `queue.updated`. |

### EventPage

The JSON form of the event stream (`wait_ms` given, or `Accept: application/json`).

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `cursor` | string | yes | Pass this as `cursor` next time. Equal to the request's cursor when nothing happened. |
| `events` | [Event] | yes |  |
| `truncated` | boolean | yes | True when more events were already available than `limit`. |

### FeedbackDeleted

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `deleted` | boolean | yes |  |
| `id` | string | yes |  |

### FeedbackDiagnostics

What the sender chose to add about its machine and last command. Each field is one it was shown before sending.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `arch` | string \| null | no |  |
| `last_command` | string \| null | no | The name of the last command, not its arguments. |
| `last_exit` | integer \| null | no |  |
| `os` | string \| null | no |  |
| `repo` | string \| null | no | A repository's name, if the sender named one. |

### FeedbackItem

One item, as an instance administrator reads it.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `change` | string \| null | no |  |
| `cli_version` | string \| null | no |  |
| `created_ms` | integer | yes |  |
| `diagnostics` | FeedbackDiagnostics \| null | no |  |
| `id` | string | yes |  |
| `kind` | FeedbackKind \| null | no |  |
| `principal` | string \| null | no | The principal of the token it was sent with; null when sent without one. |
| `reply` | string \| null | no |  |
| `server_version` | string | yes | The version of the server that stored it. |
| `state` | FeedbackState | yes |  |
| `text` | string | yes | As sent: any UTF-8, control characters included. Escape it before showing it. |
| `updated_ms` | integer | yes |  |

### FeedbackKind

One of: `"bug"` \| `"idea"` \| `"question"` \| `"duplicate"` \| `"not_planned"`

### FeedbackReceipt

What `POST /v1/feedback` stored. Keep `id`: it is the only way to read the item's status.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `created_ms` | integer | yes |  |
| `id` | string | yes | `fb_` and 32 hex digits. |
| `state` | FeedbackState | yes |  |

### FeedbackState

One of: `"received"` \| `"triaged"`

### FeedbackStatus

What became of an item: all its sender is told.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `change` | string \| null | no | A reference to the change that came of it. |
| `created_ms` | integer | yes |  |
| `id` | string | yes |  |
| `kind` | FeedbackKind \| null | no | Null until someone says what it is. |
| `reply` | string \| null | no | One line for the sender. |
| `state` | FeedbackState | yes |  |
| `updated_ms` | integer | yes |  |

### FileContent

One file of a `Files` answer.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `content` | string | yes | The whole file; empty when `truncated`. |
| `encoding` | Encoding | yes |  |
| `oid` | string | yes |  |
| `path` | string | yes |  |
| `size` | integer | yes | Size of the whole file in bytes. |
| `truncated` | boolean | yes | True when the file did not fit in `max_bytes`: read it with `blob` (and `range`). |

### FileDiff

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `additions` | integer | yes |  |
| `binary` | boolean | yes |  |
| `deletions` | integer | yes |  |
| `old_path` | string \| null | no |  |
| `patch` | string \| null | no | Unified diff of this file; null when not requested, binary, or cut by `max_bytes` (then `truncated`). |
| `path` | string | yes |  |
| `status` | FileStatus | yes |  |
| `truncated` | boolean | yes |  |

### FileStatus

One of: `"added"` \| `"modified"` \| `"deleted"` \| `"renamed"`

### FileWrite

One file to write or delete in `POST /v1/repos/{repo}/commits`. Give `content`, or `delete: true`.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `content` | string \| null | no | The whole new content of the file, in `encoding`. |
| `delete` | boolean \| null | no | True: delete the file (it must exist); a directory left empty disappears. Not together with `content`. |
| `encoding` | Encoding \| null | no | How `content` is written: `utf8` (the default) or `base64` (any bytes). |
| `path` | string | yes | Path from the repository root, `/`-separated: no leading slash, no empty, `.`, `..` or `.git` segment, no backslash or NUL. Directories are created as needed. |

### Files

A directory with the files below it and their content.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `commit` | string | yes | The commit the directory was read at (resolved from `rev`): send it back as `known` next time. |
| `files` | [FileContent] | yes | Recursively, in path order. |
| `next` | string \| null | no | Pass as `after` to continue a listing that was cut. |
| `path` | string | yes |  |
| `tree` | string | yes | The id of the directory itself at `commit`: also accepted as `known`. |
| `truncated` | boolean | yes |  |
| `unchanged` | boolean | yes | True when the directory is the tree `known` names, or the same in the commit it names: then `files` is empty. |

### GrantInfo

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `principal` | string | yes |  |
| `repo` | string \| null | no | The repository the grant is on; null for an instance-wide grant. |
| `scopes` | [Scope] | yes |  |

### Health

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `backend` | string | yes | `mem` (in-memory stub) or `real`. |
| `status` | string | yes |  |
| `time_ms` | integer | yes |  |
| `uptime_ms` | integer | yes |  |
| `version` | string | yes |  |

### Index

`GET /v1`: what this service is and where to read more.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `api` | string | yes |  |
| `endpoints` | [EndpointBrief] | yes |  |
| `events` | string | yes |  |
| `guide` | string | yes |  |
| `openapi` | string | yes |  |
| `service` | string | yes |  |
| `version` | string | yes |  |

### KeyRemoved

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `removed` | boolean | yes | Always `true`. |

### LandingRule

"A change to `target` whose changed paths are exactly `paths` lands by itself, squashed under `title`, when `check` is green on its latest revision as reported by `reporter`."

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `allow_executable` | boolean | no | Optional: let an executable file (mode 100755) at a listed path land. Default false: only plain files (mode 100644) do, and an executable is refused as `not_a_plain_file`. Symbolic links and submodules never land by rule. |
| `check` | string | yes | The check that must have passed on the change's latest revision. |
| `delete_branch` | boolean | no | Optional: delete the change's head branch when the rule lands it (if it still points at the landed head). Default false: the branch is left. |
| `head_branch` | string \| null | no | Optional: the head branch the change must have been pushed by, a short name that may contain `{name}` once, e.g. `prover/{name}` (the same name its paths give). Absent: any branch, or none. |
| `name` | string | yes | Unique in the repository; it is in the events. |
| `paths` | [RulePath] | yes | The exact set of changed paths: each with its status, nothing else. No globs. |
| `protect_target` | boolean | no | The rule's target branch moves only by a landing or by an admin of the repository: a push or a commit to it from anyone else is `forbidden` (message starting `protected_branch:`); push a branch and open a change instead. Default true. False leaves the target as open as any other branch. |
| `queue` | QueueOptions \| null | no | Optional: changes that fit this rule need not sit on the target's tip. They wait in the target's queue, the server builds for each the commit that would land on top of the ones ahead (a candidate), the rule's reporter checks candidates (`queue.candidates`, `queue.report`) and a passing candidate lands in order as exactly that commit. Absent: a change lands only while it is built on the tip. |
| `reporter` | string | yes | The only principal whose report of that check counts, and the only one allowed to report it (`jp_…`). |
| `target` | string | yes | The branch changes must target, e.g. `main` (stored as `refs/heads/main`). |
| `title` | string | yes | The squash commit's title; may use `{name}`, `{change}` and `{number}`. |

### LandingRules

A repository's landing rules: the body of `PUT …/landing-rules` and the answer of all three calls.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `rules` | [LandingRule] | yes |  |

### Limits

The bucket that binds first for this caller. A request with a token is charged, all or nothing, to the token's own bucket and to its authenticated principal's, shared by all its tokens and 16 times larger (a server constant); this reports whichever has fewer requests left. Without a token, or with one that does not authenticate: the client address's bucket (or, while the server holds too many addresses, the shared shard a new address is charged to). There are no other limits.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `cost` | integer | yes | What this request cost. |
| `limit` | integer | yes | Bucket capacity: the largest burst. |
| `remaining` | integer | yes | Requests that can be made right now. |
| `reset_ms` | integer | yes | Milliseconds until the bucket is full again. |
| `streams` | StreamLimits | yes |  |
| `window_ms` | integer | yes | The bucket refills `limit` requests per `window_ms`, continuously. |

### LogConsistency

That the log of `new` entries extends the log of `old` entries without changing any of them: the consistency proof of RFC 9162 (section 2.1.4). Keep the checkpoint you verified (its `size` and `root`); next time ask for `old=<kept size>&new=<the size of a new signed head>` and check `jit_trust::verify_consistency(old_root, new_root, &ConsistencyProof { old_size: old, new_size: new, path })` against the new head's `root`: the log only grew. A new head smaller than the kept size, or a proof that does not verify, means the log was rewritten. `old == new` and `old == 0` answer an empty path (nothing to prove: the roots must be equal, or the old one the empty tree's).

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `new` | integer | yes | jit-trust's `new_size`. |
| `old` | integer | yes | jit-trust's `old_size`. |
| `path` | [string] | yes | The hashes, 64 lower-case hex digits each, in the order `verify_consistency` reads them. |

### LogEntry

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `actor` | string | yes |  |
| `kind` | string | yes | `genesis`, `ref_update`, `record`, `set_signer`, `withheld`, `restored`, or `runner_token` (a runner token was minted: `actor` is the administrator who asked) or `token_revoked` (`actor` revoked it). |
| `on_behalf_of` | string \| null | no |  |
| `prev` | string | yes | Hash of the previous entry, hex. |
| `raw` | string \| null | no | The canonical signed bytes, base64, for clients that verify. |
| `refs` | [RefMove] | yes | Ref movements of a `ref_update` entry. |
| `revocation_id` | string \| null | no | On a `runner_token` or `token_revoked` entry: the revocation id of the token minted or revoked. |
| `seq` | integer | yes |  |
| `signature` | string | yes |  |
| `signer` | string | yes |  |
| `time_ms` | integer | yes |  |
| `token_id` | string \| null | no |  |
| `withheld` | WithheldInfo \| null | no | On a `withheld` entry: what this host stopped serving, why, and the reference; on a `restored` entry: the sequence number of the `withheld` entry it lifts. Absent on every other kind. |

### LogHead

The signed head of a repository's append-only ref log (`jit-trust`'s checkpoint).

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `repo` | string | yes |  |
| `root` | string | yes | Merkle root over the first `size` entries, hex. |
| `signature` | string | yes |  |
| `signer` | string | yes |  |
| `size` | integer | yes |  |
| `time_ms` | integer | yes |  |

### LogProof

That the entry at `seq` is in the log of `size` entries: the audit path of RFC 9162 (section 2.1.3), from the leaf up. Verify: decode the entry's `raw` bytes (`GET …/reflog?raw=true`), its leaf is `SignedEntry::from_bytes(raw)?.leaf_hash()` (RFC 9162's leaf hash of those bytes), then `jit_trust::verify_inclusion(leaf, &InclusionProof { seq, size, path }, root)` with the `root` of a signed checkpoint of this `size` (`GET …/reflog/head`: pass its `size`).

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `path` | [string] | yes | The sibling hashes, 64 lower-case hex digits each (the form of `LogHead.root`), about log2(size) of them. |
| `seq` | integer | yes |  |
| `size` | integer | yes | The tree size the path is for. |

### LoginStarted

`POST /v1/session/start`: a login in flight, for 10 minutes.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `expires_ms` | integer | yes |  |
| `nonce` | string | yes | 64 hex digits: the front end keeps it in the browser's `__Host-neo_login` cookie. |
| `state` | string | yes | 64 hex digits: sent to the login page, which sends it back with Privy's tokens. |

### LookupPairing

`POST /v1/pairings/lookup`: the code is in the body, never in a URL.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `code` | string | yes |  |

### MergeState

One of: `"clean"` \| `"conflicted"` \| `"unknown"`

### Mergeability

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `behind` | integer | yes | How many commits the base has gained since this revision's merge base. |
| `conflicts` | [string] | yes | Paths that conflict with the base, when `state` is `conflicted`. |
| `state` | MergeState | yes |  |

### Meta

Present in every answer.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `limits` | Limits | yes | The caller's limits after this request. |
| `request_id` | string | yes | Echo this when reporting a problem. |
| `took_us` | integer | yes | Server-side time spent on the request, microseconds. |

### MintRunnerToken

`POST /v1/repos/{repo}/tokens`: a token for a runner on this one repository.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `consent` | string | yes | The principal's own agreement: its key's signature (128 hex digits) over this repository's id, this host's log signing key (both in `GET …/reflog/head`: `repo`, `signer`) and `consent_ms` (`jit_trust::RunnerConsent`; `jit-runner setup` makes it). Without it an administrator could be issued a token that acts as anyone; with the host in it, one host's cannot be used at another. |
| `consent_ms` | integer | yes | When `consent` was signed, Unix milliseconds. Accepted for one hour. |
| `principal` | string | yes | The runner's own principal (`jp_…`), already registered. Give a runner a principal of its own: a landing rule names it as the only reporter whose check counts. |
| `scopes` | array \| null | no | What the token may do: `read` always, and of `change_write` and `push` what is listed. Default `["read", "change_write"]`: enough to read the repository and report a check, and **not push**. Ask for `push` only for a runner that commits; never for one that reports the check of a landing rule, because the command it runs is code from the changes it checks. |
| `ttl_ms` | integer \| null | no | How long the token lasts, in milliseconds. Default 24 hours; at most 30 days. |

### PairingApproved

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `key` | AccountKey | yes |  |

### PairingBegun

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `code` | string | yes | `XXXX-XXXX` (Crockford's base 32): typed on the account page. Never put it in a link. |
| `expires_ms` | integer | yes |  |
| `instance_key` | string | yes | The instance's key, 64 hex digits: what the machine's polls are signed for. |
| `origin` | string | yes | This instance's origin (`JIT_PUBLIC_URL`, normalized: `scheme://host[:port]`). The machine compares it with the origin it dialed before it shows the code, and stops on a mismatch; it never signs this one. |
| `page` | string \| null | no | Where to type the code (`<JIT_WEB_URL>/pair`), or `null`: then `<JIT_URL>/pair`. |
| `pairing` | string | yes | 32 hex digits: what the machine polls (`GET /v1/pairings/{pairing}`). |

### PairingFound

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `expires_ms` | integer | yes |  |
| `fingerprint` | string | yes | 16 hex digits: the first 8 bytes of SHA-256 of the machine's key. |
| `name` | string | yes | The name the machine gave. |
| `started_from` | string | yes | The client address the pairing was started from, as the per-address limits key it (an IPv4 address, an IPv6 /64). Kept only with the pairing; shown only here, to the session that typed the code. |
| `started_ms` | integer | yes |  |

### PairingState

One of: `"pending"` \| `"approved"`

### PairingStatus

`GET /v1/pairings/{pairing}`.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `account` | string \| null | no | Once approved: the account (`jp_…`). |
| `handle` | string \| null | no | Once approved: the account's handle. |
| `status` | PairingState | yes |  |

### PathChange

How a landing rule expects one of its paths to have changed.

One of: `"added"` \| `"modified"` \| `"deleted"`

### PathMerge

How a landing rule's queue merges a path.

One of: `"union"`

### PrincipalInfo

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `created_ms` | integer | yes |  |
| `id` | string | yes |  |
| `kind` | PrincipalKind | yes |  |
| `name` | string | yes |  |

### PrincipalKind

One of: `"person"` \| `"org"`

### Queue

One target's queue. At most 200 entries, 200 waiting changes and 64 candidates are listed; `truncated` says when there are more.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `candidates` | [Candidate] | yes | Front first. |
| `entries` | [QueuedChange] | yes | In landing order. |
| `target` | string | yes |  |
| `tip` | string \| null | no |  |
| `truncated` | boolean | yes |  |
| `waiting` | [string] | yes | Changes that fit the rule and wait for one of their owner's places, in order. |

### QueueEjected

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `change` | string | yes |  |
| `reason` | any | yes | `{reason, ...}`: `checks_failed {batch, summary}`, `merge_conflict {paths}`, `not_as_the_rule {rule, paths}`, `superseded`, `dequeued`, `abandoned`, `parent_not_landed {parent}`. |

### QueueEntry

A change's own place in a queue, on its summary (`ChangeSummary.queue`). The whole queue of a target, with every change in it, is `Queue` (`queue.get`), whose entries are `QueuedChange`.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `batch` | string \| null | no |  |
| `enqueued_ms` | integer | yes |  |
| `position` | integer | yes |  |

### QueueOptions

How a landing rule's queue runs.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `depth` | integer | no | Candidates that exist at once, each built on the one ahead: 1 to 16, default 4. 1 is a serial queue (nothing is ever checked twice); more lets a reporter that runs several checks at once land that many per check duration, and a failure costs a re-check of those behind it. |
| `max_per_owner` | integer | no | Changes of one owner in the queue at once: 1 to 64, default 2. Its others wait their turn behind everyone already in line. |

### QueuedChange

A change in a landing rule's queue (`queue.get`): where it stands and which candidate is built for it. Not `QueueEntry`, which is the same change's place as its own summary shows it (`ChangeSummary.queue`).

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `author` | string | yes |  |
| `candidate` | string \| null | no | The candidate built for it, if one is. |
| `change` | string | yes |  |
| `head` | string | yes |  |
| `number` | integer | yes |  |
| `position` | integer | yes | 0 is the front. |
| `revision` | integer | yes |  |

### Ref

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `name` | string | yes | Full name, for example `refs/heads/main`. |
| `oid` | string | yes |  |

### RefMove

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `name` | string | yes |  |
| `new` | string \| null | no | Null when the ref was deleted. |
| `old` | string \| null | no | Null when the ref was created. |

### RegisterPrincipal

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `id` | string | yes | The principal's identity: its public key in text form, `jp_` followed by 64 hex digits. |
| `kind` | PrincipalKind \| null | no | Defaults to `person`. |
| `name` | string | yes | A label; it can differ between instances. |

### RenewClaim

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `ttl_ms` | integer \| null | no |  |

### Repo

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `clone_url` | string | yes |  |
| `created_by` | string | yes |  |
| `created_ms` | integer | yes |  |
| `cursor` | string | yes | Cursor of the newest event; pass it to `sync` or `events` to hear only what comes after. |
| `default_branch` | string | yes |  |
| `description` | string | yes |  |
| `head` | string \| null | no | Commit the default branch points at; null while the repository is empty. |
| `id` | string | yes | The repository's identity (its key); survives renames and hosts. |
| `log_size` | integer | yes | Number of entries in the signed ref log. |
| `name` | string | yes |  |
| `public` | boolean | yes |  |

### RepoSync

`GET …/sync?since=`: what changed in a repository since a cursor, already folded into state.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `changes` | [ChangeBrief] | yes | Changes created or touched in the interval, in their current state. |
| `claims` | [Claim] | yes | Claims active now. |
| `cursor` | string | yes | Pass as `since` next time. |
| `events` | integer | yes | Number of events folded into this answer. |
| `refs` | [RefMove] | yes | Net movement of each ref over the interval (one entry per ref, however many times it moved). |
| `since` | string | yes |  |
| `truncated` | boolean | yes | True when the interval held more than the server folds at once; call again with `cursor`. |

### ReportCandidate

A reporter's word on a candidate.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `head` | string | yes | The commit that was checked. Required: `precondition_failed` unless it is the candidate's commit. |
| `log` | string \| null | no | The check's output, at most 256 KiB; its last 64 KiB are kept on the change's revision. |
| `name` | string | yes | The rule's check. |
| `run_seq` | integer \| null | no | The run, as in `checks.report`: a lower one than the server holds is `conflict` with `details.reason` `stale_run`; a different verdict for a finished run is `run_finished`. |
| `state` | CheckState | yes |  |
| `summary` | string | no |  |

### ReportCheck

A check result on a revision of a change. A second report of the same name on the same revision replaces the first.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `head` | string \| null | no | The commit the check ran on. `precondition_failed` (with `details.head`, the revision's head) unless it is that revision's head. A landing rule counts a `passed` check only if its report named the head. |
| `log` | string \| null | no | The check's output as text, at most 256 KiB. |
| `name` | string | yes | The check's name, e.g. `test`. |
| `revision` | integer \| null | no | The revision checked. Default: the latest. |
| `run_seq` | integer \| null | no | Which run of the check this is: the same number for a run's `running` and its verdict, a higher one for a later run (the time the run started, in milliseconds, serves). Absent is run 0. Per (change, revision, name) the server keeps the highest: a report of a lower run is `conflict` with `details.reason` `stale_run`; for a check a landing rule or the queue names, a different verdict for a run that already has one is `conflict` with `details.reason` `run_finished` (the same verdict again is accepted). `details.run_seq` is the run the server holds. A reporter that never sends it reports one run per revision: its first verdict stands. |
| `state` | CheckState | yes |  |
| `summary` | string | no |  |

### Restore

Lift a withholding.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `seq` | integer | yes | The sequence number of the `withheld` entry (`seq` in the answer of `withhold`, or of that entry in `GET …/reflog`). |

### Review

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `by` | string | yes |  |
| `created_ms` | integer | yes |  |
| `id` | string | yes |  |
| `open_comments` | integer | yes | Comments not yet resolved; each may carry a patch that applies in one call. |
| `revision` | integer | yes |  |
| `summary` | string | yes |  |
| `verdict` | ReviewVerdict | yes |  |

### ReviewVerdict

One of: `"approve"` \| `"request_changes"` \| `"comment"`

### Revision

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `base` | string | yes |  |
| `created_by` | string | yes |  |
| `created_ms` | integer | yes |  |
| `head` | string | yes |  |
| `note` | string | yes |  |
| `number` | integer | yes |  |

### RevokeAnyToken

`POST /v1/tokens/revoke`: no body (or `{}`) revokes the token this request carries; with `revocation_id`, an instance administrator revokes any token by the id of one of its blocks.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `revocation_id` | string \| null | no | Which token: the revocation id of one of its blocks (64 hex digits). Without `unseen`, it must be an id this instance knows (one already revoked, a runner token's, or a block of a token presented since the server started): any other is `bad_request`, since it would stop no token. Absent: the token this request carries. |
| `unseen` | boolean \| null | no | `true`: revoke `revocation_id` although this instance has never seen it, on the administrator's word (a token that leaked and was never presented here, or not since a restart). Instance administrators only (`admin` on the instance, through a token not narrowed below it: what "instance root" means here). It is explicit and never a fallback: a wrong id sent as unseen is recorded as revoked and stops nothing. Only with `revocation_id`; `false` is the same as leaving it out. |

### RevokeToken

`POST /v1/repos/{repo}/tokens/revoke`: a runner token of that repository.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `revocation_id` | string \| null | no | Which token: the revocation id of one of its blocks (64 hex digits), from a runner token's answer or its mint entry in the signed log. Required. |

### RulePath

One path a landing rule lists.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `merge` | PathMerge \| null | no | Optional: `union` merges this path by line union in the rule's queue (decision 0078): a change may only add lines, and they go after what landed, without the ones already there. Only on a `modified` path without `{name}`, in a rule with `queue`. Absent: the ordinary merge. |
| `path` | string | yes | From the repository root; may contain `{name}` once (one identifier, shared by every path that uses it). |
| `status` | PathChange | yes |  |

### RuleVerdict

What one landing rule says about a change now.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `lands` | boolean | yes | True when nothing stands in the way: the next passing report of the rule's check lands the change. |
| `refusals` | [any] | yes | What stands in the way, one object each: `reason` plus its fields. `check_missing {check}`, `check_not_passed {check, status, conclusion?}`, `wrong_reporter {check, reporter, wanted}`, `unexpected_paths {paths}`, `missing_paths {paths}`, `head_branch {branch, wanted}`, `behind_target`, `bad_name`, `stacked`, `not_open`, `conflict {paths}`, `check_not_pinned {check}` (its report named no head), `queued {position?, candidate?}` (the rule has a queue and the change is in line: nothing to do but wait), `ejected {why}` (the queue put this revision out; `why` as in `queue.report`), `withheld {reference}` (this host withholds the change's head branch or its target: no rule lands it while that stands), `not_a_plain_file {entries: [{path, kind}]}` (kind: `executable`, `symlink`, `submodule`, `other`). |
| `rule` | string | yes |  |
| `warnings` | [any] | no | What stands in nobody's way but should be known, one object each: `union_path_filling {path, bytes}` (the union-merged file was past three quarters of its bound at the push: an administrator should rotate or compact it; decision 0086). Never counted as a refusal. |

### RunnerToken

A runner's token, answered once and never stored: keep it in a file only the runner can read. Its `Debug` leaves the token out, so a log line or a failed assertion cannot carry it.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `not_after_ms` | integer | yes |  |
| `principal` | string | yes |  |
| `repo` | string | yes | The repository's id (`jr_…`). |
| `revocation_id` | string | no | What revokes it: `POST /v1/repos/{repo}/tokens/revoke` with this id (or `POST /v1/tokens/revoke` carrying the token itself). It and everything narrowed from it stop; the token it was narrowed from goes on. Not a secret; it is also in the signed log's entry of this mint. Empty from a server older than revocation by id. |
| `scopes` | [Scope] | yes | What it may do: `read` and `change_write` unless `push` was asked for. Nothing else, ever. |
| `token` | string | yes | The bearer token (`jt_…`). It works on this repository only, for `scopes` only. |
| `token_id` | string | yes | Its id, as it appears in the signed ref log on every write made with it. |

### Scope

What a token may do. Mirrors `jit-trust`'s operations.

One of: `"read"` \| `"push"` \| `"change_write"` \| `"review"` \| `"claim"` \| `"merge"` \| `"admin"`

### SessionEnded

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `ended` | boolean | yes | Always `true`. |

### SessionExchange

`POST /v1/session/exchange`. Its `Debug` shows no value: every field is a credential or binds one.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `access_token` | string | yes | Privy's access token. |
| `identity_token` | string | yes | Privy's identity token (of the same person: the subjects must match). |
| `nonce` | string | yes | The login's nonce, from the browser's cookie. |
| `state` | string | yes | From `POST /v1/session/start`. |

### SessionExchanged

A session (8 hours) for the account.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `account` | AccountBrief | yes |  |
| `created` | boolean | yes | The account was made by this exchange. |
| `expires_ms` | integer | yes |  |
| `fresh_until_ms` | integer | yes | Until when the login counts as fresh (approving a key needs that): ten minutes after Google last verified the person, never after `expires_ms`; may be in the past. |
| `session` | string | yes | The session token. Shown once; the front end keeps it in the browser's `__Host-neo_session` cookie. |

### SetFeedback

`PATCH /v1/admin/feedback/{id}`. A field left out is left as it is; `null` clears it (not `state`).

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `change` | string \| null | no | A reference to the change that came of it: one line, at most 200 bytes. |
| `kind` | FeedbackKind \| null | no |  |
| `reply` | string \| null | no | One line for the sender, at most 512 bytes. |
| `state` | FeedbackState \| null | no | A kind makes the item triaged unless `state` says otherwise; `received` with a kind is refused. |

### SetGrant

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `scopes` | [Scope] | yes | What the principal may do in this scope from now on. An empty list removes the grant. |

### Signature

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `email` | string | yes |  |
| `name` | string | yes |  |
| `time_ms` | integer | yes |  |

### StreamLimits

Concurrent event streams: the token's or its principal's count, whichever has fewer slots left.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `limit` | integer | yes |  |
| `open` | integer | yes |  |

### SuspendAccount

`POST /v1/admin/accounts/{account}/suspend`.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `reason` | SuspendReason | yes |  |
| `reference` | string \| null | no | What the administrator can follow up on (a case or ticket number). At most 512 bytes, no control characters. It goes to the server's log line only: it is not stored and never answered. |

### SuspendReason

Why an instance administrator suspended an account: jit-trust's `ReasonCode`, nothing else.

One of: `"abuse"` \| `"spam"` \| `"legal"` \| `"security"` \| `"owner_request"`

### TokenRevoked

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `logged_in` | string \| null | no | The repository whose signed log carries the entry: a runner token's own revocation is written in its repository's log. Null for everything else (a token of no repository, and a token narrowed from a runner's revoking itself: those are in the revocation table only). |
| `newly` | boolean | yes | False when it was revoked already: nothing changed and nothing was written. |
| `revocation_id` | string | yes |  |
| `unseen` | boolean \| null | no | `true` when the request said `"unseen": true`; absent otherwise. |

### Tree

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `commit` | string | yes | The commit the tree was read at (resolved from the `rev` in the request). |
| `entries` | Listed5 | yes |  |
| `path` | string | yes |  |

### TreeEntry

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `kind` | EntryKind | yes |  |
| `mode` | integer | yes |  |
| `name` | string | yes |  |
| `oid` | string | yes |  |
| `path` | string | yes |  |
| `size` | integer \| null | no | Bytes; null for directories and submodules. |

### UpsertChange

`PUT /v1/repos/{repo}/changes/for/{branch}`: make sure an open change proposes this branch.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `base` | string \| null | no | The branch a new change targets. Default: the default branch. Ignored for an existing change. |
| `description` | string \| null | no | Used only when a change is opened; an existing change keeps its description. |
| `title` | string | yes | Used only when a change is opened; an existing change keeps its title. |

### Upserted

The open change for a branch, and what the call did to get it.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `change` | ChangeSummary | yes | The change, as `changes.get` answers it. |
| `created` | boolean | yes | True when the change was opened by this call. |
| `revised` | boolean | yes | True when this call added a revision (the branch had moved since the change's latest revision). |

### WhoAmI

`GET /v1/whoami`.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `anonymous` | boolean | yes |  |
| `expires_ms` | integer \| null | no |  |
| `on_behalf_of` | string \| null | no | Whose authority the principal acts under, when it is not its own. |
| `principal` | string | yes | The authenticated principal: who every write is attributed to. `anonymous` without a token. |
| `scopes` | [Scope] | yes |  |
| `token_id` | string \| null | no |  |
| `via` | string \| null | no | The sub-agent the token names as its holder, if any. A label for display, not proven and not an identity: everything is attributed to `principal`. |

### WithheldInfo

The withholding a `withheld` or `restored` log entry is about.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `reason` | WithheldReason \| null | no | `withheld` entries only. |
| `reference` | string \| null | no | `withheld` entries only; may be empty. |
| `scope` | WithheldScopeInfo \| null | no | `withheld` entries only. |
| `seq` | integer | yes | The sequence number of the `withheld` entry: on a `withheld` entry its own, on a `restored` entry the one it lifts. This is what `POST …/restore` takes. |

### WithheldKind

What a withholding covers.

One of: `"repository"` \| `"refs"` \| `"record"`

### WithheldReason

Why a host withholds content, as a class; the particulars go in `reference`.

One of: `"legal"` \| `"policy"` \| `"security"` \| `"owner"`

### WithheldScopeInfo

A withholding's scope as the log states it.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `id` | string \| null | no | `record`: the record's id when it is text (as jit-collab's ids are). |
| `id_hex` | string \| null | no | `record`: the record's id in lowercase hex when it is not text (then `id` is absent). |
| `kind` | WithheldKind | yes |  |
| `patterns` | array \| null | no | `refs`: the patterns (exact, or a prefix ending in `*`). |
| `record` | string \| null | no | `record`: the record's kind. |

### Withhold

Take part of a repository down at this host (instance administrators only). What each scope covers, and does not: `WithholdScope`.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `include_queue` | boolean \| null | no | A `refs` pattern that covers `refs/queue` or anything under `refs/queue/` (the merge queue's candidate pins, e.g. `refs/*` or `refs/queue/*`) is refused unless this is `true`: withholding them stops the queue from serving its candidates. Only for a `refs` scope. Default false. |
| `reason` | WithheldReason | yes |  |
| `reference` | string \| null | no | What a reader can follow up on: a case or notice number, a URL, a policy section. At most 1024 bytes, no control characters. It is public: it is in the signed log, which anyone who may read the repository reads. Default empty. |
| `scope` | WithholdScope | yes |  |

### WithholdScope

The scope of a `POST /v1/repos/{repo}/withhold`: `kind` and the fields of that kind only (any other field is refused). `{"kind":"repository"}` covers every ref's content and every record: API reads of the repository answer `451 withheld` and clone and fetch serve nothing; what stays readable is the repository's record, its signed log and `GET …/withholdings`. `{"kind":"refs","patterns":["refs/heads/leak","refs/heads/topic/*"]}` covers the refs whose NAMES match and the content only they reach. It does NOT cover content that another served ref, a change's `refs/changes/…` pin or a queue pin also reaches: that stays served, by that ref and by id (decision 0070); cover those refs too, or withhold the repository. Ref names stay listed (they are in the signed log). `{"kind":"record","record":"revision","id":"<change id>/2"}` covers one record jit-collab anchors in the log: the API refuses or leaves out a change one of whose revisions, reviews or landing is withheld, and bundles and mirrors leave the record out. It does NOT cover the git content the record names: withhold its refs for that. The log itself is always served, and states every withholding.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `id` | string \| null | no | `record` only, required: the record's id as jit-collab writes it in the log and the API shows it: a revision `<change id>/<revision number>`, a review `<change id>/<review id>`, a landing `<change id>`, landing rules and a target override their decimal number. The record must exist (`not_found`). Exactly that spelling: another (`/01`, `/+1`, upper case, a change's number for its id) is `bad_request` naming the one to send, since the log compares ids byte for byte. |
| `kind` | WithheldKind | yes |  |
| `patterns` | array \| null | no | `refs` only, required: 1 to 1024 patterns, each under `refs/`, exact or a prefix ending in `*` (a `*` anywhere else is refused: it would match only that literal name). Each must be able to match a ref: an exact pattern a valid ref name (git's rules; it may name a ref that does not exist yet, which withholds the name in advance), a prefix the beginning of one (`refs/heads/topic/` without `*` is refused). |
| `record` | string \| null | no | `record` only, required: the record's kind as jit-collab anchors it in the log: `revision`, `review`, `landing`, `landing_rules` or `target_override`. |

### Withholding

A withholding in force: a `withheld` entry that no `restored` entry has lifted (`GET …/withholdings`).

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `at_ms` | integer | yes | When the entry was written, Unix ms. |
| `binding` | boolean | yes | Whether this host enforces it: signed by this host's own log key. `false` for one stated by an earlier host of the repository (it came with the log): it says what that host did not serve, and binds nobody here. |
| `reason` | WithheldReason | yes |  |
| `reference` | string | yes | May be empty. |
| `scope` | WithheldScopeInfo | yes | In the form a `withhold` body takes, plus `id_hex` for a record id that is not text. |
| `seq` | integer | yes | The `withheld` entry's sequence number: what `POST …/restore` takes, and where it is in `GET …/reflog`. |
| `signer` | string | yes | The log key that signed it (64 hex digits). |

### Work

`GET …/work`: what the caller could usefully do next in this repository.

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `cursor` | string | yes |  |
| `needs_you` | [WorkItem] | yes | The caller's open changes that need action from the caller: failing checks, requested changes, conflicts. |
| `taken` | [Claim] | yes | Claims held by others: paths and tasks to stay away from. |
| `to_review` | [WorkItem] | yes | Others' open changes waiting for a review the caller could give. |
| `your_claims` | [Claim] | yes | The caller's own claims, soonest to expire first. |

### WorkItem

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `change` | ChangeBrief | yes |  |
| `reasons` | [string] | yes | Why it is listed: `checks_failed`, `changes_requested`, `conflicted`, `needs_review`, `behind_base`. |


<!-- https://docs.neoopensource.com/deploy -->

# Deploying neoopensource

The product is neoopensource; the server binary, the variables and the paths below keep their `jit` and `jithub`
names (see the README).

Two apps (decision 0054): the **back end**, built by the `Dockerfile` at the repository root (`jit-server`: the API,
git over HTTP and the data), and the **front end**, built by `web/Dockerfile` (the web pages, a Bun server that reads
only the back end's API). The back end keeps one data directory; the front end keeps nothing.

| App | Build | Port | Volume | Health | Variables |
| --- | --- | --- | --- | --- | --- |
| back end | `Dockerfile` (context: repository root) | 7878 | `/data` | `GET /healthz` | `JIT_PUBLIC_URL` = the back end's public URL; `JIT_WEB_URL` = the front end's origin |
| front end | `web/Dockerfile` (context: `web/`) | 3000 | none | `GET /healthz` | `JIT_API_URL` = how the front end reaches the back end; `JIT_PUBLIC_URL` = the front end's public URL |

The back end serves no pages (decision 0066): with `JIT_WEB_URL` set, `/` and `/r/…` on it redirect (`308`) to the same
path on the front end; without it they answer `404` (JSON). A health check or uptime probe on the back end must use
`/healthz`, never expect HTML at `/`.

## The back end

`jit-server` serves on one port:

| Path | What |
| --- | --- |
| `/`, `/r/{repo}/…` | `GET`/`HEAD`: `308` to the same path and query on `JIT_WEB_URL`; without it, or other methods: `404` (the API's JSON error). The old view's `/assets/…` and `/theme/…`: `404` |
| `/v1/…`, `/llms.txt` | the API |
| `/{repo}.git/…` | git over smart HTTP (clone, fetch, push) |
| `/healthz`, `/v1/health` | health |

### The operator's checklist

One page; each line says where the detail is. `<c>` is the server's container; `neo` is the CLI (`jit` until the
rename is on main). No token is ever typed, shown or put in a command's arguments: tokens live in files.

**At the first start**

1. Take the root token out without showing it: `( umask 077; docker exec <c> cat /data/trust/root-token > root.token )`.
   It is valid 30 days and written once ("First start: the root token").
2. Put the two key files away, offline, apart from every backup:
   `docker exec <c> tar -C /data/trust -cf - instance.key log.key > keys.tar` ("Backup and restore", step 1).
   Once sign-up exists on the instance there is a third file, `binding.key` (it ties each account to its
   outside login): it joins this copy the day the first account is made, and an instance that holds accounts does
   not start without it.
3. Give yourself a principal of your own and stop using the root token for daily work ("First start", steps 1–3).
4. Note the host's key, which never changes: `neo reflog <any repo> --head` → `signer`. Put it
   in every runner's setup file as `host_key`, so a runner's request cannot be made for another host

**Regularly**

5. Before the root token's 30 days are over (or after: it does not matter), mint the next one offline:
   `docker exec <c> jit-server token mint --key /data/trust/instance.key --out /data/trust/root-token.next`, copy it
   out as in 1. The instance stays the same instance; tokens narrowed from the old one end with it.
6. A runner's token lasts at most 30 days. The runner warns in its log three days before and then stops with
   exit code 3 and the command to run: `jit-runner setup <setup file>` as you, not as the runner's user.
7. Backups run daily on their own where the off-host backup is installed ("Off-host backups", in the production host's section); look at
   `journalctl -u neo-backup` now and then, and run the restore drill once a quarter.

**Before sign-up is switched on (not built yet; decision 0057)**

8. From the first account on, the data directory requires reader version 2: **no build older than the one that
   made that account can ever be started on it again; there is no rollback past that point.** So the deploy
   script's check (an image's reader version against `trust/MIN_READER`, refusing a lower one) must be
   live, and shown to refuse the previous image, before the switch; and a restore after that point starts
   quarantined (decision 0057, point 14).
   An image says its reader version without opening anything: `jit-server --version` prints one line,
   `{"reader_version":2,"version":"0.0.0"}` (keys in that order today; read them by name). Refuse the image when
   its `reader_version` is below the number in `<data-dir>/trust/MIN_READER` (decimal text and a newline, written
   by jit-trust before the store's own fence is raised, so it is never lower). A **missing** file means the
   directory was never opened by a build that writes it: unknown, never 0. Refuse, or open it once with the
   current build, which writes the file.
   On the production host that check is `jithub-autodeploy`'s reader fence (in that host's section). It is signed off once
   trust's `MIN_READER` change is deployed and the fence has been seen to refuse: `jithub-autodeploy --check
   <a commit from before #294>` must answer `refused …: the image does not report its reader version and the
   data directory needs …` (`--check` swaps and records nothing).

**If a token leaks or is lost**

| What | Do | Effect |
| --- | --- | --- |
| any token you can still present | `neo --token-file LEAKED api POST /v1/tokens/revoke` | that token and everything narrowed from it are refused from the next request |
| a runner's token (lost host, no file) | `neo --token-file admin.token api POST /v1/repos/<repo>/tokens/revoke --json '{"revocation_id":"<id>"}'`; the id is in what `jit-runner setup` printed (`token_revocation_id`) and in the repository's signed log (`neo reflog <repo>`, the entry of kind `runner_token`) | the same, and the revocation is an entry in that repository's signed log |
| everything one principal can do on a repository | `neo --token-file admin.token grant set jp_… --repo <repo> --scopes ''` | every token of that principal stops there, also ones made with its own key |
| the root token | revoke it with itself (first row), then mint the next one (5) | the leaked one and what was narrowed from it stop; the new one is unaffected |
| `instance.key` or `log.key` | there is no rotation yet: stop the instance and ask | see the table in "Backup and restore" |

**Which id.** A revocation id is one of a token's `revocation_ids` (`neo whoami` with that token, or the answer
to minting it). It is not the token id the log shows, which is the hash of the token's text: revoking that stopped
nothing and used to be accepted; it is now refused with a message that says so. The instance refuses an id it does
not know as a revocation id: it knows the ids already revoked, the ids of runner tokens minted here, and the
blocks of every token presented since it last started. So **after a restart, an id is unknown until its token is
presented again**: a runner token is still revoked by its id as in the table (its id is kept), a token you hold is
revoked by presenting it (first row), and for a token you do not hold and that has not been presented since the
restart the instance's administrator vouches for the id:

```
neo --token-file admin.token api POST /v1/tokens/revoke --json '{"revocation_id":"<id>","unseen":true}'
```

(`neo admin revoke <revocation id> --unseen` once the CLI has it). Only an instance administrator may, through a
token not narrowed below that: this is what "instance root" means here; a repository's admin and a narrowed admin
token are `403`. The answer is the usual one plus `"unseen": true`. The field is explicit and never a fallback (an
unknown id without it stays `400`, whose message names the field): a wrong id sent as unseen is recorded as revoked
and stops nothing, so copy it, do not type it. **The record**: for a runner token's id the revocation is an entry
in its repository's signed log; for any other id there is no signed log to write to, and the server's log gets one
JSON line instead (`"msg":"token revoked as unseen"`, with `principal`: who revoked, `revocation_id`,
`"unseen":true` and `newly`; never the token and never a client address). That line is the record until the
instance has a log of its own. On a build without the field, withdraw the principal's grant (third row), which
stops every token of that principal on that repository.

Revoking is idempotent; an event stream that is already open re-checks its token before every event of a private repository and at least every 15 seconds, and ends once the token no longer authenticates (decision 0059, limits and streams). **After a restore, redo
every revocation and grant change made since the backup**: a restore brings back what the backup knew (tested:
`crates/jit-trust/tests/instance.rs`, the restore test).

### What the platform needs to know

| | |
| --- | --- |
| Build | the `Dockerfile` at the repository root (no build arguments) |
| Port | `7878` (HTTP; TLS is the platform's proxy) |
| Health check | `GET /healthz` answers `200` and `{"status":"ok"}`; the image also carries a `HEALTHCHECK` on it |
| Persistent volume | `/data` |
| User | `jit` (uid 10001), not root |
| Stop | `SIGTERM`: open requests drain for up to 10 s, then exit 0 |

### Variables (names only)

| Name | Set by | Meaning |
| --- | --- | --- |
| `JIT_PUBLIC_URL` | **you, in the deployment** | The address people and agents reach the service at, for example the `https://` URL of the app. Clone URLs and links are built from it. Without it they point at `http://0.0.0.0:7878`. |
| `JIT_BACKEND` | the image (`real`) | The real backend: repositories, git transport and tokens on disk. Do not change it: `mem` keeps nothing. |
| `JIT_DATA_DIR` | the image (`/data`) | The data directory. |
| `JIT_LISTEN` | the image (`0.0.0.0:7878`) | The listen address inside the container. |
| `JIT_MAX_OBJECT_BYTES` | optional | The largest file a push may contain, in bytes. Default `134217728` (128 MiB). Also `[limits] max_object_bytes` in `config.toml`; the variable wins. See "Limits on what a push may hold". |
| `JIT_MAX_PUSH_BYTES` | optional | The most pack bytes one push may send. Default `4294967296` (4 GiB). Also `[limits] max_push_bytes`. |
| `JIT_MAX_DECODE_BYTES` | optional | The most one read may allocate to decode one stored object (with its delta chain). Default eight times `JIT_MAX_OBJECT_BYTES` (1 GiB). `0`, a value that is not a number of bytes, or one under four times `JIT_MAX_OBJECT_BYTES` (what reading an accepted file can need) does not start the server. Also `[limits] max_decode_bytes`. |
| `JIT_MAX_BUNDLE_BYTES` | optional | The largest bundle `GET /v1/repos/{repo}/bundle` (`neo bundle`) serves, in bytes. Default `2147483648` (2 GiB, what `neo bundle` accepts by default). A larger one is answered `413 too_large` and its file removed. `0` or a value that is not a number of bytes does not start the server. Also `[limits] max_bundle_bytes`. Bundles are files under `<data-dir>/bundles/` (one per repository, of its current log position; earlier ones are removed, nothing to back up); no new one is written below `JIT_MIN_FREE_BYTES` (decision 0085). |
| `JIT_WEB_URL` | optional (production: **you**) | The front end's origin, for example `https://neoopensource.com`: `/` and `/r/…` on the back end redirect there, so old links and bookmarks keep working. An `http`/`https` URL with a host and nothing after it (no path beyond `/`, query, fragment or user name); anything else stops the server at start-up naming the variable. Also `web_url` in `config.toml`; the variable wins. Without it those paths answer `404`. |
| `JIT_CONFIG` | optional | A `config.toml` to read instead of `/data/config.toml` (rate limits, body cap; `docs/contracts/jit-server.md` section 1). It never holds secrets. |
| `JIT_METRICS_LISTEN` | optional | Where Prometheus metrics are served (`GET /metrics`), for example `127.0.0.1:9100` or the container's address on an internal network. Unset: no metrics. See "Metrics" below. |
| `JIT_NODE` | optional | This server's name in its metrics (the `node` label on every series), for example `us-1`; `[a-z0-9-]{1,32}`, default `primary`. |
| `JIT_TRUSTED_PROXY` | **you, when a reverse proxy is in front** | IP addresses and CIDRs, comma-separated (for example `172.18.0.1,172.18.0.3`; exact addresses preferred over CIDRs): the peers (Caddy through Docker's gateway, the `web` container) whose right-most `X-Forwarded-For` entry is the client address the anonymous limits key on. Unset: every client is its TCP peer, so behind a proxy all anonymous callers share one bucket and anonymous clones have no per-client share (a warning at start-up says so). Precondition: the server's port is reachable only by Caddy and the `web` container (published on `127.0.0.1` or not at all). Verify the two host facts in "The client address behind the proxy" before setting it. |
| `JIT_GIT_CONCURRENT`, `JIT_GIT_CONCURRENT_PER_CLIENT` | optional | Clones and fetches producing a pack at once, overall (default twice the CPUs) and per token or, behind a trusted proxy, per client address (default a quarter of the total). See "Clones and fetches are capped". |

| `JIT_SIGNUP` | **leave unset** (production runs with it off) | Sign-up: `off` (the default), `preview` or `privy`. See "Sign-up" below. Off, the sign-up routes do not exist and nothing else here is read. |
| `JIT_SIGNUP_ALLOW_FILE`, `PRIVY_APP_ID`, `PRIVY_APP_CLIENT_IDS`, `PRIVY_KEYS_FILE` | only with sign-up on | The preview's list, the Privy app and its client ids (public identifiers, never in the code), and the file of the app's public keys. See "Sign-up". |

There is no secret to put in the environment: the instance makes its own keys and its first token on first start.

### Sign-up

**The deployed instance runs with sign-up off** (`JIT_SIGNUP` unset). Then the sign-up routes
(docs/contracts/accounts.md) answer exactly as paths that do not exist, except `POST /v1/session/end`, and every other
route behaves as before: off is what a cut deploys. Turning it on is a deliberate change of the deployment,
after item 8 of the operator's checklist above, never a side effect of a merge.

To turn it on, set in the deployment (each also a key of `[signup]` in `config.toml`; the variable wins):

| Variable | Value |
| --- | --- |
| `JIT_SIGNUP` | `preview` (only the people on the list) or `privy` (anyone) |
| `JIT_SIGNUP_ALLOW_FILE` | with `preview` only: a file of Privy DIDs, one per line (`#` comments allowed). Refused with `privy`. |
| `PRIVY_APP_ID` | the Privy app's id (public) |
| `PRIVY_APP_CLIENT_IDS` | the accepted client ids, comma-separated (public); not empty |
| `PRIVY_KEYS_FILE` | `{"checked_at": <Unix seconds>, "keys": [JWK, …]}`: the app's P-256 public keys, one or two. Update `checked_at` whenever you compare the set with Privy's: after 7 days new sign-ins answer `503 keys_stale` (existing sessions keep working). |
| `JIT_PUBLIC_URL` | **required, set explicitly**: the API's public origin as people dial it (`https://…`; `http` only for a loopback host). A machine's pairing poll must name it, so a pairing relayed through a mistyped address never completes. |
| `JIT_TRUSTED_PROXY` | **required**: the reverse proxy's address. Without it the server refuses to start (unless it listens on loopback only), because the per-address limits of sign-up and pairing would otherwise be one limit for everyone behind the proxy. Verify "The client address behind the proxy" first. |

The server refuses to start on a missing or malformed one and names it (never a line of the allow list). The
per-address limits (5 sign-ups a day, 10 pairings started and 10 lookups an hour, starting a login) are kept in memory
and start again at every restart; the hourly bound on new accounts (100) and the per-account and per-session limits
are kept by jit-trust in the store and hold across restarts. Switching back to `off` and restarting makes the routes
disappear again, and jit-trust refuses every account credential (sessions, machine keys) on every route but
`POST /v1/session/end`, which still ends a session for good (`accounts_dormant`, set at start from `JIT_SIGNUP`).

### Metrics

Set `JIT_METRICS_LISTEN` to serve Prometheus metrics at `GET /metrics` on a second listener (for example
`0.0.0.0:9100` inside the container, on a network only the Prometheus container shares). **Do not publish that
port**: it has no authentication, the network is its only fence (it never shares the public port, and the server
refuses to start if you point it there). With host networking, or outside a container, use `127.0.0.1:9100`: `0.0.0.0` would put it on the public interface. Scrape it every 15 s or more; gauges are re-read at most every 15 s and the
disk size once a minute. Counters reset at each restart (each deploy). The list of metrics and their labels is
`docs/contracts/metrics.md`; none carries a repository, a principal, a token, a path or an address. Every
series carries `node` (set `JIT_NODE` per server); the contract says which metrics to sum across nodes and which
to read from one.

```yaml
# docker compose, sketch: the metrics port is on the internal network only, not under `ports:`
services:
  jithub:
    environment:
      JIT_METRICS_LISTEN: "0.0.0.0:9100"
    networks: [default, metrics]
  prometheus:
    networks: [metrics]   # scrapes http://jithub:9100/metrics
networks:
  metrics:
    internal: true
```

### What must be persistent

All of `/data`, as one volume:

- `/data/store/`: every repository (objects, packs, refs) and the metadata store, including the signed ref logs.
- `/data/trust/`: the instance's keys and the first token. **Losing this directory loses the instance's identity**:
  tokens issued before stop working and the ref logs can no longer be continued by the same signer.

Nothing outside `/data` is state. How to back it up and restore it is the next section.

### Limits on what a push may hold

Instance settings in bytes, read at start (a value that is not a positive whole number stops the start
with a message; `jit-server --print-config` shows what is in force):

| Setting | Environment | `config.toml` | Default |
| --- | --- | --- | --- |
| The largest file in a push | `JIT_MAX_OBJECT_BYTES` | `[limits] max_object_bytes` | `134217728` (128 MiB) |
| The most pack bytes in one push | `JIT_MAX_PUSH_BYTES` | `[limits] max_push_bytes` | `4294967296` (4 GiB) |
| The most one read decodes for one object | `JIT_MAX_DECODE_BYTES` | `[limits] max_decode_bytes` | eight times the largest file: `1073741824` (1 GiB) |
| The largest bundle served (`GET …/bundle`) | `JIT_MAX_BUNDLE_BYTES` | `[limits] max_bundle_bytes` | `2147483648` (2 GiB) |

- A push that contains a larger file is refused as a whole, nothing of it is kept, and git shows the person why:
  the file's size, the limit and its setting, and what to do ("a file that large does not belong in git here: keep
  it elsewhere, commit a reference to it, and push again"). A push over the second limit is told to push the
  history in smaller steps.
- Why there is a per-file limit at all: a pack can describe a large file in a few kilobytes (a delta), so the
  limit is what bounds how much memory a small request can make the server use. 128 MiB is in line with what hosted
  forges accept.
- **The limits are on what is received, not on what is served.** A repository that already holds a larger file
  (the limit was lowered later) is cloned and fetched whole.
- They apply to `git push` and to an import. The API's own body cap (`max_body_bytes`, 8 MiB) is separate.
- **A push is authorized twice.** Once before its pack is read, and again inside the transaction that moves its
  refs: a token revoked or expired, or a right withdrawn, while the pack was arriving refuses the whole push
  ("the token has been revoked"), and nothing of it becomes reachable. This holds for `git push`. **It does not
  yet hold for commits made through the API or for a landing made on a caller's behalf**: those authorize before
  their write and do not ask again inside it.
- **A chain of deltas is bounded at the push, and every read is bounded.** To read an object stored as a delta,
  the server decodes its whole chain at once: two buffers of the chain's largest object and every delta's
  instructions together. A push in which one chain's instructions come to more than twice `JIT_MAX_OBJECT_BYTES`
  (256 MiB at the default) is refused ("a chain of deltas in this push needs … bytes"; the person repacks with
  `git repack -adf --depth=50` and pushes again). And no read may allocate more than `JIT_MAX_DECODE_BYTES` (eight
  times `JIT_MAX_OBJECT_BYTES`, 1 GiB at the default) for one object: past it that one request fails with an error
  and the server goes on. A file within the push limits never needs that much. **If a legitimate object ever hits
  it** (a repository imported or pushed before these limits held one larger than they now allow): its clone, fetch
  or file read fails with a server error naming no object, and the server's log has the reading error; raise
  `JIT_MAX_DECODE_BYTES` to cover it (at most about three times the object's size plus its chain) and restart, or
  keep the file out of the repository.
- **A floor of free disk space, off by default:** `JIT_MIN_FREE_BYTES` (or `[limits] min_free_bytes`), in bytes.
  While the file system that holds `/data` has less than that available, a `git push` is refused before its pack
  is read ("this instance is short of disk space and takes no pushes for now"), and clones and fetches go on. It
  is one system call per push and keeps no state. A commit made through the API
  (`POST /v1/repos/{repo}/commits`) is refused the same way. A token with `admin` on the instance may still push
  and commit below it. Not yet covered: imports (no import route exists yet).
- **Everything a push makes the server inflate counts against one total** (16 GiB a push): every object, every
  delta's instructions, and what each delta builds. A push is refused at the entry that would pass the total,
  before that entry is inflated.
- **A tree that arrives is checked as git checks received objects**, and the push or import is refused, naming the
  tree and the reason, when a tree holds: the same name twice (a file and a symlink, a file and a directory), entries
  out of git's order, the name `.`, `..`, an empty name, a name with `/`, `.git` in any spelling a git client reads
  as `.git`, `.gitmodules` as a symlink, a mode padded with a zero or a mode that is not a directory, file,
  executable, symlink or submodule. Each of these has been a way to make a checkout write outside itself. Old
  histories made by old tools sometimes hold zero-padded modes: such a repository is refused on import until it is
  rewritten. A tree the repository already held is not judged again. Trees made through the API
  (`commits.create`) are built by the server and meet all of this by construction.

### Backup and restore

Two commands of the same binary, each printing one JSON object. A backup is taken **while the instance runs**; it
does not stop or slow pushes.

**1. Once, right after the first start: put the two key files somewhere a backup is not, offline.**

```
docker exec <container> tar -C /data/trust -cf - instance.key log.key > jithub-keys.tar
```

`instance.key` is the instance's identity: every instance token is minted under it and verified against it.
`log.key` signs every ref log entry and checkpoint. Neither changes after the first start. Keep `jithub-keys.tar`
in a secret store, off this host: move it there, check that it opens, and delete it here.

**A third file once people can sign up: `binding.key`.** It appears in `/data/trust/` at the first sign-in and
never changes. It links a person's outside identity to their account without the store holding the identity.
Take the copy again right after the first sign-in, with all three:
`docker exec <container> tar -C /data/trust -cf - instance.key log.key binding.key > jithub-keys.tar`.
Lost, every signed-up person is a stranger to their own account and the instance does not start on that data
(it is never made again); leaked together with the store, accounts can be linked to identities. Like the
other two it is in no backup unless you ask (`--with-keys`). They are **not** in a backup unless you ask for them (`--with-keys`), so that a backup that
leaks cannot mint tokens or sign logs.

| If it is | lost | leaked |
| --- | --- | --- |
| `instance.key` | every instance token is dead and a restore is a different instance | whoever has it mints root tokens; there is no rotation yet |
| `log.key` | no existing ref log can be continued | whoever has it can sign a forked log that verifies |

**An instance that has had its first sign-up has a third key, `trust/binding.key`** (jit-trust writes it once, at
the first account; an instance with no account has none). Keep it with the other two from that day on: it is what
ties each account to the person who signed up, the store of an instance with accounts does not start without it,
and like the other two it is in a backup only with `--with-keys`. `backup.json` carries the id of the key the
store's accounts were made with (`binding_key_id`, a hash, never the key) and lists the file under
`keep_separately`; a restore of such a backup refuses, before writing anything, keys that lack it or hold
another one.

`root-token` is never in a backup, with or without `--with-keys`: it is a credential that expires, and a new one
is minted from `instance.key` whenever needed (step 3).

**2. A backup, as often as you like:**

```
docker exec <container> jit-server backup --data-dir /data --to /data/backups/2026-11-29
docker cp <container>:/data/backups/2026-11-29 ./jithub-backup-2026-11-29     # off the volume, off the host
docker exec <container> rm -r /data/backups/2026-11-29                        # optional: free the volume
```

The directory given to `--to` must not exist yet. The command asks the running server to take the snapshot (only
the process that has the store open can read it consistently). It proves itself with a token it mints on the spot
from `/data/trust/instance.key`, valid for five minutes: being able to read the instance key is the right to back
the instance up, and nobody who was merely granted rights, not even `admin`, can ask for one. It prints what it
copied: repositories, tables, rows, object files and bytes, and how long it took. If no server is
running on that data directory, the same command takes the backup itself.

What a backup holds, all **as of one instant**:

| In the backup | |
| --- | --- |
| `store/` | every repository: objects, packs, refs; and the metadata store with the **signed ref logs**, principals, grants, revocations, changes, reviews, claims, events, landing rules |
| `config.toml`, `collab/` | if the instance has them |
| `backup.json` | when it was taken, by which version, what was copied, and the public halves of the two keys |

| Not in the backup | Keep it how |
| --- | --- |
| `trust/instance.key`, `trust/log.key` | step 1, once; or `--with-keys` to put them in this backup |
| `trust/root-token` | not kept: mint a new one (step 3) |
| `server.json`, `tmp/` | not state |

"One instant" means: a ref and the log entry that moved it are in the backup together or not at all, and every
object a ref of the backup leads to is in it. A push that is acknowledged before the command starts is in the
backup; one that is acknowledged after it returns is not; one in between is in it wholly or not at all.

**A backup is secret material even without the two key files.** `store/` holds the content of private
repositories and the root key seeds of every repository whose key the host holds in custody. Store it encrypted
and access-controlled, like the keys, never as ordinary data.

**3. Restore, into a new directory (here: a new volume mounted at `/data` of a container that is not running the
server yet):**

```
docker run --rm -v jithub-new:/data -v "$PWD":/in --entrypoint sh <image> -c '
  mkdir /tmp/keys && tar -C /tmp/keys -xf /in/jithub-keys.tar &&
  jit-server restore --from /in/jithub-backup-2026-11-29 --data-dir /data/restored --keys-from /tmp/keys'
```

then start the instance on it (`JIT_DATA_DIR=/data/restored`, or move its content to the volume's root), and mint
yourself a root token, because a restored instance has no `root-token` file:

```
docker exec <container> jit-server token mint --key /data/restored/trust/instance.key --out /tmp/root --ttl-s 2592000
```

Restore

- refuses a target directory that is not empty;
- refuses to finish without the instance's own keys, and checks the keys it is given against the public keys in
  `backup.json` (an instance started on this data with other keys could not sign for its repositories, and no token
  issued before would be valid);
- copies, then opens the result and checks that every ref of every repository points at an object that is there.

Then check from outside, per repository: `jit verify <repo>` (the signed log verifies and names the refs) and a
`git clone`.

What a restore means:

- **The same instance.** Same identity, same log signer: tokens minted before the backup still verify until they
  expire, and the instance signs new entries for its repositories.
- **The instant of the backup, nothing later.** Pushes and changes after it are gone, **and so are token
  revocations and grant changes**: a token revoked after the backup works again, a grant removed after it is back.
  Redo those by hand before the instance is reachable.
- **Clients and mirrors that saw the log after the backup will report a rollback** (`jit verify --since`: the
  checkpoint they kept is larger, or of the same size with another root) as soon as the restored instance appends.
  That is the audit working as designed; announce the restore to them.
- **Never run the old and the restored instance at the same time.** Two logs signed with one key in different
  directions is equivocation, and it is provable from the two signed checkpoints.
- **A copy of `store/` without the two key files is not this instance.** `jit-server restore` refuses to finish
  without them; do not work around it by letting a first start create new keys next to an old store.

### What a crash leaves

The server can be killed at any moment (`kill -9`, a power cut, the platform replacing the container); there is no
clean-shutdown step that the data depends on.

- **A push that was acknowledged is there after the restart**: its objects were written and synced to disk, and the
  transaction that moved its refs and added the signed log entry was committed and synced, before the client was
  told "ok". The same holds for every API write that returned success.
- **A push that was not acknowledged either left nothing visible or, if the server died after committing and
  before answering, is there in full.** There is no third state: all refs of an atomic push move together or not at
  all, with their signed log entry, in one transaction. If it did not commit, no ref moved, the log has no entry
  for it, no object of it is served, and what was received of its pack sat in a quarantine directory that is
  deleted the next time the repository is used. The tests kill the server halfway through a pack and right after an
  answer; the window between the commit and the answer is not covered by a test, and is the case below.
- **What a client does after a broken connection.** It cannot know which of the two happened, so it asks:
  - `git push`: push again. If the first one landed, the second is a no-op ("Everything up-to-date"); if it did not,
    it lands now. Reading the ref first (`git ls-remote`) tells which, if that matters.
  - `POST /v1/repos/{repo}/commits`: send `expect` (what the branch pointed at before). A retry of a write that did
    land answers `precondition_failed` with the branch's current value in `details.current`: compare it with the
    commit you meant to make. Without `expect`, a retry makes a second commit on top of the first.
  - **`Idempotency-Key` does not survive a restart**: the server remembers keys in memory only. After a broken
    connection that may have been a restart, a repeated key is treated as a new request. Use `expect`.
- **A crash while packs are being merged in the background** loses nothing: the merged pack is indexed, verified,
  and fsynced into place before the packs it replaces are taken out of service. Leftover quarantine directories are
  removed when that repository is first opened after a restart, and retired pack indices are swept on restart.
  Background consolidation is copy-only by default; setting `JIT_CONSOLIDATE_DELTA=1` (or `consolidate_delta = true`
  in `config.toml`) enables bounded cross-pack delta compression after a 30 s quiet period per repository (at most
  2 worker threads, 128 MiB per merge). Either way a merge is skipped while less than 3× the merged size is free
  on disk (a file system that cannot be asked is let through).
  **`JIT_CONSOLIDATE_DELTA` is off by default. Turning it on is a trade:** a quarter to a half less disk where
  history is compressible (measured: 105 to 73 MiB, and 1,605 to 1,073 MiB) and two to three times faster full
  clones of a many-object repository, against **incremental fetches about a third slower** on a repository whose
  trees it has deltified (measured on a small repository at 8 clients: 16,500 to 8,400-12,500 per second at the
  same CPU), and a background pass that, 30 s after a repository's last push, rewrites up to 128 MiB of its packs
  with two threads. Its memory is bounded by the number of objects (a crafted push of 100 near-identical
  67 MiB trees repacked at 148 MiB), trees are at most 4 deltas deep and commits never deltified, objects over the
  size limit are copied as they are stored, and every read is bounded by `JIT_MAX_DECODE_BYTES`. Turn it on
  where disk matters more than fetch latency; leave it off on an instance that serves many incremental fetches.
- **Full-clone pack cache**: repeated full clones of multi-pack repositories share an unlinked temporary pack under
  `/data/pack-cache` (capped at 256 MiB per pack, 512 MiB total, and 64 entries LRU; never `/tmp`, not included in
  backups). Leftover files in `/data/pack-cache` are swept at start-up, and any error creating or writing a cached
  pack falls back to direct streaming without failing the clone.
- **A crash during a backup** leaves an incomplete directory at `--to` (no `backup.json`, or restore refuses it):
  remove it and take another.

### "Remove" does not erase

Nothing on the host is ever deleted by taking something down, and this page should not be read as if it were:

- **A commit that was force-pushed away, or whose branch was deleted, is no longer served**: asked for by id it
  answers 404, exactly like an id that never existed, and a clone does not contain it. **Its bytes stay on disk**,
  in the pack they arrived in, and the signed log still says which commit the branch pointed at before.
- **Taking a repository or a ref down** (a `Withheld` entry) means the host stops serving it and says so in the
  signed log. Any cached temporary packs for that repository in `/data/pack-cache` are dropped on explicit
  invalidation, on repository removal, and on the first git request under an active withholding; the authoritative
  object packs stay on the host. **A refs withholding hides refs, not content**: the named refs and
  what only they reach are refused, but content that any other ref still reaches (another branch built on it, a
  change's pin under `refs/changes/`, a tag) stays served under that ref and by commit id. To withhold content,
  cover every ref that reaches it (a pattern may end in `*`) or withhold the whole repository, then check with a
  fresh clone and by asking for the commit by id. A record withholding is for one record (a change, a review)
  and touches no git content.
- **Backups hold everything the store holds**, private repositories and removed content included, for as long as
  the backups are kept.
- Clones, forks and mirrors elsewhere keep what they have; no host can recall them.

There is no erasure command and no retention period today. If something must be gone from the host (a leaked
secret is the usual case: rotate the secret first), that is a manual operation on the data directory and on every
backup, and it is not built.

All of this assumes the volume keeps what was synced to it (a disk or a network volume that acknowledges a sync and
then loses the write is outside what software can promise). Tested with the real binary and `kill -9`:
`crates/jit-server/tests/backup.rs`.

### Taking a repository down

Who can: an **instance administrator** only, that is the root token or a principal granted `admin` on the instance
(`PUT /v1/grants/{principal}`), through a token not narrowed below that. An administrator of one repository cannot,
and neither can an instance administrator's token attenuated to some repositories, operations or refs (`403`;
anonymous `401`). Decision 0071.

The call, with that token:

```
neo api POST /v1/repos/<repo>/withhold --json '{"scope":{"kind":"repository"},"reason":"legal","reference":"order 2026-17"}'
```

`reason` is one of `legal`, `policy`, `security`, `owner`; `reference` (a case or notice number, a URL) is public:
it is in the repository's signed log. `scope` is one of:

- `{"kind":"repository"}`: everything. Every API read of the repository answers `451 withheld` except its record
  (`GET /v1/repos/<repo>`), its log and its withholdings; clone and fetch serve nothing; no write but grants,
  revocations, withholding and restoring is accepted.
- `{"kind":"refs","patterns":["refs/heads/leak"]}`: those ref names (exact, or a prefix ending in `*`) and what only
  they reach. It does **not** cover a commit that another branch, a tag, a change's `refs/changes/…` pin or a queue
  pin still reaches: that stays served, by that ref and by id (decision 0070). **Withholding a branch by name does
  not stop its content being read through a change's pin**: if the branch is a change's head, its commits stay
  readable (even as `?rev=<branch>`) through `refs/changes/<id>/<n>`. To take that content down, withhold the
  change's pins (`refs/changes/<id>/*`) and its revision records too, or the whole repository. The names stay listed
  (they are in the signed log). For a leaked secret, cover every ref that reaches it, or take the whole repository
  down. A pattern that covers `refs/queue/` is refused unless the body says `"include_queue": true`. Each pattern
  must be able to match a ref: an exact pattern must be a valid ref name (git's rules), a prefix the beginning of
  one; `refs/heads/topic/` without `*`, `..`, a space, `~^:?[\`, an empty or `.`-led component and the like are
  refused (`400`) rather than written as a withholding of nothing. An exact name no ref has today is accepted: it
  withholds that name in advance.
- `{"kind":"record","record":"revision","id":"<change>/<n>"}`: one of jit-collab's records (`revision`, `review`,
  `landing`, `landing_rules`, `target_override`); the record must exist (`404`). The id is exactly as the log
  writes it (`<change id>/<n>`, `<change id>/<review id>`, `<change id>`, or the number): another spelling (`/01`,
  `/+1`, upper case, a change's number in place of its id) is refused with the form to send. The API refuses the
  change it belongs to and leaves it out of lists; bundles and mirrors leave the record out. It does **not** cover
  the git content the record names: withhold its refs for that.

Send an `Idempotency-Key` header: a retry with the same key and body answers the first entry and writes nothing
(the same key with another body is `409`). A retry without one writes a second withholding (each is lifted on its
own). Keys are kept in memory and a restart forgets them.

The answer is the signed `withheld` entry; keep its `seq`. To check it took effect:

- `GET /v1/repos/<repo>/withholdings` lists every withholding in force there, oldest first, with `seq`, `scope`,
  `reason`, `reference`, `at_ms`, `signer` and `binding` (`true`: signed by this host's key, so this host enforces
  it; one an earlier host stated came with the log and binds nobody here). `GET /v1/repos/<repo>/reflog` shows the
  entry itself.
- An API read of covered content (`GET /v1/repos/<repo>/tree?rev=<branch>`, a blob, the change) answers `451
  withheld` with `details.seq` naming the entry.
- `git ls-remote <clone_url>` lists none of the covered refs (nothing at all for the whole repository), and a clone
  or fetch of covered content is refused (`not our ref`); bundle exports leave it out.

**When in doubt, withhold the whole repository** (`{"kind":"repository"}`): it is the one scope that leaves nothing
of the repository's content served by another route, and it can be narrowed later (withhold the narrower scope, then
lift the whole one).

**Taking one change down** is several calls, because a change is several records and refs (there is no single
"change" scope, decision 0071). With `<id>` the change id and `<branch>` its head branch:

1. Its refs: `{"scope":{"kind":"refs","patterns":["refs/changes/<id>/*","refs/heads/<branch>"]},…}`. Any other
   branch or tag that contains its commits keeps serving them: add those patterns too.
2. Each revision: `{"scope":{"kind":"record","record":"revision","id":"<id>/<n>"},…}` for n = 1 to the latest
   (`GET /v1/repos/<repo>/changes/<id>` lists them).
3. Each review: `{"scope":{"kind":"record","record":"review","id":"<id>/<review id>"},…}`; and, if it landed, its
   landing: `{"scope":{"kind":"record","record":"landing","id":"<id>"},…}` (a landed change's commits are on the
   target branch: only the whole repository takes those down).
4. A revision or review added after these calls is not covered: withhold it too, or use the whole repository.

Keep every `seq`: lifting is one restore per withholding.

To lift one: `neo api POST /v1/repos/<repo>/restore --json '{"seq":<seq>}'` writes a `restored` entry, and the
covered content is served again (unless another withholding in force covers it). `404` means no withholding is in
force at that number (never one, or already lifted). Lifting a narrower withholding while a wider one is in force
serves nothing the wider one covers.

Gaps: the statement is written in that repository's log only. There is no instance-wide log of take-downs yet: the
repository-log entry is the record, and to list every withholding on the instance, ask each repository's `GET
…/withholdings`. Nothing is deleted (see the section above).

### First start: the root token

On the first start with an empty `/data`, the server writes one token to

```
/data/trust/root-token
```

It is readable by the service's user only (mode `0600`), it belongs to the instance's own principal, which may do
everything, and it is valid for **30 days**. It is written once: a restart does not replace it. The server never
prints it: the logs name the file's path and nothing else (`cargo xtask container-proof` checks that the token is in
neither stdout nor stderr, and that it is in no process's arguments while the proof uses it).

Copy it once into a file only you can read, **without displaying it**. On the machine that runs the container (for
a platform such as Coolify: a shell on the server, over SSH):

```
( umask 077; docker exec <container> cat /data/trust/root-token > jithub-root.token )
```

The redirect sends the token straight into `jithub-root.token` (mode `0600` because of the `umask`); nothing is
shown. Do not `cat` it to a terminal, and do not use a web terminal for this (Coolify's app terminal can only
display): what a terminal shows stays in its scrollback, in screen shares and recordings, and in whatever logs the
session. Never put it in a command's arguments either (`curl -H "Authorization: Bearer …"`): any local user can read
another process's arguments with `ps`. The clients take the file instead: `neo --token-file jithub-root.token …` or
`JIT_TOKEN_FILE`, and git through `neo git-credential` (`neo` is the CLI; its
binary is `jit` until the rename is on main). Treat the file like a root password: move it to a secret
store, not into a chat or a ticket.

Use it straight away to give yourself a principal of your own, so that nothing depends on the 30-day token:

1. Make a key on your machine: `jit-server key new --out me.key` (it prints the public id, `jp_…`; the file is
   owner-only).
2. Register it and give it rights, with the root token: `POST /v1/principals` (`{"id": "jp_…", "name": "…"}`), then
   `PUT /v1/grants/jp_…` (`{"scopes": [...]}`); `GET /v1` lists the endpoints and scopes.
3. Mint your own tokens from that key, offline: `jit-server token mint --key me.key --out me.token`.

A new instance token, before or after the 30 days, is minted offline from the instance's key, inside the container,
into a file (never printed), and copied out the same way:

```
docker exec <container> jit-server token mint --key /data/trust/instance.key --out /data/trust/root-token.next
( umask 077; docker exec <container> cat /data/trust/root-token.next > jithub-root.token )
```

(Tested in jit-trust and against a running server, #118: the instance stays itself, and tokens narrowed from the old
root end with it.)

### What this instance stores

Under `/data`, and nowhere else: repositories (git objects and refs) and their records (name, description,
visibility, creator); each repository's signed ref log and checkpoints; principals (a public key, a name label, when
registered) and their grants; tokens' revocation ids and the revocations themselves, never the text of a token, with
one exception, the root token written once to `/data/trust/root-token` (owner-only) for the operator to collect;
the instance's own keys (`/data/trust/`, owner-only) and the root keys of repositories it holds a key for; changes
and their revisions, checks, reviews and comments where they exist, claims, landing rules and events. Commits carry
the author and committer names and e-mail addresses their authors wrote into them, as in any git host; commits made
through the API name the principal (`<principal id>@jithub`). Not stored: agent sessions or transcripts, accounts,
passwords, and request logs. The logs (JSON lines on stderr) record start-up, shutdown and backups only, with no
tokens and no client addresses. In memory only, gone on every restart: the per-address counters of the anonymous
rate limit, and the `Idempotency-Key` answers (`docs/contracts/jit-api.md` section 2).

With sign-up on (`JIT_SIGNUP` `preview` or `privy`, "Sign-up" above) the instance also stores accounts and what
jit-trust keeps for them (docs/contracts/accounts.md), and a pairing in flight keeps the normalized client address
it was started from (an IPv4 address, or an IPv6 address as its /64) for at most ten minutes, deleted with the
pairing; it is never logged and is shown only to the session that types the pairing's code. The log then also
records why a sign-in was refused, by the name of the rule, never a token, a code, a Privy subject or an address.
The per-address counts of sign-ups, logins started, pairings and lookups are in memory only.

### Who can read what

- The deployed instance creates public repositories only; an instance admin can create private ones (decision 0063).
- A repository is **public unless an instance admin creates it with `"public": false`**. Public means anyone who can reach the
  service can read it without a token: the front end, the API and `git clone`.
- A private repository is invisible without a token: the front end and the API answer "not found", and git asks for
  credentials.
- Every write (creating a repository, a push) needs a token. Git sends it as the password of Basic auth (any user
  name) or as a Bearer header.

So on a public address, decide per repository; nothing is writable anonymously.

### Proving an image

```
cargo xtask container-proof
```

builds the image, runs it with a fresh volume, waits for the health check, checks `/healthz`, `/v1` and that `/` is a `404` (no pages on the back end), reads
the root token from the container, creates a private repository, pushes to it and clones it back with stock git,
checks that an anonymous clone is refused, that the logs do not contain the token and that the token was in no
process's arguments while it was used. It then builds the front end's image from `web/`, runs it beside the back end
on a private network with `JIT_API_URL` and no token, waits for its health check, and checks that it is not root,
that its first page lists a public repository and not the private one, and that `/r/<private>` is 404 through it.
It then proves the runner's separation of the check command from its own user (`jit-runner`), in a throwaway
container, never on the host. Tests that switch users need root and report themselves skipped everywhere else.
The proof runs those tests (`as_another_user_…`) as root with `JIT_REQUIRE_ROOT_TESTS=1`, prints each name with
its result, and fails if any fails, if any reports itself skipped, or if fewer than five ran (four in the library's tests, one in `tests/e2e.rs`: the checkout written by the `fetch_as` user). `cargo xtask
container-proof --runner-only` runs that step alone. Last it stops the back end (exit 0),
and removes both containers, the volume, both images and the network. It needs a Docker daemon and about 4 GB of free
disk for the builds.

## The front end (`web/`)

| | |
| --- | --- |
| Build | `web/Dockerfile`, build context `web/` (Coolify: base directory `/web`, Dockerfile location `/Dockerfile`) |
| Port | `3000` (`PORT` changes it) |
| Health check | `GET /healthz` answers `200` `ok`; the image also carries a `HEALTHCHECK` on it |
| Persistent volume | none: it keeps no state |
| User | `bun` (uid 1000), not root |
| Variables | `JIT_API_URL` (required): the back end as the front end reaches it, for example `http://<back-end-service>:7878` on the platform's internal network, or the back end's public `https://` URL. `JIT_PUBLIC_URL`: the front end's own public `https://` URL, used in the Markdown twins' links. `PORT` (default 3000). No secrets. |

It serves the pages (`/`, `/r/{repo}/…`), the stylesheet and fonts (`/assets/…`), and passes `GET /v1/…` and
`/llms.txt` through to the back end, so every link on a page works from the front end's domain. Git over HTTP is not
passed through: clone URLs are the back end's `JIT_PUBLIC_URL`, as the API reports them. A viewer's token (later, from
sign-in) is an httpOnly cookie that only this server reads and forwards to the API; agents may send their own
`Authorization: Bearer` header instead.

Prove it locally:

```
docker build -t jithub-web web/
docker run --rm -p 3000:3000 -e JIT_API_URL=http://host.docker.internal:7878 jithub-web
curl -s localhost:3000/healthz          # ok
curl -s 'localhost:3000/r/demo?format=md'
```

## Feedback (`neo feedback`)

The instance stores feedback people send it (`docs/contracts/feedback.md`, decision 0077): at most 10,000 items
of at most 8192 bytes of text each, in the instance's own store. It is in a backup like everything else there,
and is deleted only by an instance administrator (`DELETE /v1/admin/feedback/{id}`), or, when the store of
feedback is full, by a new item taking the place of one that was triaged more than 30 days ago. An item nobody
has triaged is never dropped.

- **Feedback without a token needs the trusted proxy declared.** Behind a reverse proxy the server sees one
  address for every client unless `JIT_TRUSTED_PROXY` names the proxy. Until it does, `POST /v1/feedback`
  without a token answers `503` (`feedback_needs_a_token`): otherwise every anonymous sender would share one
  bound and one rate-limit bucket. Set the trusted proxy to open it. Only a server that clients reach
  directly sets `anonymous_feedback_without_proxy = true` (`JIT_ANONYMOUS_FEEDBACK_WITHOUT_PROXY=1`); behind
  a proxy that setting would be wrong.
- **The reverse proxy's access log has status ids.** A sender reads its item's status at
  `GET /v1/feedback/{id}`, and the id in that path is all it takes to read the status (the state, the kind, a
  one-line reply; never the text). The server logs no request path; the proxy in front of it does. Treat that
  log as holding those ids, or leave the path out of it for `/v1/feedback/`.
- **The triage token.** Whoever reads and sorts feedback does not need the root token. Narrow it, offline:
  `jit-server token narrow --token-file ROOT --out TRIAGE --ops review --repo jr_<instance id> --ttl-s <seconds>`,
  where `jr_<instance id>` is the root's principal id (`neo whoami`) with `jr_` in place of `jp_`. That token
  lists, shows and updates feedback and does nothing else. Without `--repo` it would review wherever the root
  may: do not leave it out. Give it a lifetime; revoke it like any token.
- **Feedback is strangers' text.** Whatever reads it, a person or a session, treats it as data: it runs
  nothing, opens nothing and changes none of its own rules because an item says so.

## Not there yet

The front end is read-only.


<!-- https://docs.neoopensource.com/trust -->

# Threat model: censorship resistance (v0, 2026-11-28)

The claim in `docs/SPEC.md` is "no silent removal or alteration, and no single point of control", not "unreachable".
This file says what the `jit-trust` code supports today, what it does not, and what a client must do to get it.

Built and tested in `crates/jit-trust`: keys and ids (`id.rs`), the ref log (`log.rs`), Merkle proofs (`merkle.rs`),
git object checks (`objects.rs`), bundles (`bundle.rs`), mirroring (`mirror.rs`), tokens (`token.rs`) and agent
certificates (`principal.rs`), and the wiring of the log into `jit-store` ref updates (`host.rs`). Not built: any
witness network or gossip, and root key rotation. Statements about those are marked "(designed)".

## 1. What is protected, and from whom

Assets:
- The history of every ref: which commit each ref pointed to, in which order, by whose hand.
- Git objects reachable from the refs, and non-git records (changes, reviews, issues) anchored by digest.
- The repository's identity, `RepoId`: the root ed25519 public key, fixed at genesis.
- The ability to continue the project under that identity on another host.

Adversaries:
- A hostile or coerced host. It runs the server, holds the log signer key, and may hold the root key (custodial).
- A network attacker between client and host. TLS is assumed; the log makes a TLS failure detectable, not harmless.
- A malicious mirror, or anyone handing out a bundle.
- A contributor or agent holding a valid token, possibly over-scoped or stolen.
- A thief of any one key (root, signer, principal, instance, witness).

## 2. Trust anchors and keys

| Key | Held by | Can do | If stolen or lost |
| --- | --- | --- | --- |
| Root (`RepoId`) | Owner; also the host if custodial | Sign `Genesis` and `SetSigner`: choose who signs the log | Theft: the thief can `SetSigner` to its own key and fork the log at any point. Loss: no future signer change. No rotation or recovery in v0. |
| Log signer | Host (a self-hoster may use the root key) | Sign every `RefUpdate` and `Record` entry and every checkpoint | The thief can append any ref move or record and sign checkpoints for a fork. Evidence names the key, not the person. Loss: the log stops until a root-signed `SetSigner`. |
| Principal (person, agent) | That principal | Sign push certificates (`sign_push`); mint tokens (`Token::mint`); issue `AgentCert` | The thief can sign writes as that principal and mint tokens up to the principal's `RepoAcl` rights on every instance that knows it. |
| Instance key | Host | Mint tokens for any subject, bounded by that subject's `RepoAcl` rights | The thief can act as any principal on that instance within their rights; such writes are host-attested only. |
| Witness | Independent party | `SignedCheckpoint::cosign` | The thief can cosign a fork. No witness set exists yet. |

## 3. What a hostile or coerced host CAN do

| Action | Detectable? | By whom, with what evidence |
| --- | --- | --- |
| Refuse service, stop serving the repository | Yes, trivially | Anyone. Not prevented. The remedy is portability (section 8). |
| Append entries nobody asked for: move or delete a ref, anchor a `Record` | Visible, not prevented | Anyone who reads the log: the entry is permanent and signed by the signer key. |
| Attribute a write to a principal who did not make it, when the entry has no `actor_sig` | Not distinguishable from a real write | The `Actor` fields are host-asserted. Only an entry with a valid `actor_sig` binds the principal, on whose behalf it acted and the token id. Stock git clients cannot produce one. |
| Replay a push certificate when a ref returns to an earlier value | No | Open problem 3. |
| Set any `time_ms` | No | Entry and checkpoint times are the host's clock. Nothing verifies them. |
| Split view: show different logs to different clients | Only by comparison | Two checkpoints for one `RepoId`, signed by the same signer, that no consistency proof connects. Needs clients, mirrors or witnesses to compare. No gossip exists. |
| Freeze: keep serving an old valid checkpoint | Only by a client that saw a newer one | Nothing bounds checkpoint age. |
| Rewrite history after genesis for a client that holds nothing | No | A fresh client verifies a fully re-signed log as valid (shown at the end of `a_mirror_detects_a_rollback_and_a_fork_and_keeps_the_evidence`). |
| With the root key (custodial): anything the owner can | As above | Including `SetSigner` to a new key and a new fork from any point. |
| Stop serving content and say so: a `Withheld` entry (decision 0047) | Yes, by design | Anyone who reads the log: what is withheld, since when, the reason class and reference, under the host's key. Mirrors and bundles then treat that content as optional and report it; copies that already hold it keep it. Nothing checks that the stated reason is true. |
| Stop serving content without saying so | Yes, as a failure | A mirror or a bundle check fails on the missing objects of a ref that no withholding covers. |
| Delete objects no current ref reaches; withhold record content | Content no; existence yes | The log still names every old `Oid` and every record digest. Bundles count earlier ref values they do not carry (`history_missing`) and list absent records (`records_missing`); a mirror does not fetch earlier values. |
| Read everything; see who pushed what and when | Not hidden, by design | Non-goal (section 8). |

## 4. What it CANNOT do without detection

Each row assumes the client verifies (`verify_log`, `verify_bundle` or `mirror`), and where noted that it kept an
earlier checkpoint. Tests are in `crates/jit-trust/tests/log.rs` (L) and `tests/portability.rs` (P).

| Attack | Mechanism | Test |
| --- | --- | --- |
| Drop an entry from the middle | `seq` must equal position (`BadSequence`); `prev` must chain | L `a_dropped_entry_is_detected` |
| Reorder entries | `BadSequence` | L `reordered_entries_are_detected` |
| Insert or duplicate an entry | `BadSequence` | L `an_inserted_or_duplicated_entry_is_detected` |
| Alter any byte of a stored entry | Canonical decoding, strict ed25519 verification, chain | L `any_altered_byte_is_detected` |
| Alter one entry and re-sign it with the signer key | The next entry's `prev` no longer matches (`BrokenChain`) | L `an_entry_altered_and_resigned_by_the_host_breaks_the_chain` |
| Rewrite from some point and re-sign everything after (needs an earlier checkpoint) | The old checkpoint does not match; no consistency proof exists; the two checkpoints are evidence | L `a_history_rewritten_from_some_point_on_fails_against_what_was_seen_before`; P `a_mirror_detects_a_rollback_and_a_fork_and_keeps_the_evidence` |
| Drop the last entries (needs an earlier checkpoint) | `CheckpointMismatch`; `MirrorError::Rollback` | L `dropped_last_entries_are_detected_against_a_checkpoint_seen_before`; P as above |
| Sign entries with any key but the signer in force | `WrongSigner`, `BadSignature` | L `only_the_signer_in_force_can_extend_the_log` |
| Hand the log to another key without the root key | `SetSigner` needs the root key | L `the_host_cannot_hand_the_log_to_another_key_but_the_root_can` |
| Pass off another repository's log, or a genesis the root did not sign | `WrongRepo`; `WrongSigner` at 0 | L `a_log_is_bound_to_its_repository_key` |
| Move a ref from a value the log never gave it | Replayed compare-and-swap (`RefMismatch`) | L `a_forged_update_from_a_value_the_ref_never_had_is_detected` |
| Reuse an actor's push certificate on another write, or change for whom it acted | `BadActorSignature` | L `an_actor_signature_binds_the_write_to_the_actor`, `an_actor_signature_also_covers_for_whom_and_under_which_token` |
| Serve an object whose content differs from its id, or leave out an object a ref needs | Every object is re-hashed (SHA-1 with collision detection); the closure of every ref must be complete | P `a_mirror_refuses_altered_or_withheld_content_and_changes_nothing`, `a_tampered_or_misattributed_bundle_is_refused` |
| Serve different content for an anchored record | The content must hash to the digest in the log | P `a_mirror_refuses_altered_or_withheld_content_and_changes_nothing` |
| Edit the log file on disk behind the server | `RepoLog::open` re-verifies everything | L `the_file_store_persists_discards_a_torn_tail_and_exposes_tampering` |

"Detection" means the client gets an error and changes nothing. It does not mean the honest data is recovered: that
needs a copy elsewhere, which is what mirrors and bundles are for.

## 5. What a client MUST check

State to keep per `RepoId`, outside the host's control: the last verified `SignedCheckpoint` and the log up to it (or
at least its size, root, head, signer and refs). `FsRepo` keeps exactly this under `<data>/trust/<RepoId>/`. A client
that keeps nothing gets only the first rows of section 4.

(a) First clone.
1. Get the `RepoId` from a source the host does not control (the project's site, a signed release, a person). A
   `RepoId` read from the same host proves nothing.
2. `FsRepo::open(data, repo, format)` then `sync_from(&remote)`; or fetch all entries and the latest checkpoint and
   call `verify_log(repo, entries, Some(&cp))`, then check each object as `objects::walk` does.
3. Check the refs you use equal `VerifiedLog.refs`. Refs served outside the log are not covered.
4. If witness keys are configured, require `cp.witnessed_by(&trusted) >= k` (designed; no witnesses exist).
5. Keep the checkpoint.

(b) Every later fetch. `mirror` does all of this; a client doing it by hand must do the same.
1. Fetch the new checkpoint. Smaller than what you hold: rollback. Stop and keep both checkpoints.
2. Equal size: require an equal root. A different root with a valid signature is equivocation evidence.
3. Fetch the entries since your size and replay them on top of your state (`RepoLog::preview`). A consistency proof
   alone is not enough: it shows append-only, not that the new entries obey the signer and compare-and-swap rules.
4. Check `verify_checkpoint(&new, repo, signer)` with the signer in force after the replay, not the key the checkpoint
   names. A `SetSigner` in the new range changes it. Check the checkpoint's root equals the replayed root.
5. Fetch and re-hash the objects the new refs need; check each record against its digest.
6. Only then extend your log and replace the stored checkpoint.

A light client that does not replay entries can check only `verify_consistency(old.root, new.root, proof)` and
`verify_inclusion` for the entries it cares about. It then trusts the host on the signer in force and on ref values.

(c) A mirror. As (b), and also:
1. Keep the checkpoint in a separate file from the log. `FileLogStore::open` discards a torn tail, so a log file cut
   short looks like a shorter valid log; `FsRepo::open` refuses a log shorter than its stored checkpoint.
2. On `MirrorError::Rollback` or `MirrorError::Fork`, keep the local copy unchanged and publish both checkpoints.
3. Know the limit: `mirror` fetches what the current refs reach. History that was force-pushed away before the first
   sync is not fetched, and nothing checks the remote still has it.
4. Serve your checkpoints to others so that views can be compared.

(d) Importing a bundle.
1. Call `verify_bundle(input, Some(repo))` with the out-of-band `RepoId`. With `None` the bundle proves itself under
   whatever key it names: check `BundleSummary.repo` yourself.
2. `import_bundle` refuses a bundle that is behind the local log or diverges from it, and writes the log last.
3. Read `BundleSummary.records_missing`: records the log anchors whose content the bundle does not carry.
4. A bundle says nothing about freshness. Compare its checkpoint with any other view you can reach.

## 6. Mirrors and malicious bundles

A mirror or a bundle maker holds no signer or root key, so it cannot forge entries or checkpoints, and it cannot pass
off another repository: everything is bound to `RepoId`. It can serve an old prefix (freeze), leave out record
content (reported as missing), refuse service, or serve one side of a host's split view. It can serve a validly
signed fork that a stolen or custodial root key created; nothing in v0 says which fork is right. Objects no ref
reaches and records the log does not anchor are refused, so a bundle cannot smuggle content in. Cost limits: a bundle
is verified in memory in v0, with each object or record capped at `MAX_BUNDLE_ITEM` (1 GiB) and each entry at
`MAX_ENTRY_BYTES` (16 MiB); there is no cap on the total, so a client must bound the bytes it is willing to read.

## 7. Tokens and agents

Tokens are Biscuit public-key bearer tokens, attenuable offline (`Token::attenuate`). The verifier
(`Authority::authorize`) caps size (4 KiB) and blocks (8) before parsing, accepts only blocks of one fixed shape,
intersects the typed scopes itself and never runs Biscuit's Datalog engine, so a holder cannot widen a token or make
verification expensive by appending a crafted block (tests in `token.rs`). The issuer, the revocation list and the
`RepoAcl` are consulted on every call, cached tokens included.

- A stolen token works for anyone until `not_after_ms`, within its scope. Nothing binds a token to its holder's key.
- A token authenticates one principal (`Grant.actor`): its issuer, or for an instance-minted token the subject the
  instance vouches for. Sub-agent names in a token (`Grant.delegate`, `chain`) are written by whoever held it and
  prove nothing: anyone holding a token can name any principal. Ownership and permissions must key on `actor`
  (decision 0045); a delegate is proven only by a push certificate from its own key.
- Attenuation narrows what a sub-agent gets. It does not protect the parent token, and the parent cannot see or
  revoke a child it did not record: revoking a parent block's id revokes every child; revoking one child needs its id.
- A token minted by a principal's own key is bounded by that principal's `RepoAcl` rights on the instance verifying
  it. A token minted by the instance key is bounded by its subject's rights.
- An over-scoped token can make writes that are valid and permanent in the log. The log records `token_id`, which
  identifies the token, not the hand that used it.
- `AgentCert` has an expiry and no revocation.

Mitigations: short expiry, narrow `refs` and `paths`, protected refs that only the merge queue moves, and push
certificates from the agent's own key.

`refs/queue/` is the server's own: the landing queue pins its candidates there, and no token writes under it,
an administrator's and the instance root's included (a token that may write and not read gets the answer for
a repository it cannot see). It is refused twice: at authorization, before a push is
read (the API's trust adapter, `RESERVED_REFS`), and inside the ref transaction (jit-collab's guard). Reading
there is as for any ref.

The queue's pinning and unpinning of a candidate there (its own cause, `queue-pin`, used for nothing else) are
**not entries of the signed log**; everything else is, a landing included, whatever ref it moves: a candidate pin is scratch state,
and what the queue did is recorded by the landing (the target's ref update and the anchored `landing` record
naming the rule). What this costs: a host could pin and unpin arbitrary commits there without a trace in the
log. It gains nothing by it that it did not have: a host can hold any object it likes without telling anyone,
the prefix is not advertised, and nothing under it reaches a clone, a bundle or a mirror. A ref there moved by
anyone, or by any other cause, is still logged. Under a withholding a candidate is handed out or refused by
the rules in `docs/contracts/jit-trust.md` ("Under a withholding").

**A refs withholding hides refs, not content.** It covers names: the host refuses those refs and what only they
reach. Content that another served ref also reaches (a branch built on it, a change's pin, a tag) stays served.
Someone who wants a commit kept available after its branch is withheld needs only one other ref that reaches it,
made before or after; someone complying with an order about content must cover every ref that reaches it or
withhold the whole repository, and should check with a fresh clone. The stronger meaning (a ref built on withheld
content is itself not served) is decision 0070 and is not built.

## 8. Non-goals, concretely

The spec excludes anonymity, hiding content from the operator, and evading lawful process against a user. So: a host
that receives a lawful takedown can remove the repository at that host, and this design does not stop it. Every host
sees content and metadata. The log is readable by anyone who can read the repository: who pushed what, when, and
under which token id. What the design gives instead: a removal or alteration at one host shows up as a refusal or as
a signed entry, not silently; it cannot change what mirrors and bundles already hold; and when the owner holds the
root key, one root-signed `SetSigner` on any mirror's copy continues the project under the same `RepoId` with no help
from the old host (P `the_owner_moves_the_repository_to_a_mirror_without_the_old_host`). With a custodial root key
that last property does not hold, which is why a host hands the key over on request (`Trust::hand_over_root_key`).

An account is not needed to leave. Whoever holds the root key can present a `RootRequest` (signed with that key,
addressed to the host, valid for minutes) and receive the bundle; the host consults no account, token or grant
(`tests/key_holder.rs`, decision 0049). A suspension therefore governs writing at that host, not access to one's
own history. It is not a way around a withholding: what the host withholds stays out of that export too. A stolen
root key gives the thief the same export.

## 9. Open problems and planned work

Ordered by how much each weakens the headline claim.

1. No comparison of views. Split view and freeze are undetectable unless clients compare checkpoints. Cosigning
   exists as a type (`Cosignature`, `witnessed_by`), but `cosign` does not itself check consistency, the cosigned
   message has no witness time, and there is no witness network or gossip. Until then "no silent alteration" holds
   only for clients that kept an earlier checkpoint. And no client keeps one today: there is no route for a
   consistency proof, and neither `neo verify` nor the log page remembers a checkpoint. What to build, and the
   options for a reader who holds nothing, are decision 0073.
2. No fork-choice rule for migration. "The log with the root-signed `SetSigner` wins" is not in the code:
   `verify_log` accepts the old host's fork and the owner's fork alike. If the old host appended entries after the
   mirror's copy ends, clients that saw them hold checkpoints the moved log cannot extend, and they will reject the
   legitimate move as a fork. A rule is needed (for example: accept divergence only where the other branch's first
   entry is a root-signed `SetSigner`), plus tooling that hands clients the evidence.
3. Push certificates are optional and not bound to a position. `push_message` signs the repository, the full `Actor`
   and the body. If a ref returns to an earlier value (revert, force-push, delete and recreate), the host can replay
   an old certificate. Planned: bind a nonce or `prev`, and make client-signed pushes the default for `jit`. Until
   then every entry made through today's clients is attributed on the host's word.
4. Root key: no rotation, no recovery, no shared control. Theft lets the thief fork from any point; loss freezes the
   signer for ever. The root key can also equivocate: two different `SetSigner` entries at one position.
5. Freshness. Nothing bounds checkpoint age. Planned: witness-signed times and a client maximum age.
6. Records can be re-anchored. Nothing forbids a second `Record` entry with the same kind and id; bundles and mirrors
   carry the content matching the newest digest. The earlier digest stays in the log, so the change is visible, but
   a reader showing "the latest" shows the newest. Records need revision rules and actor signatures.
7. Retention. Objects no current ref reaches are not required by any check. The log keeps every old `Oid`, so a
   mirror could check availability; no code does. Bundles do not carry them.
8. The spec sentence "a host cannot rewrite or drop history without it being provable" is true only against someone
   who holds an earlier checkpoint or entries. For a client with no prior state the host can serve any log after
   genesis, or any log at all with a custodial root.
9. SHA-1. v0 repositories use `ObjectFormat::Sha1`. Hashing uses `sha1-checked` and treats a detected collision
   attack as an error; the path is not exercised by a test with a real collision. The log itself is SHA-256.
10. Startup cost. Opening a log re-verifies every signature: about 43 µs per entry, so tens of seconds per million
    entries. A host under pressure to restart quickly must not skip it silently; a signed local snapshot is planned.
11. Wiring. `jit-server` registers `HostLog` with the store when it starts, so every ref update, by git or by the
    API (the landing queue's own pins under `refs/queue/` excepted, above), is logged inside the transaction that moves the ref: there is no push to a running server that is not
    logged (the earlier sentence here said otherwise and was stale). A ref update that names no actor is refused.
    A custodial root key seed sits unencrypted in the metadata store.
12. Leaving a hosted instance: what you can and cannot take today. **A verified copy: yes.** Anyone who can read
    a repository can clone it with git and verify its signed log (`neo verify`), pinning the repository's id, and
    can mirror it; the copy proves what the host said and when. **A signed bundle over HTTP: not yet** (the
    library writes one, `export_bundle`; the route `GET /v1/repos/{repo}/bundle` is being built). **The signer:
    not yet.** Moving a repository's log to another host as *the same repository* needs its root key, to sign the
    hand-over (`SetSigner`). For a repository created on a hosted instance the instance made that key and holds
    it; the library can hand it to the owner (`Trust::hand_over_root_key`), and **no route does**. So today a
    hosted user can leave with everything that proves the history, and cannot yet continue that history elsewhere
    under the same identity; another host would start a new repository from the copy. Whether and how the key is
    handed over is the operator's decision, not yet taken: once the owner holds it, the host can no longer sign
    a hand-over on the owner's behalf, and a lost key cannot be replaced.
