# The registry client: what is built The sheet of the index client of `docs/package-registry-design.md` (stage 4; decisions D141a and D158a in `docs/decisions.md`). The design says what the registry is for and why; this sheet says what the code does today, and gives the **formats** that the registry service (stage 5, **not built**) must write. Where the two differ this sheet is the code. Nothing here is promised stable in 1.x unless a decision says so (D126a): the index format has a version (`format = 1` in the head and in the index's `config.toml`) so that a later one can change it, and a client that reads another format stops. **D158a reworked this client.** The git design (D141a to D148a: the index a git repository, owners that were domains or handles, owner and maintainer keys, a signature on every statement, the owner's own server, `request-handle` and `maintain`) was replaced when Davis decided the registry is a Cloudflare Worker with its own accounts (D157a). What the client reads now is a **signed head and pieces of files over https** (or from a folder). Nothing was ever deployed in the old format. The client is `compiler/src/index.tom` (the head, its signature and the files of the tree), `compiler/src/regclient.tom` (settings, the local copy, names, minimal version selection) and the lock and store half in `compiler/src/seeds.tom`. It needs `curl` (to fetch over https), `ssh-keygen` (OpenSSH 8.0 or newer, to check the head's signature) and `git` (to fetch a seed, as the git seeds do). **`tomato run`, `build`, `compile` and `test` never read an index and never use the network** (D117a): only `tomato seed add`, `install` and `registry add` and `update` do. ## Built, and what is not | Built | Not built (the service, stage 5, and the author's commands) | | --- | --- | | the signed head and pieces: `registry add`, `update`, `list`; the signature check through `ssh-keygen -Y verify`; the pieces checked against the head's hashes; a serial that does not go back | **the registry service itself**: accounts, sign-in, tokens, the write API, the verifier, the generator, the reviewers' page (design section 9; nothing exists on Cloudflare) | | the files of the tree: owners with their pins, seeds, versions, owner yanks, short names, reviewer yanks, the policy level | `tomato seed login`, `logout`, `publish`, `yank`, `unyank`, `request-name`, `endorse`, `score` (they call the service's write API, design section 9.5) | | `tomato seed add NAME[@VERSION]` for a **listed** seed (an alias, a short name, `owner/name`), `--registry`, `--allow-yanked`, `--test` | the snapshot tar for mirrors, the offline key, a warning for a head much older than the clock (design section 9.4) | | `--unlisted --git URL` for a seed the registry does not list; a bare unlisted `owner/name` refused with one line; a host shortcut names a listed seed by its repository | an explicit form of an unlisted seed in a `# seeds:` header (design section 19, question 15) | | the `# seeds:` header of a single file: listed seeds only | `[git-hosts]` (the user's own shortcuts) | | minimal version selection, over the index or over the lock alone; `source = "registry"` entries in `tomato.lock` with the owner's pin | | | `install` (with `--locked` and `--offline`), `verify`, `vendor` and every build for registry seeds | | | owner yanks and the reviewers' emergency yanks: `add` skips a yanked version, a named one warns, `honor_reviewer_yanks` | | | `update` (`--dry-run`, `--offline`, `--registry`, `--accept-owner-change`), `outdated`, `tree`, `why`, `search`, `info`, the yank warnings for a seed already locked | | | a built-in registry `tomato` (`https://seeds.tomatolang.com/index`) with **no key yet**: it cannot be updated until a release puts the registry's key in `builtin_keys()` of `regclient.tom` | | | the head's `[log]` table and the optional `log` field of a version are **read and ignored** (unknown fields are ignored) | **the transparency log's checks** (D172a, stage 10): the consistency check in `registry update` and `tomato seed verify OWNER/NAME@VERSION` (below); the `[unreachable]` warning; `info --online` | ## The user's settings (`${TOMATO_HOME:-$HOME/.tomato}/config.toml`) ```toml [registry] default = "tomato" # the registry `tomato seed add NAME` asks; the built-in `tomato` is the default until a registry of your own is added [registries.tomato] # one of your own with this name replaces the built-in one index = "https://seeds.tomatolang.com/index" # an https address, a file:// URL or an absolute folder: where head.toml, head.toml.sig and pieces/ are keys = ["ssh-ed25519 AAAA... the registry's key"] # the heads must verify against one of these; taken from here, never from the index honor_reviewer_yanks = true # false: a reviewer's yank is treated as absent (the owner's own yank always counts) [aliases] json5 = "acme/json5" # your own short names: `tomato seed alias NAME OWNER/NAME` ``` These are the user's: a project's `tomato.toml` cannot set any of them (a seed cannot make a user's tool pick another seed). Other tables of the file (`[build]`) are read by other code and left alone; an unknown key *inside* these three tables is an error (E679). A registry needs at least one key, or it is not fetched (E679): an index is used only when its head verifies against a key you set. The first `registry add` makes your registry the default. ## Commands ``` tomato seed registry add NAME URL --key KEY... [--default] write the settings, fetch the index, check it; a failed fetch or an index that is not an index leaves the settings file exactly as it was tomato seed registry update [NAME] [--allow-older] fetch the head again (all your registries with no NAME); the new files replace the old only when they check out tomato seed registry list the registries, the serial each local copy is at, and how many keys tomato seed alias [--list] the aliases; tomato seed alias NAME OWNER/NAME sets one; tomato seed unalias NAME removes it tomato seed add WORD [--registry NAME] [--allow-yanked] [--test] [--yes] tomato seed add --unlisted --git URL (--rev COMMIT | --tag TAG | --branch BRANCH) [--subdir DIR] [--test] [--yes] tomato seed update [NAME...] [--dry-run] [--yes] [--offline] [--registry NAME] [--accept-owner-change OWNER] tomato seed outdated | tree | why NAME what the lock holds: newer versions, the graph, who needs a seed tomato seed search TEXT | info NAME[@VERSION] [--registry NAME] read the registry's local index; no project needed ``` **`registry update`** fetches `head.toml` and `head.toml.sig`, checks the signature against your keys (E687 if none verifies), checks the serial against the copy you have (a **lower** one is refused unless `--allow-older`: a mirror that serves an old index would hide a yank), fetches each piece the head names, checks its sha256 against the head's, unpacks it with `std/tarfile` (no absolute name, no `..`, no link) and only then puts the tree in place, with `serial` and `head.toml` beside it. A failure at any step leaves the old copy working. It says `registry NAME: fetched the index at serial N (S seeds; policy level 0: structural checks only)`, or `updated serial A -> B`, or `already at serial N`. **`add WORD`** takes a **listed** seed. `WORD` is `NAME` or `NAME@VERSION` (`@1.2.0`: that exact version, yanked or not). A word with a slash is a full name: the owner (a registry username, no dot) and a seed. A word without one is, in this order: **your alias**, **the registry's short name** (an entry of `names.toml`), else a lookup error (exit status 1) that lists the seeds of that name in the index so you can pick one by its full name. `add` prints what it is about to do before it writes anything, never asks except about foreign symbols (as for git seeds), writes the **full name** and the chosen version as the minimum into `[seeds]` (`[test-seeds]` with `--test`; a lower version never lowers a higher minimum on the same line), and locks. The summary is: ``` acme/json5 1.2.0 owner acme (account made 2026-11-01), 5 versions, similar to: none repository: https://git.example.net/acme/json5.git at 9f2c1d..., first listed 2026-11-02 imported as: from json5 import ... status: listed (policy level 0: structural checks only), no endorsements or test results collected by this client short name: json5 (granted 2026-12-03 by a reviewer of fixture) ``` An owner the index marks `similar = "other"` gets a warning line, and one that has a `recovered` date a note. **Unlisted seeds (design section 1.7).** A seed the index does not have is refused with one line, `NAME is not listed in the registry REG; to use an unlisted seed: tomato seed add --unlisted --git URL --rev COMMIT`. `--git` without `--unlisted` is E621. A **host shortcut** (`gh:USER/REPO`, `gitlab:USER/REPO`, `codeberg:USER/REPO`, `srht:~USER/REPO`) is expanded to its https URL and names the **listed** seed whose source (the URL that applies, compared without `.git`, a closing slash or the case of the host) is that repository; with none it is refused with the same hint, and `--rev`, `--tag`, `--branch` and `--subdir` with a shortcut are E621 (the version comes from the registry). The lock and the manifest hold the owner's `owner/name`, never the shortcut. The `# seeds:` header of a program (`NAME>=VERSION`, D117a) names listed seeds: one the index does not have is the same refusal, worded for a program (a project is where `--unlisted` records one). **`update`** raises the minimum of each registry seed of `[seeds]` and `[test-seeds]` (the named ones, or all) to the newest **listed** version (not yanked, not a pre-release) on the compatible line of the version now locked, writes it into the manifest as `add` does, and locks again; the lines say what moved (`1.0.0 -> 1.2.0`, the hashes, and the pin if it changed). `--dry-run` writes nothing. **The lock pins the owner's pin**: a seed whose owner now has another `pin` in the index (control of the account moved by a reviewer's act) is E686 unless `--accept-owner-change OWNER` names that owner. It reads the registry's local copy: run `registry update` first (`--offline` refuses). **`outdated`** compares the lock with that copy: a newer version on the line, a newer line, whether the locked version is yanked, and the date it was last published. **`tree`** and **`why`** read the lock only. **`search`** lists the seeds whose name or short name holds the text, those with more versions first (at most 50); **`info`** shows the owner (its age, a `similar` mark, a `recovered` date), the repository, the short name, the versions newest first with their yanks, the entries of that seed's file that are left out, and with `@VERSION` that version's commit, hash and requirements. None of them fetches anything. **Yank warnings** (`warning: acme/json5 1.3.0 is yanked by a reviewer of the registry ...`) are printed by `tree`, `verify`, `outdated`, `install` and `update` for locked seeds when the registry's local copy exists and says so; they never stop a build, a lock or an install. ## The lock `tomato.lock` gets a top-level `index = "NAME"` (the registry's name in your settings, not its URL; one lock never mixes registries) and entries like ```toml [[seed]] name = "acme/json5" version = "1.2.0" source = "registry" git = "https://git.example.net/acme/json5.git" commit = "9f2c1d...40 hex" pin = "p-4kq9x2" # the owner's pin in the index when this was locked hash = "sha256:..." modules = ["json5"] seeds = ["other/strutil 0.4.1"] # what it needs, as its index entry says ``` `path` (a seed in a folder of its repository) is written when the entry has one, and makes the lock's `version` 2, as for a git seed. The lock holds **everything a build needs**: `install --locked`, `install --offline`, `verify`, `vendor` and every build read the lock and the store only. A lock records no yank. When the lock covers the manifest (the selection below, run over the lock's own `seeds` lists, gives exactly the locked seeds), `install` does not read the index at all and fetches only what the store lacks; otherwise it reads the registry's local copy, selects again, and refuses an entry that disagrees with the lock about a version it already holds (a published version never changes: E684). The unlisted seeds (`source = "git"`) are as they were. ## Resolution (design section 4) The selection is minimal version selection: the highest minimum anyone asks for (the manifest, and the `seeds` of the selected versions' entries), repeated until it stops changing, so a bump drops the requirements of the version it replaced. The version chosen must exist; two requirements on different compatible lines of one seed (`1.x`; `0.y`) are E683 naming who asked for each; `add` chooses the newest version that is not yanked and not a pre-release; a pre-release is used only when a requirement names it. `[test-seeds]` takes part in one selection with `[seeds]`, and a seed only the tests reach is `test_only`. A registered seed's own `tomato.toml`, at the entry's commit, must say what its entry says (its name, version, the seeds it needs, its modules): otherwise E684. ## The index (format 1): what the client reads `head.toml` and its signature, then pieces. The design (section 9.3) has the whole description; the client reads: ```toml # head.toml (signed: head.toml.sig is `ssh-keygen -Y sign -n tomato-seeds-index-v1` over these exact bytes) format = 1 # another number stops the client (E680) name = "tomato" # display only serial = 1042 # a whole number from 1; a client keeps the highest it has seen and refuses a lower one generated = 2026-12-01T10:15:00Z # display only previous = "sha256:..." # omitted for the first serial [log] # optional (D172a): the transparency log's size and root, covered by the head's signature; this client ignores it for now origin = "seeds.tomatolang.com/log" size = 1042 root = "ab12...64hex" [[piece]] path = "pieces/ab12...64hex.tar" # always pieces/ and the piece's own sha256 and .tar: a path cannot leave the folder sha256 = "ab12...64hex" size = 123456 # optional ``` The pieces are tar files (`std/tarfile`: plain or gzip) of the **tree**: all the pieces are unpacked into one folder, and the files of two pieces never share a path. | File of the tree | Holds | | --- | --- | | `config.toml` | `format = 1` (required, and equal to the head's) and `name` | | `policy.toml` | `version`, `notice_days`, `[listing]`, `[short_name]`, `[demotion]`. The client reads which `[listing]` requirements are on (`level_zero`) for the summary line; it enforces nothing | | `owners/USER.toml` | `[owner]`: `pin`, `created`, and optionally `similar` (the older username this one is within one edit of) and `recovered` (the date a reviewer recovered the account) | | `seeds/USER/NAME.toml` | `[[source]]` (`git`, `path`, `mirrors`; the last applies), `[[version]]`, `[[yank]]` (the owner's, while it stands) and `[moved]` (`to`) | | `names.toml` | `[[name]]` (`name`, `seed`, `granted`): the short names that stand now; one seed per name (the first of two is kept) | | `yanks.toml` | `[[yank]]` (`seed`, `version`, `kind`, `reason`, `yanked`): the reviewers' emergency yanks that stand now (listing only) | A `[[version]]` has `version`, `commit` (40 hex digits), `hash` (`sha256:` and 64 hex digits), `tomato`, `modules` (at least one), `seeds` (a table of name to minimum version) and optionally `published` (the author's date) and `listed` (when it entered the index), and, for the service of D167a (versions come from git tags), `tag` (the tag it was recorded from), `tag_moved` (the date the tag was later seen on another commit; the registry kept the first) and `log` (the position of the version's leaf in the transparency log, D172a). The client ignores all three for now. **`tree` and a `hash` that may be absent (D177a, proposed, not built in the client: stage 10 confirms the name).** The service always records git's **tree oid** of the seed's folder at the version's commit (`COMMIT:SUBDIR`, the root tree for a seed at the root) and may offer it as `tree` (`git-sha1:` and 40 hex digits, or `git-sha256:` and 64 for a repository in that format; the algorithm is part of the value). It records the client's `hash` (**seed hash v1, whose definition is not changed**) **only when the tree was small enough to read**, so the entry of a large seed has a `tree` and **no `hash`**. Today's client requires `hash` (an entry without one is *left out and noted*, below), so **stage 10 makes `hash` optional when `tree` is there**, checks whichever the entry has (the `tree` check is git's own: `git rev-parse COMMIT:SUBDIR` in the repository the client fetched into, which covers a committed `builds/` that seed hash v1 leaves out), and a lock line for `tree` is optional. The transparency log's `version` leaf carries `tree` and `hash` (or `-`) in the same way (architecture 24.2). A seed's file may also have an optional `[unreachable]` table with `since` (the registry could not read the repository for a long time; listing-only, D174a): ignored for now. An entry that is not well formed (a bad commit, a version that is not one, a version twice: the first stands) is **left out and noted**; `tomato seed add NAME@VERSION` and `info` say which. **A file says what is true now; there is no history in it.** Unknown fields and files are ignored, so the registry may add them without a new format; one that changes the meaning of an old one needs a new `format`. A tree has no signatures inside: the head's signature covers the hash of every piece, so every byte. ## The transparency log (D172a) The registry keeps an **append-only Merkle tree** (RFC 6962 hashing) of every recorded version and every yank, unyank and takedown, and the signed head carries its size and root (`[log]`). The Worker serves the checkpoints, tiles and proofs. Client verification is **stage 10 work**. The exact **proof format and paths are not promised** in 1.x. The client will check (`docs/seed-registry-architecture.md` section 24): - **`tomato seed registry update`** keeps the last log head it accepted and, for a larger size, verifies a **consistency proof** from it; a smaller size, the same size with another root, or a head with no log after one with a log is refused (E687) and the old copy keeps working. The first fetch of a registry stores its head. - **`tomato seed verify OWNER/NAME@VERSION`** rebuilds the version's leaf from the local index and verifies its **inclusion proof** against the stored head, fetching the proof from the registry (and storing it, so a later offline check works). Offline with no stored proof it says "not checked" and exits with a status that is not success. (`verify` with no argument keeps its meaning: it re-hashes the store against the lock.) - `run`, `build`, `compile`, `test`, `add` and `install` never touch the log or the network (D117a). ## Errors E679 the settings (`[registry]`, `[registries.NAME]`, `[aliases]`, a registry name, an index address or a key, the words of `registry`, `alias`, `unalias`; a registry with no key, or the built-in one before the registry has its key); E680 the index (no `config.toml`, another format, not TOML); E681 `ssh-keygen` is missing; E682 a name or version that the registry does not list (a seed it does not have is unlisted), or a word that is not an alias, a short name or a seed name; E683 requirements that cannot all be met; E684 a seed that is not what its entry says, or a lock and an index that disagree about a published version; E685 an owner's malware yank without `--allow-yanked`; E686 the owner's pin changed (`update`); E687 the registry's index cannot be fetched or does not verify (a file cannot be read or downloaded, the head is not signed by a key you set, a piece does not match the head's hash, the serial went back); E688 and E689 are retired. E571 is also raised when a name needs a registry and none can be used. E621 is a word of `add` that is no seed name or shortcut, a shortcut with `--rev`, or `--git` with no `--unlisted`. `docs/errors.md` has the one-line meanings. ## The fixture and the tests `tests/registry/` is a registry served as data: `index/` (made by `tomato run tests/registry/gen.tom` with the test-only key `keys/registry`, which is public test data: `head.toml`, `head.toml.sig` and the one piece in `pieces/`), `index2/` (the next serial: the owner of `acme` has a new pin and one more version of `json5`), `tree/` (the files inside the piece, to read), `seeds-src/` (the seeds' files), `tomato run --entry sources tests/registry/gen.tom DEST` (one bare git repository for each seed, with deterministic commits, so the ids in the index are the ones the script makes on any machine) and `commits.txt` and `fingerprints.txt`. The fixture holds seeds with owner and reviewer yanks, a short name that was granted and one that was released, a similar owner, entries that are not well formed, and seeds whose entries do not match what is at their commit. `dev/test.tom` has `t_registry_logic` (`tests/registry_logic.tom`, the reader's rules and the head's signature) and `t_cli_registry` (the commands, in parts). The sources are reached through a `git` shim that maps `https://git.fixture.example/OWNER/NAME.git` to the local repositories, and the index through a `curl` shim that serves `https://seeds.fixture.example/index/...` from the fixture: there is no network.