# The registry protocol

The protocol is what the `jadpo` tool and the registry application are each
built against. It is served at `https://jadpo.dev/registry/v1/` as JSON,
with failures in the [failure envelope](/docs/http.md), and is versioned by
its path. Reads need no sign-in. The `jadpo` tool never signs in: nothing
it can send makes a release live.

| Request | Answers |
|---|---|
| `GET packages/@{publisher}/{name}` | The package: description, kind, code name and label, publisher (verified, official), maintained or its successor, and each release's version, digest, time, and whether it is yanked or urgent |
| `GET packages/@{publisher}/{name}/releases/{version}` | One release: repository, tag, commit, digest, its `surface.jadpo_record`, facts, change record, written account, compatible Jadpo releases and its index in the log |
| `GET archives/{digest}` | The release's files as a tar archive whose files, unpacked, have that digest, as the lock computes it |
| `GET log/head` | The log's size and root hash |
| `GET log/signed-head` | The log's size and root hash, with the `key` that signed them and its `signature` |
| `GET log/proof/{digest}?size=` | The release's log entry, its index and the hashes that prove it is in the log of that size |
| `GET log/consistency?from=&to=` | The hashes that prove the log of size `to` extends the log of size `from` |
| `GET search?q=&from=&to=&kind=` | Ranked results, the standard library's first, each naming a package and declaration, with why it matched |
| `POST advisories/query` | Given installed packages and versions, the advisories against them, each naming its declarations, versions and the packages carrying copies |
| `POST fingerprints/query` | Given `prefixes`, each the first five hex digits of a source fingerprint, every public function and action of a release that isn't yanked whose `source` fingerprint starts with one: its `package`, `version` (the newest with that fingerprint), `declaration` and `source` |
| `POST decode-failures` | Given a `package`, `version`, `operation` and the `shape` of an answer its scheduled contract run couldn't decode, keeps the report and answers its `id` |
| `POST releases` | Given a repository, a tag, `dry_run` and optionally `publisher`, starts a release (or a dry run) and answers its id |
| `GET releases/{id}` | Its state (`verifying`, `failed` with the bar's rows, `pending`, `cancelled`, `live`), with its facts and change record once checked |

- **The log** is an append-only Merkle tree of releases, hashed as RFC
  6962 does with SHA-256. Each leaf is one line, `@acme/postcodes 2.1.0
  sha256:…`, so a logged digest can't stand for another package's or
  version's release. `add` and `update` keep the last head they saw in
  `.jadpo/registry_head`, ask `log/consistency` from its size to the new
  head's and refuse a head the proof doesn't show extends it, then ask
  `log/proof` at the new head's size and refuse a release it doesn't show
  is in the log. Proofs are made by RFC 6962's definitions and checked by
  RFC 9162's algorithms; the root is never sent with a proof, since a
  client checks it against the head it holds.
- **A head can be signed.** `GET log/signed-head`'s `signature` is an Ed25519
  signature over the one line `jadpo-log-head {size} {root}`, its root as 64
  hex digits, written as a `Bytes` is, and its `key` the `PublicKey` it
  verifies against. A registry keeps its signing keys as data and signs with
  [`crypto.sign`](/docs/hashing-and-cryptography.md#signatures), so it can change them.
  `jadpo` holds the public registry's keys; when it holds any for the registry
  it asks, it asks for this row instead of `log/head` and refuses a head with
  no signature, a signature that isn't its key's, or a key it doesn't hold
  (`install.not_proved`). `JADPO_REGISTRY_KEY` gives a stand-in's keys,
  comma-separated.
- **A placeholder fills a whole segment**, so `{publisher}` is the handle
  with its `@`: `GET packages/@acme/postcodes` is `packages/{publisher}/{name}`
  with `publisher` `@acme`. Each part of a scoped name is lower-case
  letters and digits, starting with a letter, with single `-`s between
  them, at most 39 characters.
- **Every answer's field is always sent**, `null` where it has no value,
  as a Jadpo application writes an output; sizes and indexes are JSON
  numbers. A release's facts are the table in [What a release
  shows](/docs/the-public-registry.md#what-a-release-shows), less the Jadpo releases it works with,
  which are the release's own field since they grow after it is checked.
  `publisher` is the handle `package.jadpo` names, `null` where it names none,
  which only a release that failed can have.
  A change record's entry is its `declaration`, its `kind` (`function`,
  `type`, `provider`), `change` (`added`, `removed`, `retyped`,
  `new_failure`, `new_host`, `personal_data_sent`, `behaviour_changed`),
  `detail` and `why`.
- **A release refused for its publisher** is `failed` with a bar row whose
  `check` is `publisher` and whose `detail` says why, which `jadpo package
  publish` shows as `publish.publisher_mismatch`. An optional `publisher`
  on `POST releases` lets the registry refuse at once, as
  `repository_refused`, a repository another publisher releases from
  (recorded 2026-11-07).
- **Its failures** are `package_not_found`, `release_not_found`,
  `archive_not_found` and `release_request_not_found` (404), `not_in_log`
  (404, also for a release logged after the size asked about),
  `size_past_head` (422, a size past the head or sizes the wrong way
  round) and `repository_refused` (422, not a repository reached over
  HTTPS). `POST releases` and `POST decode-failures` answer 202, the others
  200.
- **`POST fingerprints/query`** is how `jadpo suggest` finds an app's
  copy of a published function ([Functions that already
  exist](/docs/functions-that-already-exist.md)). It sends prefixes,
  at most 1,000 a request and each five lower-case hex digits, never a
  fingerprint, and the registry answers each prefix's whole bucket, so it
  learns nothing of which function an app holds; a prefix of another
  length, or more than 1,000, is 422 `invalid_input`. The fingerprints are
  the `source` ones `jadpo package verify` writes for each release
  (recorded 2026-11-08).
- **`POST decode-failures`** holds a shape and never a value. `shape` is a
  list of at most 1,000 members, each a `path` of at most 256 bytes from the
  answer's root, `$.data[].id`, and its `kind`: `object`, `list`, `text`,
  `number`, `bool` or `null`. A member name stands for itself only when it is
  letters, `_` and `-` of at most 64 bytes, starting with a letter; any other,
  a map keyed by a customer's id for instance, is `*`, so a value can't leave
  as a name. Anything else is 422 `invalid_input`.
- **The lock's `registry` source** records the scoped name:
  `package Postcodes.v2 version 2.1.0 registry @acme/postcodes digest
  sha256:…`.
- **The registry application's served OpenAPI is checked against this
  table** by a conformance test, `jadpo package protocol <document>`
  ([Tooling](/docs/commands-for-packages.md#jadpo-package-protocol)), also run against a
  local registry built from the same table, so neither side drifts. Every
  row must be served below `/registry/v1/` with its placeholders, query
  members, body, status, answer and failures, open to a caller who hasn't
  signed in, and nothing else but `openapi.json`; shapes are compared
  through any `$ref`, and what a Jadpo application adds that the table
  doesn't constrain (the runtime's shared failures, `x-jadpo-` keywords,
  an `Idempotency-Key` header) is left alone.
