~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

docs: the README says what Monolith is, and the guides read plainly

Merged chadtmiller.com asked to merge into main from chadtmiller.com/monolith:docs/voice-pass
.claude/skills/docs/SKILL.mdnew+210−0
@@ -0,0 +1,210 @@
---
name: docs
description: Write or edit Monolith's README, docs/README.md or the guides in docs/guide/ (and compat/ and bench/ READMEs when touched). Use for any change to those pages, a voice pass, or a new guide. Not for spec/, which keeps its own voice.
---
# Writing the README and the guides
Read this before writing or editing `README.md`, `docs/README.md` or a page
in `docs/guide/`. It's adapted from marco's `docs/_style.md`
(github.com/jazware/marco), which is vlpds's and vlRelay's.
`spec/` isn't covered. The spec is what the server is built from, it's
cited section by section by the harness, and it says what is in its own
register. The guides are for people running the server or calling it, and
they link the spec for the detail.
## Where the pages go
- Every `.md` under `docs/` is a page of the site (`docs-site/content.mjs`).
`docs/README.md` is its overview, and each page's title is its first `#`
heading. The guides appear in the order `docs/README.md` lists them.
- `cd docs-site && npm run build` fails on a link to a file or heading
that isn't there, a method `spec/PDS.md` lists under no page, or a
variable the spec names in no table. Run it after every page you touch.
- Nothing private: no hostnames, IPs, home paths or real DIDs and handles
besides the project's own (`chadtmiller.com`, `knotless.dev`). Use
`pds.example.com`, `alice.pds.example.com`, `did:plc:aaaa…`.
## Current version only
The pages describe the server in the tree (AGENTS.md says the same).
- No history: no "used to", "no longer", "now does", "was changed", and no
comparison with an earlier Monolith. "Clients still speak `2025-06-18`"
is fine, since it's about the clients.
- No plans, sessions or tracker numbers. A limitation is stated as how the
server behaves today ("`resolveHandle` answers only its own accounts'
handles"), and goes in the README's "Known gaps".
- No rejected designs. If a page needs the reason, give the current one in
a sentence.
## Shapes
### The README
The front door. Someone who reads only it should know what Monolith is,
why they'd run it, how to start, and where to read on. In this order:
1. `# Monolith`, then one line saying what it is.
2. One or two short paragraphs: what it is and what sets it apart, with
the numbers that make the case (from `bench/RESULTS.md` and
`compat/RESULTS.md`, with where they came from). Not how it came to be
built: how a change is made is AGENTS.md's, linked from Contributing.
3. `## Highlights`: 4-7 bullets, each one thing a reader would choose it
for, ending `→ [Page](link)`. A bullet may open with a bold term, since
it's a reference list of named things.
4. `## Quickstart`: the shortest path that runs, as commands, then a link
to Getting started for the rest.
5. `## Docs`: a two-column table of every guide and the reference pages,
with what's in each in a few words.
6. `## Layout`: a table of the top-level directories and crates, one line
each. The detail lives in the page that owns it (the spec, `AGENTS.md`,
a crate's `lib.rs`), so link or name it.
7. `## Development`: the few commands a contributor needs first, then a
link to Contributing.
8. `## Known gaps`. AGENTS.md cites this heading, so keep it.
### A guide
1. `# Title`, then one or two short paragraphs saying what the reader ends
up with and what they need. Don't list the sections, since the headings
already do.
2. `##` sections, one task each, in the order a reader does them. Lead
with the command or table, then explain it.
3. Every command runnable as written, with `pds.example.com` and friends as
placeholders. Every default with its variable (`PDS_PORT`, 2583).
4. Detail links out to the spec page that owns it rather than repeating it.
5. A short `## Next` at the end of a guide that leads somewhere.
`docs/README.md` lists every guide with what's in it, then the spec and
reference pages.
## Voice
Write like an engineer explaining the server to another engineer:
conversational, direct, concrete.
### What the voice is
- **Plain declarative sentences, one idea each.** Most run 12-25 words.
- **Conversational connectives.** "So", "Since", "That means", "In that
case". Sentences don't link up with semicolons.
- **Contractions everywhere.** it's, don't, can't, isn't, there's, that's.
- **Person.** The reader is "you" ("If you run the binary…"). The server is
the subject of mechanism sentences ("The server checks…", "`pds serve`
reads…"). No "I".
- **Concrete before abstract.** The scenario with its numbers first, then
the mechanism. When a term needs a definition, give it in one sentence
and then an example.
- **Numbers do the arguing.** Round numbers with units, and where they came
from in a few words (measured in the benchmark, the spec's limit).
- **Trade-offs said plainly.** The cost, the number, why it's fine.
- **Paragraphs of 1-4 sentences.**
- **Parentheses for asides**: a variable, a default, a spec page.
- **Modern English word order.** Monolith's older pages lean on habits
that read as stilted. Fix these on sight:
| Habit | Looks like | Do instead |
|---|---|---|
| "as" for "such as" or "like" | "a tag pins one, as `…:0.2.0`" | "such as", "like", "for example", or a colon before the example |
| Fronted "Of X," | "Of OAuth, no account pages." | "There are no OAuth account pages." |
| "alone" for "only" | "the binary alone", "for `/mcp` alone" | "only the binary", "only for `/mcp`" |
| "no one" / "nothing" as a subject to dodge a verb | "as no one, the account with it" | "then, without the admin password, create the account" |
| "that is to" | "the device that is to hold the passkey" | "the device that'll hold the passkey" |
| "is" as the only verb in a table's header | `| Variable | Is |` | `| Variable | What it does |`, or `| Variable | |` |
| Bare noun phrases for statements | "its labels name its version" is fine, "No sign-up from the page." isn't | Full sentences with a subject and verb |
| Inverted conditionals | "With it set, the CLI calls as the admin" | "When it's set, the CLI calls as the admin" |
### Banned patterns
Search for each of these on every page you touch.
| Pattern | Looks like | Do instead |
|---|---|---|
| Semicolon splice | "That is the latest version; a tag pins one." | Two sentences, or join with "and", "but" or "so". |
| Em dash or `--` aside | "the log — and only the log — is durable" | Parentheses, a comma, or a second sentence. |
| "X, not Y" flourish | "with its password session, not an app password or an OAuth token" | Say X. Mention Y in its own sentence only if readers would assume it ("An app password or an OAuth token can't do this."). |
| Colon chains | "It takes a token: the tokens XRPC takes, …: …" | One colon per sentence, and only to introduce a list, code or an example. |
| Rule-of-three lists | "fast, cheap and simple" | Keep the items that carry information. |
| Abstract nouns for actions | "the persistence of", "the handling of" | The verb: "stores", "handles". |
| Filler | crucially, importantly, in practice, it's worth noting, notably, essentially, robust, seamless, under the hood, first-class, by design, "the key insight", "this is where X comes in" | Delete it. If the sentence falls apart, rewrite it. |
| Bold lead-in on prose bullets | "- **Fail-stop.** When a node…" | Plain bullets. Bold a term at its definition, a real warning, or the names in a reference list (README highlights). |
| Bold or italics for emphasis | "**the log is the database**" | Put the phrase first, or the stressed word last. |
| One-line paragraph for drama | "Nothing else." on its own | Fold it into the paragraph it concludes. |
| Narrating the page | "This guide covers…", "In this section we'll look at" | Delete it and start with the content. |
| Stacked qualifiers | "about ~", "usually typically" | One qualifier, or none. |
| Exclamation marks | | None. |
### Mechanical pass
Apply these in order to every paragraph, list item and table cell you edit.
1. Replace every semicolon in prose with a period or with "and", "but" or "so".
2. Replace every em dash or double hyphen used as punctuation.
3. More than one colon in a sentence: split it. A colon that isn't
introducing a list, code or an example: make it a period or "because"/"so".
4. Find ", not " and "rather than". Keep one only when it corrects a real
misconception.
5. Fix the habits in the table under "What the voice is".
6. Delete filler words, then re-read the sentence.
7. Use contractions.
8. Split any sentence over ~35 words, or with more than two clauses joined
by commas.
9. Make the actor the subject: "is acknowledged by the server" becomes
"the server acknowledges".
10. Delete sentences that describe the page instead of the server.
11. Read it aloud. If you wouldn't say it to a coworker, rewrite it.
Length comes out about the same. If a page grows by more than ~10%,
something got explained twice.
### Before and after
> Before: That is the latest version; a tag pins one, as
> `knotless.dev/chadtmiller.com/monolith:0.2.0`. The image is the `pds`
> binary alone, on Debian slim, run as a user of its own, with its data on
> the volume `/data`.
>
> After: That's the latest version. A tag pins one, such as
> `knotless.dev/chadtmiller.com/monolith:0.2.0`. The image holds only the
> `pds` binary on Debian slim. It runs as its own user and keeps its data
> on the volume `/data`.
> Before: As the admin, make an invite code; then, as no one, the account
> with it.
>
> After: Make an invite code as the admin, then create the account with it.
> Before: Of OAuth, no account pages (`/account`): an account lists and
> ends its OAuth sessions and devices with `pds oauth …` instead.
>
> After: There are no OAuth account pages (`/account`). An account lists
> and ends its OAuth sessions and devices with `pds oauth …` instead.
## What a voice pass must not change
A voice pass changes wording. Check each of these before committing:
- **Facts.** Every number, unit, default, variable, flag, metric, error
name, file path and version stays as it is. If a sentence goes, its fact
moves to another sentence or is already on the page.
- **Nothing new.** Don't add a claim, number or feature that isn't on the
page, in the spec or in the code. If something reads wrong, flag it
rather than fixing it in prose.
- **Headings.** Others cite them, and anchors are made from them. Leave
them as they are. If one must change, update every link and citation in
the same commit: `rg -n 'guide/<page>.md' .` finds the links, and the
citations are quoted, as `(docs/guide/contributing.md, "The code gates")`
in `harness/` and `AGENTS.md`.
- **Links.** Every link stays and points to the same target.
- **Code blocks** and inline code are untouched.
## Avoiding duplication
- Each fact has one home. The spec owns what the server does, the guides
own how to run and call it, `bench/` and `compat/` own the measurements,
AGENTS.md owns how a change is made. Other pages state it in a clause and
link there.
- When a change in behaviour updates the spec, update the guide that tells
people about it in the same pull (AGENTS.md).
bench/README.md+280−256
536 lines changed: not loaded until asked for.
compat/README.md+226−203
429 lines changed: not loaded until asked for.
docs/assets/consent.pngnew+0−0
A binary file, not shown.
docs/guide/calling.md+67−66
@@ -1,24 +1,24 @@
# Calling the server
Every method the server serves can be called three ways: over XRPC, as a
command of the `pds` CLI, and as a tool on its MCP endpoint. All three take
the same arguments and give the same answer.
You can call every method the server serves in three ways: over XRPC, as a
command of the `pds` CLI, and as a tool on its MCP endpoint. All three
take the same arguments and give the same answer.
## Names
The tool and the command are made from the method's lexicon
([COMMANDS.md](../../spec/COMMANDS.md#names)):
The tool and the command names come from the method's lexicon
([COMMANDS.md](../../spec/COMMANDS.md#names)). For example,
`com.atproto.repo.createRecord` is the tool `repo_create_record` and the
command `pds repo create-record`. Its arguments are the tool's arguments,
or the command's flags. A method added to the server is a tool and a
command at once.
or the command's flags. So a method added to the server becomes a tool and
a command at once.
Where a method names an account, as `repo` does, the tool and the command
may leave it out, for the token's account.
When a method names an account (`repo`, for example), the tool and the
command can leave it out, and then it's the token's account.
## XRPC
The methods are under `/xrpc/`, as on any atproto PDS:
The methods are under `/xrpc/`, like on any atproto PDS:
```sh
curl https://pds.example.com/xrpc/com.atproto.server.describeServer
@@ -29,11 +29,11 @@ curl https://pds.example.com/xrpc/com.atproto.server.describeServer
`pds <group> <command> [flags]` calls a running server. It reads three
variables:
| Variable | Is |
| Variable | What it does |
| --- | --- |
| `PDS_URL` | the server's base URL |
| `PDS_TOKEN` | a bearer token to send, if set |
| `PDS_ADMIN_PASSWORD` | with no `PDS_TOKEN`, the admin's password, sent as `Basic` with the user `admin` |
| `PDS_URL` | The server's base URL. |
| `PDS_TOKEN` | A bearer token to send, if it's set. |
| `PDS_ADMIN_PASSWORD` | When there's no `PDS_TOKEN`, the admin's password, sent as `Basic` with the user `admin`. |
Sign in, keep the access token, and call:
@@ -44,18 +44,18 @@ pds repo create-record --collection com.example.note --record '{"text":"hi"}'
pds repo list-records --collection com.example.note --limit 5
```
`pds --help` lists the groups and commands, and `pds <group> --help` a
group's, each with its lexicon's description. `pds admin logs` and `pds
admin stats`, and the MCP tools `admin_logs` and `admin_stats`, are the
admin's reads of the log and the metrics, which have no lexicon
`pds --help` lists the groups and commands, and `pds <group> --help` lists
a group's, each with its lexicon's description. `pds admin logs` and `pds
admin stats` (and the MCP tools `admin_logs` and `admin_stats`) are how
the admin reads the log and the metrics, which have no lexicon
([COMMANDS.md](../../spec/COMMANDS.md#the-admins-reads),
[Operating](operating.md#reading-the-log-and-stats)).
An account's OAuth sessions, the apps it signed in to, and the browsers it
is signed in on, are listed and ended with its own password session, not
an app password or an OAuth token
([OAUTH-ACCOUNT.md](../../spec/OAUTH-ACCOUNT.md)), as the reference's
account pages do:
An account lists and ends its OAuth sessions (the apps it signed in to)
and the browsers it's signed in on with its own password session
([OAUTH-ACCOUNT.md](../../spec/OAUTH-ACCOUNT.md)). An app password or an
OAuth token can't do this. These commands do what the reference's account
pages do:
```sh
pds oauth sessions # each session's id, client, scope
@@ -64,14 +64,14 @@ pds oauth devices # each browser's id, user agent, IP
pds oauth revoke-device --id <id> # sign the account out of it
```
The same are the MCP tools `oauth_sessions`, `oauth_revoke_session`,
The matching MCP tools are `oauth_sessions`, `oauth_revoke_session`,
`oauth_devices` and `oauth_revoke_device`.
Passkeys are added, listed and removed the same way, with the password
session ([PASSKEYS.md](../../spec/PASSKEYS.md)). `pds passkey add` answers
a link, good for 15 minutes, to open in a browser on the device that is
to hold the passkey; the account then signs in on the authorization page
with `Sign in with a passkey`, with no password and no email code:
You add, list and remove passkeys the same way, with the password session
([PASSKEYS.md](../../spec/PASSKEYS.md)). `pds passkey add` answers with a
link that's good for 15 minutes. Open it in a browser on the device that'll
hold the passkey. After that, the account signs in on the authorization
page with `Sign in with a passkey`, with no password and no email code:
```sh
pds passkey add --name Laptop # {"url": ".../oauth/passkey?token=…", "expiresAt": …}
@@ -79,17 +79,18 @@ pds passkey list # each passkey's id, name, when added an
pds passkey remove --id <id> # it no longer signs in
```
The same are the MCP tools `passkey_list`, `passkey_add` and
`passkey_remove`. The link is a secret: whoever opens it in time adds a
passkey to the account.
The matching MCP tools are `passkey_list`, `passkey_add` and
`passkey_remove`. Treat the link as a secret, since whoever opens it in
time adds a passkey to the account.
A few commands send or write bytes rather than JSON
([COMMANDS.md](../../spec/COMMANDS.md#answers)): `sync get-repo` and
`sync get-blob` write the CAR file or blob to standard output,
A few commands send or write bytes instead of JSON
([COMMANDS.md](../../spec/COMMANDS.md#answers)). `sync get-repo` and
`sync get-blob` write the CAR file or blob to standard output.
`repo upload-blob --encoding <type>` sends standard input as the blob, and
`repo import-repo` sends standard input as a CAR file. So a repository
moves from one server to another, each with its own `PDS_URL` and
`PDS_TOKEN`, as the account moves ([MIGRATION.md](../../spec/MIGRATION.md)):
`repo import-repo` sends standard input as a CAR file. That means you can
move a repository from one server to another when the account moves, each
side with its own `PDS_URL` and `PDS_TOKEN`
([MIGRATION.md](../../spec/MIGRATION.md)):
```sh
PDS_URL=$OLD PDS_TOKEN=$OLD_TOKEN pds sync get-repo --did "$DID" \
@@ -97,11 +98,11 @@ PDS_URL=$OLD PDS_TOKEN=$OLD_TOKEN pds sync get-repo --did "$DID" \
```
`pds xrpc` makes any call by name, with `goat xrpc`'s arguments
([COMMANDS.md](../../spec/COMMANDS.md#any-call)): `k==v` a query
parameter, `k=v` a string property of the body, `k:=json` any other,
`Name:value` a header, and `-` standard input as the body. It reaches
what has no command, as a method the server forwards to the AppView, and
checks nothing before sending:
([COMMANDS.md](../../spec/COMMANDS.md#any-call)). `k==v` is a query
parameter, `k=v` a string property of the body, `k:=json` any other
property, `Name:value` a header, and `-` sends standard input as the body.
It reaches methods that have no command, such as one the server forwards
to the AppView, and it checks nothing before sending:
```sh
pds xrpc query app.bsky.actor.getProfile actor==atproto.com
@@ -110,34 +111,34 @@ pds xrpc procedure com.atproto.repo.createRecord repo=alice.test collection=com.
## MCP
`POST /mcp` is an MCP endpoint over Streamable HTTP, with tools only
([COMMANDS.md](../../spec/COMMANDS.md#the-mcp-endpoint)). It serves clients
of either era of MCP: the stateless revision `2026-07-28`, and, after an
`initialize`, the legacy `2025-11-25` and `2025-06-18` that most clients
still speak.
`POST /mcp` is an MCP endpoint over Streamable HTTP, and it serves only
tools ([COMMANDS.md](../../spec/COMMANDS.md#the-mcp-endpoint)). It serves
clients of either era of MCP. That's the stateless revision `2026-07-28`
and, after an `initialize`, the legacy `2025-11-25` and `2025-06-18` that
most clients still speak.
It takes `Authorization: Bearer <token>`: the tokens XRPC takes, an MCP
client's OAuth access token, or the admin's `Basic`. Every tool is listed
to every caller, with a token or without.
It takes `Authorization: Bearer <token>` with any token XRPC takes or an
MCP client's OAuth access token. It also takes the admin's `Basic`. Every
caller sees every tool listed, with a token or without.
Each tool has a `title` and says what it does in its annotations
([COMMANDS.md](../../spec/COMMANDS.md#hints)): a read is `readOnlyHint`,
and a call that may delete, replace or end something is `destructiveHint`,
so that a client asks before those and not before a read or a new record.
Each tool has a `title`, and its annotations say what it does
([COMMANDS.md](../../spec/COMMANDS.md#hints)). A read is `readOnlyHint`,
and a call that may delete, replace or end something is `destructiveHint`.
So a client asks before those, but not before a read or a new record.
## Connect an AI app
An MCP client such as Claude signs in by OAuth, as MCP's authorization
spec has it ([OAUTH-MCP.md](../../spec/OAUTH-MCP.md)). The server's root
page, `GET /`, says how:
An MCP client such as Claude signs in by OAuth, the way MCP's
authorization spec describes ([OAUTH-MCP.md](../../spec/OAUTH-MCP.md)).
The server's root page, `GET /`, says how:
1. Add `<your server's URL>/mcp` to the app as a connector. In Claude:
Settings > Connectors > Add custom connector, and choose "Sign in when
needed".
1. Add `<your server's URL>/mcp` to the app as a connector. In Claude, go
to Settings > Connectors > Add custom connector, and choose "Sign in
when needed".
2. When it asks, sign in on the server's page and approve it.
3. Ask it things, as "What have I posted this week?"
3. Ask it things, like "What have I posted this week?"
The client finds the server's MCP issuer from the endpoint's metadata,
and the token it gets is for `/mcp` alone. Claude reaches only a server on
the internet, so it needs a server deployed as [Deploying](deploying.md)
says.
The client finds the server's MCP issuer from the endpoint's metadata, and
the token it gets is only for `/mcp`. Claude can only reach a server on the
internet, so you'll need a server deployed the way
[Deploying](deploying.md) describes.
docs/guide/comparing.md+225−199
424 lines changed: not loaded until asked for.
docs/guide/contributing.md+130−120
@@ -1,11 +1,11 @@
# Contributing
A change goes spec first, then the harness, then the server.
[AGENTS.md](../../AGENTS.md#how-a-change-is-made) says how, and the rules
an agent building the server is given. This guide is working from a clone
of the repository, the checks a change meets, and how a release is made.
To run Monolith, you need no clone: [Getting started](getting-started.md)
starts from its image or its download.
[AGENTS.md](../../AGENTS.md#how-a-change-is-made) says how, and lists the
rules an agent building the server is given. Here you'll set up a clone of
the repository, see the checks a change has to meet, and see how a release
is made. You don't need a clone to run Monolith.
[Getting started](getting-started.md) starts from its image or its download.
## Working from a clone
@@ -17,17 +17,17 @@ The clone needs:
- Rust, through [rustup](https://rustup.rs). The Justfile runs cargo as
`rustup run stable cargo`.
- Node, the version [`.node-version`](../../.node-version) names (24).
- Node, at the version [`.node-version`](../../.node-version) names (24).
- [just](https://github.com/casey/just), which runs the
[Justfile](../../Justfile)'s targets, and `jq` for the sign-in below.
- The harness's and the pages' packages, once:
- The harness's and the pages' packages, installed once:
```sh
cd harness && npm ci && cd ..
cd web && npm ci && cd ..
```
- Chromium, for the harness's `--pages` run and `just look` only:
- Chromium, but only for the harness's `--pages` run and `just look`:
```sh
cd harness && npx playwright install chromium
@@ -39,9 +39,9 @@ cd harness && npx playwright install chromium
just build
```
This builds the authorization pages in `web/` into `web/dist`, then `pds`
into `target/release/pds`, which embeds them. The image is built from the
[Dockerfile](../../Dockerfile), the same way:
This builds the authorization pages in `web/` into `web/dist`, then builds
`pds` into `target/release/pds`, which embeds them. The
[Dockerfile](../../Dockerfile) builds the image the same way:
```sh
docker build -t monolith .
@@ -54,16 +54,16 @@ just dev --seed
```
`just dev` builds `pds`, then runs
[`harness/dev.mjs`](../../harness/dev.mjs): the server at
`http://localhost:2583`, with a PLC directory of its own in memory and an
AppView of nowhere. What the server serves itself, as preferences, is
served; what it would forward to an AppView fails. Its URL is `localhost`,
not an IP address, so that a browser makes and uses passkeys there
([PASSKEYS.md](../../spec/PASSKEYS.md#the-relying-party)): `pds passkey
add` gives a link to open, and the authorization page then offers the
passkey.
Its files are in `target/dev/`: the data in `target/dev/data`, the
[`harness/dev.mjs`](../../harness/dev.mjs). That starts the server at
`http://localhost:2583`, with its own PLC directory in memory and an
AppView that points nowhere. What the server serves itself, such as
preferences, works, but anything it would forward to an AppView fails. Its
URL is `localhost`, not an IP address, so a browser will make and use
passkeys there ([PASSKEYS.md](../../spec/PASSKEYS.md#the-relying-party)).
`pds passkey add` gives you a link to open, and the authorization page
then offers the passkey.
Its files go in `target/dev/`: the data in `target/dev/data`, the
server's log in `target/dev/server.log`, and mail in `target/dev/mail`.
Each start makes `target/dev/` afresh.
@@ -73,18 +73,18 @@ the CLI needs, and where MCP is, then runs until Ctrl-C.
The flags:
- `--seed` makes `alice.test`, `bob.test` and `carol.test`, each with the
password `password`, if they are not there already.
password `password`, if they aren't there already.
- `--keep` carries on from the last run: the same data, the same rotation
key, and the DIDs' operations given to the new PLC directory again. Each
stop saves them in `target/dev/plc.json`.
key, and the DIDs' operations, given to the new PLC directory again.
Each stop saves them in `target/dev/plc.json`.
- `--port <n>` listens on another port.
- `-- <command...>` runs another server command in place of
- `-- <command...>` runs another server command instead of
`../target/release/pds serve`.
The admin's password is `admin`, and handles end in `.test`.
Paste the `export` lines it printed, with `target/release/pds` on your
`PATH`, and you are `alice.test`:
Put `target/release/pds` on your `PATH` and paste the `export` lines it
printed. Then you're `alice.test`:
```sh
export PDS_URL=http://localhost:2583 PDS_ADMIN_PASSWORD=admin
@@ -94,12 +94,12 @@ pds repo list-records --collection com.example.note --limit 5
```
`just dev` sets no SMTP server, so no mail leaves the machine. Each email
the server would send, as a confirmation or password reset token, is
written to `target/dev/mail/` as a JSON file of its own, `{"to", "kind",
the server would send, such as a confirmation or password reset token,
goes to `target/dev/mail/` as its own JSON file, `{"to", "kind",
"token"}` ([EMAIL.md](../../spec/EMAIL.md#the-development-sink)).
Ctrl-C stops it. The server shuts down, and the PLC directory's operations
are saved. `just dev --keep` carries on from there.
Ctrl-C stops it. The server shuts down and the PLC directory's operations
get saved, so `just dev --keep` carries on from there.
## The just targets
@@ -118,38 +118,40 @@ just docs-site # the documentation site, served while you write (below)
just docs-deploy # the documentation site, deployed by its owner (below)
```
While you work, run `just quick` alone. Push the branch and open the pull
early: the gates run on the runner.
While you work, run `just quick` by itself, with nothing else running.
Push the branch and open the pull early, since the gates run on the
runner.
## The gates
`just gates` runs the code gates, the tests and the harness side by side,
the harness several runs at once
([`harness/gates.mjs`](../../harness/gates.mjs); `GATES_JOBS` sets how
many), a short run with the server killed every 15 steps among them.
`just gates` runs the code gates, the tests and the harness side by side
([`harness/gates.mjs`](../../harness/gates.mjs)). The harness does several
runs at once (`GATES_JOBS` sets how many), and one of them is a short run
with the server killed every 15 steps.
The `gates` workflow
([`.knotless/workflows/gates.yml`](../../.knotless/workflows/gates.yml))
runs them on every pull into `main` and every push to it that changes what
they check: the server's source and build, the pages it embeds (`web/`),
the data and lexicons it reads from `spec/`, and the harness the gates
run. A change to nothing of those, as the README, `docs/`, the spec's
prose, the benchmark or the compatibility check, is filed as skipped,
which the merge queue takes as passing.
runs them on every pull into `main`, and on every push to it, that changes
what they check. That's the server's source and build, the pages it
embeds (`web/`), the data and lexicons it reads from `spec/`, and the
harness the gates run. A change that touches none of those, such as the
README, `docs/`, the spec's prose, the benchmark or the compatibility
check, is filed as skipped, and the merge queue takes that as passing.
## Nightly
`just nightly` runs the long crash runs, the server killed every 15 steps
over runs of 1000, then the performance step alone: the server's speed
against the reference's and against its baseline, and what it holds once
subscribers have come and gone, its whole output in the log; then the
scale run, which measures the server's starts.
`just nightly` runs the long crash runs, which kill the server every 15
steps over runs of 1000. Then it runs the performance step on its own. That
measures the server's speed against the reference's and against its
baseline, and what it holds once subscribers have come and gone, with its
whole output in the log. Last comes the scale run, which measures the
server's starts.
The `nightly` workflow
([`.knotless/workflows/nightly.yml`](../../.knotless/workflows/nightly.yml))
runs them on `main`'s tip every night at 10:00 UTC, and when the owner
asks, on `main` or on a branch, as for a pull that changes how the server
stores:
runs them on `main`'s tip every night at 10:00 UTC. The owner can also ask
for it on `main` or on a branch, for example for a pull that changes how
the server stores its data:
```sh
knotless run rerun --ref main --workflow nightly
@@ -158,37 +160,40 @@ knotless run rerun --ref refs/heads/<branch> --workflow nightly
## The code gates
Besides the harness and the tests, the source itself is held to these,
the `code` gates. They are among the gates `just gates` and the `gates`
workflow run. `just code` runs them alone, as does `node gates.mjs code`
Besides the harness and the tests, the source itself has to pass these,
the `code` gates. They're part of what `just gates` and the `gates`
workflow run. `just code` runs only them, and so does `node gates.mjs code`
in `harness/`, with `CARGO` naming the cargo to run.
- `cargo fmt --all --check`: formatted as rustfmt formats it.
- `cargo clippy --workspace --all-targets -- -D warnings`: no warning of
clippy's, nor of rustc's, in any target.
- `cargo deny check` ([`deny.toml`](../../deny.toml)): every dependency
under a licence of the allowlist, all permissive, no advisory of the
RustSec database, unmaintained and unsound crates too, no yanked
version, no wildcard version, and crates from crates.io alone.
- `#![forbid(unsafe_code)]` at the root of every crate, each of its
targets, which `harness/code.mjs` checks: what needs the operating
system goes through a crate that wraps it safely.
- Every citation of the spec in the harness, as `(spec/LIFECYCLE.md,
"deactivateAccount")`, naming a section its page has, and every section
of every page cited by some check, but the few `harness/spec-coverage.mjs`
lists as unchecked, each with why (`spec/PDS.md`, "How it is checked").
The `citations` workflow runs it alone on every pull that changes a spec
page or the harness, so a pull of the spec's prose, which the gates
skip, is held to it too.
- The pages' source ([web/AGENTS.md](../../web/AGENTS.md)): each component
using only its own layer and those below (`harness/layers.mjs`), every
text colour at 4.5:1 on what it is drawn on in light and dark
(`harness/contrast.mjs`), and `svelte-check` with no warning.
- `cargo fmt --all --check`: the code is formatted the way rustfmt
formats it.
- `cargo clippy --workspace --all-targets -- -D warnings`: there's no
clippy or rustc warning in any target.
- `cargo deny check` ([`deny.toml`](../../deny.toml)): every dependency is
under a licence on the allowlist, and they're all permissive. There's no
advisory from the RustSec database, unmaintained and unsound crates
included, no yanked version and no wildcard version. Crates come only
from crates.io.
- `#![forbid(unsafe_code)]` sits at the root of every crate and each of
its targets, and `harness/code.mjs` checks it. Anything that needs the
operating system goes through a crate that wraps it safely.
- Every citation of the spec in the harness, such as `(spec/LIFECYCLE.md,
"deactivateAccount")`, names a section its page has. Every section of
every page is cited by some check, except the few that
`harness/spec-coverage.mjs` lists as unchecked, each with why
(`spec/PDS.md`, "How it is checked"). The `citations` workflow runs only
this check on every pull that changes a spec page or the harness. So a
pull of the spec's prose, which the gates skip, still has to pass it.
- The pages' source ([web/AGENTS.md](../../web/AGENTS.md)) has its own
checks. Each component uses only its own layer and those below it
(`harness/layers.mjs`), and every text colour reaches 4.5:1 on what it's
drawn on in light and dark (`harness/contrast.mjs`). `svelte-check`
gives no warning.
## The pages, by eye
`just look` draws an authorization page in a browser, in any state, as
pictures in `target/look` to open:
`just look` draws an authorization page in a browser, in any state, and
saves pictures of it in `target/look` for you to open:
```sh
just look consent --scope 'atproto repo:*'
@@ -198,24 +203,26 @@ just look consent --scope 'atproto repo:*'
`docs-site/` builds the site from these guides, the spec's pages, the
lexicons, and `compat/` and `bench/`. Its landing page,
`docs-site/src/pages/index.astro`, is the photograph, a headline, one sentence and two buttons: its words are written
as [the landing skill](../../.claude/skills/landing/SKILL.md) says, and its
one figure is read from the last benchmark, `bench/results.json`:
`docs-site/src/pages/index.astro`, holds the photograph, a headline, one
sentence and two buttons. Its words follow
[the landing skill](../../.claude/skills/landing/SKILL.md), and its one
figure is read from the last benchmark, `bench/results.json`. Build it
with:
```sh
cd docs-site && npm ci && npm run build
```
The build fails on a link to a file or heading that is not there, a method
`spec/PDS.md` lists under no page, or a variable the spec names in no table
of them; the `docs` workflow builds it on each pull that changes what it is
made from. `just docs-site` serves it at http://localhost:4321/ while you
write.
The build fails on a link to a file or heading that isn't there, a method
`spec/PDS.md` lists under no page, or a variable the spec names in no
table. The `docs` workflow builds it on each pull that
changes what it's made from. `just docs-site` serves it at
http://localhost:4321/ while you write.
The site is at https://chadtmiller-com.knotless.page/monolith/. The `docs`
workflow deploys it on each push to `main` that changes what it is made
from, signed in with the owner's app password, `RELEASE_PASSWORD`. Its
owner can deploy it by hand too, signed in with `knotless login`:
workflow deploys it on each push to `main` that changes what it's made
from, signed in with the owner's app password (`RELEASE_PASSWORD`). The
owner can also deploy it by hand after `knotless login`:
```sh
just docs-deploy
@@ -223,42 +230,45 @@ just docs-deploy
## Releases
A pull that changes what those who run the server or call it see, its
behaviour, its settings, its CLI, its image, adds a change file to
`.changeset/`: `knope document-change` asks for the bump (`patch`, `minor`
or `major`) and a summary, or write it by hand, as the ones there are. Its
heading and text are that change's entry in `CHANGELOG.md`, for those
readers, not for us. A change they do not see, as a test or the harness,
adds none.
A release is `main` with the workspace's `version` raised, tagged
`v<version>`, made by two workflows:
- `release-pull.yml`, each day when `main` has change files: `knope
release` on `main`'s tip, which raises the version, writes the version's
section of `CHANGELOG.md` and removes the change files, as the one open
pull `Release <version>`, kept up to date as change files land. Queueing
that pull is the release. 0.x's `minor` raises the minor, where knope
alone would raise the patch. `knotless run rerun
A pull that changes what people running or calling the server see (its
behaviour, its settings, its CLI, its image) adds a change file to
`.changeset/`. `knope document-change` asks for the bump (`patch`,
`minor` or `major`) and a summary, or you can write it by hand like the
ones already there. Its heading and text become that change's entry in
`CHANGELOG.md`, so write them for those readers rather than for us. A
change they don't see, such as a test or the harness, adds none.
A release is `main` with the workspace's `version` raised and tagged
`v<version>`. Two workflows make it:
- `release-pull.yml` runs each day when `main` has change files. It runs
`knope release` on `main`'s tip, which raises the version, writes the
version's section of `CHANGELOG.md` and removes the change files. The
result is the one open pull, `Release <version>`, kept up to date as
change files land. Queueing that pull is the release. On 0.x, `minor`
raises the minor version, where knope by itself would raise the patch.
`knotless run rerun
knotless://chadtmiller.com/monolith --ref refs/heads/main --workflow
release-pull` makes the pull at once.
- `release.yml`, once that lands and the gates pass at it: it builds the
pages and `pds` as the Dockerfile does, makes the image from the binary
with no container engine (`.knotless/image.sh`, as the runner's jobs have
none), and publishes both, the image as the package `monolith` and
`pds-<version>-x86_64-linux.tar.gz` with its `.sha256` as the package
`pds`, each with the version's changelog as its notes, then tags the
commit. Asked for on a branch, it builds both and publishes nothing.
Both run on `runner.knotless.dev`, with `RELEASE_PASSWORD`, an app password
of the owner's, sealed to it for pushes to `main` alone.
Once tagged, `harness/upgrade/` is written again with the release's
binary, which is then the previous version every later build must start on
(`compare.mjs --upgrade`, in [Comparing](comparing.md#the-store-scale-and-upgrades)),
and committed:
- `release.yml` runs once that pull lands and the gates pass at it. It
builds the pages and `pds` the way the Dockerfile does, and makes the
image from the binary with no container engine (`.knotless/image.sh`,
since the runner's jobs have none). It publishes both, each with the
version's changelog as its notes: the image as the package `monolith`,
and `pds-<version>-x86_64-linux.tar.gz` with its `.sha256` as the
package `pds`. Then it tags the commit. When you ask for it on a branch,
it builds both and publishes nothing.
Both run on `runner.knotless.dev` with `RELEASE_PASSWORD`, an app password
of the owner's, sealed to it only for pushes to `main`.
Once the release is tagged, write `harness/upgrade/` again with its binary
and commit it:
```sh
git worktree add ../pds-release v<version> && (cd ../pds-release/web && npm ci) && (cd ../pds-release && just build)
cd harness && node compare.mjs --upgrade-write -- ../../pds-release/target/release/pds serve
```
That binary is then the previous version every later build must start on
(`compare.mjs --upgrade`, in [Comparing](comparing.md#the-store-scale-and-upgrades)).
docs/guide/deploying.md+64−61
@@ -1,109 +1,112 @@
# Deploying
This guide is the rest of running the server on the network, after
[Getting started](getting-started.md): the image, the address and proxy,
the whole environment, blobs in a bucket, and backups.
Running the server on the network takes a bit more than
[Getting started](getting-started.md) shows. You'll need the image, the
address and proxy, the whole environment, blobs in a bucket and backups.
## The image
`knotless.dev/chadtmiller.com/monolith` is the server as an image, `latest`
or a version as its tag, published with each release for linux/amd64:
`pds` alone, on Debian slim, run as the user `pds`, uid and gid 10001. It
sets `PDS_PORT=2583`, `PDS_BIND_ADDRESS=::` and `PDS_DATA_DIR=/data`, a
volume, which that user must own. Its labels, `org.opencontainers.image.version`
and `org.opencontainers.image.revision`, name the version and the commit it
was built from, and `/xrpc/_health` answers the version.
`knotless.dev/chadtmiller.com/monolith` is the server as an image. Its tag
is `latest` or a version, and it's published with each release for
linux/amd64. It holds only `pds` on Debian slim and runs as the user
`pds`, uid and gid 10001. It sets `PDS_PORT=2583`, `PDS_BIND_ADDRESS=::`
and `PDS_DATA_DIR=/data`, a volume that user must own. Its labels,
`org.opencontainers.image.version` and `org.opencontainers.image.revision`,
name the version and the commit it was built from, and `/xrpc/_health`
answers with the version.
```sh
docker run -d -p 127.0.0.1:2583:2583 -v pds-data:/data --env-file pds.env knotless.dev/chadtmiller.com/monolith
```
The image is the `pds` binary alone: `pds <group> <command>` in it is the
CLI, as anywhere. To build it yourself from a clone, see
Since the image holds only the `pds` binary, `pds <group> <command>` in it
is the CLI, like anywhere else. To build it yourself from a clone, see
[Contributing](contributing.md#build).
`docker stop` sends SIGTERM, which shuts the server down within Docker's 10
`docker stop` sends SIGTERM, and the server shuts down within Docker's 10
seconds ([OPERATIONS.md](../../spec/OPERATIONS.md#events)).
## Address, TLS and proxies
Outside a container, the server listens on `127.0.0.1` unless
`PDS_BIND_ADDRESS` names another address
([PDS.md](../../spec/PDS.md#what-it-serves)). Either way it speaks plain
HTTP: TLS is the reverse proxy's.
([PDS.md](../../spec/PDS.md#what-it-serves)). Either way, it speaks plain
HTTP, and the reverse proxy handles TLS.
Behind a proxy, set `PDS_TRUSTED_PROXIES` to the proxy's addresses. The
server reads `X-Forwarded-For` only from those peers, so without it every
client shares the proxy's rate limits
server reads `X-Forwarded-For` only from those peers. So if it isn't set,
every client shares the proxy's rate limits
([LIMITS.md](../../spec/LIMITS.md#rate-limits)).
`/metrics`, with `PDS_METRICS_PORT` set, is on `127.0.0.1` alone, so in a
container only what runs in it can scrape it ([Operating](operating.md)).
When `PDS_METRICS_PORT` is set, `/metrics` listens only on `127.0.0.1`. In
a container, that means only what runs inside it can scrape it
([Operating](operating.md)).
## The environment
What a server on the network is given, besides those. Each variable's page
says the rest.
These are what a server on the network needs besides those above. Each
variable's page says the rest.
| Variable | Is |
| Variable | What it does |
| --- | --- |
| `PDS_HOSTNAME`, `PDS_PUBLIC_URL` | its host name, and its `https://` URL. Passkeys are bound to the URL's host ([PASSKEYS.md](../../spec/PASSKEYS.md#the-relying-party)): a browser makes none for an IP address, and once the URL names another host, those made before are no longer offered |
| `PDS_HANDLE_DOMAINS` | the domains its accounts' handles end in, as `.example.com`; each handle's own host must reach the server for `/.well-known/atproto-did`, so a wildcard DNS record and certificate |
| `PDS_HOSTNAME`, `PDS_PUBLIC_URL` | The host name and its `https://` URL. Passkeys are bound to the URL's host ([PASSKEYS.md](../../spec/PASSKEYS.md#the-relying-party)). A browser won't make one for an IP address, and once the URL names another host, the ones made before aren't offered anymore |
| `PDS_HANDLE_DOMAINS` | The domains accounts' handles end in, such as `.example.com`. Each handle's own host must reach the server for `/.well-known/atproto-did`, so you need a wildcard DNS record and certificate |
| `PDS_PLC_URL` | `https://plc.directory` |
| `PDS_PLC_ROTATION_KEY_HEX` | a new secp256k1 key (`openssl rand -hex 32`), in a secret store: whoever holds it controls every account's DID |
| `PDS_RECOVERY_DID_KEY` | a `did:key` whose private key is kept offline, so the DIDs outlive a lost or stolen rotation key |
| `PDS_EMAIL_SMTP_URL`, `PDS_EMAIL_FROM` | the mail server, and the address mail is from |
| `PDS_ADMIN_PASSWORD`, `PDS_INVITE_REQUIRED` | the admin's password, which also reads the log and stats ([Operating](operating.md#reading-the-log-and-stats)); `true` unless anyone may sign up |
| `PDS_LOG_DIR`, `PDS_LOG_KEEP_BYTES` | a directory, on a volume of its own apart from `/data`, the log is kept in too, so that the admin reads it back across deploys; and the most it takes, 64 MiB unless set |
| `PDS_CRAWLERS` | the relays told of it, as `https://bsky.network` |
| `PDS_PLC_ROTATION_KEY_HEX` | A new secp256k1 key (`openssl rand -hex 32`), kept in a secret store. Whoever holds it controls every account's DID |
| `PDS_RECOVERY_DID_KEY` | A `did:key` whose private key is kept offline, so the DIDs outlive a lost or stolen rotation key |
| `PDS_EMAIL_SMTP_URL`, `PDS_EMAIL_FROM` | The mail server, and the address mail comes from |
| `PDS_ADMIN_PASSWORD`, `PDS_INVITE_REQUIRED` | The admin password, which also reads the log and stats ([Operating](operating.md#reading-the-log-and-stats)). Invites are required (`true`) unless anyone may sign up |
| `PDS_LOG_DIR`, `PDS_LOG_KEEP_BYTES` | A directory where the log is also kept, on its own volume apart from `/data`, so the admin can read it back across deploys. The second sets how much it keeps, 64 MiB by default |
| `PDS_CRAWLERS` | The relays the server tells about itself, such as `https://bsky.network` |
| `PDS_BSKY_APP_VIEW_URL`, `PDS_BSKY_APP_VIEW_DID`, `PDS_BSKY_APP_VIEW_CDN_URL_PATTERN` | `https://api.bsky.app`, `did:web:api.bsky.app` and `https://cdn.bsky.app/img/%s/plain/%s/%s@jpeg`, for the Bluesky app |
| `PDS_MAX_REPO_IMPORT_SIZE` | the largest repository an account may bring when it moves here ([MIGRATION.md](../../spec/MIGRATION.md)), 300 MiB unless set |
| `PDS_BLOB_UPLOAD_LIMIT` | the largest blob an account may upload, 5 MiB unless set ([LIMITS.md](../../spec/LIMITS.md)); at least as large as the old server's when accounts move here from one that takes larger blobs, as for video, else theirs cannot all be brought |
| `PDS_BLOB_QUOTA_BYTES` | the bytes of blobs an account may hold, 1 GiB unless set ([LIMITS.md](../../spec/LIMITS.md#blobs)); above the largest account's blobs when accounts move here, as an `uploadBlob` past it is refused, `400 BlobQuotaExceeded` |
| `PDS_RATE_LIMITS_ENABLED` | `true` unless set; its `uploads` limit lets an account 1000 `uploadBlob`s a day ([LIMITS.md](../../spec/LIMITS.md#rate-limits)), so an account bringing more blobs than that brings them over days, or while the server runs with `false` for the move alone |
| `PDS_HANDLE_DNS_SERVER` | optionally, the DNS server asked for a handle's `_atproto` TXT record when an account takes a handle of its own domain ([IDENTITY.md](../../spec/IDENTITY.md#resolving-a-handle)); unset, the machine's resolver |
| `PDS_BLOBSTORE_S3_BUCKET` and the rest of [BLOBS.md](../../spec/BLOBS.md#where-blobs-are-kept)'s | optionally, a bucket of an S3-compatible store to keep blobs in, rather than the data directory (below) |
| `PDS_MAX_REPO_IMPORT_SIZE` | The largest repository an account can bring when it moves here ([MIGRATION.md](../../spec/MIGRATION.md)), 300 MiB by default |
| `PDS_BLOB_UPLOAD_LIMIT` | The largest blob an account can upload, 5 MiB by default ([LIMITS.md](../../spec/LIMITS.md)). If accounts move here from a server that takes larger blobs (for video, say), set it at least that large, or they can't bring all of theirs |
| `PDS_BLOB_QUOTA_BYTES` | The bytes of blobs an account can hold, 1 GiB by default ([LIMITS.md](../../spec/LIMITS.md#blobs)). An `uploadBlob` past it is refused with `400 BlobQuotaExceeded`, so when accounts move here, set it above the largest account's blobs |
| `PDS_RATE_LIMITS_ENABLED` | `true` by default. Its `uploads` limit lets an account make 1000 `uploadBlob`s a day ([LIMITS.md](../../spec/LIMITS.md#rate-limits)), so an account bringing more blobs than that brings them over several days, or while the server runs with `false` just for the move |
| `PDS_HANDLE_DNS_SERVER` | Optional. The DNS server asked for a handle's `_atproto` TXT record when an account takes a handle on its own domain ([IDENTITY.md](../../spec/IDENTITY.md#resolving-a-handle)). When it's unset, the server uses the machine's resolver |
| `PDS_BLOBSTORE_S3_BUCKET` and the rest of [BLOBS.md](../../spec/BLOBS.md#where-blobs-are-kept)'s | Optional. A bucket in an S3-compatible store to keep blobs in instead of the data directory (below) |
`PDS_DEV_MAIL_DIR`, `PDS_OAUTH_CLIENT_FETCH`, `PDS_HANDLE_FETCH` and
`PDS_DISABLE_SSRF_PROTECTION` are for development, never for a server on
the network.
`PDS_DISABLE_SSRF_PROTECTION` are for development. Never set them on a
server on the network.
## Blobs in a bucket
With `PDS_BLOBSTORE_S3_BUCKET` set, the server keeps blobs in that bucket
of a store that speaks S3's API (Amazon S3, Cloudflare R2, MinIO and the
like), and none of their bytes in the data directory. The bucket's region,
endpoint, path style, credentials and timeouts have variables of their own
([BLOBS.md](../../spec/BLOBS.md#where-blobs-are-kept)).
When `PDS_BLOBSTORE_S3_BUCKET` is set, the server keeps blobs in that
bucket of a store that speaks S3's API (Amazon S3, Cloudflare R2, MinIO
and the like). None of their bytes go in the data directory. The bucket's
region, endpoint, path style, credentials and timeouts have their own
variables ([BLOBS.md](../../spec/BLOBS.md#where-blobs-are-kept)).
Where blobs are kept is chosen at the first start. To change it later,
stop the server and move them, with the environment `pds serve` is given,
the bucket's variables set:
The server picks where blobs live at its first start. To change it later,
stop the server and move them. Run this with the environment `pds serve`
gets, plus the bucket's variables:
```sh
pds migrate-blobs --to bucket # or --to disk
```
Then start the server with the new variables. A move killed part way is
run again to finish it ([BLOBS.md](../../spec/BLOBS.md#moving-them)).
Then start the server with the new variables. If a move gets killed part
way, run it again to finish
([BLOBS.md](../../spec/BLOBS.md#moving-them)).
## Backups
Back the server up by snapshots of its volume or filesystem, taken while it
runs. A snapshot is a data directory the server starts on, holding every
write answered before it
Back the server up with snapshots of its volume or filesystem, taken while
it runs. A snapshot is a data directory the server can start on, and it
holds every write answered before it was taken
([DURABILITY.md](../../spec/DURABILITY.md#backups)).
A `cp` or `rsync` of a running server's directory is not a backup. Stop
the server first, or snapshot.
A `cp` or `rsync` of a running server's directory isn't a backup. Stop
the server first, or take a snapshot.
Keep the environment apart, and safe: the data directory holds no PLC
rotation key.
Keep the environment somewhere separate and safe, since the data
directory doesn't hold the PLC rotation key.
With blobs in a bucket, the snapshot holds no blob's bytes. Keep the
bucket versioned, so that a blob deleted after the snapshot can be brought
back with it.
With blobs in a bucket, the snapshot doesn't hold any blob bytes. Keep the
bucket versioned, so a blob deleted after the snapshot can be restored
along with it.
Starting on a backup rolls the server back: what was written after is
lost, and relays and AppViews hold commits and firehose `seq`s it no
longer has.
Starting on a backup rolls the server back. Anything written after it is
lost, and relays and AppViews hold commits and firehose `seq`s the server
doesn't have anymore.
docs/guide/getting-started.md+40−39
@@ -1,17 +1,17 @@
# Getting started
This guide takes Monolith from nothing to an account you sign in to from
the Bluesky app: get the server, give it its settings, run it behind your
proxy, and make the first account. You need no clone of the repository;
that is for [contributing](contributing.md).
You'll take Monolith from nothing to an account you sign in to from the
Bluesky app. You get the server, give it its settings, run it behind your
proxy and make the first account. You don't need a clone of the
repository, since that's for [contributing](contributing.md).
## What you need
- A Linux server, x86-64, with a volume for the data.
- A domain, with two DNS records pointing at the server: the server's own
name, as `pds.example.com`, and a wildcard under it, `*.pds.example.com`.
Each account's handle is a name under it, as `alice.pds.example.com`,
and each must reach the server.
- A domain with two DNS records pointing at the server. One is the
server's own name, such as `pds.example.com`, and the other is a wildcard
under it, `*.pds.example.com`. Each account's handle is a name under it,
such as `alice.pds.example.com`, and each one must reach the server.
- A reverse proxy that holds a TLS certificate for both names and passes
their requests to the server. The server speaks plain HTTP.
- An SMTP server to send mail through, for sign-up confirmations and
@@ -19,19 +19,19 @@ that is for [contributing](contributing.md).
## Get Monolith
The image:
Pull the image:
```sh
docker pull knotless.dev/chadtmiller.com/monolith
```
That is the latest version; a tag pins one, as
`knotless.dev/chadtmiller.com/monolith:0.2.0`. The image is the `pds`
binary alone, on Debian slim, run as a user of its own, with its data on
That's the latest version. A tag pins one, such as
`knotless.dev/chadtmiller.com/monolith:0.2.0`. The image holds only the
`pds` binary on Debian slim. It runs as its own user and keeps its data on
the volume `/data`. Its labels name its version and the commit it was
built from (`org.opencontainers.image.version` and `.revision`).
Or the binary, for Linux x86-64, of a version from the releases page:
Or get the binary for Linux x86-64 from the releases page:
```sh
v=0.2.0
@@ -41,16 +41,16 @@ tar xzf pds-$v-x86_64-linux.tar.gz && sudo install pds /usr/local/bin/
```
The [releases page](https://knotless.dev/chadtmiller.com/monolith/releases)
lists every version. With the [knotless](https://knotless.dev) CLI,
`knotless release download knotless://chadtmiller.com/monolith pds` takes
lists every version. If you have the [knotless](https://knotless.dev) CLI,
`knotless release download knotless://chadtmiller.com/monolith pds` fetches
the latest and checks each file against its release.
`pds` is one program: `pds serve` runs the server, and
`pds` is one program. `pds serve` runs the server, and
`pds <group> <command>` is the CLI that calls one.
## Configure it
The server takes its settings from its environment. Put them in a file,
The server reads its settings from its environment. Put them in a file,
`pds.env`:
```sh
@@ -71,15 +71,15 @@ PDS_BSKY_APP_VIEW_CDN_URL_PATTERN=https://cdn.bsky.app/img/%s/plain/%s/%s@jpeg
```
Keep this file safe. Whoever holds the rotation key controls every
account's DID, and the data directory holds no copy of it: without it, the
server can no longer change its accounts' DIDs, as a new handle needs.
[Deploying](deploying.md#the-environment) says what each setting is for,
and what else there is, as a recovery key kept offline.
account's DID, and the data directory doesn't keep a copy. If you lose it,
the server can't change its accounts' DIDs anymore, which a new handle
needs. [Deploying](deploying.md#the-environment) says what each setting is
for and what else there is, such as a recovery key kept offline.
`PDS_TRUSTED_PROXIES` names where the proxy's requests come from: with the
proxy on the same machine and the server in Docker, the bridge's gateway,
usually `172.17.0.1`; with the binary, `127.0.0.1`. Without it, every
client shares the proxy's rate limits.
`PDS_TRUSTED_PROXIES` says where the proxy's requests come from. If the
proxy is on the same machine and the server runs in Docker, that's the
bridge's gateway, usually `172.17.0.1`. With the binary, it's `127.0.0.1`.
If it isn't set, every client shares the proxy's rate limits.
## Run it
@@ -91,14 +91,14 @@ docker run -d --name monolith --restart unless-stopped \
knotless.dev/chadtmiller.com/monolith
```
Or the binary, its data in a directory of its own:
Or run the binary, with its data in a directory of its own:
```sh
set -a; . ./pds.env; set +a
PDS_PORT=2583 PDS_DATA_DIR=/var/lib/monolith pds serve
```
Either way it listens on `127.0.0.1:2583`. Point the proxy's two names at
Either way, it listens on `127.0.0.1:2583`. Point the proxy's two names at
that address, then check that it answers through the proxy:
```sh
@@ -107,12 +107,12 @@ curl https://pds.example.com/xrpc/_health
## Make the first account
The CLI calls the server named by `PDS_URL`. With the binary, run `pds` as
it is; with Docker, as `docker run --rm -e PDS_URL -e PDS_ADMIN_PASSWORD
knotless.dev/chadtmiller.com/monolith`, which passes on whichever of them
is set.
The CLI calls the server that `PDS_URL` names. With the binary, run `pds`
as it is. With Docker, run it as `docker run --rm -e PDS_URL -e
PDS_ADMIN_PASSWORD knotless.dev/chadtmiller.com/monolith`, which passes on
whichever of those is set.
As the admin, make an invite code; then, as no one, the account with it:
Make an invite code as the admin, then create the account with it:
```sh
export PDS_URL=https://pds.example.com
@@ -121,17 +121,18 @@ pds server create-account --handle alice.pds.example.com \
--email alice@example.com --password '…' --invite-code <the code>
```
The admin's password goes with the first command alone: with it set, the
CLI calls as the admin, and `createAccount` takes no admin
([MIGRATION.md](../../spec/MIGRATION.md#createaccount-with-a-did)). The account's DID is
made and registered with the PLC directory as the account is created.
The admin password goes only with the first command. When it's set, the
CLI calls as the admin, and `createAccount` doesn't take an admin
([MIGRATION.md](../../spec/MIGRATION.md#createaccount-with-a-did)). The
server makes the account's DID and registers it with the PLC directory
when it creates the account.
## Sign in
In the Bluesky app, sign in with `alice.pds.example.com` and its password,
choosing the custom hosting provider `https://pds.example.com`. An app
that signs in with OAuth instead sends you to the server's own sign-in
page.
and choose the custom hosting provider `https://pds.example.com`. An app
that signs in with OAuth sends you to the server's own sign-in page
instead.
## Next
docs/guide/operating.md+88−87
@@ -1,36 +1,37 @@
# Operating
This guide is about a server that runs: what it tells you, how it stops
and starts again, and what it takes of the machine. The rules are in
Once the server runs, you'll want to know what it tells you, how it stops
and starts again, and what it needs from the machine. The rules are in
[OPERATIONS.md](../../spec/OPERATIONS.md), [STORE.md](../../spec/STORE.md)
and [LIMITS.md](../../spec/LIMITS.md).
## The log
The server writes its log to standard output: one JSON object per line, a
line for every request it answers, and lines for events such as a start, a
recovery or a shutdown. It never logs passwords, tokens, codes, emails or
keys. Standard error is only for why `pds serve` exits 1, as when a
variable does not parse.
The server writes its log to standard output as one JSON object per line.
There's a line for every request it answers, and lines for events such as
a start, a recovery or a shutdown. It never logs passwords, tokens, codes,
emails or keys. Standard error is only for why `pds serve` exits 1, for
example when a variable doesn't parse.
`PDS_LOG_LEVEL` sets the least level written: `debug`, `info` (the
`PDS_LOG_LEVEL` sets the lowest level written: `debug`, `info` (the
default), `warn` or `error`, or `off` for none
([OPERATIONS.md](../../spec/OPERATIONS.md#the-log)).
Set `PDS_LOG_DIR` to keep each line in that directory too, so that it can
be read back without reaching the machine, and outlives a container made
again. Its files take at most `PDS_LOG_KEEP_BYTES` (64 MiB by default),
the oldest lines let go first. Keep it apart from `PDS_DATA_DIR`, on a
volume of its own: no backup needs it
Set `PDS_LOG_DIR` to keep each line in that directory too. Then you can
read it back without reaching the machine, and it outlives a rebuilt
container. Its files take at most `PDS_LOG_KEEP_BYTES` (64 MiB by
default), and the oldest lines go first. Keep it apart from
`PDS_DATA_DIR`, on its own volume, since no backup needs it
([OPERATIONS.md](../../spec/OPERATIONS.md#kept)).
## Reading the log and stats
With `PDS_ADMIN_PASSWORD` set, the admin reads what the server logged and
counted over its own port: `GET /xrpc/_logs` and `GET /xrpc/_stats`, with
`Authorization: Basic` and the user `admin`, or as the CLI's `pds admin
logs` and `pds admin stats`, or the MCP tools `admin_logs` and
`admin_stats` ([OPERATIONS.md](../../spec/OPERATIONS.md#the-admins-reads)):
When `PDS_ADMIN_PASSWORD` is set, the admin can read what the server
logged and counted over its own port. Use `GET /xrpc/_logs` and
`GET /xrpc/_stats` with `Authorization: Basic` and the user `admin`, the
CLI's `pds admin logs` and `pds admin stats`, or the MCP tools
`admin_logs` and `admin_stats`
([OPERATIONS.md](../../spec/OPERATIONS.md#the-admins-reads)):
```sh
export PDS_URL=https://pds.example.com PDS_ADMIN_PASSWORD=…
@@ -41,26 +42,26 @@ pds admin logs --method com.atproto.repo.createRecord --min-ms 500
pds admin stats # requests by route, since the start
```
`_logs` answers the last `limit` (100 by default, at most 500) of the lines
kept in `PDS_LOG_DIR` that match every filter given, oldest first; with no
`PDS_LOG_DIR` it is `404 LogNotKept`. `_stats` answers what the metrics
have counted since the server started, as JSON: requests by route and
status with their mean times, the requests it made, its syncs, its
accounts and its firehose; it needs no `PDS_METRICS_PORT`.
`_logs` answers with the last `limit` lines (100 by default, at most 500)
kept in `PDS_LOG_DIR` that match every filter given, oldest first. Without
`PDS_LOG_DIR` it answers `404 LogNotKept`. `_stats` answers with what the
metrics have counted since the server started, as JSON. That's requests by
route and status with their mean times, the requests it made, its syncs,
its accounts and its firehose. It doesn't need `PDS_METRICS_PORT`.
## Health
`GET /xrpc/_health` answers `200` with `{"version": "..."}` while the
server serves, and is in no rate limit. Point a load balancer or a
server serves, and it isn't rate limited. Point a load balancer or a
container's health check at it
([OPERATIONS.md](../../spec/OPERATIONS.md#health)).
## Metrics
Set `PDS_METRICS_PORT` to serve Prometheus metrics at `/metrics` on
`127.0.0.1` and that port. It has no auth, and is never on the server's own
port; unset, nothing listens. A scrape is no request of the server's: no
log line, no span, no rate limit
`127.0.0.1` and that port. It has no auth, and it's never on the server's
own port. When it's unset, nothing listens. A scrape doesn't count as a
request to the server, so it gets no log line, no span and no rate limit
([OPERATIONS.md](../../spec/OPERATIONS.md#metrics)).
## Traces
@@ -68,96 +69,96 @@ log line, no span, no rate limit
Set `OTEL_EXPORTER_OTLP_ENDPOINT` (or `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT`)
and the server exports a span for each request, and spans within it, by
OTLP over HTTP with protobuf. The other `OTEL_*` variables set headers,
compression, the service name and batching. A receiver that is down slows
no request ([OPERATIONS.md](../../spec/OPERATIONS.md#traces)).
compression, the service name and batching. A receiver that's down doesn't
slow any request ([OPERATIONS.md](../../spec/OPERATIONS.md#traces)).
## Stopping
On SIGTERM or SIGINT the server stops taking connections, lets the
requests under way finish for up to 10 seconds, closes the firehose's
subscriptions, syncs what it has written, exports its spans for up to 5
seconds, logs `shutdown`, and exits 0
On SIGTERM or SIGINT the server stops taking connections and gives the
requests under way up to 10 seconds to finish. Then it closes the
firehose's subscriptions, syncs what it has written, exports its spans for
up to 5 seconds, logs `shutdown`, and exits 0
([OPERATIONS.md](../../spec/OPERATIONS.md#events)).
A server killed, or a machine that lost power, loses no answered write: the
next start recovers, and logs `recovered`
If the server is killed or the machine loses power, no answered write is
lost. The next start recovers and logs `recovered`
([DURABILITY.md](../../spec/DURABILITY.md)). After a power cut, a write
never answered may be found whole with nothing kept of its event: that
event is never sent, and as its account is next used the firehose has the
events an activation makes, its `#sync` among them, once
([STORE.md](../../spec/STORE.md#scale)).
that was never answered may turn up whole with nothing kept of its event.
That event is never sent. Instead, the next time its account is used, the
firehose has the events an activation makes (its `#sync` among them),
once ([STORE.md](../../spec/STORE.md#scale)).
## Syncing writes
A write is on disk before it is answered, and writes waiting at once share
a sync. `PDS_SYNC` says how:
- `together` (the default): every write is written where its account
keeps it, and also to one journal for all, in `PDS_DATA_DIR/journal/`,
whose sync is what it waits for: one sync answers every write waiting
when it began, whichever accounts they are to. What the journal holds
the server makes durable where it is kept in the background, two
seconds after the last write or once the journal holds 16 MiB, and then
lets go of; a start after a kill or a power cut puts back from it what
is missing before it serves, and a shutdown leaves none of it. Its
files take a few bytes when the server is quiet, and up to twice what
was written in the last seconds while it is not.
- `each`: each account's writes are made durable by a sync of its own,
which only the writes waiting on that account share.
A write is on disk before the server answers it, and writes waiting at the
same time share a sync. `PDS_SYNC` picks how:
- `together` (the default): every write goes where its account keeps it,
and also to one shared journal in `PDS_DATA_DIR/journal/`. The write
waits for the journal's sync, so one sync answers every write waiting
when it began, whatever accounts they're for. In the background, the
server makes what the journal holds durable where it's kept, two seconds
after the last write or once the journal holds 16 MiB, and then lets it
go. A start after a kill or a power cut restores what's missing from the
journal before it serves, and a shutdown leaves none of it. Its files
take a few bytes when the server is quiet, and up to twice what was
written in the last seconds when it's busy.
- `each`: each account's writes are made durable by their own sync, which
only the writes waiting on that account share.
Any other value makes the server exit 1 as it starts, with `pds:
PDS_SYNC: ` and why. The `start` line of the log says which it is, as
`sync`. Either is safe, and a server started with one on a data directory
the other left carries on from it; `together` answers more writes a
second where many accounts are written at once, as on a disk whose sync
takes a millisecond or more
PDS_SYNC: ` and the reason. The log's `start` line shows which one it is,
as `sync`. Either is safe, and a server started with one carries on from a
data directory the other left. `together` answers more writes a second
when many accounts are written at once, such as on a disk whose sync takes
a millisecond or more
([DURABILITY.md](../../spec/DURABILITY.md#writes-waiting-at-once)).
## Upgrades
Stop the server, put the new binary or image in place, and start it on the
same data directory. A server starts on the data directory the last
release wrote, shut down or killed, and carries on from it, but for
spaces: an alpha, they are not carried across versions, and the server
starts with none of the spaces the release before kept. A data
directory a later version wrote it may refuse, exiting 1; it never serves
part of one ([STORE.md](../../spec/STORE.md#upgrades)). Its first start
on a data directory a release before the firehose's index wrote reads
every account's files once, for the events made before, and takes that
much longer to serve. So back the data directory up before an upgrade:
once a later version has written to it, the one before may not start on
it.
same data directory. The server starts on a data directory the last
release wrote, whether it was shut down or killed, and carries on from it.
Spaces are the exception. They're an alpha, so they aren't carried across
versions, and the server starts with none of the spaces the previous
release kept. It may refuse a data directory a later version wrote and
exit 1, but it never serves part of one
([STORE.md](../../spec/STORE.md#upgrades)). If a release from before the
firehose's index wrote the data directory, the first start reads every
account's files once for the earlier events, and takes that much longer to
serve. So back up the data directory before an upgrade. Once a later
version has written to it, the earlier one may not start on it.
## Disk
The data directory stays within three times what its accounts hold, plus
a constant for each account, as the server compacts it in the background
The data directory stays within three times what its accounts hold, plus a
constant for each account, since the server compacts it in the background
([STORE.md](../../spec/STORE.md#bounds)).
Below `PDS_MIN_FREE_BYTES` of free space (256 MiB by default) on the
filesystem of `PDS_DATA_DIR`, writes are refused with `507
InsufficientStorage`, and reads go on
When free space on the filesystem of `PDS_DATA_DIR` drops below
`PDS_MIN_FREE_BYTES` (256 MiB by default), the server refuses writes with
`507 InsufficientStorage` but keeps serving reads
([LIMITS.md](../../spec/LIMITS.md#disk)). Watch the free space, and grow
the volume before it gets there.
## Memory
The server's resident memory stays within its base, plus
`PDS_CACHE_BYTES` (256 MiB by default), plus 4 KiB for each account,
whatever the accounts hold. Set `PDS_CACHE_BYTES` to what the machine can
spare ([STORE.md](../../spec/STORE.md#scale)).
`PDS_CACHE_BYTES` (256 MiB by default), plus 4 KiB for each account, no
matter what the accounts hold. Set `PDS_CACHE_BYTES` to what the machine
can spare ([STORE.md](../../spec/STORE.md#scale)).
## Open files
As it starts the server raises its limit of file descriptors to the hard
limit it was given, and keeps at most a quarter of them open as accounts'
logs and a quarter as their tables, each no more than 4096: an account
whose files are not among them has them opened again when it is next read
or written. It serves every account under a hard limit of 256; one of
16384 or more lets it hold the most it will
When it starts, the server raises its file descriptor limit to the hard
limit it was given. It keeps at most a quarter of them open as accounts'
logs and a quarter as their tables, each capped at 4096. If an account's
files aren't among them, the server opens them again the next time it's
read or written. It serves every account under a hard limit of 256, and a
limit of 16384 or more lets it hold the most it will
([LIMITS.md](../../spec/LIMITS.md#open-files-and-threads)).
## Backups
[Deploying](deploying.md#backups) says how to back the server up, and what
a start on a backup does.
[Deploying](deploying.md#backups) explains how to back up the server, and
what a start on a backup does.
docs/README.md+10−17
@@ -1,36 +1,29 @@
# Monolith documentation
Monolith is an atproto PDS built from specifications, by agents, and
checked against the reference PDS. `spec/` says what the server does;
`crates/` is built from it alone, reading no source of the reference PDS
or of an atproto SDK; and `harness/compare.mjs` holds the result to the
reference PDS (`@atproto/pds`), the same random requests to both and every
answer compared.
A change is made in that order: the spec first, then a check in the
harness that fails against the server as it was, then the server, built
from the spec by an agent given the rules in
[AGENTS.md](../AGENTS.md#how-a-change-is-made).
Monolith is an atproto PDS that keeps its state in write-ahead logs on
local disk, with no database beside it. It speaks the same XRPC, OAuth and
firehose as the reference PDS (`@atproto/pds`), so the Bluesky app, relays
and AppViews talk to it like any other PDS.
## Guides
How to do things with Monolith, a task at a time. Running it needs no
clone of the repository; contributing does.
How to do things with Monolith, one task at a time. You don't need a clone
of the repository to run it, only to contribute.
- [Getting started](guide/getting-started.md): get the image or the
binary, configure it, run it behind your proxy, make the first account,
sign in from Bluesky.
binary, configure it, run it behind your proxy, make the first account
and sign in from Bluesky.
- [Calling the server](guide/calling.md): XRPC, the `pds` CLI, the MCP
endpoint, and connecting an AI app.
- [Deploying](guide/deploying.md): the image, the proxy, the environment,
blobs in a bucket, backups.
blobs in a bucket and backups.
- [Operating](guide/operating.md): the log, health, metrics, traces,
stopping, upgrades, disk and memory.
- [Comparing with the reference](guide/comparing.md): the harness's runs,
performance, the benchmark and the compatibility check.
- [Contributing](guide/contributing.md): working from a clone, a server
to try with `just dev --seed`, the just targets, the gates, nightly, the
code gates, releases.
code gates and releases.
## Specification
spec/OAUTH-SCOPES.md+3−3
@@ -9,9 +9,9 @@ sessions and the `Authorization` header's form are in
[`SESSIONS.md`](SESSIONS.md).
What is not served yet: OAuth tokens through the MCP tools and the CLI
(`COMMANDS.md`), which take only `Bearer` tokens. No method served needs
`account:repo` or `account:status`: those are for methods not served
(`importRepo`, `deactivateAccount` and the rest). Calls for other services
(`COMMANDS.md`), which take only `Bearer` tokens. `importRepo` needs
`account:repo` and `deactivateAccount` `account:status`, each to manage
(the methods' table, below). Calls for other services
(`PROXY.md`) need `rpc:` permissions ("Proxied calls", below); the space
methods (`SPACES.md`) need `space:` permissions ("Spaces", below).
spec/SPACES.md+3−3
@@ -451,6 +451,6 @@ The reference is held to each check too, which checks the check. The other
runs, against the `latest` reference, hold what the KEM key changes to
this page instead (`PDS.md`).
Not checked yet, as nothing serves it: that the server makes the shared
secret, MACs, signatures and archives the vectors hold, over HTTP, against
a syncer. Each later part checks its methods that way, in this run.
That the server makes the shared secret, MACs, signatures and archives the
vectors hold, over HTTP, against a syncer, each later part checks through
its own methods, in this run.
README.md+163−71
@@ -1,87 +1,179 @@
# Monolith
An atproto PDS built from specifications, by agents, and checked against
the reference PDS.
Monolith is an atproto PDS that keeps its state in write-ahead logs on
local disk, with no database beside it. A write is synced before it's
answered, so it survives the server being killed at any moment. Each
account is loaded when it's first used, so memory stays within the
server's base, a cache (256 MiB by default) and 4 KiB an account, however
much the accounts hold.
`spec/` says what the server does. Agents build `crates/` from it alone,
reading no source of the reference PDS or of an atproto SDK, and
`harness/compare.mjs` holds the result to the reference PDS
(`@atproto/pds`): the same random requests to both, every answer compared,
and the server's whole repository verified with the reference's own library.
![The consent page an app sends you to when it signs in with OAuth: the app, the account, what it asks for in plain words, and Allow, Deny and Back](docs/assets/consent.png)
It speaks the same XRPC, OAuth and firehose as the reference PDS
(`@atproto/pds`), so the Bluesky app, relays and AppViews talk to it like
any other PDS. It answers like the reference in every check of the
compatibility suite. Every method is also a `pds` command and an MCP tool,
so an AI app such as Claude can sign in and work with your account.
README.mdline 16

This says every method is an MCP tool, but Known gaps says blob upload and download and import-repo are CLI-only. Say "nearly every" or name the exceptions.

It's one Rust binary. In the benchmark it wrote records ~25 times as fast
as the reference (2,492/s against 99/s), started in 239 ms against 3.4 s,
and idled at ~20 MiB against ~378 MiB (on an M1 Pro, in Docker:
[bench/RESULTS.md](bench/RESULTS.md)).
## Highlights
- **Behaves like the reference.** Every area of the server is run beside
`@atproto/pds` with the same seeded random requests, every answer is
compared, and the server's whole repository is verified with the
reference's own library. A difference fails the gates.
→ [Comparing with the reference](docs/guide/comparing.md),
[Compatibility](compat/README.md)
- **Its own storage.** Writes waiting at the same time share one sync,
whichever accounts they're for, through a shared journal (`PDS_SYNC`).
The server compacts its logs in the background, so the data directory
stays within three times what its accounts hold. Blobs can go in an
S3-compatible bucket instead. → [Operating](docs/guide/operating.md),
[STORE.md](spec/STORE.md)
- **Three ways to call it.** Every method is an XRPC call, a `pds` command
and a tool on the MCP endpoint, all made from its lexicon. An MCP client
signs in with OAuth on the server's own pages.
→ [Calling the server](docs/guide/calling.md)
- **OAuth and passkeys.** The server is the OAuth authorization server for
its accounts, with its own sign-in and consent pages. An account can sign
in there with a passkey instead of its password.
→ [OAUTH.md](spec/OAUTH.md), [PASSKEYS.md](spec/PASSKEYS.md)
- **Spaces.** It serves permissioned data from atproto's spaces proposal,
OAuth `space:` permissions included, checked against the reference's
pinned spaces alpha. → [SPACES.md](spec/SPACES.md)
- **Fast and small.** Beside the reference in the benchmark, it served the
request mix at 2,483/s against 299/s, and peaked at 167 MiB against
806 MiB. → [Benchmark](bench/README.md), [results](bench/RESULTS.md)
## Quickstart
You need a Linux server, a domain with a wildcard record under it, a
reverse proxy holding TLS for both, and an SMTP server.
[Getting started](docs/guide/getting-started.md) walks through each one.
```sh
docker pull knotless.dev/chadtmiller.com/monolith
```
Put the settings in `pds.env` (Getting started lists them), then run it
and check that it answers through your proxy:
```sh
docker run -d --name monolith --restart unless-stopped \
-p 127.0.0.1:2583:2583 -v pds-data:/data --env-file pds.env \
knotless.dev/chadtmiller.com/monolith
curl https://pds.example.com/xrpc/_health
```
Make an invite code as the admin, then the first account with it:
```sh
export PDS_URL=https://pds.example.com
PDS_ADMIN_PASSWORD=… pds server create-invite-code --use-count 1
pds server create-account --handle alice.pds.example.com \
--email alice@example.com --password '…' --invite-code <the code>
```
The CLI is the same `pds` binary. With Docker, run it as `docker run --rm
-e PDS_URL -e PDS_ADMIN_PASSWORD knotless.dev/chadtmiller.com/monolith`.
The binary for Linux x86-64 is on the
[releases page](https://knotless.dev/chadtmiller.com/monolith/releases).
## Docs
The docs site is at https://chadtmiller-com.knotless.page/monolith/, built
from [`docs/`](docs/README.md), the spec and the reference pages.
| | |
| --- | --- |
| [Getting started](docs/guide/getting-started.md) | Get the image or the binary, configure it, run it, make the first account |
| [Calling the server](docs/guide/calling.md) | XRPC, the `pds` CLI, the MCP endpoint, connecting an AI app |
| [Deploying](docs/guide/deploying.md) | The image, the proxy, the environment, blobs in a bucket, backups |
| [Operating](docs/guide/operating.md) | The log, health, metrics, traces, upgrades, disk and memory |
| [Comparing with the reference](docs/guide/comparing.md) | The harness's runs, performance, the benchmark, the compatibility check |
| [Contributing](docs/guide/contributing.md) | Working from a clone, a server to try, the gates, releases |
| [PDS.md](spec/PDS.md) | The specification: what the server does, with a page for each area |
| [COMMANDS.md](spec/COMMANDS.md) | Every method as an MCP tool and a CLI command |
| [Compatibility](compat/README.md) | How closely other PDSes behave like the reference |
| [Benchmark](bench/README.md) | Monolith beside other PDSes, and how it's run |
## Layout
| Path | Is |
| Path | |
| --- | --- |
| `spec/` | the specification: `PDS.md` for the server, with a page for each area of it beside it (`ACCOUNTS.md`, `SESSIONS.md`, `EMAIL.md`, `LIFECYCLE.md`, `MIGRATION.md`, `REPO.md`, `VALIDATION.md`, `SYNC.md`, `FEDERATION.md`, `IDENTITY.md`, `BLOBS.md`, `PROXY.md`, `SPACES.md` with `SPACES-REPO.md`, `SPACES-CREDENTIALS.md`, `SPACES-POLICIES.md`, `SPACES-EXPORT.md` and `SPACES-SYNC.md`, `DURABILITY.md`, `LIMITS.md`, `OAUTH.md`, `OAUTH-SCOPES.md`, `OAUTH-CLIENTS.md`, `OAUTH-PAGES.md`, `OAUTH-PERMISSION-SETS.md`, `OAUTH-ACCOUNT.md`, `PASSKEYS.md`, `OPERATIONS.md`), `COMMANDS.md` for its MCP tools and CLI commands, with atproto's specs, the RFCs OAuth rests on, WebAuthn and the CBOR and COSE RFCs passkeys rest on (`webauthn/`), the spaces proposal and what it rests on (`spaces/`), the lexicons the server serves and the record lexicons it checks writes against, atproto's test vectors and the spaces vectors, and MCP's specification |
| `harness/` | runs the server beside the reference PDS and compares them: `compare.mjs` the run, its shared plumbing in `lib/`, and each area's checks in `checks/`; `upgrade/` the data directories and answers of the last release, which the upgrade run holds the server to; `perf.mjs` the performance step; `gates.mjs` every gate, and `code.mjs`, `spec-coverage.mjs`, `layers.mjs` and `contrast.mjs` the ones cargo has no flag for; `look.mjs` the authorization pages drawn in any state (`just look`); `spaces/` the spaces run, beside the pinned spaces alpha of the reference, with its own dependencies, and the spaces vectors' check (`vectors.mjs`) |
| `web/` | the OAuth authorization pages (`spec/OAUTH-PAGES.md`): one Svelte 5 app, its components in atomic design's layers, its styles from `src/tokens.css`, built by Vite into `web/dist`, which `pds-server` embeds when it is compiled; `web/AGENTS.md` says how it is made |
| `crates/pds-repo` | the data model (DAG-CBOR, CIDs), the MST, signed commits and CAR files, with no I/O; checked by atproto's test vectors |
| `crates/pds-store` | the append-only log the server keeps its state in; checked by its own tests and the server's, which cut the log at every byte of its last write |
| `crates/pds-lexicon` | the lexicons in `spec/lexicons`, as data: each method's arguments, and the MCP tool and CLI command made from it |
| `crates/pds-server` | the PDS: XRPC, the firehose and the MCP endpoint, over `pds-repo`, `pds-store` and `pds-lexicon`; `lib.rs` routes and dispatches each call to its area's module (`server.rs`, `sessions.rs`, `email.rs`, `lifecycle.rs`, `repo.rs`, `sync.rs`, `federation.rs`, `identity.rs`, `blobs.rs`, `invites.rs`), beside the firehose (`events.rs`), the MCP endpoint (`mcp.rs`), the OAuth authorization server (`oauth.rs`), whose pages (`oauth/page.rs`) are the build of `web/` that `build.rs` embeds at compile time and `oauth/assets.rs` serves, the PLC directory (`plc.rs`), the bucket blobs may be kept in (`blobstore.rs`), the limits every call meets (`limits.rs`), the logs it starts again from (`log.rs`), their generations, compaction and the backfill window (`store.rs`), an account's checkpoint (`checkpoint.rs`), the service log's (`compact.rs`), and the accounts, each loaded from it on its first use (`directory.rs`) |
| `crates/pds-cli` | the CLI: each method as a command, a client of a running server |
| `crates/pds` | the one binary: `pds serve` runs the server, `pds <group> <command>` the CLI; its allocator is jemalloc, built by `.cargo/config.toml` to give freed memory back at once, so that resident memory follows what is in use (`spec/STORE.md`, "Scale") |
| `Dockerfile` | the server as a container image ([Deploying](docs/guide/deploying.md)); `.knotless/image.sh` makes the released one from the same binary, with no container engine |
| `.changeset/`, `CHANGELOG.md`, `knope.toml` | the change files of the next release, what each version changed for those who run the server or call it, and how `knope` makes a release of them ([Contributing](docs/guide/contributing.md#releases)) |
| `docs/` | the guides: running, calling, deploying, operating, comparing and contributing to the server |
| `docs-site/` | the documentation site, built with Astro from `docs/`, `spec/`, the lexicons, `compat/` and `bench/`; its landing page (`src/pages/index.astro`) is the photograph, a headline, one sentence and two buttons, its words written as `.claude/skills/landing` says and its one figure read from `bench/results.json` |
The Rust is one workspace, laid out flat: every crate one level down in
`crates/`, in a directory named as the crate, under a root `Cargo.toml` that
holds only the workspace, its shared package fields and its dependencies'
versions.
## Documentation
The documentation is at https://chadtmiller-com.knotless.page/monolith/,
built from [`docs/`](docs/README.md) and the spec. The guides:
- [Getting started](docs/guide/getting-started.md): get the image or the binary, configure it, run it, make the first account.
- [Calling the server](docs/guide/calling.md): XRPC, the `pds` CLI and the MCP endpoint.
- [Deploying](docs/guide/deploying.md): the image, the environment, backups.
- [Operating](docs/guide/operating.md): the log, health, metrics, upgrades, disk and memory.
- [Comparing with the reference](docs/guide/comparing.md): the harness's runs, the benchmark, the compatibility check.
- [Contributing](docs/guide/contributing.md): working from a clone, a server to try, the gates, the code gates, releases.
| `spec/` | The specification. `PDS.md` links a page for each area, and beside them are the specs it rests on (atproto's, the RFCs, WebAuthn, the spaces proposal, MCP's), the lexicons and the test vectors |
| `harness/` | Runs the server beside the reference and compares them: `compare.mjs` and its `checks/`, the upgrade run, `perf.mjs`, the benchmark, the compatibility check, the gates, `look.mjs` and the spaces run |
| `web/` | The OAuth authorization pages, a Svelte 5 app that `pds-server` embeds at compile time (`web/AGENTS.md`) |
| `crates/pds-repo` | The data model (DAG-CBOR, CIDs), the MST, signed commits and CAR files, with no I/O, checked by atproto's test vectors |
| `crates/pds-store` | The append-only log the server keeps its state in |
| `crates/pds-lexicon` | The lexicons as data: each method's arguments, and the MCP tool and CLI command made from it |
| `crates/pds-server` | The PDS: XRPC, the firehose, the MCP endpoint and OAuth. Each area's methods are a module of their own, named in `lib.rs`'s `AREAS` |
| `crates/pds-cli` | The CLI, a client of a running server |
| `crates/pds` | The one binary, `pds`. Its allocator is jemalloc, built by `.cargo/config.toml` to give freed memory back at once, so resident memory follows what's in use (`spec/STORE.md`, "Scale") |
| `Dockerfile` | The image ([Deploying](docs/guide/deploying.md)). `.knotless/image.sh` makes the released one from the same binary |
| `.changeset/`, `CHANGELOG.md`, `knope.toml` | Change files for the next release, what each version changed, and how `knope` makes a release ([Contributing](docs/guide/contributing.md#releases)) |
| `docs/` | The guides |
| `docs-site/` | The docs site, built with Astro from `docs/`, `spec/`, the lexicons, `compat/` and `bench/`. Its landing page's words follow `.claude/skills/landing` |
| `compat/`, `bench/` | The compatibility check's and the benchmark's pages and results |
The Rust is one flat workspace. Every crate sits one level down in
`crates/`, and the root `Cargo.toml` holds only the workspace, its shared
package fields and its dependencies' versions.
## Development
You need Rust through rustup and the Node version `.node-version` names.
```sh
(cd harness && npm ci) && (cd web && npm ci)
just dev --seed # a server to try, with accounts in it
just quick # a short harness run of each kind, while you work
```
A change goes spec first, then a harness check that fails, then the
server ([AGENTS.md](AGENTS.md#how-a-change-is-made)). `just gates` runs
everything on the runner when you push.
[Contributing](docs/guide/contributing.md) has the rest.
## Known gaps
- A server started on a backup does nothing about the rollback: it numbers
its firehose events again from the backup's last, and tells no relay or
AppView to sync its accounts again.
- Accounts are made with `createAccount`, or move in with their DID
(`MIGRATION.md`).
- Of OAuth, no account pages (`/account`): an account lists and ends its
OAuth sessions and devices with `pds oauth …` and the `oauth_` tools
- A server started from a backup doesn't handle the rollback. It numbers
its firehose events again from the backup's last one, and doesn't tell
any relay or AppView to sync its accounts again.
- There are no OAuth account pages (`/account`). An account lists and ends
its OAuth sessions and devices with `pds oauth …` and the `oauth_` tools
instead (`OAUTH-ACCOUNT.md`), and adds and removes passkeys with `pds
passkey …` and the `passkey_` tools (`PASSKEYS.md`). Passkeys are ES256
or RS256, with `none` attestation alone. No sign-up from the
authorization page. Permission sets are resolved through DNS, which the
harness cannot serve both sides: it checks them through
`PDS_LEXICON_AUTHORITY_DID`, and the server's own tests the DNS lookup.
The server makes `did:plc` accounts alone; a `did:web` account moves in
with a service token its owner signs (`MIGRATION.md`). `resolveHandle` answers only its accounts' handles, and asks no one
of another. Of the sync methods, it serves `getRepo`,
`getLatestCommit`, `subscribeRepos`, `listRepos`, `getRepoStatus`,
`getBlocks`, `getRecord`, `getBlob` and `listBlobs`, and sends
`requestCrawl` to its crawlers without serving it.
- Of spaces (`spec/SPACES.md`), each account's KEM key, its space repos
(`SPACES-REPO.md`), credentials (`SPACES-CREDENTIALS.md`), policies
and the space lifecycle (`SPACES-POLICIES.md`), full-state sync: STAR
`getRepo`, space blobs and importing a repo (`SPACES-EXPORT.md`),
write notifications, the writer set and syncers' registrations
(`SPACES-SYNC.md`), and OAuth `space:` permissions
(`OAUTH-SCOPES.md`, "Spaces"), whose space type declarations resolve
as permission sets do. The authorization page shows a `space:`
permission as its scope string, not in words.
- No MCP tool uploads or reads blobs, or imports a repository:
passkey …` and the `passkey_` tools (`PASSKEYS.md`).
- Passkeys are ES256 or RS256, with only `none` attestation.
- There's no sign-up from the authorization page.
- The authorization page shows a `space:` permission as its scope string
instead of describing it in words (`OAUTH-SCOPES.md`, "Spaces").
- The CLI and the MCP tools take only `Bearer` tokens, so an OAuth token
can't be used through them (`OAUTH-SCOPES.md`).
- Permission sets are resolved through DNS, and the harness can't serve
that to both sides. It checks them through `PDS_LEXICON_AUTHORITY_DID`,
and the server's own tests check the DNS lookup.
- The server makes only `did:plc` accounts. A `did:web` account moves in
with a service token its owner signs (`MIGRATION.md`).
- `resolveHandle` answers only its own accounts' handles, and doesn't ask
anyone else.
- Of the sync methods, it serves `getRepo`, `getLatestCommit`,
`subscribeRepos`, `listRepos`, `getRepoStatus`, `getBlocks`,
`getRecord`, `getBlob` and `listBlobs`. It sends `requestCrawl` to its
crawlers but doesn't serve it.
- No MCP tool uploads or reads blobs, or imports a repository.
`upload-blob`, `get-blob` and `import-repo` are CLI commands only.
- MCP serves only tools: no resources, prompts or `subscriptions/listen`.
- Mail sent over SMTP (`EMAIL.md`) is no outbound request of
`OPERATIONS.md`: it has no span and no `pds_outbound_*` metrics.
- MCP serves only tools. There are no resources, prompts or
`subscriptions/listen`.
- Mail sent over SMTP (`EMAIL.md`) isn't an outbound request in the sense
of `OPERATIONS.md`, so it has no span and no `pds_outbound_*` metrics.
## License
MIT or Apache-2.0, at your option: [`LICENSE-MIT`](LICENSE-MIT),
[`LICENSE-APACHE`](LICENSE-APACHE). The specifications, lexicons and RFCs
vendored under `spec/` keep their own licenses, beside them.
[`LICENSE-APACHE`](LICENSE-APACHE). The specs, lexicons and RFCs vendored
under `spec/` keep their own licenses, which sit beside them.