# Tests and CI The configured Tangled workflow, `.tangled/workflows/ci.yml`, runs for branch pushes, pull requests, and manual runs. Formatting, unit tests, both HTTP smoke suites, the `@atproto/space` SDK interop lane and the x86_64 release build must all pass before a push to `main` deploys to Fly. The ARMv6 ReleaseSafe build and the property campaigns are their own workflows, `.tangled/workflows/armv6.yml` and `.tangled/workflows/campaigns.yml`, and so is the [interop lane](#interop), `.tangled/workflows/interop.yml`; they run on the same events but do not gate deployment, so a red one after a deploy needs a follow-up fix. Pull requests, other branches, and manual workflow runs never deploy. See [when no pipeline starts](https://tangled.org/zat.dev/zds/blob/main/docs/deployment.md#when-no-pipeline-starts) if a push does not start one. ## Local checks ```sh zig fmt --check build.zig build.zig.zon src bench tools just test just smoke-all git diff --check ``` `just smoke-all` builds the PDS and Spaces HTTP-signature helper once, then runs the public and permissioned suites concurrently. Each suite gets its own temporary database, blobstore, and response files. Default ports are 2585 (public PDS), 2586 (mock PLC), and 2587 (permissioned PDS). Both suites must succeed. Failed runs retain diagnostic files and print their directory; successful runs remove them. Avoid publishing raw diagnostics, which can contain test credentials. `just smoke` and `just smoke-permissioned` still work independently and build the binaries they need. The standalone permissioned suite defaults to 2586. Use `ZDS_SMOKE_PORT`, `ZDS_SMOKE_PLC_PORT`, and `ZDS_PERMISSIONED_SMOKE_PORT` to override the ports. To check the OAuth sign-in and consent pages in a browser, serve the local PDS over HTTPS with `dev/Caddyfile` and set `--public-url` to that origin. The pages rely on `__Host-` cookies, which Safari (including the iOS Simulator) does not keep on `http://localhost`, so on plain HTTP sign-in appears to succeed and then returns to the sign-in card. The smokes exercise the same contract without a browser. `just smoke-space-sdk` runs the permissioned suite with the [pinned `@atproto/space` SDK](https://tangled.org/zat.dev/zds/blob/main/docs/permissioned-data.md#sdk-interop-lane) checking ZDS's signatures, MACs, and STAR archives; it needs Node 22 and pnpm. `just smoke` and `just smoke-all` do not. CI keeps the pinned Zig compiler and package cache (`.ci-cache`) between runs on heavypad's spindle. Zig's build cache is not carried over: restored files get new inodes and zig 0.17 recompiles everything that reads them, so `tools/ci-checks.sh` compiles the x86_64 release in the background while the tests and smoke run, and the ARMv6 check and the campaigns are separate workflows that do not gate deploys. Every dependency is a tangled.org archive, and that endpoint rate-limits; `tools/ci-fetch.sh` runs `zig build --fetch` with six attempts and doubling backoff, and cuts off an attempt that stalls for five minutes (`FETCH_ATTEMPT_TIMEOUT`). Timings should distinguish cold compilation from warm test execution. No assertions, database durability settings, or cryptographic checks are relaxed for speed. ## interop `just interop` (`tools/interop/run.sh`) checks zds against other AT Protocol implementations instead of against its own expectations. It needs Go, Node 22, pnpm and Python 3, and takes under a minute once everything is built. It starts: - a PLC directory (`interop-check plc`) that validates every operation the way plc.directory does (signatures against the previous rotation keys, the DID derived from the genesis operation) and serves DID documents built from them; - zds, and the [reference PDS](https://github.com/bluesky-social/atproto/tree/main/packages/pds) pinned in `tools/interop/refpds`; - `interop-relay`, indigo's relay core (the code behind bsky.network) with its production validation, subscribed to zds. `tools/interop/scenario.py` then drives the same writes through each PDS: accounts, profile puts, posts, a blob, `applyWrites` batches, a few hundred records under fixed keys, deletes over fixed and server-chosen keys, swaps that lose, a handle change, and deactivation. While it runs: | check | what fails it | | --- | --- | | firehose, live and replayed from cursor 0 | a commit whose signature, CAR, `prevData`, `since`, rev order, op shape (sync 1.1 `prev` on updates and deletes) or MST inversion is wrong, or whose `data` is not the MST its records build | | goat | `goat firehose --verify-basic --verify-mst` warns | | repos | `getRepo` with a bad hash, signature or non-canonical MST; a repo that disagrees with the firehose, `getLatestCommit`, `getRepoStatus`, `listRecords`, `getRecord`, `sync.getRecord` proofs or `getBlob` bytes | | relay | the relay re-serves a different stream, or indigo's relay logs a warning about zds | | diff | a response differs from the reference's in status, error name, fields or values, beyond `tools/interop/known-differences.json` | The reference PDS runs the firehose, goat and repo checks too, and must pass them; that keeps the checkers honest. Values a server chooses (DIDs, revs, TIDs, tokens, commit CIDs) are normalized before the diff, but record and blob CIDs are compared as they are: identical record bytes hash the same everywhere. Fields only zds returns are listed and do not fail. A known difference needs a reason, and one that stops happening fails the run until it is removed. `goat` and indigo's default DID resolver refuse loopback addresses, so the signature and relay checks resolve through the harness's PLC with `tools/interop/check`, a Go module on indigo that also pins goat (`go tool goat`). Failed runs keep their directory: each lane has its server log, the transcript, `live.jsonl` (one line per firehose event) and the checkers' logs. The harness has no zds dependency, so a relay can reuse it. A relay's CI runs `tools/interop/run.sh` from a zds checkout with `INTEROP_RELAY_CMD` set to a command that starts the relay. The command gets `INTEROP_PLC_URL`, `INTEROP_PDS_HOST` (a plain-ws `host:port` to subscribe to), `INTEROP_RELAY_PORT` (serve `subscribeRepos` and `/_health` there) and `INTEROP_RELAY_DIR` (scratch space). The firehose it re-serves is checked like a PDS's and compared with the PDS's own. `INTEROP_RELAY_PDS=reference` puts the reference PDS under the relay instead, so the relay's CI needs no Zig; `INTEROP_LANES="reference relay"` skips zds entirely. ## generated cases and performance Substantial changes and critical request paths require adversarial review, replayable generated tests and relevant performance measurements before release. Keep production load tests separate from disposable local probes. The optional Hegel properties exercise MIME prefixes, collection-declaration changes, password-recovery histories and repo write histories against independent expectations: ```sh HEGEL_SEED=17 HEGEL_TEST_CASES=100 zig build fuzz -Dhegel -Doptimize=ReleaseSafe scripts/campaign run properties --out /tmp/zds-properties scripts/campaign calibrate calibration --out /tmp/zds-calibration ``` Hegel is pinned in `build.zig.zon` and is not needed for ordinary builds. `HEGEL_ZIG_REPLAY` replays its printed minimized failure; select that property's test with `-Dfuzz-filter='campaign MIME'`, `-Dfuzz-filter='campaign dynamic'`, `-Dfuzz-filter='campaign password'` or `-Dfuzz-filter='campaign repo'`. `scripts/campaign` runs `tools/fuzz/campaigns.zon` through hegel-zig's campaign runner on committed source in a disposable worktree. Each campaign declares the interactions every seed must reach (`.reach`); a seed that never, say, reopens the database reports `unreached` instead of passing. `calibration` plants the bugs in `tools/fuzz/mutants.zon` one at a time and requires each to be caught. CI runs the `properties` campaign. The repo write property drives `applyWrites` with creates, puts, deletes, multi-operation batches, stale record and commit swaps, and reopening the SQLite file. After every step it compares each record with a model, decodes the stored block, and verifies the exported repo CAR's signature, MST and record count. Known violations it tolerates are counted in its report and listed in the property's source. The properties use temporary SQLite databases, synthetic accounts and cached declaration fixtures; they do not contact a PDS, DNS or a mail provider. SQLite, entropy and scheduling remain real: this is property testing, not deterministic I/O simulation. Focused performance probes: ```sh zig build bench -Doptimize=ReleaseFast -- --scenario password zig build bench-space-auth -Doptimize=ReleaseFast zig run -O ReleaseFast --dep blob_mime -Mroot=bench/blob_mime.zig -Mblob_mime=src/internal/blob_mime.zig zig build smoke-build -Doptimize=ReleaseFast uv run bench/account_spaces_http.py zig-out/bin/zds ``` The HTTP probe starts its own loopback server and seeds a disposable account; it reports latency percentiles at concurrency eight. Compare binaries using the same harness (`--legacy` omits reset routes absent before v0.14.15), after builds have finished. Cached scope timing includes declaration JSON parsing, expansion and permission matching; it excludes DNS and remote declaration fetches.