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

A documentation site built from docs/, the spec and the lexicons

Merged chadtmiller.com asked to merge into main from chadtmiller.com/monolith:docs/site
.knotless/workflows/docs.ymlnew+29−0
@@ -0,0 +1,29 @@
# The documentation site (docs-site/): the guides under docs/, the
# specification's pages, and the methods and variables made from the
# lexicons and the spec's tables. Its 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, so a pull that breaks one
# is caught. On a push to main it is deployed as the repository's site, at
# https://chadtmiller-com.knotless.page/spec-pds/, logged in with the
# owner's app password in SITE_PASSWORD, which no pull is given.
image: node:24.22.1
runners: [runner.knotless.dev]
# The two lists are the same; keep them so.
on:
push:
refs: [refs/heads/main]
paths: [docs/**, spec/*.md, spec/lexicons/**, compat/*.md, bench/*.md, docs-site/**, web/src/tokens.css, .knotless/workflows/docs.yml, .knotless/uses.lock]
pull:
base: [refs/heads/main]
paths: [docs/**, spec/*.md, spec/lexicons/**, compat/*.md, bench/*.md, docs-site/**, web/src/tokens.css, .knotless/workflows/docs.yml, .knotless/uses.lock]
secrets: [SITE_PASSWORD]
cache: [docs-site/node_modules]
steps:
- uses: chadtmiller.com/steps/npm-ci@1
with: {dir: docs-site}
- name: build
run: cd docs-site && npm run build
- uses: chadtmiller.com/steps/site@1
on: {refs: [refs/heads/main]}
with: {dir: docs-site/dist}
secrets: [SITE_PASSWORD]
.knotless/review.md+1−1
@@ -1,6 +1,6 @@
This repository builds a PDS from specifications: agents build `crates/` from `spec/`, and `harness/` checks it against the reference PDS. Check that:
- Every change in behaviour is in `spec/` (`PDS.md` or the page of its area beside it, `COMMANDS.md` or a lexicon) as well as in the code, and the README says what is built, not how it came to be built.
- Every change in behaviour is in `spec/` (`PDS.md` or the page of its area beside it, `COMMANDS.md` or a lexicon) as well as in the code, and the README and `docs/` say what is built, not how it came to be built; a change to how the server is run, deployed, called or checked updates its guide in `docs/guide/`.
- A harness change makes a check stricter or fixes it, and never loosens one so that a server passes. A new check says what it compares, and with what.
- Server code takes nothing from the reference PDS's or an SDK's source, and adds no atproto or MCP crates.
- Each conformance check excused in `harness/conformance.yaml` gives a reason that the suite's source supports.
.knotless/uses.lock+4−0
@@ -7,3 +7,7 @@ chadtmiller.com/steps/npm-ci@1:
version: 1.0.0
commit: 686cdbb38978730bb1ba5d1c999967e48497ce15
release: at://did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.release/3mza7iq7tundv.dzyz2ceqihhxzgk2f2637ygpfw.sjjb7q6l3fsl3spvqsuzdoe73w
chadtmiller.com/steps/site@1:
version: 1.0.0
commit: c09eceeb5cb08db27056ebe6e11a533baf716839
release: at://did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.release/3mza7iq7tundv.j72zsnw3q3ykgliyoih74ixcru.sjjb7q6l3fsl3spvqsuzdoe73w
docs/guide/calling.mdnew+77−0
@@ -0,0 +1,77 @@
# 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.
## Names
The tool and the command are made from the method's lexicon
([COMMANDS.md](../../spec/COMMANDS.md#names)):
`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.
Where a method names an account, as `repo` does, the tool and the command
may leave it out, for the token's account.
## XRPC
The methods are under `/xrpc/`, as on any atproto PDS:
```sh
curl http://127.0.0.1:2583/xrpc/com.atproto.server.describeServer
```
## The CLI
`pds <group> <command> [flags]` calls a running server. It reads three
variables:
| Variable | Is |
| --- | --- |
| `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` |
Sign in, keep the access token, and call:
```sh
export PDS_URL=http://127.0.0.1:2583
export PDS_TOKEN=$(pds server create-session --identifier alice.test --password … | jq -r .accessJwt)
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.
## 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.
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.
## 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:
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".
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?"
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.
docs/guide/comparing.mdnew+256−0
@@ -0,0 +1,256 @@
# Comparing with the reference
The server is held to the reference PDS (`@atproto/pds`) by
`harness/compare.mjs`. This guide says what the runs check, and how to run
each by hand. [PDS.md](../../spec/PDS.md#how-it-is-checked) says what is
compared, and each area's page has its own "How it is checked".
You need the harness's packages and a built server
([Getting started](getting-started.md)).
## The comparison
`spec/PDS.md` says what the server does and how `compare.mjs` checks it:
the server and the reference PDS get the same random requests, and their
answers must agree, past what differs between any two servers. The
reference's own library must verify the server's whole repository, and its
MST root must equal the reference's.
Some requests go at once: puts of different keys, and batches racing on the
same commit, of which exactly one may land.
What the server forwards, to the AppView, a chat service or any service an
`atproto-proxy` header names, goes on both sides to stub services
(`harness/lib/services.mjs`). Those record what each side sent, so the
harness compares the forwarded requests, their headers and service-auth
tokens, as well as the answers.
OAuth's permission sets
([OAUTH-PERMISSION-SETS.md](../../spec/OAUTH-PERMISSION-SETS.md)) are
published by an account on a third PDS that shares the PLC directory, and
both servers are pointed at it, so each resolves the harness's sets over
the network, with their proofs, as it would any app's. PAR's answers, the
page's data, the token's expanded `scope` at sign-in and refresh, and what
calls a set's session may make are compared with the reference.
Every run ends with the server's operations
([OPERATIONS.md](../../spec/OPERATIONS.md)): its `/xrpc/_health` against
the reference's; its metrics against its log and what the harness sent;
every span against the request it is of, at a stub OTLP receiver that the
run takes away for a while; a shutdown, and starts at another log level,
with a PLC directory that fails, after a kill, and with variables that do
not parse; and its whole log, a line for every request, holding none of
the passwords, tokens, codes, emails or keys the run handled.
A second server, built again from `spec/` by an agent working
independently of the first, passed the same harness, with the same
repository encoding and the same behaviour the specs leave open.
## Running it
From `harness/`, with the server's command after `--`:
```sh
cd harness && npm ci
node compare.mjs --steps 400 --seed 1 -- ../target/release/pds serve
```
A seed makes the same requests every run. Each flag below is a run of its
own kind.
### Crashes and the firehose
```sh
node compare.mjs --steps 1000 --seed 21 --crash-every 15 --firehose -- ../target/release/pds serve
```
With `--crash-every N` the harness kills the server with SIGKILL every N
steps, often during a write, starts it again on the same data, and checks
that every answered write survived and the interrupted write landed whole
or not at all. What survives a power cut is checked by `pds-server`'s own
tests, which cut its log short at every byte of its last write.
With `--firehose` the harness also subscribes to both servers'
`subscribeRepos`. It checks each of the server's events as a consumer would
(signature, the chain of `since` and `prevData`, the ops undone on the tree
in the event giving the previous root, and the reference library's
`verifyProofs`), compares its commits with the reference's by their ops,
and replays from random cursors. With crashes, the stream must carry on
after each restart with no gap or repeat.
### Tools and commands
```sh
node compare.mjs --steps 400 --seed 31 --commands -- ../target/release/pds serve
node conformance.mjs -- ../target/release/pds serve
```
`--commands` sends some of its requests through the MCP tool or the CLI
command instead of XRPC, in any of the three MCP revisions, held to the
reference as the rest are. It first checks every tool's schema and every
command's flags against the lexicons, and each legacy revision's handshake
([COMMANDS.md](../../spec/COMMANDS.md#how-it-is-checked)).
`conformance.mjs` runs MCP's conformance suite against the endpoint, for
`2026-07-28` and `2025-11-25`.
### Invites and limits
```sh
node compare.mjs --steps 400 --seed 1 --invites -- ../target/release/pds serve
node compare.mjs --steps 400 --seed 1 --limits -- ../target/release/pds serve
```
`--invites` runs the reference and the server with invite codes required.
`--limits` turns the rate limits on and compares each with the
reference's, with password sessions and OAuth tokens, then holds the
server alone to the rest of [LIMITS.md](../../spec/LIMITS.md): file modes,
the session and app-password caps, firehose messages and subscribers,
calls to the PLC directory, timeouts, the free-space floor, the blob quota
and its time for unreferenced uploads, and starting again with more
accounts than open files allowed.
### Lifecycle
```sh
node compare.mjs --lifecycle -- ../target/release/pds serve
```
`--lifecycle` ([LIFECYCLE.md](../../spec/LIFECYCLE.md)): accounts
deactivated, taken down by the admin and deleted by emailed token, and
what each state does to every method and to the firehose. With
`--crash-every N`, the server is killed every N changes of state.
### The store, scale and upgrades
```sh
node compare.mjs --steps 600 --seed 51 --crash-every 40 --store -- ../target/release/pds serve
node compare.mjs --scale -- ../target/release/pds serve
node compare.mjs --upgrade -- ../target/release/pds serve
```
`--store` holds the server to [STORE.md](../../spec/STORE.md): with a
five-second backfill window on both sides, it rewrites a few accounts'
records, blobs and space records many times over, kills the server while
it reorganizes its data, compares every read and the firehose's
`OutdatedCursor` replays with the reference, and then holds the data
directory to three times the live state and a constant for each account,
and each start to twice the first.
`--scale` holds the server alone to STORE.md's
[scale rules](../../spec/STORE.md#scale), with a 16 MiB cache: its resident
memory, sampled while it holds 2000 accounts, touches each, writes a 64 MiB
repository and streams it back and replays the firehose, stays within its
base, the cache and 4 KiB an account; and it starts as fast with all of
that as on an empty data directory.
`--upgrade` starts the server alone on the data directories the last
release wrote, in `harness/upgrade/`, one shut down and one killed, and
holds every read to what that release answered there, and its next writes
to carrying on from that release's
([STORE.md](../../spec/STORE.md#upgrades)).
### Blobs in a bucket
`--migrate` moves the server's blobs from its data directory into a bucket
and back with `pds migrate-blobs`, killed at random moments and run again,
one move turned back halfway and one stopped by an object gone, and reads
every blob against the reference's after each
([BLOBS.md](../../spec/BLOBS.md#moving-them)); and holds the data directory
to one process at a time.
`--s3` keeps both sides' blobs in buckets of an S3 store the harness runs
in process, which checks every request's signature
([BLOBS.md](../../spec/BLOBS.md#where-blobs-are-kept)). With the random
steps and crashes, or `--lifecycle`, the store fails uploads, reads and the
server's deletes for both sides alike, and the answers are compared; the
server's bucket is held to what its accounts hold, within a minute, and its
data directory to holding no blob's bytes.
### The authorization pages
```sh
node compare.mjs --pages --seed 1 -- ../target/release/pds serve
```
`--pages` drives the OAuth authorization pages in Chromium on both sides
([OAUTH-PAGES.md](../../spec/OAUTH-PAGES.md)): flows from a PAR to the
client's redirect URI, signing in, remembered accounts, the email code, two
tabs of one request, denials and backs, each taken the same way on both
sides. The API calls each page made and where it landed are compared, and
its codes exchanged. The server's pages alone are held to the rest of the
page: their views and words, the consent list for each scope, focus, busy
buttons, headers and HTML, assets, console, the origins asked, the width on
a phone, and axe-core's WCAG rules.
### Spaces
The spaces run ([SPACES.md](../../spec/SPACES.md)) checks the server
against the pinned spaces alpha of the reference, with its own packages:
```sh
cd harness/spaces && npm ci
node compare.mjs --seed 1 -- ../../target/release/pds serve
```
## Performance
```sh
node perf.mjs -- ../target/release/pds serve
```
`perf.mjs` runs one workload against both, each in a process of its own.
The server's p99 must be within 1.5 times the reference's, and its
throughput at least 0.8 times the reference's.
## Other PDSes
### The benchmark
`harness/bench.mjs` benchmarks the server beside other PDSes on this
machine, one at a time: perf's workload with `applyWrites` and
`listRecords`, each part's throughput, p50 and p99, and each server's start
time and memory. Each implementation is an adapter in it, pinned in
`bench/impls.json`. [bench/README.md](../../bench/README.md) says how to
run and extend it, and [bench/RESULTS.md](../../bench/RESULTS.md) holds the
last results, with the machine and every caveat.
```sh
cd harness && node bench.mjs --setup && node bench.mjs --rounds 3 --json ../bench/results.json
```
`just bench` runs the same.
### The store benchmark
`bench/store/` benchmarks how the server keeps its data, apart from the
rest of it: its logs (`crates/pds-store`) beside SQLite under the same
commits, each synced before it is answered; a log replayed; and the
server's start and memory by the number of accounts in its service log,
beside STORE.md's bounds.
[bench/store/README.md](../../bench/store/README.md) says what each part
measures, and [bench/store/RESULTS.md](../../bench/store/RESULTS.md) holds
the last results, by machine. The `store-bench` workflow runs it on the
runner, on a pull that changes it and when the owner asks.
```sh
just store-bench
```
### Compatibility
`harness/compat.mjs` checks how closely any PDS behaves like the
reference, area by area: the core of `compare.mjs`'s checks (OAuth and its
scopes, sessions, accounts, records, validation, the repository, sync, the
firehose, identity, blobs), against each implementation with an adapter in
`harness/lib/adapters/`, going on past a difference.
[compat/README.md](../../compat/README.md) says which checks it runs and
how to add an implementation; [compat/RESULTS.md](../../compat/RESULTS.md)
holds the last run, against spec-pds, zds, vlpds and pds.js.
```sh
just compat
```
which is `cd harness && node bench.mjs --setup && node compat.mjs --steps
200 --json ../compat/results.json`. Arguments pass through, as `just compat
--impls zds --areas oauth`.
docs/guide/contributing.mdnew+100−0
@@ -0,0 +1,100 @@
# 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 the checks a change
meets, and how a release is made.
## The just targets
The [Justfile](../../Justfile) holds them:
```sh
just test # the crates' own tests
just quick # a short harness run of each kind, for while working
just code # the code gates (below)
just perf # the performance step
just gates # the code gates, the tests and the harness runs
just nightly # the long crash runs, then the performance step
just look consent # an authorization page drawn, desktop light and phone dark, in target/look
just dev --seed # a server to try by hand (Getting started)
```
While you work, run `just quick` alone. Push the branch and open the pull
early: 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.
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.
## 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, then 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:
```sh
knotless run rerun --ref main --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`
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.
- 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.
## The pages, by eye
`just look` draws an authorization page in a browser, in any state, as
pictures in `target/look` to open:
```sh
just look consent --scope 'atproto repo:*'
```
## Releases
A release is `main` with the workspace's `version` raised, tagged
`v<version>`. As it is tagged, `harness/upgrade/` is written again with its
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:
```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
```
docs/guide/deploying.mdnew+99−0
@@ -0,0 +1,99 @@
# Deploying
This guide runs the server on the network: in a container or outside one,
behind a reverse proxy, and backed up.
## The image
The [Dockerfile](../../Dockerfile) builds the server as an image: the
pages, then `pds` with the gates' toolchain, on Debian slim, run as a user
of its own. It sets `PDS_PORT=2583`, `PDS_BIND_ADDRESS=::` and
`PDS_DATA_DIR=/data`, a volume.
```sh
docker build -t spec-pds .
docker run -d -p 2583:2583 -v pds-data:/data --env-file pds.env spec-pds
```
The image is the `pds` binary alone: `pds <group> <command>` in it is the
CLI, as anywhere.
`docker stop` sends SIGTERM, which shuts the server 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.
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
([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)).
## The environment
What a server on the network is given, besides those. Each variable's page
says the rest.
| Variable | Is |
| --- | --- |
| `PDS_HOSTNAME`, `PDS_PUBLIC_URL` | its host name, and its `https://` URL |
| `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_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; `true` unless anyone may sign up |
| `PDS_CRAWLERS` | the relays told of it, 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_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_DEV_MAIL_DIR`, `PDS_OAUTH_CLIENT_FETCH` and
`PDS_DISABLE_SSRF_PROTECTION` are for development, never for 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)).
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:
```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)).
## 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
([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.
Keep the environment apart, and safe: the data directory holds no 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.
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.
docs/guide/getting-started.mdnew+99−0
@@ -0,0 +1,99 @@
# Getting started
This guide builds the server and runs one on your machine to try by hand,
with accounts to sign in as.
## What you need
- Rust, through [rustup](https://rustup.rs). The Justfile runs cargo as
`rustup run stable cargo`.
- Node, 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:
```sh
cd harness && npm ci && cd ..
cd web && npm ci && cd ..
```
- Chromium, for the harness's `--pages` run and `just look` only:
```sh
cd harness && npx playwright install chromium
```
## Build
```sh
just build
```
This builds the authorization pages in `web/` into `web/dist`, then `pds`
into `target/release/pds`, which embeds them. `pds` is one binary: `pds
serve` runs the server, and `pds <group> <command>` is the CLI.
## Run a server to try
```sh
just dev --seed
```
`just dev` builds `pds`, then runs
[`harness/dev.mjs`](../../harness/dev.mjs): the server on
`127.0.0.1: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 files are 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.
It prints where the server and its PLC directory are, the `export` lines
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.
- `--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`.
- `--port <n>` listens on another port.
- `-- <command...>` runs another server command in place of
`../target/release/pds serve`.
The admin's password is `admin`, and handles end in `.test`.
## Sign in and write a record
Paste the `export` lines it printed, with `target/release/pds` on your
`PATH`:
```sh
export PDS_URL=http://127.0.0.1:2583 PDS_ADMIN_PASSWORD=admin
export PDS_TOKEN=$(pds server create-session --identifier alice.test --password password | jq -r .accessJwt)
```
Now you are `alice.test`. Write a record, and list it:
```sh
pds repo create-record --collection com.example.note --record '{"text":"hi"}'
pds repo list-records --collection com.example.note --limit 5
```
The command leaves out `--repo`: where a method names an account, the CLI
takes the token's. [Calling the server](calling.md) says more about the CLI
and about MCP.
## Mail
`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",
"token"}` ([EMAIL.md](../../spec/EMAIL.md#the-development-sink)).
## Stop it
Press Ctrl-C. The server shuts down, and the PLC directory's operations
are saved. Run `just dev --keep` to carry on from there.
docs/guide/operating.mdnew+85−0
@@ -0,0 +1,85 @@
# 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
[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.
`PDS_LOG_LEVEL` sets the least level written: `debug`, `info` (the
default), `warn` or `error`, or `off` for none
([OPERATIONS.md](../../spec/OPERATIONS.md#the-log)).
## Health
`GET /xrpc/_health` answers `200` with `{"version": "..."}` while the
server serves, and is in no rate limit. 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
([OPERATIONS.md](../../spec/OPERATIONS.md#metrics)).
## Traces
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)).
## 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
([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`
([DURABILITY.md](../../spec/DURABILITY.md)).
## 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. A data
directory a later version wrote it may refuse, exiting 1; it never serves
part of one ([STORE.md](../../spec/STORE.md#upgrades)).
## 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
([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
([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)).
## Backups
[Deploying](deploying.md#backups) says how to back the server up, and what
a start on a backup does.
docs/README.mdnew+44−0
@@ -0,0 +1,44 @@
# spec-pds documentation
spec-pds 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).
## Guides
How to do things with spec-pds, a task at a time.
- [Getting started](guide/getting-started.md): build it, run a server to
try with `just dev --seed`, sign in, write a record.
- [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.
- [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): the just targets, the gates,
nightly, the code gates, releases.
## Specification
- [PDS.md](../spec/PDS.md): what the server does, with a page for each
area linked from it.
- [COMMANDS.md](../spec/COMMANDS.md): every method as an MCP tool and a
CLI command.
## Reference
- [Compatibility](../compat/README.md): how closely other PDSes behave
like the reference, and how to add one.
- [Benchmark](../bench/README.md): the server beside other PDSes, how to
run it and the fairness rules.
docs-site/src/content.config.tsnew+8−0
docs-site/src/theme.cssnew+119−0
docs-site/src/ThemeSelect.astronew+3−0
docs-site/.gitignorenew+4−0
docs-site/astro.config.mjsnew+100−0
docs-site/content.mjsnew+294−0
docs-site/package-lock.jsonnew+6464−0
A large diff, not shown.
docs-site/package.jsonnew+16−0
docs-site/plugins.mjsnew+84−0
spec/COMMANDS.md+8−0
spec/OAUTH-CLIENTS.md+4−0
spec/OAUTH-MCP.md+1−1
AGENTS.md+12−2
Dockerfile+2−2
README.md+12−319