Files
Warp/server/test/complement
tajniak81andClaude Opus 5.5 92836f8dcd
CI / Test (ubuntu-latest) (push) Canceled after 0s
CI / Test (windows-latest) (push) Canceled after 0s
CI / Storage tests on PostgreSQL (push) Canceled after 0s
CI / Complement (federation off) (push) Canceled after 0s
CI / golangci-lint (push) Canceled after 0s
CI / Smoke test the binary (push) Canceled after 0s
Phase 6: media
Implements PLAN.md Phase 6: the media repository. Clients upload files,
reserve an mxc:// URI and upload to it later, download and ask for
thumbnails, all through the authenticated media endpoints of Matrix 1.11;
other servers download this server's media through the federation media
endpoints, and media uploaded elsewhere is fetched over federation on
first use and kept.

internal/mediaapi is the component. Content goes into a BlobStore named
by its SHA-256, so the same file uploaded twice is stored once and the
hash doubles as the ETag; the metadata that maps an mxc:// URI onto a
blob is in media_repository and media_thumbnails. The local-filesystem
store writes to a temporary file and renames it into place once hashed,
so nothing ever refers to half a file. A storage driver can bring its own
store through storage.BlobProvider, which is where PocketBase's
filesystem abstraction (local or S3) plugs in with Phase 10.

Reserved uploads belong to the user who made them, take one upload,
lapse after a day, and are capped per user; a download of one waits for
its content, woken in memory the moment it arrives, for as long as
timeout_ms allows.

Thumbnails come from a fixed set of configured sizes, so a thousand
requested sizes cannot mean a thousand resizes. They are made on first
request and kept, never enlarge, honour a JPEG's EXIF orientation, and
point at the original when it already fits. The pixel count is checked
from the header before anything is decoded, at most four resizes run at
once, and concurrent requests for the same thumbnail share one.

Remote media is fetched through the signed client: the multipart/mixed
answer of Matrix 1.11, with a fallback to the legacy download endpoint
for servers that answer M_UNRECOGNIZED, and Location redirects followed
by a dialer that refuses loopback, private and link-local addresses.
Concurrent requests share one fetch, detached from the request that
started it. With federation off nothing is fetched, and what was cached
before is still served.

Downloads carry a sandboxing CSP, nosniff, inline Content-Disposition
only for the types the spec lists as safe, and private immutable caching.
The unauthenticated legacy download endpoints are off by default behind
media.legacy_unauthenticated_downloads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 21:26:49 +02:00
..
2026-10-16 17:14:20 +02:00
2026-10-16 21:26:49 +02:00
2026-10-16 17:14:20 +02:00
2026-10-16 21:26:49 +02:00

Complement

Complement is the official Matrix integration suite and this project's primary progress metric (PLAN.md section 9). It runs one container per homeserver per test and drives it over the real HTTP API.

make complement                          # the C-S set, federation off
make complement-federation               # the federation set
bash run.sh TestLogin                    # one test
COMPLEMENT_DEBUG=1 make complement       # with the container logs

Needs Docker. run.sh builds the image, clones Complement into .complement/ at the repository root (git-ignored) and runs the subset for the phases that are done.

Files

Dockerfile the homeserver image, built from the repository root
entrypoint.sh the deployment, entirely WARP_* environment variables
run.sh build, clone, run

Profiles

COMPLEMENT_PROFILE picks one; each has its own test set in run.sh.

csapi (the default, make complement) — the Client-Server tests in tests/csapi, with WARP_FEDERATION_ENABLED=false. Port 8448 is still served over TLS, because the CA is mounted either way, but the gate answers every federation request with M_UNRECOGNIZED.

federation (make complement-federation) — the federation tests in tests/ and the multi-server tests in tests/csapi, with federation on. The entrypoint has Complement's CA at /complement/ca sign a certificate for the server's name, serves the API on 8448 with it, and points federation.tls_ca_file at the same CA, so that Warp trusts the other homeservers of the run and the servers Complement itself pretends to be. The switch reaches the container through COMPLEMENT_SHARE_ENV_PREFIX: run.sh sets PASS_WARP_FEDERATION_ENABLED, which Complement passes on as WARP_FEDERATION_ENABLED.

The federation set leaves out partial-state joins (MSC3706, TestPartialStateJoin*), which Warp does not implement, and anything that needs application services (Phase 9) or device lists (Phase 7).

The test set

COMPLEMENT_TESTS in run.sh lists what is expected to pass. Phase 1:

  • TestRegistration
  • TestLogin
  • TestDeviceManagement

Extend it as each phase lands rather than switching to the whole suite: a pass count that drops because a later phase is missing is noise, not information.

Two notes on the environment, both in entrypoint.sh:

  • Rate limiting is off. The whole suite comes from the one address the test runner has, so the limiter would spend the run returning M_LIMIT_EXCEEDED and tell us nothing about the server. Synapse's own Complement image does the same.
  • Registration is on, because the tests create their own users.

Tests that need later phases

Some subtests of the three above reach for endpoints that are not Phase 1 work. TestDeviceManagement calls /sync after creating a session, and TestLogout checks that a revoked token cannot sync. Phase 1 answers /sync with an empty but well-formed response for exactly that reason — there are no rooms yet, so an empty sync is the complete truth, and it makes token revocation observable. Phase 4 replaces it with the real syncapi.

The shared-secret registration subtests of TestRegistration probe /_synapse/admin/v1/register and skip themselves when it 404s, which it does here: that endpoint is Synapse's, and warp create-account covers the same need.